@sps-woodland/file-upload 8.26.1 → 8.26.2

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/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as e from "react";
2
- import { Metadata as _e, I18nContext as fe, cl as M, Spinner as ue } from "@sps-woodland/core";
3
- import { parseFileSize as me, code as c } from "@spscommerce/utils";
4
- import { Button as B } from "@sps-woodland/buttons";
2
+ import { Metadata as _e, I18nContext as fe, cl as B, Spinner as ue } from "@sps-woodland/core";
3
+ import { parseFileSize as me, code as _ } from "@spscommerce/utils";
4
+ import { Button as I } from "@sps-woodland/buttons";
5
5
  import { GENERAL_ERROR_LARGE as he, UPLOAD_LARGE as ve } from "@sps-woodland/illustrations";
6
- const I = {
6
+ const R = {
7
7
  "7Z": ["application/x-7z-compressed"],
8
8
  AAC: ["audio/aac"],
9
9
  ABW: ["application/x-abiword"],
@@ -88,7 +88,7 @@ function we(a, i, l) {
88
88
  writable: !0
89
89
  }) : a[i] = l, a;
90
90
  }
91
- function R(a, i) {
91
+ function L(a, i) {
92
92
  var l = Object.keys(a);
93
93
  if (Object.getOwnPropertySymbols) {
94
94
  var t = Object.getOwnPropertySymbols(a);
@@ -98,12 +98,12 @@ function R(a, i) {
98
98
  }
99
99
  return l;
100
100
  }
101
- function L(a) {
101
+ function W(a) {
102
102
  for (var i = 1; i < arguments.length; i++) {
103
103
  var l = arguments[i] != null ? arguments[i] : {};
104
- i % 2 ? R(Object(l), !0).forEach(function(t) {
104
+ i % 2 ? L(Object(l), !0).forEach(function(t) {
105
105
  we(a, t, l[t]);
106
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(a, Object.getOwnPropertyDescriptors(l)) : R(Object(l)).forEach(function(t) {
106
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(a, Object.getOwnPropertyDescriptors(l)) : L(Object(l)).forEach(function(t) {
107
107
  Object.defineProperty(a, t, Object.getOwnPropertyDescriptor(l, t));
108
108
  });
109
109
  }
@@ -116,25 +116,25 @@ var ge = (a, i, l) => {
116
116
  return !1;
117
117
  }
118
118
  return !0;
119
- }, j = (a) => (i) => {
120
- var l = a.defaultClassName, t = L(L({}, a.defaultVariants), i);
119
+ }, C = (a) => (i) => {
120
+ var l = a.defaultClassName, t = W(W({}, a.defaultVariants), i);
121
121
  for (var n in t) {
122
122
  var v, w = (v = t[n]) !== null && v !== void 0 ? v : a.defaultVariants[n];
123
123
  if (w != null) {
124
124
  var p = w;
125
125
  typeof p == "boolean" && (p = p === !0 ? "true" : "false");
126
- var _ = (
126
+ var d = (
127
127
  // @ts-expect-error
128
128
  a.variantClassNames[n][p]
129
129
  );
130
- _ && (l += " " + _);
130
+ d && (l += " " + d);
131
131
  }
132
132
  }
133
- for (var [F, C] of a.compoundVariants)
134
- ge(F, t, a.defaultVariants) && (l += " " + C);
133
+ for (var [F, k] of a.compoundVariants)
134
+ ge(F, t, a.defaultVariants) && (l += " " + k);
135
135
  return l;
136
- }, Fe = "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jws", V = "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwt", xe = "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwr", be = j({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw0", variantClassNames: { active: { true: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw1", false: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw2" }, mini: { true: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw3", false: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw4" }, error: { true: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw5", false: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw6" }, shown: { true: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw7", false: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw8" }, disabled: { true: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw9", false: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwa" } }, defaultVariants: { active: !1, mini: !1, error: !1, shown: !0, disabled: !1 }, compoundVariants: [] }), Ee = "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jww", ye = j({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwb", variantClassNames: { constrainContentWidth: { true: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwc", false: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwd" }, disabled: { true: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwe", false: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwf" } }, defaultVariants: { constrainContentWidth: !1, disabled: !1 }, compoundVariants: [] }), Ue = "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwv", Se = "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwx", je = j({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwh", variantClassNames: { mini: { true: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwi", false: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwj" }, error: { true: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwk", false: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwl" }, disabled: { true: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwm", false: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwn" } }, defaultVariants: { mini: !1, error: !1, disabled: !1 }, compoundVariants: [] }), Ce = "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwy", z = "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwg", ke = "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwu", De = j({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwo", variantClassNames: { mini: { true: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwp", false: "pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwq" } }, defaultVariants: { mini: !1 }, compoundVariants: [] });
137
- function W({
136
+ }, Fe = "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jws", z = "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwt", xe = "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwr", be = C({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw0", variantClassNames: { active: { true: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw1", false: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw2" }, mini: { true: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw3", false: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw4" }, error: { true: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw5", false: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw6" }, shown: { true: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw7", false: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw8" }, disabled: { true: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw9", false: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwa" } }, defaultVariants: { active: !1, mini: !1, error: !1, shown: !0, disabled: !1 }, compoundVariants: [] }), ye = "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jww", Ee = C({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwb", variantClassNames: { constrainContentWidth: { true: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwc", false: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwd" }, disabled: { true: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwe", false: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwf" } }, defaultVariants: { constrainContentWidth: !1, disabled: !1 }, compoundVariants: [] }), Ue = "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwv", Se = "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwx", je = C({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwh", variantClassNames: { mini: { true: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwi", false: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwj" }, error: { true: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwk", false: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwl" }, disabled: { true: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwm", false: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwn" } }, defaultVariants: { mini: !1, error: !1, disabled: !1 }, compoundVariants: [] }), Ce = "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwy", G = "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwg", ke = "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwu", De = C({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwo", variantClassNames: { mini: { true: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwp", false: "pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwq" } }, defaultVariants: { mini: !1 }, compoundVariants: [] });
137
+ function X({
138
138
  constrainContentWidth: a,
139
139
  description: i,
140
140
  multiple: l = !1,
@@ -143,23 +143,23 @@ function W({
143
143
  mini: v,
144
144
  downloadLabel: w,
145
145
  acceptExtensions: p,
146
- maxSize: _,
146
+ maxSize: d,
147
147
  customRequirement: F,
148
- onSelection: C,
148
+ onSelection: k,
149
149
  onDismiss: O,
150
150
  download: N,
151
151
  shown: x,
152
- className: G,
153
- disabled: d,
152
+ className: Z,
153
+ disabled: c,
154
154
  children: Ne,
155
- ...X
155
+ ...q
156
156
  }) {
157
- const b = e.useRef(/* @__PURE__ */ new Set()), [Z, T] = e.useState(x), [Te, q] = e.useState([]), [H, J] = e.useState(""), [P, K] = e.useState(), [Y, E] = e.useState(!1), [g, y] = e.useState(!1), [k, A] = e.useState([]), [Q, $] = e.useState(""), { t: h } = e.useContext(fe), U = h(l ? "design-system:fileUpload.instructions_plural" : "design-system:fileUpload.instructions").split("|"), ee = i || (l ? "Files" : "File"), f = e.useRef(null);
157
+ const b = e.useRef(/* @__PURE__ */ new Set()), [H, T] = e.useState(x), [Te, J] = e.useState([]), [K, Y] = e.useState(""), [P, $] = e.useState(), [Q, y] = e.useState(!1), [g, E] = e.useState(!1), [U, A] = e.useState([]), [V, ee] = e.useState(""), { t: h } = e.useContext(fe), S = (l ? h("design-system:fileUpload.instructions_plural", { defaultValue: "Drag and drop your files here or |browse for files| on your desktop." }) : h("design-system:fileUpload.instructions", { defaultValue: "Drag and drop your file here or |browse for a file| on your desktop." })).split("|"), M = i || (l ? "Files" : "File"), f = e.useRef(null);
158
158
  e.useEffect(() => {
159
159
  x && T(x);
160
160
  }, [x]), e.useEffect(() => {
161
- _ && ae(_);
162
- }, [_]), e.useEffect(() => {
161
+ d && ae(d);
162
+ }, [d]), e.useEffect(() => {
163
163
  p && le(p);
164
164
  }, [p]);
165
165
  function oe() {
@@ -167,33 +167,33 @@ function W({
167
167
  }
168
168
  function ae(o) {
169
169
  try {
170
- K(me(o));
170
+ $(me(o));
171
171
  } catch {
172
172
  throw new Error(`Could not parse "${o}" as a file size.`);
173
173
  }
174
174
  }
175
175
  function le(o) {
176
176
  const u = (Array.isArray(o) ? o : o.trim().split(/\s?,\s?/)).map((m) => m.replace(/^\./, "")), r = u.map((m) => `.${m}`.toLowerCase());
177
- $(
178
- r.map((m, S) => S > 0 && S === r.length - 1 ? `or ${m}` : m).join(r.length > 2 ? ", " : " ")
177
+ ee(
178
+ r.map((m, j) => j > 0 && j === r.length - 1 ? `or ${m}` : m).join(r.length > 2 ? ", " : " ")
179
179
  ), b.current.clear();
180
180
  for (const m of u) {
181
- const S = Object.keys(I).includes(m.toUpperCase()) ? I[m.toUpperCase()] : [];
182
- for (const ce of S)
181
+ const j = Object.keys(R).includes(m.toUpperCase()) ? R[m.toUpperCase()] : [];
182
+ for (const ce of j)
183
183
  b.current.add(ce);
184
184
  }
185
- J(r.concat(Array.from(b.current)).join(","));
185
+ Y(r.concat(Array.from(b.current)).join(","));
186
186
  }
187
187
  function D(o) {
188
188
  A([]);
189
189
  let s = [];
190
190
  const u = Array.from(o);
191
191
  for (const r of u)
192
- r === null ? s.push("Not a file") : (p && !b.current.has(r.type) && s.push(r.name), _ && P && r.size > P && s.indexOf(r.name) === -1 && s.push(r.name));
193
- s.length ? (y(!0), f.current && f.current.value && (f.current.value = "")) : (q(u), C(u)), A(s);
192
+ r === null ? s.push("Not a file") : (p && !b.current.has(r.type) && s.push(r.name), d && P && r.size > P && s.indexOf(r.name) === -1 && s.push(r.name));
193
+ s.length ? (E(!0), f.current && f.current.value && (f.current.value = "")) : (J(u), k(u)), A(s);
194
194
  }
195
195
  function te(o) {
196
- o.preventDefault(), y(!1), f.current && f.current.click();
196
+ o.preventDefault(), E(!1), f.current && f.current.click();
197
197
  }
198
198
  function ie() {
199
199
  N && N();
@@ -202,16 +202,16 @@ function W({
202
202
  o.stopPropagation(), D(o.target.files || []), f.current && f.current.value && (f.current.value = "");
203
203
  }
204
204
  function se(o) {
205
- o.preventDefault(), o.stopPropagation(), E(!0), y(!1);
205
+ o.preventDefault(), o.stopPropagation(), y(!0), E(!1);
206
206
  }
207
207
  function re(o) {
208
- o.preventDefault(), E(!0), y(!1);
208
+ o.preventDefault(), y(!0), E(!1);
209
209
  }
210
210
  function pe(o) {
211
- o.preventDefault(), E(!1);
211
+ o.preventDefault(), y(!1);
212
212
  }
213
213
  function de(o) {
214
- o.preventDefault(), o.stopPropagation(), E(!1), o.dataTransfer.items ? D(
214
+ o.preventDefault(), o.stopPropagation(), y(!1), o.dataTransfer.items ? D(
215
215
  Array.from(o.dataTransfer.items).map(
216
216
  (s) => s.getAsFile()
217
217
  )
@@ -220,18 +220,18 @@ function W({
220
220
  return /* @__PURE__ */ e.createElement(
221
221
  "div",
222
222
  {
223
- onDrop: d ? () => {
223
+ onDrop: c ? () => {
224
224
  } : de,
225
- onDragOver: d ? () => {
225
+ onDragOver: c ? () => {
226
226
  } : se,
227
- onDragLeave: d ? () => {
227
+ onDragLeave: c ? () => {
228
228
  } : pe,
229
- onDragEnter: d ? () => {
229
+ onDragEnter: c ? () => {
230
230
  } : re,
231
- className: M(be({ active: Y, mini: v, error: g, shown: Z, disabled: d }), G),
232
- ...X
231
+ className: B(be({ active: Q, mini: v, error: g, shown: H, disabled: c }), Z),
232
+ ...q
233
233
  },
234
- /* @__PURE__ */ e.createElement("div", { className: M(ye({ constrainContentWidth: a, disabled: d })) }, n ? /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(ue, { size: "md", "aria-hidden": "true" }), /* @__PURE__ */ e.createElement("div", { className: z }, h("design-system:fileUpload.processing"))) : /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: je({ mini: v, error: g, disabled: d }), "aria-hidden": "true" }, /* @__PURE__ */ e.createElement(
234
+ /* @__PURE__ */ e.createElement("div", { className: B(Ee({ constrainContentWidth: a, disabled: c })) }, n ? /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(ue, { size: "md", "aria-hidden": "true" }), /* @__PURE__ */ e.createElement("div", { className: G }, h("design-system:fileUpload.processing", { defaultValue: "Processing Upload..." }))) : /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: je({ mini: v, error: g, disabled: c }), "aria-hidden": "true" }, /* @__PURE__ */ e.createElement(
235
235
  "img",
236
236
  {
237
237
  className: Ce,
@@ -239,31 +239,33 @@ function W({
239
239
  alt: "Upload Icon"
240
240
  }
241
241
  )), /* @__PURE__ */ e.createElement("div", { className: De({ mini: v }) }, g ? /* @__PURE__ */ e.createElement("div", null, h(
242
- k.length > 1 ? "design-system:fileUpload.cancelled_plural" : "design-system:fileUpload.cancelled"
243
- )) : /* @__PURE__ */ e.createElement("div", null, h("design-system:fileUpload.title", { description: ee }))), g ? /* @__PURE__ */ e.createElement("div", { className: xe }, new Set(
244
- k.map((o, s) => {
242
+ U.length > 1 ? "design-system:fileUpload.cancelled_plural" : "design-system:fileUpload.cancelled",
243
+ { defaultValue: U.length > 1 ? "File Upload(s) Failed" : "File Upload Failed" }
244
+ )) : /* @__PURE__ */ e.createElement("div", null, h("design-system:fileUpload.title", { description: M, defaultValue: `Upload your ${M}` }))), g ? /* @__PURE__ */ e.createElement("div", { className: xe }, new Set(
245
+ U.map((o, s) => {
245
246
  const u = Math.floor(o.length / 2);
246
- return /* @__PURE__ */ e.createElement("div", { className: Fe, key: o }, /* @__PURE__ */ e.createElement("span", { className: V }, o.substr(0, u)), /* @__PURE__ */ e.createElement("div", { className: V }, /* @__PURE__ */ e.createElement("span", null, o.substr(u))), s < k.length - 1 ? "," : "");
247
+ return /* @__PURE__ */ e.createElement("div", { className: Fe, key: o }, /* @__PURE__ */ e.createElement("span", { className: z }, o.substr(0, u)), /* @__PURE__ */ e.createElement("div", { className: z }, /* @__PURE__ */ e.createElement("span", null, o.substr(u))), s < U.length - 1 ? "," : "");
247
248
  })
248
- )) : /* @__PURE__ */ e.createElement("span", null), /* @__PURE__ */ e.createElement("div", { className: z }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("span", null, U[0]), d ? /* @__PURE__ */ e.createElement("u", null, U[1]) : /* @__PURE__ */ e.createElement("a", { href: "", onClick: te }, U[1]), /* @__PURE__ */ e.createElement("span", null, U[2]))), /* @__PURE__ */ e.createElement("div", { className: ke }, p ? /* @__PURE__ */ e.createElement("span", null, "(", " ", h("design-system:fileUpload.acceptedTypes", {
249
- fileTypes: Q
250
- }), " ", ")") : "", _ ? /* @__PURE__ */ e.createElement("span", null, "( ", h("design-system:fileUpload.maximumSize", { size: _ }), " )") : "", F ? /* @__PURE__ */ e.createElement("span", null, " ", F, " ") : ""), w && /* @__PURE__ */ e.createElement("div", { className: Ue }, /* @__PURE__ */ e.createElement(
251
- B,
249
+ )) : /* @__PURE__ */ e.createElement("span", null), /* @__PURE__ */ e.createElement("div", { className: G }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("span", null, S[0]), c ? /* @__PURE__ */ e.createElement("u", null, S[1]) : /* @__PURE__ */ e.createElement("a", { href: "", onClick: te }, S[1]), /* @__PURE__ */ e.createElement("span", null, S[2]))), /* @__PURE__ */ e.createElement("div", { className: ke }, p ? /* @__PURE__ */ e.createElement("span", null, "(", " ", h("design-system:fileUpload.acceptedTypes", {
250
+ fileTypes: V,
251
+ defaultValue: `${V} format accepted`
252
+ }), " ", ")") : "", d ? /* @__PURE__ */ e.createElement("span", null, "( ", h("design-system:fileUpload.maximumSize", { size: d, defaultValue: `${d} maximum` }), " )") : "", F ? /* @__PURE__ */ e.createElement("span", null, " ", F, " ") : ""), w && /* @__PURE__ */ e.createElement("div", { className: Ue }, /* @__PURE__ */ e.createElement(
253
+ I,
252
254
  {
253
- disabled: d,
255
+ disabled: c,
254
256
  kind: "link",
255
257
  icon: "download-cloud",
256
258
  onClick: ie
257
259
  },
258
260
  w
259
261
  )))),
260
- t && !n && /* @__PURE__ */ e.createElement("div", { className: Ee }, /* @__PURE__ */ e.createElement(
261
- B,
262
+ t && !n && /* @__PURE__ */ e.createElement("div", { className: ye }, /* @__PURE__ */ e.createElement(
263
+ I,
262
264
  {
263
- disabled: d,
265
+ disabled: c,
264
266
  kind: "icon",
265
267
  icon: "x",
266
- title: h("design-system:fileUpload.close"),
268
+ title: h("design-system:fileUpload.close", { defaultValue: "Close" }),
267
269
  onClick: oe
268
270
  }
269
271
  )),
@@ -272,14 +274,14 @@ function W({
272
274
  {
273
275
  ref: f,
274
276
  type: "file",
275
- accept: H || "*/*",
277
+ accept: K || "*/*",
276
278
  multiple: l || void 0,
277
279
  onChange: ne
278
280
  }
279
281
  ))
280
282
  );
281
283
  }
282
- _e.set(W, {
284
+ _e.set(X, {
283
285
  name: "FileUpload",
284
286
  props: {
285
287
  constrainContentWidth: { type: "boolean" },
@@ -298,7 +300,7 @@ _e.set(W, {
298
300
  }
299
301
  });
300
302
  const Oe = {
301
- components: [W],
303
+ components: [X],
302
304
  examples: {
303
305
  basic: {
304
306
  label: "Basic File Upload",
@@ -306,7 +308,7 @@ const Oe = {
306
308
  examples: {
307
309
  basic: {
308
310
  description: "Single file upload",
309
- react: c`
311
+ react: _`
310
312
  import { FileUpload } from "@sps-woodland/file-upload";
311
313
 
312
314
  function Component() {
@@ -322,7 +324,7 @@ const Oe = {
322
324
  },
323
325
  multiple: {
324
326
  description: "Multiple file upload",
325
- react: c`
327
+ react: _`
326
328
  import { FileUpload } from "@sps-woodland/file-upload";
327
329
 
328
330
  function Component() {
@@ -344,7 +346,7 @@ const Oe = {
344
346
  examples: {
345
347
  maxSize: {
346
348
  description: "Maximum size",
347
- react: c`
349
+ react: _`
348
350
  import { FileUpload } from "@sps-woodland/file-upload";
349
351
 
350
352
  function Component() {
@@ -360,7 +362,7 @@ const Oe = {
360
362
  },
361
363
  fileWhitelist: {
362
364
  description: "File type whitelist",
363
- react: c`
365
+ react: _`
364
366
  import { FileUpload } from "@sps-woodland/file-upload";
365
367
 
366
368
  function Component() {
@@ -381,7 +383,7 @@ const Oe = {
381
383
  },
382
384
  bothRestrictions: {
383
385
  description: "Both restrictions",
384
- react: c`
386
+ react: _`
385
387
  import { FileUpload } from "@sps-woodland/file-upload";
386
388
 
387
389
  function Component() {
@@ -408,7 +410,7 @@ const Oe = {
408
410
  description: "With this option, the file upload component can be dismissed by the user. If the user does dismiss it, you can show it again programmatically if you need to.",
409
411
  examples: {
410
412
  basic: {
411
- react: c`
413
+ react: _`
412
414
  import { FileUpload } from "@sps-woodland/file-upload";
413
415
  import { Button } from "@sps-woodland/buttons";
414
416
 
@@ -447,7 +449,7 @@ const Oe = {
447
449
  description: "You can optionally provide a button to download a file. Typically this will be a template for whatever the user is expected to upload. They can then fill out the template, save it, and upload it.",
448
450
  examples: {
449
451
  basic: {
450
- react: c`
452
+ react: _`
451
453
  import { FileUpload } from "@sps-woodland/file-upload";
452
454
 
453
455
  function Component() {
@@ -478,7 +480,7 @@ const Oe = {
478
480
  description: "When the file upload component is to be placed in a small container, it should be marked as a mini file upload so that everything fits.",
479
481
  examples: {
480
482
  basic: {
481
- react: c`
483
+ react: _`
482
484
  import { FileUpload } from "@sps-woodland/file-upload";
483
485
 
484
486
  function Component() {
@@ -503,7 +505,7 @@ const Oe = {
503
505
  description: "If this prop is provided, the content will be restricted to 50% of the overall width of the component. Consult your product designer if you're not sure whether to use this variant.",
504
506
  examples: {
505
507
  basic: {
506
- react: c`
508
+ react: _`
507
509
  import { FileUpload } from "@sps-woodland/file-upload";
508
510
 
509
511
  function Component() {
@@ -529,7 +531,7 @@ const Oe = {
529
531
  examples: {
530
532
  basic: {
531
533
  description: "Disabled File Upload",
532
- react: c`
534
+ react: _`
533
535
  import { FileUpload } from "@sps-woodland/file-upload";
534
536
 
535
537
  function Component() {
@@ -551,10 +553,10 @@ const Oe = {
551
553
  }
552
554
  }
553
555
  }
554
- }, Ie = {
556
+ }, Be = {
555
557
  "File Upload": Oe
556
558
  };
557
559
  export {
558
- W as FileUpload,
559
- Ie as MANIFEST
560
+ X as FileUpload,
561
+ Be as MANIFEST
560
562
  };
package/lib/index.umd.cjs CHANGED
@@ -1,4 +1,4 @@
1
- (function(n,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("@sps-woodland/core"),require("@spscommerce/utils"),require("@sps-woodland/buttons"),require("@sps-woodland/illustrations")):typeof define=="function"&&define.amd?define(["exports","react","@sps-woodland/core","@spscommerce/utils","@sps-woodland/buttons","@sps-woodland/illustrations"],g):(n=typeof globalThis<"u"?globalThis:n||self,g(n.FileUpload={},n.React,n.core,n.utils,n.buttons,n.illustrations))})(this,function(n,g,F,p,A,M){"use strict";function Z(o){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const l=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(i,t,l.get?l:{enumerable:!0,get:()=>o[t]})}}return i.default=o,Object.freeze(i)}const e=Z(g),B={"7Z":["application/x-7z-compressed"],AAC:["audio/aac"],ABW:["application/x-abiword"],ARC:["application/octet-stream"],AVI:["video/x-msvideo"],AZW:["application/vnd.amazon.ebook"],BIN:["application/octet-stream"],BMP:["image/bmp"],BZ:["application/x-bzip"],BZ2:["application/x-bzip2"],CER:["application/pkix-cert","application/x-x509-ca-cert"],CSH:["application/x-csh"],CSS:["text/css"],CSV:["text/csv","application/vnd.ms-excel"],DOC:["application/msword"],DOCX:["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],EML:["application/octet-stream","message/rfc822","multipart/mixed","message/rfc5322","message/rfc6532"],EOT:["application/vnd.ms-fontobject"],EPUB:["application/epub+zip"],ES:["application/ecmascript"],FLV:["video/x-flv"],GIF:["image/gif"],GZ:["application/x-gzip"],HTM:["text/html"],HTML:["text/html"],ICO:["image/x-icon"],ICS:["text/calendar"],JAR:["application/java-archive"],JPEG:["image/jpeg"],JPG:["image/jpeg"],JS:["application/javascript"],JSON:["application/json"],M3U:["audio/x-mpequrl"],MID:["audio/midi"],MIDI:["audio/midi"],MOV:["video/quicktime"],MP3:["audio/mpeg3"],MP4:["video/mp4"],MPEG:["video/mpeg"],MPKG:["application/vnd.apple.installer+xml"],ODP:["application/vnd.oasis.opendocument.presentation"],ODS:["application/vnd.oasis.opendocument.spreadsheet"],ODT:["application/vnd.oasis.opendocument.text"],OGA:["audio/ogg"],OGV:["video/ogg"],OGX:["application/ogg"],OTF:["font/otf"],PNG:["image/png"],PDF:["application/pdf"],PPT:["application/vnd.ms-powerpoint"],PPTX:["application/vnd.openxmlformats-officedocument.presentationml.presentation"],RAR:["application/x-rar-compressed"],RTF:["application/rtf"],SH:["application/x-sh"],SVG:["image/svg+xml"],SWF:["application/x-shockwave-flash"],TAR:["application/x-tar"],TIF:["image/tiff"],TIFF:["image/tiff"],TS:["application/typescript"],TTF:["font/ttf"],TXT:["text/plain"],VSD:["application/vnd.visio"],WAV:["audio/wav"],WEBA:["audio/webm"],WEBM:["video/webm"],WEBP:["image/webp"],WOFF:["font/woff"],WOFF2:["font/woff2"],XHTML:["application/xhtml+xml"],XLS:["application/vnd.ms-excel"],XLSX:["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],XML:["application/xml"],XUL:["application/vnd.mozilla.xul+xml"],ZIP:["application/zip"]};function H(o,i,t){return i in o?Object.defineProperty(o,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[i]=t,o}function I(o,i){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(o);i&&(l=l.filter(function(s){return Object.getOwnPropertyDescriptor(o,s).enumerable})),t.push.apply(t,l)}return t}function R(o){for(var i=1;i<arguments.length;i++){var t=arguments[i]!=null?arguments[i]:{};i%2?I(Object(t),!0).forEach(function(l){H(o,l,t[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):I(Object(t)).forEach(function(l){Object.defineProperty(o,l,Object.getOwnPropertyDescriptor(t,l))})}return o}var J=(o,i,t)=>{for(var l of Object.keys(o)){var s;if(o[l]!==((s=i[l])!==null&&s!==void 0?s:t[l]))return!1}return!0},y=o=>i=>{var t=o.defaultClassName,l=R(R({},o.defaultVariants),i);for(var s in l){var w,x=(w=l[s])!==null&&w!==void 0?w:o.defaultVariants[s];if(x!=null){var c=x;typeof c=="boolean"&&(c=c===!0?"true":"false");var f=o.variantClassNames[s][c];f&&(t+=" "+f)}}for(var[E,T]of o.compoundVariants)J(E,l,o.defaultVariants)&&(t+=" "+T);return t},K="pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jws",L="pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwt",Y="pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwr",Q=y({defaultClassName:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw0",variantClassNames:{active:{true:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw1",false:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw2"},mini:{true:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw3",false:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw4"},error:{true:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw5",false:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw6"},shown:{true:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw7",false:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw8"},disabled:{true:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw9",false:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwa"}},defaultVariants:{active:!1,mini:!1,error:!1,shown:!0,disabled:!1},compoundVariants:[]}),$="pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jww",ee=y({defaultClassName:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwb",variantClassNames:{constrainContentWidth:{true:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwc",false:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwd"},disabled:{true:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwe",false:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwf"}},defaultVariants:{constrainContentWidth:!1,disabled:!1},compoundVariants:[]}),oe="pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwv",ae="pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwx",te=y({defaultClassName:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwh",variantClassNames:{mini:{true:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwi",false:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwj"},error:{true:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwk",false:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwl"},disabled:{true:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwm",false:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwn"}},defaultVariants:{mini:!1,error:!1,disabled:!1},compoundVariants:[]}),le="pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwy",V="pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwg",ie="pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwu",ne=y({defaultClassName:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwo",variantClassNames:{mini:{true:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwp",false:"pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwq"}},defaultVariants:{mini:!1},compoundVariants:[]});function D({constrainContentWidth:o,description:i,multiple:t=!1,dismissable:l,processing:s,mini:w,downloadLabel:x,acceptExtensions:c,maxSize:f,customRequirement:E,onSelection:T,onDismiss:z,download:W,shown:S,className:re,disabled:_,children:De,...pe}){const U=e.useRef(new Set),[de,G]=e.useState(S),[Te,ce]=e.useState([]),[_e,fe]=e.useState(""),[X,ue]=e.useState(),[me,j]=e.useState(!1),[b,C]=e.useState(!1),[N,q]=e.useState([]),[he,ve]=e.useState(""),{t:v}=e.useContext(F.I18nContext),k=v(t?"design-system:fileUpload.instructions_plural":"design-system:fileUpload.instructions").split("|"),we=i||(t?"Files":"File"),u=e.useRef(null);e.useEffect(()=>{S&&G(S)},[S]),e.useEffect(()=>{f&&Fe(f)},[f]),e.useEffect(()=>{c&&xe(c)},[c]);function ge(){l&&(G(!1),z&&z())}function Fe(a){try{ue(p.parseFileSize(a))}catch{throw new Error(`Could not parse "${a}" as a file size.`)}}function xe(a){const m=(Array.isArray(a)?a:a.trim().split(/\s?,\s?/)).map(h=>h.replace(/^\./,"")),d=m.map(h=>`.${h}`.toLowerCase());ve(d.map((h,O)=>O>0&&O===d.length-1?`or ${h}`:h).join(d.length>2?", ":" ")),U.current.clear();for(const h of m){const O=Object.keys(B).includes(h.toUpperCase())?B[h.toUpperCase()]:[];for(const ke of O)U.current.add(ke)}fe(d.concat(Array.from(U.current)).join(","))}function P(a){q([]);let r=[];const m=Array.from(a);for(const d of m)d===null?r.push("Not a file"):(c&&!U.current.has(d.type)&&r.push(d.name),f&&X&&d.size>X&&r.indexOf(d.name)===-1&&r.push(d.name));r.length?(C(!0),u.current&&u.current.value&&(u.current.value="")):(ce(m),T(m)),q(r)}function be(a){a.preventDefault(),C(!1),u.current&&u.current.click()}function ye(){W&&W()}function Ee(a){a.stopPropagation(),P(a.target.files||[]),u.current&&u.current.value&&(u.current.value="")}function Se(a){a.preventDefault(),a.stopPropagation(),j(!0),C(!1)}function Ue(a){a.preventDefault(),j(!0),C(!1)}function je(a){a.preventDefault(),j(!1)}function Ce(a){a.preventDefault(),a.stopPropagation(),j(!1),a.dataTransfer.items?P(Array.from(a.dataTransfer.items).map(r=>r.getAsFile())):P(a.dataTransfer.files)}return e.createElement("div",{onDrop:_?()=>{}:Ce,onDragOver:_?()=>{}:Se,onDragLeave:_?()=>{}:je,onDragEnter:_?()=>{}:Ue,className:F.cl(Q({active:me,mini:w,error:b,shown:de,disabled:_}),re),...pe},e.createElement("div",{className:F.cl(ee({constrainContentWidth:o,disabled:_}))},s?e.createElement("div",null,e.createElement(F.Spinner,{size:"md","aria-hidden":"true"}),e.createElement("div",{className:V},v("design-system:fileUpload.processing"))):e.createElement("div",null,e.createElement("div",{className:te({mini:w,error:b,disabled:_}),"aria-hidden":"true"},e.createElement("img",{className:le,src:b?M.GENERAL_ERROR_LARGE:M.UPLOAD_LARGE,alt:"Upload Icon"})),e.createElement("div",{className:ne({mini:w})},b?e.createElement("div",null,v(N.length>1?"design-system:fileUpload.cancelled_plural":"design-system:fileUpload.cancelled")):e.createElement("div",null,v("design-system:fileUpload.title",{description:we}))),b?e.createElement("div",{className:Y},new Set(N.map((a,r)=>{const m=Math.floor(a.length/2);return e.createElement("div",{className:K,key:a},e.createElement("span",{className:L},a.substr(0,m)),e.createElement("div",{className:L},e.createElement("span",null,a.substr(m))),r<N.length-1?",":"")}))):e.createElement("span",null),e.createElement("div",{className:V},e.createElement("div",null,e.createElement("span",null,k[0]),_?e.createElement("u",null,k[1]):e.createElement("a",{href:"",onClick:be},k[1]),e.createElement("span",null,k[2]))),e.createElement("div",{className:ie},c?e.createElement("span",null,"("," ",v("design-system:fileUpload.acceptedTypes",{fileTypes:he})," ",")"):"",f?e.createElement("span",null,"( ",v("design-system:fileUpload.maximumSize",{size:f})," )"):"",E?e.createElement("span",null," ",E," "):""),x&&e.createElement("div",{className:oe},e.createElement(A.Button,{disabled:_,kind:"link",icon:"download-cloud",onClick:ye},x)))),l&&!s&&e.createElement("div",{className:$},e.createElement(A.Button,{disabled:_,kind:"icon",icon:"x",title:v("design-system:fileUpload.close"),onClick:ge})),e.createElement("form",{className:ae},e.createElement("input",{ref:u,type:"file",accept:_e||"*/*",multiple:t||void 0,onChange:Ee})))}F.Metadata.set(D,{name:"FileUpload",props:{constrainContentWidth:{type:"boolean"},description:{type:"string"},multiple:{type:"boolean"},dismissable:{type:"boolean"},mini:{type:"boolean"},downloadLabel:{type:"string"},acceptExtensions:{type:"string[] | string"},maxSize:{type:"string"},customRequirement:{type:"string"},onSelection:{type:"(files: File[]) => void",required:!0},dismissal:{type:"() => void"},download:{type:"() => void"},disabled:{type:"boolean"}}});const se={"File Upload":{components:[D],examples:{basic:{label:"Basic File Upload",description:"Simply allow the user to drag-and-drop or select a single file or multiple files at once.",examples:{basic:{description:"Single file upload",react:p.code`
1
+ (function(n,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("@sps-woodland/core"),require("@spscommerce/utils"),require("@sps-woodland/buttons"),require("@sps-woodland/illustrations")):typeof define=="function"&&define.amd?define(["exports","react","@sps-woodland/core","@spscommerce/utils","@sps-woodland/buttons","@sps-woodland/illustrations"],g):(n=typeof globalThis<"u"?globalThis:n||self,g(n.FileUpload={},n.React,n.core,n.utils,n.buttons,n.illustrations))})(this,function(n,g,F,p,A,M){"use strict";function J(o){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const l in o)if(l!=="default"){const t=Object.getOwnPropertyDescriptor(o,l);Object.defineProperty(i,l,t.get?t:{enumerable:!0,get:()=>o[l]})}}return i.default=o,Object.freeze(i)}const e=J(g),V={"7Z":["application/x-7z-compressed"],AAC:["audio/aac"],ABW:["application/x-abiword"],ARC:["application/octet-stream"],AVI:["video/x-msvideo"],AZW:["application/vnd.amazon.ebook"],BIN:["application/octet-stream"],BMP:["image/bmp"],BZ:["application/x-bzip"],BZ2:["application/x-bzip2"],CER:["application/pkix-cert","application/x-x509-ca-cert"],CSH:["application/x-csh"],CSS:["text/css"],CSV:["text/csv","application/vnd.ms-excel"],DOC:["application/msword"],DOCX:["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],EML:["application/octet-stream","message/rfc822","multipart/mixed","message/rfc5322","message/rfc6532"],EOT:["application/vnd.ms-fontobject"],EPUB:["application/epub+zip"],ES:["application/ecmascript"],FLV:["video/x-flv"],GIF:["image/gif"],GZ:["application/x-gzip"],HTM:["text/html"],HTML:["text/html"],ICO:["image/x-icon"],ICS:["text/calendar"],JAR:["application/java-archive"],JPEG:["image/jpeg"],JPG:["image/jpeg"],JS:["application/javascript"],JSON:["application/json"],M3U:["audio/x-mpequrl"],MID:["audio/midi"],MIDI:["audio/midi"],MOV:["video/quicktime"],MP3:["audio/mpeg3"],MP4:["video/mp4"],MPEG:["video/mpeg"],MPKG:["application/vnd.apple.installer+xml"],ODP:["application/vnd.oasis.opendocument.presentation"],ODS:["application/vnd.oasis.opendocument.spreadsheet"],ODT:["application/vnd.oasis.opendocument.text"],OGA:["audio/ogg"],OGV:["video/ogg"],OGX:["application/ogg"],OTF:["font/otf"],PNG:["image/png"],PDF:["application/pdf"],PPT:["application/vnd.ms-powerpoint"],PPTX:["application/vnd.openxmlformats-officedocument.presentationml.presentation"],RAR:["application/x-rar-compressed"],RTF:["application/rtf"],SH:["application/x-sh"],SVG:["image/svg+xml"],SWF:["application/x-shockwave-flash"],TAR:["application/x-tar"],TIF:["image/tiff"],TIFF:["image/tiff"],TS:["application/typescript"],TTF:["font/ttf"],TXT:["text/plain"],VSD:["application/vnd.visio"],WAV:["audio/wav"],WEBA:["audio/webm"],WEBM:["video/webm"],WEBP:["image/webp"],WOFF:["font/woff"],WOFF2:["font/woff2"],XHTML:["application/xhtml+xml"],XLS:["application/vnd.ms-excel"],XLSX:["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],XML:["application/xml"],XUL:["application/vnd.mozilla.xul+xml"],ZIP:["application/zip"]};function K(o,i,l){return i in o?Object.defineProperty(o,i,{value:l,enumerable:!0,configurable:!0,writable:!0}):o[i]=l,o}function B(o,i){var l=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);i&&(t=t.filter(function(s){return Object.getOwnPropertyDescriptor(o,s).enumerable})),l.push.apply(l,t)}return l}function I(o){for(var i=1;i<arguments.length;i++){var l=arguments[i]!=null?arguments[i]:{};i%2?B(Object(l),!0).forEach(function(t){K(o,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(l)):B(Object(l)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(l,t))})}return o}var Y=(o,i,l)=>{for(var t of Object.keys(o)){var s;if(o[t]!==((s=i[t])!==null&&s!==void 0?s:l[t]))return!1}return!0},b=o=>i=>{var l=o.defaultClassName,t=I(I({},o.defaultVariants),i);for(var s in t){var v,x=(v=t[s])!==null&&v!==void 0?v:o.defaultVariants[s];if(x!=null){var c=x;typeof c=="boolean"&&(c=c===!0?"true":"false");var _=o.variantClassNames[s][c];_&&(l+=" "+_)}}for(var[E,N]of o.compoundVariants)Y(E,t,o.defaultVariants)&&(l+=" "+N);return l},$="pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jws",R="pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwt",Q="pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwr",ee=b({defaultClassName:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw0",variantClassNames:{active:{true:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw1",false:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw2"},mini:{true:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw3",false:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw4"},error:{true:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw5",false:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw6"},shown:{true:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw7",false:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw8"},disabled:{true:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw9",false:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwa"}},defaultVariants:{active:!1,mini:!1,error:!1,shown:!0,disabled:!1},compoundVariants:[]}),oe="pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jww",ae=b({defaultClassName:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwb",variantClassNames:{constrainContentWidth:{true:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwc",false:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwd"},disabled:{true:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwe",false:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwf"}},defaultVariants:{constrainContentWidth:!1,disabled:!1},compoundVariants:[]}),le="pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwv",te="pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwx",ie=b({defaultClassName:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwh",variantClassNames:{mini:{true:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwi",false:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwj"},error:{true:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwk",false:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwl"},disabled:{true:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwm",false:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwn"}},defaultVariants:{mini:!1,error:!1,disabled:!1},compoundVariants:[]}),ne="pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwy",L="pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwg",se="pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwu",re=b({defaultClassName:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwo",variantClassNames:{mini:{true:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwp",false:"pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwq"}},defaultVariants:{mini:!1},compoundVariants:[]});function T({constrainContentWidth:o,description:i,multiple:l=!1,dismissable:t,processing:s,mini:v,downloadLabel:x,acceptExtensions:c,maxSize:_,customRequirement:E,onSelection:N,onDismiss:z,download:W,shown:U,className:de,disabled:f,children:De,...ce}){const S=e.useRef(new Set),[_e,G]=e.useState(U),[Te,fe]=e.useState([]),[ue,me]=e.useState(""),[X,he]=e.useState(),[we,j]=e.useState(!1),[y,C]=e.useState(!1),[k,q]=e.useState([]),[Z,ve]=e.useState(""),{t:w}=e.useContext(F.I18nContext),O=(l?w("design-system:fileUpload.instructions_plural",{defaultValue:"Drag and drop your files here or |browse for files| on your desktop."}):w("design-system:fileUpload.instructions",{defaultValue:"Drag and drop your file here or |browse for a file| on your desktop."})).split("|"),H=i||(l?"Files":"File"),u=e.useRef(null);e.useEffect(()=>{U&&G(U)},[U]),e.useEffect(()=>{_&&Fe(_)},[_]),e.useEffect(()=>{c&&xe(c)},[c]);function ge(){t&&(G(!1),z&&z())}function Fe(a){try{he(p.parseFileSize(a))}catch{throw new Error(`Could not parse "${a}" as a file size.`)}}function xe(a){const m=(Array.isArray(a)?a:a.trim().split(/\s?,\s?/)).map(h=>h.replace(/^\./,"")),d=m.map(h=>`.${h}`.toLowerCase());ve(d.map((h,D)=>D>0&&D===d.length-1?`or ${h}`:h).join(d.length>2?", ":" ")),S.current.clear();for(const h of m){const D=Object.keys(V).includes(h.toUpperCase())?V[h.toUpperCase()]:[];for(const ke of D)S.current.add(ke)}me(d.concat(Array.from(S.current)).join(","))}function P(a){q([]);let r=[];const m=Array.from(a);for(const d of m)d===null?r.push("Not a file"):(c&&!S.current.has(d.type)&&r.push(d.name),_&&X&&d.size>X&&r.indexOf(d.name)===-1&&r.push(d.name));r.length?(C(!0),u.current&&u.current.value&&(u.current.value="")):(fe(m),N(m)),q(r)}function ye(a){a.preventDefault(),C(!1),u.current&&u.current.click()}function be(){W&&W()}function Ee(a){a.stopPropagation(),P(a.target.files||[]),u.current&&u.current.value&&(u.current.value="")}function Ue(a){a.preventDefault(),a.stopPropagation(),j(!0),C(!1)}function Se(a){a.preventDefault(),j(!0),C(!1)}function je(a){a.preventDefault(),j(!1)}function Ce(a){a.preventDefault(),a.stopPropagation(),j(!1),a.dataTransfer.items?P(Array.from(a.dataTransfer.items).map(r=>r.getAsFile())):P(a.dataTransfer.files)}return e.createElement("div",{onDrop:f?()=>{}:Ce,onDragOver:f?()=>{}:Ue,onDragLeave:f?()=>{}:je,onDragEnter:f?()=>{}:Se,className:F.cl(ee({active:we,mini:v,error:y,shown:_e,disabled:f}),de),...ce},e.createElement("div",{className:F.cl(ae({constrainContentWidth:o,disabled:f}))},s?e.createElement("div",null,e.createElement(F.Spinner,{size:"md","aria-hidden":"true"}),e.createElement("div",{className:L},w("design-system:fileUpload.processing",{defaultValue:"Processing Upload..."}))):e.createElement("div",null,e.createElement("div",{className:ie({mini:v,error:y,disabled:f}),"aria-hidden":"true"},e.createElement("img",{className:ne,src:y?M.GENERAL_ERROR_LARGE:M.UPLOAD_LARGE,alt:"Upload Icon"})),e.createElement("div",{className:re({mini:v})},y?e.createElement("div",null,w(k.length>1?"design-system:fileUpload.cancelled_plural":"design-system:fileUpload.cancelled",{defaultValue:k.length>1?"File Upload(s) Failed":"File Upload Failed"})):e.createElement("div",null,w("design-system:fileUpload.title",{description:H,defaultValue:`Upload your ${H}`}))),y?e.createElement("div",{className:Q},new Set(k.map((a,r)=>{const m=Math.floor(a.length/2);return e.createElement("div",{className:$,key:a},e.createElement("span",{className:R},a.substr(0,m)),e.createElement("div",{className:R},e.createElement("span",null,a.substr(m))),r<k.length-1?",":"")}))):e.createElement("span",null),e.createElement("div",{className:L},e.createElement("div",null,e.createElement("span",null,O[0]),f?e.createElement("u",null,O[1]):e.createElement("a",{href:"",onClick:ye},O[1]),e.createElement("span",null,O[2]))),e.createElement("div",{className:se},c?e.createElement("span",null,"("," ",w("design-system:fileUpload.acceptedTypes",{fileTypes:Z,defaultValue:`${Z} format accepted`})," ",")"):"",_?e.createElement("span",null,"( ",w("design-system:fileUpload.maximumSize",{size:_,defaultValue:`${_} maximum`})," )"):"",E?e.createElement("span",null," ",E," "):""),x&&e.createElement("div",{className:le},e.createElement(A.Button,{disabled:f,kind:"link",icon:"download-cloud",onClick:be},x)))),t&&!s&&e.createElement("div",{className:oe},e.createElement(A.Button,{disabled:f,kind:"icon",icon:"x",title:w("design-system:fileUpload.close",{defaultValue:"Close"}),onClick:ge})),e.createElement("form",{className:te},e.createElement("input",{ref:u,type:"file",accept:ue||"*/*",multiple:l||void 0,onChange:Ee})))}F.Metadata.set(T,{name:"FileUpload",props:{constrainContentWidth:{type:"boolean"},description:{type:"string"},multiple:{type:"boolean"},dismissable:{type:"boolean"},mini:{type:"boolean"},downloadLabel:{type:"string"},acceptExtensions:{type:"string[] | string"},maxSize:{type:"string"},customRequirement:{type:"string"},onSelection:{type:"(files: File[]) => void",required:!0},dismissal:{type:"() => void"},download:{type:"() => void"},disabled:{type:"boolean"}}});const pe={"File Upload":{components:[T],examples:{basic:{label:"Basic File Upload",description:"Simply allow the user to drag-and-drop or select a single file or multiple files at once.",examples:{basic:{description:"Single file upload",react:p.code`
2
2
  import { FileUpload } from "@sps-woodland/file-upload";
3
3
 
4
4
  function Component() {
@@ -170,4 +170,4 @@
170
170
  onSelection={selectFile} />
171
171
  )
172
172
  }
173
- `}}}}}};n.FileUpload=D,n.MANIFEST=se,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
173
+ `}}}}}};n.FileUpload=T,n.MANIFEST=pe,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
package/lib/style.css CHANGED
@@ -1 +1 @@
1
- .pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw0{border-width:.0625rem;border-style:dashed;border-radius:.25rem;display:block;padding:1rem;position:relative}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw1{background-color:#f4ecf2;border-color:#91467f;border-style:solid}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw3{padding:1rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw5{border-color:#de012e}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw8{display:none}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jw9{border-color:#d2d4d4}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwb{color:#4b5356;margin:0 auto;text-align:center}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwc{width:50%}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwe{color:#717779}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwg{font-size:.75rem;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwh{color:#717779;display:block;margin-bottom:1rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwi{font-size:1.5rem;line-height:1.5rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwj{font-size:3rem;line-height:3rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwk{color:#de012e}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwm{opacity:.5}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwo{font-weight:600;margin-bottom:.25rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwp{font-size:1rem;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwq{font-size:1.125rem;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwr{font-size:.875rem;font-weight:600;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jws{display:flex;justify-content:center;white-space:nowrap}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwt{max-width:50%;overflow:hidden}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwt:first-child{text-overflow:ellipsis}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwt:last-child{float:right}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwu{font-size:.75rem;line-height:1.125rem;margin-top:.25rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwu>span+span{margin-left:.125rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwv{margin-top:1rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jww{position:absolute;right:.5rem;top:.5rem}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwx{display:none}.pkg_sps-woodland_file-upload__version_8_26_1__hash_rh07jwy{height:3rem}
1
+ .pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw0{border-width:.0625rem;border-style:dashed;border-radius:.25rem;display:block;padding:1rem;position:relative}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw1{background-color:#f4ecf2;border-color:#91467f;border-style:solid}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw3{padding:1rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw5{border-color:#de012e}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw8{display:none}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jw9{border-color:#d2d4d4}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwb{color:#4b5356;margin:0 auto;text-align:center}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwc{width:50%}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwe{color:#717779}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwg{font-size:.75rem;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwh{color:#717779;display:block;margin-bottom:1rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwi{font-size:1.5rem;line-height:1.5rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwj{font-size:3rem;line-height:3rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwk{color:#de012e}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwm{opacity:.5}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwo{font-weight:600;margin-bottom:.25rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwp{font-size:1rem;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwq{font-size:1.125rem;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwr{font-size:.875rem;font-weight:600;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jws{display:flex;justify-content:center;white-space:nowrap}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwt{max-width:50%;overflow:hidden}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwt:first-child{text-overflow:ellipsis}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwt:last-child{float:right}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwu{font-size:.75rem;line-height:1.125rem;margin-top:.25rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwu>span+span{margin-left:.125rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwv{margin-top:1rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jww{position:absolute;right:.5rem;top:.5rem}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwx{display:none}.pkg_sps-woodland_file-upload__version_8_26_2__hash_rh07jwy{height:3rem}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sps-woodland/file-upload",
3
3
  "description": "SPS Woodland Design System file upload component",
4
- "version": "8.26.1",
4
+ "version": "8.26.2",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/file-upload",
@@ -30,12 +30,12 @@
30
30
  "@spscommerce/utils": "^7.0.0",
31
31
  "react": "^16.14.0",
32
32
  "react-dom": "^16.14.0",
33
- "@sps-woodland/buttons": "8.26.1",
34
- "@sps-woodland/core": "8.26.1",
35
- "@sps-woodland/tokens": "8.26.1",
36
- "@sps-woodland/illustrations": "8.26.1",
37
- "@spscommerce/ds-react": "8.26.1",
38
- "@spscommerce/ds-shared": "8.26.1"
33
+ "@sps-woodland/buttons": "8.26.2",
34
+ "@sps-woodland/core": "8.26.2",
35
+ "@sps-woodland/tokens": "8.26.2",
36
+ "@sps-woodland/illustrations": "8.26.2",
37
+ "@spscommerce/ds-react": "8.26.2",
38
+ "@spscommerce/ds-shared": "8.26.2"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@spscommerce/ds-illustrations": "^6.12.1",
@@ -44,13 +44,13 @@
44
44
  "@vanilla-extract/recipes": "^0.2.5",
45
45
  "react": "^16.14.0",
46
46
  "react-dom": "^16.14.0",
47
- "@sps-woodland/buttons": "8.26.1",
48
- "@sps-woodland/core": "8.26.1",
49
- "@sps-woodland/tokens": "8.26.1",
50
- "@spscommerce/ds-colors": "8.26.1",
51
- "@sps-woodland/illustrations": "8.26.1",
52
- "@spscommerce/ds-react": "8.26.1",
53
- "@spscommerce/ds-shared": "8.26.1"
47
+ "@sps-woodland/buttons": "8.26.2",
48
+ "@sps-woodland/core": "8.26.2",
49
+ "@sps-woodland/tokens": "8.26.2",
50
+ "@spscommerce/ds-colors": "8.26.2",
51
+ "@sps-woodland/illustrations": "8.26.2",
52
+ "@spscommerce/ds-react": "8.26.2",
53
+ "@spscommerce/ds-shared": "8.26.2"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "pnpm run build:js && pnpm run build:types",