@sps-woodland/file-upload 8.0.0-rc1 → 8.0.0

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