@mgamadeus/ddd-admin-ui 0.1.0-rc.2 → 0.1.0-rc.4

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.
Files changed (101) hide show
  1. package/.claude/skills/ddd-admin-ui-specialist/SKILL.md +20 -2
  2. package/CHANGELOG.md +67 -1
  3. package/README.md +42 -6
  4. package/STANDARDS.md +132 -58
  5. package/dist/components.css +63 -3
  6. package/dist/i18n/hints.json +2 -1
  7. package/dist/i18n/index.d.ts +1 -1
  8. package/dist/i18n/index.d.ts.map +1 -1
  9. package/dist/i18n/index.js.map +1 -1
  10. package/dist/i18n/store.d.ts +10 -2
  11. package/dist/i18n/store.d.ts.map +1 -1
  12. package/dist/i18n/store.js +6 -2
  13. package/dist/i18n/store.js.map +1 -1
  14. package/dist/i18n-keys.json +9 -1
  15. package/dist/list/EntityListBody.d.ts +10 -3
  16. package/dist/list/EntityListBody.d.ts.map +1 -1
  17. package/dist/list/EntityListBody.js +9 -3
  18. package/dist/list/EntityListBody.js.map +1 -1
  19. package/dist/list/EntityListTable.d.ts +42 -2
  20. package/dist/list/EntityListTable.d.ts.map +1 -1
  21. package/dist/list/EntityListTable.js +158 -6
  22. package/dist/list/EntityListTable.js.map +1 -1
  23. package/dist/list/StatusBadge.d.ts +1 -1
  24. package/dist/list/StatusBadge.d.ts.map +1 -1
  25. package/dist/list/StatusBadge.js +3 -2
  26. package/dist/list/StatusBadge.js.map +1 -1
  27. package/dist/logic/index.d.ts +5 -1
  28. package/dist/logic/index.d.ts.map +1 -1
  29. package/dist/logic/index.js +2 -0
  30. package/dist/logic/index.js.map +1 -1
  31. package/dist/logic/pure/listSort.d.ts +29 -0
  32. package/dist/logic/pure/listSort.d.ts.map +1 -0
  33. package/dist/logic/pure/listSort.js +35 -0
  34. package/dist/logic/pure/listSort.js.map +1 -0
  35. package/dist/logic/pure/listTracks.d.ts +90 -0
  36. package/dist/logic/pure/listTracks.d.ts.map +1 -0
  37. package/dist/logic/pure/listTracks.js +139 -0
  38. package/dist/logic/pure/listTracks.js.map +1 -0
  39. package/dist/logic/pure/status.d.ts +23 -2
  40. package/dist/logic/pure/status.d.ts.map +1 -1
  41. package/dist/logic/pure/status.js +23 -2
  42. package/dist/logic/pure/status.js.map +1 -1
  43. package/dist/primitives/index.d.ts +1 -0
  44. package/dist/primitives/index.d.ts.map +1 -1
  45. package/dist/primitives/index.js +1 -0
  46. package/dist/primitives/index.js.map +1 -1
  47. package/dist/primitives/segmented-control.d.ts +57 -0
  48. package/dist/primitives/segmented-control.d.ts.map +1 -0
  49. package/dist/primitives/segmented-control.js +206 -0
  50. package/dist/primitives/segmented-control.js.map +1 -0
  51. package/dist/primitives/segmentedControlNavigation.d.ts +31 -0
  52. package/dist/primitives/segmentedControlNavigation.d.ts.map +1 -0
  53. package/dist/primitives/segmentedControlNavigation.js +65 -0
  54. package/dist/primitives/segmentedControlNavigation.js.map +1 -0
  55. package/dist/scripts/build-i18n-manifest.mjs +9 -3
  56. package/dist/showcase/Showcase.d.ts +35 -0
  57. package/dist/showcase/Showcase.d.ts.map +1 -0
  58. package/dist/showcase/Showcase.js +47 -0
  59. package/dist/showcase/Showcase.js.map +1 -0
  60. package/dist/showcase/coverage.d.ts +11 -0
  61. package/dist/showcase/coverage.d.ts.map +1 -0
  62. package/dist/showcase/coverage.js +77 -0
  63. package/dist/showcase/coverage.js.map +1 -0
  64. package/dist/showcase/index.d.ts +6 -0
  65. package/dist/showcase/index.d.ts.map +1 -0
  66. package/dist/showcase/index.js +5 -0
  67. package/dist/showcase/index.js.map +1 -0
  68. package/dist/showcase/sections/FormShowcase.d.ts +3 -0
  69. package/dist/showcase/sections/FormShowcase.d.ts.map +1 -0
  70. package/dist/showcase/sections/FormShowcase.js +26 -0
  71. package/dist/showcase/sections/FormShowcase.js.map +1 -0
  72. package/dist/showcase/sections/GlassShowcase.d.ts +3 -0
  73. package/dist/showcase/sections/GlassShowcase.d.ts.map +1 -0
  74. package/dist/showcase/sections/GlassShowcase.js +19 -0
  75. package/dist/showcase/sections/GlassShowcase.js.map +1 -0
  76. package/dist/showcase/sections/ListShowcase.d.ts +13 -0
  77. package/dist/showcase/sections/ListShowcase.d.ts.map +1 -0
  78. package/dist/showcase/sections/ListShowcase.js +67 -0
  79. package/dist/showcase/sections/ListShowcase.js.map +1 -0
  80. package/dist/showcase/sections/MediaShowcase.d.ts +3 -0
  81. package/dist/showcase/sections/MediaShowcase.d.ts.map +1 -0
  82. package/dist/showcase/sections/MediaShowcase.js +28 -0
  83. package/dist/showcase/sections/MediaShowcase.js.map +1 -0
  84. package/dist/showcase/sections/OptionalShowcase.d.ts +14 -0
  85. package/dist/showcase/sections/OptionalShowcase.d.ts.map +1 -0
  86. package/dist/showcase/sections/OptionalShowcase.js +32 -0
  87. package/dist/showcase/sections/OptionalShowcase.js.map +1 -0
  88. package/dist/showcase/sections/PageShowcase.d.ts +3 -0
  89. package/dist/showcase/sections/PageShowcase.d.ts.map +1 -0
  90. package/dist/showcase/sections/PageShowcase.js +37 -0
  91. package/dist/showcase/sections/PageShowcase.js.map +1 -0
  92. package/dist/showcase/sections/PrimitivesShowcase.d.ts +13 -0
  93. package/dist/showcase/sections/PrimitivesShowcase.d.ts.map +1 -0
  94. package/dist/showcase/sections/PrimitivesShowcase.js +40 -0
  95. package/dist/showcase/sections/PrimitivesShowcase.js.map +1 -0
  96. package/dist/showcase/sections/TranslationsShowcase.d.ts +3 -0
  97. package/dist/showcase/sections/TranslationsShowcase.d.ts.map +1 -0
  98. package/dist/showcase/sections/TranslationsShowcase.js +30 -0
  99. package/dist/showcase/sections/TranslationsShowcase.js.map +1 -0
  100. package/dist/tokens.json +37 -1
  101. package/package.json +7 -6
