@ahrowe/ui 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +85 -71
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/package/common/inputDropdown/inputDropdown.d.ts +1 -1
- package/dist/types/package/common/inputDropdown/inputDropdown.types.d.ts +6 -0
- package/dist/types/package/common/toast/toast.types.d.ts +3 -0
- package/dist/types/package/common/toast/toastProvider.d.ts +1 -1
- package/docs/InputDropdown.md +12 -0
- package/docs/Toast.md +4 -0
- package/docs/VirtualList.md +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2484,56 +2484,58 @@ function wn(e, t) {
|
|
|
2484
2484
|
let n = t.find((t) => t.value === e);
|
|
2485
2485
|
return n ? n.label ?? n.value : e;
|
|
2486
2486
|
}
|
|
2487
|
-
function Tn({ label: e = "", value: t = "", formValidator: n = null, items: r = [],
|
|
2488
|
-
let
|
|
2489
|
-
if (
|
|
2490
|
-
|
|
2491
|
-
let e = r.find((e) => e.value ===
|
|
2492
|
-
e
|
|
2493
|
-
}
|
|
2494
|
-
let
|
|
2495
|
-
|
|
2496
|
-
},
|
|
2497
|
-
|
|
2498
|
-
|
|
2487
|
+
function Tn({ label: e = "", value: t = "", formValidator: n = null, items: r = [], allowCustomValue: a = !1, className: o, style: s, classNames: c, styles: l, onSelect: u = () => null, onChange: m, placeholder: h = "", ...g }) {
|
|
2488
|
+
let _ = Cn(t, n), [v, y] = f(() => wn(_, r)), [b, x] = f(_), [S, C] = f(!1), [w, T] = f(null), E = d(null);
|
|
2489
|
+
if (_ !== b) {
|
|
2490
|
+
x(_);
|
|
2491
|
+
let e = r.find((e) => e.value === _);
|
|
2492
|
+
e ? y(e.label ?? e.value) : a && y(_);
|
|
2493
|
+
}
|
|
2494
|
+
let D = r.filter((e) => (e.label ?? e.value).toLowerCase().includes(v.toLowerCase())), O = () => {
|
|
2495
|
+
E.current &&= (clearTimeout(E.current), null), C(!0);
|
|
2496
|
+
}, k = () => {
|
|
2497
|
+
E.current = setTimeout(() => {
|
|
2498
|
+
C(!1), E.current = null;
|
|
2499
2499
|
}, 100);
|
|
2500
|
-
},
|
|
2501
|
-
|
|
2500
|
+
}, A = i((e) => {
|
|
2501
|
+
y(e.label ?? e.value), C(!1), T(null), n && n.set(e.value), m && m(e.value), u(e.value);
|
|
2502
2502
|
}, [
|
|
2503
2503
|
n,
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
]),
|
|
2507
|
-
e.key === "ArrowUp" ? (e.preventDefault(),
|
|
2504
|
+
m,
|
|
2505
|
+
u
|
|
2506
|
+
]), j = i((e) => {
|
|
2507
|
+
e.key === "ArrowUp" ? (e.preventDefault(), T((e) => e ? e - 1 : null)) : e.key === "ArrowDown" ? (e.preventDefault(), T((e) => e === null ? 0 : Math.min(e + 1, D.length - 1))) : e.key === "Enter" && (w !== null && D[w] ? A(D[w]) : a && (C(!1), T(null)));
|
|
2508
2508
|
}, [
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2509
|
+
D,
|
|
2510
|
+
w,
|
|
2511
|
+
A,
|
|
2512
|
+
a
|
|
2512
2513
|
]);
|
|
2513
2514
|
return /* @__PURE__ */ G("div", {
|
|
2514
|
-
...
|
|
2515
|
-
className: p(Sn.inputDropdown,
|
|
2515
|
+
...g,
|
|
2516
|
+
className: p(Sn.inputDropdown, c?.root, o),
|
|
2516
2517
|
style: {
|
|
2517
|
-
...
|
|
2518
|
-
...
|
|
2518
|
+
...l?.root,
|
|
2519
|
+
...s
|
|
2519
2520
|
},
|
|
2520
|
-
onFocus:
|
|
2521
|
-
onBlur:
|
|
2522
|
-
onKeyDown:
|
|
2521
|
+
onFocus: O,
|
|
2522
|
+
onBlur: k,
|
|
2523
|
+
onKeyDown: j,
|
|
2523
2524
|
children: [/* @__PURE__ */ W(ut, {
|
|
2524
2525
|
label: e,
|
|
2525
|
-
value:
|
|
2526
|
+
value: v,
|
|
2526
2527
|
onChange: (e) => {
|
|
2527
|
-
|
|
2528
|
+
y(e), T(null), C(!0), a && (n && n.set(e), m && m(e));
|
|
2528
2529
|
},
|
|
2529
|
-
placeholder:
|
|
2530
|
+
placeholder: h
|
|
2530
2531
|
}), /* @__PURE__ */ W("div", {
|
|
2531
|
-
className: p(Sn.dropdown, { [Sn.dropdownShown]:
|
|
2532
|
-
style:
|
|
2533
|
-
children:
|
|
2534
|
-
className: p(Sn.dropdownItem,
|
|
2535
|
-
style:
|
|
2536
|
-
|
|
2532
|
+
className: p(Sn.dropdown, { [Sn.dropdownShown]: S }, c?.dropdown),
|
|
2533
|
+
style: l?.dropdown,
|
|
2534
|
+
children: S && D.map((e, t) => /* @__PURE__ */ W("div", {
|
|
2535
|
+
className: p(Sn.dropdownItem, w === t && Sn.dropdownItemHighlighted, c?.item),
|
|
2536
|
+
style: l?.item,
|
|
2537
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
2538
|
+
onClick: () => A(e),
|
|
2537
2539
|
children: e.label ?? e.value
|
|
2538
2540
|
}, `${t}_${e.label}_${e.value}`))
|
|
2539
2541
|
})]
|
|
@@ -5027,6 +5029,9 @@ var pi = {
|
|
|
5027
5029
|
"toast-dismissing": "toast-dismissing_xKmB-",
|
|
5028
5030
|
toastDismissing: "toast-dismissing_xKmB-",
|
|
5029
5031
|
toastFadeOut: "toastFadeOut_cvHYp",
|
|
5032
|
+
"toast-paused": "toast-paused_NPmT4",
|
|
5033
|
+
toastPaused: "toast-paused_NPmT4",
|
|
5034
|
+
toastProgressBar: "toastProgressBar_6vBs6",
|
|
5030
5035
|
"toast-info": "toast-info_RlLli",
|
|
5031
5036
|
toastInfo: "toast-info_RlLli",
|
|
5032
5037
|
toastIcon: "toastIcon_xU1nA",
|
|
@@ -5040,7 +5045,6 @@ var pi = {
|
|
|
5040
5045
|
toastDefault: "toast-default_RTt2L",
|
|
5041
5046
|
toastContent: "toastContent_gvyIv",
|
|
5042
5047
|
toastCloseButton: "toastCloseButton_n-YST",
|
|
5043
|
-
toastProgressBar: "toastProgressBar_6vBs6",
|
|
5044
5048
|
toastShrink: "toastShrink_h89HS"
|
|
5045
5049
|
}, mi = {
|
|
5046
5050
|
info: S,
|
|
@@ -5050,41 +5054,48 @@ var pi = {
|
|
|
5050
5054
|
default: h
|
|
5051
5055
|
};
|
|
5052
5056
|
function hi({ item: e, isBottom: t, onDismiss: n }) {
|
|
5053
|
-
let { id: r, content: i, options: o, dismissing: s } = e, { duration: c, showRemainingTime: l, showCloseButton: u, type:
|
|
5057
|
+
let { id: r, content: i, options: o, dismissing: s } = e, { duration: c, showRemainingTime: l, showCloseButton: u, pauseOnHover: h, type: g, classNames: _, styles: v } = o, [y, b] = f(!1), [x, S] = f(!1), C = h && (y || x), w = d(c);
|
|
5054
5058
|
return a(() => {
|
|
5055
|
-
if (c === 0) return;
|
|
5056
|
-
let e = setTimeout(() => n(r),
|
|
5057
|
-
return () =>
|
|
5059
|
+
if (c === 0 || C) return;
|
|
5060
|
+
let e = Date.now(), t = setTimeout(() => n(r), w.current);
|
|
5061
|
+
return () => {
|
|
5062
|
+
clearTimeout(t), w.current -= Date.now() - e;
|
|
5063
|
+
};
|
|
5058
5064
|
}, [
|
|
5059
5065
|
r,
|
|
5060
5066
|
c,
|
|
5061
|
-
n
|
|
5067
|
+
n,
|
|
5068
|
+
C
|
|
5062
5069
|
]), /* @__PURE__ */ G("div", {
|
|
5063
|
-
className: p(pi.toast, t ? pi.toastBottom : null, pi[`toast-${
|
|
5064
|
-
style:
|
|
5070
|
+
className: p(pi.toast, t ? pi.toastBottom : null, pi[`toast-${g}`], s && pi.toastDismissing, C && pi.toastPaused, _?.root),
|
|
5071
|
+
style: v?.root,
|
|
5072
|
+
onMouseEnter: h ? () => b(!0) : void 0,
|
|
5073
|
+
onMouseLeave: h ? () => b(!1) : void 0,
|
|
5074
|
+
onFocus: h ? () => S(!0) : void 0,
|
|
5075
|
+
onBlur: h ? () => S(!1) : void 0,
|
|
5065
5076
|
children: [
|
|
5066
5077
|
/* @__PURE__ */ W(m, {
|
|
5067
|
-
icon: mi[
|
|
5068
|
-
className: p(pi.toastIcon,
|
|
5069
|
-
style:
|
|
5078
|
+
icon: mi[g],
|
|
5079
|
+
className: p(pi.toastIcon, _?.icon),
|
|
5080
|
+
style: v?.icon
|
|
5070
5081
|
}),
|
|
5071
5082
|
/* @__PURE__ */ W("div", {
|
|
5072
|
-
className: p(pi.toastContent,
|
|
5073
|
-
style:
|
|
5083
|
+
className: p(pi.toastContent, _?.content),
|
|
5084
|
+
style: v?.content,
|
|
5074
5085
|
children: i
|
|
5075
5086
|
}),
|
|
5076
5087
|
u && /* @__PURE__ */ W(Be, {
|
|
5077
5088
|
icon: H,
|
|
5078
5089
|
onClick: () => n(r),
|
|
5079
|
-
className: p(pi.toastCloseButton,
|
|
5080
|
-
style:
|
|
5090
|
+
className: p(pi.toastCloseButton, _?.closeButton),
|
|
5091
|
+
style: v?.closeButton,
|
|
5081
5092
|
"aria-label": "Close"
|
|
5082
5093
|
}),
|
|
5083
5094
|
l && c > 0 && /* @__PURE__ */ W("div", {
|
|
5084
|
-
className: p(pi.toastProgressBar,
|
|
5095
|
+
className: p(pi.toastProgressBar, _?.progressBar),
|
|
5085
5096
|
style: {
|
|
5086
5097
|
"--toast-duration": `${c}ms`,
|
|
5087
|
-
...
|
|
5098
|
+
...v?.progressBar
|
|
5088
5099
|
}
|
|
5089
5100
|
})
|
|
5090
5101
|
]
|
|
@@ -5113,60 +5124,63 @@ var bi = {
|
|
|
5113
5124
|
duration: 4e3,
|
|
5114
5125
|
showRemainingTime: !0,
|
|
5115
5126
|
showCloseButton: !0,
|
|
5116
|
-
allowStacking: !0
|
|
5127
|
+
allowStacking: !0,
|
|
5128
|
+
pauseOnHover: !0
|
|
5117
5129
|
}, xi = 220;
|
|
5118
5130
|
function Si(e) {
|
|
5119
5131
|
return pi[`container-${e}`];
|
|
5120
5132
|
}
|
|
5121
|
-
function Ci({ children: e, position: t = bi.position, duration: n = bi.duration, showRemainingTime: r = bi.showRemainingTime, showCloseButton: o = bi.showCloseButton, allowStacking: s = bi.allowStacking }) {
|
|
5122
|
-
let [
|
|
5123
|
-
|
|
5133
|
+
function Ci({ children: e, position: t = bi.position, duration: n = bi.duration, showRemainingTime: r = bi.showRemainingTime, showCloseButton: o = bi.showCloseButton, allowStacking: s = bi.allowStacking, pauseOnHover: c = bi.pauseOnHover }) {
|
|
5134
|
+
let [l, u] = f([]), m = d(0), h = i((e) => {
|
|
5135
|
+
u((t) => t.map((t) => t.id === e ? {
|
|
5124
5136
|
...t,
|
|
5125
5137
|
dismissing: !0
|
|
5126
5138
|
} : t)), setTimeout(() => {
|
|
5127
|
-
|
|
5139
|
+
u((t) => t.filter((t) => t.id !== e));
|
|
5128
5140
|
}, xi);
|
|
5129
|
-
}, []),
|
|
5141
|
+
}, []), g = i((e, i) => {
|
|
5130
5142
|
let a = {
|
|
5131
5143
|
position: i?.position ?? t,
|
|
5132
5144
|
duration: i?.duration ?? n,
|
|
5133
5145
|
showRemainingTime: i?.showRemainingTime ?? r,
|
|
5134
5146
|
showCloseButton: i?.showCloseButton ?? o,
|
|
5147
|
+
pauseOnHover: i?.pauseOnHover ?? c,
|
|
5135
5148
|
type: i?.type ?? "default",
|
|
5136
5149
|
classNames: i?.classNames,
|
|
5137
5150
|
styles: i?.styles
|
|
5138
5151
|
};
|
|
5139
|
-
|
|
5140
|
-
let
|
|
5141
|
-
id: `toast-${
|
|
5152
|
+
m.current += 1;
|
|
5153
|
+
let l = {
|
|
5154
|
+
id: `toast-${m.current}`,
|
|
5142
5155
|
content: e,
|
|
5143
5156
|
options: a,
|
|
5144
5157
|
dismissing: !1
|
|
5145
5158
|
};
|
|
5146
|
-
|
|
5147
|
-
|
|
5159
|
+
u((e) => !s && e.length > 0 ? (setTimeout(() => {
|
|
5160
|
+
u([l]);
|
|
5148
5161
|
}, xi), e.map((e) => ({
|
|
5149
5162
|
...e,
|
|
5150
5163
|
dismissing: !0
|
|
5151
|
-
}))) : [...e,
|
|
5164
|
+
}))) : [...e, l]);
|
|
5152
5165
|
}, [
|
|
5153
5166
|
t,
|
|
5154
5167
|
n,
|
|
5155
5168
|
r,
|
|
5156
5169
|
o,
|
|
5157
|
-
s
|
|
5170
|
+
s,
|
|
5171
|
+
c
|
|
5158
5172
|
]);
|
|
5159
|
-
a(() => (_i(
|
|
5160
|
-
let
|
|
5173
|
+
a(() => (_i(g), () => vi()), [g]);
|
|
5174
|
+
let _ = l.reduce((e, t) => {
|
|
5161
5175
|
let n = t.options.position;
|
|
5162
5176
|
return e[n] || (e[n] = []), e[n].push(t), e;
|
|
5163
5177
|
}, {});
|
|
5164
|
-
return /* @__PURE__ */ G(U, { children: [e, /* @__PURE__ */ W(Ve, { children: Object.entries(
|
|
5178
|
+
return /* @__PURE__ */ G(U, { children: [e, /* @__PURE__ */ W(Ve, { children: Object.entries(_).map(([e, t]) => /* @__PURE__ */ W("div", {
|
|
5165
5179
|
className: p(pi.container, Si(e)),
|
|
5166
5180
|
children: t.map((t) => /* @__PURE__ */ W(hi, {
|
|
5167
5181
|
item: t,
|
|
5168
5182
|
isBottom: e.startsWith("bottom"),
|
|
5169
|
-
onDismiss:
|
|
5183
|
+
onDismiss: h
|
|
5170
5184
|
}, t.id))
|
|
5171
5185
|
}, e)) })] });
|
|
5172
5186
|
}
|