@sps-woodland/file-upload 7.15.1 → 7.16.1

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 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.CER="application/pkix-cert",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:[]}),xe="rh07jwp",be="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 R({constrainContentWidth:e,description:o,multiple:a=!1,dismissable:l,processing:n,mini:v,downloadLabel:g,acceptExtensions:c,maxSize:p,customRequirement:S,onSelection:N,onDismiss:W,download:z,shown:x,className:H,children:Ne,...J}){const b=t.useRef(new Set),[Y,L]=t.useState(x),[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(()=>{x&&L(x)},[x]),t.useEffect(()=>{p&&ie(p)},[p]),t.useEffect(()=>{c&&ae(c)},[c]);function te(){l&&(L(!1),W&&W())}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?", ":" ")),b.current.clear();for(const m of f){const j=Object.keys(V).includes(m.toUpperCase())?V[m.toUpperCase()].split(","):[];for(const pe of j)b.current.add(pe)}y(r.concat(Array.from(b.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&&!b.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(){z&&z()}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:xe},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:be},t.createElement("input",{ref:u,type:"file",accept:$||"*/*",multiple:a||void 0,onChange:ne})))}w.Metadata.set(R,{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:[R],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"),p=require("@spscommerce/utils"),R=require("@spscommerce/ds-react"),C=require("@spscommerce/ds-shared");function fe(t){if(t&&t.__esModule)return t;const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(l,a,o.get?o:{enumerable:!0,get:()=>t[a]})}}return l.default=t,Object.freeze(l)}const e=fe(ue),W={"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"],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 me(t,l,a){return l in t?Object.defineProperty(t,l,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[l]=a,t}function z(t,l){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);l&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,o)}return a}function L(t){for(var l=1;l<arguments.length;l++){var a=arguments[l]!=null?arguments[l]:{};l%2?z(Object(a),!0).forEach(function(o){me(t,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):z(Object(a)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(a,o))})}return t}var he=(t,l,a)=>{for(var o of Object.keys(t)){var n;if(t[o]!==((n=l[o])!==null&&n!==void 0?n:a[o]))return!1}return!0},j=t=>l=>{var a=t.defaultClassName,o=L(L({},t.defaultVariants),l);for(var n in o){var v,g=(v=o[n])!==null&&v!==void 0?v:t.defaultVariants[n];if(g!=null){var c=g;typeof c=="boolean"&&(c=c===!0?"true":"false");var d=t.variantClassNames[n][c];d&&(a+=" "+d)}}for(var[x,O]of t.compoundVariants)he(x,o,t.defaultVariants)&&(a+=" "+O);return a},ve="rh07jwm",k="rh07jwn",we="rh07jwl",ge=j({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",xe=j({defaultClassName:"rh07jw9",variantClassNames:{constrainContentWidth:{true:"rh07jwa",false:"rh07jwb"}},defaultVariants:{constrainContentWidth:!1},compoundVariants:[]}),Se="rh07jwp",be="rh07jwr",ye=j({defaultClassName:"rh07jwd",variantClassNames:{mini:{true:"rh07jwe",false:"rh07jwf"},error:{true:"rh07jwg",false:"rh07jwh"}},defaultVariants:{mini:!1,error:!1},compoundVariants:[]}),X="rh07jwc",Ee="rh07jwo",Ue=j({defaultClassName:"rh07jwi",variantClassNames:{mini:{true:"rh07jwj",false:"rh07jwk"}},defaultVariants:{mini:!1},compoundVariants:[]});function P({constrainContentWidth:t,description:l,multiple:a=!1,dismissable:o,processing:n,mini:v,downloadLabel:g,acceptExtensions:c,maxSize:d,customRequirement:x,onSelection:O,onDismiss:M,download:A,shown:S,className:G,children:Oe,..._}){const b=e.useRef(new Set),[q,I]=e.useState(S),[De,K]=e.useState([]),[Z,H]=e.useState(""),[B,J]=e.useState(),[Y,y]=e.useState(!1),[F,E]=e.useState(!1),[D,V]=e.useState([]),[Q,$]=e.useState(""),{t:h}=e.useContext(w.I18nContext),N=h(a?"design-system:fileUpload.instructions_plural":"design-system:fileUpload.instructions").split("|"),ee=l||(a?"Files":"File"),u=e.useRef(null);e.useEffect(()=>{S&&I(S)},[S]),e.useEffect(()=>{d&&ie(d)},[d]),e.useEffect(()=>{c&&ae(c)},[c]);function te(){o&&(I(!1),M&&M())}function ie(i){try{J(p.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());$(r.map((m,U)=>U>0&&U===r.length-1?`or ${m}`:m).join(r.length>2?", ":" ")),b.current.clear();for(const m of f){const U=Object.keys(W).includes(m.toUpperCase())?W[m.toUpperCase()]:[];for(const de of U)b.current.add(de)}H(r.concat(Array.from(b.current)).join(","))}function T(i){V([]);let s=[];const f=Array.from(i);for(const r of f)r===null?s.push("Not a file"):(c&&!b.current.has(r.type)&&s.push(r.name),d&&B&&r.size>B&&s.indexOf(r.name)===-1&&s.push(r.name));s.length?(E(!0),u.current&&u.current.value&&(u.current.value="")):(K(f),O(f)),V(s)}function oe(i){i.preventDefault(),E(!1),u.current&&u.current.click()}function le(){A&&A()}function ne(i){i.stopPropagation(),T(i.target.files||[]),u.current&&u.current.value&&(u.current.value="")}function se(i){i.preventDefault(),i.stopPropagation(),y(!0),E(!1)}function re(i){i.preventDefault(),y(!0),E(!1)}function ce(i){i.preventDefault(),y(!1)}function pe(i){i.preventDefault(),i.stopPropagation(),y(!1),i.dataTransfer.items?T(Array.from(i.dataTransfer.items).map(s=>s.getAsFile())):T(i.dataTransfer.files)}return e.createElement("div",{onDrop:pe,onDragOver:se,onDragLeave:ce,onDragEnter:re,className:w.cl(ge({active:Y,mini:v,error:F,shown:q}),G),..._},e.createElement("div",{className:w.cl(xe({constrainContentWidth:t}))},n?e.createElement("div",null,e.createElement(w.Spinner,{size:"md","aria-hidden":"true"}),e.createElement("div",{className:X},h("design-system:fileUpload.processing"))):e.createElement("div",null,e.createElement(w.Icon,{className:ye({mini:v,error:F}),icon:F?"exclamation-circle":"upload-cloud","aria-hidden":"true"}),e.createElement("div",{className:Ue({mini:v})},F?e.createElement("div",null,h(D.length>1?"design-system:fileUpload.cancelled_plural":"design-system:fileUpload.cancelled")):e.createElement("div",null,h("design-system:fileUpload.title",{description:ee}))),F?e.createElement("div",{className:we},new Set(D.map((i,s)=>{const f=Math.floor(i.length/2);return e.createElement("div",{className:ve,key:i},e.createElement("span",{className:k},i.substr(0,f)),e.createElement("div",{className:k},e.createElement("span",null,i.substr(f))),s<D.length-1?",":"")}))):e.createElement("span",null),e.createElement("div",{className:X},e.createElement("div",null,e.createElement("span",null,N[0]),e.createElement("a",{href:"",onClick:oe},N[1]),e.createElement("span",null,N[2]))),e.createElement("div",{className:Ee},c?e.createElement("span",null,"("," ",h("design-system:fileUpload.acceptedTypes",{fileTypes:Q})," ",")"):"",d?e.createElement("span",null,"( ",h("design-system:fileUpload.maximumSize",{size:d})," )"):"",x?e.createElement("span",null," ",x," "):""),g&&e.createElement("div",{className:Se},e.createElement(R.SpsButton,{kind:C.ButtonKind.LINK,icon:C.SpsIcon.DOWNLOAD_CLOUD,onClick:le},g)))),o&&!n&&e.createElement("div",{className:Fe},e.createElement(R.SpsButton,{kind:C.ButtonKind.ICON,icon:C.SpsIcon.X,title:h("design-system:fileUpload.close"),onClick:te})),e.createElement("form",{className:be},e.createElement("input",{ref:u,type:"file",accept:Z||"*/*",multiple:a||void 0,onChange:ne})))}w.Metadata.set(P,{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 Ce={components:[P],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() {
@@ -10,7 +10,7 @@
10
10
  <FileUpload onSelection={selectFile} />
