@dmsi/wedgekit-react 3.1.0 → 3.2.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/dist/components/CalendarIconButton.d.ts +10 -0
- package/dist/components/CalendarIconButton.d.ts.map +1 -0
- package/dist/components/CalendarIconButton.js +29 -0
- package/dist/components/DataGridCell.d.ts.map +1 -1
- package/dist/components/DataGridCell.js +124 -110
- package/dist/components/DateInput.d.ts.map +1 -1
- package/dist/components/DateInput.js +146 -135
- package/dist/components/DateRangeInput.d.ts.map +1 -1
- package/dist/components/DateRangeInput.js +268 -256
- package/package.json +1 -1
|
@@ -1,227 +1,238 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as D, useRef as k, useEffect as
|
|
4
|
-
import { createPortal as
|
|
5
|
-
import { clsx as
|
|
6
|
-
import { InputBase as
|
|
7
|
-
import { CalendarRange as
|
|
8
|
-
import {
|
|
9
|
-
import { findDocumentRoot as
|
|
10
|
-
import { useMatchesMobile as
|
|
11
|
-
import { isValidDate as
|
|
12
|
-
import { formatDateWithDashes as
|
|
13
|
-
import { marginTopUsingComponentGap as
|
|
14
|
-
function
|
|
15
|
-
id:
|
|
16
|
-
testid:
|
|
17
|
-
value:
|
|
18
|
-
onChange:
|
|
19
|
-
placeholder:
|
|
20
|
-
disabled:
|
|
21
|
-
readOnly:
|
|
22
|
-
label:
|
|
23
|
-
isDateAvailable:
|
|
2
|
+
import { jsxs as F, jsx as l, Fragment as te } from "react/jsx-runtime";
|
|
3
|
+
import { useState as D, useRef as k, useEffect as E, useLayoutEffect as oe } from "react";
|
|
4
|
+
import { createPortal as ne } from "react-dom";
|
|
5
|
+
import { clsx as re } from "../node_modules/clsx/dist/clsx.js";
|
|
6
|
+
import { InputBase as ae } from "./Input.js";
|
|
7
|
+
import { CalendarRange as A } from "./CalendarRange.js";
|
|
8
|
+
import { CalendarIconButton as se } from "./CalendarIconButton.js";
|
|
9
|
+
import { findDocumentRoot as ie } from "../utils.js";
|
|
10
|
+
import { useMatchesMobile as le } from "../hooks/useMatchesMedia.js";
|
|
11
|
+
import { isValidDate as y, calculateCursorPosition as ce } from "../utils/date.js";
|
|
12
|
+
import { formatDateWithDashes as ue, formatInputValueWithDashes as N, parseInputDateWithDashes as I } from "../utils/date-patch-dashes.js";
|
|
13
|
+
import { marginTopUsingComponentGap as fe } from "../classNames.js";
|
|
14
|
+
function Pe({
|
|
15
|
+
id: o,
|
|
16
|
+
testid: c,
|
|
17
|
+
value: j,
|
|
18
|
+
onChange: C,
|
|
19
|
+
placeholder: H = "MM/DD/YYYY",
|
|
20
|
+
disabled: V,
|
|
21
|
+
readOnly: d = !1,
|
|
22
|
+
label: K,
|
|
23
|
+
isDateAvailable: M,
|
|
24
24
|
disableManualInput: q,
|
|
25
|
-
theme:
|
|
25
|
+
theme: $,
|
|
26
26
|
...X
|
|
27
27
|
}) {
|
|
28
|
-
const [
|
|
28
|
+
const [g, p] = D(!1), [x, w] = D(""), [T, m] = D(!1), v = k(null), s = k(null), P = k(null), u = le(), [B, G] = D({
|
|
29
29
|
top: 0,
|
|
30
30
|
left: 0,
|
|
31
31
|
width: 0,
|
|
32
32
|
openAbove: !1
|
|
33
|
-
}),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, [
|
|
37
|
-
|
|
38
|
-
}, [
|
|
39
|
-
const
|
|
33
|
+
}), f = j;
|
|
34
|
+
E(() => {
|
|
35
|
+
T || w(z(f));
|
|
36
|
+
}, [f, T]), oe(() => {
|
|
37
|
+
g && h();
|
|
38
|
+
}, [g]);
|
|
39
|
+
const h = () => {
|
|
40
40
|
if (P.current) {
|
|
41
41
|
const e = P.current.getBoundingClientRect(), t = window.innerWidth, a = window.innerHeight, n = 340, i = 400;
|
|
42
|
-
let
|
|
43
|
-
|
|
44
|
-
const
|
|
42
|
+
let r = e.left;
|
|
43
|
+
r + n > t && (r = e.right - n, r < 0 && (r = Math.max(0, (t - n) / 2)));
|
|
44
|
+
const b = r + window.scrollX, W = a - e.bottom, ee = e.top, Y = W < i && ee > W;
|
|
45
45
|
let R;
|
|
46
|
-
Y ? R = e.top + window.scrollY - i - 4 : R = e.bottom + window.scrollY + 4, G({ top: R, left:
|
|
46
|
+
Y ? R = e.top + window.scrollY - i - 4 : R = e.bottom + window.scrollY + 4, G({ top: R, left: b, width: e.width, openAbove: Y });
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const e = new ResizeObserver(
|
|
52
|
-
return s.current && e.observe(s.current), window.addEventListener("scroll",
|
|
53
|
-
e.disconnect(), window.removeEventListener("scroll",
|
|
49
|
+
E(() => {
|
|
50
|
+
h();
|
|
51
|
+
const e = new ResizeObserver(h);
|
|
52
|
+
return s.current && e.observe(s.current), window.addEventListener("scroll", h), () => {
|
|
53
|
+
e.disconnect(), window.removeEventListener("scroll", h);
|
|
54
54
|
};
|
|
55
|
-
}, []),
|
|
55
|
+
}, []), E(() => {
|
|
56
56
|
const e = (t) => {
|
|
57
|
-
t.key === "Escape" &&
|
|
57
|
+
t.key === "Escape" && v.current && (p(!1), s.current?.blur());
|
|
58
58
|
};
|
|
59
59
|
return document.addEventListener("keydown", e), () => {
|
|
60
60
|
document.removeEventListener("keydown", e);
|
|
61
61
|
};
|
|
62
62
|
});
|
|
63
63
|
function L(e) {
|
|
64
|
-
|
|
64
|
+
C(e), p(!1), m(!1);
|
|
65
65
|
}
|
|
66
66
|
const S = () => {
|
|
67
|
-
|
|
67
|
+
d || p(!0);
|
|
68
|
+
}, U = () => {
|
|
69
|
+
S();
|
|
70
|
+
}, J = () => {
|
|
71
|
+
d || p((e) => !e);
|
|
72
|
+
}, Q = (e) => {
|
|
73
|
+
e.preventDefault(), e.stopPropagation(), e.currentTarget.blur();
|
|
74
|
+
}, Z = (e) => {
|
|
75
|
+
if (d) return;
|
|
76
|
+
const t = e.target.value, a = e.target.selectionStart || 0;
|
|
77
|
+
m(!0);
|
|
78
|
+
const n = N(t);
|
|
79
|
+
w(n), requestAnimationFrame(() => {
|
|
80
|
+
if (s.current) {
|
|
81
|
+
const r = ce(
|
|
82
|
+
t,
|
|
83
|
+
n,
|
|
84
|
+
a
|
|
85
|
+
);
|
|
86
|
+
s.current.setSelectionRange(r, r);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
const i = I(n);
|
|
90
|
+
i && y(i) && C(i);
|
|
91
|
+
}, _ = () => {
|
|
92
|
+
m(!1);
|
|
93
|
+
const e = I(x);
|
|
94
|
+
(!e || !y(e)) && w(z(f));
|
|
95
|
+
}, O = (e) => {
|
|
96
|
+
if (e.key === "Backspace") {
|
|
97
|
+
const t = e.target, a = t.selectionStart || 0, n = t.value;
|
|
98
|
+
if (a > 0 && n[a - 1] === "/") {
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
const i = n.slice(0, a - 2) + n.slice(a), r = N(i);
|
|
101
|
+
w(r), requestAnimationFrame(() => {
|
|
102
|
+
if (s.current) {
|
|
103
|
+
const b = Math.max(0, a - 2);
|
|
104
|
+
s.current.setSelectionRange(b, b);
|
|
105
|
+
}
|
|
106
|
+
}), m(!0);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (e.key === "Enter") {
|
|
111
|
+
const t = I(x);
|
|
112
|
+
t && y(t) && (C(t), p(!1), m(!1));
|
|
113
|
+
}
|
|
68
114
|
};
|
|
69
|
-
return /* @__PURE__ */
|
|
115
|
+
return /* @__PURE__ */ F("div", { className: "relative", children: [
|
|
70
116
|
/* @__PURE__ */ l(
|
|
71
|
-
|
|
117
|
+
ae,
|
|
72
118
|
{
|
|
73
|
-
id:
|
|
74
|
-
testid:
|
|
119
|
+
id: o,
|
|
120
|
+
testid: c,
|
|
75
121
|
ref: (e) => {
|
|
76
122
|
s.current = e;
|
|
77
123
|
},
|
|
78
124
|
...X,
|
|
79
125
|
wrapperRef: P,
|
|
80
126
|
value: x,
|
|
81
|
-
placeholder:
|
|
82
|
-
disabled:
|
|
83
|
-
readOnly:
|
|
84
|
-
after: /* @__PURE__ */ l(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (h) return;
|
|
93
|
-
const t = e.target.value, a = e.target.selectionStart || 0;
|
|
94
|
-
p(!0);
|
|
95
|
-
const n = A(t);
|
|
96
|
-
g(n), requestAnimationFrame(() => {
|
|
97
|
-
if (s.current) {
|
|
98
|
-
const o = oe(
|
|
99
|
-
t,
|
|
100
|
-
n,
|
|
101
|
-
a
|
|
102
|
-
);
|
|
103
|
-
s.current.setSelectionRange(o, o);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
const i = E(n);
|
|
107
|
-
i && b(i) && y(i);
|
|
108
|
-
},
|
|
109
|
-
onBlur: () => {
|
|
110
|
-
p(!1);
|
|
111
|
-
const e = E(x);
|
|
112
|
-
(!e || !b(e)) && g(N(u));
|
|
113
|
-
},
|
|
114
|
-
onKeyDown: (e) => {
|
|
115
|
-
if (e.key === "Backspace") {
|
|
116
|
-
const t = e.target, a = t.selectionStart || 0, n = t.value;
|
|
117
|
-
if (a > 0 && n[a - 1] === "/") {
|
|
118
|
-
e.preventDefault();
|
|
119
|
-
const i = n.slice(0, a - 2) + n.slice(a), o = A(i);
|
|
120
|
-
g(o), requestAnimationFrame(() => {
|
|
121
|
-
if (s.current) {
|
|
122
|
-
const v = Math.max(0, a - 2);
|
|
123
|
-
s.current.setSelectionRange(v, v);
|
|
124
|
-
}
|
|
125
|
-
}), p(!0);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (e.key === "Enter") {
|
|
130
|
-
const t = E(x);
|
|
131
|
-
t && b(t) && (y(t), f(!1), p(!1));
|
|
127
|
+
placeholder: H,
|
|
128
|
+
disabled: V,
|
|
129
|
+
readOnly: d,
|
|
130
|
+
after: /* @__PURE__ */ l(
|
|
131
|
+
se,
|
|
132
|
+
{
|
|
133
|
+
id: o ? `${o}-calendar-button` : void 0,
|
|
134
|
+
testid: c ? `${c}-calendar-button` : void 0,
|
|
135
|
+
disabled: V || d,
|
|
136
|
+
expanded: g,
|
|
137
|
+
onToggle: J
|
|
132
138
|
}
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
),
|
|
140
|
+
onFocus: q ? Q : S,
|
|
141
|
+
onClick: U,
|
|
142
|
+
onChange: Z,
|
|
143
|
+
onBlur: _,
|
|
144
|
+
onKeyDown: O,
|
|
145
|
+
label: K,
|
|
135
146
|
secondaryIconColor: !0
|
|
136
147
|
}
|
|
137
148
|
),
|
|
138
|
-
|
|
139
|
-
/* @__PURE__ */
|
|
149
|
+
g && !d && ne(
|
|
150
|
+
/* @__PURE__ */ F(te, { children: [
|
|
140
151
|
/* @__PURE__ */ l(
|
|
141
152
|
"div",
|
|
142
153
|
{
|
|
143
|
-
className:
|
|
154
|
+
className: re(
|
|
144
155
|
"fixed inset-0 z-30",
|
|
145
|
-
|
|
156
|
+
u && "overflow-y-auto bg-neutral-600/50"
|
|
146
157
|
),
|
|
147
|
-
"data-theme":
|
|
148
|
-
onClick: () =>
|
|
158
|
+
"data-theme": $,
|
|
159
|
+
onClick: () => p(!1),
|
|
149
160
|
onMouseDown: (e) => {
|
|
150
|
-
|
|
161
|
+
u || e.preventDefault();
|
|
151
162
|
},
|
|
152
163
|
onWheel: (e) => {
|
|
153
|
-
if (!
|
|
164
|
+
if (!u) {
|
|
154
165
|
const t = document.scrollingElement ?? document.documentElement;
|
|
155
166
|
t.scrollTop += e.deltaY, t.scrollLeft += e.deltaX;
|
|
156
167
|
}
|
|
157
168
|
},
|
|
158
169
|
onTouchMove: (e) => {
|
|
159
|
-
|
|
170
|
+
u || e.stopPropagation();
|
|
160
171
|
},
|
|
161
|
-
style: { touchAction:
|
|
172
|
+
style: { touchAction: u ? "auto" : "pan-y pan-x" },
|
|
162
173
|
"aria-hidden": "true",
|
|
163
|
-
children:
|
|
174
|
+
children: u && /* @__PURE__ */ l("div", { className: "min-h-full flex items-start justify-center py-4 px-2", children: /* @__PURE__ */ l(
|
|
164
175
|
"div",
|
|
165
176
|
{
|
|
166
177
|
ref: (e) => {
|
|
167
|
-
|
|
178
|
+
v.current = e;
|
|
168
179
|
},
|
|
169
180
|
className: "bg-background-primary-normal rounded-base shadow-4 max-w-full",
|
|
170
181
|
onClick: (e) => e.stopPropagation(),
|
|
171
182
|
children: /* @__PURE__ */ l(
|
|
172
|
-
|
|
183
|
+
A,
|
|
173
184
|
{
|
|
174
|
-
id:
|
|
175
|
-
testid:
|
|
176
|
-
from:
|
|
177
|
-
to:
|
|
185
|
+
id: o ? `${o}-calendar` : void 0,
|
|
186
|
+
testid: c ? `${c}-calendar` : void 0,
|
|
187
|
+
from: f,
|
|
188
|
+
to: f,
|
|
178
189
|
onChange: L,
|
|
179
190
|
cardStyle: !0,
|
|
180
191
|
mode: "single",
|
|
181
192
|
disableRange: !0,
|
|
182
|
-
isDateAvailable:
|
|
193
|
+
isDateAvailable: M
|
|
183
194
|
}
|
|
184
195
|
)
|
|
185
196
|
}
|
|
186
197
|
) })
|
|
187
198
|
}
|
|
188
199
|
),
|
|
189
|
-
!
|
|
200
|
+
!u && /* @__PURE__ */ l(
|
|
190
201
|
"div",
|
|
191
202
|
{
|
|
192
203
|
ref: (e) => {
|
|
193
|
-
|
|
204
|
+
v.current = e;
|
|
194
205
|
},
|
|
195
|
-
className: `absolute z-50 ${
|
|
196
|
-
"data-theme":
|
|
206
|
+
className: `absolute z-50 ${fe}`,
|
|
207
|
+
"data-theme": $,
|
|
197
208
|
style: {
|
|
198
|
-
top: `${
|
|
199
|
-
left: `${
|
|
209
|
+
top: `${B.top}px`,
|
|
210
|
+
left: `${B.left}px`
|
|
200
211
|
},
|
|
201
212
|
children: /* @__PURE__ */ l(
|
|
202
|
-
|
|
213
|
+
A,
|
|
203
214
|
{
|
|
204
|
-
id:
|
|
205
|
-
testid:
|
|
206
|
-
from:
|
|
207
|
-
to:
|
|
215
|
+
id: o ? `${o}-calendar` : void 0,
|
|
216
|
+
testid: c ? `${c}-calendar` : void 0,
|
|
217
|
+
from: f,
|
|
218
|
+
to: f,
|
|
208
219
|
onChange: L,
|
|
209
220
|
cardStyle: !0,
|
|
210
221
|
mode: "single",
|
|
211
222
|
disableRange: !0,
|
|
212
|
-
isDateAvailable:
|
|
223
|
+
isDateAvailable: M
|
|
213
224
|
}
|
|
214
225
|
)
|
|
215
226
|
}
|
|
216
227
|
)
|
|
217
228
|
] }),
|
|
218
|
-
|
|
229
|
+
ie(v.current)
|
|
219
230
|
)
|
|
220
231
|
] });
|
|
221
232
|
}
|
|
222
|
-
function
|
|
223
|
-
return !
|
|
233
|
+
function z(o) {
|
|
234
|
+
return !o || !y(o) ? "" : ue(o);
|
|
224
235
|
}
|
|
225
236
|
export {
|
|
226
|
-
|
|
237
|
+
Pe as DateInput
|
|
227
238
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangeInput.d.ts","sourceRoot":"","sources":["../../src/components/DateRangeInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAa,MAAM,SAAS,CAAC;AACpD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAcpE,KAAK,mBAAmB,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,GAAG;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,E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CAAC,CAAC;AAExE,wBAAgB,cAAc,CAAC,EAC7B,EAAE,EACF,MAAM,EACN,KAAK,EACL,QAAQ,EACR,WAAuC,EACvC,QAAQ,EACR,QAAgB,EAChB,MAAc,EACd,YAAoB,EACpB,KAAK,EACL,eAAe,EACf,mBAAmB,EACnB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,mBAAmB,2CA4lBrB"}
|