@bioturing/components 0.21.2 → 0.23.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/style.css +1 -1
- package/dist/components/code-block/component.js +67 -66
- package/dist/components/code-block/component.js.map +1 -1
- package/dist/components/form/component.js +6 -4
- package/dist/components/form/component.js.map +1 -1
- package/dist/components/form/item.js +23 -38
- package/dist/components/form/item.js.map +1 -1
- package/dist/components/form/label.js +49 -0
- package/dist/components/form/label.js.map +1 -0
- package/dist/components/icon-button/component.js +42 -38
- package/dist/components/icon-button/component.js.map +1 -1
- package/dist/components/icon-button/style.css +1 -1
- package/dist/components/input/component.js +65 -21
- package/dist/components/input/component.js.map +1 -1
- package/dist/components/input/style.css +1 -0
- package/dist/components/modal/style.css +1 -1
- package/dist/components/popup-panel/component.js +63 -63
- package/dist/components/popup-panel/component.js.map +1 -1
- package/dist/components/select/style.css +1 -1
- package/dist/components/spin/component.js +16 -6
- package/dist/components/spin/component.js.map +1 -1
- package/dist/components/spin/style.css +1 -1
- package/dist/components/utils/WithRenderProp.js +9 -9
- package/dist/components/utils/WithRenderProp.js.map +1 -1
- package/dist/index.d.ts +24 -8
- package/package.json +5 -5
|
@@ -1,26 +1,70 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import {
|
|
4
|
-
import { Input as
|
|
5
|
-
import { forwardRef as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { MagnifyingGlassIcon as p, EyeIcon as x, EyeClosedIcon as C } from "@bioturing/assets";
|
|
4
|
+
import { Input as n } from "antd";
|
|
5
|
+
import { forwardRef as a, useCallback as d, useMemo as P } from "react";
|
|
6
|
+
import './style.css';/* empty css */
|
|
7
|
+
import { useCls as g } from "../utils/antdUtils.js";
|
|
8
|
+
import { Spin as z } from "../spin/component.js";
|
|
9
|
+
import { IconButton as M } from "../icon-button/component.js";
|
|
10
|
+
const T = (e, s) => /* @__PURE__ */ r(n, { ref: s, ...e }), y = (e, s) => {
|
|
11
|
+
const o = P(() => ({
|
|
12
|
+
iconRender: (t) => /* @__PURE__ */ r(
|
|
13
|
+
M,
|
|
14
|
+
{
|
|
15
|
+
size: "small",
|
|
16
|
+
label: t ? "Hide password" : "Show password",
|
|
17
|
+
children: t ? /* @__PURE__ */ r(x, {}) : /* @__PURE__ */ r(C, {})
|
|
18
|
+
}
|
|
19
|
+
),
|
|
20
|
+
...e
|
|
21
|
+
}), [e]);
|
|
22
|
+
return /* @__PURE__ */ r(n.Password, { ref: s, ...o });
|
|
23
|
+
}, A = ({
|
|
24
|
+
enterButton: e = !1,
|
|
25
|
+
onSearch: s,
|
|
26
|
+
prefix: o,
|
|
27
|
+
onPressEnter: t,
|
|
28
|
+
onClear: i,
|
|
29
|
+
loading: c,
|
|
30
|
+
...u
|
|
31
|
+
}, l) => {
|
|
32
|
+
const I = g(), f = d(
|
|
33
|
+
(m) => {
|
|
34
|
+
s == null || s(m.currentTarget.value, m, { source: "input" });
|
|
35
|
+
},
|
|
36
|
+
[s]
|
|
37
|
+
), w = d(() => {
|
|
38
|
+
s == null || s("", void 0, { source: "clear" });
|
|
39
|
+
}, [s]);
|
|
40
|
+
return e === !1 ? /* @__PURE__ */ r(
|
|
41
|
+
n,
|
|
42
|
+
{
|
|
43
|
+
ref: l,
|
|
44
|
+
prefix: o || (c ? /* @__PURE__ */ r(z, { size: 16 }) : /* @__PURE__ */ r(p, { size: 16, className: I("input-search-icon") })),
|
|
45
|
+
onPressEnter: t || f,
|
|
46
|
+
onClear: i || w,
|
|
47
|
+
allowClear: !0,
|
|
48
|
+
...u
|
|
49
|
+
}
|
|
50
|
+
) : /* @__PURE__ */ r(
|
|
51
|
+
n.Search,
|
|
52
|
+
{
|
|
53
|
+
ref: l,
|
|
54
|
+
prefix: o,
|
|
55
|
+
onPressEnter: t,
|
|
56
|
+
onClear: i,
|
|
57
|
+
loading: c,
|
|
58
|
+
enterButton: e === !0 ? /* @__PURE__ */ r(p, { size: 16 }) : e,
|
|
59
|
+
...u
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}, E = (e, s) => /* @__PURE__ */ r(n.TextArea, { ref: s, ...e }), b = a(T), j = a(y), R = a(A), k = a(E), D = Object.assign(b, {
|
|
63
|
+
Password: j,
|
|
64
|
+
Search: R,
|
|
65
|
+
TextArea: k
|
|
22
66
|
});
|
|
23
67
|
export {
|
|
24
|
-
|
|
68
|
+
D as Input
|
|
25
69
|
};
|
|
26
70
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/input/component.tsx"],"sourcesContent":["\"use client\";\nimport {
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/input/component.tsx"],"sourcesContent":["\"use client\";\nimport { EyeIcon, EyeClosedIcon, MagnifyingGlassIcon } from \"@bioturing/assets\";\nimport {\n Input as AntInput,\n type InputProps as AntInputProps,\n type InputRef,\n} from \"antd\";\nimport { type PasswordProps as AntPasswordProps } from \"antd/es/input\";\nimport { type SearchProps as AntSearchProps } from \"antd/es/input\";\nimport { type TextAreaProps as AntTextAreaProps } from \"antd/es/input\";\nimport { forwardRef, useCallback, useMemo } from \"react\";\nimport { useCls } from \"../utils\";\nimport { Spin } from \"../spin\";\n\nimport \"./style.css\";\nimport { IconButton } from \"../icon-button\";\n\n// Define props interfaces\nexport interface InputProps extends AntInputProps {}\nexport interface PasswordProps extends AntPasswordProps {}\nexport interface TextAreaProps extends AntTextAreaProps {}\nexport interface SearchProps extends AntSearchProps {}\n\n// Create inner function for main Input\nconst MainInputInner = (props: InputProps, ref: React.Ref<InputRef>) => {\n return <AntInput ref={ref} {...props} />;\n};\n\n// Create inner function for Password\nconst PasswordInner = (props: PasswordProps, ref: React.Ref<InputRef>) => {\n // Apply default iconRender unless overridden by props\n const mergedProps = useMemo(() => {\n return {\n iconRender: (visible: boolean) => (\n <IconButton\n size=\"small\"\n label={visible ? \"Hide password\" : \"Show password\"}\n >\n {visible ? <EyeIcon /> : <EyeClosedIcon />}\n </IconButton>\n ),\n ...props,\n };\n }, [props]);\n\n return <AntInput.Password ref={ref} {...mergedProps} />;\n};\n\n// Create inner function for Search\nconst SearchInner = (\n {\n enterButton = false,\n onSearch,\n prefix,\n onPressEnter,\n onClear,\n loading,\n ...rest\n }: SearchProps,\n ref: React.Ref<InputRef>\n) => {\n const cls = useCls();\n\n const handlePressEnter = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n onSearch?.(event.currentTarget.value, event, { source: \"input\" });\n },\n [onSearch]\n );\n\n const handleClear = useCallback(() => {\n onSearch?.(\"\", undefined, { source: \"clear\" });\n }, [onSearch]);\n\n return enterButton === false ? (\n <AntInput\n ref={ref}\n prefix={\n prefix ||\n (loading ? (\n <Spin size={16} />\n ) : (\n <MagnifyingGlassIcon size={16} className={cls(\"input-search-icon\")} />\n ))\n }\n onPressEnter={onPressEnter || handlePressEnter}\n onClear={onClear || handleClear}\n allowClear\n {...rest}\n />\n ) : (\n <AntInput.Search\n ref={ref}\n prefix={prefix}\n onPressEnter={onPressEnter}\n onClear={onClear}\n loading={loading}\n enterButton={\n enterButton === true ? <MagnifyingGlassIcon size={16} /> : enterButton\n }\n {...rest}\n />\n );\n};\n\n// Create inner function for TextArea\nconst TextAreaInner = (\n props: TextAreaProps,\n ref: React.Ref<HTMLTextAreaElement>\n) => {\n return <AntInput.TextArea ref={ref} {...props} />;\n};\n\n// Use forwardRef with type assertion for main Input\nconst MainInput = forwardRef(MainInputInner) as (\n props: InputProps & {\n ref?: React.ForwardedRef<InputRef>;\n }\n) => ReturnType<typeof MainInputInner>;\n\n// Use forwardRef with type assertion for Password\nconst Password = forwardRef(PasswordInner) as (\n props: PasswordProps & {\n ref?: React.ForwardedRef<InputRef>;\n }\n) => ReturnType<typeof PasswordInner>;\n\n// Use forwardRef with type assertion for Search\nconst Search = forwardRef(SearchInner) as (\n props: SearchProps & {\n ref?: React.ForwardedRef<InputRef>;\n }\n) => ReturnType<typeof SearchInner>;\n\n// Use forwardRef with type assertion for TextArea\nconst TextArea = forwardRef(TextAreaInner) as (\n props: TextAreaProps & {\n ref?: React.ForwardedRef<HTMLTextAreaElement>;\n }\n) => ReturnType<typeof TextAreaInner>;\n\n// Export the final composed component\nexport const Input = Object.assign(MainInput, {\n Password,\n Search,\n TextArea,\n});\n"],"names":["MainInputInner","props","ref","jsx","AntInput","PasswordInner","mergedProps","useMemo","visible","IconButton","EyeIcon","EyeClosedIcon","SearchInner","enterButton","onSearch","prefix","onPressEnter","onClear","loading","rest","cls","useCls","handlePressEnter","useCallback","event","handleClear","Spin","MagnifyingGlassIcon","TextAreaInner","MainInput","forwardRef","Password","Search","TextArea","Input"],"mappings":";;;;;;;;;AAwBA,MAAMA,IAAiB,CAACC,GAAmBC,MACjC,gBAAAC,EAAAC,GAAA,EAAS,KAAAF,GAAW,GAAGD,EAAO,CAAA,GAIlCI,IAAgB,CAACJ,GAAsBC,MAA6B;AAElE,QAAAI,IAAcC,EAAQ,OACnB;AAAA,IACL,YAAY,CAACC,MACX,gBAAAL;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOD,IAAU,kBAAkB;AAAA,QAElC,UAAUA,IAAA,gBAAAL,EAACO,GAAQ,CAAA,CAAA,sBAAMC,GAAc,CAAA,CAAA;AAAA,MAAA;AAAA,IAC1C;AAAA,IAEF,GAAGV;AAAA,EACL,IACC,CAACA,CAAK,CAAC;AAEV,2BAAQG,EAAS,UAAT,EAAkB,KAAAF,GAAW,GAAGI,GAAa;AACvD,GAGMM,IAAc,CAClB;AAAA,EACE,aAAA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5BM,IAAQ,OAAO,OAAOL,GAAW;AAAA,EAC5C,UAAAE;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AACF,CAAC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer components{.ds-input-search-icon{color:var(--ds-color-icon)}.ds-input-affix-wrapper .ds-input-prefix{margin-inline-end:var(--ds-padding-xs)}.ds-input-affix-wrapper .ds-input-suffix{margin-inline-start:var(--ds-padding-xs)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ds-modal-wrap{max-height:100vh}.ds-modal-wrap .ds-modal-close-x{width:100%;display:flex}.ds-modal-wrap .ds-modal{padding-bottom:0;margin-top:0;margin-bottom:0;max-height:100vh;top:0}:is(.ds-modal-wrap .ds-modal) .ds-modal-content{display:flex;flex-direction:column;padding:0;box-shadow:var(--ds-box-shadow-secondary);background:var(--ds-modal-bg)}:is(.ds-modal-wrap .ds-modal) .ds-modal-body{padding:var(--ds-modal-content-padding);flex-grow:1;flex-shrink:1;min-height:0;overflow:auto}:is(.ds-modal-wrap .ds-modal) .ds-modal-header{padding:calc(var(--ds-modal-padding) * 2 / 3) var(--ds-modal-padding) 0 var(--ds-modal-padding);margin-bottom:0;background:transparent}:is(.ds-modal-wrap .ds-modal) .ds-modal-footer{padding:0 var(--ds-modal-padding) var(--ds-modal-padding) var(--ds-modal-padding);margin-top:0;background:transparent}:is(.ds-modal-wrap .ds-modal) .ds-modal-close{top:calc(var(--ds-modal-padding) * 2 / 3 - 4px)}.ds-modal-wrap:not(.ds-modal-centered) .ds-modal-inner{margin-top:4rem}.ds-modal-wrap:not(.ds-modal-fullscreen) .ds-modal-content{max-height:calc(100vh - var(--ds-modal-edge-padding) * 2);margin:var(--ds-modal-edge-padding)}.ds-modal-wrap:not(.ds-modal-fullscreen) .ds-modal>div[tabindex="0"]{max-height:calc(100vh - var(--ds-modal-edge-padding) * 2)}.ds-modal-no-body-scroll .ds-modal{max-height:100%}:is(.ds-modal-no-body-scroll .ds-modal) .ds-modal-body{overflow:hidden;display:grid}:is(:is(.ds-modal-no-body-scroll .ds-modal) .ds-modal-body)>*{min-height:0}.ds-modal-fullscreen .ds-modal>div[tabindex="0"]{height:100%}.ds-modal-fullscreen .ds-modal .ds-modal-inner{height:100%}.ds-modal-fullscreen .ds-modal .ds-modal-content{border-radius:0;height:100%;width:100%}:is(.ds-modal-fixed .ds-modal) .ds-modal-footer{border-top:1px solid var(--ds-color-split);margin-top:0;padding:calc(var(--ds-modal-padding) / 2) var(--ds-modal-padding)}:is(.ds-modal-fixed .ds-modal) .ds-modal-header{border-bottom:1px solid var(--ds-color-split);margin-bottom:0;padding:calc(var(--ds-modal-padding) / 2) var(--ds-modal-padding)}:is(.ds-modal-fixed .ds-modal) .ds-modal-close{top:8px}:is(.ds-modal-content-overflow .ds-modal) .ds-modal-inner{margin-top:0}}
|
|
1
|
+
@layer components{.ds-modal-wrap{max-height:100vh}.ds-modal-wrap .ds-modal-close-x{width:100%;display:flex}.ds-modal-wrap .ds-modal{padding-bottom:0;margin-top:0;margin-bottom:0;max-height:100vh;top:0}:is(.ds-modal-wrap .ds-modal) .ds-modal-content{display:flex;flex-direction:column;padding:0;box-shadow:var(--ds-box-shadow-secondary);background:var(--ds-modal-bg, var(--ds-modal-content-bg))}:is(.ds-modal-wrap .ds-modal) .ds-modal-body{padding:var(--ds-modal-content-padding);flex-grow:1;flex-shrink:1;min-height:0;overflow:auto}:is(.ds-modal-wrap .ds-modal) .ds-modal-header{padding:calc(var(--ds-modal-padding) * 2 / 3) var(--ds-modal-padding) 0 var(--ds-modal-padding);margin-bottom:0;background:transparent}:is(.ds-modal-wrap .ds-modal) .ds-modal-footer{padding:0 var(--ds-modal-padding) var(--ds-modal-padding) var(--ds-modal-padding);margin-top:0;background:transparent}:is(.ds-modal-wrap .ds-modal) .ds-modal-close{top:calc(var(--ds-modal-padding) * 2 / 3 - 4px)}.ds-modal-wrap:not(.ds-modal-centered) .ds-modal-inner{margin-top:4rem}.ds-modal-wrap:not(.ds-modal-fullscreen) .ds-modal-content{max-height:calc(100vh - var(--ds-modal-edge-padding) * 2);margin:var(--ds-modal-edge-padding)}.ds-modal-wrap:not(.ds-modal-fullscreen) .ds-modal>div[tabindex="0"]{max-height:calc(100vh - var(--ds-modal-edge-padding) * 2)}.ds-modal-no-body-scroll .ds-modal{max-height:100%}:is(.ds-modal-no-body-scroll .ds-modal) .ds-modal-body{overflow:hidden;display:grid}:is(:is(.ds-modal-no-body-scroll .ds-modal) .ds-modal-body)>*{min-height:0}.ds-modal-fullscreen .ds-modal>div[tabindex="0"]{height:100%}.ds-modal-fullscreen .ds-modal .ds-modal-inner{height:100%}.ds-modal-fullscreen .ds-modal .ds-modal-content{border-radius:0;height:100%;width:100%}:is(.ds-modal-fixed .ds-modal) .ds-modal-footer{border-top:1px solid var(--ds-color-split);margin-top:0;padding:calc(var(--ds-modal-padding) / 2) var(--ds-modal-padding)}:is(.ds-modal-fixed .ds-modal) .ds-modal-header{border-bottom:1px solid var(--ds-color-split);margin-bottom:0;padding:calc(var(--ds-modal-padding) / 2) var(--ds-modal-padding)}:is(.ds-modal-fixed .ds-modal) .ds-modal-close{top:8px}:is(.ds-modal-content-overflow .ds-modal) .ds-modal-inner{margin-top:0}}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as o, jsxs as d, Fragment as a } from "react/jsx-runtime";
|
|
3
3
|
import { Popover as i } from "@base-ui-components/react/popover";
|
|
4
|
-
import { useState as f, useCallback as
|
|
4
|
+
import { useState as f, useCallback as C, useEffect as O, useMemo as N } from "react";
|
|
5
5
|
import s from "antd/es/flex";
|
|
6
6
|
import { X as ee } from "@bioturing/assets";
|
|
7
7
|
import { PopupPanelSize as te } from "./constants.js";
|
|
8
8
|
import { useResizable as oe } from "react-use-resizable";
|
|
9
|
-
import
|
|
9
|
+
import ne from "merge-refs";
|
|
10
10
|
import './style.css';/* empty css */
|
|
11
|
-
import { useControlledState as
|
|
11
|
+
import { useControlledState as re } from "../hooks/useControlledState.js";
|
|
12
12
|
import { useCls as pe, parseAntdPlacement as ie } from "../utils/antdUtils.js";
|
|
13
|
-
import { clsx as
|
|
13
|
+
import { clsx as r } from "../utils/cn.js";
|
|
14
14
|
import { IconButton as de } from "../icon-button/component.js";
|
|
15
15
|
const we = ({
|
|
16
|
-
children:
|
|
17
|
-
placement:
|
|
18
|
-
openOnHover:
|
|
19
|
-
open:
|
|
20
|
-
onOpenChange:
|
|
21
|
-
content:
|
|
16
|
+
children: S,
|
|
17
|
+
placement: I,
|
|
18
|
+
openOnHover: D = !1,
|
|
19
|
+
open: W,
|
|
20
|
+
onOpenChange: j,
|
|
21
|
+
content: E,
|
|
22
22
|
title: h,
|
|
23
|
-
trigger:
|
|
24
|
-
className:
|
|
25
|
-
anchor:
|
|
23
|
+
trigger: F = "click",
|
|
24
|
+
className: V,
|
|
25
|
+
anchor: $,
|
|
26
26
|
beforeCloseButton: P,
|
|
27
27
|
afterCloseButton: H,
|
|
28
28
|
afterTitle: c,
|
|
29
29
|
size: g = "medium",
|
|
30
30
|
footer: l,
|
|
31
|
-
defaultOpen:
|
|
32
|
-
resizable:
|
|
31
|
+
defaultOpen: A,
|
|
32
|
+
resizable: y = !1,
|
|
33
33
|
classNames: e,
|
|
34
34
|
modal: M = !1,
|
|
35
35
|
closeOnClickOutside: T = !0
|
|
36
36
|
}) => {
|
|
37
|
-
const [U,
|
|
38
|
-
D,
|
|
37
|
+
const [U, b] = re(
|
|
39
38
|
W,
|
|
40
|
-
|
|
39
|
+
j,
|
|
40
|
+
A ?? !1
|
|
41
41
|
// Always provide a default value to prevent undefined
|
|
42
|
-
), t = pe(),
|
|
43
|
-
X(
|
|
42
|
+
), t = pe(), w = ie(I), [v, X] = f(null), [q, G] = f(), [J, K] = f(), L = C((n) => {
|
|
43
|
+
X(n);
|
|
44
44
|
}, []);
|
|
45
|
-
|
|
45
|
+
O(() => {
|
|
46
46
|
if (!v) return;
|
|
47
|
-
const
|
|
47
|
+
const n = new ResizeObserver((u) => {
|
|
48
48
|
for (const p of u)
|
|
49
49
|
G(p.contentRect.width), K(p.contentRect.height);
|
|
50
50
|
});
|
|
51
|
-
return
|
|
52
|
-
|
|
51
|
+
return n.observe(v), () => {
|
|
52
|
+
n.disconnect();
|
|
53
53
|
};
|
|
54
54
|
}, [v]);
|
|
55
|
-
const
|
|
55
|
+
const x = N(() => /* @__PURE__ */ o(ee, { size: 16 }), []), Q = C(() => /* @__PURE__ */ d("div", { className: r(t("popup-panel-header"), e == null ? void 0 : e.header), children: [
|
|
56
56
|
/* @__PURE__ */ d(
|
|
57
57
|
s,
|
|
58
58
|
{
|
|
@@ -63,7 +63,7 @@ const we = ({
|
|
|
63
63
|
/* @__PURE__ */ o(
|
|
64
64
|
i.Title,
|
|
65
65
|
{
|
|
66
|
-
render: /* @__PURE__ */ o("div", { className:
|
|
66
|
+
render: /* @__PURE__ */ o("div", { className: r(t("grow", "truncate"), e == null ? void 0 : e.title), children: h })
|
|
67
67
|
}
|
|
68
68
|
),
|
|
69
69
|
/* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
|
|
@@ -71,7 +71,7 @@ const we = ({
|
|
|
71
71
|
/* @__PURE__ */ o(
|
|
72
72
|
i.Close,
|
|
73
73
|
{
|
|
74
|
-
render: /* @__PURE__ */ o(de, { children:
|
|
74
|
+
render: /* @__PURE__ */ o(de, { children: x })
|
|
75
75
|
}
|
|
76
76
|
),
|
|
77
77
|
H
|
|
@@ -87,88 +87,88 @@ const we = ({
|
|
|
87
87
|
t,
|
|
88
88
|
e == null ? void 0 : e.header,
|
|
89
89
|
e == null ? void 0 : e.title,
|
|
90
|
-
|
|
90
|
+
x,
|
|
91
91
|
h
|
|
92
|
-
]), [
|
|
92
|
+
]), [R, k] = f(!1), { getRootProps: Y, getHandleProps: z, rootRef: Z } = oe({
|
|
93
93
|
initialWidth: q,
|
|
94
94
|
initialHeight: J,
|
|
95
|
-
onDragStart: () =>
|
|
96
|
-
onDragEnd: () =>
|
|
95
|
+
onDragStart: () => k(!0),
|
|
96
|
+
onDragEnd: () => k(!1)
|
|
97
97
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}, [
|
|
101
|
-
const { ref: _, ...B } = Y(), m = (
|
|
102
|
-
if (!
|
|
98
|
+
O(() => {
|
|
99
|
+
R ? document.body.style.userSelect = "none" : document.body.style.userSelect = "";
|
|
100
|
+
}, [R]);
|
|
101
|
+
const { ref: _, ...B } = Y(), m = (n, u) => {
|
|
102
|
+
if (!n.current) return;
|
|
103
103
|
const { widthDiff: p } = u;
|
|
104
|
-
|
|
104
|
+
n.current.style.left = `${parseInt(n.current.style.left || "0") - p}px`;
|
|
105
105
|
};
|
|
106
106
|
return /* @__PURE__ */ d(
|
|
107
107
|
i.Root,
|
|
108
108
|
{
|
|
109
|
-
openOnHover:
|
|
109
|
+
openOnHover: F === "hover" ? !0 : D,
|
|
110
110
|
open: U,
|
|
111
|
-
onOpenChange: (
|
|
112
|
-
p === "outside-press" && !T ||
|
|
111
|
+
onOpenChange: (n, u, p) => {
|
|
112
|
+
(p === "outside-press" || p === "focus-out") && !T || b(n, u, p);
|
|
113
113
|
},
|
|
114
114
|
modal: M,
|
|
115
115
|
children: [
|
|
116
116
|
/* @__PURE__ */ o(
|
|
117
117
|
i.Trigger,
|
|
118
118
|
{
|
|
119
|
-
render:
|
|
120
|
-
className:
|
|
119
|
+
render: S,
|
|
120
|
+
className: r(t("popup-panel-trigger"), e == null ? void 0 : e.trigger)
|
|
121
121
|
}
|
|
122
122
|
),
|
|
123
123
|
/* @__PURE__ */ o(i.Portal, { children: /* @__PURE__ */ o(
|
|
124
124
|
i.Positioner,
|
|
125
125
|
{
|
|
126
|
-
className:
|
|
127
|
-
side:
|
|
128
|
-
align:
|
|
126
|
+
className: r(t("popup-panel-root"), e == null ? void 0 : e.root),
|
|
127
|
+
side: w.placement,
|
|
128
|
+
align: w.align,
|
|
129
129
|
sideOffset: 4,
|
|
130
|
-
anchor:
|
|
130
|
+
anchor: $,
|
|
131
131
|
style: {
|
|
132
132
|
"--size-width": g ? te[g] : void 0
|
|
133
133
|
},
|
|
134
134
|
children: /* @__PURE__ */ d(
|
|
135
135
|
i.Popup,
|
|
136
136
|
{
|
|
137
|
-
className:
|
|
137
|
+
className: r(
|
|
138
138
|
t("popup-panel"),
|
|
139
139
|
t(`popup-panel-size-${g}`),
|
|
140
|
-
|
|
140
|
+
V,
|
|
141
141
|
e == null ? void 0 : e.popup
|
|
142
142
|
),
|
|
143
|
-
ref:
|
|
144
|
-
...B,
|
|
145
|
-
...
|
|
143
|
+
ref: ne(_, L),
|
|
144
|
+
...y ? B : {},
|
|
145
|
+
...R ? { "data-resizing": !0 } : {},
|
|
146
146
|
children: [
|
|
147
147
|
h && Q(),
|
|
148
148
|
/* @__PURE__ */ o(
|
|
149
149
|
"div",
|
|
150
150
|
{
|
|
151
|
-
className:
|
|
152
|
-
children: /* @__PURE__ */ o("div", { className: t("popup-panel-content-inner"), children:
|
|
151
|
+
className: r(t("popup-panel-content"), e == null ? void 0 : e.content),
|
|
152
|
+
children: /* @__PURE__ */ o("div", { className: t("popup-panel-content-inner"), children: E })
|
|
153
153
|
}
|
|
154
154
|
),
|
|
155
155
|
l && /* @__PURE__ */ o(
|
|
156
156
|
"div",
|
|
157
157
|
{
|
|
158
|
-
className:
|
|
159
|
-
children: typeof l == "function" ? l({ close: () =>
|
|
158
|
+
className: r(t("popup-panel-footer"), e == null ? void 0 : e.footer),
|
|
159
|
+
children: typeof l == "function" ? l({ close: () => b(!1) }) : l
|
|
160
160
|
}
|
|
161
161
|
),
|
|
162
|
-
|
|
162
|
+
y && /* @__PURE__ */ d(a, { children: [
|
|
163
163
|
/* @__PURE__ */ o(
|
|
164
164
|
"div",
|
|
165
165
|
{
|
|
166
|
-
className:
|
|
166
|
+
className: r(
|
|
167
167
|
t("popup-panel-resize-handle"),
|
|
168
168
|
e == null ? void 0 : e.resizeHandle
|
|
169
169
|
),
|
|
170
170
|
"data-placement": "bottom-left",
|
|
171
|
-
...
|
|
171
|
+
...z({
|
|
172
172
|
lockHorizontal: !0
|
|
173
173
|
})
|
|
174
174
|
}
|
|
@@ -176,27 +176,27 @@ const we = ({
|
|
|
176
176
|
/* @__PURE__ */ o(
|
|
177
177
|
"div",
|
|
178
178
|
{
|
|
179
|
-
className:
|
|
179
|
+
className: r(
|
|
180
180
|
t("popup-panel-resize-handle"),
|
|
181
181
|
e == null ? void 0 : e.resizeHandle
|
|
182
182
|
),
|
|
183
183
|
"data-placement": "top-left",
|
|
184
|
-
...
|
|
184
|
+
...z({
|
|
185
185
|
reverse: !0,
|
|
186
186
|
lockVertical: !0,
|
|
187
|
-
onResize: (
|
|
187
|
+
onResize: (n) => m(Z, n)
|
|
188
188
|
})
|
|
189
189
|
}
|
|
190
190
|
),
|
|
191
191
|
/* @__PURE__ */ o(
|
|
192
192
|
"div",
|
|
193
193
|
{
|
|
194
|
-
className:
|
|
194
|
+
className: r(
|
|
195
195
|
t("popup-panel-resize-handle"),
|
|
196
196
|
e == null ? void 0 : e.resizeHandle
|
|
197
197
|
),
|
|
198
198
|
"data-placement": "top-right",
|
|
199
|
-
...
|
|
199
|
+
...z({
|
|
200
200
|
lockVertical: !0
|
|
201
201
|
})
|
|
202
202
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/popup-panel/component.tsx"],"sourcesContent":["\"use client\";\nimport { useCls, clsx, parseAntdPlacement } from \"../utils\";\nimport { Popover } from \"@base-ui-components/react/popover\";\n\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport Flex from \"antd/es/flex\";\nimport { IconButton } from \"../icon-button\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState } from \"../hooks\";\nimport { useResizable, type MoveValues } from \"react-use-resizable\";\nimport mergeRefs from \"merge-refs\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n > {\n /** The trigger element that opens the popup panel */\n children?: React.ComponentProps<typeof Popover.Trigger>[\"render\"];\n /** Placement of the popup panel relative to its trigger */\n placement?: PopoverProps[\"placement\"];\n /** Whether to open the popup panel on hover */\n openOnHover?: boolean;\n /** Controls the open state of the popup panel */\n open?: boolean;\n /** Callback fired when the open state changes */\n onOpenChange?: Popover.Root.Props[\"onOpenChange\"];\n /** Content to display inside the popup panel */\n content?: React.ReactNode;\n /** Title text or element to display in the panel header */\n title?: React.ReactNode;\n /** The event that triggers the popup panel */\n /**\n * @default \"click\"\n */\n trigger?: \"click\" | \"hover\";\n /** Custom anchor element for positioning the panel */\n anchor?: Popover.Positioner.Props[\"anchor\"];\n /** Content to display before the close button */\n beforeCloseButton?: React.ReactNode;\n /** Content to display after the close button */\n afterCloseButton?: React.ReactNode;\n /** Content to display after the title */\n afterTitle?: React.ReactNode;\n /**\n * Predefined sizes for the popup panel\n * - xsmall: 320px\n * - small: 400px\n * - medium: 480px (default)\n * - large: 640px\n * - xlarge: 840px\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?: keyof typeof PopupPanelSize;\n /**\n * Footer content for the popup panel\n * Can be a React node or a function that returns a React node\n */\n footer?:\n | React.ReactNode\n | ((props: { close: () => void }) => React.ReactNode);\n /**\n * Whether the panel should be open by default when uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Whether the panel should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Custom class names for different parts of the popup panel\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n header?: string;\n title?: string;\n content?: string;\n footer?: string;\n resizeHandle?: string;\n };\n /**\n * Whether to close the panel when clicking outside\n * @default true\n */\n closeOnClickOutside?: boolean;\n /**\n * Whether to use modal mode\n * @default false\n */\n modal?: Popover.Root.Props[\"modal\"];\n}\n\nexport const PopupPanel = ({\n children,\n placement,\n openOnHover = false,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n content,\n title,\n trigger = \"click\",\n className,\n anchor,\n beforeCloseButton,\n afterCloseButton,\n afterTitle,\n size = \"medium\",\n footer,\n defaultOpen,\n resizable = false,\n classNames,\n modal = false,\n closeOnClickOutside = true,\n}: PopupPanelProps) => {\n // Use controlled state with proper initialization to prevent switching between controlled/uncontrolled\n const [open, setOpen] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen ?? false // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const headlessUIPlacement = parseAntdPlacement(placement);\n // We don't need triggerRef since we're using callbackRef for the popup\n const [popupRef, setPopupRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const callbackRef = useCallback((node: HTMLDivElement) => {\n setPopupRef(node);\n }, []);\n useEffect(() => {\n if (!popupRef) return;\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n setWidth(entry.contentRect.width);\n setHeight(entry.contentRect.height);\n }\n });\n observer.observe(popupRef);\n return () => {\n observer.disconnect();\n };\n }, [popupRef]);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n const renderTitle = useCallback(() => {\n return (\n <div className={clsx(cls(\"popup-panel-header\"), classNames?.header)}>\n <Flex\n align=\"center\"\n gap={8}\n className={cls(\"popup-panel-title-wrapper\")}\n >\n <Popover.Title\n render={\n <div className={clsx(cls(\"grow\", \"truncate\"), classNames?.title)}>\n {title}\n </div>\n }\n ></Popover.Title>\n <div className=\"flex items-center gap-2\">\n {beforeCloseButton}\n <Popover.Close\n render={<IconButton>{defaultCloseIcon}</IconButton>}\n />\n {afterCloseButton}\n </div>\n </Flex>\n {afterTitle ? afterTitle : null}\n </div>\n );\n }, [\n afterCloseButton,\n afterTitle,\n beforeCloseButton,\n cls,\n classNames?.header,\n classNames?.title,\n defaultCloseIcon,\n title,\n ]);\n const [resizing, setResizing] = useState(false);\n const { getRootProps, getHandleProps, rootRef } = useResizable({\n initialWidth: width,\n initialHeight: height,\n onDragStart: () => setResizing(true),\n onDragEnd: () => setResizing(false),\n });\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n const { ref: rootRefProp, ...rootPropsWithoutRef } = getRootProps();\n // Handle reverse handle change for vertical resizing\n // Currently not used but kept for future implementation\n // const _onReverseHandleChangeVertical = (\n // parent: React.RefObject<HTMLDivElement>,\n // values: MoveValues\n // ) => {\n // if (!parent.current) return;\n // const { heightDiff } = values;\n // parent.current.style.top = `${\n // parseInt(parent.current.style.top || \"0\") - heightDiff\n // }px`;\n // };\n\n // Handle reverse handle change\n const onReverseHandleChangeHorizontal = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current) return;\n const { widthDiff } = values;\n parent.current.style.left = `${\n parseInt(parent.current.style.left || \"0\") - widthDiff\n }px`;\n };\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(open, event, reason) => {\n if (reason === \"outside-press\" && !closeOnClickOutside) return;\n setOpen(open, event, reason);\n }}\n modal={modal}\n >\n <Popover.Trigger\n render={children}\n className={clsx(cls(\"popup-panel-trigger\"), classNames?.trigger)}\n ></Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner\n className={clsx(cls(\"popup-panel-root\"), classNames?.root)}\n side={headlessUIPlacement.placement}\n align={headlessUIPlacement.align}\n sideOffset={4}\n anchor={anchor}\n style={\n {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup\n )}\n ref={mergeRefs(rootRefProp, callbackRef)}\n {...rootPropsWithoutRef}\n {...(resizing ? { \"data-resizing\": true } : {})}\n >\n {/* <div ref={popupRef}> */}\n {title && renderTitle()}\n <div\n className={clsx(cls(\"popup-panel-content\"), classNames?.content)}\n >\n <div className={cls(\"popup-panel-content-inner\")}>{content}</div>\n </div>\n {footer && (\n <div\n className={clsx(cls(\"popup-panel-footer\"), classNames?.footer)}\n >\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n {resizable && (\n <>\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left\"\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left\"\n {...getHandleProps({\n reverse: true,\n lockVertical: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right\"\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n </>\n )}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n"],"names":["PopupPanel","children","placement","openOnHover","outsideOpen","outsideOnOpenChange","content","title","trigger","className","anchor","beforeCloseButton","afterCloseButton","afterTitle","size","footer","defaultOpen","resizable","classNames","modal","closeOnClickOutside","open","setOpen","useControlledState","cls","useCls","headlessUIPlacement","parseAntdPlacement","popupRef","setPopupRef","useState","width","setWidth","height","setHeight","callbackRef","useCallback","node","useEffect","observer","entries","entry","defaultCloseIcon","useMemo","jsx","X","renderTitle","jsxs","clsx","Flex","Popover","IconButton","resizing","setResizing","getRootProps","getHandleProps","rootRef","useResizable","rootRefProp","rootPropsWithoutRef","onReverseHandleChangeHorizontal","parent","values","widthDiff","event","reason","PopupPanelSize","mergeRefs","Fragment"],"mappings":";;;;;;;;;;;;;;AAsGO,MAAMA,KAAa,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAA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ACO,MACTF,EAAgCJ,GAASM,CAAM;AAAA,wBAClD,CAAA;AAAA,sBAAA;AAAA,oBACH;AAAA,oBACA,gBAAAlB;AAAA,sBAAC;AAAA,sBAAA;AAAA,wBACC,WAAWI;AAAA,0BACTxB,EAAI,2BAA2B;AAAA,0BAC/BN,KAAA,gBAAAA,EAAY;AAAA,wBACd;AAAA,wBACA,kBAAe;AAAA,wBACd,GAAGqC,EAAe;AAAA,0BACjB,cAAc;AAAA,wBACf,CAAA;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBACH,EACF,CAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UAEJ;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/popup-panel/component.tsx"],"sourcesContent":["\"use client\";\nimport { useCls, clsx, parseAntdPlacement } from \"../utils\";\nimport { Popover } from \"@base-ui-components/react/popover\";\n\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport Flex from \"antd/es/flex\";\nimport { IconButton } from \"../icon-button\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState } from \"../hooks\";\nimport { useResizable, type MoveValues } from \"react-use-resizable\";\nimport mergeRefs from \"merge-refs\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n > {\n /** The trigger element that opens the popup panel */\n children?: React.ComponentProps<typeof Popover.Trigger>[\"render\"];\n /** Placement of the popup panel relative to its trigger */\n placement?: PopoverProps[\"placement\"];\n /** Whether to open the popup panel on hover */\n openOnHover?: boolean;\n /** Controls the open state of the popup panel */\n open?: boolean;\n /** Callback fired when the open state changes */\n onOpenChange?: Popover.Root.Props[\"onOpenChange\"];\n /** Content to display inside the popup panel */\n content?: React.ReactNode;\n /** Title text or element to display in the panel header */\n title?: React.ReactNode;\n /** The event that triggers the popup panel */\n /**\n * @default \"click\"\n */\n trigger?: \"click\" | \"hover\";\n /** Custom anchor element for positioning the panel */\n anchor?: Popover.Positioner.Props[\"anchor\"];\n /** Content to display before the close button */\n beforeCloseButton?: React.ReactNode;\n /** Content to display after the close button */\n afterCloseButton?: React.ReactNode;\n /** Content to display after the title */\n afterTitle?: React.ReactNode;\n /**\n * Predefined sizes for the popup panel\n * - xsmall: 320px\n * - small: 400px\n * - medium: 480px (default)\n * - large: 640px\n * - xlarge: 840px\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?: keyof typeof PopupPanelSize;\n /**\n * Footer content for the popup panel\n * Can be a React node or a function that returns a React node\n */\n footer?:\n | React.ReactNode\n | ((props: { close: () => void }) => React.ReactNode);\n /**\n * Whether the panel should be open by default when uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Whether the panel should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Custom class names for different parts of the popup panel\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n header?: string;\n title?: string;\n content?: string;\n footer?: string;\n resizeHandle?: string;\n };\n /**\n * Whether to close the panel when clicking outside\n * @default true\n */\n closeOnClickOutside?: boolean;\n /**\n * Whether to use modal mode\n * @default false\n */\n modal?: Popover.Root.Props[\"modal\"];\n}\n\nexport const PopupPanel = ({\n children,\n placement,\n openOnHover = false,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n content,\n title,\n trigger = \"click\",\n className,\n anchor,\n beforeCloseButton,\n afterCloseButton,\n afterTitle,\n size = \"medium\",\n footer,\n defaultOpen,\n resizable = false,\n classNames,\n modal = false,\n closeOnClickOutside = true,\n}: PopupPanelProps) => {\n // Use controlled state with proper initialization to prevent switching between controlled/uncontrolled\n const [open, setOpen] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen ?? false // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const headlessUIPlacement = parseAntdPlacement(placement);\n // We don't need triggerRef since we're using callbackRef for the popup\n const [popupRef, setPopupRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const callbackRef = useCallback((node: HTMLDivElement) => {\n setPopupRef(node);\n }, []);\n useEffect(() => {\n if (!popupRef) return;\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n setWidth(entry.contentRect.width);\n setHeight(entry.contentRect.height);\n }\n });\n observer.observe(popupRef);\n return () => {\n observer.disconnect();\n };\n }, [popupRef]);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n const renderTitle = useCallback(() => {\n return (\n <div className={clsx(cls(\"popup-panel-header\"), classNames?.header)}>\n <Flex\n align=\"center\"\n gap={8}\n className={cls(\"popup-panel-title-wrapper\")}\n >\n <Popover.Title\n render={\n <div className={clsx(cls(\"grow\", \"truncate\"), classNames?.title)}>\n {title}\n </div>\n }\n ></Popover.Title>\n <div className=\"flex items-center gap-2\">\n {beforeCloseButton}\n <Popover.Close\n render={<IconButton>{defaultCloseIcon}</IconButton>}\n />\n {afterCloseButton}\n </div>\n </Flex>\n {afterTitle ? afterTitle : null}\n </div>\n );\n }, [\n afterCloseButton,\n afterTitle,\n beforeCloseButton,\n cls,\n classNames?.header,\n classNames?.title,\n defaultCloseIcon,\n title,\n ]);\n const [resizing, setResizing] = useState(false);\n const { getRootProps, getHandleProps, rootRef } = useResizable({\n initialWidth: width,\n initialHeight: height,\n onDragStart: () => setResizing(true),\n onDragEnd: () => setResizing(false),\n });\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n const { ref: rootRefProp, ...rootPropsWithoutRef } = getRootProps();\n // Handle reverse handle change for vertical resizing\n // Currently not used but kept for future implementation\n // const _onReverseHandleChangeVertical = (\n // parent: React.RefObject<HTMLDivElement>,\n // values: MoveValues\n // ) => {\n // if (!parent.current) return;\n // const { heightDiff } = values;\n // parent.current.style.top = `${\n // parseInt(parent.current.style.top || \"0\") - heightDiff\n // }px`;\n // };\n\n // Handle reverse handle change\n const onReverseHandleChangeHorizontal = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current) return;\n const { widthDiff } = values;\n parent.current.style.left = `${\n parseInt(parent.current.style.left || \"0\") - widthDiff\n }px`;\n };\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(open, event, reason) => {\n if (\n (reason === \"outside-press\" || reason === \"focus-out\") &&\n !closeOnClickOutside\n )\n return;\n setOpen(open, event, reason);\n }}\n modal={modal}\n >\n <Popover.Trigger\n render={children}\n className={clsx(cls(\"popup-panel-trigger\"), classNames?.trigger)}\n ></Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner\n className={clsx(cls(\"popup-panel-root\"), classNames?.root)}\n side={headlessUIPlacement.placement}\n align={headlessUIPlacement.align}\n sideOffset={4}\n anchor={anchor}\n style={\n {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup\n )}\n ref={mergeRefs(rootRefProp, callbackRef)}\n // resizable props\n {...(resizable ? rootPropsWithoutRef : {})}\n {...(resizing ? { \"data-resizing\": true } : {})}\n >\n {/* <div ref={popupRef}> */}\n {title && renderTitle()}\n <div\n className={clsx(cls(\"popup-panel-content\"), classNames?.content)}\n >\n <div className={cls(\"popup-panel-content-inner\")}>{content}</div>\n </div>\n {footer && (\n <div\n className={clsx(cls(\"popup-panel-footer\"), classNames?.footer)}\n >\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n {resizable && (\n <>\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left\"\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left\"\n {...getHandleProps({\n reverse: true,\n lockVertical: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right\"\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n </>\n )}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n"],"names":["PopupPanel","children","placement","openOnHover","outsideOpen","outsideOnOpenChange","content","title","trigger","className","anchor","beforeCloseButton","afterCloseButton","afterTitle","size","footer","defaultOpen","resizable","classNames","modal","closeOnClickOutside","open","setOpen","useControlledState","cls","useCls","headlessUIPlacement","parseAntdPlacement","popupRef","setPopupRef","useState","width","setWidth","height","setHeight","callbackRef","useCallback","node","useEffect","observer","entries","entry","defaultCloseIcon","useMemo","jsx","X","renderTitle","jsxs","clsx","Flex","Popover","IconButton","resizing","setResizing","getRootProps","getHandleProps","rootRef","useResizable","rootRefProp","rootPropsWithoutRef","onReverseHandleChangeHorizontal","parent","values","widthDiff","event","reason","PopupPanelSize","mergeRefs","Fragment"],"mappings":";;;;;;;;;;;;;;AAsGO,MAAMA,KAAa,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,QAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,E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GAAGqC,EAAe;AAAA,0BACjB,cAAc;AAAA,wBACf,CAAA;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBACH,EACF,CAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UAEJ;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ds-select-popup .ds-select-item-option-state{order:-1}.ds-select-popup .ds-select-checkbox-indicator,.ds-select-popup .ant-select-checkbox-indicator{margin-right:.5rem}.ds-select-multiple .ds-select-item-option-selected:not(.ds-select-item-option-disabled):not(:hover){background:transparent}.ds-select-popup-enhanced{
|
|
1
|
+
@layer components{.ds-select-popup .ds-select-item-option-state{order:-1}.ds-select-popup .ds-select-checkbox-indicator,.ds-select-popup .ant-select-checkbox-indicator{margin-right:.5rem}.ds-select-multiple .ds-select-item-option-selected:not(.ds-select-item-option-disabled):not(:hover){background:transparent}.ds-select-popup-enhanced{transition:none;width:var(--ds-select-popup-width);height:fit-content;max-width:calc(var(--available-width) - 16px);max-height:calc(var(--available-height) - 16px)}}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
3
|
import i from "antd/es/spin";
|
|
4
4
|
import './style.css';/* empty css */
|
|
5
|
-
import { useCls as
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
return /* @__PURE__ */
|
|
5
|
+
import { useCls as e } from "../utils/antdUtils.js";
|
|
6
|
+
const d = ({ indicator: n, size: o, ...r }) => {
|
|
7
|
+
const p = e(), s = n || /* @__PURE__ */ t("span", { className: p("spin-loader") });
|
|
8
|
+
return /* @__PURE__ */ t(
|
|
9
|
+
i,
|
|
10
|
+
{
|
|
11
|
+
indicator: s,
|
|
12
|
+
size: typeof o == "number" ? "default" : o,
|
|
13
|
+
style: {
|
|
14
|
+
"--spin-size": typeof o == "number" ? `${o}px` : void 0
|
|
15
|
+
},
|
|
16
|
+
...r
|
|
17
|
+
}
|
|
18
|
+
);
|
|
9
19
|
};
|
|
10
20
|
export {
|
|
11
|
-
|
|
21
|
+
d as Spin
|
|
12
22
|
};
|
|
13
23
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/spin/component.tsx"],"sourcesContent":["\"use client\";\nimport { useCls } from \"../utils\";\nimport { default as AntdSpin, SpinProps as AntdSpinProps } from \"antd/es/spin\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport type SpinProps = AntdSpinProps;\n\nexport const Spin = ({ indicator, ...rest }: SpinProps) => {\n const cls = useCls();\n const spinIndicator = indicator || <span className={cls(\"spin-loader\")} />;\n return <AntdSpin
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/spin/component.tsx"],"sourcesContent":["\"use client\";\nimport { useCls } from \"../utils\";\nimport { default as AntdSpin, SpinProps as AntdSpinProps } from \"antd/es/spin\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport type SpinProps = Omit<AntdSpinProps, \"size\"> & {\n size?: \"small\" | \"default\" | \"large\" | number;\n};\n\nexport const Spin = ({ indicator, size, ...rest }: SpinProps) => {\n const cls = useCls();\n const spinIndicator = indicator || <span className={cls(\"spin-loader\")} />;\n return (\n <AntdSpin\n indicator={spinIndicator}\n size={typeof size === \"number\" ? \"default\" : size}\n style={\n {\n \"--spin-size\": typeof size == \"number\" ? `${size}px` : undefined,\n } as React.CSSProperties\n }\n {...rest}\n />\n );\n};\n"],"names":["Spin","indicator","size","rest","cls","useCls","spinIndicator","jsx","AntdSpin"],"mappings":";;;;;AAWO,MAAMA,IAAO,CAAC,EAAE,WAAAC,GAAW,MAAAC,GAAM,GAAGC,QAAsB;AAC/D,QAAMC,IAAMC,EAAO,GACbC,IAAgBL,KAAa,gBAAAM,EAAC,UAAK,WAAWH,EAAI,aAAa,GAAG;AAEtE,SAAA,gBAAAG;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAWF;AAAA,MACX,MAAM,OAAOJ,KAAS,WAAW,YAAYA;AAAA,MAC7C,OACE;AAAA,QACE,eAAe,OAAOA,KAAQ,WAAW,GAAGA,CAAI,OAAO;AAAA,MACzD;AAAA,MAED,GAAGC;AAAA,IAAA;AAAA,EACN;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{:root{--ds-animate-spin: ds-spin 1s linear infinite}@keyframes ds-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.ds-spin .ds-spin-icon{animation:var(--ds-animate-spin);color:var(--ds-color-icon)}.ds-spin .ds-spin-text{color:var(--ds-color-icon)}.ds-spin-loader{width:1em;height:1em;border:max(2px,.12em) solid var(--ds-color-border);border-bottom-color:var(--ds-color-icon);border-radius:50%;display:inline-block;box-sizing:border-box;animation:spin 1s linear infinite}}
|
|
1
|
+
@layer components{:root{--ds-animate-spin: ds-spin 1s linear infinite}@keyframes ds-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.ds-spin .ds-spin-icon{animation:var(--ds-animate-spin);color:var(--ds-color-icon)}.ds-spin .ds-spin-text{color:var(--ds-color-icon)}.ds-spin-loader{width:var(--spin-size, 1em);height:var(--spin-size, 1em);border:max(2px,.12em) solid var(--ds-color-border);border-bottom-color:var(--ds-color-icon);border-radius:50%;display:inline-block;box-sizing:border-box;animation:spin 1s linear infinite}}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as p } from "react";
|
|
3
3
|
import { useRender as i } from "@base-ui-components/react/use-render";
|
|
4
|
-
const
|
|
5
|
-
const { render:
|
|
4
|
+
const c = (e, r) => {
|
|
5
|
+
const { render: n, as: t = "div", state: o, ...d } = e;
|
|
6
6
|
return i({
|
|
7
|
-
render:
|
|
8
|
-
props:
|
|
9
|
-
state:
|
|
7
|
+
render: n || ((s) => /* @__PURE__ */ m(t, { ...s })),
|
|
8
|
+
props: d,
|
|
9
|
+
state: o,
|
|
10
10
|
ref: r
|
|
11
11
|
});
|
|
12
|
-
},
|
|
12
|
+
}, l = p(c);
|
|
13
13
|
export {
|
|
14
|
-
|
|
14
|
+
l as WithRenderProp
|
|
15
15
|
};
|
|
16
16
|
//# sourceMappingURL=WithRenderProp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WithRenderProp.js","sources":["../../../src/components/utils/WithRenderProp.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { useRender } from \"@base-ui-components/react/use-render\";\nimport { ElementTypeToDOMType } from \"./types\";\n\nexport type WithRenderPropProps<\n T extends React.ElementType = \"div\",\n State extends Record<string, unknown> = Record<string, unknown>\n> = React.ComponentPropsWithoutRef<T> & {\n render?: useRender.RenderProp<State>;\n as?: T;\n state?: State;\n};\n\nconst WithRenderPropInner = <\n T extends React.ElementType = \"div\",\n State extends Record<string, unknown> = Record<string, unknown>\n>(\n props: WithRenderPropProps<T, State>,\n ref: React.ForwardedRef<T>\n) => {\n const { render, as: Tag = \"div\", ...etc } = props;\n const renderedElement = useRender({\n render: render || ((props) => <Tag {...props} />),\n props: etc,\n state
|
|
1
|
+
{"version":3,"file":"WithRenderProp.js","sources":["../../../src/components/utils/WithRenderProp.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { useRender } from \"@base-ui-components/react/use-render\";\nimport { ElementTypeToDOMType } from \"./types\";\n\nexport type WithRenderPropProps<\n T extends React.ElementType = \"div\",\n State extends Record<string, unknown> = Record<string, unknown>\n> = React.ComponentPropsWithoutRef<T> & {\n render?: useRender.RenderProp<State>;\n as?: T;\n state?: State;\n};\n\nconst WithRenderPropInner = <\n T extends React.ElementType = \"div\",\n State extends Record<string, unknown> = Record<string, unknown>\n>(\n props: WithRenderPropProps<T, State>,\n ref: React.ForwardedRef<T>\n) => {\n const { render, as: Tag = \"div\", state, ...etc } = props;\n const renderedElement = useRender({\n render: render || ((props) => <Tag {...props} />),\n props: etc,\n state,\n ref: ref as unknown as React.Ref<ElementTypeToDOMType<T>>,\n });\n return renderedElement;\n};\n\nexport const WithRenderProp = forwardRef(WithRenderPropInner) as <\n T extends React.ElementType = \"div\",\n State extends Record<string, unknown> = Record<string, unknown>\n>(\n props: WithRenderPropProps<T, State> & {\n ref?: React.Ref<ElementTypeToDOMType<T>>;\n }\n) => ReturnType<typeof WithRenderPropInner>;\n"],"names":["WithRenderPropInner","props","ref","render","Tag","state","etc","useRender","jsx","WithRenderProp","forwardRef"],"mappings":";;;AAaA,MAAMA,IAAsB,CAI1BC,GACAC,MACG;AACG,QAAA,EAAE,QAAAC,GAAQ,IAAIC,IAAM,OAAO,OAAAC,GAAO,GAAGC,MAAQL;AAO5C,SANiBM,EAAU;AAAA,IAChC,QAAQJ,MAAW,CAACF,MAAW,gBAAAO,EAAAJ,GAAA,EAAK,GAAGH,EAAO,CAAA;AAAA,IAC9C,OAAOK;AAAA,IACP,OAAAD;AAAA,IACA,KAAAH;AAAA,EAAA,CACD;AAEH,GAEaO,IAAiBC,EAAWV,CAAmB;"}
|