@jcsoftdev/ui 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +337 -0
- package/README.md +25 -3
- package/bin/ui-theme.mjs +40 -6
- package/dist/ai/code-block/code-block.js +1 -1
- package/dist/atoms/big-date/big-date.js +2 -2
- package/dist/atoms/button/button.d.ts +6 -1
- package/dist/atoms/button/button.js +2 -2
- package/dist/atoms/chip/chip.d.ts +5 -0
- package/dist/atoms/chip/chip.js +3 -3
- package/dist/atoms/icon-button/icon-button.js +1 -1
- package/dist/atoms/internal/hit-area.d.ts +5 -4
- package/dist/atoms/internal/hit-area.js +1 -1
- package/dist/atoms/progress/index.d.ts +1 -1
- package/dist/atoms/progress/index.js +4 -1
- package/dist/atoms/progress/progress.d.ts +6 -1
- package/dist/atoms/progress/progress.js +19 -1
- package/dist/atoms/radio-group/radio-group.js +1 -1
- package/dist/atoms/status-pill/status-pill.d.ts +16 -5
- package/dist/atoms/status-pill/status-pill.js +43 -18
- package/dist/brand/logo-forge.js +1 -1
- package/dist/charts/candlestick-chart/candlestick-chart.js +2 -2
- package/dist/charts/chart-grid/chart-grid.js +2 -2
- package/dist/charts/chord-chart/chord-chart.js +1 -1
- package/dist/charts/core/axes.js +2 -2
- package/dist/charts/core/cartesian/annotations.js +2 -2
- package/dist/charts/core/cartesian/marks.js +1 -1
- package/dist/charts/core/distribution/marks.js +1 -1
- package/dist/charts/core/distribution/xy-points.js +1 -1
- package/dist/charts/core/export-menu.js +1 -1
- package/dist/charts/funnel-chart/funnel-chart.js +1 -1
- package/dist/charts/gantt-chart/gantt-chart.js +4 -4
- package/dist/charts/gantt-chart/gantt-marks.js +3 -3
- package/dist/charts/index.d.ts +2 -0
- package/dist/charts/index.js +2 -0
- package/dist/charts/maps/geo/map-data-table.js +1 -1
- package/dist/charts/polar-area-chart/polar-area-chart.js +1 -1
- package/dist/charts/radar-chart/radar-chart.js +1 -1
- package/dist/charts/stock-chart/stock-chart.js +1 -1
- package/dist/charts/stock-chart/stock-drawing-layer.js +3 -3
- package/dist/charts/stock-chart/stock-plot.js +2 -2
- package/dist/containers/chat-thread/chat-thread.d.ts +98 -0
- package/dist/containers/chat-thread/chat-thread.js +219 -0
- package/dist/containers/chat-thread/format.d.ts +20 -0
- package/dist/containers/chat-thread/format.js +50 -0
- package/dist/containers/chat-thread/index.d.ts +1 -0
- package/dist/containers/chat-thread/index.js +8 -0
- package/dist/containers/cols/cols.d.ts +1 -1
- package/dist/containers/cols/cols.js +7 -0
- package/dist/containers/comment/comment.js +1 -1
- package/dist/containers/context-rail/context-rail.d.ts +62 -0
- package/dist/containers/context-rail/context-rail.js +175 -0
- package/dist/containers/context-rail/index.d.ts +1 -0
- package/dist/containers/context-rail/index.js +6 -0
- package/dist/containers/dashboard/dashboard.d.ts +40 -0
- package/dist/containers/dashboard/dashboard.js +84 -0
- package/dist/containers/dashboard/index.d.ts +1 -0
- package/dist/containers/dashboard/index.js +14 -0
- package/dist/containers/data-grid/data-grid.demos.js +4 -4
- package/dist/containers/data-grid/data-grid.js +6 -6
- package/dist/containers/data-grid/filter-builder-editor.js +2 -2
- package/dist/containers/data-grid/grid-toolbar.js +1 -1
- package/dist/containers/data-grid/spreadsheet.demos.d.ts +1 -1
- package/dist/containers/data-grid/spreadsheet.demos.js +1 -1
- package/dist/containers/detail-header/detail-header.d.ts +24 -0
- package/dist/containers/detail-header/detail-header.js +32 -0
- package/dist/containers/detail-header/index.d.ts +1 -0
- package/dist/containers/detail-header/index.js +6 -0
- package/dist/containers/facts/facts.js +1 -1
- package/dist/containers/filter-bar/filter-bar.d.ts +58 -0
- package/dist/containers/filter-bar/filter-bar.js +123 -0
- package/dist/containers/filter-bar/index.d.ts +1 -0
- package/dist/containers/filter-bar/index.js +6 -0
- package/dist/containers/hbars/hbars.js +2 -2
- package/dist/containers/index.d.ts +9 -0
- package/dist/containers/index.js +9 -0
- package/dist/containers/kanban/kanban.d.ts +23 -2
- package/dist/containers/kanban/kanban.js +101 -21
- package/dist/containers/kanban/model.d.ts +12 -0
- package/dist/containers/kanban/model.js +8 -0
- package/dist/containers/kpi/kpi.js +1 -1
- package/dist/containers/kpi-group/kpi-group.d.ts +6 -1
- package/dist/containers/kpi-group/kpi-group.js +6 -2
- package/dist/containers/list-detail/index.d.ts +1 -1
- package/dist/containers/list-detail/index.js +4 -0
- package/dist/containers/list-detail/list-detail.d.ts +51 -3
- package/dist/containers/list-detail/list-detail.js +109 -15
- package/dist/containers/page/page.d.ts +17 -4
- package/dist/containers/page/page.js +33 -4
- package/dist/containers/page-header/back.d.ts +10 -0
- package/dist/containers/page-header/back.js +28 -0
- package/dist/containers/page-header/index.d.ts +1 -0
- package/dist/containers/page-header/index.js +1 -0
- package/dist/containers/page-header/page-header.d.ts +19 -2
- package/dist/containers/page-header/page-header.js +26 -2
- package/dist/containers/pagination/cursor-pagination.d.ts +28 -0
- package/dist/containers/pagination/cursor-pagination.js +48 -0
- package/dist/containers/pagination/index.d.ts +3 -0
- package/dist/containers/pagination/index.js +10 -0
- package/dist/containers/pagination/pagination.d.ts +52 -0
- package/dist/containers/pagination/pagination.js +216 -0
- package/dist/containers/pagination/range.d.ts +29 -0
- package/dist/containers/pagination/range.js +42 -0
- package/dist/containers/pagination/use-pagination.d.ts +18 -0
- package/dist/containers/pagination/use-pagination.js +22 -0
- package/dist/containers/responsive-list/responsive-list.d.ts +28 -2
- package/dist/containers/responsive-list/responsive-list.js +134 -25
- package/dist/containers/row-actions/index.d.ts +1 -0
- package/dist/containers/row-actions/index.js +4 -0
- package/dist/containers/row-actions/row-actions.d.ts +26 -0
- package/dist/containers/row-actions/row-actions.js +78 -0
- package/dist/containers/selectable-card/index.d.ts +1 -0
- package/dist/containers/selectable-card/index.js +6 -0
- package/dist/containers/selectable-card/selectable-card.d.ts +26 -0
- package/dist/containers/selectable-card/selectable-card.js +57 -0
- package/dist/containers/settings-layout/settings-layout.d.ts +24 -7
- package/dist/containers/settings-layout/settings-layout.js +63 -8
- package/dist/containers/shortcuts/shortcuts.js +1 -1
- package/dist/containers/table/cell-padding.d.ts +2 -0
- package/dist/containers/table/cell-padding.js +4 -0
- package/dist/containers/table/index.d.ts +1 -0
- package/dist/containers/table/index.js +8 -0
- package/dist/containers/table/sort.d.ts +14 -0
- package/dist/containers/table/sort.js +11 -0
- package/dist/containers/table/table-parts.d.ts +24 -0
- package/dist/containers/table/table-parts.js +52 -0
- package/dist/containers/table/table.d.ts +37 -3
- package/dist/containers/table/table.js +120 -19
- package/dist/containers/table-columns-menu/index.d.ts +1 -0
- package/dist/containers/table-columns-menu/index.js +6 -0
- package/dist/containers/table-columns-menu/table-columns-menu.d.ts +14 -0
- package/dist/containers/table-columns-menu/table-columns-menu.js +46 -0
- package/dist/dashboards/layout.d.ts +1 -27
- package/dist/dashboards/layout.js +8 -40
- package/dist/forms/chip-group/chip-group.d.ts +5 -0
- package/dist/forms/chip-group/chip-group.js +3 -1
- package/dist/forms/combobox/combobox.js +1 -1
- package/dist/forms/copy-field/copy-field.js +1 -1
- package/dist/forms/date-picker/date-picker.d.ts +3 -1
- package/dist/forms/date-picker/date-picker.js +4 -2
- package/dist/forms/date-picker/date-time-picker.d.ts +8 -2
- package/dist/forms/date-picker/date-time-picker.js +13 -2
- package/dist/forms/field/field.d.ts +9 -2
- package/dist/forms/field/field.js +18 -4
- package/dist/forms/fieldset/fieldset.d.ts +11 -0
- package/dist/forms/fieldset/fieldset.js +12 -0
- package/dist/forms/fieldset/index.d.ts +1 -0
- package/dist/forms/fieldset/index.js +4 -0
- package/dist/forms/form-footer/form-footer.d.ts +26 -0
- package/dist/forms/form-footer/form-footer.js +44 -0
- package/dist/forms/form-footer/index.d.ts +1 -0
- package/dist/forms/form-footer/index.js +4 -0
- package/dist/forms/form-grid/form-grid.d.ts +21 -4
- package/dist/forms/form-grid/form-grid.js +20 -3
- package/dist/forms/form-grid/index.d.ts +1 -1
- package/dist/forms/form-grid/index.js +6 -2
- package/dist/forms/form-section/form-section.d.ts +12 -0
- package/dist/forms/form-section/form-section.js +30 -0
- package/dist/forms/form-section/index.d.ts +1 -0
- package/dist/forms/form-section/index.js +4 -0
- package/dist/forms/index.d.ts +3 -0
- package/dist/forms/index.js +3 -0
- package/dist/forms/input/input.d.ts +6 -2
- package/dist/forms/input/input.js +4 -1
- package/dist/forms/internal/listbox-items.d.ts +1 -1
- package/dist/forms/internal/listbox-items.js +3 -2
- package/dist/forms/native-select/native-select.js +1 -1
- package/dist/forms/select/index.d.ts +1 -1
- package/dist/forms/select/select.d.ts +5 -2
- package/dist/forms/select/select.js +7 -2
- package/dist/forms/select-menu/select-menu.js +1 -1
- package/dist/forms/time-input/time-input.d.ts +4 -2
- package/dist/forms/time-input/time-input.js +3 -1
- package/dist/i18n/strings.d.ts +86 -0
- package/dist/i18n/strings.js +46 -0
- package/dist/motion/count-up.d.ts +20 -0
- package/dist/motion/count-up.js +59 -0
- package/dist/motion/cross-fade.d.ts +21 -0
- package/dist/motion/cross-fade.js +86 -0
- package/dist/motion/index.d.ts +5 -0
- package/dist/motion/index.js +14 -0
- package/dist/motion/model.d.ts +15 -0
- package/dist/motion/model.js +68 -0
- package/dist/motion/motion-styles.d.ts +1 -0
- package/dist/motion/motion-styles.js +35 -0
- package/dist/motion/reveal.d.ts +37 -0
- package/dist/motion/reveal.js +69 -0
- package/dist/motion/use-enter-phase.d.ts +11 -0
- package/dist/motion/use-enter-phase.js +40 -0
- package/dist/motion/use-highlight-row.d.ts +22 -0
- package/dist/motion/use-highlight-row.js +38 -0
- package/dist/navigation/tabs/tabs.js +1 -1
- package/dist/navigation/wizard/wizard.d.ts +4 -1
- package/dist/navigation/wizard/wizard.js +3 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +8 -1
- package/dist/overlays/context-menu/context-menu.js +3 -1
- package/dist/overlays/dialog/dialog.js +10 -2
- package/dist/overlays/drawer/drawer.d.ts +18 -4
- package/dist/overlays/drawer/drawer.js +53 -4
- package/dist/overlays/drawer/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +1 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +5 -4
- package/dist/overlays/hover-card/hover-card.js +2 -0
- package/dist/overlays/popover/popover.js +2 -0
- package/dist/overlays/toaster/index.d.ts +1 -1
- package/dist/overlays/toaster/toaster.d.ts +28 -2
- package/dist/overlays/toaster/toaster.js +73 -29
- package/dist/overlays/tooltip/tooltip.js +2 -0
- package/dist/primitives/use-presence.js +9 -0
- package/dist/shell/app-shell/app-shell.d.ts +8 -1
- package/dist/shell/app-shell/app-shell.js +50 -3
- package/dist/shell/index.d.ts +1 -0
- package/dist/shell/index.js +1 -0
- package/dist/shell/sidebar/sidebar.d.ts +17 -1
- package/dist/shell/sidebar/sidebar.js +126 -76
- package/dist/shell/topbar/topbar.d.ts +4 -2
- package/dist/shell/topbar/topbar.js +2 -0
- package/dist/showcase/operations-bento.js +2 -2
- package/dist/states/empty-state/empty-state.d.ts +10 -3
- package/dist/states/empty-state/empty-state.js +46 -5
- package/dist/states/error-state/error-state.js +1 -1
- package/dist/states/skeleton/skeleton.js +1 -1
- package/dist/utils/class-tokens.generated.js +4 -6
- package/dist/utils/list-navigation.d.ts +14 -0
- package/dist/utils/list-navigation.js +44 -0
- package/dist/utils/overlay-motion.d.ts +12 -0
- package/dist/utils/overlay-motion.js +14 -0
- package/dist/utils/use-container-width.d.ts +6 -0
- package/dist/utils/use-container-width.js +19 -0
- package/package.json +2 -2
- package/scripts/build-theme.mjs +46 -5
- package/src/ai/code-block/code-block.tsx +1 -1
- package/src/atoms/big-date/big-date.tsx +2 -2
- package/src/atoms/button/button.tsx +8 -3
- package/src/atoms/chip/chip.tsx +8 -3
- package/src/atoms/icon-button/icon-button.tsx +1 -1
- package/src/atoms/internal/hit-area.ts +5 -4
- package/src/atoms/progress/index.ts +8 -1
- package/src/atoms/progress/progress.tsx +30 -1
- package/src/atoms/radio-group/radio-group.tsx +1 -1
- package/src/atoms/status-pill/status-pill.tsx +59 -18
- package/src/brand/logo-forge.tsx +1 -1
- package/src/charts/candlestick-chart/candlestick-chart.tsx +2 -2
- package/src/charts/chart-grid/chart-grid.tsx +2 -2
- package/src/charts/chord-chart/chord-chart.tsx +1 -1
- package/src/charts/core/axes.tsx +2 -2
- package/src/charts/core/cartesian/annotations.tsx +2 -2
- package/src/charts/core/cartesian/marks.tsx +1 -1
- package/src/charts/core/distribution/marks.tsx +1 -1
- package/src/charts/core/distribution/xy-points.tsx +1 -1
- package/src/charts/core/export-menu.tsx +1 -1
- package/src/charts/funnel-chart/funnel-chart.tsx +1 -1
- package/src/charts/gantt-chart/gantt-chart.tsx +4 -4
- package/src/charts/gantt-chart/gantt-marks.tsx +3 -3
- package/src/charts/index.ts +2 -0
- package/src/charts/maps/geo/map-data-table.tsx +1 -1
- package/src/charts/polar-area-chart/polar-area-chart.tsx +1 -1
- package/src/charts/radar-chart/radar-chart.tsx +1 -1
- package/src/charts/stock-chart/stock-chart.tsx +1 -1
- package/src/charts/stock-chart/stock-drawing-layer.tsx +3 -3
- package/src/charts/stock-chart/stock-plot.tsx +2 -2
- package/src/containers/chat-thread/chat-thread.tsx +331 -0
- package/src/containers/chat-thread/format.ts +67 -0
- package/src/containers/chat-thread/index.ts +12 -0
- package/src/containers/cols/cols.tsx +13 -1
- package/src/containers/comment/comment.tsx +1 -1
- package/src/containers/context-rail/context-rail.tsx +229 -0
- package/src/containers/context-rail/index.ts +7 -0
- package/src/containers/dashboard/dashboard.tsx +142 -0
- package/src/containers/dashboard/index.ts +12 -0
- package/src/containers/data-grid/data-grid.demos.tsx +4 -4
- package/src/containers/data-grid/data-grid.tsx +6 -6
- package/src/containers/data-grid/filter-builder-editor.tsx +2 -2
- package/src/containers/data-grid/grid-toolbar.tsx +1 -1
- package/src/containers/data-grid/spreadsheet.demos.tsx +1 -1
- package/src/containers/detail-header/detail-header.tsx +64 -0
- package/src/containers/detail-header/index.ts +5 -0
- package/src/containers/facts/facts.tsx +1 -1
- package/src/containers/filter-bar/filter-bar.tsx +201 -0
- package/src/containers/filter-bar/index.ts +7 -0
- package/src/containers/hbars/hbars.tsx +2 -2
- package/src/containers/index.ts +9 -0
- package/src/containers/kanban/kanban.tsx +146 -39
- package/src/containers/kanban/model.ts +20 -0
- package/src/containers/kpi/kpi.tsx +1 -1
- package/src/containers/kpi-group/kpi-group.tsx +17 -2
- package/src/containers/list-detail/index.ts +5 -0
- package/src/containers/list-detail/list-detail.tsx +157 -9
- package/src/containers/page/page.tsx +61 -7
- package/src/containers/page-header/back.tsx +42 -0
- package/src/containers/page-header/index.ts +1 -0
- package/src/containers/page-header/page-header.tsx +49 -3
- package/src/containers/pagination/cursor-pagination.tsx +79 -0
- package/src/containers/pagination/index.ts +7 -0
- package/src/containers/pagination/pagination.tsx +266 -0
- package/src/containers/pagination/range.ts +68 -0
- package/src/containers/pagination/use-pagination.ts +44 -0
- package/src/containers/responsive-list/responsive-list.tsx +183 -46
- package/src/containers/row-actions/index.ts +1 -0
- package/src/containers/row-actions/row-actions.tsx +114 -0
- package/src/containers/selectable-card/index.ts +5 -0
- package/src/containers/selectable-card/selectable-card.tsx +84 -0
- package/src/containers/settings-layout/settings-layout.tsx +104 -13
- package/src/containers/shortcuts/shortcuts.tsx +1 -1
- package/src/containers/table/cell-padding.ts +2 -0
- package/src/containers/table/index.ts +6 -0
- package/src/containers/table/sort.ts +23 -0
- package/src/containers/table/table-parts.tsx +81 -0
- package/src/containers/table/table.tsx +212 -45
- package/src/containers/table-columns-menu/index.ts +5 -0
- package/src/containers/table-columns-menu/table-columns-menu.tsx +68 -0
- package/src/dashboards/layout.tsx +8 -75
- package/src/forms/chip-group/chip-group.tsx +8 -1
- package/src/forms/combobox/combobox.tsx +1 -1
- package/src/forms/copy-field/copy-field.tsx +1 -1
- package/src/forms/date-picker/date-picker.tsx +7 -2
- package/src/forms/date-picker/date-time-picker.tsx +28 -2
- package/src/forms/field/field.tsx +30 -3
- package/src/forms/fieldset/fieldset.tsx +22 -0
- package/src/forms/fieldset/index.ts +1 -0
- package/src/forms/form-footer/form-footer.tsx +74 -0
- package/src/forms/form-footer/index.ts +1 -0
- package/src/forms/form-grid/form-grid.tsx +42 -5
- package/src/forms/form-grid/index.ts +8 -1
- package/src/forms/form-section/form-section.tsx +41 -0
- package/src/forms/form-section/index.ts +1 -0
- package/src/forms/index.ts +3 -0
- package/src/forms/input/input.tsx +10 -3
- package/src/forms/internal/listbox-items.tsx +3 -4
- package/src/forms/native-select/native-select.tsx +1 -1
- package/src/forms/select/index.ts +1 -1
- package/src/forms/select/select.tsx +14 -3
- package/src/forms/select-menu/select-menu.tsx +1 -1
- package/src/forms/time-input/time-input.tsx +6 -2
- package/src/i18n/strings.ts +86 -0
- package/src/motion/count-up.tsx +83 -0
- package/src/motion/cross-fade.tsx +139 -0
- package/src/motion/index.ts +5 -0
- package/src/motion/model.ts +86 -0
- package/src/motion/motion-styles.tsx +47 -0
- package/src/motion/reveal.tsx +115 -0
- package/src/motion/use-enter-phase.ts +50 -0
- package/src/motion/use-highlight-row.ts +63 -0
- package/src/navigation/tabs/tabs.tsx +1 -1
- package/src/navigation/wizard/wizard.tsx +6 -1
- package/src/overlays/alert-dialog/alert-dialog.tsx +5 -1
- package/src/overlays/context-menu/context-menu.tsx +3 -2
- package/src/overlays/dialog/dialog.tsx +7 -2
- package/src/overlays/drawer/drawer.tsx +68 -6
- package/src/overlays/drawer/index.ts +1 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +5 -4
- package/src/overlays/hover-card/hover-card.tsx +2 -0
- package/src/overlays/popover/popover.tsx +2 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toaster.tsx +113 -17
- package/src/overlays/tooltip/tooltip.tsx +2 -0
- package/src/primitives/use-presence.ts +13 -0
- package/src/shell/app-shell/app-shell.tsx +54 -2
- package/src/shell/index.ts +1 -0
- package/src/shell/sidebar/sidebar.tsx +154 -75
- package/src/shell/topbar/topbar.tsx +8 -0
- package/src/showcase/operations-bento.tsx +2 -2
- package/src/states/empty-state/empty-state.tsx +52 -9
- package/src/states/error-state/error-state.tsx +1 -1
- package/src/states/skeleton/skeleton.tsx +1 -1
- package/src/utils/class-tokens.generated.ts +4 -6
- package/src/utils/list-navigation.ts +63 -0
- package/src/utils/overlay-motion.ts +33 -0
- package/src/utils/use-container-width.ts +24 -0
- package/styles/Theme.kt +15 -18
- package/styles/tailwind.css +29 -28
- package/styles/theme.css +29 -28
- package/styles/tokens.css +46 -0
- package/tokens/default.json +51 -29
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef } from "react";
|
|
2
|
-
export
|
|
2
|
+
export type SelectSize = "sm" | "md";
|
|
3
|
+
export interface SelectProps extends Omit<ComponentPropsWithoutRef<"select">, "size"> {
|
|
4
|
+
/** `sm` is 30px and `md` (default) 38px, the heights of `Button` and `Input` of the same size. */
|
|
5
|
+
size?: SelectSize;
|
|
3
6
|
}
|
|
4
7
|
/**
|
|
5
8
|
* Wraps the native `<select>` (keeps the system picker on mobile) and draws
|
|
6
9
|
* the chevron with an icon.
|
|
7
10
|
*/
|
|
8
|
-
export declare function Select({ className, children, ...props }: SelectProps): import("react").JSX.Element;
|
|
11
|
+
export declare function Select({ size, className, children, ...props }: SelectProps): import("react").JSX.Element;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronDown } from "../../icons/index.js";
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
|
-
|
|
4
|
+
const selectSizeClasses = {
|
|
5
|
+
sm: "h-control-sm pl-2.5",
|
|
6
|
+
md: "h-control-md pl-3"
|
|
7
|
+
};
|
|
8
|
+
function Select({ size = "md", className, children, ...props }) {
|
|
5
9
|
return /* @__PURE__ */ jsxs("span", { className: "relative flex w-full items-center", children: [
|
|
6
10
|
/* @__PURE__ */ jsx(
|
|
7
11
|
"select",
|
|
8
12
|
{
|
|
9
13
|
className: cn(
|
|
10
|
-
"
|
|
14
|
+
"w-full min-w-0 appearance-none rounded-input border-control bg-surface-control py-0 pr-7 text-control text-ink focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 aria-[invalid=true]:border-danger",
|
|
15
|
+
selectSizeClasses[size],
|
|
11
16
|
className
|
|
12
17
|
),
|
|
13
18
|
...props,
|
|
@@ -162,7 +162,7 @@ function SelectMenu({
|
|
|
162
162
|
},
|
|
163
163
|
className: cn(
|
|
164
164
|
"flex w-full min-w-0 items-center justify-between gap-2 rounded-input border-control bg-surface-control py-0 pr-2.5 pl-3 text-left text-control text-ink 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",
|
|
165
|
-
size === "sm" ? "h-control-sm" : "h-
|
|
165
|
+
size === "sm" ? "h-control-sm" : "h-control-md min-h-(--touch-target)",
|
|
166
166
|
classNames?.trigger,
|
|
167
167
|
className
|
|
168
168
|
),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef } from "react";
|
|
2
|
-
export interface TimeInputProps extends Omit<ComponentPropsWithoutRef<"input">, "type" | "value" | "defaultValue" | "onChange" | "step" | "inputMode" | "maxLength"> {
|
|
2
|
+
export interface TimeInputProps extends Omit<ComponentPropsWithoutRef<"input">, "type" | "value" | "defaultValue" | "onChange" | "step" | "inputMode" | "maxLength" | "size"> {
|
|
3
|
+
/** `sm` is 30px and `md` (default) 38px, the heights of `Button` and `Input` of the same size. */
|
|
4
|
+
size?: "sm" | "md";
|
|
3
5
|
/** 24h "HH:MM" (controlled). */
|
|
4
6
|
value?: string;
|
|
5
7
|
defaultValue?: string;
|
|
@@ -12,4 +14,4 @@ export interface TimeInputProps extends Omit<ComponentPropsWithoutRef<"input">,
|
|
|
12
14
|
* 24h time field. A masked text input, so it renders "15:30" whatever the browser
|
|
13
15
|
* locale is. ArrowUp / ArrowDown change the segment under the caret (minutes move by `step`).
|
|
14
16
|
*/
|
|
15
|
-
export declare function TimeInput({ value, defaultValue, onValueChange, step, className, onBlur, onKeyDown, placeholder, ...props }: TimeInputProps): import("react").JSX.Element;
|
|
17
|
+
export declare function TimeInput({ value, defaultValue, onValueChange, step, size, className, onBlur, onKeyDown, placeholder, ...props }: TimeInputProps): import("react").JSX.Element;
|
|
@@ -22,6 +22,7 @@ function TimeInput({
|
|
|
22
22
|
defaultValue = "",
|
|
23
23
|
onValueChange,
|
|
24
24
|
step = 5,
|
|
25
|
+
size = "md",
|
|
25
26
|
className,
|
|
26
27
|
onBlur,
|
|
27
28
|
onKeyDown,
|
|
@@ -71,7 +72,8 @@ function TimeInput({
|
|
|
71
72
|
maxLength: 5,
|
|
72
73
|
placeholder,
|
|
73
74
|
className: cn(
|
|
74
|
-
|
|
75
|
+
size === "sm" ? "h-control-sm" : "h-control-md",
|
|
76
|
+
"w-full min-w-0 rounded-input border-control bg-surface-control px-3 font-mono text-control text-ink tabular-nums placeholder:text-ink-3 focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 aria-[invalid=true]:border-danger",
|
|
75
77
|
className
|
|
76
78
|
),
|
|
77
79
|
...props,
|
package/dist/i18n/strings.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export interface UiStrings {
|
|
|
3
3
|
close: string;
|
|
4
4
|
loading: string;
|
|
5
5
|
optional: string;
|
|
6
|
+
save: string;
|
|
7
|
+
unsavedChanges: string;
|
|
6
8
|
cancel: string;
|
|
7
9
|
confirm: string;
|
|
8
10
|
processing: string;
|
|
@@ -56,6 +58,44 @@ export interface UiStrings {
|
|
|
56
58
|
selectAll: string;
|
|
57
59
|
/** Name of the overflow menu trigger of a `TableActionsCell`. */
|
|
58
60
|
rowActions: string;
|
|
61
|
+
/** Default body of a `TableEmpty` row. */
|
|
62
|
+
tableEmpty: string;
|
|
63
|
+
/** Label of the `TableColumnsMenu` trigger and its group. */
|
|
64
|
+
columns: string;
|
|
65
|
+
/** Name of the `Pagination` landmark. */
|
|
66
|
+
pagination: string;
|
|
67
|
+
/** Label of the page size picker of a `Pagination`. */
|
|
68
|
+
rowsPerPage: string;
|
|
69
|
+
/** Range text of a `Pagination`; `{first}`, `{last}` and `{total}` are replaced. */
|
|
70
|
+
pageRange: string;
|
|
71
|
+
firstPage: string;
|
|
72
|
+
previousPage: string;
|
|
73
|
+
nextPage: string;
|
|
74
|
+
lastPage: string;
|
|
75
|
+
/** Range text of a `Pagination variant="pages"`; `{first}`, `{last}` and `{total}` are replaced. */
|
|
76
|
+
showingRange: string;
|
|
77
|
+
/** Range text of a `CursorPagination` (no known total); `{first}` and `{last}` are replaced. */
|
|
78
|
+
showingRangeOpen: string;
|
|
79
|
+
/** Visible label of the previous-page button of `Pagination variant="pages"` and `CursorPagination`. */
|
|
80
|
+
previous: string;
|
|
81
|
+
/** Name of a page number button; `{page}` is replaced. */
|
|
82
|
+
pageNumber: string;
|
|
83
|
+
/** Name of the search field of a `FilterBar`. */
|
|
84
|
+
search: string;
|
|
85
|
+
/** Label of the `FilterBar` button that opens every filter under a narrow container. */
|
|
86
|
+
filters: string;
|
|
87
|
+
/** Label of the `FilterBar` button that opens the extra filters. */
|
|
88
|
+
moreFilters: string;
|
|
89
|
+
/** Clears every active filter of a `FilterBar`. */
|
|
90
|
+
clearAllFilters: string;
|
|
91
|
+
/** Name of the remove button of an active filter chip; `{filter}` is replaced by its label. */
|
|
92
|
+
removeFilter: string;
|
|
93
|
+
/** Name of the list of active filter chips of a `FilterBar`. */
|
|
94
|
+
activeFilters: string;
|
|
95
|
+
/** Result count of a `FilterBar` for exactly one result. */
|
|
96
|
+
resultOne: string;
|
|
97
|
+
/** Result count of a `FilterBar`; `{count}` is replaced. */
|
|
98
|
+
resultMany: string;
|
|
59
99
|
/** Name of the `PasswordInput` toggle; its pressed state says whether the password is visible. */
|
|
60
100
|
showPassword: string;
|
|
61
101
|
/** Default title of a `LoginForm`. */
|
|
@@ -96,6 +136,8 @@ export declare const uiStrings: {
|
|
|
96
136
|
readonly close: "Close";
|
|
97
137
|
readonly loading: "Loading";
|
|
98
138
|
readonly optional: "optional";
|
|
139
|
+
readonly save: "Save";
|
|
140
|
+
readonly unsavedChanges: "Unsaved changes";
|
|
99
141
|
readonly cancel: "Cancel";
|
|
100
142
|
readonly confirm: "Confirm";
|
|
101
143
|
readonly processing: "Processing…";
|
|
@@ -138,6 +180,27 @@ export declare const uiStrings: {
|
|
|
138
180
|
readonly selectRow: "Select {row}";
|
|
139
181
|
readonly selectAll: "Select all rows";
|
|
140
182
|
readonly rowActions: "Row actions";
|
|
183
|
+
readonly tableEmpty: "No rows to show";
|
|
184
|
+
readonly columns: "Columns";
|
|
185
|
+
readonly pagination: "Pagination";
|
|
186
|
+
readonly rowsPerPage: "Rows per page";
|
|
187
|
+
readonly pageRange: "{first}–{last} of {total}";
|
|
188
|
+
readonly firstPage: "First page";
|
|
189
|
+
readonly previousPage: "Previous page";
|
|
190
|
+
readonly nextPage: "Next page";
|
|
191
|
+
readonly lastPage: "Last page";
|
|
192
|
+
readonly showingRange: "Showing {first}–{last} of {total}";
|
|
193
|
+
readonly showingRangeOpen: "Showing {first}–{last}";
|
|
194
|
+
readonly previous: "Previous";
|
|
195
|
+
readonly pageNumber: "Page {page}";
|
|
196
|
+
readonly search: "Search";
|
|
197
|
+
readonly filters: "Filters";
|
|
198
|
+
readonly moreFilters: "More filters";
|
|
199
|
+
readonly clearAllFilters: "Clear all filters";
|
|
200
|
+
readonly removeFilter: "Remove filter {filter}";
|
|
201
|
+
readonly activeFilters: "Active filters";
|
|
202
|
+
readonly resultOne: "1 result";
|
|
203
|
+
readonly resultMany: "{count} results";
|
|
141
204
|
readonly showPassword: "Show password";
|
|
142
205
|
readonly signIn: "Sign in";
|
|
143
206
|
readonly signInAs: "Sign in as";
|
|
@@ -160,6 +223,8 @@ export declare const uiStrings: {
|
|
|
160
223
|
readonly close: "Cerrar";
|
|
161
224
|
readonly loading: "Cargando";
|
|
162
225
|
readonly optional: "opcional";
|
|
226
|
+
readonly save: "Guardar";
|
|
227
|
+
readonly unsavedChanges: "Cambios sin guardar";
|
|
163
228
|
readonly cancel: "Cancelar";
|
|
164
229
|
readonly confirm: "Confirmar";
|
|
165
230
|
readonly processing: "Procesando…";
|
|
@@ -202,6 +267,27 @@ export declare const uiStrings: {
|
|
|
202
267
|
readonly selectRow: "Seleccionar {row}";
|
|
203
268
|
readonly selectAll: "Seleccionar todas las filas";
|
|
204
269
|
readonly rowActions: "Acciones de la fila";
|
|
270
|
+
readonly tableEmpty: "No hay filas para mostrar";
|
|
271
|
+
readonly columns: "Columnas";
|
|
272
|
+
readonly pagination: "Paginación";
|
|
273
|
+
readonly rowsPerPage: "Filas por página";
|
|
274
|
+
readonly pageRange: "{first}–{last} de {total}";
|
|
275
|
+
readonly firstPage: "Primera página";
|
|
276
|
+
readonly previousPage: "Página anterior";
|
|
277
|
+
readonly nextPage: "Página siguiente";
|
|
278
|
+
readonly lastPage: "Última página";
|
|
279
|
+
readonly showingRange: "Mostrando {first}–{last} de {total}";
|
|
280
|
+
readonly showingRangeOpen: "Mostrando {first}–{last}";
|
|
281
|
+
readonly previous: "Anterior";
|
|
282
|
+
readonly pageNumber: "Página {page}";
|
|
283
|
+
readonly search: "Buscar";
|
|
284
|
+
readonly filters: "Filtros";
|
|
285
|
+
readonly moreFilters: "Más filtros";
|
|
286
|
+
readonly clearAllFilters: "Limpiar todos los filtros";
|
|
287
|
+
readonly removeFilter: "Quitar filtro {filter}";
|
|
288
|
+
readonly activeFilters: "Filtros activos";
|
|
289
|
+
readonly resultOne: "1 resultado";
|
|
290
|
+
readonly resultMany: "{count} resultados";
|
|
205
291
|
readonly showPassword: "Mostrar contraseña";
|
|
206
292
|
readonly signIn: "Inicia sesión";
|
|
207
293
|
readonly signInAs: "Ingresar como";
|
package/dist/i18n/strings.js
CHANGED
|
@@ -4,6 +4,8 @@ const uiStrings = {
|
|
|
4
4
|
close: "Close",
|
|
5
5
|
loading: "Loading",
|
|
6
6
|
optional: "optional",
|
|
7
|
+
save: "Save",
|
|
8
|
+
unsavedChanges: "Unsaved changes",
|
|
7
9
|
cancel: "Cancel",
|
|
8
10
|
confirm: "Confirm",
|
|
9
11
|
processing: "Processing\u2026",
|
|
@@ -46,6 +48,27 @@ const uiStrings = {
|
|
|
46
48
|
selectRow: "Select {row}",
|
|
47
49
|
selectAll: "Select all rows",
|
|
48
50
|
rowActions: "Row actions",
|
|
51
|
+
tableEmpty: "No rows to show",
|
|
52
|
+
columns: "Columns",
|
|
53
|
+
pagination: "Pagination",
|
|
54
|
+
rowsPerPage: "Rows per page",
|
|
55
|
+
pageRange: "{first}\u2013{last} of {total}",
|
|
56
|
+
firstPage: "First page",
|
|
57
|
+
previousPage: "Previous page",
|
|
58
|
+
nextPage: "Next page",
|
|
59
|
+
lastPage: "Last page",
|
|
60
|
+
showingRange: "Showing {first}\u2013{last} of {total}",
|
|
61
|
+
showingRangeOpen: "Showing {first}\u2013{last}",
|
|
62
|
+
previous: "Previous",
|
|
63
|
+
pageNumber: "Page {page}",
|
|
64
|
+
search: "Search",
|
|
65
|
+
filters: "Filters",
|
|
66
|
+
moreFilters: "More filters",
|
|
67
|
+
clearAllFilters: "Clear all filters",
|
|
68
|
+
removeFilter: "Remove filter {filter}",
|
|
69
|
+
activeFilters: "Active filters",
|
|
70
|
+
resultOne: "1 result",
|
|
71
|
+
resultMany: "{count} results",
|
|
49
72
|
showPassword: "Show password",
|
|
50
73
|
signIn: "Sign in",
|
|
51
74
|
signInAs: "Sign in as",
|
|
@@ -68,6 +91,8 @@ const uiStrings = {
|
|
|
68
91
|
close: "Cerrar",
|
|
69
92
|
loading: "Cargando",
|
|
70
93
|
optional: "opcional",
|
|
94
|
+
save: "Guardar",
|
|
95
|
+
unsavedChanges: "Cambios sin guardar",
|
|
71
96
|
cancel: "Cancelar",
|
|
72
97
|
confirm: "Confirmar",
|
|
73
98
|
processing: "Procesando\u2026",
|
|
@@ -110,6 +135,27 @@ const uiStrings = {
|
|
|
110
135
|
selectRow: "Seleccionar {row}",
|
|
111
136
|
selectAll: "Seleccionar todas las filas",
|
|
112
137
|
rowActions: "Acciones de la fila",
|
|
138
|
+
tableEmpty: "No hay filas para mostrar",
|
|
139
|
+
columns: "Columnas",
|
|
140
|
+
pagination: "Paginaci\xF3n",
|
|
141
|
+
rowsPerPage: "Filas por p\xE1gina",
|
|
142
|
+
pageRange: "{first}\u2013{last} de {total}",
|
|
143
|
+
firstPage: "Primera p\xE1gina",
|
|
144
|
+
previousPage: "P\xE1gina anterior",
|
|
145
|
+
nextPage: "P\xE1gina siguiente",
|
|
146
|
+
lastPage: "\xDAltima p\xE1gina",
|
|
147
|
+
showingRange: "Mostrando {first}\u2013{last} de {total}",
|
|
148
|
+
showingRangeOpen: "Mostrando {first}\u2013{last}",
|
|
149
|
+
previous: "Anterior",
|
|
150
|
+
pageNumber: "P\xE1gina {page}",
|
|
151
|
+
search: "Buscar",
|
|
152
|
+
filters: "Filtros",
|
|
153
|
+
moreFilters: "M\xE1s filtros",
|
|
154
|
+
clearAllFilters: "Limpiar todos los filtros",
|
|
155
|
+
removeFilter: "Quitar filtro {filter}",
|
|
156
|
+
activeFilters: "Filtros activos",
|
|
157
|
+
resultOne: "1 resultado",
|
|
158
|
+
resultMany: "{count} resultados",
|
|
113
159
|
showPassword: "Mostrar contrase\xF1a",
|
|
114
160
|
signIn: "Inicia sesi\xF3n",
|
|
115
161
|
signInAs: "Ingresar como",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type HTMLAttributes, type Ref } from "react";
|
|
2
|
+
/** Anything with an `Intl.NumberFormat`-style `format`, such as `new Intl.NumberFormat(...)`. */
|
|
3
|
+
export interface NumberFormatter {
|
|
4
|
+
format(value: number): string;
|
|
5
|
+
}
|
|
6
|
+
export interface CountUpProps extends Omit<HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
7
|
+
value: number;
|
|
8
|
+
/** Formats every shown value. Defaults to `Intl.NumberFormat` in the UI strings locale. */
|
|
9
|
+
formatter?: NumberFormatter;
|
|
10
|
+
/** Where a client-side mount starts counting from. Default 0. */
|
|
11
|
+
from?: number;
|
|
12
|
+
ref?: Ref<HTMLSpanElement>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A number that counts to `value` over 1.5 `--motion-duration`s with `--motion-ease`, on a client
|
|
16
|
+
* mount and on every change. Server HTML, hydration and reduced motion show the final value at
|
|
17
|
+
* once. While it counts, assistive tech reads only the final value and the final text reserves
|
|
18
|
+
* its width, so the line does not grow digit by digit. Works as the `value` of a `Kpi`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function CountUp({ value, formatter, from, className, ref, ...props }: CountUpProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { useUiStrings } from "../i18n/index.js";
|
|
5
|
+
import { usePrefersReducedMotion } from "../utils/reduced-motion.js";
|
|
6
|
+
import { composeRefs } from "../utils/slot.js";
|
|
7
|
+
import { COUNT_UP_SCALE, countAt, parseDuration, parseEasing } from "./model.js";
|
|
8
|
+
import { MotionStyles } from "./motion-styles.js";
|
|
9
|
+
import { useStartedOnServer } from "./use-enter-phase.js";
|
|
10
|
+
function CountUp({ value, formatter, from = 0, className, ref, ...props }) {
|
|
11
|
+
const { locale } = useUiStrings();
|
|
12
|
+
const format = useMemo(() => formatter ?? new Intl.NumberFormat(locale), [formatter, locale]);
|
|
13
|
+
const startedOnServer = useStartedOnServer();
|
|
14
|
+
const reduced = usePrefersReducedMotion();
|
|
15
|
+
const [shown, setShown] = useState(() => startedOnServer || reduced ? value : from);
|
|
16
|
+
const node = useRef(null);
|
|
17
|
+
const latest = useRef(shown);
|
|
18
|
+
latest.current = shown;
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const start = latest.current;
|
|
21
|
+
const el = node.current;
|
|
22
|
+
if (reduced || start === value || !el || typeof requestAnimationFrame === "undefined") {
|
|
23
|
+
setShown(value);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const styles = getComputedStyle(el);
|
|
27
|
+
const duration = parseDuration(styles.getPropertyValue("--motion-duration")) * COUNT_UP_SCALE;
|
|
28
|
+
const ease = parseEasing(styles.getPropertyValue("--motion-ease"));
|
|
29
|
+
const t0 = performance.now();
|
|
30
|
+
let frame = requestAnimationFrame(function tick(now) {
|
|
31
|
+
const next = countAt(start, value, now - t0, duration, ease);
|
|
32
|
+
setShown(next);
|
|
33
|
+
if (next !== value) frame = requestAnimationFrame(tick);
|
|
34
|
+
});
|
|
35
|
+
return () => cancelAnimationFrame(frame);
|
|
36
|
+
}, [value, reduced]);
|
|
37
|
+
const final = format.format(value);
|
|
38
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
39
|
+
/* @__PURE__ */ jsx(MotionStyles, {}),
|
|
40
|
+
/* @__PURE__ */ jsx(
|
|
41
|
+
"span",
|
|
42
|
+
{
|
|
43
|
+
ref: composeRefs(ref, node),
|
|
44
|
+
className: className ? `ui-count ${className}` : "ui-count",
|
|
45
|
+
...props,
|
|
46
|
+
children: shown === value ? final : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47
|
+
/* @__PURE__ */ jsxs("span", { className: "ui-count-run", "aria-hidden": "true", children: [
|
|
48
|
+
/* @__PURE__ */ jsx("span", { children: final }),
|
|
49
|
+
/* @__PURE__ */ jsx("span", { children: format.format(shown) })
|
|
50
|
+
] }),
|
|
51
|
+
/* @__PURE__ */ jsx("span", { className: "ui-motion-sr", children: final })
|
|
52
|
+
] })
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
CountUp
|
|
59
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type HTMLAttributes, type Key, type ReactNode, type Ref } from "react";
|
|
2
|
+
export interface CrossFadeProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Identity of the content. A new key fades the old content out and the new one in. */
|
|
4
|
+
contentKey: Key;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
ref?: Ref<HTMLDivElement>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Swaps keyed content (a list-detail pane, a tab panel) with a cross-fade and a 4px rise. The old
|
|
10
|
+
* content stays mounted on top of the new one until it has faded, out of the layout (so nothing
|
|
11
|
+
* jumps), hidden from assistive tech and inert. If focus was inside the old content it moves to
|
|
12
|
+
* the new content. The first render (also server HTML) never animates; reduced motion swaps
|
|
13
|
+
* without any fade.
|
|
14
|
+
*/
|
|
15
|
+
export declare function CrossFade({ contentKey, children, ref, ...props }: CrossFadeProps): import("react").JSX.Element;
|
|
16
|
+
export interface PresenceProps extends Omit<CrossFadeProps, "contentKey"> {
|
|
17
|
+
/** Shows the children when true; changes fade them in and out. */
|
|
18
|
+
present: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** `CrossFade` between the children and nothing: shows or hides content with a fade. */
|
|
21
|
+
export declare function Presence({ present, children, ...props }: PresenceProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState
|
|
8
|
+
} from "react";
|
|
9
|
+
import { usePrefersReducedMotion } from "../utils/reduced-motion.js";
|
|
10
|
+
import { MotionStyles } from "./motion-styles.js";
|
|
11
|
+
const LEAVE_TIMEOUT_MS = 1e3;
|
|
12
|
+
function CrossFade({ contentKey, children, ref, ...props }) {
|
|
13
|
+
const reduced = usePrefersReducedMotion();
|
|
14
|
+
const current = useRef(null);
|
|
15
|
+
const committed = useRef(children);
|
|
16
|
+
const [state, setState] = useState({
|
|
17
|
+
key: contentKey,
|
|
18
|
+
entering: null,
|
|
19
|
+
leaving: [],
|
|
20
|
+
refocus: 0
|
|
21
|
+
});
|
|
22
|
+
if (state.key !== contentKey) {
|
|
23
|
+
const animate = !reduced;
|
|
24
|
+
const focused = typeof document !== "undefined" && document.activeElement;
|
|
25
|
+
setState({
|
|
26
|
+
key: contentKey,
|
|
27
|
+
entering: animate ? contentKey : null,
|
|
28
|
+
leaving: animate ? [
|
|
29
|
+
...state.leaving.filter((layer) => layer.key !== contentKey),
|
|
30
|
+
{ key: state.key, node: committed.current }
|
|
31
|
+
] : [],
|
|
32
|
+
refocus: focused && current.current?.contains(focused) ? state.refocus + 1 : state.refocus
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
committed.current = children;
|
|
37
|
+
});
|
|
38
|
+
useLayoutEffect(() => {
|
|
39
|
+
if (state.refocus === 0 || !current.current) return;
|
|
40
|
+
current.current.tabIndex = -1;
|
|
41
|
+
current.current.focus({ preventScroll: true });
|
|
42
|
+
}, [state.refocus]);
|
|
43
|
+
const leavingCount = state.leaving.length;
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (leavingCount === 0) return;
|
|
46
|
+
const timer = setTimeout(() => setState((s) => ({ ...s, leaving: [] })), LEAVE_TIMEOUT_MS);
|
|
47
|
+
return () => clearTimeout(timer);
|
|
48
|
+
}, [leavingCount]);
|
|
49
|
+
const drop = (key) => (event) => {
|
|
50
|
+
if (event.target !== event.currentTarget) return;
|
|
51
|
+
setState((s) => ({ ...s, leaving: s.leaving.filter((layer) => layer.key !== key) }));
|
|
52
|
+
};
|
|
53
|
+
const layers = [
|
|
54
|
+
...state.leaving.map((layer) => /* @__PURE__ */ jsx(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
"data-motion-leave": "",
|
|
58
|
+
"aria-hidden": "true",
|
|
59
|
+
inert: true,
|
|
60
|
+
onAnimationEnd: drop(layer.key),
|
|
61
|
+
children: layer.node
|
|
62
|
+
},
|
|
63
|
+
`k:${String(layer.key)}`
|
|
64
|
+
)),
|
|
65
|
+
/* @__PURE__ */ jsx(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
ref: current,
|
|
69
|
+
"data-motion": state.entering === contentKey ? "enter" : void 0,
|
|
70
|
+
children
|
|
71
|
+
},
|
|
72
|
+
`k:${String(contentKey)}`
|
|
73
|
+
)
|
|
74
|
+
];
|
|
75
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
76
|
+
/* @__PURE__ */ jsx(MotionStyles, {}),
|
|
77
|
+
/* @__PURE__ */ jsx("div", { ref, "data-motion-swap": "", ...props, children: layers })
|
|
78
|
+
] });
|
|
79
|
+
}
|
|
80
|
+
function Presence({ present, children, ...props }) {
|
|
81
|
+
return /* @__PURE__ */ jsx(CrossFade, { contentKey: present ? "present" : "absent", ...props, children: present ? children : null });
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
CrossFade,
|
|
85
|
+
Presence
|
|
86
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CountUp, type CountUpProps, type NumberFormatter } from "./count-up.js";
|
|
2
|
+
export { CrossFade, type CrossFadeProps, Presence, type PresenceProps } from "./cross-fade.js";
|
|
3
|
+
export { MotionStyles } from "./motion-styles.js";
|
|
4
|
+
export { Reveal, type RevealProps, Stagger, type StaggerProps } from "./reveal.js";
|
|
5
|
+
export { type HighlightRow, type HighlightRowProps, useHighlightRow } from "./use-highlight-row.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CountUp } from "./count-up.js";
|
|
2
|
+
import { CrossFade, Presence } from "./cross-fade.js";
|
|
3
|
+
import { MotionStyles } from "./motion-styles.js";
|
|
4
|
+
import { Reveal, Stagger } from "./reveal.js";
|
|
5
|
+
import { useHighlightRow } from "./use-highlight-row.js";
|
|
6
|
+
export {
|
|
7
|
+
CountUp,
|
|
8
|
+
CrossFade,
|
|
9
|
+
MotionStyles,
|
|
10
|
+
Presence,
|
|
11
|
+
Reveal,
|
|
12
|
+
Stagger,
|
|
13
|
+
useHighlightRow
|
|
14
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Fallbacks when the theme does not define `--motion-duration` / `--motion-ease`. */
|
|
2
|
+
export declare const DEFAULT_DURATION_MS = 180;
|
|
3
|
+
export declare const DEFAULT_EASE = "cubic-bezier(.2,.8,.2,1)";
|
|
4
|
+
/** A count-up runs this many token durations: long enough to read, still under 300ms by default. */
|
|
5
|
+
export declare const COUNT_UP_SCALE = 1.5;
|
|
6
|
+
export type Easing = (t: number) => number;
|
|
7
|
+
/** Milliseconds from a CSS time (`180ms`, `.18s`); `fallback` when it does not parse. */
|
|
8
|
+
export declare function parseDuration(value: string | null | undefined, fallback?: number): number;
|
|
9
|
+
/** Easing function for a CSS `<easing-function>`: `linear`, the `ease*` keywords or `cubic-bezier()`. */
|
|
10
|
+
export declare function parseEasing(value: string | null | undefined): Easing;
|
|
11
|
+
/**
|
|
12
|
+
* Value a count-up shows `elapsed` ms into a run of `duration` ms. It lands exactly on `to` at the
|
|
13
|
+
* end, and integer runs stay integers so a formatter never flashes decimals.
|
|
14
|
+
*/
|
|
15
|
+
export declare function countAt(from: number, to: number, elapsed: number, duration: number, ease: Easing): number;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const DEFAULT_DURATION_MS = 180;
|
|
2
|
+
const DEFAULT_EASE = "cubic-bezier(.2,.8,.2,1)";
|
|
3
|
+
const COUNT_UP_SCALE = 1.5;
|
|
4
|
+
function parseDuration(value, fallback = DEFAULT_DURATION_MS) {
|
|
5
|
+
const match = /^\s*(-?\d*\.?\d+)\s*(ms|s)\s*$/i.exec(value ?? "");
|
|
6
|
+
if (!match) return fallback;
|
|
7
|
+
const amount = Number(match[1]) * (match[2]?.toLowerCase() === "s" ? 1e3 : 1);
|
|
8
|
+
return Number.isFinite(amount) && amount >= 0 ? amount : fallback;
|
|
9
|
+
}
|
|
10
|
+
function cubicBezier(x1, y1, x2, y2) {
|
|
11
|
+
const sample = (a, b, t) => 3 * a * t * (1 - t) ** 2 + 3 * b * t ** 2 * (1 - t) + t ** 3;
|
|
12
|
+
const slope = (a, b, t) => 3 * a * (1 - t) ** 2 + 6 * (b - a) * t * (1 - t) + 3 * (1 - b) * t ** 2;
|
|
13
|
+
return (x) => {
|
|
14
|
+
if (x <= 0) return 0;
|
|
15
|
+
if (x >= 1) return 1;
|
|
16
|
+
let t = x;
|
|
17
|
+
for (let i = 0; i < 8; i += 1) {
|
|
18
|
+
const error = sample(x1, x2, t) - x;
|
|
19
|
+
if (Math.abs(error) < 1e-6) return sample(y1, y2, t);
|
|
20
|
+
const d = slope(x1, x2, t);
|
|
21
|
+
if (Math.abs(d) < 1e-6) break;
|
|
22
|
+
t -= error / d;
|
|
23
|
+
}
|
|
24
|
+
let lo = 0;
|
|
25
|
+
let hi = 1;
|
|
26
|
+
t = x;
|
|
27
|
+
for (let i = 0; i < 30; i += 1) {
|
|
28
|
+
const value = sample(x1, x2, t);
|
|
29
|
+
if (Math.abs(value - x) < 1e-6) break;
|
|
30
|
+
if (value < x) lo = t;
|
|
31
|
+
else hi = t;
|
|
32
|
+
t = (lo + hi) / 2;
|
|
33
|
+
}
|
|
34
|
+
return sample(y1, y2, t);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const KEYWORDS = {
|
|
38
|
+
ease: [0.25, 0.1, 0.25, 1],
|
|
39
|
+
"ease-in": [0.42, 0, 1, 1],
|
|
40
|
+
"ease-out": [0, 0, 0.58, 1],
|
|
41
|
+
"ease-in-out": [0.42, 0, 0.58, 1]
|
|
42
|
+
};
|
|
43
|
+
function parseEasing(value) {
|
|
44
|
+
const text = (value ?? "").trim().toLowerCase();
|
|
45
|
+
if (text === "linear") return (t) => Math.min(1, Math.max(0, t));
|
|
46
|
+
const keyword = KEYWORDS[text];
|
|
47
|
+
if (keyword) return cubicBezier(...keyword);
|
|
48
|
+
const match = /^cubic-bezier\(([^)]*)\)$/.exec(text);
|
|
49
|
+
const points = match?.[1]?.split(",").map(Number);
|
|
50
|
+
if (points?.length === 4 && points.every(Number.isFinite)) {
|
|
51
|
+
const [x1, y1, x2, y2] = points;
|
|
52
|
+
if (x1 >= 0 && x1 <= 1 && x2 >= 0 && x2 <= 1) return cubicBezier(x1, y1, x2, y2);
|
|
53
|
+
}
|
|
54
|
+
return cubicBezier(0.2, 0.8, 0.2, 1);
|
|
55
|
+
}
|
|
56
|
+
function countAt(from, to, elapsed, duration, ease) {
|
|
57
|
+
if (!(duration > 0) || elapsed >= duration) return to;
|
|
58
|
+
const value = from + (to - from) * ease(Math.max(0, elapsed) / duration);
|
|
59
|
+
return Number.isInteger(from) && Number.isInteger(to) ? Math.round(value) : value;
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
COUNT_UP_SCALE,
|
|
63
|
+
DEFAULT_DURATION_MS,
|
|
64
|
+
DEFAULT_EASE,
|
|
65
|
+
countAt,
|
|
66
|
+
parseDuration,
|
|
67
|
+
parseEasing
|
|
68
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function MotionStyles(): import("react").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
const D = "var(--motion-duration,180ms)";
|
|
3
|
+
const E = "var(--motion-ease,cubic-bezier(.2,.8,.2,1))";
|
|
4
|
+
const CSS = `
|
|
5
|
+
@keyframes ui-motion-enter{from{opacity:0;transform:translate3d(0,var(--ui-motion-rise,6px),0)}}
|
|
6
|
+
@keyframes ui-motion-leave{to{opacity:0}}
|
|
7
|
+
@keyframes ui-motion-pulse-a{from{background-color:var(--ui-motion-highlight)}}
|
|
8
|
+
@keyframes ui-motion-pulse-b{from{background-color:var(--ui-motion-highlight)}}
|
|
9
|
+
[data-motion-stagger]{--ui-motion-step:min(calc(${D} / 4),calc(var(--ui-motion-span,calc(${D} * 1.5)) / var(--ui-motion-n,1)))}
|
|
10
|
+
[data-motion=wait]{opacity:0}
|
|
11
|
+
[data-motion=wait]:focus-within{opacity:1}
|
|
12
|
+
[data-motion=enter]{animation:ui-motion-enter ${D} ${E} backwards;animation-delay:calc(var(--ui-motion-delay,0ms) + var(--ui-motion-i,0) * var(--ui-motion-step,0ms))}
|
|
13
|
+
[data-motion-swap]{position:relative}
|
|
14
|
+
[data-motion-swap]>[data-motion=enter]{--ui-motion-rise:4px}
|
|
15
|
+
[data-motion-swap]>[data-motion-leave]{position:absolute;inset:0 0 auto;pointer-events:none;animation:ui-motion-leave ${D} ${E} forwards}
|
|
16
|
+
[data-motion-pulse]{--ui-motion-highlight:color-mix(in srgb,var(--accent,currentColor) 24%,transparent)}
|
|
17
|
+
[data-motion-pulse=a]:not(tr),tr[data-motion-pulse=a]>*{animation:ui-motion-pulse-a calc(${D} * 1.6) ${E}}
|
|
18
|
+
[data-motion-pulse=b]:not(tr),tr[data-motion-pulse=b]>*{animation:ui-motion-pulse-b calc(${D} * 1.6) ${E}}
|
|
19
|
+
.ui-count{font-variant-numeric:tabular-nums}
|
|
20
|
+
.ui-count-run{display:inline-grid;justify-items:end}
|
|
21
|
+
.ui-count-run>*{grid-area:1/1}
|
|
22
|
+
.ui-count-run>:first-child{visibility:hidden}
|
|
23
|
+
.ui-motion-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
|
|
24
|
+
@media (prefers-reduced-motion:reduce){
|
|
25
|
+
[data-motion]{animation:none!important;opacity:1!important}
|
|
26
|
+
[data-motion-swap]>[data-motion-leave]{display:none}
|
|
27
|
+
[data-motion-pulse]:not(tr),tr[data-motion-pulse]>*{animation:none!important}
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
function MotionStyles() {
|
|
31
|
+
return /* @__PURE__ */ jsx("style", { href: "jcsoftdev-ui-motion", precedence: "default", children: CSS });
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
MotionStyles
|
|
35
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode, type Ref } from "react";
|
|
2
|
+
export interface RevealProps extends HTMLAttributes<HTMLElement> {
|
|
3
|
+
/** Extra wait before entering, in ms. */
|
|
4
|
+
delay?: number;
|
|
5
|
+
/** Enter when the element first scrolls into view instead of on mount. */
|
|
6
|
+
inView?: boolean;
|
|
7
|
+
/** Animate the single child element instead of rendering a `div`. */
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
ref?: Ref<HTMLElement>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fades its content in with a small rise when it mounts on the client, or first scrolls into view
|
|
13
|
+
* with `inView`. Server-rendered content and reduced motion show the end state at once. The
|
|
14
|
+
* content stays in the accessibility tree the whole time: hiding uses `opacity` only.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Reveal({ delay, inView, asChild, style, ref, ...props }: RevealProps): import("react").JSX.Element;
|
|
17
|
+
export interface StaggerProps extends HTMLAttributes<HTMLElement> {
|
|
18
|
+
/** Extra wait before the first child enters, in ms. */
|
|
19
|
+
delay?: number;
|
|
20
|
+
/** Start when the group first scrolls into view instead of on mount. */
|
|
21
|
+
inView?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Longest gap between the first and the last child's start, in ms. Each step is a quarter of
|
|
24
|
+
* `--motion-duration`, shortened so long lists still fit in this span (default 1.5 durations).
|
|
25
|
+
*/
|
|
26
|
+
maxStagger?: number;
|
|
27
|
+
/** Element that wraps the children, e.g. `ul` for a list of `li`. */
|
|
28
|
+
as?: "div" | "ul" | "ol" | "section";
|
|
29
|
+
ref?: Ref<HTMLElement>;
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Its children enter one after another, like `Reveal`, with the whole sequence capped by
|
|
34
|
+
* `maxStagger`. Each child element receives `data-motion` and a `style` variable, so it must
|
|
35
|
+
* pass `style` and `data-*` props to its DOM element (every element and most components do).
|
|
36
|
+
*/
|
|
37
|
+
export declare function Stagger({ delay, inView, maxStagger, as: Tag, style, ref, children, ...props }: StaggerProps): import("react").JSX.Element;
|