@mpen/react-basic-inputs 0.3.2 → 0.3.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/README.md +0 -0
- package/dist/react-basic-inputs.d.ts +1 -2
- package/dist/react-basic-inputs.js +133 -140
- package/dist/react-basic-inputs.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
File without changes
|
|
@@ -17,8 +17,7 @@ export declare type ActionButtonProps = RequiredKeys<ComponentPropsWithoutRef<'b
|
|
|
17
17
|
export declare function DatetimeLocalInput({ value, defaultValue, min, max, onChange, ...props }: DatetimeLocalInputProps): JSX_2.Element;
|
|
18
18
|
|
|
19
19
|
export declare type DatetimeLocalInputChangeEvent = {
|
|
20
|
-
value:
|
|
21
|
-
date: Date | null;
|
|
20
|
+
value: string;
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
export declare type DatetimeLocalInputProps = OverrideProps<'input', {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var q = (e, t, n) => t in e ?
|
|
1
|
+
var z = Object.defineProperty;
|
|
2
|
+
var q = (e, t, n) => t in e ? z(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var P = (e, t, n) => (q(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { useDebugValue as G, useRef as h, useInsertionEffect as Z, useEffect as
|
|
4
|
+
import { jsx as x, jsxs as L } from "react/jsx-runtime";
|
|
5
|
+
import { useDebugValue as G, useRef as h, useInsertionEffect as Z, useEffect as C, useMemo as K, useCallback as O, createElement as W, forwardRef as k, useState as D, useImperativeHandle as B, useLayoutEffect as J, useId as X } from "react";
|
|
6
6
|
const Q = Object.freeze(() => {
|
|
7
7
|
});
|
|
8
8
|
function ee(e) {
|
|
@@ -32,7 +32,7 @@ function ue() {
|
|
|
32
32
|
}
|
|
33
33
|
var R = function(e, t) {
|
|
34
34
|
var n = ue();
|
|
35
|
-
|
|
35
|
+
C(function() {
|
|
36
36
|
if (!n)
|
|
37
37
|
return e();
|
|
38
38
|
}, t);
|
|
@@ -55,7 +55,7 @@ function se(e, t) {
|
|
|
55
55
|
}
|
|
56
56
|
return String(t);
|
|
57
57
|
}
|
|
58
|
-
class
|
|
58
|
+
class H {
|
|
59
59
|
constructor() {
|
|
60
60
|
P(this, "_usedKeys", /* @__PURE__ */ new Map());
|
|
61
61
|
}
|
|
@@ -86,15 +86,15 @@ function fe({
|
|
|
86
86
|
placeholder: r,
|
|
87
87
|
...s
|
|
88
88
|
}) {
|
|
89
|
-
const l = t == null,
|
|
90
|
-
if (
|
|
89
|
+
const l = t == null, o = K(() => t != null && e.some((c) => c.value == t), [e, t]), i = K(() => t == null || !n ? null : n(t), [n, t]), a = K(() => {
|
|
90
|
+
if (o)
|
|
91
91
|
return e;
|
|
92
92
|
const c = [...e];
|
|
93
|
-
return l ? r != null && c.unshift({ text: r, hidden: !0, value: null, key: le }) :
|
|
94
|
-
}, [
|
|
95
|
-
const g = c.target.selectedIndex,
|
|
93
|
+
return l ? r != null && c.unshift({ text: r, hidden: !0, value: null, key: le }) : i && c.push(i), c;
|
|
94
|
+
}, [o, e, l, i, r]), d = te((c) => {
|
|
95
|
+
const g = c.target.selectedIndex, S = a[g];
|
|
96
96
|
u == null || u({
|
|
97
|
-
value:
|
|
97
|
+
value: S.value,
|
|
98
98
|
// option: opt,
|
|
99
99
|
// event: ev,
|
|
100
100
|
index: g,
|
|
@@ -102,18 +102,18 @@ function fe({
|
|
|
102
102
|
timeStamp: c.timeStamp,
|
|
103
103
|
target: c.target
|
|
104
104
|
});
|
|
105
|
-
}),
|
|
106
|
-
|
|
107
|
-
}, [
|
|
108
|
-
|
|
105
|
+
}), f = h(null), m = O(() => {
|
|
106
|
+
f.current && (f.current.selectedIndex < 0 || a[f.current.selectedIndex].value != t) && (f.current.selectedIndex = a.findIndex((c) => c.value == t));
|
|
107
|
+
}, [a, t]), N = (c) => {
|
|
108
|
+
f.current = c, m();
|
|
109
109
|
};
|
|
110
110
|
R(() => {
|
|
111
111
|
m();
|
|
112
112
|
}, [m]);
|
|
113
|
-
const
|
|
114
|
-
return /* @__PURE__ */
|
|
115
|
-
const { value:
|
|
116
|
-
return /* @__PURE__ */ W("option", { ...
|
|
113
|
+
const v = new H();
|
|
114
|
+
return /* @__PURE__ */ x("select", { ...s, onChange: d, ref: N, children: a.map((c, g) => {
|
|
115
|
+
const { value: S, text: b, uniqueKey: y, ...T } = c, V = v.fix(c, g);
|
|
116
|
+
return /* @__PURE__ */ W("option", { ...T, key: V, value: V }, c.text);
|
|
117
117
|
}) });
|
|
118
118
|
}
|
|
119
119
|
function ie(e) {
|
|
@@ -129,27 +129,27 @@ function oe(e) {
|
|
|
129
129
|
function de(e) {
|
|
130
130
|
return e ? e === "∞" || e === "+∞" ? Number.POSITIVE_INFINITY : e === "-∞" ? Number.NEGATIVE_INFINITY : Number.parseFloat(e) : Number.NaN;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function Y(e) {
|
|
133
133
|
return Number.isNaN(e) ? "" : e === Number.POSITIVE_INFINITY ? "∞" : e === Number.NEGATIVE_INFINITY ? "-∞" : oe(e);
|
|
134
134
|
}
|
|
135
135
|
function me(e) {
|
|
136
|
-
return e ?
|
|
136
|
+
return e ? Y(Number.parseFloat(e)) : "";
|
|
137
137
|
}
|
|
138
138
|
function I(e, t = 2) {
|
|
139
139
|
return String(e).padStart(t, "0");
|
|
140
140
|
}
|
|
141
|
-
const
|
|
142
|
-
const [
|
|
141
|
+
const j = k(function({ value: t = "", onPaste: n, onChange: u, onInput: r, onBlur: s, formatOnChange: l = ee, ...o }, i) {
|
|
142
|
+
const [a, d] = D(t), f = h(t), m = h(!1);
|
|
143
143
|
R(() => {
|
|
144
|
-
d(t), m.current = !1,
|
|
144
|
+
d(t), m.current = !1, f.current = t;
|
|
145
145
|
}, [t]);
|
|
146
146
|
const N = {
|
|
147
147
|
type: "text",
|
|
148
|
-
...
|
|
149
|
-
ref:
|
|
150
|
-
value:
|
|
151
|
-
onChange: (
|
|
152
|
-
d(
|
|
148
|
+
...o,
|
|
149
|
+
ref: i,
|
|
150
|
+
value: a,
|
|
151
|
+
onChange: (v) => {
|
|
152
|
+
d(v.target.value);
|
|
153
153
|
},
|
|
154
154
|
// TODO: fire a change event onPaste ?
|
|
155
155
|
// formatOnPaste?
|
|
@@ -167,81 +167,81 @@ const z = k(function({ value: t = "", onPaste: n, onChange: u, onInput: r, onBlu
|
|
|
167
167
|
// // ev.preventDefault()
|
|
168
168
|
// // setCurrentValue(formatOnChange(ev.clipboardData.getData('text/plain')))
|
|
169
169
|
// },
|
|
170
|
-
onInput: (
|
|
171
|
-
m.current = !0, r == null || r(
|
|
170
|
+
onInput: (v) => {
|
|
171
|
+
m.current = !0, r == null || r(v);
|
|
172
172
|
},
|
|
173
|
-
onBlur: (
|
|
174
|
-
const c = l(
|
|
175
|
-
m.current && (c !==
|
|
173
|
+
onBlur: (v) => {
|
|
174
|
+
const c = l(a);
|
|
175
|
+
m.current && (c !== f.current && (u == null || u({
|
|
176
176
|
type: "change",
|
|
177
177
|
value: c,
|
|
178
|
-
timeStamp:
|
|
179
|
-
target:
|
|
180
|
-
}),
|
|
178
|
+
timeStamp: v.timeStamp,
|
|
179
|
+
target: v.target
|
|
180
|
+
}), f.current = c), c !== v.target.value && d(c)), s == null || s(v);
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
-
return /* @__PURE__ */
|
|
183
|
+
return /* @__PURE__ */ x("input", { ...N });
|
|
184
184
|
});
|
|
185
|
-
function
|
|
186
|
-
return /* @__PURE__ */
|
|
185
|
+
function Ee({ formatOnChange: e = ie, ...t }) {
|
|
186
|
+
return /* @__PURE__ */ x(j, { formatOnChange: e, ...t, type: "text" });
|
|
187
187
|
}
|
|
188
|
-
const
|
|
188
|
+
const De = k(function({
|
|
189
189
|
onInput: t,
|
|
190
190
|
style: n,
|
|
191
191
|
initialHeight: u = "auto",
|
|
192
192
|
...r
|
|
193
193
|
}, s) {
|
|
194
|
-
const l = h(null), [
|
|
195
|
-
const
|
|
196
|
-
if (!
|
|
194
|
+
const l = h(null), [o, i] = D(u), a = O(() => {
|
|
195
|
+
const f = l.current;
|
|
196
|
+
if (!f)
|
|
197
197
|
return;
|
|
198
|
-
|
|
199
|
-
const m = `${
|
|
200
|
-
|
|
198
|
+
f.style.height = u;
|
|
199
|
+
const m = `${f.scrollHeight}px`;
|
|
200
|
+
i(m), f.style.height = m;
|
|
201
201
|
}, [u]);
|
|
202
202
|
B(s, () => ({
|
|
203
203
|
element: l.current,
|
|
204
|
-
adjustHeight:
|
|
205
|
-
}), [
|
|
206
|
-
const d = _((
|
|
207
|
-
|
|
204
|
+
adjustHeight: a
|
|
205
|
+
}), [a]);
|
|
206
|
+
const d = _((f) => {
|
|
207
|
+
a(), t == null || t(f);
|
|
208
208
|
});
|
|
209
209
|
return J(() => {
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
if (!
|
|
210
|
+
a();
|
|
211
|
+
const f = l.current;
|
|
212
|
+
if (!f)
|
|
213
213
|
return;
|
|
214
214
|
const m = new ResizeObserver((N) => {
|
|
215
|
-
|
|
215
|
+
a();
|
|
216
216
|
});
|
|
217
|
-
return m.observe(
|
|
218
|
-
m.unobserve(
|
|
217
|
+
return m.observe(f), () => {
|
|
218
|
+
m.unobserve(f);
|
|
219
219
|
};
|
|
220
|
-
}, [
|
|
220
|
+
}, [a]), /* @__PURE__ */ x("textarea", { ...r, style: {
|
|
221
221
|
overflow: "hidden",
|
|
222
222
|
// these 2 styles aren't needed if the caller sets them in CSS.
|
|
223
223
|
resize: "none",
|
|
224
224
|
...n,
|
|
225
|
-
height:
|
|
225
|
+
height: o
|
|
226
226
|
}, onInput: d, ref: l });
|
|
227
227
|
});
|
|
228
|
-
function
|
|
229
|
-
const t = X(), n = e.name ?? t, u = e.valueEquals ?? Object.is, r = e.options ?? [], s = new
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
value:
|
|
233
|
-
index:
|
|
228
|
+
function _e(e) {
|
|
229
|
+
const t = X(), n = e.name ?? t, u = e.valueEquals ?? Object.is, r = e.options ?? [], s = new H(), l = _((o) => {
|
|
230
|
+
const i = Number(o.target.value), a = r[i];
|
|
231
|
+
a != null && e.onChange != null && e.onChange({
|
|
232
|
+
value: a.value,
|
|
233
|
+
index: i,
|
|
234
234
|
type: "change",
|
|
235
|
-
timeStamp:
|
|
236
|
-
target:
|
|
235
|
+
timeStamp: o.timeStamp,
|
|
236
|
+
target: o.target
|
|
237
237
|
});
|
|
238
238
|
});
|
|
239
|
-
return /* @__PURE__ */
|
|
240
|
-
const { value:
|
|
241
|
-
return e.value !== void 0 && (g.checked = u(
|
|
242
|
-
/* @__PURE__ */
|
|
243
|
-
/* @__PURE__ */
|
|
244
|
-
] }) },
|
|
239
|
+
return /* @__PURE__ */ x("ul", { className: e.className, children: r.map((o, i) => {
|
|
240
|
+
const { value: a, text: d, key: f, itemClassName: m, labelClassName: N, inputClassName: v, textClassName: c, ...g } = o, S = s.fix(o, i);
|
|
241
|
+
return e.value !== void 0 && (g.checked = u(a, e.value)), /* @__PURE__ */ x("li", { className: m, "aria-disabled": g.disabled, children: /* @__PURE__ */ L("label", { className: N, children: [
|
|
242
|
+
/* @__PURE__ */ x("input", { ...g, className: v, value: i, onChange: l, name: n, type: "radio" }),
|
|
243
|
+
/* @__PURE__ */ x("span", { className: c, children: d })
|
|
244
|
+
] }) }, S);
|
|
245
245
|
}) });
|
|
246
246
|
}
|
|
247
247
|
function U() {
|
|
@@ -250,7 +250,7 @@ function U() {
|
|
|
250
250
|
function A(e) {
|
|
251
251
|
e.current != null && (clearTimeout(e.current), e.current = null);
|
|
252
252
|
}
|
|
253
|
-
const
|
|
253
|
+
const Me = ({
|
|
254
254
|
value: e,
|
|
255
255
|
onChange: t,
|
|
256
256
|
debounce: n = 500,
|
|
@@ -263,24 +263,24 @@ const De = ({
|
|
|
263
263
|
const l = () => {
|
|
264
264
|
r.current != null && r.current.value !== e && (t == null || t({ value: r.current.value }));
|
|
265
265
|
};
|
|
266
|
-
return /* @__PURE__ */
|
|
266
|
+
return /* @__PURE__ */ x("input", { ...u, ref: r, defaultValue: e, onInput: () => {
|
|
267
267
|
A(s), s.current = setTimeout(l, n);
|
|
268
268
|
}, onBlur: () => {
|
|
269
269
|
A(s), l();
|
|
270
270
|
} });
|
|
271
271
|
};
|
|
272
|
-
function
|
|
272
|
+
function pe({ onClick: e, ...t }) {
|
|
273
273
|
return t.onClick = (n) => {
|
|
274
274
|
n.preventDefault(), e == null || e(n);
|
|
275
|
-
}, /* @__PURE__ */
|
|
275
|
+
}, /* @__PURE__ */ x("button", { type: "button", ...t });
|
|
276
276
|
}
|
|
277
277
|
function E(e, t) {
|
|
278
278
|
const n = e instanceof Date ? e : new Date(e);
|
|
279
279
|
let u = `${n.getFullYear()}-${I(n.getMonth() + 1)}-${I(n.getDate())}T${I(n.getHours())}:${I(n.getMinutes())}`;
|
|
280
280
|
const r = (t == null ? void 0 : t.milliseconds) || (t == null ? void 0 : t.milliseconds) == null && n.getMilliseconds() !== 0;
|
|
281
|
-
return ((t == null ? void 0 : t.seconds) || (t == null ? void 0 : t.seconds) == null && (n.getSeconds() !== 0 || r)) && (u += `:${I(n.getSeconds())}`, r && (u += `.${I(n.getMilliseconds(), 3)}`)), t != null && t.offset && (u +=
|
|
281
|
+
return ((t == null ? void 0 : t.seconds) || (t == null ? void 0 : t.seconds) == null && (n.getSeconds() !== 0 || r)) && (u += `:${I(n.getSeconds())}`, r && (u += `.${I(n.getMilliseconds(), 3)}`)), t != null && t.offset && (u += F(-n.getTimezoneOffset())), u;
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function F(e) {
|
|
284
284
|
if (e == null)
|
|
285
285
|
return "";
|
|
286
286
|
if (e === 0)
|
|
@@ -300,26 +300,13 @@ function M(e) {
|
|
|
300
300
|
}
|
|
301
301
|
return Ne(e) ? "" : E(e, ve);
|
|
302
302
|
}
|
|
303
|
-
const
|
|
304
|
-
function
|
|
305
|
-
return e !== void 0 && (s.value = e === null ? "" : E(e,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
// isoString: toIsoDateString(date,{offset:true}),
|
|
311
|
-
// isoString: date.toISOString(),
|
|
312
|
-
value: a.valueOf(),
|
|
313
|
-
date: a
|
|
314
|
-
});
|
|
315
|
-
} else
|
|
316
|
-
r({
|
|
317
|
-
// isoStringWithOffset: null,
|
|
318
|
-
// isoString: null,
|
|
319
|
-
value: null,
|
|
320
|
-
date: null
|
|
321
|
-
});
|
|
322
|
-
}), /* @__PURE__ */ v("input", { type: "datetime-local", ...s });
|
|
303
|
+
const p = { offset: !1 };
|
|
304
|
+
function we({ value: e, defaultValue: t, min: n, max: u, onChange: r, ...s }) {
|
|
305
|
+
return e !== void 0 && (s.value = e === null ? "" : E(e, p)), t != null && (s.defaultValue = E(t, p)), n != null && (s.min = E(n, p)), u != null && (s.max = E(u, p)), r != null && (s.onChange = (l) => {
|
|
306
|
+
r({
|
|
307
|
+
value: l.currentTarget.value
|
|
308
|
+
});
|
|
309
|
+
}), /* @__PURE__ */ x("input", { type: "datetime-local", ...s });
|
|
323
310
|
}
|
|
324
311
|
function ge(e) {
|
|
325
312
|
const t = h(e);
|
|
@@ -327,9 +314,9 @@ function ge(e) {
|
|
|
327
314
|
}
|
|
328
315
|
function be(e, t) {
|
|
329
316
|
const n = h(e), u = ge(t);
|
|
330
|
-
return
|
|
317
|
+
return C(() => {
|
|
331
318
|
Object.is(n.current, e) || (u.current(), n.current = e);
|
|
332
|
-
}, [u, e]),
|
|
319
|
+
}, [u, e]), O((r) => {
|
|
333
320
|
n.current = r;
|
|
334
321
|
}, []);
|
|
335
322
|
}
|
|
@@ -411,7 +398,7 @@ const he = [
|
|
|
411
398
|
// Kiribati
|
|
412
399
|
{ value: 14 * 60, text: "+14:00" }
|
|
413
400
|
];
|
|
414
|
-
function
|
|
401
|
+
function w(e) {
|
|
415
402
|
if (typeof e != "string" || e === "")
|
|
416
403
|
return null;
|
|
417
404
|
const t = e.match(/([+-])(\d{2}):(\d{2})|Z$/);
|
|
@@ -422,10 +409,16 @@ function $(e) {
|
|
|
422
409
|
const [, n, u, r] = t, s = Number(u) * 60 + Number(r);
|
|
423
410
|
return n === "+" ? s : -s;
|
|
424
411
|
}
|
|
425
|
-
function
|
|
412
|
+
function $(e) {
|
|
426
413
|
return e === "" ? null : -new Date(e).getTimezoneOffset();
|
|
427
414
|
}
|
|
428
|
-
function
|
|
415
|
+
function Ie(e, t, n) {
|
|
416
|
+
return e ? t : $(n);
|
|
417
|
+
}
|
|
418
|
+
function ye(e, t, n) {
|
|
419
|
+
return F(Ie(e, t, n));
|
|
420
|
+
}
|
|
421
|
+
function $e({
|
|
429
422
|
value: e,
|
|
430
423
|
defaultValue: t,
|
|
431
424
|
min: n,
|
|
@@ -433,36 +426,36 @@ function we({
|
|
|
433
426
|
onChange: r,
|
|
434
427
|
...s
|
|
435
428
|
}) {
|
|
436
|
-
const [l,
|
|
437
|
-
|
|
438
|
-
}), N =
|
|
429
|
+
const [l, o] = D(() => w(e ?? t) !== null), [i, a] = D(() => w(e ?? t)), [d, f] = D(() => M(e ?? t)), m = be(e, () => {
|
|
430
|
+
o(w(e) !== null), a(w(e)), f(M(e));
|
|
431
|
+
}), N = O((b) => {
|
|
439
432
|
m(b), r == null || r({
|
|
440
433
|
value: b
|
|
441
434
|
});
|
|
442
435
|
}, [r, m]);
|
|
443
436
|
n != null && (s.min = M(n)), u != null && (s.max = M(u));
|
|
444
|
-
const
|
|
437
|
+
const v = l ? i : $(d), c = O(
|
|
445
438
|
(b) => {
|
|
446
|
-
const
|
|
447
|
-
|
|
439
|
+
const y = b.currentTarget.value;
|
|
440
|
+
f(y), N(y + ye(l, i, y));
|
|
448
441
|
},
|
|
449
|
-
[N,
|
|
450
|
-
), g =
|
|
442
|
+
[N, l, i]
|
|
443
|
+
), g = O(
|
|
451
444
|
(b) => {
|
|
452
|
-
|
|
445
|
+
a(b.value), N(d + F(b.value));
|
|
453
446
|
},
|
|
454
447
|
[N, d]
|
|
455
|
-
),
|
|
448
|
+
), S = O(
|
|
456
449
|
(b) => {
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
let
|
|
460
|
-
|
|
450
|
+
const y = b.currentTarget.checked;
|
|
451
|
+
o(y);
|
|
452
|
+
let T;
|
|
453
|
+
y ? d && i === null ? (T = $(d), a(T)) : T = i : T = $(d), N(d + F(T));
|
|
461
454
|
},
|
|
462
|
-
[
|
|
455
|
+
[i, d, N]
|
|
463
456
|
);
|
|
464
457
|
return /* @__PURE__ */ L("span", { children: [
|
|
465
|
-
/* @__PURE__ */
|
|
458
|
+
/* @__PURE__ */ x(
|
|
466
459
|
"input",
|
|
467
460
|
{
|
|
468
461
|
type: "datetime-local",
|
|
@@ -471,19 +464,19 @@ function we({
|
|
|
471
464
|
onChange: c
|
|
472
465
|
}
|
|
473
466
|
),
|
|
474
|
-
/* @__PURE__ */
|
|
467
|
+
/* @__PURE__ */ x(
|
|
475
468
|
"input",
|
|
476
469
|
{
|
|
477
470
|
type: "checkbox",
|
|
478
471
|
title: l ? "Use UTC offset from this device" : "Enable UTC offset selection",
|
|
479
472
|
checked: l,
|
|
480
|
-
onChange:
|
|
473
|
+
onChange: S
|
|
481
474
|
}
|
|
482
475
|
),
|
|
483
|
-
/* @__PURE__ */
|
|
476
|
+
/* @__PURE__ */ x(
|
|
484
477
|
fe,
|
|
485
478
|
{
|
|
486
|
-
value:
|
|
479
|
+
value: v,
|
|
487
480
|
onChange: g,
|
|
488
481
|
disabled: !l,
|
|
489
482
|
options: he
|
|
@@ -491,29 +484,29 @@ function we({
|
|
|
491
484
|
)
|
|
492
485
|
] });
|
|
493
486
|
}
|
|
494
|
-
const
|
|
495
|
-
const
|
|
487
|
+
const Fe = k(function({ placeholder: t, formatOnChange: n = me, onChange: u, value: r, ...s }, l) {
|
|
488
|
+
const o = {
|
|
496
489
|
inputMode: "decimal",
|
|
497
490
|
...s,
|
|
498
491
|
formatOnChange: n,
|
|
499
492
|
type: "number"
|
|
500
493
|
};
|
|
501
|
-
return r !== void 0 && (
|
|
494
|
+
return r !== void 0 && (o.value = Y(r)), t != null && (o.placeholder = String(t)), u != null && (o.onChange = (i) => {
|
|
502
495
|
u({
|
|
503
|
-
...
|
|
504
|
-
value: de(
|
|
496
|
+
...i,
|
|
497
|
+
value: de(i.value)
|
|
505
498
|
});
|
|
506
|
-
}), /* @__PURE__ */
|
|
499
|
+
}), /* @__PURE__ */ x(j, { ...o, ref: l });
|
|
507
500
|
});
|
|
508
501
|
export {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
502
|
+
pe as ActionButton,
|
|
503
|
+
we as DatetimeLocalInput,
|
|
504
|
+
$e as DatetimeOffsetInput,
|
|
505
|
+
Me as DebouncedInput,
|
|
506
|
+
j as Input,
|
|
507
|
+
Fe as NumberInput,
|
|
508
|
+
_e as RadioMenu,
|
|
516
509
|
fe as Select,
|
|
517
|
-
|
|
518
|
-
|
|
510
|
+
De as TextArea,
|
|
511
|
+
Ee as TextInput
|
|
519
512
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(x,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],f):(x=typeof globalThis<"u"?globalThis:x||self,f(x["@mpen/react-basic-inputs"]={},x.jsxRuntime,x.React))})(this,function(x,f,r){"use strict";var ve=Object.defineProperty;var be=(x,f,r)=>f in x?ve(x,f,{enumerable:!0,configurable:!0,writable:!0,value:r}):x[f]=r;var L=(x,f,r)=>(be(x,typeof f!="symbol"?f+"":f,r),r);const U=Object.freeze(()=>{});function q(e){return e}let E;typeof window<"u"?E=e=>{r.useDebugValue(e);const t=r.useRef(Y);r.useInsertionEffect(()=>{t.current=e},[e]);const n=r.useRef(null);return n.current||(n.current=function(){return t.current.apply(this,arguments)}),n.current}:E=U;function H(e){return E(e)}function Y(){throw new Error("INVALID_USE_EVENT_INVOCATION: the callback from useEvent cannot be invoked before the component has mounted.")}function z(){var e=r.useRef(!0);return e.current?(e.current=!1,!0):e.current}var p=function(e,t){var n=z();r.useEffect(function(){if(!n)return e()},t)};function G(e,...t){return typeof e=="function"?e(...t):e}function Z(e,t){if(e.uniqueKey!=null)return G(e.uniqueKey,e,t);if(typeof e.value=="string")return e.value;if(typeof e.value=="number")return String(e.value);try{const n=JSON.stringify(e.value);if(n!==void 0)return n}catch{}return String(t)}class K{constructor(){L(this,"_usedKeys",new Map)}fix(t,n){let u=Z(t,n);for(;;){let s=this._usedKeys.get(u);if(s===void 0){this._usedKeys.set(u,1);break}this._usedKeys.set(u,++s),u=`${u}(${s})`}return u}}const B=e=>({value:e,text:String(e),disabled:!0,key:J}),W="3c9369b7-0a5e-46ea-93c2-e8b9fec67fdb",J="1a53f789-77f5-4ce6-a829-b00e563f1ee8";function C({options:e,value:t,invalidValueOption:n=B,onChange:u,placeholder:s,...l}){const a=t==null,i=r.useMemo(()=>t!=null&&e.some(c=>c.value==t),[e,t]),m=r.useMemo(()=>t==null||!n?null:n(t),[n,t]),o=r.useMemo(()=>{if(i)return e;const c=[...e];return a?s!=null&&c.unshift({text:s,hidden:!0,value:null,key:W}):m&&c.push(m),c},[i,e,a,m,s]),v=H(c=>{const g=c.target.selectedIndex,S=o[g];u==null||u({value:S.value,index:g,type:"change",timeStamp:c.timeStamp,target:c.target})}),d=r.useRef(null),b=r.useCallback(()=>{d.current&&(d.current.selectedIndex<0||o[d.current.selectedIndex].value!=t)&&(d.current.selectedIndex=o.findIndex(c=>c.value==t))},[o,t]),I=c=>{d.current=c,b()};p(()=>{b()},[b]);const N=new K;return f.jsx("select",{...l,onChange:v,ref:I,children:o.map((c,g)=>{const{value:S,text:h,uniqueKey:O,...T}=c,P=N.fix(c,g);return r.createElement("option",{...T,key:P,value:P},c.text)})})}function X(e){return e?String(e).replace(/\s+/gu," ").trim():""}function Q(e){try{return e.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})}catch{return e.toFixed(14).replace(/\.?0+$/,"")}}function R(e){return e?e==="∞"||e==="+∞"?Number.POSITIVE_INFINITY:e==="-∞"?Number.NEGATIVE_INFINITY:Number.parseFloat(e):Number.NaN}function V(e){return Number.isNaN(e)?"":e===Number.POSITIVE_INFINITY?"∞":e===Number.NEGATIVE_INFINITY?"-∞":Q(e)}function ee(e){return e?V(Number.parseFloat(e)):""}function y(e,t=2){return String(e).padStart(t,"0")}const $=r.forwardRef(function({value:t="",onPaste:n,onChange:u,onInput:s,onBlur:l,formatOnChange:a=q,...i},m){const[o,v]=r.useState(t),d=r.useRef(t),b=r.useRef(!1);p(()=>{v(t),b.current=!1,d.current=t},[t]);const I={type:"text",...i,ref:m,value:o,onChange:N=>{v(N.target.value)},onInput:N=>{b.current=!0,s==null||s(N)},onBlur:N=>{const c=a(o);b.current&&(c!==d.current&&(u==null||u({type:"change",value:c,timeStamp:N.timeStamp,target:N.target}),d.current=c),c!==N.target.value&&v(c)),l==null||l(N)}};return f.jsx("input",{...I})});function te({formatOnChange:e=X,...t}){return f.jsx($,{formatOnChange:e,...t,type:"text"})}const ne=r.forwardRef(function({onInput:t,style:n,initialHeight:u="auto",...s},l){const a=r.useRef(null),[i,m]=r.useState(u),o=r.useCallback(()=>{const d=a.current;if(!d)return;d.style.height=u;const b=`${d.scrollHeight}px`;m(b),d.style.height=b},[u]);r.useImperativeHandle(l,()=>({element:a.current,adjustHeight:o}),[o]);const v=E(d=>{o(),t==null||t(d)});return r.useLayoutEffect(()=>{o();const d=a.current;if(!d)return;const b=new ResizeObserver(I=>{o()});return b.observe(d),()=>{b.unobserve(d)}},[o]),f.jsx("textarea",{...s,style:{overflow:"hidden",resize:"none",...n,height:i},onInput:v,ref:a})});function ue(e){const t=r.useId(),n=e.name??t,u=e.valueEquals??Object.is,s=e.options??[],l=new K,a=E(i=>{const m=Number(i.target.value),o=s[m];o!=null&&e.onChange!=null&&e.onChange({value:o.value,index:m,type:"change",timeStamp:i.timeStamp,target:i.target})});return f.jsx("ul",{className:e.className,children:s.map((i,m)=>{const{value:o,text:v,key:d,itemClassName:b,labelClassName:I,inputClassName:N,textClassName:c,...g}=i,S=l.fix(i,m);return e.value!==void 0&&(g.checked=u(o,e.value)),f.jsx("li",{className:b,"aria-disabled":g.disabled,children:f.jsxs("label",{className:I,children:[f.jsx("input",{...g,className:N,value:m,onChange:a,name:n,type:"radio"}),f.jsx("span",{className:c,children:v})]})},S)})})}function j(){return r.useRef(null)}function A(e){e.current!=null&&(clearTimeout(e.current),e.current=null)}const re=({value:e,onChange:t,debounce:n=500,...u})=>{const s=j(),l=j();p(()=>{A(l),s.current!=null&&(s.current.value=e)},[e]);const a=()=>{s.current!=null&&s.current.value!==e&&(t==null||t({value:s.current.value}))};return f.jsx("input",{...u,ref:s,defaultValue:e,onInput:()=>{A(l),l.current=setTimeout(a,n)},onBlur:()=>{A(l),a()}})};function se({onClick:e,...t}){return t.onClick=n=>{n.preventDefault(),e==null||e(n)},f.jsx("button",{type:"button",...t})}function D(e,t){const n=e instanceof Date?e:new Date(e);let u=`${n.getFullYear()}-${y(n.getMonth()+1)}-${y(n.getDate())}T${y(n.getHours())}:${y(n.getMinutes())}`;const s=(t==null?void 0:t.milliseconds)||(t==null?void 0:t.milliseconds)==null&&n.getMilliseconds()!==0;return((t==null?void 0:t.seconds)||(t==null?void 0:t.seconds)==null&&(n.getSeconds()!==0||s))&&(u+=`:${y(n.getSeconds())}`,s&&(u+=`.${y(n.getMilliseconds(),3)}`)),t!=null&&t.offset&&(u+=M(-n.getTimezoneOffset())),u}function M(e){if(e==null)return"";if(e===0)return"Z";const t=e>0?"+":"-",n=Math.floor(Math.abs(e)/60),u=Math.abs(e)%60;return`${t}${y(n)}:${y(u)}`}const le=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?)(Z|[+-]\d{2}:\d{2})?$/,fe={offset:!1,seconds:!1,milliseconds:!1};function ce(e){return e==null||Number.isNaN(e)||e===""||Number.isNaN(+new Date(e))}function _(e){if(typeof e=="string"){const t=e.match(le);if(t)return t[1]}return ce(e)?"":D(e,fe)}const w={offset:!1};function ae({value:e,defaultValue:t,min:n,max:u,onChange:s,...l}){return e!==void 0&&(l.value=e===null?"":D(e,w)),t!=null&&(l.defaultValue=D(t,w)),n!=null&&(l.min=D(n,w)),u!=null&&(l.max=D(u,w)),s!=null&&(l.onChange=a=>{if(a.currentTarget.value.length){const i=new Date(a.currentTarget.valueAsNumber);s({value:i.valueOf(),date:i})}else s({value:null,date:null})}),f.jsx("input",{type:"datetime-local",...l})}function ie(e){const t=r.useRef(e);return t.current=e,t}function oe(e,t){const n=r.useRef(e),u=ie(t);return r.useEffect(()=>{Object.is(n.current,e)||(u.current(),n.current=e)},[u,e]),r.useCallback(s=>{n.current=s},[])}const de=[{value:-12*60,text:"-12:00"},{value:-11*60,text:"-11:00"},{value:-10*60,text:"-10:00"},{value:-9.5*60,text:"-09:30"},{value:-9*60,text:"-09:00"},{value:-8*60,text:"-08:00"},{value:-7*60,text:"-07:00"},{value:-6*60,text:"-06:00"},{value:-5*60,text:"-05:00"},{value:-4*60,text:"-04:00"},{value:-3.5*60,text:"-03:30"},{value:-3*60,text:"-03:00"},{value:-2*60,text:"-02:00"},{value:-1*60,text:"-01:00"},{value:0,text:"±00:00"},{value:1*60,text:"+01:00"},{value:2*60,text:"+02:00"},{value:3*60,text:"+03:00"},{value:3.5*60,text:"+03:30"},{value:4*60,text:"+04:00"},{value:4.5*60,text:"+04:30"},{value:5*60,text:"+05:00"},{value:5.5*60,text:"+05:30"},{value:5.75*60,text:"+05:45"},{value:6*60,text:"+06:00"},{value:6.5*60,text:"+06:30"},{value:7*60,text:"+07:00"},{value:8*60,text:"+08:00"},{value:8.75*60,text:"+08:45"},{value:9*60,text:"+09:00"},{value:9.5*60,text:"+09:30"},{value:10*60,text:"+10:00"},{value:10.5*60,text:"+10:30"},{value:11*60,text:"+11:00"},{value:12*60,text:"+12:00"},{value:12.75*60,text:"+12:45"},{value:13*60,text:"+13:00"},{value:14*60,text:"+14:00"}];function k(e){if(typeof e!="string"||e==="")return null;const t=e.match(/([+-])(\d{2}):(\d{2})|Z$/);if(!t)return null;if(t[0]==="Z")return 0;const[,n,u,s]=t,l=Number(u)*60+Number(s);return n==="+"?l:-l}function F(e){return e===""?null:-new Date(e).getTimezoneOffset()}function xe({value:e,defaultValue:t,min:n,max:u,onChange:s,...l}){const[a,i]=r.useState(()=>k(e??t)!==null),[m,o]=r.useState(()=>k(e??t)),[v,d]=r.useState(()=>_(e??t)),b=oe(e,()=>{i(k(e)!==null),o(k(e)),d(_(e))}),I=r.useCallback(h=>{b(h),s==null||s({value:h})},[s,b]);n!=null&&(l.min=_(n)),u!=null&&(l.max=_(u));const N=a?m:F(v),c=r.useCallback(h=>{const O=h.currentTarget.value;d(O),I(O+M(N))},[I,N]),g=r.useCallback(h=>{o(h.value),I(v+M(h.value))},[I,v]),S=r.useCallback(h=>{const O=h.currentTarget.checked;i(O);let T;O?v&&m===null?(T=F(v),o(T)):T=m:T=F(v),I(v+M(T))},[m,v,I]);return f.jsxs("span",{children:[f.jsx("input",{type:"datetime-local",...l,value:v,onChange:c}),f.jsx("input",{type:"checkbox",title:a?"Use UTC offset from this device":"Enable UTC offset selection",checked:a,onChange:S}),f.jsx(C,{value:N,onChange:g,disabled:!a,options:de})]})}const me=r.forwardRef(function({placeholder:t,formatOnChange:n=ee,onChange:u,value:s,...l},a){const i={inputMode:"decimal",...l,formatOnChange:n,type:"number"};return s!==void 0&&(i.value=V(s)),t!=null&&(i.placeholder=String(t)),u!=null&&(i.onChange=m=>{u({...m,value:R(m.value)})}),f.jsx($,{...i,ref:a})});x.ActionButton=se,x.DatetimeLocalInput=ae,x.DatetimeOffsetInput=xe,x.DebouncedInput=re,x.Input=$,x.NumberInput=me,x.RadioMenu=ue,x.Select=C,x.TextArea=ne,x.TextInput=te,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(d,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],f):(d=typeof globalThis<"u"?globalThis:d||self,f(d["@mpen/react-basic-inputs"]={},d.jsxRuntime,d.React))})(this,function(d,f,r){"use strict";var Ne=Object.defineProperty;var Ie=(d,f,r)=>f in d?Ne(d,f,{enumerable:!0,configurable:!0,writable:!0,value:r}):d[f]=r;var L=(d,f,r)=>(Ie(d,typeof f!="symbol"?f+"":f,r),r);const U=Object.freeze(()=>{});function q(e){return e}let E;typeof window<"u"?E=e=>{r.useDebugValue(e);const t=r.useRef(Y);r.useInsertionEffect(()=>{t.current=e},[e]);const n=r.useRef(null);return n.current||(n.current=function(){return t.current.apply(this,arguments)}),n.current}:E=U;function H(e){return E(e)}function Y(){throw new Error("INVALID_USE_EVENT_INVOCATION: the callback from useEvent cannot be invoked before the component has mounted.")}function z(){var e=r.useRef(!0);return e.current?(e.current=!1,!0):e.current}var $=function(e,t){var n=z();r.useEffect(function(){if(!n)return e()},t)};function G(e,...t){return typeof e=="function"?e(...t):e}function Z(e,t){if(e.uniqueKey!=null)return G(e.uniqueKey,e,t);if(typeof e.value=="string")return e.value;if(typeof e.value=="number")return String(e.value);try{const n=JSON.stringify(e.value);if(n!==void 0)return n}catch{}return String(t)}class K{constructor(){L(this,"_usedKeys",new Map)}fix(t,n){let u=Z(t,n);for(;;){let s=this._usedKeys.get(u);if(s===void 0){this._usedKeys.set(u,1);break}this._usedKeys.set(u,++s),u=`${u}(${s})`}return u}}const B=e=>({value:e,text:String(e),disabled:!0,key:J}),W="3c9369b7-0a5e-46ea-93c2-e8b9fec67fdb",J="1a53f789-77f5-4ce6-a829-b00e563f1ee8";function C({options:e,value:t,invalidValueOption:n=B,onChange:u,placeholder:s,...l}){const i=t==null,m=r.useMemo(()=>t!=null&&e.some(c=>c.value==t),[e,t]),x=r.useMemo(()=>t==null||!n?null:n(t),[n,t]),a=r.useMemo(()=>{if(m)return e;const c=[...e];return i?s!=null&&c.unshift({text:s,hidden:!0,value:null,key:W}):x&&c.push(x),c},[m,e,i,x,s]),v=H(c=>{const g=c.target.selectedIndex,O=a[g];u==null||u({value:O.value,index:g,type:"change",timeStamp:c.timeStamp,target:c.target})}),o=r.useRef(null),b=r.useCallback(()=>{o.current&&(o.current.selectedIndex<0||a[o.current.selectedIndex].value!=t)&&(o.current.selectedIndex=a.findIndex(c=>c.value==t))},[a,t]),I=c=>{o.current=c,b()};$(()=>{b()},[b]);const N=new K;return f.jsx("select",{...l,onChange:v,ref:I,children:a.map((c,g)=>{const{value:O,text:h,uniqueKey:T,...S}=c,P=N.fix(c,g);return r.createElement("option",{...S,key:P,value:P},c.text)})})}function X(e){return e?String(e).replace(/\s+/gu," ").trim():""}function Q(e){try{return e.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})}catch{return e.toFixed(14).replace(/\.?0+$/,"")}}function R(e){return e?e==="∞"||e==="+∞"?Number.POSITIVE_INFINITY:e==="-∞"?Number.NEGATIVE_INFINITY:Number.parseFloat(e):Number.NaN}function V(e){return Number.isNaN(e)?"":e===Number.POSITIVE_INFINITY?"∞":e===Number.NEGATIVE_INFINITY?"-∞":Q(e)}function ee(e){return e?V(Number.parseFloat(e)):""}function y(e,t=2){return String(e).padStart(t,"0")}const A=r.forwardRef(function({value:t="",onPaste:n,onChange:u,onInput:s,onBlur:l,formatOnChange:i=q,...m},x){const[a,v]=r.useState(t),o=r.useRef(t),b=r.useRef(!1);$(()=>{v(t),b.current=!1,o.current=t},[t]);const I={type:"text",...m,ref:x,value:a,onChange:N=>{v(N.target.value)},onInput:N=>{b.current=!0,s==null||s(N)},onBlur:N=>{const c=i(a);b.current&&(c!==o.current&&(u==null||u({type:"change",value:c,timeStamp:N.timeStamp,target:N.target}),o.current=c),c!==N.target.value&&v(c)),l==null||l(N)}};return f.jsx("input",{...I})});function te({formatOnChange:e=X,...t}){return f.jsx(A,{formatOnChange:e,...t,type:"text"})}const ne=r.forwardRef(function({onInput:t,style:n,initialHeight:u="auto",...s},l){const i=r.useRef(null),[m,x]=r.useState(u),a=r.useCallback(()=>{const o=i.current;if(!o)return;o.style.height=u;const b=`${o.scrollHeight}px`;x(b),o.style.height=b},[u]);r.useImperativeHandle(l,()=>({element:i.current,adjustHeight:a}),[a]);const v=E(o=>{a(),t==null||t(o)});return r.useLayoutEffect(()=>{a();const o=i.current;if(!o)return;const b=new ResizeObserver(I=>{a()});return b.observe(o),()=>{b.unobserve(o)}},[a]),f.jsx("textarea",{...s,style:{overflow:"hidden",resize:"none",...n,height:m},onInput:v,ref:i})});function ue(e){const t=r.useId(),n=e.name??t,u=e.valueEquals??Object.is,s=e.options??[],l=new K,i=E(m=>{const x=Number(m.target.value),a=s[x];a!=null&&e.onChange!=null&&e.onChange({value:a.value,index:x,type:"change",timeStamp:m.timeStamp,target:m.target})});return f.jsx("ul",{className:e.className,children:s.map((m,x)=>{const{value:a,text:v,key:o,itemClassName:b,labelClassName:I,inputClassName:N,textClassName:c,...g}=m,O=l.fix(m,x);return e.value!==void 0&&(g.checked=u(a,e.value)),f.jsx("li",{className:b,"aria-disabled":g.disabled,children:f.jsxs("label",{className:I,children:[f.jsx("input",{...g,className:N,value:x,onChange:i,name:n,type:"radio"}),f.jsx("span",{className:c,children:v})]})},O)})})}function j(){return r.useRef(null)}function F(e){e.current!=null&&(clearTimeout(e.current),e.current=null)}const re=({value:e,onChange:t,debounce:n=500,...u})=>{const s=j(),l=j();$(()=>{F(l),s.current!=null&&(s.current.value=e)},[e]);const i=()=>{s.current!=null&&s.current.value!==e&&(t==null||t({value:s.current.value}))};return f.jsx("input",{...u,ref:s,defaultValue:e,onInput:()=>{F(l),l.current=setTimeout(i,n)},onBlur:()=>{F(l),i()}})};function se({onClick:e,...t}){return t.onClick=n=>{n.preventDefault(),e==null||e(n)},f.jsx("button",{type:"button",...t})}function D(e,t){const n=e instanceof Date?e:new Date(e);let u=`${n.getFullYear()}-${y(n.getMonth()+1)}-${y(n.getDate())}T${y(n.getHours())}:${y(n.getMinutes())}`;const s=(t==null?void 0:t.milliseconds)||(t==null?void 0:t.milliseconds)==null&&n.getMilliseconds()!==0;return((t==null?void 0:t.seconds)||(t==null?void 0:t.seconds)==null&&(n.getSeconds()!==0||s))&&(u+=`:${y(n.getSeconds())}`,s&&(u+=`.${y(n.getMilliseconds(),3)}`)),t!=null&&t.offset&&(u+=M(-n.getTimezoneOffset())),u}function M(e){if(e==null)return"";if(e===0)return"Z";const t=e>0?"+":"-",n=Math.floor(Math.abs(e)/60),u=Math.abs(e)%60;return`${t}${y(n)}:${y(u)}`}const le=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?)(Z|[+-]\d{2}:\d{2})?$/,fe={offset:!1,seconds:!1,milliseconds:!1};function ce(e){return e==null||Number.isNaN(e)||e===""||Number.isNaN(+new Date(e))}function _(e){if(typeof e=="string"){const t=e.match(le);if(t)return t[1]}return ce(e)?"":D(e,fe)}const p={offset:!1};function ie({value:e,defaultValue:t,min:n,max:u,onChange:s,...l}){return e!==void 0&&(l.value=e===null?"":D(e,p)),t!=null&&(l.defaultValue=D(t,p)),n!=null&&(l.min=D(n,p)),u!=null&&(l.max=D(u,p)),s!=null&&(l.onChange=i=>{s({value:i.currentTarget.value})}),f.jsx("input",{type:"datetime-local",...l})}function ae(e){const t=r.useRef(e);return t.current=e,t}function oe(e,t){const n=r.useRef(e),u=ae(t);return r.useEffect(()=>{Object.is(n.current,e)||(u.current(),n.current=e)},[u,e]),r.useCallback(s=>{n.current=s},[])}const de=[{value:-12*60,text:"-12:00"},{value:-11*60,text:"-11:00"},{value:-10*60,text:"-10:00"},{value:-9.5*60,text:"-09:30"},{value:-9*60,text:"-09:00"},{value:-8*60,text:"-08:00"},{value:-7*60,text:"-07:00"},{value:-6*60,text:"-06:00"},{value:-5*60,text:"-05:00"},{value:-4*60,text:"-04:00"},{value:-3.5*60,text:"-03:30"},{value:-3*60,text:"-03:00"},{value:-2*60,text:"-02:00"},{value:-1*60,text:"-01:00"},{value:0,text:"±00:00"},{value:1*60,text:"+01:00"},{value:2*60,text:"+02:00"},{value:3*60,text:"+03:00"},{value:3.5*60,text:"+03:30"},{value:4*60,text:"+04:00"},{value:4.5*60,text:"+04:30"},{value:5*60,text:"+05:00"},{value:5.5*60,text:"+05:30"},{value:5.75*60,text:"+05:45"},{value:6*60,text:"+06:00"},{value:6.5*60,text:"+06:30"},{value:7*60,text:"+07:00"},{value:8*60,text:"+08:00"},{value:8.75*60,text:"+08:45"},{value:9*60,text:"+09:00"},{value:9.5*60,text:"+09:30"},{value:10*60,text:"+10:00"},{value:10.5*60,text:"+10:30"},{value:11*60,text:"+11:00"},{value:12*60,text:"+12:00"},{value:12.75*60,text:"+12:45"},{value:13*60,text:"+13:00"},{value:14*60,text:"+14:00"}];function w(e){if(typeof e!="string"||e==="")return null;const t=e.match(/([+-])(\d{2}):(\d{2})|Z$/);if(!t)return null;if(t[0]==="Z")return 0;const[,n,u,s]=t,l=Number(u)*60+Number(s);return n==="+"?l:-l}function k(e){return e===""?null:-new Date(e).getTimezoneOffset()}function xe(e,t,n){return e?t:k(n)}function me(e,t,n){return M(xe(e,t,n))}function ve({value:e,defaultValue:t,min:n,max:u,onChange:s,...l}){const[i,m]=r.useState(()=>w(e??t)!==null),[x,a]=r.useState(()=>w(e??t)),[v,o]=r.useState(()=>_(e??t)),b=oe(e,()=>{m(w(e)!==null),a(w(e)),o(_(e))}),I=r.useCallback(h=>{b(h),s==null||s({value:h})},[s,b]);n!=null&&(l.min=_(n)),u!=null&&(l.max=_(u));const N=i?x:k(v),c=r.useCallback(h=>{const T=h.currentTarget.value;o(T),I(T+me(i,x,T))},[I,i,x]),g=r.useCallback(h=>{a(h.value),I(v+M(h.value))},[I,v]),O=r.useCallback(h=>{const T=h.currentTarget.checked;m(T);let S;T?v&&x===null?(S=k(v),a(S)):S=x:S=k(v),I(v+M(S))},[x,v,I]);return f.jsxs("span",{children:[f.jsx("input",{type:"datetime-local",...l,value:v,onChange:c}),f.jsx("input",{type:"checkbox",title:i?"Use UTC offset from this device":"Enable UTC offset selection",checked:i,onChange:O}),f.jsx(C,{value:N,onChange:g,disabled:!i,options:de})]})}const be=r.forwardRef(function({placeholder:t,formatOnChange:n=ee,onChange:u,value:s,...l},i){const m={inputMode:"decimal",...l,formatOnChange:n,type:"number"};return s!==void 0&&(m.value=V(s)),t!=null&&(m.placeholder=String(t)),u!=null&&(m.onChange=x=>{u({...x,value:R(x.value)})}),f.jsx(A,{...m,ref:i})});d.ActionButton=se,d.DatetimeLocalInput=ie,d.DatetimeOffsetInput=ve,d.DebouncedInput=re,d.Input=A,d.NumberInput=be,d.RadioMenu=ue,d.Select=C,d.TextArea=ne,d.TextInput=te,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|