@bioturing/components 0.22.0 → 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/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.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/spin/component.js +16 -6
- package/dist/components/spin/component.js.map +1 -1
- package/dist/components/spin/style.css +1 -1
- package/dist/index.d.ts +12 -5
- package/package.json +4 -4
|
@@ -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)
|
|
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}}
|
|
@@ -6,19 +6,21 @@ import s from "antd/es/form/FormList";
|
|
|
6
6
|
import { FormProvider as n } from "antd/es/form/context";
|
|
7
7
|
import p from "antd/es/form/hooks/useFormInstance";
|
|
8
8
|
import { FormItem as F } from "./item.js";
|
|
9
|
+
import { FormLabel as f } from "./label.js";
|
|
9
10
|
import './style.css';/* empty css */
|
|
10
|
-
const
|
|
11
|
+
const a = ({
|
|
11
12
|
...r
|
|
12
|
-
}) => /* @__PURE__ */ o(t, { ...r }),
|
|
13
|
+
}) => /* @__PURE__ */ o(t, { ...r }), x = Object.assign(a, {
|
|
13
14
|
useForm: i,
|
|
14
15
|
useFormInstance: p,
|
|
15
16
|
useWatch: e,
|
|
16
17
|
Item: F,
|
|
17
18
|
List: s,
|
|
18
19
|
ErrorList: m,
|
|
19
|
-
Provider: n
|
|
20
|
+
Provider: n,
|
|
21
|
+
Label: f
|
|
20
22
|
});
|
|
21
23
|
export {
|
|
22
|
-
|
|
24
|
+
x as Form
|
|
23
25
|
};
|
|
24
26
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/form/component.tsx"],"sourcesContent":["\"use client\";\nimport ErrorList from \"antd/es/form/ErrorList\";\nimport {\n FormProps as AntdFormProps,\n default as AntdInternalForm,\n useForm,\n useWatch,\n} from \"antd/es/form/Form\";\nimport FormList from \"antd/es/form/FormList\";\nimport { FormProvider } from \"antd/es/form/context\";\nimport useFormInstance from \"antd/es/form/hooks/useFormInstance\";\nimport * as React from \"react\";\nimport { FormItem, type FormItemProps } from \"./item\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface FormProps<Values =
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/form/component.tsx"],"sourcesContent":["\"use client\";\nimport ErrorList from \"antd/es/form/ErrorList\";\nimport {\n FormProps as AntdFormProps,\n default as AntdInternalForm,\n useForm,\n useWatch,\n} from \"antd/es/form/Form\";\nimport FormList from \"antd/es/form/FormList\";\nimport { FormProvider } from \"antd/es/form/context\";\nimport useFormInstance from \"antd/es/form/hooks/useFormInstance\";\nimport * as React from \"react\";\nimport { FormItem, type FormItemProps } from \"./item\";\nimport { FormLabel } from \"./label\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface FormProps<Values = unknown> extends AntdFormProps<Values> {}\n\ninterface InternalFormProps<Values = unknown>\n extends React.ComponentProps<typeof AntdInternalForm<Values>> {}\n\nconst InternalForm = <Values = unknown,>({\n ...rest\n}: InternalFormProps<Values>) => {\n return <AntdInternalForm {...rest} />;\n};\n\nexport const Form = Object.assign(InternalForm, {\n useForm,\n useFormInstance,\n useWatch,\n Item: FormItem,\n List: FormList,\n ErrorList,\n Provider: FormProvider,\n Label: FormLabel,\n});\n\nexport type { FormItemProps };\n"],"names":["InternalForm","rest","jsx","AntdInternalForm","Form","useForm","useFormInstance","useWatch","FormItem","FormList","ErrorList","FormProvider","FormLabel"],"mappings":";;;;;;;;;;AAuBA,MAAMA,IAAe,CAAoB;AAAA,EACvC,GAAGC;AACL,MACS,gBAAAC,EAACC,GAAkB,EAAA,GAAGF,EAAM,CAAA,GAGxBG,IAAO,OAAO,OAAOJ,GAAc;AAAA,EAC9C,SAAAK;AAAA,EACA,iBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAMC;AAAA,EACN,MAAMC;AAAA,EACN,WAAAC;AAAA,EACA,UAAUC;AAAA,EACV,OAAOC;AACT,CAAC;"}
|
|
@@ -1,45 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import { useCls as p } from "../utils/antdUtils.js";
|
|
7
|
-
import { IconButton as d } from "../icon-button/component.js";
|
|
8
|
-
const y = ({
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import p from "antd/es/form/FormItem";
|
|
4
|
+
import { FormLabel as s } from "./label.js";
|
|
5
|
+
const f = ({
|
|
9
6
|
tooltip: m,
|
|
10
|
-
label:
|
|
11
|
-
optionalMark:
|
|
12
|
-
requiredMark:
|
|
13
|
-
...
|
|
14
|
-
}) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
label: o,
|
|
8
|
+
optionalMark: t,
|
|
9
|
+
requiredMark: e = !0,
|
|
10
|
+
...n
|
|
11
|
+
}) => /* @__PURE__ */ r(
|
|
12
|
+
p,
|
|
13
|
+
{
|
|
14
|
+
label: /* @__PURE__ */ r(
|
|
15
|
+
s,
|
|
18
16
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
r,
|
|
25
|
-
m && /* @__PURE__ */ e(
|
|
26
|
-
d,
|
|
27
|
-
{
|
|
28
|
-
className: n("form-item-explaination-icon"),
|
|
29
|
-
label: typeof m == "string" || a(m) ? m : void 0,
|
|
30
|
-
children: /* @__PURE__ */ e(f, {})
|
|
31
|
-
}
|
|
32
|
-
),
|
|
33
|
-
s && /* @__PURE__ */ e("span", { className: n("form-item-label-optional-mark"), children: typeof s == "boolean" ? "(optional)" : s }),
|
|
34
|
-
o !== !1 && /* @__PURE__ */ e("span", { className: n("form-item-label-required-mark"), children: typeof o == "boolean" ? "*" : o })
|
|
35
|
-
]
|
|
17
|
+
label: o,
|
|
18
|
+
tooltip: m,
|
|
19
|
+
optionalMark: t,
|
|
20
|
+
requiredMark: e,
|
|
21
|
+
as: "span"
|
|
36
22
|
}
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
23
|
+
),
|
|
24
|
+
...n
|
|
25
|
+
}
|
|
26
|
+
);
|
|
42
27
|
export {
|
|
43
|
-
|
|
28
|
+
f as FormItem
|
|
44
29
|
};
|
|
45
30
|
//# sourceMappingURL=item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sources":["../../../src/components/form/item.tsx"],"sourcesContent":["\"use client\";\nimport {
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../src/components/form/item.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntdFormItem,\n type FormItemProps as AntdFormItemProps,\n} from \"antd/es/form/FormItem\";\nimport { FormLabel } from \"./label\";\n\nexport interface FormItemProps<Values = unknown>\n extends AntdFormItemProps<Values> {\n // tooltip?: React.ReactNode | TooltipProps;\n /**\n * Whether the field is optional. If true, the label will be marked as optional.\n * @default false\n */\n optionalMark?: boolean | React.ReactNode;\n /**\n * Whether show the asterisk when the field is required\n * @default true\n */\n requiredMark?: boolean | React.ReactNode;\n}\n\nexport const FormItem = <Values = unknown,>({\n tooltip,\n label,\n optionalMark,\n requiredMark = true,\n ...rest\n}: FormItemProps<Values>) => {\n return (\n <AntdFormItem\n label={\n <FormLabel\n label={label}\n tooltip={tooltip}\n optionalMark={optionalMark}\n requiredMark={requiredMark}\n as=\"span\"\n />\n }\n {...rest}\n />\n );\n};\n"],"names":["FormItem","tooltip","label","optionalMark","requiredMark","rest","jsx","AntdFormItem","FormLabel"],"mappings":";;;;AAsBO,MAAMA,IAAW,CAAoB;AAAA,EAC1C,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,GAAGC;AACL,MAEI,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,OACE,gBAAAD;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,OAAAN;AAAA,QACA,SAAAD;AAAA,QACA,cAAAE;AAAA,QACA,cAAAC;AAAA,QACA,IAAG;AAAA,MAAA;AAAA,IACL;AAAA,IAED,GAAGC;AAAA,EAAA;AACN;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as b, isValidElement as d } from "react";
|
|
4
|
+
import { QuestionIcon as h } from "@bioturing/assets";
|
|
5
|
+
import { useCls as u } from "../utils/antdUtils.js";
|
|
6
|
+
import { IconButton as N } from "../icon-button/component.js";
|
|
7
|
+
import { cn as x } from "../utils/cn.js";
|
|
8
|
+
import { WithRenderProp as y } from "../utils/WithRenderProp.js";
|
|
9
|
+
const I = ({
|
|
10
|
+
label: l,
|
|
11
|
+
tooltip: o,
|
|
12
|
+
optionalMark: n,
|
|
13
|
+
requiredMark: m = !0,
|
|
14
|
+
className: t,
|
|
15
|
+
as: i,
|
|
16
|
+
render: s,
|
|
17
|
+
...a
|
|
18
|
+
}, c) => {
|
|
19
|
+
const r = u(), f = [
|
|
20
|
+
l,
|
|
21
|
+
o && /* @__PURE__ */ e(
|
|
22
|
+
N,
|
|
23
|
+
{
|
|
24
|
+
className: r("form-item-explaination-icon"),
|
|
25
|
+
label: typeof o == "string" || d(o) ? o : void 0,
|
|
26
|
+
children: /* @__PURE__ */ e(h, {})
|
|
27
|
+
},
|
|
28
|
+
"tooltip"
|
|
29
|
+
),
|
|
30
|
+
n && /* @__PURE__ */ e("span", { className: r("form-item-label-optional-mark"), children: typeof n == "boolean" ? "(optional)" : n }, "optional"),
|
|
31
|
+
m !== !1 && /* @__PURE__ */ e("span", { className: r("form-item-label-required-mark"), children: typeof m == "boolean" ? "*" : m }, "required")
|
|
32
|
+
], p = {
|
|
33
|
+
ref: c,
|
|
34
|
+
className: x(
|
|
35
|
+
r(
|
|
36
|
+
"form-item-label-inner",
|
|
37
|
+
m && "form-item-label-with-required-mark"
|
|
38
|
+
),
|
|
39
|
+
t
|
|
40
|
+
),
|
|
41
|
+
children: f,
|
|
42
|
+
...a
|
|
43
|
+
};
|
|
44
|
+
return /* @__PURE__ */ e(y, { as: i || "span", render: s, ...p });
|
|
45
|
+
}, j = b(I);
|
|
46
|
+
export {
|
|
47
|
+
j as FormLabel
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","sources":["../../../src/components/form/label.tsx"],"sourcesContent":["\"use client\";\nimport React, {\n forwardRef,\n type ElementType,\n type Ref,\n ComponentPropsWithRef,\n isValidElement,\n} from \"react\";\nimport {\n useCls,\n WithRenderPropProps,\n WithRenderProp,\n ElementTypeToDOMType,\n cn,\n} from \"../utils\";\nimport { IconButton } from \"../icon-button\";\nimport { QuestionIcon } from \"@bioturing/assets\";\nimport { WrapperTooltipProps } from \"antd/es/form/FormItemLabel\";\n\nexport type FormLabelProps<E extends ElementType = \"label\"> =\n WithRenderPropProps<E> & {\n /**\n * Label content to display\n */\n label: React.ReactNode;\n /**\n * Optional tooltip to display next to the label\n */\n tooltip?: React.ReactNode | WrapperTooltipProps;\n /**\n * Whether to show optional mark or custom optional mark content\n * @default false\n */\n optionalMark?: boolean | React.ReactNode;\n /**\n * Whether to show required mark or custom required mark content\n * @default true\n */\n requiredMark?: boolean | React.ReactNode;\n };\n\n/**\n * Implementation of the FormLabel component\n */\nconst FormLabelImpl = <E extends ElementType = \"label\">(\n {\n label,\n tooltip,\n optionalMark,\n requiredMark = true,\n className,\n as,\n render,\n ...rest\n }: FormLabelProps<E>,\n ref: Ref<ElementTypeToDOMType<E>>\n) => {\n const cls = useCls();\n\n const labelContent = [\n label,\n tooltip && (\n <IconButton\n key=\"tooltip\"\n className={cls(\"form-item-explaination-icon\")}\n label={\n typeof tooltip === \"string\" || isValidElement(tooltip)\n ? tooltip\n : undefined\n }\n >\n <QuestionIcon />\n </IconButton>\n ),\n optionalMark && (\n <span key=\"optional\" className={cls(\"form-item-label-optional-mark\")}>\n {typeof optionalMark === \"boolean\" ? \"(optional)\" : optionalMark}\n </span>\n ),\n requiredMark !== false && (\n <span key=\"required\" className={cls(\"form-item-label-required-mark\")}>\n {typeof requiredMark === \"boolean\" ? \"*\" : requiredMark}\n </span>\n ),\n ];\n\n const elementProps = {\n ref,\n className: cn(\n cls(\n \"form-item-label-inner\",\n requiredMark && \"form-item-label-with-required-mark\"\n ),\n className\n ),\n children: labelContent,\n ...rest,\n };\n\n return <WithRenderProp as={as || \"span\"} render={render} {...elementProps} />;\n};\n\n// Export with correct typing\nexport const FormLabel = forwardRef(FormLabelImpl) as <\n E extends ElementType = \"label\"\n>(\n props: FormLabelProps<E> & { ref?: ComponentPropsWithRef<E>[\"ref\"] }\n) => ReturnType<typeof FormLabelImpl>;\n"],"names":["FormLabelImpl","label","tooltip","optionalMark","requiredMark","className","as","render","rest","ref","cls","useCls","labelContent","jsx","IconButton","isValidElement","QuestionIcon","elementProps","cn","WithRenderProp","FormLabel","forwardRef"],"mappings":";;;;;;;;AA4CA,MAAMA,IAAgB,CACpB;AAAA,EACE,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,WAAAC;AAAA,EACA,IAAAC;AAAA,EACA,QAAAC;AAAA,EACA,GAAGC;AACL,GACAC,MACG;AACH,QAAMC,IAAMC,EAAO,GAEbC,IAAe;AAAA,IACnBX;AAAA,IACAC,KACE,gBAAAW;AAAA,MAACC;AAAA,MAAA;AAAA,QAEC,WAAWJ,EAAI,6BAA6B;AAAA,QAC5C,OACE,OAAOR,KAAY,YAAYa,EAAeb,CAAO,IACjDA,IACA;AAAA,QAGN,4BAACc,GAAa,CAAA,CAAA;AAAA,MAAA;AAAA,MARV;AAAA,IASN;AAAA,IAEFb,KACE,gBAAAU,EAAC,QAAoB,EAAA,WAAWH,EAAI,+BAA+B,GAChE,UAAA,OAAOP,KAAiB,YAAY,eAAeA,EAAA,GAD5C,UAEV;AAAA,IAEFC,MAAiB,MACd,gBAAAS,EAAA,QAAA,EAAoB,WAAWH,EAAI,+BAA+B,GAChE,UAAO,OAAAN,KAAiB,YAAY,MAAMA,KADnC,UAEV;AAAA,EAEJ,GAEMa,IAAe;AAAA,IACnB,KAAAR;AAAA,IACA,WAAWS;AAAA,MACTR;AAAA,QACE;AAAA,QACAN,KAAgB;AAAA,MAClB;AAAA,MACAC;AAAA,IACF;AAAA,IACA,UAAUO;AAAA,IACV,GAAGJ;AAAA,EACL;AAEA,2BAAQW,GAAe,EAAA,IAAIb,KAAM,QAAQ,QAAAC,GAAiB,GAAGU,GAAc;AAC7E,GAGaG,IAAYC,EAAWrB,CAAa;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/icon-button/component.tsx"],"sourcesContent":["\"use client\";\nimport React, {\n forwardRef,\n type ElementType,\n type
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/icon-button/component.tsx"],"sourcesContent":["\"use client\";\nimport React, {\n forwardRef,\n type ElementType,\n type Ref,\n ComponentPropsWithRef,\n} from \"react\";\nimport { Tooltip, TooltipProps } from \"../tooltip\";\nimport {\n useCls,\n clsx,\n WithRenderPropProps,\n WithRenderProp,\n ElementTypeToDOMType,\n} from \"../utils\";\nimport { Spin } from \"../spin\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\n// Base props without href/as handling\nexport type IconButtonProps<E extends ElementType = \"button\"> =\n WithRenderPropProps<E, { loading: boolean }> & {\n /**\n * Label text or element to display within tooltip\n * @default undefined\n */\n label?: React.ReactNode;\n /**\n * Size of the icon button: small (1.25rem) or medium (1.5rem)\n * @default medium\n */\n size?: \"small\" | \"medium\";\n /**\n * Whether to apply negative margin for better visual alignment\n * @default true\n */\n negativeMargin?: boolean;\n /**\n * Whether to show loading state\n * @default false\n */\n loading?: boolean;\n /**\n * Props to pass to the Tooltip component when wrapping the button\n */\n tooltipProps?: TooltipProps;\n /**\n * Whether to show active state\n * @default false\n */\n active?: boolean;\n };\n\n/**\n * Implementation of the IconButton component\n */\nconst IconButtonImpl = <E extends ElementType = \"button\">(\n {\n label,\n size = \"medium\",\n negativeMargin = true,\n children,\n className,\n tooltipProps = {},\n active = false,\n as,\n href,\n // Extract anchor-specific props\n target,\n rel,\n download,\n hrefLang,\n referrerPolicy,\n loading,\n render,\n ...rest\n }: IconButtonProps<E>,\n ref: Ref<ElementTypeToDOMType<E>>\n) => {\n const cls = useCls();\n const buttonClasses = clsx(\n cls(\n \"icon-button\",\n `icon-button-${size}`,\n active && \"icon-button-active\",\n negativeMargin && \"icon-button-negative-margin\"\n ),\n className\n );\n\n // Use a type assertion for the component to avoid TypeScript errors\n const Component = (as || (href ? \"a\" : \"button\")) as ElementType;\n\n const elementProps = {\n ref,\n className: buttonClasses,\n ...(Component === \"button\" && { type: \"button\" }),\n ...(Component === \"a\"\n ? {\n ...(href && { href }),\n ...(target !== undefined && { target }),\n ...(rel !== undefined && { rel }),\n ...(download !== undefined && { download }),\n ...(hrefLang !== undefined && { hrefLang }),\n ...(referrerPolicy !== undefined && { referrerPolicy }),\n }\n : {}),\n \"data-loading\": loading,\n children: loading ? <Spin /> : children,\n ...rest,\n };\n\n const element = (\n <WithRenderProp\n as={Component}\n render={render}\n {...elementProps}\n state={{\n loading,\n }}\n />\n );\n\n return label ? (\n <Tooltip title={label} arrow={false} {...tooltipProps}>\n {element}\n </Tooltip>\n ) : (\n element\n );\n};\n\n// Export with correct typing\nexport const IconButton = forwardRef(IconButtonImpl) as <\n E extends ElementType = \"button\"\n>(\n props: IconButtonProps<E> & { ref?: ComponentPropsWithRef<E>[\"ref\"] }\n) => ReturnType<typeof IconButtonImpl>;\n"],"names":["IconButtonImpl","label","size","negativeMargin","children","className","tooltipProps","active","as","href","target","rel","download","hrefLang","referrerPolicy","loading","render","rest","ref","cls","useCls","buttonClasses","clsx","Component","elementProps","jsx","Spin","element","WithRenderProp","Tooltip","IconButton","forwardRef"],"mappings":";;;;;;;;;AAyDA,MAAMA,IAAiB,CACrB;AAAA,EACE,OAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,gBAAAC,IAAiB;AAAA,EACjB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC,IAAe,CAAC;AAAA,EAChB,QAAAC,IAAS;AAAA,EACT,IAAAC;AAAA,EACA,MAAAC;AAAA;AAAA,EAEA,QAAAC;AAAA,EACA,KAAAC;AAAA,EACA,UA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
|
|
|
1
|
-
@layer components{.ds-icon-button{display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:999px;cursor:pointer;background-color:transparent;color:var(--ds-color-icon);transition:all .2s}.ds-icon-button:hover{background-color:var(--ds-color-fill-secondary);color:var(--ds-color-icon-hover)}.ds-icon-button:active,.ds-icon-button.ds-icon-button-active,.ds-icon-button.ds-popover-open{background-color:var(--ds-color-primary-bg);color:var(--ds-color-primary)}.ds-icon-button:focus{outline:none}.ds-icon-button:disabled{cursor:not-allowed;pointer-events:none;color:var(--ds-color-text-disabled)}.ds-icon-button.ds-icon-button-medium{padding:.25rem;font-size:1.25rem;height:1.75rem;width:1.75rem}.ds-icon-button.ds-icon-button-medium.ds-icon-button-negative-margin{margin:-.25rem}.ds-icon-button.ds-icon-button-small{padding:.25rem;font-size:1rem;height:1.5rem;width:1.5rem}.ds-icon-button.ds-icon-button-small.ds-icon-button-negative-margin{margin:-.25rem}.ds-icon-button .ds-spin{font-size:.8em;line-height:1;display:flex;align-items:center;justify-content:center}}
|
|
1
|
+
@layer components{.ds-icon-button{display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:999px;cursor:pointer;background-color:transparent;color:var(--ds-color-icon);transition:all .2s}.ds-icon-button:hover{background-color:var(--ds-color-fill-secondary);color:var(--ds-color-icon-hover)}.ds-icon-button:active,.ds-icon-button.ds-icon-button-active,.ds-icon-button.ds-popover-open{background-color:var(--ds-color-primary-bg);color:var(--ds-color-primary)}.ds-icon-button:focus{outline:none}.ds-icon-button:focus-visible{outline:var(--ds-line-width-focus) solid var(--ds-color-primary-border);outline-offset:1px;transition:outline-offset 0s,outline 0s}.ds-icon-button:disabled{cursor:not-allowed;pointer-events:none;color:var(--ds-color-text-disabled)}.ds-icon-button.ds-icon-button-medium{padding:.25rem;font-size:1.25rem;height:1.75rem;width:1.75rem}.ds-icon-button.ds-icon-button-medium.ds-icon-button-negative-margin{margin:-.25rem}.ds-icon-button.ds-icon-button-small{padding:.25rem;font-size:1rem;height:1.5rem;width:1.5rem}.ds-icon-button.ds-icon-button-small.ds-icon-button-negative-margin{margin:-.25rem}.ds-icon-button .ds-spin{font-size:.8em;line-height:1;display:flex;align-items:center;justify-content:center}}
|
|
@@ -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","Main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AG,CAAA;AAAA,MAGxE,cAAcJ,KAAgBM;AAAA,MAC9B,SAASL,KAAWQ;AAAA,MACpB,YAAU;AAAA,MACT,GAAGN;AAAA,IAAA;AAAA,EAAA,IAGN,gBAAAhB;AAAA,IAACC,EAAS;AAAA,IAAT;AAAA,MACC,KAAAF;AAAA,MACA,QAAAa;AAAA,MACA,cAAAC;AAAA,MACA,SAAAC;AAAA,MACA,SAAAC;AAAA,MACA,aACEL,MAAgB,uBAAQc,GAAoB,EAAA,MAAM,GAAI,CAAA,IAAKd;AAAA,MAE5D,GAAGM;AAAA,IAAA;AAAA,EACN;AAEJ,GAGMS,IAAgB,CACpB3B,GACAC,wBAEQE,EAAS,UAAT,EAAkB,KAAAF,GAAW,GAAGD,GAAO,GAI3C4B,IAAYC,EAAW9B,CAAc,GAOrC+B,IAAWD,EAAWzB,CAAa,GAOnC2B,IAASF,EAAWlB,CAAW,GAO/BqB,IAAWH,EAAWF,CAAa,GAO5BM,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,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,EACZ,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,qBAAAC,IAAsB;AACxB,MAAuB;AAEf,QAAA,CAACC,GAAMC,CAAO,IAAIC;AAAA,IACtBnB;AAAA,IACAC;AAAA,IACAW,KAAe;AAAA;AAAA,EACjB,GAEMQ,IAAMC,GAAO,GACbC,IAAsBC,GAAmBzB,CAAS,GAElD,CAAC0B,GAAUC,CAAW,IAAIC,EAAgC,IAAI,GAC9D,CAACC,GAAOC,CAAQ,IAAIF,EAAiB,GACrC,CAACG,GAAQC,CAAS,IAA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,IACtCP;AAAA,oBAAA;AAAA,kBACN;AAAA,kBAEDE,KAEG,gBAAA8B,EAAAqB,GAAA,EAAA,UAAA;AAAA,oBAAA,gBAAAxB;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,gBAAgB;AAAA,wBACjB,CAAA;AAAA,sBAAA;AAAA,oBACH;AAAA,oBACA,gBAAAX;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,SAAS;AAAA,0BACT,cAAc;AAAA,0BACd,UAAU,CAACO,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,EACZ,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,qBAAAC,IAAsB;AACxB,MAAuB;AAEf,QAAA,CAACC,GAAMC,CAAO,IAAIC;AAAA,IACtBnB;AAAA,IACAC;AAAA,IACAW,KAAe;AAAA;AAAA,EACjB,GAEMQ,IAAMC,GAAO,GACbC,IAAsBC,GAAmBzB,CAAS,GAElD,CAAC0B,GAAUC,CAAW,IAAIC,EAAgC,IAAI,GAC9D,CAACC,GAAOC,CAAQ,IAAIF,EAAiB,GACrC,CAACG,GAAQC,CAAS,IAAIJ,EAAiB,GACvCK,IAAcC,EAAY,CAACC,MAAyB;AACxD,IAAAR,EAAYQ,CAAI;AAAA,EAClB,GAAG,EAAE;AACL,EAAAC,EAAU,MAAM;AACd,QAAI,CAACV,EAAU;AACf,UAAMW,IAAW,IAAI,eAAe,CAACC,MAAY;AAC/C,iBAAWC,KAASD;AACT,QAAAR,EAAAS,EAAM,YAAY,KAAK,GACtBP,EAAAO,EAAM,YAAY,MAAM;AAAA,IACpC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Ae;AAAA,wBACd,GAAGqC,EAAe;AAAA,0BACjB,gBAAgB;AAAA,wBACjB,CAAA;AAAA,sBAAA;AAAA,oBACH;AAAA,oBACA,gBAAAX;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,SAAS;AAAA,0BACT,cAAc;AAAA,0BACd,UAAU,CAACO,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,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}}
|
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ import { Dropdown } from 'antd';
|
|
|
82
82
|
import { DropDownProps } from 'antd';
|
|
83
83
|
import { DropdownProps } from 'antd';
|
|
84
84
|
import { ElementType } from 'react';
|
|
85
|
+
import { ElementTypeToDOMType as ElementTypeToDOMType_2 } from '..';
|
|
85
86
|
import { EmptyProps as EmptyProps_2 } from 'antd/es/empty';
|
|
86
87
|
import { ErrorListProps } from 'antd/es/form';
|
|
87
88
|
import { EventDataNode } from 'antd/es/tree';
|
|
@@ -94,6 +95,7 @@ import { FloatButtonProps } from 'antd';
|
|
|
94
95
|
import { FloatButtonRef } from 'antd';
|
|
95
96
|
import { FormInstance } from 'antd';
|
|
96
97
|
import { FormItemProps as FormItemProps_2 } from 'antd/es/form/FormItem';
|
|
98
|
+
import { FormLabelProps } from './label';
|
|
97
99
|
import { FormListFieldData } from 'antd';
|
|
98
100
|
import { FormListOperation } from 'antd';
|
|
99
101
|
import { FormListProps } from 'antd/es/form';
|
|
@@ -1718,7 +1720,7 @@ export { FloatButtonProps }
|
|
|
1718
1720
|
|
|
1719
1721
|
export { FloatButtonRef }
|
|
1720
1722
|
|
|
1721
|
-
export declare const Form: (<Values =
|
|
1723
|
+
export declare const Form: (<Values = unknown>({ ...rest }: InternalFormProps<Values>) => JSX.Element) & {
|
|
1722
1724
|
useForm: typeof useForm;
|
|
1723
1725
|
useFormInstance: typeof default_9;
|
|
1724
1726
|
useWatch: typeof useWatch;
|
|
@@ -1726,6 +1728,9 @@ export declare const Form: (<Values = any>({ ...rest }: InternalFormProps<Values
|
|
|
1726
1728
|
List: React_2.FC<FormListProps>;
|
|
1727
1729
|
ErrorList: React_2.FC<ErrorListProps>;
|
|
1728
1730
|
Provider: React_2.FC<FormProviderProps>;
|
|
1731
|
+
Label: <E extends React_2.ElementType = "label">(props: FormLabelProps<E> & {
|
|
1732
|
+
ref?: React_2.ComponentPropsWithRef<E>["ref"];
|
|
1733
|
+
}) => ReturnType<(<E_1 extends React_2.ElementType = "label">({ label, tooltip, optionalMark, requiredMark, className, as, render, ...rest }: FormLabelProps<E_1>, ref: React_2.Ref<ElementTypeToDOMType_2<E_1>>) => JSX.Element)>;
|
|
1729
1734
|
};
|
|
1730
1735
|
|
|
1731
1736
|
export { FormInstance }
|
|
@@ -1865,7 +1870,7 @@ export declare interface InputProps extends InputProps_2 {
|
|
|
1865
1870
|
|
|
1866
1871
|
export declare const InternalBadge: ({ count, showZero, ...rest }: BadgeProps) => JSX.Element;
|
|
1867
1872
|
|
|
1868
|
-
declare interface InternalFormProps<Values =
|
|
1873
|
+
declare interface InternalFormProps<Values = unknown> extends React_2.ComponentProps<typeof default_8<Values>> {
|
|
1869
1874
|
}
|
|
1870
1875
|
|
|
1871
1876
|
declare const InternalTable: <RecordType extends object = object>(props: TableProps<RecordType> & {
|
|
@@ -2934,7 +2939,7 @@ export declare interface ScrollAreaProps {
|
|
|
2934
2939
|
orientation?: "vertical" | "horizontal";
|
|
2935
2940
|
}
|
|
2936
2941
|
|
|
2937
|
-
declare const SearchInner: (
|
|
2942
|
+
declare const SearchInner: ({ enterButton, onSearch, prefix, onPressEnter, onClear, loading, ...rest }: SearchProps, ref: React.Ref<InputRef>) => JSX.Element;
|
|
2938
2943
|
|
|
2939
2944
|
export declare interface SearchProps extends SearchProps_2 {
|
|
2940
2945
|
}
|
|
@@ -2999,9 +3004,11 @@ export { Space }
|
|
|
2999
3004
|
|
|
3000
3005
|
export { SpaceProps }
|
|
3001
3006
|
|
|
3002
|
-
export declare const Spin: ({ indicator, ...rest }: SpinProps) => JSX.Element;
|
|
3007
|
+
export declare const Spin: ({ indicator, size, ...rest }: SpinProps) => JSX.Element;
|
|
3003
3008
|
|
|
3004
|
-
export declare type SpinProps = SpinProps_2
|
|
3009
|
+
export declare type SpinProps = Omit<SpinProps_2, "size"> & {
|
|
3010
|
+
size?: "small" | "default" | "large" | number;
|
|
3011
|
+
};
|
|
3005
3012
|
|
|
3006
3013
|
export declare const Split: default_2.FC<SplitterProps> & {
|
|
3007
3014
|
Panel: default_2.FC<SplitterPanelProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bioturing/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@ant-design/cssinjs": "^1.23.0",
|
|
20
|
-
"@base-ui-components/react": "1.0.0-beta.
|
|
21
|
-
"@floating-ui/react": "^0.27.
|
|
20
|
+
"@base-ui-components/react": "1.0.0-beta.1",
|
|
21
|
+
"@floating-ui/react": "^0.27.13",
|
|
22
22
|
"cmdk": "^1.1.1",
|
|
23
23
|
"es-toolkit": "^1.37.2",
|
|
24
24
|
"merge-refs": "^2.0.0",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"rc-table": "^7.50.4",
|
|
28
28
|
"rc-tree": "^5.13.1",
|
|
29
29
|
"react-use-resizable": "^0.2.0",
|
|
30
|
-
"tailwind-merge": "^3.
|
|
30
|
+
"tailwind-merge": "^3.3.1",
|
|
31
31
|
"@bioturing/assets": "0.18.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|