@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
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { storedFamily } from "../../../lib/stored.js";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
// src/modules/record-table/states/RecordTableCursorState.ts
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Where a cursor-paged list was for this tab, per `sessionKey`: the first row in view and the
|
|
6
|
+
* scroll offset, both under the `filters` they were seen with.
|
|
7
|
+
*/
|
|
8
|
+
const tablePositionState = storedFamily({
|
|
9
|
+
key: "erxes:table:position",
|
|
10
|
+
session: true,
|
|
11
|
+
schema: z.object({
|
|
12
|
+
filters: z.string(),
|
|
13
|
+
row: z.string(),
|
|
14
|
+
scroll: z.number()
|
|
15
|
+
}),
|
|
16
|
+
initial: {
|
|
17
|
+
filters: "",
|
|
18
|
+
row: "",
|
|
19
|
+
scroll: 0
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
export { tablePositionState };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/modules/record-table/types/RecordTableCursorTypes.ts
|
|
2
|
+
/** Which way a cursor-paged table loads more rows: forward or backward. */
|
|
2
3
|
let EnumCursorDirection = /* @__PURE__ */ function(EnumCursorDirection) {
|
|
3
4
|
EnumCursorDirection["FORWARD"] = "forward";
|
|
4
5
|
EnumCursorDirection["BACKWARD"] = "backward";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ContactQueries, TContactContentType } from "./contacts.js";
|
|
2
|
+
/**
|
|
3
|
+
* A customer or company as a chip: its avatar and name. Inside erxes, clicking it opens the
|
|
4
|
+
* record in core's side panel beside the page; elsewhere it is only the name.
|
|
5
|
+
* `contacts` is `contactQueries` from `@erxes/core-contract/client`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ContactLink: ({ contentType, contentId, contacts, placeholder }: {
|
|
8
|
+
contentType: TContactContentType;
|
|
9
|
+
contentId: string;
|
|
10
|
+
contacts: ContactQueries;
|
|
11
|
+
/** Shown when the record has no name, email or phone. */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { companyTitle, customerTitle } from "./contacts.js";
|
|
2
|
+
import { RecordChip } from "./RecordChip.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useQuery } from "@tanstack/react-query";
|
|
5
|
+
// src/modules/records/ContactLink.tsx
|
|
6
|
+
/** The customer's or company's title and avatar. */
|
|
7
|
+
const useContact = (contentType, contentId, contacts) => {
|
|
8
|
+
const isCustomer = contentType === "core:customer";
|
|
9
|
+
const customer = useQuery({
|
|
10
|
+
...contacts.customer(contentId),
|
|
11
|
+
enabled: isCustomer
|
|
12
|
+
});
|
|
13
|
+
const company = useQuery({
|
|
14
|
+
...contacts.company(contentId),
|
|
15
|
+
enabled: !isCustomer
|
|
16
|
+
});
|
|
17
|
+
if (isCustomer) return {
|
|
18
|
+
title: customer.data ? customerTitle(customer.data) : "",
|
|
19
|
+
avatarUrl: customer.data?.avatarUrl,
|
|
20
|
+
isPending: customer.isPending,
|
|
21
|
+
error: customer.error
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
title: company.data ? companyTitle(company.data) : "",
|
|
25
|
+
avatarUrl: company.data?.avatarUrl,
|
|
26
|
+
isPending: company.isPending,
|
|
27
|
+
error: company.error
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* A customer or company as a chip: its avatar and name. Inside erxes, clicking it opens the
|
|
32
|
+
* record in core's side panel beside the page; elsewhere it is only the name.
|
|
33
|
+
* `contacts` is `contactQueries` from `@erxes/core-contract/client`.
|
|
34
|
+
*/
|
|
35
|
+
const ContactLink = ({ contentType, contentId, contacts, placeholder }) => {
|
|
36
|
+
const contact = useContact(contentType, contentId, contacts);
|
|
37
|
+
const name = contact.error?.message || contact.title || placeholder || (contentType === "core:customer" ? "Unnamed customer" : "Unnamed company");
|
|
38
|
+
return /* @__PURE__ */ jsx(RecordChip, {
|
|
39
|
+
record: {
|
|
40
|
+
contentType,
|
|
41
|
+
contentId
|
|
42
|
+
},
|
|
43
|
+
name,
|
|
44
|
+
avatarUrl: contact.avatarUrl,
|
|
45
|
+
loading: contact.isPending,
|
|
46
|
+
failed: Boolean(contact.error)
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
export { ContactLink };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ContactQueries, ContactSearchQueries } from "./contacts.js";
|
|
2
|
+
/** Which contacts a picker lists: core's customers or its companies. */
|
|
3
|
+
export type TContactKind = 'customer' | 'company';
|
|
4
|
+
/**
|
|
5
|
+
* A picker's searchable list of customers or companies, the picked first.
|
|
6
|
+
* Searched on the server; `contacts` is `contactSearchQueries` from
|
|
7
|
+
* `@erxes/core-contract/client`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SelectContactContent: ({ kind, value, onValueChange, contacts, multiple, noneLabel }: {
|
|
10
|
+
kind: TContactKind;
|
|
11
|
+
value: string[];
|
|
12
|
+
onValueChange: (ids: string[]) => void;
|
|
13
|
+
contacts: ContactSearchQueries;
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
noneLabel?: string;
|
|
16
|
+
}) => import("react").JSX.Element;
|
|
17
|
+
type RelationProps = {
|
|
18
|
+
kind: TContactKind;
|
|
19
|
+
value: string[];
|
|
20
|
+
/** Picks several unless `multiple` is false; then a pick replaces the one linked. */
|
|
21
|
+
onValueChange?: (ids: string[]) => void;
|
|
22
|
+
/** `contactQueries` and `contactSearchQueries` from `@erxes/core-contract/client`. */
|
|
23
|
+
contacts: ContactQueries;
|
|
24
|
+
contactSearch: ContactSearchQueries;
|
|
25
|
+
multiple?: boolean;
|
|
26
|
+
scope: string;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* A record's customers or companies in a side panel field.
|
|
31
|
+
* Put it in a `cell={false}` field. The first shows as a chip, then a muted button adds, changes, or shows the rest
|
|
32
|
+
* (`+N`). Without `onValueChange` it only shows them. Core's panels and plugin
|
|
33
|
+
* records draw contacts with it.
|
|
34
|
+
*/
|
|
35
|
+
export declare const ContactRelationInput: (props: RelationProps) => import("react").JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Avatar } from "../../components/avatar.js";
|
|
2
|
+
import { Button } from "../../components/button.js";
|
|
3
|
+
import { Combobox } from "../../components/combobox.js";
|
|
4
|
+
import { Popover } from "../../components/popover.js";
|
|
5
|
+
import { Spinner } from "../../components/spinner.js";
|
|
6
|
+
import { cn } from "../../lib/utils.js";
|
|
7
|
+
import { readImage } from "../../utils/core.js";
|
|
8
|
+
import { PopoverScoped } from "../hotkey/components/PopoverScoped.js";
|
|
9
|
+
import { EntityPicker } from "../pickers/EntityPicker.js";
|
|
10
|
+
import { ContactLink } from "./ContactLink.js";
|
|
11
|
+
import { companyTitle, customerTitle } from "./contacts.js";
|
|
12
|
+
import { IconPlus } from "@tabler/icons-react";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import { useTranslation } from "react-i18next";
|
|
16
|
+
import { useQuery } from "@tanstack/react-query";
|
|
17
|
+
import { useDebounce } from "use-debounce";
|
|
18
|
+
// src/modules/records/ContactPicker.tsx
|
|
19
|
+
/** Up to 20 customers or companies: those matching `search`, or the ones with `ids`. */
|
|
20
|
+
const useContactRows = (contacts, kind, { search, ids }) => {
|
|
21
|
+
const input = {
|
|
22
|
+
search: search || void 0,
|
|
23
|
+
ids
|
|
24
|
+
};
|
|
25
|
+
const enabled = !ids || ids.length > 0;
|
|
26
|
+
const customers = useQuery({
|
|
27
|
+
...contacts.customers(input),
|
|
28
|
+
enabled: enabled && kind === "customer",
|
|
29
|
+
placeholderData: (previous) => previous
|
|
30
|
+
});
|
|
31
|
+
const companies = useQuery({
|
|
32
|
+
...contacts.companies(input),
|
|
33
|
+
enabled: enabled && kind === "company",
|
|
34
|
+
placeholderData: (previous) => previous
|
|
35
|
+
});
|
|
36
|
+
if (kind === "customer") return {
|
|
37
|
+
data: customers.data?.data.map((customer) => ({
|
|
38
|
+
id: customer.id,
|
|
39
|
+
name: customerTitle(customer),
|
|
40
|
+
avatarUrl: customer.avatarUrl
|
|
41
|
+
})),
|
|
42
|
+
isPending: customers.isPending,
|
|
43
|
+
error: customers.error
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
data: companies.data?.data.map((company) => ({
|
|
47
|
+
id: company.id,
|
|
48
|
+
name: companyTitle(company),
|
|
49
|
+
avatarUrl: company.avatarUrl
|
|
50
|
+
})),
|
|
51
|
+
isPending: companies.isPending,
|
|
52
|
+
error: companies.error
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* A picker's searchable list of customers or companies, the picked first.
|
|
57
|
+
* Searched on the server; `contacts` is `contactSearchQueries` from
|
|
58
|
+
* `@erxes/core-contract/client`.
|
|
59
|
+
*/
|
|
60
|
+
const SelectContactContent = ({ kind, value, onValueChange, contacts, multiple = true, noneLabel }) => {
|
|
61
|
+
const [search, setSearch] = useState("");
|
|
62
|
+
const [debounced] = useDebounce(search.trim(), 500);
|
|
63
|
+
const placeholder = kind === "customer" ? "Unnamed customer" : "Unnamed company";
|
|
64
|
+
const selected = useContactRows(contacts, kind, { ids: value });
|
|
65
|
+
const matches = useContactRows(contacts, kind, { search: debounced });
|
|
66
|
+
const found = matches.data ?? [];
|
|
67
|
+
const items = [...(selected.data ?? []).filter((option) => value.includes(option.id) && !found.some((match) => match.id === option.id)), ...found];
|
|
68
|
+
return /* @__PURE__ */ jsx(EntityPicker, {
|
|
69
|
+
multiple,
|
|
70
|
+
noneLabel,
|
|
71
|
+
items,
|
|
72
|
+
itemKey: (option) => ({
|
|
73
|
+
id: option.id,
|
|
74
|
+
label: option.name
|
|
75
|
+
}),
|
|
76
|
+
renderItem: (option) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Avatar, { children: [/* @__PURE__ */ jsx(Avatar.Image, { src: readImage(option.avatarUrl ?? void 0) }), /* @__PURE__ */ jsx(Avatar.Fallback, { children: option.name.charAt(0) })] }), /* @__PURE__ */ jsx(Combobox.Value, {
|
|
77
|
+
value: option.name,
|
|
78
|
+
placeholder
|
|
79
|
+
})] }),
|
|
80
|
+
value,
|
|
81
|
+
onValueChange,
|
|
82
|
+
onSearchChange: setSearch,
|
|
83
|
+
loading: matches.isPending,
|
|
84
|
+
error: matches.error ?? selected.error
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const ContactRelationTriggerLabel = ({ saving, moreCount, hasLinks, addLabel }) => {
|
|
88
|
+
if (saving) return /* @__PURE__ */ jsx(Spinner, { size: "sm" });
|
|
89
|
+
if (moreCount > 0) return /* @__PURE__ */ jsxs("span", {
|
|
90
|
+
className: "font-normal",
|
|
91
|
+
children: ["+", moreCount]
|
|
92
|
+
});
|
|
93
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(IconPlus, { "aria-hidden": "true" }), !hasLinks && /* @__PURE__ */ jsx("span", {
|
|
94
|
+
className: "font-normal",
|
|
95
|
+
children: addLabel
|
|
96
|
+
})] });
|
|
97
|
+
};
|
|
98
|
+
/** The button after the first chip: `+N` more, or add, opening the picker. */
|
|
99
|
+
const ContactRelationPopover = ({ kind, value, contacts, contactSearch, multiple = true, scope, disabled = false, onValueChange }) => {
|
|
100
|
+
const { t } = useTranslation("common", { keyPrefix: "side-panel" });
|
|
101
|
+
const [open, setOpen] = useState(false);
|
|
102
|
+
const hasLinks = value.length > 0;
|
|
103
|
+
const moreCount = Math.max(0, value.length - 1);
|
|
104
|
+
const addLabel = kind === "company" ? t("add-company", "Add company") : t("add-customer", "Add customer");
|
|
105
|
+
const editLabel = kind === "company" ? t("edit-companies", "Edit companies") : t("edit-customers", "Edit customers");
|
|
106
|
+
return /* @__PURE__ */ jsxs(PopoverScoped, {
|
|
107
|
+
scope,
|
|
108
|
+
open,
|
|
109
|
+
onOpenChange: setOpen,
|
|
110
|
+
children: [/* @__PURE__ */ jsx(Popover.Trigger, {
|
|
111
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
112
|
+
variant: moreCount > 0 ? "secondary" : "ghost",
|
|
113
|
+
size: "xs",
|
|
114
|
+
tone: "muted",
|
|
115
|
+
"data-panel-inline": "",
|
|
116
|
+
disabled,
|
|
117
|
+
"aria-label": hasLinks ? editLabel : addLabel,
|
|
118
|
+
className: cn("shrink-0 [&>svg]:size-3.5", hasLinks && !moreCount && "opacity-0 group-hover/relations:opacity-100 focus-visible:opacity-100 data-popup-open:opacity-100")
|
|
119
|
+
}),
|
|
120
|
+
children: /* @__PURE__ */ jsx(ContactRelationTriggerLabel, {
|
|
121
|
+
saving: disabled,
|
|
122
|
+
moreCount,
|
|
123
|
+
hasLinks,
|
|
124
|
+
addLabel
|
|
125
|
+
})
|
|
126
|
+
}), /* @__PURE__ */ jsx(Combobox.Content, { children: onValueChange ? /* @__PURE__ */ jsx(SelectContactContent, {
|
|
127
|
+
kind,
|
|
128
|
+
value,
|
|
129
|
+
contacts: contactSearch,
|
|
130
|
+
multiple,
|
|
131
|
+
onValueChange: (ids) => {
|
|
132
|
+
if (disabled) return;
|
|
133
|
+
onValueChange(ids);
|
|
134
|
+
if (!multiple) setOpen(false);
|
|
135
|
+
}
|
|
136
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
137
|
+
className: "flex flex-col items-start gap-1 p-2",
|
|
138
|
+
children: value.map((id) => /* @__PURE__ */ jsx(ContactLink, {
|
|
139
|
+
contentType: kind === "company" ? "core:company" : "core:customer",
|
|
140
|
+
contentId: id,
|
|
141
|
+
contacts
|
|
142
|
+
}, id))
|
|
143
|
+
}) })]
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* A record's customers or companies in a side panel field.
|
|
148
|
+
* Put it in a `cell={false}` field. The first shows as a chip, then a muted button adds, changes, or shows the rest
|
|
149
|
+
* (`+N`). Without `onValueChange` it only shows them. Core's panels and plugin
|
|
150
|
+
* records draw contacts with it.
|
|
151
|
+
*/
|
|
152
|
+
const ContactRelationInput = (props) => {
|
|
153
|
+
const { kind, value, contacts, onValueChange } = props;
|
|
154
|
+
const { t } = useTranslation("common", { keyPrefix: "side-panel" });
|
|
155
|
+
let control = null;
|
|
156
|
+
if (onValueChange || value.length > 1) control = /* @__PURE__ */ jsx(ContactRelationPopover, { ...props });
|
|
157
|
+
else if (!value.length) control = /* @__PURE__ */ jsx("span", {
|
|
158
|
+
className: "px-1 text-xs text-muted-foreground",
|
|
159
|
+
children: t("not-specified", "Not specified")
|
|
160
|
+
});
|
|
161
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
162
|
+
className: "group/relations flex min-h-7 min-w-0 items-center gap-1 px-1",
|
|
163
|
+
children: [value.slice(0, 1).map((id) => /* @__PURE__ */ jsx("div", {
|
|
164
|
+
className: "flex min-w-0 overflow-hidden",
|
|
165
|
+
children: /* @__PURE__ */ jsx(ContactLink, {
|
|
166
|
+
contentType: kind === "company" ? "core:company" : "core:customer",
|
|
167
|
+
contentId: id,
|
|
168
|
+
contacts
|
|
169
|
+
})
|
|
170
|
+
}, id)), control]
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
export { ContactRelationInput, SelectContactContent };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MemberQueries } from "../pickers/members.js";
|
|
2
|
+
/** The content type core's side panel opens team members as. */
|
|
3
|
+
export declare const MEMBER_CONTENT_TYPE = "core:user";
|
|
4
|
+
/**
|
|
5
|
+
* A team member as a chip: their avatar and name. Inside erxes, clicking it opens the member in
|
|
6
|
+
* core's side panel beside the page (their detail and what they did); elsewhere it is only
|
|
7
|
+
* the name. `members` is `memberQueries` from `@erxes/core-contract/client`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MemberLink: ({ memberId, members }: {
|
|
10
|
+
memberId: string;
|
|
11
|
+
members: MemberQueries;
|
|
12
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { memberName, useMembersById } from "../pickers/members.js";
|
|
2
|
+
import { RecordChip } from "./RecordChip.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/modules/records/MemberLink.tsx
|
|
5
|
+
/** The content type core's side panel opens team members as. */
|
|
6
|
+
const MEMBER_CONTENT_TYPE = "core:user";
|
|
7
|
+
/**
|
|
8
|
+
* A team member as a chip: their avatar and name. Inside erxes, clicking it opens the member in
|
|
9
|
+
* core's side panel beside the page (their detail and what they did); elsewhere it is only
|
|
10
|
+
* the name. `members` is `memberQueries` from `@erxes/core-contract/client`.
|
|
11
|
+
*/
|
|
12
|
+
const MemberLink = ({ memberId, members }) => {
|
|
13
|
+
const member = useMembersById([memberId], members).get(memberId);
|
|
14
|
+
return /* @__PURE__ */ jsx(RecordChip, {
|
|
15
|
+
record: {
|
|
16
|
+
contentType: MEMBER_CONTENT_TYPE,
|
|
17
|
+
contentId: memberId
|
|
18
|
+
},
|
|
19
|
+
name: member ? memberName(member) : "",
|
|
20
|
+
avatarUrl: member?.avatarUrl,
|
|
21
|
+
loading: !member,
|
|
22
|
+
failed: false
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export { MEMBER_CONTENT_TYPE, MemberLink };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RecordRef } from "./openRecord.js";
|
|
2
|
+
/**
|
|
3
|
+
* A record as a chip: its avatar and name. Inside erxes, clicking it opens the record in core's
|
|
4
|
+
* side panel beside the page; elsewhere it is only the name. A record that can't be read says
|
|
5
|
+
* why, and still opens to show it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RecordChip: ({ record, name, avatarUrl, loading, failed }: {
|
|
8
|
+
record: RecordRef;
|
|
9
|
+
name: string;
|
|
10
|
+
avatarUrl: string | null | undefined;
|
|
11
|
+
loading: boolean;
|
|
12
|
+
failed: boolean;
|
|
13
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Avatar } from "../../components/avatar.js";
|
|
2
|
+
import { Skeleton } from "../../components/skeleton.js";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
import { readImage } from "../../utils/core.js";
|
|
5
|
+
import { useOpenRecord } from "./openRecord.js";
|
|
6
|
+
import { IconArrowUpRight } from "@tabler/icons-react";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/modules/records/RecordChip.tsx
|
|
9
|
+
const CHIP = "group/chip inline-flex h-6 max-w-full items-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium";
|
|
10
|
+
/**
|
|
11
|
+
* A record as a chip: its avatar and name. Inside erxes, clicking it opens the record in core's
|
|
12
|
+
* side panel beside the page; elsewhere it is only the name. A record that can't be read says
|
|
13
|
+
* why, and still opens to show it.
|
|
14
|
+
*/
|
|
15
|
+
const RecordChip = ({ record, name, avatarUrl, loading, failed }) => {
|
|
16
|
+
const { open, canOpen } = useOpenRecord();
|
|
17
|
+
if (loading) return /* @__PURE__ */ jsx(Skeleton, {
|
|
18
|
+
radius: "sm",
|
|
19
|
+
className: "h-5 w-20"
|
|
20
|
+
});
|
|
21
|
+
const face = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Avatar, {
|
|
22
|
+
size: "sm",
|
|
23
|
+
className: "size-4 flex-none",
|
|
24
|
+
children: [/* @__PURE__ */ jsx(Avatar.Image, { src: readImage(avatarUrl ?? void 0) }), /* @__PURE__ */ jsx(Avatar.Fallback, { children: name.charAt(0) })]
|
|
25
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
26
|
+
className: cn("truncate", failed && "text-destructive"),
|
|
27
|
+
children: name
|
|
28
|
+
})] });
|
|
29
|
+
if (!canOpen) return /* @__PURE__ */ jsx("span", {
|
|
30
|
+
title: name,
|
|
31
|
+
className: CHIP,
|
|
32
|
+
children: face
|
|
33
|
+
});
|
|
34
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
35
|
+
type: "button",
|
|
36
|
+
onClick: () => open(record),
|
|
37
|
+
title: name,
|
|
38
|
+
"data-panel-inline": "",
|
|
39
|
+
className: cn(CHIP, "hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),
|
|
40
|
+
children: [face, /* @__PURE__ */ jsx(IconArrowUpRight, {
|
|
41
|
+
className: "size-3 flex-none text-muted-foreground opacity-0 transition-opacity group-hover/chip:opacity-100 group-focus-visible/chip:opacity-100",
|
|
42
|
+
"aria-hidden": "true"
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export { RecordChip };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { UseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
/** What a customer reads as: core's `Customer` has these fields and more. */
|
|
3
|
+
export interface CustomerContact {
|
|
4
|
+
id: string;
|
|
5
|
+
firstName: string | null;
|
|
6
|
+
middleName: string | null;
|
|
7
|
+
lastName: string | null;
|
|
8
|
+
primaryEmail: string | null;
|
|
9
|
+
primaryPhone: string | null;
|
|
10
|
+
avatarUrl: string | null;
|
|
11
|
+
}
|
|
12
|
+
/** What a company reads as: core's `Company` has these fields and more. */
|
|
13
|
+
export interface CompanyContact {
|
|
14
|
+
id: string;
|
|
15
|
+
primaryName: string | null;
|
|
16
|
+
primaryEmail: string | null;
|
|
17
|
+
primaryPhone: string | null;
|
|
18
|
+
avatarUrl: string | null;
|
|
19
|
+
}
|
|
20
|
+
type ContactQuery<T> = UseQueryOptions<T, Error, T>;
|
|
21
|
+
/**
|
|
22
|
+
* Where customers and companies come from, as TanStack query options. erxes-ui knows nothing
|
|
23
|
+
* of core: web and plugin UIs pass `contactQueries` from `@erxes/core-contract/client`.
|
|
24
|
+
*/
|
|
25
|
+
export interface ContactQueries {
|
|
26
|
+
customer: (id: string) => ContactQuery<CustomerContact>;
|
|
27
|
+
company: (id: string) => ContactQuery<CompanyContact>;
|
|
28
|
+
}
|
|
29
|
+
type ContactRows<T> = UseQueryOptions<{
|
|
30
|
+
data: T[];
|
|
31
|
+
}, Error, {
|
|
32
|
+
data: T[];
|
|
33
|
+
}>;
|
|
34
|
+
/** What a contact search asks for: matches, or the contacts with these ids. */
|
|
35
|
+
export interface ContactSearch {
|
|
36
|
+
search?: string;
|
|
37
|
+
ids?: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Where a filter's `customer` and `company` fields search contacts.
|
|
41
|
+
* TanStack query options; in erxes, `contactSearchQueries` from `@erxes/core-contract/client`.
|
|
42
|
+
*/
|
|
43
|
+
export interface ContactSearchQueries {
|
|
44
|
+
customers: (input: ContactSearch) => ContactRows<CustomerContact>;
|
|
45
|
+
companies: (input: ContactSearch) => ContactRows<CompanyContact>;
|
|
46
|
+
}
|
|
47
|
+
/** The customer or company types `ContactLink` shows. */
|
|
48
|
+
export type TContactContentType = 'core:customer' | 'core:company';
|
|
49
|
+
/** A customer's name, else its email or phone. */
|
|
50
|
+
export declare const customerTitle: (customer: Pick<CustomerContact, 'firstName' | 'middleName' | 'lastName' | 'primaryEmail' | 'primaryPhone'>) => string;
|
|
51
|
+
/** A company's name, else its email or phone. */
|
|
52
|
+
export declare const companyTitle: (company: Pick<CompanyContact, 'primaryName' | 'primaryEmail' | 'primaryPhone'>) => string;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/modules/records/contacts.ts
|
|
2
|
+
/** A customer's name, else its email or phone. */
|
|
3
|
+
const customerTitle = (customer) => [
|
|
4
|
+
customer.firstName,
|
|
5
|
+
customer.middleName,
|
|
6
|
+
customer.lastName
|
|
7
|
+
].filter(Boolean).join(" ") || customer.primaryEmail || customer.primaryPhone || "";
|
|
8
|
+
/** A company's name, else its email or phone. */
|
|
9
|
+
const companyTitle = (company) => company.primaryName || company.primaryEmail || company.primaryPhone || "";
|
|
10
|
+
export { companyTitle, customerTitle };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A record the host can open, by `contentType` and `contentId`.
|
|
4
|
+
* The type is `core:customer`, `core:company`, or a plugin's own.
|
|
5
|
+
*/
|
|
6
|
+
export interface RecordRef {
|
|
7
|
+
contentType: string;
|
|
8
|
+
contentId: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Opens a record; `tab` picks the tab it opens on: `detail`, `activity` or one of its type's
|
|
12
|
+
* `tabs` by `value`. A tab the record lacks opens its default.
|
|
13
|
+
*/
|
|
14
|
+
type OpenRecord = (record: RecordRef & {
|
|
15
|
+
tab?: string;
|
|
16
|
+
}) => void;
|
|
17
|
+
/** Opens a draft of a record type, starting with `defaults` (e.g. the stage it was added in). */
|
|
18
|
+
type OpenNewRecord = (contentType: string, defaults?: Record<string, unknown>) => void;
|
|
19
|
+
type DismissRecord = (record: RecordRef) => void;
|
|
20
|
+
/**
|
|
21
|
+
* The host app's way to open records, which `useOpenRecord` calls.
|
|
22
|
+
* Web provides it: beside the page in its side panel, or, inside a record, on top of that
|
|
23
|
+
* record so Back returns to it. erxes-ui is a Module Federation singleton, so every plugin
|
|
24
|
+
* reads the host's.
|
|
25
|
+
*/
|
|
26
|
+
export declare const RecordOpenerProvider: ({ open, openNew, current, dismiss, children }: PropsWithChildren<{
|
|
27
|
+
open: OpenRecord;
|
|
28
|
+
openNew?: OpenNewRecord;
|
|
29
|
+
current?: RecordRef | null;
|
|
30
|
+
dismiss?: DismissRecord;
|
|
31
|
+
}>) => import("react").JSX.Element;
|
|
32
|
+
/**
|
|
33
|
+
* Opens a record, or a new draft, in core's side panel.
|
|
34
|
+
* `const { open, openNew } = useOpenRecord()`: `open({ contentType: 'sales:deal', contentId })`
|
|
35
|
+
* opens a record in core's side panel, the page staying under it, on its default tab, or on
|
|
36
|
+
* the one `tab` names (`open({ contentType: 'hr:employee', contentId, tab: 'leave' })`), and
|
|
37
|
+
* `openNew('sales:deal', { stageId })` opens a draft that becomes the record on Save. Any
|
|
38
|
+
* type core or an installed plugin registers opens (`IUIConfig.recordTypes`). `canOpen` is
|
|
39
|
+
* false outside erxes (a plugin page rendered on its own), where both do nothing.
|
|
40
|
+
*
|
|
41
|
+
* `current` is the record the panel shows now (null when it shows none or a draft), for a list
|
|
42
|
+
* that marks it or steps to the next (j/k). `dismiss(record)` takes a record out of the panel,
|
|
43
|
+
* shown or behind Back, e.g. one the list just deleted. Inside a record, `useRecordPanel`.
|
|
44
|
+
*/
|
|
45
|
+
export declare const useOpenRecord: () => {
|
|
46
|
+
open: OpenRecord;
|
|
47
|
+
openNew: OpenNewRecord;
|
|
48
|
+
current: RecordRef | null;
|
|
49
|
+
dismiss: DismissRecord;
|
|
50
|
+
canOpen: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* What a record shown in core's panel, or on its own page, can do to it. Core's own tabs are
|
|
54
|
+
* `detail` and `activity`; a type's `tabs` use their `value`.
|
|
55
|
+
*/
|
|
56
|
+
export interface RecordPanelControls {
|
|
57
|
+
record: RecordRef;
|
|
58
|
+
/** The tab shown; empty is the record's default. */
|
|
59
|
+
tab: string;
|
|
60
|
+
/** Shows a tab: an Actions menu item whose form opens on Detail picks `detail` first. */
|
|
61
|
+
setTab: (tab: string) => void;
|
|
62
|
+
/** Closes the panel; on a record's own page, goes back to its list. */
|
|
63
|
+
close: () => void;
|
|
64
|
+
/** Takes this record out, e.g. after deleting it: back to the record under it, else closed. */
|
|
65
|
+
dismiss: () => void;
|
|
66
|
+
/** Puts another record in this one's place, Back unchanged: a request accepted as a task. */
|
|
67
|
+
replace: (next: RecordRef) => void;
|
|
68
|
+
}
|
|
69
|
+
/** Web gives each record it shows its controls. */
|
|
70
|
+
export declare const RecordPanelProvider: import("react").Context<RecordPanelControls | null>;
|
|
71
|
+
/**
|
|
72
|
+
* The record a slot is in, and what the slot can do to it.
|
|
73
|
+
* Any slot (`Title`, `Actions`, `Detail`, a tab, a relation tab): `const panel = useRecordPanel()`, then `panel?.dismiss()` after a delete,
|
|
74
|
+
* `panel?.replace({ contentType: 'tasks:task', contentId })`, `panel?.setTab('detail')`.
|
|
75
|
+
* Null outside a record (a plugin page on its own).
|
|
76
|
+
*/
|
|
77
|
+
export declare const useRecordPanel: () => RecordPanelControls | null;
|
|
78
|
+
/** A `RecordPage`'s record, and the list it goes back to. */
|
|
79
|
+
export interface RecordPageProps extends RecordRef {
|
|
80
|
+
/**
|
|
81
|
+
* The list closing or deleting the record goes back to, e.g. its team's tasks; without it, the
|
|
82
|
+
* plugin's first page. Pass it once the record is known.
|
|
83
|
+
*/
|
|
84
|
+
listPath?: string;
|
|
85
|
+
}
|
|
86
|
+
/** Web registers how a record draws on its own page. */
|
|
87
|
+
export declare const setRecordPage: (component: import("react").ComponentType<RecordPageProps> | null) => void;
|
|
88
|
+
/**
|
|
89
|
+
* A record on its own page, as core draws a customer's.
|
|
90
|
+
* The record's View at full size, under the page header, with Back to its list. A plugin
|
|
91
|
+
* routes its record type's `detailPath` to `<RecordPage contentType="sales:deal" contentId={id} listPath="/sales/deals" />`.
|
|
92
|
+
*/
|
|
93
|
+
export declare const RecordPage: (props: RecordPageProps) => import("react").JSX.Element | null;
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { hostComponent } from "../../utils/host-component.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, use, useMemo } from "react";
|
|
4
|
+
// src/modules/records/openRecord.tsx
|
|
5
|
+
const RecordOpenerContext = createContext(null);
|
|
6
|
+
const ignore = () => void 0;
|
|
7
|
+
/**
|
|
8
|
+
* The host app's way to open records, which `useOpenRecord` calls.
|
|
9
|
+
* Web provides it: beside the page in its side panel, or, inside a record, on top of that
|
|
10
|
+
* record so Back returns to it. erxes-ui is a Module Federation singleton, so every plugin
|
|
11
|
+
* reads the host's.
|
|
12
|
+
*/
|
|
13
|
+
const RecordOpenerProvider = ({ open, openNew = ignore, current = null, dismiss = ignore, children }) => {
|
|
14
|
+
const opener = useMemo(() => ({
|
|
15
|
+
open,
|
|
16
|
+
openNew,
|
|
17
|
+
current,
|
|
18
|
+
dismiss
|
|
19
|
+
}), [
|
|
20
|
+
open,
|
|
21
|
+
openNew,
|
|
22
|
+
current,
|
|
23
|
+
dismiss
|
|
24
|
+
]);
|
|
25
|
+
return /* @__PURE__ */ jsx(RecordOpenerContext, {
|
|
26
|
+
value: opener,
|
|
27
|
+
children
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Opens a record, or a new draft, in core's side panel.
|
|
32
|
+
* `const { open, openNew } = useOpenRecord()`: `open({ contentType: 'sales:deal', contentId })`
|
|
33
|
+
* opens a record in core's side panel, the page staying under it, on its default tab, or on
|
|
34
|
+
* the one `tab` names (`open({ contentType: 'hr:employee', contentId, tab: 'leave' })`), and
|
|
35
|
+
* `openNew('sales:deal', { stageId })` opens a draft that becomes the record on Save. Any
|
|
36
|
+
* type core or an installed plugin registers opens (`IUIConfig.recordTypes`). `canOpen` is
|
|
37
|
+
* false outside erxes (a plugin page rendered on its own), where both do nothing.
|
|
38
|
+
*
|
|
39
|
+
* `current` is the record the panel shows now (null when it shows none or a draft), for a list
|
|
40
|
+
* that marks it or steps to the next (j/k). `dismiss(record)` takes a record out of the panel,
|
|
41
|
+
* shown or behind Back, e.g. one the list just deleted. Inside a record, `useRecordPanel`.
|
|
42
|
+
*/
|
|
43
|
+
const useOpenRecord = () => {
|
|
44
|
+
const opener = use(RecordOpenerContext);
|
|
45
|
+
return {
|
|
46
|
+
open: opener?.open ?? ignore,
|
|
47
|
+
openNew: opener?.openNew ?? ignore,
|
|
48
|
+
current: opener?.current ?? null,
|
|
49
|
+
dismiss: opener?.dismiss ?? ignore,
|
|
50
|
+
canOpen: opener !== null
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const RecordPanelContext = createContext(null);
|
|
54
|
+
/** Web gives each record it shows its controls. */
|
|
55
|
+
const RecordPanelProvider = RecordPanelContext;
|
|
56
|
+
/**
|
|
57
|
+
* The record a slot is in, and what the slot can do to it.
|
|
58
|
+
* Any slot (`Title`, `Actions`, `Detail`, a tab, a relation tab): `const panel = useRecordPanel()`, then `panel?.dismiss()` after a delete,
|
|
59
|
+
* `panel?.replace({ contentType: 'tasks:task', contentId })`, `panel?.setTab('detail')`.
|
|
60
|
+
* Null outside a record (a plugin page on its own).
|
|
61
|
+
*/
|
|
62
|
+
const useRecordPanel = () => use(RecordPanelContext);
|
|
63
|
+
const page = hostComponent();
|
|
64
|
+
/** Web registers how a record draws on its own page. */
|
|
65
|
+
const setRecordPage = page.set;
|
|
66
|
+
/**
|
|
67
|
+
* A record on its own page, as core draws a customer's.
|
|
68
|
+
* The record's View at full size, under the page header, with Back to its list. A plugin
|
|
69
|
+
* routes its record type's `detailPath` to `<RecordPage contentType="sales:deal" contentId={id} listPath="/sales/deals" />`.
|
|
70
|
+
*/
|
|
71
|
+
const RecordPage = page.Host;
|
|
72
|
+
export { RecordOpenerProvider, RecordPage, RecordPanelProvider, setRecordPage, useOpenRecord, useRecordPanel };
|