11
11
  )
12
12
  }
13
- `},multiple:{description:"Multiple file upload",react:d.code`
13
+ `},multiple:{description:"Multiple file upload",react:p.code`
14
14
  import { FileUpload } from "@sps-woodland/file-upload";
15
15
 
16
16
  function Component() {
@@ -22,7 +22,7 @@
22
22
  <FileUpload onSelection={selectFile} multiple />
23
23
  )
24
24
  }
25
- `}}},restrictions:{label:"Restrictions",description:"You can place restrictions on what files will be accepted with an extension whitelist and/or a maximum size.",examples:{maxSize:{description:"Maximum size",react:d.code`
25
+ `}}},restrictions:{label:"Restrictions",description:"You can place restrictions on what files will be accepted with an extension whitelist and/or a maximum size.",examples:{maxSize:{description:"Maximum size",react:p.code`
26
26
  import { FileUpload } from "@sps-woodland/file-upload";
27
27
 
28
28
  function Component() {
@@ -34,7 +34,7 @@
34
34
  <FileUpload onSelection={selectFile} maxSize="100KB" />
35
35
  )
36
36
  }
37
- `},fileWhitelist:{description:"File type whitelist",react:d.code`
37
+ `},fileWhitelist:{description:"File type whitelist",react:p.code`
38
38
  import { FileUpload } from "@sps-woodland/file-upload";
39
39
 
40
40
  function Component() {
@@ -51,7 +51,7 @@
51
51
  />
52
52
  )
53
53
  }
54
- `},bothRestrictions:{description:"Both restrictions",react:d.code`
54
+ `},bothRestrictions:{description:"Both restrictions",react:p.code`
55
55
  import { FileUpload } from "@sps-woodland/file-upload";
56
56
 
57
57
  function Component() {
@@ -69,7 +69,7 @@
69
69
  />
70
70
  )
71
71
  }
72
- `}}},dismissable:{label:"Dismissable",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.",examples:{basic:{react:d.code`
72
+ `}}},dismissable:{label:"Dismissable",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.",examples:{basic:{react:p.code`
73
73
  import { FileUpload } from "@sps-woodland/file-upload";
74
74
 
75
75
  function Component() {
@@ -98,7 +98,7 @@
98
98
  </>
99
99
  )
100
100
  }
101
- `}}},download:{label:"Download Button",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.",examples:{basic:{react:d.code`
101
+ `}}},download:{label:"Download Button",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.",examples:{basic:{react:p.code`
102
102
  import { FileUpload } from "@sps-woodland/file-upload";
