@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,30 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/** A run of rows under one header, such as the tasks in one status. */
|
|
3
|
+
export interface RecordListGroup<TRow> {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
rows: TRow[];
|
|
8
|
+
/** The header's controls on the right, such as a "+" that adds a row to this group. */
|
|
9
|
+
action?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
interface RecordListProps<TRow> {
|
|
12
|
+
groups: RecordListGroup<TRow>[];
|
|
13
|
+
rowId: (row: TRow) => string;
|
|
14
|
+
/** The row's name, for its checkbox's label. */
|
|
15
|
+
rowLabel: (row: TRow) => string;
|
|
16
|
+
/** The row's content, after its checkbox. */
|
|
17
|
+
renderRow: (row: TRow) => ReactNode;
|
|
18
|
+
/** False: one list with no headers, such as rows sorted by date. */
|
|
19
|
+
grouped?: boolean;
|
|
20
|
+
/** False: rows without checkboxes, for a list with no bulk actions. */
|
|
21
|
+
selectable?: boolean;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Rows in groups, each under a sticky header that folds it away and picks all its rows; the
|
|
26
|
+
* folded groups are kept in this browser. Shift-click picks every row between two clicks, as
|
|
27
|
+
* shown. Inside `RecordList.Provider`, which holds the selection a command bar reads.
|
|
28
|
+
*/
|
|
29
|
+
export declare const RecordListRoot: <TRow>({ groups, rowId, rowLabel, renderRow, grouped, selectable, className }: RecordListProps<TRow>) => import("react").JSX.Element;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Button } from "../../components/button.js";
|
|
2
|
+
import { Checkbox } from "../../components/checkbox.js";
|
|
3
|
+
import { useMediaQuery } from "../../hooks/use-media-query.js";
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
import { collapsedGroups, useRecordListContext, useSelectionState } from "./RecordListProvider.js";
|
|
6
|
+
import { IconChevronDown, IconChevronRight } from "@tabler/icons-react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useId } from "react";
|
|
9
|
+
import { useAtom } from "jotai";
|
|
10
|
+
// src/modules/record-list/RecordListRoot.tsx
|
|
11
|
+
/**
|
|
12
|
+
* A row's control that shows on hover or focus. A row's own controls (an empty date, say) can
|
|
13
|
+
* use the same classes. Where a finger may be the pointer (a phone, a touch laptop), nothing
|
|
14
|
+
* hovers first, so there they always show.
|
|
15
|
+
*/
|
|
16
|
+
const revealed = "opacity-0 group-hover/list-row:opacity-100 group-focus-within/list-row:opacity-100";
|
|
17
|
+
const useHover = () => useMediaQuery("(hover: hover) and (not (any-pointer: coarse))");
|
|
18
|
+
const GroupHeader = ({ group, ids, panelId, collapsed, onCollapse, selectable }) => /* @__PURE__ */ jsxs("div", {
|
|
19
|
+
className: "group/list-row sticky top-0 z-10 flex h-9 items-center gap-1 border-b bg-muted px-2 text-xs font-medium",
|
|
20
|
+
children: [
|
|
21
|
+
selectable && /* @__PURE__ */ jsx(GroupCheckbox, {
|
|
22
|
+
label: group.label,
|
|
23
|
+
ids
|
|
24
|
+
}),
|
|
25
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
26
|
+
variant: "ghost",
|
|
27
|
+
size: "sm",
|
|
28
|
+
"aria-expanded": !collapsed,
|
|
29
|
+
"aria-controls": collapsed ? void 0 : panelId,
|
|
30
|
+
onClick: () => onCollapse(!collapsed),
|
|
31
|
+
children: [
|
|
32
|
+
collapsed ? /* @__PURE__ */ jsx(IconChevronRight, { "aria-hidden": true }) : /* @__PURE__ */ jsx(IconChevronDown, { "aria-hidden": true }),
|
|
33
|
+
group.icon,
|
|
34
|
+
group.label,
|
|
35
|
+
/* @__PURE__ */ jsx("span", {
|
|
36
|
+
className: "text-muted-foreground tabular-nums",
|
|
37
|
+
children: ids.length
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
}),
|
|
41
|
+
group.action && /* @__PURE__ */ jsx("span", {
|
|
42
|
+
className: "ml-auto flex items-center",
|
|
43
|
+
children: group.action
|
|
44
|
+
})
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
/** Picks or drops every row of a group. */
|
|
48
|
+
const GroupCheckbox = ({ label, ids }) => {
|
|
49
|
+
const { selection } = useRecordListContext();
|
|
50
|
+
const hover = useHover();
|
|
51
|
+
const picked = useSelectionState((current) => ids.filter((id) => current.has(id)).length);
|
|
52
|
+
return /* @__PURE__ */ jsx("span", {
|
|
53
|
+
className: cn("flex h-9 w-8 shrink-0 items-center justify-center", hover && !picked && revealed),
|
|
54
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
55
|
+
checked: picked > 0 && picked === ids.length,
|
|
56
|
+
indeterminate: picked > 0 && picked < ids.length,
|
|
57
|
+
"aria-label": `Select all in ${label}`,
|
|
58
|
+
onCheckedChange: () => selection.toggleAll(ids)
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const rowClass = "group/list-row flex h-11 items-center gap-1 border-b px-2 text-sm hover:bg-muted data-selected:bg-primary/10";
|
|
63
|
+
/** A row with no checkbox, in a list without selection. */
|
|
64
|
+
const PlainRow = ({ id, children }) => /* @__PURE__ */ jsx("li", {
|
|
65
|
+
"data-record-row": id,
|
|
66
|
+
className: rowClass,
|
|
67
|
+
children
|
|
68
|
+
});
|
|
69
|
+
const Row = ({ id, label, order, children }) => {
|
|
70
|
+
const { selection } = useRecordListContext();
|
|
71
|
+
const hover = useHover();
|
|
72
|
+
const checked = useSelectionState((current) => current.has(id));
|
|
73
|
+
const selecting = useSelectionState((current) => current.size > 0);
|
|
74
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
75
|
+
"data-record-row": id,
|
|
76
|
+
"data-selected": checked || void 0,
|
|
77
|
+
className: rowClass,
|
|
78
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
79
|
+
className: cn("flex h-11 w-8 shrink-0 items-center justify-center", hover && !selecting && revealed),
|
|
80
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
81
|
+
className: "relative after:absolute after:-inset-x-2 after:-inset-y-3.5",
|
|
82
|
+
checked,
|
|
83
|
+
"aria-label": `Select ${label}`,
|
|
84
|
+
onCheckedChange: (_checked, { event }) => {
|
|
85
|
+
const range = event instanceof MouseEvent && event.shiftKey;
|
|
86
|
+
if (range) window.getSelection()?.removeAllRanges();
|
|
87
|
+
selection.toggle(id, range ? order : void 0);
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
}), children]
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Rows in groups, each under a sticky header that folds it away and picks all its rows; the
|
|
95
|
+
* folded groups are kept in this browser. Shift-click picks every row between two clicks, as
|
|
96
|
+
* shown. Inside `RecordList.Provider`, which holds the selection a command bar reads.
|
|
97
|
+
*/
|
|
98
|
+
const RecordListRoot = ({ groups, rowId, rowLabel, renderRow, grouped = true, selectable = true, className }) => {
|
|
99
|
+
const { listId } = useRecordListContext();
|
|
100
|
+
const [collapsed, setCollapsed] = useAtom(collapsedGroups(listId));
|
|
101
|
+
const prefix = useId();
|
|
102
|
+
const folded = (group) => grouped && collapsed.includes(group.id);
|
|
103
|
+
const order = groups.filter((group) => !folded(group)).flatMap((group) => group.rows.map(rowId));
|
|
104
|
+
const rows = (list) => list.map((row) => selectable ? /* @__PURE__ */ jsx(Row, {
|
|
105
|
+
id: rowId(row),
|
|
106
|
+
label: rowLabel(row),
|
|
107
|
+
order,
|
|
108
|
+
children: renderRow(row)
|
|
109
|
+
}, rowId(row)) : /* @__PURE__ */ jsx(PlainRow, {
|
|
110
|
+
id: rowId(row),
|
|
111
|
+
children: renderRow(row)
|
|
112
|
+
}, rowId(row)));
|
|
113
|
+
if (!grouped) return /* @__PURE__ */ jsx("div", {
|
|
114
|
+
"data-record-list": listId,
|
|
115
|
+
className,
|
|
116
|
+
children: /* @__PURE__ */ jsx("ul", { children: rows(groups.flatMap((group) => group.rows)) })
|
|
117
|
+
});
|
|
118
|
+
return /* @__PURE__ */ jsx("div", {
|
|
119
|
+
"data-record-list": listId,
|
|
120
|
+
className,
|
|
121
|
+
children: groups.map((group) => {
|
|
122
|
+
const panelId = `${prefix}-${group.id}`;
|
|
123
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
124
|
+
"aria-label": group.label,
|
|
125
|
+
children: [/* @__PURE__ */ jsx(GroupHeader, {
|
|
126
|
+
group,
|
|
127
|
+
ids: group.rows.map(rowId),
|
|
128
|
+
panelId,
|
|
129
|
+
collapsed: folded(group),
|
|
130
|
+
selectable,
|
|
131
|
+
onCollapse: (fold) => setCollapsed((current) => fold ? [...current, group.id] : current.filter((id) => id !== group.id))
|
|
132
|
+
}), !folded(group) && /* @__PURE__ */ jsx("ul", {
|
|
133
|
+
id: panelId,
|
|
134
|
+
children: rows(group.rows)
|
|
135
|
+
})]
|
|
136
|
+
}, group.id);
|
|
137
|
+
})
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
export { RecordListRoot };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rows a click on `id` picks. With `anchor` (the row clicked before), every row from it to
|
|
3
|
+
* `id` in `order`, the rows as shown; without, or when either left the list, `id` alone.
|
|
4
|
+
*/
|
|
5
|
+
export declare const rowsBetween: (order: readonly string[], anchor: string | null, id: string) => string[];
|
|
6
|
+
/** `picked` with `ids` added (`on`) or taken out. */
|
|
7
|
+
export declare const withRows: (picked: ReadonlySet<string>, ids: readonly string[], on: boolean) => Set<string>;
|
|
8
|
+
/**
|
|
9
|
+
* One list's picked rows, outside React: each row subscribes to its own state, so a click
|
|
10
|
+
* renders only the rows it changes. Every change starts from the current state, so changes
|
|
11
|
+
* made before a render all count.
|
|
12
|
+
*/
|
|
13
|
+
export declare const createSelection: () => {
|
|
14
|
+
subscribe: (listener: () => void) => () => void;
|
|
15
|
+
picked: () => ReadonlySet<string>;
|
|
16
|
+
/** With `order` (the rows as shown), a shift-click: every row since the last click. */
|
|
17
|
+
toggle: (id: string, order?: readonly string[]) => void;
|
|
18
|
+
/** Picks all of `ids`, or clears them when all are picked. */
|
|
19
|
+
toggleAll: (ids: readonly string[]) => void;
|
|
20
|
+
clear: () => void;
|
|
21
|
+
};
|
|
22
|
+
export type Selection = ReturnType<typeof createSelection>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/modules/record-list/selection.ts
|
|
2
|
+
/**
|
|
3
|
+
* The rows a click on `id` picks. With `anchor` (the row clicked before), every row from it to
|
|
4
|
+
* `id` in `order`, the rows as shown; without, or when either left the list, `id` alone.
|
|
5
|
+
*/
|
|
6
|
+
const rowsBetween = (order, anchor, id) => {
|
|
7
|
+
const from = anchor === null ? -1 : order.indexOf(anchor);
|
|
8
|
+
const to = order.indexOf(id);
|
|
9
|
+
if (from === -1 || to === -1) return [id];
|
|
10
|
+
return order.slice(Math.min(from, to), Math.max(from, to) + 1);
|
|
11
|
+
};
|
|
12
|
+
/** `picked` with `ids` added (`on`) or taken out. */
|
|
13
|
+
const withRows = (picked, ids, on) => {
|
|
14
|
+
const next = new Set(picked);
|
|
15
|
+
for (const id of ids) if (on) next.add(id);
|
|
16
|
+
else next.delete(id);
|
|
17
|
+
return next;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* One list's picked rows, outside React: each row subscribes to its own state, so a click
|
|
21
|
+
* renders only the rows it changes. Every change starts from the current state, so changes
|
|
22
|
+
* made before a render all count.
|
|
23
|
+
*/
|
|
24
|
+
const createSelection = () => {
|
|
25
|
+
let picked = /* @__PURE__ */ new Set();
|
|
26
|
+
let anchor = null;
|
|
27
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
28
|
+
const set = (next) => {
|
|
29
|
+
picked = next;
|
|
30
|
+
for (const listener of listeners) listener();
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
subscribe: (listener) => {
|
|
34
|
+
listeners.add(listener);
|
|
35
|
+
return () => {
|
|
36
|
+
listeners.delete(listener);
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
picked: () => picked,
|
|
40
|
+
/** With `order` (the rows as shown), a shift-click: every row since the last click. */
|
|
41
|
+
toggle: (id, order) => {
|
|
42
|
+
const rows = order ? rowsBetween(order, anchor, id) : [id];
|
|
43
|
+
anchor = id;
|
|
44
|
+
set(withRows(picked, rows, !picked.has(id)));
|
|
45
|
+
},
|
|
46
|
+
/** Picks all of `ids`, or clears them when all are picked. */
|
|
47
|
+
toggleAll: (ids) => set(withRows(picked, ids, !ids.every((id) => picked.has(id)))),
|
|
48
|
+
clear: () => {
|
|
49
|
+
anchor = null;
|
|
50
|
+
set(/* @__PURE__ */ new Set());
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export { createSelection, rowsBetween, withRows };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A record's description as a full-size tab. It saves when the editor loses focus. */
|
|
2
|
+
export declare const PanelDescriptionEditor: ({ value, scope, readonly, isHTML, onSave }: {
|
|
3
|
+
value: string;
|
|
4
|
+
scope: string;
|
|
5
|
+
readonly?: boolean;
|
|
6
|
+
/** Stores HTML instead of the editor's blocks. */
|
|
7
|
+
isHTML?: boolean;
|
|
8
|
+
onSave: (description: string) => void;
|
|
9
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { usePageHotkey } from "../../hooks/use-page-hotkey.js";
|
|
2
|
+
import { Editor } from "../blocks/components/LazyEditor.js";
|
|
3
|
+
import { useSaveOnLeave } from "./useSaveOnLeave.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/modules/record-panel/PanelDescriptionEditor.tsx
|
|
6
|
+
/** The editor inside `container`, when it is shown (an inactive tab's panel is `hidden`). */
|
|
7
|
+
const visibleEditor = (container) => {
|
|
8
|
+
const editor = container?.querySelector("[contenteditable=\"true\"]");
|
|
9
|
+
if (!editor?.getClientRects().length) return null;
|
|
10
|
+
return editor.closest("[hidden], [inert]") ? null : editor;
|
|
11
|
+
};
|
|
12
|
+
/** `/` focuses the description editor, unless it is read-only or not shown (another panel's may be). */
|
|
13
|
+
const useSlashFocus = (containerRef, readonly) => usePageHotkey("/", () => visibleEditor(containerRef.current)?.focus(), {
|
|
14
|
+
useKey: true,
|
|
15
|
+
when: () => !readonly && visibleEditor(containerRef.current) !== null
|
|
16
|
+
});
|
|
17
|
+
/** A record's description as a full-size tab. It saves when the editor loses focus. */
|
|
18
|
+
const PanelDescriptionEditor = ({ value, scope, readonly, isHTML, onSave }) => {
|
|
19
|
+
const { containerRef, onChange } = useSaveOnLeave({
|
|
20
|
+
value,
|
|
21
|
+
readonly,
|
|
22
|
+
onSave
|
|
23
|
+
});
|
|
24
|
+
useSlashFocus(containerRef, readonly);
|
|
25
|
+
return /* @__PURE__ */ jsx("div", {
|
|
26
|
+
ref: containerRef,
|
|
27
|
+
className: "flex min-h-0 flex-1 flex-col p-3",
|
|
28
|
+
children: /* @__PURE__ */ jsx(Editor, {
|
|
29
|
+
initialContent: value,
|
|
30
|
+
onChange,
|
|
31
|
+
scope,
|
|
32
|
+
readonly,
|
|
33
|
+
isHTML,
|
|
34
|
+
variant: "default",
|
|
35
|
+
className: "h-full min-h-0 flex-1 [&_.bn-container]:h-full [&_.bn-editor]:min-h-full"
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export { PanelDescriptionEditor };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rich-text description row in the side panel, across its width.
|
|
3
|
+
* Like the other cells it saves when you leave it, never while typing.
|
|
4
|
+
*/
|
|
5
|
+
export declare const PanelDescriptionField: ({ label, value, scope, readonly, isHTML, onSave }: {
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
scope: string;
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
/** Stores HTML instead of the editor's blocks. */
|
|
11
|
+
isHTML?: boolean;
|
|
12
|
+
onSave: (value: string) => void;
|
|
13
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Editor } from "../blocks/components/LazyEditor.js";
|
|
2
|
+
import { useSaveOnLeave } from "./useSaveOnLeave.js";
|
|
3
|
+
import { IconAlignLeft } from "@tabler/icons-react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/modules/record-panel/PanelDescriptionField.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A rich-text description row in the side panel, across its width.
|
|
8
|
+
* Like the other cells it saves when you leave it, never while typing.
|
|
9
|
+
*/
|
|
10
|
+
const PanelDescriptionField = ({ label, value, scope, readonly, isHTML, onSave }) => {
|
|
11
|
+
const { containerRef, onChange } = useSaveOnLeave({
|
|
12
|
+
value,
|
|
13
|
+
readonly,
|
|
14
|
+
onSave
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
17
|
+
className: "flex flex-col gap-1.5 pt-2",
|
|
18
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
19
|
+
className: "flex items-center gap-1.5 text-xs font-medium text-accent-foreground",
|
|
20
|
+
children: [/* @__PURE__ */ jsx(IconAlignLeft, {
|
|
21
|
+
className: "size-3.5 shrink-0",
|
|
22
|
+
"aria-hidden": "true"
|
|
23
|
+
}), label]
|
|
24
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
25
|
+
ref: containerRef,
|
|
26
|
+
children: /* @__PURE__ */ jsx(Editor, {
|
|
27
|
+
initialContent: value,
|
|
28
|
+
onChange,
|
|
29
|
+
scope,
|
|
30
|
+
label,
|
|
31
|
+
readonly,
|
|
32
|
+
isHTML,
|
|
33
|
+
variant: "ghost",
|
|
34
|
+
className: "h-auto min-h-20"
|
|
35
|
+
})
|
|
36
|
+
})]
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export { PanelDescriptionField };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RecordTableInlineCell } from "../record-table/components/RecordTableCellInline.js";
|
|
2
|
+
import { Icon } from "@tabler/icons-react";
|
|
3
|
+
/**
|
|
4
|
+
* A side panel row: icon and label, then the value as a table cell.
|
|
5
|
+
* Click to edit; Enter saves and Escape cancels, as in the list. `cell={false}` keeps a value's
|
|
6
|
+
* own layout, such as an avatar upload.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PanelField: ({ label, icon: Icon, children, placeholder, htmlFor, cell }: {
|
|
9
|
+
label: React.ReactNode;
|
|
10
|
+
icon?: Icon;
|
|
11
|
+
placeholder?: React.ReactNode;
|
|
12
|
+
htmlFor?: string;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
cell?: boolean;
|
|
15
|
+
}) => import("react").JSX.Element;
|
|
16
|
+
/** A table cell trigger with the side panel's rounded hover. */
|
|
17
|
+
export declare const PanelFieldTrigger: (props: React.ComponentProps<typeof RecordTableInlineCell.Trigger>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Label } from "../../components/label.js";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
import { RecordTableInlineCell } from "../record-table/components/RecordTableCellInline.js";
|
|
4
|
+
import { PanelLabel } from "./PanelLabel.js";
|
|
5
|
+
import { IconForms } from "@tabler/icons-react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useId } from "react";
|
|
8
|
+
// src/modules/record-panel/PanelField.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A side panel row: icon and label, then the value as a table cell.
|
|
11
|
+
* Click to edit; Enter saves and Escape cancels, as in the list. `cell={false}` keeps a value's
|
|
12
|
+
* own layout, such as an avatar upload.
|
|
13
|
+
*/
|
|
14
|
+
const PanelField = ({ label, icon: Icon = IconForms, children, placeholder, htmlFor, cell = true }) => {
|
|
15
|
+
const labelId = useId();
|
|
16
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
17
|
+
className: "grid grid-cols-field items-center gap-x-2 min-h-7",
|
|
18
|
+
children: [/* @__PURE__ */ jsxs(Label, {
|
|
19
|
+
id: labelId,
|
|
20
|
+
htmlFor,
|
|
21
|
+
variant: "muted",
|
|
22
|
+
className: "flex min-w-0 items-center",
|
|
23
|
+
children: [Icon && /* @__PURE__ */ jsx(Icon, {
|
|
24
|
+
className: "size-3.5 shrink-0",
|
|
25
|
+
"aria-hidden": "true"
|
|
26
|
+
}), /* @__PURE__ */ jsx(PanelLabel, { children: label })]
|
|
27
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
28
|
+
className: cn("relative min-w-0", cell && "text-xs [&_button:not([role=switch],[data-panel-inline])]:h-7 [&_button:not([role=switch])]:text-xs [&_input]:text-xs"),
|
|
29
|
+
children: [/* @__PURE__ */ jsx(RecordTableInlineCell.LabelledBy, {
|
|
30
|
+
value: labelId,
|
|
31
|
+
children
|
|
32
|
+
}), placeholder && /* @__PURE__ */ jsxs("span", {
|
|
33
|
+
className: "pointer-events-none absolute inset-y-0 left-2 flex items-center gap-1.5 text-xs text-muted-foreground",
|
|
34
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
35
|
+
className: "size-3.5 shrink-0",
|
|
36
|
+
"aria-hidden": "true"
|
|
37
|
+
}), placeholder]
|
|
38
|
+
})]
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
/** A table cell trigger with the side panel's rounded hover. */
|
|
43
|
+
const PanelFieldTrigger = (props) => /* @__PURE__ */ jsx(RecordTableInlineCell.Trigger, {
|
|
44
|
+
variant: "field",
|
|
45
|
+
...props
|
|
46
|
+
});
|
|
47
|
+
export { PanelField, PanelFieldTrigger };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Icon } from "@tabler/icons-react";
|
|
2
|
+
/**
|
|
3
|
+
* One field of a form in the side panel, laid out like `PanelField`.
|
|
4
|
+
* Icon and label, then the control, with its error, or else its hint, under it. A long label wraps to two lines (the
|
|
5
|
+
* full text on hover) instead of being cut. `htmlFor` names the control by its id, so a click
|
|
6
|
+
* on the label focuses it and a switch toggles. The input, select or picker in the row is named
|
|
7
|
+
* by the label and described by the error or hint, and marked invalid and required with it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PanelFormRow: ({ label, icon: Icon, required, error, hint, htmlFor, children }: {
|
|
10
|
+
label: React.ReactNode;
|
|
11
|
+
icon?: Icon;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
error?: string;
|
|
14
|
+
/** What the field takes or does, under the control while it has no error. */
|
|
15
|
+
hint?: React.ReactNode;
|
|
16
|
+
/** The control's id. */
|
|
17
|
+
htmlFor?: string;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
}) => import("react").JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
* A new record's form in the side panel: its rows, then Cancel and Save.
|
|
22
|
+
* Nothing is saved until Save. The first field takes focus when it opens; Enter in a field
|
|
23
|
+
* saves, and Escape cancels (asking first once something was typed).
|
|
24
|
+
*/
|
|
25
|
+
export declare const PanelFormLayout: ({ children, onCancel, saving, saveLabel }: {
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
onCancel: () => void;
|
|
28
|
+
saving?: boolean;
|
|
29
|
+
saveLabel?: string;
|
|
30
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { Button } from "../../components/button.js";
|
|
2
|
+
import { FieldControlContext } from "../../components/field-control.js";
|
|
3
|
+
import { Spinner } from "../../components/spinner.js";
|
|
4
|
+
import { useConfirm } from "../../hooks/use-confirm.js";
|
|
5
|
+
import { useFocusFirstField } from "../../hooks/use-focus-first-field.js";
|
|
6
|
+
import { isOverlayShown } from "../../hooks/use-page-hotkey.js";
|
|
7
|
+
import { RecordTableInlineCell } from "../record-table/components/RecordTableCellInline.js";
|
|
8
|
+
import { PanelLabel } from "./PanelLabel.js";
|
|
9
|
+
import { IconForms } from "@tabler/icons-react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useEffect, useId, useRef } from "react";
|
|
12
|
+
import { useTranslation } from "react-i18next";
|
|
13
|
+
import { useHotkeys } from "react-hotkeys-hook";
|
|
14
|
+
// src/modules/record-panel/PanelForm.tsx
|
|
15
|
+
/**
|
|
16
|
+
* One field of a form in the side panel, laid out like `PanelField`.
|
|
17
|
+
* Icon and label, then the control, with its error, or else its hint, under it. A long label wraps to two lines (the
|
|
18
|
+
* full text on hover) instead of being cut. `htmlFor` names the control by its id, so a click
|
|
19
|
+
* on the label focuses it and a switch toggles. The input, select or picker in the row is named
|
|
20
|
+
* by the label and described by the error or hint, and marked invalid and required with it.
|
|
21
|
+
*/
|
|
22
|
+
const PanelFormRow = ({ label, icon: Icon = IconForms, required, error, hint, htmlFor, children }) => {
|
|
23
|
+
const labelId = useId();
|
|
24
|
+
const messageId = useId();
|
|
25
|
+
const LabelTag = htmlFor ? "label" : "span";
|
|
26
|
+
const field = {
|
|
27
|
+
"aria-labelledby": labelId,
|
|
28
|
+
"aria-describedby": error || hint ? messageId : void 0,
|
|
29
|
+
"aria-invalid": error ? true : void 0,
|
|
30
|
+
"aria-required": required ? true : void 0
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
33
|
+
className: "grid grid-cols-field items-start gap-x-2 gap-y-0.5",
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ jsxs(LabelTag, {
|
|
36
|
+
id: labelId,
|
|
37
|
+
htmlFor,
|
|
38
|
+
className: "flex min-h-7 min-w-0 items-center gap-1.5 text-xs font-medium text-accent-foreground",
|
|
39
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
40
|
+
className: "mt-1.75 size-3.5 shrink-0 self-start",
|
|
41
|
+
"aria-hidden": "true"
|
|
42
|
+
}), /* @__PURE__ */ jsxs(PanelLabel, {
|
|
43
|
+
tooltip: label,
|
|
44
|
+
children: [label, required && /* @__PURE__ */ jsx("span", {
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
className: "text-destructive",
|
|
47
|
+
children: " *"
|
|
48
|
+
})]
|
|
49
|
+
})]
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ jsxs("div", {
|
|
52
|
+
className: "group/panel-value relative flex min-h-7 min-w-0 flex-col justify-center text-xs [&_button:not([role=switch])]:text-xs [&_input]:text-xs [&_input:placeholder-shown]:pl-7",
|
|
53
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
54
|
+
className: "pointer-events-none absolute left-2 top-1/2 z-1 hidden size-3.5 -translate-y-1/2 text-muted-foreground group-has-[input:placeholder-shown]/panel-value:block",
|
|
55
|
+
"aria-hidden": "true"
|
|
56
|
+
}), /* @__PURE__ */ jsx(RecordTableInlineCell.LabelledBy, {
|
|
57
|
+
value: labelId,
|
|
58
|
+
children: /* @__PURE__ */ jsx(FieldControlContext, {
|
|
59
|
+
value: field,
|
|
60
|
+
children
|
|
61
|
+
})
|
|
62
|
+
})]
|
|
63
|
+
}),
|
|
64
|
+
error ? /* @__PURE__ */ jsx("span", {
|
|
65
|
+
id: messageId,
|
|
66
|
+
role: "alert",
|
|
67
|
+
className: "col-start-2 text-xs text-destructive",
|
|
68
|
+
children: error
|
|
69
|
+
}) : hint && /* @__PURE__ */ jsx("span", {
|
|
70
|
+
id: messageId,
|
|
71
|
+
className: "col-start-2 text-xs text-muted-foreground",
|
|
72
|
+
children: hint
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Escape while focus is in the form leaves it, once the member agrees to drop what they typed.
|
|
79
|
+
* Returns the ref for the form's root; `bodyRef` holds its fields. A picker, menu or dialog keeps
|
|
80
|
+
* its own Escape: focus is in its popup then, outside the form.
|
|
81
|
+
*/
|
|
82
|
+
const useEscapeToCancel = (bodyRef, onCancel, saving) => {
|
|
83
|
+
const { t } = useTranslation("common", { keyPrefix: "form" });
|
|
84
|
+
const { confirm } = useConfirm();
|
|
85
|
+
const touched = useRef(false);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
const body = bodyRef.current;
|
|
88
|
+
const onInput = () => {
|
|
89
|
+
touched.current = true;
|
|
90
|
+
};
|
|
91
|
+
body?.addEventListener("input", onInput);
|
|
92
|
+
return () => body?.removeEventListener("input", onInput);
|
|
93
|
+
}, [bodyRef]);
|
|
94
|
+
return useHotkeys("esc", () => {
|
|
95
|
+
if (!touched.current) {
|
|
96
|
+
onCancel();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
confirm({
|
|
100
|
+
message: t("discard-title", "Discard this draft?"),
|
|
101
|
+
options: {
|
|
102
|
+
description: t("discard-description", "What you typed here is not saved."),
|
|
103
|
+
okLabel: t("discard", "Discard"),
|
|
104
|
+
cancelLabel: t("keep-editing", "Keep editing"),
|
|
105
|
+
variants: { ok: "destructive" }
|
|
106
|
+
}
|
|
107
|
+
}).then(onCancel);
|
|
108
|
+
}, {
|
|
109
|
+
enableOnFormTags: true,
|
|
110
|
+
enableOnContentEditable: true,
|
|
111
|
+
preventDefault: true,
|
|
112
|
+
ignoreEventWhen: (event) => Boolean(saving) || event.defaultPrevented || isOverlayShown(bodyRef.current)
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* A new record's form in the side panel: its rows, then Cancel and Save.
|
|
117
|
+
* Nothing is saved until Save. The first field takes focus when it opens; Enter in a field
|
|
118
|
+
* saves, and Escape cancels (asking first once something was typed).
|
|
119
|
+
*/
|
|
120
|
+
const PanelFormLayout = ({ children, onCancel, saving, saveLabel }) => {
|
|
121
|
+
const { t } = useTranslation("common", { keyPrefix: "side-panel" });
|
|
122
|
+
const bodyRef = useRef(null);
|
|
123
|
+
const rootRef = useEscapeToCancel(bodyRef, onCancel, saving);
|
|
124
|
+
useFocusFirstField(bodyRef);
|
|
125
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
126
|
+
ref: rootRef,
|
|
127
|
+
className: "flex flex-1 min-h-0 flex-col",
|
|
128
|
+
"aria-busy": saving ? true : void 0,
|
|
129
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
130
|
+
ref: bodyRef,
|
|
131
|
+
className: "flex-1 min-h-0 overflow-y-auto",
|
|
132
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
133
|
+
className: "flex flex-col gap-1 p-3",
|
|
134
|
+
children
|
|
135
|
+
})
|
|
136
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
137
|
+
className: "flex shrink-0 justify-end gap-1 border-t bg-background p-2",
|
|
138
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
139
|
+
type: "button",
|
|
140
|
+
variant: "ghost",
|
|
141
|
+
size: "sm",
|
|
142
|
+
disabled: saving,
|
|
143
|
+
onClick: onCancel,
|
|
144
|
+
children: t("cancel", "Cancel")
|
|
145
|
+
}), /* @__PURE__ */ jsxs(Button, {
|
|
146
|
+
type: "submit",
|
|
147
|
+
size: "sm",
|
|
148
|
+
disabled: saving,
|
|
149
|
+
children: [saving && /* @__PURE__ */ jsx(Spinner, { size: "sm" }), saveLabel || t("save", "Save")]
|
|
150
|
+
})]
|
|
151
|
+
})]
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
export { PanelFormLayout, PanelFormRow };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A side panel label cut at two lines, with the full text on hover.
|
|
3
|
+
* On the record's own page (`usePanelExpanded`) it shows in full. `tooltip` replaces the hover
|
|
4
|
+
* text.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PanelLabel: ({ children, tooltip, className }: {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
tooltip?: React.ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Tooltip } from "../../components/tooltip.js";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
import { usePanelExpanded } from "./panelExpansion.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useEffect, useRef, useState } from "react";
|
|
6
|
+
// src/modules/record-panel/PanelLabel.tsx
|
|
7
|
+
/** Whether the label is cut off; the observers see the clamp come and go with the panel width. */
|
|
8
|
+
const useIsClamped = () => {
|
|
9
|
+
const ref = useRef(null);
|
|
10
|
+
const [isClamped, setIsClamped] = useState(false);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const element = ref.current;
|
|
13
|
+
if (!element) return;
|
|
14
|
+
const check = () => setIsClamped(element.scrollHeight > element.clientHeight + 1);
|
|
15
|
+
const resizeObserver = new ResizeObserver(check);
|
|
16
|
+
const contentObserver = new MutationObserver(check);
|
|
17
|
+
check();
|
|
18
|
+
resizeObserver.observe(element);
|
|
19
|
+
contentObserver.observe(element, {
|
|
20
|
+
childList: true,
|
|
21
|
+
subtree: true,
|
|
22
|
+
characterData: true
|
|
23
|
+
});
|
|
24
|
+
return () => {
|
|
25
|
+
resizeObserver.disconnect();
|
|
26
|
+
contentObserver.disconnect();
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
return {
|
|
30
|
+
ref,
|
|
31
|
+
isClamped
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A side panel label cut at two lines, with the full text on hover.
|
|
36
|
+
* On the record's own page (`usePanelExpanded`) it shows in full. `tooltip` replaces the hover
|
|
37
|
+
* text.
|
|
38
|
+
*/
|
|
39
|
+
const PanelLabel = ({ children, tooltip, className }) => {
|
|
40
|
+
const expanded = usePanelExpanded();
|
|
41
|
+
const { ref, isClamped } = useIsClamped();
|
|
42
|
+
const showTooltip = isClamped && !expanded;
|
|
43
|
+
return /* @__PURE__ */ jsx(Tooltip.Provider, {
|
|
44
|
+
delay: 100,
|
|
45
|
+
children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(Tooltip.Trigger, {
|
|
46
|
+
render: /* @__PURE__ */ jsx("span", { className: cn("my-1 block min-w-0 wrap-break-word", className) }),
|
|
47
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
48
|
+
ref,
|
|
49
|
+
className: cn("block", !expanded && "line-clamp-2"),
|
|
50
|
+
children
|
|
51
|
+
})
|
|
52
|
+
}), showTooltip && /* @__PURE__ */ jsx(Tooltip.Content, { children: tooltip ?? children })] })
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export { PanelLabel };
|