@vrobots/storybook 0.1.68 → 0.1.70
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/package.json +1 -1
- package/dist/src/components/FoldersAndFiles.d.ts +1 -0
- package/dist/src/components/FoldersAndFiles.js +47 -0
- package/dist/src/components/form/FileUploader.js +2 -2
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.js +1 -0
- package/dist/src/stories/FoldersAndFiles.stories.d.ts +13 -0
- package/dist/src/stories/FoldersAndFiles.stories.js +14 -0
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FoldersAndFiles: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { TreeView, createTreeCollection } from "@chakra-ui/react";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { LuFile, LuFolder } from "react-icons/lu";
|
|
6
|
+
export const FoldersAndFiles = () => {
|
|
7
|
+
const [expandedValue, setExpandedValue] = useState(["node_modules"]);
|
|
8
|
+
return (_jsxs(TreeView.Root, { collection: collection, expandedValue: expandedValue, onExpandedChange: (e) => setExpandedValue(e.expandedValue), children: [_jsx(TreeView.Label, { children: "Tree" }), _jsx(TreeView.Tree, { children: _jsx(TreeView.Node, { indentGuide: _jsx(TreeView.BranchIndentGuide, {}), render: ({ node }) => node.children ? (_jsxs(TreeView.BranchControl, { children: [_jsx(LuFolder, {}), _jsx(TreeView.BranchText, { children: node.name })] })) : (_jsxs(TreeView.Item, { children: [_jsx(LuFile, {}), _jsx(TreeView.ItemText, { children: node.name })] })) }) })] }));
|
|
9
|
+
};
|
|
10
|
+
const collection = createTreeCollection({
|
|
11
|
+
nodeToValue: (node) => node.id,
|
|
12
|
+
nodeToString: (node) => node.name,
|
|
13
|
+
rootNode: {
|
|
14
|
+
id: "ROOT",
|
|
15
|
+
name: "",
|
|
16
|
+
children: [
|
|
17
|
+
{
|
|
18
|
+
id: "node_modules",
|
|
19
|
+
name: "node_modules",
|
|
20
|
+
children: [
|
|
21
|
+
{ id: "node_modules/zag-js", name: "zag-js" },
|
|
22
|
+
{ id: "node_modules/pandacss", name: "panda" },
|
|
23
|
+
{
|
|
24
|
+
id: "node_modules/@types",
|
|
25
|
+
name: "@types",
|
|
26
|
+
children: [
|
|
27
|
+
{ id: "node_modules/@types/react", name: "react" },
|
|
28
|
+
{ id: "node_modules/@types/react-dom", name: "react-dom" },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "src",
|
|
35
|
+
name: "src",
|
|
36
|
+
children: [
|
|
37
|
+
{ id: "src/app.tsx", name: "app.tsx" },
|
|
38
|
+
{ id: "src/index.ts", name: "index.ts" },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{ id: "panda.config", name: "panda.config.ts" },
|
|
42
|
+
{ id: "package.json", name: "package.json" },
|
|
43
|
+
{ id: "renovate.json", name: "renovate.json" },
|
|
44
|
+
{ id: "readme.md", name: "README.md" },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
});
|
|
@@ -27,7 +27,7 @@ const filterFilesByAccept = (files, accept) => {
|
|
|
27
27
|
return files;
|
|
28
28
|
return files.filter((file) => rules.some((rule) => fileMatchesRule(file, rule)));
|
|
29
29
|
};
|
|
30
|
-
const FileUploader = ({ title, description, buttonLabel, helperText, accept, multiple
|
|
30
|
+
const FileUploader = ({ title, description, buttonLabel, helperText, accept, multiple, onFilesSelected, uploadPercentages = [], children, ...props }) => {
|
|
31
31
|
const [isDragging, setIsDragging] = useState(false);
|
|
32
32
|
const [files, setFiles] = useState([]);
|
|
33
33
|
const fileInputRef = useRef(null);
|
|
@@ -54,6 +54,6 @@ const FileUploader = ({ title, description, buttonLabel, helperText, accept, mul
|
|
|
54
54
|
const droppedFiles = Array.from(event.dataTransfer.files ?? []);
|
|
55
55
|
handleFiles(droppedFiles);
|
|
56
56
|
};
|
|
57
|
-
return (_jsx(Card.Root, { ...props, children: _jsxs(Card.Body, { children: [_jsx(Card.Title, { children: title ||
|
|
57
|
+
return (_jsx(Card.Root, { ...props, children: _jsxs(Card.Body, { children: [_jsx(Card.Title, { children: title || `Upload ${multiple ? 'File/s' : 'a File'}` }), !!description && _jsx(Card.Description, { children: description }), _jsxs(Box, { mt: 4, p: 6, borderWidth: "2px", borderStyle: "dashed", borderColor: isDragging ? "teal.500" : "border.emphasized", borderRadius: "md", bg: isDragging ? "teal.subtle" : "bg.muted", textAlign: "center", transition: "background 0.2s ease, border-color 0.2s ease", onDragEnter: handleDrag(true), onDragOver: handleDrag(true), onDragLeave: handleDrag(false), onDrop: handleDrop, children: [_jsxs(Text, { fontWeight: "medium", children: ["Drag and drop ", multiple ? 'file/s' : 'a file', " here"] }), _jsx(Text, { fontSize: "sm", color: "fg.muted", mt: 1, children: "or click the button below to browse from your device" }), _jsx("input", { ref: fileInputRef, type: "file", hidden: true, accept: accept, multiple: multiple, onChange: handleFileInputChange }), _jsx(Button, { mt: 4, onClick: () => fileInputRef.current?.click(), children: buttonLabel || `Choose ${multiple ? 'File/s' : 'a File'}` }), !!helperText && (_jsx(Text, { fontSize: "xs", color: "fg.muted", mt: 3, children: helperText }))] }), files.length > 0 && (_jsxs(Box, { mt: 4, mb: 4, children: [_jsxs(Text, { fontSize: "sm", fontWeight: "medium", mb: 2, children: ["Selected ", multiple ? 'File/s' : 'a File'] }), _jsx(List.Root, { gap: "1", children: files.map((file, index) => (_jsx(List.Item, { children: `${file.name} ${!!uploadPercentages[index] ? '-' + uploadPercentages[index] + '%' : ''}` }, `${file.name}-${file.size}`))) })] })), children] }) }));
|
|
58
58
|
};
|
|
59
59
|
export default FileUploader;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: () => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: string;
|
|
8
|
+
};
|
|
9
|
+
args: {};
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
export declare const Component: Story;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FoldersAndFiles } from '../components';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Navigation/FoldersAndFiles',
|
|
4
|
+
component: FoldersAndFiles,
|
|
5
|
+
tags: ['autodocs'],
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'fullscreen',
|
|
8
|
+
},
|
|
9
|
+
args: {}
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
export const Component = {
|
|
13
|
+
args: {}
|
|
14
|
+
};
|