@erxes/ui 4.0.0-v2.2 → 4.0.0-v2.20
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/AGENTS.md +63 -0
- package/CATALOG.md +276 -0
- package/README.md +20 -0
- package/dist/components/accordion.d.ts +1 -0
- package/dist/components/accordion.js +1 -0
- package/dist/components/alert-dialog.d.ts +4 -0
- package/dist/components/alert-dialog.js +4 -0
- package/dist/components/alert.d.ts +1 -0
- package/dist/components/alert.js +1 -0
- package/dist/components/avatar.d.ts +2 -0
- package/dist/components/avatar.js +1 -0
- package/dist/components/background-gradient-animation.d.ts +4 -1
- package/dist/components/background-gradient-animation.js +4 -1
- package/dist/components/badge.d.ts +3 -0
- package/dist/components/badge.js +2 -0
- package/dist/components/breadcrumb.d.ts +1 -0
- package/dist/components/breadcrumb.js +1 -0
- package/dist/components/button.d.ts +6 -1
- package/dist/components/button.js +5 -1
- package/dist/components/calendar.d.ts +5 -0
- package/dist/components/calendar.js +4 -0
- package/dist/components/card.d.ts +1 -0
- package/dist/components/card.js +1 -0
- package/dist/components/chart-config.d.ts +4 -1
- package/dist/components/charts.d.ts +8 -1
- package/dist/components/charts.js +16 -6
- package/dist/components/checkbox.d.ts +1 -0
- package/dist/components/checkbox.js +1 -0
- package/dist/components/choicebox-group.d.ts +1 -0
- package/dist/components/choicebox-group.js +1 -0
- package/dist/components/collapsible.d.ts +1 -0
- package/dist/components/collapsible.js +1 -0
- package/dist/components/color-picker.d.ts +1 -0
- package/dist/components/color-picker.js +15 -8
- package/dist/components/combobox.d.ts +6 -1
- package/dist/components/combobox.js +13 -2
- package/dist/components/command-bar.d.ts +4 -0
- package/dist/components/command-bar.js +7 -0
- package/dist/components/command.d.ts +4 -0
- package/dist/components/command.js +4 -0
- package/dist/components/context-menu.d.ts +1 -0
- package/dist/components/context-menu.js +1 -0
- package/dist/components/copy-text.d.ts +1 -0
- package/dist/components/copy-text.js +1 -0
- package/dist/components/date-picker-value.d.ts +5 -9
- package/dist/components/date-picker-value.js +15 -34
- package/dist/components/date-picker.d.ts +4 -4
- package/dist/components/date-picker.js +9 -7
- package/dist/components/date-text-input.d.ts +2 -4
- package/dist/components/date-text-input.js +11 -9
- package/dist/components/dialog.d.ts +9 -2
- package/dist/components/dialog.js +24 -11
- package/dist/components/drag-handle.d.ts +1 -0
- package/dist/components/drag-handle.js +1 -0
- package/dist/components/dropdown-menu.d.ts +1 -0
- package/dist/components/dropdown-menu.js +1 -0
- package/dist/components/empty.d.ts +6 -1
- package/dist/components/empty.js +25 -2
- package/dist/components/field-control.d.ts +16 -0
- package/dist/components/field-control.js +19 -0
- package/dist/components/form-layout.d.ts +21 -0
- package/dist/components/form-layout.js +57 -0
- package/dist/components/form.d.ts +14 -3
- package/dist/components/form.js +24 -8
- package/dist/components/hover-card.d.ts +1 -0
- package/dist/components/hover-card.js +1 -0
- package/dist/components/icon-tip.d.ts +7 -0
- package/dist/components/icon-tip.js +16 -0
- package/dist/components/info-card.d.ts +4 -0
- package/dist/components/info-card.js +4 -0
- package/dist/components/input-group.d.ts +5 -4
- package/dist/components/input-group.js +6 -5
- package/dist/components/input.d.ts +2 -1
- package/dist/components/input.js +10 -4
- package/dist/components/kbd.d.ts +2 -1
- package/dist/components/kbd.js +2 -1
- package/dist/components/label.d.ts +1 -1
- package/dist/components/label.js +1 -1
- package/dist/components/multiselect.d.ts +1 -0
- package/dist/components/multiselect.js +7 -3
- package/dist/components/on-demand.d.ts +15 -2
- package/dist/components/on-demand.js +21 -1
- package/dist/components/popover.d.ts +4 -0
- package/dist/components/popover.js +21 -13
- package/dist/components/radio-group.d.ts +1 -0
- package/dist/components/radio-group.js +1 -0
- package/dist/components/scroll-area.d.ts +1 -0
- package/dist/components/scroll-area.js +1 -0
- package/dist/components/select.d.ts +5 -1
- package/dist/components/select.js +21 -10
- package/dist/components/separator.d.ts +4 -0
- package/dist/components/separator.js +4 -0
- package/dist/components/sheet.d.ts +9 -2
- package/dist/components/sheet.js +23 -10
- package/dist/components/sidebar/panel.js +1 -1
- package/dist/components/sidebar.d.ts +1 -0
- package/dist/components/sidebar.js +1 -0
- package/dist/components/skeleton.d.ts +1 -0
- package/dist/components/skeleton.js +1 -0
- package/dist/components/spinner.d.ts +1 -0
- package/dist/components/spinner.js +1 -0
- package/dist/components/string-array.js +1 -0
- package/dist/components/switch.d.ts +1 -0
- package/dist/components/switch.js +1 -0
- package/dist/components/table.d.ts +4 -0
- package/dist/components/table.js +4 -0
- package/dist/components/tabs.d.ts +8 -1
- package/dist/components/tabs.js +8 -1
- package/dist/components/text-overflow.d.ts +4 -1
- package/dist/components/text-overflow.js +4 -1
- package/dist/components/textarea.d.ts +1 -0
- package/dist/components/textarea.js +5 -1
- package/dist/components/toaster.d.ts +4 -1
- package/dist/components/toaster.js +5 -2
- package/dist/components/toggle-group.d.ts +5 -0
- package/dist/components/toggle-group.js +19 -11
- package/dist/components/toggle.d.ts +1 -0
- package/dist/components/toggle.js +1 -0
- package/dist/components/tooltip.d.ts +4 -0
- package/dist/components/tooltip.js +4 -0
- package/dist/components/upload.d.ts +4 -0
- package/dist/components/upload.js +20 -11
- package/dist/federation.d.ts +4 -0
- package/dist/federation.js +7 -1
- package/dist/hooks/use-focus-first-field.d.ts +8 -0
- package/dist/hooks/use-focus-first-field.js +15 -0
- package/dist/hooks/use-item-keys.d.ts +11 -0
- package/dist/hooks/use-item-keys.js +24 -0
- package/dist/hooks/use-page-hotkey.d.ts +14 -0
- package/dist/hooks/use-page-hotkey.js +24 -0
- package/dist/hooks/use-toast.d.ts +5 -0
- package/dist/hooks/use-toast.js +5 -0
- package/dist/index.d.ts +34 -7
- package/dist/index.js +32 -4
- package/dist/lib/format.d.ts +60 -0
- package/dist/lib/format.js +86 -0
- package/dist/lib/money.d.ts +13 -0
- package/dist/lib/money.js +21 -0
- package/dist/lib/render-in-dom.d.ts +6 -0
- package/dist/lib/render-in-dom.js +26 -0
- package/dist/lib/stored.d.ts +13 -0
- package/dist/lib/stored.js +41 -0
- package/dist/lib/text.d.ts +11 -0
- package/dist/lib/text.js +18 -0
- package/dist/modules/attachments/use-carousel.js +5 -10
- package/dist/modules/blocks/components/BlockEditor.js +2 -2
- package/dist/modules/blocks/components/Editor.d.ts +1 -1
- package/dist/modules/blocks/components/Editor.js +5 -2
- package/dist/modules/blocks/hooks/useBarcodeSizeForm.d.ts +1 -1
- package/dist/modules/blocks/hooks/useBlockEditor.d.ts +3 -0
- package/dist/modules/blocks/hooks/useBlockEditor.js +21 -2
- package/dist/modules/blocks/types/TextEditor.d.ts +3 -1
- package/dist/modules/blocks/utils/parseBlocks.d.ts +1 -1
- package/dist/modules/blocks/utils/parseBlocks.js +1 -1
- package/dist/modules/conditions/ConditionsEditor.d.ts +13 -0
- package/dist/modules/conditions/ConditionsEditor.js +171 -0
- package/dist/modules/conditions/DateEditors.d.ts +8 -0
- package/dist/modules/conditions/DateEditors.js +188 -0
- package/dist/modules/conditions/FieldPicker.d.ts +17 -0
- package/dist/modules/conditions/FieldPicker.js +99 -0
- package/dist/modules/conditions/LazyConditionsEditor.d.ts +10 -0
- package/dist/modules/conditions/LazyConditionsEditor.js +11 -0
- package/dist/modules/conditions/RuleParts.d.ts +30 -0
- package/dist/modules/conditions/RuleParts.js +78 -0
- package/dist/modules/conditions/RuleRow.d.ts +27 -0
- package/dist/modules/conditions/RuleRow.js +156 -0
- package/dist/modules/conditions/TypedInput.d.ts +13 -0
- package/dist/modules/conditions/TypedInput.js +36 -0
- package/dist/modules/conditions/ValueEditor.d.ts +18 -0
- package/dist/modules/conditions/ValueEditor.js +169 -0
- package/dist/modules/conditions/conditions.d.ts +77 -0
- package/dist/modules/conditions/conditions.js +69 -0
- package/dist/modules/conditions/fieldIcons.d.ts +6 -0
- package/dist/modules/conditions/fieldIcons.js +21 -0
- package/dist/modules/conditions/fieldOptions.d.ts +15 -0
- package/dist/modules/conditions/fieldOptions.js +38 -0
- package/dist/modules/conditions/filterRule.d.ts +45 -0
- package/dist/modules/conditions/filterRule.js +171 -0
- package/dist/modules/conditions/filterText.d.ts +16 -0
- package/dist/modules/conditions/filterText.js +156 -0
- package/dist/modules/display/components/EmailDisplay.d.ts +4 -0
- package/dist/modules/display/components/EmailDisplay.js +6 -3
- package/dist/modules/display/components/PhoneDisplay.d.ts +4 -0
- package/dist/modules/display/components/PhoneDisplay.js +4 -0
- package/dist/modules/display/components/RelativeDateDisplay.d.ts +7 -5
- package/dist/modules/display/components/RelativeDateDisplay.js +10 -8
- package/dist/modules/display/components/SexDisplay.d.ts +1 -0
- package/dist/modules/display/components/SexDisplay.js +1 -0
- package/dist/modules/filter/components/Filter.d.ts +4 -0
- package/dist/modules/filter/components/Filter.js +4 -0
- package/dist/modules/filter/components/FilterBar.js +8 -7
- package/dist/modules/filter/components/FilterDialog.js +4 -5
- package/dist/modules/filter/components/FilterPopover.js +1 -1
- package/dist/modules/filter/components/FilterProvider.d.ts +1 -2
- package/dist/modules/filter/components/FilterProvider.js +22 -16
- package/dist/modules/filter/hooks/useFilterContext.d.ts +1 -0
- package/dist/modules/filter/hooks/useFilterContext.js +1 -0
- package/dist/modules/filter/types/filter.d.ts +0 -1
- package/dist/modules/hotkey/components/PopoverScoped.d.ts +5 -0
- package/dist/modules/hotkey/components/PopoverScoped.js +5 -0
- package/dist/modules/hotkey/hooks/usePreviousHotkeyScope.d.ts +1 -0
- package/dist/modules/hotkey/hooks/usePreviousHotkeyScope.js +1 -0
- package/dist/modules/hotkey/hooks/useScopedHotkeys.d.ts +5 -1
- package/dist/modules/hotkey/hooks/useScopedHotkeys.js +5 -1
- package/dist/modules/icons/components/IconComponent.d.ts +4 -0
- package/dist/modules/icons/components/IconComponent.js +4 -0
- package/dist/modules/icons/components/IconPicker.d.ts +4 -0
- package/dist/modules/icons/components/IconPicker.js +7 -5
- package/dist/modules/icons/providers/IconsProvider.d.ts +1 -0
- package/dist/modules/icons/providers/IconsProvider.js +1 -0
- package/dist/modules/inputs/components/EmailField.d.ts +4 -1
- package/dist/modules/inputs/components/EmailField.js +4 -1
- package/dist/modules/inputs/components/FullNameField.d.ts +6 -0
- package/dist/modules/inputs/components/FullNameField.js +20 -8
- package/dist/modules/inputs/components/PhoneField.d.ts +4 -1
- package/dist/modules/inputs/components/PhoneField.js +4 -1
- package/dist/modules/inputs/components/SexField.d.ts +1 -0
- package/dist/modules/inputs/components/SexField.js +1 -0
- package/dist/modules/layout/components/AppLayout.d.ts +6 -6
- package/dist/modules/layout/components/AppLayout.js +12 -13
- package/dist/modules/layout/components/AppLayoutResizeHandle.d.ts +5 -12
- package/dist/modules/layout/components/AppLayoutResizeHandle.js +15 -18
- package/dist/modules/layout/components/Page.d.ts +5 -0
- package/dist/modules/layout/components/Page.js +5 -0
- package/dist/modules/layout/components/PageHeader.d.ts +4 -1
- package/dist/modules/layout/components/PageHeader.js +4 -1
- package/dist/modules/list/DisplayMenu.d.ts +37 -0
- package/dist/modules/list/DisplayMenu.js +92 -0
- package/dist/modules/list/ListFilter.d.ts +83 -0
- package/dist/modules/list/ListFilter.js +83 -0
- package/dist/modules/list/ViewBar.d.ts +47 -0
- package/dist/modules/list/ViewBar.js +65 -0
- package/dist/modules/list/filter/AddFilter.d.ts +10 -0
- package/dist/modules/list/filter/AddFilter.js +140 -0
- package/dist/modules/list/filter/AdvancedPopover.d.ts +8 -0
- package/dist/modules/list/filter/AdvancedPopover.js +103 -0
- package/dist/modules/list/filter/ListFilterBar.d.ts +6 -0
- package/dist/modules/list/filter/ListFilterBar.js +157 -0
- package/dist/modules/list/filter/RecordCount.d.ts +7 -0
- package/dist/modules/list/filter/RecordCount.js +22 -0
- package/dist/modules/list/filter/RuleChips.d.ts +12 -0
- package/dist/modules/list/filter/RuleChips.js +151 -0
- package/dist/modules/list/filter/SearchChip.d.ts +6 -0
- package/dist/modules/list/filter/SearchChip.js +69 -0
- package/dist/modules/list/filter/filterRules.d.ts +21 -0
- package/dist/modules/list/filter/filterRules.js +37 -0
- package/dist/modules/list/filter/listFilterContext.d.ts +36 -0
- package/dist/modules/list/filter/listFilterContext.js +18 -0
- package/dist/modules/list/filter/listFilterQuery.d.ts +20 -0
- package/dist/modules/list/filter/listFilterQuery.js +30 -0
- package/dist/modules/navigation-menu/components/NavigationMenu.d.ts +4 -3
- package/dist/modules/navigation-menu/components/NavigationMenu.js +7 -7
- package/dist/modules/pickers/EntityPicker.d.ts +7 -0
- package/dist/modules/pickers/EntityPicker.js +7 -0
- package/dist/modules/pickers/LookupPicker.d.ts +57 -0
- package/dist/modules/pickers/LookupPicker.js +115 -0
- package/dist/modules/pickers/SelectMember.d.ts +17 -2
- package/dist/modules/pickers/SelectMember.js +58 -4
- package/dist/modules/pickers/members.d.ts +3 -2
- package/dist/modules/pickers/members.js +1 -1
- package/dist/modules/record-field/components/NumberField.d.ts +5 -0
- package/dist/modules/record-field/components/NumberField.js +14 -7
- package/dist/modules/record-field/components/TextField.d.ts +4 -0
- package/dist/modules/record-field/components/TextField.js +10 -2
- package/dist/modules/record-field/meta-inputs/components/PhoneInput.d.ts +5 -0
- package/dist/modules/record-field/meta-inputs/components/PhoneInput.js +5 -0
- package/dist/modules/record-list/RecordList.d.ts +19 -0
- package/dist/modules/record-list/RecordList.js +24 -0
- package/dist/modules/record-list/RecordListProvider.d.ts +30 -0
- package/dist/modules/record-list/RecordListProvider.js +57 -0
- package/dist/modules/record-list/RecordListRoot.d.ts +30 -0
- package/dist/modules/record-list/RecordListRoot.js +140 -0
- package/dist/modules/record-list/selection.d.ts +22 -0
- package/dist/modules/record-list/selection.js +54 -0
- package/dist/modules/record-panel/PanelDescriptionEditor.d.ts +9 -0
- package/dist/modules/record-panel/PanelDescriptionEditor.js +39 -0
- package/dist/modules/record-panel/PanelDescriptionField.d.ts +13 -0
- package/dist/modules/record-panel/PanelDescriptionField.js +39 -0
- package/dist/modules/record-panel/PanelField.d.ts +17 -0
- package/dist/modules/record-panel/PanelField.js +47 -0
- package/dist/modules/record-panel/PanelForm.d.ts +30 -0
- package/dist/modules/record-panel/PanelForm.js +154 -0
- package/dist/modules/record-panel/PanelLabel.d.ts +10 -0
- package/dist/modules/record-panel/PanelLabel.js +55 -0
- package/dist/modules/record-panel/PanelSection.d.ts +12 -0
- package/dist/modules/record-panel/PanelSection.js +24 -0
- package/dist/modules/record-panel/panelExpansion.d.ts +10 -0
- package/dist/modules/record-panel/panelExpansion.js +7 -0
- package/dist/modules/record-panel/useSaveOnLeave.d.ts +14 -0
- package/dist/modules/record-panel/useSaveOnLeave.js +42 -0
- package/dist/modules/record-table/components/RecordTable.d.ts +6 -0
- package/dist/modules/record-table/components/RecordTable.js +6 -0
- package/dist/modules/record-table/components/RecordTableCell.d.ts +9 -0
- package/dist/modules/record-table/components/RecordTableCell.js +16 -2
- package/dist/modules/record-table/components/RecordTableCellInline.d.ts +5 -0
- package/dist/modules/record-table/components/RecordTableCellInline.js +8 -7
- package/dist/modules/record-table/components/RecordTableCursor.js +30 -28
- package/dist/modules/record-table/components/RecordTableHead.d.ts +7 -2
- package/dist/modules/record-table/components/RecordTableHead.js +73 -6
- package/dist/modules/record-table/components/RecordTableProvider.d.ts +22 -1
- package/dist/modules/record-table/components/RecordTableProvider.js +24 -8
- package/dist/modules/record-table/hooks/useTablePreferences.d.ts +1 -1
- package/dist/modules/record-table/hooks/useTablePreferences.js +18 -31
- package/dist/modules/record-table/states/RecordTableCursorState.d.ts +21 -1
- package/dist/modules/record-table/states/RecordTableCursorState.js +21 -3
- package/dist/modules/record-table/types/RecordTableCursorTypes.d.ts +1 -0
- package/dist/modules/record-table/types/RecordTableCursorTypes.js +1 -0
- package/dist/modules/records/ContactLink.d.ts +13 -0
- package/dist/modules/records/ContactLink.js +49 -0
- package/dist/modules/records/ContactPicker.d.ts +36 -0
- package/dist/modules/records/ContactPicker.js +173 -0
- package/dist/modules/records/MemberLink.d.ts +12 -0
- package/dist/modules/records/MemberLink.js +25 -0
- package/dist/modules/records/RecordChip.d.ts +13 -0
- package/dist/modules/records/RecordChip.js +46 -0
- package/dist/modules/records/contacts.d.ts +53 -0
- package/dist/modules/records/contacts.js +10 -0
- package/dist/modules/records/openRecord.d.ts +94 -0
- package/dist/modules/records/openRecord.js +72 -0
- package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/display.BlTmubjj.js +181 -0
- package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/index.D0heQG4v.js +987 -0
- package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/pathe.M-eThtNZ.zq3TM4NT.js +176 -0
- package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/run.CjdgFZiW.js +1509 -0
- package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/source-map.DakdQc29.js +687 -0
- package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/tinyrainbow.Do8I1XRG.js +85 -0
- package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/task-utils.js +6 -0
- package/dist/state/sidebarPanelState.js +7 -2
- package/dist/state/themeState.d.ts +13 -2
- package/dist/state/themeState.js +18 -4
- package/dist/theme.css +3 -0
- package/dist/types/SexCode.d.ts +1 -0
- package/dist/types/SexCode.js +1 -0
- package/dist/types/UIConfig.d.ts +182 -86
- package/dist/types/UIConfig.js +14 -0
- package/dist/utils/IsUndefinedOrNull.d.ts +1 -0
- package/dist/utils/IsUndefinedOrNull.js +1 -0
- package/dist/utils/file-storage.d.ts +1 -0
- package/dist/utils/file-storage.js +1 -0
- package/dist/utils/format/formatPhoneNumber.d.ts +4 -0
- package/dist/utils/format/formatPhoneNumber.js +4 -0
- package/dist/utils/getPluginAssetsUrl.d.ts +5 -0
- package/dist/utils/getPluginAssetsUrl.js +5 -0
- package/dist/utils/host-component.d.ts +10 -0
- package/dist/utils/host-component.js +34 -0
- package/dist/utils/json.d.ts +3 -2
- package/dist/utils/json.js +3 -2
- package/dist/utils/plugin-runtime.d.ts +21 -17
- package/dist/utils/plugin-runtime.js +59 -12
- package/dist/utils/plugin-styles.d.ts +10 -3
- package/dist/utils/plugin-styles.js +44 -12
- package/dist/utils/record-timeline.d.ts +10 -9
- package/dist/utils/record-timeline.js +12 -17
- package/exports.txt +249 -0
- package/package.json +14 -3
- package/dist/constants/IntlLanguages.d.ts +0 -74
- package/dist/constants/IntlLanguages.js +0 -76
- package/dist/hooks/use-query-state.d.ts +0 -16
- package/dist/hooks/use-query-state.js +0 -122
- package/dist/modules/filter/hooks/useFilterQueryState.d.ts +0 -4
- package/dist/modules/filter/hooks/useFilterQueryState.js +0 -14
- package/dist/types/Theme.d.ts +0 -1
- package/dist/types/Theme.js +0 -0
- package/dist/utils/localization/formatDateISOStringToRelativeDate.d.ts +0 -2
- package/dist/utils/localization/formatDateISOStringToRelativeDate.js +0 -16
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ElementType, ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A plain heading that groups the side panel's rows.
|
|
4
|
+
* It separates a record's fields, tags and linked records.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PanelSection: ({ title, icon: Icon, children, nested }: {
|
|
7
|
+
title: string;
|
|
8
|
+
/** Beside the title, as a plugin's section has it. */
|
|
9
|
+
icon?: ElementType;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
nested?: boolean;
|
|
12
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { cn } from "../../lib/utils.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/modules/record-panel/PanelSection.tsx
|
|
4
|
+
/**
|
|
5
|
+
* A plain heading that groups the side panel's rows.
|
|
6
|
+
* It separates a record's fields, tags and linked records.
|
|
7
|
+
*/
|
|
8
|
+
const PanelSection = ({ title, icon: Icon, children, nested = false }) => /* @__PURE__ */ jsxs("section", {
|
|
9
|
+
className: cn("pt-1", !nested && "border-b last:border-b-0"),
|
|
10
|
+
children: [/* @__PURE__ */ jsxs("h3", {
|
|
11
|
+
className: cn("flex items-center gap-1.5 text-xs", nested ? "h-7 px-1 font-normal text-muted-foreground" : "h-10 px-3 font-medium"),
|
|
12
|
+
children: [Icon && /* @__PURE__ */ jsx(Icon, {
|
|
13
|
+
className: "size-3.5 flex-none text-muted-foreground",
|
|
14
|
+
"aria-hidden": "true"
|
|
15
|
+
}), title]
|
|
16
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
17
|
+
className: cn("min-w-0", nested ? "pb-1" : "px-3 pb-2"),
|
|
18
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
19
|
+
className: "flex min-w-0 flex-col gap-1",
|
|
20
|
+
children
|
|
21
|
+
})
|
|
22
|
+
})]
|
|
23
|
+
});
|
|
24
|
+
export { PanelSection };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Whether the nearest record panel fills a page, and how to switch it. */
|
|
2
|
+
type PanelExpansion = {
|
|
3
|
+
expanded: boolean;
|
|
4
|
+
toggle?: () => void;
|
|
5
|
+
} | null;
|
|
6
|
+
/** Provided by the host's record panel; erxes-ui's panel parts read it. */
|
|
7
|
+
export declare const PanelExpansionContext: import("react").Context<PanelExpansion>;
|
|
8
|
+
/** Whether the record shows at full size on its own page. A slot can lay out wider then. */
|
|
9
|
+
export declare const usePanelExpanded: () => boolean;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
// src/modules/record-panel/panelExpansion.ts
|
|
3
|
+
/** Provided by the host's record panel; erxes-ui's panel parts read it. */
|
|
4
|
+
const PanelExpansionContext = createContext(null);
|
|
5
|
+
/** Whether the record shows at full size on its own page. A slot can lay out wider then. */
|
|
6
|
+
const usePanelExpanded = () => useContext(PanelExpansionContext)?.expanded ?? false;
|
|
7
|
+
export { PanelExpansionContext, usePanelExpanded };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saves a description editor when you click or tab anywhere outside it, never while
|
|
3
|
+
* typing. Focus can't be trusted to leave the editor first: closing the image preview
|
|
4
|
+
* or a toolbar menu drops it on the page. An edit that arrives while focus is already
|
|
5
|
+
* outside, such as an upload that finishes after you moved on, saves right away.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useSaveOnLeave: ({ value, readonly, onSave }: {
|
|
8
|
+
value: string;
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
onSave: (value: string) => void;
|
|
11
|
+
}) => {
|
|
12
|
+
containerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
13
|
+
onChange: (next: string) => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
// src/modules/record-panel/useSaveOnLeave.ts
|
|
3
|
+
/**
|
|
4
|
+
* Saves a description editor when you click or tab anywhere outside it, never while
|
|
5
|
+
* typing. Focus can't be trusted to leave the editor first: closing the image preview
|
|
6
|
+
* or a toolbar menu drops it on the page. An edit that arrives while focus is already
|
|
7
|
+
* outside, such as an upload that finishes after you moved on, saves right away.
|
|
8
|
+
*/
|
|
9
|
+
const useSaveOnLeave = ({ value, readonly, onSave }) => {
|
|
10
|
+
const containerRef = useRef(null);
|
|
11
|
+
const latest = useRef(value);
|
|
12
|
+
const saved = useRef(value);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
latest.current = value;
|
|
15
|
+
saved.current = value;
|
|
16
|
+
}, [value]);
|
|
17
|
+
const save = () => {
|
|
18
|
+
if (readonly || latest.current === saved.current) return;
|
|
19
|
+
saved.current = latest.current;
|
|
20
|
+
onSave(latest.current);
|
|
21
|
+
};
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const leave = (event) => {
|
|
24
|
+
if (event.target instanceof Node && containerRef.current?.contains(event.target)) return;
|
|
25
|
+
save();
|
|
26
|
+
};
|
|
27
|
+
document.addEventListener("pointerdown", leave, true);
|
|
28
|
+
document.addEventListener("focusin", leave);
|
|
29
|
+
return () => {
|
|
30
|
+
document.removeEventListener("pointerdown", leave, true);
|
|
31
|
+
document.removeEventListener("focusin", leave);
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
containerRef,
|
|
36
|
+
onChange: (next) => {
|
|
37
|
+
latest.current = next;
|
|
38
|
+
if (!containerRef.current?.contains(document.activeElement)) save();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export { useSaveOnLeave };
|
|
@@ -12,6 +12,12 @@ import { RecordTableRow } from "./RecordTableRow.js";
|
|
|
12
12
|
import { RecordTableRowList } from "./RecordTableRowList.js";
|
|
13
13
|
import { RecordTableRowSkeleton } from "./RecordTableRowSkeleton.js";
|
|
14
14
|
import { RecordTableScroll } from "./RecordTableScroll.js";
|
|
15
|
+
/**
|
|
16
|
+
* The table every record list uses; never `Table` or a plain `<table>`.
|
|
17
|
+
* `RecordTable.Provider` takes the `columns` and `data`; `checkboxColumn` adds row selection,
|
|
18
|
+
* `ColumnSelector` lets a member pick columns, and `CursorProvider` with its skeletons loads
|
|
19
|
+
* more rows by cursor.
|
|
20
|
+
*/
|
|
15
21
|
export declare const RecordTable: typeof RecordTableRoot & {
|
|
16
22
|
Provider: typeof RecordTableProvider;
|
|
17
23
|
Header: typeof RecordTableHeader;
|
|
@@ -14,6 +14,12 @@ import { RecordTableRowList } from "./RecordTableRowList.js";
|
|
|
14
14
|
import { RecordTableRowSkeleton } from "./RecordTableRowSkeleton.js";
|
|
15
15
|
import { RecordTableScroll } from "./RecordTableScroll.js";
|
|
16
16
|
// src/modules/record-table/components/RecordTable.tsx
|
|
17
|
+
/**
|
|
18
|
+
* The table every record list uses; never `Table` or a plain `<table>`.
|
|
19
|
+
* `RecordTable.Provider` takes the `columns` and `data`; `checkboxColumn` adds row selection,
|
|
20
|
+
* `ColumnSelector` lets a member pick columns, and `CursorProvider` with its skeletons loads
|
|
21
|
+
* more rows by cursor.
|
|
22
|
+
*/
|
|
17
23
|
const RecordTable = Object.assign(RecordTableRoot, {
|
|
18
24
|
Provider: RecordTableProvider,
|
|
19
25
|
Header: RecordTableHeader,
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
/** The header cell id of the column a cell sits in, so its control is named by the column. */
|
|
3
3
|
export declare const CellColumnHead: React.Context<string | undefined>;
|
|
4
|
+
/**
|
|
5
|
+
* A cell control's id and name: the column head (or a side panel field's label), then the
|
|
6
|
+
* control's own text ("Emails ada@…"), so an empty value is still named. Spread it before the
|
|
7
|
+
* caller's props, which win.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useCellLabel: (id?: string) => {
|
|
10
|
+
id: string;
|
|
11
|
+
'aria-labelledby': string | undefined;
|
|
12
|
+
};
|
|
4
13
|
/** A body cell. Its width and pinned offset are CSS variables the table container sets. */
|
|
5
14
|
export declare const RecordTableCell: ({ ref, children, className, columnId, pinned, style, ...props }: React.HTMLAttributes<HTMLTableCellElement> & {
|
|
6
15
|
columnId: string;
|
|
@@ -2,10 +2,24 @@ import { Table } from "../../../components/table.js";
|
|
|
2
2
|
import { cn } from "../../../lib/utils.js";
|
|
3
3
|
import { useRecordTable } from "./RecordTableProvider.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import { createContext } from "react";
|
|
5
|
+
import { createContext, use, useId } from "react";
|
|
6
6
|
// src/modules/record-table/components/RecordTableCell.tsx
|
|
7
7
|
/** The header cell id of the column a cell sits in, so its control is named by the column. */
|
|
8
8
|
const CellColumnHead = createContext(void 0);
|
|
9
|
+
/**
|
|
10
|
+
* A cell control's id and name: the column head (or a side panel field's label), then the
|
|
11
|
+
* control's own text ("Emails ada@…"), so an empty value is still named. Spread it before the
|
|
12
|
+
* caller's props, which win.
|
|
13
|
+
*/
|
|
14
|
+
const useCellLabel = (id) => {
|
|
15
|
+
const ownId = useId();
|
|
16
|
+
const controlId = id ?? ownId;
|
|
17
|
+
const head = use(CellColumnHead);
|
|
18
|
+
return {
|
|
19
|
+
id: controlId,
|
|
20
|
+
"aria-labelledby": head ? `${head} ${controlId}` : void 0
|
|
21
|
+
};
|
|
22
|
+
};
|
|
9
23
|
/** A body cell. Its width and pinned offset are CSS variables the table container sets. */
|
|
10
24
|
const RecordTableCell = ({ ref, children, className, columnId, pinned, style, ...props }) => {
|
|
11
25
|
const { headId } = useRecordTable();
|
|
@@ -32,4 +46,4 @@ const RecordTableCell = ({ ref, children, className, columnId, pinned, style, ..
|
|
|
32
46
|
})
|
|
33
47
|
});
|
|
34
48
|
};
|
|
35
|
-
export { CellColumnHead, RecordTableCell };
|
|
49
|
+
export { CellColumnHead, RecordTableCell, useCellLabel };
|
|
@@ -15,6 +15,11 @@ declare const cellDisplayVariants: (props?: ({
|
|
|
15
15
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
16
16
|
declare const RecordTableCellDisplay: ({ className, variant, ...props }: React.ComponentProps<'div'> & VariantProps<typeof cellDisplayVariants>) => React.JSX.Element;
|
|
17
17
|
declare const RecordTableInlineAnchor: ({ ref, className, onClick, children, ...props }: React.ComponentProps<typeof Badge>) => React.JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* A table cell value, and the trigger and popover that edit it in place.
|
|
20
|
+
* Used bare it shows a read-only value. `Trigger` and `Content` go inside a `Popover` or
|
|
21
|
+
* `PopoverScoped`; `Trigger`'s `variant="field"` fits a side panel row.
|
|
22
|
+
*/
|
|
18
23
|
export declare const RecordTableInlineCell: typeof RecordTableCellDisplay & {
|
|
19
24
|
/** Names the triggers inside by the element with this id, as the column head does in a table. */
|
|
20
25
|
LabelledBy: React.Context<string | undefined>;
|
|
@@ -2,9 +2,8 @@ import { Badge } from "../../../components/badge.js";
|
|
|
2
2
|
import { Button, buttonVariants } from "../../../components/button.js";
|
|
3
3
|
import { Popover } from "../../../components/popover.js";
|
|
4
4
|
import { cn } from "../../../lib/utils.js";
|
|
5
|
-
import { CellColumnHead } from "./RecordTableCell.js";
|
|
5
|
+
import { CellColumnHead, useCellLabel } from "./RecordTableCell.js";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import { use, useId } from "react";
|
|
8
7
|
import { cva } from "class-variance-authority";
|
|
9
8
|
// src/modules/record-table/components/RecordTableCellInline.tsx
|
|
10
9
|
const cellTriggerVariants = cva("h-8 px-2 w-full justify-start text-left focus-visible:relative focus-visible:z-10 focus-visible:outline-none focus-visible:shadow-subtle overflow-hidden", {
|
|
@@ -20,13 +19,10 @@ const cellTriggerVariants = cva("h-8 px-2 w-full justify-start text-left focus-v
|
|
|
20
19
|
defaultVariants: { variant: "cell" }
|
|
21
20
|
});
|
|
22
21
|
const RecordTableCellTrigger = ({ ref, children, className, id, variant, empty, ...props }) => {
|
|
23
|
-
const
|
|
24
|
-
const triggerId = id ?? ownId;
|
|
25
|
-
const columnHead = use(CellColumnHead);
|
|
22
|
+
const label = useCellLabel(id);
|
|
26
23
|
return /* @__PURE__ */ jsx(Popover.Trigger, {
|
|
27
24
|
render: /* @__PURE__ */ jsx(Button, {
|
|
28
|
-
|
|
29
|
-
"aria-labelledby": columnHead ? `${columnHead} ${triggerId}` : void 0,
|
|
25
|
+
...label,
|
|
30
26
|
variant: "ghost",
|
|
31
27
|
className: cn(cellTriggerVariants({
|
|
32
28
|
variant,
|
|
@@ -73,6 +69,11 @@ const RecordTableInlineAnchor = ({ ref, className, onClick, children, ...props }
|
|
|
73
69
|
children
|
|
74
70
|
});
|
|
75
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* A table cell value, and the trigger and popover that edit it in place.
|
|
74
|
+
* Used bare it shows a read-only value. `Trigger` and `Content` go inside a `Popover` or
|
|
75
|
+
* `PopoverScoped`; `Trigger`'s `variant="field"` fits a side panel row.
|
|
76
|
+
*/
|
|
76
77
|
const RecordTableInlineCell = Object.assign(RecordTableCellDisplay, {
|
|
77
78
|
/** Names the triggers inside by the element with this id, as the column head does in a table. */
|
|
78
79
|
LabelledBy: CellColumnHead,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ScrollArea } from "../../../components/scroll-area.js";
|
|
2
2
|
import { mergeRefs } from "../../../lib/utils.js";
|
|
3
3
|
import { useCursorScroll } from "../hooks/useCursorScroll.js";
|
|
4
|
+
import { tablePositionState } from "../states/RecordTableCursorState.js";
|
|
4
5
|
import "../types/RecordTableCursorTypes.js";
|
|
5
6
|
import { RecordTableRowSkeleton } from "./RecordTableRowSkeleton.js";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { createContext, useContext, useEffect, useState } from "react";
|
|
8
|
+
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
|
9
|
+
import { useStore } from "jotai";
|
|
8
10
|
import { useDebouncedCallback } from "use-debounce";
|
|
9
11
|
// src/modules/record-table/components/RecordTableCursor.tsx
|
|
10
12
|
const RecordTableCursorContext = createContext(null);
|
|
@@ -13,19 +15,6 @@ const useRecordTableCursorContext = () => {
|
|
|
13
15
|
if (!context) throw new Error("Cursor skeletons must be used within a RecordTableCursorProvider");
|
|
14
16
|
return context;
|
|
15
17
|
};
|
|
16
|
-
/** Session storage is best effort: when it is blocked the position is simply not restored. */
|
|
17
|
-
const remember = (key, value) => {
|
|
18
|
-
try {
|
|
19
|
-
sessionStorage.setItem(key, value);
|
|
20
|
-
} catch {}
|
|
21
|
-
};
|
|
22
|
-
const recall = (key) => {
|
|
23
|
-
try {
|
|
24
|
-
return sessionStorage.getItem(key);
|
|
25
|
-
} catch {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
18
|
/**
|
|
30
19
|
* Scrolls a cursor-paged table. With a `sessionKey` it remembers the first visible row and the
|
|
31
20
|
* scroll position for the session, and restores the position when the rows come back.
|
|
@@ -37,34 +26,47 @@ const RecordTableCursorProvider = ({ children, hasPreviousPage, loading, dataLen
|
|
|
37
26
|
offset
|
|
38
27
|
});
|
|
39
28
|
const [viewport, setViewport] = useState(null);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
const store = useStore();
|
|
30
|
+
const remember = (part) => {
|
|
31
|
+
if (sessionKey) store.set(tablePositionState(sessionKey), (saved) => ({
|
|
32
|
+
...saved,
|
|
33
|
+
...part
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
const rememberScrollTop = useDebouncedCallback((scroll) => remember({ scroll }), 150);
|
|
43
37
|
const handleScroll = (event) => {
|
|
44
38
|
const scroll = event.currentTarget;
|
|
45
39
|
const firstVisibleRow = scroll.querySelector(".in-view");
|
|
46
|
-
if (
|
|
40
|
+
if (firstVisibleRow) remember({ row: firstVisibleRow.id });
|
|
47
41
|
rememberScrollTop(scroll.scrollTop);
|
|
48
42
|
};
|
|
49
43
|
useEffect(() => {
|
|
50
44
|
const scroll = scrollRef.current;
|
|
51
45
|
if (!dataLength || loading || !scroll || !sessionKey) return;
|
|
52
|
-
const saved =
|
|
53
|
-
if (saved) scroll.scrollTop =
|
|
46
|
+
const saved = store.get(tablePositionState(sessionKey)).scroll;
|
|
47
|
+
if (saved) scroll.scrollTop = saved;
|
|
54
48
|
}, [
|
|
55
49
|
loading,
|
|
56
50
|
dataLength,
|
|
57
51
|
scrollRef,
|
|
58
|
-
sessionKey
|
|
52
|
+
sessionKey,
|
|
53
|
+
store
|
|
54
|
+
]);
|
|
55
|
+
const cursor = useMemo(() => ({
|
|
56
|
+
viewport,
|
|
57
|
+
startBackwardFetch,
|
|
58
|
+
hasNextPage,
|
|
59
|
+
hasPreviousPage,
|
|
60
|
+
loading
|
|
61
|
+
}), [
|
|
62
|
+
viewport,
|
|
63
|
+
startBackwardFetch,
|
|
64
|
+
hasNextPage,
|
|
65
|
+
hasPreviousPage,
|
|
66
|
+
loading
|
|
59
67
|
]);
|
|
60
68
|
return /* @__PURE__ */ jsx(RecordTableCursorContext.Provider, {
|
|
61
|
-
value:
|
|
62
|
-
viewport,
|
|
63
|
-
startBackwardFetch,
|
|
64
|
-
hasNextPage,
|
|
65
|
-
hasPreviousPage,
|
|
66
|
-
loading
|
|
67
|
-
},
|
|
69
|
+
value: cursor,
|
|
68
70
|
children: /* @__PURE__ */ jsxs(ScrollArea.Root, {
|
|
69
71
|
className: "h-full w-full pb-2 pr-2 relative",
|
|
70
72
|
children: [
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { RecordTableFeatures } from "./RecordTableProvider.js";
|
|
1
|
+
import { RecordTableFeatures, TRecordTableSort } from "./RecordTableProvider.js";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Header, RowData } from "@tanstack/react-table";
|
|
4
4
|
type RecordTableHeader = Header<RecordTableFeatures, RowData>;
|
|
5
|
-
/**
|
|
5
|
+
/** Off → ascending → descending → off. */
|
|
6
|
+
export declare const nextSort: (sort: TRecordTableSort | null, by: string) => TRecordTableSort | null;
|
|
7
|
+
/**
|
|
8
|
+
* A header cell: drag it to reorder its column, drag its right edge to resize it, click it to
|
|
9
|
+
* sort by it when the table sorts (`RecordTable.Provider`'s `sortable`).
|
|
10
|
+
*/
|
|
6
11
|
export declare const RecordTableHead: ({ header, pinned, children, className, ...props }: React.ComponentProps<'th'> & {
|
|
7
12
|
header: RecordTableHeader;
|
|
8
13
|
pinned: boolean;
|
|
@@ -2,8 +2,9 @@ import { Table } from "../../../components/table.js";
|
|
|
2
2
|
import { cn } from "../../../lib/utils.js";
|
|
3
3
|
import { isStructuralColumn } from "../utils/columnUtils.js";
|
|
4
4
|
import { useRecordTable, useRecordTableState } from "./RecordTableProvider.js";
|
|
5
|
+
import { IconArrowDown, IconArrowUp, IconArrowsSort } from "@tabler/icons-react";
|
|
5
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import "react";
|
|
7
|
+
import { useRef } from "react";
|
|
7
8
|
import { cva } from "class-variance-authority";
|
|
8
9
|
import { useDndContext } from "@dnd-kit/core";
|
|
9
10
|
import { useSortable } from "@dnd-kit/sortable";
|
|
@@ -13,10 +14,65 @@ const recordTableHeadVariants = cva("sticky z-2 top-0 w-(--head-width) transitio
|
|
|
13
14
|
isDragging: { true: "z-3" },
|
|
14
15
|
pinned: { true: "z-3 left-(--head-start)" }
|
|
15
16
|
} });
|
|
16
|
-
|
|
17
|
+
const SORT_BUTTON = {
|
|
18
|
+
none: {
|
|
19
|
+
Icon: IconArrowsSort,
|
|
20
|
+
label: "Sort ascending"
|
|
21
|
+
},
|
|
22
|
+
asc: {
|
|
23
|
+
Icon: IconArrowUp,
|
|
24
|
+
label: "Sort descending"
|
|
25
|
+
},
|
|
26
|
+
desc: {
|
|
27
|
+
Icon: IconArrowDown,
|
|
28
|
+
label: "Clear sort"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const ARIA_SORT = {
|
|
32
|
+
asc: "ascending",
|
|
33
|
+
desc: "descending",
|
|
34
|
+
none: "none"
|
|
35
|
+
};
|
|
36
|
+
const CLICK_MS = 300;
|
|
37
|
+
/** Off → ascending → descending → off. */
|
|
38
|
+
const nextSort = (sort, by) => {
|
|
39
|
+
if (sort?.by !== by) return {
|
|
40
|
+
by,
|
|
41
|
+
direction: "asc"
|
|
42
|
+
};
|
|
43
|
+
return sort.direction === "asc" ? {
|
|
44
|
+
by,
|
|
45
|
+
direction: "desc"
|
|
46
|
+
} : null;
|
|
47
|
+
};
|
|
48
|
+
/** The header's sort control: the order shown, and a button for the keyboard. */
|
|
49
|
+
const SortButton = ({ direction, onSort }) => {
|
|
50
|
+
const { Icon, label } = SORT_BUTTON[direction ?? "none"];
|
|
51
|
+
return /* @__PURE__ */ jsx("button", {
|
|
52
|
+
type: "button",
|
|
53
|
+
"aria-label": label,
|
|
54
|
+
className: cn("relative z-1 ml-1 inline-flex size-5 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted focus-visible:opacity-100 focus-visible:outline-2 focus-visible:outline-ring", !direction && "opacity-0 group-hover/head:opacity-100"),
|
|
55
|
+
onClick: (event) => {
|
|
56
|
+
event.stopPropagation();
|
|
57
|
+
onSort();
|
|
58
|
+
},
|
|
59
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
60
|
+
className: "size-3.5",
|
|
61
|
+
"aria-hidden": true
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* A header cell: drag it to reorder its column, drag its right edge to resize it, click it to
|
|
67
|
+
* sort by it when the table sorts (`RecordTable.Provider`'s `sortable`).
|
|
68
|
+
*/
|
|
17
69
|
const RecordTableHead = ({ header, pinned, children, className, ...props }) => {
|
|
18
70
|
const { id } = header.column;
|
|
19
|
-
const { headId } = useRecordTable();
|
|
71
|
+
const { headId, sorting } = useRecordTable();
|
|
72
|
+
const pressedAt = useRef(0);
|
|
73
|
+
const sortable = Boolean(sorting?.columns.includes(id));
|
|
74
|
+
const direction = sorting?.sort?.by === id ? sorting.sort.direction : void 0;
|
|
75
|
+
const sort = () => sorting?.onChange(nextSort(sorting.sort, id));
|
|
20
76
|
const { isDragging, listeners, setNodeRef, transform } = useSortable({
|
|
21
77
|
id,
|
|
22
78
|
disabled: pinned
|
|
@@ -27,13 +83,24 @@ const RecordTableHead = ({ header, pinned, children, className, ...props }) => {
|
|
|
27
83
|
className: cn(recordTableHeadVariants({
|
|
28
84
|
isDragging,
|
|
29
85
|
pinned
|
|
30
|
-
}), className),
|
|
86
|
+
}), sortable && "group/head cursor-pointer", className),
|
|
31
87
|
style: {
|
|
32
88
|
"--head-width": `var(--header-${header.id}-width)`,
|
|
33
89
|
"--head-start": pinned ? `var(--col-${id}-start)` : void 0
|
|
34
90
|
},
|
|
91
|
+
"aria-sort": sortable ? ARIA_SORT[direction ?? "none"] : void 0,
|
|
92
|
+
onPointerDown: sortable ? () => pressedAt.current = Date.now() : void 0,
|
|
93
|
+
onClick: sortable ? () => {
|
|
94
|
+
if (Date.now() - pressedAt.current < CLICK_MS) sort();
|
|
95
|
+
} : void 0,
|
|
35
96
|
...props,
|
|
36
|
-
children: [
|
|
97
|
+
children: [sortable ? /* @__PURE__ */ jsxs("div", {
|
|
98
|
+
className: "flex items-center",
|
|
99
|
+
children: [children, /* @__PURE__ */ jsx(SortButton, {
|
|
100
|
+
direction,
|
|
101
|
+
onSort: sort
|
|
102
|
+
})]
|
|
103
|
+
}) : children, !isStructuralColumn(id) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37
104
|
/* @__PURE__ */ jsx("span", {
|
|
38
105
|
...listeners,
|
|
39
106
|
"aria-hidden": true,
|
|
@@ -75,4 +142,4 @@ const RecordTableHeadSize = ({ header }) => {
|
|
|
75
142
|
onTouchStart: startResize
|
|
76
143
|
});
|
|
77
144
|
};
|
|
78
|
-
export { RecordTableHead };
|
|
145
|
+
export { RecordTableHead, nextSort };
|
|
@@ -16,8 +16,21 @@ export type RecordTableFeatures = typeof recordTableFeatures;
|
|
|
16
16
|
export type RecordTableColumnDef<TData extends RowData> = ColumnDef<RecordTableFeatures, TData>;
|
|
17
17
|
/** Rows are typed `RowData` here: every table shares this context, whatever its data. */
|
|
18
18
|
export type RecordTableInstance = Table<RecordTableFeatures, RowData>;
|
|
19
|
+
/** The order a list's rows come in: by a column, either way. The page sorts (usually its query). */
|
|
20
|
+
export interface TRecordTableSort {
|
|
21
|
+
by: string;
|
|
22
|
+
direction: 'asc' | 'desc';
|
|
23
|
+
}
|
|
24
|
+
interface IRecordTableSorting {
|
|
25
|
+
sort: TRecordTableSort | null;
|
|
26
|
+
/** The columns a click on their header sorts by. */
|
|
27
|
+
columns: readonly string[];
|
|
28
|
+
onChange: (sort: TRecordTableSort | null) => void;
|
|
29
|
+
}
|
|
19
30
|
interface IRecordTableContext {
|
|
20
31
|
table: RecordTableInstance;
|
|
32
|
+
/** Null: the table doesn't sort from its headers. */
|
|
33
|
+
sorting: IRecordTableSorting | null;
|
|
21
34
|
columnSelectorOpen: boolean;
|
|
22
35
|
setColumnSelectorOpen: (open: boolean) => void;
|
|
23
36
|
/** The id of a column's header cell, unique per table: cells are named by their column. */
|
|
@@ -37,6 +50,14 @@ export interface RecordTableProviderProps<TData extends RowData> extends HTMLAtt
|
|
|
37
50
|
data: TData[];
|
|
38
51
|
stickyColumns?: string[];
|
|
39
52
|
tableId?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Sorting by a click on a column's header: off, then ascending, then descending, then off.
|
|
55
|
+
* `sortable` lists the columns that sort; the page orders the rows by `sort` (its query does)
|
|
56
|
+
* and keeps it, e.g. in the URL. Without `onSortChange` no header sorts.
|
|
57
|
+
*/
|
|
58
|
+
sort?: TRecordTableSort | null;
|
|
59
|
+
sortable?: readonly string[];
|
|
60
|
+
onSortChange?: (sort: TRecordTableSort | null) => void;
|
|
40
61
|
}
|
|
41
|
-
export declare const RecordTableProvider: <TData extends RowData>({ children, columns, data, stickyColumns, tableId, ...containerProps }: RecordTableProviderProps<TData>) => import("react").JSX.Element;
|
|
62
|
+
export declare const RecordTableProvider: <TData extends RowData>({ children, columns, data, stickyColumns, tableId, sort, sortable, onSortChange, ...containerProps }: RecordTableProviderProps<TData>) => import("react").JSX.Element;
|
|
42
63
|
export {};
|
|
@@ -3,7 +3,7 @@ import { readRow } from "../utils/rowFields.js";
|
|
|
3
3
|
import { RecordTableContainer } from "./RecordTableContainer.js";
|
|
4
4
|
import { RecordTableDnDProvider } from "./RecordTableDnDProvider.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { createContext, useContext, useId, useState } from "react";
|
|
6
|
+
import { createContext, useContext, useId, useMemo, useState } from "react";
|
|
7
7
|
import { shallow, useSelector } from "@tanstack/react-store";
|
|
8
8
|
import { columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnSizingFeature, columnVisibilityFeature, rowSelectionFeature, tableFeatures, useTable } from "@tanstack/react-table";
|
|
9
9
|
// src/modules/record-table/components/RecordTableProvider.tsx
|
|
@@ -34,7 +34,7 @@ const useRecordTableState = (select) => {
|
|
|
34
34
|
};
|
|
35
35
|
/** A row's `_id` or `id`, else tanstack's default (its index under its parent). */
|
|
36
36
|
const getRowId = (row, index, parent) => readRow(row).id ?? (parent ? `${parent.id}.${index}` : String(index));
|
|
37
|
-
const RecordTableProvider = ({ children, columns, data, stickyColumns, tableId, ...containerProps }) => {
|
|
37
|
+
const RecordTableProvider = ({ children, columns, data, stickyColumns, tableId, sort = null, sortable, onSortChange, ...containerProps }) => {
|
|
38
38
|
const [columnSelectorOpen, setColumnSelectorOpen] = useState(false);
|
|
39
39
|
const { state, setColumnOrder, ...layoutHandlers } = useColumnLayout({
|
|
40
40
|
columnIds: columns.map((column) => column.id ?? ""),
|
|
@@ -53,13 +53,29 @@ const RecordTableProvider = ({ children, columns, data, stickyColumns, tableId,
|
|
|
53
53
|
getRowId
|
|
54
54
|
}, () => null);
|
|
55
55
|
const headPrefix = useId();
|
|
56
|
+
const sorting = useMemo(() => onSortChange ? {
|
|
57
|
+
sort,
|
|
58
|
+
columns: sortable ?? [],
|
|
59
|
+
onChange: onSortChange
|
|
60
|
+
} : null, [
|
|
61
|
+
sort,
|
|
62
|
+
sortable,
|
|
63
|
+
onSortChange
|
|
64
|
+
]);
|
|
65
|
+
const context = useMemo(() => ({
|
|
66
|
+
table: shared,
|
|
67
|
+
sorting,
|
|
68
|
+
columnSelectorOpen,
|
|
69
|
+
setColumnSelectorOpen,
|
|
70
|
+
headId: (columnId) => `${headPrefix}-head-${columnId}`
|
|
71
|
+
}), [
|
|
72
|
+
shared,
|
|
73
|
+
sorting,
|
|
74
|
+
columnSelectorOpen,
|
|
75
|
+
headPrefix
|
|
76
|
+
]);
|
|
56
77
|
return /* @__PURE__ */ jsx(RecordTableContext.Provider, {
|
|
57
|
-
value:
|
|
58
|
-
table: shared,
|
|
59
|
-
columnSelectorOpen,
|
|
60
|
-
setColumnSelectorOpen,
|
|
61
|
-
headId: (columnId) => `${headPrefix}-head-${columnId}`
|
|
62
|
-
},
|
|
78
|
+
value: context,
|
|
63
79
|
children: /* @__PURE__ */ jsx(RecordTableDnDProvider, {
|
|
64
80
|
setColumnOrder,
|
|
65
81
|
children: /* @__PURE__ */ jsx(RecordTableContainer, {
|
|
@@ -10,7 +10,7 @@ declare const tablePrefsSchema: z.ZodObject<{
|
|
|
10
10
|
stickyColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
11
11
|
}, z.core.$strip>;
|
|
12
12
|
type TablePrefs = z.infer<typeof tablePrefsSchema>;
|
|
13
|
-
/** A table's column layout, kept in
|
|
13
|
+
/** A table's column layout, kept in this browser per `tableId`; without one nothing is kept. */
|
|
14
14
|
export declare const useTablePreferences: (tableId: string | undefined) => {
|
|
15
15
|
prefs: {
|
|
16
16
|
columnOrder?: string[] | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useCallback
|
|
1
|
+
import { storedFamily } from "../../../lib/stored.js";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { useAtom } from "jotai";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
// src/modules/record-table/hooks/useTablePreferences.ts
|
|
5
6
|
const ids = z.array(z.string());
|
|
@@ -14,37 +15,23 @@ const tablePrefsSchema = z.object({
|
|
|
14
15
|
/** The columns meant to stick when the pinning was saved (a newly sticky column is pinned once). */
|
|
15
16
|
stickyColumns: ids.optional()
|
|
16
17
|
});
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} catch {
|
|
24
|
-
return {};
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const writePrefs = (tableId, prefs) => {
|
|
28
|
-
try {
|
|
29
|
-
localStorage.setItem(storageKey(tableId), JSON.stringify(prefs));
|
|
30
|
-
} catch {}
|
|
31
|
-
};
|
|
32
|
-
/** A table's column layout, kept in localStorage per `tableId`; without one nothing is kept. */
|
|
18
|
+
const tablePrefsState = storedFamily({
|
|
19
|
+
key: "erxes:table:prefs",
|
|
20
|
+
schema: tablePrefsSchema,
|
|
21
|
+
initial: {}
|
|
22
|
+
});
|
|
23
|
+
/** A table's column layout, kept in this browser per `tableId`; without one nothing is kept. */
|
|
33
24
|
const useTablePreferences = (tableId) => {
|
|
34
|
-
const [prefs, setPrefs] =
|
|
25
|
+
const [prefs, setPrefs] = useAtom(tablePrefsState(tableId ?? ""));
|
|
26
|
+
const savePrefs = useCallback((updates) => {
|
|
27
|
+
if (tableId) setPrefs((current) => ({
|
|
28
|
+
...current,
|
|
29
|
+
...updates
|
|
30
|
+
}));
|
|
31
|
+
}, [tableId, setPrefs]);
|
|
35
32
|
return {
|
|
36
|
-
prefs,
|
|
37
|
-
savePrefs
|
|
38
|
-
if (!tableId) return;
|
|
39
|
-
setPrefs((current) => {
|
|
40
|
-
const merged = {
|
|
41
|
-
...current,
|
|
42
|
-
...updates
|
|
43
|
-
};
|
|
44
|
-
writePrefs(tableId, merged);
|
|
45
|
-
return merged;
|
|
46
|
-
});
|
|
47
|
-
}, [tableId])
|
|
33
|
+
prefs: tableId ? prefs : {},
|
|
34
|
+
savePrefs
|
|
48
35
|
};
|
|
49
36
|
};
|
|
50
37
|
export { useTablePreferences };
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Where a cursor-paged list was for this tab, per `sessionKey`: the first row in view and the
|
|
3
|
+
* scroll offset, both under the `filters` they were seen with.
|
|
4
|
+
*/
|
|
5
|
+
export declare const tablePositionState: import("jotai-family").AtomFamily<string, import("jotai").WritableAtom<{
|
|
6
|
+
filters: string;
|
|
7
|
+
row: string;
|
|
8
|
+
scroll: number;
|
|
9
|
+
}, [typeof import("jotai/utils").RESET | {
|
|
10
|
+
filters: string;
|
|
11
|
+
row: string;
|
|
12
|
+
scroll: number;
|
|
13
|
+
} | ((prev: {
|
|
14
|
+
filters: string;
|
|
15
|
+
row: string;
|
|
16
|
+
scroll: number;
|
|
17
|
+
}) => typeof import("jotai/utils").RESET | {
|
|
18
|
+
filters: string;
|
|
19
|
+
row: string;
|
|
20
|
+
scroll: number;
|
|
21
|
+
})], void>>;
|