@cratis/components 4.29.0 → 4.30.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 (40) hide show
  1. package/compat-manifest.json +11 -11
  2. package/dist/esm/DataPage/DataPage.d.ts +7 -0
  3. package/dist/esm/DataPage/DataPage.d.ts.map +1 -1
  4. package/dist/esm/DataPage/DataPage.js.map +1 -1
  5. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts +7 -0
  6. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts.map +1 -1
  7. package/dist/esm/DataTables/DataTableForObservableQuery.js +4 -2
  8. package/dist/esm/DataTables/DataTableForObservableQuery.js.map +1 -1
  9. package/dist/esm/DataTables/DataTableForQuery.d.ts +8 -1
  10. package/dist/esm/DataTables/DataTableForQuery.d.ts.map +1 -1
  11. package/dist/esm/DataTables/DataTableForQuery.js +9 -3
  12. package/dist/esm/DataTables/DataTableForQuery.js.map +1 -1
  13. package/dist/esm/DataTables/DataTableServerQuery.d.ts +38 -0
  14. package/dist/esm/DataTables/DataTableServerQuery.d.ts.map +1 -0
  15. package/dist/esm/DataTables/DataTableServerQuery.js +4 -0
  16. package/dist/esm/DataTables/DataTableServerQuery.js.map +1 -0
  17. package/dist/esm/DataTables/DataTableServerQueryState.d.ts +9 -0
  18. package/dist/esm/DataTables/DataTableServerQueryState.d.ts.map +1 -0
  19. package/dist/esm/DataTables/DataTableServerQueryState.js +4 -0
  20. package/dist/esm/DataTables/DataTableServerQueryState.js.map +1 -0
  21. package/dist/esm/DataTables/hasRequiredArguments.d.ts +9 -0
  22. package/dist/esm/DataTables/hasRequiredArguments.d.ts.map +1 -0
  23. package/dist/esm/DataTables/hasRequiredArguments.js +7 -0
  24. package/dist/esm/DataTables/hasRequiredArguments.js.map +1 -0
  25. package/dist/esm/DataTables/index.d.ts +2 -0
  26. package/dist/esm/DataTables/index.d.ts.map +1 -1
  27. package/dist/esm/DataTables/index.js +1 -0
  28. package/dist/esm/DataTables/index.js.map +1 -1
  29. package/dist/esm/DataTables/resolveDataTableStatus.d.ts +2 -7
  30. package/dist/esm/DataTables/resolveDataTableStatus.d.ts.map +1 -1
  31. package/dist/esm/DataTables/resolveDataTableStatus.js.map +1 -1
  32. package/dist/esm/DataTables/useServerQuery.d.ts +32 -0
  33. package/dist/esm/DataTables/useServerQuery.d.ts.map +1 -0
  34. package/dist/esm/DataTables/useServerQuery.js +67 -0
  35. package/dist/esm/DataTables/useServerQuery.js.map +1 -0
  36. package/dist/esm/QueryStatus/resolveQueryStatus.d.ts +10 -3
  37. package/dist/esm/QueryStatus/resolveQueryStatus.d.ts.map +1 -1
  38. package/dist/esm/QueryStatus/resolveQueryStatus.js +2 -0
  39. package/dist/esm/QueryStatus/resolveQueryStatus.js.map +1 -1
  40. package/package.json +2 -2
