@bioturing/components 0.22.0 → 0.24.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/drag-drop/draggable.js +7 -1
- package/dist/components/drag-drop/draggable.js.map +1 -1
- package/dist/components/drag-drop/droppable.js +58 -50
- package/dist/components/drag-drop/droppable.js.map +1 -1
- package/dist/components/drag-drop/style.css +1 -1
- package/dist/components/drag-drop/value.js +91 -67
- package/dist/components/drag-drop/value.js.map +1 -1
- package/dist/components/form/component.js +6 -4
- package/dist/components/form/component.js.map +1 -1
- package/dist/components/form/item.js +23 -38
- package/dist/components/form/item.js.map +1 -1
- package/dist/components/form/label.js +49 -0
- package/dist/components/form/label.js.map +1 -0
- package/dist/components/icon-button/component.js.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/components/tag/component.js.map +1 -1
- package/dist/components/tag/style.css +1 -1
- package/dist/components/truncate/component.js +87 -72
- package/dist/components/truncate/component.js.map +1 -1
- package/dist/components/truncate/helpers.js +44 -24
- package/dist/components/truncate/helpers.js.map +1 -1
- package/dist/components/truncate/style.css +1 -1
- package/dist/index.d.ts +41 -17
- package/package.json +5 -5
|
@@ -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}}
|
|
@@ -26,7 +26,13 @@ const F = ({
|
|
|
26
26
|
disabled: n,
|
|
27
27
|
onDragEnd: g,
|
|
28
28
|
onDragStart: E
|
|
29
|
-
}), t = c === !0 ? /* @__PURE__ */ p(
|
|
29
|
+
}), t = c === !0 ? /* @__PURE__ */ p(
|
|
30
|
+
C,
|
|
31
|
+
{
|
|
32
|
+
className: m("draggable-indicator")
|
|
33
|
+
},
|
|
34
|
+
"indicator-icon" + e
|
|
35
|
+
) : c, y = [
|
|
30
36
|
N(t) ? l ? R(t, {
|
|
31
37
|
...a,
|
|
32
38
|
...f,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draggable.js","sources":["../../../src/components/drag-drop/draggable.tsx"],"sourcesContent":["\"use client\";\n\nimport { useDraggable } from \"./hooks\";\nimport { clsx, useCls } from \"../utils\";\nimport { useRender } from \"@base-ui-components/react/use-render\";\nimport type { Data, DragDropDraggableProps } from \"./types\";\nimport { DotsSixVerticalIcon } from \"@bioturing/assets\";\nimport { cloneElement, isValidElement, HTMLProps } from \"react\";\n\n/**\n * A draggable item component that can be used within the Drag context\n */\nexport const Draggable = <T extends Data = Data>({\n id,\n children,\n className,\n disabled = false,\n data,\n style,\n render,\n onDragEnd,\n onDragStart,\n indicator = true,\n onlyIndicatorDraggable = false,\n ...rest\n}: DragDropDraggableProps<T>) => {\n const cls = useCls();\n\n const { attributes, listeners, isDragging, setNodeRef } = useDraggable({\n id,\n data,\n disabled,\n onDragEnd,\n onDragStart,\n });\n\n const indicatorIcon =\n indicator === true ? (\n <DotsSixVerticalIcon
|
|
1
|
+
{"version":3,"file":"draggable.js","sources":["../../../src/components/drag-drop/draggable.tsx"],"sourcesContent":["\"use client\";\n\nimport { useDraggable } from \"./hooks\";\nimport { clsx, useCls } from \"../utils\";\nimport { useRender } from \"@base-ui-components/react/use-render\";\nimport type { Data, DragDropDraggableProps } from \"./types\";\nimport { DotsSixVerticalIcon } from \"@bioturing/assets\";\nimport { cloneElement, isValidElement, HTMLProps } from \"react\";\n\n/**\n * A draggable item component that can be used within the Drag context\n */\nexport const Draggable = <T extends Data = Data>({\n id,\n children,\n className,\n disabled = false,\n data,\n style,\n render,\n onDragEnd,\n onDragStart,\n indicator = true,\n onlyIndicatorDraggable = false,\n ...rest\n}: DragDropDraggableProps<T>) => {\n const cls = useCls();\n\n const { attributes, listeners, isDragging, setNodeRef } = useDraggable({\n id,\n data,\n disabled,\n onDragEnd,\n onDragStart,\n });\n\n const indicatorIcon =\n indicator === true ? (\n <DotsSixVerticalIcon\n className={cls(\"draggable-indicator\")}\n key={\"indicator-icon\" + id}\n />\n ) : (\n indicator\n );\n const indicatorElement = isValidElement(indicatorIcon)\n ? onlyIndicatorDraggable\n ? cloneElement(indicatorIcon, {\n ...attributes,\n ...listeners,\n key: \"indicator\" + id,\n })\n : indicatorIcon\n : null;\n\n const combinedChildren = [\n indicatorElement,\n ...(Array.isArray(children) ? children : [children]),\n ];\n\n const renderedElement = useRender({\n render: render ? (\n render\n ) : (\n <div className={clsx(cls(\"draggable\"), className)} />\n ),\n ref: setNodeRef,\n props: {\n children: combinedChildren,\n className,\n style: {\n ...style,\n touchAction: \"none\", // Prevents scrolling on touch devices while dragging\n cursor: disabled ? \"default\" : \"grab\",\n opacity: isDragging ? 0.5 : 1, // Visual feedback when dragging\n },\n ...rest,\n ...attributes,\n ...(!onlyIndicatorDraggable ? listeners : {}),\n },\n state: {\n isDragging,\n id,\n data,\n },\n });\n\n return renderedElement;\n};\n"],"names":["Draggable","id","children","className","disabled","data","style","render","onDragEnd","onDragStart","indicator","onlyIndicatorDraggable","rest","cls","useCls","attributes","listeners","isDragging","setNodeRef","useDraggable","indicatorIcon","jsx","DotsSixVerticalIcon","combinedChildren","isValidElement","cloneElement","useRender","clsx"],"mappings":";;;;;;;;AAYO,MAAMA,IAAY,CAAwB;AAAA,EAC/C,IAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,wBAAAC,IAAyB;AAAA,EACzB,GAAGC;AACL,MAAiC;AAC/B,QAAMC,IAAMC,EAAO,GAEb,EAAE,YAAAC,GAAY,WAAAC,GAAW,YAAAC,GAAY,YAAAC,EAAA,IAAeC,EAAa;AAAA,IACrE,IAAAlB;AAAA,IACA,MAAAI;AAAA,IACA,UAAAD;AAAA,IACA,WAAAI;AAAA,IACA,aAAAC;AAAA,EAAA,CACD,GAEKW,IACJV,MAAc,KACZ,gBAAAW;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAWT,EAAI,qBAAqB;AAAA,IAAA;AAAA,IAC/B,mBAAmBZ;AAAA,EAAA,IAG1BS,GAYEa,IAAmB;AAAA,IAVAC,EAAeJ,CAAa,IACjDT,IACEc,EAAaL,GAAe;AAAA,MAC1B,GAAGL;AAAA,MACH,GAAGC;AAAA,MACH,KAAK,cAAcf;AAAA,IAAA,CACpB,IACDmB,IACF;AAAA,IAIF,GAAI,MAAM,QAAQlB,CAAQ,IAAIA,IAAW,CAACA,CAAQ;AAAA,EACpD;AA6BO,SA3BiBwB,EAAU;AAAA,IAChC,QAAQnB,KAGL,gBAAAc,EAAA,OAAA,EAAI,WAAWM,EAAKd,EAAI,WAAW,GAAGV,CAAS,EAAG,CAAA;AAAA,IAErD,KAAKe;AAAA,IACL,OAAO;AAAA,MACL,UAAUK;AAAA,MACV,WAAApB;AAAA,MACA,OAAO;AAAA,QACL,GAAGG;AAAA,QACH,aAAa;AAAA;AAAA,QACb,QAAQF,IAAW,YAAY;AAAA,QAC/B,SAASa,IAAa,MAAM;AAAA;AAAA,MAC9B;AAAA,MACA,GAAGL;AAAA,MACH,GAAGG;AAAA,MACH,GAAKJ,IAAqC,CAAA,IAAZK;AAAA,IAChC;AAAA,IACA,OAAO;AAAA,MACL,YAAAC;AAAA,MACA,IAAAhB;AAAA,MACA,MAAAI;AAAA,IAAA;AAAA,EACF,CACD;AAGH;"}
|
|
@@ -1,80 +1,88 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { memo as
|
|
4
|
-
import { useDroppable as
|
|
5
|
-
import { ArrowsOutCardinalIcon as
|
|
6
|
-
import { useRender as
|
|
7
|
-
import { Value as
|
|
8
|
-
import { uniqWith as
|
|
9
|
-
import { useCls as
|
|
10
|
-
import { clsx as
|
|
11
|
-
const
|
|
2
|
+
import { jsxs as h, jsx as n } from "react/jsx-runtime";
|
|
3
|
+
import { memo as y, useCallback as x, useMemo as D } from "react";
|
|
4
|
+
import { useDroppable as B } from "./hooks.js";
|
|
5
|
+
import { ArrowsOutCardinalIcon as F } from "@bioturing/assets";
|
|
6
|
+
import { useRender as G } from "@base-ui-components/react/use-render";
|
|
7
|
+
import { Value as H } from "./value.js";
|
|
8
|
+
import { uniqWith as I, isEqual as J } from "es-toolkit";
|
|
9
|
+
import { useCls as K } from "../utils/antdUtils.js";
|
|
10
|
+
import { clsx as Q } from "../utils/cn.js";
|
|
11
|
+
const S = ({
|
|
12
12
|
id: d,
|
|
13
|
-
children:
|
|
14
|
-
className:
|
|
15
|
-
disabled:
|
|
16
|
-
placeholder:
|
|
17
|
-
icon: f = /* @__PURE__ */ n(
|
|
18
|
-
render:
|
|
13
|
+
children: i,
|
|
14
|
+
className: E,
|
|
15
|
+
disabled: O = !1,
|
|
16
|
+
placeholder: m = "Drop items here",
|
|
17
|
+
icon: f = /* @__PURE__ */ n(F, {}),
|
|
18
|
+
render: R,
|
|
19
19
|
onDrop: c,
|
|
20
|
-
validate:
|
|
20
|
+
validate: j,
|
|
21
21
|
multiple: s,
|
|
22
22
|
value: r,
|
|
23
23
|
onChange: o,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
maxItems: p,
|
|
25
|
+
renderValueLabel: a,
|
|
26
|
+
renderValueIcon: N,
|
|
27
|
+
...q
|
|
27
28
|
}) => {
|
|
28
|
-
const e =
|
|
29
|
+
const e = K(), k = x(
|
|
29
30
|
(t) => {
|
|
30
31
|
c && c(t), o && o(
|
|
31
|
-
s ?
|
|
32
|
+
s ? I([...r, t.data], J) : t.data
|
|
32
33
|
);
|
|
33
34
|
},
|
|
34
35
|
[c, o, s, r]
|
|
35
|
-
), { isOver:
|
|
36
|
+
), { isOver: w, setNodeRef: A, attributes: M, listeners: P } = B({
|
|
36
37
|
id: d,
|
|
37
|
-
disabled:
|
|
38
|
-
onDrop:
|
|
39
|
-
validate:
|
|
40
|
-
}),
|
|
41
|
-
() => ({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
disabled: O,
|
|
39
|
+
onDrop: k,
|
|
40
|
+
validate: j
|
|
41
|
+
}), l = D(
|
|
42
|
+
() => ({
|
|
43
|
+
value: r,
|
|
44
|
+
onChange: o,
|
|
45
|
+
multiple: s,
|
|
46
|
+
renderValueLabel: a,
|
|
47
|
+
renderValueIcon: N,
|
|
48
|
+
maxItems: p
|
|
49
|
+
}),
|
|
50
|
+
[r, o, s, a, N, p]
|
|
51
|
+
), z = D(
|
|
52
|
+
() => i || /* @__PURE__ */ h("div", { className: e("drop-zone-content"), children: [
|
|
45
53
|
/* @__PURE__ */ n("div", { className: e("drop-zone-icon"), children: f }),
|
|
46
|
-
/* @__PURE__ */ n("div", { className: e("drop-zone-text"), children:
|
|
54
|
+
/* @__PURE__ */ n("div", { className: e("drop-zone-text"), children: m })
|
|
47
55
|
] }),
|
|
48
|
-
[
|
|
49
|
-
),
|
|
50
|
-
({ className: t, ...
|
|
51
|
-
|
|
56
|
+
[i, e, f, m]
|
|
57
|
+
), W = x(
|
|
58
|
+
({ className: t, ...b }) => !s && r || s && r.length ? /* @__PURE__ */ n(
|
|
59
|
+
H,
|
|
52
60
|
{
|
|
53
|
-
...
|
|
61
|
+
...l,
|
|
54
62
|
className: t,
|
|
55
|
-
...
|
|
63
|
+
...b
|
|
56
64
|
}
|
|
57
|
-
) : /* @__PURE__ */ n("div", { className:
|
|
58
|
-
[r, s,
|
|
65
|
+
) : /* @__PURE__ */ n("div", { className: Q(e("drop-zone"), t), ...b, children: z }),
|
|
66
|
+
[r, s, l, z, e]
|
|
59
67
|
);
|
|
60
|
-
return
|
|
61
|
-
render:
|
|
62
|
-
ref:
|
|
68
|
+
return G({
|
|
69
|
+
render: R ?? W,
|
|
70
|
+
ref: A,
|
|
63
71
|
props: {
|
|
64
|
-
className:
|
|
65
|
-
...
|
|
66
|
-
...
|
|
67
|
-
...
|
|
72
|
+
className: E,
|
|
73
|
+
...M,
|
|
74
|
+
...P,
|
|
75
|
+
...q
|
|
68
76
|
},
|
|
69
77
|
state: {
|
|
70
|
-
isOver:
|
|
78
|
+
isOver: w,
|
|
71
79
|
value: r,
|
|
72
80
|
onChange: o,
|
|
73
81
|
id: d
|
|
74
82
|
}
|
|
75
83
|
});
|
|
76
|
-
},
|
|
84
|
+
}, V = y(S);
|
|
77
85
|
export {
|
|
78
|
-
|
|
86
|
+
V as Droppable
|
|
79
87
|
};
|
|
80
88
|
//# sourceMappingURL=droppable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"droppable.js","sources":["../../../src/components/drag-drop/droppable.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useCallback, useMemo, memo } from \"react\";\nimport { useDroppable } from \"./hooks\";\nimport { clsx, useCls } from \"../utils\";\nimport { ArrowsOutCardinalIcon } from \"@bioturing/assets\";\nimport { useRender } from \"@base-ui-components/react/use-render\";\nimport type { Data, DragDropDroppableProps, DraggableInfo } from \"./types\";\nimport { Value } from \"./value\";\nimport { uniqWith, isEqual } from \"es-toolkit\";\n\n/**\n * A drop zone component that can receive draggable items\n * Styled similarly to the Upload component's droppable area\n */\nconst DroppableInner = <T extends Data = Data, M extends boolean = false>({\n id,\n children,\n className,\n disabled = false,\n placeholder = \"Drop items here\",\n icon = <ArrowsOutCardinalIcon
|
|
1
|
+
{"version":3,"file":"droppable.js","sources":["../../../src/components/drag-drop/droppable.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useCallback, useMemo, memo } from \"react\";\nimport { useDroppable } from \"./hooks\";\nimport { clsx, useCls } from \"../utils\";\nimport { ArrowsOutCardinalIcon } from \"@bioturing/assets\";\nimport { useRender } from \"@base-ui-components/react/use-render\";\nimport type { Data, DragDropDroppableProps, DraggableInfo } from \"./types\";\nimport { Value } from \"./value\";\nimport { uniqWith, isEqual } from \"es-toolkit\";\n\n/**\n * A drop zone component that can receive draggable items\n * Styled similarly to the Upload component's droppable area\n */\nconst DroppableInner = <T extends Data = Data, M extends boolean = false>({\n id,\n children,\n className,\n disabled = false,\n placeholder = \"Drop items here\",\n icon = <ArrowsOutCardinalIcon />,\n render,\n onDrop,\n validate,\n multiple,\n value,\n onChange,\n maxItems,\n renderValueLabel,\n renderValueIcon,\n ...rest\n}: DragDropDroppableProps<T, M>) => {\n const cls = useCls();\n const handleOnDrop = useCallback(\n (item: DraggableInfo<T>) => {\n if (onDrop) {\n onDrop(item);\n }\n if (onChange) {\n if (multiple) {\n (onChange as (value: T[]) => void)(\n uniqWith([...(value as T[]), item.data], isEqual)\n );\n } else {\n (onChange as (value: T) => void)(item.data);\n }\n }\n },\n [onDrop, onChange, multiple, value]\n );\n const { isOver, setNodeRef, attributes, listeners } = useDroppable({\n id,\n disabled,\n onDrop: handleOnDrop,\n validate,\n });\n\n // memoize value props to avoid re-renders\n const valueProps = useMemo(\n () => ({\n value,\n onChange,\n multiple,\n renderValueLabel,\n renderValueIcon,\n maxItems,\n }),\n [value, onChange, multiple, renderValueLabel, renderValueIcon, maxItems]\n );\n\n // memoize dropzone content\n const dropzoneContent = useMemo(\n () =>\n children || (\n <div className={cls(\"drop-zone-content\")}>\n <div className={cls(\"drop-zone-icon\")}>{icon}</div>\n <div className={cls(\"drop-zone-text\")}>{placeholder}</div>\n </div>\n ),\n [children, cls, icon, placeholder]\n );\n\n // memoize default render tree\n const defaultRender = useCallback<\n (props: Record<string, unknown>) => React.ReactElement\n >(\n ({ className, ...props }) =>\n (!multiple && value) || (multiple && (value as T[]).length) ? (\n <Value<T, M>\n {...valueProps}\n className={className as string}\n {...props}\n />\n ) : (\n <div className={clsx(cls(\"drop-zone\"), className as string)} {...props}>\n {dropzoneContent}\n </div>\n ),\n [value, multiple, valueProps, dropzoneContent, cls]\n );\n\n const renderedElement = useRender({\n render: render ?? defaultRender,\n ref: setNodeRef,\n props: {\n className: className,\n ...attributes,\n ...listeners,\n ...rest,\n },\n state: {\n isOver,\n value,\n onChange: onChange as (value: M extends true ? T[] : T) => void,\n id,\n },\n });\n\n return renderedElement;\n};\n\nexport const Droppable = memo(DroppableInner) as typeof DroppableInner;\n"],"names":["DroppableInner","id","children","className","disabled","placeholder","icon","ArrowsOutCardinalIcon","render","onDrop","validate","multiple","value","onChange","maxItems","renderValueLabel","renderValueIcon","rest","cls","useCls","handleOnDrop","useCallback","item","uniqWith","isEqual","isOver","setNodeRef","attributes","listeners","useDroppable","valueProps","useMemo","dropzoneContent","jsxs","jsx","defaultRender","props","Value","clsx","useRender","Droppable","memo"],"mappings":";;;;;;;;;;AAeA,MAAMA,IAAiB,CAAmD;AAAA,EACxE,IAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,aAAAC,IAAc;AAAA,EACd,MAAAC,sBAAQC,GAAsB,EAAA;AAAA,EAC9B,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,GAAGC;AACL,MAAoC;AAClC,QAAMC,IAAMC,EAAO,GACbC,IAAeC;AAAA,IACnB,CAACC,MAA2B;AAC1B,MAAIb,KACFA,EAAOa,CAAI,GAETT,KAECA;AAAA,QADCF,IAEAY,EAAS,CAAC,GAAIX,GAAeU,EAAK,IAAI,GAAGE,CAAO,IAGjBF,EAAK;AAAA,MAFtC;AAAA,IAKN;AAAA,IACA,CAACb,GAAQI,GAAUF,GAAUC,CAAK;AAAA,EACpC,GACM,EAAE,QAAAa,GAAQ,YAAAC,GAAY,YAAAC,GAAY,WAAAC,EAAA,IAAcC,EAAa;AAAA,IACjE,IAAA5B;AAAA,IACA,UAAAG;AAAA,IACA,QAAQgB;AAAA,IACR,UAAAV;AAAA,EAAA,CACD,GAGKoB,IAAaC;AAAA,IACjB,OAAO;AAAA,MACL,OAAAnB;AAAA,MACA,UAAAC;AAAA,MACA,UAAAF;AAAA,MACA,kBAAAI;AAAA,MACA,iBAAAC;AAAA,MACA,UAAAF;AAAA,IAAA;AAAA,IAEF,CAACF,GAAOC,GAAUF,GAAUI,GAAkBC,GAAiBF,CAAQ;AAAA,EACzE,GAGMkB,IAAkBD;AAAA,IACtB,MACE7B,KACE,gBAAA+B,EAAC,SAAI,WAAWf,EAAI,mBAAmB,GACrC,UAAA;AAAA,MAAA,gBAAAgB,EAAC,OAAI,EAAA,WAAWhB,EAAI,gBAAgB,GAAI,UAAKZ,GAAA;AAAA,wBAC5C,OAAI,EAAA,WAAWY,EAAI,gBAAgB,GAAI,UAAYb,EAAA,CAAA;AAAA,IAAA,GACtD;AAAA,IAEJ,CAACH,GAAUgB,GAAKZ,GAAMD,CAAW;AAAA,EACnC,GAGM8B,IAAgBd;AAAA,IAGpB,CAAC,EAAE,WAAAlB,GAAW,GAAGiC,EACd,MAAA,CAACzB,KAAYC,KAAWD,KAAaC,EAAc,SAClD,gBAAAsB;AAAA,MAACG;AAAA,MAAA;AAAA,QACE,GAAGP;AAAA,QACJ,WAAW3B;AAAAA,QACV,GAAGiC;AAAA,MAAA;AAAA,IAGN,IAAA,gBAAAF,EAAC,OAAI,EAAA,WAAWI,EAAKpB,EAAI,WAAW,GAAGf,CAAmB,GAAI,GAAGiC,GAC9D,UACHJ,EAAA,CAAA;AAAA,IAEJ,CAACpB,GAAOD,GAAUmB,GAAYE,GAAiBd,CAAG;AAAA,EACpD;AAmBO,SAjBiBqB,EAAU;AAAA,IAChC,QAAQ/B,KAAU2B;AAAA,IAClB,KAAKT;AAAA,IACL,OAAO;AAAA,MACL,WAAAvB;AAAA,MACA,GAAGwB;AAAA,MACH,GAAGC;AAAA,MACH,GAAGX;AAAA,IACL;AAAA,IACA,OAAO;AAAA,MACL,QAAAQ;AAAA,MACA,OAAAb;AAAA,MACA,UAAAC;AAAA,MACA,IAAAZ;AAAA,IAAA;AAAA,EACF,CACD;AAGH,GAEauC,IAAYC,EAAKzC,CAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ds-drag-container{position:relative}.ds-draggable{position:relative;cursor:grab;-webkit-user-select:none;user-select:none;background-color:var(--ds-color-bg-container);border:1px solid var(--ds-color-border);border-radius:var(--ds-border-radius);padding:.5rem;margin-bottom:.5rem;display:flex;max-width:100%;gap:.5rem;transition:background-color .2s,border-color .2s,box-shadow .2s}.ds-draggable[data-dragging]{opacity:.5;box-shadow:0 2px 8px #00000026;z-index:1}.ds-draggable[data-disabled]{cursor:not-allowed;opacity:.5;background-color:var(--ds-color-bg-disabled)}.ds-draggable:hover{border-color:var(--ds-color-primary)}.ds-draggable .ds-draggable-indicator{font-size:1.25rem;color:var(--ds-color-icon)}.ds-drop-zone{position:relative;width:100%;background-color:var(--ds-color-fill-alter);border:1px dashed var(--ds-color-border);border-radius:var(--ds-border-radius);padding:.75rem;display:flex;align-items:center;justify-content:center;transition:border-color .1s,background-color .1s}.ds-drop-zone[data-disabled=true]{cursor:not-allowed;background-color:var(--ds-color-bg-disabled);border-color:var(--ds-color-border)}.ds-drop-zone[data-dropping][data-valid],.ds-drop-zone[data-over][data-valid]{border-color:var(--ds-color-primary);background-color:var(--ds-color-primary-bg)}.ds-drop-zone[data-dragging][data-valid]{border-color:var(--ds-color-primary)}.ds-drop-zone .ds-drop-zone-content{display:flex;align-items:center;justify-content:center;text-align:center;gap:.5rem}.ds-drop-zone .ds-drop-zone-icon{font-size:1.25rem;color:var(--ds-color-icon)}.ds-drop-zone .ds-drop-zone-text{color:var(--ds-color-text-description);font-size:var(--ds-font-size)}.ds-dropzone-value{padding:.75rem;border-radius:var(--ds-border-radius);border-width:1px;border-style:solid;border-color:var(--ds-color-border)}.ds-dropzone-value[data-dragging][data-valid]{border-color:var(--ds-color-primary);border-style:dashed}.ds-dropzone-value[data-dropping][data-valid],.ds-dropzone-value[data-over][data-valid]{border-color:var(--ds-color-primary);background-color:var(--ds-color-primary-bg)}.ds-dropzone-value-icon{color:var(--ds-color-icon);font-size:1.5rem}.ds-dropzone-value-text{color:var(--ds-color-text-secondary)}
|
|
1
|
+
.ds-drag-container{position:relative}.ds-draggable{position:relative;cursor:grab;-webkit-user-select:none;user-select:none;background-color:var(--ds-color-bg-container);border:1px solid var(--ds-color-border);border-radius:var(--ds-border-radius);padding:.5rem;margin-bottom:.5rem;display:flex;max-width:100%;gap:.5rem;transition:background-color .2s,border-color .2s,box-shadow .2s}.ds-draggable[data-dragging]{opacity:.5;box-shadow:0 2px 8px #00000026;z-index:1}.ds-draggable[data-disabled]{cursor:not-allowed;opacity:.5;background-color:var(--ds-color-bg-disabled)}.ds-draggable:hover{border-color:var(--ds-color-primary)}.ds-draggable .ds-draggable-indicator{font-size:1.25rem;color:var(--ds-color-icon)}.ds-drop-zone{position:relative;width:100%;background-color:var(--ds-color-fill-alter);border:1px dashed var(--ds-color-border);border-radius:var(--ds-border-radius);padding:.75rem;display:flex;align-items:center;justify-content:center;transition:border-color .1s,background-color .1s}.ds-drop-zone[data-disabled=true]{cursor:not-allowed;background-color:var(--ds-color-bg-disabled);border-color:var(--ds-color-border)}.ds-drop-zone[data-dropping][data-valid],.ds-drop-zone[data-over][data-valid]{border-color:var(--ds-color-primary);background-color:var(--ds-color-primary-bg)}.ds-drop-zone[data-dragging][data-valid]{border-color:var(--ds-color-primary)}.ds-drop-zone .ds-drop-zone-content{display:flex;align-items:center;justify-content:center;text-align:center;gap:.5rem}.ds-drop-zone .ds-drop-zone-icon{font-size:1.25rem;color:var(--ds-color-icon)}.ds-drop-zone .ds-drop-zone-text{color:var(--ds-color-text-description);font-size:var(--ds-font-size)}.ds-dropzone-value{padding:.75rem;border-radius:var(--ds-border-radius);border-width:1px;border-style:solid;border-color:var(--ds-color-border)}.ds-dropzone-value[data-dragging][data-valid]{border-color:var(--ds-color-primary);border-style:dashed}.ds-dropzone-value[data-dropping][data-valid],.ds-dropzone-value[data-over][data-valid]{border-color:var(--ds-color-primary);background-color:var(--ds-color-primary-bg)}.ds-dropzone-value.ds-dropzone-value-multiple{padding:.625rem}.ds-dropzone-value.ds-dropzone-value-multiple .ds-tag{max-width:100%;flex-shrink:0;margin:0}:is(.ds-dropzone-value.ds-dropzone-value-multiple .ds-tag) .ds-tag-close-icon{flex-shrink:0}.ds-dropzone-value-icon{color:var(--ds-color-icon);font-size:1.5rem;flex-shrink:0}.ds-dropzone-value-text{color:var(--ds-color-text-secondary)}
|
|
@@ -1,84 +1,108 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { FileIcon as h, XIcon as
|
|
4
|
-
import { isEqual as
|
|
5
|
-
import { memo as
|
|
6
|
-
import { Stack as
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
import { jsx as o, jsxs as T, Fragment as R } from "react/jsx-runtime";
|
|
3
|
+
import { FileIcon as h, XIcon as q } from "@bioturing/assets";
|
|
4
|
+
import { isEqual as x } from "es-toolkit";
|
|
5
|
+
import { memo as y, forwardRef as B, useState as X, useCallback as t, cloneElement as v } from "react";
|
|
6
|
+
import { Stack as A } from "../stack/index.js";
|
|
7
|
+
import D from "merge-refs";
|
|
8
|
+
import { Tag as G } from "../tag/component.js";
|
|
9
|
+
import { useCls as H } from "../utils/antdUtils.js";
|
|
10
|
+
import { Truncate as J } from "../truncate/component.js";
|
|
11
|
+
import { IconButton as K } from "../icon-button/component.js";
|
|
12
|
+
function L({
|
|
13
|
+
value: s,
|
|
14
|
+
onChange: n,
|
|
15
|
+
multiple: l,
|
|
16
|
+
renderValueLabel: d,
|
|
17
|
+
renderValueIcon: f,
|
|
18
|
+
className: E,
|
|
19
|
+
style: N,
|
|
20
|
+
maxItems: m,
|
|
21
|
+
...S
|
|
22
|
+
}, k) {
|
|
23
|
+
const c = H(), [u, j] = X(null), w = t((r) => {
|
|
24
|
+
j(r);
|
|
25
|
+
}, []), i = t(
|
|
22
26
|
(r) => {
|
|
23
|
-
const
|
|
24
|
-
return typeof
|
|
27
|
+
const e = d(r);
|
|
28
|
+
return typeof e == "string" ? /* @__PURE__ */ o(
|
|
29
|
+
J,
|
|
30
|
+
{
|
|
31
|
+
position: "middle",
|
|
32
|
+
className: c("dropzone-value-label"),
|
|
33
|
+
container: u,
|
|
34
|
+
children: e
|
|
35
|
+
}
|
|
36
|
+
) : /* @__PURE__ */ o("span", { className: c("dropzone-value-label"), children: e });
|
|
25
37
|
},
|
|
26
|
-
[
|
|
27
|
-
),
|
|
28
|
-
(r) =>
|
|
29
|
-
className:
|
|
38
|
+
[c, u, d]
|
|
39
|
+
), a = t(
|
|
40
|
+
(r) => v(f(r) || /* @__PURE__ */ o(h, {}), {
|
|
41
|
+
className: c("dropzone-value-icon")
|
|
30
42
|
}),
|
|
31
|
-
[
|
|
32
|
-
),
|
|
43
|
+
[c, f]
|
|
44
|
+
), b = t(
|
|
33
45
|
(r) => {
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
n(
|
|
47
|
+
s.filter((e) => !x(e, r))
|
|
36
48
|
);
|
|
37
49
|
},
|
|
38
|
-
[
|
|
39
|
-
),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
[n, s]
|
|
51
|
+
), z = t(() => {
|
|
52
|
+
l ? n([]) : n == null || n(null);
|
|
53
|
+
}, [n, l]), p = t(
|
|
54
|
+
(r) => {
|
|
55
|
+
const e = i(r);
|
|
56
|
+
return /* @__PURE__ */ T(R, { children: [
|
|
57
|
+
a(r),
|
|
58
|
+
e,
|
|
59
|
+
/* @__PURE__ */ o(K, { size: "small", onClick: z, children: /* @__PURE__ */ o(q, {}) })
|
|
60
|
+
] });
|
|
61
|
+
},
|
|
62
|
+
[i, a, z]
|
|
63
|
+
), F = t(
|
|
64
|
+
(r) => m == 1 ? p(r[0]) : /* @__PURE__ */ o(R, { children: (r || []).map((e, I) => {
|
|
65
|
+
const M = i(e);
|
|
66
|
+
return /* @__PURE__ */ o(
|
|
67
|
+
G,
|
|
68
|
+
{
|
|
69
|
+
icon: a(e),
|
|
70
|
+
size: "large",
|
|
71
|
+
closable: !0,
|
|
72
|
+
onClose: () => b(e),
|
|
73
|
+
children: M
|
|
74
|
+
},
|
|
75
|
+
I
|
|
76
|
+
);
|
|
77
|
+
}) }),
|
|
78
|
+
[
|
|
79
|
+
i,
|
|
80
|
+
a,
|
|
81
|
+
m,
|
|
82
|
+
p,
|
|
83
|
+
b
|
|
84
|
+
]
|
|
85
|
+
);
|
|
86
|
+
return /* @__PURE__ */ o(
|
|
87
|
+
A,
|
|
64
88
|
{
|
|
65
|
-
ref:
|
|
66
|
-
gap:
|
|
89
|
+
ref: D(k, w),
|
|
90
|
+
gap: l ? 4 : 8,
|
|
67
91
|
align: "center",
|
|
68
|
-
wrap:
|
|
69
|
-
className:
|
|
92
|
+
wrap: l && m !== 1,
|
|
93
|
+
className: c(
|
|
70
94
|
"dropzone-value",
|
|
71
|
-
|
|
72
|
-
|
|
95
|
+
l && "dropzone-value-multiple",
|
|
96
|
+
E
|
|
73
97
|
),
|
|
74
|
-
style:
|
|
75
|
-
...
|
|
76
|
-
children:
|
|
98
|
+
style: N,
|
|
99
|
+
...S,
|
|
100
|
+
children: l ? F(s) : p(s)
|
|
77
101
|
}
|
|
78
102
|
);
|
|
79
103
|
}
|
|
80
|
-
const
|
|
104
|
+
const g = y(B(L));
|
|
81
105
|
export {
|
|
82
|
-
|
|
106
|
+
g as Value
|
|
83
107
|
};
|
|
84
108
|
//# sourceMappingURL=value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value.js","sources":["../../../src/components/drag-drop/value.tsx"],"sourcesContent":["\"use client\";\nimport { FileIcon, XIcon } from \"@bioturing/assets\";\nimport { isEqual } from \"es-toolkit\";\nimport
|
|
1
|
+
{"version":3,"file":"value.js","sources":["../../../src/components/drag-drop/value.tsx"],"sourcesContent":["\"use client\";\nimport { FileIcon, XIcon } from \"@bioturing/assets\";\nimport { isEqual } from \"es-toolkit\";\nimport {\n cloneElement,\n forwardRef,\n memo,\n useCallback,\n type ForwardedRef,\n useState,\n} from \"react\";\nimport { IconButton } from \"../icon-button\";\nimport { Stack } from \"../stack\";\nimport { Tag } from \"../tag\";\nimport { Truncate } from \"../truncate\";\nimport { useCls } from \"../utils\";\nimport { DragDropValueProps, type Data } from \"./types\";\nimport mergeRefs from \"merge-refs\";\n\nfunction ValueInner<T extends Data, M extends boolean>(\n {\n value,\n onChange,\n multiple,\n renderValueLabel,\n renderValueIcon,\n className,\n style,\n maxItems,\n ...rest\n }: DragDropValueProps<T, M>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n const cls = useCls();\n\n // todo: make this as reusable hook\n const [containerEl, setContainerEl] = useState<HTMLDivElement>(null);\n const containerRef = useCallback((el: HTMLDivElement | null) => {\n setContainerEl(el);\n }, []);\n\n const renderLabel = useCallback(\n (value: T) => {\n const label = renderValueLabel(value);\n return typeof label === \"string\" ? (\n <Truncate\n position=\"middle\"\n className={cls(\"dropzone-value-label\")}\n container={containerEl}\n >\n {label}\n </Truncate>\n ) : (\n <span className={cls(\"dropzone-value-label\")}>{label}</span>\n );\n },\n [cls, containerEl, renderValueLabel]\n );\n\n const renderedValueIcon = useCallback(\n (value: T) => {\n return cloneElement(renderValueIcon(value) || <FileIcon />, {\n className: cls(\"dropzone-value-icon\"),\n });\n },\n [cls, renderValueIcon]\n );\n\n const handleResetMultiple = useCallback(\n (singleValue: T) => {\n (onChange as (value: T[]) => void)(\n (value as T[]).filter((v) => !isEqual(v, singleValue))\n );\n },\n [onChange, value]\n );\n\n const handleResetSingle = useCallback(() => {\n if (multiple) {\n (onChange as (value: T[]) => void)([] as T[]);\n } else {\n onChange?.(null);\n }\n }, [onChange, multiple]);\n\n const renderSingle = useCallback(\n (value: T) => {\n const label = renderLabel(value as T);\n return (\n <>\n {renderedValueIcon(value as T)}\n {label}\n <IconButton size=\"small\" onClick={handleResetSingle}>\n <XIcon />\n </IconButton>\n </>\n );\n },\n [renderLabel, renderedValueIcon, handleResetSingle]\n );\n\n const renderMultiple = useCallback(\n (value: T[]) => {\n if (maxItems == 1) {\n return renderSingle(value[0]);\n }\n return (\n <>\n {((value as T[]) || []).map((singleValue, index) => {\n const label = renderLabel(singleValue);\n return (\n <Tag\n key={index}\n icon={renderedValueIcon(singleValue)}\n size=\"large\"\n closable\n onClose={() => handleResetMultiple(singleValue)}\n >\n {label}\n </Tag>\n );\n })}\n </>\n );\n },\n [\n renderLabel,\n renderedValueIcon,\n maxItems,\n renderSingle,\n handleResetMultiple,\n ]\n );\n\n return (\n <Stack\n ref={mergeRefs(ref, containerRef)}\n gap={multiple ? 4 : 8}\n align=\"center\"\n wrap={multiple && maxItems !== 1}\n className={cls(\n \"dropzone-value\",\n multiple && \"dropzone-value-multiple\",\n className\n )}\n style={style}\n {...rest}\n >\n {multiple ? renderMultiple(value as T[]) : renderSingle(value as T)}\n </Stack>\n );\n}\n\nexport const Value = memo(forwardRef(ValueInner)) as <\n T extends Data,\n M extends boolean\n>(\n props: DragDropValueProps<T, M> & { ref?: ForwardedRef<HTMLDivElement> }\n) => ReturnType<typeof ValueInner>;\n"],"names":["ValueInner","value","onChange","multiple","renderValueLabel","renderValueIcon","className","style","maxItems","rest","ref","cls","useCls","containerEl","setContainerEl","useState","containerRef","useCallback","el","renderLabel","label","jsx","Truncate","renderedValueIcon","cloneElement","FileIcon","handleResetMultiple","singleValue","v","isEqual","handleResetSingle","renderSingle","jsxs","Fragment","IconButton","XIcon","renderMultiple","index","Tag","Stack","mergeRefs","Value","memo","forwardRef"],"mappings":"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"}
|
|
@@ -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;"}
|