@@ -6,15 +6,20 @@
6
6
  */
7
7
  @source './';
8
8
 
9
- /* Layer scale. The blocks and primitives stack with `z-(--layer-<name>)`; these are only defaults: zero specificity
10
- (`:where`) in the lowest cascade layer (`theme`), so any host declaration of a `--layer-*` variable wins, layered or
11
- not. Equal overlay / popover values: a later portal paints on top. */
9
+ /* Layer scale and component defaults. The blocks and primitives stack with `z-(--layer-<name>)`; these are only
10
+ defaults: zero specificity (`:where`) in the lowest cascade layer (`theme`), so any host declaration of a `--layer-*`
11
+ or `--segmented-control-*` variable wins, layered or not. Equal overlay / popover values: a later portal paints on
12
+ top. */
12
13
  @layer theme {
13
14
  :where(:root) {
14
15
  --layer-raised: 10;
15
16
  --layer-sticky: 20;
16
17
  --layer-overlay: 50;
17
18
  --layer-popover: 50;
19
+ /* SegmentedControl: corner of the track, the options and the indicator (the pill of the other toggles), and the
20
+ slide of the indicator (no slide with reduced motion). */
21
+ --segmented-control-radius: 9999px;
22
+ --segmented-control-duration: 200ms;
18
23
  }
19
24
  }
20
25
 
@@ -127,6 +132,61 @@
127
132
  backdrop-filter: blur(12px);
128
133
  box-shadow: var(--surface-shadow);
129
134
  }
135
+ /* A list table with column tracks (`EntityListColumn.width`): one CSS grid, every row a subgrid of it, so header and
136
+ body share the tracks. The table sets `grid-template-columns` (and its minimum width) inline; the header sticks as
137
+ a whole (a cell's containing block is now its row). Cells centre their content vertically, as table cells do. */
138
+ table[data-list-tracks] {
139
+ display: grid;
140
+ }
141
+ table[data-list-tracks] > :is(thead, tbody),
142
+ table[data-list-tracks] > :is(thead, tbody) > tr {
143
+ display: grid;
144
+ grid-column: 1 / -1;
145
+ grid-template-columns: subgrid;
146
+ }
147
+ table[data-list-tracks] > thead {
148
+ position: sticky;
149
+ top: 0;
150
+ z-index: var(--layer-raised);
151
+ }
152
+ table[data-list-tracks] > :is(thead, tbody) > tr > :is(th, td) {
153
+ display: flex;
154
+ align-items: center;
155
+ min-width: 0;
156
+ }
157
+ /* Pinned columns (`data-list-pin`, sticky offsets inline): while content scrolls under them they paint the card
158
+ surface (the row's tint on a selected or hovered row) and the innermost one draws the separating edge. The scroll
159
+ container carries `data-list-overflow-start` / `-end` while content is hidden past that edge. */
160
+ [data-list-overflow-start] tbody [data-list-pin='start'],
161
+ [data-list-overflow-end] tbody [data-list-pin='end'] {
162
+ background-color: --theme(--color-card);
163
+ }
164
+ [data-list-overflow-start] tbody tr:hover > [data-list-pin='start'],
165
+ [data-list-overflow-end] tbody tr:hover > [data-list-pin='end'] {
166
+ background-color: color-mix(in oklab, --theme(--color-muted) 50%, --theme(--color-card));
167
+ }
168
+ [data-list-overflow-start] tbody tr[data-state='selected'] > [data-list-pin='start'],
169
+ [data-list-overflow-end] tbody tr[data-state='selected'] > [data-list-pin='end'] {
170
+ background-color: --theme(--color-muted);
171
+ }
172
+ [data-list-overflow-start] [data-list-pin='start'][data-list-pin-edge]::after,
173
+ [data-list-overflow-end] [data-list-pin='end'][data-list-pin-edge]::before {
174
+ content: '';
175
+ position: absolute;
176
+ top: 0;
177
+ bottom: 0;
178
+ width: 1px;
179
+ pointer-events: none;
180
+ background-color: --theme(--color-border);
181
+ }
182
+ [data-list-overflow-start] [data-list-pin='start'][data-list-pin-edge]::after {
183
+ right: -1px;
184
+ box-shadow: 4px 0 8px color-mix(in oklab, --theme(--color-foreground) 8%, transparent);
185
+ }
186
+ [data-list-overflow-end] [data-list-pin='end'][data-list-pin-edge]::before {
187
+ left: -1px;
188
+ box-shadow: -4px 0 8px color-mix(in oklab, --theme(--color-foreground) 8%, transparent);
189
+ }
130
190
  }
131
191
 
132
192
  /* List cards: the toolbar and the filter panel sit straight on the page background — no card background, no rule;
@@ -126,5 +126,6 @@
126
126
  "Wrong credentials.": "Error message on the login page when the e-mail address / username or the password is wrong.",
127
127
  "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
128
  "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
- "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."
129
+ "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 …"
130
131
  }
@@ -1,5 +1,5 @@
1
1
  export { formatIcuPlural, isIcuPlural } from './plural.js';
2
- export { getTranslationState, m, setTranslations, subscribeTranslations, type TranslateOptions, translateText, translationKeyOf, type WritingStyle, } from './store.js';
2
+ export { getTranslationState, m, type MarkOptions, setTranslations, subscribeTranslations, type TranslateOptions, translateText, translationKeyOf, type WritingStyle, } from './store.js';
3
3
  export { Translate, type TranslateProps } from './Translate.js';
4
4
  export { type TranslateFn, useTranslate } from './useTranslate.js';
5
5
  export { formatUiNumber, getUiLocale, uiDateTimeFormat, uiNumberFormat, uiRelativeTimeFormat } from './format.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,mBAAmB,EACnB,CAAC,EACD,eAAe,EACf,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,aAAa,EACb,gBAAgB,EAChB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAClH,OAAO,EACL,yBAAyB,EACzB,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,mBAAmB,EACnB,CAAC,EACD,KAAK,WAAW,EAChB,eAAe,EACf,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,aAAa,EACb,gBAAgB,EAChB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAClH,OAAO,EACL,yBAAyB,EACzB,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,mBAAmB,EACnB,CAAC,EACD,eAAe,EACf,qBAAqB,EAErB,aAAa,EACb,gBAAgB,GAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAiB,CAAC;AACjE,OAAO,EAAoB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAClH,OAAO,EACL,yBAAyB,EAEzB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,mBAAmB,EACnB,CAAC,EAED,eAAe,EACf,qBAAqB,EAErB,aAAa,EACb,gBAAgB,GAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAiB,CAAC;AACjE,OAAO,EAAoB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAClH,OAAO,EACL,yBAAyB,EAEzB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC"}
@@ -27,10 +27,18 @@ export declare const setTranslations: (languageCode: string, writingStyle: Writi
27
27
  export declare const translationKeyOf: (text: string, context?: string) => string;
28
28
  /** Translates `text` in the active language (English text when no translation exists). */
