@jcsoftdev/ui 0.5.0 → 0.6.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 +337 -0
- package/README.md +25 -3
- package/bin/ui-theme.mjs +40 -6
- package/dist/ai/code-block/code-block.js +1 -1
- 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 +101 -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 +109 -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 +28 -2
- package/dist/containers/responsive-list/responsive-list.js +134 -25
- 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/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 +86 -0
- package/dist/i18n/strings.js +46 -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.js +10 -2
- 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/toaster.d.ts +28 -2
- package/dist/overlays/toaster/toaster.js +73 -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.js +1 -1
- package/dist/utils/class-tokens.generated.js +4 -6
- 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/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 +146 -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 +157 -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 +183 -46
- 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/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 +86 -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 +7 -2
- 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/toaster.tsx +113 -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 +1 -1
- package/src/utils/class-tokens.generated.ts +4 -6
- 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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { ClassNames } from "../../utils/class-names.js";
|
|
3
|
+
/** Container widths (px) from which `layout="auto"` shows the table. The set is closed so every query is a literal class. */
|
|
4
|
+
export type ResponsiveListBreakpoint = 480 | 640 | 672 | 768 | 960 | 1280;
|
|
3
5
|
export interface ResponsiveListColumn<T> {
|
|
4
6
|
key: string;
|
|
5
7
|
header: string;
|
|
@@ -20,9 +22,33 @@ export interface ResponsiveListProps<T> {
|
|
|
20
22
|
/** Header of the actions column. Defaults to the localized "Actions". */
|
|
21
23
|
actionsHeader?: string;
|
|
22
24
|
rowClassName?: (item: T) => string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* `"auto"` (default) is a table from `breakpoint` of the list's own container width up and cards
|
|
27
|
+
* below it. `"cards"` always renders the cards, for a list that sits in a narrow pane (a master
|
|
28
|
+
* list next to its detail).
|
|
29
|
+
*/
|
|
30
|
+
layout?: "auto" | "cards";
|
|
31
|
+
/** Container width (px) from which `layout="auto"` shows the table. Defaults to 672 (42rem). */
|
|
32
|
+
breakpoint?: ResponsiveListBreakpoint;
|
|
33
|
+
/**
|
|
34
|
+
* `"visible"` (default) shows each field label in the cards. `"hidden"` keeps them for screen
|
|
35
|
+
* readers only, for cards whose values explain themselves (a price, a status).
|
|
36
|
+
*/
|
|
37
|
+
cardLabels?: "visible" | "hidden";
|
|
38
|
+
/** Key of the selected row, or `null`/`undefined` for none. Only used together with `onSelect`. */
|
|
39
|
+
selectedKey?: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Makes rows selectable (click, Enter or Space) and adds keyboard navigation (arrows, Home, End).
|
|
42
|
+
* Without `renderActions` the cards are a `listbox` of `option`s and the table a `grid` whose
|
|
43
|
+
* rows carry `aria-selected`; with it the rows keep plain list/table semantics and the selected
|
|
44
|
+
* one gets `aria-current="true"`, because actions cannot live inside an option.
|
|
45
|
+
*/
|
|
46
|
+
onSelect?: (key: string, item: T) => void;
|
|
47
|
+
/** Arrow keys select the row they land on, not only move focus. Off by default. */
|
|
48
|
+
selectOnFocus?: boolean;
|
|
23
49
|
className?: string;
|
|
24
50
|
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
25
51
|
classNames?: ClassNames<ResponsiveListPart>;
|
|
26
52
|
}
|
|
27
|
-
/** A table
|
|
28
|
-
export declare function ResponsiveList<T>({ caption, items, columns, rowKey, renderActions, actionsHeader, rowClassName, className, classNames, }: ResponsiveListProps<T>): import("react").JSX.Element;
|
|
53
|
+
/** A table from `breakpoint` of its own width up and a stack of cards below it, from one column definition. */
|
|
54
|
+
export declare function ResponsiveList<T>({ caption, items, columns, rowKey, renderActions, actionsHeader, rowClassName, layout, breakpoint, cardLabels, selectedKey, onSelect, selectOnFocus, className, classNames, }: ResponsiveListProps<T>): import("react").JSX.Element;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useUiStrings } from "../../i18n/index.js";
|
|
4
4
|
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { focusRowByKey } from "../../utils/list-navigation.js";
|
|
5
6
|
import {
|
|
6
7
|
Table,
|
|
7
8
|
TableBody,
|
|
@@ -10,6 +11,32 @@ import {
|
|
|
10
11
|
TableHeaderCell,
|
|
11
12
|
TableRow
|
|
12
13
|
} from "../table/table.js";
|
|
14
|
+
const tableClasses = {
|
|
15
|
+
480: {
|
|
16
|
+
table: "hidden @min-[480px]/responsive-list:block",
|
|
17
|
+
cards: "@min-[480px]/responsive-list:hidden"
|
|
18
|
+
},
|
|
19
|
+
640: {
|
|
20
|
+
table: "hidden @min-[640px]/responsive-list:block",
|
|
21
|
+
cards: "@min-[640px]/responsive-list:hidden"
|
|
22
|
+
},
|
|
23
|
+
672: {
|
|
24
|
+
table: "hidden @min-[42rem]/responsive-list:block",
|
|
25
|
+
cards: "@min-[42rem]/responsive-list:hidden"
|
|
26
|
+
},
|
|
27
|
+
768: {
|
|
28
|
+
table: "hidden @min-[768px]/responsive-list:block",
|
|
29
|
+
cards: "@min-[768px]/responsive-list:hidden"
|
|
30
|
+
},
|
|
31
|
+
960: {
|
|
32
|
+
table: "hidden @min-[960px]/responsive-list:block",
|
|
33
|
+
cards: "@min-[960px]/responsive-list:hidden"
|
|
34
|
+
},
|
|
35
|
+
1280: {
|
|
36
|
+
table: "hidden @min-[1280px]/responsive-list:block",
|
|
37
|
+
cards: "@min-[1280px]/responsive-list:hidden"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
13
40
|
function ResponsiveList({
|
|
14
41
|
caption,
|
|
15
42
|
items,
|
|
@@ -18,47 +45,115 @@ function ResponsiveList({
|
|
|
18
45
|
renderActions,
|
|
19
46
|
actionsHeader,
|
|
20
47
|
rowClassName,
|
|
48
|
+
layout = "auto",
|
|
49
|
+
breakpoint = 672,
|
|
50
|
+
cardLabels = "visible",
|
|
51
|
+
selectedKey,
|
|
52
|
+
onSelect,
|
|
53
|
+
selectOnFocus = false,
|
|
21
54
|
className,
|
|
22
55
|
classNames
|
|
23
56
|
}) {
|
|
24
57
|
const strings = useUiStrings();
|
|
25
58
|
const primary = columns.find((column) => column.primary) ?? columns[0];
|
|
26
59
|
const details = columns.filter((column) => column !== primary);
|
|
60
|
+
const selectable = onSelect !== void 0;
|
|
61
|
+
const listbox = selectable && !renderActions;
|
|
62
|
+
const firstKey = items[0] ? rowKey(items[0]) : void 0;
|
|
63
|
+
const stopKey = selectedKey != null && items.some((item) => rowKey(item) === selectedKey) ? selectedKey : firstKey;
|
|
64
|
+
const rowProps = (item, kind) => {
|
|
65
|
+
if (!selectable) return {};
|
|
66
|
+
const key = rowKey(item);
|
|
67
|
+
const selected = key === selectedKey;
|
|
68
|
+
const select = () => onSelect(key, item);
|
|
69
|
+
return {
|
|
70
|
+
tabIndex: key === stopKey ? 0 : -1,
|
|
71
|
+
"data-selected": selected ? "true" : void 0,
|
|
72
|
+
...kind === "grid" || listbox ? { "aria-selected": selected } : { "aria-current": selected ? "true" : void 0 },
|
|
73
|
+
...kind === "card" && listbox ? { role: "option" } : {},
|
|
74
|
+
onClick: (event) => {
|
|
75
|
+
if (event.target.closest(
|
|
76
|
+
"a, button, input, select, textarea, [data-row-actions]"
|
|
77
|
+
))
|
|
78
|
+
return;
|
|
79
|
+
select();
|
|
80
|
+
},
|
|
81
|
+
onKeyDown: (event) => {
|
|
82
|
+
if (event.target !== event.currentTarget) return;
|
|
83
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
select();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const scope = event.currentTarget.closest("[data-row-scope]");
|
|
89
|
+
if (!scope || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
90
|
+
const row = focusRowByKey(scope, event.currentTarget, event.key);
|
|
91
|
+
if (!row) return;
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
if (selectOnFocus) {
|
|
94
|
+
const nextKey = row.getAttribute("data-row-key");
|
|
95
|
+
const next = items.find((candidate) => rowKey(candidate) === nextKey);
|
|
96
|
+
if (next) onSelect(rowKey(next), next);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
};
|
|
27
101
|
return /* @__PURE__ */ jsxs("div", { className: cn("@container/responsive-list min-w-0", classNames?.root, className), children: [
|
|
28
|
-
/* @__PURE__ */ jsx(
|
|
102
|
+
layout === "auto" ? /* @__PURE__ */ jsx(
|
|
29
103
|
"div",
|
|
30
104
|
{
|
|
31
105
|
className: cn(
|
|
32
|
-
"
|
|
106
|
+
"rounded-card border-card shadow-card surface-card",
|
|
107
|
+
tableClasses[breakpoint].table,
|
|
33
108
|
classNames?.tableWrapper
|
|
34
109
|
),
|
|
35
|
-
children: /* @__PURE__ */ jsxs(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
110
|
+
children: /* @__PURE__ */ jsxs(
|
|
111
|
+
Table,
|
|
112
|
+
{
|
|
113
|
+
...selectable ? { role: "grid", "aria-label": caption, "data-row-scope": "" } : {},
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsx("caption", { className: "sr-only", children: caption }),
|
|
116
|
+
/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { className: "hover:bg-transparent", children: [
|
|
117
|
+
columns.map((column) => /* @__PURE__ */ jsx(TableHeaderCell, { scope: "col", alignRight: column.align === "end", children: column.header }, column.key)),
|
|
118
|
+
renderActions ? /* @__PURE__ */ jsx(TableHeaderCell, { scope: "col", alignRight: true, children: actionsHeader ?? strings.actions }) : null
|
|
119
|
+
] }) }),
|
|
120
|
+
/* @__PURE__ */ jsx(TableBody, { children: items.map((item) => /* @__PURE__ */ jsxs(
|
|
121
|
+
TableRow,
|
|
122
|
+
{
|
|
123
|
+
"data-row-key": rowKey(item),
|
|
124
|
+
className: cn(
|
|
125
|
+
rowClassName?.(item),
|
|
126
|
+
selectable && "cursor-pointer focus-visible:focus-ring data-[selected=true]:bg-accent-soft"
|
|
127
|
+
),
|
|
128
|
+
...rowProps(item, "grid"),
|
|
129
|
+
children: [
|
|
130
|
+
columns.map((column) => /* @__PURE__ */ jsx(TableCell, { alignRight: column.align === "end", children: column.cell(item) }, column.key)),
|
|
131
|
+
renderActions ? /* @__PURE__ */ jsx(TableCell, { alignRight: true, children: /* @__PURE__ */ jsx(
|
|
132
|
+
"div",
|
|
133
|
+
{
|
|
134
|
+
"data-row-actions": "",
|
|
135
|
+
className: cn("flex flex-wrap justify-end gap-2", classNames?.actions),
|
|
136
|
+
children: renderActions(item)
|
|
137
|
+
}
|
|
138
|
+
) }) : null
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
rowKey(item)
|
|
142
|
+
)) })
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
)
|
|
54
146
|
}
|
|
55
|
-
),
|
|
147
|
+
) : null,
|
|
56
148
|
/* @__PURE__ */ jsx(
|
|
57
149
|
"ul",
|
|
58
150
|
{
|
|
59
151
|
"aria-label": caption,
|
|
152
|
+
...listbox ? { role: "listbox" } : {},
|
|
153
|
+
...selectable ? { "data-row-scope": "" } : {},
|
|
60
154
|
className: cn(
|
|
61
|
-
"m-0 flex list-none flex-col gap-density p-0
|
|
155
|
+
"m-0 flex list-none flex-col gap-density p-0",
|
|
156
|
+
layout === "auto" && tableClasses[breakpoint].cards,
|
|
62
157
|
classNames?.cards
|
|
63
158
|
),
|
|
64
159
|
children: items.map((item) => /* @__PURE__ */ jsxs(
|
|
@@ -67,9 +162,11 @@ function ResponsiveList({
|
|
|
67
162
|
"data-row-key": rowKey(item),
|
|
68
163
|
className: cn(
|
|
69
164
|
"flex min-w-0 flex-col gap-3 rounded-card border-card p-card shadow-card surface-card",
|
|
165
|
+
selectable && "cursor-pointer focus-visible:focus-ring data-[selected=true]:bg-accent-soft data-[selected=true]:shadow-selected",
|
|
70
166
|
rowClassName?.(item),
|
|
71
167
|
classNames?.card
|
|
72
168
|
),
|
|
169
|
+
...rowProps(item, "card"),
|
|
73
170
|
children: [
|
|
74
171
|
/* @__PURE__ */ jsx(
|
|
75
172
|
"div",
|
|
@@ -86,15 +183,27 @@ function ResponsiveList({
|
|
|
86
183
|
{
|
|
87
184
|
className: cn(
|
|
88
185
|
"flex items-baseline justify-between gap-4",
|
|
186
|
+
cardLabels === "hidden" && "justify-start",
|
|
89
187
|
classNames?.cardDetail
|
|
90
188
|
),
|
|
91
189
|
children: [
|
|
92
|
-
/* @__PURE__ */ jsx(
|
|
190
|
+
/* @__PURE__ */ jsx(
|
|
191
|
+
"dt",
|
|
192
|
+
{
|
|
193
|
+
className: cn(
|
|
194
|
+
"shrink-0 text-ink-3 text-meta",
|
|
195
|
+
cardLabels === "hidden" && "sr-only",
|
|
196
|
+
classNames?.cardLabel
|
|
197
|
+
),
|
|
198
|
+
children: column.header
|
|
199
|
+
}
|
|
200
|
+
),
|
|
93
201
|
/* @__PURE__ */ jsx(
|
|
94
202
|
"dd",
|
|
95
203
|
{
|
|
96
204
|
className: cn(
|
|
97
205
|
"m-0 min-w-0 text-right text-body text-ink [overflow-wrap:anywhere]",
|
|
206
|
+
cardLabels === "hidden" && "text-left",
|
|
98
207
|
classNames?.cardValue
|
|
99
208
|
),
|
|
100
209
|
children: column.cell(item)
|
|
@@ -104,7 +213,7 @@ function ResponsiveList({
|
|
|
104
213
|
},
|
|
105
214
|
column.key
|
|
106
215
|
)) }) : null,
|
|
107
|
-
renderActions ? /* @__PURE__ */ jsx("div", { className: cn("flex flex-wrap gap-2", classNames?.actions), children: renderActions(item) }) : null
|
|
216
|
+
renderActions ? /* @__PURE__ */ jsx("div", { "data-row-actions": "", className: cn("flex flex-wrap gap-2", classNames?.actions), children: renderActions(item) }) : null
|
|
108
217
|
]
|
|
109
218
|
},
|
|
110
219
|
rowKey(item)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type RowActionItem, RowActions, type RowActionsProps } from "./row-actions.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactNode } from "react";
|
|
2
|
+
export interface RowActionItem {
|
|
3
|
+
/** Stable key of the item. */
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
onSelect: () => void;
|
|
7
|
+
/** Leading decorative icon. */
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/** `danger` items sort to the end of the menu, behind a separator, and read in the danger colour. */
|
|
10
|
+
tone?: "default" | "danger";
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface RowActionsProps extends Omit<ComponentPropsWithoutRef<"span">, "children" | "onClick" | "onKeyDown"> {
|
|
14
|
+
/** Accessible name of the overflow trigger. Name the row: "Actions for Ana Quispe". */
|
|
15
|
+
label: string;
|
|
16
|
+
/** At most one inline action, typically a `Button size="sm"`: the one thing the row is mostly for. */
|
|
17
|
+
primary?: ReactNode;
|
|
18
|
+
/** The rest, in the overflow menu. No trigger renders when it is empty. */
|
|
19
|
+
items: readonly RowActionItem[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* One row's actions: at most one inline primary action, the rest in an overflow menu behind a
|
|
23
|
+
* 30px "more" button. It never wraps, so the row keeps its height; destructive items sort last,
|
|
24
|
+
* behind a separator. The menu is a WAI-ARIA menu: arrows, Home/End, typeahead, Escape.
|
|
25
|
+
*/
|
|
26
|
+
export declare function RowActions({ label, primary, items, className, ...props }: RowActionsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
Fragment
|
|
5
|
+
} from "react";
|
|
6
|
+
import { IconButton } from "../../atoms/icon-button/icon-button.js";
|
|
7
|
+
import { EllipsisVertical } from "../../icons/index.js";
|
|
8
|
+
import {
|
|
9
|
+
DropdownMenu,
|
|
10
|
+
DropdownMenuContent,
|
|
11
|
+
DropdownMenuItem,
|
|
12
|
+
DropdownMenuSeparator,
|
|
13
|
+
DropdownMenuTrigger
|
|
14
|
+
} from "../../overlays/dropdown-menu/dropdown-menu.js";
|
|
15
|
+
import { cn } from "../../utils/cn.js";
|
|
16
|
+
function contain(event) {
|
|
17
|
+
event.stopPropagation();
|
|
18
|
+
}
|
|
19
|
+
function RowActions({ label, primary, items, className, ...props }) {
|
|
20
|
+
const regular = items.filter((item) => item.tone !== "danger");
|
|
21
|
+
const destructive = items.filter((item) => item.tone === "danger");
|
|
22
|
+
return (
|
|
23
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: only stops events from bubbling to the row; the controls inside are the interactive parts
|
|
24
|
+
/* @__PURE__ */ jsxs(
|
|
25
|
+
"span",
|
|
26
|
+
{
|
|
27
|
+
"data-slot": "row-actions",
|
|
28
|
+
className: cn(
|
|
29
|
+
"inline-flex flex-nowrap items-center justify-end gap-1.5 whitespace-nowrap",
|
|
30
|
+
className
|
|
31
|
+
),
|
|
32
|
+
...props,
|
|
33
|
+
onClick: contain,
|
|
34
|
+
onKeyDown: contain,
|
|
35
|
+
children: [
|
|
36
|
+
primary,
|
|
37
|
+
items.length > 0 ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
38
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
39
|
+
IconButton,
|
|
40
|
+
{
|
|
41
|
+
size: "sm",
|
|
42
|
+
variant: "secondary",
|
|
43
|
+
label,
|
|
44
|
+
className: "transition-[scale,color] duration-(--motion-duration) ease-(--motion-ease) motion-reduce:transition-none [@media(hover:hover)]:text-ink-3 [@media(hover:hover)]:group-focus-within/row:text-ink [@media(hover:hover)]:group-hover/row:text-ink data-[state=open]:text-ink",
|
|
45
|
+
children: /* @__PURE__ */ jsx(EllipsisVertical, { "aria-hidden": "true" })
|
|
46
|
+
}
|
|
47
|
+
) }),
|
|
48
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { align: "end", children: [regular, destructive].map(
|
|
49
|
+
(group, index) => group.length === 0 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
50
|
+
index === 1 && regular.length > 0 ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
51
|
+
group.map((item) => /* @__PURE__ */ jsxs(
|
|
52
|
+
DropdownMenuItem,
|
|
53
|
+
{
|
|
54
|
+
disabled: item.disabled,
|
|
55
|
+
onSelect: () => item.onSelect(),
|
|
56
|
+
"data-tone": item.tone === "danger" ? "danger" : void 0,
|
|
57
|
+
className: cn(
|
|
58
|
+
"[&_svg]:size-4 [&_svg]:shrink-0",
|
|
59
|
+
item.tone === "danger" && "text-danger data-highlighted:bg-danger-soft"
|
|
60
|
+
),
|
|
61
|
+
children: [
|
|
62
|
+
item.icon,
|
|
63
|
+
item.label
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
item.id
|
|
67
|
+
))
|
|
68
|
+
] }, index === 0 ? "regular" : "destructive")
|
|
69
|
+
) })
|
|
70
|
+
] }) : null
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
RowActions
|
|
78
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectableCard, type SelectableCardPart, type SelectableCardProps, } from "./selectable-card.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef, type ReactNode } from "react";
|
|
2
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
3
|
+
export type SelectableCardPart = "root" | "content" | "reason";
|
|
4
|
+
export interface SelectableCardProps extends Omit<ComponentPropsWithRef<"button">, "children" | "role" | "aria-checked"> {
|
|
5
|
+
/** Card content. It sits inside a button, so use phrasing content only (spans, text, icons). */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Selectable mode. Omitted: the card is a plain button that runs `onClick`. A boolean makes it
|
|
9
|
+
* a toggle (`aria-pressed`), or a radio (`aria-checked`) with `semantics="radio"`.
|
|
10
|
+
*/
|
|
11
|
+
selected?: boolean;
|
|
12
|
+
/** `"pressed"` for a toggle (default), `"radio"` when exactly one card of a group is selected; wrap the group in `role="radiogroup"`. */
|
|
13
|
+
semantics?: "pressed" | "radio";
|
|
14
|
+
/** The card stays focusable and ignores clicks (`aria-disabled`), and the reason is read out with it. */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** Visible text explaining why the card is disabled; announced as its description. */
|
|
17
|
+
disabledReason?: string;
|
|
18
|
+
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
19
|
+
classNames?: ClassNames<SelectableCardPart>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A card that is itself the interactive element: one `button`, no overlay and no nested
|
|
23
|
+
* controls. Use it as a button (`onClick`) or as a selectable option (`selected`). A disabled card
|
|
24
|
+
* keeps focus so its reason can be reached.
|
|
25
|
+
*/
|
|
26
|
+
export declare function SelectableCard({ children, selected, semantics, disabled, disabledReason, onClick, className, classNames, "aria-describedby": describedBy, ...props }: SelectableCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
function SelectableCard({
|
|
6
|
+
children,
|
|
7
|
+
selected,
|
|
8
|
+
semantics = "pressed",
|
|
9
|
+
disabled = false,
|
|
10
|
+
disabledReason,
|
|
11
|
+
onClick,
|
|
12
|
+
className,
|
|
13
|
+
classNames,
|
|
14
|
+
"aria-describedby": describedBy,
|
|
15
|
+
...props
|
|
16
|
+
}) {
|
|
17
|
+
const reasonId = useId();
|
|
18
|
+
const showReason = disabled && Boolean(disabledReason);
|
|
19
|
+
const radio = semantics === "radio" && selected !== void 0;
|
|
20
|
+
const handleClick = (event) => {
|
|
21
|
+
if (disabled) {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
onClick?.(event);
|
|
26
|
+
};
|
|
27
|
+
return (
|
|
28
|
+
// biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-checked is only set together with role="radio"
|
|
29
|
+
/* @__PURE__ */ jsxs(
|
|
30
|
+
"button",
|
|
31
|
+
{
|
|
32
|
+
type: "button",
|
|
33
|
+
...props,
|
|
34
|
+
role: radio ? "radio" : void 0,
|
|
35
|
+
"aria-checked": radio ? selected : void 0,
|
|
36
|
+
"aria-pressed": !radio && selected !== void 0 ? selected : void 0,
|
|
37
|
+
"aria-disabled": disabled || void 0,
|
|
38
|
+
"aria-describedby": [describedBy, showReason ? reasonId : void 0].filter(Boolean).join(" ") || void 0,
|
|
39
|
+
onClick: handleClick,
|
|
40
|
+
className: cn(
|
|
41
|
+
"pressable flex w-full min-w-0 flex-col gap-1 rounded-card border-card p-card text-left shadow-card surface-card focus-visible:focus-ring",
|
|
42
|
+
selected && "border-accent-line bg-accent-soft shadow-selected",
|
|
43
|
+
disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer",
|
|
44
|
+
classNames?.root,
|
|
45
|
+
className
|
|
46
|
+
),
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ jsx("span", { className: cn("flex min-w-0 flex-col gap-1", classNames?.content), children }),
|
|
49
|
+
showReason ? /* @__PURE__ */ jsx("span", { id: reasonId, className: cn("text-ink-3 text-meta", classNames?.reason), children: disabledReason }) : null
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
SelectableCard
|
|
57
|
+
};
|
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
1
|
+
import { type ComponentPropsWithoutRef } from "react";
|
|
2
|
+
/** Container widths (px) under which the layout stacks. The set is closed so every query is a literal class. */
|
|
3
|
+
export type SettingsLayoutBreakpoint = 720 | 940 | 1080 | 1280;
|
|
4
|
+
export type SettingsLayoutContainer = "page" | "self";
|
|
5
|
+
export interface SettingsLayoutProps extends ComponentPropsWithoutRef<"div"> {
|
|
6
|
+
/**
|
|
7
|
+
* Container width (px) under which the nav and the content stack. `"never"` keeps two columns.
|
|
8
|
+
* Defaults to 940. `SettingsLayoutNav` follows it without being told.
|
|
9
|
+
*/
|
|
10
|
+
breakpoint?: SettingsLayoutBreakpoint | "never";
|
|
11
|
+
/**
|
|
12
|
+
* Which container is measured. `"page"` (default) is the ancestor `@container/page`;
|
|
13
|
+
* `"self"` wraps the layout in its own container, for use outside a page shell.
|
|
14
|
+
*/
|
|
15
|
+
container?: SettingsLayoutContainer;
|
|
16
|
+
}
|
|
3
17
|
/**
|
|
4
|
-
* Two-column settings grid (side nav + content).
|
|
5
|
-
*
|
|
18
|
+
* Two-column settings grid (side nav + content). Stacks to one column under `breakpoint`
|
|
19
|
+
* (940 px by default) of the measured container, never of the viewport.
|
|
6
20
|
*/
|
|
7
|
-
export declare function SettingsLayout({ className, ...props }: SettingsLayoutProps): import("react").JSX.Element;
|
|
8
|
-
export
|
|
21
|
+
export declare function SettingsLayout({ breakpoint, container, className, ...props }: SettingsLayoutProps): import("react").JSX.Element;
|
|
22
|
+
export interface SettingsLayoutNavProps extends ComponentPropsWithoutRef<"nav"> {
|
|
23
|
+
/** Overrides the breakpoint the surrounding `SettingsLayout` set. */
|
|
24
|
+
breakpoint?: SettingsLayoutBreakpoint | "never";
|
|
25
|
+
}
|
|
9
26
|
/** Sticky side nav that becomes a scrollable horizontal row on narrow pages. */
|
|
10
|
-
export declare function SettingsLayoutNav({ "aria-label": ariaLabel, className, ...props }: SettingsLayoutNavProps): import("react").JSX.Element;
|
|
27
|
+
export declare function SettingsLayoutNav({ "aria-label": ariaLabel, breakpoint, className, ...props }: SettingsLayoutNavProps): import("react").JSX.Element;
|
|
11
28
|
export interface SettingsLayoutNavItemProps extends ComponentPropsWithoutRef<"button"> {
|
|
12
29
|
/** Currently visible section. */
|
|
13
30
|
active?: boolean;
|
|
@@ -1,30 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, use } from "react";
|
|
2
4
|
import { cn } from "../../utils/cn.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
const SettingsLayoutContext = createContext({
|
|
6
|
+
breakpoint: 940,
|
|
7
|
+
container: "page"
|
|
8
|
+
});
|
|
9
|
+
const stackClasses = {
|
|
10
|
+
page: {
|
|
11
|
+
720: {
|
|
12
|
+
grid: "@max-[720px]/page:grid-cols-1",
|
|
13
|
+
nav: "@max-[720px]/page:static @max-[720px]/page:flex-row @max-[720px]/page:overflow-x-auto"
|
|
14
|
+
},
|
|
15
|
+
940: {
|
|
16
|
+
grid: "@max-[940px]/page:grid-cols-1",
|
|
17
|
+
nav: "@max-[940px]/page:static @max-[940px]/page:flex-row @max-[940px]/page:overflow-x-auto"
|
|
18
|
+
},
|
|
19
|
+
1080: {
|
|
20
|
+
grid: "@max-[1080px]/page:grid-cols-1",
|
|
21
|
+
nav: "@max-[1080px]/page:static @max-[1080px]/page:flex-row @max-[1080px]/page:overflow-x-auto"
|
|
22
|
+
},
|
|
23
|
+
1280: {
|
|
24
|
+
grid: "@max-[1280px]/page:grid-cols-1",
|
|
25
|
+
nav: "@max-[1280px]/page:static @max-[1280px]/page:flex-row @max-[1280px]/page:overflow-x-auto"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
self: {
|
|
29
|
+
720: {
|
|
30
|
+
grid: "@max-[720px]/settings:grid-cols-1",
|
|
31
|
+
nav: "@max-[720px]/settings:static @max-[720px]/settings:flex-row @max-[720px]/settings:overflow-x-auto"
|
|
32
|
+
},
|
|
33
|
+
940: {
|
|
34
|
+
grid: "@max-[940px]/settings:grid-cols-1",
|
|
35
|
+
nav: "@max-[940px]/settings:static @max-[940px]/settings:flex-row @max-[940px]/settings:overflow-x-auto"
|
|
36
|
+
},
|
|
37
|
+
1080: {
|
|
38
|
+
grid: "@max-[1080px]/settings:grid-cols-1",
|
|
39
|
+
nav: "@max-[1080px]/settings:static @max-[1080px]/settings:flex-row @max-[1080px]/settings:overflow-x-auto"
|
|
40
|
+
},
|
|
41
|
+
1280: {
|
|
42
|
+
grid: "@max-[1280px]/settings:grid-cols-1",
|
|
43
|
+
nav: "@max-[1280px]/settings:static @max-[1280px]/settings:flex-row @max-[1280px]/settings:overflow-x-auto"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function stackFor(config, part) {
|
|
48
|
+
return config.breakpoint === "never" ? void 0 : stackClasses[config.container][config.breakpoint][part];
|
|
49
|
+
}
|
|
50
|
+
function SettingsLayout({
|
|
51
|
+
breakpoint = 940,
|
|
52
|
+
container = "page",
|
|
53
|
+
className,
|
|
54
|
+
...props
|
|
55
|
+
}) {
|
|
56
|
+
const config = { breakpoint, container };
|
|
57
|
+
const grid = /* @__PURE__ */ jsx(
|
|
5
58
|
"div",
|
|
6
59
|
{
|
|
7
60
|
className: cn(
|
|
8
|
-
"grid grid-cols-[220px_minmax(0,1fr)] items-start gap-6
|
|
61
|
+
"grid grid-cols-[220px_minmax(0,1fr)] items-start gap-6",
|
|
62
|
+
stackFor(config, "grid"),
|
|
9
63
|
className
|
|
10
64
|
),
|
|
11
65
|
...props
|
|
12
66
|
}
|
|
13
67
|
);
|
|
68
|
+
return /* @__PURE__ */ jsx(SettingsLayoutContext, { value: config, children: container === "self" ? /* @__PURE__ */ jsx("div", { className: "@container/settings min-w-0", children: grid }) : grid });
|
|
14
69
|
}
|
|
15
70
|
function SettingsLayoutNav({
|
|
16
71
|
"aria-label": ariaLabel = "Sections",
|
|
72
|
+
breakpoint,
|
|
17
73
|
className,
|
|
18
74
|
...props
|
|
19
75
|
}) {
|
|
76
|
+
const inherited = use(SettingsLayoutContext);
|
|
77
|
+
const config = { ...inherited, breakpoint: breakpoint ?? inherited.breakpoint };
|
|
20
78
|
return /* @__PURE__ */ jsx(
|
|
21
79
|
"nav",
|
|
22
80
|
{
|
|
23
81
|
"aria-label": ariaLabel,
|
|
24
|
-
className: cn(
|
|
25
|
-
"sticky top-20 flex flex-col gap-px @max-[940px]/page:static @max-[940px]/page:flex-row @max-[940px]/page:overflow-x-auto",
|
|
26
|
-
className
|
|
27
|
-
),
|
|
82
|
+
className: cn("sticky top-20 flex flex-col gap-px", stackFor(config, "nav"), className),
|
|
28
83
|
...props
|
|
29
84
|
}
|
|
30
85
|
);
|
|
@@ -41,7 +96,7 @@ function SettingsLayoutNavItem({
|
|
|
41
96
|
type,
|
|
42
97
|
"aria-current": active ? "true" : void 0,
|
|
43
98
|
className: cn(
|
|
44
|
-
"flex shrink-0 items-center gap-2.5 rounded-control px-2.5 py-1.75 font-medium text-fs-130 text-ink-2 hover:bg-surface-2 hover:text-ink",
|
|
99
|
+
"flex min-h-(--touch-target) shrink-0 items-center gap-2.5 rounded-control px-2.5 py-1.75 font-medium text-fs-130 text-ink-2 hover:bg-surface-2 hover:text-ink",
|
|
45
100
|
active && "bg-accent-soft font-semibold text-accent-ink",
|
|
46
101
|
className
|
|
47
102
|
),
|
|
@@ -9,7 +9,7 @@ import { Slot } from "../../utils/slot.js";
|
|
|
9
9
|
function Shortcuts({ className, ...props }) {
|
|
10
10
|
return /* @__PURE__ */ jsx("ul", { className: cn("m-0 flex list-none flex-col gap-0.5 p-0", className), ...props });
|
|
11
11
|
}
|
|
12
|
-
const itemClasses = "flex min-h-control-sm w-full cursor-pointer items-center gap-2 rounded-button px-2 text-start text-fs-130 text-ink-2 no-underline hover:bg-surface-2 hover:text-ink focus-visible:focus-ring
|
|
12
|
+
const itemClasses = "flex min-h-control-sm w-full cursor-pointer items-center gap-2 rounded-button px-2 text-start text-fs-130 text-ink-2 no-underline hover:bg-surface-2 hover:text-ink focus-visible:focus-ring";
|
|
13
13
|
function ShortcutsItem({
|
|
14
14
|
icon,
|
|
15
15
|
kbd,
|