@cratis/components 4.53.0 → 4.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/compat-manifest.json +13 -13
  2. package/dist/esm/CommandDialog/CommandDialog.d.ts +9 -1
  3. package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
  4. package/dist/esm/CommandDialog/CommandDialog.js +10 -4
  5. package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
  6. package/dist/esm/CommandDialog/index.d.ts +1 -0
  7. package/dist/esm/CommandDialog/index.d.ts.map +1 -1
  8. package/dist/esm/CommandDialog/validationFeedback.d.ts +28 -0
  9. package/dist/esm/CommandDialog/validationFeedback.d.ts.map +1 -0
  10. package/dist/esm/CommandDialog/validationFeedback.js +20 -0
  11. package/dist/esm/CommandDialog/validationFeedback.js.map +1 -0
  12. package/dist/esm/Common/CratisComponentsProvider.d.ts +4 -0
  13. package/dist/esm/Common/CratisComponentsProvider.d.ts.map +1 -1
  14. package/dist/esm/Common/CratisComponentsProvider.js.map +1 -1
  15. package/dist/esm/DataTables/DataTableCard.d.ts +4 -0
  16. package/dist/esm/DataTables/DataTableCard.d.ts.map +1 -0
  17. package/dist/esm/DataTables/DataTableCard.js +43 -0
  18. package/dist/esm/DataTables/DataTableCard.js.map +1 -0
  19. package/dist/esm/DataTables/DataTableCardControls.d.ts +6 -0
  20. package/dist/esm/DataTables/DataTableCardControls.d.ts.map +1 -0
  21. package/dist/esm/DataTables/DataTableCardControls.js +27 -0
  22. package/dist/esm/DataTables/DataTableCardControls.js.map +1 -0
  23. package/dist/esm/DataTables/DataTableCards.d.ts +16 -0
  24. package/dist/esm/DataTables/DataTableCards.d.ts.map +1 -0
  25. package/dist/esm/DataTables/DataTableCards.js +40 -0
  26. package/dist/esm/DataTables/DataTableCards.js.map +1 -0
  27. package/dist/esm/DataTables/DataTableCore.d.ts +3 -1
  28. package/dist/esm/DataTables/DataTableCore.d.ts.map +1 -1
  29. package/dist/esm/DataTables/DataTableCore.js +8 -2
  30. package/dist/esm/DataTables/DataTableCore.js.map +1 -1
  31. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts +2 -1
  32. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts.map +1 -1
  33. package/dist/esm/DataTables/DataTableForObservableQuery.js +1 -1
  34. package/dist/esm/DataTables/DataTableForObservableQuery.js.map +1 -1
  35. package/dist/esm/DataTables/DataTableForQuery.d.ts +2 -1
  36. package/dist/esm/DataTables/DataTableForQuery.d.ts.map +1 -1
  37. package/dist/esm/DataTables/DataTableForQuery.js +1 -1
  38. package/dist/esm/DataTables/DataTableForQuery.js.map +1 -1
  39. package/dist/esm/DataTables/DataTableHeaderCell.d.ts +2 -2
  40. package/dist/esm/DataTables/DataTableHeaderCell.d.ts.map +1 -1
  41. package/dist/esm/DataTables/DataTableHeaderCell.js +5 -19
  42. package/dist/esm/DataTables/DataTableHeaderCell.js.map +1 -1
  43. package/dist/esm/DataTables/DataTableHeaderContent.d.ts +11 -0
  44. package/dist/esm/DataTables/DataTableHeaderContent.d.ts.map +1 -0
  45. package/dist/esm/DataTables/DataTableHeaderContent.js +37 -0
  46. package/dist/esm/DataTables/DataTableHeaderContent.js.map +1 -0
  47. package/dist/esm/DataTables/DataTableMessages.d.ts +2 -0
  48. package/dist/esm/DataTables/DataTableMessages.d.ts.map +1 -1
  49. package/dist/esm/DataTables/DataTableMessages.js.map +1 -1
  50. package/dist/esm/DataTables/DataTableMobileLayoutProps.d.ts +8 -0
  51. package/dist/esm/DataTables/DataTableMobileLayoutProps.d.ts.map +1 -0
  52. package/dist/esm/DataTables/DataTableMobileLayoutProps.js +4 -0
  53. package/dist/esm/DataTables/DataTableMobileLayoutProps.js.map +1 -0
  54. package/dist/esm/DataTables/DataTableParts.d.ts +12 -0
  55. package/dist/esm/DataTables/DataTableParts.d.ts.map +1 -1
  56. package/dist/esm/DataTables/DataTableParts.js.map +1 -1
  57. package/dist/esm/DataTables/DataTableRow.d.ts +3 -1
  58. package/dist/esm/DataTables/DataTableRow.d.ts.map +1 -1
  59. package/dist/esm/DataTables/DataTableRow.js +3 -9
  60. package/dist/esm/DataTables/DataTableRow.js.map +1 -1
  61. package/dist/esm/DataTables/DataTableRows.d.ts.map +1 -1
  62. package/dist/esm/DataTables/DataTableRows.js +1 -1
  63. package/dist/esm/DataTables/DataTableRows.js.map +1 -1
  64. package/dist/esm/DataTables/dataTableCellContent.d.ts +5 -0
  65. package/dist/esm/DataTables/dataTableCellContent.d.ts.map +1 -0
  66. package/dist/esm/DataTables/dataTableCellContent.js +11 -0
  67. package/dist/esm/DataTables/dataTableCellContent.js.map +1 -0
  68. package/dist/esm/DataTables/useDataTableMessages.d.ts.map +1 -1
  69. package/dist/esm/DataTables/useDataTableMessages.js +2 -0
  70. package/dist/esm/DataTables/useDataTableMessages.js.map +1 -1
  71. package/dist/esm/DataTables/useDataTablePresentationFocus.d.ts +3 -0
  72. package/dist/esm/DataTables/useDataTablePresentationFocus.d.ts.map +1 -0
  73. package/dist/esm/DataTables/useDataTablePresentationFocus.js +45 -0
  74. package/dist/esm/DataTables/useDataTablePresentationFocus.js.map +1 -0
  75. package/dist/esm/DataTables/useMobileLayout.d.ts +4 -0
  76. package/dist/esm/DataTables/useMobileLayout.d.ts.map +1 -0
  77. package/dist/esm/DataTables/useMobileLayout.js +20 -0
  78. package/dist/esm/DataTables/useMobileLayout.js.map +1 -0
  79. package/dist/esm/DataTables/useRowSelection.d.ts.map +1 -1
  80. package/dist/esm/DataTables/useRowSelection.js +1 -1
  81. package/dist/esm/DataTables/useRowSelection.js.map +1 -1
  82. package/dist/esm/Dialogs/Dialog.d.ts +7 -0
  83. package/dist/esm/Dialogs/Dialog.d.ts.map +1 -1
  84. package/dist/esm/Dialogs/Dialog.js.map +1 -1
  85. package/dist/esm/Dialogs/DialogImplementation.d.ts.map +1 -1
  86. package/dist/esm/Dialogs/DialogImplementation.js +1 -0
  87. package/dist/esm/Dialogs/DialogImplementation.js.map +1 -1
  88. package/dist/esm/Dialogs/DialogRefusalFeedback.d.ts +11 -0
  89. package/dist/esm/Dialogs/DialogRefusalFeedback.d.ts.map +1 -0
  90. package/dist/esm/Dialogs/DialogRefusalFeedback.js +4 -0
  91. package/dist/esm/Dialogs/DialogRefusalFeedback.js.map +1 -0
  92. package/dist/esm/Dialogs/DialogSlotHost.d.ts.map +1 -1
  93. package/dist/esm/Dialogs/DialogSlotHost.js +1 -0
  94. package/dist/esm/Dialogs/DialogSlotHost.js.map +1 -1
  95. package/dist/esm/Dialogs/index.d.ts +1 -0
  96. package/dist/esm/Dialogs/index.d.ts.map +1 -1
  97. package/dist/esm/Dialogs/useDialogFocus.d.ts +5 -2
  98. package/dist/esm/Dialogs/useDialogFocus.d.ts.map +1 -1
  99. package/dist/esm/Dialogs/useDialogFocus.js +14 -7
  100. package/dist/esm/Dialogs/useDialogFocus.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,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,C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AiB,EAC3C,cAAc,EAAE,MAAM,CAAC,KAAK,CAAC,oBAAoB,EACjD,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,EACzC,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,EACzC,MAAM,EAAE,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,s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OAAOA,GAAA,CAAC,kBAAkB,EAAA,EAAA,GAAK,KAAK,GAAI;IAC7F,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,GAAGA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,2BAA2B,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,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E,cAAc,CAAC,mBAAmB,CAAC,CAAC;IAChD,mBAAmB;IACnB,UAAU,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;IACpD,kBAAkB;IAClB,IAAI,CAAC,EAAE,cAAc,CAAC,uBAAuB,CAAC,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,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC1D,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;AAED,wDAAwD;AACxD,eAAO,MAAM,YAAY,GAAI,KAAK,SAAS,MAAM,8LAc9C,iBAAiB,CAAC,KAAK,CAAC,gCAkE1B,CAAC"}
