@senvenli/react 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +32 -2
- package/dist/action/button-group.d.ts +26 -0
- package/dist/action/button-group.js +12 -0
- package/dist/action/button-group.js.map +1 -0
- package/dist/action/button.d.ts +42 -0
- package/dist/action/button.js +58 -0
- package/dist/action/button.js.map +1 -0
- package/dist/action/close-button.d.ts +12 -0
- package/dist/action/close-button.js +13 -0
- package/dist/action/close-button.js.map +1 -0
- package/dist/action/copy-button.d.ts +21 -0
- package/dist/action/copy-button.js +38 -0
- package/dist/action/copy-button.js.map +1 -0
- package/dist/action/fab.d.ts +29 -0
- package/dist/action/fab.js +57 -0
- package/dist/action/fab.js.map +1 -0
- package/dist/action/files.d.ts +70 -0
- package/dist/action/files.js +156 -0
- package/dist/action/files.js.map +1 -0
- package/dist/action/index.d.ts +23 -0
- package/dist/action/index.js +16 -0
- package/dist/action/index.js.map +1 -0
- package/dist/action/language-names.d.ts +19 -0
- package/dist/action/language-names.js +79 -0
- package/dist/action/language-names.js.map +1 -0
- package/dist/action/language-switcher.d.ts +57 -0
- package/dist/action/language-switcher.js +53 -0
- package/dist/action/language-switcher.js.map +1 -0
- package/dist/action/link-button.d.ts +57 -0
- package/dist/action/link-button.js +48 -0
- package/dist/action/link-button.js.map +1 -0
- package/dist/action/link.d.ts +24 -0
- package/dist/action/link.js +18 -0
- package/dist/action/link.js.map +1 -0
- package/dist/action/pressable.d.ts +40 -0
- package/dist/action/pressable.js +65 -0
- package/dist/action/pressable.js.map +1 -0
- package/dist/action/styles.d.ts +60 -0
- package/dist/action/styles.js +109 -0
- package/dist/action/styles.js.map +1 -0
- package/dist/action/theme-script.d.ts +12 -0
- package/dist/action/theme-script.js +23 -0
- package/dist/action/theme-script.js.map +1 -0
- package/dist/action/theme-switcher.d.ts +43 -0
- package/dist/action/theme-switcher.js +260 -0
- package/dist/action/theme-switcher.js.map +1 -0
- package/dist/action/theme-toggle.d.ts +43 -0
- package/dist/action/theme-toggle.js +259 -0
- package/dist/action/theme-toggle.js.map +1 -0
- package/dist/action/toggle.d.ts +44 -0
- package/dist/action/toggle.js +28 -0
- package/dist/action/toggle.js.map +1 -0
- package/dist/action/touch-target.d.ts +9 -0
- package/dist/action/touch-target.js +14 -0
- package/dist/action/touch-target.js.map +1 -0
- package/dist/charts/axis-width.d.ts +186 -0
- package/dist/charts/axis-width.js +1262 -0
- package/dist/charts/axis-width.js.map +1 -0
- package/dist/charts/bar-public.d.ts +16 -0
- package/dist/charts/bar-public.js +16 -0
- package/dist/charts/bar-public.js.map +1 -0
- package/dist/charts/chart-parts.d.ts +136 -0
- package/dist/charts/chart-parts.js +160 -0
- package/dist/charts/chart-parts.js.map +1 -0
- package/dist/charts/core-charts.d.ts +157 -0
- package/dist/charts/core-charts.js +505 -0
- package/dist/charts/core-charts.js.map +1 -0
- package/dist/charts/index.d.ts +12 -0
- package/dist/charts/index.js +8 -0
- package/dist/charts/index.js.map +1 -0
- package/dist/charts/list-charts.d.ts +124 -0
- package/dist/charts/list-charts.js +308 -0
- package/dist/charts/list-charts.js.map +1 -0
- package/dist/charts/more-charts.d.ts +138 -0
- package/dist/charts/more-charts.js +284 -0
- package/dist/charts/more-charts.js.map +1 -0
- package/dist/charts/report-charts.d.ts +138 -0
- package/dist/charts/report-charts.js +370 -0
- package/dist/charts/report-charts.js.map +1 -0
- package/dist/charts/value-tick.d.ts +178 -0
- package/dist/charts/value-tick.js +240 -0
- package/dist/charts/value-tick.js.map +1 -0
- package/dist/collection/data-table-url-hook.d.ts +34 -0
- package/dist/collection/data-table-url-hook.js +70 -0
- package/dist/collection/data-table-url-hook.js.map +1 -0
- package/dist/collection/data-table-url.d.ts +30 -0
- package/dist/collection/data-table-url.js +48 -0
- package/dist/collection/data-table-url.js.map +1 -0
- package/dist/collection/data-table.d.ts +112 -0
- package/dist/collection/data-table.js +188 -0
- package/dist/collection/data-table.js.map +1 -0
- package/dist/collection/grid-list-public.d.ts +18 -0
- package/dist/collection/grid-list-public.js +19 -0
- package/dist/collection/grid-list-public.js.map +1 -0
- package/dist/collection/grid-list.d.ts +73 -0
- package/dist/collection/grid-list.js +46 -0
- package/dist/collection/grid-list.js.map +1 -0
- package/dist/collection/index.d.ts +14 -0
- package/dist/collection/index.js +8 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/list.d.ts +61 -0
- package/dist/collection/list.js +38 -0
- package/dist/collection/list.js.map +1 -0
- package/dist/collection/selection-checkbox.d.ts +5 -0
- package/dist/collection/selection-checkbox.js +13 -0
- package/dist/collection/selection-checkbox.js.map +1 -0
- package/dist/collection/table.d.ts +91 -0
- package/dist/collection/table.js +183 -0
- package/dist/collection/table.js.map +1 -0
- package/dist/collection/tree.d.ts +31 -0
- package/dist/collection/tree.js +22 -0
- package/dist/collection/tree.js.map +1 -0
- package/dist/color/color.d.ts +87 -0
- package/dist/color/color.js +200 -0
- package/dist/color/color.js.map +1 -0
- package/dist/color/contrast.d.ts +34 -0
- package/dist/color/contrast.js +44 -0
- package/dist/color/contrast.js.map +1 -0
- package/dist/color/index.d.ts +4 -0
- package/dist/color/index.js +5 -0
- package/dist/color/index.js.map +1 -0
- package/dist/date/calendar.d.ts +71 -0
- package/dist/date/calendar.js +291 -0
- package/dist/date/calendar.js.map +1 -0
- package/dist/date/fields.d.ts +174 -0
- package/dist/date/fields.js +250 -0
- package/dist/date/fields.js.map +1 -0
- package/dist/date/index.d.ts +7 -0
- package/dist/date/index.js +6 -0
- package/dist/date/index.js.map +1 -0
- package/dist/date/month-grid.d.ts +31 -0
- package/dist/date/month-grid.js +115 -0
- package/dist/date/month-grid.js.map +1 -0
- package/dist/date/pickers.d.ts +118 -0
- package/dist/date/pickers.js +176 -0
- package/dist/date/pickers.js.map +1 -0
- package/dist/date/public.d.ts +25 -0
- package/dist/date/public.js +24 -0
- package/dist/date/public.js.map +1 -0
- package/dist/date/segments.d.ts +153 -0
- package/dist/date/segments.js +433 -0
- package/dist/date/segments.js.map +1 -0
- package/dist/defaults.d.ts +74 -0
- package/dist/defaults.js +100 -0
- package/dist/defaults.js.map +1 -0
- package/dist/density.d.ts +2 -0
- package/dist/density.js +2 -0
- package/dist/density.js.map +1 -0
- package/dist/display/avatar.d.ts +29 -0
- package/dist/display/avatar.js +71 -0
- package/dist/display/avatar.js.map +1 -0
- package/dist/display/badge.d.ts +65 -0
- package/dist/display/badge.js +99 -0
- package/dist/display/badge.js.map +1 -0
- package/dist/display/card.d.ts +72 -0
- package/dist/display/card.js +91 -0
- package/dist/display/card.js.map +1 -0
- package/dist/display/carousel.d.ts +47 -0
- package/dist/display/carousel.js +214 -0
- package/dist/display/carousel.js.map +1 -0
- package/dist/display/description-list.d.ts +25 -0
- package/dist/display/description-list.js +36 -0
- package/dist/display/description-list.js.map +1 -0
- package/dist/display/icon-aliases.d.ts +1 -0
- package/dist/display/icon-aliases.js +259 -0
- package/dist/display/icon-aliases.js.map +1 -0
- package/dist/display/icon-names.d.ts +4 -0
- package/dist/display/icon-names.js +2 -0
- package/dist/display/icon-names.js.map +1 -0
- package/dist/display/icon.d.ts +51 -0
- package/dist/display/icon.js +96 -0
- package/dist/display/icon.js.map +1 -0
- package/dist/display/image-crop.d.ts +106 -0
- package/dist/display/image-crop.js +117 -0
- package/dist/display/image-crop.js.map +1 -0
- package/dist/display/image-cropper.d.ts +68 -0
- package/dist/display/image-cropper.js +284 -0
- package/dist/display/image-cropper.js.map +1 -0
- package/dist/display/image-viewer.d.ts +54 -0
- package/dist/display/image-viewer.js +84 -0
- package/dist/display/image-viewer.js.map +1 -0
- package/dist/display/image.d.ts +26 -0
- package/dist/display/image.js +17 -0
- package/dist/display/image.js.map +1 -0
- package/dist/display/index.d.ts +29 -0
- package/dist/display/index.js +16 -0
- package/dist/display/index.js.map +1 -0
- package/dist/display/iso-chip.d.ts +19 -0
- package/dist/display/iso-chip.js +21 -0
- package/dist/display/iso-chip.js.map +1 -0
- package/dist/display/kbd.d.ts +11 -0
- package/dist/display/kbd.js +33 -0
- package/dist/display/kbd.js.map +1 -0
- package/dist/display/lozenge.d.ts +30 -0
- package/dist/display/lozenge.js +55 -0
- package/dist/display/lozenge.js.map +1 -0
- package/dist/display/scroll-area.d.ts +29 -0
- package/dist/display/scroll-area.js +95 -0
- package/dist/display/scroll-area.js.map +1 -0
- package/dist/display/separator.d.ts +13 -0
- package/dist/display/separator.js +24 -0
- package/dist/display/separator.js.map +1 -0
- package/dist/display/stat.d.ts +35 -0
- package/dist/display/stat.js +41 -0
- package/dist/display/stat.js.map +1 -0
- package/dist/display/timeline.d.ts +44 -0
- package/dist/display/timeline.js +111 -0
- package/dist/display/timeline.js.map +1 -0
- package/dist/display/typography.d.ts +37 -0
- package/dist/display/typography.js +53 -0
- package/dist/display/typography.js.map +1 -0
- package/dist/display/visually-hidden.d.ts +14 -0
- package/dist/display/visually-hidden.js +10 -0
- package/dist/display/visually-hidden.js.map +1 -0
- package/dist/feedback/banner.d.ts +46 -0
- package/dist/feedback/banner.js +157 -0
- package/dist/feedback/banner.js.map +1 -0
- package/dist/feedback/cooldown.d.ts +17 -0
- package/dist/feedback/cooldown.js +59 -0
- package/dist/feedback/cooldown.js.map +1 -0
- package/dist/feedback/empty-state.d.ts +35 -0
- package/dist/feedback/empty-state.js +39 -0
- package/dist/feedback/empty-state.js.map +1 -0
- package/dist/feedback/index.d.ts +12 -0
- package/dist/feedback/index.js +11 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/feedback/meter.d.ts +33 -0
- package/dist/feedback/meter.js +42 -0
- package/dist/feedback/meter.js.map +1 -0
- package/dist/feedback/motion.d.ts +9 -0
- package/dist/feedback/motion.js +57 -0
- package/dist/feedback/motion.js.map +1 -0
- package/dist/feedback/progress.d.ts +39 -0
- package/dist/feedback/progress.js +68 -0
- package/dist/feedback/progress.js.map +1 -0
- package/dist/feedback/skeleton.d.ts +48 -0
- package/dist/feedback/skeleton.js +61 -0
- package/dist/feedback/skeleton.js.map +1 -0
- package/dist/feedback/spinner.d.ts +19 -0
- package/dist/feedback/spinner.js +29 -0
- package/dist/feedback/spinner.js.map +1 -0
- package/dist/feedback/status-dot.d.ts +23 -0
- package/dist/feedback/status-dot.js +37 -0
- package/dist/feedback/status-dot.js.map +1 -0
- package/dist/form/countries.d.ts +34 -0
- package/dist/form/countries.js +273 -0
- package/dist/form/countries.js.map +1 -0
- package/dist/form/data-attributes.d.ts +11 -0
- package/dist/form/data-attributes.js +22 -0
- package/dist/form/data-attributes.js.map +1 -0
- package/dist/form/field-parts.d.ts +113 -0
- package/dist/form/field-parts.js +178 -0
- package/dist/form/field-parts.js.map +1 -0
- package/dist/form/field.d.ts +36 -0
- package/dist/form/field.js +65 -0
- package/dist/form/field.js.map +1 -0
- package/dist/form/files.d.ts +70 -0
- package/dist/form/files.js +156 -0
- package/dist/form/files.js.map +1 -0
- package/dist/form/form.d.ts +40 -0
- package/dist/form/form.js +74 -0
- package/dist/form/form.js.map +1 -0
- package/dist/form/image-crop.d.ts +106 -0
- package/dist/form/image-crop.js +117 -0
- package/dist/form/image-crop.js.map +1 -0
- package/dist/form/image-cropper.d.ts +68 -0
- package/dist/form/image-cropper.js +284 -0
- package/dist/form/image-cropper.js.map +1 -0
- package/dist/form/index.d.ts +24 -0
- package/dist/form/index.js +15 -0
- package/dist/form/index.js.map +1 -0
- package/dist/form/input-group.d.ts +63 -0
- package/dist/form/input-group.js +63 -0
- package/dist/form/input-group.js.map +1 -0
- package/dist/form/input-otp.d.ts +35 -0
- package/dist/form/input-otp.js +83 -0
- package/dist/form/input-otp.js.map +1 -0
- package/dist/form/input.d.ts +36 -0
- package/dist/form/input.js +41 -0
- package/dist/form/input.js.map +1 -0
- package/dist/form/number-field.d.ts +84 -0
- package/dist/form/number-field.js +81 -0
- package/dist/form/number-field.js.map +1 -0
- package/dist/form/otp-field.d.ts +37 -0
- package/dist/form/otp-field.js +116 -0
- package/dist/form/otp-field.js.map +1 -0
- package/dist/form/password-field.d.ts +61 -0
- package/dist/form/password-field.js +61 -0
- package/dist/form/password-field.js.map +1 -0
- package/dist/form/phone-field.d.ts +104 -0
- package/dist/form/phone-field.js +275 -0
- package/dist/form/phone-field.js.map +1 -0
- package/dist/form/phone-paste.d.ts +24 -0
- package/dist/form/phone-paste.js +40 -0
- package/dist/form/phone-paste.js.map +1 -0
- package/dist/form/phone.d.ts +159 -0
- package/dist/form/phone.js +309 -0
- package/dist/form/phone.js.map +1 -0
- package/dist/form/search-field.d.ts +29 -0
- package/dist/form/search-field.js +23 -0
- package/dist/form/search-field.js.map +1 -0
- package/dist/form/styles.d.ts +31 -0
- package/dist/form/styles.js +43 -0
- package/dist/form/styles.js.map +1 -0
- package/dist/form/text-area.d.ts +70 -0
- package/dist/form/text-area.js +93 -0
- package/dist/form/text-area.js.map +1 -0
- package/dist/form/text-field.d.ts +131 -0
- package/dist/form/text-field.js +59 -0
- package/dist/form/text-field.js.map +1 -0
- package/dist/form/validation.d.ts +145 -0
- package/dist/form/validation.js +136 -0
- package/dist/form/validation.js.map +1 -0
- package/dist/i18n.d.ts +438 -0
- package/dist/i18n.js +948 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/intl-locale.d.ts +30 -0
- package/dist/intl-locale.js +83 -0
- package/dist/intl-locale.js.map +1 -0
- package/dist/layers.d.ts +32 -0
- package/dist/layers.js +33 -0
- package/dist/layers.js.map +1 -0
- package/dist/layout/auth-form-layout.d.ts +71 -0
- package/dist/layout/auth-form-layout.js +61 -0
- package/dist/layout/auth-form-layout.js.map +1 -0
- package/dist/layout/auth-layout.d.ts +59 -0
- package/dist/layout/auth-layout.js +26 -0
- package/dist/layout/auth-layout.js.map +1 -0
- package/dist/layout/box.d.ts +26 -0
- package/dist/layout/box.js +16 -0
- package/dist/layout/box.js.map +1 -0
- package/dist/layout/grid.d.ts +27 -0
- package/dist/layout/grid.js +26 -0
- package/dist/layout/grid.js.map +1 -0
- package/dist/layout/index.d.ts +16 -0
- package/dist/layout/index.js +12 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/pressable.d.ts +40 -0
- package/dist/layout/pressable.js +65 -0
- package/dist/layout/pressable.js.map +1 -0
- package/dist/layout/reset-sent-card.d.ts +39 -0
- package/dist/layout/reset-sent-card.js +22 -0
- package/dist/layout/reset-sent-card.js.map +1 -0
- package/dist/layout/scroll-area.d.ts +29 -0
- package/dist/layout/scroll-area.js +95 -0
- package/dist/layout/scroll-area.js.map +1 -0
- package/dist/layout/section.d.ts +41 -0
- package/dist/layout/section.js +22 -0
- package/dist/layout/section.js.map +1 -0
- package/dist/layout/split.d.ts +50 -0
- package/dist/layout/split.js +35 -0
- package/dist/layout/split.js.map +1 -0
- package/dist/layout/stack.d.ts +44 -0
- package/dist/layout/stack.js +36 -0
- package/dist/layout/stack.js.map +1 -0
- package/dist/layout/tokens.d.ts +33 -0
- package/dist/layout/tokens.js +85 -0
- package/dist/layout/tokens.js.map +1 -0
- package/dist/layout/toolbar.d.ts +37 -0
- package/dist/layout/toolbar.js +334 -0
- package/dist/layout/toolbar.js.map +1 -0
- package/dist/navigate-context.d.ts +12 -0
- package/dist/navigate-context.js +13 -0
- package/dist/navigate-context.js.map +1 -0
- package/dist/navigation/accordion.d.ts +40 -0
- package/dist/navigation/accordion.js +33 -0
- package/dist/navigation/accordion.js.map +1 -0
- package/dist/navigation/bottom-nav.d.ts +29 -0
- package/dist/navigation/bottom-nav.js +48 -0
- package/dist/navigation/bottom-nav.js.map +1 -0
- package/dist/navigation/brand-link-context.d.ts +8 -0
- package/dist/navigation/brand-link-context.js +9 -0
- package/dist/navigation/brand-link-context.js.map +1 -0
- package/dist/navigation/breadcrumbs.d.ts +36 -0
- package/dist/navigation/breadcrumbs.js +51 -0
- package/dist/navigation/breadcrumbs.js.map +1 -0
- package/dist/navigation/dock.d.ts +27 -0
- package/dist/navigation/dock.js +47 -0
- package/dist/navigation/dock.js.map +1 -0
- package/dist/navigation/footer.d.ts +43 -0
- package/dist/navigation/footer.js +43 -0
- package/dist/navigation/footer.js.map +1 -0
- package/dist/navigation/index.d.ts +22 -0
- package/dist/navigation/index.js +17 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/navigation/language-names.d.ts +19 -0
- package/dist/navigation/language-names.js +79 -0
- package/dist/navigation/language-names.js.map +1 -0
- package/dist/navigation/language-switcher.d.ts +55 -0
- package/dist/navigation/language-switcher.js +53 -0
- package/dist/navigation/language-switcher.js.map +1 -0
- package/dist/navigation/nav-panel.d.ts +18 -0
- package/dist/navigation/nav-panel.js +51 -0
- package/dist/navigation/nav-panel.js.map +1 -0
- package/dist/navigation/navbar.d.ts +73 -0
- package/dist/navigation/navbar.js +64 -0
- package/dist/navigation/navbar.js.map +1 -0
- package/dist/navigation/page-header.d.ts +37 -0
- package/dist/navigation/page-header.js +50 -0
- package/dist/navigation/page-header.js.map +1 -0
- package/dist/navigation/pagination.d.ts +25 -0
- package/dist/navigation/pagination.js +51 -0
- package/dist/navigation/pagination.js.map +1 -0
- package/dist/navigation/panel-header.d.ts +37 -0
- package/dist/navigation/panel-header.js +50 -0
- package/dist/navigation/panel-header.js.map +1 -0
- package/dist/navigation/sidebar-script.d.ts +12 -0
- package/dist/navigation/sidebar-script.js +20 -0
- package/dist/navigation/sidebar-script.js.map +1 -0
- package/dist/navigation/sidebar.d.ts +149 -0
- package/dist/navigation/sidebar.js +332 -0
- package/dist/navigation/sidebar.js.map +1 -0
- package/dist/navigation/skip-link.d.ts +12 -0
- package/dist/navigation/skip-link.js +30 -0
- package/dist/navigation/skip-link.js.map +1 -0
- package/dist/navigation/stepper.d.ts +50 -0
- package/dist/navigation/stepper.js +96 -0
- package/dist/navigation/stepper.js.map +1 -0
- package/dist/navigation/tabs.d.ts +84 -0
- package/dist/navigation/tabs.js +118 -0
- package/dist/navigation/tabs.js.map +1 -0
- package/dist/navigation/toolbar.d.ts +37 -0
- package/dist/navigation/toolbar.js +334 -0
- package/dist/navigation/toolbar.js.map +1 -0
- package/dist/overlay/alert-dialog.d.ts +63 -0
- package/dist/overlay/alert-dialog.js +76 -0
- package/dist/overlay/alert-dialog.js.map +1 -0
- package/dist/overlay/command-palette.d.ts +53 -0
- package/dist/overlay/command-palette.js +130 -0
- package/dist/overlay/command-palette.js.map +1 -0
- package/dist/overlay/command.d.ts +53 -0
- package/dist/overlay/command.js +129 -0
- package/dist/overlay/command.js.map +1 -0
- package/dist/overlay/context-menu.d.ts +29 -0
- package/dist/overlay/context-menu.js +58 -0
- package/dist/overlay/context-menu.js.map +1 -0
- package/dist/overlay/dialog.d.ts +162 -0
- package/dist/overlay/dialog.js +174 -0
- package/dist/overlay/dialog.js.map +1 -0
- package/dist/overlay/drawer.d.ts +41 -0
- package/dist/overlay/drawer.js +114 -0
- package/dist/overlay/drawer.js.map +1 -0
- package/dist/overlay/floating.d.ts +142 -0
- package/dist/overlay/floating.js +226 -0
- package/dist/overlay/floating.js.map +1 -0
- package/dist/overlay/hover-card.d.ts +19 -0
- package/dist/overlay/hover-card.js +31 -0
- package/dist/overlay/hover-card.js.map +1 -0
- package/dist/overlay/index.d.ts +18 -0
- package/dist/overlay/index.js +12 -0
- package/dist/overlay/index.js.map +1 -0
- package/dist/overlay/overlay-base.d.ts +105 -0
- package/dist/overlay/overlay-base.js +250 -0
- package/dist/overlay/overlay-base.js.map +1 -0
- package/dist/overlay/overlay.d.ts +299 -0
- package/dist/overlay/overlay.js +558 -0
- package/dist/overlay/overlay.js.map +1 -0
- package/dist/overlay/toast.d.ts +58 -0
- package/dist/overlay/toast.js +145 -0
- package/dist/overlay/toast.js.map +1 -0
- package/dist/provider.d.ts +26 -0
- package/dist/provider.js +30 -0
- package/dist/provider.js.map +1 -0
- package/dist/selection/autocomplete.d.ts +54 -0
- package/dist/selection/autocomplete.js +122 -0
- package/dist/selection/autocomplete.js.map +1 -0
- package/dist/selection/checkbox.d.ts +56 -0
- package/dist/selection/checkbox.js +49 -0
- package/dist/selection/checkbox.js.map +1 -0
- package/dist/selection/choice-size.d.ts +26 -0
- package/dist/selection/choice-size.js +50 -0
- package/dist/selection/choice-size.js.map +1 -0
- package/dist/selection/choice-text.d.ts +21 -0
- package/dist/selection/choice-text.js +33 -0
- package/dist/selection/choice-text.js.map +1 -0
- package/dist/selection/combobox.d.ts +173 -0
- package/dist/selection/combobox.js +410 -0
- package/dist/selection/combobox.js.map +1 -0
- package/dist/selection/index.d.ts +20 -0
- package/dist/selection/index.js +13 -0
- package/dist/selection/index.js.map +1 -0
- package/dist/selection/list-box.d.ts +30 -0
- package/dist/selection/list-box.js +16 -0
- package/dist/selection/list-box.js.map +1 -0
- package/dist/selection/listbox.d.ts +44 -0
- package/dist/selection/listbox.js +49 -0
- package/dist/selection/listbox.js.map +1 -0
- package/dist/selection/match.d.ts +20 -0
- package/dist/selection/match.js +57 -0
- package/dist/selection/match.js.map +1 -0
- package/dist/selection/multi-select.d.ts +72 -0
- package/dist/selection/multi-select.js +138 -0
- package/dist/selection/multi-select.js.map +1 -0
- package/dist/selection/radio-card.d.ts +31 -0
- package/dist/selection/radio-card.js +29 -0
- package/dist/selection/radio-card.js.map +1 -0
- package/dist/selection/radio.d.ts +72 -0
- package/dist/selection/radio.js +64 -0
- package/dist/selection/radio.js.map +1 -0
- package/dist/selection/select-public.d.ts +19 -0
- package/dist/selection/select-public.js +24 -0
- package/dist/selection/select-public.js.map +1 -0
- package/dist/selection/select.d.ts +72 -0
- package/dist/selection/select.js +69 -0
- package/dist/selection/select.js.map +1 -0
- package/dist/selection/slider.d.ts +16 -0
- package/dist/selection/slider.js +44 -0
- package/dist/selection/slider.js.map +1 -0
- package/dist/selection/styles.d.ts +26 -0
- package/dist/selection/styles.js +78 -0
- package/dist/selection/styles.js.map +1 -0
- package/dist/selection/switch.d.ts +24 -0
- package/dist/selection/switch.js +27 -0
- package/dist/selection/switch.js.map +1 -0
- package/dist/selection/tag-group.d.ts +38 -0
- package/dist/selection/tag-group.js +45 -0
- package/dist/selection/tag-group.js.map +1 -0
- package/dist/tone.d.ts +6 -0
- package/dist/tone.js +2 -0
- package/dist/tone.js.map +1 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +42 -0
- package/dist/utils.js.map +1 -0
- package/manifest/component.full.schema.json +391 -0
- package/manifest/component.schema.json +279 -0
- package/manifests/accordion.json +299 -0
- package/manifests/alert-dialog.json +261 -0
- package/manifests/area-chart.json +338 -0
- package/manifests/autocomplete.json +299 -0
- package/manifests/avatar.json +253 -0
- package/manifests/badge.json +288 -0
- package/manifests/banner.json +185 -0
- package/manifests/bar-chart.json +454 -0
- package/manifests/bar-list.json +262 -0
- package/manifests/bottom-nav.json +139 -0
- package/manifests/box.json +3450 -0
- package/manifests/breadcrumbs.json +199 -0
- package/manifests/button-group.json +2294 -0
- package/manifests/button.json +1211 -0
- package/manifests/calendar-heatmap.json +218 -0
- package/manifests/calendar.json +299 -0
- package/manifests/card.json +308 -0
- package/manifests/carousel.json +263 -0
- package/manifests/chart-parts.json +309 -0
- package/manifests/checkbox.json +998 -0
- package/manifests/close-button.json +1000 -0
- package/manifests/color-field.json +276 -0
- package/manifests/color-picker.json +161 -0
- package/manifests/color-swatch-picker.json +220 -0
- package/manifests/color-swatch.json +140 -0
- package/manifests/combobox.json +581 -0
- package/manifests/command.json +275 -0
- package/manifests/composed-chart.json +287 -0
- package/manifests/context-menu.json +148 -0
- package/manifests/copy-button.json +192 -0
- package/manifests/data-table.json +334 -0
- package/manifests/date-field.json +302 -0
- package/manifests/date-picker.json +472 -0
- package/manifests/description-list.json +201 -0
- package/manifests/dialog.json +322 -0
- package/manifests/donut-chart.json +264 -0
- package/manifests/drawer.json +211 -0
- package/manifests/empty-state.json +185 -0
- package/manifests/fab.json +172 -0
- package/manifests/field.json +209 -0
- package/manifests/file-upload.json +791 -0
- package/manifests/form.json +829 -0
- package/manifests/funnel-chart.json +223 -0
- package/manifests/gauge-chart.json +252 -0
- package/manifests/grid-list.json +335 -0
- package/manifests/grid.json +3482 -0
- package/manifests/heading.json +183 -0
- package/manifests/heatmap.json +265 -0
- package/manifests/hover-card.json +172 -0
- package/manifests/icon.json +201 -0
- package/manifests/image-cropper.json +295 -0
- package/manifests/image-viewer.json +198 -0
- package/manifests/image.json +193 -0
- package/manifests/index.json +2035 -0
- package/manifests/input-group.json +3571 -0
- package/manifests/input.json +1557 -0
- package/manifests/kbd.json +98 -0
- package/manifests/language-switcher.json +274 -0
- package/manifests/line-chart.json +342 -0
- package/manifests/link.json +867 -0
- package/manifests/list-box.json +213 -0
- package/manifests/menu.json +453 -0
- package/manifests/meter.json +145 -0
- package/manifests/navbar.json +281 -0
- package/manifests/otp-field.json +1029 -0
- package/manifests/page-header.json +164 -0
- package/manifests/pagination.json +181 -0
- package/manifests/popover.json +205 -0
- package/manifests/pressable.json +367 -0
- package/manifests/progress.json +282 -0
- package/manifests/radar-chart.json +229 -0
- package/manifests/radial-chart.json +195 -0
- package/manifests/radio.json +975 -0
- package/manifests/scatter-chart.json +277 -0
- package/manifests/scroll-area.json +127 -0
- package/manifests/section.json +169 -0
- package/manifests/select.json +474 -0
- package/manifests/separator.json +119 -0
- package/manifests/sidebar.json +584 -0
- package/manifests/skeleton.json +235 -0
- package/manifests/skip-link.json +89 -0
- package/manifests/slider.json +706 -0
- package/manifests/sparkline.json +208 -0
- package/manifests/spinner.json +105 -0
- package/manifests/split.json +6618 -0
- package/manifests/stack.json +3541 -0
- package/manifests/stat.json +192 -0
- package/manifests/stepper.json +279 -0
- package/manifests/switch.json +205 -0
- package/manifests/table.json +375 -0
- package/manifests/tabs.json +438 -0
- package/manifests/tag-group.json +264 -0
- package/manifests/text-area.json +1136 -0
- package/manifests/text.json +244 -0
- package/manifests/theme-switcher.json +152 -0
- package/manifests/time-field.json +284 -0
- package/manifests/timeline.json +196 -0
- package/manifests/toast.json +87 -0
- package/manifests/toggle-button.json +1489 -0
- package/manifests/toolbar.json +145 -0
- package/manifests/tooltip.json +181 -0
- package/manifests/tracker.json +192 -0
- package/manifests/tree.json +245 -0
- package/manifests/visually-hidden.json +114 -0
- package/package.json +117 -3
- package/styles/base.css +56 -0
- package/styles/theme.css +154 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table-url-hook.js","sourceRoot":"","sources":["../../src/collection/data-table-url-hook.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAsB,MAAM,kBAAkB,CAAC;AAqB3E,MAAM,UAAU,GAAkC,EAAE,CAAC;AAErD,SAAS,aAAa,CAAC,YAAuC;IAC5D,IAAI,YAAY,KAAK,SAAS;QAAE,OAAO,IAAI,eAAe,CAAC,YAAY,CAAC,CAAC;IACzE,OAAO,IAAI,eAAe,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC1F,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,EAAE,OAAO,GAAG,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,KAA6B,EAAE;IAIrI,MAAM,QAAQ,GAAG,uBAAuB,EAAE,CAAC;IAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACvF,MAAM,UAAU,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;IACvD,oHAAoH;IACpH,MAAM,QAAQ,GAAG,CAAC,MAAuB,EAAiB,EAAE;QAC1D,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE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AAU,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,MAAM,SAAS,GAAG,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;IACxG,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC5C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,WAAW,CAAC,OAAO;YAAE,OAAO;QACzE,WAAW,CAAC,OAAO,GAAG,SAAS,CAAC;QAChC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AAChC,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport type { SortDescriptor } from \"react-aria-components\";\n\nimport { useDesignSystemNavigate } from \"../navigate-context\";\nimport { readView, writeView, type DataTableView } from \"./data-table-url\";\n\nexport type DataTableUrlFilter = { key: string; options: readonly { id: string }[] };\n\nexport type UseDataTableUrlOptions = {\n /** The table's `filters`: only their keys are read from the URL, and only values they offer. */\n filters?: readonly DataTableUrlFilter[];\n /** The table's `defaultSort`, left out of the URL. */\n defaultSort?: SortDescriptor;\n /** Prefixes the URL params (`orders.page`) when two tables share a page. */\n urlKey?: string;\n /**\n * The URL's search params. Pass them when the page renders on the server (SSR): without them the server\n * reads no params while the browser reads `window.location.search`, and a URL with params hydrates with a\n * mismatch. A host router can also pass its current params here; the view follows when they change.\n */\n searchParams?: URLSearchParams | string;\n /** Passed to the provider's `navigate` with each view change (a host router's replace or scroll option). */\n routerOptions?: unknown;\n};\n\nconst NO_FILTERS: readonly DataTableUrlFilter[] = [];\n\nfunction initialParams(searchParams?: URLSearchParams | string) {\n if (searchParams !== undefined) return new URLSearchParams(searchParams);\n return new URLSearchParams(typeof window === \"undefined\" ? \"\" : window.location.search);\n}\n\n/**\n * Keeps a DataTable's view in the URL, so a reload or a shared link shows the same page, sort, filters and search:\n * `<DataTable {...useDataTableUrl({ filters, defaultSort })} … />`. Reads the URL on mount, writes every change through\n * the provider's `navigate`, and follows Back and Forward and a host router's new `searchParams`. The format is\n * flat and readable (`?q=acme&status=active&sort=name&dir=desc&page=2`); defaults are left out.\n */\nexport function useDataTableUrl({ filters = NO_FILTERS, defaultSort, urlKey, searchParams, routerOptions }: UseDataTableUrlOptions = {}): {\n view: DataTableView;\n onViewChange: (view: DataTableView) => void;\n} {\n const navigate = useDesignSystemNavigate();\n const filterKeys = React.useMemo(() => filters.map((filter) => filter.key), [filters]);\n const urlOptions = { urlKey, filterKeys, defaultSort };\n // A view from a URL, keeping only filter values the table offers (a stale or hand-edited `?status=foo` is ignored).\n const viewFrom = (params: URLSearchParams): DataTableView => {\n const read = readView(params, urlOptions);\n const known = Object.fromEntries(\n filters\n .map((filter) => [filter.key, (read.filters[filter.key] ?? []).filter((value) => filter.options.some((option) => option.id === value))] as const)\n .filter(([, values]) => values.length > 0),\n );\n return { ...read, filters: known };\n };\n const [view, setView] = React.useState<DataTableView>(() => viewFrom(initialParams(searchParams)));\n const viewRef = React.useRef(view);\n viewRef.current = view;\n\n const onViewChange = (next: DataTableView) => {\n viewRef.current = next;\n setView(next);\n if (!navigate || typeof window === \"undefined\") return;\n const params = writeView(new URLSearchParams(window.location.search), next, urlOptions).toString();\n const href = `${window.location.pathname}${params ? `?${params}` : \"\"}${window.location.hash}`;\n if (href !== `${window.location.pathname}${window.location.search}${window.location.hash}`) navigate(href, routerOptions as never);\n };\n\n // The URL moved under the table: Back and Forward, or a host router handing new `searchParams`.\n const adopt = (next: DataTableView) => {\n if (JSON.stringify(next) === JSON.stringify(viewRef.current)) return;\n viewRef.current = next;\n setView(next);\n };\n const adoptRef = React.useRef(adopt);\n adoptRef.current = adopt;\n const viewFromRef = React.useRef(viewFrom);\n viewFromRef.current = viewFrom;\n React.useEffect(() => {\n if (typeof window === \"undefined\") return;\n const onPop = () => adoptRef.current(viewFromRef.current(new URLSearchParams(window.location.search)));\n window.addEventListener(\"popstate\", onPop);\n return () => window.removeEventListener(\"popstate\", onPop);\n }, []);\n const paramsKey = searchParams === undefined ? undefined : new URLSearchParams(searchParams).toString();\n const firstParams = React.useRef(paramsKey);\n React.useEffect(() => {\n if (paramsKey === undefined || paramsKey === firstParams.current) return;\n firstParams.current = paramsKey;\n adoptRef.current(viewFromRef.current(new URLSearchParams(paramsKey)));\n }, [paramsKey]);\n\n return { view, onViewChange };\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SortDescriptor } from "react-aria-components";
|
|
2
|
+
/**
|
|
3
|
+
* How a DataTable's view is written in the URL. One module on purpose: the format is a public contract
|
|
4
|
+
* (links get shared and bookmarked), and a change touches only this file.
|
|
5
|
+
*
|
|
6
|
+
* Flat and readable: `?q=acme&status=active&status=paused&sort=name&dir=desc&page=2`
|
|
7
|
+
* - `q` the search, `page` 1-based, `sort` the column key with `dir=asc|desc`;
|
|
8
|
+
* - each filter its own param named by its key, a multi-value filter repeated (values may hold commas);
|
|
9
|
+
* - defaults are left out (page 1, the default sort, no search, no filters), so a plain list has a clean URL;
|
|
10
|
+
* - `urlKey` prefixes every name (`orders.page`) when two tables share a page.
|
|
11
|
+
* Params that are not the table's are kept as they are.
|
|
12
|
+
*/
|
|
13
|
+
export type DataTableView = {
|
|
14
|
+
/** 1-based. */
|
|
15
|
+
page: number;
|
|
16
|
+
sort?: SortDescriptor;
|
|
17
|
+
search: string;
|
|
18
|
+
/** Filter key → the selected values; a key with no values is not filtering. */
|
|
19
|
+
filters: Readonly<Record<string, readonly string[]>>;
|
|
20
|
+
};
|
|
21
|
+
export type DataTableUrlOptions = {
|
|
22
|
+
urlKey?: string;
|
|
23
|
+
/** The filter keys the table knows; other params are never read as filters. */
|
|
24
|
+
filterKeys: readonly string[];
|
|
25
|
+
defaultSort?: SortDescriptor;
|
|
26
|
+
};
|
|
27
|
+
/** The view a URL holds, with defaults for what it leaves out. */
|
|
28
|
+
export declare function readView(params: URLSearchParams, { urlKey, filterKeys, defaultSort }: DataTableUrlOptions): DataTableView;
|
|
29
|
+
/** The URL params for a view: the table's own names rewritten, every other param kept. */
|
|
30
|
+
export declare function writeView(base: URLSearchParams, view: DataTableView, { urlKey, filterKeys, defaultSort }: DataTableUrlOptions): URLSearchParams;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const RESERVED = ["q", "sort", "dir", "page"];
|
|
2
|
+
const nameOf = (name, urlKey) => (urlKey ? `${urlKey}.${name}` : name);
|
|
3
|
+
/** The view a URL holds, with defaults for what it leaves out. */
|
|
4
|
+
export function readView(params, { urlKey, filterKeys, defaultSort }) {
|
|
5
|
+
const get = (name) => params.get(nameOf(name, urlKey));
|
|
6
|
+
const page = Number.parseInt(get("page") ?? "", 10);
|
|
7
|
+
const column = get("sort");
|
|
8
|
+
const dir = get("dir");
|
|
9
|
+
const filters = {};
|
|
10
|
+
for (const key of filterKeys) {
|
|
11
|
+
if (RESERVED.includes(key))
|
|
12
|
+
continue;
|
|
13
|
+
const values = params.getAll(nameOf(key, urlKey)).filter(Boolean);
|
|
14
|
+
if (values.length)
|
|
15
|
+
filters[key] = values;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
page: Number.isFinite(page) && page > 0 ? page : 1,
|
|
19
|
+
sort: column ? { column, direction: dir === "desc" ? "descending" : "ascending" } : defaultSort,
|
|
20
|
+
search: get("q") ?? "",
|
|
21
|
+
filters,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** The URL params for a view: the table's own names rewritten, every other param kept. */
|
|
25
|
+
export function writeView(base, view, { urlKey, filterKeys, defaultSort }) {
|
|
26
|
+
const next = new URLSearchParams(base);
|
|
27
|
+
for (const name of [...RESERVED, ...filterKeys])
|
|
28
|
+
next.delete(nameOf(name, urlKey));
|
|
29
|
+
const search = view.search.trim();
|
|
30
|
+
if (search)
|
|
31
|
+
next.set(nameOf("q", urlKey), search);
|
|
32
|
+
for (const key of filterKeys) {
|
|
33
|
+
if (RESERVED.includes(key))
|
|
34
|
+
continue;
|
|
35
|
+
for (const value of view.filters[key] ?? [])
|
|
36
|
+
next.append(nameOf(key, urlKey), value);
|
|
37
|
+
}
|
|
38
|
+
const isDefaultSort = (!view.sort && !defaultSort) ||
|
|
39
|
+
(view.sort && defaultSort && String(view.sort.column) === String(defaultSort.column) && view.sort.direction === defaultSort.direction);
|
|
40
|
+
if (view.sort && !isDefaultSort) {
|
|
41
|
+
next.set(nameOf("sort", urlKey), String(view.sort.column));
|
|
42
|
+
next.set(nameOf("dir", urlKey), view.sort.direction === "descending" ? "desc" : "asc");
|
|
43
|
+
}
|
|
44
|
+
if (view.page > 1)
|
|
45
|
+
next.set(nameOf("page", urlKey), String(view.page));
|
|
46
|
+
return next;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=data-table-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table-url.js","sourceRoot":"","sources":["../../src/collection/data-table-url.ts"],"names":[],"mappings":"AA8BA,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAU,CAAC;AAEvD,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,MAAe,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAExF,kEAAkE;AAClE,MAAM,UAAU,QAAQ,CAAC,MAAuB,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAuB;IACxG,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAA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CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACzF,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC;QAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACvE,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { SortDescriptor } from \"react-aria-components\";\n\n/**\n * How a DataTable's view is written in the URL. One module on purpose: the format is a public contract\n * (links get shared and bookmarked), and a change touches only this file.\n *\n * Flat and readable: `?q=acme&status=active&status=paused&sort=name&dir=desc&page=2`\n * - `q` the search, `page` 1-based, `sort` the column key with `dir=asc|desc`;\n * - each filter its own param named by its key, a multi-value filter repeated (values may hold commas);\n * - defaults are left out (page 1, the default sort, no search, no filters), so a plain list has a clean URL;\n * - `urlKey` prefixes every name (`orders.page`) when two tables share a page.\n * Params that are not the table's are kept as they are.\n */\n\nexport type DataTableView = {\n /** 1-based. */\n page: number;\n sort?: SortDescriptor;\n search: string;\n /** Filter key → the selected values; a key with no values is not filtering. */\n filters: Readonly<Record<string, readonly string[]>>;\n};\n\nexport type DataTableUrlOptions = {\n urlKey?: string;\n /** The filter keys the table knows; other params are never read as filters. */\n filterKeys: readonly string[];\n defaultSort?: SortDescriptor;\n};\n\nconst RESERVED = [\"q\", \"sort\", \"dir\", \"page\"] as const;\n\nconst nameOf = (name: string, urlKey?: string) => (urlKey ? `${urlKey}.${name}` : name);\n\n/** The view a URL holds, with defaults for what it leaves out. */\nexport function readView(params: URLSearchParams, { urlKey, filterKeys, defaultSort }: DataTableUrlOptions): DataTableView {\n const get = (name: string) => params.get(nameOf(name, urlKey));\n const page = Number.parseInt(get(\"page\") ?? \"\", 10);\n const column = get(\"sort\");\n const dir = get(\"dir\");\n const filters: Record<string, string[]> = {};\n for (const key of filterKeys) {\n if ((RESERVED as readonly string[]).includes(key)) continue;\n const values = params.getAll(nameOf(key, urlKey)).filter(Boolean);\n if (values.length) filters[key] = values;\n }\n return {\n page: Number.isFinite(page) && page > 0 ? page : 1,\n sort: column ? { column, direction: dir === \"desc\" ? \"descending\" : \"ascending\" } : defaultSort,\n search: get(\"q\") ?? \"\",\n filters,\n };\n}\n\n/** The URL params for a view: the table's own names rewritten, every other param kept. */\nexport function writeView(base: URLSearchParams, view: DataTableView, { urlKey, filterKeys, defaultSort }: DataTableUrlOptions): URLSearchParams {\n const next = new URLSearchParams(base);\n for (const name of [...RESERVED, ...filterKeys]) next.delete(nameOf(name, urlKey));\n const search = view.search.trim();\n if (search) next.set(nameOf(\"q\", urlKey), search);\n for (const key of filterKeys) {\n if ((RESERVED as readonly string[]).includes(key)) continue;\n for (const value of view.filters[key] ?? []) next.append(nameOf(key, urlKey), value);\n }\n const isDefaultSort =\n (!view.sort && !defaultSort) ||\n (view.sort && defaultSort && String(view.sort.column) === String(defaultSort.column) && view.sort.direction === defaultSort.direction);\n if (view.sort && !isDefaultSort) {\n next.set(nameOf(\"sort\", urlKey), String(view.sort.column));\n next.set(nameOf(\"dir\", urlKey), view.sort.direction === \"descending\" ? \"desc\" : \"asc\");\n }\n if (view.page > 1) next.set(nameOf(\"page\", urlKey), String(view.page));\n return next;\n}\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Density } from "../density.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { type Key, type SortDescriptor } from "react-aria-components";
|
|
4
|
+
import type { DataTableView } from "./data-table-url.js";
|
|
5
|
+
import { type TableColumn } from "./table.js";
|
|
6
|
+
export type DataTableColumn<T> = TableColumn<T> & {
|
|
7
|
+
/** Offered in the column picker ("Columns"); the row header column never hides. */
|
|
8
|
+
isHideable?: boolean;
|
|
9
|
+
/** The value sorted and searched in a client list; the row's value under `key` by default. */
|
|
10
|
+
value?: (row: T) => string | number | null | undefined;
|
|
11
|
+
};
|
|
12
|
+
export type DataTableFilter = {
|
|
13
|
+
/** Also the URL param name. */
|
|
14
|
+
key: string;
|
|
15
|
+
/** "Durum". */
|
|
16
|
+
label: string;
|
|
17
|
+
options: readonly {
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
}[];
|
|
21
|
+
/** A client list's value(s) for this filter; the row's value under `key` by default (a nested or derived field). */
|
|
22
|
+
value?: (row: never) => string | readonly string[] | null | undefined;
|
|
23
|
+
};
|
|
24
|
+
export type DataTableQuery = DataTableView & {
|
|
25
|
+
pageSize: number;
|
|
26
|
+
};
|
|
27
|
+
export type DataTableResult<T> = {
|
|
28
|
+
rows: readonly T[];
|
|
29
|
+
total: number;
|
|
30
|
+
};
|
|
31
|
+
export type DataTableBulkAction = {
|
|
32
|
+
id: string;
|
|
33
|
+
/** A verb ("Send reminder"). */
|
|
34
|
+
label: string;
|
|
35
|
+
/**
|
|
36
|
+
* Runs on the selected keys (across pages, filtered-out rows included). When it resolves the selection
|
|
37
|
+
* clears and the list reloads; when it rejects both stay, so tell the user why from here (a toast).
|
|
38
|
+
*/
|
|
39
|
+
onAction: (keys: Key[]) => unknown;
|
|
40
|
+
};
|
|
41
|
+
type DataTableBase<T> = {
|
|
42
|
+
/** Names the table ("Orders"). */
|
|
43
|
+
"aria-label": string;
|
|
44
|
+
columns: readonly DataTableColumn<T>[];
|
|
45
|
+
/**
|
|
46
|
+
* The row's stable id; `row.id` by default. Selection is kept by it across pages. Ids must be unique within
|
|
47
|
+
* the list; build one from the fields that are when the data has none (`${row.date}:${row.channel}`). A
|
|
48
|
+
* repeated id on a page still renders every row: the later ones are keyed `a#2`, `a#3`, … in row order, and
|
|
49
|
+
* selection, bulk actions and `onRowAction` receive those suffixed keys; a development warning names the
|
|
50
|
+
* repeated ids. A suffixed key follows the row's position, not the row: after a sort, filter
|
|
51
|
+
* or page change a selection made through it can move to another copy, and an id repeated on two pages is
|
|
52
|
+
* one key, so selecting it on one page selects it on both.
|
|
53
|
+
*/
|
|
54
|
+
rowKey?: (row: T) => Key;
|
|
55
|
+
filters?: readonly DataTableFilter[];
|
|
56
|
+
bulkActions?: readonly DataTableBulkAction[];
|
|
57
|
+
defaultSort?: SortDescriptor;
|
|
58
|
+
/** Column key → shown; columns left out are shown. Pass with `onColumnVisibilityChange` to own it. */
|
|
59
|
+
columnVisibility?: Readonly<Record<string, boolean>>;
|
|
60
|
+
onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;
|
|
61
|
+
/** Opens the record (row press while nothing is selected). */
|
|
62
|
+
onRowAction?: (key: Key) => void;
|
|
63
|
+
/** 20 by default. */
|
|
64
|
+
pageSize?: number;
|
|
65
|
+
/** The range sentence: (41, 60, 1204) → "41–60 of 1,204". */
|
|
66
|
+
formatRange?: (from: number, to: number, total: number) => string;
|
|
67
|
+
/**
|
|
68
|
+
* What an empty list shows (with no search or filter active): an `EmptyState size="small"` with the action that
|
|
69
|
+
* fills it. "No records yet" by default.
|
|
70
|
+
*/
|
|
71
|
+
emptyState?: React.ReactNode;
|
|
72
|
+
/**
|
|
73
|
+
* The view (page, sort, search, filters), controlled. Keep it in the URL with `useDataTableUrl`, or anywhere else;
|
|
74
|
+
* left out, the table keeps it itself.
|
|
75
|
+
*/
|
|
76
|
+
view?: DataTableView;
|
|
77
|
+
/** The first view when uncontrolled: page 1, the default sort, no search and no filters by default. */
|
|
78
|
+
defaultView?: Partial<DataTableView>;
|
|
79
|
+
/** Called with the whole next view on every change (a new sort, search, filter or page). */
|
|
80
|
+
onViewChange?: (view: DataTableView) => void;
|
|
81
|
+
/** `compact` (36px rows) by default: DataTable is the dense working list of a back office. */
|
|
82
|
+
density?: Density;
|
|
83
|
+
};
|
|
84
|
+
export type DataTableProps<T> = DataTableBase<T> & ({
|
|
85
|
+
/**
|
|
86
|
+
* A server list: fetches one page for the view; aborted when the view changes again. It is read when
|
|
87
|
+
* the view changes, not when the function does: for a list that depends on something else (a parent
|
|
88
|
+
* tab), give the DataTable a `key` from it so it starts afresh.
|
|
89
|
+
*/
|
|
90
|
+
query: (view: DataTableQuery, signal: AbortSignal) => Promise<DataTableResult<T>>;
|
|
91
|
+
rows?: never;
|
|
92
|
+
virtualizeAbove?: never;
|
|
93
|
+
height?: never;
|
|
94
|
+
} | {
|
|
95
|
+
/** A client list: searched, filtered and sorted here; paged, or virtualized when long. */
|
|
96
|
+
rows: readonly T[];
|
|
97
|
+
query?: never;
|
|
98
|
+
/** Client lists longer than this render only the rows in view instead of pages. 200 by default. */
|
|
99
|
+
virtualizeAbove?: number;
|
|
100
|
+
/** The virtualized list's height in px. 480 by default. */
|
|
101
|
+
height?: number;
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* The record list of a back office or admin screen: Toolbar (search, filters, column picker), a compact Table
|
|
105
|
+
* with sortable headers and selection, the bulk bar while rows are selected, Pagination, and loading,
|
|
106
|
+
* empty and error states in the table's frame. Page, sort, filters and search are the `view`, kept by the
|
|
107
|
+
* table or by the app; `useDataTableUrl` keeps it in the URL, so a reload or a shared link shows the same view. Server lists page;
|
|
108
|
+
* client lists over 200 rows render only the rows in view. Selection survives paging and clears after a
|
|
109
|
+
* bulk action settles.
|
|
110
|
+
*/
|
|
111
|
+
export declare function DataTable<T extends object>(props: DataTableProps<T>): React.JSX.Element;
|
|
112
|
+
export {};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useLocale } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { Button } from "../action/button.js";
|
|
7
|
+
import { EmptyState } from "../feedback/empty-state.js";
|
|
8
|
+
import { Skeleton } from "../feedback/skeleton.js";
|
|
9
|
+
import { SearchField } from "../form/search-field.js";
|
|
10
|
+
import { intlLocale, retryLabel, tableClearFiltersLabel, tableColumnsLabel, tableEmptyLabel, tableLoadFailedHintLabel, tableLoadFailedLabel, tableNoResultsLabel, tableSearchLabel, tableSelectedLabel, tableToolsLabel, } from "../i18n.js";
|
|
11
|
+
import { Pagination } from "../navigation/pagination.js";
|
|
12
|
+
import { BulkBar, Toolbar, ToolbarSpacer } from "../layout/toolbar.js";
|
|
13
|
+
import { Menu } from "../overlay/floating.js";
|
|
14
|
+
import { matchesQuery } from "../selection/match.js";
|
|
15
|
+
import { TableView, uniqueRowKeys } from "./table.js";
|
|
16
|
+
const SEARCH_DEBOUNCE = 300;
|
|
17
|
+
/** The row's value for a column, as a client list sorts and searches it. */
|
|
18
|
+
function cellValue(row, column) {
|
|
19
|
+
return column.value ? column.value(row) : row[column.key];
|
|
20
|
+
}
|
|
21
|
+
/** One empty list for every render, so memos keyed on `filters` hold for tables without filters. */
|
|
22
|
+
const NO_FILTERS = [];
|
|
23
|
+
/** One function for every render, so memos keyed on `rowKey` hold. */
|
|
24
|
+
const defaultRowKey = (row) => row.id;
|
|
25
|
+
/**
|
|
26
|
+
* The record list of a back office or admin screen: Toolbar (search, filters, column picker), a compact Table
|
|
27
|
+
* with sortable headers and selection, the bulk bar while rows are selected, Pagination, and loading,
|
|
28
|
+
* empty and error states in the table's frame. Page, sort, filters and search are the `view`, kept by the
|
|
29
|
+
* table or by the app; `useDataTableUrl` keeps it in the URL, so a reload or a shared link shows the same view. Server lists page;
|
|
30
|
+
* client lists over 200 rows render only the rows in view. Selection survives paging and clears after a
|
|
31
|
+
* bulk action settles.
|
|
32
|
+
*/
|
|
33
|
+
export function DataTable(props) {
|
|
34
|
+
const { "aria-label": label, columns, rowKey = defaultRowKey, filters = NO_FILTERS, bulkActions = [], defaultSort, onRowAction, pageSize = 20, formatRange, emptyState, density = "compact", } = props;
|
|
35
|
+
const { locale } = useLocale();
|
|
36
|
+
// The view: the app's (`view`), or the table's own.
|
|
37
|
+
const [own, setOwn] = React.useState(() => ({ page: 1, sort: defaultSort, search: "", filters: {}, ...props.defaultView }));
|
|
38
|
+
const view = props.view ?? own;
|
|
39
|
+
const viewRef = React.useRef(view);
|
|
40
|
+
viewRef.current = view;
|
|
41
|
+
const setView = (patch) => {
|
|
42
|
+
// Anything but a page change starts again at page 1.
|
|
43
|
+
const next = { ...viewRef.current, ...patch, page: patch.page ?? 1 };
|
|
44
|
+
viewRef.current = next;
|
|
45
|
+
if (props.view === undefined)
|
|
46
|
+
setOwn(next);
|
|
47
|
+
props.onViewChange?.(next);
|
|
48
|
+
};
|
|
49
|
+
// The search box answers each keystroke; the view (the fetch, and the URL with useDataTableUrl) follows once typing
|
|
50
|
+
// pauses. A view changed from outside (Back and Forward, a host router) brings the box along.
|
|
51
|
+
const [searchInput, setSearchInput] = React.useState(view.search);
|
|
52
|
+
const searchTimer = React.useRef(undefined);
|
|
53
|
+
React.useEffect(() => () => clearTimeout(searchTimer.current), []);
|
|
54
|
+
const shownSearch = React.useRef(view.search);
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
if (view.search === shownSearch.current)
|
|
57
|
+
return;
|
|
58
|
+
shownSearch.current = view.search;
|
|
59
|
+
clearTimeout(searchTimer.current);
|
|
60
|
+
setSearchInput(view.search);
|
|
61
|
+
}, [view.search]);
|
|
62
|
+
const onSearch = (search) => {
|
|
63
|
+
setSearchInput(search);
|
|
64
|
+
clearTimeout(searchTimer.current);
|
|
65
|
+
searchTimer.current = setTimeout(() => {
|
|
66
|
+
shownSearch.current = search;
|
|
67
|
+
setView({ search });
|
|
68
|
+
}, SEARCH_DEBOUNCE);
|
|
69
|
+
};
|
|
70
|
+
// Columns the picker hides.
|
|
71
|
+
const [ownVisibility, setOwnVisibility] = React.useState({});
|
|
72
|
+
const visibility = props.columnVisibility ?? ownVisibility;
|
|
73
|
+
const rowHeaderKey = (columns.find((column) => column.isRowHeader) ?? columns[0])?.key;
|
|
74
|
+
const shownColumns = columns.filter((column) => column.key === rowHeaderKey || visibility[column.key] !== false);
|
|
75
|
+
const hideable = columns.filter((column) => column.isHideable && column.key !== rowHeaderKey);
|
|
76
|
+
const setVisibility = (next) => {
|
|
77
|
+
if (props.columnVisibility === undefined)
|
|
78
|
+
setOwnVisibility(next);
|
|
79
|
+
props.onColumnVisibilityChange?.(next);
|
|
80
|
+
};
|
|
81
|
+
// Server data.
|
|
82
|
+
const [reload, setReload] = React.useState(0);
|
|
83
|
+
// `forView` is the view a result answered: a stale result (the moment after Back restores another view)
|
|
84
|
+
// never decides anything about the new one.
|
|
85
|
+
const [server, setServer] = React.useState({ status: "loading" });
|
|
86
|
+
const viewKey = JSON.stringify(view);
|
|
87
|
+
const queryRef = React.useRef(props.query);
|
|
88
|
+
queryRef.current = props.query;
|
|
89
|
+
const isServer = props.query !== undefined;
|
|
90
|
+
React.useEffect(() => {
|
|
91
|
+
if (!isServer)
|
|
92
|
+
return;
|
|
93
|
+
const controller = new AbortController();
|
|
94
|
+
setServer((previous) => ({ status: "loading", result: previous.result }));
|
|
95
|
+
Promise.resolve(queryRef.current({ ...view, pageSize }, controller.signal)).then((result) => !controller.signal.aborted && setServer({ status: "ready", result, forView: viewKey }), () => !controller.signal.aborted && setServer((previous) => ({ status: "error", result: previous.result })));
|
|
96
|
+
return () => controller.abort();
|
|
97
|
+
// `view` is read through `viewKey`.
|
|
98
|
+
}, [isServer, viewKey, pageSize, reload]);
|
|
99
|
+
// Client data: searched, filtered and sorted here.
|
|
100
|
+
const collator = React.useMemo(() => new Intl.Collator(intlLocale(locale), { numeric: true, sensitivity: "base" }), [locale]);
|
|
101
|
+
const clientRows = React.useMemo(() => {
|
|
102
|
+
if (isServer)
|
|
103
|
+
return [];
|
|
104
|
+
let rows = [...(props.rows ?? [])];
|
|
105
|
+
if (view.search.trim())
|
|
106
|
+
rows = rows.filter((row) => matchesQuery(view.search, ...columns.map((column) => String(cellValue(row, column) ?? ""))));
|
|
107
|
+
for (const [key, values] of Object.entries(view.filters)) {
|
|
108
|
+
if (!values.length)
|
|
109
|
+
continue;
|
|
110
|
+
const accessor = filters.find((filter) => filter.key === key)?.value;
|
|
111
|
+
rows = rows.filter((row) => {
|
|
112
|
+
const own = accessor ? accessor(row) : row[key];
|
|
113
|
+
const list = Array.isArray(own) ? own : [own];
|
|
114
|
+
return list.some((item) => item != null && values.includes(String(item)));
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const sortColumn = view.sort && columns.find((column) => column.key === String(view.sort.column));
|
|
118
|
+
if (sortColumn) {
|
|
119
|
+
const sign = view.sort.direction === "descending" ? -1 : 1;
|
|
120
|
+
rows.sort((a, b) => {
|
|
121
|
+
const left = cellValue(a, sortColumn);
|
|
122
|
+
const right = cellValue(b, sortColumn);
|
|
123
|
+
if (typeof left === "number" && typeof right === "number")
|
|
124
|
+
return (left - right) * sign;
|
|
125
|
+
return collator.compare(String(left ?? ""), String(right ?? "")) * sign;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return rows;
|
|
129
|
+
// `view` is read through `viewKey`.
|
|
130
|
+
}, [isServer, props.rows, viewKey, columns, filters, collator]);
|
|
131
|
+
const virtual = !isServer && clientRows.length > (props.virtualizeAbove ?? 200);
|
|
132
|
+
const total = isServer ? (server.result?.total ?? 0) : clientRows.length;
|
|
133
|
+
// A page past the end (a shared `?page=99`, the last page emptied by a bulk delete) moves to the last page.
|
|
134
|
+
const lastPage = Math.max(1, Math.ceil(total / pageSize));
|
|
135
|
+
const known = !isServer || (server.status === "ready" && server.forView === viewKey);
|
|
136
|
+
React.useEffect(() => {
|
|
137
|
+
if (known && !virtual && view.page > lastPage)
|
|
138
|
+
setView({ page: lastPage });
|
|
139
|
+
});
|
|
140
|
+
const pageRows = React.useMemo(() => (isServer ? (server.result?.rows ?? []) : virtual ? clientRows : clientRows.slice((view.page - 1) * pageSize, view.page * pageSize)), [isServer, server.result, virtual, clientRows, view.page, pageSize]);
|
|
141
|
+
// Selection across pages: kept by key, whatever page shows.
|
|
142
|
+
const [selected, setSelected] = React.useState(new Set());
|
|
143
|
+
// The keys the table gives the rows on this page: a repeated id is suffixed there, so it is here too.
|
|
144
|
+
// Every render, as TableView computes its keys: a row whose id changed in place must not
|
|
145
|
+
// keep a stale key here, or its selection would be filtered out.
|
|
146
|
+
const visibleKeys = new Set(uniqueRowKeys(pageRows.map(rowKey)).keys);
|
|
147
|
+
const onSelectionChange = (keys) => {
|
|
148
|
+
const next = new Set([...selected].filter((key) => !visibleKeys.has(key)));
|
|
149
|
+
for (const key of keys === "all" ? visibleKeys : keys)
|
|
150
|
+
if (visibleKeys.has(key))
|
|
151
|
+
next.add(key);
|
|
152
|
+
setSelected(next);
|
|
153
|
+
};
|
|
154
|
+
const [pendingAction, setPendingAction] = React.useState(null);
|
|
155
|
+
const runBulk = async (action) => {
|
|
156
|
+
setPendingAction(action.id);
|
|
157
|
+
try {
|
|
158
|
+
await action.onAction([...selected]);
|
|
159
|
+
// Done: the selection goes and the list shows the result.
|
|
160
|
+
setSelected(new Set());
|
|
161
|
+
setReload((n) => n + 1);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
// Failed: the selection and the bar stay so the action can be tried again; the app says what went
|
|
165
|
+
// wrong (its `onAction` toasts the reason), the table never swallows it into an unhandled rejection.
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
setPendingAction(null);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const isFiltered = Boolean(view.search.trim()) || Object.values(view.filters).some((values) => values.length > 0);
|
|
172
|
+
const clearFilters = () => {
|
|
173
|
+
clearTimeout(searchTimer.current);
|
|
174
|
+
setSearchInput("");
|
|
175
|
+
setView({ search: "", filters: {} });
|
|
176
|
+
};
|
|
177
|
+
const status = isServer ? server.status : "ready";
|
|
178
|
+
const showSkeleton = status === "loading" && !(server.result && server.result.rows.length);
|
|
179
|
+
const empty = () => isFiltered ? (_jsx(EmptyState, { size: "small", icon: "search-x", title: tableNoResultsLabel(locale), primaryAction: _jsx(Button, { size: "small", onPress: clearFilters, children: tableClearFiltersLabel(locale) }) })) : (emptyState ?? _jsx(EmptyState, { size: "small", icon: "inbox", title: tableEmptyLabel(locale) }));
|
|
180
|
+
return (_jsxs("section", { "data-slot": "data-table", "aria-busy": status === "loading" || undefined, className: "flex min-w-0 flex-col gap-ds-150", children: [selected.size > 0 && bulkActions.length > 0 ? (_jsx(BulkBar, { "aria-label": tableSelectedLabel(locale), selectedCount: selected.size, onClear: () => setSelected(new Set()), actions: bulkActions.map((action) => (_jsx(Button, { size: "small", isPending: pendingAction === action.id, isDisabled: pendingAction !== null, onPress: () => void runBulk(action), children: action.label }, action.id))) })) : (_jsxs(Toolbar, { "aria-label": tableToolsLabel(locale), children: [_jsx("div", { "data-slot": "data-table-search", className: "w-56 max-w-full", children: _jsx(SearchField, { "aria-label": tableSearchLabel(locale), placeholder: tableSearchLabel(locale), size: "small", value: searchInput, onChange: onSearch }) }), filters.map((filter) => {
|
|
181
|
+
const values = view.filters[filter.key] ?? [];
|
|
182
|
+
return (_jsx(Menu, { "aria-label": filter.label, placement: "bottom start", selectionMode: "multiple", selectedKeys: values, onSelectionChange: (keys) => setView({ filters: { ...view.filters, [filter.key]: keys === "all" ? filter.options.map((option) => option.id) : [...keys].map(String) } }), items: filter.options.map((option) => ({ id: option.id, label: option.label })), trigger: _jsx(Button, { size: "small", variant: values.length ? "default" : "subtle", iconBefore: "filter", children: values.length ? `${filter.label} · ${values.length}` : filter.label }) }, filter.key));
|
|
183
|
+
}), _jsx(ToolbarSpacer, {}), hideable.length > 0 && (_jsx(Menu, { "aria-label": tableColumnsLabel(locale), selectionMode: "multiple", selectedKeys: hideable.filter((column) => visibility[column.key] !== false).map((column) => column.key), onSelectionChange: (keys) => {
|
|
184
|
+
const shown = keys === "all" ? new Set(hideable.map((column) => column.key)) : new Set([...keys].map(String));
|
|
185
|
+
setVisibility(Object.fromEntries(hideable.map((column) => [column.key, shown.has(column.key)])));
|
|
186
|
+
}, items: hideable.map((column) => ({ id: column.key, label: column.header })), trigger: _jsx(Button, { size: "small", variant: "subtle", iconBefore: "columns-3", children: tableColumnsLabel(locale) }) }))] })), status === "error" ? (_jsx("div", { "data-slot": "data-table-error", className: "rounded-ds-large bg-ds-surface-raised py-ds-400 shadow-ds-raised", children: _jsx(EmptyState, { size: "small", tone: "danger", icon: "cloud-off", announce: true, title: tableLoadFailedLabel(locale), description: tableLoadFailedHintLabel(locale), primaryAction: _jsx(Button, { size: "small", iconBefore: "rotate-cw", onPress: () => setReload((n) => n + 1), children: retryLabel(locale) }) }) })) : showSkeleton ? (_jsxs("div", { "data-slot": "data-table-loading", "aria-hidden": true, className: "flex flex-col overflow-hidden rounded-ds-large bg-ds-surface-raised shadow-ds-raised", children: [_jsx("div", { className: "h-9 border-b border-ds-border bg-ds-surface-sunken" }), Array.from({ length: Math.min(pageSize, 8) }, (_, index) => (_jsxs("div", { className: cn("flex items-center gap-ds-300 border-b border-ds-border px-ds-200 last:border-b-0", density === "compact" ? "h-ds-row-compact" : "h-ds-row"), children: [_jsx(Skeleton, { width: "18%", height: 12 }), _jsx(Skeleton, { width: "30%", height: 12 }), _jsx(Skeleton, { width: "16%", height: 12 })] }, index)))] })) : (_jsx(TableView, { component: "DataTable", "aria-label": label, columns: shownColumns, rows: pageRows, rowKey: rowKey, selectionMode: bulkActions.length ? "multiple" : "none", selectedKeys: [...selected].filter((key) => visibleKeys.has(key)), onSelectionChange: onSelectionChange, sortDescriptor: view.sort, onSortChange: (sort) => setView({ sort }), density: density, onRowAction: onRowAction, emptyState: empty(), virtual: virtual ? { height: props.height ?? 480 } : undefined })), !virtual && status !== "error" && total > 0 && (_jsx(Pagination, { page: view.page, pageSize: pageSize, total: total, onPageChange: (page) => setView({ page }), formatRange: formatRange }))] }));
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=data-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table.js","sourceRoot":"","sources":["../../src/collection/data-table.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAiD,MAAM,uBAAuB,CAAC;AAEjG,OAAO,EAAE,EAAE,EAAE,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K,GAAG,CAAC,IAAI,CAC9C,KAAC,UAAU,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,WAAW,GAAI,CACvI,IACO,CACX,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport type { Density } from \"../density\";\nimport * as React from \"react\";\nimport { useLocale, type Key, type Selection, type SortDescriptor } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { Button } from \"../action/button\";\nimport { EmptyState } from \"../feedback/empty-state\";\nimport { Skeleton } from \"../feedback/skeleton\";\nimport { SearchField } from \"../form/search-field\";\nimport {\n intlLocale,\n retryLabel,\n tableClearFiltersLabel,\n tableColumnsLabel,\n tableEmptyLabel,\n tableLoadFailedHintLabel,\n tableLoadFailedLabel,\n tableNoResultsLabel,\n tableSearchLabel,\n tableSelectedLabel,\n tableToolsLabel,\n} from \"../i18n\";\nimport { Pagination } from \"../navigation/pagination\";\nimport { BulkBar, Toolbar, ToolbarSpacer } from \"../layout/toolbar\";\nimport { Menu } from \"../overlay/floating\";\nimport { matchesQuery } from \"../selection/match\";\nimport type { DataTableView } from \"./data-table-url\";\nimport { TableView, uniqueRowKeys, type TableColumn } from \"./table\";\n\nexport type DataTableColumn<T> = TableColumn<T> & {\n /** Offered in the column picker (\"Columns\"); the row header column never hides. */\n isHideable?: boolean;\n /** The value sorted and searched in a client list; the row's value under `key` by default. */\n value?: (row: T) => string | number | null | undefined;\n};\n\nexport type DataTableFilter = {\n /** Also the URL param name. */\n key: string;\n /** \"Durum\". */\n label: string;\n options: readonly { id: string; label: string }[];\n /** A client list's value(s) for this filter; the row's value under `key` by default (a nested or derived field). */\n value?: (row: never) => string | readonly string[] | null | undefined;\n};\n\nexport type DataTableQuery = DataTableView & { pageSize: number };\n\nexport type DataTableResult<T> = { rows: readonly T[]; total: number };\n\nexport type DataTableBulkAction = {\n id: string;\n /** A verb (\"Send reminder\"). */\n label: string;\n /**\n * Runs on the selected keys (across pages, filtered-out rows included). When it resolves the selection\n * clears and the list reloads; when it rejects both stay, so tell the user why from here (a toast).\n */\n onAction: (keys: Key[]) => unknown;\n};\n\ntype DataTableBase<T> = {\n /** Names the table (\"Orders\"). */\n \"aria-label\": string;\n columns: readonly DataTableColumn<T>[];\n /**\n * The row's stable id; `row.id` by default. Selection is kept by it across pages. Ids must be unique within\n * the list; build one from the fields that are when the data has none (`${row.date}:${row.channel}`). A\n * repeated id on a page still renders every row: the later ones are keyed `a#2`, `a#3`, … in row order, and\n * selection, bulk actions and `onRowAction` receive those suffixed keys; a development warning names the\n * repeated ids. A suffixed key follows the row's position, not the row: after a sort, filter\n * or page change a selection made through it can move to another copy, and an id repeated on two pages is\n * one key, so selecting it on one page selects it on both.\n */\n rowKey?: (row: T) => Key;\n filters?: readonly DataTableFilter[];\n bulkActions?: readonly DataTableBulkAction[];\n defaultSort?: SortDescriptor;\n /** Column key → shown; columns left out are shown. Pass with `onColumnVisibilityChange` to own it. */\n columnVisibility?: Readonly<Record<string, boolean>>;\n onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;\n /** Opens the record (row press while nothing is selected). */\n onRowAction?: (key: Key) => void;\n /** 20 by default. */\n pageSize?: number;\n /** The range sentence: (41, 60, 1204) → \"41–60 of 1,204\". */\n formatRange?: (from: number, to: number, total: number) => string;\n /**\n * What an empty list shows (with no search or filter active): an `EmptyState size=\"small\"` with the action that\n * fills it. \"No records yet\" by default.\n */\n emptyState?: React.ReactNode;\n /**\n * The view (page, sort, search, filters), controlled. Keep it in the URL with `useDataTableUrl`, or anywhere else;\n * left out, the table keeps it itself.\n */\n view?: DataTableView;\n /** The first view when uncontrolled: page 1, the default sort, no search and no filters by default. */\n defaultView?: Partial<DataTableView>;\n /** Called with the whole next view on every change (a new sort, search, filter or page). */\n onViewChange?: (view: DataTableView) => void;\n /** `compact` (36px rows) by default: DataTable is the dense working list of a back office. */\n density?: Density;\n};\n\nexport type DataTableProps<T> = DataTableBase<T> &\n (\n | {\n /**\n * A server list: fetches one page for the view; aborted when the view changes again. It is read when\n * the view changes, not when the function does: for a list that depends on something else (a parent\n * tab), give the DataTable a `key` from it so it starts afresh.\n */\n query: (view: DataTableQuery, signal: AbortSignal) => Promise<DataTableResult<T>>;\n rows?: never;\n virtualizeAbove?: never;\n height?: never;\n }\n | {\n /** A client list: searched, filtered and sorted here; paged, or virtualized when long. */\n rows: readonly T[];\n query?: never;\n /** Client lists longer than this render only the rows in view instead of pages. 200 by default. */\n virtualizeAbove?: number;\n /** The virtualized list's height in px. 480 by default. */\n height?: number;\n }\n );\n\nconst SEARCH_DEBOUNCE = 300;\n\n/** The row's value for a column, as a client list sorts and searches it. */\nfunction cellValue<T>(row: T, column: DataTableColumn<T>) {\n return column.value ? column.value(row) : ((row as Record<string, unknown>)[column.key] as string | number | null | undefined);\n}\n\n/** One empty list for every render, so memos keyed on `filters` hold for tables without filters. */\nconst NO_FILTERS: readonly DataTableFilter[] = [];\n\n/** One function for every render, so memos keyed on `rowKey` hold. */\nconst defaultRowKey = (row: object): Key => (row as { id: Key }).id;\n\n/**\n * The record list of a back office or admin screen: Toolbar (search, filters, column picker), a compact Table\n * with sortable headers and selection, the bulk bar while rows are selected, Pagination, and loading,\n * empty and error states in the table's frame. Page, sort, filters and search are the `view`, kept by the\n * table or by the app; `useDataTableUrl` keeps it in the URL, so a reload or a shared link shows the same view. Server lists page;\n * client lists over 200 rows render only the rows in view. Selection survives paging and clears after a\n * bulk action settles.\n */\nexport function DataTable<T extends object>(props: DataTableProps<T>) {\n const {\n \"aria-label\": label,\n columns,\n rowKey = defaultRowKey as (row: T) => Key,\n filters = NO_FILTERS,\n bulkActions = [],\n defaultSort,\n onRowAction,\n pageSize = 20,\n formatRange,\n emptyState,\n density = \"compact\",\n } = props;\n const { locale } = useLocale();\n // The view: the app's (`view`), or the table's own.\n const [own, setOwn] = React.useState<DataTableView>(() => ({ page: 1, sort: defaultSort, search: \"\", filters: {}, ...props.defaultView }));\n const view = props.view ?? own;\n const viewRef = React.useRef(view);\n viewRef.current = view;\n const setView = (patch: Partial<DataTableView>) => {\n // Anything but a page change starts again at page 1.\n const next = { ...viewRef.current, ...patch, page: patch.page ?? 1 };\n viewRef.current = next;\n if (props.view === undefined) setOwn(next);\n props.onViewChange?.(next);\n };\n // The search box answers each keystroke; the view (the fetch, and the URL with useDataTableUrl) follows once typing\n // pauses. A view changed from outside (Back and Forward, a host router) brings the box along.\n const [searchInput, setSearchInput] = React.useState(view.search);\n const searchTimer = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n React.useEffect(() => () => clearTimeout(searchTimer.current), []);\n const shownSearch = React.useRef(view.search);\n React.useEffect(() => {\n if (view.search === shownSearch.current) return;\n shownSearch.current = view.search;\n clearTimeout(searchTimer.current);\n setSearchInput(view.search);\n }, [view.search]);\n const onSearch = (search: string) => {\n setSearchInput(search);\n clearTimeout(searchTimer.current);\n searchTimer.current = setTimeout(() => {\n shownSearch.current = search;\n setView({ search });\n }, SEARCH_DEBOUNCE);\n };\n\n // Columns the picker hides.\n const [ownVisibility, setOwnVisibility] = React.useState<Record<string, boolean>>({});\n const visibility = props.columnVisibility ?? ownVisibility;\n const rowHeaderKey = (columns.find((column) => column.isRowHeader) ?? columns[0])?.key;\n const shownColumns = columns.filter((column) => column.key === rowHeaderKey || visibility[column.key] !== false);\n const hideable = columns.filter((column) => column.isHideable && column.key !== rowHeaderKey);\n const setVisibility = (next: Record<string, boolean>) => {\n if (props.columnVisibility === undefined) setOwnVisibility(next);\n props.onColumnVisibilityChange?.(next);\n };\n\n // Server data.\n const [reload, setReload] = React.useState(0);\n // `forView` is the view a result answered: a stale result (the moment after Back restores another view)\n // never decides anything about the new one.\n const [server, setServer] = React.useState<{ status: \"loading\" | \"ready\" | \"error\"; result?: DataTableResult<T>; forView?: string }>({ status: \"loading\" });\n const viewKey = JSON.stringify(view);\n const queryRef = React.useRef(props.query);\n queryRef.current = props.query;\n const isServer = props.query !== undefined;\n React.useEffect(() => {\n if (!isServer) return;\n const controller = new AbortController();\n setServer((previous) => ({ status: \"loading\", result: previous.result }));\n Promise.resolve(queryRef.current!({ ...view, pageSize }, controller.signal)).then(\n (result) => !controller.signal.aborted && setServer({ status: \"ready\", result, forView: viewKey }),\n () => !controller.signal.aborted && setServer((previous) => ({ status: \"error\", result: previous.result })),\n );\n return () => controller.abort();\n // `view` is read through `viewKey`.\n }, [isServer, viewKey, pageSize, reload]);\n\n // Client data: searched, filtered and sorted here.\n const collator = React.useMemo(() => new Intl.Collator(intlLocale(locale), { numeric: true, sensitivity: \"base\" }), [locale]);\n const clientRows = React.useMemo(() => {\n if (isServer) return [];\n let rows = [...(props.rows ?? [])];\n if (view.search.trim()) rows = rows.filter((row) => matchesQuery(view.search, ...columns.map((column) => String(cellValue(row, column) ?? \"\"))));\n for (const [key, values] of Object.entries(view.filters)) {\n if (!values.length) continue;\n const accessor = filters.find((filter) => filter.key === key)?.value as ((row: T) => string | readonly string[] | null | undefined) | undefined;\n rows = rows.filter((row) => {\n const own = accessor ? accessor(row) : ((row as Record<string, unknown>)[key] as string | null | undefined);\n const list = Array.isArray(own) ? own : [own];\n return list.some((item) => item != null && values.includes(String(item)));\n });\n }\n const sortColumn = view.sort && columns.find((column) => column.key === String(view.sort!.column));\n if (sortColumn) {\n const sign = view.sort!.direction === \"descending\" ? -1 : 1;\n rows.sort((a, b) => {\n const left = cellValue(a, sortColumn);\n const right = cellValue(b, sortColumn);\n if (typeof left === \"number\" && typeof right === \"number\") return (left - right) * sign;\n return collator.compare(String(left ?? \"\"), String(right ?? \"\")) * sign;\n });\n }\n return rows;\n // `view` is read through `viewKey`.\n }, [isServer, props.rows, viewKey, columns, filters, collator]);\n const virtual = !isServer && clientRows.length > (props.virtualizeAbove ?? 200);\n const total = isServer ? (server.result?.total ?? 0) : clientRows.length;\n // A page past the end (a shared `?page=99`, the last page emptied by a bulk delete) moves to the last page.\n const lastPage = Math.max(1, Math.ceil(total / pageSize));\n const known = !isServer || (server.status === \"ready\" && server.forView === viewKey);\n React.useEffect(() => {\n if (known && !virtual && view.page > lastPage) setView({ page: lastPage });\n });\n const pageRows = React.useMemo(\n () => (isServer ? (server.result?.rows ?? []) : virtual ? clientRows : clientRows.slice((view.page - 1) * pageSize, view.page * pageSize)),\n [isServer, server.result, virtual, clientRows, view.page, pageSize],\n );\n\n // Selection across pages: kept by key, whatever page shows.\n const [selected, setSelected] = React.useState<ReadonlySet<Key>>(new Set());\n // The keys the table gives the rows on this page: a repeated id is suffixed there, so it is here too.\n // Every render, as TableView computes its keys: a row whose id changed in place must not\n // keep a stale key here, or its selection would be filtered out.\n const visibleKeys = new Set(uniqueRowKeys(pageRows.map(rowKey)).keys);\n const onSelectionChange = (keys: Selection) => {\n const next = new Set([...selected].filter((key) => !visibleKeys.has(key)));\n for (const key of keys === \"all\" ? visibleKeys : keys) if (visibleKeys.has(key)) next.add(key);\n setSelected(next);\n };\n const [pendingAction, setPendingAction] = React.useState<string | null>(null);\n const runBulk = async (action: DataTableBulkAction) => {\n setPendingAction(action.id);\n try {\n await action.onAction([...selected]);\n // Done: the selection goes and the list shows the result.\n setSelected(new Set());\n setReload((n) => n + 1);\n } catch {\n // Failed: the selection and the bar stay so the action can be tried again; the app says what went\n // wrong (its `onAction` toasts the reason), the table never swallows it into an unhandled rejection.\n } finally {\n setPendingAction(null);\n }\n };\n\n const isFiltered = Boolean(view.search.trim()) || Object.values(view.filters).some((values) => values.length > 0);\n const clearFilters = () => {\n clearTimeout(searchTimer.current);\n setSearchInput(\"\");\n setView({ search: \"\", filters: {} });\n };\n const status = isServer ? server.status : \"ready\";\n const showSkeleton = status === \"loading\" && !(server.result && server.result.rows.length);\n\n const empty = () =>\n isFiltered ? (\n <EmptyState\n size=\"small\"\n icon=\"search-x\"\n title={tableNoResultsLabel(locale)}\n primaryAction={<Button size=\"small\" onPress={clearFilters}>{tableClearFiltersLabel(locale)}</Button>}\n />\n ) : (\n emptyState ?? <EmptyState size=\"small\" icon=\"inbox\" title={tableEmptyLabel(locale)} />\n );\n\n return (\n <section data-slot=\"data-table\" aria-busy={status === \"loading\" || undefined} className=\"flex min-w-0 flex-col gap-ds-150\">\n {selected.size > 0 && bulkActions.length > 0 ? (\n <BulkBar\n aria-label={tableSelectedLabel(locale)}\n selectedCount={selected.size}\n onClear={() => setSelected(new Set())}\n actions={bulkActions.map((action) => (\n <Button key={action.id} size=\"small\" isPending={pendingAction === action.id} isDisabled={pendingAction !== null} onPress={() => void runBulk(action)}>\n {action.label}\n </Button>\n ))}\n />\n ) : (\n <Toolbar aria-label={tableToolsLabel(locale)}>\n <div data-slot=\"data-table-search\" className=\"w-56 max-w-full\">\n <SearchField\n aria-label={tableSearchLabel(locale)}\n placeholder={tableSearchLabel(locale)}\n size=\"small\"\n value={searchInput}\n onChange={onSearch}\n />\n </div>\n {filters.map((filter) => {\n const values = view.filters[filter.key] ?? [];\n return (\n <Menu\n key={filter.key}\n aria-label={filter.label}\n placement=\"bottom start\"\n selectionMode=\"multiple\"\n selectedKeys={values}\n onSelectionChange={(keys) => setView({ filters: { ...view.filters, [filter.key]: keys === \"all\" ? filter.options.map((option) => option.id) : [...keys].map(String) } })}\n items={filter.options.map((option) => ({ id: option.id, label: option.label }))}\n trigger={\n <Button size=\"small\" variant={values.length ? \"default\" : \"subtle\"} iconBefore=\"filter\">\n {values.length ? `${filter.label} · ${values.length}` : filter.label}\n </Button>\n }\n />\n );\n })}\n <ToolbarSpacer />\n {hideable.length > 0 && (\n <Menu\n aria-label={tableColumnsLabel(locale)}\n selectionMode=\"multiple\"\n selectedKeys={hideable.filter((column) => visibility[column.key] !== false).map((column) => column.key)}\n onSelectionChange={(keys) => {\n const shown = keys === \"all\" ? new Set(hideable.map((column) => column.key)) : new Set([...keys].map(String));\n setVisibility(Object.fromEntries(hideable.map((column) => [column.key, shown.has(column.key)])));\n }}\n items={hideable.map((column) => ({ id: column.key, label: column.header }))}\n trigger={\n <Button size=\"small\" variant=\"subtle\" iconBefore=\"columns-3\">\n {tableColumnsLabel(locale)}\n </Button>\n }\n />\n )}\n </Toolbar>\n )}\n\n {status === \"error\" ? (\n <div data-slot=\"data-table-error\" className=\"rounded-ds-large bg-ds-surface-raised py-ds-400 shadow-ds-raised\">\n <EmptyState\n size=\"small\"\n tone=\"danger\"\n icon=\"cloud-off\"\n announce\n title={tableLoadFailedLabel(locale)}\n description={tableLoadFailedHintLabel(locale)}\n primaryAction={\n <Button size=\"small\" iconBefore=\"rotate-cw\" onPress={() => setReload((n) => n + 1)}>\n {retryLabel(locale)}\n </Button>\n }\n />\n </div>\n ) : showSkeleton ? (\n <div data-slot=\"data-table-loading\" aria-hidden className=\"flex flex-col overflow-hidden rounded-ds-large bg-ds-surface-raised shadow-ds-raised\">\n <div className=\"h-9 border-b border-ds-border bg-ds-surface-sunken\" />\n {Array.from({ length: Math.min(pageSize, 8) }, (_, index) => (\n <div key={index} className={cn(\"flex items-center gap-ds-300 border-b border-ds-border px-ds-200 last:border-b-0\", density === \"compact\" ? \"h-ds-row-compact\" : \"h-ds-row\")}>\n <Skeleton width=\"18%\" height={12} />\n <Skeleton width=\"30%\" height={12} />\n <Skeleton width=\"16%\" height={12} />\n </div>\n ))}\n </div>\n ) : (\n <TableView\n component=\"DataTable\"\n aria-label={label}\n columns={shownColumns}\n rows={pageRows}\n rowKey={rowKey}\n selectionMode={bulkActions.length ? \"multiple\" : \"none\"}\n selectedKeys={[...selected].filter((key) => visibleKeys.has(key))}\n onSelectionChange={onSelectionChange}\n sortDescriptor={view.sort}\n onSortChange={(sort) => setView({ sort })}\n density={density}\n onRowAction={onRowAction}\n emptyState={empty()}\n virtual={virtual ? { height: (props as { height?: number }).height ?? 480 } : undefined}\n />\n )}\n\n {!virtual && status !== \"error\" && total > 0 && (\n <Pagination page={view.page} pageSize={pageSize} total={total} onPageChange={(page) => setView({ page })} formatRange={formatRange} />\n )}\n </section>\n );\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type StackListProps } from "./list.js";
|
|
3
|
+
import { type TileGridProps } from "./grid-list.js";
|
|
4
|
+
/** `layout="stack"` (default): rows with a leading visual, a title, a description and trailing status. */
|
|
5
|
+
export type GridListStackProps<T = never> = StackListProps<T> & {
|
|
6
|
+
layout?: "stack";
|
|
7
|
+
};
|
|
8
|
+
/** `layout="grid"`: selectable tiles in a responsive grid, with tile actions and drag reordering. */
|
|
9
|
+
export type GridListGridProps<T extends object> = TileGridProps<T> & {
|
|
10
|
+
layout: "grid";
|
|
11
|
+
};
|
|
12
|
+
export type GridListProps<T extends object = never> = GridListStackProps<T> | GridListGridProps<T>;
|
|
13
|
+
/**
|
|
14
|
+
* A list people move through with arrow keys and select from, as React Aria's GridList: `layout="stack"` (default)
|
|
15
|
+
* for rows (people, deliveries, a conversation list), `layout="grid"` for tiles (photos, documents). Rows take
|
|
16
|
+
* `GridListItem` and `GridListSection` children or `items` with `renderItem`; tiles take `items` with `renderItem`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function GridList<T extends object = never>(props: GridListProps<T>): React.JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { StackList } from "./list.js";
|
|
5
|
+
import { TileGrid } from "./grid-list.js";
|
|
6
|
+
/**
|
|
7
|
+
* A list people move through with arrow keys and select from, as React Aria's GridList: `layout="stack"` (default)
|
|
8
|
+
* for rows (people, deliveries, a conversation list), `layout="grid"` for tiles (photos, documents). Rows take
|
|
9
|
+
* `GridListItem` and `GridListSection` children or `items` with `renderItem`; tiles take `items` with `renderItem`.
|
|
10
|
+
*/
|
|
11
|
+
export function GridList(props) {
|
|
12
|
+
if (props.layout === "grid") {
|
|
13
|
+
const { layout: _layout, ...grid } = props;
|
|
14
|
+
return _jsx(TileGrid, { ...grid });
|
|
15
|
+
}
|
|
16
|
+
const { layout: _layout, ...stack } = props;
|
|
17
|
+
return _jsx(StackList, { ...stack });
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=grid-list-public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid-list-public.js","sourceRoot":"","sources":["../../src/collection/grid-list-public.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAuB,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAsB,MAAM,aAAa,CAAC;AAU3D;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAA2B,KAAuB;IACxE,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC5B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;QAC3C,OAAO,KAAC,QAAQ,OAAM,IAAyB,GAAI,CAAC;IACtD,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,KAA8B,CAAC;IACrE,OAAO,KAAC,SAAS,OAAM,KAA2B,GAAI,CAAC;AACzD,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { StackList, type StackListProps } from \"./list\";\nimport { TileGrid, type TileGridProps } from \"./grid-list\";\n\n/** `layout=\"stack\"` (default): rows with a leading visual, a title, a description and trailing status. */\nexport type GridListStackProps<T = never> = StackListProps<T> & { layout?: \"stack\" };\n\n/** `layout=\"grid\"`: selectable tiles in a responsive grid, with tile actions and drag reordering. */\nexport type GridListGridProps<T extends object> = TileGridProps<T> & { layout: \"grid\" };\n\nexport type GridListProps<T extends object = never> = GridListStackProps<T> | GridListGridProps<T>;\n\n/**\n * A list people move through with arrow keys and select from, as React Aria's GridList: `layout=\"stack\"` (default)\n * for rows (people, deliveries, a conversation list), `layout=\"grid\"` for tiles (photos, documents). Rows take\n * `GridListItem` and `GridListSection` children or `items` with `renderItem`; tiles take `items` with `renderItem`.\n */\nexport function GridList<T extends object = never>(props: GridListProps<T>) {\n if (props.layout === \"grid\") {\n const { layout: _layout, ...grid } = props;\n return <TileGrid {...(grid as TileGridProps<T>)} />;\n }\n const { layout: _layout, ...stack } = props as GridListStackProps<T>;\n return <StackList {...(stack as StackListProps<T>)} />;\n}\n"]}
|