@mgamadeus/ddd-admin-ui 0.1.0-rc.4 → 0.1.0-rc.5
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/.claude/skills/ddd-admin-ui-specialist/SKILL.md +8 -0
- package/CHANGELOG.md +48 -0
- package/README.md +19 -3
- package/STANDARDS.md +25 -1
- package/dist/components.css +2 -2
- package/dist/form/FormActions.d.ts.map +1 -1
- package/dist/form/FormActions.js +7 -2
- package/dist/form/FormActions.js.map +1 -1
- package/dist/i18n/hints.json +11 -7
- package/dist/i18n-keys.json +45 -8
- package/dist/list/Combobox.d.ts +33 -3
- package/dist/list/Combobox.d.ts.map +1 -1
- package/dist/list/Combobox.js +71 -13
- package/dist/list/Combobox.js.map +1 -1
- package/dist/list/CopyButton.d.ts +23 -0
- package/dist/list/CopyButton.d.ts.map +1 -0
- package/dist/list/CopyButton.js +28 -0
- package/dist/list/CopyButton.js.map +1 -0
- package/dist/list/EntityListBody.d.ts +2 -2
- package/dist/list/EntityListBody.d.ts.map +1 -1
- package/dist/list/EntityListBody.js +2 -2
- package/dist/list/EntityListBody.js.map +1 -1
- package/dist/list/EntityListEmpty.d.ts +6 -1
- package/dist/list/EntityListEmpty.d.ts.map +1 -1
- package/dist/list/EntityListEmpty.js +4 -1
- package/dist/list/EntityListEmpty.js.map +1 -1
- package/dist/list/EntityListTable.d.ts +3 -1
- package/dist/list/EntityListTable.d.ts.map +1 -1
- package/dist/list/EntityListTable.js +4 -4
- package/dist/list/EntityListTable.js.map +1 -1
- package/dist/list/filters.d.ts +8 -1
- package/dist/list/filters.d.ts.map +1 -1
- package/dist/list/filters.js +5 -2
- package/dist/list/filters.js.map +1 -1
- package/dist/list/index.d.ts +2 -0
- package/dist/list/index.d.ts.map +1 -1
- package/dist/list/index.js +1 -0
- package/dist/list/index.js.map +1 -1
- package/dist/logic/browser/storage.d.ts +17 -0
- package/dist/logic/browser/storage.d.ts.map +1 -0
- package/dist/logic/browser/storage.js +40 -0
- package/dist/logic/browser/storage.js.map +1 -0
- package/dist/logic/index.d.ts +7 -0
- package/dist/logic/index.d.ts.map +1 -1
- package/dist/logic/index.js +4 -0
- package/dist/logic/index.js.map +1 -1
- package/dist/logic/pure/confirm.d.ts +4 -0
- package/dist/logic/pure/confirm.d.ts.map +1 -1
- package/dist/logic/pure/confirm.js.map +1 -1
- package/dist/logic/pure/dateInput.d.ts +21 -0
- package/dist/logic/pure/dateInput.d.ts.map +1 -0
- package/dist/logic/pure/dateInput.js +79 -0
- package/dist/logic/pure/dateInput.js.map +1 -0
- package/dist/logic/pure/stickyParams.d.ts +10 -0
- package/dist/logic/pure/stickyParams.d.ts.map +1 -0
- package/dist/logic/pure/stickyParams.js +31 -0
- package/dist/logic/pure/stickyParams.js.map +1 -0
- package/dist/logic/react/useLatestSearch.d.ts +18 -0
- package/dist/logic/react/useLatestSearch.d.ts.map +1 -0
- package/dist/logic/react/useLatestSearch.js +37 -0
- package/dist/logic/react/useLatestSearch.js.map +1 -0
- package/dist/logic/react/useRowSelection.d.ts +12 -2
- package/dist/logic/react/useRowSelection.d.ts.map +1 -1
- package/dist/logic/react/useRowSelection.js +16 -8
- package/dist/logic/react/useRowSelection.js.map +1 -1
- package/dist/next/storage.d.ts +2 -10
- package/dist/next/storage.d.ts.map +1 -1
- package/dist/next/storage.js +2 -33
- package/dist/next/storage.js.map +1 -1
- package/dist/page/DefinitionList.d.ts +7 -2
- package/dist/page/DefinitionList.d.ts.map +1 -1
- package/dist/page/DefinitionList.js +4 -1
- package/dist/page/DefinitionList.js.map +1 -1
- package/dist/page/EntityDetailShell.d.ts +2 -2
- package/dist/page/EntityDetailShell.d.ts.map +1 -1
- package/dist/page/EntityDetailShell.js +3 -2
- package/dist/page/EntityDetailShell.js.map +1 -1
- package/dist/page/EntityListPage.d.ts +3 -1
- package/dist/page/EntityListPage.d.ts.map +1 -1
- package/dist/page/EntityListPage.js +1 -1
- package/dist/page/EntityListPage.js.map +1 -1
- package/dist/page/EntityTabs.d.ts +2 -2
- package/dist/page/EntityTabs.d.ts.map +1 -1
- package/dist/page/EntityTabs.js +3 -2
- package/dist/page/EntityTabs.js.map +1 -1
- package/dist/page/PageFrame.d.ts +6 -1
- package/dist/page/PageFrame.d.ts.map +1 -1
- package/dist/page/PageFrame.js +1 -1
- package/dist/page/PageFrame.js.map +1 -1
- package/dist/page/PageToolbar.d.ts +2 -2
- package/dist/page/PageToolbar.d.ts.map +1 -1
- package/dist/page/PageToolbar.js +3 -2
- package/dist/page/PageToolbar.js.map +1 -1
- package/dist/page/SectionHeader.d.ts +1 -1
- package/dist/page/SectionHeader.d.ts.map +1 -1
- package/dist/page/links.d.ts +2 -17
- package/dist/page/links.d.ts.map +1 -1
- package/dist/page/links.js +3 -3
- package/dist/page/links.js.map +1 -1
- package/dist/primitives/breadcrumb.d.ts.map +1 -1
- package/dist/primitives/breadcrumb.js +7 -0
- package/dist/primitives/breadcrumb.js.map +1 -1
- package/dist/primitives/command.js +1 -1
- package/dist/primitives/command.js.map +1 -1
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +1 -0
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/link.d.ts +28 -0
- package/dist/primitives/link.d.ts.map +1 -0
- package/dist/primitives/link.js +15 -0
- package/dist/primitives/link.js.map +1 -0
- package/dist/primitives/segmented-control.d.ts +8 -0
- package/dist/primitives/segmented-control.d.ts.map +1 -1
- package/dist/primitives/segmented-control.js +24 -6
- package/dist/primitives/segmented-control.js.map +1 -1
- package/dist/provider/AdminUiProvider.d.ts +3 -3
- package/dist/provider/AdminUiProvider.d.ts.map +1 -1
- package/dist/provider/AdminUiProvider.js +5 -4
- package/dist/provider/AdminUiProvider.js.map +1 -1
- package/dist/provider/types.d.ts +6 -0
- package/dist/provider/types.d.ts.map +1 -1
- package/dist/showcase/coverage.d.ts.map +1 -1
- package/dist/showcase/coverage.js +4 -1
- package/dist/showcase/coverage.js.map +1 -1
- package/dist/showcase/sections/ListShowcase.d.ts.map +1 -1
- package/dist/showcase/sections/ListShowcase.js +36 -6
- package/dist/showcase/sections/ListShowcase.js.map +1 -1
- package/dist/showcase/sections/PageShowcase.d.ts.map +1 -1
- package/dist/showcase/sections/PageShowcase.js +5 -1
- package/dist/showcase/sections/PageShowcase.js.map +1 -1
- package/dist/showcase/sections/PrimitivesShowcase.d.ts.map +1 -1
- package/dist/showcase/sections/PrimitivesShowcase.js +2 -2
- package/dist/showcase/sections/PrimitivesShowcase.js.map +1 -1
- package/dist/translations/TranslationControls.d.ts.map +1 -1
- package/dist/translations/TranslationControls.js +8 -6
- package/dist/translations/TranslationControls.js.map +1 -1
- package/package.json +2 -2
|
@@ -24,6 +24,10 @@ installed package (`node_modules/@mgamadeus/ddd-admin-ui/`). This skill reaches
|
|
|
24
24
|
| a wide table: column tracks, pinned columns, sortable headers, row numbers | `EntityListColumn` `width` / `minWidth` / `pin` / `align` / `sortKey` + `sort` / `onSortChange` / `showRowIndex` | list |
|
|
25
25
|
| the sort in the URL | `formatListSort` / `parseListSort` / `nextListSort` (`key:asc`; `sortStart`, `sortRequired`) | logic |
|
|
26
26
|
| one value out of a few (period, scope, view) | `SegmentedControl` (not tabs, not toggle chips) | primitives |
|
|
27
|
+
| a picker over a server search, with clear / create | `Combobox` `onSearch` + `useLatestSearch`, `clearable`, `onRequestCreate` | list, logic |
|
|
28
|
+
| copy a value next to it | `CopyButton` | list |
|
|
29
|
+
| one router link for every block, sticky search parameters | `AdminUiProvider.linkComponent` + `withStickyParams` | provider, logic |
|
|
30
|
+
| a `type="date"` / `datetime-local` value | `toDateInputValue` / `fromDateTimeInputValue` … with `'local'` or `'utc'` | logic |
|
|
27
31
|
| see every block in the host theme, light and dark | `Showcase` on a development route | showcase |
|
|
28
32
|
| a view that loads its own data (a tree) in the list card | `EntityListBody.renderOwnView` | list |
|
|
29
33
|
| an entity detail with tabs | `EntityDetailShell` (+ `SectionHeader`, `DefinitionList`) | page |
|
|
@@ -62,6 +66,10 @@ installed package (`node_modules/@mgamadeus/ddd-admin-ui/`). This skill reaches
|
|
|
62
66
|
- **SegmentedControl** is a radio group: exactly one value, one tab stop, arrows select (`activation="manual"`: Space /
|
|
63
67
|
Enter). Tooltips (`iconOnly`, `disabledReason`) need `AdminUiProvider`. Corner and slide come from
|
|
64
68
|
`--segmented-control-radius` / `--segmented-control-duration`.
|
|
69
|
+
- **Combobox server search**: pass `onSearch` and `isSearching` (from `useLatestSearch`, which drops answers to older
|
|
70
|
+
terms); the block debounces and never shows the previous term's options. A picked value outside the results needs
|
|
71
|
+
`selectedOption`.
|
|
72
|
+
- **Links**: set `linkComponent` once on `AdminUiProvider`; without it blocks render plain `<a>` (full page loads).
|
|
65
73
|
- **Showcase** needs no optional peer: pass `loadNotifySonner={() => import('@mgamadeus/ddd-admin-ui/notify-sonner')}`
|
|
66
74
|
only when sonner is installed. A new block gets a showcase sample and a `SHOWCASE_COVERAGE` entry, or the checks fail.
|
|
67
75
|
- **Text contexts are literals.** `m('Failed', { context: 'import-status' })`: extractors (the package manifest and
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,54 @@
|
|
|
3
3
|
All notable changes to `@mgamadeus/ddd-admin-ui`. 0.x: each minor may break; pin the exact version while the package
|
|
4
4
|
is in 0.x prereleases.
|
|
5
5
|
|
|
6
|
+
## 0.1.0-rc.5
|
|
7
|
+
|
|
8
|
+
- `EntityListTable` / `EntityListBody`: `rowClassName(item, index)` for extra row classes.
|
|
9
|
+
- `useRowSelection`: `isSelectable(item)`. A row it refuses gets a disabled checkbox; "Select all loaded", the header
|
|
10
|
+
state, the count and `selectedKeys` take selectable rows only. `EntityListSelection` gains the optional
|
|
11
|
+
`isItemSelectionDisabled` (a row without a key still gets no checkbox).
|
|
12
|
+
- `Combobox`: `clearable` (a clear control; re-picking the picked option clears; without it the value is kept, as
|
|
13
|
+
before), `onSearch` (server search: no client filtering, debounced 300 ms, `''` on close; the list never shows the
|
|
14
|
+
previous term's options) with `isSearching`, option `group` (headings in first-appearance order) and `badge`,
|
|
15
|
+
`onRequestCreate` (a "Create “…”" row while no label equals the trimmed term), `selectedOption` (the label of a picked
|
|
16
|
+
value outside the options), `popoverClassName`; `COMBOBOX_SEARCH_DEBOUNCE_MS`. With `clearable`, `className` sizes a
|
|
17
|
+
wrapper around trigger and clear control.
|
|
18
|
+
- `./logic`: `useLatestSearch` (only the answer to the last term counts; aborts the previous request), date input
|
|
19
|
+
values `toDateInputValue`, `fromDateInputValue`, `toDateTimeInputValue`, `fromDateTimeInputValue` with an explicit
|
|
20
|
+
`'local' | 'utc'` zone (`DateInputZone`), `withStickyParams(href, names, currentSearch)`, the guarded storage helpers
|
|
21
|
+
`readStored` / `writeStored` (`StorageArea`, moved from the Next adapters, which use them from here) and
|
|
22
|
+
`buildStorageKey(prefix, area, name)` → `<prefix>.<area>.<name>`.
|
|
23
|
+
- `CopyButton` in `./list`: `value`, `label`, `reveal` (`always` / `hover`), `notify` (a toast through `notify`).
|
|
24
|
+
- Links: `AdminUiProvider.linkComponent` sets the router link of every block that renders a link (`EntityTabs`,
|
|
25
|
+
`SectionHeader` tabs, `EntityDetailShell` back link, `AddEntityButton`, and `BreadcrumbLink` with an `href`); a
|
|
26
|
+
block's own `linkComponent` still wins. Without the provider prop every link renders as before.
|
|
27
|
+
The link contract (`PageLinkProps`, `PageLinkComponent`, `AnchorLink`) moved to `./primitives` with
|
|
28
|
+
`LinkComponentContext`, `LinkComponentProvider`, `useLinkComponent`; `./page` still exports the old names.
|
|
29
|
+
- `EntityListEmpty size="compact"`: one inline line. `DefinitionList layout="rows"`: divided rows, label left, value
|
|
30
|
+
right. `FilterDateRange hideLabel` with `fromLabel` / `toLabel` (and `className`) for an inline range.
|
|
31
|
+
- `PageFrame` / `EntityListPage` `asSpecimen`: no `data-page-frame`, no full-height frame (used by the showcase, so a
|
|
32
|
+
host rule keyed to the attribute no longer fires there).
|
|
33
|
+
- `SegmentedControl`: a control wider than its container scrolls inside itself, keeping the selected and the focused
|
|
34
|
+
option in view (touch swipes scroll then, the drag preview stays for mouse and pen); options no longer shrink.
|
|
35
|
+
Options take `context` (passed to `t()`) and `translate: false` for already translated text.
|
|
36
|
+
- `ConfirmOptions.description`: documented — may be a React node; the package's own confirmations pass plain text.
|
|
37
|
+
- Showcase: samples of the new props and blocks; specimen cells shrink (`min-w-0`), so a wide specimen does not widen
|
|
38
|
+
the page at 390 px.
|
|
39
|
+
- DOM change: `FormActions` renders `data-form-actions="admin-ui"` (was an empty value), and `components.css` selects
|
|
40
|
+
that value only, so a host's own action bar with a bare `data-form-actions` is no longer restyled.
|
|
41
|
+
- Text keys changed (move host translations):
|
|
42
|
+
- `Search for a command to run...` → `Search for a command to run…`
|
|
43
|
+
- the translation progress statuses got the context `translation-status`: `Waiting`, `Translating`, `Done`,
|
|
44
|
+
`Failed`, `Cancelled` → `Waiting__translation-status`, `Translating__translation-status`,
|
|
45
|
+
`Done__translation-status`, `Failed__translation-status`, `Cancelled__translation-status`.
|
|
46
|
+
`Translating…` (the running button label) stays a separate key: a button text, not a status word.
|
|
47
|
+
- new: `Clear`, `Copied`, `Could not copy`, `Create “%term%”`.
|
|
48
|
+
- Consumer checks: Combobox in the browser (out-of-order answers, picked label outside the results, reset on close,
|
|
49
|
+
keyboard through groups and the create row, clearing), selectable rows, SegmentedControl in a 358 px container, the
|
|
50
|
+
showcase at 390 px without page scroll and without `data-page-frame`, links through the provider's link component
|
|
51
|
+
keeping sticky parameters; unit tests for the date values (UTC and Europe/Berlin around midnight and both clock
|
|
52
|
+
changes), `withStickyParams` and the storage helpers.
|
|
53
|
+
|
|
6
54
|
## 0.1.0-rc.4
|
|
7
55
|
|
|
8
56
|
- `SegmentedControl` in `./primitives`: one value out of a few. Props `value`, `onValueChange`, `options` (`value`,
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ pnpm add @mgamadeus/ddd-admin-ui @mgamadeus/ddd-web radix-ui react react-dom luc
|
|
|
20
20
|
|
|
21
21
|
| Entry | What it holds | May import (besides React and its peers) |
|
|
22
22
|
|---|---|---|
|
|
23
|
-
| `./logic` | pure helpers (`formatDate`, `defineStatusMap`, conditions, schemas, `notify`, `runSequential`), React hooks without markup (`useUrlListState`, `useEntityDrawer`, `useRowSelection`, `useEntityTranslations`, …), browser helpers (`prepareImageFile`) | `./i18n` |
|
|
23
|
+
| `./logic` | pure helpers (`formatDate`, `defineStatusMap`, conditions, schemas, `notify`, `runSequential`), React hooks without markup (`useUrlListState`, `useEntityDrawer`, `useRowSelection`, `useEntityTranslations`, …), browser helpers (`prepareImageFile`, `readStored` / `writeStored`, `buildStorageKey`), date input values (`toDateInputValue`, `fromDateTimeInputValue`, …), `withStickyParams`, `useLatestSearch` | `./i18n` |
|
|
24
24
|
| `./i18n` | the UI text store (`m`, `translateText`, `setTranslations`), `useTranslate`, `<Translate>`, number / date formats of the UI locale, server-message translation | — |
|
|
25
25
|
| `./primitives` | buttons, inputs, selects, dialogs, sheets, popovers, menus, tooltips, tables, badges, `SegmentedControl`, `cn`, the portal container | `./i18n` |
|
|
26
26
|
| `./list` | entity list card, toolbar, search, filters, table, grid, load-more, status badge, cells, multi-select, combobox, bulk bar | logic, i18n, primitives |
|
|
@@ -155,8 +155,17 @@ It reads the host's `node_modules` (npm and pnpm layouts) and the folders above
|
|
|
155
155
|
`ddd-admin-ui.<kind>.<id>`), `portalContainer` (where dialogs, sheets, popovers, selects, menus and tooltips mount;
|
|
156
156
|
default `document.body`), `tooltipDelayMs`, `translations` (a `TranslationAdapter` that feeds the text store from a
|
|
157
157
|
host store), `useUrlStateAdapter`, `useDrawerUrlAdapter`, `upload`, `renderMarkdownEditor`, `aiTranslation`,
|
|
158
|
-
`preserveSearchParams` (search parameters the URL writer never removes)
|
|
159
|
-
|
|
158
|
+
`preserveSearchParams` (search parameters the URL writer never removes), `linkComponent` (the router link of every
|
|
159
|
+
block that renders a link; wrap it with `withStickyParams` to keep sticky search parameters). Without a
|
|
160
|
+
notification adapter `notify.*` does nothing and warns once outside production.
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
const StickyLink: PageLinkComponent = ({ href, ...props }) => {
|
|
164
|
+
const search = useSearchParams();
|
|
165
|
+
return <Link href={withStickyParams(href, ['workspace', 'debug'], search)} {...props} />;
|
|
166
|
+
};
|
|
167
|
+
<AdminUiProvider linkComponent={StickyLink} …>
|
|
168
|
+
```
|
|
160
169
|
|
|
161
170
|
4. **Confirmations.** Blocks that ask before a step open the package's confirm dialog (`useConfirmDialog`). A host
|
|
162
171
|
with its own confirmation service passes it as `confirm` (`(options: ConfirmOptions) => Promise<boolean>`, a stable
|
|
@@ -180,6 +189,13 @@ const STATUS = defineStatusMap({ ACTIVE: { label: 'Active', tone: 'success' } })
|
|
|
180
189
|
Client components (`DateCell`, `EntityListTable`, `Form`, …) render from server components as long as they get no
|
|
181
190
|
function props there.
|
|
182
191
|
|
|
192
|
+
## Dates in native inputs
|
|
193
|
+
|
|
194
|
+
`<input type="date">` and `type="datetime-local"` hold wall-clock text. Translate it with an explicit zone, `'local'`
|
|
195
|
+
(the browser's clock) or `'utc'`: `toDateInputValue(date, zone)` / `fromDateInputValue(text, zone)` and
|
|
196
|
+
`toDateTimeInputValue` / `fromDateTimeInputValue` (`./logic`). Empty or invalid gives `''` / `null`; no arithmetic. A
|
|
197
|
+
local time skipped when the clocks go forward resolves an hour later, a repeated one to its first occurrence.
|
|
198
|
+
|
|
183
199
|
## Showcase
|
|
184
200
|
|
|
185
201
|
`./showcase` is a development page, not a screen block: mount it on a route of the host, below `AdminUiProvider`, to
|
package/STANDARDS.md
CHANGED
|
@@ -108,6 +108,7 @@ const selection = useRowSelection({
|
|
|
108
108
|
getKey: task => toNumericId(task.id), // a host helper
|
|
109
109
|
resetKey: filterString ?? '', // new filters → empty selection
|
|
110
110
|
disabled: busy,
|
|
111
|
+
isSelectable: canDelete, // optional: other rows get a disabled checkbox, "select all" skips them
|
|
111
112
|
});
|
|
112
113
|
|
|
113
114
|
const handleBulkDelete = async () => {
|
|
@@ -168,7 +169,10 @@ const columns: EntityListColumn<Project>[] = [
|
|
|
168
169
|
- Dates: `DateCell` in tables, `formatDateTime` / `formatDate` in text. Never raw strings, never
|
|
169
170
|
`toLocaleString()`, never `new Date(value)`.
|
|
170
171
|
- Numbers and ids: the host's formatters (one per kind), never ad-hoc `toFixed` calls.
|
|
171
|
-
- Copy next to a value outside the ID column:
|
|
172
|
+
- Copy next to a value outside the ID column: `CopyButton` (`value`, `label`, `reveal="hover"` in rows, `notify` for a
|
|
173
|
+
toast).
|
|
174
|
+
- A row that looks different (archived, muted): `rowClassName={(item, index) => …}` on the table or body.
|
|
175
|
+
- Small lists inside a card or section: `EntityListEmpty size="compact"` (one inline line, no 64 px block).
|
|
172
176
|
|
|
173
177
|
### Wide tables: tracks, pins, sort, row index
|
|
174
178
|
|
|
@@ -254,6 +258,13 @@ Always with an icon.
|
|
|
254
258
|
|
|
255
259
|
Single searchable select (not a filter): `Combobox`.
|
|
256
260
|
|
|
261
|
+
- Long or server-side lists: `onSearch` + `isSearching` with `useLatestSearch` (the block debounces, never shows a stale
|
|
262
|
+
term's options, resets the search on close); a picked value outside the current results passes `selectedOption`.
|
|
263
|
+
- `clearable` for an optional value (a clear control; picking the picked option clears it); without it a pick is kept.
|
|
264
|
+
An option whose value is `''` and means something ("No parent") stays an ordinary option.
|
|
265
|
+
- Headings with `group`, a count or status after the label with `badge`, a "Create “…”" row with `onRequestCreate`.
|
|
266
|
+
- A date range in a toolbar row or table header: `FilterDateRange hideLabel` with `fromLabel` / `toLabel`.
|
|
267
|
+
|
|
257
268
|
## 8. Detail screens — `EntityDetailShell`
|
|
258
269
|
|
|
259
270
|
Every entity detail uses the shell: back + centred title + description + actions, `EntityMetadata` (ID, Created,
|
|
@@ -302,6 +313,12 @@ Inside a tab:
|
|
|
302
313
|
</CardContent></Card>
|
|
303
314
|
```
|
|
304
315
|
|
|
316
|
+
A summary card or side panel lists facts as divided rows, label left and value right: `layout="rows"`.
|
|
317
|
+
|
|
318
|
+
Every link a block renders (tabs, the back link, the Add button, breadcrumb links) goes through the host's link component, set once as
|
|
319
|
+
`AdminUiProvider.linkComponent` (a block's own `linkComponent` prop still wins). A host with sticky search parameters
|
|
320
|
+
wraps its router link with `withStickyParams(href, names, currentSearch)`.
|
|
321
|
+
|
|
305
322
|
Create screens: no `metadata` id yet → the strip renders nothing. Edit screens outside a shell keep
|
|
306
323
|
`<EntityMetadata id={…} changeHistory={…} />` right under their `FormHeader`.
|
|
307
324
|
|
|
@@ -433,6 +450,8 @@ const entity = id ? (query.currentData?.supplier ?? null) : null; // currentDa
|
|
|
433
450
|
- A list hosting two drawers passes its own `editKey` / `createKey`.
|
|
434
451
|
- **Confirm**: the drawer asks through the package dialog; a host with its own confirmation service passes
|
|
435
452
|
`confirm={hostConfirm}` (stable function, same Radix copy). The same prop exists on the translatable fields.
|
|
453
|
+
`ConfirmOptions.description` may be a React node; the package's own confirmations always pass plain text, so a
|
|
454
|
+
service that renders text only can show them.
|
|
436
455
|
- One column inside the drawer (≤ 760 px): no `md:grid-cols-2` form grids.
|
|
437
456
|
|
|
438
457
|
## 13. One value out of a few — `SegmentedControl`
|
|
@@ -456,4 +475,9 @@ const entity = id ? (query.currentData?.supplier ?? null) : null; // currentDa
|
|
|
456
475
|
- Always exactly one value; 2–5 short options. More, or long labels: a select.
|
|
457
476
|
- `activation="manual"` when a change is expensive (loads data): arrows move the focus, Space / Enter select.
|
|
458
477
|
- `iconOnly` keeps the label as the accessible name and shows it as a tooltip (needs `AdminUiProvider`).
|
|
478
|
+
- In a row with form controls use `height={36}` (the height of a select trigger).
|
|
479
|
+
- On a phone the control keeps its size and scrolls inside itself (the selected and the focused option stay in view);
|
|
480
|
+
with more than three options or long labels prefer `fullWidth` with short labels, or a select.
|
|
481
|
+
- Labels are English UI texts, translated by the control (`context` for an ambiguous word, marked as literal
|
|
482
|
+
`m('Open', { context: 'filter' })`); already translated text (names from the server) passes `translate: false`.
|
|
459
483
|
- A disabled option says why (`disabledReason`); a count goes in `badge` and, when it matters, in `description`.
|
package/dist/components.css
CHANGED
|
@@ -101,11 +101,11 @@
|
|
|
101
101
|
}
|
|
102
102
|
/* Sticky glass bars (bulk bar, form action bar). */
|
|
103
103
|
/* Form actions at the top of the form: written last, shown first, sticky under the chrome. */
|
|
104
|
-
form:has(> [data-form-actions]) {
|
|
104
|
+
form:has(> [data-form-actions='admin-ui']) {
|
|
105
105
|
display: flex;
|
|
106
106
|
flex-direction: column;
|
|
107
107
|
}
|
|
108
|
-
form > [data-form-actions] {
|
|
108
|
+
form > [data-form-actions='admin-ui'] {
|
|
109
109
|
order: -1;
|
|
110
110
|
}
|
|
111
111
|
.glass-bar {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormActions.d.ts","sourceRoot":"","sources":["../../src/form/FormActions.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;AAS1D,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4FAA4F;IAC5F,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"FormActions.d.ts","sourceRoot":"","sources":["../../src/form/FormActions.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;AAS1D,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4FAA4F;IAC5F,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAsED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,0EAQzB,gBAAgB,gCAiDlB,CAAC"}
|
package/dist/form/FormActions.js
CHANGED
|
@@ -7,11 +7,16 @@ import { cn } from "../primitives/cn.js";
|
|
|
7
7
|
import { DrawerFooter } from "./DrawerFooter.js";
|
|
8
8
|
import { useIsInDrawer } from "./drawerSlots.js";
|
|
9
9
|
import { useFormDirty } from "../logic/react/useFormDirty.js";
|
|
10
|
+
/**
|
|
11
|
+
* The value of the bar's `data-form-actions` attribute: `components.css` selects exactly this value, so a host's own
|
|
12
|
+
* action bar with a bare `data-form-actions` is not restyled by the package.
|
|
13
|
+
*/
|
|
14
|
+
const FORM_ACTIONS_MARKER = 'admin-ui';
|
|
10
15
|
/** Below `sm` the buttons share the row; from `sm` up each keeps its own width. */
|
|
11
16
|
const ACTION_CLASS = 'flex-1 min-w-fit *:w-full sm:flex-none sm:*:w-auto';
|
|
12
17
|
/**
|
|
13
18
|
* The page action pill (host CSS `.glass-bar`): compact, right-aligned at the top of the form and sticky under the
|
|
14
|
-
* fixed chrome (`--nav-h`) while the form scrolls. Forms write `<FormActions>` last; `data-form-actions` + the host
|
|
19
|
+
* fixed chrome (`--nav-h`) while the form scrolls. Forms write `<FormActions>` last; `data-form-actions="admin-ui"` + the host
|
|
15
20
|
* CSS move it first (`order: -1`), so the DOM / tab order is unchanged everywhere.
|
|
16
21
|
*/
|
|
17
22
|
// No row of its own where the page has tabs: the wrapper is 0 px tall and pulled 3.5 rem up (and as
|
|
@@ -75,6 +80,6 @@ export const FormActions = ({ primary, secondary, tertiary, sticky = true, place
|
|
|
75
80
|
if (!sticky) {
|
|
76
81
|
return (_jsx(DrawerFooter, { inlineClassName: cn('pt-6', className), children: _jsxs("div", { ref: anchor, className: "flex flex-wrap-reverse items-center gap-2", children: [secondary && _jsx("div", { className: ACTION_CLASS, children: secondary }), tertiary && _jsx("div", { className: ACTION_CLASS, children: tertiary }), primary && _jsx("div", { className: cn(ACTION_CLASS, 'sm:ml-auto'), children: primary })] }) }));
|
|
77
82
|
}
|
|
78
|
-
return (_jsx(DrawerFooter, { inlineClassName: cn(STICKY_WRAPPER_CLASS, placement === 'auto' && BESIDE_TABS_CLASS, className), inlineProps: { 'data-form-actions':
|
|
83
|
+
return (_jsx(DrawerFooter, { inlineClassName: cn(STICKY_WRAPPER_CLASS, placement === 'auto' && BESIDE_TABS_CLASS, className), inlineProps: { 'data-form-actions': FORM_ACTIONS_MARKER }, children: _jsxs("div", { ref: anchor, className: STICKY_PILL_CLASS, children: [_jsx(ChangeStatus, { control: formContext?.control, isDirty: isDirty }), tertiary && _jsx("div", { className: ACTION_CLASS, children: tertiary }), secondary && _jsx("div", { className: ACTION_CLASS, children: secondary }), primary && _jsx("div", { className: ACTION_CLASS, children: primary })] }) }));
|
|
79
84
|
};
|
|
80
85
|
//# sourceMappingURL=FormActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormActions.js","sourceRoot":"","sources":["../../src/form/FormActions.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAgB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAA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ns to the world list; asks for confirmation if there are unsaved changes.",
|
|
25
25
|
"Cancel__confirm-dialog": "Button on the left of a generic confirmation dialog that dismisses it without doing the action. Shown when the caller did not set its own label.",
|
|
26
26
|
"Cancel__media-picker": "Footer button of the media picker dialog; click to close the dialog without changing the chosen media item.",
|
|
27
|
-
"Cancelled": "Status badge label (short pill) in lists, cards and detail views, describing the state of a partner contract. Keep it short, like a status word.",
|
|
28
27
|
"Change__media-field-action": "Button label under a media field preview; click to open the picker and replace the currently chosen image. Shown only when an image is already set.",
|
|
29
28
|
"Clear %label%": "Accessible label of the small X button inside a text filter that empties it. %label% is the filter name, e.g. Name or Account ID.",
|
|
30
29
|
"Clear all": "Button at the bottom of a multi-select dropdown that deselects every option in the list.",
|
|
@@ -46,11 +45,9 @@
|
|
|
46
45
|
"Discard changes?": "Title of the confirmation dialog shown when the user closes a form drawer that has unsaved edits. Phrased as a question.",
|
|
47
46
|
"Discard__unsaved-changes-confirm": "Destructive confirm button of the discard dialog; clicking it closes the form and loses the unsaved edits. Imperative verb.",
|
|
48
47
|
"Dismiss": "Button in the AI translation panel that hides the finished progress list of the last translation run. Imperative.",
|
|
49
|
-
"Done": "Status badge of one language in the translation progress list: the translation finished successfully.",
|
|
50
48
|
"Edit__action": "Default accessible name and tooltip of the small pencil icon button in the top-right corner of a settings card; clicking it opens the edit form for that card. Imperative verb.",
|
|
51
49
|
"Enter %language% text…": "Placeholder of a text input in a translatable field; %language% is the name of the active language tab, e.g. 'German'.",
|
|
52
50
|
"Export to Excel": "Sample text of the outline button specimen in the UI showcase; imperative, exports a list as a spreadsheet. Maintenance UI showcase screen, Buttons section.",
|
|
53
|
-
"Failed": "Status badge label (short pill) in lists, cards and detail views, describing the state of a push notification or mail delivery attempt. Keep it short, like a status word. Also used for other status families.",
|
|
54
51
|
"Filters": "Button text in a list toolbar that opens or closes the collapsible panel with extra filters. Hidden on phones, where only the icon shows.",
|
|
55
52
|
"Form sections": "Accessible label (aria-label) of the small sticky navigation bar at the top of a long admin form (challenge, campaign) that jumps between its panels.",
|
|
56
53
|
"Grid view": "Tooltip and accessible label of the icon button in a list toolbar that switches the list to a grid of cards.",
|
|
@@ -80,7 +77,6 @@
|
|
|
80
77
|
"Request contains invalid data": "Title of the red error toast and error box above a form after the server rejected a save because one or more fields are invalid (the fields are listed below it).",
|
|
81
78
|
"Save changes": "Sample text of the primary button specimen in the UI showcase; imperative, a typical save action. Maintenance UI showcase screen, Buttons section.",
|
|
82
79
|
"Search": "Accessible label of a search input field in a list toolbar, read by screen readers. Use the plain noun or verb for searching.",
|
|
83
|
-
"Search for a command to run...": "Hidden (screen-reader only) description of the command palette dialog, telling the user to search for a command or page to run.",
|
|
84
80
|
"Search…": "Placeholder text inside a search box above a list or table, and the generic placeholder of a dropdown's search field. Ends with an ellipsis.",
|
|
85
81
|
"Sections": "Accessible name (screen reader label) of the sub-tab bar below a section heading when the heading is not plain text.",
|
|
86
82
|
"Sections__tab-navigation": "Default accessible name (screen reader label, not visible) of the tab bar under the header of a detail screen, whose tabs switch between sections of the record such as General, Teams or Rides. Plural noun.",
|
|
@@ -111,7 +107,6 @@
|
|
|
111
107
|
"Token authentication failed": "Error message from the server when the login session token is invalid or expired; the user has to sign in again.",
|
|
112
108
|
"Translate to": "Form label above the language chips in the AI translation panel of an admin form; the chips are the target languages.",
|
|
113
109
|
"Translate to selected locales": "Button in the AI translation panel that starts translating the texts into all language chips the user selected. Imperative.",
|
|
114
|
-
"Translating": "Status badge of one language in the translation progress list: the translation request is running right now.",
|
|
115
110
|
"Translating…": "Label of a button while the automatic AI translation is running for the selected languages; progress state, keep the ellipsis.",
|
|
116
111
|
"Translation failed": "Fallback error message shown in the tooltip of a failed language in the translation progress list when the server gave no message.",
|
|
117
112
|
"Unauthorized": "Short error message from the server when the request needs a valid login (session expired or missing); the user has to sign in again.",
|
|
@@ -122,10 +117,19 @@
|
|
|
122
117
|
"Upload__media-picker": "Button in the media picker dialog header; click to choose image files from the computer and upload them as new media items.",
|
|
123
118
|
"Uploading…__media-picker": "Button label in the media picker dialog while selected image files are being uploaded; the button is disabled meanwhile.",
|
|
124
119
|
"View": "Label and accessible name of the toggle on the Home screen that switches between the Timeline and Kanban views.",
|
|
125
|
-
"Waiting": "Short form of the status 'Waiting for Customer', on a compact status button in the support ticket sidebar. Keep it to one short word.",
|
|
126
120
|
"Wrong credentials.": "Error message on the login page when the e-mail address / username or the password is wrong.",
|
|
127
121
|
"Yes": "Option of a yes/no filter in the filter panel of a list; selecting it shows only records where the flag is set.",
|
|
128
122
|
"Yes__boolean-flag": "Default label of a yes/no flag cell in a list table, shown with a green check when the flag is on, e.g. Active column.",
|
|
129
123
|
"You have unsaved changes. Closing now will lose them.": "Body text of the discard confirmation dialog, warning that closing the form drawer throws away the user's unsaved edits.",
|
|
130
|
-
"Row number": "Screen-reader name of the narrow '#' column at the start of a list table that numbers the loaded rows 1, 2, 3 …"
|
|
124
|
+
"Row number": "Screen-reader name of the narrow '#' column at the start of a list table that numbers the loaded rows 1, 2, 3 …",
|
|
125
|
+
"Clear": "Accessible name and tooltip of the small × inside a picker (combobox) that removes the picked value, leaving the field empty.",
|
|
126
|
+
"Copied": "Toast after a copy button put a value (an id, a link, a code) on the clipboard.",
|
|
127
|
+
"Could not copy": "Error toast when the browser refused to put a value on the clipboard (no permission or an insecure page).",
|
|
128
|
+
"Create “%term%”": "Last row of a picker's search list: creates a new entry named by the typed text (%term%) because no existing entry has that name.",
|
|
129
|
+
"Search for a command to run…": "Hidden (screen-reader only) description of the command palette dialog, telling the user to search for a command or page to run.",
|
|
130
|
+
"Waiting__translation-status": "Short form of the status 'Waiting for Customer', on a compact status button in the support ticket sidebar. Keep it to one short word.",
|
|
131
|
+
"Translating__translation-status": "Status badge of one language in the translation progress list: the translation request is running right now.",
|
|
132
|
+
"Done__translation-status": "Status badge of one language in the translation progress list: the translation finished successfully.",
|
|
133
|
+
"Failed__translation-status": "Status badge label (short pill) in lists, cards and detail views, describing the state of a push notification or mail delivery attempt. Keep it short, like a status word. Also used for other status families.",
|
|
134
|
+
"Cancelled__translation-status": "Status badge label (short pill) in lists, cards and detail views, describing the state of a partner contract. Keep it short, like a status word."
|
|
131
135
|
}
|
package/dist/i18n-keys.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package": "@mgamadeus/ddd-admin-ui",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.5",
|
|
4
4
|
"generatedBy": "scripts/build-i18n-manifest.mjs",
|
|
5
5
|
"keys": [
|
|
6
6
|
{
|
|
@@ -143,8 +143,9 @@
|
|
|
143
143
|
"hint": "Footer button of the media picker dialog; click to close the dialog without changing the chosen media item."
|
|
144
144
|
},
|
|
145
145
|
{
|
|
146
|
-
"key": "
|
|
146
|
+
"key": "Cancelled__translation-status",
|
|
147
147
|
"text": "Cancelled",
|
|
148
|
+
"context": "translation-status",
|
|
148
149
|
"files": [
|
|
149
150
|
"translations/TranslationControls.tsx"
|
|
150
151
|
],
|
|
@@ -159,6 +160,14 @@
|
|
|
159
160
|
],
|
|
160
161
|
"hint": "Button label under a media field preview; click to open the picker and replace the currently chosen image. Shown only when an image is already set."
|
|
161
162
|
},
|
|
163
|
+
{
|
|
164
|
+
"key": "Clear",
|
|
165
|
+
"text": "Clear",
|
|
166
|
+
"files": [
|
|
167
|
+
"list/Combobox.tsx"
|
|
168
|
+
],
|
|
169
|
+
"hint": "Accessible name and tooltip of the small × inside a picker (combobox) that removes the picked value, leaving the field empty."
|
|
170
|
+
},
|
|
162
171
|
{
|
|
163
172
|
"key": "Clear %label%",
|
|
164
173
|
"text": "Clear %label%",
|
|
@@ -278,6 +287,14 @@
|
|
|
278
287
|
],
|
|
279
288
|
"hint": "Button on the right of a generic confirmation dialog that carries out the action asked about. Shown when the caller did not set its own label."
|
|
280
289
|
},
|
|
290
|
+
{
|
|
291
|
+
"key": "Copied",
|
|
292
|
+
"text": "Copied",
|
|
293
|
+
"files": [
|
|
294
|
+
"list/CopyButton.tsx"
|
|
295
|
+
],
|
|
296
|
+
"hint": "Toast after a copy button put a value (an id, a link, a code) on the clipboard."
|
|
297
|
+
},
|
|
281
298
|
{
|
|
282
299
|
"key": "Copy ID",
|
|
283
300
|
"text": "Copy ID",
|
|
@@ -295,6 +312,22 @@
|
|
|
295
312
|
],
|
|
296
313
|
"hint": "Accessible label (screen reader and tooltip) of the small button that copies the record ID to the clipboard, shown in the metadata block of every detail screen. %id% is the record ID, for example 4711 or a UUID. Imperative tone."
|
|
297
314
|
},
|
|
315
|
+
{
|
|
316
|
+
"key": "Could not copy",
|
|
317
|
+
"text": "Could not copy",
|
|
318
|
+
"files": [
|
|
319
|
+
"list/CopyButton.tsx"
|
|
320
|
+
],
|
|
321
|
+
"hint": "Error toast when the browser refused to put a value on the clipboard (no permission or an insecure page)."
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"key": "Create “%term%”",
|
|
325
|
+
"text": "Create “%term%”",
|
|
326
|
+
"files": [
|
|
327
|
+
"list/Combobox.tsx"
|
|
328
|
+
],
|
|
329
|
+
"hint": "Last row of a picker's search list: creates a new entry named by the typed text (%term%) because no existing entry has that name."
|
|
330
|
+
},
|
|
298
331
|
{
|
|
299
332
|
"key": "Created__entity-metadata",
|
|
300
333
|
"text": "Created",
|
|
@@ -331,8 +364,9 @@
|
|
|
331
364
|
"hint": "Button in the AI translation panel that hides the finished progress list of the last translation run. Imperative."
|
|
332
365
|
},
|
|
333
366
|
{
|
|
334
|
-
"key": "
|
|
367
|
+
"key": "Done__translation-status",
|
|
335
368
|
"text": "Done",
|
|
369
|
+
"context": "translation-status",
|
|
336
370
|
"files": [
|
|
337
371
|
"translations/TranslationControls.tsx"
|
|
338
372
|
],
|
|
@@ -364,8 +398,9 @@
|
|
|
364
398
|
"hint": "Sample text of the outline button specimen in the UI showcase; imperative, exports a list as a spreadsheet. Maintenance UI showcase screen, Buttons section."
|
|
365
399
|
},
|
|
366
400
|
{
|
|
367
|
-
"key": "
|
|
401
|
+
"key": "Failed__translation-status",
|
|
368
402
|
"text": "Failed",
|
|
403
|
+
"context": "translation-status",
|
|
369
404
|
"files": [
|
|
370
405
|
"translations/TranslationControls.tsx"
|
|
371
406
|
],
|
|
@@ -620,8 +655,8 @@
|
|
|
620
655
|
"hint": "Accessible label of a search input field in a list toolbar, read by screen readers. Use the plain noun or verb for searching."
|
|
621
656
|
},
|
|
622
657
|
{
|
|
623
|
-
"key": "Search for a command to run
|
|
624
|
-
"text": "Search for a command to run
|
|
658
|
+
"key": "Search for a command to run…",
|
|
659
|
+
"text": "Search for a command to run…",
|
|
625
660
|
"files": [
|
|
626
661
|
"primitives/command.tsx"
|
|
627
662
|
],
|
|
@@ -875,8 +910,9 @@
|
|
|
875
910
|
"hint": "Button in the AI translation panel that starts translating the texts into all language chips the user selected. Imperative."
|
|
876
911
|
},
|
|
877
912
|
{
|
|
878
|
-
"key": "
|
|
913
|
+
"key": "Translating__translation-status",
|
|
879
914
|
"text": "Translating",
|
|
915
|
+
"context": "translation-status",
|
|
880
916
|
"files": [
|
|
881
917
|
"translations/TranslationControls.tsx"
|
|
882
918
|
],
|
|
@@ -967,8 +1003,9 @@
|
|
|
967
1003
|
"hint": "Label and accessible name of the toggle on the Home screen that switches between the Timeline and Kanban views."
|
|
968
1004
|
},
|
|
969
1005
|
{
|
|
970
|
-
"key": "
|
|
1006
|
+
"key": "Waiting__translation-status",
|
|
971
1007
|
"text": "Waiting",
|
|
1008
|
+
"context": "translation-status",
|
|
972
1009
|
"files": [
|
|
973
1010
|
"translations/TranslationControls.tsx"
|
|
974
1011
|
],
|
package/dist/list/Combobox.d.ts
CHANGED
|
@@ -5,10 +5,16 @@ export interface ComboboxOption {
|
|
|
5
5
|
/** Second line in the list (e.g. an id or a parent). */
|
|
6
6
|
description?: string;
|
|
7
7
|
icon?: ReactNode;
|
|
8
|
+
/** Heading the option is listed under; groups keep the order in which they first appear. */
|
|
9
|
+
group?: string;
|
|
10
|
+
/** A small marker after the label (a count, a status). */
|
|
11
|
+
badge?: ReactNode;
|
|
8
12
|
}
|
|
13
|
+
/** Wait (ms) after the last keystroke before `onSearch` runs. */
|
|
14
|
+
export declare const COMBOBOX_SEARCH_DEBOUNCE_MS = 300;
|
|
9
15
|
export interface ComboboxProps {
|
|
10
16
|
options: readonly ComboboxOption[];
|
|
11
|
-
/** `''` = nothing picked. */
|
|
17
|
+
/** `''` = nothing picked (unless an option has the value `''`: then it is an ordinary option). */
|
|
12
18
|
value: string;
|
|
13
19
|
onChange: (value: string) => void;
|
|
14
20
|
placeholder?: string;
|
|
@@ -24,9 +30,33 @@ export interface ComboboxProps {
|
|
|
24
30
|
*/
|
|
25
31
|
shape?: 'field' | 'pill';
|
|
26
32
|
id?: string;
|
|
33
|
+
/** Classes of the trigger; with `clearable`, of the wrapper around trigger and clear button (size it there). */
|
|
27
34
|
className?: string;
|
|
28
35
|
'aria-label'?: string;
|
|
36
|
+
/**
|
|
37
|
+
* A clear control (`value` → `''`) while something is picked; picking the picked option again clears it too. Without
|
|
38
|
+
* it, picking the picked option keeps the value.
|
|
39
|
+
*/
|
|
40
|
+
clearable?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Server search: the block stops filtering and calls this with the typed term, debounced
|
|
43
|
+
* (`COMBOBOX_SEARCH_DEBOUNCE_MS`), and with `''` when the popover closes. Pass the answer as `options` and
|
|
44
|
+
* `isSearching` while a request runs; until the answer to the current term is in, the list shows the searching
|
|
45
|
+
* state, never the previous term's options. Drop answers to older terms (`useLatestSearch` does both).
|
|
46
|
+
*/
|
|
47
|
+
onSearch?: (term: string) => void;
|
|
48
|
+
/** A search request is in flight (with `onSearch`). */
|
|
49
|
+
isSearching?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Offers a "Create “…”" row while the trimmed term matches no option label (case-insensitive). Choosing it calls this
|
|
52
|
+
* with the trimmed term, closes the popover and clears the term; the host creates the entry and sets `value`.
|
|
53
|
+
*/
|
|
54
|
+
onRequestCreate?: (term: string) => void;
|
|
55
|
+
/** The picked option when it is not among `options` (a server search result list without it): its label shows. */
|
|
56
|
+
selectedOption?: ComboboxOption;
|
|
57
|
+
/** Classes of the popover (e.g. a wider list than the trigger). */
|
|
58
|
+
popoverClassName?: string;
|
|
29
59
|
}
|
|
30
|
-
/** Single-choice combobox with a search field
|
|
31
|
-
export declare const Combobox: ({ options: rawOptions, value, onChange, placeholder, searchPlaceholder, emptyMessage, isLoading, disabled, size, shape, id, className, "aria-label": ariaLabel, }: ComboboxProps) => import("react").JSX.Element;
|
|
60
|
+
/** Single-choice combobox with a search field: client-side filtering, or a server search through `onSearch`. */
|
|
61
|
+
export declare const Combobox: ({ options: rawOptions, value, onChange, placeholder, searchPlaceholder, emptyMessage, isLoading, disabled, size, shape, id, className, "aria-label": ariaLabel, clearable, onSearch, isSearching, onRequestCreate, selectedOption, popoverClassName, }: ComboboxProps) => import("react").JSX.Element;
|
|
32
62
|
//# sourceMappingURL=Combobox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../../src/list/Combobox.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../../src/list/Combobox.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAmBpE,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,iEAAiE;AACjE,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IACnC,kGAAkG;IAClG,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mFAAmF;IACnF,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IACxB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gHAAgH;IAChH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,uDAAuD;IACvD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,kHAAkH;IAClH,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAkBD,gHAAgH;AAChH,eAAO,MAAM,QAAQ,GAAI,wPAoBtB,aAAa,gCAqJf,CAAC"}
|
package/dist/list/Combobox.js
CHANGED
|
@@ -1,27 +1,85 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Check, ChevronsUpDown } from 'lucide-react';
|
|
4
|
-
import { useState } from 'react';
|
|
3
|
+
import { Check, ChevronsUpDown, Plus, X } from 'lucide-react';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { CONTROL_SURFACE_CLASS, Button, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Popover, PopoverContent, PopoverTrigger, Skeleton, } from "../primitives/index.js";
|
|
6
6
|
import { useTranslate } from "../i18n/index.js";
|
|
7
7
|
import { cn } from "../primitives/cn.js";
|
|
8
|
-
/**
|
|
9
|
-
export const
|
|
8
|
+
/** Wait (ms) after the last keystroke before `onSearch` runs. */
|
|
9
|
+
export const COMBOBOX_SEARCH_DEBOUNCE_MS = 300;
|
|
10
|
+
/** Groups in the order they first appear; options without a group first. */
|
|
11
|
+
const groupOptions = (options) => {
|
|
12
|
+
const groups = new Map();
|
|
13
|
+
for (const option of options) {
|
|
14
|
+
const key = option.group ?? '';
|
|
15
|
+
if (!groups.has(key))
|
|
16
|
+
groups.set(key, []);
|
|
17
|
+
groups.get(key)?.push(option);
|
|
18
|
+
}
|
|
19
|
+
const ungrouped = groups.get('');
|
|
20
|
+
if (ungrouped) {
|
|
21
|
+
groups.delete('');
|
|
22
|
+
return [['', ungrouped], ...groups.entries()];
|
|
23
|
+
}
|
|
24
|
+
return [...groups.entries()];
|
|
25
|
+
};
|
|
26
|
+
/** Single-choice combobox with a search field: client-side filtering, or a server search through `onSearch`. */
|
|
27
|
+
export const Combobox = ({ options: rawOptions, value, onChange, placeholder, searchPlaceholder, emptyMessage, isLoading = false, disabled, size = 'default', shape = 'field', id, className, 'aria-label': ariaLabel, clearable = false, onSearch, isSearching = false, onRequestCreate, selectedOption, popoverClassName, }) => {
|
|
10
28
|
const { t } = useTranslate();
|
|
11
29
|
const [open, setOpen] = useState(false);
|
|
30
|
+
const [term, setTerm] = useState('');
|
|
31
|
+
// the last term handed to `onSearch`: until it equals the typed term and the answer is in, options are stale
|
|
32
|
+
const [sentTerm, setSentTerm] = useState('');
|
|
33
|
+
const onSearchRef = useRef(onSearch);
|
|
34
|
+
onSearchRef.current = onSearch;
|
|
12
35
|
// Labels marked with `m()` (status / type option lists) are translated here; an already translated or a user text
|
|
13
|
-
// (a
|
|
14
|
-
const
|
|
36
|
+
// (a name) has no key and stays as it is.
|
|
37
|
+
const translate = (option) => ({
|
|
15
38
|
...option,
|
|
16
39
|
label: t(option.label),
|
|
17
40
|
description: option.description ? t(option.description) : undefined,
|
|
18
|
-
})
|
|
19
|
-
const
|
|
20
|
-
|
|
41
|
+
});
|
|
42
|
+
const options = rawOptions.map(translate);
|
|
43
|
+
const selected = options.find(option => option.value === value) ??
|
|
44
|
+
(selectedOption && selectedOption.value === value ? translate(selectedOption) : undefined);
|
|
45
|
+
const serverSearch = onSearch !== undefined;
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!serverSearch || !open || term === sentTerm)
|
|
48
|
+
return;
|
|
49
|
+
const timer = setTimeout(() => {
|
|
50
|
+
setSentTerm(term);
|
|
51
|
+
onSearchRef.current?.(term);
|
|
52
|
+
}, COMBOBOX_SEARCH_DEBOUNCE_MS);
|
|
53
|
+
return () => clearTimeout(timer);
|
|
54
|
+
}, [serverSearch, open, term, sentTerm]);
|
|
55
|
+
const setOpenState = (next) => {
|
|
56
|
+
setOpen(next);
|
|
57
|
+
if (next)
|
|
58
|
+
return;
|
|
59
|
+
// closing resets the search: the next opening starts from the full (or the host's default) list
|
|
60
|
+
if (serverSearch && (term !== '' || sentTerm !== ''))
|
|
61
|
+
onSearchRef.current?.('');
|
|
62
|
+
setTerm('');
|
|
63
|
+
setSentTerm('');
|
|
64
|
+
};
|
|
65
|
+
const pick = (option) => {
|
|
66
|
+
onChange(clearable && option.value === value ? '' : option.value);
|
|
67
|
+
setOpenState(false);
|
|
68
|
+
};
|
|
69
|
+
const trimmed = term.trim();
|
|
70
|
+
const canCreate = onRequestCreate !== undefined &&
|
|
71
|
+
trimmed !== '' &&
|
|
72
|
+
!options.some(option => option.label.trim().toLowerCase() === trimmed.toLowerCase());
|
|
73
|
+
const searching = isLoading || (serverSearch && (isSearching || term !== sentTerm));
|
|
74
|
+
const showClear = clearable && value !== '' && !disabled;
|
|
75
|
+
const trigger = (_jsxs(Popover, { open: open, onOpenChange: setOpenState, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { id: id, type: "button", variant: "field", rounded: shape === 'pill' ? 'full' : 'default', "data-control": shape, role: "combobox", "aria-expanded": open, "aria-label": ariaLabel, disabled: disabled, className: cn('justify-between', shape === 'pill'
|
|
21
76
|
? cn(CONTROL_SURFACE_CLASS, 'data-[state=open]:bg-tint-strong')
|
|
22
|
-
: 'data-[state=open]:border-field-edge-strong', size === 'sm' ? 'h-8' : 'h-9', selected && selected.value !== '' && 'font-bold', className), children: [_jsx("span", { className: cn('truncate', !selected && 'text-muted-foreground'), children: selected?.label ?? placeholder ?? t('Select…') }), _jsx(ChevronsUpDown, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": true })] }) }), _jsx(PopoverContent, { className:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
77
|
+
: 'data-[state=open]:border-field-edge-strong', size === 'sm' ? 'h-8' : 'h-9', selected && selected.value !== '' && 'font-bold', clearable ? cn('w-full', showClear && 'pr-14') : className), children: [_jsx("span", { className: cn('truncate', !selected && 'text-muted-foreground'), children: selected?.label ?? placeholder ?? t('Select…') }), _jsx(ChevronsUpDown, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": true })] }) }), _jsx(PopoverContent, { className: cn('w-(--radix-popover-trigger-width) min-w-56 p-0', popoverClassName), align: "start", children: _jsxs(Command, { shouldFilter: !serverSearch, children: [_jsx(CommandInput, { placeholder: searchPlaceholder ?? t('Search…'), value: term, onValueChange: setTerm }), _jsxs(CommandList, { children: [searching ? (_jsxs("div", { className: "space-y-2 p-2", "aria-busy": true, children: [_jsx(Skeleton, { className: "h-6 w-full" }), _jsx(Skeleton, { className: "h-6 w-3/4" })] })) : (_jsxs(_Fragment, { children: [_jsx(CommandEmpty, { children: emptyMessage ?? t('No results') }), groupOptions(options).map(([group, groupOptionsList]) => (_jsx(CommandGroup, { heading: group ? t(group) : undefined, children: groupOptionsList.map(option => (_jsxs(CommandItem, { value: `${option.label} ${option.value}`, onSelect: () => pick(option), children: [_jsx(Check, { className: cn('size-4', option.value === value ? 'opacity-100' : 'opacity-0'), "aria-hidden": true }), option.icon, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate", children: option.label }), option.description && (_jsx("span", { className: "block truncate text-xs text-muted-foreground", children: option.description }))] }), option.badge !== undefined && _jsx("span", { className: "shrink-0", children: option.badge })] }, option.value))) }, group || '__ungrouped__')))] })), canCreate && !searching && (_jsx(CommandGroup, { forceMount: true, children: _jsxs(CommandItem, { forceMount: true, value: `__create__ ${trimmed}`, onSelect: () => {
|
|
78
|
+
onRequestCreate?.(trimmed);
|
|
79
|
+
setOpenState(false);
|
|
80
|
+
}, children: [_jsx(Plus, { className: "size-4", "aria-hidden": true }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: t('Create “%term%”', { replacements: { term: trimmed } }) })] }) }))] })] }) })] }));
|
|
81
|
+
if (!clearable)
|
|
82
|
+
return trigger;
|
|
83
|
+
return (_jsxs("div", { className: cn('relative', className), children: [trigger, showClear && (_jsx("button", { type: "button", onClick: () => onChange(''), "aria-label": t('Clear'), title: t('Clear'), className: "absolute top-1/2 right-8 inline-flex size-5 -translate-y-1/2 items-center justify-center rounded text-muted-foreground hover:bg-tint hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none", children: _jsx(X, { className: "size-3.5", "aria-hidden": true }) }))] }));
|
|
26
84
|
};
|
|
27
85
|
//# sourceMappingURL=Combobox.js.map
|