@@ -1,14 +1,8 @@
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);
10
- };
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) => {
5
+ const DataTableRow = ({ row, rowKey, 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-datatable-row-key": rowKey, "data-selected": isSelected || undefined, "data-interactive": isInteractive || undefined, onClick: (event) => onActivate(event), onKeyDown: (event) => {
12
6
  if (event.target !== event.currentTarget ||
13
7
  (event.key !== 'Enter' && event.key !== ' ')) {
14
8
  return;
@@ -19,7 +13,7 @@ const DataTableRow = ({ row, columns, parts: pt, selectionMode, isSelected, isIn
19
13
  ...pt?.cell?.style,
20
14
  ...column.props.style,
21
15
  ...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))) }));
16
+ }, 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 })) : (dataTableCellContent(column.props, row)) }, columnIndex))) }));
23
17
 
24
18
  export { DataTableRow };
25
19
  //# sourceMappingURL=DataTableRow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableRow.js","sources":["../../../DataTables/DataTableRow.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 { ReactElement, ReactNode, SyntheticEvent } from 'react';\nimport type { ColumnProps } from './Column';\nimport { classNames } from '../ClassNames/classNames';\nimport type { DataTableParts } from './DataTableParts';\nimport { valueAtPath } from './valueAtPath';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nconst renderCellContent = (\n column: ColumnProps<any>,\n row: Record<string, unknown>,\n): ReactNode => {\n if (column.body) return column.body(row);\n const value = valueAtPath(row, column.field);\n return value == null ? '' : String(value);\n};\n\n/** Props for {@link DataTableRow}. */\nexport interface DataTableRowProps<TData> {\n row: TData;\n columns: ReactElement<ColumnProps<any>>[];\n /** The table's part attributes. */\n parts?: DataTableParts;\n selectionMode?: 'single' | 'multiple';\n isSelected: boolean;\n isInteractive: boolean;\n isRowSelected: boolean;\n rowClassName?: (rowData: TData) => string;\n resolvedSelectionAriaLabel: string;\n selectionGroupName: string;\n onActivate: (event: SyntheticEvent) => void;\n onToggleSelection: () => void;\n}\n\n/** One data row, activated by click, Enter or Space. */\nexport const DataTableRow = <TData extends object>({\n row,\n columns,\n parts: pt,\n selectionMode,\n isSelected,\n isInteractive,\n isRowSelected,\n rowClassName,\n resolvedSelectionAriaLabel,\n selectionGroupName,\n onActivate,\n onToggleSelection,\n}: DataTableRowProps<TData>) => (\n <tr\n {...pt?.row}\n tabIndex={isInteractive ? 0 : pt?.row?.tabIndex}\n aria-selected={selectionMode === 'single' ? isSelected : undefined}\n className={classNames(\n 'cratis-datatable__row',\n pt?.row?.className,\n rowClassName?.(row),\n )}\n data-cratis-part='row'\n data-selected={isSelected || undefined}\n data-interactive={isInteractive || undefined}\n onClick={(event) => onActivate(event)}\n onKeyDown={(event) => {\n if (\n event.target !== event.currentTarget ||\n (event.key !== 'Enter' && event.key !== ' ')\n ) {\n return;\n }\n event.preventDefault();\n onActivate(event);\n }}\n >\n {columns.map((column, columnIndex) => (\n <td\n key={columnIndex}\n {...pt?.cell}\n style={{\n ...pt?.cell?.style,\n ...column.props.style,\n ...column.props.bodyStyle,\n }}\n className={classNames(\n 'cratis-datatable__cell',\n pt?.cell?.className,\n column.props.bodyClassName ?? column.props.className,\n )}\n data-cratis-part='cell'\n data-selected={isSelected || undefined}\n >\n {column.props.selectionMode === 'multiple' ? (\n <input\n type='checkbox'\n aria-label={resolvedSelectionAriaLabel}\n checked={isRowSelected}\n onClick={(event) => event.stopPropagation()}\n onChange={() => onToggleSelection()}\n />\n ) : column.props.selectionMode ? (\n <input\n type='radio'\n name={selectionGroupName}\n readOnly\n tabIndex={-1}\n aria-label={resolvedSelectionAriaLabel}\n checked={isSelected}\n />\n ) : (\n renderCellContent(column.props, row as Record<string, unknown>)\n )}\n </td>\n ))}\n </tr>\n);\n"],"names":["_jsx"],"mappings":";;;;AAWA,MAAM,iBAAiB,GAAG,CACt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C,MAAM,EAAE,WAAW,MAC7BA,GAAA,CAAA,IAAA,EAAA,EAAA,GAEQ,EAAE,EAAE,IAAI,EACZ,KAAK,EAAE;AACH,YAAA,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK;AAClB,YAAA,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK;AACrB,YAAA,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS;AAC5B,SAAA,EACD,SAAS,EAAE,UAAU,CACjB,wBAAwB,EACxB,EAAE,EAAE,IAAI,EAAE,SAAS,EACnB,MAAM,CAAC,KAAK,CAAC,aAAa,IAAI,MAAM,CAAC,KAAK,CAAC,SAAS,CACvD,EAAA,kBAAA,EACgB,MAAM,EAAA,eAAA,EACR,UAAU,IAAI,SAAS,EAAA,QAAA,EAErC,MAAM,CAAC,KAAK,CAAC,aAAa,KAAK,UAAU,IACtCA,GAAA,CAAA,OAAA,EAAA,EACI,IAAI,EAAC,UAAU,EAAA,YAAA,EACH,0BAA0B,EACtC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,eAAe,EAAE,EAC3C,QAAQ,EAAE,MAAM,iBAAiB,EAAE,EAAA,CACrC,IACF,MAAM,CAAC,KAAK,CAAC,aAAa,IAC1BA,GAAA,CAAA,OAAA,EAAA,EACI,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,kBAAkB,EACxB,QAAQ,EAAA,IAAA,EACR,QAAQ,EAAE,EAAE,EAAA,YAAA,EACA,0BAA0B,EACtC,OAAO,EAAE,UAAU,EAAA,CACrB,KAEF,iBAAiB,CAAC,MAAM,CAAC,KAAK,EAAE,GAA8B,CAAC,CAClE,EAAA,EAlCI,WAAW,CAmCf,CACR,CAAC,EAAA,CACD;;"}
