@bioturing/components 0.41.1 → 0.42.0-beta.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.
Files changed (43) hide show
  1. package/dist/base.d.ts +1 -0
  2. package/dist/base.d.ts.map +1 -1
  3. package/dist/base.js +1 -0
  4. package/dist/base.js.map +1 -1
  5. package/dist/components/dropdown-menu/component.d.ts.map +1 -1
  6. package/dist/components/dropdown-menu/component.js +153 -155
  7. package/dist/components/dropdown-menu/component.js.map +1 -1
  8. package/dist/components/dropdown-menu/style.css +1 -1
  9. package/dist/components/form/FormItem/FormItemInput.d.ts +50 -0
  10. package/dist/components/form/FormItem/FormItemInput.d.ts.map +1 -0
  11. package/dist/components/form/FormItem/FormItemInput.js +137 -0
  12. package/dist/components/form/FormItem/FormItemInput.js.map +1 -0
  13. package/dist/components/form/FormItem/FormItemLabel.d.ts +48 -0
  14. package/dist/components/form/FormItem/FormItemLabel.d.ts.map +1 -0
  15. package/dist/components/form/FormItem/FormItemLabel.js +80 -0
  16. package/dist/components/form/FormItem/FormItemLabel.js.map +1 -0
  17. package/dist/components/form/FormItem/ItemHolder.d.ts +33 -0
  18. package/dist/components/form/FormItem/ItemHolder.d.ts.map +1 -0
  19. package/dist/components/form/FormItem/ItemHolder.js +168 -0
  20. package/dist/components/form/FormItem/ItemHolder.js.map +1 -0
  21. package/dist/components/form/FormItem/index.d.ts +106 -0
  22. package/dist/components/form/FormItem/index.d.ts.map +1 -0
  23. package/dist/components/form/FormItem/index.js +234 -0
  24. package/dist/components/form/FormItem/index.js.map +1 -0
  25. package/dist/components/form/component.d.ts +7 -1
  26. package/dist/components/form/component.d.ts.map +1 -1
  27. package/dist/components/form/component.js +4 -4
  28. package/dist/components/form/item.d.ts +27 -23
  29. package/dist/components/form/item.d.ts.map +1 -1
  30. package/dist/components/form/label.d.ts.map +1 -1
  31. package/dist/components/form/label.js +33 -31
  32. package/dist/components/form/label.js.map +1 -1
  33. package/dist/components/form/style.css +1 -1
  34. package/dist/components/toast/function.d.ts +1 -1
  35. package/dist/components/toast/function.d.ts.map +1 -1
  36. package/dist/components/utils/renderProp.d.ts +1 -1
  37. package/dist/components/utils/renderProp.d.ts.map +1 -1
  38. package/dist/components/utils/renderProp.js +16 -10
  39. package/dist/components/utils/renderProp.js.map +1 -1
  40. package/dist/stats.html +1 -1
  41. package/package.json +4 -3
  42. package/dist/components/form/item.js +0 -43
  43. package/dist/components/form/item.js.map +0 -1
