@cosmicdrift/kumiko-renderer 0.414.0 → 0.415.0

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 (124) hide show
  1. package/dist/app/entity-list-screen.js +12 -9
  2. package/dist/app/list-facets.d.ts +1 -0
  3. package/dist/app/list-facets.js +10 -1
  4. package/dist/app/named-filter-facet.d.ts +0 -1
  5. package/dist/app/named-filter-facet.js +19 -10
  6. package/dist/app/projection-detail-guidance-data.js +3 -1
  7. package/dist/app/projection-detail-guidance.js +9 -9
  8. package/dist/app/projection-detail-header.js +4 -3
  9. package/dist/app/projection-detail-navigation.d.ts +2 -0
  10. package/dist/app/projection-detail-navigation.js +13 -3
  11. package/dist/app/screen-access.js +1 -2
  12. package/dist/app/use-entity-list-payload.d.ts +2 -1
  13. package/dist/app/use-entity-list-payload.js +4 -2
  14. package/dist/app/use-projection-detail-actions.d.ts +1 -0
  15. package/dist/app/use-projection-detail-actions.js +26 -14
  16. package/dist/app/use-row-decoration.d.ts +6 -4
  17. package/dist/app/use-row-decoration.js +67 -19
  18. package/dist/app/use-screen-list-rows.js +1 -1
  19. package/dist/card-options.d.ts +25 -0
  20. package/dist/card-options.js +1 -0
  21. package/dist/components/list-empty-state.d.ts +5 -0
  22. package/dist/components/list-empty-state.js +17 -1
  23. package/dist/components/render-list-hint-columns.d.ts +1 -0
  24. package/dist/components/render-list-hint-columns.js +10 -0
  25. package/dist/components/render-list-toolbar-model.d.ts +2 -2
  26. package/dist/components/use-render-list-columns.js +3 -3
  27. package/dist/context/screen-focus-context.d.ts +1 -1
  28. package/dist/context/screen-focus-context.js +3 -3
  29. package/dist/data-table-facet-types.d.ts +4 -0
  30. package/dist/headless/index.d.ts +1 -1
  31. package/dist/headless/index.js +1 -1
  32. package/dist/headless/pwa-service-worker-meta.d.ts +3 -0
  33. package/dist/headless/pwa-service-worker-meta.js +10 -0
  34. package/dist/headless/view-model/types.d.ts +4 -0
  35. package/dist/i18n-defaults.js +2 -1
  36. package/dist/metric-types.d.ts +2 -0
  37. package/dist/primitives-record-guidance.d.ts +2 -0
  38. package/dist/primitives.d.ts +7 -24
  39. package/dist/web/app/dashboard-header.js +1 -1
  40. package/dist/web/app/dashboard-list-panel.js +8 -13
  41. package/dist/web/app/dashboard-panels.d.ts +1 -0
  42. package/dist/web/app/dashboard-panels.js +9 -7
  43. package/dist/web/app/dashboard-reference-list-table.js +1 -0
  44. package/dist/web/app/dashboard-shared.js +2 -1
  45. package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -0
  46. package/dist/web/app/dashboard-stat-group-panel.js +14 -7
  47. package/dist/web/app/dashboard-text-panel.js +8 -4
  48. package/dist/web/drawn-icons.d.ts +6 -0
  49. package/dist/web/drawn-icons.js +30 -0
  50. package/dist/web/icons.js +6 -5
  51. package/dist/web/index.d.ts +2 -0
  52. package/dist/web/index.js +2 -0
  53. package/dist/web/layout/default-app-shell.js +3 -3
  54. package/dist/web/layout/nav-collapse-state.d.ts +2 -0
  55. package/dist/web/layout/nav-collapse-state.js +10 -0
  56. package/dist/web/layout/nav-tree.js +46 -23
  57. package/dist/web/layout/notification-bell.d.ts +7 -2
  58. package/dist/web/layout/notification-bell.js +16 -5
  59. package/dist/web/layout/shell-focus.d.ts +2 -2
  60. package/dist/web/layout/shell-focus.js +7 -3
  61. package/dist/web/layout/shell-header.d.ts +2 -1
  62. package/dist/web/layout/shell-header.js +56 -27
  63. package/dist/web/layout/shell-style.d.ts +3 -0
  64. package/dist/web/layout/shell-style.js +6 -0
  65. package/dist/web/layout/workspace-shell.d.ts +11 -1
  66. package/dist/web/layout/workspace-shell.js +6 -4
  67. package/dist/web/primitives/banner.d.ts +1 -1
  68. package/dist/web/primitives/banner.js +12 -7
  69. package/dist/web/primitives/card.js +18 -8
  70. package/dist/web/primitives/data-table/actions-column.d.ts +1 -1
  71. package/dist/web/primitives/data-table/actions-column.js +3 -1
  72. package/dist/web/primitives/data-table/card-body.d.ts +1 -1
  73. package/dist/web/primitives/data-table/card-body.js +11 -6
  74. package/dist/web/primitives/data-table/card-row.js +21 -17
  75. package/dist/web/primitives/data-table/hint-cell.d.ts +1 -3
  76. package/dist/web/primitives/data-table/hint-cell.js +4 -10
  77. package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
  78. package/dist/web/primitives/data-table/row-render-parts.js +3 -2
  79. package/dist/web/primitives/data-table/sort-options-select.js +3 -3
  80. package/dist/web/primitives/data-table/table-content.js +4 -4
  81. package/dist/web/primitives/data-table/table-view.js +8 -3
  82. package/dist/web/primitives/data-table/toolbar.d.ts +2 -0
  83. package/dist/web/primitives/data-table/toolbar.js +44 -9
  84. package/dist/web/primitives/data-table/totals-footer.js +4 -3
  85. package/dist/web/primitives/data-table-cell.js +44 -18
  86. package/dist/web/primitives/facet-filter.d.ts +1 -1
  87. package/dist/web/primitives/facet-filter.js +16 -8
  88. package/dist/web/primitives/facet-search-filter.d.ts +2 -1
  89. package/dist/web/primitives/facet-search-filter.js +3 -2
  90. package/dist/web/primitives/facet-trigger-label.d.ts +8 -0
  91. package/dist/web/primitives/facet-trigger-label.js +9 -0
  92. package/dist/web/primitives/file-view-action.js +4 -1
  93. package/dist/web/primitives/layout-elements.js +1 -1
  94. package/dist/web/primitives/metric.js +17 -5
  95. package/dist/web/primitives/page-header.js +3 -2
  96. package/dist/web/primitives/pager.d.ts +3 -2
  97. package/dist/web/primitives/pager.js +16 -20
  98. package/dist/web/primitives/record-breadcrumb.js +1 -1
  99. package/dist/web/primitives/record-steps.js +9 -4
  100. package/dist/web/primitives/record-summary.js +1 -1
  101. package/dist/web/primitives/segmented-select.js +6 -3
  102. package/dist/web/primitives/tabs.js +6 -1
  103. package/dist/web/pwa/pwa-support.js +19 -1
  104. package/dist/web/ui/sidebar.d.ts +2 -1
  105. package/dist/web/ui/sidebar.js +4 -3
  106. package/dist/web/widgets/ai-text-field.js +3 -2
  107. package/dist/web/widgets/dashboard-list-cards.js +6 -14
  108. package/dist/web/widgets/dashboard-list.d.ts +8 -0
  109. package/dist/web/widgets/dashboard-list.js +34 -8
  110. package/dist/web/widgets/drawer-panel-class.d.ts +1 -0
  111. package/dist/web/widgets/drawer-panel-class.js +9 -1
  112. package/dist/web/widgets/drawer.js +2 -2
  113. package/dist/web/widgets/pdf-viewer-toolbar.js +3 -2
  114. package/dist/web/widgets/sheet-parts.js +3 -1
  115. package/dist/web/widgets/stat-box-cell.js +1 -1
  116. package/dist/web/widgets/stat.d.ts +7 -1
  117. package/dist/web/widgets/stat.js +12 -4
  118. package/dist/web/widgets/step-list-row.d.ts +4 -0
  119. package/dist/web/widgets/step-list-row.js +22 -14
  120. package/dist/web/widgets/step-list.d.ts +12 -4
  121. package/dist/web/widgets/step-list.js +38 -20
  122. package/package.json +5 -5
  123. package/src/changes.json +72 -0
  124. package/src/web/styles.css +6 -0
