@open-mercato/ui 0.6.3-develop.3810.1.ad92c339f5 → 0.6.3-develop.3811.1.be22750402
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +39 -4
- package/package.json +3 -3
- package/src/backend/AGENTS.md +23 -4
package/AGENTS.md
CHANGED
|
@@ -4,6 +4,41 @@ UI usage patterns based on customers, sales, and staff modules. Use these defaul
|
|
|
4
4
|
|
|
5
5
|
> **DS reference:** [`.ai/ds-rules.md`](../../.ai/ds-rules.md) — color tokens, typography, spacing, decision trees. **Component reference (variants/sizes/props/examples/MUST rules):** [`.ai/ui-components.md`](../../.ai/ui-components.md).
|
|
6
6
|
|
|
7
|
+
## Always
|
|
8
|
+
|
|
9
|
+
- Use existing UI primitives and backend components before creating new ones.
|
|
10
|
+
- Use `CrudForm` for create/edit flows and dialog forms unless the task explicitly needs a custom host.
|
|
11
|
+
- Use `DataTable` as the default list view, including portal list pages.
|
|
12
|
+
- Use `apiCall`/`apiCallOrThrow` for backend and portal data calls.
|
|
13
|
+
- Use `useGuardedMutation` for every write that cannot use `CrudForm`.
|
|
14
|
+
- Use i18n keys and `useT()` for user-facing copy.
|
|
15
|
+
- Keep UMES spot IDs, replacement handles, field/group IDs, and portal page metadata stable.
|
|
16
|
+
- Follow `.ai/ds-rules.md` and `.ai/ui-components.md` for tokens, primitives, and component contracts.
|
|
17
|
+
|
|
18
|
+
## Ask First
|
|
19
|
+
|
|
20
|
+
- Ask before changing primitive APIs, DataTable/CrudForm contracts, portal shell behavior, frozen portal spots, or replacement handles.
|
|
21
|
+
- Ask before creating a new primitive or backend component when an existing component might fit.
|
|
22
|
+
- Ask before changing default interaction patterns for dialogs, bulk actions, row clicks, or portal navigation.
|
|
23
|
+
|
|
24
|
+
## Never
|
|
25
|
+
|
|
26
|
+
- Never use raw `<button>`, raw checkbox inputs, or raw `<Link>` styled as a button.
|
|
27
|
+
- Never use raw `fetch` in UI data flows where `apiCall` is available.
|
|
28
|
+
- Never hard-code user-facing strings.
|
|
29
|
+
- Never use `window.confirm`; use the shared confirmation dialog.
|
|
30
|
+
- Never add custom per-page progress bars for DataTable bulk work.
|
|
31
|
+
- Never omit `page.meta.ts` for guarded portal pages.
|
|
32
|
+
- Never gate wildcard feature arrays with `includes(...)` or `Set.has(...)`.
|
|
33
|
+
|
|
34
|
+
## Validation Commands
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
yarn workspace @open-mercato/ui test
|
|
38
|
+
yarn workspace @open-mercato/ui build
|
|
39
|
+
yarn i18n:check
|
|
40
|
+
```
|
|
41
|
+
|
|
7
42
|
## Reference Modules
|
|
8
43
|
|
|
9
44
|
- Customers: `packages/core/src/modules/customers/backend/customers/people/create/page.tsx`, `…/people/page.tsx`, `…/components/detail/TaskForm.tsx`
|
|
@@ -45,7 +80,7 @@ When you need… use this. Details (variants, sizes, props, MUST rules) live in
|
|
|
45
80
|
| Breadcrumb navigation (DS-aligned, slash/arrow/dot divider, ARIA correct) | `Breadcrumb` (with `BreadcrumbList` / `BreadcrumbItem` / `BreadcrumbLink` / `BreadcrumbPage` / `BreadcrumbStatic` / `BreadcrumbSeparator` / `BreadcrumbEllipsis`) | `@open-mercato/ui/primitives/breadcrumb` |
|
|
46
81
|
| Wrap a `<Link>` as button | `Button asChild` / `IconButton asChild` | — |
|
|
47
82
|
|
|
48
|
-
## Critical
|
|
83
|
+
## Critical Primitive Rules
|
|
49
84
|
|
|
50
85
|
1. **NEVER use raw `<button>` or `<input type="checkbox">`** — always use the primitives. Native checkboxes get `accent-color: var(--accent-indigo)` as a safety net for legacy code, but new code MUST use `Checkbox`.
|
|
51
86
|
2. **Always pass `type="button"` explicitly** on non-submit `Button`/`IconButton` — HTML defaults to `submit`.
|
|
@@ -119,7 +154,7 @@ import { Avatar, AvatarStack } from '@open-mercato/ui/primitives/avatar'
|
|
|
119
154
|
// renders: JK · OZ · AN · +1
|
|
120
155
|
```
|
|
121
156
|
|
|
122
|
-
###
|
|
157
|
+
### Usage Rules
|
|
123
158
|
|
|
124
159
|
- NEVER render `<div className="rounded-full bg-muted ...">` for avatars — use `Avatar`
|
|
125
160
|
- `size="sm"` uses `text-[9px]` — DS exception for tiny initials (same as notification badge count)
|
|
@@ -157,7 +192,7 @@ import { Kbd, KbdShortcut } from '@open-mercato/ui/primitives/kbd'
|
|
|
157
192
|
</span>
|
|
158
193
|
```
|
|
159
194
|
|
|
160
|
-
###
|
|
195
|
+
### Usage Rules
|
|
161
196
|
|
|
162
197
|
- NEVER use raw `<span>` or `<code>` to display keyboard keys — use `Kbd`
|
|
163
198
|
- Platform-specific keys (`⌘` vs `Ctrl`): detect with `navigator.platform` or use `Ctrl/⌘` text when cross-platform
|
|
@@ -220,7 +255,7 @@ const leadTagMap: TagMap<'customer' | 'hot' | 'inactive' | 'renewal'> = {
|
|
|
220
255
|
<Tag variant={leadTagMap[tag.type]} dot>{tag.label}</Tag>
|
|
221
256
|
```
|
|
222
257
|
|
|
223
|
-
###
|
|
258
|
+
### Usage Rules
|
|
224
259
|
|
|
225
260
|
- NEVER hardcode colors on `Tag` — use variants only
|
|
226
261
|
- Use `dot` for tags that represent a status-like category (Customer, Hot); omit for purely descriptive labels
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/ui",
|
|
3
|
-
"version": "0.6.3-develop.
|
|
3
|
+
"version": "0.6.3-develop.3811.1.be22750402",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -141,13 +141,13 @@
|
|
|
141
141
|
"remark-gfm": "^4.0.1"
|
|
142
142
|
},
|
|
143
143
|
"peerDependencies": {
|
|
144
|
-
"@open-mercato/shared": "0.6.3-develop.
|
|
144
|
+
"@open-mercato/shared": "0.6.3-develop.3811.1.be22750402",
|
|
145
145
|
"react": ">=18.0.0",
|
|
146
146
|
"react-dom": ">=18.0.0",
|
|
147
147
|
"react-is": ">=18.0.0"
|
|
148
148
|
},
|
|
149
149
|
"devDependencies": {
|
|
150
|
-
"@open-mercato/shared": "0.6.3-develop.
|
|
150
|
+
"@open-mercato/shared": "0.6.3-develop.3811.1.be22750402",
|
|
151
151
|
"@testing-library/dom": "^10.4.1",
|
|
152
152
|
"@testing-library/jest-dom": "^6.9.1",
|
|
153
153
|
"@testing-library/react": "^16.3.1",
|
package/src/backend/AGENTS.md
CHANGED
|
@@ -2,15 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
Use `@open-mercato/ui/backend` for all admin/backend page components. See `packages/ui/AGENTS.md` for full UI patterns.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Always
|
|
6
6
|
|
|
7
7
|
1. **MUST set stable `id` values on `RowActions` items** — use `edit`, `open`, `delete`, etc. DataTable resolves default row-click behavior from these ids
|
|
8
8
|
2. **MUST use `apiCall`/`apiCallOrThrow`** from `@open-mercato/ui/backend/utils/apiCall` — never use raw `fetch`
|
|
9
9
|
3. **MUST use `LoadingMessage`/`ErrorMessage`** from `@open-mercato/ui/backend/detail` for loading and error states
|
|
10
|
-
4. **MUST
|
|
10
|
+
4. **MUST use `useT()`** for all labels and messages
|
|
11
11
|
5. **MUST use `useGuardedMutation` when not using `CrudForm`** — wrap every write operation (`POST`/`PUT`/`PATCH`/`DELETE`) in `runMutation({ operation, context, mutationPayload })` so global mutation injections (record locks, conflict UI, future guards) run consistently
|
|
12
|
-
6. **MUST use `Button` or `IconButton`** for every interactive button
|
|
13
|
-
7. **MUST treat missing records as a dedicated page-level state** — distinguish `notFound` from generic `error`, return early, and render a shared `ErrorMessage`-based state with a clear recovery action (for example, back to the owning list page).
|
|
12
|
+
6. **MUST use `Button` or `IconButton`** for every interactive button. Use `IconButton` for icon-only buttons, `Button` for everything else. Always pass `type="button"` explicitly on non-submit buttons. See `packages/ui/AGENTS.md` → Button and IconButton Usage for full patterns and variant reference.
|
|
13
|
+
7. **MUST treat missing records as a dedicated page-level state** — distinguish `notFound` from generic `error`, return early, and render a shared `ErrorMessage`-based state with a clear recovery action (for example, back to the owning list page).
|
|
14
|
+
|
|
15
|
+
## Ask First
|
|
16
|
+
|
|
17
|
+
- Ask before changing DataTable row-click defaults, UMES host surface IDs, CrudForm event behavior, or replacement handles.
|
|
18
|
+
- Ask before introducing backend-page write flows that do not fit `CrudForm` or `useGuardedMutation`.
|
|
19
|
+
|
|
20
|
+
## Never
|
|
21
|
+
|
|
22
|
+
- Never use raw `fetch` from backend UI components.
|
|
23
|
+
- Never hard-code user-facing strings.
|
|
24
|
+
- Never use raw `<button>` elements.
|
|
25
|
+
- Never render `CrudForm`, detail sections, tabs, or record actions when the record is missing.
|
|
26
|
+
|
|
27
|
+
## Validation Commands
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn workspace @open-mercato/ui test
|
|
31
|
+
yarn workspace @open-mercato/ui build
|
|
32
|
+
```
|
|
14
33
|
|
|
15
34
|
## DataTable Row-Click Behavior
|
|
16
35
|
|