@easemate/web-kit 0.1.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/README.md +824 -0
- package/build/components/code/index.cjs +152 -0
- package/build/components/code/index.d.cts +11 -0
- package/build/components/code/index.d.ts +11 -0
- package/build/components/code/index.js +148 -0
- package/build/components/code/utils/highlight-api.cjs +18 -0
- package/build/components/code/utils/highlight-api.d.cts +7 -0
- package/build/components/code/utils/highlight-api.d.ts +7 -0
- package/build/components/code/utils/highlight-api.js +14 -0
- package/build/components/code/utils/syntax-grammars.cjs +62 -0
- package/build/components/code/utils/syntax-grammars.d.cts +7 -0
- package/build/components/code/utils/syntax-grammars.d.ts +7 -0
- package/build/components/code/utils/syntax-grammars.js +59 -0
- package/build/components/code/utils/syntax-highlighter-theme.cjs +27 -0
- package/build/components/code/utils/syntax-highlighter-theme.d.cts +3 -0
- package/build/components/code/utils/syntax-highlighter-theme.d.ts +3 -0
- package/build/components/code/utils/syntax-highlighter-theme.js +23 -0
- package/build/components/code/utils/syntax-highlighter-types.cjs +2 -0
- package/build/components/code/utils/syntax-highlighter-types.d.cts +12 -0
- package/build/components/code/utils/syntax-highlighter-types.d.ts +12 -0
- package/build/components/code/utils/syntax-highlighter-types.js +1 -0
- package/build/components/code/utils/syntax-tokenizer.cjs +63 -0
- package/build/components/code/utils/syntax-tokenizer.d.cts +3 -0
- package/build/components/code/utils/syntax-tokenizer.d.ts +3 -0
- package/build/components/code/utils/syntax-tokenizer.js +58 -0
- package/build/components/curve/bezier-conversion.cjs +23 -0
- package/build/components/curve/bezier-conversion.d.cts +2 -0
- package/build/components/curve/bezier-conversion.d.ts +2 -0
- package/build/components/curve/bezier-conversion.js +19 -0
- package/build/components/curve/canvas-controls.cjs +300 -0
- package/build/components/curve/canvas-controls.d.cts +12 -0
- package/build/components/curve/canvas-controls.d.ts +12 -0
- package/build/components/curve/canvas-controls.js +296 -0
- package/build/components/curve/canvas.cjs +1208 -0
- package/build/components/curve/canvas.d.cts +24 -0
- package/build/components/curve/canvas.d.ts +24 -0
- package/build/components/curve/canvas.js +1204 -0
- package/build/components/curve/constants.cjs +203 -0
- package/build/components/curve/constants.d.cts +23 -0
- package/build/components/curve/constants.d.ts +23 -0
- package/build/components/curve/constants.js +200 -0
- package/build/components/curve/controls.cjs +942 -0
- package/build/components/curve/controls.d.cts +37 -0
- package/build/components/curve/controls.d.ts +37 -0
- package/build/components/curve/controls.js +938 -0
- package/build/components/curve/index.cjs +335 -0
- package/build/components/curve/index.d.cts +31 -0
- package/build/components/curve/index.d.ts +31 -0
- package/build/components/curve/index.js +330 -0
- package/build/components/curve/output.cjs +141 -0
- package/build/components/curve/output.d.cts +19 -0
- package/build/components/curve/output.d.ts +19 -0
- package/build/components/curve/output.js +137 -0
- package/build/components/curve/styles.cjs +493 -0
- package/build/components/curve/styles.d.cts +6 -0
- package/build/components/curve/styles.d.ts +6 -0
- package/build/components/curve/styles.js +490 -0
- package/build/components/curve/svg-renderer.cjs +185 -0
- package/build/components/curve/svg-renderer.d.cts +9 -0
- package/build/components/curve/svg-renderer.d.ts +9 -0
- package/build/components/curve/svg-renderer.js +175 -0
- package/build/components/curve/toolbar.cjs +368 -0
- package/build/components/curve/toolbar.d.cts +26 -0
- package/build/components/curve/toolbar.d.ts +26 -0
- package/build/components/curve/toolbar.js +364 -0
- package/build/components/curve/types.cjs +10 -0
- package/build/components/curve/types.d.cts +33 -0
- package/build/components/curve/types.d.ts +33 -0
- package/build/components/curve/types.js +7 -0
- package/build/components/curve/utils.cjs +541 -0
- package/build/components/curve/utils.d.cts +33 -0
- package/build/components/curve/utils.d.ts +33 -0
- package/build/components/curve/utils.js +521 -0
- package/build/components/index.cjs +18 -0
- package/build/components/index.d.cts +2 -0
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/build/decorators/Component.cjs +127 -0
- package/build/decorators/Component.d.cts +28 -0
- package/build/decorators/Component.d.ts +28 -0
- package/build/decorators/Component.js +123 -0
- package/build/decorators/Listen.cjs +154 -0
- package/build/decorators/Listen.d.cts +18 -0
- package/build/decorators/Listen.d.ts +18 -0
- package/build/decorators/Listen.js +151 -0
- package/build/decorators/OutsideClick.cjs +64 -0
- package/build/decorators/OutsideClick.d.cts +16 -0
- package/build/decorators/OutsideClick.d.ts +16 -0
- package/build/decorators/OutsideClick.js +59 -0
- package/build/decorators/Prop.cjs +273 -0
- package/build/decorators/Prop.d.cts +22 -0
- package/build/decorators/Prop.d.ts +22 -0
- package/build/decorators/Prop.js +270 -0
- package/build/decorators/Query.cjs +79 -0
- package/build/decorators/Query.d.cts +27 -0
- package/build/decorators/Query.d.ts +27 -0
- package/build/decorators/Query.js +76 -0
- package/build/decorators/Watch.cjs +52 -0
- package/build/decorators/Watch.d.cts +11 -0
- package/build/decorators/Watch.d.ts +11 -0
- package/build/decorators/Watch.js +49 -0
- package/build/decorators/index.cjs +15 -0
- package/build/decorators/index.d.cts +6 -0
- package/build/decorators/index.d.ts +6 -0
- package/build/decorators/index.js +6 -0
- package/build/elements/button/index.cjs +214 -0
- package/build/elements/button/index.d.cts +11 -0
- package/build/elements/button/index.d.ts +11 -0
- package/build/elements/button/index.js +210 -0
- package/build/elements/checkbox/index.cjs +316 -0
- package/build/elements/checkbox/index.d.cts +14 -0
- package/build/elements/checkbox/index.d.ts +14 -0
- package/build/elements/checkbox/index.js +312 -0
- package/build/elements/color/index.cjs +154 -0
- package/build/elements/color/index.d.cts +18 -0
- package/build/elements/color/index.d.ts +18 -0
- package/build/elements/color/index.js +150 -0
- package/build/elements/color/picker.cjs +544 -0
- package/build/elements/color/picker.d.cts +37 -0
- package/build/elements/color/picker.d.ts +37 -0
- package/build/elements/color/picker.js +540 -0
- package/build/elements/color/utils.cjs +235 -0
- package/build/elements/color/utils.d.cts +37 -0
- package/build/elements/color/utils.d.ts +37 -0
- package/build/elements/color/utils.js +218 -0
- package/build/elements/dropdown/index.cjs +875 -0
- package/build/elements/dropdown/index.d.cts +30 -0
- package/build/elements/dropdown/index.d.ts +30 -0
- package/build/elements/dropdown/index.js +871 -0
- package/build/elements/field/index.cjs +82 -0
- package/build/elements/field/index.d.cts +4 -0
- package/build/elements/field/index.d.ts +4 -0
- package/build/elements/field/index.js +78 -0
- package/build/elements/icons/animation/chevron.cjs +57 -0
- package/build/elements/icons/animation/chevron.d.cts +10 -0
- package/build/elements/icons/animation/chevron.d.ts +10 -0
- package/build/elements/icons/animation/chevron.js +53 -0
- package/build/elements/icons/animation/clear.cjs +74 -0
- package/build/elements/icons/animation/clear.d.cts +3 -0
- package/build/elements/icons/animation/clear.d.ts +3 -0
- package/build/elements/icons/animation/clear.js +70 -0
- package/build/elements/icons/animation/grid.cjs +77 -0
- package/build/elements/icons/animation/grid.d.cts +8 -0
- package/build/elements/icons/animation/grid.d.ts +8 -0
- package/build/elements/icons/animation/grid.js +73 -0
- package/build/elements/icons/animation/loading.cjs +68 -0
- package/build/elements/icons/animation/loading.d.cts +3 -0
- package/build/elements/icons/animation/loading.d.ts +3 -0
- package/build/elements/icons/animation/loading.js +64 -0
- package/build/elements/icons/animation/snap.cjs +133 -0
- package/build/elements/icons/animation/snap.d.cts +8 -0
- package/build/elements/icons/animation/snap.d.ts +8 -0
- package/build/elements/icons/animation/snap.js +129 -0
- package/build/elements/icons/index.cjs +40 -0
- package/build/elements/icons/index.d.cts +24 -0
- package/build/elements/icons/index.d.ts +24 -0
- package/build/elements/icons/index.js +24 -0
- package/build/elements/icons/interface/anchor-add.cjs +35 -0
- package/build/elements/icons/interface/anchor-add.d.cts +3 -0
- package/build/elements/icons/interface/anchor-add.d.ts +3 -0
- package/build/elements/icons/interface/anchor-add.js +31 -0
- package/build/elements/icons/interface/anchor-remove.cjs +34 -0
- package/build/elements/icons/interface/anchor-remove.d.cts +3 -0
- package/build/elements/icons/interface/anchor-remove.d.ts +3 -0
- package/build/elements/icons/interface/anchor-remove.js +30 -0
- package/build/elements/icons/interface/arrow-up.cjs +30 -0
- package/build/elements/icons/interface/arrow-up.d.cts +3 -0
- package/build/elements/icons/interface/arrow-up.d.ts +3 -0
- package/build/elements/icons/interface/arrow-up.js +26 -0
- package/build/elements/icons/interface/arrows-vertical.cjs +30 -0
- package/build/elements/icons/interface/arrows-vertical.d.cts +3 -0
- package/build/elements/icons/interface/arrows-vertical.d.ts +3 -0
- package/build/elements/icons/interface/arrows-vertical.js +26 -0
- package/build/elements/icons/interface/bezier-angle.cjs +33 -0
- package/build/elements/icons/interface/bezier-angle.d.cts +3 -0
- package/build/elements/icons/interface/bezier-angle.d.ts +3 -0
- package/build/elements/icons/interface/bezier-angle.js +29 -0
- package/build/elements/icons/interface/bezier-distribute.cjs +34 -0
- package/build/elements/icons/interface/bezier-distribute.d.cts +3 -0
- package/build/elements/icons/interface/bezier-distribute.d.ts +3 -0
- package/build/elements/icons/interface/bezier-distribute.js +30 -0
- package/build/elements/icons/interface/bezier-length.cjs +31 -0
- package/build/elements/icons/interface/bezier-length.d.cts +3 -0
- package/build/elements/icons/interface/bezier-length.d.ts +3 -0
- package/build/elements/icons/interface/bezier-length.js +27 -0
- package/build/elements/icons/interface/bezier-mirror.cjs +31 -0
- package/build/elements/icons/interface/bezier-mirror.d.cts +3 -0
- package/build/elements/icons/interface/bezier-mirror.d.ts +3 -0
- package/build/elements/icons/interface/bezier-mirror.js +27 -0
- package/build/elements/icons/interface/bezier.cjs +26 -0
- package/build/elements/icons/interface/bezier.d.cts +3 -0
- package/build/elements/icons/interface/bezier.d.ts +3 -0
- package/build/elements/icons/interface/bezier.js +22 -0
- package/build/elements/icons/interface/check.cjs +30 -0
- package/build/elements/icons/interface/check.d.cts +3 -0
- package/build/elements/icons/interface/check.d.ts +3 -0
- package/build/elements/icons/interface/check.js +26 -0
- package/build/elements/icons/interface/circle-arrow-left.cjs +30 -0
- package/build/elements/icons/interface/circle-arrow-left.d.cts +3 -0
- package/build/elements/icons/interface/circle-arrow-left.d.ts +3 -0
- package/build/elements/icons/interface/circle-arrow-left.js +26 -0
- package/build/elements/icons/interface/circle-arrow-right.cjs +30 -0
- package/build/elements/icons/interface/circle-arrow-right.d.cts +3 -0
- package/build/elements/icons/interface/circle-arrow-right.d.ts +3 -0
- package/build/elements/icons/interface/circle-arrow-right.js +26 -0
- package/build/elements/icons/interface/code.cjs +30 -0
- package/build/elements/icons/interface/code.d.cts +3 -0
- package/build/elements/icons/interface/code.d.ts +3 -0
- package/build/elements/icons/interface/code.js +26 -0
- package/build/elements/icons/interface/dots.cjs +32 -0
- package/build/elements/icons/interface/dots.d.cts +3 -0
- package/build/elements/icons/interface/dots.d.ts +3 -0
- package/build/elements/icons/interface/dots.js +28 -0
- package/build/elements/icons/interface/mention.cjs +30 -0
- package/build/elements/icons/interface/mention.d.cts +3 -0
- package/build/elements/icons/interface/mention.d.ts +3 -0
- package/build/elements/icons/interface/mention.js +26 -0
- package/build/elements/icons/interface/minus.cjs +30 -0
- package/build/elements/icons/interface/minus.d.cts +3 -0
- package/build/elements/icons/interface/minus.d.ts +3 -0
- package/build/elements/icons/interface/minus.js +26 -0
- package/build/elements/icons/interface/picker.cjs +34 -0
- package/build/elements/icons/interface/picker.d.cts +3 -0
- package/build/elements/icons/interface/picker.d.ts +3 -0
- package/build/elements/icons/interface/picker.js +30 -0
- package/build/elements/icons/interface/plus.cjs +30 -0
- package/build/elements/icons/interface/plus.d.cts +3 -0
- package/build/elements/icons/interface/plus.d.ts +3 -0
- package/build/elements/icons/interface/plus.js +26 -0
- package/build/elements/icons/interface/settings.cjs +30 -0
- package/build/elements/icons/interface/settings.d.cts +3 -0
- package/build/elements/icons/interface/settings.d.ts +3 -0
- package/build/elements/icons/interface/settings.js +26 -0
- package/build/elements/index.cjs +62 -0
- package/build/elements/index.d.cts +22 -0
- package/build/elements/index.d.ts +22 -0
- package/build/elements/index.js +22 -0
- package/build/elements/input/index.cjs +273 -0
- package/build/elements/input/index.d.cts +17 -0
- package/build/elements/input/index.d.ts +17 -0
- package/build/elements/input/index.js +269 -0
- package/build/elements/logo/index.cjs +732 -0
- package/build/elements/logo/index.d.cts +17 -0
- package/build/elements/logo/index.d.ts +17 -0
- package/build/elements/logo/index.js +728 -0
- package/build/elements/monitor/fps.cjs +432 -0
- package/build/elements/monitor/fps.d.cts +21 -0
- package/build/elements/monitor/fps.d.ts +21 -0
- package/build/elements/monitor/fps.js +428 -0
- package/build/elements/monitor/index.cjs +670 -0
- package/build/elements/monitor/index.d.cts +112 -0
- package/build/elements/monitor/index.d.ts +112 -0
- package/build/elements/monitor/index.js +666 -0
- package/build/elements/number/index.cjs +173 -0
- package/build/elements/number/index.d.cts +19 -0
- package/build/elements/number/index.d.ts +19 -0
- package/build/elements/number/index.js +169 -0
- package/build/elements/origin/index.cjs +169 -0
- package/build/elements/origin/index.d.cts +12 -0
- package/build/elements/origin/index.d.ts +12 -0
- package/build/elements/origin/index.js +165 -0
- package/build/elements/popover/index.cjs +209 -0
- package/build/elements/popover/index.d.cts +19 -0
- package/build/elements/popover/index.d.ts +19 -0
- package/build/elements/popover/index.js +205 -0
- package/build/elements/radio/index.cjs +301 -0
- package/build/elements/radio/index.d.cts +13 -0
- package/build/elements/radio/index.d.ts +13 -0
- package/build/elements/radio/index.js +283 -0
- package/build/elements/radio/input.cjs +329 -0
- package/build/elements/radio/input.d.cts +15 -0
- package/build/elements/radio/input.d.ts +15 -0
- package/build/elements/radio/input.js +325 -0
- package/build/elements/radio/option.cjs +15 -0
- package/build/elements/radio/option.d.cts +3 -0
- package/build/elements/radio/option.d.ts +3 -0
- package/build/elements/radio/option.js +11 -0
- package/build/elements/shared.cjs +66 -0
- package/build/elements/shared.d.cts +40 -0
- package/build/elements/shared.d.ts +40 -0
- package/build/elements/shared.js +59 -0
- package/build/elements/slider/index.cjs +232 -0
- package/build/elements/slider/index.d.cts +20 -0
- package/build/elements/slider/index.d.ts +20 -0
- package/build/elements/slider/index.js +228 -0
- package/build/elements/state/index.cjs +681 -0
- package/build/elements/state/index.d.cts +86 -0
- package/build/elements/state/index.d.ts +86 -0
- package/build/elements/state/index.js +677 -0
- package/build/elements/toggle/index.cjs +151 -0
- package/build/elements/toggle/index.d.cts +9 -0
- package/build/elements/toggle/index.d.ts +9 -0
- package/build/elements/toggle/index.js +147 -0
- package/build/elements/tooltip/index.cjs +187 -0
- package/build/elements/tooltip/index.d.cts +17 -0
- package/build/elements/tooltip/index.d.ts +17 -0
- package/build/elements/tooltip/index.js +183 -0
- package/build/index.cjs +40 -0
- package/build/index.d.cts +6 -0
- package/build/index.d.ts +6 -0
- package/build/index.js +12 -0
- package/build/init.cjs +325 -0
- package/build/init.d.cts +157 -0
- package/build/init.d.ts +157 -0
- package/build/init.js +289 -0
- package/build/internal/component-loaders.cjs +206 -0
- package/build/internal/component-loaders.d.cts +52 -0
- package/build/internal/component-loaders.d.ts +52 -0
- package/build/internal/component-loaders.js +167 -0
- package/build/internal/fonts.cjs +128 -0
- package/build/internal/fonts.d.cts +32 -0
- package/build/internal/fonts.d.ts +32 -0
- package/build/internal/fonts.js +123 -0
- package/build/internal/lazy-load.cjs +89 -0
- package/build/internal/lazy-load.d.cts +32 -0
- package/build/internal/lazy-load.d.ts +32 -0
- package/build/internal/lazy-load.js +86 -0
- package/build/internal/style-inject.cjs +236 -0
- package/build/internal/style-inject.d.cts +44 -0
- package/build/internal/style-inject.d.ts +44 -0
- package/build/internal/style-inject.js +226 -0
- package/build/register.cjs +36 -0
- package/build/register.d.cts +32 -0
- package/build/register.d.ts +32 -0
- package/build/register.js +34 -0
- package/build/theme/index.cjs +452 -0
- package/build/theme/index.d.cts +146 -0
- package/build/theme/index.d.ts +146 -0
- package/build/theme/index.js +423 -0
- package/build/theme/presets.cjs +54 -0
- package/build/theme/presets.d.cts +19 -0
- package/build/theme/presets.d.ts +19 -0
- package/build/theme/presets.js +51 -0
- package/build/theme/registry.cjs +204 -0
- package/build/theme/registry.d.cts +99 -0
- package/build/theme/registry.d.ts +99 -0
- package/build/theme/registry.js +194 -0
- package/build/theme/tokens.cjs +148 -0
- package/build/theme/tokens.d.cts +163 -0
- package/build/theme/tokens.d.ts +163 -0
- package/build/theme/tokens.js +145 -0
- package/build/utils/dismiss-controller.cjs +77 -0
- package/build/utils/dismiss-controller.d.cts +14 -0
- package/build/utils/dismiss-controller.d.ts +14 -0
- package/build/utils/dismiss-controller.js +73 -0
- package/build/utils/index.cjs +18 -0
- package/build/utils/index.d.cts +3 -0
- package/build/utils/index.d.ts +3 -0
- package/build/utils/index.js +3 -0
- package/build/utils/outside-click.cjs +82 -0
- package/build/utils/outside-click.d.cts +18 -0
- package/build/utils/outside-click.d.ts +18 -0
- package/build/utils/outside-click.js +74 -0
- package/build/utils/template-helpers.cjs +39 -0
- package/build/utils/template-helpers.d.cts +13 -0
- package/build/utils/template-helpers.d.ts +13 -0
- package/build/utils/template-helpers.js +28 -0
- package/package.json +96 -0
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import { html } from 'lit-html';
|
|
2
|
+
import { dispatchControlEvent } from "../shared.js";
|
|
3
|
+
import { COLOR_FORMATS, getColorComponents, hexToHsv, hsvToHex, hsvToRgb, isLightColor, isValidHex, updateHsvFromComponents } from "./utils.js";
|
|
4
|
+
import { Component } from '~/decorators/Component';
|
|
5
|
+
import { Prop } from '~/decorators/Prop';
|
|
6
|
+
import { Query } from '~/decorators/Query';
|
|
7
|
+
import { styleMap } from '~/utils/template-helpers';
|
|
8
|
+
import "../icons/interface/arrows-vertical.js";
|
|
9
|
+
import "../icons/interface/picker.js";
|
|
10
|
+
@Component({
|
|
11
|
+
tag: 'ease-color-picker',
|
|
12
|
+
autoSlot: false,
|
|
13
|
+
styles: `
|
|
14
|
+
:host {
|
|
15
|
+
display: grid;
|
|
16
|
+
grid-gap: 8px;
|
|
17
|
+
user-select: none;
|
|
18
|
+
-webkit-user-select: none;
|
|
19
|
+
|
|
20
|
+
--ease-color-picker-width: 180px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[part="saturation"] {
|
|
24
|
+
position: relative;
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 124px;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
background-image: linear-gradient(to top, black, transparent), linear-gradient(to right, white, transparent);
|
|
29
|
+
border-radius: 7px;
|
|
30
|
+
touch-action: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[part="saturation-handle"] {
|
|
34
|
+
position: absolute;
|
|
35
|
+
width: 10px;
|
|
36
|
+
height: 10px;
|
|
37
|
+
box-shadow: inset 0 0 0 2px var(--color-blue-100);
|
|
38
|
+
border-radius: 50%;
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[part="hue"] {
|
|
43
|
+
position: relative;
|
|
44
|
+
height: 8px;
|
|
45
|
+
align-self: center;
|
|
46
|
+
flex-grow: 1;
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
border-radius: 9px;
|
|
49
|
+
background-image: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
|
|
50
|
+
touch-action: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[part="hue-handle"] {
|
|
54
|
+
position: absolute;
|
|
55
|
+
top: 0;
|
|
56
|
+
width: 8px;
|
|
57
|
+
height: 8px;
|
|
58
|
+
box-shadow: inset 0 0 0 2px var(--color-blue-100);
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[part="preview"] {
|
|
64
|
+
position: relative;
|
|
65
|
+
width: 20px;
|
|
66
|
+
height: 20px;
|
|
67
|
+
border-radius: 5px;
|
|
68
|
+
box-shadow: inset 0 0 0 .75px var(--color-blue-80);
|
|
69
|
+
display: grid;
|
|
70
|
+
place-items: center;
|
|
71
|
+
|
|
72
|
+
&[data-eyedropper] {
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
|
|
75
|
+
&:hover,
|
|
76
|
+
&:focus-visible {
|
|
77
|
+
ease-icon-picker {
|
|
78
|
+
scale: 1.1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ease-icon-picker {
|
|
83
|
+
color: var(--icon-color, var(--color-blue-100));
|
|
84
|
+
transition: scale 0.2s, color 0.15s;
|
|
85
|
+
filter: drop-shadow(0 0 2px var(--color-black-15));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
[part="toolbar"] {
|
|
91
|
+
display: flex;
|
|
92
|
+
justify-content: space-between;
|
|
93
|
+
align-items: center;
|
|
94
|
+
gap: 8px;
|
|
95
|
+
position: relative;
|
|
96
|
+
z-index: 1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
[part="toolbar"] ease-button {
|
|
100
|
+
padding: 4px;
|
|
101
|
+
width: max-content;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
[part="format-container"] {
|
|
105
|
+
display: grid;
|
|
106
|
+
grid-template-columns: 30px 1fr;
|
|
107
|
+
align-items: center;
|
|
108
|
+
gap: 8px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
[part="format-inputs"] {
|
|
112
|
+
padding: 2px 4px;
|
|
113
|
+
width: 100%;
|
|
114
|
+
border-radius: var(--ease-color-picker-format-radius, var(--radii-md));
|
|
115
|
+
background-color: var(--ease-color-picker-format-background, var(--color-gray-850));
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
box-shadow: var(
|
|
118
|
+
--ease-color-picker-format-shadow,
|
|
119
|
+
inset 0 1px 0.25px 0 var(--color-white-4),
|
|
120
|
+
0 1px 2.5px 0 var(--color-black-8)
|
|
121
|
+
);
|
|
122
|
+
box-sizing: border-box;
|
|
123
|
+
display: flex;
|
|
124
|
+
justify-content: space-around;
|
|
125
|
+
|
|
126
|
+
&:hover,
|
|
127
|
+
&:focus-within {
|
|
128
|
+
background-color: var(--ease-color-picker-format-background-hover, var(--color-gray-825));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
[part="format-input"] {
|
|
133
|
+
appearance: none;
|
|
134
|
+
-moz-appearance: textfield;
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
box-sizing: border-box;
|
|
137
|
+
font-size: var(--ease-color-picker-format-font-size, 11px);
|
|
138
|
+
font-weight: 500;
|
|
139
|
+
color: var(--color-gray-600);
|
|
140
|
+
min-width: 0;
|
|
141
|
+
box-sizing: border-box;
|
|
142
|
+
border: none;
|
|
143
|
+
outline: none;
|
|
144
|
+
padding: 4px;
|
|
145
|
+
margin: 0;
|
|
146
|
+
background-color: transparent;
|
|
147
|
+
line-height: 12px;
|
|
148
|
+
transition: color 0.2s;
|
|
149
|
+
width: 100%;
|
|
150
|
+
text-align: center;
|
|
151
|
+
font-optical-sizing: auto;
|
|
152
|
+
font-family: var(--ease-font-mono, 'Geist Mono', monospace);
|
|
153
|
+
|
|
154
|
+
&:hover,
|
|
155
|
+
&:focus-within {
|
|
156
|
+
color: var(--color-blue-100);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
&::placeholder {
|
|
160
|
+
color: var(--color-gray-800);
|
|
161
|
+
opacity: 1;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&::-webkit-outer-spin-button,
|
|
165
|
+
&::-webkit-inner-spin-button {
|
|
166
|
+
-webkit-appearance: none;
|
|
167
|
+
margin: 0;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
[part="color-container"] {
|
|
172
|
+
display: grid;
|
|
173
|
+
grid-template-columns: 1fr 20px;
|
|
174
|
+
align-items: center;
|
|
175
|
+
gap: 8px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
[part="format-trigger"] {
|
|
179
|
+
--ease-icon-size: var(--ease-color-picker-format-icon-size, 10px);
|
|
180
|
+
|
|
181
|
+
display: flex;
|
|
182
|
+
align-items: center;
|
|
183
|
+
gap: 2px;
|
|
184
|
+
font-family: var(--ease-font-mono, 'Geist Mono', monospace);
|
|
185
|
+
font-optical-sizing: auto;
|
|
186
|
+
font-size: var(--ease-color-picker-format-trigger-font-size, 10px);
|
|
187
|
+
font-weight: 500;
|
|
188
|
+
color: var(--color-gray-400);
|
|
189
|
+
cursor: pointer;
|
|
190
|
+
transition: color 0.15s;
|
|
191
|
+
overflow: hidden;
|
|
192
|
+
position: relative;
|
|
193
|
+
height: 14px;
|
|
194
|
+
|
|
195
|
+
&:hover {
|
|
196
|
+
color: var(--color-gray-200);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
ease-icon-arrows-vertical {
|
|
200
|
+
color: var(--color-gray-600);
|
|
201
|
+
flex-shrink: 0;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
[part="format-label"] {
|
|
206
|
+
display: inline-block;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
[part="format-label"][data-animating="out"] {
|
|
210
|
+
animation: formatOut 0.15s ease-in forwards;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
[part="format-label"][data-animating="in"] {
|
|
214
|
+
animation: formatIn 0.15s ease-out forwards;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@keyframes formatOut {
|
|
218
|
+
0% {
|
|
219
|
+
transform: translateY(0) scale(1);
|
|
220
|
+
opacity: 1;
|
|
221
|
+
}
|
|
222
|
+
100% {
|
|
223
|
+
transform: translateY(6px) scale(0.8);
|
|
224
|
+
opacity: 0;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@keyframes formatIn {
|
|
229
|
+
0% {
|
|
230
|
+
transform: translateY(-6px) scale(0.8);
|
|
231
|
+
opacity: 0;
|
|
232
|
+
}
|
|
233
|
+
100% {
|
|
234
|
+
transform: translateY(0) scale(1);
|
|
235
|
+
opacity: 1;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
`,
|
|
240
|
+
template() {
|
|
241
|
+
const { h, s, v } = this.hsv;
|
|
242
|
+
const pureHue = hsvToRgb(h, 1, 1);
|
|
243
|
+
const currentRgb = hsvToRgb(h, s, v);
|
|
244
|
+
const saturationBg = `rgb(${pureHue.r}, ${pureHue.g}, ${pureHue.b})`;
|
|
245
|
+
const huePercent = h / 360;
|
|
246
|
+
const vInverted = 1 - v;
|
|
247
|
+
// Position handles so they stay within container bounds (handle is 10px)
|
|
248
|
+
const saturationHandleStyles = {
|
|
249
|
+
left: `calc(${s * 100}% - ${s * 10}px)`,
|
|
250
|
+
top: `calc(${vInverted * 100}% - ${vInverted * 10}px)`
|
|
251
|
+
};
|
|
252
|
+
const hueHandleStyles = {
|
|
253
|
+
left: `calc(${huePercent * 100}% - ${huePercent * 10}px)`
|
|
254
|
+
};
|
|
255
|
+
const isLight = isLightColor(currentRgb.r, currentRgb.g, currentRgb.b);
|
|
256
|
+
const hasEyeDropper = 'EyeDropper' in window;
|
|
257
|
+
const previewStyles = {
|
|
258
|
+
backgroundColor: this.value,
|
|
259
|
+
'--icon-color': isLight ? 'var(--color-gray-900)' : 'var(--color-blue-100)'
|
|
260
|
+
};
|
|
261
|
+
const components = getColorComponents(this.hsv, this.format);
|
|
262
|
+
return html `
|
|
263
|
+
<div
|
|
264
|
+
part="saturation"
|
|
265
|
+
style=${styleMap({ backgroundColor: saturationBg })}
|
|
266
|
+
@pointerdown=${this.handleSaturationPointerDown}
|
|
267
|
+
@pointermove=${this.handleSaturationPointerMove}
|
|
268
|
+
@pointerup=${this.handleSaturationPointerUp}
|
|
269
|
+
@pointercancel=${this.handleSaturationPointerUp}
|
|
270
|
+
>
|
|
271
|
+
<div part="saturation-handle" style=${styleMap(saturationHandleStyles)}></div>
|
|
272
|
+
</div>
|
|
273
|
+
<div part="color-container">
|
|
274
|
+
<div
|
|
275
|
+
part="hue"
|
|
276
|
+
@pointerdown=${this.handleHuePointerDown}
|
|
277
|
+
@pointermove=${this.handleHuePointerMove}
|
|
278
|
+
@pointerup=${this.handleHuePointerUp}
|
|
279
|
+
@pointercancel=${this.handleHuePointerUp}
|
|
280
|
+
>
|
|
281
|
+
<div part="hue-handle" style=${styleMap(hueHandleStyles)}></div>
|
|
282
|
+
</div>
|
|
283
|
+
|
|
284
|
+
<div
|
|
285
|
+
part="preview"
|
|
286
|
+
style=${styleMap(previewStyles)}
|
|
287
|
+
?data-eyedropper=${hasEyeDropper}
|
|
288
|
+
@click=${hasEyeDropper ? this.handleEyeDropperClick : null}
|
|
289
|
+
>
|
|
290
|
+
${hasEyeDropper ? html `<ease-icon-picker></ease-icon-picker>` : null}
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
<div part="format-container">
|
|
294
|
+
<div part="format-trigger" @click=${this.handleFormatCycle}>
|
|
295
|
+
<span part="format-label" data-animating=${this.formatAnimating}>${this.format.toUpperCase()}</span>
|
|
296
|
+
<ease-icon-arrows-vertical />
|
|
297
|
+
</div>
|
|
298
|
+
<div part="format-inputs">
|
|
299
|
+
${this.format === 'hex'
|
|
300
|
+
? html `
|
|
301
|
+
<input
|
|
302
|
+
part="format-input"
|
|
303
|
+
data-hex
|
|
304
|
+
type="text"
|
|
305
|
+
.value=${components.values[0]}
|
|
306
|
+
@input=${(e) => this.handleComponentChange(0, e.target.value)}
|
|
307
|
+
/>
|
|
308
|
+
`
|
|
309
|
+
: components.labels.map((_, i) => html `
|
|
310
|
+
<input
|
|
311
|
+
part="format-input"
|
|
312
|
+
type="number"
|
|
313
|
+
min="0"
|
|
314
|
+
max=${components.max[i]}
|
|
315
|
+
.value=${String(components.values[i])}
|
|
316
|
+
@input=${(e) => this.handleComponentChange(i, Number(e.target.value))}
|
|
317
|
+
/>
|
|
318
|
+
`)}
|
|
319
|
+
</div>
|
|
320
|
+
</div>
|
|
321
|
+
<div part="toolbar">
|
|
322
|
+
<ease-button variant="headless-muted" @click=${this.handleCancelButtonClick}>Cancel</ease-button>
|
|
323
|
+
<ease-button variant="headless" @click=${this.handleApplyButtonClick}>Apply</ease-button>
|
|
324
|
+
</div>
|
|
325
|
+
`;
|
|
326
|
+
}
|
|
327
|
+
})
|
|
328
|
+
export class ColorPicker extends HTMLElement {
|
|
329
|
+
hsv = { h: 0, s: 1, v: 1 };
|
|
330
|
+
originalValue = '#FF0000';
|
|
331
|
+
format = 'hex';
|
|
332
|
+
formatAnimating = 'none';
|
|
333
|
+
#isDraggingSaturation = false;
|
|
334
|
+
#isDraggingHue = false;
|
|
335
|
+
#activeSaturationPointer = null;
|
|
336
|
+
#activeHuePointer = null;
|
|
337
|
+
isInternalUpdate = false;
|
|
338
|
+
@Query('[part="saturation"]')
|
|
339
|
+
accessor saturationArea;
|
|
340
|
+
@Query('[part="hue"]')
|
|
341
|
+
accessor hueArea;
|
|
342
|
+
@Query('[part="hex-input"]')
|
|
343
|
+
accessor hexInput;
|
|
344
|
+
@Prop({
|
|
345
|
+
reflect: true,
|
|
346
|
+
defaultValue: '#FF0000',
|
|
347
|
+
onChange(value) {
|
|
348
|
+
if (!this.isInternalUpdate) {
|
|
349
|
+
this.updateFromHex(value ?? '#FF0000');
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
})
|
|
353
|
+
accessor value;
|
|
354
|
+
connectedCallback() {
|
|
355
|
+
this.originalValue = this.value;
|
|
356
|
+
this.updateFromHex(this.value);
|
|
357
|
+
}
|
|
358
|
+
updateFromHex(hex) {
|
|
359
|
+
if (!isValidHex(hex)) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const hsv = hexToHsv(hex);
|
|
363
|
+
if (hsv) {
|
|
364
|
+
this.hsv = hsv;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
#updateValue(event) {
|
|
368
|
+
const newValue = hsvToHex(this.hsv.h, this.hsv.s, this.hsv.v);
|
|
369
|
+
if (this.value !== newValue) {
|
|
370
|
+
this.isInternalUpdate = true;
|
|
371
|
+
this.value = newValue;
|
|
372
|
+
this.isInternalUpdate = false;
|
|
373
|
+
if (this.hexInput && document.activeElement !== this.hexInput) {
|
|
374
|
+
this.hexInput.value = newValue;
|
|
375
|
+
}
|
|
376
|
+
if (event) {
|
|
377
|
+
dispatchControlEvent(this, 'input', { value: this.value, event });
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
handleSaturationPointerDown = (event) => {
|
|
382
|
+
if (!this.saturationArea) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
if (event.button !== undefined && event.button !== 0) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
event.preventDefault();
|
|
389
|
+
event.stopPropagation();
|
|
390
|
+
this.#isDraggingSaturation = true;
|
|
391
|
+
this.#activeSaturationPointer = event.pointerId;
|
|
392
|
+
this.saturationArea.setPointerCapture(event.pointerId);
|
|
393
|
+
this.updateSaturationValue(event);
|
|
394
|
+
};
|
|
395
|
+
handleSaturationPointerMove = (event) => {
|
|
396
|
+
if (!this.#isDraggingSaturation || event.pointerId !== this.#activeSaturationPointer) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
event.preventDefault();
|
|
400
|
+
this.updateSaturationValue(event);
|
|
401
|
+
};
|
|
402
|
+
handleSaturationPointerUp = (event) => {
|
|
403
|
+
if (!this.#isDraggingSaturation || event.pointerId !== this.#activeSaturationPointer) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
this.#isDraggingSaturation = false;
|
|
407
|
+
this.#activeSaturationPointer = null;
|
|
408
|
+
if (this.saturationArea?.hasPointerCapture(event.pointerId)) {
|
|
409
|
+
this.saturationArea.releasePointerCapture(event.pointerId);
|
|
410
|
+
}
|
|
411
|
+
dispatchControlEvent(this, 'change', { value: this.value, event });
|
|
412
|
+
};
|
|
413
|
+
updateSaturationValue(event) {
|
|
414
|
+
if (!this.saturationArea) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const rect = this.saturationArea.getBoundingClientRect();
|
|
418
|
+
const x = Math.max(0, Math.min(rect.width, event.clientX - rect.left));
|
|
419
|
+
const y = Math.max(0, Math.min(rect.height, event.clientY - rect.top));
|
|
420
|
+
this.hsv.s = x / rect.width;
|
|
421
|
+
this.hsv.v = 1 - y / rect.height;
|
|
422
|
+
this.#updateValue(event);
|
|
423
|
+
this.requestRender();
|
|
424
|
+
}
|
|
425
|
+
handleHuePointerDown = (event) => {
|
|
426
|
+
if (!this.hueArea) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (event.button !== undefined && event.button !== 0) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
event.preventDefault();
|
|
433
|
+
event.stopPropagation();
|
|
434
|
+
this.#isDraggingHue = true;
|
|
435
|
+
this.#activeHuePointer = event.pointerId;
|
|
436
|
+
this.hueArea.setPointerCapture(event.pointerId);
|
|
437
|
+
this.updateHue(event);
|
|
438
|
+
};
|
|
439
|
+
handleHuePointerMove = (event) => {
|
|
440
|
+
if (!this.#isDraggingHue || event.pointerId !== this.#activeHuePointer) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
event.preventDefault();
|
|
444
|
+
this.updateHue(event);
|
|
445
|
+
};
|
|
446
|
+
handleHuePointerUp = (event) => {
|
|
447
|
+
if (!this.#isDraggingHue || event.pointerId !== this.#activeHuePointer) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
this.#isDraggingHue = false;
|
|
451
|
+
this.#activeHuePointer = null;
|
|
452
|
+
if (this.hueArea?.hasPointerCapture(event.pointerId)) {
|
|
453
|
+
this.hueArea.releasePointerCapture(event.pointerId);
|
|
454
|
+
}
|
|
455
|
+
dispatchControlEvent(this, 'change', { value: this.value, event });
|
|
456
|
+
};
|
|
457
|
+
updateHue(event) {
|
|
458
|
+
if (!this.hueArea) {
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
const rect = this.hueArea.getBoundingClientRect();
|
|
462
|
+
const x = Math.max(0, Math.min(rect.width, event.clientX - rect.left));
|
|
463
|
+
this.hsv.h = (x / rect.width) * 360;
|
|
464
|
+
this.#updateValue(event);
|
|
465
|
+
this.requestRender();
|
|
466
|
+
}
|
|
467
|
+
handleHexInputChange = (event) => {
|
|
468
|
+
const input = event.target;
|
|
469
|
+
const newValue = input.value;
|
|
470
|
+
if (isValidHex(newValue)) {
|
|
471
|
+
this.updateFromHex(newValue);
|
|
472
|
+
this.#updateValue(event);
|
|
473
|
+
this.requestRender();
|
|
474
|
+
dispatchControlEvent(this, 'change', { value: this.value, event });
|
|
475
|
+
}
|
|
476
|
+
else if (this.hexInput) {
|
|
477
|
+
this.hexInput.value = this.value;
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
handleComponentChange = (index, value) => {
|
|
481
|
+
this.hsv = updateHsvFromComponents(this.hsv, this.format, index, value);
|
|
482
|
+
this.#updateValue(null);
|
|
483
|
+
this.requestRender();
|
|
484
|
+
};
|
|
485
|
+
handleFormatChange = (format) => {
|
|
486
|
+
this.format = format;
|
|
487
|
+
this.requestRender();
|
|
488
|
+
};
|
|
489
|
+
handleFormatCycle = () => {
|
|
490
|
+
// Start exit animation
|
|
491
|
+
this.formatAnimating = 'out';
|
|
492
|
+
this.requestRender();
|
|
493
|
+
// After exit animation, change format and start enter animation
|
|
494
|
+
setTimeout(() => {
|
|
495
|
+
const currentIndex = COLOR_FORMATS.indexOf(this.format);
|
|
496
|
+
const nextIndex = (currentIndex + 1) % COLOR_FORMATS.length;
|
|
497
|
+
this.format = COLOR_FORMATS[nextIndex];
|
|
498
|
+
this.formatAnimating = 'in';
|
|
499
|
+
this.requestRender();
|
|
500
|
+
// Clear animation state after enter animation
|
|
501
|
+
setTimeout(() => {
|
|
502
|
+
this.formatAnimating = 'none';
|
|
503
|
+
this.requestRender();
|
|
504
|
+
}, 150);
|
|
505
|
+
}, 150);
|
|
506
|
+
};
|
|
507
|
+
handleCancelButtonClick = (event) => {
|
|
508
|
+
this.updateFromHex(this.originalValue);
|
|
509
|
+
this.isInternalUpdate = true;
|
|
510
|
+
this.value = this.originalValue;
|
|
511
|
+
this.isInternalUpdate = false;
|
|
512
|
+
this.requestRender();
|
|
513
|
+
dispatchControlEvent(this, 'cancel', { value: this.originalValue, event });
|
|
514
|
+
};
|
|
515
|
+
handleApplyButtonClick = (event) => {
|
|
516
|
+
this.originalValue = this.value;
|
|
517
|
+
dispatchControlEvent(this, 'apply', { value: this.value, event });
|
|
518
|
+
};
|
|
519
|
+
handleEyeDropperClick = async (event) => {
|
|
520
|
+
if (!('EyeDropper' in window)) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
try {
|
|
524
|
+
const eyeDropper = new window.EyeDropper();
|
|
525
|
+
const result = await eyeDropper.open();
|
|
526
|
+
if (result.sRGBHex) {
|
|
527
|
+
this.updateFromHex(result.sRGBHex);
|
|
528
|
+
this.#updateValue(event);
|
|
529
|
+
this.requestRender();
|
|
530
|
+
dispatchControlEvent(this, 'change', { value: this.value, event });
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
catch {
|
|
534
|
+
// User cancelled or API error - silently ignore
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
export default {
|
|
539
|
+
ColorPicker
|
|
540
|
+
};
|