@sps-woodland/file-upload 8.17.1 → 8.18.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 +11 -11
- package/lib/index.es.js +144 -144
- package/lib/style.css +1 -1
- package/package.json +12 -12
- package/vite.config.mjs +11 -2
package/lib/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const fe=require("react"),g=require("@sps-woodland/core"),c=require("@spscommerce/utils"),z=require("@sps-woodland/buttons");function ue(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const l in t)if(l!=="default"){const a=Object.getOwnPropertyDescriptor(t,l);Object.defineProperty(o,l,a.get?a:{enumerable:!0,get:()=>t[l]})}}return o.default=t,Object.freeze(o)}const e=ue(fe),L={"7Z":["application/x-7z-compressed"],AAC:["audio/aac"],ABW:["application/x-abiword"],ARC:["application/octet-stream"],AVI:["video/x-msvideo"],AZW:["application/vnd.amazon.ebook"],BIN:["application/octet-stream"],BMP:["image/bmp"],BZ:["application/x-bzip"],BZ2:["application/x-bzip2"],CER:["application/pkix-cert","application/x-x509-ca-cert"],CSH:["application/x-csh"],CSS:["text/css"],CSV:["text/csv","application/vnd.ms-excel"],DOC:["application/msword"],DOCX:["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],EML:["application/octet-stream","message/rfc822","multipart/mixed","message/rfc5322","message/rfc6532"],EOT:["application/vnd.ms-fontobject"],EPUB:["application/epub+zip"],ES:["application/ecmascript"],FLV:["video/x-flv"],GIF:["image/gif"],GZ:["application/x-gzip"],HTM:["text/html"],HTML:["text/html"],ICO:["image/x-icon"],ICS:["text/calendar"],JAR:["application/java-archive"],JPEG:["image/jpeg"],JPG:["image/jpeg"],JS:["application/javascript"],JSON:["application/json"],M3U:["audio/x-mpequrl"],MID:["audio/midi"],MIDI:["audio/midi"],MOV:["video/quicktime"],MP3:["audio/mpeg3"],MP4:["video/mp4"],MPEG:["video/mpeg"],MPKG:["application/vnd.apple.installer+xml"],ODP:["application/vnd.oasis.opendocument.presentation"],ODS:["application/vnd.oasis.opendocument.spreadsheet"],ODT:["application/vnd.oasis.opendocument.text"],OGA:["audio/ogg"],OGV:["video/ogg"],OGX:["application/ogg"],OTF:["font/otf"],PNG:["image/png"],PDF:["application/pdf"],PPT:["application/vnd.ms-powerpoint"],PPTX:["application/vnd.openxmlformats-officedocument.presentationml.presentation"],RAR:["application/x-rar-compressed"],RTF:["application/rtf"],SH:["application/x-sh"],SVG:["image/svg+xml"],SWF:["application/x-shockwave-flash"],TAR:["application/x-tar"],TIF:["image/tiff"],TIFF:["image/tiff"],TS:["application/typescript"],TTF:["font/ttf"],TXT:["text/plain"],VSD:["application/vnd.visio"],WAV:["audio/wav"],WEBA:["audio/webm"],WEBM:["video/webm"],WEBP:["image/webp"],WOFF:["font/woff"],WOFF2:["font/woff2"],XHTML:["application/xhtml+xml"],XLS:["application/vnd.ms-excel"],XLSX:["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],XML:["application/xml"],XUL:["application/vnd.mozilla.xul+xml"],ZIP:["application/zip"]};function me(t,o,l){return o in t?Object.defineProperty(t,o,{value:l,enumerable:!0,configurable:!0,writable:!0}):t[o]=l,t}function R(t,o){var l=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);o&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),l.push.apply(l,a)}return l}function W(t){for(var o=1;o<arguments.length;o++){var l=arguments[o]!=null?arguments[o]:{};o%2?R(Object(l),!0).forEach(function(a){me(t,a,l[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(l)):R(Object(l)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(l,a))})}return t}var he=(t,o,l)=>{for(var a of Object.keys(t)){var n;if(t[a]!==((n=o[a])!==null&&n!==void 0?n:l[a]))return!1}return!0},O=t=>o=>{var l=t.defaultClassName,a=W(W({},t.defaultVariants),o);for(var n in a){var w,F=(w=a[n])!==null&&w!==void 0?w:t.defaultVariants[n];if(F!=null){var p=F;typeof p=="boolean"&&(p=p===!0?"true":"false");var f=t.variantClassNames[n][p];f&&(l+=" "+f)}}for(var[b,D]of t.compoundVariants)he(b,a,t.defaultVariants)&&(l+=" "+D);return l},ve="rh07jws",k="rh07jwt",we="rh07jwr",ge=O({defaultClassName:"rh07jw0",variantClassNames:{active:{true:"rh07jw1",false:"rh07jw2"},mini:{true:"rh07jw3",false:"rh07jw4"},error:{true:"rh07jw5",false:"rh07jw6"},shown:{true:"rh07jw7",false:"rh07jw8"},disabled:{true:"rh07jw9",false:"rh07jwa"}},defaultVariants:{active:!1,mini:!1,error:!1,shown:!0,disabled:!1},compoundVariants:[]}),Fe="rh07jww",xe=O({defaultClassName:"rh07jwb",variantClassNames:{constrainContentWidth:{true:"rh07jwc",false:"rh07jwd"},disabled:{true:"rh07jwe",false:"rh07jwf"}},defaultVariants:{constrainContentWidth:!1,disabled:!1},compoundVariants:[]}),be="rh07jwv",ye="rh07jwx",Se=O({defaultClassName:"rh07jwh",variantClassNames:{mini:{true:"rh07jwi",false:"rh07jwj"},error:{true:"rh07jwk",false:"rh07jwl"},disabled:{true:"rh07jwm",false:"rh07jwn"}},defaultVariants:{mini:!1,error:!1,disabled:!1},compoundVariants:[]}),X="rh07jwg",Ee="rh07jwu",Ue=O({defaultClassName:"rh07jwo",variantClassNames:{mini:{true:"rh07jwp",false:"rh07jwq"}},defaultVariants:{mini:!1},compoundVariants:[]});function P({constrainContentWidth:t,description:o,multiple:l=!1,dismissable:a,processing:n,mini:w,downloadLabel:F,acceptExtensions:p,maxSize:f,customRequirement:b,onSelection:D,onDismiss:M,download:A,shown:y,className:G,disabled:d,children:Oe,...q}){const S=e.useRef(new Set),[Z,B]=e.useState(y),[De,H]=e.useState([]),[J,K]=e.useState(""),[I,_]=e.useState(),[Y,E]=e.useState(!1),[x,U]=e.useState(!1),[T,V]=e.useState([]),[Q,$]=e.useState(""),{t:v}=e.useContext(g.I18nContext),j=v(l?"design-system:fileUpload.instructions_plural":"design-system:fileUpload.instructions").split("|"),ee=o||(l?"Files":"File"),u=e.useRef(null);e.useEffect(()=>{y&&B(y)},[y]),e.useEffect(()=>{f&&ie(f)},[f]),e.useEffect(()=>{p&&le(p)},[p]);function te(){a&&(B(!1),M&&M())}function ie(i){try{_(c.parseFileSize(i))}catch{throw new Error(`Could not parse "${i}" as a file size.`)}}function le(i){const m=(Array.isArray(i)?i:i.trim().split(/\s?,\s?/)).map(h=>h.replace(/^\./,"")),r=m.map(h=>`.${h}`.toLowerCase());$(r.map((h,C)=>C>0&&C===r.length-1?`or ${h}`:h).join(r.length>2?", ":" ")),S.current.clear();for(const h of m){const C=Object.keys(L).includes(h.toUpperCase())?L[h.toUpperCase()]:[];for(const de of C)S.current.add(de)}K(r.concat(Array.from(S.current)).join(","))}function N(i){V([]);let s=[];const m=Array.from(i);for(const r of m)r===null?s.push("Not a file"):(p&&!S.current.has(r.type)&&s.push(r.name),f&&I&&r.size>I&&s.indexOf(r.name)===-1&&s.push(r.name));s.length?(U(!0),u.current&&u.current.value&&(u.current.value="")):(H(m),D(m)),V(s)}function ae(i){i.preventDefault(),U(!1),u.current&&u.current.click()}function oe(){A&&A()}function ne(i){i.stopPropagation(),N(i.target.files||[]),u.current&&u.current.value&&(u.current.value="")}function se(i){i.preventDefault(),i.stopPropagation(),E(!0),U(!1)}function re(i){i.preventDefault(),E(!0),U(!1)}function ce(i){i.preventDefault(),E(!1)}function pe(i){i.preventDefault(),i.stopPropagation(),E(!1),i.dataTransfer.items?N(Array.from(i.dataTransfer.items).map(s=>s.getAsFile())):N(i.dataTransfer.files)}return e.createElement("div",{onDrop:d?()=>{}:pe,onDragOver:d?()=>{}:se,onDragLeave:d?()=>{}:ce,onDragEnter:d?()=>{}:re,className:g.cl(ge({active:Y,mini:w,error:x,shown:Z,disabled:d}),G),...q},e.createElement("div",{className:g.cl(xe({constrainContentWidth:t,disabled:d}))},n?e.createElement("div",null,e.createElement(g.Spinner,{size:"md","aria-hidden":"true"}),e.createElement("div",{className:X},v("design-system:fileUpload.processing"))):e.createElement("div",null,e.createElement(g.Icon,{className:Se({mini:w,error:x,disabled:d}),icon:x?"exclamation-circle":"upload-cloud","aria-hidden":"true"}),e.createElement("div",{className:Ue({mini:w})},x?e.createElement("div",null,v(T.length>1?"design-system:fileUpload.cancelled_plural":"design-system:fileUpload.cancelled")):e.createElement("div",null,v("design-system:fileUpload.title",{description:ee}))),x?e.createElement("div",{className:we},new Set(T.map((i,s)=>{const m=Math.floor(i.length/2);return e.createElement("div",{className:ve,key:i},e.createElement("span",{className:k},i.substr(0,m)),e.createElement("div",{className:k},e.createElement("span",null,i.substr(m))),s<T.length-1?",":"")}))):e.createElement("span",null),e.createElement("div",{className:X},e.createElement("div",null,e.createElement("span",null,j[0]),d?e.createElement("u",null,j[1]):e.createElement("a",{href:"",onClick:ae},j[1]),e.createElement("span",null,j[2]))),e.createElement("div",{className:Ee},p?e.createElement("span",null,"("," ",v("design-system:fileUpload.acceptedTypes",{fileTypes:Q})," ",")"):"",f?e.createElement("span",null,"( ",v("design-system:fileUpload.maximumSize",{size:f})," )"):"",b?e.createElement("span",null," ",b," "):""),F&&e.createElement("div",{className:be},e.createElement(z.Button,{disabled:d,kind:"link",icon:"download-cloud",onClick:oe},F)))),a&&!n&&e.createElement("div",{className:Fe},e.createElement(z.Button,{disabled:d,kind:"icon",icon:"x",title:v("design-system:fileUpload.close"),onClick:te})),e.createElement("form",{className:ye},e.createElement("input",{ref:u,type:"file",accept:J||"*/*",multiple:l||void 0,onChange:ne})))}g.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"},disabled:{type:"boolean"}}});const je={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:c.code`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _e=require("react"),w=require("@sps-woodland/core"),p=require("@spscommerce/utils"),I=require("@sps-woodland/buttons");function fe(o){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const l in o)if(l!=="default"){const a=Object.getOwnPropertyDescriptor(o,l);Object.defineProperty(i,l,a.get?a:{enumerable:!0,get:()=>o[l]})}}return i.default=o,Object.freeze(i)}const e=fe(_e),V={"7Z":["application/x-7z-compressed"],AAC:["audio/aac"],ABW:["application/x-abiword"],ARC:["application/octet-stream"],AVI:["video/x-msvideo"],AZW:["application/vnd.amazon.ebook"],BIN:["application/octet-stream"],BMP:["image/bmp"],BZ:["application/x-bzip"],BZ2:["application/x-bzip2"],CER:["application/pkix-cert","application/x-x509-ca-cert"],CSH:["application/x-csh"],CSS:["text/css"],CSV:["text/csv","application/vnd.ms-excel"],DOC:["application/msword"],DOCX:["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],EML:["application/octet-stream","message/rfc822","multipart/mixed","message/rfc5322","message/rfc6532"],EOT:["application/vnd.ms-fontobject"],EPUB:["application/epub+zip"],ES:["application/ecmascript"],FLV:["video/x-flv"],GIF:["image/gif"],GZ:["application/x-gzip"],HTM:["text/html"],HTML:["text/html"],ICO:["image/x-icon"],ICS:["text/calendar"],JAR:["application/java-archive"],JPEG:["image/jpeg"],JPG:["image/jpeg"],JS:["application/javascript"],JSON:["application/json"],M3U:["audio/x-mpequrl"],MID:["audio/midi"],MIDI:["audio/midi"],MOV:["video/quicktime"],MP3:["audio/mpeg3"],MP4:["video/mp4"],MPEG:["video/mpeg"],MPKG:["application/vnd.apple.installer+xml"],ODP:["application/vnd.oasis.opendocument.presentation"],ODS:["application/vnd.oasis.opendocument.spreadsheet"],ODT:["application/vnd.oasis.opendocument.text"],OGA:["audio/ogg"],OGV:["video/ogg"],OGX:["application/ogg"],OTF:["font/otf"],PNG:["image/png"],PDF:["application/pdf"],PPT:["application/vnd.ms-powerpoint"],PPTX:["application/vnd.openxmlformats-officedocument.presentationml.presentation"],RAR:["application/x-rar-compressed"],RTF:["application/rtf"],SH:["application/x-sh"],SVG:["image/svg+xml"],SWF:["application/x-shockwave-flash"],TAR:["application/x-tar"],TIF:["image/tiff"],TIFF:["image/tiff"],TS:["application/typescript"],TTF:["font/ttf"],TXT:["text/plain"],VSD:["application/vnd.visio"],WAV:["audio/wav"],WEBA:["audio/webm"],WEBM:["video/webm"],WEBP:["image/webp"],WOFF:["font/woff"],WOFF2:["font/woff2"],XHTML:["application/xhtml+xml"],XLS:["application/vnd.ms-excel"],XLSX:["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],XML:["application/xml"],XUL:["application/vnd.mozilla.xul+xml"],ZIP:["application/zip"]};function ue(o,i,l){return i in o?Object.defineProperty(o,i,{value:l,enumerable:!0,configurable:!0,writable:!0}):o[i]=l,o}function z(o,i){var l=Object.keys(o);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(o);i&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),l.push.apply(l,a)}return l}function L(o){for(var i=1;i<arguments.length;i++){var l=arguments[i]!=null?arguments[i]:{};i%2?z(Object(l),!0).forEach(function(a){ue(o,a,l[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(l)):z(Object(l)).forEach(function(a){Object.defineProperty(o,a,Object.getOwnPropertyDescriptor(l,a))})}return o}var me=(o,i,l)=>{for(var a of Object.keys(o)){var n;if(o[a]!==((n=i[a])!==null&&n!==void 0?n:l[a]))return!1}return!0},C=o=>i=>{var l=o.defaultClassName,a=L(L({},o.defaultVariants),i);for(var n in a){var v,g=(v=a[n])!==null&&v!==void 0?v:o.defaultVariants[n];if(g!=null){var d=g;typeof d=="boolean"&&(d=d===!0?"true":"false");var _=o.variantClassNames[n][d];_&&(l+=" "+_)}}for(var[x,k]of o.compoundVariants)me(x,a,o.defaultVariants)&&(l+=" "+k);return l},he="pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jws",R="pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwt",ve="pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwr",we=C({defaultClassName:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw0",variantClassNames:{active:{true:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw1",false:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw2"},mini:{true:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw3",false:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw4"},error:{true:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw5",false:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw6"},shown:{true:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw7",false:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw8"},disabled:{true:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw9",false:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwa"}},defaultVariants:{active:!1,mini:!1,error:!1,shown:!0,disabled:!1},compoundVariants:[]}),ge="pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jww",Fe=C({defaultClassName:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwb",variantClassNames:{constrainContentWidth:{true:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwc",false:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwd"},disabled:{true:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwe",false:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwf"}},defaultVariants:{constrainContentWidth:!1,disabled:!1},compoundVariants:[]}),xe="pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwv",be="pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwx",ye=C({defaultClassName:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwh",variantClassNames:{mini:{true:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwi",false:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwj"},error:{true:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwk",false:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwl"},disabled:{true:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwm",false:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwn"}},defaultVariants:{mini:!1,error:!1,disabled:!1},compoundVariants:[]}),W="pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwg",Se="pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwu",Ee=C({defaultClassName:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwo",variantClassNames:{mini:{true:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwp",false:"pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwq"}},defaultVariants:{mini:!1},compoundVariants:[]});function T({constrainContentWidth:o,description:i,multiple:l=!1,dismissable:a,processing:n,mini:v,downloadLabel:g,acceptExtensions:d,maxSize:_,customRequirement:x,onSelection:k,onDismiss:N,download:P,shown:b,className:X,disabled:c,children:Ce,...G}){const y=e.useRef(new Set),[q,M]=e.useState(b),[ke,Z]=e.useState([]),[H,J]=e.useState(""),[A,K]=e.useState(),[Y,S]=e.useState(!1),[F,E]=e.useState(!1),[O,B]=e.useState([]),[Q,$]=e.useState(""),{t:h}=e.useContext(w.I18nContext),U=h(l?"design-system:fileUpload.instructions_plural":"design-system:fileUpload.instructions").split("|"),ee=i||(l?"Files":"File"),f=e.useRef(null);e.useEffect(()=>{b&&M(b)},[b]),e.useEffect(()=>{_&&te(_)},[_]),e.useEffect(()=>{d&&le(d)},[d]);function oe(){a&&(M(!1),N&&N())}function te(t){try{K(p.parseFileSize(t))}catch{throw new Error(`Could not parse "${t}" as a file size.`)}}function le(t){const u=(Array.isArray(t)?t:t.trim().split(/\s?,\s?/)).map(m=>m.replace(/^\./,"")),r=u.map(m=>`.${m}`.toLowerCase());$(r.map((m,j)=>j>0&&j===r.length-1?`or ${m}`:m).join(r.length>2?", ":" ")),y.current.clear();for(const m of u){const j=Object.keys(V).includes(m.toUpperCase())?V[m.toUpperCase()]:[];for(const ce of j)y.current.add(ce)}J(r.concat(Array.from(y.current)).join(","))}function D(t){B([]);let s=[];const u=Array.from(t);for(const r of u)r===null?s.push("Not a file"):(d&&!y.current.has(r.type)&&s.push(r.name),_&&A&&r.size>A&&s.indexOf(r.name)===-1&&s.push(r.name));s.length?(E(!0),f.current&&f.current.value&&(f.current.value="")):(Z(u),k(u)),B(s)}function ae(t){t.preventDefault(),E(!1),f.current&&f.current.click()}function ie(){P&&P()}function ne(t){t.stopPropagation(),D(t.target.files||[]),f.current&&f.current.value&&(f.current.value="")}function se(t){t.preventDefault(),t.stopPropagation(),S(!0),E(!1)}function re(t){t.preventDefault(),S(!0),E(!1)}function pe(t){t.preventDefault(),S(!1)}function de(t){t.preventDefault(),t.stopPropagation(),S(!1),t.dataTransfer.items?D(Array.from(t.dataTransfer.items).map(s=>s.getAsFile())):D(t.dataTransfer.files)}return e.createElement("div",{onDrop:c?()=>{}:de,onDragOver:c?()=>{}:se,onDragLeave:c?()=>{}:pe,onDragEnter:c?()=>{}:re,className:w.cl(we({active:Y,mini:v,error:F,shown:q,disabled:c}),X),...G},e.createElement("div",{className:w.cl(Fe({constrainContentWidth:o,disabled:c}))},n?e.createElement("div",null,e.createElement(w.Spinner,{size:"md","aria-hidden":"true"}),e.createElement("div",{className:W},h("design-system:fileUpload.processing"))):e.createElement("div",null,e.createElement(w.Icon,{className:ye({mini:v,error:F,disabled:c}),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:ee}))),F?e.createElement("div",{className:ve},new Set(O.map((t,s)=>{const u=Math.floor(t.length/2);return e.createElement("div",{className:he,key:t},e.createElement("span",{className:R},t.substr(0,u)),e.createElement("div",{className:R},e.createElement("span",null,t.substr(u))),s<O.length-1?",":"")}))):e.createElement("span",null),e.createElement("div",{className:W},e.createElement("div",null,e.createElement("span",null,U[0]),c?e.createElement("u",null,U[1]):e.createElement("a",{href:"",onClick:ae},U[1]),e.createElement("span",null,U[2]))),e.createElement("div",{className:Se},d?e.createElement("span",null,"("," ",h("design-system:fileUpload.acceptedTypes",{fileTypes:Q})," ",")"):"",_?e.createElement("span",null,"( ",h("design-system:fileUpload.maximumSize",{size:_})," )"):"",x?e.createElement("span",null," ",x," "):""),g&&e.createElement("div",{className:xe},e.createElement(I.Button,{disabled:c,kind:"link",icon:"download-cloud",onClick:ie},g)))),a&&!n&&e.createElement("div",{className:ge},e.createElement(I.Button,{disabled:c,kind:"icon",icon:"x",title:h("design-system:fileUpload.close"),onClick:oe})),e.createElement("form",{className:be},e.createElement("input",{ref:f,type:"file",accept:H||"*/*",multiple:l||void 0,onChange:ne})))}w.Metadata.set(T,{name:"FileUpload",props:{constrainContentWidth:{type:"boolean"},description:{type:"string"},multiple:{type:"boolean"},dismissable:{type:"boolean"},mini:{type:"boolean"},downloadLabel:{type:"string"},acceptExtensions:{type:"string[] | string"},maxSize:{type:"string"},customRequirement:{type:"string"},onSelection:{type:"(files: File[]) => void",required:!0},dismissal:{type:"() => void"},download:{type:"() => void"},disabled:{type:"boolean"}}});const Ue={components:[T],examples:{basic:{label:"Basic File Upload",description:"Simply allow the user to drag-and-drop or select a single file or multiple files at once.",examples:{basic:{description:"Single file upload",react:p.code`
|
|
2
2
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
3
3
|
|
|
4
4
|
function Component() {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<FileUpload onSelection={selectFile} />
|
|
11
11
|
)
|
|
12
12
|
}
|
|
13
|
-
`},multiple:{description:"Multiple file upload",react:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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,7 +153,7 @@
|
|
|
153
153
|
</div>
|
|
154
154
|
)
|
|
155
155
|
}
|
|
156
|
-
`}}},disabled:{label:"Disabled State",description:"File Upload have a disabled style for each possible state.",examples:{basic:{description:"Disabled File Upload",react:
|
|
156
|
+
`}}},disabled:{label:"Disabled State",description:"File Upload have a disabled style for each possible state.",examples:{basic:{description:"Disabled File Upload",react:p.code`
|
|
157
157
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
158
158
|
|
|
159
159
|
function Component() {
|
|
@@ -170,4 +170,4 @@
|
|
|
170
170
|
onSelection={selectFile} />
|
|
171
171
|
)
|
|
172
172
|
}
|
|
173
|
-
`}}}}},
|
|
173
|
+
`}}}}},je={"File Upload":Ue};exports.FileUpload=T;exports.MANIFEST=je;
|
package/lib/index.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
|
-
import { Metadata as
|
|
3
|
-
import { parseFileSize as
|
|
4
|
-
import { Button as
|
|
5
|
-
const
|
|
2
|
+
import { Metadata as _e, I18nContext as fe, cl as A, Spinner as ue, Icon as me } from "@sps-woodland/core";
|
|
3
|
+
import { parseFileSize as he, code as c } from "@spscommerce/utils";
|
|
4
|
+
import { Button as B } from "@sps-woodland/buttons";
|
|
5
|
+
const I = {
|
|
6
6
|
"7Z": ["application/x-7z-compressed"],
|
|
7
7
|
AAC: ["audio/aac"],
|
|
8
8
|
ABW: ["application/x-abiword"],
|
|
@@ -79,197 +79,197 @@ const z = {
|
|
|
79
79
|
XUL: ["application/vnd.mozilla.xul+xml"],
|
|
80
80
|
ZIP: ["application/zip"]
|
|
81
81
|
};
|
|
82
|
-
function
|
|
83
|
-
return
|
|
84
|
-
value:
|
|
82
|
+
function ve(a, i, l) {
|
|
83
|
+
return i in a ? Object.defineProperty(a, i, {
|
|
84
|
+
value: l,
|
|
85
85
|
enumerable: !0,
|
|
86
86
|
configurable: !0,
|
|
87
87
|
writable: !0
|
|
88
|
-
}) : i
|
|
88
|
+
}) : a[i] = l, a;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
var
|
|
90
|
+
function V(a, i) {
|
|
91
|
+
var l = Object.keys(a);
|
|
92
92
|
if (Object.getOwnPropertySymbols) {
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
return Object.getOwnPropertyDescriptor(
|
|
96
|
-
})),
|
|
93
|
+
var t = Object.getOwnPropertySymbols(a);
|
|
94
|
+
i && (t = t.filter(function(n) {
|
|
95
|
+
return Object.getOwnPropertyDescriptor(a, n).enumerable;
|
|
96
|
+
})), l.push.apply(l, t);
|
|
97
97
|
}
|
|
98
|
-
return
|
|
98
|
+
return l;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
for (var
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(
|
|
106
|
-
Object.defineProperty(
|
|
100
|
+
function z(a) {
|
|
101
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
102
|
+
var l = arguments[i] != null ? arguments[i] : {};
|
|
103
|
+
i % 2 ? V(Object(l), !0).forEach(function(t) {
|
|
104
|
+
ve(a, t, l[t]);
|
|
105
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(a, Object.getOwnPropertyDescriptors(l)) : V(Object(l)).forEach(function(t) {
|
|
106
|
+
Object.defineProperty(a, t, Object.getOwnPropertyDescriptor(l, t));
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
return
|
|
109
|
+
return a;
|
|
110
110
|
}
|
|
111
|
-
var
|
|
112
|
-
for (var
|
|
111
|
+
var we = (a, i, l) => {
|
|
112
|
+
for (var t of Object.keys(a)) {
|
|
113
113
|
var n;
|
|
114
|
-
if (
|
|
114
|
+
if (a[t] !== ((n = i[t]) !== null && n !== void 0 ? n : l[t]))
|
|
115
115
|
return !1;
|
|
116
116
|
}
|
|
117
117
|
return !0;
|
|
118
|
-
},
|
|
119
|
-
var
|
|
120
|
-
for (var n in
|
|
121
|
-
var
|
|
122
|
-
if (
|
|
123
|
-
var p =
|
|
118
|
+
}, j = (a) => (i) => {
|
|
119
|
+
var l = a.defaultClassName, t = z(z({}, a.defaultVariants), i);
|
|
120
|
+
for (var n in t) {
|
|
121
|
+
var v, w = (v = t[n]) !== null && v !== void 0 ? v : a.defaultVariants[n];
|
|
122
|
+
if (w != null) {
|
|
123
|
+
var p = w;
|
|
124
124
|
typeof p == "boolean" && (p = p === !0 ? "true" : "false");
|
|
125
|
-
var
|
|
125
|
+
var _ = (
|
|
126
126
|
// @ts-expect-error
|
|
127
|
-
|
|
127
|
+
a.variantClassNames[n][p]
|
|
128
128
|
);
|
|
129
|
-
|
|
129
|
+
_ && (l += " " + _);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
for (var [
|
|
133
|
-
|
|
134
|
-
return
|
|
135
|
-
},
|
|
136
|
-
function
|
|
137
|
-
constrainContentWidth:
|
|
138
|
-
description:
|
|
139
|
-
multiple:
|
|
140
|
-
dismissable:
|
|
132
|
+
for (var [F, C] of a.compoundVariants)
|
|
133
|
+
we(F, t, a.defaultVariants) && (l += " " + C);
|
|
134
|
+
return l;
|
|
135
|
+
}, ge = "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jws", L = "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwt", Fe = "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwr", xe = j({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw0", variantClassNames: { active: { true: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw1", false: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw2" }, mini: { true: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw3", false: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw4" }, error: { true: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw5", false: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw6" }, shown: { true: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw7", false: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw8" }, disabled: { true: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw9", false: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwa" } }, defaultVariants: { active: !1, mini: !1, error: !1, shown: !0, disabled: !1 }, compoundVariants: [] }), be = "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jww", ye = j({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwb", variantClassNames: { constrainContentWidth: { true: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwc", false: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwd" }, disabled: { true: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwe", false: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwf" } }, defaultVariants: { constrainContentWidth: !1, disabled: !1 }, compoundVariants: [] }), Ee = "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwv", Se = "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwx", Ue = j({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwh", variantClassNames: { mini: { true: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwi", false: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwj" }, error: { true: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwk", false: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwl" }, disabled: { true: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwm", false: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwn" } }, defaultVariants: { mini: !1, error: !1, disabled: !1 }, compoundVariants: [] }), W = "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwg", je = "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwu", Ce = j({ defaultClassName: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwo", variantClassNames: { mini: { true: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwp", false: "pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwq" } }, defaultVariants: { mini: !1 }, compoundVariants: [] });
|
|
136
|
+
function R({
|
|
137
|
+
constrainContentWidth: a,
|
|
138
|
+
description: i,
|
|
139
|
+
multiple: l = !1,
|
|
140
|
+
dismissable: t,
|
|
141
141
|
processing: n,
|
|
142
|
-
mini:
|
|
143
|
-
downloadLabel:
|
|
142
|
+
mini: v,
|
|
143
|
+
downloadLabel: w,
|
|
144
144
|
acceptExtensions: p,
|
|
145
|
-
maxSize:
|
|
146
|
-
customRequirement:
|
|
147
|
-
onSelection:
|
|
148
|
-
onDismiss:
|
|
149
|
-
download:
|
|
150
|
-
shown:
|
|
151
|
-
className:
|
|
152
|
-
disabled:
|
|
153
|
-
children:
|
|
154
|
-
...
|
|
145
|
+
maxSize: _,
|
|
146
|
+
customRequirement: F,
|
|
147
|
+
onSelection: C,
|
|
148
|
+
onDismiss: O,
|
|
149
|
+
download: T,
|
|
150
|
+
shown: x,
|
|
151
|
+
className: X,
|
|
152
|
+
disabled: d,
|
|
153
|
+
children: De,
|
|
154
|
+
...G
|
|
155
155
|
}) {
|
|
156
|
-
const
|
|
156
|
+
const b = e.useRef(/* @__PURE__ */ new Set()), [Z, N] = e.useState(x), [Oe, q] = e.useState([]), [H, J] = e.useState(""), [P, K] = e.useState(), [Y, y] = e.useState(!1), [g, E] = e.useState(!1), [k, M] = e.useState([]), [Q, $] = e.useState(""), { t: h } = e.useContext(fe), S = h(l ? "design-system:fileUpload.instructions_plural" : "design-system:fileUpload.instructions").split("|"), ee = i || (l ? "Files" : "File"), f = e.useRef(null);
|
|
157
157
|
e.useEffect(() => {
|
|
158
|
-
|
|
159
|
-
}, [
|
|
160
|
-
|
|
161
|
-
}, [
|
|
162
|
-
p &&
|
|
158
|
+
x && N(x);
|
|
159
|
+
}, [x]), e.useEffect(() => {
|
|
160
|
+
_ && ae(_);
|
|
161
|
+
}, [_]), e.useEffect(() => {
|
|
162
|
+
p && le(p);
|
|
163
163
|
}, [p]);
|
|
164
|
-
function
|
|
165
|
-
|
|
164
|
+
function oe() {
|
|
165
|
+
t && (N(!1), O && O());
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function ae(o) {
|
|
168
168
|
try {
|
|
169
|
-
|
|
169
|
+
K(he(o));
|
|
170
170
|
} catch {
|
|
171
|
-
throw new Error(`Could not parse "${
|
|
171
|
+
throw new Error(`Could not parse "${o}" as a file size.`);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
const
|
|
174
|
+
function le(o) {
|
|
175
|
+
const u = (Array.isArray(o) ? o : o.trim().split(/\s?,\s?/)).map((m) => m.replace(/^\./, "")), r = u.map((m) => `.${m}`.toLowerCase());
|
|
176
176
|
$(
|
|
177
|
-
r.map((
|
|
178
|
-
),
|
|
179
|
-
for (const
|
|
180
|
-
const
|
|
181
|
-
for (const
|
|
182
|
-
|
|
177
|
+
r.map((m, U) => U > 0 && U === r.length - 1 ? `or ${m}` : m).join(r.length > 2 ? ", " : " ")
|
|
178
|
+
), b.current.clear();
|
|
179
|
+
for (const m of u) {
|
|
180
|
+
const U = Object.keys(I).includes(m.toUpperCase()) ? I[m.toUpperCase()] : [];
|
|
181
|
+
for (const ce of U)
|
|
182
|
+
b.current.add(ce);
|
|
183
183
|
}
|
|
184
|
-
|
|
184
|
+
J(r.concat(Array.from(b.current)).join(","));
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
|
|
186
|
+
function D(o) {
|
|
187
|
+
M([]);
|
|
188
188
|
let s = [];
|
|
189
|
-
const
|
|
190
|
-
for (const r of
|
|
191
|
-
r === null ? s.push("Not a file") : (p && !
|
|
192
|
-
s.length ? (
|
|
189
|
+
const u = Array.from(o);
|
|
190
|
+
for (const r of u)
|
|
191
|
+
r === null ? s.push("Not a file") : (p && !b.current.has(r.type) && s.push(r.name), _ && P && r.size > P && s.indexOf(r.name) === -1 && s.push(r.name));
|
|
192
|
+
s.length ? (E(!0), f.current && f.current.value && (f.current.value = "")) : (q(u), C(u)), M(s);
|
|
193
193
|
}
|
|
194
|
-
function
|
|
195
|
-
|
|
194
|
+
function te(o) {
|
|
195
|
+
o.preventDefault(), E(!1), f.current && f.current.click();
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
|
|
197
|
+
function ie() {
|
|
198
|
+
T && T();
|
|
199
199
|
}
|
|
200
|
-
function ne(
|
|
201
|
-
|
|
200
|
+
function ne(o) {
|
|
201
|
+
o.stopPropagation(), D(o.target.files || []), f.current && f.current.value && (f.current.value = "");
|
|
202
202
|
}
|
|
203
|
-
function se(
|
|
204
|
-
|
|
203
|
+
function se(o) {
|
|
204
|
+
o.preventDefault(), o.stopPropagation(), y(!0), E(!1);
|
|
205
205
|
}
|
|
206
|
-
function re(
|
|
207
|
-
|
|
206
|
+
function re(o) {
|
|
207
|
+
o.preventDefault(), y(!0), E(!1);
|
|
208
208
|
}
|
|
209
|
-
function pe(
|
|
210
|
-
|
|
209
|
+
function pe(o) {
|
|
210
|
+
o.preventDefault(), y(!1);
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
|
|
214
|
-
Array.from(
|
|
212
|
+
function de(o) {
|
|
213
|
+
o.preventDefault(), o.stopPropagation(), y(!1), o.dataTransfer.items ? D(
|
|
214
|
+
Array.from(o.dataTransfer.items).map(
|
|
215
215
|
(s) => s.getAsFile()
|
|
216
216
|
)
|
|
217
|
-
) :
|
|
217
|
+
) : D(o.dataTransfer.files);
|
|
218
218
|
}
|
|
219
219
|
return /* @__PURE__ */ e.createElement(
|
|
220
220
|
"div",
|
|
221
221
|
{
|
|
222
|
-
onDrop:
|
|
223
|
-
} :
|
|
224
|
-
onDragOver:
|
|
222
|
+
onDrop: d ? () => {
|
|
223
|
+
} : de,
|
|
224
|
+
onDragOver: d ? () => {
|
|
225
225
|
} : se,
|
|
226
|
-
onDragLeave:
|
|
226
|
+
onDragLeave: d ? () => {
|
|
227
227
|
} : pe,
|
|
228
|
-
onDragEnter:
|
|
228
|
+
onDragEnter: d ? () => {
|
|
229
229
|
} : re,
|
|
230
|
-
className:
|
|
231
|
-
...
|
|
230
|
+
className: A(xe({ active: Y, mini: v, error: g, shown: Z, disabled: d }), X),
|
|
231
|
+
...G
|
|
232
232
|
},
|
|
233
|
-
/* @__PURE__ */ e.createElement("div", { className:
|
|
234
|
-
|
|
233
|
+
/* @__PURE__ */ e.createElement("div", { className: A(ye({ constrainContentWidth: a, disabled: d })) }, n ? /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(ue, { size: "md", "aria-hidden": "true" }), /* @__PURE__ */ e.createElement("div", { className: W }, h("design-system:fileUpload.processing"))) : /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(
|
|
234
|
+
me,
|
|
235
235
|
{
|
|
236
|
-
className:
|
|
237
|
-
icon:
|
|
236
|
+
className: Ue({ mini: v, error: g, disabled: d }),
|
|
237
|
+
icon: g ? "exclamation-circle" : "upload-cloud",
|
|
238
238
|
"aria-hidden": "true"
|
|
239
239
|
}
|
|
240
|
-
), /* @__PURE__ */ e.createElement("div", { className:
|
|
241
|
-
|
|
242
|
-
)) : /* @__PURE__ */ e.createElement("div", null,
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
return /* @__PURE__ */ e.createElement("div", { className:
|
|
240
|
+
), /* @__PURE__ */ e.createElement("div", { className: Ce({ mini: v }) }, g ? /* @__PURE__ */ e.createElement("div", null, h(
|
|
241
|
+
k.length > 1 ? "design-system:fileUpload.cancelled_plural" : "design-system:fileUpload.cancelled"
|
|
242
|
+
)) : /* @__PURE__ */ e.createElement("div", null, h("design-system:fileUpload.title", { description: ee }))), g ? /* @__PURE__ */ e.createElement("div", { className: Fe }, new Set(
|
|
243
|
+
k.map((o, s) => {
|
|
244
|
+
const u = Math.floor(o.length / 2);
|
|
245
|
+
return /* @__PURE__ */ e.createElement("div", { className: ge, key: o }, /* @__PURE__ */ e.createElement("span", { className: L }, o.substr(0, u)), /* @__PURE__ */ e.createElement("div", { className: L }, /* @__PURE__ */ e.createElement("span", null, o.substr(u))), s < k.length - 1 ? "," : "");
|
|
246
246
|
})
|
|
247
|
-
)) : /* @__PURE__ */ e.createElement("span", null), /* @__PURE__ */ e.createElement("div", { className:
|
|
248
|
-
fileTypes:
|
|
249
|
-
}), " ", ")") : "",
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
)) : /* @__PURE__ */ e.createElement("span", null), /* @__PURE__ */ e.createElement("div", { className: W }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("span", null, S[0]), d ? /* @__PURE__ */ e.createElement("u", null, S[1]) : /* @__PURE__ */ e.createElement("a", { href: "", onClick: te }, S[1]), /* @__PURE__ */ e.createElement("span", null, S[2]))), /* @__PURE__ */ e.createElement("div", { className: je }, p ? /* @__PURE__ */ e.createElement("span", null, "(", " ", h("design-system:fileUpload.acceptedTypes", {
|
|
248
|
+
fileTypes: Q
|
|
249
|
+
}), " ", ")") : "", _ ? /* @__PURE__ */ e.createElement("span", null, "( ", h("design-system:fileUpload.maximumSize", { size: _ }), " )") : "", F ? /* @__PURE__ */ e.createElement("span", null, " ", F, " ") : ""), w && /* @__PURE__ */ e.createElement("div", { className: Ee }, /* @__PURE__ */ e.createElement(B, { disabled: d, kind: "link", icon: "download-cloud", onClick: ie }, w)))),
|
|
250
|
+
t && !n && /* @__PURE__ */ e.createElement("div", { className: be }, /* @__PURE__ */ e.createElement(
|
|
251
|
+
B,
|
|
252
252
|
{
|
|
253
|
-
disabled:
|
|
253
|
+
disabled: d,
|
|
254
254
|
kind: "icon",
|
|
255
255
|
icon: "x",
|
|
256
|
-
title:
|
|
257
|
-
onClick:
|
|
256
|
+
title: h("design-system:fileUpload.close"),
|
|
257
|
+
onClick: oe
|
|
258
258
|
}
|
|
259
259
|
)),
|
|
260
|
-
/* @__PURE__ */ e.createElement("form", { className:
|
|
260
|
+
/* @__PURE__ */ e.createElement("form", { className: Se }, /* @__PURE__ */ e.createElement(
|
|
261
261
|
"input",
|
|
262
262
|
{
|
|
263
|
-
ref:
|
|
263
|
+
ref: f,
|
|
264
264
|
type: "file",
|
|
265
|
-
accept:
|
|
266
|
-
multiple:
|
|
265
|
+
accept: H || "*/*",
|
|
266
|
+
multiple: l || void 0,
|
|
267
267
|
onChange: ne
|
|
268
268
|
}
|
|
269
269
|
))
|
|
270
270
|
);
|
|
271
271
|
}
|
|
272
|
-
|
|
272
|
+
_e.set(R, {
|
|
273
273
|
name: "FileUpload",
|
|
274
274
|
props: {
|
|
275
275
|
constrainContentWidth: { type: "boolean" },
|
|
@@ -287,8 +287,8 @@ fe.set(X, {
|
|
|
287
287
|
disabled: { type: "boolean" }
|
|
288
288
|
}
|
|
289
289
|
});
|
|
290
|
-
const
|
|
291
|
-
components: [
|
|
290
|
+
const ke = {
|
|
291
|
+
components: [R],
|
|
292
292
|
examples: {
|
|
293
293
|
basic: {
|
|
294
294
|
label: "Basic File Upload",
|
|
@@ -296,7 +296,7 @@ const Oe = {
|
|
|
296
296
|
examples: {
|
|
297
297
|
basic: {
|
|
298
298
|
description: "Single file upload",
|
|
299
|
-
react:
|
|
299
|
+
react: c`
|
|
300
300
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
301
301
|
|
|
302
302
|
function Component() {
|
|
@@ -312,7 +312,7 @@ const Oe = {
|
|
|
312
312
|
},
|
|
313
313
|
multiple: {
|
|
314
314
|
description: "Multiple file upload",
|
|
315
|
-
react:
|
|
315
|
+
react: c`
|
|
316
316
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
317
317
|
|
|
318
318
|
function Component() {
|
|
@@ -334,7 +334,7 @@ const Oe = {
|
|
|
334
334
|
examples: {
|
|
335
335
|
maxSize: {
|
|
336
336
|
description: "Maximum size",
|
|
337
|
-
react:
|
|
337
|
+
react: c`
|
|
338
338
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
339
339
|
|
|
340
340
|
function Component() {
|
|
@@ -350,7 +350,7 @@ const Oe = {
|
|
|
350
350
|
},
|
|
351
351
|
fileWhitelist: {
|
|
352
352
|
description: "File type whitelist",
|
|
353
|
-
react:
|
|
353
|
+
react: c`
|
|
354
354
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
355
355
|
|
|
356
356
|
function Component() {
|
|
@@ -371,7 +371,7 @@ const Oe = {
|
|
|
371
371
|
},
|
|
372
372
|
bothRestrictions: {
|
|
373
373
|
description: "Both restrictions",
|
|
374
|
-
react:
|
|
374
|
+
react: c`
|
|
375
375
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
376
376
|
|
|
377
377
|
function Component() {
|
|
@@ -398,7 +398,7 @@ const Oe = {
|
|
|
398
398
|
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.",
|
|
399
399
|
examples: {
|
|
400
400
|
basic: {
|
|
401
|
-
react:
|
|
401
|
+
react: c`
|
|
402
402
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
403
403
|
import { Button } from "@sps-woodland/buttons";
|
|
404
404
|
|
|
@@ -437,7 +437,7 @@ const Oe = {
|
|
|
437
437
|
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.",
|
|
438
438
|
examples: {
|
|
439
439
|
basic: {
|
|
440
|
-
react:
|
|
440
|
+
react: c`
|
|
441
441
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
442
442
|
|
|
443
443
|
function Component() {
|
|
@@ -468,7 +468,7 @@ const Oe = {
|
|
|
468
468
|
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.",
|
|
469
469
|
examples: {
|
|
470
470
|
basic: {
|
|
471
|
-
react:
|
|
471
|
+
react: c`
|
|
472
472
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
473
473
|
|
|
474
474
|
function Component() {
|
|
@@ -493,7 +493,7 @@ const Oe = {
|
|
|
493
493
|
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.",
|
|
494
494
|
examples: {
|
|
495
495
|
basic: {
|
|
496
|
-
react:
|
|
496
|
+
react: c`
|
|
497
497
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
498
498
|
|
|
499
499
|
function Component() {
|
|
@@ -519,7 +519,7 @@ const Oe = {
|
|
|
519
519
|
examples: {
|
|
520
520
|
basic: {
|
|
521
521
|
description: "Disabled File Upload",
|
|
522
|
-
react:
|
|
522
|
+
react: c`
|
|
523
523
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
524
524
|
|
|
525
525
|
function Component() {
|
|
@@ -541,10 +541,10 @@ const Oe = {
|
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
|
-
},
|
|
545
|
-
"File Upload":
|
|
544
|
+
}, Me = {
|
|
545
|
+
"File Upload": ke
|
|
546
546
|
};
|
|
547
547
|
export {
|
|
548
|
-
|
|
549
|
-
|
|
548
|
+
R as FileUpload,
|
|
549
|
+
Me as MANIFEST
|
|
550
550
|
};
|
package/lib/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw0{border-width:.0625rem;border-style:dashed;border-radius:.25rem;display:block;padding:1rem;position:relative}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw1{background-color:#f4ecf2;border-color:#91467f;border-style:solid}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw3{padding:1rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw5{border-color:#de012e}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw8{display:none}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jw9{border-color:#d2d4d4}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwb{color:#4b5356;margin:0 auto;text-align:center}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwc{width:50%}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwe{color:#717779}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwg{font-size:.75rem;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwh{color:#717779;display:block;margin-bottom:.25rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwi{font-size:1.5rem;line-height:1.5rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwj{font-size:3rem;line-height:3rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwk{color:#de012e}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwm{opacity:.5}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwo{font-weight:600;margin-bottom:.25rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwp{font-size:1rem;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwq{font-size:1.125rem;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwr{font-size:.875rem;font-weight:600;line-height:1.25rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jws{display:flex;justify-content:center;white-space:nowrap}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwt{max-width:50%;overflow:hidden}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwt:first-child{text-overflow:ellipsis}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwt:last-child{float:right}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwu{font-size:.75rem;line-height:1.125rem;margin-top:.25rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwu>span+span{margin-left:.125rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwv{margin-top:1rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jww{position:absolute;right:.5rem;top:.5rem}.pkg_sps-woodland_file-upload__version_8_18_0__hash_rh07jwx{display:none}
|
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.
|
|
4
|
+
"version": "8.18.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/utils": "^7.0.0",
|
|
31
31
|
"react": "^16.14.0",
|
|
32
32
|
"react-dom": "^16.14.0",
|
|
33
|
-
"@sps-woodland/buttons": "8.
|
|
34
|
-
"@sps-woodland/core": "8.
|
|
35
|
-
"@sps-woodland/tokens": "8.
|
|
36
|
-
"@spscommerce/ds-react": "8.
|
|
37
|
-
"@spscommerce/ds-shared": "8.
|
|
33
|
+
"@sps-woodland/buttons": "8.18.0",
|
|
34
|
+
"@sps-woodland/core": "8.18.0",
|
|
35
|
+
"@sps-woodland/tokens": "8.18.0",
|
|
36
|
+
"@spscommerce/ds-react": "8.18.0",
|
|
37
|
+
"@spscommerce/ds-shared": "8.18.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@spscommerce/ds-illustrations": "^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/buttons": "8.
|
|
47
|
-
"@sps-woodland/core": "8.
|
|
48
|
-
"@sps-woodland/tokens": "8.
|
|
49
|
-
"@spscommerce/ds-colors": "8.
|
|
50
|
-
"@spscommerce/ds-react": "8.
|
|
51
|
-
"@spscommerce/ds-shared": "8.
|
|
46
|
+
"@sps-woodland/buttons": "8.18.0",
|
|
47
|
+
"@sps-woodland/core": "8.18.0",
|
|
48
|
+
"@sps-woodland/tokens": "8.18.0",
|
|
49
|
+
"@spscommerce/ds-colors": "8.18.0",
|
|
50
|
+
"@spscommerce/ds-react": "8.18.0",
|
|
51
|
+
"@spscommerce/ds-shared": "8.18.0"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "pnpm run build:js && pnpm run build:types",
|
package/vite.config.mjs
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
|
|
3
3
|
import { defineConfig } from "vite";
|
|
4
|
-
|
|
4
|
+
import { getVanillaExtractPluginProps } from "../../../scripts/vanilla-extract-plugin-props.mjs";
|
|
5
5
|
import pkg from "./package.json";
|
|
6
6
|
|
|
7
|
+
const packageVersion = process.env.PREDICTED_VERSION || pkg.version;
|
|
8
|
+
|
|
7
9
|
export default defineConfig({
|
|
8
|
-
plugins: [
|
|
10
|
+
plugins: [
|
|
11
|
+
vanillaExtractPlugin(
|
|
12
|
+
getVanillaExtractPluginProps({
|
|
13
|
+
packageName: pkg.name,
|
|
14
|
+
packageVersion,
|
|
15
|
+
})
|
|
16
|
+
),
|
|
17
|
+
],
|
|
9
18
|
build: {
|
|
10
19
|
lib: {
|
|
11
20
|
entry: path.resolve(__dirname, "src/index.ts"),
|