@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
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useId,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState
|
|
9
|
+
} from "react";
|
|
10
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
11
|
+
import { ChevronDown } from "../../icons/index.js";
|
|
12
|
+
import * as PopoverPrimitive from "../../primitives/popover/popover.js";
|
|
13
|
+
import { cn } from "../../utils/cn.js";
|
|
14
|
+
import { useComposedRefs } from "../../utils/compose.js";
|
|
15
|
+
import { materialClass } from "../../utils/material.js";
|
|
16
|
+
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
17
|
+
import {
|
|
18
|
+
flattenItems,
|
|
19
|
+
isTypeaheadKey,
|
|
20
|
+
moveActive,
|
|
21
|
+
nextTypeahead,
|
|
22
|
+
typeaheadIndex
|
|
23
|
+
} from "../internal/listbox.js";
|
|
24
|
+
import { LISTBOX_SURFACE, ListboxItems, optionDomId } from "../internal/listbox-items.js";
|
|
25
|
+
const TYPEAHEAD_MS = 600;
|
|
26
|
+
const OPEN_KEYS = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "Enter", " "]);
|
|
27
|
+
function SelectMenu({
|
|
28
|
+
options,
|
|
29
|
+
value: valueProp,
|
|
30
|
+
defaultValue,
|
|
31
|
+
onValueChange,
|
|
32
|
+
placeholder,
|
|
33
|
+
name,
|
|
34
|
+
required,
|
|
35
|
+
invalid,
|
|
36
|
+
size = "md",
|
|
37
|
+
container,
|
|
38
|
+
material,
|
|
39
|
+
disabled,
|
|
40
|
+
className,
|
|
41
|
+
classNames,
|
|
42
|
+
onKeyDown,
|
|
43
|
+
onKeyUp,
|
|
44
|
+
onClick,
|
|
45
|
+
ref,
|
|
46
|
+
id,
|
|
47
|
+
"aria-label": ariaLabel,
|
|
48
|
+
"aria-labelledby": ariaLabelledBy,
|
|
49
|
+
"aria-invalid": ariaInvalid,
|
|
50
|
+
...props
|
|
51
|
+
}) {
|
|
52
|
+
const strings = useUiStrings();
|
|
53
|
+
const listId = useId();
|
|
54
|
+
const triggerRef = useRef(null);
|
|
55
|
+
const composedRef = useComposedRefs(ref, triggerRef);
|
|
56
|
+
const typeahead = useRef({ buffer: "", at: 0 });
|
|
57
|
+
const [value, setValue] = useControllableState({
|
|
58
|
+
prop: valueProp,
|
|
59
|
+
defaultProp: defaultValue,
|
|
60
|
+
onChange: (next) => {
|
|
61
|
+
if (next !== void 0) onValueChange?.(next);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const [open, setOpenState] = useState(false);
|
|
65
|
+
const [active, setActive] = useState(-1);
|
|
66
|
+
const [listLabel, setListLabel] = useState();
|
|
67
|
+
const flat = useMemo(() => flattenItems(options), [options]);
|
|
68
|
+
const selectedIndex = flat.findIndex((option) => option.value === value);
|
|
69
|
+
const selected = flat[selectedIndex];
|
|
70
|
+
const isDisabled = Boolean(disabled);
|
|
71
|
+
const setOpen = (next, move) => {
|
|
72
|
+
if (next && isDisabled) return;
|
|
73
|
+
if (next) {
|
|
74
|
+
const preferred = selected && !selected.disabled ? selectedIndex : -1;
|
|
75
|
+
setActive(
|
|
76
|
+
move ? moveActive(flat, move === "last" ? flat.length : -1, move) : preferred >= 0 ? preferred : moveActive(flat, -1, "first")
|
|
77
|
+
);
|
|
78
|
+
setListLabel(triggerRef.current?.labels?.[0]?.textContent?.trim() || void 0);
|
|
79
|
+
}
|
|
80
|
+
setOpenState(next);
|
|
81
|
+
};
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (!open || active < 0) return;
|
|
84
|
+
document.getElementById(optionDomId(listId, active))?.scrollIntoView?.({ block: "nearest" });
|
|
85
|
+
}, [open, active, listId]);
|
|
86
|
+
const pick = (index) => {
|
|
87
|
+
const option = flat[index];
|
|
88
|
+
if (!option || option.disabled) return;
|
|
89
|
+
setValue(option.value);
|
|
90
|
+
setOpenState(false);
|
|
91
|
+
};
|
|
92
|
+
const handleKeyDown = (event) => {
|
|
93
|
+
onKeyDown?.(event);
|
|
94
|
+
if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
95
|
+
const { key } = event;
|
|
96
|
+
const buffering = typeahead.current.buffer !== "" && Date.now() - typeahead.current.at <= TYPEAHEAD_MS;
|
|
97
|
+
const typing = isTypeaheadKey(event) && !(key === " " && !buffering);
|
|
98
|
+
if (typing) {
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
typeahead.current = nextTypeahead(typeahead.current, key, Date.now());
|
|
101
|
+
const found = typeaheadIndex(flat, typeahead.current.buffer, open ? active : selectedIndex);
|
|
102
|
+
if (found < 0) return;
|
|
103
|
+
if (open) setActive(found);
|
|
104
|
+
else pick(found);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (!open) {
|
|
108
|
+
if (OPEN_KEYS.has(key)) {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
setOpen(true);
|
|
111
|
+
} else if (key === "Home" || key === "End") {
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
setOpen(true, key === "Home" ? "first" : "last");
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const moves = {
|
|
118
|
+
ArrowDown: "next",
|
|
119
|
+
ArrowUp: "prev",
|
|
120
|
+
Home: "first",
|
|
121
|
+
End: "last"
|
|
122
|
+
};
|
|
123
|
+
const move = moves[key];
|
|
124
|
+
if (move) {
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
setActive((current) => moveActive(flat, current, move));
|
|
127
|
+
} else if (key === "Enter" || key === " ") {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
pick(active);
|
|
130
|
+
} else if (key === "Tab") {
|
|
131
|
+
setOpenState(false);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const showPlaceholder = !selected;
|
|
135
|
+
return /* @__PURE__ */ jsxs(PopoverPrimitive.Root, { open, onOpenChange: (next) => setOpen(next), children: [
|
|
136
|
+
/* @__PURE__ */ jsxs(
|
|
137
|
+
PopoverPrimitive.Trigger,
|
|
138
|
+
{
|
|
139
|
+
ref: composedRef,
|
|
140
|
+
id,
|
|
141
|
+
role: "combobox",
|
|
142
|
+
"data-ui-layer": "",
|
|
143
|
+
"aria-haspopup": "listbox",
|
|
144
|
+
"aria-expanded": open,
|
|
145
|
+
"aria-controls": open ? listId : void 0,
|
|
146
|
+
"aria-activedescendant": open && active >= 0 ? optionDomId(listId, active) : void 0,
|
|
147
|
+
"aria-required": required || void 0,
|
|
148
|
+
"aria-invalid": ariaInvalid ?? (invalid || void 0),
|
|
149
|
+
"aria-label": ariaLabel,
|
|
150
|
+
"aria-labelledby": ariaLabelledBy,
|
|
151
|
+
disabled,
|
|
152
|
+
"data-placeholder": showPlaceholder ? "" : void 0,
|
|
153
|
+
...props,
|
|
154
|
+
onClick: (event) => {
|
|
155
|
+
onClick?.(event);
|
|
156
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
157
|
+
},
|
|
158
|
+
onKeyDown: handleKeyDown,
|
|
159
|
+
onKeyUp: (event) => {
|
|
160
|
+
onKeyUp?.(event);
|
|
161
|
+
if (event.key === " ") event.preventDefault();
|
|
162
|
+
},
|
|
163
|
+
className: cn(
|
|
164
|
+
"flex w-full min-w-0 items-center justify-between gap-2 rounded-input border-control bg-surface-control py-0 pr-2.5 pl-3 text-left text-control text-ink focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-danger",
|
|
165
|
+
size === "sm" ? "h-control-sm" : "h-input min-h-(--touch-target)",
|
|
166
|
+
classNames?.trigger,
|
|
167
|
+
className
|
|
168
|
+
),
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ jsx(
|
|
171
|
+
"span",
|
|
172
|
+
{
|
|
173
|
+
className: cn(
|
|
174
|
+
"min-w-0 flex-1 truncate",
|
|
175
|
+
showPlaceholder && "text-ink-3",
|
|
176
|
+
classNames?.value
|
|
177
|
+
),
|
|
178
|
+
children: selected?.label ?? placeholder ?? strings.selectPlaceholder
|
|
179
|
+
}
|
|
180
|
+
),
|
|
181
|
+
/* @__PURE__ */ jsx(
|
|
182
|
+
ChevronDown,
|
|
183
|
+
{
|
|
184
|
+
"aria-hidden": "true",
|
|
185
|
+
className: cn("size-3.5 shrink-0 text-ink-3", classNames?.icon)
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
name ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value: value ?? "", disabled }) : null,
|
|
192
|
+
/* @__PURE__ */ jsx(PopoverPrimitive.Portal, { container, children: /* @__PURE__ */ jsx(
|
|
193
|
+
PopoverPrimitive.Content,
|
|
194
|
+
{
|
|
195
|
+
id: listId,
|
|
196
|
+
role: "listbox",
|
|
197
|
+
"data-ui-layer": "",
|
|
198
|
+
"aria-label": ariaLabelledBy ? void 0 : ariaLabel ?? listLabel ?? placeholder,
|
|
199
|
+
"aria-labelledby": ariaLabelledBy,
|
|
200
|
+
sideOffset: 4,
|
|
201
|
+
collisionPadding: 8,
|
|
202
|
+
align: "start",
|
|
203
|
+
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
204
|
+
onCloseAutoFocus: (event) => event.preventDefault(),
|
|
205
|
+
className: cn(
|
|
206
|
+
LISTBOX_SURFACE,
|
|
207
|
+
materialClass(material, "surface-solid"),
|
|
208
|
+
classNames?.content
|
|
209
|
+
),
|
|
210
|
+
children: /* @__PURE__ */ jsx(
|
|
211
|
+
ListboxItems,
|
|
212
|
+
{
|
|
213
|
+
items: options,
|
|
214
|
+
flat,
|
|
215
|
+
idBase: listId,
|
|
216
|
+
isSelected: (option) => option.value === value,
|
|
217
|
+
activeIndex: active,
|
|
218
|
+
onActivate: setActive,
|
|
219
|
+
onPick: (option) => pick(flat.indexOf(option)),
|
|
220
|
+
optionClassName: classNames?.option,
|
|
221
|
+
groupClassName: classNames?.group
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
) })
|
|
226
|
+
] });
|
|
227
|
+
}
|
|
228
|
+
export {
|
|
229
|
+
SelectMenu
|
|
230
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type DisplacementField } from "./displacement-map.js";
|
|
2
|
+
/**
|
|
3
|
+
* The crystal lens: a thick, clear, convex lens that minifies the backdrop. Every output pixel at
|
|
4
|
+
* `p` (measured from the centre of the surface) shows the backdrop at `p + (g(t) - 1) p` with `g(t)
|
|
5
|
+
* = 1 + (gMax - 1) s(t)`, `s(t) = 0.3 + 0.3 t^2 + 0.4 t^6` and `t` the superellipse radial coordinate (1 at
|
|
6
|
+
* the silhouette). The pull is mild in the middle and grows steeply towards the rim, like the
|
|
7
|
+
* side of a ball lens. A radial map `p -> p g(|p|)` with `g >= 1` and `g' >= 0` has the Jacobian
|
|
8
|
+
* determinant `g (g + t g')`, which is at least 1, so it cannot fold back on itself however large
|
|
9
|
+
* `gMax` is: this is what lets the crystal minify by a factor of three at the rim where the other
|
|
10
|
+
* profiles must stay under a slope of one.
|
|
11
|
+
*
|
|
12
|
+
* The samples lie outside the surface (a minifying lens sees a wider area than it covers), so the
|
|
13
|
+
* map is rasterised over the surface plus a margin on every side; the engine lays the filter on a
|
|
14
|
+
* layer that large and clips it back to the silhouette.
|
|
15
|
+
*/
|
|
16
|
+
export declare const CRYSTAL_EXPONENT = 2.5;
|
|
17
|
+
/** Weights of the constant (even minification), quadratic (whole-surface) and sixth-power (rim) parts of the crystal lens. */
|
|
18
|
+
export declare const CRYSTAL_WEIGHTS: {
|
|
19
|
+
readonly flat: 0.3;
|
|
20
|
+
readonly whole: 0.3;
|
|
21
|
+
readonly rim: 0.4;
|
|
22
|
+
};
|
|
23
|
+
/** `gMax - 1` per unit of `refraction`: how much more the rim minifies than the middle. */
|
|
24
|
+
export declare const CRYSTAL_GAIN = 1.3;
|
|
25
|
+
/** Largest source offset of the crystal lens, in px (bounds the margin and the filter area). */
|
|
26
|
+
export declare const CRYSTAL_MAX_OFFSET = 260;
|
|
27
|
+
/** `s(t)` of the crystal lens. */
|
|
28
|
+
export declare const crystalShape: (t: number) => number;
|
|
29
|
+
/** Radial coordinate of a point of a surface: 1 on the superellipse touching the middle of each side, held there beyond it. */
|
|
30
|
+
export declare function crystalRadius(px: number, py: number, hx: number, hy: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* Largest source offset of the crystal lens, in px, for a surface and a `refraction` of 0 to 2
|
|
33
|
+
* (1.67 is a thick lens, 2 the thickest the margin allows).
|
|
34
|
+
*/
|
|
35
|
+
export declare function crystalAmplitude(width: number, height: number, refraction: number): number;
|
|
36
|
+
export interface CrystalMapOptions {
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
/** Source offset at the silhouette, in px, from {@link crystalAmplitude}; sets the margin. */
|
|
40
|
+
amplitude: number;
|
|
41
|
+
/**
|
|
42
|
+
* Map pixels per CSS pixel. Default 1, between 0.5 and 2: the field is smooth and most of it lies
|
|
43
|
+
* in the margin the layer clips away, so a large lens can go below one.
|
|
44
|
+
*/
|
|
45
|
+
dpr?: number;
|
|
46
|
+
/** Margin past the surface, in px. Default {@link crystalMargin} of `amplitude`. */
|
|
47
|
+
margin?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Margin past each side of the surface, in px (default: `margin` on all four). A surface inside
|
|
50
|
+
* a clipping ancestor (an `overflow` or `clip-path` stage) only has the backdrop within it: a
|
|
51
|
+
* layer that reaches past the clip is cut by the browser and its filter is shifted, so the map
|
|
52
|
+
* covers only the backdrop that exists, and the offsets are clamped so no sample lands beyond it.
|
|
53
|
+
*/
|
|
54
|
+
room?: Partial<Record<"left" | "right" | "top" | "bottom", number>>;
|
|
55
|
+
/** Largest factor the offset is multiplied by (chromatic dispersion pulls red this much further). Default 1. */
|
|
56
|
+
reach?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Margin, in px, the crystal layer extends past the surface on every side: the largest offset,
|
|
60
|
+
* plus what chromatic dispersion adds to it.
|
|
61
|
+
*/
|
|
62
|
+
export declare const crystalMargin: (amplitude: number, dispersion?: number) => number;
|
|
63
|
+
/**
|
|
64
|
+
* Displacement field of the crystal lens over the surface and its margin: red and green carry
|
|
65
|
+
* `s(t) p / half` (so `scale = 2 amplitude 255/254` restores the offset), blue is 255 (no soft
|
|
66
|
+
* band: a crystal is not frosted). The size of `data` is the surface plus twice the margin.
|
|
67
|
+
*/
|
|
68
|
+
export declare function computeCrystalField({ width, height, amplitude, dpr, margin, room, reach, }: CrystalMapOptions): DisplacementField;
|
|
69
|
+
/** Crystal map as a PNG `data:` URI for `feImage` (browser only, cached). */
|
|
70
|
+
export declare function createCrystalMap(options: CrystalMapOptions): string;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { cachedMap, clamp } from "./displacement-map.js";
|
|
2
|
+
const CRYSTAL_EXPONENT = 2.5;
|
|
3
|
+
const CRYSTAL_WEIGHTS = { flat: 0.3, whole: 0.3, rim: 0.4 };
|
|
4
|
+
const CRYSTAL_GAIN = 1.3;
|
|
5
|
+
const CRYSTAL_MAX_OFFSET = 260;
|
|
6
|
+
const crystalShape = (t) => CRYSTAL_WEIGHTS.flat + CRYSTAL_WEIGHTS.whole * t ** 2 + CRYSTAL_WEIGHTS.rim * t ** 6;
|
|
7
|
+
function crystalRadius(px, py, hx, hy) {
|
|
8
|
+
const u = Math.abs(px) / hx;
|
|
9
|
+
const v = Math.abs(py) / hy;
|
|
10
|
+
return Math.min((u ** CRYSTAL_EXPONENT + v ** CRYSTAL_EXPONENT) ** (1 / CRYSTAL_EXPONENT), 1);
|
|
11
|
+
}
|
|
12
|
+
function crystalAmplitude(width, height, refraction) {
|
|
13
|
+
const half = Math.max(width, height) / 2;
|
|
14
|
+
return Math.min(clamp(refraction, 0, 2) * CRYSTAL_GAIN * half, CRYSTAL_MAX_OFFSET);
|
|
15
|
+
}
|
|
16
|
+
const EDGE_SLACK = 3;
|
|
17
|
+
const crystalMargin = (amplitude, dispersion = 0) => Math.ceil(amplitude * (1 + Math.max(dispersion, 0))) + 2;
|
|
18
|
+
function computeCrystalField({
|
|
19
|
+
width,
|
|
20
|
+
height,
|
|
21
|
+
amplitude,
|
|
22
|
+
dpr = 1,
|
|
23
|
+
margin,
|
|
24
|
+
room,
|
|
25
|
+
reach = 1
|
|
26
|
+
}) {
|
|
27
|
+
const ratio = clamp(dpr, 0.5, 2);
|
|
28
|
+
const w = Math.max(1, width);
|
|
29
|
+
const h = Math.max(1, height);
|
|
30
|
+
const m = margin ?? crystalMargin(amplitude);
|
|
31
|
+
const free = (side) => Math.max(room?.[side] ?? m, 0);
|
|
32
|
+
const [left, right, top, bottom] = [free("left"), free("right"), free("top"), free("bottom")];
|
|
33
|
+
const pw = Math.max(1, Math.round((w + left + right) * ratio));
|
|
34
|
+
const ph = Math.max(1, Math.round((h + top + bottom) * ratio));
|
|
35
|
+
const rx = pw / (w + left + right);
|
|
36
|
+
const ry = ph / (h + top + bottom);
|
|
37
|
+
const data = new Uint8ClampedArray(pw * ph * 4);
|
|
38
|
+
const hx = w / 2;
|
|
39
|
+
const hy = h / 2;
|
|
40
|
+
const half = Math.max(hx, hy);
|
|
41
|
+
const slack = room ? EDGE_SLACK : 0;
|
|
42
|
+
const bounded = room !== void 0;
|
|
43
|
+
const [minX, maxX] = [-hx - left + slack, hx + right - slack];
|
|
44
|
+
const [minY, maxY] = [-hy - top + slack, hy + bottom - slack];
|
|
45
|
+
const unit = Math.max(amplitude, 1e-6);
|
|
46
|
+
const f = Math.max(reach, 1);
|
|
47
|
+
const within = (p, offset, lo, hi) => clamp((bounded ? clamp(offset, (lo - p) / f, (hi - p) / f) : offset) / unit, -1, 1);
|
|
48
|
+
for (let j = 0; j < ph; j++) {
|
|
49
|
+
const py = (j + 0.5) / ry - top - hy;
|
|
50
|
+
for (let i = 0; i < pw; i++) {
|
|
51
|
+
const px = (i + 0.5) / rx - left - hx;
|
|
52
|
+
const s = crystalShape(crystalRadius(px, py, hx, hy));
|
|
53
|
+
const o = (j * pw + i) * 4;
|
|
54
|
+
data[o] = 128 + within(px, s * px * amplitude / half, minX, maxX) * 127;
|
|
55
|
+
data[o + 1] = 128 + within(py, s * py * amplitude / half, minY, maxY) * 127;
|
|
56
|
+
data[o + 2] = 255;
|
|
57
|
+
data[o + 3] = 255;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { width: pw, height: ph, data };
|
|
61
|
+
}
|
|
62
|
+
function createCrystalMap(options) {
|
|
63
|
+
const key = [
|
|
64
|
+
options.width,
|
|
65
|
+
options.height,
|
|
66
|
+
Math.round(options.amplitude),
|
|
67
|
+
options.dpr ?? 1,
|
|
68
|
+
options.margin ?? 0,
|
|
69
|
+
options.reach ?? 1,
|
|
70
|
+
options.room?.left ?? -1,
|
|
71
|
+
options.room?.right ?? -1,
|
|
72
|
+
options.room?.top ?? -1,
|
|
73
|
+
options.room?.bottom ?? -1
|
|
74
|
+
].map((n) => Math.round(n * 100) / 100).join("x");
|
|
75
|
+
return cachedMap(`c${key}`, () => computeCrystalField(options));
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
CRYSTAL_EXPONENT,
|
|
79
|
+
CRYSTAL_GAIN,
|
|
80
|
+
CRYSTAL_MAX_OFFSET,
|
|
81
|
+
CRYSTAL_WEIGHTS,
|
|
82
|
+
computeCrystalField,
|
|
83
|
+
createCrystalMap,
|
|
84
|
+
crystalAmplitude,
|
|
85
|
+
crystalMargin,
|
|
86
|
+
crystalRadius,
|
|
87
|
+
crystalShape
|
|
88
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export interface DisplacementMapOptions {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
/** Corner radius of the glass shape, in px. */
|
|
5
|
+
radius: number;
|
|
6
|
+
/** Width of the refracting bevel, in px, for `coverage: "rim"`; the centre stays undistorted. */
|
|
7
|
+
bezel: number;
|
|
8
|
+
/**
|
|
9
|
+
* `"full"` (default) bends the backdrop over the whole surface, strongest at the rim and
|
|
10
|
+
* gentle but never zero towards the centre (a squarish pillow); `"dome"` does the same with
|
|
11
|
+
* round contours, a drop that is flatter in the middle; `"rim"` only across the bevel.
|
|
12
|
+
*/
|
|
13
|
+
coverage?: LensCoverage;
|
|
14
|
+
/** Width of the rim, in px, over which the veil and the blur ease off (blue channel). Default: `bezel`. */
|
|
15
|
+
soft?: number;
|
|
16
|
+
/** Largest offset of the whole-surface profiles, in px. Default {@link FULL_CAP}. */
|
|
17
|
+
cap?: number;
|
|
18
|
+
/** Device pixel ratio the map is rasterised at. Default 1, capped at 2. */
|
|
19
|
+
dpr?: number;
|
|
20
|
+
}
|
|
21
|
+
export type LensCoverage = "full" | "rim" | "dome" | "crystal";
|
|
22
|
+
/** The shape of the lens; `coverage` is the older name of the same option. */
|
|
23
|
+
export type LensProfile = LensCoverage;
|
|
24
|
+
/** Whether a profile bends the whole surface (everything but the rim band). */
|
|
25
|
+
export declare const isWhole: (coverage: LensCoverage) => coverage is "full" | "dome";
|
|
26
|
+
export interface DisplacementField {
|
|
27
|
+
/** Width and height of `data` in pixels (CSS size times the capped ratio). */
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
/**
|
|
31
|
+
* RGBA, row major. Red and green carry the horizontal and vertical source offset (128 is zero);
|
|
32
|
+
* blue carries how soft the backdrop is there: 255 in the middle, easing down to 0 at the edge,
|
|
33
|
+
* so the lens shows the backdrop sharp and lively along the rim and frosted under the text.
|
|
34
|
+
*/
|
|
35
|
+
data: Uint8ClampedArray;
|
|
36
|
+
}
|
|
37
|
+
export declare const clamp: (value: number, min: number, max: number, ceil?: number) => number;
|
|
38
|
+
/** How much of the legibility veil is left at the very edge of the rim. */
|
|
39
|
+
export declare const VEIL_FLOOR = 0.5;
|
|
40
|
+
/**
|
|
41
|
+
* Bevel width of a surface, in px. `"rim"`: a little more than its corner radius, so the bend
|
|
42
|
+
* reads as a drop. `"full"`: half the short side, the whole surface.
|
|
43
|
+
*/
|
|
44
|
+
export declare function bezelFor(radius: number, width: number, height: number, coverage?: LensCoverage): number;
|
|
45
|
+
/**
|
|
46
|
+
* Largest source offset of the lens, as a fraction of the bevel width (`"rim"`). The profile falls
|
|
47
|
+
* at most 1.5 times its amplitude per bevel width, so 0.58 keeps the mapping `depth +
|
|
48
|
+
* offset(depth)` strictly increasing (slope 0.87 < 1). Above 1 it folds back on itself: several
|
|
49
|
+
* output pixels then sample the same source pixels in reverse order, and straight stripes break
|
|
50
|
+
* into a repeating sawtooth along the walls. That fold, not the map resolution, was the serrated
|
|
51
|
+
* edge of the first lenses.
|
|
52
|
+
*/
|
|
53
|
+
export declare const MAX_OFFSET = 0.58;
|
|
54
|
+
/**
|
|
55
|
+
* Full coverage is a dome over a superellipse radial coordinate: with `u = x / hx`, `v = y / hy`
|
|
56
|
+
* and `r = (|u|^N + |v|^N)^(1/N)`, a pixel is pulled towards the centre along the gradient of `r` in
|
|
57
|
+
* the normalised (u, v) plane (perpendicular to the contours of the superellipse) by `A (r / r_corner)^1.5`. The gradient is
|
|
58
|
+
* continuous everywhere except the exact centre, where the pull is zero, so there is no crease:
|
|
59
|
+
* a field built from the distance to the nearest edge, or from each axis on its own, has its
|
|
60
|
+
* pull flip direction along the diagonals of the shape and the glass reads as a four-faced
|
|
61
|
+
* pyramid. `N = 3` keeps the contours between an ellipse (a round drop) and a rounded rectangle
|
|
62
|
+
* (a slab). The slope of the pull is at most 2A / (r_corner^2 h) along an axis, so A is at most
|
|
63
|
+
* 0.55 of the smaller half size (fold-free), and at most {@link FULL_CAP} px so a large surface
|
|
64
|
+
* does not smear.
|
|
65
|
+
*/
|
|
66
|
+
export declare const FULL_FRACTION = 0.55;
|
|
67
|
+
/** Exponent of the superellipse radial coordinate of the full lens. */
|
|
68
|
+
export declare const FULL_EXPONENT = 3;
|
|
69
|
+
/** Largest offset of the full lens, in px. */
|
|
70
|
+
export declare const FULL_CAP = 24;
|
|
71
|
+
/**
|
|
72
|
+
* Shape of the two whole-surface profiles: the exponent `N` of the radial coordinate
|
|
73
|
+
* `(|u|^N + |v|^N)^(1/N)` (3: squarish, 2: round) and the power `p` of the pull `A t^p`, with
|
|
74
|
+
* `t` the radial coordinate over its value at the corners.
|
|
75
|
+
*/
|
|
76
|
+
export declare const WHOLE_SHAPES: {
|
|
77
|
+
readonly full: {
|
|
78
|
+
readonly exponent: 3;
|
|
79
|
+
readonly power: 1.5;
|
|
80
|
+
};
|
|
81
|
+
readonly dome: {
|
|
82
|
+
readonly exponent: 2;
|
|
83
|
+
readonly power: 2;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/** Offset amplitude of the lens along each axis, in px. */
|
|
87
|
+
export declare function lensAmplitude(width: number, height: number, bezel: number, coverage?: LensCoverage, cap?: number): {
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
};
|
|
91
|
+
/** `scale` of the displacement filter: the offset is half of it (128 is neutral). */
|
|
92
|
+
export declare function scaleFor(width: number, height: number, bezel: number, coverage?: LensCoverage, cap?: number): number;
|
|
93
|
+
/**
|
|
94
|
+
* `"full"`: the table of the dome, `(x / half size)^2` from the centre (0) to the edge (1).
|
|
95
|
+
*
|
|
96
|
+
* `"rim"`: lateral displacement across the bevel, 1 at the outer edge and 0 at the inner one: `1 -
|
|
97
|
+
* smoothstep(x)`, with x running from the outer edge inwards. It starts flat (the outermost
|
|
98
|
+
* pixels show one clean shifted copy of the backdrop, like the rim of a drop), bends most at the
|
|
99
|
+
* middle of the bevel and eases to zero, so the lens meets the clear centre without a seam. Its
|
|
100
|
+
* slope never exceeds 1.5, which is what keeps {@link MAX_OFFSET} fold-free.
|
|
101
|
+
*/
|
|
102
|
+
export declare function lensProfile(coverage?: LensCoverage): Float32Array;
|
|
103
|
+
/**
|
|
104
|
+
* Displacement field of a rounded rectangle, from its signed distance function: zero in the
|
|
105
|
+
* middle, and across the rim a source offset pointing into the shape whose length follows
|
|
106
|
+
* {@link lensProfile} and whose direction is the inward surface normal (straight edges pull
|
|
107
|
+
* along the axis, corners along the radius). Pure, so it runs anywhere.
|
|
108
|
+
*/
|
|
109
|
+
export declare function computeDisplacementField({ width, height, radius, bezel, coverage, soft, cap, dpr, }: DisplacementMapOptions): DisplacementField;
|
|
110
|
+
/**
|
|
111
|
+
* Displacement map for `feDisplacementMap`, as a PNG `data:` URI for `feImage`. Browser only
|
|
112
|
+
* (it rasterises on a canvas); results are kept in a small cache, so reopening a dialog of the
|
|
113
|
+
* same size costs nothing.
|
|
114
|
+
*/
|
|
115
|
+
export declare function createDisplacementMap(options: DisplacementMapOptions): string;
|
|
116
|
+
/** Rasterises a field to a PNG `data:` URI, kept in a small cache shared by every map. */
|
|
117
|
+
export declare function cachedMap(key: string, compute: () => DisplacementField): string;
|