@orangelogic/design-system 3.18.0 → 3.19.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/library/chunks/{asset-link-format.Bk1qHIQA.js → asset-link-format.ttcRQgDc.js} +5 -5
- package/library/chunks/{button.DCyoZrRj.js → button.D1YIxtv-.js} +1 -1
- package/library/chunks/{color-swatch-group.BtVbKp-v.js → color-swatch-group.Bumfw-G2.js} +4788 -4335
- package/library/chunks/{color-swatch.DxxOpJXT.js → color-swatch.DdsUysbF.js} +1 -1
- package/library/chunks/{confirm-popover.-_1n24v-.js → confirm-popover.CJXyEa5A.js} +3 -3
- package/library/chunks/{dialog.Dl9aHLD4.js → dialog.BbQ4Du0M.js} +2 -2
- package/library/chunks/{document-viewer.B-jtpLuD.js → document-viewer.C9tM2Gc7.js} +6 -6
- package/library/chunks/{dot-pagination.BNoG-qx7.js → dot-pagination.CJRAtM51.js} +1 -1
- package/library/chunks/{folder-select.DWaC4EWa.js → folder-select.BAPsI-gg.js} +4 -4
- package/library/chunks/gradient.CIzq8fOU.js +176 -0
- package/library/chunks/{header.v8maWlzT.js → header.BioJzPlg.js} +1 -1
- package/library/chunks/{i18n.CNnI4-0K.js → i18n.rtxrs1c1.js} +11 -3
- package/library/chunks/{icon-button.5-oAlIkv.js → icon-button.CbUddcgI.js} +1 -1
- package/library/chunks/{iframe.DOwG9Q7o.js → iframe.y7iCAVZP.js} +1 -1
- package/library/chunks/{image.BSh7WAGF.js → image.A2hE1WoV.js} +1 -1
- package/library/chunks/{index.Byin4Jfx.js → index.Coy2OPB4.js} +13 -13
- package/library/chunks/{input.Csf-S2nB.js → input.D1FFprPl.js} +1 -1
- package/library/chunks/{markdown.b03AOvFT.js → markdown.Dd_GFJK8.js} +2 -2
- package/library/chunks/{menu-item.HtTWOcq4.js → menu-item.0TbnDEDp.js} +1 -1
- package/library/chunks/{option.DgxoCq1j.js → option.CyorNG0S.js} +17 -17
- package/library/chunks/{pagination.C9NblxKt.js → pagination.D0BeaEIi.js} +5 -5
- package/library/chunks/{tab-group.B6Aej-jM.js → tab-group.C98CWzEH.js} +4 -4
- package/library/chunks/{tree.pId63hLe.js → tree.B7IKBX3n.js} +1 -1
- package/library/chunks/{types.Fkwo_sYp.js → types.DVZ_cbKn.js} +49 -48
- package/library/components/alert.js +2 -2
- package/library/components/asset-link-format.js +3 -3
- package/library/components/atoms.js +15 -15
- package/library/components/audio.js +2 -2
- package/library/components/border-input-group.js +2 -2
- package/library/components/breadcrumb.js +1 -1
- package/library/components/button.js +2 -2
- package/library/components/color-picker.js +971 -337
- package/library/components/color-swatch-group.js +3 -3
- package/library/components/color-swatch.js +2 -2
- package/library/components/confirm-popover.js +4 -4
- package/library/components/copy-button.js +1 -1
- package/library/components/corner-position-input-group.js +3 -3
- package/library/components/date-calendar.js +1 -1
- package/library/components/details.js +1 -1
- package/library/components/dialog.js +3 -3
- package/library/components/document-viewer.js +3 -3
- package/library/components/dot-pagination.js +2 -2
- package/library/components/drawer.js +2 -2
- package/library/components/dropdown.js +2 -2
- package/library/components/dynamic-select.js +4 -4
- package/library/components/e-chart.js +1 -1
- package/library/components/element-clamp.js +2 -2
- package/library/components/file-on-demand.js +9 -9
- package/library/components/folder-select.js +4 -4
- package/library/components/format-bytes.js +1 -1
- package/library/components/format-date.js +1 -1
- package/library/components/format-number.js +1 -1
- package/library/components/format-time.js +1 -1
- package/library/components/header.js +2 -2
- package/library/components/icon-button.js +2 -2
- package/library/components/iframe.js +2 -2
- package/library/components/image-comparer.js +1 -1
- package/library/components/image.js +2 -2
- package/library/components/input.js +2 -2
- package/library/components/line-clamp.js +1 -1
- package/library/components/markdown.js +3 -3
- package/library/components/masonry.js +2 -2
- package/library/components/menu-item.js +2 -2
- package/library/components/menu.js +2 -2
- package/library/components/molecules.js +3 -3
- package/library/components/option.js +2 -2
- package/library/components/organisms.js +2 -2
- package/library/components/padding-input-group.js +1 -1
- package/library/components/pagination.js +6 -6
- package/library/components/popup.js +1 -1
- package/library/components/position-picker.js +1 -1
- package/library/components/progress-bar.js +1 -1
- package/library/components/progress-ring.js +1 -1
- package/library/components/range.js +1 -1
- package/library/components/rating.js +1 -1
- package/library/components/relative-time.js +1 -1
- package/library/components/select.js +2 -2
- package/library/components/shadow-input-group.js +1 -1
- package/library/components/share-option-list.js +1 -1
- package/library/components/sidebar.js +1 -1
- package/library/components/size-input-group.js +3 -3
- package/library/components/spinner.js +1 -1
- package/library/components/split-panel.js +1 -1
- package/library/components/tab-group.js +5 -5
- package/library/components/tab.js +2 -2
- package/library/components/tag.js +2 -2
- package/library/components/tooltip.js +1 -1
- package/library/components/tree-item.js +2 -2
- package/library/components/tree.js +2 -2
- package/library/components/typeface.js +2 -2
- package/library/components/types.js +171 -161
- package/library/components/video.js +2 -2
- package/library/package.json +1 -1
- package/library/packages/atoms/src/components/color-picker/color-picker.d.ts +160 -2
- package/library/packages/atoms/src/components/color-picker/components/gradient-slider/gradient-slider.d.ts +80 -0
- package/library/packages/atoms/src/components/color-picker/components/gradient-slider/gradient-slider.styles.d.ts +2 -0
- package/library/packages/atoms/src/components/color-picker/components/gradient-stop-list/gradient-stop-list.d.ts +85 -0
- package/library/packages/atoms/src/components/color-picker/components/gradient-stop-list/gradient-stop-list.styles.d.ts +2 -0
- package/library/packages/atoms/src/components/input/input.d.ts +1 -1
- package/library/packages/atoms/src/components/option/option.d.ts +1 -1
- package/library/packages/events/src/cx-gradient-change.d.ts +10 -0
- package/library/packages/events/src/cx-gradient-stop-add.d.ts +9 -0
- package/library/packages/events/src/cx-gradient-stop-change.d.ts +10 -0
- package/library/packages/events/src/cx-gradient-stop-remove.d.ts +8 -0
- package/library/packages/events/src/cx-gradient-stop-select.d.ts +8 -0
- package/library/packages/events/src/cx-keydown.d.ts +4 -1
- package/library/packages/events/src/events.d.ts +5 -0
- package/library/packages/molecules/src/multi-select/components/board/board.d.ts +58 -2
- package/library/packages/molecules/src/multi-select/components/board-list-item/board-list-item.d.ts +14 -0
- package/library/packages/molecules/src/multi-select/controllers/filter-controller.d.ts +68 -0
- package/library/packages/molecules/src/multi-select/multi-select.d.ts +211 -0
- package/library/packages/molecules/src/multi-select/utils/base.d.ts +44 -0
- package/library/packages/molecules/src/multi-select/utils/reconcile.d.ts +57 -0
- package/library/packages/types/src/board.d.ts +25 -0
- package/library/packages/types/src/color-picker.d.ts +35 -2
- package/library/packages/utils/src/custom-element/i18n.d.ts +8 -0
- package/library/packages/utils/src/gradient/gradient.d.ts +65 -0
- package/library/packages/utils/src/gradient/index.d.ts +1 -0
- package/library/packages/utils/src/index.d.ts +1 -0
- package/library/react-web-component.d.ts +494 -470
- package/library/utils.js +143 -133
- package/package.json +1 -1
- package/library/packages/molecules/src/multi-select/multi-select.utils.d.ts +0 -3
|
@@ -1,66 +1,406 @@
|
|
|
1
|
-
import { n
|
|
2
|
-
import { c as
|
|
3
|
-
import { c as
|
|
4
|
-
import {
|
|
5
|
-
import { d as
|
|
6
|
-
import { d as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { n, C as T } from "../chunks/lib-cortex-element.CVMmyPMC.js";
|
|
2
|
+
import { c as A } from "../chunks/component.styles.CAS3c9pM.js";
|
|
3
|
+
import { M as j, s as D, G as $, C as v, a as b, p as Z, b as tt, c as F, i as et } from "../chunks/gradient.CIzq8fOU.js";
|
|
4
|
+
import { c as O } from "../chunks/custom-element.L4WJXn1j.js";
|
|
5
|
+
import { d as q } from "../chunks/debounce.DaHuiSGU.js";
|
|
6
|
+
import { d as it } from "../chunks/default-value.COZopaet.js";
|
|
7
|
+
import { d as G } from "../chunks/drag.DenOh3AE.js";
|
|
8
|
+
import { F as rt } from "../chunks/form.DN2v7-DH.js";
|
|
9
|
+
import { L as N } from "../chunks/i18n.rtxrs1c1.js";
|
|
10
|
+
import { c as d } from "../chunks/math.DuKzLacZ.js";
|
|
11
|
+
import { w as S } from "../chunks/watch.DJF5K-8U.js";
|
|
12
|
+
import { i as L, x as c } from "../chunks/lit-element.jLBm65_O.js";
|
|
12
13
|
import { r as g } from "../chunks/state.CSDxrqLd.js";
|
|
13
|
-
import { t as
|
|
14
|
-
import { e as
|
|
14
|
+
import { t as at } from "../chunks/event-options.CYHYGOd8.js";
|
|
15
|
+
import { e as k } from "../chunks/query.BBf1UFkC.js";
|
|
15
16
|
import { e as _ } from "../chunks/class-map.BiVq-cVR.js";
|
|
16
|
-
import { o as
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import { C as
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
import { o as I } from "../chunks/if-defined.BRoBj_Rp.js";
|
|
18
|
+
import { c as H } from "../chunks/repeat.CFjcER6_.js";
|
|
19
|
+
import { o as m } from "../chunks/style-map.llVFPd__.js";
|
|
20
|
+
import { n as u } from "../chunks/when.Dr1es41R.js";
|
|
21
|
+
import { C as U } from "../chunks/button.D1YIxtv-.js";
|
|
22
|
+
import ot from "./button-group.js";
|
|
23
|
+
import W from "./dropdown.js";
|
|
24
|
+
import { C as X } from "../chunks/icon.BLXWp6CU.js";
|
|
25
|
+
import { C as Y } from "../chunks/input.D1FFprPl.js";
|
|
26
|
+
import { C as st } from "../chunks/option.CyorNG0S.js";
|
|
27
|
+
import lt from "./select.js";
|
|
28
|
+
import nt from "./spinner.js";
|
|
29
|
+
import ct from "./tab.js";
|
|
30
|
+
import { C as pt } from "../chunks/tab-group.C98CWzEH.js";
|
|
31
|
+
import dt from "./tab-panel.js";
|
|
32
|
+
import ht from "./visually-hidden.js";
|
|
33
|
+
import { C as ut } from "../chunks/icon-button.CbUddcgI.js";
|
|
34
|
+
import { T as x } from "../chunks/index.C1chwzNp.js";
|
|
35
|
+
const gt = L`:host{--grid-width:280px;--grid-height:200px;--grid-handle-size:16px;--slider-height:15px;--slider-handle-size:17px;--swatch-size:25px;--format-button-width:52px;--eye-dropper-button-width:52px;--control-border-color:var(--cx-color-neutral-300);--control-button-color:var(--cx-color-neutral-0);--control-caret-color:var(--cx-color-neutral-800);display:inline-block}.color-picker{width:var(--grid-width);font-family:var(--cx-font-sans);font-size:var(--cx-font-size-medium);font-weight:var(--cx-font-weight-regular);color:var(--color);background-color:var(--cx-panel-background-color);border-radius:var(--cx-border-radius-small);-webkit-user-select:none;user-select:none}.color-picker--inline{border:var(--inline-border,solid var(--cx-panel-border-width) var(--cx-panel-border-color))}.color-picker--inline:focus-visible{outline:var(--cx-focus-ring);outline-offset:var(--cx-focus-ring-offset)}.color-picker__grid{height:var(--grid-height);border-top-left-radius:var(--cx-border-radius-small);border-top-right-radius:var(--cx-border-radius-small);cursor:crosshair;forced-color-adjust:none;background-image:linear-gradient(#0000 0%,#000 100%),linear-gradient(90deg,#fff 0%,#fff0 100%);position:relative}.color-picker__grid-handle{width:var(--grid-handle-size);height:var(--grid-handle-size);margin-top:calc(var(--grid-handle-size) / -2);margin-left:calc(var(--grid-handle-size) / -2);transition:var(--cx-transition-fast) scale;border:2px solid #fff;border-radius:50%;position:absolute;box-shadow:0 0 0 1px #00000040}.color-picker__grid-handle--dragging{cursor:none;scale:1.5}.color-picker__grid-handle:focus-visible{outline:var(--cx-focus-ring)}.color-picker__controls{padding:var(--cx-spacing-small);align-items:center;gap:var(--cx-spacing-small);display:flex}.color-picker__sliders{flex:auto}.color-picker__slider{height:var(--slider-height);border-radius:var(--cx-border-radius-pill);forced-color-adjust:none;position:relative;box-shadow:inset 0 0 0 1px #0003}.color-picker__slider:not(:last-of-type){margin-bottom:var(--cx-spacing-small)}.color-picker__slider-handle{top:calc(50% - var(--slider-handle-size) / 2);width:var(--slider-handle-size);height:var(--slider-handle-size);margin-left:calc(var(--slider-handle-size) / -2);background-color:#fff;border-radius:50%;position:absolute;box-shadow:0 0 0 1px #00000040}.color-picker__slider-handle:focus-visible{outline:var(--cx-focus-ring)}.color-picker__hue{background-image:linear-gradient(90deg,red 0%,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}.color-picker__alpha .color-picker__alpha-gradient{border-radius:inherit;width:100%;height:100%;position:absolute;top:0;left:0}.color-picker__preview{border-radius:var(--cx-border-radius-circle);cursor:pointer;forced-color-adjust:none;width:2rem;height:2rem;width:var(--cx-input-height-medium);height:var(--cx-input-height-medium);background:0 0;border:none;flex:none;justify-content:center;align-items:center;display:inline-flex;position:relative}.color-picker__preview--button,.color-picker__preview--button::part(base){border-radius:var(--cx-border-radius-small)}.color-picker__preview:focus-visible{outline:var(--cx-focus-ring);outline-offset:var(--cx-focus-ring-offset)}.color-picker__preview-color{border:1px solid #00000020;width:100%;height:100%;position:absolute;top:0;left:0}.color-picker__preview-color--copied{animation:.75s pulse}.color-picker__preview.color-picker__preview--button{outline:solid 1px var(--control-border-color)}.color-picker__preview--small.color-picker__preview--button{width:var(--cx-toggle-size-small);height:var(--cx-toggle-size-small)}.color-picker__preview--medium.color-picker__preview--button{width:var(--cx-toggle-size-medium);height:var(--cx-toggle-size-medium)}.color-picker__preview--large.color-picker__preview--button{width:var(--cx-toggle-size-large);height:var(--cx-toggle-size-large)}.color-picker__preview:before{content:"";border-radius:inherit;background-color:var(--preview-color,currentColor);width:100%;height:100%;position:absolute;top:0;left:0}.color-picker__preview--empty:before{background-color:#0000}.color-picker__preview__transparent-bg{background-image:linear-gradient(45deg, var(--cx-color-neutral-300) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--cx-color-neutral-300) 75%), linear-gradient(45deg, transparent 75%, var(--cx-color-neutral-300) 75%), linear-gradient(45deg, var(--cx-color-neutral-300) 25%, transparent 25%);background-position:0 0,0 0,-5px -5px,5px 5px;background-size:10px 10px}@keyframes pulse{0%{box-shadow:0 0 0 0 var(--cx-color-primary-500)}70%{box-shadow:0 0 0 .5rem #0000}to{box-shadow:0 0 #0000}}.color-picker__preview__container{align-items:center;gap:var(--cx-spacing-2x-small);display:flex}.color-picker__user-input__container{padding:0 var(--cx-spacing-small) var(--cx-spacing-small) var(--cx-spacing-small);display:flex}.color-picker__input_color{flex:auto;min-width:0}.color-picker__input_opacity{margin-left:var(--cx-spacing-2x-small);width:54px}.color-picker__input_opacity::part(input){padding-left:var(--cx-spacing-x-small);padding-right:var(--cx-spacing-x-small)}.color-picker__user-input__container cx-button-group{margin-left:var(--cx-spacing-2x-small)}.color-picker__user-input__container cx-button{font-size:var(--cx-font-size-medium)}.color-picker__user-input__container cx-button[part=format-button]{min-width:var(--format-button-width);max-width:var(--format-button-width)}.color-picker__user-input__container cx-button[part=eye-dropper-button]{min-width:var(--eye-dropper-button-width);max-width:var(--eye-dropper-button-width)}.color-picker__swatches{grid-gap:.5rem;border-top:solid 1px var(--cx-color-neutral-200);padding:var(--cx-spacing-small);forced-color-adjust:none;grid-template-columns:repeat(8,1fr);justify-items:center;display:grid}.color-picker__customSwatches{grid-gap:.5rem;padding:0 var(--cx-spacing-small) var(--cx-spacing-small) var(--cx-spacing-small);forced-color-adjust:none;grid-template-columns:repeat(8,1fr);justify-items:center;display:grid}.color-picker__customSwatches-label{--cx-button-text-transform:none;padding:var(--cx-spacing-small);justify-content:space-between;align-items:center;width:100%;display:inline-flex}.color-picker__spinner{text-align:center;margin:var(--cx-spacing-small) 0}.color-picker__swatch{width:var(--swatch-size);height:var(--swatch-size);border-radius:var(--cx-border-radius-small);position:relative}.color-picker__swatch .color-picker__swatch-color{border-radius:inherit;cursor:pointer;border:1px solid #00000020;width:100%;height:100%;position:absolute;top:0;left:0}.color-picker__swatch:focus-visible{outline:var(--cx-focus-ring);outline-offset:var(--cx-focus-ring-offset)}.color-picker--disabled{opacity:.5;cursor:default}.color-picker--disabled .color-picker__grid,.color-picker--disabled .color-picker__grid-handle,.color-picker--disabled .color-picker__slider,.color-picker--disabled .color-picker__slider-handle,.color-picker--disabled .color-picker__preview,.color-picker--disabled .color-picker__swatch,.color-picker--disabled .color-picker__swatch-color{pointer-events:none}.color-dropdown::part(panel){background-color:var(--cx-panel-background-color);border:solid var(--cx-panel-border-width) var(--cx-panel-border-color);border-radius:var(--cx-border-radius-small);max-height:none;overflow:visible}.color-dropdown__trigger::part(base){background-color:var(--control-button-color);border-color:var(--control-border-color);border-radius:var(--cx-border-radius-medium);padding-inline-start:var(--cx-spacing-2x-small);padding-inline-end:var(--cx-spacing-2x-small)}.color-dropdown__trigger::part(label){padding-inline-start:var(--cx-spacing-2x-small);padding-inline-end:var(--cx-spacing-2x-small)}.color-dropdown__trigger{cursor:pointer;forced-color-adjust:none;background-color:#0000;border:none;display:inline-block;position:relative}.color-dropdown__trigger:focus-visible{outline:none}.color-dropdown__trigger.color-dropdown__trigger--disabled{opacity:.5;cursor:default}.color-dropdown__trigger-icon{color:var(--control-caret-color);font-size:var(--cx-font-size-large);justify-content:flex-end;align-items:center;width:100%;height:100%;display:flex}cx-tooltip{display:inline-block}.color-picker__tabs{--tab-group-top-gap:0;--tab-panel-padding:0}.color-picker__gradient-panel{gap:var(--cx-spacing-small);padding:var(--cx-spacing-small);flex-direction:column;display:flex}.color-picker__gradient-options{gap:var(--cx-spacing-2x-small);align-items:start;display:flex}.color-picker__gradient-type-select,.color-picker__gradient-angle{flex:1 1 0;min-width:0}`, mt = L`:host{--gradient-track-height:28px;--gradient-marker-size:20px;--gradient-marker-tail:6px;display:block}.gradient-slider{height:calc(var(--gradient-track-height) + var(--gradient-marker-size) + var(--gradient-marker-tail));margin:0 calc(var(--gradient-marker-size) / 2);forced-color-adjust:none;position:relative}.gradient-slider__track,.gradient-slider__checkerboard{height:var(--gradient-track-height);border-radius:var(--cx-border-radius-medium);position:absolute;bottom:0;left:0;right:0}.gradient-slider__track{box-shadow:inset 0 0 0 1px var(--cx-color-neutral-300)}.gradient-slider__checkerboard{pointer-events:none;background-image:linear-gradient(45deg, var(--cx-color-neutral-300) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--cx-color-neutral-300) 75%), linear-gradient(45deg, transparent 75%, var(--cx-color-neutral-300) 75%), linear-gradient(45deg, var(--cx-color-neutral-300) 25%, transparent 25%);background-position:0 0,0 0,-5px -5px,5px 5px;background-size:10px 10px}.gradient-slider__marker{width:var(--gradient-marker-size);height:calc(var(--gradient-marker-size) + var(--gradient-marker-tail));margin-left:calc(var(--gradient-marker-size) / -2);cursor:grab;background:0 0;border:none;padding:0;display:block;position:absolute;top:0}.gradient-slider__marker:before,.gradient-slider__marker:after{pointer-events:none}.gradient-slider__marker:before{width:var(--gradient-marker-size);height:var(--gradient-marker-size);content:"";border:3px solid var(--cx-color-neutral-0);border-radius:var(--cx-border-radius-small);box-shadow:0 0 0 1px var(--cx-color-neutral-300);box-sizing:border-box;background-color:currentColor;position:absolute;top:0;left:0}.gradient-slider__marker:after{top:calc(var(--gradient-marker-size) - var(--gradient-marker-tail) / 2);left:calc(50% - var(--gradient-marker-tail) / 2);width:var(--gradient-marker-tail);height:var(--gradient-marker-tail);content:"";background:var(--cx-color-neutral-0);border-right:1px solid var(--cx-color-neutral-300);border-bottom:1px solid var(--cx-color-neutral-300);position:absolute;transform:rotate(45deg)}.gradient-slider__marker--active:before{box-shadow:0 0 0 2px var(--cx-color-primary-600)}.gradient-slider__marker--active{z-index:1}.gradient-slider__marker--dragging{cursor:grabbing}.gradient-slider__marker:focus-visible{outline:none}.gradient-slider__marker:focus-visible:before{outline:var(--cx-focus-ring);outline-offset:var(--cx-focus-ring-offset)}:host([disabled]) .gradient-slider{opacity:.5}:host([disabled]) .gradient-slider__marker{cursor:not-allowed}`;
|
|
36
|
+
var ft = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, V = (t, e, i, r) => {
|
|
37
|
+
for (var a = r > 1 ? void 0 : r ? vt(e, i) : e, l = t.length - 1, p; l >= 0; l--)
|
|
38
|
+
(p = t[l]) && (a = (r ? p(e, i, a) : p(a)) || a);
|
|
39
|
+
return r && a && ft(e, i, a), a;
|
|
40
|
+
};
|
|
41
|
+
const bt = 1, xt = 10;
|
|
42
|
+
let y = class extends T {
|
|
43
|
+
constructor() {
|
|
44
|
+
super(...arguments), this.localize = new N(this), this.stops = [], this.activeStopId = "", this.disabled = !1, this.draggingStopId = "";
|
|
45
|
+
}
|
|
46
|
+
/** False once the gradient is down to the minimum number of stops. */
|
|
47
|
+
get canRemoveStop() {
|
|
48
|
+
return this.stops.length > j;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Selects a stop, making it the target of the picker's color controls.
|
|
52
|
+
* @param id - The stop to select.
|
|
53
|
+
*/
|
|
54
|
+
selectStop(t) {
|
|
55
|
+
this.disabled || t === this.activeStopId || this.emit("cx-gradient-stop-select", { detail: { id: t } });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Moves a stop to a new position and reports the resulting set of stops.
|
|
59
|
+
* @param id - The stop to move.
|
|
60
|
+
* @param position - The new position, clamped to 0-100.
|
|
61
|
+
* @param commit - Whether this is the final position rather than an intermediate drag frame.
|
|
62
|
+
*/
|
|
63
|
+
moveStop(t, e, i) {
|
|
64
|
+
const r = this.stops.map(
|
|
65
|
+
(a) => a.id === t ? { ...a, position: d(e, 0, 100) } : a
|
|
66
|
+
);
|
|
67
|
+
this.emit("cx-gradient-stop-change", { detail: { stops: r } }), i && this.emit("cx-gradient-change", { detail: { stops: r } });
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Removes a stop, refusing when doing so would leave fewer than the minimum.
|
|
71
|
+
* @param id - The stop to remove.
|
|
72
|
+
*/
|
|
73
|
+
removeStop(t) {
|
|
74
|
+
if (this.disabled || !this.canRemoveStop)
|
|
75
|
+
return;
|
|
76
|
+
const e = this.stops.filter((i) => i.id !== t);
|
|
77
|
+
this.emit("cx-gradient-stop-remove", { detail: { id: t } }), this.emit("cx-gradient-change", { detail: { stops: e } });
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Converts a pointer offset within the bar into a stop position.
|
|
81
|
+
* @param offsetX - The pointer's horizontal offset from the bar's left edge.
|
|
82
|
+
* @param trackWidth - The bar's rendered width.
|
|
83
|
+
* @returns The equivalent position, 0-100.
|
|
84
|
+
*/
|
|
85
|
+
getPositionFromOffset(t, e) {
|
|
86
|
+
return e === 0 ? 0 : d(t / e * 100, 0, 100);
|
|
87
|
+
}
|
|
88
|
+
handleMarkerPointerDown(t) {
|
|
89
|
+
if (this.disabled)
|
|
90
|
+
return;
|
|
91
|
+
t.preventDefault();
|
|
92
|
+
const e = t.currentTarget, i = e.dataset.stopId ?? "", r = this.shadowRoot.querySelector(
|
|
93
|
+
'[part~="track"]'
|
|
94
|
+
), a = r.getBoundingClientRect(), { width: l } = a;
|
|
95
|
+
let f = this.stops.find((P) => P.id === i)?.position ?? 0;
|
|
96
|
+
const h = t.clientX - (a.left + f / 100 * l);
|
|
97
|
+
e.focus(), this.selectStop(i), this.draggingStopId = i, e.hasPointerCapture(t.pointerId) && e.releasePointerCapture(t.pointerId), G(r, {
|
|
98
|
+
onMove: (P) => {
|
|
99
|
+
f = this.getPositionFromOffset(P - h, l), this.moveStop(i, f, !1);
|
|
100
|
+
},
|
|
101
|
+
onStop: () => {
|
|
102
|
+
this.draggingStopId = "", this.moveStop(i, f, !0);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
handleMarkerKeyDown(t) {
|
|
107
|
+
if (this.disabled)
|
|
108
|
+
return;
|
|
109
|
+
const i = t.currentTarget.dataset.stopId ?? "", r = this.stops.find((l) => l.id === i);
|
|
110
|
+
if (!r)
|
|
111
|
+
return;
|
|
112
|
+
const a = t.shiftKey ? xt : bt;
|
|
113
|
+
if (t.key === "ArrowLeft" || t.key === "ArrowDown") {
|
|
114
|
+
t.preventDefault(), this.selectStop(i), this.moveStop(i, r.position - a, !0);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (t.key === "ArrowRight" || t.key === "ArrowUp") {
|
|
118
|
+
t.preventDefault(), this.selectStop(i), this.moveStop(i, r.position + a, !0);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (t.key === "Home") {
|
|
122
|
+
t.preventDefault(), this.selectStop(i), this.moveStop(i, 0, !0);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (t.key === "End") {
|
|
126
|
+
t.preventDefault(), this.selectStop(i), this.moveStop(i, 100, !0);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
(t.key === "Delete" || t.key === "Backspace") && (t.preventDefault(), this.removeStop(i));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Builds the CSS gradient shown on the bar. The preview is always left-to-right regardless
|
|
133
|
+
* of the gradient's real type, because the bar represents the gradient line itself rather
|
|
134
|
+
* than its rendered orientation.
|
|
135
|
+
* @param sortedStops - The stops in ascending position order.
|
|
136
|
+
* @returns A CSS gradient string.
|
|
137
|
+
*/
|
|
138
|
+
getTrackBackground(t) {
|
|
139
|
+
return t.length === 0 ? "transparent" : `linear-gradient(to right, ${t.map((i) => `${i.color} ${i.position}%`).join(", ")})`;
|
|
140
|
+
}
|
|
141
|
+
render() {
|
|
142
|
+
const t = D(this.stops);
|
|
143
|
+
return c`<div part="base" class="gradient-slider"><div class="gradient-slider__checkerboard" aria-hidden="true"></div><div part="track" class="gradient-slider__track" style=${m({
|
|
144
|
+
backgroundImage: this.getTrackBackground(t)
|
|
145
|
+
})}></div>${H(
|
|
146
|
+
t,
|
|
147
|
+
(e) => e.id,
|
|
148
|
+
(e, i) => c`<button part="marker" class=${_({
|
|
149
|
+
"gradient-slider__marker": !0,
|
|
150
|
+
"gradient-slider__marker--active": e.id === this.activeStopId,
|
|
151
|
+
"gradient-slider__marker--dragging": e.id === this.draggingStopId
|
|
152
|
+
})} type="button" data-stop-id=${e.id} style=${m({
|
|
153
|
+
color: e.color,
|
|
154
|
+
left: `${e.position}%`
|
|
155
|
+
})} role="slider" aria-label=${this.localize.term(
|
|
156
|
+
"gradientStopNumber",
|
|
157
|
+
i + 1
|
|
158
|
+
)} aria-valuemin="0" aria-valuemax="100" aria-valuenow=${Math.round(e.position)} aria-valuetext=${`${Math.round(e.position)}%, ${e.color}`} ?disabled=${this.disabled} @pointerdown=${this.handleMarkerPointerDown} @keydown=${this.handleMarkerKeyDown}></button>`
|
|
159
|
+
)}</div>`;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
y.styles = [A, mt];
|
|
163
|
+
V([
|
|
164
|
+
n({ type: Array })
|
|
165
|
+
], y.prototype, "stops", 2);
|
|
166
|
+
V([
|
|
167
|
+
n({ attribute: "active-stop-id", type: String })
|
|
168
|
+
], y.prototype, "activeStopId", 2);
|
|
169
|
+
V([
|
|
170
|
+
n({ reflect: !0, type: Boolean })
|
|
171
|
+
], y.prototype, "disabled", 2);
|
|
172
|
+
V([
|
|
173
|
+
g()
|
|
174
|
+
], y.prototype, "draggingStopId", 2);
|
|
175
|
+
y = V([
|
|
176
|
+
O("cx-gradient-slider")
|
|
177
|
+
], y);
|
|
178
|
+
const _t = L`:host{--stop-swatch-size:28px;--stop-list-max-height:auto;display:block}.stop-list{gap:var(--cx-spacing-2x-small);flex-direction:column;display:flex}.stop-list__rows{gap:var(--cx-spacing-2x-small);max-height:var(--stop-list-max-height);flex-direction:column;display:flex;overflow-y:auto}.stop-list__header{align-items:center;display:flex}.stop-list__add{display:block}.stop-list__add::part(base){width:100%}.stop-list__title{font-size:var(--cx-font-size-medium);font-weight:var(--cx-font-weight-semibold);color:var(--cx-color-neutral-900)}.stop-list__row{gap:var(--cx-spacing-2x-small);padding:var(--cx-spacing-2x-small);background:var(--cx-color-neutral-50);border-radius:var(--cx-border-radius-medium);cursor:pointer;border:1px solid #0000;grid-template-columns:1fr auto auto;align-items:center;display:grid}.stop-list__row--active{border-color:var(--cx-color-primary-600)}.stop-list__hex{min-width:0}.stop-list__numbers{gap:var(--cx-spacing-2x-small);grid-column:1/-1;display:flex}.stop-list__swatch{width:var(--stop-swatch-size);height:var(--stop-swatch-size);cursor:pointer;border:1px solid var(--cx-color-neutral-300);border-radius:var(--cx-border-radius-small);background:0 0;padding:0;display:block;position:relative;overflow:hidden}.stop-list__swatch--transparent-bg{background-image:linear-gradient(45deg, var(--cx-color-neutral-300) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--cx-color-neutral-300) 75%), linear-gradient(45deg, transparent 75%, var(--cx-color-neutral-300) 75%), linear-gradient(45deg, var(--cx-color-neutral-300) 25%, transparent 25%);background-position:0 0,0 0,-4px -4px,4px 4px;background-size:8px 8px}.stop-list__swatch-color{position:absolute;inset:0}.stop-list__swatch:focus-visible{outline:var(--cx-focus-ring);outline-offset:var(--cx-focus-ring-offset)}.stop-list__picker-dropdown{flex:none}.stop-list__opacity,.stop-list__position{flex:1 1 0;min-width:0}.stop-list__delete{flex:none}:host([disabled]) .stop-list__row,:host([disabled]) .stop-list__swatch{cursor:not-allowed}`;
|
|
179
|
+
var yt = Object.defineProperty, wt = Object.getOwnPropertyDescriptor, M = (t, e, i, r) => {
|
|
180
|
+
for (var a = r > 1 ? void 0 : r ? wt(e, i) : e, l = t.length - 1, p; l >= 0; l--)
|
|
181
|
+
(p = t[l]) && (a = (r ? p(e, i, a) : p(a)) || a);
|
|
182
|
+
return r && a && yt(e, i, a), a;
|
|
183
|
+
};
|
|
184
|
+
const kt = 100;
|
|
185
|
+
let w = class extends T {
|
|
186
|
+
constructor() {
|
|
187
|
+
super(...arguments), this.localize = new N(this), this.stops = [], this.activeStopId = "", this.disabled = !1;
|
|
188
|
+
}
|
|
189
|
+
/** False once the gradient is down to the minimum number of stops. */
|
|
190
|
+
get canRemoveStop() {
|
|
191
|
+
return this.stops.length > j;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Reads a row's stop id from the element that raised an event.
|
|
195
|
+
* @param event - The event whose `currentTarget` carries the id.
|
|
196
|
+
* @returns The stop id, or an empty string when the attribute is missing.
|
|
197
|
+
*/
|
|
198
|
+
getStopId(t) {
|
|
199
|
+
return t.currentTarget.dataset.stopId ?? "";
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Replaces one stop and reports the resulting set.
|
|
203
|
+
* @param id - The stop to change.
|
|
204
|
+
* @param changes - The fields to overwrite.
|
|
205
|
+
*/
|
|
206
|
+
commitStopChange(t, e) {
|
|
207
|
+
const i = this.stops.map(
|
|
208
|
+
(r) => r.id === t ? { ...r, ...e } : r
|
|
209
|
+
);
|
|
210
|
+
this.emit("cx-gradient-change", { detail: { stops: i } });
|
|
211
|
+
}
|
|
212
|
+
handleRowClick(t) {
|
|
213
|
+
const e = this.getStopId(t);
|
|
214
|
+
this.disabled || e === this.activeStopId || this.emit("cx-gradient-stop-select", { detail: { id: e } });
|
|
215
|
+
}
|
|
216
|
+
handleAddClick() {
|
|
217
|
+
if (this.disabled)
|
|
218
|
+
return;
|
|
219
|
+
const t = D(this.stops), e = t[t.length - 1], i = t[t.length - 2], r = i ? (i.position + e.position) / 2 : kt;
|
|
220
|
+
this.emit("cx-gradient-stop-add", {
|
|
221
|
+
detail: { color: e?.color ?? "#ffffff", position: r }
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
handleDropdownClick(t) {
|
|
225
|
+
t.target.closest('[slot="trigger"]') || t.stopPropagation();
|
|
226
|
+
}
|
|
227
|
+
handlePickerInput(t) {
|
|
228
|
+
t.stopPropagation();
|
|
229
|
+
const e = t.target, i = e.dataset.stopId ?? "";
|
|
230
|
+
if (!this.stops.find((l) => l.id === i) || !e.value)
|
|
231
|
+
return;
|
|
232
|
+
const a = new x(e.value);
|
|
233
|
+
a.isValid && this.commitStopChange(i, { color: a.toRgbString() });
|
|
234
|
+
}
|
|
235
|
+
handleDeleteClick(t) {
|
|
236
|
+
if (t.stopPropagation(), this.disabled || !this.canRemoveStop)
|
|
237
|
+
return;
|
|
238
|
+
const e = this.getStopId(t), i = this.stops.filter((r) => r.id !== e);
|
|
239
|
+
this.emit("cx-gradient-stop-remove", { detail: { id: e } }), this.emit("cx-gradient-change", { detail: { stops: i } });
|
|
240
|
+
}
|
|
241
|
+
handleHexChange(t) {
|
|
242
|
+
t.stopPropagation();
|
|
243
|
+
const e = this.getStopId(t), i = t.target, r = this.stops.find((p) => p.id === e);
|
|
244
|
+
if (!r)
|
|
245
|
+
return;
|
|
246
|
+
const a = new x(i.value);
|
|
247
|
+
if (!a.isValid) {
|
|
248
|
+
i.value = new x(r.color).toHexString();
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const l = new x(r.color).getAlpha();
|
|
252
|
+
this.commitStopChange(e, {
|
|
253
|
+
color: a.setAlpha(l).toRgbString()
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
handleOpacityChange(t) {
|
|
257
|
+
t.stopPropagation();
|
|
258
|
+
const e = this.getStopId(t), i = t.target, r = this.stops.find((l) => l.id === e);
|
|
259
|
+
if (!r)
|
|
260
|
+
return;
|
|
261
|
+
const a = Number.parseInt(i.value.replace(/\D/g, ""), 10);
|
|
262
|
+
if (Number.isNaN(a)) {
|
|
263
|
+
i.value = `${Math.round(new x(r.color).getAlpha() * 100)}%`;
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
this.commitStopChange(e, {
|
|
267
|
+
color: new x(r.color).setAlpha(d(a, 0, 100) / 100).toRgbString()
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
handlePositionChange(t) {
|
|
271
|
+
t.stopPropagation();
|
|
272
|
+
const e = this.getStopId(t), i = t.target, r = this.stops.find((l) => l.id === e);
|
|
273
|
+
if (!r)
|
|
274
|
+
return;
|
|
275
|
+
const a = Number.parseInt(i.value.replace(/\D/g, ""), 10);
|
|
276
|
+
if (Number.isNaN(a)) {
|
|
277
|
+
i.value = `${Math.round(r.position)}%`;
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
this.commitStopChange(e, { position: d(a, 0, 100) });
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Renders one stop's row of fields.
|
|
284
|
+
* @param stop - The stop this row edits.
|
|
285
|
+
* @param index - The stop's position in the sorted list, used for labelling.
|
|
286
|
+
*/
|
|
287
|
+
renderRow(t, e) {
|
|
288
|
+
const i = new x(t.color), r = this.localize.term("gradientStopNumber", e + 1);
|
|
289
|
+
return c`<div part="row" class=${_({
|
|
290
|
+
"stop-list__row": !0,
|
|
291
|
+
"stop-list__row--active": t.id === this.activeStopId
|
|
292
|
+
})} data-stop-id=${t.id} role="group" aria-label=${r} @click=${this.handleRowClick}><cx-input part="hex-input" class="stop-list__hex" type="text" size="small" label=${this.localize.term("hex")} data-stop-id=${t.id} value=${i.toHexString().toUpperCase()} autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" ?disabled=${this.disabled} @cx-change=${this.handleHexChange}></cx-input><cx-dropdown class="stop-list__picker-dropdown" hoist distance="4" placement="bottom-start" stay-open-on-select ?disabled=${this.disabled} @click=${this.handleDropdownClick}><button slot="trigger" part="swatch" class="stop-list__swatch stop-list__swatch--transparent-bg" type="button" data-stop-id=${t.id} aria-label=${this.localize.term("color")} ?disabled=${this.disabled} @click=${this.handleRowClick}><span class="stop-list__swatch-color" style=${m({ backgroundColor: t.color })}></span></button><cx-color-picker part="stop-color-picker" class="stop-list__picker" inline opacity data-stop-id=${t.id} value=${t.color} label=${r} @cx-input=${this.handlePickerInput} @cx-change=${this.handlePickerInput}></cx-color-picker></cx-dropdown><cx-icon-button part="delete-button" class="stop-list__delete" name="delete" label=${this.localize.term("removeGradientStop")} data-stop-id=${t.id} ?disabled=${this.disabled || !this.canRemoveStop} @click=${this.handleDeleteClick}></cx-icon-button><div class="stop-list__numbers"><cx-input part="opacity-input" class="stop-list__opacity" type="text" size="small" label=${this.localize.term("opacity")} data-stop-id=${t.id} .maskBlocks=${{
|
|
293
|
+
num: {
|
|
294
|
+
mask: Number,
|
|
295
|
+
max: 100,
|
|
296
|
+
min: 0,
|
|
297
|
+
scale: 0,
|
|
298
|
+
thousandsSeparator: ""
|
|
299
|
+
}
|
|
300
|
+
}} mask="num%" no-spin-buttons value=${`${Math.round(i.getAlpha() * 100)}%`} ?disabled=${this.disabled} @cx-change=${this.handleOpacityChange}></cx-input><cx-input part="position-input" class="stop-list__position" type="text" size="small" label=${this.localize.term("position")} data-stop-id=${t.id} .maskBlocks=${{
|
|
301
|
+
num: {
|
|
302
|
+
mask: Number,
|
|
303
|
+
max: 100,
|
|
304
|
+
min: 0,
|
|
305
|
+
scale: 0,
|
|
306
|
+
thousandsSeparator: ""
|
|
307
|
+
}
|
|
308
|
+
}} mask="num%" no-spin-buttons value=${`${Math.round(t.position)}%`} ?disabled=${this.disabled} @cx-change=${this.handlePositionChange}></cx-input></div></div>`;
|
|
309
|
+
}
|
|
310
|
+
render() {
|
|
311
|
+
const t = D(this.stops);
|
|
312
|
+
return c`<div part="base" class="stop-list"><div part="header" class="stop-list__header"><span class="stop-list__title">${this.localize.term("gradientStops")}</span></div><div class="stop-list__rows">${H(
|
|
313
|
+
t,
|
|
314
|
+
(e) => e.id,
|
|
315
|
+
(e, i) => this.renderRow(e, i)
|
|
316
|
+
)}</div><cx-button part="add-button" class="stop-list__add" size="small" ?disabled=${this.disabled} @click=${this.handleAddClick}><cx-icon slot="prefix" name="add"></cx-icon>${this.localize.term("addGradientStop")}</cx-button></div>`;
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
w.styles = [A, _t];
|
|
320
|
+
w.dependencies = {
|
|
321
|
+
"cx-button": U,
|
|
322
|
+
"cx-dropdown": W,
|
|
323
|
+
"cx-icon": X,
|
|
324
|
+
"cx-icon-button": ut,
|
|
325
|
+
"cx-input": Y
|
|
326
|
+
};
|
|
327
|
+
M([
|
|
328
|
+
n({ type: Array })
|
|
329
|
+
], w.prototype, "stops", 2);
|
|
330
|
+
M([
|
|
331
|
+
n({ attribute: "active-stop-id", type: String })
|
|
332
|
+
], w.prototype, "activeStopId", 2);
|
|
333
|
+
M([
|
|
334
|
+
n({ reflect: !0, type: Boolean })
|
|
335
|
+
], w.prototype, "disabled", 2);
|
|
336
|
+
w = M([
|
|
337
|
+
O("cx-gradient-stop-list")
|
|
338
|
+
], w);
|
|
339
|
+
var $t = Object.defineProperty, St = Object.getOwnPropertyDescriptor, J = (t) => {
|
|
30
340
|
throw TypeError(t);
|
|
31
|
-
},
|
|
32
|
-
for (var a =
|
|
33
|
-
(p = t[
|
|
34
|
-
return
|
|
35
|
-
},
|
|
36
|
-
const
|
|
37
|
-
let
|
|
341
|
+
}, s = (t, e, i, r) => {
|
|
342
|
+
for (var a = r > 1 ? void 0 : r ? St(e, i) : e, l = t.length - 1, p; l >= 0; l--)
|
|
343
|
+
(p = t[l]) && (a = (r ? p(e, i, a) : p(a)) || a);
|
|
344
|
+
return r && a && $t(e, i, a), a;
|
|
345
|
+
}, Q = (t, e, i) => e.has(t) || J("Cannot " + i), Ct = (t, e, i) => (Q(t, e, "read from private field"), e.get(t)), Vt = (t, e, i) => e.has(t) ? J("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), R = (t, e, i, r) => (Q(t, e, "write to private field"), e.set(t, i), i), C;
|
|
346
|
+
const B = "EyeDropper" in window, E = "solid", z = "gradient", K = 90;
|
|
347
|
+
let o = class extends T {
|
|
38
348
|
constructor() {
|
|
39
|
-
super(), this.formControlController = new
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
349
|
+
super(), this.formControlController = new rt(this), this.isSafeValue = !1, Vt(this, C, !1), this.localize = new N(this), this.hasFocus = !1, this.isDraggingGridHandle = !1, this.isEmpty = !1, this.inputColorValue = "", this.inputOpacityValue = "", this.hue = 0, this.saturation = 100, this.brightness = 100, this.alpha = 100, this.gradientValue = {
|
|
350
|
+
angle: K,
|
|
351
|
+
stops: [],
|
|
352
|
+
type: $.Linear
|
|
353
|
+
}, this.activeStopId = "", this.parsedSwatches = [], this.parsedCustomSwatches = [], this.value = "", this.defaultValue = "", this.label = "", this.variant = "default", this.format = v.Hex, this.formats = [
|
|
354
|
+
v.Hex,
|
|
355
|
+
v.Rgb,
|
|
356
|
+
v.Hsl
|
|
357
|
+
], this.emitFormat = void 0, this.inline = !1, this.gradient = !1, this.mode = b.Solid, this.gradientTypes = [$.Linear, $.Radial], this.size = "medium", this.noFormatToggle = !1, this.name = "", this.disabled = !1, this.hoist = !1, this.opacity = !1, this.uppercase = !1, this.clearable = !1, this.tooltip = "", this.swatches = "", this.customSwatches = "", this.loading = !1, this.creatable = !1, this.form = void 0, this.required = !1, this.emitValue = "", this.handleFocusIn = this.handleFocusIn.bind(this), this.handleFocusOut = this.handleFocusOut.bind(this), this.addEventListener("focusin", this.handleFocusIn), this.addEventListener("focusout", this.handleFocusOut);
|
|
44
358
|
}
|
|
45
|
-
/**
|
|
359
|
+
/**
|
|
360
|
+
* Gets the validity state object.
|
|
361
|
+
*
|
|
362
|
+
* The text input lives in the Solid tab's controls, so it is absent while the Gradient tab
|
|
363
|
+
* is showing. `FormControlController` still polls this, so fall back to the host's own
|
|
364
|
+
* validity rather than dereferencing a missing input.
|
|
365
|
+
*/
|
|
46
366
|
get validity() {
|
|
47
|
-
return this.input.
|
|
367
|
+
return this.input?.validity ?? this.formValidity;
|
|
48
368
|
}
|
|
49
369
|
/** Gets the validation message */
|
|
50
370
|
get validationMessage() {
|
|
51
|
-
return this.input
|
|
371
|
+
return this.input?.validationMessage ?? "";
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Validity for the states this component can judge without the text input: a required
|
|
375
|
+
* control needs a value.
|
|
376
|
+
*/
|
|
377
|
+
get formValidity() {
|
|
378
|
+
const t = this.required && !this.value;
|
|
379
|
+
return {
|
|
380
|
+
badInput: !1,
|
|
381
|
+
customError: !1,
|
|
382
|
+
patternMismatch: !1,
|
|
383
|
+
rangeOverflow: !1,
|
|
384
|
+
rangeUnderflow: !1,
|
|
385
|
+
stepMismatch: !1,
|
|
386
|
+
tooLong: !1,
|
|
387
|
+
tooShort: !1,
|
|
388
|
+
typeMismatch: !1,
|
|
389
|
+
valid: !t,
|
|
390
|
+
valueMissing: t
|
|
391
|
+
};
|
|
52
392
|
}
|
|
53
393
|
runFirstUpdated() {
|
|
54
|
-
this.input
|
|
394
|
+
this.input?.updateComplete.then(() => {
|
|
55
395
|
this.formControlController.updateValidity();
|
|
56
|
-
}), this.value && this.emitFormat !== this.format && this.syncValues();
|
|
396
|
+
}), this.value && this.emitFormat !== this.format && this.syncValues(), this.syncTabToMode();
|
|
57
397
|
}
|
|
58
398
|
handleCopy() {
|
|
59
|
-
this.input
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
);
|
|
63
|
-
});
|
|
399
|
+
this.input?.select(), document.execCommand("copy");
|
|
400
|
+
const t = this.previewButton;
|
|
401
|
+
t && (t.focus(), t.classList.add("color-picker__preview-color--copied"), t.addEventListener("animationend", () => {
|
|
402
|
+
t.classList.remove("color-picker__preview-color--copied");
|
|
403
|
+
}));
|
|
64
404
|
}
|
|
65
405
|
handleFocusIn() {
|
|
66
406
|
this.hasFocus = !0, this.emit("cx-focus");
|
|
@@ -70,10 +410,10 @@ let r = class extends D {
|
|
|
70
410
|
}
|
|
71
411
|
handleFormatToggle() {
|
|
72
412
|
const t = [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
413
|
+
v.Hex,
|
|
414
|
+
v.Rgb,
|
|
415
|
+
v.Hsl,
|
|
416
|
+
v.Hsv
|
|
77
417
|
].filter((i) => this.formats.includes(i)), e = (t.indexOf(this.format) + 1) % t.length;
|
|
78
418
|
this.format = t[e], this.setColor(this.value), this.emit("cx-change"), this.emit("cx-input");
|
|
79
419
|
}
|
|
@@ -82,12 +422,12 @@ let r = class extends D {
|
|
|
82
422
|
".color-picker__slider.color-picker__alpha"
|
|
83
423
|
), i = e.querySelector(
|
|
84
424
|
".color-picker__slider-handle"
|
|
85
|
-
), { width:
|
|
86
|
-
let a = this.value,
|
|
87
|
-
i.focus(), t.preventDefault(),
|
|
425
|
+
), { width: r } = e.getBoundingClientRect();
|
|
426
|
+
let a = this.value, l = this.value;
|
|
427
|
+
i.focus(), t.preventDefault(), G(e, {
|
|
88
428
|
initialEvent: t,
|
|
89
429
|
onMove: (p) => {
|
|
90
|
-
this.alpha =
|
|
430
|
+
this.alpha = d(p / r * 100, 0, 100), this.syncValues(), this.value !== l && (l = this.value, this.emit("cx-input"));
|
|
91
431
|
},
|
|
92
432
|
onStop: () => {
|
|
93
433
|
this.value !== a && (a = this.value, this.emit("cx-change"));
|
|
@@ -99,12 +439,12 @@ let r = class extends D {
|
|
|
99
439
|
".color-picker__slider.color-picker__hue"
|
|
100
440
|
), i = e.querySelector(
|
|
101
441
|
".color-picker__slider-handle"
|
|
102
|
-
), { width:
|
|
103
|
-
let a = this.value,
|
|
104
|
-
i.focus(), t.preventDefault(),
|
|
442
|
+
), { width: r } = e.getBoundingClientRect();
|
|
443
|
+
let a = this.value, l = this.value;
|
|
444
|
+
i.focus(), t.preventDefault(), G(e, {
|
|
105
445
|
initialEvent: t,
|
|
106
446
|
onMove: (p) => {
|
|
107
|
-
this.hue =
|
|
447
|
+
this.hue = d(p / r * 360, 0, 360), this.syncValues(), this.value !== l && (l = this.value, this.emit("cx-input"));
|
|
108
448
|
},
|
|
109
449
|
onStop: () => {
|
|
110
450
|
this.value !== a && (a = this.value, this.emit("cx-change"));
|
|
@@ -116,40 +456,40 @@ let r = class extends D {
|
|
|
116
456
|
".color-picker__grid"
|
|
117
457
|
), i = e.querySelector(
|
|
118
458
|
".color-picker__grid-handle"
|
|
119
|
-
), { height:
|
|
120
|
-
let
|
|
121
|
-
i.focus(), t.preventDefault(), this.isDraggingGridHandle = !0,
|
|
459
|
+
), { height: r, width: a } = e.getBoundingClientRect();
|
|
460
|
+
let l = this.value, p = this.value;
|
|
461
|
+
i.focus(), t.preventDefault(), this.isDraggingGridHandle = !0, G(e, {
|
|
122
462
|
initialEvent: t,
|
|
123
|
-
onMove: (
|
|
124
|
-
this.saturation =
|
|
463
|
+
onMove: (f, h) => {
|
|
464
|
+
this.saturation = d(f / a * 100, 0, 100), this.brightness = d(100 - h / r * 100, 0, 100), this.syncValues(), this.value !== p && (p = this.value, this.emit("cx-input"));
|
|
125
465
|
},
|
|
126
466
|
onStop: () => {
|
|
127
|
-
this.isDraggingGridHandle = !1, this.value !==
|
|
467
|
+
this.isDraggingGridHandle = !1, this.value !== l && (l = this.value, this.emit("cx-change"));
|
|
128
468
|
}
|
|
129
469
|
});
|
|
130
470
|
}
|
|
131
471
|
handleAlphaKeyDown(t) {
|
|
132
472
|
const e = t.shiftKey ? 10 : 1, i = this.value;
|
|
133
|
-
t.key === "ArrowLeft" && (t.preventDefault(), this.alpha =
|
|
473
|
+
t.key === "ArrowLeft" && (t.preventDefault(), this.alpha = d(this.alpha - e, 0, 100), this.syncValues()), t.key === "ArrowRight" && (t.preventDefault(), this.alpha = d(this.alpha + e, 0, 100), this.syncValues()), t.key === "Home" && (t.preventDefault(), this.alpha = 0, this.syncValues()), t.key === "End" && (t.preventDefault(), this.alpha = 100, this.syncValues()), this.value !== i && (this.emit("cx-change"), this.emit("cx-input"));
|
|
134
474
|
}
|
|
135
475
|
handleHueKeyDown(t) {
|
|
136
476
|
const e = t.shiftKey ? 10 : 1, i = this.value;
|
|
137
|
-
t.key === "ArrowLeft" && (t.preventDefault(), this.hue =
|
|
477
|
+
t.key === "ArrowLeft" && (t.preventDefault(), this.hue = d(this.hue - e, 0, 360), this.syncValues()), t.key === "ArrowRight" && (t.preventDefault(), this.hue = d(this.hue + e, 0, 360), this.syncValues()), t.key === "Home" && (t.preventDefault(), this.hue = 0, this.syncValues()), t.key === "End" && (t.preventDefault(), this.hue = 360, this.syncValues()), this.value !== i && (this.emit("cx-change"), this.emit("cx-input"));
|
|
138
478
|
}
|
|
139
479
|
handleGridKeyDown(t) {
|
|
140
480
|
const e = t.shiftKey ? 10 : 1, i = this.value;
|
|
141
|
-
t.key === "ArrowLeft" && (t.preventDefault(), this.saturation =
|
|
481
|
+
t.key === "ArrowLeft" && (t.preventDefault(), this.saturation = d(this.saturation - e, 0, 100), this.syncValues()), t.key === "ArrowRight" && (t.preventDefault(), this.saturation = d(this.saturation + e, 0, 100), this.syncValues()), t.key === "ArrowUp" && (t.preventDefault(), this.brightness = d(this.brightness + e, 0, 100), this.syncValues()), t.key === "ArrowDown" && (t.preventDefault(), this.brightness = d(this.brightness - e, 0, 100), this.syncValues()), this.value !== i && (this.emit("cx-change"), this.emit("cx-input"));
|
|
142
482
|
}
|
|
143
483
|
handleInputChange(t) {
|
|
144
|
-
const e = t.target, i = this.value,
|
|
145
|
-
|
|
484
|
+
const e = t.target, i = this.value, r = this.getFormatFromValue(e.value);
|
|
485
|
+
r && r !== this.format && (this.format = r), t.stopPropagation(), this.input.value ? (this.setColor(e.value), this.syncValues(), this.input.value = this.inputColorValue) : this.value = "", this.value !== i && (this.emit("cx-change"), this.emit("cx-input"));
|
|
146
486
|
}
|
|
147
487
|
handleInputInput(t) {
|
|
148
488
|
this.formControlController.updateValidity(), t.stopPropagation(), this.debouncedSetColor();
|
|
149
489
|
}
|
|
150
490
|
debouncedSetColor() {
|
|
151
491
|
const t = this.getFormatFromValue(this.input.value);
|
|
152
|
-
t && t !== this.format && (
|
|
492
|
+
t && t !== this.format && (R(this, C, !0), this.format = t), this.setColor(this.input.value, !1), this.inputOpacityValue = Math.round(this.alpha).toString();
|
|
153
493
|
}
|
|
154
494
|
handleInputKeyDown(t) {
|
|
155
495
|
if (t.key === "Enter") {
|
|
@@ -168,7 +508,7 @@ let r = class extends D {
|
|
|
168
508
|
handleOpacityInputChange(t) {
|
|
169
509
|
if (t.stopPropagation(), this.opacityInput.value) {
|
|
170
510
|
const e = parseInt(this.opacityInput.value);
|
|
171
|
-
isNaN(e) || (this.alpha =
|
|
511
|
+
isNaN(e) || (this.alpha = d(e, 0, 100), this.syncValues());
|
|
172
512
|
}
|
|
173
513
|
this.emit("cx-change"), this.emit("cx-input");
|
|
174
514
|
}
|
|
@@ -178,13 +518,13 @@ let r = class extends D {
|
|
|
178
518
|
setOpacity() {
|
|
179
519
|
if (this.opacityInput.value) {
|
|
180
520
|
const t = parseInt(this.opacityInput.value);
|
|
181
|
-
isNaN(t) || (this.alpha =
|
|
521
|
+
isNaN(t) || (this.alpha = d(t, 0, 100));
|
|
182
522
|
}
|
|
183
523
|
}
|
|
184
524
|
handleOpacityInputKeyDown(t) {
|
|
185
525
|
if (t.key === "Enter" && this.opacityInput.value) {
|
|
186
526
|
const e = parseInt(this.opacityInput.value);
|
|
187
|
-
isNaN(e) || (this.alpha =
|
|
527
|
+
isNaN(e) || (this.alpha = d(e, 0, 100), this.syncValues(), this.emit("cx-change"), this.emit("cx-input"), setTimeout(() => this.opacityInput.select()));
|
|
188
528
|
}
|
|
189
529
|
}
|
|
190
530
|
handleTouchMove(t) {
|
|
@@ -196,64 +536,64 @@ let r = class extends D {
|
|
|
196
536
|
parseColor(t) {
|
|
197
537
|
if (!t)
|
|
198
538
|
return null;
|
|
199
|
-
const e = new
|
|
539
|
+
const e = new x(t);
|
|
200
540
|
if (!e.isValid)
|
|
201
541
|
return null;
|
|
202
|
-
const i = e.toHsl(),
|
|
542
|
+
const i = e.toHsl(), r = {
|
|
203
543
|
a: i.a,
|
|
204
544
|
h: i.h,
|
|
205
545
|
l: i.l * 100,
|
|
206
546
|
s: i.s * 100
|
|
207
|
-
}, a = e.toRgb(),
|
|
208
|
-
a:
|
|
209
|
-
h:
|
|
210
|
-
s:
|
|
211
|
-
v:
|
|
547
|
+
}, a = e.toRgb(), l = e.toHexString(), p = e.toHex8String(), f = e.toHsv(), h = {
|
|
548
|
+
a: f.a,
|
|
549
|
+
h: f.h,
|
|
550
|
+
s: f.s * 100,
|
|
551
|
+
v: f.v * 100
|
|
212
552
|
};
|
|
213
553
|
return {
|
|
214
|
-
hex: this.setLetterCase(
|
|
554
|
+
hex: this.setLetterCase(l),
|
|
215
555
|
hexa: this.setLetterCase(p),
|
|
216
556
|
hsl: {
|
|
217
|
-
h:
|
|
218
|
-
l:
|
|
219
|
-
s:
|
|
557
|
+
h: r.h,
|
|
558
|
+
l: r.l,
|
|
559
|
+
s: r.s,
|
|
220
560
|
string: this.setLetterCase(
|
|
221
|
-
`hsl(${Math.round(
|
|
222
|
-
|
|
561
|
+
`hsl(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(
|
|
562
|
+
r.l
|
|
223
563
|
)}%)`
|
|
224
564
|
)
|
|
225
565
|
},
|
|
226
566
|
hsla: {
|
|
227
|
-
a:
|
|
228
|
-
h:
|
|
229
|
-
l:
|
|
230
|
-
s:
|
|
567
|
+
a: r.a,
|
|
568
|
+
h: r.h,
|
|
569
|
+
l: r.l,
|
|
570
|
+
s: r.s,
|
|
231
571
|
string: this.setLetterCase(
|
|
232
|
-
`hsla(${Math.round(
|
|
233
|
-
|
|
234
|
-
)}%, ${
|
|
572
|
+
`hsla(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(
|
|
573
|
+
r.l
|
|
574
|
+
)}%, ${r.a.toFixed(2).toString()})`
|
|
235
575
|
)
|
|
236
576
|
},
|
|
237
577
|
hsv: {
|
|
238
|
-
h:
|
|
239
|
-
s:
|
|
578
|
+
h: h.h,
|
|
579
|
+
s: h.s,
|
|
240
580
|
string: this.setLetterCase(
|
|
241
|
-
`hsv(${Math.round(
|
|
242
|
-
|
|
581
|
+
`hsv(${Math.round(h.h)}, ${Math.round(h.s)}%, ${Math.round(
|
|
582
|
+
h.v
|
|
243
583
|
)}%)`
|
|
244
584
|
),
|
|
245
|
-
v:
|
|
585
|
+
v: h.v
|
|
246
586
|
},
|
|
247
587
|
hsva: {
|
|
248
|
-
a:
|
|
249
|
-
h:
|
|
250
|
-
s:
|
|
588
|
+
a: h.a,
|
|
589
|
+
h: h.h,
|
|
590
|
+
s: h.s,
|
|
251
591
|
string: this.setLetterCase(
|
|
252
|
-
`hsva(${Math.round(
|
|
253
|
-
|
|
254
|
-
)}%, ${
|
|
592
|
+
`hsva(${Math.round(h.h)}, ${Math.round(h.s)}%, ${Math.round(
|
|
593
|
+
h.v
|
|
594
|
+
)}%, ${h.a.toFixed(2).toString()})`
|
|
255
595
|
),
|
|
256
|
-
v:
|
|
596
|
+
v: h.v
|
|
257
597
|
},
|
|
258
598
|
rgb: {
|
|
259
599
|
b: a.b,
|
|
@@ -285,11 +625,108 @@ let r = class extends D {
|
|
|
285
625
|
setLetterCase(t) {
|
|
286
626
|
return typeof t != "string" ? "" : this.uppercase ? t.toUpperCase() : t.toLowerCase();
|
|
287
627
|
}
|
|
628
|
+
/**
|
|
629
|
+
* Adopts an externally assigned CSS gradient string as the current gradient.
|
|
630
|
+
* @param value - The gradient string, already known to be parseable in shape.
|
|
631
|
+
*/
|
|
632
|
+
adoptGradientValue(t) {
|
|
633
|
+
const e = Z(t);
|
|
634
|
+
if (!e)
|
|
635
|
+
return;
|
|
636
|
+
this.mode = b.Gradient, this.gradientValue = e;
|
|
637
|
+
const r = e.stops.some(
|
|
638
|
+
(a) => a.id === this.activeStopId
|
|
639
|
+
) ? this.activeStop : e.stops[0];
|
|
640
|
+
r && (this.activeStopId = r.id, this.loadStopIntoControls(r));
|
|
641
|
+
}
|
|
642
|
+
/** True when the Gradient tab is enabled and active. */
|
|
643
|
+
get isGradientMode() {
|
|
644
|
+
return this.gradient && this.mode === b.Gradient;
|
|
645
|
+
}
|
|
646
|
+
/** The gradient stop the color controls currently edit, if any. */
|
|
647
|
+
get activeStop() {
|
|
648
|
+
return this.gradientValue.stops.find(
|
|
649
|
+
(t) => t.id === this.activeStopId
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Writes the current HSVA state into the active stop and republishes `value` as a CSS
|
|
654
|
+
* gradient string.
|
|
655
|
+
* @param currentColor - The parsed color represented by the current HSVA state.
|
|
656
|
+
*/
|
|
657
|
+
async syncGradientValue(t) {
|
|
658
|
+
const e = this.opacity ? t.rgba.string : t.hex;
|
|
659
|
+
this.gradientValue = {
|
|
660
|
+
...this.gradientValue,
|
|
661
|
+
stops: this.gradientValue.stops.map(
|
|
662
|
+
(i) => i.id === this.activeStopId ? { ...i, color: e } : i
|
|
663
|
+
)
|
|
664
|
+
}, this.inputColorValue = this.getStopInputValue(t), this.inputOpacityValue = this.opacity ? Math.round(this.alpha).toString() : "", this.publishGradientValue(), await this.updateComplete, this.isSafeValue = !1;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Formats the active stop's color for the text input, honoring the current format.
|
|
668
|
+
* @param currentColor - The parsed color represented by the current HSVA state.
|
|
669
|
+
* @returns The formatted color string.
|
|
670
|
+
*/
|
|
671
|
+
getStopInputValue(t) {
|
|
672
|
+
return this.format === v.Hsl ? t.hsl.string : this.format === v.Rgb ? t.rgb.string : this.format === v.Hsv ? t.hsv.string : t.hex;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Loads a stop's color into the HSVA controls without writing back to `value`.
|
|
676
|
+
* @param stop - The stop to load.
|
|
677
|
+
*/
|
|
678
|
+
loadStopIntoControls(t) {
|
|
679
|
+
this.setColor(t.color, !1);
|
|
680
|
+
const e = this.parseColor(t.color);
|
|
681
|
+
e && (this.inputColorValue = this.getStopInputValue(e), this.inputOpacityValue = this.opacity ? Math.round(this.alpha).toString() : "");
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Publishes the current gradient as `value` without letting the `value` watcher re-adopt
|
|
685
|
+
* it. Re-adopting would re-parse the string and mint fresh stop ids, which destroys the
|
|
686
|
+
* marker being dragged; `isSafeValue` is the existing guard for "this component wrote
|
|
687
|
+
* `value` itself", and it must always be cleared again once the update settles.
|
|
688
|
+
*/
|
|
689
|
+
async publishGradientValue() {
|
|
690
|
+
this.isSafeValue = !0, this.value = tt(this.gradientValue), this.emitValue = this.value, await this.updateComplete, this.isSafeValue = !1;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Replaces the gradient's stops, republishes `value`, and keeps the active stop valid.
|
|
694
|
+
* @param stops - The next set of stops.
|
|
695
|
+
*/
|
|
696
|
+
async applyGradientStops(t) {
|
|
697
|
+
const e = D(t);
|
|
698
|
+
if (this.gradientValue = { ...this.gradientValue, stops: e }, !e.some((i) => i.id === this.activeStopId)) {
|
|
699
|
+
const i = e[0];
|
|
700
|
+
i && (this.activeStopId = i.id, this.loadStopIntoControls(i));
|
|
701
|
+
}
|
|
702
|
+
await this.publishGradientValue();
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Seeds a two-stop gradient from the current solid color so switching to the Gradient tab
|
|
706
|
+
* starts from something visible rather than an empty bar.
|
|
707
|
+
*/
|
|
708
|
+
seedGradientFromCurrentColor() {
|
|
709
|
+
const t = this.parseColor(
|
|
710
|
+
`hsva(${this.hue}, ${this.saturation}%, ${this.brightness}%, ${this.alpha / 100})`
|
|
711
|
+
), e = t ? this.opacity ? t.rgba.string : t.hex : "#ffffff", i = new x(e).setAlpha(0).toRgbString(), r = [
|
|
712
|
+
{ color: e, id: F(), position: 0 },
|
|
713
|
+
{ color: i, id: F(), position: 100 }
|
|
714
|
+
];
|
|
715
|
+
this.gradientValue = {
|
|
716
|
+
angle: K,
|
|
717
|
+
stops: r,
|
|
718
|
+
type: this.gradientTypes[0] ?? $.Linear
|
|
719
|
+
}, this.activeStopId = r[0].id;
|
|
720
|
+
}
|
|
288
721
|
async syncValues() {
|
|
289
722
|
const t = this.parseColor(
|
|
290
723
|
`hsva(${this.hue}, ${this.saturation}%, ${this.brightness}%, ${this.alpha / 100})`
|
|
291
724
|
);
|
|
292
725
|
if (t !== null) {
|
|
726
|
+
if (this.isGradientMode) {
|
|
727
|
+
await this.syncGradientValue(t);
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
293
730
|
if (this.emitFormat) {
|
|
294
731
|
const e = `${this.emitFormat}${this.opacity ? "a" : ""}`, i = t[e];
|
|
295
732
|
this.emitFormat === "hex" ? this.emitValue = i : this.emitValue = typeof i == "string" ? i : i.string;
|
|
@@ -298,10 +735,12 @@ let r = class extends D {
|
|
|
298
735
|
}
|
|
299
736
|
}
|
|
300
737
|
handleAfterHide() {
|
|
301
|
-
this.previewButton
|
|
738
|
+
this.previewButton?.classList.remove(
|
|
739
|
+
"color-picker__preview-color--copied"
|
|
740
|
+
);
|
|
302
741
|
}
|
|
303
742
|
handleEyeDropper() {
|
|
304
|
-
if (!
|
|
743
|
+
if (!B)
|
|
305
744
|
return;
|
|
306
745
|
new EyeDropper().open().then((e) => {
|
|
307
746
|
const i = this.value;
|
|
@@ -327,9 +766,9 @@ let r = class extends D {
|
|
|
327
766
|
this.disabled || (this.setColor(t), this.value !== e && (this.emit("cx-change"), this.emit("cx-input")));
|
|
328
767
|
}
|
|
329
768
|
/** Generates a hex string from HSV values. Hue must be 0-360. All other arguments must be 0-100. */
|
|
330
|
-
getHexString(t, e, i,
|
|
331
|
-
const a = new
|
|
332
|
-
`hsva(${t}, ${e}%, ${i}%, ${
|
|
769
|
+
getHexString(t, e, i, r = 100) {
|
|
770
|
+
const a = new x(
|
|
771
|
+
`hsva(${t}, ${e}%, ${i}%, ${r / 100})`
|
|
333
772
|
);
|
|
334
773
|
return a.isValid ? a.toHex8String() : "";
|
|
335
774
|
}
|
|
@@ -339,16 +778,71 @@ let r = class extends D {
|
|
|
339
778
|
* @returns The color format.
|
|
340
779
|
*/
|
|
341
780
|
getFormatFromValue(t) {
|
|
342
|
-
const e = new
|
|
781
|
+
const e = new x(t);
|
|
343
782
|
return !e.isValid || !this.formats || this.formats.length === 0 ? null : this.formats.includes(e.format) ? e.format : this.formats[0];
|
|
344
783
|
}
|
|
345
784
|
// Prevents nested components from leaking events
|
|
346
785
|
stopNestedEventPropagation(t) {
|
|
347
786
|
t.stopImmediatePropagation();
|
|
348
787
|
}
|
|
788
|
+
handleTabShow(t) {
|
|
789
|
+
if (t.target !== this.tabGroup)
|
|
790
|
+
return;
|
|
791
|
+
const e = t.detail.name === z ? b.Gradient : b.Solid;
|
|
792
|
+
e !== this.mode && (this.mode = e, e === b.Gradient ? this.switchToGradientMode() : this.switchToSolidMode(), this.emit("cx-change"), this.emit("cx-input"));
|
|
793
|
+
}
|
|
794
|
+
/** Moves editing to the Gradient tab, seeding stops on first use. */
|
|
795
|
+
switchToGradientMode() {
|
|
796
|
+
this.gradientValue.stops.length === 0 && this.seedGradientFromCurrentColor();
|
|
797
|
+
const t = this.activeStop ?? this.gradientValue.stops[0];
|
|
798
|
+
t && (this.activeStopId = t.id, this.loadStopIntoControls(t)), this.publishGradientValue();
|
|
799
|
+
}
|
|
800
|
+
/** Moves editing back to the Solid tab, keeping the active stop's color. */
|
|
801
|
+
switchToSolidMode() {
|
|
802
|
+
const t = this.activeStop ?? this.gradientValue.stops[0];
|
|
803
|
+
if (t) {
|
|
804
|
+
this.setColor(t.color);
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
this.syncValues();
|
|
808
|
+
}
|
|
809
|
+
handleGradientStopSelect(t) {
|
|
810
|
+
const e = this.gradientValue.stops.find(
|
|
811
|
+
(i) => i.id === t.detail.id
|
|
812
|
+
);
|
|
813
|
+
e && (this.activeStopId = e.id, this.loadStopIntoControls(e));
|
|
814
|
+
}
|
|
815
|
+
handleGradientStopAdd(t) {
|
|
816
|
+
const { color: e, position: i } = t.detail, r = { color: e, id: F(), position: i };
|
|
817
|
+
this.applyGradientStops([...this.gradientValue.stops, r]), this.activeStopId = r.id, this.loadStopIntoControls(r), this.emit("cx-change"), this.emit("cx-input");
|
|
818
|
+
}
|
|
819
|
+
handleGradientStopRemove(t) {
|
|
820
|
+
t.detail.id === this.activeStopId && (this.activeStopId = "");
|
|
821
|
+
}
|
|
822
|
+
handleGradientStopChange(t) {
|
|
823
|
+
this.applyGradientStops(t.detail.stops), this.emit("cx-input");
|
|
824
|
+
}
|
|
825
|
+
handleGradientChange(t) {
|
|
826
|
+
this.applyGradientStops(t.detail.stops), this.emit("cx-change"), this.emit("cx-input");
|
|
827
|
+
}
|
|
828
|
+
handleGradientTypeSelect(t) {
|
|
829
|
+
t.stopPropagation();
|
|
830
|
+
const e = t.target;
|
|
831
|
+
this.handleGradientTypeChange(e.value);
|
|
832
|
+
}
|
|
833
|
+
handleGradientTypeChange(t) {
|
|
834
|
+
t !== this.gradientValue.type && (this.gradientValue = { ...this.gradientValue, type: t }, this.publishGradientValue(), this.emit("cx-change"), this.emit("cx-input"));
|
|
835
|
+
}
|
|
836
|
+
handleGradientAngleInput(t) {
|
|
837
|
+
const e = t.target, i = Number.parseInt(e.value.replace(/\D/g, ""), 10);
|
|
838
|
+
t.stopPropagation(), !Number.isNaN(i) && (this.gradientValue = {
|
|
839
|
+
...this.gradientValue,
|
|
840
|
+
angle: d(i, 0, 360)
|
|
841
|
+
}, this.publishGradientValue(), this.emit("cx-change"), this.emit("cx-input"));
|
|
842
|
+
}
|
|
349
843
|
handleFormatChange() {
|
|
350
|
-
if (
|
|
351
|
-
|
|
844
|
+
if (Ct(this, C)) {
|
|
845
|
+
R(this, C, !1);
|
|
352
846
|
return;
|
|
353
847
|
}
|
|
354
848
|
this.syncValues();
|
|
@@ -356,12 +850,42 @@ let r = class extends D {
|
|
|
356
850
|
handleOpacityChange() {
|
|
357
851
|
this.alpha = 100;
|
|
358
852
|
}
|
|
853
|
+
/**
|
|
854
|
+
* Parses a swatch list once per change rather than on every render. `render()` used to
|
|
855
|
+
* split and filter these strings itself, which repeated the work on every update — and
|
|
856
|
+
* the gradient tab re-renders on every pointer move while a stop is dragged.
|
|
857
|
+
* @param value - The raw property value, either a delimited string or an array.
|
|
858
|
+
* @returns The individual color strings.
|
|
859
|
+
*/
|
|
860
|
+
parseSwatchList(t) {
|
|
861
|
+
return t ? Array.isArray(t) ? t : t.split(";").filter((e) => e.trim() !== "") : [];
|
|
862
|
+
}
|
|
863
|
+
handleSwatchesChange() {
|
|
864
|
+
this.parsedSwatches = this.parseSwatchList(this.swatches);
|
|
865
|
+
}
|
|
866
|
+
handleCustomSwatchesChange() {
|
|
867
|
+
this.parsedCustomSwatches = this.parseSwatchList(this.customSwatches);
|
|
868
|
+
}
|
|
869
|
+
async handleModeChange() {
|
|
870
|
+
await this.updateComplete, this.syncTabToMode();
|
|
871
|
+
}
|
|
872
|
+
/** Selects the tab panel matching the current mode. */
|
|
873
|
+
syncTabToMode() {
|
|
874
|
+
if (!this.gradient)
|
|
875
|
+
return;
|
|
876
|
+
const t = this.mode === b.Gradient ? z : E;
|
|
877
|
+
this.tabGroup?.show(t);
|
|
878
|
+
}
|
|
359
879
|
handleValueChange(t, e) {
|
|
360
|
-
this.isEmpty = !e
|
|
880
|
+
if (this.isEmpty = !e, this.gradient && et(e)) {
|
|
881
|
+
this.isSafeValue || this.adoptGradientValue(e);
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
this.isGradientMode && e && (this.mode = b.Solid);
|
|
361
885
|
const i = this.getFormatFromValue(e);
|
|
362
886
|
if (i && i !== this.format && (this.format = i), e || (this.hue = 0, this.saturation = 0, this.brightness = 100, this.alpha = 100), !this.isSafeValue) {
|
|
363
|
-
const
|
|
364
|
-
|
|
887
|
+
const r = this.parseColor(e);
|
|
888
|
+
r !== null ? (this.hue = r.hsva.h, this.saturation = r.hsva.s, this.brightness = r.hsva.v, this.alpha = r.hsva.a * 100, this.syncValues()) : (this.inputColorValue = t ?? "", this.inputOpacityValue = "");
|
|
365
889
|
}
|
|
366
890
|
}
|
|
367
891
|
/** Sets focus on the color picker. */
|
|
@@ -403,7 +927,7 @@ let r = class extends D {
|
|
|
403
927
|
}
|
|
404
928
|
/** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
|
|
405
929
|
checkValidity() {
|
|
406
|
-
return this.input
|
|
930
|
+
return this.input?.checkValidity() ?? this.formValidity.valid;
|
|
407
931
|
}
|
|
408
932
|
/** Gets the associated form, if one exists. */
|
|
409
933
|
getForm() {
|
|
@@ -413,93 +937,142 @@ let r = class extends D {
|
|
|
413
937
|
reportValidity() {
|
|
414
938
|
return !this.inline && !this.validity.valid ? (this.dropdown.show(), this.addEventListener(
|
|
415
939
|
"cx-after-show",
|
|
416
|
-
() => this.input
|
|
940
|
+
() => this.input?.reportValidity(),
|
|
417
941
|
{ once: !0 }
|
|
418
|
-
), this.disabled || this.formControlController.emitInvalidEvent(), !1) : this.input
|
|
942
|
+
), this.disabled || this.formControlController.emitInvalidEvent(), !1) : this.input?.reportValidity() ?? this.formValidity.valid;
|
|
419
943
|
}
|
|
420
944
|
/** Sets a custom validation message. Pass an empty string to restore validity. */
|
|
421
945
|
setCustomValidity(t) {
|
|
422
|
-
this.input
|
|
946
|
+
this.input?.setCustomValidity(t), this.formControlController.updateValidity();
|
|
423
947
|
}
|
|
424
948
|
renderSwatches(t) {
|
|
425
949
|
return t.map((e) => {
|
|
426
950
|
const i = this.parseColor(e);
|
|
427
951
|
if (!i)
|
|
428
952
|
return console.error(`Unable to parse swatch color: "${e}"`, this), "";
|
|
429
|
-
const
|
|
430
|
-
return
|
|
953
|
+
const r = () => this.selectSwatch(e), a = (l) => !this.disabled && l.key === "Enter" && this.setColor(i.hexa);
|
|
954
|
+
return c`<div part="swatch" class="color-picker__swatch color-picker__transparent-bg" tabindex=${I(this.disabled ? void 0 : "0")} role="button" aria-label=${e} @click=${r} @keydown=${a}><div class="color-picker__swatch-color" style=${m({ backgroundColor: i.hexa })}></div></div>`;
|
|
431
955
|
});
|
|
432
956
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
957
|
+
/**
|
|
958
|
+
* Renders one gradient type toggle. The type travels on a data attribute so the click
|
|
959
|
+
* handler can stay a bound method rather than a per-render arrow function.
|
|
960
|
+
* @param type - The gradient type this button selects.
|
|
961
|
+
*/
|
|
962
|
+
/**
|
|
963
|
+
* Returns a gradient type's user-facing name.
|
|
964
|
+
* @param type - The gradient type to label.
|
|
965
|
+
*/
|
|
966
|
+
getGradientTypeLabel(t) {
|
|
967
|
+
return t === $.Radial ? this.localize.term("radial") : this.localize.term("linear");
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Renders the gradient type selector and, for linear gradients, the angle input.
|
|
971
|
+
*/
|
|
972
|
+
renderGradientOptions() {
|
|
973
|
+
return c`<div class="color-picker__gradient-options"><cx-select part="gradient-type-select" class="color-picker__gradient-type-select" size="small" hoist label=${this.localize.term("gradient")} value=${this.gradientValue.type} ?disabled=${this.disabled} @cx-change=${this.handleGradientTypeSelect} @cx-blur=${this.stopNestedEventPropagation} @cx-focus=${this.stopNestedEventPropagation}>${H(
|
|
974
|
+
this.gradientTypes,
|
|
975
|
+
(t) => t,
|
|
976
|
+
(t) => c`<cx-option value=${t}>${this.getGradientTypeLabel(t)}</cx-option>`
|
|
977
|
+
)}</cx-select>${u(
|
|
978
|
+
this.gradientValue.type === $.Linear,
|
|
979
|
+
() => c`<cx-input part="gradient-angle-input" class="color-picker__gradient-angle" type="text" size="small" label=${this.localize.term("gradientAngle")} .maskBlocks=${{
|
|
980
|
+
num: {
|
|
981
|
+
mask: Number,
|
|
982
|
+
max: 360,
|
|
983
|
+
min: 0,
|
|
984
|
+
scale: 0,
|
|
985
|
+
thousandsSeparator: ""
|
|
986
|
+
}
|
|
987
|
+
}} mask="num°" no-spin-buttons value=${`${Math.round(this.gradientValue.angle)}°`} ?disabled=${this.disabled} @cx-input=${this.handleGradientAngleInput} @cx-blur=${this.stopNestedEventPropagation} @cx-focus=${this.stopNestedEventPropagation}></cx-input>`
|
|
988
|
+
)}</div>`;
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* Renders the shared color controls, wrapped in a Solid / Gradient tab group when the
|
|
992
|
+
* gradient tab is enabled. When it is not, the controls render exactly as they always have,
|
|
993
|
+
* so existing consumers see an unchanged DOM.
|
|
994
|
+
*/
|
|
995
|
+
renderTabsOrControls(t) {
|
|
996
|
+
return this.gradient ? c`<cx-tab-group class="color-picker__tabs" @cx-tab-show=${this.handleTabShow}><cx-tab slot="nav" panel=${E} ?active=${this.mode === b.Solid}>${this.localize.term("solid")}</cx-tab><cx-tab slot="nav" panel=${z} ?active=${this.isGradientMode}>${this.localize.term("gradient")}</cx-tab><cx-tab-panel name=${E} ?active=${this.mode === b.Solid}>${u(
|
|
997
|
+
this.mode === b.Solid,
|
|
998
|
+
() => this.renderColorControls(t)
|
|
999
|
+
)}</cx-tab-panel><cx-tab-panel name=${z} ?active=${this.isGradientMode}>${u(
|
|
1000
|
+
this.isGradientMode,
|
|
1001
|
+
() => c`<div class="color-picker__gradient-panel">${this.renderGradientOptions()}<cx-gradient-slider part="gradient-slider" exportparts="track:gradient-track,marker:gradient-marker" .stops=${this.gradientValue.stops} active-stop-id=${this.activeStopId} ?disabled=${this.disabled} @cx-gradient-stop-select=${this.handleGradientStopSelect} @cx-gradient-stop-change=${this.handleGradientStopChange} @cx-gradient-change=${this.handleGradientChange} @cx-gradient-stop-remove=${this.handleGradientStopRemove}></cx-gradient-slider><cx-gradient-stop-list part="gradient-stop-list" exportparts="
|
|
1002
|
+
row:gradient-stop-row,
|
|
1003
|
+
add-button:gradient-add-stop-button,
|
|
1004
|
+
delete-button:gradient-delete-stop-button
|
|
1005
|
+
" .stops=${this.gradientValue.stops} active-stop-id=${this.activeStopId} ?disabled=${this.disabled} @cx-gradient-stop-select=${this.handleGradientStopSelect} @cx-gradient-stop-add=${this.handleGradientStopAdd} @cx-gradient-stop-remove=${this.handleGradientStopRemove} @cx-gradient-change=${this.handleGradientChange}></cx-gradient-stop-list></div>`
|
|
1006
|
+
)}</cx-tab-panel></cx-tab-group>` : this.renderColorControls(t);
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Renders the color grid, hue/alpha sliders, and the text inputs. These controls are shared
|
|
1010
|
+
* by both tabs: in Solid mode they edit `value` directly, and in Gradient mode they edit the
|
|
1011
|
+
* active gradient stop.
|
|
1012
|
+
*/
|
|
1013
|
+
renderColorControls(t) {
|
|
1014
|
+
const e = this.saturation, i = 100 - this.brightness;
|
|
1015
|
+
return c`<div part="grid" class="color-picker__grid" style=${m({
|
|
443
1016
|
backgroundColor: this.getHexString(this.hue, 100, 100)
|
|
444
1017
|
})} @pointerdown=${this.handleGridDrag} @touchmove=${this.handleTouchMove}><span part="grid-handle" class=${_({
|
|
445
1018
|
"color-picker__grid-handle": !0,
|
|
446
1019
|
"color-picker__grid-handle--dragging": this.isDraggingGridHandle
|
|
447
|
-
})} style=${
|
|
1020
|
+
})} style=${m({
|
|
448
1021
|
backgroundColor: this.getHexString(
|
|
449
1022
|
this.hue,
|
|
450
1023
|
this.saturation,
|
|
451
1024
|
this.brightness,
|
|
452
1025
|
this.alpha
|
|
453
1026
|
),
|
|
454
|
-
left: `${
|
|
455
|
-
top: `${
|
|
456
|
-
})} role="application" aria-label="HSV" tabindex=${
|
|
1027
|
+
left: `${e}%`,
|
|
1028
|
+
top: `${i}%`
|
|
1029
|
+
})} role="application" aria-label="HSV" tabindex=${I(this.disabled ? void 0 : "0")} @keydown=${this.handleGridKeyDown}></span></div><div class="color-picker__controls"><div class="color-picker__sliders"><div part="slider hue-slider" class="color-picker__hue color-picker__slider" @pointerdown=${this.handleHueDrag} @touchmove=${this.handleTouchMove}><span part="slider-handle hue-slider-handle" class="color-picker__slider-handle" style=${m({
|
|
457
1030
|
left: `${this.hue === 0 ? 0 : 100 / (360 / this.hue)}%`
|
|
458
|
-
})} role="slider" aria-label="hue" aria-orientation="horizontal" aria-valuemin="0" aria-valuemax="360" aria-valuenow=${`${Math.round(this.hue)}`} tabindex=${
|
|
1031
|
+
})} role="slider" aria-label="hue" aria-orientation="horizontal" aria-valuemin="0" aria-valuemax="360" aria-valuenow=${`${Math.round(this.hue)}`} tabindex=${I(this.disabled ? void 0 : "0")} @keydown=${this.handleHueKeyDown}></span></div>${u(
|
|
459
1032
|
this.opacity,
|
|
460
|
-
() =>
|
|
1033
|
+
() => c`<div part="slider opacity-slider" class="color-picker__alpha color-picker__slider color-picker__transparent-bg" @pointerdown=${this.handleAlphaDrag} @touchmove=${this.handleTouchMove}><div class="color-picker__alpha-gradient" style=${m({
|
|
461
1034
|
backgroundImage: `linear-gradient(
|
|
462
|
-
|
|
463
|
-
|
|
1035
|
+
to right,
|
|
1036
|
+
${this.getHexString(
|
|
464
1037
|
this.hue,
|
|
465
1038
|
this.saturation,
|
|
466
1039
|
this.brightness,
|
|
467
1040
|
0
|
|
468
1041
|
)} 0%,
|
|
469
|
-
|
|
1042
|
+
${this.getHexString(
|
|
470
1043
|
this.hue,
|
|
471
1044
|
this.saturation,
|
|
472
1045
|
this.brightness,
|
|
473
1046
|
100
|
|
474
1047
|
)} 100%
|
|
475
|
-
|
|
476
|
-
})}></div><span part="slider-handle opacity-slider-handle" class="color-picker__slider-handle" style=${
|
|
1048
|
+
)`
|
|
1049
|
+
})}></div><span part="slider-handle opacity-slider-handle" class="color-picker__slider-handle" style=${m({
|
|
477
1050
|
left: `${this.alpha}%`
|
|
478
|
-
})} role="slider" aria-label="alpha" aria-orientation="horizontal" aria-valuemin="0" aria-valuemax="100" aria-valuenow=${Math.round(this.alpha)} tabindex=${
|
|
1051
|
+
})} role="slider" aria-label="alpha" aria-orientation="horizontal" aria-valuemin="0" aria-valuemax="100" aria-valuenow=${Math.round(this.alpha)} tabindex=${I(this.disabled ? void 0 : "0")} @keydown=${this.handleAlphaKeyDown}></span></div>`
|
|
479
1052
|
)}</div><div class="color-picker__preview__container"><button type="button" part="preview" class=${_({
|
|
480
1053
|
"color-picker__preview": !0,
|
|
481
1054
|
"color-picker__preview--button": this.variant === "button",
|
|
482
1055
|
"color-picker__preview--empty": this.isEmpty,
|
|
483
1056
|
"color-picker__preview__transparent-bg": this.isEmpty
|
|
484
|
-
})} aria-label=${this.localize.term("copy")} style=${
|
|
1057
|
+
})} aria-label=${this.localize.term("copy")} style=${m({
|
|
485
1058
|
"--preview-color": this.getHexString(
|
|
486
1059
|
this.hue,
|
|
487
1060
|
this.saturation,
|
|
488
1061
|
this.brightness,
|
|
489
1062
|
this.alpha
|
|
490
1063
|
)
|
|
491
|
-
})} @click=${this.handleCopy}></button>${
|
|
1064
|
+
})} @click=${this.handleCopy}></button>${u(
|
|
492
1065
|
this.clearable,
|
|
493
|
-
() =>
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
)}</div></div><div class="color-picker__user-input__container" aria-live="polite"><cx-input class="color-picker__input_color" part="input" type="text" name=${this.name} autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" value=${this.isEmpty ? "" : this.inputColorValue} ?required=${this.required} ?disabled=${this.disabled} aria-label=${this.localize.term("currentValue")} @keydown=${this.handleInputKeyDown} @cx-change=${this.handleInputChange} @cx-input=${this.handleInputInput} @cx-invalid=${this.handleInputInvalid} @cx-blur=${this.stopNestedEventPropagation} @cx-focus=${this.stopNestedEventPropagation}></cx-input>${
|
|
1066
|
+
() => c`<cx-button variant="text" class="color-picker__clear-button" part="clear-button" size="small" exportparts="
|
|
1067
|
+
base:clear-button__base,
|
|
1068
|
+
prefix:clear-button__prefix,
|
|
1069
|
+
label:clear-button__label,
|
|
1070
|
+
suffix:clear-button__suffix,
|
|
1071
|
+
caret:clear-button__caret
|
|
1072
|
+
" @click=${this.handleClear} @cx-blur=${this.stopNestedEventPropagation} @cx-focus=${this.stopNestedEventPropagation}><cx-icon class="color-picker__clear-button__icon" name="close"></cx-icon></cx-button>`
|
|
1073
|
+
)}</div></div><div class="color-picker__user-input__container" aria-live="polite"><cx-input class="color-picker__input_color" part="input" type="text" name=${this.name} autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" value=${this.isEmpty ? "" : this.inputColorValue} ?required=${this.required} ?disabled=${this.disabled} aria-label=${this.localize.term("currentValue")} @keydown=${this.handleInputKeyDown} @cx-change=${this.handleInputChange} @cx-input=${this.handleInputInput} @cx-invalid=${this.handleInputInvalid} @cx-blur=${this.stopNestedEventPropagation} @cx-focus=${this.stopNestedEventPropagation}></cx-input>${u(
|
|
501
1074
|
this.opacity,
|
|
502
|
-
() =>
|
|
1075
|
+
() => c`<cx-input class="color-picker__input_opacity" part="opacity-input" type="text" name=${this.name} .maskBlocks=${{
|
|
503
1076
|
num: {
|
|
504
1077
|
mask: Number,
|
|
505
1078
|
max: 100,
|
|
@@ -507,46 +1080,61 @@ let r = class extends D {
|
|
|
507
1080
|
scale: 0,
|
|
508
1081
|
thousandsSeparator: ""
|
|
509
1082
|
}
|
|
510
|
-
}} mask="num%" no-spin-buttons value=${this.isEmpty ? "%" :
|
|
511
|
-
)}<cx-button-group>${
|
|
1083
|
+
}} mask="num%" no-spin-buttons value=${this.isEmpty ? "%" : t} ?required=${this.required} ?disabled=${this.disabled} aria-label=${this.localize.term("opacity")} @keydown=${this.handleOpacityInputKeyDown} @cx-change=${this.handleOpacityInputChange} @cx-input=${this.handleOpacityInputInput} @cx-invalid=${this.handleInputInvalid} @cx-blur=${this.stopNestedEventPropagation} @cx-focus=${this.stopNestedEventPropagation}></cx-input>`
|
|
1084
|
+
)}<cx-button-group>${u(
|
|
512
1085
|
!this.noFormatToggle,
|
|
513
|
-
() =>
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
1086
|
+
() => c`<cx-button part="format-button" aria-label=${this.localize.term("toggleColorFormat")} exportparts="
|
|
1087
|
+
base:format-button__base,
|
|
1088
|
+
prefix:format-button__prefix,
|
|
1089
|
+
label:format-button__label,
|
|
1090
|
+
suffix:format-button__suffix,
|
|
1091
|
+
caret:format-button__caret
|
|
1092
|
+
" @click=${this.handleFormatToggle} @cx-blur=${this.stopNestedEventPropagation} @cx-focus=${this.stopNestedEventPropagation}>${this.setLetterCase(this.format)}</cx-button>`
|
|
1093
|
+
)}
|
|
1094
|
+
${u(
|
|
1095
|
+
B,
|
|
1096
|
+
() => c`<cx-button part="eye-dropper-button" exportparts="
|
|
1097
|
+
base:eye-dropper-button__base,
|
|
1098
|
+
prefix:eye-dropper-button__prefix,
|
|
1099
|
+
label:eye-dropper-button__label,
|
|
1100
|
+
suffix:eye-dropper-button__suffix,
|
|
1101
|
+
caret:eye-dropper-button__caret
|
|
1102
|
+
" @click=${this.handleEyeDropper} @cx-blur=${this.stopNestedEventPropagation} @cx-focus=${this.stopNestedEventPropagation}><cx-icon name="colorize" label=${this.localize.term("selectAColorFromTheScreen")}></cx-icon></cx-button>`
|
|
1103
|
+
)}</cx-button-group></div>`;
|
|
1104
|
+
}
|
|
1105
|
+
render() {
|
|
1106
|
+
const t = this.parsedSwatches, e = this.parsedCustomSwatches, i = this.inputOpacityValue.endsWith("%") ? this.inputOpacityValue : `${this.inputOpacityValue}%`, r = c`<div part="base" class=${_({
|
|
1107
|
+
"color-picker": !0,
|
|
1108
|
+
"color-picker--disabled": this.disabled,
|
|
1109
|
+
"color-picker--focused": this.hasFocus,
|
|
1110
|
+
"color-picker--inline": this.inline
|
|
1111
|
+
})} aria-disabled=${this.disabled ? "true" : "false"} aria-labelledby="label" tabindex=${this.inline ? "0" : "-1"}>${u(
|
|
1112
|
+
this.inline,
|
|
1113
|
+
() => c`<cx-visually-hidden id="label"><slot name="label">${this.label}</slot></cx-visually-hidden>`
|
|
520
1114
|
)}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
suffix:eye-dropper-button__suffix,
|
|
528
|
-
caret:eye-dropper-button__caret
|
|
529
|
-
" @click=${this.handleEyeDropper} @cx-blur=${this.stopNestedEventPropagation} @cx-focus=${this.stopNestedEventPropagation}><cx-icon name="colorize" label=${this.localize.term("selectAColorFromTheScreen")}></cx-icon></cx-button>`
|
|
530
|
-
)}</cx-button-group></div>${d(
|
|
531
|
-
i.length > 0,
|
|
532
|
-
() => h`<div part="swatches" class="color-picker__swatches">${this.renderSwatches(i)}</div>`
|
|
1115
|
+
|
|
1116
|
+
${this.renderTabsOrControls(i)}
|
|
1117
|
+
|
|
1118
|
+
${u(
|
|
1119
|
+
t.length > 0,
|
|
1120
|
+
() => c`<div part="swatches" class="color-picker__swatches">${this.renderSwatches(t)}</div>`
|
|
533
1121
|
)}
|
|
534
|
-
${
|
|
535
|
-
|
|
536
|
-
() =>
|
|
537
|
-
${
|
|
1122
|
+
${u(
|
|
1123
|
+
e.length > 0 || this.creatable,
|
|
1124
|
+
() => c`<div class="color-picker__customSwatches-label">${this.localize.term("custom")}
|
|
1125
|
+
${u(
|
|
538
1126
|
this.creatable,
|
|
539
|
-
() =>
|
|
1127
|
+
() => c`<cx-button part="swatch-add-button" size="small" @click=${this.handleSwatchAdd}>${this.localize.term("addCurrent")}</cx-button>`
|
|
540
1128
|
)}</div>`
|
|
541
1129
|
)}
|
|
542
|
-
${
|
|
543
|
-
|
|
544
|
-
() =>
|
|
1130
|
+
${u(
|
|
1131
|
+
e.length > 0,
|
|
1132
|
+
() => c`<div part="custom-swatches" class="color-picker__customSwatches">${this.renderSwatches(e)}</div>`
|
|
545
1133
|
)}
|
|
546
|
-
${
|
|
1134
|
+
${u(
|
|
547
1135
|
this.loading,
|
|
548
|
-
() =>
|
|
549
|
-
)}</div>`,
|
|
1136
|
+
() => c`<div part="loading-spinner" class="color-picker__spinner"><cx-spinner></cx-spinner></div>`
|
|
1137
|
+
)}</div>`, a = this.variant === "button" ? c`<cx-button part="trigger" class=${_({
|
|
550
1138
|
"color-dropdown__trigger": !0,
|
|
551
1139
|
"color-dropdown__trigger--focused": this.hasFocus
|
|
552
1140
|
})} outline aria-label=${this.label} ?disabled=${this.disabled} type="button" size=${this.size} @cx-blur=${this.stopNestedEventPropagation}><div slot="prefix" part="preview" class=${_({
|
|
@@ -557,193 +1145,239 @@ let r = class extends D {
|
|
|
557
1145
|
"color-picker__preview--medium": this.size === "medium",
|
|
558
1146
|
"color-picker__preview--small": this.size === "small",
|
|
559
1147
|
"color-picker__preview__transparent-bg": !0
|
|
560
|
-
})} style=${
|
|
1148
|
+
})} style=${m({
|
|
561
1149
|
color: this.getHexString(
|
|
562
1150
|
this.hue,
|
|
563
1151
|
this.saturation,
|
|
564
1152
|
this.brightness,
|
|
565
1153
|
this.alpha
|
|
566
1154
|
)
|
|
567
|
-
})}></div><slot slot="suffix" name="expand-icon" part="expand-icon" class="color-dropdown__trigger-icon"><cx-icon name="expand_more"></cx-icon></slot><cx-visually-hidden><slot name="label">${this.label}</slot></cx-visually-hidden></cx-button>` :
|
|
1155
|
+
})}></div><slot slot="suffix" name="expand-icon" part="expand-icon" class="color-dropdown__trigger-icon"><cx-icon name="expand_more"></cx-icon></slot><cx-visually-hidden><slot name="label">${this.label}</slot></cx-visually-hidden></cx-button>` : c`<button part="trigger" class=${_({
|
|
568
1156
|
"color-picker__preview": !0,
|
|
569
1157
|
"color-picker__preview--empty": this.isEmpty,
|
|
570
1158
|
"color-picker__preview--large": this.size === "large",
|
|
571
1159
|
"color-picker__preview--medium": this.size === "medium",
|
|
572
1160
|
"color-picker__preview--small": this.size === "small",
|
|
573
1161
|
"color-picker__preview__transparent-bg": !0
|
|
574
|
-
})} style=${
|
|
1162
|
+
})} style=${m({
|
|
575
1163
|
color: this.getHexString(
|
|
576
1164
|
this.hue,
|
|
577
1165
|
this.saturation,
|
|
578
1166
|
this.brightness,
|
|
579
1167
|
this.alpha
|
|
580
1168
|
)
|
|
581
|
-
})}><cx-visually-hidden><slot name="label">${this.label}</slot></cx-visually-hidden></button>`,
|
|
1169
|
+
})}><cx-visually-hidden><slot name="label">${this.label}</slot></cx-visually-hidden></button>`, l = u(
|
|
582
1170
|
this.tooltip,
|
|
583
|
-
() =>
|
|
584
|
-
() =>
|
|
1171
|
+
() => c`<cx-tooltip content=${this.tooltip}>${a}</cx-tooltip>`,
|
|
1172
|
+
() => a
|
|
585
1173
|
);
|
|
586
|
-
return this.inline ?
|
|
1174
|
+
return this.inline ? r : c`<cx-dropdown aria-disabled=${this.disabled ? "true" : "false"} class=${_({
|
|
587
1175
|
"color-dropdown": !0,
|
|
588
1176
|
"color-dropdown--opened": !!this.dropdown?.open
|
|
589
|
-
})} .containing-element=${this} ?disabled=${this.disabled} ?hoist=${this.hoist} @cx-after-hide=${this.handleAfterHide}><slot name="trigger" slot="trigger">${
|
|
1177
|
+
})} .containing-element=${this} ?disabled=${this.disabled} ?hoist=${this.hoist} @cx-after-hide=${this.handleAfterHide}><slot name="trigger" slot="trigger">${l}</slot>${r}</cx-dropdown>`;
|
|
590
1178
|
}
|
|
591
1179
|
};
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
"cx-button":
|
|
596
|
-
"cx-button-group":
|
|
597
|
-
"cx-dropdown":
|
|
598
|
-
"cx-
|
|
599
|
-
"cx-
|
|
600
|
-
"cx-
|
|
601
|
-
"cx-
|
|
1180
|
+
C = /* @__PURE__ */ new WeakMap();
|
|
1181
|
+
o.styles = [A, gt];
|
|
1182
|
+
o.dependencies = {
|
|
1183
|
+
"cx-button": U,
|
|
1184
|
+
"cx-button-group": ot,
|
|
1185
|
+
"cx-dropdown": W,
|
|
1186
|
+
"cx-gradient-slider": y,
|
|
1187
|
+
"cx-gradient-stop-list": w,
|
|
1188
|
+
"cx-icon": X,
|
|
1189
|
+
"cx-input": Y,
|
|
1190
|
+
"cx-option": st,
|
|
1191
|
+
"cx-select": lt,
|
|
1192
|
+
"cx-spinner": nt,
|
|
1193
|
+
"cx-tab": ct,
|
|
1194
|
+
"cx-tab-group": pt,
|
|
1195
|
+
"cx-tab-panel": dt,
|
|
1196
|
+
"cx-visually-hidden": ht
|
|
602
1197
|
};
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
],
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
],
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
],
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
],
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
],
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
],
|
|
621
|
-
|
|
1198
|
+
s([
|
|
1199
|
+
k('[part~="base"]')
|
|
1200
|
+
], o.prototype, "base", 2);
|
|
1201
|
+
s([
|
|
1202
|
+
k('[part~="input"]')
|
|
1203
|
+
], o.prototype, "input", 2);
|
|
1204
|
+
s([
|
|
1205
|
+
k('[part~="opacity-input"]')
|
|
1206
|
+
], o.prototype, "opacityInput", 2);
|
|
1207
|
+
s([
|
|
1208
|
+
k(".color-dropdown")
|
|
1209
|
+
], o.prototype, "dropdown", 2);
|
|
1210
|
+
s([
|
|
1211
|
+
k(".color-picker__tabs")
|
|
1212
|
+
], o.prototype, "tabGroup", 2);
|
|
1213
|
+
s([
|
|
1214
|
+
k('[part~="preview"]')
|
|
1215
|
+
], o.prototype, "previewButton", 2);
|
|
1216
|
+
s([
|
|
1217
|
+
k('[part~="trigger"]')
|
|
1218
|
+
], o.prototype, "trigger", 2);
|
|
1219
|
+
s([
|
|
1220
|
+
g()
|
|
1221
|
+
], o.prototype, "hasFocus", 2);
|
|
1222
|
+
s([
|
|
1223
|
+
g()
|
|
1224
|
+
], o.prototype, "isDraggingGridHandle", 2);
|
|
1225
|
+
s([
|
|
1226
|
+
g()
|
|
1227
|
+
], o.prototype, "isEmpty", 2);
|
|
1228
|
+
s([
|
|
622
1229
|
g()
|
|
623
|
-
],
|
|
624
|
-
|
|
1230
|
+
], o.prototype, "inputColorValue", 2);
|
|
1231
|
+
s([
|
|
625
1232
|
g()
|
|
626
|
-
],
|
|
627
|
-
|
|
1233
|
+
], o.prototype, "inputOpacityValue", 2);
|
|
1234
|
+
s([
|
|
628
1235
|
g()
|
|
629
|
-
],
|
|
630
|
-
|
|
1236
|
+
], o.prototype, "hue", 2);
|
|
1237
|
+
s([
|
|
631
1238
|
g()
|
|
632
|
-
],
|
|
633
|
-
|
|
1239
|
+
], o.prototype, "saturation", 2);
|
|
1240
|
+
s([
|
|
634
1241
|
g()
|
|
635
|
-
],
|
|
636
|
-
|
|
1242
|
+
], o.prototype, "brightness", 2);
|
|
1243
|
+
s([
|
|
637
1244
|
g()
|
|
638
|
-
],
|
|
639
|
-
|
|
1245
|
+
], o.prototype, "alpha", 2);
|
|
1246
|
+
s([
|
|
640
1247
|
g()
|
|
641
|
-
],
|
|
642
|
-
|
|
1248
|
+
], o.prototype, "gradientValue", 2);
|
|
1249
|
+
s([
|
|
643
1250
|
g()
|
|
644
|
-
],
|
|
645
|
-
|
|
1251
|
+
], o.prototype, "activeStopId", 2);
|
|
1252
|
+
s([
|
|
646
1253
|
g()
|
|
647
|
-
],
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
],
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
],
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
],
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
],
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
],
|
|
663
|
-
|
|
664
|
-
|
|
1254
|
+
], o.prototype, "parsedSwatches", 2);
|
|
1255
|
+
s([
|
|
1256
|
+
g()
|
|
1257
|
+
], o.prototype, "parsedCustomSwatches", 2);
|
|
1258
|
+
s([
|
|
1259
|
+
n({ reflect: !0, type: String })
|
|
1260
|
+
], o.prototype, "value", 2);
|
|
1261
|
+
s([
|
|
1262
|
+
it()
|
|
1263
|
+
], o.prototype, "defaultValue", 2);
|
|
1264
|
+
s([
|
|
1265
|
+
n()
|
|
1266
|
+
], o.prototype, "label", 2);
|
|
1267
|
+
s([
|
|
1268
|
+
n({ reflect: !0, type: String })
|
|
1269
|
+
], o.prototype, "variant", 2);
|
|
1270
|
+
s([
|
|
1271
|
+
n()
|
|
1272
|
+
], o.prototype, "format", 2);
|
|
1273
|
+
s([
|
|
1274
|
+
n({
|
|
665
1275
|
attribute: "formats",
|
|
666
1276
|
converter: {
|
|
667
1277
|
fromAttribute: (t) => t?.split(" ") ?? [],
|
|
668
1278
|
toAttribute: (t) => t.join(" ")
|
|
669
1279
|
}
|
|
670
1280
|
})
|
|
671
|
-
],
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
],
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
],
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
],
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
],
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
],
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
],
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
],
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
],
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
],
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
],
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
],
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
],
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
],
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
],
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
],
|
|
723
|
-
|
|
1281
|
+
], o.prototype, "formats", 2);
|
|
1282
|
+
s([
|
|
1283
|
+
n({ attribute: "emit-format", reflect: !0, type: String })
|
|
1284
|
+
], o.prototype, "emitFormat", 2);
|
|
1285
|
+
s([
|
|
1286
|
+
n({ reflect: !0, type: Boolean })
|
|
1287
|
+
], o.prototype, "inline", 2);
|
|
1288
|
+
s([
|
|
1289
|
+
n({ type: Boolean })
|
|
1290
|
+
], o.prototype, "gradient", 2);
|
|
1291
|
+
s([
|
|
1292
|
+
n({ reflect: !0, type: String })
|
|
1293
|
+
], o.prototype, "mode", 2);
|
|
1294
|
+
s([
|
|
1295
|
+
n({
|
|
1296
|
+
attribute: "gradient-types",
|
|
1297
|
+
converter: {
|
|
1298
|
+
fromAttribute: (t) => t?.split(" ") ?? [],
|
|
1299
|
+
toAttribute: (t) => t.join(" ")
|
|
1300
|
+
}
|
|
1301
|
+
})
|
|
1302
|
+
], o.prototype, "gradientTypes", 2);
|
|
1303
|
+
s([
|
|
1304
|
+
n({ reflect: !0 })
|
|
1305
|
+
], o.prototype, "size", 2);
|
|
1306
|
+
s([
|
|
1307
|
+
n({ attribute: "no-format-toggle", type: Boolean })
|
|
1308
|
+
], o.prototype, "noFormatToggle", 2);
|
|
1309
|
+
s([
|
|
1310
|
+
n()
|
|
1311
|
+
], o.prototype, "name", 2);
|
|
1312
|
+
s([
|
|
1313
|
+
n({ reflect: !0, type: Boolean })
|
|
1314
|
+
], o.prototype, "disabled", 2);
|
|
1315
|
+
s([
|
|
1316
|
+
n({ type: Boolean })
|
|
1317
|
+
], o.prototype, "hoist", 2);
|
|
1318
|
+
s([
|
|
1319
|
+
n({ type: Boolean })
|
|
1320
|
+
], o.prototype, "opacity", 2);
|
|
1321
|
+
s([
|
|
1322
|
+
n({ type: Boolean })
|
|
1323
|
+
], o.prototype, "uppercase", 2);
|
|
1324
|
+
s([
|
|
1325
|
+
n({ type: Boolean })
|
|
1326
|
+
], o.prototype, "clearable", 2);
|
|
1327
|
+
s([
|
|
1328
|
+
n({ type: String })
|
|
1329
|
+
], o.prototype, "tooltip", 2);
|
|
1330
|
+
s([
|
|
1331
|
+
n()
|
|
1332
|
+
], o.prototype, "swatches", 2);
|
|
1333
|
+
s([
|
|
1334
|
+
n({ attribute: "custom-swatches", reflect: !0 })
|
|
1335
|
+
], o.prototype, "customSwatches", 2);
|
|
1336
|
+
s([
|
|
1337
|
+
n({ reflect: !0, type: Boolean })
|
|
1338
|
+
], o.prototype, "loading", 2);
|
|
1339
|
+
s([
|
|
1340
|
+
n({ reflect: !0, type: Boolean })
|
|
1341
|
+
], o.prototype, "creatable", 2);
|
|
1342
|
+
s([
|
|
1343
|
+
n({ reflect: !1 })
|
|
1344
|
+
], o.prototype, "form", 2);
|
|
1345
|
+
s([
|
|
1346
|
+
n({ reflect: !0, type: Boolean })
|
|
1347
|
+
], o.prototype, "required", 2);
|
|
1348
|
+
s([
|
|
724
1349
|
g()
|
|
725
|
-
],
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
],
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
],
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
],
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
],
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
],
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
],
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
],
|
|
1350
|
+
], o.prototype, "emitValue", 2);
|
|
1351
|
+
s([
|
|
1352
|
+
q(300)
|
|
1353
|
+
], o.prototype, "debouncedSetColor", 1);
|
|
1354
|
+
s([
|
|
1355
|
+
q(300)
|
|
1356
|
+
], o.prototype, "setOpacity", 1);
|
|
1357
|
+
s([
|
|
1358
|
+
at({ passive: !1 })
|
|
1359
|
+
], o.prototype, "handleTouchMove", 1);
|
|
1360
|
+
s([
|
|
1361
|
+
S("format", { waitUntilFirstUpdate: !0 })
|
|
1362
|
+
], o.prototype, "handleFormatChange", 1);
|
|
1363
|
+
s([
|
|
1364
|
+
S("opacity", { waitUntilFirstUpdate: !0 })
|
|
1365
|
+
], o.prototype, "handleOpacityChange", 1);
|
|
1366
|
+
s([
|
|
1367
|
+
S("swatches")
|
|
1368
|
+
], o.prototype, "handleSwatchesChange", 1);
|
|
1369
|
+
s([
|
|
1370
|
+
S("customSwatches")
|
|
1371
|
+
], o.prototype, "handleCustomSwatchesChange", 1);
|
|
1372
|
+
s([
|
|
1373
|
+
S("mode")
|
|
1374
|
+
], o.prototype, "handleModeChange", 1);
|
|
1375
|
+
s([
|
|
1376
|
+
S("value")
|
|
1377
|
+
], o.prototype, "handleValueChange", 1);
|
|
1378
|
+
o = s([
|
|
1379
|
+
O("cx-color-picker")
|
|
1380
|
+
], o);
|
|
747
1381
|
export {
|
|
748
|
-
|
|
1382
|
+
o as default
|
|
749
1383
|
};
|