@rio-cloud/rio-uikit 2.2.1 → 2.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AnalyticsAnalysisOverlay.d.ts +1 -0
- package/AnalyticsAnalysisOverlay.js +5 -0
- package/AnalyticsAnalysisOverlay.js.map +1 -0
- package/Table.d.ts +2 -0
- package/Table.js +23 -0
- package/Table.js.map +1 -0
- package/TableCol.d.ts +2 -2
- package/TableCol.js +1 -1
- package/TableHead.d.ts +2 -2
- package/TableHead.js +1 -1
- package/TableSettingsDialog.d.ts +2 -2
- package/TableSettingsDialog.js +1 -1
- package/TableToolbar.js +3 -2
- package/analyticsAnalysisUtils.d.ts +1 -0
- package/analyticsAnalysisUtils.js +13 -0
- package/analyticsAnalysisUtils.js.map +1 -0
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisBanner.d.ts +18 -0
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisBanner.js +128 -0
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisBanner.js.map +1 -0
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisOverlay.d.ts +9 -0
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisOverlay.js +73 -0
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisOverlay.js.map +1 -0
- package/components/applicationHeader/AppMenuContent.js.map +1 -1
- package/components/applicationHeader/ApplicationActionBar.js +4 -4
- package/components/applicationHeader/ApplicationActionBar.js.map +1 -1
- package/components/applicationHeader/CollapsedNavItem.js +5 -14
- package/components/applicationHeader/CollapsedNavItem.js.map +1 -1
- package/components/applicationHeader/NavItems.js +10 -10
- package/components/applicationHeader/NavItems.js.map +1 -1
- package/components/assetTree/AssetTree.js +23 -23
- package/components/assetTree/AssetTree.js.map +1 -1
- package/components/assetTree/TreeNothingFound.js +2 -2
- package/components/assetTree/TreeNothingFound.js.map +1 -1
- package/components/assetTree/treeUtils.js.map +1 -1
- package/components/autosuggest/AutoSuggest.js +31 -31
- package/components/autosuggest/AutoSuggest.js.map +1 -1
- package/components/autosuggest/AutoSuggestAddons.js +9 -9
- package/components/autosuggest/AutoSuggestAddons.js.map +1 -1
- package/components/banner/BannerActions.js +2 -2
- package/components/banner/BannerActions.js.map +1 -1
- package/components/banner/BannerIcon.js +3 -3
- package/components/banner/BannerIcon.js.map +1 -1
- package/components/banner/BannerPage.js +4 -4
- package/components/banner/BannerPage.js.map +1 -1
- package/components/button/Button.d.ts +7 -0
- package/components/button/Button.js +73 -65
- package/components/button/Button.js.map +1 -1
- package/components/checkbox/Checkbox.js +18 -17
- package/components/checkbox/Checkbox.js.map +1 -1
- package/components/datepicker/DateRangePicker.js +0 -2
- package/components/datepicker/DateRangePicker.js.map +1 -1
- package/components/datepicker/DayPicker.js +16 -16
- package/components/datepicker/DayPicker.js.map +1 -1
- package/components/dialog/Dialog.js.map +1 -1
- package/components/dialog/DialogHeader.js +23 -20
- package/components/dialog/DialogHeader.js.map +1 -1
- package/components/dialog/MediaDialog.js +1 -1
- package/components/dialog/MediaDialog.js.map +1 -1
- package/components/editableContent/EditableContent.js +7 -7
- package/components/editableContent/EditableContent.js.map +1 -1
- package/components/expander/ExpanderList.d.ts +5 -0
- package/components/expander/ExpanderList.js +25 -16
- package/components/expander/ExpanderList.js.map +1 -1
- package/components/expander/ExpanderPanel.d.ts +5 -0
- package/components/expander/ExpanderPanel.js +29 -28
- package/components/expander/ExpanderPanel.js.map +1 -1
- package/components/fade/FadeExpander.js +1 -1
- package/components/fade/FadeExpander.js.map +1 -1
- package/components/filepicker/FilePicker.js.map +1 -1
- package/components/loadMore/LoadMoreButton.d.ts +5 -0
- package/components/loadMore/LoadMoreButton.js +33 -29
- package/components/loadMore/LoadMoreButton.js.map +1 -1
- package/components/map/components/features/ContextMenu.js +13 -13
- package/components/map/components/features/ContextMenu.js.map +1 -1
- package/components/map/components/features/basics/InfoBubble.js.map +1 -1
- package/components/map/components/features/settings/MapSettingsTile.js.map +1 -1
- package/components/map/components/features/settings/builtinSettings/MapTypeSettings.js +6 -6
- package/components/map/components/features/settings/builtinSettings/MapTypeSettings.js.map +1 -1
- package/components/map/utils/eventHandling.js +18 -18
- package/components/map/utils/eventHandling.js.map +1 -1
- package/components/map/utils/positions.d.ts +1 -1
- package/components/map/utils/positions.js +15 -12
- package/components/map/utils/positions.js.map +1 -1
- package/components/map/utils/rendering.d.ts +1 -1
- package/components/menuItems/MenuItems.js +6 -6
- package/components/menuItems/MenuItems.js.map +1 -1
- package/components/notification/NotificationsContainer.js.map +1 -1
- package/components/numberInput/NumberInput.js +57 -56
- package/components/numberInput/NumberInput.js.map +1 -1
- package/components/popover/Popover.js +4 -4
- package/components/popover/Popover.js.map +1 -1
- package/components/resizer/Resizer.js +6 -3
- package/components/resizer/Resizer.js.map +1 -1
- package/components/selects/BaseSelectDropdown.js +34 -32
- package/components/selects/BaseSelectDropdown.js.map +1 -1
- package/components/selects/MultiselectTogglePlaceholder.js.map +1 -1
- package/components/selects/MultiselectToggleSelection.js +11 -11
- package/components/selects/MultiselectToggleSelection.js.map +1 -1
- package/components/sidebars/Sidebar.js +12 -12
- package/components/sidebars/Sidebar.js.map +1 -1
- package/components/sidebars/SidebarCloseButton.js +2 -2
- package/components/sidebars/SidebarCloseButton.js.map +1 -1
- package/components/smoothScrollbars/SmoothScrollbars.d.ts +4 -3
- package/components/smoothScrollbars/SmoothScrollbars.js +11 -11
- package/components/smoothScrollbars/SmoothScrollbars.js.map +1 -1
- package/components/states/CustomState.js.map +1 -1
- package/components/svgImage/svgConverter.js.map +1 -1
- package/components/table/Table.d.ts +267 -0
- package/components/table/Table.js +233 -0
- package/components/table/Table.js.map +1 -0
- package/components/table/Table.types.d.ts +207 -0
- package/components/table/TableBody.d.ts +10 -0
- package/components/table/TableBody.js +5 -0
- package/components/table/TableBody.js.map +1 -0
- package/components/table/TableCard.d.ts +63 -0
- package/components/table/TableCard.js +150 -0
- package/components/table/TableCard.js.map +1 -0
- package/components/table/TableColumn.d.ts +47 -0
- package/components/table/TableColumn.js +5 -0
- package/components/table/TableColumn.js.map +1 -0
- package/components/table/TableExpandedContentRow.d.ts +22 -0
- package/components/table/TableExpandedContentRow.js +5 -0
- package/components/table/TableExpandedContentRow.js.map +1 -0
- package/components/table/TableExpandedRow.d.ts +17 -0
- package/components/table/TableExpandedRow.js +5 -0
- package/components/table/TableExpandedRow.js.map +1 -0
- package/components/table/TableExpanderButton.d.ts +25 -0
- package/components/table/TableExpanderButton.js +22 -0
- package/components/table/TableExpanderButton.js.map +1 -0
- package/components/table/TableFooter.d.ts +13 -0
- package/components/table/TableFooter.js +5 -0
- package/components/table/TableFooter.js.map +1 -0
- package/components/table/TableGroupFooterRow.d.ts +18 -0
- package/components/table/TableGroupFooterRow.js +5 -0
- package/components/table/TableGroupFooterRow.js.map +1 -0
- package/components/table/TableGroupRow.d.ts +24 -0
- package/components/table/TableGroupRow.js +5 -0
- package/components/table/TableGroupRow.js.map +1 -0
- package/components/table/TableHeader.d.ts +9 -0
- package/components/table/TableHeader.js +5 -0
- package/components/table/TableHeader.js.map +1 -0
- package/components/table/TableHeaderColumn.d.ts +70 -0
- package/components/table/TableHeaderColumn.js +5 -0
- package/components/table/TableHeaderColumn.js.map +1 -0
- package/components/table/TableHeaderRow.d.ts +9 -0
- package/components/table/TableHeaderRow.js +5 -0
- package/components/table/TableHeaderRow.js.map +1 -0
- package/components/table/TableRow.d.ts +19 -0
- package/components/table/TableRow.js +5 -0
- package/components/table/TableRow.js.map +1 -0
- package/components/table/TableSpacerRow.d.ts +12 -0
- package/components/table/TableSpacerRow.js +5 -0
- package/components/table/TableSpacerRow.js.map +1 -0
- package/components/table/TableToolbar.d.ts +23 -1
- package/components/table/TableToolbar.js +38 -4
- package/components/table/TableToolbar.js.map +1 -1
- package/components/table/TableViewToggles.d.ts +18 -0
- package/components/table/TableViewToggles.js +59 -87
- package/components/table/TableViewToggles.js.map +1 -1
- package/components/table/layout/columnSizing.d.ts +3 -0
- package/components/table/layout/columnSizing.js +23 -0
- package/components/table/layout/columnSizing.js.map +1 -0
- package/components/table/layout/useDraggableColumns.d.ts +14 -0
- package/components/table/layout/useDraggableColumns.js +47 -0
- package/components/table/layout/useDraggableColumns.js.map +1 -0
- package/components/table/layout/useHorizontalSectionSync.d.ts +11 -0
- package/components/table/layout/useHorizontalSectionSync.js +39 -0
- package/components/table/layout/useHorizontalSectionSync.js.map +1 -0
- package/components/table/layout/useMeasuredColumnMaxWidths.d.ts +12 -0
- package/components/table/layout/useMeasuredColumnMaxWidths.js +85 -0
- package/components/table/layout/useMeasuredColumnMaxWidths.js.map +1 -0
- package/components/table/layout/useResizableColumns.d.ts +14 -0
- package/components/table/layout/useResizableColumns.js +91 -0
- package/components/table/layout/useResizableColumns.js.map +1 -0
- package/components/table/layout/useTableLayout.d.ts +25 -0
- package/components/table/layout/useTableLayout.js +56 -0
- package/components/table/layout/useTableLayout.js.map +1 -0
- package/components/table/layout/useTableVirtualization.d.ts +22 -0
- package/components/table/layout/useTableVirtualization.js +125 -0
- package/components/table/layout/useTableVirtualization.js.map +1 -0
- package/components/table/model/buildTableViewModel.d.ts +28 -0
- package/components/table/model/buildTableViewModel.js +221 -0
- package/components/table/model/buildTableViewModel.js.map +1 -0
- package/components/table/model/resolveCellContent.d.ts +2 -0
- package/components/table/model/resolveCellContent.js +5 -0
- package/components/table/model/resolveCellContent.js.map +1 -0
- package/components/table/model/resolveRowMeta.d.ts +2 -0
- package/components/table/model/resolveRowMeta.js +15 -0
- package/components/table/model/resolveRowMeta.js.map +1 -0
- package/components/table/model/resolveTableClassConfig.d.ts +48 -0
- package/components/table/model/resolveTableClassConfig.js +64 -0
- package/components/table/model/resolveTableClassConfig.js.map +1 -0
- package/components/table/model/tableViewModel.types.d.ts +153 -0
- package/components/table/native/TableCol.js.map +1 -0
- package/components/table/{TableHead.js → native/TableHead.js} +2 -2
- package/components/table/native/TableHead.js.map +1 -0
- package/components/table/native/TableSettingsColumnButtons.js +59 -0
- package/components/table/native/TableSettingsColumnButtons.js.map +1 -0
- package/components/table/{TableSettingsColumnDetails.js → native/TableSettingsColumnDetails.js} +2 -2
- package/components/table/native/TableSettingsColumnDetails.js.map +1 -0
- package/components/table/{TableSettingsDialog.d.ts → native/TableSettingsDialog.d.ts} +2 -3
- package/components/table/native/TableSettingsDialog.js +216 -0
- package/components/table/native/TableSettingsDialog.js.map +1 -0
- package/components/table/{TableSettingsDialogFooter.js → native/TableSettingsDialogFooter.js} +2 -2
- package/components/table/native/TableSettingsDialogFooter.js.map +1 -0
- package/components/table/native/TableSettingsListContainer.js.map +1 -0
- package/components/table/native/TableSettingsListItem.js +100 -0
- package/components/table/native/TableSettingsListItem.js.map +1 -0
- package/components/table/parse/parseBody.d.ts +3 -0
- package/components/table/parse/parseBody.js +13 -0
- package/components/table/parse/parseBody.js.map +1 -0
- package/components/table/parse/parseColumns.d.ts +3 -0
- package/components/table/parse/parseColumns.js +81 -0
- package/components/table/parse/parseColumns.js.map +1 -0
- package/components/table/parse/parseFooter.d.ts +3 -0
- package/components/table/parse/parseFooter.js +39 -0
- package/components/table/parse/parseFooter.js.map +1 -0
- package/components/table/parse/parseHeaders.d.ts +4 -0
- package/components/table/parse/parseHeaders.js +89 -0
- package/components/table/parse/parseHeaders.js.map +1 -0
- package/components/table/parse/parseRows.d.ts +3 -0
- package/components/table/parse/parseRows.js +93 -0
- package/components/table/parse/parseRows.js.map +1 -0
- package/components/table/parse/tableChildGuards.d.ts +25 -0
- package/components/table/parse/tableChildGuards.js +29 -0
- package/components/table/parse/tableChildGuards.js.map +1 -0
- package/components/table/render/body/TableBodyRow.d.ts +16 -0
- package/components/table/render/body/TableBodyRow.js +84 -0
- package/components/table/render/body/TableBodyRow.js.map +1 -0
- package/components/table/render/body/TableBodySection.d.ts +20 -0
- package/components/table/render/body/TableBodySection.js +68 -0
- package/components/table/render/body/TableBodySection.js.map +1 -0
- package/components/table/render/body/TableDataRow.d.ts +15 -0
- package/components/table/render/body/TableDataRow.js +143 -0
- package/components/table/render/body/TableDataRow.js.map +1 -0
- package/components/table/render/body/TableEmptyRow.d.ts +7 -0
- package/components/table/render/body/TableEmptyRow.js +6 -0
- package/components/table/render/body/TableEmptyRow.js.map +1 -0
- package/components/table/render/body/TableExpandedRow.d.ts +8 -0
- package/components/table/render/body/TableExpandedRow.js +84 -0
- package/components/table/render/body/TableExpandedRow.js.map +1 -0
- package/components/table/render/body/TableGroupRow.d.ts +8 -0
- package/components/table/render/body/TableGroupRow.js +21 -0
- package/components/table/render/body/TableGroupRow.js.map +1 -0
- package/components/table/render/body/TableSpacerRow.d.ts +7 -0
- package/components/table/render/body/TableSpacerRow.js +15 -0
- package/components/table/render/body/TableSpacerRow.js.map +1 -0
- package/components/table/render/footer/TableFooterCell.d.ts +8 -0
- package/components/table/render/footer/TableFooterCell.js +31 -0
- package/components/table/render/footer/TableFooterCell.js.map +1 -0
- package/components/table/render/footer/TableFooterContent.d.ts +6 -0
- package/components/table/render/footer/TableFooterContent.js +6 -0
- package/components/table/render/footer/TableFooterContent.js.map +1 -0
- package/components/table/render/footer/TableFooterSection.d.ts +10 -0
- package/components/table/render/footer/TableFooterSection.js +28 -0
- package/components/table/render/footer/TableFooterSection.js.map +1 -0
- package/components/table/render/header/TableBatchDropdown.d.ts +9 -0
- package/components/table/render/header/TableBatchDropdown.js +28 -0
- package/components/table/render/header/TableBatchDropdown.js.map +1 -0
- package/components/table/render/header/TableColumnFilter.d.ts +66 -0
- package/components/table/render/header/TableColumnFilter.js +70 -0
- package/components/table/render/header/TableColumnFilter.js.map +1 -0
- package/components/table/render/header/TableDraggableHeaderCell.d.ts +3 -0
- package/components/table/render/header/TableDraggableHeaderCell.js +54 -0
- package/components/table/render/header/TableDraggableHeaderCell.js.map +1 -0
- package/components/table/render/header/TableHeader.types.d.ts +35 -0
- package/components/table/render/header/TableHeaderCellContent.d.ts +3 -0
- package/components/table/render/header/TableHeaderCellContent.js +57 -0
- package/components/table/render/header/TableHeaderCellContent.js.map +1 -0
- package/components/table/render/header/TableHeaderCellResizeHandle.d.ts +3 -0
- package/components/table/render/header/TableHeaderCellResizeHandle.js +22 -0
- package/components/table/render/header/TableHeaderCellResizeHandle.js.map +1 -0
- package/components/table/render/header/TableHeaderDragOverlay.d.ts +13 -0
- package/components/table/render/header/TableHeaderDragOverlay.js +35 -0
- package/components/table/render/header/TableHeaderDragOverlay.js.map +1 -0
- package/components/table/render/header/TableHeaderSection.d.ts +3 -0
- package/components/table/render/header/TableHeaderSection.js +104 -0
- package/components/table/render/header/TableHeaderSection.js.map +1 -0
- package/components/table/render/header/TableHeaderSelectionCell.d.ts +9 -0
- package/components/table/render/header/TableHeaderSelectionCell.js +41 -0
- package/components/table/render/header/TableHeaderSelectionCell.js.map +1 -0
- package/components/table/render/header/TableStaticHeaderCell.d.ts +3 -0
- package/components/table/render/header/TableStaticHeaderCell.js +36 -0
- package/components/table/render/header/TableStaticHeaderCell.js.map +1 -0
- package/components/table/render/header/resolveAriaSort.d.ts +2 -0
- package/components/table/render/header/resolveAriaSort.js +8 -0
- package/components/table/render/header/resolveAriaSort.js.map +1 -0
- package/components/table/render/header/resolveColumnCollisionDetection.d.ts +2 -0
- package/components/table/render/header/resolveColumnCollisionDetection.js +9 -0
- package/components/table/render/header/resolveColumnCollisionDetection.js.map +1 -0
- package/components/table/render/header/resolveHeaderCellClassName.d.ts +10 -0
- package/components/table/render/header/resolveHeaderCellClassName.js +22 -0
- package/components/table/render/header/resolveHeaderCellClassName.js.map +1 -0
- package/components/table/render/header/resolveHeaderCellStyle.d.ts +829 -0
- package/components/table/render/header/resolveHeaderCellStyle.js +9 -0
- package/components/table/render/header/resolveHeaderCellStyle.js.map +1 -0
- package/components/table/selection/useTableSelection.d.ts +82 -0
- package/components/table/selection/useTableSelection.js +35 -0
- package/components/table/selection/useTableSelection.js.map +1 -0
- package/components/table/settings/TableColumnsDropdown.d.ts +90 -0
- package/components/table/settings/TableColumnsDropdown.js +137 -0
- package/components/table/settings/TableColumnsDropdown.js.map +1 -0
- package/components/table/settings/TableColumnsDropdownItem.d.ts +8 -0
- package/components/table/settings/TableColumnsDropdownItem.js +66 -0
- package/components/table/settings/TableColumnsDropdownItem.js.map +1 -0
- package/components/table/shared/getAlignClassName.d.ts +3 -0
- package/components/table/shared/getAlignClassName.js +6 -0
- package/components/table/shared/getAlignClassName.js.map +1 -0
- package/components/table/shared/getInteractiveRowProps.d.ts +14 -0
- package/components/table/shared/getInteractiveRowProps.js +15 -0
- package/components/table/shared/getInteractiveRowProps.js.map +1 -0
- package/components/table/shared/resolveTableAria.d.ts +2 -0
- package/components/table/shared/resolveTableAria.js +6 -0
- package/components/table/shared/resolveTableAria.js.map +1 -0
- package/components/table/tableSizing.constants.d.ts +4 -0
- package/components/table/tableSizing.constants.js +8 -0
- package/components/table/tableSizing.constants.js.map +1 -0
- package/components/teaser/TeaserContainer.js +3 -3
- package/components/teaser/TeaserContainer.js.map +1 -1
- package/components/virtualList/VirtualList.js +16 -13
- package/components/virtualList/VirtualList.js.map +1 -1
- package/googleAnalyticsUtils.d.ts +1 -0
- package/googleAnalyticsUtils.js +9 -0
- package/googleAnalyticsUtils.js.map +1 -0
- package/hooks/useCookies.js +17 -17
- package/hooks/useCookies.js.map +1 -1
- package/hooks/useDraggableElement.d.ts +35 -0
- package/hooks/useDraggableElement.js +49 -0
- package/hooks/useDraggableElement.js.map +1 -0
- package/hooks/useElapsedTime.js +4 -4
- package/hooks/useElapsedTime.js.map +1 -1
- package/hooks/useLocationSuggestions.js +13 -10
- package/hooks/useLocationSuggestions.js.map +1 -1
- package/hooks/useMergeRefs.js +12 -12
- package/hooks/useMergeRefs.js.map +1 -1
- package/hooks/usePrevious.d.ts +1 -1
- package/hooks/usePrevious.js.map +1 -1
- package/hooks/useResizeObserver.js +25 -10
- package/hooks/useResizeObserver.js.map +1 -1
- package/hooks/useRioCookieConsent.js +7 -4
- package/hooks/useRioCookieConsent.js.map +1 -1
- package/hooks/useSorting.js +10 -10
- package/hooks/useSorting.js.map +1 -1
- package/hooks/useStorage.js +12 -12
- package/hooks/useStorage.js.map +1 -1
- package/hooks/useSum.js +10 -7
- package/hooks/useSum.js.map +1 -1
- package/hooks/useTableSelection.js.map +1 -1
- package/hooks/useTimeout.js +6 -3
- package/hooks/useTimeout.js.map +1 -1
- package/package.json +3 -3
- package/routeUtils.js +12 -10
- package/utils/analytics/analyticsAnalysisUtils.d.ts +27 -0
- package/utils/analytics/analyticsAnalysisUtils.js +161 -0
- package/utils/analytics/analyticsAnalysisUtils.js.map +1 -0
- package/utils/analytics/autoTracking.d.ts +14 -0
- package/utils/analytics/autoTracking.js +19 -0
- package/utils/analytics/autoTracking.js.map +1 -0
- package/utils/analytics/createAnalyticsOverlayTooltip.d.ts +36 -0
- package/utils/analytics/createAnalyticsOverlayTooltip.js +203 -0
- package/utils/analytics/createAnalyticsOverlayTooltip.js.map +1 -0
- package/utils/analytics/googleAnalyticsUtils.d.ts +37 -0
- package/utils/analytics/googleAnalyticsUtils.js +37 -0
- package/utils/analytics/googleAnalyticsUtils.js.map +1 -0
- package/utils/analytics/logAnalyticsOverlayUnmatchedEntries.d.ts +8 -0
- package/utils/analytics/logAnalyticsOverlayUnmatchedEntries.js +61 -0
- package/utils/analytics/logAnalyticsOverlayUnmatchedEntries.js.map +1 -0
- package/utils/analytics/useAnalyticsOverlayDom.d.ts +11 -0
- package/utils/analytics/useAnalyticsOverlayDom.js +120 -0
- package/utils/analytics/useAnalyticsOverlayDom.js.map +1 -0
- package/utils/arrayMove.js +11 -0
- package/utils/arrayMove.js.map +1 -0
- package/utils/cssuseragent.js +2 -2
- package/utils/cssuseragent.js.map +1 -1
- package/utils/deviceUtils.js.map +1 -1
- package/utils/formatUtils.js.map +1 -1
- package/utils/hasUtilityClass.js +3 -3
- package/utils/hasUtilityClass.js.map +1 -1
- package/utils/hidePiiData.js.map +1 -1
- package/utils/init/checkForReleaseVersion.js +4 -4
- package/utils/init/checkForReleaseVersion.js.map +1 -1
- package/utils/init/styledLogs.js.map +1 -1
- package/utils/mergeRefs.js +3 -3
- package/utils/mergeRefs.js.map +1 -1
- package/utils/routeUtils.d.ts +32 -1
- package/utils/routeUtils.js +85 -67
- package/utils/routeUtils.js.map +1 -1
- package/utils/storageUtils.js +9 -9
- package/utils/storageUtils.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +2 -2
- package/version.js.map +1 -1
- package/components/table/TableCol.js.map +0 -1
- package/components/table/TableHead.js.map +0 -1
- package/components/table/TableSettingsColumnButtons.js +0 -45
- package/components/table/TableSettingsColumnButtons.js.map +0 -1
- package/components/table/TableSettingsColumnDetails.js.map +0 -1
- package/components/table/TableSettingsDialog.js +0 -208
- package/components/table/TableSettingsDialog.js.map +0 -1
- package/components/table/TableSettingsDialogFooter.js.map +0 -1
- package/components/table/TableSettingsListContainer.js.map +0 -1
- package/components/table/TableSettingsListItem.js +0 -96
- package/components/table/TableSettingsListItem.js.map +0 -1
- /package/components/table/{TableCol.d.ts → native/TableCol.d.ts} +0 -0
- /package/components/table/{TableCol.js → native/TableCol.js} +0 -0
- /package/components/table/{TableHead.d.ts → native/TableHead.d.ts} +0 -0
- /package/components/table/{TableSettingsColumnButtons.d.ts → native/TableSettingsColumnButtons.d.ts} +0 -0
- /package/components/table/{TableSettingsColumnDetails.d.ts → native/TableSettingsColumnDetails.d.ts} +0 -0
- /package/components/table/{TableSettingsDialogFooter.d.ts → native/TableSettingsDialogFooter.d.ts} +0 -0
- /package/components/table/{TableSettingsListContainer.d.ts → native/TableSettingsListContainer.d.ts} +0 -0
- /package/components/table/{TableSettingsListContainer.js → native/TableSettingsListContainer.js} +0 -0
- /package/components/table/{TableSettingsListItem.d.ts → native/TableSettingsListItem.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback as c } from "react";
|
|
2
|
-
import
|
|
3
|
-
const
|
|
2
|
+
import a from "./useCookies.js";
|
|
3
|
+
const n = (e) => {
|
|
4
4
|
if (!e)
|
|
5
5
|
return {
|
|
6
6
|
cookieName: "cookie_settings",
|
|
@@ -35,8 +35,11 @@ const a = (e) => {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
}, u = () => {
|
|
38
|
-
const { getCookie: e } =
|
|
39
|
-
return { getRioCookieConsentInfo: c(
|
|
38
|
+
const { getCookie: e } = a();
|
|
39
|
+
return { getRioCookieConsentInfo: c(
|
|
40
|
+
() => n(e("cookie_settings")),
|
|
41
|
+
[e]
|
|
42
|
+
) };
|
|
40
43
|
};
|
|
41
44
|
export {
|
|
42
45
|
u as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRioCookieConsent.js","sources":["../../src/hooks/useRioCookieConsent.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nimport useCookies from './useCookies';\n\nexport type RioCookieConsentStatus =\n | 'missing'\n | 'invalid'\n | 'ux-cookies-accepted'\n | 'marketing-cookies-accepted'\n | 'custom';\n\nexport type RioCookieConsentInfo = {\n /**\n * Name of the RIO consent cookie.\n */\n cookieName: 'cookie_settings';\n\n /**\n * Indicates whether the consent cookie exists.\n */\n isSet: boolean;\n\n /**\n * Raw cookie value as read from `document.cookie`.\n */\n rawValue?: string;\n\n /**\n * Parsed and normalized cookie switches when JSON parsing succeeds.\n */\n parsedValue?: Record<string, number>;\n\n /**\n * True when UX cookies are accepted (`switch-49 === 1`).\n */\n uxCookiesAccepted: boolean;\n\n /**\n * True when marketing cookies are accepted (`switch-2 === 1`).\n */\n marketingCookiesAccepted: boolean;\n\n /**\n * Computed consent status derived from parsed cookie values.\n */\n status: RioCookieConsentStatus;\n};\n\nexport type UseRioCookieConsentResult = {\n /**\n * Reads and parses the RIO cookie consent settings.\n */\n getRioCookieConsentInfo: () => RioCookieConsentInfo;\n};\n\nconst evaluateRioCookieSettings = (cookieValue?: string): RioCookieConsentInfo => {\n if (!cookieValue) {\n return {\n cookieName: 'cookie_settings',\n isSet: false,\n uxCookiesAccepted: false,\n marketingCookiesAccepted: false,\n status: 'missing',\n };\n }\n\n try {\n const parsed = JSON.parse(cookieValue) as Record<string, unknown>;\n const uxCookiesAccepted = parsed['switch-49'] === 1;\n const marketingCookiesAccepted = parsed['switch-2'] === 1;\n\n let status: RioCookieConsentStatus = 'custom';\n if (uxCookiesAccepted && !marketingCookiesAccepted) {\n status = 'ux-cookies-accepted';\n } else if (!uxCookiesAccepted && marketingCookiesAccepted) {\n status = 'marketing-cookies-accepted';\n }\n\n return {\n cookieName: 'cookie_settings',\n isSet: true,\n rawValue: cookieValue,\n parsedValue: {\n 'switch-2': Number(parsed['switch-2']),\n 'switch-49': Number(parsed['switch-49']),\n },\n uxCookiesAccepted,\n marketingCookiesAccepted,\n status,\n };\n } catch {\n return {\n cookieName: 'cookie_settings',\n isSet: true,\n rawValue: cookieValue,\n uxCookiesAccepted: false,\n marketingCookiesAccepted: false,\n status: 'invalid',\n };\n }\n};\n\n/**\n * Returns helpers for reading RIO's cookie consent state from `cookie_settings`.\n *\n * @returns {UseRioCookieConsentResult} Cookie consent helper functions.\n *\n * @example\n * const { getRioCookieConsentInfo } = useRioCookieConsent();\n * const consent = getRioCookieConsentInfo();\n * const uxAccepted = consent.uxCookiesAccepted;\n */\nconst useRioCookieConsent = (): UseRioCookieConsentResult => {\n const { getCookie } = useCookies();\n\n const getRioCookieConsentInfo = useCallback(() =>
|
|
1
|
+
{"version":3,"file":"useRioCookieConsent.js","sources":["../../src/hooks/useRioCookieConsent.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nimport useCookies from './useCookies';\n\nexport type RioCookieConsentStatus =\n | 'missing'\n | 'invalid'\n | 'ux-cookies-accepted'\n | 'marketing-cookies-accepted'\n | 'custom';\n\nexport type RioCookieConsentInfo = {\n /**\n * Name of the RIO consent cookie.\n */\n cookieName: 'cookie_settings';\n\n /**\n * Indicates whether the consent cookie exists.\n */\n isSet: boolean;\n\n /**\n * Raw cookie value as read from `document.cookie`.\n */\n rawValue?: string;\n\n /**\n * Parsed and normalized cookie switches when JSON parsing succeeds.\n */\n parsedValue?: Record<string, number>;\n\n /**\n * True when UX cookies are accepted (`switch-49 === 1`).\n */\n uxCookiesAccepted: boolean;\n\n /**\n * True when marketing cookies are accepted (`switch-2 === 1`).\n */\n marketingCookiesAccepted: boolean;\n\n /**\n * Computed consent status derived from parsed cookie values.\n */\n status: RioCookieConsentStatus;\n};\n\nexport type UseRioCookieConsentResult = {\n /**\n * Reads and parses the RIO cookie consent settings.\n */\n getRioCookieConsentInfo: () => RioCookieConsentInfo;\n};\n\nconst evaluateRioCookieSettings = (cookieValue?: string): RioCookieConsentInfo => {\n if (!cookieValue) {\n return {\n cookieName: 'cookie_settings',\n isSet: false,\n uxCookiesAccepted: false,\n marketingCookiesAccepted: false,\n status: 'missing',\n };\n }\n\n try {\n const parsed = JSON.parse(cookieValue) as Record<string, unknown>;\n const uxCookiesAccepted = parsed['switch-49'] === 1;\n const marketingCookiesAccepted = parsed['switch-2'] === 1;\n\n let status: RioCookieConsentStatus = 'custom';\n if (uxCookiesAccepted && !marketingCookiesAccepted) {\n status = 'ux-cookies-accepted';\n } else if (!uxCookiesAccepted && marketingCookiesAccepted) {\n status = 'marketing-cookies-accepted';\n }\n\n return {\n cookieName: 'cookie_settings',\n isSet: true,\n rawValue: cookieValue,\n parsedValue: {\n 'switch-2': Number(parsed['switch-2']),\n 'switch-49': Number(parsed['switch-49']),\n },\n uxCookiesAccepted,\n marketingCookiesAccepted,\n status,\n };\n } catch {\n return {\n cookieName: 'cookie_settings',\n isSet: true,\n rawValue: cookieValue,\n uxCookiesAccepted: false,\n marketingCookiesAccepted: false,\n status: 'invalid',\n };\n }\n};\n\n/**\n * Returns helpers for reading RIO's cookie consent state from `cookie_settings`.\n *\n * @returns {UseRioCookieConsentResult} Cookie consent helper functions.\n *\n * @example\n * const { getRioCookieConsentInfo } = useRioCookieConsent();\n * const consent = getRioCookieConsentInfo();\n * const uxAccepted = consent.uxCookiesAccepted;\n */\nconst useRioCookieConsent = (): UseRioCookieConsentResult => {\n const { getCookie } = useCookies();\n\n const getRioCookieConsentInfo = useCallback(\n () => evaluateRioCookieSettings(getCookie('cookie_settings')),\n [getCookie]\n );\n\n return { getRioCookieConsentInfo };\n};\n\nexport default useRioCookieConsent;\n"],"names":["evaluateRioCookieSettings","cookieValue","parsed","uxCookiesAccepted","marketingCookiesAccepted","status","useRioCookieConsent","getCookie","useCookies","useCallback"],"mappings":";;AAuDA,MAAMA,IAA4B,CAACC,MAA+C;AAC9E,MAAI,CAACA;AACD,WAAO;AAAA,MACH,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,0BAA0B;AAAA,MAC1B,QAAQ;AAAA,IAAA;AAIhB,MAAI;AACA,UAAMC,IAAS,KAAK,MAAMD,CAAW,GAC/BE,IAAoBD,EAAO,WAAW,MAAM,GAC5CE,IAA2BF,EAAO,UAAU,MAAM;AAExD,QAAIG,IAAiC;AACrC,WAAIF,KAAqB,CAACC,IACtBC,IAAS,wBACF,CAACF,KAAqBC,MAC7BC,IAAS,+BAGN;AAAA,MACH,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,UAAUJ;AAAA,MACV,aAAa;AAAA,QACT,YAAY,OAAOC,EAAO,UAAU,CAAC;AAAA,QACrC,aAAa,OAAOA,EAAO,WAAW,CAAC;AAAA,MAAA;AAAA,MAE3C,mBAAAC;AAAA,MACA,0BAAAC;AAAA,MACA,QAAAC;AAAA,IAAA;AAAA,EAER,QAAQ;AACJ,WAAO;AAAA,MACH,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,UAAUJ;AAAA,MACV,mBAAmB;AAAA,MACnB,0BAA0B;AAAA,MAC1B,QAAQ;AAAA,IAAA;AAAA,EAEhB;AACJ,GAYMK,IAAsB,MAAiC;AACzD,QAAM,EAAE,WAAAC,EAAA,IAAcC,EAAA;AAOtB,SAAO,EAAE,yBALuBC;AAAA,IAC5B,MAAMT,EAA0BO,EAAU,iBAAiB,CAAC;AAAA,IAC5D,CAACA,CAAS;AAAA,EAAA,EAGL;AACb;"}
|
package/hooks/useSorting.js
CHANGED
|
@@ -3,24 +3,24 @@ import { SortDirection as t, naturalSortByProperty as m } from "../utils/SortUti
|
|
|
3
3
|
const K = (c, I, d = t.ASCENDING, D = !0, N = !1) => {
|
|
4
4
|
const [o, g] = f(I), [e, a] = f(d);
|
|
5
5
|
return { sortedItems: l(() => {
|
|
6
|
-
const
|
|
7
|
-
const r = p[
|
|
8
|
-
return r <
|
|
6
|
+
const s = (n, i) => D ? m(n, i, e, N) : n.sort((p, y) => {
|
|
7
|
+
const r = p[i], u = y[i];
|
|
8
|
+
return r < u ? e === t.ASCENDING ? -1 : 1 : r > u ? e === t.ASCENDING ? 1 : -1 : 0;
|
|
9
9
|
});
|
|
10
10
|
if (Array.isArray(o)) {
|
|
11
|
-
const [
|
|
12
|
-
(r,
|
|
13
|
-
const S = String(
|
|
14
|
-
return r[S] || (r[S] = []), r[S].push(
|
|
11
|
+
const [n, i] = o, y = s(c, n).reduce(
|
|
12
|
+
(r, u) => {
|
|
13
|
+
const S = String(u[n]);
|
|
14
|
+
return r[S] || (r[S] = []), r[S].push(u), r;
|
|
15
15
|
},
|
|
16
16
|
{}
|
|
17
17
|
);
|
|
18
|
-
return Object.values(y).flatMap((r) =>
|
|
18
|
+
return Object.values(y).flatMap((r) => s(r, i));
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return s(c, o);
|
|
21
21
|
}, [c, o, e, D, N]), sortKey: o, sortDirection: e, setSortKey: g, setSortDirection: a, toggleDirection: () => {
|
|
22
22
|
a(
|
|
23
|
-
(
|
|
23
|
+
(s) => s === t.ASCENDING ? t.DESCENDING : t.ASCENDING
|
|
24
24
|
);
|
|
25
25
|
} };
|
|
26
26
|
};
|
package/hooks/useSorting.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSorting.js","sources":["../../src/hooks/useSorting.ts"],"sourcesContent":["import { useState, useMemo } from 'react';\n\nimport { naturalSortByProperty, SortDirection, type SortDirectionType } from '../utils/SortUtils';\n\ntype SortKey<T> = keyof T | [keyof T, keyof T];\n\ntype UseSortingResult<T> = {\n /**\n * The sorted data\n */\n sortedItems: T[];\n\n /**\n * The key(s) to sort the data for\n */\n sortKey: SortKey<T>;\n\n /**\n * The current direction that the data is sorted\n */\n sortDirection: SortDirectionType;\n\n /**\n * Function to change the sorting key(s) afterwards\n * @param newKey the new sorting key(s)\n * @returns\n */\n setSortKey: (newKey: SortKey<T>) => void;\n\n /**\n * Function to change the sorting order afterwards\n * @param newKey the new sorting key(s)\n * @returns\n */\n setSortDirection: (newSortDirection: SortDirectionType) => void;\n\n /**\n * Function to toggle the sorting between ascending and descending order\n * @returns\n */\n toggleDirection: () => void;\n};\n\nconst useSorting = <T>(\n items: T[],\n initialKey: SortKey<T>,\n initialDirection: SortDirectionType = SortDirection.ASCENDING,\n enableNaturalSort = true,\n isCaseSensitive = false\n): UseSortingResult<T> => {\n const [sortKey, setSortKey] = useState<SortKey<T>>(initialKey);\n const [sortDirection, setSortDirection] = useState<SortDirectionType>(initialDirection);\n\n const sortedItems = useMemo(() => {\n const sortByKey = (arr: T[], key: keyof T)
|
|
1
|
+
{"version":3,"file":"useSorting.js","sources":["../../src/hooks/useSorting.ts"],"sourcesContent":["import { useState, useMemo } from 'react';\n\nimport { naturalSortByProperty, SortDirection, type SortDirectionType } from '../utils/SortUtils';\n\ntype SortKey<T> = keyof T | [keyof T, keyof T];\n\ntype UseSortingResult<T> = {\n /**\n * The sorted data\n */\n sortedItems: T[];\n\n /**\n * The key(s) to sort the data for\n */\n sortKey: SortKey<T>;\n\n /**\n * The current direction that the data is sorted\n */\n sortDirection: SortDirectionType;\n\n /**\n * Function to change the sorting key(s) afterwards\n * @param newKey the new sorting key(s)\n * @returns\n */\n setSortKey: (newKey: SortKey<T>) => void;\n\n /**\n * Function to change the sorting order afterwards\n * @param newKey the new sorting key(s)\n * @returns\n */\n setSortDirection: (newSortDirection: SortDirectionType) => void;\n\n /**\n * Function to toggle the sorting between ascending and descending order\n * @returns\n */\n toggleDirection: () => void;\n};\n\nconst useSorting = <T>(\n items: T[],\n initialKey: SortKey<T>,\n initialDirection: SortDirectionType = SortDirection.ASCENDING,\n enableNaturalSort = true,\n isCaseSensitive = false\n): UseSortingResult<T> => {\n const [sortKey, setSortKey] = useState<SortKey<T>>(initialKey);\n const [sortDirection, setSortDirection] = useState<SortDirectionType>(initialDirection);\n\n const sortedItems = useMemo(() => {\n const sortByKey = (arr: T[], key: keyof T) =>\n enableNaturalSort\n ? naturalSortByProperty(arr, key, sortDirection, isCaseSensitive)\n : arr.sort((a, b) => {\n const aVal = a[key];\n const bVal = b[key];\n if (aVal < bVal) {\n return sortDirection === SortDirection.ASCENDING ? -1 : 1;\n }\n if (aVal > bVal) {\n return sortDirection === SortDirection.ASCENDING ? 1 : -1;\n }\n return 0;\n });\n\n if (Array.isArray(sortKey)) {\n const [primaryKey, secondaryKey] = sortKey;\n const primarySorted = sortByKey(items, primaryKey);\n\n // Group items with the same primary key value\n const groups = primarySorted.reduce(\n (acc, item) => {\n const key = String(item[primaryKey]);\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(item);\n return acc;\n },\n {} as Record<string, T[]>\n );\n\n // Sort each group by the secondary key and flatten the result\n return Object.values(groups).flatMap(group => sortByKey(group, secondaryKey));\n }\n return sortByKey(items, sortKey);\n }, [items, sortKey, sortDirection, enableNaturalSort, isCaseSensitive]);\n\n const toggleDirection = () => {\n setSortDirection(prev =>\n prev === SortDirection.ASCENDING ? SortDirection.DESCENDING : SortDirection.ASCENDING\n );\n };\n\n return { sortedItems, sortKey, sortDirection, setSortKey, setSortDirection, toggleDirection };\n};\n\nexport default useSorting;\n"],"names":["useSorting","items","initialKey","initialDirection","SortDirection","enableNaturalSort","isCaseSensitive","sortKey","setSortKey","useState","sortDirection","setSortDirection","useMemo","sortByKey","arr","key","naturalSortByProperty","a","b","aVal","bVal","primaryKey","secondaryKey","groups","acc","item","group","prev"],"mappings":";;AA2CA,MAAMA,IAAa,CACfC,GACAC,GACAC,IAAsCC,EAAc,WACpDC,IAAoB,IACpBC,IAAkB,OACI;AACtB,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAqBP,CAAU,GACvD,CAACQ,GAAeC,CAAgB,IAAIF,EAA4BN,CAAgB;AA+CtF,SAAO,EAAE,aA7CWS,EAAQ,MAAM;AAC9B,UAAMC,IAAY,CAACC,GAAUC,MACzBV,IACMW,EAAsBF,GAAKC,GAAKL,GAAeJ,CAAe,IAC9DQ,EAAI,KAAK,CAACG,GAAGC,MAAM;AACf,YAAMC,IAAOF,EAAEF,CAAG,GACZK,IAAOF,EAAEH,CAAG;AAClB,aAAII,IAAOC,IACAV,MAAkBN,EAAc,YAAY,KAAK,IAExDe,IAAOC,IACAV,MAAkBN,EAAc,YAAY,IAAI,KAEpD;AAAA,IACX,CAAC;AAEX,QAAI,MAAM,QAAQG,CAAO,GAAG;AACxB,YAAM,CAACc,GAAYC,CAAY,IAAIf,GAI7BgB,IAHgBV,EAAUZ,GAAOoB,CAAU,EAGpB;AAAA,QACzB,CAACG,GAAKC,MAAS;AACX,gBAAMV,IAAM,OAAOU,EAAKJ,CAAU,CAAC;AACnC,iBAAKG,EAAIT,CAAG,MACRS,EAAIT,CAAG,IAAI,CAAA,IAEfS,EAAIT,CAAG,EAAE,KAAKU,CAAI,GACXD;AAAA,QACX;AAAA,QACA,CAAA;AAAA,MAAC;AAIL,aAAO,OAAO,OAAOD,CAAM,EAAE,QAAQ,CAAAG,MAASb,EAAUa,GAAOJ,CAAY,CAAC;AAAA,IAChF;AACA,WAAOT,EAAUZ,GAAOM,CAAO;AAAA,EACnC,GAAG,CAACN,GAAOM,GAASG,GAAeL,GAAmBC,CAAe,CAAC,GAQhD,SAAAC,GAAS,eAAAG,GAAe,YAAAF,GAAY,kBAAAG,GAAkB,iBANpD,MAAM;AAC1B,IAAAA;AAAA,MAAiB,OACbgB,MAASvB,EAAc,YAAYA,EAAc,aAAaA,EAAc;AAAA,IAAA;AAAA,EAEpF,EAE4E;AAChF;"}
|
package/hooks/useStorage.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
const a = (e,
|
|
3
|
-
const
|
|
4
|
-
const n =
|
|
5
|
-
return n ? JSON.parse(n) : typeof
|
|
1
|
+
import { useState as S, useEffect as g, useCallback as u } from "react";
|
|
2
|
+
const a = (e, o, c) => {
|
|
3
|
+
const t = c === "localStorage" ? window.localStorage : window.sessionStorage, [s, r] = S(() => {
|
|
4
|
+
const n = t.getItem(e);
|
|
5
|
+
return n ? JSON.parse(n) : typeof o == "function" ? o() : o;
|
|
6
6
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, [e,
|
|
10
|
-
const i =
|
|
11
|
-
|
|
7
|
+
g(() => {
|
|
8
|
+
s ? t.setItem(e, JSON.stringify(s)) : t.removeItem(e);
|
|
9
|
+
}, [e, s, t]);
|
|
10
|
+
const i = u(() => {
|
|
11
|
+
r(void 0);
|
|
12
12
|
}, []);
|
|
13
|
-
return [
|
|
14
|
-
}, f = (e,
|
|
13
|
+
return [s, r, i];
|
|
14
|
+
}, f = (e, o) => a(e, o, "localStorage"), m = (e, o) => a(e, o, "sessionStorage");
|
|
15
15
|
export {
|
|
16
16
|
f as useLocalStorage,
|
|
17
17
|
m as useSessionStorage
|
package/hooks/useStorage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStorage.js","sources":["../../src/hooks/useStorage.ts"],"sourcesContent":["// Inspired by https://github.com/WebDevSimplified/useful-custom-react-hooks/blob/main/src/8-useStorage/useStorage.js\nimport { useCallback, useState, useEffect } from 'react';\n\nexport type StorageType = 'localStorage' | 'sessionStorage';\n\n/**\n * A custom hook for managing state stored in localStorage or sessionStorage.\n *\n * @param key The key under which the state will be stored.\n * @param defaultValue The initial value for the state, or a function that returns the initial value.\n * @param storageType The type of storage to use: localStorage or sessionStorage.\n *\n * @returns A tuple containing the state value, a function to update the state, and a function\n * to remove the value from storage.\n */\nconst useStorage = <T>(\n key: string,\n defaultValue: T | (() => T),\n storageType: StorageType\n): [T | undefined, React.Dispatch<React.SetStateAction<T | undefined>>, () => void] => {\n // Determine the storage object based on the specified storage type\n const storageObject = storageType === 'localStorage' ? window.localStorage : window.sessionStorage;\n\n // Initialize state with the value from storage, or the default value\n const [value, setValue] = useState<T | undefined>(() => {\n const jsonValue = storageObject.getItem(key);\n\n if (jsonValue) {\n return JSON.parse(jsonValue);\n }\n\n if (typeof defaultValue === 'function') {\n return (defaultValue as Function)();\n }\n\n return defaultValue;\n });\n\n // Update storage whenever the value changes\n useEffect(() => {\n if (!value) {\n storageObject.removeItem(key);\n } else {\n storageObject.setItem(key, JSON.stringify(value));\n }\n }, [key, value, storageObject]);\n\n // Callback to remove the value from storage\n const remove = useCallback(() => {\n setValue(undefined);\n }, []);\n\n return [value, setValue, remove];\n};\n\n/**\n * A custom hook for managing state stored in localStorage.\n *\n * @param key The key under which the state will be stored in localStorage.\n * @param defaultValue The initial value for the state, or a function that returns the initial value.\n *\n * @returns A tuple containing the state value, a function to update the state, and a function\n * to remove the value from localStorage.\n */\nexport const useLocalStorage = <T>(\n key: string,\n defaultValue: T | (() => T)\n): [T | undefined, React.Dispatch<React.SetStateAction<T | undefined>>, () => void]
|
|
1
|
+
{"version":3,"file":"useStorage.js","sources":["../../src/hooks/useStorage.ts"],"sourcesContent":["// Inspired by https://github.com/WebDevSimplified/useful-custom-react-hooks/blob/main/src/8-useStorage/useStorage.js\nimport { useCallback, useState, useEffect } from 'react';\n\nexport type StorageType = 'localStorage' | 'sessionStorage';\n\n/**\n * A custom hook for managing state stored in localStorage or sessionStorage.\n *\n * @param key The key under which the state will be stored.\n * @param defaultValue The initial value for the state, or a function that returns the initial value.\n * @param storageType The type of storage to use: localStorage or sessionStorage.\n *\n * @returns A tuple containing the state value, a function to update the state, and a function\n * to remove the value from storage.\n */\nconst useStorage = <T>(\n key: string,\n defaultValue: T | (() => T),\n storageType: StorageType\n): [T | undefined, React.Dispatch<React.SetStateAction<T | undefined>>, () => void] => {\n // Determine the storage object based on the specified storage type\n const storageObject = storageType === 'localStorage' ? window.localStorage : window.sessionStorage;\n\n // Initialize state with the value from storage, or the default value\n const [value, setValue] = useState<T | undefined>(() => {\n const jsonValue = storageObject.getItem(key);\n\n if (jsonValue) {\n return JSON.parse(jsonValue);\n }\n\n if (typeof defaultValue === 'function') {\n return (defaultValue as Function)();\n }\n\n return defaultValue;\n });\n\n // Update storage whenever the value changes\n useEffect(() => {\n if (!value) {\n storageObject.removeItem(key);\n } else {\n storageObject.setItem(key, JSON.stringify(value));\n }\n }, [key, value, storageObject]);\n\n // Callback to remove the value from storage\n const remove = useCallback(() => {\n setValue(undefined);\n }, []);\n\n return [value, setValue, remove];\n};\n\n/**\n * A custom hook for managing state stored in localStorage.\n *\n * @param key The key under which the state will be stored in localStorage.\n * @param defaultValue The initial value for the state, or a function that returns the initial value.\n *\n * @returns A tuple containing the state value, a function to update the state, and a function\n * to remove the value from localStorage.\n */\nexport const useLocalStorage = <T>(\n key: string,\n defaultValue: T | (() => T)\n): [T | undefined, React.Dispatch<React.SetStateAction<T | undefined>>, () => void] =>\n useStorage<T>(key, defaultValue, 'localStorage');\n\n/**\n * A custom hook for managing state stored in sessionStorage.\n *\n * @param key The key under which the state will be stored in sessionStorage.\n * @param defaultValue The initial value for the state, or a function that returns the initial value.\n *\n * @returns A tuple containing the state value, a function to update the state,\n * and a function to remove the value from sessionStorage.\n */\nexport const useSessionStorage = <T>(\n key: string,\n defaultValue: T | (() => T)\n): [T | undefined, React.Dispatch<React.SetStateAction<T | undefined>>, () => void] =>\n useStorage<T>(key, defaultValue, 'sessionStorage');\n"],"names":["useStorage","key","defaultValue","storageType","storageObject","value","setValue","useState","jsonValue","useEffect","remove","useCallback","useLocalStorage","useSessionStorage"],"mappings":";AAeA,MAAMA,IAAa,CACfC,GACAC,GACAC,MACmF;AAEnF,QAAMC,IAAgBD,MAAgB,iBAAiB,OAAO,eAAe,OAAO,gBAG9E,CAACE,GAAOC,CAAQ,IAAIC,EAAwB,MAAM;AACpD,UAAMC,IAAYJ,EAAc,QAAQH,CAAG;AAE3C,WAAIO,IACO,KAAK,MAAMA,CAAS,IAG3B,OAAON,KAAiB,aAChBA,EAAA,IAGLA;AAAA,EACX,CAAC;AAGD,EAAAO,EAAU,MAAM;AACZ,IAAKJ,IAGDD,EAAc,QAAQH,GAAK,KAAK,UAAUI,CAAK,CAAC,IAFhDD,EAAc,WAAWH,CAAG;AAAA,EAIpC,GAAG,CAACA,GAAKI,GAAOD,CAAa,CAAC;AAG9B,QAAMM,IAASC,EAAY,MAAM;AAC7B,IAAAL,EAAS,MAAS;AAAA,EACtB,GAAG,CAAA,CAAE;AAEL,SAAO,CAACD,GAAOC,GAAUI,CAAM;AACnC,GAWaE,IAAkB,CAC3BX,GACAC,MAEAF,EAAcC,GAAKC,GAAc,cAAc,GAWtCW,IAAoB,CAC7BZ,GACAC,MAEAF,EAAcC,GAAKC,GAAc,gBAAgB;"}
|
package/hooks/useSum.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { useMemo as
|
|
1
|
+
import { useMemo as n } from "react";
|
|
2
2
|
import { getValueByPath as c, parseNumberFromValue as l } from "../utils/formatUtils.js";
|
|
3
|
-
const B = (e, r,
|
|
4
|
-
const { locale:
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const B = (e, r, u = {}) => {
|
|
4
|
+
const { locale: o = "en-GB" } = u;
|
|
5
|
+
return n(
|
|
6
|
+
() => e.reduce((t, s) => {
|
|
7
|
+
const m = c(s, r), a = l(m, o);
|
|
8
|
+
return t + a;
|
|
9
|
+
}, 0),
|
|
10
|
+
[e, r, o]
|
|
11
|
+
);
|
|
9
12
|
};
|
|
10
13
|
export {
|
|
11
14
|
B as default
|
package/hooks/useSum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSum.js","sources":["../../src/hooks/useSum.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nimport { parseNumberFromValue, getValueByPath } from '../utils/formatUtils';\n\nexport type UseSumOptions = {\n /**\n * The locale used to parse localized number formats (e.g. \"de-DE\", \"en-GB\").\n * @default \"en-GB\".\n */\n locale?: string;\n};\n\n/**\n * Calculates the sum of numeric values from a list of objects, using a defined property path.\n * Supports localized number strings (e.g. \"1.234,56 €\", \"1,000.75\").\n *\n * @param items - The list of objects to sum values from.\n * @param path - The dot-separated path to the target value in each object.\n * @param options - Optional configuration such as locale for parsing.\n * @returns The total sum of all valid parsed values as a number.\n */\nconst useSum = (items: unknown[], path: string, options: UseSumOptions = {}): number => {\n const { locale = 'en-GB' } = options;\n\n const sum = useMemo(()
|
|
1
|
+
{"version":3,"file":"useSum.js","sources":["../../src/hooks/useSum.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nimport { parseNumberFromValue, getValueByPath } from '../utils/formatUtils';\n\nexport type UseSumOptions = {\n /**\n * The locale used to parse localized number formats (e.g. \"de-DE\", \"en-GB\").\n * @default \"en-GB\".\n */\n locale?: string;\n};\n\n/**\n * Calculates the sum of numeric values from a list of objects, using a defined property path.\n * Supports localized number strings (e.g. \"1.234,56 €\", \"1,000.75\").\n *\n * @param items - The list of objects to sum values from.\n * @param path - The dot-separated path to the target value in each object.\n * @param options - Optional configuration such as locale for parsing.\n * @returns The total sum of all valid parsed values as a number.\n */\nconst useSum = (items: unknown[], path: string, options: UseSumOptions = {}): number => {\n const { locale = 'en-GB' } = options;\n\n const sum = useMemo(\n () =>\n items.reduce((total: number, item: unknown) => {\n const raw = getValueByPath(item, path);\n const value = parseNumberFromValue(raw, locale);\n\n return total + value;\n }, 0),\n [items, path, locale]\n );\n\n return sum;\n};\n\nexport default useSum;\n"],"names":["useSum","items","path","options","locale","useMemo","total","item","raw","getValueByPath","value","parseNumberFromValue"],"mappings":";;AAqBA,MAAMA,IAAS,CAACC,GAAkBC,GAAcC,IAAyB,CAAA,MAAe;AACpF,QAAM,EAAE,QAAAC,IAAS,QAAA,IAAYD;AAa7B,SAXYE;AAAA,IACR,MACIJ,EAAM,OAAO,CAACK,GAAeC,MAAkB;AAC3C,YAAMC,IAAMC,EAAeF,GAAML,CAAI,GAC/BQ,IAAQC,EAAqBH,GAAKJ,CAAM;AAE9C,aAAOE,IAAQI;AAAA,IACnB,GAAG,CAAC;AAAA,IACR,CAACT,GAAOC,GAAME,CAAM;AAAA,EAAA;AAI5B;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableSelection.js","sources":["../../src/hooks/useTableSelection.ts"],"sourcesContent":["import { useState, useRef, useCallback, useEffect } from 'react';\n\n/**\n * CSS class applied to the currently active row.\n */\nexport const ACTIVE_CLASS = 'active';\n\n/**\n * Default HTML data attribute name used to store the unique ID on table row elements.\n */\nexport const DEFAULT_DATA_ATTRIBUTE = 'data-id';\n\n// Default classes for the checkbox and action cells\nexport const DEFAULT_TABLE_CHECKBOX_CELL_CLASS = '.table-checkbox';\nexport const DEFAULT_TABLE_ACTION_CELL_CLASS = '.table-action';\n\n/**\n * Options for the `useTableSelection` hook.\n */\nexport type UseTableSelectionOptions<TData extends Record<string, any>> = {\n /**\n * The array of data items to be displayed in the table.\n * The hook uses this to determine all possible row IDs for \"select all\" functionality.\n */\n tableData: TData[];\n\n /**\n * The key in `TData` objects that serves as the unique identifier for each row.\n */\n idKey: keyof TData;\n\n /**\n * Optional array of row IDs that should be initially selected.\n */\n initialSelectedRowIds?: string[];\n\n /**\n * Optional ID of the row that should be initially marked as active.\n */\n initialActiveRowId?: string;\n\n // customize reference values\n\n /**\n * Optional CSS query selector to find the checkbox input element within each table row.\n * @default '.table-checkbox input[type=\"checkbox\"]'\n */\n checkboxQuerySelector?: string;\n\n /**\n * Optional name of the HTML data attribute on `<tr>` elements that holds the unique row ID.\n * @default 'data-id' (matches DEFAULT_DATA_ATTRIBUTE)\n */\n dataAttributeName?: string;\n\n /**\n * Optional external ref for the table element. If not provided, the hook creates its own.\n * Useful if the parent component needs direct access to the table DOM element for other purposes.\n */\n ref?: React.RefObject<HTMLTableElement>;\n};\n\n/**\n * Return value of the `useTableSelection` hook.\n */\nexport type UseTableSelectionReturn = {\n /**\n * React ref attached to the `<table>` HTML element.\n * Ensure this ref is assigned to your table element to enable DOM manipulations.\n */\n tableRef: React.RefObject<HTMLTableElement>;\n\n /**\n * An array of strings, where each string is the ID of a currently selected row.\n */\n selectedRowIds: string[];\n\n /**\n * The ID of the currently active row. An empty string signifies no row is active.\n */\n activeRowId: string;\n\n /**\n * Callback handler to be attached to the click/change event of individual row selection UI elements (e.g., checkboxes).\n * It expects the clicked element to be within a `<tr>` that has the specified `dataAttributeName`.\n * Manages the selection state of a single row.\n *\n * @param event The React mouse event from the selection UI element.\n */\n onSelection: (event: React.MouseEvent<HTMLElement>) => void;\n\n /**\n * Callback handler to be attached to the click event of table row (`<tr>`) elements.\n * Manages the active row state.\n * @param event The React mouse event from the `<tr>` element.\n */\n onActiveRowChange: (event: React.MouseEvent<HTMLTableRowElement>) => void;\n\n /**\n * Callback handler to select or deselect all rows.\n * @param shouldSelect If true, all rows in `tableData` will be selected; otherwise, all selections will be cleared.\n */\n onToggleAll: (shouldSelect: boolean) => void;\n\n /**\n * Function to update row selection and active highlighting. This is useful when the row data changes due to a search value\n * or any other filter.\n *\n * @returns\n */\n updateRowSelection: () => void;\n\n /**\n * Setter function to change selected rows from the outside in a controlled manner.\n *\n * @param rowIds\n * @returns\n */\n setSelectedRowIds: (rowIds: string[]) => void;\n\n /**\n * Setter function to change the active row from the outside in a controlled manner.\n * Use this to deselect an active row.\n *\n * @param activeRowId\n * @returns\n */\n setActiveRowId: (activeRowId: string | undefined) => void;\n\n /**\n * A boolean indicating whether at least one row is currently selected.\n */\n hasSelection: boolean;\n\n /**\n * A boolean indicating whether all rows in the current `tableData` are selected.\n */\n isAllSelected: boolean;\n};\n\n/**\n * A React hook to manage row selection and active row state for an HTML table,\n * including DOM manipulations for visual feedback to optimize performance by\n * preventing individual row re-renders.\n *\n * @param {UseTableSelectionOptions<TData>} options The configuration properties for the hook.\n * @returns {UseTableSelectionReturn} The state and handlers for managing table selection and active row.\n */\nconst useTableSelection = <TData extends Record<string, any>>(\n props: UseTableSelectionOptions<TData>\n): UseTableSelectionReturn => {\n const {\n tableData,\n idKey,\n initialSelectedRowIds = [],\n initialActiveRowId = '',\n checkboxQuerySelector = '.table-checkbox input[type=\"checkbox\"]',\n dataAttributeName = DEFAULT_DATA_ATTRIBUTE,\n ref,\n } = props;\n\n const [selectedRowIds, setSelectedRowIds] = useState<string[]>(initialSelectedRowIds);\n const [activeRowId, setActiveRowId] = useState<string>(initialActiveRowId);\n const [lastActiveRowId, setLastActiveRowId] = useState<string>(initialActiveRowId);\n\n const internalTableRef = useRef<HTMLTableElement>(null);\n const tableRef = ref ?? internalTableRef;\n\n // --- DOM Manipulation Effect (The performance workaround) ---\n /**\n * Effect to handle DOM manipulations for active row highlighting and ensuring\n * checkboxes for selected rows are visually checked.\n * This effect runs when active row state or selection state changes.\n * Note: This effect currently only *selects* rows based on `selectedRowIds`.\n * Deselection in the DOM is handled directly by `onSelection` and `onToggleAll` handlers.\n * For a more centralized DOM update, this effect could be expanded to handle deselection as well.\n */\n useEffect(() => {\n updateRowSelection();\n }, [activeRowId, lastActiveRowId, selectedRowIds]); // Rerun when these change\n\n const updateRowSelection = () => {\n if (!tableRef.current) {\n return;\n }\n\n const rows = [...tableRef.current.rows] as HTMLTableRowElement[];\n\n if (lastActiveRowId !== activeRowId) {\n // Due to performance reasons the individual rows should not re-render when the\n // selected driver changes, hence we need to avoid passing that information as props\n // to the row component otherwise it would re-render as the props have changed.\n // Instead, we check here which row to highlight.\n removeHighlightFromRow(rows, lastActiveRowId, dataAttributeName);\n highlightRow(rows, activeRowId, dataAttributeName);\n }\n\n // handle multi-selection\n selectedRowIds.forEach(rowId => {\n selectRow(rows, rowId, dataAttributeName, checkboxQuerySelector);\n });\n };\n\n const handleActiveRowChange = useCallback((event: React.MouseEvent<HTMLTableRowElement>) => {\n event.preventDefault();\n event.stopPropagation();\n\n const targetRow = event.currentTarget;\n const rowId = targetRow.getAttribute(dataAttributeName) ?? '';\n\n // Avoid activation if click is on checkbox/action area (more robust check needed if complex row structure)\n const clickedElement = event.target as HTMLElement;\n const isCheckboxCell = clickedElement.closest(DEFAULT_TABLE_CHECKBOX_CELL_CLASS);\n const isActionCell = clickedElement.closest(DEFAULT_TABLE_ACTION_CELL_CLASS);\n if (isCheckboxCell || isActionCell) {\n return;\n }\n\n changeActiveRow(rowId);\n }, []);\n\n const changeActiveRow = (rowId = '') => {\n setActiveRowId(currentActiveRow => {\n const newActiveRowId = currentActiveRow === rowId ? '' : rowId;\n setLastActiveRowId(currentActiveRow); // Update lastActive for the effect\n return newActiveRowId;\n });\n };\n\n const handleSelection = useCallback((event: React.MouseEvent<HTMLElement>) => {\n event.preventDefault();\n event.stopPropagation();\n\n // Find the correct row element containing the data attribute\n const rowElement = (event.target as HTMLElement).closest(`tr[${dataAttributeName}]`);\n const selectedRowId = rowElement?.getAttribute(dataAttributeName);\n\n if (!selectedRowId) {\n console.warn('Could not find row ID for selection event.');\n return;\n }\n\n setSelectedRowIds(prevSelectedRowIds => {\n if (prevSelectedRowIds.includes(selectedRowId)) {\n deselectRows([selectedRowId]);\n return prevSelectedRowIds.filter(id => id !== selectedRowId);\n }\n return [...prevSelectedRowIds, selectedRowId];\n });\n }, []);\n\n const handleToggleAll = useCallback(\n (shouldSelect: boolean) => {\n const allRowIds = tableData.map(row => `${row[idKey]}`);\n setSelectedRowIds(shouldSelect ? allRowIds : []);\n\n // Deselect all rows when there is at least one row selected, else select all rows\n if (shouldSelect) {\n setSelectedRowIds(allRowIds);\n } else {\n setSelectedRowIds([]);\n deselectRows(allRowIds);\n\n for (const id in allRowIds) {\n const rows = tableRef.current ? [...tableRef.current.rows] : [];\n deselectRow([...rows] as HTMLTableRowElement[], id, dataAttributeName, checkboxQuerySelector);\n }\n }\n // DOM updates are handled by useEffect -> updateRowsDOM\n },\n [tableData]\n );\n\n const deselectRows = (rowIds: string[]) => {\n const rows = tableRef.current ? [...tableRef.current.rows] : [];\n rowIds.forEach(rowId => {\n deselectRow(rows, rowId, dataAttributeName, checkboxQuerySelector);\n });\n };\n\n const hasSelection = selectedRowIds.length > 0;\n const isAllSelected = hasSelection && selectedRowIds.length === tableData.length && tableData.length > 0;\n\n // --- Return hook state and handlers ---\n return {\n tableRef,\n selectedRowIds,\n activeRowId,\n onSelection: handleSelection,\n onActiveRowChange: handleActiveRowChange,\n onToggleAll: handleToggleAll,\n updateRowSelection,\n setSelectedRowIds: (rowIds: string[]) => setSelectedRowIds(rowIds),\n setActiveRowId: (activeRowId: string | undefined) => changeActiveRow(activeRowId),\n hasSelection,\n isAllSelected,\n };\n};\n\n/**\n * Finds a table row element by its data attribute value.\n *\n * @param rows Array of HTMLTableRowElements to search within.\n * @param value The value of the data attribute to find.\n * @param attribute The name of the data attribute (e.g., 'data-id').\n * @returns The found HTMLTableRowElement or undefined.\n */\nexport const getRowByDataAttribute = (\n rows: HTMLTableRowElement[],\n value: string | null | undefined,\n attribute: string\n): HTMLTableRowElement | undefined => {\n if (!value) {\n return undefined;\n }\n return rows.find(row => row.getAttribute(attribute) === value);\n};\n\n/**\n * Adds an \"active\" class to a specified table row.\n *\n * @param rows Array of HTMLTableRowElements to search within.\n * @param rowId The ID of the row to highlight.\n * @param dataAttributeName The data attribute used to identify the row.\n */\nexport const highlightRow = (rows: HTMLTableRowElement[], rowId: string | null, dataAttributeName: string) => {\n const row = getRowByDataAttribute(rows, rowId, dataAttributeName);\n row?.classList.add(ACTIVE_CLASS);\n};\n\n/**\n * Removes the \"active\" class from a specified table row.\n *\n * @param rows Array of HTMLTableRowElements to search within.\n * @param rowId The ID of the row to unhighlight.\n * @param dataAttributeName The data attribute used to identify the row.\n */\nexport const removeHighlightFromRow = (\n rows: HTMLTableRowElement[],\n rowId: string | null,\n dataAttributeName: string\n) => {\n const row = getRowByDataAttribute(rows, rowId, dataAttributeName);\n row?.classList.remove(ACTIVE_CLASS);\n};\n\n// Helper to get the checkbox input for a single row\nconst getCheckboxFromRow = (row: HTMLTableRowElement, checkboxQuerySelector: string): HTMLInputElement | null => {\n return row.querySelector(checkboxQuerySelector);\n};\n\n/**\n * Sets the checked state of a checkbox within a specific table row.\n * @param rows Array of HTMLTableRowElements to search within.\n * @param rowId The ID of the row to target (value of dataAttribute).\n * @param dataAttribute The data attribute used to identify the row.\n * @param checkboxQuerySelector A CSS selector to find the checkbox input within the row.\n * @param isChecked The desired checked state (true for checked, false for unchecked).\n */\nexport const setRowCheckboxState = (\n rows: HTMLTableRowElement[],\n rowId: string,\n dataAttribute: string,\n checkboxQuerySelector: string,\n isChecked: boolean\n) => {\n const row = getRowByDataAttribute(rows, rowId, dataAttribute);\n if (row) {\n const checkbox = getCheckboxFromRow(row, checkboxQuerySelector);\n if (checkbox) {\n checkbox.checked = isChecked;\n }\n }\n};\n\n/**\n * Marks a specific row as selected by checking its checkbox.\n */\nexport const selectRow = (\n rows: HTMLTableRowElement[],\n rowId: string,\n dataAttribute: string,\n checkboxQuerySelector: string\n) => {\n setRowCheckboxState(rows, rowId, dataAttribute, checkboxQuerySelector, true);\n};\n\n/**\n * Marks a specific row as deselected by unchecking its checkbox.\n */\nexport const deselectRow = (\n rows: HTMLTableRowElement[],\n rowId: string,\n dataAttribute: string,\n checkboxQuerySelector: string\n) => {\n setRowCheckboxState(rows, rowId, dataAttribute, checkboxQuerySelector, false);\n};\n\nexport default useTableSelection;\n"],"names":["ACTIVE_CLASS","DEFAULT_DATA_ATTRIBUTE","DEFAULT_TABLE_CHECKBOX_CELL_CLASS","DEFAULT_TABLE_ACTION_CELL_CLASS","useTableSelection","props","tableData","idKey","initialSelectedRowIds","initialActiveRowId","checkboxQuerySelector","dataAttributeName","ref","selectedRowIds","setSelectedRowIds","useState","activeRowId","setActiveRowId","lastActiveRowId","setLastActiveRowId","internalTableRef","useRef","tableRef","useEffect","updateRowSelection","rows","removeHighlightFromRow","highlightRow","rowId","selectRow","handleActiveRowChange","useCallback","event","clickedElement","isCheckboxCell","isActionCell","changeActiveRow","currentActiveRow","newActiveRowId","handleSelection","selectedRowId","prevSelectedRowIds","deselectRows","id","handleToggleAll","shouldSelect","allRowIds","row","deselectRow","rowIds","hasSelection","isAllSelected","getRowByDataAttribute","value","attribute","getCheckboxFromRow","setRowCheckboxState","dataAttribute","isChecked","checkbox"],"mappings":";AAKO,MAAMA,IAAe,UAKfC,IAAyB,WAGzBC,IAAoC,mBACpCC,IAAkC,iBAsIzCC,IAAoB,CACtBC,MAC0B;AAC1B,QAAM;AAAA,IACF,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,uBAAAC,IAAwB,CAAA;AAAA,IACxB,oBAAAC,IAAqB;AAAA,IACrB,uBAAAC,IAAwB;AAAA,IACxB,mBAAAC,IAAoBV;AAAA,IACpB,KAAAW;AAAA,EAAA,IACAP,GAEE,CAACQ,GAAgBC,CAAiB,IAAIC,EAAmBP,CAAqB,GAC9E,CAACQ,GAAaC,CAAc,IAAIF,EAAiBN,CAAkB,GACnE,CAACS,GAAiBC,CAAkB,IAAIJ,EAAiBN,CAAkB,GAE3EW,IAAmBC,EAAyB,IAAI,GAChDC,IAAWV,KAAOQ;AAWxB,EAAAG,EAAU,MAAM;AACZ,IAAAC,EAAA;AAAA,EACJ,GAAG,CAACR,GAAaE,GAAiBL,CAAc,CAAC;AAEjD,QAAMW,IAAqB,MAAM;AAC7B,QAAI,CAACF,EAAS;AACV;AAGJ,UAAMG,IAAO,CAAC,GAAGH,EAAS,QAAQ,IAAI;AAEtC,IAAIJ,MAAoBF,MAKpBU,EAAuBD,GAAMP,GAAiBP,CAAiB,GAC/DgB,EAAaF,GAAMT,GAAaL,CAAiB,IAIrDE,EAAe,QAAQ,CAAAe,MAAS;AAC5B,MAAAC,EAAUJ,GAAMG,GAAOjB,GAAmBD,CAAqB;AAAA,IACnE,CAAC;AAAA,EACL,GAEMoB,IAAwBC,EAAY,CAACC,MAAiD;AACxF,IAAAA,EAAM,eAAA,GACNA,EAAM,gBAAA;AAGN,UAAMJ,IADYI,EAAM,cACA,aAAarB,CAAiB,KAAK,IAGrDsB,IAAiBD,EAAM,QACvBE,IAAiBD,EAAe,QAAQ/B,CAAiC,GACzEiC,IAAeF,EAAe,QAAQ9B,CAA+B;AAC3E,IAAI+B,KAAkBC,KAItBC,EAAgBR,CAAK;AAAA,EACzB,GAAG,CAAA,CAAE,GAECQ,IAAkB,CAACR,IAAQ,OAAO;AACpC,IAAAX,EAAe,CAAAoB,MAAoB;AAC/B,YAAMC,IAAiBD,MAAqBT,IAAQ,KAAKA;AACzD,aAAAT,EAAmBkB,CAAgB,GAC5BC;AAAA,IACX,CAAC;AAAA,EACL,GAEMC,IAAkBR,EAAY,CAACC,MAAyC;AAC1E,IAAAA,EAAM,eAAA,GACNA,EAAM,gBAAA;AAIN,UAAMQ,IADcR,EAAM,OAAuB,QAAQ,MAAMrB,CAAiB,GAAG,GACjD,aAAaA,CAAiB;AAEhE,QAAI,CAAC6B,GAAe;AAChB,cAAQ,KAAK,4CAA4C;AACzD;AAAA,IACJ;AAEA,IAAA1B,EAAkB,CAAA2B,MACVA,EAAmB,SAASD,CAAa,KACzCE,EAAa,CAACF,CAAa,CAAC,GACrBC,EAAmB,OAAO,CAAAE,MAAMA,MAAOH,CAAa,KAExD,CAAC,GAAGC,GAAoBD,CAAa,CAC/C;AAAA,EACL,GAAG,CAAA,CAAE,GAECI,IAAkBb;AAAA,IACpB,CAACc,MAA0B;AACvB,YAAMC,IAAYxC,EAAU,IAAI,CAAAyC,MAAO,GAAGA,EAAIxC,CAAK,CAAC,EAAE;AAItD,UAHAO,EAAkB+B,IAAeC,IAAY,EAAE,GAG3CD;AACA,QAAA/B,EAAkBgC,CAAS;AAAA,WACxB;AACH,QAAAhC,EAAkB,CAAA,CAAE,GACpB4B,EAAaI,CAAS;AAEtB,mBAAWH,KAAMG,GAAW;AACxB,gBAAMrB,IAAOH,EAAS,UAAU,CAAC,GAAGA,EAAS,QAAQ,IAAI,IAAI,CAAA;AAC7D,UAAA0B,EAAY,CAAC,GAAGvB,CAAI,GAA4BkB,GAAIhC,GAAmBD,CAAqB;AAAA,QAChG;AAAA,MACJ;AAAA,IAEJ;AAAA,IACA,CAACJ,CAAS;AAAA,EAAA,GAGRoC,IAAe,CAACO,MAAqB;AACvC,UAAMxB,IAAOH,EAAS,UAAU,CAAC,GAAGA,EAAS,QAAQ,IAAI,IAAI,CAAA;AAC7D,IAAA2B,EAAO,QAAQ,CAAArB,MAAS;AACpB,MAAAoB,EAAYvB,GAAMG,GAAOjB,GAAmBD,CAAqB;AAAA,IACrE,CAAC;AAAA,EACL,GAEMwC,IAAerC,EAAe,SAAS,GACvCsC,IAAgBD,KAAgBrC,EAAe,WAAWP,EAAU,UAAUA,EAAU,SAAS;AAGvG,SAAO;AAAA,IACH,UAAAgB;AAAA,IACA,gBAAAT;AAAA,IACA,aAAAG;AAAA,IACA,aAAauB;AAAA,IACb,mBAAmBT;AAAA,IACnB,aAAac;AAAA,IACb,oBAAApB;AAAA,IACA,mBAAmB,CAACyB,MAAqBnC,EAAkBmC,CAAM;AAAA,IACjE,gBAAgB,CAACjC,MAAoCoB,EAAgBpB,CAAW;AAAA,IAChF,cAAAkC;AAAA,IACA,eAAAC;AAAA,EAAA;AAER,GAUaC,IAAwB,CACjC3B,GACA4B,GACAC,MACkC;AAClC,MAAKD;AAGL,WAAO5B,EAAK,KAAK,CAAAsB,MAAOA,EAAI,aAAaO,CAAS,MAAMD,CAAK;AACjE,GASa1B,IAAe,CAACF,GAA6BG,GAAsBjB,MAA8B;AAE1G,EADYyC,EAAsB3B,GAAMG,GAAOjB,CAAiB,GAC3D,UAAU,IAAIX,CAAY;AACnC,GASa0B,IAAyB,CAClCD,GACAG,GACAjB,MACC;AAED,EADYyC,EAAsB3B,GAAMG,GAAOjB,CAAiB,GAC3D,UAAU,OAAOX,CAAY;AACtC,GAGMuD,IAAqB,CAACR,GAA0BrC,MAC3CqC,EAAI,cAAcrC,CAAqB,GAWrC8C,IAAsB,CAC/B/B,GACAG,GACA6B,GACA/C,GACAgD,MACC;AACD,QAAMX,IAAMK,EAAsB3B,GAAMG,GAAO6B,CAAa;AAC5D,MAAIV,GAAK;AACL,UAAMY,IAAWJ,EAAmBR,GAAKrC,CAAqB;AAC9D,IAAIiD,MACAA,EAAS,UAAUD;AAAA,EAE3B;AACJ,GAKa7B,IAAY,CACrBJ,GACAG,GACA6B,GACA/C,MACC;AACD,EAAA8C,EAAoB/B,GAAMG,GAAO6B,GAAe/C,GAAuB,EAAI;AAC/E,GAKasC,IAAc,CACvBvB,GACAG,GACA6B,GACA/C,MACC;AACD,EAAA8C,EAAoB/B,GAAMG,GAAO6B,GAAe/C,GAAuB,EAAK;AAChF;"}
|
|
1
|
+
{"version":3,"file":"useTableSelection.js","sources":["../../src/hooks/useTableSelection.ts"],"sourcesContent":["import { useState, useRef, useCallback, useEffect } from 'react';\n\n/**\n * CSS class applied to the currently active row.\n */\nexport const ACTIVE_CLASS = 'active';\n\n/**\n * Default HTML data attribute name used to store the unique ID on table row elements.\n */\nexport const DEFAULT_DATA_ATTRIBUTE = 'data-id';\n\n// Default classes for the checkbox and action cells\nexport const DEFAULT_TABLE_CHECKBOX_CELL_CLASS = '.table-checkbox';\nexport const DEFAULT_TABLE_ACTION_CELL_CLASS = '.table-action';\n\n/**\n * Options for the `useTableSelection` hook.\n */\nexport type UseTableSelectionOptions<TData extends Record<string, any>> = {\n /**\n * The array of data items to be displayed in the table.\n * The hook uses this to determine all possible row IDs for \"select all\" functionality.\n */\n tableData: TData[];\n\n /**\n * The key in `TData` objects that serves as the unique identifier for each row.\n */\n idKey: keyof TData;\n\n /**\n * Optional array of row IDs that should be initially selected.\n */\n initialSelectedRowIds?: string[];\n\n /**\n * Optional ID of the row that should be initially marked as active.\n */\n initialActiveRowId?: string;\n\n // customize reference values\n\n /**\n * Optional CSS query selector to find the checkbox input element within each table row.\n * @default '.table-checkbox input[type=\"checkbox\"]'\n */\n checkboxQuerySelector?: string;\n\n /**\n * Optional name of the HTML data attribute on `<tr>` elements that holds the unique row ID.\n * @default 'data-id' (matches DEFAULT_DATA_ATTRIBUTE)\n */\n dataAttributeName?: string;\n\n /**\n * Optional external ref for the table element. If not provided, the hook creates its own.\n * Useful if the parent component needs direct access to the table DOM element for other purposes.\n */\n ref?: React.RefObject<HTMLTableElement>;\n};\n\n/**\n * Return value of the `useTableSelection` hook.\n */\nexport type UseTableSelectionReturn = {\n /**\n * React ref attached to the `<table>` HTML element.\n * Ensure this ref is assigned to your table element to enable DOM manipulations.\n */\n tableRef: React.RefObject<HTMLTableElement>;\n\n /**\n * An array of strings, where each string is the ID of a currently selected row.\n */\n selectedRowIds: string[];\n\n /**\n * The ID of the currently active row. An empty string signifies no row is active.\n */\n activeRowId: string;\n\n /**\n * Callback handler to be attached to the click/change event of individual row selection UI elements (e.g., checkboxes).\n * It expects the clicked element to be within a `<tr>` that has the specified `dataAttributeName`.\n * Manages the selection state of a single row.\n *\n * @param event The React mouse event from the selection UI element.\n */\n onSelection: (event: React.MouseEvent<HTMLElement>) => void;\n\n /**\n * Callback handler to be attached to the click event of table row (`<tr>`) elements.\n * Manages the active row state.\n * @param event The React mouse event from the `<tr>` element.\n */\n onActiveRowChange: (event: React.MouseEvent<HTMLTableRowElement>) => void;\n\n /**\n * Callback handler to select or deselect all rows.\n * @param shouldSelect If true, all rows in `tableData` will be selected; otherwise, all selections will be cleared.\n */\n onToggleAll: (shouldSelect: boolean) => void;\n\n /**\n * Function to update row selection and active highlighting. This is useful when the row data changes due to a search value\n * or any other filter.\n *\n * @returns\n */\n updateRowSelection: () => void;\n\n /**\n * Setter function to change selected rows from the outside in a controlled manner.\n *\n * @param rowIds\n * @returns\n */\n setSelectedRowIds: (rowIds: string[]) => void;\n\n /**\n * Setter function to change the active row from the outside in a controlled manner.\n * Use this to deselect an active row.\n *\n * @param activeRowId\n * @returns\n */\n setActiveRowId: (activeRowId: string | undefined) => void;\n\n /**\n * A boolean indicating whether at least one row is currently selected.\n */\n hasSelection: boolean;\n\n /**\n * A boolean indicating whether all rows in the current `tableData` are selected.\n */\n isAllSelected: boolean;\n};\n\n/**\n * A React hook to manage row selection and active row state for an HTML table,\n * including DOM manipulations for visual feedback to optimize performance by\n * preventing individual row re-renders.\n *\n * @param {UseTableSelectionOptions<TData>} options The configuration properties for the hook.\n * @returns {UseTableSelectionReturn} The state and handlers for managing table selection and active row.\n */\nconst useTableSelection = <TData extends Record<string, any>>(\n props: UseTableSelectionOptions<TData>\n): UseTableSelectionReturn => {\n const {\n tableData,\n idKey,\n initialSelectedRowIds = [],\n initialActiveRowId = '',\n checkboxQuerySelector = '.table-checkbox input[type=\"checkbox\"]',\n dataAttributeName = DEFAULT_DATA_ATTRIBUTE,\n ref,\n } = props;\n\n const [selectedRowIds, setSelectedRowIds] = useState<string[]>(initialSelectedRowIds);\n const [activeRowId, setActiveRowId] = useState<string>(initialActiveRowId);\n const [lastActiveRowId, setLastActiveRowId] = useState<string>(initialActiveRowId);\n\n const internalTableRef = useRef<HTMLTableElement>(null);\n const tableRef = ref ?? internalTableRef;\n\n // --- DOM Manipulation Effect (The performance workaround) ---\n /**\n * Effect to handle DOM manipulations for active row highlighting and ensuring\n * checkboxes for selected rows are visually checked.\n * This effect runs when active row state or selection state changes.\n * Note: This effect currently only *selects* rows based on `selectedRowIds`.\n * Deselection in the DOM is handled directly by `onSelection` and `onToggleAll` handlers.\n * For a more centralized DOM update, this effect could be expanded to handle deselection as well.\n */\n useEffect(() => {\n updateRowSelection();\n }, [activeRowId, lastActiveRowId, selectedRowIds]); // Rerun when these change\n\n const updateRowSelection = () => {\n if (!tableRef.current) {\n return;\n }\n\n const rows = [...tableRef.current.rows] as HTMLTableRowElement[];\n\n if (lastActiveRowId !== activeRowId) {\n // Due to performance reasons the individual rows should not re-render when the\n // selected driver changes, hence we need to avoid passing that information as props\n // to the row component otherwise it would re-render as the props have changed.\n // Instead, we check here which row to highlight.\n removeHighlightFromRow(rows, lastActiveRowId, dataAttributeName);\n highlightRow(rows, activeRowId, dataAttributeName);\n }\n\n // handle multi-selection\n selectedRowIds.forEach(rowId => {\n selectRow(rows, rowId, dataAttributeName, checkboxQuerySelector);\n });\n };\n\n const handleActiveRowChange = useCallback((event: React.MouseEvent<HTMLTableRowElement>) => {\n event.preventDefault();\n event.stopPropagation();\n\n const targetRow = event.currentTarget;\n const rowId = targetRow.getAttribute(dataAttributeName) ?? '';\n\n // Avoid activation if click is on checkbox/action area (more robust check needed if complex row structure)\n const clickedElement = event.target as HTMLElement;\n const isCheckboxCell = clickedElement.closest(DEFAULT_TABLE_CHECKBOX_CELL_CLASS);\n const isActionCell = clickedElement.closest(DEFAULT_TABLE_ACTION_CELL_CLASS);\n if (isCheckboxCell || isActionCell) {\n return;\n }\n\n changeActiveRow(rowId);\n }, []);\n\n const changeActiveRow = (rowId = '') => {\n setActiveRowId(currentActiveRow => {\n const newActiveRowId = currentActiveRow === rowId ? '' : rowId;\n setLastActiveRowId(currentActiveRow); // Update lastActive for the effect\n return newActiveRowId;\n });\n };\n\n const handleSelection = useCallback((event: React.MouseEvent<HTMLElement>) => {\n event.preventDefault();\n event.stopPropagation();\n\n // Find the correct row element containing the data attribute\n const rowElement = (event.target as HTMLElement).closest(`tr[${dataAttributeName}]`);\n const selectedRowId = rowElement?.getAttribute(dataAttributeName);\n\n if (!selectedRowId) {\n console.warn('Could not find row ID for selection event.');\n return;\n }\n\n setSelectedRowIds(prevSelectedRowIds => {\n if (prevSelectedRowIds.includes(selectedRowId)) {\n deselectRows([selectedRowId]);\n return prevSelectedRowIds.filter(id => id !== selectedRowId);\n }\n return [...prevSelectedRowIds, selectedRowId];\n });\n }, []);\n\n const handleToggleAll = useCallback(\n (shouldSelect: boolean) => {\n const allRowIds = tableData.map(row => `${row[idKey]}`);\n setSelectedRowIds(shouldSelect ? allRowIds : []);\n\n // Deselect all rows when there is at least one row selected, else select all rows\n if (shouldSelect) {\n setSelectedRowIds(allRowIds);\n } else {\n setSelectedRowIds([]);\n deselectRows(allRowIds);\n\n for (const id in allRowIds) {\n const rows = tableRef.current ? [...tableRef.current.rows] : [];\n deselectRow([...rows] as HTMLTableRowElement[], id, dataAttributeName, checkboxQuerySelector);\n }\n }\n // DOM updates are handled by useEffect -> updateRowsDOM\n },\n [tableData]\n );\n\n const deselectRows = (rowIds: string[]) => {\n const rows = tableRef.current ? [...tableRef.current.rows] : [];\n rowIds.forEach(rowId => {\n deselectRow(rows, rowId, dataAttributeName, checkboxQuerySelector);\n });\n };\n\n const hasSelection = selectedRowIds.length > 0;\n const isAllSelected = hasSelection && selectedRowIds.length === tableData.length && tableData.length > 0;\n\n // --- Return hook state and handlers ---\n return {\n tableRef,\n selectedRowIds,\n activeRowId,\n onSelection: handleSelection,\n onActiveRowChange: handleActiveRowChange,\n onToggleAll: handleToggleAll,\n updateRowSelection,\n setSelectedRowIds: (rowIds: string[]) => setSelectedRowIds(rowIds),\n setActiveRowId: (activeRowId: string | undefined) => changeActiveRow(activeRowId),\n hasSelection,\n isAllSelected,\n };\n};\n\n/**\n * Finds a table row element by its data attribute value.\n *\n * @param rows Array of HTMLTableRowElements to search within.\n * @param value The value of the data attribute to find.\n * @param attribute The name of the data attribute (e.g., 'data-id').\n * @returns The found HTMLTableRowElement or undefined.\n */\nexport const getRowByDataAttribute = (\n rows: HTMLTableRowElement[],\n value: string | null | undefined,\n attribute: string\n): HTMLTableRowElement | undefined => {\n if (!value) {\n return;\n }\n return rows.find(row => row.getAttribute(attribute) === value);\n};\n\n/**\n * Adds an \"active\" class to a specified table row.\n *\n * @param rows Array of HTMLTableRowElements to search within.\n * @param rowId The ID of the row to highlight.\n * @param dataAttributeName The data attribute used to identify the row.\n */\nexport const highlightRow = (rows: HTMLTableRowElement[], rowId: string | null, dataAttributeName: string) => {\n const row = getRowByDataAttribute(rows, rowId, dataAttributeName);\n row?.classList.add(ACTIVE_CLASS);\n};\n\n/**\n * Removes the \"active\" class from a specified table row.\n *\n * @param rows Array of HTMLTableRowElements to search within.\n * @param rowId The ID of the row to unhighlight.\n * @param dataAttributeName The data attribute used to identify the row.\n */\nexport const removeHighlightFromRow = (\n rows: HTMLTableRowElement[],\n rowId: string | null,\n dataAttributeName: string\n) => {\n const row = getRowByDataAttribute(rows, rowId, dataAttributeName);\n row?.classList.remove(ACTIVE_CLASS);\n};\n\n// Helper to get the checkbox input for a single row\nconst getCheckboxFromRow = (row: HTMLTableRowElement, checkboxQuerySelector: string): HTMLInputElement | null =>\n row.querySelector(checkboxQuerySelector);\n\n/**\n * Sets the checked state of a checkbox within a specific table row.\n * @param rows Array of HTMLTableRowElements to search within.\n * @param rowId The ID of the row to target (value of dataAttribute).\n * @param dataAttribute The data attribute used to identify the row.\n * @param checkboxQuerySelector A CSS selector to find the checkbox input within the row.\n * @param isChecked The desired checked state (true for checked, false for unchecked).\n */\nexport const setRowCheckboxState = (\n rows: HTMLTableRowElement[],\n rowId: string,\n dataAttribute: string,\n checkboxQuerySelector: string,\n isChecked: boolean\n) => {\n const row = getRowByDataAttribute(rows, rowId, dataAttribute);\n if (row) {\n const checkbox = getCheckboxFromRow(row, checkboxQuerySelector);\n if (checkbox) {\n checkbox.checked = isChecked;\n }\n }\n};\n\n/**\n * Marks a specific row as selected by checking its checkbox.\n */\nexport const selectRow = (\n rows: HTMLTableRowElement[],\n rowId: string,\n dataAttribute: string,\n checkboxQuerySelector: string\n) => {\n setRowCheckboxState(rows, rowId, dataAttribute, checkboxQuerySelector, true);\n};\n\n/**\n * Marks a specific row as deselected by unchecking its checkbox.\n */\nexport const deselectRow = (\n rows: HTMLTableRowElement[],\n rowId: string,\n dataAttribute: string,\n checkboxQuerySelector: string\n) => {\n setRowCheckboxState(rows, rowId, dataAttribute, checkboxQuerySelector, false);\n};\n\nexport default useTableSelection;\n"],"names":["ACTIVE_CLASS","DEFAULT_DATA_ATTRIBUTE","DEFAULT_TABLE_CHECKBOX_CELL_CLASS","DEFAULT_TABLE_ACTION_CELL_CLASS","useTableSelection","props","tableData","idKey","initialSelectedRowIds","initialActiveRowId","checkboxQuerySelector","dataAttributeName","ref","selectedRowIds","setSelectedRowIds","useState","activeRowId","setActiveRowId","lastActiveRowId","setLastActiveRowId","internalTableRef","useRef","tableRef","useEffect","updateRowSelection","rows","removeHighlightFromRow","highlightRow","rowId","selectRow","handleActiveRowChange","useCallback","event","clickedElement","isCheckboxCell","isActionCell","changeActiveRow","currentActiveRow","newActiveRowId","handleSelection","selectedRowId","prevSelectedRowIds","deselectRows","id","handleToggleAll","shouldSelect","allRowIds","row","deselectRow","rowIds","hasSelection","isAllSelected","getRowByDataAttribute","value","attribute","getCheckboxFromRow","setRowCheckboxState","dataAttribute","isChecked","checkbox"],"mappings":"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"}
|
package/hooks/useTimeout.js
CHANGED
package/hooks/useTimeout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTimeout.js","sources":["../../src/hooks/useTimeout.ts"],"sourcesContent":["import type React from 'react';\nimport { useEffect, useMemo, useRef } from 'react';\n\n// See www.joshwcomeau.com/snippets/react-hooks/use-timeout/\n\n/**\n * A custom hook for handling timeout events.\n *\n * @param callback The callback function to execute after the timeout.\n * @param delay The duration of the timeout in milliseconds. Pass `null` to cancel the timeout.\n *\n * @returns A mutable ref object to manage the timeout ID.\n */\nconst useTimeout = (callback: () => void, delay: number | null): React.MutableRefObject<number | null> => {\n const timeoutRef = useRef<number | null>(null);\n const savedCallback = useRef<() => void>(callback);\n\n // Update the saved callback when the callback prop changes\n useEffect(() => {\n savedCallback.current = callback;\n }, [callback]);\n\n // Set up the timeout when the delay changes\n useEffect(() => {\n const tick = () => savedCallback.current();\n\n // If delay is a number, set up the timeout\n if (typeof delay === 'number') {\n timeoutRef.current = setTimeout(tick, delay) as unknown as number;\n\n // Cleanup function to clear the timeout when delay changes or component unmounts\n return () => {\n if (timeoutRef.current !== null) {\n clearTimeout(timeoutRef.current);\n }\n };\n }\n }, [delay]);\n\n return timeoutRef;\n};\n\nexport const useChainedTimeout = () => {\n const MAX_DELAY_MS = 2 ** 31 - 1;\n\n const setChainedTimeout = (ref: React.MutableRefObject<any>, fn: () => void, timeoutAtMs: number) => {\n const delayMs = timeoutAtMs - Date.now();\n\n ref.current =\n delayMs <= MAX_DELAY_MS\n ? setTimeout(fn, delayMs)\n : setTimeout(() => setChainedTimeout(ref, fn, timeoutAtMs), MAX_DELAY_MS);\n };\n\n const handleRef = useRef<any>(null);\n\n const { set, clear } = useMemo(() => {\n const clear = () => clearTimeout(handleRef.current);\n\n const set = (fn: () => void, delayMs = 0): void => {\n clear();\n\n if (delayMs <= MAX_DELAY_MS) {\n // For simplicity, if the timeout is short, just set a normal timeout.\n handleRef.current = setTimeout(fn, delayMs);\n } else {\n setChainedTimeout(handleRef, fn, Date.now() + delayMs);\n }\n };\n\n return {\n set,\n clear,\n };\n }, []);\n\n useEffect(() =>
|
|
1
|
+
{"version":3,"file":"useTimeout.js","sources":["../../src/hooks/useTimeout.ts"],"sourcesContent":["import type React from 'react';\nimport { useEffect, useMemo, useRef } from 'react';\n\n// See www.joshwcomeau.com/snippets/react-hooks/use-timeout/\n\n/**\n * A custom hook for handling timeout events.\n *\n * @param callback The callback function to execute after the timeout.\n * @param delay The duration of the timeout in milliseconds. Pass `null` to cancel the timeout.\n *\n * @returns A mutable ref object to manage the timeout ID.\n */\nconst useTimeout = (callback: () => void, delay: number | null): React.MutableRefObject<number | null> => {\n const timeoutRef = useRef<number | null>(null);\n const savedCallback = useRef<() => void>(callback);\n\n // Update the saved callback when the callback prop changes\n useEffect(() => {\n savedCallback.current = callback;\n }, [callback]);\n\n // Set up the timeout when the delay changes\n useEffect(() => {\n const tick = () => savedCallback.current();\n\n // If delay is a number, set up the timeout\n if (typeof delay === 'number') {\n timeoutRef.current = setTimeout(tick, delay) as unknown as number;\n\n // Cleanup function to clear the timeout when delay changes or component unmounts\n return () => {\n if (timeoutRef.current !== null) {\n clearTimeout(timeoutRef.current);\n }\n };\n }\n }, [delay]);\n\n return timeoutRef;\n};\n\nexport const useChainedTimeout = () => {\n const MAX_DELAY_MS = 2 ** 31 - 1;\n\n const setChainedTimeout = (ref: React.MutableRefObject<any>, fn: () => void, timeoutAtMs: number) => {\n const delayMs = timeoutAtMs - Date.now();\n\n ref.current =\n delayMs <= MAX_DELAY_MS\n ? setTimeout(fn, delayMs)\n : setTimeout(() => setChainedTimeout(ref, fn, timeoutAtMs), MAX_DELAY_MS);\n };\n\n const handleRef = useRef<any>(null);\n\n const { set, clear } = useMemo(() => {\n const clear = () => clearTimeout(handleRef.current);\n\n const set = (fn: () => void, delayMs = 0): void => {\n clear();\n\n if (delayMs <= MAX_DELAY_MS) {\n // For simplicity, if the timeout is short, just set a normal timeout.\n handleRef.current = setTimeout(fn, delayMs);\n } else {\n setChainedTimeout(handleRef, fn, Date.now() + delayMs);\n }\n };\n\n return {\n set,\n clear,\n };\n }, []);\n\n useEffect(\n () => () => {\n clear();\n },\n [clear]\n );\n\n return {\n set,\n clear,\n handleRef,\n };\n};\n\nexport default useTimeout;\n"],"names":["useTimeout","callback","delay","timeoutRef","useRef","savedCallback","useEffect","tick","useChainedTimeout","setChainedTimeout","ref","fn","timeoutAtMs","delayMs","handleRef","set","clear","useMemo"],"mappings":";AAaA,MAAMA,IAAa,CAACC,GAAsBC,MAAgE;AACtG,QAAMC,IAAaC,EAAsB,IAAI,GACvCC,IAAgBD,EAAmBH,CAAQ;AAGjD,SAAAK,EAAU,MAAM;AACZ,IAAAD,EAAc,UAAUJ;AAAA,EAC5B,GAAG,CAACA,CAAQ,CAAC,GAGbK,EAAU,MAAM;AACZ,UAAMC,IAAO,MAAMF,EAAc,QAAA;AAGjC,QAAI,OAAOH,KAAU;AACjB,aAAAC,EAAW,UAAU,WAAWI,GAAML,CAAK,GAGpC,MAAM;AACT,QAAIC,EAAW,YAAY,QACvB,aAAaA,EAAW,OAAO;AAAA,MAEvC;AAAA,EAER,GAAG,CAACD,CAAK,CAAC,GAEHC;AACX,GAEaK,IAAoB,MAAM;AAGnC,QAAMC,IAAoB,CAACC,GAAkCC,GAAgBC,MAAwB;AACjG,UAAMC,IAAUD,IAAc,KAAK,IAAA;AAEnC,IAAAF,EAAI,UACAG,KAAW,aACL,WAAWF,GAAIE,CAAO,IACtB,WAAW,MAAMJ,EAAkBC,GAAKC,GAAIC,CAAW,GAAG,UAAY;AAAA,EACpF,GAEME,IAAYV,EAAY,IAAI,GAE5B,EAAE,KAAAW,GAAK,OAAAC,EAAA,IAAUC,EAAQ,MAAM;AACjC,UAAMD,IAAQ,MAAM,aAAaF,EAAU,OAAO;AAalD,WAAO;AAAA,MACH,KAZQ,CAACH,GAAgBE,IAAU,MAAY;AAC/CG,QAAAA,EAAAA,GAEIH,KAAW,aAEXC,EAAU,UAAU,WAAWH,GAAIE,CAAO,IAE1CJ,EAAkBK,GAAWH,GAAI,KAAK,IAAA,IAAQE,CAAO;AAAA,MAE7D;AAAA,MAII,OAAAG;AAAAA,IAAA;AAAA,EAER,GAAG,CAAA,CAAE;AAEL,SAAAV;AAAA,IACI,MAAM,MAAM;AACR,MAAAU,EAAA;AAAA,IACJ;AAAA,IACA,CAACA,CAAK;AAAA,EAAA,GAGH;AAAA,IACH,KAAAD;AAAA,IACA,OAAAC;AAAA,IACA,WAAAF;AAAA,EAAA;AAER;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rio-cloud/rio-uikit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-beta.1",
|
|
4
4
|
"description": "The RIO UIKIT component library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@biomejs/biome": "2.4.
|
|
50
|
-
"@rio-cloud/biome-config": "1.
|
|
49
|
+
"@biomejs/biome": "2.4.4",
|
|
50
|
+
"@rio-cloud/biome-config": "1.2.0",
|
|
51
51
|
"@rio-cloud/vite-plugin-frontend-license-check": "1.2.0",
|
|
52
52
|
"@testing-library/dom": "10.4.1",
|
|
53
53
|
"@testing-library/jest-dom": "6.9.1",
|
package/routeUtils.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { deserializeValue as
|
|
2
|
-
import { isEqual as
|
|
1
|
+
import { deserializeColumnsConfig as r, deserializeValue as o, getSortDirShort as s, mapColumnsSettingsToStrings as t, parseColumnsSettingsStrings as n, parseSorting as l, serializeColumnsConfig as a, serializeSorting as g, serializeValue as S, toQueryString as u } from "./utils/routeUtils.js";
|
|
2
|
+
import { isEqual as C } from "es-toolkit";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
r as deserializeColumnsConfig,
|
|
5
|
+
o as deserializeValue,
|
|
6
|
+
s as getSortDirShort,
|
|
7
|
+
C as isEqual,
|
|
8
|
+
t as mapColumnsSettingsToStrings,
|
|
9
|
+
n as parseColumnsSettingsStrings,
|
|
10
|
+
l as parseSorting,
|
|
11
|
+
a as serializeColumnsConfig,
|
|
12
|
+
g as serializeSorting,
|
|
11
13
|
S as serializeValue,
|
|
12
|
-
|
|
14
|
+
u as toQueryString
|
|
13
15
|
};
|
|
14
16
|
//# sourceMappingURL=routeUtils.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type AnalyticsReportEntry = {
|
|
2
|
+
reportName: string;
|
|
3
|
+
eventAction: string;
|
|
4
|
+
eventLabel: string;
|
|
5
|
+
eventCount: string;
|
|
6
|
+
totalUsers: string;
|
|
7
|
+
eventCountPerActiveUser: string;
|
|
8
|
+
};
|
|
9
|
+
type AnalyticsCsvUpload = {
|
|
10
|
+
reportName: string;
|
|
11
|
+
csvRaw: string;
|
|
12
|
+
};
|
|
13
|
+
type AnalyticsAnalysisData = {
|
|
14
|
+
analyticsLookup: Map<string, AnalyticsReportEntry[]>;
|
|
15
|
+
analyticsDateRangeLabel: string | null;
|
|
16
|
+
analyticsTotalUsers: number | null;
|
|
17
|
+
};
|
|
18
|
+
export declare const LOOKUP_MAX_LENGTH = 100;
|
|
19
|
+
export declare const REQUIRED_ANALYTICS_HEADER_ROW: string;
|
|
20
|
+
export declare const ANALYTICS_OVERLAY_SELECTOR = "[data-track-ga-event-action][data-track-ga-event-label]";
|
|
21
|
+
export declare const EVENT_TYPE_ICON_CLASS: Record<'seen' | 'clicked', string>;
|
|
22
|
+
export declare const createAnalyticsLookupKey: (eventAction: string, eventLabel: string) => string;
|
|
23
|
+
export declare const toEventType: (eventTrigger: string) => "seen" | "clicked" | null;
|
|
24
|
+
export declare const hasRequiredAnalyticsHeaderRow: (csvRaw: string) => boolean;
|
|
25
|
+
export declare const parseAnalyticsReportCsv: (csvRaw: string, reportName: string) => AnalyticsReportEntry[];
|
|
26
|
+
export declare const buildAnalyticsAnalysisData: (uploads: AnalyticsCsvUpload[]) => AnalyticsAnalysisData;
|
|
27
|
+
export type { AnalyticsAnalysisData, AnalyticsCsvUpload, AnalyticsReportEntry };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const T = "# Start date:", U = "# End date:", g = /^#\s*(\d{8})\s*-\s*(\d{8})\s*$/, $ = 100, b = [
|
|
2
|
+
"event_action",
|
|
3
|
+
"event_label",
|
|
4
|
+
"Event count",
|
|
5
|
+
"Total users",
|
|
6
|
+
"Event count per active user"
|
|
7
|
+
], I = ["event_action", "event_label"], O = ["event count"], M = ["total users", "active users"], w = ["event count per active user", "event countactive user"], X = b.join(","), G = "[data-track-ga-event-action][data-track-ga-event-label]", Q = {
|
|
8
|
+
seen: "rioglyph-eye-open",
|
|
9
|
+
clicked: "rioglyph-click"
|
|
10
|
+
}, V = (t) => t.slice(0, 100), P = (t, e) => `${t}::${V(e)}`, W = (t) => t === "visibility" ? "seen" : t === "click" ? "clicked" : null, f = (t) => {
|
|
11
|
+
const e = t.trim();
|
|
12
|
+
if (!/^\d{8}$/.test(e))
|
|
13
|
+
return null;
|
|
14
|
+
const s = Number(e.slice(0, 4)), n = Number(e.slice(4, 6)), r = Number(e.slice(6, 8)), c = new Date(Date.UTC(s, n - 1, r));
|
|
15
|
+
return c.getUTCFullYear() !== s || c.getUTCMonth() !== n - 1 || c.getUTCDate() !== r ? null : c;
|
|
16
|
+
}, y = (t) => new Intl.DateTimeFormat("en-US", {
|
|
17
|
+
month: "long",
|
|
18
|
+
day: "numeric",
|
|
19
|
+
year: "numeric",
|
|
20
|
+
timeZone: "UTC"
|
|
21
|
+
}).format(t), k = (t) => {
|
|
22
|
+
const e = t.split(/\r?\n/), s = e.find((a) => a.startsWith(T)), n = e.find((a) => a.startsWith(U)), r = s?.slice(T.length).trim() ?? "", c = n?.slice(U.length).trim() ?? "", i = f(r), o = f(c);
|
|
23
|
+
if (i !== null && o !== null)
|
|
24
|
+
return { startDate: i, endDate: o };
|
|
25
|
+
const l = e.find((a) => g.test(a.trim()));
|
|
26
|
+
if (!l)
|
|
27
|
+
return { startDate: i, endDate: o };
|
|
28
|
+
const u = l.trim().match(g);
|
|
29
|
+
if (!u)
|
|
30
|
+
return { startDate: i, endDate: o };
|
|
31
|
+
const d = f(u[1]), v = f(u[2]);
|
|
32
|
+
return { startDate: d, endDate: v };
|
|
33
|
+
}, D = (t) => t.split(/\r?\n/).map((e) => e.trim()).filter((e) => e && !e.startsWith("#")), A = (t) => {
|
|
34
|
+
const e = [];
|
|
35
|
+
let s = "", n = !1;
|
|
36
|
+
for (let r = 0; r < t.length; r += 1) {
|
|
37
|
+
const c = t[r];
|
|
38
|
+
if (c === '"') {
|
|
39
|
+
const i = t[r + 1];
|
|
40
|
+
if (n && i === '"') {
|
|
41
|
+
s += '"', r += 1;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
n = !n;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (c === "," && !n) {
|
|
48
|
+
e.push(s.trim()), s = "";
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
s += c;
|
|
52
|
+
}
|
|
53
|
+
return e.push(s.trim()), e;
|
|
54
|
+
}, R = (t) => t.trim().toLowerCase().replace(/\s+/g, " "), E = (t, e) => {
|
|
55
|
+
const s = new Set(e.map((n) => R(n)));
|
|
56
|
+
return t.findIndex((n) => s.has(R(n)));
|
|
57
|
+
}, _ = (t) => !t || !t.trim() ? !1 : Number.isFinite(Number(t)), h = (t) => {
|
|
58
|
+
const e = t?.trim() ?? "";
|
|
59
|
+
return e !== "" && !_(e);
|
|
60
|
+
}, H = (t) => {
|
|
61
|
+
let e = E(t, [I[0]]), s = E(t, [I[1]]), n = E(t, O), r = E(t, M), c = E(t, w);
|
|
62
|
+
return e === -1 && t.length >= 1 && (e = 0), s === -1 && t.length >= 2 && (s = e + 1), n === -1 && t.length >= 3 && (n = s + 1), r === -1 && t.length >= 4 && (r = n + 1), c === -1 && t.length >= 5 && (c = r + 1), e < 0 || s < 0 || n < 0 || r < 0 || c < 0 ? null : {
|
|
63
|
+
eventActionIndex: e,
|
|
64
|
+
eventLabelIndex: s,
|
|
65
|
+
eventCountIndex: n,
|
|
66
|
+
totalUsersIndex: r,
|
|
67
|
+
eventCountPerUserIndex: c
|
|
68
|
+
};
|
|
69
|
+
}, x = (t, e) => {
|
|
70
|
+
const s = t.slice(1);
|
|
71
|
+
let n = 0, r = 0;
|
|
72
|
+
for (const c of s) {
|
|
73
|
+
const i = A(c), o = i[e.eventActionIndex], l = i[e.eventLabelIndex];
|
|
74
|
+
if (!o && !l)
|
|
75
|
+
continue;
|
|
76
|
+
n += 1;
|
|
77
|
+
const u = i[e.eventCountIndex], d = i[e.totalUsersIndex];
|
|
78
|
+
if (h(o) && h(l) && _(u) && _(d) && (r += 1), n >= 5)
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
return n === 0 ? !0 : r >= Math.ceil(n / 2);
|
|
82
|
+
}, C = (t) => {
|
|
83
|
+
if (t.length < 2)
|
|
84
|
+
return null;
|
|
85
|
+
const e = A(t[0]), s = H(e);
|
|
86
|
+
if (s && x(t, s))
|
|
87
|
+
return s;
|
|
88
|
+
const n = {
|
|
89
|
+
eventActionIndex: 0,
|
|
90
|
+
eventLabelIndex: 1,
|
|
91
|
+
eventCountIndex: 2,
|
|
92
|
+
totalUsersIndex: 3,
|
|
93
|
+
eventCountPerUserIndex: 4
|
|
94
|
+
};
|
|
95
|
+
return x(t, n) ? n : null;
|
|
96
|
+
}, q = (t) => {
|
|
97
|
+
const e = D(t);
|
|
98
|
+
if (e.length === 0)
|
|
99
|
+
return !1;
|
|
100
|
+
const s = A(e[0]);
|
|
101
|
+
return I.every(
|
|
102
|
+
(r) => s.some((c) => R(c) === r)
|
|
103
|
+
) && C(e) !== null;
|
|
104
|
+
}, F = (t) => {
|
|
105
|
+
const e = Number(t);
|
|
106
|
+
return Number.isFinite(e) ? e : 0;
|
|
107
|
+
}, S = (t) => !(t?.trim().toLowerCase() ?? ""), N = (t, e, s, n) => {
|
|
108
|
+
if (t !== 0)
|
|
109
|
+
return !1;
|
|
110
|
+
const r = e[s], c = e[n];
|
|
111
|
+
return S(r) && S(c);
|
|
112
|
+
}, Y = (t) => {
|
|
113
|
+
const e = D(t);
|
|
114
|
+
if (e.length < 2)
|
|
115
|
+
return null;
|
|
116
|
+
const s = C(e);
|
|
117
|
+
if (!s)
|
|
118
|
+
return null;
|
|
119
|
+
const n = A(e[1]);
|
|
120
|
+
return N(0, n, s.eventActionIndex, s.eventLabelIndex) ? F(n[s.totalUsersIndex]) : null;
|
|
121
|
+
}, z = (t, e) => {
|
|
122
|
+
const s = D(t);
|
|
123
|
+
if (s.length < 2)
|
|
124
|
+
return [];
|
|
125
|
+
const n = C(s);
|
|
126
|
+
return n ? s.slice(1).reduce((r, c, i) => {
|
|
127
|
+
const o = A(c);
|
|
128
|
+
if (N(i, o, n.eventActionIndex, n.eventLabelIndex))
|
|
129
|
+
return r;
|
|
130
|
+
const l = o[n.eventActionIndex], u = o[n.eventLabelIndex];
|
|
131
|
+
return !l || !u || r.push({
|
|
132
|
+
reportName: e,
|
|
133
|
+
eventAction: l,
|
|
134
|
+
eventLabel: u,
|
|
135
|
+
eventCount: o[n.eventCountIndex] ?? "0",
|
|
136
|
+
totalUsers: o[n.totalUsersIndex] ?? "0",
|
|
137
|
+
eventCountPerActiveUser: o[n.eventCountPerUserIndex] ?? "0"
|
|
138
|
+
}), r;
|
|
139
|
+
}, []) : [];
|
|
140
|
+
}, K = (t) => {
|
|
141
|
+
const e = t.map((a) => ({
|
|
142
|
+
analyticsEntries: z(a.csvRaw, a.reportName),
|
|
143
|
+
analyticsTotalUsers: Y(a.csvRaw)
|
|
144
|
+
})), s = e.flatMap((a) => a.analyticsEntries), n = e.map((a) => a.analyticsTotalUsers).filter((a) => a !== null), r = n.length > 0 ? n.reduce((a, m) => a + m, 0) : null, c = s.reduce((a, m) => {
|
|
145
|
+
const L = P(m.eventAction, m.eventLabel), p = a.get(L) ?? [];
|
|
146
|
+
return p.push(m), a.set(L, p), a;
|
|
147
|
+
}, /* @__PURE__ */ new Map()), i = t.map((a) => k(a.csvRaw)), o = i.map((a) => a.startDate).filter((a) => a !== null), l = i.map((a) => a.endDate).filter((a) => a !== null), u = o.length > 0 ? new Date(Math.min(...o.map((a) => a.getTime()))) : null, d = l.length > 0 ? new Date(Math.max(...l.map((a) => a.getTime()))) : null, v = u && d ? `${y(u)} - ${y(d)}` : null;
|
|
148
|
+
return { analyticsLookup: c, analyticsDateRangeLabel: v, analyticsTotalUsers: r };
|
|
149
|
+
};
|
|
150
|
+
export {
|
|
151
|
+
G as ANALYTICS_OVERLAY_SELECTOR,
|
|
152
|
+
Q as EVENT_TYPE_ICON_CLASS,
|
|
153
|
+
$ as LOOKUP_MAX_LENGTH,
|
|
154
|
+
X as REQUIRED_ANALYTICS_HEADER_ROW,
|
|
155
|
+
K as buildAnalyticsAnalysisData,
|
|
156
|
+
P as createAnalyticsLookupKey,
|
|
157
|
+
q as hasRequiredAnalyticsHeaderRow,
|
|
158
|
+
z as parseAnalyticsReportCsv,
|
|
159
|
+
W as toEventType
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=analyticsAnalysisUtils.js.map
|