@economic/taco 2.39.2 → 2.40.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. package/dist/components/OverflowGroup/OverflowGroup.d.ts +0 -1
  2. package/dist/components/Table/hooks/useRowCreation.d.ts +4 -4
  3. package/dist/components/Table/types.d.ts +19 -19
  4. package/dist/components/Tabs/Tabs.d.ts +0 -5
  5. package/dist/esm/packages/taco/src/components/Alert/Alert.js.map +1 -1
  6. package/dist/esm/packages/taco/src/components/Badge/Badge.js.map +1 -1
  7. package/dist/esm/packages/taco/src/components/BadgeIcon/BadgeIcon.js.map +1 -1
  8. package/dist/esm/packages/taco/src/components/Banner/Banner.js +1 -1
  9. package/dist/esm/packages/taco/src/components/Banner/Banner.js.map +1 -1
  10. package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/Calendar/Calendar.js +4 -4
  12. package/dist/esm/packages/taco/src/components/Calendar/Calendar.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Card/Card.js +2 -2
  14. package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +2 -2
  16. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Combobox/Combobox.js +2 -2
  18. package/dist/esm/packages/taco/src/components/Combobox/Combobox.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js +6 -6
  20. package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Dialog/components/Content.js +2 -2
  22. package/dist/esm/packages/taco/src/components/Dialog/components/Content.js.map +1 -1
  23. package/dist/esm/packages/taco/src/components/Drawer/Drawer.js.map +1 -1
  24. package/dist/esm/packages/taco/src/components/Drawer/components/Content.js +5 -5
  25. package/dist/esm/packages/taco/src/components/Drawer/components/Content.js.map +1 -1
  26. package/dist/esm/packages/taco/src/components/Field/Field.js +1 -1
  27. package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
  28. package/dist/esm/packages/taco/src/components/Hanger/Hanger.js +1 -1
  29. package/dist/esm/packages/taco/src/components/Hanger/Hanger.js.map +1 -1
  30. package/dist/esm/packages/taco/src/components/Header/components/Agreement/Display.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Header/components/Agreement/Item.js +1 -1
  32. package/dist/esm/packages/taco/src/components/Header/components/Agreement/Item.js.map +1 -1
  33. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +2 -2
  34. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
  35. package/dist/esm/packages/taco/src/components/Header/components/Link.js +1 -1
  36. package/dist/esm/packages/taco/src/components/Header/components/Link.js.map +1 -1
  37. package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js +1 -1
  38. package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js.map +1 -1
  39. package/dist/esm/packages/taco/src/components/Icon/Icon.js +1 -1
  40. package/dist/esm/packages/taco/src/components/Icon/Icon.js.map +1 -1
  41. package/dist/esm/packages/taco/src/components/Input/Input.js +1 -1
  42. package/dist/esm/packages/taco/src/components/Input/Input.js.map +1 -1
  43. package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js +1 -1
  44. package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js.map +1 -1
  45. package/dist/esm/packages/taco/src/components/List/components/Item.js +1 -1
  46. package/dist/esm/packages/taco/src/components/List/components/Item.js.map +1 -1
  47. package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js +4 -4
  48. package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js.map +1 -1
  49. package/dist/esm/packages/taco/src/components/Listbox/useMultiListbox.js.map +1 -1
  50. package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
  51. package/dist/esm/packages/taco/src/components/Menu/components/Item.js +2 -2
  52. package/dist/esm/packages/taco/src/components/Menu/components/Item.js.map +1 -1
  53. package/dist/esm/packages/taco/src/components/Navigation/Navigation.js +1 -1
  54. package/dist/esm/packages/taco/src/components/Navigation/Navigation.js.map +1 -1
  55. package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js +2 -2
  56. package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js.map +1 -1
  57. package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js +1 -1
  58. package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js.map +1 -1
  59. package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js +1 -4
  60. package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js.map +1 -1
  61. package/dist/esm/packages/taco/src/components/Pagination/PageNumbers.js +1 -1
  62. package/dist/esm/packages/taco/src/components/Pagination/PageNumbers.js.map +1 -1
  63. package/dist/esm/packages/taco/src/components/Pagination/Pagination.js +3 -3
  64. package/dist/esm/packages/taco/src/components/Pagination/Pagination.js.map +1 -1
  65. package/dist/esm/packages/taco/src/components/Popover/Popover.js +2 -2
  66. package/dist/esm/packages/taco/src/components/Popover/Popover.js.map +1 -1
  67. package/dist/esm/packages/taco/src/components/Progress/Progress.js.map +1 -1
  68. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  69. package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js +1 -1
  70. package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
  71. package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js.map +1 -1
  72. package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js +1 -1
  73. package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js.map +1 -1
  74. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +5 -5
  75. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
  76. package/dist/esm/packages/taco/src/components/Select/Select.js.map +1 -1
  77. package/dist/esm/packages/taco/src/components/Select/useSelect.js +1 -1
  78. package/dist/esm/packages/taco/src/components/Select/useSelect.js.map +1 -1
  79. package/dist/esm/packages/taco/src/components/Select2/Select2.js +7 -7
  80. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  81. package/dist/esm/packages/taco/src/components/Select2/components/Create.js +2 -2
  82. package/dist/esm/packages/taco/src/components/Select2/components/Create.js.map +1 -1
  83. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +5 -5
  84. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
  85. package/dist/esm/packages/taco/src/components/Select2/components/Option.js +4 -4
  86. package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
  87. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +5 -5
  88. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  89. package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js +1 -1
  90. package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js.map +1 -1
  91. package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
  92. package/dist/esm/packages/taco/src/components/Table/components/BaseTable.js +2 -2
  93. package/dist/esm/packages/taco/src/components/Table/components/BaseTable.js.map +1 -1
  94. package/dist/esm/packages/taco/src/components/Table/components/PaginatedTable.js.map +1 -1
  95. package/dist/esm/packages/taco/src/components/Table/components/Table.js.map +1 -1
  96. package/dist/esm/packages/taco/src/components/Table/components/WindowedTable.js +1 -1
  97. package/dist/esm/packages/taco/src/components/Table/components/WindowedTable.js.map +1 -1
  98. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js +8 -8
  99. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js.map +1 -1
  100. package/dist/esm/packages/taco/src/components/Table/hooks/useRowCreation.js.map +1 -1
  101. package/dist/esm/packages/taco/src/components/Table/util/renderColumn.js +1 -1
  102. package/dist/esm/packages/taco/src/components/Table/util/renderColumn.js.map +1 -1
  103. package/dist/esm/packages/taco/src/components/Table/util/renderRow.js.map +1 -1
  104. package/dist/esm/packages/taco/src/components/Table/util/rowIndexPath.js.map +1 -1
  105. package/dist/esm/packages/taco/src/components/Table3/Table3.js +3 -3
  106. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  107. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
  108. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/TextareaWithAutosizing.js.map +1 -1
  109. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +1 -1
  110. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
  111. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +1 -1
  112. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
  113. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js +2 -2
  114. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js.map +1 -1
  115. package/dist/esm/packages/taco/src/components/Table3/useTable3.js +1 -1
  116. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  117. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
  118. package/dist/esm/packages/taco/src/components/Tabs/Tabs.js +2 -11
  119. package/dist/esm/packages/taco/src/components/Tabs/Tabs.js.map +1 -1
  120. package/dist/esm/packages/taco/src/components/Tag/Tag.js +3 -3
  121. package/dist/esm/packages/taco/src/components/Tag/Tag.js.map +1 -1
  122. package/dist/esm/packages/taco/src/components/Toast/Toaster.js +1 -1
  123. package/dist/esm/packages/taco/src/components/Toast/Toaster.js.map +1 -1
  124. package/dist/esm/packages/taco/src/components/Toast/util.js.map +1 -1
  125. package/dist/esm/packages/taco/src/components/Tour/Tour.js +2 -2
  126. package/dist/esm/packages/taco/src/components/Tour/Tour.js.map +1 -1
  127. package/dist/esm/packages/taco/src/components/Treeview/Treeview.js +1 -1
  128. package/dist/esm/packages/taco/src/components/Treeview/Treeview.js.map +1 -1
  129. package/dist/esm/packages/taco/src/hooks/useIntersectionObserver.js.map +1 -1
  130. package/dist/esm/packages/taco/src/primitives/BubbleSelect.js.map +1 -1
  131. package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js.map +1 -1
  132. package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js.map +1 -1
  133. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +4 -4
  134. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  135. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +1 -1
  136. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
  137. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +3 -3
  138. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
  139. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
  140. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +1 -1
  141. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  142. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js +3 -3
  143. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js.map +1 -1
  144. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Goto.js.map +1 -1
  145. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js +9 -9
  146. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
  147. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +2 -2
  148. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  149. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js +1 -1
  150. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js.map +1 -1
  151. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js +1 -1
  152. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js.map +1 -1
  153. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/Filters.js +1 -1
  154. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/Filters.js.map +1 -1
  155. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js +1 -1
  156. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
  157. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.js +1 -1
  158. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.js.map +1 -1
  159. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.js +1 -1
  160. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.js.map +1 -1
  161. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/util.js +1 -1
  162. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/util.js.map +1 -1
  163. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js +1 -1
  164. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
  165. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/PrintDialog.js +4 -4
  166. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/PrintDialog.js.map +1 -1
  167. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js.map +1 -1
  168. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.js +3 -3
  169. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.js.map +1 -1
  170. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.js +6 -6
  171. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.js.map +1 -1
  172. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleColumnFreezing.js.map +1 -1
  173. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleGrid.js.map +1 -1
  174. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js.map +1 -1
  175. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js.map +1 -1
  176. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFontSizeListener.js.map +1 -1
  177. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +2 -2
  178. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  179. package/dist/esm/packages/taco/src/utils/date.js +1 -1
  180. package/dist/esm/packages/taco/src/utils/date.js.map +1 -1
  181. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  182. package/dist/taco.cjs.development.js +160 -170
  183. package/dist/taco.cjs.development.js.map +1 -1
  184. package/dist/taco.cjs.production.min.js +1 -1
  185. package/dist/taco.cjs.production.min.js.map +1 -1
  186. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"Tour.js","sources":["../../../../../../../src/components/Tour/Tour.tsx"],"sourcesContent":["import * as React from 'react';\nimport Joyride, { Step, CallBackProps, ACTIONS, LIFECYCLE, Placement, EVENTS, TooltipRenderProps } from 'react-joyride';\n\nimport { Button } from '../Button/Button';\nimport { Group } from '../Group/Group';\nimport { IconButton } from '../IconButton/IconButton';\nimport { useLocalization } from '../Provider/Localization';\n\nexport type TourTexts = {\n /** Text for back action button */\n back: string;\n /**\n * Text for close button.\n * This button is displayed if tour is not continuous - replacing the `Next` button.\n * It will pause the flow of the tour and close the tooltip\n */\n close: string;\n /**\n * Aria-label and title for close icon button in each step.\n * This button skips and completes the flow entirely\n */\n skip: string;\n /**\n * Text for last action button.\n * This button is displayed when user is on the last step of the tour\n */\n last: string;\n /**\n * Text for next action button.\n * This button is displayed if tour has more than one steps and is continuous\n */\n next: string;\n /** Aria label and title for beacon that will open the tour step */\n open: string;\n};\n\nexport type TourStepProps = {\n /** Content can be any valid react node, for e.g. a `div` */\n children: React.ReactNode;\n /** Define the position of the tour's popup relative to the element is presenting */\n position?: Placement;\n /** The css selector of the html element you want to include in a tour */\n selector: string;\n /**\n * Show beacon for step.\n * A beacon is a styled component which indicates the current element to be presented.\n * For more informations about how to create a beacon, read [Joyride](https://docs.react-joyride.com) docs\n */\n showBeacon?: boolean;\n /** Text displayed above the children/content of the popup */\n title: string;\n};\n\nconst Tooltip = ({\n continuous,\n index,\n isLastStep,\n step,\n backProps,\n primaryProps,\n skipProps,\n tooltipProps,\n size,\n locale,\n disableTourSkipOnEsc,\n}: TooltipRenderProps & { locale: TourTexts; disableTourSkipOnEsc?: boolean }) => {\n const skipButtonRef = React.useRef<HTMLButtonElement>(null);\n\n React.useEffect(() => {\n const onWindowKeyDown = (event: KeyboardEvent): void => {\n if (!disableTourSkipOnEsc) {\n if (event.key === 'Escape' && skipButtonRef.current !== null) {\n event.preventDefault();\n skipButtonRef.current.click();\n return;\n }\n }\n };\n\n window.addEventListener('keydown', onWindowKeyDown);\n\n return () => {\n window.removeEventListener('keydown', onWindowKeyDown);\n };\n }, []);\n\n return (\n <div {...tooltipProps} className=\"yt-tour__step w-88 relative rounded bg-white p-4\">\n <IconButton\n {...skipProps}\n ref={skipButtonRef}\n appearance=\"discrete\"\n icon=\"close\"\n title={locale.skip}\n aria-label={locale.skip}\n className=\"absolute top-0 right-0 mt-1 mr-1\"\n />\n {step.title && <h5>{step.title}</h5>}\n {step.content}\n <Group className=\"mt-4 justify-end\">\n {index > 0 && (\n <Button {...backProps} appearance=\"discrete\">\n {locale.back}\n </Button>\n )}\n <Button {...primaryProps} appearance=\"primary\">\n {continuous\n ? isLastStep\n ? `${locale.last} (${index + 1}/${size})`\n : `${locale.next} (${index + 1}/${size})`\n : locale.close}\n </Button>\n </Group>\n </div>\n );\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const TourStep = (_props: TourStepProps): null => null;\n\nexport type TourProps = {\n /** Controls if [Joyride](https://docs.react-joyride.com) is active */\n autoStart?: boolean;\n /** Children should be one or more `Tour.Step` components */\n children: any;\n /** Are there more than one steps and should you be able to navigate between them using `Next` and `Previous` buttons */\n continuous?: boolean;\n /** Disable closing of tour when click on `Escape` */\n disableCloseOnEsc?: boolean;\n /** Don't close the presenting popup of the tour step when clicking outside it */\n disableOverlayClose?: boolean;\n /** Allows user to interact with the presented components (mouse and touch events) when the popup is visible */\n disableScrolling?: boolean;\n /* When user clicks on the close icon button, which will close the tour and complete the flow */\n onClose?: (step: TourStepProps) => void;\n /* When user completes the entire flow */\n onComplete?: Function;\n /** When step is ready */\n onReady?: (step: TourStepProps) => void;\n /* Allow mouse and touch events through the spotlight */\n spotlightClicks?: boolean;\n /* Stops the injection of custom overflow styles on parent container. Can be used to prevent remaining overflow styles after tour is done. */\n disableScrollParentFix?: boolean;\n /** The scroll distance from the element scrollTop value. */\n scrollOffset?: number;\n};\n\nexport const Tour = (props: TourProps) => {\n const {\n texts: { tour },\n } = useLocalization();\n\n const {\n autoStart: run,\n onComplete,\n onClose,\n onReady,\n spotlightClicks,\n disableCloseOnEsc: disableTourSkipOnEsc,\n disableScrollParentFix = false,\n scrollOffset,\n ...rest\n } = props;\n\n const steps = React.useMemo(() => {\n return React.Children.map(props.children, child => {\n const step: Step = {\n disableBeacon: !child.props.showBeacon,\n target: child.props.selector,\n placement: child.props.position,\n title: child.props.title,\n content: child.props.children,\n };\n return step;\n });\n }, [props.children]);\n\n const getStep = React.useCallback(\n (selector: string | HTMLElement) => props.children.find((child: any) => child.props.selector === selector)?.props,\n [props.children]\n );\n\n const callback = (state: CallBackProps) => {\n if (state.action === ACTIONS.SKIP && state.lifecycle === LIFECYCLE.COMPLETE) {\n if (onClose) {\n onClose(getStep(state.step.target));\n }\n }\n\n if (state.type === EVENTS.TOUR_END) {\n if (onComplete) {\n onComplete();\n }\n }\n\n if (state.lifecycle === LIFECYCLE.READY) {\n if (onReady) {\n onReady(getStep(state.step.target));\n }\n }\n };\n\n return (\n <Joyride\n {...rest}\n run={run}\n steps={steps}\n showProgress\n floaterProps={{\n disableAnimation: true,\n }}\n tooltipComponent={tooltipProps => (\n <Tooltip {...tooltipProps} locale={tour} disableTourSkipOnEsc={disableTourSkipOnEsc} />\n )}\n locale={tour}\n spotlightPadding={8}\n spotlightClicks={spotlightClicks}\n disableScrollParentFix={disableScrollParentFix}\n callback={callback}\n scrollOffset={scrollOffset}\n styles={{\n /** style beacon */\n options: {\n // tailwind.theme.colors.blue.300\n primaryColor: '#6ba4ff',\n },\n }}\n disableCloseOnEsc\n />\n );\n};\n\nTour.Step = TourStep;\n"],"names":["Tooltip","continuous","index","isLastStep","step","backProps","primaryProps","skipProps","tooltipProps","size","locale","disableTourSkipOnEsc","skipButtonRef","React","onWindowKeyDown","event","key","current","preventDefault","click","window","addEventListener","removeEventListener","className","IconButton","ref","appearance","icon","title","skip","content","Group","Button","back","last","next","close","TourStep","_props","Tour","props","texts","tour","useLocalization","autoStart","run","onComplete","onClose","onReady","spotlightClicks","disableCloseOnEsc","disableScrollParentFix","scrollOffset","rest","steps","map","children","child","disableBeacon","showBeacon","target","selector","placement","position","getStep","_props$children$find","find","callback","state","action","ACTIONS","SKIP","lifecycle","LIFECYCLE","COMPLETE","type","EVENTS","TOUR_END","READY","Joyride","showProgress","floaterProps","disableAnimation","tooltipComponent","spotlightPadding","styles","options","primaryColor","Step"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js","sources":["../../../../../../../src/components/Tour/Tour.tsx"],"sourcesContent":["import * as React from 'react';\nimport Joyride, { Step, CallBackProps, ACTIONS, LIFECYCLE, Placement, EVENTS, TooltipRenderProps } from 'react-joyride';\n\nimport { Button } from '../Button/Button';\nimport { Group } from '../Group/Group';\nimport { IconButton } from '../IconButton/IconButton';\nimport { useLocalization } from '../Provider/Localization';\n\nexport type TourTexts = {\n /** Text for back action button */\n back: string;\n /**\n * Text for close button.\n * This button is displayed if tour is not continuous - replacing the `Next` button.\n * It will pause the flow of the tour and close the tooltip\n */\n close: string;\n /**\n * Aria-label and title for close icon button in each step.\n * This button skips and completes the flow entirely\n */\n skip: string;\n /**\n * Text for last action button.\n * This button is displayed when user is on the last step of the tour\n */\n last: string;\n /**\n * Text for next action button.\n * This button is displayed if tour has more than one steps and is continuous\n */\n next: string;\n /** Aria label and title for beacon that will open the tour step */\n open: string;\n};\n\nexport type TourStepProps = {\n /** Content can be any valid react node, for e.g. a `div` */\n children: React.ReactNode;\n /** Define the position of the tour's popup relative to the element is presenting */\n position?: Placement;\n /** The css selector of the html element you want to include in a tour */\n selector: string;\n /**\n * Show beacon for step.\n * A beacon is a styled component which indicates the current element to be presented.\n * For more informations about how to create a beacon, read [Joyride](https://docs.react-joyride.com) docs\n */\n showBeacon?: boolean;\n /** Text displayed above the children/content of the popup */\n title: string;\n};\n\nconst Tooltip = ({\n continuous,\n index,\n isLastStep,\n step,\n backProps,\n primaryProps,\n skipProps,\n tooltipProps,\n size,\n locale,\n disableTourSkipOnEsc,\n}: TooltipRenderProps & { locale: TourTexts; disableTourSkipOnEsc?: boolean }) => {\n const skipButtonRef = React.useRef<HTMLButtonElement>(null);\n\n React.useEffect(() => {\n const onWindowKeyDown = (event: KeyboardEvent): void => {\n if (!disableTourSkipOnEsc) {\n if (event.key === 'Escape' && skipButtonRef.current !== null) {\n event.preventDefault();\n skipButtonRef.current.click();\n return;\n }\n }\n };\n\n window.addEventListener('keydown', onWindowKeyDown);\n\n return () => {\n window.removeEventListener('keydown', onWindowKeyDown);\n };\n }, []);\n\n return (\n <div {...tooltipProps} className=\"yt-tour__step w-88 relative rounded bg-white p-4\">\n <IconButton\n {...skipProps}\n ref={skipButtonRef}\n appearance=\"discrete\"\n icon=\"close\"\n title={locale.skip}\n aria-label={locale.skip}\n className=\"absolute top-0 right-0 mt-1 mr-1\"\n />\n {step.title && <h5>{step.title}</h5>}\n {step.content}\n <Group className=\"mt-4 justify-end\">\n {index > 0 && (\n <Button {...backProps} appearance=\"discrete\">\n {locale.back}\n </Button>\n )}\n <Button {...primaryProps} appearance=\"primary\">\n {continuous\n ? isLastStep\n ? `${locale.last} (${index + 1}/${size})`\n : `${locale.next} (${index + 1}/${size})`\n : locale.close}\n </Button>\n </Group>\n </div>\n );\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const TourStep = (_props: TourStepProps): null => null;\n\nexport type TourProps = {\n /** Controls if [Joyride](https://docs.react-joyride.com) is active */\n autoStart?: boolean;\n /** Children should be one or more `Tour.Step` components */\n children: any;\n /** Are there more than one steps and should you be able to navigate between them using `Next` and `Previous` buttons */\n continuous?: boolean;\n /** Disable closing of tour when click on `Escape` */\n disableCloseOnEsc?: boolean;\n /** Don't close the presenting popup of the tour step when clicking outside it */\n disableOverlayClose?: boolean;\n /** Allows user to interact with the presented components (mouse and touch events) when the popup is visible */\n disableScrolling?: boolean;\n /* When user clicks on the close icon button, which will close the tour and complete the flow */\n onClose?: (step: TourStepProps) => void;\n /* When user completes the entire flow */\n onComplete?: Function;\n /** When step is ready */\n onReady?: (step: TourStepProps) => void;\n /* Allow mouse and touch events through the spotlight */\n spotlightClicks?: boolean;\n /* Stops the injection of custom overflow styles on parent container. Can be used to prevent remaining overflow styles after tour is done. */\n disableScrollParentFix?: boolean;\n /** The scroll distance from the element scrollTop value. */\n scrollOffset?: number;\n};\n\nexport const Tour = (props: TourProps) => {\n const {\n texts: { tour },\n } = useLocalization();\n\n const {\n autoStart: run,\n onComplete,\n onClose,\n onReady,\n spotlightClicks,\n disableCloseOnEsc: disableTourSkipOnEsc,\n disableScrollParentFix = false,\n scrollOffset,\n ...rest\n } = props;\n\n const steps = React.useMemo(() => {\n return React.Children.map(props.children, child => {\n const step: Step = {\n disableBeacon: !child.props.showBeacon,\n target: child.props.selector,\n placement: child.props.position,\n title: child.props.title,\n content: child.props.children,\n };\n return step;\n });\n }, [props.children]);\n\n const getStep = React.useCallback(\n (selector: string | HTMLElement) => props.children.find((child: any) => child.props.selector === selector)?.props,\n [props.children]\n );\n\n const callback = (state: CallBackProps) => {\n if (state.action === ACTIONS.SKIP && state.lifecycle === LIFECYCLE.COMPLETE) {\n if (onClose) {\n onClose(getStep(state.step.target));\n }\n }\n\n if (state.type === EVENTS.TOUR_END) {\n if (onComplete) {\n onComplete();\n }\n }\n\n if (state.lifecycle === LIFECYCLE.READY) {\n if (onReady) {\n onReady(getStep(state.step.target));\n }\n }\n };\n\n return (\n <Joyride\n {...rest}\n run={run}\n steps={steps}\n showProgress\n floaterProps={{\n disableAnimation: true,\n }}\n tooltipComponent={tooltipProps => (\n <Tooltip {...tooltipProps} locale={tour} disableTourSkipOnEsc={disableTourSkipOnEsc} />\n )}\n locale={tour}\n spotlightPadding={8}\n spotlightClicks={spotlightClicks}\n disableScrollParentFix={disableScrollParentFix}\n callback={callback}\n scrollOffset={scrollOffset}\n styles={{\n /** style beacon */\n options: {\n // tailwind.theme.colors.blue.300\n primaryColor: '#6ba4ff',\n },\n }}\n disableCloseOnEsc\n />\n );\n};\n\nTour.Step = TourStep;\n"],"names":["Tooltip","continuous","index","isLastStep","step","backProps","primaryProps","skipProps","tooltipProps","size","locale","disableTourSkipOnEsc","skipButtonRef","React","onWindowKeyDown","event","key","current","preventDefault","click","window","addEventListener","removeEventListener","className","IconButton","ref","appearance","icon","title","skip","content","Group","Button","back","last","next","close","TourStep","_props","Tour","props","texts","tour","useLocalization","autoStart","run","onComplete","onClose","onReady","spotlightClicks","disableCloseOnEsc","disableScrollParentFix","scrollOffset","rest","steps","map","children","child","disableBeacon","showBeacon","target","selector","placement","position","getStep","_props$children$find","find","callback","state","action","ACTIONS","SKIP","lifecycle","LIFECYCLE","COMPLETE","type","EVENTS","TOUR_END","READY","Joyride","showProgress","floaterProps","disableAnimation","tooltipComponent","spotlightPadding","styles","options","primaryColor","Step"],"mappings":";;;;;;;AAqDA,MAAMA,OAAO,GAAGA,CAAC;EACbC,UAAU;EACVC,KAAK;EACLC,UAAU;EACVC,IAAI;EACJC,SAAS;EACTC,YAAY;EACZC,SAAS;EACTC,YAAY;EACZC,IAAI;EACJC,MAAM;EACNC;CACyE;EACzE,MAAMC,aAAa,GAAGC,MAAY,CAAoB,IAAI,CAAC;EAE3DA,SAAe,CAAC;IACZ,MAAMC,eAAe,GAAIC,KAAoB;MACzC,IAAI,CAACJ,oBAAoB,EAAE;QACvB,IAAII,KAAK,CAACC,GAAG,KAAK,QAAQ,IAAIJ,aAAa,CAACK,OAAO,KAAK,IAAI,EAAE;UAC1DF,KAAK,CAACG,cAAc,EAAE;UACtBN,aAAa,CAACK,OAAO,CAACE,KAAK,EAAE;UAC7B;;;KAGX;IAEDC,MAAM,CAACC,gBAAgB,CAAC,SAAS,EAAEP,eAAe,CAAC;IAEnD,OAAO;MACHM,MAAM,CAACE,mBAAmB,CAAC,SAAS,EAAER,eAAe,CAAC;KACzD;GACJ,EAAE,EAAE,CAAC;EAEN,oBACID,uCAASL,YAAY;IAAEe,SAAS,EAAC;mBAC7BV,cAACW,UAAU,oBACHjB,SAAS;IACbkB,GAAG,EAAEb,aAAa;IAClBc,UAAU,EAAC,UAAU;IACrBC,IAAI,EAAC,OAAO;IACZC,KAAK,EAAElB,MAAM,CAACmB,IAAI;kBACNnB,MAAM,CAACmB,IAAI;IACvBN,SAAS,EAAC;KACZ,EACDnB,IAAI,CAACwB,KAAK,iBAAIf,0BAAKT,IAAI,CAACwB,KAAK,CAAM,EACnCxB,IAAI,CAAC0B,OAAO,eACbjB,cAACkB,KAAK;I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AChCE,sBAAsB,EAAEA,sBAAsB;IAC9CgB,QAAQ,EAAEA,QAAQ;IAClBf,YAAY,EAAEA,YAAY;IAC1BiC,MAAM,EAAE;;MAEJC,OAAO,EAAE;;QAELC,YAAY,EAAE;;KAErB;IACDrC,iBAAiB;KACnB;AAEV;AAEAX,IAAI,CAACiD,IAAI,GAAGnD,QAAQ;;;;"}
@@ -50,7 +50,7 @@ const TreeviewGroup = /*#__PURE__*/React__default.forwardRef(function TreeviewGr
50
50
  }, typeof title === 'function' ? title(expanded) : title), /*#__PURE__*/React__default.createElement("ul", {
51
51
  role: "group",
52
52
  className: listClassName
53
- }, React__default.Children.toArray(children).filter(item => !!item).map((item, i) => ( /*#__PURE__*/React__default.createElement("li", {
53
+ }, React__default.Children.toArray(children).filter(item => !!item).map((item, i) => (/*#__PURE__*/React__default.createElement("li", {
54
54
  key: i,
55
55
  role: "none"
56
56
  }, /*#__PURE__*/React__default.cloneElement(item, {
@@ -1 +1 @@
1
- {"version":3,"file":"Treeview.js","sources":["../../../../../../../src/components/Treeview/Treeview.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\n\nexport type TreeviewItemProps = React.LinkHTMLAttributes<HTMLAnchorElement>;\n\nconst TreeviewItem = React.forwardRef(function TreeviewItem(props: TreeviewItemProps, ref: React.Ref<HTMLAnchorElement>) {\n return <a {...props} ref={ref} />;\n});\n\nexport type TreeviewGroupProps = Omit<React.LinkHTMLAttributes<HTMLDivElement>, 'className' | 'onClick' | 'title'> & {\n /** Add a classname to the treeview */\n className?: string | ((expanded: boolean) => string);\n /**\n * Set wheter the region is expanded, showing the children, or collapsed.\n * Default value is `false`\n */\n expanded?: boolean;\n /** Region is expanded at mount and can't be collapsed */\n fixed?: boolean;\n /** Handler called when user clicks the title of the group */\n onClick?: (event: React.MouseEvent<HTMLDivElement>, expanded: boolean) => void;\n /** Text displayed in the group's header */\n title: React.ReactNode | ((expanded: boolean) => React.ReactNode);\n};\n\nconst TreeviewGroup = React.forwardRef(function TreeviewGroup(props: TreeviewGroupProps, ref: React.Ref<HTMLDivElement>) {\n const {\n children,\n className: externalClassName,\n expanded: initialExpanded = false,\n title,\n fixed,\n onClick,\n ...otherProps\n } = props;\n const [expanded, setExpanded] = React.useState(fixed || initialExpanded);\n\n React.useEffect(() => {\n if (!fixed) {\n setExpanded(fixed || initialExpanded);\n }\n }, [fixed, initialExpanded]);\n\n const listClassName = cn('flex-col mb-0', {\n flex: expanded,\n hidden: !expanded,\n });\n\n const itemProps = {\n ...otherProps,\n 'aria-expanded': expanded,\n role: 'treeitem',\n tabIndex: -1,\n };\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>): void => {\n const nextState = !expanded;\n\n if (!fixed) {\n setExpanded(nextState);\n }\n\n if (onClick) {\n onClick(event, nextState);\n }\n };\n\n const className = typeof externalClassName === 'function' ? externalClassName(expanded) : externalClassName;\n\n return (\n <div {...itemProps} className={className} ref={ref}>\n <div onClick={handleClick}>{typeof title === 'function' ? title(expanded) : title}</div>\n <ul role=\"group\" className={listClassName}>\n {React.Children.toArray(children)\n .filter(item => !!item)\n .map((item, i) => (\n <li key={i} role=\"none\">\n {React.cloneElement(item as React.ReactElement<any>, { role: 'treeitem' })}\n </li>\n ))}\n </ul>\n </div>\n );\n});\n\nexport type TreeviewProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport type ForwardedTreeviewWithStatics = React.ForwardRefExoticComponent<\n TreeviewProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Navigable link */\n Item: React.ForwardRefExoticComponent<TreeviewItemProps & React.RefAttributes<HTMLAnchorElement>>;\n /** Container for a set of related links, usually expandable */\n Group: React.ForwardRefExoticComponent<TreeviewGroupProps & React.RefAttributes<HTMLDivElement>>;\n};\n\nexport const Treeview = React.forwardRef(function Treeview(props: TreeviewProps, ref: React.Ref<HTMLDivElement>) {\n return <div {...props} ref={ref} role=\"tree\" />;\n}) as ForwardedTreeviewWithStatics;\n\nTreeview.Group = TreeviewGroup;\nTreeview.Item = TreeviewItem;\n"],"names":["TreeviewItem","React","forwardRef","props","ref","TreeviewGroup","children","className","externalClassName","expanded","initialExpanded","title","fixed","onClick","otherProps","setExpanded","useState","useEffect","listClassName","cn","flex","hidden","itemProps","role","tabIndex","handleClick","event","nextState","Children","toArray","filter","item","map","i","key","cloneElement","Treeview","Group","Item"],"mappings":";;;AAKA,MAAMA,YAAY,gBAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,YAAYA,CAACG,KAAwB,EAAEC,GAAiC;EACnH,oBAAOH,oDAAOE,KAAK;IAAEC,GAAG,EAAEA;KAAO;AACrC,CAAC,CAAC;AAkBF,MAAMC,aAAa,gBAAGJ,cAAK,CAACC,UAAU,CAAC,SAASG,aAAaA,CAACF,KAAyB,EAAEC,GAA8B;EACnH,MAAM;IACFE,QAAQ;IACRC,SAAS,EAAEC,iBAAiB;IAC5BC,QAAQ,EAAEC,eAAe,GAAG,KAAK;IACjCC,KAAK;IACLC,KAAK;IACLC,OAAO;IACP,GAAGC;GACN,GAAGX,KAAK;EACT,MAAM,CAACM,QAAQ,EAAEM,WAAW,CAAC,GAAGd,cAAK,CAACe,QAAQ,CAACJ,KAAK,IAAIF,eAAe,CAAC;EAExET,cAAK,CAACgB,SAAS,CAAC;IACZ,IAAI,CAACL,KAAK,EAAE;MACRG,WAAW,CAACH,KAAK,IAAIF,eAAe,CAAC;;GAE5C,EAAE,CAACE,KAAK,EAAEF,eAAe,CAAC,CAAC;EAE5B,MAAMQ,aAAa,GAAGC,EAAE,CAAC,eAAe,EAAE;IACtCC,IAAI,EAAEX,QAAQ;IACdY,MAAM,EAAE,CAACZ;GACZ,CAAC;EAEF,MAAMa,SAAS,GAAG;IACd,GAAGR,UAAU;IACb,eAAe,EAAEL,QAAQ;IACzBc,IAAI,EAAE,UAAU;IAChBC,QAAQ,EAAE,CAAC;GACd;EAED,MAAMC,WAAW,GAAIC,KAAuC;IACxD,MAAMC,SAAS,GAAG,CAAClB,QAAQ;IAE3B,IAAI,CAACG,KAAK,EAAE;MACRG,WAAW,CAACY,SAAS,CAAC;;IAG1B,IAAId,OAAO,EAAE;MACTA,OAAO,CAACa,KAAK,EAAEC,SAAS,CAAC;;GAEhC;EAED,MAAMpB,SAAS,GAAG,OAAOC,iBAAiB,KAAK,UAAU,GAAGA,iBAAiB,CAACC,QAAQ,CAAC,GAAGD,iBAAiB;EAE3G,oBACIP,sDAASqB,SAAS;IAAEf,SAAS,EAAEA,SAAS;IAAEH,GAAG,EAAEA;mBAC3CH;IAAKY,OAAO,EAAEY;KAAc,OAAOd,KAAK,KAAK,UAAU,GAAGA,KAAK,CAACF,QAAQ,CAAC,GAAGE,KAAK,CAAO,eACxFV;IAAIsB,IAAI,EAAC,OAAO;IAAChB,SAAS,EAAEW;KACvBjB,cAAK,CAAC2B,QAAQ,CAACC,OAAO,CAACvB,QAAQ,CAAC,CAC5BwB,MAAM,CAACC,IAAI,IAAI,CAAC,CAACA,IAAI,CAAC,CACtBC,GAAG,CAAC,CAACD,IAAI,EAAEE,CAAC,oBACThC;IAAIiC,GAAG,EAAED,CAAC;IAAEV,IAAI,EAAC;kBACZtB,cAAK,CAACkC,YAAY,CAACJ,IAA+B,EAAE;IAAER,IAAI,EAAE;GAAY,CAAC,CACzE,CACR,CAAC,CACL,CACH;AAEd,CAAC,CAAC;MAaWa,QAAQ,gBAAGnC,cAAK,CAACC,UAAU,CAAC,SAASkC,QAAQA,CAACjC,KAAoB,EAAEC,GAA8B;EAC3G,oBAAOH,sDAASE,KAAK;IAAEC,GAAG,EAAEA,GAAG;IAAEmB,IAAI,EAAC;KAAS;AACnD,CAAC;AAEDa,QAAQ,CAACC,KAAK,GAAGhC,aAAa;AAC9B+B,QAAQ,CAACE,IAAI,GAAGtC,YAAY;;;;"}
1
+ {"version":3,"file":"Treeview.js","sources":["../../../../../../../src/components/Treeview/Treeview.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\n\nexport type TreeviewItemProps = React.LinkHTMLAttributes<HTMLAnchorElement>;\n\nconst TreeviewItem = React.forwardRef(function TreeviewItem(props: TreeviewItemProps, ref: React.Ref<HTMLAnchorElement>) {\n return <a {...props} ref={ref} />;\n});\n\nexport type TreeviewGroupProps = Omit<React.LinkHTMLAttributes<HTMLDivElement>, 'className' | 'onClick' | 'title'> & {\n /** Add a classname to the treeview */\n className?: string | ((expanded: boolean) => string);\n /**\n * Set wheter the region is expanded, showing the children, or collapsed.\n * Default value is `false`\n */\n expanded?: boolean;\n /** Region is expanded at mount and can't be collapsed */\n fixed?: boolean;\n /** Handler called when user clicks the title of the group */\n onClick?: (event: React.MouseEvent<HTMLDivElement>, expanded: boolean) => void;\n /** Text displayed in the group's header */\n title: React.ReactNode | ((expanded: boolean) => React.ReactNode);\n};\n\nconst TreeviewGroup = React.forwardRef(function TreeviewGroup(props: TreeviewGroupProps, ref: React.Ref<HTMLDivElement>) {\n const {\n children,\n className: externalClassName,\n expanded: initialExpanded = false,\n title,\n fixed,\n onClick,\n ...otherProps\n } = props;\n const [expanded, setExpanded] = React.useState(fixed || initialExpanded);\n\n React.useEffect(() => {\n if (!fixed) {\n setExpanded(fixed || initialExpanded);\n }\n }, [fixed, initialExpanded]);\n\n const listClassName = cn('flex-col mb-0', {\n flex: expanded,\n hidden: !expanded,\n });\n\n const itemProps = {\n ...otherProps,\n 'aria-expanded': expanded,\n role: 'treeitem',\n tabIndex: -1,\n };\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>): void => {\n const nextState = !expanded;\n\n if (!fixed) {\n setExpanded(nextState);\n }\n\n if (onClick) {\n onClick(event, nextState);\n }\n };\n\n const className = typeof externalClassName === 'function' ? externalClassName(expanded) : externalClassName;\n\n return (\n <div {...itemProps} className={className} ref={ref}>\n <div onClick={handleClick}>{typeof title === 'function' ? title(expanded) : title}</div>\n <ul role=\"group\" className={listClassName}>\n {React.Children.toArray(children)\n .filter(item => !!item)\n .map((item, i) => (\n <li key={i} role=\"none\">\n {React.cloneElement(item as React.ReactElement<any>, { role: 'treeitem' })}\n </li>\n ))}\n </ul>\n </div>\n );\n});\n\nexport type TreeviewProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport type ForwardedTreeviewWithStatics = React.ForwardRefExoticComponent<\n TreeviewProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Navigable link */\n Item: React.ForwardRefExoticComponent<TreeviewItemProps & React.RefAttributes<HTMLAnchorElement>>;\n /** Container for a set of related links, usually expandable */\n Group: React.ForwardRefExoticComponent<TreeviewGroupProps & React.RefAttributes<HTMLDivElement>>;\n};\n\nexport const Treeview = React.forwardRef(function Treeview(props: TreeviewProps, ref: React.Ref<HTMLDivElement>) {\n return <div {...props} ref={ref} role=\"tree\" />;\n}) as ForwardedTreeviewWithStatics;\n\nTreeview.Group = TreeviewGroup;\nTreeview.Item = TreeviewItem;\n"],"names":["TreeviewItem","React","forwardRef","props","ref","TreeviewGroup","children","className","externalClassName","expanded","initialExpanded","title","fixed","onClick","otherProps","setExpanded","useState","useEffect","listClassName","cn","flex","hidden","itemProps","role","tabIndex","handleClick","event","nextState","Children","toArray","filter","item","map","i","key","cloneElement","Treeview","Group","Item"],"mappings":";;;AAKA,MAAMA,YAAY,gBAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,YAAYA,CAACG,KAAwB,EAAEC,GAAiC;EACnH,oBAAOH,oDAAOE,KAAK;IAAEC,GAAG,EAAEA;KAAO;AACrC,CAAC,CAAC;AAkBF,MAAMC,aAAa,gBAAGJ,cAAK,CAACC,UAAU,CAAC,SAASG,aAAaA,CAACF,KAAyB,EAAEC,GAA8B;EACnH,MAAM;IACFE,QAAQ;IACRC,SAAS,EAAEC,iBAAiB;IAC5BC,QAAQ,EAAEC,eAAe,GAAG,KAAK;IACjCC,KAAK;IACLC,KAAK;IACLC,OAAO;IACP,GAAGC;GACN,GAAGX,KAAK;EACT,MAAM,CAACM,QAAQ,EAAEM,WAAW,CAAC,GAAGd,cAAK,CAACe,QAAQ,CAACJ,KAAK,IAAIF,eAAe,CAAC;EAExET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AAE;GAAY,CAAC,CACzE,CACR,CAAC,CACL,CACH;AAEd,CAAC,CAAC;MAaWa,QAAQ,gBAAGnC,cAAK,CAACC,UAAU,CAAC,SAASkC,QAAQA,CAACjC,KAAoB,EAAEC,GAA8B;EAC3G,oBAAOH,sDAASE,KAAK;IAAEC,GAAG,EAAEA,GAAG;IAAEmB,IAAI,EAAC;KAAS;AACnD,CAAC;AAEDa,QAAQ,CAACC,KAAK,GAAGhC,aAAa;AAC9B+B,QAAQ,CAACE,IAAI,GAAGtC,YAAY;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useIntersectionObserver.js","sources":["../../../../../../src/hooks/useIntersectionObserver.ts"],"sourcesContent":["import React from 'react';\n\nexport const useIntersectionObserver = (ref: React.RefObject<HTMLElement>, offset?: number) => {\n const [intersectedIndexes, setIntersectedIndexes] = React.useState({});\n\n const handleIntersection = (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n if (observer.root) {\n const children = Array.from((observer.root as Element).children);\n const map = {};\n\n entries.forEach(entry => {\n // entries only contains the items being intersected not all children of the ref\n // so use root and the the entry being intersected to find its real index\n // on first mount this is different - all children are present\n map[children.indexOf(entry.target)] = entry.isIntersecting;\n });\n\n setIntersectedIndexes(prev => ({ ...prev, ...map }));\n }\n };\n\n const intersectedChildIndex = React.useMemo(() => {\n const index = Object.values(intersectedIndexes).indexOf(false);\n return index > -1 ? index : undefined;\n }, [intersectedIndexes]);\n\n const hasRootMargin = intersectedChildIndex !== undefined && offset;\n\n React.useEffect(() => {\n const observer = new IntersectionObserver(handleIntersection, {\n root: ref.current,\n // offset the button, but only after the first item has been intersected\n rootMargin: hasRootMargin ? `0px -${offset}px 0px 0px` : undefined,\n threshold: 1,\n });\n\n if (observer.root) {\n Array.from(observer.root.children).forEach(item => {\n if (!item.hasAttribute('data-observer-ignore')) {\n observer.observe(item);\n }\n });\n }\n\n return () => {\n observer.disconnect();\n };\n }, [hasRootMargin]);\n\n return intersectedChildIndex;\n};\n"],"names":["useIntersectionObserver","ref","offset","intersectedIndexes","setIntersectedIndexes","React","useState","handleIntersection","entries","observer","root","children","Array","from","map","forEach","entry","indexOf","target","isIntersecting","prev","intersectedChildIndex","useMemo","index","Object","values","undefined","hasRootMargin","useEffect","IntersectionObserver","current","rootMargin","threshold","item","hasAttribute","observe","disconnect"],"mappings":";;MAEaA,uBAAuB,GAAGA,CAACC,GAAiC,EAAEC,MAAe;EACtF,MAAM,CAACC,kBAAkB,EAAEC,qBAAqB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,EAAE,CAAC;EAEtE,MAAMC,kBAAkB,GAAGA,CAACC,OAAoC,EAAEC,QAA8B;IAC5F,IAAIA,QAAQ,CAACC,IAAI,EAAE;MACf,MAAMC,QAAQ,GAAGC,KAAK,CAACC,IAAI,CAAEJ,QAAQ,CAACC,IAAgB,CAACC,QAAQ,CAAC;MAChE,MAAMG,GAAG,GAAG,EAAE;MAEdN,OAAO,CAACO,OAAO,CAACC,KAAK;;;;QAIjBF,GAAG,CAACH,QAAQ,CAACM,OAAO,CAACD,KAAK,CAACE,MAAM,CAAC,CAAC,GAAGF,KAAK,CAACG,cAAc;OAC7D,CAAC;MAEFf,qBAAqB,CAACgB,IAAI,KAAK;QAAE,GAAGA,IAAI;QAAE,GAAGN;OAAK,CAAC,CAAC;;GAE3D;EAED,MAAMO,qBAAqB,GAAGhB,cAAK,CAACiB,OAAO,CAAC;IACxC,MAAMC,KAAK,GAAGC,MAAM,CAACC,MAAM,CAACtB,kBAAkB,CAAC,CAACc,OAAO,CAAC,KAAK,CAAC;IAC9D,OAAOM,KAAK,GAAG,CAAC,CAAC,GAAGA,KAAK,GAAGG,SAAS;GACxC,EAAE,CAACvB,kBAAkB,CAAC,CAAC;EAExB,MAAMwB,aAAa,GAAGN,qBAAqB,KAAKK,SAAS,IAAIxB,MAAM;EAEnEG,cAAK,CAACuB,SAAS,CAAC;IACZ,MAAMnB,QAAQ,GAAG,IAAIoB,oBAAoB,CAACtB,kBAAkB,EAAE;MAC1DG,IAAI,EAAET,GAAG,CAAC6B,OAAO;;MAEjBC,UAAU,EAAEJ,aAAa,WAAWzB,kBAAkB,GAAGwB,SAAS;MAClEM,SAAS,EAAE;KACd,CAAC;IAEF,IAAIvB,QAAQ,CAACC,IAAI,EAAE;MACfE,KAAK,CAACC,IAAI,CAACJ,QAAQ,CAACC,IAAI,CAACC,QAAQ,CAAC,CAACI,OAAO,CAACkB,IAAI;QAC3C,IAAI,CAACA,IAAI,CAACC,YAAY,CAAC,sBAAsB,CAAC,EAAE;UAC5CzB,QAAQ,CAAC0B,OAAO,CAACF,IAAI,CAAC;;OAE7B,CAAC;;IAGN,OAAO;MACHxB,QAAQ,CAAC2B,UAAU,EAAE;KACxB;GACJ,EAAE,CAACT,aAAa,CAAC,CAAC;EAEnB,OAAON,qBAAqB;AAChC;;;;"}
1
+ {"version":3,"file":"useIntersectionObserver.js","sources":["../../../../../../src/hooks/useIntersectionObserver.ts"],"sourcesContent":["import React from 'react';\n\nexport const useIntersectionObserver = (ref: React.RefObject<HTMLElement>, offset?: number) => {\n const [intersectedIndexes, setIntersectedIndexes] = React.useState({});\n\n const handleIntersection = (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n if (observer.root) {\n const children = Array.from((observer.root as Element).children);\n const map = {};\n\n entries.forEach(entry => {\n // entries only contains the items being intersected not all children of the ref\n // so use root and the the entry being intersected to find its real index\n // on first mount this is different - all children are present\n map[children.indexOf(entry.target)] = entry.isIntersecting;\n });\n\n setIntersectedIndexes(prev => ({ ...prev, ...map }));\n }\n };\n\n const intersectedChildIndex = React.useMemo(() => {\n const index = Object.values(intersectedIndexes).indexOf(false);\n return index > -1 ? index : undefined;\n }, [intersectedIndexes]);\n\n const hasRootMargin = intersectedChildIndex !== undefined && offset;\n\n React.useEffect(() => {\n const observer = new IntersectionObserver(handleIntersection, {\n root: ref.current,\n // offset the button, but only after the first item has been intersected\n rootMargin: hasRootMargin ? `0px -${offset}px 0px 0px` : undefined,\n threshold: 1,\n });\n\n if (observer.root) {\n Array.from(observer.root.children).forEach(item => {\n if (!item.hasAttribute('data-observer-ignore')) {\n observer.observe(item);\n }\n });\n }\n\n return () => {\n observer.disconnect();\n };\n }, [hasRootMargin]);\n\n return intersectedChildIndex;\n};\n"],"names":["useIntersectionObserver","ref","offset","intersectedIndexes","setIntersectedIndexes","React","useState","handleIntersection","entries","observer","root","children","Array","from","map","forEach","entry","indexOf","target","isIntersecting","prev","intersectedChildIndex","useMemo","index","Object","values","undefined","hasRootMargin","useEffect","IntersectionObserver","current","rootMargin","threshold","item","hasAttribute","observe","disconnect"],"mappings":";;MAEaA,uBAAuB,GAAGA,CAACC,GAAiC,EAAEC,MAAe;EACtF,MAAM,CAACC,kBAAkB,EAAEC,qBAAqB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,EAAE,CAAC;EAEtE,MAAMC,kBAAkB,GAAGA,CAACC,OAAoC,EAAEC,QAA8B;IAC5F,IAAIA,QAAQ,CAACC,IAAI,EAAE;MACf,MAAMC,QAAQ,GAAGC,KAAK,CAACC,IAAI,CAAEJ,QAAQ,CAACC,IAAgB,CAACC,QAAQ,CAAC;MAChE,MAAMG,GAAG,GAAG,EAAE;MAEdN,OAAO,CAACO,OAAO,CAACC,KAAK;;;;QAIjBF,GAAG,CAACH,QAAQ,CAACM,OAAO,CAACD,KAAK,CAACE,MAAM,CAAC,CAAC,GAAGF,KAAK,CAACG,cAAc;OAC7D,CAAC;MAEFf,qBAAqB,CAACgB,IAAI,KAAK;QAAE,GAAGA,IAAI;QAAE,GAAGN;OAAK,CAAC,CAAC;;GAE3D;EAED,MAAMO,qBAAqB,GAAGhB,cAAK,CAACiB,OAAO,CAAC;IACxC,MAAMC,KAAK,GAAGC,MAAM,CAACC,MAAM,CAACtB,kBAAkB,CAAC,CAACc,OAAO,CAAC,KAAK,CAAC;IAC9D,OAAOM,KAAK,GAAG,CAAC,CAAC,GAAGA,KAAK,GAAGG,SAAS;GACxC,EAAE,CAACvB,kBAAkB,CAAC,CAAC;EAExB,MAAMwB,aAAa,GAAGN,qBAAqB,KAAKK,SAAS,IAAIxB,MAAM;EAEnEG,cAAK,CAACuB,SAAS,CAAC;IACZ,MAAMnB,QAAQ,GAAG,IAAIoB,oBAAoB,CAACtB,kBAAkB,EAAE;MAC1DG,IAAI,EAAET,GAAG,CAAC6B,OAAO;;MAEjBC,UAAU,EAAEJ,aAAa,GAAG,QAAQzB,MAAM,YAAY,GAAGwB,SAAS;MAClEM,SAAS,EAAE;KACd,CAAC;IAEF,IAAIvB,QAAQ,CAACC,IAAI,EAAE;MACfE,KAAK,CAACC,IAAI,CAACJ,QAAQ,CAACC,IAAI,CAACC,QAAQ,CAAC,CAACI,OAAO,CAACkB,IAAI;QAC3C,IAAI,CAACA,IAAI,CAACC,YAAY,CAAC,sBAAsB,CAAC,EAAE;UAC5CzB,QAAQ,CAAC0B,OAAO,CAACF,IAAI,CAAC;;OAE7B,CAAC;;IAGN,OAAO;MACHxB,QAAQ,CAAC2B,UAAU,EAAE;KACxB;GACJ,EAAE,CAACT,aAAa,CAAC,CAAC;EAEnB,OAAON,qBAAqB;AAChC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"BubbleSelect.js","sources":["../../../../../../src/primitives/BubbleSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { usePreviousValue } from '../hooks/usePrevious';\n\n// taken from radix - https://github.com/radix-ui/primitives/blob/main/packages/react/select/src/Select.tsx#L1183-L1224\nexport const BubbleSelect = (props: React.SelectHTMLAttributes<HTMLSelectElement>) => {\n const { value, ...selectProps } = props;\n const ref = React.useRef<HTMLSelectElement>(null);\n const prevValue = usePreviousValue(value);\n\n // Bubble value change to parents (e.g form change event)\n React.useEffect(() => {\n const select = ref.current!;\n const descriptor = Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value') as PropertyDescriptor;\n const setValue = descriptor.set;\n\n if (prevValue !== value && setValue) {\n if (Array.isArray(value)) {\n value.forEach(v => {\n const option: HTMLOptionElement | null = select.querySelector(`option[value='${v}']`);\n\n if (option) {\n option.selected = true;\n }\n });\n } else {\n setValue.call(select, value);\n }\n\n const event = new Event('change', { bubbles: true });\n select.dispatchEvent(event);\n }\n }, [prevValue, value]);\n\n /**\n * We purposefully do not use `type=\"hidden\"` here otherwise forms that\n * wrap it will not be able to access its value via the FormData API.\n *\n * We purposefully do not add the `value` attribute here to allow the value\n * to be set programatically and bubble to any parent form `onChange` event.\n * Adding the `value` will cause React to consider the programatic\n * dispatch a duplicate and it will get swallowed.\n */\n return <select {...selectProps} defaultValue={value} ref={ref} style={{ display: 'none' }} />;\n};\n"],"names":["BubbleSelect","props","value","selectProps","ref","React","useRef","prevValue","usePreviousValue","useEffect","select","current","descriptor","Object","getOwnPropertyDescriptor","window","HTMLSelectElement","prototype","setValue","set","Array","isArray","forEach","v","option","querySelector","selected","call","event","Event","bubbles","dispatchEvent","defaultValue","style","display"],"mappings":";;;AAGA;MACaA,YAAY,GAAIC,KAAoD;EAC7E,MAAM;IAAEC,KAAK;IAAE,GAAGC;GAAa,GAAGF,KAAK;EACvC,MAAMG,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,SAAS,GAAGC,gBAAgB,CAACN,KAAK,CAAC;;EAGzCG,cAAK,CAACI,SAAS,CAAC;IACZ,MAAMC,MAAM,GAAGN,GAAG,CAACO,OAAQ;IAC3B,MAAMC,UAAU,GAAGC,MAAM,CAACC,wBAAwB,CAACC,MAAM,CAACC,iBAAiB,CAACC,SAAS,EAAE,OAAO,CAAuB;IACrH,MAAMC,QAAQ,GAAGN,UAAU,CAACO,GAAG;IAE/B,IAAIZ,SAAS,KAAKL,KAAK,IAAIgB,QAAQ,EAAE;MACjC,IAAIE,KAAK,CAACC,OAAO,CAACnB,KAAK,CAAC,EAAE;QACtBA,KAAK,CAACoB,OAAO,CAACC,CAAC;UACX,MAAMC,MAAM,GAA6Bd,MAAM,CAACe,aAAa,kBAAkBF,KAAK,CAAC;UAErF,IAAIC,MAAM,EAAE;YACRA,MAAM,CAACE,QAAQ,GAAG,IAAI;;SAE7B,CAAC;OACL,MAAM;QACHR,QAAQ,CAACS,IAAI,CAACjB,MAAM,EAAER,KAAK,CAAC;;MAGhC,MAAM0B,KAAK,GAAG,IAAIC,KAAK,CAAC,QAAQ,EAAE;QAAEC,OAAO,EAAE;OAAM,CAAC;MACpDpB,MAAM,CAACqB,aAAa,CAACH,KAAK,CAAC;;GAElC,EAAE,CAACrB,SAAS,EAAEL,KAAK,CAAC,CAAC;;;;;;;;;;EAWtB,oBAAOG,yDAAYF,WAAW;IAAE6B,YAAY,EAAE9B,KAAK;IAAEE,GAAG,EAAEA,GAAG;IAAE6B,KAAK,EAAE;MAAEC,OAAO,EAAE;;KAAY;AACjG;;;;"}
1
+ {"version":3,"file":"BubbleSelect.js","sources":["../../../../../../src/primitives/BubbleSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { usePreviousValue } from '../hooks/usePrevious';\n\n// taken from radix - https://github.com/radix-ui/primitives/blob/main/packages/react/select/src/Select.tsx#L1183-L1224\nexport const BubbleSelect = (props: React.SelectHTMLAttributes<HTMLSelectElement>) => {\n const { value, ...selectProps } = props;\n const ref = React.useRef<HTMLSelectElement>(null);\n const prevValue = usePreviousValue(value);\n\n // Bubble value change to parents (e.g form change event)\n React.useEffect(() => {\n const select = ref.current!;\n const descriptor = Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value') as PropertyDescriptor;\n const setValue = descriptor.set;\n\n if (prevValue !== value && setValue) {\n if (Array.isArray(value)) {\n value.forEach(v => {\n const option: HTMLOptionElement | null = select.querySelector(`option[value='${v}']`);\n\n if (option) {\n option.selected = true;\n }\n });\n } else {\n setValue.call(select, value);\n }\n\n const event = new Event('change', { bubbles: true });\n select.dispatchEvent(event);\n }\n }, [prevValue, value]);\n\n /**\n * We purposefully do not use `type=\"hidden\"` here otherwise forms that\n * wrap it will not be able to access its value via the FormData API.\n *\n * We purposefully do not add the `value` attribute here to allow the value\n * to be set programatically and bubble to any parent form `onChange` event.\n * Adding the `value` will cause React to consider the programatic\n * dispatch a duplicate and it will get swallowed.\n */\n return <select {...selectProps} defaultValue={value} ref={ref} style={{ display: 'none' }} />;\n};\n"],"names":["BubbleSelect","props","value","selectProps","ref","React","useRef","prevValue","usePreviousValue","useEffect","select","current","descriptor","Object","getOwnPropertyDescriptor","window","HTMLSelectElement","prototype","setValue","set","Array","isArray","forEach","v","option","querySelector","selected","call","event","Event","bubbles","dispatchEvent","defaultValue","style","display"],"mappings":";;;AAGA;MACaA,YAAY,GAAIC,KAAoD;EAC7E,MAAM;IAAEC,KAAK;IAAE,GAAGC;GAAa,GAAGF,KAAK;EACvC,MAAMG,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,SAAS,GAAGC,gBAAgB,CAACN,KAAK,CAAC;;EAGzCG,cAAK,CAACI,SAAS,CAAC;IACZ,MAAMC,MAAM,GAAGN,GAAG,CAACO,OAAQ;IAC3B,MAAMC,UAAU,GAAGC,MAAM,CAACC,wBAAwB,CAACC,MAAM,CAACC,iBAAiB,CAACC,SAAS,EAAE,OAAO,CAAuB;IACrH,MAAMC,QAAQ,GAAGN,UAAU,CAACO,GAAG;IAE/B,IAAIZ,SAAS,KAAKL,KAAK,IAAIgB,QAAQ,EAAE;MACjC,IAAIE,KAAK,CAACC,OAAO,CAACnB,KAAK,CAAC,EAAE;QACtBA,KAAK,CAACoB,OAAO,CAACC,CAAC;UACX,MAAMC,MAAM,GAA6Bd,MAAM,CAACe,aAAa,CAAC,iBAAiBF,CAAC,IAAI,CAAC;UAErF,IAAIC,MAAM,EAAE;YACRA,MAAM,CAACE,QAAQ,GAAG,IAAI;;SAE7B,CAAC;OACL,MAAM;QACHR,QAAQ,CAACS,IAAI,CAACjB,MAAM,EAAER,KAAK,CAAC;;MAGhC,MAAM0B,KAAK,GAAG,IAAIC,KAAK,CAAC,QAAQ,EAAE;QAAEC,OAAO,EAAE;OAAM,CAAC;MACpDpB,MAAM,CAACqB,aAAa,CAACH,KAAK,CAAC;;GAElC,EAAE,CAACrB,SAAS,EAAEL,KAAK,CAAC,CAAC;;;;;;;;;;EAWtB,oBAAOG,yDAAYF,WAAW;IAAE6B,YAAY,EAAE9B,KAAK;IAAEE,GAAG,EAAEA,GAAG;IAAE6B,KAAK,EAAE;MAAEC,OAAO,EAAE;;KAAY;AACjG;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Root.js","sources":["../../../../../../../../src/primitives/Collection/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { isAriaDirectionKey } from '../../../utils/aria';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\n\n/* This component provides a keyboard navigable collection primitive for use in lists\n * It is unlikely you need to edit this component\n */\n\nexport type CollectionProps = React.HTMLAttributes<HTMLDivElement> & {\n querySelector: string;\n};\n\nexport type CollectionRef = HTMLDivElement & {\n setActiveIndex: (option: HTMLDivElement) => void;\n};\n\nconst getOptionsFromCollection = (collection: HTMLDivElement, selector: string): NodeListOf<Element> =>\n collection.querySelectorAll(selector);\n\n// we use javascript to set attributes (rather than cloning children and adding them)\n// so that we can support nesting (e.g. groups) - child elements that aren't options.\n// without doing this we would have to unwrap and flatten all groups\nexport const Root = React.forwardRef<CollectionRef, CollectionProps>(function CollectionRoot(props, ref) {\n const { querySelector, tabIndex = 0, ...otherProps } = props;\n const internalRef = useMergedRef<CollectionRef>(ref);\n const [activeIndex, setActiveIndex] = React.useState<number | undefined>();\n const lastLengthRef = React.useRef(0);\n\n const setActiveOption = (index: number, collection: HTMLDivElement, option: Element) => {\n collection.querySelector(`[aria-current]`)?.removeAttribute('aria-current');\n option.setAttribute('aria-current', 'true');\n option.scrollIntoView({ block: 'nearest' });\n setActiveIndex(index);\n };\n\n const setActiveIndexByElement = React.useCallback(\n (option: HTMLDivElement) => {\n if (internalRef.current) {\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, internalRef.current, option);\n }\n }\n }\n },\n [internalRef.current, querySelector]\n );\n\n React.useEffect(() => {\n if (internalRef.current) {\n internalRef.current.setActiveIndex = setActiveIndexByElement;\n }\n }, [internalRef.current]);\n\n React.useEffect(() => {\n if (internalRef.current) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n\n if (options.length && options.length !== lastLengthRef.current) {\n let selected = internalRef.current.querySelectorAll(`[aria-current=\"true\"]`);\n\n if (selected.length === 0) {\n selected = internalRef.current.querySelectorAll(`[aria-selected]`);\n }\n\n if (selected.length === 1) {\n if (options) {\n const firstSelected = selected.item(0);\n const selectedIndex = Array.from(options).indexOf(firstSelected);\n\n if (selectedIndex > -1) {\n setActiveOption(selectedIndex, internalRef.current, firstSelected);\n }\n }\n } else {\n // multiple selected or none selected should go to 0\n setActiveOption(0, internalRef.current, options.item(0));\n }\n }\n\n lastLengthRef.current = options.length;\n }\n }, [props.children]);\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const option = event.target as HTMLElement;\n\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, event.currentTarget, option);\n }\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // this stops the event dispatched to the option rebounding back and starting an infinite loop\n if (event.target !== event.currentTarget) {\n return;\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n\n if (options) {\n if (isAriaDirectionKey(event)) {\n event.preventDefault();\n event.stopPropagation();\n const nextActiveIndex = getNextEnabledItem(event, options, activeIndex);\n\n if (nextActiveIndex !== undefined && nextActiveIndex !== activeIndex) {\n setActiveOption(nextActiveIndex, event.currentTarget, options.item(nextActiveIndex));\n }\n } else if (activeIndex !== undefined && !!options.item(activeIndex)) {\n // forward events onto the underlying option - this lets consumers place onKeyDown handlers on their own components\n options\n .item(activeIndex)\n ?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n }\n }\n };\n\n return <div {...otherProps} onClick={handleClick} onKeyDown={handleKeyDown} ref={internalRef} tabIndex={tabIndex} />;\n});\n\nexport const getNextIndexFromKeycode = (\n event: React.KeyboardEvent,\n length: number,\n activeIndex: number | undefined\n): number | undefined => {\n switch (event.key) {\n case 'ArrowUp':\n return activeIndex === undefined ? length - 1 : activeIndex > 0 ? activeIndex - 1 : activeIndex;\n\n case 'ArrowDown':\n return activeIndex === undefined ? 0 : activeIndex < length - 1 ? activeIndex + 1 : activeIndex;\n\n case 'Home':\n return 0;\n\n case 'End':\n return length - 1;\n\n default:\n return;\n }\n};\n\nexport const getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n options: NodeListOf<Element>,\n activeIndex: number | undefined,\n recurse = true\n): number | undefined => {\n const nextIndex = getNextIndexFromKeycode(event, options.length, activeIndex);\n\n if (nextIndex !== undefined) {\n if (nextIndex === activeIndex) {\n return activeIndex;\n } else if (options.item(nextIndex) && isSkippableItem(options.item(nextIndex))) {\n // check in the other direction if the first or last item is disabled,\n // but prevent infinite loops if all elements are disabled by disabling recursion\n if (recurse) {\n if (nextIndex === 0) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowDown' }) as any,\n options,\n nextIndex,\n false\n );\n } else if (nextIndex === options.length - 1) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowUp' }) as any,\n options,\n nextIndex,\n false\n );\n }\n }\n\n return getNextEnabledItem(event, options, nextIndex, recurse);\n }\n }\n\n return nextIndex;\n};\n\nconst isSkippableItem = (element: Element) => {\n return (\n element.getAttribute('role') === 'presentation' ||\n !!element.hasAttribute('disabled') ||\n !!element.getAttribute('aria-disabled') ||\n !!element.getAttribute('aria-hidden')\n );\n};\n"],"names":["getOptionsFromCollection","collection","selector","querySelectorAll","Root","React","forwardRef","CollectionRoot","props","ref","querySelector","tabIndex","otherProps","internalRef","useMergedRef","activeIndex","setActiveIndex","useState","lastLengthRef","useRef","setActiveOption","index","option","_collection$querySele","removeAttribute","setAttribute","scrollIntoView","block","setActiveIndexByElement","useCallback","current","matches","options","nextActiveIndex","Array","from","indexOf","useEffect","length","selected","firstSelected","item","selectedIndex","children","handleClick","event","target","currentTarget","handleKeyDown","onKeyDown","isDefaultPrevented","isAriaDirectionKey","preventDefault","stopPropagation","getNextEnabledItem","undefined","_options$item","dispatchEvent","createCustomKeyboardEvent","onClick","getNextIndexFromKeycode","key","recurse","nextIndex","isSkippableItem","KeyboardEvent","type","element","getAttribute","hasAttribute"],"mappings":";;;;;AAiBA,MAAMA,wBAAwB,GAAGA,CAACC,UAA0B,EAAEC,QAAgB,KAC1ED,UAAU,CAACE,gBAAgB,CAACD,QAAQ,CAAC;AAEzC;AACA;AACA;MACaE,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAiC,SAASC,cAAcA,CAACC,KAAK,EAAEC,GAAG;EACnG,MAAM;IAAEC,aAAa;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAC5D,MAAMK,WAAW,GAAGC,YAAY,CAAgBL,GAAG,CAAC;EACpD,MAAM,CAACM,WAAW,EAAEC,cAAc,CAAC,GAAGX,cAAK,CAACY,QAAQ,EAAsB;EAC1E,MAAMC,aAAa,GAAGb,cAAK,CAACc,MAAM,CAAC,CAAC,CAAC;EAErC,MAAMC,eAAe,GAAGA,CAACC,KAAa,EAAEpB,UAA0B,EAAEqB,MAAe;;IAC/E,CAAAC,qBAAA,GAAAtB,UAAU,CAACS,aAAa,iBAAiB,CAAC,cAAAa,qBAAA,u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S,EACT,KAAK,CACR;;;MAIT,OAAOT,kBAAkB,CAACT,KAAK,EAAEb,OAAO,EAAE+B,SAAS,EAAED,OAAO,CAAC;;;EAIrE,OAAOC,SAAS;AACpB;AAEA,MAAMC,eAAe,GAAIG,OAAgB;EACrC,OACIA,OAAO,CAACC,YAAY,CAAC,MAAM,CAAC,KAAK,cAAc,IAC/C,CAAC,CAACD,OAAO,CAACE,YAAY,CAAC,UAAU,CAAC,IAClC,CAAC,CAACF,OAAO,CAACC,YAAY,CAAC,eAAe,CAAC,IACvC,CAAC,CAACD,OAAO,CAACC,YAAY,CAAC,aAAa,CAAC;AAE7C,CAAC;;;;"}
1
+ {"version":3,"file":"Root.js","sources":["../../../../../../../../src/primitives/Collection/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { isAriaDirectionKey } from '../../../utils/aria';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\n\n/* This component provides a keyboard navigable collection primitive for use in lists\n * It is unlikely you need to edit this component\n */\n\nexport type CollectionProps = React.HTMLAttributes<HTMLDivElement> & {\n querySelector: string;\n};\n\nexport type CollectionRef = HTMLDivElement & {\n setActiveIndex: (option: HTMLDivElement) => void;\n};\n\nconst getOptionsFromCollection = (collection: HTMLDivElement, selector: string): NodeListOf<Element> =>\n collection.querySelectorAll(selector);\n\n// we use javascript to set attributes (rather than cloning children and adding them)\n// so that we can support nesting (e.g. groups) - child elements that aren't options.\n// without doing this we would have to unwrap and flatten all groups\nexport const Root = React.forwardRef<CollectionRef, CollectionProps>(function CollectionRoot(props, ref) {\n const { querySelector, tabIndex = 0, ...otherProps } = props;\n const internalRef = useMergedRef<CollectionRef>(ref);\n const [activeIndex, setActiveIndex] = React.useState<number | undefined>();\n const lastLengthRef = React.useRef(0);\n\n const setActiveOption = (index: number, collection: HTMLDivElement, option: Element) => {\n collection.querySelector(`[aria-current]`)?.removeAttribute('aria-current');\n option.setAttribute('aria-current', 'true');\n option.scrollIntoView({ block: 'nearest' });\n setActiveIndex(index);\n };\n\n const setActiveIndexByElement = React.useCallback(\n (option: HTMLDivElement) => {\n if (internalRef.current) {\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, internalRef.current, option);\n }\n }\n }\n },\n [internalRef.current, querySelector]\n );\n\n React.useEffect(() => {\n if (internalRef.current) {\n internalRef.current.setActiveIndex = setActiveIndexByElement;\n }\n }, [internalRef.current]);\n\n React.useEffect(() => {\n if (internalRef.current) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n\n if (options.length && options.length !== lastLengthRef.current) {\n let selected = internalRef.current.querySelectorAll(`[aria-current=\"true\"]`);\n\n if (selected.length === 0) {\n selected = internalRef.current.querySelectorAll(`[aria-selected]`);\n }\n\n if (selected.length === 1) {\n if (options) {\n const firstSelected = selected.item(0);\n const selectedIndex = Array.from(options).indexOf(firstSelected);\n\n if (selectedIndex > -1) {\n setActiveOption(selectedIndex, internalRef.current, firstSelected);\n }\n }\n } else {\n // multiple selected or none selected should go to 0\n setActiveOption(0, internalRef.current, options.item(0));\n }\n }\n\n lastLengthRef.current = options.length;\n }\n }, [props.children]);\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const option = event.target as HTMLElement;\n\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, event.currentTarget, option);\n }\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // this stops the event dispatched to the option rebounding back and starting an infinite loop\n if (event.target !== event.currentTarget) {\n return;\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n\n if (options) {\n if (isAriaDirectionKey(event)) {\n event.preventDefault();\n event.stopPropagation();\n const nextActiveIndex = getNextEnabledItem(event, options, activeIndex);\n\n if (nextActiveIndex !== undefined && nextActiveIndex !== activeIndex) {\n setActiveOption(nextActiveIndex, event.currentTarget, options.item(nextActiveIndex));\n }\n } else if (activeIndex !== undefined && !!options.item(activeIndex)) {\n // forward events onto the underlying option - this lets consumers place onKeyDown handlers on their own components\n options\n .item(activeIndex)\n ?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n }\n }\n };\n\n return <div {...otherProps} onClick={handleClick} onKeyDown={handleKeyDown} ref={internalRef} tabIndex={tabIndex} />;\n});\n\nexport const getNextIndexFromKeycode = (\n event: React.KeyboardEvent,\n length: number,\n activeIndex: number | undefined\n): number | undefined => {\n switch (event.key) {\n case 'ArrowUp':\n return activeIndex === undefined ? length - 1 : activeIndex > 0 ? activeIndex - 1 : activeIndex;\n\n case 'ArrowDown':\n return activeIndex === undefined ? 0 : activeIndex < length - 1 ? activeIndex + 1 : activeIndex;\n\n case 'Home':\n return 0;\n\n case 'End':\n return length - 1;\n\n default:\n return;\n }\n};\n\nexport const getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n options: NodeListOf<Element>,\n activeIndex: number | undefined,\n recurse = true\n): number | undefined => {\n const nextIndex = getNextIndexFromKeycode(event, options.length, activeIndex);\n\n if (nextIndex !== undefined) {\n if (nextIndex === activeIndex) {\n return activeIndex;\n } else if (options.item(nextIndex) && isSkippableItem(options.item(nextIndex))) {\n // check in the other direction if the first or last item is disabled,\n // but prevent infinite loops if all elements are disabled by disabling recursion\n if (recurse) {\n if (nextIndex === 0) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowDown' }) as any,\n options,\n nextIndex,\n false\n );\n } else if (nextIndex === options.length - 1) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowUp' }) as any,\n options,\n nextIndex,\n false\n );\n }\n }\n\n return getNextEnabledItem(event, options, nextIndex, recurse);\n }\n }\n\n return nextIndex;\n};\n\nconst isSkippableItem = (element: Element) => {\n return (\n element.getAttribute('role') === 'presentation' ||\n !!element.hasAttribute('disabled') ||\n !!element.getAttribute('aria-disabled') ||\n !!element.getAttribute('aria-hidden')\n );\n};\n"],"names":["getOptionsFromCollection","collection","selector","querySelectorAll","Root","React","forwardRef","CollectionRoot","props","ref","querySelector","tabIndex","otherProps","internalRef","useMergedRef","activeIndex","setActiveIndex","useState","lastLengthRef","useRef","setActiveOption","index","option","_collection$querySele","removeAttribute","setAttribute","scrollIntoView","block","setActiveIndexByElement","useCallback","current","matches","options","nextActiveIndex","Array","from","indexOf","useEffect","length","selected","firstSelected","item","selectedIndex","children","handleClick","event","target","currentTarget","handleKeyDown","onKeyDown","isDefaultPrevented","isAriaDirectionKey","preventDefault","stopPropagation","getNextEnabledItem","undefined","_options$item","dispatchEvent","createCustomKeyboardEvent","onClick","getNextIndexFromKeycode","key","recurse","nextIndex","isSkippableItem","KeyboardEvent","type","element","getAttribute","hasAttribute"],"mappings":";;;;;AAiBA,MAAMA,wBAAwB,GAAGA,CAACC,UAA0B,EAAEC,QAAgB,KAC1ED,UAAU,CAACE,gBAAgB,CAACD,QAAQ,CAAC;AAEzC;AACA;AACA;MACaE,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAiC,SAASC,cAAcA,CAACC,KAAK,EAAEC,GAAG;EACnG,MAAM;IAAEC,aAAa;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAC5D,MAAMK,WAAW,GAAGC,YAAY,CAAgBL,GAAG,CAAC;EACpD,MAAM,CAACM,WAAW,EAAEC,cAAc,CAAC,GAAGX,cAAK,CAACY,QAAQ,EAAsB;EAC1E,MAAMC,aAAa,GAAGb,cAAK,CAACc,MAAM,CAAC,CAAC,CAAC;EAErC,MAAMC,eAAe,GAAGA,CAACC,KAAa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B,IAAIW,aAAa,CAACpB,KAAK,CAACqB,IAAI,EAAE;YAAE,GAAIrB,KAAa;YAAEgB,GAAG,EAAE;WAAW,CAAQ,EAC3E7B,OAAO,EACP+B,SAAS,EACT,KAAK,CACR;;;MAIT,OAAOT,kBAAkB,CAACT,KAAK,EAAEb,OAAO,EAAE+B,SAAS,EAAED,OAAO,CAAC;;;EAIrE,OAAOC,SAAS;AACpB;AAEA,MAAMC,eAAe,GAAIG,OAAgB;EACrC,OACIA,OAAO,CAACC,YAAY,CAAC,MAAM,CAAC,KAAK,cAAc,IAC/C,CAAC,CAACD,OAAO,CAACE,YAAY,CAAC,UAAU,CAAC,IAClC,CAAC,CAACF,OAAO,CAACC,YAAY,CAAC,eAAe,CAAC,IACvC,CAAC,CAACD,OAAO,CAACC,YAAY,CAAC,aAAa,CAAC;AAE7C,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Root.js","sources":["../../../../../../../../src/primitives/Listbox2/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useId } from '../../../hooks/useId';\nimport * as CollectionPrimitive from '../../Collection/Collection';\nimport { Listbox2Value } from '../types';\nimport { Listbox2Context } from './Context';\n\nexport type Listbox2Props = React.HTMLAttributes<HTMLDivElement> & {\n customSelector?: string;\n disabled?: boolean;\n multiple?: boolean;\n readOnly?: boolean;\n setValue: (value: Listbox2Value) => void;\n value?: Listbox2Value;\n};\n\nconst DEFAULT_SELECTOR = '[role=\"option\"]';\n\nexport const Root = React.forwardRef<CollectionPrimitive.CollectionRef, Listbox2Props>(function Listbox2(props, ref) {\n const {\n children,\n customSelector,\n disabled = false,\n id: nativeId,\n multiple,\n readOnly = false,\n setValue,\n title,\n value,\n ...otherProps\n } = props;\n // The id name cannot start with a number, otherwise unit tests will fail when trying to querry element with such id.\n // That's why adding prefix.\n const id = 'listbox2-' + useId(nativeId);\n\n const context = React.useMemo(\n () => ({\n disabled,\n readOnly,\n setValue,\n value,\n }),\n [disabled, readOnly, value]\n );\n\n return (\n <Listbox2Context.Provider value={context}>\n <div data-taco=\"listbox2\">\n <CollectionPrimitive.Root\n {...otherProps}\n aria-multiselectable={multiple ? true : undefined}\n id={id}\n querySelector={customSelector ? `${DEFAULT_SELECTOR}, ${customSelector}` : DEFAULT_SELECTOR}\n ref={ref}\n role=\"listbox\">\n {children}\n </CollectionPrimitive.Root>\n </div>\n </Listbox2Context.Provider>\n );\n});\n\nexport const createListboxValueSetter =\n (multiple: boolean, setValue: React.Dispatch<React.SetStateAction<Listbox2Value | undefined>>) =>\n (nextValue: Listbox2Value) => {\n setValue(value => {\n if (Array.isArray(nextValue)) {\n return nextValue;\n }\n\n if (multiple) {\n if (value === undefined) {\n return [nextValue];\n } else if (Array.isArray(value)) {\n if (value.includes(nextValue)) {\n return value.filter(v => v !== nextValue);\n }\n\n return [...value, nextValue];\n } else if (value === nextValue) {\n return [];\n }\n\n return [value, nextValue];\n }\n\n return nextValue;\n });\n };\n"],"names":["DEFAULT_SELECTOR","Root","React","forwardRef","Listbox2","props","ref","children","customSelector","disabled","id","nativeId","multiple","readOnly","setValue","title","value","otherProps","useId","context","useMemo","Listbox2Context","Provider","CollectionPrimitive","undefined","querySelector","role","createListboxValueSetter","nextValue","Array","isArray","includes","filter","v"],"mappings":";;;;;;AAeA,MAAMA,gBAAgB,GAAG,iBAAiB;MAE7BC,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAmD,SAASC,QAAQA,CAACC,KAAK,EAAEC,GAAG;EAC/G,MAAM;IACFC,QAAQ;IACRC,cAAc;IACdC,QAAQ,GAAG,KAAK;IAChBC,EAAE,EAAEC,QAAQ;IACZC,QAAQ;IACRC,QAAQ,GAAG,KAAK;IAChBC,QAAQ;IACRC,KAAK;IACLC,KAAK;IACL,GAAGC;GACN,GAAGZ,KAAK;;;EAGT,MAAMK,EAAE,GAAG,WAAW,GAAGQ,KAAK,CAACP,QAAQ,CAAC;EAExC,MAAMQ,OAAO,GAAGjB,cAAK,CAACkB,OAAO,CACzB,OAAO;IACHX,QAAQ;IACRI,QAAQ;IACRC,QAAQ;IACRE;GACH,CAAC,EACF,CAACP,QAAQ,EAAEI,QAAQ,EAAEG,KAAK,CAAC,CAC9B;EAED,oBACId,6BAACmB,eAAe,CAACC,QAAQ;IAACN,KAAK,EAAEG;kBAC7BjB;iBAAe;kBACXA,6BAACqB,MAAwB,oBACjBN,UAAU;4BACQL,QAAQ,GAAG,IAAI,GAAGY,SAAS;IACjDd,EAAE,EAAEA,EAAE;IACNe,aAAa,EAAEjB,cAAc,MAAMR,qBAAqBQ,gBAAgB,GAAGR,gBAAgB;IAC3FM,GAAG,EAAEA,GAAG;IACRoB,IAAI,EAAC;MACJnB,QAAQ,CACc,CACzB,CACiB;AAEnC,CAAC;MAEYoB,wBAAwB,GACjCA,CAACf,QAAiB,EAAEE,QAAyE,KAC5Fc,SAAwB;EACrBd,QAAQ,CAACE,KAAK;IACV,IAAIa,KAAK,CAACC,OAAO,CAACF,SAAS,CAAC,EAAE;MAC1B,OAAOA,SAAS;;IAGpB,IAAIhB,QAAQ,EAAE;MACV,IAAII,KAAK,KAAKQ,SAAS,EAAE;QACrB,OAAO,CAACI,SAAS,CAAC;OACrB,MAAM,IAAIC,KAAK,CAACC,OAAO,CAACd,KAAK,CAAC,EAAE;QAC7B,IAAIA,KAAK,CAACe,QAAQ,CAACH,SAAS,CAAC,EAAE;UAC3B,OAAOZ,KAAK,CAACgB,MAAM,CAACC,CAAC,IAAIA,CAAC,KAAKL,SAAS,CAAC;;QAG7C,OAAO,CAAC,GAAGZ,KAAK,EAAEY,SAAS,CAAC;OAC/B,MAAM,IAAIZ,KAAK,KAAKY,SAAS,EAAE;QAC5B,OAAO,EAAE;;MAGb,OAAO,CAACZ,KAAK,EAAEY,SAAS,CAAC;;IAG7B,OAAOA,SAAS;GACnB,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"Root.js","sources":["../../../../../../../../src/primitives/Listbox2/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useId } from '../../../hooks/useId';\nimport * as CollectionPrimitive from '../../Collection/Collection';\nimport { Listbox2Value } from '../types';\nimport { Listbox2Context } from './Context';\n\nexport type Listbox2Props = React.HTMLAttributes<HTMLDivElement> & {\n customSelector?: string;\n disabled?: boolean;\n multiple?: boolean;\n readOnly?: boolean;\n setValue: (value: Listbox2Value) => void;\n value?: Listbox2Value;\n};\n\nconst DEFAULT_SELECTOR = '[role=\"option\"]';\n\nexport const Root = React.forwardRef<CollectionPrimitive.CollectionRef, Listbox2Props>(function Listbox2(props, ref) {\n const {\n children,\n customSelector,\n disabled = false,\n id: nativeId,\n multiple,\n readOnly = false,\n setValue,\n title,\n value,\n ...otherProps\n } = props;\n // The id name cannot start with a number, otherwise unit tests will fail when trying to querry element with such id.\n // That's why adding prefix.\n const id = 'listbox2-' + useId(nativeId);\n\n const context = React.useMemo(\n () => ({\n disabled,\n readOnly,\n setValue,\n value,\n }),\n [disabled, readOnly, value]\n );\n\n return (\n <Listbox2Context.Provider value={context}>\n <div data-taco=\"listbox2\">\n <CollectionPrimitive.Root\n {...otherProps}\n aria-multiselectable={multiple ? true : undefined}\n id={id}\n querySelector={customSelector ? `${DEFAULT_SELECTOR}, ${customSelector}` : DEFAULT_SELECTOR}\n ref={ref}\n role=\"listbox\">\n {children}\n </CollectionPrimitive.Root>\n </div>\n </Listbox2Context.Provider>\n );\n});\n\nexport const createListboxValueSetter =\n (multiple: boolean, setValue: React.Dispatch<React.SetStateAction<Listbox2Value | undefined>>) =>\n (nextValue: Listbox2Value) => {\n setValue(value => {\n if (Array.isArray(nextValue)) {\n return nextValue;\n }\n\n if (multiple) {\n if (value === undefined) {\n return [nextValue];\n } else if (Array.isArray(value)) {\n if (value.includes(nextValue)) {\n return value.filter(v => v !== nextValue);\n }\n\n return [...value, nextValue];\n } else if (value === nextValue) {\n return [];\n }\n\n return [value, nextValue];\n }\n\n return nextValue;\n });\n };\n"],"names":["DEFAULT_SELECTOR","Root","React","forwardRef","Listbox2","props","ref","children","customSelector","disabled","id","nativeId","multiple","readOnly","setValue","title","value","otherProps","useId","context","useMemo","Listbox2Context","Provider","CollectionPrimitive","undefined","querySelector","role","createListboxValueSetter","nextValue","Array","isArray","includes","filter","v"],"mappings":";;;;;;AAeA,MAAMA,gBAAgB,GAAG,iBAAiB;MAE7BC,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAmD,SAASC,QAAQA,CAACC,KAAK,EAAEC,GAAG;EAC/G,MAAM;IACFC,QAAQ;IACRC,cAAc;IACdC,QAAQ,GAAG,KAAK;IAChBC,EAAE,EAAEC,QAAQ;IACZC,QAAQ;IACRC,QAAQ,GAAG,KAAK;IAChBC,QAAQ;IACRC,KAAK;IACLC,KAAK;IACL,GAAGC;GACN,GAAGZ,KAAK;;;EAGT,MAAMK,EAAE,GAAG,WAAW,GAAGQ,KAAK,CAACP,QAAQ,CAAC;EAExC,MAAMQ,OAAO,GAAGjB,cAAK,CAACkB,OAAO,CACzB,OAAO;IACHX,QAAQ;IACRI,QAAQ;IACRC,QAAQ;IACRE;GACH,CAAC,EACF,CAACP,QAAQ,EAAEI,QAAQ,EAAEG,KAAK,CAAC,CAC9B;EAED,oBACId,6BAACmB,eAAe,CAACC,QAAQ;IAACN,KAAK,EAAEG;kBAC7BjB;iBAAe;kBACXA,6BAACqB,MAAwB,oBACjBN,UAAU;4BACQL,QAAQ,GAAG,IAAI,GAAGY,SAAS;IACjDd,EAAE,EAAEA,EAAE;IACNe,aAAa,EAAEjB,cAAc,GAAG,GAAGR,gBAAgB,KAAKQ,cAAc,EAAE,GAAGR,gBAAgB;IAC3FM,GAAG,EAAEA,GAAG;IACRoB,IAAI,EAAC;MACJnB,QAAQ,CACc,CACzB,CACiB;AAEnC,CAAC;MAEYoB,wBAAwB,GACjCA,CAACf,QAAiB,EAAEE,QAAyE,KAC5Fc,SAAwB;EACrBd,QAAQ,CAACE,KAAK;IACV,IAAIa,KAAK,CAACC,OAAO,CAACF,SAAS,CAAC,EAAE;MAC1B,OAAOA,SAAS;;IAGpB,IAAIhB,QAAQ,EAAE;MACV,IAAII,KAAK,KAAKQ,SAAS,EAAE;QACrB,OAAO,CAACI,SAAS,CAAC;OACrB,MAAM,IAAIC,KAAK,CAACC,OAAO,CAACd,KAAK,CAAC,EAAE;QAC7B,IAAIA,KAAK,CAACe,QAAQ,CAACH,SAAS,CAAC,EAAE;UAC3B,OAAOZ,KAAK,CAACgB,MAAM,CAACC,CAAC,IAAIA,CAAC,KAAKL,SAAS,CAAC;;QAG7C,OAAO,CAAC,GAAGZ,KAAK,EAAEY,SAAS,CAAC;OAC/B,MAAM,IAAIZ,KAAK,KAAKY,SAAS,EAAE;QAC5B,OAAO,EAAE;;MAGb,OAAO,CAACZ,KAAK,EAAEY,SAAS,CAAC;;IAG7B,OAAOA,SAAS;GACnB,CAAC;AACN;;;;"}
@@ -50,16 +50,16 @@ function TableGrid(props) {
50
50
  ref: table.ref,
51
51
  style: table.style,
52
52
  tabIndex: -1
53
- }), /*#__PURE__*/React__default.createElement("thead", null, table.instance.getHeaderGroups().map(headerGroup => ( /*#__PURE__*/React__default.createElement("tr", {
53
+ }), /*#__PURE__*/React__default.createElement("thead", null, table.instance.getHeaderGroups().map(headerGroup => (/*#__PURE__*/React__default.createElement("tr", {
54
54
  key: headerGroup.id
55
- }, headerGroup.headers.map(props => ( /*#__PURE__*/React__default.createElement(Header, {
55
+ }, headerGroup.headers.map(props => (/*#__PURE__*/React__default.createElement(Header, {
56
56
  key: props.id,
57
57
  header: props,
58
58
  scrollToIndex: table.renderer.scrollToIndex
59
- }))))))), filterReason ? ( /*#__PURE__*/React__default.createElement(EmptyStateBody, {
59
+ }))))))), filterReason ? (/*#__PURE__*/React__default.createElement(EmptyStateBody, {
60
60
  emptyState: props.table.props.emptyState,
61
61
  reason: filterReason
62
- })) : ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Body, {
62
+ })) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Body, {
63
63
  enableHorizontalArrowKeyNavigation: enableHorizontalArrowKeyNavigation,
64
64
  table: table.instance,
65
65
  tableElement: table.ref.current,
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","sources":["../../../../../../../../src/primitives/Table/Core/Table.tsx"],"sourcesContent":["import React from 'react';\nimport { FocusScope } from '@react-aria/focus';\nimport { Header } from './components/Header/Header';\nimport { Body } from './components/Body/Body';\nimport { Foot } from './components/Footer/Footer';\nimport { EmptyStateBody } from './components/Body/EmptyStateBody';\nimport { useTableReturnValue } from './useTable';\nimport { TableToolbar } from './components/Toolbar/Toolbar';\nimport './style.css';\nimport { TableEmptyStateReason } from '../types';\nimport { ROW_HEIGHT_ESTIMATES } from './util/rows';\n\ntype TableProps = {\n children: JSX.Element | Array<JSX.Element | null>;\n};\n\nexport function Table(props: TableProps) {\n return <>{props.children}</>;\n}\nTable.Toolbar = TableToolbar;\nTable.Grid = TableGrid;\n\nexport type TableGridProps<TType = unknown> = React.TableHTMLAttributes<HTMLTableElement> & {\n 'data-taco': string;\n enableHorizontalArrowKeyNavigation?: boolean;\n table: useTableReturnValue<TType>;\n};\n\nfunction getFilterReason<TType = unknown>(table: useTableReturnValue<TType>): TableEmptyStateReason | null {\n if (table.instance.getFilteredRowModel().rows.length === 0 && table.instance.getCoreRowModel().rows.length !== 0) {\n const state = table.instance.getState();\n\n if (table.meta.search.enableGlobalFilter && !!state.globalFilter) {\n return 'searching';\n }\n\n return 'filtering';\n }\n if (table.instance.getCoreRowModel().rows.length === 0) {\n return 'empty';\n }\n\n return null;\n}\n\nexport function TableGrid<TType = unknown>(props: TableGridProps<TType>) {\n const { enableHorizontalArrowKeyNavigation, table, ...attributes } = props;\n const handleFocus =\n table.meta.rowActive.rowActiveIndex === undefined\n ? (event: React.FocusEvent) => {\n table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);\n }\n : undefined;\n const filterReason = getFilterReason(table);\n\n return (\n <>\n <style>{table.stylesheet}</style>\n <FocusScope>\n <table\n {...attributes}\n id={table.id}\n data-table-font-size={table.meta.fontSize.size}\n data-table-grouped={!!table.state.grouping?.length}\n data-table-horizontally-scrolled={table.meta.columnFreezing.isHorizontallyScrolled ? true : undefined}\n data-table-status={table.meta.server.isEnabled ? (table.meta.server.isReady ? 'ready' : undefined) : 'ready'}\n data-table-pause-hover={table.meta.rowActive.isHoverStatePaused ? true : undefined}\n data-table-resizing={table.state.columnSizingInfo.isResizingColumn ? true : undefined}\n data-table-row-height={table.meta.rowHeight.height}\n onFocus={handleFocus}\n onScroll={table.meta.columnFreezing.handleScroll}\n ref={table.ref}\n style={table.style}\n tabIndex={-1}>\n <thead>\n {table.instance.getHeaderGroups().map(headerGroup => (\n <tr key={headerGroup.id}>\n {headerGroup.headers.map(props => (\n <Header key={props.id} header={props} scrollToIndex={table.renderer.scrollToIndex} />\n ))}\n </tr>\n ))}\n </thead>\n {filterReason ? (\n <EmptyStateBody emptyState={props.table.props.emptyState} reason={filterReason} />\n ) : (\n <>\n <Body\n enableHorizontalArrowKeyNavigation={enableHorizontalArrowKeyNavigation}\n table={table.instance}\n tableElement={table.ref.current}\n scrollToIndex={table.renderer.scrollToIndex}\n style={\n props.children\n ? {\n ...table.renderer.style,\n height:\n (table.renderer.style.height as number) +\n ROW_HEIGHT_ESTIMATES[table.meta.rowHeight.height],\n }\n : table.renderer.style\n }>\n {table.renderer.rows}\n {props.children}\n </Body>\n {table.meta.footer.isEnabled ? <Foot table={table.instance} /> : null}\n </>\n )}\n </table>\n </FocusScope>\n </>\n );\n}\n"],"names":["Table","props","React","children","Toolbar","TableToolbar","Grid","TableGrid","getFilterReason","table","instance","getFilteredRowModel","rows","length","getCoreRowModel","state","getState","meta","search","enableGlobalFilter","globalFilter","enableHorizontalArrowKeyNavigation","attributes","handleFocus","rowActive","rowActiveIndex","undefined","event","renderer","scrollToIndex","filterReason","stylesheet","FocusScope","id","fontSize","size","_table$state$grouping","grouping","columnFreezing","isHorizontallyScrolled","server","isEnabled","isReady","isHoverStatePaused","columnSizingInfo","isResizingColumn","rowHeight","height","onFocus","onScroll","handleScroll","ref","style","tabIndex","getHeaderGroups","map","headerGroup","key","headers","Header","header","EmptyStateBody","emptyState","reason","Body","tableElement","current","ROW_HEIGHT_ESTIMATES","footer","Foot"],"mappings":";;;;;;;;;SAgBgBA,KAAKA,CAACC,KAAiB;EACnC,oBAAOC,4DAAGD,KAAK,CAACE,QAAQ,CAAI;AAChC;AACAH,KAAK,CAACI,OAAO,GAAGC,YAAY;AAC5BL,KAAK,CAACM,IAAI,GAAGC,SAAS;AAQtB,SAASC,eAAeA,CAAkBC,KAAiC;EACvE,IAAIA,KAAK,CAACC,QAAQ,CAACC,mBAAmB,EAAE,CAACC,IAAI,CAACC,MAAM,KAAK,CAAC,IAAIJ,KAAK,CAACC,QAAQ,CAACI,eAAe,EAAE,CAACF,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;IAC9G,MAAME,KAAK,GAAGN,KAAK,CAACC,QAAQ,CAACM,QAAQ,EAAE;IAEvC,IAAIP,KAAK,CAACQ,IAAI,CAACC,MAAM,CAACC,kBAAkB,IAAI,CAAC,CAACJ,KAAK,CAACK,YAAY,EAAE;MAC9D,OAAO,WAAW;;IAGtB,OAAO,WAAW;;EAEtB,IAAIX,KAAK,CAACC,QAAQ,CAACI,eAAe,EAAE,CAACF,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;IACpD,OAAO,OAAO;;EAGlB,OAAO,IAAI;AACf;SAEgBN,SAASA,CAAkBN,KAA4B;;EACnE,MAAM;IAAEoB,kCAAkC;IAAEZ,KAAK;IAAE,GAAGa;GAAY,GAAGrB,KAAK;EAC1E,MAAMsB,WAAW,GACbd,KAAK,CAACQ,IAAI,CAACO,SAAS,CAACC,cAAc,KAAKC,SAAS,GAC1CC,KAAuB;IACpBlB,KAAK,CAACQ,IAAI,CAACO,SAAS,CAACD,WAAW,CAACI,KAAK,EAAElB,KAAK,CAACQ,IAAI,CAACJ,MAAM,E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O,CAACH,GAAG,CAACtD,KAAK,mBAC1BC,6BAACyD,MAAM;IAACF,GAAG,EAAExD,KAAK,CAACgC,EAAE;IAAE2B,MAAM,EAAE3D,KAAK;IAAE4B,aAAa,EAAEpB,KAAK,CAACmB,QAAQ,CAACC;IAAiB,CACxF,CAAC,CACD,CACR,CAAC,CACE,EACPC,YAAY,kBACT5B,6BAAC2D,cAAc;IAACC,UAAU,EAAE7D,KAAK,CAACQ,KAAK,CAACR,KAAK,CAAC6D,UAAU;IAAEC,MAAM,EAAEjC;IAAgB,mBAElF5B,yEACIA,6BAAC8D,IAAI;IACD3C,kCAAkC,EAAEA,kCAAkC;IACtEZ,KAAK,EAAEA,KAAK,CAACC,QAAQ;IACrBuD,YAAY,EAAExD,KAAK,CAAC0C,GAAG,CAACe,OAAO;IAC/BrC,aAAa,EAAEpB,KAAK,CAACmB,QAAQ,CAACC,aAAa;IAC3CuB,KAAK,EACDnD,KAAK,CAACE,QAAQ,GACR;MACI,GAAGM,KAAK,CAACmB,QAAQ,CAACwB,KAAK;MACvBL,MAAM,EACDtC,KAAK,CAACmB,QAAQ,CAACwB,KAAK,CAACL,MAAiB,GACvCoB,oBAAoB,CAAC1D,KAAK,CAACQ,IAAI,CAAC6B,SAAS,CAACC,MAAM;KACvD,GACDtC,KAAK,CAACmB,QAAQ,CAACwB;KAExB3C,KAAK,CAACmB,QAAQ,CAAChB,IAAI,EACnBX,KAAK,CAACE,QAAQ,CACZ,EACNM,KAAK,CAACQ,IAAI,CAACmD,MAAM,CAAC3B,SAAS,gBAAGvC,6BAACmE,IAAI;IAAC5D,KAAK,EAAEA,KAAK,CAACC;IAAY,GAAG,IAAI,CACtE,CACN,CACG,CACC,CACd;AAEX;;;;"}
1
+ {"version":3,"file":"Table.js","sources":["../../../../../../../../src/primitives/Table/Core/Table.tsx"],"sourcesContent":["import React from 'react';\nimport { FocusScope } from '@react-aria/focus';\nimport { Header } from './components/Header/Header';\nimport { Body } from './components/Body/Body';\nimport { Foot } from './components/Footer/Footer';\nimport { EmptyStateBody } from './components/Body/EmptyStateBody';\nimport { useTableReturnValue } from './useTable';\nimport { TableToolbar } from './components/Toolbar/Toolbar';\nimport './style.css';\nimport { TableEmptyStateReason } from '../types';\nimport { ROW_HEIGHT_ESTIMATES } from './util/rows';\n\ntype TableProps = {\n children: JSX.Element | Array<JSX.Element | null>;\n};\n\nexport function Table(props: TableProps) {\n return <>{props.children}</>;\n}\nTable.Toolbar = TableToolbar;\nTable.Grid = TableGrid;\n\nexport type TableGridProps<TType = unknown> = React.TableHTMLAttributes<HTMLTableElement> & {\n 'data-taco': string;\n enableHorizontalArrowKeyNavigation?: boolean;\n table: useTableReturnValue<TType>;\n};\n\nfunction getFilterReason<TType = unknown>(table: useTableReturnValue<TType>): TableEmptyStateReason | null {\n if (table.instance.getFilteredRowModel().rows.length === 0 && table.instance.getCoreRowModel().rows.length !== 0) {\n const state = table.instance.getState();\n\n if (table.meta.search.enableGlobalFilter && !!state.globalFilter) {\n return 'searching';\n }\n\n return 'filtering';\n }\n if (table.instance.getCoreRowModel().rows.length === 0) {\n return 'empty';\n }\n\n return null;\n}\n\nexport function TableGrid<TType = unknown>(props: TableGridProps<TType>) {\n const { enableHorizontalArrowKeyNavigation, table, ...attributes } = props;\n const handleFocus =\n table.meta.rowActive.rowActiveIndex === undefined\n ? (event: React.FocusEvent) => {\n table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);\n }\n : undefined;\n const filterReason = getFilterReason(table);\n\n return (\n <>\n <style>{table.stylesheet}</style>\n <FocusScope>\n <table\n {...attributes}\n id={table.id}\n data-table-font-size={table.meta.fontSize.size}\n data-table-grouped={!!table.state.grouping?.length}\n data-table-horizontally-scrolled={table.meta.columnFreezing.isHorizontallyScrolled ? true : undefined}\n data-table-status={table.meta.server.isEnabled ? (table.meta.server.isReady ? 'ready' : undefined) : 'ready'}\n data-table-pause-hover={table.meta.rowActive.isHoverStatePaused ? true : undefined}\n data-table-resizing={table.state.columnSizingInfo.isResizingColumn ? true : undefined}\n data-table-row-height={table.meta.rowHeight.height}\n onFocus={handleFocus}\n onScroll={table.meta.columnFreezing.handleScroll}\n ref={table.ref}\n style={table.style}\n tabIndex={-1}>\n <thead>\n {table.instance.getHeaderGroups().map(headerGroup => (\n <tr key={headerGroup.id}>\n {headerGroup.headers.map(props => (\n <Header key={props.id} header={props} scrollToIndex={table.renderer.scrollToIndex} />\n ))}\n </tr>\n ))}\n </thead>\n {filterReason ? (\n <EmptyStateBody emptyState={props.table.props.emptyState} reason={filterReason} />\n ) : (\n <>\n <Body\n enableHorizontalArrowKeyNavigation={enableHorizontalArrowKeyNavigation}\n table={table.instance}\n tableElement={table.ref.current}\n scrollToIndex={table.renderer.scrollToIndex}\n style={\n props.children\n ? {\n ...table.renderer.style,\n height:\n (table.renderer.style.height as number) +\n ROW_HEIGHT_ESTIMATES[table.meta.rowHeight.height],\n }\n : table.renderer.style\n }>\n {table.renderer.rows}\n {props.children}\n </Body>\n {table.meta.footer.isEnabled ? <Foot table={table.instance} /> : null}\n </>\n )}\n </table>\n </FocusScope>\n </>\n );\n}\n"],"names":["Table","props","React","children","Toolbar","TableToolbar","Grid","TableGrid","getFilterReason","table","instance","getFilteredRowModel","rows","length","getCoreRowModel","state","getState","meta","search","enableGlobalFilter","globalFilter","enableHorizontalArrowKeyNavigation","attributes","handleFocus","rowActive","rowActiveIndex","undefined","event","renderer","scrollToIndex","filterReason","stylesheet","FocusScope","id","fontSize","size","_table$state$grouping","grouping","columnFreezing","isHorizontallyScrolled","server","isEnabled","isReady","isHoverStatePaused","columnSizingInfo","isResizingColumn","rowHeight","height","onFocus","onScroll","handleScroll","ref","style","tabIndex","getHeaderGroups","map","headerGroup","key","headers","Header","header","EmptyStateBody","emptyState","reason","Body","tableElement","current","ROW_HEIGHT_ESTIMATES","footer","Foot"],"mappings":";;;;;;;;;SAgBgBA,KAAKA,CAACC,KAAiB;EACnC,oBAAOC,4DAAGD,KAAK,CAACE,QAAQ,CAAI;A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KAAK,CAACR,KAAK,CAAC6D,UAAU;IAAEC,MAAM,EAAEjC;IAAgB,kBAElF5B,yEACIA,6BAAC8D,IAAI;IACD3C,kCAAkC,EAAEA,kCAAkC;IACtEZ,KAAK,EAAEA,KAAK,CAACC,QAAQ;IACrBuD,YAAY,EAAExD,KAAK,CAAC0C,GAAG,CAACe,OAAO;IAC/BrC,aAAa,EAAEpB,KAAK,CAACmB,QAAQ,CAACC,aAAa;IAC3CuB,KAAK,EACDnD,KAAK,CAACE,QAAQ,GACR;MACI,GAAGM,KAAK,CAACmB,QAAQ,CAACwB,KAAK;MACvBL,MAAM,EACDtC,KAAK,CAACmB,QAAQ,CAACwB,KAAK,CAACL,MAAiB,GACvCoB,oBAAoB,CAAC1D,KAAK,CAACQ,IAAI,CAAC6B,SAAS,CAACC,MAAM;KACvD,GACDtC,KAAK,CAACmB,QAAQ,CAACwB;KAExB3C,KAAK,CAACmB,QAAQ,CAAChB,IAAI,EACnBX,KAAK,CAACE,QAAQ,CACZ,EACNM,KAAK,CAACQ,IAAI,CAACmD,MAAM,CAAC3B,SAAS,gBAAGvC,6BAACmE,IAAI;IAAC5D,KAAK,EAAEA,KAAK,CAACC;IAAY,GAAG,IAAI,CACtE,CACN,CACG,CACC,CACd;AAEX;;;;"}
@@ -53,7 +53,7 @@ const MemoedGroupedCell = /*#__PURE__*/React__default.memo(function MemoedGroupe
53
53
  }
54
54
  }), /*#__PURE__*/React__default.createElement("span", {
55
55
  className: "grow"
56
- }, children), rowActions !== null && rowActions !== void 0 && rowActions.length && canShowActions ? ( /*#__PURE__*/React__default.createElement(Actions, {
56
+ }, children), rowActions !== null && rowActions !== void 0 && rowActions.length && canShowActions ? (/*#__PURE__*/React__default.createElement(Actions, {
57
57
  actions: rowActions,
58
58
  actionsLength: 4,
59
59
  data: subRows,
@@ -1 +1 @@
1
- {"version":3,"file":"GroupedCell.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { getCellAttributes } from '../util';\nimport { Actions as RowGroupActions } from '../../Internal/Actions';\nimport { isInternalColumn } from '../../../../../useTableManager/util/columns';\nimport { RowContext } from '../../../Row/RowContext';\nimport { TableFontSize, TableRowActionGroupRenderer } from '../../../../../types';\nimport { TableCellRendererProps } from '../../../../types';\n\nexport function GroupedCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, index, isHighlighted } = props;\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const attributes = getCellAttributes(cell, index, isHighlighted);\n\n const { isHovered, rowIndex } = React.useContext(RowContext);\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n const canShowActions = isActiveRow || (isHovered && !tableMeta.rowActive.isHoverStatePaused);\n\n const colSpan = cell.row.getVisibleCells().filter(c => !isInternalColumn(c.column.id)).length - 1;\n const content = columnMeta.renderer?.(cell.getValue<TType>(), cell.row.original) ?? cell.getValue() ?? null;\n const subRows = cell.getContext().row.subRows.map(row => row.original);\n\n return (\n <MemoedGroupedCell<TType>\n {...attributes}\n canShowActions={canShowActions}\n cellRef={cellRef}\n colSpan={colSpan}\n fontSize={tableMeta.fontSize.size}\n rowActions={tableMeta.rowGroups.rowActionsForGroup}\n rowId={cell.row.id}\n subRows={subRows}>\n {content}\n </MemoedGroupedCell>\n );\n}\n\ntype MemoedGroupedCellProps<TType = unknown> = React.TdHTMLAttributes<HTMLTableCellElement> & {\n canShowActions: boolean;\n cellRef: React.RefObject<HTMLTableCellElement>;\n colSpan: number;\n fontSize: TableFontSize;\n rowActions?: TableRowActionGroupRenderer<TType>[];\n rowId: string;\n subRows: TType[];\n};\n\nconst MemoedGroupedCell = React.memo(function MemoedGroupedCell<TType = unknown>(props: MemoedGroupedCellProps<TType>) {\n const { canShowActions, cellRef, children, colSpan, fontSize, rowActions, rowId, subRows, ...attributes } = props;\n\n return (\n <td {...attributes} ref={cellRef} style={{ gridColumn: `span ${colSpan} / span ${colSpan}` }}>\n <span className=\"grow\">{children}</span>\n {rowActions?.length && canShowActions ? (\n <RowGroupActions\n actions={rowActions}\n actionsLength={4}\n data={subRows}\n fontSize={fontSize}\n isActiveRow\n rowId={rowId}\n />\n ) : null}\n </td>\n );\n}) as <TType = unknown>(props: MemoedGroupedCellProps<TType>) => JSX.Element;\n"],"names":["GroupedCell","props","cell","cellRef","index","isHighlighted","tableMeta","getContext","table","options","meta","columnMeta","column","columnDef","attributes","getCellAttributes","isHovered","rowIndex","React","useContext","RowContext","isActiveRow","rowActive","rowActiveIndex","canShowActions","isHoverStatePaused","colSpan","row","getVisibleCells","filter","c","isInternalColumn","id","length","content","_ref","_columnMeta$renderer","_columnMeta$renderer2","renderer","call","getValue","original","subRows","map","MemoedGroupedCell","fontSize","size","rowActions","rowGroups","rowActionsForGroup","rowId","memo","children","ref","style","gridColumn","className","RowGroupActions","actions","actionsLength","data"],"mappings":";;;;;;SASgBA,WAAWA,CAAkBC,KAAoC;;EAC7E,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,KAAK;IAAEC;GAAe,GAAGJ,KAAK;EACrD,MAAMK,SAAS,GAAGJ,IAAI,CAACK,UAAU,EAAE,CAACC,KAAK,CAACC,OAAO,CAACC,IAA6B;EAC/E,MAAMC,UAAU,GAAGT,IAAI,CAACU,MAAM,CAACC,SAAS,CAACH,IAA4C;EACrF,MAAMI,UAAU,GAAGC,iBAAiB,CAACb,IAAI,EAAEE,KAAK,EAAEC,aAAa,CAAC;EAEhE,MAAM;IAAEW,SAAS;IAAEC;GAAU,GAAGC,cAAK,CAACC,UAAU,CAACC,UAAU,CAAC;EAC5D,MAAMC,WAAW,GAAGf,SAAS,CAACgB,SAAS,CAACC,cAAc,KAAKN,QAAQ;EACnE,MAAMO,cAAc,GAAGH,WAAW,I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EE,UAAU;IAAEG,KAAK;IAAER,OAAO;IAAE,GAAG5B;GAAY,GAAGb,KAAK;EAEjH,oBACIiB,qDAAQJ,UAAU;IAAEuC,GAAG,EAAElD,OAAO;IAAEmD,KAAK,EAAE;MAAEC,UAAU,UAAU7B,kBAAkBA;;mBAC7ER;IAAMsC,SAAS,EAAC;KAAQJ,QAAQ,CAAQ,EACvCL,UAAU,aAAVA,UAAU,eAAVA,UAAU,CAAEd,MAAM,IAAIT,cAAc,kBACjCN,6BAACuC,OAAe;IACZC,OAAO,EAAEX,UAAU;IACnBY,aAAa,EAAE,CAAC;IAChBC,IAAI,EAAElB,OAAO;IACbG,QAAQ,EAAEA,QAAQ;IAClBxB,WAAW;IACX6B,KAAK,EAAEA;IACT,IACF,IAAI,CACP;AAEb,CAAC,CAA2E;;;;"}
1
+ {"version":3,"file":"GroupedCell.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { getCellAttributes } from '../util';\nimport { Actions as RowGroupActions } from '../../Internal/Actions';\nimport { isInternalColumn } from '../../../../../useTableManager/util/columns';\nimport { RowContext } from '../../../Row/RowContext';\nimport { TableFontSize, TableRowActionGroupRenderer } from '../../../../../types';\nimport { TableCellRendererProps } from '../../../../types';\n\nexport function GroupedCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, index, isHighlighted } = props;\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const attributes = getCellAttributes(cell, index, isHighlighted);\n\n const { isHovered, rowIndex } = React.useContext(RowContext);\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n const canShowActions = isActiveRow || (isHovered && !tableMeta.rowActive.isHoverStatePaused);\n\n const colSpan = cell.row.getVisibleCells().filter(c => !isInternalColumn(c.column.id)).length - 1;\n const content = columnMeta.renderer?.(cell.getValue<TType>(), cell.row.original) ?? cell.getValue() ?? null;\n const subRows = cell.getContext().row.subRows.map(row => row.original);\n\n return (\n <MemoedGroupedCell<TType>\n {...attributes}\n canShowActions={canShowActions}\n cellRef={cellRef}\n colSpan={colSpan}\n fontSize={tableMeta.fontSize.size}\n rowActions={tableMeta.rowGroups.rowActionsForGroup}\n rowId={cell.row.id}\n subRows={subRows}>\n {content}\n </MemoedGroupedCell>\n );\n}\n\ntype MemoedGroupedCellProps<TType = unknown> = React.TdHTMLAttributes<HTMLTableCellElement> & {\n canShowActions: boolean;\n cellRef: React.RefObject<HTMLTableCellElement>;\n colSpan: number;\n fontSize: TableFontSize;\n rowActions?: TableRowActionGroupRenderer<TType>[];\n rowId: string;\n subRows: TType[];\n};\n\nconst MemoedGroupedCell = React.memo(function MemoedGroupedCell<TType = unknown>(props: MemoedGroupedCellProps<TType>) {\n const { canShowActions, cellRef, children, colSpan, fontSize, rowActions, rowId, subRows, ...attributes } = props;\n\n return (\n <td {...attributes} ref={cellRef} style={{ gridColumn: `span ${colSpan} / span ${colSpan}` }}>\n <span className=\"grow\">{children}</span>\n {rowActions?.length && canShowActions ? (\n <RowGroupActions\n actions={rowActions}\n actionsLength={4}\n data={subRows}\n fontSize={fontSize}\n isActiveRow\n rowId={rowId}\n />\n ) : null}\n </td>\n );\n}) as <TType = unknown>(props: MemoedGroupedCellProps<TType>) => JSX.Element;\n"],"names":["GroupedCell","props","cell","cellRef","index","isHighlighted","tableMeta","getContext","table","options","meta","columnMeta","column","columnDef","attributes","getCellAttributes","isHovered","rowIndex","React","useContext","RowContext","isActiveRow","rowActive","rowActiveIndex","canShowActions","isHoverStatePaused","colSpan","row","getVisibleCells","filter","c","isInternalColumn","id","length","content","_ref","_columnMeta$renderer","_columnMeta$renderer2","renderer","call","getValue","original","subRows","map","MemoedGroupedCell","fontSize","size","rowActions","rowGroups","rowActionsForGroup","rowId","memo","children","ref","style","gridColumn","className","RowGroupActions","actions","actionsLength","data"],"mappings":";;;;;;SASgBA,WAAWA,CAAkBC,KAAoC;;EAC7E,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,KAAK;IAAEC;GAAe,GAAGJ,KAAK;EACrD,MAAMK,SAAS,GAAGJ,IAAI,CAACK,UAAU,EAAE,CAACC,KAAK,CAACC,OAAO,CAACC,IAA6B;EAC/E,MAAMC,UAAU,GAAGT,IAAI,CAACU,MAAM,CAACC,SAAS,CAACH,IAA4C;EACrF,MAAMI,UAAU,GAAGC,iBAAiB,CAACb,IAAI,EAAEE,KAAK,EAAEC,aAAa,CAAC;EAEhE,MAAM;IAAEW,SAAS;IAAEC;GAAU,GAAGC,cAAK,CAACC,UAAU,CAACC,UAAU,CAAC;EAC5D,MAAMC,WAAW,GAAGf,SAAS,CAACgB,SAAS,CAACC,cAAc,KAAKN,QAAQ;EACnE,MAAMO,cAAc,GAAGH,WAAW,IAAKL,SAAS,IAAI,CAACV,SAAS,CAACgB,SAAS,CAACG,kBAAmB;EAE5F,MAAMC,OAAO,GAAGxB,IAAI,CAACyB,GAAG,CAACC,eAAe,EAAE,CAACC,MAAM,CAACC,CAAC,IAAI,CAACC,gBAAgB,CAACD,CAAC,CAAClB,MAAM,CAACoB,EAAE,CAAC,CAAC,CAACC,MAAM,GAAG,CAAC;EACjG,MAAMC,OAAO,IAAAC,IAAA,IAAAC,oBAAA,IAAAC,qBAAA,GAAG1B,UAAU,CAAC2B,QAAQ,cAAAD,qBAAA,uBAAnBA,qBAAA,CAAAE,IAAA,CAAA5B,UAAU,EAAYT,IAAI,CAACsC,QAAQ,EAAS,EAAEtC,IAAI,CAACyB,GAAG,CAACc,QAAQ,CAAC,cAAAL,oBAAA,cAAAA,oBAAA,GAAIlC,IAAI,CAACsC,QAAQ,EAAE,cAAAL,IAAA,cAAAA,IAAA,GAAI,IAAI;EAC3G,MAAMO,OAAO,GAAGxC,IAAI,CAACK,UAAU,EAA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: button.props.shortcut ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, tooltip, /*#__PURE__*/React__default.createElement(Shortcut, {
39
+ tooltip: button.props.shortcut ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, tooltip, /*#__PURE__*/React__default.createElement(Shortcut, {
40
40
  className: "ml-2",
41
41
  keys: button.props.shortcut
42
42
  }))) : tooltip
43
43
  });
44
- }), actionsInMenu.length ? ( /*#__PURE__*/React__default.createElement(IconButton, {
44
+ }), actionsInMenu.length ? (/*#__PURE__*/React__default.createElement(IconButton, {
45
45
  appearance: "transparent",
46
46
  "aria-label": texts.table.columns.actions.tooltip,
47
47
  icon: "more",
48
48
  tabIndex: isActiveRow ? 0 : -1,
49
- menu: menuProps => ( /*#__PURE__*/React__default.createElement(Menu, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu.Content, null, actionsInMenu.map((action, i) => ( /*#__PURE__*/React__default.createElement(Menu.Item, Object.assign({
49
+ menu: menuProps => (/*#__PURE__*/React__default.createElement(Menu, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu.Content, null, actionsInMenu.map((action, i) => (/*#__PURE__*/React__default.createElement(Menu.Item, Object.assign({
50
50
  key: i
51
51
  }, action.props, {
52
52
  shortcut: action.props.shortcut
@@ -1 +1 @@
1
- {"version":3,"file":"Actions.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Internal/Actions.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext as ReactTableCellContext, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { useLocalization } from '../../../../../../components/Provider/Localization';\nimport { IconButton } from '../../../../../../components/IconButton/IconButton';\nimport { Menu } from '../../../../../../components/Menu/Menu';\nimport { Shortcut } from '../../../../../../components/Shortcut/Shortcut';\nimport { TableFontSize, TableRowActionRenderer } from '../../../../types';\nimport { FontSizes } from '../../../../../../types';\nimport { RowContext } from '../../Row/RowContext';\nimport { useTableManagerInternalColumn } from '../../../../useTableManager/types';\n\nexport type ActionsProps<TType = unknown> = {\n actions: TableRowActionRenderer<TType>[];\n actionsLength: number;\n data: any;\n fontSize: TableFontSize;\n isActiveRow: boolean;\n rowId: string;\n};\nexport function Actions<TType = unknown>(props: ActionsProps<TType>) {\n const { actions, actionsLength, data, fontSize, isActiveRow, rowId } = props;\n const { texts } = useLocalization();\n const visibleActions = actions.map(action => action(data, rowId)).filter(action => !!action) as JSX.Element[];\n\n const actionsOnRow = visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);\n const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);\n\n const className = cn(\n '-mb-2 flex justify-end text-right bg-[inherit] shadow-[-6px_0px_6px_var(--table-row-actions-shadow)] print:hidden',\n {\n // Adjust negative margin on row actions cell to ensure that the cell aligns vertically.\n '-mt-2': fontSize === FontSizes.small,\n '-mt-1.5': fontSize !== FontSizes.small,\n }\n );\n\n return (\n <span className={className}>\n {actionsOnRow.map((button, index) => {\n const tooltip = String(button.props.tooltip ?? button.props['aria-label'] ?? '');\n\n return React.cloneElement(button, {\n appearance: 'transparent',\n key: index,\n tabIndex: isActiveRow ? 0 : -1,\n tooltip: button.props.shortcut ? (\n <>\n {tooltip}\n <Shortcut className=\"ml-2\" keys={button.props.shortcut} />\n </>\n ) : (\n tooltip\n ),\n });\n })}\n {actionsInMenu.length ? (\n <IconButton\n appearance=\"transparent\"\n aria-label={texts.table.columns.actions.tooltip}\n icon=\"more\"\n tabIndex={isActiveRow ? 0 : -1}\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n {actionsInMenu.map((action, i) => (\n <Menu.Item key={i} {...action.props} shortcut={action.props.shortcut}>\n {action.props['aria-label']}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu>\n )}\n />\n ) : null}\n </span>\n );\n}\n\nfunction Header() {\n return null;\n}\n\nconst Cell = React.memo(function MemoedCell<TType = unknown>(context: ReactTableCellContext<TType, unknown>) {\n const { row, table } = context;\n const { isHovered, rowIndex } = React.useContext(RowContext);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const actions = tableMeta.rowActions.rowActions;\n const actionsLength = tableMeta.rowActions.rowActionsLength;\n\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n const isResizingColumn = !!table.getState().columnSizingInfo.isResizingColumn;\n const isHoverStatePaused = tableMeta.rowActive.isHoverStatePaused;\n\n // We don't want to show actions in edit mode, since we have editing actions,\n // which is shown in edit mode instead.\n if (actions?.length && (isActiveRow || (isHovered && !isHoverStatePaused && !isResizingColumn))) {\n return (\n <Actions\n actions={actions}\n actionsLength={actionsLength}\n data={row.original}\n fontSize={tableMeta.fontSize.size}\n isActiveRow={isActiveRow}\n rowId={row.id}\n />\n );\n }\n\n return null;\n}) as <TType = unknown>(context: ReactTableCellContext<TType, unknown>) => JSX.Element;\n\nexport const renderer: useTableManagerInternalColumn = {\n header: Header,\n renderer: Cell,\n meta: {\n align: 'right',\n className: cn(\n 'print:opacity-0 !px-0 !pr-1 overflow-hidden [table_&]:group-[[data-row-active=\"true\"]]/row:sticky right-0',\n 'group-[[data-row-active=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-row-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-row-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n // TODO: remove when table3 is migrated, this satisfies the legacy table3 type\n enableSearch: false,\n header: '',\n },\n};\n"],"names":["Actions","props","actions","actionsLength","data","fontSize","isActiveRow","rowId","texts","useLocalization","visibleActions","map","action","filter","actionsOnRow","length","slice","actionsInMenu","className","cn","FontSizes","small","React","button","index","tooltip","String","_ref","_button$props$tooltip","cloneElement","appearance","key","tabIndex","shortcut","Shortcut","keys","IconButton","table","columns","icon","menu","menuProps","Menu","Content","i","Item","Header","Cell","memo","MemoedCell","context","row","isHovered","rowIndex","useContext","RowContext","tableMeta","options","meta","rowActions","rowActionsLength","rowActive","rowActiveIndex","isResizingColumn","getState","columnSizingInfo","isHoverStatePaused","original","size","id","renderer","header","align","enableSearch"],"mappings":";;;;;;;;;SAoBgBA,OAAOA,CAAkBC,KAA0B;EAC/D,MAAM;IAAEC,OAAO;IAAEC,aAAa;IAAEC,IAAI;IAAEC,QAAQ;IAAEC,WAAW;IAAEC;GAAO,GAAGN,KAAK;EAC5E,MAAM;IAAEO;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,cAAc,GAAGR,OAAO,CAACS,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACR,IAAI,EAAEG,KAAK,CAAC,CAAC,CAACM,MAAM,CAACD,MAAM,IAAI,CAAC,CAACA,MAAM,CAAkB;EAE7G,MAAME,YAAY,GAAGJ,cAAc,CAACK,MAAM,KAAKZ,aAAa,GAAGO,cAAc,GAAGA,cAAc,CAACM,KAAK,CAAC,CAAC,EAAEb,aAAa,GAAG,CAAC,CAAC;EAC1H,MAAMc,aAAa,GAAGP,cAAc,CAACM,KAAK,CAACN,cAAc,CAACK,MAAM,KAAKZ,aAAa,GAAGA,aAAa,GAAGA,aAAa,GAAG,CAAC,CAAC;EAEvH,MAAMe,SAAS,GAAGC,EAAE,CAChB,mHAAmH,EACnH;;IAEI,OAAO,EAAEd,QAAQ,KAAKe,SAAS,CAACC,KAAK;IACrC,SAAS,EAAEhB,QAAQ,KAAKe,SAAS,CAACC;GACrC,CACJ;EAED,oBACIC;IAAMJ,SAAS,EAAEA;KACZJ,YAAY,CAACH,GAAG,CAAC,CAACY,MAAM,EAAEC,KAAK;;IAC5B,MAAMC,OAAO,GAAGC,MAAM,EAAAC,IAAA,IAAAC,qBAAA,GAACL,MAAM,CAACtB,KAAK,CAACwB,OAAO,cAAAG,qBAAA,cAAAA,qBAAA,GAAIL,MAAM,CAACtB,KAAK,CAAC,YAAY,CAAC,cAAA0B,IAAA,cAAAA,IAAA,GAAI,EAAE,CAAC;IAEhF,oBAAOL,cAAK,CAACO,YAAY,CAACN,MAAM,EAAE;MA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AAK,CAACoB,OAAO,CAACC,IAA6B;EAE7D,MAAMxD,OAAO,GAAGsD,SAAS,CAACG,UAAU,CAACA,UAAU;EAC/C,MAAMxD,aAAa,GAAGqD,SAAS,CAACG,UAAU,CAACC,gBAAgB;EAE3D,MAAMtD,WAAW,GAAGkD,SAAS,CAACK,SAAS,CAACC,cAAc,KAAKT,QAAQ;EACnE,MAAMU,gBAAgB,GAAG,CAAC,CAAC1B,KAAK,CAAC2B,QAAQ,EAAE,CAACC,gBAAgB,CAACF,gBAAgB;EAC7E,MAAMG,kBAAkB,GAAGV,SAAS,CAACK,SAAS,CAACK,kBAAkB;;;EAIjE,IAAIhE,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEa,MAAM,KAAKT,WAAW,IAAK8C,SAAS,IAAI,CAACc,kBAAkB,IAAI,CAACH,gBAAiB,CAAC,EAAE;IAC7F,oBACIzC,6BAACtB,OAAO;MACJE,OAAO,EAAEA,OAAO;MAChBC,aAAa,EAAEA,aAAa;MAC5BC,IAAI,EAAE+C,GAAG,CAACgB,QAAQ;MAClB9D,QAAQ,EAAEmD,SAAS,CAACnD,QAAQ,CAAC+D,IAAI;MACjC9D,WAAW,EAAEA,WAAW;MACxBC,KAAK,EAAE4C,GAAG,CAACkB;MACb;;EAIV,OAAO,IAAI;AACf,CAAC,CAAqF;MAEzEC,QAAQ,GAAkC;EACnDC,MAAM,EAAEzB,MAAM;EACdwB,QAAQ,EAAEvB,IAAI;EACdW,IAAI,EAAE;IACFc,KAAK,EAAE,OAAO;IACdtD,SAAS,eAAEC,EAAE,CACT,2GAA2G,EAC3G,2EAA2E,EAC3E,sDAAsD,EACtD,6DAA6D,CAChE;;IAEDsD,YAAY,EAAE,KAAK;IACnBF,MAAM,EAAE;;;;;;"}
1
+ {"version":3,"file":"Actions.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Internal/Actions.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext as ReactTableCellContext, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { useLocalization } from '../../../../../../components/Provider/Localization';\nimport { IconButton } from '../../../../../../components/IconButton/IconButton';\nimport { Menu } from '../../../../../../components/Menu/Menu';\nimport { Shortcut } from '../../../../../../components/Shortcut/Shortcut';\nimport { TableFontSize, TableRowActionRenderer } from '../../../../types';\nimport { FontSizes } from '../../../../../../types';\nimport { RowContext } from '../../Row/RowContext';\nimport { useTableManagerInternalColumn } from '../../../../useTableManager/types';\n\nexport type ActionsProps<TType = unknown> = {\n actions: TableRowActionRenderer<TType>[];\n actionsLength: number;\n data: any;\n fontSize: TableFontSize;\n isActiveRow: boolean;\n rowId: string;\n};\nexport function Actions<TType = unknown>(props: ActionsProps<TType>) {\n const { actions, actionsLength, data, fontSize, isActiveRow, rowId } = props;\n const { texts } = useLocalization();\n const visibleActions = actions.map(action => action(data, rowId)).filter(action => !!action) as JSX.Element[];\n\n const actionsOnRow = visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);\n const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);\n\n const className = cn(\n '-mb-2 flex justify-end text-right bg-[inherit] shadow-[-6px_0px_6px_var(--table-row-actions-shadow)] print:hidden',\n {\n // Adjust negative margin on row actions cell to ensure that the cell aligns vertically.\n '-mt-2': fontSize === FontSizes.small,\n '-mt-1.5': fontSize !== FontSizes.small,\n }\n );\n\n return (\n <span className={className}>\n {actionsOnRow.map((button, index) => {\n const tooltip = String(button.props.tooltip ?? button.props['aria-label'] ?? '');\n\n return React.cloneElement(button, {\n appearance: 'transparent',\n key: index,\n tabIndex: isActiveRow ? 0 : -1,\n tooltip: button.props.shortcut ? (\n <>\n {tooltip}\n <Shortcut className=\"ml-2\" keys={button.props.shortcut} />\n </>\n ) : (\n tooltip\n ),\n });\n })}\n {actionsInMenu.length ? (\n <IconButton\n appearance=\"transparent\"\n aria-label={texts.table.columns.actions.tooltip}\n icon=\"more\"\n tabIndex={isActiveRow ? 0 : -1}\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n {actionsInMenu.map((action, i) => (\n <Menu.Item key={i} {...action.props} shortcut={action.props.shortcut}>\n {action.props['aria-label']}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu>\n )}\n />\n ) : null}\n </span>\n );\n}\n\nfunction Header() {\n return null;\n}\n\nconst Cell = React.memo(function MemoedCell<TType = unknown>(context: ReactTableCellContext<TType, unknown>) {\n const { row, table } = context;\n const { isHovered, rowIndex } = React.useContext(RowContext);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const actions = tableMeta.rowActions.rowActions;\n const actionsLength = tableMeta.rowActions.rowActionsLength;\n\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n const isResizingColumn = !!table.getState().columnSizingInfo.isResizingColumn;\n const isHoverStatePaused = tableMeta.rowActive.isHoverStatePaused;\n\n // We don't want to show actions in edit mode, since we have editing actions,\n // which is shown in edit mode instead.\n if (actions?.length && (isActiveRow || (isHovered && !isHoverStatePaused && !isResizingColumn))) {\n return (\n <Actions\n actions={actions}\n actionsLength={actionsLength}\n data={row.original}\n fontSize={tableMeta.fontSize.size}\n isActiveRow={isActiveRow}\n rowId={row.id}\n />\n );\n }\n\n return null;\n}) as <TType = unknown>(context: ReactTableCellContext<TType, unknown>) => JSX.Element;\n\nexport const renderer: useTableManagerInternalColumn = {\n header: Header,\n renderer: Cell,\n meta: {\n align: 'right',\n className: cn(\n 'print:opacity-0 !px-0 !pr-1 overflow-hidden [table_&]:group-[[data-row-active=\"true\"]]/row:sticky right-0',\n 'group-[[data-row-active=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-row-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-row-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n // TODO: remove when table3 is migrated, this satisfies the legacy table3 type\n enableSearch: false,\n header: '',\n },\n};\n"],"names":["Actions","props","actions","actionsLength","data","fontSize","isActiveRow","rowId","texts","useLocalization","visibleActions","map","action","filter","actionsOnRow","length","slice","actionsInMenu","className","cn","FontSizes","small","React","button","index","tooltip","String","_ref","_button$props$tooltip","cloneElement","appearance","key","tabIndex","shortcut","Shortcut","keys","IconButton","table","columns","icon","menu","menuProps","Menu","Content","i","Item","Header","Cell","memo","MemoedCell","context","row","isHovered","rowIndex","useContext","RowContext","tableMeta","options","meta","rowActions","rowActionsLength","rowActive","rowActiveIndex","isResizingColumn","getState","columnSizingInfo","isHoverStatePaused","original","size","id","renderer","header","align","enableSearch"],"mappings":";;;;;;;;;SAoBgBA,OAAOA,CAAkBC,KAA0B;EAC/D,MAAM;IAAEC,OAAO;IAAEC,aAAa;IAAEC,IAAI;IAAEC,QAAQ;IAAEC,WAAW;IAAEC;GAAO,GAAGN,KAAK;EAC5E,MAAM;IAAEO;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,cAAc,GAAGR,OAAO,CAACS,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACR,IAAI,EAAEG,KAAK,CAAC,CAAC,CAACM,MAAM,CAACD,MAAM,IAAI,CAAC,CAACA,MAAM,CAAkB;EAE7G,MAAME,YAAY,GAAGJ,cAAc,CAACK,MAAM,KAAKZ,aAAa,GAAGO,cAAc,GAAGA,cAAc,CAACM,KAAK,CAAC,CAAC,EAAEb,aAAa,GAAG,CAAC,CAAC;EAC1H,MAAMc,aAAa,GAAGP,cAAc,CAACM,KAAK,CAACN,cAAc,CAACK,MAAM,KAAKZ,aAAa,GAAGA,aAAa,GAAGA,aAAa,GAAG,CAAC,CAAC;EAEvH,MAAMe,SAAS,GAAGC,EAAE,CAChB,mHAAmH,EACnH;;IAEI,OAAO,EAAEd,QAAQ,KAAKe,SAAS,CAACC,KAAK;IACrC,SAAS,EAAEhB,QAAQ,KAAKe,SAAS,CAACC;GACrC,CACJ;EAED,oBACIC;IAAMJ,SAAS,EAAEA;KACZJ,YAAY,CAACH,GAAG,CAAC,CAACY,MAAM,EAA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tD,SAAS,eAAEC,EAAE,CACT,2GAA2G,EAC3G,2EAA2E,EAC3E,sDAAsD,EACtD,6DAA6D,CAChE;;IAEDsD,YAAY,EAAE,KAAK;IACnBF,MAAM,EAAE;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Selection.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Internal/Selection.tsx"],"sourcesContent":["import React from 'react';\nimport {\n HeaderContext as ReactTableHeaderContext,\n CellContext as ReactTableCellContext,\n TableMeta as ReactTableMeta,\n RowSelectionState,\n} from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { useLocalization } from '../../../../../../components/Provider/Localization';\nimport { Tooltip } from '../../../../../../components/Tooltip/Tooltip';\nimport { Checkbox } from '../../../../../../components/Checkbox/Checkbox';\nimport { Shortcut } from '../../../../../../components/Shortcut/Shortcut';\nimport { getRadioClassnames } from '../../../../../../components/RadioGroup/util';\nimport { TableServerLoadAllState } from '../../../../types';\nimport { RowContext } from '../../Row/RowContext';\nimport { useTableManagerInternalColumn } from '../../../../useTableManager/types';\n\nfunction Header<TType = unknown>(context: ReactTableHeaderContext<TType, unknown>) {\n const { texts } = useLocalization();\n const { table } = context;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (table.options.enableMultiRowSelection) {\n const isAllRowsSelected = table.getIsAllRowsSelected();\n const isSomeRowsSelected = table.getIsSomeRowsSelected();\n const title = isAllRowsSelected ? texts.table.columns.select.deselectAll : texts.table.columns.select.selectAll;\n\n const handleChange = async (checked: boolean) => {\n // load all data if that is possible\n if (tableMeta.server.loadAllIfNeeded) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters);\n }\n\n table.toggleAllRowsSelected(checked);\n };\n\n return (\n <Tooltip title={title}>\n <Checkbox\n aria-label={title}\n className=\"hover:border-blue !-mt-px\"\n key={String(`${isAllRowsSelected}_${isSomeRowsSelected}`)}\n checked={isAllRowsSelected}\n indeterminate={isSomeRowsSelected}\n loading={tableMeta.server.loadAllStatus === TableServerLoadAllState.Loading}\n onChange={handleChange}\n />\n </Tooltip>\n );\n }\n\n return null;\n}\n\nconst toggleBetween = (fromRowIndex: number, toRowIndex: number): [number, number] => {\n const fromIndex = toRowIndex < fromRowIndex ? toRowIndex : fromRowIndex;\n const toIndex = toRowIndex > fromRowIndex ? toRowIndex : fromRowIndex;\n\n return [fromIndex, toIndex];\n};\n\nfunction Cell<TType = unknown>(context: ReactTableCellContext<TType, unknown>) {\n const { texts } = useLocalization();\n const { row, table } = context;\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (table.options.enableGrouping && table.getState().grouping?.length && !row.getIsGrouped()) {\n return null;\n }\n\n const isSelected = row.getIsGrouped() ? row.getIsAllSubRowsSelected() : row.getIsSelected();\n const title = isSelected ? texts.table.columns.select.deselect : texts.table.columns.select.select;\n\n if (table.options.enableMultiRowSelection) {\n const handleClick = async (event: React.MouseEvent) => {\n event.stopPropagation();\n\n if (row.getIsGrouped()) {\n row.subRows.forEach(row => row.toggleSelected());\n } else if (event.shiftKey) {\n const [fromIndex, toIndex] = toggleBetween(tableMeta.rowSelection.lastSelectedRowIndex.current ?? 0, rowIndex);\n const selectedRows = table.getRowModel().rows.slice(fromIndex, toIndex + 1);\n\n if (tableMeta.server.loadAllIfNeeded && selectedRows.some(row => row.original === undefined)) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters);\n }\n\n table.setRowSelection((currentRowSelection: RowSelectionState) => ({\n ...currentRowSelection,\n ...selectedRows.reduce((state, row) => ({ ...state, [row.id]: true }), {}),\n }));\n } else {\n row.toggleSelected();\n }\n\n tableMeta.rowSelection.lastSelectedRowIndex.current = row.index;\n };\n\n return (\n <Tooltip\n title={\n <>\n {title}\n <Shortcut className=\"ml-2\" keys=\"Space\" />\n </>\n }>\n <Checkbox\n aria-label={title}\n className=\"!mt-0\"\n checked={isSelected}\n onClick={handleClick}\n // this is necessary to remove console spam from eslint\n onChange={() => false}\n />\n </Tooltip>\n );\n } else {\n const className = cn('!mt-0', getRadioClassnames());\n\n const handleClick = (event: React.MouseEvent): void => {\n event.stopPropagation();\n row.toggleSelected();\n tableMeta.rowSelection.lastSelectedRowIndex.current = row.index;\n };\n\n return (\n <button className={className} aria-checked={isSelected} onClick={handleClick} role=\"radio\" type=\"button\">\n {isSelected ? <span className=\"h-2 w-2 rounded-full bg-white\" /> : null}\n </button>\n );\n }\n}\n\nexport const renderer: useTableManagerInternalColumn = {\n header: Header,\n renderer: Cell,\n size: 40,\n meta: {\n align: 'center',\n className: '!px-1',\n // TODO: remove when table3 is migrated, this satisfies the legacy table3 type\n enableSearch: false,\n header: '',\n headerClassName: '!px-1',\n },\n};\n"],"names":["Header","context","texts","useLocalization","table","tableMeta","options","meta","enableMultiRowSelection","isAllRowsSelected","getIsAllRowsSelected","isSomeRowsSelected","getIsSomeRowsSelected","title","columns","select","deselectAll","selectAll","handleChange","checked","toggleAllRowsSelected","_temp","server","loadAllIfNeeded","Promise","resolve","getState","sorting","columnFilters","then","_temp2","e","reject","React","Tooltip","Checkbox","className","key","String","indeterminate","loading","loadAllStatus","TableServerLoadAllState","Loading","onChange","toggleBetween","fromRowIndex","toRowIndex","fromIndex","toIndex","Cell","row","rowIndex","useContext","RowContext","enableGrouping","_table$getState$group","grouping","length","getIsGrouped","isSelected","getIsAllSubRowsSelected","getIsSelected","deselect","handleClick","event","rowSelection","lastSelectedRowIndex","current","index","stopPropagation","_temp6","subRows","forEach","toggleSelected","_temp5","shiftKey","_tableMeta$rowSelecti","_temp4","setRowSelection","currentRowSelection","selectedRows","reduce","state","id","getRowModel","rows","slice","_temp3","some","original","undefined","_temp7","Shortcut","keys","onClick","cn","getRadioClassnames","role","type","renderer","header","size","align","enableSearch","headerClassName"],"mappings":";;;;;;;;;;AAiBA,SAASA,MAAMA,CAAkBC,OAAgD;EAC7E,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MAACC,IAAI,EAAC;OAC3FvC,UAAU,gBAAG3B;MAAMG,SAAS,EAAC;MAAkC,GAAG,IAAI,CAClE;;AAGrB;MAEagE,QAAQ,GAAkC;EACnDC,MAAM,EAAErG,MAAM;EACdoG,QAAQ,EAAElD,IAAI;EACdoD,IAAI,EAAE,EAAE;EACR/F,IAAI,EAAE;IACFgG,KAAK,EAAE,QAAQ;IACfnE,SAAS,EAAE,OAAO;;IAElBoE,YAAY,EAAE,KAAK;IACnBH,MAAM,EAAE,EAAE;IACVI,eAAe,EAAE;;;;;;"}
1
+ {"version":3,"file":"Selection.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Internal/Selection.tsx"],"sourcesContent":["import React from 'react';\nimport {\n HeaderContext as ReactTableHeaderContext,\n CellContext as ReactTableCellContext,\n TableMeta as ReactTableMeta,\n RowSelectionState,\n} from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { useLocalization } from '../../../../../../components/Provider/Localization';\nimport { Tooltip } from '../../../../../../components/Tooltip/Tooltip';\nimport { Checkbox } from '../../../../../../components/Checkbox/Checkbox';\nimport { Shortcut } from '../../../../../../components/Shortcut/Shortcut';\nimport { getRadioClassnames } from '../../../../../../components/RadioGroup/util';\nimport { TableServerLoadAllState } from '../../../../types';\nimport { RowContext } from '../../Row/RowContext';\nimport { useTableManagerInternalColumn } from '../../../../useTableManager/types';\n\nfunction Header<TType = unknown>(context: ReactTableHeaderContext<TType, unknown>) {\n const { texts } = useLocalization();\n const { table } = context;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (table.options.enableMultiRowSelection) {\n const isAllRowsSelected = table.getIsAllRowsSelected();\n const isSomeRowsSelected = table.getIsSomeRowsSelected();\n const title = isAllRowsSelected ? texts.table.columns.select.deselectAll : texts.table.columns.select.selectAll;\n\n const handleChange = async (checked: boolean) => {\n // load all data if that is possible\n if (tableMeta.server.loadAllIfNeeded) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters);\n }\n\n table.toggleAllRowsSelected(checked);\n };\n\n return (\n <Tooltip title={title}>\n <Checkbox\n aria-label={title}\n className=\"hover:border-blue !-mt-px\"\n key={String(`${isAllRowsSelected}_${isSomeRowsSelected}`)}\n checked={isAllRowsSelected}\n indeterminate={isSomeRowsSelected}\n loading={tableMeta.server.loadAllStatus === TableServerLoadAllState.Loading}\n onChange={handleChange}\n />\n </Tooltip>\n );\n }\n\n return null;\n}\n\nconst toggleBetween = (fromRowIndex: number, toRowIndex: number): [number, number] => {\n const fromIndex = toRowIndex < fromRowIndex ? toRowIndex : fromRowIndex;\n const toIndex = toRowIndex > fromRowIndex ? toRowIndex : fromRowIndex;\n\n return [fromIndex, toIndex];\n};\n\nfunction Cell<TType = unknown>(context: ReactTableCellContext<TType, unknown>) {\n const { texts } = useLocalization();\n const { row, table } = context;\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (table.options.enableGrouping && table.getState().grouping?.length && !row.getIsGrouped()) {\n return null;\n }\n\n const isSelected = row.getIsGrouped() ? row.getIsAllSubRowsSelected() : row.getIsSelected();\n const title = isSelected ? texts.table.columns.select.deselect : texts.table.columns.select.select;\n\n if (table.options.enableMultiRowSelection) {\n const handleClick = async (event: React.MouseEvent) => {\n event.stopPropagation();\n\n if (row.getIsGrouped()) {\n row.subRows.forEach(row => row.toggleSelected());\n } else if (event.shiftKey) {\n const [fromIndex, toIndex] = toggleBetween(tableMeta.rowSelection.lastSelectedRowIndex.current ?? 0, rowIndex);\n const selectedRows = table.getRowModel().rows.slice(fromIndex, toIndex + 1);\n\n if (tableMeta.server.loadAllIfNeeded && selectedRows.some(row => row.original === undefined)) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters);\n }\n\n table.setRowSelection((currentRowSelection: RowSelectionState) => ({\n ...currentRowSelection,\n ...selectedRows.reduce((state, row) => ({ ...state, [row.id]: true }), {}),\n }));\n } else {\n row.toggleSelected();\n }\n\n tableMeta.rowSelection.lastSelectedRowIndex.current = row.index;\n };\n\n return (\n <Tooltip\n title={\n <>\n {title}\n <Shortcut className=\"ml-2\" keys=\"Space\" />\n </>\n }>\n <Checkbox\n aria-label={title}\n className=\"!mt-0\"\n checked={isSelected}\n onClick={handleClick}\n // this is necessary to remove console spam from eslint\n onChange={() => false}\n />\n </Tooltip>\n );\n } else {\n const className = cn('!mt-0', getRadioClassnames());\n\n const handleClick = (event: React.MouseEvent): void => {\n event.stopPropagation();\n row.toggleSelected();\n tableMeta.rowSelection.lastSelectedRowIndex.current = row.index;\n };\n\n return (\n <button className={className} aria-checked={isSelected} onClick={handleClick} role=\"radio\" type=\"button\">\n {isSelected ? <span className=\"h-2 w-2 rounded-full bg-white\" /> : null}\n </button>\n );\n }\n}\n\nexport const renderer: useTableManagerInternalColumn = {\n header: Header,\n renderer: Cell,\n size: 40,\n meta: {\n align: 'center',\n className: '!px-1',\n // TODO: remove when table3 is migrated, this satisfies the legacy table3 type\n enableSearch: false,\n header: '',\n headerClassName: '!px-1',\n },\n};\n"],"names":["Header","context","texts","useLocalization","table","tableMeta","options","meta","enableMultiRowSelection","isAllRowsSelected","getIsAllRowsSelected","isSomeRowsSelected","getIsSomeRowsSelected","title","columns","select","deselectAll","selectAll","handleChange","checked","toggleAllRowsSelected","_temp","server","loadAllIfNeeded","Promise","resolve","getState","sorting","columnFilters","then","_temp2","e","reject","React","Tooltip","Checkbox","className","key","String","indeterminate","loading","loadAllStatus","TableServerLoadAllState","Loading","onChange","toggleBetween","fromRowIndex","toRowIndex","fromIndex","toIndex","Cell","row","rowIndex","useContext","RowContext","enableGrouping","_table$getState$group","grouping","length","getIsGrouped","isSelected","getIsAllSubRowsSelected","getIsSelected","deselect","handleClick","event","rowSelection","lastSelectedRowIndex","current","index","stopPropagation","_temp6","subRows","forEach","toggleSelected","_temp5","shiftKey","_tableMeta$rowSelecti","_temp4","setRowSelection","currentRowSelection","selectedRows","reduce","state","id","getRowModel","rows","slice","_temp3","some","original","undefined","_temp7","Shortcut","keys","onClick","cn","getRadioClassnames","role","type","renderer","header","size","align","enableSearch","headerClassName"],"mappings":";;;;;;;;;;AAiBA,SAASA,MAAMA,CAAkBC,OAAgD;EAC7E,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAM;IAAEC;GAAO,GAAGH,OAAO;EACzB,MAAMI,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAE7D,IAAIH,KAAK,CAACE,OAAO,CAACE,uBAAuB,EAAE;IACvC,MAAMC,iBAAiB,GAAGL,KAAK,CAACM,oBAAoB,EAAE;IACtD,MAAMC,kBAAkB,GAAGP,KAAK,CAACQ,qBAAqB,EAAE;IACxD,MAAMC,KAAK,GAAGJ,iBAAiB,GAAGP,KAAK,CAACE,KAAK,CAACU,OAAO,CAACC,MAAM,CAACC,WAAW,GAAGd,KAAK,CAACE,KAAK,CAACU,OAAO,CAACC,MAAM,CAACE,SAAS;IAE/G,MAAMC,YAAY,aAAUC,OAAgB;MAAA;;UAOxCf,KAAK,CAACgB,qBAAqB,CAACD,OAAO,CAAC;;QAAC,MAAAE,KAAA;UAAA,IALjChB,SAAS,CAACiB,MAAM,CAACC,eAAe;;YAChC,OAAAC,OAAA,CAAAC,OAAA,CACMpB,SAAS,CAACiB,MAAM,CAACC,eAAe,CAACnB,KAAK,CAACsB,QAAQ,EAAE,CAACC,OAAO,EAAEvB,KAAK,CAACsB,QAAQ,EAAE,CAACE,aAAa,CAAC,EAAAC,IAAA;;;;QAHpG,OAAAL,OAAA,CAAAC,OAAA,CAAAJ,KAAA,IAAAA,KAAA,CAAAQ,IAAA,GAAAR,KAAA,CAAAQ,IAAA,CAAAC,MAAA,IAAAA,MAAA,CAAAT,KAAA;OAOH,QAAAU,CAAA;QAAA,OAAAP,OAAA,CAAAQ,MAAA,CAAAD,CAAA;;;IAED,oBACIE,6BAACC,OAAO;MA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c,EAAE;MACpBrE,SAAS,CAAC6D,YAAY,CAACC,oBAAoB,CAACC,OAAO,GAAGjB,GAAG,CAACkB,KAAK;KAClE;IAED,oBACIpC;MAAQG,SAAS,EAAEA,SAAS;sBAAgBwB,UAAU;MAAEmC,OAAO,EAAE/B,WAAW;MAAEkC,IAAI,EAAC,OAAO;MAACC,IAAI,EAAC;OAC3FvC,UAAU,gBAAG3B;MAAMG,SAAS,EAAC;MAAkC,GAAG,IAAI,CAClE;;AAGrB;MAEagE,QAAQ,GAAkC;EACnDC,MAAM,EAAErG,MAAM;EACdoG,QAAQ,EAAElD,IAAI;EACdoD,IAAI,EAAE,EAAE;EACR/F,IAAI,EAAE;IACFgG,KAAK,EAAE,QAAQ;IACfnE,SAAS,EAAE,OAAO;;IAElBoE,YAAY,EAAE,KAAK;IACnBH,MAAM,EAAE,EAAE;IACVI,eAAe,EAAE;;;;;;"}
@@ -4,7 +4,7 @@ import { Summary } from './Summary.js';
4
4
 
5
5
  function Foot(props) {
6
6
  const nonGroupedHeaders = props.table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());
7
- return /*#__PURE__*/React__default.createElement("tfoot", null, /*#__PURE__*/React__default.createElement("tr", null, nonGroupedHeaders.map((header, index) => ( /*#__PURE__*/React__default.createElement(Footer, {
7
+ return /*#__PURE__*/React__default.createElement("tfoot", null, /*#__PURE__*/React__default.createElement("tr", null, nonGroupedHeaders.map((header, index) => (/*#__PURE__*/React__default.createElement(Footer, {
8
8
  key: header.id,
9
9
  header: header,
10
10
  index: index
@@ -1 +1 @@
1
- {"version":3,"file":"Footer.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Footer/Footer.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Header as ReactTableHeader,\n ColumnMeta as ReactTableColumnMeta,\n flexRender,\n Table as ReactTable,\n} from '@tanstack/react-table';\nimport { Summary } from './Summary';\n\nexport type FootProps<TType = unknown> = {\n table: ReactTable<TType>;\n};\nexport function Foot<TType = unknown>(props: FootProps<TType>) {\n const nonGroupedHeaders = props.table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());\n return (\n <tfoot>\n <tr>\n {nonGroupedHeaders.map((header, index) => (\n <Footer key={header.id} header={header} index={index} />\n ))}\n </tr>\n </tfoot>\n );\n}\n\nexport type FooterProps<TType = unknown> = {\n header: ReactTableHeader<TType, unknown>;\n index: number;\n};\nexport function Footer<TType = unknown>(props: FooterProps<TType>) {\n return <MemoedFooter footer={props.header} index={props.index} />;\n}\n\nexport type MemoedFooterProps<TType = unknown> = {\n footer: ReactTableHeader<TType, unknown>;\n index: number;\n};\nconst MemoedFooter = React.memo(function MemoedFooter<TType = unknown>(props: MemoedFooterProps<TType>) {\n const { footer, index } = props;\n const columnMeta = footer.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n\n // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers\n const isHeaderGroup = !!footer.subHeaders?.length;\n const isPinned = isHeaderGroup\n ? footer.subHeaders.find(x => x.column.getIsPinned())?.column.getIsPinned()\n : footer.column.getIsPinned();\n\n const style: React.CSSProperties = {};\n\n if (isPinned) {\n // pinned columns should be offset from either the left or right\n style[isPinned] = `${footer.column.getStart(isPinned)}px`;\n }\n\n let content;\n let align;\n\n if (index === 0) {\n align = 'left';\n content = <Summary table={footer.getContext().table} />;\n } else {\n align = columnMeta.align;\n content = footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext());\n }\n\n return (\n <td\n key={footer.id}\n data-cell-align={align}\n data-cell-id={footer.id}\n data-cell-pinned={isPinned ? isPinned : undefined}\n style={style}>\n {content}\n </td>\n );\n}) as <TType = unknown>(props: MemoedFooterProps<TType>) => JSX.Element;\n"],"names":["Foot","props","nonGroupedHeaders","table","getFooterGroups","headers","filter","header","column","getIsGrouped","React","map","index","Footer","key","id","MemoedFooter","footer","memo","columnMeta","columnDef","meta","isHeaderGroup","_footer$subHeaders","subHeaders","length","isPinned","_footer$subHeaders$fi","find","x","getIsPinned","style","getStart","content","align","Summary","getContext","isPlaceholder","flexRender","undefined"],"mappings":";;;;SAYgBA,IAAIA,CAAkBC,KAAuB;EACzD,MAAMC,iBAAiB,GAAGD,KAAK,CAACE,KAAK,CAACC,eAAe,EAAE,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,MAAM,CAACC,MAAM,IAAI,CAACA,MAAM,CAACC,MAAM,CAACC,YAAY,EAAE,CAAC;EAClH,oBACIC,yDACIA,yCACKR,iBAAiB,CAACS,GAAG,CAAC,CAACJ,MAAM,EAAEK,KAAK,oBACjCF,6BAACG,MAAM;IAACC,GAAG,EAAEP,MAAM,CAACQ,EAAE;IAAER,MAAM,EAAEA,MAAM;IAAEK,KAAK,EAAEA;IAAS,CAC3D,CAAC,CACD,CACD;AAEhB;SAMgBC,MAAMA,CAAkBZ,KAAyB;EAC7D,oBAAOS,6BAACM,YAAY;IAACC,MAAM,EAAEhB,KAAK,CAACM,MAAM;IAAEK,KAAK,EAAEX,KAAK,CAACW;IAAS;AACrE;AAMA,MAAMI,YAAY,gBAAGN,cAAK,CAACQ,IAAI,CAAC,SAASF,YAAYA,CAAkBf,KAA+B;;EAClG,MAAM;IAAEgB,MAAM;IAAEL;GAAO,GAAGX,KAAK;EAC/B,MAAMkB,UAAU,GAAGF,MAAM,CAACT,MAAM,CAACY,SAAS,CAACC,IAA4C;;EAGvF,MAAMC,aAAa,GAAG,CAAC,GAAAC,kBAAA,GAACN,MAAM,CAACO,UAAU,cAAAD,kBAAA,eAAjBA,kBAAA,CAAmBE,MAAM;EACjD,MAAMC,QAAQ,GAAGJ,aAAa,IAAAK,qBAAA,GACxBV,MAAM,CAACO,UAAU,CAACI,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACrB,MAAM,CAACsB,WAAW,EAAE,CAAC,cAAAH,qBAAA,uBAAnDA,qBAAA,CAAqDnB,MAAM,CAACsB,WAAW,EAAE,GACzEb,MAAM,CAACT,MAAM,CAACsB,WAAW,EAAE;EAEjC,MAAMC,KAAK,GAAwB,EAAE;EAErC,IAAIL,QAAQ,EAAE;;IAEVK,KAAK,CAACL,QAAQ,CAAC,MAAMT,MAAM,CAACT,MAAM,CAACwB,QAAQ,CAACN,QAAQ,KAAK;;EAG7D,IAAIO,OAAO;EACX,IAAIC,KAAK;EAET,IAAItB,KAAK,KAAK,CAAC,EAAE;IACbsB,KAAK,GAAG,MAAM;IACdD,OAAO,gBAAGvB,6BAACyB,OAAO;MAAChC,KAAK,EAAEc,MAAM,CAACmB,UAAU,EAAE,CAACjC;MAAS;GAC1D,MAAM;IACH+B,KAAK,GAAGf,UAAU,CAACe,KAAK;IACxBD,OAAO,GAAGhB,MAAM,CAACoB,aAAa,GAAG,IAAI,GAAGC,UAAU,CAACrB,MAAM,CAACT,MAAM,CAACY,SAAS,CAACH,MAAM,EAAEA,MAAM,CAACmB,UAAU,EAAE,CAAC;;EAG3G,oBACI1B;IACII,GAAG,EAAEG,MAAM,CAACF,EAAE;uBACGmB,KAAK;oBACRjB,MAAM,CAACF,EAAE;wBACLW,QAAQ,GAAGA,QAAQ,GAAGa,SAAS;IACjDR,KAAK,EAAEA;KACNE,OAAO,CACP;AAEb,CAAC,CAAsE;;;;"}
1
+ {"version":3,"file":"Footer.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Footer/Footer.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Header as ReactTableHeader,\n ColumnMeta as ReactTableColumnMeta,\n flexRender,\n Table as ReactTable,\n} from '@tanstack/react-table';\nimport { Summary } from './Summary';\n\nexport type FootProps<TType = unknown> = {\n table: ReactTable<TType>;\n};\nexport function Foot<TType = unknown>(props: FootProps<TType>) {\n const nonGroupedHeaders = props.table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());\n return (\n <tfoot>\n <tr>\n {nonGroupedHeaders.map((header, index) => (\n <Footer key={header.id} header={header} index={index} />\n ))}\n </tr>\n </tfoot>\n );\n}\n\nexport type FooterProps<TType = unknown> = {\n header: ReactTableHeader<TType, unknown>;\n index: number;\n};\nexport function Footer<TType = unknown>(props: FooterProps<TType>) {\n return <MemoedFooter footer={props.header} index={props.index} />;\n}\n\nexport type MemoedFooterProps<TType = unknown> = {\n footer: ReactTableHeader<TType, unknown>;\n index: number;\n};\nconst MemoedFooter = React.memo(function MemoedFooter<TType = unknown>(props: MemoedFooterProps<TType>) {\n const { footer, index } = props;\n const columnMeta = footer.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n\n // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers\n const isHeaderGroup = !!footer.subHeaders?.length;\n const isPinned = isHeaderGroup\n ? footer.subHeaders.find(x => x.column.getIsPinned())?.column.getIsPinned()\n : footer.column.getIsPinned();\n\n const style: React.CSSProperties = {};\n\n if (isPinned) {\n // pinned columns should be offset from either the left or right\n style[isPinned] = `${footer.column.getStart(isPinned)}px`;\n }\n\n let content;\n let align;\n\n if (index === 0) {\n align = 'left';\n content = <Summary table={footer.getContext().table} />;\n } else {\n align = columnMeta.align;\n content = footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext());\n }\n\n return (\n <td\n key={footer.id}\n data-cell-align={align}\n data-cell-id={footer.id}\n data-cell-pinned={isPinned ? isPinned : undefined}\n style={style}>\n {content}\n </td>\n );\n}) as <TType = unknown>(props: MemoedFooterProps<TType>) => JSX.Element;\n"],"names":["Foot","props","nonGroupedHeaders","table","getFooterGroups","headers","filter","header","column","getIsGrouped","React","map","index","Footer","key","id","MemoedFooter","footer","memo","columnMeta","columnDef","meta","isHeaderGroup","_footer$subHeaders","subHeaders","length","isPinned","_footer$subHeaders$fi","find","x","getIsPinned","style","getStart","content","align","Summary","getContext","isPlaceholder","flexRender","undefined"],"mappings":";;;;SAYgBA,IAAIA,CAAkBC,KAAuB;EACzD,MAAMC,iBAAiB,GAAGD,KAAK,CAACE,KAAK,CAACC,eAAe,EAAE,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,MAAM,CAACC,MAAM,IAAI,CAACA,MAAM,CA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