@sps-woodland/buttons 8.0.0-rc1
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 +3 -0
- package/lib/button/Button.css.d.ts +14 -0
- package/lib/button/Button.d.ts +1 -0
- package/lib/button/Button.examples.d.ts +2 -0
- package/lib/index.cjs.js +426 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.es.js +1601 -0
- package/lib/manifest.d.ts +2 -0
- package/lib/style.css +1 -0
- package/package.json +40 -0
- package/vite.config.js +21 -0
package/lib/index.es.js
ADDED
@@ -0,0 +1,1601 @@
|
|
1
|
+
import * as d from "react";
|
2
|
+
import U, { useRef as W, useCallback as R, useEffect as ie, useContext as Ke, useState as je, useMemo as ze } from "react";
|
3
|
+
import { I18nContext as Ye, Icon as qe, Spinner as Xe, cl as Je, Metadata as Qe } from "@sps-woodland/core";
|
4
|
+
import { code as m } from "@spscommerce/utils";
|
5
|
+
function Ie(e) {
|
6
|
+
var t, n, r = "";
|
7
|
+
if (typeof e == "string" || typeof e == "number")
|
8
|
+
r += e;
|
9
|
+
else if (typeof e == "object")
|
10
|
+
if (Array.isArray(e))
|
11
|
+
for (t = 0; t < e.length; t++)
|
12
|
+
e[t] && (n = Ie(e[t])) && (r && (r += " "), r += n);
|
13
|
+
else
|
14
|
+
for (t in e)
|
15
|
+
e[t] && (r && (r += " "), r += t);
|
16
|
+
return r;
|
17
|
+
}
|
18
|
+
function Me() {
|
19
|
+
for (var e, t, n = 0, r = ""; n < arguments.length; )
|
20
|
+
(e = arguments[n++]) && (t = Ie(e)) && (r && (r += " "), r += t);
|
21
|
+
return r;
|
22
|
+
}
|
23
|
+
typeof window < "u" && U.useLayoutEffect;
|
24
|
+
let pe = /* @__PURE__ */ new Map();
|
25
|
+
function Ze(e, t) {
|
26
|
+
if (e === t)
|
27
|
+
return e;
|
28
|
+
let n = pe.get(e);
|
29
|
+
if (n)
|
30
|
+
return n(t), t;
|
31
|
+
let r = pe.get(t);
|
32
|
+
return r ? (r(e), e) : t;
|
33
|
+
}
|
34
|
+
function et(...e) {
|
35
|
+
return (...t) => {
|
36
|
+
for (let n of e)
|
37
|
+
typeof n == "function" && n(...t);
|
38
|
+
};
|
39
|
+
}
|
40
|
+
function me(...e) {
|
41
|
+
let t = {
|
42
|
+
...e[0]
|
43
|
+
};
|
44
|
+
for (let n = 1; n < e.length; n++) {
|
45
|
+
let r = e[n];
|
46
|
+
for (let s in r) {
|
47
|
+
let l = t[s], u = r[s];
|
48
|
+
typeof l == "function" && typeof u == "function" && s[0] === "o" && s[1] === "n" && s.charCodeAt(2) >= 65 && s.charCodeAt(2) <= 90 ? t[s] = et(l, u) : (s === "className" || s === "UNSAFE_className") && typeof l == "string" && typeof u == "string" ? t[s] = Me(l, u) : s === "id" && l && u ? t.id = Ze(l, u) : t[s] = u !== void 0 ? u : l;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return t;
|
52
|
+
}
|
53
|
+
const tt = /* @__PURE__ */ new Set([
|
54
|
+
"id"
|
55
|
+
]), nt = /* @__PURE__ */ new Set([
|
56
|
+
"aria-label",
|
57
|
+
"aria-labelledby",
|
58
|
+
"aria-describedby",
|
59
|
+
"aria-details"
|
60
|
+
]), rt = /^(data-.*)$/;
|
61
|
+
function ot(e, t = {}) {
|
62
|
+
let { labelable: n, propNames: r } = t, s = {};
|
63
|
+
for (const l in e)
|
64
|
+
Object.prototype.hasOwnProperty.call(e, l) && (tt.has(l) || n && nt.has(l) || (r == null ? void 0 : r.has(l)) || rt.test(l)) && (s[l] = e[l]);
|
65
|
+
return s;
|
66
|
+
}
|
67
|
+
let G = /* @__PURE__ */ new Map(), be = /* @__PURE__ */ new Set();
|
68
|
+
function ge() {
|
69
|
+
if (typeof window > "u")
|
70
|
+
return;
|
71
|
+
let e = (n) => {
|
72
|
+
let r = G.get(n.target);
|
73
|
+
r || (r = /* @__PURE__ */ new Set(), G.set(n.target, r), n.target.addEventListener("transitioncancel", t)), r.add(n.propertyName);
|
74
|
+
}, t = (n) => {
|
75
|
+
let r = G.get(n.target);
|
76
|
+
if (!!r && (r.delete(n.propertyName), r.size === 0 && (n.target.removeEventListener("transitioncancel", t), G.delete(n.target)), G.size === 0)) {
|
77
|
+
for (let s of be)
|
78
|
+
s();
|
79
|
+
be.clear();
|
80
|
+
}
|
81
|
+
};
|
82
|
+
document.body.addEventListener("transitionrun", e), document.body.addEventListener("transitionend", t);
|
83
|
+
}
|
84
|
+
typeof document < "u" && (document.readyState !== "loading" ? ge() : document.addEventListener("DOMContentLoaded", ge));
|
85
|
+
const st = typeof window < "u" ? U.useLayoutEffect : () => {
|
86
|
+
};
|
87
|
+
let ye = /* @__PURE__ */ new Map();
|
88
|
+
function at(e, t) {
|
89
|
+
if (e === t)
|
90
|
+
return e;
|
91
|
+
let n = ye.get(e);
|
92
|
+
if (n)
|
93
|
+
return n(t), t;
|
94
|
+
let r = ye.get(t);
|
95
|
+
return r ? (r(e), e) : t;
|
96
|
+
}
|
97
|
+
function it(...e) {
|
98
|
+
return (...t) => {
|
99
|
+
for (let n of e)
|
100
|
+
typeof n == "function" && n(...t);
|
101
|
+
};
|
102
|
+
}
|
103
|
+
function Q(...e) {
|
104
|
+
let t = {
|
105
|
+
...e[0]
|
106
|
+
};
|
107
|
+
for (let n = 1; n < e.length; n++) {
|
108
|
+
let r = e[n];
|
109
|
+
for (let s in r) {
|
110
|
+
let l = t[s], u = r[s];
|
111
|
+
typeof l == "function" && typeof u == "function" && s[0] === "o" && s[1] === "n" && s.charCodeAt(2) >= 65 && s.charCodeAt(2) <= 90 ? t[s] = it(l, u) : (s === "className" || s === "UNSAFE_className") && typeof l == "string" && typeof u == "string" ? t[s] = Me(l, u) : s === "id" && l && u ? t.id = at(l, u) : t[s] = u !== void 0 ? u : l;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
return t;
|
115
|
+
}
|
116
|
+
function F(e) {
|
117
|
+
if (lt())
|
118
|
+
e.focus({
|
119
|
+
preventScroll: !0
|
120
|
+
});
|
121
|
+
else {
|
122
|
+
let t = ct(e);
|
123
|
+
e.focus(), ut(t);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
let q = null;
|
127
|
+
function lt() {
|
128
|
+
if (q == null) {
|
129
|
+
q = !1;
|
130
|
+
try {
|
131
|
+
var e = document.createElement("div");
|
132
|
+
e.focus({
|
133
|
+
get preventScroll() {
|
134
|
+
return q = !0, !0;
|
135
|
+
}
|
136
|
+
});
|
137
|
+
} catch {
|
138
|
+
}
|
139
|
+
}
|
140
|
+
return q;
|
141
|
+
}
|
142
|
+
function ct(e) {
|
143
|
+
for (var t = e.parentNode, n = [], r = document.scrollingElement || document.documentElement; t instanceof HTMLElement && t !== r; )
|
144
|
+
(t.offsetHeight < t.scrollHeight || t.offsetWidth < t.scrollWidth) && n.push({
|
145
|
+
element: t,
|
146
|
+
scrollTop: t.scrollTop,
|
147
|
+
scrollLeft: t.scrollLeft
|
148
|
+
}), t = t.parentNode;
|
149
|
+
return r instanceof HTMLElement && n.push({
|
150
|
+
element: r,
|
151
|
+
scrollTop: r.scrollTop,
|
152
|
+
scrollLeft: r.scrollLeft
|
153
|
+
}), n;
|
154
|
+
}
|
155
|
+
function ut(e) {
|
156
|
+
for (let { element: t, scrollTop: n, scrollLeft: r } of e)
|
157
|
+
t.scrollTop = n, t.scrollLeft = r;
|
158
|
+
}
|
159
|
+
let A = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Set();
|
160
|
+
function $e() {
|
161
|
+
if (typeof window > "u")
|
162
|
+
return;
|
163
|
+
let e = (n) => {
|
164
|
+
let r = A.get(n.target);
|
165
|
+
r || (r = /* @__PURE__ */ new Set(), A.set(n.target, r), n.target.addEventListener("transitioncancel", t)), r.add(n.propertyName);
|
166
|
+
}, t = (n) => {
|
167
|
+
let r = A.get(n.target);
|
168
|
+
if (!!r && (r.delete(n.propertyName), r.size === 0 && (n.target.removeEventListener("transitioncancel", t), A.delete(n.target)), A.size === 0)) {
|
169
|
+
for (let s of te)
|
170
|
+
s();
|
171
|
+
te.clear();
|
172
|
+
}
|
173
|
+
};
|
174
|
+
document.body.addEventListener("transitionrun", e), document.body.addEventListener("transitionend", t);
|
175
|
+
}
|
176
|
+
typeof document < "u" && (document.readyState !== "loading" ? $e() : document.addEventListener("DOMContentLoaded", $e));
|
177
|
+
function Ae(e) {
|
178
|
+
requestAnimationFrame(() => {
|
179
|
+
A.size === 0 ? e() : te.add(e);
|
180
|
+
});
|
181
|
+
}
|
182
|
+
function dt() {
|
183
|
+
let e = W(/* @__PURE__ */ new Map()), t = R((s, l, u, p) => {
|
184
|
+
let f = p != null && p.once ? (...b) => {
|
185
|
+
e.current.delete(u), u(...b);
|
186
|
+
} : u;
|
187
|
+
e.current.set(u, {
|
188
|
+
type: l,
|
189
|
+
eventTarget: s,
|
190
|
+
fn: f,
|
191
|
+
options: p
|
192
|
+
}), s.addEventListener(l, u, p);
|
193
|
+
}, []), n = R((s, l, u, p) => {
|
194
|
+
var f;
|
195
|
+
let b = ((f = e.current.get(u)) === null || f === void 0 ? void 0 : f.fn) || u;
|
196
|
+
s.removeEventListener(l, b, p), e.current.delete(u);
|
197
|
+
}, []), r = R(() => {
|
198
|
+
e.current.forEach((s, l) => {
|
199
|
+
n(s.eventTarget, s.type, l, s.options);
|
200
|
+
});
|
201
|
+
}, [
|
202
|
+
n
|
203
|
+
]);
|
204
|
+
return ie(() => r, [
|
205
|
+
r
|
206
|
+
]), {
|
207
|
+
addGlobalListener: t,
|
208
|
+
removeGlobalListener: n,
|
209
|
+
removeAllGlobalListeners: r
|
210
|
+
};
|
211
|
+
}
|
212
|
+
function Fe(e, t) {
|
213
|
+
st(() => {
|
214
|
+
if (e && e.ref && t)
|
215
|
+
return e.ref.current = t.current, () => {
|
216
|
+
e.ref.current = null;
|
217
|
+
};
|
218
|
+
}, [
|
219
|
+
e,
|
220
|
+
t
|
221
|
+
]);
|
222
|
+
}
|
223
|
+
function le(e) {
|
224
|
+
var t;
|
225
|
+
return typeof window < "u" && window.navigator != null ? e.test(((t = window.navigator.userAgentData) === null || t === void 0 ? void 0 : t.platform) || window.navigator.platform) : !1;
|
226
|
+
}
|
227
|
+
function _e() {
|
228
|
+
return le(/^Mac/i);
|
229
|
+
}
|
230
|
+
function ft() {
|
231
|
+
return le(/^iPhone/i);
|
232
|
+
}
|
233
|
+
function pt() {
|
234
|
+
return le(/^iPad/i) || _e() && navigator.maxTouchPoints > 1;
|
235
|
+
}
|
236
|
+
function Re() {
|
237
|
+
return ft() || pt();
|
238
|
+
}
|
239
|
+
const mt = typeof window < "u" ? U.useLayoutEffect : () => {
|
240
|
+
};
|
241
|
+
let H = /* @__PURE__ */ new Map(), ve = /* @__PURE__ */ new Set();
|
242
|
+
function he() {
|
243
|
+
if (typeof window > "u")
|
244
|
+
return;
|
245
|
+
let e = (n) => {
|
246
|
+
let r = H.get(n.target);
|
247
|
+
r || (r = /* @__PURE__ */ new Set(), H.set(n.target, r), n.target.addEventListener("transitioncancel", t)), r.add(n.propertyName);
|
248
|
+
}, t = (n) => {
|
249
|
+
let r = H.get(n.target);
|
250
|
+
if (!!r && (r.delete(n.propertyName), r.size === 0 && (n.target.removeEventListener("transitioncancel", t), H.delete(n.target)), H.size === 0)) {
|
251
|
+
for (let s of ve)
|
252
|
+
s();
|
253
|
+
ve.clear();
|
254
|
+
}
|
255
|
+
};
|
256
|
+
document.body.addEventListener("transitionrun", e), document.body.addEventListener("transitionend", t);
|
257
|
+
}
|
258
|
+
typeof document < "u" && (document.readyState !== "loading" ? he() : document.addEventListener("DOMContentLoaded", he));
|
259
|
+
function bt(e) {
|
260
|
+
var t;
|
261
|
+
return typeof window > "u" || window.navigator == null ? !1 : ((t = window.navigator.userAgentData) === null || t === void 0 ? void 0 : t.brands.some((n) => e.test(n.brand))) || e.test(window.navigator.userAgent);
|
262
|
+
}
|
263
|
+
function gt(e) {
|
264
|
+
var t;
|
265
|
+
return typeof window < "u" && window.navigator != null ? e.test(((t = window.navigator.userAgentData) === null || t === void 0 ? void 0 : t.platform) || window.navigator.platform) : !1;
|
266
|
+
}
|
267
|
+
function yt() {
|
268
|
+
return gt(/^Mac/i);
|
269
|
+
}
|
270
|
+
function $t() {
|
271
|
+
return bt(/Android/i);
|
272
|
+
}
|
273
|
+
function vt(e) {
|
274
|
+
return e.mozInputSource === 0 && e.isTrusted ? !0 : $t() && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
|
275
|
+
}
|
276
|
+
const ht = U.createContext(null);
|
277
|
+
ht.displayName = "PressResponderContext";
|
278
|
+
class kt {
|
279
|
+
isDefaultPrevented() {
|
280
|
+
return this.nativeEvent.defaultPrevented;
|
281
|
+
}
|
282
|
+
preventDefault() {
|
283
|
+
this.defaultPrevented = !0, this.nativeEvent.preventDefault();
|
284
|
+
}
|
285
|
+
stopPropagation() {
|
286
|
+
this.nativeEvent.stopPropagation(), this.isPropagationStopped = () => !0;
|
287
|
+
}
|
288
|
+
isPropagationStopped() {
|
289
|
+
return !1;
|
290
|
+
}
|
291
|
+
persist() {
|
292
|
+
}
|
293
|
+
constructor(t, n) {
|
294
|
+
this.nativeEvent = n, this.target = n.target, this.currentTarget = n.currentTarget, this.relatedTarget = n.relatedTarget, this.bubbles = n.bubbles, this.cancelable = n.cancelable, this.defaultPrevented = n.defaultPrevented, this.eventPhase = n.eventPhase, this.isTrusted = n.isTrusted, this.timeStamp = n.timeStamp, this.type = t;
|
295
|
+
}
|
296
|
+
}
|
297
|
+
function wt(e) {
|
298
|
+
let t = W({
|
299
|
+
isFocused: !1,
|
300
|
+
onBlur: e,
|
301
|
+
observer: null
|
302
|
+
});
|
303
|
+
return t.current.onBlur = e, mt(() => {
|
304
|
+
const n = t.current;
|
305
|
+
return () => {
|
306
|
+
n.observer && (n.observer.disconnect(), n.observer = null);
|
307
|
+
};
|
308
|
+
}, []), R((n) => {
|
309
|
+
if (n.target instanceof HTMLButtonElement || n.target instanceof HTMLInputElement || n.target instanceof HTMLTextAreaElement || n.target instanceof HTMLSelectElement) {
|
310
|
+
t.current.isFocused = !0;
|
311
|
+
let r = n.target, s = (l) => {
|
312
|
+
var u, p;
|
313
|
+
t.current.isFocused = !1, r.disabled && ((p = (u = t.current).onBlur) === null || p === void 0 || p.call(u, new kt("blur", l))), t.current.observer && (t.current.observer.disconnect(), t.current.observer = null);
|
314
|
+
};
|
315
|
+
r.addEventListener("focusout", s, {
|
316
|
+
once: !0
|
317
|
+
}), t.current.observer = new MutationObserver(() => {
|
318
|
+
t.current.isFocused && r.disabled && (t.current.observer.disconnect(), r.dispatchEvent(new FocusEvent("blur")), r.dispatchEvent(new FocusEvent("focusout", {
|
319
|
+
bubbles: !0
|
320
|
+
})));
|
321
|
+
}), t.current.observer.observe(r, {
|
322
|
+
attributes: !0,
|
323
|
+
attributeFilter: [
|
324
|
+
"disabled"
|
325
|
+
]
|
326
|
+
});
|
327
|
+
}
|
328
|
+
}, []);
|
329
|
+
}
|
330
|
+
function Bt(e) {
|
331
|
+
let { isDisabled: t, onFocus: n, onBlur: r, onFocusChange: s } = e;
|
332
|
+
const l = R((f) => {
|
333
|
+
if (f.target === f.currentTarget)
|
334
|
+
return r && r(f), s && s(!1), !0;
|
335
|
+
}, [
|
336
|
+
r,
|
337
|
+
s
|
338
|
+
]), u = wt(l), p = R((f) => {
|
339
|
+
f.target === f.currentTarget && (n && n(f), s && s(!0), u(f));
|
340
|
+
}, [
|
341
|
+
s,
|
342
|
+
n,
|
343
|
+
u
|
344
|
+
]);
|
345
|
+
return {
|
346
|
+
focusProps: {
|
347
|
+
onFocus: !t && (n || s || r) ? p : void 0,
|
348
|
+
onBlur: !t && (r || s) ? l : null
|
349
|
+
}
|
350
|
+
};
|
351
|
+
}
|
352
|
+
let j = null, Et = /* @__PURE__ */ new Set(), ke = !1, D = !1, ne = !1;
|
353
|
+
function ce(e, t) {
|
354
|
+
for (let n of Et)
|
355
|
+
n(e, t);
|
356
|
+
}
|
357
|
+
function Pt(e) {
|
358
|
+
return !(e.metaKey || !yt() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
|
359
|
+
}
|
360
|
+
function we(e) {
|
361
|
+
D = !0, Pt(e) && (j = "keyboard", ce("keyboard", e));
|
362
|
+
}
|
363
|
+
function K(e) {
|
364
|
+
j = "pointer", (e.type === "mousedown" || e.type === "pointerdown") && (D = !0, ce("pointer", e));
|
365
|
+
}
|
366
|
+
function Tt(e) {
|
367
|
+
vt(e) && (D = !0, j = "virtual");
|
368
|
+
}
|
369
|
+
function xt(e) {
|
370
|
+
e.target === window || e.target === document || (!D && !ne && (j = "virtual", ce("virtual", e)), D = !1, ne = !1);
|
371
|
+
}
|
372
|
+
function St() {
|
373
|
+
D = !1, ne = !0;
|
374
|
+
}
|
375
|
+
function Be() {
|
376
|
+
if (typeof window > "u" || ke)
|
377
|
+
return;
|
378
|
+
let e = HTMLElement.prototype.focus;
|
379
|
+
HTMLElement.prototype.focus = function() {
|
380
|
+
D = !0, e.apply(this, arguments);
|
381
|
+
}, document.addEventListener("keydown", we, !0), document.addEventListener("keyup", we, !0), document.addEventListener("click", Tt, !0), window.addEventListener("focus", xt, !0), window.addEventListener("blur", St, !1), typeof PointerEvent < "u" ? (document.addEventListener("pointerdown", K, !0), document.addEventListener("pointermove", K, !0), document.addEventListener("pointerup", K, !0)) : (document.addEventListener("mousedown", K, !0), document.addEventListener("mousemove", K, !0), document.addEventListener("mouseup", K, !0)), ke = !0;
|
382
|
+
}
|
383
|
+
typeof document < "u" && (document.readyState !== "loading" ? Be() : document.addEventListener("DOMContentLoaded", Be));
|
384
|
+
function Nt() {
|
385
|
+
return j;
|
386
|
+
}
|
387
|
+
function Ee(e) {
|
388
|
+
if (!e)
|
389
|
+
return;
|
390
|
+
let t = !0;
|
391
|
+
return (n) => {
|
392
|
+
let r = {
|
393
|
+
...n,
|
394
|
+
preventDefault() {
|
395
|
+
n.preventDefault();
|
396
|
+
},
|
397
|
+
isDefaultPrevented() {
|
398
|
+
return n.isDefaultPrevented();
|
399
|
+
},
|
400
|
+
stopPropagation() {
|
401
|
+
console.error("stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.");
|
402
|
+
},
|
403
|
+
continuePropagation() {
|
404
|
+
t = !1;
|
405
|
+
}
|
406
|
+
};
|
407
|
+
e(r), t && n.stopPropagation();
|
408
|
+
};
|
409
|
+
}
|
410
|
+
function Dt(e) {
|
411
|
+
return {
|
412
|
+
keyboardProps: e.isDisabled ? {} : {
|
413
|
+
onKeyDown: Ee(e.onKeyDown),
|
414
|
+
onKeyUp: Ee(e.onKeyUp)
|
415
|
+
}
|
416
|
+
};
|
417
|
+
}
|
418
|
+
function Ct(e) {
|
419
|
+
if (Nt() === "virtual") {
|
420
|
+
let t = document.activeElement;
|
421
|
+
Ae(() => {
|
422
|
+
document.activeElement === t && document.contains(e) && F(e);
|
423
|
+
});
|
424
|
+
} else
|
425
|
+
F(e);
|
426
|
+
}
|
427
|
+
function Ot(e, t) {
|
428
|
+
return t.some(
|
429
|
+
(n) => n.contains(e)
|
430
|
+
);
|
431
|
+
}
|
432
|
+
class ue {
|
433
|
+
get size() {
|
434
|
+
return this.fastMap.size;
|
435
|
+
}
|
436
|
+
getTreeNode(t) {
|
437
|
+
return this.fastMap.get(t);
|
438
|
+
}
|
439
|
+
addTreeNode(t, n, r) {
|
440
|
+
let s = this.fastMap.get(n != null ? n : null), l = new Pe({
|
441
|
+
scopeRef: t
|
442
|
+
});
|
443
|
+
s.addChild(l), l.parent = s, this.fastMap.set(t, l), r && (l.nodeToRestore = r);
|
444
|
+
}
|
445
|
+
removeTreeNode(t) {
|
446
|
+
if (t === null)
|
447
|
+
return;
|
448
|
+
let n = this.fastMap.get(t), r = n.parent;
|
449
|
+
for (let l of this.traverse())
|
450
|
+
l !== n && n.nodeToRestore && l.nodeToRestore && n.scopeRef.current && Ot(l.nodeToRestore, n.scopeRef.current) && (l.nodeToRestore = n.nodeToRestore);
|
451
|
+
let s = n.children;
|
452
|
+
r.removeChild(n), s.length > 0 && s.forEach(
|
453
|
+
(l) => r.addChild(l)
|
454
|
+
), this.fastMap.delete(n.scopeRef);
|
455
|
+
}
|
456
|
+
*traverse(t = this.root) {
|
457
|
+
if (t.scopeRef != null && (yield t), t.children.length > 0)
|
458
|
+
for (let n of t.children)
|
459
|
+
yield* this.traverse(n);
|
460
|
+
}
|
461
|
+
clone() {
|
462
|
+
let t = new ue();
|
463
|
+
for (let n of this.traverse())
|
464
|
+
t.addTreeNode(n.scopeRef, n.parent.scopeRef, n.nodeToRestore);
|
465
|
+
return t;
|
466
|
+
}
|
467
|
+
constructor() {
|
468
|
+
this.fastMap = /* @__PURE__ */ new Map(), this.root = new Pe({
|
469
|
+
scopeRef: null
|
470
|
+
}), this.fastMap.set(null, this.root);
|
471
|
+
}
|
472
|
+
}
|
473
|
+
class Pe {
|
474
|
+
addChild(t) {
|
475
|
+
this.children.push(t), t.parent = this;
|
476
|
+
}
|
477
|
+
removeChild(t) {
|
478
|
+
this.children.splice(this.children.indexOf(t), 1), t.parent = void 0;
|
479
|
+
}
|
480
|
+
constructor(t) {
|
481
|
+
this.children = [], this.contain = !1, this.scopeRef = t.scopeRef;
|
482
|
+
}
|
483
|
+
}
|
484
|
+
new ue();
|
485
|
+
let Lt = /* @__PURE__ */ U.createContext(null);
|
486
|
+
function Kt(e) {
|
487
|
+
let t = Ke(Lt) || {};
|
488
|
+
Fe(t, e);
|
489
|
+
let { ref: n, ...r } = t;
|
490
|
+
return r;
|
491
|
+
}
|
492
|
+
function It(e, t) {
|
493
|
+
let { focusProps: n } = Bt(e), { keyboardProps: r } = Dt(e), s = Q(n, r), l = Kt(t), u = e.isDisabled ? {} : l, p = W(e.autoFocus);
|
494
|
+
return ie(() => {
|
495
|
+
p.current && t.current && Ct(t.current), p.current = !1;
|
496
|
+
}, [
|
497
|
+
t
|
498
|
+
]), {
|
499
|
+
focusableProps: Q({
|
500
|
+
...s,
|
501
|
+
tabIndex: e.excludeFromTabOrder && !e.isDisabled ? -1 : void 0
|
502
|
+
}, u)
|
503
|
+
};
|
504
|
+
}
|
505
|
+
let _ = "default", re = "", J = /* @__PURE__ */ new WeakMap();
|
506
|
+
function Te(e) {
|
507
|
+
Re() ? (_ === "default" && (re = document.documentElement.style.webkitUserSelect, document.documentElement.style.webkitUserSelect = "none"), _ = "disabled") : (e instanceof HTMLElement || e instanceof SVGElement) && (J.set(e, e.style.userSelect), e.style.userSelect = "none");
|
508
|
+
}
|
509
|
+
function X(e) {
|
510
|
+
if (Re()) {
|
511
|
+
if (_ !== "disabled")
|
512
|
+
return;
|
513
|
+
_ = "restoring", setTimeout(() => {
|
514
|
+
Ae(() => {
|
515
|
+
_ === "restoring" && (document.documentElement.style.webkitUserSelect === "none" && (document.documentElement.style.webkitUserSelect = re || ""), re = "", _ = "default");
|
516
|
+
});
|
517
|
+
}, 300);
|
518
|
+
} else if ((e instanceof HTMLElement || e instanceof SVGElement) && e && J.has(e)) {
|
519
|
+
let t = J.get(e);
|
520
|
+
e.style.userSelect === "none" && (e.style.userSelect = t), e.getAttribute("style") === "" && e.removeAttribute("style"), J.delete(e);
|
521
|
+
}
|
522
|
+
}
|
523
|
+
function oe(e) {
|
524
|
+
return e.mozInputSource === 0 && e.isTrusted ? !0 : e.detail === 0 && !e.pointerType;
|
525
|
+
}
|
526
|
+
const Ue = U.createContext(null);
|
527
|
+
Ue.displayName = "PressResponderContext";
|
528
|
+
function Mt(e) {
|
529
|
+
let t = Ke(Ue);
|
530
|
+
if (t) {
|
531
|
+
let { register: n, ...r } = t;
|
532
|
+
e = Q(r, e), n();
|
533
|
+
}
|
534
|
+
return Fe(t, e.ref), e;
|
535
|
+
}
|
536
|
+
function At(e) {
|
537
|
+
let {
|
538
|
+
onPress: t,
|
539
|
+
onPressChange: n,
|
540
|
+
onPressStart: r,
|
541
|
+
onPressEnd: s,
|
542
|
+
onPressUp: l,
|
543
|
+
isDisabled: u,
|
544
|
+
isPressed: p,
|
545
|
+
preventFocusOnPress: f,
|
546
|
+
shouldCancelOnPointerExit: b,
|
547
|
+
allowTextSelectionOnPress: g,
|
548
|
+
ref: O,
|
549
|
+
...x
|
550
|
+
} = Mt(e), k = W(null);
|
551
|
+
k.current = {
|
552
|
+
onPress: t,
|
553
|
+
onPressChange: n,
|
554
|
+
onPressStart: r,
|
555
|
+
onPressEnd: s,
|
556
|
+
onPressUp: l,
|
557
|
+
isDisabled: u,
|
558
|
+
shouldCancelOnPointerExit: b
|
559
|
+
};
|
560
|
+
let [S, E] = je(!1), L = W({
|
561
|
+
isPressed: !1,
|
562
|
+
ignoreEmulatedMouseEvents: !1,
|
563
|
+
ignoreClickAfterPress: !1,
|
564
|
+
didFirePressStart: !1,
|
565
|
+
activePointerId: null,
|
566
|
+
target: null,
|
567
|
+
isOverTarget: !1,
|
568
|
+
pointerType: null
|
569
|
+
}), { addGlobalListener: w, removeAllGlobalListeners: $ } = dt(), N = ze(() => {
|
570
|
+
let o = L.current, B = (i, v) => {
|
571
|
+
let { onPressStart: a, onPressChange: c, isDisabled: Y } = k.current;
|
572
|
+
Y || o.didFirePressStart || (a && a({
|
573
|
+
type: "pressstart",
|
574
|
+
pointerType: v,
|
575
|
+
target: i.currentTarget,
|
576
|
+
shiftKey: i.shiftKey,
|
577
|
+
metaKey: i.metaKey,
|
578
|
+
ctrlKey: i.ctrlKey,
|
579
|
+
altKey: i.altKey
|
580
|
+
}), c && c(!0), o.didFirePressStart = !0, E(!0));
|
581
|
+
}, h = (i, v, a = !0) => {
|
582
|
+
let { onPressEnd: c, onPressChange: Y, onPress: fe, isDisabled: We } = k.current;
|
583
|
+
!o.didFirePressStart || (o.ignoreClickAfterPress = !0, o.didFirePressStart = !1, c && c({
|
584
|
+
type: "pressend",
|
585
|
+
pointerType: v,
|
586
|
+
target: i.currentTarget,
|
587
|
+
shiftKey: i.shiftKey,
|
588
|
+
metaKey: i.metaKey,
|
589
|
+
ctrlKey: i.ctrlKey,
|
590
|
+
altKey: i.altKey
|
591
|
+
}), Y && Y(!1), E(!1), fe && a && !We && fe({
|
592
|
+
type: "press",
|
593
|
+
pointerType: v,
|
594
|
+
target: i.currentTarget,
|
595
|
+
shiftKey: i.shiftKey,
|
596
|
+
metaKey: i.metaKey,
|
597
|
+
ctrlKey: i.ctrlKey,
|
598
|
+
altKey: i.altKey
|
599
|
+
}));
|
600
|
+
}, V = (i, v) => {
|
601
|
+
let { onPressUp: a, isDisabled: c } = k.current;
|
602
|
+
c || a && a({
|
603
|
+
type: "pressup",
|
604
|
+
pointerType: v,
|
605
|
+
target: i.currentTarget,
|
606
|
+
shiftKey: i.shiftKey,
|
607
|
+
metaKey: i.metaKey,
|
608
|
+
ctrlKey: i.ctrlKey,
|
609
|
+
altKey: i.altKey
|
610
|
+
});
|
611
|
+
}, T = (i) => {
|
612
|
+
o.isPressed && (o.isOverTarget && h(P(o.target, i), o.pointerType, !1), o.isPressed = !1, o.isOverTarget = !1, o.activePointerId = null, o.pointerType = null, $(), g || X(o.target));
|
613
|
+
}, y = {
|
614
|
+
onKeyDown(i) {
|
615
|
+
Z(i.nativeEvent, i.currentTarget) && i.currentTarget.contains(i.target) ? (Se(i.target, i.key) && i.preventDefault(), i.stopPropagation(), !o.isPressed && !i.repeat && (o.target = i.currentTarget, o.isPressed = !0, B(i, "keyboard"), w(document, "keyup", He, !1))) : i.key === "Enter" && se(i.currentTarget) && i.stopPropagation();
|
616
|
+
},
|
617
|
+
onKeyUp(i) {
|
618
|
+
Z(i.nativeEvent, i.currentTarget) && !i.repeat && i.currentTarget.contains(i.target) && V(P(o.target, i), "keyboard");
|
619
|
+
},
|
620
|
+
onClick(i) {
|
621
|
+
i && !i.currentTarget.contains(i.target) || i && i.button === 0 && (i.stopPropagation(), u && i.preventDefault(), !o.ignoreClickAfterPress && !o.ignoreEmulatedMouseEvents && (o.pointerType === "virtual" || oe(i.nativeEvent)) && (!u && !f && F(i.currentTarget), B(i, "virtual"), V(i, "virtual"), h(i, "virtual")), o.ignoreEmulatedMouseEvents = !1, o.ignoreClickAfterPress = !1);
|
622
|
+
}
|
623
|
+
}, He = (i) => {
|
624
|
+
if (o.isPressed && Z(i, o.target)) {
|
625
|
+
Se(i.target, i.key) && i.preventDefault(), i.stopPropagation(), o.isPressed = !1;
|
626
|
+
let v = i.target;
|
627
|
+
h(P(o.target, i), "keyboard", o.target.contains(v)), $(), o.target instanceof HTMLElement && o.target.contains(v) && (se(o.target) || o.target.getAttribute("role") === "link") && o.target.click();
|
628
|
+
}
|
629
|
+
};
|
630
|
+
if (typeof PointerEvent < "u") {
|
631
|
+
y.onPointerDown = (c) => {
|
632
|
+
if (!(c.button !== 0 || !c.currentTarget.contains(c.target))) {
|
633
|
+
if (Vt(c.nativeEvent)) {
|
634
|
+
o.pointerType = "virtual";
|
635
|
+
return;
|
636
|
+
}
|
637
|
+
ee(c.currentTarget) && c.preventDefault(), o.pointerType = c.pointerType, c.stopPropagation(), o.isPressed || (o.isPressed = !0, o.isOverTarget = !0, o.activePointerId = c.pointerId, o.target = c.currentTarget, !u && !f && F(c.currentTarget), g || Te(o.target), B(c, o.pointerType), w(document, "pointermove", i, !1), w(document, "pointerup", v, !1), w(document, "pointercancel", a, !1));
|
638
|
+
}
|
639
|
+
}, y.onMouseDown = (c) => {
|
640
|
+
!c.currentTarget.contains(c.target) || c.button === 0 && (ee(c.currentTarget) && c.preventDefault(), c.stopPropagation());
|
641
|
+
}, y.onPointerUp = (c) => {
|
642
|
+
!c.currentTarget.contains(c.target) || o.pointerType === "virtual" || c.button === 0 && I(c, c.currentTarget) && V(c, o.pointerType || c.pointerType);
|
643
|
+
};
|
644
|
+
let i = (c) => {
|
645
|
+
c.pointerId === o.activePointerId && (I(c, o.target) ? o.isOverTarget || (o.isOverTarget = !0, B(P(o.target, c), o.pointerType)) : o.isOverTarget && (o.isOverTarget = !1, h(P(o.target, c), o.pointerType, !1), k.current.shouldCancelOnPointerExit && T(c)));
|
646
|
+
}, v = (c) => {
|
647
|
+
c.pointerId === o.activePointerId && o.isPressed && c.button === 0 && (I(c, o.target) ? h(P(o.target, c), o.pointerType) : o.isOverTarget && h(P(o.target, c), o.pointerType, !1), o.isPressed = !1, o.isOverTarget = !1, o.activePointerId = null, o.pointerType = null, $(), g || X(o.target));
|
648
|
+
}, a = (c) => {
|
649
|
+
T(c);
|
650
|
+
};
|
651
|
+
y.onDragStart = (c) => {
|
652
|
+
!c.currentTarget.contains(c.target) || T(c);
|
653
|
+
};
|
654
|
+
} else {
|
655
|
+
y.onMouseDown = (a) => {
|
656
|
+
a.button !== 0 || !a.currentTarget.contains(a.target) || (ee(a.currentTarget) && a.preventDefault(), a.stopPropagation(), !o.ignoreEmulatedMouseEvents && (o.isPressed = !0, o.isOverTarget = !0, o.target = a.currentTarget, o.pointerType = oe(a.nativeEvent) ? "virtual" : "mouse", !u && !f && F(a.currentTarget), B(a, o.pointerType), w(document, "mouseup", i, !1)));
|
657
|
+
}, y.onMouseEnter = (a) => {
|
658
|
+
!a.currentTarget.contains(a.target) || (a.stopPropagation(), o.isPressed && !o.ignoreEmulatedMouseEvents && (o.isOverTarget = !0, B(a, o.pointerType)));
|
659
|
+
}, y.onMouseLeave = (a) => {
|
660
|
+
!a.currentTarget.contains(a.target) || (a.stopPropagation(), o.isPressed && !o.ignoreEmulatedMouseEvents && (o.isOverTarget = !1, h(a, o.pointerType, !1), k.current.shouldCancelOnPointerExit && T(a)));
|
661
|
+
}, y.onMouseUp = (a) => {
|
662
|
+
!a.currentTarget.contains(a.target) || !o.ignoreEmulatedMouseEvents && a.button === 0 && V(a, o.pointerType);
|
663
|
+
};
|
664
|
+
let i = (a) => {
|
665
|
+
if (a.button === 0) {
|
666
|
+
if (o.isPressed = !1, $(), o.ignoreEmulatedMouseEvents) {
|
667
|
+
o.ignoreEmulatedMouseEvents = !1;
|
668
|
+
return;
|
669
|
+
}
|
670
|
+
I(a, o.target) ? h(P(o.target, a), o.pointerType) : o.isOverTarget && h(P(o.target, a), o.pointerType, !1), o.isOverTarget = !1;
|
671
|
+
}
|
672
|
+
};
|
673
|
+
y.onTouchStart = (a) => {
|
674
|
+
if (!a.currentTarget.contains(a.target))
|
675
|
+
return;
|
676
|
+
a.stopPropagation();
|
677
|
+
let c = Ft(a.nativeEvent);
|
678
|
+
!c || (o.activePointerId = c.identifier, o.ignoreEmulatedMouseEvents = !0, o.isOverTarget = !0, o.isPressed = !0, o.target = a.currentTarget, o.pointerType = "touch", !u && !f && F(a.currentTarget), g || Te(o.target), B(a, o.pointerType), w(window, "scroll", v, !0));
|
679
|
+
}, y.onTouchMove = (a) => {
|
680
|
+
if (!a.currentTarget.contains(a.target) || (a.stopPropagation(), !o.isPressed))
|
681
|
+
return;
|
682
|
+
let c = xe(a.nativeEvent, o.activePointerId);
|
683
|
+
c && I(c, a.currentTarget) ? o.isOverTarget || (o.isOverTarget = !0, B(a, o.pointerType)) : o.isOverTarget && (o.isOverTarget = !1, h(a, o.pointerType, !1), k.current.shouldCancelOnPointerExit && T(a));
|
684
|
+
}, y.onTouchEnd = (a) => {
|
685
|
+
if (!a.currentTarget.contains(a.target) || (a.stopPropagation(), !o.isPressed))
|
686
|
+
return;
|
687
|
+
let c = xe(a.nativeEvent, o.activePointerId);
|
688
|
+
c && I(c, a.currentTarget) ? (V(a, o.pointerType), h(a, o.pointerType)) : o.isOverTarget && h(a, o.pointerType, !1), o.isPressed = !1, o.activePointerId = null, o.isOverTarget = !1, o.ignoreEmulatedMouseEvents = !0, g || X(o.target), $();
|
689
|
+
}, y.onTouchCancel = (a) => {
|
690
|
+
!a.currentTarget.contains(a.target) || (a.stopPropagation(), o.isPressed && T(a));
|
691
|
+
};
|
692
|
+
let v = (a) => {
|
693
|
+
o.isPressed && a.target.contains(o.target) && T({
|
694
|
+
currentTarget: o.target,
|
695
|
+
shiftKey: !1,
|
696
|
+
ctrlKey: !1,
|
697
|
+
metaKey: !1,
|
698
|
+
altKey: !1
|
699
|
+
});
|
700
|
+
};
|
701
|
+
y.onDragStart = (a) => {
|
702
|
+
!a.currentTarget.contains(a.target) || T(a);
|
703
|
+
};
|
704
|
+
}
|
705
|
+
return y;
|
706
|
+
}, [
|
707
|
+
w,
|
708
|
+
u,
|
709
|
+
f,
|
710
|
+
$,
|
711
|
+
g
|
712
|
+
]);
|
713
|
+
return ie(() => () => {
|
714
|
+
g || X(L.current.target);
|
715
|
+
}, [
|
716
|
+
g
|
717
|
+
]), {
|
718
|
+
isPressed: p || S,
|
719
|
+
pressProps: Q(x, N)
|
720
|
+
};
|
721
|
+
}
|
722
|
+
function se(e) {
|
723
|
+
return e.tagName === "A" && e.hasAttribute("href");
|
724
|
+
}
|
725
|
+
function Z(e, t) {
|
726
|
+
const { key: n, code: r } = e, s = t, l = s.getAttribute("role");
|
727
|
+
return (n === "Enter" || n === " " || n === "Spacebar" || r === "Space") && !(s instanceof HTMLInputElement && !Ve(s, n) || s instanceof HTMLTextAreaElement || s.isContentEditable) && (!se(s) || l === "button" && n !== "Enter") && !(l === "link" && n !== "Enter");
|
728
|
+
}
|
729
|
+
function Ft(e) {
|
730
|
+
const { targetTouches: t } = e;
|
731
|
+
return t.length > 0 ? t[0] : null;
|
732
|
+
}
|
733
|
+
function xe(e, t) {
|
734
|
+
const n = e.changedTouches;
|
735
|
+
for (let r = 0; r < n.length; r++) {
|
736
|
+
const s = n[r];
|
737
|
+
if (s.identifier === t)
|
738
|
+
return s;
|
739
|
+
}
|
740
|
+
return null;
|
741
|
+
}
|
742
|
+
function P(e, t) {
|
743
|
+
return {
|
744
|
+
currentTarget: e,
|
745
|
+
shiftKey: t.shiftKey,
|
746
|
+
ctrlKey: t.ctrlKey,
|
747
|
+
metaKey: t.metaKey,
|
748
|
+
altKey: t.altKey
|
749
|
+
};
|
750
|
+
}
|
751
|
+
function _t(e) {
|
752
|
+
let t = e.width / 2 || e.radiusX || 0, n = e.height / 2 || e.radiusY || 0;
|
753
|
+
return {
|
754
|
+
top: e.clientY - n,
|
755
|
+
right: e.clientX + t,
|
756
|
+
bottom: e.clientY + n,
|
757
|
+
left: e.clientX - t
|
758
|
+
};
|
759
|
+
}
|
760
|
+
function Rt(e, t) {
|
761
|
+
return !(e.left > t.right || t.left > e.right || e.top > t.bottom || t.top > e.bottom);
|
762
|
+
}
|
763
|
+
function I(e, t) {
|
764
|
+
let n = t.getBoundingClientRect(), r = _t(e);
|
765
|
+
return Rt(n, r);
|
766
|
+
}
|
767
|
+
function ee(e) {
|
768
|
+
return !(e instanceof HTMLElement) || !e.draggable;
|
769
|
+
}
|
770
|
+
function Se(e, t) {
|
771
|
+
return e instanceof HTMLInputElement ? !Ve(e, t) : e instanceof HTMLButtonElement ? e.type !== "submit" : !0;
|
772
|
+
}
|
773
|
+
const Ut = /* @__PURE__ */ new Set([
|
774
|
+
"checkbox",
|
775
|
+
"radio",
|
776
|
+
"range",
|
777
|
+
"color",
|
778
|
+
"file",
|
779
|
+
"image",
|
780
|
+
"button",
|
781
|
+
"submit",
|
782
|
+
"reset"
|
783
|
+
]);
|
784
|
+
function Ve(e, t) {
|
785
|
+
return e.type === "checkbox" || e.type === "radio" ? t === " " : Ut.has(e.type);
|
786
|
+
}
|
787
|
+
function Vt(e) {
|
788
|
+
return e.width === 0 && e.height === 0 || e.width === 1 && e.height === 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "mouse";
|
789
|
+
}
|
790
|
+
let Gt = /* @__PURE__ */ new Set(), Ne = !1, C = !1, ae = !1;
|
791
|
+
function de(e, t) {
|
792
|
+
for (let n of Gt)
|
793
|
+
n(e, t);
|
794
|
+
}
|
795
|
+
function Ht(e) {
|
796
|
+
return !(e.metaKey || !_e() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
|
797
|
+
}
|
798
|
+
function De(e) {
|
799
|
+
C = !0, Ht(e) && de("keyboard", e);
|
800
|
+
}
|
801
|
+
function M(e) {
|
802
|
+
(e.type === "mousedown" || e.type === "pointerdown") && (C = !0, de("pointer", e));
|
803
|
+
}
|
804
|
+
function Wt(e) {
|
805
|
+
oe(e) && (C = !0);
|
806
|
+
}
|
807
|
+
function jt(e) {
|
808
|
+
e.target === window || e.target === document || (!C && !ae && de("virtual", e), C = !1, ae = !1);
|
809
|
+
}
|
810
|
+
function zt() {
|
811
|
+
C = !1, ae = !0;
|
812
|
+
}
|
813
|
+
function Ce() {
|
814
|
+
if (typeof window > "u" || Ne)
|
815
|
+
return;
|
816
|
+
let e = HTMLElement.prototype.focus;
|
817
|
+
HTMLElement.prototype.focus = function() {
|
818
|
+
C = !0, e.apply(this, arguments);
|
819
|
+
}, document.addEventListener("keydown", De, !0), document.addEventListener("keyup", De, !0), document.addEventListener("click", Wt, !0), window.addEventListener("focus", jt, !0), window.addEventListener("blur", zt, !1), typeof PointerEvent < "u" ? (document.addEventListener("pointerdown", M, !0), document.addEventListener("pointermove", M, !0), document.addEventListener("pointerup", M, !0)) : (document.addEventListener("mousedown", M, !0), document.addEventListener("mousemove", M, !0), document.addEventListener("mouseup", M, !0)), Ne = !0;
|
820
|
+
}
|
821
|
+
typeof document < "u" && (document.readyState !== "loading" ? Ce() : document.addEventListener("DOMContentLoaded", Ce));
|
822
|
+
function Yt(e, t) {
|
823
|
+
let {
|
824
|
+
elementType: n = "button",
|
825
|
+
isDisabled: r,
|
826
|
+
onPress: s,
|
827
|
+
onPressStart: l,
|
828
|
+
onPressEnd: u,
|
829
|
+
onPressChange: p,
|
830
|
+
preventFocusOnPress: f,
|
831
|
+
allowFocusWhenDisabled: b,
|
832
|
+
onClick: g,
|
833
|
+
href: O,
|
834
|
+
target: x,
|
835
|
+
rel: k,
|
836
|
+
type: S = "button"
|
837
|
+
} = e, E;
|
838
|
+
n === "button" ? E = {
|
839
|
+
type: S,
|
840
|
+
disabled: r
|
841
|
+
} : E = {
|
842
|
+
role: "button",
|
843
|
+
tabIndex: r ? void 0 : 0,
|
844
|
+
href: n === "a" && r ? void 0 : O,
|
845
|
+
target: n === "a" ? x : void 0,
|
846
|
+
type: n === "input" ? S : void 0,
|
847
|
+
disabled: n === "input" ? r : void 0,
|
848
|
+
"aria-disabled": !r || n === "input" ? void 0 : r,
|
849
|
+
rel: n === "a" ? k : void 0
|
850
|
+
};
|
851
|
+
let { pressProps: L, isPressed: w } = At({
|
852
|
+
onPressStart: l,
|
853
|
+
onPressEnd: u,
|
854
|
+
onPressChange: p,
|
855
|
+
onPress: s,
|
856
|
+
isDisabled: r,
|
857
|
+
preventFocusOnPress: f,
|
858
|
+
ref: t
|
859
|
+
}), { focusableProps: $ } = It(e, t);
|
860
|
+
b && ($.tabIndex = r ? -1 : $.tabIndex);
|
861
|
+
let N = me($, L, ot(e, {
|
862
|
+
labelable: !0
|
863
|
+
}));
|
864
|
+
return {
|
865
|
+
isPressed: w,
|
866
|
+
buttonProps: me(E, N, {
|
867
|
+
"aria-haspopup": e["aria-haspopup"],
|
868
|
+
"aria-expanded": e["aria-expanded"],
|
869
|
+
"aria-controls": e["aria-controls"],
|
870
|
+
"aria-pressed": e["aria-pressed"],
|
871
|
+
onClick: (o) => {
|
872
|
+
g && (g(o), console.warn("onClick is deprecated, please use onPress"));
|
873
|
+
}
|
874
|
+
})
|
875
|
+
};
|
876
|
+
}
|
877
|
+
function qt(e, t, n) {
|
878
|
+
return t in e ? Object.defineProperty(e, t, {
|
879
|
+
value: n,
|
880
|
+
enumerable: !0,
|
881
|
+
configurable: !0,
|
882
|
+
writable: !0
|
883
|
+
}) : e[t] = n, e;
|
884
|
+
}
|
885
|
+
function Oe(e, t) {
|
886
|
+
var n = Object.keys(e);
|
887
|
+
if (Object.getOwnPropertySymbols) {
|
888
|
+
var r = Object.getOwnPropertySymbols(e);
|
889
|
+
t && (r = r.filter(function(s) {
|
890
|
+
return Object.getOwnPropertyDescriptor(e, s).enumerable;
|
891
|
+
})), n.push.apply(n, r);
|
892
|
+
}
|
893
|
+
return n;
|
894
|
+
}
|
895
|
+
function Le(e) {
|
896
|
+
for (var t = 1; t < arguments.length; t++) {
|
897
|
+
var n = arguments[t] != null ? arguments[t] : {};
|
898
|
+
t % 2 ? Oe(Object(n), !0).forEach(function(r) {
|
899
|
+
qt(e, r, n[r]);
|
900
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : Oe(Object(n)).forEach(function(r) {
|
901
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
|
902
|
+
});
|
903
|
+
}
|
904
|
+
return e;
|
905
|
+
}
|
906
|
+
var Xt = (e, t, n) => {
|
907
|
+
for (var r of Object.keys(e)) {
|
908
|
+
var s;
|
909
|
+
if (e[r] !== ((s = t[r]) !== null && s !== void 0 ? s : n[r]))
|
910
|
+
return !1;
|
911
|
+
}
|
912
|
+
return !0;
|
913
|
+
}, z = (e) => (t) => {
|
914
|
+
var n = e.defaultClassName, r = Le(Le({}, e.defaultVariants), t);
|
915
|
+
for (var s in r) {
|
916
|
+
var l, u = (l = r[s]) !== null && l !== void 0 ? l : e.defaultVariants[s];
|
917
|
+
if (u != null) {
|
918
|
+
var p = u;
|
919
|
+
typeof p == "boolean" && (p = p === !0 ? "true" : "false");
|
920
|
+
var f = e.variantClassNames[s][p];
|
921
|
+
f && (n += " " + f);
|
922
|
+
}
|
923
|
+
}
|
924
|
+
for (var [b, g] of e.compoundVariants)
|
925
|
+
Xt(b, r, e.defaultVariants) && (n += " " + g);
|
926
|
+
return n;
|
927
|
+
}, Jt = z({ defaultClassName: "_125pcxy0", variantClassNames: { disabled: { true: "_125pcxy1", false: "_125pcxy2" }, kind: { default: "_125pcxy3", link: "_125pcxy4", confirm: "_125pcxy5", delete: "_125pcxy6", key: "_125pcxy7", icon: "_125pcxy8" }, spinning: { true: "_125pcxy9", false: "_125pcxya" } }, defaultVariants: { disabled: !1, kind: "default", spinning: !1 }, compoundVariants: [[{ kind: "icon", spinning: !0 }, "_125pcxyb"], [{ kind: "default", spinning: !0 }, "_125pcxyc"], [{ kind: "confirm", spinning: !0 }, "_125pcxyd"], [{ kind: "delete", spinning: !0 }, "_125pcxye"], [{ kind: "key", spinning: !0 }, "_125pcxyf"], [{ disabled: !0, spinning: !1 }, "_125pcxyg"]] }), Qt = z({ defaultClassName: "_125pcxyh", variantClassNames: { disabled: { true: "_125pcxyi", false: "_125pcxyj" }, kind: { icon: "_125pcxyk", default: "_125pcxyl", delete: "_125pcxym", key: "_125pcxyn", confirm: "_125pcxyo", link: "_125pcxyp" }, spinning: { true: "_125pcxyq", false: "_125pcxyr" } }, defaultVariants: { disabled: !1, kind: "default", spinning: !1 }, compoundVariants: [] }), Zt = z({ defaultClassName: "_125pcxyv", variantClassNames: { kind: { icon: "_125pcxyw", default: "_125pcxyx", key: "_125pcxyy", delete: "_125pcxyz", confirm: "_125pcxy10", link: "_125pcxy11" } }, defaultVariants: { kind: "default" }, compoundVariants: [] }), en = z({ defaultClassName: "_125pcxy12", variantClassNames: { spinning: { true: "_125pcxy13", false: "_125pcxy14" } }, defaultVariants: { spinning: !1 }, compoundVariants: [] }), tn = z({ defaultClassName: "_125pcxys", variantClassNames: { spinning: { true: "_125pcxyt", false: "_125pcxyu" } }, defaultVariants: { spinning: !1 }, compoundVariants: [] });
|
928
|
+
const Ge = d.forwardRef(
|
929
|
+
({
|
930
|
+
onClick: e,
|
931
|
+
onPress: t,
|
932
|
+
children: n,
|
933
|
+
className: r,
|
934
|
+
isDisabled: s,
|
935
|
+
disabled: l,
|
936
|
+
href: u,
|
937
|
+
icon: p,
|
938
|
+
kind: f = "default",
|
939
|
+
spinning: b,
|
940
|
+
spinningTitle: g,
|
941
|
+
...O
|
942
|
+
}, x) => {
|
943
|
+
var B;
|
944
|
+
const k = {
|
945
|
+
onPress: t != null ? t : e,
|
946
|
+
isDisabled: (B = l != null ? l : s) != null ? B : b,
|
947
|
+
...O
|
948
|
+
}, { "data-testid": S } = O, E = x != null ? x : d.useRef(null), { buttonProps: L } = Yt(k, E), { t: w } = d.useContext(Ye), $ = p && /* @__PURE__ */ d.createElement(qe, {
|
949
|
+
className: Zt({ kind: f }),
|
950
|
+
icon: p,
|
951
|
+
"aria-hidden": "true",
|
952
|
+
"data-testid": `${S}__${p}-icon`
|
953
|
+
});
|
954
|
+
let N;
|
955
|
+
f === "default" || f === "icon" || f === "link" ? N = "dark" : N = "light";
|
956
|
+
const o = b && /* @__PURE__ */ d.createElement(Xe, {
|
957
|
+
color: N,
|
958
|
+
className: en({ spinning: b }),
|
959
|
+
title: g || w("design-system:button.spinningTitle"),
|
960
|
+
"data-testid": `${S}__spinner`
|
961
|
+
});
|
962
|
+
return /* @__PURE__ */ d.createElement("div", {
|
963
|
+
className: Je(Jt({ disabled: s || l, kind: f, spinning: b }), r)
|
964
|
+
}, u ? /* @__PURE__ */ d.createElement("a", {
|
965
|
+
className: tn({ spinning: b }),
|
966
|
+
...O,
|
967
|
+
href: u
|
968
|
+
}, $, n, o) : /* @__PURE__ */ d.createElement(d.Fragment, null, /* @__PURE__ */ d.createElement("button", {
|
969
|
+
className: Qt({ disabled: s || l, kind: f, spinning: b }),
|
970
|
+
disabled: s,
|
971
|
+
...L,
|
972
|
+
ref: E
|
973
|
+
}, $, n, o)));
|
974
|
+
}
|
975
|
+
);
|
976
|
+
Qe.set(Ge, {
|
977
|
+
name: "Buttons",
|
978
|
+
props: {
|
979
|
+
disabled: "boolean",
|
980
|
+
href: "string",
|
981
|
+
icon: "IconName",
|
982
|
+
kind: {
|
983
|
+
type: '"default" | "link" | "icon" | "confirm" | "delete" | "key"',
|
984
|
+
default: '"default"'
|
985
|
+
},
|
986
|
+
spinning: "boolean",
|
987
|
+
spinningTitle: "string",
|
988
|
+
type: { type: '"button" | "submit"', default: '"button"' }
|
989
|
+
}
|
990
|
+
});
|
991
|
+
const nn = {
|
992
|
+
components: [Ge],
|
993
|
+
description: () => /* @__PURE__ */ d.createElement(d.Fragment, null, /* @__PURE__ */ d.createElement("div", {
|
994
|
+
className: "sps-body-14"
|
995
|
+
}, "Buttons are used to initiate events or actions. The labels and/or icons describe what the button will do."), /* @__PURE__ */ d.createElement("br", null), /* @__PURE__ */ d.createElement("h5", null, "Variants"), /* @__PURE__ */ d.createElement("div", {
|
996
|
+
className: "sps-body-14"
|
997
|
+
}, /* @__PURE__ */ d.createElement("span", {
|
998
|
+
className: "sps-text-semibold"
|
999
|
+
}, "Default: "), "For tertiary actions or actions of lower importance on a page."), /* @__PURE__ */ d.createElement("div", {
|
1000
|
+
className: "sps-body-14"
|
1001
|
+
}, /* @__PURE__ */ d.createElement("span", {
|
1002
|
+
className: "sps-text-semibold"
|
1003
|
+
}, "Key: "), "For primary or important actions on a page."), /* @__PURE__ */ d.createElement("div", {
|
1004
|
+
className: "sps-body-14"
|
1005
|
+
}, /* @__PURE__ */ d.createElement("span", {
|
1006
|
+
className: "sps-text-semibold"
|
1007
|
+
}, "Confirm: "), "For the main call to action on a page. There should only be one Confirm button per screen."), /* @__PURE__ */ d.createElement("div", {
|
1008
|
+
className: "sps-body-14"
|
1009
|
+
}, /* @__PURE__ */ d.createElement("span", {
|
1010
|
+
className: "sps-text-semibold"
|
1011
|
+
}, "Delete: "), "For deleting information or another destructive action. These should always be paired with a Delete Confirmation Modal."), /* @__PURE__ */ d.createElement("div", {
|
1012
|
+
className: "sps-body-14"
|
1013
|
+
}, /* @__PURE__ */ d.createElement("span", {
|
1014
|
+
className: "sps-text-semibold"
|
1015
|
+
}, "Disabled: "), "For actions that are not permitted in a particular state. These can be accompanied by a Tooltip on hover describing why it\u2019s disabled."), /* @__PURE__ */ d.createElement("div", {
|
1016
|
+
className: "sps-body-14"
|
1017
|
+
}, /* @__PURE__ */ d.createElement("span", {
|
1018
|
+
className: "sps-text-semibold"
|
1019
|
+
}, "With an Icon: "), "For further illustrating the action. Example: Pencil icon in an Edit button. There can also be Icon Buttons without text.")),
|
1020
|
+
examples: {
|
1021
|
+
basic: {
|
1022
|
+
label: "Basic Buttons",
|
1023
|
+
description: ({ NavigateTo: e }) => /* @__PURE__ */ d.createElement(d.Fragment, null, /* @__PURE__ */ d.createElement("p", null, "The most common type of button that can be used in most cases. Example: Basic Buttons in a ", /* @__PURE__ */ d.createElement(e, {
|
1024
|
+
to: "modals"
|
1025
|
+
}, "Modal"), ".")),
|
1026
|
+
examples: {
|
1027
|
+
withoutIcons: {
|
1028
|
+
description: "Without Icons",
|
1029
|
+
react: m`
|
1030
|
+
import { Button } from "@sps-woodland/buttons";
|
1031
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1032
|
+
|
1033
|
+
function Component() {
|
1034
|
+
return (
|
1035
|
+
<>
|
1036
|
+
<Button className={sprinkles({ mr: "xs" })}>Default</Button>
|
1037
|
+
<Button className={sprinkles({ mr: "xs" })} kind="key">Key</Button>
|
1038
|
+
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Confirm</Button>
|
1039
|
+
<Button className={sprinkles({ mr: "xs" })} kind="delete">Delete</Button>
|
1040
|
+
<Button disabled>Disabled</Button>
|
1041
|
+
</>
|
1042
|
+
)
|
1043
|
+
}
|
1044
|
+
`
|
1045
|
+
},
|
1046
|
+
withIcons: {
|
1047
|
+
description: "With Icons",
|
1048
|
+
react: m`
|
1049
|
+
import { Button } from "@sps-woodland/buttons";
|
1050
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1051
|
+
|
1052
|
+
function Component() {
|
1053
|
+
return (
|
1054
|
+
<>
|
1055
|
+
<Button className={sprinkles({ mr: "xs" })} icon="download-cloud">Default</Button>
|
1056
|
+
<Button className={sprinkles({ mr: "xs" })} icon="key" kind="key">Key</Button>
|
1057
|
+
<Button className={sprinkles({ mr: "xs" })} icon="download-cloud" kind="confirm">Confirm</Button>
|
1058
|
+
<Button className={sprinkles({ mr: "xs" })} icon="trash" kind="delete">Delete</Button>
|
1059
|
+
<Button icon="download-cloud" disabled>Disabled</Button>
|
1060
|
+
</>
|
1061
|
+
)
|
1062
|
+
}
|
1063
|
+
`
|
1064
|
+
},
|
1065
|
+
spinning: {
|
1066
|
+
description: "Spinning",
|
1067
|
+
react: m`
|
1068
|
+
import { Button } from "@sps-woodland/buttons";
|
1069
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1070
|
+
|
1071
|
+
function Component() {
|
1072
|
+
return (
|
1073
|
+
<>
|
1074
|
+
<Button className={sprinkles({ mr: "xs" })} spinning>Default</Button>
|
1075
|
+
<Button className={sprinkles({ mr: "xs" })} spinning kind="key">Key</Button>
|
1076
|
+
<Button className={sprinkles({ mr: "xs" })} spinning kind="confirm">Confirm</Button>
|
1077
|
+
<Button spinning kind="delete">Delete</Button>
|
1078
|
+
</>
|
1079
|
+
)
|
1080
|
+
}
|
1081
|
+
`
|
1082
|
+
}
|
1083
|
+
}
|
1084
|
+
},
|
1085
|
+
dropdown: {
|
1086
|
+
label: "Dropdown Buttons",
|
1087
|
+
description: "Use these for actions that need to select an option to proceed. Example: Download button with optiosn related to the file format (PDF, PPT, etc.).",
|
1088
|
+
examples: {
|
1089
|
+
withoutIcons: {
|
1090
|
+
description: "Without Icons",
|
1091
|
+
react: m`
|
1092
|
+
import { SpsDropdown } from "@spscommerce/ds-react";
|
1093
|
+
|
1094
|
+
function Component() {
|
1095
|
+
return (
|
1096
|
+
<>
|
1097
|
+
<SpsDropdown
|
1098
|
+
className="mr-1 mb-1"
|
1099
|
+
label="Default"
|
1100
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1101
|
+
/>
|
1102
|
+
<SpsDropdown
|
1103
|
+
className="mr-1 mb-1"
|
1104
|
+
kind={ButtonKind.KEY}
|
1105
|
+
label="Key"
|
1106
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1107
|
+
/>
|
1108
|
+
<SpsDropdown
|
1109
|
+
className="mr-1 mb-1"
|
1110
|
+
kind={ButtonKind.CONFIRM}
|
1111
|
+
label="Confirm"
|
1112
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1113
|
+
/>
|
1114
|
+
<SpsDropdown
|
1115
|
+
className="mr-1 mb-1"
|
1116
|
+
kind={ButtonKind.DELETE}
|
1117
|
+
label="Delete"
|
1118
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1119
|
+
/>
|
1120
|
+
<SpsDropdown
|
1121
|
+
className="mr-1 mb-1"
|
1122
|
+
disabled
|
1123
|
+
label="Disabled"
|
1124
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1125
|
+
/>
|
1126
|
+
</>
|
1127
|
+
)
|
1128
|
+
}
|
1129
|
+
`
|
1130
|
+
},
|
1131
|
+
withIcons: {
|
1132
|
+
description: "With Icons",
|
1133
|
+
react: m`
|
1134
|
+
import { SpsDropdown } from "@spscommerce/ds-react";
|
1135
|
+
|
1136
|
+
function Component() {
|
1137
|
+
return (
|
1138
|
+
<>
|
1139
|
+
<SpsDropdown
|
1140
|
+
className="mr-1 mb-1"
|
1141
|
+
icon={SpsIcon.DOWNLOAD_CLOUD}
|
1142
|
+
label="Default"
|
1143
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1144
|
+
/>
|
1145
|
+
<SpsDropdown
|
1146
|
+
className="mr-1 mb-1"
|
1147
|
+
icon={SpsIcon.DOWNLOAD_CLOUD}
|
1148
|
+
kind={ButtonKind.KEY}
|
1149
|
+
label="Key"
|
1150
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1151
|
+
/>
|
1152
|
+
<SpsDropdown
|
1153
|
+
className="mr-1 mb-1"
|
1154
|
+
icon={SpsIcon.DOWNLOAD_CLOUD}
|
1155
|
+
kind={ButtonKind.CONFIRM}
|
1156
|
+
label="Confirm"
|
1157
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1158
|
+
/>
|
1159
|
+
<SpsDropdown
|
1160
|
+
className="mr-1 mb-1"
|
1161
|
+
icon={SpsIcon.TRASH}
|
1162
|
+
kind={ButtonKind.DELETE}
|
1163
|
+
label="Delete"
|
1164
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1165
|
+
/>
|
1166
|
+
<SpsDropdown
|
1167
|
+
className="mr-1 mb-1"
|
1168
|
+
icon={SpsIcon.DOWNLOAD_CLOUD}
|
1169
|
+
disabled
|
1170
|
+
label="Disabled"
|
1171
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1172
|
+
/>
|
1173
|
+
</>
|
1174
|
+
)
|
1175
|
+
}
|
1176
|
+
`
|
1177
|
+
},
|
1178
|
+
spinning: {
|
1179
|
+
description: "Spinning",
|
1180
|
+
react: m`
|
1181
|
+
import { SpsDropdown } from "@spscommerce/ds-react";
|
1182
|
+
|
1183
|
+
function Component() {
|
1184
|
+
return (
|
1185
|
+
<>
|
1186
|
+
<SpsDropdown
|
1187
|
+
spinning
|
1188
|
+
className="mr-1 mb-1"
|
1189
|
+
label="Default"
|
1190
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1191
|
+
/>
|
1192
|
+
<SpsDropdown
|
1193
|
+
spinning
|
1194
|
+
className="mr-1 mb-1"
|
1195
|
+
kind={ButtonKind.KEY}
|
1196
|
+
label="Key"
|
1197
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1198
|
+
/>
|
1199
|
+
<SpsDropdown
|
1200
|
+
spinning
|
1201
|
+
className="mr-1 mb-1"
|
1202
|
+
kind={ButtonKind.CONFIRM}
|
1203
|
+
label="Confirm"
|
1204
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1205
|
+
/>
|
1206
|
+
<SpsDropdown
|
1207
|
+
spinning
|
1208
|
+
className="mr-1 mb-1"
|
1209
|
+
kind={ButtonKind.DELETE}
|
1210
|
+
label="Delete"
|
1211
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1212
|
+
/>
|
1213
|
+
</>
|
1214
|
+
)
|
1215
|
+
}
|
1216
|
+
`
|
1217
|
+
}
|
1218
|
+
}
|
1219
|
+
},
|
1220
|
+
splitButtons: {
|
1221
|
+
label: "Split Buttons",
|
1222
|
+
description: "Use when there is 1 primary action and other related actions can be taken.",
|
1223
|
+
examples: {
|
1224
|
+
withoutIcons: {
|
1225
|
+
description: "Without Icons",
|
1226
|
+
react: m`
|
1227
|
+
import { SpsSplitButton } from "@spscommerce/ds-react";
|
1228
|
+
|
1229
|
+
function Component() {
|
1230
|
+
return (
|
1231
|
+
<>
|
1232
|
+
<SpsSplitButton className="mr-1 mb-1" label="Default" />
|
1233
|
+
<SpsSplitButton
|
1234
|
+
className="mr-1 mb-1"
|
1235
|
+
kind={ButtonKind.KEY}
|
1236
|
+
label="Key"
|
1237
|
+
/>
|
1238
|
+
<SpsSplitButton
|
1239
|
+
className="mr-1 mb-1"
|
1240
|
+
kind={ButtonKind.CONFIRM}
|
1241
|
+
label="Confirm"
|
1242
|
+
/>
|
1243
|
+
<SpsSplitButton
|
1244
|
+
className="mr-1 mb-1"
|
1245
|
+
kind={ButtonKind.DELETE}
|
1246
|
+
label="Delete"
|
1247
|
+
/>
|
1248
|
+
<SpsSplitButton className="mr-1 mb-1" disabled label="Disabled" />
|
1249
|
+
</>
|
1250
|
+
)
|
1251
|
+
}
|
1252
|
+
`
|
1253
|
+
},
|
1254
|
+
withIcons: {
|
1255
|
+
description: "With Icons",
|
1256
|
+
react: m`
|
1257
|
+
import { SpsSplitButton } from "@spscommerce/ds-react";
|
1258
|
+
|
1259
|
+
function Component() {
|
1260
|
+
return (
|
1261
|
+
<>
|
1262
|
+
<SpsSplitButton
|
1263
|
+
className="mr-1 mb-1"
|
1264
|
+
icon={SpsIcon.PLUS_SIGN}
|
1265
|
+
label="Default"
|
1266
|
+
/>
|
1267
|
+
<SpsSplitButton
|
1268
|
+
className="mr-1 mb-1"
|
1269
|
+
icon={SpsIcon.PLUS_SIGN}
|
1270
|
+
kind={ButtonKind.KEY}
|
1271
|
+
label="Key"
|
1272
|
+
/>
|
1273
|
+
<SpsSplitButton
|
1274
|
+
className="mr-1 mb-1"
|
1275
|
+
icon={SpsIcon.PLUS_SIGN}
|
1276
|
+
kind={ButtonKind.CONFIRM}
|
1277
|
+
label="Confirm"
|
1278
|
+
/>
|
1279
|
+
<SpsSplitButton
|
1280
|
+
className="mr-1 mb-1"
|
1281
|
+
icon={SpsIcon.PLUS_SIGN}
|
1282
|
+
kind={ButtonKind.DELETE}
|
1283
|
+
label="Delete"
|
1284
|
+
/>
|
1285
|
+
<SpsSplitButton
|
1286
|
+
className="mr-1 mb-1"
|
1287
|
+
icon={SpsIcon.PLUS_SIGN}
|
1288
|
+
disabled
|
1289
|
+
label="Disabled"
|
1290
|
+
/>
|
1291
|
+
</>
|
1292
|
+
)
|
1293
|
+
}
|
1294
|
+
`
|
1295
|
+
}
|
1296
|
+
}
|
1297
|
+
},
|
1298
|
+
iconButtons: {
|
1299
|
+
label: "Icon Buttons",
|
1300
|
+
description: ({ NavigateTo: e, Link: t }) => /* @__PURE__ */ d.createElement(d.Fragment, null, /* @__PURE__ */ d.createElement("p", null, "Use these for quick actions that can clearly be articulated by the use of an icon. Example: A Print button in the", " ", /* @__PURE__ */ d.createElement(e, {
|
1301
|
+
to: "list-action-bar"
|
1302
|
+
}, "List Action Bar"), ". Do not use an icon that doesn't have a universally understood meaning; instead use a Basic Button or a Basic Button with an icon. ", /* @__PURE__ */ d.createElement(t, {
|
1303
|
+
to: "/style-and-layout/icons/"
|
1304
|
+
}, "View All Icons"))),
|
1305
|
+
examples: {
|
1306
|
+
standard: {
|
1307
|
+
description: "Standard Icon Buttons",
|
1308
|
+
react: m`
|
1309
|
+
import { Button } from "@sps-woodland/buttons";
|
1310
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1311
|
+
|
1312
|
+
function Component() {
|
1313
|
+
return (
|
1314
|
+
<>
|
1315
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="printer" />
|
1316
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="pencil" />
|
1317
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="x" />
|
1318
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="trash" />
|
1319
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="gear" />
|
1320
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="download-cloud" />
|
1321
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="search" />
|
1322
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="plus-sign" />
|
1323
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="minus" />
|
1324
|
+
</>
|
1325
|
+
)
|
1326
|
+
}
|
1327
|
+
`
|
1328
|
+
},
|
1329
|
+
dropdown: {
|
1330
|
+
description: ({ NavigateTo: e }) => /* @__PURE__ */ d.createElement(d.Fragment, null, /* @__PURE__ */ d.createElement("h5", null, "Dropdown Icon Buttons"), /* @__PURE__ */ d.createElement("p", null, "Use these when there are several options available for action. Example: Dropdown Icon Button in a ", /* @__PURE__ */ d.createElement(e, {
|
1331
|
+
to: "content-rows"
|
1332
|
+
}, "Content Row"), ".")),
|
1333
|
+
react: m`
|
1334
|
+
import { SpsDropdown } from "@spscommerce/ds-react";
|
1335
|
+
|
1336
|
+
function Component() {
|
1337
|
+
return (
|
1338
|
+
<>
|
1339
|
+
<SpsDropdown
|
1340
|
+
className="mr-1 mb-1"
|
1341
|
+
kind={ButtonKind.ICON}
|
1342
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
1343
|
+
/>
|
1344
|
+
</>
|
1345
|
+
)
|
1346
|
+
}
|
1347
|
+
`
|
1348
|
+
},
|
1349
|
+
spinner: {
|
1350
|
+
description: "Spinner",
|
1351
|
+
react: m`
|
1352
|
+
import { Button } from "@sps-woodland/buttons";
|
1353
|
+
|
1354
|
+
function Component() {
|
1355
|
+
return (
|
1356
|
+
<>
|
1357
|
+
<Button kind="icon" icon="download-cloud" spinning />
|
1358
|
+
</>
|
1359
|
+
)
|
1360
|
+
}
|
1361
|
+
`
|
1362
|
+
}
|
1363
|
+
}
|
1364
|
+
},
|
1365
|
+
textButtons: {
|
1366
|
+
label: "Text Buttons",
|
1367
|
+
description: ({ NavigateTo: e }) => /* @__PURE__ */ d.createElement("p", null, "Use for less important actions, or ones that aren't taken as frequently. They should not appear inline with other copy. Example: Advanced Search button in the", " ", /* @__PURE__ */ d.createElement(e, {
|
1368
|
+
to: "list-toolbar"
|
1369
|
+
}, "List Toolbar")),
|
1370
|
+
examples: {
|
1371
|
+
withoutIcons: {
|
1372
|
+
description: "Without Icons",
|
1373
|
+
react: m`
|
1374
|
+
import { Button } from "@sps-woodland/buttons";
|
1375
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1376
|
+
|
1377
|
+
function Component() {
|
1378
|
+
return (
|
1379
|
+
<>
|
1380
|
+
<Button className={sprinkles({ mr: "sm" })} kind="link">Default</Button>
|
1381
|
+
<Button className={sprinkles({ mr: "sm", color: "red-medium" })} kind="link">Delete</Button>
|
1382
|
+
<Button className={sprinkles({ mr: "sm" })} kind="link" disabled>Disabled</Button>
|
1383
|
+
</>
|
1384
|
+
)
|
1385
|
+
}
|
1386
|
+
`
|
1387
|
+
},
|
1388
|
+
withIcons: {
|
1389
|
+
description: "With Icons",
|
1390
|
+
react: m`
|
1391
|
+
import { Button } from "@sps-woodland/buttons";
|
1392
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1393
|
+
|
1394
|
+
function Component() {
|
1395
|
+
return (
|
1396
|
+
<>
|
1397
|
+
<Button className={sprinkles({ mr: "sm" })} kind="link" icon="download-cloud">Default</Button>
|
1398
|
+
<Button className={sprinkles({ mr: "sm", color: "red-medium" })} kind="link" icon="trash">Delete</Button>
|
1399
|
+
<Button className={sprinkles({ mr: "sm" })} kind="link" icon="gear" disabled>Disabled</Button>
|
1400
|
+
</>
|
1401
|
+
)
|
1402
|
+
}
|
1403
|
+
`
|
1404
|
+
},
|
1405
|
+
spinner: {
|
1406
|
+
description: "Spinner",
|
1407
|
+
react: m`
|
1408
|
+
import { Button } from "@sps-woodland/buttons";
|
1409
|
+
|
1410
|
+
function Component() {
|
1411
|
+
return (
|
1412
|
+
<>
|
1413
|
+
<Button kind="link" spinning>Default</Button>
|
1414
|
+
</>
|
1415
|
+
)
|
1416
|
+
}
|
1417
|
+
`
|
1418
|
+
}
|
1419
|
+
}
|
1420
|
+
},
|
1421
|
+
submitButtons: {
|
1422
|
+
label: "Submit Buttons",
|
1423
|
+
description: ({ NavigateTo: e }) => /* @__PURE__ */ d.createElement("p", null, "Use to submit a form. There can be a number of visual variations, for example a", " ", /* @__PURE__ */ d.createElement(e, {
|
1424
|
+
to: "modals"
|
1425
|
+
}, "Modal"), " uses Basic Button (Key) as its Submit Button."),
|
1426
|
+
examples: {
|
1427
|
+
basic: {
|
1428
|
+
react: m`
|
1429
|
+
import { Button } from "@sps-woodland/buttons";
|
1430
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1431
|
+
|
1432
|
+
function Component() {
|
1433
|
+
const { formMeta, formValue, updateForm } = useSpsForm({});
|
1434
|
+
|
1435
|
+
function alertOnSubmit() {
|
1436
|
+
window.alert("Form submitted");
|
1437
|
+
}
|
1438
|
+
|
1439
|
+
return (
|
1440
|
+
<SpsForm formMeta={formMeta} onSubmit={alertOnSubmit}>
|
1441
|
+
{/* Use only one Submit button in your form */}
|
1442
|
+
<Button className={sprinkles({ mr: "xs" })} type="submit" kind="key">Key</Button>
|
1443
|
+
<Button type="submit" kind="confirm">Confirm</Button>
|
1444
|
+
</SpsForm>
|
1445
|
+
)
|
1446
|
+
}
|
1447
|
+
`
|
1448
|
+
}
|
1449
|
+
}
|
1450
|
+
},
|
1451
|
+
link: {
|
1452
|
+
label: "Button as a Link",
|
1453
|
+
description: "Used to link to another page, such as an external website. They may open in the same window or in a new one. It should only be used when a Text Button doesn't provide enough visual emphasis.",
|
1454
|
+
examples: {
|
1455
|
+
basic: {
|
1456
|
+
react: m`
|
1457
|
+
import { Button } from "@sps-woodland/buttons";
|
1458
|
+
|
1459
|
+
function Component() {
|
1460
|
+
return (
|
1461
|
+
<>
|
1462
|
+
<Button kind="default" href="https://google.com">
|
1463
|
+
Button Text
|
1464
|
+
</Button>
|
1465
|
+
</>
|
1466
|
+
)
|
1467
|
+
}
|
1468
|
+
`
|
1469
|
+
}
|
1470
|
+
}
|
1471
|
+
},
|
1472
|
+
buttonGroups: {
|
1473
|
+
label: "Button Groups",
|
1474
|
+
description: ({ NavigateTo: e }) => /* @__PURE__ */ d.createElement("p", null, "Use button groups when there are a number of actions that can be taken in a view. When there are multiple button types in a group, they are separated using dividers. Example: Button groups in ", /* @__PURE__ */ d.createElement(e, {
|
1475
|
+
to: "List Action Bar"
|
1476
|
+
}, "List Action Bar"), "."),
|
1477
|
+
examples: {
|
1478
|
+
basic: {
|
1479
|
+
description: "Basic Button Groups",
|
1480
|
+
react: m`
|
1481
|
+
import { Button } from "@sps-woodland/buttons";
|
1482
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1483
|
+
|
1484
|
+
function Component() {
|
1485
|
+
return (
|
1486
|
+
<>
|
1487
|
+
<Button className={sprinkles({ mr: "xs" })}>Cancel</Button>
|
1488
|
+
<Button className={sprinkles({ mr: "xs" })} kind="key">Save</Button>
|
1489
|
+
</>
|
1490
|
+
)
|
1491
|
+
}
|
1492
|
+
`
|
1493
|
+
},
|
1494
|
+
icon: {
|
1495
|
+
description: "Icon Button Groups",
|
1496
|
+
react: m`
|
1497
|
+
import { Button } from "@sps-woodland/buttons";
|
1498
|
+
|
1499
|
+
function Component() {
|
1500
|
+
return (
|
1501
|
+
<>
|
1502
|
+
<Button kind="icon" icon="pencil" />
|
1503
|
+
<Button kind="icon" icon="trash" />
|
1504
|
+
</>
|
1505
|
+
)
|
1506
|
+
}
|
1507
|
+
`
|
1508
|
+
},
|
1509
|
+
textAndIcons: {
|
1510
|
+
description: "Text Buttons + Icon Buttons Group",
|
1511
|
+
react: m`
|
1512
|
+
import { Button } from "@sps-woodland/buttons";
|
1513
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1514
|
+
import { VericalRule } from "@sps-woodland/core";
|
1515
|
+
|
1516
|
+
function Component() {
|
1517
|
+
return (
|
1518
|
+
<>
|
1519
|
+
<Button className={sprinkles({ mr: "xs" })} kind="link">Text Button</Button>
|
1520
|
+
<VerticalRule />
|
1521
|
+
<Button kind="icon" icon="download-cloud" />
|
1522
|
+
<Button kind="icon" icon="printer" />
|
1523
|
+
</>
|
1524
|
+
)
|
1525
|
+
}
|
1526
|
+
`
|
1527
|
+
},
|
1528
|
+
textAndBasic: {
|
1529
|
+
description: "Text Buttons + Basic Buttons Group",
|
1530
|
+
react: m`
|
1531
|
+
import { Button } from "@sps-woodland/buttons";
|
1532
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1533
|
+
import { VericalRule } from "@sps-woodland/core";
|
1534
|
+
|
1535
|
+
function Component() {
|
1536
|
+
return (
|
1537
|
+
<>
|
1538
|
+
<Button className={sprinkles({ mr: "xs" })} kind="link">Text Button</Button>
|
1539
|
+
<VerticalRule />
|
1540
|
+
<Button className={sprinkles({ ml: "xs", mr: "xs" })} kind="default">Button</Button>
|
1541
|
+
<Button className={sprinkles({ mr: "xs" })} kind="key">Button</Button>
|
1542
|
+
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Button</Button>
|
1543
|
+
</>
|
1544
|
+
)
|
1545
|
+
}
|
1546
|
+
`
|
1547
|
+
},
|
1548
|
+
iconsAndBasic: {
|
1549
|
+
description: "Icon Buttons + Basic Buttons Group",
|
1550
|
+
react: m`
|
1551
|
+
import { Button } from "@sps-woodland/buttons";
|
1552
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1553
|
+
import { VericalRule } from "@sps-woodland/core";
|
1554
|
+
|
1555
|
+
function Component() {
|
1556
|
+
return (
|
1557
|
+
<>
|
1558
|
+
<Button kind="icon" icon="download-cloud" />
|
1559
|
+
<Button kind="icon" icon="printer" />
|
1560
|
+
<VerticalRule />
|
1561
|
+
<Button className={sprinkles({ ml: "xs", mr: "xs" })} kind="default">Button</Button>
|
1562
|
+
<Button className={sprinkles({ mr: "xs" })} kind="key">Button</Button>
|
1563
|
+
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Button</Button>
|
1564
|
+
</>
|
1565
|
+
)
|
1566
|
+
}
|
1567
|
+
`
|
1568
|
+
},
|
1569
|
+
textIconsAndBasic: {
|
1570
|
+
description: "Text Buttons + Icon Buttons + Basic Buttons Group",
|
1571
|
+
react: m`
|
1572
|
+
import { Button } from "@sps-woodland/buttons";
|
1573
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
1574
|
+
import { VericalRule } from "@sps-woodland/core";
|
1575
|
+
|
1576
|
+
function Component() {
|
1577
|
+
return (
|
1578
|
+
<>
|
1579
|
+
<Button className={sprinkles({ mr: "xs" })} kind="link">Text Button</Button>
|
1580
|
+
<VerticalRule />
|
1581
|
+
<Button kind="icon" icon="download-cloud" />
|
1582
|
+
<Button kind="icon" icon="printer" />
|
1583
|
+
<VerticalRule />
|
1584
|
+
<Button className={sprinkles({ ml: "xs", mr: "xs" })} kind="default">Button</Button>
|
1585
|
+
<Button className={sprinkles({ mr: "xs" })} kind="key">Button</Button>
|
1586
|
+
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Button</Button>
|
1587
|
+
</>
|
1588
|
+
)
|
1589
|
+
}
|
1590
|
+
`
|
1591
|
+
}
|
1592
|
+
}
|
1593
|
+
}
|
1594
|
+
}
|
1595
|
+
}, an = {
|
1596
|
+
Buttons: nn
|
1597
|
+
};
|
1598
|
+
export {
|
1599
|
+
Ge as Button,
|
1600
|
+
an as MANIFEST
|
1601
|
+
};
|