@simplexable/ui 0.1.0 → 0.2.1
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/index.js +247 -124
- package/package.json +8 -2
package/dist/index.js
CHANGED
|
@@ -10205,9 +10205,23 @@ function h_(e, t, n) {
|
|
|
10205
10205
|
function g_(e, t) {
|
|
10206
10206
|
return `${e}-option-${encodeURIComponent(String(t))}`;
|
|
10207
10207
|
}
|
|
10208
|
+
function __(e) {
|
|
10209
|
+
return String(e ?? "").trim().toLowerCase();
|
|
10210
|
+
}
|
|
10211
|
+
function v_(e, t) {
|
|
10212
|
+
let n = __(t);
|
|
10213
|
+
return n ? e.findIndex((e) => !e.disabled && __(e.label).startsWith(n)) : -1;
|
|
10214
|
+
}
|
|
10215
|
+
function y_(e, t, n) {
|
|
10216
|
+
let r = __(n);
|
|
10217
|
+
if (!r || !e.length) return -1;
|
|
10218
|
+
for (let n = t + 1; n < e.length; n += 1) if (!e[n].disabled && __(e[n].label).startsWith(r)) return n;
|
|
10219
|
+
for (let n = 0; n <= t; n += 1) if (!e[n].disabled && __(e[n].label).startsWith(r)) return n;
|
|
10220
|
+
return -1;
|
|
10221
|
+
}
|
|
10208
10222
|
//#endregion
|
|
10209
10223
|
//#region src/components/Select/SelectOptionList.jsx
|
|
10210
|
-
function
|
|
10224
|
+
function b_({ activeIndex: e = -1, id: r, options: i, selectedValue: a, showSecondary: o = !1, onOptionClick: s }) {
|
|
10211
10225
|
return i.map((i, c) => {
|
|
10212
10226
|
let l = i.value === String(a ?? ""), u = c === e, d = i.secondary ? `${i.label}, ${i.secondary}` : i.label, f = g_(r, i.value);
|
|
10213
10227
|
return /* @__PURE__ */ n("li", {
|
|
@@ -10247,10 +10261,10 @@ function __({ activeIndex: e = -1, id: r, options: i, selectedValue: a, showSeco
|
|
|
10247
10261
|
}
|
|
10248
10262
|
//#endregion
|
|
10249
10263
|
//#region src/components/Select/SelectTriggerRow.jsx
|
|
10250
|
-
function
|
|
10264
|
+
function x_(...e) {
|
|
10251
10265
|
return e.filter(Boolean).join(" ");
|
|
10252
10266
|
}
|
|
10253
|
-
function
|
|
10267
|
+
function S_({ activeDescendant: e, ariaProps: r, clearSelection: i, disabled: a = !1, displayValue: o, handleTriggerKeyDown: s, id: c, isInteractive: l, isOpen: u, label: d, listboxId: f, placeholder: p, showClear: m, toggleMenu: h, triggerRef: g }) {
|
|
10254
10268
|
return l ? /* @__PURE__ */ n("div", {
|
|
10255
10269
|
className: "sx-select__control-row",
|
|
10256
10270
|
children: [
|
|
@@ -10260,7 +10274,7 @@ function y_({ activeDescendant: e, ariaProps: r, clearSelection: i, disabled: a
|
|
|
10260
10274
|
"aria-controls": u ? f : void 0,
|
|
10261
10275
|
"aria-expanded": u,
|
|
10262
10276
|
"aria-haspopup": "listbox",
|
|
10263
|
-
className:
|
|
10277
|
+
className: x_("sx-field__control", "sx-select__trigger", !o && "sx-select__trigger--placeholder"),
|
|
10264
10278
|
id: c,
|
|
10265
10279
|
ref: g,
|
|
10266
10280
|
role: "combobox",
|
|
@@ -10286,7 +10300,7 @@ function y_({ activeDescendant: e, ariaProps: r, clearSelection: i, disabled: a
|
|
|
10286
10300
|
}),
|
|
10287
10301
|
/* @__PURE__ */ t("button", {
|
|
10288
10302
|
"aria-label": u ? `close ${d} options` : `open ${d} options`,
|
|
10289
|
-
className:
|
|
10303
|
+
className: x_("sx-select__disclosure-button", u && "sx-select__disclosure-button--open"),
|
|
10290
10304
|
disabled: a,
|
|
10291
10305
|
tabIndex: -1,
|
|
10292
10306
|
type: "button",
|
|
@@ -10302,7 +10316,7 @@ function y_({ activeDescendant: e, ariaProps: r, clearSelection: i, disabled: a
|
|
|
10302
10316
|
className: "sx-select__static-row",
|
|
10303
10317
|
children: [/* @__PURE__ */ t("div", {
|
|
10304
10318
|
...r,
|
|
10305
|
-
className:
|
|
10319
|
+
className: x_("sx-field__control", "sx-select__display", !o && "sx-select__display--placeholder"),
|
|
10306
10320
|
id: c,
|
|
10307
10321
|
children: o || p
|
|
10308
10322
|
}), a && /* @__PURE__ */ t("span", {
|
|
@@ -10317,8 +10331,8 @@ function y_({ activeDescendant: e, ariaProps: r, clearSelection: i, disabled: a
|
|
|
10317
10331
|
}
|
|
10318
10332
|
//#endregion
|
|
10319
10333
|
//#region src/components/Select/useSearchableSingleSelect.js
|
|
10320
|
-
var
|
|
10321
|
-
function
|
|
10334
|
+
var C_ = 300;
|
|
10335
|
+
function w_({ debounceMs: e = C_, disabled: t = !1, initialResultsPolicy: n = "all", loadOptions: r, minQueryLength: i = 0, onBlur: a, onChange: o, onSearchQueryChange: s, readOnly: c = !1, resolved: l = !1, searchQuery: u, value: m = "", values: v }) {
|
|
10322
10336
|
let y = h(() => u_(v), [v]), b = f_(y, m) || (m ? {
|
|
10323
10337
|
label: String(m),
|
|
10324
10338
|
value: String(m)
|
|
@@ -10475,8 +10489,8 @@ function x_({ debounceMs: e = b_, disabled: t = !1, initialResultsPolicy: n = "a
|
|
|
10475
10489
|
}
|
|
10476
10490
|
//#endregion
|
|
10477
10491
|
//#region src/components/Select/useSelectListboxLayout.js
|
|
10478
|
-
var
|
|
10479
|
-
function
|
|
10492
|
+
var T_ = 12, E_ = 4;
|
|
10493
|
+
function D_({ isOpen: e, listboxRef: t, triggerRef: n }) {
|
|
10480
10494
|
let [r, i] = _(null);
|
|
10481
10495
|
return m(() => {
|
|
10482
10496
|
if (!e) {
|
|
@@ -10486,13 +10500,13 @@ function w_({ isOpen: e, listboxRef: t, triggerRef: n }) {
|
|
|
10486
10500
|
let r = n.current?.closest(".sx-field__frame"), a = t.current;
|
|
10487
10501
|
if (!r || !a || typeof window > "u") return;
|
|
10488
10502
|
let o = r.getBoundingClientRect(), s = Math.max(o.width, window.innerWidth - 24);
|
|
10489
|
-
a.style.visibility = "hidden", a.style.left = "0", a.style.right = "auto", a.style.top = "100%", a.style.bottom = "auto", a.style.marginTop = `${
|
|
10490
|
-
let c = a.getBoundingClientRect(), l = o.left + c.width > window.innerWidth -
|
|
10503
|
+
a.style.visibility = "hidden", a.style.left = "0", a.style.right = "auto", a.style.top = "100%", a.style.bottom = "auto", a.style.marginTop = `${E_}px`, a.style.marginBottom = "0", a.style.minWidth = `${o.width}px`, a.style.width = "max-content", a.style.maxWidth = `${s}px`;
|
|
10504
|
+
let c = a.getBoundingClientRect(), l = o.left + c.width > window.innerWidth - T_, u = window.innerHeight - T_ - o.bottom - E_, d = o.top - T_ - E_, f = c.height > u && d > u, p = Math.max(f ? d : u, 0);
|
|
10491
10505
|
a.style.visibility = "", i({
|
|
10492
10506
|
bottom: f ? "100%" : "auto",
|
|
10493
10507
|
left: l ? "auto" : "0",
|
|
10494
|
-
marginBottom: f ? `${
|
|
10495
|
-
marginTop: f ? "0" : `${
|
|
10508
|
+
marginBottom: f ? `${E_}px` : "0",
|
|
10509
|
+
marginTop: f ? "0" : `${E_}px`,
|
|
10496
10510
|
maxHeight: `${p}px`,
|
|
10497
10511
|
maxWidth: `${s}px`,
|
|
10498
10512
|
minWidth: `${o.width}px`,
|
|
@@ -10508,8 +10522,8 @@ function w_({ isOpen: e, listboxRef: t, triggerRef: n }) {
|
|
|
10508
10522
|
}
|
|
10509
10523
|
//#endregion
|
|
10510
10524
|
//#region src/components/Select/SearchableSingleSelect.jsx
|
|
10511
|
-
function
|
|
10512
|
-
let E = p(), D = l || `sx-searchable-select-${E}`, O =
|
|
10525
|
+
function O_({ className: e = "", clearable: r = !1, debounceMs: i, disabled: a = !1, errorMessage: o, fieldState: s = "neutral", helperText: c, id: l, initialResultsPolicy: u = "all", label: d, loadOptions: f, minQueryLength: m = 0, onBlur: h, onChange: g, onSearchQueryChange: _, placeholder: v = "select…", readOnly: y = !1, required: b = !1, resolved: x = !1, searchPlaceholder: S = "search…", searchQuery: C, value: w = "", values: T }) {
|
|
10526
|
+
let E = p(), D = l || `sx-searchable-select-${E}`, O = w_({
|
|
10513
10527
|
debounceMs: i,
|
|
10514
10528
|
disabled: a,
|
|
10515
10529
|
initialResultsPolicy: u,
|
|
@@ -10523,7 +10537,7 @@ function T_({ className: e = "", clearable: r = !1, debounceMs: i, disabled: a =
|
|
|
10523
10537
|
searchQuery: C,
|
|
10524
10538
|
value: w,
|
|
10525
10539
|
values: T
|
|
10526
|
-
}), k =
|
|
10540
|
+
}), k = D_({
|
|
10527
10541
|
isOpen: O.isOpen,
|
|
10528
10542
|
listboxRef: O.panelRef,
|
|
10529
10543
|
triggerRef: O.triggerRef
|
|
@@ -10576,7 +10590,7 @@ function T_({ className: e = "", clearable: r = !1, debounceMs: i, disabled: a =
|
|
|
10576
10590
|
tabIndex: O.focusRegion === "list" ? 0 : -1,
|
|
10577
10591
|
onKeyDown: O.handleListboxKeyDown,
|
|
10578
10592
|
onMouseDown: (e) => e.stopPropagation(),
|
|
10579
|
-
children: /* @__PURE__ */ t(
|
|
10593
|
+
children: /* @__PURE__ */ t(b_, {
|
|
10580
10594
|
activeIndex: O.activeIndex,
|
|
10581
10595
|
id: O.listboxId,
|
|
10582
10596
|
options: O.resultOptions,
|
|
@@ -10604,7 +10618,7 @@ function T_({ className: e = "", clearable: r = !1, debounceMs: i, disabled: a =
|
|
|
10604
10618
|
readOnly: y,
|
|
10605
10619
|
required: b,
|
|
10606
10620
|
resolved: x,
|
|
10607
|
-
children: (e) => /* @__PURE__ */ t(
|
|
10621
|
+
children: (e) => /* @__PURE__ */ t(S_, {
|
|
10608
10622
|
activeDescendant: void 0,
|
|
10609
10623
|
ariaProps: e,
|
|
10610
10624
|
clearSelection: O.clearSelection,
|
|
@@ -10625,13 +10639,20 @@ function T_({ className: e = "", clearable: r = !1, debounceMs: i, disabled: a =
|
|
|
10625
10639
|
}
|
|
10626
10640
|
//#endregion
|
|
10627
10641
|
//#region src/components/Select/useSingleSelect.js
|
|
10628
|
-
function
|
|
10642
|
+
function k_(e) {
|
|
10643
|
+
return e.ctrlKey || e.metaKey || e.altKey ? !1 : e.key.length === 1;
|
|
10644
|
+
}
|
|
10645
|
+
function A_({ disabled: e = !1, onBlur: t, onChange: n, readOnly: r = !1, resolved: i = !1, value: a = "", values: o }) {
|
|
10629
10646
|
let s = h(() => u_(o), [o]), c = f_(s, a) || (a ? {
|
|
10630
10647
|
label: String(a),
|
|
10631
10648
|
value: String(a)
|
|
10632
|
-
} : null), l = !e && !r && !i, [u, m] = _(!1), [v, y] = _(-1), b = g(null), x = g(null), S =
|
|
10633
|
-
|
|
10634
|
-
}, [
|
|
10649
|
+
} : null), l = !e && !r && !i, [u, m] = _(!1), [v, y] = _(-1), b = g(null), x = g(null), S = g(""), C = g(null), w = p(), T = d(() => {
|
|
10650
|
+
S.current = "", C.current != null && (window.clearTimeout(C.current), C.current = null);
|
|
10651
|
+
}, []), E = d(() => {
|
|
10652
|
+
C.current != null && window.clearTimeout(C.current), C.current = window.setTimeout(T, 700);
|
|
10653
|
+
}, [T]), D = d(({ focusTrigger: e = !0, invokeBlur: n = !1 } = {}) => {
|
|
10654
|
+
T(), m(!1), y(-1), e && b.current?.focus(), n && t?.();
|
|
10655
|
+
}, [t, T]), O = d((e = -1) => {
|
|
10635
10656
|
if (!l) return;
|
|
10636
10657
|
let t = s.findIndex((e) => e.value === String(a)), n = e >= 0 ? e : t >= 0 && !s[t].disabled ? t : p_(s);
|
|
10637
10658
|
y(n), m(!0);
|
|
@@ -10639,77 +10660,100 @@ function E_({ disabled: e = !1, onBlur: t, onChange: n, readOnly: r = !1, resolv
|
|
|
10639
10660
|
l,
|
|
10640
10661
|
s,
|
|
10641
10662
|
a
|
|
10642
|
-
]),
|
|
10643
|
-
!e || e.disabled || (n?.(e.value),
|
|
10644
|
-
}, [
|
|
10645
|
-
l && (u ?
|
|
10663
|
+
]), k = d((e) => {
|
|
10664
|
+
!e || e.disabled || (n?.(e.value), D({ invokeBlur: !0 }));
|
|
10665
|
+
}, [D, n]), A = d(() => {
|
|
10666
|
+
l && (u ? D() : O());
|
|
10646
10667
|
}, [
|
|
10647
|
-
|
|
10668
|
+
D,
|
|
10648
10669
|
l,
|
|
10649
10670
|
u,
|
|
10650
|
-
|
|
10651
|
-
]),
|
|
10652
|
-
e.preventDefault(), e.stopPropagation(), l && (n?.(""),
|
|
10671
|
+
O
|
|
10672
|
+
]), j = d((e) => {
|
|
10673
|
+
e.preventDefault(), e.stopPropagation(), l && (n?.(""), D({ invokeBlur: !0 }));
|
|
10653
10674
|
}, [
|
|
10654
|
-
|
|
10675
|
+
D,
|
|
10655
10676
|
l,
|
|
10656
10677
|
n
|
|
10657
|
-
]),
|
|
10658
|
-
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10678
|
+
]), ee = d((e, t, n) => {
|
|
10679
|
+
let r = e.toLowerCase(), i = S.current, a = i.length === 1 && i === r, o = -1;
|
|
10680
|
+
if (a) {
|
|
10681
|
+
let e = v_(s, r), i = e - 1;
|
|
10682
|
+
n && t >= 0 && (i = __(s[t]?.label).startsWith(r) ? t : e - 1), o = y_(s, i, r);
|
|
10683
|
+
} else {
|
|
10684
|
+
let e = i + r;
|
|
10685
|
+
S.current = e, o = v_(s, e);
|
|
10686
|
+
}
|
|
10687
|
+
return E(), o;
|
|
10688
|
+
}, [s, E]), te = d((e) => {
|
|
10689
|
+
if (l) {
|
|
10690
|
+
if (k_(e)) {
|
|
10691
|
+
e.preventDefault(), e.stopPropagation();
|
|
10692
|
+
let t = ee(e.key, v, u);
|
|
10693
|
+
if (t < 0) return;
|
|
10694
|
+
u ? y(t) : O(t);
|
|
10669
10695
|
return;
|
|
10670
10696
|
}
|
|
10671
|
-
|
|
10697
|
+
if ([
|
|
10698
|
+
"ArrowDown",
|
|
10699
|
+
"ArrowUp",
|
|
10700
|
+
"End",
|
|
10701
|
+
"Enter",
|
|
10702
|
+
"Escape",
|
|
10703
|
+
"Home",
|
|
10704
|
+
" "
|
|
10705
|
+
].includes(e.key) && !(e.key === "Escape" && !u)) {
|
|
10706
|
+
if (e.preventDefault(), e.stopPropagation(), T(), !u) {
|
|
10707
|
+
e.key === "ArrowUp" ? O(m_(s)) : e.key !== "Escape" && e.key !== "Home" && e.key !== "End" && O();
|
|
10708
|
+
return;
|
|
10709
|
+
}
|
|
10710
|
+
e.key === "ArrowDown" && y((e) => h_(s, e, 1)), e.key === "ArrowUp" && y((e) => h_(s, e, -1)), e.key === "Home" && y(p_(s)), e.key === "End" && y(m_(s)), (e.key === "Enter" || e.key === " ") && v >= 0 && k(s[v]), e.key === "Escape" && D({ invokeBlur: !0 });
|
|
10711
|
+
}
|
|
10672
10712
|
}
|
|
10673
10713
|
}, [
|
|
10674
10714
|
v,
|
|
10675
|
-
|
|
10715
|
+
ee,
|
|
10716
|
+
D,
|
|
10676
10717
|
l,
|
|
10677
10718
|
u,
|
|
10678
|
-
|
|
10719
|
+
O,
|
|
10679
10720
|
s,
|
|
10680
|
-
T
|
|
10721
|
+
T,
|
|
10722
|
+
k
|
|
10681
10723
|
]);
|
|
10682
10724
|
return f(() => {
|
|
10683
10725
|
if (!u) return;
|
|
10684
10726
|
let e = (e) => {
|
|
10685
|
-
(b.current?.closest(".sx-field"))?.contains(e.target) ||
|
|
10727
|
+
(b.current?.closest(".sx-field"))?.contains(e.target) || D({
|
|
10686
10728
|
focusTrigger: !1,
|
|
10687
10729
|
invokeBlur: !0
|
|
10688
10730
|
});
|
|
10689
10731
|
};
|
|
10690
10732
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
10691
|
-
}, [
|
|
10733
|
+
}, [D, u]), f(() => {
|
|
10692
10734
|
!u || v < 0 || x.current?.querySelector(`[data-sx-select-option-index="${v}"]`)?.scrollIntoView?.({ block: "nearest" });
|
|
10693
|
-
}, [v, u]), {
|
|
10694
|
-
|
|
10735
|
+
}, [v, u]), f(() => () => {
|
|
10736
|
+
C.current != null && window.clearTimeout(C.current);
|
|
10737
|
+
}, []), {
|
|
10738
|
+
activeDescendant: u && v >= 0 ? g_(w, s[v]?.value) : void 0,
|
|
10695
10739
|
activeIndex: v,
|
|
10696
|
-
clearSelection:
|
|
10697
|
-
handleOptionClick:
|
|
10698
|
-
handleTriggerKeyDown:
|
|
10740
|
+
clearSelection: j,
|
|
10741
|
+
handleOptionClick: k,
|
|
10742
|
+
handleTriggerKeyDown: te,
|
|
10699
10743
|
isInteractive: l,
|
|
10700
10744
|
isOpen: u,
|
|
10701
|
-
listboxId:
|
|
10745
|
+
listboxId: w,
|
|
10702
10746
|
listboxRef: x,
|
|
10703
10747
|
options: s,
|
|
10704
10748
|
selectedOption: c,
|
|
10705
|
-
toggleMenu:
|
|
10749
|
+
toggleMenu: A,
|
|
10706
10750
|
triggerRef: b
|
|
10707
10751
|
};
|
|
10708
10752
|
}
|
|
10709
10753
|
//#endregion
|
|
10710
10754
|
//#region src/components/Select/SingleSelect.jsx
|
|
10711
|
-
function
|
|
10712
|
-
let v = p(), y = s || `sx-select-${v}`, b =
|
|
10755
|
+
function j_({ className: e = "", clearable: n = !1, disabled: r = !1, errorMessage: i, fieldState: a = "neutral", helperText: o, id: s, label: c, onBlur: l, onChange: u, placeholder: d = "select…", readOnly: f = !1, required: m = !1, resolved: h = !1, value: g = "", values: _ }) {
|
|
10756
|
+
let v = p(), y = s || `sx-select-${v}`, b = A_({
|
|
10713
10757
|
disabled: r,
|
|
10714
10758
|
onBlur: l,
|
|
10715
10759
|
onChange: u,
|
|
@@ -10717,7 +10761,7 @@ function D_({ className: e = "", clearable: n = !1, disabled: r = !1, errorMessa
|
|
|
10717
10761
|
resolved: h,
|
|
10718
10762
|
value: g,
|
|
10719
10763
|
values: _
|
|
10720
|
-
}), x =
|
|
10764
|
+
}), x = D_({
|
|
10721
10765
|
isOpen: b.isOpen,
|
|
10722
10766
|
listboxRef: b.listboxRef,
|
|
10723
10767
|
triggerRef: b.triggerRef
|
|
@@ -10730,7 +10774,7 @@ function D_({ className: e = "", clearable: n = !1, disabled: r = !1, errorMessa
|
|
|
10730
10774
|
style: x || void 0,
|
|
10731
10775
|
tabIndex: -1,
|
|
10732
10776
|
onKeyDown: b.handleTriggerKeyDown,
|
|
10733
|
-
children: /* @__PURE__ */ t(
|
|
10777
|
+
children: /* @__PURE__ */ t(b_, {
|
|
10734
10778
|
activeIndex: b.activeIndex,
|
|
10735
10779
|
id: b.listboxId,
|
|
10736
10780
|
options: b.options,
|
|
@@ -10751,7 +10795,7 @@ function D_({ className: e = "", clearable: n = !1, disabled: r = !1, errorMessa
|
|
|
10751
10795
|
readOnly: f,
|
|
10752
10796
|
required: m,
|
|
10753
10797
|
resolved: h,
|
|
10754
|
-
children: (e) => /* @__PURE__ */ t(
|
|
10798
|
+
children: (e) => /* @__PURE__ */ t(S_, {
|
|
10755
10799
|
activeDescendant: b.isOpen && b.activeIndex >= 0 ? `${b.listboxId}-option-${encodeURIComponent(b.options[b.activeIndex]?.value)}` : void 0,
|
|
10756
10800
|
ariaProps: e,
|
|
10757
10801
|
clearSelection: b.clearSelection,
|
|
@@ -10772,7 +10816,7 @@ function D_({ className: e = "", clearable: n = !1, disabled: r = !1, errorMessa
|
|
|
10772
10816
|
}
|
|
10773
10817
|
//#endregion
|
|
10774
10818
|
//#region src/components/Dialog/SuccessDialog.jsx
|
|
10775
|
-
var
|
|
10819
|
+
var M_ = [
|
|
10776
10820
|
"a[href]",
|
|
10777
10821
|
"area[href]",
|
|
10778
10822
|
"button:not([disabled])",
|
|
@@ -10782,7 +10826,7 @@ var O_ = [
|
|
|
10782
10826
|
"[contenteditable=\"true\"]",
|
|
10783
10827
|
"[tabindex]:not([tabindex=\"-1\"])"
|
|
10784
10828
|
].join(",");
|
|
10785
|
-
function
|
|
10829
|
+
function N_({ children: e, autoClose: r = !1, className: i = "", closeLabel: a = "close", delay: o = 5, onClose: s, open: c = !1, preview: l = !1, title: u }) {
|
|
10786
10830
|
let d = p(), m = g(null), h = g(null), _ = g(s);
|
|
10787
10831
|
if (_.current = s, f(() => {
|
|
10788
10832
|
if (!c || l) return;
|
|
@@ -10796,7 +10840,7 @@ function k_({ children: e, autoClose: r = !1, className: i = "", closeLabel: a =
|
|
|
10796
10840
|
return;
|
|
10797
10841
|
}
|
|
10798
10842
|
if (t.key !== "Tab" || !e) return;
|
|
10799
|
-
let n = [...e.querySelectorAll(
|
|
10843
|
+
let n = [...e.querySelectorAll(M_)];
|
|
10800
10844
|
if (n.length === 0) {
|
|
10801
10845
|
t.preventDefault(), e.focus();
|
|
10802
10846
|
return;
|
|
@@ -10874,7 +10918,7 @@ function k_({ children: e, autoClose: r = !1, className: i = "", closeLabel: a =
|
|
|
10874
10918
|
}
|
|
10875
10919
|
//#endregion
|
|
10876
10920
|
//#region src/components/TextInput/TextInput.jsx
|
|
10877
|
-
var
|
|
10921
|
+
var P_ = u(function({ label: e, value: n, onChange: r, onBlur: i, placeholder: a, required: o = !1, disabled: s = !1, readOnly: c = !1, error: l = !1, errorMessage: u, helperText: d, resolved: f = !1, fieldState: m = "neutral", status: h, isOpen: g = !1, type: _ = "text", className: v = "", id: y, ...b }, x) {
|
|
10878
10922
|
let S = p(), C = y || `sx-text-input-${S}`, w = typeof l == "string" ? l : u, T = !!l || !!w, E = m === "neutral" ? h : m;
|
|
10879
10923
|
return /* @__PURE__ */ t(ge, {
|
|
10880
10924
|
className: v,
|
|
@@ -10906,110 +10950,189 @@ var A_ = u(function({ label: e, value: n, onChange: r, onBlur: i, placeholder: a
|
|
|
10906
10950
|
value: n
|
|
10907
10951
|
})
|
|
10908
10952
|
});
|
|
10909
|
-
});
|
|
10953
|
+
}), F_ = 1.2, I_ = 16, L_ = "data-sx-textarea-measure", R_ = /* @__PURE__ */ "borderBottomStyle.borderBottomWidth.borderLeftStyle.borderLeftWidth.borderRightStyle.borderRightWidth.borderTopStyle.borderTopWidth.boxSizing.fontFamily.fontSize.fontStretch.fontStyle.fontVariant.fontWeight.letterSpacing.lineHeight.paddingBottom.paddingLeft.paddingRight.paddingTop.tabSize.textIndent.textTransform.whiteSpace.wordBreak.wordSpacing".split(".");
|
|
10954
|
+
function z_(e) {
|
|
10955
|
+
let t = Number.parseFloat(e);
|
|
10956
|
+
return Number.isFinite(t) ? t : 0;
|
|
10957
|
+
}
|
|
10958
|
+
function B_(e) {
|
|
10959
|
+
return H_(e.fontSize, I_);
|
|
10960
|
+
}
|
|
10961
|
+
function V_(e, t = B_(e)) {
|
|
10962
|
+
let n = e.lineHeight;
|
|
10963
|
+
if (!n || n === "normal") return t * F_;
|
|
10964
|
+
let r = z_(n);
|
|
10965
|
+
return r <= 0 ? t * F_ : n.endsWith("px") ? r : n.endsWith("%") ? r / 100 * t : n.endsWith("rem") ? r * I_ : n.endsWith("em") || /^-?\d+(\.\d+)?$/.test(n.trim()) ? r * t : r;
|
|
10966
|
+
}
|
|
10967
|
+
function H_(e, t = I_) {
|
|
10968
|
+
if (!e) return 0;
|
|
10969
|
+
let n = z_(e);
|
|
10970
|
+
return n === 0 ? 0 : e.endsWith("px") ? n : e.endsWith("rem") ? n * I_ : e.endsWith("em") ? n * t : e.endsWith("%") ? n / 100 * t : n;
|
|
10971
|
+
}
|
|
10972
|
+
function U_(e) {
|
|
10973
|
+
let t = getComputedStyle(e), n = B_(t), r = H_(t.paddingTop, n) + H_(t.paddingBottom, n);
|
|
10974
|
+
return {
|
|
10975
|
+
border: H_(t.borderTopWidth, n) + H_(t.borderBottomWidth, n),
|
|
10976
|
+
fontSize: n,
|
|
10977
|
+
isBorderBox: t.boxSizing === "border-box",
|
|
10978
|
+
padding: r,
|
|
10979
|
+
rowHeight: V_(t, n),
|
|
10980
|
+
style: t
|
|
10981
|
+
};
|
|
10982
|
+
}
|
|
10983
|
+
function W_(e, t) {
|
|
10984
|
+
let n = getComputedStyle(e), r = t.style;
|
|
10985
|
+
r.width = `${e.getBoundingClientRect().width}px`, R_.forEach((e) => {
|
|
10986
|
+
r[e] = n[e];
|
|
10987
|
+
});
|
|
10988
|
+
}
|
|
10989
|
+
function G_(e) {
|
|
10990
|
+
let t = e.ownerDocument, n = t.querySelector(`textarea[${L_}]`);
|
|
10991
|
+
return n || (n = t.createElement("textarea"), n.setAttribute(L_, ""), n.setAttribute("aria-hidden", "true"), n.setAttribute("tabindex", "-1"), n.readOnly = !0, n.style.position = "absolute", n.style.top = "-9999px", n.style.left = "-9999px", n.style.visibility = "hidden", n.style.pointerEvents = "none", n.style.overflow = "hidden", n.style.resize = "none", t.body.appendChild(n)), W_(e, n), n;
|
|
10992
|
+
}
|
|
10993
|
+
function K_(e, t) {
|
|
10994
|
+
let n = G_(e), r = n.style.height, i = n.style.overflowY;
|
|
10995
|
+
n.style.overflowY = "hidden", n.style.height = "0px", n.value = "x";
|
|
10996
|
+
let a = n.scrollHeight;
|
|
10997
|
+
n.value = "x\nx";
|
|
10998
|
+
let o = n.scrollHeight;
|
|
10999
|
+
n.value = "", n.style.height = r, n.style.overflowY = i;
|
|
11000
|
+
let s = o - a;
|
|
11001
|
+
return s > 0 ? s : t.rowHeight;
|
|
11002
|
+
}
|
|
11003
|
+
function q_(e, t = U_(e)) {
|
|
11004
|
+
return K_(e, t);
|
|
11005
|
+
}
|
|
11006
|
+
function J_(e, t) {
|
|
11007
|
+
return t.isBorderBox ? e + t.border : e - t.padding;
|
|
11008
|
+
}
|
|
11009
|
+
function Y_(e, t, n) {
|
|
11010
|
+
let r = t * e;
|
|
11011
|
+
return n.isBorderBox ? r + n.padding + n.border : r;
|
|
11012
|
+
}
|
|
11013
|
+
function X_(e, t) {
|
|
11014
|
+
if (e == null || e === "") return;
|
|
11015
|
+
let n = Number(e);
|
|
11016
|
+
if (!Number.isInteger(n) || n < 1) throw Error("TextArea: maxRows must be a positive integer.");
|
|
11017
|
+
if (n < t) throw Error(`TextArea: maxRows (${n}) must not be less than minRows (${t}).`);
|
|
11018
|
+
return n;
|
|
11019
|
+
}
|
|
11020
|
+
function Z_(e, t) {
|
|
11021
|
+
let { selectionDirection: n, selectionEnd: r, selectionStart: i } = e;
|
|
11022
|
+
if (t(), document.activeElement === e) try {
|
|
11023
|
+
e.setSelectionRange(i, r, n);
|
|
11024
|
+
} catch {}
|
|
11025
|
+
}
|
|
11026
|
+
function Q_(e, t, n) {
|
|
11027
|
+
Z_(e, () => {
|
|
11028
|
+
let r = U_(e), i = q_(e, r), a = Y_(t, i, r), o = n == null ? null : Y_(n, i, r);
|
|
11029
|
+
e.style.overflowY = "hidden", e.style.height = "0px";
|
|
11030
|
+
let s = J_(e.scrollHeight, r), c = Math.max(s, a), l = o != null && c > o, u = l ? o : c, d = l ? "auto" : "hidden";
|
|
11031
|
+
e.style.minHeight = `${a}px`, e.style.maxHeight = o == null ? "" : `${o}px`, e.style.height = `${u}px`, e.style.overflowY = d;
|
|
11032
|
+
});
|
|
11033
|
+
}
|
|
10910
11034
|
//#endregion
|
|
10911
11035
|
//#region src/components/Field/useAutoResizeTextarea.js
|
|
10912
|
-
function
|
|
10913
|
-
let
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
if (!e) return;
|
|
10918
|
-
e.style.height = "0px";
|
|
10919
|
-
let t = Math.max(e.scrollHeight, e.getBoundingClientRect().height, Number.parseFloat(getComputedStyle(e).minHeight) || 0);
|
|
10920
|
-
e.style.height = `${Math.max(t, 0)}px`;
|
|
10921
|
-
}));
|
|
10922
|
-
}, []);
|
|
11036
|
+
function $_(e, t = 2, n) {
|
|
11037
|
+
let r = g(null), i = g(null), a = d(() => {
|
|
11038
|
+
let e = r.current;
|
|
11039
|
+
e && Q_(e, t, n);
|
|
11040
|
+
}, [n, t]);
|
|
10923
11041
|
return m(() => {
|
|
10924
|
-
|
|
11042
|
+
a();
|
|
10925
11043
|
}, [
|
|
11044
|
+
n,
|
|
10926
11045
|
t,
|
|
10927
|
-
|
|
11046
|
+
a,
|
|
10928
11047
|
e
|
|
10929
11048
|
]), f(() => {
|
|
10930
|
-
let e =
|
|
11049
|
+
let e = r.current;
|
|
10931
11050
|
if (!e || typeof ResizeObserver > "u") return;
|
|
10932
|
-
let t = e.getBoundingClientRect().width,
|
|
11051
|
+
let t = e.getBoundingClientRect().width, n = new ResizeObserver((e) => {
|
|
10933
11052
|
let n = e[0]?.contentRect.width;
|
|
10934
|
-
n !== t
|
|
11053
|
+
if (n !== t) {
|
|
11054
|
+
if (t = n, typeof requestAnimationFrame > "u") {
|
|
11055
|
+
a();
|
|
11056
|
+
return;
|
|
11057
|
+
}
|
|
11058
|
+
i.current !== null && typeof cancelAnimationFrame < "u" && cancelAnimationFrame(i.current), i.current = requestAnimationFrame(() => {
|
|
11059
|
+
i.current = null, a();
|
|
11060
|
+
});
|
|
11061
|
+
}
|
|
10935
11062
|
});
|
|
10936
|
-
return
|
|
10937
|
-
}, [
|
|
10938
|
-
|
|
11063
|
+
return n.observe(e), () => n.disconnect();
|
|
11064
|
+
}, [a]), f(() => () => {
|
|
11065
|
+
i.current !== null && typeof cancelAnimationFrame < "u" && cancelAnimationFrame(i.current);
|
|
10939
11066
|
}, []), {
|
|
10940
|
-
syncHeight:
|
|
10941
|
-
textareaRef:
|
|
11067
|
+
syncHeight: a,
|
|
11068
|
+
textareaRef: r
|
|
10942
11069
|
};
|
|
10943
11070
|
}
|
|
10944
11071
|
//#endregion
|
|
10945
11072
|
//#region src/components/TextArea/TextArea.jsx
|
|
10946
|
-
var
|
|
10947
|
-
let
|
|
10948
|
-
|
|
10949
|
-
},
|
|
10950
|
-
a?.(e),
|
|
11073
|
+
var ev = u(function({ label: e, value: n, onChange: r, onBlur: i, onInput: a, placeholder: o, required: s = !1, disabled: c = !1, readOnly: l = !1, error: u = !1, errorMessage: d, helperText: f, resolved: m = !1, fieldState: h = "neutral", status: g, isOpen: _ = !1, minRows: v = 2, maxRows: y, className: b = "", id: x, ...S }, C) {
|
|
11074
|
+
let w = p(), T = x || `sx-text-area-${w}`, E = Number.isFinite(Number(v)) && Number(v) > 0 ? Number(v) : 2, { syncHeight: D, textareaRef: O } = $_(n, E, X_(y, E)), k = typeof u == "string" ? u : d, A = !!u || !!k, j = h === "neutral" ? g : h, ee = (e) => {
|
|
11075
|
+
O.current = e, typeof C == "function" ? C(e) : C && (C.current = e);
|
|
11076
|
+
}, te = (e) => {
|
|
11077
|
+
a?.(e), D();
|
|
10951
11078
|
};
|
|
10952
11079
|
return /* @__PURE__ */ t(ge, {
|
|
10953
|
-
className:
|
|
11080
|
+
className: b,
|
|
10954
11081
|
disabled: c,
|
|
10955
|
-
errorMessage:
|
|
10956
|
-
fieldState:
|
|
11082
|
+
errorMessage: k,
|
|
11083
|
+
fieldState: j,
|
|
10957
11084
|
helperText: f,
|
|
10958
|
-
id:
|
|
10959
|
-
invalid:
|
|
11085
|
+
id: T,
|
|
11086
|
+
invalid: A,
|
|
10960
11087
|
isOpen: _,
|
|
10961
11088
|
label: e,
|
|
10962
11089
|
readOnly: l,
|
|
10963
11090
|
required: s,
|
|
10964
11091
|
resolved: m,
|
|
10965
11092
|
children: (e) => /* @__PURE__ */ t("textarea", {
|
|
10966
|
-
...
|
|
11093
|
+
...S,
|
|
10967
11094
|
...e,
|
|
10968
|
-
"aria-busy":
|
|
11095
|
+
"aria-busy": j === "validating" || void 0,
|
|
10969
11096
|
className: "sx-field__control sx-field__control--textarea sx-text-area__control",
|
|
10970
11097
|
disabled: c,
|
|
10971
|
-
id:
|
|
11098
|
+
id: T,
|
|
10972
11099
|
onBlur: i,
|
|
10973
11100
|
onChange: r,
|
|
10974
|
-
onInput:
|
|
11101
|
+
onInput: te,
|
|
10975
11102
|
placeholder: o,
|
|
10976
11103
|
readOnly: l || m,
|
|
10977
|
-
ref:
|
|
11104
|
+
ref: ee,
|
|
10978
11105
|
required: s,
|
|
10979
11106
|
rows: 1,
|
|
10980
|
-
style: {
|
|
10981
|
-
minHeight: `${1.35 * T}rem`,
|
|
10982
|
-
...x.style
|
|
10983
|
-
},
|
|
10984
11107
|
value: n
|
|
10985
11108
|
})
|
|
10986
11109
|
});
|
|
10987
|
-
}),
|
|
11110
|
+
}), tv = /^([01]\d|2[0-3]):([0-5]\d)$/, nv = [
|
|
10988
11111
|
2e3,
|
|
10989
11112
|
0,
|
|
10990
11113
|
1
|
|
10991
11114
|
];
|
|
10992
|
-
function
|
|
11115
|
+
function rv(e) {
|
|
10993
11116
|
if (typeof e != "string") return null;
|
|
10994
|
-
let t =
|
|
11117
|
+
let t = tv.exec(e);
|
|
10995
11118
|
return t ? {
|
|
10996
11119
|
hour: Number(t[1]),
|
|
10997
11120
|
minute: Number(t[2])
|
|
10998
11121
|
} : null;
|
|
10999
11122
|
}
|
|
11000
|
-
function
|
|
11001
|
-
let t =
|
|
11002
|
-
return t ? new Date(
|
|
11123
|
+
function iv(e) {
|
|
11124
|
+
let t = rv(e);
|
|
11125
|
+
return t ? new Date(nv[0], nv[1], nv[2], t.hour, t.minute) : null;
|
|
11003
11126
|
}
|
|
11004
|
-
function
|
|
11127
|
+
function av(e) {
|
|
11005
11128
|
return !(e instanceof Date) || Number.isNaN(e.getTime()) ? null : `${String(e.getHours()).padStart(2, "0")}:${String(e.getMinutes()).padStart(2, "0")}`;
|
|
11006
11129
|
}
|
|
11007
|
-
function
|
|
11008
|
-
let t =
|
|
11130
|
+
function ov(e) {
|
|
11131
|
+
let t = rv(e);
|
|
11009
11132
|
return t ? t.hour * 60 + t.minute : null;
|
|
11010
11133
|
}
|
|
11011
|
-
function
|
|
11012
|
-
let n =
|
|
11134
|
+
function sv(e, t = "24h") {
|
|
11135
|
+
let n = rv(e);
|
|
11013
11136
|
if (!n) return "";
|
|
11014
11137
|
if (t !== "12h") return `${String(n.hour).padStart(2, "0")}:${String(n.minute).padStart(2, "0")}`;
|
|
11015
11138
|
let r = n.hour >= 12 ? "PM" : "AM";
|
|
@@ -11017,12 +11140,12 @@ function z_(e, t = "24h") {
|
|
|
11017
11140
|
}
|
|
11018
11141
|
//#endregion
|
|
11019
11142
|
//#region src/components/Picker/TimePicker.jsx
|
|
11020
|
-
function
|
|
11021
|
-
let T = p(), E = c || `sx-time-picker-${T}`, [D, O] = _(!1), k = !i && !v && !b, A =
|
|
11022
|
-
O(!1), h?.(e ?
|
|
11143
|
+
function cv({ className: e = "", clearable: r = !1, disabled: i = !1, errorMessage: a, fieldState: o = "neutral", helperText: s, id: c, label: l, maxTime: u = null, minTime: f = null, onBlur: m, onChange: h, placeholder: g = "select time", readOnly: v = !1, required: y = !1, resolved: b = !1, timeFormat: x = "24h", timeInterval: S = 15, timeIntervals: C, value: w = null }) {
|
|
11144
|
+
let T = p(), E = c || `sx-time-picker-${T}`, [D, O] = _(!1), k = !i && !v && !b, A = rv(w), j = iv(w), ee = iv(f), te = iv(u), ne = sv(w, x), re = d((e) => {
|
|
11145
|
+
O(!1), h?.(e ? av(e) : null);
|
|
11023
11146
|
}, [h]), ie = d((e) => {
|
|
11024
11147
|
e.preventDefault(), e.stopPropagation(), k && h?.(null);
|
|
11025
|
-
}, [k, h]), ae =
|
|
11148
|
+
}, [k, h]), ae = ov(f), oe = ov(u), se = d((e) => {
|
|
11026
11149
|
if (!e || !A) return !0;
|
|
11027
11150
|
let t = e.getHours() * 60 + e.getMinutes();
|
|
11028
11151
|
return (ae == null || t >= ae) && (oe == null || t <= oe);
|
|
@@ -11103,7 +11226,7 @@ function B_({ className: e = "", clearable: r = !1, disabled: i = !1, errorMessa
|
|
|
11103
11226
|
}
|
|
11104
11227
|
//#endregion
|
|
11105
11228
|
//#region src/components/Alert/Warning.jsx
|
|
11106
|
-
function
|
|
11229
|
+
function lv({ autoClear: e = !1, autoClearInterval: r = 30, children: i, className: a = "", onClose: o, showClose: s = !1, title: c }) {
|
|
11107
11230
|
let [l, u] = _(!0), d = () => {
|
|
11108
11231
|
u(!1), o?.();
|
|
11109
11232
|
};
|
|
@@ -11148,4 +11271,4 @@ function V_({ autoClear: e = !1, autoClearInterval: r = 30, children: i, classNa
|
|
|
11148
11271
|
}) : null;
|
|
11149
11272
|
}
|
|
11150
11273
|
//#endregion
|
|
11151
|
-
export { ie as Badge, ne as Button, et as CheckboxField, ut as CheckboxGroup, Yl as DatePicker, l_ as DateTimePicker, ge as FieldShell, dt as InfoAlert, ft as RadioGroup,
|
|
11274
|
+
export { ie as Badge, ne as Button, et as CheckboxField, ut as CheckboxGroup, Yl as DatePicker, l_ as DateTimePicker, ge as FieldShell, dt as InfoAlert, ft as RadioGroup, O_ as SearchableSingleSelect, j_ as SingleSelect, N_ as SuccessDialog, ev as TextArea, P_ as TextInput, cv as TimePicker, lv as Warning };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplexable/ui",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Reusable React UI components and styles for Simplexable applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"dev": "vite",
|
|
18
18
|
"build": "vite build",
|
|
19
|
+
"test": "vitest run",
|
|
19
20
|
"prepublishOnly": "npm run build"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
@@ -26,10 +27,15 @@
|
|
|
26
27
|
"access": "restricted"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
30
|
+
"@testing-library/dom": "^10.4.1",
|
|
31
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
32
|
+
"@testing-library/react": "^16.3.3",
|
|
29
33
|
"@vitejs/plugin-react": "^6.1.1",
|
|
34
|
+
"jsdom": "^29.1.1",
|
|
30
35
|
"react": "^19.0.0",
|
|
31
36
|
"react-dom": "^19.0.0",
|
|
32
|
-
"vite": "^8.2.2"
|
|
37
|
+
"vite": "^8.2.2",
|
|
38
|
+
"vitest": "^4.1.11"
|
|
33
39
|
},
|
|
34
40
|
"dependencies": {
|
|
35
41
|
"@phosphor-icons/react": "^2.1.10",
|