@fangzsx/component-library 0.0.37 → 0.0.38

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,3 @@
1
- import { default as React } from 'react';
2
-
3
1
  interface ImageUploadProps {
4
2
  label?: string;
5
3
  required?: boolean;
@@ -11,5 +9,5 @@ interface ImageUploadProps {
11
9
  disabled?: boolean;
12
10
  onChange?: (file: File | null, error: string) => void;
13
11
  }
14
- declare const ImageUpload: React.FC<ImageUploadProps>;
15
- export default ImageUpload;
12
+ export declare function ImageUpload({ label, required, maxSizeMB, acceptedFormats, error, forceError, helperText, disabled, onChange, }: ImageUploadProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -1,59 +1,70 @@
1
- import { jsx as e, jsxs as t } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
2
  import { C as H } from "../../Close-pjIlDyCW.js";
3
3
  import { c as M } from "../../createSvgIcon-C0YrvByi.js";
4
4
  import { FormControl as P, FormLabel as T, Box as i, Stack as U, Typography as l, IconButton as V, FormHelperText as E } from "@mui/material";
5
5
  import { useState as g, useRef as q, useCallback as G } from "react";
6
6
  const J = M(/* @__PURE__ */ e("path", {
7
7
  d: "M19 5v14H5V5zm0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-4.86 8.86-3 3.87L9 13.14 6 17h12z"
8
- }), "ImageOutlined"), K = (n) => {
9
- const a = n.lastIndexOf(".");
10
- return a <= 0 ? { baseName: n, extension: "" } : {
11
- baseName: n.slice(0, a),
12
- extension: n.slice(a)
8
+ }), "ImageOutlined");
9
+ function K(t) {
10
+ const a = t.lastIndexOf(".");
11
+ return a <= 0 ? { baseName: t, extension: "" } : {
12
+ baseName: t.slice(0, a),
13
+ extension: t.slice(a)
13
14
  };
14
- }, rr = ({
15
- label: n = "Logo",
15
+ }
16
+ function rr({
17
+ label: t = "Logo",
16
18
  required: a = !0,
17
- maxSizeMB: d = 2,
18
- acceptedFormats: s = ["png", "jpg", "jpeg"],
19
+ maxSizeMB: u = 2,
20
+ acceptedFormats: c = ["png", "jpg", "jpeg"],
19
21
  error: x = "",
20
22
  forceError: y = !1,
21
23
  helperText: b,
22
24
  disabled: o = !1,
23
- onChange: c
24
- }) => {
25
- const [v, h] = g(!1), [p, k] = g(null), [O, D] = g(""), m = q(null), w = d * 1024 * 1024, R = s.map((r) => `.${r}`).join(","), C = s.map(
25
+ onChange: s
26
+ }) {
27
+ const [v, f] = g(!1), [p, k] = g(null), [O, D] = g(""), d = q(null), w = u * 1024 * 1024, R = c.map((r) => `.${r}`).join(","), C = c.map(
26
28
  (r) => `image/${r === "jpg" ? "jpeg" : r}`
27
29
  ), j = G(
28
- (r) => {
30
+ function(r) {
29
31
  if (!r) return;
30
- if (!C.some((f) => r.type === f)) {
31
- c?.(null, `Only ${s.join(", ")} files are supported`);
32
+ if (!C.some((h) => r.type === h)) {
33
+ s?.(null, `Only ${c.join(", ")} files are supported`);
32
34
  return;
33
35
  }
34
36
  if (r.size > w) {
35
- c?.(null, `File size must be less than ${d}MB`);
37
+ s?.(null, `File size must be less than ${u}MB`);
36
38
  return;
37
39
  }
38
40
  const I = new FileReader();
39
- I.onload = (f) => {
40
- k(f.target?.result), D(r.name), c?.(r, "");
41
+ I.onload = function(h) {
42
+ k(h.target?.result), D(r.name), s?.(r, "");
41
43
  }, I.readAsDataURL(r);
42
44
  },
43
- [C, w, d, s, c]
44
- ), S = (r) => {
45
- r.preventDefault(), !o && (h(!1), j(r.dataTransfer.files?.[0] ?? null));
46
- }, F = (r) => {
47
- r.preventDefault(), o || h(!0);
48
- }, L = () => h(!1), W = () => {
49
- o || m.current?.click();
50
- }, z = (r) => {
45
+ [C, w, u, c, s]
46
+ );
47
+ function S(r) {
48
+ r.preventDefault(), !o && (f(!1), j(r.dataTransfer.files?.[0] ?? null));
49
+ }
50
+ function F(r) {
51
+ r.preventDefault(), o || f(!0);
52
+ }
53
+ function L() {
54
+ f(!1);
55
+ }
56
+ function W() {
57
+ o || d.current?.click();
58
+ }
59
+ function z(r) {
51
60
  j(r.target.files?.[0] ?? null);
52
- }, N = (r) => {
53
- r.stopPropagation(), k(null), D(""), c?.(null, ""), m.current && (m.current.value = "");
54
- }, u = !!x || y && !p, B = x || (y && !p ? `${n} can't be empty` : ""), { baseName: $, extension: A } = K(O);
55
- return /* @__PURE__ */ t(P, { fullWidth: !0, error: u, disabled: o, children: [
56
- n && /* @__PURE__ */ e(
61
+ }
62
+ function N(r) {
63
+ r.stopPropagation(), k(null), D(""), s?.(null, ""), d.current && (d.current.value = "");
64
+ }
65
+ const m = !!x || y && !p, B = x || (y && !p ? `${t} can't be empty` : ""), { baseName: $, extension: A } = K(O);
66
+ return /* @__PURE__ */ n(P, { fullWidth: !0, error: m, disabled: o, children: [
67
+ t && /* @__PURE__ */ e(
57
68
  T,
58
69
  {
59
70
  required: a,
@@ -66,10 +77,10 @@ const J = M(/* @__PURE__ */ e("path", {
66
77
  "&.Mui-focused": { color: "text.primary" },
67
78
  "&.Mui-error": { color: "text.primary" }
68
79
  },
69
- children: n
80
+ children: t
70
81
  }
71
82
  ),
72
- /* @__PURE__ */ t(
83
+ /* @__PURE__ */ n(
73
84
  i,
74
85
  {
75
86
  onClick: W,
@@ -79,7 +90,7 @@ const J = M(/* @__PURE__ */ e("path", {
79
90
  sx: {
80
91
  border: 2,
81
92
  borderStyle: "dashed",
82
- borderColor: u ? "error.main" : v ? "primary.main" : "grey.300",
93
+ borderColor: m ? "error.main" : v ? "primary.main" : "grey.300",
83
94
  borderRadius: 2,
84
95
  p: p ? 1.5 : 4,
85
96
  textAlign: "center",
@@ -88,7 +99,7 @@ const J = M(/* @__PURE__ */ e("path", {
88
99
  transition: "all 0.2s ease",
89
100
  opacity: o ? 0.6 : 1,
90
101
  "&:hover": o ? {} : {
91
- borderColor: u ? "error.main" : "primary.main",
102
+ borderColor: m ? "error.main" : "primary.main",
92
103
  bgcolor: "primary.50"
93
104
  }
94
105
  },
@@ -96,7 +107,7 @@ const J = M(/* @__PURE__ */ e("path", {
96
107
  /* @__PURE__ */ e(
97
108
  "input",
98
109
  {
99
- ref: m,
110
+ ref: d,
100
111
  type: "file",
101
112
  accept: R,
102
113
  onChange: z,
@@ -104,7 +115,7 @@ const J = M(/* @__PURE__ */ e("path", {
104
115
  disabled: o
105
116
  }
106
117
  ),
107
- p ? /* @__PURE__ */ t(U, { direction: "row", alignItems: "center", spacing: 2, children: [
118
+ p ? /* @__PURE__ */ n(U, { direction: "row", alignItems: "center", spacing: 2, children: [
108
119
  /* @__PURE__ */ e(
109
120
  i,
110
121
  {
@@ -121,8 +132,8 @@ const J = M(/* @__PURE__ */ e("path", {
121
132
  }
122
133
  }
123
134
  ),
124
- /* @__PURE__ */ t(i, { sx: { flex: 1, minWidth: 0, textAlign: "left" }, children: [
125
- /* @__PURE__ */ t(
135
+ /* @__PURE__ */ n(i, { sx: { flex: 1, minWidth: 0, textAlign: "left" }, children: [
136
+ /* @__PURE__ */ n(
126
137
  l,
127
138
  {
128
139
  variant: "body2",
@@ -175,14 +186,14 @@ const J = M(/* @__PURE__ */ e("path", {
175
186
  children: /* @__PURE__ */ e(H, { fontSize: "small" })
176
187
  }
177
188
  )
178
- ] }) : /* @__PURE__ */ t(i, { children: [
189
+ ] }) : /* @__PURE__ */ n(i, { children: [
179
190
  /* @__PURE__ */ e(
180
191
  J,
181
192
  {
182
193
  sx: { fontSize: 40, color: "primary.main", mb: 1.5 }
183
194
  }
184
195
  ),
185
- /* @__PURE__ */ t(l, { variant: "body2", color: "text.secondary", gutterBottom: !0, children: [
196
+ /* @__PURE__ */ n(l, { variant: "body2", color: "text.secondary", gutterBottom: !0, children: [
186
197
  "Drop image here or",
187
198
  " ",
188
199
  /* @__PURE__ */ e(
@@ -197,22 +208,22 @@ const J = M(/* @__PURE__ */ e("path", {
197
208
  }
198
209
  )
199
210
  ] }),
200
- /* @__PURE__ */ t(l, { variant: "caption", color: "text.disabled", display: "block", children: [
211
+ /* @__PURE__ */ n(l, { variant: "caption", color: "text.disabled", display: "block", children: [
201
212
  "File size should be less than ",
202
- d,
213
+ u,
203
214
  "MB"
204
215
  ] }),
205
- /* @__PURE__ */ t(l, { variant: "caption", color: "text.disabled", display: "block", children: [
216
+ /* @__PURE__ */ n(l, { variant: "caption", color: "text.disabled", display: "block", children: [
206
217
  "Supports ",
207
- s.join(", ")
218
+ c.join(", ")
208
219
  ] })
209
220
  ] })
210
221
  ]
211
222
  }
212
223
  ),
213
- (u || b) && /* @__PURE__ */ e(E, { sx: { mt: 0.75, mx: 0 }, children: B || b })
224
+ (m || b) && /* @__PURE__ */ e(E, { sx: { mt: 0.75, mx: 0 }, children: B || b })
214
225
  ] });
215
- };
226
+ }
216
227
  export {
217
- rr as default
228
+ rr as ImageUpload
218
229
  };
package/dist/main.d.ts CHANGED
@@ -7,6 +7,7 @@ export { CheckboxGroup } from './components/CheckboxGroup';
7
7
  export { Dropdown } from './components/Dropdown';
8
8
  export { DropdownOptions } from './components/DropdownOptions';
9
9
  export { FlatBanner } from './components/FlatBanner';
10
+ export { ImageUpload } from './components/ImageUpload';
10
11
  export { Label } from './components/Label';
11
12
  export { LinearProgress } from './components/LinearProgress';
12
13
  export { MediaCardWithAction } from './components/MediaCardWithAction';
package/dist/main.js CHANGED
@@ -1,38 +1,40 @@
1
1
  import { AppBarPublic as e } from "./components/AppBarPublic/index.js";
2
2
  import { Banner as p } from "./components/Banner/index.js";
3
3
  import { B as m } from "./index-Dnsx2wLn.js";
4
- import { CheckBox as n } from "./components/Checkbox/index.js";
5
- import { ScrollableDialog as i } from "./components/Dialog/index.js";
4
+ import { CheckBox as a } from "./components/Checkbox/index.js";
5
+ import { ScrollableDialog as d } from "./components/Dialog/index.js";
6
6
  import { CheckboxGroup as l } from "./components/CheckboxGroup/index.js";
7
7
  import { Dropdown as B } from "./components/Dropdown/index.js";
8
8
  import { DropdownOptions as s } from "./components/DropdownOptions/index.js";
9
9
  import { FlatBanner as D } from "./components/FlatBanner/index.js";
10
- import { Label as h } from "./components/Label/index.js";
11
- import { LinearProgress as g } from "./components/LinearProgress/index.js";
12
- import { MediaCardWithAction as A } from "./components/MediaCardWithAction/index.js";
13
- import { PhoneAndCountryDropdown as F } from "./components/PhoneAndCountryDropdown/index.js";
14
- import { PromoCode as L } from "./components/PromoCode/index.js";
15
- import { RadioButtonGroup as T } from "./components/RadioButtonGroup/index.js";
16
- import { Stepper as I } from "./components/Stepper/index.js";
17
- import { Text as O } from "./components/Text/index.js";
18
- import { TextFieldInput as W } from "./components/TextFieldInput/index.js";
10
+ import { ImageUpload as g } from "./components/ImageUpload/index.js";
11
+ import { Label as P } from "./components/Label/index.js";
12
+ import { LinearProgress as A } from "./components/LinearProgress/index.js";
13
+ import { MediaCardWithAction as F } from "./components/MediaCardWithAction/index.js";
14
+ import { PhoneAndCountryDropdown as I } from "./components/PhoneAndCountryDropdown/index.js";
15
+ import { PromoCode as S } from "./components/PromoCode/index.js";
16
+ import { RadioButtonGroup as y } from "./components/RadioButtonGroup/index.js";
17
+ import { Stepper as O } from "./components/Stepper/index.js";
18
+ import { Text as U } from "./components/Text/index.js";
19
+ import { TextFieldInput as j } from "./components/TextFieldInput/index.js";
19
20
  export {
20
21
  e as AppBarPublic,
21
22
  p as Banner,
22
23
  m as Button,
23
- n as CheckBox,
24
+ a as CheckBox,
24
25
  l as CheckboxGroup,
25
- i as Dialog,
26
+ d as Dialog,
26
27
  B as Dropdown,
27
28
  s as DropdownOptions,
28
29
  D as FlatBanner,
29
- h as Label,
30
- g as LinearProgress,
31
- A as MediaCardWithAction,
32
- F as PhoneAndCountryDropdown,
33
- L as PromoCode,
34
- T as RadioButtonGroup,
35
- I as Stepper,
36
- O as Text,
37
- W as TextFieldInput
30
+ g as ImageUpload,
31
+ P as Label,
32
+ A as LinearProgress,
33
+ F as MediaCardWithAction,
34
+ I as PhoneAndCountryDropdown,
35
+ S as PromoCode,
36
+ y as RadioButtonGroup,
37
+ O as Stepper,
38
+ U as Text,
39
+ j as TextFieldInput
38
40
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fangzsx/component-library",
3
3
  "author": "Jay Gilbert Garzon",
4
4
  "private": false,
5
- "version": "0.0.37",
5
+ "version": "0.0.38",
6
6
  "type": "module",
7
7
  "main": "dist/main.js",
8
8
  "types": "dist/main.d.ts",