@jcsoftdev/ui 0.2.3 → 0.4.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 +390 -7
- package/README.md +57 -3
- package/bin/ui-theme.mjs +1162 -25
- package/dist/ai/attachment/attachment.js +1 -1
- package/dist/ai/chat-list/group.js +3 -1
- package/dist/ai/conversation/conversation.js +1 -1
- package/dist/ai/internal/use-copy.d.ts +1 -5
- package/dist/ai/internal/use-copy.js +1 -32
- package/dist/ai/markdown/parse.js +59 -17
- package/dist/ai/source/source.js +1 -1
- package/dist/atoms/avatar/avatar.d.ts +13 -3
- package/dist/atoms/avatar/avatar.js +40 -2
- package/dist/atoms/avatar/index.d.ts +1 -1
- package/dist/atoms/avatar/index.js +3 -1
- package/dist/atoms/button/button.d.ts +4 -1
- package/dist/atoms/button/button.js +4 -2
- package/dist/atoms/checkbox/checkbox.d.ts +8 -3
- package/dist/atoms/checkbox/checkbox.js +26 -3
- package/dist/atoms/chip/chip.d.ts +19 -5
- package/dist/atoms/chip/chip.js +34 -5
- package/dist/atoms/chip/index.d.ts +1 -1
- package/dist/atoms/chip/index.js +6 -1
- package/dist/atoms/due-chip/due-chip.d.ts +31 -0
- package/dist/atoms/due-chip/due-chip.js +41 -0
- package/dist/atoms/due-chip/index.d.ts +2 -0
- package/dist/atoms/due-chip/index.js +6 -0
- package/dist/atoms/due-chip/model.d.ts +25 -0
- package/dist/atoms/due-chip/model.js +44 -0
- package/dist/atoms/icon-button/icon-button.d.ts +22 -0
- package/dist/atoms/icon-button/icon-button.js +38 -0
- package/dist/atoms/icon-button/index.d.ts +1 -0
- package/dist/atoms/icon-button/index.js +8 -0
- package/dist/atoms/index.d.ts +5 -0
- package/dist/atoms/index.js +5 -0
- package/dist/atoms/internal/hit-area.d.ts +6 -0
- package/dist/atoms/internal/hit-area.js +4 -0
- package/dist/atoms/kbd/index.d.ts +1 -0
- package/dist/atoms/kbd/index.js +4 -0
- package/dist/atoms/kbd/kbd.d.ts +7 -0
- package/dist/atoms/kbd/kbd.js +17 -0
- package/dist/atoms/radio-group/radio-group.js +6 -2
- package/dist/atoms/seal/index.d.ts +1 -0
- package/dist/atoms/seal/index.js +4 -0
- package/dist/atoms/seal/seal.d.ts +30 -0
- package/dist/atoms/seal/seal.js +71 -0
- package/dist/atoms/spinner/index.d.ts +1 -0
- package/dist/atoms/spinner/index.js +5 -0
- package/dist/atoms/spinner/spinner.d.ts +19 -0
- package/dist/atoms/spinner/spinner.js +31 -0
- package/dist/atoms/status-dot/index.d.ts +1 -1
- package/dist/atoms/status-dot/status-dot.d.ts +4 -2
- package/dist/atoms/status-dot/status-dot.js +5 -1
- package/dist/atoms/switch/switch.js +3 -1
- package/dist/calendar/date-calendar/date-calendar.d.ts +32 -0
- package/dist/calendar/date-calendar/date-calendar.js +189 -0
- package/dist/calendar/date-calendar/index.d.ts +1 -0
- package/dist/calendar/date-calendar/index.js +6 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +1 -0
- package/dist/calendar/internal/date-utils.d.ts +26 -0
- package/dist/calendar/internal/date-utils.js +95 -1
- package/dist/charts/bar-chart/bar-race-chart.js +1 -0
- package/dist/charts/beeswarm-chart/beeswarm-chart.js +1 -1
- package/dist/charts/chord-chart/chord-chart.js +13 -5
- package/dist/charts/core/cartesian/cartesian-chart.d.ts +1 -1
- package/dist/charts/core/cartesian/cartesian-chart.js +48 -11
- package/dist/charts/core/cartesian/layout.d.ts +6 -1
- package/dist/charts/core/cartesian/layout.js +14 -5
- package/dist/charts/core/cartesian/marks.d.ts +2 -2
- package/dist/charts/core/cartesian/marks.js +1 -1
- package/dist/charts/core/cartesian/types.d.ts +28 -2
- package/dist/charts/core/category-explorer.d.ts +2 -2
- package/dist/charts/core/category-explorer.js +8 -4
- package/dist/charts/core/chart-dock.d.ts +26 -0
- package/dist/charts/core/chart-dock.js +45 -0
- package/dist/charts/core/chart-frame.d.ts +9 -2
- package/dist/charts/core/chart-frame.js +105 -25
- package/dist/charts/core/distribution/explorer.d.ts +5 -2
- package/dist/charts/core/distribution/explorer.js +12 -5
- package/dist/charts/core/distribution/xy-points.js +1 -1
- package/dist/charts/core/index.d.ts +3 -0
- package/dist/charts/core/index.js +3 -0
- package/dist/charts/core/leave-grace.d.ts +11 -0
- package/dist/charts/core/leave-grace.js +26 -0
- package/dist/charts/core/nearest.d.ts +14 -0
- package/dist/charts/core/nearest.js +22 -0
- package/dist/charts/core/plot-overlay.js +9 -3
- package/dist/charts/core/pointer.test-utils.d.ts +38 -0
- package/dist/charts/core/pointer.test-utils.js +123 -0
- package/dist/charts/core/tooltip.d.ts +25 -2
- package/dist/charts/core/tooltip.js +115 -40
- package/dist/charts/core/touch-select.d.ts +20 -0
- package/dist/charts/core/touch-select.js +184 -0
- package/dist/charts/core/types.d.ts +8 -4
- package/dist/charts/core/types.js +5 -0
- package/dist/charts/core/use-index-navigation.d.ts +17 -6
- package/dist/charts/core/use-index-navigation.js +47 -10
- package/dist/charts/donut-chart/donut-chart.d.ts +5 -1
- package/dist/charts/donut-chart/donut-chart.js +40 -1
- package/dist/charts/donut-chart/slice-labels.d.ts +20 -0
- package/dist/charts/donut-chart/slice-labels.js +20 -0
- package/dist/charts/dumbbell-chart/dumbbell-chart.js +6 -3
- package/dist/charts/fill-gauge-chart/fill-gauge-chart.js +1 -0
- package/dist/charts/funnel-chart/funnel-chart.js +2 -1
- package/dist/charts/gauge-chart/gauge-chart.js +2 -1
- package/dist/charts/heatmap-chart/heatmap-chart.d.ts +4 -1
- package/dist/charts/heatmap-chart/heatmap-chart.js +3 -1
- package/dist/charts/heatmap-chart/heatmap-grid.d.ts +4 -1
- package/dist/charts/heatmap-chart/heatmap-grid.js +3 -1
- package/dist/charts/hex-tile-map/hex-tile-map.js +124 -115
- package/dist/charts/hierarchy-morph/hierarchy-morph.js +2 -1
- package/dist/charts/icicle-chart/icicle-chart.js +7 -9
- package/dist/charts/lollipop-chart/lollipop-chart.js +6 -3
- package/dist/charts/maps/geo/map-viewport.js +1 -1
- package/dist/charts/polar-area-chart/polar-area-chart.js +42 -12
- package/dist/charts/progress-units/progress-units.js +1 -0
- package/dist/charts/radar-chart/radar-chart.js +1 -1
- package/dist/charts/radial-bar-chart/radial-bar-chart.js +2 -1
- package/dist/charts/range-area-chart/range-area-chart.js +3 -2
- package/dist/charts/sankey-chart/sankey-chart.js +12 -4
- package/dist/charts/tree-chart/tree-chart.js +1 -0
- package/dist/charts/treemap-chart/treemap-chart.js +2 -7
- package/dist/charts/waterfall-chart/waterfall-chart.js +6 -3
- package/dist/containers/action-bar/action-bar.d.ts +11 -2
- package/dist/containers/action-bar/action-bar.js +4 -1
- package/dist/containers/aside/aside.d.ts +14 -0
- package/dist/containers/aside/aside.js +25 -0
- package/dist/containers/aside/index.d.ts +1 -0
- package/dist/containers/aside/index.js +5 -0
- package/dist/containers/banner/banner.d.ts +4 -1
- package/dist/containers/banner/banner.js +9 -1
- package/dist/containers/card/card.d.ts +21 -3
- package/dist/containers/card/card.js +20 -5
- package/dist/containers/description-list/description-list.d.ts +29 -6
- package/dist/containers/description-list/description-list.js +47 -6
- package/dist/containers/feed/feed.d.ts +23 -0
- package/dist/containers/feed/feed.js +77 -0
- package/dist/containers/feed/index.d.ts +2 -0
- package/dist/containers/feed/index.js +10 -0
- package/dist/containers/feed/model.d.ts +19 -0
- package/dist/containers/feed/model.js +38 -0
- package/dist/containers/grid/grid.d.ts +15 -0
- package/dist/containers/grid/grid.js +24 -0
- package/dist/containers/grid/index.d.ts +1 -0
- package/dist/containers/grid/index.js +4 -0
- package/dist/containers/index.d.ts +9 -0
- package/dist/containers/index.js +9 -0
- package/dist/containers/kpi/kpi.d.ts +60 -7
- package/dist/containers/kpi/kpi.js +142 -28
- package/dist/containers/kpi-group/index.d.ts +1 -1
- package/dist/containers/kpi-group/index.js +3 -1
- package/dist/containers/kpi-group/kpi-group.d.ts +9 -1
- package/dist/containers/kpi-group/kpi-group.js +11 -1
- package/dist/containers/list-detail/index.d.ts +1 -0
- package/dist/containers/list-detail/index.js +20 -0
- package/dist/containers/list-detail/list-detail.d.ts +55 -0
- package/dist/containers/list-detail/list-detail.js +221 -0
- package/dist/containers/note/index.d.ts +1 -0
- package/dist/containers/note/index.js +4 -0
- package/dist/containers/note/note.d.ts +13 -0
- package/dist/containers/note/note.js +27 -0
- package/dist/containers/page/index.d.ts +1 -0
- package/dist/containers/page/index.js +4 -0
- package/dist/containers/page/page.d.ts +7 -0
- package/dist/containers/page/page.js +14 -0
- package/dist/containers/page-header/page-header.d.ts +8 -3
- package/dist/containers/page-header/page-header.js +35 -8
- package/dist/containers/responsive-list/responsive-list.d.ts +1 -1
- package/dist/containers/responsive-list/responsive-list.js +6 -3
- package/dist/containers/section/index.d.ts +1 -0
- package/dist/containers/section/index.js +6 -0
- package/dist/containers/section/section.d.ts +68 -0
- package/dist/containers/section/section.js +198 -0
- package/dist/containers/shortcuts/index.d.ts +1 -0
- package/dist/containers/shortcuts/index.js +8 -0
- package/dist/containers/shortcuts/shortcuts.d.ts +18 -0
- package/dist/containers/shortcuts/shortcuts.js +50 -0
- package/dist/containers/stack/index.d.ts +1 -0
- package/dist/containers/stack/index.js +6 -0
- package/dist/containers/stack/stack.d.ts +15 -0
- package/dist/containers/stack/stack.js +43 -0
- package/dist/containers/table/selection.d.ts +9 -0
- package/dist/containers/table/selection.js +20 -0
- package/dist/containers/table/table.d.ts +66 -4
- package/dist/containers/table/table.js +128 -7
- package/dist/containers/timeline/index.d.ts +1 -1
- package/dist/containers/timeline/index.js +4 -2
- package/dist/containers/timeline/timeline.d.ts +32 -5
- package/dist/containers/timeline/timeline.js +154 -90
- package/dist/forms/chip-group/chip-group.d.ts +54 -0
- package/dist/forms/chip-group/chip-group.js +114 -0
- package/dist/forms/chip-group/index.d.ts +1 -0
- package/dist/forms/chip-group/index.js +6 -0
- package/dist/forms/combobox/combobox.d.ts +60 -0
- package/dist/forms/combobox/combobox.js +281 -0
- package/dist/forms/combobox/index.d.ts +1 -0
- package/dist/forms/combobox/index.js +6 -0
- package/dist/forms/copy-field/copy-field.d.ts +17 -0
- package/dist/forms/copy-field/copy-field.js +72 -0
- package/dist/forms/copy-field/index.d.ts +1 -0
- package/dist/forms/copy-field/index.js +4 -0
- package/dist/forms/date-picker/date-picker.d.ts +40 -0
- package/dist/forms/date-picker/date-picker.js +183 -0
- package/dist/forms/date-picker/date-time-picker.d.ts +43 -0
- package/dist/forms/date-picker/date-time-picker.js +121 -0
- package/dist/forms/date-picker/index.d.ts +2 -0
- package/dist/forms/date-picker/index.js +10 -0
- package/dist/forms/date-picker/model.d.ts +35 -0
- package/dist/forms/date-picker/model.js +83 -0
- package/dist/forms/dropzone/dropzone.d.ts +30 -2
- package/dist/forms/dropzone/dropzone.js +153 -23
- package/dist/forms/emoji-picker/emoji-picker.js +1 -1
- package/dist/forms/field/field.d.ts +16 -10
- package/dist/forms/field/field.js +41 -5
- package/dist/forms/form/form.d.ts +15 -0
- package/dist/forms/form/form.js +29 -0
- package/dist/forms/form/index.d.ts +1 -0
- package/dist/forms/form/index.js +10 -0
- package/dist/forms/index.d.ts +6 -0
- package/dist/forms/index.js +6 -0
- package/dist/forms/input/index.d.ts +1 -1
- package/dist/forms/input/index.js +6 -2
- package/dist/forms/input/input.d.ts +23 -3
- package/dist/forms/input/input.js +78 -7
- package/dist/forms/input-icon/input-icon.d.ts +1 -1
- package/dist/forms/internal/listbox-items.d.ts +18 -0
- package/dist/forms/internal/listbox-items.js +88 -0
- package/dist/forms/internal/listbox.d.ts +44 -0
- package/dist/forms/internal/listbox.js +74 -0
- package/dist/forms/number-stepper/model.d.ts +16 -0
- package/dist/forms/number-stepper/model.js +23 -0
- package/dist/forms/number-stepper/number-stepper.d.ts +36 -6
- package/dist/forms/number-stepper/number-stepper.js +86 -37
- package/dist/forms/select-menu/index.d.ts +1 -0
- package/dist/forms/select-menu/index.js +6 -0
- package/dist/forms/select-menu/select-menu.d.ts +35 -0
- package/dist/forms/select-menu/select-menu.js +230 -0
- package/dist/glass/crystal-map.d.ts +70 -0
- package/dist/glass/crystal-map.js +88 -0
- package/dist/glass/displacement-map.d.ts +117 -0
- package/dist/glass/displacement-map.js +201 -0
- package/dist/glass/index.d.ts +8 -0
- package/dist/glass/index.js +63 -0
- package/dist/glass/lens-crystal.d.ts +29 -0
- package/dist/glass/lens-crystal.js +161 -0
- package/dist/glass/lens-dispersion.d.ts +11 -0
- package/dist/glass/lens-dispersion.js +19 -0
- package/dist/glass/liquid-glass.d.ts +41 -0
- package/dist/glass/liquid-glass.js +256 -0
- package/dist/glass/liquid-motion.d.ts +53 -0
- package/dist/glass/liquid-motion.js +302 -0
- package/dist/glass/liquid-options.d.ts +162 -0
- package/dist/glass/liquid-options.js +179 -0
- package/dist/glass/refraction.d.ts +100 -0
- package/dist/glass/refraction.js +714 -0
- package/dist/glass/specular-map.d.ts +26 -0
- package/dist/glass/specular-map.js +75 -0
- package/dist/glass/spring.d.ts +79 -0
- package/dist/glass/spring.js +58 -0
- package/dist/glass/support.d.ts +13 -0
- package/dist/glass/support.js +14 -0
- package/dist/glass/use-glass-refraction.d.ts +8 -0
- package/dist/glass/use-glass-refraction.js +16 -0
- package/dist/i18n/strings.d.ts +113 -0
- package/dist/i18n/strings.js +70 -2
- package/dist/i18n/ui-strings-provider.d.ts +1 -1
- package/dist/i18n/ui-strings-provider.js +6 -2
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +4 -0
- package/dist/icons/key.d.ts +2 -0
- package/dist/icons/key.js +12 -0
- package/dist/icons/webhook.d.ts +2 -0
- package/dist/icons/webhook.js +12 -0
- package/dist/liquid/index.d.ts +3 -0
- package/dist/liquid/index.js +29 -0
- package/dist/navigation/breadcrumbs/breadcrumbs.d.ts +29 -0
- package/dist/navigation/breadcrumbs/breadcrumbs.js +70 -0
- package/dist/navigation/breadcrumbs/index.d.ts +1 -0
- package/dist/navigation/breadcrumbs/index.js +6 -0
- package/dist/navigation/index.d.ts +2 -0
- package/dist/navigation/index.js +2 -0
- package/dist/navigation/segmented/index.d.ts +1 -1
- package/dist/navigation/segmented/model.d.ts +5 -0
- package/dist/navigation/segmented/model.js +6 -0
- package/dist/navigation/segmented/segmented.d.ts +17 -3
- package/dist/navigation/segmented/segmented.js +20 -4
- package/dist/navigation/stepper/index.d.ts +1 -1
- package/dist/navigation/stepper/index.js +3 -1
- package/dist/navigation/stepper/stepper.d.ts +8 -0
- package/dist/navigation/stepper/stepper.js +68 -45
- package/dist/navigation/tabs/index.d.ts +1 -0
- package/dist/navigation/tabs/index.js +6 -0
- package/dist/navigation/tabs/tabs-nav.d.ts +37 -0
- package/dist/navigation/tabs/tabs-nav.js +57 -0
- package/dist/navigation/wizard/index.d.ts +1 -0
- package/dist/navigation/wizard/index.js +6 -0
- package/dist/navigation/wizard/model.d.ts +33 -0
- package/dist/navigation/wizard/model.js +34 -0
- package/dist/navigation/wizard/wizard.d.ts +45 -0
- package/dist/navigation/wizard/wizard.js +169 -0
- package/dist/overlays/alert-dialog/alert-dialog.d.ts +103 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +342 -0
- package/dist/overlays/alert-dialog/index.d.ts +1 -0
- package/dist/overlays/alert-dialog/index.js +26 -0
- package/dist/overlays/context-menu/context-menu.d.ts +9 -1
- package/dist/overlays/context-menu/context-menu.js +4 -1
- package/dist/overlays/dialog/dialog.d.ts +9 -1
- package/dist/overlays/dialog/dialog.js +3 -0
- package/dist/overlays/drawer/drawer.d.ts +9 -1
- package/dist/overlays/drawer/drawer.js +3 -0
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +25 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +14 -4
- package/dist/overlays/dropdown-menu/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/index.js +8 -2
- package/dist/overlays/hover-card/hover-card.d.ts +10 -1
- package/dist/overlays/hover-card/hover-card.js +4 -1
- package/dist/overlays/index.d.ts +2 -0
- package/dist/overlays/index.js +2 -0
- package/dist/overlays/popover/popover.d.ts +9 -1
- package/dist/overlays/popover/popover.js +3 -0
- package/dist/overlays/testing/index.d.ts +5 -0
- package/dist/overlays/testing/index.js +4 -0
- package/dist/overlays/toaster/index.d.ts +2 -1
- package/dist/overlays/toaster/index.js +4 -2
- package/dist/overlays/toaster/toast-store.d.ts +6 -2
- package/dist/overlays/toaster/toast.d.ts +3 -0
- package/dist/overlays/toaster/toast.js +3 -0
- package/dist/overlays/toaster/toaster.d.ts +3 -0
- package/dist/overlays/toaster/toaster.js +36 -3
- package/dist/overlays/tooltip/index.d.ts +1 -0
- package/dist/overlays/tooltip/index.js +4 -0
- package/dist/overlays/tooltip/model.d.ts +10 -0
- package/dist/overlays/tooltip/model.js +13 -0
- package/dist/overlays/tooltip/tooltip.d.ts +41 -0
- package/dist/overlays/tooltip/tooltip.js +116 -0
- package/dist/palette/command-palette/command-palette.d.ts +12 -2
- package/dist/palette/command-palette/command-palette.js +5 -0
- package/dist/primitives/command/command.d.ts +3 -2
- package/dist/primitives/command/command.js +2 -0
- package/dist/primitives/menu/menu.js +1 -1
- package/dist/primitives/popper/popper.js +5 -0
- package/dist/primitives/use-dismissable-layer.js +1 -1
- package/dist/rich-text/rich-text-editor.js +94 -8
- package/dist/rich-text/sanitize.js +70 -20
- package/dist/shell/app-shell/app-shell.d.ts +17 -0
- package/dist/shell/app-shell/app-shell.js +44 -4
- package/dist/shell/bottom-nav/bottom-nav.d.ts +34 -0
- package/dist/shell/bottom-nav/bottom-nav.js +124 -0
- package/dist/shell/bottom-nav/index.d.ts +2 -0
- package/dist/shell/bottom-nav/index.js +9 -0
- package/dist/shell/bottom-nav/split.d.ts +11 -0
- package/dist/shell/bottom-nav/split.js +10 -0
- package/dist/shell/sidebar/sidebar.d.ts +16 -2
- package/dist/shell/sidebar/sidebar.js +46 -4
- package/dist/shell/topbar/topbar.d.ts +20 -9
- package/dist/shell/topbar/topbar.js +16 -9
- package/dist/states/empty-state/empty-state.d.ts +3 -1
- package/dist/states/empty-state/empty-state.js +9 -1
- package/dist/states/error-state/error-state.d.ts +8 -1
- package/dist/states/error-state/error-state.js +15 -9
- package/dist/states/index.d.ts +1 -0
- package/dist/states/index.js +1 -0
- package/dist/states/live-status-bar/index.d.ts +1 -0
- package/dist/states/live-status-bar/index.js +6 -0
- package/dist/states/live-status-bar/live-status-bar.d.ts +17 -0
- package/dist/states/live-status-bar/live-status-bar.js +49 -0
- package/dist/states/offline-banner/offline-banner.d.ts +3 -1
- package/dist/states/offline-banner/offline-banner.js +8 -4
- package/dist/states/skeleton/skeleton.d.ts +8 -2
- package/dist/states/skeleton/skeleton.js +44 -2
- package/dist/utils/class-groups.js +17 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/material.d.ts +13 -0
- package/dist/utils/material.js +6 -0
- package/dist/utils/tone.d.ts +8 -0
- package/dist/utils/tone.js +17 -0
- package/dist/utils/use-copy.d.ts +5 -0
- package/dist/utils/use-copy.js +35 -0
- package/icons/svg/key.svg +5 -0
- package/icons/svg/webhook.svg +5 -0
- package/package.json +31 -21
- package/scripts/build-theme.d.mts +22 -0
- package/scripts/build-theme.mjs +248 -5
- package/src/ai/attachment/attachment.tsx +1 -1
- package/src/ai/chat-list/group.ts +3 -1
- package/src/ai/conversation/conversation.tsx +1 -1
- package/src/ai/internal/use-copy.ts +1 -38
- package/src/ai/markdown/parse.ts +74 -17
- package/src/ai/source/source.tsx +1 -1
- package/src/atoms/avatar/avatar.tsx +57 -4
- package/src/atoms/avatar/index.ts +8 -1
- package/src/atoms/button/button.tsx +8 -3
- package/src/atoms/checkbox/checkbox.tsx +33 -4
- package/src/atoms/chip/chip.tsx +55 -8
- package/src/atoms/chip/index.ts +9 -1
- package/src/atoms/due-chip/due-chip.tsx +75 -0
- package/src/atoms/due-chip/index.ts +2 -0
- package/src/atoms/due-chip/model.ts +67 -0
- package/src/atoms/icon-button/icon-button.tsx +58 -0
- package/src/atoms/icon-button/index.ts +6 -0
- package/src/atoms/index.ts +5 -0
- package/src/atoms/internal/hit-area.ts +7 -0
- package/src/atoms/kbd/index.ts +1 -0
- package/src/atoms/kbd/kbd.tsx +20 -0
- package/src/atoms/radio-group/radio-group.tsx +8 -2
- package/src/atoms/seal/index.ts +1 -0
- package/src/atoms/seal/seal.tsx +107 -0
- package/src/atoms/spinner/index.ts +1 -0
- package/src/atoms/spinner/spinner.tsx +49 -0
- package/src/atoms/status-dot/index.ts +1 -0
- package/src/atoms/status-dot/status-dot.tsx +15 -3
- package/src/atoms/switch/switch.tsx +3 -1
- package/src/calendar/date-calendar/date-calendar.tsx +230 -0
- package/src/calendar/date-calendar/index.ts +5 -0
- package/src/calendar/index.ts +1 -0
- package/src/calendar/internal/date-utils.ts +115 -0
- package/src/charts/README.md +21 -0
- package/src/charts/bar-chart/bar-race-chart.tsx +1 -0
- package/src/charts/beeswarm-chart/beeswarm-chart.tsx +1 -1
- package/src/charts/chord-chart/chord-chart.tsx +13 -5
- package/src/charts/core/cartesian/cartesian-chart.tsx +55 -10
- package/src/charts/core/cartesian/layout.ts +29 -10
- package/src/charts/core/cartesian/marks.tsx +3 -3
- package/src/charts/core/cartesian/types.ts +30 -2
- package/src/charts/core/category-explorer.tsx +12 -6
- package/src/charts/core/chart-dock.tsx +68 -0
- package/src/charts/core/chart-frame.tsx +116 -27
- package/src/charts/core/distribution/explorer.tsx +17 -7
- package/src/charts/core/distribution/xy-points.tsx +1 -1
- package/src/charts/core/index.ts +3 -0
- package/src/charts/core/leave-grace.ts +35 -0
- package/src/charts/core/nearest.ts +38 -0
- package/src/charts/core/plot-overlay.tsx +9 -3
- package/src/charts/core/pointer.test-utils.ts +146 -0
- package/src/charts/core/tooltip.tsx +129 -15
- package/src/charts/core/touch-select.ts +250 -0
- package/src/charts/core/types.ts +13 -4
- package/src/charts/core/use-index-navigation.ts +70 -11
- package/src/charts/donut-chart/donut-chart.tsx +53 -3
- package/src/charts/donut-chart/slice-labels.ts +39 -0
- package/src/charts/dumbbell-chart/dumbbell-chart.tsx +8 -3
- package/src/charts/fill-gauge-chart/fill-gauge-chart.tsx +1 -0
- package/src/charts/funnel-chart/funnel-chart.tsx +2 -1
- package/src/charts/gauge-chart/gauge-chart.tsx +2 -1
- package/src/charts/heatmap-chart/heatmap-chart.tsx +5 -0
- package/src/charts/heatmap-chart/heatmap-grid.tsx +5 -1
- package/src/charts/hex-tile-map/hex-tile-map.tsx +6 -1
- package/src/charts/hierarchy-morph/hierarchy-morph.tsx +2 -1
- package/src/charts/icicle-chart/icicle-chart.tsx +8 -9
- package/src/charts/lollipop-chart/lollipop-chart.tsx +8 -3
- package/src/charts/maps/geo/map-viewport.tsx +1 -1
- package/src/charts/polar-area-chart/polar-area-chart.tsx +37 -12
- package/src/charts/progress-units/progress-units.tsx +1 -0
- package/src/charts/radar-chart/radar-chart.tsx +1 -1
- package/src/charts/radial-bar-chart/radial-bar-chart.tsx +2 -1
- package/src/charts/range-area-chart/range-area-chart.tsx +3 -2
- package/src/charts/sankey-chart/sankey-chart.tsx +12 -4
- package/src/charts/tree-chart/tree-chart.tsx +1 -0
- package/src/charts/treemap-chart/treemap-chart.tsx +2 -7
- package/src/charts/waterfall-chart/waterfall-chart.tsx +8 -3
- package/src/containers/action-bar/action-bar.tsx +13 -2
- package/src/containers/aside/aside.tsx +40 -0
- package/src/containers/aside/index.ts +1 -0
- package/src/containers/banner/banner.tsx +18 -1
- package/src/containers/card/card.tsx +43 -4
- package/src/containers/description-list/description-list.tsx +85 -9
- package/src/containers/feed/feed.tsx +99 -0
- package/src/containers/feed/index.ts +8 -0
- package/src/containers/feed/model.ts +54 -0
- package/src/containers/grid/grid.tsx +37 -0
- package/src/containers/grid/index.ts +1 -0
- package/src/containers/index.ts +9 -0
- package/src/containers/kpi/kpi.tsx +231 -38
- package/src/containers/kpi-group/index.ts +7 -1
- package/src/containers/kpi-group/kpi-group.tsx +26 -1
- package/src/containers/list-detail/index.ts +15 -0
- package/src/containers/list-detail/list-detail.tsx +293 -0
- package/src/containers/note/index.ts +1 -0
- package/src/containers/note/note.tsx +38 -0
- package/src/containers/page/index.ts +1 -0
- package/src/containers/page/page.tsx +17 -0
- package/src/containers/page-header/page-header.tsx +38 -8
- package/src/containers/responsive-list/responsive-list.tsx +7 -4
- package/src/containers/section/index.ts +11 -0
- package/src/containers/section/section.tsx +281 -0
- package/src/containers/shortcuts/index.ts +6 -0
- package/src/containers/shortcuts/shortcuts.tsx +92 -0
- package/src/containers/stack/index.ts +7 -0
- package/src/containers/stack/stack.tsx +55 -0
- package/src/containers/table/selection.ts +26 -0
- package/src/containers/table/table.tsx +215 -13
- package/src/containers/timeline/index.ts +3 -0
- package/src/containers/timeline/timeline.tsx +204 -93
- package/src/forms/chip-group/chip-group.tsx +184 -0
- package/src/forms/chip-group/index.ts +8 -0
- package/src/forms/combobox/combobox.tsx +359 -0
- package/src/forms/combobox/index.ts +7 -0
- package/src/forms/copy-field/copy-field.tsx +88 -0
- package/src/forms/copy-field/index.ts +1 -0
- package/src/forms/date-picker/date-picker.tsx +239 -0
- package/src/forms/date-picker/date-time-picker.tsx +178 -0
- package/src/forms/date-picker/index.ts +10 -0
- package/src/forms/date-picker/model.ts +108 -0
- package/src/forms/dropzone/dropzone.tsx +217 -35
- package/src/forms/emoji-picker/emoji-picker.tsx +1 -1
- package/src/forms/field/field.tsx +72 -7
- package/src/forms/form/form.tsx +46 -0
- package/src/forms/form/index.ts +8 -0
- package/src/forms/index.ts +6 -0
- package/src/forms/input/index.ts +8 -1
- package/src/forms/input/input.tsx +103 -7
- package/src/forms/input-icon/input-icon.tsx +1 -1
- package/src/forms/internal/listbox-items.tsx +103 -0
- package/src/forms/internal/listbox.ts +124 -0
- package/src/forms/number-stepper/model.ts +35 -0
- package/src/forms/number-stepper/number-stepper.tsx +132 -42
- package/src/forms/select-menu/index.ts +7 -0
- package/src/forms/select-menu/select-menu.tsx +280 -0
- package/src/glass/crystal-map.ts +150 -0
- package/src/glass/displacement-map.ts +317 -0
- package/src/glass/index.ts +43 -0
- package/src/glass/lens-crystal.ts +226 -0
- package/src/glass/lens-dispersion.ts +34 -0
- package/src/glass/liquid-glass.tsx +371 -0
- package/src/glass/liquid-motion.ts +395 -0
- package/src/glass/liquid-options.ts +306 -0
- package/src/glass/refraction.ts +1010 -0
- package/src/glass/specular-map.ts +95 -0
- package/src/glass/spring.ts +98 -0
- package/src/glass/support.ts +27 -0
- package/src/glass/use-glass-refraction.ts +21 -0
- package/src/i18n/strings.ts +113 -0
- package/src/i18n/ui-strings-provider.tsx +15 -4
- package/src/icons/index.ts +2 -0
- package/src/icons/key.tsx +13 -0
- package/src/icons/webhook.tsx +13 -0
- package/src/liquid/index.ts +24 -0
- package/src/navigation/breadcrumbs/breadcrumbs.tsx +103 -0
- package/src/navigation/breadcrumbs/index.ts +8 -0
- package/src/navigation/index.ts +2 -0
- package/src/navigation/segmented/index.ts +1 -0
- package/src/navigation/segmented/model.ts +11 -0
- package/src/navigation/segmented/segmented.tsx +45 -6
- package/src/navigation/stepper/index.ts +7 -1
- package/src/navigation/stepper/stepper.tsx +41 -5
- package/src/navigation/tabs/index.ts +7 -0
- package/src/navigation/tabs/tabs-nav.tsx +131 -0
- package/src/navigation/wizard/index.ts +7 -0
- package/src/navigation/wizard/model.ts +61 -0
- package/src/navigation/wizard/wizard.tsx +222 -0
- package/src/overlays/alert-dialog/alert-dialog.tsx +486 -0
- package/src/overlays/alert-dialog/index.ts +19 -0
- package/src/overlays/context-menu/context-menu.tsx +11 -1
- package/src/overlays/dialog/dialog.tsx +10 -0
- package/src/overlays/drawer/drawer.tsx +10 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +38 -4
- package/src/overlays/dropdown-menu/index.ts +3 -0
- package/src/overlays/hover-card/hover-card.tsx +12 -1
- package/src/overlays/index.ts +2 -0
- package/src/overlays/popover/popover.tsx +10 -0
- package/src/overlays/testing/index.ts +5 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toast-store.ts +6 -2
- package/src/overlays/toaster/toast.ts +6 -0
- package/src/overlays/toaster/toaster.tsx +44 -2
- package/src/overlays/tooltip/index.ts +1 -0
- package/src/overlays/tooltip/model.ts +18 -0
- package/src/overlays/tooltip/tooltip.tsx +166 -0
- package/src/palette/command-palette/command-palette.tsx +15 -1
- package/src/primitives/command/command.tsx +4 -0
- package/src/primitives/menu/menu.tsx +1 -1
- package/src/primitives/popper/popper.tsx +10 -0
- package/src/primitives/use-dismissable-layer.ts +7 -2
- package/src/rich-text/rich-text-editor.tsx +116 -13
- package/src/rich-text/sanitize.ts +94 -23
- package/src/shell/app-shell/app-shell.tsx +60 -4
- package/src/shell/bottom-nav/bottom-nav.tsx +187 -0
- package/src/shell/bottom-nav/index.ts +8 -0
- package/src/shell/bottom-nav/split.ts +20 -0
- package/src/shell/sidebar/sidebar.tsx +51 -5
- package/src/shell/topbar/topbar.tsx +81 -58
- package/src/states/empty-state/empty-state.tsx +11 -1
- package/src/states/error-state/error-state.tsx +23 -8
- package/src/states/index.ts +1 -0
- package/src/states/live-status-bar/index.ts +6 -0
- package/src/states/live-status-bar/live-status-bar.tsx +62 -0
- package/src/states/offline-banner/offline-banner.tsx +13 -5
- package/src/states/skeleton/skeleton.tsx +68 -2
- package/src/utils/class-groups.ts +17 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/material.ts +16 -0
- package/src/utils/tone.ts +29 -0
- package/src/utils/use-copy.ts +38 -0
- package/styles/Theme.kt +64 -3
- package/styles/base.css +51 -0
- package/styles/tailwind.css +836 -0
- package/styles/theme.css +579 -34
- package/styles/tokens.css +788 -15
- package/tokens/default.json +918 -29
- package/scripts/build-theme.d.ts +0 -18
package/bin/ui-theme.mjs
CHANGED
|
@@ -1,48 +1,1185 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __esm = (fn, res, err) => function __init() {
|
|
5
|
+
if (err) throw err[0];
|
|
6
|
+
try {
|
|
7
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
+
} catch (e) {
|
|
9
|
+
throw err = [e], e;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// ../ui-tokens/dist/color.js
|
|
18
|
+
function parseHex(value) {
|
|
19
|
+
const m = HEX.exec(value.trim());
|
|
20
|
+
if (!m)
|
|
21
|
+
throw new TypeError(`Expected a hex color like "#6d28d9", got ${JSON.stringify(value)}`);
|
|
22
|
+
let hex = m[1];
|
|
23
|
+
if (hex.length === 3)
|
|
24
|
+
hex = [...hex].map((ch) => ch + ch).join("");
|
|
25
|
+
const n = Number.parseInt(hex, 16);
|
|
26
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
27
|
+
}
|
|
28
|
+
function formatHex([r, g, b]) {
|
|
29
|
+
return `#${[r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("")}`;
|
|
30
|
+
}
|
|
31
|
+
function hexToOklch(hex) {
|
|
32
|
+
const [r, g, b] = parseHex(hex).map(toLinear);
|
|
33
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
34
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
35
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
36
|
+
const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;
|
|
37
|
+
const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
38
|
+
const bb = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
39
|
+
const c = Math.hypot(a, bb);
|
|
40
|
+
const h = c < 1e-4 ? 0 : (Math.atan2(bb, a) * 180 / Math.PI + 360) % 360;
|
|
41
|
+
return { l: L, c, h };
|
|
42
|
+
}
|
|
43
|
+
function oklchToLinear({ l, c, h }) {
|
|
44
|
+
const a = c * Math.cos(h * Math.PI / 180);
|
|
45
|
+
const b = c * Math.sin(h * Math.PI / 180);
|
|
46
|
+
const l_ = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
47
|
+
const m_ = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
48
|
+
const s_ = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
49
|
+
return [
|
|
50
|
+
4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_,
|
|
51
|
+
-1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_,
|
|
52
|
+
-0.0041960863 * l_ - 0.7034186147 * m_ + 1.707614701 * s_
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
function oklchToHex(color) {
|
|
56
|
+
const l = Math.min(1, Math.max(0, color.l));
|
|
57
|
+
const h = (color.h % 360 + 360) % 360;
|
|
58
|
+
let c = Math.max(0, color.c);
|
|
59
|
+
if (!inGamut(oklchToLinear({ l, c, h }))) {
|
|
60
|
+
let lo = 0;
|
|
61
|
+
let hi = c;
|
|
62
|
+
for (let i = 0; i < 24; i++) {
|
|
63
|
+
const mid = (lo + hi) / 2;
|
|
64
|
+
if (inGamut(oklchToLinear({ l, c: mid, h })))
|
|
65
|
+
lo = mid;
|
|
66
|
+
else
|
|
67
|
+
hi = mid;
|
|
68
|
+
}
|
|
69
|
+
c = lo;
|
|
70
|
+
}
|
|
71
|
+
const [r, g, b] = oklchToLinear({ l, c, h });
|
|
72
|
+
return formatHex([byte(r), byte(g), byte(b)]);
|
|
73
|
+
}
|
|
74
|
+
function relativeLuminance(hex) {
|
|
75
|
+
const [r, g, b] = parseHex(hex).map(toLinear);
|
|
76
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
77
|
+
}
|
|
78
|
+
function contrastRatio(a, b) {
|
|
79
|
+
const la = relativeLuminance(a);
|
|
80
|
+
const lb = relativeLuminance(b);
|
|
81
|
+
return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
|
|
82
|
+
}
|
|
83
|
+
function solveTone({ hue, chroma, from, direction, against, min }) {
|
|
84
|
+
const step = 4e-3;
|
|
85
|
+
let last = oklchToHex({ l: from, c: chroma, h: hue });
|
|
86
|
+
for (let l = from; l >= -step && l <= 1 + step; l += step * direction) {
|
|
87
|
+
last = oklchToHex({ l: Math.min(1, Math.max(0, l)), c: chroma, h: hue });
|
|
88
|
+
if (against.every((bg) => contrastRatio(last, bg) >= min))
|
|
89
|
+
return last;
|
|
90
|
+
}
|
|
91
|
+
return last;
|
|
92
|
+
}
|
|
93
|
+
var HEX, toLinear, fromLinear, byte, EPS, inGamut;
|
|
94
|
+
var init_color = __esm({
|
|
95
|
+
"../ui-tokens/dist/color.js"() {
|
|
96
|
+
"use strict";
|
|
97
|
+
HEX = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
98
|
+
toLinear = (v) => {
|
|
99
|
+
const s = v / 255;
|
|
100
|
+
return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
101
|
+
};
|
|
102
|
+
fromLinear = (v) => v <= 31308e-7 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - 0.055;
|
|
103
|
+
byte = (v) => Math.round(Math.min(1, Math.max(0, fromLinear(v))) * 255);
|
|
104
|
+
EPS = 1e-6;
|
|
105
|
+
inGamut = (rgb) => rgb.every((v) => v >= -EPS && v <= 1 + EPS);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// ../ui-tokens/dist/audit.js
|
|
110
|
+
function auditTheme(theme, pairs = CONTRAST_PAIRS) {
|
|
111
|
+
const byName = new Map(theme.color.tokens.map((t) => [t.name, t.value]));
|
|
112
|
+
const violations = [];
|
|
113
|
+
for (const scheme of ["light", "dark"]) {
|
|
114
|
+
for (const pair of pairs) {
|
|
115
|
+
const fg = byName.get(pair.fg)?.[scheme];
|
|
116
|
+
const bg = byName.get(pair.bg)?.[scheme];
|
|
117
|
+
const ratio = fg && bg && HEX_ONLY.test(fg) && HEX_ONLY.test(bg) ? contrastRatio(fg, bg) : 0;
|
|
118
|
+
if (ratio < pair.min)
|
|
119
|
+
violations.push({ ...pair, scheme, ratio });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return violations;
|
|
123
|
+
}
|
|
124
|
+
var text, ui, PAGE, SURFACES, STATUS, CONTRAST_PAIRS, HEX_ONLY;
|
|
125
|
+
var init_audit = __esm({
|
|
126
|
+
"../ui-tokens/dist/audit.js"() {
|
|
127
|
+
"use strict";
|
|
128
|
+
init_color();
|
|
129
|
+
text = (fg, bgs) => bgs.map((bg) => ({ fg, bg, min: 4.5, kind: "text" }));
|
|
130
|
+
ui = (fg, bgs) => bgs.map((bg) => ({ fg, bg, min: 3, kind: "ui" }));
|
|
131
|
+
PAGE = ["bg", "surface"];
|
|
132
|
+
SURFACES = ["bg", "surface", "surface-2", "sunken", "float"];
|
|
133
|
+
STATUS = ["danger", "warning", "info", "success"];
|
|
134
|
+
CONTRAST_PAIRS = [
|
|
135
|
+
...text("ink", SURFACES),
|
|
136
|
+
...text("ink-2", SURFACES),
|
|
137
|
+
...text("ink-3", SURFACES),
|
|
138
|
+
...text("on-accent", ["accent"]),
|
|
139
|
+
...text("accent-ink", [...PAGE, "surface-2", "accent-soft"]),
|
|
140
|
+
...text("toast-ink", ["toast-bg"]),
|
|
141
|
+
...STATUS.flatMap((s) => text(s, [...PAGE, `${s}-soft`])),
|
|
142
|
+
...ui("line-control", [...PAGE, "surface-2", "float"]),
|
|
143
|
+
...ui("accent-word", [...PAGE, "float"]),
|
|
144
|
+
...["1", "2", "3", "4", "5", "6", "7"].flatMap((n) => ui(`chart-cat-${n}`, PAGE)),
|
|
145
|
+
...["reserve"].flatMap((n) => ui(`chart-cat-${n}`, PAGE)),
|
|
146
|
+
...["up", "down", "total"].flatMap((n) => ui(`chart-${n}`, PAGE))
|
|
147
|
+
];
|
|
148
|
+
HEX_ONLY = /^#[0-9a-f]{6}$/i;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// ../ui-tokens/dist/create-theme.js
|
|
153
|
+
function normalizeSeeds(seeds2) {
|
|
154
|
+
if (!seeds2 || typeof seeds2 !== "object")
|
|
155
|
+
throw new TypeError("createTheme expects a seeds object");
|
|
156
|
+
if (seeds2.contrast !== void 0 && seeds2.contrast !== "AA") {
|
|
157
|
+
throw new RangeError(`Unsupported contrast "${String(seeds2.contrast)}": only "AA" exists in v1`);
|
|
158
|
+
}
|
|
159
|
+
const brandHex = formatHex(parseHex(seeds2.brand));
|
|
160
|
+
const brand = hexToOklch(brandHex);
|
|
161
|
+
const neutralSeed = seeds2.neutral ? hexToOklch(seeds2.neutral) : void 0;
|
|
162
|
+
const dangerSeed = seeds2.danger ? hexToOklch(seeds2.danger) : void 0;
|
|
163
|
+
const neutral = neutralSeed ? { l: 0, c: Math.min(neutralSeed.c, 0.04), h: neutralSeed.h } : { l: 0, c: Math.min(0.012, brand.c * 0.12), h: brand.h };
|
|
164
|
+
const accent2 = seeds2.accent ? formatHex(parseHex(seeds2.accent)) : oklchToHex({ ...brand, h: brand.h + 38 });
|
|
165
|
+
const danger = dangerSeed ?? { l: 0, c: 0.19, h: 27 };
|
|
166
|
+
return { brandHex, brand, neutral, accent2, danger };
|
|
167
|
+
}
|
|
168
|
+
function palette(scheme, seeds2) {
|
|
169
|
+
const { brandHex, brand, neutral, accent2, danger } = seeds2;
|
|
170
|
+
const light = scheme === "light";
|
|
171
|
+
const dir = light ? -1 : 1;
|
|
172
|
+
const grey = (l) => oklchToHex({ l, c: neutral.c, h: neutral.h });
|
|
173
|
+
const p = {};
|
|
174
|
+
const get = (...names) => names.map((n) => p[n]);
|
|
175
|
+
Object.assign(p, light ? {
|
|
176
|
+
bg: grey(0.965),
|
|
177
|
+
surface: "#ffffff",
|
|
178
|
+
"surface-2": grey(0.955),
|
|
179
|
+
sunken: grey(0.925),
|
|
180
|
+
float: "#ffffff",
|
|
181
|
+
line: grey(0.925),
|
|
182
|
+
"line-strong": grey(0.875),
|
|
183
|
+
track: grey(0.91),
|
|
184
|
+
"seg-track": grey(0.93),
|
|
185
|
+
"seg-on": "#ffffff",
|
|
186
|
+
hatch: grey(0.935)
|
|
187
|
+
} : {
|
|
188
|
+
bg: "#000000",
|
|
189
|
+
surface: grey(0.18),
|
|
190
|
+
"surface-2": grey(0.235),
|
|
191
|
+
sunken: grey(0.27),
|
|
192
|
+
float: grey(0.205),
|
|
193
|
+
line: grey(0.245),
|
|
194
|
+
"line-strong": grey(0.33),
|
|
195
|
+
track: grey(0.27),
|
|
196
|
+
"seg-track": grey(0.2),
|
|
197
|
+
"seg-on": grey(0.3),
|
|
198
|
+
hatch: grey(0.22)
|
|
199
|
+
});
|
|
200
|
+
p.hair = light ? rgba("0,0,0", 0.11) : rgba("255,255,255", 0.1);
|
|
201
|
+
p.ink = light ? "#000000" : grey(0.96);
|
|
202
|
+
const surfaces = get(...SURFACES2);
|
|
203
|
+
const tint = { hue: neutral.h, chroma: neutral.c };
|
|
204
|
+
p["ink-2"] = solveTone({
|
|
205
|
+
...tint,
|
|
206
|
+
from: light ? 0.45 : 0.8,
|
|
207
|
+
direction: dir,
|
|
208
|
+
against: surfaces,
|
|
209
|
+
min: AA_TEXT
|
|
210
|
+
});
|
|
211
|
+
p["ink-3"] = solveTone({
|
|
212
|
+
...tint,
|
|
213
|
+
from: light ? 0.53 : 0.68,
|
|
214
|
+
direction: dir,
|
|
215
|
+
against: surfaces,
|
|
216
|
+
min: AA_TEXT
|
|
217
|
+
});
|
|
218
|
+
p["line-control"] = solveTone({
|
|
219
|
+
...tint,
|
|
220
|
+
from: light ? 0.68 : 0.5,
|
|
221
|
+
direction: dir,
|
|
222
|
+
against: get(...PAGE2, "surface-2", "float"),
|
|
223
|
+
min: AA_UI
|
|
224
|
+
});
|
|
225
|
+
p.accent = brandHex;
|
|
226
|
+
const deep = solveTone({
|
|
227
|
+
hue: brand.h,
|
|
228
|
+
chroma: brand.c * 0.4,
|
|
229
|
+
from: 0.28,
|
|
230
|
+
direction: -1,
|
|
231
|
+
against: [brandHex],
|
|
232
|
+
min: AA_TEXT
|
|
233
|
+
});
|
|
234
|
+
const pale = solveTone({
|
|
235
|
+
hue: brand.h,
|
|
236
|
+
chroma: brand.c * 0.15,
|
|
237
|
+
from: 0.97,
|
|
238
|
+
direction: 1,
|
|
239
|
+
against: [brandHex],
|
|
240
|
+
min: AA_TEXT
|
|
241
|
+
});
|
|
242
|
+
p["on-accent"] = contrastRatio(deep, brandHex) >= AA_TEXT ? deep : pale;
|
|
243
|
+
p["accent-soft"] = oklchToHex({
|
|
244
|
+
l: light ? 0.96 : 0.2,
|
|
245
|
+
c: Math.min(brand.c * (light ? 0.22 : 0.3), 0.05),
|
|
246
|
+
h: brand.h
|
|
247
|
+
});
|
|
248
|
+
p["accent-line"] = oklchToHex({ l: light ? 0.86 : 0.32, c: brand.c * 0.35, h: brand.h });
|
|
249
|
+
p["accent-ink"] = solveTone({
|
|
250
|
+
hue: brand.h,
|
|
251
|
+
chroma: brand.c,
|
|
252
|
+
from: light ? Math.min(brand.l, 0.55) : Math.max(brand.l, 0.8),
|
|
253
|
+
direction: dir,
|
|
254
|
+
against: [...get(...PAGE2, "surface-2"), p["accent-soft"]],
|
|
255
|
+
min: AA_TEXT
|
|
256
|
+
});
|
|
257
|
+
p["accent-word"] = solveTone({
|
|
258
|
+
hue: brand.h,
|
|
259
|
+
chroma: brand.c,
|
|
260
|
+
from: brand.l,
|
|
261
|
+
direction: dir,
|
|
262
|
+
against: get(...PAGE2, "float"),
|
|
263
|
+
min: AA_UI
|
|
264
|
+
});
|
|
265
|
+
p["accent-2"] = accent2;
|
|
266
|
+
const status = (name, hue, chroma) => {
|
|
267
|
+
p[`${name}-soft`] = oklchToHex({
|
|
268
|
+
l: light ? 0.955 : 0.19,
|
|
269
|
+
c: Math.min(chroma * (light ? 0.25 : 0.33), 0.05),
|
|
270
|
+
h: hue
|
|
271
|
+
});
|
|
272
|
+
p[name] = solveTone({
|
|
273
|
+
hue,
|
|
274
|
+
chroma,
|
|
275
|
+
from: light ? 0.5 : 0.8,
|
|
276
|
+
direction: dir,
|
|
277
|
+
against: [...get(...PAGE2), p[`${name}-soft`]],
|
|
278
|
+
min: AA_TEXT
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
status("danger", danger.h, danger.c);
|
|
282
|
+
for (const [name, [hue, chroma]] of Object.entries(STATUS2))
|
|
283
|
+
status(name, hue, chroma);
|
|
284
|
+
p.scrim = light ? rgba("0,0,0", 0.2) : rgba("0,0,0", 0.72);
|
|
285
|
+
p["toast-bg"] = light ? "#000000" : grey(0.24);
|
|
286
|
+
p["toast-ink"] = solveTone({
|
|
287
|
+
...tint,
|
|
288
|
+
from: 0.97,
|
|
289
|
+
direction: 1,
|
|
290
|
+
against: [p["toast-bg"]],
|
|
291
|
+
min: AA_TEXT
|
|
292
|
+
});
|
|
293
|
+
CHART_CATEGORIES.forEach(([hue, chroma], i) => {
|
|
294
|
+
p[`chart-cat-${i + 1}`] = solveTone({
|
|
295
|
+
hue,
|
|
296
|
+
chroma,
|
|
297
|
+
from: light ? 0.6 : 0.78,
|
|
298
|
+
direction: dir,
|
|
299
|
+
against: get(...PAGE2),
|
|
300
|
+
min: AA_UI
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
p["chart-cat-reserve"] = p["accent-word"];
|
|
304
|
+
p["chart-grid"] = light ? rgba("0,0,0", 0.06) : rgba("255,255,255", 0.07);
|
|
305
|
+
p["chart-crosshair"] = light ? rgba("0,0,0", 0.3) : rgba("255,255,255", 0.34);
|
|
306
|
+
const chart = (name, hue, chroma, from) => {
|
|
307
|
+
p[name] = solveTone({
|
|
308
|
+
hue,
|
|
309
|
+
chroma,
|
|
310
|
+
from: light ? from : 1 - from * 0.55,
|
|
311
|
+
direction: dir,
|
|
312
|
+
against: get(...PAGE2),
|
|
313
|
+
min: AA_UI
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
chart("chart-up", 155, 0.15, 0.6);
|
|
317
|
+
chart("chart-down", danger.h, Math.min(danger.c, 0.17), 0.6);
|
|
318
|
+
chart("chart-total", neutral.h, 0.02, 0.4);
|
|
319
|
+
return p;
|
|
320
|
+
}
|
|
321
|
+
function createTheme(seeds2) {
|
|
322
|
+
const normalized = normalizeSeeds(seeds2);
|
|
323
|
+
const light = palette("light", normalized);
|
|
324
|
+
const dark = palette("dark", normalized);
|
|
325
|
+
const tokens2 = USAGE.map(([name, usage]) => ({
|
|
326
|
+
name,
|
|
327
|
+
value: { light: light[name], dark: dark[name] },
|
|
328
|
+
usage
|
|
329
|
+
}));
|
|
330
|
+
return {
|
|
331
|
+
name: seeds2.name ?? `Generated ${normalized.brandHex}`,
|
|
332
|
+
version: 2,
|
|
333
|
+
color: {
|
|
334
|
+
themes: [
|
|
335
|
+
{ id: "light", name: "Light" },
|
|
336
|
+
{ id: "dark", name: "Dark" }
|
|
337
|
+
],
|
|
338
|
+
tokens: tokens2
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
var PAGE2, SURFACES2, AA_TEXT, AA_UI, CHART_CATEGORIES, STATUS2, rgba, USAGE;
|
|
343
|
+
var init_create_theme = __esm({
|
|
344
|
+
"../ui-tokens/dist/create-theme.js"() {
|
|
345
|
+
"use strict";
|
|
346
|
+
init_color();
|
|
347
|
+
PAGE2 = ["bg", "surface"];
|
|
348
|
+
SURFACES2 = ["bg", "surface", "surface-2", "sunken", "float"];
|
|
349
|
+
AA_TEXT = 4.55;
|
|
350
|
+
AA_UI = 3.05;
|
|
351
|
+
CHART_CATEGORIES = [
|
|
352
|
+
[245, 0.12],
|
|
353
|
+
[165, 0.12],
|
|
354
|
+
[75, 0.13],
|
|
355
|
+
[290, 0.14],
|
|
356
|
+
[340, 0.14],
|
|
357
|
+
[255, 0.03],
|
|
358
|
+
[125, 0.13]
|
|
359
|
+
];
|
|
360
|
+
STATUS2 = {
|
|
361
|
+
warning: [85, 0.15],
|
|
362
|
+
info: [255, 0.16],
|
|
363
|
+
success: [150, 0.15]
|
|
364
|
+
};
|
|
365
|
+
rgba = (rgb, alpha) => `rgba(${rgb},${alpha})`;
|
|
366
|
+
USAGE = [
|
|
367
|
+
["bg", "Page background."],
|
|
368
|
+
["surface", "Cards, sidebar, fields and rows."],
|
|
369
|
+
["surface-2", "Hovered row, neutral chip and control fill inside a card."],
|
|
370
|
+
["sunken", "Sunken areas: neutral avatar and drop zones."],
|
|
371
|
+
["float", "Things that float above the page: dialogs, sheets and menus."],
|
|
372
|
+
["line", "Decorative dividers and borders."],
|
|
373
|
+
["line-strong", "Stronger decorative border."],
|
|
374
|
+
[
|
|
375
|
+
"line-control",
|
|
376
|
+
"Border of text fields, selects and checkboxes (3:1 on bg, surface, surface-2 and float)."
|
|
377
|
+
],
|
|
378
|
+
["hair", "Hairline around cards and secondary buttons."],
|
|
379
|
+
["track", "Progress bar track."],
|
|
380
|
+
["seg-track", "Segmented control tray."],
|
|
381
|
+
["seg-on", "Selected segmented option."],
|
|
382
|
+
["ink", "Primary text."],
|
|
383
|
+
["ink-2", "Secondary text (4.5:1 on every surface)."],
|
|
384
|
+
["ink-3", "Metadata text (4.5:1 on every surface)."],
|
|
385
|
+
["accent", "Brand fill: the primary action and the selected state."],
|
|
386
|
+
["on-accent", "Text and icons on an accent fill (4.5:1)."],
|
|
387
|
+
[
|
|
388
|
+
"accent-ink",
|
|
389
|
+
"Brand-colored text and focus ring (4.5:1 on bg, surface, surface-2 and accent-soft)."
|
|
390
|
+
],
|
|
391
|
+
["accent-word", "Brand-colored large text and the on switch (3:1 on bg, surface and float)."],
|
|
392
|
+
["accent-soft", "Soft brand background."],
|
|
393
|
+
["accent-line", "Brand hairline."],
|
|
394
|
+
["accent-2", "Neighbour tone for gradients and illustrations."],
|
|
395
|
+
["danger", "Error text and icons (4.5:1 on surface and danger-soft)."],
|
|
396
|
+
["danger-soft", "Error background."],
|
|
397
|
+
["warning", "Warning text and icons (4.5:1 on surface and warning-soft)."],
|
|
398
|
+
["warning-soft", "Warning background."],
|
|
399
|
+
["info", "Informational text and icons (4.5:1 on surface and info-soft)."],
|
|
400
|
+
["info-soft", "Informational background."],
|
|
401
|
+
["success", "Success text and icons (4.5:1 on surface and success-soft)."],
|
|
402
|
+
["success-soft", "Success background."],
|
|
403
|
+
["hatch", "Diagonal hatch for unavailable time."],
|
|
404
|
+
["scrim", "Veil behind dialogs and sheets."],
|
|
405
|
+
["toast-bg", "Toast background."],
|
|
406
|
+
["toast-ink", "Toast text (4.5:1 on toast-bg)."],
|
|
407
|
+
...CHART_CATEGORIES.map((_, i) => [
|
|
408
|
+
`chart-cat-${i + 1}`,
|
|
409
|
+
`Charts: categorical series ${i + 2} (3:1 on bg and surface).`
|
|
410
|
+
]),
|
|
411
|
+
["chart-cat-reserve", "Charts: reserve category color, equal to accent-word."],
|
|
412
|
+
["chart-grid", "Charts: background guide lines."],
|
|
413
|
+
["chart-crosshair", "Charts: pointer crosshair."],
|
|
414
|
+
["chart-up", "Charts: rising value (3:1)."],
|
|
415
|
+
["chart-down", "Charts: falling value (3:1)."],
|
|
416
|
+
["chart-total", "Charts: totals and unchanged values (3:1)."]
|
|
417
|
+
];
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// ../ui-tokens/dist/css.js
|
|
422
|
+
function toCss(theme, { selector = ":root", scheme = "auto" } = {}) {
|
|
423
|
+
if (scheme === "light" || scheme === "dark")
|
|
424
|
+
return `${block(selector, theme, scheme)}
|
|
425
|
+
`;
|
|
426
|
+
const notLight = `${selector}:where(:not([data-theme="light"]):not([data-theme="light"] *))`;
|
|
427
|
+
const forcedDark = `${selector}:where([data-theme="dark"]),
|
|
428
|
+
:where([data-theme="dark"]) ${selector}`;
|
|
429
|
+
const nestedLight = `${selector} :where([data-theme="light"])`;
|
|
430
|
+
const nestedDark = `${selector} :where([data-theme="dark"])`;
|
|
431
|
+
const indented = block(notLight, theme, "dark").split("\n").map((l) => ` ${l}`).join("\n");
|
|
432
|
+
return [
|
|
433
|
+
block(selector, theme, "light"),
|
|
434
|
+
`@media (prefers-color-scheme: dark) {
|
|
435
|
+
${indented}
|
|
436
|
+
}`,
|
|
437
|
+
block(forcedDark, theme, "dark"),
|
|
438
|
+
block(nestedLight, theme, "light"),
|
|
439
|
+
block(nestedDark, theme, "dark"),
|
|
440
|
+
""
|
|
441
|
+
].join("\n");
|
|
442
|
+
}
|
|
443
|
+
var block;
|
|
444
|
+
var init_css = __esm({
|
|
445
|
+
"../ui-tokens/dist/css.js"() {
|
|
446
|
+
"use strict";
|
|
447
|
+
block = (selector, theme, scheme) => `${selector} {
|
|
448
|
+
${theme.color.tokens.map((t) => ` --${t.name}: ${t.value[scheme]};`).join("\n")}
|
|
449
|
+
}`;
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
// ../ui-tokens/dist/merge.js
|
|
454
|
+
function withTheme(base, theme) {
|
|
455
|
+
const generated = new Set(theme.color.tokens.map((t) => t.name));
|
|
456
|
+
const kept = (base.color?.tokens ?? []).filter((t) => !generated.has(t.name));
|
|
457
|
+
const tokens2 = [...theme.color.tokens, ...kept];
|
|
458
|
+
return {
|
|
459
|
+
...base,
|
|
460
|
+
name: theme.name,
|
|
461
|
+
color: { ...base.color ?? {}, themes: theme.color.themes, tokens: tokens2 }
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
var init_merge = __esm({
|
|
465
|
+
"../ui-tokens/dist/merge.js"() {
|
|
466
|
+
"use strict";
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
// ../ui-tokens/dist/index.js
|
|
471
|
+
var dist_exports = {};
|
|
472
|
+
__export(dist_exports, {
|
|
473
|
+
CONTRAST_PAIRS: () => CONTRAST_PAIRS,
|
|
474
|
+
auditTheme: () => auditTheme,
|
|
475
|
+
contrastRatio: () => contrastRatio,
|
|
476
|
+
createTheme: () => createTheme,
|
|
477
|
+
hexToOklch: () => hexToOklch,
|
|
478
|
+
oklchToHex: () => oklchToHex,
|
|
479
|
+
toCss: () => toCss,
|
|
480
|
+
withTheme: () => withTheme
|
|
481
|
+
});
|
|
482
|
+
var init_dist = __esm({
|
|
483
|
+
"../ui-tokens/dist/index.js"() {
|
|
484
|
+
"use strict";
|
|
485
|
+
init_audit();
|
|
486
|
+
init_color();
|
|
487
|
+
init_create_theme();
|
|
488
|
+
init_css();
|
|
489
|
+
init_merge();
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
// ../ui-tokens/bin/ui-theme.mjs
|
|
2
494
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
495
|
import { dirname, join, resolve } from "node:path";
|
|
4
496
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { buildTheme } from "../scripts/build-theme.mjs";
|
|
6
497
|
|
|
7
|
-
|
|
498
|
+
// ../ui-tokens/scripts/build-theme.mjs
|
|
499
|
+
var PALETTE_ROLES = {
|
|
500
|
+
fill: "accent",
|
|
501
|
+
deep: "on-accent",
|
|
502
|
+
ink: "accent-ink",
|
|
503
|
+
word: "accent-word",
|
|
504
|
+
soft: "accent-soft",
|
|
505
|
+
line: "accent-line",
|
|
506
|
+
2: "accent-2"
|
|
507
|
+
};
|
|
508
|
+
var isThemed = (value) => value !== null && typeof value === "object";
|
|
509
|
+
var valueFor = (token, theme, base) => {
|
|
510
|
+
if (!isThemed(token.value)) return token.value;
|
|
511
|
+
return token.value[theme] ?? token.value[base];
|
|
512
|
+
};
|
|
513
|
+
var themeOf = (tokens2) => {
|
|
514
|
+
const themes = tokens2.color?.themes?.map((t) => t.id) ?? ["light", "dark"];
|
|
515
|
+
return { base: themes[0], others: themes.slice(1) };
|
|
516
|
+
};
|
|
517
|
+
var TONE_NAME = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
518
|
+
var TONE_ROLES = ["fill", "soft", "ink"];
|
|
519
|
+
function tonesOf(tokens2) {
|
|
520
|
+
const out2 = [];
|
|
521
|
+
for (const [name, roles] of Object.entries(tokens2.tonePalettes ?? {})) {
|
|
522
|
+
if (!TONE_NAME.test(name)) {
|
|
523
|
+
throw new Error(
|
|
524
|
+
`tonePalettes: "${name}" must be kebab-case (lowercase letters, digits, hyphens)`
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
for (const role of Object.keys(roles ?? {})) {
|
|
528
|
+
if (!TONE_ROLES.includes(role)) {
|
|
529
|
+
throw new Error(`tonePalettes.${name}: unknown role "${role}" (expected fill, soft, ink)`);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
for (const role of ["fill", "soft"]) {
|
|
533
|
+
if (roles?.[role] === void 0)
|
|
534
|
+
throw new Error(`tonePalettes.${name}: "${role}" is required`);
|
|
535
|
+
}
|
|
536
|
+
const value = { fill: roles.fill, soft: roles.soft, ink: roles.ink ?? roles.fill };
|
|
537
|
+
out2.push(
|
|
538
|
+
{ name: `tone-${name}`, value: value.fill },
|
|
539
|
+
{ name: `tone-${name}-soft`, value: value.soft },
|
|
540
|
+
{ name: `tone-${name}-ink`, value: value.ink }
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
return out2;
|
|
544
|
+
}
|
|
545
|
+
var allTokens = (tokens2) => [
|
|
546
|
+
...tokens2.color?.tokens ?? [],
|
|
547
|
+
...tonesOf(tokens2),
|
|
548
|
+
...tokens2.shadow?.tokens ?? [],
|
|
549
|
+
...tokens2.radius?.tokens ?? [],
|
|
550
|
+
...tokens2.spacing?.tokens ?? [],
|
|
551
|
+
...tokens2.size?.tokens ?? [],
|
|
552
|
+
...tokens2.styles?.tokens ?? [],
|
|
553
|
+
...tokens2.styles?.density?.tokens ?? []
|
|
554
|
+
];
|
|
555
|
+
var typeStyles = (tokens2) => (tokens2.type?.groups ?? []).flatMap(
|
|
556
|
+
(g) => g.styles.map((s) => ({ ...s, family: s.family ?? g.family ?? "sans" }))
|
|
557
|
+
);
|
|
558
|
+
function palettesOf(tokens2) {
|
|
559
|
+
const out2 = /* @__PURE__ */ new Map();
|
|
560
|
+
for (const t of tokens2.color?.tokens ?? []) {
|
|
561
|
+
const m = /^pal-(.+)-(fill|deep|ink|word|soft|line|2)$/.exec(t.name);
|
|
562
|
+
if (!m) continue;
|
|
563
|
+
if (!out2.has(m[1])) out2.set(m[1], {});
|
|
564
|
+
out2.get(m[1])[m[2]] = t.name;
|
|
565
|
+
}
|
|
566
|
+
return out2;
|
|
567
|
+
}
|
|
568
|
+
var decls = (list) => list.map(([k, v]) => ` --${k}: ${v};`).join("\n");
|
|
569
|
+
var attrSelector = (attr, id) => `:root[${attr}="${id}"],
|
|
570
|
+
[${attr}="${id}"]`;
|
|
571
|
+
var indent = (text2) => text2.split("\n").map((l) => l ? ` ${l}` : l).join("\n");
|
|
572
|
+
function variantBlocks(attr, id, entries, { base, others }) {
|
|
573
|
+
const flat = entries.map(([name, v]) => [
|
|
574
|
+
name,
|
|
575
|
+
isThemed(v) ? v[base] ?? Object.values(v)[0] : v
|
|
576
|
+
]);
|
|
577
|
+
const out2 = [`${attrSelector(attr, id)} {
|
|
578
|
+
${decls(flat)}
|
|
579
|
+
}`];
|
|
580
|
+
for (const theme of others) {
|
|
581
|
+
const themed = entries.filter(([, v]) => isThemed(v) && theme in v).map(([n, v]) => [n, v[theme]]);
|
|
582
|
+
if (!themed.length) continue;
|
|
583
|
+
const at = (root) => `${root}[${attr}="${id}"],
|
|
584
|
+
${root} [${attr}="${id}"]`;
|
|
585
|
+
if (theme === "dark") {
|
|
586
|
+
const sel = at(`:root:not([data-theme="${base}"])`);
|
|
587
|
+
out2.push(
|
|
588
|
+
`@media (prefers-color-scheme: dark) {
|
|
589
|
+
${indent(`${sel} {
|
|
590
|
+
${decls(themed)}
|
|
591
|
+
}`)}
|
|
592
|
+
}`
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
out2.push(`${at(`:root[data-theme="${theme}"]`)} {
|
|
596
|
+
${decls(themed)}
|
|
597
|
+
}`);
|
|
598
|
+
}
|
|
599
|
+
return out2;
|
|
600
|
+
}
|
|
601
|
+
function stylesOf(tokens2) {
|
|
602
|
+
const styles = tokens2.styles;
|
|
603
|
+
if (!styles) return null;
|
|
604
|
+
const byName = new Map(allTokens(tokens2).map((t) => [t.name, t]));
|
|
605
|
+
const known = (name, where) => {
|
|
606
|
+
if (!byName.has(name)) throw new Error(`styles: unknown token "${name}" in ${where}`);
|
|
607
|
+
return name;
|
|
608
|
+
};
|
|
609
|
+
const density = styles.density ?? { levels: [] };
|
|
610
|
+
const densityGoverned = new Set(
|
|
611
|
+
density.levels.length ? ["density", ...density.scaled ?? []] : []
|
|
612
|
+
);
|
|
613
|
+
for (const name of densityGoverned) {
|
|
614
|
+
known(name, "density");
|
|
615
|
+
if (isThemed(byName.get(name).value))
|
|
616
|
+
throw new Error(`styles: density token "${name}" is themed`);
|
|
617
|
+
}
|
|
618
|
+
for (const level of density.levels) {
|
|
619
|
+
for (const name of Object.keys(level.values ?? {})) {
|
|
620
|
+
if (!densityGoverned.has(name) || name === "density")
|
|
621
|
+
throw new Error(`styles: density level "${level.id}" sets "${name}", which is not scaled`);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
const radiusLevels = styles.radius?.levels ?? [];
|
|
625
|
+
const radiusGoverned = new Set(radiusLevels.flatMap((l) => Object.keys(l.values ?? {})));
|
|
626
|
+
for (const name of radiusGoverned) known(name, "radius levels");
|
|
627
|
+
const presets = styles.presets ?? [];
|
|
628
|
+
const def = presets.find((p) => p.id === styles.default);
|
|
629
|
+
if (presets.length && !def) throw new Error(`styles: default preset "${styles.default}" missing`);
|
|
630
|
+
if (def && Object.keys(def.values ?? {}).length)
|
|
631
|
+
throw new Error("styles: the default preset is the base tokens and must not override values");
|
|
632
|
+
const presetGoverned = /* @__PURE__ */ new Set([
|
|
633
|
+
...(styles.tokens ?? []).map((t) => t.name),
|
|
634
|
+
...(tokens2.radius?.tokens ?? []).map((t) => t.name),
|
|
635
|
+
...(tokens2.shadow?.tokens ?? []).map((t) => t.name)
|
|
636
|
+
]);
|
|
637
|
+
for (const p of presets) {
|
|
638
|
+
for (const [name, v] of Object.entries(p.values ?? {})) {
|
|
639
|
+
known(name, `preset "${p.id}"`);
|
|
640
|
+
if (densityGoverned.has(name))
|
|
641
|
+
throw new Error(`styles: preset "${p.id}" sets "${name}", which belongs to data-density`);
|
|
642
|
+
if (radiusGoverned.has(name) && isThemed(v))
|
|
643
|
+
throw new Error(`styles: preset "${p.id}" themes radius "${name}"`);
|
|
644
|
+
presetGoverned.add(name);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
const order = [...byName.keys()];
|
|
648
|
+
const sorted = (set) => order.filter((n) => set.has(n));
|
|
649
|
+
return {
|
|
650
|
+
byName,
|
|
651
|
+
presets,
|
|
652
|
+
density,
|
|
653
|
+
radiusLevels,
|
|
654
|
+
presetGoverned: sorted(presetGoverned),
|
|
655
|
+
densityGoverned: sorted(densityGoverned),
|
|
656
|
+
radiusGoverned: sorted(radiusGoverned)
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
function buildStyleBlocks(tokens2) {
|
|
660
|
+
const s = stylesOf(tokens2);
|
|
661
|
+
if (!s) return [];
|
|
662
|
+
const themes = themeOf(tokens2);
|
|
663
|
+
const blocks = [];
|
|
664
|
+
const radius = new Set(s.radiusGoverned);
|
|
665
|
+
for (const p of s.presets) {
|
|
666
|
+
const entries = s.presetGoverned.map((name) => {
|
|
667
|
+
const v = p.values?.[name] ?? s.byName.get(name).value;
|
|
668
|
+
return [name, radius.has(name) ? `var(--${name}-override, ${v})` : v];
|
|
669
|
+
});
|
|
670
|
+
blocks.push(...variantBlocks("data-style", p.id, entries, themes));
|
|
671
|
+
}
|
|
672
|
+
for (const level of s.density.levels) {
|
|
673
|
+
const entries = s.densityGoverned.map((name) => {
|
|
674
|
+
if (name === "density") return [name, String(level.density)];
|
|
675
|
+
return [name, level.values?.[name] ?? `calc(${s.byName.get(name).value} * var(--density))`];
|
|
676
|
+
});
|
|
677
|
+
blocks.push(...variantBlocks("data-density", level.id, entries, themes));
|
|
678
|
+
}
|
|
679
|
+
for (const level of s.radiusLevels) {
|
|
680
|
+
const entries = s.radiusGoverned.flatMap((name) => {
|
|
681
|
+
const v = level.values?.[name] ?? s.byName.get(name).value;
|
|
682
|
+
return [
|
|
683
|
+
[`${name}-override`, v],
|
|
684
|
+
[name, v]
|
|
685
|
+
];
|
|
686
|
+
});
|
|
687
|
+
blocks.push(...variantBlocks("data-radius", level.id, entries, themes));
|
|
688
|
+
}
|
|
689
|
+
return blocks;
|
|
690
|
+
}
|
|
691
|
+
var cssRule = (selector, body, depth = 1) => {
|
|
692
|
+
const pad = " ".repeat(depth);
|
|
693
|
+
const lines = Object.entries(body).map(
|
|
694
|
+
([k, v]) => typeof v === "object" ? cssRule(k, v, depth + 1) : `${pad}${k}: ${v};`
|
|
695
|
+
);
|
|
696
|
+
return `${" ".repeat(depth - 1)}${selector} {
|
|
697
|
+
${lines.join("\n")}
|
|
698
|
+
${" ".repeat(depth - 1)}}`;
|
|
699
|
+
};
|
|
700
|
+
function buildTokensCss(tokens2) {
|
|
701
|
+
const { base, others } = themeOf(tokens2);
|
|
702
|
+
const all = allTokens(tokens2);
|
|
703
|
+
const themedOnly = (theme) => all.filter((t) => isThemed(t.value) && theme in t.value);
|
|
704
|
+
const blocks = [];
|
|
705
|
+
const root = all.map((t) => [t.name, valueFor(t, base, base)]);
|
|
706
|
+
for (const [k, v] of Object.entries(tokens2.type?.families ?? {})) {
|
|
707
|
+
root.push([`font-${k}`, v]);
|
|
708
|
+
}
|
|
709
|
+
blocks.push(`:root {
|
|
710
|
+
color-scheme: ${base};
|
|
711
|
+
${decls(root)}
|
|
712
|
+
}`);
|
|
713
|
+
for (const theme of others) {
|
|
714
|
+
const body = decls(themedOnly(theme).map((t) => [t.name, t.value[theme]]));
|
|
715
|
+
const scheme = ` color-scheme: ${theme};
|
|
716
|
+
`;
|
|
717
|
+
if (theme === "dark") {
|
|
718
|
+
blocks.push(
|
|
719
|
+
`@media (prefers-color-scheme: dark) {
|
|
720
|
+
:root:not([data-theme="${base}"]) {
|
|
721
|
+
${scheme.split("\n").map((l) => l ? ` ${l}` : l).join("\n")}${body.split("\n").map((l) => ` ${l}`).join("\n")}
|
|
722
|
+
}
|
|
723
|
+
}`
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
blocks.push(`:root[data-theme="${theme}"] {
|
|
727
|
+
${scheme}${body}
|
|
728
|
+
}`);
|
|
729
|
+
}
|
|
730
|
+
for (const [id, roles] of palettesOf(tokens2)) {
|
|
731
|
+
const pairs = Object.entries(PALETTE_ROLES).filter(([role]) => roles[role]).map(([role, target]) => [target, `var(--${roles[role]})`]);
|
|
732
|
+
const swap = tokens2.chartSwaps?.palettes?.[id];
|
|
733
|
+
if (swap && tokens2.chartSwaps.reserve)
|
|
734
|
+
pairs.push([swap, `var(--${tokens2.chartSwaps.reserve})`]);
|
|
735
|
+
blocks.push(`:root[data-accent="${id}"] {
|
|
736
|
+
${decls(pairs)}
|
|
737
|
+
}`);
|
|
738
|
+
}
|
|
739
|
+
blocks.push(...buildStyleBlocks(tokens2));
|
|
740
|
+
return `/* Generated by ui-theme from "${tokens2.name}". Do not edit. */
|
|
741
|
+
${blocks.join("\n\n")}
|
|
742
|
+
`;
|
|
743
|
+
}
|
|
744
|
+
var stripPrefix = (name, prefix) => name.startsWith(`${prefix}-`) ? name.slice(prefix.length + 1) : name;
|
|
745
|
+
function buildThemeCss(tokens2) {
|
|
746
|
+
const lines = [];
|
|
747
|
+
for (const t of tokens2.color?.tokens ?? []) {
|
|
748
|
+
lines.push(` --color-${t.name}: var(--${t.name});`);
|
|
749
|
+
}
|
|
750
|
+
for (const t of tonesOf(tokens2)) {
|
|
751
|
+
lines.push(` --color-${t.name}: var(--${t.name});`);
|
|
752
|
+
}
|
|
753
|
+
for (const t of tokens2.radius?.tokens ?? []) {
|
|
754
|
+
lines.push(` --radius-${stripPrefix(t.name, "radius")}: var(--${t.name});`);
|
|
755
|
+
}
|
|
756
|
+
for (const t of tokens2.shadow?.tokens ?? []) {
|
|
757
|
+
lines.push(` --shadow-${stripPrefix(t.name, "shadow")}: var(--${t.name});`);
|
|
758
|
+
}
|
|
759
|
+
for (const t of tokens2.size?.tokens ?? []) {
|
|
760
|
+
lines.push(` --spacing-${t.name}: var(--${t.name});`);
|
|
761
|
+
}
|
|
762
|
+
for (const k of Object.keys(tokens2.type?.families ?? {})) {
|
|
763
|
+
lines.push(` --font-${k}: var(--font-${k});`);
|
|
764
|
+
}
|
|
765
|
+
for (const s of typeStyles(tokens2)) {
|
|
766
|
+
lines.push(` --text-${s.name}: ${s.fontSize};`);
|
|
767
|
+
if (s.lineHeight !== void 0) {
|
|
768
|
+
lines.push(` --text-${s.name}--line-height: ${s.lineHeight};`);
|
|
769
|
+
}
|
|
770
|
+
if (s.fontWeight !== void 0) {
|
|
771
|
+
lines.push(` --text-${s.name}--font-weight: ${s.fontWeight};`);
|
|
772
|
+
}
|
|
773
|
+
if (s.letterSpacing !== void 0) {
|
|
774
|
+
lines.push(` --text-${s.name}--letter-spacing: ${s.letterSpacing};`);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
if ((tokens2.type?.sizeScale ?? []).length > 0) {
|
|
778
|
+
lines.push(
|
|
779
|
+
" /* Size-only scale (px x 10, no line-height or weight) for dense UI text that must not inherit a role's weight. */"
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
for (const s of tokens2.type?.sizeScale ?? []) {
|
|
783
|
+
lines.push(` --text-${s.name}: ${s.fontSize};`);
|
|
784
|
+
}
|
|
785
|
+
const styles = stylesOf(tokens2);
|
|
786
|
+
for (const [themeVar, name] of Object.entries(tokens2.styles?.tailwind ?? {})) {
|
|
787
|
+
if (!styles.byName.has(name)) throw new Error(`styles.tailwind: unknown token "${name}"`);
|
|
788
|
+
lines.push(` ${themeVar}: var(--${name});`);
|
|
789
|
+
}
|
|
790
|
+
const utilities = Object.entries(tokens2.styles?.utilities ?? {}).map(
|
|
791
|
+
([name, body]) => cssRule(`@utility ${name}`, body)
|
|
792
|
+
);
|
|
793
|
+
const tail = utilities.length ? `
|
|
794
|
+
${utilities.join("\n\n")}
|
|
795
|
+
` : "";
|
|
796
|
+
const selfReference = (l) => {
|
|
797
|
+
const m = /^\s*(--[\w-]+): var\((--[\w-]+)\);$/.exec(l);
|
|
798
|
+
return m !== null && m[1] === m[2];
|
|
799
|
+
};
|
|
800
|
+
const mapped = lines.filter((l) => !selfReference(l));
|
|
801
|
+
const same = lines.filter(selfReference);
|
|
802
|
+
const reference = same.length ? `
|
|
803
|
+
@theme reference inline {
|
|
804
|
+
${same.join("\n")}
|
|
805
|
+
}
|
|
806
|
+
` : "";
|
|
807
|
+
return `/* Generated by ui-theme from "${tokens2.name}". Do not edit. */
|
|
808
|
+
@theme inline {
|
|
809
|
+
${mapped.join("\n")}
|
|
810
|
+
}
|
|
811
|
+
${reference}${tail}`;
|
|
812
|
+
}
|
|
813
|
+
function buildFontsCss(tokens2) {
|
|
814
|
+
const imports = (tokens2.type?.fonts ?? []).filter((f) => f.source === "google").map((f) => `@import url("https://fonts.googleapis.com/css2?family=${f.spec}&display=swap");`);
|
|
815
|
+
return `/* Generated by ui-theme. Optional: skip it when the app loads fonts itself (e.g. next/font). */
|
|
816
|
+
${imports.join("\n")}
|
|
817
|
+
`;
|
|
818
|
+
}
|
|
819
|
+
var camel = (name) => name.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase()).replace(/^[0-9]/, "_$&");
|
|
820
|
+
var pascal = (name) => {
|
|
821
|
+
const c = camel(name);
|
|
822
|
+
return c[0].toUpperCase() + c.slice(1);
|
|
823
|
+
};
|
|
824
|
+
function toKotlinColor(css) {
|
|
825
|
+
const v = css.trim().toLowerCase();
|
|
826
|
+
const hex = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(v);
|
|
827
|
+
if (hex) {
|
|
828
|
+
let h = hex[1];
|
|
829
|
+
if (h.length === 3) h = [...h].map((c) => c + c).join("");
|
|
830
|
+
if (h.length === 6) return `Color(0xFF${h.toUpperCase()})`;
|
|
831
|
+
return `Color(0x${(h.slice(6) + h.slice(0, 6)).toUpperCase()})`;
|
|
832
|
+
}
|
|
833
|
+
const rgba2 = /^rgba?\(([^)]+)\)$/.exec(v);
|
|
834
|
+
if (rgba2) {
|
|
835
|
+
const [r, g, b, a = "1"] = rgba2[1].split(",").map((x) => x.trim());
|
|
836
|
+
const hx = (n) => Math.round(Number(n)).toString(16).padStart(2, "0");
|
|
837
|
+
const alpha = Math.round(Number(a) * 255).toString(16).padStart(2, "0");
|
|
838
|
+
return `Color(0x${(alpha + hx(r) + hx(g) + hx(b)).toUpperCase()})`;
|
|
839
|
+
}
|
|
840
|
+
throw new Error(`Unsupported color for Kotlin: ${css}`);
|
|
841
|
+
}
|
|
842
|
+
var kotlinColorOf = (token, theme, base) => {
|
|
843
|
+
const value = valueFor(token, theme, base);
|
|
844
|
+
try {
|
|
845
|
+
return toKotlinColor(value);
|
|
846
|
+
} catch {
|
|
847
|
+
throw new Error(
|
|
848
|
+
`Token "${token.name}" (${theme}) has a color Kotlin cannot represent: ${value}. Use hex or rgb(a) values, or pass --no-kotlin.`
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
var px = (value) => `${Number.parseFloat(value)}.dp`;
|
|
853
|
+
var GLASS_VARIANTS = ["regular", "clear"];
|
|
854
|
+
function glassOf(tokens2) {
|
|
855
|
+
const byName = new Map((tokens2.styles?.tokens ?? []).map((t) => [t.name, t]));
|
|
856
|
+
return GLASS_VARIANTS.filter((v) => byName.has(`glass-${v}-tint`)).map((id) => {
|
|
857
|
+
const part = (name) => {
|
|
858
|
+
const t = byName.get(`glass-${id}-${name}`);
|
|
859
|
+
if (!t) throw new Error(`styles: glass variant "${id}" is missing "glass-${id}-${name}"`);
|
|
860
|
+
return t;
|
|
861
|
+
};
|
|
862
|
+
return {
|
|
863
|
+
id,
|
|
864
|
+
tint: part("tint"),
|
|
865
|
+
border: part("border"),
|
|
866
|
+
edge: part("edge"),
|
|
867
|
+
dim: part("dim"),
|
|
868
|
+
blur: part("blur"),
|
|
869
|
+
saturate: part("saturate")
|
|
870
|
+
};
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
function glassKotlin(tokens2, { library }) {
|
|
874
|
+
const variants = glassOf(tokens2);
|
|
875
|
+
if (!variants.length) return [];
|
|
876
|
+
const { base, others } = themeOf(tokens2);
|
|
877
|
+
const vis = library ? "public " : "";
|
|
878
|
+
const out2 = [];
|
|
879
|
+
if (library) out2.push("@Immutable");
|
|
880
|
+
out2.push(
|
|
881
|
+
`${vis}class GlassMaterial(`,
|
|
882
|
+
` ${vis}val tint: Color,`,
|
|
883
|
+
` ${vis}val border: Color,`,
|
|
884
|
+
` ${vis}val edge: Color,`,
|
|
885
|
+
` ${vis}val dim: Color,`,
|
|
886
|
+
` ${vis}val blur: ${library ? "Dp" : "androidx.compose.ui.unit.Dp"},`,
|
|
887
|
+
` ${vis}val saturate: Float,`,
|
|
888
|
+
")",
|
|
889
|
+
""
|
|
890
|
+
);
|
|
891
|
+
if (library) out2.push("@Immutable");
|
|
892
|
+
out2.push(`${vis}object UiGlass {`);
|
|
893
|
+
for (const theme of [base, ...others]) {
|
|
894
|
+
for (const v of variants) {
|
|
895
|
+
const c = (t) => kotlinColorOf(t, theme, base);
|
|
896
|
+
const type = library ? ": GlassMaterial" : "";
|
|
897
|
+
out2.push(
|
|
898
|
+
` ${vis}val ${pascal(v.id)}${pascal(theme)}${type} = GlassMaterial(`,
|
|
899
|
+
` tint = ${c(v.tint)},`,
|
|
900
|
+
` border = ${c(v.border)},`,
|
|
901
|
+
` edge = ${c(v.edge)},`,
|
|
902
|
+
` dim = ${c(v.dim)},`,
|
|
903
|
+
` blur = ${px(valueFor(v.blur, theme, base))},`,
|
|
904
|
+
` saturate = ${Number.parseFloat(valueFor(v.saturate, theme, base))}f,`,
|
|
905
|
+
" )"
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
out2.push("}", "");
|
|
910
|
+
return out2;
|
|
911
|
+
}
|
|
912
|
+
function buildThemeKt(tokens2, pkg = "com.jcsoftdev.ui.theme", { library = false } = {}) {
|
|
913
|
+
if (library) return buildLibraryThemeKt(tokens2, pkg);
|
|
914
|
+
const { base, others } = themeOf(tokens2);
|
|
915
|
+
const themes = [base, ...others];
|
|
916
|
+
const colors = (tokens2.color?.tokens ?? []).filter((t) => !t.name.startsWith("pal-"));
|
|
917
|
+
const out2 = [
|
|
918
|
+
`// Generated by ui-theme from "${tokens2.name}". Do not edit.`,
|
|
919
|
+
`package ${pkg}`,
|
|
920
|
+
"",
|
|
921
|
+
"import androidx.compose.foundation.shape.RoundedCornerShape",
|
|
922
|
+
"import androidx.compose.ui.graphics.Color",
|
|
923
|
+
"import androidx.compose.ui.text.TextStyle",
|
|
924
|
+
"import androidx.compose.ui.text.font.FontWeight",
|
|
925
|
+
"import androidx.compose.ui.unit.dp",
|
|
926
|
+
"import androidx.compose.ui.unit.em",
|
|
927
|
+
"import androidx.compose.ui.unit.sp",
|
|
928
|
+
"",
|
|
929
|
+
"class ThemeColors(",
|
|
930
|
+
...colors.map((t) => ` val ${camel(t.name)}: Color,`),
|
|
931
|
+
")",
|
|
932
|
+
"",
|
|
933
|
+
"object UiColors {"
|
|
934
|
+
];
|
|
935
|
+
for (const theme of themes) {
|
|
936
|
+
out2.push(` val ${pascal(theme)} = ThemeColors(`);
|
|
937
|
+
for (const t of colors) {
|
|
938
|
+
out2.push(` ${camel(t.name)} = ${kotlinColorOf(t, theme, base)},`);
|
|
939
|
+
}
|
|
940
|
+
out2.push(" )");
|
|
941
|
+
}
|
|
942
|
+
out2.push("}", "");
|
|
943
|
+
const palettes = palettesOf(tokens2);
|
|
944
|
+
if (palettes.size) {
|
|
945
|
+
out2.push("class AccentPalette(");
|
|
946
|
+
for (const target of Object.values(PALETTE_ROLES)) {
|
|
947
|
+
out2.push(` val ${camel(target)}: Color,`);
|
|
948
|
+
}
|
|
949
|
+
out2.push(")", "", "object UiPalettes {");
|
|
950
|
+
for (const theme of themes) {
|
|
951
|
+
out2.push(` val ${pascal(theme)}: Map<String, AccentPalette> = mapOf(`);
|
|
952
|
+
for (const [id, roles] of palettes) {
|
|
953
|
+
const byName = new Map(tokens2.color.tokens.map((t) => [t.name, t]));
|
|
954
|
+
const args2 = Object.entries(PALETTE_ROLES).map(([role]) => {
|
|
955
|
+
const tok = byName.get(roles[role]);
|
|
956
|
+
return tok ? kotlinColorOf(tok, theme, base) : "Color.Unspecified";
|
|
957
|
+
});
|
|
958
|
+
out2.push(` "${id}" to AccentPalette(${args2.join(", ")}),`);
|
|
959
|
+
}
|
|
960
|
+
out2.push(" )");
|
|
961
|
+
}
|
|
962
|
+
out2.push("}", "");
|
|
963
|
+
}
|
|
964
|
+
out2.push("object UiShapes {");
|
|
965
|
+
for (const t of tokens2.radius?.tokens ?? []) {
|
|
966
|
+
const n = camel(stripPrefix(t.name, "radius"));
|
|
967
|
+
const pill = Number.parseFloat(t.value) >= 999;
|
|
968
|
+
out2.push(` val ${n} = RoundedCornerShape(${pill ? "50" : px(t.value)})`);
|
|
969
|
+
}
|
|
970
|
+
out2.push("}", "", "object UiSizes {");
|
|
971
|
+
for (const t of [...tokens2.spacing?.tokens ?? [], ...tokens2.size?.tokens ?? []]) {
|
|
972
|
+
out2.push(` val ${camel(t.name)} = ${px(t.value)}`);
|
|
973
|
+
}
|
|
974
|
+
out2.push("}", "");
|
|
975
|
+
const family = (tokens2.type?.fonts ?? [])[0]?.family ?? "";
|
|
976
|
+
out2.push(`const val UiFontFamilyName = "${family}"`, "", "object UiTypography {");
|
|
977
|
+
for (const s of typeStyles(tokens2)) {
|
|
978
|
+
const size = Number.parseFloat(s.fontSize);
|
|
979
|
+
const parts = [`fontSize = ${size}.sp`];
|
|
980
|
+
if (s.fontWeight !== void 0) parts.push(`fontWeight = FontWeight(${s.fontWeight})`);
|
|
981
|
+
if (s.lineHeight !== void 0) {
|
|
982
|
+
const lh = String(s.lineHeight).endsWith("px") ? Number.parseFloat(s.lineHeight) : Number((size * Number(s.lineHeight)).toFixed(2));
|
|
983
|
+
parts.push(`lineHeight = ${lh}.sp`);
|
|
984
|
+
}
|
|
985
|
+
if (s.letterSpacing) parts.push(`letterSpacing = (${Number.parseFloat(s.letterSpacing)}).em`);
|
|
986
|
+
out2.push(` val ${camel(s.name)} = TextStyle(${parts.join(", ")})`);
|
|
987
|
+
}
|
|
988
|
+
out2.push("}", "");
|
|
989
|
+
const sizeScale = tokens2.type?.sizeScale ?? [];
|
|
990
|
+
if (sizeScale.length > 0) {
|
|
991
|
+
out2.push("object UiFontSizes {");
|
|
992
|
+
for (const s of sizeScale)
|
|
993
|
+
out2.push(` val ${camel(s.name)} = ${Number.parseFloat(s.fontSize)}.sp`);
|
|
994
|
+
out2.push("}", "");
|
|
995
|
+
}
|
|
996
|
+
out2.push(...glassKotlin(tokens2, { library: false }));
|
|
997
|
+
return out2.join("\n");
|
|
998
|
+
}
|
|
999
|
+
function buildLibraryThemeKt(tokens2, pkg) {
|
|
1000
|
+
const { base, others } = themeOf(tokens2);
|
|
1001
|
+
const themes = [base, ...others];
|
|
1002
|
+
const colors = (tokens2.color?.tokens ?? []).filter((t) => !t.name.startsWith("pal-"));
|
|
1003
|
+
const out2 = [
|
|
1004
|
+
`// Generated by ui-theme from "${tokens2.name}". Do not edit.`,
|
|
1005
|
+
"",
|
|
1006
|
+
`package ${pkg}`,
|
|
1007
|
+
"",
|
|
1008
|
+
"import androidx.compose.foundation.shape.RoundedCornerShape",
|
|
1009
|
+
"import androidx.compose.runtime.Immutable",
|
|
1010
|
+
"import androidx.compose.ui.graphics.Color",
|
|
1011
|
+
"import androidx.compose.ui.text.TextStyle",
|
|
1012
|
+
"import androidx.compose.ui.text.font.FontWeight",
|
|
1013
|
+
"import androidx.compose.ui.unit.Dp",
|
|
1014
|
+
"import androidx.compose.ui.unit.TextUnit",
|
|
1015
|
+
"import androidx.compose.ui.unit.dp",
|
|
1016
|
+
"import androidx.compose.ui.unit.em",
|
|
1017
|
+
"import androidx.compose.ui.unit.sp",
|
|
1018
|
+
"",
|
|
1019
|
+
"@Immutable",
|
|
1020
|
+
"public class ThemeColors(",
|
|
1021
|
+
...colors.map((t) => ` public val ${camel(t.name)}: Color,`),
|
|
1022
|
+
")",
|
|
1023
|
+
"",
|
|
1024
|
+
"public object UiColors {"
|
|
1025
|
+
];
|
|
1026
|
+
for (const theme of themes) {
|
|
1027
|
+
out2.push(` public val ${pascal(theme)}: ThemeColors = ThemeColors(`);
|
|
1028
|
+
for (const t of colors) {
|
|
1029
|
+
out2.push(` ${camel(t.name)} = ${kotlinColorOf(t, theme, base)},`);
|
|
1030
|
+
}
|
|
1031
|
+
out2.push(" )");
|
|
1032
|
+
}
|
|
1033
|
+
out2.push("}", "");
|
|
1034
|
+
const palettes = palettesOf(tokens2);
|
|
1035
|
+
if (palettes.size) {
|
|
1036
|
+
const byName = new Map(tokens2.color.tokens.map((t) => [t.name, t]));
|
|
1037
|
+
out2.push("@Immutable", "public class AccentPalette(");
|
|
1038
|
+
for (const target of Object.values(PALETTE_ROLES)) {
|
|
1039
|
+
out2.push(` public val ${camel(target)}: Color,`);
|
|
1040
|
+
}
|
|
1041
|
+
out2.push(")", "", "@Immutable", "public object UiPalettes {");
|
|
1042
|
+
out2.push(
|
|
1043
|
+
` public val ids: List<String> = listOf(${[...palettes.keys()].map((id) => `"${id}"`).join(", ")})`
|
|
1044
|
+
);
|
|
1045
|
+
for (const theme of themes) {
|
|
1046
|
+
out2.push("");
|
|
1047
|
+
for (const [id, roles] of palettes) {
|
|
1048
|
+
const args2 = Object.keys(PALETTE_ROLES).map((role) => {
|
|
1049
|
+
const tok = byName.get(roles[role]);
|
|
1050
|
+
return tok ? kotlinColorOf(tok, theme, base) : "Color.Unspecified";
|
|
1051
|
+
});
|
|
1052
|
+
out2.push(` private val ${camel(`${theme}-${id}`)} = AccentPalette(${args2.join(", ")})`);
|
|
1053
|
+
}
|
|
1054
|
+
out2.push(
|
|
1055
|
+
"",
|
|
1056
|
+
` public fun ${camel(theme)}(id: String): AccentPalette? =`,
|
|
1057
|
+
" when (id) {"
|
|
1058
|
+
);
|
|
1059
|
+
for (const id of palettes.keys()) {
|
|
1060
|
+
out2.push(` "${id}" -> ${camel(`${theme}-${id}`)}`);
|
|
1061
|
+
}
|
|
1062
|
+
out2.push(" else -> null", " }");
|
|
1063
|
+
}
|
|
1064
|
+
out2.push("}", "");
|
|
1065
|
+
}
|
|
1066
|
+
out2.push("public object UiShapes {");
|
|
1067
|
+
for (const t of tokens2.radius?.tokens ?? []) {
|
|
1068
|
+
const n = camel(stripPrefix(t.name, "radius"));
|
|
1069
|
+
const pill = Number.parseFloat(t.value) >= 999;
|
|
1070
|
+
out2.push(
|
|
1071
|
+
` public val ${n}: RoundedCornerShape = RoundedCornerShape(${pill ? "50" : px(t.value)})`
|
|
1072
|
+
);
|
|
1073
|
+
}
|
|
1074
|
+
out2.push("}", "", "public object UiSizes {");
|
|
1075
|
+
for (const t of [...tokens2.spacing?.tokens ?? [], ...tokens2.size?.tokens ?? []]) {
|
|
1076
|
+
out2.push(` public val ${camel(t.name)}: Dp = ${px(t.value)}`);
|
|
1077
|
+
}
|
|
1078
|
+
out2.push("}", "");
|
|
1079
|
+
const family = (tokens2.type?.fonts ?? [])[0]?.family ?? "";
|
|
1080
|
+
out2.push(
|
|
1081
|
+
`public const val UiFontFamilyName: String = "${family}"`,
|
|
1082
|
+
"",
|
|
1083
|
+
"public object UiTypography {"
|
|
1084
|
+
);
|
|
1085
|
+
for (const s of typeStyles(tokens2)) {
|
|
1086
|
+
const size = Number.parseFloat(s.fontSize);
|
|
1087
|
+
const parts = [`fontSize = ${size}.sp`];
|
|
1088
|
+
if (s.fontWeight !== void 0) parts.push(`fontWeight = FontWeight(${s.fontWeight})`);
|
|
1089
|
+
if (s.lineHeight !== void 0) {
|
|
1090
|
+
const lh = String(s.lineHeight).endsWith("px") ? Number.parseFloat(s.lineHeight) : Number((size * Number(s.lineHeight)).toFixed(2));
|
|
1091
|
+
parts.push(`lineHeight = ${lh}.sp`);
|
|
1092
|
+
}
|
|
1093
|
+
if (s.letterSpacing) parts.push(`letterSpacing = (${Number.parseFloat(s.letterSpacing)}).em`);
|
|
1094
|
+
out2.push(` public val ${camel(s.name)}: TextStyle = TextStyle(${parts.join(", ")})`);
|
|
1095
|
+
}
|
|
1096
|
+
out2.push("}", "");
|
|
1097
|
+
const sizeScale = tokens2.type?.sizeScale ?? [];
|
|
1098
|
+
if (sizeScale.length > 0) {
|
|
1099
|
+
out2.push("public object UiFontSizes {");
|
|
1100
|
+
for (const s of sizeScale)
|
|
1101
|
+
out2.push(` public val ${camel(s.name)}: TextUnit = ${Number.parseFloat(s.fontSize)}.sp`);
|
|
1102
|
+
out2.push("}", "");
|
|
1103
|
+
}
|
|
1104
|
+
out2.push(...glassKotlin(tokens2, { library: true }));
|
|
1105
|
+
return out2.join("\n");
|
|
1106
|
+
}
|
|
1107
|
+
function buildTheme(tokens2, { kotlinPackage: kotlinPackage2, kotlinLibrary: kotlinLibrary2 = false, kotlin = true } = {}) {
|
|
1108
|
+
const css = {
|
|
1109
|
+
"tokens.css": buildTokensCss(tokens2),
|
|
1110
|
+
"theme.css": buildThemeCss(tokens2),
|
|
1111
|
+
"tailwind.css": buildThemeCss(tokens2),
|
|
1112
|
+
"fonts.css": buildFontsCss(tokens2)
|
|
1113
|
+
};
|
|
1114
|
+
if (!kotlin) return css;
|
|
1115
|
+
return { ...css, "Theme.kt": buildThemeKt(tokens2, kotlinPackage2, { library: kotlinLibrary2 }) };
|
|
1116
|
+
}
|
|
8
1117
|
|
|
9
|
-
|
|
1118
|
+
// ../ui-tokens/bin/ui-theme.mjs
|
|
1119
|
+
var USAGE2 = `Usage:
|
|
1120
|
+
ui-theme build [tokens.json] --out <dir> [--kotlin-package <pkg>] [--no-kotlin]
|
|
1121
|
+
ui-theme generate --brand <hex> [--accent <hex>] [--neutral <hex>] [--danger <hex>] --out <dir>
|
|
1122
|
+
|
|
1123
|
+
build generates tokens.css, theme.css, tailwind.css, fonts.css and Theme.kt from a tokens file.
|
|
10
1124
|
Without a tokens file the bundled default theme is used.
|
|
11
|
-
--
|
|
1125
|
+
--kotlin-library emits the explicit-API, @Immutable flavour used by the Compose kit.
|
|
1126
|
+
--no-kotlin skips Theme.kt, so tokens with var() or oklch() colors build.
|
|
1127
|
+
--no-css skips the CSS outputs.
|
|
12
1128
|
|
|
13
|
-
|
|
14
|
-
|
|
1129
|
+
generate derives a WCAG AA color set (light and dark) from seed colors, merges it into the bundled
|
|
1130
|
+
default tokens (the data-accent presets are kept) and writes tokens.json plus the same CSS outputs.`;
|
|
1131
|
+
var args = process.argv.slice(2);
|
|
1132
|
+
var flag = (name) => {
|
|
15
1133
|
const i = args.indexOf(name);
|
|
16
|
-
if (i === -1) return
|
|
1134
|
+
if (i === -1) return void 0;
|
|
17
1135
|
return args.splice(i, 2)[1];
|
|
18
1136
|
};
|
|
19
|
-
|
|
1137
|
+
var has = (name) => {
|
|
20
1138
|
const i = args.indexOf(name);
|
|
21
1139
|
if (i === -1) return false;
|
|
22
1140
|
args.splice(i, 1);
|
|
23
1141
|
return true;
|
|
24
1142
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1143
|
+
var out = flag("--out");
|
|
1144
|
+
var kotlinPackage = flag("--kotlin-package");
|
|
1145
|
+
var tokensFlag = flag("--tokens");
|
|
1146
|
+
var noKotlin = has("--no-kotlin");
|
|
1147
|
+
var kotlinLibrary = has("--kotlin-library");
|
|
1148
|
+
var noCss = has("--no-css");
|
|
1149
|
+
var seeds = {
|
|
1150
|
+
brand: flag("--brand"),
|
|
1151
|
+
accent: flag("--accent"),
|
|
1152
|
+
neutral: flag("--neutral"),
|
|
1153
|
+
danger: flag("--danger")
|
|
1154
|
+
};
|
|
1155
|
+
var [command, positional] = args;
|
|
1156
|
+
if (!["build", "generate"].includes(command) || !out || command === "generate" && !seeds.brand) {
|
|
1157
|
+
console.error(USAGE2);
|
|
34
1158
|
process.exit(command === "--help" ? 0 : 1);
|
|
35
1159
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1160
|
+
var here = dirname(fileURLToPath(import.meta.url));
|
|
1161
|
+
var file = resolve(tokensFlag ?? positional ?? join(here, "../tokens/default.json"));
|
|
1162
|
+
var tokens = JSON.parse(readFileSync(file, "utf8"));
|
|
1163
|
+
var extra = {};
|
|
1164
|
+
if (command === "generate") {
|
|
1165
|
+
const { createTheme: createTheme2, withTheme: withTheme2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
1166
|
+
const defined = Object.fromEntries(Object.entries(seeds).filter(([, v]) => v !== void 0));
|
|
1167
|
+
try {
|
|
1168
|
+
tokens = withTheme2(tokens, createTheme2(defined));
|
|
1169
|
+
} catch (error) {
|
|
1170
|
+
console.error(`ui-theme: ${error instanceof Error ? error.message : String(error)}`);
|
|
1171
|
+
process.exit(1);
|
|
1172
|
+
}
|
|
1173
|
+
extra["tokens.json"] = `${JSON.stringify(tokens, null, 2)}
|
|
1174
|
+
`;
|
|
1175
|
+
}
|
|
1176
|
+
var files = {
|
|
1177
|
+
...extra,
|
|
1178
|
+
...buildTheme(tokens, { kotlinPackage, kotlinLibrary, kotlin: !noKotlin })
|
|
1179
|
+
};
|
|
44
1180
|
mkdirSync(resolve(out), { recursive: true });
|
|
45
1181
|
for (const [name, content] of Object.entries(files)) {
|
|
1182
|
+
if (noCss && name.endsWith(".css")) continue;
|
|
46
1183
|
writeFileSync(join(resolve(out), name), content);
|
|
47
1184
|
console.log(`wrote ${join(out, name)}`);
|
|
48
1185
|
}
|