@pnkx-lib/ui 1.9.314 → 1.9.316

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.
Files changed (36) hide show
  1. package/dist/style.css +1 -1
  2. package/es/fields/CascaderField.js +9 -1
  3. package/es/fields/DatePicker.js +9 -1
  4. package/es/fields/DateRangePicker.js +9 -1
  5. package/es/fields/Input.js +62 -4
  6. package/es/fields/Select.js +9 -1
  7. package/es/fields/SliderRanger.js +17 -2
  8. package/es/fields/SliderSingle.js +9 -1
  9. package/es/fields/Switch.js +9 -1
  10. package/es/fields/Textarea.js +9 -1
  11. package/es/fields/TimePicker.js +9 -1
  12. package/es/fields/TimeRangePicker.js +9 -1
  13. package/es/fields/TinyMCE.js +9 -1
  14. package/es/fields/Upload.js +9 -1
  15. package/es/ui/ImportFile.js +60 -4
  16. package/es/ui/Label.js +3 -2
  17. package/es/ui/Sidebar.js +421 -223
  18. package/es/ui/UploadComponent.js +3 -37
  19. package/es/ui/UploadMultiple.js +1 -1
  20. package/package.json +1 -1
  21. package/types/components/fields/CascaderField.d.ts +1 -0
  22. package/types/components/fields/DatePicker.d.ts +1 -0
  23. package/types/components/fields/DateRangePicker.d.ts +1 -0
  24. package/types/components/fields/Input.d.ts +3 -2
  25. package/types/components/fields/Select.d.ts +1 -0
  26. package/types/components/fields/SliderRanger.d.ts +1 -0
  27. package/types/components/fields/SliderSingle.d.ts +1 -0
  28. package/types/components/fields/Switch.d.ts +1 -0
  29. package/types/components/fields/Textarea.d.ts +1 -0
  30. package/types/components/fields/TimePicker.d.ts +1 -0
  31. package/types/components/fields/TimeRangePicker.d.ts +1 -0
  32. package/types/components/fields/TinyMCE.d.ts +1 -0
  33. package/types/components/fields/Upload.d.ts +1 -0
  34. package/types/components/ui/ImportFile.d.ts +2 -7
  35. package/types/components/ui/Label.d.ts +2 -1
  36. package/types/components/ui/UploadComponent.d.ts +3 -1
@@ -1,6 +1,6 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { useState } from 'react';
3
- import { Upload, Image, Tooltip, message } from 'antd';
3
+ import { Upload, Image, Tooltip } from 'antd';
4
4
  import { Spin } from './Spin.js';
5
5
  import { Label } from './Label.js';
6
6
  import { t as twMerge } from '../chunks/bundle-mjs-BME7zF0Z.js';