103
103
 
104
104
  function Component() {
@@ -120,7 +120,7 @@
120
120
  />
121
121
  )
122
122
  }
123
- `}}},mini:{label:"Mini File Upload",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.",examples:{basic:{react:d.code`
123
+ `}}},mini:{label:"Mini File Upload",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.",examples:{basic:{react:p.code`
124
124
  import { FileUpload } from "@sps-woodland/file-upload";
125
125
 
126
126
  function Component() {
@@ -136,7 +136,7 @@
136
136
  </div>
137
137
  )
138
138
  }
139
- `}}},constrainContentWidth:{label:"Constrain Content Width",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.",examples:{basic:{react:d.code`
139
+ `}}},constrainContentWidth:{label:"Constrain Content Width",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.",examples:{basic:{react:p.code`
140
140
  import { FileUpload } from "@sps-woodland/file-upload";
141
141
 
142
142
  function Component() {
@@ -152,4 +152,4 @@
152
152
  </div>
153
153
  )
154
154
  }
155
- `}}}}},De={"File Upload":Oe};exports.FileUpload=R;exports.MANIFEST=De;
155
+ `}}}}},je={"File Upload":Ce};exports.FileUpload=P;exports.MANIFEST=je;
package/lib/index.es.js CHANGED
@@ -1,211 +1,286 @@
1
- import * as t from "react";
2
- import { Metadata as ue, I18nContext as me, cl as R, Spinner as he, Icon as ve } from "@sps-woodland/core";
1
+ import * as e from "react";
2
+ import { Metadata as ue, I18nContext as me, cl as I, Spinner as he, Icon as ve } from "@sps-woodland/core";
3
3
  import { parseFileSize as we, code as m } from "@spscommerce/utils";
