@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,171 @@
|
|
|
1
|
+
import { Button } from "../../components/button.js";
|
|
2
|
+
import { Popover } from "../../components/popover.js";
|
|
3
|
+
import { Select } from "../../components/select.js";
|
|
4
|
+
import { useItemKeys } from "../../hooks/use-item-keys.js";
|
|
5
|
+
import { NO_VALUE, isRule } from "./conditions.js";
|
|
6
|
+
import { isFilterRule, ruleFor } from "./filterRule.js";
|
|
7
|
+
import { FieldPicker } from "./FieldPicker.js";
|
|
8
|
+
import { RemoveButton, RuleRow } from "./RuleRow.js";
|
|
9
|
+
import { IconBraces, IconPlus } from "@tabler/icons-react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import { useTranslation } from "react-i18next";
|
|
13
|
+
// src/modules/conditions/ConditionsEditor.tsx
|
|
14
|
+
/** "Where" first; the second row picks "and" or "or" for the group; the rest repeat it. */
|
|
15
|
+
const Conjunction = ({ index, group, disabled, onChange }) => {
|
|
16
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
17
|
+
const word = group.match === "all" ? t("and", "And") : t("or", "Or");
|
|
18
|
+
if (index === 0) return /* @__PURE__ */ jsx("span", {
|
|
19
|
+
className: "px-2 text-sm text-muted-foreground",
|
|
20
|
+
children: t("where", "Where")
|
|
21
|
+
});
|
|
22
|
+
if (index > 1 || disabled) return /* @__PURE__ */ jsx("span", {
|
|
23
|
+
className: "px-2 text-sm text-muted-foreground",
|
|
24
|
+
children: word
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ jsxs(Select, {
|
|
27
|
+
value: group.match,
|
|
28
|
+
onValueChange: (match) => onChange({
|
|
29
|
+
...group,
|
|
30
|
+
match: match === "any" ? "any" : "all"
|
|
31
|
+
}),
|
|
32
|
+
children: [/* @__PURE__ */ jsx(Select.Trigger, {
|
|
33
|
+
className: "h-8 w-full",
|
|
34
|
+
"aria-label": t("conjunction", "And or or"),
|
|
35
|
+
children: /* @__PURE__ */ jsx(Select.Value, { children: word })
|
|
36
|
+
}), /* @__PURE__ */ jsxs(Select.Content, { children: [/* @__PURE__ */ jsx(Select.Item, {
|
|
37
|
+
value: "all",
|
|
38
|
+
children: t("and", "And")
|
|
39
|
+
}), /* @__PURE__ */ jsx(Select.Item, {
|
|
40
|
+
value: "any",
|
|
41
|
+
children: t("or", "Or")
|
|
42
|
+
})] })]
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
/** "Add filter rule" opens the field picker; "Add filter group", while groups may still nest. */
|
|
46
|
+
const AddButtons = ({ fields, disabled, customPath, canGroup, onAdd }) => {
|
|
47
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
48
|
+
const [open, setOpen] = useState(false);
|
|
49
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
50
|
+
className: "flex gap-1",
|
|
51
|
+
children: [/* @__PURE__ */ jsxs(Popover, {
|
|
52
|
+
open,
|
|
53
|
+
onOpenChange: setOpen,
|
|
54
|
+
children: [/* @__PURE__ */ jsxs(Popover.Trigger, {
|
|
55
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
56
|
+
size: "sm",
|
|
57
|
+
variant: "ghost",
|
|
58
|
+
tone: "muted",
|
|
59
|
+
disabled
|
|
60
|
+
}),
|
|
61
|
+
children: [/* @__PURE__ */ jsx(IconPlus, {}), t("add-rule", "Add filter rule")]
|
|
62
|
+
}), /* @__PURE__ */ jsx(Popover.Content, {
|
|
63
|
+
variant: "flush",
|
|
64
|
+
align: "start",
|
|
65
|
+
className: "w-72",
|
|
66
|
+
children: /* @__PURE__ */ jsx(FieldPicker, {
|
|
67
|
+
fields,
|
|
68
|
+
customPath,
|
|
69
|
+
onSelect: (field) => {
|
|
70
|
+
setOpen(false);
|
|
71
|
+
onAdd(ruleFor(field));
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
})]
|
|
75
|
+
}), canGroup && /* @__PURE__ */ jsxs(Button, {
|
|
76
|
+
size: "sm",
|
|
77
|
+
variant: "ghost",
|
|
78
|
+
tone: "muted",
|
|
79
|
+
disabled,
|
|
80
|
+
onClick: () => onAdd({
|
|
81
|
+
match: "all",
|
|
82
|
+
rules: []
|
|
83
|
+
}),
|
|
84
|
+
children: [/* @__PURE__ */ jsx(IconBraces, {}), t("add-group", "Add filter group")]
|
|
85
|
+
})]
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
/** One group: its rows and nested groups (three levels in all), then the add buttons. */
|
|
89
|
+
const GroupEditor = ({ group, onChange, depth, ...shared }) => {
|
|
90
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
91
|
+
const keys = useItemKeys(group.rules.length);
|
|
92
|
+
const [fresh, setFresh] = useState(null);
|
|
93
|
+
const update = (index, node) => onChange({
|
|
94
|
+
...group,
|
|
95
|
+
rules: group.rules.map((item, at) => at === index ? node : item)
|
|
96
|
+
});
|
|
97
|
+
const remove = (index) => {
|
|
98
|
+
keys.removed(index);
|
|
99
|
+
onChange({
|
|
100
|
+
...group,
|
|
101
|
+
rules: group.rules.filter((_, at) => at !== index)
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const lead = (index) => /* @__PURE__ */ jsx(Conjunction, {
|
|
105
|
+
index,
|
|
106
|
+
group,
|
|
107
|
+
disabled: shared.disabled,
|
|
108
|
+
onChange
|
|
109
|
+
});
|
|
110
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
111
|
+
className: "flex flex-col gap-1.5",
|
|
112
|
+
children: [group.rules.map((node, index) => isFilterRule(node) ? /* @__PURE__ */ jsx(RuleRow, {
|
|
113
|
+
...shared,
|
|
114
|
+
rule: node,
|
|
115
|
+
lead: lead(index),
|
|
116
|
+
fresh: fresh === index,
|
|
117
|
+
onChange: (next) => update(index, next),
|
|
118
|
+
onRemove: () => remove(index)
|
|
119
|
+
}, keys.keyAt(index)) : /* @__PURE__ */ jsxs("div", {
|
|
120
|
+
className: "grid grid-cols-condition items-start gap-1.5",
|
|
121
|
+
children: [
|
|
122
|
+
lead(index),
|
|
123
|
+
/* @__PURE__ */ jsx("div", {
|
|
124
|
+
className: "col-span-3 rounded-md border bg-muted/40 p-2",
|
|
125
|
+
children: /* @__PURE__ */ jsx(GroupEditor, {
|
|
126
|
+
...shared,
|
|
127
|
+
group: node,
|
|
128
|
+
depth: depth + 1,
|
|
129
|
+
onChange: (next) => update(index, next)
|
|
130
|
+
})
|
|
131
|
+
}),
|
|
132
|
+
/* @__PURE__ */ jsx(RemoveButton, {
|
|
133
|
+
label: t("remove-group", "Remove group"),
|
|
134
|
+
disabled: shared.disabled,
|
|
135
|
+
onRemove: () => remove(index)
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
}, keys.keyAt(index))), /* @__PURE__ */ jsx(AddButtons, {
|
|
139
|
+
fields: shared.fields,
|
|
140
|
+
disabled: shared.disabled,
|
|
141
|
+
customPath: shared.customPath,
|
|
142
|
+
canGroup: depth < 2,
|
|
143
|
+
onAdd: (node) => {
|
|
144
|
+
keys.added();
|
|
145
|
+
setFresh(isRule(node) && !NO_VALUE.has(node.op) ? group.rules.length : null);
|
|
146
|
+
onChange({
|
|
147
|
+
...group,
|
|
148
|
+
rules: [...group.rules, node]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
})]
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Conditions as rows "Where <field> <operator> <value>", joined by "and" or "or", with nested
|
|
156
|
+
* groups, on `fields`; `members` and `tags` feed their pickers. Fields and values pick from the
|
|
157
|
+
* same menus as a list's filter chips. With `customPath`, a typed path is a field too.
|
|
158
|
+
*/
|
|
159
|
+
const ConditionsEditor = ({ value, onChange, disabled, fields, customPath, ...lookups }) => /* @__PURE__ */ jsx(GroupEditor, {
|
|
160
|
+
group: value ?? {
|
|
161
|
+
match: "all",
|
|
162
|
+
rules: []
|
|
163
|
+
},
|
|
164
|
+
fields,
|
|
165
|
+
lookups,
|
|
166
|
+
disabled,
|
|
167
|
+
customPath,
|
|
168
|
+
depth: 0,
|
|
169
|
+
onChange: (next) => onChange(next.rules.length ? next : void 0)
|
|
170
|
+
});
|
|
171
|
+
export { ConditionsEditor };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TConditionRule } from "./conditions.js";
|
|
2
|
+
import { ValueEditorProps } from "./ValueEditor.js";
|
|
3
|
+
/** "In the last 30 days": the usual spans in one pick, or any amount and unit. */
|
|
4
|
+
export declare const RelativeEditor: (props: Omit<ValueEditorProps, 'rule' | 'field' | 'lookups'> & {
|
|
5
|
+
rule: TConditionRule;
|
|
6
|
+
}) => import("react").JSX.Element;
|
|
7
|
+
/** A day (before, on, after) or a range of days, on erxes-ui's date picker. */
|
|
8
|
+
export declare const DayEditor: ({ rule, onChange, onDone }: ValueEditorProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { Combobox } from "../../components/combobox.js";
|
|
2
|
+
import { Command } from "../../components/command.js";
|
|
3
|
+
import { DatePicker } from "../../components/date-picker.js";
|
|
4
|
+
import { Select } from "../../components/select.js";
|
|
5
|
+
import { toIsoDay } from "../../lib/format.js";
|
|
6
|
+
import { oneOf, textOf } from "../../lib/text.js";
|
|
7
|
+
import { RELATIVE_UNITS, isRule } from "./conditions.js";
|
|
8
|
+
import { between, valuesBetween } from "./filterRule.js";
|
|
9
|
+
import { useSpanText } from "./filterText.js";
|
|
10
|
+
import { TypedInput } from "./TypedInput.js";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { useTranslation } from "react-i18next";
|
|
14
|
+
// src/modules/conditions/DateEditors.tsx
|
|
15
|
+
const Span = z.object({
|
|
16
|
+
amount: z.number().optional(),
|
|
17
|
+
unit: z.enum(RELATIVE_UNITS).optional()
|
|
18
|
+
});
|
|
19
|
+
/** Relative dates in one pick, by operator; they stay current in a saved view. */
|
|
20
|
+
const PRESETS = {
|
|
21
|
+
within_last: [
|
|
22
|
+
{
|
|
23
|
+
amount: 1,
|
|
24
|
+
unit: "days"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
amount: 7,
|
|
28
|
+
unit: "days"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
amount: 30,
|
|
32
|
+
unit: "days"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
amount: 90,
|
|
36
|
+
unit: "days"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
amount: 12,
|
|
40
|
+
unit: "months"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
within_next: [
|
|
44
|
+
{
|
|
45
|
+
amount: 7,
|
|
46
|
+
unit: "days"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
amount: 30,
|
|
50
|
+
unit: "days"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
amount: 90,
|
|
54
|
+
unit: "days"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
more_than_ago: [
|
|
58
|
+
{
|
|
59
|
+
amount: 30,
|
|
60
|
+
unit: "days"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
amount: 90,
|
|
64
|
+
unit: "days"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
amount: 12,
|
|
68
|
+
unit: "months"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
anniversary_within: [{
|
|
72
|
+
amount: 7,
|
|
73
|
+
unit: "days"
|
|
74
|
+
}, {
|
|
75
|
+
amount: 30,
|
|
76
|
+
unit: "days"
|
|
77
|
+
}]
|
|
78
|
+
};
|
|
79
|
+
/** The amount and unit of a span, typed. */
|
|
80
|
+
const SpanInput = ({ rule, onChange, onDone }) => {
|
|
81
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
82
|
+
const current = Span.safeParse(rule.value).data ?? {};
|
|
83
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
84
|
+
className: "flex items-center gap-1.5 border-t p-2",
|
|
85
|
+
children: [/* @__PURE__ */ jsx(TypedInput, {
|
|
86
|
+
type: "number",
|
|
87
|
+
min: 0,
|
|
88
|
+
className: "h-8 w-20",
|
|
89
|
+
"aria-label": t("amount", "Amount"),
|
|
90
|
+
initial: textOf(current.amount),
|
|
91
|
+
onCommit: (text) => onChange({
|
|
92
|
+
...rule,
|
|
93
|
+
value: {
|
|
94
|
+
unit: current.unit ?? "days",
|
|
95
|
+
amount: Math.max(0, Math.round(Number(text) || 0))
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
onEnter: onDone
|
|
99
|
+
}), rule.op === "anniversary_within" ? /* @__PURE__ */ jsx("span", {
|
|
100
|
+
className: "text-sm text-muted-foreground",
|
|
101
|
+
children: t("units.days", "days")
|
|
102
|
+
}) : /* @__PURE__ */ jsxs(Select, {
|
|
103
|
+
value: current.unit ?? "days",
|
|
104
|
+
onValueChange: (next) => {
|
|
105
|
+
const unit = oneOf(RELATIVE_UNITS, next);
|
|
106
|
+
if (unit) onChange({
|
|
107
|
+
...rule,
|
|
108
|
+
value: {
|
|
109
|
+
amount: current.amount ?? 0,
|
|
110
|
+
unit
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
children: [/* @__PURE__ */ jsx(Select.Trigger, {
|
|
115
|
+
className: "h-8 flex-1",
|
|
116
|
+
"aria-label": t("unit-label", "Unit"),
|
|
117
|
+
children: /* @__PURE__ */ jsx(Select.Value, { children: t(`units.${current.unit ?? "days"}`, current.unit ?? "days") })
|
|
118
|
+
}), /* @__PURE__ */ jsx(Select.Content, { children: RELATIVE_UNITS.map((unit) => /* @__PURE__ */ jsx(Select.Item, {
|
|
119
|
+
value: unit,
|
|
120
|
+
children: t(`units.${unit}`, unit)
|
|
121
|
+
}, unit)) })]
|
|
122
|
+
})]
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
/** "In the last 30 days": the usual spans in one pick, or any amount and unit. */
|
|
126
|
+
const RelativeEditor = (props) => {
|
|
127
|
+
const { rule, onChange, onDone } = props;
|
|
128
|
+
const spanText = useSpanText();
|
|
129
|
+
const current = Span.safeParse(rule.value).data ?? {};
|
|
130
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
131
|
+
className: "flex flex-col",
|
|
132
|
+
children: [/* @__PURE__ */ jsx(Command, {
|
|
133
|
+
className: "h-auto",
|
|
134
|
+
children: /* @__PURE__ */ jsx(Command.List, { children: (PRESETS[rule.op] ?? []).map((span) => /* @__PURE__ */ jsxs(Command.Item, {
|
|
135
|
+
value: `${span.amount}-${span.unit}`,
|
|
136
|
+
onSelect: () => {
|
|
137
|
+
onChange({
|
|
138
|
+
...rule,
|
|
139
|
+
value: span
|
|
140
|
+
});
|
|
141
|
+
onDone?.();
|
|
142
|
+
},
|
|
143
|
+
children: [spanText(span), /* @__PURE__ */ jsx(Combobox.Check, { checked: current.amount === span.amount && current.unit === span.unit })]
|
|
144
|
+
}, `${span.amount}-${span.unit}`)) })
|
|
145
|
+
}), /* @__PURE__ */ jsx(SpanInput, { ...props })]
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
const dayOf = (value) => {
|
|
149
|
+
const text = textOf(value);
|
|
150
|
+
return /^\d{4}-\d{2}-\d{2}/.test(text) ? text.slice(0, 10) : void 0;
|
|
151
|
+
};
|
|
152
|
+
/** A day (before, on, after) or a range of days, on erxes-ui's date picker. */
|
|
153
|
+
const DayEditor = ({ rule, onChange, onDone }) => {
|
|
154
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
155
|
+
if (isRule(rule)) return /* @__PURE__ */ jsx(DatePicker, {
|
|
156
|
+
inline: true,
|
|
157
|
+
mode: "single",
|
|
158
|
+
value: dayOf(rule.value),
|
|
159
|
+
placeholder: t("pick-day", "Pick a day"),
|
|
160
|
+
clearable: false,
|
|
161
|
+
onChange: (date) => {
|
|
162
|
+
if (!(date instanceof Date)) return;
|
|
163
|
+
onChange({
|
|
164
|
+
...rule,
|
|
165
|
+
value: toIsoDay(date)
|
|
166
|
+
});
|
|
167
|
+
onDone?.();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
const [from, to] = valuesBetween(rule).map(dayOf);
|
|
171
|
+
const path = rule.rules[0].path;
|
|
172
|
+
return /* @__PURE__ */ jsx(DatePicker, {
|
|
173
|
+
inline: true,
|
|
174
|
+
mode: "range",
|
|
175
|
+
value: {
|
|
176
|
+
from,
|
|
177
|
+
to
|
|
178
|
+
},
|
|
179
|
+
clearable: false,
|
|
180
|
+
onChange: (range) => {
|
|
181
|
+
if (!range || range instanceof Date || Array.isArray(range)) return;
|
|
182
|
+
const { from: start, to: end } = range;
|
|
183
|
+
onChange(between(path, start && toIsoDay(start), end && toIsoDay(end)));
|
|
184
|
+
if (start && end) onDone?.();
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
export { DayEditor, RelativeEditor };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TConditionField } from "./conditions.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* The searchable list of fields, grouped under headings with each field's icon; what every
|
|
5
|
+
* filter and condition editor picks a field from. `children` are rows above the fields (search,
|
|
6
|
+
* the advanced filter). With `customPath`, a typed path (`event.payload.amount`) is a choice too.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FieldPicker: ({ fields, value, onSelect, children, customPath, loading, error }: {
|
|
9
|
+
fields: TConditionField[];
|
|
10
|
+
/** The path picked now; it shows a check. */
|
|
11
|
+
value?: string;
|
|
12
|
+
onSelect: (field: TConditionField) => void;
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
customPath?: boolean;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
error?: Error | null;
|
|
17
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Combobox } from "../../components/combobox.js";
|
|
2
|
+
import { Command } from "../../components/command.js";
|
|
3
|
+
import { FieldIcon } from "./fieldIcons.js";
|
|
4
|
+
import { IconCode } from "@tabler/icons-react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { useTranslation } from "react-i18next";
|
|
8
|
+
// src/modules/conditions/FieldPicker.tsx
|
|
9
|
+
/** Core's own groups, in the order the picker lists them; any other (a plugin's) follows. */
|
|
10
|
+
const GROUPS = {
|
|
11
|
+
fields: "Fields",
|
|
12
|
+
lead: "Lead",
|
|
13
|
+
company: "Company",
|
|
14
|
+
activity: "Activity",
|
|
15
|
+
custom: "Properties"
|
|
16
|
+
};
|
|
17
|
+
const ORDER = Object.keys(GROUPS);
|
|
18
|
+
/** A heading per group, and one per `groupLabel` (each plugin's fields under its title). */
|
|
19
|
+
const groupOf = (field) => field.groupLabel ? `label:${field.groupLabel}` : field.group ?? "fields";
|
|
20
|
+
const rank = (group) => {
|
|
21
|
+
const at = ORDER.indexOf(group);
|
|
22
|
+
return at < 0 ? ORDER.length : at;
|
|
23
|
+
};
|
|
24
|
+
/** The groups in the picker's order, each with its heading: the fields' `groupLabel`, else its name. */
|
|
25
|
+
const useGroups = (fields) => {
|
|
26
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
27
|
+
return [...new Set(fields.map(groupOf))].toSorted((a, b) => rank(a) - rank(b)).map((group) => {
|
|
28
|
+
const inGroup = fields.filter((field) => groupOf(field) === group);
|
|
29
|
+
return {
|
|
30
|
+
group,
|
|
31
|
+
heading: inGroup[0]?.groupLabel ?? t(`group.${group}`, GROUPS[group] ?? group),
|
|
32
|
+
fields: inGroup
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
/** A path typed by hand: automations reach event payloads and step outputs the catalog lacks. */
|
|
37
|
+
const PATH = /^(event|subject|steps|run)(\.[A-Za-z0-9_-]+)+$/;
|
|
38
|
+
/**
|
|
39
|
+
* The searchable list of fields, grouped under headings with each field's icon; what every
|
|
40
|
+
* filter and condition editor picks a field from. `children` are rows above the fields (search,
|
|
41
|
+
* the advanced filter). With `customPath`, a typed path (`event.payload.amount`) is a choice too.
|
|
42
|
+
*/
|
|
43
|
+
const FieldPicker = ({ fields, value, onSelect, children, customPath, loading, error }) => {
|
|
44
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
45
|
+
const [search, setSearch] = useState("");
|
|
46
|
+
const groups = useGroups(fields);
|
|
47
|
+
const typed = search.trim();
|
|
48
|
+
return /* @__PURE__ */ jsxs(Command, { children: [/* @__PURE__ */ jsx(Command.Input, {
|
|
49
|
+
value: search,
|
|
50
|
+
onValueChange: setSearch,
|
|
51
|
+
placeholder: customPath ? t("field-or-path", "Field or path…") : t("add", "Add filter…"),
|
|
52
|
+
focusOnMount: true
|
|
53
|
+
}), /* @__PURE__ */ jsxs(Command.List, {
|
|
54
|
+
className: "max-h-popup",
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ jsx(Command.Empty, { children: t("no-match", "No field matches") }),
|
|
57
|
+
children,
|
|
58
|
+
loading && /* @__PURE__ */ jsx("p", {
|
|
59
|
+
className: "px-2 py-1.5 text-xs text-muted-foreground",
|
|
60
|
+
children: t("loading", "Loading fields…")
|
|
61
|
+
}),
|
|
62
|
+
error && /* @__PURE__ */ jsx("p", {
|
|
63
|
+
role: "alert",
|
|
64
|
+
className: "px-2 py-1.5 text-xs text-destructive",
|
|
65
|
+
children: error.message
|
|
66
|
+
}),
|
|
67
|
+
customPath && PATH.test(typed) && !fields.some((field) => field.path === typed) && /* @__PURE__ */ jsxs(Command.Item, {
|
|
68
|
+
value: `path:${typed}`,
|
|
69
|
+
keywords: [typed],
|
|
70
|
+
onSelect: () => onSelect({
|
|
71
|
+
path: typed,
|
|
72
|
+
label: typed,
|
|
73
|
+
type: "text"
|
|
74
|
+
}),
|
|
75
|
+
children: [/* @__PURE__ */ jsx(IconCode, {}), /* @__PURE__ */ jsx("span", {
|
|
76
|
+
className: "truncate font-mono text-xs",
|
|
77
|
+
children: typed
|
|
78
|
+
})]
|
|
79
|
+
}),
|
|
80
|
+
groups.map((group) => /* @__PURE__ */ jsx(Command.Group, {
|
|
81
|
+
heading: group.heading,
|
|
82
|
+
children: group.fields.map((field) => /* @__PURE__ */ jsxs(Command.Item, {
|
|
83
|
+
value: field.path,
|
|
84
|
+
keywords: [field.label, group.heading],
|
|
85
|
+
onSelect: () => onSelect(field),
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ jsx(FieldIcon, { field }),
|
|
88
|
+
/* @__PURE__ */ jsx("span", {
|
|
89
|
+
className: "truncate",
|
|
90
|
+
children: field.label
|
|
91
|
+
}),
|
|
92
|
+
/* @__PURE__ */ jsx(Combobox.Check, { checked: field.path === value })
|
|
93
|
+
]
|
|
94
|
+
}, field.path))
|
|
95
|
+
}, group.group))
|
|
96
|
+
]
|
|
97
|
+
})] });
|
|
98
|
+
};
|
|
99
|
+
export { FieldPicker };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConditionsEditor as ConditionsEditor$1 } from "./ConditionsEditor.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
declare const Editor: import("react").LazyExoticComponent<typeof ConditionsEditor$1>;
|
|
4
|
+
/**
|
|
5
|
+
* Edits a condition group of rules, for automations and advanced filters.
|
|
6
|
+
* It is fetched the first time one renders: erxes-ui is one shared chunk every route loads,
|
|
7
|
+
* and only automations and a list's advanced filter edit conditions.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ConditionsEditor: (props: ComponentProps<typeof Editor>) => import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense, lazy } from "react";
|
|
3
|
+
// src/modules/conditions/LazyConditionsEditor.tsx
|
|
4
|
+
const Editor = lazy(async () => ({ default: (await import("./ConditionsEditor.js")).ConditionsEditor }));
|
|
5
|
+
/**
|
|
6
|
+
* Edits a condition group of rules, for automations and advanced filters.
|
|
7
|
+
* It is fetched the first time one renders: erxes-ui is one shared chunk every route loads,
|
|
8
|
+
* and only automations and a list's advanced filter edit conditions.
|
|
9
|
+
*/
|
|
10
|
+
const ConditionsEditor = (props) => /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(Editor, { ...props }) });
|
|
11
|
+
export { ConditionsEditor };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TConditionField, TConditionLookups } from "./conditions.js";
|
|
2
|
+
import { TFilterOperator, TFilterRule } from "./filterRule.js";
|
|
3
|
+
import { ReactElement } from "react";
|
|
4
|
+
type PartProps = {
|
|
5
|
+
/** The button the part shows; it opens the editor. */
|
|
6
|
+
button: ReactElement;
|
|
7
|
+
open: boolean;
|
|
8
|
+
onOpenChange: (open: boolean) => void;
|
|
9
|
+
};
|
|
10
|
+
/** The rule's field: the grouped, searchable field list. */
|
|
11
|
+
export declare const FieldPart: ({ fields, field, customPath, onSelect, ...part }: PartProps & {
|
|
12
|
+
fields: TConditionField[];
|
|
13
|
+
field: TConditionField;
|
|
14
|
+
customPath?: boolean;
|
|
15
|
+
onSelect: (field: TConditionField) => void;
|
|
16
|
+
}) => import("react").JSX.Element;
|
|
17
|
+
/** The rule's operator: those of the field's type. */
|
|
18
|
+
export declare const OperatorPart: ({ rule, field, onSelect, ...part }: PartProps & {
|
|
19
|
+
rule: TFilterRule;
|
|
20
|
+
field: TConditionField;
|
|
21
|
+
onSelect: (op: TFilterOperator) => void;
|
|
22
|
+
}) => import("react").JSX.Element;
|
|
23
|
+
/** The rule's value, in the editor its operator and type need; a final pick closes it. */
|
|
24
|
+
export declare const ValuePart: ({ rule, field, lookups, onChange, ...part }: PartProps & {
|
|
25
|
+
rule: TFilterRule;
|
|
26
|
+
field: TConditionField;
|
|
27
|
+
lookups: TConditionLookups;
|
|
28
|
+
onChange: (next: TFilterRule) => void;
|
|
29
|
+
}) => import("react").JSX.Element;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Combobox } from "../../components/combobox.js";
|
|
2
|
+
import { Command } from "../../components/command.js";
|
|
3
|
+
import { Popover } from "../../components/popover.js";
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
import { RELATIVE } from "./conditions.js";
|
|
6
|
+
import { opOf, operatorsFor, pathOf } from "./filterRule.js";
|
|
7
|
+
import { FieldPicker } from "./FieldPicker.js";
|
|
8
|
+
import { useOperatorLabel } from "./filterText.js";
|
|
9
|
+
import { ValueEditor } from "./ValueEditor.js";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
// src/modules/conditions/RuleParts.tsx
|
|
12
|
+
/** The operators of the field's type (and the rule's own, should it be another); a pick changes it. */
|
|
13
|
+
const OperatorMenu = ({ rule, field, onSelect }) => {
|
|
14
|
+
const label = useOperatorLabel();
|
|
15
|
+
const current = opOf(rule);
|
|
16
|
+
const ops = operatorsFor(field.type);
|
|
17
|
+
return /* @__PURE__ */ jsx(Command, { children: /* @__PURE__ */ jsx(Command.List, { children: (ops.includes(current) ? ops : [current, ...ops]).map((op) => /* @__PURE__ */ jsxs(Command.Item, {
|
|
18
|
+
value: op,
|
|
19
|
+
onSelect: () => onSelect(op),
|
|
20
|
+
children: [label(op, field.type), /* @__PURE__ */ jsx(Combobox.Check, { checked: op === current })]
|
|
21
|
+
}, op)) }) });
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* One part of a rule (its field, operator or value) as a button that opens its editor in a
|
|
25
|
+
* popover: a chip's segments and the advanced filter's rows both use it.
|
|
26
|
+
*/
|
|
27
|
+
const RulePart = ({ button, open, onOpenChange, className, children }) => /* @__PURE__ */ jsxs(Popover, {
|
|
28
|
+
open,
|
|
29
|
+
onOpenChange,
|
|
30
|
+
children: [/* @__PURE__ */ jsx(Popover.Trigger, { render: button }), /* @__PURE__ */ jsx(Popover.Content, {
|
|
31
|
+
variant: "flush",
|
|
32
|
+
align: "start",
|
|
33
|
+
className,
|
|
34
|
+
children
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
37
|
+
/** The rule's field: the grouped, searchable field list. */
|
|
38
|
+
const FieldPart = ({ fields, field, customPath, onSelect, ...part }) => /* @__PURE__ */ jsx(RulePart, {
|
|
39
|
+
...part,
|
|
40
|
+
className: "w-72",
|
|
41
|
+
children: /* @__PURE__ */ jsx(FieldPicker, {
|
|
42
|
+
fields,
|
|
43
|
+
value: field.path,
|
|
44
|
+
customPath,
|
|
45
|
+
onSelect
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
/** The rule's operator: those of the field's type. */
|
|
49
|
+
const OperatorPart = ({ rule, field, onSelect, ...part }) => /* @__PURE__ */ jsx(RulePart, {
|
|
50
|
+
...part,
|
|
51
|
+
className: "w-56",
|
|
52
|
+
children: /* @__PURE__ */ jsx(OperatorMenu, {
|
|
53
|
+
rule,
|
|
54
|
+
field,
|
|
55
|
+
onSelect
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
/** The rule's value, in the editor its operator and type need; a final pick closes it. */
|
|
59
|
+
const ValuePart = ({ rule, field, lookups, onChange, ...part }) => {
|
|
60
|
+
const op = opOf(rule);
|
|
61
|
+
const calendar = field.type === "date" && !RELATIVE.has(op);
|
|
62
|
+
const typed = field.type === "number" || field.type === "text";
|
|
63
|
+
return /* @__PURE__ */ jsx(RulePart, {
|
|
64
|
+
...part,
|
|
65
|
+
className: calendar ? "w-auto" : "w-72",
|
|
66
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: cn(typed && "p-2"),
|
|
68
|
+
children: /* @__PURE__ */ jsx(ValueEditor, {
|
|
69
|
+
rule,
|
|
70
|
+
field,
|
|
71
|
+
lookups,
|
|
72
|
+
onChange,
|
|
73
|
+
onDone: () => part.onOpenChange(false)
|
|
74
|
+
}, `${pathOf(rule)}:${op}`)
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
export { FieldPart, OperatorPart, ValuePart };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TConditionField, TConditionLookups } from "./conditions.js";
|
|
2
|
+
import { TFilterRule } from "./filterRule.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
export type RowShared = {
|
|
5
|
+
fields: TConditionField[];
|
|
6
|
+
lookups: TConditionLookups;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
customPath?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/** The row's (or a group's) last cell: an X named for what it removes. */
|
|
11
|
+
export declare const RemoveButton: ({ label, disabled, onRemove }: {
|
|
12
|
+
label: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
onRemove: () => void;
|
|
15
|
+
}) => import("react").JSX.Element;
|
|
16
|
+
/**
|
|
17
|
+
* A row of the advanced filter (and an automation's conditions): `lead` ("Where", "And", "Or"),
|
|
18
|
+
* then the field, the operator and the value, each opening its editor, then remove. `fresh`
|
|
19
|
+
* opens the value at once, for a row just added.
|
|
20
|
+
*/
|
|
21
|
+
export declare const RuleRow: ({ rule, fields, lookups, disabled, customPath, lead, fresh, onChange, onRemove }: RowShared & {
|
|
22
|
+
rule: TFilterRule;
|
|
23
|
+
lead: ReactNode;
|
|
24
|
+
fresh: boolean;
|
|
25
|
+
onChange: (next: TFilterRule) => void;
|
|
26
|
+
onRemove: () => void;
|
|
27
|
+
}) => import("react").JSX.Element;
|