@@ -18,53 +18,19 @@ const UploadComponent = ({
18
18
  styleImageDefault,
19
19
  imageValue,
20
20
  errorMessage,
21
+ loading,
21
22
  ...restProps
22
23
  }) => {
23
24
  const [imageUrl, setImageUrl] = useState(imageValue);
24
- const [loading, setLoading] = useState(false);
25
- const handleUpload = async (options) => {
26
- const { file } = options;
27
- const formData = new FormData();
28
- formData.append("file", file);
29
- formData.append("upload_preset", "ml_default");
30
- setLoading(true);
31
- try {
32
- const res = await fetch(
33
- "https://api.cloudinary.com/v1_1/dhtrzmzd3/image/upload",
34
- {
35
- method: "POST",
36
- body: formData
37
- }
38
- );
39
- const response = await res.json();
40
- const uploadedUrl = response?.secure_url;
41
- setImageUrl(uploadedUrl);
42
- if (onUploadSuccess) {
43
- onUploadSuccess(uploadedUrl);
44
- message.success("Tải ảnh lên thành công");
45
- }
46
- } catch (err) {
47
- console.error(err);
48
- message.error("Tải ảnh lên thất bại");
49
- } finally {
50
- setLoading(false);
51
- }
52
- };
53
25
  const handleRemoveImage = () => {
54
26
  setImageUrl("");
55
27
  if (onUploadSuccess) {
56
28
  onUploadSuccess("");
57
29
  }
58
30
  };
59
- const props = {
60
- name: "file",
61
- multiple: false,
62
- customRequest: handleUpload,
63
- showUploadList: false
64
- };
65
31
  return /* @__PURE__ */ jsxs("div", { className: customStyleContainer, children: [
66
32
  label && /* @__PURE__ */ jsx(Label, { label, required }),
67
- /* @__PURE__ */ jsx(Dragger, { ...props, ...restProps, children: /* @__PURE__ */ jsx("div", { children: loading ? /* @__PURE__ */ jsx(Spin, {}) : imageUrl ? /* @__PURE__ */ jsx("div", { className: customStyleUpload, children: /* @__PURE__ */ jsxs(
33
+ /* @__PURE__ */ jsx(Dragger, { ...restProps, children: /* @__PURE__ */ jsx("div", { children: loading ? /* @__PURE__ */ jsx(Spin, {}) : imageUrl ? /* @__PURE__ */ jsx("div", { className: customStyleUpload, children: /* @__PURE__ */ jsxs(
68
34
  "div",
69
35
  {
70
36
  onClick: (e) => e.stopPropagation(),
@@ -62,7 +62,7 @@ const UploadMultiple = ({
62
62
  render: ({ field }) => {
63
63
  const { value, onChange } = field;
64
64
  const props = createUploadProps(value || [], onChange);
65
- return /* @__PURE__ */ jsx(Spin, { spinning: isLoading, tip: "Đang tải", children: /* @__PURE__ */ jsxs(Dragger, { ...props, children: [
65
+ return /* @__PURE__ */ jsx(Spin, { spinning: isLoading, tip: "Đang tải", children: /* @__PURE__ */ jsxs(Dragger, { ...props, accept: "image/*", children: [
66
66
  /* @__PURE__ */ jsx("p", { className: "ant-upload-drag-icon", children: /* @__PURE__ */ jsx(RefIcon, {}) }),
67
67
  /* @__PURE__ */ jsx("p", { className: "ant-upload-text", children: title }),
68
68
  /* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: content })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pnkx-lib/ui",
3
3
  "private": false,
4
- "version": "1.9.314",
4
+ "version": "1.9.316",
5
5
  "type": "module",
6
6
  "main": "./es/index.js",
7
7
  "module": "./es/index.js",
@@ -9,6 +9,7 @@ interface CascaderFieldProps extends CascaderPropsAntd {
9
9
  afterOnChange?: (value: any) => void;
10
10
  classNameContainer?: string;
11
11
  classNameCascader?: string;
12
+ classNameLabel?: string;
12
13
  }
13
14
  export declare const Cascader: (props: CascaderFieldProps) => import("react/jsx-runtime").JSX.Element;
14
15
  export {};
@@ -17,5 +17,6 @@ export interface DatePickerProps extends Omit<ReactDatePickerProps, "onChange">
17
17
  customOnChange?: (date: any, event: React.SyntheticEvent<any>) => void;
18
18
  customValue?: Date | null;
19
19
  size?: TSize;
20
+ classNameLabel?: string;
20
21
  }
21
22
  export declare const DatePicker: (props: DatePickerProps) => import("react/jsx-runtime").JSX.Element;
@@ -9,5 +9,6 @@ export interface RangePickerFieldProps extends Omit<RangePickerProps, "value" |
9
9
  afterOnChange?: (dates: [Dayjs | null, Dayjs | null] | null, dateStrings: [string, string]) => void;
10
10
  customStyleContainer?: string;
11
11
  customStyleDatePicker?: string;
12
+ classNameLabel?: string;
12
13
  }
13
14
  export declare const RangePicker: (props: RangePickerFieldProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,8 @@
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";
5
- type TInputNumberType = "number" | "money";
4
+ type CustomInputTypeAttribute = React.HTMLInputTypeAttribute | "money" | "number_custom";
5
+ type TInputNumberType = "number" | "money" | "number_custom";
6
6
  export interface InputProps extends InputPropsAntd {
7
7
  field?: ControllerRenderProps<any, any>;
8
8
  formState?: UseFormStateReturn<any>;
@@ -18,6 +18,7 @@ export interface InputProps extends InputPropsAntd {
18
18
  suffix?: string;
19
19
  contentTooltip?: string;
20
20
  toLowerCaseValue?: boolean;
21
+ classNameLabel?: string;
21
22
  }
22
23
  export declare const Input: (props: InputProps) => import("react/jsx-runtime").JSX.Element;
23
24
  export interface PropsNumberFormat extends Omit<InputProps, "onChange" | "afterOnChange" | "value" | "defaultValue" | "iconStartInput" | "iconEndInput"> {
@@ -12,5 +12,6 @@ export interface SelectFieldProps extends SelectProps {
12
12
  maxTagTextLength?: number | undefined;
13
13
  maxTagCount?: number | "responsive";
14
14
  onClear?: () => void;
15
+ classNameLabel?: string;
15
16
  }
16
17
  export declare const Select: (props: SelectFieldProps) => import("react/jsx-runtime").JSX.Element;
@@ -11,5 +11,6 @@ export interface SliderRangesProps extends Omit<SliderRangeProps, "onChange"> {
11
11
  hiddenInputRange?: boolean;
12
12
  max?: number;
13
13
  min?: number;
14
+ classNameLabel?: string;
14
15
  }
15
16
  export declare const SliderRange: (props: SliderRangesProps) => import("react/jsx-runtime").JSX.Element;
@@ -8,5 +8,6 @@ export interface SliderProps extends Omit<SliderSingleAntdProps, "onChange"> {
8
8
  afterOnChange?: (data: number) => void;
9
9
  customStyleContainer?: string;
10
10
  customStyleSlider?: string;
11
+ classNameLabel?: string;
11
12
  }
12
13
  export declare const SliderSingle: (props: SliderProps) => import("react/jsx-runtime").JSX.Element;
@@ -8,5 +8,6 @@ export interface SwitchProps extends Omit<SwitchAntdProps, "onChange"> {
8
8
  afterOnChange?: (checked: boolean) => void;
9
9
  customStyleContainer?: string;
10
10
  customStyleSwitch?: string;
11
+ classNameLabel?: string;
11
12
  }
12
13
  export declare const Switch: (props: SwitchProps) => import("react/jsx-runtime").JSX.Element;
@@ -7,5 +7,6 @@ export interface TextAreaProps extends TextAreaPropsAntd {
7
7
  customStyleTextarea?: string;
8
8
  afterOnChange?: (value: string) => void;
9
9
  required?: boolean;
10
+ classNameLabel?: string;
10
11
  }
11
12
  export declare const Textarea: import('react').ForwardRefExoticComponent<TextAreaProps & import('react').RefAttributes<HTMLTextAreaElement>>;
@@ -7,6 +7,7 @@ interface TimeRangePickerProps extends Omit<TimePickerProps, "value" | "onChange
7
7
  field?: ControllerRenderProps<any, any>;
8
8
  formState?: UseFormStateReturn<any>;
9
9
  label?: string;
10
+ classNameLabel?: string;
10
11
  }
11
12
  export declare const TimePicker: React.FC<TimeRangePickerProps>;
12
13
  export {};
@@ -7,6 +7,7 @@ interface TimeRangePickerProps extends AntdTimeRangePickerProps {
7
7
  field?: ControllerRenderProps<any, any>;
8
8
  formState?: UseFormStateReturn<any>;
9
9
  label?: string;
10
+ classNameLabel?: string;
10
11
  }
11
12
  export declare const TimeRangePicker: React.FC<TimeRangePickerProps>;
12
13
  export {};
@@ -9,6 +9,7 @@ export interface TinyProps extends IAllProps {
9
9
  label?: string;
10
10
  customStyleLabel?: string;
11
11
  text_patterns?: any;
12
+ classNameLabel?: string;
12
13
  }
13
14
  export declare const TinyMCE: {
14
15
  (props: TinyProps): import("react/jsx-runtime").JSX.Element;
@@ -11,5 +11,6 @@ export interface UploadFieldProps extends Omit<UploadProps, "value" | "onChange"
11
11
  customStyleContainer?: string;
12
12
  customStyleUpload?: string;
13
13
  afterOnChange?: (fileList: UploadFile[]) => void;
14
+ classNameLabel?: string;
14
15
  }
15
16
  export declare const UploadField: (props: UploadFieldProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,6 @@
1
1
  import { UploadProps } from 'antd';
2
- type UploadStatus = {
3
- type: "success" | "error" | "";
4
- message: string;
5
- };
6
2
  interface ImportFileProps extends UploadProps {
7
- loading: boolean;
8
- status: UploadStatus;
3
+ onUploadSuccess: any;
9
4
  }
10
- export declare const ImportFile: ({ loading, status, ...rest }: ImportFileProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const ImportFile: ({ onUploadSuccess, ...rest }: ImportFileProps) => import("react/jsx-runtime").JSX.Element;
11
6
  export {};
@@ -1,5 +1,6 @@
1
1
  export interface LabelProps {
2
2
  label: string;
3
3
  required?: boolean;
4
+ classNameLabel?: string;
4
5
  }
5
- export declare const Label: ({ label, required }: LabelProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const Label: ({ label, required, classNameLabel }: LabelProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { default as React } from 'react';
2
- interface UploadImageProps {
2
+ import { UploadProps } from 'antd';
3
+ interface UploadImageProps extends UploadProps {
3
4
  onUploadSuccess?: (url: string) => void;
4
5
  customStyleContainer?: string;
5
6
  customStyleUpload?: string;
@@ -8,6 +9,7 @@ interface UploadImageProps {
8
9
  styleImageDefault?: string;
9
10
  imageValue?: string;
10
11
  errorMessage?: string;
12
+ loading?: boolean;
11
13
  }
12
14
  export declare const UploadComponent: React.FC<UploadImageProps>;
13
15
  export {};