4
- import { SpsButton as k } from "@spscommerce/ds-react";
5
- import { ButtonKind as X, SpsIcon as G } from "@spscommerce/ds-shared";
6
- var A = /* @__PURE__ */ ((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.CER = "application/pkix-cert", 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))(A || {});
7
- function ge(e, o, a) {
8
- return o in e ? Object.defineProperty(e, o, {
4
+ import { SpsButton as B } from "@spscommerce/ds-react";
5
+ import { ButtonKind as V, SpsIcon as W } from "@spscommerce/ds-shared";
6
+ const L = {
7
+ "7Z": ["application/x-7z-compressed"],
8
+ AAC: ["audio/aac"],
9
+ ABW: ["application/x-abiword"],
10
+ ARC: ["application/octet-stream"],
11
+ AVI: ["video/x-msvideo"],
12
+ AZW: ["application/vnd.amazon.ebook"],
13
+ BIN: ["application/octet-stream"],
14
+ BMP: ["image/bmp"],
15
+ BZ: ["application/x-bzip"],
16
+ BZ2: ["application/x-bzip2"],
17
+ CER: ["application/pkix-cert", "application/x-x509-ca-cert"],
18
+ CSH: ["application/x-csh"],
19
+ CSS: ["text/css"],
20
+ CSV: ["text/csv,application/vnd.ms-excel"],
21
+ DOC: ["application/msword"],
22
+ DOCX: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
23
+ EOT: ["application/vnd.ms-fontobject"],
24
+ EPUB: ["application/epub+zip"],
25
+ ES: ["application/ecmascript"],
26
+ FLV: ["video/x-flv"],
27
+ GIF: ["image/gif"],
28
+ GZ: ["application/x-gzip"],
29
+ HTM: ["text/html"],
30
+ HTML: ["text/html"],
31
+ ICO: ["image/x-icon"],
32
+ ICS: ["text/calendar"],
33
+ JAR: ["application/java-archive"],
34
+ JPEG: ["image/jpeg"],
35
+ JPG: ["image/jpeg"],
36
+ JS: ["application/javascript"],
37
+ JSON: ["application/json"],
38
+ M3U: ["audio/x-mpequrl"],
39
+ MID: ["audio/midi"],
40
+ MIDI: ["audio/midi"],
41
+ MOV: ["video/quicktime"],
42
+ MP3: ["audio/mpeg3"],
43
+ MP4: ["video/mp4"],
44
+ MPEG: ["video/mpeg"],
45
+ MPKG: ["application/vnd.apple.installer+xml"],
46
+ ODP: ["application/vnd.oasis.opendocument.presentation"],
47
+ ODS: ["application/vnd.oasis.opendocument.spreadsheet"],
48
+ ODT: ["application/vnd.oasis.opendocument.text"],
49
+ OGA: ["audio/ogg"],
50
+ OGV: ["video/ogg"],
51
+ OGX: ["application/ogg"],
52
+ OTF: ["font/otf"],
53
+ PNG: ["image/png"],
54
+ PDF: ["application/pdf"],
55
+ PPT: ["application/vnd.ms-powerpoint"],
56
+ PPTX: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
57
+ RAR: ["application/x-rar-compressed"],
58
+ RTF: ["application/rtf"],
59
+ SH: ["application/x-sh"],
60
+ SVG: ["image/svg+xml"],
61
+ SWF: ["application/x-shockwave-flash"],
62
+ TAR: ["application/x-tar"],
63
+ TIF: ["image/tiff"],
64
+ TIFF: ["image/tiff"],
65
+ TS: ["application/typescript"],
66
+ TTF: ["font/ttf"],
67
+ TXT: ["text/plain"],
68
+ VSD: ["application/vnd.visio"],
69
+ WAV: ["audio/wav"],
70
+ WEBA: ["audio/webm"],
71
+ WEBM: ["video/webm"],
72
+ WEBP: ["image/webp"],
73
+ WOFF: ["font/woff"],
74
+ WOFF2: ["font/woff2"],
75
+ XHTML: ["application/xhtml+xml"],
76
+ XLS: ["application/vnd.ms-excel"],
77
+ XLSX: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
78
+ XML: ["application/xml"],
79
+ XUL: ["application/vnd.mozilla.xul+xml"],
80
+ ZIP: ["application/zip"]
81
+ };
82
+ function ge(i, o, a) {
83
+ return o in i ? Object.defineProperty(i, o, {
9
84
  value: a,
10
85
  enumerable: !0,
11
86
  configurable: !0,
12
87
  writable: !0
13
- }) : e[o] = a, e;
88
+ }) : i[o] = a, i;
14
89
  }
15
- function K(e, o) {
16
- var a = Object.keys(e);
90
+ function z(i, o) {
91
+ var a = Object.keys(i);
17
92
  if (Object.getOwnPropertySymbols) {
18
- var l = Object.getOwnPropertySymbols(e);
93
+ var l = Object.getOwnPropertySymbols(i);
19
94
  o && (l = l.filter(function(n) {
20
- return Object.getOwnPropertyDescriptor(e, n).enumerable;
95
+ return Object.getOwnPropertyDescriptor(i, n).enumerable;
21
96
  })), a.push.apply(a, l);
22
97
  }
23
98
  return a;
24
99
  }
25
- function Z(e) {
100
+ function R(i) {
26
101
  for (var o = 1; o < arguments.length; o++) {
27
102
  var a = arguments[o] != null ? arguments[o] : {};
28
- o % 2 ? K(Object(a), !0).forEach(function(l) {
29
- ge(e, l, a[l]);
30
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(a)) : K(Object(a)).forEach(function(l) {
31
- Object.defineProperty(e, l, Object.getOwnPropertyDescriptor(a, l));
103
+ o % 2 ? z(Object(a), !0).forEach(function(l) {
104
+ ge(i, l, a[l]);
105
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(i, Object.getOwnPropertyDescriptors(a)) : z(Object(a)).forEach(function(l) {
106
+ Object.defineProperty(i, l, Object.getOwnPropertyDescriptor(a, l));
32
107
  });
33
108
  }
34
- return e;
109
+ return i;
35
110
  }
36
- var Fe = (e, o, a) => {
37
- for (var l of Object.keys(e)) {
111
+ var Fe = (i, o, a) => {
112
+ for (var l of Object.keys(i)) {
38
113
  var n;
39
- if (e[l] !== ((n = o[l]) !== null && n !== void 0 ? n : a[l]))
114
+ if (i[l] !== ((n = o[l]) !== null && n !== void 0 ? n : a[l]))
40
115
  return !1;
41
116
  }
42
117
  return !0;
43
- }, j = (e) => (o) => {
44
- var a = e.defaultClassName, l = Z(Z({}, e.defaultVariants), o);
118
+ }, U = (i) => (o) => {
119
+ var a = i.defaultClassName, l = R(R({}, i.defaultVariants), o);
45
120
  for (var n in l) {
46
- var v, w = (v = l[n]) !== null && v !== void 0 ? v : e.defaultVariants[n];
121
+ var v, w = (v = l[n]) !== null && v !== void 0 ? v : i.defaultVariants[n];
47
122
  if (w != null) {
48
- var c = w;
49
- typeof c == "boolean" && (c = c === !0 ? "true" : "false");
50
- var p = e.variantClassNames[n][c];
51
- p && (a += " " + p);
123
+ var p = w;
124
+ typeof p == "boolean" && (p = p === !0 ? "true" : "false");
125
+ var c = i.variantClassNames[n][p];
126
+ c && (a += " " + c);
52
127
  }
53
128
  }
54
- for (var [F, O] of e.compoundVariants)
55
- Fe(F, l, e.defaultVariants) && (a += " " + O);
129
+ for (var [F, C] of i.compoundVariants)
130
+ Fe(F, l, i.defaultVariants) && (a += " " + C);
56
131
  return a;
57
- }, xe = "rh07jwm", q = "rh07jwn", Se = "rh07jwl", be = j({ 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: [] }), Ue = "rh07jwq", Ce = j({ defaultClassName: "rh07jw9", variantClassNames: { constrainContentWidth: { true: "rh07jwa", false: "rh07jwb" } }, defaultVariants: { constrainContentWidth: !1 }, compoundVariants: [] }), je = "rh07jwp", Oe = "rh07jwr", De = j({ defaultClassName: "rh07jwd", variantClassNames: { mini: { true: "rh07jwe", false: "rh07jwf" }, error: { true: "rh07jwg", false: "rh07jwh" } }, defaultVariants: { mini: !1, error: !1 }, compoundVariants: [] }), H = "rh07jwc", Ne = "rh07jwo", Pe = j({ defaultClassName: "rh07jwi", variantClassNames: { mini: { true: "rh07jwj", false: "rh07jwk" } }, defaultVariants: { mini: !1 }, compoundVariants: [] });
58
- function J({
59
- constrainContentWidth: e,
132
+ }, xe = "rh07jwm", k = "rh07jwn", ye = "rh07jwl", Se = U({ 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: [] }), be = "rh07jwq", Ee = U({ defaultClassName: "rh07jw9", variantClassNames: { constrainContentWidth: { true: "rh07jwa", false: "rh07jwb" } }, defaultVariants: { constrainContentWidth: !1 }, compoundVariants: [] }), Ue = "rh07jwp", Ce = "rh07jwr", je = U({ defaultClassName: "rh07jwd", variantClassNames: { mini: { true: "rh07jwe", false: "rh07jwf" }, error: { true: "rh07jwg", false: "rh07jwh" } }, defaultVariants: { mini: !1, error: !1 }, compoundVariants: [] }), X = "rh07jwc", Oe = "rh07jwo", De = U({ defaultClassName: "rh07jwi", variantClassNames: { mini: { true: "rh07jwj", false: "rh07jwk" } }, defaultVariants: { mini: !1 }, compoundVariants: [] });
133
+ function G({
134
+ constrainContentWidth: i,
60
135
  description: o,
61
136
  multiple: a = !1,
62
137
  dismissable: l,
63
138
  processing: n,
64
139
  mini: v,
65
140
  downloadLabel: w,
66
- acceptExtensions: c,
67
- maxSize: p,
141
+ acceptExtensions: p,
142
+ maxSize: c,
68
143
  customRequirement: F,
69
- onSelection: O,
70
- onDismiss: B,
71
- download: V,
144
+ onSelection: C,
145
+ onDismiss: N,
146
+ download: T,
72
147
  shown: x,
73
- className: _,
74
- children: Be,
75
- ...Y
148
+ className: K,
149
+ children: Te,
150
+ ...Z
76
151
  }) {
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
- t.useEffect(() => {
79
- x && W(x);
80
- }, [x]), t.useEffect(() => {
81
- p && ae(p);
82
- }, [p]), t.useEffect(() => {
83
- c && le(c);
84
- }, [c]);
152
+ const y = e.useRef(/* @__PURE__ */ new Set()), [q, P] = e.useState(x), [Pe, H] = e.useState([]), [J, _] = e.useState(""), [A, Y] = e.useState(), [Q, S] = e.useState(!1), [g, b] = e.useState(!1), [j, M] = e.useState([]), [$, ee] = e.useState(""), { t: h } = e.useContext(me), O = h(a ? "design-system:fileUpload.instructions_plural" : "design-system:fileUpload.instructions").split("|"), te = o || (a ? "Files" : "File"), d = e.useRef(null);
153
+ e.useEffect(() => {
154
+ x && P(x);
155
+ }, [x]), e.useEffect(() => {
156
+ c && ae(c);
157
+ }, [c]), e.useEffect(() => {
158
+ p && le(p);
159
+ }, [p]);
85
160
  function ie() {
86
- l && (W(!1), B && B());
161
+ l && (P(!1), N && N());
87
162
  }
88
- function ae(i) {
163
+ function ae(t) {
89
164
  try {
90
- T(we(i));
165
+ Y(we(t));
91
166
  } catch {
92
- throw new Error(`Could not parse "${i}" as a file size.`);
167
+ throw new Error(`Could not parse "${t}" as a file size.`);
93
168
  }
94
169
  }
95
- function le(i) {
96
- const f = (Array.isArray(i) ? i : i.trim().split(/\s?,\s?/)).map((u) => u.replace(/^\./, "")), r = f.map((u) => `.${u}`.toLowerCase());
170
+ function le(t) {
171
+ const f = (Array.isArray(t) ? t : t.trim().split(/\s?,\s?/)).map((u) => u.replace(/^\./, "")), r = f.map((u) => `.${u}`.toLowerCase());
97
172
  ee(
98
- r.map((u, C) => C > 0 && C === r.length - 1 ? `or ${u}` : u).join(r.length > 2 ? ", " : " ")
99
- ), S.current.clear();
173
+ r.map((u, E) => E > 0 && E === r.length - 1 ? `or ${u}` : u).join(r.length > 2 ? ", " : " ")
174
+ ), y.current.clear();
100
175
  for (const u of f) {
101
- const C = Object.keys(A).includes(u.toUpperCase()) ? A[u.toUpperCase()].split(",") : [];
102
- for (const fe of C)
103
- S.current.add(fe);
176
+ const E = Object.keys(L).includes(u.toUpperCase()) ? L[u.toUpperCase()] : [];
177
+ for (const fe of E)
178
+ y.current.add(fe);
104
179
  }
105
- E(r.concat(Array.from(S.current)).join(","));
180
+ _(r.concat(Array.from(y.current)).join(","));
106
181
  }
107
- function P(i) {
108
- z([]);
182
+ function D(t) {
183
+ M([]);
109
184
  let s = [];
110
- const f = Array.from(i);
185
+ const f = Array.from(t);
111
186
  for (const r of f)
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), d.current && d.current.value && (d.current.value = "")) : ($(f), O(f)), z(s);
187
+ r === null ? s.push("Not a file") : (p && !y.current.has(r.type) && s.push(r.name), c && A && r.size > A && s.indexOf(r.name) === -1 && s.push(r.name));
188
+ s.length ? (b(!0), d.current && d.current.value && (d.current.value = "")) : (H(f), C(f)), M(s);
114
189
  }
115
- function oe(i) {
116
- i.preventDefault(), U(!1), d.current && d.current.click();
190
+ function oe(t) {
191
+ t.preventDefault(), b(!1), d.current && d.current.click();
117
192
  }
118
193
  function ne() {
119
- V && V();
194
+ T && T();
120
195
  }
121
- function se(i) {
122
- i.stopPropagation(), P(i.target.files || []), d.current && d.current.value && (d.current.value = "");
196
+ function se(t) {
197
+ t.stopPropagation(), D(t.target.files || []), d.current && d.current.value && (d.current.value = "");
123
198
  }
124
- function re(i) {
125
- i.preventDefault(), i.stopPropagation(), b(!0), U(!1);
199
+ function re(t) {
200
+ t.preventDefault(), t.stopPropagation(), S(!0), b(!1);
126
201
  }
127
- function ce(i) {
128
- i.preventDefault(), b(!0), U(!1);
202
+ function pe(t) {
203
+ t.preventDefault(), S(!0), b(!1);
129
204
  }
130
- function pe(i) {
131
- i.preventDefault(), b(!1);
205
+ function ce(t) {
206
+ t.preventDefault(), S(!1);
132
207
  }
133
- function de(i) {
134
- i.preventDefault(), i.stopPropagation(), b(!1), i.dataTransfer.items ? P(
135
- Array.from(i.dataTransfer.items).map(
208
+ function de(t) {
209
+ t.preventDefault(), t.stopPropagation(), S(!1), t.dataTransfer.items ? D(
210
+ Array.from(t.dataTransfer.items).map(
136
211
  (s) => s.getAsFile()
137
212
  )
138
- ) : P(i.dataTransfer.files);
213
+ ) : D(t.dataTransfer.files);
139
214
  }
140
- return /* @__PURE__ */ t.createElement("div", {
215
+ return /* @__PURE__ */ e.createElement("div", {
141
216
  onDrop: de,
142
217
  onDragOver: re,
143
- onDragLeave: pe,
144
- onDragEnter: ce,
145
- className: R(be({ active: I, mini: v, error: g, shown: Q }), _),
146
- ...Y
147
- }, /* @__PURE__ */ t.createElement("div", {
148
- className: R(Ce({ constrainContentWidth: e }))
149
- }, n ? /* @__PURE__ */ t.createElement("div", null, /* @__PURE__ */ t.createElement(he, {
218
+ onDragLeave: ce,
219
+ onDragEnter: pe,
220
+ className: I(Se({ active: Q, mini: v, error: g, shown: q }), K),
221
+ ...Z
222
+ }, /* @__PURE__ */ e.createElement("div", {
223
+ className: I(Ee({ constrainContentWidth: i }))
224
+ }, n ? /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(he, {
150
225
  size: "md",
151
226
  "aria-hidden": "true"
152
- }), /* @__PURE__ */ t.createElement("div", {
153
- className: H
154
- }, h("design-system:fileUpload.processing"))) : /* @__PURE__ */ t.createElement("div", null, /* @__PURE__ */ t.createElement(ve, {
155
- className: De({ mini: v, error: g }),
227
+ }), /* @__PURE__ */ e.createElement("div", {
228
+ className: X
229
+ }, h("design-system:fileUpload.processing"))) : /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(ve, {
230
+ className: je({ mini: v, error: g }),
156
231
  icon: g ? "exclamation-circle" : "upload-cloud",
157
232
  "aria-hidden": "true"
158
- }), /* @__PURE__ */ t.createElement("div", {
159
- className: Pe({ mini: v })
160
- }, g ? /* @__PURE__ */ t.createElement("div", null, h(
161
- D.length > 1 ? "design-system:fileUpload.cancelled_plural" : "design-system:fileUpload.cancelled"
162
- )) : /* @__PURE__ */ t.createElement("div", null, h("design-system:fileUpload.title", { description: te }))), g ? /* @__PURE__ */ t.createElement("div", {
163
- className: Se
233
+ }), /* @__PURE__ */ e.createElement("div", {
234
+ className: De({ mini: v })
235
+ }, g ? /* @__PURE__ */ e.createElement("div", null, h(
236
+ j.length > 1 ? "design-system:fileUpload.cancelled_plural" : "design-system:fileUpload.cancelled"
237
+ )) : /* @__PURE__ */ e.createElement("div", null, h("design-system:fileUpload.title", { description: te }))), g ? /* @__PURE__ */ e.createElement("div", {
238
+ className: ye
164
239
  }, new Set(
165
- D.map((i, s) => {
166
- const f = Math.floor(i.length / 2);
167
- return /* @__PURE__ */ t.createElement("div", {
240
+ j.map((t, s) => {
241
+ const f = Math.floor(t.length / 2);
242
+ return /* @__PURE__ */ e.createElement("div", {
168
243
  className: xe,
169
- key: i
170
- }, /* @__PURE__ */ t.createElement("span", {
171
- className: q
172
- }, i.substr(0, f)), /* @__PURE__ */ t.createElement("div", {
173
- className: q
174
- }, /* @__PURE__ */ t.createElement("span", null, i.substr(f))), s < D.length - 1 ? "," : "");
244
+ key: t
245
+ }, /* @__PURE__ */ e.createElement("span", {
246
+ className: k
247
+ }, t.substr(0, f)), /* @__PURE__ */ e.createElement("div", {
248
+ className: k
249
+ }, /* @__PURE__ */ e.createElement("span", null, t.substr(f))), s < j.length - 1 ? "," : "");
175
250
  })
176
- )) : /* @__PURE__ */ t.createElement("span", null), /* @__PURE__ */ t.createElement("div", {
177
- className: H
178
- }, /* @__PURE__ */ t.createElement("div", null, /* @__PURE__ */ t.createElement("span", null, N[0]), /* @__PURE__ */ t.createElement("a", {
251
+ )) : /* @__PURE__ */ e.createElement("span", null), /* @__PURE__ */ e.createElement("div", {
252
+ className: X
253
+ }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("span", null, O[0]), /* @__PURE__ */ e.createElement("a", {
179
254
  href: "",
180
255
  onClick: oe
181
- }, N[1]), /* @__PURE__ */ t.createElement("span", null, N[2]))), /* @__PURE__ */ t.createElement("div", {
182
- className: Ne
183
- }, c ? /* @__PURE__ */ t.createElement("span", null, "(", " ", h("design-system:fileUpload.acceptedTypes", {
184
- fileTypes: M
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
- className: je
187
- }, /* @__PURE__ */ t.createElement(k, {
188
- kind: X.LINK,
189
- icon: G.DOWNLOAD_CLOUD,
190
- onClick: ne
191
- }, w)))), l && !n && /* @__PURE__ */ t.createElement("div", {
256
+ }, O[1]), /* @__PURE__ */ e.createElement("span", null, O[2]))), /* @__PURE__ */ e.createElement("div", {
257
+ className: Oe
258
+ }, p ? /* @__PURE__ */ e.createElement("span", null, "(", " ", h("design-system:fileUpload.acceptedTypes", {
259
+ fileTypes: $
260
+ }), " ", ")") : "", c ? /* @__PURE__ */ e.createElement("span", null, "( ", h("design-system:fileUpload.maximumSize", { size: c }), " )") : "", F ? /* @__PURE__ */ e.createElement("span", null, " ", F, " ") : ""), w && /* @__PURE__ */ e.createElement("div", {
192
261
  className: Ue
193
- }, /* @__PURE__ */ t.createElement(k, {
194
- kind: X.ICON,
195
- icon: G.X,
262
+ }, /* @__PURE__ */ e.createElement(B, {
263
+ kind: V.LINK,
264
+ icon: W.DOWNLOAD_CLOUD,
265
+ onClick: ne
266
+ }, w)))), l && !n && /* @__PURE__ */ e.createElement("div", {
267
+ className: be
268
+ }, /* @__PURE__ */ e.createElement(B, {
269
+ kind: V.ICON,
270
+ icon: W.X,
196
271
  title: h("design-system:fileUpload.close"),
197
272
  onClick: ie
198
- })), /* @__PURE__ */ t.createElement("form", {
199
- className: Oe
200
- }, /* @__PURE__ */ t.createElement("input", {
273
+ })), /* @__PURE__ */ e.createElement("form", {
274
+ className: Ce
275
+ }, /* @__PURE__ */ e.createElement("input", {
201
276
  ref: d,
202
277
  type: "file",
203
- accept: y || "*/*",
278
+ accept: J || "*/*",
204
279
  multiple: a || void 0,
205
280
  onChange: se
206
281
  })));
207
282
  }
208
- ue.set(J, {
283
+ ue.set(G, {
209
284
  name: "FileUpload",
210
285
  props: {
211
286
  constrainContentWidth: { type: "boolean" },
@@ -222,8 +297,8 @@ ue.set(J, {
222
297
  download: { type: "() => void" }
223
298
  }
224
299
  });
225
- const Ae = {
226
- components: [J],
300
+ const Ne = {
301
+ components: [G],
227
302
  examples: {
228
303
  basic: {
229
304
  label: "Basic File Upload",
@@ -448,10 +523,10 @@ const Ae = {
448
523
  }
449
524
  }
450
525
  }
451
- }, ke = {
452
- "File Upload": Ae
526
+ }, Ve = {
527
+ "File Upload": Ne
453
528
  };
454
529
  export {
455
- J as FileUpload,
456
- ke as MANIFEST
530
+ G as FileUpload,
531
+ Ve as MANIFEST
457
532
  };
@@ -1,76 +1,76 @@
1
- export declare enum MIMEType {
2
- "7Z" = "application/x-7z-compressed",
3
- AAC = "audio/aac",
4
- ABW = "application/x-abiword",
5
- ARC = "application/octet-stream",
6
- AVI = "video/x-msvideo",
7
- AZW = "application/vnd.amazon.ebook",
8
- BIN = "application/octet-stream",
9
- BMP = "image/bmp",
10
- BZ = "application/x-bzip",
11
- BZ2 = "application/x-bzip2",
12
- CER = "application/pkix-cert",
13
- CSH = "application/x-csh",
14
- CSS = "text/css",
15
- CSV = "text/csv,application/vnd.ms-excel",
16
- DOC = "application/msword",
17
- DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
18
- EOT = "application/vnd.ms-fontobject",
19
- EPUB = "application/epub+zip",
20
- ES = "application/ecmascript",
21
- FLV = "video/x-flv",
22
- GIF = "image/gif",
23
- GZ = "application/x-gzip",
24
- HTM = "text/html",
25
- HTML = "text/html",
26
- ICO = "image/x-icon",
27
- ICS = "text/calendar",
28
- JAR = "application/java-archive",
29
- JPEG = "image/jpeg",
30
- JPG = "image/jpeg",
31
- JS = "application/javascript",
32
- JSON = "application/json",
33
- M3U = "audio/x-mpequrl",
34
- MID = "audio/midi",
35
- MIDI = "audio/midi",
36
- MOV = "video/quicktime",
37
- MP3 = "audio/mpeg3",
38
- MP4 = "video/mp4",
39
- MPEG = "video/mpeg",
40
- MPKG = "application/vnd.apple.installer+xml",
41
- ODP = "application/vnd.oasis.opendocument.presentation",
42
- ODS = "application/vnd.oasis.opendocument.spreadsheet",
43
- ODT = "application/vnd.oasis.opendocument.text",
44
- OGA = "audio/ogg",
45
- OGV = "video/ogg",
46
- OGX = "application/ogg",
47
- OTF = "font/otf",
48
- PNG = "image/png",
49
- PDF = "application/pdf",
50
- PPT = "application/vnd.ms-powerpoint",
51
- PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation",
52
- RAR = "application/x-rar-compressed",
53
- RTF = "application/rtf",
54
- SH = "application/x-sh",
55
- SVG = "image/svg+xml",
56
- SWF = "application/x-shockwave-flash",
57
- TAR = "application/x-tar",
58
- TIF = "image/tiff",
59
- TIFF = "image/tiff",
60
- TS = "application/typescript",
61
- TTF = "font/ttf",
62
- TXT = "text/plain",
63
- VSD = "application/vnd.visio",
64
- WAV = "audio/wav",
65
- WEBA = "audio/webm",
66
- WEBM = "video/webm",
67
- WEBP = "image/webp",
68
- WOFF = "font/woff",
69
- WOFF2 = "font/woff2",
70
- XHTML = "application/xhtml+xml",
71
- XLS = "application/vnd.ms-excel",
72
- XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
73
- XML = "application/xml",
74
- XUL = "application/vnd.mozilla.xul+xml",
75
- ZIP = "application/zip"
76
- }
1
+ export declare const MIMEType: {
2
+ "7Z": string[];
3
+ AAC: string[];
4
+ ABW: string[];
5
+ ARC: string[];
6
+ AVI: string[];
7
+ AZW: string[];
8
+ BIN: string[];
9
+ BMP: string[];
10
+ BZ: string[];
11
+ BZ2: string[];
12
+ CER: string[];
13
+ CSH: string[];
14
+ CSS: string[];
15
+ CSV: string[];
16
+ DOC: string[];
17
+ DOCX: string[];
18
+ EOT: string[];
19
+ EPUB: string[];
20
+ ES: string[];
21
+ FLV: string[];
22
+ GIF: string[];
23
+ GZ: string[];
24
+ HTM: string[];
25
+ HTML: string[];
26
+ ICO: string[];
27
+ ICS: string[];
28
+ JAR: string[];
29
+ JPEG: string[];
30
+ JPG: string[];
31
+ JS: string[];
32
+ JSON: string[];
33
+ M3U: string[];
34
+ MID: string[];
35
+ MIDI: string[];
36
+ MOV: string[];
37
+ MP3: string[];
38
+ MP4: string[];
39
+ MPEG: string[];
40
+ MPKG: string[];
41
+ ODP: string[];
42
+ ODS: string[];
43
+ ODT: string[];
44
+ OGA: string[];
45
+ OGV: string[];
46
+ OGX: string[];
47
+ OTF: string[];
48
+ PNG: string[];
49
+ PDF: string[];
50
+ PPT: string[];
51
+ PPTX: string[];
52
+ RAR: string[];
53
+ RTF: string[];
54
+ SH: string[];
55
+ SVG: string[];
56
+ SWF: string[];
57
+ TAR: string[];
58
+ TIF: string[];
59
+ TIFF: string[];
60
+ TS: string[];
61
+ TTF: string[];
62
+ TXT: string[];
63
+ VSD: string[];
64
+ WAV: string[];
65
+ WEBA: string[];
66
+ WEBM: string[];
67
+ WEBP: string[];
68
+ WOFF: string[];
69
+ WOFF2: string[];
70
+ XHTML: string[];
71
+ XLS: string[];
72
+ XLSX: string[];
73
+ XML: string[];
74
+ XUL: string[];
75
+ ZIP: string[];
76
+ };
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.15.1",
4
+ "version": "7.16.1",
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,11 +30,11 @@
30
30
  "@spscommerce/utils": "^6.12.1",
31
31
  "react": "^16.14.0",
32
32
  "react-dom": "^16.14.0",
33
- "@sps-woodland/core": "7.15.1",
34
- "@sps-woodland/tokens": "7.15.1",
35
- "@spscommerce/ds-colors": "7.15.1",
36
- "@spscommerce/ds-react": "7.15.1",
37
- "@spscommerce/ds-shared": "7.15.1"
33
+ "@sps-woodland/core": "7.16.1",
34
+ "@sps-woodland/tokens": "7.16.1",
35
+ "@spscommerce/ds-colors": "7.16.1",
36
+ "@spscommerce/ds-react": "7.16.1",
37
+ "@spscommerce/ds-shared": "7.16.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@spscommerce/ds-illustrations": "6.37.3",
@@ -43,11 +43,11 @@
43
43
  "@vanilla-extract/recipes": "^0.2.5",
44
44
  "react": "^16.14.0",
45
45
  "react-dom": "^16.14.0",
46
- "@sps-woodland/core": "7.15.1",
47
- "@sps-woodland/tokens": "7.15.1",
48
- "@spscommerce/ds-colors": "7.15.1",
49
- "@spscommerce/ds-react": "7.15.1",
50
- "@spscommerce/ds-shared": "7.15.1"
46
+ "@sps-woodland/core": "7.16.1",
47
+ "@sps-woodland/tokens": "7.16.1",
48
+ "@spscommerce/ds-colors": "7.16.1",
49
+ "@spscommerce/ds-react": "7.16.1",
50
+ "@spscommerce/ds-shared": "7.16.1"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "pnpm run build:js && pnpm run build:types",