@@ -68,7 +68,7 @@
68
68
  {
69
69
  "name": "@cratis/components",
70
70
  "role": "core",
71
- "version": "4.29.0",
71
+ "version": "4.30.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.0",
95
+ "version": "4.30.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.0",
108
+ "version": "4.30.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.0",
119
+ "version": "4.30.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.0",
125
+ "@cratis/components": "4.30.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.0",
135
+ "version": "4.30.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.0",
141
+ "@cratis/components": "4.30.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.0",
191
+ "version": "4.30.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.0",
197
+ "@cratis/components": "4.30.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.0",
259
+ "version": "4.30.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.0",
265
+ "@cratis/components": "4.30.0",
266
266
  "primereact": ">=10.9.9 <11",
267
267
  "react": "^19.0.0",
268
268
  "react-dom": "^19.0.0"
@@ -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;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AW,CAAC;IAExB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B;0BA+GG,MAAM,SACA,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,GAChC,SAAS,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC,GAClC,mBAAmB,CAAC,SAAS,EAAE,UAAU,CAAC,GAC1C,mBAAmB,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC,EAClD,SAAS,SAAS,MAAM,EACxB,UAAU,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,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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,C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,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;;"}
@@ -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
  */
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableForObservableQuery.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableForObservableQuery.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,mBAAmB,EAAU,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAEpE,OAAO,EAEH,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAC3B,MAAM,qBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oCAAiC,CAAC;AAGrF;;;;;;GAMG;AACH,MAAM,WAAW,gCAAgC,CAC7C,MAAM,SACA,mBAAmB,CAAC,SAAS,EAAE,UAAU,CAAC,GAC1C,mBAAmB,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC,EAClD,SAAS,SAAS,MAAM,EACxB,UAAU,SAAS,MAAM;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAE3B;;OAEG;IACH,cAAc,CAAC,EAAE,UAAU,CAAC;IAE5B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB,gDAAgD;IAChD,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,0CAA0C;IAC1C,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,2CAA2C;IAC3C,mBAAmB,CAAC,EAAE,SAAS,CAAC;IAEhC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7B;;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C,EAAE,MAAM,CAAC;IAE5B,mDAAmD;IACnD,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAElC;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,6EAA6E;IAC7E,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC3D;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,2BAA2B,GACpC,MAAM,SACA,mBAAmB,CAAC,SAAS,EAAE,UAAU,CAAC,GAC1C,mBAAmB,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC,EAClD,SAAS,SAAS,MAAM,EACxB,UAAU,SAAS,MAAM,SAElB,gCAAgC,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,gCA2IzE,CAAC"}
@@ -5,10 +5,12 @@ import { useRef, useState, useEffect } from 'react';
5
5
  import { DataTableCore } from './DataTableCore.js';
6
6
  import { TablePaginator } from './TablePaginator.js';
7
7
  import { resolveDataTableStatus } from './resolveDataTableStatus.js';
8
+ import { useServerQuery } from './useServerQuery.js';
8
9
 
9
10
  const paging = new Paging(0, 20);
10
11
  const DataTableForObservableQuery = (props) => {
11
- const [result, , setPage] = useObservableQueryWithPaging(props.query, paging, props.queryArguments);
12
+ const server = useServerQuery(props.serverQuery, props.queryArguments, props.defaultFilters);
13
+ const [result, setSorting, setPage] = useObservableQueryWithPaging(props.query, paging, server.queryArguments);
12
14
  const containerRef = useRef(null);
13
15
  const [tableHeight, setTableHeight] = useState(600);
14
16
  const timeoutRef = useRef(undefined);
@@ -56,7 +58,7 @@ const DataTableForObservableQuery = (props) => {
56
58
  border: '1px solid var(--cratis-surface-border)',
57
59
  borderRadius: 'var(--cratis-border-radius)',
58
60
  overflow: 'hidden',
59
- }, children: [jsx("div", { style: { height: `${tableHeight}px`, overflow: 'hidden' }, children: jsx(DataTableCore, { data: rows, dataKey: props.dataKey, emptyMessage: props.emptyMessage, status: status, loadingMessage: props.loadingMessage, failureMessage: props.failureMessage, unauthorizedMessage: props.unauthorizedMessage, selectionMode: props.selectionMode ?? 'single', selection: props.selection, onSelectionChange: props.onSelectionChange, selectedItems: props.selectedItems, onSelectedItemsChange: props.onSelectedItemsChange, globalFilterFields: props.globalFilterFields, globalSearchPlaceholder: props.globalSearchPlaceholder, globalSearchAriaLabel: props.globalSearchAriaLabel, defaultFilters: props.defaultFilters, scrollable: true, scrollHeight: '100%', className: props.className, style: { minWidth: '100%' }, pt: props.pt, ptOptions: props.ptOptions, unstyled: props.unstyled, children: props.children }) }), showPaginator && (jsx("div", { style: {
61
+ }, children: [jsx("div", { style: { height: `${tableHeight}px`, overflow: 'hidden' }, children: jsx(DataTableCore, { data: rows, dataKey: props.dataKey, emptyMessage: props.emptyMessage, status: status, loadingMessage: props.loadingMessage, failureMessage: props.failureMessage, unauthorizedMessage: props.unauthorizedMessage, selectionMode: props.selectionMode ?? 'single', selection: props.selection, onSelectionChange: props.onSelectionChange, selectedItems: props.selectedItems, onSelectedItemsChange: props.onSelectedItemsChange, globalFilterFields: props.globalFilterFields, globalSearchPlaceholder: props.globalSearchPlaceholder, globalSearchAriaLabel: props.globalSearchAriaLabel, defaultFilters: props.defaultFilters, ...server.tableProps({ setSorting, setPage }), scrollable: true, scrollHeight: '100%', className: props.className, style: { minWidth: '100%' }, pt: props.pt, ptOptions: props.ptOptions, unstyled: props.unstyled, children: props.children }) }), showPaginator && (jsx("div", { style: {
60
62
  borderTop: '1px solid var(--cratis-surface-border)',
61
63
  flexShrink: 0,
62
64
  }, children: jsx(TablePaginator, { page: result.paging.page, pageCount: pageCount, onPageChange: setPage, totalItems: totalItems, pageSize: paging.pageSize, pageLinks: props.pageLinks, className: props.paginatorClassName, ariaLabels: props.paginatorAriaLabels, pt: props.paginatorPt, ptOptions: props.paginatorPtOptions }) }))] }));
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableForObservableQuery.js","sources":["../../../DataTables/DataTableForObservableQuery.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 { DataTableParts } from './DataTableCore';\nimport type { Constructor } from '@cratis/fundamentals';\nimport { type IObservableQueryFor, Paging } from '@cratis/arc/queries';\nimport { useObservableQueryWithPaging } from '@cratis/arc.react/queries';\nimport { type ReactNode, useState, useRef, useEffect } from 'react';\nimport { DataTableCore } from './DataTableCore';\nimport {\n TablePaginator,\n type TablePaginatorParts,\n type TablePaginatorProps,\n} from './TablePaginator';\nimport type { DataTableFilterMeta } from './DataTableFilterMeta';\nimport type { DataTableSelectionChangeEvent } from './DataTableSelectionChangeEvent';\nimport { resolveDataTableStatus } from './resolveDataTableStatus';\n\n/**\n * Props for {@link DataTableForObservableQuery}.\n *\n * @typeParam TQuery - The query class implementing `IObservableQueryFor`.\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type.\n */\nexport interface DataTableForObservableQueryProps<\n TQuery extends\n | IObservableQueryFor<TDataType, TArguments>\n | IObservableQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n> {\n /**\n * Children to render — `<Column>` elements describing the visible columns.\n */\n children?: ReactNode;\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'`.\n */\n selectionMode?: 'single' | 'multiple';\n\n /**\n * The currently selected rows, for `selectionMode='multiple'`.\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 * Extra CSS class name forwarded to the underlying DataTable root.\n */\n className?: string;\n\n /** Cratis-owned per-part attributes applied to the underlying table. */\n pt?: DataTableParts;\n\n /**\n * @deprecated Cratis parts always merge. Remove this renderer-era option.\n */\n ptOptions?: object;\n\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `pt` and CSS instead.\n */\n unstyled?: boolean;\n\n /** Shows numbered page buttons in the paginator. Defaults to false. */\n pageLinks?: TablePaginatorProps['pageLinks'];\n\n /** Extra CSS class name forwarded to the paginator. */\n paginatorClassName?: string;\n\n /** Cratis-owned attributes for paginator parts. */\n paginatorPt?: TablePaginatorParts;\n\n /**\n * @deprecated Cratis paginator parts always merge. Remove this renderer-era option.\n */\n paginatorPtOptions?: object;\n\n /** Accessible names for the paginator controls. Override any to localize. */\n paginatorAriaLabels?: TablePaginatorProps['ariaLabels'];\n}\n\nconst paging = new Paging(0, 20);\n\n/**\n * A paged data table bound to a real-time Cratis Arc observable query\n * (`IObservableQueryFor<TDataType, TArguments>`). Subscribes via\n * `useObservableQueryWithPaging`, so the table re-renders automatically as the\n * underlying read model changes server-side. Rows render through the semantic Cratis-owned\n * {@link DataTableCore} inside an internally-scrolling region that resizes to\n * fill its container.\n *\n * ## Children\n *\n * Children are Cratis `<Column>` elements describing the visible columns.\n *\n * ```tsx\n * import { DataTableForObservableQuery, Column } from '@cratis/components/DataTables';\n * import { AllTasks } from './AllTasks'; // observable proxy from C#\n *\n * <DataTableForObservableQuery query={AllTasks} emptyMessage=\"No tasks\">\n * <Column field=\"title\" header=\"Title\" sortable />\n * <Column field=\"assignee\" header=\"Assignee\" />\n * </DataTableForObservableQuery>\n * ```\n *\n * Use {@link DataTableForQuery} for one-shot snapshot queries. Use\n * {@link DataPage} for a higher-level layout that combines this table with\n * an action menubar, selection, and a details pane.\n *\n * @typeParam TQuery - The query class (proxy generated from C# `IObservableQueryFor`).\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type.\n * @param props - {@link DataTableForObservableQueryProps}.\n */\nexport const DataTableForObservableQuery = <\n TQuery extends\n | IObservableQueryFor<TDataType, TArguments>\n | IObservableQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n>(\n props: DataTableForObservableQueryProps<TQuery, TDataType, TArguments>,\n) => {\n // Type arguments are supplied explicitly, and the constructor is erased on the way in\n // (Cratis/Components#135). Two separate defects in `@cratis/arc.react` make the plain call\n // fail to type-check:\n //\n // 1. `useObservableQueryWithPaging<TDataType, TQuery extends IObservableQueryFor<TDataType>, …>`\n // gives `TDataType` no inference site — it appears only inside `TQuery`'s constraint — so it\n // silently falls back to `unknown` and `result` comes back as `QueryResultWithState<unknown>`.\n // 2. `ObservableQuerySubscription<T>` carries a `private _connection`, which makes it nominally\n // typed. `@cratis/arc.react` pins `@cratis/arc` to an exact version, so any consumer whose own\n // `@cratis/arc` differs by even a patch gets a second nested copy — two declarations of that\n // class, and TS2345 \"types have separate declarations of a private property\". Our peer range\n // allows multiple Arc versions, so we cannot assume a consumer's tree is deduped.\n //\n // Erasing the constructor type sidesteps the nominal comparison, and naming `TDataType`\n // explicitly recovers the row type this component is generic over — strictly better than the\n // `unknown` the inference would otherwise produce. Remove both once Arc returns an interface\n // from `subscribe()` and makes `TDataType` inferable.\n const [result, , setPage] = useObservableQueryWithPaging<\n TDataType,\n never,\n TArguments\n >(props.query as never, paging, props.queryArguments);\n const containerRef = useRef<HTMLDivElement>(null);\n const [tableHeight, setTableHeight] = useState<number>(600);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const totalItems = result.paging.totalItems;\n const pageCount = result.paging.totalPages;\n const showPaginator = totalItems > 0 && pageCount > 1;\n\n // SAFETY: Arc observable collection queries are row-typed while runtime data is the current row array.\n const rows = result.data as unknown as TDataType[];\n const status = resolveDataTableStatus(result);\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n const resizeObserver = new ResizeObserver((entries) => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n timeoutRef.current = setTimeout(() => {\n for (const entry of entries) {\n const containerHeight = entry.contentRect.height;\n if (containerHeight > 0) {\n const paginatorHeight = showPaginator ? 56 : 0;\n const calculatedHeight = containerHeight - paginatorHeight - 2;\n const newHeight = Math.max(calculatedHeight, 200);\n\n setTableHeight((prevHeight) => {\n if (Math.abs(newHeight - prevHeight) > 5) {\n return newHeight;\n }\n return prevHeight;\n });\n }\n }\n }, 10);\n });\n\n resizeObserver.observe(containerRef.current);\n\n return () => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n resizeObserver.disconnect();\n };\n }, [showPaginator]);\n\n return (\n <div\n ref={containerRef}\n style={{\n display: 'flex',\n flexDirection: 'column',\n height: '100%',\n border: '1px solid var(--cratis-surface-border)',\n borderRadius: 'var(--cratis-border-radius)',\n overflow: 'hidden',\n }}\n >\n <div style={{ height: `${tableHeight}px`, overflow: 'hidden' }}>\n <DataTableCore<TDataType>\n data={rows}\n dataKey={props.dataKey}\n emptyMessage={props.emptyMessage}\n status={status}\n loadingMessage={props.loadingMessage}\n failureMessage={props.failureMessage}\n unauthorizedMessage={props.unauthorizedMessage}\n selectionMode={props.selectionMode ?? 'single'}\n selection={props.selection}\n onSelectionChange={props.onSelectionChange}\n selectedItems={props.selectedItems}\n onSelectedItemsChange={props.onSelectedItemsChange}\n globalFilterFields={props.globalFilterFields}\n globalSearchPlaceholder={props.globalSearchPlaceholder}\n globalSearchAriaLabel={props.globalSearchAriaLabel}\n defaultFilters={props.defaultFilters}\n scrollable\n scrollHeight='100%'\n className={props.className}\n style={{ minWidth: '100%' }}\n pt={props.pt}\n ptOptions={props.ptOptions}\n unstyled={props.unstyled}\n >\n {props.children}\n </DataTableCore>\n </div>\n\n {showPaginator && (\n <div\n style={{\n borderTop: '1px solid var(--cratis-surface-border)',\n flexShrink: 0,\n }}\n >\n <TablePaginator\n page={result.paging.page}\n pageCount={pageCount}\n onPageChange={setPage}\n totalItems={totalItems}\n pageSize={paging.pageSize}\n pageLinks={props.pageLinks}\n className={props.paginatorClassName}\n ariaLabels={props.paginatorAriaLabels}\n pt={props.paginatorPt}\n ptOptions={props.paginatorPtOptions}\n />\n </div>\n )}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AAoJA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC;AAiCzB,MAAM,2BAA2B,GAAG,CAOvC,KAAsE,KACtE;IAkBA,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,4BAA4B,CAItD,KAAK,CAAC,KAAc,EAAE,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC;AACrD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC;IACjD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAS,GAAG,CAAC;AAC3D,IAAA,MAAM,UAAU,GAAG,MAAM,CAA4C,SAAS,CAAC;AAC/E,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU;AAC3C,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU;IAC1C,MAAM,aAAa,GAAG,UAAU,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC;AAGrD,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,IA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Z,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ,YAEvB,KAAK,CAAC,QAAQ,EAAA,CACH,GACd,EAEL,aAAa,KACVA,GAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAE;AACH,oBAAA,SAAS,EAAE,wCAAwC;AACnD,oBAAA,UAAU,EAAE,CAAC;AAChB,iBAAA,EAAA,QAAA,EAEDA,GAAA,CAAC,cAAc,EAAA,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EACxB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,OAAO,EACrB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,SAAS,EAAE,KAAK,CAAC,kBAAkB,EACnC,UAAU,EAAE,KAAK,CAAC,mBAAmB,EACrC,EAAE,EAAE,KAAK,CAAC,WAAW,EACrB,SAAS,EAAE,KAAK,CAAC,kBAAkB,EAAA,CACrC,EAAA,CACA,CACT,CAAA,EAAA,CACC;AAEd;;"}
1
+ {"version":3,"file":"DataTableForObservableQuery.js","sources":["../../../DataTables/DataTableForObservableQuery.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 { DataTableParts } from './DataTableCore';\nimport type { Constructor } from '@cratis/fundamentals';\nimport { type IObservableQueryFor, Paging } from '@cratis/arc/queries';\nimport { useObservableQueryWithPaging } from '@cratis/arc.react/queries';\nimport { type ReactNode, useState, useRef, useEffect } from 'react';\nimport { DataTableCore } from './DataTableCore';\nimport {\n TablePaginator,\n type TablePaginatorParts,\n type TablePaginatorProps,\n} from './TablePaginator';\nimport type { DataTableFilterMeta } from './DataTableFilterMeta';\nimport type { DataTableSelectionChangeEvent } from './DataTableSelectionChangeEvent';\nimport { resolveDataTableStatus } from './resolveDataTableStatus';\nimport type { DataTableServerQuery } from './DataTableServerQuery';\nimport { useServerQuery } from './useServerQuery';\n\n/**\n * Props for {@link DataTableForObservableQuery}.\n *\n * @typeParam TQuery - The query class implementing `IObservableQueryFor`.\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type.\n */\nexport interface DataTableForObservableQueryProps<\n TQuery extends\n | IObservableQueryFor<TDataType, TArguments>\n | IObservableQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n> {\n /**\n * Children to render — `<Column>` elements describing the visible columns.\n */\n children?: ReactNode;\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'`.\n */\n selectionMode?: 'single' | 'multiple';\n\n /**\n * The currently selected rows, for `selectionMode='multiple'`.\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 into server mode: the query sorts, filters and searches the complete result before\n * paging, and the table renders the rows as returned. Leave undefined to sort, filter and search\n * the loaded page. See {@link DataTableServerQuery}.\n */\n serverQuery?: DataTableServerQuery<TArguments>;\n\n /**\n * Extra CSS class name forwarded to the underlying DataTable root.\n */\n className?: string;\n\n /** Cratis-owned per-part attributes applied to the underlying table. */\n pt?: DataTableParts;\n\n /**\n * @deprecated Cratis parts always merge. Remove this renderer-era option.\n */\n ptOptions?: object;\n\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `pt` and CSS instead.\n */\n unstyled?: boolean;\n\n /** Shows numbered page buttons in the paginator. Defaults to false. */\n pageLinks?: TablePaginatorProps['pageLinks'];\n\n /** Extra CSS class name forwarded to the paginator. */\n paginatorClassName?: string;\n\n /** Cratis-owned attributes for paginator parts. */\n paginatorPt?: TablePaginatorParts;\n\n /**\n * @deprecated Cratis paginator parts always merge. Remove this renderer-era option.\n */\n paginatorPtOptions?: object;\n\n /** Accessible names for the paginator controls. Override any to localize. */\n paginatorAriaLabels?: TablePaginatorProps['ariaLabels'];\n}\n\nconst paging = new Paging(0, 20);\n\n/**\n * A paged data table bound to a real-time Cratis Arc observable query\n * (`IObservableQueryFor<TDataType, TArguments>`). Subscribes via\n * `useObservableQueryWithPaging`, so the table re-renders automatically as the\n * underlying read model changes server-side. Rows render through the semantic Cratis-owned\n * {@link DataTableCore} inside an internally-scrolling region that resizes to\n * fill its container.\n *\n * ## Children\n *\n * Children are Cratis `<Column>` elements describing the visible columns.\n *\n * ```tsx\n * import { DataTableForObservableQuery, Column } from '@cratis/components/DataTables';\n * import { AllTasks } from './AllTasks'; // observable proxy from C#\n *\n * <DataTableForObservableQuery query={AllTasks} emptyMessage=\"No tasks\">\n * <Column field=\"title\" header=\"Title\" sortable />\n * <Column field=\"assignee\" header=\"Assignee\" />\n * </DataTableForObservableQuery>\n * ```\n *\n * Use {@link DataTableForQuery} for one-shot snapshot queries. Use\n * {@link DataPage} for a higher-level layout that combines this table with\n * an action menubar, selection, and a details pane.\n *\n * @typeParam TQuery - The query class (proxy generated from C# `IObservableQueryFor`).\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type.\n * @param props - {@link DataTableForObservableQueryProps}.\n */\nexport const DataTableForObservableQuery = <\n TQuery extends\n | IObservableQueryFor<TDataType, TArguments>\n | IObservableQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n>(\n props: DataTableForObservableQueryProps<TQuery, TDataType, TArguments>,\n) => {\n // Type arguments are supplied explicitly, and the constructor is erased on the way in\n // (Cratis/Components#135). Two separate defects in `@cratis/arc.react` make the plain call\n // fail to type-check:\n //\n // 1. `useObservableQueryWithPaging<TDataType, TQuery extends IObservableQueryFor<TDataType>, …>`\n // gives `TDataType` no inference site — it appears only inside `TQuery`'s constraint — so it\n // silently falls back to `unknown` and `result` comes back as `QueryResultWithState<unknown>`.\n // 2. `ObservableQuerySubscription<T>` carries a `private _connection`, which makes it nominally\n // typed. `@cratis/arc.react` pins `@cratis/arc` to an exact version, so any consumer whose own\n // `@cratis/arc` differs by even a patch gets a second nested copy — two declarations of that\n // class, and TS2345 \"types have separate declarations of a private property\". Our peer range\n // allows multiple Arc versions, so we cannot assume a consumer's tree is deduped.\n //\n // Erasing the constructor type sidesteps the nominal comparison, and naming `TDataType`\n // explicitly recovers the row type this component is generic over — strictly better than the\n // `unknown` the inference would otherwise produce. Remove both once Arc returns an interface\n // from `subscribe()` and makes `TDataType` inferable.\n const server = useServerQuery(props.serverQuery, props.queryArguments, props.defaultFilters);\n const [result, setSorting, setPage] = useObservableQueryWithPaging<\n TDataType,\n never,\n TArguments\n >(props.query as never, paging, server.queryArguments);\n const containerRef = useRef<HTMLDivElement>(null);\n const [tableHeight, setTableHeight] = useState<number>(600);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const totalItems = result.paging.totalItems;\n const pageCount = result.paging.totalPages;\n const showPaginator = totalItems > 0 && pageCount > 1;\n\n // SAFETY: Arc observable collection queries are row-typed while runtime data is the current row array.\n const rows = result.data as unknown as TDataType[];\n const status = resolveDataTableStatus(result);\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n const resizeObserver = new ResizeObserver((entries) => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n timeoutRef.current = setTimeout(() => {\n for (const entry of entries) {\n const containerHeight = entry.contentRect.height;\n if (containerHeight > 0) {\n const paginatorHeight = showPaginator ? 56 : 0;\n const calculatedHeight = containerHeight - paginatorHeight - 2;\n const newHeight = Math.max(calculatedHeight, 200);\n\n setTableHeight((prevHeight) => {\n if (Math.abs(newHeight - prevHeight) > 5) {\n return newHeight;\n }\n return prevHeight;\n });\n }\n }\n }, 10);\n });\n\n resizeObserver.observe(containerRef.current);\n\n return () => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n resizeObserver.disconnect();\n };\n }, [showPaginator]);\n\n return (\n <div\n ref={containerRef}\n style={{\n display: 'flex',\n flexDirection: 'column',\n height: '100%',\n border: '1px solid var(--cratis-surface-border)',\n borderRadius: 'var(--cratis-border-radius)',\n overflow: 'hidden',\n }}\n >\n <div style={{ height: `${tableHeight}px`, overflow: 'hidden' }}>\n <DataTableCore<TDataType>\n data={rows}\n dataKey={props.dataKey}\n emptyMessage={props.emptyMessage}\n status={status}\n loadingMessage={props.loadingMessage}\n failureMessage={props.failureMessage}\n unauthorizedMessage={props.unauthorizedMessage}\n selectionMode={props.selectionMode ?? 'single'}\n selection={props.selection}\n onSelectionChange={props.onSelectionChange}\n selectedItems={props.selectedItems}\n onSelectedItemsChange={props.onSelectedItemsChange}\n globalFilterFields={props.globalFilterFields}\n globalSearchPlaceholder={props.globalSearchPlaceholder}\n globalSearchAriaLabel={props.globalSearchAriaLabel}\n defaultFilters={props.defaultFilters}\n {...server.tableProps({ setSorting, setPage })}\n scrollable\n scrollHeight='100%'\n className={props.className}\n style={{ minWidth: '100%' }}\n pt={props.pt}\n ptOptions={props.ptOptions}\n unstyled={props.unstyled}\n >\n {props.children}\n </DataTableCore>\n </div>\n\n {showPaginator && (\n <div\n style={{\n borderTop: '1px solid var(--cratis-surface-border)',\n flexShrink: 0,\n }}\n >\n <TablePaginator\n page={result.paging.page}\n pageCount={pageCount}\n onPageChange={setPage}\n totalItems={totalItems}\n pageSize={paging.pageSize}\n pageLinks={props.pageLinks}\n className={props.paginatorClassName}\n ariaLabels={props.paginatorAriaLabels}\n pt={props.paginatorPt}\n ptOptions={props.paginatorPtOptions}\n />\n </div>\n )}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;AA6JA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC;AAiCzB,MAAM,2BAA2B,GAAG,CAOvC,KAAsE,KACtE;AAkBA,IAAA,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC;IAC5F,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,GAAG,4BAA4B,CAIhE,KAAK,CAAC,KAAc,EAAE,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;AACtD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC;IACjD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAS,GAAG,CAAC;AAC3D,IAAA,MAAM,UAAU,GAAG,MAAM,CAA4C,SAAS,CAAC;AAC/E,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU;AAC3C,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU;IAC1C,MAAM,aAAa,GAAG,UAAU,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC;AAGrD,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,IAA8B;AAClD,IAAA,MAAM,MAAM,GAAG,sBAAsB,CAAC,MA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,EAAE,KAAK,CAAC,SAAS,EAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ,YAEvB,KAAK,CAAC,QAAQ,EAAA,CACH,GACd,EAEL,aAAa,KACVA,GAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAE;AACH,oBAAA,SAAS,EAAE,wCAAwC;AACnD,oBAAA,UAAU,EAAE,CAAC;AAChB,iBAAA,EAAA,QAAA,EAEDA,GAAA,CAAC,cAAc,EAAA,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EACxB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,OAAO,EACrB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,SAAS,EAAE,KAAK,CAAC,kBAAkB,EACnC,UAAU,EAAE,KAAK,CAAC,mBAAmB,EACrC,EAAE,EAAE,KAAK,CAAC,WAAW,EACrB,SAAS,EAAE,KAAK,CAAC,kBAAkB,EAAA,CACrC,EAAA,CACA,CACT,CAAA,EAAA,CACC;AAEd;;"}
@@ -1,10 +1,11 @@
1
1
  import type { DataTableParts } from './DataTableCore.js';
2
2
  import type { Constructor } from '@cratis/fundamentals';
3
3
  import { type IQueryFor } from '@cratis/arc/queries';
4
- import type { ReactNode } from 'react';
4
+ 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 DataTableForQuery}.
10
11
  *
@@ -77,6 +78,12 @@ export interface DataTableForQueryProps<TQuery extends IQueryFor<TDataType, TArg
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
  */
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableForQuery.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableForQuery.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,SAAS,EAAU,MAAM,qBAAqB,CAAC;AAE7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAEH,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAC3B,MAAM,qBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oCAAiC,CAAC;AAGrF;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB,CACnC,MAAM,SAAS,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,SAAS,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC,EACpF,SAAS,SAAS,MAAM,EACxB,UAAU,SAAS,MAAM;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAE3B;;OAEG;IACH,cAAc,CAAC,EAAE,UAAU,CAAC;IAE5B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB,gDAAgD;IAChD,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,0CAA0C;IAC1C,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,2CAA2C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AEnB,uEAAuE;IACvE,SAAS,CAAC,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;IAE7C,uDAAuD;IACvD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,mDAAmD;IACnD,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAElC;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,6EAA6E;IAC7E,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC3D;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,iBAAiB,GAC1B,MAAM,SAAS,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,SAAS,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC,EACpF,SAAS,SAAS,MAAM,EACxB,UAAU,SAAS,MAAM,SAElB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,gCA0F/D,CAAC"}
@@ -1,17 +1,23 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { Paging } from '@cratis/arc/queries';
3
3
  import { useQueryWithPaging } from '@cratis/arc.react/queries';
4
+ import { useMemo } from 'react';
4
5
  import { DataTableCore } from './DataTableCore.js';
5
6
  import { TablePaginator } from './TablePaginator.js';
6
7
  import { resolveDataTableStatus } from './resolveDataTableStatus.js';
8
+ import { useServerQuery } from './useServerQuery.js';
9
+ import { hasRequiredArguments } from './hasRequiredArguments.js';
7
10
 
8
11
  const paging = new Paging(0, 20);
9
12
  const DataTableForQuery = (props) => {
10
- const [result, , , setPage] = useQueryWithPaging(props.query, paging, props.queryArguments);
13
+ const server = useServerQuery(props.serverQuery, props.queryArguments, props.defaultFilters);
14
+ const [result, , setSorting, setPage] = useQueryWithPaging(props.query, paging, server.queryArguments);
11
15
  const totalItems = result.paging.totalItems;
12
16
  const pageCount = result.paging.totalPages;
13
17
  const rows = result.data;
14
- const status = resolveDataTableStatus(result);
18
+ const requiredArguments = useMemo(() => new props.query().requiredRequestParameters, [props.query]);
19
+ const isWaitingForArguments = !hasRequiredArguments(requiredArguments, server.queryArguments);
20
+ const status = resolveDataTableStatus(isWaitingForArguments ? { ...result, isSuccess: true } : result);
15
21
  return (jsxs("div", { style: {
16
22
  display: 'flex',
17
23
  flexDirection: 'column',
@@ -19,7 +25,7 @@ const DataTableForQuery = (props) => {
19
25
  border: '1px solid var(--cratis-surface-border)',
20
26
  borderRadius: 'var(--cratis-border-radius)',
21
27
  overflow: 'hidden',
22
- }, children: [jsx("div", { style: { flex: 1, minHeight: 0, overflow: 'hidden' }, children: jsx(DataTableCore, { data: rows, dataKey: props.dataKey, emptyMessage: props.emptyMessage, status: status, loadingMessage: props.loadingMessage, failureMessage: props.failureMessage, unauthorizedMessage: props.unauthorizedMessage, selectionMode: props.selectionMode ?? 'single', selection: props.selection, onSelectionChange: props.onSelectionChange, selectedItems: props.selectedItems, onSelectedItemsChange: props.onSelectedItemsChange, globalFilterFields: props.globalFilterFields, globalSearchPlaceholder: props.globalSearchPlaceholder, globalSearchAriaLabel: props.globalSearchAriaLabel, defaultFilters: props.defaultFilters, scrollable: true, scrollHeight: '100%', className: props.className, style: { minWidth: '100%' }, pt: props.pt, ptOptions: props.ptOptions, unstyled: props.unstyled, children: props.children }) }), totalItems > 0 && pageCount > 1 && (jsx("div", { style: {
28
+ }, children: [jsx("div", { style: { flex: 1, minHeight: 0, overflow: 'hidden' }, children: jsx(DataTableCore, { data: rows, dataKey: props.dataKey, emptyMessage: props.emptyMessage, status: status, loadingMessage: props.loadingMessage, failureMessage: props.failureMessage, unauthorizedMessage: props.unauthorizedMessage, selectionMode: props.selectionMode ?? 'single', selection: props.selection, onSelectionChange: props.onSelectionChange, selectedItems: props.selectedItems, onSelectedItemsChange: props.onSelectedItemsChange, globalFilterFields: props.globalFilterFields, globalSearchPlaceholder: props.globalSearchPlaceholder, globalSearchAriaLabel: props.globalSearchAriaLabel, defaultFilters: props.defaultFilters, ...server.tableProps({ setSorting, setPage }), scrollable: true, scrollHeight: '100%', className: props.className, style: { minWidth: '100%' }, pt: props.pt, ptOptions: props.ptOptions, unstyled: props.unstyled, children: props.children }) }), totalItems > 0 && pageCount > 1 && (jsx("div", { style: {
23
29
  borderTop: '1px solid var(--cratis-surface-border)',
24
30
  flexShrink: 0,
25
31
  }, children: jsx(TablePaginator, { page: result.paging.page, pageCount: pageCount, onPageChange: setPage, totalItems: totalItems, pageSize: paging.pageSize, pageLinks: props.pageLinks, className: props.paginatorClassName, ariaLabels: props.paginatorAriaLabels, pt: props.paginatorPt, ptOptions: props.paginatorPtOptions }) }))] }));
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableForQuery.js","sources":["../../../DataTables/DataTableForQuery.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 { DataTableParts } from './DataTableCore';\nimport type { Constructor } from '@cratis/fundamentals';\nimport { type IQueryFor, Paging } from '@cratis/arc/queries';\nimport { useQueryWithPaging } from '@cratis/arc.react/queries';\nimport type { ReactNode } from 'react';\nimport { DataTableCore } from './DataTableCore';\nimport {\n TablePaginator,\n type TablePaginatorParts,\n type TablePaginatorProps,\n} from './TablePaginator';\nimport type { DataTableFilterMeta } from './DataTableFilterMeta';\nimport type { DataTableSelectionChangeEvent } from './DataTableSelectionChangeEvent';\nimport { resolveDataTableStatus } from './resolveDataTableStatus';\n\n/**\n * Props for {@link DataTableForQuery}.\n *\n * @typeParam TQuery - The query class implementing `IQueryFor`.\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type, or `object` if it takes none.\n */\nexport interface DataTableForQueryProps<\n TQuery extends IQueryFor<TDataType, TArguments> | IQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n> {\n /**\n * Children to render — `<Column>` elements describing the visible columns.\n */\n children?: ReactNode;\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'`.\n */\n selectionMode?: 'single' | 'multiple';\n\n /**\n * The currently selected rows, for `selectionMode='multiple'`.\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 * Extra CSS class name forwarded to the underlying DataTable root.\n */\n className?: string;\n\n /** Cratis-owned per-part attributes applied to the underlying table. */\n pt?: DataTableParts;\n\n /**\n * @deprecated Cratis parts always merge. Remove this renderer-era option.\n */\n ptOptions?: object;\n\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `pt` and CSS instead.\n */\n unstyled?: boolean;\n\n /** Shows numbered page buttons in the paginator. Defaults to false. */\n pageLinks?: TablePaginatorProps['pageLinks'];\n\n /** Extra CSS class name forwarded to the paginator. */\n paginatorClassName?: string;\n\n /** Cratis-owned attributes for paginator parts. */\n paginatorPt?: TablePaginatorParts;\n\n /**\n * @deprecated Cratis paginator parts always merge. Remove this renderer-era option.\n */\n paginatorPtOptions?: object;\n\n /** Accessible names for the paginator controls. Override any to localize. */\n paginatorAriaLabels?: TablePaginatorProps['ariaLabels'];\n}\n\nconst paging = new Paging(0, 20);\n\n/**\n * A paged data table bound to a snapshot Cratis Arc query\n * (`IQueryFor<TDataType, TArguments>`). Subscribes via\n * `useQueryWithPaging` from `@cratis/arc.react/queries`, renders the result\n * page through the semantic Cratis-owned {@link DataTableCore}, and shows a\n * {@link TablePaginator} when the result set exceeds one page.\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's static query method. `dotnet build`\n * writes a `.ts` file per query with the right return type and a `use()`\n * hook; importing the class is all the connection-to-the-backend you need.\n *\n * ## Children\n *\n * Children are Cratis `<Column>` elements describing the visible columns —\n * `field`, `header`, custom `body` templates, and `sortable`.\n *\n * ```tsx\n * import { DataTableForQuery, Column } from '@cratis/components/DataTables';\n * import { AllAuthors } from './AllAuthors'; // proxy from C#\n *\n * <DataTableForQuery query={AllAuthors} emptyMessage=\"No authors\">\n * <Column field=\"name\" header=\"Name\" sortable />\n * <Column field=\"email\" header=\"Email\" />\n * </DataTableForQuery>\n * ```\n *\n * Use {@link DataTableForObservableQuery} for queries that should update in\n * real time as the underlying read model changes server-side. Use\n * {@link DataPage} for a higher-level layout that combines this table with\n * an action menubar, selection, and a details pane.\n *\n * ## Styling\n *\n * Forward `pt` / `ptOptions` / `unstyled` / `className` to the underlying\n * DataTable. See [pass-through cheat sheet](../../Documentation/Styling/pass-through.md).\n *\n * @typeParam TQuery - The query class (proxy generated from C# `IQueryFor`).\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type.\n * @param props - {@link DataTableForQueryProps}.\n */\nexport const DataTableForQuery = <\n TQuery extends IQueryFor<TDataType, TArguments> | IQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n>(\n props: DataTableForQueryProps<TQuery, TDataType, TArguments>,\n) => {\n const [result, , , setPage] = useQueryWithPaging(\n props.query,\n paging,\n props.queryArguments,\n );\n const totalItems = result.paging.totalItems;\n const pageCount = result.paging.totalPages;\n\n // SAFETY: Arc collection queries are row-typed while their runtime data is the current row array.\n const rows = result.data as unknown as TDataType[];\n const status = resolveDataTableStatus(result);\n\n return (\n <div\n style={{\n display: 'flex',\n flexDirection: 'column',\n height: '100%',\n border: '1px solid var(--cratis-surface-border)',\n borderRadius: 'var(--cratis-border-radius)',\n overflow: 'hidden',\n }}\n >\n {/* The scroll container must be `DataTableCore`'s own bounded container rather than\n this wrapper. `.cratis-datatable__container` sets `overflow-x: auto`, and CSS\n computes the matching `overflow-y: visible` to `auto`, so that element is always\n the nearest scrolling ancestor for the `position: sticky` header cells. Scrolling\n out here would leave the header sticking to a container that never scrolls, so the\n header would not freeze. */}\n <div style={{ flex: 1, minHeight: 0, overflow: 'hidden' }}>\n <DataTableCore<TDataType>\n data={rows}\n dataKey={props.dataKey}\n emptyMessage={props.emptyMessage}\n status={status}\n loadingMessage={props.loadingMessage}\n failureMessage={props.failureMessage}\n unauthorizedMessage={props.unauthorizedMessage}\n selectionMode={props.selectionMode ?? 'single'}\n selection={props.selection}\n onSelectionChange={props.onSelectionChange}\n selectedItems={props.selectedItems}\n onSelectedItemsChange={props.onSelectedItemsChange}\n globalFilterFields={props.globalFilterFields}\n globalSearchPlaceholder={props.globalSearchPlaceholder}\n globalSearchAriaLabel={props.globalSearchAriaLabel}\n defaultFilters={props.defaultFilters}\n scrollable\n scrollHeight='100%'\n className={props.className}\n style={{ minWidth: '100%' }}\n pt={props.pt}\n ptOptions={props.ptOptions}\n unstyled={props.unstyled}\n >\n {props.children}\n </DataTableCore>\n </div>\n\n {totalItems > 0 && pageCount > 1 && (\n <div\n style={{\n borderTop: '1px solid var(--cratis-surface-border)',\n flexShrink: 0,\n }}\n >\n <TablePaginator\n page={result.paging.page}\n pageCount={pageCount}\n onPageChange={setPage}\n totalItems={totalItems}\n pageSize={paging.pageSize}\n pageLinks={props.pageLinks}\n className={props.paginatorClassName}\n ariaLabels={props.paginatorAriaLabels}\n pt={props.paginatorPt}\n ptOptions={props.paginatorPtOptions}\n />\n </div>\n )}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AAkJA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC;AA8CzB,MAAM,iBAAiB,GAAG,CAK7B,KAA4D,KAC5D;IACA,MAAM,CAAC,MAAM,MAAM,OAAO,CAAC,GAAG,kBAAkB,CAC5C,KAAK,CAAC,KAAK,EACX,MAAM,EACN,KAAK,CAAC,cAAc,CACvB;AACD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU;AAC3C,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU;AAG1C,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,IAA8B;AAClD,IAAA,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,CAAC;IAE7C,QACIA,IAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAE;AACH,YAAA,OAAO,EAAE,MAAM;AACf,YAAA,aAAa,EAAE,QAAQ;AACvB,YAAA,MAAM,EAAE,MAAM;AACd,YAAA,MAAM,EAAE,wCAAwC;AAChD,YAAA,YAAY,EAAE,6BAA6B;AAC3C,YAAA,QAAQ,EAAE,QAAQ;AACrB,SAAA,EAAA,QAAA,EAAA,CAQDC,aAAK,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,YACrDA,GAAA,CAAC,aAAa,EAAA,EACV,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,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,CAAC,mBAAmB,EACrC,EAAE,EAAE,KAAK,CAAC,WAAW,EACrB,SAAS,EAAE,KAAK,CAAC,kBAAkB,EAAA,CACrC,EAAA,CACA,CACT,CAAA,EAAA,CACC;AAEd;;"}
1
+ {"version":3,"file":"DataTableForQuery.js","sources":["../../../DataTables/DataTableForQuery.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 { DataTableParts } from './DataTableCore';\nimport type { Constructor } from '@cratis/fundamentals';\nimport { type IQueryFor, Paging } from '@cratis/arc/queries';\nimport { useQueryWithPaging } from '@cratis/arc.react/queries';\nimport { type ReactNode, useMemo } from 'react';\nimport { DataTableCore } from './DataTableCore';\nimport {\n TablePaginator,\n type TablePaginatorParts,\n type TablePaginatorProps,\n} from './TablePaginator';\nimport type { DataTableFilterMeta } from './DataTableFilterMeta';\nimport type { DataTableSelectionChangeEvent } from './DataTableSelectionChangeEvent';\nimport { resolveDataTableStatus } from './resolveDataTableStatus';\nimport type { DataTableServerQuery } from './DataTableServerQuery';\nimport { useServerQuery } from './useServerQuery';\nimport { hasRequiredArguments } from './hasRequiredArguments';\n\n/**\n * Props for {@link DataTableForQuery}.\n *\n * @typeParam TQuery - The query class implementing `IQueryFor`.\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type, or `object` if it takes none.\n */\nexport interface DataTableForQueryProps<\n TQuery extends IQueryFor<TDataType, TArguments> | IQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n> {\n /**\n * Children to render — `<Column>` elements describing the visible columns.\n */\n children?: ReactNode;\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'`.\n */\n selectionMode?: 'single' | 'multiple';\n\n /**\n * The currently selected rows, for `selectionMode='multiple'`.\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 into server mode: the query sorts, filters and searches the complete result before\n * paging, and the table renders the rows as returned. Leave undefined to sort, filter and search\n * the loaded page. See {@link DataTableServerQuery}.\n */\n serverQuery?: DataTableServerQuery<TArguments>;\n\n /**\n * Extra CSS class name forwarded to the underlying DataTable root.\n */\n className?: string;\n\n /** Cratis-owned per-part attributes applied to the underlying table. */\n pt?: DataTableParts;\n\n /**\n * @deprecated Cratis parts always merge. Remove this renderer-era option.\n */\n ptOptions?: object;\n\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `pt` and CSS instead.\n */\n unstyled?: boolean;\n\n /** Shows numbered page buttons in the paginator. Defaults to false. */\n pageLinks?: TablePaginatorProps['pageLinks'];\n\n /** Extra CSS class name forwarded to the paginator. */\n paginatorClassName?: string;\n\n /** Cratis-owned attributes for paginator parts. */\n paginatorPt?: TablePaginatorParts;\n\n /**\n * @deprecated Cratis paginator parts always merge. Remove this renderer-era option.\n */\n paginatorPtOptions?: object;\n\n /** Accessible names for the paginator controls. Override any to localize. */\n paginatorAriaLabels?: TablePaginatorProps['ariaLabels'];\n}\n\nconst paging = new Paging(0, 20);\n\n/**\n * A paged data table bound to a snapshot Cratis Arc query\n * (`IQueryFor<TDataType, TArguments>`). Subscribes via\n * `useQueryWithPaging` from `@cratis/arc.react/queries`, renders the result\n * page through the semantic Cratis-owned {@link DataTableCore}, and shows a\n * {@link TablePaginator} when the result set exceeds one page.\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's static query method. `dotnet build`\n * writes a `.ts` file per query with the right return type and a `use()`\n * hook; importing the class is all the connection-to-the-backend you need.\n *\n * ## Children\n *\n * Children are Cratis `<Column>` elements describing the visible columns —\n * `field`, `header`, custom `body` templates, and `sortable`.\n *\n * ```tsx\n * import { DataTableForQuery, Column } from '@cratis/components/DataTables';\n * import { AllAuthors } from './AllAuthors'; // proxy from C#\n *\n * <DataTableForQuery query={AllAuthors} emptyMessage=\"No authors\">\n * <Column field=\"name\" header=\"Name\" sortable />\n * <Column field=\"email\" header=\"Email\" />\n * </DataTableForQuery>\n * ```\n *\n * Use {@link DataTableForObservableQuery} for queries that should update in\n * real time as the underlying read model changes server-side. Use\n * {@link DataPage} for a higher-level layout that combines this table with\n * an action menubar, selection, and a details pane.\n *\n * ## Styling\n *\n * Forward `pt` / `ptOptions` / `unstyled` / `className` to the underlying\n * DataTable. See [pass-through cheat sheet](../../Documentation/Styling/pass-through.md).\n *\n * @typeParam TQuery - The query class (proxy generated from C# `IQueryFor`).\n * @typeParam TDataType - The row type returned by the query.\n * @typeParam TArguments - The query's argument object type.\n * @param props - {@link DataTableForQueryProps}.\n */\nexport const DataTableForQuery = <\n TQuery extends IQueryFor<TDataType, TArguments> | IQueryFor<TDataType[], TArguments>,\n TDataType extends object,\n TArguments extends object,\n>(\n props: DataTableForQueryProps<TQuery, TDataType, TArguments>,\n) => {\n const server = useServerQuery(props.serverQuery, props.queryArguments, props.defaultFilters);\n const [result, , setSorting, setPage] = useQueryWithPaging(\n props.query,\n paging,\n server.queryArguments,\n );\n const totalItems = result.paging.totalItems;\n const pageCount = result.paging.totalPages;\n\n // SAFETY: Arc collection queries are row-typed while their runtime data is the current row array.\n const rows = result.data as unknown as TDataType[];\n const requiredArguments = useMemo(() => new props.query().requiredRequestParameters, [props.query]);\n // Arc settles a snapshot query it did not send, because a required argument is missing, as\n // unsuccessful. That is a table waiting for its arguments, not a failed query.\n const isWaitingForArguments = !hasRequiredArguments(requiredArguments, server.queryArguments);\n const status = resolveDataTableStatus(isWaitingForArguments ? { ...result, isSuccess: true } : result);\n\n return (\n <div\n style={{\n display: 'flex',\n flexDirection: 'column',\n height: '100%',\n border: '1px solid var(--cratis-surface-border)',\n borderRadius: 'var(--cratis-border-radius)',\n overflow: 'hidden',\n }}\n >\n {/* The scroll container must be `DataTableCore`'s own bounded container rather than\n this wrapper. `.cratis-datatable__container` sets `overflow-x: auto`, and CSS\n computes the matching `overflow-y: visible` to `auto`, so that element is always\n the nearest scrolling ancestor for the `position: sticky` header cells. Scrolling\n out here would leave the header sticking to a container that never scrolls, so the\n header would not freeze. */}\n <div style={{ flex: 1, minHeight: 0, overflow: 'hidden' }}>\n <DataTableCore<TDataType>\n data={rows}\n dataKey={props.dataKey}\n emptyMessage={props.emptyMessage}\n status={status}\n loadingMessage={props.loadingMessage}\n failureMessage={props.failureMessage}\n unauthorizedMessage={props.unauthorizedMessage}\n selectionMode={props.selectionMode ?? 'single'}\n selection={props.selection}\n onSelectionChange={props.onSelectionChange}\n selectedItems={props.selectedItems}\n onSelectedItemsChange={props.onSelectedItemsChange}\n globalFilterFields={props.globalFilterFields}\n globalSearchPlaceholder={props.globalSearchPlaceholder}\n globalSearchAriaLabel={props.globalSearchAriaLabel}\n defaultFilters={props.defaultFilters}\n {...server.tableProps({ setSorting, setPage })}\n scrollable\n scrollHeight='100%'\n className={props.className}\n style={{ minWidth: '100%' }}\n pt={props.pt}\n ptOptions={props.ptOptions}\n unstyled={props.unstyled}\n >\n {props.children}\n </DataTableCore>\n </div>\n\n {totalItems > 0 && pageCount > 1 && (\n <div\n style={{\n borderTop: '1px solid var(--cratis-surface-border)',\n flexShrink: 0,\n }}\n >\n <TablePaginator\n page={result.paging.page}\n pageCount={pageCount}\n onPageChange={setPage}\n totalItems={totalItems}\n pageSize={paging.pageSize}\n pageLinks={props.pageLinks}\n className={props.paginatorClassName}\n ariaLabels={props.paginatorAriaLabels}\n pt={props.paginatorPt}\n ptOptions={props.paginatorPtOptions}\n />\n </div>\n )}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AA4JA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC;AA8CzB,MAAM,iBAAiB,GAAG,CAK7B,KAA4D,KAC5D;AACA,IAAA,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC;IAC5F,MAAM,CAAC,MAAM,IAAI,UAAU,EAAE,OAAO,CAAC,GAAG,kBAAkB,CACtD,KAAK,CAAC,KAAK,EACX,MAAM,EACN,MAAM,CAAC,cAAc,CACxB;AACD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU;AAC3C,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU;AAG1C,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,IAA8B;IAClD,MAAM,iBAAiB,GAAG,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,yBAAyB,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAGnG,MAAM,qBAAqB,GAAG,CAAC,oBAAoB,CAAC,iBAAiB,EAAE,MAAM,CAAC,cAAc,CAAC;IAC7F,MAAM,MAAM,GAA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AM,EACnB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAC3B,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAA,QAAA,EAEvB,KAAK,CAAC,QAAQ,EAAA,CACH,GACd,EAEL,UAAU,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC,KAC5BA,GAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAE;AACH,oBAAA,SAAS,EAAE,wCAAwC;AACnD,oBAAA,UAAU,EAAE,CAAC;AAChB,iBAAA,EAAA,QAAA,EAEDA,GAAA,CAAC,cAAc,EAAA,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EACxB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,OAAO,EACrB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,SAAS,EAAE,KAAK,CAAC,kBAAkB,EACnC,UAAU,EAAE,KAAK,CAAC,mBAAmB,EACrC,EAAE,EAAE,KAAK,CAAC,WAAW,EACrB,SAAS,EAAE,KAAK,CAAC,kBAAkB,EAAA,CACrC,EAAA,CACA,CACT,CAAA,EAAA,CACC;AAEd;;"}
@@ -0,0 +1,38 @@
1
+ import type { DataTableServerQueryState } from './DataTableServerQueryState.js';
2
+ /** How long the search text must stay unchanged before it reaches the query, unless configured. */
3
+ export declare const defaultServerQuerySearchDebounceMilliseconds = 300;
4
+ /**
5
+ * Opts a query-bound table into server mode: the server sorts and filters the complete result
6
+ * before paging, instead of the table sorting and filtering the loaded page.
7
+ *
8
+ * In server mode the table renders the rows exactly as the query returns them. A sort change is sent
9
+ * as Arc sorting (`sortBy` and `sortDirection`). Column filters and search text are sent as query
10
+ * arguments built by {@link toArguments}; Components never guesses the query's argument names or
11
+ * operators. Every change goes back to the first page, and search text is sent once typing pauses.
12
+ * The paginator shows the totals Arc reports for the filtered result.
13
+ *
14
+ * The query must return an `IQueryable` or use MongoDB `Observe` so Arc can sort and page the complete
15
+ * result, and it must apply the filter arguments itself.
16
+ *
17
+ * @typeParam TArguments - The query's argument object type.
18
+ */
19
+ export interface DataTableServerQuery<TArguments extends object = object> {
20
+ /**
21
+ * Builds the query arguments for the current filters and search text. They are merged over
22
+ * `queryArguments`, so they can add optional arguments or replace one.
23
+ * @param state - The applied column filters and the settled search text.
24
+ * @returns The arguments that carry the filters and search text to the query.
25
+ */
26
+ toArguments(state: DataTableServerQueryState): Partial<TArguments>;
27
+ /**
28
+ * The field to sort by on the server, keyed by column field. A column that is not listed sorts by
29
+ * its own field. Arc converts the field to PascalCase on the server.
30
+ */
31
+ sortFields?: Readonly<Record<string, string>>;
32
+ /**
33
+ * Milliseconds the search text must stay unchanged before it is sent. Defaults to
34
+ * {@link defaultServerQuerySearchDebounceMilliseconds}; `0` sends every change at once.
35
+ */
36
+ searchDebounceMilliseconds?: number;
37
+ }
38
+ //# sourceMappingURL=DataTableServerQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableServerQuery.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableServerQuery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAA6B,CAAC;AAE7E,mGAAmG;AACnG,eAAO,MAAM,4CAA4C,MAAM,CAAC;AAEhE;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,oBAAoB,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM;IACpE;;;;;OAKG;IACH,WAAW,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEnE;;;OAGG;IACH,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAE9C;;;OAGG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACvC"}
@@ -0,0 +1,4 @@
1
+ const defaultServerQuerySearchDebounceMilliseconds = 300;
2
+
3
+ export { defaultServerQuerySearchDebounceMilliseconds };
4
+ //# sourceMappingURL=DataTableServerQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableServerQuery.js","sources":["../../../DataTables/DataTableServerQuery.ts"],"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 { DataTableServerQueryState } from './DataTableServerQueryState';\n\n/** How long the search text must stay unchanged before it reaches the query, unless configured. */\nexport const defaultServerQuerySearchDebounceMilliseconds = 300;\n\n/**\n * Opts a query-bound table into server mode: the server sorts and filters the complete result\n * before paging, instead of the table sorting and filtering the loaded page.\n *\n * In server mode the table renders the rows exactly as the query returns them. A sort change is sent\n * as Arc sorting (`sortBy` and `sortDirection`). Column filters and search text are sent as query\n * arguments built by {@link toArguments}; Components never guesses the query's argument names or\n * operators. Every change goes back to the first page, and search text is sent once typing pauses.\n * The paginator shows the totals Arc reports for the filtered result.\n *\n * The query must return an `IQueryable` or use MongoDB `Observe` so Arc can sort and page the complete\n * result, and it must apply the filter arguments itself.\n *\n * @typeParam TArguments - The query's argument object type.\n */\nexport interface DataTableServerQuery<TArguments extends object = object> {\n /**\n * Builds the query arguments for the current filters and search text. They are merged over\n * `queryArguments`, so they can add optional arguments or replace one.\n * @param state - The applied column filters and the settled search text.\n * @returns The arguments that carry the filters and search text to the query.\n */\n toArguments(state: DataTableServerQueryState): Partial<TArguments>;\n\n /**\n * The field to sort by on the server, keyed by column field. A column that is not listed sorts by\n * its own field. Arc converts the field to PascalCase on the server.\n */\n sortFields?: Readonly<Record<string, string>>;\n\n /**\n * Milliseconds the search text must stay unchanged before it is sent. Defaults to\n * {@link defaultServerQuerySearchDebounceMilliseconds}; `0` sends every change at once.\n */\n searchDebounceMilliseconds?: number;\n}\n"],"names":[],"mappings":"AAMO,MAAM,4CAA4C,GAAG;;"}
@@ -0,0 +1,9 @@
1
+ import type { DataTableFilterMeta } from './DataTableFilterMeta.js';
2
+ /** The filter and search state a server query turns into query arguments. */
3
+ export interface DataTableServerQueryState {
4
+ /** The applied column filters, keyed by column field. Empty when no column is filtered. */
5
+ filters: DataTableFilterMeta;
6
+ /** The search text once typing has paused. Empty when nothing is searched for. */
7
+ globalFilter: string;
8
+ }
9
+ //# sourceMappingURL=DataTableServerQueryState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableServerQueryState.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableServerQueryState.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AAEjE,6EAA6E;AAC7E,MAAM,WAAW,yBAAyB;IACtC,2FAA2F;IAC3F,OAAO,EAAE,mBAAmB,CAAC;IAC7B,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ export {};
4
+ //# sourceMappingURL=DataTableServerQueryState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableServerQueryState.js","sourceRoot":"","sources":["../../../DataTables/DataTableServerQueryState.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 { DataTableFilterMeta } from './DataTableFilterMeta';\n\n/** The filter and search state a server query turns into query arguments. */\nexport interface DataTableServerQueryState {\n /** The applied column filters, keyed by column field. Empty when no column is filtered. */\n filters: DataTableFilterMeta;\n /** The search text once typing has paused. Empty when nothing is searched for. */\n globalFilter: string;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Whether every required query argument has a value, by the rule Arc uses before it sends a snapshot
3
+ * query: undefined, null and an empty string count as missing.
4
+ * @param required The names of the query's required arguments.
5
+ * @param args The query arguments.
6
+ * @returns True when no required argument is missing.
7
+ */
8
+ export declare const hasRequiredArguments: (required: readonly string[], args?: object) => boolean;
9
+ //# sourceMappingURL=hasRequiredArguments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasRequiredArguments.d.ts","sourceRoot":"","sources":["../../../DataTables/hasRequiredArguments.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,aAAc,SAAS,MAAM,EAAE,SAAS,MAAM,KAAG,OAI5E,CAAC"}
@@ -0,0 +1,7 @@
1
+ const hasRequiredArguments = (required, args) => required.every((name) => {
2
+ const value = args?.[name];
3
+ return value !== undefined && value !== null && value !== '';
4
+ });
5
+
6
+ export { hasRequiredArguments };
7
+ //# sourceMappingURL=hasRequiredArguments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasRequiredArguments.js","sources":["../../../DataTables/hasRequiredArguments.ts"],"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\n/**\n * Whether every required query argument has a value, by the rule Arc uses before it sends a snapshot\n * query: undefined, null and an empty string count as missing.\n * @param required The names of the query's required arguments.\n * @param args The query arguments.\n * @returns True when no required argument is missing.\n */\nexport const hasRequiredArguments = (required: readonly string[], args?: object): boolean =>\n required.every((name) => {\n const value = (args as Record<string, unknown> | undefined)?.[name];\n return value !== undefined && value !== null && value !== '';\n });\n"],"names":[],"mappings":"AAUO,MAAM,oBAAoB,GAAG,CAAC,QAA2B,EAAE,IAAa,KAC3E,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,KAAI;AACpB,IAAA,MAAM,KAAK,GAAI,IAA4C,GAAG,IAAI,CAAC;IACnE,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;AAChE,CAAC;;"}
@@ -12,5 +12,7 @@ export * from './DataTableFilterMeta.js';
12
12
  export type { DataTableSort } from './DataTableSort.js';
13
13
  export { DataTableSortDirection } from './DataTableSortDirection.js';
14
14
  export { DataTableRowProcessing } from './DataTableRowProcessing.js';
15
+ export { defaultServerQuerySearchDebounceMilliseconds, type DataTableServerQuery, } from './DataTableServerQuery.js';
16
+ export type { DataTableServerQueryState } from './DataTableServerQueryState.js';
15
17
  export { registerDataTableFilterMatcher, resolveDataTableFilterMatcher, unregisterDataTableFilterMatcher, type DataTableFilterMatcherRegistration, } from './DataTableFilterMatcherRegistry.js';
16
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../DataTables/index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAiB,CAAC;AAChC,cAAc,sBAAmB,CAAC;AAClC,cAAc,wBAAqB,CAAC;AACpC,cAAc,kCAA+B,CAAC;AAC9C,cAAc,aAAU,CAAC;AACzB,cAAc,uBAAoB,CAAC;AACnC,cAAc,qBAAkB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAClD,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAqB,CAAC;AAC7D,cAAc,oCAAiC,CAAC;AAChD,cAAc,0BAAuB,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAiB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA0B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA0B,CAAC;AAClE,OAAO,EACH,8BAA8B,EAC9B,6BAA6B,EAC7B,gCAAgC,EAChC,KAAK,kCAAkC,GAC1C,MAAM,qCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../DataTables/index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAiB,CAAC;AAChC,cAAc,sBAAmB,CAAC;AAClC,cAAc,wBAAqB,CAAC;AACpC,cAAc,kCAA+B,CAAC;AAC9C,cAAc,aAAU,CAAC;AACzB,cAAc,uBAAoB,CAAC;AACnC,cAAc,qBAAkB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAClD,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAqB,CAAC;AAC7D,cAAc,oCAAiC,CAAC;AAChD,cAAc,0BAAuB,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAiB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA0B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA0B,CAAC;AAClE,OAAO,EACH,4CAA4C,EAC5C,KAAK,oBAAoB,GAC5B,MAAM,2BAAwB,CAAC;AAChC,YAAY,EAAE,yBAAyB,EAAE,MAAM,gCAA6B,CAAC;AAC7E,OAAO,EACH,8BAA8B,EAC9B,6BAA6B,EAC7B,gCAAgC,EAChC,KAAK,kCAAkC,GAC1C,MAAM,qCAAkC,CAAC"}
@@ -9,5 +9,6 @@ export { paginatorPages } from './paginatorPages.js';
9
9
  export { DataTableFilterMatchMode } from './DataTableFilterMeta.js';
10
10
  export { DataTableSortDirection } from './DataTableSortDirection.js';
11
11
  export { DataTableRowProcessing } from './DataTableRowProcessing.js';
12
+ export { defaultServerQuerySearchDebounceMilliseconds } from './DataTableServerQuery.js';
12
13
  export { registerDataTableFilterMatcher, resolveDataTableFilterMatcher, unregisterDataTableFilterMatcher } from './DataTableFilterMatcherRegistry.js';
13
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -1,10 +1,5 @@
1
+ import { type QueryStatusFlags } from '../QueryStatus/resolveQueryStatus.js';
1
2
  import { DataTableStatus } from './DataTableStatus.js';
2
3
  /** Resolve Arc query flags into the table's display state. */
3
- export declare const resolveDataTableStatus: (result: {
4
- isAuthorized?: boolean;
5
- hasExceptions?: boolean;
6
- isValid?: boolean;
7
- isPerforming?: boolean;
8
- isReady?: boolean;
9
- }) => DataTableStatus;
4
+ export declare const resolveDataTableStatus: (result: QueryStatusFlags) => DataTableStatus;
10
5
  //# sourceMappingURL=resolveDataTableStatus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveDataTableStatus.d.ts","sourceRoot":"","sources":["../../../DataTables/resolveDataTableStatus.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;AASpD,8DAA8D;AAC9D,eAAO,MAAM,sBAAsB,WAAY;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,KAAG,eAAuE,CAAC"}
1
+ {"version":3,"file":"resolveDataTableStatus.d.ts","sourceRoot":"","sources":["../../../DataTables/resolveDataTableStatus.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,sCAAmC,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;AASpD,8DAA8D;AAC9D,eAAO,MAAM,sBAAsB,WAAY,gBAAgB,KAAG,eACV,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveDataTableStatus.js","sources":["../../../DataTables/resolveDataTableStatus.ts"],"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 { QueryStatus } from '../QueryStatus/QueryStatus';\nimport { resolveQueryStatus } from '../QueryStatus/resolveQueryStatus';\nimport { DataTableStatus } from './DataTableStatus';\n\nconst tableStatusByQueryStatus: Record<QueryStatus, DataTableStatus> = {\n [QueryStatus.Ready]: DataTableStatus.Ready,\n [QueryStatus.Loading]: DataTableStatus.Loading,\n [QueryStatus.Failed]: DataTableStatus.Failed,\n [QueryStatus.Unauthorized]: DataTableStatus.Unauthorized,\n};\n\n/** Resolve Arc query flags into the table's display state. */\nexport const resolveDataTableStatus = (result: {\n isAuthorized?: boolean;\n hasExceptions?: boolean;\n isValid?: boolean;\n isPerforming?: boolean;\n isReady?: boolean;\n}): DataTableStatus => tableStatusByQueryStatus[resolveQueryStatus(result)];\n"],"names":[],"mappings":";;;;AAOA,MAAM,wBAAwB,GAAyC;AACnE,IAAA,CAAC,WAAW,CAAC,KAAK,GAAG,eAAe,CAAC,KAAK;AAC1C,IAAA,CAAC,WAAW,CAAC,OAAO,GAAG,eAAe,CAAC,OAAO;AAC9C,IAAA,CAAC,WAAW,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM;AAC5C,IAAA,CAAC,WAAW,CAAC,YAAY,GAAG,eAAe,CAAC,YAAY;CAC3D;AAGM,MAAM,sBAAsB,GAAG,CAAC,MAMtC,KAAsB,wBAAwB,CAAC,kBAAkB,CAAC,MAAM,CAAC;;"}
1
+ {"version":3,"file":"resolveDataTableStatus.js","sources":["../../../DataTables/resolveDataTableStatus.ts"],"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 { QueryStatus } from '../QueryStatus/QueryStatus';\nimport { resolveQueryStatus, type QueryStatusFlags } from '../QueryStatus/resolveQueryStatus';\nimport { DataTableStatus } from './DataTableStatus';\n\nconst tableStatusByQueryStatus: Record<QueryStatus, DataTableStatus> = {\n [QueryStatus.Ready]: DataTableStatus.Ready,\n [QueryStatus.Loading]: DataTableStatus.Loading,\n [QueryStatus.Failed]: DataTableStatus.Failed,\n [QueryStatus.Unauthorized]: DataTableStatus.Unauthorized,\n};\n\n/** Resolve Arc query flags into the table's display state. */\nexport const resolveDataTableStatus = (result: QueryStatusFlags): DataTableStatus =>\n tableStatusByQueryStatus[resolveQueryStatus(result)];\n"],"names":[],"mappings":";;;;AAOA,MAAM,wBAAwB,GAAyC;AACnE,IAAA,CAAC,WAAW,CAAC,KAAK,GAAG,eAAe,CAAC,KAAK;AAC1C,IAAA,CAAC,WAAW,CAAC,OAAO,GAAG,eAAe,CAAC,OAAO;AAC9C,IAAA,CAAC,WAAW,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM;AAC5C,IAAA,CAAC,WAAW,CAAC,YAAY,GAAG,eAAe,CAAC,YAAY;CAC3D;AAGM,MAAM,sBAAsB,GAAG,CAAC,MAAwB,KAC3D,wBAAwB,CAAC,kBAAkB,CAAC,MAAM,CAAC;;"}
@@ -0,0 +1,32 @@
1
+ import { Sorting } from '@cratis/arc/queries';
2
+ import type { DataTableCoreProps } from './DataTableCore.js';
3
+ import type { DataTableFilterMeta } from './DataTableFilterMeta.js';
4
+ import { type DataTableServerQuery } from './DataTableServerQuery.js';
5
+ /** The sorting and paging delegates of an Arc paging hook. */
6
+ export interface ServerQueryControls {
7
+ setSorting: (sorting: Sorting) => unknown;
8
+ setPage: (page: number) => unknown;
9
+ }
10
+ /** The table props that hand a table's sort, filter and search state to the server. */
11
+ export type ServerQueryTableProps = Pick<DataTableCoreProps<object>, 'rowProcessing' | 'sort' | 'onSortChange' | 'filters' | 'onFilter' | 'globalFilter' | 'onGlobalFilterChange'>;
12
+ /** What a bound table needs to run in server mode, or to run unchanged without it. */
13
+ export interface ServerQueryBinding<TArguments extends object> {
14
+ /** The arguments to perform the query with. */
15
+ queryArguments: TArguments | undefined;
16
+ /**
17
+ * Builds the table props that drive the query through the paging hook's delegates.
18
+ * @param controls - The paging hook's sorting and paging delegates.
19
+ * @returns No props without a server query, so the table keeps its loaded-page behavior.
20
+ */
21
+ tableProps(controls: ServerQueryControls): ServerQueryTableProps;
22
+ }
23
+ /**
24
+ * Keeps a bound table's sort, filter and search state for server mode and turns it into Arc sorting
25
+ * and query arguments. Without a server query it passes the arguments through and adds no table props.
26
+ * @param serverQuery - The server mode options, or undefined for loaded-page mode.
27
+ * @param queryArguments - The arguments the table was given.
28
+ * @param defaultFilters - The initial column filters.
29
+ * @returns The arguments to query with and the table props for server mode.
30
+ */
31
+ export declare const useServerQuery: <TArguments extends object>(serverQuery: DataTableServerQuery<TArguments> | undefined, queryArguments: TArguments | undefined, defaultFilters: DataTableFilterMeta | undefined) => ServerQueryBinding<TArguments>;
32
+ //# sourceMappingURL=useServerQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useServerQuery.d.ts","sourceRoot":"","sources":["../../../DataTables/useServerQuery.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AAEjE,OAAO,EAEH,KAAK,oBAAoB,EAC5B,MAAM,2BAAwB,CAAC;AAIhC,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAChC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;IAC1C,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACtC;AAED,uFAAuF;AACvF,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACpC,kBAAkB,CAAC,MAAM,CAAC,EACxB,eAAe,GACf,MAAM,GACN,cAAc,GACd,SAAS,GACT,UAAU,GACV,cAAc,GACd,sBAAsB,CAC3B,CAAC;AAEF,sFAAsF;AACtF,MAAM,WAAW,kBAAkB,CAAC,UAAU,SAAS,MAAM;IACzD,+CAA+C;IAC/C,cAAc,EAAE,UAAU,GAAG,SAAS,CAAC;IACvC;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,mBAAmB,GAAG,qBAAqB,CAAC;CACpE;AAiBD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,SAAS,MAAM,eACvC,oBAAoB,CAAC,UAAU,CAAC,GAAG,SAAS,kBACzC,UAAU,GAAG,SAAS,kBACtB,mBAAmB,GAAG,SAAS,KAChD,kBAAkB,CAAC,UAAU,CAsD/B,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { useState, useRef, useEffect } from 'react';
2
+ import { Sorting, SortDirection } from '@cratis/arc/queries';
3
+ import { DataTableRowProcessing } from './DataTableRowProcessing.js';
4
+ import { defaultServerQuerySearchDebounceMilliseconds } from './DataTableServerQuery.js';
5
+ import { DataTableSortDirection } from './DataTableSortDirection.js';
6
+
7
+ const firstPage = 0;
8
+ const toSorting = (sort, sortFields) => sort
9
+ ? new Sorting(sortFields?.[sort.field] ?? sort.field, sort.direction === DataTableSortDirection.Descending
10
+ ? SortDirection.descending
11
+ : SortDirection.ascending)
12
+ : Sorting.none;
13
+ const useServerQuery = (serverQuery, queryArguments, defaultFilters) => {
14
+ const [sort, setSort] = useState(null);
15
+ const [filters, setFilters] = useState(defaultFilters ?? {});
16
+ const [searchText, setSearchText] = useState('');
17
+ const [appliedSearch, setAppliedSearch] = useState('');
18
+ const appliedSearchRef = useRef('');
19
+ const searchTimerRef = useRef(undefined);
20
+ useEffect(() => () => clearTimeout(searchTimerRef.current), []);
21
+ if (!serverQuery) {
22
+ return { queryArguments, tableProps: () => ({}) };
23
+ }
24
+ const debounceMilliseconds = serverQuery.searchDebounceMilliseconds ?? defaultServerQuerySearchDebounceMilliseconds;
25
+ const serverArguments = {
26
+ ...queryArguments,
27
+ ...serverQuery.toArguments({ filters, globalFilter: appliedSearch }),
28
+ };
29
+ return {
30
+ queryArguments: serverArguments,
31
+ tableProps: ({ setSorting, setPage }) => ({
32
+ rowProcessing: DataTableRowProcessing.None,
33
+ sort,
34
+ onSortChange: (next) => {
35
+ setSort(next);
36
+ setSorting(toSorting(next, serverQuery.sortFields));
37
+ setPage(firstPage);
38
+ },
39
+ filters,
40
+ onFilter: (next) => {
41
+ setFilters(next);
42
+ setPage(firstPage);
43
+ },
44
+ globalFilter: searchText,
45
+ onGlobalFilterChange: (next) => {
46
+ setSearchText(next);
47
+ clearTimeout(searchTimerRef.current);
48
+ const apply = () => {
49
+ if (next === appliedSearchRef.current)
50
+ return;
51
+ appliedSearchRef.current = next;
52
+ setAppliedSearch(next);
53
+ setPage(firstPage);
54
+ };
55
+ if (debounceMilliseconds > 0) {
56
+ searchTimerRef.current = setTimeout(apply, debounceMilliseconds);
57
+ }
58
+ else {
59
+ apply();
60
+ }
61
+ },
62
+ }),
63
+ };
64
+ };
65
+
66
+ export { useServerQuery };
67
+ //# sourceMappingURL=useServerQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useServerQuery.js","sources":["../../../DataTables/useServerQuery.ts"],"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 } from 'react';\nimport { SortDirection, Sorting } from '@cratis/arc/queries';\nimport type { DataTableCoreProps } from './DataTableCore';\nimport type { DataTableFilterMeta } from './DataTableFilterMeta';\nimport { DataTableRowProcessing } from './DataTableRowProcessing';\nimport {\n defaultServerQuerySearchDebounceMilliseconds,\n type DataTableServerQuery,\n} from './DataTableServerQuery';\nimport type { DataTableSort } from './DataTableSort';\nimport { DataTableSortDirection } from './DataTableSortDirection';\n\n/** The sorting and paging delegates of an Arc paging hook. */\nexport interface ServerQueryControls {\n setSorting: (sorting: Sorting) => unknown;\n setPage: (page: number) => unknown;\n}\n\n/** The table props that hand a table's sort, filter and search state to the server. */\nexport type ServerQueryTableProps = Pick<\n DataTableCoreProps<object>,\n | 'rowProcessing'\n | 'sort'\n | 'onSortChange'\n | 'filters'\n | 'onFilter'\n | 'globalFilter'\n | 'onGlobalFilterChange'\n>;\n\n/** What a bound table needs to run in server mode, or to run unchanged without it. */\nexport interface ServerQueryBinding<TArguments extends object> {\n /** The arguments to perform the query with. */\n queryArguments: TArguments | undefined;\n /**\n * Builds the table props that drive the query through the paging hook's delegates.\n * @param controls - The paging hook's sorting and paging delegates.\n * @returns No props without a server query, so the table keeps its loaded-page behavior.\n */\n tableProps(controls: ServerQueryControls): ServerQueryTableProps;\n}\n\nconst firstPage = 0;\n\nconst toSorting = (\n sort: DataTableSort | null,\n sortFields: Readonly<Record<string, string>> | undefined,\n): Sorting =>\n sort\n ? new Sorting(\n sortFields?.[sort.field] ?? sort.field,\n sort.direction === DataTableSortDirection.Descending\n ? SortDirection.descending\n : SortDirection.ascending,\n )\n : Sorting.none;\n\n/**\n * Keeps a bound table's sort, filter and search state for server mode and turns it into Arc sorting\n * and query arguments. Without a server query it passes the arguments through and adds no table props.\n * @param serverQuery - The server mode options, or undefined for loaded-page mode.\n * @param queryArguments - The arguments the table was given.\n * @param defaultFilters - The initial column filters.\n * @returns The arguments to query with and the table props for server mode.\n */\nexport const useServerQuery = <TArguments extends object>(\n serverQuery: DataTableServerQuery<TArguments> | undefined,\n queryArguments: TArguments | undefined,\n defaultFilters: DataTableFilterMeta | undefined,\n): ServerQueryBinding<TArguments> => {\n const [sort, setSort] = useState<DataTableSort | null>(null);\n const [filters, setFilters] = useState<DataTableFilterMeta>(defaultFilters ?? {});\n const [searchText, setSearchText] = useState('');\n const [appliedSearch, setAppliedSearch] = useState('');\n const appliedSearchRef = useRef('');\n const searchTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n useEffect(() => () => clearTimeout(searchTimerRef.current), []);\n\n if (!serverQuery) {\n return { queryArguments, tableProps: () => ({}) };\n }\n\n const debounceMilliseconds =\n serverQuery.searchDebounceMilliseconds ?? defaultServerQuerySearchDebounceMilliseconds;\n const serverArguments = {\n ...queryArguments,\n ...serverQuery.toArguments({ filters, globalFilter: appliedSearch }),\n } as TArguments;\n\n return {\n queryArguments: serverArguments,\n tableProps: ({ setSorting, setPage }) => ({\n rowProcessing: DataTableRowProcessing.None,\n sort,\n onSortChange: (next) => {\n setSort(next);\n setSorting(toSorting(next, serverQuery.sortFields));\n setPage(firstPage);\n },\n filters,\n onFilter: (next) => {\n setFilters(next);\n setPage(firstPage);\n },\n globalFilter: searchText,\n onGlobalFilterChange: (next) => {\n setSearchText(next);\n clearTimeout(searchTimerRef.current);\n const apply = () => {\n if (next === appliedSearchRef.current) return;\n appliedSearchRef.current = next;\n setAppliedSearch(next);\n setPage(firstPage);\n };\n if (debounceMilliseconds > 0) {\n searchTimerRef.current = setTimeout(apply, debounceMilliseconds);\n } else {\n apply();\n }\n },\n }),\n };\n};\n"],"names":[],"mappings":";;;;;;AA6CA,MAAM,SAAS,GAAG,CAAC;AAEnB,MAAM,SAAS,GAAG,CACd,IAA0B,EAC1B,UAAwD,KAExD;MACM,IAAI,OAAO,CACT,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,EACtC,IAAI,CAAC,SAAS,KAAK,sBAAsB,CAAC;UACpC,aAAa,CAAC;AAChB,UAAE,aAAa,CAAC,SAAS;AAEjC,MAAE,OAAO,CAAC,IAAI;AAUf,MAAM,cAAc,GAAG,CAC1B,WAAyD,EACzD,cAAsC,EACtC,cAA+C,KACf;IAChC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAuB,IAAI,CAAC;AAC5D,IAAA,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAsB,cAAc,IAAI,EAAE,CAAC;IACjF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;IAChD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;AACtD,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAC,EAAE,CAAC;AACnC,IAAA,MAAM,cAAc,GAAG,MAAM,CAA4C,SAAS,CAAC;AAEnF,IAAA,SAAS,CAAC,MAAM,MAAM,YAAY,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,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AAc,CAAC,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,oBAAoB,CAAC;gBACpE;qBAAO;AACH,oBAAA,KAAK,EAAE;gBACX;YACJ,CAAC;SACJ,CAAC;KACL;AACL;;"}
@@ -1,10 +1,17 @@
1
1
  import { QueryStatus } from './QueryStatus.js';
2
- /** Resolve Arc query flags into a component-neutral display state. */
3
- export declare const resolveQueryStatus: (result: {
2
+ /** The Arc query flags a display state is resolved from. */
3
+ export interface QueryStatusFlags {
4
+ isSuccess?: boolean;
4
5
  isAuthorized?: boolean;
5
6
  hasExceptions?: boolean;
6
7
  isValid?: boolean;
7
8
  isPerforming?: boolean;
8
9
  isReady?: boolean;
9
- }) => QueryStatus;
10
+ }
11
+ /**
12
+ * Resolve Arc query flags into a component-neutral display state. A settled result that is not
13
+ * successful is a failure even when no other flag explains why, such as a response Arc could not
14
+ * read; it never resolves to ready, which would present the failure as an empty result.
15
+ */
16
+ export declare const resolveQueryStatus: (result: QueryStatusFlags) => QueryStatus;
10
17
  //# sourceMappingURL=resolveQueryStatus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveQueryStatus.d.ts","sourceRoot":"","sources":["../../../QueryStatus/resolveQueryStatus.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AAE5C,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,WAAY;IACvC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,KAAG,WAKH,CAAC"}
1
+ {"version":3,"file":"resolveQueryStatus.d.ts","sourceRoot":"","sources":["../../../QueryStatus/resolveQueryStatus.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AAE5C,4DAA4D;AAC5D,MAAM,WAAW,gBAAgB;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,gBAAgB,KAAG,WAM7D,CAAC"}
@@ -7,6 +7,8 @@ const resolveQueryStatus = (result) => {
7
7
  return QueryStatus.Failed;
8
8
  if (result.isPerforming === true || result.isReady === false)
9
9
  return QueryStatus.Loading;
10
+ if (result.isSuccess === false)
11
+ return QueryStatus.Failed;
10
12
  return QueryStatus.Ready;
11
13
  };
12
14
 
@@ -1 +1 @@
1
- {"version":3,"file":"resolveQueryStatus.js","sources":["../../../QueryStatus/resolveQueryStatus.ts"],"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 { QueryStatus } from './QueryStatus';\n\n/** Resolve Arc query flags into a component-neutral display state. */\nexport const resolveQueryStatus = (result: {\n isAuthorized?: boolean;\n hasExceptions?: boolean;\n isValid?: boolean;\n isPerforming?: boolean;\n isReady?: boolean;\n}): QueryStatus => {\n if (result.isAuthorized === false) return QueryStatus.Unauthorized;\n if (result.hasExceptions === true || result.isValid === false) return QueryStatus.Failed;\n if (result.isPerforming === true || result.isReady === false) return QueryStatus.Loading;\n return QueryStatus.Ready;\n};\n"],"names":[],"mappings":";;AAMO,MAAM,kBAAkB,GAAG,CAAC,MAMlC,KAAiB;AACd,IAAA,IAAI,MAAM,CAAC,YAAY,KAAK,KAAK;QAAE,OAAO,WAAW,CAAC,YAAY;IAClE,IAAI,MAAM,CAAC,aAAa,KAAK,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK;QAAE,OAAO,WAAW,CAAC,MAAM;IACxF,IAAI,MAAM,CAAC,YAAY,KAAK,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK;QAAE,OAAO,WAAW,CAAC,OAAO;IACxF,OAAO,WAAW,CAAC,KAAK;AAC5B;;"}
1
+ {"version":3,"file":"resolveQueryStatus.js","sources":["../../../QueryStatus/resolveQueryStatus.ts"],"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 { QueryStatus } from './QueryStatus';\n\n/** The Arc query flags a display state is resolved from. */\nexport interface QueryStatusFlags {\n isSuccess?: boolean;\n isAuthorized?: boolean;\n hasExceptions?: boolean;\n isValid?: boolean;\n isPerforming?: boolean;\n isReady?: boolean;\n}\n\n/**\n * Resolve Arc query flags into a component-neutral display state. A settled result that is not\n * successful is a failure even when no other flag explains why, such as a response Arc could not\n * read; it never resolves to ready, which would present the failure as an empty result.\n */\nexport const resolveQueryStatus = (result: QueryStatusFlags): QueryStatus => {\n if (result.isAuthorized === false) return QueryStatus.Unauthorized;\n if (result.hasExceptions === true || result.isValid === false) return QueryStatus.Failed;\n if (result.isPerforming === true || result.isReady === false) return QueryStatus.Loading;\n if (result.isSuccess === false) return QueryStatus.Failed;\n return QueryStatus.Ready;\n};\n"],"names":[],"mappings":";;AAoBO,MAAM,kBAAkB,GAAG,CAAC,MAAwB,KAAiB;AACxE,IAAA,IAAI,MAAM,CAAC,YAAY,KAAK,KAAK;QAAE,OAAO,WAAW,CAAC,YAAY;IAClE,IAAI,MAAM,CAAC,aAAa,KAAK,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK;QAAE,OAAO,WAAW,CAAC,MAAM;IACxF,IAAI,MAAM,CAAC,YAAY,KAAK,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK;QAAE,OAAO,WAAW,CAAC,OAAO;AACxF,IAAA,IAAI,MAAM,CAAC,SAAS,KAAK,KAAK;QAAE,OAAO,WAAW,CAAC,MAAM;IACzD,OAAO,WAAW,CAAC,KAAK;AAC5B;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/components",
3
- "version": "4.29.0",
3
+ "version": "4.30.0",
4
4
  "description": "React components for CQRS and event-sourced apps — command dialogs, typed forms, and query-backed data tables for Cratis Arc",
5
5
  "keywords": [
6
6
  "react",
@@ -312,7 +312,7 @@
312
312
  "ts-deepmerge": "8.0.0"
313
313
  },
314
314
  "devDependencies": {
315
- "@cratis/arc.vite": "22.16.0",
315
+ "@cratis/arc.vite": "22.122.1",
316
316
  "pixi.js": "^8.20.1",
317
317
  "react": "19.3.0",
318
318
  "react-dom": "19.3.0"