@@ -1,6 +1,7 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { evalFieldCondition } from "@cosmicdrift/kumiko-framework/ui-types";
3
3
  import { resolveActionIcon } from "@cosmicdrift/kumiko-types/action-icon";
4
+ import { entityListDeclaresSearch } from "@cosmicdrift/kumiko-types/screen";
4
5
  import { useCallback, useEffect, useMemo, useState } from "react";
5
6
  import { ListGroupPageBridges } from "../components/list-group-page-bridges.js";
6
7
  import { RenderList } from "../components/render-list.js";
@@ -55,6 +56,15 @@ export function EntityListScreen({ schema, screen, translate, onRowClick, }) {
55
56
  function toolbarDescriptionOf(description, isEmbedded, translate) {
56
57
  return description === undefined || isEmbedded ? undefined : translate(description);
57
58
  }
59
+ // Searchable default: explicit author choice wins, otherwise auto-on when
60
+ // the entity has searchable fields (dead toolbar slot otherwise — the
61
+ // server search index has nothing to filter). Gated on
62
+ // schema.searchAdapterMissing !== true regardless of source (explicit or
63
+ // auto) — a search bar the server can't serve would 422 at request-time;
64
+ // matches the boot-time check in api/server.ts.
65
+ function isEntityListSearchable(schema, screen, entity) {
66
+ return schema.searchAdapterMissing !== true && entityListDeclaresSearch(screen, entity);
67
+ }
58
68
  function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
59
69
  const isEmbeddedScreen = useIsEmbeddedScreen();
60
70
  const featureName = schema.featureName;
@@ -92,9 +102,11 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
92
102
  translate: effectiveTranslate,
93
103
  urlState,
94
104
  });
