@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,214 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { QueryClient, QueryClientProvider, useQuery } from "@tanstack/react-query";
|
|
4
|
-
import type { UseQueryResult } from "@tanstack/react-query";
|
|
5
|
-
import { renderWithUi, screen, userEvent, waitFor } from "@/test/render";
|
|
6
|
-
import { DataState } from "../data-state";
|
|
7
|
-
|
|
8
|
-
type ShipmentList = { items: number[] };
|
|
9
|
-
|
|
10
|
-
function mockQuery<T>(partial: Partial<UseQueryResult<T>>): UseQueryResult<T> {
|
|
11
|
-
return partial as UseQueryResult<T>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function withQueryClient(ui: React.ReactElement, client: QueryClient) {
|
|
15
|
-
return <QueryClientProvider client={client}>{ui}</QueryClientProvider>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function EmptyWarehouseHarness() {
|
|
19
|
-
const query = useQuery<ShipmentList>({
|
|
20
|
-
queryKey: ["data-state-test", "empty"],
|
|
21
|
-
queryFn: () => Promise.resolve({ items: [] }),
|
|
22
|
-
});
|
|
23
|
-
return (
|
|
24
|
-
<DataState
|
|
25
|
-
query={query}
|
|
26
|
-
skeleton={<div data-testid="hawb-skeleton">loading</div>}
|
|
27
|
-
empty={<div>Không có kiện chờ gom</div>}
|
|
28
|
-
isEmpty={(data) => data.items.length === 0}
|
|
29
|
-
>
|
|
30
|
-
{(data) => <div data-testid="hawb-list">{data.items.length} kiện</div>}
|
|
31
|
-
</DataState>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function LoadedWarehouseHarness() {
|
|
36
|
-
const query = useQuery<ShipmentList>({
|
|
37
|
-
queryKey: ["data-state-test", "loaded"],
|
|
38
|
-
queryFn: () => Promise.resolve({ items: [1, 2] }),
|
|
39
|
-
});
|
|
40
|
-
return (
|
|
41
|
-
<DataState
|
|
42
|
-
query={query}
|
|
43
|
-
skeleton={<div data-testid="hawb-skeleton">loading</div>}
|
|
44
|
-
empty={<div>Không có kiện chờ gom</div>}
|
|
45
|
-
isEmpty={(data) => data.items.length === 0}
|
|
46
|
-
>
|
|
47
|
-
{(data) => <div data-testid="hawb-list">{data.items.length} kiện</div>}
|
|
48
|
-
</DataState>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
describe("DataState", () => {
|
|
53
|
-
it("shows skeleton while pending", () => {
|
|
54
|
-
renderWithUi(
|
|
55
|
-
<DataState
|
|
56
|
-
query={mockQuery({ isPending: true, isError: false })}
|
|
57
|
-
skeleton={<div data-testid="skel">loading</div>}
|
|
58
|
-
>
|
|
59
|
-
{() => <div>data</div>}
|
|
60
|
-
</DataState>,
|
|
61
|
-
);
|
|
62
|
-
expect(screen.getByTestId("skel")).toBeInTheDocument();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("renders children when data loaded", () => {
|
|
66
|
-
renderWithUi(
|
|
67
|
-
<DataState
|
|
68
|
-
query={mockQuery({ isPending: false, isError: false, data: { items: [1] } })}
|
|
69
|
-
skeleton={<div>loading</div>}
|
|
70
|
-
empty={<div>empty</div>}
|
|
71
|
-
>
|
|
72
|
-
{(data) => <div>count:{data.items.length}</div>}
|
|
73
|
-
</DataState>,
|
|
74
|
-
);
|
|
75
|
-
expect(screen.getByText("count:1")).toBeInTheDocument();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("shows empty state when isEmpty", () => {
|
|
79
|
-
renderWithUi(
|
|
80
|
-
<DataState
|
|
81
|
-
query={mockQuery({ isPending: false, isError: false, data: { items: [] } })}
|
|
82
|
-
skeleton={<div>loading</div>}
|
|
83
|
-
empty={<div>No items</div>}
|
|
84
|
-
>
|
|
85
|
-
{() => <div>data</div>}
|
|
86
|
-
</DataState>,
|
|
87
|
-
);
|
|
88
|
-
expect(screen.getByText("No items")).toBeInTheDocument();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("renders Alert.QueryError and refetches on retry when query errors", async () => {
|
|
92
|
-
const user = userEvent.setup();
|
|
93
|
-
const refetch = vi.fn();
|
|
94
|
-
renderWithUi(
|
|
95
|
-
<DataState
|
|
96
|
-
query={mockQuery({
|
|
97
|
-
isPending: false,
|
|
98
|
-
isError: true,
|
|
99
|
-
isFetching: false,
|
|
100
|
-
error: new Error("GET /v1/customers failed: 503"),
|
|
101
|
-
refetch,
|
|
102
|
-
})}
|
|
103
|
-
skeleton={<div data-testid="skel">loading</div>}
|
|
104
|
-
>
|
|
105
|
-
{() => <div>data</div>}
|
|
106
|
-
</DataState>,
|
|
107
|
-
);
|
|
108
|
-
expect(screen.getByRole("alert")).toBeInTheDocument();
|
|
109
|
-
expect(screen.getByText(/503/)).toBeInTheDocument();
|
|
110
|
-
await user.click(screen.getByRole("button", { name: /thử lại/i }));
|
|
111
|
-
expect(refetch).toHaveBeenCalledOnce();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("shows skeleton while retrying after error", () => {
|
|
115
|
-
renderWithUi(
|
|
116
|
-
<DataState
|
|
117
|
-
query={mockQuery({
|
|
118
|
-
isPending: false,
|
|
119
|
-
isError: true,
|
|
120
|
-
isFetching: true,
|
|
121
|
-
error: new Error("503"),
|
|
122
|
-
})}
|
|
123
|
-
skeleton={<div data-testid="retry-skel">loading</div>}
|
|
124
|
-
>
|
|
125
|
-
{() => <div>data</div>}
|
|
126
|
-
</DataState>,
|
|
127
|
-
);
|
|
128
|
-
expect(screen.getByTestId("retry-skel")).toBeInTheDocument();
|
|
129
|
-
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("omits retry when showRetry is false", () => {
|
|
133
|
-
renderWithUi(
|
|
134
|
-
<DataState
|
|
135
|
-
query={mockQuery({
|
|
136
|
-
isPending: false,
|
|
137
|
-
isError: true,
|
|
138
|
-
isFetching: false,
|
|
139
|
-
error: new Error("403"),
|
|
140
|
-
})}
|
|
141
|
-
skeleton={<div>loading</div>}
|
|
142
|
-
showRetry={false}
|
|
143
|
-
>
|
|
144
|
-
{() => <div>data</div>}
|
|
145
|
-
</DataState>,
|
|
146
|
-
);
|
|
147
|
-
expect(screen.getByRole("alert")).toBeInTheDocument();
|
|
148
|
-
expect(screen.queryByRole("button", { name: /thử lại/i })).not.toBeInTheDocument();
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("calls onRetry override instead of refetch", async () => {
|
|
152
|
-
const user = userEvent.setup();
|
|
153
|
-
const onRetry = vi.fn();
|
|
154
|
-
const refetch = vi.fn();
|
|
155
|
-
renderWithUi(
|
|
156
|
-
<DataState
|
|
157
|
-
query={mockQuery({
|
|
158
|
-
isPending: false,
|
|
159
|
-
isError: true,
|
|
160
|
-
isFetching: false,
|
|
161
|
-
error: new Error("fail"),
|
|
162
|
-
refetch,
|
|
163
|
-
})}
|
|
164
|
-
skeleton={<div>loading</div>}
|
|
165
|
-
onRetry={onRetry}
|
|
166
|
-
>
|
|
167
|
-
{() => <div>data</div>}
|
|
168
|
-
</DataState>,
|
|
169
|
-
);
|
|
170
|
-
await user.click(screen.getByRole("button", { name: /thử lại/i }));
|
|
171
|
-
expect(onRetry).toHaveBeenCalledOnce();
|
|
172
|
-
expect(refetch).not.toHaveBeenCalled();
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it("uses custom errorRenderer when provided", () => {
|
|
176
|
-
renderWithUi(
|
|
177
|
-
<DataState
|
|
178
|
-
query={mockQuery({
|
|
179
|
-
isPending: false,
|
|
180
|
-
isError: true,
|
|
181
|
-
isFetching: false,
|
|
182
|
-
error: new Error("fail"),
|
|
183
|
-
})}
|
|
184
|
-
skeleton={<div>loading</div>}
|
|
185
|
-
errorRenderer={(err) => <div data-testid="custom-err">{String(err)}</div>}
|
|
186
|
-
>
|
|
187
|
-
{() => <div>data</div>}
|
|
188
|
-
</DataState>,
|
|
189
|
-
);
|
|
190
|
-
expect(screen.getByTestId("custom-err")).toHaveTextContent("fail");
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
describe("DataState integration (useQuery)", () => {
|
|
195
|
-
it("shows empty warehouse after query resolves", async () => {
|
|
196
|
-
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
|
197
|
-
renderWithUi(withQueryClient(<EmptyWarehouseHarness />, client));
|
|
198
|
-
|
|
199
|
-
expect(screen.getByTestId("hawb-skeleton")).toBeInTheDocument();
|
|
200
|
-
await waitFor(() => {
|
|
201
|
-
expect(screen.getByText("Không có kiện chờ gom")).toBeInTheDocument();
|
|
202
|
-
});
|
|
203
|
-
expect(screen.queryByTestId("hawb-list")).not.toBeInTheDocument();
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it("shows list when warehouse has shipments", async () => {
|
|
207
|
-
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
|
208
|
-
renderWithUi(withQueryClient(<LoadedWarehouseHarness />, client));
|
|
209
|
-
|
|
210
|
-
await waitFor(() => {
|
|
211
|
-
expect(screen.getByTestId("hawb-list")).toHaveTextContent("2 kiện");
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
});
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import type { InfiniteData, UseInfiniteQueryResult } from "@tanstack/react-query";
|
|
3
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
-
import { renderWithUi, screen, userEvent, waitFor } from "@/test/render";
|
|
5
|
-
import { InfiniteQueryState, flattenItemPages } from "../infinite-query-state";
|
|
6
|
-
import { PrefetchLink } from "../prefetch-link";
|
|
7
|
-
|
|
8
|
-
type Page = { items: string[]; next_cursor?: string };
|
|
9
|
-
|
|
10
|
-
function mockInfiniteQuery(partial: Record<string, unknown>) {
|
|
11
|
-
return partial as unknown as UseInfiniteQueryResult<InfiniteData<Page>, Error>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
describe("flattenItemPages", () => {
|
|
15
|
-
it("concatenates items across pages", () => {
|
|
16
|
-
expect(
|
|
17
|
-
flattenItemPages({
|
|
18
|
-
pages: [{ items: ["a"] }, { items: ["b", "c"] }],
|
|
19
|
-
}),
|
|
20
|
-
).toEqual(["a", "b", "c"]);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe("InfiniteQueryState", () => {
|
|
25
|
-
it("shows skeleton while pending", () => {
|
|
26
|
-
renderWithUi(
|
|
27
|
-
<InfiniteQueryState<Page, string[]>
|
|
28
|
-
query={mockInfiniteQuery({ isPending: true, isError: false })}
|
|
29
|
-
skeleton={<div data-testid="skel">loading</div>}
|
|
30
|
-
flatten={(d) => flattenItemPages(d)}
|
|
31
|
-
>
|
|
32
|
-
{() => null}
|
|
33
|
-
</InfiniteQueryState>,
|
|
34
|
-
);
|
|
35
|
-
expect(screen.getByTestId("skel")).toBeInTheDocument();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("renders flattened items and load more", async () => {
|
|
39
|
-
const user = userEvent.setup();
|
|
40
|
-
const fetchNextPage = vi.fn();
|
|
41
|
-
renderWithUi(
|
|
42
|
-
<InfiniteQueryState<Page, string[]>
|
|
43
|
-
query={mockInfiniteQuery({
|
|
44
|
-
isPending: false,
|
|
45
|
-
isError: false,
|
|
46
|
-
isFetchingNextPage: false,
|
|
47
|
-
data: { pages: [{ items: ["note-1"] }], pageParams: [undefined] },
|
|
48
|
-
hasNextPage: true,
|
|
49
|
-
fetchNextPage,
|
|
50
|
-
})}
|
|
51
|
-
skeleton={<div>loading</div>}
|
|
52
|
-
flatten={(d) => flattenItemPages(d)}
|
|
53
|
-
>
|
|
54
|
-
{(items) => (
|
|
55
|
-
<ul>
|
|
56
|
-
{items.map((id) => (
|
|
57
|
-
<li key={id}>{id}</li>
|
|
58
|
-
))}
|
|
59
|
-
</ul>
|
|
60
|
-
)}
|
|
61
|
-
</InfiniteQueryState>,
|
|
62
|
-
);
|
|
63
|
-
expect(screen.getByText("note-1")).toBeInTheDocument();
|
|
64
|
-
await user.click(screen.getByRole("button", { name: /tải thêm/i }));
|
|
65
|
-
expect(fetchNextPage).toHaveBeenCalledOnce();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("shows empty state", () => {
|
|
69
|
-
renderWithUi(
|
|
70
|
-
<InfiniteQueryState<Page, string[]>
|
|
71
|
-
query={mockInfiniteQuery({
|
|
72
|
-
isPending: false,
|
|
73
|
-
isError: false,
|
|
74
|
-
data: { pages: [{ items: [] }], pageParams: [undefined] },
|
|
75
|
-
hasNextPage: false,
|
|
76
|
-
})}
|
|
77
|
-
skeleton={<div>loading</div>}
|
|
78
|
-
empty={<div>No notes</div>}
|
|
79
|
-
flatten={(d) => flattenItemPages(d)}
|
|
80
|
-
>
|
|
81
|
-
{() => null}
|
|
82
|
-
</InfiniteQueryState>,
|
|
83
|
-
);
|
|
84
|
-
expect(screen.getByText("No notes")).toBeInTheDocument();
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe("PrefetchLink", () => {
|
|
89
|
-
it("prefetches on hover", async () => {
|
|
90
|
-
const user = userEvent.setup();
|
|
91
|
-
const queryFn = vi.fn(() => Promise.resolve({ id: "cust_1" }));
|
|
92
|
-
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
|
93
|
-
|
|
94
|
-
renderWithUi(
|
|
95
|
-
<QueryClientProvider client={client}>
|
|
96
|
-
<PrefetchLink to="/customers/cust_1" queryKey={["customer", "cust_1"]} queryFn={queryFn}>
|
|
97
|
-
Mai Nguyen
|
|
98
|
-
</PrefetchLink>
|
|
99
|
-
</QueryClientProvider>,
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
await user.hover(screen.getByRole("link", { name: "Mai Nguyen" }));
|
|
103
|
-
await waitFor(() => expect(queryFn).toHaveBeenCalledOnce());
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { renderWithUi, screen, userEvent } from "@/test/render";
|
|
3
|
-
import { MutationFeedback } from "../mutation-feedback";
|
|
4
|
-
import { QueryRefetchButton } from "../query-refetch-button";
|
|
5
|
-
|
|
6
|
-
describe("MutationFeedback", () => {
|
|
7
|
-
it("renders nothing when idle", () => {
|
|
8
|
-
const { container } = renderWithUi(
|
|
9
|
-
<MutationFeedback mutation={{ isError: false, error: null, isPending: false }} />,
|
|
10
|
-
);
|
|
11
|
-
expect(container).toBeEmptyDOMElement();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("shows Alert.QueryError when mutation failed", () => {
|
|
15
|
-
renderWithUi(
|
|
16
|
-
<MutationFeedback
|
|
17
|
-
mutation={{ isError: true, error: new Error("save failed"), isPending: false }}
|
|
18
|
-
onRetry={() => undefined}
|
|
19
|
-
/>,
|
|
20
|
-
);
|
|
21
|
-
expect(screen.getByRole("alert")).toBeInTheDocument();
|
|
22
|
-
expect(screen.getByText(/save failed/)).toBeInTheDocument();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("shows pending slot while running", () => {
|
|
26
|
-
renderWithUi(
|
|
27
|
-
<MutationFeedback
|
|
28
|
-
mutation={{ isError: false, error: null, isPending: true }}
|
|
29
|
-
pending={<div data-testid="pending">Running…</div>}
|
|
30
|
-
/>,
|
|
31
|
-
);
|
|
32
|
-
expect(screen.getByTestId("pending")).toBeInTheDocument();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("hides retry when showRetry is false", () => {
|
|
36
|
-
renderWithUi(
|
|
37
|
-
<MutationFeedback
|
|
38
|
-
mutation={{ isError: true, error: new Error("403"), isPending: false }}
|
|
39
|
-
showRetry={false}
|
|
40
|
-
/>,
|
|
41
|
-
);
|
|
42
|
-
expect(screen.queryByRole("button", { name: /thử lại/i })).not.toBeInTheDocument();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe("QueryRefetchButton", () => {
|
|
47
|
-
it("calls refetch on click", async () => {
|
|
48
|
-
const user = userEvent.setup();
|
|
49
|
-
const refetch = vi.fn();
|
|
50
|
-
renderWithUi(
|
|
51
|
-
<QueryRefetchButton query={{ isFetching: false, refetch }} label="Refresh list" />,
|
|
52
|
-
);
|
|
53
|
-
await user.click(screen.getByRole("button", { name: /refresh list/i }));
|
|
54
|
-
expect(refetch).toHaveBeenCalledOnce();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("disables while fetching", () => {
|
|
58
|
-
renderWithUi(<QueryRefetchButton query={{ isFetching: true, refetch: vi.fn() }} />);
|
|
59
|
-
expect(screen.getByRole("button")).toBeDisabled();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import { AlertQueryError } from "../feedback/alert";
|
|
4
|
-
import type { DataStateProp } from "../../props/components/query.prop";
|
|
5
|
-
|
|
6
|
-
export type {
|
|
7
|
-
DataStateProp,
|
|
8
|
-
DataStateProp as DataStateProps,
|
|
9
|
-
} from "../../props/components/query.prop";
|
|
10
|
-
|
|
11
|
-
function defaultIsEmpty(data: unknown): boolean {
|
|
12
|
-
if (!data) return true;
|
|
13
|
-
if (Array.isArray(data)) return data.length === 0;
|
|
14
|
-
if (typeof data === "object" && data !== null) {
|
|
15
|
-
const obj = data as { items?: unknown[]; length?: number };
|
|
16
|
-
if (Array.isArray(obj.items)) return obj.items.length === 0;
|
|
17
|
-
if (typeof obj.length === "number") return obj.length === 0;
|
|
18
|
-
}
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Query lifecycle widget — orchestrates skeleton / error / empty / success for one `useQuery` block.
|
|
24
|
-
* Not a visual component; prefer `@godxjp/ui/query`. Apps may also import via `@godxjp/ui/admin`.
|
|
25
|
-
*/
|
|
26
|
-
export function DataState<T>({
|
|
27
|
-
query,
|
|
28
|
-
skeleton,
|
|
29
|
-
empty,
|
|
30
|
-
isEmpty = defaultIsEmpty,
|
|
31
|
-
errorRenderer,
|
|
32
|
-
showRetry = true,
|
|
33
|
-
onRetry,
|
|
34
|
-
children,
|
|
35
|
-
}: DataStateProp<T>) {
|
|
36
|
-
const retry = React.useCallback(() => {
|
|
37
|
-
if (onRetry) {
|
|
38
|
-
void onRetry();
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
void query.refetch();
|
|
42
|
-
}, [onRetry, query]);
|
|
43
|
-
|
|
44
|
-
if (query.isPending) return <>{skeleton}</>;
|
|
45
|
-
|
|
46
|
-
if (query.isError) {
|
|
47
|
-
if (query.isFetching) return <>{skeleton}</>;
|
|
48
|
-
if (errorRenderer) return <>{errorRenderer(query.error, retry)}</>;
|
|
49
|
-
return <AlertQueryError error={query.error} onRetry={showRetry ? retry : undefined} />;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const data = query.data;
|
|
53
|
-
if (data === undefined) return <>{skeleton}</>;
|
|
54
|
-
|
|
55
|
-
if (empty && (data === null || isEmpty(data))) return <>{empty}</>;
|
|
56
|
-
|
|
57
|
-
return <>{children(data as NonNullable<T>)}</>;
|
|
58
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { DataState } from "./data-state";
|
|
2
|
-
export type { DataStateProp, DataStateProps } from "./data-state";
|
|
3
|
-
export { MutationFeedback } from "./mutation-feedback";
|
|
4
|
-
export type { MutationFeedbackProp, MutationFeedbackProps } from "./mutation-feedback";
|
|
5
|
-
export { QueryRefetchButton } from "./query-refetch-button";
|
|
6
|
-
export type { QueryRefetchButtonProp, QueryRefetchButtonProps } from "./query-refetch-button";
|
|
7
|
-
export { InfiniteQueryState, flattenItemPages } from "./infinite-query-state";
|
|
8
|
-
export type { InfiniteQueryStateProp, InfiniteQueryStateProps } from "./infinite-query-state";
|
|
9
|
-
export { PrefetchLink } from "./prefetch-link";
|
|
10
|
-
export type { PrefetchLinkProp, PrefetchLinkProps } from "./prefetch-link";
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import { AlertQueryError } from "../feedback/alert";
|
|
4
|
-
import { Button } from "../general/button";
|
|
5
|
-
import { useTranslation } from "../../i18n/use-translation";
|
|
6
|
-
import type { InfiniteQueryStateProp } from "../../props/components/query.prop";
|
|
7
|
-
|
|
8
|
-
export type {
|
|
9
|
-
InfiniteQueryStateProp,
|
|
10
|
-
InfiniteQueryStateProp as InfiniteQueryStateProps,
|
|
11
|
-
} from "../../props/components/query.prop";
|
|
12
|
-
|
|
13
|
-
/** Flatten `{ pages: [{ items }] }` — default GODX paginated API shape. */
|
|
14
|
-
export function flattenItemPages<TItem, TPage extends { items: TItem[] }>(
|
|
15
|
-
data: { pages: TPage[] } | undefined,
|
|
16
|
-
): TItem[] {
|
|
17
|
-
if (!data) return [];
|
|
18
|
-
return data.pages.flatMap((page) => page.items);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function defaultIsEmptyFlat(flat: unknown): boolean {
|
|
22
|
-
if (Array.isArray(flat)) return flat.length === 0;
|
|
23
|
-
return !flat;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* `useInfiniteQuery` lifecycle widget — flatten pages, load-more footer.
|
|
28
|
-
* Cursor / activity feeds where user accumulates pages (vs DataTable cursor buttons).
|
|
29
|
-
*/
|
|
30
|
-
export function InfiniteQueryState<TPage, TFlat>({
|
|
31
|
-
query,
|
|
32
|
-
skeleton,
|
|
33
|
-
empty,
|
|
34
|
-
flatten,
|
|
35
|
-
isEmpty = defaultIsEmptyFlat,
|
|
36
|
-
errorRenderer,
|
|
37
|
-
showRetry = true,
|
|
38
|
-
onRetry,
|
|
39
|
-
loadingMore,
|
|
40
|
-
loadMore,
|
|
41
|
-
showLoadMore = true,
|
|
42
|
-
children,
|
|
43
|
-
}: InfiniteQueryStateProp<TPage, TFlat>) {
|
|
44
|
-
const { t } = useTranslation();
|
|
45
|
-
|
|
46
|
-
const retry = React.useCallback(() => {
|
|
47
|
-
if (onRetry) {
|
|
48
|
-
void onRetry();
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
void query.refetch();
|
|
52
|
-
}, [onRetry, query]);
|
|
53
|
-
|
|
54
|
-
if (query.isPending) return <>{skeleton}</>;
|
|
55
|
-
|
|
56
|
-
if (query.isError) {
|
|
57
|
-
if (query.isFetching && !query.isFetchingNextPage) return <>{skeleton}</>;
|
|
58
|
-
if (errorRenderer) return <>{errorRenderer(query.error, retry)}</>;
|
|
59
|
-
return <AlertQueryError error={query.error} onRetry={showRetry ? retry : undefined} />;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const data = query.data;
|
|
63
|
-
if (!data) return <>{skeleton}</>;
|
|
64
|
-
|
|
65
|
-
const flat = flatten(data);
|
|
66
|
-
if (empty && isEmpty(flat)) return <>{empty}</>;
|
|
67
|
-
|
|
68
|
-
const footer =
|
|
69
|
-
showLoadMore && query.hasNextPage
|
|
70
|
-
? (loadMore ?? (
|
|
71
|
-
<div className="flex justify-center pt-4">
|
|
72
|
-
<Button
|
|
73
|
-
type="button"
|
|
74
|
-
variant="outline"
|
|
75
|
-
size="sm"
|
|
76
|
-
disabled={query.isFetchingNextPage}
|
|
77
|
-
onClick={() => void query.fetchNextPage()}
|
|
78
|
-
>
|
|
79
|
-
{query.isFetchingNextPage ? t("common.working") : t("query.loadMore")}
|
|
80
|
-
</Button>
|
|
81
|
-
</div>
|
|
82
|
-
))
|
|
83
|
-
: null;
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<>
|
|
87
|
-
{children(flat, {
|
|
88
|
-
fetchNextPage: () => void query.fetchNextPage(),
|
|
89
|
-
hasNextPage: !!query.hasNextPage,
|
|
90
|
-
isFetchingNextPage: query.isFetchingNextPage,
|
|
91
|
-
})}
|
|
92
|
-
{query.isFetchingNextPage &&
|
|
93
|
-
(loadingMore ?? (
|
|
94
|
-
<p className="text-muted-foreground pt-2 text-center text-xs">{t("common.working")}</p>
|
|
95
|
-
))}
|
|
96
|
-
{footer}
|
|
97
|
-
</>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AlertQueryError } from "../feedback/alert";
|
|
2
|
-
import type { MutationFeedbackProp } from "../../props/components/query.prop";
|
|
3
|
-
|
|
4
|
-
export type {
|
|
5
|
-
MutationFeedbackProp,
|
|
6
|
-
MutationFeedbackProp as MutationFeedbackProps,
|
|
7
|
-
} from "../../props/components/query.prop";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Inline mutation error — renders nothing when idle/success.
|
|
11
|
-
* Prefer toast for transient saves; use this for blocking form sections (SimulatorPage).
|
|
12
|
-
*/
|
|
13
|
-
export function MutationFeedback({
|
|
14
|
-
mutation,
|
|
15
|
-
onRetry,
|
|
16
|
-
showRetry = true,
|
|
17
|
-
pending,
|
|
18
|
-
className,
|
|
19
|
-
}: MutationFeedbackProp) {
|
|
20
|
-
if (mutation.isPending && pending) return <>{pending}</>;
|
|
21
|
-
|
|
22
|
-
if (!mutation.isError || mutation.error == null) return null;
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<AlertQueryError
|
|
26
|
-
className={className}
|
|
27
|
-
error={mutation.error}
|
|
28
|
-
onRetry={showRetry ? onRetry : undefined}
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Link } from "react-router-dom";
|
|
3
|
-
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
|
|
5
|
-
import type { PrefetchLinkProp } from "../../props/components/query.prop";
|
|
6
|
-
|
|
7
|
-
export type {
|
|
8
|
-
PrefetchLinkProp,
|
|
9
|
-
PrefetchLinkProp as PrefetchLinkProps,
|
|
10
|
-
} from "../../props/components/query.prop";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* React Router `Link` + `queryClient.prefetchQuery` on hover/focus.
|
|
14
|
-
* Detail routes feel instant when list rows are hovered.
|
|
15
|
-
*/
|
|
16
|
-
export function PrefetchLink({
|
|
17
|
-
queryKey,
|
|
18
|
-
queryFn,
|
|
19
|
-
prefetchOn = "both",
|
|
20
|
-
staleTime = 30_000,
|
|
21
|
-
onMouseEnter,
|
|
22
|
-
onFocus,
|
|
23
|
-
...linkProps
|
|
24
|
-
}: PrefetchLinkProp) {
|
|
25
|
-
const queryClient = useQueryClient();
|
|
26
|
-
|
|
27
|
-
const prefetch = React.useCallback(() => {
|
|
28
|
-
if (prefetchOn === "none") return;
|
|
29
|
-
void queryClient.prefetchQuery({ queryKey, queryFn, staleTime });
|
|
30
|
-
}, [prefetchOn, queryClient, queryFn, queryKey, staleTime]);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Link
|
|
34
|
-
{...linkProps}
|
|
35
|
-
onMouseEnter={(event) => {
|
|
36
|
-
if (prefetchOn === "hover" || prefetchOn === "both") prefetch();
|
|
37
|
-
onMouseEnter?.(event);
|
|
38
|
-
}}
|
|
39
|
-
onFocus={(event) => {
|
|
40
|
-
if (prefetchOn === "focus" || prefetchOn === "both") prefetch();
|
|
41
|
-
onFocus?.(event);
|
|
42
|
-
}}
|
|
43
|
-
/>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { RefreshCw } from "lucide-react";
|
|
2
|
-
|
|
3
|
-
import { Button } from "../general/button";
|
|
4
|
-
import type { QueryRefetchButtonProp } from "../../props/components/query.prop";
|
|
5
|
-
|
|
6
|
-
export type {
|
|
7
|
-
QueryRefetchButtonProp,
|
|
8
|
-
QueryRefetchButtonProp as QueryRefetchButtonProps,
|
|
9
|
-
} from "../../props/components/query.prop";
|
|
10
|
-
|
|
11
|
-
/** Page-header Refresh — spins while `query.isFetching`, calls `query.refetch()`. */
|
|
12
|
-
export function QueryRefetchButton({
|
|
13
|
-
query,
|
|
14
|
-
label = "Refresh",
|
|
15
|
-
children,
|
|
16
|
-
variant = "outline",
|
|
17
|
-
size = "sm",
|
|
18
|
-
className,
|
|
19
|
-
...props
|
|
20
|
-
}: QueryRefetchButtonProp) {
|
|
21
|
-
const text = children ?? label;
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<Button
|
|
25
|
-
type="button"
|
|
26
|
-
variant={variant}
|
|
27
|
-
size={size}
|
|
28
|
-
className={className}
|
|
29
|
-
onClick={() => void query.refetch()}
|
|
30
|
-
disabled={query.isFetching}
|
|
31
|
-
{...props}
|
|
32
|
-
>
|
|
33
|
-
<RefreshCw
|
|
34
|
-
className="ui-query-refetch-icon"
|
|
35
|
-
data-fetching={query.isFetching}
|
|
36
|
-
aria-hidden="true"
|
|
37
|
-
/>
|
|
38
|
-
{text}
|
|
39
|
-
</Button>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../feedback/dialog";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../feedback/alert";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../data-entry/autocomplete";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../data-display/badge";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../general/button";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../data-entry/calendar";
|