@oneplatformdev/ui 0.0.1-beta.13 → 0.0.1-beta.17

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.
@@ -12,7 +12,7 @@ import { DropzoneProps } from './Dropzone.types';
12
12
  * @param {(errors: FileRejection[]) => void} [props.onErrors] - Callback triggered when file errors occur.
13
13
  * @param {boolean} [props.hideErrors=false] - Whether to hide error messages.
14
14
  * @param {boolean} [props.disabled=false] - Whether the dropzone is disabled.
15
- * @param {DropzoneStyles} [props.styles] - Custom styles for different dropzone states.
15
+ * @param {DropzoneStyles} [props.classNames] - Custom classNames for different dropzone states.
16
16
  * @param {DropzoneValueItem[]} [props.value=[]] - Current selected files or URLs.
17
17
  * @param {(items: DropzoneValueItem[]) => void} [props.onChangeValue] - Callback triggered when file selection changes.
18
18
  * @param {string} [props.className] - Additional class names for styling.
@@ -1,122 +1,136 @@
1
- import { jsxs as i, jsx as d, Fragment as L } from "react/jsx-runtime";
2
- import { forwardRef as _, useState as w, useEffect as A } from "react";
3
- import { useDropzone as B } from "react-dropzone";
4
- import { Card as M } from "../Card/Card.mjs";
5
- import { File as j, X as H } from "lucide-react";
6
- import { cn as h } from "@oneplatformdev/utils";
7
- import { F as U, D as X } from "../FilePreview-Dhtv8F4u.js";
8
- import { isFile as F, extractName as Y } from "./DropzoneUtils.mjs";
9
- const q = _(
1
+ import { jsxs as t, jsx as o } from "react/jsx-runtime";
2
+ import { forwardRef as L, useState as g } from "react";
3
+ import { useDropzone as M } from "react-dropzone";
4
+ import { Card as U } from "../Card/Card.mjs";
5
+ import { File as j, X as O } from "lucide-react";
6
+ import { cn as m } from "@oneplatformdev/utils";
7
+ import { F as X, D as Y } from "../DropzoneFilePreview-Dhtv8F4u.js";
8
+ import { isFile as v, extractName as q } from "./DropzoneUtils.mjs";
9
+ const G = L(
10
10
  ({
11
- acceptTypes: u = X,
12
- maxSizeMB: b,
11
+ acceptTypes: y = Y,
12
+ maxSizeMB: w,
13
13
  maxFiles: a = 1,
14
- translations: e,
15
- onErrors: v,
16
- hideErrors: z = !1,
17
- disabled: t = !1,
18
- styles: p,
19
- value: s = [],
20
- onChangeValue: l,
21
- className: D,
14
+ onErrors: x,
15
+ hideErrors: b = !1,
16
+ disabled: p = !1,
17
+ classNames: l,
18
+ value: u = [],
19
+ onChangeValue: s,
20
+ className: F,
21
+ labelDropzonePrompt: z = "Drop files here or click to select",
22
+ labelOrClickToSelect: H = "Click to select files",
23
+ labelSelectedFiles: D = "Selected Files",
24
+ labelUploadErrors: I = "Upload Errors",
25
+ labelFileTooLarge: k = "File is too large",
26
+ labelInvalidFileType: S = "Invalid file type",
22
27
  ...E
23
- }, I) => {
24
- const [o, g] = w(s), [x, P] = w([]);
25
- A(() => {
26
- g(s);
27
- }, [s]);
28
- const S = (r, m) => {
29
- P(m), v && v(m);
30
- const c = [...o, ...r].slice(0, a);
31
- g(c), l == null || l(c);
32
- }, T = (r, m) => {
33
- if (t) return;
34
- r.stopPropagation();
35
- const c = o.filter((f, N) => N !== m);
36
- g(c), l == null || l(c);
37
- }, { getRootProps: k, getInputProps: n, isDragActive: W } = B({
38
- onDrop: S,
39
- accept: u.reduce((r, m) => (r[m] = [], r), {}),
40
- maxSize: b * 1024 * 1024,
28
+ }, P) => {
29
+ const [c, h] = g(u), [d, N] = g([]), W = (e, i) => {
30
+ N(i), x && x(i);
31
+ const r = [...c, ...e].slice(0, a);
32
+ h(r), s == null || s(r);
33
+ }, T = (e, i) => {
34
+ if (p) return;
35
+ e.stopPropagation();
36
+ const r = c.filter((n, f) => f !== i);
37
+ h(r), s == null || s(r);
38
+ }, { getRootProps: _, getInputProps: A, isDragActive: B } = M({
39
+ onDrop: W,
40
+ accept: y.reduce((e, i) => (e[i] = [], e), {}),
41
+ maxSize: w * 1024 * 1024,
41
42
  maxFiles: a,
42
- disabled: t
43
+ disabled: p
43
44
  });
44
- return /* @__PURE__ */ i(
45
- M,
45
+ return /* @__PURE__ */ t(
46
+ U,
46
47
  {
47
- ...k(),
48
+ ..._(),
48
49
  ...E,
49
- className: h(
50
+ className: m(
50
51
  "border-dashed border-2 p-6 text-center flex flex-col items-center justify-center",
51
- t && "bg-gray-300 pointer-events-none",
52
- x.length > 0 ? "border-red-500" : "border-gray-300",
53
- W && "bg-gray-100",
54
- D
52
+ p && "bg-gray-300 pointer-events-none",
53
+ d.length > 0 ? "border-red-500" : "border-gray-300",
54
+ B && "bg-gray-100",
55
+ F
55
56
  ),
56
- ref: I,
57
+ ref: P,
57
58
  children: [
58
- /* @__PURE__ */ d("input", { ...n() }),
59
- o.length === 0 && x.length === 0 && /* @__PURE__ */ i("div", { className: h("flex flex-col items-center gap-1", p == null ? void 0 : p.idleWrapper), children: [
60
- /* @__PURE__ */ d(j, { className: "w-8 h-8 text-gray-500" }),
61
- !t && /* @__PURE__ */ i(L, { children: [
62
- /* @__PURE__ */ d("span", { className: "font-semibold text-gray-600", children: e == null ? void 0 : e.dropFileHere }),
63
- /* @__PURE__ */ d("span", { className: "text-sm text-gray-500", children: e == null ? void 0 : e.orClickToSelect })
64
- ] })
65
- ] }),
66
- o.length > 0 && /* @__PURE__ */ i("div", { className: h("w-full mt-2", p == null ? void 0 : p.previewWrapper), children: [
67
- /* @__PURE__ */ i("span", { className: "font-semibold text-gray-600", children: [
68
- e == null ? void 0 : e.selectedFiles,
59
+ /* @__PURE__ */ o("input", { ...A() }),
60
+ c.length === 0 && d.length === 0 && /* @__PURE__ */ t(
61
+ "div",
62
+ {
63
+ className: m(
64
+ "flex flex-col items-center gap-1",
65
+ l == null ? void 0 : l.idleWrapper
66
+ ),
67
+ children: [
68
+ /* @__PURE__ */ o(j, { className: "w-8 h-8 text-gray-500" }),
69
+ !p && /* @__PURE__ */ o("pre", { className: "font-semibold text-gray-600", children: z })
70
+ ]
71
+ }
72
+ ),
73
+ c.length > 0 && /* @__PURE__ */ t("div", { className: m("w-full mt-2", l == null ? void 0 : l.previewWrapper), children: [
74
+ /* @__PURE__ */ t("pre", { className: "font-semibold text-gray-600", children: [
75
+ D,
69
76
  ":"
70
77
  ] }),
71
- /* @__PURE__ */ d("ul", { className: "mt-2 text-sm text-gray-500 flex flex-wrap gap-4 items-start justify-center", children: o.map((r, m) => {
72
- const c = F(r) ? r.name : Y(r), f = F(r) ? (r.size / (1024 * 1024)).toFixed(2) + " MB" : "";
73
- return /* @__PURE__ */ i("li", { className: "flex flex-col items-center gap-2 relative", children: [
74
- /* @__PURE__ */ i("div", { className: "relative", children: [
75
- /* @__PURE__ */ d(U, { item: r, styles: p }),
76
- /* @__PURE__ */ d("div", { className: "absolute top-0 right-0 cursor-pointer bg-gray-300 rounded-sm", children: /* @__PURE__ */ d(
77
- H,
78
- {
79
- size: 16,
80
- strokeWidth: 1,
81
- color: "black",
82
- onClick: (N) => T(N, m)
83
- }
84
- ) })
85
- ] }),
86
- /* @__PURE__ */ i("span", { className: "inline-flex flex-col items-center", children: [
87
- /* @__PURE__ */ d("span", { className: "max-w-[80px] text-ellipsis overflow-hidden whitespace-nowrap", children: c }),
88
- f && /* @__PURE__ */ i("span", { children: [
89
- "(",
90
- f,
91
- ")"
92
- ] })
93
- ] })
94
- ] }, m);
78
+ /* @__PURE__ */ o("ul", { className: "mt-2 text-sm text-gray-500 flex flex-wrap gap-4 items-start justify-center", children: c.map((e, i) => {
79
+ const r = v(e) ? e.name : q(e), n = v(e) ? (e.size / (1024 * 1024)).toFixed(2) + " MB" : "";
80
+ return /* @__PURE__ */ t(
81
+ "li",
82
+ {
83
+ className: "flex flex-col items-center gap-2 relative",
84
+ children: [
85
+ /* @__PURE__ */ t("div", { className: "relative", children: [
86
+ /* @__PURE__ */ o(X, { item: e, styles: l }),
87
+ /* @__PURE__ */ o("div", { className: "absolute top-0 right-0 cursor-pointer bg-gray-300 rounded-sm", children: /* @__PURE__ */ o(
88
+ O,
89
+ {
90
+ size: 16,
91
+ strokeWidth: 1,
92
+ color: "black",
93
+ onClick: (f) => T(f, i)
94
+ }
95
+ ) })
96
+ ] }),
97
+ /* @__PURE__ */ t("span", { className: "inline-flex flex-col items-center", children: [
98
+ /* @__PURE__ */ o("span", { className: "max-w-[80px] text-ellipsis overflow-hidden whitespace-nowrap", children: r }),
99
+ n && /* @__PURE__ */ t("span", { children: [
100
+ "(",
101
+ n,
102
+ ")"
103
+ ] })
104
+ ] })
105
+ ]
106
+ },
107
+ i
108
+ );
95
109
  }) })
96
110
  ] }),
97
- x.length > 0 && /* @__PURE__ */ i("div", { className: h("w-full mt-4", p == null ? void 0 : p.errorWrapper), children: [
98
- /* @__PURE__ */ i("span", { className: "font-semibold text-red-500", children: [
99
- e == null ? void 0 : e.uploadErrors,
111
+ d.length > 0 && /* @__PURE__ */ t("div", { className: m("w-full mt-4", l == null ? void 0 : l.errorWrapper), children: [
112
+ /* @__PURE__ */ t("span", { className: "font-semibold text-red-500", children: [
113
+ I,
100
114
  ":"
101
115
  ] }),
102
- /* @__PURE__ */ d("ul", { className: "mt-2 text-sm text-red-500 list-disc list-inside", children: x.map((r, m) => /* @__PURE__ */ i("li", { children: [
103
- r.file.name,
116
+ /* @__PURE__ */ o("ul", { className: "mt-2 text-sm text-red-500 list-disc list-inside", children: d.map((e, i) => /* @__PURE__ */ t("li", { children: [
117
+ e.file.name,
104
118
  " (",
105
- (r.file.size / (1024 * 1024)).toFixed(2),
119
+ (e.file.size / (1024 * 1024)).toFixed(2),
106
120
  " MB)",
107
- !z && /* @__PURE__ */ d("ul", { className: "ml-4 list-disc list-inside", children: r.errors.map((c, f) => /* @__PURE__ */ i("li", { children: [
108
- c.code === "file-too-large" && (e == null ? void 0 : e.fileTooLarge),
109
- c.code === "file-invalid-type" && (e == null ? void 0 : e.invalidFileType),
110
- c.code !== "file-too-large" && c.code !== "file-invalid-type" && c.message
111
- ] }, f)) })
112
- ] }, m)) })
121
+ !b && /* @__PURE__ */ o("ul", { className: "ml-4 list-disc list-inside", children: e.errors.map((r, n) => /* @__PURE__ */ t("li", { children: [
122
+ r.code === "file-too-large" && k,
123
+ r.code === "file-invalid-type" && S,
124
+ r.code !== "file-too-large" && r.code !== "file-invalid-type" && r.message
125
+ ] }, n)) })
126
+ ] }, i)) })
113
127
  ] })
114
128
  ]
115
129
  }
116
130
  );
117
131
  }
118
132
  );
119
- q.displayName = "Dropzone";
133
+ G.displayName = "Dropzone";
120
134
  export {
121
- q as Dropzone
135
+ G as Dropzone
122
136
  };
@@ -6,22 +6,21 @@ export interface FilePreviewProps {
6
6
  styles?: Pick<DropzoneStyles, 'previewWraper' | 'previewImage' | 'previewFile'>;
7
7
  }
8
8
  export interface DropzoneTranslations {
9
- dropFileHere: string;
10
- orClickToSelect: string;
11
- selectedFiles: string;
12
- uploadErrors: string;
13
- fileTooLarge: string;
14
- invalidFileType: string;
9
+ labelDropzonePrompt?: string;
10
+ labelOrClickToSelect?: string;
11
+ labelSelectedFiles?: string;
12
+ labelUploadErrors?: string;
13
+ labelFileTooLarge?: string;
14
+ labelInvalidFileType?: string;
15
15
  }
16
- export interface DropzoneProps extends React.HTMLAttributes<HTMLDivElement> {
16
+ export interface DropzoneProps extends DropzoneTranslations, React.HTMLAttributes<HTMLDivElement> {
17
17
  acceptTypes?: string[];
18
18
  maxSizeMB: number;
19
- translations: DropzoneTranslations;
20
19
  maxFiles?: number;
21
20
  onErrors?: (errors: FileRejection[]) => void;
22
21
  hideErrors?: boolean;
23
22
  disabled?: boolean;
24
- styles?: DropzoneStyles;
23
+ classNames?: DropzoneStyles;
25
24
  value?: DropzoneValueItem[];
26
25
  onChangeValue?: (items: DropzoneValueItem[]) => void;
27
26
  }
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "lucide-react";
4
- import { F } from "../FilePreview-Dhtv8F4u.js";
4
+ import { F } from "../DropzoneFilePreview-Dhtv8F4u.js";
5
5
  import "./DropzoneUtils.mjs";
6
6
  import "@oneplatformdev/utils";
7
7
  export {
@@ -1,5 +1,5 @@
1
1
  import { Dropzone as r } from "./Dropzone.mjs";
2
- import { D as T, a as _ } from "../FilePreview-Dhtv8F4u.js";
2
+ import { D as T, a as _ } from "../DropzoneFilePreview-Dhtv8F4u.js";
3
3
  export {
4
4
  T as DEFAULT_FILE_TYPES,
5
5
  _ as DEFAULT_IMAGES_TYPES,
@@ -0,0 +1,4 @@
1
+ import { FormDropzoneProps } from './FormDropzone.types';
2
+ import { FieldValues, UseFormReturn } from 'react-hook-form';
3
+
4
+ export declare const FormDropzone: <Data extends FieldValues, Form extends UseFormReturn<Data>>(props: FormDropzoneProps<Data, Form>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { FormControl as a } from "../Form/Form.mjs";
3
+ import { FormRenderControl as l } from "../Form/FormRenderControl.mjs";
4
+ import { Dropzone as f } from "../Dropzone/Dropzone.mjs";
5
+ const h = (n) => {
6
+ const { form: e, label: m, name: t, ...p } = n;
7
+ return /* @__PURE__ */ o(
8
+ l,
9
+ {
10
+ form: e,
11
+ label: m,
12
+ name: t,
13
+ render: ({ field: r }) => /* @__PURE__ */ o(a, { children: /* @__PURE__ */ o(
14
+ f,
15
+ {
16
+ ...p,
17
+ ...r,
18
+ onChangeValue: r.onChange
19
+ }
20
+ ) })
21
+ }
22
+ );
23
+ };
24
+ export {
25
+ h as FormDropzone
26
+ };
@@ -0,0 +1,7 @@
1
+ import { FormRenderControlExtendProps } from '../Form';
2
+ import { DropzoneProps } from '../Dropzone';
3
+ import { UseFormReturn } from 'react-hook-form';
4
+ import { FieldValues } from 'react-hook-form/dist/types/fields';
5
+
6
+ export interface FormDropzoneProps<Data extends FieldValues, Form extends UseFormReturn<Data>> extends FormRenderControlExtendProps<Data, Form>, DropzoneProps {
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from './FormDropzone';
2
+ export * from './FormDropzone.types';
@@ -0,0 +1,4 @@
1
+ import { FormDropzone as e } from "./FormDropzone.mjs";
2
+ export {
3
+ e as FormDropzone
4
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "sideEffects": false,
3
+ "main": "./index.mjs",
4
+ "module": "./index.mjs",
5
+ "default": "./index.mjs",
6
+ "types": "./index.d.ts"
7
+ }
@@ -3,5 +3,5 @@ import { FormRenderControlExtendProps } from '../Form';
3
3
  import { UseFormReturn } from 'react-hook-form';
4
4
  import { FieldValues } from 'react-hook-form/dist/types/fields';
5
5
 
6
- export interface FormSelectProps<Data extends FieldValues, Form extends UseFormReturn<Data>, ExtendOptionData> extends FormRenderControlExtendProps<Data, Form>, SelectProps<ExtendOptionData> {
6
+ export interface FormSelectProps<Data extends FieldValues, Form extends UseFormReturn<Data>, ExtendOptionData> extends FormRenderControlExtendProps<Data, Form>, Omit<SelectProps<ExtendOptionData>, 'onChange'> {
7
7
  }
package/index.d.ts CHANGED
@@ -64,3 +64,4 @@ export * from './Toggle';
64
64
  export * from './ToggleGroup';
65
65
  export * from './Tooltip';
66
66
  export * from './Dropzone';
67
+ export * from './FormDropzone';
package/index.mjs CHANGED
@@ -78,7 +78,8 @@ import { ToggleGroup as cn, ToggleGroupItem as Mn } from "./ToggleGroup/ToggleGr
78
78
  import { TooltipContent as An, TooltipProvider as In, TooltipRoot as wn, TooltipTrigger as hn } from "./Tooltip/TooltipRoot.mjs";
79
79
  import { Tooltip as Fn } from "./Tooltip/Tooltip.mjs";
80
80
  import { Dropzone as Bn } from "./Dropzone/Dropzone.mjs";
81
- import { D as Rn, a as kn } from "./FilePreview-Dhtv8F4u.js";
81
+ import { D as Rn, a as kn } from "./DropzoneFilePreview-Dhtv8F4u.js";
82
+ import { FormDropzone as Nn } from "./FormDropzone/FormDropzone.mjs";
82
83
  export {
83
84
  e as Accordion,
84
85
  t as AccordionContent,
@@ -195,6 +196,7 @@ export {
195
196
  Rr as FormControl,
196
197
  Jr as FormDatePicker,
197
198
  kr as FormDescription,
199
+ Nn as FormDropzone,
198
200
  Hr as FormField,
199
201
  Qr as FormInput,
200
202
  Nr as FormItem,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneplatformdev/ui",
3
- "version": "0.0.1-beta.13",
3
+ "version": "0.0.1-beta.17",
4
4
  "description": "UI React Components.",
5
5
  "author": "One Platform Development Team",
6
6
  "keywords": [