@kolking/react-ui 1.8.20 → 1.9.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/Thumbnails-BlXFynlF.js +38 -0
- package/dist/components/Avatar/Avatar.js +15 -15
- package/dist/components/Avatar/helpers.js +15 -16
- package/dist/components/Badge/Badge.js +28 -29
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Dialog/Dialog.js +44 -44
- package/dist/components/Dialog/useDialog.d.ts +9 -6
- package/dist/components/Dialog/useDialog.js +20 -28
- package/dist/components/Fields/Checkbox.js +15 -15
- package/dist/components/Fields/Numeric.js +34 -36
- package/dist/components/Fields/Range.d.ts +1 -1
- package/dist/components/Fields/Range.js +33 -33
- package/dist/components/Flex/Flex.d.ts +1 -1
- package/dist/components/Gallery/Gallery.d.ts +11 -0
- package/dist/components/Gallery/Gallery.js +49 -0
- package/dist/components/Gallery/GalleryItem.d.ts +12 -0
- package/dist/components/Gallery/GalleryItem.js +41 -0
- package/dist/components/Gallery/index.d.ts +2 -0
- package/dist/components/Gallery/index.js +6 -0
- package/dist/components/Icon/Icon.js +125 -122
- package/dist/components/Icon/icons.d.ts +1 -1
- package/dist/components/Icon/icons.js +4 -0
- package/dist/components/Lightbox/Lightbox.d.ts +12 -0
- package/dist/components/Lightbox/Lightbox.js +166 -0
- package/dist/components/Lightbox/Thumbnail.d.ts +7 -0
- package/dist/components/Lightbox/Thumbnail.js +26 -0
- package/dist/components/Lightbox/Thumbnails.d.ts +11 -0
- package/dist/components/Lightbox/Thumbnails.js +8 -0
- package/dist/components/Lightbox/index.d.ts +1 -0
- package/dist/components/Lightbox/index.js +4 -0
- package/dist/components/Menu/Menu.js +44 -45
- package/dist/components/Menu/MenuItem.js +33 -33
- package/dist/components/Notice/Notice.js +58 -43
- package/dist/components/Popover/Popover.js +40 -41
- package/dist/components/Progress/ProgressBar.js +14 -14
- package/dist/components/Progress/ProgressCircular.js +15 -15
- package/dist/components/Segmented/Segmented.js +43 -47
- package/dist/components/Tag/Tag.d.ts +1 -1
- package/dist/components/ToggleButton/ToggleButton.d.ts +1 -1
- package/dist/components/ToggleButton/ToggleGroup.js +42 -40
- package/dist/components/Tooltip/Tooltip.js +30 -31
- package/dist/index.d.ts +3 -1
- package/dist/index.js +71 -63
- package/dist/styles/style.css +1 -1
- package/dist/styles.module-D0C-vMZX.js +7 -0
- package/dist/utils/helpers.d.ts +3 -1
- package/dist/utils/helpers.js +30 -19
- package/package.json +41 -32
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import a from "classnames";
|
|
3
|
+
import { Thumbnail as g } from "./components/Lightbox/Thumbnail.js";
|
|
4
|
+
import { cssProps as u, htmlImage as _ } from "./utils/helpers.js";
|
|
5
|
+
const x = "Lightbox_lightbox_JQunO", p = "Lightbox_images_WFWsL", L = "Lightbox_thumbnails_jQSPH", f = "Lightbox_willhide_z2lO8", d = "Lightbox_content_UfCvB", v = "Lightbox_prev_qIKJt", T = "Lightbox_next_qZR61", j = "Lightbox_close_SgBu9", w = {
|
|
6
|
+
lightbox: x,
|
|
7
|
+
images: p,
|
|
8
|
+
thumbnails: L,
|
|
9
|
+
willhide: f,
|
|
10
|
+
content: d,
|
|
11
|
+
prev: v,
|
|
12
|
+
next: T,
|
|
13
|
+
close: j
|
|
14
|
+
}, F = ({
|
|
15
|
+
images: o,
|
|
16
|
+
selected: i,
|
|
17
|
+
className: n,
|
|
18
|
+
style: e,
|
|
19
|
+
imageSize: h,
|
|
20
|
+
objectFit: c,
|
|
21
|
+
renderImage: b = _,
|
|
22
|
+
onSelect: m,
|
|
23
|
+
...r
|
|
24
|
+
}) => o.length <= 1 ? null : /* @__PURE__ */ s(
|
|
25
|
+
"ul",
|
|
26
|
+
{
|
|
27
|
+
...r,
|
|
28
|
+
role: "listbox",
|
|
29
|
+
"data-lightbox-thumbnails": !0,
|
|
30
|
+
className: a(w.thumbnails, n),
|
|
31
|
+
style: { ...e, ...u({ thumbnailSize: h, thumbnailObjectFit: c }) },
|
|
32
|
+
children: o.map((l, t) => /* @__PURE__ */ s(g, { index: t, selected: t === i, onSelect: m, children: b({ ...l, alt: l.alt ?? `Thumbnail ${t + 1}` }) }, t))
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
export {
|
|
36
|
+
F as T,
|
|
37
|
+
w as s
|
|
38
|
+
};
|
|
@@ -4,47 +4,47 @@ import * as m from "react";
|
|
|
4
4
|
import { forwardRef as S, useMemo as x, useState as A, useEffect as N, useCallback as E } from "react";
|
|
5
5
|
import { cssProps as C } from "../../utils/helpers.js";
|
|
6
6
|
import { getStringColor as k, getGravatarUri as M, getInitials as R } from "./helpers.js";
|
|
7
|
-
const b = (a,
|
|
7
|
+
const b = (a, e) => /* @__PURE__ */ m.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 50 50", ref: e, ...a }, /* @__PURE__ */ m.createElement("path", { fill: "currentColor", d: "M25 31c4.97 0 9-4.253 9-9.5S29.97 12 25 12s-9 4.253-9 9.5 4.03 9.5 9 9.5Zm19 19c0-8.837-8.507-15-19-15S6 41.163 6 50h38Z" })), j = S(b), y = "Avatar_avatar_PNlL5", I = "Avatar_image_Jwmxk", P = "Avatar_initials_i0r2T", r = {
|
|
8
8
|
avatar: y,
|
|
9
9
|
image: I,
|
|
10
10
|
initials: P,
|
|
11
11
|
default: "Avatar_default_v75Mg"
|
|
12
12
|
}, J = ({
|
|
13
13
|
size: a = 50,
|
|
14
|
-
name:
|
|
14
|
+
name: e,
|
|
15
15
|
email: o,
|
|
16
16
|
src: c,
|
|
17
17
|
colorize: v,
|
|
18
|
-
className:
|
|
19
|
-
style:
|
|
18
|
+
className: u,
|
|
19
|
+
style: d,
|
|
20
20
|
children: g,
|
|
21
21
|
...f
|
|
22
22
|
}) => {
|
|
23
|
-
const
|
|
23
|
+
const t = e?.trim(), p = v && t ? k(t) : void 0, s = x(() => c || (o ? M(a, o) : void 0), [c, a, o]), [n, l] = A(s);
|
|
24
24
|
N(() => {
|
|
25
|
-
|
|
25
|
+
l(s);
|
|
26
26
|
}, [s]);
|
|
27
27
|
const w = E(() => {
|
|
28
|
-
|
|
28
|
+
l(void 0);
|
|
29
29
|
}, []);
|
|
30
30
|
return /* @__PURE__ */ _(
|
|
31
|
-
"
|
|
31
|
+
"figure",
|
|
32
32
|
{
|
|
33
33
|
...f,
|
|
34
34
|
"data-avatar": !0,
|
|
35
|
-
className: h(
|
|
36
|
-
style: { ...
|
|
35
|
+
className: h(r.avatar, u),
|
|
36
|
+
style: { ...d, ...C({ size: a, backgroundColor: p }) },
|
|
37
37
|
children: [
|
|
38
|
-
|
|
38
|
+
n ? /* @__PURE__ */ i(
|
|
39
39
|
"img",
|
|
40
40
|
{
|
|
41
41
|
"data-avatar-image": !0,
|
|
42
|
-
className:
|
|
43
|
-
src:
|
|
44
|
-
alt:
|
|
42
|
+
className: r.image,
|
|
43
|
+
src: n,
|
|
44
|
+
alt: t ?? "",
|
|
45
45
|
onError: w
|
|
46
46
|
}
|
|
47
|
-
) :
|
|
47
|
+
) : t ? /* @__PURE__ */ i("figcaption", { "data-avatar-initials": !0, className: r.initials, children: R(t) }) : /* @__PURE__ */ i(j, { "aria-hidden": !0, "data-avatar-default": !0, className: r.default }),
|
|
48
48
|
g
|
|
49
49
|
]
|
|
50
50
|
}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { md5 as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
return `https://www.gravatar.com/avatar/${
|
|
1
|
+
import { md5 as o } from "js-md5";
|
|
2
|
+
function l(e, t) {
|
|
3
|
+
const i = o(t.toLowerCase().trim()), r = window.devicePixelRatio || 1, n = Math.round(r * e);
|
|
4
|
+
return `https://www.gravatar.com/avatar/${i}?s=${n}&d=404`;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
const t =
|
|
8
|
-
|
|
9
|
-
return t.length > 0 && (e += [...t.pop() || ""][0]), e.toUpperCase();
|
|
6
|
+
function s(e) {
|
|
7
|
+
const t = e.trim().split(/\s+/gu).filter(Boolean);
|
|
8
|
+
return t.length === 0 ? "" : ([...t[0]][0] + (t.length > 1 ? [...t[t.length - 1]][0] : "")).toUpperCase();
|
|
10
9
|
}
|
|
11
|
-
function
|
|
10
|
+
function h(e) {
|
|
12
11
|
let t = 0;
|
|
13
|
-
if (
|
|
14
|
-
for (let
|
|
15
|
-
t =
|
|
16
|
-
return `hsl(${t % 360}, 75%, 50%)`;
|
|
12
|
+
if (e.length > 0)
|
|
13
|
+
for (let r = 0; r < e.length; r += 1)
|
|
14
|
+
t = e.charCodeAt(r) + ((t << 5) - t), t &= t;
|
|
15
|
+
return `hsl(${(t % 360 + 360) % 360}, 75%, 50%)`;
|
|
17
16
|
}
|
|
18
17
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
l as getGravatarUri,
|
|
19
|
+
s as getInitials,
|
|
20
|
+
h as getStringColor
|
|
22
21
|
};
|
|
@@ -2,64 +2,63 @@ import { jsx as h } from "react/jsx-runtime";
|
|
|
2
2
|
import { useRef as _, useLayoutEffect as w, useEffect as l } from "react";
|
|
3
3
|
import E from "classnames";
|
|
4
4
|
import { wrapNode as P, cssProps as H } from "../../utils/helpers.js";
|
|
5
|
-
const M = "Badge_badge_-mEE7", k = "Badge_appear_LbxbS", x = "Badge_accent_BIYve", L = "Badge_gray_7jA-J",
|
|
5
|
+
const M = "Badge_badge_-mEE7", k = "Badge_appear_LbxbS", x = "Badge_accent_BIYve", L = "Badge_gray_7jA-J", v = "Badge_brown_x1GS7", I = "Badge_red_zPgCR", R = "Badge_orange_EoLmF", S = "Badge_yellow_qvbb6", X = "Badge_green_XX-1c", j = "Badge_teal_VHoFK", C = "Badge_cyan_1ksBn", F = "Badge_blue_YulfT", K = "Badge_indigo_2KXUy", N = "Badge_purple_o55fQ", O = "Badge_pink_T5H--", c = {
|
|
6
6
|
badge: M,
|
|
7
7
|
appear: k,
|
|
8
8
|
accent: x,
|
|
9
9
|
gray: L,
|
|
10
|
-
brown:
|
|
11
|
-
red:
|
|
12
|
-
orange:
|
|
13
|
-
yellow:
|
|
14
|
-
green:
|
|
15
|
-
teal:
|
|
10
|
+
brown: v,
|
|
11
|
+
red: I,
|
|
12
|
+
orange: R,
|
|
13
|
+
yellow: S,
|
|
14
|
+
green: X,
|
|
15
|
+
teal: j,
|
|
16
16
|
cyan: C,
|
|
17
17
|
blue: F,
|
|
18
18
|
indigo: K,
|
|
19
19
|
purple: N,
|
|
20
20
|
pink: O
|
|
21
21
|
};
|
|
22
|
-
function T(
|
|
23
|
-
const n = _();
|
|
22
|
+
function T(o) {
|
|
23
|
+
const n = _(void 0);
|
|
24
24
|
return l(() => {
|
|
25
|
-
n.current =
|
|
25
|
+
n.current = o;
|
|
26
26
|
}), n.current;
|
|
27
27
|
}
|
|
28
28
|
const A = ({
|
|
29
|
-
size:
|
|
29
|
+
size: o,
|
|
30
30
|
scheme: n = "red",
|
|
31
|
-
placement:
|
|
32
|
-
value:
|
|
33
|
-
maxValue:
|
|
31
|
+
placement: a = "top-right",
|
|
32
|
+
value: r,
|
|
33
|
+
maxValue: s = 99,
|
|
34
34
|
className: u,
|
|
35
35
|
style: f,
|
|
36
36
|
...y
|
|
37
37
|
}) => {
|
|
38
|
-
const e = !
|
|
38
|
+
const e = !r, d = T(e), t = _(null);
|
|
39
39
|
if (w(() => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
) : 0, b = i * (1 - Math.sin(45 * Math.PI / 180)), m = (1 + Math.min(i / r, 1)) * (r / 4);
|
|
40
|
+
d && !e && t.current?.classList.add(c.appear);
|
|
41
|
+
}, [d, e]), l(() => {
|
|
42
|
+
if (!e && a && t.current?.parentElement) {
|
|
43
|
+
const g = t.current.clientHeight, p = t.current.parentElement, i = Math.min(
|
|
44
|
+
parseInt(getComputedStyle(p).getPropertyValue("border-radius")) || 0,
|
|
45
|
+
p.clientHeight / 2
|
|
46
|
+
), b = i * (1 - Math.sin(45 * Math.PI / 180)), m = (1 + Math.min(i / g, 1)) * (g / 4);
|
|
48
47
|
t.current.style.setProperty("--offset", `${b - m}px`);
|
|
49
48
|
}
|
|
50
|
-
}, [e,
|
|
49
|
+
}, [e, a]), e)
|
|
51
50
|
return null;
|
|
52
|
-
const B = typeof
|
|
51
|
+
const B = typeof r == "number" && s > 0 && r > s;
|
|
53
52
|
return /* @__PURE__ */ h(
|
|
54
53
|
"div",
|
|
55
54
|
{
|
|
56
55
|
...y,
|
|
57
56
|
ref: t,
|
|
58
57
|
"data-badge": n,
|
|
59
|
-
"data-placement":
|
|
60
|
-
className: E(
|
|
61
|
-
style: { ...f, ...H({ size:
|
|
62
|
-
children: P(B ? `${
|
|
58
|
+
"data-placement": a,
|
|
59
|
+
className: E(c.badge, c[n], u),
|
|
60
|
+
style: { ...f, ...H({ size: o }) },
|
|
61
|
+
children: P(B ? `${s}+` : r, "span")
|
|
63
62
|
}
|
|
64
63
|
);
|
|
65
64
|
};
|
|
@@ -23,4 +23,4 @@ export declare const Button: <T extends React.ElementType = "button">(props: {
|
|
|
23
23
|
title?: React.ReactNode;
|
|
24
24
|
icon?: React.ReactElement;
|
|
25
25
|
iconPosition?: "start" | "end";
|
|
26
|
-
} & Omit<React.PropsWithoutRef<React.ComponentProps<T>>, "title" | "
|
|
26
|
+
} & Omit<React.PropsWithoutRef<React.ComponentProps<T>>, "title" | "as" | "size" | "icon" | "scheme" | "minWidth" | "maxWidth" | "variant" | "busy" | "iconPosition"> & React.RefAttributes<unknown>) => React.ReactElement | null;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import h, { useState as x, useLayoutEffect as m, useContext as
|
|
2
|
+
import h, { useState as x, useLayoutEffect as m, useContext as p } from "react";
|
|
3
3
|
import s from "classnames";
|
|
4
|
-
import { useFloating as N, useInteractions as
|
|
5
|
-
import { cssProps as
|
|
6
|
-
import { DialogContext as
|
|
7
|
-
import { Button as
|
|
8
|
-
import { Heading as
|
|
9
|
-
import { Icon as
|
|
10
|
-
const
|
|
11
|
-
overlay:
|
|
12
|
-
dialog:
|
|
13
|
-
title:
|
|
4
|
+
import { useFloating as N, useInteractions as P, useDismiss as L, useRole as E, useMergeRefs as S, FloatingPortal as k, FloatingOverlay as M, FloatingFocusManager as O, useId as Q } from "@floating-ui/react";
|
|
5
|
+
import { cssProps as j } from "../../utils/helpers.js";
|
|
6
|
+
import { DialogContext as c } from "./DialogContext.js";
|
|
7
|
+
import { Button as q } from "../Button/Button.js";
|
|
8
|
+
import { Heading as w } from "../Heading/Heading.js";
|
|
9
|
+
import { Icon as B } from "../Icon/Icon.js";
|
|
10
|
+
const G = "Dialog_overlay_C98Qt", H = "Dialog_dialog_G3gxL", J = "Dialog_title_2pDPQ", V = "Dialog_footer_N-aEV", z = "Dialog_close_JSEkn", i = {
|
|
11
|
+
overlay: G,
|
|
12
|
+
dialog: H,
|
|
13
|
+
title: J,
|
|
14
14
|
footer: V,
|
|
15
15
|
close: z
|
|
16
16
|
}, oo = h.forwardRef(
|
|
@@ -19,73 +19,73 @@ const H = "Dialog_overlay_C98Qt", J = "Dialog_dialog_G3gxL", P = "Dialog_title_2
|
|
|
19
19
|
size: e,
|
|
20
20
|
width: a,
|
|
21
21
|
lockScroll: l = !0,
|
|
22
|
-
style:
|
|
23
|
-
className:
|
|
24
|
-
children:
|
|
25
|
-
setTriggerProps:
|
|
26
|
-
requestClose:
|
|
27
|
-
...
|
|
28
|
-
},
|
|
29
|
-
const [
|
|
22
|
+
style: r,
|
|
23
|
+
className: y,
|
|
24
|
+
children: v,
|
|
25
|
+
setTriggerProps: d,
|
|
26
|
+
requestClose: g,
|
|
27
|
+
...D
|
|
28
|
+
}, _) => {
|
|
29
|
+
const [u, b] = x(), { refs: F, context: n } = N({
|
|
30
30
|
open: o,
|
|
31
|
-
onOpenChange:
|
|
32
|
-
}), { getFloatingProps: C, getReferenceProps:
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
onOpenChange: g
|
|
32
|
+
}), { getFloatingProps: C, getReferenceProps: f } = P([
|
|
33
|
+
L(n),
|
|
34
|
+
E(n, { role: "dialog" })
|
|
35
35
|
]);
|
|
36
36
|
m(() => {
|
|
37
|
-
|
|
38
|
-
}, [
|
|
39
|
-
const I =
|
|
40
|
-
return o ? /* @__PURE__ */ t(
|
|
41
|
-
|
|
37
|
+
d?.(f());
|
|
38
|
+
}, [d, f]);
|
|
39
|
+
const I = S([F.setFloating, _]), R = document.querySelector("[data-floating-root]") ?? document.body;
|
|
40
|
+
return o ? /* @__PURE__ */ t(c.Provider, { value: { labelId: u, setLabelId: b, requestClose: g }, children: /* @__PURE__ */ t(k, { root: R, children: /* @__PURE__ */ t(
|
|
41
|
+
M,
|
|
42
42
|
{
|
|
43
43
|
"data-floating-root": !0,
|
|
44
44
|
"data-dialog-overlay": !0,
|
|
45
45
|
lockScroll: l,
|
|
46
|
-
className:
|
|
47
|
-
children: /* @__PURE__ */ t(
|
|
46
|
+
className: i.overlay,
|
|
47
|
+
children: /* @__PURE__ */ t(O, { context: n, children: /* @__PURE__ */ t(
|
|
48
48
|
"div",
|
|
49
49
|
{
|
|
50
|
-
...C(
|
|
50
|
+
...C(D),
|
|
51
51
|
ref: I,
|
|
52
52
|
"data-dialog": !0,
|
|
53
53
|
"data-open": o,
|
|
54
|
-
"aria-labelledby":
|
|
55
|
-
className: s(
|
|
56
|
-
style: { ...
|
|
57
|
-
children:
|
|
54
|
+
"aria-labelledby": u,
|
|
55
|
+
className: s(i.dialog, y),
|
|
56
|
+
style: { ...r, ...j({ size: e, width: a }) },
|
|
57
|
+
children: v
|
|
58
58
|
}
|
|
59
59
|
) })
|
|
60
60
|
}
|
|
61
61
|
) }) }) : null;
|
|
62
62
|
}
|
|
63
63
|
), to = ({ className: o, children: e, ...a }) => {
|
|
64
|
-
const l =
|
|
65
|
-
return m(() => (
|
|
66
|
-
|
|
64
|
+
const l = Q(), { setLabelId: r } = p(c);
|
|
65
|
+
return m(() => (r(l), () => r(void 0)), [l, r]), /* @__PURE__ */ t(
|
|
66
|
+
w,
|
|
67
67
|
{
|
|
68
68
|
as: "h4",
|
|
69
69
|
...a,
|
|
70
70
|
id: l,
|
|
71
71
|
"data-dialog-title": !0,
|
|
72
72
|
title: e,
|
|
73
|
-
className: s(
|
|
73
|
+
className: s(i.title, o)
|
|
74
74
|
}
|
|
75
75
|
);
|
|
76
|
-
}, eo = (o) => /* @__PURE__ */ t("div", { ...o, "data-dialog-content": !0 }), ao = ({ className: o, ...e }) => /* @__PURE__ */ t("div", { ...e, "data-dialog-footer": !0, className: s(
|
|
77
|
-
const { requestClose: a } =
|
|
76
|
+
}, eo = (o) => /* @__PURE__ */ t("div", { ...o, "data-dialog-content": !0 }), ao = ({ className: o, ...e }) => /* @__PURE__ */ t("div", { ...e, "data-dialog-footer": !0, className: s(i.footer, o) }), lo = ({ className: o, ...e }) => {
|
|
77
|
+
const { requestClose: a } = p(c);
|
|
78
78
|
return /* @__PURE__ */ t(
|
|
79
|
-
|
|
79
|
+
q,
|
|
80
80
|
{
|
|
81
81
|
type: "button",
|
|
82
82
|
variant: "tertiary",
|
|
83
83
|
"aria-label": "close dialog",
|
|
84
|
-
icon: /* @__PURE__ */ t(
|
|
84
|
+
icon: /* @__PURE__ */ t(B, { name: "close" }),
|
|
85
85
|
onClick: a,
|
|
86
86
|
...e,
|
|
87
87
|
"data-dialog-close": !0,
|
|
88
|
-
className: s(
|
|
88
|
+
className: s(i.close, o)
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
91
|
};
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
type DialogShowOptions<R> = {
|
|
2
|
+
onConfirm?: (values: R) => void;
|
|
3
|
+
onCancel?: () => void;
|
|
4
|
+
};
|
|
5
|
+
export type DialogOptions<T, R> = DialogShowOptions<R> & {
|
|
2
6
|
defaultOpen?: boolean;
|
|
3
7
|
onShow?: (values: T) => void;
|
|
4
|
-
onConfirm?: (result: R) => void;
|
|
5
|
-
onCancel?: () => void;
|
|
6
8
|
};
|
|
7
9
|
export type DialogType<T, R> = ReturnType<typeof useDialog<T, R>>;
|
|
8
10
|
export declare function useDialog<T, R>(options?: DialogOptions<T, R>): {
|
|
9
11
|
props: {
|
|
10
|
-
ref: import('react').RefObject<HTMLDivElement>;
|
|
12
|
+
ref: import('react').RefObject<HTMLDivElement | null>;
|
|
11
13
|
open: boolean;
|
|
12
14
|
setTriggerProps: import('react').Dispatch<import('react').SetStateAction<{}>>;
|
|
13
15
|
requestClose: () => void;
|
|
14
16
|
};
|
|
15
17
|
trigger: {
|
|
16
|
-
onClick: (values: T) => void;
|
|
18
|
+
onClick: (values: T, showOptions?: DialogShowOptions<R>) => void;
|
|
17
19
|
};
|
|
18
20
|
data: T | undefined;
|
|
19
|
-
show: (values: T) => void;
|
|
21
|
+
show: (values: T, showOptions?: DialogShowOptions<R>) => void;
|
|
20
22
|
cancel: () => void;
|
|
21
23
|
confirm: (values: R) => void;
|
|
22
24
|
preventClose: <T_1>(promise: Promise<T_1>) => Promise<T_1>;
|
|
23
25
|
};
|
|
26
|
+
export {};
|
|
@@ -1,40 +1,32 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const g = o((e) => {
|
|
12
|
-
var n, s;
|
|
13
|
-
t.current || (p(!0), d(e), (s = (n = c.current) == null ? void 0 : n.onShow) == null || s.call(n, e));
|
|
14
|
-
}, []), u = o((e) => {
|
|
15
|
-
var n;
|
|
16
|
-
t.current || (t.current = !0, (n = a.current) == null || n.setAttribute("data-open", "false"), T(a.current, () => {
|
|
17
|
-
var s, C, i, y;
|
|
18
|
-
e !== void 0 ? (C = (s = c.current) == null ? void 0 : s.onConfirm) == null || C.call(s, e) : (y = (i = c.current) == null ? void 0 : i.onCancel) == null || y.call(i), p(!1), d(void 0), t.current = !1;
|
|
1
|
+
import { useRef as c, useState as f, useCallback as t } from "react";
|
|
2
|
+
import { afterTransition as v } from "../../utils/helpers.js";
|
|
3
|
+
function S(s) {
|
|
4
|
+
const u = c(null), e = c(!1), n = c(s), a = c(void 0), [d, g] = f({}), [m, i] = f(s?.defaultOpen ?? !1), [w, l] = f();
|
|
5
|
+
n.current = s;
|
|
6
|
+
const p = t((r, h = {}) => {
|
|
7
|
+
e.current || (a.current = h, i(!0), l(r), n.current?.onShow?.(r));
|
|
8
|
+
}, []), o = t((r) => {
|
|
9
|
+
e.current || (e.current = !0, u.current?.setAttribute("data-open", "false"), v(u.current, () => {
|
|
10
|
+
r !== void 0 ? (n.current?.onConfirm?.(r), a.current?.onConfirm?.(r)) : (n.current?.onCancel?.(), a.current?.onCancel?.()), i(!1), l(void 0), e.current = !1;
|
|
19
11
|
}));
|
|
20
|
-
}, []),
|
|
21
|
-
|
|
12
|
+
}, []), C = t(() => o(), [o]), O = t((r) => o(r), [o]), b = t(async (r) => {
|
|
13
|
+
e.current = !0;
|
|
22
14
|
try {
|
|
23
|
-
return await
|
|
15
|
+
return await r;
|
|
24
16
|
} finally {
|
|
25
|
-
|
|
17
|
+
e.current = !1;
|
|
26
18
|
}
|
|
27
19
|
}, []);
|
|
28
20
|
return {
|
|
29
|
-
props: { ref:
|
|
30
|
-
trigger: { ...
|
|
21
|
+
props: { ref: u, open: m, setTriggerProps: g, requestClose: C },
|
|
22
|
+
trigger: { ...d, onClick: p },
|
|
31
23
|
data: w,
|
|
32
|
-
show:
|
|
33
|
-
cancel:
|
|
24
|
+
show: p,
|
|
25
|
+
cancel: C,
|
|
34
26
|
confirm: O,
|
|
35
|
-
preventClose:
|
|
27
|
+
preventClose: b
|
|
36
28
|
};
|
|
37
29
|
}
|
|
38
30
|
export {
|
|
39
|
-
|
|
31
|
+
S as useDialog
|
|
40
32
|
};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { jsxs as h, jsx as
|
|
1
|
+
import { jsxs as h, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import i from "classnames";
|
|
3
|
-
import
|
|
3
|
+
import k, { useRef as x, useImperativeHandle as b, useEffect as p } from "react";
|
|
4
4
|
import { cssProps as R } from "../../utils/helpers.js";
|
|
5
|
-
import { I as y, s
|
|
6
|
-
const
|
|
7
|
-
({ size:
|
|
8
|
-
const
|
|
9
|
-
return b(
|
|
10
|
-
|
|
11
|
-
}, [e,
|
|
5
|
+
import { I as y, s } from "../../Input-BG84zXZH.js";
|
|
6
|
+
const _ = k.forwardRef(
|
|
7
|
+
({ size: t, error: u, label: a, className: f, style: n, required: d, indeterminate: c, ...r }, m) => {
|
|
8
|
+
const l = r.checked || r.defaultChecked, e = x(null);
|
|
9
|
+
return b(m, () => e.current), p(() => {
|
|
10
|
+
c != null && e.current != null && (e.current.indeterminate = !l && c);
|
|
11
|
+
}, [e, c, l]), /* @__PURE__ */ h(
|
|
12
12
|
"label",
|
|
13
13
|
{
|
|
14
14
|
"data-checkbox": !0,
|
|
15
|
-
"data-required":
|
|
16
|
-
className: i(
|
|
17
|
-
style: { ...
|
|
15
|
+
"data-required": d,
|
|
16
|
+
className: i(s.checkbox, f),
|
|
17
|
+
style: { ...n, ...R({ size: t }) },
|
|
18
18
|
children: [
|
|
19
|
-
/* @__PURE__ */
|
|
20
|
-
|
|
19
|
+
/* @__PURE__ */ o(y, { ...r, ref: e, type: "checkbox", size: t, error: u }),
|
|
20
|
+
a && /* @__PURE__ */ o("div", { "data-checkbox-label": !0, className: s.label, children: a })
|
|
21
21
|
]
|
|
22
22
|
}
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
);
|
|
26
26
|
export {
|
|
27
|
-
|
|
27
|
+
_ as Checkbox
|
|
28
28
|
};
|
|
@@ -1,56 +1,54 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Icon as
|
|
5
|
-
import { Button as
|
|
1
|
+
import { jsxs as p, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import b from "classnames";
|
|
3
|
+
import f, { useRef as y, useImperativeHandle as _, useCallback as a } from "react";
|
|
4
|
+
import { Icon as c } from "../Icon/Icon.js";
|
|
5
|
+
import { Button as s } from "../Button/Button.js";
|
|
6
6
|
import "../../utils/helpers.js";
|
|
7
|
-
import { I as
|
|
8
|
-
const
|
|
9
|
-
numeric:
|
|
10
|
-
increase:
|
|
11
|
-
decrease:
|
|
12
|
-
},
|
|
13
|
-
({ labelIncrease:
|
|
14
|
-
const e =
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var r, t;
|
|
21
|
-
(r = e.current) == null || r.stepDown(), (t = e.current) == null || t.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
7
|
+
import { I as h } from "../../Input-BG84zXZH.js";
|
|
8
|
+
const v = "styles_numeric_dzUSE", w = "styles_increase_5S-Jo", E = "styles_decrease_j8UR6", t = {
|
|
9
|
+
numeric: v,
|
|
10
|
+
increase: w,
|
|
11
|
+
decrease: E
|
|
12
|
+
}, k = f.forwardRef(
|
|
13
|
+
({ labelIncrease: i = "increase", labelDecrease: o = "decrease", className: l, ...n }, d) => {
|
|
14
|
+
const e = y(null);
|
|
15
|
+
_(d, () => e.current);
|
|
16
|
+
const u = a(() => {
|
|
17
|
+
e.current?.stepUp(), e.current?.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
18
|
+
}, []), m = a(() => {
|
|
19
|
+
e.current?.stepDown(), e.current?.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
22
20
|
}, []);
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
|
|
21
|
+
return /* @__PURE__ */ p(
|
|
22
|
+
h,
|
|
25
23
|
{
|
|
26
24
|
...n,
|
|
27
25
|
ref: e,
|
|
28
26
|
type: "number",
|
|
29
27
|
wrapperType: "numeric",
|
|
30
|
-
className:
|
|
28
|
+
className: b(t.numeric, l),
|
|
31
29
|
children: [
|
|
32
|
-
/* @__PURE__ */
|
|
33
|
-
|
|
30
|
+
/* @__PURE__ */ r(
|
|
31
|
+
s,
|
|
34
32
|
{
|
|
35
33
|
type: "button",
|
|
36
34
|
variant: "secondary",
|
|
37
|
-
"aria-label":
|
|
35
|
+
"aria-label": i,
|
|
38
36
|
disabled: n.disabled || n.readOnly,
|
|
39
|
-
className:
|
|
40
|
-
icon: /* @__PURE__ */
|
|
41
|
-
onClick:
|
|
37
|
+
className: t.increase,
|
|
38
|
+
icon: /* @__PURE__ */ r(c, { name: "triangle-up" }),
|
|
39
|
+
onClick: u
|
|
42
40
|
}
|
|
43
41
|
),
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
|
|
42
|
+
/* @__PURE__ */ r(
|
|
43
|
+
s,
|
|
46
44
|
{
|
|
47
45
|
type: "button",
|
|
48
46
|
variant: "secondary",
|
|
49
|
-
"aria-label":
|
|
47
|
+
"aria-label": o,
|
|
50
48
|
disabled: n.disabled || n.readOnly,
|
|
51
|
-
className:
|
|
52
|
-
icon: /* @__PURE__ */
|
|
53
|
-
onClick:
|
|
49
|
+
className: t.decrease,
|
|
50
|
+
icon: /* @__PURE__ */ r(c, { name: "triangle-down" }),
|
|
51
|
+
onClick: m
|
|
54
52
|
}
|
|
55
53
|
)
|
|
56
54
|
]
|
|
@@ -59,5 +57,5 @@ const E = "styles_numeric_dzUSE", R = "styles_increase_5S-Jo", g = "styles_decre
|
|
|
59
57
|
}
|
|
60
58
|
);
|
|
61
59
|
export {
|
|
62
|
-
|
|
60
|
+
k as Numeric
|
|
63
61
|
};
|
|
@@ -10,7 +10,7 @@ export type RangeProps = Omit<BaseInputProps, 'min' | 'max' | 'value' | 'default
|
|
|
10
10
|
defaultValue?: number;
|
|
11
11
|
ticks?: TickMarksProps['ticks'];
|
|
12
12
|
};
|
|
13
|
-
export declare const Range: React.ForwardRefExoticComponent<Omit<BaseInputProps, "
|
|
13
|
+
export declare const Range: React.ForwardRefExoticComponent<Omit<BaseInputProps, "defaultValue" | "value" | "max" | "min"> & {
|
|
14
14
|
min?: number;
|
|
15
15
|
max?: number;
|
|
16
16
|
value?: number;
|