@rio-cloud/rio-uikit 2.3.0-beta.3 → 2.4.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 (119) hide show
  1. package/MapPreviousViewportButton.d.ts +2 -0
  2. package/MapPreviousViewportButton.js +5 -0
  3. package/MapPreviousViewportButton.js.map +1 -0
  4. package/Table.js +16 -14
  5. package/TableNext.js +16 -14
  6. package/TableRowActionsDropdown.d.ts +2 -0
  7. package/TableRowActionsDropdown.js +5 -0
  8. package/TableRowActionsDropdown.js.map +1 -0
  9. package/components/dropdown/ButtonDropdown.d.ts +4 -0
  10. package/components/dropdown/ButtonDropdown.js +82 -80
  11. package/components/dropdown/ButtonDropdown.js.map +1 -1
  12. package/components/map/components/Map.js +219 -182
  13. package/components/map/components/Map.js.map +1 -1
  14. package/components/map/components/MapContext.d.ts +4 -0
  15. package/components/map/components/MapContext.js +11 -7
  16. package/components/map/components/MapContext.js.map +1 -1
  17. package/components/map/components/MapPosition.d.ts +1 -1
  18. package/components/map/components/MapPosition.js +20 -13
  19. package/components/map/components/MapPosition.js.map +1 -1
  20. package/components/map/components/features/MapZoom.d.ts +0 -1
  21. package/components/map/components/features/MapZoom.js +12 -20
  22. package/components/map/components/features/MapZoom.js.map +1 -1
  23. package/components/map/components/features/settings/MapSettingsTile.d.ts +27 -0
  24. package/components/map/components/features/settings/MapSettingsTile.js +17 -17
  25. package/components/map/components/features/settings/MapSettingsTile.js.map +1 -1
  26. package/components/map/components/features/settings/buttons/MapPreviousViewportButton.d.ts +10 -0
  27. package/components/map/components/features/settings/buttons/MapPreviousViewportButton.js +23 -0
  28. package/components/map/components/features/settings/buttons/MapPreviousViewportButton.js.map +1 -0
  29. package/components/map/hooks/useMapViewportHistory.d.ts +19 -0
  30. package/components/map/hooks/useMapViewportHistory.js +116 -0
  31. package/components/map/hooks/useMapViewportHistory.js.map +1 -0
  32. package/components/map/icons/MapIcon.d.ts +1 -0
  33. package/components/map/icons/MapIcon.js +46 -37
  34. package/components/map/icons/MapIcon.js.map +1 -1
  35. package/components/map/utils/mapTypes.d.ts +12 -0
  36. package/components/map/utils/mapTypes.js.map +1 -1
  37. package/components/map/utils/mapUtils.d.ts +2 -0
  38. package/components/map/utils/mapUtils.js +4 -0
  39. package/components/map/utils/mapUtils.js.map +1 -1
  40. package/components/selects/Multiselect.d.ts +6 -0
  41. package/components/selects/Multiselect.js +85 -83
  42. package/components/selects/Multiselect.js.map +1 -1
  43. package/components/selects/Select.d.ts +6 -0
  44. package/components/selects/Select.js +79 -71
  45. package/components/selects/Select.js.map +1 -1
  46. package/components/table/Table.d.ts +5 -1
  47. package/components/table/Table.js +234 -210
  48. package/components/table/Table.js.map +1 -1
  49. package/components/table/Table.types.d.ts +55 -0
  50. package/components/table/TableExpandAllGroupsButton.d.ts +25 -0
  51. package/components/table/TableExpandAllGroupsButton.js +27 -0
  52. package/components/table/TableExpandAllGroupsButton.js.map +1 -0
  53. package/components/table/TableExpandedRow.d.ts +4 -0
  54. package/components/table/TableExpandedRow.js +101 -84
  55. package/components/table/TableExpandedRow.js.map +1 -1
  56. package/components/table/TableExpanderButton.js +11 -11
  57. package/components/table/TableExpanderButton.js.map +1 -1
  58. package/components/table/TableGroupRow.d.ts +16 -2
  59. package/components/table/TableGroupRow.js +57 -22
  60. package/components/table/TableGroupRow.js.map +1 -1
  61. package/components/table/TableHeader.d.ts +1 -9
  62. package/components/table/TableHeader.js +82 -65
  63. package/components/table/TableHeader.js.map +1 -1
  64. package/components/table/TableRow.d.ts +7 -1
  65. package/components/table/TableRow.js +89 -72
  66. package/components/table/TableRow.js.map +1 -1
  67. package/components/table/TableRowActionsDropdown.d.ts +11 -0
  68. package/components/table/TableRowActionsDropdown.js +22 -0
  69. package/components/table/TableRowActionsDropdown.js.map +1 -0
  70. package/components/table/TableStickyRowButton.d.ts +25 -0
  71. package/components/table/TableStickyRowButton.js +32 -0
  72. package/components/table/TableStickyRowButton.js.map +1 -0
  73. package/components/table/TableToolbar.d.ts +24 -3
  74. package/components/table/TableToolbar.js +78 -37
  75. package/components/table/TableToolbar.js.map +1 -1
  76. package/components/table/TableViewToggles.js +5 -5
  77. package/components/table/TableViewToggles.js.map +1 -1
  78. package/components/table/context/TableInteractionContext.d.ts +3 -0
  79. package/components/table/context/TableInteractionContext.js.map +1 -1
  80. package/components/table/context/TableRenderConfigContext.d.ts +2 -1
  81. package/components/table/context/TableRenderConfigContext.js.map +1 -1
  82. package/components/table/context/TableRenderContext.d.ts +1 -0
  83. package/components/table/context/TableRenderContext.js.map +1 -1
  84. package/components/table/layout/useMeasuredColumnMaxWidths.js +52 -54
  85. package/components/table/layout/useMeasuredColumnMaxWidths.js.map +1 -1
  86. package/components/table/layout/useTableLayout.d.ts +4 -1
  87. package/components/table/layout/useTableLayout.js +54 -48
  88. package/components/table/layout/useTableLayout.js.map +1 -1
  89. package/components/table/layout/useTableVirtualization.js +51 -56
  90. package/components/table/layout/useTableVirtualization.js.map +1 -1
  91. package/components/table/model/resolveResponsiveViewType.d.ts +2 -0
  92. package/components/table/model/resolveResponsiveViewType.js +27 -0
  93. package/components/table/model/resolveResponsiveViewType.js.map +1 -0
  94. package/components/table/render/header/TableHeaderCellContent.js +4 -4
  95. package/components/table/render/header/TableHeaderCellContent.js.map +1 -1
  96. package/components/table/render/header/TableHeaderSelectionCell.d.ts +3 -0
  97. package/components/table/render/header/TableHeaderSelectionCell.js +25 -14
  98. package/components/table/render/header/TableHeaderSelectionCell.js.map +1 -1
  99. package/components/table/runtime/useRenderDraftState.js +1 -0
  100. package/components/table/runtime/useRenderDraftState.js.map +1 -1
  101. package/components/table/runtime/useResponsiveResolvedViewType.d.ts +23 -0
  102. package/components/table/runtime/useResponsiveResolvedViewType.js +22 -0
  103. package/components/table/runtime/useResponsiveResolvedViewType.js.map +1 -0
  104. package/components/table/selection/useInternalTableSelectionState.d.ts +2 -0
  105. package/components/table/selection/useInternalTableSelectionState.js +29 -17
  106. package/components/table/selection/useInternalTableSelectionState.js.map +1 -1
  107. package/components/table/selection/useTableSelection.d.ts +5 -1
  108. package/components/table/selection/useTableSelection.js +37 -26
  109. package/components/table/selection/useTableSelection.js.map +1 -1
  110. package/components/table/shared/parsePixelSize.d.ts +2 -0
  111. package/components/table/shared/parsePixelSize.js +13 -0
  112. package/components/table/shared/parsePixelSize.js.map +1 -0
  113. package/hooks/useResizeObserver.d.ts +25 -6
  114. package/hooks/useResizeObserver.js +20 -18
  115. package/hooks/useResizeObserver.js.map +1 -1
  116. package/package.json +10 -10
  117. package/version.d.ts +1 -1
  118. package/version.js +2 -2
  119. package/version.js.map +1 -1
@@ -34,15 +34,15 @@ const o = {
34
34
  label: d ?? m ?? "",
35
35
  icon: /* @__PURE__ */ i("span", { className: `rioglyph ${o.TABLE}` })
36
36
  },
37
- {
38
- id: "SINGLE_CARD",
39
- label: C ?? w ?? "",
40
- icon: /* @__PURE__ */ i("span", { className: `rioglyph ${o.SINGLE_CARD}` })
41
- },
42
37
  {
43
38
  id: "MULTI_CARDS",
44
39
  label: g ?? L ?? "",
45
40
  icon: /* @__PURE__ */ i("span", { className: `rioglyph ${o.MULTI_CARDS}` })
41
+ },
42
+ {
43
+ id: "SINGLE_CARD",
44
+ label: C ?? w ?? "",
45
+ icon: /* @__PURE__ */ i("span", { className: `rioglyph ${o.SINGLE_CARD}` })
46
46
  }
47
47
  ], A = n.filter((e) => !T.includes(e.id)), _ = n.some((e) => e.label), h = S("TableViewToggles", a && a);
