@oneplatformdev/ui 0.0.1-beta.87 → 0.0.1-beta.88

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.
@@ -1,5 +1,9 @@
1
- import { DropzoneProps } from './Dropzone.types';
1
+ import { DropzoneProps, DropzoneValueItem } from './Dropzone.types';
2
+ import { Dispatch, SetStateAction } from 'react';
2
3
 
4
+ export interface DropzoneControl {
5
+ setItems: Dispatch<SetStateAction<DropzoneValueItem[]>>;
6
+ }
3
7
  /**
4
8
  * Dropzone component - A drag-and-drop file upload area with image previews, error handling, and localization.
5
9
  *
@@ -19,4 +23,4 @@ import { DropzoneProps } from './Dropzone.types';
19
23
  * @param {React.Ref<HTMLDivElement>} ref - Ref for the root dropzone container.
20
24
  * @returns {JSX.Element} The rendered Dropzone component.
21
25
  */
22
- export declare const Dropzone: import('react').ForwardRefExoticComponent<DropzoneProps & import('react').RefAttributes<HTMLDivElement>>;
26
+ export declare const Dropzone: import('react').ForwardRefExoticComponent<DropzoneProps & import('react').RefAttributes<DropzoneControl>>;
@@ -1,56 +1,57 @@
1
1
  import { jsxs as r, jsx as i, Fragment as U } from "react/jsx-runtime";
2
- import { forwardRef as j, useState as g } from "react";
3
- import { useDropzone as O } from "react-dropzone";
4
- import { Card as X } from "../Card/Card.mjs";
5
- import { X as Y } from "lucide-react";
2
+ import { X as j } from "lucide-react";
3
+ import { forwardRef as H, useState as w, useImperativeHandle as O } from "react";
4
+ import { useDropzone as X } from "react-dropzone";
6
5
  import { cn as f } from "@oneplatformdev/utils";
6
+ import { Card as Y } from "../Card/Card.mjs";
7
7
  import { F as q, D as G } from "../DropzoneFilePreview-Dhtv8F4u.js";
8
- import { DefaultFileIcon as H, isFile as u, extractName as J } from "./DropzoneUtils.mjs";
9
- import { DropzoneSinglePickPreview as K } from "./DropzoneSinglePickPreview.mjs";
10
- const Q = j(
8
+ import { DropzoneSinglePickPreview as J } from "./DropzoneSinglePickPreview.mjs";
9
+ import { DefaultFileIcon as K, isFile as g, extractName as Q } from "./DropzoneUtils.mjs";
10
+ const R = H(
11
11
  ({
12
12
  acceptTypes: y = G,
13
13
  maxSizeMB: F,
14
- maxFiles: h = 1,
14
+ maxFiles: v = 1,
15
15
  onErrors: a,
16
16
  hideErrors: D = !1,
17
17
  disabled: p = !1,
18
18
  classNames: o,
19
19
  value: z = [],
20
20
  onChangeValue: s,
21
- className: E,
22
- labelDropzonePrompt: I = "Drop files here or click to select",
21
+ className: I,
22
+ labelDropzonePrompt: E = "Drop files here or click to select",
23
23
  labelDropzoneSubPrompt: b = "",
24
- labelOrClickToSelect: R = "Click to select files",
24
+ labelOrClickToSelect: Z = "Click to select files",
25
25
  labelSelectedFiles: S = "Selected Files",
26
26
  labelUploadErrors: N = "Upload Errors",
27
27
  labelFileTooLarge: W = "File is too large",
28
28
  labelInvalidFileType: k = "Invalid file type",
29
29
  singlePick: c = !1,
30
- ...T
31
- }, _) => {
32
- const [n, v] = g(z), [m, A] = g([]), B = (e, l) => {
33
- A(l), a == null || a(l);
34
- const t = c ? e.slice(0, 1) : [...n, ...e].slice(0, h);
35
- v(t), s == null || s(t);
36
- }, w = (e, l) => {
30
+ ...B
31
+ }, T) => {
32
+ const [n, x] = w(z), [m, _] = w([]), A = (e, l) => {
33
+ _(l), a == null || a(l);
34
+ const t = c ? e.slice(0, 1) : [...n, ...e].slice(0, v);
35
+ x(t), s == null || s(t);
36
+ }, u = (e, l) => {
37
37
  if (p) return;
38
38
  e.stopPropagation();
39
- const t = n.filter((d, x) => x !== l);
40
- v(t), s == null || s(t);
41
- }, { getRootProps: L, getInputProps: M, isDragActive: P } = O({
42
- onDrop: B,
39
+ const t = n.filter((d, h) => h !== l);
40
+ x(t), s == null || s(t);
41
+ }, { getRootProps: L, getInputProps: M, isDragActive: P } = X({
42
+ onDrop: A,
43
43
  accept: y.reduce((e, l) => (e[l] = [], e), {}),
44
44
  maxSize: F * 1024 * 1024,
45
- maxFiles: c ? 1 : h,
45
+ maxFiles: c ? 1 : v,
46
46
  disabled: p
47
47
  });
48
- return /* @__PURE__ */ r(
49
- X,
48
+ return O(T, () => ({
49
+ setItems: x
50
+ }), []), /* @__PURE__ */ r(
51
+ Y,
50
52
  {
51
53
  ...L(),
52
- ...T,
53
- ref: _,
54
+ ...B,
54
55
  className: f(
55
56
  "border-dashed p-2 text-center flex flex-col items-center justify-center cursor-pointer",
56
57
  p && "border-[#E4E4E7] pointer-events-none",
@@ -58,7 +59,7 @@ const Q = j(
58
59
  P && "bg-gray-100",
59
60
  c && "!shadow-none",
60
61
  c && n.length > 0 && "!p-0 !shadow-none",
61
- E
62
+ I
62
63
  ),
63
64
  children: [
64
65
  /* @__PURE__ */ i("input", { ...M() }),
@@ -70,9 +71,9 @@ const Q = j(
70
71
  o == null ? void 0 : o.idleWrapper
71
72
  ),
72
73
  children: [
73
- /* @__PURE__ */ i(H, {}),
74
+ /* @__PURE__ */ i(K, {}),
74
75
  !p && /* @__PURE__ */ r(U, { children: [
75
- /* @__PURE__ */ i("span", { className: "font-medium text-md text-foreground max-w-[200px]", children: I }),
76
+ /* @__PURE__ */ i("span", { className: "font-medium text-md text-foreground max-w-[200px]", children: E }),
76
77
  /* @__PURE__ */ i("span", { className: "font-normal text-xs text-foreground max-w-[250px]", children: b })
77
78
  ] })
78
79
  ]
@@ -95,11 +96,11 @@ const Q = j(
95
96
  ] }, d)) })
96
97
  ] }, l)) })