105
+ const searchable = isEntityListSearchable(schema, screen, entity);
95
106
  const { filterPayload, listPayloadFor, queryPayload, effectiveSort } = useEntityListPayload({
96
107
  screen,
97
108
  entity,
109
+ searchable,
98
110
  urlState,
99
111
  rangeFilters: range.rangeFilters,
100
112
  activeNamedFilter,
@@ -385,15 +397,6 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
385
397
  : onRowClick !== undefined
386
398
  ? (row) => onRowClick(row, screen.entity)
387
399
  : undefined;
388
- // Searchable default: explicit author choice wins, otherwise auto-on when
389
- // the entity has searchable fields (dead toolbar slot otherwise — the
390
- // server search index has nothing to filter). Gated on
391
- // schema.searchAdapterMissing !== true regardless of source (explicit or
392
- // auto) — a search bar the server can't serve would 422 at request-time;
393
- // matches the boot-time check in api/server.ts.
394
- const searchable = schema.searchAdapterMissing !== true &&
395
- (screen.searchable ??
396
- Object.values(entity.fields).some((f) => "searchable" in f && f.searchable === true));
397
400
  // Assemble pager props only for pagination="pages". The server total
398
401
  // arrives async; until it is there RenderList renders the table without a
399
402
  // pager (the pager has its own total>0 guard).
@@ -21,6 +21,7 @@ export type ResolvedFacetSpec = {
21
21
  /** Author handler that serves the options instead of the entity list. */
22
22
  readonly optionsQuery?: string;
23
23
  };
24
+ readonly narrowPlacement?: "behind-filter";
24
25
  /** Reference facets only: set once the bridge resolved it. Makes the facet searchable. */
25
26
  readonly onSearchChange?: (query: string) => void;
26
27
  readonly searching?: boolean;
@@ -22,6 +22,7 @@ function facetBase(spec) {
22
22
  field: spec.field,
23
23
  label: spec.label,
24
24
  options: spec.options,
25
+ ...(spec.narrowPlacement !== undefined && { narrowPlacement: spec.narrowPlacement }),
25
26
  ...(spec.onSearchChange !== undefined && { onSearchChange: spec.onSearchChange }),
26
27
  ...(spec.searching !== undefined && { searching: spec.searching }),
27
28
  };
@@ -37,6 +38,7 @@ export function buildFacetChips(spec, config, translate) {
37
38
  id: extra.id,
38
39
  label: translate(extra.label),
39
40
  values: extra.values,
41
+ ...(extra.separatorAfter === true && { separatorAfter: true }),
40
42
  });
41
43
  return [
42
44
  ...extras.filter((extra) => extra.position !== "end").map(toChip),
@@ -56,7 +58,10 @@ export function buildEntityFilterFacets(specs, configs, translate, counts) {
56
58
  const config = configs?.[spec.field];
57
59
  if (config === false)
58
60
  continue;
59
- const base = facetBase(spec);
61
+ const base = {
62
+ ...facetBase(spec),
63
+ ...(config?.narrowPlacement !== undefined && { narrowPlacement: config.narrowPlacement }),
64
+ };
60
65
  if (config?.display !== "chips") {
61
66
  out.push(base);
62
67
  continue;
@@ -150,12 +155,14 @@ export function resolveProjectionFacetSpecs(facets, translate, featureName) {
150
155
  return facets.flatMap((facet) => {
151
156
  if (facet.type === "dateRange")
152
157
  return [];
158
+ const placement = facet.narrowPlacement !== undefined ? { narrowPlacement: facet.narrowPlacement } : {};
153
159
  if (facet.type === "select") {
154
160
  return [
155
161
  {
156
162
  field: facet.field,
157
163
  type: "select",
158
164
  label: tr(facet.label),
165
+ ...placement,
159
166
  options: facet.options.map((opt) => ({
160
167
  value: opt.value,
161
168
  label: tr(opt.label),
@@ -169,6 +176,7 @@ export function resolveProjectionFacetSpecs(facets, translate, featureName) {
169
176
  field: facet.field,
170
177
  type: "boolean",
171
178
  label: tr(facet.label),
179
+ ...placement,
172
180
  options: [
173
181
  { value: "true", label: tr(facet.trueLabel) },
174
182
  { value: "false", label: tr(facet.falseLabel) },
@@ -182,6 +190,7 @@ export function resolveProjectionFacetSpecs(facets, translate, featureName) {
182
190
  field: facet.field,
183
191
  type: "reference",
184
192
  label: tr(facet.label),
193
+ ...placement,
185
194
  options: [],
186
195
  reference: {
187
196
  refEntity: target.entityName,
@@ -6,7 +6,6 @@ import type { DataTableFacet } from "../primitives.tsx";
6
6
  import type { FacetCountQuery } from "./facet-count-bridge.tsx";
7
7
  export declare const NAMED_FILTER_FACET_FIELD = "__namedFilter";
8
8
  type NamedFilterUrlState = Pick<ListUrlStateApi, "namedFilter" | "setFilter" | "setNamedFilter">;
9
- export declare function isNamedFilterOffered(ref: NamedListFilterRef, userRoles: readonly string[] | undefined): boolean;
10
9
  export declare function namedFilterCountKey(id: string | undefined): string;
11
10
  /** One toggle chip (or one select entry) per named filter the user may open, rendered by the facet row. */
12
11
  export declare function buildNamedFilterFacet(allRefs: readonly NamedListFilterRef[] | undefined, translate: Translate, userRoles: readonly string[] | undefined, options?: NamedFilterFacetOptions, counts?: Readonly<Record<string, number>>): DataTableFacet | undefined;
@@ -1,17 +1,13 @@
1
+ import { isUiAccessGranted } from "@cosmicdrift/kumiko-framework/ui-types";
1
2
  // Not a real field: keeps the named filter out of the `.f.<field>` facet namespace.
2
3
  export const NAMED_FILTER_FACET_FIELD = "__namedFilter";
3
4
  const NAMED_FILTER_ALL_CHIP_ID = "all";
4
- // Unknown roles (undefined) deny a restricted filter, like role-gated screens do.
5
- export function isNamedFilterOffered(ref, userRoles) {
6
- const required = ref.roles;
7
- return required === undefined || (userRoles ?? []).some((role) => required.includes(role));
8
- }
9
5
  // `undefined` is the "all" entry: the list without any named filter.
10
6
  export function namedFilterCountKey(id) {
11
7
  return `${NAMED_FILTER_FACET_FIELD}:${id ?? ""}`;
12
8
  }
13
9
  function offeredRefs(allRefs, userRoles) {
14
- return allRefs?.filter((ref) => isNamedFilterOffered(ref, userRoles)) ?? [];
10
+ return allRefs?.filter((ref) => isUiAccessGranted(ref.access, userRoles)) ?? [];
15
11
  }
16
12
  /** One toggle chip (or one select entry) per named filter the user may open, rendered by the facet row. */
17
13
  export function buildNamedFilterFacet(allRefs, translate, userRoles, options, counts = {}) {
@@ -20,14 +16,16 @@ export function buildNamedFilterFacet(allRefs, translate, userRoles, options, co
20
16
  return undefined;
21
17
  const isSelect = options?.display === "select";
22
18
  const showCounts = options?.showCounts === true;
19
+ const hideEmpty = options?.hideEmpty === true;
23
20
  const countOf = (id) => {
24
- const count = showCounts ? counts[namedFilterCountKey(id)] : undefined;
21
+ const count = showCounts || hideEmpty ? counts[namedFilterCountKey(id)] : undefined;
25
22
  return count === undefined ? {} : { count };
26
23
  };
27
24
  const chips = refs.map((ref) => ({
28
25
  id: ref.id,
29
26
  label: translate(ref.label),
30
27
  values: [ref.id],
28
+ ...(ref.separatorAfter === true && { separatorAfter: true }),
31
29
  ...countOf(ref.id),
32
30
  }));
33
31
  return {
@@ -48,7 +46,9 @@ export function buildNamedFilterFacet(allRefs, translate, userRoles, options, co
48
46
  ]
49
47
  : chips,
50
48
  ...(isSelect && { display: "select" }),
49
+ ...(options?.narrowPlacement !== undefined && { narrowPlacement: options.narrowPlacement }),
51
50
  ...(showCounts && { showCounts: true }),
51
+ ...(hideEmpty && { hideEmpty: true }),
52
52
  };
53
53
  }
54
54
  /** The list payload of one named filter reduced to a count: no sort and no paging, one row, the total. */
@@ -61,7 +61,7 @@ export function namedFilterCountPayload(listPayload) {
61
61
  }
62
62
  /** One count query per offered filter plus one for "all"; each takes the very payload the list would send for that filter. */
63
63
  export function buildNamedFilterCountQueries(allRefs, userRoles, options, listPayloadFor) {
64
- if (options?.showCounts !== true)
64
+ if (options?.showCounts !== true && options?.hideEmpty !== true)
65
65
  return [];
66
66
  const refs = offeredRefs(allRefs, userRoles);
67
67
  if (refs.length === 0)
@@ -105,9 +105,18 @@ export function buildNamedFilterEmpty(allRefs, activeNamedFilter, search, otherN
105
105
  const emptyState = allRefs?.find((ref) => ref.id === activeNamedFilter)?.emptyState;
106
106
  if (emptyState === undefined || otherNarrowing || search.trim() !== "")
107
107
  return undefined;
108
+ const { title, description, paramsQuery } = emptyState;
108
109
  return {
109
- title: translate(emptyState.title),
110
- ...(emptyState.description !== undefined && { description: translate(emptyState.description) }),
110
+ title: translate(title),
111
+ ...(description !== undefined &&
112
+ (paramsQuery === undefined
113
+ ? { description: translate(description) }
114
+ : {
115
+ describedByQuery: {
116
+ query: paramsQuery,
117
+ describe: (params) => translate(description, params),
118
+ },
119
+ })),
111
120
  onReset,
112
121
  };
113
122
  }
@@ -28,7 +28,7 @@ export function readNotice(value) {
28
28
  return undefined;
29
29
  // Typed keys are re-added only when valid, so a malformed tone or text can't ride along in `rest`.
30
30
  // `rest` is only input for the banner actions' show/enabled predicates; it is never rendered.
31
- const { title, text, tone, ...rest } = value;
31
+ const { title, text, narrowTitle, narrowText, tone, ...rest } = value;
32
32
  if (typeof title !== "string" || title === "")
33
33
  return undefined;
34
34
  const parsedTone = readTone(tone);
@@ -36,6 +36,8 @@ export function readNotice(value) {
36
36
  ...rest,
37
37
  title,
38
38
  ...(typeof text === "string" && { text }),
39
+ ...(typeof narrowTitle === "string" && narrowTitle !== "" && { narrowTitle }),
40
+ ...(typeof narrowText === "string" && narrowText !== "" && { narrowText }),
39
41
  ...(parsedTone !== undefined && { tone: parsedTone }),
40
42
  };
41
43
  }
@@ -1,6 +1,7 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Fragment } from "react";
3
3
  import { RenderEditActionButton } from "../components/render-edit-action-button.js";
4
+ import { pluralKey } from "../headless/plural-key.js";
4
5
  import { isRecordProgressArray, readBreadcrumbItems, readNotice, readSteps, readTone, } from "./projection-detail-guidance-data.js";
5
6
  import { uniqueLabelKeys } from "./unique-label-keys.js";
6
7
  const BANNER_VARIANT = {
@@ -102,7 +103,7 @@ function renderBanner(model) {
102
103
  return undefined;
103
104
  const { Banner } = model.primitives;
104
105
  const actions = renderItemActions(model, spec.actions, notice);
105
- return wrapLayout(model.primitives, GUIDANCE_INSET, _jsx(Banner, { variant: BANNER_VARIANT[notice.tone ?? "neutral"], icon: BANNER_ICON[notice.tone ?? "neutral"], title: notice.title, inline: true, ...(actions !== undefined && { actions }), testId: "kumiko-screen-projection-detail-banner", children: notice.text }));
106
+ return wrapLayout(model.primitives, GUIDANCE_INSET, _jsx(Banner, { variant: BANNER_VARIANT[notice.tone ?? "neutral"], icon: BANNER_ICON[notice.tone ?? "neutral"], title: notice.title, ...(notice.narrowTitle !== undefined && { narrowTitle: notice.narrowTitle }), ...(notice.narrowText !== undefined && { narrowText: notice.narrowText }), inline: true, ...(actions !== undefined && { actions }), testId: "kumiko-screen-projection-detail-banner", children: notice.text }));
106
107
  }
107
108
  function renderSteps(model) {
108
109
  const spec = model.screen.steps;
@@ -119,6 +120,7 @@ function renderSteps(model) {
119
120
  return {
120
121
  id: step.id,
121
122
  title: step.title,
123
+ ...(step.narrowTitle !== undefined && { narrowTitle: step.narrowTitle }),
122
124
  ...(step.detail !== undefined && { detail: step.detail }),
123
125
  ...(step.narrowDetail !== undefined && { narrowDetail: step.narrowDetail }),
124
126
  ...(step.tone !== undefined && { tone: step.tone }),
@@ -138,9 +140,7 @@ function renderSteps(model) {
138
140
  if (RecordSteps !== undefined) {
139
141
  return (_jsx(RecordSteps, { title: title, ...(subtitle !== undefined && { subtitle }), emptyLabel: emptyLabel, reasonLabel: t("kumiko.detail.steps.reason"), ...(spec.narrowLimit !== undefined && {
140
142
  narrowLimit: spec.narrowLimit,
141
- moreLabel: (count) => count === 1
142
- ? t("kumiko.detail.steps.more.one")
143
- : t("kumiko.detail.steps.more.other", { count }),
143
+ moreLabel: (count) => t(pluralKey(spec.narrowMoreLabel ?? "kumiko.detail.steps.more", count), { count }),
144
144
  lessLabel: t("kumiko.detail.steps.less"),
145
145
  }), items: items, count: items.length, testId: testId }));
146
146
  }
@@ -171,7 +171,7 @@ function renderProgress(model, stacked) {
171
171
  total: chain.steps.length,
172
172
  }),
173
173
  }),
174
- }, testId: testId, children: [_jsx(StepBar, { steps: chain.steps.map((step) => step.label), currentIndex: currentIndex, doneSteps: chain.steps.map((step) => step.done), narrowLayout: "steps", ...(stacked && {
174
+ }, options: { headerLayout: "inline" }, testId: testId, children: [_jsx(StepBar, { steps: chain.steps.map((step) => step.label), currentIndex: currentIndex, doneSteps: chain.steps.map((step) => step.done), narrowLayout: "steps", ...(stacked && {
175
175
  orientation: "stacked",
176
176
  subtitles: chain.steps.map((step) => step.detail),
177
177
  }), compactLabel: t("kumiko.wizard.step-with-title", {
@@ -184,14 +184,14 @@ function renderProgress(model, stacked) {
184
184
  return cards.length === 0 ? undefined : cards;
185
185
  }
186
186
  // RecordSteps and the summary carry their own px-6; the progress cards and the banner are bare, so they need the same inset to line up with the metric tiles.
187
- const GUIDANCE_INSET = "px-6";
188
- const PROGRESS_INSET = "flex min-w-0 flex-col gap-4 px-6 py-2";
187
+ const GUIDANCE_INSET = "px-6 max-sm:px-4";
188
+ const PROGRESS_INSET = "flex min-w-0 flex-col gap-4 px-6 py-2 max-sm:px-4";
189
189
  /** Summary, banner, progress and steps in reading order; blocks whose record field holds nothing drop out. */
190
190
  export function renderDetailGuidance(model) {
191
191
  const { progress, steps } = model.screen;
192
192
  const beside = progress?.placement === "beside-steps" && steps !== undefined;
193
193
  const progressNode = renderProgress(model, beside);
194
194
  const progressInset = progress?.hideOnNarrow === true ? `${PROGRESS_INSET} max-sm:hidden` : PROGRESS_INSET;
195
- return (_jsxs(_Fragment, { children: [renderSummary(model), renderBanner(model), beside ? (wrapLayout(model.primitives, "grid grid-cols-1 gap-4 lg:grid-cols-12", _jsxs(_Fragment, { children: [wrapLayout(model.primitives, progressNode !== undefined ? "min-w-0 lg:col-span-8" : "min-w-0 lg:col-span-12", renderSteps(model)), progressNode !== undefined &&
196
- wrapLayout(model.primitives, `${progressInset} lg:col-span-4 lg:pl-0`, progressNode)] }))) : (_jsxs(_Fragment, { children: [progressNode !== undefined && wrapLayout(model.primitives, progressInset, progressNode), renderSteps(model)] }))] }));
195
+ return (_jsxs(_Fragment, { children: [renderSummary(model), renderBanner(model), beside ? (wrapLayout(model.primitives, "grid grid-cols-1 items-stretch gap-4 lg:grid-cols-12", _jsxs(_Fragment, { children: [wrapLayout(model.primitives, progressNode !== undefined ? "min-w-0 lg:col-span-8" : "min-w-0 lg:col-span-12", renderSteps(model)), progressNode !== undefined &&
196
+ wrapLayout(model.primitives, `${progressInset} lg:col-span-4 lg:flex lg:flex-col lg:pl-0 lg:[&>*]:flex-1`, progressNode)] }))) : (_jsxs(_Fragment, { children: [progressNode !== undefined && wrapLayout(model.primitives, progressInset, progressNode), renderSteps(model)] }))] }));
197
197
  }
@@ -29,11 +29,11 @@ export function renderHeaderTitleSlot(model) {
29
29
  export function renderRecordTitleBlock(model, titleText, statusBadge, subtitle, chipInBar) {
30
30
  const { Grid, Heading, FillContainer } = model.primitives;
31
31
  const block = (_jsxs(_Fragment, { children: [_jsxs(Grid, { columns: "auto", testId: "kumiko-screen-projection-detail-title-block", children: [_jsx(Heading, { variant: "page", testId: "kumiko-screen-projection-detail-title", children: titleText }), !chipInBar && statusBadge] }), subtitle] }));
32
- return FillContainer !== undefined ? (_jsx(FillContainer, { className: "flex flex-col gap-1 px-6 pt-2", children: block })) : (block);
32
+ return FillContainer !== undefined ? (_jsx(FillContainer, { className: "flex flex-col gap-1 px-6 pt-2 max-sm:px-4", children: block })) : (block);
33
33
  }
34
34
  function renderSubtitleParts(model, subtitleParts) {
35
35
  const { Text, Link } = model.primitives;
36
- return (_jsx(Text, { variant: "muted", testId: "kumiko-screen-projection-detail-subtitle", children: subtitleParts.map((part, index) => (_jsxs(Fragment, { children: [index > 0 && (_jsx(Text, { variant: "muted", decorative: true, children: " · " })), part.href !== undefined ? (_jsx(Link, { href: part.href, ...(part.onPress !== undefined && { onPress: part.onPress }), className: "underline", testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text })) : (_jsx(Text, { testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text }))] }, part.field))) }));
36
+ return (_jsx(Text, { variant: "muted", testId: "kumiko-screen-projection-detail-subtitle", children: subtitleParts.map((part, index) => (_jsxs(Fragment, { children: [index > 0 && (_jsx(Text, { variant: "muted", decorative: true, children: " · " })), part.prefix !== undefined && (_jsx(Text, { testId: `kumiko-screen-projection-detail-subtitle-${part.field}-prefix`, children: `${part.prefix} ` })), part.href !== undefined ? (_jsx(Link, { href: part.href, ...(part.onPress !== undefined && { onPress: part.onPress }), className: "underline", testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text })) : (_jsx(Text, { testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text }))] }, part.field))) }));
37
37
  }
38
38
  function renderSubtitleField(model, subtitleField, testId = "kumiko-screen-projection-detail-subtitle") {
39
39
  const { screen, record, primitives } = model;
@@ -119,9 +119,10 @@ export function buildMetricItems(model) {
119
119
  const tiles = screen.metricsStyle === "tiles";
120
120
  const tone = metricTone(metric, record, rawValue);
121
121
  const sub = metricSubline(metric.subField, record);
122
+ const narrowSub = metricSubline(metric.subFieldNarrow, record);
122
123
  const testId = `kumiko-screen-projection-detail-metric-${field}`;
123
124
  const onPress = metricPressHandler(model, metric);
124
- const item = Metric !== undefined ? (_jsx(Metric, { label: label, value: value, testId: testId, ...(onPress !== undefined && { onPress }), ...(tiles && { tile: true }), ...(tone !== undefined && { tone }), ...(metric.icon !== undefined && { icon: metric.icon }), ...(sub !== undefined && { sub }) }, field)) : (_jsxs(GridCell, { children: [_jsx(Text, { variant: "small", testId: `${testId}-label`, children: label }), _jsx(Text, { testId: `${testId}-value`, children: value })] }, field));
125
+ const item = Metric !== undefined ? (_jsx(Metric, { label: label, value: value, testId: testId, ...(onPress !== undefined && { onPress }), ...(tiles && { tile: true }), ...(tone !== undefined && { tone }), ...(metric.icon !== undefined && { icon: metric.icon }), ...(sub !== undefined && { sub }), ...(narrowSub !== undefined && { narrowSub }) }, field)) : (_jsxs(GridCell, { children: [_jsx(Text, { variant: "small", testId: `${testId}-label`, children: label }), _jsx(Text, { testId: `${testId}-value`, children: value })] }, field));
125
126
  const { FillContainer } = primitives;
126
127
  return metric.hideOnNarrow === true && FillContainer !== undefined ? (_jsx(FillContainer, { className: "max-sm:hidden", children: item }, field)) : (item);
127
128
  });
@@ -10,6 +10,8 @@ export type SubtitlePartView = {
10
10
  readonly text: string;
11
11
  readonly href?: string;
12
12
  readonly onPress?: () => void;
13
+ /** Translated text before the value; outside the link. */
14
+ readonly prefix?: string;
13
15
  };
14
16
  export declare function metricNavigateResolves(navigate: MetricNavigate, record: Readonly<Record<string, unknown>>): boolean;
15
17
  export declare function buildSubtitleParts(parts: readonly RecordHeaderSubtitlePart[], record: Readonly<Record<string, unknown>>, nav: NavApi, appFeatures: readonly FeatureSchema[], userRoles: readonly string[] | undefined, host: ReturnHost | undefined, translate: Translate, locale: string): SubtitlePartView[];
@@ -89,14 +89,24 @@ export function buildSubtitleParts(parts, record, nav, appFeatures, userRoles, h
89
89
  // skip: empty subtitle parts render nothing
90
90
  if (text === "")
91
91
  return [];
92
+ const prefixKey = typeof part === "string" ? undefined : part.prefix;
93
+ const prefix = prefixKey === undefined ? {} : { prefix: translate(prefixKey) };
92
94
  const navigate = typeof part === "string" ? undefined : part.navigate;
93
95
  if (navigate === undefined || !navigateTargetAllows(navigate, appFeatures, userRoles)) {
94
- return [{ field, text }];
96
+ return [{ field, text, ...prefix }];
95
97
  }
96
98
  const href = hrefForNavigate(nav, navigate, record);
97
99
  // skip: unresolvable targets fall back to plain text
98
100
  if (href === undefined)
99
- return [{ field, text }];
100
- return [{ field, text, href, onPress: () => runMetricNavigate(nav, navigate, record, host) }];
101
+ return [{ field, text, ...prefix }];
102
+ return [
103
+ {
104
+ field,
105
+ text,
106
+ ...prefix,
107
+ href,
108
+ onPress: () => runMetricNavigate(nav, navigate, record, host),
109
+ },
110
+ ];
101
111
  });
102
112
  }
@@ -1,5 +1,4 @@
1
1
  import { isUiAccessGranted } from "@cosmicdrift/kumiko-framework/ui-types";
2
- import { isNamedFilterOffered } from "./named-filter-facet.js";
3
2
  import { findDetailForScreen } from "./nav.js";
4
3
  import { lastSegment } from "./qn.js";
5
4
  // Shared UI-visibility predicate for the screen-render path — nav
@@ -57,7 +56,7 @@ export function namedFilterNavigateAllows(navigate, appFeatures, userRoles) {
57
56
  if (target.type !== "entityList" && target.type !== "projectionList")
58
57
  return true;
59
58
  const ref = target.namedFilters?.find((candidate) => candidate.id === namedFilter);
60
- return ref === undefined || isNamedFilterOffered(ref, userRoles);
59
+ return ref === undefined || isUiAccessGranted(ref.access, userRoles);
61
60
  }
62
61
  return true;
63
62
  }
@@ -5,6 +5,7 @@ type EntityListPayloadInput = {
5
5
  readonly screen: EntityListScreenDefinition;
6
6
  readonly entity: EntityDefinition;
7
7
  readonly urlState: ListUrlStateApi;
8
+ readonly searchable: boolean;
8
9
  readonly rangeFilters: readonly RangeFilter[];
9
10
  readonly activeNamedFilter: string | undefined;
10
11
  readonly limit: number;
@@ -12,7 +13,7 @@ type EntityListPayloadInput = {
12
13
  readonly useInfinite: boolean;
13
14
  };
14
15
  /** The list payload as a function of the named filter, so the list and every filter count share one path. */
15
- export declare function useEntityListPayload({ screen, entity, urlState, rangeFilters, activeNamedFilter, limit, usePager, useInfinite, }: EntityListPayloadInput): {
16
+ export declare function useEntityListPayload({ screen, entity, urlState, searchable, rangeFilters, activeNamedFilter, limit, usePager, useInfinite, }: EntityListPayloadInput): {
16
17
  filterPayload: {
17
18
  field: string;
18
19
  op: "in";
@@ -4,7 +4,7 @@ import { buildFilterPayload } from "./list-facets.js";
4
4
  import { resolveListSort } from "./named-filter-facet.js";
5
5
  import { buildListQueryPayload } from "./screen-shared.js";
6
6
  /** The list payload as a function of the named filter, so the list and every filter count share one path. */
7
- export function useEntityListPayload({ screen, entity, urlState, rangeFilters, activeNamedFilter, limit, usePager, useInfinite, }) {
7
+ export function useEntityListPayload({ screen, entity, urlState, searchable, rangeFilters, activeNamedFilter, limit, usePager, useInfinite, }) {
8
8
  // typeOf reads the field type straight from entity.fields (not gated on
9
9
  // filterable, deliberately permissive; see the buildFilterPayload doc).
10
10
  const filterPayloadFor = useCallback((filters) => buildFilterPayload(filters, (field) => {
@@ -14,7 +14,9 @@ export function useEntityListPayload({ screen, entity, urlState, rangeFilters, a
14
14
  return typeof type === "string" ? type : undefined;
15
15
  }), [entity.fields]);
16
16
  const filterPayload = useMemo(() => filterPayloadFor(urlState.filters), [filterPayloadFor, urlState.filters]);
17
- const { filtersFor, sort: urlSort, q, page } = urlState;
17
+ const { filtersFor, sort: urlSort, page } = urlState;
18
+ // A stale or hand-crafted ?q= on a non-searchable list must not reach the query.
19
+ const q = searchable ? urlState.q : "";
18
20
  const listPayloadFor = useCallback((namedFilter) => {
19
21
  const payload = buildListQueryPayload({
20
22
  limit,
@@ -33,4 +33,5 @@ export declare function useProjectionDetailActions(input: DetailActionsInput): {
33
33
  buildItemActions: (actions: readonly RowAction[], item: Readonly<Record<string, unknown>>) => readonly RenderEditAction[] | undefined;
34
34
  headerActions: readonly RenderEditAction[] | undefined;
35
35
  };
36
+ export declare function omitActionsDefaultingToShownRecordId(actions: readonly RowAction[], shownRecordId: string | undefined): readonly RowAction[];
36
37
  export {};
@@ -123,20 +123,23 @@ export function useProjectionDetailActions(input) {
123
123
  handleRecordLeft,
124
124
  sameEntityScreenId,
125
125
  ]);
126
- const buildItemActions = useCallback((actions, item) => buildRecordActions({
127
- actions,
128
- record: item,
129
- translate: effectiveTranslate,
130
- nav,
131
- host,
132
- dispatcher,
133
- openDrawer,
134
- onWriteSuccess: reloadDetail,
135
- onRecordLeft: handleRecordLeft,
136
- sameEntityScreenId,
137
- clientActions,
138
- defaultWritePayloadId: effectiveEntityId ?? stringId(detailQuery.data?.["id"]),
139
- }), [
126
+ const buildItemActions = useCallback((actions, item) => {
127
+ const shownRecordId = effectiveEntityId ?? stringId(detailQuery.data?.["id"]);
128
+ return buildRecordActions({
129
+ actions: omitActionsDefaultingToShownRecordId(actions, shownRecordId),
130
+ record: item,
131
+ translate: effectiveTranslate,
132
+ nav,
133
+ host,
134
+ dispatcher,
135
+ openDrawer,
136
+ onWriteSuccess: reloadDetail,
137
+ onRecordLeft: handleRecordLeft,
138
+ sameEntityScreenId,
139
+ clientActions,
140
+ defaultWritePayloadId: shownRecordId,
141
+ });
142
+ }, [
140
143
  detailQuery.data,
141
144
  effectiveEntityId,
142
145
  reloadDetail,
@@ -185,6 +188,15 @@ export function useProjectionDetailActions(input) {
185
188
  ]);
186
189
  return { buildSectionActions, buildItemActions, headerActions };
187
190
  }
191
+ // Without a shown record id, a payload-less write or client action would fall back to the guidance item's own id (a step key, not a record id).
192
+ export function omitActionsDefaultingToShownRecordId(actions, shownRecordId) {
193
+ if (shownRecordId !== undefined)
194
+ return actions;
195
+ return actions.filter((action) => !((action.kind === undefined ||
196
+ action.kind === "writeHandler" ||
197
+ action.kind === "clientAction") &&
198
+ action.payload === undefined));
199
+ }
188
200
  function stringId(value) {
189
201
  return typeof value === "string" && value !== "" ? value : undefined;
190
202
  }
@@ -3,9 +3,11 @@ type Row = Readonly<Record<string, unknown>>;
3
3
  /** Decoration fields win over same-named row fields; the row id is kept. Entries for ids not in `rows` and malformed entries are ignored. */
4
4
  export declare function mergeRowDecoration(rows: readonly Row[], answer: unknown): readonly Row[];
5
5
  /**
6
- * One decoration call per list answer. `answerToken` changes with every new list answer;
7
- * the decoration query is not live itself. A changed id set refetches through the payload,
8
- * so only a new answer with the same ids calls `refetch`. Loading and error show the plain rows.
6
+ * Sends only ids that have no answer yet, so an infinite list asks once per new page and the
7
+ * answers are kept across calls. `resetKey` drops them (filter or sort changed); a new list
8
+ * answer that is not an append (reload after a write) asks for every id again, in batches of
9
+ * the first send's size.
10
+ * Loading and error show the plain rows.
9
11
  */
10
- export declare function useRowDecoration(decoration: ListRowDecoration | undefined, rows: readonly Row[], answerToken: unknown): readonly Row[];
12
+ export declare function useRowDecoration(decoration: ListRowDecoration | undefined, rows: readonly Row[], answerToken: unknown, resetKey: string): readonly Row[];
11
13
  export {};
@@ -1,5 +1,5 @@
1
1
  import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
2
- import { useEffect, useMemo, useRef } from "react";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { useQuery } from "../hooks/use-query.js";
4
4
  function rowId(row) {
5
5
  const id = row["id"];
@@ -19,9 +19,7 @@ function decorationFieldsById(answer) {
19
19
  }
20
20
  return byId;
21
21
  }
22
- /** Decoration fields win over same-named row fields; the row id is kept. Entries for ids not in `rows` and malformed entries are ignored. */
23
- export function mergeRowDecoration(rows, answer) {
24
- const byId = decorationFieldsById(answer);
22
+ function applyDecorationFields(rows, byId) {
25
23
  if (byId.size === 0)
26
24
  return rows;
27
25
  return rows.map((row) => {
@@ -30,26 +28,76 @@ export function mergeRowDecoration(rows, answer) {
30
28
  return fields === undefined ? row : { ...row, ...fields, id: row["id"] };
31
29
  });
32
30
  }
31
+ /** Decoration fields win over same-named row fields; the row id is kept. Entries for ids not in `rows` and malformed entries are ignored. */
32
+ export function mergeRowDecoration(rows, answer) {
33
+ return applyDecorationFields(rows, decorationFieldsById(answer));
34
+ }
35
+ function emptyAccumulated(resetKey) {
36
+ return { resetKey, answeredIds: new Set(), fieldsById: new Map(), batchSize: undefined };
37
+ }
38
+ function absorbAnswer(previous, answer, sentIds) {
39
+ // A sent id the answer no longer contains loses its decoration; ids not asked for keep theirs,
40
+ // so rows do not flicker while a refresh runs batch by batch.
41
+ const fieldsById = new Map(previous.fieldsById);
42
+ for (const id of sentIds)
43
+ fieldsById.delete(id);
44
+ for (const [id, fields] of decorationFieldsById(answer))
45
+ fieldsById.set(id, fields);
46
+ return {
47
+ resetKey: previous.resetKey,
48
+ answeredIds: new Set([...previous.answeredIds, ...sentIds]),
49
+ fieldsById,
50
+ batchSize: previous.batchSize ?? sentIds.length,
51
+ };
52
+ }
53
+ function isAppendOf(previousIds, ids) {
54
+ return ids.length > previousIds.length && previousIds.every((id, index) => ids[index] === id);
55
+ }
33
56
  /**
34
- * One decoration call per list answer. `answerToken` changes with every new list answer;
35
- * the decoration query is not live itself. A changed id set refetches through the payload,
36
- * so only a new answer with the same ids calls `refetch`. Loading and error show the plain rows.
57
+ * Sends only ids that have no answer yet, so an infinite list asks once per new page and the
58
+ * answers are kept across calls. `resetKey` drops them (filter or sort changed); a new list
59
+ * answer that is not an append (reload after a write) asks for every id again, in batches of
60
+ * the first send's size.
61
+ * Loading and error show the plain rows.
37
62
  */
38
- export function useRowDecoration(decoration, rows, answerToken) {
63
+ export function useRowDecoration(decoration, rows, answerToken, resetKey) {
39
64
  const ids = rows.flatMap((row) => {
40
65
  const id = rowId(row);
41
66
  return id === undefined ? [] : [id];
42
67
  });
43
- const idsKey = ids.join("\n");
44
- const enabled = decoration !== undefined && ids.length > 0;
45
- const { data, error, refetch } = useQuery(decoration?.query ?? "", { ...decoration?.params, ids }, { enabled });
46
- const lastAnswerRef = useRef(null);
68
+ const [stored, setStored] = useState(() => emptyAccumulated(resetKey));
69
+ const accumulated = stored.resetKey === resetKey ? stored : emptyAccumulated(resetKey);
70
+ const idsToSend = ids
71
+ .filter((id) => !accumulated.answeredIds.has(id))
72
+ .slice(0, accumulated.batchSize);
73
+ const enabled = decoration !== undefined && idsToSend.length > 0;
74
+ const { data, error } = useQuery(decoration?.query ?? "", { ...decoration?.params, ids: idsToSend }, { enabled });
75
+ const sentIdsRef = useRef(idsToSend);
76
+ useEffect(() => {
77
+ sentIdsRef.current = idsToSend;
78
+ });
79
+ const absorbedAnswerRef = useRef(null);
80
+ useEffect(() => {
81
+ if (data === null || data === absorbedAnswerRef.current)
82
+ return;
83
+ absorbedAnswerRef.current = data;
84
+ const sentIds = sentIdsRef.current;
85
+ setStored((current) => absorbAnswer(current.resetKey === resetKey ? current : emptyAccumulated(resetKey), data, sentIds));
86
+ }, [data, resetKey]);
87
+ const previousListRef = useRef(null);
47
88
  useEffect(() => {
48
- const last = lastAnswerRef.current;
49
- lastAnswerRef.current = enabled ? { token: answerToken, idsKey } : null;
50
- if (enabled && last !== null && last.token !== answerToken && last.idsKey === idsKey) {
51
- void refetch();
52
- }
53
- }, [enabled, answerToken, idsKey, refetch]);
54
- return useMemo(() => (!enabled || error !== null || data === null ? rows : mergeRowDecoration(rows, data)), [enabled, error, data, rows]);
89
+ const previous = previousListRef.current;
90
+ previousListRef.current = { token: answerToken, ids };
91
+ if (previous === null || previous.token === answerToken)
92
+ return;
93
+ if (isAppendOf(previous.ids, ids))
94
+ return;
95
+ setStored((current) => ({
96
+ ...(current.resetKey === resetKey ? current : emptyAccumulated(resetKey)),
97
+ answeredIds: new Set(),
98
+ }));
99
+ }, [answerToken, ids, resetKey]);
100
+ const fieldsById = accumulated.fieldsById;
101
+ const decorated = decoration !== undefined;
102
+ return useMemo(() => (!decorated || error !== null ? rows : applyDecorationFields(rows, fieldsById)), [decorated, error, rows, fieldsById]);
55
103
  }
@@ -73,7 +73,7 @@ export function useScreenListRows({ queryType, payload, infinite, aggregates, ro
73
73
  const loadedRows = grouped ? aggregates.rows : infinite ? state.rows : (data?.rows ?? NO_ROWS);
74
74
  // Grouped rows are rebuilt on every render, so only a group refresh counts as a new answer.
75
75
  const answerToken = grouped ? aggregates.groupPages.refreshNonce : loadedRows;
76
- const rows = useRowDecoration(rowDecoration, loadedRows, answerToken);
76
+ const rows = useRowDecoration(rowDecoration, loadedRows, answerToken, resetKey);
77
77
  if (grouped) {
78
78
  return {
79
79
  rows,