@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,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
type CSSProperties,
|
|
4
5
|
type KeyboardEvent,
|
|
5
6
|
type ReactNode,
|
|
6
7
|
type PointerEvent as ReactPointerEvent,
|
|
@@ -17,6 +18,7 @@ import type { ClassNames } from "../../utils/class-names.js";
|
|
|
17
18
|
import { cn } from "../../utils/cn.js";
|
|
18
19
|
import {
|
|
19
20
|
dropIndex,
|
|
21
|
+
dropIndexGrid,
|
|
20
22
|
type KanbanCardData,
|
|
21
23
|
type KanbanColumnData,
|
|
22
24
|
type KanbanKey,
|
|
@@ -37,6 +39,7 @@ export type KanbanPart =
|
|
|
37
39
|
| "cards"
|
|
38
40
|
| "card"
|
|
39
41
|
| "grip"
|
|
42
|
+
| "actions"
|
|
40
43
|
| "empty"
|
|
41
44
|
| "indicator"
|
|
42
45
|
| "ghost";
|
|
@@ -47,10 +50,31 @@ export interface KanbanProps {
|
|
|
47
50
|
defaultColumns?: KanbanColumnData[];
|
|
48
51
|
/** Called after a drop (pointer release or keyboard drop) with the new board and the move. */
|
|
49
52
|
onColumnsChange?: (columns: KanbanColumnData[], move: KanbanMove) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Set to `false` for a board that only displays: no drag handle, no pointer or keyboard
|
|
55
|
+
* pick-up, and cards are plain content (with `cardActions` still rendered). Defaults to `true`.
|
|
56
|
+
*/
|
|
57
|
+
draggable?: boolean;
|
|
50
58
|
/** Refuse drops into another column that already reached its WIP limit. */
|
|
51
59
|
enforceLimit?: boolean;
|
|
52
60
|
/** Replaces the default card body. */
|
|
53
61
|
renderCard?: (card: KanbanCardData) => ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* Buttons shown under each card. When set, the card is no longer one `role="button"`: its body
|
|
64
|
+
* is plain content, the actions are real, separately focusable controls, and keyboard
|
|
65
|
+
* pick-up moves to a grip button. Without it the card keeps the single-button behaviour.
|
|
66
|
+
*/
|
|
67
|
+
cardActions?: (card: KanbanCardData) => ReactNode;
|
|
68
|
+
/** Accessible name of the grip button when `cardActions` is set; defaults to "Mover tarjeta: <title>". */
|
|
69
|
+
gripLabel?: (card: KanbanCardData) => string;
|
|
70
|
+
/**
|
|
71
|
+
* Lays the cards of a lane out as a responsive grid once the lane is 30rem (480 px) wide,
|
|
72
|
+
* with columns of at least `cardGridMinWidth`; a narrower lane stays a single column. Dropping with the pointer
|
|
73
|
+
* follows reading order; arrow keys still move a held card one place up or down the lane.
|
|
74
|
+
*/
|
|
75
|
+
cardGrid?: boolean;
|
|
76
|
+
/** Minimum card width (px) of the grid lane. Defaults to 224. */
|
|
77
|
+
cardGridMinWidth?: number;
|
|
54
78
|
emptyLabel?: string;
|
|
55
79
|
"aria-label"?: string;
|
|
56
80
|
className?: string;
|
|
@@ -102,8 +126,13 @@ export function Kanban({
|
|
|
102
126
|
columns: controlled,
|
|
103
127
|
defaultColumns = [],
|
|
104
128
|
onColumnsChange,
|
|
129
|
+
draggable = true,
|
|
105
130
|
enforceLimit = false,
|
|
106
131
|
renderCard,
|
|
132
|
+
cardActions,
|
|
133
|
+
gripLabel = (card) => `Mover tarjeta: ${card.title}`,
|
|
134
|
+
cardGrid = false,
|
|
135
|
+
cardGridMinWidth = 224,
|
|
107
136
|
emptyLabel = "Sin tarjetas",
|
|
108
137
|
className,
|
|
109
138
|
classNames,
|
|
@@ -137,7 +166,8 @@ export function Kanban({
|
|
|
137
166
|
useLayoutEffect(() => {
|
|
138
167
|
const id = focusId.current;
|
|
139
168
|
if (!id) return;
|
|
140
|
-
const
|
|
169
|
+
const card = rootRef.current?.querySelector<HTMLElement>(`[data-card-id="${CSS.escape(id)}"]`);
|
|
170
|
+
const el = card?.querySelector<HTMLElement>("[data-card-grip]") ?? card;
|
|
141
171
|
if (el && document.activeElement !== el) el.focus();
|
|
142
172
|
if (!grabbedId) focusId.current = null;
|
|
143
173
|
});
|
|
@@ -196,6 +226,7 @@ export function Kanban({
|
|
|
196
226
|
|
|
197
227
|
const startPointerDrag = (event: ReactPointerEvent<HTMLElement>, card: KanbanCardData) => {
|
|
198
228
|
if (event.button !== 0 || grabbedId) return;
|
|
229
|
+
if ((event.target as HTMLElement).closest("[data-card-actions]")) return;
|
|
199
230
|
if (event.pointerType === "touch" && !(event.target as HTMLElement).closest("[data-grip]")) {
|
|
200
231
|
return;
|
|
201
232
|
}
|
|
@@ -210,12 +241,17 @@ export function Kanban({
|
|
|
210
241
|
const column = document.elementFromPoint(x, y)?.closest<HTMLElement>("[data-column-id]");
|
|
211
242
|
const columnId = column?.dataset.columnId;
|
|
212
243
|
if (!column || !columnId) return null;
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
244
|
+
const others = Array.from(column.querySelectorAll<HTMLElement>("[data-card-id]")).filter(
|
|
245
|
+
(el) => el.dataset.cardId !== card.id,
|
|
246
|
+
);
|
|
247
|
+
if (column.hasAttribute("data-card-grid")) {
|
|
248
|
+
const rects = others.map((el) => el.getBoundingClientRect());
|
|
249
|
+
return { columnId, index: dropIndexGrid(rects, x, y) };
|
|
250
|
+
}
|
|
251
|
+
const mids = others.map((el) => {
|
|
252
|
+
const r = el.getBoundingClientRect();
|
|
253
|
+
return r.top + r.height / 2;
|
|
254
|
+
});
|
|
219
255
|
return { columnId, index: dropIndex(mids, y) };
|
|
220
256
|
};
|
|
221
257
|
|
|
@@ -284,10 +320,12 @@ export function Kanban({
|
|
|
284
320
|
}
|
|
285
321
|
}}
|
|
286
322
|
>
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
323
|
+
{draggable ? (
|
|
324
|
+
<p id={instructionsId} className="sr-only">
|
|
325
|
+
Presiona Espacio para tomar una tarjeta, las flechas para moverla y Espacio para soltarla.
|
|
326
|
+
Escape cancela.
|
|
327
|
+
</p>
|
|
328
|
+
) : null}
|
|
291
329
|
<div role="status" aria-live="assertive" className="sr-only">
|
|
292
330
|
{status}
|
|
293
331
|
</div>
|
|
@@ -322,37 +360,98 @@ export function Kanban({
|
|
|
322
360
|
const grabbed = grabbedId === card.id;
|
|
323
361
|
items.push(
|
|
324
362
|
<li key={card.id} className="min-w-0">
|
|
325
|
-
{
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
363
|
+
{cardActions ? (
|
|
364
|
+
<div
|
|
365
|
+
data-card-id={card.id}
|
|
366
|
+
onPointerDown={(e) => {
|
|
367
|
+
if (draggable) startPointerDrag(e, card);
|
|
368
|
+
}}
|
|
369
|
+
className={cn(
|
|
370
|
+
"relative flex flex-col gap-density-sm rounded-input border-card surface-card p-density shadow-card",
|
|
371
|
+
draggable && "cursor-grab select-none",
|
|
372
|
+
isDragged && "opacity-40",
|
|
373
|
+
grabbed && "shadow-selected",
|
|
374
|
+
classNames?.card,
|
|
375
|
+
)}
|
|
376
|
+
>
|
|
377
|
+
<div className="flex gap-1">
|
|
378
|
+
{draggable ? (
|
|
379
|
+
<button
|
|
380
|
+
type="button"
|
|
381
|
+
data-card-grip=""
|
|
382
|
+
data-grip=""
|
|
383
|
+
aria-label={gripLabel(card)}
|
|
384
|
+
aria-pressed={grabbed}
|
|
385
|
+
aria-roledescription="tarjeta arrastrable"
|
|
386
|
+
aria-describedby={instructionsId}
|
|
387
|
+
onKeyDown={(e) => onCardKeyDown(e, card)}
|
|
388
|
+
className={cn(
|
|
389
|
+
"-ml-1 flex min-h-8 w-6 shrink-0 touch-none items-start justify-center rounded-control pt-0.5 text-ink-3 focus-visible:focus-ring",
|
|
390
|
+
classNames?.grip,
|
|
391
|
+
)}
|
|
392
|
+
>
|
|
393
|
+
<GripVertical aria-hidden="true" className="size-4" />
|
|
394
|
+
</button>
|
|
395
|
+
) : null}
|
|
396
|
+
<div className="min-w-0 flex-1">
|
|
397
|
+
{renderCard ? renderCard(card) : <DefaultCard card={card} />}
|
|
398
|
+
</div>
|
|
399
|
+
</div>
|
|
400
|
+
<div
|
|
401
|
+
data-card-actions=""
|
|
402
|
+
className={cn(
|
|
403
|
+
"flex cursor-auto flex-wrap items-center gap-density-sm",
|
|
404
|
+
classNames?.actions,
|
|
405
|
+
)}
|
|
406
|
+
>
|
|
407
|
+
{cardActions(card)}
|
|
408
|
+
</div>
|
|
409
|
+
</div>
|
|
410
|
+
) : draggable ? (
|
|
411
|
+
// biome-ignore lint/a11y/useSemanticElements: draggable card is a custom widget
|
|
412
|
+
<div
|
|
413
|
+
role="button"
|
|
414
|
+
tabIndex={0}
|
|
415
|
+
data-card-id={card.id}
|
|
416
|
+
aria-pressed={grabbed}
|
|
417
|
+
aria-roledescription="tarjeta arrastrable"
|
|
418
|
+
aria-describedby={instructionsId}
|
|
419
|
+
onKeyDown={(e) => onCardKeyDown(e, card)}
|
|
420
|
+
onPointerDown={(e) => startPointerDrag(e, card)}
|
|
421
|
+
className={cn(
|
|
422
|
+
"pressable relative flex cursor-grab select-none gap-1 rounded-input border-card surface-card p-density shadow-card focus-visible:focus-ring",
|
|
423
|
+
isDragged && "opacity-40",
|
|
424
|
+
grabbed && "shadow-selected",
|
|
425
|
+
classNames?.card,
|
|
426
|
+
)}
|
|
427
|
+
>
|
|
428
|
+
<span
|
|
429
|
+
data-grip=""
|
|
430
|
+
aria-hidden="true"
|
|
431
|
+
className={cn(
|
|
432
|
+
"-ml-1 flex w-4 shrink-0 touch-none items-start pt-0.5 text-ink-3",
|
|
433
|
+
classNames?.grip,
|
|
434
|
+
)}
|
|
435
|
+
>
|
|
436
|
+
<GripVertical className="size-4" />
|
|
437
|
+
</span>
|
|
438
|
+
<div className="min-w-0 flex-1">
|
|
439
|
+
{renderCard ? renderCard(card) : <DefaultCard card={card} />}
|
|
440
|
+
</div>
|
|
441
|
+
</div>
|
|
442
|
+
) : (
|
|
443
|
+
<div
|
|
444
|
+
data-card-id={card.id}
|
|
345
445
|
className={cn(
|
|
346
|
-
"
|
|
347
|
-
classNames?.
|
|
446
|
+
"relative flex gap-1 rounded-input border-card surface-card p-density shadow-card",
|
|
447
|
+
classNames?.card,
|
|
348
448
|
)}
|
|
349
449
|
>
|
|
350
|
-
<
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
{renderCard ? renderCard(card) : <DefaultCard card={card} />}
|
|
450
|
+
<div className="min-w-0 flex-1">
|
|
451
|
+
{renderCard ? renderCard(card) : <DefaultCard card={card} />}
|
|
452
|
+
</div>
|
|
354
453
|
</div>
|
|
355
|
-
|
|
454
|
+
)}
|
|
356
455
|
</li>,
|
|
357
456
|
);
|
|
358
457
|
}
|
|
@@ -362,9 +461,10 @@ export function Kanban({
|
|
|
362
461
|
<section
|
|
363
462
|
key={column.id}
|
|
364
463
|
data-column-id={column.id}
|
|
464
|
+
data-card-grid={cardGrid ? "" : undefined}
|
|
365
465
|
aria-label={column.title}
|
|
366
466
|
className={cn(
|
|
367
|
-
"flex w-[min(18rem,85cqw)] shrink-0 snap-start flex-col gap-density-sm rounded-card bg-surface-sunken p-density-sm @4xl/kanban:w-auto @4xl/kanban:min-w-56 @4xl/kanban:flex-1",
|
|
467
|
+
"@container/lane flex w-[min(18rem,85cqw)] shrink-0 snap-start flex-col gap-density-sm rounded-card bg-surface-sunken p-density-sm @4xl/kanban:w-auto @4xl/kanban:min-w-56 @4xl/kanban:flex-1",
|
|
368
468
|
classNames?.column,
|
|
369
469
|
)}
|
|
370
470
|
>
|
|
@@ -397,8 +497,15 @@ export function Kanban({
|
|
|
397
497
|
</Chip>
|
|
398
498
|
</header>
|
|
399
499
|
<ul
|
|
500
|
+
style={
|
|
501
|
+
cardGrid
|
|
502
|
+
? ({ "--lane-card-min": `${cardGridMinWidth}px` } as CSSProperties)
|
|
503
|
+
: undefined
|
|
504
|
+
}
|
|
400
505
|
className={cn(
|
|
401
506
|
"m-0 flex min-h-16 list-none flex-col gap-density-sm p-0",
|
|
507
|
+
cardGrid &&
|
|
508
|
+
"@min-[30rem]/lane:grid @min-[30rem]/lane:grid-cols-[repeat(auto-fill,minmax(var(--lane-card-min),1fr))] @min-[30rem]/lane:items-start",
|
|
402
509
|
classNames?.cards,
|
|
403
510
|
)}
|
|
404
511
|
>
|
|
@@ -139,3 +139,23 @@ export function dropIndex(midpoints: number[], y: number): number {
|
|
|
139
139
|
}
|
|
140
140
|
return index;
|
|
141
141
|
}
|
|
142
|
+
|
|
143
|
+
export interface CardRect {
|
|
144
|
+
left: number;
|
|
145
|
+
right: number;
|
|
146
|
+
top: number;
|
|
147
|
+
bottom: number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Insert index for a pointer at (`x`, `y`) over a lane that lays its cards out as a grid, from the
|
|
152
|
+
* rectangles of the cards left in the lane in reading order: a card is passed when the pointer is
|
|
153
|
+
* below its row, or inside its row and past its horizontal midpoint.
|
|
154
|
+
*/
|
|
155
|
+
export function dropIndexGrid(rects: CardRect[], x: number, y: number): number {
|
|
156
|
+
let index = 0;
|
|
157
|
+
for (const rect of rects) {
|
|
158
|
+
if (y > rect.bottom || (y >= rect.top && x > (rect.left + rect.right) / 2)) index += 1;
|
|
159
|
+
}
|
|
160
|
+
return index;
|
|
161
|
+
}
|
|
@@ -165,7 +165,7 @@ export function KpiValue({ suffix, trend, mono, className, children, ...props }:
|
|
|
165
165
|
<span
|
|
166
166
|
{...props}
|
|
167
167
|
className={cn(
|
|
168
|
-
"break-words text-kpi-number tabular-nums @max-[9rem]/kpi:text-fs-
|
|
168
|
+
"break-words text-kpi-number tabular-nums @max-[9rem]/kpi:text-fs-200",
|
|
169
169
|
mono && "font-mono tracking-normal",
|
|
170
170
|
valueTone,
|
|
171
171
|
classNames?.value,
|
|
@@ -32,6 +32,11 @@ export interface KpiGroupProps extends Omit<ComponentPropsWithoutRef<"dl">, "chi
|
|
|
32
32
|
layout?: KpiGroupLayout;
|
|
33
33
|
/** Minimum tile width in px for `layout="auto-fit"`. */
|
|
34
34
|
minItemWidth?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Columns on the narrowest containers. `1` (default) stacks the tiles; `2` keeps two across
|
|
37
|
+
* (and `auto-fit` never goes below two) for short tiles on a phone.
|
|
38
|
+
*/
|
|
39
|
+
minColumns?: 1 | 2;
|
|
35
40
|
/** Animate numeric values counting up. */
|
|
36
41
|
animate?: boolean;
|
|
37
42
|
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root wrapper and is merged last. */
|
|
@@ -46,6 +51,7 @@ export function KpiGroup({
|
|
|
46
51
|
items,
|
|
47
52
|
layout = "divided",
|
|
48
53
|
minItemWidth = 150,
|
|
54
|
+
minColumns = 1,
|
|
49
55
|
animate = true,
|
|
50
56
|
className,
|
|
51
57
|
classNames,
|
|
@@ -60,7 +66,11 @@ export function KpiGroup({
|
|
|
60
66
|
style={
|
|
61
67
|
autoFit
|
|
62
68
|
? {
|
|
63
|
-
gridTemplateColumns: `repeat(auto-fit, minmax(min(
|
|
69
|
+
gridTemplateColumns: `repeat(auto-fit, minmax(min(${
|
|
70
|
+
minColumns === 2
|
|
71
|
+
? `${minItemWidth}px, calc((100% - var(--gap-density)) / 2)`
|
|
72
|
+
: `100%, ${minItemWidth}px`
|
|
73
|
+
}), 1fr))`,
|
|
64
74
|
...style,
|
|
65
75
|
}
|
|
66
76
|
: style
|
|
@@ -69,7 +79,12 @@ export function KpiGroup({
|
|
|
69
79
|
"m-0 grid",
|
|
70
80
|
autoFit
|
|
71
81
|
? "gap-density"
|
|
72
|
-
:
|
|
82
|
+
: cn(
|
|
83
|
+
"gap-px overflow-hidden rounded-card border-card bg-divider shadow-card @sm/kpi-group:grid-cols-2 @3xl/kpi-group:grid-cols-4",
|
|
84
|
+
minColumns === 2
|
|
85
|
+
? "grid-cols-2 @max-sm/kpi-group:[&>:last-child:nth-child(odd)]:col-span-2"
|
|
86
|
+
: "grid-cols-1",
|
|
87
|
+
),
|
|
73
88
|
classNames?.list,
|
|
74
89
|
)}
|
|
75
90
|
>
|
|
@@ -4,12 +4,17 @@ export {
|
|
|
4
4
|
ListDetailDetailHeader,
|
|
5
5
|
type ListDetailDetailHeaderProps,
|
|
6
6
|
type ListDetailDetailProps,
|
|
7
|
+
ListDetailEmpty,
|
|
8
|
+
type ListDetailEmptyProps,
|
|
9
|
+
ListDetailHeader,
|
|
10
|
+
type ListDetailHeaderProps,
|
|
7
11
|
ListDetailItem,
|
|
8
12
|
type ListDetailItemProps,
|
|
9
13
|
ListDetailList,
|
|
10
14
|
type ListDetailListProps,
|
|
11
15
|
ListDetailMeta,
|
|
12
16
|
type ListDetailProps,
|
|
17
|
+
type ListDetailRatio,
|
|
13
18
|
ListDetailTitle,
|
|
14
19
|
useListDetail,
|
|
15
20
|
} from "./list-detail.js";
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
type ComponentPropsWithoutRef,
|
|
5
|
+
type CSSProperties,
|
|
5
6
|
createContext,
|
|
6
7
|
type ReactNode,
|
|
7
8
|
useCallback,
|
|
@@ -39,6 +40,22 @@ export function useListDetail() {
|
|
|
39
40
|
return { value, select, isSelected: (candidate: string) => candidate === value };
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
/** List-to-detail width ratio when `listWidth` is not set: `1:1` (default), `1:2` or `1:3`. */
|
|
44
|
+
export type ListDetailRatio = "1:1" | "1:2" | "1:3";
|
|
45
|
+
|
|
46
|
+
const ratioClasses: Record<ListDetailRatio, string> = {
|
|
47
|
+
"1:1": "@min-[641px]/list-detail:grid-cols-2",
|
|
48
|
+
"1:2": "@min-[641px]/list-detail:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",
|
|
49
|
+
"1:3": "@min-[641px]/list-detail:grid-cols-[minmax(0,1fr)_minmax(0,3fr)]",
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const FIXED_LIST_COLUMNS =
|
|
53
|
+
"@min-[641px]/list-detail:grid-cols-[minmax(0,var(--ld-list-width))_minmax(0,1fr)]";
|
|
54
|
+
|
|
55
|
+
function cssLength(value: number | string): string {
|
|
56
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
57
|
+
}
|
|
58
|
+
|
|
42
59
|
export interface ListDetailProps
|
|
43
60
|
extends Omit<ComponentPropsWithoutRef<"div">, "defaultValue" | "onChange"> {
|
|
44
61
|
/** Controlled selected item id; `null` means none (the single-pane view then shows the list). */
|
|
@@ -56,6 +73,26 @@ export interface ListDetailProps
|
|
|
56
73
|
onBack?: (() => void) | undefined;
|
|
57
74
|
/** Names the list of items. */
|
|
58
75
|
"aria-label": string;
|
|
76
|
+
/**
|
|
77
|
+
* Fixed width of the list column beside the detail, from 641px of the component's own width: a
|
|
78
|
+
* number is pixels, a string any CSS length (`"20rem"`). A rail of 280-360px reads better than
|
|
79
|
+
* an even split for most catalogues. Wins over `ratio`.
|
|
80
|
+
*/
|
|
81
|
+
listWidth?: number | string | undefined;
|
|
82
|
+
/** Proportional split when `listWidth` is not set. Defaults to `"1:1"` (the original even split). */
|
|
83
|
+
ratio?: ListDetailRatio | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* `"flat"` (default) keeps the panes flush with a divider between them. `"card"` draws each pane
|
|
86
|
+
* as a raised card with a gap between them.
|
|
87
|
+
*/
|
|
88
|
+
surface?: "flat" | "card" | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Keeps the list column in view while the page scrolls and gives it its own scroll, from 641px
|
|
91
|
+
* of the component's own width. The list header stays at the top of the column.
|
|
92
|
+
*/
|
|
93
|
+
stickyList?: boolean | undefined;
|
|
94
|
+
/** Distance the sticky list keeps from the top of its scroll container (number = pixels). Default `0`. */
|
|
95
|
+
stickyOffset?: number | string | undefined;
|
|
59
96
|
children: ReactNode;
|
|
60
97
|
}
|
|
61
98
|
|
|
@@ -70,7 +107,13 @@ export function ListDetail({
|
|
|
70
107
|
onValueChange,
|
|
71
108
|
onBack,
|
|
72
109
|
"aria-label": label,
|
|
110
|
+
listWidth,
|
|
111
|
+
ratio = "1:1",
|
|
112
|
+
surface = "flat",
|
|
113
|
+
stickyList = false,
|
|
114
|
+
stickyOffset,
|
|
73
115
|
className,
|
|
116
|
+
style,
|
|
74
117
|
children,
|
|
75
118
|
...props
|
|
76
119
|
}: ListDetailProps) {
|
|
@@ -112,12 +155,27 @@ export function ListDetail({
|
|
|
112
155
|
|
|
113
156
|
return (
|
|
114
157
|
<ListDetailContext.Provider value={context}>
|
|
115
|
-
<div
|
|
158
|
+
<div
|
|
159
|
+
{...props}
|
|
160
|
+
ref={rootRef}
|
|
161
|
+
className={cn("@container/list-detail min-w-0", className)}
|
|
162
|
+
style={
|
|
163
|
+
{
|
|
164
|
+
...style,
|
|
165
|
+
...(listWidth !== undefined ? { "--ld-list-width": cssLength(listWidth) } : null),
|
|
166
|
+
...(stickyOffset !== undefined ? { "--ld-sticky-top": cssLength(stickyOffset) } : null),
|
|
167
|
+
} as CSSProperties
|
|
168
|
+
}
|
|
169
|
+
>
|
|
116
170
|
<div
|
|
117
171
|
data-view={value === null ? "list" : "detail"}
|
|
172
|
+
data-surface={surface}
|
|
173
|
+
data-sticky-list={stickyList ? "" : undefined}
|
|
118
174
|
className={cn(
|
|
119
|
-
"group/ld grid grid-cols-1
|
|
120
|
-
"
|
|
175
|
+
"group/ld grid grid-cols-1",
|
|
176
|
+
surface === "flat" && "border-t-divider",
|
|
177
|
+
listWidth !== undefined ? FIXED_LIST_COLUMNS : ratioClasses[ratio],
|
|
178
|
+
surface === "card" && "@min-[641px]/list-detail:gap-4",
|
|
121
179
|
"[&>*]:min-w-0",
|
|
122
180
|
)}
|
|
123
181
|
>
|
|
@@ -128,22 +186,65 @@ export function ListDetail({
|
|
|
128
186
|
);
|
|
129
187
|
}
|
|
130
188
|
|
|
131
|
-
export
|
|
189
|
+
export interface ListDetailListProps extends Omit<ComponentPropsWithoutRef<"ul">, "aria-label"> {
|
|
190
|
+
/** Sits above the items and stays put while they scroll: a `ListDetailHeader` with search, filters and a count. */
|
|
191
|
+
header?: ReactNode;
|
|
192
|
+
}
|
|
132
193
|
|
|
133
|
-
|
|
194
|
+
/**
|
|
195
|
+
* The list column: an optional `header` above the item list. The `ul` is named by the
|
|
196
|
+
* `ListDetail`'s `aria-label`; `className` and the other props go to it.
|
|
197
|
+
*/
|
|
198
|
+
export function ListDetailList({ header, className, ...props }: ListDetailListProps) {
|
|
134
199
|
const { label } = useListDetailContext("ListDetailList");
|
|
135
200
|
return (
|
|
136
|
-
<
|
|
201
|
+
<div
|
|
137
202
|
data-list-detail-pane="list"
|
|
138
|
-
aria-label={label}
|
|
139
203
|
className={cn(
|
|
140
|
-
"
|
|
204
|
+
"flex min-h-0 min-w-0 flex-col",
|
|
141
205
|
"@min-[641px]/list-detail:border-r-divider",
|
|
142
206
|
"group-data-[view=detail]/ld:@max-[640px]/list-detail:hidden",
|
|
207
|
+
"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",
|
|
208
|
+
"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",
|
|
209
|
+
)}
|
|
210
|
+
>
|
|
211
|
+
{header}
|
|
212
|
+
<ul
|
|
213
|
+
aria-label={label}
|
|
214
|
+
className={cn(
|
|
215
|
+
"m-0 flex min-h-0 list-none flex-col p-0",
|
|
216
|
+
"group-data-[sticky-list]/ld:@min-[641px]/list-detail:overflow-y-auto",
|
|
217
|
+
"group-data-[surface=card]/ld:p-2",
|
|
218
|
+
className,
|
|
219
|
+
)}
|
|
220
|
+
{...props}
|
|
221
|
+
/>
|
|
222
|
+
</div>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface ListDetailHeaderProps extends ComponentPropsWithoutRef<"div"> {
|
|
227
|
+
/** End slot showing how many items match, e.g. `12`. Announced politely when it changes. */
|
|
228
|
+
count?: ReactNode;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** Controls row of the list column: a search field, filter chips and a result count. */
|
|
232
|
+
export function ListDetailHeader({ count, className, children, ...props }: ListDetailHeaderProps) {
|
|
233
|
+
return (
|
|
234
|
+
<div
|
|
235
|
+
className={cn(
|
|
236
|
+
"flex shrink-0 flex-wrap items-center gap-2 border-b-divider py-2.5 group-data-[surface=card]/ld:px-3",
|
|
143
237
|
className,
|
|
144
238
|
)}
|
|
145
239
|
{...props}
|
|
146
|
-
|
|
240
|
+
>
|
|
241
|
+
{children}
|
|
242
|
+
{count !== undefined ? (
|
|
243
|
+
<span aria-live="polite" className="ml-auto text-count text-ink-3">
|
|
244
|
+
{count}
|
|
245
|
+
</span>
|
|
246
|
+
) : null}
|
|
247
|
+
</div>
|
|
147
248
|
);
|
|
148
249
|
}
|
|
149
250
|
|
|
@@ -172,6 +273,7 @@ export function ListDetailItem({
|
|
|
172
273
|
onClick={composeHandlers(onClick, () => select(value))}
|
|
173
274
|
className={cn(
|
|
174
275
|
"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",
|
|
276
|
+
"group-data-[surface=card]/ld:rounded-button group-data-[surface=card]/ld:border-b-0 group-data-[surface=card]/ld:px-3",
|
|
175
277
|
className,
|
|
176
278
|
)}
|
|
177
279
|
{...props}
|
|
@@ -234,6 +336,7 @@ export function ListDetailDetail({
|
|
|
234
336
|
className={cn(
|
|
235
337
|
"flex min-w-0 flex-col outline-none",
|
|
236
338
|
"group-data-[view=list]/ld:@max-[640px]/list-detail:hidden",
|
|
339
|
+
"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",
|
|
237
340
|
className,
|
|
238
341
|
)}
|
|
239
342
|
>
|
|
@@ -291,3 +394,48 @@ export function ListDetailDetailHeader({
|
|
|
291
394
|
</div>
|
|
292
395
|
);
|
|
293
396
|
}
|
|
397
|
+
|
|
398
|
+
export interface ListDetailEmptyProps extends Omit<ComponentPropsWithoutRef<"div">, "title"> {
|
|
399
|
+
/** Decorative icon; hidden from screen readers. */
|
|
400
|
+
icon?: ReactNode;
|
|
401
|
+
title: ReactNode;
|
|
402
|
+
description?: ReactNode;
|
|
403
|
+
/** Call to action under the text. */
|
|
404
|
+
action?: ReactNode;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Placeholder for the detail pane while nothing is selected ("Choose an item"). Render it inside
|
|
409
|
+
* `ListDetailDetail`; it renders nothing once an item is selected, so it needs no condition.
|
|
410
|
+
*/
|
|
411
|
+
export function ListDetailEmpty({
|
|
412
|
+
icon,
|
|
413
|
+
title,
|
|
414
|
+
description,
|
|
415
|
+
action,
|
|
416
|
+
className,
|
|
417
|
+
...props
|
|
418
|
+
}: ListDetailEmptyProps) {
|
|
419
|
+
const { value } = useListDetailContext("ListDetailEmpty");
|
|
420
|
+
if (value !== null) return null;
|
|
421
|
+
return (
|
|
422
|
+
<div
|
|
423
|
+
className={cn(
|
|
424
|
+
"flex min-h-64 flex-1 flex-col items-center justify-center gap-2 px-6 py-12 text-center",
|
|
425
|
+
className,
|
|
426
|
+
)}
|
|
427
|
+
{...props}
|
|
428
|
+
>
|
|
429
|
+
{icon !== undefined ? (
|
|
430
|
+
<span aria-hidden="true" className="inline-flex text-ink-3 [&_svg]:size-8">
|
|
431
|
+
{icon}
|
|
432
|
+
</span>
|
|
433
|
+
) : null}
|
|
434
|
+
<p className="m-0 font-semibold text-ink text-row-title">{title}</p>
|
|
435
|
+
{description !== undefined ? (
|
|
436
|
+
<p className="m-0 max-w-[44ch] text-ink-3 text-meta">{description}</p>
|
|
437
|
+
) : null}
|
|
438
|
+
{action !== undefined ? <div className="mt-2">{action}</div> : null}
|
|
439
|
+
</div>
|
|
440
|
+
);
|
|
441
|
+
}
|