@sps-woodland/file-upload 7.2.7 → 7.2.8

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.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const ue=require("react"),w=require("@sps-woodland/core"),d=require("@spscommerce/utils"),G=require("@spscommerce/ds-react"),O=require("@spscommerce/ds-shared");function fe(e){if(e&&e.__esModule)return e;const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(l,a,o.get?o:{enumerable:!0,get:()=>e[a]})}}return l.default=e,Object.freeze(l)}const t=fe(ue);var V=(e=>(e["7Z"]="application/x-7z-compressed",e.AAC="audio/aac",e.ABW="application/x-abiword",e.ARC="application/octet-stream",e.AVI="video/x-msvideo",e.AZW="application/vnd.amazon.ebook",e.BIN="application/octet-stream",e.BMP="image/bmp",e.BZ="application/x-bzip",e.BZ2="application/x-bzip2",e.CSH="application/x-csh",e.CSS="text/css",e.CSV="text/csv,application/vnd.ms-excel",e.DOC="application/msword",e.DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",e.EOT="application/vnd.ms-fontobject",e.EPUB="application/epub+zip",e.ES="application/ecmascript",e.FLV="video/x-flv",e.GIF="image/gif",e.GZ="application/x-gzip",e.HTM="text/html",e.HTML="text/html",e.ICO="image/x-icon",e.ICS="text/calendar",e.JAR="application/java-archive",e.JPEG="image/jpeg",e.JPG="image/jpeg",e.JS="application/javascript",e.JSON="application/json",e.M3U="audio/x-mpequrl",e.MID="audio/midi",e.MIDI="audio/midi",e.MOV="video/quicktime",e.MP3="audio/mpeg3",e.MP4="video/mp4",e.MPEG="video/mpeg",e.MPKG="application/vnd.apple.installer+xml",e.ODP="application/vnd.oasis.opendocument.presentation",e.ODS="application/vnd.oasis.opendocument.spreadsheet",e.ODT="application/vnd.oasis.opendocument.text",e.OGA="audio/ogg",e.OGV="video/ogg",e.OGX="application/ogg",e.OTF="font/otf",e.PNG="image/png",e.PDF="application/pdf",e.PPT="application/vnd.ms-powerpoint",e.PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",e.RAR="application/x-rar-compressed",e.RTF="application/rtf",e.SH="application/x-sh",e.SVG="image/svg+xml",e.SWF="application/x-shockwave-flash",e.TAR="application/x-tar",e.TIF="image/tiff",e.TIFF="image/tiff",e.TS="application/typescript",e.TTF="font/ttf",e.TXT="text/plain",e.VSD="application/vnd.visio",e.WAV="audio/wav",e.WEBA="audio/webm",e.WEBM="video/webm",e.WEBP="image/webp",e.WOFF="font/woff",e.WOFF2="font/woff2",e.XHTML="application/xhtml+xml",e.XLS="application/vnd.ms-excel",e.XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",e.XML="application/xml",e.XUL="application/vnd.mozilla.xul+xml",e.ZIP="application/zip",e))(V||{});function me(e,l,a){return l in e?Object.defineProperty(e,l,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[l]=a,e}function _(e,l){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);l&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,o)}return a}function q(e){for(var l=1;l<arguments.length;l++){var a=arguments[l]!=null?arguments[l]:{};l%2?_(Object(a),!0).forEach(function(o){me(e,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):_(Object(a)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(a,o))})}return e}var he=(e,l,a)=>{for(var o of Object.keys(e)){var n;if(e[o]!==((n=l[o])!==null&&n!==void 0?n:a[o]))return!1}return!0},D=e=>l=>{var a=e.defaultClassName,o=q(q({},e.defaultVariants),l);for(var n in o){var h,g=(h=o[n])!==null&&h!==void 0?h:e.defaultVariants[n];if(g!=null){var c=g;typeof c=="boolean"&&(c=c===!0?"true":"false");var p=e.variantClassNames[n][c];p&&(a+=" "+p)}}for(var[S,N]of e.compoundVariants)he(S,o,e.defaultVariants)&&(a+=" "+N);return a},ve="rh07jwm",K="rh07jwn",we="rh07jwl",ge=D({defaultClassName:"rh07jw0",variantClassNames:{active:{true:"rh07jw1",false:"rh07jw2"},mini:{true:"rh07jw3",false:"rh07jw4"},error:{true:"rh07jw5",false:"rh07jw6"},shown:{true:"rh07jw7",false:"rh07jw8"}},defaultVariants:{active:!1,mini:!1,error:!1,shown:!0},compoundVariants:[]}),Fe="rh07jwq",Se=D({defaultClassName:"rh07jw9",variantClassNames:{constrainContentWidth:{true:"rh07jwa",false:"rh07jwb"}},defaultVariants:{constrainContentWidth:!1},compoundVariants:[]}),be="rh07jwp",xe="rh07jwr",Ue=D({defaultClassName:"rh07jwd",variantClassNames:{mini:{true:"rh07jwe",false:"rh07jwf"},error:{true:"rh07jwg",false:"rh07jwh"}},defaultVariants:{mini:!1,error:!1},compoundVariants:[]}),Z="rh07jwc",Ce="rh07jwo",je=D({defaultClassName:"rh07jwi",variantClassNames:{mini:{true:"rh07jwj",false:"rh07jwk"}},defaultVariants:{mini:!1},compoundVariants:[]});function W({constrainContentWidth:e,description:l,multiple:a=!1,dismissable:o,processing:n,mini:h,downloadLabel:g,acceptExtensions:c,maxSize:p,customRequirement:S,onSelection:N,onDismiss:z,download:L,shown:b,className:H,children:Ne,...J}){const x=t.useRef(new Set),[Y,R]=t.useState(b),[Pe,Q]=t.useState([]),[$,y]=t.useState(""),[k,E]=t.useState(),[T,U]=t.useState(!1),[F,C]=t.useState(!1),[P,X]=t.useState([]),[I,M]=t.useState(""),{t:m}=t.useContext(w.I18nContext),A=m(a?"design-system:fileUpload.instructions_plural":"design-system:fileUpload.instructions").split("|"),ee=l||(a?"Files":"File"),v=t.useRef(null);t.useEffect(()=>{b&&R(b)},[b]),t.useEffect(()=>{p&&ie(p)},[p]),t.useEffect(()=>{c&&ae(c)},[c]);function te(){o&&(R(!1),z&&z())}function ie(i){try{E(d.parseFileSize(i))}catch{throw new Error(`Could not parse "${i}" as a file size.`)}}function ae(i){const u=(Array.isArray(i)?i:i.trim().split(/\s?,\s?/)).map(f=>f.replace(/^\./,"")),r=u.map(f=>`.${f}`.toLowerCase());M(r.map((f,j)=>j>0&&j===r.length-1?`or ${f}`:f).join(r.length>2?", ":" ")),x.current.clear();for(const f of u){const j=Object.keys(V).includes(f.toUpperCase())?V[f.toUpperCase()].split(","):[];for(const pe of j)x.current.add(pe)}y(r.concat(Array.from(x.current)).join(","))}function B(i){X([]);let s=[];const u=Array.from(i);for(const r of u)r===null?s.push("Not a file"):(c&&!x.current.has(r.type)&&s.push(r.name),p&&k&&r.size>k&&s.indexOf(r.name)===-1&&s.push(r.name));s.length?(C(!0),v.current&&v.current.value&&(v.current.value="")):(Q(u),N(u)),X(s)}function oe(i){i.preventDefault(),C(!1),v.current&&v.current.click()}function le(){L&&L()}function ne(i){i.stopPropagation(),B(i.target.files||[])}function se(i){i.preventDefault(),i.stopPropagation(),U(!0),C(!1)}function re(i){i.preventDefault(),U(!0),C(!1)}function ce(i){i.preventDefault(),U(!1)}function de(i){i.preventDefault(),i.stopPropagation(),U(!1),i.dataTransfer.items?B(Array.from(i.dataTransfer.items).map(s=>s.getAsFile())):B(i.dataTransfer.files)}return t.createElement("div",{onDrop:de,onDragOver:se,onDragLeave:ce,onDragEnter:re,className:w.cl(ge({active:T,mini:h,error:F,shown:Y}),H),...J},t.createElement("div",{className:w.cl(Se({constrainContentWidth:e}))},n?t.createElement("div",null,t.createElement(w.Spinner,{size:"md","aria-hidden":"true"}),t.createElement("div",{className:Z},m("design-system:fileUpload.processing"))):t.createElement("div",null,t.createElement(w.Icon,{className:Ue({mini:h,error:F}),icon:F?"exclamation-circle":"upload-cloud","aria-hidden":"true"}),t.createElement("div",{className:je({mini:h})},F?t.createElement("div",null,m(P.length>1?"design-system:fileUpload.cancelled_plural":"design-system:fileUpload.cancelled")):t.createElement("div",null,m("design-system:fileUpload.title",{description:ee}))),F?t.createElement("div",{className:we},new Set(P.map((i,s)=>{const u=Math.floor(i.length/2);return t.createElement("div",{className:ve,key:i},t.createElement("span",{className:K},i.substr(0,u)),t.createElement("div",{className:K},t.createElement("span",null,i.substr(u))),s<P.length-1?",":"")}))):t.createElement("span",null),t.createElement("div",{className:Z},t.createElement("div",null,t.createElement("span",null,A[0]),t.createElement("a",{href:"",onClick:oe},A[1]),t.createElement("span",null,A[2]))),t.createElement("div",{className:Ce},c?t.createElement("span",null,"("," ",m("design-system:fileUpload.acceptedTypes",{fileTypes:I})," ",")"):"",p?t.createElement("span",null,"( ",m("design-system:fileUpload.maximumSize",{size:p})," )"):"",S?t.createElement("span",null," ",S," "):""),g&&t.createElement("div",{className:be},t.createElement(G.SpsButton,{kind:O.ButtonKind.LINK,icon:O.SpsIcon.DOWNLOAD_CLOUD,onClick:le},g)))),o&&!n&&t.createElement("div",{className:Fe},t.createElement(G.SpsButton,{kind:O.ButtonKind.ICON,icon:O.SpsIcon.X,title:m("design-system:fileUpload.close"),onClick:te})),t.createElement("form",{className:xe},t.createElement("input",{ref:v,type:"file",accept:$||"*/*",multiple:a||void 0,onChange:ne})))}w.Metadata.set(W,{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"}}});const Oe={components:[W],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:d.code`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const ue=require("react"),w=require("@sps-woodland/core"),d=require("@spscommerce/utils"),G=require("@spscommerce/ds-react"),O=require("@spscommerce/ds-shared");function fe(e){if(e&&e.__esModule)return e;const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const l=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(o,a,l.get?l:{enumerable:!0,get:()=>e[a]})}}return o.default=e,Object.freeze(o)}const t=fe(ue);var V=(e=>(e["7Z"]="application/x-7z-compressed",e.AAC="audio/aac",e.ABW="application/x-abiword",e.ARC="application/octet-stream",e.AVI="video/x-msvideo",e.AZW="application/vnd.amazon.ebook",e.BIN="application/octet-stream",e.BMP="image/bmp",e.BZ="application/x-bzip",e.BZ2="application/x-bzip2",e.CSH="application/x-csh",e.CSS="text/css",e.CSV="text/csv,application/vnd.ms-excel",e.DOC="application/msword",e.DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",e.EOT="application/vnd.ms-fontobject",e.EPUB="application/epub+zip",e.ES="application/ecmascript",e.FLV="video/x-flv",e.GIF="image/gif",e.GZ="application/x-gzip",e.HTM="text/html",e.HTML="text/html",e.ICO="image/x-icon",e.ICS="text/calendar",e.JAR="application/java-archive",e.JPEG="image/jpeg",e.JPG="image/jpeg",e.JS="application/javascript",e.JSON="application/json",e.M3U="audio/x-mpequrl",e.MID="audio/midi",e.MIDI="audio/midi",e.MOV="video/quicktime",e.MP3="audio/mpeg3",e.MP4="video/mp4",e.MPEG="video/mpeg",e.MPKG="application/vnd.apple.installer+xml",e.ODP="application/vnd.oasis.opendocument.presentation",e.ODS="application/vnd.oasis.opendocument.spreadsheet",e.ODT="application/vnd.oasis.opendocument.text",e.OGA="audio/ogg",e.OGV="video/ogg",e.OGX="application/ogg",e.OTF="font/otf",e.PNG="image/png",e.PDF="application/pdf",e.PPT="application/vnd.ms-powerpoint",e.PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",e.RAR="application/x-rar-compressed",e.RTF="application/rtf",e.SH="application/x-sh",e.SVG="image/svg+xml",e.SWF="application/x-shockwave-flash",e.TAR="application/x-tar",e.TIF="image/tiff",e.TIFF="image/tiff",e.TS="application/typescript",e.TTF="font/ttf",e.TXT="text/plain",e.VSD="application/vnd.visio",e.WAV="audio/wav",e.WEBA="audio/webm",e.WEBM="video/webm",e.WEBP="image/webp",e.WOFF="font/woff",e.WOFF2="font/woff2",e.XHTML="application/xhtml+xml",e.XLS="application/vnd.ms-excel",e.XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",e.XML="application/xml",e.XUL="application/vnd.mozilla.xul+xml",e.ZIP="application/zip",e))(V||{});function me(e,o,a){return o in e?Object.defineProperty(e,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[o]=a,e}function _(e,o){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);o&&(l=l.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,l)}return a}function q(e){for(var o=1;o<arguments.length;o++){var a=arguments[o]!=null?arguments[o]:{};o%2?_(Object(a),!0).forEach(function(l){me(e,l,a[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):_(Object(a)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(a,l))})}return e}var he=(e,o,a)=>{for(var l of Object.keys(e)){var n;if(e[l]!==((n=o[l])!==null&&n!==void 0?n:a[l]))return!1}return!0},D=e=>o=>{var a=e.defaultClassName,l=q(q({},e.defaultVariants),o);for(var n in l){var v,g=(v=l[n])!==null&&v!==void 0?v:e.defaultVariants[n];if(g!=null){var c=g;typeof c=="boolean"&&(c=c===!0?"true":"false");var p=e.variantClassNames[n][c];p&&(a+=" "+p)}}for(var[S,N]of e.compoundVariants)he(S,l,e.defaultVariants)&&(a+=" "+N);return a},ve="rh07jwm",K="rh07jwn",we="rh07jwl",ge=D({defaultClassName:"rh07jw0",variantClassNames:{active:{true:"rh07jw1",false:"rh07jw2"},mini:{true:"rh07jw3",false:"rh07jw4"},error:{true:"rh07jw5",false:"rh07jw6"},shown:{true:"rh07jw7",false:"rh07jw8"}},defaultVariants:{active:!1,mini:!1,error:!1,shown:!0},compoundVariants:[]}),Fe="rh07jwq",Se=D({defaultClassName:"rh07jw9",variantClassNames:{constrainContentWidth:{true:"rh07jwa",false:"rh07jwb"}},defaultVariants:{constrainContentWidth:!1},compoundVariants:[]}),be="rh07jwp",xe="rh07jwr",Ue=D({defaultClassName:"rh07jwd",variantClassNames:{mini:{true:"rh07jwe",false:"rh07jwf"},error:{true:"rh07jwg",false:"rh07jwh"}},defaultVariants:{mini:!1,error:!1},compoundVariants:[]}),Z="rh07jwc",Ce="rh07jwo",je=D({defaultClassName:"rh07jwi",variantClassNames:{mini:{true:"rh07jwj",false:"rh07jwk"}},defaultVariants:{mini:!1},compoundVariants:[]});function W({constrainContentWidth:e,description:o,multiple:a=!1,dismissable:l,processing:n,mini:v,downloadLabel:g,acceptExtensions:c,maxSize:p,customRequirement:S,onSelection:N,onDismiss:z,download:L,shown:b,className:H,children:Ne,...J}){const x=t.useRef(new Set),[Y,R]=t.useState(b),[Pe,Q]=t.useState([]),[$,y]=t.useState(""),[k,E]=t.useState(),[T,U]=t.useState(!1),[F,C]=t.useState(!1),[P,X]=t.useState([]),[I,M]=t.useState(""),{t:h}=t.useContext(w.I18nContext),A=h(a?"design-system:fileUpload.instructions_plural":"design-system:fileUpload.instructions").split("|"),ee=o||(a?"Files":"File"),u=t.useRef(null);t.useEffect(()=>{b&&R(b)},[b]),t.useEffect(()=>{p&&ie(p)},[p]),t.useEffect(()=>{c&&ae(c)},[c]);function te(){l&&(R(!1),z&&z())}function ie(i){try{E(d.parseFileSize(i))}catch{throw new Error(`Could not parse "${i}" as a file size.`)}}function ae(i){const f=(Array.isArray(i)?i:i.trim().split(/\s?,\s?/)).map(m=>m.replace(/^\./,"")),r=f.map(m=>`.${m}`.toLowerCase());M(r.map((m,j)=>j>0&&j===r.length-1?`or ${m}`:m).join(r.length>2?", ":" ")),x.current.clear();for(const m of f){const j=Object.keys(V).includes(m.toUpperCase())?V[m.toUpperCase()].split(","):[];for(const pe of j)x.current.add(pe)}y(r.concat(Array.from(x.current)).join(","))}function B(i){X([]);let s=[];const f=Array.from(i);for(const r of f)r===null?s.push("Not a file"):(c&&!x.current.has(r.type)&&s.push(r.name),p&&k&&r.size>k&&s.indexOf(r.name)===-1&&s.push(r.name));s.length?(C(!0),u.current&&u.current.value&&(u.current.value="")):(Q(f),N(f)),X(s)}function le(i){i.preventDefault(),C(!1),u.current&&u.current.click()}function oe(){L&&L()}function ne(i){i.stopPropagation(),B(i.target.files||[]),u.current&&u.current.value&&(u.current.value="")}function se(i){i.preventDefault(),i.stopPropagation(),U(!0),C(!1)}function re(i){i.preventDefault(),U(!0),C(!1)}function ce(i){i.preventDefault(),U(!1)}function de(i){i.preventDefault(),i.stopPropagation(),U(!1),i.dataTransfer.items?B(Array.from(i.dataTransfer.items).map(s=>s.getAsFile())):B(i.dataTransfer.files)}return t.createElement("div",{onDrop:de,onDragOver:se,onDragLeave:ce,onDragEnter:re,className:w.cl(ge({active:T,mini:v,error:F,shown:Y}),H),...J},t.createElement("div",{className:w.cl(Se({constrainContentWidth:e}))},n?t.createElement("div",null,t.createElement(w.Spinner,{size:"md","aria-hidden":"true"}),t.createElement("div",{className:Z},h("design-system:fileUpload.processing"))):t.createElement("div",null,t.createElement(w.Icon,{className:Ue({mini:v,error:F}),icon:F?"exclamation-circle":"upload-cloud","aria-hidden":"true"}),t.createElement("div",{className:je({mini:v})},F?t.createElement("div",null,h(P.length>1?"design-system:fileUpload.cancelled_plural":"design-system:fileUpload.cancelled")):t.createElement("div",null,h("design-system:fileUpload.title",{description:ee}))),F?t.createElement("div",{className:we},new Set(P.map((i,s)=>{const f=Math.floor(i.length/2);return t.createElement("div",{className:ve,key:i},t.createElement("span",{className:K},i.substr(0,f)),t.createElement("div",{className:K},t.createElement("span",null,i.substr(f))),s<P.length-1?",":"")}))):t.createElement("span",null),t.createElement("div",{className:Z},t.createElement("div",null,t.createElement("span",null,A[0]),t.createElement("a",{href:"",onClick:le},A[1]),t.createElement("span",null,A[2]))),t.createElement("div",{className:Ce},c?t.createElement("span",null,"("," ",h("design-system:fileUpload.acceptedTypes",{fileTypes:I})," ",")"):"",p?t.createElement("span",null,"( ",h("design-system:fileUpload.maximumSize",{size:p})," )"):"",S?t.createElement("span",null," ",S," "):""),g&&t.createElement("div",{className:be},t.createElement(G.SpsButton,{kind:O.ButtonKind.LINK,icon:O.SpsIcon.DOWNLOAD_CLOUD,onClick:oe},g)))),l&&!n&&t.createElement("div",{className:Fe},t.createElement(G.SpsButton,{kind:O.ButtonKind.ICON,icon:O.SpsIcon.X,title:h("design-system:fileUpload.close"),onClick:te})),t.createElement("form",{className:xe},t.createElement("input",{ref:u,type:"file",accept:$||"*/*",multiple:a||void 0,onChange:ne})))}w.Metadata.set(W,{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"}}});const Oe={components:[W],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:d.code`
2
2
  import { FileUpload } from "@sps-woodland/file-upload";
3
3
 
4
4
  function Component() {
package/lib/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as t from "react";
2
- import { Metadata as me, I18nContext as ue, cl as R, Spinner as he, Icon as ve } from "@sps-woodland/core";
2
+ import { Metadata as ue, I18nContext as me, cl as R, Spinner as he, Icon as ve } from "@sps-woodland/core";
3
3
  import { parseFileSize as we, code as m } from "@spscommerce/utils";
4
4
  import { SpsButton as X } from "@spscommerce/ds-react";
5
5
  import { ButtonKind as k, SpsIcon as G } from "@spscommerce/ds-shared";
@@ -43,7 +43,7 @@ var Fe = (e, o, a) => {
43
43
  }, j = (e) => (o) => {
44
44
  var a = e.defaultClassName, l = Z(Z({}, e.defaultVariants), o);
45
45
  for (var n in l) {
46
- var h, w = (h = l[n]) !== null && h !== void 0 ? h : e.defaultVariants[n];
46
+ var v, w = (v = l[n]) !== null && v !== void 0 ? v : e.defaultVariants[n];
47
47
  if (w != null) {
48
48
  var c = w;
49
49
  typeof c == "boolean" && (c = c === !0 ? "true" : "false");
@@ -61,7 +61,7 @@ function J({
61
61
  multiple: a = !1,
62
62
  dismissable: l,
63
63
  processing: n,
64
- mini: h,
64
+ mini: v,
65
65
  downloadLabel: w,
66
66
  acceptExtensions: c,
67
67
  maxSize: p,
@@ -74,7 +74,7 @@ function J({
74
74
  children: Be,
75
75
  ...Y
76
76
  }) {
77
- const S = t.useRef(/* @__PURE__ */ new Set()), [Q, W] = t.useState(x), [Ve, $] = t.useState([]), [y, E] = t.useState(""), [L, T] = t.useState(), [I, b] = t.useState(!1), [g, U] = t.useState(!1), [D, z] = t.useState([]), [M, ee] = t.useState(""), { t: u } = t.useContext(ue), N = u(a ? "design-system:fileUpload.instructions_plural" : "design-system:fileUpload.instructions").split("|"), te = o || (a ? "Files" : "File"), v = t.useRef(null);
77
+ const S = t.useRef(/* @__PURE__ */ new Set()), [Q, W] = t.useState(x), [Ve, $] = t.useState([]), [y, E] = t.useState(""), [L, T] = t.useState(), [I, b] = t.useState(!1), [g, U] = t.useState(!1), [D, z] = t.useState([]), [M, ee] = t.useState(""), { t: h } = t.useContext(me), N = h(a ? "design-system:fileUpload.instructions_plural" : "design-system:fileUpload.instructions").split("|"), te = o || (a ? "Files" : "File"), d = t.useRef(null);
78
78
  t.useEffect(() => {
79
79
  x && W(x);
80
80
  }, [x]), t.useEffect(() => {
@@ -93,12 +93,12 @@ function J({
93
93
  }
94
94
  }
95
95
  function le(i) {
96
- const d = (Array.isArray(i) ? i : i.trim().split(/\s?,\s?/)).map((f) => f.replace(/^\./, "")), r = d.map((f) => `.${f}`.toLowerCase());
96
+ const f = (Array.isArray(i) ? i : i.trim().split(/\s?,\s?/)).map((u) => u.replace(/^\./, "")), r = f.map((u) => `.${u}`.toLowerCase());
97
97
  ee(
98
- r.map((f, C) => C > 0 && C === r.length - 1 ? `or ${f}` : f).join(r.length > 2 ? ", " : " ")
98
+ r.map((u, C) => C > 0 && C === r.length - 1 ? `or ${u}` : u).join(r.length > 2 ? ", " : " ")
99
99
  ), S.current.clear();
100
- for (const f of d) {
101
- const C = Object.keys(A).includes(f.toUpperCase()) ? A[f.toUpperCase()].split(",") : [];
100
+ for (const u of f) {
101
+ const C = Object.keys(A).includes(u.toUpperCase()) ? A[u.toUpperCase()].split(",") : [];
102
102
  for (const fe of C)
103
103
  S.current.add(fe);
104
104
  }
@@ -107,19 +107,19 @@ function J({
107
107
  function P(i) {
108
108
  z([]);
109
109
  let s = [];
110
- const d = Array.from(i);
111
- for (const r of d)
110
+ const f = Array.from(i);
111
+ for (const r of f)
112
112
  r === null ? s.push("Not a file") : (c && !S.current.has(r.type) && s.push(r.name), p && L && r.size > L && s.indexOf(r.name) === -1 && s.push(r.name));
113
- s.length ? (U(!0), v.current && v.current.value && (v.current.value = "")) : ($(d), O(d)), z(s);
113
+ s.length ? (U(!0), d.current && d.current.value && (d.current.value = "")) : ($(f), O(f)), z(s);
114
114
  }
115
115
  function oe(i) {
116
- i.preventDefault(), U(!1), v.current && v.current.click();
116
+ i.preventDefault(), U(!1), d.current && d.current.click();
117
117
  }
118
118
  function ne() {
119
119
  V && V();
120
120
  }
121
121
  function se(i) {
122
- i.stopPropagation(), P(i.target.files || []);
122
+ i.stopPropagation(), P(i.target.files || []), d.current && d.current.value && (d.current.value = "");
123
123
  }
124
124
  function re(i) {
125
125
  i.preventDefault(), i.stopPropagation(), b(!0), U(!1);
@@ -142,7 +142,7 @@ function J({
142
142
  onDragOver: re,
143
143
  onDragLeave: pe,
144
144
  onDragEnter: ce,
145
- className: R(be({ active: I, mini: h, error: g, shown: Q }), _),
145
+ className: R(be({ active: I, mini: v, error: g, shown: Q }), _),
146
146
  ...Y
147
147
  }, /* @__PURE__ */ t.createElement("div", {
148
148
  className: R(Ce({ constrainContentWidth: e }))
@@ -151,27 +151,27 @@ function J({
151
151
  "aria-hidden": "true"
152
152
  }), /* @__PURE__ */ t.createElement("div", {
153
153
  className: H
154
- }, u("design-system:fileUpload.processing"))) : /* @__PURE__ */ t.createElement("div", null, /* @__PURE__ */ t.createElement(ve, {
155
- className: De({ mini: h, error: g }),
154
+ }, h("design-system:fileUpload.processing"))) : /* @__PURE__ */ t.createElement("div", null, /* @__PURE__ */ t.createElement(ve, {
155
+ className: De({ mini: v, error: g }),
156
156
  icon: g ? "exclamation-circle" : "upload-cloud",
157
157
  "aria-hidden": "true"
158
158
  }), /* @__PURE__ */ t.createElement("div", {
159
- className: Pe({ mini: h })
160
- }, g ? /* @__PURE__ */ t.createElement("div", null, u(
159
+ className: Pe({ mini: v })
160
+ }, g ? /* @__PURE__ */ t.createElement("div", null, h(
161
161
  D.length > 1 ? "design-system:fileUpload.cancelled_plural" : "design-system:fileUpload.cancelled"
162
- )) : /* @__PURE__ */ t.createElement("div", null, u("design-system:fileUpload.title", { description: te }))), g ? /* @__PURE__ */ t.createElement("div", {
162
+ )) : /* @__PURE__ */ t.createElement("div", null, h("design-system:fileUpload.title", { description: te }))), g ? /* @__PURE__ */ t.createElement("div", {
163
163
  className: Se
164
164
  }, new Set(
165
165
  D.map((i, s) => {
166
- const d = Math.floor(i.length / 2);
166
+ const f = Math.floor(i.length / 2);
167
167
  return /* @__PURE__ */ t.createElement("div", {
168
168
  className: xe,
169
169
  key: i
170
170
  }, /* @__PURE__ */ t.createElement("span", {
171
171
  className: q
172
- }, i.substr(0, d)), /* @__PURE__ */ t.createElement("div", {
172
+ }, i.substr(0, f)), /* @__PURE__ */ t.createElement("div", {
173
173
  className: q
174
- }, /* @__PURE__ */ t.createElement("span", null, i.substr(d))), s < D.length - 1 ? "," : "");
174
+ }, /* @__PURE__ */ t.createElement("span", null, i.substr(f))), s < D.length - 1 ? "," : "");
175
175
  })
176
176
  )) : /* @__PURE__ */ t.createElement("span", null), /* @__PURE__ */ t.createElement("div", {
177
177
  className: H
@@ -180,9 +180,9 @@ function J({
180
180
  onClick: oe
181
181
  }, N[1]), /* @__PURE__ */ t.createElement("span", null, N[2]))), /* @__PURE__ */ t.createElement("div", {
182
182
  className: Ne
183
- }, c ? /* @__PURE__ */ t.createElement("span", null, "(", " ", u("design-system:fileUpload.acceptedTypes", {
183
+ }, c ? /* @__PURE__ */ t.createElement("span", null, "(", " ", h("design-system:fileUpload.acceptedTypes", {
184
184
  fileTypes: M
185
- }), " ", ")") : "", p ? /* @__PURE__ */ t.createElement("span", null, "( ", u("design-system:fileUpload.maximumSize", { size: p }), " )") : "", F ? /* @__PURE__ */ t.createElement("span", null, " ", F, " ") : ""), w && /* @__PURE__ */ t.createElement("div", {
185
+ }), " ", ")") : "", p ? /* @__PURE__ */ t.createElement("span", null, "( ", h("design-system:fileUpload.maximumSize", { size: p }), " )") : "", F ? /* @__PURE__ */ t.createElement("span", null, " ", F, " ") : ""), w && /* @__PURE__ */ t.createElement("div", {
186
186
  className: je
187
187
  }, /* @__PURE__ */ t.createElement(X, {
188
188
  kind: k.LINK,
@@ -193,19 +193,19 @@ function J({
193
193
  }, /* @__PURE__ */ t.createElement(X, {
194
194
  kind: k.ICON,
195
195
  icon: G.X,
196
- title: u("design-system:fileUpload.close"),
196
+ title: h("design-system:fileUpload.close"),
197
197
  onClick: ie
198
198
  })), /* @__PURE__ */ t.createElement("form", {
199
199
  className: Oe
200
200
  }, /* @__PURE__ */ t.createElement("input", {
201
- ref: v,
201
+ ref: d,
202
202
  type: "file",
203
203
  accept: y || "*/*",
204
204
  multiple: a || void 0,
205
205
  onChange: se
206
206
  })));
207
207
  }
208
- me.set(J, {
208
+ ue.set(J, {
209
209
  name: "FileUpload",
210
210
  props: {
211
211
  constrainContentWidth: { type: "boolean" },
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": "7.2.7",
4
+ "version": "7.2.8",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/file-upload",
@@ -25,23 +25,23 @@
25
25
  "access": "public"
26
26
  },
27
27
  "peerDependencies": {
28
- "@sps-woodland/core": "7.2.7",
29
- "@sps-woodland/tokens": "7.2.7",
30
- "@spscommerce/ds-colors": "7.2.7",
31
- "@spscommerce/ds-react": "7.2.7",
32
- "@spscommerce/ds-shared": "7.2.7",
28
+ "@sps-woodland/core": "7.2.8",
29
+ "@sps-woodland/tokens": "7.2.8",
30
+ "@spscommerce/ds-colors": "7.2.8",
31
+ "@spscommerce/ds-react": "7.2.8",
32
+ "@spscommerce/ds-shared": "7.2.8",
33
33
  "@spscommerce/illustrations": "6.37.3",
34
34
  "@spscommerce/utils": "^6.12.1",
35
35
  "react": "^16.14.0",
36
36
  "react-dom": "^16.14.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@sps-woodland/core": "7.2.7",
40
- "@sps-woodland/tokens": "7.2.7",
41
- "@spscommerce/ds-colors": "7.2.7",
39
+ "@sps-woodland/core": "7.2.8",
40
+ "@sps-woodland/tokens": "7.2.8",
41
+ "@spscommerce/ds-colors": "7.2.8",
42
42
  "@spscommerce/ds-illustrations": "6.37.3",
43
- "@spscommerce/ds-react": "7.2.7",
44
- "@spscommerce/ds-shared": "7.2.7",
43
+ "@spscommerce/ds-react": "7.2.8",
44
+ "@spscommerce/ds-shared": "7.2.8",
45
45
  "@spscommerce/utils": "^6.12.1",
46
46
  "@vanilla-extract/css": "^1.9.3",
47
47
  "@vanilla-extract/recipes": "^0.2.5",