@economic/taco 2.45.0-alpha.1 → 2.45.0-alpha.10
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/dist/charts/components/Area/AreaChart.d.ts +19 -0
- package/dist/charts/components/Bar/BarChart.d.ts +20 -0
- package/dist/charts/components/Donut/ActiveShape.d.ts +8 -0
- package/dist/charts/components/Donut/CenteredLabel.d.ts +11 -0
- package/dist/charts/components/Donut/DonutChart.d.ts +21 -0
- package/dist/charts/components/Donut/Legend.d.ts +13 -0
- package/dist/charts/components/Donut/util.d.ts +2 -0
- package/dist/charts/components/Legend.d.ts +16 -0
- package/dist/charts/components/Line/LineChart.d.ts +18 -0
- package/dist/charts/components/ResponsiveContainer.d.ts +5 -0
- package/dist/charts/components/Tooltip.d.ts +10 -0
- package/dist/charts/components/types.d.ts +5 -0
- package/dist/charts/utils/color.d.ts +3 -0
- package/dist/charts/utils/common.d.ts +37 -0
- package/dist/components/Alert/Alert.d.ts +1 -1
- package/dist/components/Banner/util.d.ts +0 -1
- package/dist/components/Icon/components/Autopay.d.ts +3 -0
- package/dist/components/Icon/components/AutopayPaused.d.ts +3 -0
- package/dist/components/Icon/components/Experiment.d.ts +3 -0
- package/dist/components/Icon/components/Person.d.ts +3 -0
- package/dist/components/Icon/components/PersonSolid.d.ts +3 -0
- package/dist/components/Icon/components/Wallet.d.ts +3 -0
- package/dist/components/Icon/components/index.d.ts +1 -1
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Menu/components/Item.d.ts +1 -1
- package/dist/components/Menu/components/Link.d.ts +1 -1
- package/dist/components/Navigation2/components/Link.d.ts +1 -1
- package/dist/components/Pagination/PageNumbers.d.ts +0 -1
- package/dist/components/Popover/Popover.d.ts +1 -1
- package/dist/components/Provider/Localization.d.ts +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
- package/dist/components/Report/Report.d.ts +1 -1
- package/dist/components/Select2/components/Option.d.ts +4 -4
- package/dist/components/Select2/components/Search.d.ts +1 -7
- package/dist/components/Table3/Table3.d.ts +2 -14
- package/dist/components/Table3/components/Columns/Cell/EditingDisplayCell.d.ts +0 -1
- package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +3 -4
- package/dist/components/Table3/components/Editing/DiscardChangesConfirmationDialog.d.ts +7 -0
- package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +13 -0
- package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +12 -0
- package/dist/components/Table3/features/useEditingState.d.ts +29 -0
- package/dist/components/Table3/features/useTableEditing.d.ts +28 -37
- package/dist/components/Table3/listeners/useTableEditingListener.d.ts +1 -1
- package/dist/components/Table3/types.d.ts +24 -8
- package/dist/components/Table3/useTable3.d.ts +6 -0
- package/dist/components/Table3/util/editing.d.ts +10 -1
- package/dist/components/Tag/Tag.d.ts +1 -1
- package/dist/esm/index.css +76 -10
- package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js +67 -0
- package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js +120 -0
- package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js +47 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js +27 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js +170 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js +164 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/util.js +5 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/util.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Legend.js +145 -0
- package/dist/esm/packages/taco/src/charts/components/Legend.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js +65 -0
- package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js +10 -0
- package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Tooltip.js +44 -0
- package/dist/esm/packages/taco/src/charts/components/Tooltip.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/utils/color.js +24 -0
- package/dist/esm/packages/taco/src/charts/utils/color.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/utils/common.js +34 -0
- package/dist/esm/packages/taco/src/charts/utils/common.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Accordion/Accordion.js +6 -14
- package/dist/esm/packages/taco/src/components/Accordion/Accordion.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Alert/Alert.js +2 -0
- package/dist/esm/packages/taco/src/components/Alert/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Badge/Badge.js +9 -6
- package/dist/esm/packages/taco/src/components/Badge/Badge.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Banner/util.js +5 -0
- package/dist/esm/packages/taco/src/components/Banner/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Button/Button.js +2 -1
- package/dist/esm/packages/taco/src/components/Button/Button.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Button/util.js +1 -1
- package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js +8 -5
- package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js +1 -0
- package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +2 -4
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Icon/components/Autopay.js +19 -0
- package/dist/esm/packages/taco/src/components/Icon/components/Autopay.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Icon/components/AutopayPaused.js +19 -0
- package/dist/esm/packages/taco/src/components/Icon/components/AutopayPaused.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Icon/components/Experiment.js +20 -0
- package/dist/esm/packages/taco/src/components/Icon/components/Experiment.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Icon/components/Person.js +19 -0
- package/dist/esm/packages/taco/src/components/Icon/components/Person.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Icon/components/PersonSolid.js +19 -0
- package/dist/esm/packages/taco/src/components/Icon/components/PersonSolid.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Icon/components/Wallet.js +19 -0
- package/dist/esm/packages/taco/src/components/Icon/components/Wallet.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Icon/components/index.js +12 -0
- package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Input/util.js +1 -1
- package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/util.js +1 -7
- package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Content.js +5 -0
- package/dist/esm/packages/taco/src/components/Menu/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +2 -2
- package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Popover/Popover.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +5 -3
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +21 -40
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js +7 -5
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Search.js +2 -12
- package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +75 -20
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js +1 -1
- package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Switch/Switch.js +1 -1
- package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +22 -7
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js +1 -2
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +42 -14
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +7 -39
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +19 -12
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js +34 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +73 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js +2 -14
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +96 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +39 -6
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js +4 -17
- package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +527 -0
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +71 -399
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +44 -34
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js +46 -14
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js +19 -23
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Tag/Tag.js +6 -4
- package/dist/esm/packages/taco/src/components/Tag/Tag.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useLazyEffect.js +1 -1
- package/dist/esm/packages/taco/src/hooks/useLazyEffect.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +5 -1
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/BubbleSelect.js +1 -1
- package/dist/esm/packages/taco/src/primitives/BubbleSelect.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js +18 -0
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Option.js +0 -5
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Option.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js +1 -0
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Sortable/components/Item.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +13 -9
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js +15 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +30 -17
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +9 -6
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js +7 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js +11 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +3 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +7 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +6 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +6 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js +2 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/FilterContext.js +6 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/FilterContext.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js +5 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.js +0 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js +11 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js +1 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +34 -8
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js +1 -7
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowExpansion.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowExpansion.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowSelection.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowSelection.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js +12 -7
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFontSizeListener.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFontSizeListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +3 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/dataTypes.js +6 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/dataTypes.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/presets.js +7 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/presets.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js +7 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +19 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/sorting.js.map +1 -1
- package/dist/esm/packages/taco/src/types.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js +32 -11
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/tailwind.js +2 -0
- package/dist/esm/packages/taco/src/utils/tailwind.js.map +1 -1
- package/dist/esm/packages/taco/tailwind.colors.js +122 -0
- package/dist/esm/packages/taco/tailwind.colors.js.map +1 -0
- package/dist/index.css +76 -10
- package/dist/index.d.ts +5 -0
- package/dist/primitives/Collection/components/Root.d.ts +2 -0
- package/dist/primitives/Table/Core/Table.d.ts +1 -0
- package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -0
- package/dist/primitives/Table/Core/components/Columns/Internal/Actions.d.ts +3 -1
- package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Row/RowContext.d.ts +2 -0
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/FilterContext.d.ts +3 -0
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.d.ts +0 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.d.ts +0 -3
- package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +2 -2
- package/dist/primitives/Table/Core/features/useTableStyle.d.ts +3 -3
- package/dist/primitives/Table/Core/types.d.ts +5 -0
- package/dist/primitives/Table/Core/useTable.d.ts +2 -2
- package/dist/primitives/Table/types.d.ts +3 -7
- package/dist/primitives/Table/useTableManager/features/useTableRowExpansion.d.ts +2 -1
- package/dist/primitives/Table/useTableManager/features/useTableServerLoading.d.ts +3 -3
- package/dist/primitives/Table/useTableManager/types.d.ts +0 -1
- package/dist/primitives/Table/useTableManager/useTableManager.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/util/dataTypes.d.ts +1 -1
- package/dist/taco.cjs.development.js +2298 -853
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/dom.d.ts +2 -1
- package/package.json +20 -19
- package/tailwind.colors.js +121 -0
- package/tailwind.config.js +3 -2
- package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +0 -11
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js +0 -90
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js.map +0 -1
@@ -43,10 +43,12 @@ var set = _interopDefault(require('lodash/set'));
|
|
43
43
|
var unset = _interopDefault(require('lodash/unset'));
|
44
44
|
var compact = _interopDefault(require('lodash/compact'));
|
45
45
|
var pullAt = _interopDefault(require('lodash/pullAt'));
|
46
|
-
var
|
46
|
+
var omit = _interopDefault(require('lodash/omit'));
|
47
|
+
var setWith = _interopDefault(require('lodash/setWith'));
|
47
48
|
var TabsPrimitive = require('@radix-ui/react-tabs');
|
48
49
|
var Joyride = require('react-joyride');
|
49
50
|
var Joyride__default = _interopDefault(Joyride);
|
51
|
+
var Recharts = require('recharts');
|
50
52
|
|
51
53
|
const AVAILABLE_COLORS = ['green', 'yellow', 'red', 'blue', 'purple', 'brown', 'pink', 'orange', 'grey', 'transparent'];
|
52
54
|
const getColorByState = state => {
|
@@ -57,6 +59,8 @@ const getColorByState = state => {
|
|
57
59
|
return 'yellow';
|
58
60
|
case 'error':
|
59
61
|
return 'red';
|
62
|
+
case 'experiment':
|
63
|
+
return 'purple';
|
60
64
|
case 'success':
|
61
65
|
return 'green';
|
62
66
|
default:
|
@@ -389,6 +393,36 @@ function IconAttach(props, svgRef) {
|
|
389
393
|
}
|
390
394
|
var Attach = /*#__PURE__*/React.forwardRef(IconAttach);
|
391
395
|
|
396
|
+
function IconAutopayPaused(props, svgRef) {
|
397
|
+
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
398
|
+
fill: "none",
|
399
|
+
xmlns: "http://www.w3.org/2000/svg",
|
400
|
+
viewBox: "0 0 24 24",
|
401
|
+
ref: svgRef
|
402
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
403
|
+
fillRule: "evenodd",
|
404
|
+
clipRule: "evenodd",
|
405
|
+
d: "M9.356 2.503a.743.743 0 10.449 1.417 9.323 9.323 0 011.909-.391 8.998 8.998 0 011.883.013.743.743 0 10.168-1.476 10.484 10.484 0 00-2.195-.016 10.81 10.81 0 00-2.214.453zM7.46 5.037a.743.743 0 10-.817-1.241c-.628.413-1.215.893-1.747 1.433-.52.528-.978 1.103-1.366 1.712a.743.743 0 101.253.798 8.928 8.928 0 011.17-1.467A9.28 9.28 0 017.46 5.037zm9.14-2.22a.743.743 0 00-.59 1.363 7.904 7.904 0 011.611.935c.484.363.914.776 1.287 1.229a.743.743 0 001.147-.945 9.004 9.004 0 00-1.54-1.472 9.387 9.387 0 00-1.915-1.11zM3.767 10.008a.743.743 0 10-1.432-.396A9.316 9.316 0 002 11.795a.743.743 0 101.485.048 7.83 7.83 0 01.282-1.835zm17.716-2.152a.743.743 0 10-1.389.529c.21.549.353 1.126.425 1.723a.743.743 0 101.476-.18 8.81 8.81 0 00-.512-2.072zm-9.28-.732c-.26 0-.527.127-.527.505v.406c-1.567.145-2.577 1.085-2.577 2.426 0 1.125.639 1.862 1.907 2.182l1.296.285c.836.18 1.167.435 1.167.87 0 .558-.441.923-1.26.923-.586 0-1.154-.244-1.67-.714-.332-.278-.54-.36-.796-.36-.412 0-.743.256-.743.709 0 .348.186.684.51.98.482.447 1.26.72 2.143.796v.354c0 .371.272.505.533.505.262 0 .529-.134.529-.505v-.366c1.625-.191 2.64-1.143 2.64-2.519 0-1.133-.652-1.845-1.978-2.156l-1.3-.27c-.738-.145-1.075-.424-1.075-.859 0-.488.436-.876 1.12-.876.581 0 .999.185 1.492.655.29.25.528.36.842.36.366 0 .667-.267.667-.65 0-.325-.174-.667-.499-.975-.43-.418-1.12-.685-1.892-.783v-.418c0-.372-.267-.505-.528-.505zm8.802 8.025a.743.743 0 00-.946.457 7.718 7.718 0 01-2.763 3.704 8.23 8.23 0 01-4.48 1.548 8.628 8.628 0 01-4.69-1.152c-.906-.524-1.649-1.03-2.262-1.749l.79.276a.743.743 0 10.49-1.404l-2.732-.952a.743.743 0 00-.946.458l-.997 2.86a.743.743 0 101.403.49l.45-1.294c.84 1.193 1.88 1.918 3.06 2.601a10.114 10.114 0 005.5 1.35 9.715 9.715 0 005.287-1.83 9.204 9.204 0 003.293-4.417.743.743 0 00-.457-.946z",
|
406
|
+
fill: "currentColor"
|
407
|
+
}));
|
408
|
+
}
|
409
|
+
var AutopayPaused = /*#__PURE__*/React.forwardRef(IconAutopayPaused);
|
410
|
+
|
411
|
+
function IconAutopay(props, svgRef) {
|
412
|
+
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
413
|
+
fill: "none",
|
414
|
+
xmlns: "http://www.w3.org/2000/svg",
|
415
|
+
viewBox: "0 0 24 24",
|
416
|
+
ref: svgRef
|
417
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
418
|
+
fillRule: "evenodd",
|
419
|
+
clipRule: "evenodd",
|
420
|
+
d: "M1.367 6.142a.734.734 0 011.003.269l.83 1.438a9.885 9.885 0 017.774-5.769 9.993 9.993 0 015.73.975 10.135 10.135 0 014.249 4.002.734.734 0 01-1.272.734 8.667 8.667 0 00-3.633-3.422 8.525 8.525 0 00-4.888-.832 8.417 8.417 0 00-6.355 4.376l.749-.433a.734.734 0 01.734 1.271l-2.56 1.479a.734.734 0 01-1.004-.269L1.098 7.145a.734.734 0 01.27-1.003zm2.895 10.273a.734.734 0 011.003.269 7.627 7.627 0 003.384 3.09 8.195 8.195 0 004.668.668 8.64 8.64 0 004.376-2.005c.792-.684 1.427-1.318 1.895-2.138l-.731.422a.734.734 0 01-.734-1.27l2.495-1.442a.734.734 0 011.003.27l1.501 2.6a.734.734 0 01-1.271.734l-.683-1.183c-.6 1.326-1.485 2.229-2.516 3.118a10.107 10.107 0 01-5.122 2.346 9.664 9.664 0 01-5.504-.79 9.095 9.095 0 01-4.032-3.686.734.734 0 01.268-1.003zm7.382-8.75c0-.372.264-.498.522-.498s.521.132.521.499v.413c.763.097 1.446.361 1.87.774.321.304.493.642.493.963 0 .379-.298.643-.66.643-.309 0-.544-.11-.83-.356-.488-.464-.901-.648-1.475-.648-.676 0-1.107.384-1.107.866 0 .43.333.706 1.062.849l1.285.267c1.31.307 1.955 1.01 1.955 2.13 0 1.36-1.004 2.3-2.61 2.489v.361c0 .367-.264.5-.522.5s-.527-.133-.527-.5v-.35c-.872-.074-1.64-.344-2.116-.785-.322-.293-.505-.625-.505-.97 0-.447.327-.7.734-.7.252 0 .459.081.786.357.51.464 1.072.705 1.651.705.809 0 1.245-.361 1.245-.912 0-.43-.327-.682-1.153-.86l-1.281-.282c-1.253-.316-1.885-1.044-1.885-2.155 0-1.325.998-2.254 2.547-2.398v-.401z",
|
421
|
+
fill: "currentColor"
|
422
|
+
}));
|
423
|
+
}
|
424
|
+
var Autopay = /*#__PURE__*/React.forwardRef(IconAutopay);
|
425
|
+
|
392
426
|
function IconAutotextInsert(props, svgRef) {
|
393
427
|
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
394
428
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -1583,6 +1617,22 @@ function IconExpenses(props, svgRef) {
|
|
1583
1617
|
}
|
1584
1618
|
var Expenses = /*#__PURE__*/React.forwardRef(IconExpenses);
|
1585
1619
|
|
1620
|
+
function IconExperiment(props, svgRef) {
|
1621
|
+
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
1622
|
+
fill: "none",
|
1623
|
+
xmlns: "http://www.w3.org/2000/svg",
|
1624
|
+
viewBox: "0 0 20 20",
|
1625
|
+
ref: svgRef
|
1626
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
1627
|
+
fillRule: "evenodd",
|
1628
|
+
clipRule: "evenodd",
|
1629
|
+
d: "M8.962 9.26V5.313h2.843V9.28c0 .376.796 1.24 1.049 1.511L14.5 12.5c-.507.218-3.166-1.19-4.341-.211C7.159 14.789 6 13 6.5 12c.316-.632 2.462-1.803 2.462-2.74zm.24-4.469a.762.762 0 00-.752.772v3.696a.61.61 0 01-.177.43l-2.592 2.6c-.911.913-.281 2.502.992 2.502h7.154c1.25 0 1.89-1.538 1.027-2.466l-2.446-2.63a.61.61 0 01-.162-.415V5.563a.762.762 0 00-.752-.772H9.202z",
|
1630
|
+
fill: "currentColor",
|
1631
|
+
stroke: "currentColor"
|
1632
|
+
}));
|
1633
|
+
}
|
1634
|
+
var Experiment = /*#__PURE__*/React.forwardRef(IconExperiment);
|
1635
|
+
|
1586
1636
|
function IconExportToExcel(props, svgRef) {
|
1587
1637
|
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
1588
1638
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -2624,6 +2674,21 @@ function IconPersonPlus(props, svgRef) {
|
|
2624
2674
|
}
|
2625
2675
|
var PersonPlus = /*#__PURE__*/React.forwardRef(IconPersonPlus);
|
2626
2676
|
|
2677
|
+
function IconPersonSolid(props, svgRef) {
|
2678
|
+
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
2679
|
+
fill: "none",
|
2680
|
+
xmlns: "http://www.w3.org/2000/svg",
|
2681
|
+
viewBox: "0 0 24 24",
|
2682
|
+
ref: svgRef
|
2683
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
2684
|
+
fillRule: "evenodd",
|
2685
|
+
clipRule: "evenodd",
|
2686
|
+
d: "M12 11.5c4.553 0 7.21 2.43 7.969 7.29.24 1.537-.928 2.962-2.608 3.182-.144.018-.29.028-.435.028H7.074C5.376 22 4 20.74 4 19.187c0-.133.01-.266.03-.398C4.79 13.93 7.448 11.5 12 11.5zM12 2c2.112 0 3.825 1.903 3.825 4.25S14.112 10.5 12 10.5c-2.113 0-3.825-1.903-3.825-4.25S9.887 2 12 2z",
|
2687
|
+
fill: "currentColor"
|
2688
|
+
}));
|
2689
|
+
}
|
2690
|
+
var PersonSolid = /*#__PURE__*/React.forwardRef(IconPersonSolid);
|
2691
|
+
|
2627
2692
|
function IconPersonTick(props, svgRef) {
|
2628
2693
|
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
2629
2694
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -2637,6 +2702,21 @@ function IconPersonTick(props, svgRef) {
|
|
2637
2702
|
}
|
2638
2703
|
var PersonTick = /*#__PURE__*/React.forwardRef(IconPersonTick);
|
2639
2704
|
|
2705
|
+
function IconPerson(props, svgRef) {
|
2706
|
+
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
2707
|
+
fill: "none",
|
2708
|
+
xmlns: "http://www.w3.org/2000/svg",
|
2709
|
+
viewBox: "0 0 24 24",
|
2710
|
+
ref: svgRef
|
2711
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
2712
|
+
fillRule: "evenodd",
|
2713
|
+
clipRule: "evenodd",
|
2714
|
+
d: "M12 11.5c4.553 0 7.21 2.43 7.969 7.29.24 1.537-.928 2.962-2.608 3.182-.144.018-.29.028-.435.028H7.074C5.376 22 4 20.74 4 19.187c0-.133.01-.266.03-.398C4.79 13.93 7.448 11.5 12 11.5zm0 1.5c-3.684 0-5.696 1.84-6.346 6.002-.01.061-.015.123-.015.186 0 .68.565 1.238 1.288 1.305l.147.007h9.852c.068 0 .136-.004.203-.013.784-.103 1.329-.768 1.217-1.485C17.696 14.84 15.684 13 12 13zm0-11c2.112 0 3.825 1.903 3.825 4.25S14.112 10.5 12 10.5c-2.113 0-3.825-1.903-3.825-4.25S9.887 2 12 2zm0 1.5c-1.13 0-2.186 1.174-2.186 2.75S10.87 9 12 9s2.186-1.174 2.186-2.75S13.129 3.5 12 3.5z",
|
2715
|
+
fill: "currentColor"
|
2716
|
+
}));
|
2717
|
+
}
|
2718
|
+
var Person = /*#__PURE__*/React.forwardRef(IconPerson);
|
2719
|
+
|
2640
2720
|
function IconPhoneSolid(props, svgRef) {
|
2641
2721
|
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
2642
2722
|
fill: "none",
|
@@ -3406,6 +3486,21 @@ function IconUnreconciled(props, svgRef) {
|
|
3406
3486
|
}
|
3407
3487
|
var Unreconciled = /*#__PURE__*/React.forwardRef(IconUnreconciled);
|
3408
3488
|
|
3489
|
+
function IconWallet(props, svgRef) {
|
3490
|
+
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
3491
|
+
fill: "none",
|
3492
|
+
xmlns: "http://www.w3.org/2000/svg",
|
3493
|
+
viewBox: "0 0 24 24",
|
3494
|
+
ref: svgRef
|
3495
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
3496
|
+
fillRule: "evenodd",
|
3497
|
+
clipRule: "evenodd",
|
3498
|
+
d: "M4.75 4.5h14.5a.25.25 0 01.25.25V7H16a5 5 0 000 10h3.5v2.25a.25.25 0 01-.25.25H4.75a.25.25 0 01-.25-.25V4.75a.25.25 0 01.25-.25zM22 7h-1V4.75A1.75 1.75 0 0019.25 3H4.75A1.75 1.75 0 003 4.75v14.5c0 .966.784 1.75 1.75 1.75h14.5A1.75 1.75 0 0021 19.25V17h1a1 1 0 001-1V8a1 1 0 00-1-1zm-.5 1.5H16a3.5 3.5 0 100 7h5.5v-7zm-5.5 5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z",
|
3499
|
+
fill: "currentColor"
|
3500
|
+
}));
|
3501
|
+
}
|
3502
|
+
var Wallet = /*#__PURE__*/React.forwardRef(IconWallet);
|
3503
|
+
|
3409
3504
|
function IconWarning(props, svgRef) {
|
3410
3505
|
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
3411
3506
|
fill: "none",
|
@@ -3503,6 +3598,8 @@ const icons = {
|
|
3503
3598
|
'attach-cancel': AttachCancel,
|
3504
3599
|
'attach-warning': AttachWarning,
|
3505
3600
|
attach: Attach,
|
3601
|
+
'autopay-paused': AutopayPaused,
|
3602
|
+
autopay: Autopay,
|
3506
3603
|
'autotext-insert': AutotextInsert,
|
3507
3604
|
autotext: Autotext,
|
3508
3605
|
'basic-tabs': BasicTabs,
|
@@ -3593,6 +3690,7 @@ const icons = {
|
|
3593
3690
|
envelope: Envelope,
|
3594
3691
|
'expand-view': ExpandView,
|
3595
3692
|
expenses: Expenses,
|
3693
|
+
experiment: Experiment,
|
3596
3694
|
'export-to-excel': ExportToExcel,
|
3597
3695
|
'export-to-pdf': ExportToPdf,
|
3598
3696
|
export: Export,
|
@@ -3669,7 +3767,9 @@ const icons = {
|
|
3669
3767
|
'person-change': PersonChange,
|
3670
3768
|
'person-minus': PersonMinus,
|
3671
3769
|
'person-plus': PersonPlus,
|
3770
|
+
'person-solid': PersonSolid,
|
3672
3771
|
'person-tick': PersonTick,
|
3772
|
+
person: Person,
|
3673
3773
|
'phone-solid': PhoneSolid,
|
3674
3774
|
phone: Phone,
|
3675
3775
|
play: Play,
|
@@ -3728,6 +3828,7 @@ const icons = {
|
|
3728
3828
|
undo: Undo,
|
3729
3829
|
undock: Undock,
|
3730
3830
|
unreconciled: Unreconciled,
|
3831
|
+
wallet: Wallet,
|
3731
3832
|
warning: Warning,
|
3732
3833
|
webshop: Webshop,
|
3733
3834
|
website: Website,
|
@@ -3797,6 +3898,8 @@ const getIconName = state => {
|
|
3797
3898
|
return 'warning';
|
3798
3899
|
case 'error':
|
3799
3900
|
return 'close';
|
3901
|
+
case 'experiment':
|
3902
|
+
return 'experiment';
|
3800
3903
|
case 'success':
|
3801
3904
|
return 'tick';
|
3802
3905
|
default:
|
@@ -4037,33 +4140,25 @@ const Accordion = props => {
|
|
4037
4140
|
const context = React__default.useMemo(() => ({
|
4038
4141
|
as
|
4039
4142
|
}), [as]);
|
4040
|
-
const type = typeof defaultId === 'string' || typeof id === 'string' ? 'single' : 'multiple';
|
4041
4143
|
let valueProps;
|
4042
4144
|
if (defaultId) {
|
4043
|
-
valueProps =
|
4044
|
-
|
4045
|
-
defaultValue: defaultId
|
4046
|
-
} : {
|
4047
|
-
type: 'multiple',
|
4048
|
-
defaultValue: defaultId
|
4145
|
+
valueProps = {
|
4146
|
+
defaultValue: defaultId || undefined
|
4049
4147
|
};
|
4050
4148
|
} else {
|
4051
|
-
valueProps =
|
4052
|
-
type: 'single',
|
4053
|
-
onValueChange: onChange,
|
4054
|
-
value: id || undefined
|
4055
|
-
} : {
|
4056
|
-
type: 'multiple',
|
4149
|
+
valueProps = {
|
4057
4150
|
onValueChange: onChange,
|
4058
4151
|
value: id || undefined
|
4059
4152
|
};
|
4060
4153
|
}
|
4154
|
+
const type = typeof valueProps.defaultValue === 'string' || typeof valueProps.value === 'string' ? 'single' : 'multiple';
|
4061
4155
|
const className = cn('divide-y divide-grey-200', props.className);
|
4062
4156
|
return /*#__PURE__*/React__default.createElement(AccordionContext.Provider, {
|
4063
4157
|
value: context
|
4064
4158
|
}, /*#__PURE__*/React__default.createElement(AccordionPrimitive.Root, Object.assign({}, otherProps, valueProps, {
|
4065
4159
|
"data-taco": "accordion",
|
4066
|
-
className: className
|
4160
|
+
className: className,
|
4161
|
+
type: type
|
4067
4162
|
})));
|
4068
4163
|
};
|
4069
4164
|
Accordion.Item = Item;
|
@@ -4089,10 +4184,10 @@ const Badge = /*#__PURE__*/React.forwardRef(function Badge(props, ref) {
|
|
4089
4184
|
...otherProps
|
4090
4185
|
} = props;
|
4091
4186
|
const isTransparent = color === 'transparent';
|
4092
|
-
const className = cn('rounded-full border overflow-hidden whitespace-nowrap inline-flex items-center justify-center', {
|
4187
|
+
const className = cn('rounded-full border box-border overflow-hidden whitespace-nowrap inline-flex items-center justify-center', {
|
4093
4188
|
[`border ${getOutlineColorShadeClasses(color)}`]: outline,
|
4094
|
-
[`border-
|
4095
|
-
[`border-
|
4189
|
+
[`border-none font-normal ${getSubtleColorShadeClasses(color)}`]: subtle,
|
4190
|
+
[`border-none ${getColorShadeClasses(color)}`]: !outline && !subtle,
|
4096
4191
|
'h-4 min-w-0 py-0 px-1 text-xs': small,
|
4097
4192
|
'h-2 w-2 min-w-0': compact,
|
4098
4193
|
'font-bold': outline || !subtle,
|
@@ -4104,12 +4199,15 @@ const Badge = /*#__PURE__*/React.forwardRef(function Badge(props, ref) {
|
|
4104
4199
|
if (compact) {
|
4105
4200
|
return /*#__PURE__*/React.createElement(VisuallyHidden, null, children);
|
4106
4201
|
}
|
4202
|
+
const contentToRender = typeof children === 'string' ? /*#__PURE__*/React.createElement("span", {
|
4203
|
+
className: "items-center truncate"
|
4204
|
+
}, children) : children;
|
4107
4205
|
if (status) {
|
4108
4206
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
4109
|
-
className: cn('mr-1 h-2 w-2 rounded-full', getColorShadeClasses(color))
|
4110
|
-
}),
|
4207
|
+
className: cn('mr-1 h-2 w-2 shrink-0 rounded-full', getColorShadeClasses(color))
|
4208
|
+
}), contentToRender);
|
4111
4209
|
}
|
4112
|
-
return
|
4210
|
+
return contentToRender;
|
4113
4211
|
};
|
4114
4212
|
return /*#__PURE__*/React.createElement("span", Object.assign({}, otherProps, {
|
4115
4213
|
"aria-atomic": "true",
|
@@ -4137,6 +4235,11 @@ const getBannerIcon = type => {
|
|
4137
4235
|
icon: "close",
|
4138
4236
|
color: "red"
|
4139
4237
|
});
|
4238
|
+
case 'experiment':
|
4239
|
+
return /*#__PURE__*/React__default.createElement(BadgeIcon, {
|
4240
|
+
icon: "experiment",
|
4241
|
+
color: "purple"
|
4242
|
+
});
|
4140
4243
|
case 'warning':
|
4141
4244
|
return /*#__PURE__*/React__default.createElement(BadgeIcon, {
|
4142
4245
|
icon: "warning",
|
@@ -4169,7 +4272,7 @@ const useMergedRef = ref => {
|
|
4169
4272
|
};
|
4170
4273
|
|
4171
4274
|
// taken from react-aria
|
4172
|
-
const FOCUSABLE_ELEMENTS = ['
|
4275
|
+
const FOCUSABLE_ELEMENTS = ['[tabindex]:not([disabled])', 'input:not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'button:not([disabled])', 'a[href]', 'area[href]', 'summary', 'iframe', 'object', 'embed', 'audio[controls]', 'video[controls]', '[contenteditable]', 'details:not([disabled])', 'summary:not(:disabled)'];
|
4173
4276
|
const hasFocusableElement = element => {
|
4174
4277
|
if (!element) {
|
4175
4278
|
return null;
|
@@ -4195,13 +4298,20 @@ const getNextFocussableElement = currentElement => {
|
|
4195
4298
|
if (!currentElement) {
|
4196
4299
|
return null;
|
4197
4300
|
}
|
4198
|
-
|
4301
|
+
let focussableElements = [...document.querySelectorAll(FOCUSABLE_ELEMENTS.join(','))];
|
4199
4302
|
const currentElementIndex = focussableElements.indexOf(currentElement);
|
4200
|
-
|
4201
|
-
|
4202
|
-
|
4303
|
+
if (currentElementIndex > -1) {
|
4304
|
+
focussableElements = focussableElements.slice(currentElementIndex + 1).filter(element => element.getAttribute('tabindex') !== '-1');
|
4305
|
+
if (focussableElements.length) {
|
4306
|
+
var _focussableElements$;
|
4307
|
+
focussableElements = focussableElements.filter(element => {
|
4308
|
+
var _element$checkVisibil, _element$checkVisibil2;
|
4309
|
+
return (_element$checkVisibil = (_element$checkVisibil2 = element.checkVisibility) === null || _element$checkVisibil2 === void 0 ? void 0 : _element$checkVisibil2.call(element)) !== null && _element$checkVisibil !== void 0 ? _element$checkVisibil : true;
|
4310
|
+
});
|
4311
|
+
return (_focussableElements$ = focussableElements[0]) !== null && _focussableElements$ !== void 0 ? _focussableElements$ : null;
|
4312
|
+
}
|
4203
4313
|
}
|
4204
|
-
return
|
4314
|
+
return null;
|
4205
4315
|
};
|
4206
4316
|
const getOverlaySelector = element => {
|
4207
4317
|
switch (element === null || element === void 0 ? void 0 : element.getAttribute('role')) {
|
@@ -4213,7 +4323,7 @@ const getOverlaySelector = element => {
|
|
4213
4323
|
return undefined;
|
4214
4324
|
}
|
4215
4325
|
};
|
4216
|
-
function
|
4326
|
+
function isElementTriggeredFromContainer(element, container) {
|
4217
4327
|
var _getOverlaySelector, _element$closest;
|
4218
4328
|
const selector = (_getOverlaySelector = getOverlaySelector(element)) !== null && _getOverlaySelector !== void 0 ? _getOverlaySelector : getOverlaySelector((_element$closest = element === null || element === void 0 ? void 0 : element.closest('[role=dialog],[role=menu]')) !== null && _element$closest !== void 0 ? _element$closest : null);
|
4219
4329
|
if (selector) {
|
@@ -4222,13 +4332,19 @@ function isElementInsideOrTriggeredFromContainer(element, container) {
|
|
4222
4332
|
return true;
|
4223
4333
|
}
|
4224
4334
|
const elementInDocument = document.querySelector(escapedSelector);
|
4335
|
+
if (elementInDocument === container) {
|
4336
|
+
return true;
|
4337
|
+
}
|
4225
4338
|
// if the element does exist, see if it is itself connected to somethng that was triggered from the container
|
4226
4339
|
if (elementInDocument) {
|
4227
|
-
return
|
4340
|
+
return isElementTriggeredFromContainer(elementInDocument, container);
|
4228
4341
|
}
|
4229
4342
|
return false;
|
4230
4343
|
}
|
4231
|
-
return
|
4344
|
+
return false;
|
4345
|
+
}
|
4346
|
+
function isElementInsideOrTriggeredFromContainer(element, container) {
|
4347
|
+
return isElementTriggeredFromContainer(element, container) || !!(container !== null && container !== void 0 && container.contains(element));
|
4232
4348
|
}
|
4233
4349
|
function isElementInsideOverlay(element) {
|
4234
4350
|
return !!(element !== null && element !== void 0 && element.closest('[role=dialog],[role=menu]'));
|
@@ -4241,7 +4357,15 @@ function isElementInteractive(element) {
|
|
4241
4357
|
if (!element) {
|
4242
4358
|
return false;
|
4243
4359
|
}
|
4244
|
-
|
4360
|
+
const interactiveElements = ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'LABEL', 'OPTION'];
|
4361
|
+
const isInteractive = interactiveElements.includes(element.tagName) && !element.hidden && !element.disabled && !element.readOnly;
|
4362
|
+
// sometimes buttons contain content like an icon, and we can't rely on pointer events being disabled
|
4363
|
+
// so search for a focusable parent
|
4364
|
+
if (!isInteractive) {
|
4365
|
+
const focusableParent = element.closest(FOCUSABLE_ELEMENTS.join(','));
|
4366
|
+
return focusableParent ? interactiveElements.includes(focusableParent.tagName) : false;
|
4367
|
+
}
|
4368
|
+
return isInteractive;
|
4245
4369
|
}
|
4246
4370
|
function isElementInsideTable3OrReport(element) {
|
4247
4371
|
return !!(element !== null && element !== void 0 && element.closest('[data-taco^=table]'));
|
@@ -4374,7 +4498,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(props, ref) {
|
|
4374
4498
|
});
|
4375
4499
|
|
4376
4500
|
const getButtonClasses = () => {
|
4377
|
-
return 'flex-shrink-0 min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center focus-visible:yt-focus aria-disabled:cursor-not-allowed';
|
4501
|
+
return 'flex-shrink-0 min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center focus-visible:yt-focus data-[state=instant-open]:yt-focus aria-disabled:cursor-not-allowed';
|
4378
4502
|
};
|
4379
4503
|
const getAppearanceClasses = (value, icon = false) => {
|
4380
4504
|
switch (value) {
|
@@ -4722,7 +4846,9 @@ const defaultLocalisationTexts = {
|
|
4722
4846
|
tooltip: 'Edit table'
|
4723
4847
|
},
|
4724
4848
|
create: {
|
4725
|
-
label: 'New'
|
4849
|
+
label: 'New',
|
4850
|
+
disabled: 'Existing new row must be saved',
|
4851
|
+
saving: 'Saving...'
|
4726
4852
|
}
|
4727
4853
|
},
|
4728
4854
|
clearChangesConfirmationDialog: {
|
@@ -4744,8 +4870,8 @@ const defaultLocalisationTexts = {
|
|
4744
4870
|
},
|
4745
4871
|
validation: {
|
4746
4872
|
alert: {
|
4747
|
-
titleOne: '[COUNT] unsaved
|
4748
|
-
titlePlural: '[COUNT] unsaved
|
4873
|
+
titleOne: '[COUNT] unsaved row:',
|
4874
|
+
titlePlural: '[COUNT] unsaved rows:',
|
4749
4875
|
messageOne: "[COLUMN] [ROW] is incomplete and hasn't been saved.",
|
4750
4876
|
messagePlural: "[COLUMN] [ROW] are incomplete and haven't been saved.",
|
4751
4877
|
messageRow: 'Row',
|
@@ -4853,7 +4979,8 @@ const Base$1 = /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
4853
4979
|
}, props.className);
|
4854
4980
|
return createButtonWithTooltip({
|
4855
4981
|
...otherProps,
|
4856
|
-
'data-taco': 'button'
|
4982
|
+
'data-taco': 'button',
|
4983
|
+
'data-appearance': appearance
|
4857
4984
|
}, className, ref);
|
4858
4985
|
});
|
4859
4986
|
const Button$1 = /*#__PURE__*/React.forwardRef(function Button(props, ref) {
|
@@ -5241,7 +5368,7 @@ const getInputClasses = props => {
|
|
5241
5368
|
const disabled = props.disabled || !!props['aria-disabled'];
|
5242
5369
|
const readOnly = props.readOnly || !!props['aria-readonly'];
|
5243
5370
|
const invalid = props.invalid || !!props['aria-invalid'];
|
5244
|
-
return cn('peer text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)] focus
|
5371
|
+
return cn('peer text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)] focus:yt-focus',
|
5245
5372
|
// hide the arrow controls on input[type=number]
|
5246
5373
|
'[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none', {
|
5247
5374
|
'bg-white': !props.highlighted && !readOnly,
|
@@ -5745,13 +5872,7 @@ const searchForString = (child, value, strategy = 'includes') => {
|
|
5745
5872
|
}
|
5746
5873
|
return searchForString((_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.children, value, strategy);
|
5747
5874
|
} else {
|
5748
|
-
|
5749
|
-
const valueLowerCase = String(value).toLowerCase();
|
5750
|
-
if (strategy === 'startsWith') {
|
5751
|
-
return childLowerCase.startsWith(valueLowerCase);
|
5752
|
-
} else {
|
5753
|
-
return childLowerCase.includes(valueLowerCase);
|
5754
|
-
}
|
5875
|
+
return child.toString().toLowerCase()[strategy](String(value).toLowerCase());
|
5755
5876
|
}
|
5756
5877
|
} catch {
|
5757
5878
|
return false;
|
@@ -5943,7 +6064,6 @@ const useCombobox = ({
|
|
5943
6064
|
}, [open]);
|
5944
6065
|
// event handlers
|
5945
6066
|
const handleInputBlur = event => {
|
5946
|
-
event.persist();
|
5947
6067
|
if (listRef.current && event.relatedTarget === listRef.current) {
|
5948
6068
|
event.preventDefault();
|
5949
6069
|
return;
|
@@ -5956,7 +6076,14 @@ const useCombobox = ({
|
|
5956
6076
|
if (parents !== null && parents.length > 0) {
|
5957
6077
|
event.detail.parents = parents;
|
5958
6078
|
}
|
5959
|
-
|
6079
|
+
const isComboboxChangeEvent = event => {
|
6080
|
+
return !event.isTrusted; // this makes sure we only take our own custom event, and not the browser default blur on tab.
|
6081
|
+
};
|
6082
|
+
// Only trigger onChange if this is our custom event (not a browser blur event)
|
6083
|
+
// or if the input was cleared.
|
6084
|
+
if (isComboboxChangeEvent(event) || event.target.value === '' && !inline) {
|
6085
|
+
onChange(event);
|
6086
|
+
}
|
5960
6087
|
}
|
5961
6088
|
if (props.onBlur) {
|
5962
6089
|
props.onBlur(event);
|
@@ -5970,12 +6097,10 @@ const useCombobox = ({
|
|
5970
6097
|
setOpen(true);
|
5971
6098
|
}
|
5972
6099
|
if (onClick) {
|
5973
|
-
event.persist();
|
5974
6100
|
onClick(event);
|
5975
6101
|
}
|
5976
6102
|
};
|
5977
6103
|
const handleInputKeyDown = event => {
|
5978
|
-
event.persist();
|
5979
6104
|
if (!event.ctrlKey && !event.metaKey) {
|
5980
6105
|
switch (event.key) {
|
5981
6106
|
case 'Backspace':
|
@@ -6044,7 +6169,6 @@ const useCombobox = ({
|
|
6044
6169
|
}
|
6045
6170
|
}
|
6046
6171
|
if (!event.isDefaultPrevented() && onKeyDown) {
|
6047
|
-
event.persist();
|
6048
6172
|
onKeyDown(event);
|
6049
6173
|
}
|
6050
6174
|
};
|
@@ -6300,6 +6424,7 @@ const useDatepicker = ({
|
|
6300
6424
|
setInternalValue(event.target.value);
|
6301
6425
|
};
|
6302
6426
|
const handleChange = date => {
|
6427
|
+
// Update both the input value and calendar view date when selecting a date
|
6303
6428
|
setInputValueByRef(inputRef.current, format(date, formatting.date), 'focusout');
|
6304
6429
|
};
|
6305
6430
|
const handleKeyDown = event => {
|
@@ -7647,7 +7772,7 @@ const Switch = /*#__PURE__*/React.forwardRef(function Switch(props, ref) {
|
|
7647
7772
|
onCheckedChange: onChange,
|
7648
7773
|
ref: ref
|
7649
7774
|
}), /*#__PURE__*/React.createElement(PrimitiveSwitch.Thumb, {
|
7650
|
-
className: "
|
7775
|
+
className: "pointer-events-none mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform will-change-transform group-disabled:opacity-50 group-aria-checked:translate-x-[1.1rem]"
|
7651
7776
|
}));
|
7652
7777
|
if (label) {
|
7653
7778
|
const labelContainerClassName = cn('flex self-start cursor-pointer', {
|
@@ -8209,6 +8334,11 @@ const Content$8 = /*#__PURE__*/React.forwardRef(function MenuContent(props, ref)
|
|
8209
8334
|
if (child.props.shortcut) {
|
8210
8335
|
shortcuts.push(createShortcutKeyDownHandler(child.props.shortcut, event => {
|
8211
8336
|
event.preventDefault();
|
8337
|
+
const dialog = document.querySelector('[role="dialog"]');
|
8338
|
+
// Don't trigger the shortcut if it is outside of the dialog
|
8339
|
+
if (dialog && !(dialog !== null && dialog !== void 0 && dialog.contains(internalRef.current))) {
|
8340
|
+
return;
|
8341
|
+
}
|
8212
8342
|
menu === null || menu === void 0 ? void 0 : menu.open();
|
8213
8343
|
setTimeout(() => {
|
8214
8344
|
var _childrenRefs$current, _childrenRefs$current2;
|
@@ -8283,7 +8413,7 @@ const Shortcut = ({
|
|
8283
8413
|
className: className
|
8284
8414
|
}), texts.map(key => (/*#__PURE__*/React__default.createElement("kbd", {
|
8285
8415
|
key: key,
|
8286
|
-
className: "font-display text-grey-700 [[data-taco=tooltip]_&]:bg-grey-300/[0.25] rounded-sm bg-black/[0.09] px-1 text-center font-bold [[data-taco=tooltip]_&]:text-white"
|
8416
|
+
className: "font-display text-grey-700 [[data-taco=tooltip]_&]:bg-grey-300/[0.25] rounded-sm bg-black/[0.09] px-1 text-center font-bold [[data-appearance=danger]_&]:text-white [[data-appearance=primary]_&]:text-white [[data-taco=tooltip]_&]:text-white"
|
8287
8417
|
}, key))));
|
8288
8418
|
};
|
8289
8419
|
|
@@ -8707,10 +8837,10 @@ const ModeSwitch = /*#__PURE__*/React.forwardRef(function ModeSwitch(props, ref)
|
|
8707
8837
|
onCheckedChange: onChange,
|
8708
8838
|
ref: ref
|
8709
8839
|
}), /*#__PURE__*/React.createElement(PrimitiveSwitch.Thumb, {
|
8710
|
-
className: "
|
8840
|
+
className: "pointer-events-none flex h-6 w-6 items-center justify-center rounded-full bg-white transition-transform will-change-transform group-disabled:opacity-50 group-aria-checked:translate-x-[100%]"
|
8711
8841
|
}, /*#__PURE__*/React.createElement(Icon, {
|
8712
8842
|
name: "edit-simple",
|
8713
|
-
className: "!h-5 !w-5"
|
8843
|
+
className: "pointer-events-none !h-5 !w-5"
|
8714
8844
|
})));
|
8715
8845
|
});
|
8716
8846
|
ModeSwitch.displayName = 'ModeSwitch';
|
@@ -9823,11 +9953,6 @@ const fixedForwardRef = React__default.forwardRef;
|
|
9823
9953
|
TableFilterComparator[TableFilterComparator["HasAllOf"] = 12] = "HasAllOf";
|
9824
9954
|
TableFilterComparator[TableFilterComparator["HasNoneOf"] = 13] = "HasNoneOf";
|
9825
9955
|
})(exports.TableFilterComparator || (exports.TableFilterComparator = {}));
|
9826
|
-
(function (TableServerLoadAllState) {
|
9827
|
-
TableServerLoadAllState[TableServerLoadAllState["Incomplete"] = 0] = "Incomplete";
|
9828
|
-
TableServerLoadAllState[TableServerLoadAllState["Loading"] = 1] = "Loading";
|
9829
|
-
TableServerLoadAllState[TableServerLoadAllState["Completed"] = 2] = "Completed";
|
9830
|
-
})(exports.TableServerLoadAllState || (exports.TableServerLoadAllState = {}));
|
9831
9956
|
|
9832
9957
|
const dataTypes = {
|
9833
9958
|
auto: {
|
@@ -9865,9 +9990,13 @@ const dataTypes = {
|
|
9865
9990
|
if (value === undefined) {
|
9866
9991
|
return '';
|
9867
9992
|
}
|
9868
|
-
|
9993
|
+
const formatter = new Intl.NumberFormat(options === null || options === void 0 ? void 0 : (_options$localization2 = options.localization) === null || _options$localization2 === void 0 ? void 0 : _options$localization2.locale, {
|
9869
9994
|
minimumFractionDigits: 2
|
9870
|
-
})
|
9995
|
+
});
|
9996
|
+
const decimalSeperator = formatter.format(1.1).substring(1, 2);
|
9997
|
+
const localisedValue = formatter.format(Number(value));
|
9998
|
+
const localisedValueWithoutThousandsSeperator = decimalSeperator === '.' ? localisedValue.replace(',', '') : localisedValue.replace('.', '');
|
9999
|
+
return [localisedValue, localisedValueWithoutThousandsSeperator];
|
9871
10000
|
}
|
9872
10001
|
}
|
9873
10002
|
};
|
@@ -10015,7 +10144,13 @@ function isMatched(searchQuery, cellValue, dataType, localization) {
|
|
10015
10144
|
const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, {
|
10016
10145
|
localization
|
10017
10146
|
});
|
10018
|
-
if (
|
10147
|
+
if (Array.isArray(cellDisplayValue)) {
|
10148
|
+
for (const displayValue of cellDisplayValue) {
|
10149
|
+
if (isWeakContains(displayValue, searchQuery)) {
|
10150
|
+
return true;
|
10151
|
+
}
|
10152
|
+
}
|
10153
|
+
} else if (cellDisplayValue !== undefined && isWeakContains(cellDisplayValue, searchQuery)) {
|
10019
10154
|
return true;
|
10020
10155
|
}
|
10021
10156
|
}
|
@@ -10313,10 +10448,15 @@ function processChildren(child, columns, defaultSizing, defaultSorting, defaultV
|
|
10313
10448
|
column.cell = info => renderer(info.getValue(), info.row.original);
|
10314
10449
|
} else if (dataTypeProperties.getDisplayValue) {
|
10315
10450
|
const dataTypeRenderer = value => {
|
10316
|
-
var _dataTypeProperties$g
|
10317
|
-
|
10451
|
+
var _dataTypeProperties$g;
|
10452
|
+
const displayValue = (_dataTypeProperties$g = dataTypeProperties.getDisplayValue) === null || _dataTypeProperties$g === void 0 ? void 0 : _dataTypeProperties$g.call(dataTypeProperties, value, {
|
10318
10453
|
localization
|
10319
|
-
})
|
10454
|
+
});
|
10455
|
+
if (Array.isArray(displayValue)) {
|
10456
|
+
var _displayValue$;
|
10457
|
+
return (_displayValue$ = displayValue[0]) !== null && _displayValue$ !== void 0 ? _displayValue$ : value;
|
10458
|
+
}
|
10459
|
+
return displayValue !== null && displayValue !== void 0 ? displayValue : value;
|
10320
10460
|
};
|
10321
10461
|
column.cell = info => dataTypeRenderer(info.getValue());
|
10322
10462
|
column.meta.renderer = dataTypeRenderer;
|
@@ -10413,6 +10553,15 @@ function configureReactTableOptions(options, props, localization) {
|
|
10413
10553
|
// We don't want to expose internal Tanstack Table row, so we need to wrap enableRowSelection callback into additional function,
|
10414
10554
|
// which receives the React Table Row object and passes row.original to a callback.
|
10415
10555
|
const reactTableEnableRowSelection = typeof options.enableRowSelection === 'function' ? row => options.enableRowSelection(row.original) : options.enableRowSelection;
|
10556
|
+
let getRowId;
|
10557
|
+
if (props.rowIdentityAccessor) {
|
10558
|
+
getRowId = (originalRow, index) => {
|
10559
|
+
if (originalRow) {
|
10560
|
+
return String(originalRow[props.rowIdentityAccessor]);
|
10561
|
+
}
|
10562
|
+
return String(index);
|
10563
|
+
};
|
10564
|
+
}
|
10416
10565
|
const tableOptions = {
|
10417
10566
|
defaultColumn: {
|
10418
10567
|
enableColumnFilter: options.enableFiltering || true,
|
@@ -10431,11 +10580,13 @@ function configureReactTableOptions(options, props, localization) {
|
|
10431
10580
|
enableGrouping: true,
|
10432
10581
|
enableHiding: (_options$enableColumn2 = options.enableColumnHiding) !== null && _options$enableColumn2 !== void 0 ? _options$enableColumn2 : false,
|
10433
10582
|
enablePinning: (_options$enableColumn3 = options.enableColumnFreezing) !== null && _options$enableColumn3 !== void 0 ? _options$enableColumn3 : false,
|
10583
|
+
enableRowPinning: true,
|
10434
10584
|
enableRowSelection: reactTableEnableRowSelection !== null && reactTableEnableRowSelection !== void 0 ? reactTableEnableRowSelection : false,
|
10435
10585
|
enableSorting: (_options$enableSortin = options.enableSorting) !== null && _options$enableSortin !== void 0 ? _options$enableSortin : false,
|
10436
10586
|
// models for default features
|
10437
10587
|
getExpandedRowModel: reactTable.getExpandedRowModel(),
|
10438
10588
|
getGroupedRowModel: reactTable.getGroupedRowModel(),
|
10589
|
+
getRowId,
|
10439
10590
|
groupedColumnMode: false
|
10440
10591
|
};
|
10441
10592
|
if (tableOptions.enableColumnResizing) {
|
@@ -10515,6 +10666,7 @@ const DEFAULT_PRESET = {
|
|
10515
10666
|
enableColumnHiding: false,
|
10516
10667
|
enableColumnResizing: false,
|
10517
10668
|
enableRowExpansion: false,
|
10669
|
+
enableRowExpansionAll: true,
|
10518
10670
|
enableRowSelection: false,
|
10519
10671
|
// custom -- common between all table types
|
10520
10672
|
enableColumnOrdering: false,
|
@@ -10541,6 +10693,7 @@ const presets = {
|
|
10541
10693
|
enableColumnHiding: true,
|
10542
10694
|
enableColumnResizing: true,
|
10543
10695
|
enableRowExpansion: true,
|
10696
|
+
enableRowExpansionAll: true,
|
10544
10697
|
enableRowSelection: true,
|
10545
10698
|
// custom -- common between all table types
|
10546
10699
|
enableColumnOrdering: true,
|
@@ -10566,6 +10719,7 @@ const presets = {
|
|
10566
10719
|
enableColumnHiding: false,
|
10567
10720
|
enableColumnResizing: false,
|
10568
10721
|
enableRowExpansion: true,
|
10722
|
+
enableRowExpansionAll: true,
|
10569
10723
|
enableRowSelection: true,
|
10570
10724
|
// custom -- common between all table types
|
10571
10725
|
enableColumnOrdering: false,
|
@@ -10591,6 +10745,7 @@ const presets = {
|
|
10591
10745
|
enableColumnHiding: false,
|
10592
10746
|
enableColumnResizing: false,
|
10593
10747
|
enableRowExpansion: true,
|
10748
|
+
enableRowExpansionAll: true,
|
10594
10749
|
enableRowSelection: false,
|
10595
10750
|
// custom -- common between all table types
|
10596
10751
|
enableColumnOrdering: false,
|
@@ -10608,7 +10763,7 @@ const presets = {
|
|
10608
10763
|
}
|
10609
10764
|
};
|
10610
10765
|
function getTableFeaturePreset(props) {
|
10611
|
-
var _props$enableRowActio, _props$enableRowClick, _props$enableRowDrag, _props$enableRowDrop, _props$enableRowGoto, _props$enableRowExpan, _props$enableRowSelec, _props$enableFilterin, _props$enableSearch, _props$enableSorting, _props$enableColumnFr, _props$enableColumnHi, _props$enableColumnRe, _props$enableColumnOr, _props$enableFontSize, _props$enableFooter, _props$enablePrinting, _props$enableRowActiv, _props$rowActions, _props$enableRowHeigh, _props$enableSaveSett;
|
10766
|
+
var _props$enableRowActio, _props$enableRowClick, _props$enableRowDrag, _props$enableRowDrop, _props$enableRowGoto, _props$enableRowExpan, _props$enableRowExpan2, _props$enableRowSelec, _props$enableFilterin, _props$enableSearch, _props$enableSorting, _props$enableColumnFr, _props$enableColumnHi, _props$enableColumnRe, _props$enableColumnOr, _props$enableFontSize, _props$enableFooter, _props$enablePrinting, _props$enableRowActiv, _props$rowActions, _props$enableRowHeigh, _props$enableSaveSett;
|
10612
10767
|
const presetOptions = props.preset ? presets[props.preset] : DEFAULT_PRESET;
|
10613
10768
|
const enableRowActions = (_props$enableRowActio = props.enableRowActions) !== null && _props$enableRowActio !== void 0 ? _props$enableRowActio : presetOptions.enableRowActions;
|
10614
10769
|
const enableRowClick = (_props$enableRowClick = props.enableRowClick) !== null && _props$enableRowClick !== void 0 ? _props$enableRowClick : presetOptions.enableRowClick;
|
@@ -10616,6 +10771,7 @@ function getTableFeaturePreset(props) {
|
|
10616
10771
|
const enableRowDrop = (_props$enableRowDrop = props.enableRowDrop) !== null && _props$enableRowDrop !== void 0 ? _props$enableRowDrop : presetOptions.enableRowDrop;
|
10617
10772
|
const enableRowGoto = (_props$enableRowGoto = props.enableRowGoto) !== null && _props$enableRowGoto !== void 0 ? _props$enableRowGoto : presetOptions.enableRowGoto;
|
10618
10773
|
const enableRowExpansion = (_props$enableRowExpan = props.enableRowExpansion) !== null && _props$enableRowExpan !== void 0 ? _props$enableRowExpan : presetOptions.enableRowExpansion;
|
10774
|
+
const enableRowExpansionAll = (_props$enableRowExpan2 = props.enableRowExpansionAll) !== null && _props$enableRowExpan2 !== void 0 ? _props$enableRowExpan2 : presetOptions.enableRowExpansionAll;
|
10619
10775
|
const enableRowSelection = (_props$enableRowSelec = props.enableRowSelection) !== null && _props$enableRowSelec !== void 0 ? _props$enableRowSelec : presetOptions.enableRowSelection;
|
10620
10776
|
return {
|
10621
10777
|
// react-table built-in
|
@@ -10640,6 +10796,7 @@ function getTableFeaturePreset(props) {
|
|
10640
10796
|
enableRowDrag: enableRowDrag && !!props.onRowDrag,
|
10641
10797
|
enableRowDrop: enableRowDrop && !!props.onRowDrop,
|
10642
10798
|
enableRowGoto: enableRowGoto && !!props.onRowGoto,
|
10799
|
+
enableRowExpansionAll: enableRowExpansion && enableRowExpansionAll && !!props.rowExpansionRenderer,
|
10643
10800
|
enableRowHeight: (_props$enableRowHeigh = props.enableRowHeight) !== null && _props$enableRowHeigh !== void 0 ? _props$enableRowHeigh : presetOptions.enableRowHeight,
|
10644
10801
|
enableSaveSettings: (_props$enableSaveSett = props.enableSaveSettings) !== null && _props$enableSaveSett !== void 0 ? _props$enableSaveSett : presetOptions.enableSaveSettings
|
10645
10802
|
};
|
@@ -10884,9 +11041,10 @@ function useTableRowClick(isEnabled = false, onRowClick) {
|
|
10884
11041
|
};
|
10885
11042
|
}
|
10886
11043
|
|
10887
|
-
function useTableRowExpansion(isEnabled = false, rowExpansionRenderer) {
|
11044
|
+
function useTableRowExpansion(isEnabled = false, canExpandAll = true, rowExpansionRenderer) {
|
10888
11045
|
return {
|
10889
11046
|
isEnabled,
|
11047
|
+
canExpandAll,
|
10890
11048
|
rowExpansionRenderer: isEnabled ? rowExpansionRenderer : undefined
|
10891
11049
|
};
|
10892
11050
|
}
|
@@ -10917,6 +11075,7 @@ function useTableRowHeight(isEnabled = false, defaultRowHeight = 'medium') {
|
|
10917
11075
|
function useTableRowSelection(isEnabled = false) {
|
10918
11076
|
const lastSelectedRowIndex = React__default.useRef();
|
10919
11077
|
const onKeyDown = React__default.useCallback((event, table) => {
|
11078
|
+
var _event$target;
|
10920
11079
|
if (!isEnabled || !table.options.enableRowSelection || event.defaultPrevented) {
|
10921
11080
|
return;
|
10922
11081
|
}
|
@@ -10931,7 +11090,7 @@ function useTableRowSelection(isEnabled = false) {
|
|
10931
11090
|
(_rows$rowActiveIndex2 = rows[rowActiveIndex]) === null || _rows$rowActiveIndex2 === void 0 ? void 0 : _rows$rowActiveIndex2.toggleSelected();
|
10932
11091
|
}
|
10933
11092
|
return;
|
10934
|
-
} else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
|
11093
|
+
} else if ((event.ctrlKey || event.metaKey) && event.key === 'a' && !['INPUT', 'TEXTAREA'].includes((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName)) {
|
10935
11094
|
event.preventDefault();
|
10936
11095
|
table.toggleAllRowsSelected();
|
10937
11096
|
return;
|
@@ -11336,10 +11495,16 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
11336
11495
|
}, invalidate];
|
11337
11496
|
}
|
11338
11497
|
|
11339
|
-
function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE) {
|
11498
|
+
function useTableServerLoading(length, data, loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE) {
|
11340
11499
|
const isEnabled = !!loadPage && !!loadAll;
|
11341
11500
|
const [isReady, setReady] = React__default.useState(false);
|
11342
|
-
const [
|
11501
|
+
const [loading, setLoading] = React__default.useState(false);
|
11502
|
+
const hasLoadedAll = React__default.useMemo(() => {
|
11503
|
+
if (data.length !== length || data.some(x => x === undefined)) {
|
11504
|
+
return false;
|
11505
|
+
}
|
11506
|
+
return true;
|
11507
|
+
}, [data, length]);
|
11343
11508
|
let _loadPage;
|
11344
11509
|
let _loadAll;
|
11345
11510
|
let _loadAllIfNeeded;
|
@@ -11364,9 +11529,9 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
|
|
11364
11529
|
try {
|
11365
11530
|
const _temp2 = function () {
|
11366
11531
|
if (typeof loadAll === 'function') {
|
11367
|
-
|
11532
|
+
setLoading(true);
|
11368
11533
|
return Promise.resolve(loadAll(...args)).then(function () {
|
11369
|
-
|
11534
|
+
setLoading(false);
|
11370
11535
|
setReady(true);
|
11371
11536
|
});
|
11372
11537
|
}
|
@@ -11379,7 +11544,7 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
|
|
11379
11544
|
_loadAllIfNeeded = function (...args) {
|
11380
11545
|
try {
|
11381
11546
|
const _temp3 = function () {
|
11382
|
-
if (
|
11547
|
+
if (!hasLoadedAll) {
|
11383
11548
|
var _loadAll2;
|
11384
11549
|
return Promise.resolve((_loadAll2 = _loadAll) === null || _loadAll2 === void 0 ? void 0 : _loadAll2(...args)).then(function () {});
|
11385
11550
|
}
|
@@ -11396,7 +11561,7 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
|
|
11396
11561
|
loadPage: _loadPage,
|
11397
11562
|
loadAll: _loadAll,
|
11398
11563
|
loadAllIfNeeded: _loadAllIfNeeded,
|
11399
|
-
|
11564
|
+
loading,
|
11400
11565
|
pageSize
|
11401
11566
|
};
|
11402
11567
|
}
|
@@ -11469,7 +11634,7 @@ function useLazyEffect(effect, deps) {
|
|
11469
11634
|
const readyRef = React__default.useRef(false);
|
11470
11635
|
React__default.useEffect(() => {
|
11471
11636
|
if (readyRef.current) {
|
11472
|
-
effect();
|
11637
|
+
return effect();
|
11473
11638
|
} else {
|
11474
11639
|
readyRef.current = true;
|
11475
11640
|
}
|
@@ -11511,7 +11676,8 @@ function useTableFontSizeListener(table) {
|
|
11511
11676
|
table.setColumnSizing(sizes => {
|
11512
11677
|
return Object.fromEntries(Object.entries(sizes).map(([columnName, prevColumnSize]) => {
|
11513
11678
|
var _column$columnDef$min;
|
11514
|
-
|
11679
|
+
// table.getColumn(columName) throw error in strict dev mode. Related thread: https://github.com/TanStack/table/discussions/5505
|
11680
|
+
const column = table.getAllColumns().find(x => x.id === columnName);
|
11515
11681
|
if (isInternalColumn(columnName)) {
|
11516
11682
|
var _column$getSize;
|
11517
11683
|
return [columnName, (_column$getSize = column === null || column === void 0 ? void 0 : column.getSize()) !== null && _column$getSize !== void 0 ? _column$getSize : prevColumnSize];
|
@@ -11590,7 +11756,7 @@ function useTableSearchListener(table, onChangeSearch) {
|
|
11590
11756
|
onChangeSearch(query);
|
11591
11757
|
}
|
11592
11758
|
}
|
11593
|
-
}, [meta.server.
|
11759
|
+
}, [meta.server.loading, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), onChangeSearch]);
|
11594
11760
|
}
|
11595
11761
|
|
11596
11762
|
function useTableSettingsListener(table, onChangeSettings) {
|
@@ -11726,13 +11892,13 @@ function useTableManager(props, meta, internalColumns) {
|
|
11726
11892
|
const rowClick = useTableRowClick(options.enableRowClick, props.onRowClick);
|
11727
11893
|
const rowDrag = useTableRowDrag(options.enableRowDrag && !(meta !== null && meta !== void 0 && (_meta$editing = meta.editing) !== null && _meta$editing !== void 0 && _meta$editing.isEditing), props.onRowDrag);
|
11728
11894
|
const rowDrop = useTableRowDrop(options.enableRowDrop, props.onRowDrop);
|
11729
|
-
const rowExpansion = useTableRowExpansion(options.enableRowExpansion, props.rowExpansionRenderer);
|
11895
|
+
const rowExpansion = useTableRowExpansion(options.enableRowExpansion, options.enableRowExpansionAll, props.rowExpansionRenderer);
|
11730
11896
|
const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);
|
11731
11897
|
const rowGroups = useTableRowGroups(props.rowActionsForGroup);
|
11732
11898
|
const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);
|
11733
11899
|
const rowSelection = useTableRowSelection(!!options.enableRowSelection);
|
11734
11900
|
const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);
|
11735
|
-
const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);
|
11901
|
+
const server = useTableServerLoading(length, data, props.loadPage, props.loadAll, props.pageSize);
|
11736
11902
|
// TODO: memoise
|
11737
11903
|
// convert jsx column components into valid table columns
|
11738
11904
|
const {
|
@@ -11768,7 +11934,7 @@ function useTableManager(props, meta, internalColumns) {
|
|
11768
11934
|
rowDrag,
|
11769
11935
|
rowDrop: rowDrop,
|
11770
11936
|
rowExpansion: rowExpansion,
|
11771
|
-
|
11937
|
+
rowIdentityAccessor: props.rowIdentityAccessor,
|
11772
11938
|
rowGoto,
|
11773
11939
|
rowGroups: rowGroups,
|
11774
11940
|
rowHeight,
|
@@ -12105,6 +12271,8 @@ const Skeleton = /*#__PURE__*/React__default.forwardRef(function Skeleton(props,
|
|
12105
12271
|
});
|
12106
12272
|
|
12107
12273
|
const RowContext = /*#__PURE__*/React__default.createContext({
|
12274
|
+
hideInternalColumns: false,
|
12275
|
+
hideRowActions: false,
|
12108
12276
|
isHovered: false,
|
12109
12277
|
rowIndex: -1
|
12110
12278
|
});
|
@@ -12114,6 +12282,8 @@ function Row(props) {
|
|
12114
12282
|
const {
|
12115
12283
|
renderer: RowRenderer,
|
12116
12284
|
cellRenderer: CellRenderer,
|
12285
|
+
hideInternalColumns = false,
|
12286
|
+
hideRowActions = false,
|
12117
12287
|
...displayRowProps
|
12118
12288
|
} = props;
|
12119
12289
|
const tableMeta = props.table.options.meta;
|
@@ -12121,8 +12291,10 @@ function Row(props) {
|
|
12121
12291
|
// context - it must be here for cells to read it, since they render alongside the row inside DisplayRow
|
12122
12292
|
const contextValue = React__default.useMemo(() => ({
|
12123
12293
|
isHovered,
|
12124
|
-
rowIndex: props.index
|
12125
|
-
|
12294
|
+
rowIndex: props.index,
|
12295
|
+
hideInternalColumns,
|
12296
|
+
hideRowActions
|
12297
|
+
}), [isHovered, props.index, hideInternalColumns, hideRowActions]);
|
12126
12298
|
if (props.row.original === undefined) {
|
12127
12299
|
return /*#__PURE__*/React__default.createElement(SkeletonRow, Object.assign({}, props));
|
12128
12300
|
}
|
@@ -12133,11 +12305,35 @@ function Row(props) {
|
|
12133
12305
|
})));
|
12134
12306
|
}
|
12135
12307
|
|
12136
|
-
|
12137
|
-
|
12308
|
+
// scroll padding end is designed to always show half of the next row
|
12309
|
+
function getScrollPaddingEndOffset(table) {
|
12310
|
+
const tableMeta = table.options.meta;
|
12311
|
+
let offset = 2;
|
12312
|
+
if (tableMeta.footer.isEnabled) {
|
12313
|
+
offset += 1;
|
12314
|
+
}
|
12315
|
+
if (table.getHeaderGroups().length > 1) {
|
12316
|
+
offset += table.getHeaderGroups().length - 1;
|
12317
|
+
}
|
12318
|
+
let height = ROW_HEIGHT_ESTIMATES.medium * offset;
|
12319
|
+
const bottomRows = table.getBottomRows();
|
12320
|
+
if (bottomRows.length) {
|
12321
|
+
// 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)
|
12322
|
+
height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;
|
12323
|
+
}
|
12324
|
+
return height;
|
12325
|
+
}
|
12326
|
+
// scroll padding end is designed to always show half of the next row
|
12327
|
+
function getPaddingEndOffset(table, options) {
|
12328
|
+
var _table$getBottomRows, _options$virtualiserP;
|
12329
|
+
const bottomRows = (_table$getBottomRows = table.getBottomRows()) !== null && _table$getBottomRows !== void 0 ? _table$getBottomRows : [];
|
12330
|
+
return ROW_HEIGHT_ESTIMATES.medium * ((_options$virtualiserP = options === null || options === void 0 ? void 0 : options.virtualiserPaddingEndOffset) !== null && _options$virtualiserP !== void 0 ? _options$virtualiserP : 1) * bottomRows.length;
|
12331
|
+
}
|
12332
|
+
function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, options) {
|
12333
|
+
var _table$getState$group, _table$getCenterRows, _virtualItems$padding, _virtualItems$padding2, _virtualItems$padding3, _ref, _virtualItems;
|
12138
12334
|
const tableMeta = table.options.meta;
|
12139
|
-
const rows = table.getRowModel().rows;
|
12140
12335
|
const isTableRowGrouped = !!((_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length);
|
12336
|
+
const rows = (_table$getCenterRows = table.getCenterRows()) !== null && _table$getCenterRows !== void 0 ? _table$getCenterRows : [];
|
12141
12337
|
// expanded rows
|
12142
12338
|
const {
|
12143
12339
|
createRowMeasurer,
|
@@ -12147,9 +12343,6 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
|
|
12147
12343
|
const rangeExtractor = useRowGroupVirtualisation(table);
|
12148
12344
|
// account for thead and tfoot in the scroll area - both are always medium row height
|
12149
12345
|
const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;
|
12150
|
-
// column groups offset the bottom padding :shrug:, multiplying by 1.5 ensures the bottom padding remains
|
12151
|
-
// consistent when there are groups and when there aren't. 1.5 is relatively arbitrary, but it gives alignment
|
12152
|
-
const scrollPaddingEnd = ROW_HEIGHT_ESTIMATES.medium * (table.getHeaderGroups().length > 1 ? 1.5 : 1);
|
12153
12346
|
const virtualiser = reactVirtual.useVirtualizer({
|
12154
12347
|
count: rows.length,
|
12155
12348
|
estimateSize,
|
@@ -12158,7 +12351,8 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
|
|
12158
12351
|
rangeExtractor,
|
12159
12352
|
// correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list
|
12160
12353
|
scrollPaddingStart,
|
12161
|
-
scrollPaddingEnd:
|
12354
|
+
scrollPaddingEnd: getScrollPaddingEndOffset(table),
|
12355
|
+
paddingEnd: getPaddingEndOffset(table, options)
|
12162
12356
|
});
|
12163
12357
|
const totalSize = virtualiser.getTotalSize();
|
12164
12358
|
const virtualItems = virtualiser.getVirtualItems();
|
@@ -12198,12 +12392,16 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
|
|
12198
12392
|
// rendered output
|
12199
12393
|
let style = {};
|
12200
12394
|
let content = null;
|
12201
|
-
|
12395
|
+
// bottom rows aren't virtualised (they're sticky) but we need to set the height
|
12396
|
+
if (rows.length || table.getBottomRows().length) {
|
12202
12397
|
style = {
|
12203
12398
|
height: totalSize,
|
12204
12399
|
paddingBottom,
|
12205
12400
|
paddingTop
|
12206
12401
|
};
|
12402
|
+
}
|
12403
|
+
// only render non sticky rows
|
12404
|
+
if (rows.length) {
|
12207
12405
|
content = virtualItems.map(virtualRow => {
|
12208
12406
|
// there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here
|
12209
12407
|
if (!virtualRow) {
|
@@ -12315,12 +12513,14 @@ function Actions$1(props) {
|
|
12315
12513
|
actionsLength,
|
12316
12514
|
data,
|
12317
12515
|
isActiveRow,
|
12318
|
-
rowId
|
12516
|
+
rowId,
|
12517
|
+
table
|
12319
12518
|
} = props;
|
12320
12519
|
const {
|
12321
12520
|
texts
|
12322
12521
|
} = useLocalization();
|
12323
|
-
|
12522
|
+
// we don't want to document passing table, so it isn't on the type
|
12523
|
+
const visibleActions = actions.map(action => action(data, rowId, table)).filter(action => !!action);
|
12324
12524
|
const actionsOnRow = visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);
|
12325
12525
|
const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);
|
12326
12526
|
const className = cn('flex justify-end text-right bg-[inherit] shadow-[-6px_0px_6px_var(--table-row-actions-shadow)] print:hidden');
|
@@ -12359,6 +12559,7 @@ const Cell = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
|
|
12359
12559
|
table
|
12360
12560
|
} = context;
|
12361
12561
|
const {
|
12562
|
+
hideRowActions,
|
12362
12563
|
isHovered,
|
12363
12564
|
rowIndex
|
12364
12565
|
} = React__default.useContext(RowContext);
|
@@ -12368,15 +12569,15 @@ const Cell = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
|
|
12368
12569
|
const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
|
12369
12570
|
const isResizingColumn = !!table.getState().columnSizingInfo.isResizingColumn;
|
12370
12571
|
const isHoverStatePaused = tableMeta.rowActive.isHoverStatePaused;
|
12371
|
-
|
12372
|
-
|
12373
|
-
if (actions !== null && actions !== void 0 && actions.length && (isActiveRow || isHovered && !isHoverStatePaused && !isResizingColumn)) {
|
12572
|
+
const isRowGrouped = row.getIsGrouped();
|
12573
|
+
if (!hideRowActions && !isRowGrouped && actions !== null && actions !== void 0 && actions.length && (isActiveRow || isHovered && !isHoverStatePaused && !isResizingColumn)) {
|
12374
12574
|
return /*#__PURE__*/React__default.createElement(Actions$1, {
|
12375
12575
|
actions: actions,
|
12376
12576
|
actionsLength: actionsLength,
|
12377
12577
|
data: row.original,
|
12378
12578
|
isActiveRow: isActiveRow,
|
12379
|
-
rowId: row.id
|
12579
|
+
rowId: row.id,
|
12580
|
+
table: table
|
12380
12581
|
});
|
12381
12582
|
}
|
12382
12583
|
return null;
|
@@ -12400,6 +12601,12 @@ function Cell$1() {
|
|
12400
12601
|
const {
|
12401
12602
|
texts
|
12402
12603
|
} = useLocalization();
|
12604
|
+
const {
|
12605
|
+
hideInternalColumns
|
12606
|
+
} = React__default.useContext(RowContext);
|
12607
|
+
if (hideInternalColumns) {
|
12608
|
+
return null;
|
12609
|
+
}
|
12403
12610
|
return /*#__PURE__*/React__default.createElement(Icon, {
|
12404
12611
|
"aria-label": texts.table.columns.drag.tooltip,
|
12405
12612
|
name: "drag",
|
@@ -12427,6 +12634,10 @@ function Header$3(context) {
|
|
12427
12634
|
const {
|
12428
12635
|
table
|
12429
12636
|
} = context;
|
12637
|
+
const tableMeta = table.options.meta;
|
12638
|
+
if (!tableMeta.rowExpansion.canExpandAll) {
|
12639
|
+
return null;
|
12640
|
+
}
|
12430
12641
|
const isSomeRowsExpanded = table.getIsSomeRowsExpanded();
|
12431
12642
|
const handleClick = event => {
|
12432
12643
|
event.stopPropagation();
|
@@ -12448,7 +12659,13 @@ function Cell$2(context) {
|
|
12448
12659
|
const {
|
12449
12660
|
texts
|
12450
12661
|
} = useLocalization();
|
12662
|
+
const {
|
12663
|
+
hideInternalColumns
|
12664
|
+
} = React__default.useContext(RowContext);
|
12451
12665
|
const tableMeta = context.table.options.meta;
|
12666
|
+
if (hideInternalColumns) {
|
12667
|
+
return null;
|
12668
|
+
}
|
12452
12669
|
const hasExpandedRow = (_tableMeta$rowExpansi = (_tableMeta$rowExpansi2 = tableMeta.rowExpansion).rowExpansionRenderer) === null || _tableMeta$rowExpansi === void 0 ? void 0 : _tableMeta$rowExpansi.call(_tableMeta$rowExpansi2, context.row.original);
|
12453
12670
|
if (hasExpandedRow) {
|
12454
12671
|
const isActiveRow = tableMeta.rowActive.rowActiveIndex === context.row.index;
|
@@ -12519,7 +12736,7 @@ function Header$4(context) {
|
|
12519
12736
|
className: "hover:border-blue !-mt-px",
|
12520
12737
|
checked: isAllRowsSelected,
|
12521
12738
|
indeterminate: isSomeRowsSelected && !isAllRowsSelected,
|
12522
|
-
loading: tableMeta.server.
|
12739
|
+
loading: tableMeta.server.loading,
|
12523
12740
|
onChange: handleChange
|
12524
12741
|
}));
|
12525
12742
|
}
|
@@ -12538,10 +12755,11 @@ function Cell$3(context) {
|
|
12538
12755
|
table
|
12539
12756
|
} = context;
|
12540
12757
|
const {
|
12758
|
+
hideInternalColumns,
|
12541
12759
|
rowIndex
|
12542
12760
|
} = React__default.useContext(RowContext);
|
12543
12761
|
const tableMeta = table.options.meta;
|
12544
|
-
if (table.options.enableGrouping && (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length && !row.getIsGrouped()) {
|
12762
|
+
if (hideInternalColumns || table.options.enableGrouping && (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length && !row.getIsGrouped()) {
|
12545
12763
|
return null;
|
12546
12764
|
}
|
12547
12765
|
const isSelected = row.getIsGrouped() ? row.getIsAllSubRowsSelected() : row.getIsSelected();
|
@@ -12626,13 +12844,13 @@ const INTERNAL_RENDERERS = {
|
|
12626
12844
|
rowExpansion: renderer$2,
|
12627
12845
|
rowSelection: renderer$3
|
12628
12846
|
};
|
12629
|
-
function useTable(props, externalRef, renderers, meta) {
|
12847
|
+
function useTable(props, externalRef, renderers, meta, options) {
|
12630
12848
|
// create a ref and merge with the consumer's ref
|
12631
12849
|
const ref = useMergedRef(externalRef);
|
12632
12850
|
// configure the table
|
12633
12851
|
const manager = useTableManager(props, meta, INTERNAL_RENDERERS);
|
12634
12852
|
// configure the virtualised renderer
|
12635
|
-
const renderer = useTableRenderer(renderers, manager.instance, ref, props.defaultRowActiveIndex);
|
12853
|
+
const renderer = useTableRenderer(renderers, manager.instance, ref, props.defaultRowActiveIndex, options);
|
12636
12854
|
// configure dynamic styling
|
12637
12855
|
const {
|
12638
12856
|
style,
|
@@ -12733,7 +12951,10 @@ function GroupedCell(props) {
|
|
12733
12951
|
index,
|
12734
12952
|
isHighlighted
|
12735
12953
|
} = props;
|
12736
|
-
const
|
12954
|
+
const {
|
12955
|
+
table
|
12956
|
+
} = cell.getContext();
|
12957
|
+
const tableMeta = table.options.meta;
|
12737
12958
|
const columnMeta = cell.column.columnDef.meta;
|
12738
12959
|
const attributes = getCellAttributes(cell, index, isHighlighted);
|
12739
12960
|
const {
|
@@ -12742,7 +12963,9 @@ function GroupedCell(props) {
|
|
12742
12963
|
} = React__default.useContext(RowContext);
|
12743
12964
|
const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
|
12744
12965
|
const canShowActions = isActiveRow || isHovered && !tableMeta.rowActive.isHoverStatePaused;
|
12745
|
-
|
12966
|
+
// Set colSpan based on the count of visible cells, including '__actions' and non-internal columns, so that
|
12967
|
+
// rowGroupActions aligns with rowActions.
|
12968
|
+
const colSpan = cell.row.getVisibleCells().filter(c => c.column.id === '__actions' || !isInternalColumn(c.column.id)).length - 1;
|
12746
12969
|
const content = (_ref = (_columnMeta$renderer = (_columnMeta$renderer2 = columnMeta.renderer) === null || _columnMeta$renderer2 === void 0 ? void 0 : _columnMeta$renderer2.call(columnMeta, cell.getValue(), cell.row.original)) !== null && _columnMeta$renderer !== void 0 ? _columnMeta$renderer : cell.getValue()) !== null && _ref !== void 0 ? _ref : null;
|
12747
12970
|
const subRows = cell.getContext().row.subRows.map(row => row.original);
|
12748
12971
|
return /*#__PURE__*/React__default.createElement(MemoedGroupedCell, Object.assign({}, attributes, {
|
@@ -12751,7 +12974,8 @@ function GroupedCell(props) {
|
|
12751
12974
|
colSpan: colSpan,
|
12752
12975
|
rowActions: tableMeta.rowGroups.rowActionsForGroup,
|
12753
12976
|
rowId: cell.row.id,
|
12754
|
-
subRows: subRows
|
12977
|
+
subRows: subRows,
|
12978
|
+
table: table
|
12755
12979
|
}), content);
|
12756
12980
|
}
|
12757
12981
|
const MemoedGroupedCell = /*#__PURE__*/React__default.memo(function MemoedGroupedCell(props) {
|
@@ -12763,22 +12987,29 @@ const MemoedGroupedCell = /*#__PURE__*/React__default.memo(function MemoedGroupe
|
|
12763
12987
|
rowActions,
|
12764
12988
|
rowId,
|
12765
12989
|
subRows,
|
12990
|
+
table,
|
12766
12991
|
...attributes
|
12767
12992
|
} = props;
|
12768
|
-
return
|
12769
|
-
|
12770
|
-
|
12771
|
-
|
12772
|
-
|
12773
|
-
|
12774
|
-
|
12775
|
-
|
12776
|
-
|
12777
|
-
|
12778
|
-
|
12779
|
-
|
12780
|
-
|
12781
|
-
|
12993
|
+
return (
|
12994
|
+
/*#__PURE__*/
|
12995
|
+
// pr-1 is needed to align group row actions with row actions in sibling rows, if present
|
12996
|
+
React__default.createElement("td", Object.assign({}, attributes, {
|
12997
|
+
className: "!pr-1",
|
12998
|
+
ref: cellRef,
|
12999
|
+
style: {
|
13000
|
+
gridColumn: `span ${colSpan} / span ${colSpan}`
|
13001
|
+
}
|
13002
|
+
}), /*#__PURE__*/React__default.createElement("span", {
|
13003
|
+
className: "grow"
|
13004
|
+
}, children), rowActions !== null && rowActions !== void 0 && rowActions.length && canShowActions ? (/*#__PURE__*/React__default.createElement(Actions$1, {
|
13005
|
+
actions: rowActions,
|
13006
|
+
actionsLength: 4,
|
13007
|
+
data: subRows,
|
13008
|
+
isActiveRow: true,
|
13009
|
+
rowId: rowId,
|
13010
|
+
table: table
|
13011
|
+
})) : null)
|
13012
|
+
);
|
12782
13013
|
});
|
12783
13014
|
|
12784
13015
|
function Cell$4(props) {
|
@@ -12839,7 +13070,7 @@ const DisplayRow = /*#__PURE__*/React__default.memo(function DisplayRow(props) {
|
|
12839
13070
|
if (tableMeta.rowActive.isEnabled) {
|
12840
13071
|
attributes['data-row-active'] = tableMeta.rowActive.rowActiveIndex === index ? true : undefined;
|
12841
13072
|
// we use capture because it let's us picks up clicks on components inside the row, e.g. checkboxes
|
12842
|
-
attributes.
|
13073
|
+
attributes.onPointerDown = handleClickCapture;
|
12843
13074
|
}
|
12844
13075
|
// row click
|
12845
13076
|
if (tableMeta.rowClick.isEnabled(row.original)) {
|
@@ -12917,14 +13148,17 @@ const DisplayRow = /*#__PURE__*/React__default.memo(function DisplayRow(props) {
|
|
12917
13148
|
const expansionRef = React__default.useRef(null);
|
12918
13149
|
const isExpanded = !!attributes['data-row-expanded'];
|
12919
13150
|
useSetVirtualisedRowHeight(measureRow, ref.current, expansionRef.current, isExpanded);
|
12920
|
-
const className = cn('group/row', {
|
13151
|
+
const className = cn('group/row', otherAttributes.className, {
|
12921
13152
|
'hover:cursor-grab': tableMeta.rowDrag.isEnabled && typeof attributes.onClick !== 'function',
|
12922
13153
|
'hover:cursor-pointer': typeof attributes.onClick === 'function'
|
12923
13154
|
});
|
13155
|
+
const isGrouped = row.getIsGrouped();
|
12924
13156
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("tr", Object.assign({}, attributes, {
|
12925
13157
|
className: className,
|
12926
13158
|
ref: ref
|
12927
|
-
}), children, row.getVisibleCells()
|
13159
|
+
}), children, row.getVisibleCells()
|
13160
|
+
// Filter out the row actions cell from rendering in Grouped Row
|
13161
|
+
.filter(cell => !(isGrouped && cell.column.id === '__actions')).map((cell, cellIndex) => (/*#__PURE__*/React__default.createElement(Cell$4, {
|
12928
13162
|
key: cell.id,
|
12929
13163
|
cell: cell,
|
12930
13164
|
index: cellIndex,
|
@@ -13710,8 +13944,13 @@ function Summary(props) {
|
|
13710
13944
|
}
|
13711
13945
|
|
13712
13946
|
function Foot(props) {
|
13713
|
-
const
|
13714
|
-
|
13947
|
+
const {
|
13948
|
+
children,
|
13949
|
+
table,
|
13950
|
+
...attributes
|
13951
|
+
} = props;
|
13952
|
+
const nonGroupedHeaders = table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());
|
13953
|
+
return /*#__PURE__*/React__default.createElement("tfoot", Object.assign({}, attributes), children, /*#__PURE__*/React__default.createElement("tr", null, nonGroupedHeaders.map((header, index) => (/*#__PURE__*/React__default.createElement(Footer$3, {
|
13715
13954
|
key: header.id,
|
13716
13955
|
header: header,
|
13717
13956
|
index: index
|
@@ -13759,16 +13998,29 @@ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(prop
|
|
13759
13998
|
});
|
13760
13999
|
|
13761
14000
|
function EmptyStateBody(props) {
|
14001
|
+
var _ref$current, _ref$current$parentNo;
|
13762
14002
|
const {
|
13763
14003
|
emptyState: Placeholder,
|
14004
|
+
isReady,
|
13764
14005
|
reason,
|
13765
14006
|
...attributes
|
13766
14007
|
} = props;
|
14008
|
+
const ref = React__default.useRef(null);
|
14009
|
+
if (!isReady) {
|
14010
|
+
return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
|
14011
|
+
className: "!auto-rows-fr"
|
14012
|
+
}));
|
14013
|
+
}
|
13767
14014
|
return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
|
13768
|
-
|
14015
|
+
ref: ref,
|
14016
|
+
className: "!auto-rows-fr",
|
14017
|
+
"data-taco": "empty-state"
|
13769
14018
|
}), /*#__PURE__*/React__default.createElement("tr", {
|
13770
|
-
className: "!auto-rows-fr"
|
14019
|
+
className: "!auto-rows-fr "
|
13771
14020
|
}, /*#__PURE__*/React__default.createElement("td", {
|
14021
|
+
style: {
|
14022
|
+
maxWidth: ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : (_ref$current$parentNo = _ref$current.parentNode) === null || _ref$current$parentNo === void 0 ? void 0 : _ref$current$parentNo.clientWidth
|
14023
|
+
},
|
13772
14024
|
className: "col-span-full !border-0 !p-0 hover:!bg-white"
|
13773
14025
|
}, Placeholder ? /*#__PURE__*/React__default.createElement(Placeholder, {
|
13774
14026
|
reason: reason
|
@@ -14043,7 +14295,7 @@ function Search$1(props) {
|
|
14043
14295
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SearchInput2, {
|
14044
14296
|
findCurrent: tableMeta.search.currentHighlightColumnIndex !== undefined ? tableMeta.search.currentHighlightColumnIndex + 1 : null,
|
14045
14297
|
findTotal: (_tableMeta$search$hig = (_tableMeta$search$hig2 = tableMeta.search.highlightedColumnIndexes) === null || _tableMeta$search$hig2 === void 0 ? void 0 : _tableMeta$search$hig2.length) !== null && _tableMeta$search$hig !== void 0 ? _tableMeta$search$hig : null,
|
14046
|
-
loading: tableMeta.server.
|
14298
|
+
loading: tableMeta.server.loading,
|
14047
14299
|
name: "table-search",
|
14048
14300
|
onClickFindPrevious: handlePreviousResult,
|
14049
14301
|
onClickFindNext: handleNextResult,
|
@@ -14401,6 +14653,7 @@ const getOptionsFromCollection = (collection, selector) => collection.querySelec
|
|
14401
14653
|
const Root = /*#__PURE__*/React__default.forwardRef(function CollectionRoot(props, ref) {
|
14402
14654
|
const {
|
14403
14655
|
querySelector,
|
14656
|
+
resetOnChange,
|
14404
14657
|
tabIndex = 0,
|
14405
14658
|
...otherProps
|
14406
14659
|
} = props;
|
@@ -14431,14 +14684,31 @@ const Root = /*#__PURE__*/React__default.forwardRef(function CollectionRoot(prop
|
|
14431
14684
|
internalRef.current.setActiveIndexByElement = setActiveIndexByElement;
|
14432
14685
|
}
|
14433
14686
|
}, [internalRef.current]);
|
14687
|
+
React__default.useEffect(() => {
|
14688
|
+
if (internalRef.current) {
|
14689
|
+
const selected = internalRef.current.querySelectorAll(`[aria-current="true"]`);
|
14690
|
+
const options = getOptionsFromCollection(internalRef.current, querySelector);
|
14691
|
+
if (options.length && selected.length === 1) {
|
14692
|
+
const firstSelected = internalRef.current.querySelector(`[aria-selected]`);
|
14693
|
+
if (firstSelected) {
|
14694
|
+
const selectedIndex = Array.from(options).indexOf(firstSelected);
|
14695
|
+
if (selectedIndex > -1) {
|
14696
|
+
setActiveOption(selectedIndex, internalRef.current, firstSelected);
|
14697
|
+
}
|
14698
|
+
}
|
14699
|
+
}
|
14700
|
+
}
|
14701
|
+
}, [resetOnChange]);
|
14434
14702
|
React__default.useEffect(() => {
|
14435
14703
|
if (internalRef.current) {
|
14436
14704
|
const options = getOptionsFromCollection(internalRef.current, querySelector);
|
14437
14705
|
if (options.length) {
|
14438
14706
|
let selected = internalRef.current.querySelectorAll(`[aria-current="true"]`);
|
14707
|
+
// if nothing is current (keyboard visible), look for selected items
|
14439
14708
|
if (selected.length === 0) {
|
14440
14709
|
selected = internalRef.current.querySelectorAll(`[aria-selected]`);
|
14441
14710
|
}
|
14711
|
+
// if one item is selected, make sure it's current
|
14442
14712
|
if (selected.length === 1) {
|
14443
14713
|
if (options) {
|
14444
14714
|
const firstSelected = selected.item(0);
|
@@ -14584,6 +14854,7 @@ const Root$1 = /*#__PURE__*/React__default.forwardRef(function Listbox2(props, r
|
|
14584
14854
|
id: id,
|
14585
14855
|
querySelector: customSelector ? `${DEFAULT_SELECTOR}, ${customSelector}` : DEFAULT_SELECTOR,
|
14586
14856
|
ref: ref,
|
14857
|
+
resetOnChange: value,
|
14587
14858
|
role: "listbox"
|
14588
14859
|
}), children)));
|
14589
14860
|
});
|
@@ -14642,10 +14913,6 @@ const Option = /*#__PURE__*/React__default.forwardRef(function Listbox2Option(pr
|
|
14642
14913
|
if (disabled || listboxDisabled || listboxReadOnly) {
|
14643
14914
|
event.stopPropagation();
|
14644
14915
|
return;
|
14645
|
-
}
|
14646
|
-
// UX requirement: if tab key is pressed and the current option is selected then keydown event is ignored
|
14647
|
-
else if (event.key === 'Tab' && selected) {
|
14648
|
-
return;
|
14649
14916
|
} else if (isAriaSelectionKey(event)) {
|
14650
14917
|
setValue(value);
|
14651
14918
|
}
|
@@ -14656,7 +14923,6 @@ const Option = /*#__PURE__*/React__default.forwardRef(function Listbox2Option(pr
|
|
14656
14923
|
return /*#__PURE__*/React__default.createElement("div", Object.assign({}, otherProps, {
|
14657
14924
|
"aria-disabled": listboxDisabled || disabled ? 'true' : undefined,
|
14658
14925
|
"aria-selected": selected ? 'true' : undefined,
|
14659
|
-
key: `${value}_${String(selected)}`,
|
14660
14926
|
id: id,
|
14661
14927
|
onClick: handleClick,
|
14662
14928
|
onKeyDown: handleKeyDown,
|
@@ -14721,14 +14987,16 @@ const Tag$1 = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
14721
14987
|
ref: ref,
|
14722
14988
|
"data-taco": "tag"
|
14723
14989
|
}), /*#__PURE__*/React__default.createElement("span", {
|
14724
|
-
className: "truncate px-2",
|
14990
|
+
className: "flex items-center truncate px-2",
|
14725
14991
|
ref: textRef
|
14726
14992
|
}, icon ? typeof icon === 'string' ? (/*#__PURE__*/React__default.createElement(Icon, {
|
14727
14993
|
name: icon,
|
14728
|
-
className: "-ml-1
|
14994
|
+
className: "-ml-1 mr-1 !h-5 !w-5"
|
14729
14995
|
})) : (/*#__PURE__*/React__default.cloneElement(icon, {
|
14730
|
-
className: 'mr-1 -ml-1
|
14731
|
-
})) : null,
|
14996
|
+
className: 'mr-1 -ml-1 !h-5 !w-5'
|
14997
|
+
})) : null, /*#__PURE__*/React__default.createElement("span", {
|
14998
|
+
className: "truncate"
|
14999
|
+
}, children)), onDelete ? (/*#__PURE__*/React__default.createElement(Icon, {
|
14732
15000
|
name: "close",
|
14733
15001
|
onClick: onDelete,
|
14734
15002
|
className: "-ml-1.5 !h-6 !w-5 flex-shrink-0 cursor-pointer rounded-r p-0.5 hover:bg-black/5"
|
@@ -15005,12 +15273,13 @@ const Option$1 = /*#__PURE__*/React__default.forwardRef(function Select2Option(p
|
|
15005
15273
|
}), hasValue ? (/*#__PURE__*/React__default.createElement(Icon, {
|
15006
15274
|
name: "tick",
|
15007
15275
|
className: "pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible"
|
15008
|
-
})) : null, isTag ? (/*#__PURE__*/React__default.createElement(Tag$1, {
|
15276
|
+
})) : null, typeof children !== 'string' ? (/*#__PURE__*/React__default.createElement("span", null, children)) : isTag ? (/*#__PURE__*/React__default.createElement(Tag$1, {
|
15009
15277
|
className: "pointer-events-none my-1",
|
15010
15278
|
color: color,
|
15011
15279
|
icon: prefix
|
15012
15280
|
}, children)) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, prefix ? typeof prefix === 'string' ? /*#__PURE__*/React__default.createElement(Icon, {
|
15013
|
-
name: prefix
|
15281
|
+
name: prefix,
|
15282
|
+
className: "!h-5 !w-5"
|
15014
15283
|
}) : prefix : null, /*#__PURE__*/React__default.createElement("span", {
|
15015
15284
|
className: "flex w-full justify-between"
|
15016
15285
|
}, /*#__PURE__*/React__default.createElement("span", {
|
@@ -15019,9 +15288,10 @@ const Option$1 = /*#__PURE__*/React__default.forwardRef(function Select2Option(p
|
|
15019
15288
|
className: "text-grey-700 -mt-1.5 mb-1.5 text-xs"
|
15020
15289
|
}, description) : null), /*#__PURE__*/React__default.createElement("span", {
|
15021
15290
|
className: "flex flex-col self-center"
|
15022
|
-
}, postfix ? typeof postfix === 'string' ? /*#__PURE__*/React__default.createElement(Icon, {
|
15023
|
-
name: postfix
|
15024
|
-
|
15291
|
+
}, postfix ? typeof postfix === 'string' ? (/*#__PURE__*/React__default.createElement(Icon, {
|
15292
|
+
name: postfix,
|
15293
|
+
className: "!h-5 !w-5"
|
15294
|
+
})) : postfix : null)))), popover ? (/*#__PURE__*/React__default.createElement(IconButton, {
|
15025
15295
|
icon: "ellipsis-vertical",
|
15026
15296
|
appearance: "discrete",
|
15027
15297
|
className: cn('group-aria-current:visible invisible -mr-1 ml-auto !h-5 min-h-[theme(spacing.6)] !w-5 min-w-[theme(spacing.6)] hover:!bg-black/[.08] focus:!shadow-none group-hover:visible', {
|
@@ -15099,7 +15369,9 @@ const Button$3 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
|
|
15099
15369
|
var _props$className;
|
15100
15370
|
const {
|
15101
15371
|
children,
|
15372
|
+
onBlur,
|
15102
15373
|
onClick,
|
15374
|
+
onFocus,
|
15103
15375
|
tabIndex = 0,
|
15104
15376
|
...otherProps
|
15105
15377
|
} = props;
|
@@ -15130,6 +15402,18 @@ const Button$3 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
|
|
15130
15402
|
onClick(event);
|
15131
15403
|
}
|
15132
15404
|
};
|
15405
|
+
let handleBlur;
|
15406
|
+
if (typeof onBlur === 'function') {
|
15407
|
+
// we might be focusing on an input or something inside the dropdown that was triggered by the select
|
15408
|
+
// so see if the element gaining focus is inside a portal and look up its controller
|
15409
|
+
// if we don't do this, things like validate on blur occur while simply opening the select
|
15410
|
+
handleBlur = event => {
|
15411
|
+
if (isElementInsideOrTriggeredFromContainer(event.relatedTarget, event.currentTarget)) {
|
15412
|
+
return;
|
15413
|
+
}
|
15414
|
+
onBlur(event);
|
15415
|
+
};
|
15416
|
+
}
|
15133
15417
|
// select the value text if the select is readonly
|
15134
15418
|
const handleFocus = event => {
|
15135
15419
|
if (readOnly) {
|
@@ -15139,6 +15423,9 @@ const Button$3 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
|
|
15139
15423
|
(_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : (_window$getSelection$ = _window$getSelection.selectAllChildren) === null || _window$getSelection$ === void 0 ? void 0 : _window$getSelection$.call(_window$getSelection, value);
|
15140
15424
|
}
|
15141
15425
|
}
|
15426
|
+
if (typeof onFocus === 'function') {
|
15427
|
+
onFocus(event);
|
15428
|
+
}
|
15142
15429
|
};
|
15143
15430
|
return /*#__PURE__*/React__default.createElement("button", Object.assign({}, otherProps, {
|
15144
15431
|
"aria-invalid": invalid ? true : undefined,
|
@@ -15146,6 +15433,7 @@ const Button$3 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
|
|
15146
15433
|
className: className,
|
15147
15434
|
disabled: disabled,
|
15148
15435
|
onClick: handleClick,
|
15436
|
+
onBlur: handleBlur,
|
15149
15437
|
onFocus: handleFocus,
|
15150
15438
|
ref: ref,
|
15151
15439
|
role: "combobox",
|
@@ -15169,7 +15457,7 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
|
|
15169
15457
|
readOnly,
|
15170
15458
|
tags
|
15171
15459
|
} = useSelect2Context();
|
15172
|
-
const contentClassName = cn('truncate items-center gap-1');
|
15460
|
+
const contentClassName = cn('truncate flex items-center gap-1');
|
15173
15461
|
const currentValue = children.find(matchesValue(value));
|
15174
15462
|
let output;
|
15175
15463
|
if (placeholder && currentValue === undefined) {
|
@@ -15179,13 +15467,13 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
|
|
15179
15467
|
}, placeholder);
|
15180
15468
|
} else if (currentValue) {
|
15181
15469
|
if (tags && emptyValue !== value) {
|
15182
|
-
output = /*#__PURE__*/React__default.createElement(Tag$1, {
|
15470
|
+
if (typeof currentValue.props.children === 'string') output = /*#__PURE__*/React__default.createElement(Tag$1, {
|
15183
15471
|
className: "truncate",
|
15184
15472
|
color: currentValue.props.color,
|
15185
15473
|
disabled: disabled,
|
15186
15474
|
icon: currentValue.props.prefix,
|
15187
15475
|
readOnly: readOnly
|
15188
|
-
}, currentValue.props.children);
|
15476
|
+
}, currentValue.props.children);else output = currentValue.props.children;
|
15189
15477
|
} else {
|
15190
15478
|
output = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, currentValue.props.prefix ? typeof currentValue.props.prefix === 'string' ? (/*#__PURE__*/React__default.createElement(Icon, {
|
15191
15479
|
name: currentValue.props.prefix,
|
@@ -15236,7 +15524,7 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
|
|
15236
15524
|
}, valuesAsChildren.length === 0 ? (/*#__PURE__*/React__default.createElement(Placeholder, {
|
15237
15525
|
disabled: disabled,
|
15238
15526
|
readOnly: readOnly
|
15239
|
-
}, placeholder)) : valuesAsChildren.map(child => (/*#__PURE__*/React__default.createElement(Tag$1, {
|
15527
|
+
}, placeholder)) : valuesAsChildren.map(child => typeof child.props.children === 'string' ? (/*#__PURE__*/React__default.createElement(Tag$1, {
|
15240
15528
|
key: String(child.props.value),
|
15241
15529
|
className: "truncate",
|
15242
15530
|
color: tags ? child.props.color : undefined,
|
@@ -15250,7 +15538,23 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
|
|
15250
15538
|
}
|
15251
15539
|
},
|
15252
15540
|
readOnly: readOnly
|
15253
|
-
}, child.props.children))
|
15541
|
+
}, child.props.children)) : (/*#__PURE__*/React__default.cloneElement(child.props.children, {
|
15542
|
+
key: String(child.props.value),
|
15543
|
+
className: '!pr-0 !pl-1.5',
|
15544
|
+
children: (/*#__PURE__*/React__default.createElement("span", {
|
15545
|
+
className: "flex items-center"
|
15546
|
+
}, child.props.children.props.children, /*#__PURE__*/React__default.createElement(Icon, {
|
15547
|
+
name: "close",
|
15548
|
+
onClick: event => {
|
15549
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
15550
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
15551
|
+
if (!disabled && !readOnly) {
|
15552
|
+
setValue(child.props.value);
|
15553
|
+
}
|
15554
|
+
},
|
15555
|
+
className: "ml-0.5 !h-5 !w-5 shrink-0 cursor-pointer rounded-r p-0.5 hover:bg-black/5"
|
15556
|
+
})))
|
15557
|
+
})))));
|
15254
15558
|
} else {
|
15255
15559
|
content = /*#__PURE__*/React__default.createElement(MultipleValue, {
|
15256
15560
|
onClick: forwardClick,
|
@@ -15281,6 +15585,18 @@ const MultipleValue = ({
|
|
15281
15585
|
} = useSelect2Context();
|
15282
15586
|
const [contentRef, setContentRef] = React__default.useState(null);
|
15283
15587
|
const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;
|
15588
|
+
// Retrieves the relevant text content from any JSX.Element passed as a select option, handling nested elements, arrays, and direct text
|
15589
|
+
const getTooltipTitle = child => {
|
15590
|
+
const children = child.props.children;
|
15591
|
+
if (typeof children === 'string') return children;
|
15592
|
+
if (typeof children.props.children === 'string') {
|
15593
|
+
return children.props.children;
|
15594
|
+
}
|
15595
|
+
if (Array.isArray(children.props.children)) {
|
15596
|
+
return children.props.children.filter(item => typeof item === 'string');
|
15597
|
+
}
|
15598
|
+
return '';
|
15599
|
+
};
|
15284
15600
|
return /*#__PURE__*/React__default.createElement("div", {
|
15285
15601
|
className: "relative flex w-full items-center gap-1 overflow-hidden",
|
15286
15602
|
onClick: onClick
|
@@ -15291,26 +15607,35 @@ const MultipleValue = ({
|
|
15291
15607
|
disabled: disabled,
|
15292
15608
|
readOnly: readOnly
|
15293
15609
|
}, placeholder)) : valuesAsChildren.map((child, index) => {
|
15294
|
-
const
|
15295
|
-
|
15610
|
+
const classNames = {
|
15611
|
+
truncate: index === boundaryIndex,
|
15612
|
+
hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false
|
15613
|
+
};
|
15614
|
+
let output;
|
15615
|
+
if (typeof child.props.children === 'string') {
|
15616
|
+
output = /*#__PURE__*/React__default.createElement(Tag$1, {
|
15617
|
+
key: String(child.props.value),
|
15618
|
+
className: cn('cursor-pointer', classNames),
|
15619
|
+
color: tags ? child.props.color : undefined,
|
15620
|
+
disabled: disabled,
|
15621
|
+
icon: child.props.prefix,
|
15622
|
+
readOnly: readOnly
|
15623
|
+
}, child.props.children);
|
15624
|
+
} else output = /*#__PURE__*/React__default.cloneElement(child.props.children, {
|
15296
15625
|
className: cn('cursor-pointer', {
|
15297
|
-
|
15298
|
-
|
15299
|
-
|
15300
|
-
|
15301
|
-
disabled: disabled,
|
15302
|
-
icon: child.props.prefix,
|
15303
|
-
readOnly: readOnly
|
15304
|
-
}, child.props.children);
|
15626
|
+
'shrink-0': index !== boundaryIndex
|
15627
|
+
}, classNames),
|
15628
|
+
key: String(child.props.value)
|
15629
|
+
});
|
15305
15630
|
if (index === boundaryIndex) {
|
15306
15631
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
15307
15632
|
key: String(child.props.value),
|
15308
|
-
title: String(child
|
15309
|
-
},
|
15633
|
+
title: String(getTooltipTitle(child))
|
15634
|
+
}, output);
|
15310
15635
|
}
|
15311
|
-
return
|
15636
|
+
return output;
|
15312
15637
|
})), boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (/*#__PURE__*/React__default.createElement(Tooltip, {
|
15313
|
-
title: valuesAsChildren.slice(boundaryIndex + 1).map(child => child ? String(child
|
15638
|
+
title: valuesAsChildren.slice(boundaryIndex + 1).map(child => child ? String(getTooltipTitle(child)) : '').join(', ')
|
15314
15639
|
}, /*#__PURE__*/React__default.createElement(Badge, {
|
15315
15640
|
className: "flex-shrink-0"
|
15316
15641
|
}, "+", valuesAsChildren.length - (boundaryIndex + 1)))) : null);
|
@@ -15375,7 +15700,7 @@ const BubbleSelect = props => {
|
|
15375
15700
|
if (prevValue !== value && setValue) {
|
15376
15701
|
if (Array.isArray(value)) {
|
15377
15702
|
value.forEach(v => {
|
15378
|
-
const option = select.querySelector(`option[value='${v}']`);
|
15703
|
+
const option = select.querySelector(`option[value='${CSS.escape(v)}']`);
|
15379
15704
|
if (option) {
|
15380
15705
|
option.selected = true;
|
15381
15706
|
}
|
@@ -15408,17 +15733,12 @@ const BubbleSelect = props => {
|
|
15408
15733
|
};
|
15409
15734
|
|
15410
15735
|
const Search$2 = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(props, ref) {
|
15411
|
-
const {
|
15412
|
-
onTabKeyPress,
|
15413
|
-
...otherProps
|
15414
|
-
} = props;
|
15415
15736
|
const {
|
15416
15737
|
listboxRef,
|
15417
15738
|
searchQuery,
|
15418
15739
|
setSearchQuery,
|
15419
15740
|
setValidationError,
|
15420
|
-
validationError
|
15421
|
-
setOpen
|
15741
|
+
validationError
|
15422
15742
|
} = useSelect2Context();
|
15423
15743
|
const handleChange = event => {
|
15424
15744
|
if (validationError) {
|
@@ -15431,11 +15751,6 @@ const Search$2 = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(p
|
|
15431
15751
|
if (event.key === ' ') {
|
15432
15752
|
return;
|
15433
15753
|
}
|
15434
|
-
// Select2 should close dropdown and receive focus, when user press Tab while searching (UX requirement to support better keyboard navigation)
|
15435
|
-
if (event.key === 'Tab') {
|
15436
|
-
setOpen(false);
|
15437
|
-
onTabKeyPress();
|
15438
|
-
}
|
15439
15754
|
if (isAriaSelectionKey(event) || event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
15440
15755
|
var _listboxRef$current;
|
15441
15756
|
event.preventDefault();
|
@@ -15450,7 +15765,7 @@ const Search$2 = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(p
|
|
15450
15765
|
}),
|
15451
15766
|
invalid: !!validationError,
|
15452
15767
|
message: validationError === null || validationError === void 0 ? void 0 : validationError.message
|
15453
|
-
}, /*#__PURE__*/React__default.createElement(Input, Object.assign({},
|
15768
|
+
}, /*#__PURE__*/React__default.createElement(Input, Object.assign({}, props, {
|
15454
15769
|
autoFocus: true,
|
15455
15770
|
invalid: !!validationError,
|
15456
15771
|
onChange: handleChange,
|
@@ -15674,7 +15989,6 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
15674
15989
|
// align the listbox min width with the width of the input - it should never be smaller
|
15675
15990
|
const dimensions = useBoundingClientRectListener(internalRef);
|
15676
15991
|
// state
|
15677
|
-
const [tabTriggeredClose, setTabTriggeredClose] = React__default.useState(false);
|
15678
15992
|
const [open, setOpen] = React__default.useState(false);
|
15679
15993
|
const [value, _setValue] = reactUseControllableState.useControllableState({
|
15680
15994
|
// uncontrolled
|
@@ -15751,7 +16065,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
15751
16065
|
var _listboxRef$current;
|
15752
16066
|
if (open) {
|
15753
16067
|
event.preventDefault();
|
15754
|
-
} else if (isElementInsideTable3OrReport(event.currentTarget)) {
|
16068
|
+
} else if (isElementInsideTable3OrReport(event.currentTarget) && isAriaDirectionKey(event)) {
|
15755
16069
|
return;
|
15756
16070
|
} else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {
|
15757
16071
|
setOpen(true);
|
@@ -15762,46 +16076,32 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
15762
16076
|
// the focus should always remain on the input, so we forward events on to the listbox
|
15763
16077
|
(_listboxRef$current = listboxRef.current) === null || _listboxRef$current === void 0 ? void 0 : _listboxRef$current.dispatchEvent(createCustomKeyboardEvent(event));
|
15764
16078
|
};
|
15765
|
-
|
15766
|
-
if (otherProps.onBlur) {
|
15767
|
-
// we might be focusing on an input or something inside the dropdown that was triggered by the select
|
15768
|
-
// so see if the element gaining focus is inside a portal and look up its controller
|
15769
|
-
// if we don't do this, things like validate on blur occur while simply opening the select
|
15770
|
-
handleBlur = event => {
|
15771
|
-
var _elementGainingFocus$;
|
15772
|
-
const elementGainingFocus = event.relatedTarget;
|
15773
|
-
if (elementGainingFocus === undefined) {
|
15774
|
-
return;
|
15775
|
-
}
|
15776
|
-
const portalId = elementGainingFocus === null || elementGainingFocus === void 0 ? void 0 : (_elementGainingFocus$ = elementGainingFocus.closest('[data-radix-popper-content-wrapper] > :first-child')) === null || _elementGainingFocus$ === void 0 ? void 0 : _elementGainingFocus$.id;
|
15777
|
-
if (!portalId || event.currentTarget.getAttribute(`aria-controls`) !== portalId) {
|
15778
|
-
var _otherProps$onBlur;
|
15779
|
-
(_otherProps$onBlur = otherProps.onBlur) === null || _otherProps$onBlur === void 0 ? void 0 : _otherProps$onBlur.call(otherProps, event);
|
15780
|
-
}
|
15781
|
-
};
|
15782
|
-
}
|
16079
|
+
const shouldFocusNextRef = React__default.useRef(false);
|
15783
16080
|
const handleListboxKeyDown = event => {
|
15784
16081
|
if (isAriaDirectionKey(event)) {
|
15785
16082
|
setShouldPauseHoverState(true);
|
16083
|
+
return;
|
16084
|
+
}
|
16085
|
+
if (event.key === 'Tab') {
|
16086
|
+
shouldFocusNextRef.current = true;
|
16087
|
+
setOpen(false);
|
16088
|
+
return;
|
15786
16089
|
}
|
16090
|
+
// support typeahead to set the value by typing its text
|
15787
16091
|
if (!hasSearch && /^[a-z0-9]$/i.test(event.key)) {
|
15788
16092
|
setValueIfMatched(event.key);
|
16093
|
+
return;
|
15789
16094
|
}
|
15790
16095
|
};
|
16096
|
+
// popover closes and unmounts before any event can be used to focus next, so prevent focusing the trigger and focus next
|
15791
16097
|
const handleCloseAutoFocus = event => {
|
15792
|
-
|
15793
|
-
|
15794
|
-
|
15795
|
-
|
15796
|
-
|
15797
|
-
|
15798
|
-
|
15799
|
-
// Reset the tabTriggeredClose state
|
15800
|
-
setTabTriggeredClose(false);
|
15801
|
-
}
|
15802
|
-
} else {
|
15803
|
-
var _internalRef$current;
|
15804
|
-
(_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.focus();
|
16098
|
+
if (shouldFocusNextRef.current) {
|
16099
|
+
var _otherProps$onBlur, _getNextFocussableEle;
|
16100
|
+
event.preventDefault();
|
16101
|
+
shouldFocusNextRef.current = false;
|
16102
|
+
(_otherProps$onBlur = otherProps.onBlur) === null || _otherProps$onBlur === void 0 ? void 0 : _otherProps$onBlur.call(otherProps, event);
|
16103
|
+
(_getNextFocussableEle = getNextFocussableElement(internalRef.current)) === null || _getNextFocussableEle === void 0 ? void 0 : _getNextFocussableEle.focus();
|
16104
|
+
return;
|
15805
16105
|
}
|
15806
16106
|
};
|
15807
16107
|
const areAllSelected = Array.isArray(value) && selectOptions.every(option => value.includes(option));
|
@@ -15850,18 +16150,14 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
15850
16150
|
}, /*#__PURE__*/React__default.createElement(Trigger$7, Object.assign({}, otherProps, {
|
15851
16151
|
"aria-haspopup": "listbox",
|
15852
16152
|
emptyValue: emptyValue,
|
15853
|
-
onBlur: handleBlur,
|
15854
16153
|
onKeyDown: handleKeyDown,
|
15855
16154
|
placeholder: placeholder,
|
15856
16155
|
ref: internalRef
|
15857
16156
|
}), flattenedChildren)), /*#__PURE__*/React__default.createElement(PopoverPrimitive.Portal, null, /*#__PURE__*/React__default.createElement(PopoverPrimitive.Content, {
|
15858
16157
|
asChild: true,
|
15859
16158
|
align: "start",
|
15860
|
-
onOpenAutoFocus: () => {
|
15861
|
-
var _internalRef$current2;
|
15862
|
-
(_internalRef$current2 = internalRef.current) === null || _internalRef$current2 === void 0 ? void 0 : _internalRef$current2.focus();
|
15863
|
-
},
|
15864
16159
|
onCloseAutoFocus: handleCloseAutoFocus,
|
16160
|
+
onPointerDownOutside: otherProps.onBlur,
|
15865
16161
|
sideOffset: 4,
|
15866
16162
|
tabIndex: -1
|
15867
16163
|
}, /*#__PURE__*/React__default.createElement("div", {
|
@@ -15871,8 +16167,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
15871
16167
|
}
|
15872
16168
|
}, hasSearch ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Search$2, {
|
15873
16169
|
placeholder: hasInlineCreation ? texts.select2.searchOrCreate : texts.select2.search,
|
15874
|
-
ref: searchRef
|
15875
|
-
onTabKeyPress: () => setTabTriggeredClose(true)
|
16170
|
+
ref: searchRef
|
15876
16171
|
}), multiple && selectOptions.length > 1 && (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button$1, {
|
15877
16172
|
className: "!justify-start",
|
15878
16173
|
appearance: "discrete",
|
@@ -15942,6 +16237,7 @@ const ControlledHiddenField = props => {
|
|
15942
16237
|
key: String(bubbleValue),
|
15943
16238
|
multiple: multiple,
|
15944
16239
|
name: name,
|
16240
|
+
tabIndex: -1,
|
15945
16241
|
value: bubbleValue
|
15946
16242
|
}, emptyValue !== undefined ? /*#__PURE__*/React__default.createElement("option", {
|
15947
16243
|
value: emptyValue
|
@@ -16214,10 +16510,11 @@ function guessComparatorsBasedOnControl(column) {
|
|
16214
16510
|
return getDataTypeProperties(columnMeta.dataType).filterComparators;
|
16215
16511
|
}
|
16216
16512
|
|
16513
|
+
const FilterContext = /*#__PURE__*/React__default.createContext([]);
|
16514
|
+
|
16217
16515
|
const FilterColumn = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
16218
16516
|
const {
|
16219
16517
|
allColumns,
|
16220
|
-
filters,
|
16221
16518
|
onChange: handleChange,
|
16222
16519
|
value = null,
|
16223
16520
|
...attributes
|
@@ -16225,6 +16522,7 @@ const FilterColumn = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
16225
16522
|
const {
|
16226
16523
|
texts
|
16227
16524
|
} = useLocalization();
|
16525
|
+
const filters = React__default.useContext(FilterContext);
|
16228
16526
|
const selectedColumn = allColumns.find(column => column.id === value);
|
16229
16527
|
const warning = selectedColumn && !selectedColumn.getIsVisible();
|
16230
16528
|
return /*#__PURE__*/React__default.createElement("div", {
|
@@ -16390,10 +16688,11 @@ function Control(props) {
|
|
16390
16688
|
} = props;
|
16391
16689
|
const controlRenderer = column === null || column === void 0 ? void 0 : (_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.control;
|
16392
16690
|
const dataType = column === null || column === void 0 ? void 0 : (_column$columnDef$met3 = column.columnDef.meta) === null || _column$columnDef$met3 === void 0 ? void 0 : _column$columnDef$met3.dataType;
|
16691
|
+
const filters = React__default.useContext(FilterContext);
|
16393
16692
|
const ref = React__default.useRef(null);
|
16394
16693
|
React.useEffect(() => {
|
16395
16694
|
// Set value to false only after first render of the control (when it's undefined) after setting the FilterColumn value, because we don't want to change then the value every time filter is opened
|
16396
|
-
if (controlRenderer === 'switch' && value === undefined) {
|
16695
|
+
if ((controlRenderer === 'switch' || controlRenderer === 'checkbox') && value === undefined) {
|
16397
16696
|
onChange(false);
|
16398
16697
|
}
|
16399
16698
|
}, [controlRenderer]);
|
@@ -16403,7 +16702,7 @@ function Control(props) {
|
|
16403
16702
|
setValue: value => onChange(value),
|
16404
16703
|
value,
|
16405
16704
|
ref
|
16406
|
-
}), {
|
16705
|
+
}, undefined, filters), {
|
16407
16706
|
['data-query-selector']: querySelector,
|
16408
16707
|
className: 'focus:yt-focus'
|
16409
16708
|
});
|
@@ -16418,6 +16717,12 @@ function Control(props) {
|
|
16418
16717
|
checked: Boolean(value),
|
16419
16718
|
onChange: onChange
|
16420
16719
|
}));
|
16720
|
+
} else if (controlRenderer === 'checkbox') {
|
16721
|
+
return /*#__PURE__*/React__default.createElement(Checkbox, Object.assign({}, attributes, {
|
16722
|
+
className: "!m-1.5",
|
16723
|
+
checked: Boolean(value),
|
16724
|
+
onChange: onChange
|
16725
|
+
}));
|
16421
16726
|
} else if ((controlRenderer === 'input' || controlRenderer === undefined) && dataType === 'number') {
|
16422
16727
|
return /*#__PURE__*/React__default.createElement(Input, Object.assign({}, attributes, {
|
16423
16728
|
className: "flex-grow",
|
@@ -16439,7 +16744,6 @@ function Filter$1(props) {
|
|
16439
16744
|
const {
|
16440
16745
|
allColumns,
|
16441
16746
|
filter,
|
16442
|
-
filters,
|
16443
16747
|
onChange: handleChange,
|
16444
16748
|
onRemove,
|
16445
16749
|
position
|
@@ -16514,7 +16818,6 @@ function Filter$1(props) {
|
|
16514
16818
|
className: "flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right"
|
16515
16819
|
}, position > 0 ? texts.table.filters.conditions.and : texts.table.filters.conditions.where), /*#__PURE__*/React__default.createElement(FilterColumn, {
|
16516
16820
|
allColumns: allColumns,
|
16517
|
-
filters: filters,
|
16518
16821
|
onChange: handleChangeColumn,
|
16519
16822
|
value: id,
|
16520
16823
|
ref: ref
|
@@ -16618,7 +16921,9 @@ function ManageFiltersPopover(props) {
|
|
16618
16921
|
};
|
16619
16922
|
return /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps, {
|
16620
16923
|
onChange: handleClose
|
16621
|
-
}), /*#__PURE__*/React__default.createElement(Popover.Content, null, /*#__PURE__*/React__default.createElement(
|
16924
|
+
}), /*#__PURE__*/React__default.createElement(Popover.Content, null, /*#__PURE__*/React__default.createElement(FilterContext.Provider, {
|
16925
|
+
value: filters
|
16926
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
16622
16927
|
className: "flex w-[40rem] flex-col gap-4"
|
16623
16928
|
}, /*#__PURE__*/React__default.createElement("div", {
|
16624
16929
|
className: "flex h-8"
|
@@ -16634,7 +16939,6 @@ function ManageFiltersPopover(props) {
|
|
16634
16939
|
key: `filter_${index}`,
|
16635
16940
|
allColumns: allColumns,
|
16636
16941
|
filter: filter,
|
16637
|
-
filters: filters,
|
16638
16942
|
position: index,
|
16639
16943
|
onChange: handleChangeFilter,
|
16640
16944
|
onRemove: filters.length > 0 && filters.some(f => f.id) || filters.length > 1 ? handleRemoveFilter : undefined
|
@@ -16650,7 +16954,7 @@ function ManageFiltersPopover(props) {
|
|
16650
16954
|
}, texts.table.filters.buttons.clear), /*#__PURE__*/React__default.createElement(Button$1, {
|
16651
16955
|
appearance: "primary",
|
16652
16956
|
onClick: handleApply
|
16653
|
-
}, texts.table.filters.buttons.apply)))));
|
16957
|
+
}, texts.table.filters.buttons.apply))))));
|
16654
16958
|
}
|
16655
16959
|
|
16656
16960
|
function Filters(props) {
|
@@ -16753,7 +17057,7 @@ function Table(props) {
|
|
16753
17057
|
}
|
16754
17058
|
Table.Toolbar = TableToolbar;
|
16755
17059
|
Table.Grid = TableGrid;
|
16756
|
-
function
|
17060
|
+
function getEmptyStateReason(table) {
|
16757
17061
|
if (table.instance.getFilteredRowModel().rows.length === 0 && table.instance.getCoreRowModel().rows.length !== 0) {
|
16758
17062
|
const state = table.instance.getState();
|
16759
17063
|
if (table.meta.search.enableGlobalFilter && !!state.globalFilter) {
|
@@ -16770,15 +17074,14 @@ function TableGrid(props) {
|
|
16770
17074
|
var _table$state$grouping;
|
16771
17075
|
const {
|
16772
17076
|
enableHorizontalArrowKeyNavigation,
|
17077
|
+
footerRows,
|
16773
17078
|
table,
|
16774
17079
|
...attributes
|
16775
17080
|
} = props;
|
16776
17081
|
const handleFocus = table.meta.rowActive.rowActiveIndex === undefined ? event => {
|
16777
17082
|
table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);
|
16778
17083
|
} : undefined;
|
16779
|
-
const
|
16780
|
-
const searchNotApplied = !table.state.globalFilter || table.state.globalFilter === '';
|
16781
|
-
const filtersNotApplied = !table.state.columnFilters || table.state.columnFilters.length === 0;
|
17084
|
+
const emptyStateReason = getEmptyStateReason(table);
|
16782
17085
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("style", null, table.stylesheet), /*#__PURE__*/React__default.createElement(focus.FocusScope, null, /*#__PURE__*/React__default.createElement("table", Object.assign({}, attributes, {
|
16783
17086
|
id: table.id,
|
16784
17087
|
"data-table-font-size": table.meta.fontSize.size,
|
@@ -16794,14 +17097,19 @@ function TableGrid(props) {
|
|
16794
17097
|
style: table.style,
|
16795
17098
|
tabIndex: -1
|
16796
17099
|
}), /*#__PURE__*/React__default.createElement("thead", null, table.instance.getHeaderGroups().map(headerGroup => (/*#__PURE__*/React__default.createElement("tr", {
|
16797
|
-
key: headerGroup.id
|
17100
|
+
key: headerGroup.id,
|
17101
|
+
onFocus: event => {
|
17102
|
+
// prevents rowActive.handleFocus from running when clicking on column-header menus.
|
17103
|
+
event.stopPropagation();
|
17104
|
+
}
|
16798
17105
|
}, headerGroup.headers.map(props => (/*#__PURE__*/React__default.createElement(Header$5, {
|
16799
17106
|
key: props.id,
|
16800
17107
|
header: props,
|
16801
17108
|
scrollToIndex: table.renderer.scrollToIndex
|
16802
|
-
}))))))),
|
17109
|
+
}))))))), emptyStateReason ? (/*#__PURE__*/React__default.createElement(EmptyStateBody, {
|
16803
17110
|
emptyState: props.table.props.emptyState,
|
16804
|
-
|
17111
|
+
isReady: table.meta.server.isEnabled ? table.meta.server.isReady : true,
|
17112
|
+
reason: emptyStateReason
|
16805
17113
|
})) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Body, {
|
16806
17114
|
enableHorizontalArrowKeyNavigation: enableHorizontalArrowKeyNavigation,
|
16807
17115
|
table: table.instance,
|
@@ -16811,9 +17119,9 @@ function TableGrid(props) {
|
|
16811
17119
|
...table.renderer.style,
|
16812
17120
|
height: table.renderer.style.height + ROW_HEIGHT_ESTIMATES[table.meta.rowHeight.height]
|
16813
17121
|
} : table.renderer.style
|
16814
|
-
}, table.renderer.rows,
|
17122
|
+
}, table.renderer.rows, props.children), table.meta.footer.isEnabled ? /*#__PURE__*/React__default.createElement(Foot, {
|
16815
17123
|
table: table.instance
|
16816
|
-
}) : null)))));
|
17124
|
+
}, footerRows) : null)))));
|
16817
17125
|
}
|
16818
17126
|
|
16819
17127
|
function Column$1(_) {
|
@@ -18314,71 +18622,6 @@ const useTableRowCreation = (data, tableRef) => {
|
|
18314
18622
|
};
|
18315
18623
|
};
|
18316
18624
|
|
18317
|
-
function useTableEditingListener(table, tableRef) {
|
18318
|
-
const tableMeta = table.options.meta;
|
18319
|
-
const completedRowsCount = tableMeta.editing.getCompletedRowsCount();
|
18320
|
-
const localization = useLocalization();
|
18321
|
-
const saveChanges = () => {
|
18322
|
-
requestAnimationFrame(() => {
|
18323
|
-
tableMeta.editing.saveChanges();
|
18324
|
-
});
|
18325
|
-
};
|
18326
|
-
// save when the row changes
|
18327
|
-
useLazyEffect(() => {
|
18328
|
-
if (tableMeta.editing.isEditing) {
|
18329
|
-
saveChanges();
|
18330
|
-
}
|
18331
|
-
}, [tableMeta.rowActive.rowActiveIndex]);
|
18332
|
-
useLazyEffect(() => {
|
18333
|
-
if (tableMeta.editing.isEditing) {
|
18334
|
-
if (tableMeta.rowActive.rowActiveIndex === undefined) {
|
18335
|
-
tableMeta.rowActive.setRowActiveIndex(0);
|
18336
|
-
}
|
18337
|
-
} else {
|
18338
|
-
// save
|
18339
|
-
saveChanges();
|
18340
|
-
// reset detailed mode
|
18341
|
-
tableMeta.editing.toggleDetailedMode(false);
|
18342
|
-
// reset the last index back to the first focusable element, when editing gets turned off
|
18343
|
-
tableMeta.editing.setLastFocusedCellIndex(undefined);
|
18344
|
-
}
|
18345
|
-
}, [tableMeta.editing.isEditing]);
|
18346
|
-
// show a warning if the user navigates away without triggering save, such as using the browser back/forward button
|
18347
|
-
const hasChanges = tableMeta.editing.hasChanges();
|
18348
|
-
React__default.useEffect(() => {
|
18349
|
-
function showUnsavedChangesWarning(event) {
|
18350
|
-
if (tableMeta.editing.isEditing && hasChanges) {
|
18351
|
-
event.returnValue = true;
|
18352
|
-
return true;
|
18353
|
-
}
|
18354
|
-
return false;
|
18355
|
-
}
|
18356
|
-
window.addEventListener('beforeunload', showUnsavedChangesWarning);
|
18357
|
-
return () => {
|
18358
|
-
window.removeEventListener('beforeunload', showUnsavedChangesWarning);
|
18359
|
-
};
|
18360
|
-
}, [tableMeta.editing.isEditing, hasChanges]);
|
18361
|
-
React__default.useEffect(() => {
|
18362
|
-
if (completedRowsCount > 0) {
|
18363
|
-
resetHighlightedColumnIndexes(table.getState().globalFilter, table, localization);
|
18364
|
-
}
|
18365
|
-
}, [completedRowsCount]);
|
18366
|
-
React__default.useEffect(() => {
|
18367
|
-
const onClickOutside = event => {
|
18368
|
-
if (tableMeta.editing.isEditing) {
|
18369
|
-
var _event$target$getAttr, _event$target;
|
18370
|
-
const element = (_event$target$getAttr = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getAttribute('data-taco')) !== null && _event$target$getAttr !== void 0 ? _event$target$getAttr : '';
|
18371
|
-
const insideTable = isElementInsideOrTriggeredFromContainer(event.target, tableRef.current) || element === 'backdrop';
|
18372
|
-
if (!insideTable) {
|
18373
|
-
saveChanges();
|
18374
|
-
}
|
18375
|
-
}
|
18376
|
-
};
|
18377
|
-
document.addEventListener('click', onClickOutside);
|
18378
|
-
return () => document.removeEventListener('click', onClickOutside);
|
18379
|
-
}, [saveChanges, tableMeta.editing.isEditing]);
|
18380
|
-
}
|
18381
|
-
|
18382
18625
|
function willRowMove(cell, change, rowIndex, localization) {
|
18383
18626
|
const {
|
18384
18627
|
table
|
@@ -18459,444 +18702,706 @@ function willRowMoveAfterSorting(cell, change, rowIndex) {
|
|
18459
18702
|
}
|
18460
18703
|
return ((_resortedRows$index = resortedRows[index]) === null || _resortedRows$index === void 0 ? void 0 : _resortedRows$index.id) !== cell.row.id;
|
18461
18704
|
}
|
18462
|
-
|
18463
|
-
|
18464
|
-
if (
|
18465
|
-
|
18466
|
-
const checkbox = firstCell === null || firstCell === void 0 ? void 0 : firstCell.querySelector('[data-taco="checkbox"]');
|
18467
|
-
firstCell === null || firstCell === void 0 ? void 0 : firstCell.focus();
|
18468
|
-
if (checkbox) {
|
18469
|
-
setDataFocusAttribute(checkbox);
|
18470
|
-
}
|
18471
|
-
templateRow.scrollIntoView();
|
18472
|
-
const keyframes = [{
|
18473
|
-
background: '#b2c7ef'
|
18474
|
-
}, {
|
18475
|
-
background: '#ebebeb'
|
18476
|
-
}];
|
18477
|
-
for (const child of templateRow.children) {
|
18478
|
-
child.animate(keyframes, {
|
18479
|
-
duration: 1000,
|
18480
|
-
easing: 'ease-out'
|
18481
|
-
});
|
18482
|
-
}
|
18705
|
+
const TEMPORARY_ROW_ID_PREFIX = 'temp-';
|
18706
|
+
function isTemporaryRow(rowId) {
|
18707
|
+
if (rowId === undefined) {
|
18708
|
+
return false;
|
18483
18709
|
}
|
18710
|
+
return String(rowId).startsWith(TEMPORARY_ROW_ID_PREFIX);
|
18711
|
+
}
|
18712
|
+
const shortcut = {
|
18713
|
+
key: 'e',
|
18714
|
+
meta: true,
|
18715
|
+
shift: false
|
18716
|
+
};
|
18717
|
+
function isTableScrolled(ref) {
|
18718
|
+
if (ref.current) {
|
18719
|
+
var _ref$current, _ref$current$querySel, _ref$current2, _ref$current2$querySe;
|
18720
|
+
const height = parseFloat(((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : (_ref$current$querySel = _ref$current.querySelector('tbody')) === null || _ref$current$querySel === void 0 ? void 0 : _ref$current$querySel.style.height) || '0') + parseFloat(((_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : (_ref$current2$querySe = _ref$current2.querySelector('tbody')) === null || _ref$current2$querySe === void 0 ? void 0 : _ref$current2$querySe.style.paddingBottom) || '0');
|
18721
|
+
return height > ref.current.scrollHeight;
|
18722
|
+
}
|
18723
|
+
return false;
|
18484
18724
|
}
|
18485
18725
|
|
18486
|
-
function
|
18487
|
-
|
18488
|
-
const
|
18489
|
-
|
18490
|
-
|
18491
|
-
|
18492
|
-
|
18493
|
-
|
18494
|
-
|
18495
|
-
|
18496
|
-
|
18497
|
-
|
18726
|
+
function useTableEditingListener(table, tableRef, scrollToIndex) {
|
18727
|
+
const tableMeta = table.options.meta;
|
18728
|
+
const localization = useLocalization();
|
18729
|
+
useLazyEffect(() => {
|
18730
|
+
return () => {
|
18731
|
+
if (tableMeta.editing.isEditing && tableMeta.rowActive.rowActiveIndex !== undefined) {
|
18732
|
+
var _table$getRowModel$ro;
|
18733
|
+
tableMeta.editing.saveChanges(table, (_table$getRowModel$ro = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex]) === null || _table$getRowModel$ro === void 0 ? void 0 : _table$getRowModel$ro.id);
|
18734
|
+
}
|
18735
|
+
};
|
18736
|
+
}, [tableMeta.rowActive.rowActiveIndex]);
|
18737
|
+
// show a warning if the user navigates away without triggering save, such as using the browser back/forward button
|
18738
|
+
const hasChanges = tableMeta.editing.hasChanges();
|
18739
|
+
React__default.useEffect(() => {
|
18740
|
+
function showUnsavedChangesWarning(event) {
|
18741
|
+
if (tableMeta.editing.isEditing && hasChanges) {
|
18742
|
+
event.returnValue = true;
|
18743
|
+
return true;
|
18744
|
+
}
|
18745
|
+
return false;
|
18746
|
+
}
|
18747
|
+
window.addEventListener('beforeunload', showUnsavedChangesWarning);
|
18748
|
+
return () => {
|
18749
|
+
window.removeEventListener('beforeunload', showUnsavedChangesWarning);
|
18750
|
+
};
|
18751
|
+
}, [tableMeta.editing.isEditing, hasChanges]);
|
18752
|
+
const hasSavedChanges = tableMeta.editing.hasSaved();
|
18753
|
+
useLazyEffect(() => {
|
18754
|
+
if (hasSavedChanges) {
|
18755
|
+
resetHighlightedColumnIndexes(table.getState().globalFilter, table, localization);
|
18756
|
+
}
|
18757
|
+
}, [hasSavedChanges]);
|
18758
|
+
React__default.useEffect(() => {
|
18759
|
+
const onClickOutside = event => {
|
18760
|
+
if (tableMeta.editing.isEditing) {
|
18761
|
+
const element = event.target;
|
18762
|
+
const isTableOrIsInsideTable = element.tagName === 'TABLE' || element.tagName === 'TBODY' || element.getAttribute('data-taco') === 'backdrop' || element.getAttribute('data-table') === 'editing-toggle' || !document.body.contains(element) || isElementInsideOrTriggeredFromContainer(element, tableRef.current);
|
18763
|
+
// users can click the white space below rows which could be inside the table, but a valid scenario to save
|
18764
|
+
if (!isTableOrIsInsideTable) {
|
18765
|
+
tableMeta.editing.saveChanges(table);
|
18766
|
+
}
|
18767
|
+
}
|
18768
|
+
};
|
18769
|
+
document.addEventListener('click', onClickOutside);
|
18770
|
+
return () => document.removeEventListener('click', onClickOutside);
|
18771
|
+
}, [tableMeta.editing.isEditing, tableMeta.editing.saveChanges]);
|
18772
|
+
const rows = table.getRowModel().rows;
|
18773
|
+
// make sure pending changes are removed for rows that no longer exist
|
18774
|
+
useLazyEffect(() => {
|
18775
|
+
const pendingChanges = tableMeta.editing.getErrorsShownInAlert();
|
18776
|
+
pendingChanges.forEach(pendingChange => {
|
18777
|
+
try {
|
18778
|
+
table.getRow(pendingChange.rowId);
|
18779
|
+
} catch {
|
18780
|
+
tableMeta.editing.discardChanges(pendingChange.rowId, table);
|
18781
|
+
}
|
18782
|
+
});
|
18783
|
+
}, [rows.length]);
|
18784
|
+
// shortcuts
|
18785
|
+
useGlobalKeyDown(tableMeta.editing.isEnabled ? shortcut : undefined, event => {
|
18786
|
+
event.preventDefault();
|
18787
|
+
tableMeta.editing.toggleEditing(!tableMeta.editing.isEditing, table, scrollToIndex);
|
18788
|
+
});
|
18789
|
+
useGlobalKeyDown(tableMeta.editing.isEditing ? {
|
18498
18790
|
key: 's',
|
18499
18791
|
meta: true,
|
18500
18792
|
shift: false
|
18501
18793
|
} : undefined, event => {
|
18502
18794
|
event.preventDefault();
|
18503
|
-
|
18795
|
+
tableMeta.editing.saveChanges(table);
|
18504
18796
|
});
|
18505
|
-
return {
|
18506
|
-
isEnabled,
|
18507
|
-
isEditing,
|
18508
|
-
isDetailedMode,
|
18509
|
-
toggleDetailedMode: isEnabled ? toggleDetailedMode : () => undefined,
|
18510
|
-
toggleEditing: isEnabled ? toggleEditing : () => undefined,
|
18511
|
-
lastFocusedCellIndex,
|
18512
|
-
setLastFocusedCellIndex,
|
18513
|
-
...pendingChangesFns
|
18514
|
-
};
|
18515
18797
|
}
|
18516
|
-
|
18517
|
-
|
18798
|
+
|
18799
|
+
const DELAY_BEFORE_REMOVING_SAVE_STATUS = 3000;
|
18800
|
+
function reducer$2(state, action) {
|
18801
|
+
const {
|
18802
|
+
type,
|
18803
|
+
rowId,
|
18804
|
+
payload
|
18805
|
+
} = action;
|
18806
|
+
switch (type) {
|
18807
|
+
case 'setCellValue':
|
18808
|
+
{
|
18809
|
+
const {
|
18810
|
+
columnId,
|
18811
|
+
row,
|
18812
|
+
value
|
18813
|
+
} = payload;
|
18814
|
+
return {
|
18815
|
+
...state,
|
18816
|
+
changes: {
|
18817
|
+
...state.changes,
|
18818
|
+
rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),
|
18819
|
+
originals: setWith(state.changes.originals, rowId, row, Object)
|
18820
|
+
}
|
18821
|
+
};
|
18822
|
+
}
|
18823
|
+
case 'removeCellValue':
|
18824
|
+
{
|
18825
|
+
const {
|
18826
|
+
columnId,
|
18827
|
+
rowIdentityAccessor
|
18828
|
+
} = payload;
|
18829
|
+
const changes = omit(state.changes.rows, `${rowId}.${columnId}`);
|
18830
|
+
// if there are no changes left, remove the row
|
18831
|
+
if (!Object.keys(changes[rowId]).length) {
|
18832
|
+
return reducer$2(state, {
|
18833
|
+
type: 'removeRow',
|
18834
|
+
rowId,
|
18835
|
+
payload: {
|
18836
|
+
rowIdentityAccessor
|
18837
|
+
}
|
18838
|
+
});
|
18839
|
+
}
|
18840
|
+
return {
|
18841
|
+
...state,
|
18842
|
+
changes: {
|
18843
|
+
...state.changes,
|
18844
|
+
rows: omit(state.changes.rows, `${rowId}.${columnId}`),
|
18845
|
+
errors: omit(state.changes.errors, `${rowId}.cells.${columnId}`),
|
18846
|
+
moveReasons: omit(state.changes.moveReasons, `${rowId}.${columnId}`)
|
18847
|
+
}
|
18848
|
+
};
|
18849
|
+
}
|
18850
|
+
case 'updateRow':
|
18851
|
+
{
|
18852
|
+
const {
|
18853
|
+
cellErrors,
|
18854
|
+
moveReasons,
|
18855
|
+
original,
|
18856
|
+
value
|
18857
|
+
} = payload;
|
18858
|
+
return {
|
18859
|
+
...state,
|
18860
|
+
changes: {
|
18861
|
+
...state.changes,
|
18862
|
+
rows: setWith(state.changes.rows, rowId, value, Object),
|
18863
|
+
errors: setWith(state.changes.errors, `${rowId}.cells`, cellErrors !== null && cellErrors !== void 0 ? cellErrors : state.changes.errors.cells[rowId], Object),
|
18864
|
+
originals: setWith(state.changes.originals, rowId, original !== null && original !== void 0 ? original : state.changes.originals[rowId], Object),
|
18865
|
+
moveReasons: setWith(state.changes.moveReasons, rowId, moveReasons !== null && moveReasons !== void 0 ? moveReasons : state.changes.moveReasons[rowId], Object),
|
18866
|
+
// status can be undefined, so don't use ??
|
18867
|
+
status: setWith(state.changes.status, rowId, undefined, Object)
|
18868
|
+
}
|
18869
|
+
};
|
18870
|
+
}
|
18871
|
+
case 'removeRow':
|
18872
|
+
{
|
18873
|
+
const {
|
18874
|
+
rowIdentityAccessor
|
18875
|
+
} = payload;
|
18876
|
+
return {
|
18877
|
+
...state,
|
18878
|
+
changes: {
|
18879
|
+
...state.changes,
|
18880
|
+
rows: omit(state.changes.rows, rowId),
|
18881
|
+
errors: omit(state.changes.errors, rowId),
|
18882
|
+
moveReasons: omit(state.changes.moveReasons, rowId),
|
18883
|
+
originals: omit(state.changes.originals, rowId),
|
18884
|
+
status: omit(state.changes.status, rowId)
|
18885
|
+
},
|
18886
|
+
temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor] !== rowId)
|
18887
|
+
};
|
18888
|
+
}
|
18889
|
+
case 'setRowStatus':
|
18890
|
+
{
|
18891
|
+
const {
|
18892
|
+
status
|
18893
|
+
} = payload;
|
18894
|
+
return {
|
18895
|
+
...state,
|
18896
|
+
changes: {
|
18897
|
+
...state.changes,
|
18898
|
+
status: status ? setWith(state.changes.status, rowId, status, Object) : omit(state.changes.status, rowId)
|
18899
|
+
}
|
18900
|
+
};
|
18901
|
+
}
|
18902
|
+
case 'setRowErrors':
|
18903
|
+
{
|
18904
|
+
const {
|
18905
|
+
...errors
|
18906
|
+
} = payload;
|
18907
|
+
return {
|
18908
|
+
...state,
|
18909
|
+
changes: {
|
18910
|
+
...state.changes,
|
18911
|
+
errors: setWith(state.changes.errors, rowId, errors, Object)
|
18912
|
+
}
|
18913
|
+
};
|
18914
|
+
}
|
18915
|
+
case 'insertTemporaryRow':
|
18916
|
+
{
|
18917
|
+
const {
|
18918
|
+
value
|
18919
|
+
} = payload;
|
18920
|
+
return {
|
18921
|
+
...state,
|
18922
|
+
temporaryRows: state.temporaryRows.concat(value),
|
18923
|
+
changes: {
|
18924
|
+
...state.changes,
|
18925
|
+
rows: setWith(state.changes.rows, rowId, value, Object),
|
18926
|
+
originals: setWith(state.changes.originals, rowId, value, Object)
|
18927
|
+
}
|
18928
|
+
};
|
18929
|
+
}
|
18930
|
+
default:
|
18931
|
+
return state;
|
18932
|
+
}
|
18933
|
+
}
|
18934
|
+
function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, validator) {
|
18935
|
+
const saveChanges = function (table, rowId = undefined) {
|
18518
18936
|
try {
|
18519
18937
|
let _exit = false;
|
18520
18938
|
if (!handleSave) {
|
18521
18939
|
console.warn('Tried to save, but Table has no onEditingSave handler');
|
18522
|
-
return Promise.resolve();
|
18940
|
+
return Promise.resolve(false);
|
18523
18941
|
}
|
18524
|
-
// we
|
18525
|
-
const
|
18526
|
-
[rowId]:
|
18527
|
-
} :
|
18528
|
-
|
18529
|
-
|
18530
|
-
|
18531
|
-
|
18532
|
-
|
18533
|
-
|
18534
|
-
|
18535
|
-
|
18536
|
-
|
18537
|
-
|
18538
|
-
|
18539
|
-
|
18540
|
-
|
18541
|
-
|
18542
|
-
|
18543
|
-
|
18544
|
-
|
18545
|
-
|
18546
|
-
|
18547
|
-
|
18548
|
-
|
18549
|
-
|
18550
|
-
|
18551
|
-
|
18552
|
-
|
18553
|
-
|
18554
|
-
|
18555
|
-
|
18556
|
-
|
18557
|
-
|
18558
|
-
|
18559
|
-
|
18560
|
-
|
18561
|
-
|
18562
|
-
|
18563
|
-
|
18564
|
-
let rowError;
|
18565
|
-
let cellErrors;
|
18566
|
-
if (typeof error === 'string') {
|
18567
|
-
rowError = error;
|
18568
|
-
} else if (error instanceof Error) {
|
18569
|
-
var _error$response;
|
18570
|
-
rowError = error.message;
|
18571
|
-
// most of our apis return error objects within this shape
|
18572
|
-
if (typeof ((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) === 'object') {
|
18573
|
-
var _error$response2;
|
18574
|
-
cellErrors = (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data;
|
18942
|
+
// sometimes we only want to save one row
|
18943
|
+
const changes = rowId ? {
|
18944
|
+
[rowId]: state.changes.rows[rowId]
|
18945
|
+
} : state.changes.rows;
|
18946
|
+
let completed = true;
|
18947
|
+
const _temp9 = _forOf(Object.keys(changes), function (rowId) {
|
18948
|
+
const status = getRowStatus(rowId);
|
18949
|
+
return _catch(function () {
|
18950
|
+
var _changes$rowId;
|
18951
|
+
function _temp8(_result) {
|
18952
|
+
return _exit ? _result : Promise.resolve(handleSave(changeSet)).then(function () {
|
18953
|
+
// cleanup changes, we don't need them after saving
|
18954
|
+
discardChanges(rowId, table);
|
18955
|
+
// show the saved status, then remove it after a delay
|
18956
|
+
setRowStatus(rowId, 'saved');
|
18957
|
+
setTimeout(() => {
|
18958
|
+
setRowStatus(rowId, undefined);
|
18959
|
+
}, DELAY_BEFORE_REMOVING_SAVE_STATUS);
|
18960
|
+
});
|
18961
|
+
}
|
18962
|
+
const rowChanges = (_changes$rowId = changes[rowId]) !== null && _changes$rowId !== void 0 ? _changes$rowId : {};
|
18963
|
+
// don't try to save if - already saving, or there are known errors
|
18964
|
+
if (!Object.keys(rowChanges).length || status === 'saving' || status === 'errored') {
|
18965
|
+
return;
|
18966
|
+
}
|
18967
|
+
setRowStatus(rowId, 'saving');
|
18968
|
+
const changeSet = {
|
18969
|
+
...state.changes.originals[rowId],
|
18970
|
+
...rowChanges
|
18971
|
+
};
|
18972
|
+
// if we had to create a temporary id, delete it first - it's our data, not theirs
|
18973
|
+
if (isTemporaryRow(changeSet[rowIdentityAccessor])) {
|
18974
|
+
delete changeSet[rowIdentityAccessor];
|
18975
|
+
}
|
18976
|
+
// re-run validation, maybe a cell is already invalid but has never been blurred
|
18977
|
+
const _temp7 = function () {
|
18978
|
+
if (validator) {
|
18979
|
+
return Promise.resolve(validator(changeSet)).then(function (errors) {
|
18980
|
+
if (errors && Object.keys(errors).length) {
|
18981
|
+
throw errors;
|
18575
18982
|
}
|
18576
|
-
}
|
18577
|
-
|
18578
|
-
|
18579
|
-
|
18580
|
-
|
18581
|
-
|
18582
|
-
|
18583
|
-
|
18584
|
-
|
18585
|
-
|
18586
|
-
|
18587
|
-
|
18588
|
-
|
18589
|
-
|
18590
|
-
|
18983
|
+
});
|
18984
|
+
}
|
18985
|
+
}();
|
18986
|
+
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7); // send new data to the server
|
18987
|
+
}, function (error) {
|
18988
|
+
var _error$response;
|
18989
|
+
if (error instanceof ReferenceError || error instanceof TypeError || (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) >= 500) {
|
18990
|
+
console.error(error);
|
18991
|
+
}
|
18992
|
+
// the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc
|
18993
|
+
// this code handles those errors and maps them either to row errors or cell specific errors
|
18994
|
+
let rowError;
|
18995
|
+
let cellErrors;
|
18996
|
+
if (typeof error === 'string') {
|
18997
|
+
rowError = error;
|
18998
|
+
} else if (error instanceof Error) {
|
18999
|
+
var _error$response2;
|
19000
|
+
rowError = error.message;
|
19001
|
+
// most of our apis return error objects within this shape
|
19002
|
+
if (typeof ((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) === 'object') {
|
19003
|
+
var _error$response3;
|
19004
|
+
cellErrors = (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data;
|
19005
|
+
}
|
19006
|
+
} else if (typeof error === 'object') {
|
19007
|
+
cellErrors = error;
|
19008
|
+
}
|
19009
|
+
if (rowError || cellErrors) {
|
19010
|
+
dispatch({
|
19011
|
+
type: 'setRowErrors',
|
19012
|
+
rowId,
|
19013
|
+
payload: {
|
19014
|
+
row: rowError,
|
19015
|
+
cells: cellErrors,
|
19016
|
+
shouldShowErrorAlert: true
|
18591
19017
|
}
|
18592
|
-
setRowSaveStatus(rowId, undefined);
|
18593
19018
|
});
|
18594
|
-
}
|
18595
|
-
|
18596
|
-
|
18597
|
-
}
|
18598
|
-
}()
|
19019
|
+
}
|
19020
|
+
setRowStatus(rowId, 'errored');
|
19021
|
+
completed = false;
|
19022
|
+
});
|
19023
|
+
}, function () {
|
19024
|
+
return _exit;
|
19025
|
+
});
|
19026
|
+
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function (_result3) {
|
19027
|
+
return _exit ? _result3 : completed;
|
19028
|
+
}) : _exit ? _temp9 : completed);
|
18599
19029
|
} catch (e) {
|
18600
19030
|
return Promise.reject(e);
|
18601
19031
|
}
|
18602
19032
|
};
|
18603
|
-
const
|
19033
|
+
const onCellChanged = function (cell, rowIndex, nextValue, shouldRunUpdaters = true) {
|
18604
19034
|
try {
|
18605
|
-
|
18606
|
-
|
18607
|
-
|
18608
|
-
|
18609
|
-
|
18610
|
-
|
18611
|
-
|
18612
|
-
|
18613
|
-
|
18614
|
-
|
18615
|
-
|
18616
|
-
|
18617
|
-
|
18618
|
-
|
18619
|
-
|
18620
|
-
|
18621
|
-
|
18622
|
-
|
19035
|
+
function _temp6() {
|
19036
|
+
var _state$changes$errors11;
|
19037
|
+
function _temp4() {
|
19038
|
+
// only set errors and move reasons for the cells we're currently acting on
|
19039
|
+
// why? because the UX is not good if we set them for cells the user hasn't touched yet
|
19040
|
+
const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];
|
19041
|
+
const allCells = cell.row._getAllCellsByColumnId();
|
19042
|
+
cellsToActOn.forEach(accessor => {
|
19043
|
+
if (validationErrors[accessor]) {
|
19044
|
+
nextCellErrors[accessor] = validationErrors[accessor];
|
19045
|
+
// don't show move indicator for cells with errors, they aren't valid and can't be saved
|
19046
|
+
delete nextMoveReasons[accessor];
|
19047
|
+
} else {
|
19048
|
+
var _allCells$accessor;
|
19049
|
+
// there isn't any error in this run, remove any error set in state
|
19050
|
+
delete nextCellErrors[accessor];
|
19051
|
+
if ((_allCells$accessor = allCells[accessor]) !== null && _allCells$accessor !== void 0 && _allCells$accessor.column.getIsSorted()) {
|
19052
|
+
// run row move determination
|
19053
|
+
const reason = willRowMove(cell, nextChanges[accessor], rowIndex, localization);
|
19054
|
+
// if the row will move based on this change save why, otherwise delete any existing state
|
19055
|
+
if (reason) {
|
19056
|
+
nextMoveReasons[accessor] = reason;
|
19057
|
+
} else {
|
19058
|
+
delete nextMoveReasons[accessor];
|
18623
19059
|
}
|
18624
|
-
}
|
18625
|
-
|
19060
|
+
}
|
19061
|
+
}
|
19062
|
+
});
|
19063
|
+
dispatch({
|
19064
|
+
type: 'updateRow',
|
19065
|
+
rowId: cell.row.id,
|
19066
|
+
payload: {
|
19067
|
+
cellErrors: nextCellErrors,
|
19068
|
+
moveReasons: nextMoveReasons,
|
19069
|
+
value: nextChanges
|
19070
|
+
}
|
19071
|
+
});
|
19072
|
+
}
|
19073
|
+
// create a projection of the next state, so we can act against it
|
19074
|
+
const nextChanges = {
|
19075
|
+
...changes,
|
19076
|
+
...updatesForOtherCells
|
19077
|
+
};
|
19078
|
+
const nextMoveReasons = {
|
19079
|
+
...state.changes.moveReasons[cell.row.id]
|
19080
|
+
};
|
19081
|
+
const nextCellErrors = {
|
19082
|
+
...((_state$changes$errors11 = state.changes.errors[cell.row.id]) === null || _state$changes$errors11 === void 0 ? void 0 : _state$changes$errors11.cells)
|
19083
|
+
};
|
19084
|
+
// run validation - if there are changes, and if there is an original stored
|
19085
|
+
let validationErrors = {};
|
19086
|
+
const _temp3 = function () {
|
19087
|
+
if (validator && Object.keys(nextChanges).length && state.changes.originals[cell.row.id]) {
|
19088
|
+
// merge with the original so we get a full row
|
19089
|
+
const nextRowValue = {
|
19090
|
+
...state.changes.originals[cell.row.id],
|
19091
|
+
...changes,
|
19092
|
+
...updatesForOtherCells
|
19093
|
+
};
|
19094
|
+
return Promise.resolve(validator(nextRowValue)).then(function (_validator2) {
|
19095
|
+
validationErrors = _validator2 !== null && _validator2 !== void 0 ? _validator2 : {};
|
18626
19096
|
});
|
19097
|
+
}
|
19098
|
+
}();
|
19099
|
+
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
19100
|
+
}
|
19101
|
+
const changes = nextValue !== undefined ? {
|
19102
|
+
...state.changes.rows[cell.row.id],
|
19103
|
+
[cell.column.id]: nextValue
|
19104
|
+
} : {
|
19105
|
+
...state.changes.rows[cell.row.id]
|
19106
|
+
};
|
19107
|
+
if (!Object.keys(changes).length) {
|
19108
|
+
return Promise.resolve();
|
19109
|
+
}
|
19110
|
+
let updatesForOtherCells = {};
|
19111
|
+
// run the updater handler if there is one, to see if there are any other cells to update
|
19112
|
+
const _temp5 = function () {
|
19113
|
+
if (typeof handleChange === 'function' && shouldRunUpdaters) {
|
19114
|
+
const previousRowValue = {
|
19115
|
+
...state.changes.originals[cell.row.id]
|
19116
|
+
};
|
19117
|
+
const nextRowValue = {
|
19118
|
+
...state.changes.originals[cell.row.id],
|
19119
|
+
...changes
|
19120
|
+
};
|
19121
|
+
return Promise.resolve(handleChange(cell.column.id, changes[cell.column.id], nextRowValue, previousRowValue)).then(function (_handleChange) {
|
19122
|
+
updatesForOtherCells = _handleChange !== null && _handleChange !== void 0 ? _handleChange : {};
|
18627
19123
|
});
|
18628
19124
|
}
|
18629
19125
|
}();
|
18630
|
-
return Promise.resolve(
|
18631
|
-
} catch (e) {
|
18632
|
-
return Promise.reject(e);
|
18633
|
-
}
|
18634
|
-
};
|
18635
|
-
const setCellValue = function (cell, change, rowIndex) {
|
18636
|
-
try {
|
18637
|
-
const changes = {
|
18638
|
-
[cell.column.id]: change
|
18639
|
-
};
|
18640
|
-
setPendingChanges(currentChanges => {
|
18641
|
-
const nextChanges = createPendingChangesSetter(currentChanges, cell.row, rowIndex, changes, localization);
|
18642
|
-
pendingChangesUpdater.syncCellChanges(nextChanges);
|
18643
|
-
return nextChanges;
|
18644
|
-
});
|
18645
|
-
pendingChangesUpdater.runCellUpdates(changes, cell, rowIndex);
|
18646
|
-
return Promise.resolve();
|
19126
|
+
return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5));
|
18647
19127
|
} catch (e) {
|
18648
19128
|
return Promise.reject(e);
|
18649
19129
|
}
|
18650
|
-
};
|
18651
|
-
|
19130
|
+
}; // general
|
19131
|
+
// rows
|
19132
|
+
const setRowValue = function (rowId, original, value) {
|
18652
19133
|
try {
|
18653
|
-
|
18654
|
-
|
18655
|
-
|
18656
|
-
|
18657
|
-
|
18658
|
-
|
18659
|
-
|
18660
|
-
|
18661
|
-
...changes[cell.row.id],
|
18662
|
-
[cell.column.id]: cell.getValue(),
|
18663
|
-
_meta: {
|
18664
|
-
...((_currentChanges$cell$ = currentChanges[cell.row.id]) === null || _currentChanges$cell$ === void 0 ? void 0 : _currentChanges$cell$._meta),
|
18665
|
-
original: cell.row.original,
|
18666
|
-
moveReason: {
|
18667
|
-
...((_currentChanges$cell$2 = currentChanges[cell.row.id]) === null || _currentChanges$cell$2 === void 0 ? void 0 : _currentChanges$cell$2._meta.moveReason)
|
18668
|
-
},
|
18669
|
-
errors: {
|
18670
|
-
...((_currentChanges$cell$3 = currentChanges[cell.row.id]) === null || _currentChanges$cell$3 === void 0 ? void 0 : _currentChanges$cell$3._meta.errors)
|
18671
|
-
}
|
18672
|
-
}
|
18673
|
-
}
|
18674
|
-
};
|
18675
|
-
} else {
|
18676
|
-
return changes;
|
19134
|
+
function _temp2() {
|
19135
|
+
dispatch({
|
19136
|
+
type: 'updateRow',
|
19137
|
+
rowId,
|
19138
|
+
payload: {
|
19139
|
+
cellErrors,
|
19140
|
+
original,
|
19141
|
+
value
|
18677
19142
|
}
|
18678
|
-
}
|
18679
|
-
}
|
18680
|
-
|
19143
|
+
});
|
19144
|
+
}
|
19145
|
+
let cellErrors;
|
19146
|
+
const _temp = function () {
|
19147
|
+
if (validator) {
|
19148
|
+
const row = {
|
19149
|
+
...original,
|
19150
|
+
...value
|
19151
|
+
};
|
19152
|
+
return Promise.resolve(validator(row)).then(function (_validator) {
|
19153
|
+
cellErrors = _validator !== null && _validator !== void 0 ? _validator : {};
|
19154
|
+
});
|
19155
|
+
}
|
19156
|
+
}();
|
19157
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
18681
19158
|
} catch (e) {
|
18682
19159
|
return Promise.reject(e);
|
18683
19160
|
}
|
18684
19161
|
};
|
18685
19162
|
const localization = useLocalization();
|
18686
|
-
const [
|
18687
|
-
|
18688
|
-
|
18689
|
-
|
18690
|
-
|
18691
|
-
|
19163
|
+
const [state, dispatch] = React__default.useReducer(reducer$2, {
|
19164
|
+
changes: {
|
19165
|
+
rows: {},
|
19166
|
+
errors: {},
|
19167
|
+
moveReasons: {},
|
19168
|
+
originals: {},
|
19169
|
+
status: {}
|
19170
|
+
},
|
19171
|
+
temporaryRows: []
|
19172
|
+
});
|
19173
|
+
function getRowValue(rowId) {
|
19174
|
+
var _state$changes$rows$r, _state$changes$rows;
|
19175
|
+
return (_state$changes$rows$r = (_state$changes$rows = state.changes.rows) === null || _state$changes$rows === void 0 ? void 0 : _state$changes$rows[rowId]) !== null && _state$changes$rows$r !== void 0 ? _state$changes$rows$r : undefined;
|
18692
19176
|
}
|
18693
|
-
function
|
18694
|
-
var
|
18695
|
-
return (
|
19177
|
+
function getRowMoveReason(rowId) {
|
19178
|
+
var _Object$values$, _state$changes$moveRe, _state$changes$moveRe2;
|
19179
|
+
return (_Object$values$ = Object.values((_state$changes$moveRe = (_state$changes$moveRe2 = state.changes.moveReasons) === null || _state$changes$moveRe2 === void 0 ? void 0 : _state$changes$moveRe2[rowId]) !== null && _state$changes$moveRe !== void 0 ? _state$changes$moveRe : {})[0]) !== null && _Object$values$ !== void 0 ? _Object$values$ : undefined;
|
18696
19180
|
}
|
18697
|
-
const pendingChangesUpdater = usePendingChangesUpdater(handleChange, setPendingChanges);
|
18698
19181
|
function hasRowErrors(rowId) {
|
18699
|
-
var
|
18700
|
-
|
18701
|
-
return false;
|
18702
|
-
}
|
18703
|
-
return !!((_pendingChanges$rowId = pendingChanges[rowId]) !== null && _pendingChanges$rowId !== void 0 && (_pendingChanges$rowId2 = _pendingChanges$rowId._meta.errors) !== null && _pendingChanges$rowId2 !== void 0 && _pendingChanges$rowId2.row) || !!Object.keys((_pendingChanges$rowId3 = (_pendingChanges$rowId4 = pendingChanges[rowId]) === null || _pendingChanges$rowId4 === void 0 ? void 0 : (_pendingChanges$rowId5 = _pendingChanges$rowId4._meta.errors) === null || _pendingChanges$rowId5 === void 0 ? void 0 : _pendingChanges$rowId5.cells) !== null && _pendingChanges$rowId3 !== void 0 ? _pendingChanges$rowId3 : {}).length;
|
18704
|
-
}
|
18705
|
-
function hasRowErrorsSeen(rowId) {
|
18706
|
-
var _pendingChanges$rowId6;
|
18707
|
-
if (!isEnabled) {
|
18708
|
-
return false;
|
18709
|
-
}
|
18710
|
-
return hasRowErrors(rowId) && !!((_pendingChanges$rowId6 = pendingChanges[rowId]._meta.errors) !== null && _pendingChanges$rowId6 !== void 0 && _pendingChanges$rowId6.shouldShowErrorAlert);
|
19182
|
+
var _state$changes$errors, _state$changes$errors2, _state$changes$errors3;
|
19183
|
+
return !!((_state$changes$errors = state.changes.errors[rowId]) !== null && _state$changes$errors !== void 0 && _state$changes$errors.row) || !!Object.keys((_state$changes$errors2 = (_state$changes$errors3 = state.changes.errors[rowId]) === null || _state$changes$errors3 === void 0 ? void 0 : _state$changes$errors3.cells) !== null && _state$changes$errors2 !== void 0 ? _state$changes$errors2 : {}).length;
|
18711
19184
|
}
|
18712
|
-
function
|
18713
|
-
|
18714
|
-
|
18715
|
-
const {
|
18716
|
-
_meta,
|
18717
|
-
...pendingChange
|
18718
|
-
} = rowPendingChanges;
|
18719
|
-
return pendingChange;
|
18720
|
-
}
|
18721
|
-
return undefined;
|
19185
|
+
function hasRowErrorsShownInAlert(rowId) {
|
19186
|
+
var _state$changes$errors4;
|
19187
|
+
return hasRowErrors(rowId) && !!((_state$changes$errors4 = state.changes.errors[rowId]) !== null && _state$changes$errors4 !== void 0 && _state$changes$errors4.shouldShowErrorAlert);
|
18722
19188
|
}
|
18723
|
-
function
|
18724
|
-
|
19189
|
+
function hasTemporaryRowErrors() {
|
19190
|
+
var _state$temporaryRows, _state$changes$errors5, _state$changes$errors6, _state$changes$errors7;
|
19191
|
+
const newRow = (_state$temporaryRows = state.temporaryRows) === null || _state$temporaryRows === void 0 ? void 0 : _state$temporaryRows[0];
|
19192
|
+
if (!newRow) {
|
18725
19193
|
return false;
|
18726
19194
|
}
|
18727
|
-
|
19195
|
+
const rowId = newRow[rowIdentityAccessor];
|
19196
|
+
return !!((_state$changes$errors5 = state.changes.errors[rowId]) !== null && _state$changes$errors5 !== void 0 && _state$changes$errors5.row) || !!Object.keys((_state$changes$errors6 = (_state$changes$errors7 = state.changes.errors[rowId]) === null || _state$changes$errors7 === void 0 ? void 0 : _state$changes$errors7.cells) !== null && _state$changes$errors6 !== void 0 ? _state$changes$errors6 : {}).length;
|
18728
19197
|
}
|
18729
|
-
function
|
18730
|
-
|
18731
|
-
|
18732
|
-
|
18733
|
-
|
18734
|
-
|
18735
|
-
|
18736
|
-
|
18737
|
-
|
19198
|
+
function getRowStatus(rowId) {
|
19199
|
+
return state.changes.status[rowId];
|
19200
|
+
}
|
19201
|
+
function setRowStatus(rowId, status) {
|
19202
|
+
dispatch({
|
19203
|
+
type: 'setRowStatus',
|
19204
|
+
rowId,
|
19205
|
+
payload: {
|
19206
|
+
status
|
18738
19207
|
}
|
18739
|
-
return nextStates;
|
18740
19208
|
});
|
18741
19209
|
}
|
18742
|
-
function
|
18743
|
-
|
18744
|
-
|
18745
|
-
|
18746
|
-
|
18747
|
-
|
18748
|
-
|
19210
|
+
function insertTemporaryRow(data) {
|
19211
|
+
const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${uuid.v4()}`;
|
19212
|
+
const value = {
|
19213
|
+
...data,
|
19214
|
+
[rowIdentityAccessor]: newRowId
|
19215
|
+
};
|
19216
|
+
dispatch({
|
19217
|
+
type: 'insertTemporaryRow',
|
19218
|
+
rowId: newRowId,
|
19219
|
+
payload: {
|
19220
|
+
value
|
19221
|
+
}
|
19222
|
+
});
|
19223
|
+
return newRowId;
|
19224
|
+
}
|
19225
|
+
// cells
|
19226
|
+
function setCellValue(cell, value) {
|
19227
|
+
const rowId = cell.row.id;
|
19228
|
+
const columnId = cell.column.id;
|
19229
|
+
// update if the change is different to the original value
|
19230
|
+
if (value !== cell.row.original[columnId]) {
|
19231
|
+
dispatch({
|
19232
|
+
type: 'setCellValue',
|
19233
|
+
rowId,
|
19234
|
+
payload: {
|
19235
|
+
columnId,
|
19236
|
+
row: cell.row.original,
|
19237
|
+
value
|
19238
|
+
}
|
19239
|
+
});
|
18749
19240
|
}
|
18750
|
-
|
18751
|
-
|
18752
|
-
|
18753
|
-
|
18754
|
-
|
19241
|
+
// otherwise remove any previous change - no point saving the same value
|
19242
|
+
else if (cell.row.id in state.changes.rows) {
|
19243
|
+
dispatch({
|
19244
|
+
type: 'removeCellValue',
|
19245
|
+
rowId,
|
19246
|
+
payload: {
|
19247
|
+
columnId,
|
19248
|
+
rowIdentityAccessor
|
19249
|
+
}
|
19250
|
+
});
|
18755
19251
|
}
|
18756
|
-
return !!getAlertErrors().length;
|
18757
19252
|
}
|
18758
|
-
function
|
18759
|
-
|
19253
|
+
function getCellValue(cell) {
|
19254
|
+
var _state$changes$rows2, _state$changes$rows2$;
|
19255
|
+
return (_state$changes$rows2 = state.changes.rows) === null || _state$changes$rows2 === void 0 ? void 0 : (_state$changes$rows2$ = _state$changes$rows2[cell.row.id]) === null || _state$changes$rows2$ === void 0 ? void 0 : _state$changes$rows2$[cell.column.id];
|
19256
|
+
}
|
19257
|
+
function getCellError(cell) {
|
19258
|
+
var _state$changes$errors8, _state$changes$errors9, _state$changes$errors10;
|
19259
|
+
return (_state$changes$errors8 = state.changes.errors) === null || _state$changes$errors8 === void 0 ? void 0 : (_state$changes$errors9 = _state$changes$errors8[cell.row.id]) === null || _state$changes$errors9 === void 0 ? void 0 : (_state$changes$errors10 = _state$changes$errors9.cells) === null || _state$changes$errors10 === void 0 ? void 0 : _state$changes$errors10[cell.column.id];
|
19260
|
+
}
|
19261
|
+
function getErrorsShownInAlert() {
|
19262
|
+
const rowsWithErrors = Object.keys(state.changes.errors);
|
19263
|
+
if (!rowsWithErrors.length) {
|
19264
|
+
return [];
|
19265
|
+
}
|
19266
|
+
return rowsWithErrors.filter(hasRowErrorsShownInAlert).map(rowId => ({
|
18760
19267
|
rowId,
|
18761
|
-
|
19268
|
+
changes: state.changes.rows[rowId],
|
19269
|
+
errors: state.changes.errors[rowId]
|
18762
19270
|
}));
|
18763
19271
|
}
|
18764
|
-
function
|
18765
|
-
|
18766
|
-
|
18767
|
-
|
18768
|
-
|
18769
|
-
delete nextChanges[rowId];
|
18770
|
-
return nextChanges;
|
18771
|
-
});
|
19272
|
+
function hasSaved() {
|
19273
|
+
return !!Object.values(state.changes.status).filter(value => value === 'saved').length;
|
19274
|
+
}
|
19275
|
+
function hasChanges(rowId) {
|
19276
|
+
return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;
|
18772
19277
|
}
|
18773
|
-
function
|
18774
|
-
|
19278
|
+
function discardChanges(rowId, table) {
|
19279
|
+
// remove any new rows from pinned state before discarding them
|
19280
|
+
table.resetRowPinning(true);
|
19281
|
+
dispatch({
|
19282
|
+
type: 'removeRow',
|
19283
|
+
rowId,
|
19284
|
+
payload: {
|
19285
|
+
rowIdentityAccessor
|
19286
|
+
}
|
19287
|
+
});
|
18775
19288
|
}
|
18776
19289
|
return {
|
19290
|
+
// row
|
19291
|
+
setRowValue,
|
19292
|
+
getRowValue,
|
19293
|
+
getRowMoveReason,
|
19294
|
+
hasRowErrors,
|
19295
|
+
hasRowErrorsShownInAlert,
|
19296
|
+
hasTemporaryRowErrors,
|
19297
|
+
getRowStatus,
|
19298
|
+
setRowStatus,
|
19299
|
+
// cells
|
19300
|
+
setCellValue,
|
18777
19301
|
getCellValue,
|
18778
19302
|
getCellError,
|
18779
|
-
|
18780
|
-
|
18781
|
-
|
19303
|
+
onCellChanged,
|
19304
|
+
// general
|
19305
|
+
getErrorsShownInAlert,
|
18782
19306
|
hasChanges,
|
18783
|
-
hasAlertErrors,
|
18784
|
-
getAlertErrors,
|
18785
19307
|
saveChanges,
|
18786
|
-
|
18787
|
-
|
18788
|
-
|
18789
|
-
|
18790
|
-
|
18791
|
-
setRowSaveStatus,
|
18792
|
-
getRowMoveReason,
|
18793
|
-
getCompletedRowsCount
|
19308
|
+
discardChanges,
|
19309
|
+
hasSaved,
|
19310
|
+
// new rows
|
19311
|
+
insertTemporaryRow,
|
19312
|
+
temporaryRows: state.temporaryRows
|
18794
19313
|
};
|
18795
19314
|
}
|
18796
|
-
|
18797
|
-
|
18798
|
-
const
|
18799
|
-
const setLastFocusedCellIndex = React__default.useCallback(index => {
|
18800
|
-
lastFocusedCellIndexRef.current = index;
|
18801
|
-
}, []);
|
18802
|
-
return [lastFocusedCellIndexRef.current, setLastFocusedCellIndex];
|
18803
|
-
}
|
18804
|
-
function usePendingChangesUpdater(handleChange, setPendingChanges) {
|
18805
|
-
const localization = useLocalization();
|
18806
|
-
const updatersRef = React__default.useRef({});
|
18807
|
-
const runCellUpdates = React__default.useCallback(lodash.debounce(function (changes, cell, rowIndex) {
|
19315
|
+
|
19316
|
+
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, rowIdentityAccessor, validator) {
|
19317
|
+
const createRow = function (table, scrollToIndex, row) {
|
18808
19318
|
try {
|
18809
|
-
|
18810
|
-
|
18811
|
-
|
18812
|
-
|
18813
|
-
|
18814
|
-
|
18815
|
-
|
18816
|
-
|
18817
|
-
|
18818
|
-
|
18819
|
-
|
18820
|
-
|
18821
|
-
|
19319
|
+
let _exit = false;
|
19320
|
+
function _temp2(_result) {
|
19321
|
+
if (_exit) return _result;
|
19322
|
+
const changeset = row !== null && row !== void 0 ? row : handleCreate();
|
19323
|
+
try {
|
19324
|
+
if (changeset) {
|
19325
|
+
const newRowId = pendingChangesFns.insertTemporaryRow(changeset);
|
19326
|
+
// reset before changing row otherwise the cell changes and validation might run
|
19327
|
+
setLastFocusedCellIndex(undefined);
|
19328
|
+
// set the active row to the new row before toggling editing on
|
19329
|
+
const temporaryRows = tableMeta.editing.temporaryRows;
|
19330
|
+
const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
|
19331
|
+
tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
|
19332
|
+
// wait until set states have run
|
19333
|
+
requestAnimationFrame(() => {
|
19334
|
+
toggleEditing(true, table, scrollToIndex, false);
|
19335
|
+
setTimeout(() => {
|
19336
|
+
requestAnimationFrame(() => table.getRow(newRowId).pin('bottom'));
|
19337
|
+
}, 250);
|
19338
|
+
});
|
19339
|
+
}
|
19340
|
+
} catch (error) {
|
19341
|
+
console.error(error);
|
19342
|
+
}
|
19343
|
+
}
|
19344
|
+
if (!handleCreate) {
|
19345
|
+
return Promise.resolve();
|
19346
|
+
}
|
19347
|
+
const tableMeta = table.options.meta;
|
19348
|
+
const _temp = function () {
|
19349
|
+
if (tableMeta.rowActive.rowActiveIndex !== undefined) {
|
19350
|
+
var _table$getRowModel$ro2;
|
19351
|
+
return Promise.resolve(tableMeta.editing.saveChanges(table, (_table$getRowModel$ro2 = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex]) === null || _table$getRowModel$ro2 === void 0 ? void 0 : _table$getRowModel$ro2.id)).then(function (saved) {
|
19352
|
+
if (!saved) {
|
19353
|
+
_exit = true;
|
18822
19354
|
}
|
18823
19355
|
});
|
18824
19356
|
}
|
18825
19357
|
}();
|
18826
|
-
return Promise.resolve(
|
19358
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
18827
19359
|
} catch (e) {
|
18828
19360
|
return Promise.reject(e);
|
18829
19361
|
}
|
18830
|
-
}, 250), []);
|
18831
|
-
function syncCellChanges(changes) {
|
18832
|
-
updatersRef.current = changes;
|
18833
|
-
}
|
18834
|
-
return {
|
18835
|
-
syncCellChanges,
|
18836
|
-
runCellUpdates
|
18837
|
-
};
|
18838
|
-
}
|
18839
|
-
function createPendingChangesSetter(currentChanges, row, rowIndex, changes, localization) {
|
18840
|
-
var _currentChanges$row$i, _currentChanges$row$i2, _currentChanges$row$i3;
|
18841
|
-
// prepare
|
18842
|
-
const nextChanges = {
|
18843
|
-
...currentChanges
|
18844
|
-
};
|
18845
|
-
const rowChanges = {
|
18846
|
-
...currentChanges[row.id],
|
18847
|
-
_meta: {
|
18848
|
-
...((_currentChanges$row$i = currentChanges[row.id]) === null || _currentChanges$row$i === void 0 ? void 0 : _currentChanges$row$i._meta),
|
18849
|
-
original: row.original,
|
18850
|
-
moveReason: {
|
18851
|
-
...((_currentChanges$row$i2 = currentChanges[row.id]) === null || _currentChanges$row$i2 === void 0 ? void 0 : _currentChanges$row$i2._meta.moveReason)
|
18852
|
-
},
|
18853
|
-
errors: {
|
18854
|
-
...((_currentChanges$row$i3 = currentChanges[row.id]) === null || _currentChanges$row$i3 === void 0 ? void 0 : _currentChanges$row$i3._meta.errors)
|
18855
|
-
}
|
18856
|
-
}
|
18857
19362
|
};
|
18858
|
-
//
|
18859
|
-
const
|
18860
|
-
|
18861
|
-
|
18862
|
-
|
18863
|
-
|
18864
|
-
|
18865
|
-
|
18866
|
-
|
18867
|
-
|
18868
|
-
|
18869
|
-
|
18870
|
-
|
18871
|
-
|
18872
|
-
|
18873
|
-
|
18874
|
-
}
|
19363
|
+
// used to switch the table into editing mode
|
19364
|
+
const [isEditing, setEditing] = React__default.useState(false);
|
19365
|
+
// used to switch the editing between "detailed" mode
|
19366
|
+
const [isDetailedMode, toggleDetailedMode] = React__default.useState(false);
|
19367
|
+
// used to contain ref to the create button
|
19368
|
+
const createRowButtonRef = React__default.useRef(null);
|
19369
|
+
// store the last focused cell, so that up/down arrow key navigation remains in the same column
|
19370
|
+
const [lastFocusedCellIndex, setLastFocusedCellIndex] = React__default.useState(undefined);
|
19371
|
+
const pendingChangesFns = usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, validator);
|
19372
|
+
function toggleEditing(enabled, table, scrollToIndex, doSave = true) {
|
19373
|
+
const tableMeta = table.options.meta;
|
19374
|
+
if (enabled) {
|
19375
|
+
var _tableMeta$rowActive$, _table$getRowModel$ro;
|
19376
|
+
const index = (_tableMeta$rowActive$ = tableMeta.rowActive.rowActiveIndex) !== null && _tableMeta$rowActive$ !== void 0 ? _tableMeta$rowActive$ : 0;
|
19377
|
+
if (tableMeta.rowActive.rowActiveIndex === undefined) {
|
19378
|
+
tableMeta.rowActive.setRowActiveIndex(index);
|
18875
19379
|
}
|
18876
|
-
|
18877
|
-
|
18878
|
-
|
19380
|
+
if (!isTemporaryRow((_table$getRowModel$ro = table.getRowModel().rows[index]) === null || _table$getRowModel$ro === void 0 ? void 0 : _table$getRowModel$ro.id)) {
|
19381
|
+
scrollToIndex(index);
|
19382
|
+
}
|
19383
|
+
} else if (!enabled) {
|
19384
|
+
// reset detailed mode
|
19385
|
+
toggleDetailedMode(false);
|
19386
|
+
// reset the last index back to the first focusable element, when editing gets turned off
|
19387
|
+
setLastFocusedCellIndex(undefined);
|
19388
|
+
}
|
19389
|
+
setEditing(enabled);
|
19390
|
+
if (doSave) {
|
19391
|
+
pendingChangesFns.saveChanges(table);
|
18879
19392
|
}
|
18880
19393
|
}
|
18881
|
-
// set changes
|
18882
|
-
// or delete if there are no changes left, so that we don't store changes with unchanged data
|
18883
|
-
if (Object.keys(rowChanges).filter(k => k !== '_meta').length) {
|
18884
|
-
nextChanges[row.id] = rowChanges;
|
18885
|
-
} else {
|
18886
|
-
delete nextChanges[row.id];
|
18887
|
-
}
|
18888
|
-
return nextChanges;
|
18889
|
-
}
|
18890
|
-
function getChangesetFromChanges(changes) {
|
18891
|
-
// extract the original data from the row changes
|
18892
|
-
const {
|
18893
|
-
_meta,
|
18894
|
-
...changeset
|
18895
|
-
} = changes !== null && changes !== void 0 ? changes : {};
|
18896
|
-
// and mix them in with the changes, ready to send to the server
|
18897
19394
|
return {
|
18898
|
-
|
18899
|
-
|
19395
|
+
isEnabled,
|
19396
|
+
isEditing,
|
19397
|
+
isDetailedMode,
|
19398
|
+
toggleDetailedMode: isEnabled ? toggleDetailedMode : () => undefined,
|
19399
|
+
toggleEditing: isEnabled ? toggleEditing : () => undefined,
|
19400
|
+
lastFocusedCellIndex,
|
19401
|
+
setLastFocusedCellIndex,
|
19402
|
+
createRow,
|
19403
|
+
createRowButtonRef,
|
19404
|
+
...pendingChangesFns
|
18900
19405
|
};
|
18901
19406
|
}
|
18902
19407
|
|
@@ -18940,7 +19445,6 @@ function RowMoveIndicator(props) {
|
|
18940
19445
|
if (!show) {
|
18941
19446
|
return null;
|
18942
19447
|
}
|
18943
|
-
const className = 'wcag-blue-500 absolute left-0 top-full ml-1 whitespace-nowrap rounded-b-md px-1 py-1 text-xs font-bold z-10';
|
18944
19448
|
const {
|
18945
19449
|
title,
|
18946
19450
|
description
|
@@ -18949,7 +19453,7 @@ function RowMoveIndicator(props) {
|
|
18949
19453
|
placement: "bottom",
|
18950
19454
|
title: description.replace('[COLUMN]', columnMeta.header)
|
18951
19455
|
}, /*#__PURE__*/React__default.createElement("span", {
|
18952
|
-
|
19456
|
+
"data-row-move-indicator": true
|
18953
19457
|
}, /*#__PURE__*/React__default.createElement(Icon, {
|
18954
19458
|
name: "info",
|
18955
19459
|
className: "-mt-0.5 mr-1 !h-4 !w-4 rounded-full bg-white !p-0 text-blue-500"
|
@@ -19138,20 +19642,44 @@ function EditingControlCell(props) {
|
|
19138
19642
|
const {
|
19139
19643
|
rowIndex
|
19140
19644
|
} = React__default.useContext(RowContext);
|
19141
|
-
const
|
19645
|
+
const {
|
19646
|
+
table
|
19647
|
+
} = cell.getContext();
|
19648
|
+
const tableMeta = table.options.meta;
|
19142
19649
|
const columnMeta = cell.column.columnDef.meta;
|
19143
19650
|
const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
|
19651
|
+
const type = (_columnMeta$control = columnMeta.control) !== null && _columnMeta$control !== void 0 ? _columnMeta$control : 'input';
|
19144
19652
|
const handleFocus = useEditingCellAutofocus(props);
|
19145
|
-
const
|
19653
|
+
const value = cell.getValue();
|
19654
|
+
// some controls, like select2, should trigger cell changed (validation, updates) as the value changes
|
19655
|
+
const hasNonTextControl = React__default.useMemo(() => {
|
19656
|
+
var _cellRef$current;
|
19657
|
+
return typeof type === 'function' && !!((_cellRef$current = cellRef.current) !== null && _cellRef$current !== void 0 && _cellRef$current.querySelector('[data-taco="Select2"],[data-taco="switch"],[data-taco="checkbox"]'));
|
19658
|
+
}, [cellRef.current]);
|
19659
|
+
const handleChange = React__default.useCallback(nextValue => {
|
19660
|
+
if (nextValue !== value) {
|
19661
|
+
tableMeta.editing.setCellValue(cell, nextValue);
|
19662
|
+
if (hasNonTextControl) {
|
19663
|
+
requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
|
19664
|
+
}
|
19665
|
+
}
|
19666
|
+
}, [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex, value]);
|
19667
|
+
const blur = React__default.useCallback(function blur() {
|
19146
19668
|
tableMeta.editing.toggleDetailedMode(false);
|
19147
|
-
tableMeta.editing.
|
19148
|
-
};
|
19669
|
+
tableMeta.editing.onCellChanged(cell, rowIndex, undefined, !hasNonTextControl);
|
19670
|
+
}, [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex]);
|
19671
|
+
const handleBlur = React__default.useCallback(event => {
|
19672
|
+
if (isElementInsideOrTriggeredFromContainer(event.relatedTarget, event.currentTarget)) {
|
19673
|
+
return;
|
19674
|
+
}
|
19675
|
+
blur();
|
19676
|
+
}, [blur]);
|
19149
19677
|
// ensure that blur runs when the cell gets unmounted (when vertically arrow key navigating)
|
19150
19678
|
React__default.useEffect(() => {
|
19151
19679
|
const ref = cellRef.current;
|
19152
19680
|
return () => {
|
19153
19681
|
if (document.activeElement === ref || isElementInsideOrTriggeredFromContainer(document.activeElement, ref)) {
|
19154
|
-
|
19682
|
+
blur();
|
19155
19683
|
}
|
19156
19684
|
};
|
19157
19685
|
}, []);
|
@@ -19164,14 +19692,13 @@ function EditingControlCell(props) {
|
|
19164
19692
|
isDetailedMode: tableMeta.editing.isDetailedMode,
|
19165
19693
|
isTruncated: !!columnMeta.enableTruncate,
|
19166
19694
|
onBlur: handleBlur,
|
19167
|
-
onChange:
|
19695
|
+
onChange: handleChange,
|
19168
19696
|
row: cell.row.original,
|
19169
|
-
rowPendingChanges: tableMeta.editing.
|
19697
|
+
rowPendingChanges: tableMeta.editing.getRowValue(cell.row.id),
|
19170
19698
|
tabIndex: isActiveRow ? 0 : -1,
|
19171
|
-
toggleEditing: tableMeta.editing.toggleEditing,
|
19172
19699
|
toggleDetailedMode: tableMeta.editing.toggleDetailedMode,
|
19173
|
-
type
|
19174
|
-
value
|
19700
|
+
type,
|
19701
|
+
value
|
19175
19702
|
};
|
19176
19703
|
const cellAttributes = {
|
19177
19704
|
...getCellAttributes(cell, index, isHighlighted),
|
@@ -19203,7 +19730,6 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19203
19730
|
row,
|
19204
19731
|
rowPendingChanges,
|
19205
19732
|
tabIndex = -1,
|
19206
|
-
toggleEditing,
|
19207
19733
|
toggleDetailedMode,
|
19208
19734
|
type = 'input',
|
19209
19735
|
value
|
@@ -19234,6 +19760,13 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19234
19760
|
ref: controlRef
|
19235
19761
|
}));
|
19236
19762
|
}
|
19763
|
+
if (type === 'checkbox') {
|
19764
|
+
return /*#__PURE__*/React__default.createElement(Checkbox, Object.assign({}, commonProps, {
|
19765
|
+
checked: Boolean(value),
|
19766
|
+
onChange: onChange,
|
19767
|
+
ref: controlRef
|
19768
|
+
}));
|
19769
|
+
}
|
19237
19770
|
const handleInputKeyDown = event => {
|
19238
19771
|
const target = event.target;
|
19239
19772
|
if (target.readOnly) {
|
@@ -19262,8 +19795,8 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19262
19795
|
}
|
19263
19796
|
// reset the value, or exit edit mode when pressing escape
|
19264
19797
|
if (event.key === 'Escape') {
|
19265
|
-
event.preventDefault();
|
19266
19798
|
if (isDetailedMode) {
|
19799
|
+
event.preventDefault();
|
19267
19800
|
toggleDetailedMode(false);
|
19268
19801
|
if (value !== currentValue) {
|
19269
19802
|
props.onChange(currentValue);
|
@@ -19273,8 +19806,6 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19273
19806
|
var _target$select2;
|
19274
19807
|
return (_target$select2 = target.select) === null || _target$select2 === void 0 ? void 0 : _target$select2.call(target);
|
19275
19808
|
});
|
19276
|
-
} else {
|
19277
|
-
toggleEditing(false);
|
19278
19809
|
}
|
19279
19810
|
return;
|
19280
19811
|
}
|
@@ -19373,12 +19904,37 @@ function Cell$5(props) {
|
|
19373
19904
|
return /*#__PURE__*/React__default.createElement(DisplayCell, Object.assign({}, props));
|
19374
19905
|
}
|
19375
19906
|
|
19376
|
-
function
|
19907
|
+
function DiscardChangesConfirmationDialog(props) {
|
19908
|
+
const {
|
19909
|
+
onDiscard: handleDiscard,
|
19910
|
+
...dialogProps
|
19911
|
+
} = props;
|
19912
|
+
const {
|
19913
|
+
texts
|
19914
|
+
} = useLocalization();
|
19915
|
+
const handleClickInsideDialogContent = event => {
|
19916
|
+
// Prevents the click event from propagating to the table, ensuring the row isn't saved when a click occurs
|
19917
|
+
// inside the dialog
|
19918
|
+
event.stopPropagation();
|
19919
|
+
};
|
19920
|
+
return /*#__PURE__*/React__default.createElement(Dialog, Object.assign({}, dialogProps), /*#__PURE__*/React__default.createElement(Dialog.Content, {
|
19921
|
+
"aria-label": texts.table3.editing.clearChangesConfirmationDialog.title,
|
19922
|
+
onClick: handleClickInsideDialogContent
|
19923
|
+
}, /*#__PURE__*/React__default.createElement(Dialog.Title, null, texts.table3.editing.clearChangesConfirmationDialog.title), /*#__PURE__*/React__default.createElement("p", null, texts.table3.editing.clearChangesConfirmationDialog.description), /*#__PURE__*/React__default.createElement(Dialog.Footer, null, /*#__PURE__*/React__default.createElement(Group, null, /*#__PURE__*/React__default.createElement(Dialog.Close, null, /*#__PURE__*/React__default.createElement(Button$1, {
|
19924
|
+
tabIndex: 0
|
19925
|
+
}, texts.table3.editing.clearChangesConfirmationDialog.cancel)), /*#__PURE__*/React__default.createElement(Dialog.Close, null, /*#__PURE__*/React__default.createElement(Button$1, {
|
19926
|
+
autoFocus: true,
|
19927
|
+
tabIndex: 0,
|
19928
|
+
appearance: "primary",
|
19929
|
+
onClick: handleDiscard
|
19930
|
+
}, texts.table3.editing.clearChangesConfirmationDialog.confirm))))));
|
19931
|
+
}
|
19932
|
+
|
19933
|
+
function EditingActionsMenu(props) {
|
19377
19934
|
const {
|
19378
19935
|
hasChanges,
|
19379
19936
|
hasErrors,
|
19380
|
-
|
19381
|
-
onExit: handleExit,
|
19937
|
+
onDiscard: handleDiscard,
|
19382
19938
|
onEditingSave: handleSave,
|
19383
19939
|
isLastRow
|
19384
19940
|
} = props;
|
@@ -19400,7 +19956,6 @@ function EditingActionMenu(props) {
|
|
19400
19956
|
return /*#__PURE__*/React__default.createElement(IconButton, {
|
19401
19957
|
appearance: "transparent",
|
19402
19958
|
"aria-label": texts.table3.editing.actions.tooltip,
|
19403
|
-
className: "group-[[data-row-editing-status]]/row:hidden",
|
19404
19959
|
icon: "more",
|
19405
19960
|
onKeyDown: handleKeyDown,
|
19406
19961
|
menu: menuProps => (/*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content, {
|
@@ -19412,42 +19967,13 @@ function EditingActionMenu(props) {
|
|
19412
19967
|
}, texts.table3.editing.actions.save), /*#__PURE__*/React__default.createElement(Menu$1.Item, {
|
19413
19968
|
icon: "close",
|
19414
19969
|
disabled: !hasChanges,
|
19415
|
-
dialog: props => /*#__PURE__*/React__default.createElement(
|
19416
|
-
|
19970
|
+
dialog: props => /*#__PURE__*/React__default.createElement(DiscardChangesConfirmationDialog, Object.assign({}, props, {
|
19971
|
+
onDiscard: handleDiscard
|
19417
19972
|
}))
|
19418
|
-
}, texts.table3.editing.actions.clear)
|
19419
|
-
icon: "undo",
|
19420
|
-
onClick: handleExit
|
19421
|
-
}, texts.table3.editing.actions.exit))))
|
19973
|
+
}, texts.table3.editing.actions.clear))))
|
19422
19974
|
});
|
19423
19975
|
}
|
19424
|
-
function ConfirmClearChangesDialog(props) {
|
19425
|
-
const {
|
19426
|
-
onClear: handleClear,
|
19427
|
-
...dialogProps
|
19428
|
-
} = props;
|
19429
|
-
const {
|
19430
|
-
texts
|
19431
|
-
} = useLocalization();
|
19432
|
-
const handleClickInsideDialogContent = event => {
|
19433
|
-
// Prevents the click event from propagating to the table, ensuring the row isn't saved when a click occurs
|
19434
|
-
// inside the dialog
|
19435
|
-
event.stopPropagation();
|
19436
|
-
};
|
19437
|
-
return /*#__PURE__*/React__default.createElement(Dialog, Object.assign({}, dialogProps), /*#__PURE__*/React__default.createElement(Dialog.Content, {
|
19438
|
-
"aria-label": texts.table3.editing.clearChangesConfirmationDialog.title,
|
19439
|
-
onClick: handleClickInsideDialogContent
|
19440
|
-
}, /*#__PURE__*/React__default.createElement(Dialog.Title, null, texts.table3.editing.clearChangesConfirmationDialog.title), /*#__PURE__*/React__default.createElement("p", null, texts.table3.editing.clearChangesConfirmationDialog.description), /*#__PURE__*/React__default.createElement(Dialog.Footer, null, /*#__PURE__*/React__default.createElement(Group, null, /*#__PURE__*/React__default.createElement(Dialog.Close, null, /*#__PURE__*/React__default.createElement(Button$1, {
|
19441
|
-
tabIndex: 0
|
19442
|
-
}, texts.table3.editing.clearChangesConfirmationDialog.cancel)), /*#__PURE__*/React__default.createElement(Dialog.Close, null, /*#__PURE__*/React__default.createElement(Button$1, {
|
19443
|
-
autoFocus: true,
|
19444
|
-
tabIndex: 0,
|
19445
|
-
appearance: "primary",
|
19446
|
-
onClick: handleClear
|
19447
|
-
}, texts.table3.editing.clearChangesConfirmationDialog.confirm))))));
|
19448
|
-
}
|
19449
19976
|
|
19450
|
-
const COMPLETE_INDICATOR_DELAY = 3000;
|
19451
19977
|
function SaveStatus(props) {
|
19452
19978
|
const {
|
19453
19979
|
rowId,
|
@@ -19457,18 +19983,7 @@ function SaveStatus(props) {
|
|
19457
19983
|
texts
|
19458
19984
|
} = useLocalization();
|
19459
19985
|
const tableMeta = table.options.meta;
|
19460
|
-
const status = tableMeta.editing.
|
19461
|
-
React__default.useEffect(() => {
|
19462
|
-
let timeout;
|
19463
|
-
if (status === 'complete') {
|
19464
|
-
timeout = window.setTimeout(() => {
|
19465
|
-
tableMeta.editing.setRowSaveStatus(rowId, undefined);
|
19466
|
-
}, COMPLETE_INDICATOR_DELAY);
|
19467
|
-
}
|
19468
|
-
return () => {
|
19469
|
-
clearTimeout(timeout);
|
19470
|
-
};
|
19471
|
-
}, [status]);
|
19986
|
+
const status = tableMeta.editing.getRowStatus(rowId);
|
19472
19987
|
const className = cn('col-span-full sticky ml-auto right-0 top-0 -mb-[100%] z-10 h-8 bg-[inherit] flex items-center px-1.5 shadow-[-6px_0px_6px_var(--table-row-actions-shadow)]', {
|
19473
19988
|
'mt-0.5': tableMeta.rowHeight.height === 'short',
|
19474
19989
|
'mt-1': tableMeta.rowHeight.height === 'medium',
|
@@ -19479,7 +19994,7 @@ function SaveStatus(props) {
|
|
19479
19994
|
className: "!contents"
|
19480
19995
|
}, /*#__PURE__*/React__default.createElement("span", {
|
19481
19996
|
className: className
|
19482
|
-
}, status === '
|
19997
|
+
}, status === 'saving' ? (/*#__PURE__*/React__default.createElement(Tooltip, {
|
19483
19998
|
title: texts.table3.editing.saving.progress
|
19484
19999
|
}, /*#__PURE__*/React__default.createElement(Spinner, {
|
19485
20000
|
delay: 0,
|
@@ -19520,15 +20035,46 @@ function Row$2(props) {
|
|
19520
20035
|
}
|
19521
20036
|
}
|
19522
20037
|
}, [tableMeta.editing.isEditing, isActiveRow]);
|
20038
|
+
const rowStatus = tableMeta.editing.getRowStatus(row.id);
|
20039
|
+
// discard new row
|
20040
|
+
const [showDiscardDialog, setShowDiscardDialog] = React__default.useState(false);
|
20041
|
+
function handleDiscard() {
|
20042
|
+
tableMeta.editing.discardChanges(row.id, table);
|
20043
|
+
requestAnimationFrame(() => {
|
20044
|
+
if (isTemporaryRow(row.id)) {
|
20045
|
+
var _tableMeta$editing$cr;
|
20046
|
+
(_tableMeta$editing$cr = tableMeta.editing.createRowButtonRef.current) === null || _tableMeta$editing$cr === void 0 ? void 0 : _tableMeta$editing$cr.focus();
|
20047
|
+
} else {
|
20048
|
+
focusManager.focusFirst();
|
20049
|
+
}
|
20050
|
+
});
|
20051
|
+
}
|
20052
|
+
function handleKeyDown(event) {
|
20053
|
+
if (props.onKeyDown) {
|
20054
|
+
props.onKeyDown(event);
|
20055
|
+
}
|
20056
|
+
if (event.isDefaultPrevented() || event.isPropagationStopped()) {
|
20057
|
+
return;
|
20058
|
+
}
|
20059
|
+
if (event.key === 'Escape' && tableMeta.editing.hasChanges(row.id) && !isElementTriggeredFromContainer(event.target, event.currentTarget)) {
|
20060
|
+
event.preventDefault();
|
20061
|
+
setShowDiscardDialog(true);
|
20062
|
+
}
|
20063
|
+
}
|
19523
20064
|
const attributes = {
|
19524
|
-
'data-row-editing-invalid': tableMeta.editing.
|
19525
|
-
'data-row-editing-status':
|
19526
|
-
onFocus: handleFocus
|
20065
|
+
'data-row-editing-invalid': tableMeta.editing.hasRowErrors(row.id) ? !tableMeta.editing.hasRowErrorsShownInAlert(row.id) ? 'unseen' : true : undefined,
|
20066
|
+
'data-row-editing-status': rowStatus,
|
20067
|
+
onFocus: handleFocus,
|
20068
|
+
onKeyDown: handleKeyDown
|
19527
20069
|
};
|
19528
|
-
return /*#__PURE__*/React__default.createElement(DisplayRow, Object.assign({}, props, attributes),
|
20070
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(DisplayRow, Object.assign({}, props, attributes), rowStatus === 'saving' || rowStatus === 'saved' ? /*#__PURE__*/React__default.createElement(SaveStatus, {
|
19529
20071
|
rowId: row.id,
|
19530
20072
|
table: table
|
19531
|
-
}) : null)
|
20073
|
+
}) : null), /*#__PURE__*/React__default.createElement(DiscardChangesConfirmationDialog, {
|
20074
|
+
open: showDiscardDialog,
|
20075
|
+
onChange: setShowDiscardDialog,
|
20076
|
+
onDiscard: handleDiscard
|
20077
|
+
}));
|
19532
20078
|
}
|
19533
20079
|
|
19534
20080
|
const RENDERERS$1 = {
|
@@ -19536,29 +20082,61 @@ const RENDERERS$1 = {
|
|
19536
20082
|
cell: Cell$5
|
19537
20083
|
};
|
19538
20084
|
function useTable3(props, ref) {
|
19539
|
-
const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.validator);
|
20085
|
+
const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.onEditingCreate, props.rowIdentityAccessor, props.validator);
|
19540
20086
|
const creationEnabled = editing.isEnabled && !!props.onEditingCreate;
|
20087
|
+
// this gives me the performance heeby jeebies, but can't think of a better way to internalise the state
|
20088
|
+
const data = React__default.useMemo(() => {
|
20089
|
+
if (editing.temporaryRows.length) {
|
20090
|
+
var _props$data;
|
20091
|
+
return ((_props$data = props.data) !== null && _props$data !== void 0 ? _props$data : []).concat(editing.temporaryRows);
|
20092
|
+
}
|
20093
|
+
return props.data;
|
20094
|
+
}, [JSON.stringify(props.data), editing.temporaryRows.length]);
|
19541
20095
|
const extendedProps = {
|
19542
20096
|
...props,
|
20097
|
+
data,
|
19543
20098
|
enableRowActions: editing.isEditing ? true : props.enableRowActions,
|
19544
|
-
|
19545
|
-
|
19546
|
-
|
19547
|
-
|
19548
|
-
|
19549
|
-
|
19550
|
-
|
19551
|
-
|
20099
|
+
// Display EditingActionMenu instead of row actions while editing
|
20100
|
+
rowActions: editing.isEditing ? [(_, rowId, table) => {
|
20101
|
+
const tableMeta = table.options.meta;
|
20102
|
+
return /*#__PURE__*/React__default.createElement(EditingActionsMenu, {
|
20103
|
+
hasChanges: editing.hasChanges(rowId),
|
20104
|
+
hasErrors: editing.hasRowErrors(rowId),
|
20105
|
+
onDiscard: () => {
|
20106
|
+
editing.discardChanges(rowId, table);
|
20107
|
+
if (editing.temporaryRows.length) {
|
20108
|
+
requestAnimationFrame(() => {
|
20109
|
+
var _editing$createRowBut;
|
20110
|
+
return (_editing$createRowBut = editing.createRowButtonRef.current) === null || _editing$createRowBut === void 0 ? void 0 : _editing$createRowBut.focus();
|
20111
|
+
});
|
20112
|
+
}
|
20113
|
+
},
|
20114
|
+
onEditingSave: function () {
|
20115
|
+
try {
|
20116
|
+
return Promise.resolve(editing.saveChanges(table, rowId)).then(function () {});
|
20117
|
+
} catch (e) {
|
20118
|
+
return Promise.reject(e);
|
20119
|
+
}
|
20120
|
+
},
|
20121
|
+
isLastRow: !creationEnabled && tableMeta.rowActive.rowActiveIndex === tableMeta.length - 1
|
20122
|
+
});
|
20123
|
+
}] : props.rowActions
|
19552
20124
|
};
|
19553
20125
|
const meta = {
|
19554
20126
|
editing
|
19555
20127
|
};
|
19556
|
-
const
|
20128
|
+
const options = {
|
20129
|
+
virtualiserPaddingEndOffset: props.enableEditing && props.onEditingCreate ? editing.hasTemporaryRowErrors() ? 1.4 : 1 : 0
|
20130
|
+
};
|
20131
|
+
const table = useTable(extendedProps, ref, RENDERERS$1, meta, options);
|
19557
20132
|
// listeners
|
19558
|
-
useTableEditingListener(table.instance, table.ref);
|
20133
|
+
useTableEditingListener(table.instance, table.ref, table.renderer.scrollToIndex);
|
19559
20134
|
React__default.useEffect(() => {
|
19560
20135
|
if (table.ref.current) {
|
19561
|
-
table.ref.current.instance.toggleEditing = enabled => table.meta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing);
|
20136
|
+
table.ref.current.instance.toggleEditing = enabled => table.meta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing, table.instance, table.renderer.scrollToIndex);
|
20137
|
+
if (props.onEditingCreate) {
|
20138
|
+
table.ref.current.instance.createRow = row => table.meta.editing.createRow(table.instance, table.renderer.scrollToIndex, row);
|
20139
|
+
}
|
19562
20140
|
}
|
19563
20141
|
}, [table.ref.current]);
|
19564
20142
|
return table;
|
@@ -19577,7 +20155,7 @@ function Alert$1(props) {
|
|
19577
20155
|
const validationTexts = texts.table3.editing.validation;
|
19578
20156
|
const tableMeta = table.options.meta;
|
19579
20157
|
const [showFilterResetDialog, setShowFilterResetDialog] = React__default.useState(false);
|
19580
|
-
const pendingChangesWithErrors = tableMeta.editing.
|
20158
|
+
const pendingChangesWithErrors = tableMeta.editing.getErrorsShownInAlert();
|
19581
20159
|
function scrollToRow(rowIndex) {
|
19582
20160
|
tableMeta.rowActive.setRowActiveIndex(rowIndex);
|
19583
20161
|
scrollToIndex(rowIndex, {
|
@@ -19596,38 +20174,45 @@ function Alert$1(props) {
|
|
19596
20174
|
const title = (pendingChangesWithErrors.length === 1 ? validationTexts.alert.titleOne : validationTexts.alert.titlePlural).replace('[COUNT]', String(pendingChangesWithErrors.length));
|
19597
20175
|
// generate links to each invalid row, to go into the error message
|
19598
20176
|
const links = [];
|
19599
|
-
const
|
19600
|
-
|
20177
|
+
const visibleColumns = table.getVisibleFlatColumns().map(c => c.id);
|
20178
|
+
const rowIdentityColumn = tableMeta.rowIdentityAccessor && visibleColumns.includes(String(tableMeta.rowIdentityAccessor)) ?
|
20179
|
+
// table.getColumn(columName) throw error in strict dev mode. Related thread: https://github.com/TanStack/table/discussions/5505
|
20180
|
+
table.getAllColumns().find(x => x.id === String(tableMeta.rowIdentityAccessor)) : undefined;
|
20181
|
+
pendingChangesWithErrors.forEach((pendingChangeWithError, index) => {
|
19601
20182
|
// if appropriate, concatenate the item with the text "and"
|
19602
20183
|
if (pendingChangesWithErrors.length > 1 && index === pendingChangesWithErrors.length - 1) {
|
19603
20184
|
// Add space before and after `messageAnd` text
|
19604
20185
|
links.push(` ${validationTexts.alert.messageAnd} `);
|
19605
20186
|
}
|
19606
|
-
const rowIndex = table.getRowModel().rows.findIndex(row => row.id ===
|
20187
|
+
const rowIndex = table.getRowModel().rows.findIndex(row => row.id === pendingChangeWithError.rowId);
|
19607
20188
|
const handleClick = () => {
|
20189
|
+
// if row is visible
|
19608
20190
|
if (rowIndex > -1) {
|
19609
20191
|
scrollToRow(rowIndex);
|
19610
|
-
}
|
19611
|
-
|
20192
|
+
}
|
20193
|
+
// if row is filtered out
|
20194
|
+
else {
|
20195
|
+
setShowFilterResetDialog(pendingChangeWithError.rowId);
|
19612
20196
|
}
|
19613
20197
|
};
|
19614
20198
|
let tooltip;
|
19615
|
-
if (
|
19616
|
-
tooltip =
|
20199
|
+
if (pendingChangeWithError.errors.row) {
|
20200
|
+
tooltip = pendingChangeWithError.errors.row;
|
19617
20201
|
} else {
|
19618
20202
|
var _table$getAllColumns$, _table$getAllColumns$2;
|
19619
|
-
const firstCellErrorColumnId = Object.keys(
|
20203
|
+
const firstCellErrorColumnId = Object.keys(pendingChangeWithError.errors.cells)[0];
|
19620
20204
|
const columnName = (_table$getAllColumns$ = table.getAllColumns().find(column => column.id === firstCellErrorColumnId)) === null || _table$getAllColumns$ === void 0 ? void 0 : (_table$getAllColumns$2 = _table$getAllColumns$.columnDef.meta) === null || _table$getAllColumns$2 === void 0 ? void 0 : _table$getAllColumns$2.header;
|
19621
|
-
tooltip = `${columnName}: ${
|
20205
|
+
tooltip = `${columnName}: ${pendingChangeWithError.errors.cells[firstCellErrorColumnId]}`;
|
19622
20206
|
}
|
20207
|
+
const row = table.getRow(pendingChangeWithError.rowId).original;
|
19623
20208
|
links.push(/*#__PURE__*/React__default.createElement(Tooltip, {
|
19624
|
-
key:
|
20209
|
+
key: pendingChangeWithError.rowId,
|
19625
20210
|
title: tooltip
|
19626
20211
|
}, /*#__PURE__*/React__default.createElement("span", {
|
19627
20212
|
className: "text-blue",
|
19628
20213
|
onClick: handleClick,
|
19629
20214
|
role: "button"
|
19630
|
-
}, rowIdentityColumn ?
|
20215
|
+
}, rowIdentityColumn ? row[rowIdentityColumn.id] : rowIndex + 1)));
|
19631
20216
|
// if appropriate, concatenate the item with the text ","
|
19632
20217
|
if (pendingChangesWithErrors.length > 2 && index < pendingChangesWithErrors.length - 2) {
|
19633
20218
|
links.push(', ');
|
@@ -19683,9 +20268,38 @@ function FilterResetDialog(props) {
|
|
19683
20268
|
}, texts.table3.editing.validation.resetFiltersDialog.confirm)))));
|
19684
20269
|
}
|
19685
20270
|
|
19686
|
-
function
|
20271
|
+
function Editing(props) {
|
19687
20272
|
const {
|
19688
|
-
|
20273
|
+
scrollToIndex,
|
20274
|
+
table
|
20275
|
+
} = props;
|
20276
|
+
const {
|
20277
|
+
texts
|
20278
|
+
} = useLocalization();
|
20279
|
+
const ref = React__default.useRef(null);
|
20280
|
+
const tableMeta = table.options.meta;
|
20281
|
+
const handleChange = enabled => {
|
20282
|
+
tableMeta.editing.toggleEditing(enabled, table, scrollToIndex);
|
20283
|
+
};
|
20284
|
+
const tooltip = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, texts.table3.editing.buttons.edit.tooltip, /*#__PURE__*/React__default.createElement(Shortcut, {
|
20285
|
+
className: "ml-2",
|
20286
|
+
keys: shortcut
|
20287
|
+
}));
|
20288
|
+
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
20289
|
+
title: tooltip
|
20290
|
+
}, /*#__PURE__*/React__default.createElement(ModeSwitch, {
|
20291
|
+
"data-table": "editing-toggle",
|
20292
|
+
checked: tableMeta.editing.isEditing,
|
20293
|
+
onChange: handleChange,
|
20294
|
+
ref: ref
|
20295
|
+
}));
|
20296
|
+
}
|
20297
|
+
|
20298
|
+
function CreateNewRow(props) {
|
20299
|
+
var _temporaryRows$0$tabl, _temporaryRows$, _table$getState$colum;
|
20300
|
+
const {
|
20301
|
+
buttonRef,
|
20302
|
+
isScrolled,
|
19689
20303
|
scrollToIndex,
|
19690
20304
|
table,
|
19691
20305
|
tableMeta
|
@@ -19693,117 +20307,143 @@ function CreateNewRowButton(props) {
|
|
19693
20307
|
const {
|
19694
20308
|
texts
|
19695
20309
|
} = useLocalization();
|
19696
|
-
const
|
19697
|
-
const [
|
19698
|
-
|
19699
|
-
|
19700
|
-
const handleKeyDown = event => {
|
19701
|
-
if (!tableMeta.editing.hasChanges() && event.key === 'Tab') {
|
19702
|
-
tableMeta.editing.saveChanges();
|
19703
|
-
}
|
19704
|
-
};
|
20310
|
+
const temporaryRows = tableMeta.editing.temporaryRows;
|
20311
|
+
const temporaryRowId = (_temporaryRows$0$tabl = (_temporaryRows$ = temporaryRows[0]) === null || _temporaryRows$ === void 0 ? void 0 : _temporaryRows$[tableMeta.rowIdentityAccessor]) !== null && _temporaryRows$0$tabl !== void 0 ? _temporaryRows$0$tabl : '';
|
20312
|
+
const isDisabled = !!table.getState().globalFilter || !!((_table$getState$colum = table.getState().columnFilters) !== null && _table$getState$colum !== void 0 && _table$getState$colum.length) || !!temporaryRowId && !!tableMeta.editing.hasRowErrors(temporaryRowId);
|
20313
|
+
const isSaving = !!temporaryRowId && tableMeta.editing.getRowStatus(temporaryRowId) === 'saving';
|
19705
20314
|
const handleCreate = function () {
|
19706
20315
|
try {
|
19707
|
-
if (
|
20316
|
+
if (isDisabled) {
|
19708
20317
|
return Promise.resolve();
|
19709
20318
|
}
|
19710
|
-
|
19711
|
-
var _rowCreated$rowFinder;
|
19712
|
-
return rowCreated === null || rowCreated === void 0 ? void 0 : (_rowCreated$rowFinder = rowCreated.rowFinder) === null || _rowCreated$rowFinder === void 0 ? void 0 : _rowCreated$rowFinder.call(rowCreated, row.original);
|
19713
|
-
});
|
19714
|
-
const _temp = function () {
|
19715
|
-
if (createdRow) {
|
19716
|
-
return Promise.resolve(tableMeta.editing.saveChanges()).then(function () {
|
19717
|
-
if (!tableMeta.editing.hasRowErrors(createdRow.id)) {
|
19718
|
-
const rowFinder = onEditingCreate();
|
19719
|
-
setRowCreated({
|
19720
|
-
rowFinder
|
19721
|
-
});
|
19722
|
-
}
|
19723
|
-
});
|
19724
|
-
} else {
|
19725
|
-
const rowFinder = onEditingCreate();
|
19726
|
-
setRowCreated({
|
19727
|
-
rowFinder
|
19728
|
-
});
|
19729
|
-
}
|
19730
|
-
}();
|
19731
|
-
return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
|
20319
|
+
return Promise.resolve(tableMeta.editing.createRow(table, scrollToIndex)).then(function () {});
|
19732
20320
|
} catch (e) {
|
19733
20321
|
return Promise.reject(e);
|
19734
20322
|
}
|
19735
20323
|
};
|
19736
|
-
|
19737
|
-
|
19738
|
-
|
19739
|
-
|
19740
|
-
|
19741
|
-
|
19742
|
-
|
19743
|
-
|
19744
|
-
|
19745
|
-
|
19746
|
-
|
19747
|
-
|
19748
|
-
|
19749
|
-
|
19750
|
-
|
19751
|
-
|
19752
|
-
|
19753
|
-
|
19754
|
-
|
19755
|
-
}
|
19756
|
-
}, [rowCreated]);
|
20324
|
+
const shortcut = {
|
20325
|
+
key: 'Enter',
|
20326
|
+
meta: true
|
20327
|
+
};
|
20328
|
+
let tooltip;
|
20329
|
+
if (isSaving) {
|
20330
|
+
tooltip = texts.table3.editing.buttons.create.saving;
|
20331
|
+
} else if (isDisabled) {
|
20332
|
+
tooltip = texts.table3.editing.buttons.create.disabled;
|
20333
|
+
} else {
|
20334
|
+
tooltip = /*#__PURE__*/React__default.createElement(Shortcut, {
|
20335
|
+
keys: shortcut
|
20336
|
+
});
|
20337
|
+
}
|
20338
|
+
const className = cn('group/row border-grey-300 !sticky z-[21]', {
|
20339
|
+
'bottom-10': tableMeta.footer.isEnabled,
|
20340
|
+
'bottom-0': !tableMeta.footer.isEnabled,
|
20341
|
+
'border-b': !isScrolled
|
20342
|
+
});
|
19757
20343
|
return /*#__PURE__*/React__default.createElement("tr", {
|
19758
|
-
|
19759
|
-
className:
|
20344
|
+
"data-row-create": true,
|
20345
|
+
className: className,
|
20346
|
+
tabIndex: -1
|
19760
20347
|
}, /*#__PURE__*/React__default.createElement("td", {
|
19761
|
-
className: "!border-
|
20348
|
+
className: "!bg-grey-50 col-span-full !border-b-0 !px-1"
|
19762
20349
|
}, /*#__PURE__*/React__default.createElement(Button$1, {
|
19763
|
-
|
19764
|
-
className: "group-hover:bg-grey-200 sticky left-
|
19765
|
-
|
19766
|
-
|
20350
|
+
appearance: "transparent",
|
20351
|
+
className: "group-hover:bg-grey-200 sticky left-[4px]",
|
20352
|
+
disabled: isDisabled,
|
20353
|
+
onClick: handleCreate,
|
20354
|
+
ref: buttonRef,
|
20355
|
+
shortcut: shortcut,
|
20356
|
+
tooltip: tooltip
|
20357
|
+
}, /*#__PURE__*/React__default.createElement(Icon, {
|
20358
|
+
name: "circle-plus"
|
20359
|
+
}), texts.table3.editing.buttons.create.label)));
|
19767
20360
|
}
|
19768
20361
|
|
19769
|
-
function
|
20362
|
+
function TemporaryRow(props) {
|
19770
20363
|
const {
|
19771
|
-
|
19772
|
-
|
20364
|
+
createRowButtonRef,
|
20365
|
+
isScrolled,
|
20366
|
+
table,
|
20367
|
+
tableMeta,
|
20368
|
+
tableRef
|
19773
20369
|
} = props;
|
19774
|
-
const {
|
19775
|
-
|
19776
|
-
|
19777
|
-
|
19778
|
-
|
19779
|
-
|
19780
|
-
|
19781
|
-
|
19782
|
-
|
20370
|
+
const handleKeyDown = function (event) {
|
20371
|
+
try {
|
20372
|
+
const _temp2 = function () {
|
20373
|
+
if (event.key === 'ArrowDown') {
|
20374
|
+
event.preventDefault();
|
20375
|
+
const _temp = function () {
|
20376
|
+
if (!isElementTriggeredFromContainer(event.target, event.currentTarget)) {
|
20377
|
+
return Promise.resolve(tableMeta.editing.saveChanges(table)).then(function (saved) {
|
20378
|
+
if (saved) {
|
20379
|
+
var _createRowButtonRef$c;
|
20380
|
+
(_createRowButtonRef$c = createRowButtonRef.current) === null || _createRowButtonRef$c === void 0 ? void 0 : _createRowButtonRef$c.focus();
|
20381
|
+
}
|
20382
|
+
});
|
20383
|
+
}
|
20384
|
+
}();
|
20385
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
20386
|
+
} else if (event.key === 'ArrowUp') {
|
20387
|
+
event.preventDefault();
|
20388
|
+
event.stopPropagation();
|
20389
|
+
if (tableRef.current) {
|
20390
|
+
var _tableRef$current$que, _tableRef$current$que2, _tableRef$current$que3;
|
20391
|
+
const availableRows = Array.from((_tableRef$current$que = tableRef.current.querySelectorAll(`tbody tr:not([data-row-id^='${TEMPORARY_ROW_ID_PREFIX}'])`)) !== null && _tableRef$current$que !== void 0 ? _tableRef$current$que : []);
|
20392
|
+
const footerHeight = (_tableRef$current$que2 = (_tableRef$current$que3 = tableRef.current.querySelector('tfoot')) === null || _tableRef$current$que3 === void 0 ? void 0 : _tableRef$current$que3.getBoundingClientRect().height) !== null && _tableRef$current$que2 !== void 0 ? _tableRef$current$que2 : 0;
|
20393
|
+
const newRowHeight = event.currentTarget.getBoundingClientRect().height;
|
20394
|
+
const visibleHeight = tableRef.current.clientHeight - footerHeight - newRowHeight;
|
20395
|
+
const tableTopOffset = tableRef.current.getBoundingClientRect().top;
|
20396
|
+
let nextRowIndex;
|
20397
|
+
// iterate available rows in reverse order, since we're working at the bottom
|
20398
|
+
for (let index = availableRows.length - 1; index >= 0; index--) {
|
20399
|
+
const rowRect = availableRows[index].getBoundingClientRect();
|
20400
|
+
const topPlusHalfRow = rowRect.top + rowRect.height / 2;
|
20401
|
+
if (topPlusHalfRow - tableTopOffset <= visibleHeight) {
|
20402
|
+
nextRowIndex = index;
|
20403
|
+
break;
|
20404
|
+
}
|
20405
|
+
}
|
20406
|
+
if (nextRowIndex) {
|
20407
|
+
tableMeta.rowActive.setRowActiveIndex(Number(availableRows[nextRowIndex < 0 ? 0 : nextRowIndex].getAttribute('data-row-index')));
|
20408
|
+
}
|
20409
|
+
}
|
20410
|
+
}
|
20411
|
+
}();
|
20412
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
20413
|
+
} catch (e) {
|
20414
|
+
return Promise.reject(e);
|
20415
|
+
}
|
19783
20416
|
};
|
19784
|
-
const
|
19785
|
-
|
19786
|
-
|
19787
|
-
|
19788
|
-
|
19789
|
-
|
19790
|
-
|
19791
|
-
|
19792
|
-
|
19793
|
-
|
19794
|
-
tableMeta.editing.toggleEditing(enabled);
|
19795
|
-
requestAnimationFrame(() => {
|
19796
|
-
var _tableMeta$rowActive$;
|
19797
|
-
return scrollToIndex((_tableMeta$rowActive$ = tableMeta.rowActive.rowActiveIndex) !== null && _tableMeta$rowActive$ !== void 0 ? _tableMeta$rowActive$ : 0);
|
19798
|
-
});
|
20417
|
+
const handleKeyDownCapture = event => {
|
20418
|
+
if (event.key === 'ArrowLeft' && tableMeta.editing.lastFocusedCellIndex === 0) {
|
20419
|
+
event.preventDefault();
|
20420
|
+
event.stopPropagation();
|
20421
|
+
} else if (event.key === 'ArrowRight' && tableMeta.editing.lastFocusedCellIndex) {
|
20422
|
+
if (tableMeta.editing.lastFocusedCellIndex === table.getVisibleFlatColumns().length - 1) {
|
20423
|
+
event.preventDefault();
|
20424
|
+
event.stopPropagation();
|
20425
|
+
}
|
20426
|
+
}
|
19799
20427
|
};
|
19800
|
-
|
19801
|
-
|
19802
|
-
|
19803
|
-
|
19804
|
-
|
19805
|
-
|
19806
|
-
|
20428
|
+
const className = cn('group/row border-grey-300 !sticky z-[22]', {
|
20429
|
+
'bottom-[calc(5rem_+_2px)] data-[row-editing-move]:bottom-[calc(5rem_+_2px)]': tableMeta.footer.isEnabled,
|
20430
|
+
'bottom-[calc(2.5rem_+_2px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_2px)]': !tableMeta.footer.isEnabled,
|
20431
|
+
'border-t-2 shadow-[0px_-5px_20px_0px_rgba(0,0,0,0.1)] [&>td]:!border-b-0': isScrolled
|
20432
|
+
});
|
20433
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, table.getBottomRows().map(row => (/*#__PURE__*/React__default.createElement(Row, {
|
20434
|
+
key: row.id,
|
20435
|
+
cellRenderer: RENDERERS$1.cell,
|
20436
|
+
index: tableMeta.length,
|
20437
|
+
measureRow: () => null,
|
20438
|
+
renderer: RENDERERS$1.row,
|
20439
|
+
row: row,
|
20440
|
+
table: table,
|
20441
|
+
className: className,
|
20442
|
+
onKeyDown: handleKeyDown,
|
20443
|
+
onKeyDownCapture: handleKeyDownCapture,
|
20444
|
+
hideInternalColumns: true,
|
20445
|
+
hideRowActions: !tableMeta.editing.isEditing
|
20446
|
+
}))));
|
19807
20447
|
}
|
19808
20448
|
|
19809
20449
|
function Column$3(_) {
|
@@ -19821,8 +20461,19 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
|
|
19821
20461
|
'data-table-editing-mode': (_table3$meta$editing = table3.meta.editing) !== null && _table3$meta$editing !== void 0 && _table3$meta$editing.isEditing ? (_table3$meta$editing2 = table3.meta.editing) !== null && _table3$meta$editing2 !== void 0 && _table3$meta$editing2.isDetailedMode ? 'detailed' : 'normal' : undefined,
|
19822
20462
|
enableHorizontalArrowKeyNavigation: table3.meta.editing.isEditing
|
19823
20463
|
};
|
19824
|
-
const hasAlertErrors = table3.meta.editing.
|
19825
|
-
const
|
20464
|
+
const hasAlertErrors = table3.meta.editing.getErrorsShownInAlert().length;
|
20465
|
+
const hasCreateWorkflow = table3.meta.editing.isEnabled && props.onEditingCreate;
|
20466
|
+
const isScrolled = isTableScrolled(table3.ref);
|
20467
|
+
let createWorkflow;
|
20468
|
+
if (hasCreateWorkflow) {
|
20469
|
+
createWorkflow = /*#__PURE__*/React__default.createElement(CreateNewRow, {
|
20470
|
+
buttonRef: table3.meta.editing.createRowButtonRef,
|
20471
|
+
isScrolled: isScrolled,
|
20472
|
+
scrollToIndex: table3.renderer.scrollToIndex,
|
20473
|
+
table: table3.instance,
|
20474
|
+
tableMeta: table3.meta
|
20475
|
+
});
|
20476
|
+
}
|
19826
20477
|
return /*#__PURE__*/React__default.createElement(Table, null, /*#__PURE__*/React__default.createElement(Table.Toolbar, {
|
19827
20478
|
table: table3
|
19828
20479
|
}, table3.meta.editing.isEnabled ? (/*#__PURE__*/React__default.createElement(Editing, {
|
@@ -19835,13 +20486,15 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
|
|
19835
20486
|
tableRef: table3.ref
|
19836
20487
|
})) : null, /*#__PURE__*/React__default.createElement(Table.Grid, Object.assign({}, gridAttributes, {
|
19837
20488
|
"data-taco": "table3",
|
20489
|
+
footerRows: hasCreateWorkflow && isScrolled ? createWorkflow : undefined,
|
19838
20490
|
table: table3
|
19839
|
-
}),
|
20491
|
+
}), hasCreateWorkflow ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TemporaryRow, {
|
20492
|
+
createRowButtonRef: table3.meta.editing.createRowButtonRef,
|
20493
|
+
isScrolled: isScrolled,
|
19840
20494
|
table: table3.instance,
|
19841
20495
|
tableMeta: table3.meta,
|
19842
|
-
|
19843
|
-
|
19844
|
-
}))));
|
20496
|
+
tableRef: table3.ref
|
20497
|
+
}), !isScrolled ? createWorkflow : null)) : null));
|
19845
20498
|
});
|
19846
20499
|
const Table3 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
19847
20500
|
const stringifiedChildren = String(props.children);
|
@@ -20077,6 +20730,796 @@ const Tour = props => {
|
|
20077
20730
|
};
|
20078
20731
|
Tour.Step = TourStep;
|
20079
20732
|
|
20733
|
+
// NOTE: this file is intentianally a js file so that it can be consumed by tailwind.config.js
|
20734
|
+
|
20735
|
+
const THEME_COLORS = {
|
20736
|
+
transparent: 'transparent',
|
20737
|
+
current: 'currentColor',
|
20738
|
+
white: '#fff',
|
20739
|
+
black: '#1c1c1c',
|
20740
|
+
brand: {
|
20741
|
+
vismaRed: '#E70641',
|
20742
|
+
paleOrange: '#FFF5E5',
|
20743
|
+
sunsetOrange: '#E89C2E',
|
20744
|
+
midnightBlue: '#29283E',
|
20745
|
+
coolBlue: '#F5F7F9'
|
20746
|
+
},
|
20747
|
+
grey: {
|
20748
|
+
lightest: '#fafafa',
|
20749
|
+
light: '#F6F6F6',
|
20750
|
+
DEFAULT: '#EBEBEB',
|
20751
|
+
dark: '#DDDDDD',
|
20752
|
+
darker: '#ACACAC',
|
20753
|
+
darkest: '#595959',
|
20754
|
+
darkNew: '#a5a6a9',
|
20755
|
+
50: '#fafafa',
|
20756
|
+
100: '#F6F6F6',
|
20757
|
+
200: '#EBEBEB',
|
20758
|
+
300: '#DDDDDD',
|
20759
|
+
500: '#ACACAC',
|
20760
|
+
700: '#595959',
|
20761
|
+
900: '#303030'
|
20762
|
+
},
|
20763
|
+
purple: {
|
20764
|
+
lightest: '#585c74',
|
20765
|
+
light: '#4b4f64',
|
20766
|
+
DEFAULT: '#3d4153',
|
20767
|
+
dark: '#353a48',
|
20768
|
+
darker: '#29283e',
|
20769
|
+
darkest: '#212032',
|
20770
|
+
darkNew_1: '#373647',
|
20771
|
+
darkNew_2: '#414050',
|
20772
|
+
100: '#EEE5FF',
|
20773
|
+
200: '#ddd1ff',
|
20774
|
+
300: '#CBBCFE',
|
20775
|
+
500: '#9270FA',
|
20776
|
+
700: '#6542D1',
|
20777
|
+
900: '#412970'
|
20778
|
+
},
|
20779
|
+
blue: {
|
20780
|
+
lightest: '#DEEBFF',
|
20781
|
+
light: '#75A0F5',
|
20782
|
+
DEFAULT: '#4573D2',
|
20783
|
+
dark: '#2B57B4',
|
20784
|
+
100: '#DEEBFF',
|
20785
|
+
200: '#AACCFF',
|
20786
|
+
300: '#75A0F5',
|
20787
|
+
500: '#4573D2',
|
20788
|
+
700: '#2B57B4',
|
20789
|
+
900: '#29283E'
|
20790
|
+
},
|
20791
|
+
red: {
|
20792
|
+
lightest: '#FFDAD2',
|
20793
|
+
light: '#E66568',
|
20794
|
+
DEFAULT: '#CE3F42',
|
20795
|
+
dark: '#950027',
|
20796
|
+
100: '#FFDAD2',
|
20797
|
+
200: '#f3a09d',
|
20798
|
+
300: '#E66568',
|
20799
|
+
500: '#CE3F42',
|
20800
|
+
700: '#950027',
|
20801
|
+
900: '#64001B'
|
20802
|
+
},
|
20803
|
+
green: {
|
20804
|
+
lightest: '#cdf0e7',
|
20805
|
+
light: '#52C7AB',
|
20806
|
+
DEFAULT: '#08AE87',
|
20807
|
+
dark: '#028465',
|
20808
|
+
100: '#cdf0e7',
|
20809
|
+
200: '#9be1ce',
|
20810
|
+
300: '#52C7AB',
|
20811
|
+
500: '#08AE87',
|
20812
|
+
700: '#028465',
|
20813
|
+
900: '#14493A'
|
20814
|
+
},
|
20815
|
+
yellow: {
|
20816
|
+
lightest: '#FFF1C3',
|
20817
|
+
light: '#FFD665',
|
20818
|
+
DEFAULT: '#FFBD3B',
|
20819
|
+
dark: '#e89c2e',
|
20820
|
+
100: '#FFF1C3',
|
20821
|
+
200: '#ffe494',
|
20822
|
+
300: '#FFD665',
|
20823
|
+
500: '#FFBD3B',
|
20824
|
+
700: '#e89c2e',
|
20825
|
+
900: '#733700'
|
20826
|
+
},
|
20827
|
+
pink: {
|
20828
|
+
100: '#FFE3F7',
|
20829
|
+
200: '#fcb9e9',
|
20830
|
+
300: '#F98EDB',
|
20831
|
+
500: '#E165BF',
|
20832
|
+
700: '#CF49AA',
|
20833
|
+
900: '#870062'
|
20834
|
+
},
|
20835
|
+
brown: {
|
20836
|
+
100: '#EEE0DA',
|
20837
|
+
200: '#DFCCC2',
|
20838
|
+
300: '#C4AB9E',
|
20839
|
+
500: '#93715D',
|
20840
|
+
700: '#73503B',
|
20841
|
+
900: '#45291F'
|
20842
|
+
},
|
20843
|
+
orange: {
|
20844
|
+
100: '#FFE3BB',
|
20845
|
+
200: '#FCCB80',
|
20846
|
+
300: '#FAB64D',
|
20847
|
+
500: '#F99702',
|
20848
|
+
700: '#EF7D00',
|
20849
|
+
900: '#4A2811'
|
20850
|
+
}
|
20851
|
+
};
|
20852
|
+
|
20853
|
+
const mapColor = (palette, prefix = '') => {
|
20854
|
+
return Object.keys(palette).reduce((accum, color) => {
|
20855
|
+
if (color === 'current') {
|
20856
|
+
return accum;
|
20857
|
+
} else if (typeof palette[color] === 'string') {
|
20858
|
+
return {
|
20859
|
+
...accum,
|
20860
|
+
[prefix ? color === 'DEFAULT' ? prefix : `${prefix}-${color}` : color]: palette[color]
|
20861
|
+
};
|
20862
|
+
} else {
|
20863
|
+
return {
|
20864
|
+
...accum,
|
20865
|
+
...mapColor(palette[color], color)
|
20866
|
+
};
|
20867
|
+
}
|
20868
|
+
}, {});
|
20869
|
+
};
|
20870
|
+
const colors = /*#__PURE__*/mapColor(THEME_COLORS);
|
20871
|
+
const getThemeColor = color => colors[color];
|
20872
|
+
|
20873
|
+
function Legend(props) {
|
20874
|
+
const {
|
20875
|
+
activeIndex,
|
20876
|
+
onMouseEnter,
|
20877
|
+
onMouseLeave,
|
20878
|
+
onClick,
|
20879
|
+
payload,
|
20880
|
+
layout,
|
20881
|
+
activeItems
|
20882
|
+
} = props;
|
20883
|
+
const [hoverIndex, setHoverIndex] = React.useState(null);
|
20884
|
+
const handleMouseEnter = (entry, index) => {
|
20885
|
+
setHoverIndex(index);
|
20886
|
+
if (activeItems[entry.dataKey]) onMouseEnter(entry, index);
|
20887
|
+
};
|
20888
|
+
const handleMouseLeave = () => {
|
20889
|
+
onMouseLeave();
|
20890
|
+
setHoverIndex(null);
|
20891
|
+
};
|
20892
|
+
const moreButton = moreButtonText => (/*#__PURE__*/React__default.createElement(Button$1, {
|
20893
|
+
appearance: "transparent",
|
20894
|
+
className: "text-grey-700"
|
20895
|
+
}, moreButtonText));
|
20896
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
20897
|
+
className: "mx-auto w-auto max-w-full overflow-hidden"
|
20898
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
20899
|
+
className: cn('mb-0 ml-0 flex justify-center', {
|
20900
|
+
'flex-col': layout === 'vertical'
|
20901
|
+
})
|
20902
|
+
}, /*#__PURE__*/React__default.createElement(OverflowGroup, {
|
20903
|
+
className: "w-full items-center py-1",
|
20904
|
+
moreButton: moreButton
|
20905
|
+
}, payload.map((entry, index) => (/*#__PURE__*/React__default.createElement("span", {
|
20906
|
+
key: `${entry.dataKey}-${index}`,
|
20907
|
+
className: cn(' hover:bg-grey-100 cursor-pointer px-[8px] py-[2px] hover:rounded-[4px]', {
|
20908
|
+
'bg-grey-100 rounded': activeIndex === index
|
20909
|
+
}),
|
20910
|
+
onMouseEnter: () => handleMouseEnter(entry, index),
|
20911
|
+
onMouseLeave: handleMouseLeave,
|
20912
|
+
onClick: onClick ? () => onClick(entry) : undefined
|
20913
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
20914
|
+
className: "text-grey-700 flex items-center gap-[4px]"
|
20915
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
20916
|
+
className: cn('-mt-px ml-1 flex h-3 w-3 rounded-sm', {
|
20917
|
+
'border-grey-300 border !bg-white': !activeItems[entry.dataKey]
|
20918
|
+
}),
|
20919
|
+
style: {
|
20920
|
+
backgroundColor: entry.color
|
20921
|
+
}
|
20922
|
+
}, hoverIndex === index && activeItems[entry.dataKey] && (/*#__PURE__*/React__default.createElement(Icon, {
|
20923
|
+
name: "tick-bold",
|
20924
|
+
className: "!h-full !w-full text-white"
|
20925
|
+
}))), entry.value)))))));
|
20926
|
+
}
|
20927
|
+
|
20928
|
+
const Tooltip$2 = ({
|
20929
|
+
active,
|
20930
|
+
formatter,
|
20931
|
+
payload,
|
20932
|
+
style,
|
20933
|
+
singlePieDonutChart
|
20934
|
+
}) => {
|
20935
|
+
const getColor = entry => {
|
20936
|
+
var _ref, _entry$color;
|
20937
|
+
if (singlePieDonutChart) {
|
20938
|
+
// We use entry.payload.label because the payload structure differs between a Donut chart with a single pie
|
20939
|
+
// and one with multiple pies.
|
20940
|
+
return getThemeColor(entry.payload.color);
|
20941
|
+
}
|
20942
|
+
return (_ref = (_entry$color = entry.color) !== null && _entry$color !== void 0 ? _entry$color : entry.payload.fill) !== null && _ref !== void 0 ? _ref : 'blue-500';
|
20943
|
+
};
|
20944
|
+
if (active && payload && payload.length) {
|
20945
|
+
return /*#__PURE__*/React__default.createElement("dl", {
|
20946
|
+
className: "z-20 grid grid-cols-[max-content_max-content] gap-x-4 rounded-md bg-white p-4 text-xs shadow-[0px_0px_1px_rgba(0,0,0,0.1),_0px_6px_18px_rgba(47,51,68,0.2)]",
|
20947
|
+
style: style
|
20948
|
+
}, payload.map((entry, index) => (/*#__PURE__*/React__default.createElement(React__default.Fragment, {
|
20949
|
+
key: `${entry.name}-${index}`
|
20950
|
+
}, /*#__PURE__*/React__default.createElement("dt", {
|
20951
|
+
className: "text-grey-700 mb-0 flex items-center gap-1 font-normal"
|
20952
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
20953
|
+
className: "-mt-px h-2.5 w-2.5 rounded-sm",
|
20954
|
+
style: {
|
20955
|
+
background: getColor(entry)
|
20956
|
+
}
|
20957
|
+
}),
|
20958
|
+
// We use entry.payload.label because the payload structure differs between a Donut chart with a single pie
|
20959
|
+
// and one with multiple pies.
|
20960
|
+
singlePieDonutChart ? entry.payload.label : entry.name), /*#__PURE__*/React__default.createElement("dd", {
|
20961
|
+
className: "mb-0 text-right font-bold text-black "
|
20962
|
+
}, formatter ? formatter(entry.value) : entry.value)))));
|
20963
|
+
}
|
20964
|
+
return null;
|
20965
|
+
};
|
20966
|
+
|
20967
|
+
const getCartesianGridProps = () => ({
|
20968
|
+
vertical: false
|
20969
|
+
});
|
20970
|
+
const getXAxisProps = props => ({
|
20971
|
+
axisLine: false,
|
20972
|
+
dataKey: props.accessor,
|
20973
|
+
fontSize: 12,
|
20974
|
+
scale: props.xAxisScale,
|
20975
|
+
tickLine: false,
|
20976
|
+
tickFormatter: props.xAxisTickFormat
|
20977
|
+
});
|
20978
|
+
const getYAxisProps = props => ({
|
20979
|
+
axisLine: false,
|
20980
|
+
fontSize: 12,
|
20981
|
+
scale: props.yAxisScale,
|
20982
|
+
tickLine: false,
|
20983
|
+
tickFormatter: props.yAxisTickFormat
|
20984
|
+
});
|
20985
|
+
const getLegendProps = props => ({
|
20986
|
+
content: /*#__PURE__*/React__default.createElement(Legend, Object.assign({}, props))
|
20987
|
+
});
|
20988
|
+
const getTooltipProps = (props = undefined) => ({
|
20989
|
+
content: /*#__PURE__*/React__default.createElement(Tooltip$2, Object.assign({}, props)),
|
20990
|
+
wrapperStyle: {
|
20991
|
+
outline: 'none'
|
20992
|
+
}
|
20993
|
+
});
|
20994
|
+
|
20995
|
+
// A hacky fix for EC-50037 to make sure that Chart doesn't resize when it is inside a Card.
|
20996
|
+
const ResponsiveContainer = props => (/*#__PURE__*/React__default.createElement(Recharts.ResponsiveContainer, Object.assign({
|
20997
|
+
className: "!h-[calc(100%-1px)] !w-[calc(100%-1px)]"
|
20998
|
+
}, props)));
|
20999
|
+
|
21000
|
+
const Area = _ => null;
|
21001
|
+
const AreaChart = function AreaChart(externalProps) {
|
21002
|
+
const {
|
21003
|
+
children,
|
21004
|
+
data,
|
21005
|
+
formatter,
|
21006
|
+
...props
|
21007
|
+
} = externalProps;
|
21008
|
+
const [hoveredArea, setHoveredArea] = React.useState(null);
|
21009
|
+
const [activeAreas, setActiveAreas] = React.useState(() => {
|
21010
|
+
const areas = {};
|
21011
|
+
React__default.Children.forEach(children, child => {
|
21012
|
+
areas[child.props.accessor] = true;
|
21013
|
+
});
|
21014
|
+
return areas;
|
21015
|
+
});
|
21016
|
+
const handleLegendClick = entry => {
|
21017
|
+
setHoveredArea(null);
|
21018
|
+
setActiveAreas({
|
21019
|
+
...activeAreas,
|
21020
|
+
[entry.dataKey]: !activeAreas[entry.dataKey]
|
21021
|
+
});
|
21022
|
+
};
|
21023
|
+
return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.AreaChart, {
|
21024
|
+
data: data,
|
21025
|
+
margin: {
|
21026
|
+
top: 10,
|
21027
|
+
right: 0,
|
21028
|
+
left: -25,
|
21029
|
+
bottom: 0
|
21030
|
+
}
|
21031
|
+
}, /*#__PURE__*/React__default.createElement(Recharts.CartesianGrid, Object.assign({}, getCartesianGridProps())), /*#__PURE__*/React__default.createElement(Recharts.XAxis, Object.assign({}, getXAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.YAxis, Object.assign({}, getYAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.Legend, Object.assign({}, getLegendProps({
|
21032
|
+
onClick: handleLegendClick,
|
21033
|
+
onMouseEnter: entry => setHoveredArea(entry.dataKey),
|
21034
|
+
onMouseLeave: () => setHoveredArea(null),
|
21035
|
+
activeItems: activeAreas
|
21036
|
+
}))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
|
21037
|
+
formatter: formatter
|
21038
|
+
})), React__default.Children.map(children, child => {
|
21039
|
+
var _child$props$color, _child$props$color2, _child$props$color3;
|
21040
|
+
return /*#__PURE__*/React__default.createElement(Recharts.Area, {
|
21041
|
+
activeDot: {
|
21042
|
+
fill: getThemeColor((_child$props$color = child.props.color) !== null && _child$props$color !== void 0 ? _child$props$color : 'blue-300')
|
21043
|
+
},
|
21044
|
+
isAnimationActive: false,
|
21045
|
+
dataKey: child.props.accessor,
|
21046
|
+
dot: false,
|
21047
|
+
fill: getThemeColor((_child$props$color2 = child.props.color) !== null && _child$props$color2 !== void 0 ? _child$props$color2 : 'grey-100'),
|
21048
|
+
name: child.props.label,
|
21049
|
+
strokeWidth: 2,
|
21050
|
+
stroke: getThemeColor((_child$props$color3 = child.props.color) !== null && _child$props$color3 !== void 0 ? _child$props$color3 : 'grey-300'),
|
21051
|
+
stackId: child.props.stackId,
|
21052
|
+
hide: !activeAreas[child.props.accessor],
|
21053
|
+
opacity: hoveredArea && child.props.accessor !== hoveredArea ? 0.3 : 1
|
21054
|
+
});
|
21055
|
+
})));
|
21056
|
+
};
|
21057
|
+
AreaChart.Area = Area;
|
21058
|
+
|
21059
|
+
const Bar$1 = _ => null;
|
21060
|
+
const getXAxisVerticalProps = props => ({
|
21061
|
+
...getXAxisProps(props),
|
21062
|
+
...{
|
21063
|
+
type: 'number',
|
21064
|
+
dataKey: undefined
|
21065
|
+
}
|
21066
|
+
});
|
21067
|
+
const getYAxisVerticalProps = props => ({
|
21068
|
+
...getYAxisProps(props),
|
21069
|
+
...{
|
21070
|
+
dataKey: props.accessor,
|
21071
|
+
type: 'category'
|
21072
|
+
}
|
21073
|
+
});
|
21074
|
+
const BarChart = function BarChart(externalProps) {
|
21075
|
+
const {
|
21076
|
+
children,
|
21077
|
+
data,
|
21078
|
+
formatter,
|
21079
|
+
layout = 'horizontal',
|
21080
|
+
...props
|
21081
|
+
} = externalProps;
|
21082
|
+
const [activeIndex, setActiveIndex] = React__default.useState(undefined);
|
21083
|
+
const [hoveredBar, setHoveredBar] = React__default.useState(null);
|
21084
|
+
const [activeBars, setActiveBars] = React__default.useState(() => {
|
21085
|
+
const keys = {};
|
21086
|
+
React__default.Children.forEach(children, child => {
|
21087
|
+
keys[child.props.accessor] = true;
|
21088
|
+
});
|
21089
|
+
return keys;
|
21090
|
+
});
|
21091
|
+
// Recharts doesn't provide a way for us to know if a stacked bar is at the top or the bottom,
|
21092
|
+
// so we can't set proper radiuses without some "magic"
|
21093
|
+
const stacks = {};
|
21094
|
+
React__default.Children.forEach(children, child => {
|
21095
|
+
if (child.props.stackId) {
|
21096
|
+
if (!stacks[child.props.stackId]) {
|
21097
|
+
stacks[child.props.stackId] = [child.props.accessor];
|
21098
|
+
} else {
|
21099
|
+
stacks[child.props.stackId].push(child.props.accessor);
|
21100
|
+
}
|
21101
|
+
}
|
21102
|
+
});
|
21103
|
+
const handleLegendClick = entry => {
|
21104
|
+
setHoveredBar(null);
|
21105
|
+
setActiveBars({
|
21106
|
+
...activeBars,
|
21107
|
+
[entry.dataKey]: !activeBars[entry.dataKey]
|
21108
|
+
});
|
21109
|
+
};
|
21110
|
+
const handleLegendHover = (entry, index) => {
|
21111
|
+
setHoveredBar(entry.dataKey);
|
21112
|
+
setActiveIndex(index);
|
21113
|
+
};
|
21114
|
+
return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.BarChart, {
|
21115
|
+
layout: layout,
|
21116
|
+
data: data,
|
21117
|
+
margin: {
|
21118
|
+
top: 10,
|
21119
|
+
right: 0,
|
21120
|
+
left: layout === 'vertical' ? 0 : -25,
|
21121
|
+
bottom: 0
|
21122
|
+
},
|
21123
|
+
onMouseMove: chartState => setActiveIndex(chartState.activeTooltipIndex),
|
21124
|
+
onMouseLeave: () => setActiveIndex(undefined)
|
21125
|
+
}, /*#__PURE__*/React__default.createElement(Recharts.CartesianGrid, Object.assign({}, getCartesianGridProps())), /*#__PURE__*/React__default.createElement(Recharts.XAxis, Object.assign({}, layout === 'vertical' ? getXAxisVerticalProps(props) : getXAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.YAxis, Object.assign({}, layout === 'vertical' ? getYAxisVerticalProps(props) : getYAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.Legend, Object.assign({}, getLegendProps({
|
21126
|
+
onClick: handleLegendClick,
|
21127
|
+
onMouseEnter: handleLegendHover,
|
21128
|
+
onMouseLeave: () => setHoveredBar(null),
|
21129
|
+
activeItems: activeBars
|
21130
|
+
}))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
|
21131
|
+
formatter: formatter
|
21132
|
+
})), React__default.Children.map(children, child => (/*#__PURE__*/React__default.createElement(Recharts.Bar, {
|
21133
|
+
isAnimationActive: false,
|
21134
|
+
barSize: 16,
|
21135
|
+
dataKey: child.props.accessor,
|
21136
|
+
name: child.props.label,
|
21137
|
+
onMouseEnter: (_, index) => setActiveIndex(index),
|
21138
|
+
onMouseLeave: () => setActiveIndex(undefined),
|
21139
|
+
fill: getThemeColor(child.props.color ? `${child.props.color}` : `blue-300`),
|
21140
|
+
radius: getBarRadius(stacks, child.props.accessor, child.props.stackId, activeBars),
|
21141
|
+
stackId: child.props.stackId,
|
21142
|
+
style: child.props.stackId ? {
|
21143
|
+
stroke: '#fff',
|
21144
|
+
strokeWidth: '2px'
|
21145
|
+
} : undefined,
|
21146
|
+
hide: !activeBars[child.props.accessor]
|
21147
|
+
}, data.map((_, index) => (/*#__PURE__*/React__default.createElement(Recharts.Cell, {
|
21148
|
+
key: `cell-${index}`,
|
21149
|
+
opacity: hoveredBar && child.props.accessor !== hoveredBar || activeIndex !== undefined && activeIndex !== index ? 0.3 : 1
|
21150
|
+
}))))))));
|
21151
|
+
};
|
21152
|
+
BarChart.Bar = Bar$1;
|
21153
|
+
const getBarRadius = (stacks, accessor, stackId, activeBars) => {
|
21154
|
+
if (stackId && Array.isArray(stacks[stackId])) {
|
21155
|
+
const length = stacks[stackId].length - 1;
|
21156
|
+
const index = stacks[stackId].indexOf(accessor);
|
21157
|
+
if (Object.entries(activeBars).filter(item => item[0] !== accessor).every(item => !item[1])) {
|
21158
|
+
return [3, 3, 0, 0];
|
21159
|
+
}
|
21160
|
+
if (activeBars[stacks[stackId][index + 1]] === false) {
|
21161
|
+
return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length - 1 ? 0 : 3, index === length - 1 ? 0 : 3];
|
21162
|
+
}
|
21163
|
+
if (index !== 0 && index !== length) {
|
21164
|
+
return 0;
|
21165
|
+
}
|
21166
|
+
return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length ? 0 : 3, index === length ? 0 : 3];
|
21167
|
+
}
|
21168
|
+
return 3;
|
21169
|
+
};
|
21170
|
+
|
21171
|
+
const Legend$1 = ({
|
21172
|
+
legendPosition,
|
21173
|
+
hoveredItem,
|
21174
|
+
selectedItem,
|
21175
|
+
data,
|
21176
|
+
onClick,
|
21177
|
+
setHoveredItem,
|
21178
|
+
formatter,
|
21179
|
+
total,
|
21180
|
+
visibleItems,
|
21181
|
+
label
|
21182
|
+
}) => {
|
21183
|
+
const isTotalLegendSelected = selectedItem.length === data.length;
|
21184
|
+
const isTotalLegendHovered = hoveredItem.length === data.length;
|
21185
|
+
const handleMouseLeave = () => setHoveredItem([]);
|
21186
|
+
const renderLegendItem = (entry, index) => {
|
21187
|
+
const isTotal = entry === null;
|
21188
|
+
// We can't use `isTotal` here because TypeScript is unable to infer the type when `entry` is not null.
|
21189
|
+
const itemData = entry === null ? {
|
21190
|
+
id: 'total',
|
21191
|
+
label,
|
21192
|
+
value: total,
|
21193
|
+
color: 'grey-300'
|
21194
|
+
} : entry;
|
21195
|
+
const isSelected = isTotal ? isTotalLegendSelected : selectedItem.includes(itemData.id);
|
21196
|
+
const isHovered = isTotal ? isTotalLegendHovered : hoveredItem.includes(itemData.id);
|
21197
|
+
return /*#__PURE__*/React__default.createElement("li", {
|
21198
|
+
key: isTotal ? 'total' : `${itemData.label}-${index}`,
|
21199
|
+
className: cn('mr-2 flex cursor-pointer gap-2 rounded pl-0 pr-1', {
|
21200
|
+
'bg-grey-100': isHovered && (!isTotal || legendPosition === 'right'),
|
21201
|
+
'bg-grey-200': isSelected && (!isTotal || legendPosition === 'right')
|
21202
|
+
}),
|
21203
|
+
onClick: () => onClick(isTotal ? data : itemData),
|
21204
|
+
onMouseEnter: () => setHoveredItem(isTotal ? data.map(item => item.id) : [itemData.id]),
|
21205
|
+
onMouseLeave: handleMouseLeave
|
21206
|
+
}, legendPosition === 'bottom' ? (/*#__PURE__*/React__default.createElement("div", {
|
21207
|
+
className: "flex items-center gap-1"
|
21208
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
21209
|
+
className: cn('ml-1 h-3 w-3 rounded-sm', {
|
21210
|
+
'border-grey-300 border !bg-white': !visibleItems[itemData.id]
|
21211
|
+
}),
|
21212
|
+
style: {
|
21213
|
+
backgroundColor: getThemeColor(itemData.color)
|
21214
|
+
}
|
21215
|
+
}, visibleItems[itemData.id] && isHovered && (/*#__PURE__*/React__default.createElement(Icon, {
|
21216
|
+
name: "tick-bold",
|
21217
|
+
className: "mb-2.5 !h-full !w-full text-white"
|
21218
|
+
}))), /*#__PURE__*/React__default.createElement("div", null, itemData.label))) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
21219
|
+
className: "ml-1 mt-1 h-9 w-2 rounded-[1px]",
|
21220
|
+
style: {
|
21221
|
+
backgroundColor: getThemeColor(itemData.color)
|
21222
|
+
}
|
21223
|
+
}), /*#__PURE__*/React__default.createElement("div", null, itemData.label, /*#__PURE__*/React__default.createElement("span", {
|
21224
|
+
className: "-mt-1 flex w-full text-lg font-bold"
|
21225
|
+
}, formatter ? formatter(itemData.value) : itemData.value)))));
|
21226
|
+
};
|
21227
|
+
const moreButton = moreButtonText => (/*#__PURE__*/React__default.createElement(Button$1, {
|
21228
|
+
appearance: "transparent",
|
21229
|
+
className: "text-grey-700"
|
21230
|
+
}, moreButtonText));
|
21231
|
+
const className = cn('flex-grow pl-4', {
|
21232
|
+
'w-full': legendPosition === 'bottom'
|
21233
|
+
});
|
21234
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
21235
|
+
className: className
|
21236
|
+
}, /*#__PURE__*/React__default.createElement("ul", {
|
21237
|
+
className: cn('mb-0 ml-0 mt-4 flex justify-center space-y-1', legendPosition === 'right' ? 'flex-col gap-1' : 'flex-row')
|
21238
|
+
}, legendPosition === 'right' ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderLegendItem(null), data.map(renderLegendItem))) : (/*#__PURE__*/React__default.createElement(OverflowGroup, {
|
21239
|
+
className: "w-full items-center py-1",
|
21240
|
+
moreButton: moreButton
|
21241
|
+
}, data.map(renderLegendItem)))));
|
21242
|
+
};
|
21243
|
+
|
21244
|
+
const DONUT_WIDTH = 16;
|
21245
|
+
const HOVER_DONUT_WIDTH = 10;
|
21246
|
+
|
21247
|
+
const CenteredLabel = ({
|
21248
|
+
radius,
|
21249
|
+
legendPosition,
|
21250
|
+
label,
|
21251
|
+
total,
|
21252
|
+
formatter,
|
21253
|
+
showLegend
|
21254
|
+
}) => {
|
21255
|
+
const totalInset = HOVER_DONUT_WIDTH + DONUT_WIDTH + DONUT_WIDTH;
|
21256
|
+
const diameter = radius * 2;
|
21257
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
21258
|
+
className: "absolute mt-1 flex h-12 flex-col text-center",
|
21259
|
+
style: {
|
21260
|
+
top: `calc(${radius}px - (3rem / 2))`,
|
21261
|
+
left: legendPosition === 'right' ? `${totalInset}px` : `calc(50%-${diameter - 2 * totalInset})`,
|
21262
|
+
width: showLegend ? `${diameter - 2 * totalInset}px` : `${diameter}px`
|
21263
|
+
}
|
21264
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
21265
|
+
className: "w-full truncate text-lg font-bold"
|
21266
|
+
}, formatter ? formatter(total) : total), label);
|
21267
|
+
};
|
21268
|
+
|
21269
|
+
const ActiveShape = props => {
|
21270
|
+
var _getThemeColor;
|
21271
|
+
const {
|
21272
|
+
cx,
|
21273
|
+
cy,
|
21274
|
+
id,
|
21275
|
+
innerRadius,
|
21276
|
+
onClick,
|
21277
|
+
outerRadius = 0,
|
21278
|
+
pieColors,
|
21279
|
+
startAngle,
|
21280
|
+
endAngle,
|
21281
|
+
fill
|
21282
|
+
} = props;
|
21283
|
+
return /*#__PURE__*/React__default.createElement("g", {
|
21284
|
+
onClick: () => onClick(id),
|
21285
|
+
className: cn({
|
21286
|
+
'cursor-pointer': !!onClick
|
21287
|
+
})
|
21288
|
+
}, /*#__PURE__*/React__default.createElement(Recharts.Sector, {
|
21289
|
+
cx: cx,
|
21290
|
+
cy: cy,
|
21291
|
+
innerRadius: innerRadius,
|
21292
|
+
outerRadius: outerRadius,
|
21293
|
+
startAngle: startAngle,
|
21294
|
+
endAngle: endAngle,
|
21295
|
+
fill: fill
|
21296
|
+
}), /*#__PURE__*/React__default.createElement(Recharts.Sector, {
|
21297
|
+
cx: cx,
|
21298
|
+
cy: cy,
|
21299
|
+
startAngle: startAngle,
|
21300
|
+
endAngle: endAngle,
|
21301
|
+
innerRadius: outerRadius + 2,
|
21302
|
+
outerRadius: outerRadius + HOVER_DONUT_WIDTH,
|
21303
|
+
fill: id !== undefined ? (_getThemeColor = getThemeColor(pieColors[id])) !== null && _getThemeColor !== void 0 ? _getThemeColor : getThemeColor('blue-500') : getThemeColor('blue-500'),
|
21304
|
+
opacity: 0.3
|
21305
|
+
}));
|
21306
|
+
};
|
21307
|
+
|
21308
|
+
const Segment = _ => null;
|
21309
|
+
const DonutChart = function DonutChart({
|
21310
|
+
children,
|
21311
|
+
formatter,
|
21312
|
+
onClick,
|
21313
|
+
showLegend = false,
|
21314
|
+
legendPosition = 'bottom',
|
21315
|
+
label
|
21316
|
+
}) {
|
21317
|
+
const ref = React__default.useRef(null);
|
21318
|
+
const [radius, setRadius] = React__default.useState(0);
|
21319
|
+
const [hoveredItem, setHoveredItem] = React__default.useState([]);
|
21320
|
+
// used for right legends
|
21321
|
+
const [selectedItem, setSelectedItem] = React__default.useState([]);
|
21322
|
+
// used for bottom legends
|
21323
|
+
const [visibleItems, setVisibleItems] = React__default.useState(() => {
|
21324
|
+
const keys = {};
|
21325
|
+
React__default.Children.forEach(children, child => {
|
21326
|
+
keys[child.props.id] = true;
|
21327
|
+
});
|
21328
|
+
return keys;
|
21329
|
+
});
|
21330
|
+
React__default.useEffect(() => {
|
21331
|
+
if (ref.current) {
|
21332
|
+
var _ref$current$parentEl;
|
21333
|
+
const rect = (_ref$current$parentEl = ref.current.parentElement) === null || _ref$current$parentEl === void 0 ? void 0 : _ref$current$parentEl.getBoundingClientRect();
|
21334
|
+
if (rect) {
|
21335
|
+
const width = showLegend ? rect.width / 2 : rect.width;
|
21336
|
+
const max = rect.height < width ? rect.height : width;
|
21337
|
+
setRadius(max / 2);
|
21338
|
+
}
|
21339
|
+
}
|
21340
|
+
}, [showLegend]);
|
21341
|
+
const diameter = radius * 2; // get dimensions of the parent container to find the max radius, so we can fill the container AND always have a 16px wide donut
|
21342
|
+
const data = React__default.Children.map(children, child => ({
|
21343
|
+
id: child.props.id,
|
21344
|
+
color: child.props.color,
|
21345
|
+
label: child.props.label,
|
21346
|
+
value: child.props.value
|
21347
|
+
}));
|
21348
|
+
const displayedData = data.filter(child => visibleItems[child.id]);
|
21349
|
+
const total = displayedData.reduce((accum, entry) => accum + entry.value, 0);
|
21350
|
+
const showTooltip = (!showLegend || legendPosition === 'bottom') && displayedData.length > 0;
|
21351
|
+
const handleLegendClick = entry => {
|
21352
|
+
if (legendPosition === 'bottom' && !Array.isArray(entry)) {
|
21353
|
+
setVisibleItems({
|
21354
|
+
...visibleItems,
|
21355
|
+
[entry.id]: !visibleItems[entry.id]
|
21356
|
+
});
|
21357
|
+
} else {
|
21358
|
+
const nextSelectedItem = Array.isArray(entry) ? entry.map(entryItem => entryItem.id) : [entry.id];
|
21359
|
+
// Using slice to avoid mutation of the react state 'selectedItem'
|
21360
|
+
const isCurrentSegmentActive = selectedItem.slice().sort().join(',') === nextSelectedItem.sort().join(',');
|
21361
|
+
if (onClick && !isCurrentSegmentActive) {
|
21362
|
+
onClick(entry);
|
21363
|
+
}
|
21364
|
+
setSelectedItem(isCurrentSegmentActive ? [] : nextSelectedItem);
|
21365
|
+
}
|
21366
|
+
};
|
21367
|
+
const handlePieClick = React__default.useCallback(pieId => {
|
21368
|
+
if (onClick && pieId !== undefined) {
|
21369
|
+
const pieProps = displayedData.find(item => item.id === pieId);
|
21370
|
+
onClick(pieProps);
|
21371
|
+
}
|
21372
|
+
}, [onClick, displayedData]);
|
21373
|
+
const singlePieDonutChart = displayedData.length === 1;
|
21374
|
+
const activeShapeColor = React__default.useMemo(() => {
|
21375
|
+
const getSegmentColor = item => item.reduce((colors, itemId) => {
|
21376
|
+
const visibleHoveredItem = displayedData.find(dataItem => dataItem.id === itemId);
|
21377
|
+
if (visibleHoveredItem) {
|
21378
|
+
colors[visibleHoveredItem.id] = visibleHoveredItem.color;
|
21379
|
+
}
|
21380
|
+
return colors;
|
21381
|
+
}, {});
|
21382
|
+
const hoveredSegmentColor = getSegmentColor(hoveredItem);
|
21383
|
+
const selectedSegmentColor = getSegmentColor(selectedItem);
|
21384
|
+
return legendPosition === 'bottom' || hoveredItem.length !== 0 ? hoveredSegmentColor : selectedSegmentColor;
|
21385
|
+
}, [hoveredItem, selectedItem, legendPosition]);
|
21386
|
+
if (ref.current && !radius) {
|
21387
|
+
return null;
|
21388
|
+
}
|
21389
|
+
const getActiveIndex = () => {
|
21390
|
+
if (hoveredItem.length > 0) {
|
21391
|
+
return hoveredItem.map(itemId => displayedData.findIndex(element => element.id === itemId));
|
21392
|
+
}
|
21393
|
+
return selectedItem.map(selectedItemId => displayedData.findIndex(element => element.id === selectedItemId));
|
21394
|
+
};
|
21395
|
+
const content = () => {
|
21396
|
+
const elements = React__default.Children.toArray(children).filter(child => /*#__PURE__*/React__default.isValidElement(child) && visibleItems[child.props.id]);
|
21397
|
+
return elements.length > 0 ? elements.map((child, index) => {
|
21398
|
+
var _getThemeColor;
|
21399
|
+
return /*#__PURE__*/React__default.createElement(Recharts.Cell, {
|
21400
|
+
key: `cell-${index}`,
|
21401
|
+
name: child.props.label,
|
21402
|
+
fill: (_getThemeColor = getThemeColor(child.props.color)) !== null && _getThemeColor !== void 0 ? _getThemeColor : getThemeColor('blue-300')
|
21403
|
+
});
|
21404
|
+
}) : (/*#__PURE__*/React__default.createElement(Recharts.Cell, {
|
21405
|
+
key: "empty-chart",
|
21406
|
+
name: '',
|
21407
|
+
fill: getThemeColor('grey-200')
|
21408
|
+
}));
|
21409
|
+
};
|
21410
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
21411
|
+
className: cn('relative h-full w-full', {
|
21412
|
+
[`flex `]: showLegend,
|
21413
|
+
'flex-col items-center': legendPosition === 'bottom'
|
21414
|
+
}),
|
21415
|
+
ref: ref
|
21416
|
+
}, /*#__PURE__*/React__default.createElement(CenteredLabel, {
|
21417
|
+
radius: radius,
|
21418
|
+
legendPosition: legendPosition,
|
21419
|
+
label: label,
|
21420
|
+
total: total,
|
21421
|
+
formatter: formatter,
|
21422
|
+
showLegend: showLegend
|
21423
|
+
}), /*#__PURE__*/React__default.createElement(Recharts.PieChart, {
|
21424
|
+
data: data,
|
21425
|
+
height: diameter,
|
21426
|
+
width: diameter,
|
21427
|
+
style: {
|
21428
|
+
transform: 'rotate(90deg) scale(-1,1)'
|
21429
|
+
}
|
21430
|
+
}, showTooltip ? (/*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps({
|
21431
|
+
style: {
|
21432
|
+
transform: 'rotate(90deg) scale(-1,1)'
|
21433
|
+
},
|
21434
|
+
singlePieDonutChart
|
21435
|
+
})))) : null, /*#__PURE__*/React__default.createElement(Recharts.Pie, {
|
21436
|
+
isAnimationActive: false,
|
21437
|
+
activeIndex: getActiveIndex(),
|
21438
|
+
activeShape: /*#__PURE__*/React__default.createElement(ActiveShape, {
|
21439
|
+
pieColors: activeShapeColor,
|
21440
|
+
onClick: handlePieClick
|
21441
|
+
}),
|
21442
|
+
data: displayedData.length > 0 ? displayedData : [],
|
21443
|
+
dataKey: "value",
|
21444
|
+
innerRadius: radius - HOVER_DONUT_WIDTH - DONUT_WIDTH,
|
21445
|
+
onMouseEnter: segment => displayedData.length > 0 && setHoveredItem([segment.id]),
|
21446
|
+
onMouseLeave: () => setHoveredItem([]),
|
21447
|
+
outerRadius: radius - HOVER_DONUT_WIDTH,
|
21448
|
+
paddingAngle: 2,
|
21449
|
+
// Prevents the pie group element from being focusable
|
21450
|
+
rootTabIndex: -1
|
21451
|
+
}, content())), showLegend && (/*#__PURE__*/React__default.createElement(Legend$1, {
|
21452
|
+
data: data,
|
21453
|
+
visibleItems: visibleItems,
|
21454
|
+
onClick: handleLegendClick,
|
21455
|
+
total: total,
|
21456
|
+
setHoveredItem: setHoveredItem,
|
21457
|
+
label: label,
|
21458
|
+
legendPosition: legendPosition,
|
21459
|
+
hoveredItem: hoveredItem,
|
21460
|
+
selectedItem: selectedItem,
|
21461
|
+
formatter: formatter
|
21462
|
+
})));
|
21463
|
+
};
|
21464
|
+
DonutChart.Segment = Segment;
|
21465
|
+
|
21466
|
+
const Line$1 = _ => null;
|
21467
|
+
const LineChart = function LineChart(externalProps) {
|
21468
|
+
const {
|
21469
|
+
children,
|
21470
|
+
data,
|
21471
|
+
formatter,
|
21472
|
+
...props
|
21473
|
+
} = externalProps;
|
21474
|
+
const [hoveredLine, setHoveredLine] = React.useState(null);
|
21475
|
+
const [activeLines, setActiveLines] = React.useState(() => {
|
21476
|
+
const keys = {};
|
21477
|
+
React__default.Children.forEach(children, child => {
|
21478
|
+
keys[child.props.accessor] = true;
|
21479
|
+
});
|
21480
|
+
return keys;
|
21481
|
+
});
|
21482
|
+
const handleLegendClick = entry => {
|
21483
|
+
setHoveredLine(null);
|
21484
|
+
setActiveLines({
|
21485
|
+
...activeLines,
|
21486
|
+
[entry.dataKey]: !activeLines[entry.dataKey]
|
21487
|
+
});
|
21488
|
+
};
|
21489
|
+
return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.LineChart, {
|
21490
|
+
data: data,
|
21491
|
+
margin: {
|
21492
|
+
top: 10,
|
21493
|
+
right: 0,
|
21494
|
+
left: -25,
|
21495
|
+
bottom: 0
|
21496
|
+
}
|
21497
|
+
}, /*#__PURE__*/React__default.createElement(Recharts.CartesianGrid, Object.assign({}, getCartesianGridProps())), /*#__PURE__*/React__default.createElement(Recharts.XAxis, Object.assign({}, getXAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.YAxis, Object.assign({}, getYAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.Legend, Object.assign({}, getLegendProps({
|
21498
|
+
onClick: handleLegendClick,
|
21499
|
+
onMouseEnter: entry => setHoveredLine(entry.dataKey),
|
21500
|
+
onMouseLeave: () => setHoveredLine(null),
|
21501
|
+
activeItems: activeLines
|
21502
|
+
}))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
|
21503
|
+
formatter: formatter
|
21504
|
+
})), React__default.Children.map(children, child => {
|
21505
|
+
var _child$props$color, _child$props$color2;
|
21506
|
+
return /*#__PURE__*/React__default.createElement(Recharts.Line, {
|
21507
|
+
activeDot: {
|
21508
|
+
fill: getThemeColor((_child$props$color = child.props.color) !== null && _child$props$color !== void 0 ? _child$props$color : 'blue-300')
|
21509
|
+
},
|
21510
|
+
dataKey: child.props.accessor,
|
21511
|
+
isAnimationActive: false,
|
21512
|
+
dot: false,
|
21513
|
+
name: child.props.label,
|
21514
|
+
stroke: getThemeColor((_child$props$color2 = child.props.color) !== null && _child$props$color2 !== void 0 ? _child$props$color2 : 'blue-300'),
|
21515
|
+
strokeWidth: 2,
|
21516
|
+
hide: !activeLines[child.props.accessor],
|
21517
|
+
opacity: hoveredLine && child.props.accessor !== hoveredLine ? 0.3 : 1
|
21518
|
+
});
|
21519
|
+
})));
|
21520
|
+
};
|
21521
|
+
LineChart.Line = Line$1;
|
21522
|
+
|
20080
21523
|
const Button$4 = /*#__PURE__*/React__default.forwardRef(function Button(props, ref) {
|
20081
21524
|
const {
|
20082
21525
|
...attributes
|
@@ -20349,15 +21792,13 @@ const AgreementDisplay = props => {
|
|
20349
21792
|
}));
|
20350
21793
|
};
|
20351
21794
|
|
20352
|
-
const Container$1 =
|
20353
|
-
children
|
20354
|
-
}) => {
|
21795
|
+
const Container$1 = props => {
|
20355
21796
|
return /*#__PURE__*/React__default.createElement("div", {
|
20356
21797
|
className: "-ml-2 flex flex-shrink-0 flex-grow-0 items-center gap-2 pr-2 xl:ml-auto xl:w-64",
|
20357
21798
|
"data-taco": "header-agreements"
|
20358
21799
|
}, /*#__PURE__*/React__default.createElement("span", {
|
20359
21800
|
className: "hidden h-8 w-px flex-shrink-0 flex-grow-0 bg-white/[0.3] xl:flex"
|
20360
|
-
}), children);
|
21801
|
+
}), props.children);
|
20361
21802
|
};
|
20362
21803
|
function AgreementSelector(props) {
|
20363
21804
|
const {
|
@@ -20823,10 +22264,12 @@ const useOnClickOutside = (ref, callback) => {
|
|
20823
22264
|
exports.Accordion = Accordion;
|
20824
22265
|
exports.Alert = Alert;
|
20825
22266
|
exports.AlertDialog = AlertDialog;
|
22267
|
+
exports.AreaChart = AreaChart;
|
20826
22268
|
exports.Backdrop = Backdrop;
|
20827
22269
|
exports.Badge = Badge;
|
20828
22270
|
exports.BadgeIcon = BadgeIcon;
|
20829
22271
|
exports.Banner = Banner;
|
22272
|
+
exports.BarChart = BarChart;
|
20830
22273
|
exports.Base = Base;
|
20831
22274
|
exports.Button = Button$1;
|
20832
22275
|
exports.Calendar = Calendar$1;
|
@@ -20837,6 +22280,7 @@ exports.Combobox = Combobox;
|
|
20837
22280
|
exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
|
20838
22281
|
exports.Datepicker = Datepicker;
|
20839
22282
|
exports.Dialog = Dialog;
|
22283
|
+
exports.DonutChart = DonutChart;
|
20840
22284
|
exports.Drawer = Drawer;
|
20841
22285
|
exports.Field = Field;
|
20842
22286
|
exports.Form = Form;
|
@@ -20848,6 +22292,7 @@ exports.Icon = Icon;
|
|
20848
22292
|
exports.IconButton = IconButton;
|
20849
22293
|
exports.Input = Input;
|
20850
22294
|
exports.Layout = Layout$1;
|
22295
|
+
exports.LineChart = LineChart;
|
20851
22296
|
exports.List = List$1;
|
20852
22297
|
exports.Listbox = Listbox;
|
20853
22298
|
exports.LocalizationContext = LocalizationContext;
|