@namroodinc/liquid-editorial 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -0
- package/README.md +1576 -180
- package/UPGRADING.md +215 -0
- package/dist/chunks/ColourField-CJicr3OT.cjs +2 -0
- package/dist/chunks/ColourField-CJicr3OT.cjs.map +1 -0
- package/dist/chunks/{ColourField-C2YDshDg.js → ColourField-DjHRiFDU.js} +167 -162
- package/dist/chunks/ColourField-DjHRiFDU.js.map +1 -0
- package/dist/chunks/DatePicker-D_6CQpUd.js +296 -0
- package/dist/chunks/DatePicker-D_6CQpUd.js.map +1 -0
- package/dist/chunks/DatePicker-aSlYLjtW.cjs +2 -0
- package/dist/chunks/DatePicker-aSlYLjtW.cjs.map +1 -0
- package/dist/chunks/FormEditor-M7tNidFo.js +584 -0
- package/dist/chunks/FormEditor-M7tNidFo.js.map +1 -0
- package/dist/chunks/FormEditor-UzbPdiJo.cjs +2 -0
- package/dist/chunks/FormEditor-UzbPdiJo.cjs.map +1 -0
- package/dist/chunks/Slider-k8weRl34.cjs +2 -0
- package/dist/chunks/Slider-k8weRl34.cjs.map +1 -0
- package/dist/chunks/Slider-vdMFLX-H.js +174 -0
- package/dist/chunks/Slider-vdMFLX-H.js.map +1 -0
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs +2 -0
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs.map +1 -0
- package/dist/chunks/dialogFocus-BFoyeTpA.js +48 -0
- package/dist/chunks/dialogFocus-BFoyeTpA.js.map +1 -0
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.d.cts.map +1 -1
- package/dist/components/Choice/index.d.ts.map +1 -1
- package/dist/components/Choice/index.js +2 -0
- package/dist/components/Choice/index.js.map +1 -1
- package/dist/components/ColourField/focus.d.cts +0 -1
- package/dist/components/ColourField/focus.d.cts.map +1 -1
- package/dist/components/ColourField/focus.d.ts +0 -1
- package/dist/components/ColourField/focus.d.ts.map +1 -1
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.d.cts.map +1 -1
- package/dist/components/ColourField/index.d.ts.map +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/ColourField/value.d.cts +6 -0
- package/dist/components/ColourField/value.d.cts.map +1 -1
- package/dist/components/ColourField/value.d.ts +6 -0
- package/dist/components/ColourField/value.d.ts.map +1 -1
- package/dist/components/DatePicker/date.d.cts +9 -0
- package/dist/components/DatePicker/date.d.cts.map +1 -0
- package/dist/components/DatePicker/date.d.ts +9 -0
- package/dist/components/DatePicker/date.d.ts.map +1 -0
- package/dist/components/DatePicker/index.cjs +1 -2
- package/dist/components/DatePicker/index.d.cts +9 -6
- package/dist/components/DatePicker/index.d.cts.map +1 -1
- package/dist/components/DatePicker/index.d.ts +9 -6
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +1 -259
- package/dist/components/DatePicker/style.css +5 -0
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +69 -73
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.d.cts.map +1 -1
- package/dist/components/EditLayout/index.d.ts.map +1 -1
- package/dist/components/EditLayout/index.js +68 -55
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/Field/style.css +20 -0
- package/dist/components/FormEditor/README.md +375 -0
- package/dist/components/FormEditor/additional-control.d.cts +6 -0
- package/dist/components/FormEditor/additional-control.d.cts.map +1 -0
- package/dist/components/FormEditor/additional-control.d.ts +6 -0
- package/dist/components/FormEditor/additional-control.d.ts.map +1 -0
- package/dist/components/FormEditor/choice-control.d.cts +6 -0
- package/dist/components/FormEditor/choice-control.d.cts.map +1 -0
- package/dist/components/FormEditor/choice-control.d.ts +6 -0
- package/dist/components/FormEditor/choice-control.d.ts.map +1 -0
- package/dist/components/FormEditor/control.d.cts +8 -0
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts +8 -0
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts +1 -1
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts +1 -1
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/FormEditor/model.d.cts +68 -2
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +68 -2
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/FormEditor/style.css +12 -0
- package/dist/components/Grid/style.css +2 -1
- package/dist/components/ImageCropper/index.cjs +1 -1
- package/dist/components/ImageCropper/index.cjs.map +1 -1
- package/dist/components/ImageCropper/index.js +6 -6
- package/dist/components/ImageCropper/index.js.map +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +40 -48
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.cjs.map +1 -1
- package/dist/components/NumberField/index.d.cts.map +1 -1
- package/dist/components/NumberField/index.d.ts.map +1 -1
- package/dist/components/NumberField/index.js +4 -0
- package/dist/components/NumberField/index.js.map +1 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts +2 -0
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts +2 -0
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +45 -44
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.cjs.map +1 -1
- package/dist/components/SelectionCard/index.d.cts.map +1 -1
- package/dist/components/SelectionCard/index.d.ts.map +1 -1
- package/dist/components/SelectionCard/index.js +2 -1
- package/dist/components/SelectionCard/index.js.map +1 -1
- package/dist/components/Slider/index.cjs +1 -2
- package/dist/components/Slider/index.d.cts +14 -1
- package/dist/components/Slider/index.d.cts.map +1 -1
- package/dist/components/Slider/index.d.ts +14 -1
- package/dist/components/Slider/index.d.ts.map +1 -1
- package/dist/components/Slider/index.js +1 -127
- package/dist/components/Slider/scale.d.cts +13 -0
- package/dist/components/Slider/scale.d.cts.map +1 -0
- package/dist/components/Slider/scale.d.ts +13 -0
- package/dist/components/Slider/scale.d.ts.map +1 -0
- package/dist/elements.css +9 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -20
- package/dist/internal/dialogFocus.d.cts +17 -0
- package/dist/internal/dialogFocus.d.cts.map +1 -0
- package/dist/internal/dialogFocus.d.ts +17 -0
- package/dist/internal/dialogFocus.d.ts.map +1 -0
- package/dist/reset.css +2 -0
- package/dist/styles.css +1 -0
- package/package.json +2 -2
- package/dist/chunks/ColourField-C2YDshDg.js.map +0 -1
- package/dist/chunks/ColourField-Dc9533G6.cjs +0 -2
- package/dist/chunks/ColourField-Dc9533G6.cjs.map +0 -1
- package/dist/chunks/FormEditor-DRmPFe2E.js +0 -328
- package/dist/chunks/FormEditor-DRmPFe2E.js.map +0 -1
- package/dist/chunks/FormEditor-PVkvKep1.cjs +0 -2
- package/dist/chunks/FormEditor-PVkvKep1.cjs.map +0 -1
- package/dist/components/DatePicker/index.cjs.map +0 -1
- package/dist/components/DatePicker/index.js.map +0 -1
- package/dist/components/Slider/index.cjs.map +0 -1
- package/dist/components/Slider/index.js.map +0 -1
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
import { t as e } from "./Icon-XNismJDm.js";
|
|
2
2
|
import { Button as t } from "../components/Button/index.js";
|
|
3
3
|
import { t as n } from "./mergeRefs-DGM402mE.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import y from "colord
|
|
4
|
+
import { n as r } from "./dialogFocus-BFoyeTpA.js";
|
|
5
|
+
import { TextField as i } from "../components/TextField/index.js";
|
|
6
|
+
import { FieldAffix as a } from "../components/FieldAffix/index.js";
|
|
7
|
+
import { Popover as o } from "../components/Popover/index.js";
|
|
8
|
+
import { n as s } from "./Slider-vdMFLX-H.js";
|
|
9
|
+
import { forwardRef as c, useEffect as l, useId as u, useMemo as d, useRef as f, useState as p, useSyncExternalStore as m } from "react";
|
|
10
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
11
|
+
import { colord as v, extend as y } from "colord";
|
|
12
|
+
import b from "colord/plugins/names";
|
|
12
13
|
//#region src/components/ColourField/colour.ts
|
|
13
|
-
|
|
14
|
-
var
|
|
14
|
+
y([b]);
|
|
15
|
+
var x = {
|
|
15
16
|
h: 0,
|
|
16
17
|
s: 100,
|
|
17
18
|
v: 0,
|
|
18
19
|
a: 1
|
|
19
20
|
};
|
|
20
|
-
function
|
|
21
|
+
function S(e) {
|
|
21
22
|
let t = e.trim();
|
|
22
23
|
if (!t) return null;
|
|
23
|
-
let n = t.replace(/^#/, ""), r = n.length < 5 ? [...n].map((e) => e + e).join("") : n, i = /^(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i.test(n) ?
|
|
24
|
+
let n = t.replace(/^#/, ""), r = n.length < 5 ? [...n].map((e) => e + e).join("") : n, i = /^(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i.test(n) ? v({
|
|
24
25
|
r: parseInt(r.slice(0, 2), 16),
|
|
25
26
|
g: parseInt(r.slice(2, 4), 16),
|
|
26
27
|
b: parseInt(r.slice(4, 6), 16),
|
|
27
28
|
a: r.length === 8 ? parseInt(r.slice(6), 16) / 255 : 1
|
|
28
|
-
}) :
|
|
29
|
+
}) : v(t);
|
|
29
30
|
return i.isValid() ? i : null;
|
|
30
31
|
}
|
|
31
|
-
function S(e) {
|
|
32
|
-
return _(e).toHex().toUpperCase();
|
|
33
|
-
}
|
|
34
32
|
function C(e) {
|
|
35
|
-
return
|
|
33
|
+
return v(e).toHex().toUpperCase();
|
|
34
|
+
}
|
|
35
|
+
function w(e) {
|
|
36
|
+
return S(e)?.toHex().toUpperCase() ?? "";
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
let n =
|
|
39
|
-
if (!n || n.toHex().toUpperCase() ===
|
|
38
|
+
function T(e, t = x) {
|
|
39
|
+
let n = S(e);
|
|
40
|
+
if (!n || n.toHex().toUpperCase() === C(t)) return t;
|
|
40
41
|
let { r, g: i, b: a, a: o } = n.rgba, s = Math.max(r, i, a), c = s - Math.min(r, i, a), l = c === 0 ? t.h : s === r ? (i - a) / c * 60 : s === i ? ((a - r) / c + 2) * 60 : ((r - i) / c + 4) * 60;
|
|
41
42
|
l < 0 && (l += 360);
|
|
42
43
|
let u = {
|
|
@@ -53,32 +54,25 @@ function w(e, t = b) {
|
|
|
53
54
|
}
|
|
54
55
|
//#endregion
|
|
55
56
|
//#region src/components/ColourField/focus.ts
|
|
56
|
-
var T = ":is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])";
|
|
57
57
|
function E(e) {
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
function D(e) {
|
|
61
|
-
return Array.from(e.querySelectorAll(T)).filter(E);
|
|
62
|
-
}
|
|
63
|
-
function O(e) {
|
|
64
|
-
let t = D(e.closest("[aria-modal='true']") ?? document.body).filter((e) => !e.closest(".ds-popover") && !e.closest("[inert]"));
|
|
65
|
-
(t[t.map((t) => e.contains(t)).lastIndexOf(!0) + 1] ?? t[0])?.focus({ preventScroll: !0 });
|
|
58
|
+
let t = e.closest("[aria-modal='true']") ?? document.body, n = r(t).filter((e) => !e.closest(".ds-popover"));
|
|
59
|
+
(n[n.map((t) => e.contains(t)).lastIndexOf(!0) + 1] ?? n[0])?.focus({ preventScroll: !0 });
|
|
66
60
|
}
|
|
67
61
|
//#endregion
|
|
68
62
|
//#region src/components/ColourField/square.tsx
|
|
69
|
-
function
|
|
63
|
+
function D(e) {
|
|
70
64
|
return Math.max(0, Math.min(100, e));
|
|
71
65
|
}
|
|
72
|
-
function
|
|
73
|
-
let r =
|
|
66
|
+
function O({ colour: e, isDisabled: t, onChange: n }) {
|
|
67
|
+
let r = f(null), i = (t) => {
|
|
74
68
|
let r = t.currentTarget.getBoundingClientRect();
|
|
75
69
|
r.width && r.height && n({
|
|
76
70
|
...e,
|
|
77
|
-
s:
|
|
78
|
-
v:
|
|
71
|
+
s: D((t.clientX - r.left) / r.width * 100),
|
|
72
|
+
v: D((1 - (t.clientY - r.top) / r.height) * 100)
|
|
79
73
|
});
|
|
80
74
|
};
|
|
81
|
-
return /* @__PURE__ */
|
|
75
|
+
return /* @__PURE__ */ g("div", {
|
|
82
76
|
className: "ds-colour-panel__square",
|
|
83
77
|
role: "slider",
|
|
84
78
|
tabIndex: t ? -1 : 0,
|
|
@@ -91,10 +85,10 @@ function A({ colour: e, isDisabled: t, onChange: n }) {
|
|
|
91
85
|
onKeyDown: (r) => {
|
|
92
86
|
if (t) return;
|
|
93
87
|
let i = r.shiftKey ? 10 : 1, a = {
|
|
94
|
-
ArrowLeft: { s:
|
|
95
|
-
ArrowRight: { s:
|
|
96
|
-
ArrowDown: { v:
|
|
97
|
-
ArrowUp: { v:
|
|
88
|
+
ArrowLeft: { s: D(e.s - i) },
|
|
89
|
+
ArrowRight: { s: D(e.s + i) },
|
|
90
|
+
ArrowDown: { v: D(e.v - i) },
|
|
91
|
+
ArrowUp: { v: D(e.v + i) },
|
|
98
92
|
Home: { s: 0 },
|
|
99
93
|
End: { s: 100 }
|
|
100
94
|
}[r.key];
|
|
@@ -118,7 +112,7 @@ function A({ colour: e, isDisabled: t, onChange: n }) {
|
|
|
118
112
|
onLostPointerCapture: () => {
|
|
119
113
|
r.current = null;
|
|
120
114
|
},
|
|
121
|
-
children: /* @__PURE__ */
|
|
115
|
+
children: /* @__PURE__ */ g("span", {
|
|
122
116
|
className: "ds-colour-panel__thumb",
|
|
123
117
|
style: {
|
|
124
118
|
left: `${e.s}%`,
|
|
@@ -129,65 +123,79 @@ function A({ colour: e, isDisabled: t, onChange: n }) {
|
|
|
129
123
|
}
|
|
130
124
|
//#endregion
|
|
131
125
|
//#region src/components/ColourField/value.ts
|
|
132
|
-
function
|
|
133
|
-
let [r, i] =
|
|
126
|
+
function k({ value: e, defaultValue: t = "", onValueChange: n }) {
|
|
127
|
+
let [r, i] = p(t), a = e ?? r, [o, s] = p(() => ({
|
|
134
128
|
source: a,
|
|
135
|
-
colour:
|
|
129
|
+
colour: T(a)
|
|
136
130
|
})), c = o.colour;
|
|
137
|
-
return o.source !== a && (c =
|
|
131
|
+
return o.source !== a && (c = T(a, c), s({
|
|
138
132
|
source: a,
|
|
139
133
|
colour: c
|
|
140
134
|
})), {
|
|
141
135
|
current: a,
|
|
142
136
|
colour: c,
|
|
143
137
|
commit: (t) => {
|
|
144
|
-
let r = typeof t == "string" ?
|
|
138
|
+
let r = typeof t == "string" ? w(t) : C(t);
|
|
145
139
|
s({
|
|
146
140
|
source: r,
|
|
147
|
-
colour: typeof t == "string" ?
|
|
141
|
+
colour: typeof t == "string" ? T(t, c) : t
|
|
148
142
|
}), e === void 0 && i(r), n?.(r);
|
|
149
143
|
}
|
|
150
144
|
};
|
|
151
145
|
}
|
|
146
|
+
function A(e, t) {
|
|
147
|
+
let [n, r] = p(null);
|
|
148
|
+
return n && n.source !== e && n.text === e && r({
|
|
149
|
+
source: e,
|
|
150
|
+
text: e
|
|
151
|
+
}), {
|
|
152
|
+
text: n?.source === e ? n.text : t || e,
|
|
153
|
+
type: (t, n) => r({
|
|
154
|
+
source: n ? w(t) : e,
|
|
155
|
+
text: t
|
|
156
|
+
}),
|
|
157
|
+
discard: () => r(null)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
152
160
|
//#endregion
|
|
153
161
|
//#region src/components/ColourField/panel.tsx
|
|
154
|
-
function
|
|
162
|
+
function j() {
|
|
155
163
|
return window.EyeDropper;
|
|
156
164
|
}
|
|
157
|
-
var
|
|
158
|
-
function
|
|
159
|
-
let r = t %
|
|
165
|
+
var M = () => () => {}, N = [], P = 8;
|
|
166
|
+
function F(e, t, n) {
|
|
167
|
+
let r = t % P, i = r + Math.floor((n - 1 - r) / P) * P;
|
|
160
168
|
switch (e) {
|
|
161
169
|
case "Home": return 0;
|
|
162
170
|
case "End": return n - 1;
|
|
163
171
|
case "ArrowRight": return (t + 1) % n;
|
|
164
172
|
case "ArrowLeft": return (t - 1 + n) % n;
|
|
165
|
-
case "ArrowDown": return t +
|
|
166
|
-
case "ArrowUp": return t >=
|
|
173
|
+
case "ArrowDown": return t + P < n ? t + P : r;
|
|
174
|
+
case "ArrowUp": return t >= P ? t - P : i;
|
|
167
175
|
default: return;
|
|
168
176
|
}
|
|
169
177
|
}
|
|
170
|
-
var
|
|
171
|
-
let { current: a, colour: o, commit: s } =
|
|
178
|
+
var I = c(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
179
|
+
let { current: a, colour: o, commit: s } = k({
|
|
172
180
|
value: e,
|
|
173
181
|
defaultValue: t,
|
|
174
182
|
onValueChange: n
|
|
175
183
|
});
|
|
176
|
-
return /* @__PURE__ */
|
|
184
|
+
return /* @__PURE__ */ g(L, {
|
|
177
185
|
...r,
|
|
178
186
|
ref: i,
|
|
179
187
|
colour: o,
|
|
180
188
|
current: a,
|
|
181
189
|
onColourChange: s
|
|
182
190
|
});
|
|
183
|
-
}),
|
|
184
|
-
let D =
|
|
191
|
+
}), L = c(function({ colour: n, current: r, onColourChange: i, presets: a = N, showPresets: o = !0, picker: c = "custom", isDisabled: v = !1, className: y, style: b, ...x }, E) {
|
|
192
|
+
let D = f(null), k = f(!0), A = f(v), [I, L] = p(!1), [R, z] = p(""), B = m(M, () => !!j(), () => !1), V = u(), H = w(r), U = C({
|
|
185
193
|
...n,
|
|
186
194
|
a: 1
|
|
187
|
-
}), W =
|
|
195
|
+
}), W = d(() => {
|
|
188
196
|
let e = /* @__PURE__ */ new Map();
|
|
189
197
|
for (let t of a) {
|
|
190
|
-
let n =
|
|
198
|
+
let n = w(t);
|
|
191
199
|
n && !e.has(n) && e.set(n, t);
|
|
192
200
|
}
|
|
193
201
|
return [...e].map(([e, t]) => ({
|
|
@@ -195,30 +203,30 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
195
203
|
preset: t
|
|
196
204
|
}));
|
|
197
205
|
}, [a]), G = W.findIndex((e) => e.normalised === H);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}, [v]),
|
|
201
|
-
|
|
206
|
+
l(() => {
|
|
207
|
+
A.current = v;
|
|
208
|
+
}, [v]), l(() => (k.current = !0, () => {
|
|
209
|
+
k.current = !1;
|
|
202
210
|
}), []);
|
|
203
211
|
let K = async () => {
|
|
204
|
-
let e =
|
|
205
|
-
if (!(!e || v ||
|
|
212
|
+
let e = j();
|
|
213
|
+
if (!(!e || v || I)) {
|
|
206
214
|
L(!0), z("");
|
|
207
215
|
try {
|
|
208
216
|
let t = await new e().open();
|
|
209
|
-
|
|
210
|
-
...
|
|
217
|
+
k.current && !A.current && S(t.sRGBHex) && i({
|
|
218
|
+
...T(t.sRGBHex, n),
|
|
211
219
|
a: n.a
|
|
212
220
|
});
|
|
213
221
|
} catch (e) {
|
|
214
|
-
|
|
222
|
+
k.current && !(e instanceof DOMException && e.name === "AbortError") && z("Unable to pick a colour from the screen. Try again.");
|
|
215
223
|
} finally {
|
|
216
|
-
|
|
224
|
+
k.current && L(!1);
|
|
217
225
|
}
|
|
218
226
|
}
|
|
219
227
|
};
|
|
220
|
-
return /* @__PURE__ */
|
|
221
|
-
...
|
|
228
|
+
return /* @__PURE__ */ _("div", {
|
|
229
|
+
...x,
|
|
222
230
|
ref: E,
|
|
223
231
|
className: ["ds-colour-panel", y].filter(Boolean).join(" "),
|
|
224
232
|
"data-disabled": v || void 0,
|
|
@@ -226,32 +234,32 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
226
234
|
...b,
|
|
227
235
|
"--colour-hue": `hsl(${n.h} 100% 50%)`,
|
|
228
236
|
"--colour-rgb": U,
|
|
229
|
-
"--colour-rgba":
|
|
237
|
+
"--colour-rgba": C(n)
|
|
230
238
|
},
|
|
231
239
|
children: [
|
|
232
|
-
/* @__PURE__ */
|
|
240
|
+
/* @__PURE__ */ _("div", {
|
|
233
241
|
className: "ds-colour-panel__head",
|
|
234
|
-
children: [/* @__PURE__ */
|
|
242
|
+
children: [/* @__PURE__ */ g("span", { children: "Colour" }), /* @__PURE__ */ g("span", {
|
|
235
243
|
className: "ds-colour-panel__value",
|
|
236
244
|
children: H || "No colour"
|
|
237
245
|
})]
|
|
238
246
|
}),
|
|
239
|
-
|
|
247
|
+
c === "custom" ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g(O, {
|
|
240
248
|
colour: n,
|
|
241
249
|
isDisabled: v,
|
|
242
250
|
onChange: i
|
|
243
|
-
}), /* @__PURE__ */
|
|
251
|
+
}), /* @__PURE__ */ _("div", {
|
|
244
252
|
className: "ds-colour-panel__hue-row",
|
|
245
|
-
children: [B && /* @__PURE__ */
|
|
253
|
+
children: [B && /* @__PURE__ */ g(t, {
|
|
246
254
|
variant: "simple",
|
|
247
255
|
size: "sm",
|
|
248
256
|
isIconOnly: !0,
|
|
249
257
|
iconStart: "pipette",
|
|
250
258
|
"aria-label": "Pick from screen",
|
|
251
259
|
isDisabled: v,
|
|
252
|
-
"aria-busy":
|
|
260
|
+
"aria-busy": I || void 0,
|
|
253
261
|
onClick: () => void K()
|
|
254
|
-
}), /* @__PURE__ */
|
|
262
|
+
}), /* @__PURE__ */ g(s, {
|
|
255
263
|
className: "ds-colour-panel__hue",
|
|
256
264
|
value: n.h,
|
|
257
265
|
min: 0,
|
|
@@ -280,9 +288,9 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
280
288
|
});
|
|
281
289
|
}
|
|
282
290
|
})]
|
|
283
|
-
})] }) : /* @__PURE__ */
|
|
291
|
+
})] }) : /* @__PURE__ */ _("div", {
|
|
284
292
|
className: "ds-colour-panel__native",
|
|
285
|
-
children: [/* @__PURE__ */
|
|
293
|
+
children: [/* @__PURE__ */ g("input", {
|
|
286
294
|
ref: D,
|
|
287
295
|
type: "color",
|
|
288
296
|
value: U,
|
|
@@ -290,12 +298,12 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
290
298
|
"aria-hidden": "true",
|
|
291
299
|
disabled: v,
|
|
292
300
|
onChange: (e) => {
|
|
293
|
-
|
|
294
|
-
...
|
|
301
|
+
S(e.target.value) && i({
|
|
302
|
+
...T(e.target.value, n),
|
|
295
303
|
a: n.a
|
|
296
304
|
});
|
|
297
305
|
}
|
|
298
|
-
}), /* @__PURE__ */
|
|
306
|
+
}), /* @__PURE__ */ g(t, {
|
|
299
307
|
variant: "neutral",
|
|
300
308
|
size: "sm",
|
|
301
309
|
iconStart: "pipette",
|
|
@@ -311,12 +319,12 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
311
319
|
children: "Custom colour…"
|
|
312
320
|
})]
|
|
313
321
|
}),
|
|
314
|
-
/* @__PURE__ */
|
|
322
|
+
/* @__PURE__ */ _("div", {
|
|
315
323
|
className: "ds-colour-panel__opacity",
|
|
316
|
-
children: [/* @__PURE__ */
|
|
324
|
+
children: [/* @__PURE__ */ g("label", {
|
|
317
325
|
htmlFor: `${V}-opacity`,
|
|
318
326
|
children: "Opacity"
|
|
319
|
-
}), /* @__PURE__ */
|
|
327
|
+
}), /* @__PURE__ */ g(s, {
|
|
320
328
|
id: `${V}-opacity`,
|
|
321
329
|
className: "ds-colour-panel__alpha",
|
|
322
330
|
value: Math.round(n.a * 100),
|
|
@@ -331,24 +339,24 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
331
339
|
})
|
|
332
340
|
})]
|
|
333
341
|
}),
|
|
334
|
-
|
|
342
|
+
o && W.length > 0 && /* @__PURE__ */ _("div", {
|
|
335
343
|
className: "ds-colour-panel__presets",
|
|
336
|
-
children: [/* @__PURE__ */
|
|
344
|
+
children: [/* @__PURE__ */ g("span", {
|
|
337
345
|
id: V,
|
|
338
346
|
className: "ds-colour-panel__presets-label",
|
|
339
347
|
children: "Presets"
|
|
340
|
-
}), /* @__PURE__ */
|
|
348
|
+
}), /* @__PURE__ */ g("div", {
|
|
341
349
|
className: "ds-colour-panel__grid",
|
|
342
350
|
role: "radiogroup",
|
|
343
351
|
"aria-labelledby": V,
|
|
344
|
-
style: { "--colour-preset-columns":
|
|
352
|
+
style: { "--colour-preset-columns": P },
|
|
345
353
|
onKeyDown: (e) => {
|
|
346
|
-
let t = Array.from(e.currentTarget.querySelectorAll("[role='radio']")), n = t.indexOf(e.target), r = n < 0 ? void 0 :
|
|
354
|
+
let t = Array.from(e.currentTarget.querySelectorAll("[role='radio']")), n = t.indexOf(e.target), r = n < 0 ? void 0 : F(e.key, n, t.length);
|
|
347
355
|
r !== void 0 && (e.preventDefault(), t[r]?.focus(), t[r]?.click());
|
|
348
356
|
},
|
|
349
357
|
children: W.map(({ normalised: n, preset: r }, a) => {
|
|
350
358
|
let o = a === G;
|
|
351
|
-
return /* @__PURE__ */
|
|
359
|
+
return /* @__PURE__ */ g(t, {
|
|
352
360
|
variant: "simple",
|
|
353
361
|
size: "xs",
|
|
354
362
|
isIconOnly: !0,
|
|
@@ -360,10 +368,10 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
360
368
|
isDisabled: v,
|
|
361
369
|
className: "ds-colour-panel__preset",
|
|
362
370
|
onClick: () => i(r),
|
|
363
|
-
children: /* @__PURE__ */
|
|
371
|
+
children: /* @__PURE__ */ g("span", {
|
|
364
372
|
className: "ds-colour-swatch",
|
|
365
373
|
style: { "--colour-swatch": n },
|
|
366
|
-
children: o && /* @__PURE__ */
|
|
374
|
+
children: o && /* @__PURE__ */ g(e, {
|
|
367
375
|
name: "check",
|
|
368
376
|
size: 16,
|
|
369
377
|
strokeWidth: 3
|
|
@@ -373,134 +381,131 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
373
381
|
})
|
|
374
382
|
})]
|
|
375
383
|
}),
|
|
376
|
-
R && /* @__PURE__ */
|
|
384
|
+
R && /* @__PURE__ */ g("span", {
|
|
377
385
|
className: "ds-colour-panel__error",
|
|
378
386
|
role: "status",
|
|
379
387
|
children: R
|
|
380
388
|
})
|
|
381
389
|
]
|
|
382
390
|
});
|
|
383
|
-
}),
|
|
384
|
-
let { current:
|
|
391
|
+
}), R = c(function({ value: e, defaultValue: s, onValueChange: c, onValidityChange: d, presets: m, showPresets: h, picker: v, placement: y, isDisabled: b = !1, disabled: x, readOnly: C, isInvalid: T, "aria-invalid": D, id: O, className: j, onBlur: M, onKeyDown: N, ...P }, F) {
|
|
392
|
+
let { current: I, colour: R, commit: z } = k({
|
|
385
393
|
value: e,
|
|
386
|
-
defaultValue:
|
|
387
|
-
onValueChange:
|
|
388
|
-
}), [
|
|
389
|
-
|
|
390
|
-
let $ =
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}, [Z,
|
|
394
|
+
defaultValue: s,
|
|
395
|
+
onValueChange: c
|
|
396
|
+
}), [B, V] = p(!1), H = f(null), U = f(null), W = f(null), G = f(null), K = u(), q = O ?? `${K}-input`, J = w(I), { text: Y, type: ee, discard: X } = A(I, J), Z = !(!Y.trim() || S(Y)), Q = b || x;
|
|
397
|
+
B && (Q || C) && V(!1);
|
|
398
|
+
let $ = B && !Q && !C;
|
|
399
|
+
l(() => {
|
|
400
|
+
d?.(!Z), U.current?.setCustomValidity(Z ? "Enter a colour, such as #0052CC or rebeccapurple." : "");
|
|
401
|
+
}, [Z, d]), l(() => {
|
|
394
402
|
if (!$) return;
|
|
395
|
-
|
|
403
|
+
G.current && r(G.current)[0]?.focus({ preventScroll: !0 });
|
|
396
404
|
let e = (e) => {
|
|
397
405
|
let t = e.target;
|
|
398
|
-
t && !
|
|
406
|
+
t && !H.current?.contains(t) && !G.current?.contains(t) && V(!1);
|
|
399
407
|
};
|
|
400
408
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
401
409
|
}, [$]);
|
|
402
|
-
let
|
|
403
|
-
|
|
404
|
-
},
|
|
405
|
-
|
|
406
|
-
},
|
|
410
|
+
let te = (e) => {
|
|
411
|
+
W.current = e, V(!$);
|
|
412
|
+
}, ne = () => {
|
|
413
|
+
V(!1), W.current?.focus({ preventScroll: !0 });
|
|
414
|
+
}, re = {
|
|
407
415
|
"aria-label": $ ? "Close colour picker" : "Open colour picker",
|
|
408
416
|
"aria-haspopup": "dialog",
|
|
409
417
|
"aria-expanded": $,
|
|
410
|
-
"aria-controls": $ ?
|
|
411
|
-
isDisabled: Q ||
|
|
418
|
+
"aria-controls": $ ? K : void 0,
|
|
419
|
+
isDisabled: Q || C
|
|
412
420
|
};
|
|
413
|
-
return /* @__PURE__ */
|
|
421
|
+
return /* @__PURE__ */ _("div", {
|
|
414
422
|
className: "ds-colour-field",
|
|
415
|
-
ref:
|
|
423
|
+
ref: H,
|
|
416
424
|
onBlur: (e) => {
|
|
417
425
|
let t = e.relatedTarget;
|
|
418
|
-
t && !
|
|
426
|
+
t && !H.current?.contains(t) && !G.current?.contains(t) && V(!1);
|
|
419
427
|
},
|
|
420
428
|
onKeyDown: (e) => {
|
|
421
|
-
if ($ && e.key === "Escape" && (e.preventDefault(), e.stopPropagation(),
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
(e.shiftKey ? e.target === t[0] : e.target === t.at(-1)) && (e.preventDefault(), e.stopPropagation(), H(!1), e.shiftKey ? G.current?.focus({ preventScroll: !0 }) : U.current && O(U.current));
|
|
429
|
+
if ($ && e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), ne()), !$ || e.key !== "Tab" || !G.current?.contains(e.target)) return;
|
|
430
|
+
let t = r(G.current);
|
|
431
|
+
(e.shiftKey ? e.target === t[0] : e.target === t.at(-1)) && (e.preventDefault(), e.stopPropagation(), V(!1), e.shiftKey ? W.current?.focus({ preventScroll: !0 }) : H.current && E(H.current));
|
|
425
432
|
},
|
|
426
|
-
children: [/* @__PURE__ */
|
|
433
|
+
children: [/* @__PURE__ */ g(a, {
|
|
427
434
|
isLeadInteractive: !0,
|
|
428
435
|
isTrailInteractive: !0,
|
|
429
|
-
lead: /* @__PURE__ */
|
|
436
|
+
lead: /* @__PURE__ */ g(t, {
|
|
430
437
|
"aria-hidden": "true",
|
|
431
438
|
tabIndex: -1,
|
|
432
|
-
isDisabled:
|
|
439
|
+
isDisabled: re.isDisabled,
|
|
433
440
|
variant: "simple",
|
|
434
441
|
size: "xs",
|
|
435
442
|
isIconOnly: !0,
|
|
436
443
|
onMouseDown: (e) => e.preventDefault(),
|
|
437
444
|
onClick: () => {
|
|
438
|
-
|
|
445
|
+
W.current = U.current, $ ? ne() : V(!0);
|
|
439
446
|
},
|
|
440
|
-
children: /* @__PURE__ */
|
|
447
|
+
children: /* @__PURE__ */ g("span", {
|
|
441
448
|
className: "ds-colour-swatch ds-colour-field__swatch",
|
|
442
|
-
style: { "--colour-swatch":
|
|
449
|
+
style: { "--colour-swatch": J || "transparent" }
|
|
443
450
|
})
|
|
444
451
|
}),
|
|
445
|
-
trail: /* @__PURE__ */
|
|
446
|
-
...
|
|
452
|
+
trail: /* @__PURE__ */ g(t, {
|
|
453
|
+
...re,
|
|
447
454
|
variant: "simple",
|
|
448
455
|
size: "xs",
|
|
449
456
|
isIconOnly: !0,
|
|
450
457
|
iconStart: "chevron-down",
|
|
451
|
-
onClick: (e) =>
|
|
458
|
+
onClick: (e) => te(e.currentTarget)
|
|
452
459
|
}),
|
|
453
|
-
children: /* @__PURE__ */
|
|
454
|
-
...
|
|
455
|
-
ref: n(
|
|
456
|
-
id:
|
|
460
|
+
children: /* @__PURE__ */ g(i, {
|
|
461
|
+
...P,
|
|
462
|
+
ref: n(U, F),
|
|
463
|
+
id: q,
|
|
457
464
|
disabled: Q,
|
|
458
|
-
readOnly:
|
|
465
|
+
readOnly: C,
|
|
459
466
|
spellCheck: !1,
|
|
460
467
|
autoComplete: "off",
|
|
461
|
-
value:
|
|
462
|
-
"aria-invalid": Z ||
|
|
468
|
+
value: Y,
|
|
469
|
+
"aria-invalid": Z || T || D || void 0,
|
|
463
470
|
"aria-haspopup": "dialog",
|
|
464
|
-
"aria-controls": $ ?
|
|
465
|
-
className: ["ds-colour-field__input",
|
|
471
|
+
"aria-controls": $ ? K : void 0,
|
|
472
|
+
className: ["ds-colour-field__input", j].filter(Boolean).join(" "),
|
|
466
473
|
onChange: (e) => {
|
|
467
|
-
let t = e.target.value, n = !t.trim() || !!
|
|
468
|
-
|
|
469
|
-
source: n ? C(t) : Y,
|
|
470
|
-
text: t
|
|
471
|
-
}), n && L(t);
|
|
474
|
+
let t = e.target.value, n = !t.trim() || !!S(t);
|
|
475
|
+
ee(t, n), n && z(t);
|
|
472
476
|
},
|
|
473
477
|
onBlur: (e) => {
|
|
474
|
-
Z ||
|
|
478
|
+
Z || X(), M?.(e);
|
|
475
479
|
},
|
|
476
480
|
onKeyDown: (e) => {
|
|
477
|
-
|
|
481
|
+
N?.(e), !e.defaultPrevented && (e.key === "Enter" && !Z && (e.preventDefault(), X()), e.key === "ArrowDown" && !Q && !C && (e.preventDefault(), W.current = e.currentTarget, V(!0)));
|
|
478
482
|
}
|
|
479
483
|
})
|
|
480
|
-
}), /* @__PURE__ */
|
|
481
|
-
anchorRef:
|
|
482
|
-
anchorId:
|
|
484
|
+
}), /* @__PURE__ */ g(o, {
|
|
485
|
+
anchorRef: U,
|
|
486
|
+
anchorId: q,
|
|
483
487
|
isOpen: $,
|
|
484
|
-
placement:
|
|
485
|
-
panelRef:
|
|
486
|
-
id:
|
|
488
|
+
placement: y,
|
|
489
|
+
panelRef: G,
|
|
490
|
+
id: K,
|
|
487
491
|
role: "dialog",
|
|
488
492
|
"aria-label": "Choose a colour",
|
|
493
|
+
tabIndex: -1,
|
|
489
494
|
className: "ds-colour-field__popover",
|
|
490
|
-
children: /* @__PURE__ */
|
|
491
|
-
colour:
|
|
492
|
-
current:
|
|
493
|
-
presets:
|
|
494
|
-
showPresets:
|
|
495
|
-
picker:
|
|
495
|
+
children: /* @__PURE__ */ g(L, {
|
|
496
|
+
colour: R,
|
|
497
|
+
current: J,
|
|
498
|
+
presets: m,
|
|
499
|
+
showPresets: h,
|
|
500
|
+
picker: v,
|
|
496
501
|
onColourChange: (e) => {
|
|
497
|
-
|
|
502
|
+
X(), z(e);
|
|
498
503
|
}
|
|
499
504
|
})
|
|
500
505
|
})]
|
|
501
506
|
});
|
|
502
507
|
});
|
|
503
508
|
//#endregion
|
|
504
|
-
export {
|
|
509
|
+
export { I as n, S as r, R as t };
|
|
505
510
|
|
|
506
|
-
//# sourceMappingURL=ColourField-
|
|
511
|
+
//# sourceMappingURL=ColourField-DjHRiFDU.js.map
|