@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":"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,CACtB,MAAwB,EACxB,GAA4B,KACjB;IACX,IAAI,MAAM,CAAC,IAAI;AAAE,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IACxC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC;AAC5C,IAAA,OAAO,KAAK,IAAI,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;AAC7C,CAAC;AAoBM,MAAM,YAAY,GAAG,CAAuB,EAC/C,GAAG,EACH,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,sBACgB,KAAK,EAAA,eAAA,EACP,UAAU,IAAI,SAAS,EAAA,kBAAA,EACpB,aAAa,IAAI,SAAS,EAC5C,OAAO,EAAE,CAAC,KAAK,KAAK,U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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 { KeyboardEvent, 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\nconst activateFromKeyboard = (\n event: KeyboardEvent<HTMLTableRowElement>,\n onActivate: DataTableRowProps<object>['onActivate'],\n) => {\n if (event.target !== event.currentTarget || !['Enter', ' '].includes(event.key)) {\n return;\n }\n event.preventDefault();\n onActivate(event);\n};\n\nconst rowTabIndex = (isInteractive: boolean, parts: DataTableParts | undefined) =>\n isInteractive ? 0 : parts?.row?.tabIndex;\n\ninterface RowCellProps<TData> extends Pick<DataTableRowProps<TData>,\n 'row' | 'isSelected' | 'isRowSelected' | 'resolvedSelectionAriaLabel' |\n 'selectionGroupName' | 'onToggleSelection'> {\n column: DataTableRowProps<TData>['columns'][number];\n parts?: DataTableParts;\n}\n\nconst rowCellContent = <TData,>({\n column,\n row,\n isSelected,\n isRowSelected,\n resolvedSelectionAriaLabel,\n selectionGroupName,\n onToggleSelection,\n}: RowCellProps<TData>) => {\n if (column.props.selectionMode === 'multiple') {\n return (\n <input\n type='checkbox'\n aria-label={resolvedSelectionAriaLabel}\n checked={isRowSelected}\n onClick={(event) => event.stopPropagation()}\n onChange={() => onToggleSelection()}\n />\n );\n }\n if (column.props.selectionMode) {\n return (\n <input\n type='radio'\n name={selectionGroupName}\n readOnly\n tabIndex={-1}\n aria-label={resolvedSelectionAriaLabel}\n checked={isSelected}\n />\n );\n }\n return dataTableCellContent(column.props, row);\n};\n\nconst RowCell = <TData,>({ parts: pt, ...props }: RowCellProps<TData>) => (\n <td\n {...pt?.cell}\n style={{\n ...pt?.cell?.style,\n ...props.column.props.style,\n ...props.column.props.bodyStyle,\n }}\n className={classNames(\n 'cratis-datatable__cell',\n pt?.cell?.className,\n props.column.props.bodyClassName ?? props.column.props.className,\n )}\n data-cratis-part='cell'\n data-selected={props.isSelected || undefined}\n >\n {rowCellContent(props)}\n </td>\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={rowTabIndex(isInteractive, pt)}\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) => activateFromKeyboard(event, onActivate)}\n >\n {columns.map((column, columnIndex) => (\n <RowCell\n key={columnIndex}\n column={column}\n row={row}\n parts={pt}\n isSelected={isSelected}\n isRowSelected={isRowSelected}\n resolvedSelectionAriaLabel={resolvedSelectionAriaLabel}\n selectionGroupName={selectionGroupName}\n onToggleSelection={onToggleSelection}\n />\n ))}\n </tr>\n);\n"],"names":["_jsx"],"mappings":";;;;AA8BA,MAAM,oBAAoB,GAAG,CACzB,KAAyC,EACzC,UAAmD,KACnD;IACA,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,aAAa,IAAI,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QAC7E;IACJ;IACA,KAAK,CAAC,cAAc,EAAE;IACtB,UAAU,CAAC,KAAK,CAAC;AACrB,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,aAAsB,EAAE,KAAiC,KAC1E,aAAa,GAAG,CAAC,GAAG,KAAK,EAAE,GAAG,EAAE,QAAQ;AAS5C,MAAM,cAAc,GAAG,CAAS,EAC5B,MAAM,EACN,GAAG,EACH,UAAU,EACV,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,EAClB,iBAAiB,GACC,KAAI;IACtB,IAAI,MAAM,CAAC,KAAK,CAAC,aAAa,KAAK,UAAU,EAAE;AAC3C,QAAA,QACIA,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;IAEV;AACA,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE;QAC5B,QACIA,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,E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C,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 !==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,IAAA,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AACrE,CAAC;AAGM,MAAM,6BAA6B,GAAG,CAAC,KAAc,KAAI;AAC5D,IAAA,MAAM,IAAI,GAAG,MAAM,CAAiB,IAAI,CAAC;AACzC,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC;AAC9B,IAAA,MAAM,OAAO,GAAG,MAAM,CAAgC,SAAS,CAAC;IAChE,SAAS,CAAC,MAAK;QACX,MAAM,QAAQ,GAAG,CAAC,KAAiB,KAAI,EAAG,OAAO,CAAC,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1G,QAAA,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC;QAC9C,OAAO,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)));
@@ -1 +1 @@
1
- {"version":3,"file":"useRowSelection.js","sources":["../../../DataTables/useRowSelection.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, useMemo, useRef } from 'react';\nimport type { RowSelection } from './RowSelection';\nimport type { RowSelectionSource } from './RowSelectionSource';\nimport { valueAtPath } from './valueAtPath';\n\n/**\n * Single and multiple row selection by data key, or by object identity without one.\n * @param source The rows and the selection to work with.\n * @returns The selection state and actions.\n */\nexport const useRowSelection = <TData extends object>({\n data,\n visibleRows,\n dataKey,\n selection,\n selectedItems,\n onSelectedItemsChange,\n}: RowSelectionSource<TData>): RowSelection<TData> => {\n const dataKeyIdentity = (row: TData) =>\n String(valueAtPath(row as Record<string, unknown>, dataKey!));\n const dataKeyCounts = useMemo(() => {\n const counts = new Map<string, number>();\n if (!dataKey) return counts;\n for (const row of data) {\n const identity = String(valueAtPath(row as Record<string, unknown>, dataKey));\n counts.set(identity, (counts.get(identity) ?? 0) + 1);\n }\n return counts;\n }, [data, dataKey]);\n const firstLoadedIndexByDataKey = useMemo(() => {\n const indices = new Map<string, number>();\n if (!dataKey) return indices;\n data.forEach((row, loadedIndex) => {\n const identity = String(valueAtPath(row as Record<string, unknown>, dataKey));\n if (!indices.has(identity)) indices.set(identity, loadedIndex);\n });\n return indices;\n }, [data, dataKey]);\n const selectedLoadedIndex = selection ? data.indexOf(selection) : -1;\n const selectedDataKey = selection && dataKey ? dataKeyIdentity(selection) : undefined;\n const isSelectedRow = (row: TData, loadedIndex: number) => {\n if (!selection) return false;\n if (!dataKey) return loadedIndex === selectedLoadedIndex;\n\n const identity = dataKeyIdentity(row);\n if (identity !== selectedDataKey) return false;\n if ((dataKeyCounts.get(identity) ?? 0) <= 1) return true;\n if (selectedLoadedIndex >= 0) return loadedIndex === selectedLoadedIndex;\n return loadedIndex === firstLoadedIndexByDataKey.get(identity);\n };\n\n // Membership is by dataKey when there is one, and by object identity otherwise. A table whose\n // rows are replaced wholesale on every refresh - which is every observable query - keeps its\n // selection only in the first case, which is why dataKey matters here as much as it does for\n // single selection.\n const selectedItemsList = useMemo(() => selectedItems ?? [], [selectedItems]);\n const isRowSelected = (row: TData) =>\n dataKey\n ? selectedItemsList.some(\n (selected) => dataKeyIdentity(selected) === dataKeyIdentity(row),\n )\n : selectedItemsList.includes(row);\n\n const toggleRowSelection = (row: TData) => {\n const next = isRowSelected(row)\n ? selectedItemsList.filter((selected) =>\n dataKey\n ? dataKeyIdentity(selected) !== dataKeyIdentity(row)\n : selected !== row,\n )\n : [...selectedItemsList, row];\n onSelectedItemsChange?.(next);\n };\n\n // Select-all means the rows the user can currently see. A filtered table that silently selected\n // rows hidden behind the filter would act on more than it showed, which is the whole hazard of a\n // bulk action.\n const isVisibleRow = (row: TData) =>\n dataKey\n ? visibleRows.some(\n (visible) => dataKeyIdentity(visible) === dataKeyIdentity(row),\n )\n : visibleRows.includes(row);\n const selectedVisibleCount = visibleRows.filter((row) => isRowSelected(row)).length;\n const allFilteredRowsSelected =\n visibleRows.length > 0 && selectedVisibleCount === visibleRows.length;\n const someFilteredRowsSelected = selectedVisibleCount > 0 && !allFilteredRowsSelected;\n const selectAllRef = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (selectAllRef.current) {\n selectAllRef.current.indeterminate = someFilteredRowsSelected;\n }\n }, [someFilteredRowsSelected]);\n\n const toggleSelectAll = () => {\n if (allFilteredRowsSelected) {\n onSelectedItemsChange?.(\n selectedItemsList.filter((selected) => !isVisibleRow(selected)),\n );\n return;\n }\n const additions = visibleRows.filter((row) => !isRowSelected(row));\n onSelectedItemsChange?.([...selectedItemsList, ...additions]);\n };\n\n return {\n dataKeyIdentity,\n isSelectedRow,\n isRowSelected,\n toggleRowSelection,\n allFilteredRowsSelected,\n selectAllRef,\n toggleSelectAll,\n };\n};\n"],"names":[],"mappings":";;;AAaO,MAAM,eAAe,GAAG,CAAuB,EAClD,IAAI,EACJ,WAAW,EACX,OAAO,EACP,SAAS,EACT,aAAa,EACb,qBAAqB,GACG,KAAyB;AACjD,IAAA,MAAM,eAAe,GAAG,CAAC,GAAU,KAC/B,MAAM,CAAC,WAAW,CAAC,GAA8B,EAAE,OAAQ,CAAC,CAAC;AACjE,IAAA,MAAM,aAAa,GAAG,OAAO,CAAC,MAAK;AAC/B,QAAA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB;AACxC,QAAA,IAAI,CAAC,OAAO;AA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QAAQ,CAAC,GAAG,CAAC;AACnC,IAAA,MAAM,oBAAoB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM;AACnF,IAAA,MAAM,uBAAuB,GACzB,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,oBAAoB,KAAK,WAAW,CAAC,MAAM;IACzE,MAAM,wBAAwB,GAAG,oBAAoB,GAAG,CAAC,IAAI,CAAC,uBAAuB;AACrF,IAAA,MAAM,YAAY,GAAG,MAAM,CAAmB,IAAI,CAAC;IACnD,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,YAAY,CAAC,OAAO,EAAE;AACtB,YAAA,YAAY,CAAC,OAAO,CAAC,aAAa,GAAG,wBAAwB;QACjE;AACJ,IAAA,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAC;IAE9B,MAAM,eAAe,GAAG,MAAK;QACzB,IAAI,uBAAuB,EAAE;AACzB,YAAA,qBAAqB,GACjB,iBAAiB,CAAC,MAAM,CAAC,CAAC,QAAQ,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAClE;YACD;QACJ;AACA,QAAA,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAClE,qBAAqB,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAAC,CAAC;AACjE,IAAA,CAAC;IAED,OAAO;QACH,eAAe;QACf,aAAa;QACb,aAAa;QACb,kBAAkB;QAClB,uBAAuB;QACvB,YAAY;QACZ,eAAe;KAClB;AACL;;"}
1
+ {"version":3,"file":"useRowSelection.js","sources":["../../../DataTables/useRowSelection.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, useMemo, useRef } from 'react';\nimport type { RowSelection } from './RowSelection';\nimport type { RowSelectionSource } from './RowSelectionSource';\nimport { valueAtPath } from './valueAtPath';\n\n/**\n * Single and multiple row selection by data key, or by object identity without one.\n * @param source The rows and the selection to work with.\n * @returns The selection state and actions.\n */\nexport const useRowSelection = <TData extends object>({\n data,\n visibleRows,\n dataKey,\n selection,\n selectedItems,\n onSelectedItemsChange,\n}: RowSelectionSource<TData>): RowSelection<TData> => {\n const dataKeyIdentity = (row: TData) =>\n String(valueAtPath(row as Record<string, unknown>, dataKey!));\n const dataKeyCounts = useMemo(() => {\n const counts = new Map<string, number>();\n if (!dataKey) return counts;\n for (const row of data) {\n const identity = String(valueAtPath(row as Record<string, unknown>, dataKey));\n counts.set(identity, (counts.get(identity) ?? 0) + 1);\n }\n return counts;\n }, [data, dataKey]);\n const firstLoadedIndexByDataKey = useMemo(() => {\n const indices = new Map<string, number>();\n if (!dataKey) return indices;\n data.forEach((row, loadedIndex) => {\n const identity = String(valueAtPath(row as Record<string, unknown>, dataKey));\n if (!indices.has(identity)) indices.set(identity, loadedIndex);\n });\n return indices;\n }, [data, dataKey]);\n const selectedLoadedIndex = selection ? data.indexOf(selection) : -1;\n const selectedDataKey = selection && dataKey ? dataKeyIdentity(selection) : undefined;\n const isSelectedRow = (row: TData, loadedIndex: number) => {\n if (!selection) return false;\n if (!dataKey) return loadedIndex === selectedLoadedIndex;\n\n const identity = dataKeyIdentity(row);\n if (identity !== selectedDataKey) return false;\n if ((dataKeyCounts.get(identity) ?? 0) <= 1) return true;\n if (selectedLoadedIndex >= 0) return loadedIndex === selectedLoadedIndex;\n return loadedIndex === firstLoadedIndexByDataKey.get(identity);\n };\n\n // Membership is by dataKey when there is one, and by object identity otherwise. A table whose\n // rows are replaced wholesale on every refresh - which is every observable query - keeps its\n // selection only in the first case, which is why dataKey matters here as much as it does for\n // single selection.\n const selectedItemsList = useMemo(() => selectedItems ?? [], [selectedItems]);\n const isRowSelected = (row: TData) =>\n dataKey\n ? selectedItemsList.some(\n (selected) => dataKeyIdentity(selected) === dataKeyIdentity(row),\n )\n : selectedItemsList.includes(row);\n\n const toggleRowSelection = (row: TData) => {\n const next = isRowSelected(row)\n ? selectedItemsList.filter((selected) =>\n dataKey\n ? dataKeyIdentity(selected) !== dataKeyIdentity(row)\n : selected !== row,\n )\n : [...selectedItemsList, row];\n onSelectedItemsChange?.(next);\n };\n\n // Select-all means the rows the user can currently see. A filtered table that silently selected\n // rows hidden behind the filter would act on more than it showed, which is the whole hazard of a\n // bulk action.\n const isVisibleRow = (row: TData) =>\n dataKey\n ? visibleRows.some(\n (visible) => dataKeyIdentity(visible) === dataKeyIdentity(row),\n )\n : visibleRows.includes(row);\n const selectedVisibleCount = visibleRows.filter((row) => isRowSelected(row)).length;\n const allFilteredRowsSelected =\n visibleRows.length > 0 && selectedVisibleCount === visibleRows.length;\n const someFilteredRowsSelected = selectedVisibleCount > 0 && !allFilteredRowsSelected;\n const selectAllRef = useRef<HTMLInputElement>(null);\n // Layout changes replace the input without changing the partial-selection boolean.\n // Reapply after every commit so a newly mounted select-all gets its mixed state too.\n useEffect(() => {\n if (selectAllRef.current) {\n selectAllRef.current.indeterminate = someFilteredRowsSelected;\n }\n });\n\n const toggleSelectAll = () => {\n if (allFilteredRowsSelected) {\n onSelectedItemsChange?.(\n selectedItemsList.filter((selected) => !isVisibleRow(selected)),\n );\n return;\n }\n const additions = visibleRows.filter((row) => !isRowSelected(row));\n onSelectedItemsChange?.([...selectedItemsList, ...additions]);\n };\n\n return {\n dataKeyIdentity,\n isSelectedRow,\n isRowSelected,\n toggleRowSelection,\n allFilteredRowsSelected,\n selectAllRef,\n toggleSelectAll,\n };\n};\n"],"names":[],"mappings":";;;AAaO,MAAM,eAAe,GAAG,CAAuB,EAClD,IAAI,EACJ,WAAW,EACX,OAAO,EACP,SAAS,EACT,aAAa,EACb,qBAAqB,GACG,KAAyB;AACjD,IAAA,MAAM,eAAe,GAAG,CAAC,GAAU,KAC/B,MAAM,CAAC,WAAW,CAAC,GAA8B,EAAE,OAAQ,CAAC,CAAC;AACjE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};
27
- const PropertyTypeGlyph = ({ type }) => (jsx("span", { className: 'cratis-schema-editor__badge-glyph', "data-property-type": type, "aria-hidden": 'true', children: glyphs[type] }));
27
+ const PropertyTypeGlyph = ({ type }) => (jsx("span", { className: 'cratis-schema-editor__badge-glyph', "data-cratis-component": 'PropertyTypeGlyph', "data-property-type": type, "aria-hidden": 'true', children: glyphs[type] }));
28
28
 
29
29
  export { PropertyTypeGlyph };
30
30
  //# sourceMappingURL=PropertyTypeGlyph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyTypeGlyph.js","sources":["../../../../SchemaEditor/Tree/PropertyTypeGlyph.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 { PropertyType } from './PropertyType';\n\nconst iconProps = {\n viewBox: '0 0 12 12',\n fill: 'none',\n stroke: 'currentColor',\n strokeWidth: 1.5,\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n width: 11,\n height: 11,\n 'aria-hidden': true,\n} as const;\n\nconst glyphs: Record<PropertyType, React.ReactNode> = {\n [PropertyType.String]: 'Aa',\n [PropertyType.Number]: '123',\n [PropertyType.Boolean]: 'T/F',\n [PropertyType.Date]: (\n <svg {...iconProps}>\n <rect x='1' y='2.5' width='10' height='8.5' rx='1.5' />\n <path d='M1 5.5h10M4 1v3M8 1v3' />\n </svg>\n ),\n [PropertyType.Time]: (\n <svg {...iconProps}>\n <circle cx='6' cy='6' r='4.5' />\n <path d='M6 3.5v2.5l2 1' />\n </svg>\n ),\n [PropertyType.UniqueIdentifier]: (\n <svg {...iconProps}>\n <path d='M4.5 1.5 3.5 10.5M8.5 1.5 7.5 10.5M1.5 4h9M1.5 8h9' />\n </svg>\n ),\n [PropertyType.Object]: '{}',\n [PropertyType.StringArray]: '[A]',\n [PropertyType.NumberArray]: '[#]',\n [PropertyType.ObjectArray]: '[{}]',\n};\n\n/** Props for the glyph of a property type. */\nexport interface PropertyTypeGlyphProps {\n /** The type whose glyph is shown. */\n type: PropertyType;\n}\n\n/**\n * A short colored chip identifying a property type at a glance. It is decorative: the type's name is always\n * next to it, so it is hidden from assistive technology.\n */\nexport const PropertyTypeGlyph = ({ type }: PropertyTypeGlyphProps) => (\n <span className='cratis-schema-editor__badge-glyph' data-property-type={type} aria-hidden='true'>{glyphs[type]}</span>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAKA,MAAM,SAAS,GAAG;AACd,IAAA,OAAO,EAAE,WAAW;AACpB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM,EAAE,cAAc;AACtB,IAAA,WAAW,EAAE,GAAG;AAChB,IAAA,aAAa,EAAE,OAAO;AACtB,IAAA,cAAc,EAAE,OAAO;AACvB,IAAA,KAAK,EAAE,EAAE;AACT,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,aAAa,EAAE,IAAI;CACb;AAEV,MAAM,MAAM,GAA0C;AAClD,IAAA,CAAC,YAAY,CAAC,MAAM,GAAG,IAAI;AAC3B,IAAA,CAAC,YAAY,CAAC,MAAM,GAAG,KAAK;AAC5B,IAAA,CAAC,YAAY,CAAC,OAAO,GAAG,KAAK;AAC7B,IAAA,CAAC,YAAY,CAAC,IAAI,IACdA,IAAA,CAAA,KAAA,EAAA,EAAA,GAAS,SAAS,EAAA,QAAA,EAAA,CACdC,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,GAAG,EAAC,CAAC,EAAC,KAAK,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,EAAE,EAAC,KAAK,EAAA,CAAG,EACvDA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,uBAAuB,EAAA,CAAG,IAChC,CACT;AACD,IAAA,CAAC,YAAY,CAAC,IAAI,IACdD,IAAA,CAAA,KAAA,EAAA,EAAA,GAAS,SAAS,EAAA,QAAA,EAAA,CACdC,GAAA,CAAA,QAAA,EAAA,EAAQ,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,CAAC,EAAC,KAAK,EAAA,CAAG,EAChCA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,gBAAgB,EAAA,CAAG,IACzB,CACT;AACD,IAAA,CAAC,YAAY,CAAC,gBAAgB,IAC1BA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,SAAS,EAAA,QAAA,EACdA,cAAM,CAAC,EAAC,oDAAoD,EAAA,CAAG,GAC7D,CACT;AACD,IAAA,CAAC,YAAY,CAAC,MAAM,GAAG,IAAI;AAC3B,IAAA,CAAC,YAAY,CAAC,WAAW,GAAG,KAAK;AACjC,IAAA,CAAC,YAAY,CAAC,WAAW,GAAG,KAAK;AACjC,IAAA,CAAC,YAAY,CAAC,WAAW,GAAG,MAAM;CACrC;AAYM,MAAM,iBAAiB,GAAG,CAAC,EAAE,IAAI,EAA0B,MAC9DA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,mCAAmC,EAAA,oBAAA,EAAqB,IAAI,EAAA,aAAA,EAAc,MAAM,EAAA,QAAA,EAAE,MAAM,CAAC,IAAI,CAAC,EAAA,CAAQ;;"}
1
+ {"version":3,"file":"PropertyTypeGlyph.js","sources":["../../../../SchemaEditor/Tree/PropertyTypeGlyph.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 { PropertyType } from './PropertyType';\n\nconst iconProps = {\n viewBox: '0 0 12 12',\n fill: 'none',\n stroke: 'currentColor',\n strokeWidth: 1.5,\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n width: 11,\n height: 11,\n 'aria-hidden': true,\n} as const;\n\nconst glyphs: Record<PropertyType, React.ReactNode> = {\n [PropertyType.String]: 'Aa',\n [PropertyType.Number]: '123',\n [PropertyType.Boolean]: 'T/F',\n [PropertyType.Date]: (\n <svg {...iconProps}>\n <rect x='1' y='2.5' width='10' height='8.5' rx='1.5' />\n <path d='M1 5.5h10M4 1v3M8 1v3' />\n </svg>\n ),\n [PropertyType.Time]: (\n <svg {...iconProps}>\n <circle cx='6' cy='6' r='4.5' />\n <path d='M6 3.5v2.5l2 1' />\n </svg>\n ),\n [PropertyType.UniqueIdentifier]: (\n <svg {...iconProps}>\n <path d='M4.5 1.5 3.5 10.5M8.5 1.5 7.5 10.5M1.5 4h9M1.5 8h9' />\n </svg>\n ),\n [PropertyType.Object]: '{}',\n [PropertyType.StringArray]: '[A]',\n [PropertyType.NumberArray]: '[#]',\n [PropertyType.ObjectArray]: '[{}]',\n};\n\n/** Props for the glyph of a property type. */\nexport interface PropertyTypeGlyphProps {\n /** The type whose glyph is shown. */\n type: PropertyType;\n}\n\n/**\n * A short colored chip identifying a property type at a glance. It is decorative: the type's name is always\n * next to it, so it is hidden from assistive technology.\n */\nexport const PropertyTypeGlyph = ({ type }: PropertyTypeGlyphProps) => (\n <span className='cratis-schema-editor__badge-glyph' data-cratis-component='PropertyTypeGlyph' data-property-type={type} aria-hidden='true'>{glyphs[type]}</span>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAKA,MAAM,SAAS,GAAG;AACd,IAAA,OAAO,EAAE,WAAW;AACpB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM,EAAE,cAAc;AACtB,IAAA,WAAW,EAAE,GAAG;AAChB,IAAA,aAAa,EAAE,OAAO;AACtB,IAAA,cAAc,EAAE,OAAO;AACvB,IAAA,KAAK,EAAE,EAAE;AACT,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,aAAa,EAAE,IAAI;CACb;AAEV,MAAM,MAAM,GAA0C;AAClD,IAAA,CAAC,YAAY,CAAC,MAAM,GAAG,IAAI;AAC3B,IAAA,CAAC,YAAY,CAAC,MAAM,GAAG,KAAK;AAC5B,IAAA,CAAC,YAAY,CAAC,OAAO,GAAG,KAAK;AAC7B,IAAA,CAAC,YAAY,CAAC,IAAI,IACdA,IAAA,CAAA,KAAA,EAAA,EAAA,GAAS,SAAS,EAAA,Q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cards {
1521
+ display: grid;
1522
+ gap: 1rem;
1523
+ padding: 0.5rem;
1524
+ margin: 0;
1525
+ list-style: none;
1526
+ }
1527
+ .cratis-datatable__card {
1528
+ min-width: 0;
1529
+ padding: 1rem;
1530
+ border: 1px solid var(--cratis-surface-border);
1531
+ border-radius: var(--cratis-border-radius);
1532
+ background: var(--cratis-surface-card);
1533
+ overflow-wrap: anywhere;
1534
+ }
1535
+ .cratis-datatable__card[data-interactive='true']:hover {
1536
+ background: var(--cratis-surface-hover);
1537
+ }
1538
+ .cratis-datatable__card[data-selected='true'] {
1539
+ background: var(--cratis-highlight-bg);
1540
+ color: var(--cratis-highlight-text-color);
1541
+ }
1542
+ .cratis-datatable__card:focus-visible {
1543
+ outline: var(--cratis-focus-outline);
1544
+ outline-offset: var(--cratis-focus-outline-offset);
1545
+ box-shadow: var(--cratis-focus-ring);
1546
+ }
1547
+ .cratis-datatable__card dl {
1548
+ display: grid;
1549
+ gap: 0.75rem;
1550
+ margin: 0;
1551
+ }
1552
+ .cratis-datatable__card-field {
1553
+ min-width: 0;
1554
+ }
1555
+ .cratis-datatable__card-label {
1556
+ font-size: var(--cratis-font-size-sm);
1557
+ font-weight: var(--cratis-type-weight-bold);
1558
+ }
1559
+ .cratis-datatable__card-value {
1560
+ min-width: 0;
1561
+ margin: 0;
1562
+ }
1563
+ .cratis-datatable__card-controls {
1564
+ display: flex;
1565
+ flex-wrap: wrap;
1566
+ align-items: center;
1567
+ gap: 1rem;
1568
+ padding: 0.5rem;
1569
+ }
1570
+ .cratis-datatable__card-status {
1571
+ padding: 2rem 1rem;
1572
+ color: var(--cratis-text-color-secondary);
1573
+ text-align: center;
1574
+ }
1575
+ @media (forced-colors: active) {
1576
+ .cratis-datatable__card {
1577
+ border-color: CanvasText;
1578
+ }
1579
+ .cratis-datatable__card[data-selected='true'],
1580
+ .cratis-datatable__card:focus-visible {
1581
+ outline: 2px solid Highlight;
1582
+ box-shadow: none;
1583
+ }
1584
+ }
1585
+
1520
1586
  @media (prefers-reduced-motion: reduce) {
1521
1587
  .cratis-datatable__row {
1522
1588
  transition: none;
@@ -1316,6 +1316,72 @@
1316
1316
  text-align: center;
1317
1317
  }
1318
1318
 
1319
+ .cratis-datatable__cards {
1320
+ display: grid;
1321
+ gap: 1rem;
1322
+ padding: 0.5rem;
1323
+ margin: 0;
1324
+ list-style: none;
1325
+ }
1326
+ .cratis-datatable__card {
1327
+ min-width: 0;
1328
+ padding: 1rem;
1329
+ border: 1px solid var(--cratis-surface-border);
1330
+ border-radius: var(--cratis-border-radius);
1331
+ background: var(--cratis-surface-card);
1332
+ overflow-wrap: anywhere;
1333
+ }
1334
+ .cratis-datatable__card[data-interactive='true']:hover {
1335
+ background: var(--cratis-surface-hover);
1336
+ }
1337
+ .cratis-datatable__card[data-selected='true'] {
1338
+ background: var(--cratis-highlight-bg);
1339
+ color: var(--cratis-highlight-text-color);
1340
+ }
1341
+ .cratis-datatable__card:focus-visible {
1342
+ outline: var(--cratis-focus-outline);
1343
+ outline-offset: var(--cratis-focus-outline-offset);
1344
+ box-shadow: var(--cratis-focus-ring);
1345
+ }
1346
+ .cratis-datatable__card dl {
1347
+ display: grid;
1348
+ gap: 0.75rem;
1349
+ margin: 0;
1350
+ }
1351
+ .cratis-datatable__card-field {
1352
+ min-width: 0;
1353
+ }
1354
+ .cratis-datatable__card-label {
1355
+ font-size: var(--cratis-font-size-sm);
1356
+ font-weight: var(--cratis-type-weight-bold);
1357
+ }
1358
+ .cratis-datatable__card-value {
1359
+ min-width: 0;
1360
+ margin: 0;
1361
+ }
1362
+ .cratis-datatable__card-controls {
1363
+ display: flex;
1364
+ flex-wrap: wrap;
1365
+ align-items: center;
1366
+ gap: 1rem;
1367
+ padding: 0.5rem;
1368
+ }
1369
+ .cratis-datatable__card-status {
1370
+ padding: 2rem 1rem;
1371
+ color: var(--cratis-text-color-secondary);
1372
+ text-align: center;
1373
+ }
1374
+ @media (forced-colors: active) {
1375
+ .cratis-datatable__card {
1376
+ border-color: CanvasText;
1377
+ }
1378
+ .cratis-datatable__card[data-selected='true'],
1379
+ .cratis-datatable__card:focus-visible {
1380
+ outline: 2px solid Highlight;
1381
+ box-shadow: none;
1382
+ }
1383
+ }
1384
+
1319
1385
  @media (prefers-reduced-motion: reduce) {
1320
1386
  .cratis-datatable__row {
1321
1387
  transition: none;
@@ -1316,6 +1316,72 @@
1316
1316
  text-align: center;
1317
1317
  }
1318
1318
 
1319
+ .cratis-datatable__cards {
1320
+ display: grid;
1321
+ gap: 1rem;
1322
+ padding: 0.5rem;
1323
+ margin: 0;
1324
+ list-style: none;
1325
+ }
1326
+ .cratis-datatable__card {
1327
+ min-width: 0;
1328
+ padding: 1rem;
1329
+ border: 1px solid var(--cratis-surface-border);
1330
+ border-radius: var(--cratis-border-radius);
1331
+ background: var(--cratis-surface-card);
1332
+ overflow-wrap: anywhere;
1333
+ }
1334
+ .cratis-datatable__card[data-interactive='true']:hover {
1335
+ background: var(--cratis-surface-hover);
1336
+ }
1337
+ .cratis-datatable__card[data-selected='true'] {
1338
+ background: var(--cratis-highlight-bg);
1339
+ color: var(--cratis-highlight-text-color);
1340
+ }
1341
+ .cratis-datatable__card:focus-visible {
1342
+ outline: var(--cratis-focus-outline);
1343
+ outline-offset: var(--cratis-focus-outline-offset);
1344
+ box-shadow: var(--cratis-focus-ring);
1345
+ }
1346
+ .cratis-datatable__card dl {
1347
+ display: grid;
1348
+ gap: 0.75rem;
1349
+ margin: 0;
1350
+ }
1351
+ .cratis-datatable__card-field {
1352
+ min-width: 0;
1353
+ }
1354
+ .cratis-datatable__card-label {
1355
+ font-size: var(--cratis-font-size-sm);
1356
+ font-weight: var(--cratis-type-weight-bold);
1357
+ }
1358
+ .cratis-datatable__card-value {
1359
+ min-width: 0;
1360
+ margin: 0;
1361
+ }
1362
+ .cratis-datatable__card-controls {
1363
+ display: flex;
1364
+ flex-wrap: wrap;
1365
+ align-items: center;
1366
+ gap: 1rem;
1367
+ padding: 0.5rem;
1368
+ }
1369
+ .cratis-datatable__card-status {
1370
+ padding: 2rem 1rem;
1371
+ color: var(--cratis-text-color-secondary);
1372
+ text-align: center;
1373
+ }
1374
+ @media (forced-colors: active) {
1375
+ .cratis-datatable__card {
1376
+ border-color: CanvasText;
1377
+ }
1378
+ .cratis-datatable__card[data-selected='true'],
1379
+ .cratis-datatable__card:focus-visible {
1380
+ outline: 2px solid Highlight;
1381
+ box-shadow: none;
1382
+ }
1383
+ }
1384
+
1319
1385
  @media (prefers-reduced-motion: reduce) {
1320
1386
  .cratis-datatable__row {
1321
1387
  transition: none;