@cratis/components 4.41.6 → 4.42.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.
- package/compat-manifest.json +11 -11
- package/dist/esm/DataPage/DataPage.d.ts +13 -7
- package/dist/esm/DataPage/DataPage.d.ts.map +1 -1
- package/dist/esm/DataPage/DataPage.js +6 -12
- package/dist/esm/DataPage/DataPage.js.map +1 -1
- package/dist/esm/DataPage/DataPageSelection.d.ts +19 -0
- package/dist/esm/DataPage/DataPageSelection.d.ts.map +1 -0
- package/dist/esm/DataPage/DataPageSelection.js +4 -0
- package/dist/esm/DataPage/DataPageSelection.js.map +1 -0
- package/dist/esm/DataPage/adaptMenuItem.d.ts +5 -0
- package/dist/esm/DataPage/adaptMenuItem.d.ts.map +1 -0
- package/dist/esm/DataPage/adaptMenuItem.js +22 -0
- package/dist/esm/DataPage/adaptMenuItem.js.map +1 -0
- package/dist/esm/DataPage/index.d.ts +1 -0
- package/dist/esm/DataPage/index.d.ts.map +1 -1
- package/package.json +1 -1
package/compat-manifest.json
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
{
|
|
69
69
|
"name": "@cratis/components",
|
|
70
70
|
"role": "core",
|
|
71
|
-
"version": "4.
|
|
71
|
+
"version": "4.42.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.
|
|
95
|
+
"version": "4.42.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.
|
|
108
|
+
"version": "4.42.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.
|
|
119
|
+
"version": "4.42.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.
|
|
125
|
+
"@cratis/components": "4.42.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.
|
|
135
|
+
"version": "4.42.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.
|
|
141
|
+
"@cratis/components": "4.42.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.
|
|
191
|
+
"version": "4.42.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.
|
|
197
|
+
"@cratis/components": "4.42.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.
|
|
259
|
+
"version": "4.42.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.
|
|
265
|
+
"@cratis/components": "4.42.0",
|
|
266
266
|
"primereact": ">=10.9.9 <11",
|
|
267
267
|
"react": "^19.0.0",
|
|
268
268
|
"react-dom": "^19.0.0"
|
|
@@ -8,21 +8,24 @@ import type { DataTableFilterMeta } from '../DataTables/DataTableFilterMeta.js';
|
|
|
8
8
|
import type { DataTableSelectionChangeEvent } from '../DataTables/DataTableSelectionChangeEvent.js';
|
|
9
9
|
import type { DataTableServerQuery } from '../DataTables/DataTableServerQuery.js';
|
|
10
10
|
import type { Constructor } from '@cratis/fundamentals';
|
|
11
|
+
import type { DataPageSelection } from './DataPageSelection.js';
|
|
11
12
|
/**
|
|
12
13
|
* Props for {@link MenuItem} — a single action in a {@link DataPage}'s
|
|
13
14
|
* action bar.
|
|
15
|
+
*
|
|
16
|
+
* @typeParam TDataType - The surrounding page's row type. JSX does not infer it from the parent.
|
|
14
17
|
*/
|
|
15
|
-
export interface MenuItemProps {
|
|
18
|
+
export interface MenuItemProps<TDataType extends object = object> {
|
|
16
19
|
/** Icon component rendered before the label (e.g. a react-icons icon). */
|
|
17
20
|
icon?: React.ComponentType<{
|
|
18
21
|
className?: string;
|
|
19
22
|
}>;
|
|
20
23
|
/** The visible label. */
|
|
21
24
|
label?: string;
|
|
22
|
-
/** Invoked when the item is activated. */
|
|
23
|
-
command?: () => void;
|
|
24
|
-
/**
|
|
25
|
-
disabled?: boolean;
|
|
25
|
+
/** Invoked with the immutable, committed selection when the enabled item is activated. */
|
|
26
|
+
command?: (selection: DataPageSelection<TDataType>) => void;
|
|
27
|
+
/** A boolean or selection predicate; when true, the item cannot dispatch its command. */
|
|
28
|
+
disabled?: boolean | ((selection: DataPageSelection<TDataType>) => boolean);
|
|
26
29
|
/**
|
|
27
30
|
* When true, the menu item is disabled while no row is selected in the
|
|
28
31
|
* surrounding {@link DataPage}. Use it for context-sensitive actions like
|
|
@@ -33,9 +36,12 @@ export interface MenuItemProps {
|
|
|
33
36
|
/**
|
|
34
37
|
* Declarative menu item for use inside `<DataPage.MenuItems>`. Renders nothing
|
|
35
38
|
* directly; the surrounding {@link MenuItems} component reads its props and
|
|
36
|
-
* forwards them to the action menubar.
|
|
39
|
+
* forwards them to the action menubar. Supply the page's row type explicitly
|
|
40
|
+
* as `<DataPage.MenuItem<Person>>` for typed row access in callbacks.
|
|
41
|
+
*
|
|
42
|
+
* @typeParam TDataType - The surrounding page's row type, not inferred from its JSX parent.
|
|
37
43
|
*/
|
|
38
|
-
export declare const MenuItem: (_props: MenuItemProps) => null;
|
|
44
|
+
export declare const MenuItem: <TDataType extends object = object>(_props: MenuItemProps<TDataType>) => null;
|
|
39
45
|
/**
|
|
40
46
|
* Props for {@link MenuItems}.
|
|
41
47
|
*/
|
|
@@ -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,cAA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AC,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"}
|
|
@@ -7,6 +7,7 @@ import { DataTableForObservableQuery } from '../DataTables/DataTableForObservabl
|
|
|
7
7
|
import { DataTableForQuery } from '../DataTables/DataTableForQuery.js';
|
|
8
8
|
import { Allotment } from 'allotment';
|
|
9
9
|
import { DataPageLayout } from './DataPageLayout.js';
|
|
10
|
+
import { adaptMenuItem } from './adaptMenuItem.js';
|
|
10
11
|
|
|
11
12
|
const MenuItem = (_props) => {
|
|
12
13
|
return null;
|
|
@@ -16,25 +17,18 @@ const tableRegionStyle = { flexGrow: 1, flexBasis: 0, minHeight: 0 };
|
|
|
16
17
|
const pageStyle = { minHeight: '20rem' };
|
|
17
18
|
const MenuItems = ({ children }) => {
|
|
18
19
|
const context = useDataPageContext();
|
|
19
|
-
const
|
|
20
|
-
? context.selectedItems
|
|
21
|
-
:
|
|
20
|
+
const selection = useMemo(() => context.selectionMode === 'multiple'
|
|
21
|
+
? Object.freeze({ selectionMode: 'multiple', selectedItems: Object.freeze([...context.selectedItems]) })
|
|
22
|
+
: Object.freeze({ selectionMode: 'single', selectedItem: context.selectedItem }), [context.selectionMode, context.selectedItem, context.selectedItems]);
|
|
22
23
|
const items = useMemo(() => {
|
|
23
24
|
const menuItems = [];
|
|
24
25
|
React.Children.forEach(children, (child) => {
|
|
25
26
|
if (React.isValidElement(child) && child.type === MenuItem) {
|
|
26
|
-
|
|
27
|
-
menuItems.push({
|
|
28
|
-
label: child.props.label,
|
|
29
|
-
command: child.props.command,
|
|
30
|
-
icon: Icon ? jsx(Icon, { className: 'cratis:mr-2' }) : undefined,
|
|
31
|
-
disabled: (child.props.disabled ?? false) ||
|
|
32
|
-
(isDisabled && (child.props.disableOnUnselected ?? false)),
|
|
33
|
-
});
|
|
27
|
+
menuItems.push(adaptMenuItem(child.props, selection));
|
|
34
28
|
}
|
|
35
29
|
});
|
|
36
30
|
return menuItems;
|
|
37
|
-
}, [children,
|
|
31
|
+
}, [children, selection]);
|
|
38
32
|
return (jsx("div", { className: 'cratis-data-page-actions cratis:px-4 cratis:py-2', style: actionsStyle, children: jsx(ActionMenubar, { "aria-label": context.actionsAriaLabel ?? 'Actions', model: items, className: context.menubarClassName, pt: context.menubarPt, ptOptions: context.menubarPtOptions, unstyled: context.menubarUnstyled }) }));
|
|
39
33
|
};
|
|
40
34
|
const Columns = ({ children }) => {
|
|
@@ -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 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 /** Whether the page content is a main landmark. Defaults to true; set false inside an existing main. */\n landmark?: boolean;\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 /**\n * The message to show instead of {@link emptyMessage} when a search or column filter is active\n * and no rows are shown. Defaults to a localizable message that says only the loaded page was\n * searched, or, with `serverQuery`, a neutral \"No rows match the search.\".\n */\n filteredEmptyMessage?: ReactNode;\n\n /** Notified of every change to the search text, as typed. */\n onGlobalFilterChange?: (globalFilter: string) => void;\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, including replacement or removal of its query row.\n * With a controlled selection, the consumer must accept the new value. Without a callback,\n * the controlled value and its details remain unchanged even if the query row disappears.\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} landmark={props.landmark} panel={true} style={pageStyle} data-cratis-component='DataPage'>\n {props.detailsComponent ? (\n <Allotment className='cratis:h-full' proportionalLayout={false}>\n <Allotment.Pane>\n <DataPageLayout>{props.children}</DataPageLayout>\n </Allotment.Pane>\n {selectedItem && (\n <Allotment.Pane preferredSize='450px'>\n <props.detailsComponent\n item={selectedItem}\n onRefresh={props.onRefresh}\n />\n </Allotment.Pane>\n )}\n </Allotment>\n ) : (\n <DataPageLayout>{props.children}</DataPageLayout>\n )}\n </Page>\n </DataPageContext.Provider>\n );\n};\n\nDataPage.MenuItem = MenuItem;\nDataPage.MenuItems = MenuItems;\nDataPage.Columns = Columns;\n\nexport { DataPage };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;AAyDO,MAAM,QAAQ,GAAG,CAAC,MAAqB,KAAI;AAC9C,IAAA,OAAO,IAAI;AACf;AAuBA,MAAM,YAAY,GAAkB,EAAE,UAAU,EAAE,CAAC,EAAE;AAQrD,MAAM,gBAAgB,GAAkB,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;AAQnF,MAAM,SAAS,GAAkB,EAAE,SAAS,EAAE,OAAO,EAAE;MAS1C,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAkB,KAAI;AACtD,IAAA,MAAM,OAAO,GAAG,kBAAkB,EAAE;AACpC,IAAA,MAAM,UAAU,GACZ,OAAO,CAAC,aAAa,KAAK;AACtB,UAAE,OAAO,CAAC,aAAa,CAAC,MAAM,KAAK;AACnC,UAAE,CAAC,OAAO,CAAC,YAAY;AAE/B,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,MAAK;QACvB,MAAM,SAAS,GAAqB,EAAE;QACtC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,KAAI;AACvC,YAAA,IAAI,KAAK,CAAC,cAAc,CAAgB,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;AACvE,gBAAA,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI;gBAC7B,SAAS,CAAC,IAAI,CAAC;AACX,oBAAA,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK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A,IAAC,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,EAAA,CACW,CACpB,CAAA,EAAA,CACO,KAEZA,GAAA,CAAC,cAAc,EAAA,EAAA,QAAA,EAAE,KAAK,CAAC,QAAQ,EAAA,CAAkB,CACpD,EAAA,CACE,EAAA,CACgB;AAEnC;AAEA,QAAQ,CAAC,QAAQ,GAAG,QAAQ;AAC5B,QAAQ,CAAC,SAAS,GAAG,SAAS;AAC9B,QAAQ,CAAC,OAAO,GAAG,OAAO;;"}
|
|
1
|
+
{"version":3,"file":"DataPage.js","sources":["../../../DataPage/DataPage.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { type CSSProperties, type ReactNode, useMemo } from 'react';\nimport { Page } from '../Common/Page';\nimport React from 'react';\nimport { ActionMenubar, type ActionMenuItem } from '../Common/ActionMenubar';\nimport type { ButtonParts } from '../Common/Button';\nimport { type IObservableQueryFor, type IQueryFor, QueryFor } from '@cratis/arc/queries';\nimport { DataTableForObservableQuery } from '../DataTables/DataTableForObservableQuery';\nimport type { DataTableParts } from '../DataTables/DataTableCore';\nimport { DataTableForQuery } from '../DataTables/DataTableForQuery';\nimport type {\n TablePaginatorParts,\n TablePaginatorProps,\n} from '../DataTables/TablePaginator';\nimport type { DataTableFilterMeta } from '../DataTables/DataTableFilterMeta';\nimport type { DataTableSelectionChangeEvent } from '../DataTables/DataTableSelectionChangeEvent';\nimport type { DataTableServerQuery } from '../DataTables/DataTableServerQuery';\nimport { Allotment } from 'allotment';\nimport type { Constructor } from '@cratis/fundamentals';\nimport { DataPageLayout } from './DataPageLayout';\nimport type { DataPageSelection } from './DataPageSelection';\nimport { adaptMenuItem } from './adaptMenuItem';\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 *\n * @typeParam TDataType - The surrounding page's row type. JSX does not infer it from the parent.\n */\nexport interface MenuItemProps<TDataType extends object = object> {\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 with the immutable, committed selection when the enabled item is activated. */\n command?: (selection: DataPageSelection<TDataType>) => void;\n /** A boolean or selection predicate; when true, the item cannot dispatch its command. */\n disabled?: boolean | ((selection: DataPageSelection<TDataType>) => 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. Supply the page's row type explicitly\n * as `<DataPage.MenuItem<Person>>` for typed row access in callbacks.\n *\n * @typeParam TDataType - The surrounding page's row type, not inferred from its JSX parent.\n */\nexport const MenuItem = <TDataType extends object = object,>(_props: MenuItemProps<TDataType>) => {\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 selection = useMemo<DataPageSelection>(() => context.selectionMode === 'multiple'\n ? Object.freeze({ selectionMode: 'multiple', selectedItems: Object.freeze([...context.selectedItems]) })\n : Object.freeze({ selectionMode: 'single', selectedItem: context.selectedItem }),\n [context.selectionMode, context.selectedItem, context.selectedItems]);\n\n const items = useMemo(() => {\n const menuItems: ActionMenuItem[] = [];\n React.Children.forEach(children, (child) => {\n // SAFETY: Marker generics are erased by React children. Consumers explicitly\n // supply this page's row type on MenuItem; the private context never escapes.\n if (React.isValidElement<MenuItemProps>(child) && child.type === MenuItem) {\n menuItems.push(adaptMenuItem(child.props, selection));\n }\n });\n\n return menuItems;\n }, [children, selection]);\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 /** Whether the page content is a main landmark. Defaults to true; set false inside an existing main. */\n landmark?: boolean;\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 /**\n * The message to show instead of {@link emptyMessage} when a search or column filter is active\n * and no rows are shown. Defaults to a localizable message that says only the loaded page was\n * searched, or, with `serverQuery`, a neutral \"No rows match the search.\".\n */\n filteredEmptyMessage?: ReactNode;\n\n /** Notified of every change to the search text, as typed. */\n onGlobalFilterChange?: (globalFilter: string) => void;\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, including replacement or removal of its query row.\n * With a controlled selection, the consumer must accept the new value. Without a callback,\n * the controlled value and its details remain unchanged even if the query row disappears.\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} landmark={props.landmark} panel={true} style={pageStyle} data-cratis-component='DataPage'>\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":";;;;;;;;;;;AAgEO,MAAM,QAAQ,GAAG,CAAqC,MAAgC,KAAI;AAC7F,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;IACpC,MAAM,SAAS,GAAG,OAAO,CAAoB,MAAM,OAAO,CAAC,aAAa,KAAK;UACvE,MAAM,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC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AA,CAAC,SAAS,EAAA,EAAC,SAAS,EAAC,eAAe,EAAC,kBAAkB,EAAE,KAAK,EAAA,QAAA,EAAA,CAC1DD,GAAA,CAAC,SAAS,CAAC,IAAI,EAAA,EAAA,QAAA,EACXA,GAAA,CAAC,cAAc,EAAA,EAAA,QAAA,EAAE,KAAK,CAAC,QAAQ,EAAA,CAAkB,EAAA,CACpC,EAChB,YAAY,KACTA,IAAC,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,EAAA,CACW,CACpB,CAAA,EAAA,CACO,KAEZA,GAAA,CAAC,cAAc,EAAA,EAAA,QAAA,EAAE,KAAK,CAAC,QAAQ,EAAA,CAAkB,CACpD,EAAA,CACE,EAAA,CACgB;AAEnC;AAEA,QAAQ,CAAC,QAAQ,GAAG,QAAQ;AAC5B,QAAQ,CAAC,SAAS,GAAG,SAAS;AAC9B,QAAQ,CAAC,OAAO,GAAG,OAAO;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The selection committed by a {@link DataPage} when a menu action is rendered.
|
|
3
|
+
* The container and multiple-selection array are immutable; application row
|
|
4
|
+
* objects are not deep-frozen. Narrow `selectionMode` before accessing the row(s).
|
|
5
|
+
*
|
|
6
|
+
* @typeParam TDataType - The page's row type, supplied explicitly on `DataPage.MenuItem`.
|
|
7
|
+
*/
|
|
8
|
+
export type DataPageSelection<TDataType extends object = object> = {
|
|
9
|
+
/** A page that selects one row at a time. */
|
|
10
|
+
readonly selectionMode: 'single';
|
|
11
|
+
/** The selected row, or null/undefined when nothing is selected. */
|
|
12
|
+
readonly selectedItem: TDataType | null | undefined;
|
|
13
|
+
} | {
|
|
14
|
+
/** A page that selects multiple rows. */
|
|
15
|
+
readonly selectionMode: 'multiple';
|
|
16
|
+
/** The selected rows at render time, copied independently of the page's array. */
|
|
17
|
+
readonly selectedItems: readonly TDataType[];
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=DataPageSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataPageSelection.d.ts","sourceRoot":"","sources":["../../../DataPage/DataPageSelection.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,IACzD;IACE,6CAA6C;IAC7C,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;IACjC,oEAAoE;IACpE,QAAQ,CAAC,YAAY,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;CACvD,GACC;IACE,yCAAyC;IACzC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;IACnC,kFAAkF;IAClF,QAAQ,CAAC,aAAa,EAAE,SAAS,SAAS,EAAE,CAAC;CAChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataPageSelection.js","sourceRoot":"","sources":["../../../DataPage/DataPageSelection.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\n/**\n * The selection committed by a {@link DataPage} when a menu action is rendered.\n * The container and multiple-selection array are immutable; application row\n * objects are not deep-frozen. Narrow `selectionMode` before accessing the row(s).\n *\n * @typeParam TDataType - The page's row type, supplied explicitly on `DataPage.MenuItem`.\n */\nexport type DataPageSelection<TDataType extends object = object> =\n | {\n /** A page that selects one row at a time. */\n readonly selectionMode: 'single';\n /** The selected row, or null/undefined when nothing is selected. */\n readonly selectedItem: TDataType | null | undefined;\n }\n | {\n /** A page that selects multiple rows. */\n readonly selectionMode: 'multiple';\n /** The selected rows at render time, copied independently of the page's array. */\n readonly selectedItems: readonly TDataType[];\n };\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ActionMenuItem } from '../Common/ActionMenubar.js';
|
|
2
|
+
import type { MenuItemProps } from './DataPage.js';
|
|
3
|
+
import type { DataPageSelection } from './DataPageSelection.js';
|
|
4
|
+
export declare function adaptMenuItem(props: MenuItemProps, selection: DataPageSelection): ActionMenuItem;
|
|
5
|
+
//# sourceMappingURL=adaptMenuItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptMenuItem.d.ts","sourceRoot":"","sources":["../../../DataPage/adaptMenuItem.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAY,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAqB,CAAC;AAE7D,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,iBAAiB,GAAG,cAAc,CAgBhG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
function adaptMenuItem(props, selection) {
|
|
4
|
+
const Icon = props.icon;
|
|
5
|
+
const unselected = selection.selectionMode === 'multiple'
|
|
6
|
+
? selection.selectedItems.length === 0
|
|
7
|
+
: !selection.selectedItem;
|
|
8
|
+
const disabled = (typeof props.disabled === 'function' ? props.disabled(selection) : props.disabled ?? false)
|
|
9
|
+
|| (unselected && (props.disableOnUnselected ?? false));
|
|
10
|
+
return {
|
|
11
|
+
label: props.label,
|
|
12
|
+
icon: Icon ? jsx(Icon, { className: 'cratis:mr-2' }) : undefined,
|
|
13
|
+
disabled,
|
|
14
|
+
command: () => {
|
|
15
|
+
if (!disabled)
|
|
16
|
+
props.command?.(selection);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { adaptMenuItem };
|
|
22
|
+
//# sourceMappingURL=adaptMenuItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptMenuItem.js","sources":["../../../DataPage/adaptMenuItem.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 { ActionMenuItem } from '../Common/ActionMenubar';\nimport type { MenuItemProps } from './DataPage';\nimport type { DataPageSelection } from './DataPageSelection';\n\nexport function adaptMenuItem(props: MenuItemProps, selection: DataPageSelection): ActionMenuItem {\n const Icon = props.icon;\n const unselected = selection.selectionMode === 'multiple'\n ? selection.selectedItems.length === 0\n : !selection.selectedItem;\n const disabled = (typeof props.disabled === 'function' ? props.disabled(selection) : props.disabled ?? false)\n || (unselected && (props.disableOnUnselected ?? false));\n\n return {\n label: props.label,\n icon: Icon ? <Icon className='cratis:mr-2' /> : undefined,\n disabled,\n command: () => {\n if (!disabled) props.command?.(selection);\n },\n };\n}\n"],"names":["_jsx"],"mappings":";;AAOM,SAAU,aAAa,CAAC,KAAoB,EAAE,SAA4B,EAAA;AAC5E,IAAA,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI;AACvB,IAAA,MAAM,UAAU,GAAG,SAAS,CAAC,aAAa,KAAK;AAC3C,UAAE,SAAS,CAAC,aAAa,CAAC,MAAM,KAAK;AACrC,UAAE,CAAC,SAAS,CAAC,YAAY;IAC7B,MAAM,QAAQ,GAAG,CAAC,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK;YACpG,UAAU,KAAK,KAAK,CAAC,mBAAmB,IAAI,KAAK,CAAC,CAAC;IAE3D,OAAO;QACH,KAAK,EAAE,KAAK,CAAC,KAAK;AAClB,QAAA,IAAI,EAAE,IAAI,GAAGA,GAAA,CAAC,IAAI,EAAA,EAAC,SAAS,EAAC,aAAa,EAAA,CAAG,GAAG,SAAS;QACzD,QAAQ;QACR,OAAO,EAAE,MAAK;AACV,YAAA,IAAI,CAAC,QAAQ;AAAE,gBAAA,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC;QAC7C,CAAC;KACJ;AACL;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../DataPage/index.ts"],"names":[],"mappings":"AAGA,cAAc,eAAY,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../DataPage/index.ts"],"names":[],"mappings":"AAGA,cAAc,eAAY,CAAC;AAC3B,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAqB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAsB,CAAC"}
|
package/package.json
CHANGED