@bioturing/components 0.36.0 → 0.37.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/button/component.d.ts +1 -1
- package/dist/components/button/component.d.ts.map +1 -1
- package/dist/components/button/component.js +42 -35
- package/dist/components/button/component.js.map +1 -1
- package/dist/components/button/style.css +1 -1
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/modal/Modal.js +105 -102
- package/dist/components/modal/Modal.js.map +1 -1
- package/dist/components/toast/function.js +11 -11
- package/dist/components/toast/function.js.map +1 -1
- package/dist/components/toast/style.css +1 -1
- package/dist/components/truncate/component.d.ts +7 -0
- package/dist/components/truncate/component.d.ts.map +1 -1
- package/dist/components/truncate/component.js +57 -48
- package/dist/components/truncate/component.js.map +1 -1
- package/dist/components/truncate/helpers.d.ts +8 -2
- package/dist/components/truncate/helpers.d.ts.map +1 -1
- package/dist/components/truncate/helpers.js +82 -54
- package/dist/components/truncate/helpers.js.map +1 -1
- package/dist/stats.html +1 -1
- package/package.json +2 -2
|
@@ -6,7 +6,7 @@ export interface ButtonProps extends AntdButtonProps {
|
|
|
6
6
|
*/
|
|
7
7
|
negativeMargin?: boolean;
|
|
8
8
|
}
|
|
9
|
-
declare const ButtonInner: ({ negativeMargin, type, size, variant, icon, ...rest }: ButtonProps, ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const ButtonInner: ({ negativeMargin, type, size, variant, icon, loading, classNames, ...rest }: ButtonProps, ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export declare const Button: (props: ButtonProps & {
|
|
11
11
|
ref?: React.ForwardedRef<HTMLButtonElement | HTMLAnchorElement>;
|
|
12
12
|
}) => ReturnType<typeof ButtonInner>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/button/component.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,WAAW,IAAI,eAAe,EACpC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/button/component.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,WAAW,IAAI,eAAe,EACpC,MAAM,gBAAgB,CAAC;AAOxB,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,QAAA,MAAM,WAAW,GACf,6EASG,WAAW,EACd,KAAK,KAAK,CAAC,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,4CA2CtD,CAAC;AAEF,eAAO,MAAM,MAAM,EAA8B,CAC/C,KAAK,EAAE,WAAW,GAAG;IACnB,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,CAAC;CACjE,KACE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -1,46 +1,53 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import
|
|
4
|
-
import { forwardRef as
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import f from "antd/es/button";
|
|
4
|
+
import { forwardRef as d } from "react";
|
|
5
|
+
import { CircleNotchIcon as b } from "@bioturing/assets";
|
|
5
6
|
import './style.css';/* empty css */
|
|
6
|
-
import { useCls as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import { useCls as g } from "../utils/antdUtils.js";
|
|
8
|
+
import { cn as w } from "../utils/cn.js";
|
|
9
|
+
const N = ({
|
|
10
|
+
negativeMargin: m = !0,
|
|
11
|
+
type: t,
|
|
12
|
+
size: e,
|
|
13
|
+
variant: n,
|
|
14
|
+
icon: i,
|
|
15
|
+
loading: c,
|
|
16
|
+
classNames: p,
|
|
17
|
+
...a
|
|
18
|
+
}, l) => {
|
|
19
|
+
const u = m && (n === "text" || n === "link" || t == "text" || t === "link"), o = g(), s = /* @__PURE__ */ r(
|
|
20
|
+
f,
|
|
21
|
+
{
|
|
22
|
+
ref: l,
|
|
23
|
+
type: t,
|
|
24
|
+
size: e,
|
|
25
|
+
variant: n,
|
|
26
|
+
icon: i,
|
|
27
|
+
loading: c && {
|
|
28
|
+
icon: /* @__PURE__ */ r(b, {})
|
|
29
|
+
},
|
|
30
|
+
className: w(i && o("btn-with-icon")),
|
|
31
|
+
classNames: {
|
|
32
|
+
icon: c ? o("btn-loading-icon") : void 0,
|
|
33
|
+
...p
|
|
34
|
+
},
|
|
35
|
+
...a
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
return u ? /* @__PURE__ */ r(
|
|
10
39
|
"span",
|
|
11
40
|
{
|
|
12
|
-
className:
|
|
41
|
+
className: o(
|
|
13
42
|
"btn-wrapper",
|
|
14
43
|
"btn-negative-margin-wrapper",
|
|
15
|
-
"btn-wrapper-" +
|
|
44
|
+
"btn-wrapper-" + e
|
|
16
45
|
),
|
|
17
|
-
children:
|
|
18
|
-
a,
|
|
19
|
-
{
|
|
20
|
-
ref: p,
|
|
21
|
-
type: t,
|
|
22
|
-
size: o,
|
|
23
|
-
variant: n,
|
|
24
|
-
icon: r,
|
|
25
|
-
className: r ? e("btn-with-icon") : "",
|
|
26
|
-
...m
|
|
27
|
-
}
|
|
28
|
-
)
|
|
46
|
+
children: s
|
|
29
47
|
}
|
|
30
|
-
) :
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
ref: p,
|
|
34
|
-
type: t,
|
|
35
|
-
size: o,
|
|
36
|
-
variant: n,
|
|
37
|
-
icon: r,
|
|
38
|
-
className: r ? e("btn-with-icon") : "",
|
|
39
|
-
...m
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
}, d = l(w);
|
|
48
|
+
) : s;
|
|
49
|
+
}, v = d(N);
|
|
43
50
|
export {
|
|
44
|
-
|
|
51
|
+
v as Button
|
|
45
52
|
};
|
|
46
53
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/button/component.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n default as AntdButton,\n type ButtonProps as AntdButtonProps,\n} from \"antd/es/button\";\nimport { forwardRef } from \"react\";\n\n// Import component-specific styles\nimport { useCls } from \"../utils\";\nimport \"./style.css\";\n\nexport interface ButtonProps extends AntdButtonProps {\n /**\n * If true, negative margin will be applied to the text and link buttons to make it align with content\n * @default true\n */\n negativeMargin?: boolean;\n}\n\nconst ButtonInner = (\n {
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/button/component.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n default as AntdButton,\n type ButtonProps as AntdButtonProps,\n} from \"antd/es/button\";\nimport { forwardRef } from \"react\";\n\n// Import component-specific styles\nimport { useCls } from \"../utils\";\nimport { cn } from \"../utils\";\nimport { CircleNotchIcon } from \"@bioturing/assets\";\nimport \"./style.css\";\n\nexport interface ButtonProps extends AntdButtonProps {\n /**\n * If true, negative margin will be applied to the text and link buttons to make it align with content\n * @default true\n */\n negativeMargin?: boolean;\n}\n\nconst ButtonInner = (\n {\n negativeMargin = true,\n type,\n size,\n variant,\n icon,\n loading,\n classNames,\n ...rest\n }: ButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) => {\n const useNegativeMargin =\n negativeMargin &&\n (variant === \"text\" ||\n variant === \"link\" ||\n type == \"text\" ||\n type === \"link\");\n const cls = useCls();\n // const iconNode = loading ? <Spin /> : icon;\n const renderedButton = (\n <AntdButton\n ref={ref}\n type={type}\n size={size}\n variant={variant}\n icon={icon}\n loading={\n loading && {\n icon: <CircleNotchIcon />,\n }\n }\n className={cn(icon && cls(\"btn-with-icon\"))}\n classNames={{\n icon: loading ? cls(\"btn-loading-icon\") : undefined,\n ...classNames,\n }}\n {...rest}\n />\n );\n return useNegativeMargin ? (\n <span\n className={cls(\n \"btn-wrapper\",\n \"btn-negative-margin-wrapper\",\n \"btn-wrapper-\" + size\n )}\n >\n {renderedButton}\n </span>\n ) : (\n renderedButton\n );\n};\n\nexport const Button = forwardRef(ButtonInner) as (\n props: ButtonProps & {\n ref?: React.ForwardedRef<HTMLButtonElement | HTMLAnchorElement>;\n }\n) => ReturnType<typeof ButtonInner>;\n"],"names":["ButtonInner","negativeMargin","type","size","variant","icon","loading","classNames","rest","ref","useNegativeMargin","cls","useCls","renderedButton","jsx","AntdButton","CircleNotchIcon","cn","Button","forwardRef"],"mappings":";;;;;;;;AAsBA,MAAMA,IAAc,CAClB;AAAA,EACE,gBAAAC,IAAiB;AAAA,EACjB,MAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,YAAAC;AAAA,EACA,GAAGC;AACL,GACAC,MACG;AACH,QAAMC,IACJT,MACCG,MAAY,UACXA,MAAY,UACZF,KAAQ,UACRA,MAAS,SACPS,IAAMC,EAAA,GAENC,IACJ,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAAN;AAAA,MACA,MAAAP;AAAA,MACA,MAAAC;AAAA,MACA,SAAAC;AAAA,MACA,MAAAC;AAAA,MACA,SACEC,KAAW;AAAA,QACT,wBAAOU,GAAA,CAAA,CAAgB;AAAA,MAAA;AAAA,MAG3B,WAAWC,EAAGZ,KAAQM,EAAI,eAAe,CAAC;AAAA,MAC1C,YAAY;AAAA,QACV,MAAML,IAAUK,EAAI,kBAAkB,IAAI;AAAA,QAC1C,GAAGJ;AAAA,MAAA;AAAA,MAEJ,GAAGC;AAAA,IAAA;AAAA,EAAA;AAGR,SAAOE,IACL,gBAAAI;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWH;AAAA,QACT;AAAA,QACA;AAAA,QACA,iBAAiBR;AAAA,MAAA;AAAA,MAGlB,UAAAU;AAAA,IAAA;AAAA,EAAA,IAGHA;AAEJ,GAEaK,IAASC,EAAWnB,CAAW;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{span.ds-btn-icon{display:flex;align-items:center}.ds-btn-negative-margin-wrapper{display:inline-flex;flex-shrink:0}.ds-btn-negative-margin-wrapper,.ds-btn-negative-margin-wrapper.ds-btn-wrapper-lg{margin-inline:-1rem}.ds-btn-negative-margin-wrapper.ds-btn-wrapper-sm{margin-inline:-.5rem}.ds-btn-loading:not(.ds-btn-with-icon) .ds-btn-loading-icon{position:absolute}.ds-btn-loading:not(.ds-btn-with-icon)>*:not(.ds-btn-loading-icon){opacity:0}}
|
|
1
|
+
@layer components{span.ds-btn-icon{display:flex;align-items:center}.ds-btn-negative-margin-wrapper{display:inline-flex;flex-shrink:0}.ds-btn-negative-margin-wrapper,.ds-btn-negative-margin-wrapper.ds-btn-wrapper-lg{margin-inline:-1rem}.ds-btn-negative-margin-wrapper.ds-btn-wrapper-sm{margin-inline:-.5rem}.ds-btn-loading-icon svg{animation:spin 1s linear infinite}.ds-btn-loading:not(.ds-btn-with-icon) .ds-btn-loading-icon{position:absolute}.ds-btn-loading:not(.ds-btn-with-icon)>*:not(.ds-btn-loading-icon){opacity:0}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,UAAU,IAAI,aAAa,EACjC,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAmD,MAAM,OAAO,CAAC;AASxE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC;IACjE;;;;;;;;;OASG;IACH,IAAI,CAAC,EACD,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,SAAS,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R,OAAO,GACP,QAAQ,GACR,SAAS,GACT,YAAY,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAC3C;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B;;OAEG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAGD,eAAO,MAAM,KAAK,GAAI,ibAkCnB,UAAU,4CA6NZ,CAAC"}
|
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import
|
|
4
|
-
import { XIcon as
|
|
5
|
-
import { useState as
|
|
6
|
-
import { ModalContextProvider as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { getConfirmLocale as
|
|
10
|
-
import { useLocale as
|
|
11
|
-
import { ModalSize as
|
|
2
|
+
import { jsx as o, jsxs as c, Fragment as H } from "react/jsx-runtime";
|
|
3
|
+
import pe from "antd/es/modal";
|
|
4
|
+
import { XIcon as he } from "@bioturing/assets";
|
|
5
|
+
import { useState as R, useRef as ye, useCallback as be, useEffect as Ce } from "react";
|
|
6
|
+
import { ModalContextProvider as ve } from "antd/es/modal/context";
|
|
7
|
+
import j from "antd/es/modal/components/NormalCancelBtn";
|
|
8
|
+
import E from "antd/es/modal/components/NormalOkBtn";
|
|
9
|
+
import { getConfirmLocale as ge } from "antd/es/modal/locale";
|
|
10
|
+
import { useLocale as ke } from "antd/es/locale";
|
|
11
|
+
import { ModalSize as m } from "./constants.js";
|
|
12
12
|
import { Stack as f } from "../stack/index.js";
|
|
13
|
-
import { Truncate as
|
|
14
|
-
import { IconButton as
|
|
15
|
-
import { useCls as
|
|
16
|
-
import { useTheme as
|
|
17
|
-
import { clsx as
|
|
18
|
-
const
|
|
13
|
+
import { Truncate as we } from "../truncate/component.js";
|
|
14
|
+
import { IconButton as xe } from "../icon-button/component.js";
|
|
15
|
+
import { useCls as Oe } from "../utils/antdUtils.js";
|
|
16
|
+
import { useTheme as ze } from "../theme-provider/context/themeStore.js";
|
|
17
|
+
import { clsx as Be } from "../utils/cn.js";
|
|
18
|
+
const Je = ({
|
|
19
19
|
open: u,
|
|
20
20
|
closeIcon: p,
|
|
21
|
-
children:
|
|
22
|
-
size:
|
|
21
|
+
children: F,
|
|
22
|
+
size: L,
|
|
23
23
|
footer: h,
|
|
24
|
-
width:
|
|
25
|
-
style:
|
|
24
|
+
width: P,
|
|
25
|
+
style: W,
|
|
26
26
|
styles: y,
|
|
27
|
-
classNames:
|
|
28
|
-
okButtonProps:
|
|
29
|
-
cancelButtonProps:
|
|
30
|
-
loading:
|
|
27
|
+
classNames: $,
|
|
28
|
+
okButtonProps: q,
|
|
29
|
+
cancelButtonProps: A,
|
|
30
|
+
loading: X,
|
|
31
31
|
onOk: b,
|
|
32
|
-
onCancel:
|
|
33
|
-
okText:
|
|
34
|
-
okType:
|
|
35
|
-
confirmLoading:
|
|
36
|
-
cancelText:
|
|
32
|
+
onCancel: C,
|
|
33
|
+
okText: v,
|
|
34
|
+
okType: D = "primary",
|
|
35
|
+
confirmLoading: s,
|
|
36
|
+
cancelText: g = "Close",
|
|
37
37
|
hideOkButton: k = !1,
|
|
38
38
|
hideCancelButton: w = !1,
|
|
39
39
|
contentPadding: r,
|
|
40
40
|
title: i,
|
|
41
41
|
afterTitle: x,
|
|
42
|
-
beforeCloseButton:
|
|
43
|
-
afterCloseButton:
|
|
44
|
-
defaultFixedHeaderFooter:
|
|
45
|
-
centered:
|
|
46
|
-
type:
|
|
47
|
-
defaultOpen:
|
|
48
|
-
background:
|
|
49
|
-
bodyScrollable:
|
|
50
|
-
rootClassName:
|
|
51
|
-
...
|
|
42
|
+
beforeCloseButton: G,
|
|
43
|
+
afterCloseButton: J,
|
|
44
|
+
defaultFixedHeaderFooter: K = !1,
|
|
45
|
+
centered: Q = !0,
|
|
46
|
+
type: U = "default",
|
|
47
|
+
defaultOpen: V = !0,
|
|
48
|
+
background: Y,
|
|
49
|
+
bodyScrollable: Z = !0,
|
|
50
|
+
rootClassName: _,
|
|
51
|
+
...ee
|
|
52
52
|
}) => {
|
|
53
|
-
const
|
|
54
|
-
"--ds-modal-bg": `var(--ds-color-bg-${
|
|
55
|
-
...
|
|
53
|
+
const oe = p === void 0 ? /* @__PURE__ */ o(he, { size: 16, weight: "bold" }) : p, t = L || (U === "default" ? "medium" : "xsmall"), re = P || m[t], te = {
|
|
54
|
+
"--ds-modal-bg": `var(--ds-color-bg-${Y || (t in m && parseInt(m[t]) <= parseInt(m.medium) ? "elevated" : "container")})`,
|
|
55
|
+
...W,
|
|
56
56
|
...t === "fullscreen" ? { top: 0, maxWidth: "100%", height: "100%" } : {}
|
|
57
|
-
},
|
|
57
|
+
}, le = {
|
|
58
58
|
...y,
|
|
59
59
|
body: {
|
|
60
60
|
...typeof r < "u" ? {
|
|
@@ -62,105 +62,108 @@ const Ge = ({
|
|
|
62
62
|
} : {},
|
|
63
63
|
...y?.body
|
|
64
64
|
}
|
|
65
|
-
}, [O, z] =
|
|
66
|
-
(
|
|
67
|
-
if (!
|
|
68
|
-
const l =
|
|
65
|
+
}, [O, z] = R(!1), n = Oe(), { className: ne } = ze(), a = ye(null), se = be(
|
|
66
|
+
(e) => {
|
|
67
|
+
if (!e) return;
|
|
68
|
+
const l = e.querySelector("." + n("modal-body"));
|
|
69
69
|
if (!(l instanceof HTMLElement)) return;
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
z(
|
|
70
|
+
const T = new ResizeObserver(() => {
|
|
71
|
+
const ue = l.scrollHeight > l.clientHeight;
|
|
72
|
+
z(ue);
|
|
73
73
|
});
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
z(
|
|
74
|
+
a.current = T, T.observe(l);
|
|
75
|
+
const fe = l.scrollHeight > l.clientHeight;
|
|
76
|
+
z(fe);
|
|
77
77
|
},
|
|
78
78
|
[n]
|
|
79
79
|
);
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
Ce(() => () => {
|
|
81
|
+
a.current && (a.current.disconnect(), a.current = null);
|
|
82
82
|
}, []);
|
|
83
|
-
const [B] =
|
|
84
|
-
loading:
|
|
85
|
-
...$
|
|
86
|
-
}, M = {
|
|
83
|
+
const [B] = ke("Modal", ge()), ae = v || B?.okText, ce = g || B?.cancelText, I = {
|
|
84
|
+
// loading: typeof confirmLoading === "boolean" ? confirmLoading : loading,
|
|
87
85
|
...q
|
|
88
|
-
},
|
|
89
|
-
|
|
86
|
+
}, M = {
|
|
87
|
+
...A
|
|
88
|
+
}, [me, N] = R(V), d = typeof u > "u", ie = d ? me : u, S = (e) => {
|
|
89
|
+
s || C?.(e);
|
|
90
|
+
}, de = /* @__PURE__ */ o(
|
|
91
|
+
ve,
|
|
90
92
|
{
|
|
91
93
|
value: {
|
|
92
94
|
okButtonProps: I,
|
|
93
95
|
cancelButtonProps: M,
|
|
94
|
-
onCancel:
|
|
96
|
+
onCancel: S,
|
|
95
97
|
onOk: b,
|
|
96
|
-
okType:
|
|
97
|
-
confirmLoading:
|
|
98
|
-
okTextLocale:
|
|
99
|
-
cancelTextLocale:
|
|
98
|
+
okType: D,
|
|
99
|
+
confirmLoading: s,
|
|
100
|
+
okTextLocale: ae,
|
|
101
|
+
cancelTextLocale: ce
|
|
100
102
|
},
|
|
101
|
-
children: k ? /* @__PURE__ */
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
/* @__PURE__ */
|
|
103
|
+
children: k ? /* @__PURE__ */ o(j, {}) : w ? /* @__PURE__ */ o(E, {}) : /* @__PURE__ */ c(H, { children: [
|
|
104
|
+
/* @__PURE__ */ o(j, {}),
|
|
105
|
+
/* @__PURE__ */ o(E, {})
|
|
104
106
|
] })
|
|
105
107
|
}
|
|
106
108
|
);
|
|
107
|
-
return /* @__PURE__ */
|
|
108
|
-
|
|
109
|
+
return /* @__PURE__ */ o(
|
|
110
|
+
pe,
|
|
109
111
|
{
|
|
110
112
|
closeIcon: !1,
|
|
111
|
-
open:
|
|
112
|
-
width:
|
|
113
|
-
style:
|
|
114
|
-
title: /* @__PURE__ */
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
/* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
|
|
113
|
+
open: ie,
|
|
114
|
+
width: re,
|
|
115
|
+
style: te,
|
|
116
|
+
title: /* @__PURE__ */ c(H, { children: [
|
|
117
|
+
/* @__PURE__ */ c(f, { align: "center", gap: 8, className: n("modal-title-wrapper"), children: [
|
|
118
|
+
/* @__PURE__ */ o(f.Child, { grow: !0, children: typeof i == "string" ? /* @__PURE__ */ o(we, { children: i }) : i }),
|
|
119
|
+
/* @__PURE__ */ c(f.Child, { stack: !0, hug: !0, align: "center", gap: 8, children: [
|
|
120
|
+
G,
|
|
121
|
+
/* @__PURE__ */ o(
|
|
122
|
+
xe,
|
|
121
123
|
{
|
|
122
|
-
onClick: (
|
|
123
|
-
children:
|
|
124
|
+
onClick: (e) => S(e),
|
|
125
|
+
children: oe
|
|
124
126
|
}
|
|
125
127
|
),
|
|
126
|
-
|
|
128
|
+
J
|
|
127
129
|
] })
|
|
128
130
|
] }),
|
|
129
131
|
x || null
|
|
130
132
|
] }),
|
|
131
|
-
rootClassName:
|
|
133
|
+
rootClassName: Be(ne, _),
|
|
132
134
|
classNames: {
|
|
133
|
-
|
|
135
|
+
...$,
|
|
134
136
|
wrapper: n(
|
|
135
137
|
"modal-wrap",
|
|
136
138
|
t == "fullscreen" && "modal-fullscreen",
|
|
137
139
|
O && "modal-content-overflow",
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
Z === !1 && "modal-no-body-scroll",
|
|
141
|
+
K || O || t == "fullscreen" ? "modal-fixed" : ""
|
|
140
142
|
)
|
|
141
143
|
},
|
|
142
|
-
styles:
|
|
143
|
-
modalRender: (
|
|
144
|
+
styles: le,
|
|
145
|
+
modalRender: (e) => /* @__PURE__ */ o("div", { ref: se, className: n("modal-inner"), children: e }),
|
|
144
146
|
okButtonProps: I,
|
|
145
147
|
cancelButtonProps: M,
|
|
146
|
-
onOk: (
|
|
147
|
-
d && N(!1), b?.(
|
|
148
|
+
onOk: (e) => {
|
|
149
|
+
d && N(!1), b?.(e);
|
|
148
150
|
},
|
|
149
|
-
onCancel: (
|
|
150
|
-
d && N(!1),
|
|
151
|
+
onCancel: (e) => {
|
|
152
|
+
s || (d && N(!1), C?.(e));
|
|
151
153
|
},
|
|
152
|
-
okText:
|
|
153
|
-
cancelText:
|
|
154
|
+
okText: v,
|
|
155
|
+
cancelText: g,
|
|
154
156
|
okType: "primary",
|
|
155
|
-
confirmLoading:
|
|
156
|
-
footer: typeof h > "u" ? k && w ? null :
|
|
157
|
-
centered:
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
confirmLoading: s,
|
|
158
|
+
footer: typeof h > "u" ? k && w ? null : de : h,
|
|
159
|
+
centered: Q,
|
|
160
|
+
loading: X,
|
|
161
|
+
...ee,
|
|
162
|
+
children: F
|
|
160
163
|
}
|
|
161
164
|
);
|
|
162
165
|
};
|
|
163
166
|
export {
|
|
164
|
-
|
|
167
|
+
Je as Modal
|
|
165
168
|
};
|
|
166
169
|
//# sourceMappingURL=Modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sources":["../../../src/components/modal/Modal.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntModal,\n type ModalProps as AntModalProps,\n} from \"antd/es/modal\";\nimport { XIcon } from \"@bioturing/assets\";\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { clsx, useCls } from \"../utils\";\nimport { ModalContextProvider } from \"antd/es/modal/context\";\nimport NormalCancelBtn from \"antd/es/modal/components/NormalCancelBtn\";\nimport NormalOkBtn from \"antd/es/modal/components/NormalOkBtn\";\nimport { getConfirmLocale } from \"antd/es/modal/locale\";\nimport { useLocale } from \"antd/es/locale\";\nimport { IconButton } from \"../icon-button\";\nimport { ModalSize } from \"./constants\";\nimport { ModalType } from \"./functions\";\nimport { Truncate } from \"../truncate\";\nimport { Stack } from \"../stack\";\nimport { useTheme } from \"../theme-provider\";\n\n// Define props interface extending Ant Design's ModalProps\nexport interface ModalProps extends Omit<AntModalProps, \"centered\"> {\n /**\n * Predefined sizes for the modal\n * - xsmall: 400px\n * - small: 520px\n * - medium: 640px (default)\n * - large: 840px\n * - xlarge: 1024px\n * - fullscreen: 100vw (takes full screen width with margins)\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?:\n | \"xsmall\"\n | \"small\"\n | \"medium\"\n | \"large\"\n | \"xlarge\"\n | \"xxlarge\"\n | \"fullscreen\";\n /**\n * Mark modal as loading\n * @default false\n */\n loading?: boolean;\n /**\n * Hide Ok button\n * @default false\n */\n hideOkButton?: boolean;\n /**\n * Hide Cancel button\n * @default false\n */\n hideCancelButton?: boolean;\n /**\n * Custom Content Padding\n * @default \"24px\"\n */\n contentPadding?: number | string | boolean;\n /**\n * Add more content below the title\n */\n afterTitle?: React.ReactNode;\n /**\n * Add more actions before close button\n */\n beforeCloseButton?: React.ReactNode;\n /**\n * Add more actions after close button\n */\n afterCloseButton?: React.ReactNode;\n /**\n * Set header and footer to fixed position\n * @default false\n */\n defaultFixedHeaderFooter?: boolean;\n /**\n * Centered Modal\n * @default true\n */\n centered?: boolean;\n /**\n * Modal type\n * @default \"default\"\n */\n type?: ModalType;\n /**\n * Default open state for uncontrolled modal\n * @default true\n */\n defaultOpen?: boolean;\n /**\n * Modal background\n * @default \"elevated\" if size smaller than \"medium\", otherwise \"container\"\n */\n background?: \"elevated\" | \"container\";\n /**\n * Modal old close callback\n * @deprecated use onCancel instead\n */\n onClose?: () => void;\n /**\n * Make modal body scrollable\n * @default true\n */\n bodyScrollable?: boolean;\n}\n\n// Create Modal component\nexport const Modal = ({\n open: externalOpen,\n closeIcon,\n children,\n size: sizeProp,\n footer,\n width,\n style,\n styles,\n classNames,\n okButtonProps,\n cancelButtonProps,\n loading,\n onOk,\n onCancel,\n okText,\n okType = \"primary\",\n confirmLoading,\n cancelText = \"Close\",\n hideOkButton = false,\n hideCancelButton = false,\n contentPadding,\n title,\n afterTitle,\n beforeCloseButton,\n afterCloseButton,\n defaultFixedHeaderFooter = false,\n centered = true,\n type = \"default\",\n defaultOpen = true,\n background: backgroundProp,\n bodyScrollable = true,\n rootClassName,\n ...rest\n}: ModalProps) => {\n // Default close icon with Phosphor icon\n const defaultCloseIcon =\n closeIcon === undefined ? <XIcon size={16} weight=\"bold\" /> : closeIcon;\n\n // Use custom width if provided, otherwise use the size from the map\n const defaultModalSize = type === \"default\" ? \"medium\" : \"xsmall\";\n\n const size: keyof typeof ModalSize = sizeProp || defaultModalSize;\n const modalWidth = width || ModalSize[size];\n\n const background =\n backgroundProp ||\n (size &&\n size in ModalSize &&\n parseInt(ModalSize[size]) <= parseInt(ModalSize.medium)\n ? \"elevated\"\n : \"container\");\n\n // Apply additional styles for fullscreen mode\n const modalStyle = {\n \"--ds-modal-bg\": `var(--ds-color-bg-${background})`,\n ...style,\n ...(size === \"fullscreen\"\n ? { top: 0, maxWidth: \"100%\", height: \"100%\" }\n : {}),\n };\n\n const modalStyles = {\n ...styles,\n body: {\n ...((typeof contentPadding != \"undefined\"\n ? {\n \"--ds-modal-content-padding\":\n contentPadding === false || contentPadding === 0\n ? \"0\"\n : typeof contentPadding == \"number\"\n ? `${contentPadding}px`\n : contentPadding,\n }\n : {}) as React.CSSProperties),\n ...styles?.body,\n },\n };\n\n const [isContentOverflow, setIsContentOverflow] = useState(false);\n\n const cls = useCls();\n\n const { className: themeClassName } = useTheme();\n\n const resizeObserverRef = useRef<ResizeObserver | null>(null);\n\n const modalInnerRef = useCallback(\n (node: HTMLElement | null) => {\n // If the node is null (component unmounting), just return\n if (!node) return;\n\n const modalBody = node.querySelector(\".\" + cls(\"modal-body\"));\n if (!(modalBody instanceof HTMLElement)) return;\n\n // Create ResizeObserver to detect overflow\n const resizeObserver = new ResizeObserver(() => {\n const hasOverflow = modalBody.scrollHeight > modalBody.clientHeight;\n setIsContentOverflow(hasOverflow);\n });\n\n // Store reference to the observer\n resizeObserverRef.current = resizeObserver;\n\n // Start observing\n resizeObserver.observe(modalBody);\n\n // Initial check\n const hasOverflow = modalBody.scrollHeight > modalBody.clientHeight;\n setIsContentOverflow(hasOverflow);\n },\n [cls]\n );\n\n // clean up resize observer\n useEffect(() => {\n return () => {\n if (resizeObserverRef.current) {\n resizeObserverRef.current.disconnect();\n resizeObserverRef.current = null;\n }\n };\n }, []);\n\n const [locale] = useLocale(\"Modal\", getConfirmLocale());\n\n const okTextLocale: React.ReactNode = okText || locale?.okText;\n const cancelTextLocale = cancelText || locale?.cancelText;\n\n const modalOkButtonProps = {\n loading: loading,\n ...okButtonProps,\n };\n\n const modalCancelButtonProps = {\n ...cancelButtonProps,\n };\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n\n const uncontrolledOpen = typeof externalOpen === \"undefined\";\n\n const open = uncontrolledOpen ? internalOpen : externalOpen;\n\n const defaultFooter = (\n <ModalContextProvider\n value={{\n okButtonProps: modalOkButtonProps,\n cancelButtonProps: modalCancelButtonProps,\n onCancel,\n onOk,\n okType,\n confirmLoading,\n okTextLocale,\n cancelTextLocale,\n }}\n >\n {hideOkButton ? (\n <NormalCancelBtn />\n ) : hideCancelButton ? (\n <NormalOkBtn />\n ) : (\n <>\n <NormalCancelBtn />\n <NormalOkBtn />\n </>\n )}\n </ModalContextProvider>\n );\n const renderTitle = () => {\n return (\n <>\n <Stack align=\"center\" gap={8} className={cls(\"modal-title-wrapper\")}>\n <Stack.Child grow>\n {typeof title === \"string\" ? <Truncate>{title}</Truncate> : title}\n </Stack.Child>\n <Stack.Child stack hug align=\"center\" gap={8}>\n {beforeCloseButton}\n <IconButton\n onClick={(e: React.MouseEvent<HTMLButtonElement>) =>\n onCancel?.(e)\n }\n >\n {defaultCloseIcon}\n </IconButton>\n {afterCloseButton}\n </Stack.Child>\n {}\n </Stack>\n {afterTitle ? afterTitle : null}\n </>\n );\n };\n return (\n <AntModal\n closeIcon={false}\n open={open}\n width={modalWidth}\n style={modalStyle}\n title={renderTitle()}\n rootClassName={clsx(themeClassName, rootClassName)}\n classNames={{\n ...classNames,\n wrapper: cls(\n \"modal-wrap\",\n size == \"fullscreen\" && \"modal-fullscreen\",\n isContentOverflow && \"modal-content-overflow\",\n bodyScrollable === false && \"modal-no-body-scroll\",\n defaultFixedHeaderFooter || isContentOverflow || size == \"fullscreen\"\n ? \"modal-fixed\"\n : \"\"\n ),\n }}\n styles={modalStyles}\n modalRender={(modal) => (\n <div ref={modalInnerRef} className={cls(\"modal-inner\")}>\n {modal}\n </div>\n )}\n okButtonProps={modalOkButtonProps}\n cancelButtonProps={modalCancelButtonProps}\n onOk={(e) => {\n if (uncontrolledOpen) setInternalOpen(false);\n onOk?.(e);\n }}\n onCancel={(e) => {\n if (uncontrolledOpen) setInternalOpen(false);\n onCancel?.(e);\n }}\n okText={okText}\n cancelText={cancelText}\n okType=\"primary\"\n confirmLoading={confirmLoading}\n footer={\n typeof footer === \"undefined\"\n ? hideOkButton && hideCancelButton\n ? null\n : defaultFooter\n : footer\n }\n centered={centered}\n {...rest}\n >\n {children}\n </AntModal>\n );\n};\n"],"names":["Modal","externalOpen","closeIcon","children","sizeProp","footer","width","style","styles","classNames","okButtonProps","cancelButtonProps","loading","onOk","onCancel","okText","okType","confirmLoading","cancelText","hideOkButton","hideCancelButton","contentPadding","title","afterTitle","beforeCloseButton","afterCloseButton","defaultFixedHeaderFooter","centered","type","defaultOpen","backgroundProp","bodyScrollable","rootClassName","rest","defaultCloseIcon","jsx","XIcon","size","modalWidth","ModalSize","modalStyle","modalStyles","isContentOverflow","setIsContentOverflow","useState","cls","useCls","themeClassName","useTheme","resizeObserverRef","useRef","modalInnerRef","useCallback","node","modalBody","resizeObserver","hasOverflow","useEffect","locale","useLocale","getConfirmLocale","okTextLocale","cancelTextLocale","modalOkButtonProps","modalCancelButtonProps","internalOpen","setInternalOpen","uncontrolledOpen","open","defaultFooter","ModalContextProvider","NormalCancelBtn","NormalOkBtn","jsxs","Fragment","AntModal","Stack","Truncate","IconButton","e","clsx","modal"],"mappings":";;;;;;;;;;;;;;;;;AA8GO,MAAMA,KAAQ,CAAC;AAAA,EACpB,MAAMC;AAAA,EACN,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAMC;AAAA,EACN,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,gBAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,cAAAC,IAAe;AAAA,EACf,kBAAAC,IAAmB;AAAA,EACnB,gBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,kBAAAC;A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ACV;AAAA,MACA,UAAU,CAACA,MAAM;AACf,QAAIZ,OAAkC,EAAK,GAC3CrD,IAAWiE,CAAC;AAAA,MACd;AAAA,MACA,QAAAhE;AAAA,MACA,YAAAG;AAAA,MACA,QAAO;AAAA,MACP,gBAAAD;AAAA,MACA,QACE,OAAOZ,IAAW,MACdc,KAAgBC,IACd,OACAiD,KACFhE;AAAA,MAEN,UAAAsB;AAAA,MACC,GAAGM;AAAA,MAEH,UAAA9B;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":["../../../src/components/modal/Modal.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntModal,\n type ModalProps as AntModalProps,\n} from \"antd/es/modal\";\nimport { XIcon } from \"@bioturing/assets\";\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { clsx, useCls } from \"../utils\";\nimport { ModalContextProvider } from \"antd/es/modal/context\";\nimport NormalCancelBtn from \"antd/es/modal/components/NormalCancelBtn\";\nimport NormalOkBtn from \"antd/es/modal/components/NormalOkBtn\";\nimport { getConfirmLocale } from \"antd/es/modal/locale\";\nimport { useLocale } from \"antd/es/locale\";\nimport { IconButton } from \"../icon-button\";\nimport { ModalSize } from \"./constants\";\nimport { ModalType } from \"./functions\";\nimport { Truncate } from \"../truncate\";\nimport { Stack } from \"../stack\";\nimport { useTheme } from \"../theme-provider\";\n\n// Define props interface extending Ant Design's ModalProps\nexport interface ModalProps extends Omit<AntModalProps, \"centered\"> {\n /**\n * Predefined sizes for the modal\n * - xsmall: 400px\n * - small: 520px\n * - medium: 640px (default)\n * - large: 840px\n * - xlarge: 1024px\n * - fullscreen: 100vw (takes full screen width with margins)\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?:\n | \"xsmall\"\n | \"small\"\n | \"medium\"\n | \"large\"\n | \"xlarge\"\n | \"xxlarge\"\n | \"fullscreen\";\n /**\n * Mark modal as loading\n * @default false\n */\n loading?: boolean;\n /**\n * Hide Ok button\n * @default false\n */\n hideOkButton?: boolean;\n /**\n * Hide Cancel button\n * @default false\n */\n hideCancelButton?: boolean;\n /**\n * Custom Content Padding\n * @default \"24px\"\n */\n contentPadding?: number | string | boolean;\n /**\n * Add more content below the title\n */\n afterTitle?: React.ReactNode;\n /**\n * Add more actions before close button\n */\n beforeCloseButton?: React.ReactNode;\n /**\n * Add more actions after close button\n */\n afterCloseButton?: React.ReactNode;\n /**\n * Set header and footer to fixed position\n * @default false\n */\n defaultFixedHeaderFooter?: boolean;\n /**\n * Centered Modal\n * @default true\n */\n centered?: boolean;\n /**\n * Modal type\n * @default \"default\"\n */\n type?: ModalType;\n /**\n * Default open state for uncontrolled modal\n * @default true\n */\n defaultOpen?: boolean;\n /**\n * Modal background\n * @default \"elevated\" if size smaller than \"medium\", otherwise \"container\"\n */\n background?: \"elevated\" | \"container\";\n /**\n * Modal old close callback\n * @deprecated use onCancel instead\n */\n onClose?: () => void;\n /**\n * Make modal body scrollable\n * @default true\n */\n bodyScrollable?: boolean;\n}\n\n// Create Modal component\nexport const Modal = ({\n open: externalOpen,\n closeIcon,\n children,\n size: sizeProp,\n footer,\n width,\n style,\n styles,\n classNames,\n okButtonProps,\n cancelButtonProps,\n loading,\n onOk,\n onCancel,\n okText,\n okType = \"primary\",\n confirmLoading,\n cancelText = \"Close\",\n hideOkButton = false,\n hideCancelButton = false,\n contentPadding,\n title,\n afterTitle,\n beforeCloseButton,\n afterCloseButton,\n defaultFixedHeaderFooter = false,\n centered = true,\n type = \"default\",\n defaultOpen = true,\n background: backgroundProp,\n bodyScrollable = true,\n rootClassName,\n ...rest\n}: ModalProps) => {\n // Default close icon with Phosphor icon\n const defaultCloseIcon =\n closeIcon === undefined ? <XIcon size={16} weight=\"bold\" /> : closeIcon;\n\n // Use custom width if provided, otherwise use the size from the map\n const defaultModalSize = type === \"default\" ? \"medium\" : \"xsmall\";\n\n const size: keyof typeof ModalSize = sizeProp || defaultModalSize;\n const modalWidth = width || ModalSize[size];\n\n const background =\n backgroundProp ||\n (size &&\n size in ModalSize &&\n parseInt(ModalSize[size]) <= parseInt(ModalSize.medium)\n ? \"elevated\"\n : \"container\");\n\n // Apply additional styles for fullscreen mode\n const modalStyle = {\n \"--ds-modal-bg\": `var(--ds-color-bg-${background})`,\n ...style,\n ...(size === \"fullscreen\"\n ? { top: 0, maxWidth: \"100%\", height: \"100%\" }\n : {}),\n };\n\n const modalStyles = {\n ...styles,\n body: {\n ...((typeof contentPadding != \"undefined\"\n ? {\n \"--ds-modal-content-padding\":\n contentPadding === false || contentPadding === 0\n ? \"0\"\n : typeof contentPadding == \"number\"\n ? `${contentPadding}px`\n : contentPadding,\n }\n : {}) as React.CSSProperties),\n ...styles?.body,\n },\n };\n\n const [isContentOverflow, setIsContentOverflow] = useState(false);\n\n const cls = useCls();\n\n const { className: themeClassName } = useTheme();\n\n const resizeObserverRef = useRef<ResizeObserver | null>(null);\n\n const modalInnerRef = useCallback(\n (node: HTMLElement | null) => {\n // If the node is null (component unmounting), just return\n if (!node) return;\n\n const modalBody = node.querySelector(\".\" + cls(\"modal-body\"));\n if (!(modalBody instanceof HTMLElement)) return;\n\n // Create ResizeObserver to detect overflow\n const resizeObserver = new ResizeObserver(() => {\n const hasOverflow = modalBody.scrollHeight > modalBody.clientHeight;\n setIsContentOverflow(hasOverflow);\n });\n\n // Store reference to the observer\n resizeObserverRef.current = resizeObserver;\n\n // Start observing\n resizeObserver.observe(modalBody);\n\n // Initial check\n const hasOverflow = modalBody.scrollHeight > modalBody.clientHeight;\n setIsContentOverflow(hasOverflow);\n },\n [cls]\n );\n\n // clean up resize observer\n useEffect(() => {\n return () => {\n if (resizeObserverRef.current) {\n resizeObserverRef.current.disconnect();\n resizeObserverRef.current = null;\n }\n };\n }, []);\n\n const [locale] = useLocale(\"Modal\", getConfirmLocale());\n\n const okTextLocale: React.ReactNode = okText || locale?.okText;\n const cancelTextLocale = cancelText || locale?.cancelText;\n\n const modalOkButtonProps = {\n // loading: typeof confirmLoading === \"boolean\" ? confirmLoading : loading,\n ...okButtonProps,\n };\n\n const modalCancelButtonProps = {\n ...cancelButtonProps,\n };\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n\n const uncontrolledOpen = typeof externalOpen === \"undefined\";\n\n const open = uncontrolledOpen ? internalOpen : externalOpen;\n\n const handleCancel = (e: React.MouseEvent<HTMLButtonElement>) => {\n if (confirmLoading) {\n return;\n }\n onCancel?.(e);\n };\n\n const defaultFooter = (\n <ModalContextProvider\n value={{\n okButtonProps: modalOkButtonProps,\n cancelButtonProps: modalCancelButtonProps,\n onCancel: handleCancel,\n onOk,\n okType,\n confirmLoading,\n okTextLocale,\n cancelTextLocale,\n }}\n >\n {hideOkButton ? (\n <NormalCancelBtn />\n ) : hideCancelButton ? (\n <NormalOkBtn />\n ) : (\n <>\n <NormalCancelBtn />\n <NormalOkBtn />\n </>\n )}\n </ModalContextProvider>\n );\n const renderTitle = () => {\n return (\n <>\n <Stack align=\"center\" gap={8} className={cls(\"modal-title-wrapper\")}>\n <Stack.Child grow>\n {typeof title === \"string\" ? <Truncate>{title}</Truncate> : title}\n </Stack.Child>\n <Stack.Child stack hug align=\"center\" gap={8}>\n {beforeCloseButton}\n <IconButton\n onClick={(e: React.MouseEvent<HTMLButtonElement>) =>\n handleCancel(e)\n }\n >\n {defaultCloseIcon}\n </IconButton>\n {afterCloseButton}\n </Stack.Child>\n {}\n </Stack>\n {afterTitle ? afterTitle : null}\n </>\n );\n };\n return (\n <AntModal\n closeIcon={false}\n open={open}\n width={modalWidth}\n style={modalStyle}\n title={renderTitle()}\n rootClassName={clsx(themeClassName, rootClassName)}\n classNames={{\n ...classNames,\n wrapper: cls(\n \"modal-wrap\",\n size == \"fullscreen\" && \"modal-fullscreen\",\n isContentOverflow && \"modal-content-overflow\",\n bodyScrollable === false && \"modal-no-body-scroll\",\n defaultFixedHeaderFooter || isContentOverflow || size == \"fullscreen\"\n ? \"modal-fixed\"\n : \"\"\n ),\n }}\n styles={modalStyles}\n modalRender={(modal) => (\n <div ref={modalInnerRef} className={cls(\"modal-inner\")}>\n {modal}\n </div>\n )}\n okButtonProps={modalOkButtonProps}\n cancelButtonProps={modalCancelButtonProps}\n onOk={(e) => {\n if (uncontrolledOpen) setInternalOpen(false);\n onOk?.(e);\n }}\n onCancel={(e) => {\n if (confirmLoading) return;\n if (uncontrolledOpen) setInternalOpen(false);\n onCancel?.(e);\n }}\n okText={okText}\n cancelText={cancelText}\n okType=\"primary\"\n confirmLoading={confirmLoading}\n footer={\n typeof footer === \"undefined\"\n ? hideOkButton && hideCancelButton\n ? null\n : defaultFooter\n : footer\n }\n centered={centered}\n loading={loading}\n {...rest}\n >\n {children}\n </AntModal>\n );\n};\n"],"names":["Modal","externalOpen","closeIcon","children","sizeProp","footer","width","style","styles","classNames","okButtonProps","cancelButtonProps","loading","onOk","onCancel","okText","okType","confirmLoading","cancelText","hideOkButton","hideCancelButton","contentPadding","title","afterTitle","beforeCloseButton","afterCloseButton","defaultFixedHeaderFooter","centered","type","defaultOpen","backgroundProp","bodyScrollable","rootClassName","rest","defaultCloseIcon","jsx","XIcon","size","modalWidth","ModalSize","modalStyle","modalStyles","isContentOverflow","setIsContentOverflow","useState","cls","useCls","themeClassName","useTheme","resizeObserverRef","useRef","modalInnerRef","useCallback","node","modalBody","resizeObserver","hasOverflow","useEffect","locale","useLocale","getConfirmLocale","okTextLocale","cancelTextLocale","modalOkButtonProps","modalCancelButtonProps","internalOpen","setInternalOpen","uncontrolledOpen","open","handleCancel","defaultFooter","ModalContextProvider","NormalCancelBtn","NormalOkBtn","jsxs","Fragment","AntModal","Stack","Truncate","IconButton","clsx","modal"],"mappings":";;;;;;;;;;;;;;;;;AA8GO,MAAMA,KAAQ,CAAC;AAAA,EACpB,MAAMC;AAAA,EACN,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAMC;AAAA,EACN,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAAC;AAA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A,UACxBK,KAAqB;AAAA,UACrBX,MAAmB,MAAS;AAAA,UAC5BL,KAA4BgB,KAAqBL,KAAQ,eACrD,gBACA;AAAA,QAAA;AAAA,MACN;AAAA,MAEF,QAAQI;AAAA,MACR,aAAa,CAACwC,MACZ,gBAAA9C,EAAC,OAAA,EAAI,KAAKgB,IAAe,WAAWN,EAAI,aAAa,GAClD,UAAAoC,EAAA,CACH;AAAA,MAEF,eAAelB;AAAA,MACf,mBAAmBC;AAAA,MACnB,MAAM,CAAC,MAAM;AACX,QAAIG,OAAkC,EAAK,GAC3CtD,IAAO,CAAC;AAAA,MACV;AAAA,MACA,UAAU,CAAC,MAAM;AACf,QAAII,MACAkD,OAAkC,EAAK,GAC3CrD,IAAW,CAAC;AAAA,MACd;AAAA,MACA,QAAAC;AAAA,MACA,YAAAG;AAAA,MACA,QAAO;AAAA,MACP,gBAAAD;AAAA,MACA,QACE,OAAOZ,IAAW,MACdc,KAAgBC,IACd,OACAkD,KACFjE;AAAA,MAEN,UAAAsB;AAAA,MACA,SAAAf;AAAA,MACC,GAAGqB;AAAA,MAEH,UAAA9B;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Toast as e } from "@base-ui-components/react";
|
|
3
3
|
const n = e.createToastManager();
|
|
4
|
-
function r
|
|
5
|
-
return (s,
|
|
4
|
+
function t(r) {
|
|
5
|
+
return (s, o) => n.add({
|
|
6
6
|
description: s,
|
|
7
7
|
data: {
|
|
8
|
-
type:
|
|
8
|
+
type: r
|
|
9
9
|
},
|
|
10
10
|
// progress and error toasts should not auto close
|
|
11
|
-
...
|
|
12
|
-
...
|
|
11
|
+
...r === "progress" ? { timeout: 0 } : {},
|
|
12
|
+
...o
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
const i = Object.assign(
|
|
16
|
-
info:
|
|
17
|
-
success:
|
|
18
|
-
error:
|
|
19
|
-
warning:
|
|
20
|
-
progress:
|
|
15
|
+
const i = Object.assign(t("info"), {
|
|
16
|
+
info: t("info"),
|
|
17
|
+
success: t("success"),
|
|
18
|
+
error: t("error"),
|
|
19
|
+
warning: t("warning"),
|
|
20
|
+
progress: t("progress")
|
|
21
21
|
});
|
|
22
22
|
export {
|
|
23
23
|
i as toast,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.js","sources":["../../../src/components/toast/function.ts"],"sourcesContent":["\"use client\";\nimport { Toast as BaseToast } from \"@base-ui-components/react\";\nimport type { ToastData } from \"./types\";\n\nexport const toastManager = BaseToast.createToastManager();\n\nfunction createToastTypeFunction(type: ToastData[\"type\"]) {\n return (\n message: string,\n options?: Omit<\n BaseToast.useToastManager.AddOptions<ToastData>,\n \"data\" | \"description\"\n >\n ) => {\n const toastId = toastManager.add<ToastData>({\n description: message,\n data: {\n type: type,\n },\n // progress and error toasts should not auto close\n ...(type === \"progress\"
|
|
1
|
+
{"version":3,"file":"function.js","sources":["../../../src/components/toast/function.ts"],"sourcesContent":["\"use client\";\nimport { Toast as BaseToast } from \"@base-ui-components/react\";\nimport type { ToastData } from \"./types\";\n\nexport const toastManager = BaseToast.createToastManager();\n\nfunction createToastTypeFunction(type: ToastData[\"type\"]) {\n return (\n message: string,\n options?: Omit<\n BaseToast.useToastManager.AddOptions<ToastData>,\n \"data\" | \"description\"\n >\n ) => {\n const toastId = toastManager.add<ToastData>({\n description: message,\n data: {\n type: type,\n },\n // progress and error toasts should not auto close\n ...(type === \"progress\" ? { timeout: 0 } : {}),\n ...options,\n });\n return toastId;\n };\n}\n\nexport const toast = Object.assign(createToastTypeFunction(\"info\"), {\n info: createToastTypeFunction(\"info\"),\n success: createToastTypeFunction(\"success\"),\n error: createToastTypeFunction(\"error\"),\n warning: createToastTypeFunction(\"warning\"),\n progress: createToastTypeFunction(\"progress\"),\n});\n"],"names":["toastManager","BaseToast","createToastTypeFunction","type","message","options","toast"],"mappings":";;AAIO,MAAMA,IAAeC,EAAU,mBAAA;AAEtC,SAASC,EAAwBC,GAAyB;AACxD,SAAO,CACLC,GACAC,MAKgBL,EAAa,IAAe;AAAA,IAC1C,aAAaI;AAAA,IACb,MAAM;AAAA,MACJ,MAAAD;AAAA,IAAA;AAAA;AAAA,IAGF,GAAIA,MAAS,aAAa,EAAE,SAAS,EAAA,IAAM,CAAA;AAAA,IAC3C,GAAGE;AAAA,EAAA,CACJ;AAGL;AAEO,MAAMC,IAAQ,OAAO,OAAOJ,EAAwB,MAAM,GAAG;AAAA,EAClE,MAAMA,EAAwB,MAAM;AAAA,EACpC,SAASA,EAAwB,SAAS;AAAA,EAC1C,OAAOA,EAAwB,OAAO;AAAA,EACtC,SAASA,EAAwB,SAAS;AAAA,EAC1C,UAAUA,EAAwB,UAAU;AAC9C,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ds-toast-viewport{position:fixed;width:100%;max-width:30rem;margin:0 auto;bottom:2rem;left:50%;transform:translate(-50%);top:auto;z-index:var(--ds-z-index-toast);display:flex;justify-content:center}.ds-toast{--gap: .5rem;--offset-y: calc( var(--toast-offset-y) * -1 + (var(--toast-index) * var(--gap) * -1) + var(--toast-swipe-movement-y) );font-family:var(--font-sans);position:absolute;box-sizing:border-box;background:var(--ds-color-bg-elevated);color:var(--ds-color-text);padding:.75rem 1rem;max-width:100%;display:inline-flex;gap:var(--gap);box-shadow:var(--ds-box-shadow-secondary);background-clip:padding-box;border-radius:.5rem;bottom:0;margin-right:0;-webkit-user-select:none;user-select:none;transition:transform .5s cubic-bezier(.22,1,.36,1),opacity .5s;cursor:default;z-index:calc(1000 - var(--toast-index));transform:translate(var(--toast-swipe-movement-x)) translateY(calc(var(--toast-swipe-movement-y) + (var(--toast-index) * -20%))) scale(calc(1 - (var(--toast-index) * .1)))}.ds-toast:after{top:100%}.ds-toast[data-expanded]{transform:translate(var(--toast-swipe-movement-x)) translateY(var(--offset-y))}.ds-toast[data-starting-style],.ds-toast[data-ending-style]:not([data-limited]){transform:translateY(150%)}.ds-toast[data-ending-style]{opacity:0}.ds-toast[data-ending-style][data-swipe-direction=up]{transform:translateY(calc(var(--toast-swipe-movement-y) - 150%))}.ds-toast[data-ending-style][data-swipe-direction=left]{transform:translate(calc(var(--toast-swipe-movement-x) - 150%)) translateY(var(--offset-y))}.ds-toast[data-ending-style][data-swipe-direction=right]{transform:translate(calc(var(--toast-swipe-movement-x) + 150%)) translateY(var(--offset-y))}.ds-toast[data-ending-style][data-swipe-direction=down]{transform:translateY(calc(var(--toast-swipe-movement-y) + 150%))}.ds-toast:after{content:"";position:absolute;width:100%;left:0;height:calc(var(--gap) + 1px)}.ds-toast-content{display:flex;flex:1;flex-direction:column;gap:2}.ds-toast-title{font-size:var(--text-ds-h5);font-weight:var(--text-ds-h5--font-weight);line-height:var(--text-ds-h5--line-height)}.ds-toast-description{font-size:var(--ds-font-size);line-height:var(--ds-line-height)}.ds-toast-description:last-child{margin-bottom:0}.ds-toast-description-traceback p:not(:first-child){margin-top:.5rem}.ds-toast-icon-wrap{width:1.25rem;font-size:1.25rem;display:block;flex:0}.ds-toast-icon{width:1.25rem;height:1.25rem;display:block}.ds-toast-icon.ds-toast-icon-info{color:var(--ds-color-primary)}.ds-toast-icon.ds-toast-icon-success{color:var(--ds-color-success)}.ds-toast-icon.ds-toast-icon-warning{color:var(--ds-color-warning)}.ds-toast-icon.ds-toast-icon-error{color:var(--ds-color-error)}.ds-toast-icon.ds-toast-icon-progress{color:var(--ds-color-primary);animation:var(--ds-animate-spin)}.ds-toast-close{margin-top:.125rem;display:flex}}
|
|
1
|
+
@layer components{.ds-toast-viewport{position:fixed;width:100%;max-width:30rem;margin:0 auto;bottom:2rem;left:50%;transform:translate(-50%);top:auto;z-index:var(--ds-z-index-toast);display:flex;justify-content:center}.ds-toast{--gap: .5rem;--offset-y: calc( var(--toast-offset-y) * -1 + (var(--toast-index) * var(--gap) * -1) + var(--toast-swipe-movement-y) );font-family:var(--font-sans);position:absolute;box-sizing:border-box;background:var(--ds-color-bg-elevated);color:var(--ds-color-text);padding:.75rem 1rem;max-width:100%;display:inline-flex;gap:var(--gap);box-shadow:var(--ds-box-shadow-secondary);background-clip:padding-box;border-radius:.5rem;bottom:0;margin-right:0;-webkit-user-select:none;user-select:none;transition:transform .5s cubic-bezier(.22,1,.36,1),opacity .5s;cursor:default;z-index:calc(1000 - var(--toast-index));transform:translate(var(--toast-swipe-movement-x)) translateY(calc(var(--toast-swipe-movement-y) + (var(--toast-index) * -20%))) scale(calc(1 - (var(--toast-index) * .1)))}.ds-toast:after{top:100%}.ds-toast[data-expanded]{transform:translate(var(--toast-swipe-movement-x)) translateY(var(--offset-y))}.ds-toast[data-starting-style],.ds-toast[data-ending-style]:not([data-limited]){transform:translateY(150%)}.ds-toast[data-ending-style]{opacity:0}.ds-toast[data-ending-style][data-swipe-direction=up]{transform:translateY(calc(var(--toast-swipe-movement-y) - 150%))}.ds-toast[data-ending-style][data-swipe-direction=left]{transform:translate(calc(var(--toast-swipe-movement-x) - 150%)) translateY(var(--offset-y))}.ds-toast[data-ending-style][data-swipe-direction=right]{transform:translate(calc(var(--toast-swipe-movement-x) + 150%)) translateY(var(--offset-y))}.ds-toast[data-ending-style][data-swipe-direction=down]{transform:translateY(calc(var(--toast-swipe-movement-y) + 150%))}.ds-toast:after{content:"";position:absolute;width:100%;left:0;height:calc(var(--gap) + 1px)}.ds-toast-content{display:flex;flex:1;flex-direction:column;max-height:calc(100vh - 92px);gap:2;overflow-y:auto}.ds-toast-title{font-size:var(--text-ds-h5);font-weight:var(--text-ds-h5--font-weight);line-height:var(--text-ds-h5--line-height)}.ds-toast-description{font-size:var(--ds-font-size);line-height:var(--ds-line-height)}.ds-toast-description:last-child{margin-bottom:0}.ds-toast-description-traceback p:not(:first-child){margin-top:.5rem}.ds-toast-icon-wrap{width:1.25rem;font-size:1.25rem;display:block;flex:0}.ds-toast-icon{width:1.25rem;height:1.25rem;display:block}.ds-toast-icon.ds-toast-icon-info{color:var(--ds-color-primary)}.ds-toast-icon.ds-toast-icon-success{color:var(--ds-color-success)}.ds-toast-icon.ds-toast-icon-warning{color:var(--ds-color-warning)}.ds-toast-icon.ds-toast-icon-error{color:var(--ds-color-error)}.ds-toast-icon.ds-toast-icon-progress{color:var(--ds-color-primary);animation:var(--ds-animate-spin)}.ds-toast-close{margin-top:.125rem;display:flex}}
|
|
@@ -12,6 +12,13 @@ export interface TruncateProps extends Omit<React.ComponentPropsWithoutRef<"span
|
|
|
12
12
|
*/
|
|
13
13
|
lines?: number | "auto";
|
|
14
14
|
container?: HTMLElement | React.RefObject<HTMLElement>;
|
|
15
|
+
/**
|
|
16
|
+
* Custom render function to transform text before display
|
|
17
|
+
* Useful for keyword highlighting, text transformations, etc.
|
|
18
|
+
* @param text - The text to render (may be truncated)
|
|
19
|
+
* @returns React node to render
|
|
20
|
+
*/
|
|
21
|
+
renderText?: (text: string) => React.ReactNode;
|
|
15
22
|
}
|
|
16
23
|
export declare const Truncate: React.FC<TruncateProps>;
|
|
17
24
|
//# sourceMappingURL=component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/truncate/component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAK9E,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEhD,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC7D,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAIxB,SAAS,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/truncate/component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAK9E,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEhD,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC7D,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAIxB,SAAS,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvD;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CAChD;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAiM5C,CAAC"}
|