@bioturing/components 0.15.4 → 0.16.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/Badge/component.js +16 -11
- package/dist/components/Badge/component.js.map +1 -1
- package/dist/components/Breadcrumb/component.js +4 -3
- package/dist/components/Breadcrumb/component.js.map +1 -1
- package/dist/components/Breadcrumb/style.css +1 -1
- package/dist/components/Breadcrumb/useItemRender.js +17 -16
- package/dist/components/Breadcrumb/useItemRender.js.map +1 -1
- package/dist/components/Button/component.js +30 -3
- package/dist/components/Button/component.js.map +1 -1
- package/dist/components/Button/style.css +1 -1
- package/dist/components/CodeBlock/component.js +7 -6
- package/dist/components/CodeBlock/component.js.map +1 -1
- package/dist/components/CodeBlock/style.css +1 -1
- package/dist/components/Collapse/component.js +35 -0
- package/dist/components/Collapse/component.js.map +1 -0
- package/dist/components/Collapse/style.css +1 -0
- package/dist/components/DSRoot/component.js +8 -7
- package/dist/components/DSRoot/component.js.map +1 -1
- package/dist/components/DSRoot/context.js +5 -4
- package/dist/components/DSRoot/context.js.map +1 -1
- package/dist/components/DropdownMenu/component.js +1 -0
- package/dist/components/DropdownMenu/component.js.map +1 -1
- package/dist/components/Field/component.js +13 -12
- package/dist/components/Field/component.js.map +1 -1
- package/dist/components/Form/component.js +4 -3
- package/dist/components/Form/component.js.map +1 -1
- package/dist/components/Form/item.js +1 -0
- package/dist/components/Form/item.js.map +1 -1
- package/dist/components/IconButton/component.js +1 -0
- package/dist/components/IconButton/component.js.map +1 -1
- package/dist/components/Modal/Modal.js +9 -8
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/Modal/ModalProvider.js +1 -0
- package/dist/components/Modal/ModalProvider.js.map +1 -1
- package/dist/components/Modal/index.js +11 -10
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Popover/component.js +6 -5
- package/dist/components/Popover/component.js.map +1 -1
- package/dist/components/PopupPanel/component.js +74 -68
- package/dist/components/PopupPanel/component.js.map +1 -1
- package/dist/components/ScrollArea/component.js +10 -9
- package/dist/components/ScrollArea/component.js.map +1 -1
- package/dist/components/Slider/component.js +9 -8
- package/dist/components/Slider/component.js.map +1 -1
- package/dist/components/Splitter/component.js +12 -11
- package/dist/components/Splitter/component.js.map +1 -1
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Stack/StackChild.js +26 -23
- package/dist/components/Stack/StackChild.js.map +1 -1
- package/dist/components/Stack/style.css +1 -1
- package/dist/components/Table/component.js +84 -72
- package/dist/components/Table/component.js.map +1 -1
- package/dist/components/Table/style.css +1 -1
- package/dist/components/Tag/component.js +6 -5
- package/dist/components/Tag/component.js.map +1 -1
- package/dist/components/ThemeProvider/component.js +15 -14
- package/dist/components/ThemeProvider/component.js.map +1 -1
- package/dist/components/Toast/component.js +17 -16
- package/dist/components/Toast/component.js.map +1 -1
- package/dist/components/Toast/function.js +5 -4
- package/dist/components/Toast/function.js.map +1 -1
- package/dist/components/Tooltip/component.js +13 -12
- package/dist/components/Tooltip/component.js.map +1 -1
- package/dist/components/Tour/component.js +5 -4
- package/dist/components/Tour/component.js.map +1 -1
- package/dist/components/Transition/component.js +45 -32
- package/dist/components/Transition/component.js.map +1 -1
- package/dist/components/Tree/components.js +9 -8
- package/dist/components/Tree/components.js.map +1 -1
- package/dist/components/Tree/helpers.js +1 -0
- package/dist/components/Tree/helpers.js.map +1 -1
- package/dist/components/Tree/useTreeCommon.js +12 -11
- package/dist/components/Tree/useTreeCommon.js.map +1 -1
- package/dist/components/Truncate/component.js +1 -0
- package/dist/components/Truncate/component.js.map +1 -1
- package/dist/components/Truncate/style.css +1 -1
- package/dist/components/Upload/component.js +13 -11
- package/dist/components/Upload/component.js.map +1 -1
- package/dist/components/Upload/dragger.js +3 -2
- package/dist/components/Upload/dragger.js.map +1 -1
- package/dist/components/Upload/hooks.js +3 -2
- package/dist/components/Upload/hooks.js.map +1 -1
- package/dist/components/Upload/style.css +1 -0
- package/dist/components/VerticalCollapsiblePanel/component.js +35 -32
- package/dist/components/VerticalCollapsiblePanel/component.js.map +1 -1
- package/dist/components/hooks/antd.js +4 -3
- package/dist/components/hooks/antd.js.map +1 -1
- package/dist/components/hooks/base-ui.js +34 -28
- package/dist/components/hooks/base-ui.js.map +1 -1
- package/dist/components/hooks/useControlledState.js +17 -9
- package/dist/components/hooks/useControlledState.js.map +1 -1
- package/dist/components/utils/WithAntdTokens.js +14 -13
- package/dist/components/utils/WithAntdTokens.js.map +1 -1
- package/dist/components/utils/antdUtils.js +1 -0
- package/dist/components/utils/antdUtils.js.map +1 -1
- package/dist/index.d.ts +131 -77
- package/dist/index.js +166 -157
- package/dist/index.js.map +1 -1
- package/dist/metadata.js +81 -87
- package/dist/metadata.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/components/Tree/helpers.tsx"],"sourcesContent":["\"use client\";\nimport React, { type Key } from \"react\";\nimport { type DataNode as AntTreeDataNode } from \"antd/es/tree\";\nimport { File, Folder, FolderOpen } from \"@bioturing/assets\";\n\n// Function to recursively find unique keys corresponding to original keys\nexport const getUniqueKeysFromOriginals = (\n nodes: AntTreeDataNode[] | undefined,\n originalKeysToFind: Set<Key>,\n map: Map<Key, Key>\n): Key[] => {\n if (!nodes) return [];\n let keys: Key[] = [];\n nodes.forEach((node) => {\n const originalKey = map.get(node.key);\n if (originalKey !== undefined && originalKeysToFind.has(originalKey)) {\n keys.push(node.key); // Add the unique key\n }\n if (node.children) {\n keys = keys.concat(\n getUniqueKeysFromOriginals(node.children, originalKeysToFind, map)\n );\n }\n });\n return keys;\n};\n\n// Helper function to generate unique keys and apply icons\nexport const processTreeData = <T extends AntTreeDataNode = AntTreeDataNode>(\n nodes: T[] | undefined,\n expandedOriginalKeys: Set<Key>, // Use Set for faster lookups\n parentKeyPrefix: string = \"\",\n keyMap: Map<Key, Key> // Map uniqueKey -> originalKey\n): T[] | undefined => {\n if (!nodes) return undefined;\n\n return nodes.map((node) => {\n const originalKey = node.key;\n // Ensure nodes have a valid key for unique key generation\n if (originalKey === null || originalKey === undefined) {\n console.warn(\n \"Tree node is missing a key. Skipping unique key generation for this node and its children.\",\n node\n );\n // Return node as is, or handle based on requirements\n return {\n ...node,\n // Optionally process children even if parent key is missing\n // children: processTreeData(node.children as T[] | undefined, expandedOriginalKeys, '', keyMap)\n };\n }\n\n const separator = \"/\"; // Use / as the separator\n const originalKeyString = String(originalKey);\n\n // Warn if the original key contains the separator\n if (originalKeyString.includes(separator)) {\n console.warn(\n `Tree node original key \"${originalKeyString}\" contains the separator character \"${separator}\". This might lead to unexpected behavior if keys are not truly unique.`,\n node\n );\n }\n\n const uniqueKey = parentKeyPrefix\n ? `${parentKeyPrefix}${separator}${originalKeyString}` // Use separator\n : originalKeyString;\n keyMap.set(uniqueKey, originalKey); // Store mapping uniqueKey -> originalKey\n\n const isExpanded = expandedOriginalKeys.has(originalKey);\n // Apply default icons based on expansion state and type (leaf/directory)\n const icon =\n node.icon ||\n (node.isLeaf ? <File /> : isExpanded ? <FolderOpen /> : <Folder />);\n\n // Recursively process children\n const processedChildren = processTreeData(\n node.children as T[] | undefined, // Cast children to T[]\n expandedOriginalKeys,\n uniqueKey, // Pass the generated unique key as the prefix for children\n keyMap\n );\n\n return {\n ...node,\n key: uniqueKey, // Override key with the unique one\n icon: icon,\n children: processedChildren,\n };\n });\n};\n"],"names":["getUniqueKeysFromOriginals","nodes","originalKeysToFind","map","keys","node","originalKey","processTreeData","expandedOriginalKeys","parentKeyPrefix","keyMap","separator","originalKeyString","uniqueKey","isExpanded","icon","jsx","File","FolderOpen","Folder","processedChildren"],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../src/components/Tree/helpers.tsx"],"sourcesContent":["\"use client\";\nimport React, { type Key } from \"react\";\nimport { type DataNode as AntTreeDataNode } from \"antd/es/tree\";\nimport { File, Folder, FolderOpen } from \"@bioturing/assets\";\n\n// Function to recursively find unique keys corresponding to original keys\nexport const getUniqueKeysFromOriginals = (\n nodes: AntTreeDataNode[] | undefined,\n originalKeysToFind: Set<Key>,\n map: Map<Key, Key>\n): Key[] => {\n if (!nodes) return [];\n let keys: Key[] = [];\n nodes.forEach((node) => {\n const originalKey = map.get(node.key);\n if (originalKey !== undefined && originalKeysToFind.has(originalKey)) {\n keys.push(node.key); // Add the unique key\n }\n if (node.children) {\n keys = keys.concat(\n getUniqueKeysFromOriginals(node.children, originalKeysToFind, map)\n );\n }\n });\n return keys;\n};\n\n// Helper function to generate unique keys and apply icons\nexport const processTreeData = <T extends AntTreeDataNode = AntTreeDataNode>(\n nodes: T[] | undefined,\n expandedOriginalKeys: Set<Key>, // Use Set for faster lookups\n parentKeyPrefix: string = \"\",\n keyMap: Map<Key, Key> // Map uniqueKey -> originalKey\n): T[] | undefined => {\n if (!nodes) return undefined;\n\n return nodes.map((node) => {\n const originalKey = node.key;\n // Ensure nodes have a valid key for unique key generation\n if (originalKey === null || originalKey === undefined) {\n console.warn(\n \"Tree node is missing a key. Skipping unique key generation for this node and its children.\",\n node\n );\n // Return node as is, or handle based on requirements\n return {\n ...node,\n // Optionally process children even if parent key is missing\n // children: processTreeData(node.children as T[] | undefined, expandedOriginalKeys, '', keyMap)\n };\n }\n\n const separator = \"/\"; // Use / as the separator\n const originalKeyString = String(originalKey);\n\n // Warn if the original key contains the separator\n if (originalKeyString.includes(separator)) {\n console.warn(\n `Tree node original key \"${originalKeyString}\" contains the separator character \"${separator}\". This might lead to unexpected behavior if keys are not truly unique.`,\n node\n );\n }\n\n const uniqueKey = parentKeyPrefix\n ? `${parentKeyPrefix}${separator}${originalKeyString}` // Use separator\n : originalKeyString;\n keyMap.set(uniqueKey, originalKey); // Store mapping uniqueKey -> originalKey\n\n const isExpanded = expandedOriginalKeys.has(originalKey);\n // Apply default icons based on expansion state and type (leaf/directory)\n const icon =\n node.icon ||\n (node.isLeaf ? <File /> : isExpanded ? <FolderOpen /> : <Folder />);\n\n // Recursively process children\n const processedChildren = processTreeData(\n node.children as T[] | undefined, // Cast children to T[]\n expandedOriginalKeys,\n uniqueKey, // Pass the generated unique key as the prefix for children\n keyMap\n );\n\n return {\n ...node,\n key: uniqueKey, // Override key with the unique one\n icon: icon,\n children: processedChildren,\n };\n });\n};\n"],"names":["getUniqueKeysFromOriginals","nodes","originalKeysToFind","map","keys","node","originalKey","processTreeData","expandedOriginalKeys","parentKeyPrefix","keyMap","separator","originalKeyString","uniqueKey","isExpanded","icon","jsx","File","FolderOpen","Folder","processedChildren"],"mappings":";;;AAMO,MAAMA,IAA6B,CACxCC,GACAC,GACAC,MACU;AACN,MAAA,CAACF,EAAO,QAAO,CAAC;AACpB,MAAIG,IAAc,CAAC;AACb,SAAAH,EAAA,QAAQ,CAACI,MAAS;AACtB,UAAMC,IAAcH,EAAI,IAAIE,EAAK,GAAG;AACpC,IAAIC,MAAgB,UAAaJ,EAAmB,IAAII,CAAW,KAC5DF,EAAA,KAAKC,EAAK,GAAG,GAEhBA,EAAK,aACPD,IAAOA,EAAK;AAAA,MACVJ,EAA2BK,EAAK,UAAUH,GAAoBC,CAAG;AAAA,IACnE;AAAA,EACF,CACD,GACMC;AACT,GAGaG,IAAkB,CAC7BN,GACAO,GACAC,IAA0B,IAC1BC,MACoB;AAChB,MAACT;AAEE,WAAAA,EAAM,IAAI,CAACI,MAAS;AACzB,YAAMC,IAAcD,EAAK;AAErB,UAAAC,KAAgB;AACV,uBAAA;AAAA,UACN;AAAA,UACAD;AAAA,QACF,GAEO;AAAA,UACL,GAAGA;AAAA;AAAA;AAAA,QAGL;AAGF,YAAMM,IAAY,KACZC,IAAoB,OAAON,CAAW;AAGxC,MAAAM,EAAkB,SAASD,CAAS,KAC9B,QAAA;AAAA,QACN,2BAA2BC,CAAiB,uCAAuCD,CAAS;AAAA,QAC5FN;AAAA,MACF;AAGI,YAAAQ,IAAYJ,IACd,GAAGA,CAAe,GAAGE,CAAS,GAAGC,CAAiB,KAClDA;AACG,MAAAF,EAAA,IAAIG,GAAWP,CAAW;AAE3B,YAAAQ,IAAaN,EAAqB,IAAIF,CAAW,GAEjDS,IACJV,EAAK,SACJA,EAAK,SAAS,gBAAAW,EAACC,GAAK,CAAA,CAAA,IAAKH,IAAa,gBAAAE,EAACE,GAAW,CAAA,CAAA,sBAAMC,GAAO,CAAA,CAAA,IAG5DC,IAAoBb;AAAA,QACxBF,EAAK;AAAA;AAAA,QACLG;AAAA,QACAK;AAAA;AAAA,QACAH;AAAA,MACF;AAEO,aAAA;AAAA,QACL,GAAGL;AAAA,QACH,KAAKQ;AAAA;AAAA,QACL,MAAAE;AAAA,QACA,UAAUK;AAAA,MACZ;AAAA,IAAA,CACD;AACH;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as v } from "react/jsx-runtime";
|
|
2
3
|
import { useMemo as I } from "react";
|
|
3
4
|
import { CaretRight as M } from "@bioturing/assets";
|
|
@@ -20,28 +21,28 @@ function z(h) {
|
|
|
20
21
|
...w
|
|
21
22
|
} = h, A = I(() => {
|
|
22
23
|
if (d) {
|
|
23
|
-
const n = [],
|
|
24
|
+
const n = [], a = (c = []) => {
|
|
24
25
|
c.forEach((t) => {
|
|
25
|
-
n.push(t.key), Array.isArray(t.children) &&
|
|
26
|
+
n.push(t.key), Array.isArray(t.children) && a(t.children);
|
|
26
27
|
});
|
|
27
28
|
};
|
|
28
|
-
return
|
|
29
|
+
return a(o), n;
|
|
29
30
|
}
|
|
30
31
|
if (i && (r != null && r.length)) {
|
|
31
|
-
const n = /* @__PURE__ */ new Map(),
|
|
32
|
+
const n = /* @__PURE__ */ new Map(), a = (t, s) => {
|
|
32
33
|
t.forEach((e) => {
|
|
33
|
-
|
|
34
|
+
s && n.set(e.key, s.key);
|
|
34
35
|
const p = Array.isArray(e.children) ? e.children : [];
|
|
35
|
-
p.length &&
|
|
36
|
+
p.length && a(p, e);
|
|
36
37
|
});
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
+
a(o);
|
|
39
40
|
const c = new Set(r);
|
|
40
41
|
return r.forEach((t) => {
|
|
41
|
-
let
|
|
42
|
-
for (; n.has(
|
|
43
|
-
const e = n.get(
|
|
44
|
-
c.has(e) || c.add(e),
|
|
42
|
+
let s = t;
|
|
43
|
+
for (; n.has(s); ) {
|
|
44
|
+
const e = n.get(s);
|
|
45
|
+
c.has(e) || c.add(e), s = e;
|
|
45
46
|
}
|
|
46
47
|
}), Array.from(c);
|
|
47
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTreeCommon.js","sources":["../../../src/components/Tree/useTreeCommon.tsx"],"sourcesContent":["\"use client\";\nimport { type DataNode as AntTreeDataNode } from \"antd/es/tree\";\n\nimport { useMemo, type Key } from \"react\";\nimport { useCls } from \"../utils\";\nimport { CaretRight } from \"@bioturing/assets\";\nimport type { TreeDataNode, TreeProps, DirectoryTreeProps } from \"./types\";\nimport { useUniqueKeysTree } from \"./useUniqueKeysTree\";\n\nexport function useTreeCommon<T extends AntTreeDataNode>(\n props: TreeProps<T> | DirectoryTreeProps<T>\n) {\n const {\n treeData: originTreeData = [],\n expandedKeys: propExpandedKeys,\n defaultExpandedKeys: propDefaultExpandedKeys = [],\n defaultExpandAll = false,\n defaultExpandParent = true,\n onExpand: propOnExpand,\n checkedKeys,\n defaultCheckedKeys,\n onCheck,\n allowDuplicatedKeys,\n className,\n switcherIcon,\n ...restProps\n } = props;\n\n // compute resolved defaultExpandedKeys\n const resolvedDefaultExpandedKeys = useMemo<Key[]>(() => {\n if (defaultExpandAll) {\n const keys: Key[] = [];\n const traverse = (nodes: TreeDataNode[] = []) => {\n nodes.forEach((node) => {\n keys.push(node.key);\n if (Array.isArray(node.children))\n traverse(node.children as TreeDataNode[]);\n });\n };\n traverse(originTreeData as TreeDataNode[]);\n return keys;\n }\n if (defaultExpandParent && propDefaultExpandedKeys?.length) {\n // build parent map\n const parentMap = new Map<Key, Key>();\n const traverse = (nodes: TreeDataNode[], parent?: TreeDataNode) => {\n nodes.forEach((node) => {\n if (parent) parentMap.set(node.key, parent.key);\n const children = Array.isArray(node.children)\n ? (node.children as TreeDataNode[])\n : [];\n if (children.length) traverse(children, node);\n });\n };\n traverse(originTreeData as TreeDataNode[]);\n // collect all expansions: original keys + their ancestors\n const expanded = new Set<Key>(propDefaultExpandedKeys);\n propDefaultExpandedKeys.forEach((key) => {\n let k = key;\n while (parentMap.has(k)) {\n const p = parentMap.get(k)!;\n if (!expanded.has(p)) expanded.add(p);\n k = p;\n }\n });\n return Array.from(expanded);\n }\n return propDefaultExpandedKeys ?? [];\n }, [\n originTreeData,\n defaultExpandAll,\n defaultExpandParent,\n propDefaultExpandedKeys,\n ]);\n\n // use unique keys hook\n const {\n processedTreeData,\n currentUniqueExpandedKeys,\n currentUniqueCheckedKeys,\n handleAntTreeExpand,\n handleAntTreeCheck,\n } = useUniqueKeysTree({\n treeData: originTreeData,\n expandedKeys: propExpandedKeys,\n defaultExpandedKeys: resolvedDefaultExpandedKeys,\n onExpand: propOnExpand,\n checkedKeys,\n defaultCheckedKeys,\n onCheck,\n allowDuplicatedKeys,\n });\n\n const cls = useCls();\n const customSwitcherIcon: TreeProps<T>[\"switcherIcon\"] = () => (\n <CaretRight weight=\"bold\" className={cls(\"caret-switcher-icon\")} />\n );\n\n return {\n cls,\n customSwitcherIcon,\n processedTreeData,\n currentUniqueExpandedKeys,\n currentUniqueCheckedKeys,\n handleAntTreeExpand,\n handleAntTreeCheck,\n restProps,\n className,\n switcherIcon,\n };\n}\n"],"names":["useTreeCommon","props","originTreeData","propExpandedKeys","propDefaultExpandedKeys","defaultExpandAll","defaultExpandParent","propOnExpand","checkedKeys","defaultCheckedKeys","onCheck","allowDuplicatedKeys","className","switcherIcon","restProps","resolvedDefaultExpandedKeys","useMemo","keys","traverse","nodes","node","parentMap","parent","children","expanded","key","k","p","processedTreeData","currentUniqueExpandedKeys","currentUniqueCheckedKeys","handleAntTreeExpand","handleAntTreeCheck","useUniqueKeysTree","cls","useCls","jsx","CaretRight"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTreeCommon.js","sources":["../../../src/components/Tree/useTreeCommon.tsx"],"sourcesContent":["\"use client\";\nimport { type DataNode as AntTreeDataNode } from \"antd/es/tree\";\n\nimport { useMemo, type Key } from \"react\";\nimport { useCls } from \"../utils\";\nimport { CaretRight } from \"@bioturing/assets\";\nimport type { TreeDataNode, TreeProps, DirectoryTreeProps } from \"./types\";\nimport { useUniqueKeysTree } from \"./useUniqueKeysTree\";\n\nexport function useTreeCommon<T extends AntTreeDataNode>(\n props: TreeProps<T> | DirectoryTreeProps<T>\n) {\n const {\n treeData: originTreeData = [],\n expandedKeys: propExpandedKeys,\n defaultExpandedKeys: propDefaultExpandedKeys = [],\n defaultExpandAll = false,\n defaultExpandParent = true,\n onExpand: propOnExpand,\n checkedKeys,\n defaultCheckedKeys,\n onCheck,\n allowDuplicatedKeys,\n className,\n switcherIcon,\n ...restProps\n } = props;\n\n // compute resolved defaultExpandedKeys\n const resolvedDefaultExpandedKeys = useMemo<Key[]>(() => {\n if (defaultExpandAll) {\n const keys: Key[] = [];\n const traverse = (nodes: TreeDataNode[] = []) => {\n nodes.forEach((node) => {\n keys.push(node.key);\n if (Array.isArray(node.children))\n traverse(node.children as TreeDataNode[]);\n });\n };\n traverse(originTreeData as TreeDataNode[]);\n return keys;\n }\n if (defaultExpandParent && propDefaultExpandedKeys?.length) {\n // build parent map\n const parentMap = new Map<Key, Key>();\n const traverse = (nodes: TreeDataNode[], parent?: TreeDataNode) => {\n nodes.forEach((node) => {\n if (parent) parentMap.set(node.key, parent.key);\n const children = Array.isArray(node.children)\n ? (node.children as TreeDataNode[])\n : [];\n if (children.length) traverse(children, node);\n });\n };\n traverse(originTreeData as TreeDataNode[]);\n // collect all expansions: original keys + their ancestors\n const expanded = new Set<Key>(propDefaultExpandedKeys);\n propDefaultExpandedKeys.forEach((key) => {\n let k = key;\n while (parentMap.has(k)) {\n const p = parentMap.get(k)!;\n if (!expanded.has(p)) expanded.add(p);\n k = p;\n }\n });\n return Array.from(expanded);\n }\n return propDefaultExpandedKeys ?? [];\n }, [\n originTreeData,\n defaultExpandAll,\n defaultExpandParent,\n propDefaultExpandedKeys,\n ]);\n\n // use unique keys hook\n const {\n processedTreeData,\n currentUniqueExpandedKeys,\n currentUniqueCheckedKeys,\n handleAntTreeExpand,\n handleAntTreeCheck,\n } = useUniqueKeysTree({\n treeData: originTreeData,\n expandedKeys: propExpandedKeys,\n defaultExpandedKeys: resolvedDefaultExpandedKeys,\n onExpand: propOnExpand,\n checkedKeys,\n defaultCheckedKeys,\n onCheck,\n allowDuplicatedKeys,\n });\n\n const cls = useCls();\n const customSwitcherIcon: TreeProps<T>[\"switcherIcon\"] = () => (\n <CaretRight weight=\"bold\" className={cls(\"caret-switcher-icon\")} />\n );\n\n return {\n cls,\n customSwitcherIcon,\n processedTreeData,\n currentUniqueExpandedKeys,\n currentUniqueCheckedKeys,\n handleAntTreeExpand,\n handleAntTreeCheck,\n restProps,\n className,\n switcherIcon,\n };\n}\n"],"names":["useTreeCommon","props","originTreeData","propExpandedKeys","propDefaultExpandedKeys","defaultExpandAll","defaultExpandParent","propOnExpand","checkedKeys","defaultCheckedKeys","onCheck","allowDuplicatedKeys","className","switcherIcon","restProps","resolvedDefaultExpandedKeys","useMemo","keys","traverse","nodes","node","parentMap","parent","children","expanded","key","k","p","processedTreeData","currentUniqueExpandedKeys","currentUniqueCheckedKeys","handleAntTreeExpand","handleAntTreeCheck","useUniqueKeysTree","cls","useCls","jsx","CaretRight"],"mappings":";;;;;;AASO,SAASA,EACdC,GACA;AACM,QAAA;AAAA,IACJ,UAAUC,IAAiB,CAAC;AAAA,IAC5B,cAAcC;AAAA,IACd,qBAAqBC,IAA0B,CAAC;AAAA,IAChD,kBAAAC,IAAmB;AAAA,IACnB,qBAAAC,IAAsB;AAAA,IACtB,UAAUC;AAAA,IACV,aAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,SAAAC;AAAA,IACA,qBA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,mBAAAwB;AAAA,IACA,2BAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,oBAAAC;AAAA,MACEC,EAAkB;AAAA,IACpB,UAAU/B;AAAA,IACV,cAAcC;AAAA,IACd,qBAAqBY;AAAA,IACrB,UAAUR;AAAA,IACV,aAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,SAAAC;AAAA,IACA,qBAAAC;AAAA,EAAA,CACD,GAEKuB,IAAMC,EAAO;AAKZ,SAAA;AAAA,IACL,KAAAD;AAAA,IACA,oBANuD,MACtD,gBAAAE,EAAAC,GAAA,EAAW,QAAO,QAAO,WAAWH,EAAI,qBAAqB,GAAG;AAAA,IAMjE,mBAAAN;AAAA,IACA,2BAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,WAAAlB;AAAA,IACA,WAAAF;AAAA,IACA,cAAAC;AAAA,EACF;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/Truncate/component.tsx"],"sourcesContent":["\"use client\";\nimport React, { useCallback, useLayoutEffect, useRef, useState } from \"react\";\nimport { clsx, useCls } from \"../utils\";\nimport { getMiddleTruncatedString } from \"./helpers\";\n\nimport \"./style.css\";\n\nexport type TruncatePosition = \"middle\" | \"end\";\n\nexport type Props = {\n text: string;\n} & React.CSSProperties;\n\nexport interface TruncateProps\n extends Omit<React.ComponentPropsWithoutRef<\"span\">, \"title\"> {\n /** Text content to be truncated */\n children: string;\n /** Where to truncate the text: start, middle, or end */\n position?: TruncatePosition;\n /** Number of lines to display before truncating (default: 1, 'auto' to fit parent height) */\n lines?: number | \"auto\";\n}\n\nexport const Truncate: React.FC<TruncateProps> = ({\n children,\n position = \"end\",\n lines = 1,\n className,\n style,\n ...rest\n}) => {\n const cls = useCls();\n const containerRef = useRef<HTMLElement>(null);\n const [isTruncated, setIsTruncated] = useState(false);\n const [truncatedText, setTruncatedText] = useState(children);\n\n const text = children;\n\n // Get appropriate container styles based on position and lines\n const getContainerStyles = useCallback(() => {\n // For explicit line numbers or single line\n if (lines !== \"auto\") {\n return {\n ...style,\n ...(lines > 1 ? { \"--ds-line-clamp\": lines } : {}),\n } as React.CSSProperties;\n }\n\n // For auto line calculation, we'll let the useLayoutEffect handle it\n return {\n ...style,\n // Set a temporary high value to ensure it fits the parent\n \"--ds-line-clamp\": 999,\n } as React.CSSProperties;\n }, [lines, style]);\n\n useLayoutEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n\n // Handle auto-height calculation\n if (lines === \"auto\") {\n setTruncatedText(text);\n\n const calculateLines = () => {\n // Get the parent element's height\n const parent = container.parentElement;\n if (!parent) return;\n\n // Calculate the font size and line height\n const styles = window.getComputedStyle(container);\n const fontSize = parseFloat(styles.fontSize);\n const lineHeight =\n styles.lineHeight === \"normal\"\n ? fontSize * 1.2 // Approximate for \"normal\"\n : parseFloat(styles.lineHeight);\n\n // Get parent's padding and border to subtract from available height\n const parentStyles = window.getComputedStyle(parent);\n const paddingTop = parseFloat(parentStyles.paddingTop) || 0;\n const paddingBottom = parseFloat(parentStyles.paddingBottom) || 0;\n const borderTopWidth = parseFloat(parentStyles.borderTopWidth) || 0;\n const borderBottomWidth =\n parseFloat(parentStyles.borderBottomWidth) || 0;\n\n // Calculate how many lines can fit in the available space\n const parentHeight = parent.clientHeight;\n const availableHeight =\n parentHeight -\n paddingTop -\n paddingBottom -\n borderTopWidth -\n borderBottomWidth;\n const maxLines = Math.max(1, Math.floor(availableHeight / lineHeight));\n\n // Apply the calculated line-clamp\n if (container) {\n container.style.setProperty(\"--ds-line-clamp\", String(maxLines));\n }\n\n // Check if the text is truncated\n const clone = document.createElement(\"span\");\n clone.style.visibility = \"hidden\";\n clone.style.position = \"absolute\";\n clone.style.width = `${container.clientWidth}px`;\n clone.style.fontSize = styles.fontSize;\n clone.style.fontFamily = styles.fontFamily;\n clone.style.lineHeight = styles.lineHeight;\n clone.textContent = text;\n document.body.appendChild(clone);\n\n const isTruncated = clone.scrollHeight > availableHeight;\n document.body.removeChild(clone);\n\n setIsTruncated(isTruncated);\n };\n\n window.document.fonts?.ready?.then(calculateLines);\n const observer = new ResizeObserver(() => {\n window.requestAnimationFrame(calculateLines);\n });\n\n observer.observe(container);\n if (container.parentElement) {\n observer.observe(container.parentElement);\n }\n\n return () => observer.disconnect();\n }\n\n // Skip custom truncation logic for multi-line mode\n if (typeof lines === \"number\" && lines > 1) {\n setTruncatedText(text);\n // Check if text is truncated by comparing heights\n const checkIfTruncated = () => {\n const clone = document.createElement(\"span\");\n clone.style.visibility = \"hidden\";\n clone.style.position = \"absolute\";\n clone.style.width = `${container.clientWidth}px`;\n clone.textContent = text;\n document.body.appendChild(clone);\n const isTruncated =\n clone.scrollHeight >\n (container.clientHeight || container.offsetHeight);\n document.body.removeChild(clone);\n setIsTruncated(isTruncated);\n };\n\n window.document.fonts?.ready?.then(checkIfTruncated);\n const observer = new ResizeObserver(() => {\n window.requestAnimationFrame(checkIfTruncated);\n });\n\n observer.observe(container);\n return () => observer.disconnect();\n }\n\n // Original single-line truncation logic\n let cancellationToken = { cancelled: false };\n\n const calculateTruncatedString = () => {\n if (cancellationToken) cancellationToken.cancelled = true;\n\n const requestCancellationToken = { cancelled: false };\n cancellationToken = requestCancellationToken;\n\n const truncated = getMiddleTruncatedString(text, \"\\u2026\", container);\n\n if (requestCancellationToken.cancelled) return;\n\n setTruncatedText(truncated);\n };\n\n if (position == \"middle\") {\n window.document.fonts?.ready?.then(calculateTruncatedString);\n }\n\n if (position == \"end\") {\n setTruncatedText(text);\n }\n\n const observer = new ResizeObserver(() => {\n if (position == \"middle\")\n window.requestAnimationFrame(calculateTruncatedString);\n if (position == \"end\") {\n const isOverflowing = container.scrollWidth > container.clientWidth;\n if (isOverflowing) {\n setIsTruncated(true);\n }\n }\n });\n\n observer.observe(container);\n\n return () => {\n cancellationToken.cancelled = true;\n observer.disconnect();\n };\n }, [text, position, lines]);\n\n return (\n <span\n ref={containerRef}\n style={getContainerStyles()}\n className={clsx(\n lines === 1 ? cls(\"truncate\") : cls(\"truncate-multiline\"),\n position === \"middle\" ? cls(\"truncate-middle\") : cls(\"truncate-end\"),\n className\n )}\n title={isTruncated ? text : undefined}\n {...rest}\n >\n {text === truncatedText ? text : <span>{truncatedText}</span>}\n </span>\n );\n};\n"],"names":["Truncate","children","position","lines","className","style","rest","cls","useCls","containerRef","useRef","isTruncated","setIsTruncated","useState","truncatedText","setTruncatedText","text","getContainerStyles","useCallback","useLayoutEffect","container","calculateLines","parent","styles","fontSize","lineHeight","parentStyles","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","availableHeight","maxLines","clone","_b","_a","observer","checkIfTruncated","_d","_c","cancellationToken","calculateTruncatedString","requestCancellationToken","truncated","getMiddleTruncatedString","_f","_e","jsx","clsx"],"mappings":";;;;;;AAuBO,MAAMA,KAAoC,CAAC;AAAA,EAChD,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,OAAAC,IAAQ;AAAA,EACR,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAMC,EAAO,GACbC,IAAeC,EAAoB,IAAI,GACvC,CAACC,GAAaC,CAAc,IAAIC,EAAS,EAAK,GAC9C,CAACC,GAAeC,CAAgB,IAAIF,EAASZ,CAAQ,GAErDe,IAAOf,GAGPgB,IAAqBC,EAAY,MAEjCf,MAAU,SACL;AAAA,IACL,GAAGE;AAAA,IACH,GAAIF,IAAQ,IAAI,EAAE,mBAAmBA,EAAA,IAAU,CAAA;AAAA,EACjD,IAIK;AAAA,IACL,GAAGE;AAAA;AAAA,IAEH,mBAAmB;AAAA,EACrB,GACC,CAACF,GAAOE,CAAK,CAAC;AAEjB,SAAAc,EAAgB,MAAM;;AACpB,UAAMC,IAAYX,EAAa;AAC/B,QAAI,CAACW,EAAW;AAGhB,QAAIjB,MAAU,QAAQ;AACpB,MAAAY,EAAiBC,CAAI;AAErB,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AAwB,GACnDvC,KAAY,SACQkB,EAAU,cAAcA,EAAU,eAEtDR,EAAe,EAAI;AAAA,IAEvB,CACD;AAED,WAAAwB,EAAS,QAAQhB,CAAS,GAEnB,MAAM;AACX,MAAAoB,EAAkB,YAAY,IAC9BJ,EAAS,WAAW;AAAA,IACtB;AAAA,EACC,GAAA,CAACpB,GAAMd,GAAUC,CAAK,CAAC,GAGxB,gBAAA4C;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKtC;AAAA,MACL,OAAOQ,EAAmB;AAAA,MAC1B,WAAW+B;AAAA,QACKzC,EAAdJ,MAAU,IAAQ,aAAkB,oBAAR;AAAA,QACJI,EAAxBL,MAAa,WAAe,oBAAyB,cAAR;AAAA,QAC7CE;AAAA,MACF;AAAA,MACA,OAAOO,IAAcK,IAAO;AAAA,MAC3B,GAAGV;AAAA,MAEH,UAASU,MAAAF,IAAgBE,IAAO,gBAAA+B,EAAC,UAAM,UAAcjC,EAAA,CAAA;AAAA,IAAA;AAAA,EACxD;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/Truncate/component.tsx"],"sourcesContent":["\"use client\";\nimport React, { useCallback, useLayoutEffect, useRef, useState } from \"react\";\nimport { clsx, useCls } from \"../utils\";\nimport { getMiddleTruncatedString } from \"./helpers\";\n\nimport \"./style.css\";\n\nexport type TruncatePosition = \"middle\" | \"end\";\n\nexport type Props = {\n text: string;\n} & React.CSSProperties;\n\nexport interface TruncateProps\n extends Omit<React.ComponentPropsWithoutRef<\"span\">, \"title\"> {\n /** Text content to be truncated */\n children: string;\n /** Where to truncate the text: start, middle, or end */\n position?: TruncatePosition;\n /** Number of lines to display before truncating (default: 1, 'auto' to fit parent height) */\n lines?: number | \"auto\";\n}\n\nexport const Truncate: React.FC<TruncateProps> = ({\n children,\n position = \"end\",\n lines = 1,\n className,\n style,\n ...rest\n}) => {\n const cls = useCls();\n const containerRef = useRef<HTMLElement>(null);\n const [isTruncated, setIsTruncated] = useState(false);\n const [truncatedText, setTruncatedText] = useState(children);\n\n const text = children;\n\n // Get appropriate container styles based on position and lines\n const getContainerStyles = useCallback(() => {\n // For explicit line numbers or single line\n if (lines !== \"auto\") {\n return {\n ...style,\n ...(lines > 1 ? { \"--ds-line-clamp\": lines } : {}),\n } as React.CSSProperties;\n }\n\n // For auto line calculation, we'll let the useLayoutEffect handle it\n return {\n ...style,\n // Set a temporary high value to ensure it fits the parent\n \"--ds-line-clamp\": 999,\n } as React.CSSProperties;\n }, [lines, style]);\n\n useLayoutEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n\n // Handle auto-height calculation\n if (lines === \"auto\") {\n setTruncatedText(text);\n\n const calculateLines = () => {\n // Get the parent element's height\n const parent = container.parentElement;\n if (!parent) return;\n\n // Calculate the font size and line height\n const styles = window.getComputedStyle(container);\n const fontSize = parseFloat(styles.fontSize);\n const lineHeight =\n styles.lineHeight === \"normal\"\n ? fontSize * 1.2 // Approximate for \"normal\"\n : parseFloat(styles.lineHeight);\n\n // Get parent's padding and border to subtract from available height\n const parentStyles = window.getComputedStyle(parent);\n const paddingTop = parseFloat(parentStyles.paddingTop) || 0;\n const paddingBottom = parseFloat(parentStyles.paddingBottom) || 0;\n const borderTopWidth = parseFloat(parentStyles.borderTopWidth) || 0;\n const borderBottomWidth =\n parseFloat(parentStyles.borderBottomWidth) || 0;\n\n // Calculate how many lines can fit in the available space\n const parentHeight = parent.clientHeight;\n const availableHeight =\n parentHeight -\n paddingTop -\n paddingBottom -\n borderTopWidth -\n borderBottomWidth;\n const maxLines = Math.max(1, Math.floor(availableHeight / lineHeight));\n\n // Apply the calculated line-clamp\n if (container) {\n container.style.setProperty(\"--ds-line-clamp\", String(maxLines));\n }\n\n // Check if the text is truncated\n const clone = document.createElement(\"span\");\n clone.style.visibility = \"hidden\";\n clone.style.position = \"absolute\";\n clone.style.width = `${container.clientWidth}px`;\n clone.style.fontSize = styles.fontSize;\n clone.style.fontFamily = styles.fontFamily;\n clone.style.lineHeight = styles.lineHeight;\n clone.textContent = text;\n document.body.appendChild(clone);\n\n const isTruncated = clone.scrollHeight > availableHeight;\n document.body.removeChild(clone);\n\n setIsTruncated(isTruncated);\n };\n\n window.document.fonts?.ready?.then(calculateLines);\n const observer = new ResizeObserver(() => {\n window.requestAnimationFrame(calculateLines);\n });\n\n observer.observe(container);\n if (container.parentElement) {\n observer.observe(container.parentElement);\n }\n\n return () => observer.disconnect();\n }\n\n // Skip custom truncation logic for multi-line mode\n if (typeof lines === \"number\" && lines > 1) {\n setTruncatedText(text);\n // Check if text is truncated by comparing heights\n const checkIfTruncated = () => {\n const clone = document.createElement(\"span\");\n clone.style.visibility = \"hidden\";\n clone.style.position = \"absolute\";\n clone.style.width = `${container.clientWidth}px`;\n clone.textContent = text;\n document.body.appendChild(clone);\n const isTruncated =\n clone.scrollHeight >\n (container.clientHeight || container.offsetHeight);\n document.body.removeChild(clone);\n setIsTruncated(isTruncated);\n };\n\n window.document.fonts?.ready?.then(checkIfTruncated);\n const observer = new ResizeObserver(() => {\n window.requestAnimationFrame(checkIfTruncated);\n });\n\n observer.observe(container);\n return () => observer.disconnect();\n }\n\n // Original single-line truncation logic\n let cancellationToken = { cancelled: false };\n\n const calculateTruncatedString = () => {\n if (cancellationToken) cancellationToken.cancelled = true;\n\n const requestCancellationToken = { cancelled: false };\n cancellationToken = requestCancellationToken;\n\n const truncated = getMiddleTruncatedString(text, \"\\u2026\", container);\n\n if (requestCancellationToken.cancelled) return;\n\n setTruncatedText(truncated);\n };\n\n if (position == \"middle\") {\n window.document.fonts?.ready?.then(calculateTruncatedString);\n }\n\n if (position == \"end\") {\n setTruncatedText(text);\n }\n\n const observer = new ResizeObserver(() => {\n if (position == \"middle\")\n window.requestAnimationFrame(calculateTruncatedString);\n if (position == \"end\") {\n const isOverflowing = container.scrollWidth > container.clientWidth;\n if (isOverflowing) {\n setIsTruncated(true);\n }\n }\n });\n\n observer.observe(container);\n\n return () => {\n cancellationToken.cancelled = true;\n observer.disconnect();\n };\n }, [text, position, lines]);\n\n return (\n <span\n ref={containerRef}\n style={getContainerStyles()}\n className={clsx(\n lines === 1 ? cls(\"truncate\") : cls(\"truncate-multiline\"),\n position === \"middle\" ? cls(\"truncate-middle\") : cls(\"truncate-end\"),\n className\n )}\n title={isTruncated ? text : undefined}\n {...rest}\n >\n {text === truncatedText ? text : <span>{truncatedText}</span>}\n </span>\n );\n};\n"],"names":["Truncate","children","position","lines","className","style","rest","cls","useCls","containerRef","useRef","isTruncated","setIsTruncated","useState","truncatedText","setTruncatedText","text","getContainerStyles","useCallback","useLayoutEffect","container","calculateLines","parent","styles","fontSize","lineHeight","parentStyles","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","availableHeight","maxLines","clone","_b","_a","observer","checkIfTruncated","_d","_c","cancellationToken","calculateTruncatedString","requestCancellationToken","truncated","getMiddleTruncatedString","_f","_e","jsx","clsx"],"mappings":";;;;;;;AAuBO,MAAMA,KAAoC,CAAC;AAAA,EAChD,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,OAAAC,IAAQ;AAAA,EACR,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAMC,EAAO,GACbC,IAAeC,EAAoB,IAAI,GACvC,CAACC,GAAaC,CAAc,IAAIC,EAAS,EAAK,GAC9C,CAACC,GAAeC,CAAgB,IAAIF,EAASZ,CAAQ,GAErDe,IAAOf,GAGPgB,IAAqBC,EAAY,MAEjCf,MAAU,SACL;AAAA,IACL,GAAGE;AAAA,IACH,GAAIF,IAAQ,IAAI,EAAE,mBAAmBA,EAAA,IAAU,CAAA;AAAA,EACjD,IAIK;AAAA,IACL,GAAGE;AAAA;AAAA,IAEH,mBAAmB;AAAA,EACrB,GACC,CAACF,GAAOE,CAAK,CAAC;AAEjB,SAAAc,EAAgB,MAAM;;AACpB,UAAMC,IAAYX,EAAa;AAC/B,QAAI,CAACW,EAAW;AAGhB,QAAIjB,MAAU,QAAQ;AACpB,M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AY,YACd,OAAO,sBAAsBuC,CAAwB,GACnDvC,KAAY,SACQkB,EAAU,cAAcA,EAAU,eAEtDR,EAAe,EAAI;AAAA,IAEvB,CACD;AAED,WAAAwB,EAAS,QAAQhB,CAAS,GAEnB,MAAM;AACX,MAAAoB,EAAkB,YAAY,IAC9BJ,EAAS,WAAW;AAAA,IACtB;AAAA,EACC,GAAA,CAACpB,GAAMd,GAAUC,CAAK,CAAC,GAGxB,gBAAA4C;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKtC;AAAA,MACL,OAAOQ,EAAmB;AAAA,MAC1B,WAAW+B;AAAA,QACKzC,EAAdJ,MAAU,IAAQ,aAAkB,oBAAR;AAAA,QACJI,EAAxBL,MAAa,WAAe,oBAAyB,cAAR;AAAA,QAC7CE;AAAA,MACF;AAAA,MACA,OAAOO,IAAcK,IAAO;AAAA,MAC3B,GAAGV;AAAA,MAEH,UAASU,MAAAF,IAAgBE,IAAO,gBAAA+B,EAAC,UAAM,UAAcjC,EAAA,CAAA;AAAA,IAAA;AAAA,EACxD;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ds-truncate{white-space:nowrap;overflow:hidden;
|
|
1
|
+
@layer components{.ds-truncate{white-space:nowrap;overflow:hidden;flex-grow:1;min-width:0;max-width:100%;display:block}.ds-truncate-end{text-overflow:ellipsis}.ds-truncate-middle{text-overflow:clip}.ds-truncate-multiline{display:-webkit-box;-webkit-line-clamp:var(--ds-line-clamp, 2);line-clamp:var(--ds-line-clamp, 2);-webkit-box-orient:vertical;overflow:hidden;white-space:normal;text-overflow:ellipsis;word-break:break-word}}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
3
|
import n from "antd/es/upload";
|
|
3
|
-
import { CloudArrowUp as
|
|
4
|
-
import { Dragger as
|
|
5
|
-
import { useUploadItemRender as
|
|
4
|
+
import { CloudArrowUp as c } from "@bioturing/assets";
|
|
5
|
+
import { Dragger as d } from "./dragger.js";
|
|
6
|
+
import { useUploadItemRender as a } from "./hooks.js";
|
|
6
7
|
import { UploadItem as f } from "./item.js";
|
|
8
|
+
import './style.css';/* empty css */
|
|
7
9
|
import { Button as u } from "../Button/component.js";
|
|
8
10
|
import { useCls as U } from "../utils/antdUtils.js";
|
|
9
11
|
import { clsx as g } from "../utils/cn.js";
|
|
@@ -14,26 +16,26 @@ const h = ({
|
|
|
14
16
|
className: t,
|
|
15
17
|
fileList: e,
|
|
16
18
|
children: m,
|
|
17
|
-
...
|
|
19
|
+
...i
|
|
18
20
|
}) => {
|
|
19
|
-
const
|
|
21
|
+
const l = U(), p = /* @__PURE__ */ o(u, { icon: /* @__PURE__ */ o(c, { size: 24 }), type: "default", children: "Upload Files" }), s = a({ showRemoveButton: r });
|
|
20
22
|
return /* @__PURE__ */ o(
|
|
21
23
|
n,
|
|
22
24
|
{
|
|
23
|
-
className: g(
|
|
24
|
-
...
|
|
25
|
+
className: g(l("upload"), t),
|
|
26
|
+
...i,
|
|
25
27
|
fileList: e,
|
|
26
28
|
itemRender: s,
|
|
27
|
-
children: m ||
|
|
29
|
+
children: m || p
|
|
28
30
|
}
|
|
29
31
|
);
|
|
30
|
-
},
|
|
32
|
+
}, B = Object.assign(h, {
|
|
31
33
|
// Dragger,
|
|
32
|
-
Dragger:
|
|
34
|
+
Dragger: d,
|
|
33
35
|
Item: f
|
|
34
36
|
});
|
|
35
37
|
export {
|
|
36
38
|
h as DefaultUpload,
|
|
37
|
-
|
|
39
|
+
B as Upload
|
|
38
40
|
};
|
|
39
41
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/Upload/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntUpload,\n type UploadFile as AntUploadFile,\n type UploadProps as AntUploadProps,\n type RcFile,\n type UploadChangeParam,\n} from \"antd/es/upload\";\nimport { Button } from \"..\";\nimport { CloudArrowUp } from \"@bioturing/assets\";\nimport { clsx, useCls } from \"../utils\";\nimport { Dragger } from \"./dragger\";\nimport { useUploadItemRender } from \"./hooks\";\nimport { UploadItem } from \"./item\";\n\n// Re-export UploadFile and other types for consumers\nexport type UploadFile = AntUploadFile;\nexport type { RcFile, UploadChangeParam };\n\nexport type { UploadItemProps, UploadFileStatus } from \"./item\";\n\n// Define props interface extending Ant Design's UploadProps\nexport interface UploadProps extends AntUploadProps {\n /**\n * Show remove button for uploaded files\n * @default true\n */\n showRemoveButton?: boolean;\n // /**\n // * Show file list\n // * @default true\n // */\n // showFileList?: boolean;\n // /**\n // * Custom icon\n // */\n // icon?: React.ReactNode;\n}\n\n// Default icons for file types\nexport const DefaultUpload = ({\n // icon = <CloudArrowUp size={24} />,\n showRemoveButton = true,\n // showFileList = true,\n className,\n fileList,\n children,\n ...restProps\n}: UploadProps) => {\n const cls = useCls();\n const icon = <CloudArrowUp size={24} />;\n\n // Default children if none provided\n const defaultChildren = (\n <Button icon={icon} type=\"default\">\n Upload Files\n </Button>\n );\n const itemRender = useUploadItemRender({ showRemoveButton });\n\n return (\n <AntUpload\n className={clsx(cls(\"upload\"), className)}\n {...restProps}\n fileList={fileList}\n itemRender={itemRender}\n >\n {children || defaultChildren}\n </AntUpload>\n );\n};\n\nexport const Upload = Object.assign(DefaultUpload, {\n // Dragger,\n Dragger: Dragger,\n Item: UploadItem,\n});\n"],"names":["DefaultUpload","showRemoveButton","className","fileList","children","restProps","cls","useCls","defaultChildren","jsx","Button","CloudArrowUp","itemRender","useUploadItemRender","AntUpload","clsx","Upload","Dragger","UploadItem"],"mappings":"
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/Upload/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntUpload,\n type UploadFile as AntUploadFile,\n type UploadProps as AntUploadProps,\n type RcFile,\n type UploadChangeParam,\n} from \"antd/es/upload\";\nimport { Button } from \"..\";\nimport { CloudArrowUp } from \"@bioturing/assets\";\nimport { clsx, useCls } from \"../utils\";\nimport { Dragger } from \"./dragger\";\nimport { useUploadItemRender } from \"./hooks\";\nimport { UploadItem } from \"./item\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\n// Re-export UploadFile and other types for consumers\nexport type UploadFile = AntUploadFile;\nexport type { RcFile, UploadChangeParam };\n\nexport type { UploadItemProps, UploadFileStatus } from \"./item\";\n\n// Define props interface extending Ant Design's UploadProps\nexport interface UploadProps extends AntUploadProps {\n /**\n * Show remove button for uploaded files\n * @default true\n */\n showRemoveButton?: boolean;\n // /**\n // * Show file list\n // * @default true\n // */\n // showFileList?: boolean;\n // /**\n // * Custom icon\n // */\n // icon?: React.ReactNode;\n}\n\n// Default icons for file types\nexport const DefaultUpload = ({\n // icon = <CloudArrowUp size={24} />,\n showRemoveButton = true,\n // showFileList = true,\n className,\n fileList,\n children,\n ...restProps\n}: UploadProps) => {\n const cls = useCls();\n const icon = <CloudArrowUp size={24} />;\n\n // Default children if none provided\n const defaultChildren = (\n <Button icon={icon} type=\"default\">\n Upload Files\n </Button>\n );\n const itemRender = useUploadItemRender({ showRemoveButton });\n\n return (\n <AntUpload\n className={clsx(cls(\"upload\"), className)}\n {...restProps}\n fileList={fileList}\n itemRender={itemRender}\n >\n {children || defaultChildren}\n </AntUpload>\n );\n};\n\nexport const Upload = Object.assign(DefaultUpload, {\n // Dragger,\n Dragger: Dragger,\n Item: UploadItem,\n});\n"],"names":["DefaultUpload","showRemoveButton","className","fileList","children","restProps","cls","useCls","defaultChildren","jsx","Button","CloudArrowUp","itemRender","useUploadItemRender","AntUpload","clsx","Upload","Dragger","UploadItem"],"mappings":";;;;;;;;;;;AA2CO,MAAMA,IAAgB,CAAC;AAAA;AAAA,EAE5B,kBAAAC,IAAmB;AAAA;AAAA,EAEnB,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,MAAmB;AACjB,QAAMC,IAAMC,EAAO,GAIbC,IACH,gBAAAC,EAAAC,GAAA,EAAO,MAJG,gBAAAD,EAACE,GAAa,EAAA,MAAM,GAAI,CAAA,GAIf,MAAK,WAAU,UAEnC,gBAAA,GAEIC,IAAaC,EAAoB,EAAE,kBAAAZ,GAAkB;AAGzD,SAAA,gBAAAQ;AAAA,IAACK;AAAA,IAAA;AAAA,MACC,WAAWC,EAAKT,EAAI,QAAQ,GAAGJ,CAAS;AAAA,MACvC,GAAGG;AAAA,MACJ,UAAAF;AAAA,MACA,YAAAS;AAAA,MAEC,UAAYR,KAAAI;AAAA,IAAA;AAAA,EACf;AAEJ,GAEaQ,IAAS,OAAO,OAAOhB,GAAe;AAAA;AAAA,EAEjD,SAAAiB;AAAA,EACA,MAAMC;AACR,CAAC;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r, jsxs as i, Fragment as p } from "react/jsx-runtime";
|
|
2
3
|
import m from "antd/es/upload";
|
|
3
4
|
import { CloudArrowUp as u } from "@bioturing/assets";
|
|
4
5
|
import { useUploadItemRender as c } from "./hooks.js";
|
|
@@ -10,7 +11,7 @@ const N = ({
|
|
|
10
11
|
itemRender: a,
|
|
11
12
|
...n
|
|
12
13
|
}) => {
|
|
13
|
-
const e = f(), s = () => /* @__PURE__ */ p
|
|
14
|
+
const e = f(), s = () => /* @__PURE__ */ i(p, { children: [
|
|
14
15
|
/* @__PURE__ */ r("p", { className: e("upload-drag-icon"), children: /* @__PURE__ */ r(u, { size: 40 }) }),
|
|
15
16
|
/* @__PURE__ */ r("p", { className: e("upload-text"), children: t }),
|
|
16
17
|
/* @__PURE__ */ r("p", { className: e("upload-hint"), children: l })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dragger.js","sources":["../../../src/components/Upload/dragger.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntUpload,\n type DraggerProps as AntDraggerProps,\n} from \"antd/es/upload\";\nimport React from \"react\";\nimport { CloudArrowUp } from \"@bioturing/assets\";\nimport { useCls } from \"../utils\";\nimport { useUploadItemRender } from \"./hooks\";\n\nexport interface DraggerProps extends AntDraggerProps {\n /**\n * Custom title for the upload component\n */\n uploadTitle?: React.ReactNode;\n /**\n * Custom description for the upload component\n **/\n uploadDescription?: React.ReactNode;\n}\n\nexport const Dragger = ({\n children,\n uploadTitle = \"Click or drag file to this area to upload\",\n uploadDescription = \"Support for a single or bulk upload.\",\n itemRender,\n ...rest\n}: DraggerProps) => {\n const cls = useCls();\n const renderChildren = () => {\n return (\n <>\n <p className={cls(\"upload-drag-icon\")}>\n <CloudArrowUp size={40} />\n </p>\n <p className={cls(\"upload-text\")}>{uploadTitle}</p>\n <p className={cls(\"upload-hint\")}>{uploadDescription}</p>\n </>\n );\n };\n const defaultItemRender = useUploadItemRender({ showRemoveButton: true });\n return (\n <AntUpload.Dragger itemRender={itemRender || defaultItemRender} {...rest}>\n {children ? children : renderChildren()}\n </AntUpload.Dragger>\n );\n};\n"],"names":["Dragger","children","uploadTitle","uploadDescription","itemRender","rest","cls","useCls","renderChildren","jsxs","Fragment","jsx","CloudArrowUp","defaultItemRender","useUploadItemRender","AntUpload"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dragger.js","sources":["../../../src/components/Upload/dragger.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntUpload,\n type DraggerProps as AntDraggerProps,\n} from \"antd/es/upload\";\nimport React from \"react\";\nimport { CloudArrowUp } from \"@bioturing/assets\";\nimport { useCls } from \"../utils\";\nimport { useUploadItemRender } from \"./hooks\";\n\nexport interface DraggerProps extends AntDraggerProps {\n /**\n * Custom title for the upload component\n */\n uploadTitle?: React.ReactNode;\n /**\n * Custom description for the upload component\n **/\n uploadDescription?: React.ReactNode;\n}\n\nexport const Dragger = ({\n children,\n uploadTitle = \"Click or drag file to this area to upload\",\n uploadDescription = \"Support for a single or bulk upload.\",\n itemRender,\n ...rest\n}: DraggerProps) => {\n const cls = useCls();\n const renderChildren = () => {\n return (\n <>\n <p className={cls(\"upload-drag-icon\")}>\n <CloudArrowUp size={40} />\n </p>\n <p className={cls(\"upload-text\")}>{uploadTitle}</p>\n <p className={cls(\"upload-hint\")}>{uploadDescription}</p>\n </>\n );\n };\n const defaultItemRender = useUploadItemRender({ showRemoveButton: true });\n return (\n <AntUpload.Dragger itemRender={itemRender || defaultItemRender} {...rest}>\n {children ? children : renderChildren()}\n </AntUpload.Dragger>\n );\n};\n"],"names":["Dragger","children","uploadTitle","uploadDescription","itemRender","rest","cls","useCls","renderChildren","jsxs","Fragment","jsx","CloudArrowUp","defaultItemRender","useUploadItemRender","AntUpload"],"mappings":";;;;;;AAqBO,MAAMA,IAAU,CAAC;AAAA,EACtB,UAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,mBAAAC,IAAoB;AAAA,EACpB,YAAAC;AAAA,EACA,GAAGC;AACL,MAAoB;AAClB,QAAMC,IAAMC,EAAO,GACbC,IAAiB,MAGjB,gBAAAC,EAAAC,GAAA,EAAA,UAAA;AAAA,IAAC,gBAAAC,EAAA,KAAA,EAAE,WAAWL,EAAI,kBAAkB,GAClC,UAAC,gBAAAK,EAAAC,GAAA,EAAa,MAAM,GAAA,CAAI,EAC1B,CAAA;AAAA,sBACC,KAAE,EAAA,WAAWN,EAAI,aAAa,GAAI,UAAYJ,GAAA;AAAA,sBAC9C,KAAE,EAAA,WAAWI,EAAI,aAAa,GAAI,UAAkBH,EAAA,CAAA;AAAA,EAAA,GACvD,GAGEU,IAAoBC,EAAoB,EAAE,kBAAkB,IAAM;AACxE,SACG,gBAAAH,EAAAI,EAAU,SAAV,EAAkB,YAAYX,KAAcS,GAAoB,GAAGR,GACjE,UAAAJ,KAAsBO,EACzB,EAAA,CAAA;AAEJ;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
3
|
import { useCallback as o } from "react";
|
|
3
4
|
import { UploadItem as n } from "./item.js";
|
|
4
|
-
const
|
|
5
|
+
const d = ({ showRemoveButton: r = !0 }) => o((s, e, a, t) => /* @__PURE__ */ m(
|
|
5
6
|
n,
|
|
6
7
|
{
|
|
7
8
|
fileName: e.name,
|
|
@@ -13,6 +14,6 @@ const c = ({ showRemoveButton: r = !0 }) => o((a, e, s, t) => /* @__PURE__ */ m(
|
|
|
13
14
|
}
|
|
14
15
|
), [r]);
|
|
15
16
|
export {
|
|
16
|
-
|
|
17
|
+
d as useUploadItemRender
|
|
17
18
|
};
|
|
18
19
|
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":["../../../src/components/Upload/hooks.tsx"],"sourcesContent":["\"use client\";\nimport { type UploadProps } from \"antd/es/upload\";\nimport { useCallback } from \"react\";\nimport { UploadItem } from \"./item\";\n\nexport type UseUploadItemRenderProps = {\n showRemoveButton?: boolean;\n};\n\nexport const useUploadItemRender: (\n props: UseUploadItemRenderProps\n) => UploadProps[\"itemRender\"] = ({ showRemoveButton = true }) => {\n // If showFileList is false, don't render anything\n // if (!showFileList) return null;\n\n // Custom rendering of file items\n const itemRender: UploadProps[\"itemRender\"] = (\n _originNode,\n file,\n _fileList,\n actions\n ) => {\n return (\n <UploadItem\n fileName={file.name}\n fileType={file.type}\n status={file.status}\n percent={file.percent}\n removable={showRemoveButton}\n onRemove={() => actions.remove()}\n />\n );\n };\n return useCallback(itemRender, [showRemoveButton]);\n};\n"],"names":["useUploadItemRender","showRemoveButton","useCallback","_originNode","file","_fileList","actions","jsx","UploadItem"],"mappings":"
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../../../src/components/Upload/hooks.tsx"],"sourcesContent":["\"use client\";\nimport { type UploadProps } from \"antd/es/upload\";\nimport { useCallback } from \"react\";\nimport { UploadItem } from \"./item\";\n\nexport type UseUploadItemRenderProps = {\n showRemoveButton?: boolean;\n};\n\nexport const useUploadItemRender: (\n props: UseUploadItemRenderProps\n) => UploadProps[\"itemRender\"] = ({ showRemoveButton = true }) => {\n // If showFileList is false, don't render anything\n // if (!showFileList) return null;\n\n // Custom rendering of file items\n const itemRender: UploadProps[\"itemRender\"] = (\n _originNode,\n file,\n _fileList,\n actions\n ) => {\n return (\n <UploadItem\n fileName={file.name}\n fileType={file.type}\n status={file.status}\n percent={file.percent}\n removable={showRemoveButton}\n onRemove={() => actions.remove()}\n />\n );\n };\n return useCallback(itemRender, [showRemoveButton]);\n};\n"],"names":["useUploadItemRender","showRemoveButton","useCallback","_originNode","file","_fileList","actions","jsx","UploadItem"],"mappings":";;;;AASO,MAAMA,IAEoB,CAAC,EAAE,kBAAAC,IAAmB,SAsB9CC,EAjBuC,CAC5CC,GACAC,GACAC,GACAC,MAGE,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,UAAUJ,EAAK;AAAA,IACf,UAAUA,EAAK;AAAA,IACf,QAAQA,EAAK;AAAA,IACb,SAASA,EAAK;AAAA,IACd,WAAWH;AAAA,IACX,UAAU,MAAMK,EAAQ,OAAO;AAAA,EAAA;AACjC,GAG2B,CAACL,CAAgB,CAAC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer components{.ds-upload-wrapper{display:flex;flex-direction:column}.ds-upload-list{display:flex;flex-direction:column;flex-grow:1}.ds-upload-list-item-container{margin-top:.5rem}.ds-upload-item{padding:.5rem;border-radius:var(--ds-border-radius);border:1px solid var(--ds-color-border);flex-grow:1}.ds-upload-item-icon{font-size:1.25rem;color:var(--ds-color-text-tertiary)}.ds-upload-drag-icon{font-size:2.5rem;color:var(--ds-color-primary);margin-bottom:.5rem;display:flex;align-items:center;justify-content:center}.ds-upload-item-content{display:flex;align-items:center;justify-content:space-between;min-width:0}.ds-upload-item-name-progress{min-width:0;display:flex;flex-direction:column;flex-grow:1;flex-shrink:1;gap:0rem}}
|
|
@@ -1,76 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsxs as r, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Collapsible as
|
|
4
|
-
import { MinusCircle as
|
|
3
|
+
import { useState as V, useRef as g, useEffect as j } from "react";
|
|
4
|
+
import { Collapsible as n } from "@base-ui-components/react";
|
|
5
|
+
import { MinusCircle as A, PlusCircle as M } from "@bioturing/assets";
|
|
5
6
|
import { useControlledState as R } from "../hooks/useControlledState.js";
|
|
6
7
|
import { Truncate as S } from "../Truncate/component.js";
|
|
7
8
|
import './style.css';/* empty css */
|
|
8
9
|
import { Transition as E } from "../Transition/component.js";
|
|
9
|
-
import { useCls as
|
|
10
|
-
import { useAnimationsFinished as
|
|
10
|
+
import { useCls as T, useAntdCssVarClassname as $ } from "../utils/antdUtils.js";
|
|
11
|
+
import { useAnimationsFinished as q } from "../hooks/base-ui.js";
|
|
11
12
|
import { clsx as o } from "../utils/cn.js";
|
|
12
13
|
import { IconButton as f } from "../IconButton/component.js";
|
|
13
14
|
const Z = ({
|
|
14
15
|
children: h,
|
|
15
|
-
title:
|
|
16
|
-
defaultOpen:
|
|
17
|
-
open:
|
|
16
|
+
title: i,
|
|
17
|
+
defaultOpen: u = !1,
|
|
18
|
+
open: b,
|
|
18
19
|
onOpenChange: N,
|
|
19
20
|
className: C,
|
|
20
|
-
headerClassName:
|
|
21
|
-
headerInnerClassName:
|
|
22
|
-
bodyClassName:
|
|
21
|
+
headerClassName: x,
|
|
22
|
+
headerInnerClassName: y,
|
|
23
|
+
bodyClassName: v,
|
|
23
24
|
contentPadding: a = "16px",
|
|
24
|
-
afterTitle:
|
|
25
|
+
afterTitle: c,
|
|
25
26
|
actions: O,
|
|
26
|
-
useTitleAsTrigger:
|
|
27
|
+
useTitleAsTrigger: p = !0,
|
|
27
28
|
keepMounted: w = !1
|
|
28
29
|
}) => {
|
|
29
|
-
const e =
|
|
30
|
-
|
|
30
|
+
const e = T(), [s, t] = R(
|
|
31
|
+
b,
|
|
31
32
|
N,
|
|
32
|
-
|
|
33
|
-
), [
|
|
34
|
-
|
|
33
|
+
u
|
|
34
|
+
), [k, B] = V(s), m = g(null), d = q(m, {
|
|
35
|
+
waitForNextTick: s
|
|
36
|
+
}), F = $();
|
|
37
|
+
return j(() => {
|
|
35
38
|
d(() => {
|
|
36
|
-
|
|
39
|
+
B(s);
|
|
37
40
|
});
|
|
38
41
|
}, [s, d]), /* @__PURE__ */ r(
|
|
39
|
-
|
|
42
|
+
n.Root,
|
|
40
43
|
{
|
|
41
|
-
className: o(e("collapsible-panel"),
|
|
44
|
+
className: o(e("collapsible-panel"), F, C),
|
|
42
45
|
open: s,
|
|
43
46
|
onOpenChange: t,
|
|
44
47
|
ref: m,
|
|
45
48
|
children: [
|
|
46
|
-
/* @__PURE__ */ r("div", { className: o(e("collapsible-panel-header"),
|
|
49
|
+
/* @__PURE__ */ r("div", { className: o(e("collapsible-panel-header"), x), children: [
|
|
47
50
|
/* @__PURE__ */ r(
|
|
48
51
|
"div",
|
|
49
52
|
{
|
|
50
53
|
className: o(
|
|
51
54
|
e("collapsible-panel-header-inner"),
|
|
52
|
-
|
|
55
|
+
y
|
|
53
56
|
),
|
|
54
57
|
children: [
|
|
55
58
|
/* @__PURE__ */ l(
|
|
56
59
|
"div",
|
|
57
60
|
{
|
|
58
61
|
className: e("collapsible-panel-header-text"),
|
|
59
|
-
onClick:
|
|
60
|
-
style:
|
|
62
|
+
onClick: p ? () => t((I) => !I) : void 0,
|
|
63
|
+
style: p ? {
|
|
61
64
|
cursor: "pointer"
|
|
62
65
|
} : {},
|
|
63
|
-
children: typeof
|
|
66
|
+
children: typeof i == "string" ? /* @__PURE__ */ l(S, { children: i }) : i
|
|
64
67
|
}
|
|
65
68
|
),
|
|
66
69
|
/* @__PURE__ */ r("div", { className: e("collapsible-panel-header-actions"), children: [
|
|
67
70
|
s && O,
|
|
68
71
|
/* @__PURE__ */ l(
|
|
69
|
-
|
|
72
|
+
n.Trigger,
|
|
70
73
|
{
|
|
71
74
|
className: e("collapsible-panel-trigger"),
|
|
72
75
|
render: s ? /* @__PURE__ */ l(f, { children: /* @__PURE__ */ l(
|
|
73
|
-
|
|
76
|
+
A,
|
|
74
77
|
{
|
|
75
78
|
weight: "bold",
|
|
76
79
|
className: o(
|
|
@@ -94,10 +97,10 @@ const Z = ({
|
|
|
94
97
|
]
|
|
95
98
|
}
|
|
96
99
|
),
|
|
97
|
-
s &&
|
|
100
|
+
s && c && /* @__PURE__ */ l("div", { className: e("collapsible-panel-header-after"), children: c })
|
|
98
101
|
] }),
|
|
99
102
|
/* @__PURE__ */ l(
|
|
100
|
-
|
|
103
|
+
n.Panel,
|
|
101
104
|
{
|
|
102
105
|
className: e("collapsible-panel-content"),
|
|
103
106
|
style: typeof a < "u" ? {
|
|
@@ -107,8 +110,8 @@ const Z = ({
|
|
|
107
110
|
children: /* @__PURE__ */ l(
|
|
108
111
|
E,
|
|
109
112
|
{
|
|
110
|
-
show:
|
|
111
|
-
className: o(e("collapsible-panel-body"),
|
|
113
|
+
show: k,
|
|
114
|
+
className: o(e("collapsible-panel-body"), v),
|
|
112
115
|
keepMounted: !0,
|
|
113
116
|
children: /* @__PURE__ */ l("div", { children: h })
|
|
114
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/VerticalCollapsiblePanel/component.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { Collapsible } from \"@base-ui-components/react\";\nimport { MinusCircle, PlusCircle } from \"@bioturing/assets\";\nimport { useCls, clsx, useAntdCssVarClassname } from \"../utils\";\nimport { useControlledState } from \"../hooks/useControlledState\";\nimport { Transition } from \"../Transition\";\nimport { useAnimationsFinished } from \"../hooks\";\nimport { IconButton } from \"../IconButton\";\nimport { Truncate } from \"../Truncate/component\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface VerticalCollapsiblePanelProps {\n /**\n * The content of the panel that will be toggled\n */\n children: React.ReactNode;\n /**\n * The header of the panel\n */\n title?: React.ReactNode;\n /**\n * Indicate if the title should be used as a trigger\n * @default true\n */\n useTitleAsTrigger?: boolean;\n /**\n * Custom Content Padding\n * @default \"24px\"\n */\n contentPadding?: number | string | boolean;\n /**\n * Add more content below the title\n * Only show when panel is open\n */\n afterTitle?: React.ReactNode;\n\n /**\n * Whether the panel is expanded by default\n */\n defaultOpen?: boolean;\n /**\n * Control the open state (makes the component controlled)\n */\n open?: boolean;\n /**\n * Callback when the open state changes\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Additional class name for the component\n */\n className?: string;\n /**\n * Addtional class name for the header\n */\n headerClassName?: string;\n /**\n * Addtional class name for the header\n */\n headerInnerClassName?: string;\n /**\n * Addtional class name for the body\n * */\n bodyClassName?: string;\n /**\n * Actions to be displayed in the header\n * Only show when panel is open\n */\n actions?: React.ReactNode;\n /**\n * Keeping it as mounted, just hide the content\n */\n keepMounted?: boolean;\n}\n\nexport const VerticalCollapsiblePanel: React.FC<\n VerticalCollapsiblePanelProps\n> = ({\n children,\n title,\n defaultOpen = false,\n open: controlledOpen,\n onOpenChange,\n className,\n headerClassName,\n headerInnerClassName,\n bodyClassName,\n contentPadding = \"16px\",\n afterTitle,\n actions,\n useTitleAsTrigger = true,\n keepMounted = false,\n}) => {\n const cls = useCls();\n // Use useControlledState for open state\n const [isOpen, setIsOpen] = useControlledState(\n controlledOpen,\n onOpenChange,\n defaultOpen\n );\n const [isBodyOpen, setIsBodyOpen] = useState(isOpen);\n const ref = useRef<HTMLDivElement>(null);\n const runOnceAnimationsFinish = useAnimationsFinished(ref, isOpen);\n const cssVars = useAntdCssVarClassname();\n useEffect(() => {\n runOnceAnimationsFinish(() => {\n setIsBodyOpen(isOpen);\n });\n }, [isOpen, runOnceAnimationsFinish]);\n return (\n <Collapsible.Root\n className={clsx(cls(\"collapsible-panel\"), cssVars, className)}\n open={isOpen}\n onOpenChange={setIsOpen}\n ref={ref}\n >\n <div className={clsx(cls(\"collapsible-panel-header\"), headerClassName)}>\n <div\n className={clsx(\n cls(\"collapsible-panel-header-inner\"),\n headerInnerClassName\n )}\n >\n <div\n className={cls(\"collapsible-panel-header-text\")}\n onClick={\n useTitleAsTrigger ? () => setIsOpen((open) => !open) : undefined\n }\n style={\n useTitleAsTrigger\n ? {\n cursor: \"pointer\",\n }\n : {}\n }\n >\n {typeof title == \"string\" ? <Truncate>{title}</Truncate> : title}\n </div>\n <div className={cls(\"collapsible-panel-header-actions\")}>\n {isOpen && actions}\n <Collapsible.Trigger\n className={cls(\"collapsible-panel-trigger\")}\n render={\n isOpen ? (\n <IconButton>\n <MinusCircle\n weight=\"bold\"\n className={clsx(\n cls(\"collapsible-panel-caret\"),\n isOpen && cls(\"collapsible-panel-caret-open\")\n )}\n />\n </IconButton>\n ) : (\n <IconButton>\n <PlusCircle\n weight=\"bold\"\n className={clsx(\n cls(\"collapsible-panel-caret\"),\n isOpen && cls(\"collapsible-panel-caret-open\")\n )}\n />\n </IconButton>\n )\n }\n ></Collapsible.Trigger>\n </div>\n </div>\n {isOpen && afterTitle && (\n <div className={cls(\"collapsible-panel-header-after\")}>\n {afterTitle}\n </div>\n )}\n </div>\n <Collapsible.Panel\n className={cls(\"collapsible-panel-content\")}\n style={\n (typeof contentPadding != \"undefined\"\n ? {\n \"--ds-content-padding\":\n contentPadding === false || contentPadding === 0\n ? \"0\"\n : typeof contentPadding == \"number\"\n ? `${contentPadding}px`\n : contentPadding,\n }\n : {}) as React.CSSProperties\n }\n keepMounted={keepMounted}\n >\n <Transition\n show={isBodyOpen}\n className={clsx(cls(\"collapsible-panel-body\"), bodyClassName)}\n keepMounted\n >\n <div>{children}</div>\n </Transition>\n </Collapsible.Panel>\n </Collapsible.Root>\n );\n};\n"],"names":["VerticalCollapsiblePanel","children","title","defaultOpen","controlledOpen","onOpenChange","className","headerClassName","headerInnerClassName","bodyClassName","contentPadding","afterTitle","actions","useTitleAsTrigger","keepMounted","cls","useCls","isOpen","setIsOpen","useControlledState","isBodyOpen","setIsBodyOpen","useState","ref","useRef","runOnceAnimationsFinish","useAnimationsFinished","cssVars","useAntdCssVarClassname","useEffect","jsxs","Collapsible","clsx","jsx","open","Truncate","IconButton","MinusCircle","PlusCircle","Transition"],"mappings":"
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/VerticalCollapsiblePanel/component.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { Collapsible } from \"@base-ui-components/react\";\nimport { MinusCircle, PlusCircle } from \"@bioturing/assets\";\nimport { useCls, clsx, useAntdCssVarClassname } from \"../utils\";\nimport { useControlledState } from \"../hooks/useControlledState\";\nimport { Transition } from \"../Transition\";\nimport { useAnimationsFinished } from \"../hooks\";\nimport { IconButton } from \"../IconButton\";\nimport { Truncate } from \"../Truncate/component\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface VerticalCollapsiblePanelProps {\n /**\n * The content of the panel that will be toggled\n */\n children: React.ReactNode;\n /**\n * The header of the panel\n */\n title?: React.ReactNode;\n /**\n * Indicate if the title should be used as a trigger\n * @default true\n */\n useTitleAsTrigger?: boolean;\n /**\n * Custom Content Padding\n * @default \"24px\"\n */\n contentPadding?: number | string | boolean;\n /**\n * Add more content below the title\n * Only show when panel is open\n */\n afterTitle?: React.ReactNode;\n\n /**\n * Whether the panel is expanded by default\n */\n defaultOpen?: boolean;\n /**\n * Control the open state (makes the component controlled)\n */\n open?: boolean;\n /**\n * Callback when the open state changes\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Additional class name for the component\n */\n className?: string;\n /**\n * Addtional class name for the header\n */\n headerClassName?: string;\n /**\n * Addtional class name for the header\n */\n headerInnerClassName?: string;\n /**\n * Addtional class name for the body\n * */\n bodyClassName?: string;\n /**\n * Actions to be displayed in the header\n * Only show when panel is open\n */\n actions?: React.ReactNode;\n /**\n * Keeping it as mounted, just hide the content\n */\n keepMounted?: boolean;\n}\n\nexport const VerticalCollapsiblePanel: React.FC<\n VerticalCollapsiblePanelProps\n> = ({\n children,\n title,\n defaultOpen = false,\n open: controlledOpen,\n onOpenChange,\n className,\n headerClassName,\n headerInnerClassName,\n bodyClassName,\n contentPadding = \"16px\",\n afterTitle,\n actions,\n useTitleAsTrigger = true,\n keepMounted = false,\n}) => {\n const cls = useCls();\n // Use useControlledState for open state\n const [isOpen, setIsOpen] = useControlledState(\n controlledOpen,\n onOpenChange,\n defaultOpen\n );\n const [isBodyOpen, setIsBodyOpen] = useState(isOpen);\n const ref = useRef<HTMLDivElement>(null);\n const runOnceAnimationsFinish = useAnimationsFinished(ref, {\n waitForNextTick: isOpen,\n });\n const cssVars = useAntdCssVarClassname();\n useEffect(() => {\n runOnceAnimationsFinish(() => {\n setIsBodyOpen(isOpen);\n });\n }, [isOpen, runOnceAnimationsFinish]);\n return (\n <Collapsible.Root\n className={clsx(cls(\"collapsible-panel\"), cssVars, className)}\n open={isOpen}\n onOpenChange={setIsOpen}\n ref={ref}\n >\n <div className={clsx(cls(\"collapsible-panel-header\"), headerClassName)}>\n <div\n className={clsx(\n cls(\"collapsible-panel-header-inner\"),\n headerInnerClassName\n )}\n >\n <div\n className={cls(\"collapsible-panel-header-text\")}\n onClick={\n useTitleAsTrigger ? () => setIsOpen((open) => !open) : undefined\n }\n style={\n useTitleAsTrigger\n ? {\n cursor: \"pointer\",\n }\n : {}\n }\n >\n {typeof title == \"string\" ? <Truncate>{title}</Truncate> : title}\n </div>\n <div className={cls(\"collapsible-panel-header-actions\")}>\n {isOpen && actions}\n <Collapsible.Trigger\n className={cls(\"collapsible-panel-trigger\")}\n render={\n isOpen ? (\n <IconButton>\n <MinusCircle\n weight=\"bold\"\n className={clsx(\n cls(\"collapsible-panel-caret\"),\n isOpen && cls(\"collapsible-panel-caret-open\")\n )}\n />\n </IconButton>\n ) : (\n <IconButton>\n <PlusCircle\n weight=\"bold\"\n className={clsx(\n cls(\"collapsible-panel-caret\"),\n isOpen && cls(\"collapsible-panel-caret-open\")\n )}\n />\n </IconButton>\n )\n }\n ></Collapsible.Trigger>\n </div>\n </div>\n {isOpen && afterTitle && (\n <div className={cls(\"collapsible-panel-header-after\")}>\n {afterTitle}\n </div>\n )}\n </div>\n <Collapsible.Panel\n className={cls(\"collapsible-panel-content\")}\n style={\n (typeof contentPadding != \"undefined\"\n ? {\n \"--ds-content-padding\":\n contentPadding === false || contentPadding === 0\n ? \"0\"\n : typeof contentPadding == \"number\"\n ? `${contentPadding}px`\n : contentPadding,\n }\n : {}) as React.CSSProperties\n }\n keepMounted={keepMounted}\n >\n <Transition\n show={isBodyOpen}\n className={clsx(cls(\"collapsible-panel-body\"), bodyClassName)}\n keepMounted\n >\n <div>{children}</div>\n </Transition>\n </Collapsible.Panel>\n </Collapsible.Root>\n );\n};\n"],"names":["VerticalCollapsiblePanel","children","title","defaultOpen","controlledOpen","onOpenChange","className","headerClassName","headerInnerClassName","bodyClassName","contentPadding","afterTitle","actions","useTitleAsTrigger","keepMounted","cls","useCls","isOpen","setIsOpen","useControlledState","isBodyOpen","setIsBodyOpen","useState","ref","useRef","runOnceAnimationsFinish","useAnimationsFinished","cssVars","useAntdCssVarClassname","useEffect","jsxs","Collapsible","clsx","jsx","open","Truncate","IconButton","MinusCircle","PlusCircle","Transition"],"mappings":";;;;;;;;;;;;;AA8EO,MAAMA,IAET,CAAC;AAAA,EACH,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAMC;AAAA,EACN,cAAAC;AAAA,EACA,WAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,mBAAAC,IAAoB;AAAA,EACpB,aAAAC,IAAc;AAChB,MAAM;AACJ,QAAMC,IAAMC,EAAO,GAEb,CAACC,GAAQC,CAAS,IAAIC;AAAA,IAC1Bf;AAAA,IACAC;AAAA,IACAF;AAAA,EACF,GACM,CAACiB,GAAYC,CAAa,IAAIC,EAASL,CAAM,GAC7CM,IAAMC,EAAuB,IAAI,GACjCC,IA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
2
|
-
import
|
|
3
|
+
import t from "antd/es/grid";
|
|
3
4
|
import o from "antd/es/app/useApp";
|
|
4
5
|
import { default as d } from "antd/es/app/useApp";
|
|
5
6
|
import { useForm as l, useWatch as x } from "antd/es/form/Form";
|
|
6
|
-
const
|
|
7
|
+
const m = s.useToken, p = t.useBreakpoint, a = () => {
|
|
7
8
|
const { message: e } = o();
|
|
8
9
|
return e;
|
|
9
10
|
}, c = () => {
|
|
@@ -16,7 +17,7 @@ export {
|
|
|
16
17
|
l as useForm,
|
|
17
18
|
a as useMessage,
|
|
18
19
|
c as useModal,
|
|
19
|
-
|
|
20
|
+
m as useToken,
|
|
20
21
|
x as useWatch
|
|
21
22
|
};
|
|
22
23
|
//# sourceMappingURL=antd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"antd.js","sources":["../../../src/components/hooks/antd.ts"],"sourcesContent":["\"use client\";\nimport theme from \"antd/es/theme\";\nimport Grid from \"antd/es/grid\";\nimport useApp from \"antd/es/app/useApp\";\n\nexport const useToken = theme.useToken;\nexport const useBreakpoint = Grid.useBreakpoint;\n\nexport { useForm, useWatch } from \"antd/es/form/Form\";\n\nexport const useMessage = () => {\n const { message } = useApp();\n return message;\n};\n\nexport const useModal = () => {\n const { modal } = useApp();\n return modal;\n};\n\nexport { useApp };\n"],"names":["useToken","theme","useBreakpoint","Grid","useMessage","message","useApp","useModal","modal"],"mappings":"
|
|
1
|
+
{"version":3,"file":"antd.js","sources":["../../../src/components/hooks/antd.ts"],"sourcesContent":["\"use client\";\nimport theme from \"antd/es/theme\";\nimport Grid from \"antd/es/grid\";\nimport useApp from \"antd/es/app/useApp\";\n\nexport const useToken = theme.useToken;\nexport const useBreakpoint = Grid.useBreakpoint;\n\nexport { useForm, useWatch } from \"antd/es/form/Form\";\n\nexport const useMessage = () => {\n const { message } = useApp();\n return message;\n};\n\nexport const useModal = () => {\n const { modal } = useApp();\n return modal;\n};\n\nexport { useApp };\n"],"names":["useToken","theme","useBreakpoint","Grid","useMessage","message","useApp","useModal","modal"],"mappings":";;;;;;AAKO,MAAMA,IAAWC,EAAM,UACjBC,IAAgBC,EAAK,eAIrBC,IAAa,MAAM;AACxB,QAAA,EAAE,SAAAC,EAAQ,IAAIC,EAAO;AACpB,SAAAD;AACT,GAEaE,IAAW,MAAM;AACtB,QAAA,EAAE,OAAAC,EAAM,IAAIF,EAAO;AAClB,SAAAE;AACT;"}
|
|
@@ -1,47 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLayoutEffect as p, useEffect as m, useRef as c, useCallback as h } from "react";
|
|
3
|
+
import { flushSync as A } from "react-dom";
|
|
4
|
+
const l = typeof window < "u" ? p : m;
|
|
5
|
+
function a(t) {
|
|
6
|
+
const e = c(t);
|
|
7
|
+
return l(() => {
|
|
7
8
|
e.current = t;
|
|
8
|
-
}),
|
|
9
|
-
(...
|
|
9
|
+
}), h(
|
|
10
|
+
(...i) => {
|
|
10
11
|
var n;
|
|
11
|
-
return (n = e.current) == null ? void 0 : n.call(e, ...
|
|
12
|
+
return (n = e.current) == null ? void 0 : n.call(e, ...i);
|
|
12
13
|
},
|
|
13
14
|
[]
|
|
14
15
|
);
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
const e =
|
|
18
|
-
return
|
|
17
|
+
function E(t) {
|
|
18
|
+
const e = c(t);
|
|
19
|
+
return l(() => {
|
|
19
20
|
e.current = t;
|
|
20
21
|
}), e;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
function R(t, {
|
|
24
|
+
waitForNextTick: e = !1,
|
|
25
|
+
subtree: i = !1
|
|
26
|
+
}) {
|
|
27
|
+
const n = c(-1), u = c(-1), s = a(() => {
|
|
28
|
+
cancelAnimationFrame(n.current), clearTimeout(u.current);
|
|
25
29
|
});
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
return m(() => s, [s]), a((o) => {
|
|
31
|
+
s();
|
|
32
|
+
const r = t.current;
|
|
33
|
+
r && (typeof r.getAnimations != "function" ? o() : n.current = requestAnimationFrame(() => {
|
|
34
|
+
function f() {
|
|
35
|
+
r && Promise.allSettled(
|
|
36
|
+
r.getAnimations({
|
|
37
|
+
subtree: i
|
|
38
|
+
}).map((d) => d.finished)
|
|
33
39
|
).then(() => {
|
|
34
|
-
|
|
40
|
+
A(o);
|
|
35
41
|
});
|
|
36
42
|
}
|
|
37
|
-
e ?
|
|
43
|
+
e ? u.current = window.setTimeout(f) : f();
|
|
38
44
|
}));
|
|
39
45
|
});
|
|
40
46
|
}
|
|
41
47
|
export {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
R as useAnimationsFinished,
|
|
49
|
+
l as useEnhancedEffect,
|
|
50
|
+
a as useEventCallback,
|
|
51
|
+
E as useLatestRef
|
|
46
52
|
};
|
|
47
53
|
//# sourceMappingURL=base-ui.js.map
|