@arkyn/components 3.0.1-beta.22 → 3.0.1-beta.23
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/README.md +264 -0
- package/dist/bundle.js +1485 -859
- package/dist/bundle.umd.cjs +1 -1
- package/dist/components/audioUpload/hasFileContent/index.d.ts +13 -0
- package/dist/components/audioUpload/hasFileContent/index.d.ts.map +1 -0
- package/dist/components/audioUpload/hasFileContent/index.js +26 -0
- package/dist/components/audioUpload/index.d.ts +82 -0
- package/dist/components/audioUpload/index.d.ts.map +1 -0
- package/dist/components/audioUpload/index.js +120 -0
- package/dist/components/audioUpload/noFileContent/index.d.ts +12 -0
- package/dist/components/audioUpload/noFileContent/index.d.ts.map +1 -0
- package/dist/components/audioUpload/noFileContent/index.js +29 -0
- package/dist/components/clientOnly.d.ts +86 -0
- package/dist/components/clientOnly.d.ts.map +1 -0
- package/dist/components/clientOnly.js +86 -0
- package/dist/components/fileUpload/hasFileContent/index.d.ts +13 -0
- package/dist/components/fileUpload/hasFileContent/index.d.ts.map +1 -0
- package/dist/components/fileUpload/hasFileContent/index.js +34 -0
- package/dist/components/fileUpload/index.d.ts +94 -0
- package/dist/components/fileUpload/index.d.ts.map +1 -0
- package/dist/components/fileUpload/index.js +127 -0
- package/dist/components/fileUpload/noFileContent/index.d.ts +12 -0
- package/dist/components/fileUpload/noFileContent/index.d.ts.map +1 -0
- package/dist/components/fileUpload/noFileContent/index.js +29 -0
- package/dist/components/imageUpload/hasFileContent/index.d.ts +13 -0
- package/dist/components/imageUpload/hasFileContent/index.d.ts.map +1 -0
- package/dist/components/imageUpload/hasFileContent/index.js +24 -0
- package/dist/components/imageUpload/index.d.ts +114 -0
- package/dist/components/imageUpload/index.d.ts.map +1 -0
- package/dist/components/imageUpload/index.js +148 -0
- package/dist/components/imageUpload/noFileContent/index.d.ts +12 -0
- package/dist/components/imageUpload/noFileContent/index.d.ts.map +1 -0
- package/dist/components/imageUpload/noFileContent/index.js +29 -0
- package/dist/components/table/tableBody/index.d.ts +67 -0
- package/dist/components/table/tableBody/index.d.ts.map +1 -0
- package/dist/components/table/tableBody/index.js +69 -0
- package/dist/components/table/tableCaption/index.d.ts +62 -0
- package/dist/components/table/tableCaption/index.d.ts.map +1 -0
- package/dist/components/table/tableCaption/index.js +64 -0
- package/dist/components/table/tableContainer/index.d.ts +64 -0
- package/dist/components/table/tableContainer/index.d.ts.map +1 -0
- package/dist/components/table/tableContainer/index.js +66 -0
- package/dist/components/table/tableFooter/index.d.ts +45 -0
- package/dist/components/table/tableFooter/index.d.ts.map +1 -0
- package/dist/components/table/tableFooter/index.js +47 -0
- package/dist/components/table/tableHeader/index.d.ts +44 -0
- package/dist/components/table/tableHeader/index.d.ts.map +1 -0
- package/dist/components/table/tableHeader/index.js +46 -0
- package/dist/components/tooltip/index.d.ts.map +1 -1
- package/dist/components/tooltip/index.js +1 -1
- package/dist/hooks/useDrawer.d.ts +86 -0
- package/dist/hooks/useDrawer.d.ts.map +1 -0
- package/dist/hooks/useDrawer.js +20 -0
- package/dist/hooks/useHydrated.d.ts +76 -0
- package/dist/hooks/useHydrated.d.ts.map +1 -0
- package/dist/hooks/useHydrated.js +81 -0
- package/dist/hooks/useModal.d.ts +81 -0
- package/dist/hooks/useModal.d.ts.map +1 -0
- package/dist/hooks/useModal.js +20 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/providers/drawerProvider.d.ts +106 -0
- package/dist/providers/drawerProvider.d.ts.map +1 -0
- package/dist/providers/drawerProvider.js +120 -0
- package/dist/providers/modalProvider.d.ts +103 -0
- package/dist/providers/modalProvider.d.ts.map +1 -0
- package/dist/providers/modalProvider.js +119 -0
- package/dist/style.css +1 -1
- package/package.json +19 -2
@@ -0,0 +1,29 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { Button } from "../../button";
|
3
|
+
import "./styles.css";
|
4
|
+
function NoFileContent(props) {
|
5
|
+
const { dropFileText, isLoading, acceptFile, handleSelectFile, selectFileButtonText, disabled, } = props;
|
6
|
+
function handleDrop(event) {
|
7
|
+
if (disabled)
|
8
|
+
return;
|
9
|
+
event.preventDefault();
|
10
|
+
const file = event.dataTransfer.files[0];
|
11
|
+
if (file)
|
12
|
+
handleSelectFile(file);
|
13
|
+
}
|
14
|
+
function handleClick() {
|
15
|
+
if (disabled)
|
16
|
+
return;
|
17
|
+
const input = document.createElement("input");
|
18
|
+
input.type = "file";
|
19
|
+
input.accept = acceptFile;
|
20
|
+
input.onchange = (event) => {
|
21
|
+
const file = event.target.files?.[0];
|
22
|
+
if (file)
|
23
|
+
handleSelectFile(file);
|
24
|
+
};
|
25
|
+
input.click();
|
26
|
+
}
|
27
|
+
return (_jsxs("div", { onDrop: handleDrop, className: "arkynFileUploadNoFileContent", children: [_jsx(Button, { isLoading: isLoading, onClick: handleClick, variant: "ghost", size: "sm", type: "button", disabled: disabled, children: selectFileButtonText }), _jsx("p", { children: dropFileText })] }));
|
28
|
+
}
|
29
|
+
export { NoFileContent };
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import "./styles.css";
|
2
|
+
type HasFileContentProps = {
|
3
|
+
disabled: boolean;
|
4
|
+
acceptImage: string;
|
5
|
+
isLoading: boolean;
|
6
|
+
changeImageButtonText: string;
|
7
|
+
filePath: string;
|
8
|
+
reSendImage?: () => void;
|
9
|
+
handleSelectFile: (file: File) => void;
|
10
|
+
};
|
11
|
+
declare function HasFileContent(props: HasFileContentProps): import("react/jsx-runtime").JSX.Element;
|
12
|
+
export { HasFileContent };
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/imageUpload/hasFileContent/index.tsx"],"names":[],"mappings":"AAMA,OAAO,cAAc,CAAC;AAEtB,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,gBAAgB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,iBAAS,cAAc,CAAC,KAAK,EAAE,mBAAmB,2CA4DjD;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { RefreshCw } from "lucide-react";
|
3
|
+
import { Button } from "../../button";
|
4
|
+
import { IconButton } from "../../iconButton";
|
5
|
+
import { Tooltip } from "../../tooltip";
|
6
|
+
import "./styles.css";
|
7
|
+
function HasFileContent(props) {
|
8
|
+
const { disabled, filePath, isLoading, acceptImage, changeImageButtonText, handleSelectFile, reSendImage, } = props;
|
9
|
+
function handleClick() {
|
10
|
+
if (disabled)
|
11
|
+
return;
|
12
|
+
const input = document.createElement("input");
|
13
|
+
input.type = "file";
|
14
|
+
input.accept = acceptImage;
|
15
|
+
input.onchange = (event) => {
|
16
|
+
const file = event.target.files?.[0];
|
17
|
+
if (file)
|
18
|
+
handleSelectFile(file);
|
19
|
+
};
|
20
|
+
input.click();
|
21
|
+
}
|
22
|
+
return (_jsxs("div", { className: "arkynImageUploadHasFileContent", style: { backgroundImage: `url("${filePath}")` }, children: [reSendImage && (_jsx(Tooltip, { orientation: "bottom", text: "Reenviar imagem", children: _jsx(IconButton, { type: "button", "aria-label": "resend image", variant: "outline", scheme: "danger", size: "sm", isLoading: isLoading, onClick: reSendImage, icon: RefreshCw, disabled: disabled }) })), _jsx(Button, { isLoading: isLoading, onClick: handleClick, variant: "outline", size: "sm", type: "button", disabled: disabled, children: changeImageButtonText })] }));
|
23
|
+
}
|
24
|
+
export { HasFileContent };
|
@@ -0,0 +1,114 @@
|
|
1
|
+
import "./styles.css";
|
2
|
+
type ImageUploadProps = {
|
3
|
+
name: string;
|
4
|
+
action: string;
|
5
|
+
defaultValue?: string | null;
|
6
|
+
disabled?: boolean;
|
7
|
+
label?: string;
|
8
|
+
showAsterisk?: boolean;
|
9
|
+
changeImageButtonText?: string;
|
10
|
+
selectImageButtonText?: string;
|
11
|
+
dropImageText?: string;
|
12
|
+
method?: string;
|
13
|
+
fileName?: string;
|
14
|
+
fileResponseName?: string;
|
15
|
+
acceptImage?: string;
|
16
|
+
onChange?: (url?: string) => void;
|
17
|
+
};
|
18
|
+
/**
|
19
|
+
* ImageUpload component - specialized file upload component for image files with preview functionality
|
20
|
+
*
|
21
|
+
* @param props - ImageUpload component properties
|
22
|
+
* @param props.name - Required field name for form handling
|
23
|
+
* @param props.defaultValue - Initial image URL to display as preview. Default: ""
|
24
|
+
* @param props.disabled - Whether the image upload is disabled. Default: false
|
25
|
+
* @param props.label - Optional label text to display above the image upload area
|
26
|
+
* @param props.showAsterisk - Whether to show asterisk on label for required fields. Default: false
|
27
|
+
* @param props.changeImageButtonText - Text for the button to change/replace an uploaded image. Default: "Alterar imagem"
|
28
|
+
* @param props.selectImageButtonText - Text for the button to select an image. Default: "Selecionar imagem"
|
29
|
+
* @param props.dropImageText - Text displayed in the drop zone area. Default: "Ou arraste e solte a imagem aqui"
|
30
|
+
* @param props.action - Required endpoint URL where the image will be uploaded
|
31
|
+
* @param props.method - HTTP method for the upload request. Default: "POST"
|
32
|
+
* @param props.fileName - Form data field name for the image file. Default: "file"
|
33
|
+
* @param props.fileResponseName - Property name in the response object containing the image URL. Default: "url"
|
34
|
+
* @param props.acceptImage - Image file types accepted by the input (e.g., "image/*", ".jpg,.png"). Default: "image/*"
|
35
|
+
* @param props.onChange - Callback function called when image upload completes successfully, receives the image URL
|
36
|
+
*
|
37
|
+
* @returns ImageUpload JSX element wrapped in FieldGroup with optional label, image preview, and error handling
|
38
|
+
*
|
39
|
+
* @example
|
40
|
+
* ```tsx
|
41
|
+
* // Basic image upload
|
42
|
+
* <ImageUpload
|
43
|
+
* name="avatar"
|
44
|
+
* action="/api/upload/image"
|
45
|
+
* />
|
46
|
+
*
|
47
|
+
* // Image upload with label and custom text
|
48
|
+
* <ImageUpload
|
49
|
+
* name="profilePicture"
|
50
|
+
* action="/api/upload/avatar"
|
51
|
+
* label="Profile Picture"
|
52
|
+
* showAsterisk
|
53
|
+
* selectImageButtonText="Choose Photo"
|
54
|
+
* changeImageButtonText="Change Photo"
|
55
|
+
* dropImageText="Drop your photo here"
|
56
|
+
* />
|
57
|
+
*
|
58
|
+
* // Image upload with default value and restrictions
|
59
|
+
* <ImageUpload
|
60
|
+
* name="productImage"
|
61
|
+
* action="/api/upload/product"
|
62
|
+
* label="Product Image"
|
63
|
+
* defaultValue="https://example.com/default-image.jpg"
|
64
|
+
* acceptImage=".jpg,.jpeg,.png,.webp"
|
65
|
+
* fileName="productImage"
|
66
|
+
* fileResponseName="imageUrl"
|
67
|
+
* onChange={(url) => console.log('Image uploaded:', url)}
|
68
|
+
* />
|
69
|
+
*
|
70
|
+
* // Disabled image upload with existing image
|
71
|
+
* <ImageUpload
|
72
|
+
* name="banner"
|
73
|
+
* action="/api/upload/banner"
|
74
|
+
* label="Banner Image"
|
75
|
+
* defaultValue="https://example.com/banner.jpg"
|
76
|
+
* disabled
|
77
|
+
* />
|
78
|
+
*
|
79
|
+
* // Image upload with custom HTTP method and response handling
|
80
|
+
* <ImageUpload
|
81
|
+
* name="gallery"
|
82
|
+
* action="/api/images"
|
83
|
+
* method="PUT"
|
84
|
+
* fileName="galleryImage"
|
85
|
+
* fileResponseName="imageUrl"
|
86
|
+
* label="Gallery Image"
|
87
|
+
* acceptImage="image/jpeg,image/png"
|
88
|
+
* onChange={(url) => {
|
89
|
+
* if (url) {
|
90
|
+
* setImageUrl(url);
|
91
|
+
* console.log('Upload successful:', url);
|
92
|
+
* }
|
93
|
+
* }}
|
94
|
+
* />
|
95
|
+
*
|
96
|
+
* // Image upload for user avatar with form integration
|
97
|
+
* <ImageUpload
|
98
|
+
* name="userAvatar"
|
99
|
+
* action="/api/users/avatar"
|
100
|
+
* label="User Avatar"
|
101
|
+
* showAsterisk
|
102
|
+
* defaultValue={user?.avatarUrl}
|
103
|
+
* selectImageButtonText="Select Avatar"
|
104
|
+
* changeImageButtonText="Update Avatar"
|
105
|
+
* dropImageText="Drop avatar image here"
|
106
|
+
* onChange={(avatarUrl) => {
|
107
|
+
* updateUserProfile({ avatarUrl });
|
108
|
+
* }}
|
109
|
+
* />
|
110
|
+
* ```
|
111
|
+
*/
|
112
|
+
declare function ImageUpload(props: ImageUploadProps): import("react/jsx-runtime").JSX.Element;
|
113
|
+
export { ImageUpload };
|
114
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/imageUpload/index.tsx"],"names":[],"mappings":"AASA,OAAO,cAAc,CAAC;AAEtB,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AAEH,iBAAS,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CAoG3C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
@@ -0,0 +1,148 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { useState } from "react";
|
3
|
+
import { useForm } from "../../hooks/useForm";
|
4
|
+
import { FieldError } from "../fieldError";
|
5
|
+
import { FieldLabel } from "../fieldLabel";
|
6
|
+
import { FieldWrapper } from "../fieldWrapper";
|
7
|
+
import { HasFileContent } from "./hasFileContent";
|
8
|
+
import { NoFileContent } from "./noFileContent";
|
9
|
+
import "./styles.css";
|
10
|
+
/**
|
11
|
+
* ImageUpload component - specialized file upload component for image files with preview functionality
|
12
|
+
*
|
13
|
+
* @param props - ImageUpload component properties
|
14
|
+
* @param props.name - Required field name for form handling
|
15
|
+
* @param props.defaultValue - Initial image URL to display as preview. Default: ""
|
16
|
+
* @param props.disabled - Whether the image upload is disabled. Default: false
|
17
|
+
* @param props.label - Optional label text to display above the image upload area
|
18
|
+
* @param props.showAsterisk - Whether to show asterisk on label for required fields. Default: false
|
19
|
+
* @param props.changeImageButtonText - Text for the button to change/replace an uploaded image. Default: "Alterar imagem"
|
20
|
+
* @param props.selectImageButtonText - Text for the button to select an image. Default: "Selecionar imagem"
|
21
|
+
* @param props.dropImageText - Text displayed in the drop zone area. Default: "Ou arraste e solte a imagem aqui"
|
22
|
+
* @param props.action - Required endpoint URL where the image will be uploaded
|
23
|
+
* @param props.method - HTTP method for the upload request. Default: "POST"
|
24
|
+
* @param props.fileName - Form data field name for the image file. Default: "file"
|
25
|
+
* @param props.fileResponseName - Property name in the response object containing the image URL. Default: "url"
|
26
|
+
* @param props.acceptImage - Image file types accepted by the input (e.g., "image/*", ".jpg,.png"). Default: "image/*"
|
27
|
+
* @param props.onChange - Callback function called when image upload completes successfully, receives the image URL
|
28
|
+
*
|
29
|
+
* @returns ImageUpload JSX element wrapped in FieldGroup with optional label, image preview, and error handling
|
30
|
+
*
|
31
|
+
* @example
|
32
|
+
* ```tsx
|
33
|
+
* // Basic image upload
|
34
|
+
* <ImageUpload
|
35
|
+
* name="avatar"
|
36
|
+
* action="/api/upload/image"
|
37
|
+
* />
|
38
|
+
*
|
39
|
+
* // Image upload with label and custom text
|
40
|
+
* <ImageUpload
|
41
|
+
* name="profilePicture"
|
42
|
+
* action="/api/upload/avatar"
|
43
|
+
* label="Profile Picture"
|
44
|
+
* showAsterisk
|
45
|
+
* selectImageButtonText="Choose Photo"
|
46
|
+
* changeImageButtonText="Change Photo"
|
47
|
+
* dropImageText="Drop your photo here"
|
48
|
+
* />
|
49
|
+
*
|
50
|
+
* // Image upload with default value and restrictions
|
51
|
+
* <ImageUpload
|
52
|
+
* name="productImage"
|
53
|
+
* action="/api/upload/product"
|
54
|
+
* label="Product Image"
|
55
|
+
* defaultValue="https://example.com/default-image.jpg"
|
56
|
+
* acceptImage=".jpg,.jpeg,.png,.webp"
|
57
|
+
* fileName="productImage"
|
58
|
+
* fileResponseName="imageUrl"
|
59
|
+
* onChange={(url) => console.log('Image uploaded:', url)}
|
60
|
+
* />
|
61
|
+
*
|
62
|
+
* // Disabled image upload with existing image
|
63
|
+
* <ImageUpload
|
64
|
+
* name="banner"
|
65
|
+
* action="/api/upload/banner"
|
66
|
+
* label="Banner Image"
|
67
|
+
* defaultValue="https://example.com/banner.jpg"
|
68
|
+
* disabled
|
69
|
+
* />
|
70
|
+
*
|
71
|
+
* // Image upload with custom HTTP method and response handling
|
72
|
+
* <ImageUpload
|
73
|
+
* name="gallery"
|
74
|
+
* action="/api/images"
|
75
|
+
* method="PUT"
|
76
|
+
* fileName="galleryImage"
|
77
|
+
* fileResponseName="imageUrl"
|
78
|
+
* label="Gallery Image"
|
79
|
+
* acceptImage="image/jpeg,image/png"
|
80
|
+
* onChange={(url) => {
|
81
|
+
* if (url) {
|
82
|
+
* setImageUrl(url);
|
83
|
+
* console.log('Upload successful:', url);
|
84
|
+
* }
|
85
|
+
* }}
|
86
|
+
* />
|
87
|
+
*
|
88
|
+
* // Image upload for user avatar with form integration
|
89
|
+
* <ImageUpload
|
90
|
+
* name="userAvatar"
|
91
|
+
* action="/api/users/avatar"
|
92
|
+
* label="User Avatar"
|
93
|
+
* showAsterisk
|
94
|
+
* defaultValue={user?.avatarUrl}
|
95
|
+
* selectImageButtonText="Select Avatar"
|
96
|
+
* changeImageButtonText="Update Avatar"
|
97
|
+
* dropImageText="Drop avatar image here"
|
98
|
+
* onChange={(avatarUrl) => {
|
99
|
+
* updateUserProfile({ avatarUrl });
|
100
|
+
* }}
|
101
|
+
* />
|
102
|
+
* ```
|
103
|
+
*/
|
104
|
+
function ImageUpload(props) {
|
105
|
+
const { name, defaultValue = "", label, showAsterisk = false, action, fileName = "file", method = "POST", acceptImage = "image/*", fileResponseName = "url", changeImageButtonText = "Alterar imagem", selectImageButtonText = "Selecionar imagem", dropImageText = "Ou arraste e solte a imagem aqui", onChange, disabled = false, } = props;
|
106
|
+
const { fieldErrors } = useForm();
|
107
|
+
const fieldError = fieldErrors?.[name];
|
108
|
+
const [value, setValue] = useState(defaultValue);
|
109
|
+
const [error, setError] = useState("");
|
110
|
+
const [file, setFile] = useState(null);
|
111
|
+
const [filePath, setFilePath] = useState(defaultValue);
|
112
|
+
const [isLoading, setIsLoading] = useState(false);
|
113
|
+
async function handleUploadImage(file) {
|
114
|
+
if (disabled)
|
115
|
+
return;
|
116
|
+
setIsLoading(true);
|
117
|
+
setFile(file);
|
118
|
+
setError("");
|
119
|
+
const formData = new FormData();
|
120
|
+
formData.append(fileName, file);
|
121
|
+
await fetch(action, { method: method, body: formData })
|
122
|
+
.then(async (response) => await response.json())
|
123
|
+
.then((response) => {
|
124
|
+
if (!!response?.error)
|
125
|
+
setError(response.error);
|
126
|
+
else
|
127
|
+
setValue(response?.[fileResponseName]);
|
128
|
+
onChange && onChange(response?.[fileResponseName]);
|
129
|
+
})
|
130
|
+
.catch((error) => {
|
131
|
+
console.error(error);
|
132
|
+
setError("Erro ao enviar imagem");
|
133
|
+
})
|
134
|
+
.finally(() => setIsLoading(false));
|
135
|
+
}
|
136
|
+
function handleSelectFile(file) {
|
137
|
+
if (disabled)
|
138
|
+
return;
|
139
|
+
setFilePath(URL.createObjectURL(file));
|
140
|
+
handleUploadImage(file);
|
141
|
+
}
|
142
|
+
const errorMessage = fieldError || error;
|
143
|
+
const hasErrorClassName = errorMessage ? "hasError" : "noHasError";
|
144
|
+
const hasImageClassName = filePath ? "hasImage" : "noHasImage";
|
145
|
+
const className = `arkynImageUpload ${hasErrorClassName} ${hasImageClassName}`;
|
146
|
+
return (_jsxs(FieldWrapper, { children: [label && _jsx(FieldLabel, { showAsterisk: showAsterisk, children: label }), _jsxs("div", { className: className, children: [_jsx("input", { type: "hidden", name: name, value: value || "" }), !filePath && (_jsx(NoFileContent, { disabled: disabled, isLoading: isLoading, acceptImage: acceptImage, dropImageText: dropImageText, handleSelectFile: handleSelectFile, selectImageButtonText: selectImageButtonText })), filePath && (_jsx(HasFileContent, { disabled: disabled, isLoading: isLoading, acceptImage: acceptImage, filePath: filePath, handleSelectFile: handleSelectFile, changeImageButtonText: changeImageButtonText, reSendImage: !!errorMessage && file ? () => handleUploadImage(file) : undefined }))] }), errorMessage && _jsx(FieldError, { children: errorMessage })] }));
|
147
|
+
}
|
148
|
+
export { ImageUpload };
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import "./styles.css";
|
2
|
+
type NoFileContentProps = {
|
3
|
+
disabled: boolean;
|
4
|
+
acceptImage: string;
|
5
|
+
isLoading: boolean;
|
6
|
+
selectImageButtonText: string;
|
7
|
+
dropImageText: string;
|
8
|
+
handleSelectFile: (file: File) => void;
|
9
|
+
};
|
10
|
+
declare function NoFileContent(props: NoFileContentProps): import("react/jsx-runtime").JSX.Element;
|
11
|
+
export { NoFileContent };
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/imageUpload/noFileContent/index.tsx"],"names":[],"mappings":"AAGA,OAAO,cAAc,CAAC;AAEtB,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,iBAAS,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAkD/C;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { Button } from "../../button";
|
3
|
+
import "./styles.css";
|
4
|
+
function NoFileContent(props) {
|
5
|
+
const { dropImageText, isLoading, acceptImage, handleSelectFile, selectImageButtonText, disabled, } = props;
|
6
|
+
function handleDrop(event) {
|
7
|
+
if (disabled)
|
8
|
+
return;
|
9
|
+
event.preventDefault();
|
10
|
+
const file = event.dataTransfer.files[0];
|
11
|
+
if (file)
|
12
|
+
handleSelectFile(file);
|
13
|
+
}
|
14
|
+
function handleClick() {
|
15
|
+
if (disabled)
|
16
|
+
return;
|
17
|
+
const input = document.createElement("input");
|
18
|
+
input.type = "file";
|
19
|
+
input.accept = acceptImage;
|
20
|
+
input.onchange = (event) => {
|
21
|
+
const file = event.target.files?.[0];
|
22
|
+
if (file)
|
23
|
+
handleSelectFile(file);
|
24
|
+
};
|
25
|
+
input.click();
|
26
|
+
}
|
27
|
+
return (_jsxs("div", { onDrop: handleDrop, className: "arkynImageUploadNoFileContent", children: [_jsx(Button, { isLoading: isLoading, onClick: handleClick, variant: "ghost", size: "sm", type: "button", disabled: disabled, children: selectImageButtonText }), _jsx("p", { children: dropImageText })] }));
|
28
|
+
}
|
29
|
+
export { NoFileContent };
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { HTMLAttributes } from "react";
|
2
|
+
import "./styles.css";
|
3
|
+
type TableBodyProps = HTMLAttributes<HTMLTableSectionElement> & {
|
4
|
+
emptyMessage?: string;
|
5
|
+
};
|
6
|
+
/**
|
7
|
+
* TableBody component - used to render the main content section of a table with empty state handling
|
8
|
+
*
|
9
|
+
* @param props - TableBody component properties
|
10
|
+
* @param props.emptyMessage - Message to display when no children are provided. Default: "Nenhum dado adicionado."
|
11
|
+
*
|
12
|
+
* **...All valid HTML properties for tbody element**
|
13
|
+
*
|
14
|
+
* @returns TableBody JSX element
|
15
|
+
*
|
16
|
+
* @example
|
17
|
+
* ```tsx
|
18
|
+
* // Basic table body with data
|
19
|
+
* <TableBody>
|
20
|
+
* <tr>
|
21
|
+
* <td>John Doe</td>
|
22
|
+
* <td>john@example.com</td>
|
23
|
+
* </tr>
|
24
|
+
* <tr>
|
25
|
+
* <td>Jane Smith</td>
|
26
|
+
* <td>jane@example.com</td>
|
27
|
+
* </tr>
|
28
|
+
* </TableBody>
|
29
|
+
*
|
30
|
+
* // Empty table body with custom message
|
31
|
+
* <TableBody emptyMessage="No users found. Please add some users to get started." />
|
32
|
+
*
|
33
|
+
* // Table body with dynamic content and custom styling
|
34
|
+
* <TableBody className="striped-rows" emptyMessage="No products available">
|
35
|
+
* {products.map(product => (
|
36
|
+
* <tr key={product.id}>
|
37
|
+
* <td>{product.name}</td>
|
38
|
+
* <td>{product.price}</td>
|
39
|
+
* <td>{product.stock}</td>
|
40
|
+
* </tr>
|
41
|
+
* ))}
|
42
|
+
* </TableBody>
|
43
|
+
*
|
44
|
+
* // Complete table usage
|
45
|
+
* <TableContainer>
|
46
|
+
* <TableHeader>
|
47
|
+
* <th>Name</th>
|
48
|
+
* <th>Status</th>
|
49
|
+
* <th>Actions</th>
|
50
|
+
* </TableHeader>
|
51
|
+
* <TableBody emptyMessage="No data to display">
|
52
|
+
* {data.map(item => (
|
53
|
+
* <tr key={item.id}>
|
54
|
+
* <td>{item.name}</td>
|
55
|
+
* <td>{item.status}</td>
|
56
|
+
* <td>
|
57
|
+
* <Button>Edit</Button>
|
58
|
+
* </td>
|
59
|
+
* </tr>
|
60
|
+
* ))}
|
61
|
+
* </TableBody>
|
62
|
+
* </TableContainer>
|
63
|
+
* ```
|
64
|
+
*/
|
65
|
+
declare function TableBody(props: TableBodyProps): import("react/jsx-runtime").JSX.Element;
|
66
|
+
export { TableBody };
|
67
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/tableBody/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,cAAc,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,cAAc,CAAC;AAEtB,KAAK,cAAc,GAAG,cAAc,CAAC,uBAAuB,CAAC,GAAG;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,iBAAS,SAAS,CAAC,KAAK,EAAE,cAAc,2CAwBvC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Children } from "react";
|
3
|
+
import "./styles.css";
|
4
|
+
/**
|
5
|
+
* TableBody component - used to render the main content section of a table with empty state handling
|
6
|
+
*
|
7
|
+
* @param props - TableBody component properties
|
8
|
+
* @param props.emptyMessage - Message to display when no children are provided. Default: "Nenhum dado adicionado."
|
9
|
+
*
|
10
|
+
* **...All valid HTML properties for tbody element**
|
11
|
+
*
|
12
|
+
* @returns TableBody JSX element
|
13
|
+
*
|
14
|
+
* @example
|
15
|
+
* ```tsx
|
16
|
+
* // Basic table body with data
|
17
|
+
* <TableBody>
|
18
|
+
* <tr>
|
19
|
+
* <td>John Doe</td>
|
20
|
+
* <td>john@example.com</td>
|
21
|
+
* </tr>
|
22
|
+
* <tr>
|
23
|
+
* <td>Jane Smith</td>
|
24
|
+
* <td>jane@example.com</td>
|
25
|
+
* </tr>
|
26
|
+
* </TableBody>
|
27
|
+
*
|
28
|
+
* // Empty table body with custom message
|
29
|
+
* <TableBody emptyMessage="No users found. Please add some users to get started." />
|
30
|
+
*
|
31
|
+
* // Table body with dynamic content and custom styling
|
32
|
+
* <TableBody className="striped-rows" emptyMessage="No products available">
|
33
|
+
* {products.map(product => (
|
34
|
+
* <tr key={product.id}>
|
35
|
+
* <td>{product.name}</td>
|
36
|
+
* <td>{product.price}</td>
|
37
|
+
* <td>{product.stock}</td>
|
38
|
+
* </tr>
|
39
|
+
* ))}
|
40
|
+
* </TableBody>
|
41
|
+
*
|
42
|
+
* // Complete table usage
|
43
|
+
* <TableContainer>
|
44
|
+
* <TableHeader>
|
45
|
+
* <th>Name</th>
|
46
|
+
* <th>Status</th>
|
47
|
+
* <th>Actions</th>
|
48
|
+
* </TableHeader>
|
49
|
+
* <TableBody emptyMessage="No data to display">
|
50
|
+
* {data.map(item => (
|
51
|
+
* <tr key={item.id}>
|
52
|
+
* <td>{item.name}</td>
|
53
|
+
* <td>{item.status}</td>
|
54
|
+
* <td>
|
55
|
+
* <Button>Edit</Button>
|
56
|
+
* </td>
|
57
|
+
* </tr>
|
58
|
+
* ))}
|
59
|
+
* </TableBody>
|
60
|
+
* </TableContainer>
|
61
|
+
* ```
|
62
|
+
*/
|
63
|
+
function TableBody(props) {
|
64
|
+
const { emptyMessage = "Nenhum dado adicionado.", className: baseClassName, children, ...rest } = props;
|
65
|
+
const className = `arkynTableBody ${baseClassName}`;
|
66
|
+
const isEmpty = Children.count(children) === 0;
|
67
|
+
return (_jsx("tbody", { className: className.trim(), ...rest, children: isEmpty ? (_jsx("tr", { className: "arkynTableBodyEmptyLine", children: _jsx("td", { colSpan: 100, children: _jsx("div", { children: emptyMessage }) }) })) : (children) }));
|
68
|
+
}
|
69
|
+
export { TableBody };
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { HTMLAttributes } from "react";
|
2
|
+
import "./styles.css";
|
3
|
+
type TableCaptionProps = HTMLAttributes<HTMLElement>;
|
4
|
+
/**
|
5
|
+
* TableCaption component - used to provide a title or description for a table with proper styling
|
6
|
+
*
|
7
|
+
* @param props - TableCaption component properties
|
8
|
+
*
|
9
|
+
* **...All valid HTML properties for caption element**
|
10
|
+
*
|
11
|
+
* @returns TableCaption JSX element
|
12
|
+
*
|
13
|
+
* @example
|
14
|
+
* ```tsx
|
15
|
+
* // Basic table caption
|
16
|
+
* <TableContainer>
|
17
|
+
* <TableCaption>
|
18
|
+
* User Management
|
19
|
+
* </TableCaption>
|
20
|
+
* <TableHeader>
|
21
|
+
* <th>Name</th>
|
22
|
+
* <th>Email</th>
|
23
|
+
* </TableHeader>
|
24
|
+
* <TableBody>
|
25
|
+
* // table rows...
|
26
|
+
* </TableBody>
|
27
|
+
* </TableContainer>
|
28
|
+
*
|
29
|
+
* // Table caption with custom styling
|
30
|
+
* <TableContainer>
|
31
|
+
* <TableCaption className="highlighted-caption">
|
32
|
+
* Sales Report - Q4 2024
|
33
|
+
* </TableCaption>
|
34
|
+
* <TableHeader>
|
35
|
+
* <th>Product</th>
|
36
|
+
* <th>Revenue</th>
|
37
|
+
* </TableHeader>
|
38
|
+
* <TableBody>
|
39
|
+
* // table rows...
|
40
|
+
* </TableBody>
|
41
|
+
* </TableContainer>
|
42
|
+
*
|
43
|
+
* // Caption with rich content
|
44
|
+
* <TableContainer>
|
45
|
+
* <TableCaption>
|
46
|
+
* <h3>Employee Directory</h3>
|
47
|
+
* <p>Updated: {new Date().toLocaleDateString()}</p>
|
48
|
+
* </TableCaption>
|
49
|
+
* <TableHeader>
|
50
|
+
* <th>Employee ID</th>
|
51
|
+
* <th>Name</th>
|
52
|
+
* <th>Department</th>
|
53
|
+
* </TableHeader>
|
54
|
+
* <TableBody>
|
55
|
+
* // table rows...
|
56
|
+
* </TableBody>
|
57
|
+
* </TableContainer>
|
58
|
+
* ```
|
59
|
+
*/
|
60
|
+
declare function TableCaption(props: TableCaptionProps): import("react/jsx-runtime").JSX.Element;
|
61
|
+
export { TableCaption };
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/tableCaption/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,cAAc,CAAC;AAEtB,KAAK,iBAAiB,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CAS7C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import "./styles.css";
|
3
|
+
/**
|
4
|
+
* TableCaption component - used to provide a title or description for a table with proper styling
|
5
|
+
*
|
6
|
+
* @param props - TableCaption component properties
|
7
|
+
*
|
8
|
+
* **...All valid HTML properties for caption element**
|
9
|
+
*
|
10
|
+
* @returns TableCaption JSX element
|
11
|
+
*
|
12
|
+
* @example
|
13
|
+
* ```tsx
|
14
|
+
* // Basic table caption
|
15
|
+
* <TableContainer>
|
16
|
+
* <TableCaption>
|
17
|
+
* User Management
|
18
|
+
* </TableCaption>
|
19
|
+
* <TableHeader>
|
20
|
+
* <th>Name</th>
|
21
|
+
* <th>Email</th>
|
22
|
+
* </TableHeader>
|
23
|
+
* <TableBody>
|
24
|
+
* // table rows...
|
25
|
+
* </TableBody>
|
26
|
+
* </TableContainer>
|
27
|
+
*
|
28
|
+
* // Table caption with custom styling
|
29
|
+
* <TableContainer>
|
30
|
+
* <TableCaption className="highlighted-caption">
|
31
|
+
* Sales Report - Q4 2024
|
32
|
+
* </TableCaption>
|
33
|
+
* <TableHeader>
|
34
|
+
* <th>Product</th>
|
35
|
+
* <th>Revenue</th>
|
36
|
+
* </TableHeader>
|
37
|
+
* <TableBody>
|
38
|
+
* // table rows...
|
39
|
+
* </TableBody>
|
40
|
+
* </TableContainer>
|
41
|
+
*
|
42
|
+
* // Caption with rich content
|
43
|
+
* <TableContainer>
|
44
|
+
* <TableCaption>
|
45
|
+
* <h3>Employee Directory</h3>
|
46
|
+
* <p>Updated: {new Date().toLocaleDateString()}</p>
|
47
|
+
* </TableCaption>
|
48
|
+
* <TableHeader>
|
49
|
+
* <th>Employee ID</th>
|
50
|
+
* <th>Name</th>
|
51
|
+
* <th>Department</th>
|
52
|
+
* </TableHeader>
|
53
|
+
* <TableBody>
|
54
|
+
* // table rows...
|
55
|
+
* </TableBody>
|
56
|
+
* </TableContainer>
|
57
|
+
* ```
|
58
|
+
*/
|
59
|
+
function TableCaption(props) {
|
60
|
+
const { className: baseClassName, children, ...rest } = props;
|
61
|
+
const className = `arkynTableCaption ${baseClassName}`;
|
62
|
+
return (_jsx("caption", { className: className.trim(), ...rest, children: _jsx("div", { className: "arkynTableCaptionContent", children: children }) }));
|
63
|
+
}
|
64
|
+
export { TableCaption };
|