@companix/uikit 0.1.23 → 0.1.24
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/DrawerMobile/index.d.ts +2 -1
- package/dist/bundle.es23.js +47 -47
- package/dist/bundle.es67.js +1 -1
- package/dist/bundle.es72.js +2 -2
- package/dist/bundle.es81.js +74 -13
- package/dist/bundle.es82.js +45 -71
- package/dist/bundle.es83.js +13 -48
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { default as React } from 'react';
|
|
|
2
2
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
3
3
|
export interface MobileDrawerProps {
|
|
4
4
|
open: boolean;
|
|
5
|
+
className?: string;
|
|
5
6
|
onOpenChange: (value: boolean) => void;
|
|
6
7
|
children: React.ReactNode;
|
|
7
8
|
defaultOpen?: boolean;
|
|
@@ -11,7 +12,7 @@ export interface MobileDrawerProps {
|
|
|
11
12
|
}
|
|
12
13
|
export declare const Handle: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
13
14
|
export declare const MobileDrawer: {
|
|
14
|
-
({ children, size, ...props }: MobileDrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
({ children, className, size, ...props }: MobileDrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
15
16
|
Close: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
16
17
|
Handle: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
17
18
|
};
|
package/dist/bundle.es23.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s, jsxs as q } from "react/jsx-runtime";
|
|
2
2
|
import t from "react";
|
|
3
3
|
import G from "classnames";
|
|
4
|
-
import * as
|
|
4
|
+
import * as E from "@radix-ui/react-dialog";
|
|
5
5
|
import { VisuallyHidden as K } from "@radix-ui/react-visually-hidden";
|
|
6
6
|
import { customCSS as oe } from "@companix/utils-browser";
|
|
7
7
|
import { RemoveListener as se } from "./bundle.es58.js";
|
|
@@ -10,17 +10,17 @@ import { set as R, reset as ae, composeRefs as Q, isInput as ce, isMobileFirefox
|
|
|
10
10
|
import { usePreventScroll as de } from "./bundle.es70.js";
|
|
11
11
|
import { DRAG_CLASS as j, VELOCITY_THRESHOLD as ge, CLOSE_THRESHOLD as me, SCROLL_LOCK_TIMEOUT as pe, TRANSITIONS as Y, WINDOW_TOP_OFFSET as he } from "./bundle.es71.js";
|
|
12
12
|
const we = (m) => {
|
|
13
|
-
const { open: p, onOpenChange: l, onClosed:
|
|
13
|
+
const { open: p, onOpenChange: l, onClosed: D, children: y, defaultOpen: S = !1, disableEsc: f } = m, [x, M] = t.useState(!1), [T, P] = t.useState(!1), [_, A] = t.useState(!1), v = t.useRef(null), H = t.useRef(null), I = t.useRef(null), L = t.useRef(null), o = t.useRef(null), d = t.useRef(!1), h = t.useRef(0), b = t.useRef(!1), N = t.useRef(!S), e = t.useRef(null), O = t.useRef(e.current?.getBoundingClientRect().height || 0), g = t.useRef(0), C = t.useRef(0), w = p ?? !1, V = t.useCallback(
|
|
14
14
|
(r) => {
|
|
15
15
|
l(r);
|
|
16
16
|
},
|
|
17
17
|
[l]
|
|
18
18
|
);
|
|
19
19
|
de({
|
|
20
|
-
isDisabled: !w ||
|
|
20
|
+
isDisabled: !w || T || _ || !x
|
|
21
21
|
});
|
|
22
22
|
const ee = (r) => {
|
|
23
|
-
e.current && !e.current.contains(r.target) || (
|
|
23
|
+
e.current && !e.current.contains(r.target) || (O.current = e.current?.getBoundingClientRect().height || 0, P(!0), I.current = /* @__PURE__ */ new Date(), le() && window.addEventListener("touchend", () => d.current = !1, { once: !0 }), r.target.setPointerCapture(r.pointerId), h.current = r.pageY);
|
|
24
24
|
}, z = (r, c) => {
|
|
25
25
|
let n = r;
|
|
26
26
|
const u = window.getSelection()?.toString(), i = e.current ? W(e.current) : null, a = /* @__PURE__ */ new Date();
|
|
@@ -43,12 +43,12 @@ const we = (m) => {
|
|
|
43
43
|
}
|
|
44
44
|
return !0;
|
|
45
45
|
}, te = (r) => {
|
|
46
|
-
if (e.current &&
|
|
47
|
-
const c = h.current - r.pageY, n = c > 0, u = Math.abs(c), i =
|
|
46
|
+
if (e.current && T) {
|
|
47
|
+
const c = h.current - r.pageY, n = c > 0, u = Math.abs(c), i = O.current, a = u / i;
|
|
48
48
|
if (!d.current && !z(r.target, n)) return;
|
|
49
49
|
if (e.current.classList.add(j), d.current = !0, R(e.current, {
|
|
50
50
|
transition: "none"
|
|
51
|
-
}), R(
|
|
51
|
+
}), R(v.current, {
|
|
52
52
|
transition: "none"
|
|
53
53
|
}), n) {
|
|
54
54
|
const F = fe(c), U = Math.min(F * -1, 0) * 1;
|
|
@@ -59,7 +59,7 @@ const we = (m) => {
|
|
|
59
59
|
}
|
|
60
60
|
const k = 1 - a;
|
|
61
61
|
R(
|
|
62
|
-
|
|
62
|
+
v.current,
|
|
63
63
|
{
|
|
64
64
|
opacity: `${k}`,
|
|
65
65
|
transition: "none"
|
|
@@ -80,11 +80,11 @@ const we = (m) => {
|
|
|
80
80
|
const r = () => {
|
|
81
81
|
if (!e.current) return;
|
|
82
82
|
const c = document.activeElement;
|
|
83
|
-
if (ce(c) ||
|
|
83
|
+
if (ce(c) || b.current) {
|
|
84
84
|
const n = window.visualViewport?.height || 0, u = window.innerHeight, i = u - n, a = e.current.getBoundingClientRect().height || 0, k = a > u * 0.8;
|
|
85
85
|
g.current || (g.current = a);
|
|
86
86
|
const $ = e.current.getBoundingClientRect().top;
|
|
87
|
-
if (Math.abs(
|
|
87
|
+
if (Math.abs(C.current - i) > 60 && (b.current = !b.current), C.current = i, a > n || b.current) {
|
|
88
88
|
const F = e.current.getBoundingClientRect().height;
|
|
89
89
|
let U = F;
|
|
90
90
|
F > n && (U = n - (k ? $ : he)), e.current.style.height = `${Math.max(
|
|
@@ -103,15 +103,15 @@ const we = (m) => {
|
|
|
103
103
|
e.current && (R(e.current, {
|
|
104
104
|
transform: "translate3d(0, 0, 0)",
|
|
105
105
|
transition: `transform ${Y.DURATION}s cubic-bezier(${Y.EASE.join(",")})`
|
|
106
|
-
}), R(
|
|
106
|
+
}), R(v.current, {
|
|
107
107
|
transition: `opacity ${Y.DURATION}s cubic-bezier(${Y.EASE.join(",")})`,
|
|
108
108
|
opacity: "1"
|
|
109
109
|
}));
|
|
110
110
|
}, re = () => {
|
|
111
|
-
!
|
|
111
|
+
!T || !e.current || (e.current.classList.remove(j), d.current = !1, P(!1), L.current = /* @__PURE__ */ new Date());
|
|
112
112
|
}, ne = (r) => {
|
|
113
|
-
if (!
|
|
114
|
-
e.current.classList.remove(j), d.current = !1,
|
|
113
|
+
if (!T || !e.current) return;
|
|
114
|
+
e.current.classList.remove(j), d.current = !1, P(!1), L.current = /* @__PURE__ */ new Date();
|
|
115
115
|
const c = W(e.current);
|
|
116
116
|
if (!r || !z(r.target, !1) || !c || Number.isNaN(c) || I.current === null) return;
|
|
117
117
|
const n = L.current.getTime() - I.current.getTime(), u = h.current - r.pageY, i = Math.abs(u) / n;
|
|
@@ -140,9 +140,9 @@ const we = (m) => {
|
|
|
140
140
|
}), H.current = /* @__PURE__ */ new Date()), () => {
|
|
141
141
|
ae(document.documentElement, "scrollBehavior");
|
|
142
142
|
}), [w]), /* @__PURE__ */ s(
|
|
143
|
-
|
|
143
|
+
E.Root,
|
|
144
144
|
{
|
|
145
|
-
defaultOpen:
|
|
145
|
+
defaultOpen: S,
|
|
146
146
|
onOpenChange: (r) => {
|
|
147
147
|
r ? M(!0) : B(!0), V(r);
|
|
148
148
|
},
|
|
@@ -153,69 +153,69 @@ const we = (m) => {
|
|
|
153
153
|
{
|
|
154
154
|
value: {
|
|
155
155
|
drawerRef: e,
|
|
156
|
-
overlayRef:
|
|
156
|
+
overlayRef: v,
|
|
157
157
|
onPress: ee,
|
|
158
158
|
onRelease: ne,
|
|
159
159
|
onDrag: te,
|
|
160
160
|
isOpen: w,
|
|
161
|
-
isDragging:
|
|
162
|
-
keyboardIsOpen:
|
|
161
|
+
isDragging: T,
|
|
162
|
+
keyboardIsOpen: b,
|
|
163
163
|
closeDrawer: () => B(),
|
|
164
164
|
shouldAnimate: N,
|
|
165
|
-
onClosed:
|
|
165
|
+
onClosed: D,
|
|
166
166
|
disableEsc: f
|
|
167
167
|
},
|
|
168
|
-
children:
|
|
168
|
+
children: y
|
|
169
169
|
}
|
|
170
170
|
)
|
|
171
171
|
}
|
|
172
172
|
);
|
|
173
173
|
}, Re = t.forwardRef(
|
|
174
174
|
({ className: m, ...p }, l) => {
|
|
175
|
-
const { overlayRef:
|
|
176
|
-
(M) =>
|
|
177
|
-
[
|
|
175
|
+
const { overlayRef: D, onRelease: y, shouldAnimate: S } = J(), f = Q(l, D), x = t.useCallback(
|
|
176
|
+
(M) => y(M),
|
|
177
|
+
[y]
|
|
178
178
|
);
|
|
179
179
|
return /* @__PURE__ */ s(
|
|
180
|
-
|
|
180
|
+
E.Overlay,
|
|
181
181
|
{
|
|
182
182
|
onMouseUp: x,
|
|
183
183
|
ref: f,
|
|
184
|
-
"data-animate":
|
|
184
|
+
"data-animate": S?.current ? "true" : "false",
|
|
185
185
|
className: G("popup-overlay drawer-overlay", m),
|
|
186
186
|
...p
|
|
187
187
|
}
|
|
188
188
|
);
|
|
189
189
|
}
|
|
190
190
|
), De = t.forwardRef(
|
|
191
|
-
({ onPointerDownOutside: m, style: p, onOpenAutoFocus: l, className:
|
|
191
|
+
({ onPointerDownOutside: m, style: p, onOpenAutoFocus: l, className: D, size: y, children: S, ...f }, x) => {
|
|
192
192
|
const {
|
|
193
193
|
drawerRef: M,
|
|
194
|
-
onPress:
|
|
195
|
-
onRelease:
|
|
194
|
+
onPress: T,
|
|
195
|
+
onRelease: P,
|
|
196
196
|
onDrag: _,
|
|
197
197
|
keyboardIsOpen: A,
|
|
198
|
-
shouldAnimate:
|
|
198
|
+
shouldAnimate: v,
|
|
199
199
|
onClosed: H,
|
|
200
200
|
disableEsc: I
|
|
201
|
-
} = J(), L = Q(x, M), o = t.useRef(null), d = t.useRef(null), h = t.useRef(!1),
|
|
201
|
+
} = J(), L = Q(x, M), o = t.useRef(null), d = t.useRef(null), h = t.useRef(!1), b = (e, O = 0) => {
|
|
202
202
|
if (h.current) return !0;
|
|
203
203
|
const g = Math.abs(e.y), w = Math.abs(e.x) > g;
|
|
204
|
-
return !(e.y * 1 < 0) && g >= 0 && g <=
|
|
204
|
+
return !(e.y * 1 < 0) && g >= 0 && g <= O ? !w : (h.current = !0, !0);
|
|
205
205
|
}, N = (e) => {
|
|
206
|
-
o.current = null, h.current = !1,
|
|
206
|
+
o.current = null, h.current = !1, P(e);
|
|
207
207
|
};
|
|
208
208
|
return /* @__PURE__ */ q(
|
|
209
|
-
|
|
209
|
+
E.Content,
|
|
210
210
|
{
|
|
211
211
|
"data-direction": "bottom",
|
|
212
|
-
"data-animate":
|
|
213
|
-
className: G("popup drawer drawer-mobile",
|
|
214
|
-
style: { ...oe({ "--drawer-size":
|
|
212
|
+
"data-animate": v?.current ? "true" : "false",
|
|
213
|
+
className: G("popup drawer drawer-mobile", D),
|
|
214
|
+
style: { ...oe({ "--drawer-size": y ?? "50%" }), ...p },
|
|
215
215
|
...f,
|
|
216
216
|
ref: L,
|
|
217
217
|
onPointerDown: (e) => {
|
|
218
|
-
f.onPointerDown?.(e), o.current = { x: e.pageX, y: e.pageY },
|
|
218
|
+
f.onPointerDown?.(e), o.current = { x: e.pageX, y: e.pageY }, T(e);
|
|
219
219
|
},
|
|
220
220
|
onOpenAutoFocus: (e) => {
|
|
221
221
|
l?.(e), e.preventDefault();
|
|
@@ -228,11 +228,11 @@ const we = (m) => {
|
|
|
228
228
|
},
|
|
229
229
|
onPointerMove: (e) => {
|
|
230
230
|
if (d.current = e, f.onPointerMove?.(e), !o.current) return;
|
|
231
|
-
const
|
|
232
|
-
|
|
231
|
+
const O = e.pageY - o.current.y, g = e.pageX - o.current.x, C = e.pointerType === "touch" ? 10 : 2;
|
|
232
|
+
b({ x: g, y: O }, C) ? _(e) : (Math.abs(g) > C || Math.abs(O) > C) && (o.current = null);
|
|
233
233
|
},
|
|
234
234
|
onPointerUp: (e) => {
|
|
235
|
-
f.onPointerUp?.(e), o.current = null, h.current = !1,
|
|
235
|
+
f.onPointerUp?.(e), o.current = null, h.current = !1, P(e);
|
|
236
236
|
},
|
|
237
237
|
onPointerOut: (e) => {
|
|
238
238
|
f.onPointerOut?.(e), N(d.current);
|
|
@@ -242,20 +242,20 @@ const we = (m) => {
|
|
|
242
242
|
},
|
|
243
243
|
children: [
|
|
244
244
|
/* @__PURE__ */ s(se, { callback: H }),
|
|
245
|
-
/* @__PURE__ */ s(K, { children: /* @__PURE__ */ s(
|
|
246
|
-
/* @__PURE__ */ s(K, { children: /* @__PURE__ */ s(
|
|
247
|
-
|
|
245
|
+
/* @__PURE__ */ s(K, { children: /* @__PURE__ */ s(E.Title, {}) }),
|
|
246
|
+
/* @__PURE__ */ s(K, { children: /* @__PURE__ */ s(E.Description, {}) }),
|
|
247
|
+
S
|
|
248
248
|
]
|
|
249
249
|
}
|
|
250
250
|
);
|
|
251
251
|
}
|
|
252
252
|
), Te = t.forwardRef(
|
|
253
253
|
({ children: m, ...p }, l) => /* @__PURE__ */ s("div", { className: "drawer-handle", "aria-hidden": "true", ref: l, ...p, children: /* @__PURE__ */ s("span", { className: "drawer-handle-hitarea", "aria-hidden": "true", children: m }) })
|
|
254
|
-
), Z = ({ children: m,
|
|
254
|
+
), Z = ({ children: m, className: p, size: l, ...D }) => /* @__PURE__ */ s(we, { ...D, children: /* @__PURE__ */ q(E.Portal, { children: [
|
|
255
255
|
/* @__PURE__ */ s(Re, {}),
|
|
256
|
-
/* @__PURE__ */ s(De, {
|
|
256
|
+
/* @__PURE__ */ s(De, { className: p, size: l, children: m })
|
|
257
257
|
] }) });
|
|
258
|
-
Z.Close =
|
|
258
|
+
Z.Close = E.Close;
|
|
259
259
|
Z.Handle = Te;
|
|
260
260
|
export {
|
|
261
261
|
Te as Handle,
|
package/dist/bundle.es67.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsxs as b, jsx as o } from "react/jsx-runtime";
|
|
|
2
2
|
import h from "classnames";
|
|
3
3
|
import { attr as e } from "@companix/utils-browser";
|
|
4
4
|
import { forwardRef as x } from "react";
|
|
5
|
-
import { useInputPadding as N } from "./bundle.
|
|
5
|
+
import { useInputPadding as N } from "./bundle.es83.js";
|
|
6
6
|
const v = x(
|
|
7
7
|
({
|
|
8
8
|
required: s,
|
package/dist/bundle.es72.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as D, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { dateToFormat as $, weeks as g, createVoids as p, getDayIndex as b, getFirstDay as u, getMonthMaxDay as k } from "./bundle.es65.js";
|
|
3
|
-
import { CalendarHeader as F } from "./bundle.
|
|
4
|
-
import { useCalendar as j } from "./bundle.
|
|
3
|
+
import { CalendarHeader as F } from "./bundle.es81.js";
|
|
4
|
+
import { useCalendar as j } from "./bundle.es82.js";
|
|
5
5
|
import { attr as m } from "@companix/utils-browser";
|
|
6
6
|
import { isSameDate as f } from "./bundle.es59.js";
|
|
7
7
|
import { useLayoutEffect as I } from "react";
|
package/dist/bundle.es81.js
CHANGED
|
@@ -1,16 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { jsxs as d, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as u, useMemo as h } from "react";
|
|
3
|
+
import { Select as p } from "./bundle.es13.js";
|
|
4
|
+
import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es65.js";
|
|
5
|
+
import { Icon as C } from "./bundle.es36.js";
|
|
6
|
+
import { faChevronLeft as E, faChevronRight as T } from "@companix/icons-solid";
|
|
7
|
+
import { setMonth as _, setYear as F } from "./bundle.es59.js";
|
|
8
|
+
const y = ({
|
|
9
|
+
viewDate: n,
|
|
10
|
+
onChange: c,
|
|
11
|
+
isMonthDisabled: a,
|
|
12
|
+
isYearDisabled: m,
|
|
13
|
+
onNextMonth: N,
|
|
14
|
+
onPrevMonth: v
|
|
15
|
+
}) => {
|
|
16
|
+
const e = n.getFullYear(), r = n.getMonth(), s = "ru", M = u(
|
|
17
|
+
(t) => {
|
|
18
|
+
c(_(n, t));
|
|
19
|
+
},
|
|
20
|
+
[c, n]
|
|
21
|
+
), x = u(
|
|
22
|
+
(t) => {
|
|
23
|
+
c(F(n, t));
|
|
24
|
+
},
|
|
25
|
+
[c, n]
|
|
26
|
+
), A = h(() => k(s).map((t) => ({
|
|
27
|
+
...t,
|
|
28
|
+
className: "capitalize",
|
|
29
|
+
disabled: a && a(t.value)
|
|
30
|
+
})), [s, a]), Y = h(() => z(e, 100).map((t) => ({
|
|
31
|
+
...t,
|
|
32
|
+
disabled: m && m(t.value)
|
|
33
|
+
})), [e, m]);
|
|
34
|
+
let l = r === 11 && e === f;
|
|
35
|
+
a && !l && (l = a(
|
|
36
|
+
r === 11 ? 0 : r + 1,
|
|
37
|
+
r === 11 ? Math.min(e + 1, f) : e
|
|
38
|
+
));
|
|
39
|
+
let i = r === 0 && e === g;
|
|
40
|
+
return a && !i && (i = a(
|
|
41
|
+
r === 0 ? 11 : r - 1,
|
|
42
|
+
r === 0 ? Math.max(e - 1, g) : e
|
|
43
|
+
)), /* @__PURE__ */ d("div", { className: "calendar-header", children: [
|
|
44
|
+
!i && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "left", onClick: v, children: /* @__PURE__ */ o(C, { icon: E }) }),
|
|
45
|
+
/* @__PURE__ */ d("div", { className: "calendar-pickers", children: [
|
|
46
|
+
/* @__PURE__ */ o(
|
|
47
|
+
p,
|
|
48
|
+
{
|
|
49
|
+
fill: !0,
|
|
50
|
+
options: Y,
|
|
51
|
+
size: "sm",
|
|
52
|
+
value: e,
|
|
53
|
+
minimalOptions: !0,
|
|
54
|
+
matchTarget: "min-width",
|
|
55
|
+
onChange: (t) => x(t)
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
/* @__PURE__ */ o(
|
|
59
|
+
p,
|
|
60
|
+
{
|
|
61
|
+
fill: !0,
|
|
62
|
+
options: A,
|
|
63
|
+
size: "sm",
|
|
64
|
+
className: "capitalize",
|
|
65
|
+
value: r,
|
|
66
|
+
minimalOptions: !0,
|
|
67
|
+
matchTarget: "min-width",
|
|
68
|
+
onChange: (t) => M(t)
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
] }),
|
|
72
|
+
!l && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "right", onClick: N, children: /* @__PURE__ */ o(C, { icon: T }) })
|
|
73
|
+
] });
|
|
13
74
|
};
|
|
14
75
|
export {
|
|
15
|
-
|
|
76
|
+
y as CalendarHeader
|
|
16
77
|
};
|
package/dist/bundle.es82.js
CHANGED
|
@@ -1,77 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
isMonthDisabled: a,
|
|
12
|
-
isYearDisabled: m,
|
|
13
|
-
onNextMonth: N,
|
|
14
|
-
onPrevMonth: v
|
|
1
|
+
import { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es59.js";
|
|
2
|
+
import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es65.js";
|
|
3
|
+
import { useState as U, useCallback as M } from "react";
|
|
4
|
+
const X = ({
|
|
5
|
+
value: p,
|
|
6
|
+
disablePast: r,
|
|
7
|
+
disableFuture: c,
|
|
8
|
+
shouldDisableDate: E,
|
|
9
|
+
minDateTime: l,
|
|
10
|
+
maxDateTime: s
|
|
15
11
|
}) => {
|
|
16
|
-
const e =
|
|
17
|
-
(
|
|
18
|
-
|
|
12
|
+
const [e, u] = U(p || /* @__PURE__ */ new Date()), _ = M(() => {
|
|
13
|
+
u(L(e, 1));
|
|
14
|
+
}, [e]), C = M(() => {
|
|
15
|
+
u(N(e, 1));
|
|
16
|
+
}, [e]), D = R({
|
|
17
|
+
disableFuture: c,
|
|
18
|
+
disablePast: r,
|
|
19
|
+
shouldDisableDate: E,
|
|
20
|
+
minDateTime: l,
|
|
21
|
+
maxDateTime: s
|
|
22
|
+
}), k = M(
|
|
23
|
+
(o, t) => {
|
|
24
|
+
const n = /* @__PURE__ */ new Date();
|
|
25
|
+
t = t || e.getFullYear();
|
|
26
|
+
const h = l ? l.getMonth() : 0, Y = s ? s.getMonth() : 11, F = l?.getFullYear() || w, f = s?.getFullYear() || A;
|
|
27
|
+
let g = t >= F && t <= f ? t === F && h > o || t === f && o > Y : !0;
|
|
28
|
+
return c && (g = g || (t === n.getFullYear() ? o > n.getMonth() : t > n.getFullYear())), r && (g = g || (t === n.getFullYear() ? o < n.getMonth() : t < n.getFullYear())), g;
|
|
19
29
|
},
|
|
20
|
-
[c,
|
|
21
|
-
),
|
|
22
|
-
(
|
|
23
|
-
|
|
30
|
+
[c, r, e, l, s]
|
|
31
|
+
), v = M(
|
|
32
|
+
(o) => {
|
|
33
|
+
const t = /* @__PURE__ */ new Date(), n = l?.getFullYear() || w, h = s?.getFullYear() || A;
|
|
34
|
+
let Y = n > o || o > h;
|
|
35
|
+
return c && (Y = Y || o > t.getFullYear()), r && (Y = Y || o < t.getFullYear()), Y;
|
|
24
36
|
},
|
|
25
|
-
[c,
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
r === 11 ? 0 : r + 1,
|
|
37
|
-
r === 11 ? Math.min(e + 1, f) : e
|
|
38
|
-
));
|
|
39
|
-
let i = r === 0 && e === g;
|
|
40
|
-
return a && !i && (i = a(
|
|
41
|
-
r === 0 ? 11 : r - 1,
|
|
42
|
-
r === 0 ? Math.max(e - 1, g) : e
|
|
43
|
-
)), /* @__PURE__ */ d("div", { className: "calendar-header", children: [
|
|
44
|
-
!i && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "left", onClick: v, children: /* @__PURE__ */ o(C, { icon: E }) }),
|
|
45
|
-
/* @__PURE__ */ d("div", { className: "calendar-pickers", children: [
|
|
46
|
-
/* @__PURE__ */ o(
|
|
47
|
-
p,
|
|
48
|
-
{
|
|
49
|
-
fill: !0,
|
|
50
|
-
options: Y,
|
|
51
|
-
size: "sm",
|
|
52
|
-
value: e,
|
|
53
|
-
minimalOptions: !0,
|
|
54
|
-
matchTarget: "min-width",
|
|
55
|
-
onChange: (t) => x(t)
|
|
56
|
-
}
|
|
57
|
-
),
|
|
58
|
-
/* @__PURE__ */ o(
|
|
59
|
-
p,
|
|
60
|
-
{
|
|
61
|
-
fill: !0,
|
|
62
|
-
options: A,
|
|
63
|
-
size: "sm",
|
|
64
|
-
className: "capitalize",
|
|
65
|
-
value: r,
|
|
66
|
-
minimalOptions: !0,
|
|
67
|
-
matchTarget: "min-width",
|
|
68
|
-
onChange: (t) => M(t)
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
] }),
|
|
72
|
-
!l && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "right", onClick: N, children: /* @__PURE__ */ o(C, { icon: T }) })
|
|
73
|
-
] });
|
|
37
|
+
[c, r, l, s]
|
|
38
|
+
);
|
|
39
|
+
return {
|
|
40
|
+
viewDate: e,
|
|
41
|
+
setViewDate: u,
|
|
42
|
+
setPrevMonth: _,
|
|
43
|
+
setNextMonth: C,
|
|
44
|
+
isDayDisabled: D,
|
|
45
|
+
isMonthDisabled: k,
|
|
46
|
+
isYearDisabled: v
|
|
47
|
+
};
|
|
74
48
|
};
|
|
75
49
|
export {
|
|
76
|
-
|
|
50
|
+
X as useCalendar
|
|
77
51
|
};
|
package/dist/bundle.es83.js
CHANGED
|
@@ -1,51 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
u(L(e, 1));
|
|
14
|
-
}, [e]), C = M(() => {
|
|
15
|
-
u(N(e, 1));
|
|
16
|
-
}, [e]), D = R({
|
|
17
|
-
disableFuture: c,
|
|
18
|
-
disablePast: r,
|
|
19
|
-
shouldDisableDate: E,
|
|
20
|
-
minDateTime: l,
|
|
21
|
-
maxDateTime: s
|
|
22
|
-
}), k = M(
|
|
23
|
-
(o, t) => {
|
|
24
|
-
const n = /* @__PURE__ */ new Date();
|
|
25
|
-
t = t || e.getFullYear();
|
|
26
|
-
const h = l ? l.getMonth() : 0, Y = s ? s.getMonth() : 11, F = l?.getFullYear() || w, f = s?.getFullYear() || A;
|
|
27
|
-
let g = t >= F && t <= f ? t === F && h > o || t === f && o > Y : !0;
|
|
28
|
-
return c && (g = g || (t === n.getFullYear() ? o > n.getMonth() : t > n.getFullYear())), r && (g = g || (t === n.getFullYear() ? o < n.getMonth() : t < n.getFullYear())), g;
|
|
29
|
-
},
|
|
30
|
-
[c, r, e, l, s]
|
|
31
|
-
), v = M(
|
|
32
|
-
(o) => {
|
|
33
|
-
const t = /* @__PURE__ */ new Date(), n = l?.getFullYear() || w, h = s?.getFullYear() || A;
|
|
34
|
-
let Y = n > o || o > h;
|
|
35
|
-
return c && (Y = Y || o > t.getFullYear()), r && (Y = Y || o < t.getFullYear()), Y;
|
|
36
|
-
},
|
|
37
|
-
[c, r, l, s]
|
|
38
|
-
);
|
|
39
|
-
return {
|
|
40
|
-
viewDate: e,
|
|
41
|
-
setViewDate: u,
|
|
42
|
-
setPrevMonth: _,
|
|
43
|
-
setNextMonth: C,
|
|
44
|
-
isDayDisabled: D,
|
|
45
|
-
isMonthDisabled: k,
|
|
46
|
-
isYearDisabled: v
|
|
47
|
-
};
|
|
1
|
+
import { useRef as l, useCallback as p } from "react";
|
|
2
|
+
import { useEffectWithLayout as d } from "./bundle.es84.js";
|
|
3
|
+
const g = (r, f) => {
|
|
4
|
+
const c = l(null), i = l(null), o = { Right: c, Left: i }, u = p((t) => {
|
|
5
|
+
if (r.current) {
|
|
6
|
+
const n = r.current.style, e = o[t];
|
|
7
|
+
e.current && e.current.clientWidth ? n[`padding${t}`] !== `${e.current.clientWidth}px` && (n[`padding${t}`] = `${e.current.clientWidth}px`) : n[`padding${t}`] && (n[`padding${t}`] = "");
|
|
8
|
+
}
|
|
9
|
+
}, []);
|
|
10
|
+
return d(() => {
|
|
11
|
+
u("Left"), u("Right");
|
|
12
|
+
}, f), { rightRef: c, leftRef: i };
|
|
48
13
|
};
|
|
49
14
|
export {
|
|
50
|
-
|
|
15
|
+
g as useInputPadding
|
|
51
16
|
};
|