@attabot/complaint-app

中文文档
1.0.52发布于 2026/11/06MITTypeScriptESM + CJS近 30 天下载 4096

Complaint Management UI package — atomic React components that run on the parent app's auth and API

原始使用文档
文档目录12 节
  1. Installation
  2. Usage
  3. Theme & dark mode (parent-controlled)
  4. Pass data from the parent (no fetch)
  5. Props
  6. Atomic structure
  7. Auth & API
  8. Redux and router integration
  9. Development
  10. License
  11. Parent-owned catalogs
  12. Company context

@attabot/complaint-app

Complaint Management UI as an npm package. Built with atomic design (atoms → molecules → organisms) so the parent app can mount a ready dashboard that uses the parent’s auth token and API base URL.

Installation

npm install @attabot/complaint-app

Peer dependencies:

npm install react react-dom react-redux @reduxjs/toolkit

Usage

import ComplaintApp from '@attabot/complaint-app';
import '@attabot/complaint-app/style.css';
import brandTheme from './brandTheme.json'; // static theme file

function App() {
  const [darkMode, setDarkMode] = useState(false); // owned by parent

  return (
    <ComplaintApp
      apiUrl="https://your-api.example.com"
      authToken={sessionToken}
      theme={brandTheme}
      darkMode={darkMode}
      systemsEndpoint="/api/v1/complaint-systems"
      onCreateForm={() => navigate('/forms/new')}
      onConfigure={(system) => navigate(`/systems/${system.id}`)}
    />
  );
}

Theme & dark mode (parent-controlled)

Pass a static theme file (JSON/JS) and toggle darkMode from the parent. The package applies CSS variables across the whole UI.

import brandTheme from './brandTheme.json';

<ComplaintApp theme={brandTheme} darkMode={isDark} />

Theme file shape:

{
  "light": { "colors": { "primary": "#2D64B8", "background": "#F5F5F5" } },
  "dark":  { "colors": { "primary": "#5B8DEF", "background": "#0F1115" } }
}

Or pass flat overrides (merged into both modes):

<ComplaintApp theme={{ colors: { primary: '#0F766E' } }} darkMode={false} />

Helpers / defaults are exported: lightTheme, darkTheme, defaultThemeFile, useTheme.

Pass data from the parent (no fetch)

<ComplaintApp
  apiUrl={apiUrl}
  authToken={authToken}
  useDemoData={false}
  systems={[
    {
      id: 'qms',
      title: 'QMS - Query Management System',
      status: 'active',
      description: 'Description of the template',
      departments: 3,
      workflows: 12,
      fields: 55,
      formsFilled: 234,
      updatedOn: '12 Mar 2024',
      titleAsLink: true,
    },
  ]}
  onCreateForm={handleCreate}
  onConfigure={handleConfigure}
/>

Props

PropTypeDefaultDescription
apiUrlstringenv VITE_API_URLBase URL for axios requests
authTokenstring—Bearer token stored for API calls
themeobjectbuilt-in light/darkStatic theme file or token overrides
darkModebooleanfalseParent-controlled dark mode
basePathstring'/'React Router basename when nested
systemsarray—Parent-controlled system list
systemsEndpointstring—GET path relative to apiUrl
useDemoDatabooleantrueShow design demo cards when no data
titlestring'Complaint Management'Page title
descriptionstringlorem placeholderPage subtitle
createLabelstring'Create New Form'Primary CTA label
onCreateFormfn—Create button handler
onConfigurefn(system)—Configure button handler
onTitleClickfn(system)—Title link click
onDescriptionClickfn—Description link click
onSearchfn(query)—Search change callback
onPublishfn—Review & Publish handler
onStepChangefn—Settings step change callback

Atomic structure

src/components/
  atoms/       Button, Input, Typography, StatusBadge, Divider, Icons, Loading
  molecules/   SearchBar, DataPoint, CardHeader, CardFooter
  organisms/   PageHeader, SystemCard, SystemCardGrid