@@ -0,0 +1,137 @@
1
+ "use client";
2
+ import { jsx as t, jsxs as I, Fragment as q } from "react/jsx-runtime";
3
+ import * as n from "react";
4
+ import { get as y, set as z } from "rc-util";
5
+ import J from "rc-util/lib/hooks/useLayoutEffect";
6
+ import K from "antd/es/grid/col";
7
+ import { FormContext as H, FormItemPrefixContext as Q } from "antd/es/form/context";
8
+ import T from "antd/es/form/ErrorList";
9
+ import U from "antd/es/form/style/fallbackCmp";
10
+ import { clsx as l } from "../../utils/cn.js";
11
+ const Y = 24, ae = (N) => {
12
+ const {
13
+ prefixCls: a,
14
+ status: p,
15
+ labelCol: v,
16
+ wrapperCol: d,
17
+ children: M,
18
+ errors: w,
19
+ warnings: _,
20
+ _internalItemRender: i,
21
+ extra: m,
22
+ help: P,
23
+ fieldId: f,
24
+ marginBottom: u,
25
+ onErrorVisibleChanged: k,
26
+ label: $,
27
+ // ============ BioTuring Custom: Extract classNames ============
28
+ classNames: r
29
+ // ============ End Custom ============
30
+ } = N, o = `${a}-item`, e = n.useContext(H), j = n.useMemo(() => {
31
+ let s = {
32
+ ...d || e.wrapperCol || {}
33
+ };
34
+ return $ === null && !v && !d && e.labelCol && [void 0, "xs", "sm", "md", "lg", "xl", "xxl"].forEach((c) => {
35
+ const h = c ? [c] : [], D = y(e.labelCol, h), g = typeof D == "object" ? D : {}, E = y(s, h), X = typeof E == "object" ? E : {};
36
+ "span" in g && !("offset" in X) && g.span < Y && (s = z(
37
+ s,
38
+ [...h, "offset"],
39
+ g.span
40
+ ));
41
+ }), s;
42
+ }, [
43
+ d,
44
+ e.wrapperCol,
45
+ e.labelCol,
46
+ $,
47
+ v
48
+ ]), O = l(
49
+ `${o}-control`,
50
+ j.className,
51
+ r?.control
52
+ ), S = n.useMemo(() => {
53
+ const {
54
+ labelCol: s,
55
+ wrapperCol: G,
56
+ ...c
57
+ } = e;
58
+ return c;
59
+ }, [e]), x = n.useRef(null), [V, F] = n.useState(0);
60
+ J(() => {
61
+ m && x.current ? F(x.current.clientHeight) : F(0);
62
+ }, [m]);
63
+ const L = /* @__PURE__ */ t(
64
+ "div",
65
+ {
66
+ className: l(
67
+ `${o}-control-input`,
68
+ r?.controlInput
69
+ ),
70
+ children: /* @__PURE__ */ t(
71
+ "div",
72
+ {
73
+ className: l(
74
+ `${o}-control-input-content`,
75
+ r?.controlInputContent
76
+ ),
77
+ children: M
78
+ }
79
+ )
80
+ }
81
+ ), W = n.useMemo(
82
+ () => ({ prefixCls: a, status: p }),
83
+ [a, p]
84
+ ), C = u !== null || w.length || _.length ? /* @__PURE__ */ t(Q.Provider, { value: W, children: /* @__PURE__ */ t(
85
+ T,
86
+ {
87
+ fieldId: f,
88
+ errors: w,
89
+ warnings: _,
90
+ help: P,
91
+ helpStatus: p,
92
+ className: l(
93
+ `${o}-explain-connected`,
94
+ r?.explain
95
+ ),
96
+ onVisibleChanged: k
97
+ }
98
+ ) }) : null, R = {};
99
+ f && (R.id = `${f}_extra`);
100
+ const b = m ? /* @__PURE__ */ t(
101
+ "div",
102
+ {
103
+ ...R,
104
+ className: l(`${o}-extra`, r?.extra),
105
+ ref: x,
106
+ children: m
107
+ }
108
+ ) : null, A = C || b ? /* @__PURE__ */ I(
109
+ "div",
110
+ {
111
+ className: l(
112
+ `${o}-additional`,
113
+ r?.additional
114
+ ),
115
+ style: u ? { minHeight: u + V } : {},
116
+ children: [
117
+ C,
118
+ b
119
+ ]
120
+ }
121
+ ) : null, B = i && i.mark === "pro_table_render" && i.render ? i.render(N, {
122
+ input: L,
123
+ errorList: C,
124
+ extra: b
125
+ }) : /* @__PURE__ */ I(q, { children: [
126
+ L,
127
+ A
128
+ ] });
129
+ return /* @__PURE__ */ I(H.Provider, { value: S, children: [
130
+ /* @__PURE__ */ t(K, { ...j, className: O, children: B }),
131
+ /* @__PURE__ */ t(U, { prefixCls: a })
132
+ ] });
133
+ };
134
+ export {
135
+ ae as default
136
+ };
137
+ //# sourceMappingURL=FormItemInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormItemInput.js","sources":["../../../../src/components/form/FormItem/FormItemInput.tsx"],"sourcesContent":["/**\n * This file is copied from Ant Design 5.x-stable\n * Source: https://github.com/ant-design/ant-design/blob/5.x-stable/components/form/FormItemInput.tsx\n *\n * Customizations for @bioturing/components:\n * - Added `classNames` prop for styling control, input, error, and extra elements\n *\n * Last synced with antd version: 5.x-stable (2025-02-04)\n */\n\n\"use client\";\n\nimport * as React from \"react\";\nimport type { JSX } from \"react\";\nimport { get, set } from \"rc-util\";\nimport useLayoutEffect from \"rc-util/lib/hooks/useLayoutEffect\";\n\n// ============ BioTuring Utils ============\nimport { clsx as classNames } from \"../../utils\";\n\n// ============ Ant Design Imports ============\nimport type { ColProps } from \"antd/es/grid/col\";\nimport Col from \"antd/es/grid/col\";\nimport { FormContext, FormItemPrefixContext } from \"antd/es/form/context\";\nimport ErrorList from \"antd/es/form/ErrorList\";\nimport type { ValidateStatus } from \"antd/es/form/FormItem\";\nimport FallbackCmp from \"antd/es/form/style/fallbackCmp\";\ninterface FormItemInputMiscProps {\n prefixCls: string;\n children: React.ReactNode;\n errors: React.ReactNode[];\n warnings: React.ReactNode[];\n marginBottom?: number | null;\n onErrorVisibleChanged?: (visible: boolean) => void;\n /** @internal do not use in any of your production. */\n _internalItemRender?: {\n mark: string;\n render: (\n props: FormItemInputProps & FormItemInputMiscProps,\n domList: {\n input: JSX.Element;\n errorList: JSX.Element | null;\n extra: JSX.Element | null;\n },\n ) => React.ReactNode;\n };\n}\n\nexport interface FormItemInputProps {\n labelCol?: ColProps;\n wrapperCol?: ColProps;\n extra?: React.ReactNode;\n status?: ValidateStatus;\n help?: React.ReactNode;\n fieldId?: string;\n label?: React.ReactNode;\n\n // ============ BioTuring Custom ============\n classNames?: {\n control?: string;\n controlInput?: string;\n controlInputContent?: string;\n additional?: string;\n explain?: string;\n extra?: string;\n };\n // ============ End Custom ============\n}\n\nconst GRID_MAX = 24;\n\nconst FormItemInput: React.FC<FormItemInputProps & FormItemInputMiscProps> = (\n props,\n) => {\n const {\n prefixCls,\n status,\n labelCol,\n wrapperCol,\n children,\n errors,\n warnings,\n _internalItemRender: formItemRender,\n extra,\n help,\n fieldId,\n marginBottom,\n onErrorVisibleChanged,\n label,\n // ============ BioTuring Custom: Extract classNames ============\n classNames: customClassNames,\n // ============ End Custom ============\n } = props;\n const baseClassName = `${prefixCls}-item`;\n\n const formContext = React.useContext(FormContext);\n\n const mergedWrapperCol = React.useMemo(() => {\n let mergedWrapper: ColProps = {\n ...(wrapperCol || formContext.wrapperCol || {}),\n };\n if (label === null && !labelCol && !wrapperCol && formContext.labelCol) {\n const list = [undefined, \"xs\", \"sm\", \"md\", \"lg\", \"xl\", \"xxl\"] as const;\n\n list.forEach((size) => {\n const _size = size ? [size] : [];\n\n const formLabel = get(formContext.labelCol, _size);\n const formLabelObj = typeof formLabel === \"object\" ? formLabel : {};\n\n const wrapper = get(mergedWrapper, _size);\n const wrapperObj = typeof wrapper === \"object\" ? wrapper : {};\n\n if (\n \"span\" in formLabelObj &&\n !(\"offset\" in wrapperObj) &&\n formLabelObj.span < GRID_MAX\n ) {\n mergedWrapper = set(\n mergedWrapper,\n [..._size, \"offset\"],\n formLabelObj.span,\n );\n }\n });\n }\n return mergedWrapper;\n }, [\n wrapperCol,\n formContext.wrapperCol,\n formContext.labelCol,\n label,\n labelCol,\n ]);\n\n // ============ BioTuring Custom: Apply control className ============\n const className = classNames(\n `${baseClassName}-control`,\n mergedWrapperCol.className,\n customClassNames?.control,\n );\n // ============ End Custom ============\n\n // Pass to sub FormItem should not with col info\n const subFormContext = React.useMemo(() => {\n const {\n labelCol: _labelCol,\n wrapperCol: _wrapperCol,\n ...rest\n } = formContext;\n return rest;\n }, [formContext]);\n\n const extraRef = React.useRef<HTMLDivElement>(null);\n const [extraHeight, setExtraHeight] = React.useState<number>(0);\n useLayoutEffect(() => {\n if (extra && extraRef.current) {\n setExtraHeight(extraRef.current.clientHeight);\n } else {\n setExtraHeight(0);\n }\n }, [extra]);\n\n // ============ BioTuring Custom: Apply input classNames ============\n const inputDom: React.ReactNode = (\n <div\n className={classNames(\n `${baseClassName}-control-input`,\n customClassNames?.controlInput,\n )}\n >\n <div\n className={classNames(\n `${baseClassName}-control-input-content`,\n customClassNames?.controlInputContent,\n )}\n >\n {children}\n </div>\n </div>\n );\n // ============ End Custom ============\n\n const formItemContext = React.useMemo(\n () => ({ prefixCls, status }),\n [prefixCls, status],\n );\n\n // ============ BioTuring Custom: Apply explain className ============\n const errorListDom: React.ReactNode =\n marginBottom !== null || errors.length || warnings.length ? (\n <FormItemPrefixContext.Provider value={formItemContext}>\n <ErrorList\n fieldId={fieldId}\n errors={errors}\n warnings={warnings}\n help={help}\n helpStatus={status}\n className={classNames(\n `${baseClassName}-explain-connected`,\n customClassNames?.explain,\n )}\n onVisibleChanged={onErrorVisibleChanged}\n />\n </FormItemPrefixContext.Provider>\n ) : null;\n // ============ End Custom ============\n\n const extraProps: { id?: string } = {};\n\n if (fieldId) {\n extraProps.id = `${fieldId}_extra`;\n }\n\n // If extra = 0, && will goes wrong\n // 0&&error -> 0\n // ============ BioTuring Custom: Apply extra className ============\n const extraDom: React.ReactNode = extra ? (\n <div\n {...extraProps}\n className={classNames(`${baseClassName}-extra`, customClassNames?.extra)}\n ref={extraRef}\n >\n {extra}\n </div>\n ) : null;\n // ============ End Custom ============\n\n // ============ BioTuring Custom: Apply additional className ============\n const additionalDom: React.ReactNode =\n errorListDom || extraDom ? (\n <div\n className={classNames(\n `${baseClassName}-additional`,\n customClassNames?.additional,\n )}\n style={marginBottom ? { minHeight: marginBottom + extraHeight } : {}}\n >\n {errorListDom}\n {extraDom}\n </div>\n ) : null;\n // ============ End Custom ============\n\n const dom: React.ReactNode =\n formItemRender &&\n formItemRender.mark === \"pro_table_render\" &&\n formItemRender.render ? (\n formItemRender.render(props, {\n input: inputDom,\n errorList: errorListDom,\n extra: extraDom,\n })\n ) : (\n <>\n {inputDom}\n {additionalDom}\n </>\n );\n return (\n <FormContext.Provider value={subFormContext}>\n <Col {...mergedWrapperCol} className={className}>\n {dom}\n </Col>\n <FallbackCmp prefixCls={prefixCls} />\n </FormContext.Provider>\n );\n};\n\nexport default FormItemInput;\n"],"names":["GRID_MAX","FormItemInput","props","prefixCls","status","labelCol","wrapperCol","children","errors","warnings","formItemRender","extra","help","fieldId","marginBottom","onErrorVisibleChanged","label","customClassNames","baseClassName","formContext","React","FormContext","mergedWrapperCol","mergedWrapper","size","_size","formLabel","get","formLabelObj","wrapper","wrapperObj","set","className","classNames","subFormContext","_labelCol","_wrapperCol","rest","extraRef","extraHeight","setExtraHeight","useLayoutEffect","inputDom","jsx","formItemContext","errorListDom","FormItemPrefixContext","ErrorList","extraProps","extraDom","additionalDom","jsxs","dom","Fragment","Col","FallbackCmp"],"mappings":";;;;;;;;;;AAqEA,MAAMA,IAAW,IAEXC,KAAuE,CAC3EC,MACG;AACH,QAAM;AAAA,IACJ,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,UAAAC;AAAA,IACA,YAAAC;AAAA,IACA,UAAAC;AAAA,IACA,QAAAC;AAAA,IACA,UAAAC;AAAA,IACA,qBAAqBC;AAAA,IACrB,OAAAC;AAAA,IACA,MAAAC;AAAA,IACA,SAAAC;AAAA,IACA,cAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,OAAAC;AAAA;AAAA,IAEA,YAAYC;AAAA;AAAA,EAAA,IAEVf,GACEgB,IAAgB,GAAGf,CAAS,SAE5BgB,IAAcC,EAAM,WAAWC,CAAW,GAE1CC,IA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AAAA,QAChBD,GAAkB;AAAA,MAAA;AAAA,MAEpB,OAAOH,IAAe,EAAE,WAAWA,IAAeyB,EAAA,IAAgB,CAAA;AAAA,MAEjE,UAAA;AAAA,QAAAM;AAAA,QACAI;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAED,MAGAG,IACJ1C,KACAA,EAAe,SAAS,sBACxBA,EAAe,SACbA,EAAe,OAAOR,GAAO;AAAA,IAC3B,OAAOwC;AAAA,IACP,WAAWG;AAAA,IACX,OAAOI;AAAA,EAAA,CACR,IAED,gBAAAE,EAAAE,GAAA,EACG,UAAA;AAAA,IAAAX;AAAA,IACAQ;AAAA,EAAA,GACH;AAEJ,SACE,gBAAAC,EAAC9B,EAAY,UAAZ,EAAqB,OAAOa,GAC3B,UAAA;AAAA,IAAA,gBAAAS,EAACW,GAAA,EAAK,GAAGhC,GAAkB,WAAAU,GACxB,UAAAoB,GACH;AAAA,IACA,gBAAAT,EAACY,KAAY,WAAApD,EAAA,CAAsB;AAAA,EAAA,GACrC;AAEJ;"}
@@ -0,0 +1,48 @@
1
+ import { ColProps } from 'antd/es/grid/col';
2
+ import { TooltipProps } from 'antd/es/tooltip';
3
+ import { RequiredMark } from 'antd/es/form/Form';
4
+ import { FormLabelAlign } from 'antd/es/form/interface';
5
+ /**
6
+ * This file is copied from Ant Design 5.x-stable
7
+ * Source: https://github.com/ant-design/ant-design/blob/5.x-stable/components/form/FormItemLabel.tsx
8
+ *
9
+ * Customizations for @bioturing/components:
10
+ * - Added `classNames` prop for styling label elements
11
+ * - Integrated with BioTuring FormLabel component for consistent styling
12
+ * - Use QuestionIcon from @bioturing/assets instead of antd icon
13
+ * - Added optionalMark and labelRender prop support
14
+ * - Keep all antd context and colon handling logic
15
+ *
16
+ * Last synced with antd version: 5.x-stable (2025-02-04)
17
+ */
18
+ import * as React from "react";
19
+ export type WrapperTooltipProps = TooltipProps & {
20
+ icon?: React.ReactElement;
21
+ };
22
+ export type LabelTooltipType = WrapperTooltipProps | React.ReactNode;
23
+ export interface FormItemLabelProps {
24
+ colon?: boolean;
25
+ htmlFor?: string;
26
+ label?: React.ReactNode;
27
+ labelAlign?: FormLabelAlign;
28
+ labelCol?: ColProps;
29
+ /**
30
+ * @internal Used for pass `requiredMark` from `<Form />`
31
+ * Enhanced to support ReactNode in addition to standard RequiredMark types
32
+ */
33
+ requiredMark?: RequiredMark | React.ReactNode;
34
+ tooltip?: LabelTooltipType;
35
+ vertical?: boolean;
36
+ classNames?: {
37
+ label?: string;
38
+ labelText?: string;
39
+ };
40
+ optionalMark?: boolean | React.ReactNode;
41
+ labelRender?: (label: React.ReactElement) => React.ReactElement;
42
+ }
43
+ declare const FormItemLabel: React.FC<FormItemLabelProps & {
44
+ required?: boolean;
45
+ prefixCls: string;
46
+ }>;
47
+ export default FormItemLabel;
48
+ //# sourceMappingURL=FormItemLabel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormItemLabel.d.ts","sourceRoot":"","sources":["../../../../src/components/form/FormItem/FormItemLabel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAK7D,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG;IAC/C,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,GAAG,KAAK,CAAC,SAAS,CAAC;AAErE,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC;IAC9C,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,UAAU,CAAC,EAAE;QACX,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,YAAY,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC;IACzC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,KAAK,KAAK,CAAC,YAAY,CAAC;CAEjE;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAC3B,kBAAkB,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CA4H/D,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,80 @@
1
+ "use client";
2
+ import { jsx as n } from "react/jsx-runtime";
3
+ import * as L from "react";
4
+ import B from "antd/es/grid/col";
5
+ import { useLocale as I } from "antd/es/locale";
6
+ import W from "antd/es/locale/en_US";
7
+ import { FormContext as z } from "antd/es/form/context";
8
+ import { FormLabel as D } from "../label.js";
9
+ import { clsx as C } from "../../utils/cn.js";
10
+ const Y = ({
11
+ prefixCls: t,
12
+ label: o,
13
+ htmlFor: $,
14
+ labelCol: g,
15
+ labelAlign: N,
16
+ colon: r,
17
+ required: a,
18
+ requiredMark: l,
19
+ tooltip: F,
20
+ vertical: w,
21
+ // ============ BioTuring Custom ============
22
+ classNames: f,
23
+ optionalMark: p,
24
+ labelRender: h
25
+ // ============ End Custom ============
26
+ }) => {
27
+ const [x] = I("Form"), {
28
+ labelAlign: y,
29
+ labelCol: R,
30
+ labelWrap: S,
31
+ colon: A
32
+ } = L.useContext(z);
33
+ if (!o)
34
+ return null;
35
+ const d = g || R || {}, O = N || y, m = `${t}-item-label`, v = C(
36
+ m,
37
+ O === "left" && `${m}-left`,
38
+ d.className,
39
+ f?.label,
40
+ S && `${m}-wrap`
41
+ );
42
+ let e = o;
43
+ const b = r === !0 || A !== !1 && r !== !1;
44
+ b && !w && typeof o == "string" && o.trim() && (e = o.replace(/[:|:]\s*$/, ""));
45
+ const s = l === "optional", c = typeof l == "function", T = l === !1;
46
+ c ? e = l(e, { required: !!a }) : s && !a && (e = [
47
+ /* @__PURE__ */ n(L.Fragment, { children: e }, "label"),
48
+ /* @__PURE__ */ n("span", { className: `${t}-item-optional`, title: "", children: x?.optional || W.Form?.optional }, "optional")
49
+ ]);
50
+ let i;
51
+ T ? i = "hidden" : (s || c) && (i = "optional");
52
+ const u = /* @__PURE__ */ n(
53
+ D,
54
+ {
55
+ as: "span",
56
+ label: e,
57
+ tooltip: F,
58
+ optionalMark: !a && p && !s ? p : !1,
59
+ requiredMark: a && l !== !1 && !c && !s ? l : !1,
60
+ className: f?.labelText
61
+ }
62
+ ), j = h ? h(u) : u, k = C(
63
+ a && `${t}-item-required`,
64
+ i && `${t}-item-required-mark-${i}`,
65
+ !b && `${t}-item-no-colon`
66
+ );
67
+ return /* @__PURE__ */ n(B, { ...d, className: v, children: /* @__PURE__ */ n(
68
+ "label",
69
+ {
70
+ htmlFor: $,
71
+ className: k,
72
+ title: typeof o == "string" ? o : "",
73
+ children: j
74
+ }
75
+ ) });
76
+ };
77
+ export {
78
+ Y as default
79
+ };
80
+ //# sourceMappingURL=FormItemLabel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormItemLabel.js","sources":["../../../../src/components/form/FormItem/FormItemLabel.tsx"],"sourcesContent":["/**\n * This file is copied from Ant Design 5.x-stable\n * Source: https://github.com/ant-design/ant-design/blob/5.x-stable/components/form/FormItemLabel.tsx\n *\n * Customizations for @bioturing/components:\n * - Added `classNames` prop for styling label elements\n * - Integrated with BioTuring FormLabel component for consistent styling\n * - Use QuestionIcon from @bioturing/assets instead of antd icon\n * - Added optionalMark and labelRender prop support\n * - Keep all antd context and colon handling logic\n *\n * Last synced with antd version: 5.x-stable (2025-02-04)\n */\n\n\"use client\";\n\nimport * as React from \"react\";\n\n// ============ BioTuring Utils ============\nimport { clsx as classNames } from \"../../utils\";\n\n// ============ Ant Design Imports ============\nimport type { ColProps } from \"antd/es/grid/col\";\nimport Col from \"antd/es/grid/col\";\nimport { useLocale } from \"antd/es/locale\";\nimport defaultLocale from \"antd/es/locale/en_US\";\nimport type { TooltipProps } from \"antd/es/tooltip\";\nimport type { FormContextProps } from \"antd/es/form/context\";\nimport { FormContext } from \"antd/es/form/context\";\nimport type { RequiredMark } from \"antd/es/form/Form\";\nimport type { FormLabelAlign } from \"antd/es/form/interface\";\n\n// ============ BioTuring Custom Imports ============\nimport { FormLabel } from \"../label\";\n\nexport type WrapperTooltipProps = TooltipProps & {\n icon?: React.ReactElement;\n};\n\nexport type LabelTooltipType = WrapperTooltipProps | React.ReactNode;\n\nexport interface FormItemLabelProps {\n colon?: boolean;\n htmlFor?: string;\n label?: React.ReactNode;\n labelAlign?: FormLabelAlign;\n labelCol?: ColProps;\n /**\n * @internal Used for pass `requiredMark` from `<Form />`\n * Enhanced to support ReactNode in addition to standard RequiredMark types\n */\n requiredMark?: RequiredMark | React.ReactNode;\n tooltip?: LabelTooltipType;\n vertical?: boolean;\n\n // ============ BioTuring Custom Props ============\n classNames?: {\n label?: string;\n labelText?: string;\n };\n optionalMark?: boolean | React.ReactNode;\n labelRender?: (label: React.ReactElement) => React.ReactElement;\n // ============ End Custom Props ============\n}\n\nconst FormItemLabel: React.FC<\n FormItemLabelProps & { required?: boolean; prefixCls: string }\n> = ({\n prefixCls,\n label,\n htmlFor,\n labelCol,\n labelAlign,\n colon,\n required,\n requiredMark,\n tooltip,\n vertical,\n // ============ BioTuring Custom ============\n classNames: customClassNames,\n optionalMark,\n labelRender,\n // ============ End Custom ============\n}) => {\n const [formLocale] = useLocale(\"Form\");\n\n const {\n labelAlign: contextLabelAlign,\n labelCol: contextLabelCol,\n labelWrap,\n colon: contextColon,\n } = React.useContext<FormContextProps>(FormContext);\n\n if (!label) {\n return null;\n }\n\n // ============ Keep all antd logic unchanged ============\n const mergedLabelCol: ColProps = labelCol || contextLabelCol || {};\n const mergedLabelAlign: FormLabelAlign | undefined =\n labelAlign || contextLabelAlign;\n\n const labelClsBasic = `${prefixCls}-item-label`;\n\n // ============ BioTuring Custom: Apply label className ============\n const labelColClassName = classNames(\n labelClsBasic,\n mergedLabelAlign === \"left\" && `${labelClsBasic}-left`,\n mergedLabelCol.className,\n customClassNames?.label,\n labelWrap && `${labelClsBasic}-wrap`,\n );\n // ============ End Custom ============\n\n let labelChildren: React.ReactNode = label;\n\n // ============ Keep antd colon logic ============\n const computedColon =\n colon === true || (contextColon !== false && colon !== false);\n const haveColon = computedColon && !vertical;\n\n if (haveColon && typeof label === \"string\" && label.trim()) {\n labelChildren = label.replace(/[:|:]\\s*$/, \"\");\n }\n // ============ End colon logic ============\n\n // ============ Keep antd required mark logic ============\n const isOptionalMark = requiredMark === \"optional\";\n const isRenderMark = typeof requiredMark === \"function\";\n const hideRequiredMark = requiredMark === false;\n\n if (isRenderMark) {\n labelChildren = requiredMark(labelChildren, { required: !!required });\n } else if (isOptionalMark && !required) {\n // Combine label and optional mark using array with keys\n labelChildren = [\n <React.Fragment key=\"label\">{labelChildren}</React.Fragment>,\n <span key=\"optional\" className={`${prefixCls}-item-optional`} title=\"\">\n {formLocale?.optional || defaultLocale.Form?.optional}\n </span>,\n ];\n }\n\n let markType: string | undefined;\n if (hideRequiredMark) {\n markType = \"hidden\";\n } else if (isOptionalMark || isRenderMark) {\n markType = \"optional\";\n }\n // ============ End required mark logic ============\n\n // ============ BioTuring Custom: Use FormLabel for styling ============\n // Determine if we should show optional/required marks based on antd logic + custom props\n const shouldShowOptional = !required && optionalMark && !isOptionalMark;\n const shouldShowRequired =\n required && requiredMark !== false && !isRenderMark && !isOptionalMark;\n\n // Wrap labelChildren with FormLabel for consistent styling\n const styledLabel = (\n <FormLabel\n as=\"span\"\n label={labelChildren}\n tooltip={tooltip}\n optionalMark={shouldShowOptional ? optionalMark : false}\n requiredMark={shouldShowRequired ? requiredMark : false}\n className={customClassNames?.labelText}\n />\n );\n\n // Apply labelRender if provided\n const finalLabel = labelRender ? labelRender(styledLabel) : styledLabel;\n // ============ End Custom ============\n\n const labelClassName = classNames(\n required && `${prefixCls}-item-required`,\n markType && `${prefixCls}-item-required-mark-${markType}`,\n !computedColon && `${prefixCls}-item-no-colon`,\n );\n\n return (\n <Col {...mergedLabelCol} className={labelColClassName}>\n <label\n htmlFor={htmlFor}\n className={labelClassName}\n title={typeof label === \"string\" ? label : \"\"}\n >\n {finalLabel}\n </label>\n </Col>\n );\n};\n\nexport default FormItemLabel;\n"],"names":["FormItemLabel","prefixCls","label","htmlFor","labelCol","labelAlign","colon","required","requiredMark","tooltip","vertical","customClassNames","optionalMark","labelRender","formLocale","useLocale","contextLabelAlign","contextLabelCol","labelWrap","contextColon","React","FormContext","mergedLabelCol","mergedLabelAlign","labelClsBasic","labelColClassName","classNames","labelChildren","computedColon","isOptionalMark","isRenderMark","hideRequiredMark","jsx","defaultLocale","markType","styledLabel","FormLabel","finalLabel","labelClassName","Col"],"mappings":";;;;;;;;;AAiEA,MAAMA,IAEF,CAAC;AAAA,EACH,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA;AAAA,EAEA,YAAYC;AAAA,EACZ,cAAAC;AAAA,EACA,aAAAC;AAAA;AAEF,MAAM;AACJ,QAAM,CAACC,CAAU,IAAIC,EAAU,MAAM,GAE/B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D,cATFL,KAAYC,MAAiB,MAAS,CAACsB,KAAgB,CAACD,IASnBrB,IAAe;AAAA,MAClD,WAAWG,GAAkB;AAAA,IAAA;AAAA,EAAA,GAK3B0B,IAAaxB,IAAcA,EAAYsB,CAAW,IAAIA,GAGtDG,IAAiBZ;AAAAA,IACrBnB,KAAY,GAAGN,CAAS;AAAA,IACxBiC,KAAY,GAAGjC,CAAS,uBAAuBiC,CAAQ;AAAA,IACvD,CAACN,KAAiB,GAAG3B,CAAS;AAAA,EAAA;AAGhC,SACE,gBAAA+B,EAACO,GAAA,EAAK,GAAGjB,GAAgB,WAAWG,GAClC,UAAA,gBAAAO;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAAA7B;AAAA,MACA,WAAWmC;AAAA,MACX,OAAO,OAAOpC,KAAU,WAAWA,IAAQ;AAAA,MAE1C,UAAAmC;AAAA,IAAA;AAAA,EAAA,GAEL;AAEJ;"}
@@ -0,0 +1,33 @@
1
+ import { Meta } from 'rc-field-form/lib/interface';
2
+ import { FormItemProps } from '.';
3
+ import { ReportMetaChange } from 'antd/es/form/context';
4
+ /**
5
+ * This file is copied from Ant Design 5.x-stable
6
+ * Source: https://github.com/ant-design/ant-design/blob/5.x-stable/components/form/FormItem/ItemHolder.tsx
7
+ *
8
+ * Customizations for @bioturing/components:
9
+ * - Added `classNames` prop support for styling sub-elements
10
+ * - Pass custom props (optionalMark, requiredMark, labelRender) to FormItemLabel
11
+ *
12
+ * Last synced with antd version: 5.x-stable (2025-02-04)
13
+ */
14
+ import * as React from 'react';
15
+ export interface ItemHolderProps extends FormItemProps {
16
+ prefixCls: string;
17
+ className?: string;
18
+ rootClassName?: string;
19
+ style?: React.CSSProperties;
20
+ errors: React.ReactNode[];
21
+ warnings: React.ReactNode[];
22
+ meta: Meta;
23
+ children?: React.ReactNode;
24
+ fieldId?: string;
25
+ isRequired?: boolean;
26
+ onSubItemMetaChange: ReportMetaChange;
27
+ classNames?: FormItemProps['classNames'];
28
+ optionalMark?: FormItemProps['optionalMark'];
29
+ requiredMark?: FormItemProps['requiredMark'];
30
+ labelRender?: FormItemProps['labelRender'];
31
+ }
32
+ export default function ItemHolder(props: ItemHolderProps): import("react/jsx-runtime").JSX.Element;
33
+ //# sourceMappingURL=ItemHolder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ItemHolder.d.ts","sourceRoot":"","sources":["../../../../src/components/form/FormItem/ItemHolder.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AASxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC;AAEvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAU7D,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,gBAAgB,CAAC;IAGtC,UAAU,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC7C,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC7C,WAAW,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;CAE5C;AAED,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,eAAe,2CAqLxD"}
@@ -0,0 +1,168 @@
1
+ "use client";
2
+ import { jsxs as y, jsx as s } from "react/jsx-runtime";
3
+ import * as p from "react";
4
+ import G from "rc-util/lib/Dom/isVisible";
5
+ import J from "rc-util/lib/hooks/useLayoutEffect";
6
+ import Q from "rc-util/lib/omit";
7
+ import { Row as X } from "antd/es/grid";
8
+ import { FormContext as Y, NoStyleItemContext as Z } from "antd/es/form/context";
9
+ import C from "antd/es/form/hooks/useDebounce";
10
+ import { getStatus as ee } from "antd/es/form/util";
11
+ import re from "antd/es/form/FormItem/StatusProvider";
12
+ import te from "./FormItemInput.js";
13
+ import ae from "./FormItemLabel.js";
14
+ import { clsx as N } from "../../utils/cn.js";
15
+ function ve(l) {
16
+ const {
17
+ prefixCls: i,
18
+ className: $,
19
+ rootClassName: x,
20
+ style: F,
21
+ help: m,
22
+ errors: h,
23
+ warnings: v,
24
+ validateStatus: I,
25
+ meta: r,
26
+ hasFeedback: c,
27
+ hidden: V,
28
+ children: k,
29
+ fieldId: q,
30
+ required: M,
31
+ isRequired: R,
32
+ onSubItemMetaChange: P,
33
+ layout: E,
34
+ name: L,
35
+ // ============ BioTuring Custom: Extract classNames ============
36
+ classNames: n,
37
+ optionalMark: B,
38
+ requiredMark: _,
39
+ labelRender: j,
40
+ // ============ End Custom ============
41
+ ...H
42
+ } = l, e = `${i}-item`, { requiredMark: W, layout: z } = p.useContext(Y), u = E || z, A = u === "vertical", o = p.useRef(null), d = C(h), g = C(v), b = m != null, S = !!(b || h.length || v.length), D = !!o.current && G(o.current), [f, w] = p.useState(null);
43
+ J(() => {
44
+ if (S && o.current) {
45
+ const a = getComputedStyle(o.current);
46
+ w(Number.parseInt(a.marginBottom, 10));
47
+ }
48
+ }, [S, D]);
49
+ const K = (a) => {
50
+ a || w(null);
51
+ }, t = ((a = !1) => {
52
+ const T = a ? d : r.errors, U = a ? g : r.warnings;
53
+ return ee(T, U, r, "", !!c, I);
54
+ })(), O = N(
55
+ e,
56
+ $,
57
+ x,
58
+ n?.root,
59
+ (b || d.length || g.length) && `${e}-with-help`,
60
+ // Status
61
+ t && c && `${e}-has-feedback`,
62
+ t === "success" && `${e}-has-success`,
63
+ t === "warning" && `${e}-has-warning`,
64
+ t === "error" && `${e}-has-error`,
65
+ t === "validating" && `${e}-is-validating`,
66
+ V && `${e}-hidden`,
67
+ // Layout
68
+ u && `${e}-${u}`
69
+ );
70
+ return /* @__PURE__ */ y("div", { className: O, style: F, ref: o, children: [
71
+ /* @__PURE__ */ y(
72
+ X,
73
+ {
74
+ className: N(`${e}-row`, n?.row),
75
+ ...Q(H, [
76
+ "_internalItemRender",
77
+ "colon",
78
+ "dependencies",
79
+ "extra",
80
+ "fieldKey",
81
+ "getValueFromEvent",
82
+ "getValueProps",
83
+ "htmlFor",
84
+ "id",
85
+ // It is deprecated because `htmlFor` is its replacement.
86
+ "initialValue",
87
+ "isListField",
88
+ "label",
89
+ "labelAlign",
90
+ "labelCol",
91
+ "labelWrap",
92
+ "messageVariables",
93
+ "name",
94
+ "normalize",
95
+ "noStyle",
96
+ "preserve",
97
+ "requiredMark",
98
+ "rules",
99
+ "shouldUpdate",
100
+ "trigger",
101
+ "tooltip",
102
+ "validateFirst",
103
+ "validateTrigger",
104
+ "valuePropName",
105
+ "wrapperCol",
106
+ "validateDebounce"
107
+ ]),
108
+ children: [
109
+ /* @__PURE__ */ s(
110
+ ae,
111
+ {
112
+ htmlFor: q,
113
+ ...l,
114
+ requiredMark: _ ?? W,
115
+ required: M ?? R,
116
+ prefixCls: i,
117
+ vertical: A,
118
+ classNames: n,
119
+ optionalMark: B,
120
+ labelRender: j
121
+ }
122
+ ),
123
+ /* @__PURE__ */ s(
124
+ te,
125
+ {
126
+ ...l,
127
+ ...r,
128
+ errors: d,
129
+ warnings: g,
130
+ prefixCls: i,
131
+ status: t,
132
+ help: m,
133
+ marginBottom: f,
134
+ onErrorVisibleChanged: K,
135
+ classNames: n,
136
+ children: /* @__PURE__ */ s(Z.Provider, { value: P, children: /* @__PURE__ */ s(
137
+ re,
138
+ {
139
+ prefixCls: i,
140
+ meta: r,
141
+ errors: r.errors,
142
+ warnings: r.warnings,
143
+ hasFeedback: c,
144
+ validateStatus: t,
145
+ name: L,
146
+ children: k
147
+ }
148
+ ) })
149
+ }
150
+ )
151
+ ]
152
+ }
153
+ ),
154
+ !!f && /* @__PURE__ */ s(
155
+ "div",
156
+ {
157
+ className: `${e}-margin-offset`,
158
+ style: {
159
+ marginBottom: -f
160
+ }
161
+ }
162
+ )
163
+ ] });
164
+ }
165
+ export {
166
+ ve as default
167
+ };
168
+ //# sourceMappingURL=ItemHolder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ItemHolder.js","sources":["../../../../src/components/form/FormItem/ItemHolder.tsx"],"sourcesContent":["/**\n * This file is copied from Ant Design 5.x-stable\n * Source: https://github.com/ant-design/ant-design/blob/5.x-stable/components/form/FormItem/ItemHolder.tsx\n * \n * Customizations for @bioturing/components:\n * - Added `classNames` prop support for styling sub-elements\n * - Pass custom props (optionalMark, requiredMark, labelRender) to FormItemLabel\n * \n * Last synced with antd version: 5.x-stable (2025-02-04)\n */\n\n\"use client\";\n\nimport * as React from 'react';\nimport type { Meta } from 'rc-field-form/lib/interface';\nimport isVisible from 'rc-util/lib/Dom/isVisible';\nimport useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';\nimport omit from 'rc-util/lib/omit';\n\n// ============ BioTuring Utils ============\nimport { clsx as classNames } from '../../utils';\n\n// ============ Ant Design Imports ============\nimport type { FormItemProps } from '.';\nimport { Row } from 'antd/es/grid';\nimport type { ReportMetaChange } from 'antd/es/form/context';\nimport { FormContext, NoStyleItemContext } from 'antd/es/form/context';\nimport useDebounce from 'antd/es/form/hooks/useDebounce';\nimport { getStatus } from 'antd/es/form/util';\nimport StatusProvider from 'antd/es/form/FormItem/StatusProvider';\n\n// ============ BioTuring Custom Imports ============\nimport FormItemInput from './FormItemInput';\nimport FormItemLabel from './FormItemLabel';\n\nexport interface ItemHolderProps extends FormItemProps {\n prefixCls: string;\n className?: string;\n rootClassName?: string;\n style?: React.CSSProperties;\n errors: React.ReactNode[];\n warnings: React.ReactNode[];\n meta: Meta;\n children?: React.ReactNode;\n fieldId?: string;\n isRequired?: boolean;\n onSubItemMetaChange: ReportMetaChange;\n \n // ============ BioTuring Custom Props ============\n classNames?: FormItemProps['classNames'];\n optionalMark?: FormItemProps['optionalMark'];\n requiredMark?: FormItemProps['requiredMark'];\n labelRender?: FormItemProps['labelRender'];\n // ============ End Custom Props ============\n}\n\nexport default function ItemHolder(props: ItemHolderProps) {\n const {\n prefixCls,\n className,\n rootClassName,\n style,\n help,\n errors,\n warnings,\n validateStatus,\n meta,\n hasFeedback,\n hidden,\n children,\n fieldId,\n required,\n isRequired,\n onSubItemMetaChange,\n layout: propsLayout,\n name,\n // ============ BioTuring Custom: Extract classNames ============\n classNames: customClassNames,\n optionalMark,\n requiredMark,\n labelRender,\n // ============ End Custom ============\n ...restProps\n } = props;\n\n const itemPrefixCls = `${prefixCls}-item`;\n const { requiredMark: contextRequiredMark, layout: formLayout } = React.useContext(FormContext);\n const layout = propsLayout || formLayout;\n\n const vertical = layout === 'vertical';\n\n // ======================== Margin ========================\n const itemRef = React.useRef<HTMLDivElement>(null);\n const debounceErrors = useDebounce(errors);\n const debounceWarnings = useDebounce(warnings);\n const hasHelp = help !== undefined && help !== null;\n const hasError = !!(hasHelp || errors.length || warnings.length);\n const isOnScreen = !!itemRef.current && isVisible(itemRef.current);\n const [marginBottom, setMarginBottom] = React.useState<number | null>(null);\n\n useLayoutEffect(() => {\n if (hasError && itemRef.current) {\n // The element must be part of the DOMTree to use getComputedStyle\n // https://stackoverflow.com/questions/35360711/getcomputedstyle-returns-a-cssstyledeclaration-but-all-properties-are-empty-on-a\n const itemStyle = getComputedStyle(itemRef.current);\n setMarginBottom(Number.parseInt(itemStyle.marginBottom, 10));\n }\n }, [hasError, isOnScreen]);\n\n const onErrorVisibleChanged = (nextVisible: boolean) => {\n if (!nextVisible) {\n setMarginBottom(null);\n }\n };\n\n // ======================== Status ========================\n\n const getValidateState = (isDebounce = false) => {\n const _errors = isDebounce ? debounceErrors : meta.errors;\n const _warnings = isDebounce ? debounceWarnings : meta.warnings;\n\n return getStatus(_errors, _warnings, meta, '', !!hasFeedback, validateStatus);\n };\n\n const mergedValidateStatus = getValidateState();\n\n // ======================== Render ========================\n // ============ BioTuring Custom: Apply root className ============\n const itemClassName = classNames(\n itemPrefixCls,\n className,\n rootClassName,\n customClassNames?.root,\n (hasHelp || debounceErrors.length || debounceWarnings.length) && `${itemPrefixCls}-with-help`,\n // Status\n mergedValidateStatus && hasFeedback && `${itemPrefixCls}-has-feedback`,\n mergedValidateStatus === 'success' && `${itemPrefixCls}-has-success`,\n mergedValidateStatus === 'warning' && `${itemPrefixCls}-has-warning`,\n mergedValidateStatus === 'error' && `${itemPrefixCls}-has-error`,\n mergedValidateStatus === 'validating' && `${itemPrefixCls}-is-validating`,\n hidden && `${itemPrefixCls}-hidden`,\n // Layout\n layout && `${itemPrefixCls}-${layout}`,\n );\n // ============ End Custom ============\n\n return (\n <div className={itemClassName} style={style} ref={itemRef}>\n {/* ============ BioTuring Custom: Apply row className ============ */}\n <Row\n className={classNames(`${itemPrefixCls}-row`, customClassNames?.row)}\n {...omit(restProps, [\n '_internalItemRender' as any,\n 'colon',\n 'dependencies',\n 'extra',\n 'fieldKey',\n 'getValueFromEvent',\n 'getValueProps',\n 'htmlFor',\n 'id', // It is deprecated because `htmlFor` is its replacement.\n 'initialValue',\n 'isListField',\n 'label',\n 'labelAlign',\n 'labelCol',\n 'labelWrap',\n 'messageVariables',\n 'name',\n 'normalize',\n 'noStyle',\n 'preserve',\n 'requiredMark',\n 'rules',\n 'shouldUpdate',\n 'trigger',\n 'tooltip',\n 'validateFirst',\n 'validateTrigger',\n 'valuePropName',\n 'wrapperCol',\n 'validateDebounce',\n ])}\n >\n {/* Label */}\n <FormItemLabel\n htmlFor={fieldId}\n {...props}\n requiredMark={requiredMark ?? contextRequiredMark}\n required={required ?? isRequired}\n prefixCls={prefixCls}\n vertical={vertical}\n classNames={customClassNames}\n optionalMark={optionalMark}\n labelRender={labelRender}\n />\n {/* Input Group */}\n <FormItemInput\n {...props}\n {...meta}\n errors={debounceErrors}\n warnings={debounceWarnings}\n prefixCls={prefixCls}\n status={mergedValidateStatus}\n help={help}\n marginBottom={marginBottom}\n onErrorVisibleChanged={onErrorVisibleChanged}\n classNames={customClassNames}\n >\n <NoStyleItemContext.Provider value={onSubItemMetaChange}>\n <StatusProvider\n prefixCls={prefixCls}\n meta={meta}\n errors={meta.errors}\n warnings={meta.warnings}\n hasFeedback={hasFeedback}\n // Already calculated\n validateStatus={mergedValidateStatus}\n name={name}\n >\n {children}\n </StatusProvider>\n </NoStyleItemContext.Provider>\n </FormItemInput>\n </Row>\n {/* ============ End Custom ============ */}\n\n {!!marginBottom && (\n <div\n className={`${itemPrefixCls}-margin-offset`}\n style={{\n marginBottom: -marginBottom,\n }}\n />\n )}\n </div>\n );\n}\n"],"names":["ItemHolder","props","prefixCls","className","rootClassName","style","help","errors","warnings","validateStatus","meta","hasFeedback","hidden","children","fieldId","required","isRequired","onSubItemMetaChange","propsLayout","name","customClassNames","optionalMark","requiredMark","labelRender","restProps","itemPrefixCls","contextRequiredMark","formLayout","React","FormContext","layout","vertical","itemRef","debounceErrors","useDebounce","debounceWarnings","hasHelp","hasError","isOnScreen","isVisible","marginBottom","setMarginBottom","useLayoutEffect","itemStyle","onErrorVisibleChanged","nextVisible","mergedValidateStatus","isDebounce","_errors","_warnings","getStatus","itemClassName","classNames","jsxs","Row","omit","jsx","FormItemLabel","FormItemInput","NoStyleItemContext","StatusProvider"],"mappings":";;;;;;;;;;;;;;AAwDA,SAAwBA,GAAWC,GAAwB;AACzD,QAAM;AAAA,IACJ,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,eAAAC;AAAA,IACA,OAAAC;AAAA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;AAAA,cAC9B,UAAUX,KAAYC;AAAA,cACtB,WAAAd;AAAA,cACA,UAAA6B;AAAA,cACA,YAAYX;AAAA,cACZ,cAAAC;AAAA,cACA,aAAAE;AAAA,YAAA;AAAA,UAAA;AAAA,UAGF,gBAAAiC;AAAA,YAACE;AAAA,YAAA;AAAA,cACE,GAAGzD;AAAA,cACH,GAAGS;AAAA,cACJ,QAAQuB;AAAA,cACR,UAAUE;AAAA,cACV,WAAAjC;AAAA,cACA,QAAQ4C;AAAA,cACR,MAAAxC;AAAA,cACA,cAAAkC;AAAA,cACA,uBAAAI;AAAA,cACA,YAAYxB;AAAA,cAEZ,UAAA,gBAAAoC,EAACG,EAAmB,UAAnB,EAA4B,OAAO1C,GAClC,UAAA,gBAAAuC;AAAA,gBAACI;AAAA,gBAAA;AAAA,kBACC,WAAA1D;AAAA,kBACA,MAAAQ;AAAA,kBACA,QAAQA,EAAK;AAAA,kBACb,UAAUA,EAAK;AAAA,kBACf,aAAAC;AAAA,kBAEA,gBAAgBmC;AAAA,kBAChB,MAAA3B;AAAA,kBAEC,UAAAN;AAAA,gBAAA;AAAA,cAAA,EACH,CACF;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IAAA;AAAA,IAID,CAAC,CAAC2B,KACD,gBAAAgB;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAW,GAAG/B,CAAa;AAAA,QAC3B,OAAO;AAAA,UACL,cAAc,CAACe;AAAA,QAAA;AAAA,MACjB;AAAA,IAAA;AAAA,EACF,GAEJ;AAEJ;"}
@@ -0,0 +1,106 @@
1
+ import { FieldProps } from 'rc-field-form/lib/Field';
2
+ import { FormInstance, FormItemLayout } from 'antd/es/form/Form';
3
+ import { FormItemInputProps } from 'antd/es/form/FormItemInput';
4
+ import { FormItemLabelProps, LabelTooltipType } from 'antd/es/form/FormItemLabel';
5
+ import { default as useFormItemStatus } from 'antd/es/form/hooks/useFormItemStatus';
6
+ /**
7
+ * This file is copied from Ant Design 5.x-stable
8
+ * Source: https://github.com/ant-design/ant-design/blob/5.x-stable/components/form/FormItem/index.tsx
9
+ *
10
+ * Customizations for @bioturing/components:
11
+ * - Added `classNames` prop for styling sub-elements (root, row, label, control, etc.)
12
+ * - Added `optionalMark` prop to show optional indicator
13
+ * - Added enhanced `requiredMark` support (boolean | ReactNode)
14
+ * - Added `labelRender` prop for custom label rendering
15
+ *
16
+ * Last synced with antd version: 5.x-stable (2025-02-04)
17
+ */
18
+ import * as React from 'react';
19
+ declare const _ValidateStatuses: readonly ["success", "warning", "error", "validating", ""];
20
+ export type ValidateStatus = (typeof _ValidateStatuses)[number];
21
+ type RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode;
22
+ type RcFieldProps<Values = any> = Omit<FieldProps<Values>, 'children'>;
23
+ type ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode;
24
+ export type FeedbackIcons = (itemStatus: {
25
+ status: ValidateStatus;
26
+ errors?: React.ReactNode[];
27
+ warnings?: React.ReactNode[];
28
+ }) => {
29
+ [key in ValidateStatus]?: React.ReactNode;
30
+ };
31
+ export interface FormItemProps<Values = any> extends Omit<FormItemLabelProps, 'requiredMark'>, FormItemInputProps, RcFieldProps<Values> {
32
+ prefixCls?: string;
33
+ noStyle?: boolean;
34
+ style?: React.CSSProperties;
35
+ className?: string;
36
+ rootClassName?: string;
37
+ children?: ChildrenType<Values>;
38
+ id?: string;
39
+ hasFeedback?: boolean | {
40
+ icons: FeedbackIcons;
41
+ };
42
+ validateStatus?: ValidateStatus;
43
+ required?: boolean;
44
+ hidden?: boolean;
45
+ initialValue?: any;
46
+ messageVariables?: Record<string, string>;
47
+ tooltip?: LabelTooltipType;
48
+ /** @deprecated No need anymore */
49
+ fieldKey?: React.Key | React.Key[];
50
+ layout?: FormItemLayout;
51
+ /**
52
+ * Custom class names for different parts of the form item
53
+ * @custom BioTuring addition
54
+ */
55
+ classNames?: {
56
+ /** Class name for the form item root wrapper */
57
+ root?: string;
58
+ /** Class name for the row container */
59
+ row?: string;
60
+ /** Class name for the label column wrapper */
61
+ label?: string;
62
+ /** Class name for the label text element */
63
+ labelText?: string;
64
+ /** Class name for the label tooltip icon */
65
+ labelIcon?: string;
66
+ /** Class name for the control/input wrapper column */
67
+ control?: string;
68
+ /** Class name for the control input wrapper */
69
+ controlInput?: string;
70
+ /** Class name for the control input content */
71
+ controlInputContent?: string;
72
+ /** Class name for the additional wrapper (errors + extra) */
73
+ additional?: string;
74
+ /** Class name for the error/help message wrapper */
75
+ explain?: string;
76
+ /** Class name for the extra text wrapper */
77
+ extra?: string;
78
+ /** Class name for the feedback icon */
79
+ feedbackIcon?: string;
80
+ };
81
+ /**
82
+ * Whether to show the optional mark
83
+ * @default false
84
+ * @custom BioTuring addition
85
+ */
86
+ optionalMark?: boolean | React.ReactNode;
87
+ /**
88
+ * Custom required mark (enhanced from antd to support ReactNode)
89
+ * @default true
90
+ * @custom BioTuring addition - enhanced to support ReactNode
91
+ */
92
+ requiredMark?: boolean | React.ReactNode;
93
+ /**
94
+ * Custom render function for the label
95
+ * @custom BioTuring addition
96
+ */
97
+ labelRender?: (label: React.ReactElement) => React.ReactElement;
98
+ }
99
+ declare function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.ReactElement;
100
+ type InternalFormItemType = typeof InternalFormItem;
101
+ type CompoundedComponent = InternalFormItemType & {
102
+ useStatus: typeof useFormItemStatus;
103
+ };
104
+ declare const FormItem: CompoundedComponent;
105
+ export default FormItem;
106
+ //# sourceMappingURL=index.d.ts.map