97
98
  ] }),
98
- c && n.length > 0 && /* @__PURE__ */ i(
99
- K,
99
+ !!(c && n.length) && /* @__PURE__ */ i(
100
+ J,
100
101
  {
101
102
  item: n[0],
102
- onRemoveClick: (e) => w(e, 0),
103
+ onRemoveClick: (e) => u(e, 0),
103
104
  disabled: p
104
105
  }
105
106
  ),
@@ -109,7 +110,7 @@ const Q = j(
109
110
  ":"
110
111
  ] }),
111
112
  /* @__PURE__ */ i("ul", { className: "mt-2 text-sm text-gray-500 flex flex-wrap gap-4 items-start justify-center", children: n.map((e, l) => {
112
- const t = u(e) ? e.name : J(e), d = u(e) ? (e.size / (1024 * 1024)).toFixed(2) + " MB" : "";
113
+ const t = g(e) ? e.name : Q(e), d = g(e) ? (e.size / (1024 * 1024)).toFixed(2) + " MB" : "";
113
114
  return /* @__PURE__ */ r(
114
115
  "li",
115
116
  {
@@ -121,8 +122,8 @@ const Q = j(
121
122
  "div",
122
123
  {
123
124
  className: "absolute top-0 right-0 cursor-pointer bg-gray-300 rounded-sm",
124
- onClick: (x) => w(x, l),
125
- children: /* @__PURE__ */ i(Y, { size: 16, strokeWidth: 1, color: "black" })
125
+ onClick: (h) => u(h, l),
126
+ children: /* @__PURE__ */ i(j, { size: 16, strokeWidth: 1, color: "black" })
126
127
  }
127
128
  )
128
129
  ] }),
@@ -145,7 +146,7 @@ const Q = j(
145
146
  );
146
147
  }
147
148
  );
148
- Q.displayName = "Dropzone";
149
+ R.displayName = "Dropzone";
149
150
  export {
150
- Q as Dropzone
151
+ R as Dropzone
151
152
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneplatformdev/ui",
3
- "version": "0.0.1-beta.87",
3
+ "version": "0.0.1-beta.88",
4
4
  "description": "UI React Components.",
5
5
  "author": "One Platform Development Team",
6
6
  "keywords": [