@namroodinc/liquid-editorial 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1562 -177
- package/UPGRADING.md +70 -0
- package/dist/chunks/{ColourField-C2YDshDg.js → ColourField-Bd4twbaG.js} +128 -135
- package/dist/chunks/ColourField-Bd4twbaG.js.map +1 -0
- package/dist/chunks/ColourField-BdAbjgmY.cjs +2 -0
- package/dist/chunks/ColourField-BdAbjgmY.cjs.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/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/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/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/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts.map +1 -1
- 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/index.cjs +1 -1
- package/dist/index.js +1 -1
- 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/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/UPGRADING.md
CHANGED
|
@@ -2,6 +2,76 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.3.3
|
|
6
|
+
|
|
7
|
+
### Complete component guide and Fallow quality gate
|
|
8
|
+
|
|
9
|
+
The README now covers all 43 component families and 93 runtime exports, with
|
|
10
|
+
imports, practical examples, key defaults, state ownership, and accessibility
|
|
11
|
+
guidance. The catalogue includes compound components, hooks, helpers, and asset
|
|
12
|
+
aliases, with links to source stories. Detailed prop types remain in the shipped
|
|
13
|
+
TypeScript declarations.
|
|
14
|
+
|
|
15
|
+
Modal and Drawer share one Tab trap:
|
|
16
|
+
|
|
17
|
+
- Both return focus that left the panel on the next Tab, including focus that
|
|
18
|
+
fell to the page when the focused control was removed. Previously only
|
|
19
|
+
Drawer did this.
|
|
20
|
+
- Tab wraps from the focused panel itself and from untabbable focus beyond
|
|
21
|
+
either end. A radio group counts as one stop.
|
|
22
|
+
- Hidden inputs and unrendered or inert controls no longer count as the first
|
|
23
|
+
or last control, and no longer receive a dialog's initial focus.
|
|
24
|
+
- Tab inside a Popover anchored in the dialog is left to the popup. This covers
|
|
25
|
+
DateField and DateRangeField calendars, Menu, Select, Time, ColourField, and
|
|
26
|
+
custom Popovers. Previously a Drawer moved focus to its first control.
|
|
27
|
+
- A Drawer portaled into a shadow root tracks focus inside it.
|
|
28
|
+
- A Tab keydown that another handler already prevented is left alone.
|
|
29
|
+
|
|
30
|
+
EditLayout's action bar is a private component, reducing its complexity without
|
|
31
|
+
changing rail state, mounting, responsive behavior, or leave confirmation.
|
|
32
|
+
|
|
33
|
+
#### Adoption
|
|
34
|
+
|
|
35
|
+
No application code changes are required. Use the README's catalogue and Field
|
|
36
|
+
composition examples when adopting components. Continue importing `styles.css`
|
|
37
|
+
explicitly and managing data access, routing, and persistence in the application.
|
|
38
|
+
If a custom popup built on `Popover` inside a Modal or Drawer stops Tab
|
|
39
|
+
propagation only to escape the dialog's trap, remove that workaround. Update
|
|
40
|
+
tests that Tab from outside an open Modal and expect focus to stay outside: it
|
|
41
|
+
now moves to the Modal's first control (last with Shift+Tab).
|
|
42
|
+
|
|
43
|
+
Library contributors: `npm run fallow` now checks dead code, duplicates, and
|
|
44
|
+
cyclomatic/cognitive complexity together without changing report files. It runs
|
|
45
|
+
in CI and release validation. Run `npm run test:coverage && npm run fallow:report`
|
|
46
|
+
to update committed JSON/Markdown reports; fix required findings before merging.
|
|
47
|
+
Report rows name the export, member, package, or line, and take fixes from
|
|
48
|
+
Fallow's own suggestions without suppressions. Fallow exit 1 is classified like
|
|
49
|
+
exit 0; higher exits fail with Fallow's message. Estimated CRAP change-risk
|
|
50
|
+
advisories remain visible and non-blocking. Keep the original baseline and
|
|
51
|
+
thresholds. `npm run typecheck` now covers `scripts/`.
|
|
52
|
+
|
|
53
|
+
#### Compatibility
|
|
54
|
+
|
|
55
|
+
Public exports, props, CSS entry points, peer dependencies, and package versions
|
|
56
|
+
are unchanged. The stronger gate affects library contribution/release checks.
|
|
57
|
+
Modal's recapture of escaped focus is the most visible keyboard change; the
|
|
58
|
+
other Tab changes correct cases where focus left a dialog or landed on a control
|
|
59
|
+
that could not take it. Drawer exit timing, focus restoration, nested dialog
|
|
60
|
+
ordering, and scroll-lock behavior retain their existing contracts. Version
|
|
61
|
+
increments remain owned by the main-branch release workflow.
|
|
62
|
+
|
|
63
|
+
#### Verification
|
|
64
|
+
|
|
65
|
+
Run consuming typechecks, tests, and builds. Check Tab/Shift+Tab, Escape, opener
|
|
66
|
+
focus restoration, and nested dialogs. In a Modal and a Drawer, Tab inside an
|
|
67
|
+
open DateField calendar or Menu, press Shift+Tab after clicking non-interactive
|
|
68
|
+
dialog text, and Tab after removing the focused control. For EditLayout,
|
|
69
|
+
exercise a DateField in the Details sheet as well as responsive rail
|
|
70
|
+
changes, controlled preferences, leave confirmation, and values entered in rail
|
|
71
|
+
fields while moving between the rail and Details sheet. Library maintainers run
|
|
72
|
+
`npm run validate`, refresh the Fallow reports after coverage, and verify that
|
|
73
|
+
all README examples resolve against the built package.
|
|
74
|
+
|
|
5
75
|
## 0.3.2
|
|
6
76
|
|
|
7
77
|
### Colour picker and shared popover positioning
|
|
@@ -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 { Slider as s } from "../components/Slider/index.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();
|
|
36
34
|
}
|
|
37
|
-
function w(e
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
function w(e) {
|
|
36
|
+
return S(e)?.toHex().toUpperCase() ?? "";
|
|
37
|
+
}
|
|
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,65 @@ 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
|
}
|
|
152
146
|
//#endregion
|
|
153
147
|
//#region src/components/ColourField/panel.tsx
|
|
154
|
-
function
|
|
148
|
+
function A() {
|
|
155
149
|
return window.EyeDropper;
|
|
156
150
|
}
|
|
157
|
-
var
|
|
158
|
-
function
|
|
159
|
-
let r = t %
|
|
151
|
+
var j = () => () => {}, M = [], N = 8;
|
|
152
|
+
function P(e, t, n) {
|
|
153
|
+
let r = t % N, i = r + Math.floor((n - 1 - r) / N) * N;
|
|
160
154
|
switch (e) {
|
|
161
155
|
case "Home": return 0;
|
|
162
156
|
case "End": return n - 1;
|
|
163
157
|
case "ArrowRight": return (t + 1) % n;
|
|
164
158
|
case "ArrowLeft": return (t - 1 + n) % n;
|
|
165
|
-
case "ArrowDown": return t +
|
|
166
|
-
case "ArrowUp": return t >=
|
|
159
|
+
case "ArrowDown": return t + N < n ? t + N : r;
|
|
160
|
+
case "ArrowUp": return t >= N ? t - N : i;
|
|
167
161
|
default: return;
|
|
168
162
|
}
|
|
169
163
|
}
|
|
170
|
-
var
|
|
171
|
-
let { current: a, colour: o, commit: s } =
|
|
164
|
+
var F = c(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
165
|
+
let { current: a, colour: o, commit: s } = k({
|
|
172
166
|
value: e,
|
|
173
167
|
defaultValue: t,
|
|
174
168
|
onValueChange: n
|
|
175
169
|
});
|
|
176
|
-
return /* @__PURE__ */
|
|
170
|
+
return /* @__PURE__ */ g(I, {
|
|
177
171
|
...r,
|
|
178
172
|
ref: i,
|
|
179
173
|
colour: o,
|
|
180
174
|
current: a,
|
|
181
175
|
onColourChange: s
|
|
182
176
|
});
|
|
183
|
-
}),
|
|
184
|
-
let D =
|
|
177
|
+
}), I = c(function({ colour: n, current: r, onColourChange: i, presets: a = M, showPresets: o = !0, picker: c = "custom", isDisabled: v = !1, className: y, style: b, ...x }, E) {
|
|
178
|
+
let D = f(null), k = f(!0), F = f(v), [I, L] = p(!1), [R, z] = p(""), B = m(j, () => !!A(), () => !1), V = u(), H = w(r), U = C({
|
|
185
179
|
...n,
|
|
186
180
|
a: 1
|
|
187
|
-
}), W =
|
|
181
|
+
}), W = d(() => {
|
|
188
182
|
let e = /* @__PURE__ */ new Map();
|
|
189
183
|
for (let t of a) {
|
|
190
|
-
let n =
|
|
184
|
+
let n = w(t);
|
|
191
185
|
n && !e.has(n) && e.set(n, t);
|
|
192
186
|
}
|
|
193
187
|
return [...e].map(([e, t]) => ({
|
|
@@ -195,30 +189,30 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
195
189
|
preset: t
|
|
196
190
|
}));
|
|
197
191
|
}, [a]), G = W.findIndex((e) => e.normalised === H);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}, [v]),
|
|
201
|
-
|
|
192
|
+
l(() => {
|
|
193
|
+
F.current = v;
|
|
194
|
+
}, [v]), l(() => (k.current = !0, () => {
|
|
195
|
+
k.current = !1;
|
|
202
196
|
}), []);
|
|
203
197
|
let K = async () => {
|
|
204
|
-
let e =
|
|
205
|
-
if (!(!e || v ||
|
|
198
|
+
let e = A();
|
|
199
|
+
if (!(!e || v || I)) {
|
|
206
200
|
L(!0), z("");
|
|
207
201
|
try {
|
|
208
202
|
let t = await new e().open();
|
|
209
|
-
|
|
210
|
-
...
|
|
203
|
+
k.current && !F.current && S(t.sRGBHex) && i({
|
|
204
|
+
...T(t.sRGBHex, n),
|
|
211
205
|
a: n.a
|
|
212
206
|
});
|
|
213
207
|
} catch (e) {
|
|
214
|
-
|
|
208
|
+
k.current && !(e instanceof DOMException && e.name === "AbortError") && z("Unable to pick a colour from the screen. Try again.");
|
|
215
209
|
} finally {
|
|
216
|
-
|
|
210
|
+
k.current && L(!1);
|
|
217
211
|
}
|
|
218
212
|
}
|
|
219
213
|
};
|
|
220
|
-
return /* @__PURE__ */
|
|
221
|
-
...
|
|
214
|
+
return /* @__PURE__ */ _("div", {
|
|
215
|
+
...x,
|
|
222
216
|
ref: E,
|
|
223
217
|
className: ["ds-colour-panel", y].filter(Boolean).join(" "),
|
|
224
218
|
"data-disabled": v || void 0,
|
|
@@ -226,32 +220,32 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
226
220
|
...b,
|
|
227
221
|
"--colour-hue": `hsl(${n.h} 100% 50%)`,
|
|
228
222
|
"--colour-rgb": U,
|
|
229
|
-
"--colour-rgba":
|
|
223
|
+
"--colour-rgba": C(n)
|
|
230
224
|
},
|
|
231
225
|
children: [
|
|
232
|
-
/* @__PURE__ */
|
|
226
|
+
/* @__PURE__ */ _("div", {
|
|
233
227
|
className: "ds-colour-panel__head",
|
|
234
|
-
children: [/* @__PURE__ */
|
|
228
|
+
children: [/* @__PURE__ */ g("span", { children: "Colour" }), /* @__PURE__ */ g("span", {
|
|
235
229
|
className: "ds-colour-panel__value",
|
|
236
230
|
children: H || "No colour"
|
|
237
231
|
})]
|
|
238
232
|
}),
|
|
239
|
-
|
|
233
|
+
c === "custom" ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g(O, {
|
|
240
234
|
colour: n,
|
|
241
235
|
isDisabled: v,
|
|
242
236
|
onChange: i
|
|
243
|
-
}), /* @__PURE__ */
|
|
237
|
+
}), /* @__PURE__ */ _("div", {
|
|
244
238
|
className: "ds-colour-panel__hue-row",
|
|
245
|
-
children: [B && /* @__PURE__ */
|
|
239
|
+
children: [B && /* @__PURE__ */ g(t, {
|
|
246
240
|
variant: "simple",
|
|
247
241
|
size: "sm",
|
|
248
242
|
isIconOnly: !0,
|
|
249
243
|
iconStart: "pipette",
|
|
250
244
|
"aria-label": "Pick from screen",
|
|
251
245
|
isDisabled: v,
|
|
252
|
-
"aria-busy":
|
|
246
|
+
"aria-busy": I || void 0,
|
|
253
247
|
onClick: () => void K()
|
|
254
|
-
}), /* @__PURE__ */
|
|
248
|
+
}), /* @__PURE__ */ g(s, {
|
|
255
249
|
className: "ds-colour-panel__hue",
|
|
256
250
|
value: n.h,
|
|
257
251
|
min: 0,
|
|
@@ -280,9 +274,9 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
280
274
|
});
|
|
281
275
|
}
|
|
282
276
|
})]
|
|
283
|
-
})] }) : /* @__PURE__ */
|
|
277
|
+
})] }) : /* @__PURE__ */ _("div", {
|
|
284
278
|
className: "ds-colour-panel__native",
|
|
285
|
-
children: [/* @__PURE__ */
|
|
279
|
+
children: [/* @__PURE__ */ g("input", {
|
|
286
280
|
ref: D,
|
|
287
281
|
type: "color",
|
|
288
282
|
value: U,
|
|
@@ -290,12 +284,12 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
290
284
|
"aria-hidden": "true",
|
|
291
285
|
disabled: v,
|
|
292
286
|
onChange: (e) => {
|
|
293
|
-
|
|
294
|
-
...
|
|
287
|
+
S(e.target.value) && i({
|
|
288
|
+
...T(e.target.value, n),
|
|
295
289
|
a: n.a
|
|
296
290
|
});
|
|
297
291
|
}
|
|
298
|
-
}), /* @__PURE__ */
|
|
292
|
+
}), /* @__PURE__ */ g(t, {
|
|
299
293
|
variant: "neutral",
|
|
300
294
|
size: "sm",
|
|
301
295
|
iconStart: "pipette",
|
|
@@ -311,12 +305,12 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
311
305
|
children: "Custom colour…"
|
|
312
306
|
})]
|
|
313
307
|
}),
|
|
314
|
-
/* @__PURE__ */
|
|
308
|
+
/* @__PURE__ */ _("div", {
|
|
315
309
|
className: "ds-colour-panel__opacity",
|
|
316
|
-
children: [/* @__PURE__ */
|
|
310
|
+
children: [/* @__PURE__ */ g("label", {
|
|
317
311
|
htmlFor: `${V}-opacity`,
|
|
318
312
|
children: "Opacity"
|
|
319
|
-
}), /* @__PURE__ */
|
|
313
|
+
}), /* @__PURE__ */ g(s, {
|
|
320
314
|
id: `${V}-opacity`,
|
|
321
315
|
className: "ds-colour-panel__alpha",
|
|
322
316
|
value: Math.round(n.a * 100),
|
|
@@ -331,24 +325,24 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
331
325
|
})
|
|
332
326
|
})]
|
|
333
327
|
}),
|
|
334
|
-
|
|
328
|
+
o && W.length > 0 && /* @__PURE__ */ _("div", {
|
|
335
329
|
className: "ds-colour-panel__presets",
|
|
336
|
-
children: [/* @__PURE__ */
|
|
330
|
+
children: [/* @__PURE__ */ g("span", {
|
|
337
331
|
id: V,
|
|
338
332
|
className: "ds-colour-panel__presets-label",
|
|
339
333
|
children: "Presets"
|
|
340
|
-
}), /* @__PURE__ */
|
|
334
|
+
}), /* @__PURE__ */ g("div", {
|
|
341
335
|
className: "ds-colour-panel__grid",
|
|
342
336
|
role: "radiogroup",
|
|
343
337
|
"aria-labelledby": V,
|
|
344
|
-
style: { "--colour-preset-columns":
|
|
338
|
+
style: { "--colour-preset-columns": N },
|
|
345
339
|
onKeyDown: (e) => {
|
|
346
|
-
let t = Array.from(e.currentTarget.querySelectorAll("[role='radio']")), n = t.indexOf(e.target), r = n < 0 ? void 0 :
|
|
340
|
+
let t = Array.from(e.currentTarget.querySelectorAll("[role='radio']")), n = t.indexOf(e.target), r = n < 0 ? void 0 : P(e.key, n, t.length);
|
|
347
341
|
r !== void 0 && (e.preventDefault(), t[r]?.focus(), t[r]?.click());
|
|
348
342
|
},
|
|
349
343
|
children: W.map(({ normalised: n, preset: r }, a) => {
|
|
350
344
|
let o = a === G;
|
|
351
|
-
return /* @__PURE__ */
|
|
345
|
+
return /* @__PURE__ */ g(t, {
|
|
352
346
|
variant: "simple",
|
|
353
347
|
size: "xs",
|
|
354
348
|
isIconOnly: !0,
|
|
@@ -360,10 +354,10 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
360
354
|
isDisabled: v,
|
|
361
355
|
className: "ds-colour-panel__preset",
|
|
362
356
|
onClick: () => i(r),
|
|
363
|
-
children: /* @__PURE__ */
|
|
357
|
+
children: /* @__PURE__ */ g("span", {
|
|
364
358
|
className: "ds-colour-swatch",
|
|
365
359
|
style: { "--colour-swatch": n },
|
|
366
|
-
children: o && /* @__PURE__ */
|
|
360
|
+
children: o && /* @__PURE__ */ g(e, {
|
|
367
361
|
name: "check",
|
|
368
362
|
size: 16,
|
|
369
363
|
strokeWidth: 3
|
|
@@ -373,26 +367,26 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
373
367
|
})
|
|
374
368
|
})]
|
|
375
369
|
}),
|
|
376
|
-
R && /* @__PURE__ */
|
|
370
|
+
R && /* @__PURE__ */ g("span", {
|
|
377
371
|
className: "ds-colour-panel__error",
|
|
378
372
|
role: "status",
|
|
379
373
|
children: R
|
|
380
374
|
})
|
|
381
375
|
]
|
|
382
376
|
});
|
|
383
|
-
}),
|
|
384
|
-
let { current: F, colour:
|
|
377
|
+
}), L = 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: A, onBlur: j, onKeyDown: M, ...N }, P) {
|
|
378
|
+
let { current: F, colour: L, commit: R } = k({
|
|
385
379
|
value: e,
|
|
386
|
-
defaultValue:
|
|
387
|
-
onValueChange:
|
|
388
|
-
}), [z, B] =
|
|
389
|
-
V && (Q ||
|
|
390
|
-
let $ = V && !Q && !
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}, [Z,
|
|
380
|
+
defaultValue: s,
|
|
381
|
+
onValueChange: c
|
|
382
|
+
}), [z, B] = p(null), [V, H] = p(!1), U = f(null), W = f(null), G = f(null), K = f(null), q = u(), J = O ?? `${q}-input`, Y = w(F), X = z?.source === Y ? z.text : Y || F, Z = !(!X.trim() || S(X)), Q = b || x;
|
|
383
|
+
V && (Q || C) && H(!1);
|
|
384
|
+
let $ = V && !Q && !C;
|
|
385
|
+
l(() => {
|
|
386
|
+
d?.(!Z), W.current?.setCustomValidity(Z ? "Enter a colour, such as #0052CC or rebeccapurple." : "");
|
|
387
|
+
}, [Z, d]), l(() => {
|
|
394
388
|
if (!$) return;
|
|
395
|
-
K.current &&
|
|
389
|
+
K.current && r(K.current)[0]?.focus({ preventScroll: !0 });
|
|
396
390
|
let e = (e) => {
|
|
397
391
|
let t = e.target;
|
|
398
392
|
t && !U.current?.contains(t) && !K.current?.contains(t) && H(!1);
|
|
@@ -408,9 +402,9 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
408
402
|
"aria-haspopup": "dialog",
|
|
409
403
|
"aria-expanded": $,
|
|
410
404
|
"aria-controls": $ ? q : void 0,
|
|
411
|
-
isDisabled: Q ||
|
|
405
|
+
isDisabled: Q || C
|
|
412
406
|
};
|
|
413
|
-
return /* @__PURE__ */
|
|
407
|
+
return /* @__PURE__ */ _("div", {
|
|
414
408
|
className: "ds-colour-field",
|
|
415
409
|
ref: U,
|
|
416
410
|
onBlur: (e) => {
|
|
@@ -419,14 +413,13 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
419
413
|
},
|
|
420
414
|
onKeyDown: (e) => {
|
|
421
415
|
if ($ && e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), te()), !$ || e.key !== "Tab" || !K.current?.contains(e.target)) return;
|
|
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));
|
|
416
|
+
let t = r(K.current);
|
|
417
|
+
(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 && E(U.current));
|
|
425
418
|
},
|
|
426
|
-
children: [/* @__PURE__ */
|
|
419
|
+
children: [/* @__PURE__ */ g(a, {
|
|
427
420
|
isLeadInteractive: !0,
|
|
428
421
|
isTrailInteractive: !0,
|
|
429
|
-
lead: /* @__PURE__ */
|
|
422
|
+
lead: /* @__PURE__ */ g(t, {
|
|
430
423
|
"aria-hidden": "true",
|
|
431
424
|
tabIndex: -1,
|
|
432
425
|
isDisabled: ne.isDisabled,
|
|
@@ -437,12 +430,12 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
437
430
|
onClick: () => {
|
|
438
431
|
G.current = W.current, $ ? te() : H(!0);
|
|
439
432
|
},
|
|
440
|
-
children: /* @__PURE__ */
|
|
433
|
+
children: /* @__PURE__ */ g("span", {
|
|
441
434
|
className: "ds-colour-swatch ds-colour-field__swatch",
|
|
442
435
|
style: { "--colour-swatch": Y || "transparent" }
|
|
443
436
|
})
|
|
444
437
|
}),
|
|
445
|
-
trail: /* @__PURE__ */
|
|
438
|
+
trail: /* @__PURE__ */ g(t, {
|
|
446
439
|
...ne,
|
|
447
440
|
variant: "simple",
|
|
448
441
|
size: "xs",
|
|
@@ -450,57 +443,57 @@ var L = s(function({ value: e, defaultValue: t, onValueChange: n, ...r }, i) {
|
|
|
450
443
|
iconStart: "chevron-down",
|
|
451
444
|
onClick: (e) => ee(e.currentTarget)
|
|
452
445
|
}),
|
|
453
|
-
children: /* @__PURE__ */
|
|
446
|
+
children: /* @__PURE__ */ g(i, {
|
|
454
447
|
...N,
|
|
455
448
|
ref: n(W, P),
|
|
456
449
|
id: J,
|
|
457
450
|
disabled: Q,
|
|
458
|
-
readOnly:
|
|
451
|
+
readOnly: C,
|
|
459
452
|
spellCheck: !1,
|
|
460
453
|
autoComplete: "off",
|
|
461
454
|
value: X,
|
|
462
|
-
"aria-invalid": Z ||
|
|
455
|
+
"aria-invalid": Z || T || D || void 0,
|
|
463
456
|
"aria-haspopup": "dialog",
|
|
464
457
|
"aria-controls": $ ? q : void 0,
|
|
465
|
-
className: ["ds-colour-field__input",
|
|
458
|
+
className: ["ds-colour-field__input", A].filter(Boolean).join(" "),
|
|
466
459
|
onChange: (e) => {
|
|
467
|
-
let t = e.target.value, n = !t.trim() || !!
|
|
460
|
+
let t = e.target.value, n = !t.trim() || !!S(t);
|
|
468
461
|
B({
|
|
469
|
-
source: n ?
|
|
462
|
+
source: n ? w(t) : Y,
|
|
470
463
|
text: t
|
|
471
|
-
}), n &&
|
|
464
|
+
}), n && R(t);
|
|
472
465
|
},
|
|
473
466
|
onBlur: (e) => {
|
|
474
|
-
Z || B(null),
|
|
467
|
+
Z || B(null), j?.(e);
|
|
475
468
|
},
|
|
476
469
|
onKeyDown: (e) => {
|
|
477
|
-
M?.(e), !e.defaultPrevented && (e.key === "Enter" && !Z && (e.preventDefault(), B(null)), e.key === "ArrowDown" && !Q && !
|
|
470
|
+
M?.(e), !e.defaultPrevented && (e.key === "Enter" && !Z && (e.preventDefault(), B(null)), e.key === "ArrowDown" && !Q && !C && (e.preventDefault(), G.current = e.currentTarget, H(!0)));
|
|
478
471
|
}
|
|
479
472
|
})
|
|
480
|
-
}), /* @__PURE__ */
|
|
473
|
+
}), /* @__PURE__ */ g(o, {
|
|
481
474
|
anchorRef: W,
|
|
482
475
|
anchorId: J,
|
|
483
476
|
isOpen: $,
|
|
484
|
-
placement:
|
|
477
|
+
placement: y,
|
|
485
478
|
panelRef: K,
|
|
486
479
|
id: q,
|
|
487
480
|
role: "dialog",
|
|
488
481
|
"aria-label": "Choose a colour",
|
|
489
482
|
className: "ds-colour-field__popover",
|
|
490
|
-
children: /* @__PURE__ */
|
|
491
|
-
colour:
|
|
483
|
+
children: /* @__PURE__ */ g(I, {
|
|
484
|
+
colour: L,
|
|
492
485
|
current: Y,
|
|
493
|
-
presets:
|
|
494
|
-
showPresets:
|
|
495
|
-
picker:
|
|
486
|
+
presets: m,
|
|
487
|
+
showPresets: h,
|
|
488
|
+
picker: v,
|
|
496
489
|
onColourChange: (e) => {
|
|
497
|
-
B(null),
|
|
490
|
+
B(null), R(e);
|
|
498
491
|
}
|
|
499
492
|
})
|
|
500
493
|
})]
|
|
501
494
|
});
|
|
502
495
|
});
|
|
503
496
|
//#endregion
|
|
504
|
-
export {
|
|
497
|
+
export { F as n, L as t };
|
|
505
498
|
|
|
506
|
-
//# sourceMappingURL=ColourField-
|
|
499
|
+
//# sourceMappingURL=ColourField-Bd4twbaG.js.map
|