@godxjp/ui 6.0.0 → 6.0.2
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/dist/app/index.d.ts +140 -0
- package/dist/app/index.js +38 -0
- package/dist/app.prop-IobwLwaM.d.ts +90 -0
- package/dist/checkbox-NkFkqsQ8.d.ts +13 -0
- package/dist/chunk-2XW7J3EI.js +226 -0
- package/dist/chunk-3F2AKYRD.js +416 -0
- package/dist/chunk-3KPEZ5CF.js +37 -0
- package/dist/chunk-3UGU5TYP.js +89 -0
- package/{src/props/registry.ts → dist/chunk-6RA3KSVK.js} +118 -133
- package/dist/chunk-7NZFVD24.js +122 -0
- package/dist/chunk-7PWBC4BY.js +25 -0
- package/dist/chunk-7S7MYFXE.js +61 -0
- package/dist/chunk-7WRZG2IG.js +71 -0
- package/dist/chunk-B775Y6BE.js +1 -0
- package/dist/chunk-BHV2FUOA.js +111 -0
- package/dist/chunk-BI3HERR7.js +70 -0
- package/dist/chunk-BPSKQUL2.js +68 -0
- package/dist/chunk-CDWPQ5RP.js +187 -0
- package/dist/chunk-CP2LET6N.js +244 -0
- package/dist/chunk-CQBADMFG.js +20 -0
- package/dist/chunk-CRERCLIZ.js +33 -0
- package/dist/chunk-DU6ZYZRP.js +238 -0
- package/dist/chunk-DY5C44UP.js +55 -0
- package/dist/chunk-E4HJNQ62.js +117 -0
- package/dist/chunk-E76QIYSY.js +93 -0
- package/dist/chunk-F7PG4OEV.js +37 -0
- package/dist/chunk-GDSVW62T.js +171 -0
- package/dist/chunk-H2FHJOLU.js +178 -0
- package/dist/chunk-HJEBRCXL.js +55 -0
- package/dist/chunk-ICM6XBST.js +16 -0
- package/{src/components/data-entry/calendar.tsx → dist/chunk-IK7I3ABN.js} +33 -35
- package/dist/chunk-L6J44O74.js +144 -0
- package/dist/chunk-LDSLS6HE.js +1 -0
- package/dist/chunk-LVNUHUEZ.js +191 -0
- package/dist/chunk-M64MVRLS.js +92 -0
- package/dist/chunk-NGQW3KEM.js +402 -0
- package/dist/chunk-NZ4FOC5N.js +559 -0
- package/dist/chunk-PIIRNAXA.js +26 -0
- package/dist/chunk-S66TJXJU.js +33 -0
- package/dist/chunk-SMLKNECP.js +133 -0
- package/dist/chunk-TAHBM3F2.js +66 -0
- package/dist/chunk-TO33OY4L.js +150 -0
- package/dist/chunk-TO7URV7U.js +51 -0
- package/dist/chunk-TOO5AEKL.js +81 -0
- package/dist/chunk-U3GHAOIJ.js +299 -0
- package/dist/chunk-U7N2A7A3.js +9 -0
- package/dist/chunk-UX634MYF.js +123 -0
- package/dist/chunk-V6UWJKZF.js +28 -0
- package/{src/components/data-entry/input.tsx → dist/chunk-VOHTRR5X.js} +18 -16
- package/dist/chunk-WRFKVUPW.js +332 -0
- package/dist/chunk-WXW43RK5.js +24 -0
- package/{src/components/navigation/tabs.tsx → dist/chunk-XG7XDYIM.js} +46 -53
- package/dist/chunk-YFCQKO3B.js +842 -0
- package/dist/chunk-ZDWXGWLY.js +73 -0
- package/dist/chunk-ZLK5SPT6.js +11 -0
- package/dist/chunk-ZS6DTAM2.js +31 -0
- package/dist/chunk-ZT5UEUBO.js +1 -0
- package/dist/components/admin/index.d.ts +80 -0
- package/dist/components/admin/index.js +38 -0
- package/dist/components/data-display/badge.d.ts +12 -0
- package/dist/components/data-display/badge.js +3 -0
- package/dist/components/data-display/card.d.ts +87 -0
- package/dist/components/data-display/card.js +2 -0
- package/dist/components/data-display/index.d.ts +72 -0
- package/dist/components/data-display/index.js +89 -0
- package/dist/components/data-display/popover.d.ts +13 -0
- package/dist/components/data-display/popover.js +2 -0
- package/dist/components/data-display/scroll-area.d.ts +7 -0
- package/dist/components/data-display/scroll-area.js +2 -0
- package/dist/components/data-display/table.d.ts +10 -0
- package/dist/components/data-display/table.js +3 -0
- package/dist/components/data-entry/autocomplete.d.ts +16 -0
- package/dist/components/data-entry/autocomplete.js +8 -0
- package/dist/components/data-entry/calendar.d.ts +16 -0
- package/dist/components/data-entry/calendar.js +4 -0
- package/dist/components/data-entry/cascader.d.ts +32 -0
- package/dist/components/data-entry/cascader.js +13 -0
- package/dist/components/data-entry/checkbox.d.ts +13 -0
- package/dist/components/data-entry/checkbox.js +4 -0
- package/dist/components/data-entry/color-picker.d.ts +16 -0
- package/dist/components/data-entry/color-picker.js +6 -0
- package/dist/components/data-entry/command.d.ts +69 -0
- package/dist/components/data-entry/command.js +3 -0
- package/dist/components/data-entry/date-picker.d.ts +16 -0
- package/dist/components/data-entry/date-picker.js +8 -0
- package/dist/components/data-entry/date-range-picker.d.ts +16 -0
- package/dist/components/data-entry/date-range-picker.js +8 -0
- package/dist/components/data-entry/index.d.ts +53 -0
- package/dist/components/data-entry/index.js +152 -0
- package/dist/components/data-entry/input.d.ts +6 -0
- package/dist/components/data-entry/input.js +2 -0
- package/dist/components/data-entry/label.d.ts +8 -0
- package/dist/components/data-entry/label.js +2 -0
- package/dist/components/data-entry/radio.d.ts +24 -0
- package/dist/components/data-entry/radio.js +4 -0
- package/dist/components/data-entry/select.d.ts +18 -0
- package/dist/components/data-entry/select.js +3 -0
- package/dist/components/data-entry/slider.d.ts +16 -0
- package/dist/components/data-entry/slider.js +2 -0
- package/dist/components/data-entry/switch.d.ts +17 -0
- package/dist/components/data-entry/switch.js +2 -0
- package/dist/components/data-entry/textarea.d.ts +6 -0
- package/dist/components/data-entry/textarea.js +3 -0
- package/dist/components/data-entry/time-picker.d.ts +16 -0
- package/dist/components/data-entry/time-picker.js +7 -0
- package/dist/components/data-entry/transfer.d.ts +17 -0
- package/dist/components/data-entry/transfer.js +11 -0
- package/dist/components/data-entry/tree-select.d.ts +26 -0
- package/dist/components/data-entry/tree-select.js +13 -0
- package/dist/components/data-entry/upload.d.ts +42 -0
- package/dist/components/data-entry/upload.js +11 -0
- package/dist/components/feedback/alert.d.ts +60 -0
- package/dist/components/feedback/alert.js +7 -0
- package/dist/components/feedback/dialog.d.ts +64 -0
- package/dist/components/feedback/dialog.js +7 -0
- package/dist/components/feedback/index.d.ts +16 -0
- package/dist/components/feedback/index.js +14 -0
- package/dist/components/feedback/sheet.d.ts +24 -0
- package/dist/components/feedback/sheet.js +2 -0
- package/dist/components/feedback/sonner.d.ts +6 -0
- package/dist/components/feedback/sonner.js +1 -0
- package/dist/components/general/button.d.ts +20 -0
- package/dist/components/general/button.js +2 -0
- package/dist/components/general/index.d.ts +6 -0
- package/dist/components/general/index.js +2 -0
- package/dist/components/layout/index.d.ts +71 -0
- package/dist/components/layout/index.js +5 -0
- package/dist/components/navigation/dropdown-menu.d.ts +28 -0
- package/dist/components/navigation/dropdown-menu.js +2 -0
- package/dist/components/navigation/index.d.ts +32 -0
- package/dist/components/navigation/index.js +12 -0
- package/dist/components/navigation/pagination.d.ts +11 -0
- package/dist/components/navigation/pagination.js +7 -0
- package/dist/components/navigation/steps.d.ts +12 -0
- package/dist/components/navigation/steps.js +3 -0
- package/dist/components/navigation/tabs-items.d.ts +12 -0
- package/dist/components/navigation/tabs-items.js +3 -0
- package/dist/components/navigation/tabs.d.ts +12 -0
- package/dist/components/navigation/tabs.js +2 -0
- package/dist/components/query/index.d.ts +43 -0
- package/dist/components/query/index.js +8 -0
- package/dist/components/ui/index.d.ts +57 -0
- package/dist/components/ui/index.js +37 -0
- package/{src/props/vocabulary/content.prop.ts → dist/content.prop-D1Dd3TAc.d.ts} +16 -20
- package/dist/data-display.prop-DNTAzmDy.d.ts +58 -0
- package/dist/data-entry.prop-BEGA1lTq.d.ts +323 -0
- package/dist/data-table-D1u_rKLK.d.ts +83 -0
- package/dist/data.prop-BVvfKC_g.d.ts +41 -0
- package/dist/feedback.prop-BmxUlpAW.d.ts +64 -0
- package/dist/filter-bar-B7OGFO9S.d.ts +10 -0
- package/dist/form/index.d.ts +21 -0
- package/dist/form/index.js +4 -0
- package/dist/form.prop-BHgpuFFm.d.ts +41 -0
- package/dist/format-date-ByyZoqI5.d.ts +51 -0
- package/dist/general.prop-D7brMPNL.d.ts +16 -0
- package/dist/i18n/index.d.ts +217 -0
- package/dist/i18n/index.js +2 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +39 -0
- package/dist/inline-C5u6ptJV.d.ts +10 -0
- package/dist/interaction.prop-Cdn7wOtq.d.ts +25 -0
- package/{src/props/vocabulary/layout.prop.ts → dist/layout.prop-4TCNvyQZ.d.ts} +9 -14
- package/dist/layout.prop-C795F0qg.d.ts +112 -0
- package/dist/lib/datetime/index.d.ts +31 -0
- package/dist/lib/datetime/index.js +1 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.js +1 -0
- package/dist/navigation.prop-DpZqcXey.d.ts +78 -0
- package/dist/navigation.prop-DxBiClEH.d.ts +20 -0
- package/dist/props/components/index.d.ts +27 -0
- package/dist/props/components/index.js +1 -0
- package/dist/props/index.d.ts +28 -0
- package/dist/props/index.js +3 -0
- package/dist/props/registry.d.ts +649 -0
- package/dist/props/registry.js +1 -0
- package/dist/props/vocabulary/index.d.ts +7 -0
- package/dist/props/vocabulary/index.js +1 -0
- package/dist/query.prop-hIPrk2zI.d.ts +71 -0
- package/dist/search-input-uP01rY1L.d.ts +22 -0
- package/dist/shared.prop-BNRJc9K0.d.ts +45 -0
- package/{src → dist}/styles/control.css +1 -1
- package/dist/types-mvzYGrma.d.ts +37 -0
- package/dist/use-toast-Dol5bdY3.d.ts +34 -0
- package/package.json +234 -68
- package/src/app/__tests__/app-provider.test.tsx +0 -232
- package/src/app/__tests__/date-format-labels.test.ts +0 -36
- package/src/app/__tests__/date-formats.test.ts +0 -44
- package/src/app/__tests__/timezones.test.ts +0 -65
- package/src/app/app-provider.tsx +0 -227
- package/src/app/date-format-labels.ts +0 -21
- package/src/app/date-formats.ts +0 -30
- package/src/app/index.ts +0 -40
- package/src/app/locales.ts +0 -32
- package/src/app/request-headers.ts +0 -31
- package/src/app/storage.ts +0 -44
- package/src/app/time-format-labels.ts +0 -19
- package/src/app/time-formats.ts +0 -15
- package/src/app/timezones.ts +0 -208
- package/src/app/types.ts +0 -39
- package/src/app/use-formatting.ts +0 -47
- package/src/components/__tests__/accessibility-primitives.test.tsx +0 -65
- package/src/components/__tests__/docs-parity.test.ts +0 -41
- package/src/components/__tests__/shadcn-release-guardrails.test.ts +0 -71
- package/src/components/__tests__/theme-axes-integration.test.tsx +0 -242
- package/src/components/admin/index.ts +0 -76
- package/src/components/data-display/__tests__/card-table.test.tsx +0 -328
- package/src/components/data-display/__tests__/data-display.test.tsx +0 -73
- package/src/components/data-display/__tests__/data-table.test.tsx +0 -84
- package/src/components/data-display/__tests__/popover.test.tsx +0 -92
- package/src/components/data-display/__tests__/scroll-area-collapsible.test.tsx +0 -66
- package/src/components/data-display/badge.tsx +0 -27
- package/src/components/data-display/card.tsx +0 -194
- package/src/components/data-display/code-badge.tsx +0 -28
- package/src/components/data-display/collapsible.tsx +0 -5
- package/src/components/data-display/data-table.tsx +0 -476
- package/src/components/data-display/empty-state.tsx +0 -22
- package/src/components/data-display/index.ts +0 -41
- package/src/components/data-display/key-value-grid.tsx +0 -46
- package/src/components/data-display/popover.tsx +0 -62
- package/src/components/data-display/progress-meter.tsx +0 -20
- package/src/components/data-display/scan-panel.tsx +0 -16
- package/src/components/data-display/scroll-area.tsx +0 -42
- package/src/components/data-display/status-badge.tsx +0 -83
- package/src/components/data-display/table.tsx +0 -59
- package/src/components/data-display/timeline.tsx +0 -42
- package/src/components/data-display/tree-list.tsx +0 -42
- package/src/components/data-entry/__fixtures__/tree-options.ts +0 -80
- package/src/components/data-entry/__tests__/cascader-tree-transfer.test.tsx +0 -417
- package/src/components/data-entry/__tests__/checkbox-group.test.tsx +0 -40
- package/src/components/data-entry/__tests__/checkbox.test.tsx +0 -20
- package/src/components/data-entry/__tests__/date-autocomplete.test.tsx +0 -94
- package/src/components/data-entry/__tests__/form-field.test.tsx +0 -49
- package/src/components/data-entry/__tests__/input-textarea.test.tsx +0 -38
- package/src/components/data-entry/__tests__/label-select.test.tsx +0 -62
- package/src/components/data-entry/__tests__/pickers.test.tsx +0 -74
- package/src/components/data-entry/__tests__/radio.test.tsx +0 -46
- package/src/components/data-entry/__tests__/search-input.test.tsx +0 -32
- package/src/components/data-entry/__tests__/switch-field.test.tsx +0 -52
- package/src/components/data-entry/__tests__/upload.test.tsx +0 -125
- package/src/components/data-entry/autocomplete.tsx +0 -91
- package/src/components/data-entry/cascader.tsx +0 -305
- package/src/components/data-entry/checkbox-group.tsx +0 -90
- package/src/components/data-entry/checkbox.tsx +0 -30
- package/src/components/data-entry/choice-field.tsx +0 -27
- package/src/components/data-entry/choice-option.ts +0 -20
- package/src/components/data-entry/color-picker.tsx +0 -75
- package/src/components/data-entry/command.tsx +0 -56
- package/src/components/data-entry/country-select.tsx +0 -88
- package/src/components/data-entry/date-picker.tsx +0 -69
- package/src/components/data-entry/date-range-picker.tsx +0 -75
- package/src/components/data-entry/form-field.tsx +0 -59
- package/src/components/data-entry/index.ts +0 -62
- package/src/components/data-entry/label.tsx +0 -25
- package/src/components/data-entry/radio.tsx +0 -109
- package/src/components/data-entry/search-input.tsx +0 -103
- package/src/components/data-entry/select.tsx +0 -149
- package/src/components/data-entry/slider.tsx +0 -38
- package/src/components/data-entry/switch-field.tsx +0 -91
- package/src/components/data-entry/switch.tsx +0 -24
- package/src/components/data-entry/textarea.tsx +0 -12
- package/src/components/data-entry/time-picker.tsx +0 -214
- package/src/components/data-entry/transfer.tsx +0 -231
- package/src/components/data-entry/tree-select-strategy.ts +0 -6
- package/src/components/data-entry/tree-select.tsx +0 -279
- package/src/components/data-entry/tree-utils.ts +0 -221
- package/src/components/data-entry/upload-crop-dialog.tsx +0 -109
- package/src/components/data-entry/upload-types.ts +0 -86
- package/src/components/data-entry/upload.tsx +0 -498
- package/src/components/data-entry/use-upload-draft.ts +0 -93
- package/src/components/feedback/__tests__/alert.test.tsx +0 -127
- package/src/components/feedback/__tests__/dialog.test.tsx +0 -290
- package/src/components/feedback/__tests__/sheet.test.tsx +0 -94
- package/src/components/feedback/__tests__/skeleton.test.tsx +0 -25
- package/src/components/feedback/__tests__/toast.test.tsx +0 -52
- package/src/components/feedback/alert.tsx +0 -167
- package/src/components/feedback/dialog.tsx +0 -325
- package/src/components/feedback/index.ts +0 -53
- package/src/components/feedback/sheet.tsx +0 -130
- package/src/components/feedback/skeleton.tsx +0 -95
- package/src/components/feedback/sonner.tsx +0 -54
- package/src/components/feedback/toaster.tsx +0 -1
- package/src/components/feedback/use-toast.ts +0 -62
- package/src/components/general/__tests__/button.test.tsx +0 -71
- package/src/components/general/button.tsx +0 -61
- package/src/components/general/index.ts +0 -2
- package/src/components/layout/__tests__/page-container.test.tsx +0 -69
- package/src/components/layout/__tests__/page-inset.test.tsx +0 -14
- package/src/components/layout/__tests__/stack-inline.test.tsx +0 -39
- package/src/components/layout/app-shell.tsx +0 -42
- package/src/components/layout/breadcrumb.tsx +0 -35
- package/src/components/layout/index.ts +0 -31
- package/src/components/layout/inline.tsx +0 -13
- package/src/components/layout/menu.tsx +0 -34
- package/src/components/layout/mobile-frame.tsx +0 -57
- package/src/components/layout/page-container.tsx +0 -81
- package/src/components/layout/page-inset.tsx +0 -16
- package/src/components/layout/responsive-grid.tsx +0 -14
- package/src/components/layout/shell-app.tsx +0 -30
- package/src/components/layout/sidebar.tsx +0 -98
- package/src/components/layout/split-pane.tsx +0 -16
- package/src/components/layout/stack.tsx +0 -13
- package/src/components/layout/topbar.tsx +0 -108
- package/src/components/navigation/__tests__/app-pickers.test.tsx +0 -118
- package/src/components/navigation/__tests__/dropdown-menu.test.tsx +0 -104
- package/src/components/navigation/__tests__/navigation.test.tsx +0 -61
- package/src/components/navigation/__tests__/pagination-steps-tabs.test.tsx +0 -76
- package/src/components/navigation/date-format-picker.tsx +0 -55
- package/src/components/navigation/dropdown-menu.tsx +0 -190
- package/src/components/navigation/filter-bar.tsx +0 -38
- package/src/components/navigation/index.ts +0 -28
- package/src/components/navigation/locale-picker.tsx +0 -49
- package/src/components/navigation/page-header.tsx +0 -50
- package/src/components/navigation/pagination-utils.ts +0 -35
- package/src/components/navigation/pagination.tsx +0 -168
- package/src/components/navigation/steps.tsx +0 -163
- package/src/components/navigation/tabs-items.tsx +0 -69
- package/src/components/navigation/time-format-picker.tsx +0 -55
- package/src/components/navigation/timezone-picker.tsx +0 -63
- package/src/components/query/__tests__/data-state.test.tsx +0 -214
- package/src/components/query/__tests__/infinite-prefetch.test.tsx +0 -105
- package/src/components/query/__tests__/query-helpers.test.tsx +0 -61
- package/src/components/query/data-state.tsx +0 -58
- package/src/components/query/index.ts +0 -10
- package/src/components/query/infinite-query-state.tsx +0 -99
- package/src/components/query/mutation-feedback.tsx +0 -31
- package/src/components/query/prefetch-link.tsx +0 -45
- package/src/components/query/query-refetch-button.tsx +0 -41
- package/src/components/ui/alert-dialog.tsx +0 -1
- package/src/components/ui/alert.tsx +0 -1
- package/src/components/ui/autocomplete.tsx +0 -1
- package/src/components/ui/badge.tsx +0 -1
- package/src/components/ui/button.tsx +0 -1
- package/src/components/ui/calendar.tsx +0 -1
- package/src/components/ui/card.tsx +0 -1
- package/src/components/ui/checkbox.tsx +0 -1
- package/src/components/ui/color-picker.tsx +0 -1
- package/src/components/ui/command.tsx +0 -1
- package/src/components/ui/date-picker.tsx +0 -1
- package/src/components/ui/date-range-picker.tsx +0 -1
- package/src/components/ui/dialog.tsx +0 -1
- package/src/components/ui/dropdown-menu.tsx +0 -1
- package/src/components/ui/index.tsx +0 -31
- package/src/components/ui/input.tsx +0 -1
- package/src/components/ui/label.tsx +0 -1
- package/src/components/ui/pagination.tsx +0 -1
- package/src/components/ui/popover.tsx +0 -1
- package/src/components/ui/radio.tsx +0 -1
- package/src/components/ui/scroll-area.tsx +0 -1
- package/src/components/ui/select.tsx +0 -1
- package/src/components/ui/sheet.tsx +0 -1
- package/src/components/ui/slider.tsx +0 -1
- package/src/components/ui/sonner.tsx +0 -1
- package/src/components/ui/switch.tsx +0 -1
- package/src/components/ui/table.tsx +0 -1
- package/src/components/ui/tabs-items.tsx +0 -1
- package/src/components/ui/tabs.tsx +0 -1
- package/src/components/ui/textarea.tsx +0 -1
- package/src/components/ui/time-picker.tsx +0 -1
- package/src/components/ui/upload.tsx +0 -1
- package/src/form/__tests__/use-zod-form.test.tsx +0 -97
- package/src/form/form-field-control.tsx +0 -44
- package/src/form/form-root.tsx +0 -29
- package/src/form/index.ts +0 -7
- package/src/form/use-zod-form.ts +0 -29
- package/src/i18n/__tests__/translate.test.ts +0 -23
- package/src/i18n/index.ts +0 -9
- package/src/i18n/messages/en.json +0 -171
- package/src/i18n/messages/ja.json +0 -171
- package/src/i18n/messages/vi.json +0 -171
- package/src/i18n/translate.ts +0 -74
- package/src/i18n/use-translation.ts +0 -53
- package/src/index.ts +0 -3
- package/src/lib/__tests__/control-styles.test.ts +0 -78
- package/src/lib/__tests__/datetime.test.ts +0 -77
- package/src/lib/__tests__/format-date.test.ts +0 -97
- package/src/lib/__tests__/format.test.ts +0 -62
- package/src/lib/__tests__/theme-tokens-audit.test.ts +0 -176
- package/src/lib/__tests__/theme-tokens-css.test.ts +0 -118
- package/src/lib/__tests__/token-governance.test.ts +0 -191
- package/src/lib/__tests__/variants.test.ts +0 -18
- package/src/lib/control-styles.ts +0 -33
- package/src/lib/datetime/detect.ts +0 -25
- package/src/lib/datetime/format-date.ts +0 -100
- package/src/lib/datetime/format.ts +0 -140
- package/src/lib/datetime/index.ts +0 -25
- package/src/lib/datetime/parse.ts +0 -51
- package/src/lib/datetime/sync.ts +0 -48
- package/src/lib/format.ts +0 -114
- package/src/lib/hooks.ts +0 -54
- package/src/lib/utils.ts +0 -6
- package/src/lib/variants.ts +0 -40
- package/src/props/components/app.prop.ts +0 -99
- package/src/props/components/data-display.prop.ts +0 -73
- package/src/props/components/data-entry.prop.ts +0 -334
- package/src/props/components/feedback.prop.ts +0 -80
- package/src/props/components/form.prop.ts +0 -46
- package/src/props/components/general.prop.ts +0 -18
- package/src/props/components/index.ts +0 -99
- package/src/props/components/layout.prop.ts +0 -130
- package/src/props/components/navigation.prop.ts +0 -88
- package/src/props/components/query.prop.ts +0 -94
- package/src/props/index.ts +0 -17
- package/src/props/vocabulary/data.prop.ts +0 -46
- package/src/props/vocabulary/index.ts +0 -73
- package/src/props/vocabulary/interaction.prop.ts +0 -42
- package/src/props/vocabulary/navigation.prop.ts +0 -19
- package/src/props/vocabulary/shared.prop.ts +0 -59
- package/src/test/__tests__/render-loop-guard.test.tsx +0 -38
- package/src/test/jest-dom.d.ts +0 -4
- package/src/test/render-loop-guard.tsx +0 -50
- package/src/test/render.tsx +0 -29
- package/src/test/theme-globals.test.ts +0 -77
- package/src/test/theme-globals.ts +0 -134
- package/src/test/theme-test-utils.tsx +0 -67
- /package/{src → dist}/styles/alert-layout.css +0 -0
- /package/{src → dist}/styles/badge-layout.css +0 -0
- /package/{src → dist}/styles/card-layout.css +0 -0
- /package/{src → dist}/styles/data-display-layout.css +0 -0
- /package/{src → dist}/styles/density.css +0 -0
- /package/{src → dist}/styles/dialog-layout.css +0 -0
- /package/{src → dist}/styles/index.css +0 -0
- /package/{src → dist}/styles/layout.css +0 -0
- /package/{src → dist}/styles/shell-layout.css +0 -0
- /package/{src → dist}/styles/table-layout.css +0 -0
- /package/{src → dist}/theme/example.service.css +0 -0
- /package/{src → dist}/tokens/base.css +0 -0
- /package/{src → dist}/tokens/foundation.css +0 -0
- /package/{src → dist}/tokens/primitives/badge.css +0 -0
- /package/{src → dist}/tokens/primitives/card.css +0 -0
- /package/{src → dist}/tokens/primitives/control.css +0 -0
- /package/{src → dist}/tokens/primitives/feedback.css +0 -0
- /package/{src → dist}/tokens/primitives/layout.css +0 -0
- /package/{src → dist}/tokens/primitives/navigation.css +0 -0
- /package/{src → dist}/tokens/primitives/table.css +0 -0
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { ChevronDown, ChevronRight, ChevronsUpDown, X } from "lucide-react";
|
|
3
|
-
|
|
4
|
-
import { useTranslation } from "../../i18n/use-translation";
|
|
5
|
-
import { cn } from "../../lib/utils";
|
|
6
|
-
import { Button } from "../general/button";
|
|
7
|
-
import { Popover, PopoverContent, PopoverTrigger } from "../data-display/popover";
|
|
8
|
-
import { ScrollArea } from "../data-display/scroll-area";
|
|
9
|
-
import { Checkbox } from "./checkbox";
|
|
10
|
-
import { Command, CommandInput } from "./command";
|
|
11
|
-
import {
|
|
12
|
-
collectAllExpandableKeys,
|
|
13
|
-
filterVisibleTree,
|
|
14
|
-
findNodeByValue,
|
|
15
|
-
flattenVisibleTree,
|
|
16
|
-
getDescendantValues,
|
|
17
|
-
normalizeTreeOptions,
|
|
18
|
-
reactNodeText,
|
|
19
|
-
type NormalizedTreeOption,
|
|
20
|
-
} from "./tree-utils";
|
|
21
|
-
import type { TreeSelectProp } from "../../props/components/data-entry.prop";
|
|
22
|
-
|
|
23
|
-
export type {
|
|
24
|
-
TreeSelectProp,
|
|
25
|
-
TreeSelectProp as TreeSelectProps,
|
|
26
|
-
} from "../../props/components/data-entry.prop";
|
|
27
|
-
export { SHOW_CHILD, SHOW_PARENT, SHOW_ALL } from "./tree-select-strategy";
|
|
28
|
-
|
|
29
|
-
import { SHOW_CHILD, SHOW_PARENT, SHOW_ALL } from "./tree-select-strategy";
|
|
30
|
-
|
|
31
|
-
function toArray(value: string | string[] | undefined): string[] {
|
|
32
|
-
if (value == null) return [];
|
|
33
|
-
return Array.isArray(value) ? value : [value];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function displayValues(
|
|
37
|
-
values: string[],
|
|
38
|
-
options: NormalizedTreeOption[],
|
|
39
|
-
showCheckedStrategy: TreeSelectProp["showCheckedStrategy"],
|
|
40
|
-
treeCheckStrictly?: boolean,
|
|
41
|
-
): string[] {
|
|
42
|
-
if (treeCheckStrictly || showCheckedStrategy === SHOW_ALL) return values;
|
|
43
|
-
if (showCheckedStrategy === SHOW_PARENT) {
|
|
44
|
-
const filtered = values.filter((v) => {
|
|
45
|
-
const node = findNodeByValue(options, v);
|
|
46
|
-
if (!node?.children?.length) return true;
|
|
47
|
-
const desc = getDescendantValues(node).slice(1);
|
|
48
|
-
return !desc.every((d) => values.includes(d));
|
|
49
|
-
});
|
|
50
|
-
return filtered.length ? filtered : values;
|
|
51
|
-
}
|
|
52
|
-
// SHOW_CHILD — hide parent when all children selected
|
|
53
|
-
return values.filter((v) => {
|
|
54
|
-
const node = findNodeByValue(options, v);
|
|
55
|
-
return !node?.children?.length;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function TreeSelectRoot({
|
|
60
|
-
treeData: treeDataProp,
|
|
61
|
-
value,
|
|
62
|
-
defaultValue,
|
|
63
|
-
onChange,
|
|
64
|
-
multiple,
|
|
65
|
-
treeCheckable,
|
|
66
|
-
treeCheckStrictly,
|
|
67
|
-
showSearch,
|
|
68
|
-
showCheckedStrategy = SHOW_CHILD,
|
|
69
|
-
treeDefaultExpandAll,
|
|
70
|
-
placeholder,
|
|
71
|
-
disabled,
|
|
72
|
-
allowClear = true,
|
|
73
|
-
className,
|
|
74
|
-
id,
|
|
75
|
-
fieldNames,
|
|
76
|
-
}: TreeSelectProp) {
|
|
77
|
-
const { t } = useTranslation();
|
|
78
|
-
const options = React.useMemo(
|
|
79
|
-
() => normalizeTreeOptions(treeDataProp as Record<string, unknown>[], fieldNames),
|
|
80
|
-
[treeDataProp, fieldNames],
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const checkable = treeCheckable ?? multiple;
|
|
84
|
-
const [open, setOpen] = React.useState(false);
|
|
85
|
-
const [search, setSearch] = React.useState("");
|
|
86
|
-
const [expandedKeys, setExpandedKeys] = React.useState<Set<string>>(
|
|
87
|
-
() => new Set(treeDefaultExpandAll ? collectAllExpandableKeys(options) : []),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const isControlled = value !== undefined;
|
|
91
|
-
const [internal, setInternal] = React.useState<string[]>(() => toArray(defaultValue));
|
|
92
|
-
|
|
93
|
-
const selected = isControlled ? toArray(value) : internal;
|
|
94
|
-
|
|
95
|
-
const resolvedPlaceholder = placeholder ?? t("dataEntry.treeSelect.placeholder");
|
|
96
|
-
|
|
97
|
-
const visible = React.useMemo(() => {
|
|
98
|
-
if (showSearch && search.trim()) return filterVisibleTree(options, search);
|
|
99
|
-
return flattenVisibleTree(options, expandedKeys);
|
|
100
|
-
}, [options, expandedKeys, search, showSearch]);
|
|
101
|
-
|
|
102
|
-
const commit = (next: string[]) => {
|
|
103
|
-
if (!isControlled) setInternal(next);
|
|
104
|
-
onChange?.(checkable || multiple ? next : (next[0] ?? undefined));
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const toggleExpand = (key: string) => {
|
|
108
|
-
setExpandedKeys((prev) => {
|
|
109
|
-
const next = new Set(prev);
|
|
110
|
-
if (next.has(key)) next.delete(key);
|
|
111
|
-
else next.add(key);
|
|
112
|
-
return next;
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const toggleSelect = (node: NormalizedTreeOption) => {
|
|
117
|
-
if (node.disabled) return;
|
|
118
|
-
const key = node.value;
|
|
119
|
-
|
|
120
|
-
if (!checkable && !multiple) {
|
|
121
|
-
commit([key]);
|
|
122
|
-
setOpen(false);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const isOn = selected.includes(key);
|
|
127
|
-
let next: string[];
|
|
128
|
-
|
|
129
|
-
if (treeCheckStrictly) {
|
|
130
|
-
next = isOn ? selected.filter((v) => v !== key) : [...selected, key];
|
|
131
|
-
} else {
|
|
132
|
-
const related = getDescendantValues(node);
|
|
133
|
-
next = isOn
|
|
134
|
-
? selected.filter((v) => !related.includes(v))
|
|
135
|
-
: [...new Set([...selected, ...related])];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
commit(next);
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const displayKeys = displayValues(selected, options, showCheckedStrategy, treeCheckStrictly);
|
|
142
|
-
const displayLabel = displayKeys
|
|
143
|
-
.map((v) => {
|
|
144
|
-
const label = findNodeByValue(options, v)?.label;
|
|
145
|
-
return label ? reactNodeText(label) : v;
|
|
146
|
-
})
|
|
147
|
-
.join(", ");
|
|
148
|
-
|
|
149
|
-
const clearValue = (e: React.MouseEvent) => {
|
|
150
|
-
e.stopPropagation();
|
|
151
|
-
commit([]);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
<Popover open={open} onOpenChange={setOpen}>
|
|
156
|
-
<PopoverTrigger asChild>
|
|
157
|
-
<Button
|
|
158
|
-
id={id}
|
|
159
|
-
type="button"
|
|
160
|
-
variant="outline"
|
|
161
|
-
role="combobox"
|
|
162
|
-
aria-expanded={open}
|
|
163
|
-
disabled={disabled}
|
|
164
|
-
className={cn(
|
|
165
|
-
"w-full justify-between font-normal",
|
|
166
|
-
!displayKeys.length && "text-muted-foreground",
|
|
167
|
-
className,
|
|
168
|
-
)}
|
|
169
|
-
>
|
|
170
|
-
<span className="truncate">
|
|
171
|
-
{displayKeys.length ? displayLabel : resolvedPlaceholder}
|
|
172
|
-
</span>
|
|
173
|
-
<span className="ml-2 flex shrink-0 items-center gap-1">
|
|
174
|
-
{allowClear && displayKeys.length > 0 && !disabled && (
|
|
175
|
-
<X
|
|
176
|
-
className="size-4 opacity-50 hover:opacity-100"
|
|
177
|
-
aria-hidden="true"
|
|
178
|
-
onClick={clearValue}
|
|
179
|
-
/>
|
|
180
|
-
)}
|
|
181
|
-
<ChevronsUpDown className="size-4 opacity-50" aria-hidden="true" />
|
|
182
|
-
</span>
|
|
183
|
-
</Button>
|
|
184
|
-
</PopoverTrigger>
|
|
185
|
-
<PopoverContent className="w-[var(--radix-popover-trigger-width)] p-0" align="start">
|
|
186
|
-
{showSearch && (
|
|
187
|
-
<div className="border-b p-2">
|
|
188
|
-
<Command shouldFilter={false}>
|
|
189
|
-
<CommandInput
|
|
190
|
-
placeholder={t("dataEntry.treeSelect.searchPlaceholder")}
|
|
191
|
-
value={search}
|
|
192
|
-
onValueChange={setSearch}
|
|
193
|
-
/>
|
|
194
|
-
</Command>
|
|
195
|
-
</div>
|
|
196
|
-
)}
|
|
197
|
-
<ScrollArea className="max-h-[min(300px,50vh)]">
|
|
198
|
-
<div
|
|
199
|
-
role="tree"
|
|
200
|
-
aria-multiselectable={Boolean(checkable) || Boolean(multiple)}
|
|
201
|
-
className="p-1"
|
|
202
|
-
>
|
|
203
|
-
{visible.length === 0 ? (
|
|
204
|
-
<p className="text-muted-foreground py-6 text-center text-sm">
|
|
205
|
-
{t("dataEntry.treeSelect.empty")}
|
|
206
|
-
</p>
|
|
207
|
-
) : (
|
|
208
|
-
visible.map(({ node, depth, hasChildren }) => {
|
|
209
|
-
const expanded = expandedKeys.has(node.value);
|
|
210
|
-
const isSelected = selected.includes(node.value);
|
|
211
|
-
return (
|
|
212
|
-
<div
|
|
213
|
-
key={node.value}
|
|
214
|
-
role="treeitem"
|
|
215
|
-
aria-expanded={hasChildren ? expanded : undefined}
|
|
216
|
-
aria-selected={isSelected}
|
|
217
|
-
className={cn(
|
|
218
|
-
"flex items-center rounded-sm py-1.5 pr-2 text-sm outline-none",
|
|
219
|
-
"hover:bg-accent hover:text-accent-foreground",
|
|
220
|
-
isSelected && "bg-accent/60",
|
|
221
|
-
node.disabled && "pointer-events-none opacity-50",
|
|
222
|
-
)}
|
|
223
|
-
style={{ paddingLeft: `${depth * 1.25 + 0.5}rem` }}
|
|
224
|
-
>
|
|
225
|
-
<button
|
|
226
|
-
type="button"
|
|
227
|
-
tabIndex={-1}
|
|
228
|
-
aria-label={
|
|
229
|
-
expanded
|
|
230
|
-
? t("dataEntry.treeSelect.collapse")
|
|
231
|
-
: t("dataEntry.treeSelect.expand")
|
|
232
|
-
}
|
|
233
|
-
className={cn(
|
|
234
|
-
"mr-1 flex size-5 shrink-0 items-center justify-center rounded-sm",
|
|
235
|
-
!hasChildren && "invisible",
|
|
236
|
-
)}
|
|
237
|
-
onClick={() => toggleExpand(node.value)}
|
|
238
|
-
>
|
|
239
|
-
{expanded ? (
|
|
240
|
-
<ChevronDown className="size-4" aria-hidden="true" />
|
|
241
|
-
) : (
|
|
242
|
-
<ChevronRight className="size-4" aria-hidden="true" />
|
|
243
|
-
)}
|
|
244
|
-
</button>
|
|
245
|
-
{checkable ? (
|
|
246
|
-
<label className="flex flex-1 cursor-pointer items-center gap-2">
|
|
247
|
-
<Checkbox
|
|
248
|
-
checked={isSelected}
|
|
249
|
-
disabled={Boolean(node.disabled) || Boolean(node.disableCheckbox)}
|
|
250
|
-
onCheckedChange={() => toggleSelect(node)}
|
|
251
|
-
/>
|
|
252
|
-
<span className="truncate">{node.label}</span>
|
|
253
|
-
</label>
|
|
254
|
-
) : (
|
|
255
|
-
<button
|
|
256
|
-
type="button"
|
|
257
|
-
className="flex-1 truncate text-left"
|
|
258
|
-
disabled={node.disabled}
|
|
259
|
-
onClick={() => toggleSelect(node)}
|
|
260
|
-
>
|
|
261
|
-
{node.label}
|
|
262
|
-
</button>
|
|
263
|
-
)}
|
|
264
|
-
</div>
|
|
265
|
-
);
|
|
266
|
-
})
|
|
267
|
-
)}
|
|
268
|
-
</div>
|
|
269
|
-
</ScrollArea>
|
|
270
|
-
</PopoverContent>
|
|
271
|
-
</Popover>
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
export const TreeSelect = Object.assign(TreeSelectRoot, {
|
|
276
|
-
SHOW_CHILD,
|
|
277
|
-
SHOW_PARENT,
|
|
278
|
-
SHOW_ALL,
|
|
279
|
-
});
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import type * as React from "react";
|
|
2
|
-
|
|
3
|
-
/** Normalized tree node — Ant Design `treeData` / Cascader `options`. */
|
|
4
|
-
export type TreeOption = {
|
|
5
|
-
value: string;
|
|
6
|
-
label: React.ReactNode;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
disableCheckbox?: boolean;
|
|
9
|
-
/** When false with `loadData`, shows expand affordance */
|
|
10
|
-
isLeaf?: boolean;
|
|
11
|
-
children?: TreeOption[];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type TreeFieldNames = {
|
|
15
|
-
label?: string;
|
|
16
|
-
value?: string;
|
|
17
|
-
children?: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type NormalizedTreeOption = TreeOption & { children?: NormalizedTreeOption[] };
|
|
21
|
-
|
|
22
|
-
type RawTreeNode = Record<string, unknown>;
|
|
23
|
-
|
|
24
|
-
export function reactNodeText(value: React.ReactNode): string {
|
|
25
|
-
if (value == null || typeof value === "boolean") return "";
|
|
26
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "bigint") {
|
|
27
|
-
return String(value);
|
|
28
|
-
}
|
|
29
|
-
if (Array.isArray(value)) {
|
|
30
|
-
return (value as React.ReactNode[]).map((item) => reactNodeText(item)).join("");
|
|
31
|
-
}
|
|
32
|
-
return "";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function unknownText(value: unknown): string {
|
|
36
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "bigint") {
|
|
37
|
-
return String(value);
|
|
38
|
-
}
|
|
39
|
-
return "";
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function normalizeTreeOptions(
|
|
43
|
-
nodes: RawTreeNode[] | undefined,
|
|
44
|
-
fieldNames?: TreeFieldNames,
|
|
45
|
-
): NormalizedTreeOption[] {
|
|
46
|
-
if (!nodes?.length) return [];
|
|
47
|
-
const labelKey = fieldNames?.label ?? "label";
|
|
48
|
-
const valueKey = fieldNames?.value ?? "value";
|
|
49
|
-
const childrenKey = fieldNames?.children ?? "children";
|
|
50
|
-
|
|
51
|
-
return nodes.map((node) => {
|
|
52
|
-
const children = node[childrenKey];
|
|
53
|
-
const value = unknownText(node[valueKey]);
|
|
54
|
-
const label = node[labelKey] as React.ReactNode;
|
|
55
|
-
return {
|
|
56
|
-
value,
|
|
57
|
-
label: label ?? value,
|
|
58
|
-
disabled: Boolean(node.disabled),
|
|
59
|
-
disableCheckbox: Boolean(node.disableCheckbox),
|
|
60
|
-
isLeaf: node.isLeaf as boolean | undefined,
|
|
61
|
-
children: Array.isArray(children)
|
|
62
|
-
? normalizeTreeOptions(children as RawTreeNode[], fieldNames)
|
|
63
|
-
: undefined,
|
|
64
|
-
};
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function getNodeByPath(
|
|
69
|
-
options: NormalizedTreeOption[],
|
|
70
|
-
path: string[],
|
|
71
|
-
): NormalizedTreeOption[] {
|
|
72
|
-
const chain: NormalizedTreeOption[] = [];
|
|
73
|
-
let level = options;
|
|
74
|
-
for (const segment of path) {
|
|
75
|
-
const found = level.find((n) => n.value === segment);
|
|
76
|
-
if (!found) break;
|
|
77
|
-
chain.push(found);
|
|
78
|
-
level = found.children ?? [];
|
|
79
|
-
}
|
|
80
|
-
return chain;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function getOptionsAtPath(
|
|
84
|
-
options: NormalizedTreeOption[],
|
|
85
|
-
path: string[],
|
|
86
|
-
): NormalizedTreeOption[] {
|
|
87
|
-
if (!path.length) return options;
|
|
88
|
-
const chain = getNodeByPath(options, path);
|
|
89
|
-
return chain.at(-1)?.children ?? [];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function formatPathLabels(chain: NormalizedTreeOption[], separator = " / "): string {
|
|
93
|
-
return chain.map((n) => reactNodeText(n.label)).join(separator);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export type TreePath = { path: string[]; labels: string[] };
|
|
97
|
-
|
|
98
|
-
export function collectLeafPaths(
|
|
99
|
-
options: NormalizedTreeOption[],
|
|
100
|
-
prefix: string[] = [],
|
|
101
|
-
root: NormalizedTreeOption[] = options,
|
|
102
|
-
): TreePath[] {
|
|
103
|
-
const out: TreePath[] = [];
|
|
104
|
-
for (const node of options) {
|
|
105
|
-
const path = [...prefix, node.value];
|
|
106
|
-
const hasChildren = (node.children?.length ?? 0) > 0;
|
|
107
|
-
if (!hasChildren || node.isLeaf === true) {
|
|
108
|
-
out.push({ path, labels: getNodeByPath(root, path).map((n) => reactNodeText(n.label)) });
|
|
109
|
-
}
|
|
110
|
-
if (hasChildren) out.push(...collectLeafPaths(node.children!, path, root));
|
|
111
|
-
}
|
|
112
|
-
return out;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export function collectAllPaths(
|
|
116
|
-
options: NormalizedTreeOption[],
|
|
117
|
-
prefix: string[] = [],
|
|
118
|
-
root: NormalizedTreeOption[] = options,
|
|
119
|
-
): TreePath[] {
|
|
120
|
-
const out: TreePath[] = [];
|
|
121
|
-
for (const node of options) {
|
|
122
|
-
const path = [...prefix, node.value];
|
|
123
|
-
out.push({ path, labels: getNodeByPath(root, path).map((n) => reactNodeText(n.label)) });
|
|
124
|
-
if (node.children?.length) out.push(...collectAllPaths(node.children, path, root));
|
|
125
|
-
}
|
|
126
|
-
return out;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export function pathKey(path: string[]): string {
|
|
130
|
-
return path.join("\0");
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export function pathsEqual(a: string[], b: string[]): boolean {
|
|
134
|
-
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function filterTreeOptions(
|
|
138
|
-
options: NormalizedTreeOption[],
|
|
139
|
-
query: string,
|
|
140
|
-
filter?: (query: string, path: NormalizedTreeOption[]) => boolean,
|
|
141
|
-
): TreePath[] {
|
|
142
|
-
const q = query.trim().toLowerCase();
|
|
143
|
-
if (!q) return [];
|
|
144
|
-
const paths = collectLeafPaths(options);
|
|
145
|
-
return paths.filter(({ path }) => {
|
|
146
|
-
const chain = getNodeByPath(options, path);
|
|
147
|
-
if (filter) return filter(query, chain);
|
|
148
|
-
return chain.some((n) => reactNodeText(n.label).toLowerCase().includes(q));
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export function getDescendantValues(node: NormalizedTreeOption): string[] {
|
|
153
|
-
const values: string[] = [node.value];
|
|
154
|
-
for (const child of node.children ?? []) values.push(...getDescendantValues(child));
|
|
155
|
-
return values;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export function flattenVisibleTree(
|
|
159
|
-
options: NormalizedTreeOption[],
|
|
160
|
-
expandedKeys: Set<string>,
|
|
161
|
-
depth = 0,
|
|
162
|
-
): { node: NormalizedTreeOption; depth: number; hasChildren: boolean }[] {
|
|
163
|
-
const out: { node: NormalizedTreeOption; depth: number; hasChildren: boolean }[] = [];
|
|
164
|
-
for (const node of options) {
|
|
165
|
-
const hasChildren = (node.children?.length ?? 0) > 0 && node.isLeaf !== true;
|
|
166
|
-
out.push({ node, depth, hasChildren });
|
|
167
|
-
if (hasChildren && expandedKeys.has(node.value)) {
|
|
168
|
-
out.push(...flattenVisibleTree(node.children!, expandedKeys, depth + 1));
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return out;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export function filterVisibleTree(
|
|
175
|
-
options: NormalizedTreeOption[],
|
|
176
|
-
query: string,
|
|
177
|
-
): { node: NormalizedTreeOption; depth: number; hasChildren: boolean }[] {
|
|
178
|
-
const q = query.trim().toLowerCase();
|
|
179
|
-
if (!q) return flattenVisibleTree(options, new Set(collectAllExpandableKeys(options)));
|
|
180
|
-
|
|
181
|
-
const expanded = new Set<string>();
|
|
182
|
-
|
|
183
|
-
function walk(nodes: NormalizedTreeOption[], depth: number): boolean {
|
|
184
|
-
let branchMatch = false;
|
|
185
|
-
for (const node of nodes) {
|
|
186
|
-
const selfMatch = reactNodeText(node.label).toLowerCase().includes(q);
|
|
187
|
-
const childMatch = node.children?.length ? walk(node.children, depth + 1) : false;
|
|
188
|
-
if (selfMatch || childMatch) {
|
|
189
|
-
branchMatch = true;
|
|
190
|
-
if (childMatch) expanded.add(node.value);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return branchMatch;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
walk(options, 0);
|
|
197
|
-
return flattenVisibleTree(options, expanded);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export function collectAllExpandableKeys(options: NormalizedTreeOption[]): string[] {
|
|
201
|
-
const keys: string[] = [];
|
|
202
|
-
for (const node of options) {
|
|
203
|
-
if ((node.children?.length ?? 0) > 0 && node.isLeaf !== true) {
|
|
204
|
-
keys.push(node.value);
|
|
205
|
-
keys.push(...collectAllExpandableKeys(node.children!));
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return keys;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export function findNodeByValue(
|
|
212
|
-
options: NormalizedTreeOption[],
|
|
213
|
-
value: string,
|
|
214
|
-
): NormalizedTreeOption | undefined {
|
|
215
|
-
for (const node of options) {
|
|
216
|
-
if (node.value === value) return node;
|
|
217
|
-
const nested = node.children ? findNodeByValue(node.children, value) : undefined;
|
|
218
|
-
if (nested) return nested;
|
|
219
|
-
}
|
|
220
|
-
return undefined;
|
|
221
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import { useTranslation } from "../../i18n/use-translation";
|
|
4
|
-
import { cn } from "../../lib/utils";
|
|
5
|
-
import { Button } from "../general/button";
|
|
6
|
-
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "../feedback/dialog";
|
|
7
|
-
import { Slider } from "./slider";
|
|
8
|
-
|
|
9
|
-
interface UploadCropDialogProps {
|
|
10
|
-
open: boolean;
|
|
11
|
-
onOpenChange: (open: boolean) => void;
|
|
12
|
-
file: File | null;
|
|
13
|
-
onConfirm: (cropped: File) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** Simple 1:1 avatar crop — canvas export, no extra deps. */
|
|
17
|
-
export function UploadCropDialog({ open, onOpenChange, file, onConfirm }: UploadCropDialogProps) {
|
|
18
|
-
const { t } = useTranslation();
|
|
19
|
-
const [scale, setScale] = React.useState(1.2);
|
|
20
|
-
const [src, setSrc] = React.useState<string | null>(null);
|
|
21
|
-
const imgRef = React.useRef<HTMLImageElement>(null);
|
|
22
|
-
|
|
23
|
-
React.useEffect(() => {
|
|
24
|
-
if (!file) {
|
|
25
|
-
// eslint-disable-next-line react-hooks/set-state-in-effect -- clear object URL state when the selected file is removed.
|
|
26
|
-
setSrc(null);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const url = URL.createObjectURL(file);
|
|
30
|
-
setSrc(url);
|
|
31
|
-
return () => URL.revokeObjectURL(url);
|
|
32
|
-
}, [file]);
|
|
33
|
-
|
|
34
|
-
const handleConfirm = async () => {
|
|
35
|
-
const img = imgRef.current;
|
|
36
|
-
if (!img || !file) return;
|
|
37
|
-
|
|
38
|
-
const size = 256;
|
|
39
|
-
const canvas = document.createElement("canvas");
|
|
40
|
-
canvas.width = size;
|
|
41
|
-
canvas.height = size;
|
|
42
|
-
const ctx = canvas.getContext("2d");
|
|
43
|
-
if (!ctx) return;
|
|
44
|
-
|
|
45
|
-
const iw = img.naturalWidth;
|
|
46
|
-
const ih = img.naturalHeight;
|
|
47
|
-
const side = Math.min(iw, ih) / scale;
|
|
48
|
-
const sx = (iw - side) / 2;
|
|
49
|
-
const sy = (ih - side) / 2;
|
|
50
|
-
|
|
51
|
-
ctx.drawImage(img, sx, sy, side, side, 0, 0, size, size);
|
|
52
|
-
|
|
53
|
-
const blob = await new Promise<Blob | null>((resolve) =>
|
|
54
|
-
canvas.toBlob(resolve, "image/jpeg", 0.92),
|
|
55
|
-
);
|
|
56
|
-
if (!blob) return;
|
|
57
|
-
|
|
58
|
-
const cropped = new File([blob], file.name.replace(/\.\w+$/, "") + ".jpg", {
|
|
59
|
-
type: "image/jpeg",
|
|
60
|
-
});
|
|
61
|
-
onConfirm(cropped);
|
|
62
|
-
onOpenChange(false);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
67
|
-
<DialogContent className="max-w-sm">
|
|
68
|
-
<DialogHeader>
|
|
69
|
-
<DialogTitle>{t("dataEntry.upload.cropTitle")}</DialogTitle>
|
|
70
|
-
</DialogHeader>
|
|
71
|
-
<div className="ui-stack-sm">
|
|
72
|
-
<div
|
|
73
|
-
className={cn(
|
|
74
|
-
"bg-muted relative mx-auto size-48 overflow-hidden rounded-full border",
|
|
75
|
-
"flex items-center justify-center",
|
|
76
|
-
)}
|
|
77
|
-
>
|
|
78
|
-
{src ? (
|
|
79
|
-
<img
|
|
80
|
-
ref={imgRef}
|
|
81
|
-
src={src}
|
|
82
|
-
alt=""
|
|
83
|
-
className="size-full object-cover transition-transform duration-150"
|
|
84
|
-
style={{ transform: `scale(${scale})` }}
|
|
85
|
-
/>
|
|
86
|
-
) : null}
|
|
87
|
-
</div>
|
|
88
|
-
<div className="ui-stack-xs px-2">
|
|
89
|
-
<span className="text-muted-foreground text-xs">{t("dataEntry.upload.cropZoom")}</span>
|
|
90
|
-
<Slider
|
|
91
|
-
min={1}
|
|
92
|
-
max={2.5}
|
|
93
|
-
step={0.05}
|
|
94
|
-
value={[scale]}
|
|
95
|
-
onValueChange={(v) => setScale(v[0] ?? 1)}
|
|
96
|
-
aria-label={t("dataEntry.upload.cropZoom")}
|
|
97
|
-
/>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
<DialogFooter>
|
|
101
|
-
<Button variant="ghost" onClick={() => onOpenChange(false)}>
|
|
102
|
-
{t("common.cancel")}
|
|
103
|
-
</Button>
|
|
104
|
-
<Button onClick={() => void handleConfirm()}>{t("dataEntry.upload.cropConfirm")}</Button>
|
|
105
|
-
</DialogFooter>
|
|
106
|
-
</DialogContent>
|
|
107
|
-
</Dialog>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/** Upload item — maps to media-service after `onUpload` resolves `mediaId`. */
|
|
2
|
-
export type UploadFileStatus = "idle" | "uploading" | "done" | "error" | "removed";
|
|
3
|
-
|
|
4
|
-
export type UploadFileItem = {
|
|
5
|
-
/** Stable key for list reconciliation */
|
|
6
|
-
uid: string;
|
|
7
|
-
name: string;
|
|
8
|
-
size: number;
|
|
9
|
-
mimeType?: string;
|
|
10
|
-
/** Blob URL or media-service download URL */
|
|
11
|
-
previewUrl?: string;
|
|
12
|
-
/** Set after issue → PUT → complete */
|
|
13
|
-
mediaId?: string;
|
|
14
|
-
status: UploadFileStatus;
|
|
15
|
-
error?: string;
|
|
16
|
-
/** Local file before / during upload */
|
|
17
|
-
file?: File;
|
|
18
|
-
/**
|
|
19
|
-
* Draft-only: marked for soft-delete on form commit.
|
|
20
|
-
* Undo clears this before save — media-service has no restore API.
|
|
21
|
-
*/
|
|
22
|
-
pendingDelete?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Draft-only: replacement staged locally; baseline kept for undo.
|
|
25
|
-
*/
|
|
26
|
-
pendingReplace?: boolean;
|
|
27
|
-
/** mediaId to soft-delete on commit when `pendingReplace` */
|
|
28
|
-
replacesMediaId?: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type UploadVariant =
|
|
32
|
-
| "dropzone"
|
|
33
|
-
| "button"
|
|
34
|
-
| "picture-card"
|
|
35
|
-
| "picture"
|
|
36
|
-
| "avatar"
|
|
37
|
-
| "avatar-crop";
|
|
38
|
-
|
|
39
|
-
/** Actions parent runs on form submit (media-service). */
|
|
40
|
-
export type UploadCommitAction = {
|
|
41
|
-
/** Soft-delete on save — no restore API */
|
|
42
|
-
deleteMediaIds: string[];
|
|
43
|
-
/** Temp uploads already completed via `onUpload` — promote on save */
|
|
44
|
-
promoteMediaIds: string[];
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export function createUploadItem(file: File, partial?: Partial<UploadFileItem>): UploadFileItem {
|
|
48
|
-
const previewUrl = file.type.startsWith("image/") ? URL.createObjectURL(file) : undefined;
|
|
49
|
-
return {
|
|
50
|
-
uid: partial?.uid ?? crypto.randomUUID(),
|
|
51
|
-
name: file.name,
|
|
52
|
-
size: file.size,
|
|
53
|
-
mimeType: file.type,
|
|
54
|
-
previewUrl,
|
|
55
|
-
status: "idle",
|
|
56
|
-
file,
|
|
57
|
-
...partial,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function revokePreviewUrl(item: UploadFileItem | null | undefined) {
|
|
62
|
-
if (item?.previewUrl?.startsWith("blob:")) URL.revokeObjectURL(item.previewUrl);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function collectUploadCommitActions(items: UploadFileItem[]): UploadCommitAction {
|
|
66
|
-
const deleteMediaIds: string[] = [];
|
|
67
|
-
const promoteMediaIds: string[] = [];
|
|
68
|
-
|
|
69
|
-
for (const item of items) {
|
|
70
|
-
if (item.pendingDelete && item.mediaId) {
|
|
71
|
-
deleteMediaIds.push(item.mediaId);
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (item.pendingReplace && item.replacesMediaId) {
|
|
75
|
-
deleteMediaIds.push(item.replacesMediaId);
|
|
76
|
-
}
|
|
77
|
-
if (item.mediaId && !item.pendingDelete && item.status !== "error") {
|
|
78
|
-
promoteMediaIds.push(item.mediaId);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
deleteMediaIds: [...new Set(deleteMediaIds)],
|
|
84
|
-
promoteMediaIds: [...new Set(promoteMediaIds)],
|
|
85
|
-
};
|
|
86
|
-
}
|