Named exports are available for reuse in the parent:

import { Button, SearchBar, SystemCard, api } from '@attabot/complaint-app';

Auth & API

  1. Parent passes apiUrl + authToken into ComplaintApp / ApiProvider.
  2. Package axios client (api) keeps the passed token in memory and attaches Authorization: Bearer … immediately before every request. It does not overwrite the parent app's auth cookie.
  3. Optional token refresh against POST /api/v1/auth/refresh when a refreshToken cookie exists.
  4. No product/business APIs are hardcoded — provide systems or systemsEndpoint.

Redux and router integration

When mounted inside a parent react-redux Provider, ComplaintApp automatically reuses that Provider instead of adding a second competing Redux context. When used standalone it falls back to its own store. Pass the store prop only when you explicitly want an isolated store.

The same rule applies to React Router: an existing parent router is reused; a BrowserRouter is only created for standalone use.

Development

npm install
npm run dev      # preview Complaint Management UI
npm run build    # emit dist/ for publishing

License

MIT

Parent-owned catalogs

Pass roleList, userList, and storeList from the parent application (for example, its Redux selectors). Each entry has an id and a name or label. The parent loads these catalogs; the package uses roles and users in category/workflow selectors and stores in Store ID controls in the complaint form and preview. Updates to the props are reflected on rerender. Store controls submit IDs. Complaint types, workflows, fields, statuses, and complaint submissions continue using the complaint API. Pass the signed-in user as currentUser; when the company prop is omitted, the package also uses currentUser.company for company-specific location labels.

<ComplaintApp apiUrl={complaintApiUrl} authToken={token}
  roleList={roleList} storeList={storeList} useDemoData={false} />

The legacy rolelist prop remains an alias; roleList takes precedence. Missing roles default to an empty list. If storeList is omitted, Store ID fields retain their API-defined controls/options; an explicitly supplied empty array renders an empty store selector. The package keeps its own Redux provider unless an explicit store is supplied.

Company context

Pass the parent company object using company={company}. If omitted, the package uses currentUser.company when available. The package forwards the resolved object with page props and synchronizes it to state.appDetails.details.company, so nested components can read it through the existing package Redux provider. Parent updates replace the company object; passing null clears it. The package does not fetch company details.

Visible location labels use company.level4 (for example, Branch ID and Select Branch). Missing or blank names fall back to Store. Field keys, IDs, saved data, and dependency values retain their original values.

版本与发布记录

@attabot/complaint-app 共发布 52 个版本,首次发布于 2026/08/05;过去 12 个月发布了 52 个版本。

版本发布日期距今
1.0.52latest2026/11/061 天前
1.0.512026/11/052 天前
1.0.502026/11/043 天前
1.0.492026/11/025 天前
1.0.482026/10/317 天前
1.0.472026/10/318 天前

关于 @attabot/complaint-app 的常见问题

@attabot/complaint-app 是什么?

Complaint Management UI package — atomic React components that run on the parent app's auth and API

如何安装 @attabot/complaint-app?

在项目目录运行 npm install @attabot/complaint-app,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ^19.0.0)、react-dom(^18.0.0 || ^19.0.0)、react-redux(>=8)、@reduxjs/toolkit(>=1.9)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@attabot/complaint-app 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@attabot/complaint-app 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@attabot/complaint-app 可以商用吗?

@attabot/complaint-app 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@attabot/complaint-app 的下载量有多少?

根据 npm 官方下载统计,@attabot/complaint-app 在 2026/10/07 – 2026/11/05 这 30 天内被下载 4,096 次,日均约 137 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@attabot/complaint-app 还在维护吗?

最新版本 1.0.52 发布于 2026/11/06(1 天前);至今共发布 52 个版本,其中过去 12 个月发布了 52 个;首次发布于 2026/08/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。