@overdoser/react-toolkit 0.15.0 → 0.17.0
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/AGENTS.md +2 -0
- package/CHANGELOG.md +87 -0
- package/components/Chart/AreaChart.d.ts +5 -1
- package/components/Chart/AreaChart.js +155 -144
- package/components/Chart/BarChart.js +5 -5
- package/components/Chart/PieChart.js +2 -5
- package/components/Chart/RadarChart.js +2 -5
- package/components/Chart/TradingChart.js +258 -257
- package/components/Drawer/Drawer.js +69 -70
- package/components/Dropdown/Dropdown.js +51 -56
- package/components/Modal/Modal.js +42 -47
- package/components/Popover/Popover.js +52 -55
- package/components/SplitButton/SplitButton.js +50 -55
- package/components/inputs/DatePicker/CalendarPanel.d.ts +40 -0
- package/components/inputs/DatePicker/CalendarPanel.js +287 -0
- package/components/inputs/DatePicker/CalendarPanel.module.scss.js +41 -0
- package/components/inputs/DatePicker/DatePicker.d.ts +3 -1
- package/components/inputs/DatePicker/DatePicker.js +105 -192
- package/components/inputs/DatePicker/DatePicker.module.scss.js +20 -40
- package/components/inputs/DateTimePicker/DateTimePicker.d.ts +141 -0
- package/components/inputs/DateTimePicker/DateTimePicker.js +232 -0
- package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +37 -0
- package/components/inputs/DateTimePicker/DateTimeSegments.d.ts +48 -0
- package/components/inputs/DateTimePicker/DateTimeSegments.js +252 -0
- package/components/inputs/DateTimePicker/TimeField.d.ts +18 -0
- package/components/inputs/DateTimePicker/TimeField.js +135 -0
- package/components/inputs/DateTimePicker/index.d.ts +3 -0
- package/components/inputs/DateTimePicker/timeZoneUtils.d.ts +44 -0
- package/components/inputs/DateTimePicker/timeZoneUtils.js +102 -0
- package/components/inputs/NumberInput/NumberInput.js +79 -81
- package/components/inputs/Select/Select.d.ts +5 -0
- package/components/inputs/Select/Select.js +340 -285
- package/hooks/useEscapeLayer.d.ts +36 -0
- package/hooks/useEscapeLayer.js +33 -0
- package/index.css +1 -1
- package/index.d.ts +2 -0
- package/index.js +108 -106
- package/index.layered.css +1 -1
- package/llms.txt +29 -4
- package/manifest.json +127 -1
- package/package.json +1 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { jsxs as H, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as b, useRef as g, useEffect as w } from "react";
|
|
3
|
+
import x from "clsx";
|
|
4
|
+
import S from "./DateTimePicker.module.scss.js";
|
|
5
|
+
const y = (n) => String(n).padStart(2, "0");
|
|
6
|
+
function A(n, r, l) {
|
|
7
|
+
const a = /* @__PURE__ */ new Set();
|
|
8
|
+
for (let o = 0; o <= n; o += Math.max(1, Math.floor(r))) a.add(o);
|
|
9
|
+
return a.add(l), Array.from(a).sort((o, f) => o - f).map((o) => ({ value: o, label: y(o) }));
|
|
10
|
+
}
|
|
11
|
+
function v({ label: n, items: r, selected: l, onSelect: a, disabled: o, classes: f }) {
|
|
12
|
+
const m = g(null), u = g(!1);
|
|
13
|
+
w(() => {
|
|
14
|
+
const e = m.current, t = e?.querySelector('[aria-selected="true"]');
|
|
15
|
+
e && t && (e.scrollTop = t.offsetTop - e.clientHeight / 2 + t.offsetHeight / 2);
|
|
16
|
+
}, []), w(() => {
|
|
17
|
+
if (!u.current) return;
|
|
18
|
+
u.current = !1;
|
|
19
|
+
const e = m.current?.querySelector('[aria-selected="true"]');
|
|
20
|
+
e?.focus(), e?.scrollIntoView?.({ block: "nearest" });
|
|
21
|
+
}, [l]);
|
|
22
|
+
const i = (e) => {
|
|
23
|
+
const t = r.findIndex((h) => h.value === l);
|
|
24
|
+
let s = t;
|
|
25
|
+
switch (e.key) {
|
|
26
|
+
case "ArrowDown":
|
|
27
|
+
s = (t + 1) % r.length;
|
|
28
|
+
break;
|
|
29
|
+
case "ArrowUp":
|
|
30
|
+
s = (t - 1 + r.length) % r.length;
|
|
31
|
+
break;
|
|
32
|
+
case "Home":
|
|
33
|
+
s = 0;
|
|
34
|
+
break;
|
|
35
|
+
case "End":
|
|
36
|
+
s = r.length - 1;
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
e.preventDefault(), s !== t && (u.current = !0, a(r[s].value));
|
|
42
|
+
};
|
|
43
|
+
return (
|
|
44
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
45
|
+
/* @__PURE__ */ d(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
ref: m,
|
|
49
|
+
role: "listbox",
|
|
50
|
+
"aria-label": n,
|
|
51
|
+
className: x(S.column, f?.column),
|
|
52
|
+
onKeyDown: i,
|
|
53
|
+
children: r.map((e) => {
|
|
54
|
+
const t = e.value === l;
|
|
55
|
+
return /* @__PURE__ */ d(
|
|
56
|
+
"button",
|
|
57
|
+
{
|
|
58
|
+
type: "button",
|
|
59
|
+
role: "option",
|
|
60
|
+
"aria-selected": t,
|
|
61
|
+
tabIndex: t ? 0 : -1,
|
|
62
|
+
disabled: o,
|
|
63
|
+
className: x(S.option, t && S.optionSelected, f?.option, t && f?.optionSelected),
|
|
64
|
+
onClick: () => a(e.value),
|
|
65
|
+
children: e.label
|
|
66
|
+
},
|
|
67
|
+
e.value
|
|
68
|
+
);
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function j({
|
|
75
|
+
hour: n,
|
|
76
|
+
minute: r,
|
|
77
|
+
second: l,
|
|
78
|
+
onChange: a,
|
|
79
|
+
hourCycle: o,
|
|
80
|
+
showSeconds: f,
|
|
81
|
+
minuteStep: m,
|
|
82
|
+
disabled: u,
|
|
83
|
+
classes: i
|
|
84
|
+
}) {
|
|
85
|
+
const e = o === 12, t = n >= 12, s = b(() => e ? Array.from({ length: 12 }, (c, p) => ({ value: p + (t ? 12 : 0), label: y(p === 0 ? 12 : p) })) : Array.from({ length: 24 }, (c, p) => ({ value: p, label: y(p) })), [e, t]), h = b(() => A(59, m, r), [m, r]), M = b(() => A(59, 1, l), [l]), k = b(() => [{ value: 0, label: "AM" }, { value: 1, label: "PM" }], []);
|
|
86
|
+
return /* @__PURE__ */ H("div", { className: x(S.time, i?.time), role: "group", "aria-label": "Time", children: [
|
|
87
|
+
/* @__PURE__ */ d(
|
|
88
|
+
v,
|
|
89
|
+
{
|
|
90
|
+
label: "Hours",
|
|
91
|
+
items: s,
|
|
92
|
+
selected: n,
|
|
93
|
+
onSelect: (c) => a({ hour: c, minute: r, second: l }),
|
|
94
|
+
disabled: u,
|
|
95
|
+
classes: i
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ d(
|
|
99
|
+
v,
|
|
100
|
+
{
|
|
101
|
+
label: "Minutes",
|
|
102
|
+
items: h,
|
|
103
|
+
selected: r,
|
|
104
|
+
onSelect: (c) => a({ hour: n, minute: c, second: l }),
|
|
105
|
+
disabled: u,
|
|
106
|
+
classes: i
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
f && /* @__PURE__ */ d(
|
|
110
|
+
v,
|
|
111
|
+
{
|
|
112
|
+
label: "Seconds",
|
|
113
|
+
items: M,
|
|
114
|
+
selected: l,
|
|
115
|
+
onSelect: (c) => a({ hour: n, minute: r, second: c }),
|
|
116
|
+
disabled: u,
|
|
117
|
+
classes: i
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
e && /* @__PURE__ */ d(
|
|
121
|
+
v,
|
|
122
|
+
{
|
|
123
|
+
label: "AM/PM",
|
|
124
|
+
items: k,
|
|
125
|
+
selected: t ? 1 : 0,
|
|
126
|
+
onSelect: (c) => a({ hour: n % 12 + (c ? 12 : 0), minute: r, second: l }),
|
|
127
|
+
disabled: u,
|
|
128
|
+
classes: i
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
] });
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
j as TimeField
|
|
135
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wall-clock ⇄ instant conversion for an arbitrary IANA time zone, built on
|
|
3
|
+
* `Intl.DateTimeFormat` only (no date library). When `timeZone` is undefined
|
|
4
|
+
* every helper falls back to the plain local `Date` getters/constructor, so
|
|
5
|
+
* the default path is byte-for-byte what `DatePicker` does.
|
|
6
|
+
*/
|
|
7
|
+
export interface WallClock {
|
|
8
|
+
year: number;
|
|
9
|
+
/** 0-based, like `Date#getMonth`. */
|
|
10
|
+
month: number;
|
|
11
|
+
day: number;
|
|
12
|
+
hour: number;
|
|
13
|
+
minute: number;
|
|
14
|
+
second: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TimeParts {
|
|
17
|
+
hour: number;
|
|
18
|
+
minute: number;
|
|
19
|
+
second: number;
|
|
20
|
+
}
|
|
21
|
+
/** `true` when `Intl` accepts `timeZone` (IANA name, `'UTC'`, or an alias). */
|
|
22
|
+
export declare function isValidTimeZone(timeZone: string): boolean;
|
|
23
|
+
/** The runtime's local IANA zone (e.g. `'Europe/Bucharest'`). */
|
|
24
|
+
export declare function localTimeZone(): string;
|
|
25
|
+
/** Wall-clock fields of `date` as seen in `timeZone` (local zone when omitted). */
|
|
26
|
+
export declare function getWallClock(date: Date, timeZone?: string): WallClock;
|
|
27
|
+
/**
|
|
28
|
+
* The instant whose wall clock in `timeZone` reads `wc` (local zone when
|
|
29
|
+
* omitted). In a DST overlap (a wall-clock time that happens twice) the
|
|
30
|
+
* earlier instant wins; in a gap (a time that never happens) the result is
|
|
31
|
+
* shifted forward by the gap — the resolution most date libraries use.
|
|
32
|
+
*/
|
|
33
|
+
export declare function fromWallClock(wc: WallClock, timeZone?: string): Date;
|
|
34
|
+
/** Local-midnight `Date` for the wall-clock day — the key the calendar grid works with. */
|
|
35
|
+
export declare function wallClockDay(wc: WallClock): Date;
|
|
36
|
+
export type TimeZoneNameStyle = 'short' | 'long' | 'shortOffset' | 'longOffset';
|
|
37
|
+
/**
|
|
38
|
+
* Localized zone name for `timeZone` at `date` (e.g. `'EDT'`, `'GMT+3'`,
|
|
39
|
+
* `'Coordinated Universal Time'`). Offset styles fall back to `'short'` on
|
|
40
|
+
* older ICU builds that don't support them.
|
|
41
|
+
*/
|
|
42
|
+
export declare function timeZoneName(date: Date, timeZone: string | undefined, locale?: string, style?: TimeZoneNameStyle): string;
|
|
43
|
+
/** Default hour cycle for `locale` (12 for en-US, 24 for most of Europe). */
|
|
44
|
+
export declare function localeHourCycle(locale?: string): 12 | 24;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const i = /* @__PURE__ */ new Map();
|
|
2
|
+
function c(e) {
|
|
3
|
+
let t = i.get(e);
|
|
4
|
+
return t || (t = new Intl.DateTimeFormat("en-US", {
|
|
5
|
+
timeZone: e,
|
|
6
|
+
hourCycle: "h23",
|
|
7
|
+
year: "numeric",
|
|
8
|
+
month: "numeric",
|
|
9
|
+
day: "numeric",
|
|
10
|
+
hour: "numeric",
|
|
11
|
+
minute: "numeric",
|
|
12
|
+
second: "numeric"
|
|
13
|
+
}), i.set(e, t)), t;
|
|
14
|
+
}
|
|
15
|
+
function h(e) {
|
|
16
|
+
try {
|
|
17
|
+
return c(e), !0;
|
|
18
|
+
} catch {
|
|
19
|
+
return !1;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function y() {
|
|
23
|
+
return new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
24
|
+
}
|
|
25
|
+
function f(e, t) {
|
|
26
|
+
if (!t)
|
|
27
|
+
return {
|
|
28
|
+
year: e.getFullYear(),
|
|
29
|
+
month: e.getMonth(),
|
|
30
|
+
day: e.getDate(),
|
|
31
|
+
hour: e.getHours(),
|
|
32
|
+
minute: e.getMinutes(),
|
|
33
|
+
second: e.getSeconds()
|
|
34
|
+
};
|
|
35
|
+
const n = { year: 0, month: 0, day: 1, hour: 0, minute: 0, second: 0 };
|
|
36
|
+
for (const r of c(t).formatToParts(e))
|
|
37
|
+
switch (r.type) {
|
|
38
|
+
case "year":
|
|
39
|
+
n.year = Number(r.value);
|
|
40
|
+
break;
|
|
41
|
+
case "month":
|
|
42
|
+
n.month = Number(r.value) - 1;
|
|
43
|
+
break;
|
|
44
|
+
case "day":
|
|
45
|
+
n.day = Number(r.value);
|
|
46
|
+
break;
|
|
47
|
+
case "hour":
|
|
48
|
+
n.hour = Number(r.value) % 24;
|
|
49
|
+
break;
|
|
50
|
+
case "minute":
|
|
51
|
+
n.minute = Number(r.value);
|
|
52
|
+
break;
|
|
53
|
+
case "second":
|
|
54
|
+
n.second = Number(r.value);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
return n;
|
|
58
|
+
}
|
|
59
|
+
function l(e) {
|
|
60
|
+
const t = /* @__PURE__ */ new Date(0);
|
|
61
|
+
return t.setUTCFullYear(e.year, e.month, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t.getTime();
|
|
62
|
+
}
|
|
63
|
+
function s(e, t) {
|
|
64
|
+
return l(f(e, t)) - Math.floor(e.getTime() / 1e3) * 1e3;
|
|
65
|
+
}
|
|
66
|
+
function d(e, t) {
|
|
67
|
+
if (!t) {
|
|
68
|
+
const a = new Date(e.year, e.month, e.day, e.hour, e.minute, e.second, 0);
|
|
69
|
+
return e.year >= 0 && e.year < 100 && a.setFullYear(e.year), a;
|
|
70
|
+
}
|
|
71
|
+
const n = l(e), r = 864e5, u = new Set([n - r, n, n + r].map((a) => s(new Date(a), t))), o = [];
|
|
72
|
+
for (const a of u) {
|
|
73
|
+
const m = n - a;
|
|
74
|
+
s(new Date(m), t) === a && o.push(m);
|
|
75
|
+
}
|
|
76
|
+
return o.length > 0 ? new Date(Math.min(...o)) : new Date(n - s(new Date(n - r), t));
|
|
77
|
+
}
|
|
78
|
+
function D(e) {
|
|
79
|
+
const t = new Date(e.year, e.month, e.day);
|
|
80
|
+
return e.year >= 0 && e.year < 100 && t.setFullYear(e.year), t;
|
|
81
|
+
}
|
|
82
|
+
function b(e, t, n, r = "short") {
|
|
83
|
+
const u = (o) => new Intl.DateTimeFormat(n, { timeZone: t, timeZoneName: o }).formatToParts(e).find((a) => a.type === "timeZoneName")?.value ?? "";
|
|
84
|
+
try {
|
|
85
|
+
return u(r);
|
|
86
|
+
} catch {
|
|
87
|
+
return u("short");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function T(e) {
|
|
91
|
+
const t = new Intl.DateTimeFormat(e, { hour: "numeric" }).resolvedOptions().hourCycle;
|
|
92
|
+
return t === "h11" || t === "h12" ? 12 : 24;
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
d as fromWallClock,
|
|
96
|
+
f as getWallClock,
|
|
97
|
+
h as isValidTimeZone,
|
|
98
|
+
y as localTimeZone,
|
|
99
|
+
T as localeHourCycle,
|
|
100
|
+
b as timeZoneName,
|
|
101
|
+
D as wallClockDay
|
|
102
|
+
};
|
|
@@ -1,125 +1,123 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as B, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as q, useState as z, useRef as L, useEffect as G, useCallback as S } from "react";
|
|
3
|
+
import m from "clsx";
|
|
4
|
+
import l from "./NumberInput.module.scss.js";
|
|
5
|
+
const x = (n) => {
|
|
6
6
|
if (n.trim() === "") return null;
|
|
7
|
-
const
|
|
8
|
-
return Number.isNaN(
|
|
9
|
-
},
|
|
7
|
+
const h = Number(n);
|
|
8
|
+
return Number.isNaN(h) ? null : h;
|
|
9
|
+
}, H = q(
|
|
10
10
|
({
|
|
11
11
|
value: n,
|
|
12
|
-
defaultValue:
|
|
13
|
-
onChange:
|
|
14
|
-
min:
|
|
15
|
-
max:
|
|
16
|
-
step:
|
|
17
|
-
precision:
|
|
18
|
-
inputSize:
|
|
19
|
-
error:
|
|
20
|
-
hideControls:
|
|
21
|
-
disabled:
|
|
12
|
+
defaultValue: h,
|
|
13
|
+
onChange: v,
|
|
14
|
+
min: u,
|
|
15
|
+
max: a,
|
|
16
|
+
step: D = 1,
|
|
17
|
+
precision: N,
|
|
18
|
+
inputSize: R = "md",
|
|
19
|
+
error: C = !1,
|
|
20
|
+
hideControls: A = !1,
|
|
21
|
+
disabled: i,
|
|
22
|
+
readOnly: f,
|
|
22
23
|
classes: d,
|
|
23
|
-
className:
|
|
24
|
-
style:
|
|
25
|
-
onKeyDown:
|
|
26
|
-
onBlur:
|
|
27
|
-
...
|
|
28
|
-
},
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}, [
|
|
33
|
-
const
|
|
24
|
+
className: F,
|
|
25
|
+
style: K,
|
|
26
|
+
onKeyDown: W,
|
|
27
|
+
onBlur: E,
|
|
28
|
+
...I
|
|
29
|
+
}, P) => {
|
|
30
|
+
const c = n !== void 0, j = (c ? n : h) ?? null, [g, p] = z(j != null ? String(j) : ""), w = L(!1), b = L(!1), r = c ? n ?? null : x(g);
|
|
31
|
+
G(() => {
|
|
32
|
+
c && (!w.current || b.current) && p(n != null ? String(n) : ""), b.current = !1;
|
|
33
|
+
}, [c, n]);
|
|
34
|
+
const M = S(
|
|
34
35
|
(t) => {
|
|
35
36
|
let e = t;
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
e = Math.round(e *
|
|
37
|
+
if (u != null && (e = Math.max(u, e)), a != null && (e = Math.min(a, e)), N != null) {
|
|
38
|
+
const o = 10 ** N;
|
|
39
|
+
e = Math.round(e * o) / o;
|
|
39
40
|
}
|
|
40
41
|
return e;
|
|
41
42
|
},
|
|
42
|
-
[
|
|
43
|
-
),
|
|
43
|
+
[u, a, N]
|
|
44
|
+
), y = S(
|
|
44
45
|
(t) => {
|
|
45
|
-
|
|
46
|
+
c ? b.current = !0 : p(t != null ? String(t) : ""), v?.(t);
|
|
46
47
|
},
|
|
47
|
-
[
|
|
48
|
-
),
|
|
48
|
+
[c, v]
|
|
49
|
+
), k = S(
|
|
49
50
|
(t) => {
|
|
50
|
-
if (
|
|
51
|
-
|
|
51
|
+
if (i || f) return;
|
|
52
|
+
y(M((r ?? u ?? 0) + t * D));
|
|
52
53
|
},
|
|
53
|
-
[
|
|
54
|
-
),
|
|
55
|
-
|
|
54
|
+
[i, f, r, u, D, M, y]
|
|
55
|
+
), T = a != null && r != null && r >= a, U = u != null && r != null && r <= u, V = (t) => {
|
|
56
|
+
W?.(t), !t.defaultPrevented && (t.key === "ArrowUp" ? (t.preventDefault(), k(1)) : t.key === "ArrowDown" && (t.preventDefault(), k(-1)));
|
|
56
57
|
};
|
|
57
|
-
return /* @__PURE__ */
|
|
58
|
+
return /* @__PURE__ */ B(
|
|
58
59
|
"div",
|
|
59
60
|
{
|
|
60
|
-
className:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
className: m(
|
|
62
|
+
l.root,
|
|
63
|
+
l[R],
|
|
64
|
+
C && l.error,
|
|
65
|
+
i && l.disabled,
|
|
65
66
|
d?.root,
|
|
66
|
-
|
|
67
|
+
F
|
|
67
68
|
),
|
|
68
|
-
style:
|
|
69
|
-
"data-disabled":
|
|
69
|
+
style: K,
|
|
70
|
+
"data-disabled": i || void 0,
|
|
70
71
|
children: [
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ s(
|
|
72
73
|
"input",
|
|
73
74
|
{
|
|
74
|
-
ref:
|
|
75
|
+
ref: P,
|
|
75
76
|
type: "text",
|
|
76
77
|
inputMode: "decimal",
|
|
77
|
-
className:
|
|
78
|
-
value:
|
|
79
|
-
disabled:
|
|
80
|
-
|
|
78
|
+
className: m(l.input, d?.input),
|
|
79
|
+
value: g,
|
|
80
|
+
disabled: i,
|
|
81
|
+
readOnly: f,
|
|
82
|
+
"aria-invalid": C || void 0,
|
|
81
83
|
onChange: (t) => {
|
|
82
|
-
|
|
84
|
+
b.current = !1, p(t.target.value), v?.(x(t.target.value));
|
|
83
85
|
},
|
|
84
|
-
onKeyDown:
|
|
86
|
+
onKeyDown: V,
|
|
85
87
|
onFocus: (t) => {
|
|
86
|
-
|
|
88
|
+
w.current = !0, I.onFocus?.(t);
|
|
87
89
|
},
|
|
88
90
|
onBlur: (t) => {
|
|
89
|
-
|
|
90
|
-
const e = g(
|
|
91
|
-
|
|
92
|
-
const c = y(e);
|
|
93
|
-
c !== e ? w(c) : m(String(c));
|
|
94
|
-
}
|
|
95
|
-
F?.(t);
|
|
91
|
+
w.current = !1;
|
|
92
|
+
const e = x(g), o = e != null ? M(e) : null;
|
|
93
|
+
o !== e && y(o), c ? p(r != null ? String(r) : "") : o != null && o === e && p(String(o)), E?.(t);
|
|
96
94
|
},
|
|
97
|
-
...
|
|
95
|
+
...I
|
|
98
96
|
}
|
|
99
97
|
),
|
|
100
|
-
!
|
|
101
|
-
/* @__PURE__ */
|
|
98
|
+
!A && /* @__PURE__ */ B("div", { className: m(l.controls, d?.controls), children: [
|
|
99
|
+
/* @__PURE__ */ s(
|
|
102
100
|
"button",
|
|
103
101
|
{
|
|
104
102
|
type: "button",
|
|
105
103
|
tabIndex: -1,
|
|
106
|
-
className:
|
|
107
|
-
onClick: () =>
|
|
108
|
-
disabled:
|
|
104
|
+
className: m(l.increment, d?.increment),
|
|
105
|
+
onClick: () => k(1),
|
|
106
|
+
disabled: i || f || T,
|
|
109
107
|
"aria-label": "Increment",
|
|
110
|
-
children: /* @__PURE__ */
|
|
108
|
+
children: /* @__PURE__ */ s("svg", { viewBox: "0 0 10 6", "aria-hidden": "true", children: /* @__PURE__ */ s("path", { d: "M1 5l4-4 4 4", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
111
109
|
}
|
|
112
110
|
),
|
|
113
|
-
/* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ s(
|
|
114
112
|
"button",
|
|
115
113
|
{
|
|
116
114
|
type: "button",
|
|
117
115
|
tabIndex: -1,
|
|
118
|
-
className:
|
|
119
|
-
onClick: () =>
|
|
120
|
-
disabled:
|
|
116
|
+
className: m(l.decrement, d?.decrement),
|
|
117
|
+
onClick: () => k(-1),
|
|
118
|
+
disabled: i || f || U,
|
|
121
119
|
"aria-label": "Decrement",
|
|
122
|
-
children: /* @__PURE__ */
|
|
120
|
+
children: /* @__PURE__ */ s("svg", { viewBox: "0 0 10 6", "aria-hidden": "true", children: /* @__PURE__ */ s("path", { d: "M1 1l4 4 4-4", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
123
121
|
}
|
|
124
122
|
)
|
|
125
123
|
] })
|
|
@@ -128,7 +126,7 @@ const g = (n) => {
|
|
|
128
126
|
);
|
|
129
127
|
}
|
|
130
128
|
);
|
|
131
|
-
|
|
129
|
+
H.displayName = "NumberInput";
|
|
132
130
|
export {
|
|
133
|
-
|
|
131
|
+
H as NumberInput
|
|
134
132
|
};
|
|
@@ -86,6 +86,11 @@ export interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, 'onCh
|
|
|
86
86
|
* - **Searchable**: set `searchable`. Custom dropdown with text filter.
|
|
87
87
|
* - **Multi**: set `multiple`. Chip-based multi-select with text filter.
|
|
88
88
|
*
|
|
89
|
+
* In the searchable and multi modes `name` / `form` go to a hidden native
|
|
90
|
+
* `<select>` (so the value is submitted with `FormData`), `aria-*` / `data-*`
|
|
91
|
+
* go to the visible control, `required` becomes `aria-required`, and
|
|
92
|
+
* `onFocus` / `onBlur` fire when focus enters / leaves the whole widget.
|
|
93
|
+
*
|
|
89
94
|
* @example Native: <Select options={[{ value: 'a', label: 'A' }]} onValueChange={setValue} />
|
|
90
95
|
* @example Searchable: <Select searchable options={users} value={id} onValueChange={setId} />
|
|
91
96
|
* @example Multi: <Select multiple options={tags} value={selected} onValuesChange={setSelected} />
|