@tachui/primitives 0.8.8 → 0.8.11
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/dist/{Picker-DKphYduj.js → Picker-CpERkpVp.js} +264 -226
- package/dist/{ScrollView-CBqSqatM.js → ScrollView-DRLSVdbJ.js} +59 -44
- package/dist/{Text-D0CYYD-Q.js → Text-WpP4H9se.js} +76 -46
- package/dist/controls/Toggle.d.ts +3 -0
- package/dist/controls/Toggle.d.ts.map +1 -1
- package/dist/controls/index.js +1 -1
- package/dist/display/HTML.d.ts +10 -0
- package/dist/display/HTML.d.ts.map +1 -1
- package/dist/display/Text.d.ts +34 -35
- package/dist/display/Text.d.ts.map +1 -1
- package/dist/display/index.d.ts +1 -1
- package/dist/display/index.d.ts.map +1 -1
- package/dist/display/index.js +17 -16
- package/dist/index.js +52 -51
- package/dist/layout/Spacer.d.ts.map +1 -1
- package/dist/layout/index.js +1 -0
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { withModifiers as
|
|
1
|
+
import { withModifiers as A, ComponentWithCSSClasses as q, createSignal as R, useLifecycle as J, createEffect as Y, isSignal as l, ColorAsset as E, h as a, text as d, ConcatenatedComponent as P, clonePropsPreservingReactivity as N, resetLifecycleState as U, createComputed as Q } from "@tachui/core";
|
|
2
2
|
import { createComponentInstance as ee } from "@tachui/core/components";
|
|
3
|
-
import { T as
|
|
3
|
+
import { T as W } from "./Text-WpP4H9se.js";
|
|
4
4
|
var te = Object.defineProperty, ie = (s, e, t) => e in s ? te(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, y = (s, e, t) => ie(s, typeof e != "symbol" ? e + "" : e, t);
|
|
5
5
|
const se = {
|
|
6
6
|
colors: {
|
|
@@ -34,8 +34,8 @@ const se = {
|
|
|
34
34
|
class z extends q {
|
|
35
35
|
constructor(e, t = se) {
|
|
36
36
|
super(), 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 [i,
|
|
38
|
-
this.stateSignal = i, this.setState =
|
|
37
|
+
const [i, n] = R("normal");
|
|
38
|
+
this.stateSignal = i, this.setState = n, this.setupDOMEventListeners();
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Set up DOM event listeners for button interactions
|
|
@@ -51,12 +51,12 @@ class z extends q {
|
|
|
51
51
|
* Set up reactive style updates based on state changes
|
|
52
52
|
*/
|
|
53
53
|
setupReactiveStyles(e) {
|
|
54
|
-
const t =
|
|
54
|
+
const t = Y(() => {
|
|
55
55
|
this.stateSignal(), this.isEnabled(), this.isLoading();
|
|
56
|
-
const { tint: i, backgroundColor:
|
|
57
|
-
i && l(i) ? i() : i instanceof
|
|
58
|
-
const
|
|
59
|
-
this.applyStylesToElement(e,
|
|
56
|
+
const { tint: i, backgroundColor: n, foregroundColor: r } = this.props;
|
|
57
|
+
i && l(i) ? i() : i instanceof E && i.resolve(), n && l(n) ? n() : n instanceof E && n.resolve(), r && l(r) ? r() : r instanceof E && r.resolve();
|
|
58
|
+
const o = this.getButtonStyles();
|
|
59
|
+
this.applyStylesToElement(e, o);
|
|
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(([i,
|
|
70
|
-
const
|
|
71
|
-
if (typeof
|
|
72
|
-
const
|
|
73
|
-
process.env.NODE_ENV === "development" &&
|
|
69
|
+
Object.entries(t).forEach(([i, n]) => {
|
|
70
|
+
const r = this.camelToKebabCase(i);
|
|
71
|
+
if (typeof n == "string" || typeof n == "number") {
|
|
72
|
+
const o = e.style.getPropertyValue(r), c = o && o !== "" && o !== "inherit";
|
|
73
|
+
process.env.NODE_ENV === "development" && r === "font-family" && (console.log("[Button.applyButtonStyles] Font-family check:"), console.log("[Button.applyButtonStyles] property:", i, "cssProperty:", r), console.log("[Button.applyButtonStyles] currentValue:", o), console.log("[Button.applyButtonStyles] hasModifierValue:", c), console.log("[Button.applyButtonStyles] will set to:", n)), r === "transform" ? e.style.setProperty(r, String(n)) : c ? process.env.NODE_ENV === "development" && r === "font-family" && console.log("[Button.applyButtonStyles] Button SKIPPED font-family (has modifier value):", o) : (e.style.setProperty(r, String(n)), process.env.NODE_ENV === "development" && r === "font-family" && (console.log("[Button.applyButtonStyles] Button SET font-family to:", String(n)), 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 E)
|
|
93
93
|
return e.resolve();
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -138,8 +138,8 @@ class z extends q {
|
|
|
138
138
|
onClick: this.props.action ? () => {
|
|
139
139
|
try {
|
|
140
140
|
this.props.action?.();
|
|
141
|
-
} catch (
|
|
142
|
-
console.error("Button action error:",
|
|
141
|
+
} catch (o) {
|
|
142
|
+
console.error("Button action error:", o);
|
|
143
143
|
}
|
|
144
144
|
} : void 0,
|
|
145
145
|
// Pass through debug label for debug system
|
|
@@ -166,7 +166,7 @@ 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((n) => t.properties[n] !== void 0) : !1);
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
172
|
* Check if the button has typography-related modifiers applied
|
|
@@ -191,16 +191,16 @@ class z extends q {
|
|
|
191
191
|
variant: e,
|
|
192
192
|
size: t,
|
|
193
193
|
role: i = "none",
|
|
194
|
-
tint:
|
|
195
|
-
backgroundColor:
|
|
196
|
-
foregroundColor:
|
|
197
|
-
} = this.props, c = this.stateSignal(),
|
|
194
|
+
tint: n,
|
|
195
|
+
backgroundColor: r,
|
|
196
|
+
foregroundColor: o
|
|
197
|
+
} = this.props, c = this.stateSignal(), h = this.isLoading(), T = this.isEnabled(), g = this.hasColorModifiers(), v = this.hasTypographyModifiers(), w = {
|
|
198
198
|
// Only set color property if no modifiers will handle it
|
|
199
199
|
// This prevents conflicts between Button styles and AppearanceModifier
|
|
200
|
-
...!
|
|
200
|
+
...!g && !o && !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
|
+
...!v && {
|
|
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 k = 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
|
+
w.padding = `${k}px ${k * 2}px`, w.borderRadius = `${Z}px`, w.fontSize = `${H.size}px`, w.fontWeight = H.weight, w.minHeight = K[t];
|
|
224
224
|
}
|
|
225
|
-
let
|
|
226
|
-
const X = this.resolveColorValue(
|
|
225
|
+
let u = "transparent", m = "transparent", _ = "1px", C;
|
|
226
|
+
const X = this.resolveColorValue(n), O = this.resolveColorValue(r), D = this.resolveColorValue(o);
|
|
227
227
|
if (e) {
|
|
228
|
-
const
|
|
228
|
+
const k = X || this.theme.colors.primary;
|
|
229
229
|
switch (e) {
|
|
230
230
|
case "filled":
|
|
231
|
-
i === "destructive" ?
|
|
231
|
+
i === "destructive" ? u = this.theme.colors.destructive : i === "cancel" ? u = this.theme.colors.secondary : u = k, C = this.theme.colors.onPrimary;
|
|
232
232
|
break;
|
|
233
233
|
case "outlined":
|
|
234
|
-
m = i === "destructive" ? this.theme.colors.destructive :
|
|
234
|
+
m = i === "destructive" ? this.theme.colors.destructive : k, C = i === "destructive" ? this.theme.colors.destructive : k;
|
|
235
235
|
break;
|
|
236
236
|
case "bordered":
|
|
237
|
-
|
|
237
|
+
u = this.theme.colors.background, m = this.theme.colors.border;
|
|
238
238
|
break;
|
|
239
239
|
case "borderedProminent":
|
|
240
|
-
|
|
240
|
+
u = this.theme.colors.surface, m = this.theme.colors.primary, _ = "2px";
|
|
241
241
|
break;
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
O && (
|
|
245
|
-
let F = "1",
|
|
246
|
-
|
|
244
|
+
O && (u = O), D && (C = D);
|
|
245
|
+
let F = "1", I = "auto", B, V = "none";
|
|
246
|
+
T ? h ? (F = "0.6", I = "none") : c === "pressed" ? (u = this.darkenColor(u, 0.1), m = this.darkenColor(m, 0.1), B = "scale(0.95)") : c === "focused" && (V = "0 0 0 3px #007AFF40") : (u = this.theme.colors.disabled, m = this.theme.colors.disabled, C = this.theme.colors.disabled, F = "0.6", I = "none");
|
|
247
247
|
const p = {
|
|
248
|
-
...
|
|
248
|
+
...w
|
|
249
249
|
// Size-based styles (only if size provided)
|
|
250
250
|
};
|
|
251
|
-
return e && (p.backgroundColor =
|
|
251
|
+
return e && (p.backgroundColor = u, p.borderColor = m, p.borderWidth = _, C !== void 0 && (p.color = C)), O && (p.backgroundColor = O), D && (p.color = D), p.cursor = T ? "pointer" : "not-allowed", p.opacity = F, p.pointerEvents = I, p.transform = B !== void 0 ? B : "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 i = e.slice(1),
|
|
283
|
-
return `#${(
|
|
282
|
+
const i = e.slice(1), n = parseInt(i, 16), r = Math.max(0, Math.floor((n >> 16) * (1 - t))), o = Math.max(0, Math.floor((n >> 8 & 255) * (1 - t))), c = Math.max(0, Math.floor((n & 255) * (1 - t)));
|
|
283
|
+
return `#${(r << 16 | o << 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(), i = e.toSegment(),
|
|
295
|
-
totalSegments: e instanceof
|
|
296
|
-
accessibilityRole: e instanceof
|
|
294
|
+
const t = this.toSegment(), i = e.toSegment(), n = {
|
|
295
|
+
totalSegments: e instanceof P ? e.segments.length + 1 : 2,
|
|
296
|
+
accessibilityRole: e instanceof P ? 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 P([t, i], n);
|
|
304
304
|
}
|
|
305
305
|
/**
|
|
306
306
|
* Convert this button to a segment for concatenation
|
|
@@ -352,14 +352,14 @@ class z extends q {
|
|
|
352
352
|
return e.deep ? this.deepClone() : this.shallowClone();
|
|
353
353
|
}
|
|
354
354
|
shallowClone() {
|
|
355
|
-
const e =
|
|
356
|
-
return this.syncStateToClone(t),
|
|
355
|
+
const e = N(this.props), t = new z(e, this.theme);
|
|
356
|
+
return this.syncStateToClone(t), U(t), t;
|
|
357
357
|
}
|
|
358
358
|
deepClone() {
|
|
359
|
-
const e =
|
|
359
|
+
const e = N(this.props, {
|
|
360
360
|
deep: !0
|
|
361
361
|
}), t = new z(e, this.theme);
|
|
362
|
-
return this.syncStateToClone(t),
|
|
362
|
+
return this.syncStateToClone(t), U(t), t;
|
|
363
363
|
}
|
|
364
364
|
syncStateToClone(e) {
|
|
365
365
|
try {
|
|
@@ -370,40 +370,40 @@ class z extends q {
|
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
-
function
|
|
373
|
+
function L(s, e, t = {}) {
|
|
374
374
|
const i = {
|
|
375
375
|
...t,
|
|
376
376
|
title: s,
|
|
377
377
|
...e && { action: e }
|
|
378
|
-
},
|
|
379
|
-
return
|
|
378
|
+
}, n = ee(z, i);
|
|
379
|
+
return A(n);
|
|
380
380
|
}
|
|
381
|
-
const
|
|
381
|
+
const ge = {
|
|
382
382
|
/**
|
|
383
383
|
* Filled button (primary)
|
|
384
384
|
*/
|
|
385
|
-
Filled: (s, e, t = {}) =>
|
|
385
|
+
Filled: (s, e, t = {}) => L(s, e, { ...t, variant: "filled" }),
|
|
386
386
|
/**
|
|
387
387
|
* Outlined button
|
|
388
388
|
*/
|
|
389
|
-
Outlined: (s, e, t = {}) =>
|
|
389
|
+
Outlined: (s, e, t = {}) => L(s, e, { ...t, variant: "outlined" }),
|
|
390
390
|
/**
|
|
391
391
|
* Plain button (text only)
|
|
392
392
|
*/
|
|
393
|
-
Plain: (s, e, t = {}) =>
|
|
393
|
+
Plain: (s, e, t = {}) => L(s, e, { ...t, variant: "plain" }),
|
|
394
394
|
/**
|
|
395
395
|
* Bordered button
|
|
396
396
|
*/
|
|
397
|
-
Bordered: (s, e, t = {}) =>
|
|
397
|
+
Bordered: (s, e, t = {}) => L(s, e, { ...t, variant: "bordered" }),
|
|
398
398
|
/**
|
|
399
399
|
* Destructive button
|
|
400
400
|
*/
|
|
401
|
-
Destructive: (s, e, t = {}) =>
|
|
401
|
+
Destructive: (s, e, t = {}) => L(s, e, { ...t, role: "destructive" }),
|
|
402
402
|
/**
|
|
403
403
|
* Cancel button
|
|
404
404
|
*/
|
|
405
|
-
Cancel: (s, e, t = {}) =>
|
|
406
|
-
},
|
|
405
|
+
Cancel: (s, e, t = {}) => L(s, e, { ...t, role: "cancel" })
|
|
406
|
+
}, re = `
|
|
407
407
|
@keyframes spin {
|
|
408
408
|
from { transform: rotate(0deg); }
|
|
409
409
|
to { transform: rotate(360deg); }
|
|
@@ -411,10 +411,10 @@ const be = {
|
|
|
411
411
|
`;
|
|
412
412
|
if (typeof document < "u") {
|
|
413
413
|
const s = document.createElement("style");
|
|
414
|
-
s.textContent =
|
|
414
|
+
s.textContent = re, document.head.appendChild(s);
|
|
415
415
|
}
|
|
416
|
-
var
|
|
417
|
-
class
|
|
416
|
+
var ne = Object.defineProperty, oe = (s, e, t) => e in s ? ne(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, M = (s, e, t) => oe(s, typeof e != "symbol" ? e + "" : e, t);
|
|
417
|
+
class G {
|
|
418
418
|
constructor(e) {
|
|
419
419
|
M(this, "type", "component"), M(this, "id"), M(this, "props"), this.props = e, this.id = `enhanced-link-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
420
420
|
}
|
|
@@ -436,8 +436,8 @@ class W {
|
|
|
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(), i = this.getDestination(),
|
|
440
|
-
return e &&
|
|
439
|
+
const e = this.resolveValue(this.props.rel), t = this.getTarget(), i = this.getDestination(), r = this.isExternalURL(i) && t === "_blank" ? "noopener noreferrer" : "";
|
|
440
|
+
return e && r ? `${e} ${r}`.trim() : e || r;
|
|
441
441
|
}
|
|
442
442
|
getDownload() {
|
|
443
443
|
return this.resolveValue(this.props.download);
|
|
@@ -469,8 +469,8 @@ class W {
|
|
|
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 (r) {
|
|
473
|
+
console.error("Link onPress error:", r);
|
|
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,19 +479,19 @@ class W {
|
|
|
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 (r) {
|
|
483
|
+
throw console.error("Link onBeforeNavigation error:", r), r;
|
|
484
484
|
}
|
|
485
|
-
const i = this.getTarget(),
|
|
485
|
+
const i = this.getTarget(), n = 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 (r) {
|
|
492
|
+
console.error("Link onInternalNavigation error:", r);
|
|
493
493
|
}
|
|
494
|
-
|
|
494
|
+
n === "spa" ? this.handleSPANavigation(t) : i === "_blank" ? window.open(t, i) : window.location.href = t;
|
|
495
495
|
} else
|
|
496
496
|
i === "_blank" || i === "_top" || i === "_parent" ? window.open(t, i) : window.location.href = t;
|
|
497
497
|
}
|
|
@@ -507,14 +507,14 @@ class W {
|
|
|
507
507
|
}
|
|
508
508
|
renderContent() {
|
|
509
509
|
if (this.props.label) {
|
|
510
|
-
const
|
|
511
|
-
return Array.isArray(
|
|
510
|
+
const r = this.props.label().render();
|
|
511
|
+
return Array.isArray(r) ? r : [r];
|
|
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 i =
|
|
517
|
+
const i = W(e).render();
|
|
518
518
|
return Array.isArray(i) ? i : [i];
|
|
519
519
|
}
|
|
520
520
|
renderChildren() {
|
|
@@ -523,7 +523,7 @@ class W {
|
|
|
523
523
|
}
|
|
524
524
|
renderChild(e) {
|
|
525
525
|
if (typeof e == "string") {
|
|
526
|
-
const i =
|
|
526
|
+
const i = W(e).render();
|
|
527
527
|
return Array.isArray(i) ? i : [i];
|
|
528
528
|
} else {
|
|
529
529
|
const t = e.render();
|
|
@@ -536,16 +536,16 @@ class W {
|
|
|
536
536
|
"data-component": "enhanced-link"
|
|
537
537
|
};
|
|
538
538
|
l(this.props.destination) ? i.href = () => this.getDestination() : i.href = this.getDestination(), this.props.target && (l(this.props.target) ? i.target = () => this.getTarget() : i.target = this.getTarget());
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
const
|
|
544
|
-
|
|
539
|
+
const n = this.getRel();
|
|
540
|
+
n && (l(this.props.rel) || l(this.props.target) ? i.rel = () => this.getRel() : i.rel = n);
|
|
541
|
+
const r = this.getDownload();
|
|
542
|
+
r !== void 0 && (l(this.props.download) ? i.download = () => this.getDownload() : r === !0 ? i.download = !0 : typeof r == "string" && (i.download = r));
|
|
543
|
+
const o = this.getAccessibilityLabel();
|
|
544
|
+
o && (l(this.props.accessibilityLabel) ? i["aria-label"] = () => this.getAccessibilityLabel() : i["aria-label"] = o);
|
|
545
545
|
const c = this.getAccessibilityHint();
|
|
546
546
|
c && (l(this.props.accessibilityHint) ? i["aria-describedby"] = () => this.getAccessibilityHint() : i["aria-describedby"] = c);
|
|
547
|
-
const
|
|
548
|
-
return
|
|
547
|
+
const h = this.getAccessibilityRole();
|
|
548
|
+
return h && (l(this.props.accessibilityRole) ? i.role = () => this.getAccessibilityRole() : i.role = h), t && (i["aria-disabled"] = "true", i.tabindex = "-1"), i.onclick = (g) => this.handleClick(g), i.style = {
|
|
549
549
|
textDecoration: "none",
|
|
550
550
|
color: "inherit",
|
|
551
551
|
cursor: t ? "not-allowed" : "pointer",
|
|
@@ -554,12 +554,12 @@ class W {
|
|
|
554
554
|
}
|
|
555
555
|
// Concatenation support
|
|
556
556
|
concat(e) {
|
|
557
|
-
const t = this.toSegment(), i = e.toSegment(),
|
|
557
|
+
const t = this.toSegment(), i = e.toSegment(), n = {
|
|
558
558
|
totalSegments: 2,
|
|
559
559
|
accessibilityRole: "composite",
|
|
560
560
|
semanticStructure: "inline"
|
|
561
561
|
};
|
|
562
|
-
return new
|
|
562
|
+
return new P([t, i], n);
|
|
563
563
|
}
|
|
564
564
|
toSegment() {
|
|
565
565
|
return {
|
|
@@ -575,14 +575,14 @@ class W {
|
|
|
575
575
|
}
|
|
576
576
|
function me(s, e) {
|
|
577
577
|
if (e !== void 0) {
|
|
578
|
-
const
|
|
578
|
+
const n = {
|
|
579
579
|
text: s,
|
|
580
580
|
destination: e
|
|
581
|
-
},
|
|
582
|
-
return
|
|
581
|
+
}, r = new G(n);
|
|
582
|
+
return A(r);
|
|
583
583
|
}
|
|
584
|
-
const t = s, i = new
|
|
585
|
-
return
|
|
584
|
+
const t = s, i = new G(t);
|
|
585
|
+
return A(i);
|
|
586
586
|
}
|
|
587
587
|
const S = {
|
|
588
588
|
/**
|
|
@@ -628,10 +628,10 @@ const S = {
|
|
|
628
628
|
* Create an email link with optional subject and body
|
|
629
629
|
*/
|
|
630
630
|
email(s, e, t, i) {
|
|
631
|
-
let
|
|
632
|
-
const
|
|
633
|
-
return e &&
|
|
634
|
-
destination:
|
|
631
|
+
let n = `mailto:${s}`;
|
|
632
|
+
const r = new URLSearchParams();
|
|
633
|
+
return e && r.append("subject", e), t && r.append("body", t), r.toString() && (n += `?${r.toString()}`), {
|
|
634
|
+
destination: n,
|
|
635
635
|
children: i || s,
|
|
636
636
|
accessibilityLabel: `Send email to ${s}`,
|
|
637
637
|
accessibilityHint: "Opens your email app"
|
|
@@ -737,13 +737,13 @@ class ce {
|
|
|
737
737
|
constructor(e) {
|
|
738
738
|
this.props = e, x(this, "type", "component"), x(this, "id"), x(this, "mounted", !1), x(this, "cleanup", []), x(this, "toggleElement", null), x(this, "setIsAnimating"), x(this, "handleToggle", async (i) => {
|
|
739
739
|
if (i.preventDefault(), this.isDisabled()) return;
|
|
740
|
-
const
|
|
740
|
+
const n = !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(n);
|
|
744
744
|
}), this.id = `toggle-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
745
745
|
const [, t] = R(!1);
|
|
746
|
-
this.setIsAnimating = t,
|
|
746
|
+
this.setIsAnimating = t, Y(() => {
|
|
747
747
|
const i = this.getIsOn();
|
|
748
748
|
this.toggleElement && this.toggleElement.checked !== i && (this.toggleElement.checked = i);
|
|
749
749
|
});
|
|
@@ -788,6 +788,21 @@ class ce {
|
|
|
788
788
|
const { label: e } = this.props;
|
|
789
789
|
return e ? typeof e == "string" ? e : typeof e == "function" || l(e) ? e() : e : null;
|
|
790
790
|
}
|
|
791
|
+
getInputId() {
|
|
792
|
+
return `${this.id}-input`;
|
|
793
|
+
}
|
|
794
|
+
getLabelId() {
|
|
795
|
+
return `${this.id}-label`;
|
|
796
|
+
}
|
|
797
|
+
getInputAccessibilityProps() {
|
|
798
|
+
const t = this.resolveLabel() !== null;
|
|
799
|
+
return {
|
|
800
|
+
id: this.getInputId(),
|
|
801
|
+
"aria-label": this.props.accessibilityLabel,
|
|
802
|
+
"aria-labelledby": this.props.accessibilityLabel || !t ? void 0 : this.getLabelId(),
|
|
803
|
+
"aria-describedby": this.props.accessibilityHint ? `${this.id}-hint` : void 0
|
|
804
|
+
};
|
|
805
|
+
}
|
|
791
806
|
/**
|
|
792
807
|
* Helper to render component content safely
|
|
793
808
|
*/
|
|
@@ -829,11 +844,11 @@ class ce {
|
|
|
829
844
|
*/
|
|
830
845
|
renderSwitch() {
|
|
831
846
|
const e = this.getIsOn(), t = this.isDisabled(), i = this.getSizeStyles(), {
|
|
832
|
-
color:
|
|
833
|
-
offColor:
|
|
834
|
-
thumbColor:
|
|
847
|
+
color: n = "#007AFF",
|
|
848
|
+
offColor: r = "#e2e8f0",
|
|
849
|
+
thumbColor: o = "#ffffff",
|
|
835
850
|
animated: c = !0
|
|
836
|
-
} = this.props,
|
|
851
|
+
} = this.props, h = e ? n : r, T = e ? `translateX(${parseInt(i.width) - parseInt(i.thumbSize) - 2}px)` : "translateX(2px)", g = this.getInputAccessibilityProps();
|
|
837
852
|
return a(
|
|
838
853
|
"div",
|
|
839
854
|
{
|
|
@@ -844,12 +859,13 @@ class ce {
|
|
|
844
859
|
},
|
|
845
860
|
// Hidden input for form integration
|
|
846
861
|
a("input", {
|
|
847
|
-
ref: (
|
|
848
|
-
this.toggleElement =
|
|
849
|
-
|
|
862
|
+
ref: (v) => {
|
|
863
|
+
this.toggleElement = v, v && !this.mounted && (v.addEventListener("change", this.handleToggle), this.cleanup.push(() => {
|
|
864
|
+
v.removeEventListener("change", this.handleToggle);
|
|
850
865
|
}));
|
|
851
866
|
},
|
|
852
867
|
type: "checkbox",
|
|
868
|
+
id: g.id,
|
|
853
869
|
checked: e,
|
|
854
870
|
disabled: t,
|
|
855
871
|
style: {
|
|
@@ -860,8 +876,9 @@ class ce {
|
|
|
860
876
|
margin: 0,
|
|
861
877
|
cursor: t ? "not-allowed" : "pointer"
|
|
862
878
|
},
|
|
863
|
-
"aria-label":
|
|
864
|
-
"aria-
|
|
879
|
+
"aria-label": g["aria-label"],
|
|
880
|
+
"aria-labelledby": g["aria-labelledby"],
|
|
881
|
+
"aria-describedby": g["aria-describedby"]
|
|
865
882
|
}),
|
|
866
883
|
// Switch track
|
|
867
884
|
a(
|
|
@@ -870,7 +887,7 @@ class ce {
|
|
|
870
887
|
style: {
|
|
871
888
|
width: i.width,
|
|
872
889
|
height: i.height,
|
|
873
|
-
backgroundColor:
|
|
890
|
+
backgroundColor: h,
|
|
874
891
|
borderRadius: i.height,
|
|
875
892
|
position: "relative",
|
|
876
893
|
cursor: t ? "not-allowed" : "pointer",
|
|
@@ -878,19 +895,18 @@ class ce {
|
|
|
878
895
|
transition: c ? "background-color 0.2s ease" : "none",
|
|
879
896
|
border: "1px solid rgba(0,0,0,0.1)",
|
|
880
897
|
boxShadow: "inset 0 1px 2px rgba(0,0,0,0.1)"
|
|
881
|
-
}
|
|
882
|
-
onClick: this.handleToggle
|
|
898
|
+
}
|
|
883
899
|
},
|
|
884
900
|
// Switch thumb
|
|
885
901
|
a("div", {
|
|
886
902
|
style: {
|
|
887
903
|
width: i.thumbSize,
|
|
888
904
|
height: i.thumbSize,
|
|
889
|
-
backgroundColor:
|
|
905
|
+
backgroundColor: o,
|
|
890
906
|
borderRadius: "50%",
|
|
891
907
|
position: "absolute",
|
|
892
908
|
top: "50%",
|
|
893
|
-
transform: `translateY(-50%) ${
|
|
909
|
+
transform: `translateY(-50%) ${T}`,
|
|
894
910
|
transition: c ? "transform 0.2s ease" : "none",
|
|
895
911
|
boxShadow: "0 2px 4px rgba(0,0,0,0.2)",
|
|
896
912
|
border: "1px solid rgba(0,0,0,0.1)"
|
|
@@ -903,7 +919,7 @@ class ce {
|
|
|
903
919
|
* Render checkbox variant
|
|
904
920
|
*/
|
|
905
921
|
renderCheckbox() {
|
|
906
|
-
const e = this.getIsOn(), t = this.isDisabled(), i = this.getSizeStyles(), { color:
|
|
922
|
+
const e = this.getIsOn(), t = this.isDisabled(), i = this.getSizeStyles(), { color: n = "#007AFF" } = this.props, r = this.getInputAccessibilityProps();
|
|
907
923
|
return a(
|
|
908
924
|
"div",
|
|
909
925
|
{
|
|
@@ -920,6 +936,7 @@ class ce {
|
|
|
920
936
|
}));
|
|
921
937
|
},
|
|
922
938
|
type: "checkbox",
|
|
939
|
+
id: r.id,
|
|
923
940
|
checked: e,
|
|
924
941
|
disabled: t,
|
|
925
942
|
style: {
|
|
@@ -929,7 +946,10 @@ class ce {
|
|
|
929
946
|
height: "100%",
|
|
930
947
|
margin: 0,
|
|
931
948
|
cursor: t ? "not-allowed" : "pointer"
|
|
932
|
-
}
|
|
949
|
+
},
|
|
950
|
+
"aria-label": r["aria-label"],
|
|
951
|
+
"aria-labelledby": r["aria-labelledby"],
|
|
952
|
+
"aria-describedby": r["aria-describedby"]
|
|
933
953
|
}),
|
|
934
954
|
// Checkbox visual
|
|
935
955
|
a(
|
|
@@ -938,17 +958,16 @@ class ce {
|
|
|
938
958
|
style: {
|
|
939
959
|
width: i.thumbSize,
|
|
940
960
|
height: i.thumbSize,
|
|
941
|
-
border: `2px solid ${e ?
|
|
961
|
+
border: `2px solid ${e ? n : "#d1d5db"}`,
|
|
942
962
|
borderRadius: "4px",
|
|
943
|
-
backgroundColor: e ?
|
|
963
|
+
backgroundColor: e ? n : "#ffffff",
|
|
944
964
|
display: "flex",
|
|
945
965
|
alignItems: "center",
|
|
946
966
|
justifyContent: "center",
|
|
947
967
|
cursor: t ? "not-allowed" : "pointer",
|
|
948
968
|
opacity: t ? 0.5 : 1,
|
|
949
969
|
transition: "all 0.2s ease"
|
|
950
|
-
}
|
|
951
|
-
onClick: this.handleToggle
|
|
970
|
+
}
|
|
952
971
|
},
|
|
953
972
|
...e ? [
|
|
954
973
|
// Checkmark
|
|
@@ -972,22 +991,22 @@ class ce {
|
|
|
972
991
|
* Render button variant
|
|
973
992
|
*/
|
|
974
993
|
renderButton() {
|
|
975
|
-
const e = this.getIsOn(), t = this.isDisabled(), i = this.getSizeStyles(), { color:
|
|
994
|
+
const e = this.getIsOn(), t = this.isDisabled(), i = this.getSizeStyles(), { color: n = "#007AFF", offColor: r = "#f3f4f6" } = this.props;
|
|
976
995
|
return a(
|
|
977
996
|
"button",
|
|
978
997
|
{
|
|
979
|
-
ref: (
|
|
980
|
-
|
|
981
|
-
|
|
998
|
+
ref: (o) => {
|
|
999
|
+
o && !this.mounted && (o.addEventListener("click", this.handleToggle), this.cleanup.push(() => {
|
|
1000
|
+
o.removeEventListener("click", this.handleToggle);
|
|
982
1001
|
}));
|
|
983
1002
|
},
|
|
984
1003
|
type: "button",
|
|
985
1004
|
disabled: t,
|
|
986
1005
|
style: {
|
|
987
1006
|
padding: "8px 16px",
|
|
988
|
-
backgroundColor: e ?
|
|
1007
|
+
backgroundColor: e ? n : r,
|
|
989
1008
|
color: e ? "#ffffff" : "#374151",
|
|
990
|
-
border: `1px solid ${e ?
|
|
1009
|
+
border: `1px solid ${e ? n : "#d1d5db"}`,
|
|
991
1010
|
borderRadius: "6px",
|
|
992
1011
|
fontSize: i.fontSize,
|
|
993
1012
|
fontWeight: "500",
|
|
@@ -1019,42 +1038,61 @@ class ce {
|
|
|
1019
1038
|
/**
|
|
1020
1039
|
* Render label content
|
|
1021
1040
|
*/
|
|
1022
|
-
renderLabel() {
|
|
1023
|
-
const
|
|
1024
|
-
if (!
|
|
1025
|
-
const
|
|
1041
|
+
renderLabel(e = !1) {
|
|
1042
|
+
const t = this.resolveLabel();
|
|
1043
|
+
if (!t) return null;
|
|
1044
|
+
const i = this.getSizeStyles();
|
|
1026
1045
|
return a(
|
|
1027
1046
|
"span",
|
|
1028
1047
|
{
|
|
1048
|
+
id: this.getLabelId(),
|
|
1029
1049
|
style: {
|
|
1030
|
-
fontSize:
|
|
1050
|
+
fontSize: i.fontSize,
|
|
1031
1051
|
color: this.isDisabled() ? "#9ca3af" : "#374151",
|
|
1032
1052
|
cursor: this.isDisabled() ? "not-allowed" : "pointer"
|
|
1033
1053
|
},
|
|
1034
|
-
onClick: this.isDisabled() ? void 0
|
|
1054
|
+
onClick: e && !this.isDisabled() ? this.handleToggle : void 0
|
|
1035
1055
|
},
|
|
1036
|
-
...typeof
|
|
1056
|
+
...typeof t == "string" ? [d(t)] : this.renderComponentContent(t)
|
|
1037
1057
|
);
|
|
1038
1058
|
}
|
|
1039
1059
|
render() {
|
|
1040
1060
|
const {
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1061
|
+
variant: e = "switch",
|
|
1062
|
+
labelPosition: t = "trailing",
|
|
1063
|
+
spacing: i = 8,
|
|
1064
|
+
accessibilityHint: n
|
|
1065
|
+
} = this.props, r = this.renderLabel(e === "button"), o = this.renderToggleControl(), c = t === "leading" && r ? [r, o] : r ? [o, r] : [o], h = e === "button" ? a(
|
|
1046
1066
|
"div",
|
|
1047
1067
|
{
|
|
1048
1068
|
style: {
|
|
1049
1069
|
display: "flex",
|
|
1050
1070
|
alignItems: "center",
|
|
1051
|
-
gap: r ? `${
|
|
1071
|
+
gap: r ? `${i}px` : "0",
|
|
1052
1072
|
cursor: this.isDisabled() ? "not-allowed" : "pointer"
|
|
1053
|
-
}
|
|
1054
|
-
"aria-describedby": i ? `${this.id}-hint` : void 0
|
|
1073
|
+
}
|
|
1055
1074
|
},
|
|
1056
|
-
...
|
|
1057
|
-
|
|
1075
|
+
...c
|
|
1076
|
+
) : a(
|
|
1077
|
+
"label",
|
|
1078
|
+
{
|
|
1079
|
+
for: this.getInputId(),
|
|
1080
|
+
style: {
|
|
1081
|
+
display: "flex",
|
|
1082
|
+
alignItems: "center",
|
|
1083
|
+
gap: r ? `${i}px` : "0",
|
|
1084
|
+
cursor: this.isDisabled() ? "not-allowed" : "pointer"
|
|
1085
|
+
}
|
|
1086
|
+
},
|
|
1087
|
+
...c
|
|
1088
|
+
);
|
|
1089
|
+
return a(
|
|
1090
|
+
"div",
|
|
1091
|
+
{
|
|
1092
|
+
"aria-describedby": n ? `${this.id}-hint` : void 0
|
|
1093
|
+
},
|
|
1094
|
+
h,
|
|
1095
|
+
...n ? [
|
|
1058
1096
|
a(
|
|
1059
1097
|
"div",
|
|
1060
1098
|
{
|
|
@@ -1067,67 +1105,67 @@ class ce {
|
|
|
1067
1105
|
width: "100%"
|
|
1068
1106
|
}
|
|
1069
1107
|
},
|
|
1070
|
-
d(
|
|
1108
|
+
d(n)
|
|
1071
1109
|
)
|
|
1072
1110
|
] : []
|
|
1073
1111
|
);
|
|
1074
1112
|
}
|
|
1075
1113
|
}
|
|
1076
|
-
function
|
|
1114
|
+
function b(s, e = {}) {
|
|
1077
1115
|
const t = { ...e, isOn: s }, i = new ce(t);
|
|
1078
|
-
return
|
|
1116
|
+
return A(i);
|
|
1079
1117
|
}
|
|
1080
|
-
function
|
|
1081
|
-
return
|
|
1118
|
+
function j(s, e, t = {}) {
|
|
1119
|
+
return b(e, { ...t, label: s });
|
|
1082
1120
|
}
|
|
1083
1121
|
const ye = {
|
|
1084
1122
|
/**
|
|
1085
1123
|
* Switch toggle (default)
|
|
1086
1124
|
*/
|
|
1087
1125
|
Switch(s, e = {}) {
|
|
1088
|
-
return
|
|
1126
|
+
return b(s, { ...e, variant: "switch" });
|
|
1089
1127
|
},
|
|
1090
1128
|
/**
|
|
1091
1129
|
* Checkbox toggle
|
|
1092
1130
|
*/
|
|
1093
1131
|
Checkbox(s, e = {}) {
|
|
1094
|
-
return
|
|
1132
|
+
return b(s, { ...e, variant: "checkbox" });
|
|
1095
1133
|
},
|
|
1096
1134
|
/**
|
|
1097
1135
|
* Button toggle
|
|
1098
1136
|
*/
|
|
1099
1137
|
Button(s, e = {}) {
|
|
1100
|
-
return
|
|
1138
|
+
return b(s, { ...e, variant: "button" });
|
|
1101
1139
|
},
|
|
1102
1140
|
/**
|
|
1103
1141
|
* Small toggle
|
|
1104
1142
|
*/
|
|
1105
1143
|
Small(s, e = {}) {
|
|
1106
|
-
return
|
|
1144
|
+
return b(s, { ...e, size: "small" });
|
|
1107
1145
|
},
|
|
1108
1146
|
/**
|
|
1109
1147
|
* Large toggle
|
|
1110
1148
|
*/
|
|
1111
1149
|
Large(s, e = {}) {
|
|
1112
|
-
return
|
|
1150
|
+
return b(s, { ...e, size: "large" });
|
|
1113
1151
|
},
|
|
1114
1152
|
/**
|
|
1115
1153
|
* Custom color toggle
|
|
1116
1154
|
*/
|
|
1117
1155
|
CustomColor(s, e, t = {}) {
|
|
1118
|
-
return
|
|
1156
|
+
return b(s, { ...t, color: e });
|
|
1119
1157
|
},
|
|
1120
1158
|
/**
|
|
1121
1159
|
* Toggle with leading label
|
|
1122
1160
|
*/
|
|
1123
1161
|
WithLeadingLabel(s, e, t = {}) {
|
|
1124
|
-
return
|
|
1162
|
+
return b(e, { ...t, label: s, labelPosition: "leading" });
|
|
1125
1163
|
},
|
|
1126
1164
|
/**
|
|
1127
1165
|
* Toggle with trailing label (default)
|
|
1128
1166
|
*/
|
|
1129
1167
|
WithTrailingLabel(s, e, t = {}) {
|
|
1130
|
-
return
|
|
1168
|
+
return b(e, { ...t, label: s, labelPosition: "trailing" });
|
|
1131
1169
|
}
|
|
1132
1170
|
}, Se = {
|
|
1133
1171
|
/**
|
|
@@ -1135,7 +1173,7 @@ const ye = {
|
|
|
1135
1173
|
*/
|
|
1136
1174
|
createGroup(s, e = {}) {
|
|
1137
1175
|
return s.map(
|
|
1138
|
-
(t) =>
|
|
1176
|
+
(t) => j(t.label, t.isOn, {
|
|
1139
1177
|
...e,
|
|
1140
1178
|
onToggle: t.onToggle
|
|
1141
1179
|
})
|
|
@@ -1145,12 +1183,12 @@ const ye = {
|
|
|
1145
1183
|
* Create exclusive toggle group (radio-like behavior)
|
|
1146
1184
|
*/
|
|
1147
1185
|
createExclusiveGroup(s, e, t, i = {}) {
|
|
1148
|
-
const
|
|
1186
|
+
const n = () => l(e) ? e() : e;
|
|
1149
1187
|
return s.map(
|
|
1150
|
-
(
|
|
1188
|
+
(r) => j(r.label, n() === r.key, {
|
|
1151
1189
|
...i,
|
|
1152
|
-
onToggle: (
|
|
1153
|
-
|
|
1190
|
+
onToggle: (o) => {
|
|
1191
|
+
o && t && t(r.key);
|
|
1154
1192
|
}
|
|
1155
1193
|
})
|
|
1156
1194
|
);
|
|
@@ -1187,22 +1225,22 @@ const ye = {
|
|
|
1187
1225
|
}
|
|
1188
1226
|
}
|
|
1189
1227
|
};
|
|
1190
|
-
var de = Object.defineProperty, pe = (s, e, t) => e in s ? de(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t,
|
|
1228
|
+
var de = Object.defineProperty, pe = (s, e, t) => e in s ? de(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, f = (s, e, t) => pe(s, typeof e != "symbol" ? e + "" : e, t);
|
|
1191
1229
|
class he {
|
|
1192
1230
|
constructor(e) {
|
|
1193
|
-
this.props = e,
|
|
1194
|
-
this.props.onSelectionChange && this.props.onSelectionChange(
|
|
1195
|
-
}),
|
|
1231
|
+
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", (o) => {
|
|
1232
|
+
this.props.onSelectionChange && this.props.onSelectionChange(o), (this.props.variant === "dropdown" || this.props.variant === "menu") && this.setIsOpen(!1), this.setSearchTerm("");
|
|
1233
|
+
}), f(this, "toggleOpen", () => {
|
|
1196
1234
|
this.isDisabled() || this.setIsOpen(!this.isOpen());
|
|
1197
1235
|
}), this.id = `picker-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
1198
|
-
const [t, i] = R(!1), [
|
|
1199
|
-
if (this.isOpen = t, this.setIsOpen = i, this.searchTerm =
|
|
1200
|
-
const
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1236
|
+
const [t, i] = R(!1), [n, r] = R("");
|
|
1237
|
+
if (this.isOpen = t, this.setIsOpen = i, this.searchTerm = n, this.setSearchTerm = r, typeof window < "u") {
|
|
1238
|
+
const o = (c) => {
|
|
1239
|
+
const h = document.getElementById(this.id);
|
|
1240
|
+
h && !h.contains(c.target) && this.setIsOpen(!1);
|
|
1203
1241
|
};
|
|
1204
|
-
document.addEventListener("click",
|
|
1205
|
-
document.removeEventListener("click",
|
|
1242
|
+
document.addEventListener("click", o), this.cleanup.push(() => {
|
|
1243
|
+
document.removeEventListener("click", o);
|
|
1206
1244
|
});
|
|
1207
1245
|
}
|
|
1208
1246
|
}
|
|
@@ -1273,7 +1311,7 @@ class he {
|
|
|
1273
1311
|
* Render dropdown variant
|
|
1274
1312
|
*/
|
|
1275
1313
|
renderDropdown() {
|
|
1276
|
-
const e = this.getSelectedOption(), t = this.getFilteredOptions(), i = this.getSizeStyles(),
|
|
1314
|
+
const e = this.getSelectedOption(), t = this.getFilteredOptions(), i = this.getSizeStyles(), n = this.isOpen();
|
|
1277
1315
|
return a(
|
|
1278
1316
|
"div",
|
|
1279
1317
|
{
|
|
@@ -1302,7 +1340,7 @@ class he {
|
|
|
1302
1340
|
borderRadius: "6px",
|
|
1303
1341
|
cursor: this.isDisabled() ? "not-allowed" : "pointer",
|
|
1304
1342
|
opacity: this.isDisabled() ? 0.6 : 1,
|
|
1305
|
-
...
|
|
1343
|
+
...n && {
|
|
1306
1344
|
borderColor: this.props.tint || "#007AFF",
|
|
1307
1345
|
boxShadow: `0 0 0 1px ${this.props.tint || "#007AFF"}`
|
|
1308
1346
|
}
|
|
@@ -1325,14 +1363,14 @@ class he {
|
|
|
1325
1363
|
style: {
|
|
1326
1364
|
fontSize: "12px",
|
|
1327
1365
|
color: "#6b7280",
|
|
1328
|
-
transform:
|
|
1366
|
+
transform: n ? "rotate(180deg)" : "rotate(0deg)",
|
|
1329
1367
|
transition: "transform 0.2s"
|
|
1330
1368
|
}
|
|
1331
1369
|
},
|
|
1332
1370
|
d("▼")
|
|
1333
1371
|
)
|
|
1334
1372
|
),
|
|
1335
|
-
...
|
|
1373
|
+
...n ? [
|
|
1336
1374
|
a(
|
|
1337
1375
|
"div",
|
|
1338
1376
|
{
|
|
@@ -1364,9 +1402,9 @@ class he {
|
|
|
1364
1402
|
type: "text",
|
|
1365
1403
|
placeholder: "Search options...",
|
|
1366
1404
|
value: this.searchTerm(),
|
|
1367
|
-
onInput: (
|
|
1368
|
-
const
|
|
1369
|
-
this.setSearchTerm(
|
|
1405
|
+
onInput: (r) => {
|
|
1406
|
+
const o = r.target;
|
|
1407
|
+
this.setSearchTerm(o.value);
|
|
1370
1408
|
},
|
|
1371
1409
|
style: {
|
|
1372
1410
|
width: "100%",
|
|
@@ -1379,21 +1417,21 @@ class he {
|
|
|
1379
1417
|
)
|
|
1380
1418
|
] : [],
|
|
1381
1419
|
...t.map(
|
|
1382
|
-
(
|
|
1420
|
+
(r) => a(
|
|
1383
1421
|
"button",
|
|
1384
1422
|
{
|
|
1385
1423
|
type: "button",
|
|
1386
|
-
key: String(
|
|
1387
|
-
onClick: () => this.handleSelection(
|
|
1388
|
-
disabled:
|
|
1424
|
+
key: String(r.value),
|
|
1425
|
+
onClick: () => this.handleSelection(r.value),
|
|
1426
|
+
disabled: r.disabled,
|
|
1389
1427
|
style: {
|
|
1390
1428
|
width: "100%",
|
|
1391
1429
|
padding: "8px 12px",
|
|
1392
1430
|
textAlign: "left",
|
|
1393
|
-
backgroundColor:
|
|
1431
|
+
backgroundColor: r.value === this.getSelection() ? "#f3f4f6" : "transparent",
|
|
1394
1432
|
border: "none",
|
|
1395
|
-
cursor:
|
|
1396
|
-
opacity:
|
|
1433
|
+
cursor: r.disabled ? "not-allowed" : "pointer",
|
|
1434
|
+
opacity: r.disabled ? 0.5 : 1,
|
|
1397
1435
|
fontSize: "14px",
|
|
1398
1436
|
display: "flex",
|
|
1399
1437
|
alignItems: "center",
|
|
@@ -1403,18 +1441,18 @@ class he {
|
|
|
1403
1441
|
}
|
|
1404
1442
|
}
|
|
1405
1443
|
},
|
|
1406
|
-
...
|
|
1444
|
+
...r.icon ? [
|
|
1407
1445
|
a(
|
|
1408
1446
|
"span",
|
|
1409
1447
|
{ style: { fontSize: "16px" } },
|
|
1410
|
-
d(
|
|
1448
|
+
d(r.icon)
|
|
1411
1449
|
)
|
|
1412
1450
|
] : [],
|
|
1413
1451
|
a(
|
|
1414
1452
|
"div",
|
|
1415
1453
|
{},
|
|
1416
|
-
a("div", {}, d(
|
|
1417
|
-
...
|
|
1454
|
+
a("div", {}, d(r.label)),
|
|
1455
|
+
...r.description ? [
|
|
1418
1456
|
a(
|
|
1419
1457
|
"div",
|
|
1420
1458
|
{
|
|
@@ -1424,7 +1462,7 @@ class he {
|
|
|
1424
1462
|
marginTop: "2px"
|
|
1425
1463
|
}
|
|
1426
1464
|
},
|
|
1427
|
-
d(
|
|
1465
|
+
d(r.description)
|
|
1428
1466
|
)
|
|
1429
1467
|
] : []
|
|
1430
1468
|
)
|
|
@@ -1466,33 +1504,33 @@ class he {
|
|
|
1466
1504
|
"aria-label": this.props.accessibilityLabel
|
|
1467
1505
|
},
|
|
1468
1506
|
...e.map(
|
|
1469
|
-
(
|
|
1507
|
+
(n, r) => a(
|
|
1470
1508
|
"button",
|
|
1471
1509
|
{
|
|
1472
1510
|
type: "button",
|
|
1473
|
-
key: String(
|
|
1474
|
-
onClick: () => this.handleSelection(
|
|
1475
|
-
disabled:
|
|
1511
|
+
key: String(n.value),
|
|
1512
|
+
onClick: () => this.handleSelection(n.value),
|
|
1513
|
+
disabled: n.disabled || this.isDisabled(),
|
|
1476
1514
|
role: "radio",
|
|
1477
|
-
"aria-checked":
|
|
1515
|
+
"aria-checked": n.value === t,
|
|
1478
1516
|
style: {
|
|
1479
1517
|
...i,
|
|
1480
1518
|
flex: 1,
|
|
1481
1519
|
border: "none",
|
|
1482
1520
|
borderRadius: "6px",
|
|
1483
|
-
backgroundColor:
|
|
1484
|
-
color:
|
|
1485
|
-
fontWeight:
|
|
1486
|
-
cursor:
|
|
1487
|
-
opacity:
|
|
1488
|
-
boxShadow:
|
|
1521
|
+
backgroundColor: n.value === t ? "#ffffff" : "transparent",
|
|
1522
|
+
color: n.value === t ? "#1a1a1a" : "#6b7280",
|
|
1523
|
+
fontWeight: n.value === t ? "600" : "400",
|
|
1524
|
+
cursor: n.disabled || this.isDisabled() ? "not-allowed" : "pointer",
|
|
1525
|
+
opacity: n.disabled || this.isDisabled() ? 0.5 : 1,
|
|
1526
|
+
boxShadow: n.value === t ? "0 1px 2px rgba(0, 0, 0, 0.1)" : "none",
|
|
1489
1527
|
transition: "all 0.2s",
|
|
1490
1528
|
margin: "0",
|
|
1491
|
-
...
|
|
1492
|
-
...
|
|
1529
|
+
...r === 0 && { marginRight: "1px" },
|
|
1530
|
+
...r === e.length - 1 && { marginLeft: "1px" }
|
|
1493
1531
|
}
|
|
1494
1532
|
},
|
|
1495
|
-
...
|
|
1533
|
+
...n.icon ? [
|
|
1496
1534
|
a(
|
|
1497
1535
|
"span",
|
|
1498
1536
|
{
|
|
@@ -1501,10 +1539,10 @@ class he {
|
|
|
1501
1539
|
fontSize: "14px"
|
|
1502
1540
|
}
|
|
1503
1541
|
},
|
|
1504
|
-
d(
|
|
1542
|
+
d(n.icon)
|
|
1505
1543
|
)
|
|
1506
1544
|
] : [],
|
|
1507
|
-
d(
|
|
1545
|
+
d(n.label)
|
|
1508
1546
|
)
|
|
1509
1547
|
)
|
|
1510
1548
|
);
|
|
@@ -1519,10 +1557,10 @@ class he {
|
|
|
1519
1557
|
{
|
|
1520
1558
|
value: String(t),
|
|
1521
1559
|
onChange: (i) => {
|
|
1522
|
-
const
|
|
1523
|
-
(
|
|
1560
|
+
const n = i.target, r = e.find(
|
|
1561
|
+
(o) => String(o.value) === n.value
|
|
1524
1562
|
);
|
|
1525
|
-
|
|
1563
|
+
r && this.handleSelection(r.value);
|
|
1526
1564
|
},
|
|
1527
1565
|
disabled: this.isDisabled(),
|
|
1528
1566
|
style: {
|
|
@@ -1553,26 +1591,26 @@ class he {
|
|
|
1553
1591
|
variant: e = "dropdown",
|
|
1554
1592
|
accessibilityLabel: t,
|
|
1555
1593
|
accessibilityHint: i
|
|
1556
|
-
} = this.props,
|
|
1594
|
+
} = this.props, n = {
|
|
1557
1595
|
"aria-label": t,
|
|
1558
1596
|
"aria-describedby": i ? `${this.id}-hint` : void 0
|
|
1559
1597
|
};
|
|
1560
|
-
let
|
|
1598
|
+
let r;
|
|
1561
1599
|
switch (e) {
|
|
1562
1600
|
case "segmented":
|
|
1563
|
-
|
|
1601
|
+
r = this.renderSegmented();
|
|
1564
1602
|
break;
|
|
1565
1603
|
case "wheel":
|
|
1566
|
-
|
|
1604
|
+
r = this.renderWheel();
|
|
1567
1605
|
break;
|
|
1568
1606
|
default:
|
|
1569
|
-
|
|
1607
|
+
r = this.renderDropdown();
|
|
1570
1608
|
break;
|
|
1571
1609
|
}
|
|
1572
1610
|
return a(
|
|
1573
1611
|
"div",
|
|
1612
|
+
n,
|
|
1574
1613
|
r,
|
|
1575
|
-
o,
|
|
1576
1614
|
...i ? [
|
|
1577
1615
|
a(
|
|
1578
1616
|
"div",
|
|
@@ -1590,9 +1628,9 @@ class he {
|
|
|
1590
1628
|
);
|
|
1591
1629
|
}
|
|
1592
1630
|
}
|
|
1593
|
-
function
|
|
1594
|
-
const i = { ...t, selection: s, options: e },
|
|
1595
|
-
return
|
|
1631
|
+
function $(s, e, t = {}) {
|
|
1632
|
+
const i = { ...t, selection: s, options: e }, n = new he(i);
|
|
1633
|
+
return A(n);
|
|
1596
1634
|
}
|
|
1597
1635
|
const xe = {
|
|
1598
1636
|
/**
|
|
@@ -1600,28 +1638,28 @@ const xe = {
|
|
|
1600
1638
|
*/
|
|
1601
1639
|
// biome-ignore lint/suspicious/noExplicitAny: Generic dropdown picker requires flexible type
|
|
1602
1640
|
Dropdown(s, e, t = {}) {
|
|
1603
|
-
return
|
|
1641
|
+
return $(s, e, { ...t, variant: "dropdown" });
|
|
1604
1642
|
},
|
|
1605
1643
|
/**
|
|
1606
1644
|
* Segmented picker
|
|
1607
1645
|
*/
|
|
1608
1646
|
// biome-ignore lint/suspicious/noExplicitAny: Generic segmented picker requires flexible type
|
|
1609
1647
|
Segmented(s, e, t = {}) {
|
|
1610
|
-
return
|
|
1648
|
+
return $(s, e, { ...t, variant: "segmented" });
|
|
1611
1649
|
},
|
|
1612
1650
|
/**
|
|
1613
1651
|
* Wheel picker (native select)
|
|
1614
1652
|
*/
|
|
1615
1653
|
// biome-ignore lint/suspicious/noExplicitAny: Generic wheel picker requires flexible type
|
|
1616
1654
|
Wheel(s, e, t = {}) {
|
|
1617
|
-
return
|
|
1655
|
+
return $(s, e, { ...t, variant: "wheel" });
|
|
1618
1656
|
},
|
|
1619
1657
|
/**
|
|
1620
1658
|
* Menu picker
|
|
1621
1659
|
*/
|
|
1622
1660
|
// biome-ignore lint/suspicious/noExplicitAny: Generic menu picker requires flexible type
|
|
1623
1661
|
Menu(s, e, t = {}) {
|
|
1624
|
-
return
|
|
1662
|
+
return $(s, e, { ...t, variant: "menu" });
|
|
1625
1663
|
}
|
|
1626
1664
|
}, ve = {
|
|
1627
1665
|
/**
|
|
@@ -1656,18 +1694,18 @@ const xe = {
|
|
|
1656
1694
|
}
|
|
1657
1695
|
};
|
|
1658
1696
|
export {
|
|
1659
|
-
|
|
1697
|
+
L as B,
|
|
1660
1698
|
z as E,
|
|
1661
1699
|
me as L,
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1700
|
+
$ as P,
|
|
1701
|
+
b as T,
|
|
1702
|
+
ge as a,
|
|
1665
1703
|
S as b,
|
|
1666
1704
|
ce as c,
|
|
1667
1705
|
se as d,
|
|
1668
1706
|
ye as e,
|
|
1669
1707
|
Se as f,
|
|
1670
|
-
|
|
1708
|
+
j as g,
|
|
1671
1709
|
he as h,
|
|
1672
1710
|
xe as i,
|
|
1673
1711
|
ve as j
|