29
29
  export declare const translateText: (text: string, options?: TranslateOptions) => string;
30
+ /** Options of the `m()` marker: what text exports read next to the text. */
31
+ export interface MarkOptions {
32
+ /** The translation context the text is rendered with (key `<text>__<context>`). */
33
+ context?: string;
34
+ }
30
35
  /**
31
36
  * Marks an English UI text that is defined outside a component (status maps, column definitions, option lists) for
32
- * the key export, unchanged. The component that renders it translates it with `t(value)`.
37
+ * the key export, unchanged. The component that renders it translates it with `t(value)`, or with
38
+ * `t(value, { context })` for a text marked `m('Failed', { context: 'import-status' })`. The marker returns the text
39
+ * only: the context reaches the renderer separately (e.g. `StatusDefinition.context`). Text exports read the text and
40
+ * the context as literals, so write both as string literals.
33
41
  */
34
- export declare const m: <TText extends string>(text: TText) => TText;
42
+ export declare const m: <TText extends string>(text: TText, _options?: MarkOptions) => TText;
35
43
  export {};
36
44
  //# sourceMappingURL=store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/i18n/store.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,6GAA6G;IA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C,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAChD;AAED,UAAU,gBAAgB;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AASD,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAGvE,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAO,gBAAyB,CAAC;AAEjE,6GAA6G;AAC7G,eAAO,MAAM,eAAe,GAC1B,cAAc,MAAM,EACpB,cAAc,YAAY,EAC1B,cAAc,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAC7C,IAGF,CAAC;AAEF,yDAAyD;AACzD,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,UAAU,MAAM,KAAG,MAAkD,CAAC;AAOrH,0FAA0F;AAC1F,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,EAAE,UAAS,gBAAqB,KAAG,MAQ5E,CAAC;AAEF,4EAA4E;AAC5E,MAAM,WAAW,WAAW;IAC1B,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,CAAC,GAAI,KAAK,SAAS,MAAM,EAAE,MAAM,KAAK,EAAE,WAAW,WAAW,KAAG,KAAa,CAAC"}
@@ -1,3 +1,4 @@
1
+ // @translations-ignore-file — the doc examples below are not UI texts
1
2
  import { formatIcuPlural } from "./plural.js";
2
3
  let state = { languageCode: 'en', writingStyle: 'FORMAL', translations: {}, version: 0 };
3
4
  const listeners = new Set();
@@ -30,7 +31,10 @@ export const translateText = (text, options = {}) => {
30
31
  };
31
32
  /**
32
33
  * Marks an English UI text that is defined outside a component (status maps, column definitions, option lists) for
33
- * the key export, unchanged. The component that renders it translates it with `t(value)`.
34
+ * the key export, unchanged. The component that renders it translates it with `t(value)`, or with
35
+ * `t(value, { context })` for a text marked `m('Failed', { context: 'import-status' })`. The marker returns the text
36
+ * only: the context reaches the renderer separately (e.g. `StatusDefinition.context`). Text exports read the text and
37
+ * the context as literals, so write both as string literals.
34
38
  */
35
- export const m = (text) => text;
39
+ export const m = (text, _options) => text;
36
40
  //# sourceMappingURL=store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/i18n/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA2B9C,IAAI,KAAK,GAAqB,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC3G,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;AAExC,MAAM,IAAI,GAAG,GAAG,EAAE;IAChB,KAAK,MAAM,QAAQ,IAAI,SAAS;QAAE,QAAQ,EAAE,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAoB,EAAgB,EAAE;IAC1E,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAqB,EAAE,CAAC,KAAK,CAAC;AAEjE,6GAA6G;AAC7G,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,YAAoB,EACpB,YAA0B,EAC1B,YAA8C,EACxC,EAAE;IACR,KAAK,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,KAA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5
  "keys": [
6
6
  {
@@ -594,6 +594,14 @@
594
594
  ],
595
595
  "hint": "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)."
596
596
  },
