@cratis/components 4.29.1 → 4.31.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 (58) hide show
  1. package/compat-manifest.json +11 -11
  2. package/dist/esm/CommandForm/AutoCommandForm.d.ts +2 -1
  3. package/dist/esm/CommandForm/AutoCommandForm.d.ts.map +1 -1
  4. package/dist/esm/CommandForm/AutoCommandForm.js +9 -1
  5. package/dist/esm/CommandForm/AutoCommandForm.js.map +1 -1
  6. package/dist/esm/CommandForm/fields/GuidField.d.ts +49 -0
  7. package/dist/esm/CommandForm/fields/GuidField.d.ts.map +1 -0
  8. package/dist/esm/CommandForm/fields/GuidField.js +85 -0
  9. package/dist/esm/CommandForm/fields/GuidField.js.map +1 -0
  10. package/dist/esm/CommandForm/fields/index.d.ts +1 -0
  11. package/dist/esm/CommandForm/fields/index.d.ts.map +1 -1
  12. package/dist/esm/CommandForm/fields/index.js +1 -0
  13. package/dist/esm/CommandForm/fields/index.js.map +1 -1
  14. package/dist/esm/CommandForm/index.js +1 -0
  15. package/dist/esm/CommandForm/index.js.map +1 -1
  16. package/dist/esm/DataPage/DataPage.d.ts +7 -0
  17. package/dist/esm/DataPage/DataPage.d.ts.map +1 -1
  18. package/dist/esm/DataPage/DataPage.js.map +1 -1
  19. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts +7 -0
  20. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts.map +1 -1
  21. package/dist/esm/DataTables/DataTableForObservableQuery.js +4 -2
  22. package/dist/esm/DataTables/DataTableForObservableQuery.js.map +1 -1
  23. package/dist/esm/DataTables/DataTableForQuery.d.ts +8 -1
  24. package/dist/esm/DataTables/DataTableForQuery.d.ts.map +1 -1
  25. package/dist/esm/DataTables/DataTableForQuery.js +9 -3
  26. package/dist/esm/DataTables/DataTableForQuery.js.map +1 -1
  27. package/dist/esm/DataTables/DataTableServerQuery.d.ts +38 -0
  28. package/dist/esm/DataTables/DataTableServerQuery.d.ts.map +1 -0
  29. package/dist/esm/DataTables/DataTableServerQuery.js +4 -0
  30. package/dist/esm/DataTables/DataTableServerQuery.js.map +1 -0
  31. package/dist/esm/DataTables/DataTableServerQueryState.d.ts +9 -0
  32. package/dist/esm/DataTables/DataTableServerQueryState.d.ts.map +1 -0
  33. package/dist/esm/DataTables/DataTableServerQueryState.js +4 -0
  34. package/dist/esm/DataTables/DataTableServerQueryState.js.map +1 -0
  35. package/dist/esm/DataTables/hasRequiredArguments.d.ts +9 -0
  36. package/dist/esm/DataTables/hasRequiredArguments.d.ts.map +1 -0
  37. package/dist/esm/DataTables/hasRequiredArguments.js +7 -0
  38. package/dist/esm/DataTables/hasRequiredArguments.js.map +1 -0
  39. package/dist/esm/DataTables/index.d.ts +2 -0
  40. package/dist/esm/DataTables/index.d.ts.map +1 -1
  41. package/dist/esm/DataTables/index.js +1 -0
  42. package/dist/esm/DataTables/index.js.map +1 -1
  43. package/dist/esm/DataTables/resolveDataTableStatus.d.ts +2 -7
  44. package/dist/esm/DataTables/resolveDataTableStatus.d.ts.map +1 -1
  45. package/dist/esm/DataTables/resolveDataTableStatus.js.map +1 -1
  46. package/dist/esm/DataTables/useServerQuery.d.ts +32 -0
  47. package/dist/esm/DataTables/useServerQuery.d.ts.map +1 -0
  48. package/dist/esm/DataTables/useServerQuery.js +67 -0
  49. package/dist/esm/DataTables/useServerQuery.js.map +1 -0
  50. package/dist/esm/QueryStatus/resolveQueryStatus.d.ts +10 -3
  51. package/dist/esm/QueryStatus/resolveQueryStatus.d.ts.map +1 -1
  52. package/dist/esm/QueryStatus/resolveQueryStatus.js +2 -0
  53. package/dist/esm/QueryStatus/resolveQueryStatus.js.map +1 -1
  54. package/dist/esm/types/parts.d.ts +4 -0
  55. package/dist/esm/types/parts.d.ts.map +1 -1
  56. package/dist/esm/types/parts.js +4 -0
  57. package/dist/esm/types/parts.js.map +1 -1
  58. package/package.json +1 -1
