@jcsoftdev/ui 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +361 -0
- package/README.md +31 -5
- package/bin/ui-theme.mjs +40 -6
- package/dist/ai/code-block/code-block.js +1 -1
- package/dist/atoms/avatar/avatar.d.ts +6 -1
- package/dist/atoms/avatar/avatar.js +3 -2
- package/dist/atoms/big-date/big-date.js +2 -2
- package/dist/atoms/button/button.d.ts +6 -1
- package/dist/atoms/button/button.js +2 -2
- package/dist/atoms/chip/chip.d.ts +5 -0
- package/dist/atoms/chip/chip.js +3 -3
- package/dist/atoms/icon-button/icon-button.js +1 -1
- package/dist/atoms/internal/hit-area.d.ts +5 -4
- package/dist/atoms/internal/hit-area.js +1 -1
- package/dist/atoms/progress/index.d.ts +1 -1
- package/dist/atoms/progress/index.js +4 -1
- package/dist/atoms/progress/progress.d.ts +6 -1
- package/dist/atoms/progress/progress.js +19 -1
- package/dist/atoms/radio-group/radio-group.js +1 -1
- package/dist/atoms/status-pill/status-pill.d.ts +16 -5
- package/dist/atoms/status-pill/status-pill.js +43 -18
- package/dist/brand/logo-forge.js +1 -1
- package/dist/charts/candlestick-chart/candlestick-chart.js +2 -2
- package/dist/charts/chart-grid/chart-grid.js +2 -2
- package/dist/charts/chord-chart/chord-chart.js +1 -1
- package/dist/charts/core/axes.js +2 -2
- package/dist/charts/core/cartesian/annotations.js +2 -2
- package/dist/charts/core/cartesian/marks.js +1 -1
- package/dist/charts/core/distribution/marks.js +1 -1
- package/dist/charts/core/distribution/xy-points.js +1 -1
- package/dist/charts/core/export-menu.js +1 -1
- package/dist/charts/funnel-chart/funnel-chart.js +1 -1
- package/dist/charts/gantt-chart/gantt-chart.js +4 -4
- package/dist/charts/gantt-chart/gantt-marks.js +3 -3
- package/dist/charts/index.d.ts +2 -0
- package/dist/charts/index.js +2 -0
- package/dist/charts/maps/geo/map-data-table.js +1 -1
- package/dist/charts/polar-area-chart/polar-area-chart.js +1 -1
- package/dist/charts/radar-chart/radar-chart.js +1 -1
- package/dist/charts/stock-chart/stock-chart.js +1 -1
- package/dist/charts/stock-chart/stock-drawing-layer.js +3 -3
- package/dist/charts/stock-chart/stock-plot.js +2 -2
- package/dist/containers/chat-thread/chat-thread.d.ts +98 -0
- package/dist/containers/chat-thread/chat-thread.js +219 -0
- package/dist/containers/chat-thread/format.d.ts +20 -0
- package/dist/containers/chat-thread/format.js +50 -0
- package/dist/containers/chat-thread/index.d.ts +1 -0
- package/dist/containers/chat-thread/index.js +8 -0
- package/dist/containers/cols/cols.d.ts +1 -1
- package/dist/containers/cols/cols.js +7 -0
- package/dist/containers/comment/comment.js +1 -1
- package/dist/containers/context-rail/context-rail.d.ts +62 -0
- package/dist/containers/context-rail/context-rail.js +175 -0
- package/dist/containers/context-rail/index.d.ts +1 -0
- package/dist/containers/context-rail/index.js +6 -0
- package/dist/containers/dashboard/dashboard.d.ts +40 -0
- package/dist/containers/dashboard/dashboard.js +84 -0
- package/dist/containers/dashboard/index.d.ts +1 -0
- package/dist/containers/dashboard/index.js +14 -0
- package/dist/containers/data-grid/data-grid.demos.js +4 -4
- package/dist/containers/data-grid/data-grid.js +6 -6
- package/dist/containers/data-grid/filter-builder-editor.js +2 -2
- package/dist/containers/data-grid/grid-toolbar.js +1 -1
- package/dist/containers/data-grid/spreadsheet.demos.d.ts +1 -1
- package/dist/containers/data-grid/spreadsheet.demos.js +1 -1
- package/dist/containers/detail-header/detail-header.d.ts +24 -0
- package/dist/containers/detail-header/detail-header.js +32 -0
- package/dist/containers/detail-header/index.d.ts +1 -0
- package/dist/containers/detail-header/index.js +6 -0
- package/dist/containers/facts/facts.js +1 -1
- package/dist/containers/filter-bar/filter-bar.d.ts +58 -0
- package/dist/containers/filter-bar/filter-bar.js +123 -0
- package/dist/containers/filter-bar/index.d.ts +1 -0
- package/dist/containers/filter-bar/index.js +6 -0
- package/dist/containers/hbars/hbars.js +2 -2
- package/dist/containers/index.d.ts +9 -0
- package/dist/containers/index.js +9 -0
- package/dist/containers/kanban/kanban.d.ts +23 -2
- package/dist/containers/kanban/kanban.js +103 -21
- package/dist/containers/kanban/model.d.ts +12 -0
- package/dist/containers/kanban/model.js +8 -0
- package/dist/containers/kpi/kpi.js +1 -1
- package/dist/containers/kpi-group/kpi-group.d.ts +6 -1
- package/dist/containers/kpi-group/kpi-group.js +6 -2
- package/dist/containers/list-detail/index.d.ts +1 -1
- package/dist/containers/list-detail/index.js +4 -0
- package/dist/containers/list-detail/list-detail.d.ts +51 -3
- package/dist/containers/list-detail/list-detail.js +111 -15
- package/dist/containers/page/page.d.ts +17 -4
- package/dist/containers/page/page.js +33 -4
- package/dist/containers/page-header/back.d.ts +10 -0
- package/dist/containers/page-header/back.js +28 -0
- package/dist/containers/page-header/index.d.ts +1 -0
- package/dist/containers/page-header/index.js +1 -0
- package/dist/containers/page-header/page-header.d.ts +19 -2
- package/dist/containers/page-header/page-header.js +26 -2
- package/dist/containers/pagination/cursor-pagination.d.ts +28 -0
- package/dist/containers/pagination/cursor-pagination.js +48 -0
- package/dist/containers/pagination/index.d.ts +3 -0
- package/dist/containers/pagination/index.js +10 -0
- package/dist/containers/pagination/pagination.d.ts +52 -0
- package/dist/containers/pagination/pagination.js +216 -0
- package/dist/containers/pagination/range.d.ts +29 -0
- package/dist/containers/pagination/range.js +42 -0
- package/dist/containers/pagination/use-pagination.d.ts +18 -0
- package/dist/containers/pagination/use-pagination.js +22 -0
- package/dist/containers/responsive-list/responsive-list.d.ts +29 -3
- package/dist/containers/responsive-list/responsive-list.js +202 -82
- package/dist/containers/row-actions/index.d.ts +1 -0
- package/dist/containers/row-actions/index.js +4 -0
- package/dist/containers/row-actions/row-actions.d.ts +26 -0
- package/dist/containers/row-actions/row-actions.js +78 -0
- package/dist/containers/selectable-card/index.d.ts +1 -0
- package/dist/containers/selectable-card/index.js +6 -0
- package/dist/containers/selectable-card/selectable-card.d.ts +26 -0
- package/dist/containers/selectable-card/selectable-card.js +57 -0
- package/dist/containers/settings-layout/settings-layout.d.ts +24 -7
- package/dist/containers/settings-layout/settings-layout.js +63 -8
- package/dist/containers/shortcuts/shortcuts.js +1 -1
- package/dist/containers/table/cell-padding.d.ts +2 -0
- package/dist/containers/table/cell-padding.js +4 -0
- package/dist/containers/table/index.d.ts +1 -0
- package/dist/containers/table/index.js +8 -0
- package/dist/containers/table/sort.d.ts +14 -0
- package/dist/containers/table/sort.js +11 -0
- package/dist/containers/table/table-parts.d.ts +24 -0
- package/dist/containers/table/table-parts.js +52 -0
- package/dist/containers/table/table.d.ts +37 -3
- package/dist/containers/table/table.js +120 -19
- package/dist/containers/table-columns-menu/index.d.ts +1 -0
- package/dist/containers/table-columns-menu/index.js +6 -0
- package/dist/containers/table-columns-menu/table-columns-menu.d.ts +14 -0
- package/dist/containers/table-columns-menu/table-columns-menu.js +46 -0
- package/dist/dashboards/layout.d.ts +1 -27
- package/dist/dashboards/layout.js +8 -40
- package/dist/forms/chip-group/chip-group.d.ts +5 -0
- package/dist/forms/chip-group/chip-group.js +3 -1
- package/dist/forms/combobox/combobox.js +1 -1
- package/dist/forms/copy-field/copy-field.js +1 -1
- package/dist/forms/date-picker/date-picker.d.ts +3 -1
- package/dist/forms/date-picker/date-picker.js +4 -2
- package/dist/forms/date-picker/date-time-picker.d.ts +8 -2
- package/dist/forms/date-picker/date-time-picker.js +13 -2
- package/dist/forms/field/field.d.ts +9 -2
- package/dist/forms/field/field.js +18 -4
- package/dist/forms/fieldset/fieldset.d.ts +11 -0
- package/dist/forms/fieldset/fieldset.js +12 -0
- package/dist/forms/fieldset/index.d.ts +1 -0
- package/dist/forms/fieldset/index.js +4 -0
- package/dist/forms/form-footer/form-footer.d.ts +26 -0
- package/dist/forms/form-footer/form-footer.js +44 -0
- package/dist/forms/form-footer/index.d.ts +1 -0
- package/dist/forms/form-footer/index.js +4 -0
- package/dist/forms/form-grid/form-grid.d.ts +21 -4
- package/dist/forms/form-grid/form-grid.js +20 -3
- package/dist/forms/form-grid/index.d.ts +1 -1
- package/dist/forms/form-grid/index.js +6 -2
- package/dist/forms/form-section/form-section.d.ts +12 -0
- package/dist/forms/form-section/form-section.js +30 -0
- package/dist/forms/form-section/index.d.ts +1 -0
- package/dist/forms/form-section/index.js +4 -0
- package/dist/forms/index.d.ts +3 -0
- package/dist/forms/index.js +3 -0
- package/dist/forms/input/input.d.ts +6 -2
- package/dist/forms/input/input.js +4 -1
- package/dist/forms/internal/listbox-items.d.ts +1 -1
- package/dist/forms/internal/listbox-items.js +3 -2
- package/dist/forms/native-select/native-select.js +1 -1
- package/dist/forms/number-stepper/index.d.ts +1 -1
- package/dist/forms/number-stepper/number-stepper.d.ts +7 -0
- package/dist/forms/number-stepper/number-stepper.js +37 -6
- package/dist/forms/select/index.d.ts +1 -1
- package/dist/forms/select/select.d.ts +5 -2
- package/dist/forms/select/select.js +7 -2
- package/dist/forms/select-menu/select-menu.js +1 -1
- package/dist/forms/time-input/time-input.d.ts +4 -2
- package/dist/forms/time-input/time-input.js +3 -1
- package/dist/i18n/strings.d.ts +94 -0
- package/dist/i18n/strings.js +50 -0
- package/dist/motion/count-up.d.ts +20 -0
- package/dist/motion/count-up.js +59 -0
- package/dist/motion/cross-fade.d.ts +21 -0
- package/dist/motion/cross-fade.js +86 -0
- package/dist/motion/index.d.ts +5 -0
- package/dist/motion/index.js +14 -0
- package/dist/motion/model.d.ts +15 -0
- package/dist/motion/model.js +68 -0
- package/dist/motion/motion-styles.d.ts +1 -0
- package/dist/motion/motion-styles.js +35 -0
- package/dist/motion/reveal.d.ts +37 -0
- package/dist/motion/reveal.js +69 -0
- package/dist/motion/use-enter-phase.d.ts +11 -0
- package/dist/motion/use-enter-phase.js +40 -0
- package/dist/motion/use-highlight-row.d.ts +22 -0
- package/dist/motion/use-highlight-row.js +38 -0
- package/dist/navigation/tabs/tabs.js +1 -1
- package/dist/navigation/wizard/wizard.d.ts +4 -1
- package/dist/navigation/wizard/wizard.js +3 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +8 -1
- package/dist/overlays/context-menu/context-menu.js +3 -1
- package/dist/overlays/dialog/dialog.d.ts +1 -0
- package/dist/overlays/dialog/dialog.js +11 -3
- package/dist/overlays/drawer/drawer.d.ts +18 -4
- package/dist/overlays/drawer/drawer.js +53 -4
- package/dist/overlays/drawer/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +1 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +5 -4
- package/dist/overlays/hover-card/hover-card.js +2 -0
- package/dist/overlays/popover/popover.js +2 -0
- package/dist/overlays/toaster/index.d.ts +1 -1
- package/dist/overlays/toaster/toast-store.d.ts +2 -0
- package/dist/overlays/toaster/toast-store.js +6 -1
- package/dist/overlays/toaster/toaster.d.ts +28 -2
- package/dist/overlays/toaster/toaster.js +86 -29
- package/dist/overlays/tooltip/tooltip.js +2 -0
- package/dist/primitives/use-presence.js +9 -0
- package/dist/shell/app-shell/app-shell.d.ts +8 -1
- package/dist/shell/app-shell/app-shell.js +50 -3
- package/dist/shell/index.d.ts +1 -0
- package/dist/shell/index.js +1 -0
- package/dist/shell/sidebar/sidebar.d.ts +17 -1
- package/dist/shell/sidebar/sidebar.js +126 -76
- package/dist/shell/topbar/topbar.d.ts +4 -2
- package/dist/shell/topbar/topbar.js +2 -0
- package/dist/showcase/operations-bento.js +2 -2
- package/dist/states/empty-state/empty-state.d.ts +10 -3
- package/dist/states/empty-state/empty-state.js +46 -5
- package/dist/states/error-state/error-state.js +1 -1
- package/dist/states/skeleton/skeleton.d.ts +16 -1
- package/dist/states/skeleton/skeleton.js +13 -5
- package/dist/utils/class-tokens.generated.js +4 -6
- package/dist/utils/focus-chain.d.ts +11 -0
- package/dist/utils/focus-chain.js +39 -0
- package/dist/utils/focus-rescue.d.ts +13 -0
- package/dist/utils/focus-rescue.js +48 -0
- package/dist/utils/list-navigation.d.ts +14 -0
- package/dist/utils/list-navigation.js +44 -0
- package/dist/utils/overlay-motion.d.ts +12 -0
- package/dist/utils/overlay-motion.js +14 -0
- package/dist/utils/use-container-width.d.ts +6 -0
- package/dist/utils/use-container-width.js +19 -0
- package/package.json +2 -2
- package/scripts/build-theme.mjs +46 -5
- package/src/ai/code-block/code-block.tsx +1 -1
- package/src/atoms/avatar/avatar.tsx +8 -2
- package/src/atoms/big-date/big-date.tsx +2 -2
- package/src/atoms/button/button.tsx +8 -3
- package/src/atoms/chip/chip.tsx +8 -3
- package/src/atoms/icon-button/icon-button.tsx +1 -1
- package/src/atoms/internal/hit-area.ts +5 -4
- package/src/atoms/progress/index.ts +8 -1
- package/src/atoms/progress/progress.tsx +30 -1
- package/src/atoms/radio-group/radio-group.tsx +1 -1
- package/src/atoms/status-pill/status-pill.tsx +59 -18
- package/src/brand/logo-forge.tsx +1 -1
- package/src/charts/candlestick-chart/candlestick-chart.tsx +2 -2
- package/src/charts/chart-grid/chart-grid.tsx +2 -2
- package/src/charts/chord-chart/chord-chart.tsx +1 -1
- package/src/charts/core/axes.tsx +2 -2
- package/src/charts/core/cartesian/annotations.tsx +2 -2
- package/src/charts/core/cartesian/marks.tsx +1 -1
- package/src/charts/core/distribution/marks.tsx +1 -1
- package/src/charts/core/distribution/xy-points.tsx +1 -1
- package/src/charts/core/export-menu.tsx +1 -1
- package/src/charts/funnel-chart/funnel-chart.tsx +1 -1
- package/src/charts/gantt-chart/gantt-chart.tsx +4 -4
- package/src/charts/gantt-chart/gantt-marks.tsx +3 -3
- package/src/charts/index.ts +2 -0
- package/src/charts/maps/geo/map-data-table.tsx +1 -1
- package/src/charts/polar-area-chart/polar-area-chart.tsx +1 -1
- package/src/charts/radar-chart/radar-chart.tsx +1 -1
- package/src/charts/stock-chart/stock-chart.tsx +1 -1
- package/src/charts/stock-chart/stock-drawing-layer.tsx +3 -3
- package/src/charts/stock-chart/stock-plot.tsx +2 -2
- package/src/containers/chat-thread/chat-thread.tsx +331 -0
- package/src/containers/chat-thread/format.ts +67 -0
- package/src/containers/chat-thread/index.ts +12 -0
- package/src/containers/cols/cols.tsx +13 -1
- package/src/containers/comment/comment.tsx +1 -1
- package/src/containers/context-rail/context-rail.tsx +229 -0
- package/src/containers/context-rail/index.ts +7 -0
- package/src/containers/dashboard/dashboard.tsx +142 -0
- package/src/containers/dashboard/index.ts +12 -0
- package/src/containers/data-grid/data-grid.demos.tsx +4 -4
- package/src/containers/data-grid/data-grid.tsx +6 -6
- package/src/containers/data-grid/filter-builder-editor.tsx +2 -2
- package/src/containers/data-grid/grid-toolbar.tsx +1 -1
- package/src/containers/data-grid/spreadsheet.demos.tsx +1 -1
- package/src/containers/detail-header/detail-header.tsx +64 -0
- package/src/containers/detail-header/index.ts +5 -0
- package/src/containers/facts/facts.tsx +1 -1
- package/src/containers/filter-bar/filter-bar.tsx +201 -0
- package/src/containers/filter-bar/index.ts +7 -0
- package/src/containers/hbars/hbars.tsx +2 -2
- package/src/containers/index.ts +9 -0
- package/src/containers/kanban/kanban.tsx +148 -39
- package/src/containers/kanban/model.ts +20 -0
- package/src/containers/kpi/kpi.tsx +1 -1
- package/src/containers/kpi-group/kpi-group.tsx +17 -2
- package/src/containers/list-detail/index.ts +5 -0
- package/src/containers/list-detail/list-detail.tsx +159 -9
- package/src/containers/page/page.tsx +61 -7
- package/src/containers/page-header/back.tsx +42 -0
- package/src/containers/page-header/index.ts +1 -0
- package/src/containers/page-header/page-header.tsx +49 -3
- package/src/containers/pagination/cursor-pagination.tsx +79 -0
- package/src/containers/pagination/index.ts +7 -0
- package/src/containers/pagination/pagination.tsx +266 -0
- package/src/containers/pagination/range.ts +68 -0
- package/src/containers/pagination/use-pagination.ts +44 -0
- package/src/containers/responsive-list/responsive-list.tsx +190 -47
- package/src/containers/row-actions/index.ts +1 -0
- package/src/containers/row-actions/row-actions.tsx +114 -0
- package/src/containers/selectable-card/index.ts +5 -0
- package/src/containers/selectable-card/selectable-card.tsx +84 -0
- package/src/containers/settings-layout/settings-layout.tsx +104 -13
- package/src/containers/shortcuts/shortcuts.tsx +1 -1
- package/src/containers/table/cell-padding.ts +2 -0
- package/src/containers/table/index.ts +6 -0
- package/src/containers/table/sort.ts +23 -0
- package/src/containers/table/table-parts.tsx +81 -0
- package/src/containers/table/table.tsx +212 -45
- package/src/containers/table-columns-menu/index.ts +5 -0
- package/src/containers/table-columns-menu/table-columns-menu.tsx +68 -0
- package/src/dashboards/layout.tsx +8 -75
- package/src/forms/chip-group/chip-group.tsx +8 -1
- package/src/forms/combobox/combobox.tsx +1 -1
- package/src/forms/copy-field/copy-field.tsx +1 -1
- package/src/forms/date-picker/date-picker.tsx +7 -2
- package/src/forms/date-picker/date-time-picker.tsx +28 -2
- package/src/forms/field/field.tsx +30 -3
- package/src/forms/fieldset/fieldset.tsx +22 -0
- package/src/forms/fieldset/index.ts +1 -0
- package/src/forms/form-footer/form-footer.tsx +74 -0
- package/src/forms/form-footer/index.ts +1 -0
- package/src/forms/form-grid/form-grid.tsx +42 -5
- package/src/forms/form-grid/index.ts +8 -1
- package/src/forms/form-section/form-section.tsx +41 -0
- package/src/forms/form-section/index.ts +1 -0
- package/src/forms/index.ts +3 -0
- package/src/forms/input/input.tsx +10 -3
- package/src/forms/internal/listbox-items.tsx +3 -4
- package/src/forms/native-select/native-select.tsx +1 -1
- package/src/forms/number-stepper/index.ts +1 -0
- package/src/forms/number-stepper/number-stepper.tsx +51 -6
- package/src/forms/select/index.ts +1 -1
- package/src/forms/select/select.tsx +14 -3
- package/src/forms/select-menu/select-menu.tsx +1 -1
- package/src/forms/time-input/time-input.tsx +6 -2
- package/src/i18n/strings.ts +94 -0
- package/src/motion/count-up.tsx +83 -0
- package/src/motion/cross-fade.tsx +139 -0
- package/src/motion/index.ts +5 -0
- package/src/motion/model.ts +86 -0
- package/src/motion/motion-styles.tsx +47 -0
- package/src/motion/reveal.tsx +115 -0
- package/src/motion/use-enter-phase.ts +50 -0
- package/src/motion/use-highlight-row.ts +63 -0
- package/src/navigation/tabs/tabs.tsx +1 -1
- package/src/navigation/wizard/wizard.tsx +6 -1
- package/src/overlays/alert-dialog/alert-dialog.tsx +5 -1
- package/src/overlays/context-menu/context-menu.tsx +3 -2
- package/src/overlays/dialog/dialog.tsx +9 -3
- package/src/overlays/drawer/drawer.tsx +68 -6
- package/src/overlays/drawer/index.ts +1 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +5 -4
- package/src/overlays/hover-card/hover-card.tsx +2 -0
- package/src/overlays/popover/popover.tsx +2 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toast-store.ts +8 -0
- package/src/overlays/toaster/toaster.tsx +127 -17
- package/src/overlays/tooltip/tooltip.tsx +2 -0
- package/src/primitives/use-presence.ts +13 -0
- package/src/shell/app-shell/app-shell.tsx +54 -2
- package/src/shell/index.ts +1 -0
- package/src/shell/sidebar/sidebar.tsx +154 -75
- package/src/shell/topbar/topbar.tsx +8 -0
- package/src/showcase/operations-bento.tsx +2 -2
- package/src/states/empty-state/empty-state.tsx +52 -9
- package/src/states/error-state/error-state.tsx +1 -1
- package/src/states/skeleton/skeleton.tsx +33 -5
- package/src/utils/class-tokens.generated.ts +4 -6
- package/src/utils/focus-chain.ts +53 -0
- package/src/utils/focus-rescue.ts +68 -0
- package/src/utils/list-navigation.ts +63 -0
- package/src/utils/overlay-motion.ts +33 -0
- package/src/utils/use-container-width.ts +24 -0
- package/styles/Theme.kt +15 -18
- package/styles/tailwind.css +29 -28
- package/styles/theme.css +29 -28
- package/styles/tokens.css +46 -0
- package/tokens/default.json +51 -29
|
@@ -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,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type TableSortDirection = "ascending" | "descending";
|
|
2
|
+
/** The sorted column and its direction. `null` stands for "not sorted". */
|
|
3
|
+
export interface TableSort {
|
|
4
|
+
columnId: string;
|
|
5
|
+
direction: TableSortDirection;
|
|
6
|
+
}
|
|
7
|
+
export type AriaSort = "ascending" | "descending" | "none";
|
|
8
|
+
/**
|
|
9
|
+
* Next sort when a header is activated: unsorted -> ascending -> descending -> unsorted. Activating
|
|
10
|
+
* another column starts it at ascending.
|
|
11
|
+
*/
|
|
12
|
+
export declare function nextTableSort(current: TableSort | null, columnId: string): TableSort | null;
|
|
13
|
+
/** `aria-sort` value of a sortable header: only the sorted column reports a direction. */
|
|
14
|
+
export declare function ariaSortFor(current: TableSort | null, columnId: string): AriaSort;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function nextTableSort(current, columnId) {
|
|
2
|
+
if (!current || current.columnId !== columnId) return { columnId, direction: "ascending" };
|
|
3
|
+
return current.direction === "ascending" ? { columnId, direction: "descending" } : null;
|
|
4
|
+
}
|
|
5
|
+
function ariaSortFor(current, columnId) {
|
|
6
|
+
return current?.columnId === columnId ? current.direction : "none";
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
ariaSortFor,
|
|
10
|
+
nextTableSort
|
|
11
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface TableEmptyProps {
|
|
3
|
+
/** Number of columns to span: the count of header cells. */
|
|
4
|
+
colSpan: number;
|
|
5
|
+
/** Defaults to the localized "No rows to show". */
|
|
6
|
+
title?: ReactNode;
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/** Call to action, e.g. a button that clears the filters. */
|
|
10
|
+
action?: ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Single row that holds an `EmptyState` across every column. Put it in `TableBody` when there are no rows. */
|
|
14
|
+
export declare function TableEmpty({ colSpan, title, description, icon, action, className, }: TableEmptyProps): import("react").JSX.Element;
|
|
15
|
+
export interface TableLoadingProps {
|
|
16
|
+
/** Number of columns of the table. */
|
|
17
|
+
columns: number;
|
|
18
|
+
/** Placeholder rows. Default 5. */
|
|
19
|
+
rows?: number;
|
|
20
|
+
/** Text announced to screen readers. Defaults to the localized "Loading". */
|
|
21
|
+
label?: string;
|
|
22
|
+
}
|
|
23
|
+
/** Placeholder rows for the first load. The rows are decorative; one status region announces the load. */
|
|
24
|
+
export declare function TableLoading({ columns, rows, label }: TableLoadingProps): import("react").JSX.Element[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
4
|
+
import { EmptyState } from "../../states/empty-state/empty-state.js";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
import { CELL_PY } from "./cell-padding.js";
|
|
7
|
+
function TableEmpty({
|
|
8
|
+
colSpan,
|
|
9
|
+
title,
|
|
10
|
+
description,
|
|
11
|
+
icon,
|
|
12
|
+
action,
|
|
13
|
+
className
|
|
14
|
+
}) {
|
|
15
|
+
const strings = useUiStrings();
|
|
16
|
+
return /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, className: cn("p-0", className), children: /* @__PURE__ */ jsx(
|
|
17
|
+
EmptyState,
|
|
18
|
+
{
|
|
19
|
+
title: title ?? strings.tableEmpty,
|
|
20
|
+
description,
|
|
21
|
+
icon,
|
|
22
|
+
action
|
|
23
|
+
}
|
|
24
|
+
) }) });
|
|
25
|
+
}
|
|
26
|
+
const WIDTHS = ["w-3/4", "w-1/2", "w-2/3", "w-5/6"];
|
|
27
|
+
function TableLoading({ columns, rows = 5, label }) {
|
|
28
|
+
const strings = useUiStrings();
|
|
29
|
+
return Array.from({ length: Math.max(0, rows) }, (_, row) => (
|
|
30
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: placeholder rows have no identity
|
|
31
|
+
/* @__PURE__ */ jsx("tr", { "aria-hidden": row === 0 ? void 0 : "true", className: "border-b-divider", children: Array.from({ length: Math.max(1, columns) }, (_2, column) => (
|
|
32
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: placeholder cells have no identity
|
|
33
|
+
/* @__PURE__ */ jsxs("td", { className: cn("px-4 align-middle @max-sm/table:px-2.5", CELL_PY), children: [
|
|
34
|
+
row === 0 && column === 0 ? /* @__PURE__ */ jsx("span", { role: "status", className: "sr-only", children: label ?? strings.loading }) : null,
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
"span",
|
|
37
|
+
{
|
|
38
|
+
"aria-hidden": "true",
|
|
39
|
+
className: cn(
|
|
40
|
+
"block h-3 animate-pulse rounded-xs bg-surface-2",
|
|
41
|
+
WIDTHS[(row + column) % WIDTHS.length]
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
] }, column)
|
|
46
|
+
)) }, row)
|
|
47
|
+
));
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
TableEmpty,
|
|
51
|
+
TableLoading
|
|
52
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef, type CSSProperties, type ReactNode } from "react";
|
|
2
2
|
import { type PinnedColumns } from "./pin.js";
|
|
3
|
+
import { type TableSort } from "./sort.js";
|
|
3
4
|
export type { PinnedColumns, PinSide } from "./pin.js";
|
|
5
|
+
export { type AriaSort, ariaSortFor, nextTableSort, type TableSort, type TableSortDirection, } from "./sort.js";
|
|
4
6
|
export interface TableLabels {
|
|
5
7
|
pinLeft: string;
|
|
6
8
|
pinRight: string;
|
|
@@ -12,6 +14,12 @@ export interface TableLabels {
|
|
|
12
14
|
/** Name of the overflow menu trigger of a `TableActionsCell`. Defaults to the UI string. */
|
|
13
15
|
rowActions?: string;
|
|
14
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Row density. Each sets `--row-min-h` (the least a body row measures, whatever it holds) and
|
|
19
|
+
* `--table-cell-py` (the vertical cell padding), so a row of text and a row holding a 30px control
|
|
20
|
+
* come out the same height. Override either variable with `className` or `style` to tune it.
|
|
21
|
+
*/
|
|
22
|
+
export type TableDensity = "comfortable" | "compact";
|
|
15
23
|
export interface TableProps extends ComponentPropsWithoutRef<"table"> {
|
|
16
24
|
/** Controlled pinned columns (ids of `columnId`). Pair it with `onPinnedColumnsChange`. */
|
|
17
25
|
pinnedColumns?: PinnedColumns;
|
|
@@ -46,13 +54,34 @@ export interface TableProps extends ComponentPropsWithoutRef<"table"> {
|
|
|
46
54
|
defaultSelectedKeys?: readonly string[];
|
|
47
55
|
/** Called with the next keys. Setting it turns selection on. */
|
|
48
56
|
onSelectedKeysChange?: (keys: string[]) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Controlled sort state. Setting it, `defaultSort` or `onSortChange` turns sorting on for the
|
|
59
|
+
* headers marked `sortable`. The table only reports the state: sort your rows yourself.
|
|
60
|
+
*/
|
|
61
|
+
sort?: TableSort | null;
|
|
62
|
+
/** Initial sort when uncontrolled. */
|
|
63
|
+
defaultSort?: TableSort | null;
|
|
64
|
+
/** Called with the next sort (`null` when the sort is cleared). */
|
|
65
|
+
onSortChange?: (sort: TableSort | null) => void;
|
|
66
|
+
/** Ids (`columnId`) of the columns to hide. Headers and cells with that id render nothing. */
|
|
67
|
+
hiddenColumns?: readonly string[];
|
|
68
|
+
/**
|
|
69
|
+
* Row density: `comfortable` (default) gives every body row at least 48px, `compact` 40px, with
|
|
70
|
+
* the cells centred vertically. Rows never depend on what a cell holds for their height.
|
|
71
|
+
*/
|
|
72
|
+
density?: TableDensity;
|
|
73
|
+
/**
|
|
74
|
+
* Keeps the last column (the row actions) stuck to the right edge while the table scrolls
|
|
75
|
+
* sideways, from 24rem of the table's own width up. Leave the last column unpinned when using it.
|
|
76
|
+
*/
|
|
77
|
+
stickyActions?: boolean;
|
|
49
78
|
}
|
|
50
79
|
/**
|
|
51
80
|
* Table inside its own horizontal scroll wrapper. Give columns a `columnId` (header and cells)
|
|
52
81
|
* and mark header cells `pinnable` to let the user pin them to the left or right edge: pinned
|
|
53
82
|
* columns stay sticky while the rest scrolls.
|
|
54
83
|
*/
|
|
55
|
-
export declare function Table({ className, wrapperClassName, pinnedColumns, defaultPinnedColumns, onPinnedColumnsChange, pinStorageKey, labels, flush, stickyHeader, maxHeight, selectedKeys, defaultSelectedKeys, onSelectedKeysChange, ...props }: TableProps): import("react").JSX.Element;
|
|
84
|
+
export declare function Table({ className, wrapperClassName, pinnedColumns, defaultPinnedColumns, onPinnedColumnsChange, pinStorageKey, labels, flush, stickyHeader, maxHeight, selectedKeys, defaultSelectedKeys, onSelectedKeysChange, sort, defaultSort, onSortChange, hiddenColumns, density, stickyActions, ...props }: TableProps): import("react").JSX.Element;
|
|
56
85
|
export declare function TableHead(props: ComponentPropsWithoutRef<"thead">): import("react").JSX.Element;
|
|
57
86
|
export declare function TableBody(props: ComponentPropsWithoutRef<"tbody">): import("react").JSX.Element;
|
|
58
87
|
interface ColumnProps {
|
|
@@ -62,8 +91,13 @@ interface ColumnProps {
|
|
|
62
91
|
interface AlignProps extends ColumnProps {
|
|
63
92
|
alignRight?: boolean;
|
|
64
93
|
}
|
|
65
|
-
export declare function TableHeaderCell({ className, alignRight, columnId, pinnable, children, style, ...props }: ComponentPropsWithoutRef<"th"> & AlignProps & {
|
|
94
|
+
export declare function TableHeaderCell({ className, alignRight, columnId, pinnable, sortable, children, style, ...props }: ComponentPropsWithoutRef<"th"> & AlignProps & {
|
|
66
95
|
pinnable?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Makes the header a button that cycles the sort (ascending, descending, off) and reports it
|
|
98
|
+
* as `aria-sort`. Needs a `columnId` and a `Table` with `sort`, `defaultSort` or `onSortChange`.
|
|
99
|
+
*/
|
|
100
|
+
sortable?: boolean;
|
|
67
101
|
}): ReactNode;
|
|
68
102
|
export interface TableRowProps extends ComponentPropsWithoutRef<"tr"> {
|
|
69
103
|
/**
|
|
@@ -101,7 +135,7 @@ export interface TableActionsCellProps extends ComponentPropsWithoutRef<"td"> {
|
|
|
101
135
|
* menu there. The container query is on the table wrapper, never the viewport.
|
|
102
136
|
*/
|
|
103
137
|
export declare function TableActionsCell({ menu, className, children, ...props }: TableActionsCellProps): import("react").JSX.Element;
|
|
104
|
-
export declare function TableCell({ className, alignRight, columnId, style, ...props }: ComponentPropsWithoutRef<"td"> & AlignProps): import("react").JSX.Element;
|
|
138
|
+
export declare function TableCell({ className, alignRight, columnId, style, ...props }: ComponentPropsWithoutRef<"td"> & AlignProps): import("react").JSX.Element | null;
|
|
105
139
|
export interface TableLinkRowProps extends Omit<ComponentPropsWithoutRef<"tr">, "children"> {
|
|
106
140
|
/** Row destination: rendered as a real `<a href>` in the first cell. */
|
|
107
141
|
href: string;
|
|
@@ -6,14 +6,23 @@ import {
|
|
|
6
6
|
useContext,
|
|
7
7
|
useEffect,
|
|
8
8
|
useLayoutEffect,
|
|
9
|
+
useMemo,
|
|
9
10
|
useRef,
|
|
10
11
|
useState
|
|
11
12
|
} from "react";
|
|
12
13
|
import { Checkbox } from "../../atoms/checkbox/checkbox.js";
|
|
13
14
|
import { useUiStrings } from "../../i18n/index.js";
|
|
14
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
ArrowDown,
|
|
17
|
+
ArrowLeftToLine,
|
|
18
|
+
ArrowRightToLine,
|
|
19
|
+
ArrowUp,
|
|
20
|
+
ChevronsUpDown,
|
|
21
|
+
PinOff
|
|
22
|
+
} from "../../icons/index.js";
|
|
15
23
|
import { cn } from "../../utils/cn.js";
|
|
16
24
|
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
25
|
+
import { CELL_PY } from "./cell-padding.js";
|
|
17
26
|
import {
|
|
18
27
|
computePinOffsets,
|
|
19
28
|
parseStoredPins,
|
|
@@ -21,6 +30,11 @@ import {
|
|
|
21
30
|
setColumnPin
|
|
22
31
|
} from "./pin.js";
|
|
23
32
|
import { formatSelectRow, selectAllState, setKeys, toggleKey } from "./selection.js";
|
|
33
|
+
import { ariaSortFor, nextTableSort } from "./sort.js";
|
|
34
|
+
import {
|
|
35
|
+
ariaSortFor as ariaSortFor2,
|
|
36
|
+
nextTableSort as nextTableSort2
|
|
37
|
+
} from "./sort.js";
|
|
24
38
|
const DEFAULT_LABELS = {
|
|
25
39
|
pinLeft: "Fijar a la izquierda",
|
|
26
40
|
pinRight: "Fijar a la derecha",
|
|
@@ -28,8 +42,23 @@ const DEFAULT_LABELS = {
|
|
|
28
42
|
};
|
|
29
43
|
const PinContext = createContext(null);
|
|
30
44
|
const SelectionContext = createContext(null);
|
|
45
|
+
const SortContext = createContext(null);
|
|
46
|
+
const HiddenContext = createContext(/* @__PURE__ */ new Set());
|
|
31
47
|
const FLUSH_START = "[&_:is(th,td):first-child]:pl-0 [&_td:first-child>a]:pl-0";
|
|
32
48
|
const FLUSH_END = "[&_:is(th,td):last-child]:pr-0 [&_td:last-child>a]:pr-0";
|
|
49
|
+
const DENSITY = {
|
|
50
|
+
comfortable: "[--row-min-h:48px] [--table-cell-py:--spacing(2)]",
|
|
51
|
+
compact: "[--row-min-h:40px] [--table-cell-py:--spacing(1)]"
|
|
52
|
+
};
|
|
53
|
+
const ROW_MIN_HEIGHT = "[&>tbody>tr]:h-(--row-min-h)";
|
|
54
|
+
const STICKY_ACTIONS = cn(
|
|
55
|
+
"@sm/table:[&_:is(th,td):last-child]:sticky @sm/table:[&_:is(th,td):last-child]:right-0 @sm/table:[&_:is(th,td):last-child]:bg-surface",
|
|
56
|
+
"@sm/table:[&_td:last-child]:z-1 @sm/table:[&_th:last-child]:z-2 @sm/table:[&_td:last-child]:transition-colors @sm/table:[&_td:last-child]:duration-(--motion-duration)",
|
|
57
|
+
"@sm/table:[&_tr:hover>td:last-child]:bg-surface-2 @sm/table:[&_tr[data-selected]>td:last-child]:bg-accent-soft",
|
|
58
|
+
"@sm/table:[&_:is(th,td):last-child]:[box-shadow:var(--sticky-divider,0_0_transparent),var(--sticky-edge,0_0_transparent)]",
|
|
59
|
+
"[&_th:last-child]:[--sticky-divider:inset_0_-1px_0_var(--border-color-divider)] [&_tbody>tr:not(:last-child)>td:last-child]:[--sticky-divider:inset_0_-1px_0_var(--border-color-divider)]"
|
|
60
|
+
);
|
|
61
|
+
const STICKY_EDGE = "[&_:is(th,td):last-child]:[--sticky-edge:var(--shadow-pinned-end)]";
|
|
33
62
|
const STICKY_HEADER = "[&_thead_th]:sticky [&_thead_th]:top-0 [&_thead_th]:z-2 [&_thead_th]:bg-surface [&_thead_th]:shadow-[inset_0_-1px_0_var(--border-color-divider)]";
|
|
34
63
|
function readStorage(key) {
|
|
35
64
|
try {
|
|
@@ -61,6 +90,12 @@ function Table({
|
|
|
61
90
|
selectedKeys,
|
|
62
91
|
defaultSelectedKeys,
|
|
63
92
|
onSelectedKeysChange,
|
|
93
|
+
sort,
|
|
94
|
+
defaultSort,
|
|
95
|
+
onSortChange,
|
|
96
|
+
hiddenColumns,
|
|
97
|
+
density = "comfortable",
|
|
98
|
+
stickyActions,
|
|
64
99
|
...props
|
|
65
100
|
}) {
|
|
66
101
|
const strings = useUiStrings();
|
|
@@ -70,6 +105,15 @@ function Table({
|
|
|
70
105
|
defaultProp: defaultSelectedKeys ?? [],
|
|
71
106
|
onChange: onSelectedKeysChange ? (keys) => onSelectedKeysChange([...keys]) : void 0
|
|
72
107
|
});
|
|
108
|
+
const sortOn = sort !== void 0 || defaultSort !== void 0 || onSortChange !== void 0;
|
|
109
|
+
const [currentSort, setSort] = useControllableState({
|
|
110
|
+
prop: sort,
|
|
111
|
+
defaultProp: defaultSort ?? null,
|
|
112
|
+
onChange: onSortChange
|
|
113
|
+
});
|
|
114
|
+
const sortContext = sortOn ? { sort: currentSort, toggle: (columnId) => setSort(nextTableSort(currentSort, columnId)) } : null;
|
|
115
|
+
const hiddenKey = (hiddenColumns ?? []).join("\0");
|
|
116
|
+
const hidden = useMemo(() => new Set(hiddenColumns ?? []), [hiddenKey]);
|
|
73
117
|
const wrapperRef = useRef(null);
|
|
74
118
|
const tableRef = useRef(null);
|
|
75
119
|
const controlled = pinnedColumns !== void 0;
|
|
@@ -161,7 +205,7 @@ function Table({
|
|
|
161
205
|
rowActions: labels?.rowActions ?? strings.rowActions
|
|
162
206
|
}
|
|
163
207
|
} : null;
|
|
164
|
-
return /* @__PURE__ */ jsx(PinContext.Provider, { value: context, children: /* @__PURE__ */ jsx(SelectionContext.Provider, { value: selection, children: /* @__PURE__ */ jsx(
|
|
208
|
+
return /* @__PURE__ */ jsx(PinContext.Provider, { value: context, children: /* @__PURE__ */ jsx(SelectionContext.Provider, { value: selection, children: /* @__PURE__ */ jsx(SortContext.Provider, { value: sortContext, children: /* @__PURE__ */ jsx(HiddenContext.Provider, { value: hidden, children: /* @__PURE__ */ jsx(
|
|
165
209
|
"div",
|
|
166
210
|
{
|
|
167
211
|
ref: wrapperRef,
|
|
@@ -177,8 +221,13 @@ function Table({
|
|
|
177
221
|
"table",
|
|
178
222
|
{
|
|
179
223
|
ref: tableRef,
|
|
224
|
+
"data-table-density": density,
|
|
180
225
|
className: cn(
|
|
181
226
|
"w-full border-collapse text-fs-130",
|
|
227
|
+
DENSITY[density],
|
|
228
|
+
ROW_MIN_HEIGHT,
|
|
229
|
+
stickyActions && STICKY_ACTIONS,
|
|
230
|
+
stickyActions && scrolled.end && STICKY_EDGE,
|
|
182
231
|
(flush === true || flush === "start") && FLUSH_START,
|
|
183
232
|
(flush === true || flush === "end") && FLUSH_END,
|
|
184
233
|
stickyHeader && STICKY_HEADER,
|
|
@@ -188,7 +237,7 @@ function Table({
|
|
|
188
237
|
}
|
|
189
238
|
)
|
|
190
239
|
}
|
|
191
|
-
) }) });
|
|
240
|
+
) }) }) }) });
|
|
192
241
|
}
|
|
193
242
|
function TableHead(props) {
|
|
194
243
|
return /* @__PURE__ */ jsx("thead", { ...props });
|
|
@@ -204,7 +253,7 @@ function usePinnedCell(columnId, header) {
|
|
|
204
253
|
if (!position) return { context, attrs, className: "", style: void 0 };
|
|
205
254
|
const shadowed = position.edge && (position.side === "left" ? context.scrolledStart : context.scrolledEnd);
|
|
206
255
|
const className = cn(
|
|
207
|
-
"sticky bg-surface",
|
|
256
|
+
"sticky bg-surface transition-colors duration-(--motion-duration) motion-reduce:transition-none",
|
|
208
257
|
header ? "z-2" : "z-1 group-hover/row:bg-surface-2 group-aria-selected/row:bg-accent-soft group-data-[selected=true]/row:bg-accent-soft",
|
|
209
258
|
shadowed && (position.side === "left" ? "shadow-pinned-start" : "shadow-pinned-end")
|
|
210
259
|
);
|
|
@@ -257,20 +306,56 @@ function PinButtons({ columnId }) {
|
|
|
257
306
|
)
|
|
258
307
|
] });
|
|
259
308
|
}
|
|
309
|
+
function SortButton({
|
|
310
|
+
columnId,
|
|
311
|
+
context,
|
|
312
|
+
children
|
|
313
|
+
}) {
|
|
314
|
+
const direction = ariaSortFor(context.sort, columnId);
|
|
315
|
+
const Icon = direction === "ascending" ? ArrowUp : direction === "descending" ? ArrowDown : ChevronsUpDown;
|
|
316
|
+
return /* @__PURE__ */ jsxs(
|
|
317
|
+
"button",
|
|
318
|
+
{
|
|
319
|
+
type: "button",
|
|
320
|
+
onClick: () => context.toggle(columnId),
|
|
321
|
+
className: cn(
|
|
322
|
+
"-mx-1 inline-flex items-center gap-1 rounded-xs px-1 font-[inherit] text-[length:inherit] uppercase tracking-[inherit] hover:text-ink focus-visible:focus-ring",
|
|
323
|
+
direction !== "none" ? "text-ink" : "text-inherit"
|
|
324
|
+
),
|
|
325
|
+
children: [
|
|
326
|
+
children,
|
|
327
|
+
/* @__PURE__ */ jsx(
|
|
328
|
+
Icon,
|
|
329
|
+
{
|
|
330
|
+
"aria-hidden": "true",
|
|
331
|
+
className: cn("size-3.5 shrink-0", direction === "none" && "opacity-50")
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
}
|
|
260
338
|
function TableHeaderCell({
|
|
261
339
|
className,
|
|
262
340
|
alignRight,
|
|
263
341
|
columnId,
|
|
264
342
|
pinnable,
|
|
343
|
+
sortable,
|
|
265
344
|
children,
|
|
266
345
|
style,
|
|
267
346
|
...props
|
|
268
347
|
}) {
|
|
269
348
|
const pinned = usePinnedCell(columnId, true);
|
|
349
|
+
const hiddenIds = useContext(HiddenContext);
|
|
350
|
+
const sortContext = useContext(SortContext);
|
|
351
|
+
if (columnId && hiddenIds.has(columnId)) return null;
|
|
352
|
+
const sorting = sortable && columnId && sortContext ? { columnId, context: sortContext } : null;
|
|
353
|
+
const content = sorting ? /* @__PURE__ */ jsx(SortButton, { columnId: sorting.columnId, context: sorting.context, children }) : children;
|
|
270
354
|
const showPin = pinnable && columnId && pinned.context;
|
|
271
355
|
return /* @__PURE__ */ jsx(
|
|
272
356
|
"th",
|
|
273
357
|
{
|
|
358
|
+
"aria-sort": sorting ? ariaSortFor(sorting.context.sort, sorting.columnId) : void 0,
|
|
274
359
|
className: cn(
|
|
275
360
|
"whitespace-nowrap border-b-divider px-4 py-2.5 text-left font-[650] text-fs-110 text-ink-3 uppercase tracking-[.07em] @max-sm/table:px-2.5",
|
|
276
361
|
alignRight && "text-right",
|
|
@@ -281,9 +366,9 @@ function TableHeaderCell({
|
|
|
281
366
|
...pinned.attrs,
|
|
282
367
|
...props,
|
|
283
368
|
children: showPin ? /* @__PURE__ */ jsxs("span", { className: cn("inline-flex items-center gap-1", alignRight && "flex-row-reverse"), children: [
|
|
284
|
-
|
|
369
|
+
content,
|
|
285
370
|
/* @__PURE__ */ jsx(PinButtons, { columnId })
|
|
286
|
-
] }) :
|
|
371
|
+
] }) : content
|
|
287
372
|
}
|
|
288
373
|
);
|
|
289
374
|
}
|
|
@@ -296,7 +381,7 @@ function TableRow({ className, rowKey, ...props }) {
|
|
|
296
381
|
"aria-selected": isSelected,
|
|
297
382
|
"data-selected": isSelected || void 0,
|
|
298
383
|
className: cn(
|
|
299
|
-
"group/row border-b-divider last:border-b-0 hover:bg-surface-2",
|
|
384
|
+
"group/row border-b-divider transition-colors duration-(--motion-duration) ease-(--motion-ease) last:border-b-0 hover:bg-surface-2 motion-reduce:transition-none",
|
|
300
385
|
isSelected && "bg-accent-soft hover:bg-accent-soft",
|
|
301
386
|
className
|
|
302
387
|
),
|
|
@@ -308,14 +393,21 @@ function TableSelectCell({ rowKey, label, className, ...props }) {
|
|
|
308
393
|
const selection = useContext(SelectionContext);
|
|
309
394
|
if (!selection)
|
|
310
395
|
throw new Error("TableSelectCell needs a Table with selectedKeys or onSelectedKeysChange");
|
|
311
|
-
return /* @__PURE__ */ jsx(
|
|
312
|
-
|
|
396
|
+
return /* @__PURE__ */ jsx(
|
|
397
|
+
"td",
|
|
313
398
|
{
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
399
|
+
className: cn("w-px px-4 align-middle @max-sm/table:px-2.5", CELL_PY, className),
|
|
400
|
+
...props,
|
|
401
|
+
children: /* @__PURE__ */ jsx(
|
|
402
|
+
Checkbox,
|
|
403
|
+
{
|
|
404
|
+
checked: selection.selected.includes(rowKey),
|
|
405
|
+
onCheckedChange: () => selection.toggle(rowKey),
|
|
406
|
+
"aria-label": formatSelectRow(selection.labels.selectRow ?? "", label ?? rowKey)
|
|
407
|
+
}
|
|
408
|
+
)
|
|
317
409
|
}
|
|
318
|
-
)
|
|
410
|
+
);
|
|
319
411
|
}
|
|
320
412
|
function TableSelectAllCell({ rowKeys, className, ...props }) {
|
|
321
413
|
const selection = useContext(SelectionContext);
|
|
@@ -346,7 +438,7 @@ function TableActionsCell({ menu, className, children, ...props }) {
|
|
|
346
438
|
return /* @__PURE__ */ jsxs(
|
|
347
439
|
"td",
|
|
348
440
|
{
|
|
349
|
-
className: cn("w-px px-4
|
|
441
|
+
className: cn("w-px px-4 text-right align-middle @max-sm/table:px-2.5", CELL_PY, className),
|
|
350
442
|
...props,
|
|
351
443
|
children: [
|
|
352
444
|
/* @__PURE__ */ jsx(
|
|
@@ -372,11 +464,14 @@ function TableCell({
|
|
|
372
464
|
...props
|
|
373
465
|
}) {
|
|
374
466
|
const pinned = usePinnedCell(columnId, false);
|
|
467
|
+
const hiddenIds = useContext(HiddenContext);
|
|
468
|
+
if (columnId && hiddenIds.has(columnId)) return null;
|
|
375
469
|
return /* @__PURE__ */ jsx(
|
|
376
470
|
"td",
|
|
377
471
|
{
|
|
378
472
|
className: cn(
|
|
379
|
-
"px-4
|
|
473
|
+
"px-4 align-middle @max-sm/table:px-2.5",
|
|
474
|
+
CELL_PY,
|
|
380
475
|
alignRight && "text-right",
|
|
381
476
|
pinned.className,
|
|
382
477
|
className
|
|
@@ -397,6 +492,7 @@ function TableLinkRow({
|
|
|
397
492
|
...props
|
|
398
493
|
}) {
|
|
399
494
|
const pinned = usePinnedCell(primaryColumnId, false);
|
|
495
|
+
const hiddenIds = useContext(HiddenContext);
|
|
400
496
|
const selection = useContext(SelectionContext);
|
|
401
497
|
const isSelected = selection && rowKey !== void 0 ? selection.selected.includes(rowKey) : void 0;
|
|
402
498
|
return /* @__PURE__ */ jsxs(
|
|
@@ -405,13 +501,13 @@ function TableLinkRow({
|
|
|
405
501
|
"aria-selected": isSelected,
|
|
406
502
|
"data-selected": isSelected || void 0,
|
|
407
503
|
className: cn(
|
|
408
|
-
"group/row relative border-b-divider last:border-b-0 hover:bg-surface-2",
|
|
504
|
+
"group/row relative border-b-divider transition-colors duration-(--motion-duration) ease-(--motion-ease) last:border-b-0 hover:bg-surface-2 motion-reduce:transition-none",
|
|
409
505
|
isSelected && "bg-accent-soft hover:bg-accent-soft",
|
|
410
506
|
className
|
|
411
507
|
),
|
|
412
508
|
...props,
|
|
413
509
|
children: [
|
|
414
|
-
/* @__PURE__ */ jsx(
|
|
510
|
+
primaryColumnId && hiddenIds.has(primaryColumnId) ? null : /* @__PURE__ */ jsx(
|
|
415
511
|
"td",
|
|
416
512
|
{
|
|
417
513
|
className: cn("p-0 align-middle", pinned.className),
|
|
@@ -421,7 +517,10 @@ function TableLinkRow({
|
|
|
421
517
|
"a",
|
|
422
518
|
{
|
|
423
519
|
href,
|
|
424
|
-
className:
|
|
520
|
+
className: cn(
|
|
521
|
+
"block px-4 font-[650] text-ink no-underline before:absolute before:inset-0 before:content-[''] @max-sm/table:px-2.5",
|
|
522
|
+
CELL_PY
|
|
523
|
+
),
|
|
425
524
|
children: primary
|
|
426
525
|
}
|
|
427
526
|
)
|
|
@@ -442,5 +541,7 @@ export {
|
|
|
442
541
|
TableLinkRow,
|
|
443
542
|
TableRow,
|
|
444
543
|
TableSelectAllCell,
|
|
445
|
-
TableSelectCell
|
|
544
|
+
TableSelectCell,
|
|
545
|
+
ariaSortFor2 as ariaSortFor,
|
|
546
|
+
nextTableSort2 as nextTableSort
|
|
446
547
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type TableColumnOption, TableColumnsMenu, type TableColumnsMenuProps, } from "./table-columns-menu.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface TableColumnOption {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TableColumnsMenuProps {
|
|
6
|
+
columns: readonly TableColumnOption[];
|
|
7
|
+
/** Ids of the hidden columns; pass the same list to `Table` as `hiddenColumns`. */
|
|
8
|
+
hiddenColumns: readonly string[];
|
|
9
|
+
onHiddenColumnsChange: (hidden: string[]) => void;
|
|
10
|
+
/** Trigger text. Defaults to the localized "Columns". */
|
|
11
|
+
label?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Popover with a checkbox per column. The last visible column cannot be hidden. */
|
|
14
|
+
export declare function TableColumnsMenu({ columns, hiddenColumns, onHiddenColumnsChange, label, }: TableColumnsMenuProps): import("react").JSX.Element;
|