@economic/taco 2.45.0-alpha.1 → 2.45.0-alpha.11
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/Create.js +10 -11
- package/dist/esm/packages/taco/src/components/Select2/components/Create.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 +9 -40
- 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 +75 -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 +8 -8
- 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/Header/components/Menu.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +5 -2
- 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 +13 -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 +20 -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 +2313 -864
- 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 typeof event.detail === 'object'; // 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,14 @@ 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
|
+
keepPinnedRows: false,
|
10584
|
+
enableRowPinning: true,
|
10434
10585
|
enableRowSelection: reactTableEnableRowSelection !== null && reactTableEnableRowSelection !== void 0 ? reactTableEnableRowSelection : false,
|
10435
10586
|
enableSorting: (_options$enableSortin = options.enableSorting) !== null && _options$enableSortin !== void 0 ? _options$enableSortin : false,
|
10436
10587
|
// models for default features
|
10437
10588
|
getExpandedRowModel: reactTable.getExpandedRowModel(),
|
10438
10589
|
getGroupedRowModel: reactTable.getGroupedRowModel(),
|
10590
|
+
getRowId,
|
10439
10591
|
groupedColumnMode: false
|
10440
10592
|
};
|
10441
10593
|
if (tableOptions.enableColumnResizing) {
|
@@ -10515,6 +10667,7 @@ const DEFAULT_PRESET = {
|
|
10515
10667
|
enableColumnHiding: false,
|
10516
10668
|
enableColumnResizing: false,
|
10517
10669
|
enableRowExpansion: false,
|
10670
|
+
enableRowExpansionAll: true,
|
10518
10671
|
enableRowSelection: false,
|
10519
10672
|
// custom -- common between all table types
|
10520
10673
|
enableColumnOrdering: false,
|
@@ -10541,6 +10694,7 @@ const presets = {
|
|
10541
10694
|
enableColumnHiding: true,
|
10542
10695
|
enableColumnResizing: true,
|
10543
10696
|
enableRowExpansion: true,
|
10697
|
+
enableRowExpansionAll: true,
|
10544
10698
|
enableRowSelection: true,
|
10545
10699
|
// custom -- common between all table types
|
10546
10700
|
enableColumnOrdering: true,
|
@@ -10566,6 +10720,7 @@ const presets = {
|
|
10566
10720
|
enableColumnHiding: false,
|
10567
10721
|
enableColumnResizing: false,
|
10568
10722
|
enableRowExpansion: true,
|
10723
|
+
enableRowExpansionAll: true,
|
10569
10724
|
enableRowSelection: true,
|
10570
10725
|
// custom -- common between all table types
|
10571
10726
|
enableColumnOrdering: false,
|
@@ -10591,6 +10746,7 @@ const presets = {
|
|
10591
10746
|
enableColumnHiding: false,
|
10592
10747
|
enableColumnResizing: false,
|
10593
10748
|
enableRowExpansion: true,
|
10749
|
+
enableRowExpansionAll: true,
|
10594
10750
|
enableRowSelection: false,
|
10595
10751
|
// custom -- common between all table types
|
10596
10752
|
enableColumnOrdering: false,
|
@@ -10608,7 +10764,7 @@ const presets = {
|
|
10608
10764
|
}
|
10609
10765
|
};
|
10610
10766
|
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;
|
10767
|
+
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
10768
|
const presetOptions = props.preset ? presets[props.preset] : DEFAULT_PRESET;
|
10613
10769
|
const enableRowActions = (_props$enableRowActio = props.enableRowActions) !== null && _props$enableRowActio !== void 0 ? _props$enableRowActio : presetOptions.enableRowActions;
|
10614
10770
|
const enableRowClick = (_props$enableRowClick = props.enableRowClick) !== null && _props$enableRowClick !== void 0 ? _props$enableRowClick : presetOptions.enableRowClick;
|
@@ -10616,6 +10772,7 @@ function getTableFeaturePreset(props) {
|
|
10616
10772
|
const enableRowDrop = (_props$enableRowDrop = props.enableRowDrop) !== null && _props$enableRowDrop !== void 0 ? _props$enableRowDrop : presetOptions.enableRowDrop;
|
10617
10773
|
const enableRowGoto = (_props$enableRowGoto = props.enableRowGoto) !== null && _props$enableRowGoto !== void 0 ? _props$enableRowGoto : presetOptions.enableRowGoto;
|
10618
10774
|
const enableRowExpansion = (_props$enableRowExpan = props.enableRowExpansion) !== null && _props$enableRowExpan !== void 0 ? _props$enableRowExpan : presetOptions.enableRowExpansion;
|
10775
|
+
const enableRowExpansionAll = (_props$enableRowExpan2 = props.enableRowExpansionAll) !== null && _props$enableRowExpan2 !== void 0 ? _props$enableRowExpan2 : presetOptions.enableRowExpansionAll;
|
10619
10776
|
const enableRowSelection = (_props$enableRowSelec = props.enableRowSelection) !== null && _props$enableRowSelec !== void 0 ? _props$enableRowSelec : presetOptions.enableRowSelection;
|
10620
10777
|
return {
|
10621
10778
|
// react-table built-in
|
@@ -10640,6 +10797,7 @@ function getTableFeaturePreset(props) {
|
|
10640
10797
|
enableRowDrag: enableRowDrag && !!props.onRowDrag,
|
10641
10798
|
enableRowDrop: enableRowDrop && !!props.onRowDrop,
|
10642
10799
|
enableRowGoto: enableRowGoto && !!props.onRowGoto,
|
10800
|
+
enableRowExpansionAll: enableRowExpansion && enableRowExpansionAll && !!props.rowExpansionRenderer,
|
10643
10801
|
enableRowHeight: (_props$enableRowHeigh = props.enableRowHeight) !== null && _props$enableRowHeigh !== void 0 ? _props$enableRowHeigh : presetOptions.enableRowHeight,
|
10644
10802
|
enableSaveSettings: (_props$enableSaveSett = props.enableSaveSettings) !== null && _props$enableSaveSett !== void 0 ? _props$enableSaveSett : presetOptions.enableSaveSettings
|
10645
10803
|
};
|
@@ -10884,9 +11042,10 @@ function useTableRowClick(isEnabled = false, onRowClick) {
|
|
10884
11042
|
};
|
10885
11043
|
}
|
10886
11044
|
|
10887
|
-
function useTableRowExpansion(isEnabled = false, rowExpansionRenderer) {
|
11045
|
+
function useTableRowExpansion(isEnabled = false, canExpandAll = true, rowExpansionRenderer) {
|
10888
11046
|
return {
|
10889
11047
|
isEnabled,
|
11048
|
+
canExpandAll,
|
10890
11049
|
rowExpansionRenderer: isEnabled ? rowExpansionRenderer : undefined
|
10891
11050
|
};
|
10892
11051
|
}
|
@@ -10917,6 +11076,7 @@ function useTableRowHeight(isEnabled = false, defaultRowHeight = 'medium') {
|
|
10917
11076
|
function useTableRowSelection(isEnabled = false) {
|
10918
11077
|
const lastSelectedRowIndex = React__default.useRef();
|
10919
11078
|
const onKeyDown = React__default.useCallback((event, table) => {
|
11079
|
+
var _event$target;
|
10920
11080
|
if (!isEnabled || !table.options.enableRowSelection || event.defaultPrevented) {
|
10921
11081
|
return;
|
10922
11082
|
}
|
@@ -10931,7 +11091,7 @@ function useTableRowSelection(isEnabled = false) {
|
|
10931
11091
|
(_rows$rowActiveIndex2 = rows[rowActiveIndex]) === null || _rows$rowActiveIndex2 === void 0 ? void 0 : _rows$rowActiveIndex2.toggleSelected();
|
10932
11092
|
}
|
10933
11093
|
return;
|
10934
|
-
} else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
|
11094
|
+
} 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
11095
|
event.preventDefault();
|
10936
11096
|
table.toggleAllRowsSelected();
|
10937
11097
|
return;
|
@@ -11336,10 +11496,17 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
11336
11496
|
}, invalidate];
|
11337
11497
|
}
|
11338
11498
|
|
11339
|
-
function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE) {
|
11499
|
+
function useTableServerLoading(length, data, loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE) {
|
11340
11500
|
const isEnabled = !!loadPage && !!loadAll;
|
11341
11501
|
const [isReady, setReady] = React__default.useState(false);
|
11342
|
-
const [
|
11502
|
+
const [loading, setLoading] = React__default.useState(false);
|
11503
|
+
const hasLoadedAll = React__default.useMemo(() => {
|
11504
|
+
var _data$some;
|
11505
|
+
if (data.length !== length || !!((_data$some = data.some) !== null && _data$some !== void 0 && _data$some.call(data, x => x === undefined))) {
|
11506
|
+
return false;
|
11507
|
+
}
|
11508
|
+
return true;
|
11509
|
+
}, [data, length]);
|
11343
11510
|
let _loadPage;
|
11344
11511
|
let _loadAll;
|
11345
11512
|
let _loadAllIfNeeded;
|
@@ -11364,9 +11531,9 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
|
|
11364
11531
|
try {
|
11365
11532
|
const _temp2 = function () {
|
11366
11533
|
if (typeof loadAll === 'function') {
|
11367
|
-
|
11534
|
+
setLoading(true);
|
11368
11535
|
return Promise.resolve(loadAll(...args)).then(function () {
|
11369
|
-
|
11536
|
+
setLoading(false);
|
11370
11537
|
setReady(true);
|
11371
11538
|
});
|
11372
11539
|
}
|
@@ -11379,7 +11546,7 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
|
|
11379
11546
|
_loadAllIfNeeded = function (...args) {
|
11380
11547
|
try {
|
11381
11548
|
const _temp3 = function () {
|
11382
|
-
if (
|
11549
|
+
if (!hasLoadedAll) {
|
11383
11550
|
var _loadAll2;
|
11384
11551
|
return Promise.resolve((_loadAll2 = _loadAll) === null || _loadAll2 === void 0 ? void 0 : _loadAll2(...args)).then(function () {});
|
11385
11552
|
}
|
@@ -11396,7 +11563,7 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
|
|
11396
11563
|
loadPage: _loadPage,
|
11397
11564
|
loadAll: _loadAll,
|
11398
11565
|
loadAllIfNeeded: _loadAllIfNeeded,
|
11399
|
-
|
11566
|
+
loading,
|
11400
11567
|
pageSize
|
11401
11568
|
};
|
11402
11569
|
}
|
@@ -11469,7 +11636,7 @@ function useLazyEffect(effect, deps) {
|
|
11469
11636
|
const readyRef = React__default.useRef(false);
|
11470
11637
|
React__default.useEffect(() => {
|
11471
11638
|
if (readyRef.current) {
|
11472
|
-
effect();
|
11639
|
+
return effect();
|
11473
11640
|
} else {
|
11474
11641
|
readyRef.current = true;
|
11475
11642
|
}
|
@@ -11511,7 +11678,8 @@ function useTableFontSizeListener(table) {
|
|
11511
11678
|
table.setColumnSizing(sizes => {
|
11512
11679
|
return Object.fromEntries(Object.entries(sizes).map(([columnName, prevColumnSize]) => {
|
11513
11680
|
var _column$columnDef$min;
|
11514
|
-
|
11681
|
+
// table.getColumn(columName) throw error in strict dev mode. Related thread: https://github.com/TanStack/table/discussions/5505
|
11682
|
+
const column = table.getAllColumns().find(x => x.id === columnName);
|
11515
11683
|
if (isInternalColumn(columnName)) {
|
11516
11684
|
var _column$getSize;
|
11517
11685
|
return [columnName, (_column$getSize = column === null || column === void 0 ? void 0 : column.getSize()) !== null && _column$getSize !== void 0 ? _column$getSize : prevColumnSize];
|
@@ -11590,7 +11758,7 @@ function useTableSearchListener(table, onChangeSearch) {
|
|
11590
11758
|
onChangeSearch(query);
|
11591
11759
|
}
|
11592
11760
|
}
|
11593
|
-
}, [meta.server.
|
11761
|
+
}, [meta.server.loading, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), onChangeSearch]);
|
11594
11762
|
}
|
11595
11763
|
|
11596
11764
|
function useTableSettingsListener(table, onChangeSettings) {
|
@@ -11726,13 +11894,13 @@ function useTableManager(props, meta, internalColumns) {
|
|
11726
11894
|
const rowClick = useTableRowClick(options.enableRowClick, props.onRowClick);
|
11727
11895
|
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
11896
|
const rowDrop = useTableRowDrop(options.enableRowDrop, props.onRowDrop);
|
11729
|
-
const rowExpansion = useTableRowExpansion(options.enableRowExpansion, props.rowExpansionRenderer);
|
11897
|
+
const rowExpansion = useTableRowExpansion(options.enableRowExpansion, options.enableRowExpansionAll, props.rowExpansionRenderer);
|
11730
11898
|
const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);
|
11731
11899
|
const rowGroups = useTableRowGroups(props.rowActionsForGroup);
|
11732
11900
|
const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);
|
11733
11901
|
const rowSelection = useTableRowSelection(!!options.enableRowSelection);
|
11734
11902
|
const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);
|
11735
|
-
const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);
|
11903
|
+
const server = useTableServerLoading(length, data, props.loadPage, props.loadAll, props.pageSize);
|
11736
11904
|
// TODO: memoise
|
11737
11905
|
// convert jsx column components into valid table columns
|
11738
11906
|
const {
|
@@ -11768,7 +11936,7 @@ function useTableManager(props, meta, internalColumns) {
|
|
11768
11936
|
rowDrag,
|
11769
11937
|
rowDrop: rowDrop,
|
11770
11938
|
rowExpansion: rowExpansion,
|
11771
|
-
|
11939
|
+
rowIdentityAccessor: props.rowIdentityAccessor,
|
11772
11940
|
rowGoto,
|
11773
11941
|
rowGroups: rowGroups,
|
11774
11942
|
rowHeight,
|
@@ -12105,6 +12273,8 @@ const Skeleton = /*#__PURE__*/React__default.forwardRef(function Skeleton(props,
|
|
12105
12273
|
});
|
12106
12274
|
|
12107
12275
|
const RowContext = /*#__PURE__*/React__default.createContext({
|
12276
|
+
hideInternalColumns: false,
|
12277
|
+
hideRowActions: false,
|
12108
12278
|
isHovered: false,
|
12109
12279
|
rowIndex: -1
|
12110
12280
|
});
|
@@ -12114,6 +12284,8 @@ function Row(props) {
|
|
12114
12284
|
const {
|
12115
12285
|
renderer: RowRenderer,
|
12116
12286
|
cellRenderer: CellRenderer,
|
12287
|
+
hideInternalColumns = false,
|
12288
|
+
hideRowActions = false,
|
12117
12289
|
...displayRowProps
|
12118
12290
|
} = props;
|
12119
12291
|
const tableMeta = props.table.options.meta;
|
@@ -12121,8 +12293,10 @@ function Row(props) {
|
|
12121
12293
|
// context - it must be here for cells to read it, since they render alongside the row inside DisplayRow
|
12122
12294
|
const contextValue = React__default.useMemo(() => ({
|
12123
12295
|
isHovered,
|
12124
|
-
rowIndex: props.index
|
12125
|
-
|
12296
|
+
rowIndex: props.index,
|
12297
|
+
hideInternalColumns,
|
12298
|
+
hideRowActions
|
12299
|
+
}), [isHovered, props.index, hideInternalColumns, hideRowActions]);
|
12126
12300
|
if (props.row.original === undefined) {
|
12127
12301
|
return /*#__PURE__*/React__default.createElement(SkeletonRow, Object.assign({}, props));
|
12128
12302
|
}
|
@@ -12133,11 +12307,35 @@ function Row(props) {
|
|
12133
12307
|
})));
|
12134
12308
|
}
|
12135
12309
|
|
12136
|
-
|
12137
|
-
|
12310
|
+
// scroll padding end is designed to always show half of the next row
|
12311
|
+
function getScrollPaddingEndOffset(table) {
|
12312
|
+
const tableMeta = table.options.meta;
|
12313
|
+
let offset = 2;
|
12314
|
+
if (tableMeta.footer.isEnabled) {
|
12315
|
+
offset += 1;
|
12316
|
+
}
|
12317
|
+
if (table.getHeaderGroups().length > 1) {
|
12318
|
+
offset += table.getHeaderGroups().length - 1;
|
12319
|
+
}
|
12320
|
+
let height = ROW_HEIGHT_ESTIMATES.medium * offset;
|
12321
|
+
const bottomRows = table.getBottomRows();
|
12322
|
+
if (bottomRows.length) {
|
12323
|
+
// 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)
|
12324
|
+
height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;
|
12325
|
+
}
|
12326
|
+
return height;
|
12327
|
+
}
|
12328
|
+
// scroll padding end is designed to always show half of the next row
|
12329
|
+
function getPaddingEndOffset(table, options) {
|
12330
|
+
var _table$getBottomRows, _options$virtualiserP;
|
12331
|
+
const bottomRows = (_table$getBottomRows = table.getBottomRows()) !== null && _table$getBottomRows !== void 0 ? _table$getBottomRows : [];
|
12332
|
+
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;
|
12333
|
+
}
|
12334
|
+
function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, options) {
|
12335
|
+
var _table$getState$group, _table$getCenterRows, _virtualItems$padding, _virtualItems$padding2, _virtualItems$padding3, _ref, _virtualItems;
|
12138
12336
|
const tableMeta = table.options.meta;
|
12139
|
-
const rows = table.getRowModel().rows;
|
12140
12337
|
const isTableRowGrouped = !!((_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length);
|
12338
|
+
const rows = (_table$getCenterRows = table.getCenterRows()) !== null && _table$getCenterRows !== void 0 ? _table$getCenterRows : [];
|
12141
12339
|
// expanded rows
|
12142
12340
|
const {
|
12143
12341
|
createRowMeasurer,
|
@@ -12147,9 +12345,6 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
|
|
12147
12345
|
const rangeExtractor = useRowGroupVirtualisation(table);
|
12148
12346
|
// account for thead and tfoot in the scroll area - both are always medium row height
|
12149
12347
|
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
12348
|
const virtualiser = reactVirtual.useVirtualizer({
|
12154
12349
|
count: rows.length,
|
12155
12350
|
estimateSize,
|
@@ -12158,7 +12353,8 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
|
|
12158
12353
|
rangeExtractor,
|
12159
12354
|
// correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list
|
12160
12355
|
scrollPaddingStart,
|
12161
|
-
scrollPaddingEnd:
|
12356
|
+
scrollPaddingEnd: getScrollPaddingEndOffset(table),
|
12357
|
+
paddingEnd: getPaddingEndOffset(table, options)
|
12162
12358
|
});
|
12163
12359
|
const totalSize = virtualiser.getTotalSize();
|
12164
12360
|
const virtualItems = virtualiser.getVirtualItems();
|
@@ -12198,12 +12394,16 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
|
|
12198
12394
|
// rendered output
|
12199
12395
|
let style = {};
|
12200
12396
|
let content = null;
|
12201
|
-
|
12397
|
+
// bottom rows aren't virtualised (they're sticky) but we need to set the height
|
12398
|
+
if (rows.length || table.getBottomRows().length) {
|
12202
12399
|
style = {
|
12203
12400
|
height: totalSize,
|
12204
12401
|
paddingBottom,
|
12205
12402
|
paddingTop
|
12206
12403
|
};
|
12404
|
+
}
|
12405
|
+
// only render non sticky rows
|
12406
|
+
if (rows.length) {
|
12207
12407
|
content = virtualItems.map(virtualRow => {
|
12208
12408
|
// 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
12409
|
if (!virtualRow) {
|
@@ -12315,12 +12515,14 @@ function Actions$1(props) {
|
|
12315
12515
|
actionsLength,
|
12316
12516
|
data,
|
12317
12517
|
isActiveRow,
|
12318
|
-
rowId
|
12518
|
+
rowId,
|
12519
|
+
table
|
12319
12520
|
} = props;
|
12320
12521
|
const {
|
12321
12522
|
texts
|
12322
12523
|
} = useLocalization();
|
12323
|
-
|
12524
|
+
// we don't want to document passing table, so it isn't on the type
|
12525
|
+
const visibleActions = actions.map(action => action(data, rowId, table)).filter(action => !!action);
|
12324
12526
|
const actionsOnRow = visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);
|
12325
12527
|
const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);
|
12326
12528
|
const className = cn('flex justify-end text-right bg-[inherit] shadow-[-6px_0px_6px_var(--table-row-actions-shadow)] print:hidden');
|
@@ -12359,6 +12561,7 @@ const Cell = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
|
|
12359
12561
|
table
|
12360
12562
|
} = context;
|
12361
12563
|
const {
|
12564
|
+
hideRowActions,
|
12362
12565
|
isHovered,
|
12363
12566
|
rowIndex
|
12364
12567
|
} = React__default.useContext(RowContext);
|
@@ -12368,15 +12571,15 @@ const Cell = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
|
|
12368
12571
|
const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
|
12369
12572
|
const isResizingColumn = !!table.getState().columnSizingInfo.isResizingColumn;
|
12370
12573
|
const isHoverStatePaused = tableMeta.rowActive.isHoverStatePaused;
|
12371
|
-
|
12372
|
-
|
12373
|
-
if (actions !== null && actions !== void 0 && actions.length && (isActiveRow || isHovered && !isHoverStatePaused && !isResizingColumn)) {
|
12574
|
+
const isRowGrouped = row.getIsGrouped();
|
12575
|
+
if (!hideRowActions && !isRowGrouped && actions !== null && actions !== void 0 && actions.length && (isActiveRow || isHovered && !isHoverStatePaused && !isResizingColumn)) {
|
12374
12576
|
return /*#__PURE__*/React__default.createElement(Actions$1, {
|
12375
12577
|
actions: actions,
|
12376
12578
|
actionsLength: actionsLength,
|
12377
12579
|
data: row.original,
|
12378
12580
|
isActiveRow: isActiveRow,
|
12379
|
-
rowId: row.id
|
12581
|
+
rowId: row.id,
|
12582
|
+
table: table
|
12380
12583
|
});
|
12381
12584
|
}
|
12382
12585
|
return null;
|
@@ -12400,6 +12603,12 @@ function Cell$1() {
|
|
12400
12603
|
const {
|
12401
12604
|
texts
|
12402
12605
|
} = useLocalization();
|
12606
|
+
const {
|
12607
|
+
hideInternalColumns
|
12608
|
+
} = React__default.useContext(RowContext);
|
12609
|
+
if (hideInternalColumns) {
|
12610
|
+
return null;
|
12611
|
+
}
|
12403
12612
|
return /*#__PURE__*/React__default.createElement(Icon, {
|
12404
12613
|
"aria-label": texts.table.columns.drag.tooltip,
|
12405
12614
|
name: "drag",
|
@@ -12427,6 +12636,10 @@ function Header$3(context) {
|
|
12427
12636
|
const {
|
12428
12637
|
table
|
12429
12638
|
} = context;
|
12639
|
+
const tableMeta = table.options.meta;
|
12640
|
+
if (!tableMeta.rowExpansion.canExpandAll) {
|
12641
|
+
return null;
|
12642
|
+
}
|
12430
12643
|
const isSomeRowsExpanded = table.getIsSomeRowsExpanded();
|
12431
12644
|
const handleClick = event => {
|
12432
12645
|
event.stopPropagation();
|
@@ -12448,7 +12661,13 @@ function Cell$2(context) {
|
|
12448
12661
|
const {
|
12449
12662
|
texts
|
12450
12663
|
} = useLocalization();
|
12664
|
+
const {
|
12665
|
+
hideInternalColumns
|
12666
|
+
} = React__default.useContext(RowContext);
|
12451
12667
|
const tableMeta = context.table.options.meta;
|
12668
|
+
if (hideInternalColumns) {
|
12669
|
+
return null;
|
12670
|
+
}
|
12452
12671
|
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
12672
|
if (hasExpandedRow) {
|
12454
12673
|
const isActiveRow = tableMeta.rowActive.rowActiveIndex === context.row.index;
|
@@ -12519,7 +12738,7 @@ function Header$4(context) {
|
|
12519
12738
|
className: "hover:border-blue !-mt-px",
|
12520
12739
|
checked: isAllRowsSelected,
|
12521
12740
|
indeterminate: isSomeRowsSelected && !isAllRowsSelected,
|
12522
|
-
loading: tableMeta.server.
|
12741
|
+
loading: tableMeta.server.loading,
|
12523
12742
|
onChange: handleChange
|
12524
12743
|
}));
|
12525
12744
|
}
|
@@ -12538,10 +12757,11 @@ function Cell$3(context) {
|
|
12538
12757
|
table
|
12539
12758
|
} = context;
|
12540
12759
|
const {
|
12760
|
+
hideInternalColumns,
|
12541
12761
|
rowIndex
|
12542
12762
|
} = React__default.useContext(RowContext);
|
12543
12763
|
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()) {
|
12764
|
+
if (hideInternalColumns || table.options.enableGrouping && (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length && !row.getIsGrouped()) {
|
12545
12765
|
return null;
|
12546
12766
|
}
|
12547
12767
|
const isSelected = row.getIsGrouped() ? row.getIsAllSubRowsSelected() : row.getIsSelected();
|
@@ -12626,13 +12846,13 @@ const INTERNAL_RENDERERS = {
|
|
12626
12846
|
rowExpansion: renderer$2,
|
12627
12847
|
rowSelection: renderer$3
|
12628
12848
|
};
|
12629
|
-
function useTable(props, externalRef, renderers, meta) {
|
12849
|
+
function useTable(props, externalRef, renderers, meta, options) {
|
12630
12850
|
// create a ref and merge with the consumer's ref
|
12631
12851
|
const ref = useMergedRef(externalRef);
|
12632
12852
|
// configure the table
|
12633
12853
|
const manager = useTableManager(props, meta, INTERNAL_RENDERERS);
|
12634
12854
|
// configure the virtualised renderer
|
12635
|
-
const renderer = useTableRenderer(renderers, manager.instance, ref, props.defaultRowActiveIndex);
|
12855
|
+
const renderer = useTableRenderer(renderers, manager.instance, ref, props.defaultRowActiveIndex, options);
|
12636
12856
|
// configure dynamic styling
|
12637
12857
|
const {
|
12638
12858
|
style,
|
@@ -12733,7 +12953,10 @@ function GroupedCell(props) {
|
|
12733
12953
|
index,
|
12734
12954
|
isHighlighted
|
12735
12955
|
} = props;
|
12736
|
-
const
|
12956
|
+
const {
|
12957
|
+
table
|
12958
|
+
} = cell.getContext();
|
12959
|
+
const tableMeta = table.options.meta;
|
12737
12960
|
const columnMeta = cell.column.columnDef.meta;
|
12738
12961
|
const attributes = getCellAttributes(cell, index, isHighlighted);
|
12739
12962
|
const {
|
@@ -12742,7 +12965,9 @@ function GroupedCell(props) {
|
|
12742
12965
|
} = React__default.useContext(RowContext);
|
12743
12966
|
const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
|
12744
12967
|
const canShowActions = isActiveRow || isHovered && !tableMeta.rowActive.isHoverStatePaused;
|
12745
|
-
|
12968
|
+
// Set colSpan based on the count of visible cells, including '__actions' and non-internal columns, so that
|
12969
|
+
// rowGroupActions aligns with rowActions.
|
12970
|
+
const colSpan = cell.row.getVisibleCells().filter(c => c.column.id === '__actions' || !isInternalColumn(c.column.id)).length - 1;
|
12746
12971
|
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
12972
|
const subRows = cell.getContext().row.subRows.map(row => row.original);
|
12748
12973
|
return /*#__PURE__*/React__default.createElement(MemoedGroupedCell, Object.assign({}, attributes, {
|
@@ -12751,7 +12976,8 @@ function GroupedCell(props) {
|
|
12751
12976
|
colSpan: colSpan,
|
12752
12977
|
rowActions: tableMeta.rowGroups.rowActionsForGroup,
|
12753
12978
|
rowId: cell.row.id,
|
12754
|
-
subRows: subRows
|
12979
|
+
subRows: subRows,
|
12980
|
+
table: table
|
12755
12981
|
}), content);
|
12756
12982
|
}
|
12757
12983
|
const MemoedGroupedCell = /*#__PURE__*/React__default.memo(function MemoedGroupedCell(props) {
|
@@ -12763,22 +12989,29 @@ const MemoedGroupedCell = /*#__PURE__*/React__default.memo(function MemoedGroupe
|
|
12763
12989
|
rowActions,
|
12764
12990
|
rowId,
|
12765
12991
|
subRows,
|
12992
|
+
table,
|
12766
12993
|
...attributes
|
12767
12994
|
} = props;
|
12768
|
-
return
|
12769
|
-
|
12770
|
-
|
12771
|
-
|
12772
|
-
|
12773
|
-
|
12774
|
-
|
12775
|
-
|
12776
|
-
|
12777
|
-
|
12778
|
-
|
12779
|
-
|
12780
|
-
|
12781
|
-
|
12995
|
+
return (
|
12996
|
+
/*#__PURE__*/
|
12997
|
+
// pr-1 is needed to align group row actions with row actions in sibling rows, if present
|
12998
|
+
React__default.createElement("td", Object.assign({}, attributes, {
|
12999
|
+
className: "!pr-1",
|
13000
|
+
ref: cellRef,
|
13001
|
+
style: {
|
13002
|
+
gridColumn: `span ${colSpan} / span ${colSpan}`
|
13003
|
+
}
|
13004
|
+
}), /*#__PURE__*/React__default.createElement("span", {
|
13005
|
+
className: "grow"
|
13006
|
+
}, children), rowActions !== null && rowActions !== void 0 && rowActions.length && canShowActions ? (/*#__PURE__*/React__default.createElement(Actions$1, {
|
13007
|
+
actions: rowActions,
|
13008
|
+
actionsLength: 4,
|
13009
|
+
data: subRows,
|
13010
|
+
isActiveRow: true,
|
13011
|
+
rowId: rowId,
|
13012
|
+
table: table
|
13013
|
+
})) : null)
|
13014
|
+
);
|
12782
13015
|
});
|
12783
13016
|
|
12784
13017
|
function Cell$4(props) {
|
@@ -12917,14 +13150,17 @@ const DisplayRow = /*#__PURE__*/React__default.memo(function DisplayRow(props) {
|
|
12917
13150
|
const expansionRef = React__default.useRef(null);
|
12918
13151
|
const isExpanded = !!attributes['data-row-expanded'];
|
12919
13152
|
useSetVirtualisedRowHeight(measureRow, ref.current, expansionRef.current, isExpanded);
|
12920
|
-
const className = cn('group/row', {
|
13153
|
+
const className = cn('group/row', otherAttributes.className, {
|
12921
13154
|
'hover:cursor-grab': tableMeta.rowDrag.isEnabled && typeof attributes.onClick !== 'function',
|
12922
13155
|
'hover:cursor-pointer': typeof attributes.onClick === 'function'
|
12923
13156
|
});
|
13157
|
+
const isGrouped = row.getIsGrouped();
|
12924
13158
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("tr", Object.assign({}, attributes, {
|
12925
13159
|
className: className,
|
12926
13160
|
ref: ref
|
12927
|
-
}), children, row.getVisibleCells()
|
13161
|
+
}), children, row.getVisibleCells()
|
13162
|
+
// Filter out the row actions cell from rendering in Grouped Row
|
13163
|
+
.filter(cell => !(isGrouped && cell.column.id === '__actions')).map((cell, cellIndex) => (/*#__PURE__*/React__default.createElement(Cell$4, {
|
12928
13164
|
key: cell.id,
|
12929
13165
|
cell: cell,
|
12930
13166
|
index: cellIndex,
|
@@ -13310,7 +13546,9 @@ function HeaderMenu(props) {
|
|
13310
13546
|
return /*#__PURE__*/React__default.createElement(IconButton, {
|
13311
13547
|
className: className,
|
13312
13548
|
icon: "more",
|
13313
|
-
menu: popoverElement ? undefined : menuProps => (/*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content,
|
13549
|
+
menu: popoverElement ? undefined : menuProps => (/*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content, {
|
13550
|
+
onFocusOutside: event => event.preventDefault()
|
13551
|
+
}, memoedMenuItems))),
|
13314
13552
|
popover: popoverElement,
|
13315
13553
|
onClickCapture: event => event.preventDefault(),
|
13316
13554
|
onKeyDown: event => {
|
@@ -13710,8 +13948,13 @@ function Summary(props) {
|
|
13710
13948
|
}
|
13711
13949
|
|
13712
13950
|
function Foot(props) {
|
13713
|
-
const
|
13714
|
-
|
13951
|
+
const {
|
13952
|
+
children,
|
13953
|
+
table,
|
13954
|
+
...attributes
|
13955
|
+
} = props;
|
13956
|
+
const nonGroupedHeaders = table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());
|
13957
|
+
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
13958
|
key: header.id,
|
13716
13959
|
header: header,
|
13717
13960
|
index: index
|
@@ -13759,16 +14002,29 @@ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(prop
|
|
13759
14002
|
});
|
13760
14003
|
|
13761
14004
|
function EmptyStateBody(props) {
|
14005
|
+
var _ref$current, _ref$current$parentNo;
|
13762
14006
|
const {
|
13763
14007
|
emptyState: Placeholder,
|
14008
|
+
isReady,
|
13764
14009
|
reason,
|
13765
14010
|
...attributes
|
13766
14011
|
} = props;
|
14012
|
+
const ref = React__default.useRef(null);
|
14013
|
+
if (!isReady) {
|
14014
|
+
return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
|
14015
|
+
className: "!auto-rows-fr"
|
14016
|
+
}));
|
14017
|
+
}
|
13767
14018
|
return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
|
13768
|
-
|
14019
|
+
ref: ref,
|
14020
|
+
className: "!auto-rows-fr",
|
14021
|
+
"data-taco": "empty-state"
|
13769
14022
|
}), /*#__PURE__*/React__default.createElement("tr", {
|
13770
|
-
className: "!auto-rows-fr"
|
14023
|
+
className: "!auto-rows-fr "
|
13771
14024
|
}, /*#__PURE__*/React__default.createElement("td", {
|
14025
|
+
style: {
|
14026
|
+
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
|
14027
|
+
},
|
13772
14028
|
className: "col-span-full !border-0 !p-0 hover:!bg-white"
|
13773
14029
|
}, Placeholder ? /*#__PURE__*/React__default.createElement(Placeholder, {
|
13774
14030
|
reason: reason
|
@@ -14043,7 +14299,7 @@ function Search$1(props) {
|
|
14043
14299
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SearchInput2, {
|
14044
14300
|
findCurrent: tableMeta.search.currentHighlightColumnIndex !== undefined ? tableMeta.search.currentHighlightColumnIndex + 1 : null,
|
14045
14301
|
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.
|
14302
|
+
loading: tableMeta.server.loading,
|
14047
14303
|
name: "table-search",
|
14048
14304
|
onClickFindPrevious: handlePreviousResult,
|
14049
14305
|
onClickFindNext: handleNextResult,
|
@@ -14401,6 +14657,7 @@ const getOptionsFromCollection = (collection, selector) => collection.querySelec
|
|
14401
14657
|
const Root = /*#__PURE__*/React__default.forwardRef(function CollectionRoot(props, ref) {
|
14402
14658
|
const {
|
14403
14659
|
querySelector,
|
14660
|
+
resetOnChange,
|
14404
14661
|
tabIndex = 0,
|
14405
14662
|
...otherProps
|
14406
14663
|
} = props;
|
@@ -14431,14 +14688,31 @@ const Root = /*#__PURE__*/React__default.forwardRef(function CollectionRoot(prop
|
|
14431
14688
|
internalRef.current.setActiveIndexByElement = setActiveIndexByElement;
|
14432
14689
|
}
|
14433
14690
|
}, [internalRef.current]);
|
14691
|
+
React__default.useEffect(() => {
|
14692
|
+
if (internalRef.current) {
|
14693
|
+
const selected = internalRef.current.querySelectorAll(`[aria-current="true"]`);
|
14694
|
+
const options = getOptionsFromCollection(internalRef.current, querySelector);
|
14695
|
+
if (options.length && selected.length === 1) {
|
14696
|
+
const firstSelected = internalRef.current.querySelector(`[aria-selected]`);
|
14697
|
+
if (firstSelected) {
|
14698
|
+
const selectedIndex = Array.from(options).indexOf(firstSelected);
|
14699
|
+
if (selectedIndex > -1) {
|
14700
|
+
setActiveOption(selectedIndex, internalRef.current, firstSelected);
|
14701
|
+
}
|
14702
|
+
}
|
14703
|
+
}
|
14704
|
+
}
|
14705
|
+
}, [resetOnChange]);
|
14434
14706
|
React__default.useEffect(() => {
|
14435
14707
|
if (internalRef.current) {
|
14436
14708
|
const options = getOptionsFromCollection(internalRef.current, querySelector);
|
14437
14709
|
if (options.length) {
|
14438
14710
|
let selected = internalRef.current.querySelectorAll(`[aria-current="true"]`);
|
14711
|
+
// if nothing is current (keyboard visible), look for selected items
|
14439
14712
|
if (selected.length === 0) {
|
14440
14713
|
selected = internalRef.current.querySelectorAll(`[aria-selected]`);
|
14441
14714
|
}
|
14715
|
+
// if one item is selected, make sure it's current
|
14442
14716
|
if (selected.length === 1) {
|
14443
14717
|
if (options) {
|
14444
14718
|
const firstSelected = selected.item(0);
|
@@ -14584,6 +14858,7 @@ const Root$1 = /*#__PURE__*/React__default.forwardRef(function Listbox2(props, r
|
|
14584
14858
|
id: id,
|
14585
14859
|
querySelector: customSelector ? `${DEFAULT_SELECTOR}, ${customSelector}` : DEFAULT_SELECTOR,
|
14586
14860
|
ref: ref,
|
14861
|
+
resetOnChange: value,
|
14587
14862
|
role: "listbox"
|
14588
14863
|
}), children)));
|
14589
14864
|
});
|
@@ -14642,10 +14917,6 @@ const Option = /*#__PURE__*/React__default.forwardRef(function Listbox2Option(pr
|
|
14642
14917
|
if (disabled || listboxDisabled || listboxReadOnly) {
|
14643
14918
|
event.stopPropagation();
|
14644
14919
|
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
14920
|
} else if (isAriaSelectionKey(event)) {
|
14650
14921
|
setValue(value);
|
14651
14922
|
}
|
@@ -14656,7 +14927,6 @@ const Option = /*#__PURE__*/React__default.forwardRef(function Listbox2Option(pr
|
|
14656
14927
|
return /*#__PURE__*/React__default.createElement("div", Object.assign({}, otherProps, {
|
14657
14928
|
"aria-disabled": listboxDisabled || disabled ? 'true' : undefined,
|
14658
14929
|
"aria-selected": selected ? 'true' : undefined,
|
14659
|
-
key: `${value}_${String(selected)}`,
|
14660
14930
|
id: id,
|
14661
14931
|
onClick: handleClick,
|
14662
14932
|
onKeyDown: handleKeyDown,
|
@@ -14721,14 +14991,16 @@ const Tag$1 = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
14721
14991
|
ref: ref,
|
14722
14992
|
"data-taco": "tag"
|
14723
14993
|
}), /*#__PURE__*/React__default.createElement("span", {
|
14724
|
-
className: "truncate px-2",
|
14994
|
+
className: "flex items-center truncate px-2",
|
14725
14995
|
ref: textRef
|
14726
14996
|
}, icon ? typeof icon === 'string' ? (/*#__PURE__*/React__default.createElement(Icon, {
|
14727
14997
|
name: icon,
|
14728
|
-
className: "-ml-1
|
14998
|
+
className: "-ml-1 mr-1 !h-5 !w-5"
|
14729
14999
|
})) : (/*#__PURE__*/React__default.cloneElement(icon, {
|
14730
|
-
className: 'mr-1 -ml-1
|
14731
|
-
})) : null,
|
15000
|
+
className: 'mr-1 -ml-1 !h-5 !w-5'
|
15001
|
+
})) : null, /*#__PURE__*/React__default.createElement("span", {
|
15002
|
+
className: "truncate"
|
15003
|
+
}, children)), onDelete ? (/*#__PURE__*/React__default.createElement(Icon, {
|
14732
15004
|
name: "close",
|
14733
15005
|
onClick: onDelete,
|
14734
15006
|
className: "-ml-1.5 !h-6 !w-5 flex-shrink-0 cursor-pointer rounded-r p-0.5 hover:bg-black/5"
|
@@ -15005,12 +15277,13 @@ const Option$1 = /*#__PURE__*/React__default.forwardRef(function Select2Option(p
|
|
15005
15277
|
}), hasValue ? (/*#__PURE__*/React__default.createElement(Icon, {
|
15006
15278
|
name: "tick",
|
15007
15279
|
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, {
|
15280
|
+
})) : null, typeof children !== 'string' ? (/*#__PURE__*/React__default.createElement("span", null, children)) : isTag ? (/*#__PURE__*/React__default.createElement(Tag$1, {
|
15009
15281
|
className: "pointer-events-none my-1",
|
15010
15282
|
color: color,
|
15011
15283
|
icon: prefix
|
15012
15284
|
}, children)) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, prefix ? typeof prefix === 'string' ? /*#__PURE__*/React__default.createElement(Icon, {
|
15013
|
-
name: prefix
|
15285
|
+
name: prefix,
|
15286
|
+
className: "!h-5 !w-5"
|
15014
15287
|
}) : prefix : null, /*#__PURE__*/React__default.createElement("span", {
|
15015
15288
|
className: "flex w-full justify-between"
|
15016
15289
|
}, /*#__PURE__*/React__default.createElement("span", {
|
@@ -15019,9 +15292,10 @@ const Option$1 = /*#__PURE__*/React__default.forwardRef(function Select2Option(p
|
|
15019
15292
|
className: "text-grey-700 -mt-1.5 mb-1.5 text-xs"
|
15020
15293
|
}, description) : null), /*#__PURE__*/React__default.createElement("span", {
|
15021
15294
|
className: "flex flex-col self-center"
|
15022
|
-
}, postfix ? typeof postfix === 'string' ? /*#__PURE__*/React__default.createElement(Icon, {
|
15023
|
-
name: postfix
|
15024
|
-
|
15295
|
+
}, postfix ? typeof postfix === 'string' ? (/*#__PURE__*/React__default.createElement(Icon, {
|
15296
|
+
name: postfix,
|
15297
|
+
className: "!h-5 !w-5"
|
15298
|
+
})) : postfix : null)))), popover ? (/*#__PURE__*/React__default.createElement(IconButton, {
|
15025
15299
|
icon: "ellipsis-vertical",
|
15026
15300
|
appearance: "discrete",
|
15027
15301
|
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 +15373,9 @@ const Button$3 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
|
|
15099
15373
|
var _props$className;
|
15100
15374
|
const {
|
15101
15375
|
children,
|
15376
|
+
onBlur,
|
15102
15377
|
onClick,
|
15378
|
+
onFocus,
|
15103
15379
|
tabIndex = 0,
|
15104
15380
|
...otherProps
|
15105
15381
|
} = props;
|
@@ -15130,6 +15406,18 @@ const Button$3 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
|
|
15130
15406
|
onClick(event);
|
15131
15407
|
}
|
15132
15408
|
};
|
15409
|
+
let handleBlur;
|
15410
|
+
if (typeof onBlur === 'function') {
|
15411
|
+
// we might be focusing on an input or something inside the dropdown that was triggered by the select
|
15412
|
+
// so see if the element gaining focus is inside a portal and look up its controller
|
15413
|
+
// if we don't do this, things like validate on blur occur while simply opening the select
|
15414
|
+
handleBlur = event => {
|
15415
|
+
if (isElementInsideOrTriggeredFromContainer(event.relatedTarget, event.currentTarget)) {
|
15416
|
+
return;
|
15417
|
+
}
|
15418
|
+
onBlur(event);
|
15419
|
+
};
|
15420
|
+
}
|
15133
15421
|
// select the value text if the select is readonly
|
15134
15422
|
const handleFocus = event => {
|
15135
15423
|
if (readOnly) {
|
@@ -15139,6 +15427,9 @@ const Button$3 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
|
|
15139
15427
|
(_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
15428
|
}
|
15141
15429
|
}
|
15430
|
+
if (typeof onFocus === 'function') {
|
15431
|
+
onFocus(event);
|
15432
|
+
}
|
15142
15433
|
};
|
15143
15434
|
return /*#__PURE__*/React__default.createElement("button", Object.assign({}, otherProps, {
|
15144
15435
|
"aria-invalid": invalid ? true : undefined,
|
@@ -15146,6 +15437,7 @@ const Button$3 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
|
|
15146
15437
|
className: className,
|
15147
15438
|
disabled: disabled,
|
15148
15439
|
onClick: handleClick,
|
15440
|
+
onBlur: handleBlur,
|
15149
15441
|
onFocus: handleFocus,
|
15150
15442
|
ref: ref,
|
15151
15443
|
role: "combobox",
|
@@ -15169,7 +15461,7 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
|
|
15169
15461
|
readOnly,
|
15170
15462
|
tags
|
15171
15463
|
} = useSelect2Context();
|
15172
|
-
const contentClassName = cn('truncate items-center gap-1');
|
15464
|
+
const contentClassName = cn('truncate flex items-center gap-1');
|
15173
15465
|
const currentValue = children.find(matchesValue(value));
|
15174
15466
|
let output;
|
15175
15467
|
if (placeholder && currentValue === undefined) {
|
@@ -15179,13 +15471,13 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
|
|
15179
15471
|
}, placeholder);
|
15180
15472
|
} else if (currentValue) {
|
15181
15473
|
if (tags && emptyValue !== value) {
|
15182
|
-
output = /*#__PURE__*/React__default.createElement(Tag$1, {
|
15474
|
+
if (typeof currentValue.props.children === 'string') output = /*#__PURE__*/React__default.createElement(Tag$1, {
|
15183
15475
|
className: "truncate",
|
15184
15476
|
color: currentValue.props.color,
|
15185
15477
|
disabled: disabled,
|
15186
15478
|
icon: currentValue.props.prefix,
|
15187
15479
|
readOnly: readOnly
|
15188
|
-
}, currentValue.props.children);
|
15480
|
+
}, currentValue.props.children);else output = currentValue.props.children;
|
15189
15481
|
} else {
|
15190
15482
|
output = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, currentValue.props.prefix ? typeof currentValue.props.prefix === 'string' ? (/*#__PURE__*/React__default.createElement(Icon, {
|
15191
15483
|
name: currentValue.props.prefix,
|
@@ -15236,7 +15528,7 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
|
|
15236
15528
|
}, valuesAsChildren.length === 0 ? (/*#__PURE__*/React__default.createElement(Placeholder, {
|
15237
15529
|
disabled: disabled,
|
15238
15530
|
readOnly: readOnly
|
15239
|
-
}, placeholder)) : valuesAsChildren.map(child => (/*#__PURE__*/React__default.createElement(Tag$1, {
|
15531
|
+
}, placeholder)) : valuesAsChildren.map(child => typeof child.props.children === 'string' ? (/*#__PURE__*/React__default.createElement(Tag$1, {
|
15240
15532
|
key: String(child.props.value),
|
15241
15533
|
className: "truncate",
|
15242
15534
|
color: tags ? child.props.color : undefined,
|
@@ -15250,7 +15542,23 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
|
|
15250
15542
|
}
|
15251
15543
|
},
|
15252
15544
|
readOnly: readOnly
|
15253
|
-
}, child.props.children))
|
15545
|
+
}, child.props.children)) : (/*#__PURE__*/React__default.cloneElement(child.props.children, {
|
15546
|
+
key: String(child.props.value),
|
15547
|
+
className: '!pr-0 !pl-1.5',
|
15548
|
+
children: (/*#__PURE__*/React__default.createElement("span", {
|
15549
|
+
className: "flex items-center"
|
15550
|
+
}, child.props.children.props.children, /*#__PURE__*/React__default.createElement(Icon, {
|
15551
|
+
name: "close",
|
15552
|
+
onClick: event => {
|
15553
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
15554
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
15555
|
+
if (!disabled && !readOnly) {
|
15556
|
+
setValue(child.props.value);
|
15557
|
+
}
|
15558
|
+
},
|
15559
|
+
className: "ml-0.5 !h-5 !w-5 shrink-0 cursor-pointer rounded-r p-0.5 hover:bg-black/5"
|
15560
|
+
})))
|
15561
|
+
})))));
|
15254
15562
|
} else {
|
15255
15563
|
content = /*#__PURE__*/React__default.createElement(MultipleValue, {
|
15256
15564
|
onClick: forwardClick,
|
@@ -15281,6 +15589,18 @@ const MultipleValue = ({
|
|
15281
15589
|
} = useSelect2Context();
|
15282
15590
|
const [contentRef, setContentRef] = React__default.useState(null);
|
15283
15591
|
const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;
|
15592
|
+
// Retrieves the relevant text content from any JSX.Element passed as a select option, handling nested elements, arrays, and direct text
|
15593
|
+
const getTooltipTitle = child => {
|
15594
|
+
const children = child.props.children;
|
15595
|
+
if (typeof children === 'string') return children;
|
15596
|
+
if (typeof children.props.children === 'string') {
|
15597
|
+
return children.props.children;
|
15598
|
+
}
|
15599
|
+
if (Array.isArray(children.props.children)) {
|
15600
|
+
return children.props.children.filter(item => typeof item === 'string');
|
15601
|
+
}
|
15602
|
+
return '';
|
15603
|
+
};
|
15284
15604
|
return /*#__PURE__*/React__default.createElement("div", {
|
15285
15605
|
className: "relative flex w-full items-center gap-1 overflow-hidden",
|
15286
15606
|
onClick: onClick
|
@@ -15291,26 +15611,35 @@ const MultipleValue = ({
|
|
15291
15611
|
disabled: disabled,
|
15292
15612
|
readOnly: readOnly
|
15293
15613
|
}, placeholder)) : valuesAsChildren.map((child, index) => {
|
15294
|
-
const
|
15295
|
-
|
15614
|
+
const classNames = {
|
15615
|
+
truncate: index === boundaryIndex,
|
15616
|
+
hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false
|
15617
|
+
};
|
15618
|
+
let output;
|
15619
|
+
if (typeof child.props.children === 'string') {
|
15620
|
+
output = /*#__PURE__*/React__default.createElement(Tag$1, {
|
15621
|
+
key: String(child.props.value),
|
15622
|
+
className: cn('cursor-pointer', classNames),
|
15623
|
+
color: tags ? child.props.color : undefined,
|
15624
|
+
disabled: disabled,
|
15625
|
+
icon: child.props.prefix,
|
15626
|
+
readOnly: readOnly
|
15627
|
+
}, child.props.children);
|
15628
|
+
} else output = /*#__PURE__*/React__default.cloneElement(child.props.children, {
|
15296
15629
|
className: cn('cursor-pointer', {
|
15297
|
-
|
15298
|
-
|
15299
|
-
|
15300
|
-
|
15301
|
-
disabled: disabled,
|
15302
|
-
icon: child.props.prefix,
|
15303
|
-
readOnly: readOnly
|
15304
|
-
}, child.props.children);
|
15630
|
+
'shrink-0': index !== boundaryIndex
|
15631
|
+
}, classNames),
|
15632
|
+
key: String(child.props.value)
|
15633
|
+
});
|
15305
15634
|
if (index === boundaryIndex) {
|
15306
15635
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
15307
15636
|
key: String(child.props.value),
|
15308
|
-
title: String(child
|
15309
|
-
},
|
15637
|
+
title: String(getTooltipTitle(child))
|
15638
|
+
}, output);
|
15310
15639
|
}
|
15311
|
-
return
|
15640
|
+
return output;
|
15312
15641
|
})), boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (/*#__PURE__*/React__default.createElement(Tooltip, {
|
15313
|
-
title: valuesAsChildren.slice(boundaryIndex + 1).map(child => child ? String(child
|
15642
|
+
title: valuesAsChildren.slice(boundaryIndex + 1).map(child => child ? String(getTooltipTitle(child)) : '').join(', ')
|
15314
15643
|
}, /*#__PURE__*/React__default.createElement(Badge, {
|
15315
15644
|
className: "flex-shrink-0"
|
15316
15645
|
}, "+", valuesAsChildren.length - (boundaryIndex + 1)))) : null);
|
@@ -15375,7 +15704,7 @@ const BubbleSelect = props => {
|
|
15375
15704
|
if (prevValue !== value && setValue) {
|
15376
15705
|
if (Array.isArray(value)) {
|
15377
15706
|
value.forEach(v => {
|
15378
|
-
const option = select.querySelector(`option[value='${v}']`);
|
15707
|
+
const option = select.querySelector(`option[value='${CSS.escape(v)}']`);
|
15379
15708
|
if (option) {
|
15380
15709
|
option.selected = true;
|
15381
15710
|
}
|
@@ -15408,17 +15737,12 @@ const BubbleSelect = props => {
|
|
15408
15737
|
};
|
15409
15738
|
|
15410
15739
|
const Search$2 = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(props, ref) {
|
15411
|
-
const {
|
15412
|
-
onTabKeyPress,
|
15413
|
-
...otherProps
|
15414
|
-
} = props;
|
15415
15740
|
const {
|
15416
15741
|
listboxRef,
|
15417
15742
|
searchQuery,
|
15418
15743
|
setSearchQuery,
|
15419
15744
|
setValidationError,
|
15420
|
-
validationError
|
15421
|
-
setOpen
|
15745
|
+
validationError
|
15422
15746
|
} = useSelect2Context();
|
15423
15747
|
const handleChange = event => {
|
15424
15748
|
if (validationError) {
|
@@ -15431,11 +15755,6 @@ const Search$2 = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(p
|
|
15431
15755
|
if (event.key === ' ') {
|
15432
15756
|
return;
|
15433
15757
|
}
|
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
15758
|
if (isAriaSelectionKey(event) || event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
15440
15759
|
var _listboxRef$current;
|
15441
15760
|
event.preventDefault();
|
@@ -15450,7 +15769,7 @@ const Search$2 = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(p
|
|
15450
15769
|
}),
|
15451
15770
|
invalid: !!validationError,
|
15452
15771
|
message: validationError === null || validationError === void 0 ? void 0 : validationError.message
|
15453
|
-
}, /*#__PURE__*/React__default.createElement(Input, Object.assign({},
|
15772
|
+
}, /*#__PURE__*/React__default.createElement(Input, Object.assign({}, props, {
|
15454
15773
|
autoFocus: true,
|
15455
15774
|
invalid: !!validationError,
|
15456
15775
|
onChange: handleChange,
|
@@ -15513,20 +15832,19 @@ const useChildren = ({
|
|
15513
15832
|
};
|
15514
15833
|
|
15515
15834
|
const getNextColor = options => {
|
15516
|
-
|
15517
|
-
|
15518
|
-
|
15519
|
-
|
15520
|
-
|
15521
|
-
|
15522
|
-
|
15523
|
-
|
15524
|
-
}, {});
|
15525
|
-
options.forEach(option => {
|
15835
|
+
let occurrences = {};
|
15836
|
+
AVAILABLE_COLORS.filter(color => color !== 'transparent').forEach(color => {
|
15837
|
+
occurrences = {
|
15838
|
+
...occurrences,
|
15839
|
+
[color]: 0
|
15840
|
+
};
|
15841
|
+
});
|
15842
|
+
options.reduce((occurrences, option) => {
|
15526
15843
|
if (option.props.color) {
|
15527
15844
|
occurrences[option.props.color] = occurrences[option.props.color] ? occurrences[option.props.color] + 1 : 1;
|
15528
15845
|
}
|
15529
|
-
|
15846
|
+
return occurrences;
|
15847
|
+
}, occurrences);
|
15530
15848
|
const colors = Object.keys(occurrences);
|
15531
15849
|
if (colors.length) {
|
15532
15850
|
return colors.sort((a, b) => occurrences[a] - occurrences[b])[0];
|
@@ -15674,7 +15992,6 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
15674
15992
|
// align the listbox min width with the width of the input - it should never be smaller
|
15675
15993
|
const dimensions = useBoundingClientRectListener(internalRef);
|
15676
15994
|
// state
|
15677
|
-
const [tabTriggeredClose, setTabTriggeredClose] = React__default.useState(false);
|
15678
15995
|
const [open, setOpen] = React__default.useState(false);
|
15679
15996
|
const [value, _setValue] = reactUseControllableState.useControllableState({
|
15680
15997
|
// uncontrolled
|
@@ -15751,7 +16068,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
15751
16068
|
var _listboxRef$current;
|
15752
16069
|
if (open) {
|
15753
16070
|
event.preventDefault();
|
15754
|
-
} else if (isElementInsideTable3OrReport(event.currentTarget)) {
|
16071
|
+
} else if (isElementInsideTable3OrReport(event.currentTarget) && isAriaDirectionKey(event)) {
|
15755
16072
|
return;
|
15756
16073
|
} else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {
|
15757
16074
|
setOpen(true);
|
@@ -15762,47 +16079,33 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
15762
16079
|
// the focus should always remain on the input, so we forward events on to the listbox
|
15763
16080
|
(_listboxRef$current = listboxRef.current) === null || _listboxRef$current === void 0 ? void 0 : _listboxRef$current.dispatchEvent(createCustomKeyboardEvent(event));
|
15764
16081
|
};
|
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
|
-
}
|
16082
|
+
const shouldFocusNextRef = React__default.useRef(false);
|
15783
16083
|
const handleListboxKeyDown = event => {
|
15784
16084
|
if (isAriaDirectionKey(event)) {
|
15785
16085
|
setShouldPauseHoverState(true);
|
16086
|
+
return;
|
16087
|
+
}
|
16088
|
+
if (event.key === 'Tab') {
|
16089
|
+
shouldFocusNextRef.current = true;
|
16090
|
+
setOpen(false);
|
16091
|
+
return;
|
15786
16092
|
}
|
16093
|
+
// support typeahead to set the value by typing its text
|
15787
16094
|
if (!hasSearch && /^[a-z0-9]$/i.test(event.key)) {
|
15788
16095
|
setValueIfMatched(event.key);
|
16096
|
+
return;
|
15789
16097
|
}
|
15790
16098
|
};
|
16099
|
+
// popover closes and unmounts before any event can be used to focus next, so prevent focusing the trigger and focus next
|
15791
16100
|
const handleCloseAutoFocus = event => {
|
15792
|
-
|
15793
|
-
|
15794
|
-
|
15795
|
-
|
15796
|
-
|
15797
|
-
|
15798
|
-
|
15799
|
-
|
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();
|
15805
|
-
}
|
16101
|
+
if (shouldFocusNextRef.current) {
|
16102
|
+
var _otherProps$onBlur, _getNextFocussableEle;
|
16103
|
+
event.preventDefault();
|
16104
|
+
shouldFocusNextRef.current = false;
|
16105
|
+
(_otherProps$onBlur = otherProps.onBlur) === null || _otherProps$onBlur === void 0 ? void 0 : _otherProps$onBlur.call(otherProps, event);
|
16106
|
+
(_getNextFocussableEle = getNextFocussableElement(internalRef.current)) === null || _getNextFocussableEle === void 0 ? void 0 : _getNextFocussableEle.focus();
|
16107
|
+
return;
|
16108
|
+
}
|
15806
16109
|
};
|
15807
16110
|
const areAllSelected = Array.isArray(value) && selectOptions.every(option => value.includes(option));
|
15808
16111
|
const selectAllText = React__default.useMemo(() => {
|
@@ -15850,18 +16153,14 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
15850
16153
|
}, /*#__PURE__*/React__default.createElement(Trigger$7, Object.assign({}, otherProps, {
|
15851
16154
|
"aria-haspopup": "listbox",
|
15852
16155
|
emptyValue: emptyValue,
|
15853
|
-
onBlur: handleBlur,
|
15854
16156
|
onKeyDown: handleKeyDown,
|
15855
16157
|
placeholder: placeholder,
|
15856
16158
|
ref: internalRef
|
15857
16159
|
}), flattenedChildren)), /*#__PURE__*/React__default.createElement(PopoverPrimitive.Portal, null, /*#__PURE__*/React__default.createElement(PopoverPrimitive.Content, {
|
15858
16160
|
asChild: true,
|
15859
16161
|
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
16162
|
onCloseAutoFocus: handleCloseAutoFocus,
|
16163
|
+
onPointerDownOutside: otherProps.onBlur,
|
15865
16164
|
sideOffset: 4,
|
15866
16165
|
tabIndex: -1
|
15867
16166
|
}, /*#__PURE__*/React__default.createElement("div", {
|
@@ -15871,8 +16170,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
15871
16170
|
}
|
15872
16171
|
}, hasSearch ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Search$2, {
|
15873
16172
|
placeholder: hasInlineCreation ? texts.select2.searchOrCreate : texts.select2.search,
|
15874
|
-
ref: searchRef
|
15875
|
-
onTabKeyPress: () => setTabTriggeredClose(true)
|
16173
|
+
ref: searchRef
|
15876
16174
|
}), multiple && selectOptions.length > 1 && (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button$1, {
|
15877
16175
|
className: "!justify-start",
|
15878
16176
|
appearance: "discrete",
|
@@ -15942,6 +16240,7 @@ const ControlledHiddenField = props => {
|
|
15942
16240
|
key: String(bubbleValue),
|
15943
16241
|
multiple: multiple,
|
15944
16242
|
name: name,
|
16243
|
+
tabIndex: -1,
|
15945
16244
|
value: bubbleValue
|
15946
16245
|
}, emptyValue !== undefined ? /*#__PURE__*/React__default.createElement("option", {
|
15947
16246
|
value: emptyValue
|
@@ -16214,10 +16513,11 @@ function guessComparatorsBasedOnControl(column) {
|
|
16214
16513
|
return getDataTypeProperties(columnMeta.dataType).filterComparators;
|
16215
16514
|
}
|
16216
16515
|
|
16516
|
+
const FilterContext = /*#__PURE__*/React__default.createContext([]);
|
16517
|
+
|
16217
16518
|
const FilterColumn = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
16218
16519
|
const {
|
16219
16520
|
allColumns,
|
16220
|
-
filters,
|
16221
16521
|
onChange: handleChange,
|
16222
16522
|
value = null,
|
16223
16523
|
...attributes
|
@@ -16225,6 +16525,7 @@ const FilterColumn = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
16225
16525
|
const {
|
16226
16526
|
texts
|
16227
16527
|
} = useLocalization();
|
16528
|
+
const filters = React__default.useContext(FilterContext);
|
16228
16529
|
const selectedColumn = allColumns.find(column => column.id === value);
|
16229
16530
|
const warning = selectedColumn && !selectedColumn.getIsVisible();
|
16230
16531
|
return /*#__PURE__*/React__default.createElement("div", {
|
@@ -16390,10 +16691,11 @@ function Control(props) {
|
|
16390
16691
|
} = props;
|
16391
16692
|
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
16693
|
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;
|
16694
|
+
const filters = React__default.useContext(FilterContext);
|
16393
16695
|
const ref = React__default.useRef(null);
|
16394
16696
|
React.useEffect(() => {
|
16395
16697
|
// 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) {
|
16698
|
+
if ((controlRenderer === 'switch' || controlRenderer === 'checkbox') && value === undefined) {
|
16397
16699
|
onChange(false);
|
16398
16700
|
}
|
16399
16701
|
}, [controlRenderer]);
|
@@ -16403,7 +16705,7 @@ function Control(props) {
|
|
16403
16705
|
setValue: value => onChange(value),
|
16404
16706
|
value,
|
16405
16707
|
ref
|
16406
|
-
}), {
|
16708
|
+
}, undefined, filters), {
|
16407
16709
|
['data-query-selector']: querySelector,
|
16408
16710
|
className: 'focus:yt-focus'
|
16409
16711
|
});
|
@@ -16418,6 +16720,12 @@ function Control(props) {
|
|
16418
16720
|
checked: Boolean(value),
|
16419
16721
|
onChange: onChange
|
16420
16722
|
}));
|
16723
|
+
} else if (controlRenderer === 'checkbox') {
|
16724
|
+
return /*#__PURE__*/React__default.createElement(Checkbox, Object.assign({}, attributes, {
|
16725
|
+
className: "!m-1.5",
|
16726
|
+
checked: Boolean(value),
|
16727
|
+
onChange: onChange
|
16728
|
+
}));
|
16421
16729
|
} else if ((controlRenderer === 'input' || controlRenderer === undefined) && dataType === 'number') {
|
16422
16730
|
return /*#__PURE__*/React__default.createElement(Input, Object.assign({}, attributes, {
|
16423
16731
|
className: "flex-grow",
|
@@ -16439,7 +16747,6 @@ function Filter$1(props) {
|
|
16439
16747
|
const {
|
16440
16748
|
allColumns,
|
16441
16749
|
filter,
|
16442
|
-
filters,
|
16443
16750
|
onChange: handleChange,
|
16444
16751
|
onRemove,
|
16445
16752
|
position
|
@@ -16514,7 +16821,6 @@ function Filter$1(props) {
|
|
16514
16821
|
className: "flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right"
|
16515
16822
|
}, position > 0 ? texts.table.filters.conditions.and : texts.table.filters.conditions.where), /*#__PURE__*/React__default.createElement(FilterColumn, {
|
16516
16823
|
allColumns: allColumns,
|
16517
|
-
filters: filters,
|
16518
16824
|
onChange: handleChangeColumn,
|
16519
16825
|
value: id,
|
16520
16826
|
ref: ref
|
@@ -16618,7 +16924,9 @@ function ManageFiltersPopover(props) {
|
|
16618
16924
|
};
|
16619
16925
|
return /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps, {
|
16620
16926
|
onChange: handleClose
|
16621
|
-
}), /*#__PURE__*/React__default.createElement(Popover.Content, null, /*#__PURE__*/React__default.createElement(
|
16927
|
+
}), /*#__PURE__*/React__default.createElement(Popover.Content, null, /*#__PURE__*/React__default.createElement(FilterContext.Provider, {
|
16928
|
+
value: filters
|
16929
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
16622
16930
|
className: "flex w-[40rem] flex-col gap-4"
|
16623
16931
|
}, /*#__PURE__*/React__default.createElement("div", {
|
16624
16932
|
className: "flex h-8"
|
@@ -16634,7 +16942,6 @@ function ManageFiltersPopover(props) {
|
|
16634
16942
|
key: `filter_${index}`,
|
16635
16943
|
allColumns: allColumns,
|
16636
16944
|
filter: filter,
|
16637
|
-
filters: filters,
|
16638
16945
|
position: index,
|
16639
16946
|
onChange: handleChangeFilter,
|
16640
16947
|
onRemove: filters.length > 0 && filters.some(f => f.id) || filters.length > 1 ? handleRemoveFilter : undefined
|
@@ -16650,7 +16957,7 @@ function ManageFiltersPopover(props) {
|
|
16650
16957
|
}, texts.table.filters.buttons.clear), /*#__PURE__*/React__default.createElement(Button$1, {
|
16651
16958
|
appearance: "primary",
|
16652
16959
|
onClick: handleApply
|
16653
|
-
}, texts.table.filters.buttons.apply)))));
|
16960
|
+
}, texts.table.filters.buttons.apply))))));
|
16654
16961
|
}
|
16655
16962
|
|
16656
16963
|
function Filters(props) {
|
@@ -16753,7 +17060,7 @@ function Table(props) {
|
|
16753
17060
|
}
|
16754
17061
|
Table.Toolbar = TableToolbar;
|
16755
17062
|
Table.Grid = TableGrid;
|
16756
|
-
function
|
17063
|
+
function getEmptyStateReason(table) {
|
16757
17064
|
if (table.instance.getFilteredRowModel().rows.length === 0 && table.instance.getCoreRowModel().rows.length !== 0) {
|
16758
17065
|
const state = table.instance.getState();
|
16759
17066
|
if (table.meta.search.enableGlobalFilter && !!state.globalFilter) {
|
@@ -16770,15 +17077,14 @@ function TableGrid(props) {
|
|
16770
17077
|
var _table$state$grouping;
|
16771
17078
|
const {
|
16772
17079
|
enableHorizontalArrowKeyNavigation,
|
17080
|
+
footerRows,
|
16773
17081
|
table,
|
16774
17082
|
...attributes
|
16775
17083
|
} = props;
|
16776
17084
|
const handleFocus = table.meta.rowActive.rowActiveIndex === undefined ? event => {
|
16777
17085
|
table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);
|
16778
17086
|
} : undefined;
|
16779
|
-
const
|
16780
|
-
const searchNotApplied = !table.state.globalFilter || table.state.globalFilter === '';
|
16781
|
-
const filtersNotApplied = !table.state.columnFilters || table.state.columnFilters.length === 0;
|
17087
|
+
const emptyStateReason = getEmptyStateReason(table);
|
16782
17088
|
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
17089
|
id: table.id,
|
16784
17090
|
"data-table-font-size": table.meta.fontSize.size,
|
@@ -16799,9 +17105,10 @@ function TableGrid(props) {
|
|
16799
17105
|
key: props.id,
|
16800
17106
|
header: props,
|
16801
17107
|
scrollToIndex: table.renderer.scrollToIndex
|
16802
|
-
}))))))),
|
17108
|
+
}))))))), emptyStateReason ? (/*#__PURE__*/React__default.createElement(EmptyStateBody, {
|
16803
17109
|
emptyState: props.table.props.emptyState,
|
16804
|
-
|
17110
|
+
isReady: table.meta.server.isEnabled ? table.meta.server.isReady : true,
|
17111
|
+
reason: emptyStateReason
|
16805
17112
|
})) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Body, {
|
16806
17113
|
enableHorizontalArrowKeyNavigation: enableHorizontalArrowKeyNavigation,
|
16807
17114
|
table: table.instance,
|
@@ -16811,9 +17118,9 @@ function TableGrid(props) {
|
|
16811
17118
|
...table.renderer.style,
|
16812
17119
|
height: table.renderer.style.height + ROW_HEIGHT_ESTIMATES[table.meta.rowHeight.height]
|
16813
17120
|
} : table.renderer.style
|
16814
|
-
}, table.renderer.rows,
|
17121
|
+
}, table.renderer.rows, props.children), table.meta.footer.isEnabled ? /*#__PURE__*/React__default.createElement(Foot, {
|
16815
17122
|
table: table.instance
|
16816
|
-
}) : null)))));
|
17123
|
+
}, footerRows) : null)))));
|
16817
17124
|
}
|
16818
17125
|
|
16819
17126
|
function Column$1(_) {
|
@@ -18314,71 +18621,6 @@ const useTableRowCreation = (data, tableRef) => {
|
|
18314
18621
|
};
|
18315
18622
|
};
|
18316
18623
|
|
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
18624
|
function willRowMove(cell, change, rowIndex, localization) {
|
18383
18625
|
const {
|
18384
18626
|
table
|
@@ -18459,444 +18701,710 @@ function willRowMoveAfterSorting(cell, change, rowIndex) {
|
|
18459
18701
|
}
|
18460
18702
|
return ((_resortedRows$index = resortedRows[index]) === null || _resortedRows$index === void 0 ? void 0 : _resortedRows$index.id) !== cell.row.id;
|
18461
18703
|
}
|
18462
|
-
|
18463
|
-
|
18464
|
-
if (
|
18465
|
-
|
18466
|
-
|
18467
|
-
|
18468
|
-
|
18469
|
-
|
18470
|
-
|
18471
|
-
|
18472
|
-
|
18473
|
-
|
18474
|
-
|
18475
|
-
|
18476
|
-
|
18477
|
-
|
18478
|
-
|
18479
|
-
duration: 1000,
|
18480
|
-
easing: 'ease-out'
|
18481
|
-
});
|
18482
|
-
}
|
18704
|
+
const TEMPORARY_ROW_ID_PREFIX = 'temp-';
|
18705
|
+
function isTemporaryRow(rowId) {
|
18706
|
+
if (rowId === undefined) {
|
18707
|
+
return false;
|
18708
|
+
}
|
18709
|
+
return String(rowId).startsWith(TEMPORARY_ROW_ID_PREFIX);
|
18710
|
+
}
|
18711
|
+
const shortcut = {
|
18712
|
+
key: 'e',
|
18713
|
+
meta: true,
|
18714
|
+
shift: false
|
18715
|
+
};
|
18716
|
+
function isTableScrolled(ref) {
|
18717
|
+
if (ref.current) {
|
18718
|
+
var _ref$current, _ref$current$querySel, _ref$current2, _ref$current2$querySe;
|
18719
|
+
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');
|
18720
|
+
return height > ref.current.scrollHeight;
|
18483
18721
|
}
|
18722
|
+
return false;
|
18484
18723
|
}
|
18485
18724
|
|
18486
|
-
function
|
18487
|
-
|
18488
|
-
const
|
18489
|
-
|
18490
|
-
|
18491
|
-
|
18492
|
-
|
18493
|
-
|
18494
|
-
|
18495
|
-
|
18496
|
-
|
18497
|
-
|
18725
|
+
function useTableEditingListener(table, tableRef, scrollToIndex) {
|
18726
|
+
const tableMeta = table.options.meta;
|
18727
|
+
const localization = useLocalization();
|
18728
|
+
useLazyEffect(() => {
|
18729
|
+
return () => {
|
18730
|
+
if (tableMeta.editing.isEditing && tableMeta.rowActive.rowActiveIndex !== undefined) {
|
18731
|
+
var _table$getRowModel$ro;
|
18732
|
+
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);
|
18733
|
+
}
|
18734
|
+
};
|
18735
|
+
}, [tableMeta.rowActive.rowActiveIndex]);
|
18736
|
+
// show a warning if the user navigates away without triggering save, such as using the browser back/forward button
|
18737
|
+
const hasChanges = tableMeta.editing.hasChanges();
|
18738
|
+
React__default.useEffect(() => {
|
18739
|
+
function showUnsavedChangesWarning(event) {
|
18740
|
+
if (tableMeta.editing.isEditing && hasChanges) {
|
18741
|
+
event.returnValue = true;
|
18742
|
+
return true;
|
18743
|
+
}
|
18744
|
+
return false;
|
18745
|
+
}
|
18746
|
+
window.addEventListener('beforeunload', showUnsavedChangesWarning);
|
18747
|
+
return () => {
|
18748
|
+
window.removeEventListener('beforeunload', showUnsavedChangesWarning);
|
18749
|
+
};
|
18750
|
+
}, [tableMeta.editing.isEditing, hasChanges]);
|
18751
|
+
const hasSavedChanges = tableMeta.editing.hasSaved();
|
18752
|
+
useLazyEffect(() => {
|
18753
|
+
if (hasSavedChanges) {
|
18754
|
+
resetHighlightedColumnIndexes(table.getState().globalFilter, table, localization);
|
18755
|
+
}
|
18756
|
+
}, [hasSavedChanges]);
|
18757
|
+
React__default.useEffect(() => {
|
18758
|
+
const onClickOutside = event => {
|
18759
|
+
if (tableMeta.editing.isEditing) {
|
18760
|
+
const element = event.target;
|
18761
|
+
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);
|
18762
|
+
// users can click the white space below rows which could be inside the table, but a valid scenario to save
|
18763
|
+
if (!isTableOrIsInsideTable) {
|
18764
|
+
tableMeta.editing.saveChanges(table);
|
18765
|
+
}
|
18766
|
+
}
|
18767
|
+
};
|
18768
|
+
document.addEventListener('click', onClickOutside);
|
18769
|
+
return () => document.removeEventListener('click', onClickOutside);
|
18770
|
+
}, [tableMeta.editing.isEditing, tableMeta.editing.saveChanges]);
|
18771
|
+
const rows = table.getRowModel().rows;
|
18772
|
+
// make sure pending changes are removed for rows that no longer exist
|
18773
|
+
useLazyEffect(() => {
|
18774
|
+
const pendingChanges = tableMeta.editing.getErrorsShownInAlert();
|
18775
|
+
pendingChanges.forEach(pendingChange => {
|
18776
|
+
try {
|
18777
|
+
table.getRow(pendingChange.rowId);
|
18778
|
+
} catch {
|
18779
|
+
tableMeta.editing.discardChanges(pendingChange.rowId, table);
|
18780
|
+
}
|
18781
|
+
});
|
18782
|
+
}, [rows.length]);
|
18783
|
+
// shortcuts
|
18784
|
+
useGlobalKeyDown(tableMeta.editing.isEnabled ? shortcut : undefined, event => {
|
18785
|
+
event.preventDefault();
|
18786
|
+
tableMeta.editing.toggleEditing(!tableMeta.editing.isEditing, table, scrollToIndex);
|
18787
|
+
});
|
18788
|
+
useGlobalKeyDown(tableMeta.editing.isEditing ? {
|
18498
18789
|
key: 's',
|
18499
18790
|
meta: true,
|
18500
18791
|
shift: false
|
18501
18792
|
} : undefined, event => {
|
18502
18793
|
event.preventDefault();
|
18503
|
-
|
18794
|
+
tableMeta.editing.saveChanges(table);
|
18504
18795
|
});
|
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
18796
|
}
|
18516
|
-
|
18517
|
-
|
18797
|
+
|
18798
|
+
const DELAY_BEFORE_REMOVING_SAVE_STATUS = 3000;
|
18799
|
+
function reducer$2(state, action) {
|
18800
|
+
const {
|
18801
|
+
type,
|
18802
|
+
rowId,
|
18803
|
+
payload
|
18804
|
+
} = action;
|
18805
|
+
switch (type) {
|
18806
|
+
case 'setCellValue':
|
18807
|
+
{
|
18808
|
+
const {
|
18809
|
+
columnId,
|
18810
|
+
row,
|
18811
|
+
value
|
18812
|
+
} = payload;
|
18813
|
+
return {
|
18814
|
+
...state,
|
18815
|
+
changes: {
|
18816
|
+
...state.changes,
|
18817
|
+
rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),
|
18818
|
+
originals: setWith(state.changes.originals, rowId, row, Object)
|
18819
|
+
}
|
18820
|
+
};
|
18821
|
+
}
|
18822
|
+
case 'removeCellValue':
|
18823
|
+
{
|
18824
|
+
const {
|
18825
|
+
columnId,
|
18826
|
+
rowIdentityAccessor
|
18827
|
+
} = payload;
|
18828
|
+
const changes = omit(state.changes.rows, `${rowId}.${columnId}`);
|
18829
|
+
// if there are no changes left, remove the row
|
18830
|
+
if (!Object.keys(changes[rowId]).length) {
|
18831
|
+
return reducer$2(state, {
|
18832
|
+
type: 'removeRow',
|
18833
|
+
rowId,
|
18834
|
+
payload: {
|
18835
|
+
rowIdentityAccessor
|
18836
|
+
}
|
18837
|
+
});
|
18838
|
+
}
|
18839
|
+
return {
|
18840
|
+
...state,
|
18841
|
+
changes: {
|
18842
|
+
...state.changes,
|
18843
|
+
rows: omit(state.changes.rows, `${rowId}.${columnId}`),
|
18844
|
+
errors: omit(state.changes.errors, `${rowId}.cells.${columnId}`),
|
18845
|
+
moveReasons: omit(state.changes.moveReasons, `${rowId}.${columnId}`)
|
18846
|
+
}
|
18847
|
+
};
|
18848
|
+
}
|
18849
|
+
case 'updateRow':
|
18850
|
+
{
|
18851
|
+
const {
|
18852
|
+
cellErrors,
|
18853
|
+
moveReasons,
|
18854
|
+
original,
|
18855
|
+
value
|
18856
|
+
} = payload;
|
18857
|
+
return {
|
18858
|
+
...state,
|
18859
|
+
changes: {
|
18860
|
+
...state.changes,
|
18861
|
+
rows: setWith(state.changes.rows, rowId, value, Object),
|
18862
|
+
errors: setWith(state.changes.errors, `${rowId}.cells`, cellErrors !== null && cellErrors !== void 0 ? cellErrors : state.changes.errors.cells[rowId], Object),
|
18863
|
+
originals: setWith(state.changes.originals, rowId, original !== null && original !== void 0 ? original : state.changes.originals[rowId], Object),
|
18864
|
+
moveReasons: setWith(state.changes.moveReasons, rowId, moveReasons !== null && moveReasons !== void 0 ? moveReasons : state.changes.moveReasons[rowId], Object),
|
18865
|
+
// status can be undefined, so don't use ??
|
18866
|
+
status: setWith(state.changes.status, rowId, undefined, Object)
|
18867
|
+
}
|
18868
|
+
};
|
18869
|
+
}
|
18870
|
+
case 'removeRow':
|
18871
|
+
{
|
18872
|
+
const {
|
18873
|
+
rowIdentityAccessor
|
18874
|
+
} = payload;
|
18875
|
+
return {
|
18876
|
+
...state,
|
18877
|
+
changes: {
|
18878
|
+
...state.changes,
|
18879
|
+
rows: omit(state.changes.rows, rowId),
|
18880
|
+
errors: omit(state.changes.errors, rowId),
|
18881
|
+
moveReasons: omit(state.changes.moveReasons, rowId),
|
18882
|
+
originals: omit(state.changes.originals, rowId),
|
18883
|
+
status: omit(state.changes.status, rowId)
|
18884
|
+
},
|
18885
|
+
temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor] !== rowId)
|
18886
|
+
};
|
18887
|
+
}
|
18888
|
+
case 'setRowStatus':
|
18889
|
+
{
|
18890
|
+
const {
|
18891
|
+
status
|
18892
|
+
} = payload;
|
18893
|
+
return {
|
18894
|
+
...state,
|
18895
|
+
changes: {
|
18896
|
+
...state.changes,
|
18897
|
+
status: status ? setWith(state.changes.status, rowId, status, Object) : omit(state.changes.status, rowId)
|
18898
|
+
}
|
18899
|
+
};
|
18900
|
+
}
|
18901
|
+
case 'setRowErrors':
|
18902
|
+
{
|
18903
|
+
const {
|
18904
|
+
...errors
|
18905
|
+
} = payload;
|
18906
|
+
return {
|
18907
|
+
...state,
|
18908
|
+
changes: {
|
18909
|
+
...state.changes,
|
18910
|
+
errors: setWith(state.changes.errors, rowId, errors, Object)
|
18911
|
+
}
|
18912
|
+
};
|
18913
|
+
}
|
18914
|
+
case 'insertTemporaryRow':
|
18915
|
+
{
|
18916
|
+
const {
|
18917
|
+
value
|
18918
|
+
} = payload;
|
18919
|
+
return {
|
18920
|
+
...state,
|
18921
|
+
temporaryRows: state.temporaryRows.concat(value),
|
18922
|
+
changes: {
|
18923
|
+
...state.changes,
|
18924
|
+
rows: setWith(state.changes.rows, rowId, value, Object),
|
18925
|
+
originals: setWith(state.changes.originals, rowId, value, Object)
|
18926
|
+
}
|
18927
|
+
};
|
18928
|
+
}
|
18929
|
+
default:
|
18930
|
+
return state;
|
18931
|
+
}
|
18932
|
+
}
|
18933
|
+
function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, validator) {
|
18934
|
+
const saveChanges = function (table, rowId = undefined) {
|
18518
18935
|
try {
|
18519
18936
|
let _exit = false;
|
18520
18937
|
if (!handleSave) {
|
18521
18938
|
console.warn('Tried to save, but Table has no onEditingSave handler');
|
18522
|
-
return Promise.resolve();
|
18939
|
+
return Promise.resolve(false);
|
18523
18940
|
}
|
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;
|
18941
|
+
// sometimes we only want to save one row
|
18942
|
+
const changes = rowId ? {
|
18943
|
+
[rowId]: state.changes.rows[rowId]
|
18944
|
+
} : state.changes.rows;
|
18945
|
+
let completed = true;
|
18946
|
+
const _temp9 = _forOf(Object.keys(changes), function (rowId) {
|
18947
|
+
const status = getRowStatus(rowId);
|
18948
|
+
return _catch(function () {
|
18949
|
+
var _changes$rowId;
|
18950
|
+
function _temp8(_result) {
|
18951
|
+
return _exit ? _result : Promise.resolve(handleSave(changeSet)).then(function () {
|
18952
|
+
// cleanup changes, we don't need them after saving
|
18953
|
+
discardChanges(rowId, table);
|
18954
|
+
// show the saved status, then remove it after a delay
|
18955
|
+
setRowStatus(rowId, 'saved');
|
18956
|
+
setTimeout(() => {
|
18957
|
+
setRowStatus(rowId, undefined);
|
18958
|
+
}, DELAY_BEFORE_REMOVING_SAVE_STATUS);
|
18959
|
+
});
|
18960
|
+
}
|
18961
|
+
const rowChanges = (_changes$rowId = changes[rowId]) !== null && _changes$rowId !== void 0 ? _changes$rowId : {};
|
18962
|
+
// don't try to save if - already saving, or there are known errors
|
18963
|
+
if (!Object.keys(rowChanges).length || status === 'saving' || status === 'errored') {
|
18964
|
+
return;
|
18965
|
+
}
|
18966
|
+
setRowStatus(rowId, 'saving');
|
18967
|
+
const changeSet = {
|
18968
|
+
...state.changes.originals[rowId],
|
18969
|
+
...rowChanges
|
18970
|
+
};
|
18971
|
+
// if we had to create a temporary id, delete it first - it's our data, not theirs
|
18972
|
+
if (isTemporaryRow(changeSet[rowIdentityAccessor])) {
|
18973
|
+
delete changeSet[rowIdentityAccessor];
|
18974
|
+
}
|
18975
|
+
// re-run validation, maybe a cell is already invalid but has never been blurred
|
18976
|
+
const _temp7 = function () {
|
18977
|
+
if (validator) {
|
18978
|
+
return Promise.resolve(validator(changeSet)).then(function (errors) {
|
18979
|
+
if (errors && Object.keys(errors).length) {
|
18980
|
+
throw errors;
|
18575
18981
|
}
|
18576
|
-
}
|
18577
|
-
|
18578
|
-
|
18579
|
-
|
18580
|
-
|
18581
|
-
|
18582
|
-
|
18583
|
-
|
18584
|
-
|
18585
|
-
|
18586
|
-
|
18587
|
-
|
18588
|
-
|
18589
|
-
|
18590
|
-
|
18982
|
+
});
|
18983
|
+
}
|
18984
|
+
}();
|
18985
|
+
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7); // send new data to the server
|
18986
|
+
}, function (error) {
|
18987
|
+
var _error$response;
|
18988
|
+
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) {
|
18989
|
+
console.error(error);
|
18990
|
+
}
|
18991
|
+
// the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc
|
18992
|
+
// this code handles those errors and maps them either to row errors or cell specific errors
|
18993
|
+
let rowError;
|
18994
|
+
let cellErrors;
|
18995
|
+
if (typeof error === 'string') {
|
18996
|
+
rowError = error;
|
18997
|
+
} else if (error instanceof Error) {
|
18998
|
+
var _error$response2;
|
18999
|
+
rowError = error.message;
|
19000
|
+
// most of our apis return error objects within this shape
|
19001
|
+
if (typeof ((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) === 'object') {
|
19002
|
+
var _error$response3;
|
19003
|
+
cellErrors = (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data;
|
19004
|
+
}
|
19005
|
+
} else if (typeof error === 'object') {
|
19006
|
+
cellErrors = error;
|
19007
|
+
}
|
19008
|
+
if (rowError || cellErrors) {
|
19009
|
+
dispatch({
|
19010
|
+
type: 'setRowErrors',
|
19011
|
+
rowId,
|
19012
|
+
payload: {
|
19013
|
+
row: rowError,
|
19014
|
+
cells: cellErrors,
|
19015
|
+
shouldShowErrorAlert: true
|
18591
19016
|
}
|
18592
|
-
setRowSaveStatus(rowId, undefined);
|
18593
19017
|
});
|
18594
|
-
}
|
18595
|
-
|
18596
|
-
|
18597
|
-
}
|
18598
|
-
}()
|
19018
|
+
}
|
19019
|
+
setRowStatus(rowId, 'errored');
|
19020
|
+
completed = false;
|
19021
|
+
});
|
19022
|
+
}, function () {
|
19023
|
+
return _exit;
|
19024
|
+
});
|
19025
|
+
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function (_result3) {
|
19026
|
+
return _exit ? _result3 : completed;
|
19027
|
+
}) : _exit ? _temp9 : completed);
|
18599
19028
|
} catch (e) {
|
18600
19029
|
return Promise.reject(e);
|
18601
19030
|
}
|
18602
19031
|
};
|
18603
|
-
const
|
19032
|
+
const onCellChanged = function (cell, rowIndex, nextValue, shouldRunUpdaters = true) {
|
18604
19033
|
try {
|
18605
|
-
|
18606
|
-
|
18607
|
-
|
18608
|
-
|
18609
|
-
|
18610
|
-
|
18611
|
-
|
18612
|
-
|
18613
|
-
|
18614
|
-
|
18615
|
-
|
18616
|
-
|
18617
|
-
|
18618
|
-
|
18619
|
-
|
18620
|
-
|
18621
|
-
|
18622
|
-
|
19034
|
+
function _temp6() {
|
19035
|
+
var _state$changes$errors11;
|
19036
|
+
function _temp4() {
|
19037
|
+
// only set errors and move reasons for the cells we're currently acting on
|
19038
|
+
// why? because the UX is not good if we set them for cells the user hasn't touched yet
|
19039
|
+
const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];
|
19040
|
+
const allCells = cell.row._getAllCellsByColumnId();
|
19041
|
+
cellsToActOn.forEach(accessor => {
|
19042
|
+
if (validationErrors[accessor]) {
|
19043
|
+
nextCellErrors[accessor] = validationErrors[accessor];
|
19044
|
+
// don't show move indicator for cells with errors, they aren't valid and can't be saved
|
19045
|
+
delete nextMoveReasons[accessor];
|
19046
|
+
} else {
|
19047
|
+
var _allCells$accessor;
|
19048
|
+
// there isn't any error in this run, remove any error set in state
|
19049
|
+
delete nextCellErrors[accessor];
|
19050
|
+
if ((_allCells$accessor = allCells[accessor]) !== null && _allCells$accessor !== void 0 && _allCells$accessor.column.getIsSorted()) {
|
19051
|
+
// run row move determination
|
19052
|
+
const reason = willRowMove(cell, nextChanges[accessor], rowIndex, localization);
|
19053
|
+
// if the row will move based on this change save why, otherwise delete any existing state
|
19054
|
+
if (reason) {
|
19055
|
+
nextMoveReasons[accessor] = reason;
|
19056
|
+
} else {
|
19057
|
+
delete nextMoveReasons[accessor];
|
18623
19058
|
}
|
18624
|
-
}
|
18625
|
-
|
19059
|
+
}
|
19060
|
+
}
|
19061
|
+
});
|
19062
|
+
dispatch({
|
19063
|
+
type: 'updateRow',
|
19064
|
+
rowId: cell.row.id,
|
19065
|
+
payload: {
|
19066
|
+
cellErrors: nextCellErrors,
|
19067
|
+
moveReasons: nextMoveReasons,
|
19068
|
+
value: nextChanges
|
19069
|
+
}
|
19070
|
+
});
|
19071
|
+
}
|
19072
|
+
// create a projection of the next state, so we can act against it
|
19073
|
+
const nextChanges = {
|
19074
|
+
...changes,
|
19075
|
+
...updatesForOtherCells
|
19076
|
+
};
|
19077
|
+
const nextMoveReasons = {
|
19078
|
+
...state.changes.moveReasons[cell.row.id]
|
19079
|
+
};
|
19080
|
+
const nextCellErrors = {
|
19081
|
+
...((_state$changes$errors11 = state.changes.errors[cell.row.id]) === null || _state$changes$errors11 === void 0 ? void 0 : _state$changes$errors11.cells)
|
19082
|
+
};
|
19083
|
+
// run validation - if there are changes, and if there is an original stored
|
19084
|
+
let validationErrors = {};
|
19085
|
+
const _temp3 = function () {
|
19086
|
+
if (validator && Object.keys(nextChanges).length && state.changes.originals[cell.row.id]) {
|
19087
|
+
// merge with the original so we get a full row
|
19088
|
+
const nextRowValue = {
|
19089
|
+
...state.changes.originals[cell.row.id],
|
19090
|
+
...changes,
|
19091
|
+
...updatesForOtherCells
|
19092
|
+
};
|
19093
|
+
return Promise.resolve(validator(nextRowValue)).then(function (_validator2) {
|
19094
|
+
validationErrors = _validator2 !== null && _validator2 !== void 0 ? _validator2 : {};
|
18626
19095
|
});
|
19096
|
+
}
|
19097
|
+
}();
|
19098
|
+
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
19099
|
+
}
|
19100
|
+
const changes = nextValue !== undefined ? {
|
19101
|
+
...state.changes.rows[cell.row.id],
|
19102
|
+
[cell.column.id]: nextValue
|
19103
|
+
} : {
|
19104
|
+
...state.changes.rows[cell.row.id]
|
19105
|
+
};
|
19106
|
+
if (!Object.keys(changes).length) {
|
19107
|
+
return Promise.resolve();
|
19108
|
+
}
|
19109
|
+
let updatesForOtherCells = {};
|
19110
|
+
// run the updater handler if there is one, to see if there are any other cells to update
|
19111
|
+
const _temp5 = function () {
|
19112
|
+
if (typeof handleChange === 'function' && shouldRunUpdaters) {
|
19113
|
+
const previousRowValue = {
|
19114
|
+
...state.changes.originals[cell.row.id]
|
19115
|
+
};
|
19116
|
+
const nextRowValue = {
|
19117
|
+
...state.changes.originals[cell.row.id],
|
19118
|
+
...changes
|
19119
|
+
};
|
19120
|
+
return Promise.resolve(handleChange(cell.column.id, changes[cell.column.id], nextRowValue, previousRowValue)).then(function (_handleChange) {
|
19121
|
+
updatesForOtherCells = _handleChange !== null && _handleChange !== void 0 ? _handleChange : {};
|
18627
19122
|
});
|
18628
19123
|
}
|
18629
19124
|
}();
|
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();
|
19125
|
+
return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5));
|
18647
19126
|
} catch (e) {
|
18648
19127
|
return Promise.reject(e);
|
18649
19128
|
}
|
18650
|
-
};
|
18651
|
-
|
19129
|
+
}; // general
|
19130
|
+
// rows
|
19131
|
+
const setRowValue = function (rowId, original, value) {
|
18652
19132
|
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;
|
19133
|
+
function _temp2() {
|
19134
|
+
dispatch({
|
19135
|
+
type: 'updateRow',
|
19136
|
+
rowId,
|
19137
|
+
payload: {
|
19138
|
+
cellErrors,
|
19139
|
+
original,
|
19140
|
+
value
|
18677
19141
|
}
|
18678
|
-
}
|
18679
|
-
}
|
18680
|
-
|
19142
|
+
});
|
19143
|
+
}
|
19144
|
+
let cellErrors;
|
19145
|
+
const _temp = function () {
|
19146
|
+
if (validator) {
|
19147
|
+
const row = {
|
19148
|
+
...original,
|
19149
|
+
...value
|
19150
|
+
};
|
19151
|
+
return Promise.resolve(validator(row)).then(function (_validator) {
|
19152
|
+
cellErrors = _validator !== null && _validator !== void 0 ? _validator : {};
|
19153
|
+
});
|
19154
|
+
}
|
19155
|
+
}();
|
19156
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
18681
19157
|
} catch (e) {
|
18682
19158
|
return Promise.reject(e);
|
18683
19159
|
}
|
18684
19160
|
};
|
18685
19161
|
const localization = useLocalization();
|
18686
|
-
const [
|
18687
|
-
|
18688
|
-
|
18689
|
-
|
18690
|
-
|
18691
|
-
|
19162
|
+
const [state, dispatch] = React__default.useReducer(reducer$2, {
|
19163
|
+
changes: {
|
19164
|
+
rows: {},
|
19165
|
+
errors: {},
|
19166
|
+
moveReasons: {},
|
19167
|
+
originals: {},
|
19168
|
+
status: {}
|
19169
|
+
},
|
19170
|
+
temporaryRows: []
|
19171
|
+
});
|
19172
|
+
function getRowValue(rowId) {
|
19173
|
+
var _state$changes$rows$r, _state$changes$rows;
|
19174
|
+
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
19175
|
}
|
18693
|
-
function
|
18694
|
-
var
|
18695
|
-
return (
|
19176
|
+
function getRowMoveReason(rowId) {
|
19177
|
+
var _Object$values$, _state$changes$moveRe, _state$changes$moveRe2;
|
19178
|
+
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
19179
|
}
|
18697
|
-
const pendingChangesUpdater = usePendingChangesUpdater(handleChange, setPendingChanges);
|
18698
19180
|
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;
|
19181
|
+
var _state$changes$errors, _state$changes$errors2, _state$changes$errors3;
|
19182
|
+
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;
|
18704
19183
|
}
|
18705
|
-
function
|
18706
|
-
var
|
18707
|
-
|
19184
|
+
function hasRowErrorsShownInAlert(rowId) {
|
19185
|
+
var _state$changes$errors4;
|
19186
|
+
return hasRowErrors(rowId) && !!((_state$changes$errors4 = state.changes.errors[rowId]) !== null && _state$changes$errors4 !== void 0 && _state$changes$errors4.shouldShowErrorAlert);
|
19187
|
+
}
|
19188
|
+
function hasTemporaryRowErrors() {
|
19189
|
+
var _state$temporaryRows, _state$changes$errors5, _state$changes$errors6, _state$changes$errors7;
|
19190
|
+
const newRow = (_state$temporaryRows = state.temporaryRows) === null || _state$temporaryRows === void 0 ? void 0 : _state$temporaryRows[0];
|
19191
|
+
if (!newRow) {
|
18708
19192
|
return false;
|
18709
19193
|
}
|
18710
|
-
|
19194
|
+
const rowId = newRow[rowIdentityAccessor];
|
19195
|
+
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;
|
18711
19196
|
}
|
18712
|
-
function
|
18713
|
-
|
18714
|
-
if (rowPendingChanges) {
|
18715
|
-
const {
|
18716
|
-
_meta,
|
18717
|
-
...pendingChange
|
18718
|
-
} = rowPendingChanges;
|
18719
|
-
return pendingChange;
|
18720
|
-
}
|
18721
|
-
return undefined;
|
19197
|
+
function getRowStatus(rowId) {
|
19198
|
+
return state.changes.status[rowId];
|
18722
19199
|
}
|
18723
|
-
function
|
18724
|
-
|
18725
|
-
|
18726
|
-
|
18727
|
-
|
19200
|
+
function setRowStatus(rowId, status) {
|
19201
|
+
dispatch({
|
19202
|
+
type: 'setRowStatus',
|
19203
|
+
rowId,
|
19204
|
+
payload: {
|
19205
|
+
status
|
19206
|
+
}
|
19207
|
+
});
|
18728
19208
|
}
|
18729
|
-
function
|
18730
|
-
|
18731
|
-
|
18732
|
-
|
18733
|
-
|
18734
|
-
|
18735
|
-
|
18736
|
-
|
18737
|
-
|
19209
|
+
function insertTemporaryRow(data) {
|
19210
|
+
const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${uuid.v4()}`;
|
19211
|
+
const value = {
|
19212
|
+
...data,
|
19213
|
+
[rowIdentityAccessor]: newRowId
|
19214
|
+
};
|
19215
|
+
dispatch({
|
19216
|
+
type: 'insertTemporaryRow',
|
19217
|
+
rowId: newRowId,
|
19218
|
+
payload: {
|
19219
|
+
value
|
18738
19220
|
}
|
18739
|
-
return nextStates;
|
18740
19221
|
});
|
19222
|
+
return newRowId;
|
19223
|
+
}
|
19224
|
+
// cells
|
19225
|
+
function setCellValue(cell, value) {
|
19226
|
+
const rowId = cell.row.id;
|
19227
|
+
const columnId = cell.column.id;
|
19228
|
+
// update if the change is different to the original value
|
19229
|
+
if (value !== cell.row.original[columnId]) {
|
19230
|
+
dispatch({
|
19231
|
+
type: 'setCellValue',
|
19232
|
+
rowId,
|
19233
|
+
payload: {
|
19234
|
+
columnId,
|
19235
|
+
row: cell.row.original,
|
19236
|
+
value
|
19237
|
+
}
|
19238
|
+
});
|
19239
|
+
}
|
19240
|
+
// otherwise remove any previous change - no point saving the same value
|
19241
|
+
else if (cell.row.id in state.changes.rows) {
|
19242
|
+
dispatch({
|
19243
|
+
type: 'removeCellValue',
|
19244
|
+
rowId,
|
19245
|
+
payload: {
|
19246
|
+
columnId,
|
19247
|
+
rowIdentityAccessor
|
19248
|
+
}
|
19249
|
+
});
|
19250
|
+
}
|
18741
19251
|
}
|
18742
|
-
function
|
18743
|
-
var
|
18744
|
-
return (
|
19252
|
+
function getCellValue(cell) {
|
19253
|
+
var _state$changes$rows2, _state$changes$rows2$;
|
19254
|
+
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];
|
18745
19255
|
}
|
18746
|
-
function
|
18747
|
-
|
18748
|
-
|
18749
|
-
}
|
18750
|
-
return rowId ? !!pendingChanges[rowId] : !!Object.keys(pendingChanges).length;
|
19256
|
+
function getCellError(cell) {
|
19257
|
+
var _state$changes$errors8, _state$changes$errors9, _state$changes$errors10;
|
19258
|
+
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];
|
18751
19259
|
}
|
18752
|
-
function
|
18753
|
-
|
18754
|
-
|
19260
|
+
function getErrorsShownInAlert() {
|
19261
|
+
const rowsWithErrors = Object.keys(state.changes.errors);
|
19262
|
+
if (!rowsWithErrors.length) {
|
19263
|
+
return [];
|
18755
19264
|
}
|
18756
|
-
return
|
18757
|
-
}
|
18758
|
-
function getAlertErrors() {
|
18759
|
-
return Object.keys(pendingChanges).filter(hasRowErrorsSeen).map(rowId => ({
|
19265
|
+
return rowsWithErrors.filter(hasRowErrorsShownInAlert).map(rowId => ({
|
18760
19266
|
rowId,
|
18761
|
-
|
19267
|
+
changes: state.changes.rows[rowId],
|
19268
|
+
errors: state.changes.errors[rowId]
|
18762
19269
|
}));
|
18763
19270
|
}
|
18764
|
-
function
|
18765
|
-
|
18766
|
-
const nextChanges = {
|
18767
|
-
...currentChanges
|
18768
|
-
};
|
18769
|
-
delete nextChanges[rowId];
|
18770
|
-
return nextChanges;
|
18771
|
-
});
|
19271
|
+
function hasSaved() {
|
19272
|
+
return !!Object.values(state.changes.status).filter(value => value === 'saved').length;
|
18772
19273
|
}
|
18773
|
-
function
|
18774
|
-
return Object.
|
19274
|
+
function hasChanges(rowId) {
|
19275
|
+
return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;
|
19276
|
+
}
|
19277
|
+
function discardChanges(rowId, table) {
|
19278
|
+
// remove any new rows from pinned state before discarding them
|
19279
|
+
table.resetRowPinning(true);
|
19280
|
+
dispatch({
|
19281
|
+
type: 'removeRow',
|
19282
|
+
rowId,
|
19283
|
+
payload: {
|
19284
|
+
rowIdentityAccessor
|
19285
|
+
}
|
19286
|
+
});
|
18775
19287
|
}
|
18776
19288
|
return {
|
19289
|
+
// row
|
19290
|
+
setRowValue,
|
19291
|
+
getRowValue,
|
19292
|
+
getRowMoveReason,
|
19293
|
+
hasRowErrors,
|
19294
|
+
hasRowErrorsShownInAlert,
|
19295
|
+
hasTemporaryRowErrors,
|
19296
|
+
getRowStatus,
|
19297
|
+
setRowStatus,
|
19298
|
+
// cells
|
19299
|
+
setCellValue,
|
18777
19300
|
getCellValue,
|
18778
19301
|
getCellError,
|
18779
|
-
|
18780
|
-
|
18781
|
-
|
19302
|
+
onCellChanged,
|
19303
|
+
// general
|
19304
|
+
getErrorsShownInAlert,
|
18782
19305
|
hasChanges,
|
18783
|
-
hasAlertErrors,
|
18784
|
-
getAlertErrors,
|
18785
19306
|
saveChanges,
|
18786
|
-
|
18787
|
-
|
18788
|
-
|
18789
|
-
|
18790
|
-
|
18791
|
-
setRowSaveStatus,
|
18792
|
-
getRowMoveReason,
|
18793
|
-
getCompletedRowsCount
|
19307
|
+
discardChanges,
|
19308
|
+
hasSaved,
|
19309
|
+
// new rows
|
19310
|
+
insertTemporaryRow,
|
19311
|
+
temporaryRows: state.temporaryRows
|
18794
19312
|
};
|
18795
19313
|
}
|
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) {
|
19314
|
+
|
19315
|
+
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, rowIdentityAccessor, validator) {
|
19316
|
+
const createRow = function (table, scrollToIndex, row) {
|
18808
19317
|
try {
|
18809
|
-
|
18810
|
-
|
18811
|
-
|
18812
|
-
|
18813
|
-
|
18814
|
-
|
18815
|
-
|
18816
|
-
|
18817
|
-
|
18818
|
-
|
18819
|
-
|
18820
|
-
|
18821
|
-
|
19318
|
+
let _exit = false;
|
19319
|
+
function _temp2(_result) {
|
19320
|
+
if (_exit) return _result;
|
19321
|
+
const changeset = row !== null && row !== void 0 ? row : handleCreate();
|
19322
|
+
try {
|
19323
|
+
if (changeset) {
|
19324
|
+
const newRowId = pendingChangesFns.insertTemporaryRow(changeset);
|
19325
|
+
// reset before changing row otherwise the cell changes and validation might run
|
19326
|
+
setLastFocusedCellIndex(undefined);
|
19327
|
+
// set the active row to the new row before toggling editing on
|
19328
|
+
const temporaryRows = tableMeta.editing.temporaryRows;
|
19329
|
+
const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
|
19330
|
+
tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
|
19331
|
+
// wait until set states have run
|
19332
|
+
requestAnimationFrame(() => {
|
19333
|
+
toggleEditing(true, table, scrollToIndex, false);
|
19334
|
+
table.setRowPinning(currentState => {
|
19335
|
+
var _ref, _currentState$bottom;
|
19336
|
+
return {
|
19337
|
+
...currentState,
|
19338
|
+
bottom: (_ref = (_currentState$bottom = currentState.bottom) !== null && _currentState$bottom !== void 0 ? _currentState$bottom : []) === null || _ref === void 0 ? void 0 : _ref.concat(newRowId)
|
19339
|
+
};
|
19340
|
+
});
|
19341
|
+
});
|
19342
|
+
}
|
19343
|
+
} catch (error) {
|
19344
|
+
console.error(error);
|
19345
|
+
}
|
19346
|
+
}
|
19347
|
+
if (!handleCreate) {
|
19348
|
+
return Promise.resolve();
|
19349
|
+
}
|
19350
|
+
const tableMeta = table.options.meta;
|
19351
|
+
const _temp = function () {
|
19352
|
+
if (tableMeta.rowActive.rowActiveIndex !== undefined) {
|
19353
|
+
var _table$getRowModel$ro2;
|
19354
|
+
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) {
|
19355
|
+
if (!saved) {
|
19356
|
+
_exit = true;
|
18822
19357
|
}
|
18823
19358
|
});
|
18824
19359
|
}
|
18825
19360
|
}();
|
18826
|
-
return Promise.resolve(
|
19361
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
18827
19362
|
} catch (e) {
|
18828
19363
|
return Promise.reject(e);
|
18829
19364
|
}
|
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
19365
|
};
|
18858
|
-
//
|
18859
|
-
const
|
18860
|
-
|
18861
|
-
|
18862
|
-
|
18863
|
-
|
18864
|
-
|
18865
|
-
|
18866
|
-
|
18867
|
-
|
18868
|
-
|
18869
|
-
|
18870
|
-
|
18871
|
-
|
18872
|
-
|
18873
|
-
|
18874
|
-
}
|
19366
|
+
// used to switch the table into editing mode
|
19367
|
+
const [isEditing, setEditing] = React__default.useState(false);
|
19368
|
+
// used to switch the editing between "detailed" mode
|
19369
|
+
const [isDetailedMode, toggleDetailedMode] = React__default.useState(false);
|
19370
|
+
// used to contain ref to the create button
|
19371
|
+
const createRowButtonRef = React__default.useRef(null);
|
19372
|
+
// store the last focused cell, so that up/down arrow key navigation remains in the same column
|
19373
|
+
const [lastFocusedCellIndex, setLastFocusedCellIndex] = React__default.useState(undefined);
|
19374
|
+
const pendingChangesFns = usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, validator);
|
19375
|
+
function toggleEditing(enabled, table, scrollToIndex, doSave = true) {
|
19376
|
+
const tableMeta = table.options.meta;
|
19377
|
+
if (enabled) {
|
19378
|
+
var _tableMeta$rowActive$, _table$getRowModel$ro;
|
19379
|
+
const index = (_tableMeta$rowActive$ = tableMeta.rowActive.rowActiveIndex) !== null && _tableMeta$rowActive$ !== void 0 ? _tableMeta$rowActive$ : 0;
|
19380
|
+
if (tableMeta.rowActive.rowActiveIndex === undefined) {
|
19381
|
+
tableMeta.rowActive.setRowActiveIndex(index);
|
18875
19382
|
}
|
18876
|
-
|
18877
|
-
|
18878
|
-
|
19383
|
+
if (!isTemporaryRow((_table$getRowModel$ro = table.getRowModel().rows[index]) === null || _table$getRowModel$ro === void 0 ? void 0 : _table$getRowModel$ro.id)) {
|
19384
|
+
scrollToIndex(index);
|
19385
|
+
}
|
19386
|
+
} else if (!enabled) {
|
19387
|
+
// reset detailed mode
|
19388
|
+
toggleDetailedMode(false);
|
19389
|
+
// reset the last index back to the first focusable element, when editing gets turned off
|
19390
|
+
setLastFocusedCellIndex(undefined);
|
19391
|
+
}
|
19392
|
+
setEditing(enabled);
|
19393
|
+
if (doSave) {
|
19394
|
+
pendingChangesFns.saveChanges(table);
|
18879
19395
|
}
|
18880
19396
|
}
|
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
19397
|
return {
|
18898
|
-
|
18899
|
-
|
19398
|
+
isEnabled,
|
19399
|
+
isEditing,
|
19400
|
+
isDetailedMode,
|
19401
|
+
toggleDetailedMode: isEnabled ? toggleDetailedMode : () => undefined,
|
19402
|
+
toggleEditing: isEnabled ? toggleEditing : () => undefined,
|
19403
|
+
lastFocusedCellIndex,
|
19404
|
+
setLastFocusedCellIndex,
|
19405
|
+
createRow,
|
19406
|
+
createRowButtonRef,
|
19407
|
+
...pendingChangesFns
|
18900
19408
|
};
|
18901
19409
|
}
|
18902
19410
|
|
@@ -18940,7 +19448,6 @@ function RowMoveIndicator(props) {
|
|
18940
19448
|
if (!show) {
|
18941
19449
|
return null;
|
18942
19450
|
}
|
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
19451
|
const {
|
18945
19452
|
title,
|
18946
19453
|
description
|
@@ -18949,7 +19456,7 @@ function RowMoveIndicator(props) {
|
|
18949
19456
|
placement: "bottom",
|
18950
19457
|
title: description.replace('[COLUMN]', columnMeta.header)
|
18951
19458
|
}, /*#__PURE__*/React__default.createElement("span", {
|
18952
|
-
|
19459
|
+
"data-row-move-indicator": true
|
18953
19460
|
}, /*#__PURE__*/React__default.createElement(Icon, {
|
18954
19461
|
name: "info",
|
18955
19462
|
className: "-mt-0.5 mr-1 !h-4 !w-4 rounded-full bg-white !p-0 text-blue-500"
|
@@ -19138,20 +19645,44 @@ function EditingControlCell(props) {
|
|
19138
19645
|
const {
|
19139
19646
|
rowIndex
|
19140
19647
|
} = React__default.useContext(RowContext);
|
19141
|
-
const
|
19648
|
+
const {
|
19649
|
+
table
|
19650
|
+
} = cell.getContext();
|
19651
|
+
const tableMeta = table.options.meta;
|
19142
19652
|
const columnMeta = cell.column.columnDef.meta;
|
19143
19653
|
const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
|
19654
|
+
const type = (_columnMeta$control = columnMeta.control) !== null && _columnMeta$control !== void 0 ? _columnMeta$control : 'input';
|
19144
19655
|
const handleFocus = useEditingCellAutofocus(props);
|
19145
|
-
const
|
19656
|
+
const value = cell.getValue();
|
19657
|
+
// some controls, like select2, should trigger cell changed (validation, updates) as the value changes
|
19658
|
+
const hasNonTextControl = React__default.useMemo(() => {
|
19659
|
+
var _cellRef$current;
|
19660
|
+
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"]'));
|
19661
|
+
}, [cellRef.current]);
|
19662
|
+
const handleChange = React__default.useCallback(nextValue => {
|
19663
|
+
if (nextValue !== value) {
|
19664
|
+
tableMeta.editing.setCellValue(cell, nextValue);
|
19665
|
+
if (hasNonTextControl) {
|
19666
|
+
requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
|
19667
|
+
}
|
19668
|
+
}
|
19669
|
+
}, [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex, value]);
|
19670
|
+
const blur = React__default.useCallback(function blur() {
|
19146
19671
|
tableMeta.editing.toggleDetailedMode(false);
|
19147
|
-
tableMeta.editing.
|
19148
|
-
};
|
19672
|
+
tableMeta.editing.onCellChanged(cell, rowIndex, undefined, !hasNonTextControl);
|
19673
|
+
}, [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex]);
|
19674
|
+
const handleBlur = React__default.useCallback(event => {
|
19675
|
+
if (isElementInsideOrTriggeredFromContainer(event.relatedTarget, event.currentTarget)) {
|
19676
|
+
return;
|
19677
|
+
}
|
19678
|
+
blur();
|
19679
|
+
}, [blur]);
|
19149
19680
|
// ensure that blur runs when the cell gets unmounted (when vertically arrow key navigating)
|
19150
19681
|
React__default.useEffect(() => {
|
19151
19682
|
const ref = cellRef.current;
|
19152
19683
|
return () => {
|
19153
19684
|
if (document.activeElement === ref || isElementInsideOrTriggeredFromContainer(document.activeElement, ref)) {
|
19154
|
-
|
19685
|
+
blur();
|
19155
19686
|
}
|
19156
19687
|
};
|
19157
19688
|
}, []);
|
@@ -19164,14 +19695,13 @@ function EditingControlCell(props) {
|
|
19164
19695
|
isDetailedMode: tableMeta.editing.isDetailedMode,
|
19165
19696
|
isTruncated: !!columnMeta.enableTruncate,
|
19166
19697
|
onBlur: handleBlur,
|
19167
|
-
onChange:
|
19698
|
+
onChange: handleChange,
|
19168
19699
|
row: cell.row.original,
|
19169
|
-
rowPendingChanges: tableMeta.editing.
|
19700
|
+
rowPendingChanges: tableMeta.editing.getRowValue(cell.row.id),
|
19170
19701
|
tabIndex: isActiveRow ? 0 : -1,
|
19171
|
-
toggleEditing: tableMeta.editing.toggleEditing,
|
19172
19702
|
toggleDetailedMode: tableMeta.editing.toggleDetailedMode,
|
19173
|
-
type
|
19174
|
-
value
|
19703
|
+
type,
|
19704
|
+
value
|
19175
19705
|
};
|
19176
19706
|
const cellAttributes = {
|
19177
19707
|
...getCellAttributes(cell, index, isHighlighted),
|
@@ -19203,7 +19733,6 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19203
19733
|
row,
|
19204
19734
|
rowPendingChanges,
|
19205
19735
|
tabIndex = -1,
|
19206
|
-
toggleEditing,
|
19207
19736
|
toggleDetailedMode,
|
19208
19737
|
type = 'input',
|
19209
19738
|
value
|
@@ -19234,6 +19763,13 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19234
19763
|
ref: controlRef
|
19235
19764
|
}));
|
19236
19765
|
}
|
19766
|
+
if (type === 'checkbox') {
|
19767
|
+
return /*#__PURE__*/React__default.createElement(Checkbox, Object.assign({}, commonProps, {
|
19768
|
+
checked: Boolean(value),
|
19769
|
+
onChange: onChange,
|
19770
|
+
ref: controlRef
|
19771
|
+
}));
|
19772
|
+
}
|
19237
19773
|
const handleInputKeyDown = event => {
|
19238
19774
|
const target = event.target;
|
19239
19775
|
if (target.readOnly) {
|
@@ -19262,8 +19798,8 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19262
19798
|
}
|
19263
19799
|
// reset the value, or exit edit mode when pressing escape
|
19264
19800
|
if (event.key === 'Escape') {
|
19265
|
-
event.preventDefault();
|
19266
19801
|
if (isDetailedMode) {
|
19802
|
+
event.preventDefault();
|
19267
19803
|
toggleDetailedMode(false);
|
19268
19804
|
if (value !== currentValue) {
|
19269
19805
|
props.onChange(currentValue);
|
@@ -19273,8 +19809,6 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19273
19809
|
var _target$select2;
|
19274
19810
|
return (_target$select2 = target.select) === null || _target$select2 === void 0 ? void 0 : _target$select2.call(target);
|
19275
19811
|
});
|
19276
|
-
} else {
|
19277
|
-
toggleEditing(false);
|
19278
19812
|
}
|
19279
19813
|
return;
|
19280
19814
|
}
|
@@ -19373,12 +19907,37 @@ function Cell$5(props) {
|
|
19373
19907
|
return /*#__PURE__*/React__default.createElement(DisplayCell, Object.assign({}, props));
|
19374
19908
|
}
|
19375
19909
|
|
19376
|
-
function
|
19910
|
+
function DiscardChangesConfirmationDialog(props) {
|
19911
|
+
const {
|
19912
|
+
onDiscard: handleDiscard,
|
19913
|
+
...dialogProps
|
19914
|
+
} = props;
|
19915
|
+
const {
|
19916
|
+
texts
|
19917
|
+
} = useLocalization();
|
19918
|
+
const handleClickInsideDialogContent = event => {
|
19919
|
+
// Prevents the click event from propagating to the table, ensuring the row isn't saved when a click occurs
|
19920
|
+
// inside the dialog
|
19921
|
+
event.stopPropagation();
|
19922
|
+
};
|
19923
|
+
return /*#__PURE__*/React__default.createElement(Dialog, Object.assign({}, dialogProps), /*#__PURE__*/React__default.createElement(Dialog.Content, {
|
19924
|
+
"aria-label": texts.table3.editing.clearChangesConfirmationDialog.title,
|
19925
|
+
onClick: handleClickInsideDialogContent
|
19926
|
+
}, /*#__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, {
|
19927
|
+
tabIndex: 0
|
19928
|
+
}, texts.table3.editing.clearChangesConfirmationDialog.cancel)), /*#__PURE__*/React__default.createElement(Dialog.Close, null, /*#__PURE__*/React__default.createElement(Button$1, {
|
19929
|
+
autoFocus: true,
|
19930
|
+
tabIndex: 0,
|
19931
|
+
appearance: "primary",
|
19932
|
+
onClick: handleDiscard
|
19933
|
+
}, texts.table3.editing.clearChangesConfirmationDialog.confirm))))));
|
19934
|
+
}
|
19935
|
+
|
19936
|
+
function EditingActionsMenu(props) {
|
19377
19937
|
const {
|
19378
19938
|
hasChanges,
|
19379
19939
|
hasErrors,
|
19380
|
-
|
19381
|
-
onExit: handleExit,
|
19940
|
+
onDiscard: handleDiscard,
|
19382
19941
|
onEditingSave: handleSave,
|
19383
19942
|
isLastRow
|
19384
19943
|
} = props;
|
@@ -19400,11 +19959,11 @@ function EditingActionMenu(props) {
|
|
19400
19959
|
return /*#__PURE__*/React__default.createElement(IconButton, {
|
19401
19960
|
appearance: "transparent",
|
19402
19961
|
"aria-label": texts.table3.editing.actions.tooltip,
|
19403
|
-
className: "group-[[data-row-editing-status]]/row:hidden",
|
19404
19962
|
icon: "more",
|
19405
19963
|
onKeyDown: handleKeyDown,
|
19406
19964
|
menu: menuProps => (/*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content, {
|
19407
|
-
onKeyDown: handleMenuContentKeyDown
|
19965
|
+
onKeyDown: handleMenuContentKeyDown,
|
19966
|
+
onFocusOutside: event => event.preventDefault()
|
19408
19967
|
}, /*#__PURE__*/React__default.createElement(Menu$1.Item, {
|
19409
19968
|
icon: "tick",
|
19410
19969
|
disabled: !hasChanges || hasErrors,
|
@@ -19412,42 +19971,13 @@ function EditingActionMenu(props) {
|
|
19412
19971
|
}, texts.table3.editing.actions.save), /*#__PURE__*/React__default.createElement(Menu$1.Item, {
|
19413
19972
|
icon: "close",
|
19414
19973
|
disabled: !hasChanges,
|
19415
|
-
dialog: props => /*#__PURE__*/React__default.createElement(
|
19416
|
-
|
19974
|
+
dialog: props => /*#__PURE__*/React__default.createElement(DiscardChangesConfirmationDialog, Object.assign({}, props, {
|
19975
|
+
onDiscard: handleDiscard
|
19417
19976
|
}))
|
19418
|
-
}, texts.table3.editing.actions.clear)
|
19419
|
-
icon: "undo",
|
19420
|
-
onClick: handleExit
|
19421
|
-
}, texts.table3.editing.actions.exit))))
|
19977
|
+
}, texts.table3.editing.actions.clear))))
|
19422
19978
|
});
|
19423
19979
|
}
|
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
19980
|
|
19450
|
-
const COMPLETE_INDICATOR_DELAY = 3000;
|
19451
19981
|
function SaveStatus(props) {
|
19452
19982
|
const {
|
19453
19983
|
rowId,
|
@@ -19457,18 +19987,7 @@ function SaveStatus(props) {
|
|
19457
19987
|
texts
|
19458
19988
|
} = useLocalization();
|
19459
19989
|
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]);
|
19990
|
+
const status = tableMeta.editing.getRowStatus(rowId);
|
19472
19991
|
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
19992
|
'mt-0.5': tableMeta.rowHeight.height === 'short',
|
19474
19993
|
'mt-1': tableMeta.rowHeight.height === 'medium',
|
@@ -19479,7 +19998,7 @@ function SaveStatus(props) {
|
|
19479
19998
|
className: "!contents"
|
19480
19999
|
}, /*#__PURE__*/React__default.createElement("span", {
|
19481
20000
|
className: className
|
19482
|
-
}, status === '
|
20001
|
+
}, status === 'saving' ? (/*#__PURE__*/React__default.createElement(Tooltip, {
|
19483
20002
|
title: texts.table3.editing.saving.progress
|
19484
20003
|
}, /*#__PURE__*/React__default.createElement(Spinner, {
|
19485
20004
|
delay: 0,
|
@@ -19520,15 +20039,46 @@ function Row$2(props) {
|
|
19520
20039
|
}
|
19521
20040
|
}
|
19522
20041
|
}, [tableMeta.editing.isEditing, isActiveRow]);
|
20042
|
+
const rowStatus = tableMeta.editing.getRowStatus(row.id);
|
20043
|
+
// discard new row
|
20044
|
+
const [showDiscardDialog, setShowDiscardDialog] = React__default.useState(false);
|
20045
|
+
function handleDiscard() {
|
20046
|
+
tableMeta.editing.discardChanges(row.id, table);
|
20047
|
+
requestAnimationFrame(() => {
|
20048
|
+
if (isTemporaryRow(row.id)) {
|
20049
|
+
var _tableMeta$editing$cr;
|
20050
|
+
(_tableMeta$editing$cr = tableMeta.editing.createRowButtonRef.current) === null || _tableMeta$editing$cr === void 0 ? void 0 : _tableMeta$editing$cr.focus();
|
20051
|
+
} else {
|
20052
|
+
focusManager.focusFirst();
|
20053
|
+
}
|
20054
|
+
});
|
20055
|
+
}
|
20056
|
+
function handleKeyDown(event) {
|
20057
|
+
if (props.onKeyDown) {
|
20058
|
+
props.onKeyDown(event);
|
20059
|
+
}
|
20060
|
+
if (event.isDefaultPrevented() || event.isPropagationStopped()) {
|
20061
|
+
return;
|
20062
|
+
}
|
20063
|
+
if (event.key === 'Escape' && tableMeta.editing.hasChanges(row.id) && !isElementTriggeredFromContainer(event.target, event.currentTarget)) {
|
20064
|
+
event.preventDefault();
|
20065
|
+
setShowDiscardDialog(true);
|
20066
|
+
}
|
20067
|
+
}
|
19523
20068
|
const attributes = {
|
19524
|
-
'data-row-editing-invalid': tableMeta.editing.
|
19525
|
-
'data-row-editing-status':
|
19526
|
-
onFocus: handleFocus
|
20069
|
+
'data-row-editing-invalid': tableMeta.editing.hasRowErrors(row.id) ? !tableMeta.editing.hasRowErrorsShownInAlert(row.id) ? 'unseen' : true : undefined,
|
20070
|
+
'data-row-editing-status': rowStatus,
|
20071
|
+
onFocus: handleFocus,
|
20072
|
+
onKeyDown: handleKeyDown
|
19527
20073
|
};
|
19528
|
-
return /*#__PURE__*/React__default.createElement(DisplayRow, Object.assign({}, props, attributes),
|
20074
|
+
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
20075
|
rowId: row.id,
|
19530
20076
|
table: table
|
19531
|
-
}) : null)
|
20077
|
+
}) : null), /*#__PURE__*/React__default.createElement(DiscardChangesConfirmationDialog, {
|
20078
|
+
open: showDiscardDialog,
|
20079
|
+
onChange: setShowDiscardDialog,
|
20080
|
+
onDiscard: handleDiscard
|
20081
|
+
}));
|
19532
20082
|
}
|
19533
20083
|
|
19534
20084
|
const RENDERERS$1 = {
|
@@ -19536,29 +20086,61 @@ const RENDERERS$1 = {
|
|
19536
20086
|
cell: Cell$5
|
19537
20087
|
};
|
19538
20088
|
function useTable3(props, ref) {
|
19539
|
-
const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.validator);
|
20089
|
+
const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.onEditingCreate, props.rowIdentityAccessor, props.validator);
|
19540
20090
|
const creationEnabled = editing.isEnabled && !!props.onEditingCreate;
|
20091
|
+
// this gives me the performance heeby jeebies, but can't think of a better way to internalise the state
|
20092
|
+
const data = React__default.useMemo(() => {
|
20093
|
+
if (editing.temporaryRows.length) {
|
20094
|
+
var _props$data;
|
20095
|
+
return ((_props$data = props.data) !== null && _props$data !== void 0 ? _props$data : []).concat(editing.temporaryRows);
|
20096
|
+
}
|
20097
|
+
return props.data;
|
20098
|
+
}, [JSON.stringify(props.data), editing.temporaryRows.length]);
|
19541
20099
|
const extendedProps = {
|
19542
20100
|
...props,
|
20101
|
+
data,
|
19543
20102
|
enableRowActions: editing.isEditing ? true : props.enableRowActions,
|
19544
|
-
|
19545
|
-
|
19546
|
-
|
19547
|
-
|
19548
|
-
|
19549
|
-
|
19550
|
-
|
19551
|
-
|
20103
|
+
// Display EditingActionMenu instead of row actions while editing
|
20104
|
+
rowActions: editing.isEditing ? [(_, rowId, table) => {
|
20105
|
+
const tableMeta = table.options.meta;
|
20106
|
+
return /*#__PURE__*/React__default.createElement(EditingActionsMenu, {
|
20107
|
+
hasChanges: editing.hasChanges(rowId),
|
20108
|
+
hasErrors: editing.hasRowErrors(rowId),
|
20109
|
+
onDiscard: () => {
|
20110
|
+
editing.discardChanges(rowId, table);
|
20111
|
+
if (editing.temporaryRows.length) {
|
20112
|
+
requestAnimationFrame(() => {
|
20113
|
+
var _editing$createRowBut;
|
20114
|
+
return (_editing$createRowBut = editing.createRowButtonRef.current) === null || _editing$createRowBut === void 0 ? void 0 : _editing$createRowBut.focus();
|
20115
|
+
});
|
20116
|
+
}
|
20117
|
+
},
|
20118
|
+
onEditingSave: function () {
|
20119
|
+
try {
|
20120
|
+
return Promise.resolve(editing.saveChanges(table, rowId)).then(function () {});
|
20121
|
+
} catch (e) {
|
20122
|
+
return Promise.reject(e);
|
20123
|
+
}
|
20124
|
+
},
|
20125
|
+
isLastRow: !creationEnabled && tableMeta.rowActive.rowActiveIndex === tableMeta.length - 1
|
20126
|
+
});
|
20127
|
+
}] : props.rowActions
|
19552
20128
|
};
|
19553
20129
|
const meta = {
|
19554
20130
|
editing
|
19555
20131
|
};
|
19556
|
-
const
|
20132
|
+
const options = {
|
20133
|
+
virtualiserPaddingEndOffset: props.enableEditing && props.onEditingCreate ? editing.hasTemporaryRowErrors() ? 1.4 : 1 : 0
|
20134
|
+
};
|
20135
|
+
const table = useTable(extendedProps, ref, RENDERERS$1, meta, options);
|
19557
20136
|
// listeners
|
19558
|
-
useTableEditingListener(table.instance, table.ref);
|
20137
|
+
useTableEditingListener(table.instance, table.ref, table.renderer.scrollToIndex);
|
19559
20138
|
React__default.useEffect(() => {
|
19560
20139
|
if (table.ref.current) {
|
19561
|
-
table.ref.current.instance.toggleEditing = enabled => table.meta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing);
|
20140
|
+
table.ref.current.instance.toggleEditing = enabled => table.meta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing, table.instance, table.renderer.scrollToIndex);
|
20141
|
+
if (props.onEditingCreate) {
|
20142
|
+
table.ref.current.instance.createRow = row => table.meta.editing.createRow(table.instance, table.renderer.scrollToIndex, row);
|
20143
|
+
}
|
19562
20144
|
}
|
19563
20145
|
}, [table.ref.current]);
|
19564
20146
|
return table;
|
@@ -19577,7 +20159,7 @@ function Alert$1(props) {
|
|
19577
20159
|
const validationTexts = texts.table3.editing.validation;
|
19578
20160
|
const tableMeta = table.options.meta;
|
19579
20161
|
const [showFilterResetDialog, setShowFilterResetDialog] = React__default.useState(false);
|
19580
|
-
const pendingChangesWithErrors = tableMeta.editing.
|
20162
|
+
const pendingChangesWithErrors = tableMeta.editing.getErrorsShownInAlert();
|
19581
20163
|
function scrollToRow(rowIndex) {
|
19582
20164
|
tableMeta.rowActive.setRowActiveIndex(rowIndex);
|
19583
20165
|
scrollToIndex(rowIndex, {
|
@@ -19596,38 +20178,45 @@ function Alert$1(props) {
|
|
19596
20178
|
const title = (pendingChangesWithErrors.length === 1 ? validationTexts.alert.titleOne : validationTexts.alert.titlePlural).replace('[COUNT]', String(pendingChangesWithErrors.length));
|
19597
20179
|
// generate links to each invalid row, to go into the error message
|
19598
20180
|
const links = [];
|
19599
|
-
const
|
19600
|
-
|
20181
|
+
const visibleColumns = table.getVisibleFlatColumns().map(c => c.id);
|
20182
|
+
const rowIdentityColumn = tableMeta.rowIdentityAccessor && visibleColumns.includes(String(tableMeta.rowIdentityAccessor)) ?
|
20183
|
+
// table.getColumn(columName) throw error in strict dev mode. Related thread: https://github.com/TanStack/table/discussions/5505
|
20184
|
+
table.getAllColumns().find(x => x.id === String(tableMeta.rowIdentityAccessor)) : undefined;
|
20185
|
+
pendingChangesWithErrors.forEach((pendingChangeWithError, index) => {
|
19601
20186
|
// if appropriate, concatenate the item with the text "and"
|
19602
20187
|
if (pendingChangesWithErrors.length > 1 && index === pendingChangesWithErrors.length - 1) {
|
19603
20188
|
// Add space before and after `messageAnd` text
|
19604
20189
|
links.push(` ${validationTexts.alert.messageAnd} `);
|
19605
20190
|
}
|
19606
|
-
const rowIndex = table.getRowModel().rows.findIndex(row => row.id ===
|
20191
|
+
const rowIndex = table.getRowModel().rows.findIndex(row => row.id === pendingChangeWithError.rowId);
|
19607
20192
|
const handleClick = () => {
|
20193
|
+
// if row is visible
|
19608
20194
|
if (rowIndex > -1) {
|
19609
20195
|
scrollToRow(rowIndex);
|
19610
|
-
}
|
19611
|
-
|
20196
|
+
}
|
20197
|
+
// if row is filtered out
|
20198
|
+
else {
|
20199
|
+
setShowFilterResetDialog(pendingChangeWithError.rowId);
|
19612
20200
|
}
|
19613
20201
|
};
|
19614
20202
|
let tooltip;
|
19615
|
-
if (
|
19616
|
-
tooltip =
|
20203
|
+
if (pendingChangeWithError.errors.row) {
|
20204
|
+
tooltip = pendingChangeWithError.errors.row;
|
19617
20205
|
} else {
|
19618
20206
|
var _table$getAllColumns$, _table$getAllColumns$2;
|
19619
|
-
const firstCellErrorColumnId = Object.keys(
|
20207
|
+
const firstCellErrorColumnId = Object.keys(pendingChangeWithError.errors.cells)[0];
|
19620
20208
|
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}: ${
|
20209
|
+
tooltip = `${columnName}: ${pendingChangeWithError.errors.cells[firstCellErrorColumnId]}`;
|
19622
20210
|
}
|
20211
|
+
const row = table.getRow(pendingChangeWithError.rowId).original;
|
19623
20212
|
links.push(/*#__PURE__*/React__default.createElement(Tooltip, {
|
19624
|
-
key:
|
20213
|
+
key: pendingChangeWithError.rowId,
|
19625
20214
|
title: tooltip
|
19626
20215
|
}, /*#__PURE__*/React__default.createElement("span", {
|
19627
20216
|
className: "text-blue",
|
19628
20217
|
onClick: handleClick,
|
19629
20218
|
role: "button"
|
19630
|
-
}, rowIdentityColumn ?
|
20219
|
+
}, rowIdentityColumn ? row[rowIdentityColumn.id] : rowIndex + 1)));
|
19631
20220
|
// if appropriate, concatenate the item with the text ","
|
19632
20221
|
if (pendingChangesWithErrors.length > 2 && index < pendingChangesWithErrors.length - 2) {
|
19633
20222
|
links.push(', ');
|
@@ -19683,9 +20272,38 @@ function FilterResetDialog(props) {
|
|
19683
20272
|
}, texts.table3.editing.validation.resetFiltersDialog.confirm)))));
|
19684
20273
|
}
|
19685
20274
|
|
19686
|
-
function
|
20275
|
+
function Editing(props) {
|
20276
|
+
const {
|
20277
|
+
scrollToIndex,
|
20278
|
+
table
|
20279
|
+
} = props;
|
20280
|
+
const {
|
20281
|
+
texts
|
20282
|
+
} = useLocalization();
|
20283
|
+
const ref = React__default.useRef(null);
|
20284
|
+
const tableMeta = table.options.meta;
|
20285
|
+
const handleChange = enabled => {
|
20286
|
+
tableMeta.editing.toggleEditing(enabled, table, scrollToIndex);
|
20287
|
+
};
|
20288
|
+
const tooltip = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, texts.table3.editing.buttons.edit.tooltip, /*#__PURE__*/React__default.createElement(Shortcut, {
|
20289
|
+
className: "ml-2",
|
20290
|
+
keys: shortcut
|
20291
|
+
}));
|
20292
|
+
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
20293
|
+
title: tooltip
|
20294
|
+
}, /*#__PURE__*/React__default.createElement(ModeSwitch, {
|
20295
|
+
"data-table": "editing-toggle",
|
20296
|
+
checked: tableMeta.editing.isEditing,
|
20297
|
+
onChange: handleChange,
|
20298
|
+
ref: ref
|
20299
|
+
}));
|
20300
|
+
}
|
20301
|
+
|
20302
|
+
function CreateNewRow(props) {
|
20303
|
+
var _temporaryRows$0$tabl, _temporaryRows$, _table$getState$colum;
|
19687
20304
|
const {
|
19688
|
-
|
20305
|
+
buttonRef,
|
20306
|
+
isScrolled,
|
19689
20307
|
scrollToIndex,
|
19690
20308
|
table,
|
19691
20309
|
tableMeta
|
@@ -19693,117 +20311,143 @@ function CreateNewRowButton(props) {
|
|
19693
20311
|
const {
|
19694
20312
|
texts
|
19695
20313
|
} = 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
|
-
};
|
20314
|
+
const temporaryRows = tableMeta.editing.temporaryRows;
|
20315
|
+
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 : '';
|
20316
|
+
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);
|
20317
|
+
const isSaving = !!temporaryRowId && tableMeta.editing.getRowStatus(temporaryRowId) === 'saving';
|
19705
20318
|
const handleCreate = function () {
|
19706
20319
|
try {
|
19707
|
-
if (
|
20320
|
+
if (isDisabled) {
|
19708
20321
|
return Promise.resolve();
|
19709
20322
|
}
|
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);
|
20323
|
+
return Promise.resolve(tableMeta.editing.createRow(table, scrollToIndex)).then(function () {});
|
19732
20324
|
} catch (e) {
|
19733
20325
|
return Promise.reject(e);
|
19734
20326
|
}
|
19735
20327
|
};
|
19736
|
-
|
19737
|
-
|
19738
|
-
|
19739
|
-
|
19740
|
-
|
19741
|
-
|
19742
|
-
|
19743
|
-
|
19744
|
-
|
19745
|
-
|
19746
|
-
|
19747
|
-
|
19748
|
-
|
19749
|
-
|
19750
|
-
|
19751
|
-
|
19752
|
-
|
19753
|
-
|
19754
|
-
|
19755
|
-
}
|
19756
|
-
}, [rowCreated]);
|
20328
|
+
const shortcut = {
|
20329
|
+
key: 'Enter',
|
20330
|
+
meta: true
|
20331
|
+
};
|
20332
|
+
let tooltip;
|
20333
|
+
if (isSaving) {
|
20334
|
+
tooltip = texts.table3.editing.buttons.create.saving;
|
20335
|
+
} else if (isDisabled) {
|
20336
|
+
tooltip = texts.table3.editing.buttons.create.disabled;
|
20337
|
+
} else {
|
20338
|
+
tooltip = /*#__PURE__*/React__default.createElement(Shortcut, {
|
20339
|
+
keys: shortcut
|
20340
|
+
});
|
20341
|
+
}
|
20342
|
+
const className = cn('group/row border-grey-300 !sticky z-[21]', {
|
20343
|
+
'bottom-10': tableMeta.footer.isEnabled,
|
20344
|
+
'bottom-0': !tableMeta.footer.isEnabled,
|
20345
|
+
'border-b': !isScrolled
|
20346
|
+
});
|
19757
20347
|
return /*#__PURE__*/React__default.createElement("tr", {
|
19758
|
-
|
19759
|
-
className:
|
20348
|
+
"data-row-create": true,
|
20349
|
+
className: className,
|
20350
|
+
tabIndex: -1
|
19760
20351
|
}, /*#__PURE__*/React__default.createElement("td", {
|
19761
|
-
className: "!border-
|
20352
|
+
className: "!bg-grey-50 col-span-full !border-b-0 !px-1"
|
19762
20353
|
}, /*#__PURE__*/React__default.createElement(Button$1, {
|
19763
|
-
|
19764
|
-
className: "group-hover:bg-grey-200 sticky left-
|
19765
|
-
|
19766
|
-
|
20354
|
+
appearance: "transparent",
|
20355
|
+
className: "group-hover:bg-grey-200 sticky left-[4px]",
|
20356
|
+
disabled: isDisabled,
|
20357
|
+
onClick: handleCreate,
|
20358
|
+
ref: buttonRef,
|
20359
|
+
shortcut: shortcut,
|
20360
|
+
tooltip: tooltip
|
20361
|
+
}, /*#__PURE__*/React__default.createElement(Icon, {
|
20362
|
+
name: "circle-plus"
|
20363
|
+
}), texts.table3.editing.buttons.create.label)));
|
19767
20364
|
}
|
19768
20365
|
|
19769
|
-
function
|
20366
|
+
function TemporaryRow(props) {
|
19770
20367
|
const {
|
19771
|
-
|
19772
|
-
|
20368
|
+
createRowButtonRef,
|
20369
|
+
isScrolled,
|
20370
|
+
table,
|
20371
|
+
tableMeta,
|
20372
|
+
tableRef
|
19773
20373
|
} = props;
|
19774
|
-
const {
|
19775
|
-
|
19776
|
-
|
19777
|
-
|
19778
|
-
|
19779
|
-
|
19780
|
-
|
19781
|
-
|
19782
|
-
|
20374
|
+
const handleKeyDown = function (event) {
|
20375
|
+
try {
|
20376
|
+
const _temp2 = function () {
|
20377
|
+
if (event.key === 'ArrowDown') {
|
20378
|
+
event.preventDefault();
|
20379
|
+
const _temp = function () {
|
20380
|
+
if (!isElementTriggeredFromContainer(event.target, event.currentTarget)) {
|
20381
|
+
return Promise.resolve(tableMeta.editing.saveChanges(table)).then(function (saved) {
|
20382
|
+
if (saved) {
|
20383
|
+
var _createRowButtonRef$c;
|
20384
|
+
(_createRowButtonRef$c = createRowButtonRef.current) === null || _createRowButtonRef$c === void 0 ? void 0 : _createRowButtonRef$c.focus();
|
20385
|
+
}
|
20386
|
+
});
|
20387
|
+
}
|
20388
|
+
}();
|
20389
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
20390
|
+
} else if (event.key === 'ArrowUp') {
|
20391
|
+
event.preventDefault();
|
20392
|
+
event.stopPropagation();
|
20393
|
+
if (tableRef.current) {
|
20394
|
+
var _tableRef$current$que, _tableRef$current$que2, _tableRef$current$que3;
|
20395
|
+
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 : []);
|
20396
|
+
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;
|
20397
|
+
const newRowHeight = event.currentTarget.getBoundingClientRect().height;
|
20398
|
+
const visibleHeight = tableRef.current.clientHeight - footerHeight - newRowHeight;
|
20399
|
+
const tableTopOffset = tableRef.current.getBoundingClientRect().top;
|
20400
|
+
let nextRowIndex;
|
20401
|
+
// iterate available rows in reverse order, since we're working at the bottom
|
20402
|
+
for (let index = availableRows.length - 1; index >= 0; index--) {
|
20403
|
+
const rowRect = availableRows[index].getBoundingClientRect();
|
20404
|
+
const topPlusHalfRow = rowRect.top + rowRect.height / 2;
|
20405
|
+
if (topPlusHalfRow - tableTopOffset <= visibleHeight) {
|
20406
|
+
nextRowIndex = index;
|
20407
|
+
break;
|
20408
|
+
}
|
20409
|
+
}
|
20410
|
+
if (nextRowIndex) {
|
20411
|
+
tableMeta.rowActive.setRowActiveIndex(Number(availableRows[nextRowIndex < 0 ? 0 : nextRowIndex].getAttribute('data-row-index')));
|
20412
|
+
}
|
20413
|
+
}
|
20414
|
+
}
|
20415
|
+
}();
|
20416
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
20417
|
+
} catch (e) {
|
20418
|
+
return Promise.reject(e);
|
20419
|
+
}
|
19783
20420
|
};
|
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
|
-
});
|
20421
|
+
const handleKeyDownCapture = event => {
|
20422
|
+
if (event.key === 'ArrowLeft' && tableMeta.editing.lastFocusedCellIndex === 0) {
|
20423
|
+
event.preventDefault();
|
20424
|
+
event.stopPropagation();
|
20425
|
+
} else if (event.key === 'ArrowRight' && tableMeta.editing.lastFocusedCellIndex) {
|
20426
|
+
if (tableMeta.editing.lastFocusedCellIndex === table.getVisibleFlatColumns().length - 1) {
|
20427
|
+
event.preventDefault();
|
20428
|
+
event.stopPropagation();
|
20429
|
+
}
|
20430
|
+
}
|
19799
20431
|
};
|
19800
|
-
|
19801
|
-
|
19802
|
-
|
19803
|
-
|
19804
|
-
|
19805
|
-
|
19806
|
-
|
20432
|
+
const className = cn('group/row border-grey-300 !sticky z-[22]', {
|
20433
|
+
'bottom-[calc(5rem_+_2px)] data-[row-editing-move]:bottom-[calc(5rem_+_2px)]': tableMeta.footer.isEnabled,
|
20434
|
+
'bottom-[calc(2.5rem_+_2px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_2px)]': !tableMeta.footer.isEnabled,
|
20435
|
+
'border-t-2 shadow-[0px_-5px_20px_0px_rgba(0,0,0,0.1)] [&>td]:!border-b-0': isScrolled
|
20436
|
+
});
|
20437
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, table.getBottomRows().map(row => (/*#__PURE__*/React__default.createElement(Row, {
|
20438
|
+
key: row.id,
|
20439
|
+
cellRenderer: RENDERERS$1.cell,
|
20440
|
+
index: tableMeta.length,
|
20441
|
+
measureRow: () => null,
|
20442
|
+
renderer: RENDERERS$1.row,
|
20443
|
+
row: row,
|
20444
|
+
table: table,
|
20445
|
+
className: className,
|
20446
|
+
onKeyDown: handleKeyDown,
|
20447
|
+
onKeyDownCapture: handleKeyDownCapture,
|
20448
|
+
hideInternalColumns: true,
|
20449
|
+
hideRowActions: !tableMeta.editing.isEditing
|
20450
|
+
}))));
|
19807
20451
|
}
|
19808
20452
|
|
19809
20453
|
function Column$3(_) {
|
@@ -19821,8 +20465,19 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
|
|
19821
20465
|
'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
20466
|
enableHorizontalArrowKeyNavigation: table3.meta.editing.isEditing
|
19823
20467
|
};
|
19824
|
-
const hasAlertErrors = table3.meta.editing.
|
19825
|
-
const
|
20468
|
+
const hasAlertErrors = table3.meta.editing.getErrorsShownInAlert().length;
|
20469
|
+
const hasCreateWorkflow = table3.meta.editing.isEnabled && props.onEditingCreate;
|
20470
|
+
const isScrolled = isTableScrolled(table3.ref);
|
20471
|
+
let createWorkflow;
|
20472
|
+
if (hasCreateWorkflow) {
|
20473
|
+
createWorkflow = /*#__PURE__*/React__default.createElement(CreateNewRow, {
|
20474
|
+
buttonRef: table3.meta.editing.createRowButtonRef,
|
20475
|
+
isScrolled: isScrolled,
|
20476
|
+
scrollToIndex: table3.renderer.scrollToIndex,
|
20477
|
+
table: table3.instance,
|
20478
|
+
tableMeta: table3.meta
|
20479
|
+
});
|
20480
|
+
}
|
19826
20481
|
return /*#__PURE__*/React__default.createElement(Table, null, /*#__PURE__*/React__default.createElement(Table.Toolbar, {
|
19827
20482
|
table: table3
|
19828
20483
|
}, table3.meta.editing.isEnabled ? (/*#__PURE__*/React__default.createElement(Editing, {
|
@@ -19835,13 +20490,15 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
|
|
19835
20490
|
tableRef: table3.ref
|
19836
20491
|
})) : null, /*#__PURE__*/React__default.createElement(Table.Grid, Object.assign({}, gridAttributes, {
|
19837
20492
|
"data-taco": "table3",
|
20493
|
+
footerRows: hasCreateWorkflow && isScrolled ? createWorkflow : undefined,
|
19838
20494
|
table: table3
|
19839
|
-
}),
|
20495
|
+
}), hasCreateWorkflow ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TemporaryRow, {
|
20496
|
+
createRowButtonRef: table3.meta.editing.createRowButtonRef,
|
20497
|
+
isScrolled: isScrolled,
|
19840
20498
|
table: table3.instance,
|
19841
20499
|
tableMeta: table3.meta,
|
19842
|
-
|
19843
|
-
|
19844
|
-
}))));
|
20500
|
+
tableRef: table3.ref
|
20501
|
+
}), !isScrolled ? createWorkflow : null)) : null));
|
19845
20502
|
});
|
19846
20503
|
const Table3 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
19847
20504
|
const stringifiedChildren = String(props.children);
|
@@ -20077,6 +20734,796 @@ const Tour = props => {
|
|
20077
20734
|
};
|
20078
20735
|
Tour.Step = TourStep;
|
20079
20736
|
|
20737
|
+
// NOTE: this file is intentianally a js file so that it can be consumed by tailwind.config.js
|
20738
|
+
|
20739
|
+
const THEME_COLORS = {
|
20740
|
+
transparent: 'transparent',
|
20741
|
+
current: 'currentColor',
|
20742
|
+
white: '#fff',
|
20743
|
+
black: '#1c1c1c',
|
20744
|
+
brand: {
|
20745
|
+
vismaRed: '#E70641',
|
20746
|
+
paleOrange: '#FFF5E5',
|
20747
|
+
sunsetOrange: '#E89C2E',
|
20748
|
+
midnightBlue: '#29283E',
|
20749
|
+
coolBlue: '#F5F7F9'
|
20750
|
+
},
|
20751
|
+
grey: {
|
20752
|
+
lightest: '#fafafa',
|
20753
|
+
light: '#F6F6F6',
|
20754
|
+
DEFAULT: '#EBEBEB',
|
20755
|
+
dark: '#DDDDDD',
|
20756
|
+
darker: '#ACACAC',
|
20757
|
+
darkest: '#595959',
|
20758
|
+
darkNew: '#a5a6a9',
|
20759
|
+
50: '#fafafa',
|
20760
|
+
100: '#F6F6F6',
|
20761
|
+
200: '#EBEBEB',
|
20762
|
+
300: '#DDDDDD',
|
20763
|
+
500: '#ACACAC',
|
20764
|
+
700: '#595959',
|
20765
|
+
900: '#303030'
|
20766
|
+
},
|
20767
|
+
purple: {
|
20768
|
+
lightest: '#585c74',
|
20769
|
+
light: '#4b4f64',
|
20770
|
+
DEFAULT: '#3d4153',
|
20771
|
+
dark: '#353a48',
|
20772
|
+
darker: '#29283e',
|
20773
|
+
darkest: '#212032',
|
20774
|
+
darkNew_1: '#373647',
|
20775
|
+
darkNew_2: '#414050',
|
20776
|
+
100: '#EEE5FF',
|
20777
|
+
200: '#ddd1ff',
|
20778
|
+
300: '#CBBCFE',
|
20779
|
+
500: '#9270FA',
|
20780
|
+
700: '#6542D1',
|
20781
|
+
900: '#412970'
|
20782
|
+
},
|
20783
|
+
blue: {
|
20784
|
+
lightest: '#DEEBFF',
|
20785
|
+
light: '#75A0F5',
|
20786
|
+
DEFAULT: '#4573D2',
|
20787
|
+
dark: '#2B57B4',
|
20788
|
+
100: '#DEEBFF',
|
20789
|
+
200: '#AACCFF',
|
20790
|
+
300: '#75A0F5',
|
20791
|
+
500: '#4573D2',
|
20792
|
+
700: '#2B57B4',
|
20793
|
+
900: '#29283E'
|
20794
|
+
},
|
20795
|
+
red: {
|
20796
|
+
lightest: '#FFDAD2',
|
20797
|
+
light: '#E66568',
|
20798
|
+
DEFAULT: '#CE3F42',
|
20799
|
+
dark: '#950027',
|
20800
|
+
100: '#FFDAD2',
|
20801
|
+
200: '#f3a09d',
|
20802
|
+
300: '#E66568',
|
20803
|
+
500: '#CE3F42',
|
20804
|
+
700: '#950027',
|
20805
|
+
900: '#64001B'
|
20806
|
+
},
|
20807
|
+
green: {
|
20808
|
+
lightest: '#cdf0e7',
|
20809
|
+
light: '#52C7AB',
|
20810
|
+
DEFAULT: '#08AE87',
|
20811
|
+
dark: '#028465',
|
20812
|
+
100: '#cdf0e7',
|
20813
|
+
200: '#9be1ce',
|
20814
|
+
300: '#52C7AB',
|
20815
|
+
500: '#08AE87',
|
20816
|
+
700: '#028465',
|
20817
|
+
900: '#14493A'
|
20818
|
+
},
|
20819
|
+
yellow: {
|
20820
|
+
lightest: '#FFF1C3',
|
20821
|
+
light: '#FFD665',
|
20822
|
+
DEFAULT: '#FFBD3B',
|
20823
|
+
dark: '#e89c2e',
|
20824
|
+
100: '#FFF1C3',
|
20825
|
+
200: '#ffe494',
|
20826
|
+
300: '#FFD665',
|
20827
|
+
500: '#FFBD3B',
|
20828
|
+
700: '#e89c2e',
|
20829
|
+
900: '#733700'
|
20830
|
+
},
|
20831
|
+
pink: {
|
20832
|
+
100: '#FFE3F7',
|
20833
|
+
200: '#fcb9e9',
|
20834
|
+
300: '#F98EDB',
|
20835
|
+
500: '#E165BF',
|
20836
|
+
700: '#CF49AA',
|
20837
|
+
900: '#870062'
|
20838
|
+
},
|
20839
|
+
brown: {
|
20840
|
+
100: '#EEE0DA',
|
20841
|
+
200: '#DFCCC2',
|
20842
|
+
300: '#C4AB9E',
|
20843
|
+
500: '#93715D',
|
20844
|
+
700: '#73503B',
|
20845
|
+
900: '#45291F'
|
20846
|
+
},
|
20847
|
+
orange: {
|
20848
|
+
100: '#FFE3BB',
|
20849
|
+
200: '#FCCB80',
|
20850
|
+
300: '#FAB64D',
|
20851
|
+
500: '#F99702',
|
20852
|
+
700: '#EF7D00',
|
20853
|
+
900: '#4A2811'
|
20854
|
+
}
|
20855
|
+
};
|
20856
|
+
|
20857
|
+
const mapColor = (palette, prefix = '') => {
|
20858
|
+
return Object.keys(palette).reduce((accum, color) => {
|
20859
|
+
if (color === 'current') {
|
20860
|
+
return accum;
|
20861
|
+
} else if (typeof palette[color] === 'string') {
|
20862
|
+
return {
|
20863
|
+
...accum,
|
20864
|
+
[prefix ? color === 'DEFAULT' ? prefix : `${prefix}-${color}` : color]: palette[color]
|
20865
|
+
};
|
20866
|
+
} else {
|
20867
|
+
return {
|
20868
|
+
...accum,
|
20869
|
+
...mapColor(palette[color], color)
|
20870
|
+
};
|
20871
|
+
}
|
20872
|
+
}, {});
|
20873
|
+
};
|
20874
|
+
const colors = /*#__PURE__*/mapColor(THEME_COLORS);
|
20875
|
+
const getThemeColor = color => colors[color];
|
20876
|
+
|
20877
|
+
function Legend(props) {
|
20878
|
+
const {
|
20879
|
+
activeIndex,
|
20880
|
+
onMouseEnter,
|
20881
|
+
onMouseLeave,
|
20882
|
+
onClick,
|
20883
|
+
payload,
|
20884
|
+
layout,
|
20885
|
+
activeItems
|
20886
|
+
} = props;
|
20887
|
+
const [hoverIndex, setHoverIndex] = React.useState(null);
|
20888
|
+
const handleMouseEnter = (entry, index) => {
|
20889
|
+
setHoverIndex(index);
|
20890
|
+
if (activeItems[entry.dataKey]) onMouseEnter(entry, index);
|
20891
|
+
};
|
20892
|
+
const handleMouseLeave = () => {
|
20893
|
+
onMouseLeave();
|
20894
|
+
setHoverIndex(null);
|
20895
|
+
};
|
20896
|
+
const moreButton = moreButtonText => (/*#__PURE__*/React__default.createElement(Button$1, {
|
20897
|
+
appearance: "transparent",
|
20898
|
+
className: "text-grey-700"
|
20899
|
+
}, moreButtonText));
|
20900
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
20901
|
+
className: "mx-auto w-auto max-w-full overflow-hidden"
|
20902
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
20903
|
+
className: cn('mb-0 ml-0 flex justify-center', {
|
20904
|
+
'flex-col': layout === 'vertical'
|
20905
|
+
})
|
20906
|
+
}, /*#__PURE__*/React__default.createElement(OverflowGroup, {
|
20907
|
+
className: "w-full items-center py-1",
|
20908
|
+
moreButton: moreButton
|
20909
|
+
}, payload.map((entry, index) => (/*#__PURE__*/React__default.createElement("span", {
|
20910
|
+
key: `${entry.dataKey}-${index}`,
|
20911
|
+
className: cn(' hover:bg-grey-100 cursor-pointer px-[8px] py-[2px] hover:rounded-[4px]', {
|
20912
|
+
'bg-grey-100 rounded': activeIndex === index
|
20913
|
+
}),
|
20914
|
+
onMouseEnter: () => handleMouseEnter(entry, index),
|
20915
|
+
onMouseLeave: handleMouseLeave,
|
20916
|
+
onClick: onClick ? () => onClick(entry) : undefined
|
20917
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
20918
|
+
className: "text-grey-700 flex items-center gap-[4px]"
|
20919
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
20920
|
+
className: cn('-mt-px ml-1 flex h-3 w-3 rounded-sm', {
|
20921
|
+
'border-grey-300 border !bg-white': !activeItems[entry.dataKey]
|
20922
|
+
}),
|
20923
|
+
style: {
|
20924
|
+
backgroundColor: entry.color
|
20925
|
+
}
|
20926
|
+
}, hoverIndex === index && activeItems[entry.dataKey] && (/*#__PURE__*/React__default.createElement(Icon, {
|
20927
|
+
name: "tick-bold",
|
20928
|
+
className: "!h-full !w-full text-white"
|
20929
|
+
}))), entry.value)))))));
|
20930
|
+
}
|
20931
|
+
|
20932
|
+
const Tooltip$2 = ({
|
20933
|
+
active,
|
20934
|
+
formatter,
|
20935
|
+
payload,
|
20936
|
+
style,
|
20937
|
+
singlePieDonutChart
|
20938
|
+
}) => {
|
20939
|
+
const getColor = entry => {
|
20940
|
+
var _ref, _entry$color;
|
20941
|
+
if (singlePieDonutChart) {
|
20942
|
+
// We use entry.payload.label because the payload structure differs between a Donut chart with a single pie
|
20943
|
+
// and one with multiple pies.
|
20944
|
+
return getThemeColor(entry.payload.color);
|
20945
|
+
}
|
20946
|
+
return (_ref = (_entry$color = entry.color) !== null && _entry$color !== void 0 ? _entry$color : entry.payload.fill) !== null && _ref !== void 0 ? _ref : 'blue-500';
|
20947
|
+
};
|
20948
|
+
if (active && payload && payload.length) {
|
20949
|
+
return /*#__PURE__*/React__default.createElement("dl", {
|
20950
|
+
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)]",
|
20951
|
+
style: style
|
20952
|
+
}, payload.map((entry, index) => (/*#__PURE__*/React__default.createElement(React__default.Fragment, {
|
20953
|
+
key: `${entry.name}-${index}`
|
20954
|
+
}, /*#__PURE__*/React__default.createElement("dt", {
|
20955
|
+
className: "text-grey-700 mb-0 flex items-center gap-1 font-normal"
|
20956
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
20957
|
+
className: "-mt-px h-2.5 w-2.5 rounded-sm",
|
20958
|
+
style: {
|
20959
|
+
background: getColor(entry)
|
20960
|
+
}
|
20961
|
+
}),
|
20962
|
+
// We use entry.payload.label because the payload structure differs between a Donut chart with a single pie
|
20963
|
+
// and one with multiple pies.
|
20964
|
+
singlePieDonutChart ? entry.payload.label : entry.name), /*#__PURE__*/React__default.createElement("dd", {
|
20965
|
+
className: "mb-0 text-right font-bold text-black "
|
20966
|
+
}, formatter ? formatter(entry.value) : entry.value)))));
|
20967
|
+
}
|
20968
|
+
return null;
|
20969
|
+
};
|
20970
|
+
|
20971
|
+
const getCartesianGridProps = () => ({
|
20972
|
+
vertical: false
|
20973
|
+
});
|
20974
|
+
const getXAxisProps = props => ({
|
20975
|
+
axisLine: false,
|
20976
|
+
dataKey: props.accessor,
|
20977
|
+
fontSize: 12,
|
20978
|
+
scale: props.xAxisScale,
|
20979
|
+
tickLine: false,
|
20980
|
+
tickFormatter: props.xAxisTickFormat
|
20981
|
+
});
|
20982
|
+
const getYAxisProps = props => ({
|
20983
|
+
axisLine: false,
|
20984
|
+
fontSize: 12,
|
20985
|
+
scale: props.yAxisScale,
|
20986
|
+
tickLine: false,
|
20987
|
+
tickFormatter: props.yAxisTickFormat
|
20988
|
+
});
|
20989
|
+
const getLegendProps = props => ({
|
20990
|
+
content: /*#__PURE__*/React__default.createElement(Legend, Object.assign({}, props))
|
20991
|
+
});
|
20992
|
+
const getTooltipProps = (props = undefined) => ({
|
20993
|
+
content: /*#__PURE__*/React__default.createElement(Tooltip$2, Object.assign({}, props)),
|
20994
|
+
wrapperStyle: {
|
20995
|
+
outline: 'none'
|
20996
|
+
}
|
20997
|
+
});
|
20998
|
+
|
20999
|
+
// A hacky fix for EC-50037 to make sure that Chart doesn't resize when it is inside a Card.
|
21000
|
+
const ResponsiveContainer = props => (/*#__PURE__*/React__default.createElement(Recharts.ResponsiveContainer, Object.assign({
|
21001
|
+
className: "!h-[calc(100%-1px)] !w-[calc(100%-1px)]"
|
21002
|
+
}, props)));
|
21003
|
+
|
21004
|
+
const Area = _ => null;
|
21005
|
+
const AreaChart = function AreaChart(externalProps) {
|
21006
|
+
const {
|
21007
|
+
children,
|
21008
|
+
data,
|
21009
|
+
formatter,
|
21010
|
+
...props
|
21011
|
+
} = externalProps;
|
21012
|
+
const [hoveredArea, setHoveredArea] = React.useState(null);
|
21013
|
+
const [activeAreas, setActiveAreas] = React.useState(() => {
|
21014
|
+
const areas = {};
|
21015
|
+
React__default.Children.forEach(children, child => {
|
21016
|
+
areas[child.props.accessor] = true;
|
21017
|
+
});
|
21018
|
+
return areas;
|
21019
|
+
});
|
21020
|
+
const handleLegendClick = entry => {
|
21021
|
+
setHoveredArea(null);
|
21022
|
+
setActiveAreas({
|
21023
|
+
...activeAreas,
|
21024
|
+
[entry.dataKey]: !activeAreas[entry.dataKey]
|
21025
|
+
});
|
21026
|
+
};
|
21027
|
+
return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.AreaChart, {
|
21028
|
+
data: data,
|
21029
|
+
margin: {
|
21030
|
+
top: 10,
|
21031
|
+
right: 0,
|
21032
|
+
left: -25,
|
21033
|
+
bottom: 0
|
21034
|
+
}
|
21035
|
+
}, /*#__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({
|
21036
|
+
onClick: handleLegendClick,
|
21037
|
+
onMouseEnter: entry => setHoveredArea(entry.dataKey),
|
21038
|
+
onMouseLeave: () => setHoveredArea(null),
|
21039
|
+
activeItems: activeAreas
|
21040
|
+
}))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
|
21041
|
+
formatter: formatter
|
21042
|
+
})), React__default.Children.map(children, child => {
|
21043
|
+
var _child$props$color, _child$props$color2, _child$props$color3;
|
21044
|
+
return /*#__PURE__*/React__default.createElement(Recharts.Area, {
|
21045
|
+
activeDot: {
|
21046
|
+
fill: getThemeColor((_child$props$color = child.props.color) !== null && _child$props$color !== void 0 ? _child$props$color : 'blue-300')
|
21047
|
+
},
|
21048
|
+
isAnimationActive: false,
|
21049
|
+
dataKey: child.props.accessor,
|
21050
|
+
dot: false,
|
21051
|
+
fill: getThemeColor((_child$props$color2 = child.props.color) !== null && _child$props$color2 !== void 0 ? _child$props$color2 : 'grey-100'),
|
21052
|
+
name: child.props.label,
|
21053
|
+
strokeWidth: 2,
|
21054
|
+
stroke: getThemeColor((_child$props$color3 = child.props.color) !== null && _child$props$color3 !== void 0 ? _child$props$color3 : 'grey-300'),
|
21055
|
+
stackId: child.props.stackId,
|
21056
|
+
hide: !activeAreas[child.props.accessor],
|
21057
|
+
opacity: hoveredArea && child.props.accessor !== hoveredArea ? 0.3 : 1
|
21058
|
+
});
|
21059
|
+
})));
|
21060
|
+
};
|
21061
|
+
AreaChart.Area = Area;
|
21062
|
+
|
21063
|
+
const Bar$1 = _ => null;
|
21064
|
+
const getXAxisVerticalProps = props => ({
|
21065
|
+
...getXAxisProps(props),
|
21066
|
+
...{
|
21067
|
+
type: 'number',
|
21068
|
+
dataKey: undefined
|
21069
|
+
}
|
21070
|
+
});
|
21071
|
+
const getYAxisVerticalProps = props => ({
|
21072
|
+
...getYAxisProps(props),
|
21073
|
+
...{
|
21074
|
+
dataKey: props.accessor,
|
21075
|
+
type: 'category'
|
21076
|
+
}
|
21077
|
+
});
|
21078
|
+
const BarChart = function BarChart(externalProps) {
|
21079
|
+
const {
|
21080
|
+
children,
|
21081
|
+
data,
|
21082
|
+
formatter,
|
21083
|
+
layout = 'horizontal',
|
21084
|
+
...props
|
21085
|
+
} = externalProps;
|
21086
|
+
const [activeIndex, setActiveIndex] = React__default.useState(undefined);
|
21087
|
+
const [hoveredBar, setHoveredBar] = React__default.useState(null);
|
21088
|
+
const [activeBars, setActiveBars] = React__default.useState(() => {
|
21089
|
+
const keys = {};
|
21090
|
+
React__default.Children.forEach(children, child => {
|
21091
|
+
keys[child.props.accessor] = true;
|
21092
|
+
});
|
21093
|
+
return keys;
|
21094
|
+
});
|
21095
|
+
// Recharts doesn't provide a way for us to know if a stacked bar is at the top or the bottom,
|
21096
|
+
// so we can't set proper radiuses without some "magic"
|
21097
|
+
const stacks = {};
|
21098
|
+
React__default.Children.forEach(children, child => {
|
21099
|
+
if (child.props.stackId) {
|
21100
|
+
if (!stacks[child.props.stackId]) {
|
21101
|
+
stacks[child.props.stackId] = [child.props.accessor];
|
21102
|
+
} else {
|
21103
|
+
stacks[child.props.stackId].push(child.props.accessor);
|
21104
|
+
}
|
21105
|
+
}
|
21106
|
+
});
|
21107
|
+
const handleLegendClick = entry => {
|
21108
|
+
setHoveredBar(null);
|
21109
|
+
setActiveBars({
|
21110
|
+
...activeBars,
|
21111
|
+
[entry.dataKey]: !activeBars[entry.dataKey]
|
21112
|
+
});
|
21113
|
+
};
|
21114
|
+
const handleLegendHover = (entry, index) => {
|
21115
|
+
setHoveredBar(entry.dataKey);
|
21116
|
+
setActiveIndex(index);
|
21117
|
+
};
|
21118
|
+
return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.BarChart, {
|
21119
|
+
layout: layout,
|
21120
|
+
data: data,
|
21121
|
+
margin: {
|
21122
|
+
top: 10,
|
21123
|
+
right: 0,
|
21124
|
+
left: layout === 'vertical' ? 0 : -25,
|
21125
|
+
bottom: 0
|
21126
|
+
},
|
21127
|
+
onMouseMove: chartState => setActiveIndex(chartState.activeTooltipIndex),
|
21128
|
+
onMouseLeave: () => setActiveIndex(undefined)
|
21129
|
+
}, /*#__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({
|
21130
|
+
onClick: handleLegendClick,
|
21131
|
+
onMouseEnter: handleLegendHover,
|
21132
|
+
onMouseLeave: () => setHoveredBar(null),
|
21133
|
+
activeItems: activeBars
|
21134
|
+
}))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
|
21135
|
+
formatter: formatter
|
21136
|
+
})), React__default.Children.map(children, child => (/*#__PURE__*/React__default.createElement(Recharts.Bar, {
|
21137
|
+
isAnimationActive: false,
|
21138
|
+
barSize: 16,
|
21139
|
+
dataKey: child.props.accessor,
|
21140
|
+
name: child.props.label,
|
21141
|
+
onMouseEnter: (_, index) => setActiveIndex(index),
|
21142
|
+
onMouseLeave: () => setActiveIndex(undefined),
|
21143
|
+
fill: getThemeColor(child.props.color ? `${child.props.color}` : `blue-300`),
|
21144
|
+
radius: getBarRadius(stacks, child.props.accessor, child.props.stackId, activeBars),
|
21145
|
+
stackId: child.props.stackId,
|
21146
|
+
style: child.props.stackId ? {
|
21147
|
+
stroke: '#fff',
|
21148
|
+
strokeWidth: '2px'
|
21149
|
+
} : undefined,
|
21150
|
+
hide: !activeBars[child.props.accessor]
|
21151
|
+
}, data.map((_, index) => (/*#__PURE__*/React__default.createElement(Recharts.Cell, {
|
21152
|
+
key: `cell-${index}`,
|
21153
|
+
opacity: hoveredBar && child.props.accessor !== hoveredBar || activeIndex !== undefined && activeIndex !== index ? 0.3 : 1
|
21154
|
+
}))))))));
|
21155
|
+
};
|
21156
|
+
BarChart.Bar = Bar$1;
|
21157
|
+
const getBarRadius = (stacks, accessor, stackId, activeBars) => {
|
21158
|
+
if (stackId && Array.isArray(stacks[stackId])) {
|
21159
|
+
const length = stacks[stackId].length - 1;
|
21160
|
+
const index = stacks[stackId].indexOf(accessor);
|
21161
|
+
if (Object.entries(activeBars).filter(item => item[0] !== accessor).every(item => !item[1])) {
|
21162
|
+
return [3, 3, 0, 0];
|
21163
|
+
}
|
21164
|
+
if (activeBars[stacks[stackId][index + 1]] === false) {
|
21165
|
+
return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length - 1 ? 0 : 3, index === length - 1 ? 0 : 3];
|
21166
|
+
}
|
21167
|
+
if (index !== 0 && index !== length) {
|
21168
|
+
return 0;
|
21169
|
+
}
|
21170
|
+
return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length ? 0 : 3, index === length ? 0 : 3];
|
21171
|
+
}
|
21172
|
+
return 3;
|
21173
|
+
};
|
21174
|
+
|
21175
|
+
const Legend$1 = ({
|
21176
|
+
legendPosition,
|
21177
|
+
hoveredItem,
|
21178
|
+
selectedItem,
|
21179
|
+
data,
|
21180
|
+
onClick,
|
21181
|
+
setHoveredItem,
|
21182
|
+
formatter,
|
21183
|
+
total,
|
21184
|
+
visibleItems,
|
21185
|
+
label
|
21186
|
+
}) => {
|
21187
|
+
const isTotalLegendSelected = selectedItem.length === data.length;
|
21188
|
+
const isTotalLegendHovered = hoveredItem.length === data.length;
|
21189
|
+
const handleMouseLeave = () => setHoveredItem([]);
|
21190
|
+
const renderLegendItem = (entry, index) => {
|
21191
|
+
const isTotal = entry === null;
|
21192
|
+
// We can't use `isTotal` here because TypeScript is unable to infer the type when `entry` is not null.
|
21193
|
+
const itemData = entry === null ? {
|
21194
|
+
id: 'total',
|
21195
|
+
label,
|
21196
|
+
value: total,
|
21197
|
+
color: 'grey-300'
|
21198
|
+
} : entry;
|
21199
|
+
const isSelected = isTotal ? isTotalLegendSelected : selectedItem.includes(itemData.id);
|
21200
|
+
const isHovered = isTotal ? isTotalLegendHovered : hoveredItem.includes(itemData.id);
|
21201
|
+
return /*#__PURE__*/React__default.createElement("li", {
|
21202
|
+
key: isTotal ? 'total' : `${itemData.label}-${index}`,
|
21203
|
+
className: cn('mr-2 flex cursor-pointer gap-2 rounded pl-0 pr-1', {
|
21204
|
+
'bg-grey-100': isHovered && (!isTotal || legendPosition === 'right'),
|
21205
|
+
'bg-grey-200': isSelected && (!isTotal || legendPosition === 'right')
|
21206
|
+
}),
|
21207
|
+
onClick: () => onClick(isTotal ? data : itemData),
|
21208
|
+
onMouseEnter: () => setHoveredItem(isTotal ? data.map(item => item.id) : [itemData.id]),
|
21209
|
+
onMouseLeave: handleMouseLeave
|
21210
|
+
}, legendPosition === 'bottom' ? (/*#__PURE__*/React__default.createElement("div", {
|
21211
|
+
className: "flex items-center gap-1"
|
21212
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
21213
|
+
className: cn('ml-1 h-3 w-3 rounded-sm', {
|
21214
|
+
'border-grey-300 border !bg-white': !visibleItems[itemData.id]
|
21215
|
+
}),
|
21216
|
+
style: {
|
21217
|
+
backgroundColor: getThemeColor(itemData.color)
|
21218
|
+
}
|
21219
|
+
}, visibleItems[itemData.id] && isHovered && (/*#__PURE__*/React__default.createElement(Icon, {
|
21220
|
+
name: "tick-bold",
|
21221
|
+
className: "mb-2.5 !h-full !w-full text-white"
|
21222
|
+
}))), /*#__PURE__*/React__default.createElement("div", null, itemData.label))) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
21223
|
+
className: "ml-1 mt-1 h-9 w-2 rounded-[1px]",
|
21224
|
+
style: {
|
21225
|
+
backgroundColor: getThemeColor(itemData.color)
|
21226
|
+
}
|
21227
|
+
}), /*#__PURE__*/React__default.createElement("div", null, itemData.label, /*#__PURE__*/React__default.createElement("span", {
|
21228
|
+
className: "-mt-1 flex w-full text-lg font-bold"
|
21229
|
+
}, formatter ? formatter(itemData.value) : itemData.value)))));
|
21230
|
+
};
|
21231
|
+
const moreButton = moreButtonText => (/*#__PURE__*/React__default.createElement(Button$1, {
|
21232
|
+
appearance: "transparent",
|
21233
|
+
className: "text-grey-700"
|
21234
|
+
}, moreButtonText));
|
21235
|
+
const className = cn('flex-grow pl-4', {
|
21236
|
+
'w-full': legendPosition === 'bottom'
|
21237
|
+
});
|
21238
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
21239
|
+
className: className
|
21240
|
+
}, /*#__PURE__*/React__default.createElement("ul", {
|
21241
|
+
className: cn('mb-0 ml-0 mt-4 flex justify-center space-y-1', legendPosition === 'right' ? 'flex-col gap-1' : 'flex-row')
|
21242
|
+
}, legendPosition === 'right' ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderLegendItem(null), data.map(renderLegendItem))) : (/*#__PURE__*/React__default.createElement(OverflowGroup, {
|
21243
|
+
className: "w-full items-center py-1",
|
21244
|
+
moreButton: moreButton
|
21245
|
+
}, data.map(renderLegendItem)))));
|
21246
|
+
};
|
21247
|
+
|
21248
|
+
const DONUT_WIDTH = 16;
|
21249
|
+
const HOVER_DONUT_WIDTH = 10;
|
21250
|
+
|
21251
|
+
const CenteredLabel = ({
|
21252
|
+
radius,
|
21253
|
+
legendPosition,
|
21254
|
+
label,
|
21255
|
+
total,
|
21256
|
+
formatter,
|
21257
|
+
showLegend
|
21258
|
+
}) => {
|
21259
|
+
const totalInset = HOVER_DONUT_WIDTH + DONUT_WIDTH + DONUT_WIDTH;
|
21260
|
+
const diameter = radius * 2;
|
21261
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
21262
|
+
className: "absolute mt-1 flex h-12 flex-col text-center",
|
21263
|
+
style: {
|
21264
|
+
top: `calc(${radius}px - (3rem / 2))`,
|
21265
|
+
left: legendPosition === 'right' ? `${totalInset}px` : `calc(50%-${diameter - 2 * totalInset})`,
|
21266
|
+
width: showLegend ? `${diameter - 2 * totalInset}px` : `${diameter}px`
|
21267
|
+
}
|
21268
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
21269
|
+
className: "w-full truncate text-lg font-bold"
|
21270
|
+
}, formatter ? formatter(total) : total), label);
|
21271
|
+
};
|
21272
|
+
|
21273
|
+
const ActiveShape = props => {
|
21274
|
+
var _getThemeColor;
|
21275
|
+
const {
|
21276
|
+
cx,
|
21277
|
+
cy,
|
21278
|
+
id,
|
21279
|
+
innerRadius,
|
21280
|
+
onClick,
|
21281
|
+
outerRadius = 0,
|
21282
|
+
pieColors,
|
21283
|
+
startAngle,
|
21284
|
+
endAngle,
|
21285
|
+
fill
|
21286
|
+
} = props;
|
21287
|
+
return /*#__PURE__*/React__default.createElement("g", {
|
21288
|
+
onClick: () => onClick(id),
|
21289
|
+
className: cn({
|
21290
|
+
'cursor-pointer': !!onClick
|
21291
|
+
})
|
21292
|
+
}, /*#__PURE__*/React__default.createElement(Recharts.Sector, {
|
21293
|
+
cx: cx,
|
21294
|
+
cy: cy,
|
21295
|
+
innerRadius: innerRadius,
|
21296
|
+
outerRadius: outerRadius,
|
21297
|
+
startAngle: startAngle,
|
21298
|
+
endAngle: endAngle,
|
21299
|
+
fill: fill
|
21300
|
+
}), /*#__PURE__*/React__default.createElement(Recharts.Sector, {
|
21301
|
+
cx: cx,
|
21302
|
+
cy: cy,
|
21303
|
+
startAngle: startAngle,
|
21304
|
+
endAngle: endAngle,
|
21305
|
+
innerRadius: outerRadius + 2,
|
21306
|
+
outerRadius: outerRadius + HOVER_DONUT_WIDTH,
|
21307
|
+
fill: id !== undefined ? (_getThemeColor = getThemeColor(pieColors[id])) !== null && _getThemeColor !== void 0 ? _getThemeColor : getThemeColor('blue-500') : getThemeColor('blue-500'),
|
21308
|
+
opacity: 0.3
|
21309
|
+
}));
|
21310
|
+
};
|
21311
|
+
|
21312
|
+
const Segment = _ => null;
|
21313
|
+
const DonutChart = function DonutChart({
|
21314
|
+
children,
|
21315
|
+
formatter,
|
21316
|
+
onClick,
|
21317
|
+
showLegend = false,
|
21318
|
+
legendPosition = 'bottom',
|
21319
|
+
label
|
21320
|
+
}) {
|
21321
|
+
const ref = React__default.useRef(null);
|
21322
|
+
const [radius, setRadius] = React__default.useState(0);
|
21323
|
+
const [hoveredItem, setHoveredItem] = React__default.useState([]);
|
21324
|
+
// used for right legends
|
21325
|
+
const [selectedItem, setSelectedItem] = React__default.useState([]);
|
21326
|
+
// used for bottom legends
|
21327
|
+
const [visibleItems, setVisibleItems] = React__default.useState(() => {
|
21328
|
+
const keys = {};
|
21329
|
+
React__default.Children.forEach(children, child => {
|
21330
|
+
keys[child.props.id] = true;
|
21331
|
+
});
|
21332
|
+
return keys;
|
21333
|
+
});
|
21334
|
+
React__default.useEffect(() => {
|
21335
|
+
if (ref.current) {
|
21336
|
+
var _ref$current$parentEl;
|
21337
|
+
const rect = (_ref$current$parentEl = ref.current.parentElement) === null || _ref$current$parentEl === void 0 ? void 0 : _ref$current$parentEl.getBoundingClientRect();
|
21338
|
+
if (rect) {
|
21339
|
+
const width = showLegend ? rect.width / 2 : rect.width;
|
21340
|
+
const max = rect.height < width ? rect.height : width;
|
21341
|
+
setRadius(max / 2);
|
21342
|
+
}
|
21343
|
+
}
|
21344
|
+
}, [showLegend]);
|
21345
|
+
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
|
21346
|
+
const data = React__default.Children.map(children, child => ({
|
21347
|
+
id: child.props.id,
|
21348
|
+
color: child.props.color,
|
21349
|
+
label: child.props.label,
|
21350
|
+
value: child.props.value
|
21351
|
+
}));
|
21352
|
+
const displayedData = data.filter(child => visibleItems[child.id]);
|
21353
|
+
const total = displayedData.reduce((accum, entry) => accum + entry.value, 0);
|
21354
|
+
const showTooltip = (!showLegend || legendPosition === 'bottom') && displayedData.length > 0;
|
21355
|
+
const handleLegendClick = entry => {
|
21356
|
+
if (legendPosition === 'bottom' && !Array.isArray(entry)) {
|
21357
|
+
setVisibleItems({
|
21358
|
+
...visibleItems,
|
21359
|
+
[entry.id]: !visibleItems[entry.id]
|
21360
|
+
});
|
21361
|
+
} else {
|
21362
|
+
const nextSelectedItem = Array.isArray(entry) ? entry.map(entryItem => entryItem.id) : [entry.id];
|
21363
|
+
// Using slice to avoid mutation of the react state 'selectedItem'
|
21364
|
+
const isCurrentSegmentActive = selectedItem.slice().sort().join(',') === nextSelectedItem.sort().join(',');
|
21365
|
+
if (onClick && !isCurrentSegmentActive) {
|
21366
|
+
onClick(entry);
|
21367
|
+
}
|
21368
|
+
setSelectedItem(isCurrentSegmentActive ? [] : nextSelectedItem);
|
21369
|
+
}
|
21370
|
+
};
|
21371
|
+
const handlePieClick = React__default.useCallback(pieId => {
|
21372
|
+
if (onClick && pieId !== undefined) {
|
21373
|
+
const pieProps = displayedData.find(item => item.id === pieId);
|
21374
|
+
onClick(pieProps);
|
21375
|
+
}
|
21376
|
+
}, [onClick, displayedData]);
|
21377
|
+
const singlePieDonutChart = displayedData.length === 1;
|
21378
|
+
const activeShapeColor = React__default.useMemo(() => {
|
21379
|
+
const getSegmentColor = item => item.reduce((colors, itemId) => {
|
21380
|
+
const visibleHoveredItem = displayedData.find(dataItem => dataItem.id === itemId);
|
21381
|
+
if (visibleHoveredItem) {
|
21382
|
+
colors[visibleHoveredItem.id] = visibleHoveredItem.color;
|
21383
|
+
}
|
21384
|
+
return colors;
|
21385
|
+
}, {});
|
21386
|
+
const hoveredSegmentColor = getSegmentColor(hoveredItem);
|
21387
|
+
const selectedSegmentColor = getSegmentColor(selectedItem);
|
21388
|
+
return legendPosition === 'bottom' || hoveredItem.length !== 0 ? hoveredSegmentColor : selectedSegmentColor;
|
21389
|
+
}, [hoveredItem, selectedItem, legendPosition]);
|
21390
|
+
if (ref.current && !radius) {
|
21391
|
+
return null;
|
21392
|
+
}
|
21393
|
+
const getActiveIndex = () => {
|
21394
|
+
if (hoveredItem.length > 0) {
|
21395
|
+
return hoveredItem.map(itemId => displayedData.findIndex(element => element.id === itemId));
|
21396
|
+
}
|
21397
|
+
return selectedItem.map(selectedItemId => displayedData.findIndex(element => element.id === selectedItemId));
|
21398
|
+
};
|
21399
|
+
const content = () => {
|
21400
|
+
const elements = React__default.Children.toArray(children).filter(child => /*#__PURE__*/React__default.isValidElement(child) && visibleItems[child.props.id]);
|
21401
|
+
return elements.length > 0 ? elements.map((child, index) => {
|
21402
|
+
var _getThemeColor;
|
21403
|
+
return /*#__PURE__*/React__default.createElement(Recharts.Cell, {
|
21404
|
+
key: `cell-${index}`,
|
21405
|
+
name: child.props.label,
|
21406
|
+
fill: (_getThemeColor = getThemeColor(child.props.color)) !== null && _getThemeColor !== void 0 ? _getThemeColor : getThemeColor('blue-300')
|
21407
|
+
});
|
21408
|
+
}) : (/*#__PURE__*/React__default.createElement(Recharts.Cell, {
|
21409
|
+
key: "empty-chart",
|
21410
|
+
name: '',
|
21411
|
+
fill: getThemeColor('grey-200')
|
21412
|
+
}));
|
21413
|
+
};
|
21414
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
21415
|
+
className: cn('relative h-full w-full', {
|
21416
|
+
[`flex `]: showLegend,
|
21417
|
+
'flex-col items-center': legendPosition === 'bottom'
|
21418
|
+
}),
|
21419
|
+
ref: ref
|
21420
|
+
}, /*#__PURE__*/React__default.createElement(CenteredLabel, {
|
21421
|
+
radius: radius,
|
21422
|
+
legendPosition: legendPosition,
|
21423
|
+
label: label,
|
21424
|
+
total: total,
|
21425
|
+
formatter: formatter,
|
21426
|
+
showLegend: showLegend
|
21427
|
+
}), /*#__PURE__*/React__default.createElement(Recharts.PieChart, {
|
21428
|
+
data: data,
|
21429
|
+
height: diameter,
|
21430
|
+
width: diameter,
|
21431
|
+
style: {
|
21432
|
+
transform: 'rotate(90deg) scale(-1,1)'
|
21433
|
+
}
|
21434
|
+
}, showTooltip ? (/*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps({
|
21435
|
+
style: {
|
21436
|
+
transform: 'rotate(90deg) scale(-1,1)'
|
21437
|
+
},
|
21438
|
+
singlePieDonutChart
|
21439
|
+
})))) : null, /*#__PURE__*/React__default.createElement(Recharts.Pie, {
|
21440
|
+
isAnimationActive: false,
|
21441
|
+
activeIndex: getActiveIndex(),
|
21442
|
+
activeShape: /*#__PURE__*/React__default.createElement(ActiveShape, {
|
21443
|
+
pieColors: activeShapeColor,
|
21444
|
+
onClick: handlePieClick
|
21445
|
+
}),
|
21446
|
+
data: displayedData.length > 0 ? displayedData : [],
|
21447
|
+
dataKey: "value",
|
21448
|
+
innerRadius: radius - HOVER_DONUT_WIDTH - DONUT_WIDTH,
|
21449
|
+
onMouseEnter: segment => displayedData.length > 0 && setHoveredItem([segment.id]),
|
21450
|
+
onMouseLeave: () => setHoveredItem([]),
|
21451
|
+
outerRadius: radius - HOVER_DONUT_WIDTH,
|
21452
|
+
paddingAngle: 2,
|
21453
|
+
// Prevents the pie group element from being focusable
|
21454
|
+
rootTabIndex: -1
|
21455
|
+
}, content())), showLegend && (/*#__PURE__*/React__default.createElement(Legend$1, {
|
21456
|
+
data: data,
|
21457
|
+
visibleItems: visibleItems,
|
21458
|
+
onClick: handleLegendClick,
|
21459
|
+
total: total,
|
21460
|
+
setHoveredItem: setHoveredItem,
|
21461
|
+
label: label,
|
21462
|
+
legendPosition: legendPosition,
|
21463
|
+
hoveredItem: hoveredItem,
|
21464
|
+
selectedItem: selectedItem,
|
21465
|
+
formatter: formatter
|
21466
|
+
})));
|
21467
|
+
};
|
21468
|
+
DonutChart.Segment = Segment;
|
21469
|
+
|
21470
|
+
const Line$1 = _ => null;
|
21471
|
+
const LineChart = function LineChart(externalProps) {
|
21472
|
+
const {
|
21473
|
+
children,
|
21474
|
+
data,
|
21475
|
+
formatter,
|
21476
|
+
...props
|
21477
|
+
} = externalProps;
|
21478
|
+
const [hoveredLine, setHoveredLine] = React.useState(null);
|
21479
|
+
const [activeLines, setActiveLines] = React.useState(() => {
|
21480
|
+
const keys = {};
|
21481
|
+
React__default.Children.forEach(children, child => {
|
21482
|
+
keys[child.props.accessor] = true;
|
21483
|
+
});
|
21484
|
+
return keys;
|
21485
|
+
});
|
21486
|
+
const handleLegendClick = entry => {
|
21487
|
+
setHoveredLine(null);
|
21488
|
+
setActiveLines({
|
21489
|
+
...activeLines,
|
21490
|
+
[entry.dataKey]: !activeLines[entry.dataKey]
|
21491
|
+
});
|
21492
|
+
};
|
21493
|
+
return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.LineChart, {
|
21494
|
+
data: data,
|
21495
|
+
margin: {
|
21496
|
+
top: 10,
|
21497
|
+
right: 0,
|
21498
|
+
left: -25,
|
21499
|
+
bottom: 0
|
21500
|
+
}
|
21501
|
+
}, /*#__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({
|
21502
|
+
onClick: handleLegendClick,
|
21503
|
+
onMouseEnter: entry => setHoveredLine(entry.dataKey),
|
21504
|
+
onMouseLeave: () => setHoveredLine(null),
|
21505
|
+
activeItems: activeLines
|
21506
|
+
}))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
|
21507
|
+
formatter: formatter
|
21508
|
+
})), React__default.Children.map(children, child => {
|
21509
|
+
var _child$props$color, _child$props$color2;
|
21510
|
+
return /*#__PURE__*/React__default.createElement(Recharts.Line, {
|
21511
|
+
activeDot: {
|
21512
|
+
fill: getThemeColor((_child$props$color = child.props.color) !== null && _child$props$color !== void 0 ? _child$props$color : 'blue-300')
|
21513
|
+
},
|
21514
|
+
dataKey: child.props.accessor,
|
21515
|
+
isAnimationActive: false,
|
21516
|
+
dot: false,
|
21517
|
+
name: child.props.label,
|
21518
|
+
stroke: getThemeColor((_child$props$color2 = child.props.color) !== null && _child$props$color2 !== void 0 ? _child$props$color2 : 'blue-300'),
|
21519
|
+
strokeWidth: 2,
|
21520
|
+
hide: !activeLines[child.props.accessor],
|
21521
|
+
opacity: hoveredLine && child.props.accessor !== hoveredLine ? 0.3 : 1
|
21522
|
+
});
|
21523
|
+
})));
|
21524
|
+
};
|
21525
|
+
LineChart.Line = Line$1;
|
21526
|
+
|
20080
21527
|
const Button$4 = /*#__PURE__*/React__default.forwardRef(function Button(props, ref) {
|
20081
21528
|
const {
|
20082
21529
|
...attributes
|
@@ -20349,15 +21796,13 @@ const AgreementDisplay = props => {
|
|
20349
21796
|
}));
|
20350
21797
|
};
|
20351
21798
|
|
20352
|
-
const Container$1 =
|
20353
|
-
children
|
20354
|
-
}) => {
|
21799
|
+
const Container$1 = props => {
|
20355
21800
|
return /*#__PURE__*/React__default.createElement("div", {
|
20356
21801
|
className: "-ml-2 flex flex-shrink-0 flex-grow-0 items-center gap-2 pr-2 xl:ml-auto xl:w-64",
|
20357
21802
|
"data-taco": "header-agreements"
|
20358
21803
|
}, /*#__PURE__*/React__default.createElement("span", {
|
20359
21804
|
className: "hidden h-8 w-px flex-shrink-0 flex-grow-0 bg-white/[0.3] xl:flex"
|
20360
|
-
}), children);
|
21805
|
+
}), props.children);
|
20361
21806
|
};
|
20362
21807
|
function AgreementSelector(props) {
|
20363
21808
|
const {
|
@@ -20823,10 +22268,12 @@ const useOnClickOutside = (ref, callback) => {
|
|
20823
22268
|
exports.Accordion = Accordion;
|
20824
22269
|
exports.Alert = Alert;
|
20825
22270
|
exports.AlertDialog = AlertDialog;
|
22271
|
+
exports.AreaChart = AreaChart;
|
20826
22272
|
exports.Backdrop = Backdrop;
|
20827
22273
|
exports.Badge = Badge;
|
20828
22274
|
exports.BadgeIcon = BadgeIcon;
|
20829
22275
|
exports.Banner = Banner;
|
22276
|
+
exports.BarChart = BarChart;
|
20830
22277
|
exports.Base = Base;
|
20831
22278
|
exports.Button = Button$1;
|
20832
22279
|
exports.Calendar = Calendar$1;
|
@@ -20837,6 +22284,7 @@ exports.Combobox = Combobox;
|
|
20837
22284
|
exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
|
20838
22285
|
exports.Datepicker = Datepicker;
|
20839
22286
|
exports.Dialog = Dialog;
|
22287
|
+
exports.DonutChart = DonutChart;
|
20840
22288
|
exports.Drawer = Drawer;
|
20841
22289
|
exports.Field = Field;
|
20842
22290
|
exports.Form = Form;
|
@@ -20848,6 +22296,7 @@ exports.Icon = Icon;
|
|
20848
22296
|
exports.IconButton = IconButton;
|
20849
22297
|
exports.Input = Input;
|
20850
22298
|
exports.Layout = Layout$1;
|
22299
|
+
exports.LineChart = LineChart;
|
20851
22300
|
exports.List = List$1;
|
20852
22301
|
exports.Listbox = Listbox;
|
20853
22302
|
exports.LocalizationContext = LocalizationContext;
|