@@ -68,7 +68,7 @@
68
68
  {
69
69
  "name": "@cratis/components",
70
70
  "role": "core",
71
- "version": "4.29.1",
71
+ "version": "4.31.0",
72
72
  "releaseMajorRange": ">=4 <5",
73
73
  "independentRelease": false,
74
74
  "private": false,
@@ -92,7 +92,7 @@
92
92
  {
93
93
  "name": "@cratis/eslint-plugin-components",
94
94
  "role": "eslint",
95
- "version": "4.29.1",
95
+ "version": "4.31.0",
96
96
  "releaseMajorRange": ">=4 <5",
97
97
  "independentRelease": false,
98
98
  "private": false,
@@ -105,7 +105,7 @@
105
105
  {
106
106
  "name": "@cratis/components.migrator",
107
107
  "role": "migrator",
108
- "version": "4.29.1",
108
+ "version": "4.31.0",
109
109
  "releaseMajorRange": ">=4 <5",
110
110
  "independentRelease": false,
111
111
  "private": false,
@@ -116,13 +116,13 @@
116
116
  {
117
117
  "name": "@cratis/components.conformance",
118
118
  "role": "conformance",
119
- "version": "4.29.1",
119
+ "version": "4.31.0",
120
120
  "releaseMajorRange": ">=4 <5",
121
121
  "independentRelease": false,
122
122
  "private": false,
123
123
  "packageAccess": "public",
124
124
  "peerDependencies": {
125
- "@cratis/components": "4.29.1",
125
+ "@cratis/components": "4.31.0",
126
126
  "react": "^19.0.0",
127
127
  "react-dom": "^19.0.0"
128
128
  },
@@ -132,13 +132,13 @@
132
132
  {
133
133
  "name": "@cratis/components.mui",
134
134
  "role": "renderer-adapter",
135
- "version": "4.29.1",
135
+ "version": "4.31.0",
136
136
  "releaseMajorRange": ">=4 <5",
137
137
  "independentRelease": false,
138
138
  "private": false,
139
139
  "packageAccess": "public",
140
140
  "peerDependencies": {
141
- "@cratis/components": "4.29.1",
141
+ "@cratis/components": "4.31.0",
142
142
  "@emotion/react": ">=11.5 <12",
143
143
  "@emotion/styled": ">=11.11 <12",
144
144
  "@mui/material": ">=9 <10",
@@ -188,13 +188,13 @@
188
188
  {
189
189
  "name": "@cratis/components.primereact",
190
190
  "role": "renderer-adapter",
191
- "version": "4.29.1",
191
+ "version": "4.31.0",
192
192
  "releaseMajorRange": ">=4 <5",
193
193
  "independentRelease": false,
194
194
  "private": false,
195
195
  "packageAccess": "public",
196
196
  "peerDependencies": {
197
- "@cratis/components": "4.29.1",
197
+ "@cratis/components": "4.31.0",
198
198
  "@primereact/core": ">=11 <12",
199
199
  "@primereact/ui": ">=11 <12",
200
200
  "@primeuix/themes": ">=3 <4",
@@ -256,13 +256,13 @@
256
256
  {
257
257
  "name": "@cratis/components.primereact10",
258
258
  "role": "renderer-adapter",
259
- "version": "4.29.1",
259
+ "version": "4.31.0",
260
260
  "releaseMajorRange": ">=4 <5",
261
261
  "independentRelease": false,
262
262
  "private": false,
263
263
  "packageAccess": "public",
264
264
  "peerDependencies": {
265
- "@cratis/components": "4.29.1",
265
+ "@cratis/components": "4.31.0",
266
266
  "primereact": ">=10.9.9 <11",
267
267
  "react": "^19.0.0",
268
268
  "react-dom": "^19.0.0"
@@ -20,7 +20,8 @@ export interface AutoCommandFormProps<TCommand extends object, TResponse = objec
20
20
  * A `CommandForm` that generates its field list from the command's own properties, choosing each
21
21
  * field's component by the property's type through the {@link FieldTypeProvider} registry -
22
22
  * `registerFieldTypeProvider` for a type the built-in defaults (`string`, `number`, `boolean`,
23
- * `Date`) don't cover, or to override one of them.
23
+ * `Date`) don't cover, or to override one of them. `GuidField` is not a default; register it for
24
+ * Fundamentals `Guid` properties to edit them.
24
25
  *
25
26
  * A property whose type no registered provider handles is left out of the generated list -
26
27
  * `exclude` it explicitly for clarity, or add a `CommandForm` child by hand alongside this
@@ -1 +1 @@
1
- {"version":3,"file":"AutoCommandForm.d.ts","sourceRoot":"","sources":["../../../CommandForm/AutoCommandForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAMhF;;;GAGG;AACH,MAAM,WAAW,oBAAoB,CACjC,QAAQ,SAAS,MAAM,EACvB,SAAS,GAAG,MAAM,CACpB,SAAQ,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,UAAU,CAAC;IAC7D;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,QAAQ,CAAC,EAAE,CAAC;IAE7B;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AASD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,GAAG,MAAM,EAChF,KAAK,EAAE,oBAAoB,CAAC,QAAQ,EAAE,SAAS,CAAC,GACjD,KAAK,CAAC,YAAY,CA6CpB"}
1
+ {"version":3,"file":"AutoCommandForm.d.ts","sourceRoot":"","sources":["../../../CommandForm/AutoCommandForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAQhF;;;GAGG;AACH,MAAM,WAAW,oBAAoB,CACjC,QAAQ,SAAS,MAAM,EACvB,SAAS,GAAG,MAAM,CACpB,SAAQ,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,UAAU,CAAC;IAC7D;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,QAAQ,CAAC,EAAE,CAAC;IAE7B;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAmBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,GAAG,MAAM,EAChF,KAAK,EAAE,oBAAoB,CAAC,QAAQ,EAAE,SAAS,CAAC,GACjD,KAAK,CAAC,YAAY,CA8CpB"}
@@ -1,6 +1,8 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useMemo } from 'react';
3
3
  import { CommandForm } from '@cratis/arc.react/commands';
4
+ import { Guid } from '@cratis/fundamentals';
5
+ import { GuidField } from './fields/GuidField.js';
4
6
  import { registerDefaultFieldTypeProviders } from './defaultFieldTypeProviders.js';
5
7
  import { resolveFieldTypeProvider } from './fieldTypeProviderRegistry.js';
6
8
 
@@ -11,6 +13,12 @@ function formatTitle(propertyName) {
11
13
  .replace(/^./, (character) => character.toUpperCase())
12
14
  .trim();
13
15
  }
16
+ function guidFieldResetProps(field, overlayValue) {
17
+ if (field !== GuidField) {
18
+ return {};
19
+ }
20
+ return { resetKey: overlayValue instanceof Guid ? overlayValue.toString() : overlayValue };
21
+ }
14
22
  function AutoCommandForm(props) {
15
23
  const { exclude, footer, ...commandFormProps } = props;
16
24
  const propertyDescriptors = useMemo(() => new props.command().propertyDescriptors, [props.command]);
@@ -23,7 +31,7 @@ function AutoCommandForm(props) {
23
31
  return null;
24
32
  }
25
33
  const Field = provider.component;
26
- return (jsx(Field, { fieldName: descriptor.name, value: (instance) => {
34
+ return (jsx(Field, { ...guidFieldResetProps(Field, props.currentValues?.[descriptor.name]), fieldName: descriptor.name, value: (instance) => {
27
35
  return instance[descriptor.name];
28
36
  }, title: formatTitle(descriptor.name) }, descriptor.name));
29
37
  })
@@ -1 +1 @@
1
- {"version":3,"file":"AutoCommandForm.js","sources":["../../../CommandForm/AutoCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type React from 'react';\nimport { useMemo } from 'react';\nimport type { Command } from '@cratis/arc/commands';\nimport { CommandForm, type CommandFormProps } from '@cratis/arc.react/commands';\nimport { registerDefaultFieldTypeProviders } from './defaultFieldTypeProviders';\nimport { resolveFieldTypeProvider } from './fieldTypeProviderRegistry';\n\nregisterDefaultFieldTypeProviders();\n\n/**\n * Props for {@link AutoCommandForm} - every {@link CommandFormProps} except `children`, which is\n * generated from the command's own properties instead of being written out by hand.\n */\nexport interface AutoCommandFormProps<\n TCommand extends object,\n TResponse = object,\n> extends Omit<CommandFormProps<TCommand, TResponse>, 'children'> {\n /**\n * Property names to leave out of the generated field list - for a property that should not\n * be user-editable, or one a custom field placed elsewhere on the page already covers.\n */\n exclude?: (keyof TCommand)[];\n\n /**\n * Optional content rendered after the generated fields, inside the native Arc form and\n * command context. Supply a submit control here when needed; no action is added by default.\n */\n footer?: React.ReactNode;\n}\n\nfunction formatTitle(propertyName: string): string {\n return propertyName\n .replace(/([A-Z])/g, ' $1')\n .replace(/^./, (character) => character.toUpperCase())\n .trim();\n}\n\n/**\n * A `CommandForm` that generates its field list from the command's own properties, choosing each\n * field's component by the property's type through the {@link FieldTypeProvider} registry -\n * `registerFieldTypeProvider` for a type the built-in defaults (`string`, `number`, `boolean`,\n * `Date`) don't cover, or to override one of them.\n *\n * A property whose type no registered provider handles is left out of the generated list -\n * `exclude` it explicitly for clarity, or add a `CommandForm` child by hand alongside this\n * component for that one property.\n *\n * @example\n * ```tsx\n * <AutoCommandForm command={RegisterInvoice} exclude={['invoiceId']} />\n * ```\n */\nexport function AutoCommandForm<TCommand extends object = object, TResponse = object>(\n props: AutoCommandFormProps<TCommand, TResponse>,\n): React.ReactElement {\n const { exclude, footer, ...commandFormProps } = props;\n // SAFETY: Arc command constructors expose the Command property-descriptor contract at runtime.\n const propertyDescriptors = useMemo(\n () => (new props.command() as unknown as Command).propertyDescriptors,\n [props.command],\n );\n const excluded = useMemo(\n () => new Set<string>((exclude ?? []) as string[]),\n [exclude],\n );\n\n const fields = propertyDescriptors\n .filter((descriptor) => !excluded.has(descriptor.name))\n .map((descriptor) => {\n const provider = resolveFieldTypeProvider(descriptor);\n if (!provider) {\n return null;\n }\n\n const Field = provider.component;\n return (\n <Field\n key={descriptor.name}\n // The accessor reads the property dynamically, so CommandForm cannot infer the\n // property name from its source text; fieldName states it explicitly.\n fieldName={descriptor.name}\n value={(instance: TCommand) => {\n // SAFETY: Arc descriptors name runtime properties on the same command instance.\n return (instance as unknown as Record<string, unknown>)[\n descriptor.name\n ];\n }}\n title={formatTitle(descriptor.name)}\n />\n );\n })\n .filter((field): field is React.ReactElement => field !== null);\n\n return (\n <CommandForm {...commandFormProps}>\n {fields}\n {footer}\n </CommandForm>\n );\n}\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AAUA,iCAAiC,EAAE;AAuBnC,SAAS,WAAW,CAAC,YAAoB,EAAA;AACrC,IAAA,OAAO;AACF,SAAA,OAAO,CAAC,UAAU,EAAE,KAAK;AACzB,SAAA,OAAO,CAAC,IAAI,EAAE,CAAC,SAAS,KAAK,SAAS,CAAC,WAAW,EAAE;AACpD,SAAA,IAAI,EAAE;AACf;AAiBM,SAAU,eAAe,CAC3B,KAAgD,EAAA;IAEhD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,GAAG,KAAK;IAEtD,MAAM,mBAAmB,GAAG,OAAO,CAC/B,MAAO,IAAI,KAAK,CAAC,OAAO,EAAyB,CAAC,mBAAmB,EACrE,CAAC,KAAK,CAAC,OAAO,CAAC,CAClB;IACD,MAAM,QAAQ,GAAG,OAAO,CACpB,MAAM,IAAI,GAAG,EAAU,OAAO,IAAI,EAAE,EAAc,EAClD,CAAC,OAAO,CAAC,CACZ;IAED,MAAM,MAAM,GAAG;AACV,SAAA,MAAM,CAAC,CAAC,UAAU,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;AACrD,SAAA,GAAG,CAAC,CAAC,UAAU,KAAI;AAChB,QAAA,MAAM,QAAQ,GAAG,wBAAwB,CAAC,UAAU,CAAC;QACrD,IAAI,CAAC,QAAQ,EAAE;AACX,YAAA,OAAO,IAAI;QACf;AAEA,QAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS;AAChC,QAAA,QACIA,GAAA,CAAC,KAAK,EAAA,EAIF,SAAS,EAAE,UAAU,CAAC,IAAI,EAC1B,KAAK,EAAE,CAAC,QAAkB,KAAI;AAE1B,gBAAA,OAAQ,QAA+C,CACnD,UAAU,CAAC,IAAI,CAClB;AACL,YAAA,CAAC,EACD,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAV9B,UAAU,CAAC,IAAI,CAWtB;AAEV,IAAA,CAAC;SACA,MAAM,CAAC,CAAC,KAAK,KAAkC,KAAK,KAAK,IAAI,CAAC;IAEnE,QACIC,IAAA,CAAC,WAAW,EAAA,EAAA,GAAK,gBAAgB,EAAA,QAAA,EAAA,CAC5B,MAAM,EACN,MAAM,CAAA,EAAA,CACG;AAEtB;;"}
1
+ {"version":3,"file":"AutoCommandForm.js","sources":["../../../CommandForm/AutoCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type React from 'react';\nimport { useMemo } from 'react';\nimport type { Command } from '@cratis/arc/commands';\nimport { CommandForm, type CommandFormProps } from '@cratis/arc.react/commands';\nimport { Guid } from '@cratis/fundamentals';\nimport { GuidField } from './fields/GuidField';\nimport { registerDefaultFieldTypeProviders } from './defaultFieldTypeProviders';\nimport { resolveFieldTypeProvider } from './fieldTypeProviderRegistry';\n\nregisterDefaultFieldTypeProviders();\n\n/**\n * Props for {@link AutoCommandForm} - every {@link CommandFormProps} except `children`, which is\n * generated from the command's own properties instead of being written out by hand.\n */\nexport interface AutoCommandFormProps<\n TCommand extends object,\n TResponse = object,\n> extends Omit<CommandFormProps<TCommand, TResponse>, 'children'> {\n /**\n * Property names to leave out of the generated field list - for a property that should not\n * be user-editable, or one a custom field placed elsewhere on the page already covers.\n */\n exclude?: (keyof TCommand)[];\n\n /**\n * Optional content rendered after the generated fields, inside the native Arc form and\n * command context. Supply a submit control here when needed; no action is added by default.\n */\n footer?: React.ReactNode;\n}\n\nfunction formatTitle(propertyName: string): string {\n return propertyName\n .replace(/([A-Z])/g, ' $1')\n .replace(/^./, (character) => character.toUpperCase())\n .trim();\n}\n\n// An invalid GuidField draft leaves the command value empty, so a changed currentValues overlay must\n// discard the draft even when the native value does not change. Only the registered GuidField itself\n// receives the key: no other provider sees an extra prop.\nfunction guidFieldResetProps(field: unknown, overlayValue: unknown): { resetKey?: unknown } {\n if (field !== GuidField) {\n return {};\n }\n return { resetKey: overlayValue instanceof Guid ? overlayValue.toString() : overlayValue };\n}\n\n/**\n * A `CommandForm` that generates its field list from the command's own properties, choosing each\n * field's component by the property's type through the {@link FieldTypeProvider} registry -\n * `registerFieldTypeProvider` for a type the built-in defaults (`string`, `number`, `boolean`,\n * `Date`) don't cover, or to override one of them. `GuidField` is not a default; register it for\n * Fundamentals `Guid` properties to edit them.\n *\n * A property whose type no registered provider handles is left out of the generated list -\n * `exclude` it explicitly for clarity, or add a `CommandForm` child by hand alongside this\n * component for that one property.\n *\n * @example\n * ```tsx\n * <AutoCommandForm command={RegisterInvoice} exclude={['invoiceId']} />\n * ```\n */\nexport function AutoCommandForm<TCommand extends object = object, TResponse = object>(\n props: AutoCommandFormProps<TCommand, TResponse>,\n): React.ReactElement {\n const { exclude, footer, ...commandFormProps } = props;\n // SAFETY: Arc command constructors expose the Command property-descriptor contract at runtime.\n const propertyDescriptors = useMemo(\n () => (new props.command() as unknown as Command).propertyDescriptors,\n [props.command],\n );\n const excluded = useMemo(\n () => new Set<string>((exclude ?? []) as string[]),\n [exclude],\n );\n\n const fields = propertyDescriptors\n .filter((descriptor) => !excluded.has(descriptor.name))\n .map((descriptor) => {\n const provider = resolveFieldTypeProvider(descriptor);\n if (!provider) {\n return null;\n }\n\n const Field = provider.component;\n return (\n <Field\n key={descriptor.name}\n {...guidFieldResetProps(Field, props.currentValues?.[descriptor.name as keyof TCommand])}\n // The accessor reads the property dynamically, so CommandForm cannot infer the\n // property name from its source text; fieldName states it explicitly.\n fieldName={descriptor.name}\n value={(instance: TCommand) => {\n // SAFETY: Arc descriptors name runtime properties on the same command instance.\n return (instance as unknown as Record<string, unknown>)[\n descriptor.name\n ];\n }}\n title={formatTitle(descriptor.name)}\n />\n );\n })\n .filter((field): field is React.ReactElement => field !== null);\n\n return (\n <Command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,SAAS;AAChC,QAAA,QACIA,GAAA,CAAC,KAAK,EAAA,EAAA,GAEE,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,GAAG,UAAU,CAAC,IAAsB,CAAC,CAAC,EAGxF,SAAS,EAAE,UAAU,CAAC,IAAI,EAC1B,KAAK,EAAE,CAAC,QAAkB,KAAI;AAE1B,gBAAA,OAAQ,QAA+C,CACnD,UAAU,CAAC,IAAI,CAClB;AACL,YAAA,CAAC,EACD,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAX9B,UAAU,CAAC,IAAI,CAYtB;AAEV,IAAA,CAAC;SACA,MAAM,CAAC,CAAC,KAAK,KAAkC,KAAK,KAAK,IAAI,CAAC;IAEnE,QACIC,IAAA,CAAC,WAAW,EAAA,EAAA,GAAK,gBAAgB,EAAA,QAAA,EAAA,CAC5B,MAAM,EACN,MAAM,CAAA,EAAA,CACG;AAEtB;;"}
@@ -0,0 +1,49 @@
1
+ import { type InputHTMLAttributes, type ReactElement } from 'react';
2
+ import { type BaseCommandFormFieldProps, type InjectedCommandFormFieldProps } from '@cratis/arc.react/commands';
3
+ import { Guid } from '@cratis/fundamentals';
4
+ import { type FieldAccessibilityProps } from './fieldAccessibility.js';
5
+ /** Stable part attributes for {@link GuidField}. */
6
+ export interface GuidParts {
7
+ /** Native text input. Its value, change handling and validation attributes remain owned by the field. */
8
+ root?: InputHTMLAttributes<HTMLInputElement>;
9
+ }
10
+ /** Props for {@link GuidField}. */
11
+ export interface GuidFieldProps<TCommand = unknown> extends BaseCommandFormFieldProps<TCommand>, InjectedCommandFormFieldProps, FieldAccessibilityProps {
12
+ /** Selects a scalar Fundamentals `Guid` property on the command. */
13
+ value(instance: TCommand): Guid | undefined | null;
14
+ /** Hint displayed while the text is empty. */
15
+ placeholder?: string;
16
+ /** Additional classes on the native input. */
17
+ className?: string;
18
+ /** Native input attributes. */
19
+ pt?: GuidParts;
20
+ /** Localizable error for a nonempty draft that is not a Guid. Defaults to `Enter a valid Guid.`; an empty string keeps the default. */
21
+ formatErrorMessage?: string;
22
+ /** Localizable error for an empty required field. Defaults to `A value is required.`; an empty string keeps the default. */
23
+ requiredErrorMessage?: string;
24
+ /**
25
+ * Change this value to discard the text draft even when the command value has not changed, such
26
+ * as when an invalid draft already left the command value empty and the form is reset to empty.
27
+ */
28
+ resetKey?: unknown;
29
+ }
30
+ declare function GuidFieldComponent<TCommand = unknown>(props: GuidFieldProps<TCommand>): ReactElement;
31
+ /**
32
+ * Edits a scalar Fundamentals `Guid` command property as text, keeping the command value a native `Guid`.
33
+ *
34
+ * Partial or invalid text stays editable and leaves the command value `undefined`; the field reports a
35
+ * format error, or a required error when a required field is empty, through the form's custom field
36
+ * errors. Arc and Arc React 22.19.1 or newer refuse to execute a form with custom field errors, so an
37
+ * invalid draft cannot be submitted. The field never generates an identifier and accepts every value
38
+ * `Guid.isGuid` accepts, including the empty Guid.
39
+ *
40
+ * Not a default {@link AutoCommandForm} provider; register it explicitly:
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * registerFieldTypeProvider({ canHandle: (descriptor) => descriptor.type === Guid, component: GuidField });
45
+ * ```
46
+ */
47
+ export declare const GuidField: typeof GuidFieldComponent & import("../index.js").CommandFormMarked;
48
+ export {};
49
+ //# sourceMappingURL=GuidField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuidField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/GuidField.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA+B,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAGjG,OAAO,EAGH,KAAK,yBAAyB,EAC9B,KAAK,6BAA6B,EAErC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAyB,KAAK,uBAAuB,EAAE,MAAM,yBAAsB,CAAC;AAM3F,oDAAoD;AACpD,MAAM,WAAW,SAAS;IACtB,yGAAyG;IACzG,IAAI,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;CAChD;AAED,mCAAmC;AACnC,MAAM,WAAW,cAAc,CAAC,QAAQ,GAAG,OAAO,CAC9C,SAAQ,yBAAyB,CAAC,QAAQ,CAAC,EACvC,6BAA6B,EAC7B,uBAAuB;IAC3B,oEAAoE;IACpE,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;IACnD,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,uIAAuI;IACvI,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4HAA4H;IAC5H,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AA2HD,iBAAS,kBAAkB,CAAC,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,YAAY,CAG7F;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,SAAS,qEAA6C,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import { useState, useRef, useEffect } from 'react';
3
+ import { asCommandFormField, useCommandFormContext } from '@cratis/arc.react/commands';
4
+ import { Guid } from '@cratis/fundamentals';
5
+ import { markAsCommandFormField } from '../commandFormMarkers.js';
6
+ import { useFieldAccessibility } from './fieldAccessibility.js';
7
+
8
+ const defaultGuidFormatErrorMessage = 'Enter a valid Guid.';
9
+ const defaultGuidRequiredErrorMessage = 'A value is required.';
10
+ const textForValue = (value) => (value instanceof Guid ? value.toString() : '');
11
+ const propertyNameFromAccessor = (accessor) => {
12
+ if (typeof accessor !== 'function')
13
+ return '';
14
+ const match = accessor.toString().match(/\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);
15
+ return match ? match[1] : '';
16
+ };
17
+ function GuidControl(props) {
18
+ const { value: currentValue, boundFieldName: fieldName, resetKey, required } = props;
19
+ const { getFieldError, customFieldErrors, setCustomFieldError } = useCommandFormContext();
20
+ const [draft, setDraft] = useState(() => ({ value: currentValue, resetKey, text: textForValue(currentValue) }));
21
+ const synchronized = Object.is(draft.value, currentValue) && Object.is(draft.resetKey, resetKey);
22
+ if (!synchronized) {
23
+ setDraft({ value: currentValue, resetKey, text: textForValue(currentValue) });
24
+ }
25
+ const text = synchronized ? draft.text : textForValue(currentValue);
26
+ const errorForText = (value) => {
27
+ if (value.length === 0) {
28
+ return required ? props.requiredErrorMessage || defaultGuidRequiredErrorMessage : undefined;
29
+ }
30
+ return Guid.isGuid(value) ? undefined : props.formatErrorMessage || defaultGuidFormatErrorMessage;
31
+ };
32
+ const error = errorForText(text);
33
+ const ownedErrorRef = useRef(undefined);
34
+ const latestGetFieldErrorRef = useRef(getFieldError);
35
+ latestGetFieldErrorRef.current = getFieldError;
36
+ const publishError = (nextError, current = fieldName ? getFieldError(fieldName) : undefined) => {
37
+ if (!fieldName)
38
+ return;
39
+ if (current && current !== ownedErrorRef.current) {
40
+ ownedErrorRef.current = undefined;
41
+ return;
42
+ }
43
+ if (nextError !== current) {
44
+ setCustomFieldError(fieldName, nextError);
45
+ }
46
+ ownedErrorRef.current = nextError;
47
+ };
48
+ const customError = fieldName && Object.hasOwn(customFieldErrors, fieldName) ? customFieldErrors[fieldName] || undefined : undefined;
49
+ useEffect(() => {
50
+ if (error !== ownedErrorRef.current || (error && !customError)) {
51
+ publishError(error, customError);
52
+ }
53
+ });
54
+ useEffect(() => () => {
55
+ if (fieldName && ownedErrorRef.current && latestGetFieldErrorRef.current(fieldName) === ownedErrorRef.current) {
56
+ setCustomFieldError(fieldName, undefined);
57
+ }
58
+ }, [fieldName, setCustomFieldError]);
59
+ const errors = [...new Set([error, ...props.errors].filter((message) => Boolean(message)))];
60
+ const invalid = errors.length > 0;
61
+ const accessibility = useFieldAccessibility({ ...props, errors }, {
62
+ id: props.pt?.root?.id,
63
+ ariaLabel: props.pt?.root?.['aria-label'],
64
+ ariaDescribedBy: props.pt?.root?.['aria-describedby'],
65
+ });
66
+ return (jsxs(Fragment, { children: [jsx("input", { ...props.pt?.root, id: accessibility.controlId, "aria-label": accessibility.ariaLabel, "aria-describedby": accessibility.ariaDescribedBy, "aria-required": required || undefined, "aria-invalid": invalid || undefined, type: 'text', value: text, onChange: (event) => {
67
+ const nextText = event.currentTarget.value;
68
+ const nextValue = Guid.isGuid(nextText) ? Guid.parse(nextText) : undefined;
69
+ setDraft({ value: nextValue, resetKey, text: nextText });
70
+ publishError(undefined);
71
+ props.onChange(nextValue);
72
+ publishError(errorForText(nextText));
73
+ }, onBlur: props.onBlur, placeholder: props.placeholder, "data-disabled": props.pt?.root?.disabled || undefined, "data-invalid": invalid || undefined, "data-readonly": props.pt?.root?.readOnly || undefined, "data-cratis-part": 'input', className: ['cratis-field-input', 'cratis:w-full', props.pt?.root?.className, props.className]
74
+ .filter(Boolean)
75
+ .join(' ') }), accessibility.hiddenError] }));
76
+ }
77
+ const GuidBinding = asCommandFormField(GuidControl, { defaultValue: undefined });
78
+ function GuidFieldComponent(props) {
79
+ const boundFieldName = props.fieldName || propertyNameFromAccessor(props.value) || undefined;
80
+ return jsx(GuidBinding, { ...props, boundFieldName: boundFieldName });
81
+ }
82
+ const GuidField = markAsCommandFormField(GuidFieldComponent);
83
+
84
+ export { GuidField };
85
+ //# sourceMappingURL=GuidField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuidField.js","sources":["../../../../CommandForm/fields/GuidField.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useRef, useState, type InputHTMLAttributes, type ReactElement } from 'react';\n// Only symbols @cratis/arc.react 20.3.1 already exports may be imported at module scope here: the\n// package declares Arc React as a range, and a missing named import fails when the module links.\nimport {\n asCommandFormField,\n useCommandFormContext,\n type BaseCommandFormFieldProps,\n type InjectedCommandFormFieldProps,\n type WrappedFieldProps,\n} from '@cratis/arc.react/commands';\nimport { Guid } from '@cratis/fundamentals';\nimport { markAsCommandFormField } from '../commandFormMarkers';\nimport { useFieldAccessibility, type FieldAccessibilityProps } from './fieldAccessibility';\n\nconst defaultGuidFormatErrorMessage = 'Enter a valid Guid.';\n\nconst defaultGuidRequiredErrorMessage = 'A value is required.';\n\n/** Stable part attributes for {@link GuidField}. */\nexport interface GuidParts {\n /** Native text input. Its value, change handling and validation attributes remain owned by the field. */\n root?: InputHTMLAttributes<HTMLInputElement>;\n}\n\n/** Props for {@link GuidField}. */\nexport interface GuidFieldProps<TCommand = unknown>\n extends BaseCommandFormFieldProps<TCommand>,\n InjectedCommandFormFieldProps,\n FieldAccessibilityProps {\n /** Selects a scalar Fundamentals `Guid` property on the command. */\n value(instance: TCommand): Guid | undefined | null;\n /** Hint displayed while the text is empty. */\n placeholder?: string;\n /** Additional classes on the native input. */\n className?: string;\n /** Native input attributes. */\n pt?: GuidParts;\n /** Localizable error for a nonempty draft that is not a Guid. Defaults to `Enter a valid Guid.`; an empty string keeps the default. */\n formatErrorMessage?: string;\n /** Localizable error for an empty required field. Defaults to `A value is required.`; an empty string keeps the default. */\n requiredErrorMessage?: string;\n /**\n * Change this value to discard the text draft even when the command value has not changed, such\n * as when an invalid draft already left the command value empty and the form is reset to empty.\n */\n resetKey?: unknown;\n}\n\ninterface GuidControlProps extends WrappedFieldProps<Guid | undefined | null>, FieldAccessibilityProps {\n placeholder?: string;\n className?: string;\n pt?: GuidParts;\n formatErrorMessage?: string;\n requiredErrorMessage?: string;\n resetKey?: unknown;\n /** The bound command property. `asCommandFormField` consumes `fieldName`, so it is forwarded under this name. */\n boundFieldName?: string;\n}\n\ninterface GuidDraft {\n value: unknown;\n resetKey: unknown;\n text: string;\n}\n\nconst textForValue = (value: unknown) => (value instanceof Guid ? value.toString() : '');\n\n// Mirrors Arc React's own source-text inference, so the field reports its errors under the same\n// property name Arc binds when an accessor such as `command => command.sampleId` has no fieldName.\nconst propertyNameFromAccessor = (accessor: unknown): string => {\n if (typeof accessor !== 'function') return '';\n const match = accessor.toString().match(/\\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);\n return match ? match[1] : '';\n};\n\nfunction GuidControl(props: GuidControlProps) {\n const { value: currentValue, boundFieldName: fieldName, resetKey, required } = props;\n const { getFieldError, customFieldErrors, setCustomFieldError } = useCommandFormContext<unknown>();\n const [draft, setDraft] = useState<GuidDraft>(() => ({ value: currentValue, resetKey, text: textForValue(currentValue) }));\n const synchronized = Object.is(draft.value, currentValue) && Object.is(draft.resetKey, resetKey);\n // Adopt an external value or reset during render; a delayed effect could overwrite ongoing typing.\n if (!synchronized) {\n setDraft({ value: currentValue, resetKey, text: textForValue(currentValue) });\n }\n const text = synchronized ? draft.text : textForValue(currentValue);\n const errorForText = (value: string): string | undefined => {\n if (value.length === 0) {\n return required ? props.requiredErrorMessage || defaultGuidRequiredErrorMessage : undefined;\n }\n return Guid.isGuid(value) ? undefined : props.formatErrorMessage || defaultGuidFormatErrorMessage;\n };\n const error = errorForText(text);\n const ownedErrorRef = useRef<string | undefined>(undefined);\n const latestGetFieldErrorRef = useRef(getFieldError);\n latestGetFieldErrorRef.current = getFieldError;\n\n // The field writes only into an empty slot or over the error it published itself: an\n // onFieldValidate or caller error is never overwritten or cleared. Arc React 22.19.1+ reads custom\n // errors live, which is what makes the ownership check hold for writes made in the same event batch.\n const publishError = (nextError: string | undefined, current = fieldName ? getFieldError(fieldName) : undefined) => {\n if (!fieldName) return;\n if (current && current !== ownedErrorRef.current) {\n ownedErrorRef.current = undefined;\n return;\n }\n if (nextError !== current) {\n setCustomFieldError(fieldName, nextError);\n }\n ownedErrorRef.current = nextError;\n };\n const customError = fieldName && Object.hasOwn(customFieldErrors, fieldName) ? customFieldErrors[fieldName] || undefined : undefined;\n // Publish when the draft's own error changes, or refill an emptied slot so an invalid draft stays blocking.\n useEffect(() => {\n if (error !== ownedErrorRef.current || (error && !customError)) {\n publishError(error, customError);\n }\n });\n useEffect(() => () => {\n if (fieldName && ownedErrorRef.current && latestGetFieldErrorRef.current(fieldName) === ownedErrorRef.current) {\n setCustomFieldError(fieldName, undefined);\n }\n }, [fieldName, setCustomFieldError]);\n\n const errors = [...new Set([error, ...props.errors].filter((message): message is string => Boolean(message)))];\n const invalid = errors.length > 0;\n const accessibility = useFieldAccessibility({ ...props, errors }, {\n id: props.pt?.root?.id,\n ariaLabel: props.pt?.root?.['aria-label'],\n ariaDescribedBy: props.pt?.root?.['aria-describedby'],\n });\n return (\n <>\n <input\n {...props.pt?.root}\n id={accessibility.controlId}\n aria-label={accessibility.ariaLabel}\n aria-describedby={accessibility.ariaDescribedBy}\n aria-required={required || undefined}\n aria-invalid={invalid || undefined}\n type='text'\n value={text}\n onChange={(event) => {\n const nextText = event.currentTarget.value;\n const nextValue = Guid.isGuid(nextText) ? Guid.parse(nextText) : undefined;\n setDraft({ value: nextValue, resetKey, text: nextText });\n // A partial or invalid draft writes undefined at once, never the previous identifier.\n // Arc still owns command mutation, validation and execution; this field supplies an error.\n publishError(undefined);\n props.onChange(nextValue);\n // Publish again after binding: onFieldValidate may have replaced the error synchronously.\n publishError(errorForText(nextText));\n }}\n onBlur={props.onBlur}\n placeholder={props.placeholder}\n data-disabled={props.pt?.root?.disabled || undefined}\n data-invalid={invalid || undefined}\n data-readonly={props.pt?.root?.readOnly || undefined}\n data-cratis-part='input'\n className={['cratis-field-input', 'cratis:w-full', props.pt?.root?.className, props.className]\n .filter(Boolean)\n .join(' ')}\n />\n {accessibility.hiddenError}\n </>\n );\n}\n\nconst GuidBinding = asCommandFormField<GuidControlProps>(GuidControl, { defaultValue: undefined });\n\nfunction GuidFieldComponent<TCommand = unknown>(props: GuidFieldProps<TCommand>): ReactElement {\n const boundFieldName = props.fieldName || propertyNameFromAccessor(props.value) || undefined;\n return <GuidBinding<TCommand> {...props} boundFieldName={boundFieldName} />;\n}\n\n/**\n * Edits a scalar Fundamentals `Guid` command property as text, keeping the command value a native `Guid`.\n *\n * Partial or invalid text stays editable and leaves the command value `undefined`; the field reports a\n * format error, or a required error when a required field is empty, through the form's custom field\n * errors. Arc and Arc React 22.19.1 or newer refuse to execute a form with custom field errors, so an\n * invalid draft cannot be submitted. The field never generates an identifier and accepts every value\n * `Guid.isGuid` accepts, including the empty Guid.\n *\n * Not a default {@link AutoCommandForm} provider; register it explicitly:\n *\n * @example\n * ```tsx\n * registerFieldTypeProvider({ canHandle: (descriptor) => descriptor.type === Guid, component: GuidField });\n * ```\n */\nexport const GuidField = markAsCommandFormField(GuidFieldComponent);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AAiBA,MAAM,6BAA6B,GAAG,qBAAqB;AAE3D,MAAM,+BAA+B,GAAG,sBAAsB;AAiD9D,MAAM,YAAY,GAAG,CAAC,KAAc,MAAM,KAAK,YAAY,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC;AAIxF,MAAM,wBAAwB,GAAG,CAAC,QAAiB,KAAY;IAC3D,IAAI,OAAO,QAAQ,KAAK,UAAU;AAAE,QAAA,OAAO,EAAE;IAC7C,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,8BAA8B,CAAC;AACvE,IAAA,OAAO,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE;AAChC,CAAC;AAED,SAAS,WAAW,CAAC,KAAuB,EAAA;AACxC,IAAA,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK;IACpF,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,GAAG,qBAAqB,EAAW;AAClG,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,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AAS,EAAE,CAAC,oBAAoB,EAAE,eAAe,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS;qBACxF,MAAM,CAAC,OAAO;qBACd,IAAI,CAAC,GAAG,CAAC,EAAA,CAChB,EACD,aAAa,CAAC,WAAW,CAAA,EAAA,CAC3B;AAEX;AAEA,MAAM,WAAW,GAAG,kBAAkB,CAAmB,WAAW,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;AAElG,SAAS,kBAAkB,CAAqB,KAA+B,EAAA;AAC3E,IAAA,MAAM,cAAc,GAAG,KAAK,CAAC,SAAS,IAAI,wBAAwB,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,SAAS;IAC5F,OAAOA,GAAA,CAAC,WAAW,EAAA,EAAA,GAAe,KAAK,EAAE,cAAc,EAAE,cAAc,EAAA,CAAI;AAC/E;MAkBa,SAAS,GAAG,sBAAsB,CAAC,kBAAkB;;"}
@@ -1,4 +1,5 @@
1
1
  export * from './InputTextField.js';
2
+ export * from './GuidField.js';
2
3
  export * from './NumberField.js';
3
4
  export * from './NumberInputField.js';
4
5
  export * from './CheckboxField.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/index.ts"],"names":[],"mappings":"AAGA,cAAc,qBAAkB,CAAC;AACjC,cAAc,kBAAe,CAAC;AAC9B,cAAc,uBAAoB,CAAC;AACnC,cAAc,oBAAiB,CAAC;AAChC,cAAc,oBAAiB,CAAC;AAChC,cAAc,oBAAiB,CAAC;AAChC,cAAc,kBAAe,CAAC;AAC9B,cAAc,oBAAiB,CAAC;AAChC,cAAc,uBAAoB,CAAC;AACnC,cAAc,uBAAoB,CAAC;AACnC,cAAc,iBAAc,CAAC;AAC7B,cAAc,uBAAoB,CAAC;AACnC,cAAc,sBAAmB,CAAC;AAClC,cAAc,oBAAiB,CAAC;AAChC,cAAc,wBAAqB,CAAC;AACpC,cAAc,kBAAe,CAAC;AAC9B,cAAc,uBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/index.ts"],"names":[],"mappings":"AAGA,cAAc,qBAAkB,CAAC;AACjC,cAAc,gBAAa,CAAC;AAC5B,cAAc,kBAAe,CAAC;AAC9B,cAAc,uBAAoB,CAAC;AACnC,cAAc,oBAAiB,CAAC;AAChC,cAAc,oBAAiB,CAAC;AAChC,cAAc,oBAAiB,CAAC;AAChC,cAAc,kBAAe,CAAC;AAC9B,cAAc,oBAAiB,CAAC;AAChC,cAAc,uBAAoB,CAAC;AACnC,cAAc,uBAAoB,CAAC;AACnC,cAAc,iBAAc,CAAC;AAC7B,cAAc,uBAAoB,CAAC;AACnC,cAAc,sBAAmB,CAAC;AAClC,cAAc,oBAAiB,CAAC;AAChC,cAAc,wBAAqB,CAAC;AACpC,cAAc,kBAAe,CAAC;AAC9B,cAAc,uBAAoB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) Cratis. All rights reserved.
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
  export * from './InputTextField.js';
4
+ export * from './GuidField.js';
4
5
  export * from './NumberField.js';
5
6
  export * from './NumberInputField.js';
6
7
  export * from './CheckboxField.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../CommandForm/fields/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,cAAc,qBAAkB,CAAC;AACjC,cAAc,kBAAe,CAAC;AAC9B,cAAc,uBAAoB,CAAC;AACnC,cAAc,oBAAiB,CAAC;AAChC,cAAc,oBAAiB,CAAC;AAChC,cAAc,oBAAiB,CAAC;AAChC,cAAc,kBAAe,CAAC;AAC9B,cAAc,oBAAiB,CAAC;AAChC,cAAc,uBAAoB,CAAC;AACnC,cAAc,uBAAoB,CAAC;AACnC,cAAc,iBAAc,CAAC;AAC7B,cAAc,uBAAoB,CAAC;AACnC,cAAc,sBAAmB,CAAC;AAClC,cAAc,oBAAiB,CAAC;AAChC,cAAc,wBAAqB,CAAC;AACpC,cAAc,kBAAe,CAAC;AAC9B,cAAc,uBAAoB,CAAC","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport * from './InputTextField';\nexport * from './NumberField';\nexport * from './NumberInputField';\nexport * from './CheckboxField';\nexport * from './TextAreaField';\nexport * from './DropdownField';\nexport * from './SliderField';\nexport * from './CalendarField';\nexport * from './ColorPickerField';\nexport * from './MultiSelectField';\nexport * from './ChipsField';\nexport * from './RadioButtonField';\nexport * from './RadioGroupField';\nexport * from './PasswordField';\nexport * from './ToggleSwitchField';\nexport * from './RatingField';\nexport * from './NumberInputField';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../CommandForm/fields/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,cAAc,qBAAkB,CAAC;AACjC,cAAc,gBAAa,CAAC;AAC5B,cAAc,kBAAe,CAAC;AAC9B,cAAc,uBAAoB,CAAC;AACnC,cAAc,oBAAiB,CAAC;AAChC,cAAc,oBAAiB,CAAC;AAChC,cAAc,oBAAiB,CAAC;AAChC,cAAc,kBAAe,CAAC;AAC9B,cAAc,oBAAiB,CAAC;AAChC,cAAc,uBAAoB,CAAC;AACnC,cAAc,uBAAoB,CAAC;AACnC,cAAc,iBAAc,CAAC;AAC7B,cAAc,uBAAoB,CAAC;AACnC,cAAc,sBAAmB,CAAC;AAClC,cAAc,oBAAiB,CAAC;AAChC,cAAc,wBAAqB,CAAC;AACpC,cAAc,kBAAe,CAAC;AAC9B,cAAc,uBAAoB,CAAC","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport * from './InputTextField';\nexport * from './GuidField';\nexport * from './NumberField';\nexport * from './NumberInputField';\nexport * from './CheckboxField';\nexport * from './TextAreaField';\nexport * from './DropdownField';\nexport * from './SliderField';\nexport * from './CalendarField';\nexport * from './ColorPickerField';\nexport * from './MultiSelectField';\nexport * from './ChipsField';\nexport * from './RadioButtonField';\nexport * from './RadioGroupField';\nexport * from './PasswordField';\nexport * from './ToggleSwitchField';\nexport * from './RatingField';\nexport * from './NumberInputField';\n"]}
@@ -1,5 +1,6 @@
1
1
  export { CommandFormColumnDisplayName, CommandFormFieldDisplayName, isCommandFormColumn, isCommandFormField, markAsCommandFormColumn, markAsCommandFormField } from './commandFormMarkers.js';
2
2
  export { InputTextField } from './fields/InputTextField.js';
3
+ export { GuidField } from './fields/GuidField.js';
3
4
  export { NumberField } from './fields/NumberField.js';
4
5
  export { NumberInputField } from './fields/NumberInputField.js';
5
6
  export { CheckboxField } from './fields/CheckboxField.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
@@ -6,6 +6,7 @@ import type { DataTableParts } from '../DataTables/DataTableCore.js';
6
6
  import type { TablePaginatorParts, TablePaginatorProps } from '../DataTables/TablePaginator.js';
7
7
  import type { DataTableFilterMeta } from '../DataTables/DataTableFilterMeta.js';
8
8
  import type { DataTableSelectionChangeEvent } from '../DataTables/DataTableSelectionChangeEvent.js';
9
+ import type { DataTableServerQuery } from '../DataTables/DataTableServerQuery.js';
9
10
  import type { Constructor } from '@cratis/fundamentals';
10
11
  /**
11
12
  * Props for {@link MenuItem} — a single action in a {@link DataPage}'s
@@ -165,6 +166,12 @@ export interface DataPageProps<TQuery extends IQueryFor<TDataType, TArguments> |
165
166
  * server-reported pagination totals. Retained for source compatibility only.
166
167
  */
167
168
  clientFiltering?: boolean;
169
+ /**
170
+ * Opts the page's table into server mode: the query sorts, filters and searches the complete
171
+ * result before paging, and the table renders the rows as returned. Leave undefined to sort,
172
+ * filter and search the loaded page. See {@link DataTableServerQuery}.
173
+ */
174
+ serverQuery?: DataTableServerQuery<TArguments>;
168
175
  /** Optional callback forwarded to the details component as `onRefresh`; DataPage does not invoke it or refetch when it is called. */
169
176
  onRefresh?(): void;
170
177
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"DataPage.d.ts","sourceRoot":"","sources":["../../../DataPage/DataPage.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAsB,KAAK,SAAS,EAAW,MAAM,OAAO,CAAC;AAEpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAY,MAAM,qBAAqB,CAAC;AAEzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAA6B,CAAC;AAElE,OAAO,KAAK,EACR,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,iCAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gDAA6C,CAAC;AAEjG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAWxD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,0EAA0E;IAC1E,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,WAAY,aAAa,SAE7C,CAAC;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AAU,SAAS,MAAM,EAEzB,KAAK,EAAE,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC;;;;;;AA+DvD,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DataPage.js","sources":["../../../DataPage/DataPage.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { type CSSProperties, type ReactNode, useMemo } from 'react';\nimport { Page } from '../Common/Page';\nimport React from 'react';\nimport { ActionMenubar, type ActionMenuItem } from '../Common/ActionMenubar';\nimport type { ButtonParts } from '../Common/Button';\nimport { type IObservableQueryFor, type IQueryFor, QueryFor } from '@cratis/arc/queries';\nimport { DataTableForObservableQuery } from '../DataTables/DataTableForObservableQuery';\nimport type { DataTableParts } from '../DataTables/DataTableCore';\nimport { DataTableForQuery } from '../DataTables/DataTableForQuery';\nimport type {\n TablePaginatorParts,\n TablePaginatorProps,\n} from '../DataTables/TablePaginator';\nimport type { DataTableFilterMeta } from '../DataTables/DataTableFilterMeta';\nimport type { DataTableSelectionChangeEvent } from '../DataTables/DataTableSelectionChangeEvent';\nimport { Allotment } from 'allotment';\nimport type { Constructor } from '@cratis/fundamentals';\nimport { DataPageLayout } from './DataPageLayout';\n\n// Allotment ships its layout as a stylesheet rather than inline styles, and a pane only becomes\n// the absolutely positioned, full-height box the split view assumes once that stylesheet is on\n// the page. It used to be pulled in here with a bare `import 'allotment/dist/style.css'`, but a\n// CSS import inside the JS graph is precisely what stops the published ESM from loading in Node\n// (Cratis/Components#118). The rules now ship inside this package's own `./styles` entry point,\n// which the build concatenates from every component stylesheet plus this third-party one — so a\n// consumer still gets a working split view, from the single stylesheet they already import.\n\n/**\n * Props for {@link MenuItem} — a single action in a {@link DataPage}'s\n * action bar.\n */\nexport interface MenuItemProps {\n /** Icon component rendered before the label (e.g. a react-icons icon). */\n icon?: React.ComponentType<{ className?: string }>;\n /** The visible label. */\n label?: string;\n /** Invoked when the item is activated. */\n command?: () => void;\n /** When true, the item is greyed out regardless of selection. */\n disabled?: boolean;\n /**\n * When true, the menu item is disabled while no row is selected in the\n * surrounding {@link DataPage}. Use it for context-sensitive actions like\n * \"Edit\" or \"Delete\" that require a selection.\n */\n disableOnUnselected?: boolean;\n}\n\n/**\n * Declarative menu item for use inside `<DataPage.MenuItems>`. Renders nothing\n * directly; the surrounding {@link MenuItems} component reads its props and\n * forwards them to the action menubar.\n */\nexport const MenuItem = (_props: MenuItemProps) => {\n return null;\n};\n\n/**\n * Props for {@link MenuItems}.\n */\nexport interface MenuItemsProps {\n /** One or more `<DataPage.MenuItem>` elements. */\n children: ReactNode;\n}\n\n/**\n * Props for {@link Columns}.\n */\nexport interface ColumnsProps {\n /** Cratis-owned `<Column>` markers describing each visible column. */\n children: ReactNode;\n}\n\n/**\n * The action bar is an intrinsically sized item in the page's layout column —\n * it takes the height its menubar needs and never gives any of it up, so the\n * table region below it is the only part that has to adapt to the space left.\n */\nconst actionsStyle: CSSProperties = { flexShrink: 0 };\n\n/**\n * The table region takes every pixel the action bar leaves and no more.\n * `minHeight: 0` is the load-bearing half: without it the region's automatic\n * minimum keeps it at content height, the column grows past the page, and the\n * table's paginator ends up below the clipped edge.\n */\nconst tableRegionStyle: CSSProperties = { flexGrow: 1, flexBasis: 0, minHeight: 0 };\n\n/**\n * The floor a `DataPage` falls back to when its ancestors give it no height at\n * all. A page that renders as an empty sliver is indistinguishable from a\n * broken one, so a contract-violating consumer gets a small but usable page\n * instead of nothing.\n */\nconst pageStyle: CSSProperties = { minHeight: '20rem' };\n\n/**\n * Renders an action menubar at the top of a {@link DataPage}, populated from\n * `<DataPage.MenuItem>` children. Each menu item's `disableOnUnselected` flag\n * is automatically honored against the current row selection.\n *\n * Use as `<DataPage.MenuItems>` inside a `<DataPage>`.\n */\nexport const MenuItems = ({ children }: MenuItemsProps) => {\n const context = useDataPageContext();\n const isDisabled =\n context.selectionMode === 'multiple'\n ? context.selectedItems.length === 0\n : !context.selectedItem;\n\n const items = useMemo(() => {\n const menuItems: ActionMenuItem[] = [];\n React.Children.forEach(children, (child) => {\n if (React.isValidElement<MenuItemProps>(child) && child.type === MenuItem) {\n const Icon = child.props.icon;\n menuItems.push({\n label: child.props.label,\n command: child.props.command,\n icon: Icon ? <Icon className='cratis:mr-2' /> : undefined,\n disabled:\n (child.props.disabled ?? false) ||\n (isDisabled && (child.props.disableOnUnselected ?? false)),\n });\n }\n });\n\n return menuItems;\n }, [children, isDisabled]);\n\n return (\n <div\n className='cratis-data-page-actions cratis:px-4 cratis:py-2'\n style={actionsStyle}\n >\n <ActionMenubar\n aria-label={context.actionsAriaLabel ?? 'Actions'}\n model={items}\n className={context.menubarClassName}\n pt={context.menubarPt}\n ptOptions={context.menubarPtOptions}\n unstyled={context.menubarUnstyled}\n />\n </div>\n );\n};\n\n/**\n * Renders the data table at the body of a {@link DataPage}. Automatically\n * selects between {@link DataTableForQuery} (snapshot query) and\n * {@link DataTableForObservableQuery} (real-time observable) based on the\n * `query` type provided to the surrounding `<DataPage>`.\n *\n * Use as `<DataPage.Columns>` inside a `<DataPage>`, with Cratis-owned `<Column>`\n * children defining the table columns.\n */\nexport const Columns = ({ children }: ColumnsProps) => {\n const context = useDataPageContext();\n const isSnapshotQuery = context.query.prototype instanceof QueryFor;\n // SAFETY: The runtime prototype check above narrows a constructor shape that\n // TypeScript cannot discriminate after the generic DataPage context is erased.\n const snapshotQuery = context.query as Constructor<\n IQueryFor<object, object> | IQueryFor<object[], object>\n >;\n const observableQuery = context.query as Constructor<\n IObservableQueryFor<object, object> | IObservableQueryFor<object[], object>\n >;\n\n return (\n <div className='cratis-data-page-table' style={tableRegionStyle}>\n {isSnapshotQuery ? (\n <DataTableForQuery\n {...context}\n query={snapshotQuery}\n selection={context.selectedItem}\n onSelectionChange={context.onSelectionChanged}\n className={context.tableClassName}\n pt={context.tablePt}\n ptOptions={context.tablePtOptions}\n unstyled={context.tableUnstyled}\n >\n {children}\n </DataTableForQuery>\n ) : (\n <DataTableForObservableQuery\n {...context}\n query={observableQuery}\n selection={context.selectedItem}\n onSelectionChange={context.onSelectionChanged}\n className={context.tableClassName}\n pt={context.tablePt}\n ptOptions={context.tablePtOptions}\n unstyled={context.tableUnstyled}\n >\n {children}\n </DataTableForObservableQuery>\n )}\n </div>\n );\n};\n\n/**\n * Props passed to the optional details component rendered on the right pane\n * of a {@link DataPage} when a row is selected.\n *\n * @typeParam TDataType - The type of the selected item.\n */\nexport interface IDetailsComponentProps<TDataType> {\n /** The currently-selected row. */\n item: TDataType;\n\n /**\n * The caller's {@link DataPageProps.onRefresh} callback, forwarded unchanged\n * to the details component. Invoking it does not make DataPage refetch.\n */\n onRefresh?: () => void;\n}\n\ninterface IDataPageContext extends DataPageProps<\n IQueryFor<object, object> | IObservableQueryFor<object, object>,\n object,\n object\n> {\n selectedItem: object | null | undefined;\n onSelectionChanged: (event: DataTableSelectionChangeEvent<object>) => void;\n selectedItems: object[];\n onSelectedItemsChange: (items: object[]) => void;\n}\n\nconst DataPageContext = React.createContext<IDataPageContext | null>(null);\n\nfunction useDataPageContext(): IDataPageContext {\n const context = React.useContext(DataPageContext);\n if (!context) {\n throw new Error('useDataPageContext must be used within a DataPage component');\n }\n return context;\n}\n\n/**\n * Props for {@link DataPage}.\n *\n * @typeParam TQuery - The query class — either a snapshot `IQueryFor` or a real-time `IObservableQueryFor`.\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type, or `object` if the query takes none.\n */\nexport interface DataPageProps<\n TQuery extends\n | IQueryFor<TDataType, TArguments>\n | IQueryFor<TDataType[], TArguments>\n | IObservableQueryFor<TDataType, TArguments>\n | IObservableQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n> {\n /**\n * The title of the page\n */\n title: string;\n\n /**\n * Children to render, for this it means menu items and columns. Use <DataPage.MenuItems> and <DataPage.Columns> for this.\n */\n children: ReactNode;\n\n /**\n * Component to render when the selection changes\n */\n detailsComponent?: React.FC<IDetailsComponentProps<TDataType>>;\n\n /**\n * The type of query to use\n */\n query: Constructor<TQuery>;\n\n /**\n * Optional arguments to pass to the query\n */\n queryArguments?: TArguments;\n\n /**\n * The message to show when there is no data\n */\n emptyMessage: string;\n\n /** Message shown while loading without rows. */\n loadingMessage?: ReactNode;\n /** Message shown when the query fails. */\n failureMessage?: ReactNode;\n /** Message shown when access is denied. */\n unauthorizedMessage?: ReactNode;\n\n /**\n * The key to use for the data\n */\n dataKey?: string | undefined;\n\n /**\n * The current selection.\n */\n selection?: TDataType | undefined | null;\n\n /**\n * Callback for when the selection changes\n */\n onSelectionChange?(event: DataTableSelectionChangeEvent<TDataType>): void;\n\n /**\n * The row selection mode. Defaults to `'single'`. Use `'multiple'` for a page whose actions\n * operate on a set of rows - it adds per-row checkboxes and a select-all header checkbox, and\n * reports through {@link onSelectedItemsChange}.\n */\n selectionMode?: 'single' | 'multiple';\n\n /**\n * The currently selected rows, for `selectionMode='multiple'`. Leave undefined to let the page\n * own the selection.\n */\n selectedItems?: TDataType[];\n\n /**\n * Callback for when a multiple selection changes, with the full selected set.\n */\n onSelectedItemsChange?(items: TDataType[]): void;\n\n /**\n * Fields to use for global filtering\n */\n globalFilterFields?: string[] | undefined;\n\n /** Placeholder for the loaded-page search input. */\n globalSearchPlaceholder?: string;\n\n /** Accessible name for the loaded-page search input. */\n globalSearchAriaLabel?: string;\n\n /**\n * Default filters to use\n */\n defaultFilters?: DataTableFilterMeta;\n\n /**\n * @deprecated Filtering is always applied to the currently loaded page.\n * This compatibility prop no longer toggles behavior and does not change\n * server-reported pagination totals. Retained for source compatibility only.\n */\n clientFiltering?: boolean;\n\n /** Optional callback forwarded to the details component as `onRefresh`; DataPage does not invoke it or refetch when it is called. */\n onRefresh?(): void;\n\n /**\n * Extra CSS class name forwarded to the inner DataTable root.\n */\n tableClassName?: string;\n\n /** Cratis-owned per-part attributes applied to the inner table. */\n tablePt?: DataTableParts;\n\n /**\n * @deprecated Cratis table parts always merge. Remove this renderer-era option.\n */\n tablePtOptions?: object;\n\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `tablePt` and CSS instead.\n */\n tableUnstyled?: boolean;\n\n /** Shows numbered page buttons in the query table paginator. Defaults to false. */\n pageLinks?: TablePaginatorProps['pageLinks'];\n\n /** Extra CSS class name forwarded to the query table paginator. */\n paginatorClassName?: string;\n\n /** Cratis-owned attributes applied to the query table paginator. */\n paginatorPt?: TablePaginatorParts;\n\n /**\n * @deprecated Cratis paginator parts always merge. Remove this renderer-era option.\n */\n paginatorPtOptions?: object;\n\n /** Accessible paginator labels. Override any value to localize it. */\n paginatorAriaLabels?: TablePaginatorProps['ariaLabels'];\n\n /**\n * Extra CSS class name forwarded to the action menubar root.\n */\n menubarClassName?: string;\n\n /** Cratis-owned part attributes applied to the action menubar's buttons. */\n menubarPt?: ButtonParts;\n\n /**\n * @deprecated Cratis menubar parts always merge. Remove this renderer-era option.\n */\n menubarPtOptions?: object;\n\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `menubarPt` and CSS instead.\n */\n menubarUnstyled?: boolean;\n\n /**\n * Accessible name for the action menubar (toolbar). Override to localize.\n * Defaults to `'Actions'`.\n */\n actionsAriaLabel?: string;\n}\n\n/**\n * A page primitive that combines an action menubar, a query-backed data\n * table, and an optional details pane into one layout. Designed as the\n * default rendering for \"list view\" pages in an Arc app.\n *\n * ## What `TQuery` is\n *\n * `TQuery` is the auto-generated TypeScript class produced by the Arc proxy\n * generator from a C# read model query. Two flavors are accepted and\n * **selected automatically at runtime** based on the class hierarchy:\n *\n * - **`IQueryFor<TDataType, TArguments>`** — a snapshot query. Re-fetched\n * when `queryArguments` change or when the page is mounted. Rendered\n * through {@link DataTableForQuery} internally.\n * - **`IObservableQueryFor<TDataType, TArguments>`** — a real-time\n * subscription. Connects to the backend over WebSocket and re-renders\n * automatically whenever the underlying read model changes server-side.\n * Rendered through {@link DataTableForObservableQuery} internally.\n *\n * You don't pick which inner table to use — `DataPage` inspects the\n * prototype chain (`context.query.prototype instanceof QueryFor`) and\n * mounts the correct one.\n *\n * ## Declarative composition\n *\n * Three children build up the page:\n *\n * - **`<DataPage.MenuItems>`** wraps `<DataPage.MenuItem>` elements that\n * become the action `Menubar` at the top. Each item declares its `icon`,\n * `label`, and `command` (an `onClick` handler). Items can be marked\n * `disableOnUnselected` so they automatically grey out until the user\n * picks a row — useful for Edit / Delete actions that need a target.\n *\n * - **`<DataPage.Columns>`** wraps Cratis-owned `<Column>` markers that\n * describe the visible columns. The columns themselves are\n * Cratis-owned — the documented `ColumnProps` surface is\n * supported here (sorting, filtering, custom body templates, …).\n *\n * - **`detailsComponent`** (optional) is a React component rendered in a\n * right-hand pane via Allotment when a row is selected. It receives the\n * selected item as `item` and the caller's `onRefresh` callback, if\n * supplied. DataPage does not refetch when the details component invokes it.\n *\n * ## Selection lifecycle\n *\n * `DataPage` keeps the current selection in local state and threads it to\n * the inner table, the menubar (`disableOnUnselected` items follow it),\n * and the optional details pane. The `onSelectionChange` prop is invoked\n * after every change if the consumer also needs to react to it.\n *\n * ```tsx\n * <DataPage<AllAuthors, Author, never>\n * title=\"Authors\"\n * query={AllAuthors} // proxy from C#\n * detailsComponent={AuthorDetails}>\n * <DataPage.MenuItems>\n * <DataPage.MenuItem icon={FaPlus} label=\"Add\" command={onAdd} />\n * <DataPage.MenuItem icon={FaPencil} label=\"Edit\" command={onEdit}\n * disableOnUnselected />\n * <DataPage.MenuItem icon={FaTrash} label=\"Delete\" command={onDelete}\n * disableOnUnselected />\n * </DataPage.MenuItems>\n * <DataPage.Columns>\n * <Column field=\"name\" header=\"Name\" sortable />\n * <Column field=\"email\" header=\"Email\" />\n * </DataPage.Columns>\n * </DataPage>\n * ```\n *\n * ## Height — `DataPage` needs a bounded ancestor\n *\n * `DataPage` fills the height it is given and divides it between the action\n * bar and the table region, so the table's paginator always sits at the\n * bottom of the page rather than below its edge. It cannot invent that height:\n * every element from the page root down sizes as a percentage of its parent,\n * so **some ancestor has to have a definite height**.\n *\n * ```tsx\n * // ✅ the router outlet, a sized container, or a flex child with min-height\n * <div style={{ height: '100vh' }}>\n * <DataPage … />\n * </div>\n *\n * // ❌ nothing above resolves to a height — the table grows to its content\n * <div>\n * <DataPage … />\n * </div>\n * ```\n *\n * Without one, the page falls back to a small fixed height so it stays\n * usable instead of collapsing to nothing.\n *\n * ## Styling\n *\n * The inner DataTable and action toolbar each have their own per-slot props:\n * `tablePt` / `tableUnstyled` / `tableClassName` for the table;\n * `paginatorPt` / `paginatorClassName` / `paginatorAriaLabels` for paging;\n * `menubarPt` / `menubarPtOptions` / `menubarUnstyled` / `menubarClassName` for\n * the action toolbar's stable button parts (the action bar is implemented as\n * a button toolbar, so `menubarPt` targets the stable Cratis button parts). See the\n * [pass-through cheat sheet](../../Documentation/Styling/pass-through.md) for\n * the full slot reference.\n *\n * @typeParam TQuery - The query class (proxy generated from a C# read model query).\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type.\n * @param props - {@link DataPageProps}.\n */\nconst DataPage = <\n TQuery extends\n | IQueryFor<TDataType, TArguments>\n | IQueryFor<TDataType[], TArguments>\n | IObservableQueryFor<TDataType, TArguments>\n | IObservableQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n>(\n props: DataPageProps<TQuery, TDataType, TArguments>,\n) => {\n const [internalSelection, setInternalSelection] = React.useState<\n TDataType | null | undefined\n >(props.selection);\n const selectedItem =\n props.selection === undefined ? internalSelection : props.selection;\n\n const selectionChanged = (event: DataTableSelectionChangeEvent<TDataType>) => {\n if (props.selection === undefined) setInternalSelection(event.value);\n props.onSelectionChange?.(event);\n };\n\n const [internalSelectedItems, setInternalSelectedItems] = React.useState<TDataType[]>(\n props.selectedItems ?? [],\n );\n const selectedItems = props.selectedItems ?? internalSelectedItems;\n\n const selectedItemsChanged = (items: TDataType[]) => {\n if (props.selectedItems === undefined) setInternalSelectedItems(items);\n props.onSelectedItemsChange?.(items);\n };\n\n // SAFETY: React context cannot retain this component's generic parameters. The\n // provider and every consumer are nested in the same DataPage invocation, so the\n // erased object-level context never crosses between differently typed pages.\n const context = {\n ...props,\n selectedItem,\n onSelectionChanged: selectionChanged,\n selectedItems,\n onSelectedItemsChange: selectedItemsChanged,\n } as unknown as IDataPageContext;\n\n return (\n <DataPageContext.Provider value={context}>\n <Page title={props.title} panel={true} style={pageStyle}>\n {props.detailsComponent ? (\n <Allotment className='cratis:h-full' proportionalLayout={false}>\n <Allotment.Pane>\n <DataPageLayout>{props.children}</DataPageLayout>\n </Allotment.Pane>\n {selectedItem && (\n <Allotment.Pane preferredSize='450px'>\n <props.detailsComponent\n item={selectedItem}\n onRefresh={props.onRefresh}\n />\n </Allotment.Pane>\n )}\n </Allotment>\n ) : (\n <DataPageLayout>{props.children}</DataPageLayout>\n )}\n </Page>\n </DataPageContext.Provider>\n );\n};\n\nDataPage.MenuItem = MenuItem;\nDataPage.MenuItems = MenuItems;\nDataPage.Columns = Columns;\n\nexport { DataPage };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;AAwDO,MAAM,QAAQ,GAAG,CAAC,MAAqB,KAAI;AAC9C,IAAA,OAAO,IAAI;AACf;AAuBA,MAAM,YAAY,GAAkB,EAAE,UAAU,EAAE,CAAC,EAAE;AAQrD,MAAM,gBAAgB,GAAkB,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;AAQnF,MAAM,SAAS,GAAkB,EAAE,SAAS,EAAE,OAAO,EAAE;MAS1C,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAkB,KAAI;AACtD,IAAA,MAAM,OAAO,GAAG,kBAAkB,EAAE;AACpC,IAAA,MAAM,UAAU,GACZ,OAAO,CAAC,aAAa,KAAK;AACtB,UAAE,OAAO,CAAC,aAAa,CAAC,MAAM,KAAK;AACnC,UAAE,CAAC,OAAO,CAAC,YAAY;AAE/B,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,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SAAS,EAAA,QAAA,EAClD,KAAK,CAAC,gBAAgB,IACnBC,IAAA,CAAC,SAAS,EAAA,EAAC,SAAS,EAAC,eAAe,EAAC,kBAAkB,EAAE,KAAK,EAAA,QAAA,EAAA,CAC1DD,IAAC,SAAS,CAAC,IAAI,EAAA,EAAA,QAAA,EACXA,GAAA,CAAC,cAAc,cAAE,KAAK,CAAC,QAAQ,EAAA,CAAkB,EAAA,CACpC,EAChB,YAAY,KACTA,GAAA,CAAC,SAAS,CAAC,IAAI,EAAA,EAAC,aAAa,EAAC,OAAO,EAAA,QAAA,EACjCA,GAAA,CAAC,KAAK,CAAC,gBAAgB,EAAA,EACnB,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,KAAK,CAAC,SAAS,EAAA,CAC5B,GACW,CACpB,CAAA,EAAA,CACO,KAEZA,GAAA,CAAC,cAAc,EAAA,EAAA,QAAA,EAAE,KAAK,CAAC,QAAQ,GAAkB,CACpD,EAAA,CACE,EAAA,CACgB;AAEnC;AAEA,QAAQ,CAAC,QAAQ,GAAG,QAAQ;AAC5B,QAAQ,CAAC,SAAS,GAAG,SAAS;AAC9B,QAAQ,CAAC,OAAO,GAAG,OAAO;;"}
1
+ {"version":3,"file":"DataPage.js","sources":["../../../DataPage/DataPage.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { type CSSProperties, type ReactNode, useMemo } from 'react';\nimport { Page } from '../Common/Page';\nimport React from 'react';\nimport { ActionMenubar, type ActionMenuItem } from '../Common/ActionMenubar';\nimport type { ButtonParts } from '../Common/Button';\nimport { type IObservableQueryFor, type IQueryFor, QueryFor } from '@cratis/arc/queries';\nimport { DataTableForObservableQuery } from '../DataTables/DataTableForObservableQuery';\nimport type { DataTableParts } from '../DataTables/DataTableCore';\nimport { DataTableForQuery } from '../DataTables/DataTableForQuery';\nimport type {\n TablePaginatorParts,\n TablePaginatorProps,\n} from '../DataTables/TablePaginator';\nimport type { DataTableFilterMeta } from '../DataTables/DataTableFilterMeta';\nimport type { DataTableSelectionChangeEvent } from '../DataTables/DataTableSelectionChangeEvent';\nimport type { DataTableServerQuery } from '../DataTables/DataTableServerQuery';\nimport { Allotment } from 'allotment';\nimport type { Constructor } from '@cratis/fundamentals';\nimport { DataPageLayout } from './DataPageLayout';\n\n// Allotment ships its layout as a stylesheet rather than inline styles, and a pane only becomes\n// the absolutely positioned, full-height box the split view assumes once that stylesheet is on\n// the page. It used to be pulled in here with a bare `import 'allotment/dist/style.css'`, but a\n// CSS import inside the JS graph is precisely what stops the published ESM from loading in Node\n// (Cratis/Components#118). The rules now ship inside this package's own `./styles` entry point,\n// which the build concatenates from every component stylesheet plus this third-party one — so a\n// consumer still gets a working split view, from the single stylesheet they already import.\n\n/**\n * Props for {@link MenuItem} — a single action in a {@link DataPage}'s\n * action bar.\n */\nexport interface MenuItemProps {\n /** Icon component rendered before the label (e.g. a react-icons icon). */\n icon?: React.ComponentType<{ className?: string }>;\n /** The visible label. */\n label?: string;\n /** Invoked when the item is activated. */\n command?: () => void;\n /** When true, the item is greyed out regardless of selection. */\n disabled?: boolean;\n /**\n * When true, the menu item is disabled while no row is selected in the\n * surrounding {@link DataPage}. Use it for context-sensitive actions like\n * \"Edit\" or \"Delete\" that require a selection.\n */\n disableOnUnselected?: boolean;\n}\n\n/**\n * Declarative menu item for use inside `<DataPage.MenuItems>`. Renders nothing\n * directly; the surrounding {@link MenuItems} component reads its props and\n * forwards them to the action menubar.\n */\nexport const MenuItem = (_props: MenuItemProps) => {\n return null;\n};\n\n/**\n * Props for {@link MenuItems}.\n */\nexport interface MenuItemsProps {\n /** One or more `<DataPage.MenuItem>` elements. */\n children: ReactNode;\n}\n\n/**\n * Props for {@link Columns}.\n */\nexport interface ColumnsProps {\n /** Cratis-owned `<Column>` markers describing each visible column. */\n children: ReactNode;\n}\n\n/**\n * The action bar is an intrinsically sized item in the page's layout column —\n * it takes the height its menubar needs and never gives any of it up, so the\n * table region below it is the only part that has to adapt to the space left.\n */\nconst actionsStyle: CSSProperties = { flexShrink: 0 };\n\n/**\n * The table region takes every pixel the action bar leaves and no more.\n * `minHeight: 0` is the load-bearing half: without it the region's automatic\n * minimum keeps it at content height, the column grows past the page, and the\n * table's paginator ends up below the clipped edge.\n */\nconst tableRegionStyle: CSSProperties = { flexGrow: 1, flexBasis: 0, minHeight: 0 };\n\n/**\n * The floor a `DataPage` falls back to when its ancestors give it no height at\n * all. A page that renders as an empty sliver is indistinguishable from a\n * broken one, so a contract-violating consumer gets a small but usable page\n * instead of nothing.\n */\nconst pageStyle: CSSProperties = { minHeight: '20rem' };\n\n/**\n * Renders an action menubar at the top of a {@link DataPage}, populated from\n * `<DataPage.MenuItem>` children. Each menu item's `disableOnUnselected` flag\n * is automatically honored against the current row selection.\n *\n * Use as `<DataPage.MenuItems>` inside a `<DataPage>`.\n */\nexport const MenuItems = ({ children }: MenuItemsProps) => {\n const context = useDataPageContext();\n const isDisabled =\n context.selectionMode === 'multiple'\n ? context.selectedItems.length === 0\n : !context.selectedItem;\n\n const items = useMemo(() => {\n const menuItems: ActionMenuItem[] = [];\n React.Children.forEach(children, (child) => {\n if (React.isValidElement<MenuItemProps>(child) && child.type === MenuItem) {\n const Icon = child.props.icon;\n menuItems.push({\n label: child.props.label,\n command: child.props.command,\n icon: Icon ? <Icon className='cratis:mr-2' /> : undefined,\n disabled:\n (child.props.disabled ?? false) ||\n (isDisabled && (child.props.disableOnUnselected ?? false)),\n });\n }\n });\n\n return menuItems;\n }, [children, isDisabled]);\n\n return (\n <div\n className='cratis-data-page-actions cratis:px-4 cratis:py-2'\n style={actionsStyle}\n >\n <ActionMenubar\n aria-label={context.actionsAriaLabel ?? 'Actions'}\n model={items}\n className={context.menubarClassName}\n pt={context.menubarPt}\n ptOptions={context.menubarPtOptions}\n unstyled={context.menubarUnstyled}\n />\n </div>\n );\n};\n\n/**\n * Renders the data table at the body of a {@link DataPage}. Automatically\n * selects between {@link DataTableForQuery} (snapshot query) and\n * {@link DataTableForObservableQuery} (real-time observable) based on the\n * `query` type provided to the surrounding `<DataPage>`.\n *\n * Use as `<DataPage.Columns>` inside a `<DataPage>`, with Cratis-owned `<Column>`\n * children defining the table columns.\n */\nexport const Columns = ({ children }: ColumnsProps) => {\n const context = useDataPageContext();\n const isSnapshotQuery = context.query.prototype instanceof QueryFor;\n // SAFETY: The runtime prototype check above narrows a constructor shape that\n // TypeScript cannot discriminate after the generic DataPage context is erased.\n const snapshotQuery = context.query as Constructor<\n IQueryFor<object, object> | IQueryFor<object[], object>\n >;\n const observableQuery = context.query as Constructor<\n IObservableQueryFor<object, object> | IObservableQueryFor<object[], object>\n >;\n\n return (\n <div className='cratis-data-page-table' style={tableRegionStyle}>\n {isSnapshotQuery ? (\n <DataTableForQuery\n {...context}\n query={snapshotQuery}\n selection={context.selectedItem}\n onSelectionChange={context.onSelectionChanged}\n className={context.tableClassName}\n pt={context.tablePt}\n ptOptions={context.tablePtOptions}\n unstyled={context.tableUnstyled}\n >\n {children}\n </DataTableForQuery>\n ) : (\n <DataTableForObservableQuery\n {...context}\n query={observableQuery}\n selection={context.selectedItem}\n onSelectionChange={context.onSelectionChanged}\n className={context.tableClassName}\n pt={context.tablePt}\n ptOptions={context.tablePtOptions}\n unstyled={context.tableUnstyled}\n >\n {children}\n </DataTableForObservableQuery>\n )}\n </div>\n );\n};\n\n/**\n * Props passed to the optional details component rendered on the right pane\n * of a {@link DataPage} when a row is selected.\n *\n * @typeParam TDataType - The type of the selected item.\n */\nexport interface IDetailsComponentProps<TDataType> {\n /** The currently-selected row. */\n item: TDataType;\n\n /**\n * The caller's {@link DataPageProps.onRefresh} callback, forwarded unchanged\n * to the details component. Invoking it does not make DataPage refetch.\n */\n onRefresh?: () => void;\n}\n\ninterface IDataPageContext extends DataPageProps<\n IQueryFor<object, object> | IObservableQueryFor<object, object>,\n object,\n object\n> {\n selectedItem: object | null | undefined;\n onSelectionChanged: (event: DataTableSelectionChangeEvent<object>) => void;\n selectedItems: object[];\n onSelectedItemsChange: (items: object[]) => void;\n}\n\nconst DataPageContext = React.createContext<IDataPageContext | null>(null);\n\nfunction useDataPageContext(): IDataPageContext {\n const context = React.useContext(DataPageContext);\n if (!context) {\n throw new Error('useDataPageContext must be used within a DataPage component');\n }\n return context;\n}\n\n/**\n * Props for {@link DataPage}.\n *\n * @typeParam TQuery - The query class — either a snapshot `IQueryFor` or a real-time `IObservableQueryFor`.\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type, or `object` if the query takes none.\n */\nexport interface DataPageProps<\n TQuery extends\n | IQueryFor<TDataType, TArguments>\n | IQueryFor<TDataType[], TArguments>\n | IObservableQueryFor<TDataType, TArguments>\n | IObservableQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n> {\n /**\n * The title of the page\n */\n title: string;\n\n /**\n * Children to render, for this it means menu items and columns. Use <DataPage.MenuItems> and <DataPage.Columns> for this.\n */\n children: ReactNode;\n\n /**\n * Component to render when the selection changes\n */\n detailsComponent?: React.FC<IDetailsComponentProps<TDataType>>;\n\n /**\n * The type of query to use\n */\n query: Constructor<TQuery>;\n\n /**\n * Optional arguments to pass to the query\n */\n queryArguments?: TArguments;\n\n /**\n * The message to show when there is no data\n */\n emptyMessage: string;\n\n /** Message shown while loading without rows. */\n loadingMessage?: ReactNode;\n /** Message shown when the query fails. */\n failureMessage?: ReactNode;\n /** Message shown when access is denied. */\n unauthorizedMessage?: ReactNode;\n\n /**\n * The key to use for the data\n */\n dataKey?: string | undefined;\n\n /**\n * The current selection.\n */\n selection?: TDataType | undefined | null;\n\n /**\n * Callback for when the selection changes\n */\n onSelectionChange?(event: DataTableSelectionChangeEvent<TDataType>): void;\n\n /**\n * The row selection mode. Defaults to `'single'`. Use `'multiple'` for a page whose actions\n * operate on a set of rows - it adds per-row checkboxes and a select-all header checkbox, and\n * reports through {@link onSelectedItemsChange}.\n */\n selectionMode?: 'single' | 'multiple';\n\n /**\n * The currently selected rows, for `selectionMode='multiple'`. Leave undefined to let the page\n * own the selection.\n */\n selectedItems?: TDataType[];\n\n /**\n * Callback for when a multiple selection changes, with the full selected set.\n */\n onSelectedItemsChange?(items: TDataType[]): void;\n\n /**\n * Fields to use for global filtering\n */\n globalFilterFields?: string[] | undefined;\n\n /** Placeholder for the loaded-page search input. */\n globalSearchPlaceholder?: string;\n\n /** Accessible name for the loaded-page search input. */\n globalSearchAriaLabel?: string;\n\n /**\n * Default filters to use\n */\n defaultFilters?: DataTableFilterMeta;\n\n /**\n * @deprecated Filtering is always applied to the currently loaded page.\n * This compatibility prop no longer toggles behavior and does not change\n * server-reported pagination totals. Retained for source compatibility only.\n */\n clientFiltering?: boolean;\n\n /**\n * Opts the page's table into server mode: the query sorts, filters and searches the complete\n * result before paging, and the table renders the rows as returned. Leave undefined to sort,\n * filter and search the loaded page. See {@link DataTableServerQuery}.\n */\n serverQuery?: DataTableServerQuery<TArguments>;\n\n /** Optional callback forwarded to the details component as `onRefresh`; DataPage does not invoke it or refetch when it is called. */\n onRefresh?(): void;\n\n /**\n * Extra CSS class name forwarded to the inner DataTable root.\n */\n tableClassName?: string;\n\n /** Cratis-owned per-part attributes applied to the inner table. */\n tablePt?: DataTableParts;\n\n /**\n * @deprecated Cratis table parts always merge. Remove this renderer-era option.\n */\n tablePtOptions?: object;\n\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `tablePt` and CSS instead.\n */\n tableUnstyled?: boolean;\n\n /** Shows numbered page buttons in the query table paginator. Defaults to false. */\n pageLinks?: TablePaginatorProps['pageLinks'];\n\n /** Extra CSS class name forwarded to the query table paginator. */\n paginatorClassName?: string;\n\n /** Cratis-owned attributes applied to the query table paginator. */\n paginatorPt?: TablePaginatorParts;\n\n /**\n * @deprecated Cratis paginator parts always merge. Remove this renderer-era option.\n */\n paginatorPtOptions?: object;\n\n /** Accessible paginator labels. Override any value to localize it. */\n paginatorAriaLabels?: TablePaginatorProps['ariaLabels'];\n\n /**\n * Extra CSS class name forwarded to the action menubar root.\n */\n menubarClassName?: string;\n\n /** Cratis-owned part attributes applied to the action menubar's buttons. */\n menubarPt?: ButtonParts;\n\n /**\n * @deprecated Cratis menubar parts always merge. Remove this renderer-era option.\n */\n menubarPtOptions?: object;\n\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `menubarPt` and CSS instead.\n */\n menubarUnstyled?: boolean;\n\n /**\n * Accessible name for the action menubar (toolbar). Override to localize.\n * Defaults to `'Actions'`.\n */\n actionsAriaLabel?: string;\n}\n\n/**\n * A page primitive that combines an action menubar, a query-backed data\n * table, and an optional details pane into one layout. Designed as the\n * default rendering for \"list view\" pages in an Arc app.\n *\n * ## What `TQuery` is\n *\n * `TQuery` is the auto-generated TypeScript class produced by the Arc proxy\n * generator from a C# read model query. Two flavors are accepted and\n * **selected automatically at runtime** based on the class hierarchy:\n *\n * - **`IQueryFor<TDataType, TArguments>`** — a snapshot query. Re-fetched\n * when `queryArguments` change or when the page is mounted. Rendered\n * through {@link DataTableForQuery} internally.\n * - **`IObservableQueryFor<TDataType, TArguments>`** — a real-time\n * subscription. Connects to the backend over WebSocket and re-renders\n * automatically whenever the underlying read model changes server-side.\n * Rendered through {@link DataTableForObservableQuery} internally.\n *\n * You don't pick which inner table to use — `DataPage` inspects the\n * prototype chain (`context.query.prototype instanceof QueryFor`) and\n * mounts the correct one.\n *\n * ## Declarative composition\n *\n * Three children build up the page:\n *\n * - **`<DataPage.MenuItems>`** wraps `<DataPage.MenuItem>` elements that\n * become the action `Menubar` at the top. Each item declares its `icon`,\n * `label`, and `command` (an `onClick` handler). Items can be marked\n * `disableOnUnselected` so they automatically grey out until the user\n * picks a row — useful for Edit / Delete actions that need a target.\n *\n * - **`<DataPage.Columns>`** wraps Cratis-owned `<Column>` markers that\n * describe the visible columns. The columns themselves are\n * Cratis-owned — the documented `ColumnProps` surface is\n * supported here (sorting, filtering, custom body templates, …).\n *\n * - **`detailsComponent`** (optional) is a React component rendered in a\n * right-hand pane via Allotment when a row is selected. It receives the\n * selected item as `item` and the caller's `onRefresh` callback, if\n * supplied. DataPage does not refetch when the details component invokes it.\n *\n * ## Selection lifecycle\n *\n * `DataPage` keeps the current selection in local state and threads it to\n * the inner table, the menubar (`disableOnUnselected` items follow it),\n * and the optional details pane. The `onSelectionChange` prop is invoked\n * after every change if the consumer also needs to react to it.\n *\n * ```tsx\n * <DataPage<AllAuthors, Author, never>\n * title=\"Authors\"\n * query={AllAuthors} // proxy from C#\n * detailsComponent={AuthorDetails}>\n * <DataPage.MenuItems>\n * <DataPage.MenuItem icon={FaPlus} label=\"Add\" command={onAdd} />\n * <DataPage.MenuItem icon={FaPencil} label=\"Edit\" command={onEdit}\n * disableOnUnselected />\n * <DataPage.MenuItem icon={FaTrash} label=\"Delete\" command={onDelete}\n * disableOnUnselected />\n * </DataPage.MenuItems>\n * <DataPage.Columns>\n * <Column field=\"name\" header=\"Name\" sortable />\n * <Column field=\"email\" header=\"Email\" />\n * </DataPage.Columns>\n * </DataPage>\n * ```\n *\n * ## Height — `DataPage` needs a bounded ancestor\n *\n * `DataPage` fills the height it is given and divides it between the action\n * bar and the table region, so the table's paginator always sits at the\n * bottom of the page rather than below its edge. It cannot invent that height:\n * every element from the page root down sizes as a percentage of its parent,\n * so **some ancestor has to have a definite height**.\n *\n * ```tsx\n * // ✅ the router outlet, a sized container, or a flex child with min-height\n * <div style={{ height: '100vh' }}>\n * <DataPage … />\n * </div>\n *\n * // ❌ nothing above resolves to a height — the table grows to its content\n * <div>\n * <DataPage … />\n * </div>\n * ```\n *\n * Without one, the page falls back to a small fixed height so it stays\n * usable instead of collapsing to nothing.\n *\n * ## Styling\n *\n * The inner DataTable and action toolbar each have their own per-slot props:\n * `tablePt` / `tableUnstyled` / `tableClassName` for the table;\n * `paginatorPt` / `paginatorClassName` / `paginatorAriaLabels` for paging;\n * `menubarPt` / `menubarPtOptions` / `menubarUnstyled` / `menubarClassName` for\n * the action toolbar's stable button parts (the action bar is implemented as\n * a button toolbar, so `menubarPt` targets the stable Cratis button parts). See the\n * [pass-through cheat sheet](../../Documentation/Styling/pass-through.md) for\n * the full slot reference.\n *\n * @typeParam TQuery - The query class (proxy generated from a C# read model query).\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type.\n * @param props - {@link DataPageProps}.\n */\nconst DataPage = <\n TQuery extends\n | IQueryFor<TDataType, TArguments>\n | IQueryFor<TDataType[], TArguments>\n | IObservableQueryFor<TDataType, TArguments>\n | IObservableQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n>(\n props: DataPageProps<TQuery, TDataType, TArguments>,\n) => {\n const [internalSelection, setInternalSelection] = React.useState<\n TDataType | null | undefined\n >(props.selection);\n const selectedItem =\n props.selection === undefined ? internalSelection : props.selection;\n\n const selectionChanged = (event: DataTableSelectionChangeEvent<TDataType>) => {\n if (props.selection === undefined) setInternalSelection(event.value);\n props.onSelectionChange?.(event);\n };\n\n const [internalSelectedItems, setInternalSelectedItems] = React.useState<TDataType[]>(\n props.selectedItems ?? [],\n );\n const selectedItems = props.selectedItems ?? internalSelectedItems;\n\n const selectedItemsChanged = (items: TDataType[]) => {\n if (props.selectedItems === undefined) setInternalSelectedItems(items);\n props.onSelectedItemsChange?.(items);\n };\n\n // SAFETY: React context cannot retain this component's generic parameters. The\n // provider and every consumer are nested in the same DataPage invocation, so the\n // erased object-level context never crosses between differently typed pages.\n const context = {\n ...props,\n selectedItem,\n onSelectionChanged: selectionChanged,\n selectedItems,\n onSelectedItemsChange: selectedItemsChanged,\n } as unknown as IDataPageContext;\n\n return (\n <DataPageContext.Provider value={context}>\n <Page title={props.title} panel={true} style={pageStyle}>\n {props.detailsComponent ? (\n <Allotment className='cratis:h-full' proportionalLayout={false}>\n <Allotment.Pane>\n <DataPageLayout>{props.children}</DataPageLayout>\n </Allotment.Pane>\n {selectedItem && (\n <Allotment.Pane preferredSize='450px'>\n <props.detailsComponent\n item={selectedItem}\n onRefresh={props.onRefresh}\n />\n </Allotment.Pane>\n )}\n </Allotment>\n ) : (\n <DataPageLayout>{props.children}</DataPageLayout>\n )}\n </Page>\n </DataPageContext.Provider>\n );\n};\n\nDataPage.MenuItem = MenuItem;\nDataPage.MenuItems = MenuItems;\nDataPage.Columns = Columns;\n\nexport { DataPage };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;AAyDO,MAAM,QAAQ,GAAG,CAAC,MAAqB,KAAI;AAC9C,IAAA,OAAO,IAAI;AACf;AAuBA,MAAM,YAAY,GAAkB,EAAE,UAAU,EAAE,CAAC,EAAE;AAQrD,MAAM,gBAAgB,GAAkB,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;AAQnF,MAAM,SAAS,GAAkB,EAAE,SAAS,EAAE,OAAO,EAAE;MAS1C,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAkB,KAAI;AACtD,IAAA,MAAM,OAAO,GAAG,kBAAkB,EAAE;AACpC,IAAA,MAAM,UAAU,GACZ,OAAO,CAAC,aAAa,KAAK;AACtB,UAAE,OAAO,CAAC,aAAa,CAAC,MAAM,KAAK;AACnC,UAAE,CAAC,OAAO,CAAC,YAAY;AAE/B,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,MAAK;QACvB,MAAM,SAAS,GAAqB,EAAE;QACtC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,KAAI;AACvC,YAAA,IAAI,KAAK,CAAC,cAAc,CAAgB,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;AACvE,gBAAA,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI;gBAC7B,SAAS,CAAC,IAAI,CAAC;AACX,oBAAA,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK;AACxB,oBAAA,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;AAC5B,oBAAA,IAAI,EAAE,IAAI,GAAG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K,CAAC,SAAS,EAAA,CAC5B,GACW,CACpB,CAAA,EAAA,CACO,KAEZA,GAAA,CAAC,cAAc,EAAA,EAAA,QAAA,EAAE,KAAK,CAAC,QAAQ,GAAkB,CACpD,EAAA,CACE,EAAA,CACgB;AAEnC;AAEA,QAAQ,CAAC,QAAQ,GAAG,QAAQ;AAC5B,QAAQ,CAAC,SAAS,GAAG,SAAS;AAC9B,QAAQ,CAAC,OAAO,GAAG,OAAO;;"}
@@ -5,6 +5,7 @@ import { type ReactNode } from 'react';
5
5
  import { type TablePaginatorParts, type TablePaginatorProps } from './TablePaginator.js';
6
6
  import type { DataTableFilterMeta } from './DataTableFilterMeta.js';
7
7
  import type { DataTableSelectionChangeEvent } from './DataTableSelectionChangeEvent.js';
8
+ import type { DataTableServerQuery } from './DataTableServerQuery.js';
8
9
  /**
9
10
  * Props for {@link DataTableForObservableQuery}.
10
11
  *
@@ -77,6 +78,12 @@ export interface DataTableForObservableQueryProps<TQuery extends IObservableQuer
77
78
  * server-reported pagination totals. Retained for source compatibility only.
78
79
  */
79
80
  clientFiltering?: boolean;
81
+ /**
82
+ * Opts into server mode: the query sorts, filters and searches the complete result before
83
+ * paging, and the table renders the rows as returned. Leave undefined to sort, filter and search
84
+ * the loaded page. See {@link DataTableServerQuery}.
85
+ */
86
+ serverQuery?: DataTableServerQuery<TArguments>;
80
87
  /**
81
88
  * Extra CSS class name forwarded to the underlying DataTable root.
82
89
  */