@bioturing/components 0.21.1 → 0.21.2
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.
|
@@ -4,16 +4,16 @@ import { useMemo as i, isValidElement as a } from "react";
|
|
|
4
4
|
import c from "antd/es/form/FormItem";
|
|
5
5
|
import { QuestionIcon as f } from "@bioturing/assets";
|
|
6
6
|
import { useCls as p } from "../utils/antdUtils.js";
|
|
7
|
-
import { IconButton as
|
|
7
|
+
import { IconButton as d } from "../icon-button/component.js";
|
|
8
8
|
const y = ({
|
|
9
9
|
tooltip: m,
|
|
10
|
-
label:
|
|
10
|
+
label: r,
|
|
11
11
|
optionalMark: s,
|
|
12
12
|
requiredMark: o = !0,
|
|
13
|
-
...
|
|
13
|
+
...t
|
|
14
14
|
}) => {
|
|
15
|
-
const n = p(),
|
|
16
|
-
() => /* @__PURE__ */ e(
|
|
15
|
+
const n = p(), l = i(
|
|
16
|
+
() => r ? /* @__PURE__ */ e(
|
|
17
17
|
"span",
|
|
18
18
|
{
|
|
19
19
|
className: n(
|
|
@@ -21,9 +21,9 @@ const y = ({
|
|
|
21
21
|
o && "form-item-label-with-required-mark"
|
|
22
22
|
),
|
|
23
23
|
children: [
|
|
24
|
-
|
|
24
|
+
r,
|
|
25
25
|
m && /* @__PURE__ */ e(
|
|
26
|
-
|
|
26
|
+
d,
|
|
27
27
|
{
|
|
28
28
|
className: n("form-item-explaination-icon"),
|
|
29
29
|
label: typeof m == "string" || a(m) ? m : void 0,
|
|
@@ -34,10 +34,10 @@ const y = ({
|
|
|
34
34
|
o !== !1 && /* @__PURE__ */ e("span", { className: n("form-item-label-required-mark"), children: typeof o == "boolean" ? "*" : o })
|
|
35
35
|
]
|
|
36
36
|
}
|
|
37
|
-
),
|
|
38
|
-
[
|
|
37
|
+
) : void 0,
|
|
38
|
+
[r, m, s, o, n]
|
|
39
39
|
);
|
|
40
|
-
return /* @__PURE__ */ e(c, { label:
|
|
40
|
+
return /* @__PURE__ */ e(c, { label: l, ...t });
|
|
41
41
|
};
|
|
42
42
|
export {
|
|
43
43
|
y as FormItem
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sources":["../../../src/components/form/item.tsx"],"sourcesContent":["\"use client\";\nimport { isValidElement, useMemo } from \"react\";\nimport {\n default as AntdFormItem,\n type FormItemProps as AntdFormItemProps,\n} from \"antd/es/form/FormItem\";\nimport { QuestionIcon } from \"@bioturing/assets\";\nimport { IconButton } from \"../icon-button\";\nimport { useCls } from \"../utils\";\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 const cls = useCls();\n\n // requiredMark is used in the className below\n const renderedLabel = useMemo(\n ()
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../src/components/form/item.tsx"],"sourcesContent":["\"use client\";\nimport { isValidElement, useMemo } from \"react\";\nimport {\n default as AntdFormItem,\n type FormItemProps as AntdFormItemProps,\n} from \"antd/es/form/FormItem\";\nimport { QuestionIcon } from \"@bioturing/assets\";\nimport { IconButton } from \"../icon-button\";\nimport { useCls } from \"../utils\";\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 const cls = useCls();\n\n // requiredMark is used in the className below\n const renderedLabel = useMemo(\n () =>\n label ? (\n <span\n className={cls(\n \"form-item-label-inner\",\n requiredMark && \"form-item-label-with-required-mark\"\n )}\n >\n {[\n label,\n tooltip && (\n <IconButton\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 className={cls(\"form-item-label-optional-mark\")}>\n {typeof optionalMark == \"boolean\" ? \"(optional)\" : optionalMark}\n </span>\n ),\n requiredMark !== false && (\n <span className={cls(\"form-item-label-required-mark\")}>\n {typeof requiredMark == \"boolean\" ? \"*\" : requiredMark}\n </span>\n ),\n ]}\n </span>\n ) : undefined,\n [label, tooltip, optionalMark, requiredMark, cls]\n );\n\n return <AntdFormItem label={renderedLabel} {...rest} />;\n};\n"],"names":["FormItem","tooltip","label","optionalMark","requiredMark","rest","cls","useCls","renderedLabel","useMemo","jsx","IconButton","isValidElement","QuestionIcon","AntdFormItem"],"mappings":";;;;;;;AAyBO,MAAMA,IAAW,CAAoB;AAAA,EAC1C,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,GAAGC;AACL,MAA6B;AAC3B,QAAMC,IAAMC,EAAO,GAGbC,IAAgBC;AAAA,IACpB,MACEP,IACE,gBAAAQ;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWJ;AAAA,UACT;AAAA,UACAF,KAAgB;AAAA,QAClB;AAAA,QAEC,UAAA;AAAA,UACCF;AAAA,UACAD,KACE,gBAAAS;AAAA,YAACC;AAAA,YAAA;AAAA,cACC,WAAWL,EAAI,6BAA6B;AAAA,cAC5C,OACE,OAAOL,KAAW,YAAYW,EAAeX,CAAO,IAChDA,IACA;AAAA,cAGN,4BAACY,GAAa,CAAA,CAAA;AAAA,YAAA;AAAA,UAChB;AAAA,UAEFV,KACG,gBAAAO,EAAA,QAAA,EAAK,WAAWJ,EAAI,+BAA+B,GACjD,UAAO,OAAAH,KAAgB,YAAY,eAAeA,EACrD,CAAA;AAAA,UAEFC,MAAiB,MACd,gBAAAM,EAAA,QAAA,EAAK,WAAWJ,EAAI,+BAA+B,GACjD,UAAO,OAAAF,KAAgB,YAAY,MAAMA,EAC5C,CAAA;AAAA,QAAA;AAAA,MAEJ;AAAA,IAAA,IAEA;AAAA,IACN,CAACF,GAAOD,GAASE,GAAcC,GAAcE,CAAG;AAAA,EAClD;AAEA,SAAQ,gBAAAI,EAAAI,GAAA,EAAa,OAAON,GAAgB,GAAGH,GAAM;AACvD;"}
|