48
48
  return /* @__PURE__ */ i("div", { ...I, className: h, children: /* @__PURE__ */ i("div", { className: "form-group margin-bottom-0", children: /* @__PURE__ */ i(
@@ -1 +1 @@
1
- {"version":3,"file":"TableViewToggles.js","sources":["../../../src/components/table/TableViewToggles.tsx"],"sourcesContent":["import { type ReactNode, useEffect, useState } from 'react';\nimport { noop } from 'es-toolkit/compat';\n\nimport classNames from '../../utils/classNames';\nimport Select, { type SelectOption } from '../selects/Select';\n\nconst typeIcons: Record<TableViewTogglesViewType, string> = {\n TABLE: 'rioglyph-table-view',\n SINGLE_CARD: 'rioglyph-th-list',\n MULTI_CARDS: 'rioglyph-split-view',\n};\n\ntype TableViewToggleOption = SelectOption & {\n id: TableViewTogglesViewType;\n};\n\nexport type TableViewTogglesViewType = 'SINGLE_CARD' | 'MULTI_CARDS' | 'TABLE';\n\nexport type TableViewTogglesProps = {\n /**\n * The current viewType for controlling the TablesViewToggles component.\n *\n * Possible values are:\n *\n * - `'SINGLE_CARD'`\n * - `'MULTI_CARDS'`\n * - `'TABLE'`\n * - `TableViewToggles.VIEW_TYPE_TABLE`\n * - `TableViewToggles.VIEW_TYPE_SINGLE_CARD`\n * - `TableViewToggles.VIEW_TYPE_MULTI_CARDS`\n */\n viewType?: TableViewTogglesViewType;\n\n /**\n * Defines the initial viewType (when viewType is not controlled from the outside).\n *\n * Possible values are:\n *\n * - `'SINGLE_CARD'`\n * - `'MULTI_CARDS'`\n * - `'TABLE'`\n * - `TableViewToggles.VIEW_TYPE_TABLE`\n * - `TableViewToggles.VIEW_TYPE_SINGLE_CARD`\n * - `TableViewToggles.VIEW_TYPE_MULTI_CARDS`\n *\n * @default TableViewToggles.VIEW_TYPE_TABLE\n */\n initialViewType?: TableViewTogglesViewType;\n\n /**\n * Defines the view types which shall not be supported and are omitted.\n *\n * @default []\n */\n disabledViewTypes?: TableViewTogglesViewType[];\n\n /**\n * Callback function for when the user wants to change the viewType.\n *\n * Receives the new type as an argument.\n *\n * @param viewType The new viewType selected by the user.\n */\n onViewTypeChange: (viewType: TableViewTogglesViewType) => void;\n\n /**\n * Optional tooltip content for table view button.\n *\n * @deprecated Use `tableViewLabel` instead.\n */\n tableViewTooltipContent?: string | ReactNode;\n\n /**\n * Optional label content for the table view select item.\n */\n tableViewLabel?: string | ReactNode;\n\n /**\n * Optional tooltip content for single card view button.\n *\n * @deprecated Use `singleCardViewLabel` instead.\n */\n singleCardViewTooltipContent?: string | ReactNode;\n\n /**\n * Optional label content for the single card view select item.\n */\n singleCardViewLabel?: string | ReactNode;\n\n /**\n * Optional tooltip content for multi card view button.\n *\n * @deprecated Use `multiCardsViewLabel` instead.\n */\n multiCardsViewTooltipContent?: string | ReactNode;\n\n /**\n * Optional label content for the multi cards view select item.\n */\n multiCardsViewLabel?: string | ReactNode;\n\n /**\n * Disables all buttons.\n *\n * This means the buttons cannot be clicked. Used when disabling toolbar buttons during loading state or when the\n * corresponding table is empty.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Optional class names for the wrapper element.\n */\n className?: string;\n};\n\nconst TableViewToggles = (props: TableViewTogglesProps) => {\n const {\n viewType,\n initialViewType = 'TABLE',\n disabledViewTypes = [],\n onViewTypeChange = noop,\n tableViewTooltipContent,\n tableViewLabel,\n singleCardViewTooltipContent,\n singleCardViewLabel,\n multiCardsViewTooltipContent,\n multiCardsViewLabel,\n disabled = false,\n className,\n ...remainingProps\n } = props;\n\n const [internalViewType, setInternalViewType] = useState(initialViewType);\n\n // update internal state when external state changes - controlled component case\n useEffect(() => {\n if (viewType) {\n setInternalViewType(viewType);\n }\n }, [viewType]);\n\n const setViewType = (vt: TableViewTogglesViewType) => {\n setInternalViewType(vt);\n onViewTypeChange(vt);\n };\n\n const allOptions: TableViewToggleOption[] = [\n {\n id: 'TABLE',\n label: tableViewLabel ?? tableViewTooltipContent ?? '',\n icon: <span className={`rioglyph ${typeIcons.TABLE}`} />,\n },\n {\n id: 'SINGLE_CARD',\n label: singleCardViewLabel ?? singleCardViewTooltipContent ?? '',\n icon: <span className={`rioglyph ${typeIcons.SINGLE_CARD}`} />,\n },\n {\n id: 'MULTI_CARDS',\n label: multiCardsViewLabel ?? multiCardsViewTooltipContent ?? '',\n icon: <span className={`rioglyph ${typeIcons.MULTI_CARDS}`} />,\n },\n ];\n\n const options = allOptions.filter(option => !disabledViewTypes.includes(option.id));\n const hasOptionLabels = allOptions.some(option => option.label);\n\n const wrapperClassNames = classNames('TableViewToggles', className && className);\n\n return (\n <div {...remainingProps} className={wrapperClassNames}>\n <div className='form-group margin-bottom-0'>\n <Select\n options={options}\n value={[internalViewType]}\n onChange={item => item && setViewType(item.id as TableViewTogglesViewType)}\n disabled={disabled}\n showSelectedItemIcon\n pullRight\n dropdownClassName={!hasOptionLabels ? 'width-auto' : undefined}\n />\n </div>\n </div>\n );\n};\n\n// Don't export values as string but as a distinct union type\nTableViewToggles.VIEW_TYPE_TABLE = 'TABLE' as TableViewTogglesViewType;\nTableViewToggles.VIEW_TYPE_SINGLE_CARD = 'SINGLE_CARD' as TableViewTogglesViewType;\nTableViewToggles.VIEW_TYPE_MULTI_CARDS = 'MULTI_CARDS' as TableViewTogglesViewType;\n\nexport default TableViewToggles;\n"],"names":["typeIcons","TableViewToggles","props","viewType","initialViewType","disabledViewTypes","onViewTypeChange","noop","tableViewTooltipContent","tableViewLabel","singleCardViewTooltipContent","singleCardViewLabel","multiCardsViewTooltipContent","multiCardsViewLabel","disabled","className","remainingProps","internalViewType","setInternalViewType","useState","useEffect","setViewType","vt","allOptions","jsx","options","option","hasOptionLabels","wrapperClassNames","classNames","Select","item"],"mappings":";;;;;AAMA,MAAMA,IAAsD;AAAA,EACxD,OAAO;AAAA,EACP,aAAa;AAAA,EACb,aAAa;AACjB,GA2GMC,IAAmB,CAACC,MAAiC;AACvD,QAAM;AAAA,IACF,UAAAC;AAAA,IACA,iBAAAC,IAAkB;AAAA,IAClB,mBAAAC,IAAoB,CAAA;AAAA,IACpB,kBAAAC,IAAmBC;AAAA,IACnB,yBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,8BAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,8BAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,WAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,IACHd,GAEE,CAACe,GAAkBC,CAAmB,IAAIC,EAASf,CAAe;AAGxE,EAAAgB,EAAU,MAAM;AACZ,IAAIjB,KACAe,EAAoBf,CAAQ;AAAA,EAEpC,GAAG,CAACA,CAAQ,CAAC;AAEb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AAiB,wBAAwB;"}
1
+ {"version":3,"file":"TableViewToggles.js","sources":["../../../src/components/table/TableViewToggles.tsx"],"sourcesContent":["import { type ReactNode, useEffect, useState } from 'react';\nimport { noop } from 'es-toolkit/compat';\n\nimport classNames from '../../utils/classNames';\nimport Select, { type SelectOption } from '../selects/Select';\n\nconst typeIcons: Record<TableViewTogglesViewType, string> = {\n TABLE: 'rioglyph-table-view',\n SINGLE_CARD: 'rioglyph-th-list',\n MULTI_CARDS: 'rioglyph-split-view',\n};\n\ntype TableViewToggleOption = SelectOption & {\n id: TableViewTogglesViewType;\n};\n\nexport type TableViewTogglesViewType = 'SINGLE_CARD' | 'MULTI_CARDS' | 'TABLE';\n\nexport type TableViewTogglesProps = {\n /**\n * The current viewType for controlling the TablesViewToggles component.\n *\n * Possible values are:\n *\n * - `'SINGLE_CARD'`\n * - `'MULTI_CARDS'`\n * - `'TABLE'`\n * - `TableViewToggles.VIEW_TYPE_TABLE`\n * - `TableViewToggles.VIEW_TYPE_SINGLE_CARD`\n * - `TableViewToggles.VIEW_TYPE_MULTI_CARDS`\n */\n viewType?: TableViewTogglesViewType;\n\n /**\n * Defines the initial viewType (when viewType is not controlled from the outside).\n *\n * Possible values are:\n *\n * - `'SINGLE_CARD'`\n * - `'MULTI_CARDS'`\n * - `'TABLE'`\n * - `TableViewToggles.VIEW_TYPE_TABLE`\n * - `TableViewToggles.VIEW_TYPE_SINGLE_CARD`\n * - `TableViewToggles.VIEW_TYPE_MULTI_CARDS`\n *\n * @default TableViewToggles.VIEW_TYPE_TABLE\n */\n initialViewType?: TableViewTogglesViewType;\n\n /**\n * Defines the view types which shall not be supported and are omitted.\n *\n * @default []\n */\n disabledViewTypes?: TableViewTogglesViewType[];\n\n /**\n * Callback function for when the user wants to change the viewType.\n *\n * Receives the new type as an argument.\n *\n * @param viewType The new viewType selected by the user.\n */\n onViewTypeChange: (viewType: TableViewTogglesViewType) => void;\n\n /**\n * Optional tooltip content for table view button.\n *\n * @deprecated Use `tableViewLabel` instead.\n */\n tableViewTooltipContent?: string | ReactNode;\n\n /**\n * Optional label content for the table view select item.\n */\n tableViewLabel?: string | ReactNode;\n\n /**\n * Optional tooltip content for single card view button.\n *\n * @deprecated Use `singleCardViewLabel` instead.\n */\n singleCardViewTooltipContent?: string | ReactNode;\n\n /**\n * Optional label content for the single card view select item.\n */\n singleCardViewLabel?: string | ReactNode;\n\n /**\n * Optional tooltip content for multi card view button.\n *\n * @deprecated Use `multiCardsViewLabel` instead.\n */\n multiCardsViewTooltipContent?: string | ReactNode;\n\n /**\n * Optional label content for the multi cards view select item.\n */\n multiCardsViewLabel?: string | ReactNode;\n\n /**\n * Disables all buttons.\n *\n * This means the buttons cannot be clicked. Used when disabling toolbar buttons during loading state or when the\n * corresponding table is empty.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Optional class names for the wrapper element.\n */\n className?: string;\n};\n\nconst TableViewToggles = (props: TableViewTogglesProps) => {\n const {\n viewType,\n initialViewType = 'TABLE',\n disabledViewTypes = [],\n onViewTypeChange = noop,\n tableViewTooltipContent,\n tableViewLabel,\n singleCardViewTooltipContent,\n singleCardViewLabel,\n multiCardsViewTooltipContent,\n multiCardsViewLabel,\n disabled = false,\n className,\n ...remainingProps\n } = props;\n\n const [internalViewType, setInternalViewType] = useState(initialViewType);\n\n // update internal state when external state changes - controlled component case\n useEffect(() => {\n if (viewType) {\n setInternalViewType(viewType);\n }\n }, [viewType]);\n\n const setViewType = (vt: TableViewTogglesViewType) => {\n setInternalViewType(vt);\n onViewTypeChange(vt);\n };\n\n const allOptions: TableViewToggleOption[] = [\n {\n id: 'TABLE',\n label: tableViewLabel ?? tableViewTooltipContent ?? '',\n icon: <span className={`rioglyph ${typeIcons.TABLE}`} />,\n },\n {\n id: 'MULTI_CARDS',\n label: multiCardsViewLabel ?? multiCardsViewTooltipContent ?? '',\n icon: <span className={`rioglyph ${typeIcons.MULTI_CARDS}`} />,\n },\n {\n id: 'SINGLE_CARD',\n label: singleCardViewLabel ?? singleCardViewTooltipContent ?? '',\n icon: <span className={`rioglyph ${typeIcons.SINGLE_CARD}`} />,\n },\n ];\n\n const options = allOptions.filter(option => !disabledViewTypes.includes(option.id));\n const hasOptionLabels = allOptions.some(option => option.label);\n\n const wrapperClassNames = classNames('TableViewToggles', className && className);\n\n return (\n <div {...remainingProps} className={wrapperClassNames}>\n <div className='form-group margin-bottom-0'>\n <Select\n options={options}\n value={[internalViewType]}\n onChange={item => item && setViewType(item.id as TableViewTogglesViewType)}\n disabled={disabled}\n showSelectedItemIcon\n pullRight\n dropdownClassName={!hasOptionLabels ? 'width-auto' : undefined}\n />\n </div>\n </div>\n );\n};\n\n// Don't export values as string but as a distinct union type\nTableViewToggles.VIEW_TYPE_TABLE = 'TABLE' as TableViewTogglesViewType;\nTableViewToggles.VIEW_TYPE_SINGLE_CARD = 'SINGLE_CARD' as TableViewTogglesViewType;\nTableViewToggles.VIEW_TYPE_MULTI_CARDS = 'MULTI_CARDS' as TableViewTogglesViewType;\n\nexport default TableViewToggles;\n"],"names":["typeIcons","TableViewToggles","props","viewType","initialViewType","disabledViewTypes","onViewTypeChange","noop","tableViewTooltipContent","tableViewLabel","singleCardViewTooltipContent","singleCardViewLabel","multiCardsViewTooltipContent","multiCardsViewLabel","disabled","className","remainingProps","internalViewType","setInternalViewType","useState","useEffect","setViewType","vt","allOptions","jsx","options","option","hasOptionLabels","wrapperClassNames","classNames","Select","item"],"mappings":";;;;;AAMA,MAAMA,IAAsD;AAAA,EACxD,OAAO;AAAA,EACP,aAAa;AAAA,EACb,aAAa;AACjB,GA2GMC,IAAmB,CAACC,MAAiC;AACvD,QAAM;AAAA,IACF,UAAAC;AAAA,IACA,iBAAAC,IAAkB;AAAA,IAClB,mBAAAC,IAAoB,CAAA;AAAA,IACpB,kBAAAC,IAAmBC;AAAA,IACnB,yBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,8BAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,8BAAAC;AAAA,IACA,qBAA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AAAc,MAAQA,KAAQV,EAAYU,EAAK,EAA8B;AAAA,MACzE,UAAAjB;AAAA,MACA,sBAAoB;AAAA,MACpB,WAAS;AAAA,MACT,mBAAoBa,IAAiC,SAAf;AAAA,IAAe;AAAA,EAAA,GAE7D,EAAA,CACJ;AAER;AAGA1B,EAAiB,kBAAkB;AACnCA,EAAiB,wBAAwB;AACzCA,EAAiB,wBAAwB;"}
@@ -10,9 +10,12 @@ import { TableRowData, TableRowId, TableSortDirection } from '../Table.types';
10
10
  export type TableInteractionContextValue<RowType extends TableRowData> = {
11
11
  showSelectionColumn?: boolean;
12
12
  selectedRowIdSet: Set<TableRowId>;
13
+ selectableRowIdSet: Set<TableRowId>;
13
14
  selectionHeaderContent?: ReactNode;
14
15
  isAllRowsSelected?: boolean;
15
16
  isSomeRowsSelected?: boolean;
17
+ hasSelectableRows?: boolean;
18
+ hideSelectionCheckboxesForExcludedRows?: boolean;
16
19
  onToggleAllSelection?: () => void;
17
20
  onToggleRowSelection?: (rowId: TableRowId) => void;
18
21
  activeRowId?: TableRowId;
@@ -1 +1 @@
1
- {"version":3,"file":"TableInteractionContext.js","sources":["../../../../src/components/table/context/TableInteractionContext.tsx"],"sourcesContent":["import { createContext, useContext, type MouseEvent as ReactMouseEvent, type ReactNode } from 'react';\n\nimport type { TableRowData, TableRowId, TableSortDirection } from '../Table.types';\n\n/**\n * User-facing table interaction state and callbacks consumed by header/body cells.\n *\n * These values are conceptually different from the normalized render model:\n * they describe selection, sorting, and row activation/click behavior rather than\n * the structural table draft.\n */\nexport type TableInteractionContextValue<RowType extends TableRowData> = {\n showSelectionColumn?: boolean;\n selectedRowIdSet: Set<TableRowId>;\n selectionHeaderContent?: ReactNode;\n isAllRowsSelected?: boolean;\n isSomeRowsSelected?: boolean;\n onToggleAllSelection?: () => void;\n onToggleRowSelection?: (rowId: TableRowId) => void;\n activeRowId?: TableRowId;\n onActiveRowChange?: (rowId: TableRowId | undefined, row: RowType, rowIndex: number) => void;\n onRowClick?: (row: RowType, rowIndex: number) => void;\n isClickable: boolean;\n onSortChange?: (\n columnKey: string,\n direction: TableSortDirection,\n event: ReactMouseEvent<HTMLButtonElement>\n ) => void;\n};\n\nexport const TableInteractionContext = createContext<TableInteractionContextValue<TableRowData> | null>(null);\n\nexport const useOptionalTableInteractionContext = <RowType extends TableRowData>() =>\n useContext(TableInteractionContext) as TableInteractionContextValue<RowType> | null;\n\nexport const useTableInteractionContext = <RowType extends TableRowData>() => {\n const context = useOptionalTableInteractionContext<RowType>();\n\n if (!context) {\n throw new Error('Table interaction context is missing.');\n }\n\n return context;\n};\n"],"names":["TableInteractionContext","createContext","useOptionalTableInteractionContext","useContext"],"mappings":";AA8BO,MAAMA,IAA0BC,EAAiE,IAAI,GAE/FC,IAAqC,MAC9CC,EAAWH,CAAuB;"}
1
+ {"version":3,"file":"TableInteractionContext.js","sources":["../../../../src/components/table/context/TableInteractionContext.tsx"],"sourcesContent":["import { createContext, useContext, type MouseEvent as ReactMouseEvent, type ReactNode } from 'react';\n\nimport type { TableRowData, TableRowId, TableSortDirection } from '../Table.types';\n\n/**\n * User-facing table interaction state and callbacks consumed by header/body cells.\n *\n * These values are conceptually different from the normalized render model:\n * they describe selection, sorting, and row activation/click behavior rather than\n * the structural table draft.\n */\nexport type TableInteractionContextValue<RowType extends TableRowData> = {\n showSelectionColumn?: boolean;\n selectedRowIdSet: Set<TableRowId>;\n selectableRowIdSet: Set<TableRowId>;\n selectionHeaderContent?: ReactNode;\n isAllRowsSelected?: boolean;\n isSomeRowsSelected?: boolean;\n hasSelectableRows?: boolean;\n hideSelectionCheckboxesForExcludedRows?: boolean;\n onToggleAllSelection?: () => void;\n onToggleRowSelection?: (rowId: TableRowId) => void;\n activeRowId?: TableRowId;\n onActiveRowChange?: (rowId: TableRowId | undefined, row: RowType, rowIndex: number) => void;\n onRowClick?: (row: RowType, rowIndex: number) => void;\n isClickable: boolean;\n onSortChange?: (\n columnKey: string,\n direction: TableSortDirection,\n event: ReactMouseEvent<HTMLButtonElement>\n ) => void;\n};\n\nexport const TableInteractionContext = createContext<TableInteractionContextValue<TableRowData> | null>(null);\n\nexport const useOptionalTableInteractionContext = <RowType extends TableRowData>() =>\n useContext(TableInteractionContext) as TableInteractionContextValue<RowType> | null;\n\nexport const useTableInteractionContext = <RowType extends TableRowData>() => {\n const context = useOptionalTableInteractionContext<RowType>();\n\n if (!context) {\n throw new Error('Table interaction context is missing.');\n }\n\n return context;\n};\n"],"names":["TableInteractionContext","createContext","useOptionalTableInteractionContext","useContext"],"mappings":";AAiCO,MAAMA,IAA0BC,EAAiE,IAAI,GAE/FC,IAAqC,MAC9CC,EAAWH,CAAuB;"}
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { MotionProps } from 'motion/react';
3
- import { TableCellClassName, TableExpandedRowAnimation, TableRowClassName, TableRowData, TableViewType } from '../Table.types';
3
+ import { TableCellClassName, TableExpandedRowAnimation, TableRowClassName, TableRowData, TableVerticalAlign, TableViewType } from '../Table.types';
4
4
  import { TableViewCardClasses } from '../model/tableView.types';
5
5
  /**
6
6
  * Render-facing table configuration.
@@ -17,6 +17,7 @@ export type TableRenderConfigContextValue<RowType extends TableRowData> = {
17
17
  rowKey?: keyof RowType | ((row: RowType, rowIndex: number) => string | number);
18
18
  rowClassName?: TableRowClassName<RowType>;
19
19
  cellClassName?: TableCellClassName<RowType>;
20
+ selectionCheckboxVerticalAlignment?: TableVerticalAlign;
20
21
  rowAnimationProps?: MotionProps | ((row: RowType, rowIndex: number) => MotionProps);
21
22
  expandedRowAnimation?: TableExpandedRowAnimation;
22
23
  virtualizedRows?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"TableRenderConfigContext.js","sources":["../../../../src/components/table/context/TableRenderConfigContext.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from 'react';\nimport type { MotionProps } from 'motion/react';\n\nimport type {\n TableCellClassName,\n TableExpandedRowAnimation,\n TableRowClassName,\n TableRowData,\n TableViewType,\n} from '../Table.types';\nimport type { TableViewCardClasses } from '../model/tableView.types';\n\n/**\n * Render-facing table configuration.\n *\n * These values come from public table props and are forwarded into row/cell/header\n * components during rendering. They are separate from the normalized render model,\n * which lives in `TableRenderContext`.\n */\nexport type TableRenderConfigContextValue<RowType extends TableRowData> = {\n viewType: TableViewType;\n isTableView: boolean;\n cardClasses: TableViewCardClasses;\n noRowsState: ReactNode;\n rowKey?: keyof RowType | ((row: RowType, rowIndex: number) => string | number);\n rowClassName?: TableRowClassName<RowType>;\n cellClassName?: TableCellClassName<RowType>;\n rowAnimationProps?: MotionProps | ((row: RowType, rowIndex: number) => MotionProps);\n expandedRowAnimation?: TableExpandedRowAnimation;\n virtualizedRows?: boolean;\n virtualizationOverscan?: number;\n};\n\nexport const TableRenderConfigContext = createContext<TableRenderConfigContextValue<TableRowData> | null>(null);\n\nexport const useOptionalTableRenderConfigContext = <RowType extends TableRowData>() =>\n useContext(TableRenderConfigContext) as TableRenderConfigContextValue<RowType> | null;\n\nexport const useTableRenderConfigContext = <RowType extends TableRowData>() => {\n const context = useOptionalTableRenderConfigContext<RowType>();\n\n if (!context) {\n throw new Error('Table render config context is missing.');\n }\n\n return context;\n};\n"],"names":["TableRenderConfigContext","createContext","useOptionalTableRenderConfigContext","useContext"],"mappings":";AAiCO,MAAMA,IAA2BC,EAAkE,IAAI,GAEjGC,IAAsC,MAC/CC,EAAWH,CAAwB;"}
1
+ {"version":3,"file":"TableRenderConfigContext.js","sources":["../../../../src/components/table/context/TableRenderConfigContext.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from 'react';\nimport type { MotionProps } from 'motion/react';\n\nimport type {\n TableCellClassName,\n TableExpandedRowAnimation,\n TableRowClassName,\n TableRowData,\n TableVerticalAlign,\n TableViewType,\n} from '../Table.types';\nimport type { TableViewCardClasses } from '../model/tableView.types';\n\n/**\n * Render-facing table configuration.\n *\n * These values come from public table props and are forwarded into row/cell/header\n * components during rendering. They are separate from the normalized render model,\n * which lives in `TableRenderContext`.\n */\nexport type TableRenderConfigContextValue<RowType extends TableRowData> = {\n viewType: TableViewType;\n isTableView: boolean;\n cardClasses: TableViewCardClasses;\n noRowsState: ReactNode;\n rowKey?: keyof RowType | ((row: RowType, rowIndex: number) => string | number);\n rowClassName?: TableRowClassName<RowType>;\n cellClassName?: TableCellClassName<RowType>;\n selectionCheckboxVerticalAlignment?: TableVerticalAlign;\n rowAnimationProps?: MotionProps | ((row: RowType, rowIndex: number) => MotionProps);\n expandedRowAnimation?: TableExpandedRowAnimation;\n virtualizedRows?: boolean;\n virtualizationOverscan?: number;\n};\n\nexport const TableRenderConfigContext = createContext<TableRenderConfigContextValue<TableRowData> | null>(null);\n\nexport const useOptionalTableRenderConfigContext = <RowType extends TableRowData>() =>\n useContext(TableRenderConfigContext) as TableRenderConfigContextValue<RowType> | null;\n\nexport const useTableRenderConfigContext = <RowType extends TableRowData>() => {\n const context = useOptionalTableRenderConfigContext<RowType>();\n\n if (!context) {\n throw new Error('Table render config context is missing.');\n }\n\n return context;\n};\n"],"names":["TableRenderConfigContext","createContext","useOptionalTableRenderConfigContext","useContext"],"mappings":";AAmCO,MAAMA,IAA2BC,EAAkE,IAAI,GAEjGC,IAAsC,MAC/CC,EAAWH,CAAwB;"}
@@ -45,6 +45,7 @@ export type TableRenderDraft<RowType extends TableRowData> = {
45
45
  rowIndex: number;
46
46
  kind: 'data' | 'expanded' | 'expanded-full-width' | 'group' | 'group-footer' | 'spacer';
47
47
  disabled?: boolean;
48
+ selectable?: boolean;
48
49
  render: () => ReactNode;
49
50
  }[];
50
51
  bodyMaxHeight?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"TableRenderContext.js","sources":["../../../../src/components/table/context/TableRenderContext.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from 'react';\n\nimport type {\n TableColumnDefinition,\n TableHorizontalAlign,\n TableRowData,\n TableRowId,\n TableVerticalAlign,\n} from '../Table.types';\nimport type { TableViewHeader } from '../model/tableView.types';\n\nexport type RenderHeaderColumn<RowType extends TableRowData> = {\n id: string;\n columnKey?: string;\n label: ReactNode;\n icon?: string;\n filter?: ReactNode;\n hideLabel?: boolean;\n width?: number | string;\n mobileLabel?: string;\n horizontalAlign?: TableHorizontalAlign;\n verticalAlign?: TableVerticalAlign;\n headerClassName?: string;\n hideOnMobile?: boolean;\n sortable?: boolean;\n draggable?: boolean;\n resizeable?: boolean;\n minResizeWidth?: number;\n maxResizeWidth?: number;\n row: number;\n colSpan: number;\n rowSpan: number;\n source?: RowType;\n};\n\n/**\n * Mutable draft of the current render pass.\n *\n * The table keeps React composability, but still needs a normalized table model\n * for features such as header placement, footer detection, virtualization, and\n * stable body-row rendering.\n *\n * The table therefore works in two internal stages:\n * 1. Header/body/footer sub-components register the structure they produce into this draft.\n * 2. `Table` promotes that draft into stable draft state and renders from that.\n *\n * The draft is intentionally recreated on every render pass and must not be treated\n * as persistent state.\n */\nexport type TableRenderDraft<RowType extends TableRowData> = {\n headerColumns: RenderHeaderColumn<RowType>[];\n bodyRows: {\n rowId: TableRowId;\n rowIndex: number;\n kind: 'data' | 'expanded' | 'expanded-full-width' | 'group' | 'group-footer' | 'spacer';\n disabled?: boolean;\n render: () => ReactNode;\n }[];\n bodyMaxHeight?: string;\n hasFooter?: boolean;\n hasFooterCells?: boolean;\n hasExpandableRows?: boolean;\n};\n\nexport type RenderBodyRow<RowType extends TableRowData> = Omit<TableRenderDraft<RowType>['bodyRows'][number], 'render'>;\n\n/**\n * Structural render context.\n *\n * This context only carries the normalized render model built from the current\n * render pass. Public render configuration such as `rowClassName` or card/table\n * view mode lives in `TableRenderConfigContext`.\n */\nexport type TableRenderContextValue<RowType extends TableRowData> = {\n header?: TableViewHeader<RowType>;\n columns: RenderHeaderColumn<RowType>[];\n columnDefinitionsByKey: Map<string, TableColumnDefinition<RowType>>;\n columnIndexByKey: Map<string, number>;\n bodyRows: RenderBodyRow<RowType>[];\n renderBodyRow?: (row: RenderBodyRow<RowType>) => ReactNode;\n renderDraft: TableRenderDraft<RowType>;\n hasFooterCells?: boolean;\n hasExpandableRows?: boolean;\n /**\n * Switches body rows into the registration pass.\n *\n * While this flag is true, row components register their normalized metadata in\n * `renderDraft.bodyRows` and return `null` instead of rendering DOM directly.\n * `TableBody` then performs the second pass by rendering the collected rows\n * through `renderBodyRow(...)`.\n */\n isRegisteringBodyRows?: boolean;\n};\n\nexport const TableRenderContext = createContext<TableRenderContextValue<TableRowData> | null>(null);\n\nexport const useOptionalTableRenderContext = <RowType extends TableRowData>() =>\n useContext(TableRenderContext) as TableRenderContextValue<RowType> | null;\n\nexport const useTableRenderContext = <RowType extends TableRowData>() => {\n const context = useOptionalTableRenderContext<RowType>();\n\n if (!context) {\n throw new Error('Table render context is missing.');\n }\n\n return context;\n};\n"],"names":["TableRenderContext","createContext","useOptionalTableRenderContext","useContext"],"mappings":";AA8FO,MAAMA,IAAqBC,EAA4D,IAAI,GAErFC,IAAgC,MACzCC,EAAWH,CAAkB;"}
1
+ {"version":3,"file":"TableRenderContext.js","sources":["../../../../src/components/table/context/TableRenderContext.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from 'react';\n\nimport type {\n TableColumnDefinition,\n TableHorizontalAlign,\n TableRowData,\n TableRowId,\n TableVerticalAlign,\n} from '../Table.types';\nimport type { TableViewHeader } from '../model/tableView.types';\n\nexport type RenderHeaderColumn<RowType extends TableRowData> = {\n id: string;\n columnKey?: string;\n label: ReactNode;\n icon?: string;\n filter?: ReactNode;\n hideLabel?: boolean;\n width?: number | string;\n mobileLabel?: string;\n horizontalAlign?: TableHorizontalAlign;\n verticalAlign?: TableVerticalAlign;\n headerClassName?: string;\n hideOnMobile?: boolean;\n sortable?: boolean;\n draggable?: boolean;\n resizeable?: boolean;\n minResizeWidth?: number;\n maxResizeWidth?: number;\n row: number;\n colSpan: number;\n rowSpan: number;\n source?: RowType;\n};\n\n/**\n * Mutable draft of the current render pass.\n *\n * The table keeps React composability, but still needs a normalized table model\n * for features such as header placement, footer detection, virtualization, and\n * stable body-row rendering.\n *\n * The table therefore works in two internal stages:\n * 1. Header/body/footer sub-components register the structure they produce into this draft.\n * 2. `Table` promotes that draft into stable draft state and renders from that.\n *\n * The draft is intentionally recreated on every render pass and must not be treated\n * as persistent state.\n */\nexport type TableRenderDraft<RowType extends TableRowData> = {\n headerColumns: RenderHeaderColumn<RowType>[];\n bodyRows: {\n rowId: TableRowId;\n rowIndex: number;\n kind: 'data' | 'expanded' | 'expanded-full-width' | 'group' | 'group-footer' | 'spacer';\n disabled?: boolean;\n selectable?: boolean;\n render: () => ReactNode;\n }[];\n bodyMaxHeight?: string;\n hasFooter?: boolean;\n hasFooterCells?: boolean;\n hasExpandableRows?: boolean;\n};\n\nexport type RenderBodyRow<RowType extends TableRowData> = Omit<TableRenderDraft<RowType>['bodyRows'][number], 'render'>;\n\n/**\n * Structural render context.\n *\n * This context only carries the normalized render model built from the current\n * render pass. Public render configuration such as `rowClassName` or card/table\n * view mode lives in `TableRenderConfigContext`.\n */\nexport type TableRenderContextValue<RowType extends TableRowData> = {\n header?: TableViewHeader<RowType>;\n columns: RenderHeaderColumn<RowType>[];\n columnDefinitionsByKey: Map<string, TableColumnDefinition<RowType>>;\n columnIndexByKey: Map<string, number>;\n bodyRows: RenderBodyRow<RowType>[];\n renderBodyRow?: (row: RenderBodyRow<RowType>) => ReactNode;\n renderDraft: TableRenderDraft<RowType>;\n hasFooterCells?: boolean;\n hasExpandableRows?: boolean;\n /**\n * Switches body rows into the registration pass.\n *\n * While this flag is true, row components register their normalized metadata in\n * `renderDraft.bodyRows` and return `null` instead of rendering DOM directly.\n * `TableBody` then performs the second pass by rendering the collected rows\n * through `renderBodyRow(...)`.\n */\n isRegisteringBodyRows?: boolean;\n};\n\nexport const TableRenderContext = createContext<TableRenderContextValue<TableRowData> | null>(null);\n\nexport const useOptionalTableRenderContext = <RowType extends TableRowData>() =>\n useContext(TableRenderContext) as TableRenderContextValue<RowType> | null;\n\nexport const useTableRenderContext = <RowType extends TableRowData>() => {\n const context = useOptionalTableRenderContext<RowType>();\n\n if (!context) {\n throw new Error('Table render context is missing.');\n }\n\n return context;\n};\n"],"names":["TableRenderContext","createContext","useOptionalTableRenderContext","useContext"],"mappings":";AA+FO,MAAMA,IAAqBC,EAA4D,IAAI,GAErFC,IAAgC,MACzCC,EAAWH,CAAkB;"}
@@ -1,85 +1,83 @@
1
- import { useState as S, useRef as p, useMemo as w, useLayoutEffect as R } from "react";
2
- const A = 1, E = (t) => {
1
+ import { useState as A, useRef as z, useMemo as F, useLayoutEffect as N } from "react";
2
+ import a from "../../../hooks/useResizeObserver.js";
3
+ const j = 1, x = (t) => {
3
4
  const e = t?.trim().match(/^(-?\d+(?:\.\d+)?)px$/);
4
5
  return e ? Number(e[1]) : void 0;
5
- }, x = (t) => {
6
+ }, C = (t) => {
6
7
  const e = t.getBoundingClientRect().width;
7
8
  return e > 0 ? Math.ceil(e) : t.scrollWidth;
8
- }, O = (t) => {
9
+ }, P = (t) => {
9
10
  if (!t)
10
11
  return 0;
11
12
  const e = window.getComputedStyle(t), n = Number.parseFloat(e.columnGap || e.gap || "0");
12
13
  return Number.isFinite(n) ? Math.ceil(n) : 0;
13
- }, q = (t) => {
14
+ }, T = (t) => {
14
15
  const e = t.querySelector(".table-head-label");
15
16
  if (e) {
16
- const s = t.querySelector(".sort-arrows");
17
- return x(e) + (s ? x(s) : 0) + (s ? O(t.querySelector(".table-head-button")) : 0);
17
+ const o = t.querySelector(".sort-arrows");
18
+ return C(e) + (o ? C(o) : 0) + (o ? P(t.querySelector(".table-head-button")) : 0);
18
19
  }
19
20
  return (t.querySelector(".table-cell-content, .table-head-button-label") ?? t).scrollWidth;
20
- }, z = (t, e) => Object.fromEntries(
21
- Object.entries(e).map(([n, s]) => {
22
- const i = t[n], u = E(i), r = E(s);
21
+ }, _ = (t, e) => Object.fromEntries(
22
+ Object.entries(e).map(([n, o]) => {
23
+ const u = t[n], i = x(u), r = x(o);
23
24
  return [
24
25
  n,
25
- u !== void 0 && r !== void 0 && Math.abs(u - r) <= A ? i : s
26
+ i !== void 0 && r !== void 0 && Math.abs(i - r) <= j ? u : o
26
27
  ];
27
28
  })
28
- ), P = (t) => {
29
- const { columns: e, enabled: n, tableWrapperRef: s } = t, [i, u] = S({}), r = p(""), a = p({}), y = w(
30
- () => e.map((o) => `${o.key}:${o.width === void 0 ? "auto" : String(o.width)}`).join("|"),
29
+ ), D = (t) => {
30
+ const { columns: e, enabled: n, tableWrapperRef: o } = t, [u, i] = A({}), r = z(""), c = z({}), g = F(
31
+ () => e.map((l) => `${l.key}:${l.width === void 0 ? "auto" : String(l.width)}`).join("|"),
31
32
  [e]
32
- );
33
- return R(() => {
34
- const o = s.current;
35
- if (!n || !o) {
36
- r.current && (r.current = "", a.current = {}, u({}));
33
+ ), s = o.current, v = s?.querySelector(".table-head") ?? null, w = s?.querySelector(".table-body") ?? null, R = s?.querySelector(".table-footer") ?? null, q = s?.querySelector(".table-scroll-content") ?? null, [, , b] = a(s), [, , S] = a(v), [, , M] = a(w), [, , f] = a(R), [, , p] = a(q);
34
+ return N(() => {
35
+ if (!n || !s) {
36
+ r.current && (r.current = "", c.current = {}, i({}));
37
37
  return;
38
38
  }
39
39
  if (e.length === 0) {
40
- r.current && (r.current = "", a.current = {}, u({}));
40
+ r.current && (r.current = "", c.current = {}, i({}));
41
41
  return;
42
42
  }
43
- const h = e.filter((c) => c.width === void 0);
44
- if (h.length === 0) {
45
- r.current && (r.current = "", a.current = {}, u({}));
43
+ const l = e.filter((d) => d.width === void 0);
44
+ if (l.length === 0) {
45
+ r.current && (r.current = "", c.current = {}, i({}));
46
46
  return;
47
47
  }
48
- const m = () => {
49
- const c = Array.from(o.querySelectorAll("[data-column]")), C = Object.fromEntries(
50
- h.flatMap((M) => {
51
- const W = c.filter((d) => d.dataset.column === M.key).reduce(
52
- (d, g) => Math.max(d, q(g)),
48
+ (() => {
49
+ const d = Array.from(s.querySelectorAll("[data-column]")), k = Object.fromEntries(
50
+ l.flatMap((E) => {
51
+ const y = d.filter((h) => h.dataset.column === E.key).reduce(
52
+ (h, O) => Math.max(h, T(O)),
53
53
  0
54
54
  );
55
- return W > 0 ? [[M.key, `${Math.ceil(W)}px`]] : [];
55
+ return y > 0 ? [[E.key, `${Math.ceil(y)}px`]] : [];
56
56
  })
57
- ), l = z(
58
- a.current,
59
- C
60
- ), f = JSON.stringify(l);
61
- f !== r.current && (r.current = f, a.current = l, u(l));
62
- };
63
- m();
64
- const v = [
65
- o,
66
- ...Array.from(
67
- o.querySelectorAll(
68
- ".table-head, .table-body, .table-footer, .table-scroll-content"
69
- )
70
- )
71
- ], b = new ResizeObserver(() => {
72
- m();
73
- });
74
- return v.forEach((c) => {
75
- b.observe(c);
76
- }), () => {
77
- b.disconnect();
78
- };
79
- }, [y, n, s]), i;
57
+ ), m = _(
58
+ c.current,
59
+ k
60
+ ), W = JSON.stringify(m);
61
+ W !== r.current && (r.current = W, c.current = m, i(m));
62
+ })();
63
+ }, [
64
+ g,
65
+ n,
66
+ s,
67
+ b.blockSize,
68
+ b.inlineSize,
69
+ S.blockSize,
70
+ S.inlineSize,
71
+ M.blockSize,
72
+ M.inlineSize,
73
+ f.blockSize,
74
+ f.inlineSize,
75
+ p.blockSize,
76
+ p.inlineSize
77
+ ]), u;
80
78
  };
81
79
  export {
82
- z as stabilizeMeasuredColumnMaxWidths,
83
- P as useMeasuredColumnMaxWidths
80
+ _ as stabilizeMeasuredColumnMaxWidths,
81
+ D as useMeasuredColumnMaxWidths
84
82
  };
85
83
  //# sourceMappingURL=useMeasuredColumnMaxWidths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMeasuredColumnMaxWidths.js","sources":["../../../../src/components/table/layout/useMeasuredColumnMaxWidths.ts"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef, useState, type RefObject } from 'react';\n\nimport type { TableColumnDefinition, TableRowData } from '../Table.types';\n\nconst MEASURED_WIDTH_JITTER_TOLERANCE_PX = 1;\n\nconst parsePixelWidth = (width?: string) => {\n const match = width?.trim().match(/^(-?\\d+(?:\\.\\d+)?)px$/);\n\n return match ? Number(match[1]) : undefined;\n};\n\nconst measureRenderedWidth = (element: HTMLElement) => {\n const renderedWidth = element.getBoundingClientRect().width;\n\n return renderedWidth > 0 ? Math.ceil(renderedWidth) : element.scrollWidth;\n};\n\nconst resolveFlexGapWidth = (element: HTMLElement | null) => {\n if (!element) {\n return 0;\n }\n\n const styles = window.getComputedStyle(element);\n const gap = Number.parseFloat(styles.columnGap || styles.gap || '0');\n\n return Number.isFinite(gap) ? Math.ceil(gap) : 0;\n};\n\nconst measureColumnContentWidth = (element: HTMLElement) => {\n const headerLabelElement = element.querySelector<HTMLElement>('.table-head-label');\n\n if (headerLabelElement) {\n const sortArrowsElement = element.querySelector<HTMLElement>('.sort-arrows');\n\n return (\n measureRenderedWidth(headerLabelElement) +\n (sortArrowsElement ? measureRenderedWidth(sortArrowsElement) : 0) +\n (sortArrowsElement ? resolveFlexGapWidth(element.querySelector<HTMLElement>('.table-head-button')) : 0)\n );\n }\n\n const contentElement =\n element.querySelector<HTMLElement>('.table-cell-content, .table-head-button-label') ?? element;\n\n return contentElement.scrollWidth;\n};\n\nexport const stabilizeMeasuredColumnMaxWidths = (\n previousMeasuredColumnMaxWidths: Record<string, string>,\n nextMeasuredColumnMaxWidths: Record<string, string>\n) =>\n Object.fromEntries(\n Object.entries(nextMeasuredColumnMaxWidths).map(([columnKey, nextMeasuredWidth]) => {\n const previousMeasuredWidth = previousMeasuredColumnMaxWidths[columnKey];\n const previousMeasuredWidthPx = parsePixelWidth(previousMeasuredWidth);\n const nextMeasuredWidthPx = parsePixelWidth(nextMeasuredWidth);\n\n return [\n columnKey,\n previousMeasuredWidthPx !== undefined &&\n nextMeasuredWidthPx !== undefined &&\n Math.abs(previousMeasuredWidthPx - nextMeasuredWidthPx) <= MEASURED_WIDTH_JITTER_TOLERANCE_PX\n ? previousMeasuredWidth\n : nextMeasuredWidth,\n ];\n })\n );\n\ntype UseMeasuredColumnMaxWidthsProps<RowType extends TableRowData> = {\n columns: TableColumnDefinition<RowType>[];\n enabled: boolean;\n tableWrapperRef: RefObject<HTMLDivElement | null>;\n};\n\nexport const useMeasuredColumnMaxWidths = <RowType extends TableRowData>(\n props: UseMeasuredColumnMaxWidthsProps<RowType>\n) => {\n const { columns, enabled, tableWrapperRef } = props;\n const [measuredColumnMaxWidths, setMeasuredColumnMaxWidths] = useState<Record<string, string>>({});\n const previousMeasuredWidthsRef = useRef('');\n const previousMeasuredColumnMaxWidthsRef = useRef<Record<string, string>>({});\n const columnsSignature = useMemo(\n () =>\n columns\n .map(column => `${column.key}:${column.width === undefined ? 'auto' : String(column.width)}`)\n .join('|'),\n [columns]\n );\n\n useLayoutEffect(() => {\n const wrapperElement = tableWrapperRef.current;\n\n if (!enabled || !wrapperElement) {\n if (previousMeasuredWidthsRef.current) {\n previousMeasuredWidthsRef.current = '';\n previousMeasuredColumnMaxWidthsRef.current = {};\n setMeasuredColumnMaxWidths({});\n }\n\n return;\n }\n\n if (columns.length === 0) {\n if (previousMeasuredWidthsRef.current) {\n previousMeasuredWidthsRef.current = '';\n previousMeasuredColumnMaxWidthsRef.current = {};\n setMeasuredColumnMaxWidths({});\n }\n\n return;\n }\n\n const columnsWithoutWidth = columns.filter(column => column.width === undefined);\n\n if (columnsWithoutWidth.length === 0) {\n if (previousMeasuredWidthsRef.current) {\n previousMeasuredWidthsRef.current = '';\n previousMeasuredColumnMaxWidthsRef.current = {};\n setMeasuredColumnMaxWidths({});\n }\n\n return;\n }\n\n const measureColumnMaxWidths = () => {\n const columnElements = Array.from(wrapperElement.querySelectorAll<HTMLElement>('[data-column]'));\n const nextMeasuredColumnMaxWidths = Object.fromEntries(\n columnsWithoutWidth.flatMap(column => {\n const matchingElements = columnElements.filter(element => element.dataset.column === column.key);\n const measuredWidth = matchingElements.reduce(\n (largestWidth, element) => Math.max(largestWidth, measureColumnContentWidth(element)),\n 0\n );\n\n return measuredWidth > 0 ? [[column.key, `${Math.ceil(measuredWidth)}px`]] : [];\n })\n );\n const stabilizedMeasuredColumnMaxWidths = stabilizeMeasuredColumnMaxWidths(\n previousMeasuredColumnMaxWidthsRef.current,\n nextMeasuredColumnMaxWidths\n );\n const serializedMeasuredWidths = JSON.stringify(stabilizedMeasuredColumnMaxWidths);\n\n if (serializedMeasuredWidths !== previousMeasuredWidthsRef.current) {\n previousMeasuredWidthsRef.current = serializedMeasuredWidths;\n previousMeasuredColumnMaxWidthsRef.current = stabilizedMeasuredColumnMaxWidths;\n setMeasuredColumnMaxWidths(stabilizedMeasuredColumnMaxWidths);\n }\n };\n\n measureColumnMaxWidths();\n\n const observedElements = [\n wrapperElement,\n ...Array.from(\n wrapperElement.querySelectorAll<HTMLElement>(\n '.table-head, .table-body, .table-footer, .table-scroll-content'\n )\n ),\n ];\n const resizeObserver = new ResizeObserver(() => {\n measureColumnMaxWidths();\n });\n\n observedElements.forEach(element => {\n resizeObserver.observe(element);\n });\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [columnsSignature, enabled, tableWrapperRef]);\n\n return measuredColumnMaxWidths;\n};\n"],"names":["MEASURED_WIDTH_JITTER_TOLERANCE_PX","parsePixelWidth","width","match","measureRenderedWidth","element","renderedWidth","resolveFlexGapWidth","styles","gap","measureColumnContentWidth","headerLabelElement","sortArrowsElement","stabilizeMeasuredColumnMaxWidths","previousMeasuredColumnMaxWidths","nextMeasuredColumnMaxWidths","columnKey","nextMeasuredWidth","previousMeasuredWidth","previousMeasuredWidthPx","nextMeasuredWidthPx","useMeasuredColumnMaxWidths","props","columns","enabled","tableWrapperRef","measuredColumnMaxWidths","setMeasuredColumnMaxWidths","useState","previousMeasuredWidthsRef","useRef","previousMeasuredColumnMaxWidthsRef","columnsSignature","useMemo","column","useLayoutEffect","wrapperElement","columnsWithoutWidth","measureColumnMaxWidths","columnElements","measuredWidth","largestWidth","stabilizedMeasuredColumnMaxWidths","serializedMeasuredWidths","observedElements","resizeObserver"],"mappings":";AAIA,MAAMA,IAAqC,GAErCC,IAAkB,CAACC,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CAAO,CAAC;AAAA,YACpF;AAAA,UAAA;AAGJ,iBAAOmC,IAAgB,IAAI,CAAC,CAACN,EAAO,KAAK,GAAG,KAAK,KAAKM,CAAa,CAAC,IAAI,CAAC,IAAI,CAAA;AAAA,QACjF,CAAC;AAAA,MAAA,GAECE,IAAoC7B;AAAA,QACtCkB,EAAmC;AAAA,QACnChB;AAAA,MAAA,GAEE4B,IAA2B,KAAK,UAAUD,CAAiC;AAEjF,MAAIC,MAA6Bd,EAA0B,YACvDA,EAA0B,UAAUc,GACpCZ,EAAmC,UAAUW,GAC7Cf,EAA2Be,CAAiC;AAAA,IAEpE;AAEA,IAAAJ,EAAA;AAEA,UAAMM,IAAmB;AAAA,MACrBR;AAAA,MACA,GAAG,MAAM;AAAA,QACLA,EAAe;AAAA,UACX;AAAA,QAAA;AAAA,MACJ;AAAA,IACJ,GAEES,IAAiB,IAAI,eAAe,MAAM;AAC5C,MAAAP,EAAA;AAAA,IACJ,CAAC;AAED,WAAAM,EAAiB,QAAQ,CAAAvC,MAAW;AAChC,MAAAwC,EAAe,QAAQxC,CAAO;AAAA,IAClC,CAAC,GAEM,MAAM;AACT,MAAAwC,EAAe,WAAA;AAAA,IACnB;AAAA,EACJ,GAAG,CAACb,GAAkBR,GAASC,CAAe,CAAC,GAExCC;AACX;"}
1
+ {"version":3,"file":"useMeasuredColumnMaxWidths.js","sources":["../../../../src/components/table/layout/useMeasuredColumnMaxWidths.ts"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef, useState, type RefObject } from 'react';\n\nimport useResizeObserver from '../../../useResizeObserver';\nimport type { TableColumnDefinition, TableRowData } from '../Table.types';\n\nconst MEASURED_WIDTH_JITTER_TOLERANCE_PX = 1;\n\nconst parsePixelWidth = (width?: string) => {\n const match = width?.trim().match(/^(-?\\d+(?:\\.\\d+)?)px$/);\n\n return match ? Number(match[1]) : undefined;\n};\n\nconst measureRenderedWidth = (element: HTMLElement) => {\n const renderedWidth = element.getBoundingClientRect().width;\n\n return renderedWidth > 0 ? Math.ceil(renderedWidth) : element.scrollWidth;\n};\n\nconst resolveFlexGapWidth = (element: HTMLElement | null) => {\n if (!element) {\n return 0;\n }\n\n const styles = window.getComputedStyle(element);\n const gap = Number.parseFloat(styles.columnGap || styles.gap || '0');\n\n return Number.isFinite(gap) ? Math.ceil(gap) : 0;\n};\n\nconst measureColumnContentWidth = (element: HTMLElement) => {\n const headerLabelElement = element.querySelector<HTMLElement>('.table-head-label');\n\n if (headerLabelElement) {\n const sortArrowsElement = element.querySelector<HTMLElement>('.sort-arrows');\n\n return (\n measureRenderedWidth(headerLabelElement) +\n (sortArrowsElement ? measureRenderedWidth(sortArrowsElement) : 0) +\n (sortArrowsElement ? resolveFlexGapWidth(element.querySelector<HTMLElement>('.table-head-button')) : 0)\n );\n }\n\n const contentElement =\n element.querySelector<HTMLElement>('.table-cell-content, .table-head-button-label') ?? element;\n\n return contentElement.scrollWidth;\n};\n\nexport const stabilizeMeasuredColumnMaxWidths = (\n previousMeasuredColumnMaxWidths: Record<string, string>,\n nextMeasuredColumnMaxWidths: Record<string, string>\n) =>\n Object.fromEntries(\n Object.entries(nextMeasuredColumnMaxWidths).map(([columnKey, nextMeasuredWidth]) => {\n const previousMeasuredWidth = previousMeasuredColumnMaxWidths[columnKey];\n const previousMeasuredWidthPx = parsePixelWidth(previousMeasuredWidth);\n const nextMeasuredWidthPx = parsePixelWidth(nextMeasuredWidth);\n\n return [\n columnKey,\n previousMeasuredWidthPx !== undefined &&\n nextMeasuredWidthPx !== undefined &&\n Math.abs(previousMeasuredWidthPx - nextMeasuredWidthPx) <= MEASURED_WIDTH_JITTER_TOLERANCE_PX\n ? previousMeasuredWidth\n : nextMeasuredWidth,\n ];\n })\n );\n\ntype UseMeasuredColumnMaxWidthsProps<RowType extends TableRowData> = {\n columns: TableColumnDefinition<RowType>[];\n enabled: boolean;\n tableWrapperRef: RefObject<HTMLDivElement | null>;\n};\n\nexport const useMeasuredColumnMaxWidths = <RowType extends TableRowData>(\n props: UseMeasuredColumnMaxWidthsProps<RowType>\n) => {\n const { columns, enabled, tableWrapperRef } = props;\n const [measuredColumnMaxWidths, setMeasuredColumnMaxWidths] = useState<Record<string, string>>({});\n const previousMeasuredWidthsRef = useRef('');\n const previousMeasuredColumnMaxWidthsRef = useRef<Record<string, string>>({});\n const columnsSignature = useMemo(\n () =>\n columns\n .map(column => `${column.key}:${column.width === undefined ? 'auto' : String(column.width)}`)\n .join('|'),\n [columns]\n );\n const wrapperElement = tableWrapperRef.current;\n const tableHeadElement = wrapperElement?.querySelector<HTMLDivElement>('.table-head') ?? null;\n const tableBodyElement = wrapperElement?.querySelector<HTMLDivElement>('.table-body') ?? null;\n const tableFooterElement = wrapperElement?.querySelector<HTMLDivElement>('.table-footer') ?? null;\n const tableScrollContentElement = wrapperElement?.querySelector<HTMLDivElement>('.table-scroll-content') ?? null;\n const [, , wrapperSize] = useResizeObserver(wrapperElement);\n const [, , tableHeadSize] = useResizeObserver(tableHeadElement);\n const [, , tableBodySize] = useResizeObserver(tableBodyElement);\n const [, , tableFooterSize] = useResizeObserver(tableFooterElement);\n const [, , tableScrollContentSize] = useResizeObserver(tableScrollContentElement);\n\n useLayoutEffect(() => {\n if (!enabled || !wrapperElement) {\n if (previousMeasuredWidthsRef.current) {\n previousMeasuredWidthsRef.current = '';\n previousMeasuredColumnMaxWidthsRef.current = {};\n setMeasuredColumnMaxWidths({});\n }\n\n return;\n }\n\n if (columns.length === 0) {\n if (previousMeasuredWidthsRef.current) {\n previousMeasuredWidthsRef.current = '';\n previousMeasuredColumnMaxWidthsRef.current = {};\n setMeasuredColumnMaxWidths({});\n }\n\n return;\n }\n\n const columnsWithoutWidth = columns.filter(column => column.width === undefined);\n\n if (columnsWithoutWidth.length === 0) {\n if (previousMeasuredWidthsRef.current) {\n previousMeasuredWidthsRef.current = '';\n previousMeasuredColumnMaxWidthsRef.current = {};\n setMeasuredColumnMaxWidths({});\n }\n\n return;\n }\n\n const measureColumnMaxWidths = () => {\n const columnElements = Array.from(wrapperElement.querySelectorAll<HTMLElement>('[data-column]'));\n const nextMeasuredColumnMaxWidths = Object.fromEntries(\n columnsWithoutWidth.flatMap(column => {\n const matchingElements = columnElements.filter(element => element.dataset.column === column.key);\n const measuredWidth = matchingElements.reduce(\n (largestWidth, element) => Math.max(largestWidth, measureColumnContentWidth(element)),\n 0\n );\n\n return measuredWidth > 0 ? [[column.key, `${Math.ceil(measuredWidth)}px`]] : [];\n })\n );\n const stabilizedMeasuredColumnMaxWidths = stabilizeMeasuredColumnMaxWidths(\n previousMeasuredColumnMaxWidthsRef.current,\n nextMeasuredColumnMaxWidths\n );\n const serializedMeasuredWidths = JSON.stringify(stabilizedMeasuredColumnMaxWidths);\n\n if (serializedMeasuredWidths !== previousMeasuredWidthsRef.current) {\n previousMeasuredWidthsRef.current = serializedMeasuredWidths;\n previousMeasuredColumnMaxWidthsRef.current = stabilizedMeasuredColumnMaxWidths;\n setMeasuredColumnMaxWidths(stabilizedMeasuredColumnMaxWidths);\n }\n };\n\n measureColumnMaxWidths();\n }, [\n columnsSignature,\n enabled,\n wrapperElement,\n wrapperSize.blockSize,\n wrapperSize.inlineSize,\n tableHeadSize.blockSize,\n tableHeadSize.inlineSize,\n tableBodySize.blockSize,\n tableBodySize.inlineSize,\n tableFooterSize.blockSize,\n tableFooterSize.inlineSize,\n tableScrollContentSize.blockSize,\n tableScrollContentSize.inlineSize,\n ]);\n\n return measuredColumnMaxWidths;\n};\n"],"names":["MEASURED_WIDTH_JITTER_TOLERANCE_PX","parsePixelWidth","width","match","measureRenderedWidth","element","renderedWidth","resolveFlexGapWidth","styles","gap","measureColumnContentWidth","headerLabelElement","sortArrowsElement","stabilizeMeasuredColumnMaxWidths","previousMeasuredColumnMaxWidths","nextMeasuredColumnMaxWidths","columnKey","nextMeasuredWidth","previousMeasuredWidth","previousMeasuredWidthPx","nextMeasuredWidthPx","useMeasuredColumnMaxWidths","props","columns","enabled","tableWrapperRef","measuredColumnMaxWidths","setMeasuredColumnMaxWidths","useState","previousMeasuredWidthsRef","useRef","previousMeasuredColumnMaxWidthsRef","columnsSignature","useMemo","column","wrapperElement","tableHeadElement","tableBodyElement","tableFooterElement","tableScrollContentElement","wrapperSize","useResizeObserver","tableHeadSize","tableBodySize","tableFooterSize","tableScrollContentSize","useLayoutEffect","columnsWithoutWidth","columnElements","measuredWidth","largestWidth","stabilizedMeasuredColumnMaxWidths","serializedMeasuredWidths"],"mappings":";;AAKA,MAAMA,IAAqC,GAErCC,IAAkB,CAACC,MAAmB;AACxC,QAAMC,IAAQD,GAAO,KAAA,EAAO,MAAM,uBAAuB;AAEzD,SAAOC,IAAQ,OAAOA,EAAM,CAAC,CAAC,IAAI;AACtC,GAEMC,IAAuB,CAACC,MAAyB;AACnD,QAAMC,IAAgBD,EAAQ,sBAAA,EAAwB;AAEtD,SAAOC,IAAgB,IAAI,KAAK,KAAKA,CAAa,IAAID,EAAQ;AAClE,GAEME,IAAsB,CAACF,MAAgC;AACzD,MAAI,CAACA;AACD,WAAO;AAGX,QAAMG,IAAS,OAAO,iBAAiBH,CAAO,GACxCI,IAAM,OAAO,WAAWD,EAAO,aAAaA,EAAO,OAAO,GAAG;AAEnE,SAAO,OAAO,SAASC,CAAG,IAAI,KAAK,KAAKA,CAAG,IAAI;AACnD,GAEMC,IAA4B,CAACL,MAAyB;AACxD,QAAMM,IAAqBN,EAAQ,cAA2B,mBAAmB;AAEjF,MAAIM,GAAoB;AACpB,UAAMC,IAAoBP,EAAQ,cAA2B,cAAc;AAE3E,WACID,EAAqBO,CAAkB,KACtCC,IAAoBR,EAAqBQ,CAAiB,IAAI,MAC9DA,IAAoBL,EAAoBF,EAAQ,cAA2B,oBAAoB,CAAC,IAAI;AAAA,EAE7G;AAKA,UAFIA,EAAQ,cAA2B,+CAA+C,KAAKA,GAErE;AAC1B,GAEaQ,IAAmC,CAC5CC,GACAC,MAEA,OAAO;AAAA,EACH,OAAO,QAAQA,CAA2B,EAAE,IAAI,CAAC,CAACC,GAAWC,CAA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Ac;AAAA,IACdA,EAAc;AAAA,IACdC,EAAgB;AAAA,IAChBA,EAAgB;AAAA,IAChBC,EAAuB;AAAA,IACvBA,EAAuB;AAAA,EAAA,CAC1B,GAEMnB;AACX;"}
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties } from 'react';
2
- import { TableCardsStyleSettings, TableColumnDefinition, TableRowData } from '../Table.types';
2
+ import { TableCardsStyleSettings, TableColumnDefinition, TableRowData, TableStickyReference } from '../Table.types';
3
3
  export type TableColumnWithArea<RowType extends TableRowData> = {
4
4
  column: TableColumnDefinition<RowType>;
5
5
  columnIndex: number;
@@ -12,6 +12,7 @@ type UseTableLayoutProps<RowType extends TableRowData> = {
12
12
  hasFooterCells?: boolean;
13
13
  rowSeparatorWidth?: number | string;
14
14
  showSelectionColumn?: boolean;
15
+ stickyReference?: TableStickyReference;
15
16
  style?: CSSProperties;
16
17
  };
17
18
  type InternalTableStyle = CSSProperties & {
@@ -21,6 +22,7 @@ type InternalTableStyle = CSSProperties & {
21
22
  '--table-cards-max'?: string;
22
23
  '--table-column-count'?: string;
23
24
  '--table-row-separator-width'?: string;
25
+ '--table-sticky-reference-top'?: string;
24
26
  '--table-width'?: string;
25
27
  };
26
28
  export declare const useTableLayout: <RowType extends TableRowData>(props: UseTableLayoutProps<RowType>) => {
@@ -32,6 +34,7 @@ export declare const useTableLayout: <RowType extends TableRowData>(props: UseTa
32
34
  tableWrapperRef: import('react').MutableRefObject<HTMLDivElement | null>;
33
35
  tableFooterRowRef: import('react').RefObject<HTMLDivElement>;
34
36
  tableHeadRowRef: import('react').RefObject<HTMLDivElement>;
37
+ wrapperWidth: number | undefined;
35
38
  wrapperStyle: InternalTableStyle;
36
39
  };
37
40
  export {};
@@ -1,66 +1,72 @@
1
- import { useMeasuredColumnMaxWidths as N } from "./useMeasuredColumnMaxWidths.js";
2
- import { MIN_COLUMN_WIDTH_PX as R } from "../tableSizing.constants.js";
3
- import { toCssSize as l, getColumnTrack as L } from "./columnSizing.js";
4
- import { useHorizontalSectionSync as $ } from "./useHorizontalSectionSync.js";
5
- import B from "../../../hooks/useResizeObserver.js";
6
- const h = 50, E = (r) => {
7
- if (!r)
8
- return;
9
- const a = r.trim().match(/^(-?\d+(?:\.\d+)?)px$/);
10
- if (a)
11
- return Number(a[1]);
12
- }, k = (r) => {
13
- const { bodyMaxHeight: a, cardsStyle: d, columns: n, hasFooterCells: p, rowSeparatorWidth: u, showSelectionColumn: i, style: b } = r, [c, , { inlineSize: f }] = B(), e = n.map((t, o) => ({
14
- column: t,
15
- columnIndex: o,
16
- areaName: `table-col-${o + 1}`
17
- })), s = f ?? c.current?.clientWidth, S = (i ? h : 0) + n.reduce((t, o) => {
18
- if (o.width === void 0)
19
- return t + R;
20
- const v = E(l(o.width));
21
- return t + (v ?? 0);
22
- }, 0), m = s !== void 0 && S > s, W = s !== void 0 ? `${s}px` : "100%", {
23
- handleBodyScroll: w,
1
+ import L from "../shared/parsePixelSize.js";
2
+ import { useMeasuredColumnMaxWidths as k } from "./useMeasuredColumnMaxWidths.js";
3
+ import { MIN_COLUMN_WIDTH_PX as N } from "../tableSizing.constants.js";
4
+ import { toCssSize as i, getColumnTrack as B } from "./columnSizing.js";
5
+ import { useHorizontalSectionSync as E } from "./useHorizontalSectionSync.js";
6
+ import $ from "../../../hooks/useResizeObserver.js";
7
+ const d = 50, F = (m) => {
8
+ const {
9
+ bodyMaxHeight: p,
10
+ cardsStyle: s,
11
+ columns: r,
12
+ hasFooterCells: h,
13
+ rowSeparatorWidth: f,
14
+ showSelectionColumn: n,
15
+ stickyReference: b = "applicationLayout",
16
+ style: u
17
+ } = m, [l, , { inlineSize: S }] = $(), t = r.map((e, a) => ({
18
+ column: e,
19
+ columnIndex: a,
20
+ areaName: `table-col-${a + 1}`
21
+ })), o = S ?? l.current?.clientWidth, W = (n ? d : 0) + r.reduce((e, a) => {
22
+ if (a.width === void 0)
23
+ return e + N;
24
+ const _ = L(i(a.width));
25
+ return e + (_ ?? 0);
26
+ }, 0), c = o !== void 0 && W > o, w = o !== void 0 ? `${o}px` : "100%", {
27
+ handleBodyScroll: y,
24
28
  hasHorizontalScrollEndOffset: x,
25
29
  hasHorizontalScrollStartOffset: C,
26
30
  tableFooterRowRef: M,
27
31
  tableHeadRowRef: T
28
- } = $({
29
- enabled: !!a,
30
- hasFooterCells: p
31
- }), g = N({
32
- columns: n,
33
- enabled: m,
34
- tableWrapperRef: c
35
- }), y = e.length > 0 ? [
36
- i ? `${h}px` : void 0,
37
- ...e.map(({ column: t }) => L(t, g[t.key]))
38
- ].filter(Boolean).join(" ") : "minmax(0, 1fr)", z = e.length > 0 ? `"${[
39
- i ? "table-selection" : void 0,
40
- ...e.map(({ areaName: t }) => t)
41
- ].filter(Boolean).join(" ")}"` : "none", H = l(d?.minWidth) ?? "280px", O = l(d?.maxWidth) ?? "1fr", _ = {
42
- ...b ?? {},
43
- "--table-columns": y,
32
+ } = E({
33
+ enabled: !!p,
34
+ hasFooterCells: h
35
+ }), g = k({
36
+ columns: r,
37
+ enabled: c,
38
+ tableWrapperRef: l
39
+ }), v = t.length > 0 ? [
40
+ n ? `${d}px` : void 0,
41
+ ...t.map(({ column: e }) => B(e, g[e.key]))
42
+ ].filter(Boolean).join(" ") : "minmax(0, 1fr)", z = t.length > 0 ? `"${[
43
+ n ? "table-selection" : void 0,
44
+ ...t.map(({ areaName: e }) => e)
45
+ ].filter(Boolean).join(" ")}"` : "none", H = i(s?.minWidth), O = i(s?.maxWidth), R = {
46
+ ...u ?? {},
47
+ "--table-columns": v,
44
48
  "--table-areas": z,
45
49
  "--table-cards-min": H,
46
50
  "--table-cards-max": O,
47
- "--table-column-count": String(n.length + (i ? 1 : 0)),
48
- "--table-row-separator-width": l(u),
49
- "--table-width": W
51
+ "--table-column-count": String(r.length + (n ? 1 : 0)),
52
+ "--table-row-separator-width": i(f),
53
+ "--table-sticky-reference-top": b === "container" ? "0px" : "var(--table-sticky-offset)",
54
+ "--table-width": w
50
55
  };
51
56
  return {
52
- columnsWithAreas: e,
53
- handleBodyScroll: w,
57
+ columnsWithAreas: t,
58
+ handleBodyScroll: y,
54
59
  hasHorizontalScrollEndOffset: x,
55
60
  hasHorizontalScrollStartOffset: C,
56
- tableUseOverflow: m,
57
- tableWrapperRef: c,
61
+ tableUseOverflow: c,
62
+ tableWrapperRef: l,
58
63
  tableFooterRowRef: M,
59
64
  tableHeadRowRef: T,
60
- wrapperStyle: _
65
+ wrapperWidth: o,
66
+ wrapperStyle: R
61
67
  };
62
68
  };
63
69
  export {
64
- k as useTableLayout
70
+ F as useTableLayout
65
71
  };
66
72
  //# sourceMappingURL=useTableLayout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTableLayout.js","sources":["../../../../src/components/table/layout/useTableLayout.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nimport type { TableCardsStyleSettings, TableColumnDefinition, TableRowData } from '../Table.types';\nimport { useMeasuredColumnMaxWidths } from './useMeasuredColumnMaxWidths';\nimport { MIN_COLUMN_WIDTH_PX } from '../tableSizing.constants';\nimport { getColumnTrack, toCssSize } from './columnSizing';\nimport { useHorizontalSectionSync } from './useHorizontalSectionSync';\nimport useResizeObserver from '../../../useResizeObserver';\n\nconst TABLE_SELECTION_COLUMN_WIDTH_PX = 50;\n\nconst parsePixelSize = (value?: string) => {\n if (!value) {\n return;\n }\n\n const match = value.trim().match(/^(-?\\d+(?:\\.\\d+)?)px$/);\n\n if (!match) {\n return;\n }\n\n return Number(match[1]);\n};\n\nexport type TableColumnWithArea<RowType extends TableRowData> = {\n column: TableColumnDefinition<RowType>;\n columnIndex: number;\n areaName: string;\n};\n\ntype UseTableLayoutProps<RowType extends TableRowData> = {\n bodyMaxHeight?: string;\n cardsStyle?: TableCardsStyleSettings;\n columns: TableColumnDefinition<RowType>[];\n hasFooterCells?: boolean;\n rowSeparatorWidth?: number | string;\n showSelectionColumn?: boolean;\n style?: CSSProperties;\n};\n\ntype InternalTableStyle = CSSProperties & {\n '--table-columns'?: string;\n '--table-areas'?: string;\n '--table-cards-min'?: string;\n '--table-cards-max'?: string;\n '--table-column-count'?: string;\n '--table-row-separator-width'?: string;\n '--table-width'?: string;\n};\n\nexport const useTableLayout = <RowType extends TableRowData>(props: UseTableLayoutProps<RowType>) => {\n const { bodyMaxHeight, cardsStyle, columns, hasFooterCells, rowSeparatorWidth, showSelectionColumn, style } = props;\n const [tableWrapperRef, , { inlineSize }] = useResizeObserver<HTMLDivElement>();\n\n const columnsWithAreas: TableColumnWithArea<RowType>[] = columns.map((column, columnIndex) => ({\n column,\n columnIndex,\n areaName: `table-col-${columnIndex + 1}`,\n }));\n\n const wrapperWidth = inlineSize ?? tableWrapperRef.current?.clientWidth;\n\n const minWidthTotal =\n (showSelectionColumn ? TABLE_SELECTION_COLUMN_WIDTH_PX : 0) +\n columns.reduce((totalWidth, column) => {\n if (column.width === undefined) {\n return totalWidth + MIN_COLUMN_WIDTH_PX;\n }\n\n const columnWidth = parsePixelSize(toCssSize(column.width));\n\n return totalWidth + (columnWidth ?? 0);\n }, 0);\n\n const tableUseOverflow = wrapperWidth !== undefined && minWidthTotal > wrapperWidth;\n const tableWidth = wrapperWidth !== undefined ? `${wrapperWidth}px` : '100%';\n\n const {\n handleBodyScroll,\n hasHorizontalScrollEndOffset,\n hasHorizontalScrollStartOffset,\n tableFooterRowRef,\n tableHeadRowRef,\n } = useHorizontalSectionSync({\n enabled: !!bodyMaxHeight,\n hasFooterCells,\n });\n\n const measuredColumnMaxWidths = useMeasuredColumnMaxWidths({\n columns,\n enabled: tableUseOverflow,\n tableWrapperRef,\n });\n\n const gridTemplateColumns =\n columnsWithAreas.length > 0\n ? [\n showSelectionColumn ? `${TABLE_SELECTION_COLUMN_WIDTH_PX}px` : undefined,\n ...columnsWithAreas.map(({ column }) => getColumnTrack(column, measuredColumnMaxWidths[column.key])),\n ]\n .filter(Boolean)\n .join(' ')\n : 'minmax(0, 1fr)';\n\n const gridTemplateAreas =\n columnsWithAreas.length > 0\n ? `\"${[\n showSelectionColumn ? 'table-selection' : undefined,\n ...columnsWithAreas.map(({ areaName }) => areaName),\n ]\n .filter(Boolean)\n .join(' ')}\"`\n : 'none';\n\n const cardsMinWidth = toCssSize(cardsStyle?.minWidth) ?? '280px';\n const cardsMaxWidth = toCssSize(cardsStyle?.maxWidth) ?? '1fr';\n\n const wrapperStyle: InternalTableStyle = {\n ...(style ?? {}),\n '--table-columns': gridTemplateColumns,\n '--table-areas': gridTemplateAreas,\n '--table-cards-min': cardsMinWidth,\n '--table-cards-max': cardsMaxWidth,\n '--table-column-count': String(columns.length + (showSelectionColumn ? 1 : 0)),\n '--table-row-separator-width': toCssSize(rowSeparatorWidth),\n '--table-width': tableWidth,\n };\n\n return {\n columnsWithAreas,\n handleBodyScroll,\n hasHorizontalScrollEndOffset,\n hasHorizontalScrollStartOffset,\n tableUseOverflow,\n tableWrapperRef,\n tableFooterRowRef,\n tableHeadRowRef,\n wrapperStyle,\n };\n};\n"],"names":["TABLE_SELECTION_COLUMN_WIDTH_PX","parsePixelSize","value","match","useTableLayout","props","bodyMaxHeight","cardsStyle","columns","hasFooterCells","rowSeparatorWidth","showSelectionColumn","style","tableWrapperRef","inlineSize","useResizeObserver","columnsWithAreas","column","columnIndex","wrapperWidth","minWidthTotal","totalWidth","MIN_COLUMN_WIDTH_PX","columnWidth","toCssSize","tableUseOverflow","tableWidth","handleBodyScroll","hasHorizontalScrollEndOffset","hasHorizontalScrollStartOffset","tableFooterRowRef","tableHeadRowRef","useHorizontalSectionSync","measuredColumnMaxWidths","useMeasuredColumnMaxWidths","gridTemplateColumns","getColumnTrack","gridTemplateAreas","areaName","cardsMinWidth","cardsMaxWidth","wrapperStyle"],"mappings":";;;;;AASA,MAAMA,IAAkC,IAElCC,IAAiB,CAACC,MAAmB;AACvC,MAAI,CAACA;AACD;AAGJ,QAAMC,IAAQD,EAAM,KAAA,EAAO,MAAM,uBAAuB;AAExD,MAAKC;AAIL,WAAO,OAAOA,EAAM,CAAC,CAAC;AAC1B,GA4BaC,IAAiB,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EJoB,IACFrB,EAAiB,SAAS,IACpB,IAAI;AAAA,IACAL,IAAsB,oBAAoB;AAAA,IAC1C,GAAGK,EAAiB,IAAI,CAAC,EAAE,UAAAsB,EAAA,MAAeA,CAAQ;AAAA,EAAA,EAEjD,OAAO,OAAO,EACd,KAAK,GAAG,CAAC,MACd,QAEJC,IAAgBf,EAAUjB,GAAY,QAAQ,KAAK,SACnDiC,IAAgBhB,EAAUjB,GAAY,QAAQ,KAAK,OAEnDkC,IAAmC;AAAA,IACrC,GAAI7B,KAAS,CAAA;AAAA,IACb,mBAAmBuB;AAAA,IACnB,iBAAiBE;AAAA,IACjB,qBAAqBE;AAAA,IACrB,qBAAqBC;AAAA,IACrB,wBAAwB,OAAOhC,EAAQ,UAAUG,IAAsB,IAAI,EAAE;AAAA,IAC7E,+BAA+Ba,EAAUd,CAAiB;AAAA,IAC1D,iBAAiBgB;AAAA,EAAA;AAGrB,SAAO;AAAA,IACH,kBAAAV;AAAA,IACA,kBAAAW;AAAA,IACA,8BAAAC;AAAA,IACA,gCAAAC;AAAA,IACA,kBAAAJ;AAAA,IACA,iBAAAZ;AAAA,IACA,mBAAAiB;AAAA,IACA,iBAAAC;AAAA,IACA,cAAAU;AAAA,EAAA;AAER;"}
1
+ {"version":3,"file":"useTableLayout.js","sources":["../../../../src/components/table/layout/useTableLayout.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nimport parsePixelSize from '../shared/parsePixelSize';\nimport type {\n TableCardsStyleSettings,\n TableColumnDefinition,\n TableRowData,\n TableStickyReference,\n} from '../Table.types';\nimport { useMeasuredColumnMaxWidths } from './useMeasuredColumnMaxWidths';\nimport { MIN_COLUMN_WIDTH_PX } from '../tableSizing.constants';\nimport { getColumnTrack, toCssSize } from './columnSizing';\nimport { useHorizontalSectionSync } from './useHorizontalSectionSync';\nimport useResizeObserver from '../../../useResizeObserver';\n\nconst TABLE_SELECTION_COLUMN_WIDTH_PX = 50;\n\nexport type TableColumnWithArea<RowType extends TableRowData> = {\n column: TableColumnDefinition<RowType>;\n columnIndex: number;\n areaName: string;\n};\n\ntype UseTableLayoutProps<RowType extends TableRowData> = {\n bodyMaxHeight?: string;\n cardsStyle?: TableCardsStyleSettings;\n columns: TableColumnDefinition<RowType>[];\n hasFooterCells?: boolean;\n rowSeparatorWidth?: number | string;\n showSelectionColumn?: boolean;\n stickyReference?: TableStickyReference;\n style?: CSSProperties;\n};\n\ntype InternalTableStyle = CSSProperties & {\n '--table-columns'?: string;\n '--table-areas'?: string;\n '--table-cards-min'?: string;\n '--table-cards-max'?: string;\n '--table-column-count'?: string;\n '--table-row-separator-width'?: string;\n '--table-sticky-reference-top'?: string;\n '--table-width'?: string;\n};\n\nexport const useTableLayout = <RowType extends TableRowData>(props: UseTableLayoutProps<RowType>) => {\n const {\n bodyMaxHeight,\n cardsStyle,\n columns,\n hasFooterCells,\n rowSeparatorWidth,\n showSelectionColumn,\n stickyReference = 'applicationLayout',\n style,\n } = props;\n const [tableWrapperRef, , { inlineSize }] = useResizeObserver<HTMLDivElement>();\n\n const columnsWithAreas: TableColumnWithArea<RowType>[] = columns.map((column, columnIndex) => ({\n column,\n columnIndex,\n areaName: `table-col-${columnIndex + 1}`,\n }));\n\n const wrapperWidth = inlineSize ?? tableWrapperRef.current?.clientWidth;\n\n const minWidthTotal =\n (showSelectionColumn ? TABLE_SELECTION_COLUMN_WIDTH_PX : 0) +\n columns.reduce((totalWidth, column) => {\n if (column.width === undefined) {\n return totalWidth + MIN_COLUMN_WIDTH_PX;\n }\n\n const columnWidth = parsePixelSize(toCssSize(column.width));\n\n return totalWidth + (columnWidth ?? 0);\n }, 0);\n\n const tableUseOverflow = wrapperWidth !== undefined && minWidthTotal > wrapperWidth;\n const tableWidth = wrapperWidth !== undefined ? `${wrapperWidth}px` : '100%';\n\n const {\n handleBodyScroll,\n hasHorizontalScrollEndOffset,\n hasHorizontalScrollStartOffset,\n tableFooterRowRef,\n tableHeadRowRef,\n } = useHorizontalSectionSync({\n enabled: !!bodyMaxHeight,\n hasFooterCells,\n });\n\n const measuredColumnMaxWidths = useMeasuredColumnMaxWidths({\n columns,\n enabled: tableUseOverflow,\n tableWrapperRef,\n });\n\n const gridTemplateColumns =\n columnsWithAreas.length > 0\n ? [\n showSelectionColumn ? `${TABLE_SELECTION_COLUMN_WIDTH_PX}px` : undefined,\n ...columnsWithAreas.map(({ column }) => getColumnTrack(column, measuredColumnMaxWidths[column.key])),\n ]\n .filter(Boolean)\n .join(' ')\n : 'minmax(0, 1fr)';\n\n const gridTemplateAreas =\n columnsWithAreas.length > 0\n ? `\"${[\n showSelectionColumn ? 'table-selection' : undefined,\n ...columnsWithAreas.map(({ areaName }) => areaName),\n ]\n .filter(Boolean)\n .join(' ')}\"`\n : 'none';\n\n const cardsMinWidth = toCssSize(cardsStyle?.minWidth);\n const cardsMaxWidth = toCssSize(cardsStyle?.maxWidth);\n\n const wrapperStyle: InternalTableStyle = {\n ...(style ?? {}),\n '--table-columns': gridTemplateColumns,\n '--table-areas': gridTemplateAreas,\n '--table-cards-min': cardsMinWidth,\n '--table-cards-max': cardsMaxWidth,\n '--table-column-count': String(columns.length + (showSelectionColumn ? 1 : 0)),\n '--table-row-separator-width': toCssSize(rowSeparatorWidth),\n '--table-sticky-reference-top': stickyReference === 'container' ? '0px' : 'var(--table-sticky-offset)',\n '--table-width': tableWidth,\n };\n\n return {\n columnsWithAreas,\n handleBodyScroll,\n hasHorizontalScrollEndOffset,\n hasHorizontalScrollStartOffset,\n tableUseOverflow,\n tableWrapperRef,\n tableFooterRowRef,\n tableHeadRowRef,\n wrapperWidth,\n wrapperStyle,\n };\n};\n"],"names":["TABLE_SELECTION_COLUMN_WIDTH_PX","useTableLayout","props","bodyMaxHeight","cardsStyle","columns","hasFooterCells","rowSeparatorWidth","showSelectionColumn","stickyReference","style","tableWrapperRef","inlineSize","useResizeObserver","columnsWithAreas","column","columnIndex","wrapperWidth","minWidthTotal","totalWidth","MIN_COLUMN_WIDTH_PX","columnWidth","parsePixelSize","toCssSize","tableUseOverflow","tableWidth","handleBodyScroll","hasHorizontalScrollEndOffset","hasHorizontalScrollStartOffset","tableFooterRowRef","tableHeadRowRef","useHorizontalSectionSync","measuredColumnMaxWidths","useMeasuredColumnMaxWidths","gridTemplateColumns","getColumnTrack","gridTemplateAreas","areaName","cardsMinWidth","cardsMaxWidth","wrapperStyle"],"mappings":";;;;;;AAeA,MAAMA,IAAkC,IA8B3BC,IAAiB,CAA+BC,MAAwC;AACjG,QAAM;AAAA,IACF,eAAAC;AAAA,IACA,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,iBAAAC,IAAkB;AAAA,IAClB,OAAAC;AAAA,EAAA,IACAR,GACE,CAACS,GAAA,EAAmB,EAAE,YAAAC,EAAA,CAAY,IAAIC,EAAA,GAEtCC,IAAmDT,EAAQ,IAAI,CAACU,GAAQC,OAAiB;AAAA,IAC3F,QAAAD;AAAA,IACA,aAAAC;AAAA,IACA,UAAU,aAAaA,IAAc,CAAC;AAAA,EAAA,EACxC,GAEIC,IAAeL,KAAcD,EAAgB,SAAS,aAEtDO,KACDV,IAAsBR,IAAkC,KACzDK,EAAQ,OAAO,CAACc,GAAYJ,MAAW;AACnC,QAAIA,EAAO,UAAU;AACjB,aAAOI,IAAaC;AAGxB,UAAMC,IAAcC,EAAeC,EAAUR,EAAO,KAAK,CAAC;AAE1D,WAAOI,KAAcE,KAAe;AAAA,EACxC,GAAG,CAAC,GAEFG,IAAmBP,MAAiB,UAAaC,IAAgBD,GACjEQ,IAAaR,MAAiB,SAAY,GAAGA,CAAY,OAAO,QAEhE;AAAA,IACF,kBAAAS;AAAA,IACA,8BAAAC;AAAA,IACA,gCAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,iBAAAC;AAAA,EAAA,IACAC,EAAyB;AAAA,IACzB,SAAS,CAAC,CAAC5B;AAAA,IACX,gBAAAG;AAAA,EAAA,CACH,GAEK0B,IAA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