@tachui/primitives 0.8.32 → 0.8.34
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { withModifiers as A, ComponentWithCSSClasses as q, createSignal as
|
|
1
|
+
import { withModifiers as A, ComponentWithCSSClasses as q, createSignal as F, useLifecycle as J, createEffect as Y, isSignal as l, ColorAsset as $, h as a, text as d, ConcatenatedComponent as z, clonePropsPreservingReactivity as N, resetLifecycleState as U, createComputed as Q } from "@tachui/core";
|
|
2
2
|
import { createComponentInstance as ee } from "@tachui/core/components";
|
|
3
3
|
import { T as W } from "./Text-DmpfnY1o.js";
|
|
4
|
-
var te = Object.defineProperty, ie = (
|
|
4
|
+
var te = Object.defineProperty, ie = (i, e, t) => e in i ? te(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, y = (i, e, t) => ie(i, typeof e != "symbol" ? e + "" : e, t);
|
|
5
5
|
const se = {
|
|
6
6
|
colors: {
|
|
7
7
|
primary: "#007AFF",
|
|
@@ -31,11 +31,11 @@ const se = {
|
|
|
31
31
|
large: { size: 18, weight: "600" }
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
class
|
|
34
|
+
class I extends q {
|
|
35
35
|
constructor(e, t = se) {
|
|
36
|
-
super(),
|
|
37
|
-
const [
|
|
38
|
-
this.stateSignal =
|
|
36
|
+
super(), y(this, "props", e), y(this, "type", "component"), y(this, "id"), y(this, "mounted", !1), y(this, "cleanup", []), y(this, "stateSignal"), y(this, "setState"), y(this, "theme"), this.id = `button-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, this.theme = t;
|
|
37
|
+
const [s, o] = F("normal");
|
|
38
|
+
this.stateSignal = s, this.setState = o, this.setupDOMEventListeners();
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Set up DOM event listeners for button interactions
|
|
@@ -53,10 +53,10 @@ class z extends q {
|
|
|
53
53
|
setupReactiveStyles(e) {
|
|
54
54
|
const t = Y(() => {
|
|
55
55
|
this.stateSignal(), this.isEnabled(), this.isLoading();
|
|
56
|
-
const { tint:
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
this.applyStylesToElement(e,
|
|
56
|
+
const { tint: s, backgroundColor: o, foregroundColor: n } = this.props;
|
|
57
|
+
s && l(s) ? s() : s instanceof $ && s.resolve(), o && l(o) ? o() : o instanceof $ && o.resolve(), n && l(n) ? n() : n instanceof $ && n.resolve();
|
|
58
|
+
const r = this.getButtonStyles();
|
|
59
|
+
this.applyStylesToElement(e, r);
|
|
60
60
|
});
|
|
61
61
|
this.cleanup.push(() => {
|
|
62
62
|
t && typeof t.dispose == "function" && t.dispose();
|
|
@@ -66,11 +66,11 @@ class z extends q {
|
|
|
66
66
|
* Apply computed styles to the button element, respecting modifier-applied styles
|
|
67
67
|
*/
|
|
68
68
|
applyStylesToElement(e, t) {
|
|
69
|
-
Object.entries(t).forEach(([
|
|
70
|
-
const
|
|
71
|
-
if (typeof
|
|
72
|
-
const
|
|
73
|
-
process.env.NODE_ENV === "development" &&
|
|
69
|
+
Object.entries(t).forEach(([s, o]) => {
|
|
70
|
+
const n = this.camelToKebabCase(s);
|
|
71
|
+
if (typeof o == "string" || typeof o == "number") {
|
|
72
|
+
const r = e.style.getPropertyValue(n), c = r && r !== "" && r !== "inherit";
|
|
73
|
+
process.env.NODE_ENV === "development" && n === "font-family" && (console.log("[Button.applyButtonStyles] Font-family check:"), console.log("[Button.applyButtonStyles] property:", s, "cssProperty:", n), console.log("[Button.applyButtonStyles] currentValue:", r), console.log("[Button.applyButtonStyles] hasModifierValue:", c), console.log("[Button.applyButtonStyles] will set to:", o)), n === "transform" ? e.style.setProperty(n, String(o)) : c ? process.env.NODE_ENV === "development" && n === "font-family" && console.log("[Button.applyButtonStyles] Button SKIPPED font-family (has modifier value):", r) : (e.style.setProperty(n, String(o)), process.env.NODE_ENV === "development" && n === "font-family" && (console.log("[Button.applyButtonStyles] Button SET font-family to:", String(o)), console.log("[Button.applyButtonStyles] Element after set:", e.style.fontFamily)));
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
}
|
|
@@ -89,7 +89,7 @@ class z extends q {
|
|
|
89
89
|
return e;
|
|
90
90
|
if (l(e))
|
|
91
91
|
return e();
|
|
92
|
-
if (e instanceof
|
|
92
|
+
if (e instanceof $)
|
|
93
93
|
return e.resolve();
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -126,20 +126,20 @@ class z extends q {
|
|
|
126
126
|
d(this.props.title || "")
|
|
127
127
|
)
|
|
128
128
|
);
|
|
129
|
-
const
|
|
129
|
+
const s = ["tachui-button"];
|
|
130
130
|
return [{
|
|
131
131
|
type: "element",
|
|
132
132
|
tag: "button",
|
|
133
133
|
props: {
|
|
134
|
-
className: this.createClassString(this.props,
|
|
134
|
+
className: this.createClassString(this.props, s),
|
|
135
135
|
type: "button",
|
|
136
136
|
disabled: typeof e == "boolean" ? !e : !e(),
|
|
137
137
|
// Invert enabled to disabled
|
|
138
138
|
onClick: this.props.action ? () => {
|
|
139
139
|
try {
|
|
140
140
|
this.props.action?.();
|
|
141
|
-
} catch (
|
|
142
|
-
console.error("Button action error:",
|
|
141
|
+
} catch (r) {
|
|
142
|
+
console.error("Button action error:", r);
|
|
143
143
|
}
|
|
144
144
|
} : void 0,
|
|
145
145
|
// Pass through debug label for debug system
|
|
@@ -166,21 +166,21 @@ class z extends q {
|
|
|
166
166
|
*/
|
|
167
167
|
hasColorModifiers() {
|
|
168
168
|
let e = this.modifiers;
|
|
169
|
-
return !e && this.modifierBuilder && (e = this.modifierBuilder.modifiers), !e && this.modifiableComponent && (e = this.modifiableComponent.modifiers), !e || !Array.isArray(e) ? !1 : e.some((t) => t.type === "appearance" || t.constructor?.name === "AppearanceModifier" ? t.properties && (t.properties.foregroundColor !== void 0 || t.properties.color !== void 0) : t.properties ? ["foregroundColor", "color", "textColor"].some((
|
|
169
|
+
return !e && this.modifierBuilder && (e = this.modifierBuilder.modifiers), !e && this.modifiableComponent && (e = this.modifiableComponent.modifiers), !e || !Array.isArray(e) ? !1 : e.some((t) => t.type === "appearance" || t.constructor?.name === "AppearanceModifier" ? t.properties && (t.properties.foregroundColor !== void 0 || t.properties.color !== void 0) : t.properties ? ["foregroundColor", "color", "textColor"].some((o) => t.properties[o] !== void 0) : !1);
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
172
|
* Check if the button has typography-related modifiers applied
|
|
173
173
|
*/
|
|
174
174
|
hasTypographyModifiers() {
|
|
175
175
|
let e = this.modifiers;
|
|
176
|
-
return !e && this.modifierBuilder && (e = this.modifierBuilder.modifiers), !e && this.modifiableComponent && (e = this.modifiableComponent.modifiers), !e || !Array.isArray(e) ? !1 : e.some((
|
|
176
|
+
return !e && this.modifierBuilder && (e = this.modifierBuilder.modifiers), !e && this.modifiableComponent && (e = this.modifiableComponent.modifiers), !e || !Array.isArray(e) ? !1 : e.some((s) => s.type === "typography" || s.constructor?.name === "TypographyModifier" ? s.properties && (s.properties.transform !== void 0 || s.properties.textTransform !== void 0) : !1);
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
179
179
|
* Check if the button has a shadow modifier applied
|
|
180
180
|
*/
|
|
181
181
|
hasShadowModifier() {
|
|
182
182
|
let e = this.modifiers;
|
|
183
|
-
return !e && this.modifierBuilder && (e = this.modifierBuilder.modifiers), !e && this.modifiableComponent && (e = this.modifiableComponent.modifiers), !e || !Array.isArray(e) ? !1 : e.some((
|
|
183
|
+
return !e && this.modifierBuilder && (e = this.modifierBuilder.modifiers), !e && this.modifiableComponent && (e = this.modifiableComponent.modifiers), !e || !Array.isArray(e) ? !1 : e.some((s) => s.type === "appearance" || s.type === "shadow" || s.constructor?.name === "AppearanceModifier" || s.constructor?.name === "ShadowModifier" ? s.properties && s.properties.shadow !== void 0 : !1);
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* Get computed button styles based on variant, size, role, and state
|
|
@@ -190,17 +190,17 @@ class z extends q {
|
|
|
190
190
|
const {
|
|
191
191
|
variant: e,
|
|
192
192
|
size: t,
|
|
193
|
-
role:
|
|
194
|
-
tint:
|
|
195
|
-
backgroundColor:
|
|
196
|
-
foregroundColor:
|
|
197
|
-
} = this.props, c = this.stateSignal(),
|
|
193
|
+
role: s = "none",
|
|
194
|
+
tint: o,
|
|
195
|
+
backgroundColor: n,
|
|
196
|
+
foregroundColor: r
|
|
197
|
+
} = this.props, c = this.stateSignal(), u = this.isLoading(), T = this.isEnabled(), m = this.hasColorModifiers(), w = this.hasTypographyModifiers(), C = {
|
|
198
198
|
// Only set color property if no modifiers will handle it
|
|
199
199
|
// This prevents conflicts between Button styles and AppearanceModifier
|
|
200
|
-
...!
|
|
200
|
+
...!m && !r && !e && { color: "inherit" },
|
|
201
201
|
// Only set text-related properties if no typography modifiers will handle them
|
|
202
202
|
// This prevents conflicts between Button styles and TypographyModifier
|
|
203
|
-
...!
|
|
203
|
+
...!w && {
|
|
204
204
|
fontStyle: "inherit",
|
|
205
205
|
lineHeight: "inherit",
|
|
206
206
|
textTransform: "inherit",
|
|
@@ -215,40 +215,40 @@ class z extends q {
|
|
|
215
215
|
// Let modifiers control: fontFamily, fontSize, fontWeight, letterSpacing, textAlign
|
|
216
216
|
};
|
|
217
217
|
if (t) {
|
|
218
|
-
const
|
|
218
|
+
const L = this.theme.spacing[t] || this.theme.spacing.medium, Z = this.theme.borderRadius[t] || this.theme.borderRadius.medium, H = this.theme.typography[t] || this.theme.typography.medium, K = {
|
|
219
219
|
small: "32px",
|
|
220
220
|
medium: "40px",
|
|
221
221
|
large: "48px"
|
|
222
222
|
};
|
|
223
|
-
|
|
223
|
+
C.padding = `${L}px ${L * 2}px`, C.borderRadius = `${Z}px`, C.fontSize = `${H.size}px`, C.fontWeight = H.weight, C.minHeight = K[t];
|
|
224
224
|
}
|
|
225
|
-
let
|
|
226
|
-
const X = this.resolveColorValue(
|
|
225
|
+
let b = "transparent", v = "transparent", _ = "1px", k;
|
|
226
|
+
const X = this.resolveColorValue(o), D = this.resolveColorValue(n), E = this.resolveColorValue(r);
|
|
227
227
|
if (e) {
|
|
228
|
-
const
|
|
228
|
+
const L = X || this.theme.colors.primary;
|
|
229
229
|
switch (e) {
|
|
230
230
|
case "filled":
|
|
231
|
-
|
|
231
|
+
s === "destructive" ? b = this.theme.colors.destructive : s === "cancel" ? b = this.theme.colors.secondary : b = L, k = this.theme.colors.onPrimary;
|
|
232
232
|
break;
|
|
233
233
|
case "outlined":
|
|
234
|
-
|
|
234
|
+
v = s === "destructive" ? this.theme.colors.destructive : L, k = s === "destructive" ? this.theme.colors.destructive : L;
|
|
235
235
|
break;
|
|
236
236
|
case "bordered":
|
|
237
|
-
|
|
237
|
+
b = this.theme.colors.background, v = this.theme.colors.border;
|
|
238
238
|
break;
|
|
239
239
|
case "borderedProminent":
|
|
240
|
-
|
|
240
|
+
b = this.theme.colors.surface, v = this.theme.colors.primary, _ = "2px";
|
|
241
241
|
break;
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
|
|
245
|
-
let
|
|
246
|
-
T ?
|
|
244
|
+
D && (b = D), E && (k = E);
|
|
245
|
+
let B = "1", O = "auto", M, V = "none";
|
|
246
|
+
T ? u ? (B = "0.6", O = "none") : c === "pressed" ? (b = this.darkenColor(b, 0.1), v = this.darkenColor(v, 0.1), M = "scale(0.95)") : c === "focused" && (V = "0 0 0 3px #007AFF40") : (b = this.theme.colors.disabled, v = this.theme.colors.disabled, k = this.theme.colors.disabled, B = "0.6", O = "none");
|
|
247
247
|
const p = {
|
|
248
|
-
...
|
|
248
|
+
...C
|
|
249
249
|
// Size-based styles (only if size provided)
|
|
250
250
|
};
|
|
251
|
-
return e && (p.backgroundColor =
|
|
251
|
+
return e && (p.backgroundColor = b, p.borderColor = v, p.borderWidth = _, k !== void 0 && (p.color = k)), D && (p.backgroundColor = D), E && (p.color = E), p.cursor = T ? "pointer" : "not-allowed", p.opacity = B, p.pointerEvents = O, p.transform = M !== void 0 ? M : "none", this.hasShadowModifier() || (p.boxShadow = V), p.transition = "all 0.2s ease", p;
|
|
252
252
|
}
|
|
253
253
|
/**
|
|
254
254
|
* Handle button press with proper state management
|
|
@@ -279,8 +279,8 @@ class z extends q {
|
|
|
279
279
|
darkenColor(e, t) {
|
|
280
280
|
if (e === "transparent") return e;
|
|
281
281
|
if (e.startsWith("#")) {
|
|
282
|
-
const
|
|
283
|
-
return `#${(
|
|
282
|
+
const s = e.slice(1), o = parseInt(s, 16), n = Math.max(0, Math.floor((o >> 16) * (1 - t))), r = Math.max(0, Math.floor((o >> 8 & 255) * (1 - t))), c = Math.max(0, Math.floor((o & 255) * (1 - t)));
|
|
283
|
+
return `#${(n << 16 | r << 8 | c).toString(16).padStart(6, "0")}`;
|
|
284
284
|
}
|
|
285
285
|
return e;
|
|
286
286
|
}
|
|
@@ -291,16 +291,16 @@ class z extends q {
|
|
|
291
291
|
* Concatenate this button with another concatenatable component
|
|
292
292
|
*/
|
|
293
293
|
concat(e) {
|
|
294
|
-
const t = this.toSegment(),
|
|
295
|
-
totalSegments: e instanceof
|
|
296
|
-
accessibilityRole: e instanceof
|
|
294
|
+
const t = this.toSegment(), s = e.toSegment(), o = {
|
|
295
|
+
totalSegments: e instanceof z ? e.segments.length + 1 : 2,
|
|
296
|
+
accessibilityRole: e instanceof z ? this.mergeAccessibilityRoles(
|
|
297
297
|
"composite",
|
|
298
298
|
e.metadata.accessibilityRole
|
|
299
299
|
) : this.determineAccessibilityRole(e),
|
|
300
300
|
semanticStructure: "inline"
|
|
301
301
|
// Buttons are typically inline in concatenation
|
|
302
302
|
};
|
|
303
|
-
return new
|
|
303
|
+
return new z([t, s], o);
|
|
304
304
|
}
|
|
305
305
|
/**
|
|
306
306
|
* Convert this button to a segment for concatenation
|
|
@@ -352,13 +352,13 @@ class z extends q {
|
|
|
352
352
|
return e.deep ? this.deepClone() : this.shallowClone();
|
|
353
353
|
}
|
|
354
354
|
shallowClone() {
|
|
355
|
-
const e = N(this.props), t = new
|
|
355
|
+
const e = N(this.props), t = new I(e, this.theme);
|
|
356
356
|
return this.syncStateToClone(t), U(t), t;
|
|
357
357
|
}
|
|
358
358
|
deepClone() {
|
|
359
359
|
const e = N(this.props, {
|
|
360
360
|
deep: !0
|
|
361
|
-
}), t = new
|
|
361
|
+
}), t = new I(e, this.theme);
|
|
362
362
|
return this.syncStateToClone(t), U(t), t;
|
|
363
363
|
}
|
|
364
364
|
syncStateToClone(e) {
|
|
@@ -370,53 +370,53 @@ class z extends q {
|
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
-
function
|
|
374
|
-
const
|
|
375
|
-
...t,
|
|
376
|
-
title:
|
|
377
|
-
...
|
|
378
|
-
},
|
|
379
|
-
return A(
|
|
373
|
+
function h(i, e, t = {}) {
|
|
374
|
+
const s = typeof e == "function" ? e : void 0, n = {
|
|
375
|
+
...e != null && typeof e != "function" ? e : t,
|
|
376
|
+
title: i,
|
|
377
|
+
...s && { action: s }
|
|
378
|
+
}, r = ee(I, n);
|
|
379
|
+
return A(r);
|
|
380
380
|
}
|
|
381
381
|
const ge = {
|
|
382
382
|
/**
|
|
383
383
|
* Filled button (primary)
|
|
384
384
|
*/
|
|
385
|
-
Filled: (
|
|
385
|
+
Filled: (i, e, t = {}) => e == null || typeof e == "function" ? h(i, e, { ...t, variant: "filled" }) : h(i, { ...e ?? {}, variant: "filled" }),
|
|
386
386
|
/**
|
|
387
387
|
* Outlined button
|
|
388
388
|
*/
|
|
389
|
-
Outlined: (
|
|
389
|
+
Outlined: (i, e, t = {}) => e == null || typeof e == "function" ? h(i, e, { ...t, variant: "outlined" }) : h(i, { ...e ?? {}, variant: "outlined" }),
|
|
390
390
|
/**
|
|
391
391
|
* Plain button (text only)
|
|
392
392
|
*/
|
|
393
|
-
Plain: (
|
|
393
|
+
Plain: (i, e, t = {}) => e == null || typeof e == "function" ? h(i, e, { ...t, variant: "plain" }) : h(i, { ...e ?? {}, variant: "plain" }),
|
|
394
394
|
/**
|
|
395
395
|
* Bordered button
|
|
396
396
|
*/
|
|
397
|
-
Bordered: (
|
|
397
|
+
Bordered: (i, e, t = {}) => e == null || typeof e == "function" ? h(i, e, { ...t, variant: "bordered" }) : h(i, { ...e ?? {}, variant: "bordered" }),
|
|
398
398
|
/**
|
|
399
399
|
* Destructive button
|
|
400
400
|
*/
|
|
401
|
-
Destructive: (
|
|
401
|
+
Destructive: (i, e, t = {}) => e == null || typeof e == "function" ? h(i, e, { ...t, role: "destructive" }) : h(i, { ...e ?? {}, role: "destructive" }),
|
|
402
402
|
/**
|
|
403
403
|
* Cancel button
|
|
404
404
|
*/
|
|
405
|
-
Cancel: (
|
|
406
|
-
},
|
|
405
|
+
Cancel: (i, e, t = {}) => e == null || typeof e == "function" ? h(i, e, { ...t, role: "cancel" }) : h(i, { ...e ?? {}, role: "cancel" })
|
|
406
|
+
}, ne = `
|
|
407
407
|
@keyframes spin {
|
|
408
408
|
from { transform: rotate(0deg); }
|
|
409
409
|
to { transform: rotate(360deg); }
|
|
410
410
|
}
|
|
411
411
|
`;
|
|
412
412
|
if (typeof document < "u") {
|
|
413
|
-
const
|
|
414
|
-
|
|
413
|
+
const i = document.createElement("style");
|
|
414
|
+
i.textContent = ne, document.head.appendChild(i);
|
|
415
415
|
}
|
|
416
|
-
var
|
|
416
|
+
var oe = Object.defineProperty, re = (i, e, t) => e in i ? oe(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, P = (i, e, t) => re(i, typeof e != "symbol" ? e + "" : e, t);
|
|
417
417
|
class G {
|
|
418
418
|
constructor(e) {
|
|
419
|
-
|
|
419
|
+
P(this, "type", "component"), P(this, "id"), P(this, "props"), this.props = e, this.id = `enhanced-link-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
420
420
|
}
|
|
421
421
|
resolveValue(e) {
|
|
422
422
|
return l(e) ? e() : e;
|
|
@@ -429,15 +429,15 @@ class G {
|
|
|
429
429
|
const e = this.resolveValue(this.props.target);
|
|
430
430
|
if (e)
|
|
431
431
|
return e;
|
|
432
|
-
const t = this.resolveValue(this.props.destination),
|
|
433
|
-
return this.isExternalURL(
|
|
432
|
+
const t = this.resolveValue(this.props.destination), s = t instanceof URL ? t.toString() : t;
|
|
433
|
+
return this.isExternalURL(s) ? "_blank" : "_self";
|
|
434
434
|
}
|
|
435
435
|
getRoutingMode() {
|
|
436
436
|
return this.resolveValue(this.props.routingMode) || "auto";
|
|
437
437
|
}
|
|
438
438
|
getRel() {
|
|
439
|
-
const e = this.resolveValue(this.props.rel), t = this.getTarget(),
|
|
440
|
-
return e &&
|
|
439
|
+
const e = this.resolveValue(this.props.rel), t = this.getTarget(), s = this.getDestination(), n = this.isExternalURL(s) && t === "_blank" ? "noopener noreferrer" : "";
|
|
440
|
+
return e && n ? `${e} ${n}`.trim() : e || n;
|
|
441
441
|
}
|
|
442
442
|
getDownload() {
|
|
443
443
|
return this.resolveValue(this.props.download);
|
|
@@ -469,8 +469,8 @@ class G {
|
|
|
469
469
|
if (this.props.onPress)
|
|
470
470
|
try {
|
|
471
471
|
this.props.onPress(e);
|
|
472
|
-
} catch (
|
|
473
|
-
console.error("Link onPress error:",
|
|
472
|
+
} catch (n) {
|
|
473
|
+
console.error("Link onPress error:", n);
|
|
474
474
|
}
|
|
475
475
|
const t = this.getDestination();
|
|
476
476
|
if (this.isSpecialScheme(t) || (e.preventDefault(), this.props.openURLAction && this.props.openURLAction(t) === "handled"))
|
|
@@ -479,21 +479,21 @@ class G {
|
|
|
479
479
|
try {
|
|
480
480
|
if (!await this.props.onBeforeNavigation(t))
|
|
481
481
|
return;
|
|
482
|
-
} catch (
|
|
483
|
-
throw console.error("Link onBeforeNavigation error:",
|
|
482
|
+
} catch (n) {
|
|
483
|
+
throw console.error("Link onBeforeNavigation error:", n), n;
|
|
484
484
|
}
|
|
485
|
-
const
|
|
485
|
+
const s = this.getTarget(), o = this.getRoutingMode();
|
|
486
486
|
if (this.shouldUseInternalRouting(t)) {
|
|
487
487
|
if (this.props.onInternalNavigation)
|
|
488
488
|
try {
|
|
489
489
|
if (await this.props.onInternalNavigation(t))
|
|
490
490
|
return;
|
|
491
|
-
} catch (
|
|
492
|
-
console.error("Link onInternalNavigation error:",
|
|
491
|
+
} catch (n) {
|
|
492
|
+
console.error("Link onInternalNavigation error:", n);
|
|
493
493
|
}
|
|
494
|
-
|
|
494
|
+
o === "spa" ? this.handleSPANavigation(t) : s === "_blank" ? window.open(t, s) : window.location.href = t;
|
|
495
495
|
} else
|
|
496
|
-
|
|
496
|
+
s === "_blank" || s === "_top" || s === "_parent" ? window.open(t, s) : window.location.href = t;
|
|
497
497
|
}
|
|
498
498
|
handleSPANavigation(e) {
|
|
499
499
|
typeof window < "u" && window.history && window.history.pushState ? (window.history.pushState(null, "", e), window.dispatchEvent(new PopStateEvent("popstate"))) : window.location.href = e;
|
|
@@ -507,15 +507,15 @@ class G {
|
|
|
507
507
|
}
|
|
508
508
|
renderContent() {
|
|
509
509
|
if (this.props.label) {
|
|
510
|
-
const
|
|
511
|
-
return Array.isArray(
|
|
510
|
+
const n = this.props.label().render();
|
|
511
|
+
return Array.isArray(n) ? n : [n];
|
|
512
512
|
}
|
|
513
513
|
if (this.props.children)
|
|
514
514
|
return this.renderChildren();
|
|
515
515
|
let e;
|
|
516
516
|
this.props.text ? e = this.props.text : l(this.props.destination) ? e = Q(() => this.getDestination()) : e = this.getDestination();
|
|
517
|
-
const
|
|
518
|
-
return Array.isArray(
|
|
517
|
+
const s = W(e).render();
|
|
518
|
+
return Array.isArray(s) ? s : [s];
|
|
519
519
|
}
|
|
520
520
|
renderChildren() {
|
|
521
521
|
const { children: e } = this.props;
|
|
@@ -523,43 +523,43 @@ class G {
|
|
|
523
523
|
}
|
|
524
524
|
renderChild(e) {
|
|
525
525
|
if (typeof e == "string") {
|
|
526
|
-
const
|
|
527
|
-
return Array.isArray(
|
|
526
|
+
const s = W(e).render();
|
|
527
|
+
return Array.isArray(s) ? s : [s];
|
|
528
528
|
} else {
|
|
529
529
|
const t = e.render();
|
|
530
530
|
return Array.isArray(t) ? t : [t];
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
render() {
|
|
534
|
-
const e = this.renderContent(), t = this.isDisabled(),
|
|
534
|
+
const e = this.renderContent(), t = this.isDisabled(), s = {
|
|
535
535
|
id: this.id,
|
|
536
536
|
"data-component": "enhanced-link"
|
|
537
537
|
};
|
|
538
|
-
l(this.props.destination) ?
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
const
|
|
544
|
-
|
|
538
|
+
l(this.props.destination) ? s.href = () => this.getDestination() : s.href = this.getDestination(), this.props.target && (l(this.props.target) ? s.target = () => this.getTarget() : s.target = this.getTarget());
|
|
539
|
+
const o = this.getRel();
|
|
540
|
+
o && (l(this.props.rel) || l(this.props.target) ? s.rel = () => this.getRel() : s.rel = o);
|
|
541
|
+
const n = this.getDownload();
|
|
542
|
+
n !== void 0 && (l(this.props.download) ? s.download = () => this.getDownload() : n === !0 ? s.download = !0 : typeof n == "string" && (s.download = n));
|
|
543
|
+
const r = this.getAccessibilityLabel();
|
|
544
|
+
r && (l(this.props.accessibilityLabel) ? s["aria-label"] = () => this.getAccessibilityLabel() : s["aria-label"] = r);
|
|
545
545
|
const c = this.getAccessibilityHint();
|
|
546
|
-
c && (l(this.props.accessibilityHint) ?
|
|
547
|
-
const
|
|
548
|
-
return
|
|
546
|
+
c && (l(this.props.accessibilityHint) ? s["aria-describedby"] = () => this.getAccessibilityHint() : s["aria-describedby"] = c);
|
|
547
|
+
const u = this.getAccessibilityRole();
|
|
548
|
+
return u && (l(this.props.accessibilityRole) ? s.role = () => this.getAccessibilityRole() : s.role = u), t && (s["aria-disabled"] = "true", s.tabindex = "-1"), s.onclick = (m) => this.handleClick(m), s.style = {
|
|
549
549
|
textDecoration: "none",
|
|
550
550
|
color: "inherit",
|
|
551
551
|
cursor: t ? "not-allowed" : "pointer",
|
|
552
552
|
opacity: t ? 0.6 : 1
|
|
553
|
-
}, a("a",
|
|
553
|
+
}, a("a", s, ...e);
|
|
554
554
|
}
|
|
555
555
|
// Concatenation support
|
|
556
556
|
concat(e) {
|
|
557
|
-
const t = this.toSegment(),
|
|
557
|
+
const t = this.toSegment(), s = e.toSegment(), o = {
|
|
558
558
|
totalSegments: 2,
|
|
559
559
|
accessibilityRole: "composite",
|
|
560
560
|
semanticStructure: "inline"
|
|
561
561
|
};
|
|
562
|
-
return new
|
|
562
|
+
return new z([t, s], o);
|
|
563
563
|
}
|
|
564
564
|
toSegment() {
|
|
565
565
|
return {
|
|
@@ -573,24 +573,24 @@ class G {
|
|
|
573
573
|
return !0;
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
|
-
function me(
|
|
576
|
+
function me(i, e) {
|
|
577
577
|
if (e !== void 0) {
|
|
578
|
-
const
|
|
579
|
-
text:
|
|
578
|
+
const o = {
|
|
579
|
+
text: i,
|
|
580
580
|
destination: e
|
|
581
|
-
},
|
|
582
|
-
return A(
|
|
581
|
+
}, n = new G(o);
|
|
582
|
+
return A(n);
|
|
583
583
|
}
|
|
584
|
-
const t =
|
|
585
|
-
return A(
|
|
584
|
+
const t = i, s = new G(t);
|
|
585
|
+
return A(s);
|
|
586
586
|
}
|
|
587
587
|
const x = {
|
|
588
588
|
/**
|
|
589
589
|
* Create an external link that opens in a new tab
|
|
590
590
|
*/
|
|
591
|
-
external(
|
|
591
|
+
external(i, e, t = {}) {
|
|
592
592
|
return {
|
|
593
|
-
destination:
|
|
593
|
+
destination: i,
|
|
594
594
|
children: e,
|
|
595
595
|
target: "_blank",
|
|
596
596
|
routingMode: "external",
|
|
@@ -602,9 +602,9 @@ const x = {
|
|
|
602
602
|
/**
|
|
603
603
|
* Create an internal link for same-domain navigation
|
|
604
604
|
*/
|
|
605
|
-
internal(
|
|
605
|
+
internal(i, e, t = {}) {
|
|
606
606
|
return {
|
|
607
|
-
destination:
|
|
607
|
+
destination: i,
|
|
608
608
|
children: e,
|
|
609
609
|
routingMode: "internal",
|
|
610
610
|
target: "_self",
|
|
@@ -614,9 +614,9 @@ const x = {
|
|
|
614
614
|
/**
|
|
615
615
|
* Create a SPA link using History API
|
|
616
616
|
*/
|
|
617
|
-
spa(
|
|
617
|
+
spa(i, e, t = {}) {
|
|
618
618
|
return {
|
|
619
|
-
destination:
|
|
619
|
+
destination: i,
|
|
620
620
|
children: e,
|
|
621
621
|
routingMode: "spa",
|
|
622
622
|
target: "_self",
|
|
@@ -627,33 +627,33 @@ const x = {
|
|
|
627
627
|
/**
|
|
628
628
|
* Create an email link with optional subject and body
|
|
629
629
|
*/
|
|
630
|
-
email(
|
|
631
|
-
let
|
|
632
|
-
const
|
|
633
|
-
return e &&
|
|
634
|
-
destination:
|
|
635
|
-
children:
|
|
636
|
-
accessibilityLabel: `Send email to ${
|
|
630
|
+
email(i, e, t, s) {
|
|
631
|
+
let o = `mailto:${i}`;
|
|
632
|
+
const n = new URLSearchParams();
|
|
633
|
+
return e && n.append("subject", e), t && n.append("body", t), n.toString() && (o += `?${n.toString()}`), {
|
|
634
|
+
destination: o,
|
|
635
|
+
children: s || i,
|
|
636
|
+
accessibilityLabel: `Send email to ${i}`,
|
|
637
637
|
accessibilityHint: "Opens your email app"
|
|
638
638
|
};
|
|
639
639
|
},
|
|
640
640
|
/**
|
|
641
641
|
* Create a phone link with formatted display
|
|
642
642
|
*/
|
|
643
|
-
phone(
|
|
643
|
+
phone(i, e) {
|
|
644
644
|
return {
|
|
645
|
-
destination: `tel:${
|
|
646
|
-
children: e ||
|
|
647
|
-
accessibilityLabel: `Call ${
|
|
645
|
+
destination: `tel:${i.replace(/[^\d+]/g, "")}`,
|
|
646
|
+
children: e || i,
|
|
647
|
+
accessibilityLabel: `Call ${i}`,
|
|
648
648
|
accessibilityHint: "Opens your phone app"
|
|
649
649
|
};
|
|
650
650
|
},
|
|
651
651
|
/**
|
|
652
652
|
* Create a download link
|
|
653
653
|
*/
|
|
654
|
-
download(
|
|
654
|
+
download(i, e, t) {
|
|
655
655
|
return {
|
|
656
|
-
destination:
|
|
656
|
+
destination: i,
|
|
657
657
|
children: t || `Download ${e || "file"}`,
|
|
658
658
|
download: e || !0,
|
|
659
659
|
accessibilityLabel: `Download ${e || "file"}`,
|
|
@@ -664,39 +664,39 @@ const x = {
|
|
|
664
664
|
* Social media link utilities
|
|
665
665
|
*/
|
|
666
666
|
social: {
|
|
667
|
-
twitter(
|
|
667
|
+
twitter(i, e) {
|
|
668
668
|
return x.external(
|
|
669
|
-
`https://twitter.com/${
|
|
670
|
-
e || `@${
|
|
671
|
-
{ accessibilityLabel: `Visit ${
|
|
669
|
+
`https://twitter.com/${i}`,
|
|
670
|
+
e || `@${i}`,
|
|
671
|
+
{ accessibilityLabel: `Visit ${i} on Twitter` }
|
|
672
672
|
);
|
|
673
673
|
},
|
|
674
|
-
github(
|
|
674
|
+
github(i, e) {
|
|
675
675
|
return x.external(
|
|
676
|
-
`https://github.com/${
|
|
677
|
-
e ||
|
|
678
|
-
{ accessibilityLabel: `Visit ${
|
|
676
|
+
`https://github.com/${i}`,
|
|
677
|
+
e || i,
|
|
678
|
+
{ accessibilityLabel: `Visit ${i} on GitHub` }
|
|
679
679
|
);
|
|
680
680
|
},
|
|
681
|
-
linkedin(
|
|
681
|
+
linkedin(i, e) {
|
|
682
682
|
return x.external(
|
|
683
|
-
`https://linkedin.com/in/${
|
|
684
|
-
e ||
|
|
685
|
-
{ accessibilityLabel: `Visit ${
|
|
683
|
+
`https://linkedin.com/in/${i}`,
|
|
684
|
+
e || i,
|
|
685
|
+
{ accessibilityLabel: `Visit ${i} on LinkedIn` }
|
|
686
686
|
);
|
|
687
687
|
},
|
|
688
|
-
instagram(
|
|
688
|
+
instagram(i, e) {
|
|
689
689
|
return x.external(
|
|
690
|
-
`https://instagram.com/${
|
|
691
|
-
e || `@${
|
|
692
|
-
{ accessibilityLabel: `Visit ${
|
|
690
|
+
`https://instagram.com/${i}`,
|
|
691
|
+
e || `@${i}`,
|
|
692
|
+
{ accessibilityLabel: `Visit ${i} on Instagram` }
|
|
693
693
|
);
|
|
694
694
|
},
|
|
695
|
-
facebook(
|
|
695
|
+
facebook(i, e) {
|
|
696
696
|
return x.external(
|
|
697
|
-
`https://facebook.com/${
|
|
698
|
-
e ||
|
|
699
|
-
{ accessibilityLabel: `Visit ${
|
|
697
|
+
`https://facebook.com/${i}`,
|
|
698
|
+
e || i,
|
|
699
|
+
{ accessibilityLabel: `Visit ${i} on Facebook` }
|
|
700
700
|
);
|
|
701
701
|
}
|
|
702
702
|
},
|
|
@@ -704,9 +704,9 @@ const x = {
|
|
|
704
704
|
* App store link utilities
|
|
705
705
|
*/
|
|
706
706
|
appStore: {
|
|
707
|
-
ios(
|
|
707
|
+
ios(i, e) {
|
|
708
708
|
return x.external(
|
|
709
|
-
`https://apps.apple.com/app/id${
|
|
709
|
+
`https://apps.apple.com/app/id${i}`,
|
|
710
710
|
e || "Download from App Store",
|
|
711
711
|
{
|
|
712
712
|
accessibilityLabel: "Download from the iOS App Store",
|
|
@@ -714,9 +714,9 @@ const x = {
|
|
|
714
714
|
}
|
|
715
715
|
);
|
|
716
716
|
},
|
|
717
|
-
android(
|
|
717
|
+
android(i, e) {
|
|
718
718
|
return x.external(
|
|
719
|
-
`https://play.google.com/store/apps/details?id=${
|
|
719
|
+
`https://play.google.com/store/apps/details?id=${i}`,
|
|
720
720
|
e || "Get it on Google Play",
|
|
721
721
|
{
|
|
722
722
|
accessibilityLabel: "Download from Google Play Store",
|
|
@@ -728,24 +728,24 @@ const x = {
|
|
|
728
728
|
/**
|
|
729
729
|
* Create a custom OpenURL action
|
|
730
730
|
*/
|
|
731
|
-
openURLAction(
|
|
732
|
-
return (e) =>
|
|
731
|
+
openURLAction(i) {
|
|
732
|
+
return (e) => i(e) ? "handled" : "systemAction";
|
|
733
733
|
}
|
|
734
734
|
};
|
|
735
|
-
var ae = Object.defineProperty, le = (
|
|
735
|
+
var ae = Object.defineProperty, le = (i, e, t) => e in i ? ae(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, S = (i, e, t) => le(i, typeof e != "symbol" ? e + "" : e, t);
|
|
736
736
|
class ce {
|
|
737
737
|
constructor(e) {
|
|
738
|
-
|
|
739
|
-
if (
|
|
740
|
-
const
|
|
738
|
+
S(this, "props", e), S(this, "type", "component"), S(this, "id"), S(this, "mounted", !1), S(this, "cleanup", []), S(this, "toggleElement", null), S(this, "setIsAnimating"), S(this, "handleToggle", async (s) => {
|
|
739
|
+
if (s.preventDefault(), this.isDisabled()) return;
|
|
740
|
+
const o = !this.getIsOn();
|
|
741
741
|
this.props.animated !== !1 && (this.setIsAnimating(!0), setTimeout(() => {
|
|
742
742
|
this.setIsAnimating(!1);
|
|
743
|
-
}, 200)), this.props.onToggle && this.props.onToggle(
|
|
743
|
+
}, 200)), this.props.onToggle && this.props.onToggle(o);
|
|
744
744
|
}), this.id = `toggle-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
745
|
-
const [, t] =
|
|
745
|
+
const [, t] = F(!1);
|
|
746
746
|
this.setIsAnimating = t, Y(() => {
|
|
747
|
-
const
|
|
748
|
-
this.toggleElement && this.toggleElement.checked !==
|
|
747
|
+
const s = this.getIsOn();
|
|
748
|
+
this.toggleElement && this.toggleElement.checked !== s && (this.toggleElement.checked = s);
|
|
749
749
|
});
|
|
750
750
|
}
|
|
751
751
|
/**
|
|
@@ -843,12 +843,12 @@ class ce {
|
|
|
843
843
|
* Render switch variant
|
|
844
844
|
*/
|
|
845
845
|
renderSwitch() {
|
|
846
|
-
const e = this.getIsOn(), t = this.isDisabled(),
|
|
847
|
-
color:
|
|
848
|
-
offColor:
|
|
849
|
-
thumbColor:
|
|
846
|
+
const e = this.getIsOn(), t = this.isDisabled(), s = this.getSizeStyles(), {
|
|
847
|
+
color: o = "#007AFF",
|
|
848
|
+
offColor: n = "#e2e8f0",
|
|
849
|
+
thumbColor: r = "#ffffff",
|
|
850
850
|
animated: c = !0
|
|
851
|
-
} = this.props,
|
|
851
|
+
} = this.props, u = e ? o : n, T = e ? `translateX(${parseInt(s.width) - parseInt(s.thumbSize) - 2}px)` : "translateX(2px)", m = this.getInputAccessibilityProps();
|
|
852
852
|
return a(
|
|
853
853
|
"div",
|
|
854
854
|
{
|
|
@@ -859,13 +859,13 @@ class ce {
|
|
|
859
859
|
},
|
|
860
860
|
// Hidden input for form integration
|
|
861
861
|
a("input", {
|
|
862
|
-
ref: (
|
|
863
|
-
this.toggleElement =
|
|
864
|
-
|
|
862
|
+
ref: (w) => {
|
|
863
|
+
this.toggleElement = w, w && !this.mounted && (w.addEventListener("change", this.handleToggle), this.cleanup.push(() => {
|
|
864
|
+
w.removeEventListener("change", this.handleToggle);
|
|
865
865
|
}));
|
|
866
866
|
},
|
|
867
867
|
type: "checkbox",
|
|
868
|
-
id:
|
|
868
|
+
id: m.id,
|
|
869
869
|
checked: e,
|
|
870
870
|
disabled: t,
|
|
871
871
|
style: {
|
|
@@ -876,19 +876,19 @@ class ce {
|
|
|
876
876
|
margin: 0,
|
|
877
877
|
cursor: t ? "not-allowed" : "pointer"
|
|
878
878
|
},
|
|
879
|
-
"aria-label":
|
|
880
|
-
"aria-labelledby":
|
|
881
|
-
"aria-describedby":
|
|
879
|
+
"aria-label": m["aria-label"],
|
|
880
|
+
"aria-labelledby": m["aria-labelledby"],
|
|
881
|
+
"aria-describedby": m["aria-describedby"]
|
|
882
882
|
}),
|
|
883
883
|
// Switch track
|
|
884
884
|
a(
|
|
885
885
|
"div",
|
|
886
886
|
{
|
|
887
887
|
style: {
|
|
888
|
-
width:
|
|
889
|
-
height:
|
|
890
|
-
backgroundColor:
|
|
891
|
-
borderRadius:
|
|
888
|
+
width: s.width,
|
|
889
|
+
height: s.height,
|
|
890
|
+
backgroundColor: u,
|
|
891
|
+
borderRadius: s.height,
|
|
892
892
|
position: "relative",
|
|
893
893
|
cursor: t ? "not-allowed" : "pointer",
|
|
894
894
|
opacity: t ? 0.5 : 1,
|
|
@@ -900,9 +900,9 @@ class ce {
|
|
|
900
900
|
// Switch thumb
|
|
901
901
|
a("div", {
|
|
902
902
|
style: {
|
|
903
|
-
width:
|
|
904
|
-
height:
|
|
905
|
-
backgroundColor:
|
|
903
|
+
width: s.thumbSize,
|
|
904
|
+
height: s.thumbSize,
|
|
905
|
+
backgroundColor: r,
|
|
906
906
|
borderRadius: "50%",
|
|
907
907
|
position: "absolute",
|
|
908
908
|
top: "50%",
|
|
@@ -919,7 +919,7 @@ class ce {
|
|
|
919
919
|
* Render checkbox variant
|
|
920
920
|
*/
|
|
921
921
|
renderCheckbox() {
|
|
922
|
-
const e = this.getIsOn(), t = this.isDisabled(),
|
|
922
|
+
const e = this.getIsOn(), t = this.isDisabled(), s = this.getSizeStyles(), { color: o = "#007AFF" } = this.props, n = this.getInputAccessibilityProps();
|
|
923
923
|
return a(
|
|
924
924
|
"div",
|
|
925
925
|
{
|
|
@@ -930,13 +930,13 @@ class ce {
|
|
|
930
930
|
},
|
|
931
931
|
// Hidden input
|
|
932
932
|
a("input", {
|
|
933
|
-
ref: (
|
|
934
|
-
this.toggleElement =
|
|
935
|
-
|
|
933
|
+
ref: (r) => {
|
|
934
|
+
this.toggleElement = r, r && !this.mounted && (r.addEventListener("change", this.handleToggle), this.cleanup.push(() => {
|
|
935
|
+
r.removeEventListener("change", this.handleToggle);
|
|
936
936
|
}));
|
|
937
937
|
},
|
|
938
938
|
type: "checkbox",
|
|
939
|
-
id:
|
|
939
|
+
id: n.id,
|
|
940
940
|
checked: e,
|
|
941
941
|
disabled: t,
|
|
942
942
|
style: {
|
|
@@ -947,20 +947,20 @@ class ce {
|
|
|
947
947
|
margin: 0,
|
|
948
948
|
cursor: t ? "not-allowed" : "pointer"
|
|
949
949
|
},
|
|
950
|
-
"aria-label":
|
|
951
|
-
"aria-labelledby":
|
|
952
|
-
"aria-describedby":
|
|
950
|
+
"aria-label": n["aria-label"],
|
|
951
|
+
"aria-labelledby": n["aria-labelledby"],
|
|
952
|
+
"aria-describedby": n["aria-describedby"]
|
|
953
953
|
}),
|
|
954
954
|
// Checkbox visual
|
|
955
955
|
a(
|
|
956
956
|
"div",
|
|
957
957
|
{
|
|
958
958
|
style: {
|
|
959
|
-
width:
|
|
960
|
-
height:
|
|
961
|
-
border: `2px solid ${e ?
|
|
959
|
+
width: s.thumbSize,
|
|
960
|
+
height: s.thumbSize,
|
|
961
|
+
border: `2px solid ${e ? o : "#d1d5db"}`,
|
|
962
962
|
borderRadius: "4px",
|
|
963
|
-
backgroundColor: e ?
|
|
963
|
+
backgroundColor: e ? o : "#ffffff",
|
|
964
964
|
display: "flex",
|
|
965
965
|
alignItems: "center",
|
|
966
966
|
justifyContent: "center",
|
|
@@ -991,24 +991,24 @@ class ce {
|
|
|
991
991
|
* Render button variant
|
|
992
992
|
*/
|
|
993
993
|
renderButton() {
|
|
994
|
-
const e = this.getIsOn(), t = this.isDisabled(),
|
|
994
|
+
const e = this.getIsOn(), t = this.isDisabled(), s = this.getSizeStyles(), { color: o = "#007AFF", offColor: n = "#f3f4f6" } = this.props;
|
|
995
995
|
return a(
|
|
996
996
|
"button",
|
|
997
997
|
{
|
|
998
|
-
ref: (
|
|
999
|
-
|
|
1000
|
-
|
|
998
|
+
ref: (r) => {
|
|
999
|
+
r && !this.mounted && (r.addEventListener("click", this.handleToggle), this.cleanup.push(() => {
|
|
1000
|
+
r.removeEventListener("click", this.handleToggle);
|
|
1001
1001
|
}));
|
|
1002
1002
|
},
|
|
1003
1003
|
type: "button",
|
|
1004
1004
|
disabled: t,
|
|
1005
1005
|
style: {
|
|
1006
1006
|
padding: "8px 16px",
|
|
1007
|
-
backgroundColor: e ?
|
|
1007
|
+
backgroundColor: e ? o : n,
|
|
1008
1008
|
color: e ? "#ffffff" : "#374151",
|
|
1009
|
-
border: `1px solid ${e ?
|
|
1009
|
+
border: `1px solid ${e ? o : "#d1d5db"}`,
|
|
1010
1010
|
borderRadius: "6px",
|
|
1011
|
-
fontSize:
|
|
1011
|
+
fontSize: s.fontSize,
|
|
1012
1012
|
fontWeight: "500",
|
|
1013
1013
|
cursor: t ? "not-allowed" : "pointer",
|
|
1014
1014
|
opacity: t ? 0.5 : 1,
|
|
@@ -1041,13 +1041,13 @@ class ce {
|
|
|
1041
1041
|
renderLabel(e = !1) {
|
|
1042
1042
|
const t = this.resolveLabel();
|
|
1043
1043
|
if (!t) return null;
|
|
1044
|
-
const
|
|
1044
|
+
const s = this.getSizeStyles();
|
|
1045
1045
|
return a(
|
|
1046
1046
|
"span",
|
|
1047
1047
|
{
|
|
1048
1048
|
id: this.getLabelId(),
|
|
1049
1049
|
style: {
|
|
1050
|
-
fontSize:
|
|
1050
|
+
fontSize: s.fontSize,
|
|
1051
1051
|
color: this.isDisabled() ? "#9ca3af" : "#374151",
|
|
1052
1052
|
cursor: this.isDisabled() ? "not-allowed" : "pointer"
|
|
1053
1053
|
},
|
|
@@ -1060,15 +1060,15 @@ class ce {
|
|
|
1060
1060
|
const {
|
|
1061
1061
|
variant: e = "switch",
|
|
1062
1062
|
labelPosition: t = "trailing",
|
|
1063
|
-
spacing:
|
|
1064
|
-
accessibilityHint:
|
|
1065
|
-
} = this.props,
|
|
1063
|
+
spacing: s = 8,
|
|
1064
|
+
accessibilityHint: o
|
|
1065
|
+
} = this.props, n = this.renderLabel(e === "button"), r = this.renderToggleControl(), c = t === "leading" && n ? [n, r] : n ? [r, n] : [r], u = e === "button" ? a(
|
|
1066
1066
|
"div",
|
|
1067
1067
|
{
|
|
1068
1068
|
style: {
|
|
1069
1069
|
display: "flex",
|
|
1070
1070
|
alignItems: "center",
|
|
1071
|
-
gap:
|
|
1071
|
+
gap: n ? `${s}px` : "0",
|
|
1072
1072
|
cursor: this.isDisabled() ? "not-allowed" : "pointer"
|
|
1073
1073
|
}
|
|
1074
1074
|
},
|
|
@@ -1080,7 +1080,7 @@ class ce {
|
|
|
1080
1080
|
style: {
|
|
1081
1081
|
display: "flex",
|
|
1082
1082
|
alignItems: "center",
|
|
1083
|
-
gap:
|
|
1083
|
+
gap: n ? `${s}px` : "0",
|
|
1084
1084
|
cursor: this.isDisabled() ? "not-allowed" : "pointer"
|
|
1085
1085
|
}
|
|
1086
1086
|
},
|
|
@@ -1089,10 +1089,10 @@ class ce {
|
|
|
1089
1089
|
return a(
|
|
1090
1090
|
"div",
|
|
1091
1091
|
{
|
|
1092
|
-
"aria-describedby":
|
|
1092
|
+
"aria-describedby": o ? `${this.id}-hint` : void 0
|
|
1093
1093
|
},
|
|
1094
|
-
|
|
1095
|
-
...
|
|
1094
|
+
u,
|
|
1095
|
+
...o ? [
|
|
1096
1096
|
a(
|
|
1097
1097
|
"div",
|
|
1098
1098
|
{
|
|
@@ -1105,74 +1105,74 @@ class ce {
|
|
|
1105
1105
|
width: "100%"
|
|
1106
1106
|
}
|
|
1107
1107
|
},
|
|
1108
|
-
d(
|
|
1108
|
+
d(o)
|
|
1109
1109
|
)
|
|
1110
1110
|
] : []
|
|
1111
1111
|
);
|
|
1112
1112
|
}
|
|
1113
1113
|
}
|
|
1114
|
-
function
|
|
1115
|
-
const t = { ...e, isOn:
|
|
1116
|
-
return A(
|
|
1114
|
+
function g(i, e = {}) {
|
|
1115
|
+
const t = { ...e, isOn: i }, s = new ce(t);
|
|
1116
|
+
return A(s);
|
|
1117
1117
|
}
|
|
1118
|
-
function j(
|
|
1119
|
-
return
|
|
1118
|
+
function j(i, e, t = {}) {
|
|
1119
|
+
return g(e, { ...t, label: i });
|
|
1120
1120
|
}
|
|
1121
1121
|
const ye = {
|
|
1122
1122
|
/**
|
|
1123
1123
|
* Switch toggle (default)
|
|
1124
1124
|
*/
|
|
1125
|
-
Switch(
|
|
1126
|
-
return
|
|
1125
|
+
Switch(i, e = {}) {
|
|
1126
|
+
return g(i, { ...e, variant: "switch" });
|
|
1127
1127
|
},
|
|
1128
1128
|
/**
|
|
1129
1129
|
* Checkbox toggle
|
|
1130
1130
|
*/
|
|
1131
|
-
Checkbox(
|
|
1132
|
-
return
|
|
1131
|
+
Checkbox(i, e = {}) {
|
|
1132
|
+
return g(i, { ...e, variant: "checkbox" });
|
|
1133
1133
|
},
|
|
1134
1134
|
/**
|
|
1135
1135
|
* Button toggle
|
|
1136
1136
|
*/
|
|
1137
|
-
Button(
|
|
1138
|
-
return
|
|
1137
|
+
Button(i, e = {}) {
|
|
1138
|
+
return g(i, { ...e, variant: "button" });
|
|
1139
1139
|
},
|
|
1140
1140
|
/**
|
|
1141
1141
|
* Small toggle
|
|
1142
1142
|
*/
|
|
1143
|
-
Small(
|
|
1144
|
-
return
|
|
1143
|
+
Small(i, e = {}) {
|
|
1144
|
+
return g(i, { ...e, size: "small" });
|
|
1145
1145
|
},
|
|
1146
1146
|
/**
|
|
1147
1147
|
* Large toggle
|
|
1148
1148
|
*/
|
|
1149
|
-
Large(
|
|
1150
|
-
return
|
|
1149
|
+
Large(i, e = {}) {
|
|
1150
|
+
return g(i, { ...e, size: "large" });
|
|
1151
1151
|
},
|
|
1152
1152
|
/**
|
|
1153
1153
|
* Custom color toggle
|
|
1154
1154
|
*/
|
|
1155
|
-
CustomColor(
|
|
1156
|
-
return
|
|
1155
|
+
CustomColor(i, e, t = {}) {
|
|
1156
|
+
return g(i, { ...t, color: e });
|
|
1157
1157
|
},
|
|
1158
1158
|
/**
|
|
1159
1159
|
* Toggle with leading label
|
|
1160
1160
|
*/
|
|
1161
|
-
WithLeadingLabel(
|
|
1162
|
-
return
|
|
1161
|
+
WithLeadingLabel(i, e, t = {}) {
|
|
1162
|
+
return g(e, { ...t, label: i, labelPosition: "leading" });
|
|
1163
1163
|
},
|
|
1164
1164
|
/**
|
|
1165
1165
|
* Toggle with trailing label (default)
|
|
1166
1166
|
*/
|
|
1167
|
-
WithTrailingLabel(
|
|
1168
|
-
return
|
|
1167
|
+
WithTrailingLabel(i, e, t = {}) {
|
|
1168
|
+
return g(e, { ...t, label: i, labelPosition: "trailing" });
|
|
1169
1169
|
}
|
|
1170
1170
|
}, Se = {
|
|
1171
1171
|
/**
|
|
1172
1172
|
* Create a toggle group with multiple options
|
|
1173
1173
|
*/
|
|
1174
|
-
createGroup(
|
|
1175
|
-
return
|
|
1174
|
+
createGroup(i, e = {}) {
|
|
1175
|
+
return i.map(
|
|
1176
1176
|
(t) => j(t.label, t.isOn, {
|
|
1177
1177
|
...e,
|
|
1178
1178
|
onToggle: t.onToggle
|
|
@@ -1182,13 +1182,13 @@ const ye = {
|
|
|
1182
1182
|
/**
|
|
1183
1183
|
* Create exclusive toggle group (radio-like behavior)
|
|
1184
1184
|
*/
|
|
1185
|
-
createExclusiveGroup(
|
|
1186
|
-
const
|
|
1187
|
-
return
|
|
1188
|
-
(
|
|
1189
|
-
...
|
|
1190
|
-
onToggle: (
|
|
1191
|
-
|
|
1185
|
+
createExclusiveGroup(i, e, t, s = {}) {
|
|
1186
|
+
const o = () => l(e) ? e() : e;
|
|
1187
|
+
return i.map(
|
|
1188
|
+
(n) => j(n.label, o() === n.key, {
|
|
1189
|
+
...s,
|
|
1190
|
+
onToggle: (r) => {
|
|
1191
|
+
r && t && t(n.key);
|
|
1192
1192
|
}
|
|
1193
1193
|
})
|
|
1194
1194
|
);
|
|
@@ -1200,47 +1200,47 @@ const ye = {
|
|
|
1200
1200
|
/**
|
|
1201
1201
|
* Toggle all items in a group
|
|
1202
1202
|
*/
|
|
1203
|
-
toggleAll(
|
|
1204
|
-
|
|
1203
|
+
toggleAll(i, e) {
|
|
1204
|
+
i.forEach((t) => {
|
|
1205
1205
|
t.onToggle && t.onToggle(e);
|
|
1206
1206
|
});
|
|
1207
1207
|
},
|
|
1208
1208
|
/**
|
|
1209
1209
|
* Get state of all toggles in a group
|
|
1210
1210
|
*/
|
|
1211
|
-
getStates(
|
|
1212
|
-
return
|
|
1211
|
+
getStates(i) {
|
|
1212
|
+
return i.map((e) => l(e.isOn) ? e.isOn() : e.isOn);
|
|
1213
1213
|
},
|
|
1214
1214
|
/**
|
|
1215
1215
|
* Check if all toggles are on
|
|
1216
1216
|
*/
|
|
1217
|
-
allOn(
|
|
1218
|
-
return this.getStates(
|
|
1217
|
+
allOn(i) {
|
|
1218
|
+
return this.getStates(i).every((e) => e);
|
|
1219
1219
|
},
|
|
1220
1220
|
/**
|
|
1221
1221
|
* Check if any toggle is on
|
|
1222
1222
|
*/
|
|
1223
|
-
anyOn(
|
|
1224
|
-
return this.getStates(
|
|
1223
|
+
anyOn(i) {
|
|
1224
|
+
return this.getStates(i).some((e) => e);
|
|
1225
1225
|
}
|
|
1226
1226
|
}
|
|
1227
1227
|
};
|
|
1228
|
-
var de = Object.defineProperty, pe = (
|
|
1228
|
+
var de = Object.defineProperty, pe = (i, e, t) => e in i ? de(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, f = (i, e, t) => pe(i, typeof e != "symbol" ? e + "" : e, t);
|
|
1229
1229
|
class he {
|
|
1230
1230
|
constructor(e) {
|
|
1231
|
-
|
|
1232
|
-
this.props.onSelectionChange && this.props.onSelectionChange(
|
|
1233
|
-
}),
|
|
1231
|
+
f(this, "props", e), f(this, "type", "component"), f(this, "id"), f(this, "mounted", !1), f(this, "cleanup", []), f(this, "isOpen"), f(this, "setIsOpen"), f(this, "searchTerm"), f(this, "setSearchTerm"), f(this, "handleSelection", (r) => {
|
|
1232
|
+
this.props.onSelectionChange && this.props.onSelectionChange(r), (this.props.variant === "dropdown" || this.props.variant === "menu") && this.setIsOpen(!1), this.setSearchTerm("");
|
|
1233
|
+
}), f(this, "toggleOpen", () => {
|
|
1234
1234
|
this.isDisabled() || this.setIsOpen(!this.isOpen());
|
|
1235
1235
|
}), this.id = `picker-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
1236
|
-
const [t,
|
|
1237
|
-
if (this.isOpen = t, this.setIsOpen =
|
|
1238
|
-
const
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1236
|
+
const [t, s] = F(!1), [o, n] = F("");
|
|
1237
|
+
if (this.isOpen = t, this.setIsOpen = s, this.searchTerm = o, this.setSearchTerm = n, typeof window < "u") {
|
|
1238
|
+
const r = (c) => {
|
|
1239
|
+
const u = document.getElementById(this.id);
|
|
1240
|
+
u && !u.contains(c.target) && this.setIsOpen(!1);
|
|
1241
1241
|
};
|
|
1242
|
-
document.addEventListener("click",
|
|
1243
|
-
document.removeEventListener("click",
|
|
1242
|
+
document.addEventListener("click", r), this.cleanup.push(() => {
|
|
1243
|
+
document.removeEventListener("click", r);
|
|
1244
1244
|
});
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
@@ -1264,7 +1264,7 @@ class he {
|
|
|
1264
1264
|
getFilteredOptions() {
|
|
1265
1265
|
const e = this.getOptions(), t = this.searchTerm().toLowerCase();
|
|
1266
1266
|
return !t || !this.props.searchable ? e : e.filter(
|
|
1267
|
-
(
|
|
1267
|
+
(s) => s.label.toLowerCase().includes(t) || s.description?.toLowerCase().includes(t)
|
|
1268
1268
|
);
|
|
1269
1269
|
}
|
|
1270
1270
|
/**
|
|
@@ -1279,7 +1279,7 @@ class he {
|
|
|
1279
1279
|
*/
|
|
1280
1280
|
getSelectedOption() {
|
|
1281
1281
|
const e = this.getSelection();
|
|
1282
|
-
return this.getOptions().find((
|
|
1282
|
+
return this.getOptions().find((s) => s.value === e) || null;
|
|
1283
1283
|
}
|
|
1284
1284
|
/**
|
|
1285
1285
|
* Get picker size styles
|
|
@@ -1311,7 +1311,7 @@ class he {
|
|
|
1311
1311
|
* Render dropdown variant
|
|
1312
1312
|
*/
|
|
1313
1313
|
renderDropdown() {
|
|
1314
|
-
const e = this.getSelectedOption(), t = this.getFilteredOptions(),
|
|
1314
|
+
const e = this.getSelectedOption(), t = this.getFilteredOptions(), s = this.getSizeStyles(), o = this.isOpen();
|
|
1315
1315
|
return a(
|
|
1316
1316
|
"div",
|
|
1317
1317
|
{
|
|
@@ -1330,7 +1330,7 @@ class he {
|
|
|
1330
1330
|
onClick: this.toggleOpen,
|
|
1331
1331
|
disabled: this.isDisabled(),
|
|
1332
1332
|
style: {
|
|
1333
|
-
...
|
|
1333
|
+
...s,
|
|
1334
1334
|
width: "100%",
|
|
1335
1335
|
display: "flex",
|
|
1336
1336
|
alignItems: "center",
|
|
@@ -1340,7 +1340,7 @@ class he {
|
|
|
1340
1340
|
borderRadius: "6px",
|
|
1341
1341
|
cursor: this.isDisabled() ? "not-allowed" : "pointer",
|
|
1342
1342
|
opacity: this.isDisabled() ? 0.6 : 1,
|
|
1343
|
-
...
|
|
1343
|
+
...o && {
|
|
1344
1344
|
borderColor: this.props.tint || "#007AFF",
|
|
1345
1345
|
boxShadow: `0 0 0 1px ${this.props.tint || "#007AFF"}`
|
|
1346
1346
|
}
|
|
@@ -1363,14 +1363,14 @@ class he {
|
|
|
1363
1363
|
style: {
|
|
1364
1364
|
fontSize: "12px",
|
|
1365
1365
|
color: "#6b7280",
|
|
1366
|
-
transform:
|
|
1366
|
+
transform: o ? "rotate(180deg)" : "rotate(0deg)",
|
|
1367
1367
|
transition: "transform 0.2s"
|
|
1368
1368
|
}
|
|
1369
1369
|
},
|
|
1370
1370
|
d("▼")
|
|
1371
1371
|
)
|
|
1372
1372
|
),
|
|
1373
|
-
...
|
|
1373
|
+
...o ? [
|
|
1374
1374
|
a(
|
|
1375
1375
|
"div",
|
|
1376
1376
|
{
|
|
@@ -1402,9 +1402,9 @@ class he {
|
|
|
1402
1402
|
type: "text",
|
|
1403
1403
|
placeholder: "Search options...",
|
|
1404
1404
|
value: this.searchTerm(),
|
|
1405
|
-
onInput: (
|
|
1406
|
-
const
|
|
1407
|
-
this.setSearchTerm(
|
|
1405
|
+
onInput: (n) => {
|
|
1406
|
+
const r = n.target;
|
|
1407
|
+
this.setSearchTerm(r.value);
|
|
1408
1408
|
},
|
|
1409
1409
|
style: {
|
|
1410
1410
|
width: "100%",
|
|
@@ -1417,21 +1417,21 @@ class he {
|
|
|
1417
1417
|
)
|
|
1418
1418
|
] : [],
|
|
1419
1419
|
...t.map(
|
|
1420
|
-
(
|
|
1420
|
+
(n) => a(
|
|
1421
1421
|
"button",
|
|
1422
1422
|
{
|
|
1423
1423
|
type: "button",
|
|
1424
|
-
key: String(
|
|
1425
|
-
onClick: () => this.handleSelection(
|
|
1426
|
-
disabled:
|
|
1424
|
+
key: String(n.value),
|
|
1425
|
+
onClick: () => this.handleSelection(n.value),
|
|
1426
|
+
disabled: n.disabled,
|
|
1427
1427
|
style: {
|
|
1428
1428
|
width: "100%",
|
|
1429
1429
|
padding: "8px 12px",
|
|
1430
1430
|
textAlign: "left",
|
|
1431
|
-
backgroundColor:
|
|
1431
|
+
backgroundColor: n.value === this.getSelection() ? "#f3f4f6" : "transparent",
|
|
1432
1432
|
border: "none",
|
|
1433
|
-
cursor:
|
|
1434
|
-
opacity:
|
|
1433
|
+
cursor: n.disabled ? "not-allowed" : "pointer",
|
|
1434
|
+
opacity: n.disabled ? 0.5 : 1,
|
|
1435
1435
|
fontSize: "14px",
|
|
1436
1436
|
display: "flex",
|
|
1437
1437
|
alignItems: "center",
|
|
@@ -1441,18 +1441,18 @@ class he {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
1443
|
},
|
|
1444
|
-
...
|
|
1444
|
+
...n.icon ? [
|
|
1445
1445
|
a(
|
|
1446
1446
|
"span",
|
|
1447
1447
|
{ style: { fontSize: "16px" } },
|
|
1448
|
-
d(
|
|
1448
|
+
d(n.icon)
|
|
1449
1449
|
)
|
|
1450
1450
|
] : [],
|
|
1451
1451
|
a(
|
|
1452
1452
|
"div",
|
|
1453
1453
|
{},
|
|
1454
|
-
a("div", {}, d(
|
|
1455
|
-
...
|
|
1454
|
+
a("div", {}, d(n.label)),
|
|
1455
|
+
...n.description ? [
|
|
1456
1456
|
a(
|
|
1457
1457
|
"div",
|
|
1458
1458
|
{
|
|
@@ -1462,7 +1462,7 @@ class he {
|
|
|
1462
1462
|
marginTop: "2px"
|
|
1463
1463
|
}
|
|
1464
1464
|
},
|
|
1465
|
-
d(
|
|
1465
|
+
d(n.description)
|
|
1466
1466
|
)
|
|
1467
1467
|
] : []
|
|
1468
1468
|
)
|
|
@@ -1490,7 +1490,7 @@ class he {
|
|
|
1490
1490
|
* Render segmented variant
|
|
1491
1491
|
*/
|
|
1492
1492
|
renderSegmented() {
|
|
1493
|
-
const e = this.getOptions(), t = this.getSelection(),
|
|
1493
|
+
const e = this.getOptions(), t = this.getSelection(), s = this.getSizeStyles();
|
|
1494
1494
|
return a(
|
|
1495
1495
|
"div",
|
|
1496
1496
|
{
|
|
@@ -1504,33 +1504,33 @@ class he {
|
|
|
1504
1504
|
"aria-label": this.props.accessibilityLabel
|
|
1505
1505
|
},
|
|
1506
1506
|
...e.map(
|
|
1507
|
-
(
|
|
1507
|
+
(o, n) => a(
|
|
1508
1508
|
"button",
|
|
1509
1509
|
{
|
|
1510
1510
|
type: "button",
|
|
1511
|
-
key: String(
|
|
1512
|
-
onClick: () => this.handleSelection(
|
|
1513
|
-
disabled:
|
|
1511
|
+
key: String(o.value),
|
|
1512
|
+
onClick: () => this.handleSelection(o.value),
|
|
1513
|
+
disabled: o.disabled || this.isDisabled(),
|
|
1514
1514
|
role: "radio",
|
|
1515
|
-
"aria-checked":
|
|
1515
|
+
"aria-checked": o.value === t,
|
|
1516
1516
|
style: {
|
|
1517
|
-
...
|
|
1517
|
+
...s,
|
|
1518
1518
|
flex: 1,
|
|
1519
1519
|
border: "none",
|
|
1520
1520
|
borderRadius: "6px",
|
|
1521
|
-
backgroundColor:
|
|
1522
|
-
color:
|
|
1523
|
-
fontWeight:
|
|
1524
|
-
cursor:
|
|
1525
|
-
opacity:
|
|
1526
|
-
boxShadow:
|
|
1521
|
+
backgroundColor: o.value === t ? "#ffffff" : "transparent",
|
|
1522
|
+
color: o.value === t ? "#1a1a1a" : "#6b7280",
|
|
1523
|
+
fontWeight: o.value === t ? "600" : "400",
|
|
1524
|
+
cursor: o.disabled || this.isDisabled() ? "not-allowed" : "pointer",
|
|
1525
|
+
opacity: o.disabled || this.isDisabled() ? 0.5 : 1,
|
|
1526
|
+
boxShadow: o.value === t ? "0 1px 2px rgba(0, 0, 0, 0.1)" : "none",
|
|
1527
1527
|
transition: "all 0.2s",
|
|
1528
1528
|
margin: "0",
|
|
1529
|
-
...
|
|
1530
|
-
...
|
|
1529
|
+
...n === 0 && { marginRight: "1px" },
|
|
1530
|
+
...n === e.length - 1 && { marginLeft: "1px" }
|
|
1531
1531
|
}
|
|
1532
1532
|
},
|
|
1533
|
-
...
|
|
1533
|
+
...o.icon ? [
|
|
1534
1534
|
a(
|
|
1535
1535
|
"span",
|
|
1536
1536
|
{
|
|
@@ -1539,10 +1539,10 @@ class he {
|
|
|
1539
1539
|
fontSize: "14px"
|
|
1540
1540
|
}
|
|
1541
1541
|
},
|
|
1542
|
-
d(
|
|
1542
|
+
d(o.icon)
|
|
1543
1543
|
)
|
|
1544
1544
|
] : [],
|
|
1545
|
-
d(
|
|
1545
|
+
d(o.label)
|
|
1546
1546
|
)
|
|
1547
1547
|
)
|
|
1548
1548
|
);
|
|
@@ -1556,11 +1556,11 @@ class he {
|
|
|
1556
1556
|
"select",
|
|
1557
1557
|
{
|
|
1558
1558
|
value: String(t),
|
|
1559
|
-
onChange: (
|
|
1560
|
-
const
|
|
1561
|
-
(
|
|
1559
|
+
onChange: (s) => {
|
|
1560
|
+
const o = s.target, n = e.find(
|
|
1561
|
+
(r) => String(r.value) === o.value
|
|
1562
1562
|
);
|
|
1563
|
-
|
|
1563
|
+
n && this.handleSelection(n.value);
|
|
1564
1564
|
},
|
|
1565
1565
|
disabled: this.isDisabled(),
|
|
1566
1566
|
style: {
|
|
@@ -1574,14 +1574,14 @@ class he {
|
|
|
1574
1574
|
}
|
|
1575
1575
|
},
|
|
1576
1576
|
...e.map(
|
|
1577
|
-
(
|
|
1577
|
+
(s) => a(
|
|
1578
1578
|
"option",
|
|
1579
1579
|
{
|
|
1580
|
-
key: String(
|
|
1581
|
-
value: String(
|
|
1582
|
-
disabled:
|
|
1580
|
+
key: String(s.value),
|
|
1581
|
+
value: String(s.value),
|
|
1582
|
+
disabled: s.disabled
|
|
1583
1583
|
},
|
|
1584
|
-
d(
|
|
1584
|
+
d(s.label)
|
|
1585
1585
|
)
|
|
1586
1586
|
)
|
|
1587
1587
|
);
|
|
@@ -1590,28 +1590,28 @@ class he {
|
|
|
1590
1590
|
const {
|
|
1591
1591
|
variant: e = "dropdown",
|
|
1592
1592
|
accessibilityLabel: t,
|
|
1593
|
-
accessibilityHint:
|
|
1594
|
-
} = this.props,
|
|
1593
|
+
accessibilityHint: s
|
|
1594
|
+
} = this.props, o = {
|
|
1595
1595
|
"aria-label": t,
|
|
1596
|
-
"aria-describedby":
|
|
1596
|
+
"aria-describedby": s ? `${this.id}-hint` : void 0
|
|
1597
1597
|
};
|
|
1598
|
-
let
|
|
1598
|
+
let n;
|
|
1599
1599
|
switch (e) {
|
|
1600
1600
|
case "segmented":
|
|
1601
|
-
|
|
1601
|
+
n = this.renderSegmented();
|
|
1602
1602
|
break;
|
|
1603
1603
|
case "wheel":
|
|
1604
|
-
|
|
1604
|
+
n = this.renderWheel();
|
|
1605
1605
|
break;
|
|
1606
1606
|
default:
|
|
1607
|
-
|
|
1607
|
+
n = this.renderDropdown();
|
|
1608
1608
|
break;
|
|
1609
1609
|
}
|
|
1610
1610
|
return a(
|
|
1611
1611
|
"div",
|
|
1612
|
+
o,
|
|
1612
1613
|
n,
|
|
1613
|
-
|
|
1614
|
-
...i ? [
|
|
1614
|
+
...s ? [
|
|
1615
1615
|
a(
|
|
1616
1616
|
"div",
|
|
1617
1617
|
{
|
|
@@ -1622,51 +1622,51 @@ class he {
|
|
|
1622
1622
|
marginTop: "4px"
|
|
1623
1623
|
}
|
|
1624
1624
|
},
|
|
1625
|
-
d(
|
|
1625
|
+
d(s)
|
|
1626
1626
|
)
|
|
1627
1627
|
] : []
|
|
1628
1628
|
);
|
|
1629
1629
|
}
|
|
1630
1630
|
}
|
|
1631
|
-
function
|
|
1632
|
-
const
|
|
1633
|
-
return A(
|
|
1631
|
+
function R(i, e, t = {}) {
|
|
1632
|
+
const s = { ...t, selection: i, options: e }, o = new he(s);
|
|
1633
|
+
return A(o);
|
|
1634
1634
|
}
|
|
1635
|
-
const
|
|
1635
|
+
const ve = {
|
|
1636
1636
|
/**
|
|
1637
1637
|
* Dropdown picker (default)
|
|
1638
1638
|
*/
|
|
1639
1639
|
// biome-ignore lint/suspicious/noExplicitAny: Generic dropdown picker requires flexible type
|
|
1640
|
-
Dropdown(
|
|
1641
|
-
return
|
|
1640
|
+
Dropdown(i, e, t = {}) {
|
|
1641
|
+
return R(i, e, { ...t, variant: "dropdown" });
|
|
1642
1642
|
},
|
|
1643
1643
|
/**
|
|
1644
1644
|
* Segmented picker
|
|
1645
1645
|
*/
|
|
1646
1646
|
// biome-ignore lint/suspicious/noExplicitAny: Generic segmented picker requires flexible type
|
|
1647
|
-
Segmented(
|
|
1648
|
-
return
|
|
1647
|
+
Segmented(i, e, t = {}) {
|
|
1648
|
+
return R(i, e, { ...t, variant: "segmented" });
|
|
1649
1649
|
},
|
|
1650
1650
|
/**
|
|
1651
1651
|
* Wheel picker (native select)
|
|
1652
1652
|
*/
|
|
1653
1653
|
// biome-ignore lint/suspicious/noExplicitAny: Generic wheel picker requires flexible type
|
|
1654
|
-
Wheel(
|
|
1655
|
-
return
|
|
1654
|
+
Wheel(i, e, t = {}) {
|
|
1655
|
+
return R(i, e, { ...t, variant: "wheel" });
|
|
1656
1656
|
},
|
|
1657
1657
|
/**
|
|
1658
1658
|
* Menu picker
|
|
1659
1659
|
*/
|
|
1660
1660
|
// biome-ignore lint/suspicious/noExplicitAny: Generic menu picker requires flexible type
|
|
1661
|
-
Menu(
|
|
1662
|
-
return
|
|
1661
|
+
Menu(i, e, t = {}) {
|
|
1662
|
+
return R(i, e, { ...t, variant: "menu" });
|
|
1663
1663
|
}
|
|
1664
|
-
},
|
|
1664
|
+
}, xe = {
|
|
1665
1665
|
/**
|
|
1666
1666
|
* Create options from simple array
|
|
1667
1667
|
*/
|
|
1668
|
-
fromArray(
|
|
1669
|
-
return
|
|
1668
|
+
fromArray(i, e) {
|
|
1669
|
+
return i.map((t) => ({
|
|
1670
1670
|
value: t,
|
|
1671
1671
|
label: String(e && typeof t == "object" && t !== null ? t[e] : t)
|
|
1672
1672
|
}));
|
|
@@ -1674,8 +1674,8 @@ const xe = {
|
|
|
1674
1674
|
/**
|
|
1675
1675
|
* Create options from enum
|
|
1676
1676
|
*/
|
|
1677
|
-
fromEnum(
|
|
1678
|
-
return Object.entries(
|
|
1677
|
+
fromEnum(i) {
|
|
1678
|
+
return Object.entries(i).map(([e, t]) => ({
|
|
1679
1679
|
value: t,
|
|
1680
1680
|
label: e.replace(/([A-Z])/g, " $1").trim()
|
|
1681
1681
|
}));
|
|
@@ -1683,28 +1683,28 @@ const xe = {
|
|
|
1683
1683
|
/**
|
|
1684
1684
|
* Group options by category
|
|
1685
1685
|
*/
|
|
1686
|
-
grouped(
|
|
1687
|
-
return
|
|
1686
|
+
grouped(i) {
|
|
1687
|
+
return i.reduce(
|
|
1688
1688
|
(e, t) => {
|
|
1689
|
-
const
|
|
1690
|
-
return e[
|
|
1689
|
+
const s = t.category || "Other";
|
|
1690
|
+
return e[s] || (e[s] = []), e[s].push(t), e;
|
|
1691
1691
|
},
|
|
1692
1692
|
{}
|
|
1693
1693
|
);
|
|
1694
1694
|
}
|
|
1695
1695
|
};
|
|
1696
1696
|
export {
|
|
1697
|
-
|
|
1698
|
-
|
|
1697
|
+
h as B,
|
|
1698
|
+
I as E,
|
|
1699
1699
|
me as L,
|
|
1700
|
-
|
|
1701
|
-
|
|
1700
|
+
R as P,
|
|
1701
|
+
g as T,
|
|
1702
1702
|
ge as a,
|
|
1703
1703
|
he as b,
|
|
1704
1704
|
ce as c,
|
|
1705
1705
|
x as d,
|
|
1706
|
-
|
|
1707
|
-
|
|
1706
|
+
ve as e,
|
|
1707
|
+
xe as f,
|
|
1708
1708
|
ye as g,
|
|
1709
1709
|
Se as h,
|
|
1710
1710
|
j as i,
|