@memobit/libs 3.15.0 → 3.15.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/components/AnalogClock/AnalogClock2.js +156 -146
- package/dist/components/InputTime/InputTime.css +1 -1
- package/dist/components/InputTime/InputTime2.js +74 -53
- package/dist/helpers/VersionInfo.js +1 -1
- package/dist/version.js +1 -1
- package/dist/version.json +4 -4
- package/package.json +1 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import './AnalogClock.css';
|
|
2
2
|
/* empty css */
|
|
3
|
-
import { useMemo as b, useRef as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
var
|
|
3
|
+
import { useMemo as b, useRef as L, useState as nr } from "react";
|
|
4
|
+
import { Fragment as tr, jsx as l, jsxs as f } from "react/jsx-runtime";
|
|
5
|
+
var M = (n) => n.toString().padStart(2, "0"), x = (n, g, h) => {
|
|
6
6
|
const k = (h - 90) * Math.PI / 180;
|
|
7
7
|
return {
|
|
8
|
-
x:
|
|
9
|
-
y:
|
|
8
|
+
x: n + g * Math.cos(k),
|
|
9
|
+
y: n + g * Math.sin(k)
|
|
10
10
|
};
|
|
11
|
-
},
|
|
12
|
-
const [
|
|
13
|
-
const
|
|
11
|
+
}, er = (n) => n === 0 || n > 12, ir = ({ value: n, onChange: g, format: h = "24h", withSeconds: k = !1, minuteStep: w = 1, secondStep: D = 1, size: d = 232, disabled: u = !1, showHeader: q = !0, autoAdvance: E = !0, mode: C, onModeChange: X, className: Y = "" }) => {
|
|
12
|
+
const [G, J] = nr("hours"), I = L(null), _ = L(!1), s = C ?? G, p = n.hours >= 12, t = b(() => {
|
|
13
|
+
const r = d / 2, e = d * 0.078, c = r - e - d * 0.018, a = c - e * 1.85;
|
|
14
14
|
return {
|
|
15
|
-
center:
|
|
16
|
-
knobRadius:
|
|
15
|
+
center: r,
|
|
16
|
+
knobRadius: e,
|
|
17
17
|
outerRadius: c,
|
|
18
18
|
innerRadius: a,
|
|
19
19
|
ringThreshold: (c + a) / 2
|
|
20
20
|
};
|
|
21
|
-
}, [d]), y = (
|
|
22
|
-
|
|
23
|
-
},
|
|
21
|
+
}, [d]), y = (r) => {
|
|
22
|
+
C === void 0 && J(r), X?.(r);
|
|
23
|
+
}, N = () => {
|
|
24
24
|
if (E) {
|
|
25
25
|
if (s === "hours") {
|
|
26
26
|
y("minutes");
|
|
@@ -28,7 +28,7 @@ var p = (r) => r.toString().padStart(2, "0"), N = (r, g, h) => {
|
|
|
28
28
|
}
|
|
29
29
|
s === "minutes" && k && y("seconds");
|
|
30
30
|
}
|
|
31
|
-
},
|
|
31
|
+
}, O = b(() => {
|
|
32
32
|
if (s === "hours") {
|
|
33
33
|
if (h === "12h") return Array.from({ length: 12 }, (a, i) => {
|
|
34
34
|
const o = i + 1;
|
|
@@ -36,17 +36,17 @@ var p = (r) => r.toString().padStart(2, "0"), N = (r, g, h) => {
|
|
|
36
36
|
degrees: o * 30,
|
|
37
37
|
inner: !1,
|
|
38
38
|
label: `${o}`,
|
|
39
|
-
selected: (
|
|
39
|
+
selected: (n.hours % 12 || 12) === o,
|
|
40
40
|
value: o
|
|
41
41
|
};
|
|
42
42
|
});
|
|
43
|
-
const
|
|
43
|
+
const e = Array.from({ length: 12 }, (a, i) => {
|
|
44
44
|
const o = i + 1;
|
|
45
45
|
return {
|
|
46
46
|
degrees: o * 30,
|
|
47
47
|
inner: !1,
|
|
48
48
|
label: `${o}`,
|
|
49
|
-
selected:
|
|
49
|
+
selected: n.hours === o,
|
|
50
50
|
value: o
|
|
51
51
|
};
|
|
52
52
|
}), c = Array.from({ length: 12 }, (a, i) => {
|
|
@@ -54,240 +54,250 @@ var p = (r) => r.toString().padStart(2, "0"), N = (r, g, h) => {
|
|
|
54
54
|
return {
|
|
55
55
|
degrees: i * 30,
|
|
56
56
|
inner: !0,
|
|
57
|
-
label:
|
|
58
|
-
selected:
|
|
57
|
+
label: M(o),
|
|
58
|
+
selected: n.hours === o,
|
|
59
59
|
value: o
|
|
60
60
|
};
|
|
61
61
|
});
|
|
62
|
-
return [...
|
|
62
|
+
return [...e, ...c];
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
return Array.from({ length: 12 }, (
|
|
64
|
+
const r = s === "minutes" ? n.minutes : n.seconds;
|
|
65
|
+
return Array.from({ length: 12 }, (e, c) => {
|
|
66
66
|
const a = c * 5;
|
|
67
67
|
return {
|
|
68
68
|
degrees: a * 6,
|
|
69
69
|
inner: !1,
|
|
70
|
-
label:
|
|
71
|
-
selected:
|
|
70
|
+
label: M(a),
|
|
71
|
+
selected: r === a,
|
|
72
72
|
value: a
|
|
73
73
|
};
|
|
74
74
|
});
|
|
75
75
|
}, [
|
|
76
76
|
s,
|
|
77
77
|
h,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
]),
|
|
82
|
-
degrees:
|
|
83
|
-
radius: h === "24h" &&
|
|
78
|
+
n.hours,
|
|
79
|
+
n.minutes,
|
|
80
|
+
n.seconds
|
|
81
|
+
]), T = b(() => s === "hours" ? {
|
|
82
|
+
degrees: n.hours % 12 * 30,
|
|
83
|
+
radius: h === "24h" && er(n.hours) ? t.innerRadius : t.outerRadius
|
|
84
84
|
} : {
|
|
85
|
-
degrees: (s === "minutes" ?
|
|
86
|
-
radius:
|
|
85
|
+
degrees: (s === "minutes" ? n.minutes : n.seconds) * 6,
|
|
86
|
+
radius: t.outerRadius
|
|
87
87
|
}, [
|
|
88
88
|
s,
|
|
89
89
|
h,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
]),
|
|
90
|
+
t.innerRadius,
|
|
91
|
+
t.outerRadius,
|
|
92
|
+
n.hours,
|
|
93
|
+
n.minutes,
|
|
94
|
+
n.seconds
|
|
95
|
+
]), P = x(t.center, T.radius, T.degrees), Q = (r, e) => {
|
|
96
96
|
const c = I.current?.getBoundingClientRect();
|
|
97
97
|
if (!c || c.width === 0) return;
|
|
98
|
-
const a = d / c.width, i = (
|
|
99
|
-
let
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
98
|
+
const a = d / c.width, i = (r - c.left) * a - t.center, o = (e - c.top) * a - t.center, v = Math.sqrt(i * i + o * o);
|
|
99
|
+
let R = Math.atan2(i, -o) * 180 / Math.PI;
|
|
100
|
+
if (R < 0 && (R += 360), s === "hours") {
|
|
101
|
+
const m = Math.round(R / 30) % 12;
|
|
102
102
|
if (h === "12h") {
|
|
103
|
-
const
|
|
103
|
+
const K = m === 0 ? 12 : m;
|
|
104
104
|
return {
|
|
105
|
-
...
|
|
106
|
-
hours:
|
|
105
|
+
...n,
|
|
106
|
+
hours: p ? K % 12 + 12 : K % 12
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
const
|
|
109
|
+
const rr = v < t.ringThreshold ? m === 0 ? 0 : m + 12 : m === 0 ? 12 : m;
|
|
110
110
|
return {
|
|
111
|
-
...
|
|
112
|
-
hours:
|
|
111
|
+
...n,
|
|
112
|
+
hours: rr
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
const
|
|
115
|
+
const B = s === "minutes" ? w : D, F = Math.round(Math.round(R / 6) / B) * B % 60;
|
|
116
116
|
return s === "minutes" ? {
|
|
117
|
-
...
|
|
118
|
-
minutes:
|
|
117
|
+
...n,
|
|
118
|
+
minutes: F
|
|
119
119
|
} : {
|
|
120
|
-
...
|
|
121
|
-
seconds:
|
|
120
|
+
...n,
|
|
121
|
+
seconds: F
|
|
122
122
|
};
|
|
123
|
-
},
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
}, $ = (r) => {
|
|
124
|
+
const e = Q(r.clientX, r.clientY);
|
|
125
|
+
e && g(e);
|
|
126
|
+
}, S = (r) => {
|
|
127
|
+
if (!u) {
|
|
128
|
+
_.current = !0, $(r);
|
|
129
|
+
try {
|
|
130
|
+
r.currentTarget.setPointerCapture(r.pointerId);
|
|
131
|
+
} catch {
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, V = (r) => {
|
|
135
|
+
u || !_.current || $(r);
|
|
136
|
+
}, W = (r) => {
|
|
137
|
+
u || !_.current || (_.current = !1, r.currentTarget.hasPointerCapture(r.pointerId) && r.currentTarget.releasePointerCapture(r.pointerId), $(r), N());
|
|
138
|
+
}, j = () => {
|
|
139
|
+
u || !_.current || (_.current = !1, N());
|
|
140
|
+
}, H = (r) => {
|
|
133
141
|
if (s === "hours") {
|
|
134
142
|
if (h === "12h") {
|
|
135
|
-
const
|
|
143
|
+
const e = ((n.hours % 12 || 12) - 1 + r + 12) % 12 + 1;
|
|
136
144
|
g({
|
|
137
|
-
...
|
|
138
|
-
hours:
|
|
145
|
+
...n,
|
|
146
|
+
hours: p ? e % 12 + 12 : e % 12
|
|
139
147
|
});
|
|
140
148
|
return;
|
|
141
149
|
}
|
|
142
150
|
g({
|
|
143
|
-
...
|
|
144
|
-
hours: (
|
|
151
|
+
...n,
|
|
152
|
+
hours: (n.hours + r + 24) % 24
|
|
145
153
|
});
|
|
146
154
|
return;
|
|
147
155
|
}
|
|
148
156
|
if (s === "minutes") {
|
|
149
157
|
g({
|
|
150
|
-
...
|
|
151
|
-
minutes: (
|
|
158
|
+
...n,
|
|
159
|
+
minutes: (n.minutes + r * w + 60) % 60
|
|
152
160
|
});
|
|
153
161
|
return;
|
|
154
162
|
}
|
|
155
163
|
g({
|
|
156
|
-
...
|
|
157
|
-
seconds: (
|
|
164
|
+
...n,
|
|
165
|
+
seconds: (n.seconds + r * D + 60) % 60
|
|
158
166
|
});
|
|
159
|
-
},
|
|
160
|
-
if (!
|
|
161
|
-
if (
|
|
162
|
-
|
|
167
|
+
}, Z = (r) => {
|
|
168
|
+
if (!u) {
|
|
169
|
+
if (r.key === "ArrowUp" || r.key === "ArrowRight") {
|
|
170
|
+
r.preventDefault(), H(1);
|
|
163
171
|
return;
|
|
164
172
|
}
|
|
165
|
-
if (
|
|
166
|
-
|
|
173
|
+
if (r.key === "ArrowDown" || r.key === "ArrowLeft") {
|
|
174
|
+
r.preventDefault(), H(-1);
|
|
167
175
|
return;
|
|
168
176
|
}
|
|
169
|
-
(
|
|
177
|
+
(r.key === "Enter" || r.key === " ") && (r.preventDefault(), N());
|
|
170
178
|
}
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
...
|
|
174
|
-
hours:
|
|
179
|
+
}, U = (r) => {
|
|
180
|
+
u || r === p || g({
|
|
181
|
+
...n,
|
|
182
|
+
hours: r ? n.hours % 12 + 12 : n.hours % 12
|
|
175
183
|
});
|
|
176
|
-
},
|
|
177
|
-
return /* @__PURE__ */
|
|
178
|
-
className: `analog-clock${
|
|
179
|
-
children: [q && /* @__PURE__ */
|
|
184
|
+
}, A = (r) => `analog-clock__segment${s === r ? " analog-clock__segment--active" : ""}`, z = h === "12h" ? n.hours % 12 || 12 : n.hours;
|
|
185
|
+
return /* @__PURE__ */ f("div", {
|
|
186
|
+
className: `analog-clock${u ? " analog-clock--disabled" : ""} ${Y}`.trim(),
|
|
187
|
+
children: [q && /* @__PURE__ */ f("div", {
|
|
180
188
|
className: "analog-clock__header",
|
|
181
|
-
children: [/* @__PURE__ */
|
|
189
|
+
children: [/* @__PURE__ */ f("div", {
|
|
182
190
|
className: "analog-clock__readout",
|
|
183
191
|
children: [
|
|
184
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ l("button", {
|
|
185
193
|
type: "button",
|
|
186
|
-
className:
|
|
187
|
-
disabled:
|
|
194
|
+
className: A("hours"),
|
|
195
|
+
disabled: u,
|
|
188
196
|
onClick: () => y("hours"),
|
|
189
|
-
children:
|
|
197
|
+
children: M(z)
|
|
190
198
|
}),
|
|
191
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ l("span", {
|
|
192
200
|
className: "analog-clock__separator",
|
|
193
201
|
children: ":"
|
|
194
202
|
}),
|
|
195
|
-
/* @__PURE__ */
|
|
203
|
+
/* @__PURE__ */ l("button", {
|
|
196
204
|
type: "button",
|
|
197
|
-
className:
|
|
198
|
-
disabled:
|
|
205
|
+
className: A("minutes"),
|
|
206
|
+
disabled: u,
|
|
199
207
|
onClick: () => y("minutes"),
|
|
200
|
-
children:
|
|
208
|
+
children: M(n.minutes)
|
|
201
209
|
}),
|
|
202
|
-
k && /* @__PURE__ */
|
|
210
|
+
k && /* @__PURE__ */ f(tr, { children: [/* @__PURE__ */ l("span", {
|
|
203
211
|
className: "analog-clock__separator",
|
|
204
212
|
children: ":"
|
|
205
|
-
}), /* @__PURE__ */
|
|
213
|
+
}), /* @__PURE__ */ l("button", {
|
|
206
214
|
type: "button",
|
|
207
|
-
className:
|
|
208
|
-
disabled:
|
|
215
|
+
className: A("seconds"),
|
|
216
|
+
disabled: u,
|
|
209
217
|
onClick: () => y("seconds"),
|
|
210
|
-
children:
|
|
218
|
+
children: M(n.seconds)
|
|
211
219
|
})] })
|
|
212
220
|
]
|
|
213
|
-
}), h === "12h" && /* @__PURE__ */
|
|
221
|
+
}), h === "12h" && /* @__PURE__ */ f("div", {
|
|
214
222
|
className: "analog-clock__period",
|
|
215
|
-
children: [/* @__PURE__ */
|
|
223
|
+
children: [/* @__PURE__ */ l("button", {
|
|
216
224
|
type: "button",
|
|
217
|
-
className: `analog-clock__period-button${
|
|
218
|
-
disabled:
|
|
219
|
-
onClick: () =>
|
|
225
|
+
className: `analog-clock__period-button${p ? "" : " analog-clock__period-button--active"}`,
|
|
226
|
+
disabled: u,
|
|
227
|
+
onClick: () => U(!1),
|
|
220
228
|
children: "AM"
|
|
221
|
-
}), /* @__PURE__ */
|
|
229
|
+
}), /* @__PURE__ */ l("button", {
|
|
222
230
|
type: "button",
|
|
223
|
-
className: `analog-clock__period-button${
|
|
224
|
-
disabled:
|
|
225
|
-
onClick: () =>
|
|
231
|
+
className: `analog-clock__period-button${p ? " analog-clock__period-button--active" : ""}`,
|
|
232
|
+
disabled: u,
|
|
233
|
+
onClick: () => U(!0),
|
|
226
234
|
children: "PM"
|
|
227
235
|
})]
|
|
228
236
|
})]
|
|
229
|
-
}), /* @__PURE__ */
|
|
237
|
+
}), /* @__PURE__ */ f("svg", {
|
|
230
238
|
ref: I,
|
|
231
239
|
className: "analog-clock__dial",
|
|
232
240
|
width: d,
|
|
233
241
|
height: d,
|
|
234
242
|
viewBox: `0 0 ${d} ${d}`,
|
|
235
|
-
tabIndex:
|
|
236
|
-
onPointerDown:
|
|
237
|
-
onPointerMove:
|
|
238
|
-
onPointerUp:
|
|
239
|
-
|
|
243
|
+
tabIndex: u ? -1 : 0,
|
|
244
|
+
onPointerDown: S,
|
|
245
|
+
onPointerMove: V,
|
|
246
|
+
onPointerUp: W,
|
|
247
|
+
onPointerCancel: j,
|
|
248
|
+
onLostPointerCapture: j,
|
|
249
|
+
onKeyDown: Z,
|
|
240
250
|
children: [
|
|
241
|
-
/* @__PURE__ */
|
|
251
|
+
/* @__PURE__ */ l("circle", {
|
|
242
252
|
className: "analog-clock__face",
|
|
243
|
-
cx:
|
|
244
|
-
cy:
|
|
245
|
-
r:
|
|
253
|
+
cx: t.center,
|
|
254
|
+
cy: t.center,
|
|
255
|
+
r: t.center - 1
|
|
246
256
|
}),
|
|
247
|
-
s !== "hours" && Array.from({ length: 60 }, (
|
|
248
|
-
const c =
|
|
249
|
-
return /* @__PURE__ */
|
|
257
|
+
s !== "hours" && Array.from({ length: 60 }, (r, e) => {
|
|
258
|
+
const c = e % 5 === 0, a = x(t.center, t.outerRadius + t.knobRadius * 0.55, e * 6), i = x(t.center, t.outerRadius + t.knobRadius * (c ? 0.95 : 0.8), e * 6);
|
|
259
|
+
return /* @__PURE__ */ l("line", {
|
|
250
260
|
className: `analog-clock__tick${c ? " analog-clock__tick--major" : ""}`,
|
|
251
261
|
x1: a.x,
|
|
252
262
|
y1: a.y,
|
|
253
263
|
x2: i.x,
|
|
254
264
|
y2: i.y
|
|
255
|
-
}, `tick-${
|
|
265
|
+
}, `tick-${e}`);
|
|
256
266
|
}),
|
|
257
|
-
/* @__PURE__ */
|
|
267
|
+
/* @__PURE__ */ l("line", {
|
|
258
268
|
className: "analog-clock__hand",
|
|
259
|
-
x1:
|
|
260
|
-
y1:
|
|
261
|
-
x2:
|
|
262
|
-
y2:
|
|
269
|
+
x1: t.center,
|
|
270
|
+
y1: t.center,
|
|
271
|
+
x2: P.x,
|
|
272
|
+
y2: P.y
|
|
263
273
|
}),
|
|
264
|
-
/* @__PURE__ */
|
|
274
|
+
/* @__PURE__ */ l("circle", {
|
|
265
275
|
className: "analog-clock__knob",
|
|
266
|
-
cx:
|
|
267
|
-
cy:
|
|
268
|
-
r:
|
|
276
|
+
cx: P.x,
|
|
277
|
+
cy: P.y,
|
|
278
|
+
r: t.knobRadius
|
|
269
279
|
}),
|
|
270
|
-
/* @__PURE__ */
|
|
280
|
+
/* @__PURE__ */ l("circle", {
|
|
271
281
|
className: "analog-clock__pivot",
|
|
272
|
-
cx:
|
|
273
|
-
cy:
|
|
282
|
+
cx: t.center,
|
|
283
|
+
cy: t.center,
|
|
274
284
|
r: d * 0.017
|
|
275
285
|
}),
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
return /* @__PURE__ */
|
|
279
|
-
className: `analog-clock__number${
|
|
280
|
-
x:
|
|
281
|
-
y:
|
|
286
|
+
O.map((r) => {
|
|
287
|
+
const e = x(t.center, r.inner ? t.innerRadius : t.outerRadius, r.degrees);
|
|
288
|
+
return /* @__PURE__ */ l("text", {
|
|
289
|
+
className: `analog-clock__number${r.inner ? " analog-clock__number--inner" : ""}${r.selected ? " analog-clock__number--selected" : ""}`,
|
|
290
|
+
x: e.x,
|
|
291
|
+
y: e.y,
|
|
282
292
|
textAnchor: "middle",
|
|
283
293
|
dominantBaseline: "central",
|
|
284
|
-
children:
|
|
285
|
-
}, `${s}-${
|
|
294
|
+
children: r.label
|
|
295
|
+
}, `${s}-${r.inner ? "inner" : "outer"}-${r.value}`);
|
|
286
296
|
})
|
|
287
297
|
]
|
|
288
298
|
})]
|
|
289
299
|
});
|
|
290
300
|
};
|
|
291
301
|
export {
|
|
292
|
-
|
|
302
|
+
ir as AnalogClock
|
|
293
303
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.input-time-wrapper{gap:var(--spacing-8);flex-direction:column;display:flex}.input-time-wrapper .input-time-label{color:var(--form-control-label-color,var(--form-control-color));font-size:var(--form-control-label-font-size,var(--font-size-sm));font-weight:var(--form-control-label-font-weight,var(--font-weight-medium));letter-spacing:var(--form-control-label-letter-spacing,normal);text-transform:var(--form-control-label-text-transform,none)}.input-time-wrapper .input-time-label .input-time-required{color:var(--body-danger-color,#dc2626);margin-left:var(--spacing-2)}.input-time-wrapper .input-time{background-color:var(--form-control-background-color);color:var(--form-control-color);border:var(--spacing-1) solid var(--form-control-border-color);border-radius:var(--radius-sm);padding:var(--spacing-12);font-family:var(--form-control-font-family);font-size:var(--font-size-sm);line-height:var(--line-height-normal);box-sizing:border-box;width:100%}.input-time-wrapper .input-time:focus{background-color:var(--form-control-focus-background-color);border-color:var(--form-control-focus-border-color);color:var(--form-control-focus-color);box-shadow:0 0 0 var(--spacing-2) var(--box-shadow);outline:none}.input-time-wrapper .input-time::placeholder{color:var(--form-control-placeholder-color)}.input-time-wrapper .input-time
|
|
1
|
+
.input-time-wrapper{gap:var(--spacing-8);flex-direction:column;display:flex}.input-time-wrapper .input-time-label{color:var(--form-control-label-color,var(--form-control-color));font-size:var(--form-control-label-font-size,var(--font-size-sm));font-weight:var(--form-control-label-font-weight,var(--font-weight-medium));letter-spacing:var(--form-control-label-letter-spacing,normal);text-transform:var(--form-control-label-text-transform,none)}.input-time-wrapper .input-time-label .input-time-required{color:var(--body-danger-color,#dc2626);margin-left:var(--spacing-2)}.input-time-wrapper .input-time{background-color:var(--form-control-background-color);color:var(--form-control-color);border:var(--spacing-1) solid var(--form-control-border-color);border-radius:var(--radius-sm);padding:var(--spacing-12);font-family:var(--form-control-font-family);font-size:var(--font-size-sm);line-height:var(--line-height-normal);box-sizing:border-box;width:100%}.input-time-wrapper .input-time:focus{background-color:var(--form-control-focus-background-color);border-color:var(--form-control-focus-border-color);color:var(--form-control-focus-color);box-shadow:0 0 0 var(--spacing-2) var(--box-shadow);outline:none}.input-time-wrapper .input-time::placeholder{color:var(--form-control-placeholder-color)}.input-time-wrapper .input-time.input-time-error{background-color:var(--form-control-error-background-color);border-color:var(--form-control-error-border-color);color:var(--form-control-error-color)}.input-time-wrapper .input-time.input-time-error:focus{background-color:var(--form-control-error-background-color);border-color:var(--form-control-error-border-color);box-shadow:0 0 0 var(--spacing-2) var(--box-shadow)}.input-time-wrapper .input-time.input-time-success{background-color:var(--form-control-success-background-color);border-color:var(--form-control-success-border-color);color:var(--form-control-success-color)}.input-time-wrapper .input-time.input-time-success:focus{background-color:var(--form-control-success-background-color);border-color:var(--form-control-success-border-color);box-shadow:0 0 0 var(--spacing-2) var(--box-shadow)}.input-time-wrapper.input-time-highlighted .input-time{border-color:var(--form-control-focus-border-color)}.input-time-wrapper .input-time-error-message{font-size:var(--font-size-xs);color:var(--form-control-error-color)}.input-time-wrapper .input-time-success-message{font-size:var(--font-size-xs);color:var(--form-control-success-color)}.input-time-field{align-items:center;display:flex;position:relative}.input-time-field--with-clock .input-time{padding-right:var(--spacing-40)}.input-time-clock-button{border-radius:var(--radius-sm);color:var(--form-control-color);cursor:pointer;font-size:var(--font-size-md);padding:var(--spacing-4);right:var(--spacing-8);transition:background-color var(--transition-fast), color var(--transition-fast);background-color:#0000;border:none;justify-content:center;align-items:center;line-height:1;display:flex;position:absolute}.input-time-clock-button:hover:not(:disabled){background-color:var(--calendar-day-hover-background-color)}.input-time-clock-button--active{background-color:var(--calendar-day-selected-background-color);color:var(--calendar-day-selected-color)}.input-time-clock-button:disabled{cursor:not-allowed;opacity:.5}
|
|
@@ -1,86 +1,107 @@
|
|
|
1
1
|
import './InputTime.css';
|
|
2
|
-
import { Icon as
|
|
3
|
-
import { Popover as
|
|
4
|
-
import { TimePicker as
|
|
2
|
+
import { Icon as L } from "../Icon/Icon2.js";
|
|
3
|
+
import { Popover as M } from "../Popover/Popover2.js";
|
|
4
|
+
import { TimePicker as O } from "../TimePicker/TimePicker2.js";
|
|
5
5
|
/* empty css */
|
|
6
|
-
import { forwardRef as
|
|
7
|
-
import { jsx as
|
|
8
|
-
var
|
|
9
|
-
const
|
|
6
|
+
import { forwardRef as q, useRef as z, useState as R } from "react";
|
|
7
|
+
import { jsx as n, jsxs as h } from "react/jsx-runtime";
|
|
8
|
+
var c = (i) => i.toString().padStart(2, "0"), y = (i, s) => {
|
|
9
|
+
const t = i.trim().match(/^(\d{1,2}):?(\d{2})$/) ?? (s ? i.trim().match(/^(\d{1,2})()$/) : null);
|
|
10
|
+
if (!t) return;
|
|
11
|
+
const l = Number(t[1]), a = t[2] === "" ? 0 : Number(t[2]);
|
|
12
|
+
if (!(l > 23 || a > 59))
|
|
13
|
+
return `${c(l)}:${c(a)}`;
|
|
14
|
+
}, A = (i) => {
|
|
15
|
+
const [s, t] = (i ?? "").split(":").map(Number);
|
|
10
16
|
return {
|
|
11
|
-
hours: Number.isFinite(
|
|
17
|
+
hours: Number.isFinite(s) ? s : 0,
|
|
12
18
|
minutes: Number.isFinite(t) ? t : 0,
|
|
13
19
|
seconds: 0
|
|
14
20
|
};
|
|
15
|
-
},
|
|
16
|
-
const [
|
|
17
|
-
|
|
21
|
+
}, G = q(({ autoFocus: i, disabled: s, error: t, highlighted: l, id: a, label: v, max: N, min: b, minuteStep: F = 1, onBlur: P, onChange: o, onClick: S, onKeyDown: j, onKeyUp: w, readOnly: $ = !1, required: k = !1, success: u, value: g, withClock: p = !1 }, x) => {
|
|
22
|
+
const [d, I] = R(!1), [m, f] = R(void 0), C = z(null), T = (e) => (!b || e >= b) && (!N || e <= N), B = (e) => {
|
|
23
|
+
f(void 0), o?.(`${c(e.hours)}:${c(e.minutes)}`);
|
|
24
|
+
}, D = (e) => {
|
|
25
|
+
f(e);
|
|
26
|
+
const r = y(e, !1);
|
|
27
|
+
r && T(r) && o?.(r);
|
|
28
|
+
}, E = (e) => {
|
|
29
|
+
if (m !== void 0) {
|
|
30
|
+
if (m.trim() === "") o?.(void 0);
|
|
31
|
+
else {
|
|
32
|
+
const r = y(m, !0);
|
|
33
|
+
r && T(r) && o?.(r);
|
|
34
|
+
}
|
|
35
|
+
f(void 0);
|
|
36
|
+
}
|
|
37
|
+
P?.(e);
|
|
18
38
|
};
|
|
19
|
-
return /* @__PURE__ */
|
|
20
|
-
className: `input-time-wrapper${
|
|
39
|
+
return /* @__PURE__ */ h("div", {
|
|
40
|
+
className: `input-time-wrapper${l ? " input-time-highlighted" : ""}`,
|
|
21
41
|
children: [
|
|
22
|
-
|
|
23
|
-
htmlFor:
|
|
42
|
+
v && /* @__PURE__ */ h("label", {
|
|
43
|
+
htmlFor: a,
|
|
24
44
|
className: "input-time-label",
|
|
25
|
-
children: [
|
|
45
|
+
children: [v, k && /* @__PURE__ */ n("span", {
|
|
26
46
|
className: "input-time-required",
|
|
27
47
|
children: "*"
|
|
28
48
|
})]
|
|
29
49
|
}),
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
ref:
|
|
32
|
-
className: `input-time-field${
|
|
33
|
-
children: [/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ h("div", {
|
|
51
|
+
ref: C,
|
|
52
|
+
className: `input-time-field${p ? " input-time-field--with-clock" : ""}`,
|
|
53
|
+
children: [/* @__PURE__ */ n("input", {
|
|
34
54
|
autoFocus: i,
|
|
35
|
-
disabled:
|
|
36
|
-
type: "
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
disabled: s,
|
|
56
|
+
type: "text",
|
|
57
|
+
inputMode: "numeric",
|
|
58
|
+
maxLength: 5,
|
|
59
|
+
placeholder: "--:--",
|
|
60
|
+
className: `input-time${t ? " input-time-error" : ""}${u ? " input-time-success" : ""}`,
|
|
61
|
+
id: a,
|
|
62
|
+
ref: x,
|
|
63
|
+
value: m ?? g?.slice(0, 5) ?? "",
|
|
64
|
+
onBlur: E,
|
|
65
|
+
onChange: (e) => D(e.target.value),
|
|
66
|
+
onClick: S,
|
|
67
|
+
onKeyDown: j,
|
|
68
|
+
onKeyUp: w,
|
|
69
|
+
readOnly: $,
|
|
70
|
+
required: k
|
|
71
|
+
}), p && /* @__PURE__ */ n("button", {
|
|
72
|
+
className: `input-time-clock-button${d ? " input-time-clock-button--active" : ""}`,
|
|
73
|
+
disabled: s || $,
|
|
74
|
+
onClick: () => I(!d),
|
|
54
75
|
title: "Pick on a clock",
|
|
55
76
|
type: "button",
|
|
56
|
-
children: /* @__PURE__ */
|
|
77
|
+
children: /* @__PURE__ */ n(L, { name: "time" })
|
|
57
78
|
})]
|
|
58
79
|
}),
|
|
59
|
-
t && /* @__PURE__ */
|
|
80
|
+
t && /* @__PURE__ */ n("span", {
|
|
60
81
|
className: "input-time-error-message",
|
|
61
82
|
children: t
|
|
62
83
|
}),
|
|
63
|
-
|
|
84
|
+
u && /* @__PURE__ */ n("span", {
|
|
64
85
|
className: "input-time-success-message",
|
|
65
|
-
children:
|
|
86
|
+
children: u
|
|
66
87
|
}),
|
|
67
|
-
|
|
68
|
-
visible:
|
|
69
|
-
onClose: () =>
|
|
70
|
-
anchorEl:
|
|
71
|
-
children: /* @__PURE__ */
|
|
88
|
+
p && /* @__PURE__ */ n(M, {
|
|
89
|
+
visible: d,
|
|
90
|
+
onClose: () => I(!1),
|
|
91
|
+
anchorEl: C.current,
|
|
92
|
+
children: /* @__PURE__ */ n(O, {
|
|
72
93
|
collapsibleClock: !1,
|
|
73
94
|
label: "",
|
|
74
|
-
minuteStep:
|
|
75
|
-
onChange:
|
|
76
|
-
value:
|
|
95
|
+
minuteStep: F,
|
|
96
|
+
onChange: B,
|
|
97
|
+
value: A(g),
|
|
77
98
|
withClock: !0
|
|
78
99
|
})
|
|
79
100
|
})
|
|
80
101
|
]
|
|
81
102
|
});
|
|
82
103
|
});
|
|
83
|
-
|
|
104
|
+
G.displayName = "InputTime";
|
|
84
105
|
export {
|
|
85
|
-
|
|
106
|
+
G as InputTime
|
|
86
107
|
};
|
package/dist/version.js
CHANGED
package/dist/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memobit/libs",
|
|
3
|
-
"version": "3.15.
|
|
3
|
+
"version": "3.15.1",
|
|
4
4
|
"description": "React component library powering the Memobit apps — 100+ components, helpers and hooks. Icons ship as @memobit/icons and themes as @memobit/themes. TypeScript-first, ESM-only, React 19.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|