@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 { LIST_VALUE, NO_VALUE, RELATIVE, RelativeAmount, isRule } from "./conditions.js";
|
|
2
|
+
// src/modules/conditions/filterRule.ts
|
|
3
|
+
const isBetween = (node) => {
|
|
4
|
+
if (isRule(node) || node.match !== "all" || node.rules.length !== 2) return false;
|
|
5
|
+
const [from, to] = node.rules;
|
|
6
|
+
return !!from && !!to && isRule(from) && isRule(to) && from.op === "gte" && to.op === "lte" && from.path === to.path;
|
|
7
|
+
};
|
|
8
|
+
const isFilterRule = (node) => isRule(node) || isBetween(node);
|
|
9
|
+
const pathOf = (rule) => isRule(rule) ? rule.path : rule.rules[0].path;
|
|
10
|
+
const opOf = (rule) => isRule(rule) ? rule.op : "between";
|
|
11
|
+
const between = (path, from, to) => ({
|
|
12
|
+
match: "all",
|
|
13
|
+
rules: [{
|
|
14
|
+
path,
|
|
15
|
+
op: "gte",
|
|
16
|
+
value: from
|
|
17
|
+
}, {
|
|
18
|
+
path,
|
|
19
|
+
op: "lte",
|
|
20
|
+
value: to
|
|
21
|
+
}]
|
|
22
|
+
});
|
|
23
|
+
/** The operators that fit a field's type, in the order the menus list them. */
|
|
24
|
+
const operatorsFor = (type) => {
|
|
25
|
+
switch (type) {
|
|
26
|
+
case "date": return [
|
|
27
|
+
"within_last",
|
|
28
|
+
"within_next",
|
|
29
|
+
"more_than_ago",
|
|
30
|
+
"eq",
|
|
31
|
+
"lt",
|
|
32
|
+
"gt",
|
|
33
|
+
"between",
|
|
34
|
+
"anniversary_within",
|
|
35
|
+
"exists",
|
|
36
|
+
"not_exists"
|
|
37
|
+
];
|
|
38
|
+
case "number": return [
|
|
39
|
+
"eq",
|
|
40
|
+
"neq",
|
|
41
|
+
"gt",
|
|
42
|
+
"gte",
|
|
43
|
+
"lt",
|
|
44
|
+
"lte",
|
|
45
|
+
"between",
|
|
46
|
+
"exists",
|
|
47
|
+
"not_exists"
|
|
48
|
+
];
|
|
49
|
+
case "select":
|
|
50
|
+
case "member":
|
|
51
|
+
case "tags":
|
|
52
|
+
case "customer":
|
|
53
|
+
case "company": return [
|
|
54
|
+
"in",
|
|
55
|
+
"not_in",
|
|
56
|
+
"exists",
|
|
57
|
+
"not_exists"
|
|
58
|
+
];
|
|
59
|
+
case "list": return [
|
|
60
|
+
"contains",
|
|
61
|
+
"not_contains",
|
|
62
|
+
"exists",
|
|
63
|
+
"not_exists"
|
|
64
|
+
];
|
|
65
|
+
case "boolean": return ["eq"];
|
|
66
|
+
default: return [
|
|
67
|
+
"contains",
|
|
68
|
+
"not_contains",
|
|
69
|
+
"eq",
|
|
70
|
+
"neq",
|
|
71
|
+
"starts_with",
|
|
72
|
+
"exists",
|
|
73
|
+
"not_exists"
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
/** A new rule on `field`: its type's first operator, no value yet. */
|
|
78
|
+
const ruleFor = (field) => {
|
|
79
|
+
const op = operatorsFor(field.type)[0] ?? "eq";
|
|
80
|
+
if (op === "between") return between(field.path, void 0, void 0);
|
|
81
|
+
if (op === "within_last") return {
|
|
82
|
+
path: field.path,
|
|
83
|
+
op,
|
|
84
|
+
value: {
|
|
85
|
+
amount: 30,
|
|
86
|
+
unit: "days"
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
path: field.path,
|
|
91
|
+
op,
|
|
92
|
+
value: field.type === "boolean" ? true : void 0
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/** "Between"'s two values. */
|
|
96
|
+
const valuesBetween = (rule) => [rule.rules[0].value, rule.rules[1].value];
|
|
97
|
+
/** The same rule on another field: kept when the field reads the same way, else started anew. */
|
|
98
|
+
const withField = (rule, from, to) => {
|
|
99
|
+
if (from?.type !== to.type) return ruleFor(to);
|
|
100
|
+
return isRule(rule) ? {
|
|
101
|
+
...rule,
|
|
102
|
+
path: to.path
|
|
103
|
+
} : between(to.path, ...valuesBetween(rule));
|
|
104
|
+
};
|
|
105
|
+
const kindOf = (op) => NO_VALUE.has(op) ? "none" : RELATIVE.has(op) ? "relative" : LIST_VALUE.has(op) ? "list" : "one";
|
|
106
|
+
/**
|
|
107
|
+
* The rule with another operator. The value stays while it still means the same (a list for
|
|
108
|
+
* "is any of" and "is none of", a number for the comparisons); otherwise it starts empty.
|
|
109
|
+
*/
|
|
110
|
+
const withOperator = (rule, op) => {
|
|
111
|
+
const path = pathOf(rule);
|
|
112
|
+
const current = opOf(rule);
|
|
113
|
+
if (op === "between") return isRule(rule) && kindOf(current) === "one" ? between(path, rule.value, void 0) : between(path, void 0, void 0);
|
|
114
|
+
if (!isRule(rule)) return {
|
|
115
|
+
path,
|
|
116
|
+
op,
|
|
117
|
+
value: NO_VALUE.has(op) ? void 0 : rule.rules[0].value
|
|
118
|
+
};
|
|
119
|
+
if (kindOf(op) === kindOf(current)) return {
|
|
120
|
+
...rule,
|
|
121
|
+
op
|
|
122
|
+
};
|
|
123
|
+
if (kindOf(op) === "relative") return {
|
|
124
|
+
path,
|
|
125
|
+
op,
|
|
126
|
+
value: {
|
|
127
|
+
amount: 30,
|
|
128
|
+
unit: "days"
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
if (kindOf(op) === "list" && rule.value !== void 0 && kindOf(current) === "one") return {
|
|
132
|
+
path,
|
|
133
|
+
op,
|
|
134
|
+
value: [rule.value]
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
path,
|
|
138
|
+
op
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
const filled = (value) => value !== void 0 && value !== null && value !== "" && !(typeof value === "number" && !Number.isFinite(value));
|
|
142
|
+
/** Whether a rule says enough to filter by: its value is there, or it needs none. */
|
|
143
|
+
const isComplete = (rule) => {
|
|
144
|
+
if (NO_VALUE.has(rule.op)) return true;
|
|
145
|
+
if (RELATIVE.has(rule.op)) return RelativeAmount.safeParse(rule.value).success;
|
|
146
|
+
if (LIST_VALUE.has(rule.op)) return Array.isArray(rule.value) && rule.value.some(filled);
|
|
147
|
+
return filled(rule.value);
|
|
148
|
+
};
|
|
149
|
+
/** Whether an editor's rule says enough: a "between" needs both ends. */
|
|
150
|
+
const isFilled = (rule) => isRule(rule) ? isComplete(rule) : rule.rules.every(isComplete);
|
|
151
|
+
/**
|
|
152
|
+
* The conditions without the rules still being written: a group drops its unfinished rules,
|
|
153
|
+
* an empty group goes, and a group left with one rule is that rule (one side of a "between").
|
|
154
|
+
* Null when nothing is left.
|
|
155
|
+
*/
|
|
156
|
+
const completeOf = (group) => {
|
|
157
|
+
const rules = group.rules.flatMap((node) => {
|
|
158
|
+
if (isRule(node)) return isComplete(node) ? [node] : [];
|
|
159
|
+
const inner = completeOf(node);
|
|
160
|
+
if (!inner) return [];
|
|
161
|
+
const [only] = inner.rules;
|
|
162
|
+
return inner.rules.length === 1 && only ? [only] : [inner];
|
|
163
|
+
});
|
|
164
|
+
return rules.length ? {
|
|
165
|
+
...group,
|
|
166
|
+
rules
|
|
167
|
+
} : null;
|
|
168
|
+
};
|
|
169
|
+
/** How many rules a group holds, a "between" counting as one. */
|
|
170
|
+
const ruleCount = (group) => group.rules.reduce((count, node) => count + (isFilterRule(node) ? 1 : ruleCount(node)), 0);
|
|
171
|
+
export { between, completeOf, isFilled, isFilterRule, opOf, operatorsFor, pathOf, ruleCount, ruleFor, valuesBetween, withField, withOperator };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RelativeAmount, TConditionField, TConditionLookups, TConditionRule } from "./conditions.js";
|
|
2
|
+
import { TFilterOperator, TFilterRule } from "./filterRule.js";
|
|
3
|
+
/** An operator in words, for a field's type ("is before" on a date). */
|
|
4
|
+
export declare const useOperatorLabel: () => (op: TFilterOperator, type: string | undefined) => string;
|
|
5
|
+
/** A relative amount in words: "30 days". */
|
|
6
|
+
export declare const useSpanText: () => ({ amount, unit }: RelativeAmount) => string;
|
|
7
|
+
/**
|
|
8
|
+
* The values a rule picks: the list of "is any of", or the one of "is". A value that isn't text,
|
|
9
|
+
* a number or yes/no (a date range, a relative amount) picks nothing.
|
|
10
|
+
*/
|
|
11
|
+
export declare const valuesOf: (rule: TConditionRule | undefined) => string[];
|
|
12
|
+
/** A rule in words, as a chip shows it: the operator and the value (empty when it needs none). */
|
|
13
|
+
export declare const useRuleText: (rule: TFilterRule, field: TConditionField | undefined, lookups: TConditionLookups) => {
|
|
14
|
+
op: string;
|
|
15
|
+
value: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { useFormat } from "../../lib/format.js";
|
|
2
|
+
import { useMoney } from "../../lib/money.js";
|
|
3
|
+
import { textOf } from "../../lib/text.js";
|
|
4
|
+
import { LIST_VALUE, NO_VALUE, RelativeAmount, isRule } from "./conditions.js";
|
|
5
|
+
import { valuesBetween } from "./filterRule.js";
|
|
6
|
+
import { useFieldOptions } from "./fieldOptions.js";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { useTranslation } from "react-i18next";
|
|
9
|
+
// src/modules/conditions/filterText.ts
|
|
10
|
+
/** English for the `views` namespace's `filter.op.<op>`. */
|
|
11
|
+
const OPERATORS = {
|
|
12
|
+
eq: "is",
|
|
13
|
+
neq: "is not",
|
|
14
|
+
gt: "is greater than",
|
|
15
|
+
gte: "is at least",
|
|
16
|
+
lt: "is less than",
|
|
17
|
+
lte: "is at most",
|
|
18
|
+
contains: "contains",
|
|
19
|
+
not_contains: "doesn't contain",
|
|
20
|
+
starts_with: "starts with",
|
|
21
|
+
in: "is any of",
|
|
22
|
+
not_in: "is none of",
|
|
23
|
+
exists: "is set",
|
|
24
|
+
not_exists: "is empty",
|
|
25
|
+
within_last: "is in the last",
|
|
26
|
+
more_than_ago: "is more than … ago",
|
|
27
|
+
within_next: "is in the next",
|
|
28
|
+
anniversary_within: "anniversary in the next",
|
|
29
|
+
between: "is between"
|
|
30
|
+
};
|
|
31
|
+
/** Dates compare as days: `filter.op-date.<op>`. */
|
|
32
|
+
const DATE_OPERATORS = {
|
|
33
|
+
eq: "is on",
|
|
34
|
+
neq: "is not on",
|
|
35
|
+
gt: "is after",
|
|
36
|
+
gte: "is on or after",
|
|
37
|
+
lt: "is before",
|
|
38
|
+
lte: "is on or before"
|
|
39
|
+
};
|
|
40
|
+
/** Numbers read as symbols on a chip. */
|
|
41
|
+
const SYMBOLS = {
|
|
42
|
+
eq: "=",
|
|
43
|
+
neq: "≠",
|
|
44
|
+
gt: ">",
|
|
45
|
+
gte: "≥",
|
|
46
|
+
lt: "<",
|
|
47
|
+
lte: "≤"
|
|
48
|
+
};
|
|
49
|
+
/** English for `filter.unit.<unit>`, by plural form. */
|
|
50
|
+
const UNITS = {
|
|
51
|
+
days: {
|
|
52
|
+
defaultValue_one: "{{count}} day",
|
|
53
|
+
defaultValue_other: "{{count}} days"
|
|
54
|
+
},
|
|
55
|
+
weeks: {
|
|
56
|
+
defaultValue_one: "{{count}} week",
|
|
57
|
+
defaultValue_other: "{{count}} weeks"
|
|
58
|
+
},
|
|
59
|
+
months: {
|
|
60
|
+
defaultValue_one: "{{count}} month",
|
|
61
|
+
defaultValue_other: "{{count}} months"
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/** An operator in words, for a field's type ("is before" on a date). */
|
|
65
|
+
const useOperatorLabel = () => {
|
|
66
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
67
|
+
return (op, type) => {
|
|
68
|
+
const dated = type === "date" ? DATE_OPERATORS[op] : void 0;
|
|
69
|
+
return dated ? t(`op-date.${op}`, dated) : t(`op.${op}`, OPERATORS[op]);
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/** A relative amount in words: "30 days". */
|
|
73
|
+
const useSpanText = () => {
|
|
74
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
75
|
+
return ({ amount, unit }) => t(`unit.${unit}`, {
|
|
76
|
+
count: amount,
|
|
77
|
+
...UNITS[unit]
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const Values = z.array(z.union([
|
|
81
|
+
z.string(),
|
|
82
|
+
z.number(),
|
|
83
|
+
z.boolean()
|
|
84
|
+
]).transform(String));
|
|
85
|
+
/**
|
|
86
|
+
* The values a rule picks: the list of "is any of", or the one of "is". A value that isn't text,
|
|
87
|
+
* a number or yes/no (a date range, a relative amount) picks nothing.
|
|
88
|
+
*/
|
|
89
|
+
const valuesOf = (rule) => {
|
|
90
|
+
if (!rule || rule.value === void 0 || rule.value === null) return [];
|
|
91
|
+
return Values.safeParse(Array.isArray(rule.value) ? rule.value : [rule.value]).data ?? [];
|
|
92
|
+
};
|
|
93
|
+
/** A rule in words, as a chip shows it: the operator and the value (empty when it needs none). */
|
|
94
|
+
const useRuleText = (rule, field, lookups) => {
|
|
95
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
96
|
+
const operator = useOperatorLabel();
|
|
97
|
+
const spanText = useSpanText();
|
|
98
|
+
const money = useMoney();
|
|
99
|
+
const fmt = useFormat();
|
|
100
|
+
const type = field?.type;
|
|
101
|
+
const picked = isRule(rule) ? valuesOf(rule) : [];
|
|
102
|
+
const { options } = useFieldOptions(field, lookups, picked);
|
|
103
|
+
const one = (value) => {
|
|
104
|
+
if (value === void 0 || value === null || value === "") return "…";
|
|
105
|
+
if (type === "date") {
|
|
106
|
+
const day = textOf(value);
|
|
107
|
+
return /^\d{4}-\d{2}-\d{2}/.test(day) ? fmt.date(day.slice(0, 10)) : day;
|
|
108
|
+
}
|
|
109
|
+
if (type === "number") {
|
|
110
|
+
const n = Number(value);
|
|
111
|
+
return field?.currency ? money(n, field.currency) : fmt.number(n);
|
|
112
|
+
}
|
|
113
|
+
return textOf(value);
|
|
114
|
+
};
|
|
115
|
+
if (!isRule(rule)) {
|
|
116
|
+
const [from, to] = valuesBetween(rule);
|
|
117
|
+
return {
|
|
118
|
+
op: operator("between", type),
|
|
119
|
+
value: `${one(from)} – ${one(to)}`
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const op = operator(rule.op, type);
|
|
123
|
+
if (NO_VALUE.has(rule.op)) return {
|
|
124
|
+
op,
|
|
125
|
+
value: ""
|
|
126
|
+
};
|
|
127
|
+
const span = RelativeAmount.safeParse(rule.value);
|
|
128
|
+
if (span.success) return {
|
|
129
|
+
op,
|
|
130
|
+
value: spanText(span.data)
|
|
131
|
+
};
|
|
132
|
+
if (type === "boolean") return {
|
|
133
|
+
op: t("op.eq", "is"),
|
|
134
|
+
value: textOf(rule.value) === "true" ? t("yes", "Yes") : t("no", "No")
|
|
135
|
+
};
|
|
136
|
+
if (type === "number" && SYMBOLS[rule.op]) return {
|
|
137
|
+
op: SYMBOLS[rule.op] ?? op,
|
|
138
|
+
value: one(rule.value)
|
|
139
|
+
};
|
|
140
|
+
if (options.length || LIST_VALUE.has(rule.op)) {
|
|
141
|
+
const labels = picked.map((value) => options.find((option) => option.value === value)?.label ?? value);
|
|
142
|
+
return {
|
|
143
|
+
op: labels.length === 1 && LIST_VALUE.has(rule.op) ? operator(rule.op === "in" ? "eq" : "neq", type) : op,
|
|
144
|
+
value: labels.join(", ") || "…"
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (type === "date" || type === "number") return {
|
|
148
|
+
op,
|
|
149
|
+
value: one(rule.value)
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
op,
|
|
153
|
+
value: rule.value === void 0 ? "…" : `“${textOf(rule.value)}”`
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export { useOperatorLabel, useRuleText, useSpanText, valuesOf };
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { EmailDisplayProps } from "../types/emailDisplay.js";
|
|
2
|
+
/**
|
|
3
|
+
* A record's emails as chips, the primary one with its validation mark.
|
|
4
|
+
* `maxVisible` shows that many and a +N badge for the rest; `onEmailClick` makes each a button.
|
|
5
|
+
*/
|
|
2
6
|
export declare const EmailDisplay: ({ maxVisible, primaryEmail, emails, emailValidationStatus, ...handlers }: EmailDisplayProps) => import("react").JSX.Element;
|
|
@@ -16,13 +16,12 @@ const EmailChip = ({ item, email, onEmailClick, onEmailDoubleClick, onEmailKeyAc
|
|
|
16
16
|
className: "min-w-0",
|
|
17
17
|
children: /* @__PURE__ */ jsx(EmailText, { ...item })
|
|
18
18
|
});
|
|
19
|
-
return /* @__PURE__ */ jsx("
|
|
19
|
+
return /* @__PURE__ */ jsx("button", {
|
|
20
|
+
type: "button",
|
|
20
21
|
className: cn(buttonVariants({
|
|
21
22
|
size: "sm",
|
|
22
23
|
variant: "secondary"
|
|
23
24
|
}), "min-w-0 max-w-full h-6 w-fit rounded-sm border gap-1 cursor-pointer hover:bg-primary/10 hover:text-primary-text focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"),
|
|
24
|
-
role: "button",
|
|
25
|
-
tabIndex: 0,
|
|
26
25
|
onClick: (event) => {
|
|
27
26
|
event.stopPropagation();
|
|
28
27
|
onEmailClick(email);
|
|
@@ -40,6 +39,10 @@ const EmailChip = ({ item, email, onEmailClick, onEmailDoubleClick, onEmailKeyAc
|
|
|
40
39
|
children: /* @__PURE__ */ jsx(EmailText, { ...item })
|
|
41
40
|
});
|
|
42
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* A record's emails as chips, the primary one with its validation mark.
|
|
44
|
+
* `maxVisible` shows that many and a +N badge for the rest; `onEmailClick` makes each a button.
|
|
45
|
+
*/
|
|
43
46
|
const EmailDisplay = ({ maxVisible, primaryEmail, emails, emailValidationStatus, ...handlers }) => {
|
|
44
47
|
const values = formatEmails(primaryEmail, emails, emailValidationStatus).filter((item) => item.email);
|
|
45
48
|
const visible = maxVisible === void 0 ? values : values.slice(0, maxVisible);
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { IPhoneFieldProps } from "../../inputs/types/phoneField.js";
|
|
2
|
+
/**
|
|
3
|
+
* A record's phones as chips, the primary one with its validation mark.
|
|
4
|
+
* `maxVisible` shows that many and a +N badge for the rest.
|
|
5
|
+
*/
|
|
2
6
|
export declare const PhoneDisplay: ({ maxVisible, primaryPhone, phones, phoneValidationStatus }: IPhoneFieldProps & {
|
|
3
7
|
maxVisible?: number;
|
|
4
8
|
}) => import("react").JSX.Element;
|
|
@@ -5,6 +5,10 @@ import { formatPhoneNumber } from "../../../utils/format/formatPhoneNumber.js";
|
|
|
5
5
|
import { IconCircleDashed, IconCircleDashedCheck } from "@tabler/icons-react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
// src/modules/display/components/PhoneDisplay.tsx
|
|
8
|
+
/**
|
|
9
|
+
* A record's phones as chips, the primary one with its validation mark.
|
|
10
|
+
* `maxVisible` shows that many and a +N badge for the rest.
|
|
11
|
+
*/
|
|
8
12
|
const PhoneDisplay = ({ maxVisible, primaryPhone, phones, phoneValidationStatus }) => {
|
|
9
13
|
const values = formatPhones(primaryPhone, phones, phoneValidationStatus).filter((item) => item.phone);
|
|
10
14
|
const visible = maxVisible === void 0 ? values : values.slice(0, maxVisible);
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Tooltip } from "../../../components/tooltip.js";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Except } from "type-fest";
|
|
4
|
-
type RelativeDateDisplayProps = {
|
|
5
|
-
value: string;
|
|
6
|
-
isShort?: boolean;
|
|
7
|
-
};
|
|
8
4
|
declare const RelativeDateDisplayTooltip: ({ value, ...props }: Except<React.ComponentProps<typeof Tooltip.Trigger>, 'value'> & {
|
|
9
5
|
value: string;
|
|
10
6
|
}) => React.JSX.Element | null;
|
|
11
|
-
declare const RelativeDateDisplayValue: ({ value
|
|
7
|
+
declare const RelativeDateDisplayValue: ({ value }: {
|
|
8
|
+
value: string;
|
|
9
|
+
}) => string | null;
|
|
10
|
+
/**
|
|
11
|
+
* A date as how long ago it was, with the date and time on hover.
|
|
12
|
+
* `RelativeDateDisplay.Value` is the text alone.
|
|
13
|
+
*/
|
|
12
14
|
export declare const RelativeDateDisplay: typeof RelativeDateDisplayTooltip & {
|
|
13
15
|
Value: typeof RelativeDateDisplayValue;
|
|
14
16
|
};
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { Tooltip } from "../../../components/tooltip.js";
|
|
2
|
+
import { useFormat } from "../../../lib/format.js";
|
|
2
3
|
import { isUndefinedOrNull } from "../../../utils/IsUndefinedOrNull.js";
|
|
3
|
-
import { formatDateISOStringToRelativeDate, formatDateISOStringToRelativeDateShort } from "../../../utils/localization/formatDateISOStringToRelativeDate.js";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import "react";
|
|
6
|
-
import { format } from "date-fns";
|
|
7
6
|
// src/modules/display/components/RelativeDateDisplay.tsx
|
|
8
7
|
const RelativeDateDisplayTooltip = ({ value, ...props }) => {
|
|
8
|
+
const fmt = useFormat();
|
|
9
9
|
if (isUndefinedOrNull(value)) return null;
|
|
10
10
|
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(Tooltip.Trigger, {
|
|
11
11
|
delay: 100,
|
|
12
12
|
className: "truncate",
|
|
13
13
|
...props
|
|
14
|
-
}), /* @__PURE__ */ jsx(Tooltip.Content, { children:
|
|
14
|
+
}), /* @__PURE__ */ jsx(Tooltip.Content, { children: fmt.dateTime(value) })] });
|
|
15
15
|
};
|
|
16
|
-
const RelativeDateDisplayValue = ({ value
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const relativeDateShort = formatDateISOStringToRelativeDateShort(value);
|
|
20
|
-
return isShort ? relativeDateShort : relativeDate;
|
|
16
|
+
const RelativeDateDisplayValue = ({ value }) => {
|
|
17
|
+
const fmt = useFormat();
|
|
18
|
+
return isUndefinedOrNull(value) ? null : fmt.relative(value);
|
|
21
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* A date as how long ago it was, with the date and time on hover.
|
|
22
|
+
* `RelativeDateDisplay.Value` is the text alone.
|
|
23
|
+
*/
|
|
22
24
|
const RelativeDateDisplay = Object.assign(RelativeDateDisplayTooltip, { Value: RelativeDateDisplayValue });
|
|
23
25
|
export { RelativeDateDisplay };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SexCodes } from "../../../constants/SexCodes.js";
|
|
2
2
|
import "../../../types/SexCode.js";
|
|
3
3
|
// src/modules/display/components/SexDisplay.tsx
|
|
4
|
+
/** A sex code as its label, or nothing when it is not known. */
|
|
4
5
|
const SexDisplay = ({ value = 0 }) => value === 0 ? "" : SexCodes[value].label;
|
|
5
6
|
export { SexDisplay };
|
|
@@ -2,6 +2,10 @@ import { FilterBar, FilterBarButton, FilterBarCloseButton, FilterBarItem, Filter
|
|
|
2
2
|
import { FilterDialog, FilterDialogStringView } from "./FilterDialog.js";
|
|
3
3
|
import { FilterCommandInput, FilterCommandItem, FilterItem, FilterPopover, FilterSearchValueTrigger, FilterTrigger, FilterView } from "./FilterPopover.js";
|
|
4
4
|
import { FilterProvider } from "./FilterProvider.js";
|
|
5
|
+
/**
|
|
6
|
+
* Parts of a filter popover and bar, for a page without saved views.
|
|
7
|
+
* A list page uses `ListFilter`; reach for these parts only for a filter it can't draw.
|
|
8
|
+
*/
|
|
5
9
|
export declare const Filter: typeof FilterProvider & {
|
|
6
10
|
Trigger: typeof FilterTrigger;
|
|
7
11
|
Popover: typeof FilterPopover;
|
|
@@ -3,6 +3,10 @@ import { FilterDialog, FilterDialogStringView } from "./FilterDialog.js";
|
|
|
3
3
|
import { FilterCommandInput, FilterCommandItem, FilterItem, FilterPopover, FilterSearchValueTrigger, FilterTrigger, FilterView } from "./FilterPopover.js";
|
|
4
4
|
import { FilterProvider } from "./FilterProvider.js";
|
|
5
5
|
// src/modules/filter/components/Filter.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Parts of a filter popover and bar, for a page without saved views.
|
|
8
|
+
* A list page uses `ListFilter`; reach for these parts only for a filter it can't draw.
|
|
9
|
+
*/
|
|
6
10
|
const Filter = Object.assign(FilterProvider, {
|
|
7
11
|
Trigger: FilterTrigger,
|
|
8
12
|
Popover: FilterPopover,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Button } from "../../../components/button.js";
|
|
2
|
-
import { useRemoveQueryStateByKey } from "../../../hooks/use-query-state.js";
|
|
3
2
|
import { cn } from "../../../lib/utils.js";
|
|
4
3
|
import { useFilterContext } from "../hooks/useFilterContext.js";
|
|
5
|
-
import { useFilterQueryState } from "../hooks/useFilterQueryState.js";
|
|
6
4
|
import { IconSearch, IconX } from "@tabler/icons-react";
|
|
7
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
6
|
import "react";
|
|
9
|
-
import {
|
|
7
|
+
import { useTranslation } from "react-i18next";
|
|
8
|
+
import { useQueryState } from "nuqs";
|
|
10
9
|
// src/modules/filter/components/FilterBar.tsx
|
|
11
10
|
const FilterBar = ({ ref, className, ...props }) => {
|
|
12
11
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -16,19 +15,21 @@ const FilterBar = ({ ref, className, ...props }) => {
|
|
|
16
15
|
});
|
|
17
16
|
};
|
|
18
17
|
const FilterBarCloseButton = ({ ref, className, filterKey, ...props }) => {
|
|
19
|
-
const
|
|
18
|
+
const [, setQuery] = useQueryState(filterKey ?? "");
|
|
19
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
20
20
|
return /* @__PURE__ */ jsx(Button, {
|
|
21
21
|
ref,
|
|
22
22
|
variant: "segment",
|
|
23
23
|
size: "icon",
|
|
24
24
|
className,
|
|
25
|
-
|
|
25
|
+
"aria-label": t("remove", "Remove filter"),
|
|
26
|
+
onClick: () => void setQuery(null),
|
|
26
27
|
...props,
|
|
27
28
|
children: /* @__PURE__ */ jsx(IconX, {})
|
|
28
29
|
});
|
|
29
30
|
};
|
|
30
31
|
const FilterBarItem = ({ ref, className, queryKey, children, ...props }) => {
|
|
31
|
-
const [query] =
|
|
32
|
+
const [query] = useQueryState(queryKey || "root");
|
|
32
33
|
if (queryKey && !query) return null;
|
|
33
34
|
return /* @__PURE__ */ jsxs("div", {
|
|
34
35
|
ref,
|
|
@@ -60,7 +61,7 @@ const FilterBarButton = ({ ref, className, inDialog, filterKey, ...props }) => {
|
|
|
60
61
|
});
|
|
61
62
|
};
|
|
62
63
|
const FilterSearchValueBarItem = () => {
|
|
63
|
-
const [searchValue] =
|
|
64
|
+
const [searchValue] = useQueryState("searchValue");
|
|
64
65
|
return /* @__PURE__ */ jsxs(FilterBarItem, {
|
|
65
66
|
queryKey: "searchValue",
|
|
66
67
|
children: [/* @__PURE__ */ jsxs(FilterBarName, { children: [/* @__PURE__ */ jsx(IconSearch, {}), "Search"] }), /* @__PURE__ */ jsx(FilterBarButton, {
|
|
@@ -2,13 +2,12 @@ import { Button } from "../../../components/button.js";
|
|
|
2
2
|
import { Dialog } from "../../../components/dialog.js";
|
|
3
3
|
import { Input } from "../../../components/input.js";
|
|
4
4
|
import { useFilterContext } from "../hooks/useFilterContext.js";
|
|
5
|
-
import { useFilterQueryState } from "../hooks/useFilterQueryState.js";
|
|
6
5
|
import { openDialogState } from "../states/filterStates.js";
|
|
7
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
7
|
import { useState } from "react";
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import { useTranslation } from "react-i18next";
|
|
11
8
|
import { useAtomValue } from "jotai";
|
|
9
|
+
import { useTranslation } from "react-i18next";
|
|
10
|
+
import { useQueryState } from "nuqs";
|
|
12
11
|
// src/modules/filter/components/FilterDialog.tsx
|
|
13
12
|
const FilterDialog = (props) => {
|
|
14
13
|
const { id, setOpenDialog, resetFilterState } = useFilterContext();
|
|
@@ -24,8 +23,8 @@ const FilterDialog = (props) => {
|
|
|
24
23
|
};
|
|
25
24
|
const FilterDialogStringView = ({ filterKey, label }) => {
|
|
26
25
|
const { t } = useTranslation();
|
|
27
|
-
const { setDialogView, setOpenDialog
|
|
28
|
-
const [query, setQuery] =
|
|
26
|
+
const { setDialogView, setOpenDialog } = useFilterContext();
|
|
27
|
+
const [query, setQuery] = useQueryState(filterKey);
|
|
29
28
|
const [dialogSearch, setDialogSearch] = useState(query ?? "");
|
|
30
29
|
const onSubmit = (e) => {
|
|
31
30
|
e.preventDefault();
|
|
@@ -10,8 +10,8 @@ import { filterDialogViewState, filterPopoverViewState, openDialogState, openPop
|
|
|
10
10
|
import { IconChevronLeft, IconChevronRight, IconFilter2, IconSearch } from "@tabler/icons-react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import React, { useEffect } from "react";
|
|
13
|
-
import { useTranslation } from "react-i18next";
|
|
14
13
|
import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
|
14
|
+
import { useTranslation } from "react-i18next";
|
|
15
15
|
// src/modules/filter/components/FilterPopover.tsx
|
|
16
16
|
const FilterTrigger = ({ ref, isFiltered, className, ...props }) => {
|
|
17
17
|
const { t } = useTranslation();
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
import { FilterContext } from "../context/FilterContext.js";
|
|
2
2
|
import { filterDialogViewState, filterPopoverViewState, openDialogState, openPopoverState } from "../states/filterStates.js";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useMemo } from "react";
|
|
4
5
|
import { useSetAtom } from "jotai";
|
|
5
6
|
// src/modules/filter/components/FilterProvider.tsx
|
|
6
|
-
const FilterProvider = ({ children, id
|
|
7
|
+
const FilterProvider = ({ children, id }) => {
|
|
7
8
|
const setOpen = useSetAtom(openPopoverState(id));
|
|
8
9
|
const setView = useSetAtom(filterPopoverViewState(id));
|
|
9
10
|
const setDialogView = useSetAtom(filterDialogViewState(id));
|
|
10
11
|
const setOpenDialog = useSetAtom(openDialogState(id));
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
value: {
|
|
19
|
-
id,
|
|
20
|
-
sessionKey,
|
|
21
|
-
resetFilterState,
|
|
22
|
-
setOpen,
|
|
23
|
-
setView,
|
|
24
|
-
setDialogView,
|
|
25
|
-
setOpenDialog
|
|
12
|
+
const filter = useMemo(() => ({
|
|
13
|
+
id,
|
|
14
|
+
resetFilterState: () => {
|
|
15
|
+
setOpen(false);
|
|
16
|
+
setView("root");
|
|
17
|
+
setDialogView("root");
|
|
18
|
+
setOpenDialog(false);
|
|
26
19
|
},
|
|
20
|
+
setOpen,
|
|
21
|
+
setView,
|
|
22
|
+
setDialogView,
|
|
23
|
+
setOpenDialog
|
|
24
|
+
}), [
|
|
25
|
+
id,
|
|
26
|
+
setOpen,
|
|
27
|
+
setView,
|
|
28
|
+
setDialogView,
|
|
29
|
+
setOpenDialog
|
|
30
|
+
]);
|
|
31
|
+
return /* @__PURE__ */ jsx(FilterContext.Provider, {
|
|
32
|
+
value: filter,
|
|
27
33
|
children
|
|
28
34
|
});
|
|
29
35
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FilterContext } from "../context/FilterContext.js";
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
// src/modules/filter/hooks/useFilterContext.tsx
|
|
4
|
+
/** Controls of the enclosing `Filter`: open or close it and switch views. Throws outside one. */
|
|
4
5
|
const useFilterContext = () => {
|
|
5
6
|
const context = useContext(FilterContext);
|
|
6
7
|
if (!context) throw new Error("useFilterContext must be used inside <Filter>");
|