@cratis/components 4.54.0 → 4.55.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/compat-manifest.json +13 -13
  2. package/dist/esm/Chat/ChatConversation.d.ts.map +1 -1
  3. package/dist/esm/Chat/ChatConversation.js +38 -10
  4. package/dist/esm/Chat/ChatConversation.js.map +1 -1
  5. package/dist/esm/Chat/ChatMessageBody.js +1 -1
  6. package/dist/esm/Chat/ChatMessageBody.js.map +1 -1
  7. package/dist/esm/Chat/ChatTopicList.js +1 -1
  8. package/dist/esm/Chat/ChatTopicList.js.map +1 -1
  9. package/dist/esm/Chat/Kit/Avatar/PersonAvatarCircle.d.ts.map +1 -1
  10. package/dist/esm/Chat/Kit/Avatar/PersonAvatarCircle.js +1 -1
  11. package/dist/esm/Chat/Kit/Avatar/PersonAvatarCircle.js.map +1 -1
  12. package/dist/esm/Chat/Kit/ChatComposer.js +1 -1
  13. package/dist/esm/Chat/Kit/ChatComposer.js.map +1 -1
  14. package/dist/esm/Chat/Kit/ChatMessageBubble.d.ts.map +1 -1
  15. package/dist/esm/Chat/Kit/ChatMessageBubble.js +18 -11
  16. package/dist/esm/Chat/Kit/ChatMessageBubble.js.map +1 -1
  17. package/dist/esm/Chat/Kit/Emoji/EmojiPicker.js +1 -1
  18. package/dist/esm/Chat/Kit/Emoji/EmojiPicker.js.map +1 -1
  19. package/dist/esm/Chat/Kit/FailedReply.js +1 -1
  20. package/dist/esm/Chat/Kit/FailedReply.js.map +1 -1
  21. package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.js +1 -1
  22. package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.js.map +1 -1
  23. package/dist/esm/Chat/Kit/MessageReactions.js +1 -1
  24. package/dist/esm/Chat/Kit/MessageReactions.js.map +1 -1
  25. package/dist/esm/Chat/Kit/ReactionPicker.js +1 -1
  26. package/dist/esm/Chat/Kit/ReactionPicker.js.map +1 -1
  27. package/dist/esm/Chat/Kit/TypingIndicator.js +1 -1
  28. package/dist/esm/Chat/Kit/TypingIndicator.js.map +1 -1
  29. package/dist/esm/Common/CratisComponentsProvider.d.ts +4 -0
  30. package/dist/esm/Common/CratisComponentsProvider.d.ts.map +1 -1
  31. package/dist/esm/Common/CratisComponentsProvider.js.map +1 -1
  32. package/dist/esm/DataTables/DataTableCard.d.ts +4 -0
  33. package/dist/esm/DataTables/DataTableCard.d.ts.map +1 -0
  34. package/dist/esm/DataTables/DataTableCard.js +43 -0
  35. package/dist/esm/DataTables/DataTableCard.js.map +1 -0
  36. package/dist/esm/DataTables/DataTableCardControls.d.ts +6 -0
  37. package/dist/esm/DataTables/DataTableCardControls.d.ts.map +1 -0
  38. package/dist/esm/DataTables/DataTableCardControls.js +27 -0
  39. package/dist/esm/DataTables/DataTableCardControls.js.map +1 -0
  40. package/dist/esm/DataTables/DataTableCards.d.ts +16 -0
  41. package/dist/esm/DataTables/DataTableCards.d.ts.map +1 -0
  42. package/dist/esm/DataTables/DataTableCards.js +40 -0
  43. package/dist/esm/DataTables/DataTableCards.js.map +1 -0
  44. package/dist/esm/DataTables/DataTableCore.d.ts +3 -1
  45. package/dist/esm/DataTables/DataTableCore.d.ts.map +1 -1
  46. package/dist/esm/DataTables/DataTableCore.js +8 -2
  47. package/dist/esm/DataTables/DataTableCore.js.map +1 -1
  48. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts +2 -1
  49. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts.map +1 -1
  50. package/dist/esm/DataTables/DataTableForObservableQuery.js +1 -1
  51. package/dist/esm/DataTables/DataTableForObservableQuery.js.map +1 -1
  52. package/dist/esm/DataTables/DataTableForQuery.d.ts +2 -1
  53. package/dist/esm/DataTables/DataTableForQuery.d.ts.map +1 -1
  54. package/dist/esm/DataTables/DataTableForQuery.js +1 -1
  55. package/dist/esm/DataTables/DataTableForQuery.js.map +1 -1
  56. package/dist/esm/DataTables/DataTableHeaderCell.d.ts +2 -2
  57. package/dist/esm/DataTables/DataTableHeaderCell.d.ts.map +1 -1
  58. package/dist/esm/DataTables/DataTableHeaderCell.js +5 -19
  59. package/dist/esm/DataTables/DataTableHeaderCell.js.map +1 -1
  60. package/dist/esm/DataTables/DataTableHeaderContent.d.ts +11 -0
  61. package/dist/esm/DataTables/DataTableHeaderContent.d.ts.map +1 -0
  62. package/dist/esm/DataTables/DataTableHeaderContent.js +37 -0
  63. package/dist/esm/DataTables/DataTableHeaderContent.js.map +1 -0
  64. package/dist/esm/DataTables/DataTableMessages.d.ts +2 -0
  65. package/dist/esm/DataTables/DataTableMessages.d.ts.map +1 -1
  66. package/dist/esm/DataTables/DataTableMessages.js.map +1 -1
  67. package/dist/esm/DataTables/DataTableMobileLayoutProps.d.ts +8 -0
  68. package/dist/esm/DataTables/DataTableMobileLayoutProps.d.ts.map +1 -0
  69. package/dist/esm/DataTables/DataTableMobileLayoutProps.js +4 -0
  70. package/dist/esm/DataTables/DataTableMobileLayoutProps.js.map +1 -0
  71. package/dist/esm/DataTables/DataTableParts.d.ts +12 -0
  72. package/dist/esm/DataTables/DataTableParts.d.ts.map +1 -1
  73. package/dist/esm/DataTables/DataTableParts.js.map +1 -1
  74. package/dist/esm/DataTables/DataTableRow.d.ts +3 -1
  75. package/dist/esm/DataTables/DataTableRow.d.ts.map +1 -1
  76. package/dist/esm/DataTables/DataTableRow.js +23 -18
  77. package/dist/esm/DataTables/DataTableRow.js.map +1 -1
  78. package/dist/esm/DataTables/DataTableRows.d.ts.map +1 -1
  79. package/dist/esm/DataTables/DataTableRows.js +1 -1
  80. package/dist/esm/DataTables/DataTableRows.js.map +1 -1
  81. package/dist/esm/DataTables/dataTableCellContent.d.ts +5 -0
  82. package/dist/esm/DataTables/dataTableCellContent.d.ts.map +1 -0
  83. package/dist/esm/DataTables/dataTableCellContent.js +11 -0
  84. package/dist/esm/DataTables/dataTableCellContent.js.map +1 -0
  85. package/dist/esm/DataTables/useDataTableMessages.d.ts.map +1 -1
  86. package/dist/esm/DataTables/useDataTableMessages.js +2 -0
  87. package/dist/esm/DataTables/useDataTableMessages.js.map +1 -1
  88. package/dist/esm/DataTables/useDataTablePresentationFocus.d.ts +3 -0
  89. package/dist/esm/DataTables/useDataTablePresentationFocus.d.ts.map +1 -0
  90. package/dist/esm/DataTables/useDataTablePresentationFocus.js +45 -0
  91. package/dist/esm/DataTables/useDataTablePresentationFocus.js.map +1 -0
  92. package/dist/esm/DataTables/useMobileLayout.d.ts +4 -0
  93. package/dist/esm/DataTables/useMobileLayout.d.ts.map +1 -0
  94. package/dist/esm/DataTables/useMobileLayout.js +20 -0
  95. package/dist/esm/DataTables/useMobileLayout.js.map +1 -0
  96. package/dist/esm/DataTables/useRowSelection.d.ts.map +1 -1
  97. package/dist/esm/DataTables/useRowSelection.js +1 -1
  98. package/dist/esm/DataTables/useRowSelection.js.map +1 -1
  99. package/dist/esm/SchemaEditor/Tree/PropertyTypeGlyph.js +1 -1
  100. package/dist/esm/SchemaEditor/Tree/PropertyTypeGlyph.js.map +1 -1
  101. package/dist/esm/styles.DataPage.css +66 -0
  102. package/dist/esm/styles.DataTables.css +66 -0
  103. package/dist/esm/styles.SchemaEditor.css +66 -0
  104. package/dist/esm/styles.css +66 -0
  105. package/dist/esm/styles.renderer.builtin.css +66 -0
  106. package/dist/esm/types/parts.d.ts +21 -3
  107. package/dist/esm/types/parts.d.ts.map +1 -1
  108. package/dist/esm/types/parts.js +21 -3
  109. package/dist/esm/types/parts.js.map +1 -1
  110. package/package.json +1 -1
