@cratis/components 4.53.0 → 4.55.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 +13 -13
- package/dist/esm/CommandDialog/CommandDialog.d.ts +9 -1
- package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.js +10 -4
- package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/esm/CommandDialog/index.d.ts +1 -0
- package/dist/esm/CommandDialog/index.d.ts.map +1 -1
- package/dist/esm/CommandDialog/validationFeedback.d.ts +28 -0
- package/dist/esm/CommandDialog/validationFeedback.d.ts.map +1 -0
- package/dist/esm/CommandDialog/validationFeedback.js +20 -0
- package/dist/esm/CommandDialog/validationFeedback.js.map +1 -0
- package/dist/esm/Common/CratisComponentsProvider.d.ts +4 -0
- package/dist/esm/Common/CratisComponentsProvider.d.ts.map +1 -1
- package/dist/esm/Common/CratisComponentsProvider.js.map +1 -1
- package/dist/esm/DataTables/DataTableCard.d.ts +4 -0
- package/dist/esm/DataTables/DataTableCard.d.ts.map +1 -0
- package/dist/esm/DataTables/DataTableCard.js +43 -0
- package/dist/esm/DataTables/DataTableCard.js.map +1 -0
- package/dist/esm/DataTables/DataTableCardControls.d.ts +6 -0
- package/dist/esm/DataTables/DataTableCardControls.d.ts.map +1 -0
- package/dist/esm/DataTables/DataTableCardControls.js +27 -0
- package/dist/esm/DataTables/DataTableCardControls.js.map +1 -0
- package/dist/esm/DataTables/DataTableCards.d.ts +16 -0
- package/dist/esm/DataTables/DataTableCards.d.ts.map +1 -0
- package/dist/esm/DataTables/DataTableCards.js +40 -0
- package/dist/esm/DataTables/DataTableCards.js.map +1 -0
- package/dist/esm/DataTables/DataTableCore.d.ts +3 -1
- package/dist/esm/DataTables/DataTableCore.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableCore.js +8 -2
- package/dist/esm/DataTables/DataTableCore.js.map +1 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.d.ts +2 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.js +1 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.js.map +1 -1
- package/dist/esm/DataTables/DataTableForQuery.d.ts +2 -1
- package/dist/esm/DataTables/DataTableForQuery.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableForQuery.js +1 -1
- package/dist/esm/DataTables/DataTableForQuery.js.map +1 -1
- package/dist/esm/DataTables/DataTableHeaderCell.d.ts +2 -2
- package/dist/esm/DataTables/DataTableHeaderCell.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableHeaderCell.js +5 -19
- package/dist/esm/DataTables/DataTableHeaderCell.js.map +1 -1
- package/dist/esm/DataTables/DataTableHeaderContent.d.ts +11 -0
- package/dist/esm/DataTables/DataTableHeaderContent.d.ts.map +1 -0
- package/dist/esm/DataTables/DataTableHeaderContent.js +37 -0
- package/dist/esm/DataTables/DataTableHeaderContent.js.map +1 -0
- package/dist/esm/DataTables/DataTableMessages.d.ts +2 -0
- package/dist/esm/DataTables/DataTableMessages.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableMessages.js.map +1 -1
- package/dist/esm/DataTables/DataTableMobileLayoutProps.d.ts +8 -0
- package/dist/esm/DataTables/DataTableMobileLayoutProps.d.ts.map +1 -0
- package/dist/esm/DataTables/DataTableMobileLayoutProps.js +4 -0
- package/dist/esm/DataTables/DataTableMobileLayoutProps.js.map +1 -0
- package/dist/esm/DataTables/DataTableParts.d.ts +12 -0
- package/dist/esm/DataTables/DataTableParts.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableParts.js.map +1 -1
- package/dist/esm/DataTables/DataTableRow.d.ts +3 -1
- package/dist/esm/DataTables/DataTableRow.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableRow.js +3 -9
- package/dist/esm/DataTables/DataTableRow.js.map +1 -1
- package/dist/esm/DataTables/DataTableRows.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableRows.js +1 -1
- package/dist/esm/DataTables/DataTableRows.js.map +1 -1
- package/dist/esm/DataTables/dataTableCellContent.d.ts +5 -0
- package/dist/esm/DataTables/dataTableCellContent.d.ts.map +1 -0
- package/dist/esm/DataTables/dataTableCellContent.js +11 -0
- package/dist/esm/DataTables/dataTableCellContent.js.map +1 -0
- package/dist/esm/DataTables/useDataTableMessages.d.ts.map +1 -1
- package/dist/esm/DataTables/useDataTableMessages.js +2 -0
- package/dist/esm/DataTables/useDataTableMessages.js.map +1 -1
- package/dist/esm/DataTables/useDataTablePresentationFocus.d.ts +3 -0
- package/dist/esm/DataTables/useDataTablePresentationFocus.d.ts.map +1 -0
- package/dist/esm/DataTables/useDataTablePresentationFocus.js +45 -0
- package/dist/esm/DataTables/useDataTablePresentationFocus.js.map +1 -0
- package/dist/esm/DataTables/useMobileLayout.d.ts +4 -0
- package/dist/esm/DataTables/useMobileLayout.d.ts.map +1 -0
- package/dist/esm/DataTables/useMobileLayout.js +20 -0
- package/dist/esm/DataTables/useMobileLayout.js.map +1 -0
- package/dist/esm/DataTables/useRowSelection.d.ts.map +1 -1
- package/dist/esm/DataTables/useRowSelection.js +1 -1
- package/dist/esm/DataTables/useRowSelection.js.map +1 -1
- package/dist/esm/Dialogs/Dialog.d.ts +7 -0
- package/dist/esm/Dialogs/Dialog.d.ts.map +1 -1
- package/dist/esm/Dialogs/Dialog.js.map +1 -1
- package/dist/esm/Dialogs/DialogImplementation.d.ts.map +1 -1
- package/dist/esm/Dialogs/DialogImplementation.js +1 -0
- package/dist/esm/Dialogs/DialogImplementation.js.map +1 -1
- package/dist/esm/Dialogs/DialogRefusalFeedback.d.ts +11 -0
- package/dist/esm/Dialogs/DialogRefusalFeedback.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogRefusalFeedback.js +4 -0
- package/dist/esm/Dialogs/DialogRefusalFeedback.js.map +1 -0
- package/dist/esm/Dialogs/DialogSlotHost.d.ts.map +1 -1
- package/dist/esm/Dialogs/DialogSlotHost.js +1 -0
- package/dist/esm/Dialogs/DialogSlotHost.js.map +1 -1
- package/dist/esm/Dialogs/index.d.ts +1 -0
- package/dist/esm/Dialogs/index.d.ts.map +1 -1
- package/dist/esm/Dialogs/useDialogFocus.d.ts +5 -2
- package/dist/esm/Dialogs/useDialogFocus.d.ts.map +1 -1
- package/dist/esm/Dialogs/useDialogFocus.js +14 -7
- package/dist/esm/Dialogs/useDialogFocus.js.map +1 -1
- package/dist/esm/styles.DataPage.css +66 -0
- package/dist/esm/styles.DataTables.css +66 -0
- package/dist/esm/styles.SchemaEditor.css +66 -0
- package/dist/esm/styles.css +66 -0
- package/dist/esm/styles.renderer.builtin.css +66 -0
- package/dist/esm/types/parts.d.ts +21 -3
- package/dist/esm/types/parts.d.ts.map +1 -1
- package/dist/esm/types/parts.js +21 -3
- package/dist/esm/types/parts.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTableCardControls.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableCardControls.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAiB,CAAC;AAO1D,4FAA4F;AAC5F,eAAO,MAAM,qBAAqB,4EAA6E,kBAAkB,GAAG;IAAE,aAAa,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;CAAE,gCAyB5K,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cloneElement } from 'react';
|
|
3
|
+
import { classNames } from '../ClassNames/classNames.js';
|
|
4
|
+
import { useComponentPresentation } from '../configuration/identity/useComponentPresentation.js';
|
|
5
|
+
import { useCratisIcon } from '../configuration/useCratisIcon.js';
|
|
6
|
+
import { columnDescriptor } from './columnDescriptor.js';
|
|
7
|
+
import { DataTableSelectAll, DataTableHeaderContent } from './DataTableHeaderContent.js';
|
|
8
|
+
|
|
9
|
+
const CardColumnControl = (props) => {
|
|
10
|
+
const [columnProps, marker] = useComponentPresentation(columnDescriptor, props.column.props, props.column.props.field);
|
|
11
|
+
return jsx("div", { ...marker, children: jsx(DataTableHeaderContent, { ...props, cardMode: true, column: cloneElement(props.column, columnProps) }) });
|
|
12
|
+
};
|
|
13
|
+
const DataTableCardControls = ({ columns, parts: pt, messages, selection, selectionMode, ...controls }) => {
|
|
14
|
+
const icon = useCratisIcon();
|
|
15
|
+
const selectionProps = {
|
|
16
|
+
resolvedSelectAllAriaLabel: messages.resolvedSelectAllAriaLabel,
|
|
17
|
+
allFilteredRowsSelected: selection.allFilteredRowsSelected,
|
|
18
|
+
selectAllRef: selection.selectAllRef,
|
|
19
|
+
toggleSelectAll: selection.toggleSelectAll,
|
|
20
|
+
};
|
|
21
|
+
return (jsxs("div", { ...pt?.cardControls, className: classNames('cratis-datatable__card-controls', pt?.cardControls?.className), "data-cratis-component": 'DataTableCore', "data-cratis-part": 'card-controls', children: [selectionMode === 'multiple' && jsx(DataTableSelectAll, { ...selectionProps }), columns.filter(column => !column.props.selectionMode && (column.props.sortable || column.props.filter)).map((column, index) => (jsx(CardColumnControl, { ...controls, ...selectionProps, column: column, parts: pt, resolvedSelectionAriaLabel: messages.resolvedSelectionAriaLabel, sortAscendingIcon: icon('sortAscending', '▲'), sortDescendingIcon: icon('sortDescending', '▼'), cardSortDirection: controls.sort?.field === column.props.field
|
|
22
|
+
? controls.sort?.direction === 'ascending' ? messages.resolvedSortAscending : messages.resolvedSortDescending
|
|
23
|
+
: undefined }, index)))] }));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { DataTableCardControls };
|
|
27
|
+
//# sourceMappingURL=DataTableCardControls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTableCardControls.js","sources":["../../../DataTables/DataTableCardControls.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 { cloneElement } from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport { useComponentPresentation } from '../configuration/identity/useComponentPresentation';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport { columnDescriptor } from './columnDescriptor';\nimport { DataTableHeaderContent, DataTableSelectAll } from './DataTableHeaderContent';\nimport type { DataTableHeaderCellProps } from './DataTableHeaderCell';\nimport type { DataTableHeadProps } from './DataTableHead';\n\nconst CardColumnControl = (props: DataTableHeaderCellProps & { cardSortDirection?: string }) => {\n const [columnProps, marker] = useComponentPresentation(columnDescriptor, props.column.props, props.column.props.field);\n return <div {...marker}><DataTableHeaderContent {...props} cardMode column={cloneElement(props.column, columnProps)} /></div>;\n};\n\n/** The one reachable set of column and select-all controls while the table is unmounted. */\nexport const DataTableCardControls = ({ columns, parts: pt, messages, selection, selectionMode, ...controls }: DataTableHeadProps & { selectionMode?: 'single' | 'multiple' }) => {\n const icon = useCratisIcon();\n const selectionProps = {\n resolvedSelectAllAriaLabel: messages.resolvedSelectAllAriaLabel,\n allFilteredRowsSelected: selection.allFilteredRowsSelected,\n selectAllRef: selection.selectAllRef,\n toggleSelectAll: selection.toggleSelectAll,\n };\n return (\n <div {...pt?.cardControls} className={classNames('cratis-datatable__card-controls', pt?.cardControls?.className)} data-cratis-component='DataTableCore' data-cratis-part='card-controls'>\n {selectionMode === 'multiple' && <DataTableSelectAll {...selectionProps} />}\n {columns.filter(column => !column.props.selectionMode && (column.props.sortable || column.props.filter)).map((column, index) => (\n <CardColumnControl key={index} {...controls} {...selectionProps}\n column={column}\n parts={pt}\n resolvedSelectionAriaLabel={messages.resolvedSelectionAriaLabel}\n sortAscendingIcon={icon('sortAscending', '▲')}\n sortDescendingIcon={icon('sortDescending', '▼')}\n cardSortDirection={controls.sort?.field === column.props.field\n ? controls.sort?.direction === 'ascending' ? messages.resolvedSortAscending : messages.resolvedSortDescending\n : undefined}\n />\n ))}\n </div>\n );\n};\n"],"names":["_jsx","_j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AAa,KAAK,MAAM,CAAC,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,MACvHA,GAAA,CAAC,iBAAiB,EAAA,EAAA,GAAiB,QAAQ,EAAA,GAAM,cAAc,EAC3D,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,EAAE,EACT,0BAA0B,EAAE,QAAQ,CAAC,0BAA0B,EAC/D,iBAAiB,EAAE,IAAI,CAAC,eAAe,EAAE,GAAG,CAAC,EAC7C,kBAAkB,EAAE,IAAI,CAAC,gBAAgB,EAAE,GAAG,CAAC,EAC/C,iBAAiB,EAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC;AACrD,sBAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,KAAK,WAAW,GAAG,QAAQ,CAAC,qBAAqB,GAAG,QAAQ,CAAC;sBACrF,SAAS,EAAA,EARK,KAAK,CAS3B,CACL,CAAC,CAAA,EAAA,CACA;AAEd;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { DataTableRowsProps } from './DataTableRows.js';
|
|
3
|
+
import type { DataTableHeadProps } from './DataTableHead.js';
|
|
4
|
+
import { DataTableStatus } from './DataTableStatus.js';
|
|
5
|
+
interface DataTableCardsProps<TData extends object> extends Omit<DataTableRowsProps<TData>, 'resolvedSelectionAriaLabel'>, Omit<DataTableHeadProps, 'selection'> {
|
|
6
|
+
data: TData[];
|
|
7
|
+
status: DataTableStatus;
|
|
8
|
+
isBusy: boolean;
|
|
9
|
+
emptyMessage: ReactNode;
|
|
10
|
+
scrollable?: boolean;
|
|
11
|
+
scrollHeight?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Non-table presentation of the already processed loaded-page rows. */
|
|
14
|
+
export declare const DataTableCards: <TData extends object>(props: DataTableCardsProps<TData>) => import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=DataTableCards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTableCards.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableCards.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAiB,CAAC;AAG1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;AAEpD,UAAU,mBAAmB,CAAC,KAAK,SAAS,MAAM,CAAE,SAAQ,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,4BAA4B,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC;IAC5J,IAAI,EAAE,KAAK,EAAE,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,SAAS,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAuCD,wEAAwE;AACxE,eAAO,MAAM,cAAc,GAAI,KAAK,SAAS,MAAM,SAAS,mBAAmB,CAAC,KAAK,CAAC,gCAUrF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { classNames } from '../ClassNames/classNames.js';
|
|
3
|
+
import { DataTableCard } from './DataTableCard.js';
|
|
4
|
+
import { DataTableCardControls } from './DataTableCardControls.js';
|
|
5
|
+
import { DataTableStatus } from './DataTableStatus.js';
|
|
6
|
+
|
|
7
|
+
const isFailure = (status) => status === DataTableStatus.Failed || status === DataTableStatus.Unauthorized;
|
|
8
|
+
const statusMessage = ({ status, data, state, messages, emptyMessage }) => {
|
|
9
|
+
if (status === DataTableStatus.Failed)
|
|
10
|
+
return messages.resolvedFailureMessage;
|
|
11
|
+
if (status === DataTableStatus.Unauthorized)
|
|
12
|
+
return messages.resolvedUnauthorizedMessage;
|
|
13
|
+
if (status === DataTableStatus.Loading && !data.length)
|
|
14
|
+
return messages.resolvedLoadingMessage;
|
|
15
|
+
if (state.filteredRows.length)
|
|
16
|
+
return undefined;
|
|
17
|
+
return state.isFiltered ? messages.resolvedFilteredEmptyMessage : emptyMessage;
|
|
18
|
+
};
|
|
19
|
+
const CardStatus = (props) => {
|
|
20
|
+
const { parts: pt, status } = props;
|
|
21
|
+
const message = statusMessage(props);
|
|
22
|
+
if (message === undefined)
|
|
23
|
+
return null;
|
|
24
|
+
return jsx("div", { ...pt?.cardStatus, className: classNames('cratis-datatable__card-status', pt?.cardStatus?.className), "data-cratis-component": 'DataTableCore', "data-cratis-part": 'card-status', "data-reason": status, role: isFailure(status) ? 'alert' : 'status', children: message });
|
|
25
|
+
};
|
|
26
|
+
const CardList = ({ state, columns, parts: pt, messages, selectionMode, selectionGroupName, rowClassName, isBusy }) => (jsx("ul", { ...pt?.cards, role: 'list', className: classNames('cratis-datatable__cards', pt?.cards?.className), "data-cratis-component": 'DataTableCore', "data-cratis-part": 'cards', "data-busy": isBusy || undefined, "aria-busy": isBusy || undefined, children: state.filteredRows.map(({ row, loadedIndex }) => (jsx(DataTableCard, { rowKey: state.rowKeys[loadedIndex], row: row, columns: columns, parts: pt, selectionMode: selectionMode, isSelected: selectionMode === 'single' && state.isSelectedRow(row, loadedIndex), isInteractive: state.isInteractive, isRowSelected: state.isRowSelected(row), rowClassName: rowClassName, resolvedSelectionAriaLabel: messages.resolvedSelectionAriaLabel, selectionGroupName: selectionGroupName, onActivate: event => state.activateRow(row, loadedIndex, event), onToggleSelection: () => state.toggleRowSelection(row) }, state.rowKeys[loadedIndex]))) }));
|
|
27
|
+
const canShowRows = ({ status, data, state }) => {
|
|
28
|
+
if (isFailure(status))
|
|
29
|
+
return false;
|
|
30
|
+
if (status === DataTableStatus.Loading && !data.length)
|
|
31
|
+
return false;
|
|
32
|
+
return state.filteredRows.length > 0;
|
|
33
|
+
};
|
|
34
|
+
const DataTableCards = (props) => {
|
|
35
|
+
const { state, parts: pt, scrollable, scrollHeight } = props;
|
|
36
|
+
return (jsxs("div", { ...pt?.tableContainer, className: classNames('cratis-datatable__container', pt?.tableContainer?.className), style: { ...pt?.tableContainer?.style, ...(scrollable ? { maxHeight: scrollHeight ?? '100%', overflow: 'auto' } : {}) }, "data-cratis-part": 'table-container', children: [jsx(DataTableCardControls, { ...props, selection: state }), jsx(CardStatus, { ...props }), canShowRows(props) && jsx(CardList, { ...props })] }));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { DataTableCards };
|
|
40
|
+
//# sourceMappingURL=DataTableCards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTableCards.js","sources":["../../../DataTables/DataTableCards.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 { ReactNode } from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport type { DataTableRowsProps } from './DataTableRows';\nimport type { DataTableHeadProps } from './DataTableHead';\nimport { DataTableCard } from './DataTableCard';\nimport { DataTableCardControls } from './DataTableCardControls';\nimport { DataTableStatus } from './DataTableStatus';\n\ninterface DataTableCardsProps<TData extends object> extends Omit<DataTableRowsProps<TData>, 'resolvedSelectionAriaLabel'>, Omit<DataTableHeadProps, 'selection'> {\n data: TData[];\n status: DataTableStatus;\n isBusy: boolean;\n emptyMessage: ReactNode;\n scrollable?: boolean;\n scrollHeight?: string;\n}\n\nconst isFailure = (status: DataTableStatus) => status === DataTableStatus.Failed || status === DataTableStatus.Unauthorized;\nconst statusMessage = <TData extends object>({ status, data, state, messages, emptyMessage }: DataTableCardsProps<TData>): ReactNode => {\n if (status === DataTableStatus.Failed) return messages.resolvedFailureMessage;\n if (status === DataTableStatus.Unauthorized) return messages.resolvedUnauthorizedMessage;\n if (status === DataTableStatus.Loading && !data.length) return messages.resolvedLoadingMessage;\n if (state.filteredRows.length) return undefined;\n return state.isFiltered ? messages.resolvedFilteredEmptyMessage : emptyMessage;\n};\nconst CardStatus = <TData extends object>(props: DataTableCardsProps<TData>) => {\n const { parts: pt, status } = props;\n const message = statusMessage(props);\n if (message === undefined) return null;\n return <div {...pt?.cardStatus} className={classNames('cratis-datatable__card-status', pt?.cardStatus?.className)} data-cratis-component='DataTableCore' data-cratis-part='card-status' data-reason={status} role={isFailure(status) ? 'alert' : 'status'}>{message}</div>;\n};\nconst CardList = <TData extends object>({ state, columns, parts: pt, messages, selectionMode, selectionGroupName, rowClassName, isBusy }: DataTableCardsProps<TData>) => (\n <ul {...pt?.cards} role='list' className={classNames('cratis-datatable__cards', pt?.cards?.className)} data-cratis-component='DataTableCore' data-cratis-part='cards' data-busy={isBusy || undefined} aria-busy={isBusy || undefined}>\n {state.filteredRows.map(({ row, loadedIndex }) => (\n <DataTableCard key={state.rowKeys[loadedIndex]} rowKey={state.rowKeys[loadedIndex]} row={row} columns={columns} parts={pt}\n selectionMode={selectionMode}\n isSelected={selectionMode === 'single' && state.isSelectedRow(row, loadedIndex)}\n isInteractive={state.isInteractive}\n isRowSelected={state.isRowSelected(row)}\n rowClassName={rowClassName}\n resolvedSelectionAriaLabel={messages.resolvedSelectionAriaLabel}\n selectionGroupName={selectionGroupName}\n onActivate={event => state.activateRow(row, loadedIndex, event)}\n onToggleSelection={() => state.toggleRowSelection(row)}\n />\n ))}\n </ul>\n);\nconst canShowRows = <TData extends object>({ status, data, state }: DataTableCardsProps<TData>) => {\n if (isFailure(status)) return false;\n if (status === DataTableStatus.Loading && !data.length) return false;\n return state.filteredRows.length > 0;\n};\n\n/** Non-table presentation of the already processed loaded-page rows. */\nexport const DataTableCards = <TData extends object>(props: DataTableCardsProps<TData>) => {\n const { state, parts: pt, scrollable, scrollHeight } = props;\n return (\n <div {...pt?.tableContainer} className={classNames('cratis-datatable__container', pt?.tableContainer?.className)}\n style={{ ...pt?.tableContainer?.style, ...(scrollable ? { maxHeight: scrollHeight ?? '100%', overflow: 'auto' } : {}) }} data-cratis-part='table-container'>\n <DataTableCardControls {...props} selection={state} />\n <CardStatus {...props} />\n {canShowRows(props) && <CardList {...props} />}\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AAoBA,MAAM,SAAS,GAAG,CAAC,MAAuB,KAAK,MAAM,KAAK,eAAe,CAAC,MAAM,IAAI,MAAM,KAAK,eAAe,CAAC,YAAY;AAC3H,MAAM,aAAa,GAAG,CAAuB,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAA8B,KAAe;AACnI,IAAA,IAAI,MAAM,KAAK,eAAe,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAC,sBAAsB;AAC7E,IAAA,IAAI,MAAM,KAAK,eAAe,CAAC,YAAY;QAAE,OAAO,QAAQ,CAAC,2BAA2B;IACxF,IAAI,MAAM,KAAK,eAAe,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAC,sBAAsB;AAC9F,IAAA,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM;AAAE,QAAA,OAAO,SAAS;AAC/C,IAAA,OAAO,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC,4BAA4B,GAAG,YAAY;AAClF,CAAC;AACD,MAAM,UAAU,GAAG,CAAuB,KAAiC,KAAI;IAC3E,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,KAAK;AACnC,IAAA,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC;IACpC,IAAI,OAAO,KAAK,SAAS;AAAE,QAAA,OAAO,IAAI;AACtC,IAAA,OAAOA,gBAAS,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,+BAA+B,EAAE,EA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;AAEd;;"}
|
|
@@ -6,10 +6,12 @@ import { DataTableRowProcessing } from './DataTableRowProcessing.js';
|
|
|
6
6
|
import type { DataTableSelectionChangeEvent } from './DataTableSelectionChangeEvent.js';
|
|
7
7
|
import type { DataTableSort } from './DataTableSort.js';
|
|
8
8
|
import { DataTableStatus } from './DataTableStatus.js';
|
|
9
|
+
import type { DataTableMobileLayoutProps } from './DataTableMobileLayoutProps.js';
|
|
9
10
|
export type { DataTableParts } from './DataTableParts.js';
|
|
11
|
+
export type { DataTableMobileLayoutProps } from './DataTableMobileLayoutProps.js';
|
|
10
12
|
export type { DataTableRowClickEvent } from './DataTableRowClickEvent.js';
|
|
11
13
|
/** Props for the semantic loaded-page DataTable renderer. */
|
|
12
|
-
export interface DataTableCoreProps<TData extends object> {
|
|
14
|
+
export interface DataTableCoreProps<TData extends object> extends DataTableMobileLayoutProps {
|
|
13
15
|
/** Loaded page rows. */
|
|
14
16
|
data: TData[];
|
|
15
17
|
/** Declarative {@link Column} markers. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableCore.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableCore.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAkB,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA0B,CAAC;AAIvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oCAAiC,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAiB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;
|
|
1
|
+
{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C,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,6FAA6F;IAC7F,IAAI,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC;IACpD;;;;OAIG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,4CAA4C;IAC5C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,wCAAwC;IACxC,EAAE,CAAC,EAAE,cAAc,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AA2BD,gFAAgF;AAChF,eAAO,MAAM,aAAa,GAAI,KAAK,SAAS,MAAM,SAAS,kBAAkB,CAAC,KAAK,CAAC,sBA6FnF,CAAC"}
|
|
@@ -11,14 +11,20 @@ import { DataTableTable } from './DataTableTable.js';
|
|
|
11
11
|
import { useDataTableMessages } from './useDataTableMessages.js';
|
|
12
12
|
import { useDataTableRows } from './useDataTableRows.js';
|
|
13
13
|
import { useDataTableState } from './useDataTableState.js';
|
|
14
|
+
import { useMobileLayout } from './useMobileLayout.js';
|
|
15
|
+
import { DataTableCards } from './DataTableCards.js';
|
|
16
|
+
import { useDataTablePresentationFocus } from './useDataTablePresentationFocus.js';
|
|
14
17
|
|
|
15
18
|
const useColumns = (children) => useMemo(() => React.Children.toArray(children).filter(React.isValidElement), [children]);
|
|
19
|
+
const DataTableRoot = ({ children, scrollable, className, style, pt, mobileLayout, elementRef, isBusy }) => (jsx("div", { ...pt?.root, ref: elementRef, tabIndex: pt?.root?.tabIndex ?? (mobileLayout === 'cards' ? -1 : undefined), className: classNames('cratis-datatable', scrollable ? 'cratis-datatable--scrollable' : undefined, pt?.root?.className, className), style: { ...pt?.root?.style, ...style }, "data-cratis-part": 'root', "data-cratis-component": 'DataTableCore', "data-busy": isBusy || undefined, children: children }));
|
|
16
20
|
const DataTableCore = (props) => {
|
|
17
|
-
const { data, status = DataTableStatus.Ready, rowProcessing = DataTableRowProcessing.Loaded, globalFilterFields, scrollable,
|
|
21
|
+
const { data, status = DataTableStatus.Ready, rowProcessing = DataTableRowProcessing.Loaded, globalFilterFields, scrollable, pt, } = props;
|
|
18
22
|
const messages = useDataTableMessages(props, rowProcessing === DataTableRowProcessing.None);
|
|
19
23
|
const isBusy = status === DataTableStatus.Loading && data.length > 0;
|
|
20
24
|
const columns = useColumns(props.children);
|
|
21
25
|
const selectionGroupName = useId();
|
|
26
|
+
const useCards = useMobileLayout(props);
|
|
27
|
+
const presentationRoot = useDataTablePresentationFocus(useCards);
|
|
22
28
|
const { filters, updateFilter, globalFilter, setGlobalFilter, sort, setSort } = useDataTableState(props);
|
|
23
29
|
const rows = useDataTableRows({
|
|
24
30
|
...props,
|
|
@@ -27,7 +33,7 @@ const DataTableCore = (props) => {
|
|
|
27
33
|
sort,
|
|
28
34
|
rowProcessing,
|
|
29
35
|
});
|
|
30
|
-
return (jsxs(
|
|
36
|
+
return (jsxs(DataTableRoot, { ...props, elementRef: presentationRoot, isBusy: isBusy, children: [!!globalFilterFields?.length && (jsx(DataTableSearch, { parts: pt, value: globalFilter, placeholder: messages.resolvedGlobalSearchPlaceholder, ariaLabel: messages.resolvedGlobalSearchAriaLabel, onChange: setGlobalFilter })), useCards ? (jsx(DataTableCards, { ...props, state: rows, columns: columns, parts: pt, messages: messages, status: status, isBusy: isBusy, sort: sort, onSort: setSort, filters: filters, updateFilter: updateFilter, selectionGroupName: selectionGroupName })) : jsx(DataTableTable, { parts: pt, isBusy: isBusy, scrollable: scrollable, scrollHeight: props.scrollHeight, head: jsx(DataTableHead, { columns: columns, parts: pt, sort: sort, onSort: setSort, filters: filters, updateFilter: updateFilter, messages: messages, selection: rows }), children: jsx(DataTableBody, { status: status, hasLoadedRows: data.length > 0, rowCount: rows.filteredRows.length, columnCount: columns.length, parts: pt, messages: messages, emptyMessage: props.emptyMessage, isFiltered: rows.isFiltered, renderRows: () => (jsx(DataTableRows, { state: rows, columns: columns, parts: pt, selectionMode: props.selectionMode, rowClassName: props.rowClassName, resolvedSelectionAriaLabel: messages.resolvedSelectionAriaLabel, selectionGroupName: selectionGroupName })) }) })] }));
|
|
31
37
|
};
|
|
32
38
|
|
|
33
39
|
export { DataTableCore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableCore.js","sources":["../../../DataTables/DataTableCore.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 React, { useId, useMemo, type CSSProperties, type ReactNode } from 'react';\nimport type { ColumnProps } from './Column';\nimport { classNames } from '../ClassNames/classNames';\nimport type { DataTableFilterMeta } from './DataTableFilterMeta';\nimport { DataTableHead } from './DataTableHead';\nimport type { DataTableParts } from './DataTableParts';\nimport type { DataTableRowClickEvent } from './DataTableRowClickEvent';\nimport { DataTableBody } from './DataTableBody';\nimport { DataTableRows } from './DataTableRows';\nimport { DataTableSearch } from './DataTableSearch';\nimport { DataTableRowProcessing } from './DataTableRowProcessing';\nimport type { DataTableSelectionChangeEvent } from './DataTableSelectionChangeEvent';\nimport type { DataTableSort } from './DataTableSort';\nimport { DataTableStatus } from './DataTableStatus';\nimport { DataTableTable } from './DataTableTable';\nimport { useDataTableMessages } from './useDataTableMessages';\nimport { useDataTableRows } from './useDataTableRows';\nimport { useDataTableState } from './useDataTableState';\n\nexport type { DataTableParts } from './DataTableParts';\nexport type { DataTableRowClickEvent } from './DataTableRowClickEvent';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nconst useColumns = (children: React.ReactNode): React.ReactElement<ColumnProps<any>>[] =>\n useMemo(\n () =>\n React.Children.toArray(children).filter(\n React.isValidElement,\n ) as React.ReactElement<ColumnProps<any>>[],\n [children],\n );\n\n/** Props for the semantic loaded-page DataTable renderer. */\nexport interface DataTableCoreProps<TData extends object> {\n /** Loaded page rows. */\n data: TData[];\n /** Declarative {@link Column} markers. */\n children?: ReactNode;\n /** Row property used as stable identity. Required to preserve selection across refreshed row objects. */\n dataKey?: string;\n /** Content shown when the loaded page has no matching rows. */\n emptyMessage: ReactNode;\n /**\n * Content shown instead of {@link emptyMessage} when a search or column filter is active and no\n * rows are shown. Defaults to a localizable message that names the loaded page, or a neutral\n * one when the server applies the search.\n */\n filteredEmptyMessage?: ReactNode;\n /** Table display state. Defaults to ready. */\n status?: DataTableStatus;\n /** Message shown while loading without rows. */\n loadingMessage?: ReactNode;\n /** Message shown for a failed query. */\n failureMessage?: ReactNode;\n /** Message shown for an unauthorized query. */\n unauthorizedMessage?: ReactNode;\n /**\n * Enables row selection. `'single'` selects one row at a time through row activation;\n * `'multiple'` adds per-row checkboxes and a select-all header checkbox, and reports through\n * {@link onSelectedItemsChange} rather than {@link onSelectionChange}.\n */\n selectionMode?: 'single' | 'multiple';\n /** Accessible name for row selection controls. Falls back to the provider's `dataTable.selectRow` message, then `'Select row'`. */\n selectionAriaLabel?: string;\n /** Accessible name for the select-all control. Falls back to the provider's `dataTable.selectAllRows` message, then `'Select all rows'`. */\n selectAllAriaLabel?: string;\n /** Controlled selected row. Applies to `selectionMode='single'`. */\n selection?: TData | null;\n /** Invoked when the single-row selection changes. */\n onSelectionChange?: (event: DataTableSelectionChangeEvent<TData>) => void;\n /** Controlled selected rows. Applies to `selectionMode='multiple'`. */\n selectedItems?: TData[];\n /** Invoked with the full set of selected rows when a multiple selection changes. */\n onSelectedItemsChange?: (items: TData[]) => void;\n /** Invoked when a row is clicked or keyboard activated. */\n onRowClick?: (event: DataTableRowClickEvent<TData>) => void;\n /** Builds an extra class name for one row. */\n rowClassName?: (rowData: TData) => string;\n /** Row fields searched on the loaded page. */\n globalFilterFields?: string[];\n /** Placeholder for the loaded-page search input. Falls back to the provider's `dataTable.search` message, then `'Search…'`. */\n globalSearchPlaceholder?: string;\n /** Accessible name for the loaded-page search input. Falls back to the provider's `dataTable.searchAriaLabel` message, then `'Search table'`. */\n globalSearchAriaLabel?: string;\n /** Initial per-field filter constraints. */\n defaultFilters?: DataTableFilterMeta;\n /** Controlled per-field filter constraints. Leave undefined to let the table keep its own. */\n filters?: DataTableFilterMeta;\n /** Invoked when applied field filters change. */\n onFilter?: (filters: DataTableFilterMeta) => void;\n /** Controlled search text. Leave undefined to let the table keep its own. */\n globalFilter?: string;\n /** Invoked when the search text changes. */\n onGlobalFilterChange?: (globalFilter: string) => void;\n /** Controlled sort; null means not sorted. Leave undefined to let the table keep its own. */\n sort?: DataTableSort | null;\n /** Invoked when a sortable column header changes the sort. */\n onSortChange?: (sort: DataTableSort | null) => void;\n /**\n * Whether the table filters and sorts the rows it is given (default:\n * {@link DataTableRowProcessing.Loaded}). Use {@link DataTableRowProcessing.None} when the\n * source already applied the controlled filter and sort state.\n */\n rowProcessing?: DataTableRowProcessing;\n /** Enables the bounded scroll container. */\n scrollable?: boolean;\n /** Scroll-container maximum height. */\n scrollHeight?: string;\n /** Extra class name for the table composition. */\n className?: string;\n /** Inline style for the table composition. */\n style?: CSSProperties;\n /** Cratis-owned per-part attributes. */\n pt?: DataTableParts;\n /**\n * @deprecated Cratis parts always merge. Remove this renderer-era option.\n */\n ptOptions?: object;\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `pt` and CSS instead.\n */\n unstyled?: boolean;\n}\n\n/** A semantic, renderer-independent data table over one already-loaded page. */\nexport const DataTableCore = <TData extends object>(props: DataTableCoreProps<TData>) => {\n const {\n data,\n status = DataTableStatus.Ready,\n rowProcessing = DataTableRowProcessing.Loaded,\n globalFilterFields,\n scrollable,\n className,\n style,\n pt,\n } = props;\n const messages = useDataTableMessages(props, rowProcessing === DataTableRowProcessing.None);\n const isBusy = status === DataTableStatus.Loading && data.length > 0;\n const columns = useColumns(props.children);\n const selectionGroupName = useId();\n const { filters, updateFilter, globalFilter, setGlobalFilter, sort, setSort } =\n useDataTableState(props);\n const rows = useDataTableRows<TData>({\n ...props,\n filters,\n globalFilter,\n sort,\n rowProcessing,\n });\n\n return (\n <div\n {...pt?.root}\n className={classNames(\n 'cratis-datatable',\n scrollable ? 'cratis-datatable--scrollable' : undefined,\n pt?.root?.className,\n className,\n )}\n style={{ ...pt?.root?.style, ...style }}\n data-cratis-part='root'\n data-cratis-component='DataTableCore'\n data-busy={isBusy || undefined}\n >\n {!!globalFilterFields?.length && (\n <DataTableSearch\n parts={pt}\n value={globalFilter}\n placeholder={messages.resolvedGlobalSearchPlaceholder}\n ariaLabel={messages.resolvedGlobalSearchAriaLabel}\n onChange={setGlobalFilter}\n />\n )}\n <DataTableTable\n parts={pt}\n isBusy={isBusy}\n scrollable={scrollable}\n scrollHeight={props.scrollHeight}\n head={\n <DataTableHead\n columns={columns}\n parts={pt}\n sort={sort}\n onSort={setSort}\n filters={filters}\n updateFilter={updateFilter}\n messages={messages}\n selection={rows}\n />\n }\n >\n <DataTableBody\n status={status}\n hasLoadedRows={data.length > 0}\n rowCount={rows.filteredRows.length}\n columnCount={columns.length}\n parts={pt}\n messages={messages}\n emptyMessage={props.emptyMessage}\n isFiltered={rows.isFiltered}\n renderRows={() => (\n <DataTableRows<TData>\n state={rows}\n columns={columns}\n parts={pt}\n selectionMode={props.selectionMode}\n rowClassName={props.rowClassName}\n resolvedSelectionAriaLabel={messages.resolvedSelectionAriaLabel}\n selectionGroupName={selectionGroupName}\n />\n )}\n />\n </DataTableTable>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,UAAU,GAAG,CAAC,QAAyB,KACzC,OAAO,CACH,MACI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CACnC,KAAK,CAAC,cAA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
|
1
|
+
{"version":3,"file":"DataTableCore.js","sources":["../../../DataTables/DataTableCore.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 React, { useId, useMemo, type CSSProperties, type ReactNode } from 'react';\nimport type { ColumnProps } from './Column';\nimport { classNames } from '../ClassNames/classNames';\nimport type { DataTableFilterMeta } from './DataTableFilterMeta';\nimport { DataTableHead } from './DataTableHead';\nimport type { DataTableParts } from './DataTableParts';\nimport type { DataTableRowClickEvent } from './DataTableRowClickEvent';\nimport { DataTableBody } from './DataTableBody';\nimport { DataTableRows } from './DataTableRows';\nimport { DataTableSearch } from './DataTableSearch';\nimport { DataTableRowProcessing } from './DataTableRowProcessing';\nimport type { DataTableSelectionChangeEvent } from './DataTableSelectionChangeEvent';\nimport type { DataTableSort } from './DataTableSort';\nimport { DataTableStatus } from './DataTableStatus';\nimport { DataTableTable } from './DataTableTable';\nimport { useDataTableMessages } from './useDataTableMessages';\nimport { useDataTableRows } from './useDataTableRows';\nimport { useDataTableState } from './useDataTableState';\nimport type { DataTableMobileLayoutProps } from './DataTableMobileLayoutProps';\nimport { useMobileLayout } from './useMobileLayout';\nimport { DataTableCards } from './DataTableCards';\nimport { useDataTablePresentationFocus } from './useDataTablePresentationFocus';\n\nexport type { DataTableParts } from './DataTableParts';\nexport type { DataTableMobileLayoutProps } from './DataTableMobileLayoutProps';\nexport type { DataTableRowClickEvent } from './DataTableRowClickEvent';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nconst useColumns = (children: React.ReactNode): React.ReactElement<ColumnProps<any>>[] =>\n useMemo(\n () =>\n React.Children.toArray(children).filter(\n React.isValidElement,\n ) as React.ReactElement<ColumnProps<any>>[],\n [children],\n );\n\n/** Props for the semantic loaded-page DataTable renderer. */\nexport interface DataTableCoreProps<TData extends object> extends DataTableMobileLayoutProps {\n /** Loaded page rows. */\n data: TData[];\n /** Declarative {@link Column} markers. */\n children?: ReactNode;\n /** Row property used as stable identity. Required to preserve selection across refreshed row objects. */\n dataKey?: string;\n /** Content shown when the loaded page has no matching rows. */\n emptyMessage: ReactNode;\n /**\n * Content shown instead of {@link emptyMessage} when a search or column filter is active and no\n * rows are shown. Defaults to a localizable message that names the loaded page, or a neutral\n * one when the server applies the search.\n */\n filteredEmptyMessage?: ReactNode;\n /** Table display state. Defaults to ready. */\n status?: DataTableStatus;\n /** Message shown while loading without rows. */\n loadingMessage?: ReactNode;\n /** Message shown for a failed query. */\n failureMessage?: ReactNode;\n /** Message shown for an unauthorized query. */\n unauthorizedMessage?: ReactNode;\n /**\n * Enables row selection. `'single'` selects one row at a time through row activation;\n * `'multiple'` adds per-row checkboxes and a select-all header checkbox, and reports through\n * {@link onSelectedItemsChange} rather than {@link onSelectionChange}.\n */\n selectionMode?: 'single' | 'multiple';\n /** Accessible name for row selection controls. Falls back to the provider's `dataTable.selectRow` message, then `'Select row'`. */\n selectionAriaLabel?: string;\n /** Accessible name for the select-all control. Falls back to the provider's `dataTable.selectAllRows` message, then `'Select all rows'`. */\n selectAllAriaLabel?: string;\n /** Controlled selected row. Applies to `selectionMode='single'`. */\n selection?: TData | null;\n /** Invoked when the single-row selection changes. */\n onSelectionChange?: (event: DataTableSelectionChangeEvent<TData>) => void;\n /** Controlled selected rows. Applies to `selectionMode='multiple'`. */\n selectedItems?: TData[];\n /** Invoked with the full set of selected rows when a multiple selection changes. */\n onSelectedItemsChange?: (items: TData[]) => void;\n /** Invoked when a row is clicked or keyboard activated. */\n onRowClick?: (event: DataTableRowClickEvent<TData>) => void;\n /** Builds an extra class name for one row. */\n rowClassName?: (rowData: TData) => string;\n /** Row fields searched on the loaded page. */\n globalFilterFields?: string[];\n /** Placeholder for the loaded-page search input. Falls back to the provider's `dataTable.search` message, then `'Search…'`. */\n globalSearchPlaceholder?: string;\n /** Accessible name for the loaded-page search input. Falls back to the provider's `dataTable.searchAriaLabel` message, then `'Search table'`. */\n globalSearchAriaLabel?: string;\n /** Initial per-field filter constraints. */\n defaultFilters?: DataTableFilterMeta;\n /** Controlled per-field filter constraints. Leave undefined to let the table keep its own. */\n filters?: DataTableFilterMeta;\n /** Invoked when applied field filters change. */\n onFilter?: (filters: DataTableFilterMeta) => void;\n /** Controlled search text. Leave undefined to let the table keep its own. */\n globalFilter?: string;\n /** Invoked when the search text changes. */\n onGlobalFilterChange?: (globalFilter: string) => void;\n /** Controlled sort; null means not sorted. Leave undefined to let the table keep its own. */\n sort?: DataTableSort | null;\n /** Invoked when a sortable column header changes the sort. */\n onSortChange?: (sort: DataTableSort | null) => void;\n /**\n * Whether the table filters and sorts the rows it is given (default:\n * {@link DataTableRowProcessing.Loaded}). Use {@link DataTableRowProcessing.None} when the\n * source already applied the controlled filter and sort state.\n */\n rowProcessing?: DataTableRowProcessing;\n /** Enables the bounded scroll container. */\n scrollable?: boolean;\n /** Scroll-container maximum height. */\n scrollHeight?: string;\n /** Extra class name for the table composition. */\n className?: string;\n /** Inline style for the table composition. */\n style?: CSSProperties;\n /** Cratis-owned per-part attributes. */\n pt?: DataTableParts;\n /**\n * @deprecated Cratis parts always merge. Remove this renderer-era option.\n */\n ptOptions?: object;\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `pt` and CSS instead.\n */\n unstyled?: boolean;\n}\n\ntype DataTableRootProps = Pick<DataTableCoreProps<object>, 'children' | 'scrollable' | 'className' | 'style' | 'pt' | 'mobileLayout'> & {\n elementRef: React.Ref<HTMLDivElement>;\n isBusy: boolean;\n};\n\nconst DataTableRoot = ({ children, scrollable, className, style, pt, mobileLayout, elementRef, isBusy }: DataTableRootProps) => (\n <div\n {...pt?.root}\n ref={elementRef}\n tabIndex={pt?.root?.tabIndex ?? (mobileLayout === 'cards' ? -1 : undefined)}\n className={classNames(\n 'cratis-datatable',\n scrollable ? 'cratis-datatable--scrollable' : undefined,\n pt?.root?.className,\n className,\n )}\n style={{ ...pt?.root?.style, ...style }}\n data-cratis-part='root'\n data-cratis-component='DataTableCore'\n data-busy={isBusy || undefined}\n >\n {children}\n </div>\n);\n\n/** A semantic, renderer-independent data table over one already-loaded page. */\nexport const DataTableCore = <TData extends object>(props: DataTableCoreProps<TData>) => {\n const {\n data,\n status = DataTableStatus.Ready,\n rowProcessing = DataTableRowProcessing.Loaded,\n globalFilterFields,\n scrollable,\n pt,\n } = props;\n const messages = useDataTableMessages(props, rowProcessing === DataTableRowProcessing.None);\n const isBusy = status === DataTableStatus.Loading && data.length > 0;\n const columns = useColumns(props.children);\n const selectionGroupName = useId();\n const useCards = useMobileLayout(props);\n const presentationRoot = useDataTablePresentationFocus(useCards);\n const { filters, updateFilter, globalFilter, setGlobalFilter, sort, setSort } =\n useDataTableState(props);\n const rows = useDataTableRows<TData>({\n ...props,\n filters,\n globalFilter,\n sort,\n rowProcessing,\n });\n\n return (\n <DataTableRoot {...props} elementRef={presentationRoot} isBusy={isBusy}>\n {!!globalFilterFields?.length && (\n <DataTableSearch\n parts={pt}\n value={globalFilter}\n placeholder={messages.resolvedGlobalSearchPlaceholder}\n ariaLabel={messages.resolvedGlobalSearchAriaLabel}\n onChange={setGlobalFilter}\n />\n )}\n {useCards ? (\n <DataTableCards\n {...props}\n state={rows}\n columns={columns}\n parts={pt}\n messages={messages}\n status={status}\n isBusy={isBusy}\n sort={sort}\n onSort={setSort}\n filters={filters}\n updateFilter={updateFilter}\n selectionGroupName={selectionGroupName}\n />\n ) : <DataTableTable\n parts={pt}\n isBusy={isBusy}\n scrollable={scrollable}\n scrollHeight={props.scrollHeight}\n head={\n <DataTableHead\n columns={columns}\n parts={pt}\n sort={sort}\n onSort={setSort}\n filters={filters}\n updateFilter={updateFilter}\n messages={messages}\n selection={rows}\n />\n }\n >\n <DataTableBody\n status={status}\n hasLoadedRows={data.length > 0}\n rowCount={rows.filteredRows.length}\n columnCount={columns.length}\n parts={pt}\n messages={messages}\n emptyMessage={props.emptyMessage}\n isFiltered={rows.isFiltered}\n renderRows={() => (\n <DataTableRows<TData>\n state={rows}\n columns={columns}\n parts={pt}\n selectionMode={props.selectionMode}\n rowClassName={props.rowClassName}\n resolvedSelectionAriaLabel={messages.resolvedSelectionAriaLabel}\n selectionGroupName={selectionGroupName}\n />\n )}\n />\n </DataTableTable>}\n </DataTableRoot>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAM,UAAU,GAAG,CAAC,QAAyB,KACzC,OAAO,CACH,MACI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CACnC,KAAK,CAAC,cAAc,CACmB,EAC/C,CAAC,QAAQ,CAAC,CACb;AAmGL,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAsB,MACvHA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,IAAI,EACZ,GAAG,EAAE,UAAU,EACf,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,KAAK,YAAY,KAAK,OAAO,GAAG,EAAE,GAAG,SAAS,CAAC,EAC3E,SAAS,EAAE,UAAU,CACjB,kBAAkB,EAClB,UAAU,GAAG,8BAA8B,GAAG,SAAS,EACvD,EAAE,EAAE,IAAI,EAAE,SAAS,EACnB,SAAS,CACZ,EACD,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,sBACtB,MAAM,EAAA,uBAAA,EACD,eAAe,EAAA,WAAA,EAC1B,MAAM,IAAI,SAAS,EAAA,QAAA,EAE7B,QAAQ,EAAA,CACP,CACT;AAGM,MAAM,aAAa,GAAG,CAAuB,KAAgC,KAAI;IACpF,MAAM,EACF,IAAI,EACJ,MAAM,GAAG,eAAe,CAAC,KAAK,EAC9B,aAAa,GAAG,sBAAsB,CAAC,MAAM,EAC7C,kBAAkB,EAClB,UAAU,EACV,EAAE,GACL,GAAG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} from './DataTableCore.js';
|
|
2
|
+
import type { DataTableMobileLayoutProps } from './DataTableMobileLayoutProps.js';
|
|
2
3
|
import type { Constructor } from '@cratis/fundamentals';
|
|
3
4
|
import { type IObservableQueryFor } from '@cratis/arc/queries';
|
|
4
5
|
import { type ReactNode } from 'react';
|
|
@@ -13,7 +14,7 @@ import type { DataTableServerQuery } from './DataTableServerQuery.js';
|
|
|
13
14
|
* @typeParam TDataType - The row type returned by the query.
|
|
14
15
|
* @typeParam TArguments - The query's argument object type.
|
|
15
16
|
*/
|
|
16
|
-
export interface DataTableForObservableQueryProps<TQuery extends IObservableQueryFor<TDataType, TArguments> | IObservableQueryFor<TDataType[], TArguments>, TDataType extends object, TArguments extends object> {
|
|
17
|
+
export interface DataTableForObservableQueryProps<TQuery extends IObservableQueryFor<TDataType, TArguments> | IObservableQueryFor<TDataType[], TArguments>, TDataType extends object, TArguments extends object> extends DataTableMobileLayoutProps {
|
|
17
18
|
/**
|
|
18
19
|
* Children to render — `<Column>` elements describing the visible columns.
|
|
19
20
|
*/
|
|
@@ -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;AAErF,OAAO,KAAK,EAAE,oBAA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EAAE,CAAC,EAAE,cAAc,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,gCAwJzE,CAAC"}
|
|
@@ -61,7 +61,7 @@ const DataTableForObservableQuery = (props) => {
|
|
|
61
61
|
border: '1px solid var(--cratis-surface-border)',
|
|
62
62
|
borderRadius: 'var(--cratis-border-radius)',
|
|
63
63
|
overflow: 'hidden',
|
|
64
|
-
}, children: [jsx("div", { style: { height: `${tableHeight}px`, overflow: 'hidden' }, children: jsx(DataTableCore, { data: rows, dataKey: props.dataKey, emptyMessage: props.emptyMessage, filteredEmptyMessage: props.filteredEmptyMessage, 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, onGlobalFilterChange: props.onGlobalFilterChange, ...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: {
|
|
64
|
+
}, children: [jsx("div", { style: { height: `${tableHeight}px`, overflow: 'hidden' }, children: jsx(DataTableCore, { data: rows, mobileLayout: props.mobileLayout, mobileBreakpoint: props.mobileBreakpoint, dataKey: props.dataKey, emptyMessage: props.emptyMessage, filteredEmptyMessage: props.filteredEmptyMessage, 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, onGlobalFilterChange: props.onGlobalFilterChange, ...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: {
|
|
65
65
|
borderTop: '1px solid var(--cratis-surface-border)',
|
|
66
66
|
flexShrink: 0,
|
|
67
67
|
}, 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';\nimport type { DataTableServerQuery } from './DataTableServerQuery';\nimport { useServerQuery } from './useServerQuery';\nimport { DataTableStatus } from './DataTableStatus';\nimport { useReconciledQuerySelection } from './useReconciledQuerySelection';\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 /**\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 * The supplied selection remains consumer-owned; without a callback it is left unchanged.\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(\n props.serverQuery,\n props.queryArguments,\n props.defaultFilters,\n props.onGlobalFilterChange,\n );\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 useReconciledQuerySelection(\n rows, props.selection, props.dataKey, status === DataTableStatus.Ready,\n props.onSelectionChange,\n );\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 filteredEmptyMessage={props.filteredEmptyMessage}\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 onGlobalFilterChange={props.onGlobalFilterChange}\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.pagin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AK,CAAC,SAAS,EAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAA,QAAA,EAEvB,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 { DataTableMobileLayoutProps } from './DataTableMobileLayoutProps';\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';\nimport { DataTableStatus } from './DataTableStatus';\nimport { useReconciledQuerySelection } from './useReconciledQuerySelection';\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> extends DataTableMobileLayoutProps {\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 /**\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 * The supplied selection remains consumer-owned; without a callback it is left unchanged.\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(\n props.serverQuery,\n props.queryArguments,\n props.defaultFilters,\n props.onGlobalFilterChange,\n );\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 useReconciledQuerySelection(\n rows, props.selection, props.dataKey, status === DataTableStatus.Ready,\n props.onSelectionChange,\n );\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 mobileLayout={props.mobileLayout}\n mobileBreakpoint={props.mobileBreakpoint}\n dataKey={props.dataKey}\n emptyMessage={props.emptyMessage}\n filteredEmptyMessage={props.filteredEmptyMessage}\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 onGlobalFilterChange={props.onGlobalFilterChange}\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":";;;;;;;;;;;AA2KA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC;AAiCzB,MAAM,2BAA2B,GAAG,CAOvC,KAAsE,KACtE;IAkBA,MAAM,MAAM,GAAG,cAAc,CACzB,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,oBAAo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AAA,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,4 +1,5 @@
|
|
|
1
1
|
import type { DataTableParts } from './DataTableCore.js';
|
|
2
|
+
import type { DataTableMobileLayoutProps } from './DataTableMobileLayoutProps.js';
|
|
2
3
|
import type { Constructor } from '@cratis/fundamentals';
|
|
3
4
|
import { type IQueryFor } from '@cratis/arc/queries';
|
|
4
5
|
import { type ReactNode } from 'react';
|
|
@@ -13,7 +14,7 @@ import type { DataTableServerQuery } from './DataTableServerQuery.js';
|
|
|
13
14
|
* @typeParam TDataType - The row type returned by the query.
|
|
14
15
|
* @typeParam TArguments - The query's argument object type, or `object` if it takes none.
|
|
15
16
|
*/
|
|
16
|
-
export interface DataTableForQueryProps<TQuery extends IQueryFor<TDataType, TArguments> | IQueryFor<TDataType[], TArguments>, TDataType extends object, TArguments extends object> {
|
|
17
|
+
export interface DataTableForQueryProps<TQuery extends IQueryFor<TDataType, TArguments> | IQueryFor<TDataType[], TArguments>, TDataType extends object, TArguments extends object> extends DataTableMobileLayoutProps {
|
|
17
18
|
/**
|
|
18
19
|
* Children to render — `<Column>` elements describing the visible columns.
|
|
19
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableForQuery.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableForQuery.tsx"],"names":[],"mappings":"AAGA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
|
28
28
|
border: '1px solid var(--cratis-surface-border)',
|
|
29
29
|
borderRadius: 'var(--cratis-border-radius)',
|
|
30
30
|
overflow: 'hidden',
|
|
31
|
-
}, children: [jsx("div", { style: { flex: 1, minHeight: 0, overflow: 'hidden' }, children: jsx(DataTableCore, { data: rows, dataKey: props.dataKey, emptyMessage: props.emptyMessage, filteredEmptyMessage: props.filteredEmptyMessage, 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, onGlobalFilterChange: props.onGlobalFilterChange, ...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: {
|
|
31
|
+
}, children: [jsx("div", { style: { flex: 1, minHeight: 0, overflow: 'hidden' }, children: jsx(DataTableCore, { data: rows, mobileLayout: props.mobileLayout, mobileBreakpoint: props.mobileBreakpoint, dataKey: props.dataKey, emptyMessage: props.emptyMessage, filteredEmptyMessage: props.filteredEmptyMessage, 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, onGlobalFilterChange: props.onGlobalFilterChange, ...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: {
|
|
32
32
|
borderTop: '1px solid var(--cratis-surface-border)',
|
|
33
33
|
flexShrink: 0,
|
|
34
34
|
}, 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, 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';\nimport { DataTableStatus } from './DataTableStatus';\nimport { useReconciledQuerySelection } from './useReconciledQuerySelection';\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 /**\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 * The supplied selection remains consumer-owned; without a callback it is left unchanged.\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(\n props.serverQuery,\n props.queryArguments,\n props.defaultFilters,\n props.onGlobalFilterChange,\n );\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 useReconciledQuerySelection(\n rows, props.selection, props.dataKey,\n status === DataTableStatus.Ready && !isWaitingForArguments,\n props.onSelectionChange,\n );\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 filteredEmptyMessage={props.filteredEmptyMessage}\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 onGlobalFilterChange={props.onGlobalFilterChange}\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":";;;;;;;;;;;;AAyKA,MA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AA,EAEvB,KAAK,CAAC,QAAQ,GACH,EAAA,CACd,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;;"}
|
|
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 { DataTableMobileLayoutProps } from './DataTableMobileLayoutProps';\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';\nimport { DataTableStatus } from './DataTableStatus';\nimport { useReconciledQuerySelection } from './useReconciledQuerySelection';\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> extends DataTableMobileLayoutProps {\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 /**\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 * The supplied selection remains consumer-owned; without a callback it is left unchanged.\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(\n props.serverQuery,\n props.queryArguments,\n props.defaultFilters,\n props.onGlobalFilterChange,\n );\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 useReconciledQuerySelection(\n rows, props.selection, props.dataKey,\n status === DataTableStatus.Ready && !isWaitingForArguments,\n props.onSelectionChange,\n );\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 mobileLayout={props.mobileLayout}\n mobileBreakpoint={props.mobileBreakpoint}\n dataKey={props.dataKey}\n emptyMessage={props.emptyMessage}\n filteredEmptyMessage={props.filteredEmptyMessage}\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 onGlobalFilterChange={props.onGlobalFilterChange}\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":";;;;;;;;;;;;AA0KA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC;AA8CzB,MAAM,iBAAiB,GAAG,CAK7B,KAA4D,KAC5D;IACA,MAAM,MAAM,GAAG,cAAc,CACzB,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,oBAAoB,CAC7B;IACD,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,GAAG,sBAAsB,CAAC,qBAAqB,GAAG,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,IAAI,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Icon: ReactNode;
|
|
22
22
|
}
|
|
23
|
-
/** One column header
|
|
24
|
-
export declare const DataTableHeaderCell: (
|
|
23
|
+
/** One column header, retaining the semantic table wrapper around the shared controls. */
|
|
24
|
+
export declare const DataTableHeaderCell: (props: DataTableHeaderCellProps) => import("react").JSX.Element;
|
|
25
25
|
//# sourceMappingURL=DataTableHeaderCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableHeaderCell.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableHeaderCell.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"DataTableHeaderCell.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableHeaderCell.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAE5C,OAAO,KAAK,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AAC5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAiB,CAAC;AAKrD,6CAA6C;AAC7C,MAAM,WAAW,wBAAwB;IACrC,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IACvC,mCAAmC;IACnC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACtC,OAAO,EAAE,mBAAmB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