1
+ {"version":3,"file":"DataTableRow.js","sources":["../../../DataTables/DataTableRow.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 { ReactElement, SyntheticEvent } from 'react';\nimport type { ColumnProps } from './Column';\nimport { classNames } from '../ClassNames/classNames';\nimport type { DataTableParts } from './DataTableParts';\nimport { dataTableCellContent } from './dataTableCellContent';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/** Props for {@link DataTableRow}. */\nexport interface DataTableRowProps<TData> {\n row: TData;\n /** Shared identity for focus transfer between presentations. */\n rowKey?: string;\n columns: ReactElement<ColumnProps<any>>[];\n /** The table's part attributes. */\n parts?: DataTableParts;\n selectionMode?: 'single' | 'multiple';\n isSelected: boolean;\n isInteractive: boolean;\n isRowSelected: boolean;\n rowClassName?: (rowData: TData) => string;\n resolvedSelectionAriaLabel: string;\n selectionGroupName: string;\n onActivate: (event: SyntheticEvent) => void;\n onToggleSelection: () => void;\n}\n\n/** One data row, activated by click, Enter or Space. */\nexport const DataTableRow = <TData extends object>({\n row,\n rowKey,\n columns,\n parts: pt,\n selectionMode,\n isSelected,\n isInteractive,\n isRowSelected,\n rowClassName,\n resolvedSelectionAriaLabel,\n selectionGroupName,\n onActivate,\n onToggleSelection,\n}: DataTableRowProps<TData>) => (\n <tr\n {...pt?.row}\n tabIndex={isInteractive ? 0 : pt?.row?.tabIndex}\n aria-selected={selectionMode === 'single' ? isSelected : undefined}\n className={classNames(\n 'cratis-datatable__row',\n pt?.row?.className,\n rowClassName?.(row),\n )}\n data-cratis-part='row'\n data-datatable-row-key={rowKey}\n data-selected={isSelected || undefined}\n data-interactive={isInteractive || undefined}\n onClick={(event) => onActivate(event)}\n onKeyDown={(event) => {\n if (\n event.target !== event.currentTarget ||\n (event.key !== 'Enter' && event.key !== ' ')\n ) {\n return;\n }\n event.preventDefault();\n onActivate(event);\n }}\n >\n {columns.map((column, columnIndex) => (\n <td\n key={columnIndex}\n {...pt?.cell}\n style={{\n ...pt?.cell?.style,\n ...column.props.style,\n ...column.props.bodyStyle,\n }}\n className={classNames(\n 'cratis-datatable__cell',\n pt?.cell?.className,\n column.props.bodyClassName ?? column.props.className,\n )}\n data-cratis-part='cell'\n data-selected={isSelected || undefined}\n >\n {column.props.selectionMode === 'multiple' ? (\n <input\n type='checkbox'\n aria-label={resolvedSelectionAriaLabel}\n checked={isRowSelected}\n onClick={(event) => event.stopPropagation()}\n onChange={() => onToggleSelection()}\n />\n ) : column.props.selectionMode ? (\n <input\n type='radio'\n name={selectionGroupName}\n readOnly\n tabIndex={-1}\n aria-label={resolvedSelectionAriaLabel}\n checked={isSelected}\n />\n ) : (\n dataTableCellContent(column.props, row)\n )}\n </td>\n ))}\n </tr>\n);\n"],"names":["_jsx"],"mappings":";;;;AA+BO,MAAM,YAAY,GAAG,CAAuB,EAC/C,GAAG,EACH,MAAM,EACN,OAAO,EACP,KAAK,EAAE,EAAE,EACT,aAAa,EACb,UAAU,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,EAClB,UAAU,EACV,iBAAiB,GACM,MACvBA,GAAA,CAAA,IAAA,EAAA,EAAA,GACQ,EAAE,EAAE,GAAG,EACX,QAAQ,EAAE,aAAa,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAA,eAAA,EAChC,aAAa,KAAK,QAAQ,GAAG,UAAU,GAAG,SAAS,EAClE,SAAS,EAAE,UAAU,CACjB,uBAAuB,EACvB,EAAE,EAAE,GAAG,EAAE,SAAS,EAClB,YAAY,GAAG,GAAG,CAAC,CACtB,EAAA,kBAAA,EACgB,KAAK,EAAA,wBAAA,EACE,MAAM,EAAA,eAAA,EACf,UAAU,IAAI,SAAS,EAAA,kBAAA,EACpB,aAAa,IAAI,SAAS,EAC5C,OAAO,EAAE,CAAC,KAAK,KAAK,UAAU,CAAC,KAAK,CAAC,EACrC,SAAS,EAAE,CAAC,KAAK,KAAI;AACjB,QAAA,IACI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,aAAa;AACpC,aAAC,KAAK,CAAC,GAAG,KAAK,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,G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@ -1 +1 @@
1
- {"version":3,"file":"DataTableRows.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableRows.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAoB,CAAC;AAI7D,uCAAuC;AACvC,MAAM,WAAW,kBAAkB,CAAC,KAAK,SAAS,MAAM;IACpD,oEAAoE;IACpE,KAAK,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACjC,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,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,KAAK,MAAM,CAAC;IAC1C,0BAA0B,EAAE,MAAM,CAAC;IACnC,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAED,4EAA4E;AAC5E,eAAO,MAAM,aAAa,GAAI,KAAK,SAAS,MAAM,yCAI/C,kBAAkB,CAAC,KAAK,CAAC,gCAgB3B,CAAC"}
1
+ {"version":3,"file":"DataTableRows.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableRows.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAoB,CAAC;AAI7D,uCAAuC;AACvC,MAAM,WAAW,kBAAkB,CAAC,KAAK,SAAS,MAAM;IACpD,oEAAoE;IACpE,KAAK,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACjC,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,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,KAAK,MAAM,CAAC;IAC1C,0BAA0B,EAAE,MAAM,CAAC;IACnC,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAED,4EAA4E;AAC5E,eAAO,MAAM,aAAa,GAAI,KAAK,SAAS,MAAM,yCAI/C,kBAAkB,CAAC,KAAK,CAAC,gCAiB3B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { jsx, Fragment } from 'react/jsx-runtime';
2
2
  import { DataTableRow } from './DataTableRow.js';
3
3
 
4
- const DataTableRows = ({ state, selectionMode, ...rowProps }) => (jsx(Fragment, { children: state.filteredRows.map(({ row, loadedIndex }) => (jsx(DataTableRow, { row: row, selectionMode: selectionMode, isSelected: selectionMode === 'single' && state.isSelectedRow(row, loadedIndex), isInteractive: state.isInteractive, isRowSelected: state.isRowSelected(row), onActivate: (event) => state.activateRow(row, loadedIndex, event), onToggleSelection: () => state.toggleRowSelection(row), ...rowProps }, state.rowKeys[loadedIndex]))) }));
4
+ const DataTableRows = ({ state, selectionMode, ...rowProps }) => (jsx(Fragment, { children: state.filteredRows.map(({ row, loadedIndex }) => (jsx(DataTableRow, { row: row, rowKey: state.rowKeys[loadedIndex], selectionMode: selectionMode, isSelected: selectionMode === 'single' && state.isSelectedRow(row, loadedIndex), isInteractive: state.isInteractive, isRowSelected: state.isRowSelected(row), onActivate: (event) => state.activateRow(row, loadedIndex, event), onToggleSelection: () => state.toggleRowSelection(row), ...rowProps }, state.rowKeys[loadedIndex]))) }));
5
5
 
6
6
  export { DataTableRows };
7
7
  //# sourceMappingURL=DataTableRows.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableRows.js","sources":["../../../DataTables/DataTableRows.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 { ReactElement } from 'react';\nimport type { ColumnProps } from './Column';\nimport type { DataTableParts } from './DataTableParts';\nimport { DataTableRow } from './DataTableRow';\nimport type { DataTableRowsState } from './useDataTableRows';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/** Props for {@link DataTableRows}. */\nexport interface DataTableRowsProps<TData extends object> {\n /** The processed rows with their keys, selection and activation. */\n state: DataTableRowsState<TData>;\n columns: ReactElement<ColumnProps<any>>[];\n /** The table's part attributes. */\n parts?: DataTableParts;\n selectionMode?: 'single' | 'multiple';\n rowClassName?: (rowData: TData) => string;\n resolvedSelectionAriaLabel: string;\n selectionGroupName: string;\n}\n\n/** The data rows of a table, one {@link DataTableRow} per processed row. */\nexport const DataTableRows = <TData extends object>({\n state,\n selectionMode,\n ...rowProps\n}: DataTableRowsProps<TData>) => (\n <>\n {state.filteredRows.map(({ row, loadedIndex }) => (\n <DataTableRow<TData>\n key={state.rowKeys[loadedIndex]}\n row={row}\n selectionMode={selectionMode}\n isSelected={selectionMode === 'single' && state.isSelectedRow(row, loadedIndex)}\n isInteractive={state.isInteractive}\n isRowSelected={state.isRowSelected(row)}\n onActivate={(event) => state.activateRow(row, loadedIndex, event)}\n onToggleSelection={() => state.toggleRowSelection(row)}\n {...rowProps}\n />\n ))}\n </>\n);\n"],"names":["_jsx","_Fragment"],"mappings":";;;AAyBO,MAAM,aAAa,GAAG,CAAuB,EAChD,KAAK,EACL,aAAa,EACb,GAAG,QAAQ,EACa,MACxBA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EACK,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,MACzCD,GAAA,CAAC,YAAY,EAAA,EAET,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,aAAa,KAAK,QAAQ,IAAI,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,WAAW,CAAC,EAC/E,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EACvC,UAAU,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,CAAC,EACjE,iBAAiB,EAAE,MAAM,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAA,GAClD,QAAQ,EAAA,EARP,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CASjC,CACL,CAAC,EAAA,CACH;;"}
1
+ {"version":3,"file":"DataTableRows.js","sources":["../../../DataTables/DataTableRows.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 { ReactElement } from 'react';\nimport type { ColumnProps } from './Column';\nimport type { DataTableParts } from './DataTableParts';\nimport { DataTableRow } from './DataTableRow';\nimport type { DataTableRowsState } from './useDataTableRows';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/** Props for {@link DataTableRows}. */\nexport interface DataTableRowsProps<TData extends object> {\n /** The processed rows with their keys, selection and activation. */\n state: DataTableRowsState<TData>;\n columns: ReactElement<ColumnProps<any>>[];\n /** The table's part attributes. */\n parts?: DataTableParts;\n selectionMode?: 'single' | 'multiple';\n rowClassName?: (rowData: TData) => string;\n resolvedSelectionAriaLabel: string;\n selectionGroupName: string;\n}\n\n/** The data rows of a table, one {@link DataTableRow} per processed row. */\nexport const DataTableRows = <TData extends object>({\n state,\n selectionMode,\n ...rowProps\n}: DataTableRowsProps<TData>) => (\n <>\n {state.filteredRows.map(({ row, loadedIndex }) => (\n <DataTableRow<TData>\n key={state.rowKeys[loadedIndex]}\n row={row}\n rowKey={state.rowKeys[loadedIndex]}\n selectionMode={selectionMode}\n isSelected={selectionMode === 'single' && state.isSelectedRow(row, loadedIndex)}\n isInteractive={state.isInteractive}\n isRowSelected={state.isRowSelected(row)}\n onActivate={(event) => state.activateRow(row, loadedIndex, event)}\n onToggleSelection={() => state.toggleRowSelection(row)}\n {...rowProps}\n />\n ))}\n </>\n);\n"],"names":["_jsx","_Fragment"],"mappings":";;;AAyBO,MAAM,aAAa,GAAG,CAAuB,EAChD,KAAK,EACL,aAAa,EACb,GAAG,QAAQ,EACa,MACxBA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EACK,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,MACzCD,GAAA,CAAC,YAAY,EAAA,EAET,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAClC,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,aAAa,KAAK,QAAQ,IAAI,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,WAAW,CAAC,EAC/E,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EACvC,UAAU,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,CAAC,EACjE,iBAAiB,EAAE,MAAM,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAA,GAClD,QAAQ,EAAA,EATP,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAUjC,CACL,CAAC,EAAA,CACH;;"}
@@ -0,0 +1,5 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ColumnProps } from './Column.js';
3
+ /** Resolves a body template or nested field identically in either presentation. */
4
+ export declare const dataTableCellContent: <TData>(column: ColumnProps<TData>, row: TData) => ReactNode;
5
+ //# sourceMappingURL=dataTableCellContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataTableCellContent.d.ts","sourceRoot":"","sources":["../../../DataTables/dataTableCellContent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAG5C,mFAAmF;AACnF,eAAO,MAAM,oBAAoB,GAAI,KAAK,UAAU,WAAW,CAAC,KAAK,CAAC,OAAO,KAAK,KAAG,SAIpF,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { valueAtPath } from './valueAtPath.js';
2
+
3
+ const dataTableCellContent = (column, row) => {
4
+ if (column.body)
5
+ return column.body(row);
6
+ const value = valueAtPath(row, column.field);
7
+ return value == null ? '' : String(value);
8
+ };
9
+
10
+ export { dataTableCellContent };
11
+ //# sourceMappingURL=dataTableCellContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataTableCellContent.js","sources":["../../../DataTables/dataTableCellContent.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ReactNode } from 'react';\nimport type { ColumnProps } from './Column';\nimport { valueAtPath } from './valueAtPath';\n\n/** Resolves a body template or nested field identically in either presentation. */\nexport const dataTableCellContent = <TData>(column: ColumnProps<TData>, row: TData): ReactNode => {\n if (column.body) return column.body(row);\n const value = valueAtPath(row as Record<string, unknown>, column.field);\n return value == null ? '' : String(value);\n};\n"],"names":[],"mappings":";;MAQa,oBAAoB,GAAG,CAAQ,MAA0B,EAAE,GAAU,KAAe;IAC7F,IAAI,MAAM,CAAC,IAAI;AAAE,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IACxC,MAAM,KAAK,GAAG,WAAW,CAAC,GAA8B,EAAE,MAAM,CAAC,KAAK,CAAC;AACvE,IAAA,OAAO,KAAK,IAAI,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;AAC7C;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDataTableMessages.d.ts","sourceRoot":"","sources":["../../../DataTables/useDataTableMessages.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAA6B,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAqB,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,cAClB,yBAAyB,6BAErC,iBAiCF,CAAC"}
1
+ {"version":3,"file":"useDataTableMessages.d.ts","sourceRoot":"","sources":["../../../DataTables/useDataTableMessages.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAA6B,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAqB,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,cAClB,yBAAyB,6BAErC,iBAmCF,CAAC"}
@@ -12,6 +12,8 @@ const useDataTableMessages = (overrides, isServerMode = false) => {
12
12
  const { messages } = useCratisComponentsConfig();
13
13
  const dataTableMessages = messages?.dataTable;
14
14
  return {
15
+ resolvedSortAscending: dataTableMessages?.sortAscending ?? 'Ascending',
16
+ resolvedSortDescending: dataTableMessages?.sortDescending ?? 'Descending',
15
17
  resolvedSelectionAriaLabel: overrides.selectionAriaLabel ?? dataTableMessages?.selectRow ?? 'Select row',
16
18
  resolvedSelectAllAriaLabel: overrides.selectAllAriaLabel ??
17
19
  dataTableMessages?.selectAllRows ??
@@ -1 +1 @@
1
- {"version":3,"file":"useDataTableMessages.js","sources":["../../../DataTables/useDataTableMessages.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport type { DataTableMessageOverrides } from './DataTableMessageOverrides';\nimport type { DataTableMessages } from './DataTableMessages';\n\n/**\n * Resolves each table message from its prop, then the provider's `dataTable` messages, then the default.\n * @param overrides The messages passed as props.\n * @param isServerMode Whether the server, not the loaded page, applies search and filters.\n * @returns The messages to show.\n */\nexport const useDataTableMessages = (\n overrides: DataTableMessageOverrides,\n isServerMode = false,\n): DataTableMessages => {\n const { messages } = useCratisComponentsConfig();\n const dataTableMessages = messages?.dataTable;\n return {\n resolvedSelectionAriaLabel:\n overrides.selectionAriaLabel ?? dataTableMessages?.selectRow ?? 'Select row',\n resolvedSelectAllAriaLabel:\n overrides.selectAllAriaLabel ??\n dataTableMessages?.selectAllRows ??\n 'Select all rows',\n resolvedGlobalSearchPlaceholder:\n overrides.globalSearchPlaceholder ?? dataTableMessages?.search ?? 'Search…',\n resolvedGlobalSearchAriaLabel:\n overrides.globalSearchAriaLabel ??\n dataTableMessages?.searchAriaLabel ??\n 'Search table',\n resolvedLoadingMessage:\n overrides.loadingMessage ?? dataTableMessages?.loading ?? 'Loading…',\n resolvedFailureMessage:\n overrides.failureMessage ??\n dataTableMessages?.failed ??\n 'Could not load data.',\n resolvedUnauthorizedMessage:\n overrides.unauthorizedMessage ??\n dataTableMessages?.unauthorized ??\n 'You are not authorized to view this data.',\n resolvedFilteredEmptyMessage:\n overrides.filteredEmptyMessage ??\n (isServerMode\n ? (dataTableMessages?.filteredEmptyServer ?? 'No rows match the search.')\n : (dataTableMessages?.filteredEmpty ??\n 'No rows on this page match the search.')),\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;AAaO,MAAM,oBAAoB,GAAG,CAChC,SAAoC,EACpC,YAAY,GAAG,KAAK,KACD;AACnB,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,yBAAyB,EAAE;AAChD,IAAA,MAAM,iBAAiB,GAAG,QAAQ,EAAE,SAAS;IAC7C,OAAO;QACH,0BAA0B,EACtB,SAAS,CAAC,kBAAkB,IAAI,iBAAiB,EAAE,SAAS,IAAI,YAAY;QAChF,0BAA0B,EACtB,SAAS,CAAC,kBAAkB;AAC5B,YAAA,iBAAiB,EAAE,aAAa;YAChC,iBAAiB;QACrB,+BAA+B,EAC3B,SAAS,CAAC,uBAAuB,IAAI,iBAAiB,EAAE,MAAM,IAAI,SAAS;QAC/E,6BAA6B,EACzB,SAAS,CAAC,qBAAqB;AAC/B,YAAA,iBAAiB,EAAE,eAAe;YAClC,cAAc;QAClB,sBAAsB,EAClB,SAAS,CAAC,cAAc,IAAI,iBAAiB,EAAE,OAAO,IAAI,UAAU;QACxE,sBAAsB,EAClB,SAAS,CAAC,cAAc;AACxB,YAAA,iBAAiB,EAAE,MAAM;YACzB,sBAAsB;QAC1B,2BAA2B,EACvB,SAAS,CAAC,mBAAmB;AAC7B,YAAA,iBAAiB,EAAE,YAAY;YAC/B,2CAA2C;QAC/C,4BAA4B,EACxB,SAAS,CAAC,oBAAoB;AAC9B,aAAC;AACG,mBAAG,iBAAiB,EAAE,mBAAmB,IAAI,2BAA2B;AACxE,mBAAG,iBAAiB,EAAE,aAAa;AACjC,oBAAA,wCAAwC,CAAC,CAAC;KACvD;AACL;;"}
1
+ {"version":3,"file":"useDataTableMessages.js","sources":["../../../DataTables/useDataTableMessages.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport type { DataTableMessageOverrides } from './DataTableMessageOverrides';\nimport type { DataTableMessages } from './DataTableMessages';\n\n/**\n * Resolves each table message from its prop, then the provider's `dataTable` messages, then the default.\n * @param overrides The messages passed as props.\n * @param isServerMode Whether the server, not the loaded page, applies search and filters.\n * @returns The messages to show.\n */\nexport const useDataTableMessages = (\n overrides: DataTableMessageOverrides,\n isServerMode = false,\n): DataTableMessages => {\n const { messages } = useCratisComponentsConfig();\n const dataTableMessages = messages?.dataTable;\n return {\n resolvedSortAscending: dataTableMessages?.sortAscending ?? 'Ascending',\n resolvedSortDescending: dataTableMessages?.sortDescending ?? 'Descending',\n resolvedSelectionAriaLabel:\n overrides.selectionAriaLabel ?? dataTableMessages?.selectRow ?? 'Select row',\n resolvedSelectAllAriaLabel:\n overrides.selectAllAriaLabel ??\n dataTableMessages?.selectAllRows ??\n 'Select all rows',\n resolvedGlobalSearchPlaceholder:\n overrides.globalSearchPlaceholder ?? dataTableMessages?.search ?? 'Search…',\n resolvedGlobalSearchAriaLabel:\n overrides.globalSearchAriaLabel ??\n dataTableMessages?.searchAriaLabel ??\n 'Search table',\n resolvedLoadingMessage:\n overrides.loadingMessage ?? dataTableMessages?.loading ?? 'Loading…',\n resolvedFailureMessage:\n overrides.failureMessage ??\n dataTableMessages?.failed ??\n 'Could not load data.',\n resolvedUnauthorizedMessage:\n overrides.unauthorizedMessage ??\n dataTableMessages?.unauthorized ??\n 'You are not authorized to view this data.',\n resolvedFilteredEmptyMessage:\n overrides.filteredEmptyMessage ??\n (isServerMode\n ? (dataTableMessages?.filteredEmptyServer ?? 'No rows match the search.')\n : (dataTableMessages?.filteredEmpty ??\n 'No rows on this page match the search.')),\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;AAaO,MAAM,oBAAoB,GAAG,CAChC,SAAoC,EACpC,YAAY,GAAG,KAAK,KACD;AACnB,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,yBAAyB,EAAE;AAChD,IAAA,MAAM,iBAAiB,GAAG,QAAQ,EAAE,SAAS;IAC7C,OAAO;AACH,QAAA,qBAAqB,EAAE,iBAAiB,EAAE,aAAa,IAAI,WAAW;AACtE,QAAA,sBAAsB,EAAE,iBAAiB,EAAE,cAAc,IAAI,YAAY;QACzE,0BAA0B,EACtB,SAAS,CAAC,kBAAkB,IAAI,iBAAiB,EAAE,SAAS,IAAI,YAAY;QAChF,0BAA0B,EACtB,SAAS,CAAC,kBAAkB;AAC5B,YAAA,iBAAiB,EAAE,aAAa;YAChC,iBAAiB;QACrB,+BAA+B,EAC3B,SAAS,CAAC,uBAAuB,IAAI,iBAAiB,EAAE,MAAM,IAAI,SAAS;QAC/E,6BAA6B,EACzB,SAAS,CAAC,qBAAqB;AAC/B,YAAA,iBAAiB,EAAE,eAAe;YAClC,cAAc;QAClB,sBAAsB,EAClB,SAAS,CAAC,cAAc,IAAI,iBAAiB,EAAE,OAAO,IAAI,UAAU;QACxE,sBAAsB,EAClB,SAAS,CAAC,cAAc;AACxB,YAAA,iBAAiB,EAAE,MAAM;YACzB,sBAAsB;QAC1B,2BAA2B,EACvB,SAAS,CAAC,mBAAmB;AAC7B,YAAA,iBAAiB,EAAE,YAAY;YAC/B,2CAA2C;QAC/C,4BAA4B,EACxB,SAAS,CAAC,oBAAoB;AAC9B,aAAC;AACG,mBAAG,iBAAiB,EAAE,mBAAmB,IAAI,2BAA2B;AACxE,mBAAG,iBAAiB,EAAE,aAAa;AACjC,oBAAA,wCAAwC,CAAC,CAAC;KACvD;AACL;;"}
@@ -0,0 +1,3 @@
1
+ /** Transfers only focus lost when the outgoing presentation is removed. Never moves external focus. */
2
+ export declare const useDataTablePresentationFocus: (cards: boolean) => import("react").RefObject<HTMLDivElement | null>;
3
+ //# sourceMappingURL=useDataTablePresentationFocus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataTablePresentationFocus.d.ts","sourceRoot":"","sources":["../../../DataTables/useDataTablePresentationFocus.ts"],"names":[],"mappings":"AA6BA,uGAAuG;AACvG,eAAO,MAAM,6BAA6B,UAAW,OAAO,qDAc3D,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { useRef, useEffect, useLayoutEffect } from 'react';
2
+
3
+ const rowSelector = '[data-datatable-row-key]';
4
+ const selectionSelector = 'input[type="checkbox"], input[type="radio"]';
5
+ const rememberElement = (element, root) => {
6
+ if (!(element instanceof HTMLElement) || !root?.contains(element))
7
+ return undefined;
8
+ return {
9
+ element,
10
+ key: element.closest(rowSelector)?.getAttribute('data-datatable-row-key') ?? undefined,
11
+ selection: element.matches(selectionSelector),
12
+ };
13
+ };
14
+ const replacementTarget = (root, outgoing) => {
15
+ const row = Array.from(root?.querySelectorAll(rowSelector) ?? [])
16
+ .find(candidate => candidate.getAttribute('data-datatable-row-key') === outgoing.key);
17
+ const selection = outgoing.selection ? row?.querySelector(selectionSelector) : undefined;
18
+ return selection ?? (row?.hasAttribute('tabindex') ? row : undefined) ?? root;
19
+ };
20
+ const restoreRemovedFocus = (root, outgoing) => {
21
+ if (!outgoing || outgoing.element.isConnected)
22
+ return;
23
+ if (document.activeElement !== document.body)
24
+ return;
25
+ replacementTarget(root, outgoing)?.focus({ preventScroll: true });
26
+ };
27
+ const useDataTablePresentationFocus = (cards) => {
28
+ const root = useRef(null);
29
+ const previous = useRef(cards);
30
+ const focused = useRef(undefined);
31
+ useEffect(() => {
32
+ const remember = (event) => { focused.current = rememberElement(event.target, root.current); };
33
+ document.addEventListener('focusin', remember);
34
+ return () => document.removeEventListener('focusin', remember);
35
+ }, []);
36
+ useLayoutEffect(() => {
37
+ if (previous.current !== cards)
38
+ restoreRemovedFocus(root.current, focused.current);
39
+ previous.current = cards;
40
+ }, [cards]);
41
+ return root;
42
+ };
43
+
44
+ export { useDataTablePresentationFocus };
45
+ //# sourceMappingURL=useDataTablePresentationFocus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataTablePresentationFocus.js","sources":["../../../DataTables/useDataTablePresentationFocus.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useLayoutEffect, useRef } from 'react';\n\nconst rowSelector = '[data-datatable-row-key]';\nconst selectionSelector = 'input[type=\"checkbox\"], input[type=\"radio\"]';\ninterface PresentationFocus { element: HTMLElement; key?: string; selection: boolean }\n\nconst rememberElement = (element: EventTarget | null, root: HTMLElement | null): PresentationFocus | undefined => {\n if (!(element instanceof HTMLElement) || !root?.contains(element)) return undefined;\n return {\n element,\n key: element.closest(rowSelector)?.getAttribute('data-datatable-row-key') ?? undefined,\n selection: element.matches(selectionSelector),\n };\n};\nconst replacementTarget = (root: HTMLElement | null, outgoing: PresentationFocus) => {\n const row = Array.from(root?.querySelectorAll<HTMLElement>(rowSelector) ?? [])\n .find(candidate => candidate.getAttribute('data-datatable-row-key') === outgoing.key);\n const selection = outgoing.selection ? row?.querySelector<HTMLElement>(selectionSelector) : undefined;\n return selection ?? (row?.hasAttribute('tabindex') ? row : undefined) ?? root;\n};\nconst restoreRemovedFocus = (root: HTMLElement | null, outgoing?: PresentationFocus) => {\n if (!outgoing || outgoing.element.isConnected) return;\n if (document.activeElement !== document.body) return;\n replacementTarget(root, outgoing)?.focus({ preventScroll: true });\n};\n\n/** Transfers only focus lost when the outgoing presentation is removed. Never moves external focus. */\nexport const useDataTablePresentationFocus = (cards: boolean) => {\n const root = useRef<HTMLDivElement>(null);\n const previous = useRef(cards);\n const focused = useRef<PresentationFocus | undefined>(undefined);\n useEffect(() => {\n const remember = (event: FocusEvent) => { focused.current = rememberElement(event.target, root.current); };\n document.addEventListener('focusin', remember);\n return () => document.removeEventListener('focusin', remember);\n }, []);\n useLayoutEffect(() => {\n if (previous.current !== cards) restoreRemovedFocus(root.current, focused.current);\n previous.current = cards;\n }, [cards]);\n return root;\n};\n"],"names":[],"mappings":";;AAKA,MAAM,WAAW,GAAG,0BAA0B;AAC9C,MAAM,iBAAiB,GAAG,6CAA6C;AAGvE,MAAM,eAAe,GAAG,CAAC,OAA2B,EAAE,IAAwB,KAAmC;AAC7G,IAAA,IAAI,EAAE,OAAO,YAAY,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC;AAAE,QAAA,OAAO,SAAS;IACnF,OAAO;QACH,OAAO;AACP,QAAA,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC,wBAAwB,CAAC,IAAI,SAAS;AACtF,QAAA,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC;KAChD;AACL,CAAC;AACD,MAAM,iBAAiB,GAAG,CAAC,IAAwB,EA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AAO,MAAM,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,QAAQ,CAAC;IAClE,CAAC,EAAE,EAAE,CAAC;IACN,eAAe,CAAC,MAAK;AACjB,QAAA,IAAI,QAAQ,CAAC,OAAO,KAAK,KAAK;YAAE,mBAAmB,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;AAClF,QAAA,QAAQ,CAAC,OAAO,GAAG,KAAK;AAC5B,IAAA,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACX,IAAA,OAAO,IAAI;AACf;;"}
@@ -0,0 +1,4 @@
1
+ import type { DataTableMobileLayoutProps } from './DataTableMobileLayoutProps.js';
2
+ /** Whether this opt-in table should currently use cards; server rendering always uses a table. */
3
+ export declare const useMobileLayout: ({ mobileLayout, mobileBreakpoint }: DataTableMobileLayoutProps) => boolean;
4
+ //# sourceMappingURL=useMobileLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMobileLayout.d.ts","sourceRoot":"","sources":["../../../DataTables/useMobileLayout.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAA8B,CAAC;AAK/E,kGAAkG;AAClG,eAAO,MAAM,eAAe,uCAA8C,0BAA0B,KAAG,OAWtG,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { useMemo, useSyncExternalStore } from 'react';
2
+
3
+ const serverSnapshot = () => false;
4
+ const noSubscription = () => () => undefined;
5
+ const useMobileLayout = ({ mobileLayout, mobileBreakpoint = 640 }) => {
6
+ const breakpoint = Number.isFinite(mobileBreakpoint) && mobileBreakpoint > 0 ? mobileBreakpoint : 640;
7
+ const query = useMemo(() => {
8
+ if (mobileLayout !== 'cards' || typeof window === 'undefined' || typeof window.matchMedia !== 'function')
9
+ return undefined;
10
+ return window.matchMedia(`(width < ${breakpoint}px)`);
11
+ }, [mobileLayout, breakpoint]);
12
+ const subscribe = useMemo(() => query ? (notify) => {
13
+ query.addEventListener('change', notify);
14
+ return () => query.removeEventListener('change', notify);
15
+ } : noSubscription, [query]);
16
+ return useSyncExternalStore(subscribe, () => query?.matches ?? false, serverSnapshot);
17
+ };
18
+
19
+ export { useMobileLayout };
20
+ //# sourceMappingURL=useMobileLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMobileLayout.js","sources":["../../../DataTables/useMobileLayout.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useMemo, useSyncExternalStore } from 'react';\nimport type { DataTableMobileLayoutProps } from './DataTableMobileLayoutProps';\n\nconst serverSnapshot = () => false;\nconst noSubscription = () => () => undefined;\n\n/** Whether this opt-in table should currently use cards; server rendering always uses a table. */\nexport const useMobileLayout = ({ mobileLayout, mobileBreakpoint = 640 }: DataTableMobileLayoutProps): boolean => {\n const breakpoint = Number.isFinite(mobileBreakpoint) && mobileBreakpoint > 0 ? mobileBreakpoint : 640;\n const query = useMemo(() => {\n if (mobileLayout !== 'cards' || typeof window === 'undefined' || typeof window.matchMedia !== 'function') return undefined;\n return window.matchMedia(`(width < ${breakpoint}px)`);\n }, [mobileLayout, breakpoint]);\n const subscribe = useMemo(() => query ? (notify: () => void) => {\n query.addEventListener('change', notify);\n return () => query.removeEventListener('change', notify);\n } : noSubscription, [query]);\n return useSyncExternalStore(subscribe, () => query?.matches ?? false, serverSnapshot);\n};\n"],"names":[],"mappings":";;AAMA,MAAM,cAAc,GAAG,MAAM,KAAK;AAClC,MAAM,cAAc,GAAG,MAAM,MAAM,SAAS;AAGrC,MAAM,eAAe,GAAG,CAAC,EAAE,YAAY,EAAE,gBAAgB,GAAG,GAAG,EAA8B,KAAa;IAC7G,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,gBAAgB,GAAG,CAAC,GAAG,gBAAgB,GAAG,GAAG;AACrG,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,MAAK;AACvB,QAAA,IAAI,YAAY,KAAK,OAAO,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU;AAAE,YAAA,OAAO,SAAS;QAC1H,OAAO,MAAM,CAAC,UAAU,CAAC,YAAY,UAAU,CAAA,GAAA,CAAK,CAAC;AACzD,IAAA,CAAC,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AAC9B,IAAA,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,KAAK,GAAG,CAAC,MAAkB,KAAI;AAC3D,QAAA,KAAK,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC;QACxC,OAAO,MAAM,KAAK,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC5D,CAAC,GAAG,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC;AAC5B,IAAA,OAAO,oBAAoB,CAAC,SAAS,EAAE,MAAM,KAAK,EAAE,OAAO,IAAI,KAAK,EAAE,cAAc,CAAC;AACzF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useRowSelection.d.ts","sourceRoot":"","sources":["../../../DataTables/useRowSelection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAG/D;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,SAAS,MAAM,oFAOjD,kBAAkB,CAAC,KAAK,CAAC,KAAG,YAAY,CAAC,KAAK,CAiGhD,CAAC"}
1
+ {"version":3,"file":"useRowSelection.d.ts","sourceRoot":"","sources":["../../../DataTables/useRowSelection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAG/D;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,SAAS,MAAM,oFAOjD,kBAAkB,CAAC,KAAK,CAAC,KAAG,YAAY,CAAC,KAAK,CAmGhD,CAAC"}
@@ -63,7 +63,7 @@ const useRowSelection = ({ data, visibleRows, dataKey, selection, selectedItems,
63
63
  if (selectAllRef.current) {
64
64
  selectAllRef.current.indeterminate = someFilteredRowsSelected;
65
65
  }
66
- }, [someFilteredRowsSelected]);
66
+ });
67
67
  const toggleSelectAll = () => {
68
68
  if (allFilteredRowsSelected) {
69
69
  onSelectedItemsChange?.(selectedItemsList.filter((selected) => !isVisibleRow(selected)));