597
+ {
598
+ "key": "Row number",
599
+ "text": "Row number",
600
+ "files": [
601
+ "list/EntityListTable.tsx"
602
+ ],
603
+ "hint": "Screen-reader name of the narrow '#' column at the start of a list table that numbers the loaded rows 1, 2, 3 …"
604
+ },
597
605
  {
598
606
  "key": "Save changes",
599
607
  "text": "Save changes",
@@ -1,8 +1,8 @@
1
1
  import type { ReactNode } from 'react';
2
- import { type EntityListColumn } from './EntityListTable.js';
2
+ import { type EntityListColumn, type EntityListTableProps } from './EntityListTable.js';
3
3
  import type { EntityCardRenderer, EntityListDataProps, ListDisplayMode } from './types.js';
4
4
  import type { EntityListSelection } from '../logic/react/useRowSelection.js';
5
- export interface EntityListBodyProps<TItem, TExtra extends string = never> extends EntityListDataProps<TItem> {
5
+ export interface EntityListBodyProps<TItem, TExtra extends string = never> extends EntityListDataProps<TItem>, Pick<EntityListTableProps<TItem>, 'sort' | 'onSortChange' | 'sortRequired' | 'showRowIndex'> {
6
6
  displayMode: ListDisplayMode | TExtra;
7
7
  columns: EntityListColumn<TItem>[];
8
8
  /** Card of the grid view. Absent → table only (and no view toggle). */
@@ -17,11 +17,18 @@ export interface EntityListBodyProps<TItem, TExtra extends string = never> exten
17
17
  * table.
18
18
  */
19
19
  renderExtraView?: (mode: TExtra, items: TItem[]) => ReactNode;
20
+ /**
21
+ * A view that owns its data and its states (e.g. a tree loaded by its own query): drawn in the list card as is,
22
+ * without the paged list's skeletons, empty and error states and infinite-scroll tail. Returns `undefined` for a mode
23
+ * it does not own (then `renderExtraView`, then the table apply). While it is shown, the host leaves the toolbar's
24
+ * search, filters and clear button out when they do not act on it.
25
+ */
26
+ renderOwnView?: (mode: TExtra) => ReactNode | undefined;
20
27
  }
21
28
  /**
22
29
  * The list card's body: the table or the card grid of the same rows, each with its own
23
30
  * scroll container, empty states and infinite-scroll tail. Below `md` a list with a card always shows cards (the
24
31
  * toggle is hidden there), because a multi-column table does not fit a phone.
25
32
  */
26
- export declare const EntityListBody: <TItem, TExtra extends string = never>({ displayMode, columns, renderCard, skeletonRows, skeletonCards, selection, renderExtraView, className, ...data }: EntityListBodyProps<TItem, TExtra>) => import("react").JSX.Element;
33
+ export declare const EntityListBody: <TItem, TExtra extends string = never>({ displayMode, columns, renderCard, skeletonRows, skeletonCards, selection, renderExtraView, renderOwnView, sort, onSortChange, sortRequired, showRowIndex, className, ...data }: EntityListBodyProps<TItem, TExtra>) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null;
27
34
  //# sourceMappingURL=EntityListBody.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListBody.d.ts","sourceRoot":"","sources":["../../src/list/EntityListBody.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,MAAM,WAAW,mBAAmB,CAAC,KAAK,EAAE,MAAM,SAAS,MAAM,GAAG,KAAK,CAAE,SAAQ,mBAAmB,CAAC,KAAK,CAAC;IAC3G,WAAW,EAAE,eAAe,GAAG,MAAM,CAAC;IACtC,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;IACnC,uEAAuE;IACvE,UAAU,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa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AAmB,CAAC,KAAK,CAAC,CAAC;IACvC;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,SAAS,CAAC;IAC9D;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,CAAC;CACzD;AAKD;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,EAAE,MAAM,SAAS,MAAM,GAAG,KAAK,EAAE,kLAelE,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,oTA6CpC,CAAC"}
@@ -9,16 +9,22 @@ const isExtraMode = (mode) => mode !== 'table' && mode !== 'grid';
9
9
  * scroll container, empty states and infinite-scroll tail. Below `md` a list with a card always shows cards (the
10
10
  * toggle is hidden there), because a multi-column table does not fit a phone.
11
11
  */
12
- export const EntityListBody = ({ displayMode, columns, renderCard, skeletonRows, skeletonCards, selection, renderExtraView, className, ...data }) => {
12
+ export const EntityListBody = ({ displayMode, columns, renderCard, skeletonRows, skeletonCards, selection, renderExtraView, renderOwnView, sort, onSortChange, sortRequired, showRowIndex, className, ...data }) => {
13
+ if (isExtraMode(displayMode) && renderOwnView) {
14
+ const ownView = renderOwnView(displayMode);
15
+ if (ownView !== undefined)
16
+ return ownView;
17
+ }
18
+ const tableProps = { sort, onSortChange, sortRequired, showRowIndex };
13
19
  if (isExtraMode(displayMode) && renderExtraView) {
14
20
  return (_jsx(EntityListGrid, { ...data, renderItems: items => renderExtraView(displayMode, items), skeletonCards: skeletonCards, isGridView: false, className: className }));
15
21
  }
16
22
  if (!renderCard) {
17
- return _jsx(EntityListTable, { ...data, columns: columns, skeletonRows: skeletonRows, selection: selection, className: className });
23
+ return (_jsx(EntityListTable, { ...data, ...tableProps, columns: columns, skeletonRows: skeletonRows, selection: selection, className: className }));
18
24
  }
19
25
  if (displayMode === 'grid') {
20
26
  return _jsx(EntityListGrid, { ...data, renderCard: renderCard, skeletonCards: skeletonCards, className: className });
21
27
  }
22
- return (_jsxs(_Fragment, { children: [_jsx(EntityListTable, { ...data, columns: columns, skeletonRows: skeletonRows, selection: selection, className: cn('hidden md:block', className) }), _jsx(EntityListGrid, { ...data, renderCard: renderCard, skeletonCards: skeletonCards, isGridView: false, className: cn('md:hidden', className) })] }));
28
+ return (_jsxs(_Fragment, { children: [_jsx(EntityListTable, { ...data, ...tableProps, columns: columns, skeletonRows: skeletonRows, selection: selection, className: cn('hidden md:block', className) }), _jsx(EntityListGrid, { ...data, renderCard: renderCard, skeletonCards: skeletonCards, isGridView: false, className: cn('md:hidden', className) })] }));
23
29
  };
24
30
  //# sourceMappingURL=EntityListBody.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListBody.js","sourceRoot":"","sources":["../../src/list/EntityListBody.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EAAyB,eAAe,EAAE,MAAM,sBAAuB,CAAC;AAqB/E,MAAM,WAAW,GAAG,CAAwB,IAA8B,EAAkB,EAAE,CAC5F,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,MAAM,CAAC;AAEtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAuC,EACnE,WAAW,EACX,OAAO,EACP,UAAU,EACV,YAAY,EACZ,aAAa,EACb,SAAS,EACT,eAAe,EACf,SAAS,EACT,GAAG,IAAI,EAC4B,EAAE,EAAE;IACvC,IAAI,WAAW,CAAC,WAAW,CAAC,IAAI,eAAe,EAAE,CAAC;QAChD,OAAO,CACL,KAAC,cAAc,OACT,IAAI,EACR,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,EACzD,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,KAAK,EACjB,SA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AAS,EAAE,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,GAC3C,EACF,KAAC,cAAc,OAAK,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,GAAI,IAC3I,CACJ,CAAC;AACJ,CAAC,CAAC"}
@@ -1,5 +1,7 @@
1
- import type { ReactNode } from 'react';
1
+ import { type ReactNode } from 'react';
2
2
  import type { EntityListDataProps } from './types.js';
3
+ import { type EntityListSort, type ListSortDirection } from '../logic/pure/listSort.js';
4
+ import { type ListColumnAlign, type ListColumnPin, type ListColumnWidth } from '../logic/pure/listTracks.js';
3
5
  import type { EntityListSelection } from '../logic/react/useRowSelection.js';
4
6
  export interface EntityListColumn<TItem> {
5
7
  id: string;
@@ -7,7 +9,29 @@ export interface EntityListColumn<TItem> {
7
9
  cell: (item: TItem) => ReactNode;
8
10
  /** Content of this column's cell in an optional filter row under the header (prefer the toolbar search). */
9
11
  filter?: ReactNode;
12
+ /** Classes of the column's header and body cells. In a table with tracks a width class does not size the column. */
10
13
  className?: string;
14
+ /**
15
+ * Track of the column: a share of the free width (`'1fr'`, `'2fr'`) or a fixed length (`'120px'`). One column with a
16
+ * width gives every column a track (default `'1fr'`); without any width the table sizes its columns by content.
17
+ */
18
+ width?: ListColumnWidth;
19
+ /** Lower bound in px of a share column (default 120). The table scrolls sideways inside its card instead of squeezing. */
20
+ minWidth?: number;
21
+ /**
22
+ * Stays on screen while the table scrolls sideways. `end` always holds (a row's actions); `start` is a request,
23
+ * honoured only while the table overflows and the pinned columns take less than a third of the visible width.
24
+ */
25
+ pin?: ListColumnPin;
26
+ /** Horizontal alignment of the header and the cells (default `start`). */
27
+ align?: ListColumnAlign;
28
+ /**
29
+ * Makes the header a sort control (with the table's `onSortChange`); the value names the sort and comes back in
30
+ * `onSortChange`. The table never sorts rows itself: the host maps the key to its request.
31
+ */
32
+ sortKey?: string;
33
+ /** The first direction when this column becomes sorted (default `'asc'`; e.g. `'desc'` for dates, newest first). */
34
+ sortStart?: ListSortDirection;
11
35
  }
12
36
  export interface EntityListTableProps<TItem> extends EntityListDataProps<TItem> {
13
37
  columns: EntityListColumn<TItem>[];
@@ -24,11 +48,27 @@ export interface EntityListTableProps<TItem> extends EntityListDataProps<TItem>
24
48
  * `className` that makes the table's own wrapper non-scrolling (`overflow-visible`), the header sticks to the page.
25
49
  */
26
50
  stickyHeaderTop?: string;
51
+ /** The current sort (`null`: the host's default order). Shown on the header of the column with that `sortKey`. */
52
+ sort?: EntityListSort | null;
53
+ /**
54
+ * Called with the next sort when a sortable header is clicked: not sorted → the column's `sortStart` (ascending by
55
+ * default) → the other direction → `null` (or back to `sortStart` with `sortRequired`).
56
+ */
57
+ onSortChange?: (sort: EntityListSort | null) => void;
58
+ /** The list is always sorted: a sorted column's third click returns to its first direction instead of `null`. */
59
+ sortRequired?: boolean;
60
+ /** A leading `#` column: the 1-based position of the row among the loaded rows. Pinned with the selection column. */
61
+ showRowIndex?: boolean;
27
62
  }
28
63
  /**
29
64
  * Table view of an entity list: one scroll container that fills its card, sticky header, skeleton rows on the
30
65
  * first load, an empty / no-results / error block, and the infinite-scroll tail. Use it inside `EntityListPage`
31
66
  * (directly or through `EntityListBody`), or on its own (it then brings its own card border via `className`).
67
+ *
68
+ * Optional, per table: column tracks (`width`, `minWidth`), pinned columns (`pin`), alignment (`align`), sortable
69
+ * headers (`sortKey` + `sort` / `onSortChange`) and a row index (`showRowIndex`). A table that uses none of them renders
70
+ * exactly as before they existed. Sizes are measured only after hydration; the server render and the hydration render
71
+ * use the CSS form of the same tracks.
32
72
  */
33
- export declare const EntityListTable: <TItem>({ columns, items, getRowKey, isLoading, isFetchingMore, hasMore, onLoadMore, emptyMessage, noResultsMessage, isSearchActive, onClearSearch, loadingMessage, error, rowAction, skeletonRows, selection, className, stickyHeaderTop, }: EntityListTableProps<TItem>) => import("react").JSX.Element;
73
+ export declare const EntityListTable: <TItem>({ columns, items, getRowKey, isLoading, isFetchingMore, hasMore, onLoadMore, emptyMessage, noResultsMessage, isSearchActive, onClearSearch, loadingMessage, error, rowAction, skeletonRows, selection, className, stickyHeaderTop, sort, onSortChange, sortRequired, showRowIndex, }: EntityListTableProps<TItem>) => import("react").JSX.Element;
34
74
  //# sourceMappingURL=EntityListTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListTable.d.ts","sourceRoot":"","sources":["../../src/list/EntityListTable.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,MAAM,WAAW,gBAAgB,CAAC,KAAK;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,SAAS,CAAC;IACjC,4GAA4G;IAC5G,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB,CAAC,KAAK,CAAE,SAAQ,mBAAmB,CAAC,KAAK,CAAC;IAC7E,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;IACnC,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACvC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAmED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,EAAG,sOAmBrC,oBAAoB,CAAC,KAAK,CAAC,gCAoF7B,CAAC"}
1
+ {"version":3,"file":"EntityListTable.d.ts","sourceRoot":"","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H,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kHAAkH;IAClH,IAAI,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;IACrD,iHAAiH;IACjH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qHAAqH;IACrH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AA+KD;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,EAAG,sRAuBrC,oBAAoB,CAAC,KAAK,CAAC,gCA6O7B,CAAC"}
@@ -1,10 +1,14 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { ArrowDown, ArrowUp, ArrowUpDown } from 'lucide-react';
4
+ import { useLayoutEffect, useRef, useState } from 'react';
3
5
  import { Checkbox, Skeleton, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../primitives/index.js";
4
6
  import { useTranslate } from "../i18n/index.js";
5
7
  import { cn } from "../primitives/cn.js";
6
8
  import { EntityListLoadMore } from "./EntityListLoadMore.js";
7
9
  import { EntityListStatus } from "./EntityListStatus.js";
10
+ import { nextListSort } from "../logic/pure/listSort.js";
11
+ import { computeListTracks, hasListTracks, listTrackTemplate, minimumListWidth, resolveListPins, } from "../logic/pure/listTracks.js";
8
12
  import { useRowActivation } from "../logic/react/useRowActivation.js";
9
13
  /**
10
14
  * Column labels in the section-label voice: small, heavy, uppercase, tracked out. Every header cell is sticky
@@ -15,29 +19,177 @@ const HEADER_CELL_CLASS = 'sticky z-(--layer-raised) h-12 bg-card px-4 text-[11.
15
19
  /** Roomy rows: 16 px cells, 24 px at the card edge. */
16
20
  const BODY_CELL_CLASS = 'px-4 py-3.5 first:pl-6 last:pr-6';
17
21
  const SELECT_CELL_CLASS = 'w-10 pr-0';
22
+ const INDEX_CELL_CLASS = 'pr-0 tabular-nums text-muted-foreground';
23
+ /** Cells of a table with tracks: the text wraps inside its track instead of running into the next column. */
24
+ const TRACK_CELL_CLASS = 'whitespace-normal break-words';
25
+ /** The content box of a cell in a table with tracks (the cell itself is a flex row that centres it vertically). */
26
+ const TRACK_CONTENT_CLASS = 'min-w-0 flex-1';
27
+ /** Track of the selection column: 24 px card-edge inset + the 16 px checkbox. */
28
+ const SELECT_TRACK_PX = 40;
29
+ /** Track of the row index: up to four digits after the card-edge inset (first column) or the 16 px cell inset. */
30
+ const indexTrackPx = (afterSelection) => (afterSelection ? 48 : 56);
31
+ const ALIGN_CLASS = {
32
+ start: undefined,
33
+ center: 'text-center',
34
+ end: 'text-end',
35
+ };
36
+ /** Pin attributes and sticky offset of the cell at `position` (nothing for an unpinned cell). */
37
+ const pinProps = (layout, position, header) => {
38
+ const placement = layout.placements?.[position] ?? null;
39
+ if (!placement)
40
+ return undefined;
41
+ const style = {
42
+ position: 'sticky',
43
+ [placement.side === 'start' ? 'left' : 'right']: placement.offset,
44
+ // a pinned header cell paints above the header cells scrolling under it, a pinned body cell above body cells
45
+ zIndex: header ? 'calc(var(--layer-raised) + 1)' : 1,
46
+ };
47
+ return { style, 'data-list-pin': placement.side, 'data-list-pin-edge': placement.edge ? '' : undefined };
48
+ };
49
+ /** Cell content: as is in a content-sized table, in a shrinkable box in a table with tracks. */
50
+ const cellContent = (layout, content, align) => layout.tracks ? _jsx("div", { className: cn(TRACK_CONTENT_CLASS, align && ALIGN_CLASS[align]), children: content }) : content;
51
+ /** Classes a cell adds for the layout: wrapping in a table with tracks, the alignment on the cell otherwise. */
52
+ const cellLayoutClass = (layout, align) => layout.tracks ? TRACK_CELL_CLASS : align && ALIGN_CLASS[align];
53
+ /** `role` of a table element in a table with tracks: `display: grid` drops the native table semantics in some browsers. */
54
+ const roleIn = (layout, role) => (layout.tracks ? role : undefined);
18
55
  const SelectAllHeader = ({ selection, disabled }) => {
19
56
  const { t } = useTranslate();
20
57
  return (_jsx(Checkbox, { checked: selection.allLoadedState, onCheckedChange: checked => selection.setAllLoadedSelected(checked === true), disabled: disabled || selection.disabled, "aria-label": t('Select all loaded'), title: t('Select all loaded'), className: "align-middle" }));
21
58
  };
22
- const EntityListTableRow = ({ item, rowKey, columns, action, selection }) => {
59
+ /** A sortable column's header content: one button that moves the sort on; the cell carries `aria-sort`. */
60
+ const SortHeaderButton = ({ label, direction, onClick, iconFirst, }) => {
61
+ const Icon = direction === 'asc' ? ArrowUp : direction === 'desc' ? ArrowDown : ArrowUpDown;
62
+ const icon = _jsx(Icon, { "aria-hidden": true, className: cn('size-3.5 shrink-0', !direction && 'opacity-50') });
63
+ return (_jsxs("button", { type: "button", onClick: onClick, className: cn('-mx-1 inline-flex cursor-pointer items-center gap-1.5 rounded-sm px-1 text-left font-bold tracking-[inherit] uppercase outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring', direction && 'text-foreground'), children: [iconFirst && icon, _jsx("span", { children: label }), !iconFirst && icon] }));
64
+ };
65
+ const EntityListTableRow = ({ item, rowKey, columns, action, selection, rowNumber, layout }) => {
23
66
  const { t } = useTranslate();
24
67
  const activation = useRowActivation(action);
25
68
  const selected = selection?.isItemSelected(item) ?? false;
26
- return (_jsxs(TableRow, { className: cn('group/row', action && 'cursor-pointer'), "data-state": selected ? 'selected' : undefined, ...activation, children: [selection && (_jsx(TableCell, { className: cn(BODY_CELL_CLASS, SELECT_CELL_CLASS), "data-row-action-ignore": true, children: selection.isItemSelectable(item) && (_jsx(Checkbox, { checked: selected, onCheckedChange: checked => selection.setItemSelected(item, checked === true), disabled: selection.disabled, "aria-label": selection.rowLabel?.(item) ?? t('Select row %rowKey%', { replacements: { rowKey } }), className: "align-middle" })) })), columns.map(column => (_jsx(TableCell, { className: cn(BODY_CELL_CLASS, column.className), children: column.cell(item) }, column.id)))] }));
69
+ const leading = (selection ? 1 : 0) + (rowNumber !== undefined ? 1 : 0);
70
+ return (_jsxs(TableRow, { className: cn('group/row', action && 'cursor-pointer'), "data-state": selected ? 'selected' : undefined, role: roleIn(layout, 'row'), ...activation, children: [selection && (_jsx(TableCell, { className: cn(BODY_CELL_CLASS, SELECT_CELL_CLASS), "data-row-action-ignore": true, role: roleIn(layout, 'cell'), ...pinProps(layout, 0, false), children: selection.isItemSelectable(item) && (_jsx(Checkbox, { checked: selected, onCheckedChange: checked => selection.setItemSelected(item, checked === true), disabled: selection.disabled, "aria-label": selection.rowLabel?.(item) ?? t('Select row %rowKey%', { replacements: { rowKey } }), className: "align-middle" })) })), rowNumber !== undefined && (_jsx(TableCell, { className: cn(BODY_CELL_CLASS, INDEX_CELL_CLASS), role: roleIn(layout, 'cell'), ...pinProps(layout, selection ? 1 : 0, false), children: rowNumber })), columns.map((column, index) => (_jsx(TableCell, { className: cn(BODY_CELL_CLASS, column.className, cellLayoutClass(layout, column.align)), role: roleIn(layout, 'cell'), ...pinProps(layout, leading + index, false), children: cellContent(layout, column.cell(item), column.align) }, column.id)))] }));
27
71
  };
72
+ const sameMeasure = (previous, next) => previous !== null &&
73
+ previous.visibleWidth === next.visibleWidth &&
74
+ previous.scrollWidth === next.scrollWidth &&
75
+ previous.cellWidths.length === next.cellWidths.length &&
76
+ previous.cellWidths.every((width, index) => Math.abs(width - (next.cellWidths[index] ?? 0)) < 0.5);
28
77
  /**
29
78
  * Table view of an entity list: one scroll container that fills its card, sticky header, skeleton rows on the
30
79
  * first load, an empty / no-results / error block, and the infinite-scroll tail. Use it inside `EntityListPage`
31
80
  * (directly or through `EntityListBody`), or on its own (it then brings its own card border via `className`).
81
+ *
82
+ * Optional, per table: column tracks (`width`, `minWidth`), pinned columns (`pin`), alignment (`align`), sortable
83
+ * headers (`sortKey` + `sort` / `onSortChange`) and a row index (`showRowIndex`). A table that uses none of them renders
84
+ * exactly as before they existed. Sizes are measured only after hydration; the server render and the hydration render
85
+ * use the CSS form of the same tracks.
32
86
  */
33
- export const EntityListTable = ({ columns, items, getRowKey, isLoading = false, isFetchingMore = false, hasMore = false, onLoadMore, emptyMessage, noResultsMessage, isSearchActive, onClearSearch, loadingMessage, error, rowAction, skeletonRows = 8, selection, className, stickyHeaderTop, }) => {
87
+ export const EntityListTable = ({ columns, items, getRowKey, isLoading = false, isFetchingMore = false, hasMore = false, onLoadMore, emptyMessage, noResultsMessage, isSearchActive, onClearSearch, loadingMessage, error, rowAction, skeletonRows = 8, selection, className, stickyHeaderTop, sort, onSortChange, sortRequired = false, showRowIndex = false, }) => {
34
88
  const { t } = useTranslate();
35
89
  const headerTopStyle = stickyHeaderTop ? { top: stickyHeaderTop } : undefined;
36
90
  const hasFilterRow = columns.some(column => column.filter !== undefined);
37
91
  const showRows = !error && !isLoading && items.length > 0;
38
- return (_jsxs("div", { "data-entity-list-scroll": true, className: cn('relative overflow-auto md:min-h-0 md:flex-1', className), "aria-busy": isLoading || isFetchingMore, children: [_jsxs("table", { className: "w-full caption-bottom text-sm", children: [_jsxs(TableHeader, { className: "[&_tr]:border-0", children: [_jsxs(TableRow, { className: "hover:bg-transparent", children: [selection && (_jsx(TableHead, { className: cn(HEADER_CELL_CLASS, 'top-0', SELECT_CELL_CLASS), style: headerTopStyle, children: _jsx(SelectAllHeader, { selection: selection, disabled: isLoading || items.length === 0 }) })), columns.map(column => (_jsx(TableHead, { className: cn(HEADER_CELL_CLASS, 'top-0', column.className), style: headerTopStyle, children: typeof column.header === 'string' ? t(column.header) : column.header }, column.id)))] }), hasFilterRow && (_jsxs(TableRow, { className: "hover:bg-transparent", children: [selection && _jsx(TableHead, { className: cn(HEADER_CELL_CLASS, 'top-12 py-2.5', SELECT_CELL_CLASS) }), columns.map(column => (_jsx(TableHead, { className: cn(HEADER_CELL_CLASS, 'top-12 py-2.5 font-normal normal-case', column.className), children: column.filter }, column.id)))] }))] }), _jsx(TableBody, { children: isLoading && !error
39
- ? Array.from({ length: skeletonRows }, (_, row) => (_jsxs(TableRow, { className: "hover:bg-transparent", "aria-hidden": true, children: [selection && (_jsx(TableCell, { className: cn(BODY_CELL_CLASS, SELECT_CELL_CLASS), children: _jsx(Skeleton, { className: "size-4" }) })), columns.map(column => (_jsx(TableCell, { className: cn(BODY_CELL_CLASS, column.className), children: _jsx(Skeleton, { className: "h-4 w-full min-w-12" }) }, column.id)))] }, row)))
92
+ // ── layout: tracks, pins, row index (all optional; none of them → the content-sized table as before) ──────────────
93
+ const leadingCount = (selection ? 1 : 0) + (showRowIndex ? 1 : 0);
94
+ const tracks = [
95
+ ...(selection ? [{ width: `${SELECT_TRACK_PX}px` }] : []),
96
+ ...(showRowIndex ? [{ width: `${indexTrackPx(selection !== undefined)}px` }] : []),
97
+ ...columns.map(column => ({ width: column.width, minWidth: column.minWidth })),
98
+ ];
99
+ const sized = hasListTracks(columns);
100
+ const usesLayout = sized || showRowIndex || columns.some(column => column.pin !== undefined);
101
+ const trackSignature = tracks.map(track => `${track.width ?? ''}/${track.minWidth ?? ''}`).join(' ');
102
+ const scrollRef = useRef(null);
103
+ const headerRowRef = useRef(null);
104
+ const [measure, setMeasure] = useState(null);
105
+ // After hydration only (effects never run on the server, and the first client render matches the server HTML):
106
+ // the visible width, and in a content-sized table the header cells, re-read on every resize. The scroll position is
107
+ // written to the DOM directly (pinned cells show their surface and edge only while content is under them).
108
+ // biome-ignore lint/correctness/useExhaustiveDependencies: trackSignature re-subscribes when the columns change
109
+ useLayoutEffect(() => {
110
+ const scroller = scrollRef.current;
111
+ if (!usesLayout || !scroller || typeof ResizeObserver === 'undefined')
112
+ return;
113
+ const syncScrollEdges = () => {
114
+ const overflow = scroller.scrollWidth - scroller.clientWidth;
115
+ const scrolled = Math.abs(scroller.scrollLeft);
116
+ scroller.toggleAttribute('data-list-overflow-start', overflow > 1 && scrolled > 1);
117
+ scroller.toggleAttribute('data-list-overflow-end', overflow > 1 && scrolled < overflow - 1);
118
+ };
119
+ const read = () => {
120
+ const visibleWidth = scroller.clientWidth;
121
+ if (visibleWidth <= 0) {
122
+ // hidden (e.g. the table below `md` next to the phone cards): nothing to lay out
123
+ setMeasure(previous => (previous === null ? previous : null));
124
+ return;
125
+ }
126
+ const cellWidths = sized
127
+ ? []
128
+ : Array.from(headerRowRef.current?.children ?? [], cell => cell.getBoundingClientRect().width);
129
+ const next = { visibleWidth, scrollWidth: scroller.scrollWidth, cellWidths };
130
+ setMeasure(previous => (sameMeasure(previous, next) ? previous : next));
131
+ syncScrollEdges();
132
+ };
133
+ const observer = new ResizeObserver(read);
134
+ observer.observe(scroller);
135
+ const table = scroller.querySelector('table');
136
+ if (table)
137
+ observer.observe(table);
138
+ if (!sized)
139
+ for (const cell of Array.from(headerRowRef.current?.children ?? []))
140
+ observer.observe(cell);
141
+ scroller.addEventListener('scroll', syncScrollEdges, { passive: true });
142
+ read();
143
+ return () => {
144
+ observer.disconnect();
145
+ scroller.removeEventListener('scroll', syncScrollEdges);
146
+ scroller.removeAttribute('data-list-overflow-start');
147
+ scroller.removeAttribute('data-list-overflow-end');
148
+ };
149
+ }, [usesLayout, sized, trackSignature]);
150
+ let gridStyle;
151
+ let placements = null;
152
+ if (usesLayout) {
153
+ const pinRequests = [
154
+ ...Array.from({ length: leadingCount }, () => ({ always: true })),
155
+ ...columns.map(column => ({ pin: column.pin })),
156
+ ];
157
+ if (sized) {
158
+ const computed = measure ? computeListTracks(tracks, measure.visibleWidth) : null;
159
+ const fixedWidths = tracks.map(track => (track.width?.endsWith('px') ? Number.parseFloat(track.width) : null));
160
+ placements = resolveListPins(pinRequests, {
161
+ widths: computed?.widths ?? fixedWidths,
162
+ visibleWidth: measure?.visibleWidth ?? null,
163
+ scrollWidth: computed?.scrollWidth ?? null,
164
+ }).placements;
165
+ gridStyle = computed
166
+ ? { gridTemplateColumns: computed.widths.map(width => `${width}px`).join(' '), minWidth: computed.scrollWidth }
167
+ : { gridTemplateColumns: listTrackTemplate(tracks), minWidth: minimumListWidth(tracks) };
168
+ }
169
+ else {
170
+ const measured = measure && measure.cellWidths.length === tracks.length ? measure : null;
171
+ placements = resolveListPins(pinRequests, {
172
+ widths: measured?.cellWidths ?? tracks.map(() => null),
173
+ visibleWidth: measured?.visibleWidth ?? null,
174
+ scrollWidth: measured?.scrollWidth ?? null,
175
+ }).placements;
176
+ }
177
+ }
178
+ const layout = { tracks: sized, placements };
179
+ const headerCellProps = (position, extraStyle) => {
180
+ const pin = pinProps(layout, position, true);
181
+ const style = pin || extraStyle ? { ...extraStyle, ...pin?.style } : undefined;
182
+ return { ...pin, style, role: roleIn(layout, 'columnheader') };
183
+ };
184
+ const indexPosition = selection ? 1 : 0;
185
+ return (_jsxs("div", { ref: scrollRef, "data-entity-list-scroll": true, className: cn('relative overflow-auto md:min-h-0 md:flex-1', className), "aria-busy": isLoading || isFetchingMore, children: [_jsxs("table", { className: "w-full caption-bottom text-sm", "data-list-tracks": sized ? '' : undefined, role: roleIn(layout, 'table'), style: gridStyle, children: [_jsxs(TableHeader, { className: "[&_tr]:border-0", role: roleIn(layout, 'rowgroup'), style: sized && headerTopStyle ? headerTopStyle : undefined, children: [_jsxs(TableRow, { ref: headerRowRef, className: "hover:bg-transparent", role: roleIn(layout, 'row'), children: [selection && (_jsx(TableHead, { className: cn(HEADER_CELL_CLASS, 'top-0', SELECT_CELL_CLASS), ...headerCellProps(0, headerTopStyle), children: _jsx(SelectAllHeader, { selection: selection, disabled: isLoading || items.length === 0 }) })), showRowIndex && (_jsxs(TableHead, { className: cn(HEADER_CELL_CLASS, 'top-0', INDEX_CELL_CLASS), ...headerCellProps(indexPosition, headerTopStyle), children: [_jsx("span", { "aria-hidden": true, children: "#" }), _jsx("span", { className: "sr-only", children: t('Row number') })] })), columns.map((column, index) => {
186
+ const label = typeof column.header === 'string' ? t(column.header) : column.header;
187
+ const sortable = column.sortKey !== undefined && onSortChange !== undefined;
188
+ const direction = sortable && sort && sort.key === column.sortKey ? sort.direction : undefined;
189
+ return (_jsx(TableHead, { className: cn(HEADER_CELL_CLASS, 'top-0', column.className, cellLayoutClass(layout, column.align)), "aria-sort": direction === 'asc' ? 'ascending' : direction === 'desc' ? 'descending' : undefined, ...headerCellProps(leadingCount + index, headerTopStyle), children: cellContent(layout, sortable ? (_jsx(SortHeaderButton, { label: label, direction: direction, onClick: () => onSortChange(nextListSort(sort, column.sortKey, { start: column.sortStart, required: sortRequired })), iconFirst: column.align === 'end' })) : (label), column.align) }, column.id));
190
+ })] }), hasFilterRow && (_jsxs(TableRow, { className: "hover:bg-transparent", role: roleIn(layout, 'row'), children: [selection && _jsx(TableHead, { className: cn(HEADER_CELL_CLASS, 'top-12 py-2.5', SELECT_CELL_CLASS), ...headerCellProps(0) }), showRowIndex && (_jsx(TableHead, { className: cn(HEADER_CELL_CLASS, 'top-12 py-2.5', INDEX_CELL_CLASS), ...headerCellProps(indexPosition) })), columns.map((column, index) => (_jsx(TableHead, { className: cn(HEADER_CELL_CLASS, 'top-12 py-2.5 font-normal normal-case', column.className, cellLayoutClass(layout, column.align)), ...headerCellProps(leadingCount + index), children: column.filter === undefined ? column.filter : cellContent(layout, column.filter, column.align) }, column.id)))] }))] }), _jsx(TableBody, { role: roleIn(layout, 'rowgroup'), children: isLoading && !error
191
+ ? Array.from({ length: skeletonRows }, (_, row) => (_jsxs(TableRow, { className: "hover:bg-transparent", "aria-hidden": true, role: roleIn(layout, 'row'), children: [selection && (_jsx(TableCell, { className: cn(BODY_CELL_CLASS, SELECT_CELL_CLASS), role: roleIn(layout, 'cell'), ...pinProps(layout, 0, false), children: _jsx(Skeleton, { className: "size-4" }) })), showRowIndex && (_jsx(TableCell, { className: cn(BODY_CELL_CLASS, INDEX_CELL_CLASS), role: roleIn(layout, 'cell'), ...pinProps(layout, indexPosition, false), children: _jsx(Skeleton, { className: "h-4 w-5" }) })), columns.map((column, index) => (_jsx(TableCell, { className: cn(BODY_CELL_CLASS, column.className, cellLayoutClass(layout, column.align)), role: roleIn(layout, 'cell'), ...pinProps(layout, leadingCount + index, false), children: _jsx(Skeleton, { className: "h-4 w-full min-w-12" }) }, column.id)))] }, row)))
40
192
  : showRows &&
41
- items.map(item => (_jsx(EntityListTableRow, { rowKey: getRowKey(item), item: item, columns: columns, action: rowAction ? rowAction(item) : undefined, selection: selection }, getRowKey(item)))) })] }), _jsx(EntityListStatus, { itemCount: items.length, isLoading: isLoading, emptyMessage: emptyMessage, noResultsMessage: noResultsMessage, isSearchActive: isSearchActive, onClearSearch: onClearSearch, loadingMessage: loadingMessage, error: error }), _jsx(EntityListLoadMore, { hasMore: showRows && hasMore, isFetchingMore: isFetchingMore, onLoadMore: onLoadMore })] }));
193
+ items.map((item, index) => (_jsx(EntityListTableRow, { rowKey: getRowKey(item), item: item, columns: columns, action: rowAction ? rowAction(item) : undefined, selection: selection, rowNumber: showRowIndex ? index + 1 : undefined, layout: layout }, getRowKey(item)))) })] }), _jsx(EntityListStatus, { itemCount: items.length, isLoading: isLoading, emptyMessage: emptyMessage, noResultsMessage: noResultsMessage, isSearchActive: isSearchActive, onClearSearch: onClearSearch, loadingMessage: loadingMessage, error: error }), _jsx(EntityListLoadMore, { hasMore: showRows && hasMore, isFetchingMore: isFetchingMore, onLoadMore: onLoadMore })] }));
42
194
  };
43
195
  //# sourceMappingURL=EntityListTable.js.map