@ahrowe/ui 0.2.2 → 0.2.4
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 +89 -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/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2484,56 +2484,62 @@ 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, a || y(wn(_, r));
|
|
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
|
+
if (y(e), T(null), C(!0), a) n && n.set(e), m && m(e);
|
|
2529
|
+
else {
|
|
2530
|
+
let t = r.find((t) => (t.label ?? t.value).toLowerCase() === e.toLowerCase());
|
|
2531
|
+
t && (n && n.set(t.value), m && m(t.value), u(t.value));
|
|
2532
|
+
}
|
|
2528
2533
|
},
|
|
2529
|
-
placeholder:
|
|
2534
|
+
placeholder: h
|
|
2530
2535
|
}), /* @__PURE__ */ W("div", {
|
|
2531
|
-
className: p(Sn.dropdown, { [Sn.dropdownShown]:
|
|
2532
|
-
style:
|
|
2533
|
-
children:
|
|
2534
|
-
className: p(Sn.dropdownItem,
|
|
2535
|
-
style:
|
|
2536
|
-
|
|
2536
|
+
className: p(Sn.dropdown, { [Sn.dropdownShown]: S }, c?.dropdown),
|
|
2537
|
+
style: l?.dropdown,
|
|
2538
|
+
children: S && D.map((e, t) => /* @__PURE__ */ W("div", {
|
|
2539
|
+
className: p(Sn.dropdownItem, w === t && Sn.dropdownItemHighlighted, c?.item),
|
|
2540
|
+
style: l?.item,
|
|
2541
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
2542
|
+
onClick: () => A(e),
|
|
2537
2543
|
children: e.label ?? e.value
|
|
2538
2544
|
}, `${t}_${e.label}_${e.value}`))
|
|
2539
2545
|
})]
|
|
@@ -5027,6 +5033,9 @@ var pi = {
|
|
|
5027
5033
|
"toast-dismissing": "toast-dismissing_xKmB-",
|
|
5028
5034
|
toastDismissing: "toast-dismissing_xKmB-",
|
|
5029
5035
|
toastFadeOut: "toastFadeOut_cvHYp",
|
|
5036
|
+
"toast-paused": "toast-paused_NPmT4",
|
|
5037
|
+
toastPaused: "toast-paused_NPmT4",
|
|
5038
|
+
toastProgressBar: "toastProgressBar_6vBs6",
|
|
5030
5039
|
"toast-info": "toast-info_RlLli",
|
|
5031
5040
|
toastInfo: "toast-info_RlLli",
|
|
5032
5041
|
toastIcon: "toastIcon_xU1nA",
|
|
@@ -5040,7 +5049,6 @@ var pi = {
|
|
|
5040
5049
|
toastDefault: "toast-default_RTt2L",
|
|
5041
5050
|
toastContent: "toastContent_gvyIv",
|
|
5042
5051
|
toastCloseButton: "toastCloseButton_n-YST",
|
|
5043
|
-
toastProgressBar: "toastProgressBar_6vBs6",
|
|
5044
5052
|
toastShrink: "toastShrink_h89HS"
|
|
5045
5053
|
}, mi = {
|
|
5046
5054
|
info: S,
|
|
@@ -5050,41 +5058,48 @@ var pi = {
|
|
|
5050
5058
|
default: h
|
|
5051
5059
|
};
|
|
5052
5060
|
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:
|
|
5061
|
+
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
5062
|
return a(() => {
|
|
5055
|
-
if (c === 0) return;
|
|
5056
|
-
let e = setTimeout(() => n(r),
|
|
5057
|
-
return () =>
|
|
5063
|
+
if (c === 0 || C) return;
|
|
5064
|
+
let e = Date.now(), t = setTimeout(() => n(r), w.current);
|
|
5065
|
+
return () => {
|
|
5066
|
+
clearTimeout(t), w.current -= Date.now() - e;
|
|
5067
|
+
};
|
|
5058
5068
|
}, [
|
|
5059
5069
|
r,
|
|
5060
5070
|
c,
|
|
5061
|
-
n
|
|
5071
|
+
n,
|
|
5072
|
+
C
|
|
5062
5073
|
]), /* @__PURE__ */ G("div", {
|
|
5063
|
-
className: p(pi.toast, t ? pi.toastBottom : null, pi[`toast-${
|
|
5064
|
-
style:
|
|
5074
|
+
className: p(pi.toast, t ? pi.toastBottom : null, pi[`toast-${g}`], s && pi.toastDismissing, C && pi.toastPaused, _?.root),
|
|
5075
|
+
style: v?.root,
|
|
5076
|
+
onMouseEnter: h ? () => b(!0) : void 0,
|
|
5077
|
+
onMouseLeave: h ? () => b(!1) : void 0,
|
|
5078
|
+
onFocus: h ? () => S(!0) : void 0,
|
|
5079
|
+
onBlur: h ? () => S(!1) : void 0,
|
|
5065
5080
|
children: [
|
|
5066
5081
|
/* @__PURE__ */ W(m, {
|
|
5067
|
-
icon: mi[
|
|
5068
|
-
className: p(pi.toastIcon,
|
|
5069
|
-
style:
|
|
5082
|
+
icon: mi[g],
|
|
5083
|
+
className: p(pi.toastIcon, _?.icon),
|
|
5084
|
+
style: v?.icon
|
|
5070
5085
|
}),
|
|
5071
5086
|
/* @__PURE__ */ W("div", {
|
|
5072
|
-
className: p(pi.toastContent,
|
|
5073
|
-
style:
|
|
5087
|
+
className: p(pi.toastContent, _?.content),
|
|
5088
|
+
style: v?.content,
|
|
5074
5089
|
children: i
|
|
5075
5090
|
}),
|
|
5076
5091
|
u && /* @__PURE__ */ W(Be, {
|
|
5077
5092
|
icon: H,
|
|
5078
5093
|
onClick: () => n(r),
|
|
5079
|
-
className: p(pi.toastCloseButton,
|
|
5080
|
-
style:
|
|
5094
|
+
className: p(pi.toastCloseButton, _?.closeButton),
|
|
5095
|
+
style: v?.closeButton,
|
|
5081
5096
|
"aria-label": "Close"
|
|
5082
5097
|
}),
|
|
5083
5098
|
l && c > 0 && /* @__PURE__ */ W("div", {
|
|
5084
|
-
className: p(pi.toastProgressBar,
|
|
5099
|
+
className: p(pi.toastProgressBar, _?.progressBar),
|
|
5085
5100
|
style: {
|
|
5086
5101
|
"--toast-duration": `${c}ms`,
|
|
5087
|
-
...
|
|
5102
|
+
...v?.progressBar
|
|
5088
5103
|
}
|
|
5089
5104
|
})
|
|
5090
5105
|
]
|
|
@@ -5113,60 +5128,63 @@ var bi = {
|
|
|
5113
5128
|
duration: 4e3,
|
|
5114
5129
|
showRemainingTime: !0,
|
|
5115
5130
|
showCloseButton: !0,
|
|
5116
|
-
allowStacking: !0
|
|
5131
|
+
allowStacking: !0,
|
|
5132
|
+
pauseOnHover: !0
|
|
5117
5133
|
}, xi = 220;
|
|
5118
5134
|
function Si(e) {
|
|
5119
5135
|
return pi[`container-${e}`];
|
|
5120
5136
|
}
|
|
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
|
-
|
|
5137
|
+
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 }) {
|
|
5138
|
+
let [l, u] = f([]), m = d(0), h = i((e) => {
|
|
5139
|
+
u((t) => t.map((t) => t.id === e ? {
|
|
5124
5140
|
...t,
|
|
5125
5141
|
dismissing: !0
|
|
5126
5142
|
} : t)), setTimeout(() => {
|
|
5127
|
-
|
|
5143
|
+
u((t) => t.filter((t) => t.id !== e));
|
|
5128
5144
|
}, xi);
|
|
5129
|
-
}, []),
|
|
5145
|
+
}, []), g = i((e, i) => {
|
|
5130
5146
|
let a = {
|
|
5131
5147
|
position: i?.position ?? t,
|
|
5132
5148
|
duration: i?.duration ?? n,
|
|
5133
5149
|
showRemainingTime: i?.showRemainingTime ?? r,
|
|
5134
5150
|
showCloseButton: i?.showCloseButton ?? o,
|
|
5151
|
+
pauseOnHover: i?.pauseOnHover ?? c,
|
|
5135
5152
|
type: i?.type ?? "default",
|
|
5136
5153
|
classNames: i?.classNames,
|
|
5137
5154
|
styles: i?.styles
|
|
5138
5155
|
};
|
|
5139
|
-
|
|
5140
|
-
let
|
|
5141
|
-
id: `toast-${
|
|
5156
|
+
m.current += 1;
|
|
5157
|
+
let l = {
|
|
5158
|
+
id: `toast-${m.current}`,
|
|
5142
5159
|
content: e,
|
|
5143
5160
|
options: a,
|
|
5144
5161
|
dismissing: !1
|
|
5145
5162
|
};
|
|
5146
|
-
|
|
5147
|
-
|
|
5163
|
+
u((e) => !s && e.length > 0 ? (setTimeout(() => {
|
|
5164
|
+
u([l]);
|
|
5148
5165
|
}, xi), e.map((e) => ({
|
|
5149
5166
|
...e,
|
|
5150
5167
|
dismissing: !0
|
|
5151
|
-
}))) : [...e,
|
|
5168
|
+
}))) : [...e, l]);
|
|
5152
5169
|
}, [
|
|
5153
5170
|
t,
|
|
5154
5171
|
n,
|
|
5155
5172
|
r,
|
|
5156
5173
|
o,
|
|
5157
|
-
s
|
|
5174
|
+
s,
|
|
5175
|
+
c
|
|
5158
5176
|
]);
|
|
5159
|
-
a(() => (_i(
|
|
5160
|
-
let
|
|
5177
|
+
a(() => (_i(g), () => vi()), [g]);
|
|
5178
|
+
let _ = l.reduce((e, t) => {
|
|
5161
5179
|
let n = t.options.position;
|
|
5162
5180
|
return e[n] || (e[n] = []), e[n].push(t), e;
|
|
5163
5181
|
}, {});
|
|
5164
|
-
return /* @__PURE__ */ G(U, { children: [e, /* @__PURE__ */ W(Ve, { children: Object.entries(
|
|
5182
|
+
return /* @__PURE__ */ G(U, { children: [e, /* @__PURE__ */ W(Ve, { children: Object.entries(_).map(([e, t]) => /* @__PURE__ */ W("div", {
|
|
5165
5183
|
className: p(pi.container, Si(e)),
|
|
5166
5184
|
children: t.map((t) => /* @__PURE__ */ W(hi, {
|
|
5167
5185
|
item: t,
|
|
5168
5186
|
isBottom: e.startsWith("bottom"),
|
|
5169
|
-
onDismiss:
|
|
5187
|
+
onDismiss: h
|
|
5170
5188
|
}, t.id))
|
|
5171
5189
|
}, e)) })] });
|
|
5172
5190
|
}
|