@pnkx-lib/ui 1.9.355 → 1.9.357
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/es/fields/Input.js +4 -1
- package/es/ui/UploadComponent.js +5 -1
- package/es/ui/UploadMultiple.js +9 -65
- package/package.json +1 -1
- package/types/components/fields/Input.d.ts +2 -1
- package/types/components/ui/Table/index.d.ts +1 -1
- package/types/components/ui/UploadComponent.d.ts +1 -0
- package/types/components/ui/UploadMultiple.d.ts +2 -1
package/es/fields/Input.js
CHANGED
|
@@ -1244,12 +1244,14 @@ const Input = (props) => {
|
|
|
1244
1244
|
contentTooltip,
|
|
1245
1245
|
toLowerCaseValue,
|
|
1246
1246
|
classNameLabel,
|
|
1247
|
+
inputPassword,
|
|
1247
1248
|
...restProps
|
|
1248
1249
|
} = props;
|
|
1249
1250
|
const { name, value, onChange, onBlur } = field || {};
|
|
1250
1251
|
const { touchedFields, errors, isSubmitted } = formState || {};
|
|
1251
1252
|
const isTouched = get(touchedFields, name);
|
|
1252
1253
|
const errorMessage = get(errors, name)?.message;
|
|
1254
|
+
useState(false);
|
|
1253
1255
|
const inputRef = useRef(null);
|
|
1254
1256
|
const [isComposing, setIsComposing] = useState(false);
|
|
1255
1257
|
const capitalizeAfterPeriod = (text) => {
|
|
@@ -1385,9 +1387,10 @@ const Input = (props) => {
|
|
|
1385
1387
|
}
|
|
1386
1388
|
);
|
|
1387
1389
|
}
|
|
1390
|
+
const InputComponent = inputPassword ? Input$1.Password : Input$1;
|
|
1388
1391
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1389
1392
|
/* @__PURE__ */ jsx(
|
|
1390
|
-
|
|
1393
|
+
InputComponent,
|
|
1391
1394
|
{
|
|
1392
1395
|
ref: inputRef,
|
|
1393
1396
|
onCompositionStart: handleCompositionStart,
|
package/es/ui/UploadComponent.js
CHANGED
|
@@ -21,6 +21,7 @@ const UploadComponent = ({
|
|
|
21
21
|
description = "Ảnh có kích thước 400x400 px và dung lượng ảnh < 1 mb",
|
|
22
22
|
customRequest,
|
|
23
23
|
setImageUpload,
|
|
24
|
+
clickIconRemove,
|
|
24
25
|
...restProps
|
|
25
26
|
}) => {
|
|
26
27
|
const imageUrl = typeof field?.value === "string" ? field.value : field?.value instanceof File ? URL.createObjectURL(field.value) : null;
|
|
@@ -65,7 +66,10 @@ const UploadComponent = ({
|
|
|
65
66
|
"button",
|
|
66
67
|
{
|
|
67
68
|
type: "button",
|
|
68
|
-
onClick:
|
|
69
|
+
onClick: () => {
|
|
70
|
+
handleRemoveImage();
|
|
71
|
+
clickIconRemove?.();
|
|
72
|
+
},
|
|
69
73
|
className: "absolute top-1 right-1 w-6 h-6 flex items-center justify-center bg-white cursor-pointer bg-opacity-80 rounded-full hover:bg-opacity-100 transition",
|
|
70
74
|
children: /* @__PURE__ */ jsx(RefIcon, { className: "text-black text-[12px]" })
|
|
71
75
|
}
|
package/es/ui/UploadMultiple.js
CHANGED
|
@@ -1,75 +1,19 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
import { Spin, Upload, message } from 'antd';
|
|
4
|
-
import { C as Controller } from '../chunks/index.esm-o4O8pXMN.js';
|
|
2
|
+
import { Spin, Upload } from 'antd';
|
|
5
3
|
import { R as RefIcon } from '../chunks/InboxOutlined-DNCJCjk3.js';
|
|
6
4
|
|
|
7
5
|
const { Dragger } = Upload;
|
|
8
6
|
const UploadMultiple = ({
|
|
9
|
-
name,
|
|
10
|
-
control,
|
|
11
7
|
title,
|
|
12
|
-
content
|
|
8
|
+
content,
|
|
9
|
+
isLoading,
|
|
10
|
+
...props
|
|
13
11
|
}) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
fileList: value,
|
|
20
|
-
customRequest: async ({ file, onSuccess, onError }) => {
|
|
21
|
-
const formData = new FormData();
|
|
22
|
-
formData.append("file", file);
|
|
23
|
-
formData.append("upload_preset", "ml_default");
|
|
24
|
-
setIsLoading(true);
|
|
25
|
-
try {
|
|
26
|
-
const res = await fetch(
|
|
27
|
-
"https://api.cloudinary.com/v1_1/dhtrzmzd3/image/upload",
|
|
28
|
-
{
|
|
29
|
-
method: "POST",
|
|
30
|
-
body: formData
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
const data = await res.json();
|
|
34
|
-
const newFile = {
|
|
35
|
-
uid: data.asset_id || Date.now().toString(),
|
|
36
|
-
name: data.original_filename,
|
|
37
|
-
url: data.secure_url
|
|
38
|
-
};
|
|
39
|
-
onChange([...value || [], newFile]);
|
|
40
|
-
onSuccess?.(data, new XMLHttpRequest());
|
|
41
|
-
message.success("Tải ảnh lên thành công.");
|
|
42
|
-
} catch (err) {
|
|
43
|
-
onError?.(err);
|
|
44
|
-
message.error("Tải ảnh lên thất bại.");
|
|
45
|
-
} finally {
|
|
46
|
-
setIsLoading(false);
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
onPreview: (file) => {
|
|
50
|
-
window.open(file.url, "_blank");
|
|
51
|
-
},
|
|
52
|
-
onRemove: (file) => {
|
|
53
|
-
const newList = (value || []).filter((item) => item.uid !== file.uid);
|
|
54
|
-
onChange(newList);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
return /* @__PURE__ */ jsx(
|
|
58
|
-
Controller,
|
|
59
|
-
{
|
|
60
|
-
name,
|
|
61
|
-
control,
|
|
62
|
-
render: ({ field }) => {
|
|
63
|
-
const { value, onChange } = field;
|
|
64
|
-
const props = createUploadProps(value || [], onChange);
|
|
65
|
-
return /* @__PURE__ */ jsx(Spin, { spinning: isLoading, tip: "Đang tải", children: /* @__PURE__ */ jsxs(Dragger, { ...props, children: [
|
|
66
|
-
/* @__PURE__ */ jsx("p", { className: "ant-upload-drag-icon", children: /* @__PURE__ */ jsx(RefIcon, {}) }),
|
|
67
|
-
/* @__PURE__ */ jsx("p", { className: "ant-upload-text", children: title }),
|
|
68
|
-
/* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: content })
|
|
69
|
-
] }) });
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
);
|
|
12
|
+
return /* @__PURE__ */ jsx(Spin, { spinning: isLoading, tip: "Đang tải", children: /* @__PURE__ */ jsxs(Dragger, { ...props, children: [
|
|
13
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-drag-icon", children: /* @__PURE__ */ jsx(RefIcon, {}) }),
|
|
14
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-text", children: title }),
|
|
15
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: content })
|
|
16
|
+
] }) });
|
|
73
17
|
};
|
|
74
18
|
|
|
75
19
|
export { UploadMultiple };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React, JSX } from 'react';
|
|
2
2
|
import { InputProps as InputPropsAntd } from 'antd';
|
|
3
3
|
import { ControllerRenderProps, UseFormStateReturn } from 'react-hook-form';
|
|
4
|
-
type CustomInputTypeAttribute = React.HTMLInputTypeAttribute | "money" | "number_custom";
|
|
4
|
+
type CustomInputTypeAttribute = React.HTMLInputTypeAttribute | "money" | "number_custom" | "password";
|
|
5
5
|
type TInputNumberType = "number" | "money" | "number_custom";
|
|
6
6
|
export interface InputProps extends InputPropsAntd {
|
|
7
7
|
field?: ControllerRenderProps<any, any>;
|
|
@@ -19,6 +19,7 @@ export interface InputProps extends InputPropsAntd {
|
|
|
19
19
|
contentTooltip?: string;
|
|
20
20
|
toLowerCaseValue?: boolean;
|
|
21
21
|
classNameLabel?: string;
|
|
22
|
+
inputPassword?: boolean;
|
|
22
23
|
}
|
|
23
24
|
export declare const Input: (props: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
25
|
export interface PropsNumberFormat extends Omit<InputProps, "onChange" | "afterOnChange" | "value" | "defaultValue" | "iconStartInput" | "iconEndInput"> {
|
|
@@ -25,7 +25,7 @@ export interface TableCommonProps<T> extends Omit<TableProps<T>, "columns"> {
|
|
|
25
25
|
rowsSelected?: React.Key[];
|
|
26
26
|
onSelect: (newSelectedRowKeys: React.Key[]) => void;
|
|
27
27
|
onRowClick?: (record: T) => void;
|
|
28
|
-
rowKey
|
|
28
|
+
rowKey: string;
|
|
29
29
|
onDoubleClickRow?: (record: T) => void;
|
|
30
30
|
showIndexColumn?: boolean;
|
|
31
31
|
size?: SizeType;
|
|
@@ -12,6 +12,7 @@ interface UploadImageProps extends UploadProps {
|
|
|
12
12
|
setImageUpload?: (value: string) => void;
|
|
13
13
|
content?: string;
|
|
14
14
|
description?: string;
|
|
15
|
+
clickIconRemove?: () => void;
|
|
15
16
|
}
|
|
16
17
|
export declare const UploadComponent: React.FC<UploadImageProps & {
|
|
17
18
|
field: any;
|
|
@@ -4,5 +4,6 @@ export interface UploadMultipleProps {
|
|
|
4
4
|
control: Control | any;
|
|
5
5
|
title?: string;
|
|
6
6
|
content?: string;
|
|
7
|
+
isLoading?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare const UploadMultiple: ({
|
|
9
|
+
export declare const UploadMultiple: ({ title, content, isLoading, ...props }: UploadMultipleProps) => import("react/jsx-runtime").JSX.Element;
|