@@ -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.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;AAiCzB,MAAM,2BAA2B,GAAG,CAOv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E,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,oBAAoB,CAC7B;IACD,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,GAAG,4BAA4B,CAIhE,KAAK,CAAC,KAAc,EAAE,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;AACtD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC;IACjD,MAAM,CAAC,WAAW,EAAE,c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AAE,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,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,SAAS,EAAU,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,OAAO,CAAC;AAEhD,OAAO,EAEH,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAC3B,MAAM,qBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM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,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAElC;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,6EAA6E;IAC7E,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC3D;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,iBAAiB,GAC1B,MAAM,SAAS,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,SAAS,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC,EACpF,SAAS,SAAS,MAAM,EACxB,UAAU,SAAS,MAAM,SAElB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,gCAwG/D,CAAC"}
@@ -28,7 +28,7 @@ const DataTableForQuery = (props) => {
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,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,MA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AK,CAAC,uBAAuB,EACtD,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAClD,cAAc,EAAE,KAAK,CAAC,cAAc,EACpC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,EAAA,GAC5C,MAAM,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,EAC9C,UAAU,QACV,YAAY,EAAC,MAAM,EACnB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAC3B,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAA,QAAA,EAEvB,KAAK,CAAC,QAAQ,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,CAA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AAS,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;;"}
@@ -20,6 +20,6 @@ export interface DataTableHeaderCellProps {
20
20
  sortAscendingIcon: ReactNode;
21
21
  sortDescendingIcon: ReactNode;
22
22
  }
23
- /** One column header: its label, sort control, filter menu, and select-all or selection label. */
24
- export declare const DataTableHeaderCell: ({ column: declaredColumn, parts: pt, sort, onSort, filters, updateFilter, resolvedSelectionAriaLabel, resolvedSelectAllAriaLabel, allFilteredRowsSelected, selectAllRef, toggleSelectAll, sortAscendingIcon, sortDescendingIcon, }: DataTableHeaderCellProps) => import("react").JSX.Element;
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;AAG5C,OAAO,KAAK,EACR,yBAAyB,EACzB,mBAAmB,EACtB,MAAM,0BAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EA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;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,CAAC;IAC7B,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB,GAAG,SAAS,KAAK,IAAI,CAAC;IACzF,0BAA0B,EAAE,MAAM,CAAC;IACnC,0BAA0B,EAAE,MAAM,CAAC;IACnC,uBAAuB,EAAE,OAAO,CAAC;IACjC,YAAY,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACjD,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,iBAAiB,EAAE,SAAS,CAAC;IAC7B,kBAAkB,EAAE,SAAS,CAAC;CACjC;AAED,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,UAAW,wBAAwB,gCAoBlE,CAAC"}
@@ -1,30 +1,16 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
1
+ import { jsx } from 'react/jsx-runtime';
2
2
  import { cloneElement } from 'react';
3
3
  import { useComponentPresentation } from '../configuration/identity/useComponentPresentation.js';
4
4
  import { columnDescriptor } from './columnDescriptor.js';
5
- import { ColumnFilterMenu } from './ColumnFilterMenu.js';
6
5
  import { classNames } from '../ClassNames/classNames.js';
7
- import { DataTableSortDirection } from './DataTableSortDirection.js';
8
- import { firstConstraint } from './matchesFilterEntry.js';
6
+ import { DataTableHeaderContent } from './DataTableHeaderContent.js';
9
7
 
10
- const DataTableHeaderCell = ({ column: declaredColumn, parts: pt, sort, onSort, filters, updateFilter, resolvedSelectionAriaLabel, resolvedSelectAllAriaLabel, allFilteredRowsSelected, selectAllRef, toggleSelectAll, sortAscendingIcon, sortDescendingIcon, }) => {
8
+ const DataTableHeaderCell = (props) => {
9
+ const { column: declaredColumn, parts: pt, sort, resolvedSelectionAriaLabel } = props;
11
10
  const [columnProps, marker] = useComponentPresentation(columnDescriptor, declaredColumn.props, declaredColumn.props.field);
12
11
  const column = columnProps === declaredColumn.props ? declaredColumn : cloneElement(declaredColumn, columnProps);
13
- const field = column.props.filterField ?? column.props.field;
14
12
  const ariaSort = sort && sort.field === column.props.field ? sort.direction : undefined;
15
- return (jsx("th", { ...pt?.headerCell, scope: 'col', "aria-label": column.props.selectionMode ? resolvedSelectionAriaLabel : undefined, "aria-sort": ariaSort, style: {
16
- ...pt?.headerCell?.style,
17
- ...column.props.style,
18
- ...column.props.headerStyle,
19
- }, className: classNames('cratis-datatable__header-cell', pt?.headerCell?.className, column.props.headerClassName), "data-cratis-part": 'header-cell', ...marker, "data-selected": Boolean(ariaSort) || undefined, children: jsxs("div", { className: 'cratis-datatable-header-cell', "data-cratis-part": 'header-content', "data-selected": Boolean(ariaSort) || undefined, children: [column.props.selectionMode === 'multiple' ? (jsx("input", { type: 'checkbox', "aria-label": resolvedSelectAllAriaLabel, "data-cratis-part": 'select-all', checked: allFilteredRowsSelected, ref: selectAllRef, onChange: toggleSelectAll })) : (column.props.selectionMode && (jsx("span", { className: 'cratis-datatable__sr-only', children: resolvedSelectionAriaLabel }))), column.props.sortable && column.props.field ? (jsxs("button", { type: 'button', className: 'cratis-datatable__sort', "data-cratis-part": 'sort', "data-pressed": Boolean(ariaSort) || undefined, onClick: () => onSort({
20
- field: column.props.field,
21
- direction: sort?.field === column.props.field &&
22
- sort?.direction === DataTableSortDirection.Ascending
23
- ? DataTableSortDirection.Descending
24
- : DataTableSortDirection.Ascending,
25
- }), children: [jsx("span", { children: column.props.header }), ariaSort && (jsx("span", { "aria-hidden": 'true', children: ariaSort === 'ascending'
26
- ? sortAscendingIcon
27
- : sortDescendingIcon }))] })) : (column.props.header), column.props.filter && field && (jsx(ColumnFilterMenu, { field: field, dataType: column.props.dataType, placeholder: column.props.filterPlaceholder, showMatchModes: column.props.showFilterMatchModes, filterElement: column.props.filterElement, filterOptions: column.props.filterOptions, labels: column.props.filterLabels, pt: column.props.filterPt, constraint: firstConstraint(filters[field]), onApply: (constraint) => updateFilter(field, constraint), onClear: () => updateFilter(field, undefined) }))] }) }));
13
+ return (jsx("th", { ...pt?.headerCell, scope: 'col', "aria-label": column.props.selectionMode ? resolvedSelectionAriaLabel : undefined, "aria-sort": ariaSort, style: { ...pt?.headerCell?.style, ...column.props.style, ...column.props.headerStyle }, className: classNames('cratis-datatable__header-cell', pt?.headerCell?.className, column.props.headerClassName), "data-cratis-part": 'header-cell', ...marker, "data-selected": Boolean(ariaSort) || undefined, children: jsx(DataTableHeaderContent, { ...props, column: column }) }));
28
14
  };
29
15
 
30
16
  export { DataTableHeaderCell };
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableHeaderCell.js","sources":["../../../DataTables/DataTableHeaderCell.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, type ReactElement, type ReactNode, type RefObject } from 'react';\nimport { useComponentPresentation } from '../configuration/identity/useComponentPresentation';\nimport { columnDescriptor } from './columnDescriptor';\nimport type { ColumnProps } from './Column';\nimport { ColumnFilterMenu } from './ColumnFilterMenu';\nimport { classNames } from '../ClassNames/classNames';\nimport type {\n DataTableFilterConstraint,\n DataTableFilterMeta,\n} from './DataTableFilterMeta';\nimport type { DataTableParts } from './DataTableParts';\nimport type { DataTableSort } from './DataTableSort';\nimport { DataTableSortDirection } from './DataTableSortDirection';\nimport { firstConstraint } from './matchesFilterEntry';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/** Props for {@link DataTableHeaderCell}. */\nexport interface DataTableHeaderCellProps {\n column: ReactElement<ColumnProps<any>>;\n /** The table's part attributes. */\n parts?: DataTableParts;\n sort: DataTableSort | null;\n onSort: (sort: DataTableSort) => void;\n filters: DataTableFilterMeta;\n updateFilter: (\n field: string,\n constraint: DataTableFilterConstraint | undefined,\n ) => void;\n resolvedSelectionAriaLabel: string;\n resolvedSelectAllAriaLabel: string;\n allFilteredRowsSelected: boolean;\n selectAllRef: RefObject<HTMLInputElement | null>;\n toggleSelectAll: () => void;\n sortAscendingIcon: ReactNode;\n sortDescendingIcon: ReactNode;\n}\n\n/** One column header: its label, sort control, filter menu, and select-all or selection label. */\nexport const DataTableHeaderCell = ({\n column: declaredColumn,\n parts: pt,\n sort,\n onSort,\n filters,\n updateFilter,\n resolvedSelectionAriaLabel,\n resolvedSelectAllAriaLabel,\n allFilteredRowsSelected,\n selectAllRef,\n toggleSelectAll,\n sortAscendingIcon,\n sortDescendingIcon,\n}: DataTableHeaderCellProps) => {\n const [columnProps, marker] = useComponentPresentation(\n columnDescriptor,\n declaredColumn.props,\n declaredColumn.props.field,\n );\n const column = columnProps === declaredColumn.props ? declaredColumn : cloneElement(declaredColumn, columnProps);\n const field = column.props.filterField ?? column.props.field;\n const ariaSort =\n sort && sort.field === column.props.field ? sort.direction : undefined;\n return (\n <th\n {...pt?.headerCell}\n scope='col'\n aria-label={\n column.props.selectionMode ? resolvedSelectionAriaLabel : undefined\n }\n aria-sort={ariaSort}\n style={{\n ...pt?.headerCell?.style,\n ...column.props.style,\n ...column.props.headerStyle,\n }}\n className={classNames(\n 'cratis-datatable__header-cell',\n pt?.headerCell?.className,\n column.props.headerClassName,\n )}\n data-cratis-part='header-cell'\n {...marker}\n data-selected={Boolean(ariaSort) || undefined}\n >\n <div\n className='cratis-datatable-header-cell'\n data-cratis-part='header-content'\n data-selected={Boolean(ariaSort) || undefined}\n >\n {column.props.selectionMode === 'multiple' ? (\n <input\n type='checkbox'\n aria-label={resolvedSelectAllAriaLabel}\n data-cratis-part='select-all'\n checked={allFilteredRowsSelected}\n ref={selectAllRef}\n onChange={toggleSelectAll}\n />\n ) : (\n column.props.selectionMode && (\n <span className='cratis-datatable__sr-only'>\n {resolvedSelectionAriaLabel}\n </span>\n )\n )}\n {column.props.sortable && column.props.field ? (\n <button\n type='button'\n className='cratis-datatable__sort'\n data-cratis-part='sort'\n data-pressed={Boolean(ariaSort) || undefined}\n onClick={() =>\n onSort({\n field: column.props.field as string,\n direction:\n sort?.field === column.props.field &&\n sort?.direction === DataTableSortDirection.Ascending\n ? DataTableSortDirection.Descending\n : DataTableSortDirection.Ascending,\n })\n }\n >\n <span>{column.props.header}</span>\n {ariaSort && (\n <span aria-hidden='true'>\n {ariaSort === 'ascending'\n ? sortAscendingIcon\n : sortDescendingIcon}\n </span>\n )}\n </button>\n ) : (\n column.props.header\n )}\n {column.props.filter && field && (\n <ColumnFilterMenu\n field={field}\n dataType={column.props.dataType}\n placeholder={column.props.filterPlaceholder}\n showMatchModes={column.props.showFilterMatchModes}\n filterElement={column.props.filterElement}\n filterOptions={column.props.filterOptions}\n labels={column.props.filterLabels}\n pt={column.props.filterPt}\n constraint={firstConstraint(filters[field])}\n onApply={(constraint) => updateFilter(field, constraint)}\n onClear={() => updateFilter(field, undefined)}\n />\n )}\n </div>\n </th>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;AA0CO,MAAM,mBAAmB,GAAG,CAAC,EAChC,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,EAAE,EACT,IAAI,EACJ,MAAM,EACN,OAAO,EACP,YAAY,EACZ,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACK,KAAI;IAC3B,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,wBAAwB,CAClD,gBAAgB,EAChB,cAAc,CAAC,KAAK,EACpB,cAAc,CAAC,KAAK,CAAC,KAAK,CAC7B;IACD,MAAM,MAAM,GAAG,WAAW,KAAK,cAAc,CAAC,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC,cAAc,EAAE,WAAW,CAAC;AAChH,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,W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E,MAAM,CAAC,KAAK,CAAC,YAAY,EACjC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EACzB,UAAU,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAC3C,OAAO,EAAE,CAAC,UAAU,KAAK,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,EACxD,OAAO,EAAE,MAAM,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,EAAA,CAC/C,CACL,CAAA,EAAA,CACC,EAAA,CACL;AAEb;;"}
1
+ {"version":3,"file":"DataTableHeaderCell.js","sources":["../../../DataTables/DataTableHeaderCell.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, type ReactElement, type ReactNode, type RefObject } from 'react';\nimport { useComponentPresentation } from '../configuration/identity/useComponentPresentation';\nimport { columnDescriptor } from './columnDescriptor';\nimport type { ColumnProps } from './Column';\nimport { classNames } from '../ClassNames/classNames';\nimport type { DataTableFilterConstraint, DataTableFilterMeta } from './DataTableFilterMeta';\nimport type { DataTableParts } from './DataTableParts';\nimport type { DataTableSort } from './DataTableSort';\nimport { DataTableHeaderContent } from './DataTableHeaderContent';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/** Props for {@link DataTableHeaderCell}. */\nexport interface DataTableHeaderCellProps {\n column: ReactElement<ColumnProps<any>>;\n /** The table's part attributes. */\n parts?: DataTableParts;\n sort: DataTableSort | null;\n onSort: (sort: DataTableSort) => void;\n filters: DataTableFilterMeta;\n updateFilter: (field: string, constraint: DataTableFilterConstraint | undefined) => void;\n resolvedSelectionAriaLabel: string;\n resolvedSelectAllAriaLabel: string;\n allFilteredRowsSelected: boolean;\n selectAllRef: RefObject<HTMLInputElement | null>;\n toggleSelectAll: () => void;\n sortAscendingIcon: ReactNode;\n sortDescendingIcon: ReactNode;\n}\n\n/** One column header, retaining the semantic table wrapper around the shared controls. */\nexport const DataTableHeaderCell = (props: DataTableHeaderCellProps) => {\n const { column: declaredColumn, parts: pt, sort, resolvedSelectionAriaLabel } = props;\n const [columnProps, marker] = useComponentPresentation(columnDescriptor, declaredColumn.props, declaredColumn.props.field);\n const column = columnProps === declaredColumn.props ? declaredColumn : cloneElement(declaredColumn, columnProps);\n const ariaSort = sort && sort.field === column.props.field ? sort.direction : undefined;\n return (\n <th\n {...pt?.headerCell}\n scope='col'\n aria-label={column.props.selectionMode ? resolvedSelectionAriaLabel : undefined}\n aria-sort={ariaSort}\n style={{ ...pt?.headerCell?.style, ...column.props.style, ...column.props.headerStyle }}\n className={classNames('cratis-datatable__header-cell', pt?.headerCell?.className, column.props.headerClassName)}\n data-cratis-part='header-cell'\n {...marker}\n data-selected={Boolean(ariaSort) || undefined}\n >\n <DataTableHeaderContent {...props} column={column} />\n </th>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;AAkCO,MAAM,mBAAmB,GAAG,CAAC,KAA+B,KAAI;AACnE,IAAA,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE,GAAG,KAAK;IACrF,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,wBAAwB,CAAC,gBAAgB,EAAE,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC;IAC1H,MAAM,MAAM,GAAG,WAAW,KAAK,cAAc,CAAC,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC,cAAc,EAAE,WAAW,CAAC;IAChH,MAAM,QAAQ,GAAG,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,GAAG,SAAS;IACvF,QACIA,eACQ,EAAE,EAAE,UAAU,EAClB,KAAK,EAAC,KAAK,EAAA,YAAA,EACC,MAAM,CAAC,KAAK,CAAC,aAAa,GAAG,0BAA0B,GAAG,SAAS,EAAA,WAAA,EACpE,QAAQ,EACnB,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,EACvF,SAAS,EAAE,UAAU,CAAC,+BAA+B,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,EAAA,kBAAA,EAC9F,aAAa,EAAA,GAC1B,MAAM,mBACK,OAAO,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAA,QAAA,EAE7CA,GAAA,CAAC,sBAAsB,EAAA,EAAA,GAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAA,CAAI,EAAA,CACpD;AAEb;;"}
@@ -0,0 +1,11 @@
1
+ import type { DataTableHeaderCellProps } from './DataTableHeaderCell.js';
2
+ type HeaderContentProps = DataTableHeaderCellProps & {
3
+ cardSortDirection?: string;
4
+ cardMode?: boolean;
5
+ };
6
+ /** The shared select-all control for headers and cards. */
7
+ export declare const DataTableSelectAll: ({ resolvedSelectAllAriaLabel, allFilteredRowsSelected, selectAllRef, toggleSelectAll }: Pick<DataTableHeaderCellProps, 'resolvedSelectAllAriaLabel' | 'allFilteredRowsSelected' | 'selectAllRef' | 'toggleSelectAll'>) => import("react").JSX.Element;
8
+ /** Sort, filter and selection content shared without changing the desktop header markup. */
9
+ export declare const DataTableHeaderContent: (props: HeaderContentProps) => import("react").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=DataTableHeaderContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableHeaderContent.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableHeaderContent.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAAuB,CAAC;AAItE,KAAK,kBAAkB,GAAG,wBAAwB,GAAG;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAExG,2DAA2D;AAC3D,eAAO,MAAM,kBAAkB,2FAA4F,IAAI,CAAC,wBAAwB,EAAE,4BAA4B,GAAG,yBAAyB,GAAG,cAAc,GAAG,iBAAiB,CAAC,gCAGvP,CAAC;AAsCF,4FAA4F;AAC5F,eAAO,MAAM,sBAAsB,UAAW,kBAAkB,gCAS/D,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useId } from 'react';
3
+ import { ColumnFilterMenu } from './ColumnFilterMenu.js';
4
+ import { DataTableSortDirection } from './DataTableSortDirection.js';
5
+ import { firstConstraint } from './matchesFilterEntry.js';
6
+
7
+ const DataTableSelectAll = ({ resolvedSelectAllAriaLabel, allFilteredRowsSelected, selectAllRef, toggleSelectAll }) => (jsx("input", { type: 'checkbox', "aria-label": resolvedSelectAllAriaLabel, "data-cratis-part": 'select-all', checked: allFilteredRowsSelected, ref: selectAllRef, onChange: toggleSelectAll }));
8
+ const sortDirection = ({ column, sort }) => {
9
+ const isAscending = sort?.field === column.props.field && sort?.direction === DataTableSortDirection.Ascending;
10
+ return isAscending ? DataTableSortDirection.Descending : DataTableSortDirection.Ascending;
11
+ };
12
+ const HeaderSort = (props) => {
13
+ const { column, sort, onSort, sortAscendingIcon, sortDescendingIcon, cardSortDirection, cardMode } = props;
14
+ const directionId = useId();
15
+ if (!column.props.sortable || !column.props.field)
16
+ return column.props.header;
17
+ const ariaSort = sort && sort.field === column.props.field ? sort.direction : undefined;
18
+ return jsxs(Fragment, { children: [jsxs("button", { type: 'button', className: 'cratis-datatable__sort', "data-cratis-part": 'sort', "data-pressed": Boolean(ariaSort) || undefined, "aria-pressed": cardMode ? Boolean(ariaSort) : undefined, "aria-describedby": cardSortDirection ? directionId : undefined, onClick: () => onSort({ field: column.props.field, direction: sortDirection(props) }), children: [jsx("span", { children: column.props.header }), ariaSort && jsx("span", { "aria-hidden": 'true', children: ariaSort === 'ascending' ? sortAscendingIcon : sortDescendingIcon })] }), cardSortDirection && jsx("span", { id: directionId, className: 'cratis-datatable__sr-only', children: cardSortDirection })] });
19
+ };
20
+ const HeaderFilter = ({ column, filters, updateFilter }) => {
21
+ const field = column.props.filterField ?? column.props.field;
22
+ if (!column.props.filter || !field)
23
+ return null;
24
+ return jsx(ColumnFilterMenu, { field: field, dataType: column.props.dataType, placeholder: column.props.filterPlaceholder, showMatchModes: column.props.showFilterMatchModes, filterElement: column.props.filterElement, filterOptions: column.props.filterOptions, labels: column.props.filterLabels, pt: column.props.filterPt, constraint: firstConstraint(filters[field]), onApply: constraint => updateFilter(field, constraint), onClear: () => updateFilter(field, undefined) });
25
+ };
26
+ const HeaderSelection = (props) => {
27
+ if (props.column.props.selectionMode === 'multiple')
28
+ return jsx(DataTableSelectAll, { ...props });
29
+ return props.column.props.selectionMode ? jsx("span", { className: 'cratis-datatable__sr-only', children: props.resolvedSelectionAriaLabel }) : null;
30
+ };
31
+ const DataTableHeaderContent = (props) => {
32
+ const selected = props.sort?.field === props.column.props.field && !!props.sort;
33
+ return (jsxs("div", { className: 'cratis-datatable-header-cell', "data-cratis-part": 'header-content', "data-selected": selected || undefined, children: [jsx(HeaderSelection, { ...props }), jsx(HeaderSort, { ...props }), jsx(HeaderFilter, { ...props })] }));
34
+ };
35
+
36
+ export { DataTableHeaderContent, DataTableSelectAll };
37
+ //# sourceMappingURL=DataTableHeaderContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableHeaderContent.js","sources":["../../../DataTables/DataTableHeaderContent.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 { useId } from 'react';\nimport { ColumnFilterMenu } from './ColumnFilterMenu';\nimport type { DataTableHeaderCellProps } from './DataTableHeaderCell';\nimport { DataTableSortDirection } from './DataTableSortDirection';\nimport { firstConstraint } from './matchesFilterEntry';\n\ntype HeaderContentProps = DataTableHeaderCellProps & { cardSortDirection?: string; cardMode?: boolean };\n\n/** The shared select-all control for headers and cards. */\nexport const DataTableSelectAll = ({ resolvedSelectAllAriaLabel, allFilteredRowsSelected, selectAllRef, toggleSelectAll }: Pick<DataTableHeaderCellProps, 'resolvedSelectAllAriaLabel' | 'allFilteredRowsSelected' | 'selectAllRef' | 'toggleSelectAll'>) => (\n <input type='checkbox' aria-label={resolvedSelectAllAriaLabel} data-cratis-part='select-all'\n checked={allFilteredRowsSelected} ref={selectAllRef} onChange={toggleSelectAll} />\n);\nconst sortDirection = ({ column, sort }: DataTableHeaderCellProps) => {\n const isAscending = sort?.field === column.props.field && sort?.direction === DataTableSortDirection.Ascending;\n return isAscending ? DataTableSortDirection.Descending : DataTableSortDirection.Ascending;\n};\nconst HeaderSort = (props: HeaderContentProps) => {\n const { column, sort, onSort, sortAscendingIcon, sortDescendingIcon, cardSortDirection, cardMode } = props;\n const directionId = useId();\n if (!column.props.sortable || !column.props.field) return column.props.header;\n const ariaSort = sort && sort.field === column.props.field ? sort.direction : undefined;\n return <>\n <button type='button' className='cratis-datatable__sort' data-cratis-part='sort'\n data-pressed={Boolean(ariaSort) || undefined}\n aria-pressed={cardMode ? Boolean(ariaSort) : undefined}\n aria-describedby={cardSortDirection ? directionId : undefined}\n onClick={() => onSort({ field: column.props.field as string, direction: sortDirection(props) })}>\n <span>{column.props.header}</span>\n {ariaSort && <span aria-hidden='true'>{ariaSort === 'ascending' ? sortAscendingIcon : sortDescendingIcon}</span>}\n </button>\n {cardSortDirection && <span id={directionId} className='cratis-datatable__sr-only'>{cardSortDirection}</span>}\n </>;\n};\nconst HeaderFilter = ({ column, filters, updateFilter }: DataTableHeaderCellProps) => {\n const field = column.props.filterField ?? column.props.field;\n if (!column.props.filter || !field) return null;\n return <ColumnFilterMenu\n field={field} dataType={column.props.dataType} placeholder={column.props.filterPlaceholder}\n showMatchModes={column.props.showFilterMatchModes} filterElement={column.props.filterElement}\n filterOptions={column.props.filterOptions} labels={column.props.filterLabels} pt={column.props.filterPt}\n constraint={firstConstraint(filters[field])}\n onApply={constraint => updateFilter(field, constraint)} onClear={() => updateFilter(field, undefined)}\n />;\n};\nconst HeaderSelection = (props: DataTableHeaderCellProps) => {\n if (props.column.props.selectionMode === 'multiple') return <DataTableSelectAll {...props} />;\n return props.column.props.selectionMode ? <span className='cratis-datatable__sr-only'>{props.resolvedSelectionAriaLabel}</span> : null;\n};\n\n/** Sort, filter and selection content shared without changing the desktop header markup. */\nexport const DataTableHeaderContent = (props: HeaderContentProps) => {\n const selected = props.sort?.field === props.column.props.field && !!props.sort;\n return (\n <div className='cratis-datatable-header-cell' data-cratis-part='header-content' data-selected={selected || undefined}>\n <HeaderSelection {...props} />\n <HeaderSort {...props} />\n <HeaderFilter {...props} />\n </div>\n );\n};\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;AAYO,MAAM,kBAAkB,GAAG,CAAC,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,YAAY,EAAE,eAAe,EAAiI,MACpPA,GAAA,CAAA,OAAA,EAAA,EAAO,IAAI,EAAC,UAAU,gBAAa,0BAA0B,EAAA,kBAAA,EAAmB,YAAY,EACxF,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAA,CAAI;AAE1F,MAAM,aAAa,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAA4B,KAAI;AACjE,IAAA,MAAM,WAAW,GAAG,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,EAAE,SAAS,KAAK,sBAAsB,CAAC,SAAS;AAC9G,IAAA,OAAO,WAAW,GAAG,sBAAsB,CAAC,UAAU,GAAG,sBAAsB,CAAC,SAAS;AAC7F,CAAC;AACD,MAAM,UAAU,GAAG,CAAC,KAAyB,KAAI;AAC7C,IAAA,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAi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B,EAAA,QAAA,EAAE,KAAK,CAAC,0BAA0B,GAAQ,GAAG,IAAI;AAC1I,CAAC;AAGM,MAAM,sBAAsB,GAAG,CAAC,KAAyB,KAAI;IAChE,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,EAAE,KAAK,KAAK,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI;AAC/E,IAAA,QACIC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,8BAA8B,EAAA,kBAAA,EAAkB,gBAAgB,EAAA,eAAA,EAAgB,QAAQ,IAAI,SAAS,EAAA,QAAA,EAAA,CAChHD,IAAC,eAAe,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,EAC9BA,GAAA,CAAC,UAAU,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,EACzBA,GAAA,CAAC,YAAY,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,CAAA,EAAA,CACzB;AAEd;;"}
@@ -1,6 +1,8 @@
1
1
  import type { ReactNode } from 'react';
2
2
  /** The table messages to show, after props and provider messages are applied. */
3
3
  export interface DataTableMessages {
4
+ resolvedSortAscending: string;
5
+ resolvedSortDescending: string;
4
6
  resolvedSelectionAriaLabel: string;
5
7
  resolvedSelectAllAriaLabel: string;
6
8
  resolvedGlobalSearchPlaceholder: string;
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableMessages.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableMessages.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,iFAAiF;AACjF,MAAM,WAAW,iBAAiB;IAC9B,0BAA0B,EAAE,MAAM,CAAC;IACnC,0BAA0B,EAAE,MAAM,CAAC;IACnC,+BAA+B,EAAE,MAAM,CAAC;IACxC,6BAA6B,EAAE,MAAM,CAAC;IACtC,sBAAsB,EAAE,SAAS,CAAC;IAClC,sBAAsB,EAAE,SAAS,CAAC;IAClC,2BAA2B,EAAE,SAAS,CAAC;IACvC,sEAAsE;IACtE,4BAA4B,EAAE,SAAS,CAAC;CAC3C"}
1
+ {"version":3,"file":"DataTableMessages.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableMessages.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,iFAAiF;AACjF,MAAM,WAAW,iBAAiB;IAC9B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,0BAA0B,EAAE,MAAM,CAAC;IACnC,0BAA0B,EAAE,MAAM,CAAC;IACnC,+BAA+B,EAAE,MAAM,CAAC;IACxC,6BAA6B,EAAE,MAAM,CAAC;IACtC,sBAAsB,EAAE,SAAS,CAAC;IAClC,sBAAsB,EAAE,SAAS,CAAC;IAClC,2BAA2B,EAAE,SAAS,CAAC;IACvC,sEAAsE;IACtE,4BAA4B,EAAE,SAAS,CAAC;CAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableMessages.js","sourceRoot":"","sources":["../../../DataTables/DataTableMessages.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ReactNode } from 'react';\n\n/** The table messages to show, after props and provider messages are applied. */\nexport interface DataTableMessages {\n resolvedSelectionAriaLabel: string;\n resolvedSelectAllAriaLabel: string;\n resolvedGlobalSearchPlaceholder: string;\n resolvedGlobalSearchAriaLabel: string;\n resolvedLoadingMessage: ReactNode;\n resolvedFailureMessage: ReactNode;\n resolvedUnauthorizedMessage: ReactNode;\n /** The message for an active search or filter that leaves no rows. */\n resolvedFilteredEmptyMessage: ReactNode;\n}\n"]}
1
+ {"version":3,"file":"DataTableMessages.js","sourceRoot":"","sources":["../../../DataTables/DataTableMessages.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ReactNode } from 'react';\n\n/** The table messages to show, after props and provider messages are applied. */\nexport interface DataTableMessages {\n resolvedSortAscending: string;\n resolvedSortDescending: string;\n resolvedSelectionAriaLabel: string;\n resolvedSelectAllAriaLabel: string;\n resolvedGlobalSearchPlaceholder: string;\n resolvedGlobalSearchAriaLabel: string;\n resolvedLoadingMessage: ReactNode;\n resolvedFailureMessage: ReactNode;\n resolvedUnauthorizedMessage: ReactNode;\n /** The message for an active search or filter that leaves no rows. */\n resolvedFilteredEmptyMessage: ReactNode;\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /** Optional viewport-based presentation for the DataTable family. */
2
+ export interface DataTableMobileLayoutProps {
3
+ /** Render cards below the viewport breakpoint. Omit to keep the semantic table at every width. */
4
+ mobileLayout?: 'cards';
5
+ /** Exclusive viewport threshold in CSS pixels. Defaults to 640; nonfinite/nonpositive values use the default. */
6
+ mobileBreakpoint?: number;
7
+ }
8
+ //# sourceMappingURL=DataTableMobileLayoutProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableMobileLayoutProps.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableMobileLayoutProps.ts"],"names":[],"mappings":"AAGA,qEAAqE;AACrE,MAAM,WAAW,0BAA0B;IACvC,kGAAkG;IAClG,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iHAAiH;IACjH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ export {};
4
+ //# sourceMappingURL=DataTableMobileLayoutProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableMobileLayoutProps.js","sourceRoot":"","sources":["../../../DataTables/DataTableMobileLayoutProps.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** Optional viewport-based presentation for the DataTable family. */\nexport interface DataTableMobileLayoutProps {\n /** Render cards below the viewport breakpoint. Omit to keep the semantic table at every width. */\n mobileLayout?: 'cards';\n /** Exclusive viewport threshold in CSS pixels. Defaults to 640; nonfinite/nonpositive values use the default. */\n mobileBreakpoint?: number;\n}\n"]}
@@ -10,6 +10,18 @@ export interface DataTableParts {
10
10
  searchInput?: React.InputHTMLAttributes<HTMLInputElement>;
11
11
  /** Scroll container. */
12
12
  tableContainer?: HTMLAttributes<HTMLDivElement>;
13
+ /** Semantic card list. */
14
+ cards?: HTMLAttributes<HTMLUListElement>;
15
+ /** One row presented as a card. */
16
+ card?: HTMLAttributes<HTMLLIElement>;
17
+ /** Column label in a card. */
18
+ cardLabel?: HTMLAttributes<HTMLElement>;
19
+ /** Column value in a card. */
20
+ cardValue?: HTMLAttributes<HTMLElement>;
21
+ /** Sorting, filtering and select-all controls above cards. */
22
+ cardControls?: HTMLAttributes<HTMLDivElement>;
23
+ /** Non-table loading, failure or empty status. */
24
+ cardStatus?: HTMLAttributes<HTMLDivElement>;
13
25
  /** Semantic table element. */
14
26
  table?: TableHTMLAttributes<HTMLTableElement>;
15
27
  /** Table head. */
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableParts.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableParts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EACR,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EACnB,MAAM,OAAO,CAAC;AAEf,+DAA+D;AAC/D,MAAM,WAAW,cAAc;IAC3B,+BAA+B;IAC/B,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IACtC,kCAAkC;IAClC,MAAM,CAAC,EAAE,cAAc,C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AAC,CAAC;IAC/C,gBAAgB;IAChB,GAAG,CAAC,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC;IAC1C,iBAAiB;IACjB,IAAI,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;IAC9C,uBAAuB;IACvB,QAAQ,CAAC,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC;IAC/C,wBAAwB;IACxB,SAAS,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;IACnD,yBAAyB;IACzB,UAAU,CAAC,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC;IACjD,0BAA0B;IAC1B,WAAW,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;IACrD,kCAAkC;IAClC,UAAU,CAAC,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC;IACjD,mCAAmC;IACnC,WAAW,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;CACxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableParts.js","sourceRoot":"","sources":["../../../DataTables/DataTableParts.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type React from 'react';\nimport type {\n HTMLAttributes,\n TableHTMLAttributes,\n TdHTMLAttributes,\n ThHTMLAttributes,\n} from 'react';\n\n/** Stable Cratis-owned parts for styling a `DataTableCore`. */\nexport interface DataTableParts {\n /** Outer table composition. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Loaded-page search wrapper. */\n search?: HTMLAttributes<HTMLDivElement>;\n /** Loaded-page search input. */\n searchInput?: React.InputHTMLAttributes<HTMLInputElement>;\n /** Scroll container. */\n tableContainer?: HTMLAttributes<HTMLDivElement>;\n /** Semantic table element. */\n table?: TableHTMLAttributes<HTMLTableElement>;\n /** Table head. */\n head?: HTMLAttributes<HTMLTableSectionElement>;\n /** Header row. */\n headerRow?: HTMLAttributes<HTMLTableRowElement>;\n /** Header cell. */\n headerCell?: ThHTMLAttributes<HTMLTableCellElement>;\n /** Table body. */\n body?: HTMLAttributes<HTMLTableSectionElement>;\n /** Data row. */\n row?: HTMLAttributes<HTMLTableRowElement>;\n /** Data cell. */\n cell?: TdHTMLAttributes<HTMLTableCellElement>;\n /** Empty-state row. */\n emptyRow?: HTMLAttributes<HTMLTableRowElement>;\n /** Empty-state cell. */\n emptyCell?: TdHTMLAttributes<HTMLTableCellElement>;\n /** Loading-state row. */\n loadingRow?: HTMLAttributes<HTMLTableRowElement>;\n /** Loading-state cell. */\n loadingCell?: TdHTMLAttributes<HTMLTableCellElement>;\n /** Failed or unauthorized row. */\n failureRow?: HTMLAttributes<HTMLTableRowElement>;\n /** Failed or unauthorized cell. */\n failureCell?: TdHTMLAttributes<HTMLTableCellElement>;\n}\n"]}
1
+ {"version":3,"file":"DataTableParts.js","sourceRoot":"","sources":["../../../DataTables/DataTableParts.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type React from 'react';\nimport type {\n HTMLAttributes,\n TableHTMLAttributes,\n TdHTMLAttributes,\n ThHTMLAttributes,\n} from 'react';\n\n/** Stable Cratis-owned parts for styling a `DataTableCore`. */\nexport interface DataTableParts {\n /** Outer table composition. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Loaded-page search wrapper. */\n search?: HTMLAttributes<HTMLDivElement>;\n /** Loaded-page search input. */\n searchInput?: React.InputHTMLAttributes<HTMLInputElement>;\n /** Scroll container. */\n tableContainer?: HTMLAttributes<HTMLDivElement>;\n /** Semantic card list. */\n cards?: HTMLAttributes<HTMLUListElement>;\n /** One row presented as a card. */\n card?: HTMLAttributes<HTMLLIElement>;\n /** Column label in a card. */\n cardLabel?: HTMLAttributes<HTMLElement>;\n /** Column value in a card. */\n cardValue?: HTMLAttributes<HTMLElement>;\n /** Sorting, filtering and select-all controls above cards. */\n cardControls?: HTMLAttributes<HTMLDivElement>;\n /** Non-table loading, failure or empty status. */\n cardStatus?: HTMLAttributes<HTMLDivElement>;\n /** Semantic table element. */\n table?: TableHTMLAttributes<HTMLTableElement>;\n /** Table head. */\n head?: HTMLAttributes<HTMLTableSectionElement>;\n /** Header row. */\n headerRow?: HTMLAttributes<HTMLTableRowElement>;\n /** Header cell. */\n headerCell?: ThHTMLAttributes<HTMLTableCellElement>;\n /** Table body. */\n body?: HTMLAttributes<HTMLTableSectionElement>;\n /** Data row. */\n row?: HTMLAttributes<HTMLTableRowElement>;\n /** Data cell. */\n cell?: TdHTMLAttributes<HTMLTableCellElement>;\n /** Empty-state row. */\n emptyRow?: HTMLAttributes<HTMLTableRowElement>;\n /** Empty-state cell. */\n emptyCell?: TdHTMLAttributes<HTMLTableCellElement>;\n /** Loading-state row. */\n loadingRow?: HTMLAttributes<HTMLTableRowElement>;\n /** Loading-state cell. */\n loadingCell?: TdHTMLAttributes<HTMLTableCellElement>;\n /** Failed or unauthorized row. */\n failureRow?: HTMLAttributes<HTMLTableRowElement>;\n /** Failed or unauthorized cell. */\n failureCell?: TdHTMLAttributes<HTMLTableCellElement>;\n}\n"]}
@@ -4,6 +4,8 @@ import type { DataTableParts } from './DataTableParts.js';
4
4
  /** Props for {@link DataTableRow}. */
5
5
  export interface DataTableRowProps<TData> {
6
6
  row: TData;
7
+ /** Shared identity for focus transfer between presentations. */
8
+ rowKey?: string;
7
9
  columns: ReactElement<ColumnProps<any>>[];
8
10
  /** The table's part attributes. */
9
11
  parts?: DataTableParts;
@@ -18,5 +20,5 @@ export interface DataTableRowProps<TData> {
18
20
  onToggleSelection: () => void;
19
21
  }
20
22
  /** One data row, activated by click, Enter or Space. */
21
- export declare const DataTableRow: <TData extends object>({ row, columns, parts: pt, selectionMode, isSelected, isInteractive, isRowSelected, rowClassName, resolvedSelectionAriaLabel, selectionGroupName, onActivate, onToggleSelection, }: DataTableRowProps<TData>) => import("react").JSX.Element;
23
+ export declare const DataTableRow: <TData extends object>({ row, rowKey, columns, parts: pt, selectionMode, isSelected, isInteractive, isRowSelected, rowClassName, resolvedSelectionAriaLabel, selectionGroupName, onActivate, onToggleSelection, }: DataTableRowProps<TData>) => import("react").JSX.Element;
22
24
  //# sourceMappingURL=DataTableRow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableRow.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableRow.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAa,cAAc,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAcvD,sCAAsC;AACtC,MAAM,WAAW,iBAAiB,CAAC,KAAK;IACpC,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IAC1C,mCAAmC;IACnC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,aAAa,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,KAAK,MAAM,CAAC;IAC1C,0BAA0B,EAAE,MAAM,CAAC;IACnC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC5C,iBAAiB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,wDAAwD;AACxD,eAAO,MAAM,YAAY,GAAI,KAAK,SAAS,MAAM,sLAa9C,iBAAiB,CAAC,KAAK,CAAC,gCAiE1B,CAAC"}
1
+ {"version":3,"file":"DataTableRow.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableRow.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAiB,YAAY,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAKvD,sCAAsC;AACtC,MAAM,WAAW,iBAAiB,CAAC,KAAK;IACpC,GAAG,EAAE,KAAK,CAAC;IACX,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IAC1C,mCAAmC;IACnC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,aAAa,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,KAAK,MAAM,CAAC;IAC1C,0BAA0B,EAAE,MAAM,CAAC;IACnC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC5C,iBAAiB,EAAE,MAAM,IAAI,CAAC;CACjC;AA8ED,wDAAwD;AACxD,eAAO,MAAM,YAAY,GAAI,KAAK,SAAS,MAAM,8LAc9C,iBAAiB,CAAC,KAAK,CAAC,gCA+B1B,CAAC"}
@@ -1,25 +1,30 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { classNames } from '../ClassNames/classNames.js';
3
- import { valueAtPath } from './valueAtPath.js';
3
+ import { dataTableCellContent } from './dataTableCellContent.js';
4
4
 
5
- const renderCellContent = (column, row) => {
6
- if (column.body)
7
- return column.body(row);
8
- const value = valueAtPath(row, column.field);
9
- return value == null ? '' : String(value);
5
+ const activateFromKeyboard = (event, onActivate) => {
6
+ if (event.target !== event.currentTarget || !['Enter', ' '].includes(event.key)) {
7
+ return;
8
+ }
9
+ event.preventDefault();
10
+ onActivate(event);
10
11
  };
11
- const DataTableRow = ({ row, columns, parts: pt, selectionMode, isSelected, isInteractive, isRowSelected, rowClassName, resolvedSelectionAriaLabel, selectionGroupName, onActivate, onToggleSelection, }) => (jsx("tr", { ...pt?.row, tabIndex: isInteractive ? 0 : pt?.row?.tabIndex, "aria-selected": selectionMode === 'single' ? isSelected : undefined, className: classNames('cratis-datatable__row', pt?.row?.className, rowClassName?.(row)), "data-cratis-part": 'row', "data-selected": isSelected || undefined, "data-interactive": isInteractive || undefined, onClick: (event) => onActivate(event), onKeyDown: (event) => {
12
- if (event.target !== event.currentTarget ||
13
- (event.key !== 'Enter' && event.key !== ' ')) {
14
- return;
15
- }
16
- event.preventDefault();
17
- onActivate(event);
18
- }, children: columns.map((column, columnIndex) => (jsx("td", { ...pt?.cell, style: {
19
- ...pt?.cell?.style,
20
- ...column.props.style,
21
- ...column.props.bodyStyle,
22
- }, className: classNames('cratis-datatable__cell', pt?.cell?.className, column.props.bodyClassName ?? column.props.className), "data-cratis-part": 'cell', "data-selected": isSelected || undefined, children: column.props.selectionMode === 'multiple' ? (jsx("input", { type: 'checkbox', "aria-label": resolvedSelectionAriaLabel, checked: isRowSelected, onClick: (event) => event.stopPropagation(), onChange: () => onToggleSelection() })) : column.props.selectionMode ? (jsx("input", { type: 'radio', name: selectionGroupName, readOnly: true, tabIndex: -1, "aria-label": resolvedSelectionAriaLabel, checked: isSelected })) : (renderCellContent(column.props, row)) }, columnIndex))) }));
12
+ const rowTabIndex = (isInteractive, parts) => isInteractive ? 0 : parts?.row?.tabIndex;
13
+ const rowCellContent = ({ column, row, isSelected, isRowSelected, resolvedSelectionAriaLabel, selectionGroupName, onToggleSelection, }) => {
14
+ if (column.props.selectionMode === 'multiple') {
15
+ return (jsx("input", { type: 'checkbox', "aria-label": resolvedSelectionAriaLabel, checked: isRowSelected, onClick: (event) => event.stopPropagation(), onChange: () => onToggleSelection() }));
16
+ }
17
+ if (column.props.selectionMode) {
18
+ return (jsx("input", { type: 'radio', name: selectionGroupName, readOnly: true, tabIndex: -1, "aria-label": resolvedSelectionAriaLabel, checked: isSelected }));
19
+ }
20
+ return dataTableCellContent(column.props, row);
21
+ };
22
+ const RowCell = ({ parts: pt, ...props }) => (jsx("td", { ...pt?.cell, style: {
23
+ ...pt?.cell?.style,
24
+ ...props.column.props.style,
25
+ ...props.column.props.bodyStyle,
26
+ }, className: classNames('cratis-datatable__cell', pt?.cell?.className, props.column.props.bodyClassName ?? props.column.props.className), "data-cratis-part": 'cell', "data-selected": props.isSelected || undefined, children: rowCellContent(props) }));
27
+ const DataTableRow = ({ row, rowKey, columns, parts: pt, selectionMode, isSelected, isInteractive, isRowSelected, rowClassName, resolvedSelectionAriaLabel, selectionGroupName, onActivate, onToggleSelection, }) => (jsx("tr", { ...pt?.row, tabIndex: rowTabIndex(isInteractive, pt), "aria-selected": selectionMode === 'single' ? isSelected : undefined, className: classNames('cratis-datatable__row', pt?.row?.className, rowClassName?.(row)), "data-cratis-part": 'row', "data-datatable-row-key": rowKey, "data-selected": isSelected || undefined, "data-interactive": isInteractive || undefined, onClick: (event) => onActivate(event), onKeyDown: (event) => activateFromKeyboard(event, onActivate), children: columns.map((column, columnIndex) => (jsx(RowCell, { column: column, row: row, parts: pt, isSelected: isSelected, isRowSelected: isRowSelected, resolvedSelectionAriaLabel: resolvedSelectionAriaLabel, selectionGroupName: selectionGroupName, onToggleSelection: onToggleSelection }, columnIndex))) }));
23
28
 
24
29
  export { DataTableRow };
25
30
  //# sourceMappingURL=DataTableRow.js.map