@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/scripts/build-theme.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Token generator: tokens.json -> tokens.css, theme.css, fonts.css, Theme.kt.
|
|
1
|
+
// Token generator: tokens.json -> tokens.css, theme.css (= tailwind.css), fonts.css, Theme.kt.
|
|
2
2
|
// Pure functions, no dependencies. Used by bin/ui-theme.mjs and the tests.
|
|
3
3
|
|
|
4
4
|
const PALETTE_ROLES = {
|
|
@@ -23,8 +23,40 @@ const themeOf = (tokens) => {
|
|
|
23
23
|
return { base: themes[0], others: themes.slice(1) };
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
const TONE_NAME = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
27
|
+
const TONE_ROLES = ["fill", "soft", "ink"];
|
|
28
|
+
|
|
29
|
+
/** Tone palettes as color tokens: --tone-<name>, --tone-<name>-soft, --tone-<name>-ink. */
|
|
30
|
+
export function tonesOf(tokens) {
|
|
31
|
+
const out = [];
|
|
32
|
+
for (const [name, roles] of Object.entries(tokens.tonePalettes ?? {})) {
|
|
33
|
+
if (!TONE_NAME.test(name)) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
`tonePalettes: "${name}" must be kebab-case (lowercase letters, digits, hyphens)`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
for (const role of Object.keys(roles ?? {})) {
|
|
39
|
+
if (!TONE_ROLES.includes(role)) {
|
|
40
|
+
throw new Error(`tonePalettes.${name}: unknown role "${role}" (expected fill, soft, ink)`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
for (const role of ["fill", "soft"]) {
|
|
44
|
+
if (roles?.[role] === undefined)
|
|
45
|
+
throw new Error(`tonePalettes.${name}: "${role}" is required`);
|
|
46
|
+
}
|
|
47
|
+
const value = { fill: roles.fill, soft: roles.soft, ink: roles.ink ?? roles.fill };
|
|
48
|
+
out.push(
|
|
49
|
+
{ name: `tone-${name}`, value: value.fill },
|
|
50
|
+
{ name: `tone-${name}-soft`, value: value.soft },
|
|
51
|
+
{ name: `tone-${name}-ink`, value: value.ink },
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
|
|
26
57
|
const allTokens = (tokens) => [
|
|
27
58
|
...(tokens.color?.tokens ?? []),
|
|
59
|
+
...tonesOf(tokens),
|
|
28
60
|
...(tokens.shadow?.tokens ?? []),
|
|
29
61
|
...(tokens.radius?.tokens ?? []),
|
|
30
62
|
...(tokens.spacing?.tokens ?? []),
|
|
@@ -260,6 +292,9 @@ export function buildThemeCss(tokens) {
|
|
|
260
292
|
for (const t of tokens.color?.tokens ?? []) {
|
|
261
293
|
lines.push(` --color-${t.name}: var(--${t.name});`);
|
|
262
294
|
}
|
|
295
|
+
for (const t of tonesOf(tokens)) {
|
|
296
|
+
lines.push(` --color-${t.name}: var(--${t.name});`);
|
|
297
|
+
}
|
|
263
298
|
for (const t of tokens.radius?.tokens ?? []) {
|
|
264
299
|
lines.push(` --radius-${stripPrefix(t.name, "radius")}: var(--${t.name});`);
|
|
265
300
|
}
|
|
@@ -301,7 +336,18 @@ export function buildThemeCss(tokens) {
|
|
|
301
336
|
cssRule(`@utility ${name}`, body),
|
|
302
337
|
);
|
|
303
338
|
const tail = utilities.length ? `\n${utilities.join("\n\n")}\n` : "";
|
|
304
|
-
|
|
339
|
+
// A token whose utility name equals its raw variable (`--radius-input: var(--radius-input)`) would
|
|
340
|
+
// be emitted into Tailwind's theme layer as a cycle, which resolves to nothing for any consumer that
|
|
341
|
+
// loads tokens.css below that layer. `reference` keeps the utilities and drops the declaration;
|
|
342
|
+
// the utilities read the raw variable directly because the block is also `inline`.
|
|
343
|
+
const selfReference = (l) => {
|
|
344
|
+
const m = /^\s*(--[\w-]+): var\((--[\w-]+)\);$/.exec(l);
|
|
345
|
+
return m !== null && m[1] === m[2];
|
|
346
|
+
};
|
|
347
|
+
const mapped = lines.filter((l) => !selfReference(l));
|
|
348
|
+
const same = lines.filter(selfReference);
|
|
349
|
+
const reference = same.length ? `\n@theme reference inline {\n${same.join("\n")}\n}\n` : "";
|
|
350
|
+
return `/* Generated by ui-theme from "${tokens.name}". Do not edit. */\n@theme inline {\n${mapped.join("\n")}\n}\n${reference}${tail}`;
|
|
305
351
|
}
|
|
306
352
|
|
|
307
353
|
export function buildFontsCss(tokens) {
|
|
@@ -354,7 +400,76 @@ const kotlinColorOf = (token, theme, base) => {
|
|
|
354
400
|
|
|
355
401
|
const px = (value) => `${Number.parseFloat(value)}.dp`;
|
|
356
402
|
|
|
357
|
-
|
|
403
|
+
// ---------------------------------------------------------------- Glass
|
|
404
|
+
|
|
405
|
+
const GLASS_VARIANTS = ["regular", "clear"];
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Liquid Glass materials, derived from styles.tokens named glass-<variant>-<part>. Empty when the
|
|
409
|
+
* theme declares none, so themes without glass generate exactly what they did before.
|
|
410
|
+
*/
|
|
411
|
+
export function glassOf(tokens) {
|
|
412
|
+
const byName = new Map((tokens.styles?.tokens ?? []).map((t) => [t.name, t]));
|
|
413
|
+
return GLASS_VARIANTS.filter((v) => byName.has(`glass-${v}-tint`)).map((id) => {
|
|
414
|
+
const part = (name) => {
|
|
415
|
+
const t = byName.get(`glass-${id}-${name}`);
|
|
416
|
+
if (!t) throw new Error(`styles: glass variant "${id}" is missing "glass-${id}-${name}"`);
|
|
417
|
+
return t;
|
|
418
|
+
};
|
|
419
|
+
return {
|
|
420
|
+
id,
|
|
421
|
+
tint: part("tint"),
|
|
422
|
+
border: part("border"),
|
|
423
|
+
edge: part("edge"),
|
|
424
|
+
dim: part("dim"),
|
|
425
|
+
blur: part("blur"),
|
|
426
|
+
saturate: part("saturate"),
|
|
427
|
+
};
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function glassKotlin(tokens, { library }) {
|
|
432
|
+
const variants = glassOf(tokens);
|
|
433
|
+
if (!variants.length) return [];
|
|
434
|
+
const { base, others } = themeOf(tokens);
|
|
435
|
+
const vis = library ? "public " : "";
|
|
436
|
+
const out = [];
|
|
437
|
+
if (library) out.push("@Immutable");
|
|
438
|
+
out.push(
|
|
439
|
+
`${vis}class GlassMaterial(`,
|
|
440
|
+
` ${vis}val tint: Color,`,
|
|
441
|
+
` ${vis}val border: Color,`,
|
|
442
|
+
` ${vis}val edge: Color,`,
|
|
443
|
+
` ${vis}val dim: Color,`,
|
|
444
|
+
` ${vis}val blur: ${library ? "Dp" : "androidx.compose.ui.unit.Dp"},`,
|
|
445
|
+
` ${vis}val saturate: Float,`,
|
|
446
|
+
")",
|
|
447
|
+
"",
|
|
448
|
+
);
|
|
449
|
+
if (library) out.push("@Immutable");
|
|
450
|
+
out.push(`${vis}object UiGlass {`);
|
|
451
|
+
for (const theme of [base, ...others]) {
|
|
452
|
+
for (const v of variants) {
|
|
453
|
+
const c = (t) => kotlinColorOf(t, theme, base);
|
|
454
|
+
const type = library ? ": GlassMaterial" : "";
|
|
455
|
+
out.push(
|
|
456
|
+
` ${vis}val ${pascal(v.id)}${pascal(theme)}${type} = GlassMaterial(`,
|
|
457
|
+
` tint = ${c(v.tint)},`,
|
|
458
|
+
` border = ${c(v.border)},`,
|
|
459
|
+
` edge = ${c(v.edge)},`,
|
|
460
|
+
` dim = ${c(v.dim)},`,
|
|
461
|
+
` blur = ${px(valueFor(v.blur, theme, base))},`,
|
|
462
|
+
` saturate = ${Number.parseFloat(valueFor(v.saturate, theme, base))}f,`,
|
|
463
|
+
" )",
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
out.push("}", "");
|
|
468
|
+
return out;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export function buildThemeKt(tokens, pkg = "com.jcsoftdev.ui.theme", { library = false } = {}) {
|
|
472
|
+
if (library) return buildLibraryThemeKt(tokens, pkg);
|
|
358
473
|
const { base, others } = themeOf(tokens);
|
|
359
474
|
const themes = [base, ...others];
|
|
360
475
|
const colors = (tokens.color?.tokens ?? []).filter((t) => !t.name.startsWith("pal-"));
|
|
@@ -435,15 +550,143 @@ export function buildThemeKt(tokens, pkg = "com.jcsoftdev.ui.theme") {
|
|
|
435
550
|
out.push(` val ${camel(s.name)} = TextStyle(${parts.join(", ")})`);
|
|
436
551
|
}
|
|
437
552
|
out.push("}", "");
|
|
553
|
+
const sizeScale = tokens.type?.sizeScale ?? [];
|
|
554
|
+
if (sizeScale.length > 0) {
|
|
555
|
+
out.push("object UiFontSizes {");
|
|
556
|
+
for (const s of sizeScale)
|
|
557
|
+
out.push(` val ${camel(s.name)} = ${Number.parseFloat(s.fontSize)}.sp`);
|
|
558
|
+
out.push("}", "");
|
|
559
|
+
}
|
|
560
|
+
out.push(...glassKotlin(tokens, { library: false }));
|
|
561
|
+
return out.join("\n");
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Library flavour of Theme.kt: explicit `public` + types (the kit compiles with explicitApi),
|
|
566
|
+
* @Immutable token holders, and no Map in the API (Compose treats Map as unstable), so accent
|
|
567
|
+
* palettes are resolved with a `when` lookup.
|
|
568
|
+
*/
|
|
569
|
+
function buildLibraryThemeKt(tokens, pkg) {
|
|
570
|
+
const { base, others } = themeOf(tokens);
|
|
571
|
+
const themes = [base, ...others];
|
|
572
|
+
const colors = (tokens.color?.tokens ?? []).filter((t) => !t.name.startsWith("pal-"));
|
|
573
|
+
const out = [
|
|
574
|
+
`// Generated by ui-theme from "${tokens.name}". Do not edit.`,
|
|
575
|
+
"",
|
|
576
|
+
`package ${pkg}`,
|
|
577
|
+
"",
|
|
578
|
+
"import androidx.compose.foundation.shape.RoundedCornerShape",
|
|
579
|
+
"import androidx.compose.runtime.Immutable",
|
|
580
|
+
"import androidx.compose.ui.graphics.Color",
|
|
581
|
+
"import androidx.compose.ui.text.TextStyle",
|
|
582
|
+
"import androidx.compose.ui.text.font.FontWeight",
|
|
583
|
+
"import androidx.compose.ui.unit.Dp",
|
|
584
|
+
"import androidx.compose.ui.unit.TextUnit",
|
|
585
|
+
"import androidx.compose.ui.unit.dp",
|
|
586
|
+
"import androidx.compose.ui.unit.em",
|
|
587
|
+
"import androidx.compose.ui.unit.sp",
|
|
588
|
+
"",
|
|
589
|
+
"@Immutable",
|
|
590
|
+
"public class ThemeColors(",
|
|
591
|
+
...colors.map((t) => ` public val ${camel(t.name)}: Color,`),
|
|
592
|
+
")",
|
|
593
|
+
"",
|
|
594
|
+
"public object UiColors {",
|
|
595
|
+
];
|
|
596
|
+
for (const theme of themes) {
|
|
597
|
+
out.push(` public val ${pascal(theme)}: ThemeColors = ThemeColors(`);
|
|
598
|
+
for (const t of colors) {
|
|
599
|
+
out.push(` ${camel(t.name)} = ${kotlinColorOf(t, theme, base)},`);
|
|
600
|
+
}
|
|
601
|
+
out.push(" )");
|
|
602
|
+
}
|
|
603
|
+
out.push("}", "");
|
|
604
|
+
|
|
605
|
+
const palettes = palettesOf(tokens);
|
|
606
|
+
if (palettes.size) {
|
|
607
|
+
const byName = new Map(tokens.color.tokens.map((t) => [t.name, t]));
|
|
608
|
+
out.push("@Immutable", "public class AccentPalette(");
|
|
609
|
+
for (const target of Object.values(PALETTE_ROLES)) {
|
|
610
|
+
out.push(` public val ${camel(target)}: Color,`);
|
|
611
|
+
}
|
|
612
|
+
out.push(")", "", "@Immutable", "public object UiPalettes {");
|
|
613
|
+
out.push(
|
|
614
|
+
` public val ids: List<String> = listOf(${[...palettes.keys()].map((id) => `"${id}"`).join(", ")})`,
|
|
615
|
+
);
|
|
616
|
+
for (const theme of themes) {
|
|
617
|
+
out.push("");
|
|
618
|
+
for (const [id, roles] of palettes) {
|
|
619
|
+
const args = Object.keys(PALETTE_ROLES).map((role) => {
|
|
620
|
+
const tok = byName.get(roles[role]);
|
|
621
|
+
return tok ? kotlinColorOf(tok, theme, base) : "Color.Unspecified";
|
|
622
|
+
});
|
|
623
|
+
out.push(` private val ${camel(`${theme}-${id}`)} = AccentPalette(${args.join(", ")})`);
|
|
624
|
+
}
|
|
625
|
+
out.push(
|
|
626
|
+
"",
|
|
627
|
+
` public fun ${camel(theme)}(id: String): AccentPalette? =`,
|
|
628
|
+
" when (id) {",
|
|
629
|
+
);
|
|
630
|
+
for (const id of palettes.keys()) {
|
|
631
|
+
out.push(` "${id}" -> ${camel(`${theme}-${id}`)}`);
|
|
632
|
+
}
|
|
633
|
+
out.push(" else -> null", " }");
|
|
634
|
+
}
|
|
635
|
+
out.push("}", "");
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
out.push("public object UiShapes {");
|
|
639
|
+
for (const t of tokens.radius?.tokens ?? []) {
|
|
640
|
+
const n = camel(stripPrefix(t.name, "radius"));
|
|
641
|
+
const pill = Number.parseFloat(t.value) >= 999;
|
|
642
|
+
out.push(
|
|
643
|
+
` public val ${n}: RoundedCornerShape = RoundedCornerShape(${pill ? "50" : px(t.value)})`,
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
out.push("}", "", "public object UiSizes {");
|
|
647
|
+
for (const t of [...(tokens.spacing?.tokens ?? []), ...(tokens.size?.tokens ?? [])]) {
|
|
648
|
+
out.push(` public val ${camel(t.name)}: Dp = ${px(t.value)}`);
|
|
649
|
+
}
|
|
650
|
+
out.push("}", "");
|
|
651
|
+
|
|
652
|
+
const family = (tokens.type?.fonts ?? [])[0]?.family ?? "";
|
|
653
|
+
out.push(
|
|
654
|
+
`public const val UiFontFamilyName: String = "${family}"`,
|
|
655
|
+
"",
|
|
656
|
+
"public object UiTypography {",
|
|
657
|
+
);
|
|
658
|
+
for (const s of typeStyles(tokens)) {
|
|
659
|
+
const size = Number.parseFloat(s.fontSize);
|
|
660
|
+
const parts = [`fontSize = ${size}.sp`];
|
|
661
|
+
if (s.fontWeight !== undefined) parts.push(`fontWeight = FontWeight(${s.fontWeight})`);
|
|
662
|
+
if (s.lineHeight !== undefined) {
|
|
663
|
+
const lh = String(s.lineHeight).endsWith("px")
|
|
664
|
+
? Number.parseFloat(s.lineHeight)
|
|
665
|
+
: Number((size * Number(s.lineHeight)).toFixed(2));
|
|
666
|
+
parts.push(`lineHeight = ${lh}.sp`);
|
|
667
|
+
}
|
|
668
|
+
if (s.letterSpacing) parts.push(`letterSpacing = (${Number.parseFloat(s.letterSpacing)}).em`);
|
|
669
|
+
out.push(` public val ${camel(s.name)}: TextStyle = TextStyle(${parts.join(", ")})`);
|
|
670
|
+
}
|
|
671
|
+
out.push("}", "");
|
|
672
|
+
const sizeScale = tokens.type?.sizeScale ?? [];
|
|
673
|
+
if (sizeScale.length > 0) {
|
|
674
|
+
out.push("public object UiFontSizes {");
|
|
675
|
+
for (const s of sizeScale)
|
|
676
|
+
out.push(` public val ${camel(s.name)}: TextUnit = ${Number.parseFloat(s.fontSize)}.sp`);
|
|
677
|
+
out.push("}", "");
|
|
678
|
+
}
|
|
679
|
+
out.push(...glassKotlin(tokens, { library: true }));
|
|
438
680
|
return out.join("\n");
|
|
439
681
|
}
|
|
440
682
|
|
|
441
|
-
export function buildTheme(tokens, { kotlinPackage, kotlin = true } = {}) {
|
|
683
|
+
export function buildTheme(tokens, { kotlinPackage, kotlinLibrary = false, kotlin = true } = {}) {
|
|
442
684
|
const css = {
|
|
443
685
|
"tokens.css": buildTokensCss(tokens),
|
|
444
686
|
"theme.css": buildThemeCss(tokens),
|
|
687
|
+
"tailwind.css": buildThemeCss(tokens),
|
|
445
688
|
"fonts.css": buildFontsCss(tokens),
|
|
446
689
|
};
|
|
447
690
|
if (!kotlin) return css;
|
|
448
|
-
return { ...css, "Theme.kt": buildThemeKt(tokens, kotlinPackage) };
|
|
691
|
+
return { ...css, "Theme.kt": buildThemeKt(tokens, kotlinPackage, { library: kotlinLibrary }) };
|
|
449
692
|
}
|
|
@@ -122,7 +122,7 @@ export function Attachment({
|
|
|
122
122
|
onClick={onRemove}
|
|
123
123
|
className={cn(
|
|
124
124
|
"size-5",
|
|
125
|
-
preview && "absolute right-2.5 top-2.5
|
|
125
|
+
preview && "absolute right-2.5 top-2.5 surface-overlay shadow-control",
|
|
126
126
|
classNames?.remove,
|
|
127
127
|
)}
|
|
128
128
|
>
|
|
@@ -35,7 +35,9 @@ export function groupByDate<T extends Dated>(
|
|
|
35
35
|
const buckets = new Map<DateGroupId, T[]>();
|
|
36
36
|
for (const item of items) {
|
|
37
37
|
const id = groupOf(item.updatedAt, now);
|
|
38
|
-
|
|
38
|
+
const bucket = buckets.get(id);
|
|
39
|
+
if (bucket) bucket.push(item);
|
|
40
|
+
else buckets.set(id, [item]);
|
|
39
41
|
}
|
|
40
42
|
return ORDER.flatMap((id) => {
|
|
41
43
|
const list = buckets.get(id);
|
|
@@ -103,7 +103,7 @@ export function Conversation({
|
|
|
103
103
|
toBottom(!reduced);
|
|
104
104
|
}}
|
|
105
105
|
className={cn(
|
|
106
|
-
"absolute bottom-3 left-1/2 inline-flex h-control-sm -translate-x-1/2 cursor-pointer items-center gap-1.5 rounded-button
|
|
106
|
+
"absolute bottom-3 left-1/2 inline-flex h-control-sm -translate-x-1/2 cursor-pointer items-center gap-1.5 rounded-button px-3 text-meta text-ink shadow-overlay border-control surface-overlay pressable focus-visible:focus-ring",
|
|
107
107
|
classNames?.jump,
|
|
108
108
|
)}
|
|
109
109
|
>
|
|
@@ -1,38 +1 @@
|
|
|
1
|
-
"use
|
|
2
|
-
|
|
3
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
-
|
|
5
|
-
/** Copies text to the clipboard (with a textarea fallback) and flags success for `resetMs`. */
|
|
6
|
-
export function useCopy(resetMs = 1600) {
|
|
7
|
-
const [copied, setCopied] = useState(false);
|
|
8
|
-
const timer = useRef<number | undefined>(undefined);
|
|
9
|
-
|
|
10
|
-
useEffect(() => () => window.clearTimeout(timer.current), []);
|
|
11
|
-
|
|
12
|
-
const copy = useCallback(
|
|
13
|
-
async (text: string) => {
|
|
14
|
-
try {
|
|
15
|
-
await navigator.clipboard.writeText(text);
|
|
16
|
-
} catch {
|
|
17
|
-
const area = document.createElement("textarea");
|
|
18
|
-
area.value = text;
|
|
19
|
-
area.setAttribute("readonly", "");
|
|
20
|
-
area.style.position = "fixed";
|
|
21
|
-
area.style.opacity = "0";
|
|
22
|
-
document.body.append(area);
|
|
23
|
-
area.select();
|
|
24
|
-
try {
|
|
25
|
-
document.execCommand("copy");
|
|
26
|
-
} finally {
|
|
27
|
-
area.remove();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
setCopied(true);
|
|
31
|
-
window.clearTimeout(timer.current);
|
|
32
|
-
timer.current = window.setTimeout(() => setCopied(false), resetMs);
|
|
33
|
-
},
|
|
34
|
-
[resetMs],
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
return { copied, copy };
|
|
38
|
-
}
|
|
1
|
+
export { useCopy } from "../../utils/use-copy.js";
|
package/src/ai/markdown/parse.ts
CHANGED
|
@@ -41,10 +41,20 @@ export function safeHref(raw: string): string | null {
|
|
|
41
41
|
|
|
42
42
|
const ESCAPABLE = /[\\`*_[\]()#+\-.!|>~]/;
|
|
43
43
|
|
|
44
|
+
/** Table columns beyond this are dropped, so cells stay bounded by rows x MAX_COLUMNS. */
|
|
45
|
+
const MAX_COLUMNS = 64;
|
|
46
|
+
const NO_INLINES: Inline[] = [];
|
|
47
|
+
|
|
48
|
+
/** Deeper blockquotes and list items are kept as literal text, so input cannot exhaust the stack. */
|
|
49
|
+
const MAX_NESTING = 32;
|
|
50
|
+
/** A link destination longer than this is not a link, which keeps the scan for `)` bounded. */
|
|
51
|
+
const MAX_LINK_TARGET = 1024;
|
|
52
|
+
|
|
44
53
|
/** Index of the `)` that closes a link destination, honoring balanced inner parentheses. */
|
|
45
54
|
function closingParen(src: string, from: number): number {
|
|
46
55
|
let depth = 0;
|
|
47
|
-
|
|
56
|
+
const stop = Math.min(src.length, from + MAX_LINK_TARGET);
|
|
57
|
+
for (let i = from; i < stop; i += 1) {
|
|
48
58
|
if (src[i] === "(") depth += 1;
|
|
49
59
|
else if (src[i] === ")") {
|
|
50
60
|
if (depth === 0) return i;
|
|
@@ -62,6 +72,7 @@ export function parseInline(src: string): Inline[] {
|
|
|
62
72
|
buf = "";
|
|
63
73
|
};
|
|
64
74
|
let i = 0;
|
|
75
|
+
let nextMid = -2;
|
|
65
76
|
while (i < src.length) {
|
|
66
77
|
const ch = src[i] as string;
|
|
67
78
|
const next = src[i + 1];
|
|
@@ -105,7 +116,9 @@ export function parseInline(src: string): Inline[] {
|
|
|
105
116
|
}
|
|
106
117
|
}
|
|
107
118
|
if (ch === "[") {
|
|
108
|
-
|
|
119
|
+
// The first "](" after any earlier "[" is still the first one after this "[" while it lies ahead.
|
|
120
|
+
if (nextMid !== -1 && nextMid <= i) nextMid = src.indexOf("](", i + 1);
|
|
121
|
+
const mid = nextMid;
|
|
109
122
|
const end = mid > i ? closingParen(src, mid + 2) : -1;
|
|
110
123
|
if (end > mid) {
|
|
111
124
|
flush();
|
|
@@ -119,7 +132,9 @@ export function parseInline(src: string): Inline[] {
|
|
|
119
132
|
}
|
|
120
133
|
}
|
|
121
134
|
if (ch === "\n") {
|
|
122
|
-
|
|
135
|
+
let end = buf.length;
|
|
136
|
+
while (end > 0 && buf[end - 1] === " ") end -= 1;
|
|
137
|
+
buf = buf.slice(0, end);
|
|
123
138
|
flush();
|
|
124
139
|
out.push({ t: "br" });
|
|
125
140
|
i += 1;
|
|
@@ -133,10 +148,31 @@ export function parseInline(src: string): Inline[] {
|
|
|
133
148
|
}
|
|
134
149
|
|
|
135
150
|
const FENCE = /^\s{0,3}(`{3,}|~{3,})\s*([\w+#.-]*)/;
|
|
136
|
-
|
|
151
|
+
// Only space and tab count as whitespace here, and `s` lets `.` cross U+2028/U+2029: both keep matching linear.
|
|
152
|
+
const HEADING = /^[ \t]{0,3}(#{1,6})[ \t](.*)$/s;
|
|
153
|
+
|
|
154
|
+
/** Heading level and text; the optional closing `#` run is stripped in code to keep matching linear. */
|
|
155
|
+
function matchHeading(line: string): { level: 1 | 2 | 3 | 4 | 5 | 6; text: string } | null {
|
|
156
|
+
const m = HEADING.exec(line);
|
|
157
|
+
if (!m) return null;
|
|
158
|
+
let text = (m[2] as string).trim();
|
|
159
|
+
let end = text.length;
|
|
160
|
+
while (end > 0 && text[end - 1] === "#") end -= 1;
|
|
161
|
+
if (end > 0 && end < text.length && /\s/.test(text[end - 1] as string)) {
|
|
162
|
+
text = text.slice(0, end).trimEnd();
|
|
163
|
+
}
|
|
164
|
+
return { level: (m[1] as string).length as 1 | 2 | 3 | 4 | 5 | 6, text };
|
|
165
|
+
}
|
|
137
166
|
const HR = /^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/;
|
|
138
|
-
const ITEM = /^(\
|
|
139
|
-
const
|
|
167
|
+
const ITEM = /^([ \t]*)([-*+]|\d{1,9}[.)])[ \t]+(.*)$/s;
|
|
168
|
+
const TABLE_CELL_RULE = /^:?-+:?$/;
|
|
169
|
+
|
|
170
|
+
function isTableRule(line: string): boolean {
|
|
171
|
+
let row = line.trim();
|
|
172
|
+
if (row.startsWith("|")) row = row.slice(1);
|
|
173
|
+
if (row.endsWith("|")) row = row.slice(0, -1);
|
|
174
|
+
return row !== "" && row.split("|").every((cell) => TABLE_CELL_RULE.test(cell.trim()));
|
|
175
|
+
}
|
|
140
176
|
|
|
141
177
|
function splitRow(line: string): string[] {
|
|
142
178
|
let row = line.trim();
|
|
@@ -154,7 +190,7 @@ function alignOf(cell: string): TableAlign {
|
|
|
154
190
|
}
|
|
155
191
|
|
|
156
192
|
function isTableStart(line: string, next: string | undefined): boolean {
|
|
157
|
-
return line.includes("|") && !!next?.includes("-") &&
|
|
193
|
+
return line.includes("|") && !!next?.includes("-") && isTableRule(next);
|
|
158
194
|
}
|
|
159
195
|
|
|
160
196
|
function startsBlock(line: string, next: string | undefined): boolean {
|
|
@@ -170,7 +206,23 @@ function startsBlock(line: string, next: string | undefined): boolean {
|
|
|
170
206
|
|
|
171
207
|
/** Parses Markdown into blocks. An unclosed code fence runs to the end (streaming friendly). */
|
|
172
208
|
export function parseMarkdown(src: string): Block[] {
|
|
209
|
+
return parseBlocks(src, 0);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function literal(src: string): Block[] {
|
|
213
|
+
return [{ t: "p", c: [{ t: "text", v: src }] }];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** List markers indented past what the nesting cap can honor lose the excess, so deep input stays linear. */
|
|
217
|
+
const EXCESS_INDENT = new RegExp(`^\\s{${2 * MAX_NESTING + 4},}(?=([-*+]|\\d{1,9}[.)])\\s)`);
|
|
218
|
+
|
|
219
|
+
function parseBlocks(src: string, depth: number): Block[] {
|
|
173
220
|
const lines = src.replace(/\r\n?/g, "\n").split("\n");
|
|
221
|
+
if (depth === 0) {
|
|
222
|
+
for (let n = 0; n < lines.length; n += 1) {
|
|
223
|
+
lines[n] = (lines[n] as string).replace(EXCESS_INDENT, " ".repeat(2 * MAX_NESTING + 4));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
174
226
|
const at = (n: number) => lines[n] as string;
|
|
175
227
|
const blocks: Block[] = [];
|
|
176
228
|
let i = 0;
|
|
@@ -195,13 +247,9 @@ export function parseMarkdown(src: string): Block[] {
|
|
|
195
247
|
blocks.push({ t: "code", lang: fence[2] ?? "", v: body.join("\n") });
|
|
196
248
|
continue;
|
|
197
249
|
}
|
|
198
|
-
const heading =
|
|
250
|
+
const heading = matchHeading(line);
|
|
199
251
|
if (heading) {
|
|
200
|
-
blocks.push({
|
|
201
|
-
t: "heading",
|
|
202
|
-
level: (heading[1] as string).length as 1 | 2 | 3 | 4 | 5 | 6,
|
|
203
|
-
c: parseInline(heading[2] as string),
|
|
204
|
-
});
|
|
252
|
+
blocks.push({ t: "heading", level: heading.level, c: parseInline(heading.text) });
|
|
205
253
|
i += 1;
|
|
206
254
|
continue;
|
|
207
255
|
}
|
|
@@ -216,17 +264,25 @@ export function parseMarkdown(src: string): Block[] {
|
|
|
216
264
|
body.push(at(i).replace(/^\s{0,3}>\s?/, ""));
|
|
217
265
|
i += 1;
|
|
218
266
|
}
|
|
219
|
-
|
|
267
|
+
const inner = body.join("\n");
|
|
268
|
+
blocks.push({
|
|
269
|
+
t: "quote",
|
|
270
|
+
c: depth >= MAX_NESTING ? literal(inner) : parseBlocks(inner, depth + 1),
|
|
271
|
+
});
|
|
220
272
|
continue;
|
|
221
273
|
}
|
|
222
274
|
if (isTableStart(line, lines[i + 1])) {
|
|
223
|
-
const head = splitRow(line);
|
|
275
|
+
const head = splitRow(line).slice(0, MAX_COLUMNS);
|
|
224
276
|
const align = splitRow(at(i + 1)).map(alignOf);
|
|
225
277
|
const rows: Inline[][][] = [];
|
|
226
278
|
i += 2;
|
|
227
279
|
while (i < lines.length && at(i).trim() && at(i).includes("|")) {
|
|
228
280
|
const cells = splitRow(at(i));
|
|
229
|
-
rows.push(
|
|
281
|
+
rows.push(
|
|
282
|
+
head.map((_, col) =>
|
|
283
|
+
col < cells.length ? parseInline(cells[col] as string) : NO_INLINES,
|
|
284
|
+
),
|
|
285
|
+
);
|
|
230
286
|
i += 1;
|
|
231
287
|
}
|
|
232
288
|
blocks.push({
|
|
@@ -258,7 +314,8 @@ export function parseMarkdown(src: string): Block[] {
|
|
|
258
314
|
}
|
|
259
315
|
items.push({
|
|
260
316
|
c: parseInline(current[3] as string),
|
|
261
|
-
children:
|
|
317
|
+
children:
|
|
318
|
+
depth >= MAX_NESTING ? literal(sub.join("\n")) : parseBlocks(sub.join("\n"), depth + 1),
|
|
262
319
|
});
|
|
263
320
|
}
|
|
264
321
|
blocks.push({ t: "list", ordered, start, items });
|
package/src/ai/source/source.tsx
CHANGED
|
@@ -91,7 +91,7 @@ export function Source({
|
|
|
91
91
|
</HoverCardTrigger>
|
|
92
92
|
<HoverCardContent
|
|
93
93
|
className={cn(
|
|
94
|
-
"@container/source w-72 max-w-[calc(100vw-1rem)] rounded-popover
|
|
94
|
+
"@container/source w-72 max-w-[calc(100vw-1rem)] rounded-popover p-3 text-ink shadow-overlay border-control surface-overlay",
|
|
95
95
|
classNames?.card,
|
|
96
96
|
)}
|
|
97
97
|
>
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import { type ComponentPropsWithRef, useEffect, useState } from "react";
|
|
4
4
|
import type { ClassNames } from "../../utils/class-names.js";
|
|
5
5
|
import { cn } from "../../utils/cn.js";
|
|
6
|
+
import { customToneStyle, isCustomTone } from "../../utils/tone.js";
|
|
7
|
+
import { StatusDot, type StatusDotTone } from "../status-dot/status-dot.js";
|
|
6
8
|
|
|
7
9
|
type ImageStatus = "idle" | "loading" | "loaded" | "error";
|
|
8
10
|
|
|
@@ -67,15 +69,37 @@ const sizeClasses: Record<AvatarSize, string> = {
|
|
|
67
69
|
lg: "size-8 text-fs-110",
|
|
68
70
|
};
|
|
69
71
|
|
|
70
|
-
export type
|
|
72
|
+
export type AvatarBuiltinTone = "neutral" | "accent" | "success" | "warning" | "danger" | "info";
|
|
73
|
+
|
|
74
|
+
/** A built-in tone, or the name of a tone declared in `tonePalettes`. */
|
|
75
|
+
export type AvatarTone = AvatarBuiltinTone | (string & {});
|
|
76
|
+
|
|
77
|
+
const toneClasses: Record<AvatarBuiltinTone, string> = {
|
|
78
|
+
neutral: "bg-sunken text-ink-2",
|
|
79
|
+
accent: "bg-accent-soft text-accent-ink",
|
|
80
|
+
success: "bg-success-soft text-success",
|
|
81
|
+
warning: "bg-warning-soft text-warning",
|
|
82
|
+
danger: "bg-danger-soft text-danger",
|
|
83
|
+
info: "bg-info-soft text-info",
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const builtinTones = new Set<string>(Object.keys(toneClasses));
|
|
87
|
+
|
|
88
|
+
export type AvatarPart = "root" | "image" | "fallback" | "wrapper" | "status";
|
|
71
89
|
|
|
72
90
|
export interface AvatarProps extends Omit<ComponentPropsWithRef<"span">, "children"> {
|
|
73
91
|
/** Full name: used for the initials fallback and as the accessible name. */
|
|
74
92
|
name: string;
|
|
75
93
|
src?: string;
|
|
76
94
|
size?: AvatarSize;
|
|
77
|
-
/** Fills the avatar with the accent color (e.g. the current user). */
|
|
95
|
+
/** Fills the avatar with the accent color (e.g. the current user). Wins over `tone`. */
|
|
78
96
|
highlighted?: boolean;
|
|
97
|
+
/** Soft background and ink colour of the initials. */
|
|
98
|
+
tone?: AvatarTone;
|
|
99
|
+
/** Small status dot at the bottom-right corner. */
|
|
100
|
+
status?: StatusDotTone;
|
|
101
|
+
/** Accessible text for the status dot; defaults to the status name. */
|
|
102
|
+
statusLabel?: string;
|
|
79
103
|
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
80
104
|
classNames?: ClassNames<AvatarPart>;
|
|
81
105
|
}
|
|
@@ -85,21 +109,30 @@ export function Avatar({
|
|
|
85
109
|
src,
|
|
86
110
|
size = "md",
|
|
87
111
|
highlighted,
|
|
112
|
+
tone = "neutral",
|
|
113
|
+
status: statusTone,
|
|
114
|
+
statusLabel,
|
|
88
115
|
className,
|
|
89
116
|
classNames,
|
|
117
|
+
style,
|
|
90
118
|
...props
|
|
91
119
|
}: AvatarProps) {
|
|
92
120
|
const status = useImageStatus(src);
|
|
93
121
|
const delayElapsed = useDelayElapsed(src ? 400 : undefined);
|
|
94
122
|
|
|
95
|
-
|
|
123
|
+
const toneClass = isCustomTone(tone, builtinTones)
|
|
124
|
+
? "bg-(--tone-c-soft) text-(--tone-c-ink)"
|
|
125
|
+
: (toneClasses[tone as AvatarBuiltinTone] ?? toneClasses.neutral);
|
|
126
|
+
|
|
127
|
+
const avatar = (
|
|
96
128
|
<span
|
|
97
129
|
role="img"
|
|
98
130
|
aria-label={name}
|
|
99
131
|
{...props}
|
|
132
|
+
style={customToneStyle(tone, builtinTones, style)}
|
|
100
133
|
className={cn(
|
|
101
134
|
"inline-grid shrink-0 place-items-center overflow-hidden rounded-avatar font-bold tracking-[.02em]",
|
|
102
|
-
highlighted ? "bg-accent text-on-accent" :
|
|
135
|
+
highlighted ? "bg-accent text-on-accent" : toneClass,
|
|
103
136
|
sizeClasses[size],
|
|
104
137
|
classNames?.root,
|
|
105
138
|
className,
|
|
@@ -113,4 +146,24 @@ export function Avatar({
|
|
|
113
146
|
) : null}
|
|
114
147
|
</span>
|
|
115
148
|
);
|
|
149
|
+
|
|
150
|
+
if (statusTone === undefined) return avatar;
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<span className={cn("relative inline-flex shrink-0", classNames?.wrapper)}>
|
|
154
|
+
{avatar}
|
|
155
|
+
<span
|
|
156
|
+
className={cn(
|
|
157
|
+
"absolute right-0 bottom-0 inline-flex rounded-pill bg-surface p-0.5",
|
|
158
|
+
classNames?.status,
|
|
159
|
+
)}
|
|
160
|
+
>
|
|
161
|
+
<StatusDot
|
|
162
|
+
tone={statusTone}
|
|
163
|
+
label={statusLabel ?? statusTone}
|
|
164
|
+
classNames={{ dot: "size-2" }}
|
|
165
|
+
/>
|
|
166
|
+
</span>
|
|
167
|
+
</span>
|
|
168
|
+
);
|
|
116
169
|
}
|