@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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Checkbox } from "../../atoms/checkbox/checkbox.js";
|
|
4
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
5
|
+
import { Columns3 } from "../../icons/index.js";
|
|
6
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../overlays/popover/popover.js";
|
|
7
|
+
function TableColumnsMenu({
|
|
8
|
+
columns,
|
|
9
|
+
hiddenColumns,
|
|
10
|
+
onHiddenColumnsChange,
|
|
11
|
+
label
|
|
12
|
+
}) {
|
|
13
|
+
const strings = useUiStrings();
|
|
14
|
+
const name = label ?? strings.columns;
|
|
15
|
+
const visible = columns.filter((column) => !hiddenColumns.includes(column.id));
|
|
16
|
+
return /* @__PURE__ */ jsxs(Popover, { children: [
|
|
17
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
18
|
+
"button",
|
|
19
|
+
{
|
|
20
|
+
type: "button",
|
|
21
|
+
className: "inline-flex h-control-sm items-center gap-1.5 rounded-control bg-surface-control px-2.5 text-fs-120 text-ink shadow-control hover:bg-surface-2 focus-visible:focus-ring [&_svg]:size-4",
|
|
22
|
+
children: [
|
|
23
|
+
/* @__PURE__ */ jsx(Columns3, { "aria-hidden": "true" }),
|
|
24
|
+
name
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
) }),
|
|
28
|
+
/* @__PURE__ */ jsx(PopoverContent, { align: "end", "aria-label": name, children: /* @__PURE__ */ jsx("ul", { className: "m-0 grid list-none gap-1 p-0", children: columns.map((column) => {
|
|
29
|
+
const shown = !hiddenColumns.includes(column.id);
|
|
30
|
+
return /* @__PURE__ */ jsx("li", { className: "px-1.5 py-1", children: /* @__PURE__ */ jsx(
|
|
31
|
+
Checkbox,
|
|
32
|
+
{
|
|
33
|
+
label: column.label,
|
|
34
|
+
checked: shown,
|
|
35
|
+
disabled: shown && visible.length === 1,
|
|
36
|
+
onCheckedChange: () => onHiddenColumnsChange(
|
|
37
|
+
shown ? [...hiddenColumns, column.id] : hiddenColumns.filter((id) => id !== column.id)
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
) }, column.id);
|
|
41
|
+
}) }) })
|
|
42
|
+
] });
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
TableColumnsMenu
|
|
46
|
+
};
|
|
@@ -1,31 +1,5 @@
|
|
|
1
1
|
import type { Decorator } from "@storybook/react-vite";
|
|
2
|
-
|
|
3
|
-
/** Vertical rhythm of a dashboard page. */
|
|
4
|
-
export declare function DashboardPage({ children }: {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
}): import("react").JSX.Element;
|
|
7
|
-
/** Joined KPI tiles: two per row when narrow, four from 720 px of page width. */
|
|
8
|
-
export declare function KpiRow({ children }: {
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
}): import("react").JSX.Element;
|
|
11
|
-
/** Equal cards that stack under 720 px of page width. */
|
|
12
|
-
export declare function CardGrid({ columns, children }: {
|
|
13
|
-
columns?: 2 | 3;
|
|
14
|
-
children: ReactNode;
|
|
15
|
-
}): import("react").JSX.Element;
|
|
16
|
-
export interface ChartCardProps {
|
|
17
|
-
title: string;
|
|
18
|
-
subtitle?: string;
|
|
19
|
-
/** Slot at the end of the header (a chip, a button). */
|
|
20
|
-
aside?: ReactNode;
|
|
21
|
-
/** Fixed height of the body in px; the chart inside uses `height="fill"`. */
|
|
22
|
-
height?: number;
|
|
23
|
-
children: ReactNode;
|
|
24
|
-
}
|
|
25
|
-
/** Card with a fixed-height body so `height="fill"` charts take exactly the space left. */
|
|
26
|
-
export declare function ChartCard({ title, subtitle, aside, height, children }: ChartCardProps): import("react").JSX.Element;
|
|
27
|
-
/** Card whose body is a table or grid that scrolls inside its own wrapper. */
|
|
28
|
-
export declare function TableCard({ title, subtitle, aside, children }: Omit<ChartCardProps, "height">): import("react").JSX.Element;
|
|
2
|
+
export { CardGrid, ChartCard, type ChartCardProps, DashboardPage, KpiRow, TableCard, } from "../containers/dashboard/index.js";
|
|
29
3
|
/** Container-width frames for the `Narrow` (320) and `Tablet` (768) variants. */
|
|
30
4
|
export declare const narrowFrame: Decorator;
|
|
31
5
|
export declare const tabletFrame: Decorator;
|
|
@@ -1,43 +1,11 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
const gridClasses = {
|
|
11
|
-
2: "grid-cols-1 @min-[720px]/page:grid-cols-2",
|
|
12
|
-
3: "grid-cols-1 @min-[720px]/page:grid-cols-2 @min-[1180px]/page:grid-cols-3"
|
|
13
|
-
};
|
|
14
|
-
function CardGrid({ columns = 2, children }) {
|
|
15
|
-
return /* @__PURE__ */ jsx("div", { className: cn("grid items-start gap-4", gridClasses[columns]), children });
|
|
16
|
-
}
|
|
17
|
-
function CardTitle({ title, subtitle }) {
|
|
18
|
-
return /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
19
|
-
/* @__PURE__ */ jsx("h2", { className: "m-0 break-words font-semibold text-fs-140 text-ink", children: title }),
|
|
20
|
-
subtitle ? /* @__PURE__ */ jsx("p", { className: "m-0 break-words text-fs-120 text-ink-3", children: subtitle }) : null
|
|
21
|
-
] });
|
|
22
|
-
}
|
|
23
|
-
function ChartCard({ title, subtitle, aside, height = 300, children }) {
|
|
24
|
-
return /* @__PURE__ */ jsxs(Card, { children: [
|
|
25
|
-
/* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
26
|
-
/* @__PURE__ */ jsx(CardTitle, { title, subtitle }),
|
|
27
|
-
aside
|
|
28
|
-
] }),
|
|
29
|
-
/* @__PURE__ */ jsx(CardBody, { children: /* @__PURE__ */ jsx("div", { className: "min-w-0", style: { height }, children }) })
|
|
30
|
-
] });
|
|
31
|
-
}
|
|
32
|
-
function TableCard({ title, subtitle, aside, children }) {
|
|
33
|
-
return /* @__PURE__ */ jsxs(Card, { children: [
|
|
34
|
-
/* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
35
|
-
/* @__PURE__ */ jsx(CardTitle, { title, subtitle }),
|
|
36
|
-
aside
|
|
37
|
-
] }),
|
|
38
|
-
/* @__PURE__ */ jsx("div", { className: "min-w-0", children })
|
|
39
|
-
] });
|
|
40
|
-
}
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
CardGrid,
|
|
4
|
+
ChartCard,
|
|
5
|
+
DashboardPage,
|
|
6
|
+
KpiRow,
|
|
7
|
+
TableCard
|
|
8
|
+
} from "../containers/dashboard/index.js";
|
|
41
9
|
const narrowFrame = (Story) => /* @__PURE__ */ jsx("div", { className: "@container/page w-[320px] max-w-full", children: /* @__PURE__ */ jsx(Story, {}) });
|
|
42
10
|
const tabletFrame = (Story) => /* @__PURE__ */ jsx("div", { className: "@container/page w-[768px] max-w-full", children: /* @__PURE__ */ jsx(Story, {}) });
|
|
43
11
|
const NARROW_NOTE = "Container of 320 px: Cols collapse to one column, KPIs go two per row and every chart adapts to its card.";
|
|
@@ -23,6 +23,11 @@ interface ChipGroupCommon {
|
|
|
23
23
|
"aria-labelledby"?: string | undefined;
|
|
24
24
|
"aria-describedby"?: string | undefined;
|
|
25
25
|
"aria-invalid"?: boolean | "true" | "false" | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Minimum chip height: `sm` (default) is 30px (`--control-height-sm`), `md` 38px
|
|
28
|
+
* (`--control-height-md`), the heights of `Button` and `Input` of the same size.
|
|
29
|
+
*/
|
|
30
|
+
size?: "sm" | "md" | undefined;
|
|
26
31
|
className?: string | undefined;
|
|
27
32
|
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root. */
|
|
28
33
|
classNames?: ClassNames<ChipGroupPart>;
|
|
@@ -13,6 +13,7 @@ function ChipGroup(props) {
|
|
|
13
13
|
name,
|
|
14
14
|
invalid,
|
|
15
15
|
id,
|
|
16
|
+
size = "sm",
|
|
16
17
|
className,
|
|
17
18
|
classNames,
|
|
18
19
|
"aria-label": ariaLabel,
|
|
@@ -92,7 +93,8 @@ function ChipGroup(props) {
|
|
|
92
93
|
...item,
|
|
93
94
|
onClick: () => toggle(option.value),
|
|
94
95
|
className: cn(
|
|
95
|
-
"inline-flex
|
|
96
|
+
"inline-flex cursor-pointer items-center gap-1.5 rounded-badge border-control bg-surface-control px-3 font-medium text-fs-130 text-ink-2 hover:bg-surface-2 focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-50 aria-pressed:border-accent aria-pressed:bg-accent-soft aria-pressed:text-accent-ink group-data-[invalid]/chips:border-danger min-h-(--touch-target) [&_svg]:size-3",
|
|
97
|
+
size === "md" ? "min-h-control-md" : "min-h-control-sm",
|
|
96
98
|
classNames?.chip
|
|
97
99
|
),
|
|
98
100
|
children: [
|
|
@@ -185,7 +185,7 @@ function Combobox({
|
|
|
185
185
|
onKeyDown: handleKeyDown,
|
|
186
186
|
className: cn(
|
|
187
187
|
"w-full min-w-0 rounded-input border-control bg-surface-control pl-3 text-control text-ink placeholder:text-ink-3 focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-danger",
|
|
188
|
-
size === "sm" ? "h-control-sm" : "h-
|
|
188
|
+
size === "sm" ? "h-control-sm" : "h-control-md min-h-(--touch-target)",
|
|
189
189
|
hasClear ? "pr-8" : "pr-3",
|
|
190
190
|
classNames?.input
|
|
191
191
|
)
|
|
@@ -51,7 +51,7 @@ function CopyField({
|
|
|
51
51
|
onCopy?.(value);
|
|
52
52
|
},
|
|
53
53
|
className: cn(
|
|
54
|
-
"inline-flex h-control-sm shrink-0 cursor-pointer items-center gap-1.5 rounded-button px-2.5 font-semibold text-ink-2 text-meta hover:bg-surface-2 hover:text-ink focus-visible:focus-ring
|
|
54
|
+
"inline-flex h-control-sm shrink-0 cursor-pointer items-center gap-1.5 rounded-button px-2.5 font-semibold text-ink-2 text-meta hover:bg-surface-2 hover:text-ink focus-visible:focus-ring",
|
|
55
55
|
copied && "text-success",
|
|
56
56
|
classNames?.button
|
|
57
57
|
),
|
|
@@ -19,6 +19,8 @@ export interface DatePickerProps extends Omit<ComponentProps<"input">, "value" |
|
|
|
19
19
|
locale?: string;
|
|
20
20
|
/** First day of the week in the calendar, 0 (Sunday) to 6. Defaults from the locale (es-PE: Monday). */
|
|
21
21
|
weekStartsOn?: WeekStart;
|
|
22
|
+
/** `sm` is 30px and `md` (default) 38px, the heights of `Button` and `Input` of the same size. */
|
|
23
|
+
size?: "sm" | "md";
|
|
22
24
|
/** Shows a button that clears the date. Default `true`. */
|
|
23
25
|
clearable?: boolean;
|
|
24
26
|
clearLabel?: string;
|
|
@@ -37,4 +39,4 @@ export interface DatePickerProps extends Omit<ComponentProps<"input">, "value" |
|
|
|
37
39
|
* so it never shifts with the time zone. The person types in the locale's order ("07/09/2026" in
|
|
38
40
|
* es-PE) or picks from the calendar; Alt+ArrowDown opens it from the keyboard.
|
|
39
41
|
*/
|
|
40
|
-
export declare function DatePicker({ value: valueProp, defaultValue, onValueChange, min, max, isDateDisabled, locale: localeProp, weekStartsOn, clearable, clearLabel, name, invalid, container, material, disabled, placeholder, className, classNames, ref, onBlur, onKeyDown, "aria-invalid": ariaInvalid, ...props }: DatePickerProps): import("react").JSX.Element;
|
|
42
|
+
export declare function DatePicker({ value: valueProp, defaultValue, onValueChange, min, max, isDateDisabled, locale: localeProp, weekStartsOn, size, clearable, clearLabel, name, invalid, container, material, disabled, placeholder, className, classNames, ref, onBlur, onKeyDown, "aria-invalid": ariaInvalid, ...props }: DatePickerProps): import("react").JSX.Element;
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
maskDisplay,
|
|
18
18
|
parseDisplay
|
|
19
19
|
} from "./model.js";
|
|
20
|
-
const ICON_BUTTON = "flex w-8 items-center justify-center rounded-input text-ink-3 outline-none hover:text-ink focus-visible:focus-ring disabled:pointer-events-none disabled:opacity-50";
|
|
20
|
+
const ICON_BUTTON = "flex min-h-control-sm w-8 items-center justify-center rounded-input text-ink-3 outline-none hover:text-ink focus-visible:focus-ring disabled:pointer-events-none disabled:opacity-50";
|
|
21
21
|
function DatePicker({
|
|
22
22
|
value: valueProp,
|
|
23
23
|
defaultValue = "",
|
|
@@ -27,6 +27,7 @@ function DatePicker({
|
|
|
27
27
|
isDateDisabled,
|
|
28
28
|
locale: localeProp,
|
|
29
29
|
weekStartsOn,
|
|
30
|
+
size = "md",
|
|
30
31
|
clearable = true,
|
|
31
32
|
clearLabel,
|
|
32
33
|
name,
|
|
@@ -105,7 +106,8 @@ function DatePicker({
|
|
|
105
106
|
},
|
|
106
107
|
onKeyDown: handleKeyDown,
|
|
107
108
|
className: cn(
|
|
108
|
-
|
|
109
|
+
size === "sm" ? "h-control-sm" : "h-control-md",
|
|
110
|
+
"min-h-(--touch-target) w-full min-w-0 rounded-input border-control bg-surface-control pl-3 text-control text-ink tabular-nums placeholder:text-ink-3 focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-danger",
|
|
109
111
|
hasClear ? "pr-16" : "pr-9",
|
|
110
112
|
classNames?.input,
|
|
111
113
|
className
|
|
@@ -2,7 +2,11 @@ import { type ComponentProps } from "react";
|
|
|
2
2
|
import { type WeekStart } from "../../calendar/internal/date-utils.js";
|
|
3
3
|
import type { ClassNames } from "../../utils/class-names.js";
|
|
4
4
|
import type { Material } from "../../utils/material.js";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* `date` is the date picker's root and `time` the wrapper of the time field; `dateInput`, `clear`,
|
|
7
|
+
* `trigger`, `content` and `calendar` reach the inner `DatePicker` parts, `timeInput` the time field.
|
|
8
|
+
*/
|
|
9
|
+
export type DateTimePickerPart = "root" | "date" | "time" | "dateInput" | "clear" | "trigger" | "content" | "calendar" | "timeInput";
|
|
6
10
|
export interface DateTimePickerProps extends Omit<ComponentProps<"div">, "defaultValue" | "onChange" | "children" | "role" | "id" | "aria-label" | "aria-labelledby"> {
|
|
7
11
|
/**
|
|
8
12
|
* "YYYY-MM-DDTHH:mm" (controlled), a wall-clock date and time with no zone: the component never
|
|
@@ -33,6 +37,8 @@ export interface DateTimePickerProps extends Omit<ComponentProps<"div">, "defaul
|
|
|
33
37
|
"aria-invalid"?: boolean | "true" | "false";
|
|
34
38
|
container?: HTMLElement | null;
|
|
35
39
|
material?: Material;
|
|
40
|
+
/** Height of both halves: `sm` is 30px and `md` (default) 38px, like `Button` and `Input`. */
|
|
41
|
+
size?: "sm" | "md";
|
|
36
42
|
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
37
43
|
classNames?: ClassNames<DateTimePickerPart>;
|
|
38
44
|
}
|
|
@@ -40,4 +46,4 @@ export interface DateTimePickerProps extends Omit<ComponentProps<"div">, "defaul
|
|
|
40
46
|
* Date field with calendar plus a 24h time field, as one value. Replaces
|
|
41
47
|
* `<input type="datetime-local">`; the value is "YYYY-MM-DDTHH:mm" without a time zone.
|
|
42
48
|
*/
|
|
43
|
-
export declare function DateTimePicker({ value: valueProp, defaultValue, onValueChange, min, max, isDateDisabled, locale, weekStartsOn, step, name, id, disabled, required, invalid, container, material, className, classNames, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }: DateTimePickerProps): import("react").JSX.Element;
|
|
49
|
+
export declare function DateTimePicker({ value: valueProp, defaultValue, onValueChange, min, max, isDateDisabled, locale, weekStartsOn, step, name, id, disabled, required, invalid, container, material, size, className, classNames, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }: DateTimePickerProps): import("react").JSX.Element;
|
|
@@ -26,6 +26,7 @@ function DateTimePicker({
|
|
|
26
26
|
invalid,
|
|
27
27
|
container,
|
|
28
28
|
material,
|
|
29
|
+
size = "md",
|
|
29
30
|
className,
|
|
30
31
|
classNames,
|
|
31
32
|
"aria-label": ariaLabel,
|
|
@@ -95,8 +96,16 @@ function DateTimePicker({
|
|
|
95
96
|
"aria-labelledby": ariaLabelledBy,
|
|
96
97
|
container,
|
|
97
98
|
material,
|
|
99
|
+
size,
|
|
98
100
|
className: void 0,
|
|
99
|
-
classNames: {
|
|
101
|
+
classNames: {
|
|
102
|
+
root: cn("flex-[3_1_10rem]", classNames?.date),
|
|
103
|
+
input: classNames?.dateInput,
|
|
104
|
+
clear: classNames?.clear,
|
|
105
|
+
trigger: classNames?.trigger,
|
|
106
|
+
content: classNames?.content,
|
|
107
|
+
calendar: classNames?.calendar
|
|
108
|
+
}
|
|
100
109
|
}
|
|
101
110
|
),
|
|
102
111
|
/* @__PURE__ */ jsx("div", { className: cn("flex min-w-0 flex-[2_1_6rem]", classNames?.time), children: /* @__PURE__ */ jsx(
|
|
@@ -108,7 +117,9 @@ function DateTimePicker({
|
|
|
108
117
|
value: parts.time,
|
|
109
118
|
onValueChange: (time) => update({ ...parts, time }),
|
|
110
119
|
required,
|
|
111
|
-
step
|
|
120
|
+
step,
|
|
121
|
+
size,
|
|
122
|
+
className: classNames?.timeInput
|
|
112
123
|
}
|
|
113
124
|
) }),
|
|
114
125
|
name ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value: current, disabled }) : null
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef, type ReactNode } from "react";
|
|
2
2
|
import type { ClassNames } from "../../utils/class-names.js";
|
|
3
|
-
export type FieldPart = "root" | "label" | "optional" | "hint" | "error";
|
|
3
|
+
export type FieldPart = "root" | "label" | "optional" | "required" | "hint" | "error";
|
|
4
4
|
export interface FieldProps extends Omit<ComponentPropsWithoutRef<"div">, "children" | "id"> {
|
|
5
5
|
/** The label content: text or any node (an icon, a tooltip trigger). */
|
|
6
6
|
label: ReactNode;
|
|
@@ -9,6 +9,13 @@ export interface FieldProps extends Omit<ComponentPropsWithoutRef<"div">, "child
|
|
|
9
9
|
error?: string | null;
|
|
10
10
|
/** Marks the field as optional by appending the localized marker to the label. */
|
|
11
11
|
optional?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Marks the field as required: a visible `*` marker (hidden from assistive tech, which gets
|
|
14
|
+
* `aria-required` on the control instead). Native validation is not turned on.
|
|
15
|
+
*/
|
|
16
|
+
required?: boolean;
|
|
17
|
+
/** Disables the control and mutes the label. */
|
|
18
|
+
disabled?: boolean;
|
|
12
19
|
/** Id of the control the label and messages belong to. Generated when omitted. */
|
|
13
20
|
id?: string;
|
|
14
21
|
/**
|
|
@@ -25,4 +32,4 @@ export interface FieldProps extends Omit<ComponentPropsWithoutRef<"div">, "child
|
|
|
25
32
|
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
26
33
|
classNames?: ClassNames<FieldPart>;
|
|
27
34
|
}
|
|
28
|
-
export declare function Field({ label, hint, error, optional, id: idProp, controlId: controlIdProp, children, className, classNames, ...props }: FieldProps): import("react").JSX.Element;
|
|
35
|
+
export declare function Field({ label, hint, error, optional, required, disabled, id: idProp, controlId: controlIdProp, children, className, classNames, ...props }: FieldProps): import("react").JSX.Element;
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { useUiStrings } from "../../i18n/index.js";
|
|
13
13
|
import { cn } from "../../utils/cn.js";
|
|
14
14
|
import { Label } from "../label/index.js";
|
|
15
|
+
const NATIVE = /* @__PURE__ */ new Set(["INPUT", "SELECT", "TEXTAREA", "BUTTON"]);
|
|
15
16
|
const FORM_TAGS = /* @__PURE__ */ new Set(["input", "select", "textarea", "button"]);
|
|
16
17
|
const CONTROL = 'input:not([type="hidden"]):not([disabled]), select, textarea, [role="combobox"], [role="spinbutton"], [role="slider"], [contenteditable="true"]';
|
|
17
18
|
const FALLBACK_CONTROL = 'button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])';
|
|
@@ -20,6 +21,8 @@ function Field({
|
|
|
20
21
|
hint,
|
|
21
22
|
error,
|
|
22
23
|
optional,
|
|
24
|
+
required,
|
|
25
|
+
disabled,
|
|
23
26
|
id: idProp,
|
|
24
27
|
controlId: controlIdProp,
|
|
25
28
|
children,
|
|
@@ -40,7 +43,9 @@ function Field({
|
|
|
40
43
|
const control = single ? cloneElement(children, {
|
|
41
44
|
id: controlId,
|
|
42
45
|
"aria-describedby": describedBy,
|
|
43
|
-
"aria-invalid": error ? true : void 0
|
|
46
|
+
"aria-invalid": error ? true : void 0,
|
|
47
|
+
...required ? { "aria-required": true } : null,
|
|
48
|
+
...disabled ? { disabled: true } : null
|
|
44
49
|
}) : children;
|
|
45
50
|
useEffect(() => {
|
|
46
51
|
const body = bodyRef.current;
|
|
@@ -56,19 +61,28 @@ function Field({
|
|
|
56
61
|
const merged = [before.describedby, describedBy].filter(Boolean).join(" ");
|
|
57
62
|
if (merged) target.setAttribute("aria-describedby", merged);
|
|
58
63
|
if (error) target.setAttribute("aria-invalid", "true");
|
|
64
|
+
const beforeRequired = target.getAttribute("aria-required");
|
|
65
|
+
if (required) target.setAttribute("aria-required", "true");
|
|
66
|
+
const native = NATIVE.has(target.tagName);
|
|
67
|
+
const disabledName = native ? "disabled" : "aria-disabled";
|
|
68
|
+
const beforeDisabled = target.getAttribute(disabledName);
|
|
69
|
+
if (disabled) target.setAttribute(disabledName, native ? "" : "true");
|
|
59
70
|
return () => {
|
|
60
71
|
for (const [name, value] of [
|
|
61
72
|
["aria-describedby", before.describedby],
|
|
62
|
-
["aria-invalid", before.invalid]
|
|
73
|
+
["aria-invalid", before.invalid],
|
|
74
|
+
["aria-required", beforeRequired],
|
|
75
|
+
[disabledName, beforeDisabled]
|
|
63
76
|
]) {
|
|
64
77
|
if (value === null) target.removeAttribute(name);
|
|
65
78
|
else target.setAttribute(name, value);
|
|
66
79
|
}
|
|
67
80
|
};
|
|
68
|
-
}, [single, baseId, controlIdProp, idProp, describedBy, error]);
|
|
81
|
+
}, [single, baseId, controlIdProp, idProp, describedBy, error, required, disabled]);
|
|
69
82
|
return /* @__PURE__ */ jsxs("div", { ...props, className: cn("flex min-w-0 flex-col gap-1.25", classNames?.root, className), children: [
|
|
70
|
-
/* @__PURE__ */ jsxs(Label, { htmlFor: controlId, className: classNames?.label, children: [
|
|
83
|
+
/* @__PURE__ */ jsxs(Label, { htmlFor: controlId, className: cn(disabled && "text-ink-3", classNames?.label), children: [
|
|
71
84
|
label,
|
|
85
|
+
required ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("ms-0.5 text-danger", classNames?.required), children: "*" }) : null,
|
|
72
86
|
optional ? /* @__PURE__ */ jsxs("span", { className: cn("font-normal text-ink-3", classNames?.optional), children: [
|
|
73
87
|
" ",
|
|
74
88
|
"(",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
export interface FieldsetProps extends Omit<ComponentPropsWithoutRef<"fieldset">, "title"> {
|
|
3
|
+
/** The group name; announced with each control inside. */
|
|
4
|
+
legend: ReactNode;
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Native `<fieldset>` for a group of related controls (a radio set, an address). `disabled`
|
|
9
|
+
* disables every control inside, as the platform does.
|
|
10
|
+
*/
|
|
11
|
+
export declare function Fieldset({ legend, description, children, className, ...props }: FieldsetProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
function Fieldset({ legend, description, children, className, ...props }) {
|
|
4
|
+
return /* @__PURE__ */ jsxs("fieldset", { ...props, className: cn("m-0 flex min-w-0 flex-col gap-3 border-0 p-0", className), children: [
|
|
5
|
+
/* @__PURE__ */ jsx("legend", { className: "float-left w-full p-0 font-semibold text-ink-2 text-meta", children: legend }),
|
|
6
|
+
description ? /* @__PURE__ */ jsx("p", { className: "-mt-1.5 text-meta text-ink-3", children: description }) : null,
|
|
7
|
+
children
|
|
8
|
+
] });
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
Fieldset
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Fieldset, type FieldsetProps } from "./fieldset.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
export interface FormFooterProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
3
|
+
/** Called by the cancel button; without it no cancel button renders. */
|
|
4
|
+
onCancel?: () => void;
|
|
5
|
+
cancelLabel?: string;
|
|
6
|
+
/** Default: the localized "Save". */
|
|
7
|
+
submitLabel?: string;
|
|
8
|
+
/** Submit in flight: the submit button is busy (stays focusable, ignores presses), cancel is disabled. */
|
|
9
|
+
busy?: boolean;
|
|
10
|
+
/** Shows the localized "Unsaved changes" hint (polite live region) beside the actions. */
|
|
11
|
+
dirty?: boolean;
|
|
12
|
+
/** Disables the submit button, e.g. while the form is invalid. */
|
|
13
|
+
submitDisabled?: boolean;
|
|
14
|
+
/** Replaces the dirty hint text. */
|
|
15
|
+
hint?: ReactNode;
|
|
16
|
+
/** Extra actions placed before cancel. */
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
/** Pins the footer to the bottom of its scroll container. Default `true`. */
|
|
19
|
+
sticky?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Action row of a form: cancel and submit on the end, an optional dirty hint on the start.
|
|
23
|
+
* Sticky by default, so the actions stay in reach in a long form or a drawer. Place it inside the
|
|
24
|
+
* `<form>` so the submit button submits it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function FormFooter({ onCancel, cancelLabel, submitLabel, busy, dirty, submitDisabled, hint, children, sticky, className, ...props }: FormFooterProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from "../../atoms/button/index.js";
|
|
4
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
function FormFooter({
|
|
7
|
+
onCancel,
|
|
8
|
+
cancelLabel,
|
|
9
|
+
submitLabel,
|
|
10
|
+
busy,
|
|
11
|
+
dirty,
|
|
12
|
+
submitDisabled,
|
|
13
|
+
hint,
|
|
14
|
+
children,
|
|
15
|
+
sticky = true,
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}) {
|
|
19
|
+
const strings = useUiStrings();
|
|
20
|
+
const hintContent = hint ?? (dirty ? strings.unsavedChanges : null);
|
|
21
|
+
return /* @__PURE__ */ jsxs(
|
|
22
|
+
"div",
|
|
23
|
+
{
|
|
24
|
+
...props,
|
|
25
|
+
"aria-busy": busy ? "true" : void 0,
|
|
26
|
+
className: cn(
|
|
27
|
+
"@container/form-footer flex min-w-0 flex-wrap items-center gap-x-4 gap-y-2 border-line border-t bg-surface py-3",
|
|
28
|
+
sticky && "sticky bottom-0 z-10",
|
|
29
|
+
className
|
|
30
|
+
),
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsx("p", { role: "status", className: "me-auto min-w-0 text-meta text-ink-3", children: hintContent }),
|
|
33
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [
|
|
34
|
+
children,
|
|
35
|
+
onCancel ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", disabled: busy, onClick: onCancel, children: cancelLabel ?? strings.cancel }) : null,
|
|
36
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", variant: "primary", loading: busy, disabled: submitDisabled, children: submitLabel ?? strings.save })
|
|
37
|
+
] })
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
FormFooter
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormFooter, type FormFooterProps } from "./form-footer.js";
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef } from "react";
|
|
2
|
-
export type
|
|
2
|
+
export type FormGridColumns = 1 | 2 | 3;
|
|
3
|
+
export type FormGridSpan = 1 | 2 | 3 | "full";
|
|
4
|
+
export interface FormGridProps extends ComponentPropsWithoutRef<"div"> {
|
|
5
|
+
/**
|
|
6
|
+
* Largest column count, reached by container width: 2 columns from 620px, 3 from 900px
|
|
7
|
+
* (the wrapper is the size container). `1` never splits. Default `2`.
|
|
8
|
+
*/
|
|
9
|
+
columns?: FormGridColumns;
|
|
10
|
+
}
|
|
3
11
|
/**
|
|
4
|
-
* Grid for
|
|
5
|
-
*
|
|
12
|
+
* Grid for fields. One column in a narrow container, then up to `columns` by container width (the
|
|
13
|
+
* wrapper is the size container; the grid keeps `className` and props).
|
|
6
14
|
*/
|
|
7
|
-
export declare function FormGrid({ className, ...props }: FormGridProps): import("react").JSX.Element;
|
|
15
|
+
export declare function FormGrid({ columns, className, ...props }: FormGridProps): import("react").JSX.Element;
|
|
16
|
+
export interface FormGridItemProps extends ComponentPropsWithoutRef<"div"> {
|
|
17
|
+
/**
|
|
18
|
+
* Columns the item spans once the grid has them; it never adds a column the grid does not
|
|
19
|
+
* have. `"full"` spans every column at any width. Default `1`.
|
|
20
|
+
*/
|
|
21
|
+
span?: FormGridSpan;
|
|
22
|
+
}
|
|
23
|
+
/** Grid cell that spans several columns; use it around a `Field` that needs the full row. */
|
|
24
|
+
export declare function FormGridItem({ span, className, ...props }: FormGridItemProps): import("react").JSX.Element;
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../utils/cn.js";
|
|
3
|
-
|
|
3
|
+
const COLUMNS = {
|
|
4
|
+
1: "",
|
|
5
|
+
2: "@min-[620px]/form-grid:grid-cols-[repeat(2,minmax(0,1fr))]",
|
|
6
|
+
3: "@min-[620px]/form-grid:grid-cols-[repeat(2,minmax(0,1fr))] @min-[900px]/form-grid:grid-cols-[repeat(3,minmax(0,1fr))]"
|
|
7
|
+
};
|
|
8
|
+
function FormGrid({ columns = 2, className, ...props }) {
|
|
4
9
|
return /* @__PURE__ */ jsx("div", { className: "@container/form-grid min-w-0", children: /* @__PURE__ */ jsx(
|
|
5
10
|
"div",
|
|
6
11
|
{
|
|
12
|
+
"data-columns": columns,
|
|
7
13
|
className: cn(
|
|
8
|
-
"grid grid-cols-[minmax(0,1fr)] gap-3.5
|
|
14
|
+
"group/form-grid grid grid-cols-[minmax(0,1fr)] gap-3.5",
|
|
15
|
+
COLUMNS[columns],
|
|
9
16
|
className
|
|
10
17
|
),
|
|
11
18
|
...props
|
|
12
19
|
}
|
|
13
20
|
) });
|
|
14
21
|
}
|
|
22
|
+
const SPAN = {
|
|
23
|
+
1: "",
|
|
24
|
+
2: "group-data-[columns=2]/form-grid:@min-[620px]/form-grid:col-span-2 group-data-[columns=3]/form-grid:@min-[620px]/form-grid:col-span-2",
|
|
25
|
+
3: "group-data-[columns=3]/form-grid:@min-[620px]/form-grid:col-span-2 group-data-[columns=3]/form-grid:@min-[900px]/form-grid:col-span-3",
|
|
26
|
+
full: "col-span-full"
|
|
27
|
+
};
|
|
28
|
+
function FormGridItem({ span = 1, className, ...props }) {
|
|
29
|
+
return /* @__PURE__ */ jsx("div", { className: cn("min-w-0", SPAN[span], className), ...props });
|
|
30
|
+
}
|
|
15
31
|
export {
|
|
16
|
-
FormGrid
|
|
32
|
+
FormGrid,
|
|
33
|
+
FormGridItem
|
|
17
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { FormGrid, type FormGridProps } from "./form-grid.js";
|
|
1
|
+
export { FormGrid, type FormGridColumns, FormGridItem, type FormGridItemProps, type FormGridProps, type FormGridSpan, } from "./form-grid.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
export interface FormSectionProps extends Omit<ComponentPropsWithoutRef<"section">, "title"> {
|
|
3
|
+
title: ReactNode;
|
|
4
|
+
description?: ReactNode;
|
|
5
|
+
/** The fields; usually a `FormGrid`. */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Titled block of a form: the title and description beside the fields from 640px of container
|
|
10
|
+
* width, stacked above them in a narrower container (the wrapper is the size container).
|
|
11
|
+
*/
|
|
12
|
+
export declare function FormSection({ title, description, children, className, ...props }: FormSectionProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
function FormSection({
|
|
4
|
+
title,
|
|
5
|
+
description,
|
|
6
|
+
children,
|
|
7
|
+
className,
|
|
8
|
+
...props
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
"section",
|
|
12
|
+
{
|
|
13
|
+
...props,
|
|
14
|
+
className: cn(
|
|
15
|
+
"@container/form-section min-w-0 [&+&]:border-line [&+&]:border-t [&+&]:pt-6",
|
|
16
|
+
className
|
|
17
|
+
),
|
|
18
|
+
children: /* @__PURE__ */ jsxs("div", { className: "grid min-w-0 grid-cols-[minmax(0,1fr)] gap-x-8 gap-y-4 @min-[640px]/form-section:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]", children: [
|
|
19
|
+
/* @__PURE__ */ jsxs("header", { className: "flex min-w-0 flex-col gap-1", children: [
|
|
20
|
+
/* @__PURE__ */ jsx("h3", { className: "font-semibold text-fs-140 text-ink [overflow-wrap:anywhere]", children: title }),
|
|
21
|
+
description ? /* @__PURE__ */ jsx("p", { className: "text-fs-130 text-ink-3 [overflow-wrap:anywhere]", children: description }) : null
|
|
22
|
+
] }),
|
|
23
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0", children })
|
|
24
|
+
] })
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
FormSection
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormSection, type FormSectionProps } from "./form-section.js";
|