@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,317 @@
|
|
|
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
|
+
|
|
22
|
+
export type LensCoverage = "full" | "rim" | "dome" | "crystal";
|
|
23
|
+
/** The shape of the lens; `coverage` is the older name of the same option. */
|
|
24
|
+
export type LensProfile = LensCoverage;
|
|
25
|
+
|
|
26
|
+
/** Whether a profile bends the whole surface (everything but the rim band). */
|
|
27
|
+
export const isWhole = (coverage: LensCoverage) => coverage !== "rim" && coverage !== "crystal";
|
|
28
|
+
|
|
29
|
+
export interface DisplacementField {
|
|
30
|
+
/** Width and height of `data` in pixels (CSS size times the capped ratio). */
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
/**
|
|
34
|
+
* RGBA, row major. Red and green carry the horizontal and vertical source offset (128 is zero);
|
|
35
|
+
* blue carries how soft the backdrop is there: 255 in the middle, easing down to 0 at the edge,
|
|
36
|
+
* so the lens shows the backdrop sharp and lively along the rim and frosted under the text.
|
|
37
|
+
*/
|
|
38
|
+
data: Uint8ClampedArray;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const clamp = (value: number, min: number, max: number, ceil = Number.POSITIVE_INFINITY) =>
|
|
42
|
+
Math.min(Math.max(value, min), max, ceil);
|
|
43
|
+
|
|
44
|
+
/** How much of the legibility veil is left at the very edge of the rim. */
|
|
45
|
+
export const VEIL_FLOOR = 0.5;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Bevel width of a surface, in px. `"rim"`: a little more than its corner radius, so the bend
|
|
49
|
+
* reads as a drop. `"full"`: half the short side, the whole surface.
|
|
50
|
+
*/
|
|
51
|
+
export function bezelFor(
|
|
52
|
+
radius: number,
|
|
53
|
+
width: number,
|
|
54
|
+
height: number,
|
|
55
|
+
coverage: LensCoverage = "full",
|
|
56
|
+
): number {
|
|
57
|
+
const short = Math.min(width, height);
|
|
58
|
+
if (coverage === "full" || coverage === "dome") return Math.max(1, short / 2);
|
|
59
|
+
return clamp(radius * 1.2, 14, Math.max(8, short * 0.45), 56);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Largest source offset of the lens, as a fraction of the bevel width (`"rim"`). The profile falls
|
|
64
|
+
* at most 1.5 times its amplitude per bevel width, so 0.58 keeps the mapping `depth +
|
|
65
|
+
* offset(depth)` strictly increasing (slope 0.87 < 1). Above 1 it folds back on itself: several
|
|
66
|
+
* output pixels then sample the same source pixels in reverse order, and straight stripes break
|
|
67
|
+
* into a repeating sawtooth along the walls. That fold, not the map resolution, was the serrated
|
|
68
|
+
* edge of the first lenses.
|
|
69
|
+
*/
|
|
70
|
+
export const MAX_OFFSET = 0.58;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Full coverage is a dome over a superellipse radial coordinate: with `u = x / hx`, `v = y / hy`
|
|
74
|
+
* and `r = (|u|^N + |v|^N)^(1/N)`, a pixel is pulled towards the centre along the gradient of `r` in
|
|
75
|
+
* the normalised (u, v) plane (perpendicular to the contours of the superellipse) by `A (r / r_corner)^1.5`. The gradient is
|
|
76
|
+
* continuous everywhere except the exact centre, where the pull is zero, so there is no crease:
|
|
77
|
+
* a field built from the distance to the nearest edge, or from each axis on its own, has its
|
|
78
|
+
* pull flip direction along the diagonals of the shape and the glass reads as a four-faced
|
|
79
|
+
* pyramid. `N = 3` keeps the contours between an ellipse (a round drop) and a rounded rectangle
|
|
80
|
+
* (a slab). The slope of the pull is at most 2A / (r_corner^2 h) along an axis, so A is at most
|
|
81
|
+
* 0.55 of the smaller half size (fold-free), and at most {@link FULL_CAP} px so a large surface
|
|
82
|
+
* does not smear.
|
|
83
|
+
*/
|
|
84
|
+
export const FULL_FRACTION = 0.55;
|
|
85
|
+
/** Exponent of the superellipse radial coordinate of the full lens. */
|
|
86
|
+
export const FULL_EXPONENT = 3;
|
|
87
|
+
/** Largest offset of the full lens, in px. */
|
|
88
|
+
export const FULL_CAP = 24;
|
|
89
|
+
/**
|
|
90
|
+
* Shape of the two whole-surface profiles: the exponent `N` of the radial coordinate
|
|
91
|
+
* `(|u|^N + |v|^N)^(1/N)` (3: squarish, 2: round) and the power `p` of the pull `A t^p`, with
|
|
92
|
+
* `t` the radial coordinate over its value at the corners.
|
|
93
|
+
*/
|
|
94
|
+
export const WHOLE_SHAPES = {
|
|
95
|
+
full: { exponent: FULL_EXPONENT, power: 1.5 },
|
|
96
|
+
dome: { exponent: 2, power: 2 },
|
|
97
|
+
} as const;
|
|
98
|
+
|
|
99
|
+
/** Offset amplitude of the lens along each axis, in px. */
|
|
100
|
+
export function lensAmplitude(
|
|
101
|
+
width: number,
|
|
102
|
+
height: number,
|
|
103
|
+
bezel: number,
|
|
104
|
+
coverage: LensCoverage = "full",
|
|
105
|
+
cap: number = FULL_CAP,
|
|
106
|
+
): { x: number; y: number } {
|
|
107
|
+
if (coverage === "rim" || coverage === "crystal") {
|
|
108
|
+
const a = MAX_OFFSET * bezel;
|
|
109
|
+
return { x: a, y: a };
|
|
110
|
+
}
|
|
111
|
+
const a = Math.min((Math.min(width, height) / 2) * FULL_FRACTION, Math.max(cap, 1));
|
|
112
|
+
return { x: a, y: a };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** `scale` of the displacement filter: the offset is half of it (128 is neutral). */
|
|
116
|
+
export function scaleFor(
|
|
117
|
+
width: number,
|
|
118
|
+
height: number,
|
|
119
|
+
bezel: number,
|
|
120
|
+
coverage: LensCoverage = "full",
|
|
121
|
+
cap: number = FULL_CAP,
|
|
122
|
+
): number {
|
|
123
|
+
const { x, y } = lensAmplitude(width, height, bezel, coverage, cap);
|
|
124
|
+
return (2 * Math.max(x, y, 1) * 255) / 254;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const PROFILE_SAMPLES = 64;
|
|
128
|
+
|
|
129
|
+
let profile: Float32Array | undefined;
|
|
130
|
+
let quadratic: Float32Array | undefined;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* `"full"`: the table of the dome, `(x / half size)^2` from the centre (0) to the edge (1).
|
|
134
|
+
*
|
|
135
|
+
* `"rim"`: lateral displacement across the bevel, 1 at the outer edge and 0 at the inner one: `1 -
|
|
136
|
+
* smoothstep(x)`, with x running from the outer edge inwards. It starts flat (the outermost
|
|
137
|
+
* pixels show one clean shifted copy of the backdrop, like the rim of a drop), bends most at the
|
|
138
|
+
* middle of the bevel and eases to zero, so the lens meets the clear centre without a seam. Its
|
|
139
|
+
* slope never exceeds 1.5, which is what keeps {@link MAX_OFFSET} fold-free.
|
|
140
|
+
*/
|
|
141
|
+
export function lensProfile(coverage: LensCoverage = "rim"): Float32Array {
|
|
142
|
+
if (coverage !== "rim") {
|
|
143
|
+
if (quadratic) return quadratic;
|
|
144
|
+
quadratic = new Float32Array(PROFILE_SAMPLES).map((_, i) => (i / (PROFILE_SAMPLES - 1)) ** 2);
|
|
145
|
+
return quadratic;
|
|
146
|
+
}
|
|
147
|
+
if (profile) return profile;
|
|
148
|
+
const out = new Float32Array(PROFILE_SAMPLES);
|
|
149
|
+
for (let i = 0; i < PROFILE_SAMPLES; i++) {
|
|
150
|
+
const x = i / (PROFILE_SAMPLES - 1);
|
|
151
|
+
out[i] = 1 - x * x * (3 - 2 * x);
|
|
152
|
+
}
|
|
153
|
+
profile = out;
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Displacement field of a rounded rectangle, from its signed distance function: zero in the
|
|
159
|
+
* middle, and across the rim a source offset pointing into the shape whose length follows
|
|
160
|
+
* {@link lensProfile} and whose direction is the inward surface normal (straight edges pull
|
|
161
|
+
* along the axis, corners along the radius). Pure, so it runs anywhere.
|
|
162
|
+
*/
|
|
163
|
+
export function computeDisplacementField({
|
|
164
|
+
width,
|
|
165
|
+
height,
|
|
166
|
+
radius,
|
|
167
|
+
bezel,
|
|
168
|
+
coverage = "rim",
|
|
169
|
+
soft,
|
|
170
|
+
cap,
|
|
171
|
+
dpr = 1,
|
|
172
|
+
}: DisplacementMapOptions): DisplacementField {
|
|
173
|
+
const ratio = clamp(dpr, 1, 2);
|
|
174
|
+
const w = Math.max(1, width);
|
|
175
|
+
const h = Math.max(1, height);
|
|
176
|
+
const full = isWhole(coverage);
|
|
177
|
+
const shape = WHOLE_SHAPES[coverage === "dome" ? "dome" : "full"];
|
|
178
|
+
const corner = 2 ** (1 / shape.exponent);
|
|
179
|
+
const rim = clamp(full ? (soft ?? bezelFor(radius, w, h, "rim")) : bezel, 1, Math.min(w, h) / 2);
|
|
180
|
+
const r = clamp(radius, 0, Math.min(w, h) / 2);
|
|
181
|
+
const pw = Math.max(1, Math.round(w * ratio));
|
|
182
|
+
const ph = Math.max(1, Math.round(h * ratio));
|
|
183
|
+
// Rounding makes the real pixels-per-px a hair off `ratio`: positions use the effective ones.
|
|
184
|
+
const rx = pw / w;
|
|
185
|
+
const ry = ph / h;
|
|
186
|
+
const data = new Uint8ClampedArray(pw * ph * 4);
|
|
187
|
+
// Neutral everywhere (128, 128, 255, 255), then only the rim is computed: rows between the
|
|
188
|
+
// rims are visited at their two ends. Little-endian packing of R, G, B, A.
|
|
189
|
+
new Uint32Array(data.buffer).fill(0xffff8080);
|
|
190
|
+
const band = Math.min(pw, Math.ceil(rim * ratio) + 1);
|
|
191
|
+
const table = lensProfile("rim");
|
|
192
|
+
const last = table.length - 1;
|
|
193
|
+
const hx = w / 2;
|
|
194
|
+
const hy = h / 2;
|
|
195
|
+
const amp = lensAmplitude(w, h, bezel, coverage, cap);
|
|
196
|
+
const norm = Math.max(amp.x, amp.y, 1);
|
|
197
|
+
// The whole-surface terms of a column are the same on every row: computed once per column.
|
|
198
|
+
const columnPull = new Float64Array(full ? pw : 0);
|
|
199
|
+
const columnShape = new Float64Array(full ? pw : 0);
|
|
200
|
+
for (let i = 0; full && i < pw; i++) {
|
|
201
|
+
const px = (i + 0.5) / rx - hx;
|
|
202
|
+
const au = Math.abs(px) / hx;
|
|
203
|
+
columnPull[i] = Math.sign(px) * au ** (shape.exponent - 1);
|
|
204
|
+
columnShape[i] = au ** shape.exponent;
|
|
205
|
+
}
|
|
206
|
+
for (let j = 0; j < ph; j++) {
|
|
207
|
+
const py = (j + 0.5) / ry - hy;
|
|
208
|
+
const inner = Math.abs(py) < hy - rim;
|
|
209
|
+
const av = Math.abs(py) / hy;
|
|
210
|
+
const gv = full ? Math.sign(py) * av ** (shape.exponent - 1) : 0;
|
|
211
|
+
const vn = av ** shape.exponent;
|
|
212
|
+
for (let i = 0; i < pw; i++) {
|
|
213
|
+
if (!full && inner && i === band) i = Math.max(band, pw - band);
|
|
214
|
+
const px = (i + 0.5) / rx - hx;
|
|
215
|
+
const o = (j * pw + i) * 4;
|
|
216
|
+
if (full) {
|
|
217
|
+
const gx = columnPull[i] as number;
|
|
218
|
+
const g = Math.hypot(gx, gv);
|
|
219
|
+
const t = Math.min(((columnShape[i] as number) + vn) ** (1 / shape.exponent) / corner, 1);
|
|
220
|
+
const pull = g > 0 ? t ** shape.power / g : 0;
|
|
221
|
+
data[o] = 128 - gx * pull * 127 * (amp.x / norm);
|
|
222
|
+
data[o + 1] = 128 - gv * pull * 127 * (amp.y / norm);
|
|
223
|
+
data[o + 3] = 255;
|
|
224
|
+
if (inner && Math.abs(px) < hx - rim) {
|
|
225
|
+
data[o + 2] = 255;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const qx = Math.abs(px) - (hx - r);
|
|
230
|
+
const qy = Math.abs(py) - (hy - r);
|
|
231
|
+
const out = Math.hypot(Math.max(qx, 0), Math.max(qy, 0));
|
|
232
|
+
const depth = r - (out + Math.min(Math.max(qx, qy), 0));
|
|
233
|
+
let dx = 0;
|
|
234
|
+
let dy = 0;
|
|
235
|
+
let veil = 1;
|
|
236
|
+
if (full) {
|
|
237
|
+
if (depth > 0 && depth < rim) {
|
|
238
|
+
const x = depth / rim;
|
|
239
|
+
veil = x * x * (3 - 2 * x);
|
|
240
|
+
}
|
|
241
|
+
data[o + 2] = veil * 255;
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (depth > 0 && depth < rim) {
|
|
245
|
+
const x = depth / rim;
|
|
246
|
+
veil = x * x * (3 - 2 * x);
|
|
247
|
+
const at = (depth / rim) * last;
|
|
248
|
+
const lo = Math.floor(at);
|
|
249
|
+
const m =
|
|
250
|
+
(table[lo] as number) * (1 - (at - lo)) +
|
|
251
|
+
(table[Math.min(lo + 1, last)] as number) * (at - lo);
|
|
252
|
+
const sx = px < 0 ? -1 : 1;
|
|
253
|
+
const sy = py < 0 ? -1 : 1;
|
|
254
|
+
let nx = 0;
|
|
255
|
+
let ny = 0;
|
|
256
|
+
if (qx > 0 && qy > 0) {
|
|
257
|
+
nx = (sx * qx) / out;
|
|
258
|
+
ny = (sy * qy) / out;
|
|
259
|
+
} else if (qx > qy) nx = sx;
|
|
260
|
+
else ny = sy;
|
|
261
|
+
dx = -nx * m;
|
|
262
|
+
dy = -ny * m;
|
|
263
|
+
}
|
|
264
|
+
data[o] = 128 + dx * 127 * (amp.x / norm);
|
|
265
|
+
data[o + 1] = 128 + dy * 127 * (amp.y / norm);
|
|
266
|
+
data[o + 2] = veil * 255;
|
|
267
|
+
data[o + 3] = 255;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return { width: pw, height: ph, data };
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const cache = new Map<string, string>();
|
|
274
|
+
const CACHE_SIZE = 16;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Displacement map for `feDisplacementMap`, as a PNG `data:` URI for `feImage`. Browser only
|
|
278
|
+
* (it rasterises on a canvas); results are kept in a small cache, so reopening a dialog of the
|
|
279
|
+
* same size costs nothing.
|
|
280
|
+
*/
|
|
281
|
+
export function createDisplacementMap(options: DisplacementMapOptions): string {
|
|
282
|
+
const key = [
|
|
283
|
+
options.width,
|
|
284
|
+
options.height,
|
|
285
|
+
options.radius,
|
|
286
|
+
options.bezel,
|
|
287
|
+
options.soft ?? 0,
|
|
288
|
+
// The offset is encoded relative to the largest one, so it only shows in the map below 1 px.
|
|
289
|
+
Math.min(
|
|
290
|
+
lensAmplitude(options.width, options.height, options.bezel, options.coverage, options.cap).x,
|
|
291
|
+
1,
|
|
292
|
+
),
|
|
293
|
+
options.dpr ?? 1,
|
|
294
|
+
]
|
|
295
|
+
.map((n) => Math.round(n * 100) / 100)
|
|
296
|
+
.join("x");
|
|
297
|
+
return cachedMap(`d${options.coverage ?? "rim"}${key}`, () => computeDisplacementField(options));
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** Rasterises a field to a PNG `data:` URI, kept in a small cache shared by every map. */
|
|
301
|
+
export function cachedMap(key: string, compute: () => DisplacementField): string {
|
|
302
|
+
const hit = cache.get(key);
|
|
303
|
+
if (hit) return hit;
|
|
304
|
+
const field = compute();
|
|
305
|
+
const canvas = document.createElement("canvas");
|
|
306
|
+
canvas.width = field.width;
|
|
307
|
+
canvas.height = field.height;
|
|
308
|
+
const context = canvas.getContext("2d");
|
|
309
|
+
if (!context) return "";
|
|
310
|
+
const image = context.createImageData(field.width, field.height);
|
|
311
|
+
image.data.set(field.data);
|
|
312
|
+
context.putImageData(image, 0, 0);
|
|
313
|
+
const uri = canvas.toDataURL("image/png");
|
|
314
|
+
cache.set(key, uri);
|
|
315
|
+
if (cache.size > CACHE_SIZE) cache.delete(cache.keys().next().value as string);
|
|
316
|
+
return uri;
|
|
317
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export {
|
|
2
|
+
CRYSTAL_GAIN,
|
|
3
|
+
CRYSTAL_MAX_OFFSET,
|
|
4
|
+
computeCrystalField,
|
|
5
|
+
crystalAmplitude,
|
|
6
|
+
crystalMargin,
|
|
7
|
+
crystalRadius,
|
|
8
|
+
crystalShape,
|
|
9
|
+
} from "./crystal-map.js";
|
|
10
|
+
export {
|
|
11
|
+
computeDisplacementField,
|
|
12
|
+
createDisplacementMap,
|
|
13
|
+
type DisplacementField,
|
|
14
|
+
type DisplacementMapOptions,
|
|
15
|
+
type LensCoverage,
|
|
16
|
+
lensProfile,
|
|
17
|
+
} from "./displacement-map.js";
|
|
18
|
+
export { LiquidGlass, startLiquidGlass } from "./liquid-glass.js";
|
|
19
|
+
export {
|
|
20
|
+
LIQUID_DEFAULTS,
|
|
21
|
+
LIQUID_MOTIONS,
|
|
22
|
+
LIQUID_PRESET_CLEAR,
|
|
23
|
+
LIQUID_PRESET_CRYSTAL,
|
|
24
|
+
LIQUID_PRESET_REGULAR,
|
|
25
|
+
LIQUID_PRESET_THICK,
|
|
26
|
+
LIQUID_PRESETS,
|
|
27
|
+
type LiquidGlassOptions,
|
|
28
|
+
type LiquidInteractive,
|
|
29
|
+
type LiquidMotion,
|
|
30
|
+
type LiquidPresetName,
|
|
31
|
+
type LiquidProfile,
|
|
32
|
+
liquidStyle,
|
|
33
|
+
liquidVars,
|
|
34
|
+
mergeLiquid,
|
|
35
|
+
} from "./liquid-options.js";
|
|
36
|
+
export { applyGlassRefraction, type GlassRefractionOptions } from "./refraction.js";
|
|
37
|
+
export {
|
|
38
|
+
computeSpecularField,
|
|
39
|
+
createSpecularMap,
|
|
40
|
+
type SpecularMapOptions,
|
|
41
|
+
} from "./specular-map.js";
|
|
42
|
+
export { supportsBackdropRefraction } from "./support.js";
|
|
43
|
+
export { useGlassRefraction } from "./use-glass-refraction.js";
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { createCrystalMap, crystalAmplitude, crystalMargin } from "./crystal-map.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The crystal map covers the surface and its margin (often several times the surface), and every
|
|
5
|
+
* pixel of it is computed on the main thread. The ratio is lowered to hold the map near this many
|
|
6
|
+
* pixels, but never below half a pixel per CSS pixel (which the smooth field and the bilinear
|
|
7
|
+
* `feImage` scaling do not show), so a layer larger than twice this at 0.5 still exceeds it.
|
|
8
|
+
*/
|
|
9
|
+
const CRYSTAL_MAP_PIXELS = 48_000;
|
|
10
|
+
|
|
11
|
+
/** Ancestors that cut the backdrop: whatever lies past their edge is not there for a backdrop filter. */
|
|
12
|
+
function clippingAncestors(element: Element): Element[] {
|
|
13
|
+
const found: Element[] = [];
|
|
14
|
+
for (let node = element.parentElement; node; node = node.parentElement) {
|
|
15
|
+
const style = getComputedStyle(node);
|
|
16
|
+
const clips =
|
|
17
|
+
style.clipPath !== "none" ||
|
|
18
|
+
[style.overflowX, style.overflowY].some((value) => value !== "visible") ||
|
|
19
|
+
/paint|strict|content/.test(style.contain);
|
|
20
|
+
if (clips) found.push(node);
|
|
21
|
+
}
|
|
22
|
+
return found;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* How much backdrop lies past each side of `element`, in px, up to `margin` and rounded down to
|
|
27
|
+
* `step` (so a surface dragged along an edge does not rebuild its map on every pixel).
|
|
28
|
+
*/
|
|
29
|
+
function backdropRoom(element: Element, clips: Element[], margin: number, step = 12) {
|
|
30
|
+
const box = element.getBoundingClientRect();
|
|
31
|
+
const room = { left: margin, right: margin, top: margin, bottom: margin };
|
|
32
|
+
for (const clip of clips) {
|
|
33
|
+
const edge = clip.getBoundingClientRect();
|
|
34
|
+
room.left = Math.min(room.left, box.left - edge.left);
|
|
35
|
+
room.right = Math.min(room.right, edge.right - box.right);
|
|
36
|
+
room.top = Math.min(room.top, box.top - edge.top);
|
|
37
|
+
room.bottom = Math.min(room.bottom, edge.bottom - box.bottom);
|
|
38
|
+
}
|
|
39
|
+
for (const side of ["left", "right", "top", "bottom"] as const)
|
|
40
|
+
room[side] = Math.min(margin, Math.max(0, Math.floor(room[side] / step) * step));
|
|
41
|
+
return room;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** What the engine hands the crystal lens of one installed filter. */
|
|
45
|
+
export interface CrystalContext {
|
|
46
|
+
element: HTMLElement;
|
|
47
|
+
/** Id of the SVG filter, and the CSS that comes before it in `backdrop-filter`. */
|
|
48
|
+
id: string;
|
|
49
|
+
blur: string;
|
|
50
|
+
/** The surface's own inline `backdrop-filter` before the engine touched it. */
|
|
51
|
+
original: string;
|
|
52
|
+
filter: SVGFilterElement;
|
|
53
|
+
image: Element;
|
|
54
|
+
/** The layer or the skin was removed from the surface: install again. */
|
|
55
|
+
reinstall: () => void;
|
|
56
|
+
/** The backdrop room around the surface changed: rebuild the map. */
|
|
57
|
+
resize: () => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface CrystalLens {
|
|
61
|
+
/** Lays the map out for a size; returns the filter scale, or `undefined` when nothing changed. */
|
|
62
|
+
update(
|
|
63
|
+
width: number,
|
|
64
|
+
height: number,
|
|
65
|
+
radius: number,
|
|
66
|
+
refraction: number,
|
|
67
|
+
dispersion: number,
|
|
68
|
+
dpr: number,
|
|
69
|
+
): number | undefined;
|
|
70
|
+
/** Removes the layer and the skin and gives the surface its own styles back. */
|
|
71
|
+
undo(): void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The crystal lens samples the backdrop outside the surface (it minifies), which a filter on the
|
|
76
|
+
* surface itself cannot see. So the filter goes on a layer that extends past the surface by the
|
|
77
|
+
* largest offset, clipped back to the silhouette; the surface's own backdrop filter, background and
|
|
78
|
+
* inset shadows move to (or under) that layer's siblings, because the layer must be the lowest
|
|
79
|
+
* thing in the surface. Its own lazy chunk: the engine imports it only for a crystal surface.
|
|
80
|
+
*/
|
|
81
|
+
export function installCrystal({
|
|
82
|
+
element,
|
|
83
|
+
id,
|
|
84
|
+
blur,
|
|
85
|
+
original,
|
|
86
|
+
filter,
|
|
87
|
+
image,
|
|
88
|
+
reinstall,
|
|
89
|
+
resize,
|
|
90
|
+
}: CrystalContext): CrystalLens {
|
|
91
|
+
const saved = {
|
|
92
|
+
position: element.style.position,
|
|
93
|
+
isolation: element.style.isolation,
|
|
94
|
+
overflow: element.style.overflow,
|
|
95
|
+
boxShadow: element.style.boxShadow,
|
|
96
|
+
backgroundImage: element.style.backgroundImage,
|
|
97
|
+
backgroundColor: element.style.backgroundColor,
|
|
98
|
+
backdropFilter: original,
|
|
99
|
+
};
|
|
100
|
+
if (getComputedStyle(element).position === "static") element.style.position = "relative";
|
|
101
|
+
element.style.isolation = "isolate";
|
|
102
|
+
element.style.overflow = "visible";
|
|
103
|
+
element.style.backgroundImage = "none";
|
|
104
|
+
element.style.backgroundColor = "transparent";
|
|
105
|
+
element.style.setProperty("--glass-lens-tint", "transparent");
|
|
106
|
+
const border = element.matches(".liquid-clear")
|
|
107
|
+
? "--glass-clear-border"
|
|
108
|
+
: "--glass-regular-border";
|
|
109
|
+
// Nothing the surface paints may sit under the layer: the lens would minify its own ring and
|
|
110
|
+
// drop shadow into view. They all move to the skin, which paints above the layer.
|
|
111
|
+
element.style.boxShadow = "none";
|
|
112
|
+
const make = (css: string) => {
|
|
113
|
+
const span = document.createElement("span");
|
|
114
|
+
span.setAttribute("aria-hidden", "true");
|
|
115
|
+
span.style.cssText = `position:absolute;z-index:-1;pointer-events:none;${css}`;
|
|
116
|
+
return span;
|
|
117
|
+
};
|
|
118
|
+
const layer = make("border-radius:0;");
|
|
119
|
+
layer.dataset.glassLensLayer = "";
|
|
120
|
+
layer.style.backdropFilter = `${blur}url(#${id})`;
|
|
121
|
+
layer.style.setProperty("-webkit-backdrop-filter", `${blur}url(#${id})`);
|
|
122
|
+
const skin = make(
|
|
123
|
+
"inset:0;border-radius:inherit;" +
|
|
124
|
+
"background-image:var(--glass-noise),radial-gradient(circle at var(--liquid-glow-x,50%) var(--liquid-glow-y,50%),color-mix(in srgb,white calc(var(--liquid-glow,0)*15%),transparent),transparent 70%),linear-gradient(var(--liquid-tint-fill),var(--liquid-tint-fill)),linear-gradient(var(--liquid-veil-fill),var(--liquid-veil-fill));" +
|
|
125
|
+
`box-shadow:var(--liquid-rim-auto,var(--liquid-rim-custom,var(--liquid-rim))),var(--liquid-depth),0 0 0 1px var(${border}),var(--liquid-shadow-custom,var(--liquid-shadow-auto,var(--liquid-shadow)));`,
|
|
126
|
+
);
|
|
127
|
+
skin.dataset.glassLensSkin = "";
|
|
128
|
+
element.prepend(skin);
|
|
129
|
+
element.prepend(layer);
|
|
130
|
+
const watch =
|
|
131
|
+
typeof MutationObserver === "function"
|
|
132
|
+
? new MutationObserver(() => {
|
|
133
|
+
if (!layer.isConnected || !skin.isConnected) reinstall();
|
|
134
|
+
})
|
|
135
|
+
: undefined;
|
|
136
|
+
watch?.observe(element, { childList: true });
|
|
137
|
+
|
|
138
|
+
// A surface that is moved towards the edge of a clipping ancestor (dragged, scrolled) loses
|
|
139
|
+
// backdrop on that side: the layer's overlap with the nearest clip tells when to look again.
|
|
140
|
+
let roomWatch: IntersectionObserver | undefined;
|
|
141
|
+
let roomRoot: Element | undefined;
|
|
142
|
+
const trackRoom = (clips: Element[]) => {
|
|
143
|
+
const root = clips[0];
|
|
144
|
+
if (root === roomRoot || typeof IntersectionObserver !== "function") return;
|
|
145
|
+
roomWatch?.disconnect();
|
|
146
|
+
roomRoot = root;
|
|
147
|
+
if (!root) return;
|
|
148
|
+
roomWatch = new IntersectionObserver(resize, {
|
|
149
|
+
root,
|
|
150
|
+
threshold: Array.from({ length: 51 }, (_, i) => i / 50),
|
|
151
|
+
});
|
|
152
|
+
roomWatch.observe(layer);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
let key = "";
|
|
156
|
+
return {
|
|
157
|
+
update(width, height, radius, refraction, dispersion, dpr) {
|
|
158
|
+
const amplitude = crystalAmplitude(width, height, refraction);
|
|
159
|
+
const margin = crystalMargin(amplitude, dispersion * 0.6);
|
|
160
|
+
const round = Math.min(radius, width / 2, height / 2);
|
|
161
|
+
const clips = clippingAncestors(element);
|
|
162
|
+
const room = backdropRoom(element, clips, margin);
|
|
163
|
+
const reach = 1 + dispersion * 0.6;
|
|
164
|
+
const wide = width + room.left + room.right;
|
|
165
|
+
const tall = height + room.top + room.bottom;
|
|
166
|
+
trackRoom(clips);
|
|
167
|
+
const next = [
|
|
168
|
+
width,
|
|
169
|
+
height,
|
|
170
|
+
round,
|
|
171
|
+
amplitude,
|
|
172
|
+
margin,
|
|
173
|
+
dpr,
|
|
174
|
+
room.left,
|
|
175
|
+
room.right,
|
|
176
|
+
room.top,
|
|
177
|
+
room.bottom,
|
|
178
|
+
].join("x");
|
|
179
|
+
if (next === key) return undefined;
|
|
180
|
+
key = next;
|
|
181
|
+
const box = getComputedStyle(element);
|
|
182
|
+
const left = -(room.left + (Number.parseFloat(box.borderLeftWidth) || 0));
|
|
183
|
+
const top = -(room.top + (Number.parseFloat(box.borderTopWidth) || 0));
|
|
184
|
+
layer.style.left = `${left}px`;
|
|
185
|
+
layer.style.top = `${top}px`;
|
|
186
|
+
layer.style.width = `${wide}px`;
|
|
187
|
+
layer.style.height = `${tall}px`;
|
|
188
|
+
layer.style.clipPath = `inset(${room.top}px ${room.right}px ${room.bottom}px ${room.left}px round ${round}px)`;
|
|
189
|
+
for (const [target, name, value] of [
|
|
190
|
+
[filter, "x", "0"],
|
|
191
|
+
[filter, "y", "0"],
|
|
192
|
+
[filter, "width", String(wide)],
|
|
193
|
+
[filter, "height", String(tall)],
|
|
194
|
+
[image, "width", String(wide)],
|
|
195
|
+
[image, "height", String(tall)],
|
|
196
|
+
] as const)
|
|
197
|
+
target.setAttribute(name, value);
|
|
198
|
+
image.setAttribute(
|
|
199
|
+
"href",
|
|
200
|
+
createCrystalMap({
|
|
201
|
+
width,
|
|
202
|
+
height,
|
|
203
|
+
amplitude,
|
|
204
|
+
dpr: Math.max(0.5, Math.min(dpr, Math.sqrt(CRYSTAL_MAP_PIXELS / (wide * tall)))),
|
|
205
|
+
margin,
|
|
206
|
+
room,
|
|
207
|
+
reach,
|
|
208
|
+
}),
|
|
209
|
+
);
|
|
210
|
+
return (2 * Math.max(amplitude, 1) * 255) / 254;
|
|
211
|
+
},
|
|
212
|
+
undo() {
|
|
213
|
+
watch?.disconnect();
|
|
214
|
+
roomWatch?.disconnect();
|
|
215
|
+
layer.remove();
|
|
216
|
+
skin.remove();
|
|
217
|
+
for (const [name, value] of Object.entries(saved)) {
|
|
218
|
+
if (name === "backdropFilter") continue;
|
|
219
|
+
element.style.setProperty(
|
|
220
|
+
name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`),
|
|
221
|
+
value,
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** The node factory and the displacement pass of the lens filter being built. */
|
|
2
|
+
export interface DispersionPasses {
|
|
3
|
+
node: (name: string, attrs: Record<string, string>) => Element;
|
|
4
|
+
displace: (channel: "r" | "g" | "b", factor: number) => void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const KEEP = {
|
|
8
|
+
r: "1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0",
|
|
9
|
+
g: "0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0",
|
|
10
|
+
b: "0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0",
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
const ADD = { operator: "arithmetic", k1: "0", k2: "1", k3: "1", k4: "0" };
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Chromatic dispersion: the three colour channels are displaced by slightly different amounts
|
|
17
|
+
* (blue the least, red the most, so the rim fringes like real glass) and added back into `lens`.
|
|
18
|
+
* Its own lazy chunk: the engine imports it only for a surface that asks for dispersion.
|
|
19
|
+
*/
|
|
20
|
+
export function addDispersion(
|
|
21
|
+
{ node, displace }: DispersionPasses,
|
|
22
|
+
dispersion: number,
|
|
23
|
+
crystal: boolean,
|
|
24
|
+
): void {
|
|
25
|
+
// The crystal's offsets are large, so the same fraction would paint a noisy rainbow.
|
|
26
|
+
const spread = crystal ? dispersion * 0.6 : dispersion;
|
|
27
|
+
const factors = { r: 1 + spread, g: 1, b: 1 - spread } as const;
|
|
28
|
+
for (const c of ["r", "g", "b"] as const) {
|
|
29
|
+
displace(c, factors[c]);
|
|
30
|
+
node("feColorMatrix", { in: `d${c}`, type: "matrix", values: KEEP[c], result: c });
|
|
31
|
+
}
|
|
32
|
+
node("feComposite", { in: "r", in2: "g", ...ADD, result: "rg" });
|
|
33
|
+
node("feComposite", { in: "rg", in2: "b", ...ADD, result: "lens" });
|
|
34
|
+
}
|