@jcsoftdev/ui 0.5.0 → 0.7.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/CHANGELOG.md +361 -0
- package/README.md +31 -5
- package/bin/ui-theme.mjs +40 -6
- package/dist/ai/code-block/code-block.js +1 -1
- package/dist/atoms/avatar/avatar.d.ts +6 -1
- package/dist/atoms/avatar/avatar.js +3 -2
- package/dist/atoms/big-date/big-date.js +2 -2
- package/dist/atoms/button/button.d.ts +6 -1
- package/dist/atoms/button/button.js +2 -2
- package/dist/atoms/chip/chip.d.ts +5 -0
- package/dist/atoms/chip/chip.js +3 -3
- package/dist/atoms/icon-button/icon-button.js +1 -1
- package/dist/atoms/internal/hit-area.d.ts +5 -4
- package/dist/atoms/internal/hit-area.js +1 -1
- package/dist/atoms/progress/index.d.ts +1 -1
- package/dist/atoms/progress/index.js +4 -1
- package/dist/atoms/progress/progress.d.ts +6 -1
- package/dist/atoms/progress/progress.js +19 -1
- package/dist/atoms/radio-group/radio-group.js +1 -1
- package/dist/atoms/status-pill/status-pill.d.ts +16 -5
- package/dist/atoms/status-pill/status-pill.js +43 -18
- package/dist/brand/logo-forge.js +1 -1
- package/dist/charts/candlestick-chart/candlestick-chart.js +2 -2
- package/dist/charts/chart-grid/chart-grid.js +2 -2
- package/dist/charts/chord-chart/chord-chart.js +1 -1
- package/dist/charts/core/axes.js +2 -2
- package/dist/charts/core/cartesian/annotations.js +2 -2
- package/dist/charts/core/cartesian/marks.js +1 -1
- package/dist/charts/core/distribution/marks.js +1 -1
- package/dist/charts/core/distribution/xy-points.js +1 -1
- package/dist/charts/core/export-menu.js +1 -1
- package/dist/charts/funnel-chart/funnel-chart.js +1 -1
- package/dist/charts/gantt-chart/gantt-chart.js +4 -4
- package/dist/charts/gantt-chart/gantt-marks.js +3 -3
- package/dist/charts/index.d.ts +2 -0
- package/dist/charts/index.js +2 -0
- package/dist/charts/maps/geo/map-data-table.js +1 -1
- package/dist/charts/polar-area-chart/polar-area-chart.js +1 -1
- package/dist/charts/radar-chart/radar-chart.js +1 -1
- package/dist/charts/stock-chart/stock-chart.js +1 -1
- package/dist/charts/stock-chart/stock-drawing-layer.js +3 -3
- package/dist/charts/stock-chart/stock-plot.js +2 -2
- package/dist/containers/chat-thread/chat-thread.d.ts +98 -0
- package/dist/containers/chat-thread/chat-thread.js +219 -0
- package/dist/containers/chat-thread/format.d.ts +20 -0
- package/dist/containers/chat-thread/format.js +50 -0
- package/dist/containers/chat-thread/index.d.ts +1 -0
- package/dist/containers/chat-thread/index.js +8 -0
- package/dist/containers/cols/cols.d.ts +1 -1
- package/dist/containers/cols/cols.js +7 -0
- package/dist/containers/comment/comment.js +1 -1
- package/dist/containers/context-rail/context-rail.d.ts +62 -0
- package/dist/containers/context-rail/context-rail.js +175 -0
- package/dist/containers/context-rail/index.d.ts +1 -0
- package/dist/containers/context-rail/index.js +6 -0
- package/dist/containers/dashboard/dashboard.d.ts +40 -0
- package/dist/containers/dashboard/dashboard.js +84 -0
- package/dist/containers/dashboard/index.d.ts +1 -0
- package/dist/containers/dashboard/index.js +14 -0
- package/dist/containers/data-grid/data-grid.demos.js +4 -4
- package/dist/containers/data-grid/data-grid.js +6 -6
- package/dist/containers/data-grid/filter-builder-editor.js +2 -2
- package/dist/containers/data-grid/grid-toolbar.js +1 -1
- package/dist/containers/data-grid/spreadsheet.demos.d.ts +1 -1
- package/dist/containers/data-grid/spreadsheet.demos.js +1 -1
- package/dist/containers/detail-header/detail-header.d.ts +24 -0
- package/dist/containers/detail-header/detail-header.js +32 -0
- package/dist/containers/detail-header/index.d.ts +1 -0
- package/dist/containers/detail-header/index.js +6 -0
- package/dist/containers/facts/facts.js +1 -1
- package/dist/containers/filter-bar/filter-bar.d.ts +58 -0
- package/dist/containers/filter-bar/filter-bar.js +123 -0
- package/dist/containers/filter-bar/index.d.ts +1 -0
- package/dist/containers/filter-bar/index.js +6 -0
- package/dist/containers/hbars/hbars.js +2 -2
- package/dist/containers/index.d.ts +9 -0
- package/dist/containers/index.js +9 -0
- package/dist/containers/kanban/kanban.d.ts +23 -2
- package/dist/containers/kanban/kanban.js +103 -21
- package/dist/containers/kanban/model.d.ts +12 -0
- package/dist/containers/kanban/model.js +8 -0
- package/dist/containers/kpi/kpi.js +1 -1
- package/dist/containers/kpi-group/kpi-group.d.ts +6 -1
- package/dist/containers/kpi-group/kpi-group.js +6 -2
- package/dist/containers/list-detail/index.d.ts +1 -1
- package/dist/containers/list-detail/index.js +4 -0
- package/dist/containers/list-detail/list-detail.d.ts +51 -3
- package/dist/containers/list-detail/list-detail.js +111 -15
- package/dist/containers/page/page.d.ts +17 -4
- package/dist/containers/page/page.js +33 -4
- package/dist/containers/page-header/back.d.ts +10 -0
- package/dist/containers/page-header/back.js +28 -0
- package/dist/containers/page-header/index.d.ts +1 -0
- package/dist/containers/page-header/index.js +1 -0
- package/dist/containers/page-header/page-header.d.ts +19 -2
- package/dist/containers/page-header/page-header.js +26 -2
- package/dist/containers/pagination/cursor-pagination.d.ts +28 -0
- package/dist/containers/pagination/cursor-pagination.js +48 -0
- package/dist/containers/pagination/index.d.ts +3 -0
- package/dist/containers/pagination/index.js +10 -0
- package/dist/containers/pagination/pagination.d.ts +52 -0
- package/dist/containers/pagination/pagination.js +216 -0
- package/dist/containers/pagination/range.d.ts +29 -0
- package/dist/containers/pagination/range.js +42 -0
- package/dist/containers/pagination/use-pagination.d.ts +18 -0
- package/dist/containers/pagination/use-pagination.js +22 -0
- package/dist/containers/responsive-list/responsive-list.d.ts +29 -3
- package/dist/containers/responsive-list/responsive-list.js +202 -82
- package/dist/containers/row-actions/index.d.ts +1 -0
- package/dist/containers/row-actions/index.js +4 -0
- package/dist/containers/row-actions/row-actions.d.ts +26 -0
- package/dist/containers/row-actions/row-actions.js +78 -0
- package/dist/containers/selectable-card/index.d.ts +1 -0
- package/dist/containers/selectable-card/index.js +6 -0
- package/dist/containers/selectable-card/selectable-card.d.ts +26 -0
- package/dist/containers/selectable-card/selectable-card.js +57 -0
- package/dist/containers/settings-layout/settings-layout.d.ts +24 -7
- package/dist/containers/settings-layout/settings-layout.js +63 -8
- package/dist/containers/shortcuts/shortcuts.js +1 -1
- package/dist/containers/table/cell-padding.d.ts +2 -0
- package/dist/containers/table/cell-padding.js +4 -0
- package/dist/containers/table/index.d.ts +1 -0
- package/dist/containers/table/index.js +8 -0
- package/dist/containers/table/sort.d.ts +14 -0
- package/dist/containers/table/sort.js +11 -0
- package/dist/containers/table/table-parts.d.ts +24 -0
- package/dist/containers/table/table-parts.js +52 -0
- package/dist/containers/table/table.d.ts +37 -3
- package/dist/containers/table/table.js +120 -19
- package/dist/containers/table-columns-menu/index.d.ts +1 -0
- package/dist/containers/table-columns-menu/index.js +6 -0
- package/dist/containers/table-columns-menu/table-columns-menu.d.ts +14 -0
- package/dist/containers/table-columns-menu/table-columns-menu.js +46 -0
- package/dist/dashboards/layout.d.ts +1 -27
- package/dist/dashboards/layout.js +8 -40
- package/dist/forms/chip-group/chip-group.d.ts +5 -0
- package/dist/forms/chip-group/chip-group.js +3 -1
- package/dist/forms/combobox/combobox.js +1 -1
- package/dist/forms/copy-field/copy-field.js +1 -1
- package/dist/forms/date-picker/date-picker.d.ts +3 -1
- package/dist/forms/date-picker/date-picker.js +4 -2
- package/dist/forms/date-picker/date-time-picker.d.ts +8 -2
- package/dist/forms/date-picker/date-time-picker.js +13 -2
- package/dist/forms/field/field.d.ts +9 -2
- package/dist/forms/field/field.js +18 -4
- package/dist/forms/fieldset/fieldset.d.ts +11 -0
- package/dist/forms/fieldset/fieldset.js +12 -0
- package/dist/forms/fieldset/index.d.ts +1 -0
- package/dist/forms/fieldset/index.js +4 -0
- package/dist/forms/form-footer/form-footer.d.ts +26 -0
- package/dist/forms/form-footer/form-footer.js +44 -0
- package/dist/forms/form-footer/index.d.ts +1 -0
- package/dist/forms/form-footer/index.js +4 -0
- package/dist/forms/form-grid/form-grid.d.ts +21 -4
- package/dist/forms/form-grid/form-grid.js +20 -3
- package/dist/forms/form-grid/index.d.ts +1 -1
- package/dist/forms/form-grid/index.js +6 -2
- package/dist/forms/form-section/form-section.d.ts +12 -0
- package/dist/forms/form-section/form-section.js +30 -0
- package/dist/forms/form-section/index.d.ts +1 -0
- package/dist/forms/form-section/index.js +4 -0
- package/dist/forms/index.d.ts +3 -0
- package/dist/forms/index.js +3 -0
- package/dist/forms/input/input.d.ts +6 -2
- package/dist/forms/input/input.js +4 -1
- package/dist/forms/internal/listbox-items.d.ts +1 -1
- package/dist/forms/internal/listbox-items.js +3 -2
- package/dist/forms/native-select/native-select.js +1 -1
- package/dist/forms/number-stepper/index.d.ts +1 -1
- package/dist/forms/number-stepper/number-stepper.d.ts +7 -0
- package/dist/forms/number-stepper/number-stepper.js +37 -6
- package/dist/forms/select/index.d.ts +1 -1
- package/dist/forms/select/select.d.ts +5 -2
- package/dist/forms/select/select.js +7 -2
- package/dist/forms/select-menu/select-menu.js +1 -1
- package/dist/forms/time-input/time-input.d.ts +4 -2
- package/dist/forms/time-input/time-input.js +3 -1
- package/dist/i18n/strings.d.ts +94 -0
- package/dist/i18n/strings.js +50 -0
- package/dist/motion/count-up.d.ts +20 -0
- package/dist/motion/count-up.js +59 -0
- package/dist/motion/cross-fade.d.ts +21 -0
- package/dist/motion/cross-fade.js +86 -0
- package/dist/motion/index.d.ts +5 -0
- package/dist/motion/index.js +14 -0
- package/dist/motion/model.d.ts +15 -0
- package/dist/motion/model.js +68 -0
- package/dist/motion/motion-styles.d.ts +1 -0
- package/dist/motion/motion-styles.js +35 -0
- package/dist/motion/reveal.d.ts +37 -0
- package/dist/motion/reveal.js +69 -0
- package/dist/motion/use-enter-phase.d.ts +11 -0
- package/dist/motion/use-enter-phase.js +40 -0
- package/dist/motion/use-highlight-row.d.ts +22 -0
- package/dist/motion/use-highlight-row.js +38 -0
- package/dist/navigation/tabs/tabs.js +1 -1
- package/dist/navigation/wizard/wizard.d.ts +4 -1
- package/dist/navigation/wizard/wizard.js +3 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +8 -1
- package/dist/overlays/context-menu/context-menu.js +3 -1
- package/dist/overlays/dialog/dialog.d.ts +1 -0
- package/dist/overlays/dialog/dialog.js +11 -3
- package/dist/overlays/drawer/drawer.d.ts +18 -4
- package/dist/overlays/drawer/drawer.js +53 -4
- package/dist/overlays/drawer/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +1 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +5 -4
- package/dist/overlays/hover-card/hover-card.js +2 -0
- package/dist/overlays/popover/popover.js +2 -0
- package/dist/overlays/toaster/index.d.ts +1 -1
- package/dist/overlays/toaster/toast-store.d.ts +2 -0
- package/dist/overlays/toaster/toast-store.js +6 -1
- package/dist/overlays/toaster/toaster.d.ts +28 -2
- package/dist/overlays/toaster/toaster.js +86 -29
- package/dist/overlays/tooltip/tooltip.js +2 -0
- package/dist/primitives/use-presence.js +9 -0
- package/dist/shell/app-shell/app-shell.d.ts +8 -1
- package/dist/shell/app-shell/app-shell.js +50 -3
- package/dist/shell/index.d.ts +1 -0
- package/dist/shell/index.js +1 -0
- package/dist/shell/sidebar/sidebar.d.ts +17 -1
- package/dist/shell/sidebar/sidebar.js +126 -76
- package/dist/shell/topbar/topbar.d.ts +4 -2
- package/dist/shell/topbar/topbar.js +2 -0
- package/dist/showcase/operations-bento.js +2 -2
- package/dist/states/empty-state/empty-state.d.ts +10 -3
- package/dist/states/empty-state/empty-state.js +46 -5
- package/dist/states/error-state/error-state.js +1 -1
- package/dist/states/skeleton/skeleton.d.ts +16 -1
- package/dist/states/skeleton/skeleton.js +13 -5
- package/dist/utils/class-tokens.generated.js +4 -6
- package/dist/utils/focus-chain.d.ts +11 -0
- package/dist/utils/focus-chain.js +39 -0
- package/dist/utils/focus-rescue.d.ts +13 -0
- package/dist/utils/focus-rescue.js +48 -0
- package/dist/utils/list-navigation.d.ts +14 -0
- package/dist/utils/list-navigation.js +44 -0
- package/dist/utils/overlay-motion.d.ts +12 -0
- package/dist/utils/overlay-motion.js +14 -0
- package/dist/utils/use-container-width.d.ts +6 -0
- package/dist/utils/use-container-width.js +19 -0
- package/package.json +2 -2
- package/scripts/build-theme.mjs +46 -5
- package/src/ai/code-block/code-block.tsx +1 -1
- package/src/atoms/avatar/avatar.tsx +8 -2
- package/src/atoms/big-date/big-date.tsx +2 -2
- package/src/atoms/button/button.tsx +8 -3
- package/src/atoms/chip/chip.tsx +8 -3
- package/src/atoms/icon-button/icon-button.tsx +1 -1
- package/src/atoms/internal/hit-area.ts +5 -4
- package/src/atoms/progress/index.ts +8 -1
- package/src/atoms/progress/progress.tsx +30 -1
- package/src/atoms/radio-group/radio-group.tsx +1 -1
- package/src/atoms/status-pill/status-pill.tsx +59 -18
- package/src/brand/logo-forge.tsx +1 -1
- package/src/charts/candlestick-chart/candlestick-chart.tsx +2 -2
- package/src/charts/chart-grid/chart-grid.tsx +2 -2
- package/src/charts/chord-chart/chord-chart.tsx +1 -1
- package/src/charts/core/axes.tsx +2 -2
- package/src/charts/core/cartesian/annotations.tsx +2 -2
- package/src/charts/core/cartesian/marks.tsx +1 -1
- package/src/charts/core/distribution/marks.tsx +1 -1
- package/src/charts/core/distribution/xy-points.tsx +1 -1
- package/src/charts/core/export-menu.tsx +1 -1
- package/src/charts/funnel-chart/funnel-chart.tsx +1 -1
- package/src/charts/gantt-chart/gantt-chart.tsx +4 -4
- package/src/charts/gantt-chart/gantt-marks.tsx +3 -3
- package/src/charts/index.ts +2 -0
- package/src/charts/maps/geo/map-data-table.tsx +1 -1
- package/src/charts/polar-area-chart/polar-area-chart.tsx +1 -1
- package/src/charts/radar-chart/radar-chart.tsx +1 -1
- package/src/charts/stock-chart/stock-chart.tsx +1 -1
- package/src/charts/stock-chart/stock-drawing-layer.tsx +3 -3
- package/src/charts/stock-chart/stock-plot.tsx +2 -2
- package/src/containers/chat-thread/chat-thread.tsx +331 -0
- package/src/containers/chat-thread/format.ts +67 -0
- package/src/containers/chat-thread/index.ts +12 -0
- package/src/containers/cols/cols.tsx +13 -1
- package/src/containers/comment/comment.tsx +1 -1
- package/src/containers/context-rail/context-rail.tsx +229 -0
- package/src/containers/context-rail/index.ts +7 -0
- package/src/containers/dashboard/dashboard.tsx +142 -0
- package/src/containers/dashboard/index.ts +12 -0
- package/src/containers/data-grid/data-grid.demos.tsx +4 -4
- package/src/containers/data-grid/data-grid.tsx +6 -6
- package/src/containers/data-grid/filter-builder-editor.tsx +2 -2
- package/src/containers/data-grid/grid-toolbar.tsx +1 -1
- package/src/containers/data-grid/spreadsheet.demos.tsx +1 -1
- package/src/containers/detail-header/detail-header.tsx +64 -0
- package/src/containers/detail-header/index.ts +5 -0
- package/src/containers/facts/facts.tsx +1 -1
- package/src/containers/filter-bar/filter-bar.tsx +201 -0
- package/src/containers/filter-bar/index.ts +7 -0
- package/src/containers/hbars/hbars.tsx +2 -2
- package/src/containers/index.ts +9 -0
- package/src/containers/kanban/kanban.tsx +148 -39
- package/src/containers/kanban/model.ts +20 -0
- package/src/containers/kpi/kpi.tsx +1 -1
- package/src/containers/kpi-group/kpi-group.tsx +17 -2
- package/src/containers/list-detail/index.ts +5 -0
- package/src/containers/list-detail/list-detail.tsx +159 -9
- package/src/containers/page/page.tsx +61 -7
- package/src/containers/page-header/back.tsx +42 -0
- package/src/containers/page-header/index.ts +1 -0
- package/src/containers/page-header/page-header.tsx +49 -3
- package/src/containers/pagination/cursor-pagination.tsx +79 -0
- package/src/containers/pagination/index.ts +7 -0
- package/src/containers/pagination/pagination.tsx +266 -0
- package/src/containers/pagination/range.ts +68 -0
- package/src/containers/pagination/use-pagination.ts +44 -0
- package/src/containers/responsive-list/responsive-list.tsx +190 -47
- package/src/containers/row-actions/index.ts +1 -0
- package/src/containers/row-actions/row-actions.tsx +114 -0
- package/src/containers/selectable-card/index.ts +5 -0
- package/src/containers/selectable-card/selectable-card.tsx +84 -0
- package/src/containers/settings-layout/settings-layout.tsx +104 -13
- package/src/containers/shortcuts/shortcuts.tsx +1 -1
- package/src/containers/table/cell-padding.ts +2 -0
- package/src/containers/table/index.ts +6 -0
- package/src/containers/table/sort.ts +23 -0
- package/src/containers/table/table-parts.tsx +81 -0
- package/src/containers/table/table.tsx +212 -45
- package/src/containers/table-columns-menu/index.ts +5 -0
- package/src/containers/table-columns-menu/table-columns-menu.tsx +68 -0
- package/src/dashboards/layout.tsx +8 -75
- package/src/forms/chip-group/chip-group.tsx +8 -1
- package/src/forms/combobox/combobox.tsx +1 -1
- package/src/forms/copy-field/copy-field.tsx +1 -1
- package/src/forms/date-picker/date-picker.tsx +7 -2
- package/src/forms/date-picker/date-time-picker.tsx +28 -2
- package/src/forms/field/field.tsx +30 -3
- package/src/forms/fieldset/fieldset.tsx +22 -0
- package/src/forms/fieldset/index.ts +1 -0
- package/src/forms/form-footer/form-footer.tsx +74 -0
- package/src/forms/form-footer/index.ts +1 -0
- package/src/forms/form-grid/form-grid.tsx +42 -5
- package/src/forms/form-grid/index.ts +8 -1
- package/src/forms/form-section/form-section.tsx +41 -0
- package/src/forms/form-section/index.ts +1 -0
- package/src/forms/index.ts +3 -0
- package/src/forms/input/input.tsx +10 -3
- package/src/forms/internal/listbox-items.tsx +3 -4
- package/src/forms/native-select/native-select.tsx +1 -1
- package/src/forms/number-stepper/index.ts +1 -0
- package/src/forms/number-stepper/number-stepper.tsx +51 -6
- package/src/forms/select/index.ts +1 -1
- package/src/forms/select/select.tsx +14 -3
- package/src/forms/select-menu/select-menu.tsx +1 -1
- package/src/forms/time-input/time-input.tsx +6 -2
- package/src/i18n/strings.ts +94 -0
- package/src/motion/count-up.tsx +83 -0
- package/src/motion/cross-fade.tsx +139 -0
- package/src/motion/index.ts +5 -0
- package/src/motion/model.ts +86 -0
- package/src/motion/motion-styles.tsx +47 -0
- package/src/motion/reveal.tsx +115 -0
- package/src/motion/use-enter-phase.ts +50 -0
- package/src/motion/use-highlight-row.ts +63 -0
- package/src/navigation/tabs/tabs.tsx +1 -1
- package/src/navigation/wizard/wizard.tsx +6 -1
- package/src/overlays/alert-dialog/alert-dialog.tsx +5 -1
- package/src/overlays/context-menu/context-menu.tsx +3 -2
- package/src/overlays/dialog/dialog.tsx +9 -3
- package/src/overlays/drawer/drawer.tsx +68 -6
- package/src/overlays/drawer/index.ts +1 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +5 -4
- package/src/overlays/hover-card/hover-card.tsx +2 -0
- package/src/overlays/popover/popover.tsx +2 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toast-store.ts +8 -0
- package/src/overlays/toaster/toaster.tsx +127 -17
- package/src/overlays/tooltip/tooltip.tsx +2 -0
- package/src/primitives/use-presence.ts +13 -0
- package/src/shell/app-shell/app-shell.tsx +54 -2
- package/src/shell/index.ts +1 -0
- package/src/shell/sidebar/sidebar.tsx +154 -75
- package/src/shell/topbar/topbar.tsx +8 -0
- package/src/showcase/operations-bento.tsx +2 -2
- package/src/states/empty-state/empty-state.tsx +52 -9
- package/src/states/error-state/error-state.tsx +1 -1
- package/src/states/skeleton/skeleton.tsx +33 -5
- package/src/utils/class-tokens.generated.ts +4 -6
- package/src/utils/focus-chain.ts +53 -0
- package/src/utils/focus-rescue.ts +68 -0
- package/src/utils/list-navigation.ts +63 -0
- package/src/utils/overlay-motion.ts +33 -0
- package/src/utils/use-container-width.ts +24 -0
- package/styles/Theme.kt +15 -18
- package/styles/tailwind.css +29 -28
- package/styles/theme.css +29 -28
- package/styles/tokens.css +46 -0
- package/tokens/default.json +51 -29
|
@@ -15,6 +15,7 @@ import { useUiStrings } from "../../i18n/index.js";
|
|
|
15
15
|
import { ChevronLeft } from "../../icons/index.js";
|
|
16
16
|
import { cn } from "../../utils/cn.js";
|
|
17
17
|
import { composeHandlers } from "../../utils/compose.js";
|
|
18
|
+
import { useFocusRescue } from "../../utils/focus-rescue.js";
|
|
18
19
|
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
19
20
|
const ListDetailContext = createContext(null);
|
|
20
21
|
function useListDetailContext(part) {
|
|
@@ -26,13 +27,28 @@ function useListDetail() {
|
|
|
26
27
|
const { value, select } = useListDetailContext("useListDetail");
|
|
27
28
|
return { value, select, isSelected: (candidate) => candidate === value };
|
|
28
29
|
}
|
|
30
|
+
const ratioClasses = {
|
|
31
|
+
"1:1": "@min-[641px]/list-detail:grid-cols-2",
|
|
32
|
+
"1:2": "@min-[641px]/list-detail:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",
|
|
33
|
+
"1:3": "@min-[641px]/list-detail:grid-cols-[minmax(0,1fr)_minmax(0,3fr)]"
|
|
34
|
+
};
|
|
35
|
+
const FIXED_LIST_COLUMNS = "@min-[641px]/list-detail:grid-cols-[minmax(0,var(--ld-list-width))_minmax(0,1fr)]";
|
|
36
|
+
function cssLength(value) {
|
|
37
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
38
|
+
}
|
|
29
39
|
function ListDetail({
|
|
30
40
|
value: valueProp,
|
|
31
41
|
defaultValue = null,
|
|
32
42
|
onValueChange,
|
|
33
43
|
onBack,
|
|
34
44
|
"aria-label": label,
|
|
45
|
+
listWidth,
|
|
46
|
+
ratio = "1:1",
|
|
47
|
+
surface = "flat",
|
|
48
|
+
stickyList = false,
|
|
49
|
+
stickyOffset,
|
|
35
50
|
className,
|
|
51
|
+
style,
|
|
36
52
|
children,
|
|
37
53
|
...props
|
|
38
54
|
}) {
|
|
@@ -54,6 +70,7 @@ function ListDetail({
|
|
|
54
70
|
);
|
|
55
71
|
const rootRef = useRef(null);
|
|
56
72
|
const previous = useRef(value);
|
|
73
|
+
useFocusRescue(rootRef, { item: "[data-list-detail-item]", group: "ul" });
|
|
57
74
|
useEffect(() => {
|
|
58
75
|
const before = previous.current;
|
|
59
76
|
previous.current = value;
|
|
@@ -68,33 +85,81 @@ function ListDetail({
|
|
|
68
85
|
if (detail && back && back.getClientRects().length > 0) detail.focus();
|
|
69
86
|
}, [value]);
|
|
70
87
|
const context = useMemo(() => ({ value, select, label }), [value, select, label]);
|
|
71
|
-
return /* @__PURE__ */ jsx(ListDetailContext.Provider, { value: context, children: /* @__PURE__ */ jsx(
|
|
88
|
+
return /* @__PURE__ */ jsx(ListDetailContext.Provider, { value: context, children: /* @__PURE__ */ jsx(
|
|
72
89
|
"div",
|
|
73
90
|
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
...props,
|
|
92
|
+
ref: rootRef,
|
|
93
|
+
className: cn("@container/list-detail min-w-0", className),
|
|
94
|
+
style: {
|
|
95
|
+
...style,
|
|
96
|
+
...listWidth !== void 0 ? { "--ld-list-width": cssLength(listWidth) } : null,
|
|
97
|
+
...stickyOffset !== void 0 ? { "--ld-sticky-top": cssLength(stickyOffset) } : null
|
|
98
|
+
},
|
|
99
|
+
children: /* @__PURE__ */ jsx(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
"data-view": value === null ? "list" : "detail",
|
|
103
|
+
"data-surface": surface,
|
|
104
|
+
"data-sticky-list": stickyList ? "" : void 0,
|
|
105
|
+
className: cn(
|
|
106
|
+
"group/ld grid grid-cols-1",
|
|
107
|
+
surface === "flat" && "border-t-divider",
|
|
108
|
+
listWidth !== void 0 ? FIXED_LIST_COLUMNS : ratioClasses[ratio],
|
|
109
|
+
surface === "card" && "@min-[641px]/list-detail:gap-4",
|
|
110
|
+
"[&>*]:min-w-0"
|
|
111
|
+
),
|
|
112
|
+
children
|
|
113
|
+
}
|
|
114
|
+
)
|
|
81
115
|
}
|
|
82
|
-
) })
|
|
116
|
+
) });
|
|
83
117
|
}
|
|
84
|
-
function ListDetailList({ className, ...props }) {
|
|
118
|
+
function ListDetailList({ header, className, ...props }) {
|
|
85
119
|
const { label } = useListDetailContext("ListDetailList");
|
|
86
|
-
return /* @__PURE__ */
|
|
87
|
-
"
|
|
120
|
+
return /* @__PURE__ */ jsxs(
|
|
121
|
+
"div",
|
|
88
122
|
{
|
|
89
123
|
"data-list-detail-pane": "list",
|
|
90
|
-
"aria-label": label,
|
|
91
124
|
className: cn(
|
|
92
|
-
"
|
|
125
|
+
"flex min-h-0 min-w-0 flex-col",
|
|
93
126
|
"@min-[641px]/list-detail:border-r-divider",
|
|
94
127
|
"group-data-[view=detail]/ld:@max-[640px]/list-detail:hidden",
|
|
128
|
+
"group-data-[surface=card]/ld:overflow-hidden group-data-[surface=card]/ld:rounded-card group-data-[surface=card]/ld:border-card group-data-[surface=card]/ld:shadow-card group-data-[surface=card]/ld:surface-card group-data-[surface=card]/ld:@min-[641px]/list-detail:border-r-0",
|
|
129
|
+
"group-data-[sticky-list]/ld:@min-[641px]/list-detail:sticky group-data-[sticky-list]/ld:@min-[641px]/list-detail:top-(--ld-sticky-top,0px) group-data-[sticky-list]/ld:@min-[641px]/list-detail:max-h-[calc(100dvh-var(--ld-sticky-top,0px))] group-data-[sticky-list]/ld:@min-[641px]/list-detail:self-start"
|
|
130
|
+
),
|
|
131
|
+
children: [
|
|
132
|
+
header,
|
|
133
|
+
/* @__PURE__ */ jsx(
|
|
134
|
+
"ul",
|
|
135
|
+
{
|
|
136
|
+
"aria-label": label,
|
|
137
|
+
className: cn(
|
|
138
|
+
"m-0 flex min-h-0 list-none flex-col p-0",
|
|
139
|
+
"group-data-[sticky-list]/ld:@min-[641px]/list-detail:overflow-y-auto",
|
|
140
|
+
"group-data-[surface=card]/ld:p-2",
|
|
141
|
+
className
|
|
142
|
+
),
|
|
143
|
+
...props
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
function ListDetailHeader({ count, className, children, ...props }) {
|
|
151
|
+
return /* @__PURE__ */ jsxs(
|
|
152
|
+
"div",
|
|
153
|
+
{
|
|
154
|
+
className: cn(
|
|
155
|
+
"flex shrink-0 flex-wrap items-center gap-2 border-b-divider py-2.5 group-data-[surface=card]/ld:px-3",
|
|
95
156
|
className
|
|
96
157
|
),
|
|
97
|
-
...props
|
|
158
|
+
...props,
|
|
159
|
+
children: [
|
|
160
|
+
children,
|
|
161
|
+
count !== void 0 ? /* @__PURE__ */ jsx("span", { "aria-live": "polite", className: "ml-auto text-count text-ink-3", children: count }) : null
|
|
162
|
+
]
|
|
98
163
|
}
|
|
99
164
|
);
|
|
100
165
|
}
|
|
@@ -117,6 +182,7 @@ function ListDetailItem({
|
|
|
117
182
|
onClick: composeHandlers(onClick, () => select(value)),
|
|
118
183
|
className: cn(
|
|
119
184
|
"grid min-h-11 w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center gap-3 border-b-divider py-2.5 text-start hover:bg-surface-2 focus-visible:-outline-offset-2 focus-visible:focus-ring aria-[current=true]:bg-accent-soft",
|
|
185
|
+
"group-data-[surface=card]/ld:rounded-button group-data-[surface=card]/ld:border-b-0 group-data-[surface=card]/ld:px-3",
|
|
120
186
|
className
|
|
121
187
|
),
|
|
122
188
|
...props,
|
|
@@ -160,6 +226,7 @@ function ListDetailDetail({
|
|
|
160
226
|
className: cn(
|
|
161
227
|
"flex min-w-0 flex-col outline-none",
|
|
162
228
|
"group-data-[view=list]/ld:@max-[640px]/list-detail:hidden",
|
|
229
|
+
"group-data-[surface=card]/ld:rounded-card group-data-[surface=card]/ld:border-card group-data-[surface=card]/ld:px-card group-data-[surface=card]/ld:pb-card group-data-[surface=card]/ld:shadow-card group-data-[surface=card]/ld:surface-card",
|
|
163
230
|
className
|
|
164
231
|
),
|
|
165
232
|
children: [
|
|
@@ -209,10 +276,39 @@ function ListDetailDetailHeader({
|
|
|
209
276
|
}
|
|
210
277
|
);
|
|
211
278
|
}
|
|
279
|
+
function ListDetailEmpty({
|
|
280
|
+
icon,
|
|
281
|
+
title,
|
|
282
|
+
description,
|
|
283
|
+
action,
|
|
284
|
+
className,
|
|
285
|
+
...props
|
|
286
|
+
}) {
|
|
287
|
+
const { value } = useListDetailContext("ListDetailEmpty");
|
|
288
|
+
if (value !== null) return null;
|
|
289
|
+
return /* @__PURE__ */ jsxs(
|
|
290
|
+
"div",
|
|
291
|
+
{
|
|
292
|
+
className: cn(
|
|
293
|
+
"flex min-h-64 flex-1 flex-col items-center justify-center gap-2 px-6 py-12 text-center",
|
|
294
|
+
className
|
|
295
|
+
),
|
|
296
|
+
...props,
|
|
297
|
+
children: [
|
|
298
|
+
icon !== void 0 ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "inline-flex text-ink-3 [&_svg]:size-8", children: icon }) : null,
|
|
299
|
+
/* @__PURE__ */ jsx("p", { className: "m-0 font-semibold text-ink text-row-title", children: title }),
|
|
300
|
+
description !== void 0 ? /* @__PURE__ */ jsx("p", { className: "m-0 max-w-[44ch] text-ink-3 text-meta", children: description }) : null,
|
|
301
|
+
action !== void 0 ? /* @__PURE__ */ jsx("div", { className: "mt-2", children: action }) : null
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
}
|
|
212
306
|
export {
|
|
213
307
|
ListDetail,
|
|
214
308
|
ListDetailDetail,
|
|
215
309
|
ListDetailDetailHeader,
|
|
310
|
+
ListDetailEmpty,
|
|
311
|
+
ListDetailHeader,
|
|
216
312
|
ListDetailItem,
|
|
217
313
|
ListDetailList,
|
|
218
314
|
ListDetailMeta,
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
import type { ComponentPropsWithoutRef } from "react";
|
|
2
|
-
export
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
export interface PageProps extends ComponentPropsWithoutRef<"div"> {
|
|
3
|
+
/**
|
|
4
|
+
* A fixed column beside the page content, usually an `Aside`. The column draws a divider and the
|
|
5
|
+
* page background, never narrows the width the `page` container measures (so `Cols` inside the
|
|
6
|
+
* content react the same with or without it), and falls under the content once the page is
|
|
7
|
+
* 1000px wide or less. With an aside, `className` and the other props apply to the content column.
|
|
8
|
+
*/
|
|
9
|
+
aside?: ReactNode;
|
|
10
|
+
/** Width of the aside column: a number is pixels, a string any CSS length. Default `20rem` (320px at 16px). */
|
|
11
|
+
asideWidth?: number | string;
|
|
12
|
+
/** Keeps the aside column in view and scrolls it on its own beside the content (above 1000px). */
|
|
13
|
+
asideSticky?: boolean;
|
|
14
|
+
}
|
|
3
15
|
/**
|
|
4
16
|
* Vertical flow of page sections. It is the `page` container, so `Cols` and `SettingsLayout`
|
|
5
|
-
* inside it react to the page width instead of the viewport.
|
|
17
|
+
* inside it react to the page width instead of the viewport. With `aside` the page is a content
|
|
18
|
+
* column plus a rail; the shell around the page still owns the outer gutter and scrolling.
|
|
6
19
|
*/
|
|
7
|
-
export declare function Page({ className, ...props }: PageProps): import("react").JSX.Element;
|
|
20
|
+
export declare function Page({ aside, asideWidth, asideSticky, className, style, children, ...props }: PageProps): import("react").JSX.Element;
|
|
@@ -1,11 +1,40 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../utils/cn.js";
|
|
3
|
-
|
|
3
|
+
const CONTENT = "flex w-full min-w-0 flex-col gap-6";
|
|
4
|
+
function Page({
|
|
5
|
+
aside,
|
|
6
|
+
asideWidth,
|
|
7
|
+
asideSticky = false,
|
|
8
|
+
className,
|
|
9
|
+
style,
|
|
10
|
+
children,
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
if (aside === void 0) {
|
|
14
|
+
return /* @__PURE__ */ jsx("div", { className: cn("@container/page", CONTENT, className), style, ...props, children });
|
|
15
|
+
}
|
|
16
|
+
const width = asideWidth === void 0 ? void 0 : typeof asideWidth === "number" ? `${asideWidth}px` : asideWidth;
|
|
4
17
|
return /* @__PURE__ */ jsx(
|
|
5
18
|
"div",
|
|
6
19
|
{
|
|
7
|
-
|
|
8
|
-
|
|
20
|
+
"data-page-aside": "",
|
|
21
|
+
className: "@container/page w-full min-w-0",
|
|
22
|
+
style: width === void 0 ? void 0 : { "--page-aside-width": width },
|
|
23
|
+
children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_var(--page-aside-width,20rem)] items-start @max-[1000px]/page:grid-cols-[minmax(0,1fr)]", children: [
|
|
24
|
+
/* @__PURE__ */ jsx("div", { className: cn(CONTENT, className), style, ...props, children }),
|
|
25
|
+
/* @__PURE__ */ jsx(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
"data-page-rail": "",
|
|
29
|
+
className: cn(
|
|
30
|
+
"flex min-w-0 flex-col self-stretch border-l-divider bg-surface",
|
|
31
|
+
"@max-[1000px]/page:border-t-divider @max-[1000px]/page:border-l-0",
|
|
32
|
+
asideSticky && "@min-[1001px]/page:sticky @min-[1001px]/page:top-0 @min-[1001px]/page:max-h-dvh @min-[1001px]/page:self-start @min-[1001px]/page:overflow-y-auto"
|
|
33
|
+
),
|
|
34
|
+
children: aside
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
] })
|
|
9
38
|
}
|
|
10
39
|
);
|
|
11
40
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
export interface PageHeaderBackProps extends ComponentPropsWithoutRef<"a"> {
|
|
3
|
+
/** Renders the single child element (a router `Link`) with the link's look. The child supplies the label. */
|
|
4
|
+
asChild?: boolean | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The way back to the parent screen, for `PageHeader`'s `back` slot. A real link: pass `href`, or
|
|
8
|
+
* `asChild` with your router's `Link`. The label defaults to the localized "Back".
|
|
9
|
+
*/
|
|
10
|
+
export declare function PageHeaderBack({ asChild, className, children, ...props }: PageHeaderBackProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
4
|
+
import { ChevronLeft } from "../../icons/index.js";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
import { Slot } from "../../utils/slot.js";
|
|
7
|
+
function PageHeaderBack({
|
|
8
|
+
asChild = false,
|
|
9
|
+
className,
|
|
10
|
+
children,
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
const strings = useUiStrings();
|
|
14
|
+
const classes = cn(
|
|
15
|
+
"inline-flex min-h-8 items-center gap-1 text-control text-ink-2 no-underline hover:text-ink focus-visible:focus-ring",
|
|
16
|
+
className
|
|
17
|
+
);
|
|
18
|
+
if (asChild) {
|
|
19
|
+
return /* @__PURE__ */ jsx(Slot, { ...props, className: classes, children });
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ jsxs("a", { ...props, className: classes, children: [
|
|
22
|
+
/* @__PURE__ */ jsx(ChevronLeft, { "aria-hidden": "true", className: "size-4" }),
|
|
23
|
+
children ?? strings.back
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
PageHeaderBack
|
|
28
|
+
};
|
|
@@ -4,13 +4,30 @@ export interface PageHeaderProps extends ComponentPropsWithoutRef<"header"> {
|
|
|
4
4
|
breadcrumbs?: ReactNode;
|
|
5
5
|
/** Tighter, centred header with a smaller title and a body-size lede. */
|
|
6
6
|
compact?: boolean;
|
|
7
|
+
/** Link to the parent screen on its own row above the title: a `PageHeaderBack`. Shown before `breadcrumbs`. */
|
|
8
|
+
back?: ReactNode;
|
|
9
|
+
/** Row under the title block for status chips and short facts. Wraps; never needs a container query. */
|
|
10
|
+
meta?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Sub-navigation under the title, full width: a `TabsNav` (route tabs) or a `Tabs` list. The
|
|
13
|
+
* strip carries its own bottom divider, so it closes the header.
|
|
14
|
+
*/
|
|
15
|
+
tabs?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Keeps the whole header, tabs included, at the top of its scroll container with an opaque page
|
|
18
|
+
* background. The navigation inside stays reachable while the page scrolls.
|
|
19
|
+
*/
|
|
20
|
+
sticky?: boolean;
|
|
21
|
+
/** Distance a sticky header keeps from the top of its scroll container (number = pixels). Default `0`. */
|
|
22
|
+
stickyOffset?: number | string;
|
|
7
23
|
}
|
|
8
24
|
/**
|
|
9
25
|
* Page header. No required parts: compose an eyebrow / title / lede block in
|
|
10
26
|
* a plain `<div>` and, when the view has buttons, `PageHeaderActions` as the
|
|
11
|
-
* second child. Actions wrap under the title when the container is too narrow.
|
|
27
|
+
* second child. Actions wrap under the title when the container is too narrow. `back`,
|
|
28
|
+
* `breadcrumbs`, `meta` and `tabs` each take a full-width row around the children.
|
|
12
29
|
*/
|
|
13
|
-
export declare function PageHeader({ breadcrumbs, className, compact, children, ...props }: PageHeaderProps): import("react").JSX.Element;
|
|
30
|
+
export declare function PageHeader({ breadcrumbs, back, meta, tabs, sticky, stickyOffset, className, compact, style, children, ...props }: PageHeaderProps): import("react").JSX.Element;
|
|
14
31
|
export type PageHeaderEyebrowProps = ComponentPropsWithoutRef<"div">;
|
|
15
32
|
export declare function PageHeaderEyebrow({ className, ...props }: PageHeaderEyebrowProps): import("react").JSX.Element;
|
|
16
33
|
export type PageHeaderTitleProps = ComponentPropsWithoutRef<"h1">;
|
|
@@ -2,8 +2,14 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { cn } from "../../utils/cn.js";
|
|
3
3
|
function PageHeader({
|
|
4
4
|
breadcrumbs,
|
|
5
|
+
back,
|
|
6
|
+
meta,
|
|
7
|
+
tabs,
|
|
8
|
+
sticky,
|
|
9
|
+
stickyOffset,
|
|
5
10
|
className,
|
|
6
11
|
compact,
|
|
12
|
+
style,
|
|
7
13
|
children,
|
|
8
14
|
...props
|
|
9
15
|
}) {
|
|
@@ -11,15 +17,33 @@ function PageHeader({
|
|
|
11
17
|
"header",
|
|
12
18
|
{
|
|
13
19
|
"data-compact": compact ? "" : void 0,
|
|
20
|
+
"data-sticky": sticky ? "" : void 0,
|
|
14
21
|
className: cn(
|
|
15
22
|
"flex flex-wrap items-end justify-between gap-x-6 gap-y-3.5",
|
|
16
23
|
compact && "flex-col items-center justify-center gap-y-2 text-center",
|
|
24
|
+
sticky && "sticky top-(--page-header-top,0px) z-10 bg-surface",
|
|
17
25
|
className
|
|
18
26
|
),
|
|
27
|
+
style: stickyOffset === void 0 ? style : {
|
|
28
|
+
...style,
|
|
29
|
+
"--page-header-top": typeof stickyOffset === "number" ? `${stickyOffset}px` : stickyOffset
|
|
30
|
+
},
|
|
19
31
|
...props,
|
|
20
32
|
children: [
|
|
33
|
+
back ? /* @__PURE__ */ jsx("div", { className: "basis-full", children: back }) : null,
|
|
21
34
|
breadcrumbs ? /* @__PURE__ */ jsx("div", { className: "basis-full", children: breadcrumbs }) : null,
|
|
22
|
-
children
|
|
35
|
+
children,
|
|
36
|
+
meta ? /* @__PURE__ */ jsx(
|
|
37
|
+
"div",
|
|
38
|
+
{
|
|
39
|
+
className: cn(
|
|
40
|
+
"flex basis-full flex-wrap items-center gap-x-3 gap-y-1.5 text-ink-2 text-meta",
|
|
41
|
+
compact && "justify-center"
|
|
42
|
+
),
|
|
43
|
+
children: meta
|
|
44
|
+
}
|
|
45
|
+
) : null,
|
|
46
|
+
tabs ? /* @__PURE__ */ jsx("div", { className: "basis-full", children: tabs }) : null
|
|
23
47
|
]
|
|
24
48
|
}
|
|
25
49
|
);
|
|
@@ -38,7 +62,7 @@ function PageHeaderTitle({ className, ...props }) {
|
|
|
38
62
|
"h1",
|
|
39
63
|
{
|
|
40
64
|
className: cn(
|
|
41
|
-
"m-0 break-words text-page-title [text-wrap:balance] in-data-compact:text-fs-
|
|
65
|
+
"m-0 break-words text-page-title [text-wrap:balance] in-data-compact:text-fs-200",
|
|
42
66
|
className
|
|
43
67
|
),
|
|
44
68
|
...props
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from "react";
|
|
2
|
+
export interface CursorPaginationLabels {
|
|
3
|
+
nav: string;
|
|
4
|
+
/** `{first}` and `{last}` are replaced. */
|
|
5
|
+
range: string;
|
|
6
|
+
previous: string;
|
|
7
|
+
next: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CursorPaginationProps extends Omit<ComponentPropsWithoutRef<"nav">, "children" | "onChange"> {
|
|
10
|
+
/** 1-based page the cursor trail is on. */
|
|
11
|
+
page: number;
|
|
12
|
+
/** Rows on this page. */
|
|
13
|
+
count: number;
|
|
14
|
+
/** Rows per page, to number the range. Default 25. */
|
|
15
|
+
pageSize?: number;
|
|
16
|
+
/** Whether the server reported a next cursor. */
|
|
17
|
+
hasNext: boolean;
|
|
18
|
+
onPrevious: () => void;
|
|
19
|
+
onNext: () => void;
|
|
20
|
+
/** Texts (localized by default through `UiStrings`). */
|
|
21
|
+
labels?: Partial<CursorPaginationLabels>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Footer for server-side cursor paging, where the total is unknown: the range on screen ("Showing
|
|
25
|
+
* 26–50") and Previous / Next. Keep the cursor trail yourself; this only reports the clicks. It
|
|
26
|
+
* renders nothing while the whole list fits on the first page.
|
|
27
|
+
*/
|
|
28
|
+
export declare function CursorPagination({ page, count, pageSize, hasNext, onPrevious, onNext, labels, className, ...props }: CursorPaginationProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { Button } from "../../atoms/button/button.js";
|
|
5
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
6
|
+
import { cn } from "../../utils/cn.js";
|
|
7
|
+
import { formatRange } from "./range.js";
|
|
8
|
+
function CursorPagination({
|
|
9
|
+
page,
|
|
10
|
+
count,
|
|
11
|
+
pageSize = 25,
|
|
12
|
+
hasNext,
|
|
13
|
+
onPrevious,
|
|
14
|
+
onNext,
|
|
15
|
+
labels,
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}) {
|
|
19
|
+
const strings = useUiStrings();
|
|
20
|
+
const format = useMemo(() => new Intl.NumberFormat(strings.locale), [strings.locale]);
|
|
21
|
+
if (page <= 1 && !hasNext) return null;
|
|
22
|
+
const first = (Math.max(1, page) - 1) * pageSize + 1;
|
|
23
|
+
const last = first + Math.max(count, 1) - 1;
|
|
24
|
+
return /* @__PURE__ */ jsxs(
|
|
25
|
+
"nav",
|
|
26
|
+
{
|
|
27
|
+
"aria-label": labels?.nav ?? strings.pagination,
|
|
28
|
+
className: cn(
|
|
29
|
+
"flex min-w-0 flex-wrap items-center justify-between gap-x-4 gap-y-2 py-2 text-fs-120 text-ink-2",
|
|
30
|
+
className
|
|
31
|
+
),
|
|
32
|
+
...props,
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ jsx("span", { "aria-live": "polite", className: "tabular-nums", children: formatRange(labels?.range ?? strings.showingRangeOpen, {
|
|
35
|
+
first: format.format(first),
|
|
36
|
+
last: format.format(last)
|
|
37
|
+
}) }),
|
|
38
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
|
|
39
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", disabled: page <= 1, onClick: onPrevious, children: labels?.previous ?? strings.previous }),
|
|
40
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", disabled: !hasNext, onClick: onNext, children: labels?.next ?? strings.next })
|
|
41
|
+
] })
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
CursorPagination
|
|
48
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { CursorPagination, type CursorPaginationLabels, type CursorPaginationProps, } from "./cursor-pagination.js";
|
|
2
|
+
export { Pagination, type PaginationLabels, type PaginationProps } from "./pagination.js";
|
|
3
|
+
export { type PaginationState, usePagination } from "./use-pagination.js";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from "react";
|
|
2
|
+
export { clampPage, formatPageRange, formatRange, type PageItem, pageCount, pageItems, pageRange, } from "./range.js";
|
|
3
|
+
export interface PaginationLabels {
|
|
4
|
+
nav: string;
|
|
5
|
+
rowsPerPage: string;
|
|
6
|
+
/** `{first}`, `{last}` and `{total}` are replaced. */
|
|
7
|
+
range: string;
|
|
8
|
+
first: string;
|
|
9
|
+
previous: string;
|
|
10
|
+
next: string;
|
|
11
|
+
last: string;
|
|
12
|
+
/** Range text of the `pages` variant; `{first}`, `{last}` and `{total}` are replaced. */
|
|
13
|
+
showing: string;
|
|
14
|
+
/** Visible label of the previous button of the `pages` variant. */
|
|
15
|
+
previousLabel: string;
|
|
16
|
+
/** Visible label of the next button of the `pages` variant. */
|
|
17
|
+
nextLabel: string;
|
|
18
|
+
/** Name of a page number button; `{page}` is replaced. */
|
|
19
|
+
pageNumber: string;
|
|
20
|
+
}
|
|
21
|
+
export interface PaginationProps extends Omit<ComponentPropsWithoutRef<"nav">, "onChange"> {
|
|
22
|
+
/** Total rows across every page. */
|
|
23
|
+
total: number;
|
|
24
|
+
/** Controlled 1-based page. Pair it with `onPageChange`. */
|
|
25
|
+
page?: number;
|
|
26
|
+
/** Initial page when uncontrolled. Default 1. */
|
|
27
|
+
defaultPage?: number;
|
|
28
|
+
onPageChange?: (page: number) => void;
|
|
29
|
+
/** Controlled rows per page. Pair it with `onPageSizeChange`. */
|
|
30
|
+
pageSize?: number;
|
|
31
|
+
/** Initial rows per page when uncontrolled. Default: the first of `pageSizeOptions`. */
|
|
32
|
+
defaultPageSize?: number;
|
|
33
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
34
|
+
/** Choices of the page size picker. Default `[10, 25, 50, 100]`; a single option hides the picker. */
|
|
35
|
+
pageSizeOptions?: readonly number[];
|
|
36
|
+
/** Texts (localized by default through `UiStrings`). */
|
|
37
|
+
labels?: Partial<PaginationLabels>;
|
|
38
|
+
/**
|
|
39
|
+
* `default`: rows per page, the range and first/previous/next/last icon buttons. `pages`: the
|
|
40
|
+
* range ("Showing 1–25 of 134") and Previous, page number and Next buttons; it shows the page size
|
|
41
|
+
* picker only when `pageSizeOptions` is passed with more than one option.
|
|
42
|
+
*/
|
|
43
|
+
variant?: "default" | "pages";
|
|
44
|
+
/** Renders nothing while every row fits on one page. Default `true` for `pages`, `false` otherwise. */
|
|
45
|
+
hideOnSinglePage?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Footer of a list or table: rows per page, the range shown ("11–20 of 134") and first, previous,
|
|
49
|
+
* next and last buttons. Pages are 1-based. It does not slice your rows: use `page` and `pageSize`
|
|
50
|
+
* to do that, or to request the page from your API. Changing the page size returns to page 1.
|
|
51
|
+
*/
|
|
52
|
+
export declare function Pagination({ total, page, defaultPage, onPageChange, pageSize, defaultPageSize, onPageSizeChange, pageSizeOptions: pageSizeOptionsProp, labels, variant, hideOnSinglePage, className, ...props }: PaginationProps): import("react").JSX.Element | null;
|