@sps-woodland/file-upload 8.13.1 → 8.14.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.
@@ -25,6 +25,12 @@ export declare const fileUpload: import("@vanilla-extract/recipes/dist/declarati
25
25
  display: "none";
26
26
  };
27
27
  };
28
+ disabled: {
29
+ true: {
30
+ borderColor: string;
31
+ };
32
+ false: {};
33
+ };
28
34
  }>;
29
35
  export declare const fileUploadContent: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
30
36
  constrainContentWidth: {
@@ -33,6 +39,12 @@ export declare const fileUploadContent: import("@vanilla-extract/recipes/dist/de
33
39
  };
34
40
  false: {};
35
41
  };
42
+ disabled: {
43
+ true: {
44
+ color: string;
45
+ };
46
+ false: {};
47
+ };
36
48
  }>;
37
49
  export declare const fileUploadInstructions: string;
38
50
  export declare const fileUploadIcon: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
@@ -52,6 +64,12 @@ export declare const fileUploadIcon: import("@vanilla-extract/recipes/dist/decla
52
64
  };
53
65
  false: {};
54
66
  };
67
+ disabled: {
68
+ true: {
69
+ opacity: number;
70
+ };
71
+ false: {};
72
+ };
55
73
  }>;
56
74
  export declare const fileUploadTitle: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
57
75
  mini: {
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { ComponentProps } from "@sps-woodland/core";
3
- export declare function FileUpload({ constrainContentWidth, description, multiple, dismissable, processing, mini, downloadLabel, acceptExtensions, maxSize, customRequirement, onSelection, onDismiss, download, shown, className, children, ...rest }: ComponentProps<{
3
+ export declare function FileUpload({ constrainContentWidth, description, multiple, dismissable, processing, mini, downloadLabel, acceptExtensions, maxSize, customRequirement, onSelection, onDismiss, download, shown, className, disabled, children, ...rest }: ComponentProps<{
4
4
  constrainContentWidth?: boolean;
5
5
  description?: string;
6
6
  multiple?: boolean;
@@ -15,4 +15,5 @@ export declare function FileUpload({ constrainContentWidth, description, multipl
15
15
  onSelection: (files: File[]) => void;
16
16
  onDismiss?: () => void;
17
17
  download?: () => void;
18
+ disabled?: boolean;
18
19
  }>): React.ReactElement;
package/lib/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=require("react"),g=require("@sps-woodland/core"),p=require("@spscommerce/utils"),V=require("@sps-woodland/buttons");function fe(t){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(l,a,o.get?o:{enumerable:!0,get:()=>t[a]})}}return l.default=t,Object.freeze(l)}const e=fe(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"],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(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){ue(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,w=(v=o[n])!==null&&v!==void 0?v:t.defaultVariants[n];if(w!=null){var c=w;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",L="rh07jwn",ve="rh07jwl",ge=j({defaultClassName:"rh07jw0",variantClassNames:{active:{true:"rh07jw1",false:"rh07jw2"},mini:{true:"rh07jw3",false:"rh07jw4"},error:{true:"rh07jw5",false:"rh07jw6"},shown:{true:"rh07jw7",false:"rh07jw8"}},defaultVariants:{active:!1,mini:!1,error:!1,shown:!0},compoundVariants:[]}),we="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:[]}),k="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:w,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),[q,A]=e.useState(b),[Oe,Z]=e.useState([]),[H,J]=e.useState(""),[B,K]=e.useState(),[_,S]=e.useState(!1),[F,E]=e.useState(!1),[O,I]=e.useState([]),[Y,Q]=e.useState(""),{t:h}=e.useContext(g.I18nContext),D=h(a?"design-system:fileUpload.instructions_plural":"design-system:fileUpload.instructions").split("|"),$=l||(a?"Files":"File"),f=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{K(p.parseFileSize(i))}catch{throw new Error(`Could not parse "${i}" as a file size.`)}}function ie(i){const u=(Array.isArray(i)?i:i.trim().split(/\s?,\s?/)).map(m=>m.replace(/^\./,"")),r=u.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 u){const U=Object.keys(z).includes(m.toUpperCase())?z[m.toUpperCase()]:[];for(const pe of U)y.current.add(pe)}J(r.concat(Array.from(y.current)).join(","))}function T(i){I([]);let s=[];const u=Array.from(i);for(const r of u)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),f.current&&f.current.value&&(f.current.value="")):(Z(u),C(u)),I(s)}function ae(i){i.preventDefault(),E(!1),f.current&&f.current.click()}function oe(){M&&M()}function le(i){i.stopPropagation(),T(i.target.files||[]),f.current&&f.current.value&&(f.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:g.cl(ge({active:_,mini:v,error:F,shown:q}),X),...G},e.createElement("div",{className:g.cl(Fe({constrainContentWidth:t}))},n?e.createElement("div",null,e.createElement(g.Spinner,{size:"md","aria-hidden":"true"}),e.createElement("div",{className:k},h("design-system:fileUpload.processing"))):e.createElement("div",null,e.createElement(g.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 u=Math.floor(i.length/2);return e.createElement("div",{className:he,key:i},e.createElement("span",{className:L},i.substr(0,u)),e.createElement("div",{className:L},e.createElement("span",null,i.substr(u))),s<O.length-1?",":"")}))):e.createElement("span",null),e.createElement("div",{className:k},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," "):""),w&&e.createElement("div",{className:xe},e.createElement(V.Button,{kind:"link",icon:"download-cloud",onClick:oe},w)))),o&&!n&&e.createElement("div",{className:we},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:f,type:"file",accept:H||"*/*",multiple:a||void 0,onChange:le})))}g.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`
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`
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:p.code`
13
+ `},multiple:{description:"Multiple file upload",react:c.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:p.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:c.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:p.code`
37
+ `},fileWhitelist:{description:"File type whitelist",react:c.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:p.code`
54
+ `},bothRestrictions:{description:"Both restrictions",react:c.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:p.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:c.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:p.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:c.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:p.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:c.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:p.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:c.code`
141
141
  import { FileUpload } from "@sps-woodland/file-upload";
142
142
 
143
143
  function Component() {
@@ -153,4 +153,21 @@
153
153
  </div>
154
154
  )
155
155
  }
156
- `}}}}},je={"File Upload":Ue};exports.FileUpload=N;exports.MANIFEST=je;
156
+ `}}},disabled:{label:"Disabled State",description:"File Upload have a disabled style for each possible state.",examples:{basic:{description:"Disabled File Upload",react:c.code`
157
+ import { FileUpload } from "@sps-woodland/file-upload";
158
+
159
+ function Component() {
160
+ function selectFile(file) {
161
+ console.log(file);
162
+ }
163
+
164
+ return (
165
+ <FileUpload
166
+ disabled
167
+ downloadLabel="Download Excel Template" download={() => {}}
168
+ dismissable onDismiss={() => {}}
169
+ acceptExtensions="XLS, xlsx, .csv" maxSize="100KB"
170
+ onSelection={selectFile} />
171
+ )
172
+ }
173
+ `}}}}},Ce={"File Upload":je};exports.FileUpload=P;exports.MANIFEST=Ce;
package/lib/index.es.js CHANGED
@@ -1,8 +1,8 @@
1
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
- import { parseFileSize as he, code as m } from "@spscommerce/utils";
4
- import { Button as I } from "@sps-woodland/buttons";
5
- const V = {
2
+ import { Metadata as fe, I18nContext as ue, cl as I, Spinner as me, Icon as he } from "@sps-woodland/core";
3
+ import { parseFileSize as ve, code as d } from "@spscommerce/utils";
4
+ import { Button as V } from "@sps-woodland/buttons";
5
+ const z = {
6
6
  "7Z": ["application/x-7z-compressed"],
7
7
  AAC: ["audio/aac"],
8
8
  ABW: ["application/x-abiword"],
@@ -79,7 +79,7 @@ const V = {
79
79
  XUL: ["application/vnd.mozilla.xul+xml"],
80
80
  ZIP: ["application/zip"]
81
81
  };
82
- function ve(i, o, a) {
82
+ function we(i, o, a) {
83
83
  return o in i ? Object.defineProperty(i, o, {
84
84
  value: a,
85
85
  enumerable: !0,
@@ -87,7 +87,7 @@ function ve(i, o, a) {
87
87
  writable: !0
88
88
  }) : i[o] = a, i;
89
89
  }
90
- function W(i, o) {
90
+ function L(i, o) {
91
91
  var a = Object.keys(i);
92
92
  if (Object.getOwnPropertySymbols) {
93
93
  var l = Object.getOwnPropertySymbols(i);
@@ -97,173 +97,179 @@ function W(i, o) {
97
97
  }
98
98
  return a;
99
99
  }
100
- function z(i) {
100
+ function W(i) {
101
101
  for (var o = 1; o < arguments.length; o++) {
102
102
  var a = arguments[o] != null ? arguments[o] : {};
103
- o % 2 ? W(Object(a), !0).forEach(function(l) {
104
- ve(i, l, a[l]);
105
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(i, Object.getOwnPropertyDescriptors(a)) : W(Object(a)).forEach(function(l) {
103
+ o % 2 ? L(Object(a), !0).forEach(function(l) {
104
+ we(i, l, a[l]);
105
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(i, Object.getOwnPropertyDescriptors(a)) : L(Object(a)).forEach(function(l) {
106
106
  Object.defineProperty(i, l, Object.getOwnPropertyDescriptor(a, l));
107
107
  });
108
108
  }
109
109
  return i;
110
110
  }
111
- var we = (i, o, a) => {
111
+ var ge = (i, o, a) => {
112
112
  for (var l of Object.keys(i)) {
113
113
  var n;
114
114
  if (i[l] !== ((n = o[l]) !== null && n !== void 0 ? n : a[l]))
115
115
  return !1;
116
116
  }
117
117
  return !0;
118
- }, U = (i) => (o) => {
119
- var a = i.defaultClassName, l = z(z({}, i.defaultVariants), o);
118
+ }, C = (i) => (o) => {
119
+ var a = i.defaultClassName, l = W(W({}, i.defaultVariants), o);
120
120
  for (var n in l) {
121
- var v, w = (v = l[n]) !== null && v !== void 0 ? v : i.defaultVariants[n];
122
- if (w != null) {
123
- var p = w;
121
+ var w, g = (w = l[n]) !== null && w !== void 0 ? w : i.defaultVariants[n];
122
+ if (g != null) {
123
+ var p = g;
124
124
  typeof p == "boolean" && (p = p === !0 ? "true" : "false");
125
- var c = (
125
+ var f = (
126
126
  // @ts-expect-error
127
127
  i.variantClassNames[n][p]
128
128
  );
129
- c && (a += " " + c);
129
+ f && (a += " " + f);
130
130
  }
131
131
  }
132
- for (var [F, C] of i.compoundVariants)
133
- we(F, l, i.defaultVariants) && (a += " " + C);
132
+ for (var [x, D] of i.compoundVariants)
133
+ ge(x, l, i.defaultVariants) && (a += " " + D);
134
134
  return a;
135
- }, 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: [] });
136
- function k({
135
+ }, Fe = "rh07jws", R = "rh07jwt", xe = "rh07jwr", be = C({ 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: [] }), ye = "rh07jww", Ee = C({ defaultClassName: "rh07jwb", variantClassNames: { constrainContentWidth: { true: "rh07jwc", false: "rh07jwd" }, disabled: { true: "rh07jwe", false: "rh07jwf" } }, defaultVariants: { constrainContentWidth: !1, disabled: !1 }, compoundVariants: [] }), Se = "rh07jwv", Ue = "rh07jwx", je = C({ 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: [] }), k = "rh07jwg", Ce = "rh07jwu", De = C({ defaultClassName: "rh07jwo", variantClassNames: { mini: { true: "rh07jwp", false: "rh07jwq" } }, defaultVariants: { mini: !1 }, compoundVariants: [] });
136
+ function X({
137
137
  constrainContentWidth: i,
138
138
  description: o,
139
139
  multiple: a = !1,
140
140
  dismissable: l,
141
141
  processing: n,
142
- mini: v,
143
- downloadLabel: w,
142
+ mini: w,
143
+ downloadLabel: g,
144
144
  acceptExtensions: p,
145
- maxSize: c,
146
- customRequirement: F,
147
- onSelection: C,
148
- onDismiss: T,
149
- download: N,
150
- shown: x,
151
- className: X,
152
- children: De,
153
- ...G
145
+ maxSize: f,
146
+ customRequirement: x,
147
+ onSelection: D,
148
+ onDismiss: N,
149
+ download: P,
150
+ shown: b,
151
+ className: G,
152
+ disabled: c,
153
+ children: Te,
154
+ ...Z
154
155
  }) {
155
- const y = e.useRef(/* @__PURE__ */ new Set()), [Z, P] = e.useState(x), [Te, q] = e.useState([]), [H, J] = e.useState(""), [M, K] = e.useState(), [Y, b] = e.useState(!1), [g, E] = e.useState(!1), [j, A] = e.useState([]), [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);
156
+ const y = e.useRef(/* @__PURE__ */ new Set()), [q, M] = e.useState(b), [Ne, H] = e.useState([]), [J, K] = e.useState(""), [A, Y] = e.useState(), [Q, E] = e.useState(!1), [F, S] = e.useState(!1), [O, B] = e.useState([]), [_, $] = e.useState(""), { t: v } = e.useContext(ue), U = v(a ? "design-system:fileUpload.instructions_plural" : "design-system:fileUpload.instructions").split("|"), ee = o || (a ? "Files" : "File"), u = e.useRef(null);
156
157
  e.useEffect(() => {
157
- x && P(x);
158
- }, [x]), e.useEffect(() => {
159
- c && te(c);
160
- }, [c]), e.useEffect(() => {
161
- p && ie(p);
158
+ b && M(b);
159
+ }, [b]), e.useEffect(() => {
160
+ f && ie(f);
161
+ }, [f]), e.useEffect(() => {
162
+ p && ae(p);
162
163
  }, [p]);
163
- function ee() {
164
- l && (P(!1), T && T());
164
+ function te() {
165
+ l && (M(!1), N && N());
165
166
  }
166
- function te(t) {
167
+ function ie(t) {
167
168
  try {
168
- K(he(t));
169
+ Y(ve(t));
169
170
  } catch {
170
171
  throw new Error(`Could not parse "${t}" as a file size.`);
171
172
  }
172
173
  }
173
- function ie(t) {
174
- const f = (Array.isArray(t) ? t : t.trim().split(/\s?,\s?/)).map((u) => u.replace(/^\./, "")), r = f.map((u) => `.${u}`.toLowerCase());
175
- _(
176
- r.map((u, S) => S > 0 && S === r.length - 1 ? `or ${u}` : u).join(r.length > 2 ? ", " : " ")
174
+ function ae(t) {
175
+ const m = (Array.isArray(t) ? t : t.trim().split(/\s?,\s?/)).map((h) => h.replace(/^\./, "")), r = m.map((h) => `.${h}`.toLowerCase());
176
+ $(
177
+ r.map((h, j) => j > 0 && j === r.length - 1 ? `or ${h}` : h).join(r.length > 2 ? ", " : " ")
177
178
  ), y.current.clear();
178
- for (const u of f) {
179
- const S = Object.keys(V).includes(u.toUpperCase()) ? V[u.toUpperCase()] : [];
180
- for (const ce of S)
181
- y.current.add(ce);
179
+ for (const h of m) {
180
+ const j = Object.keys(z).includes(h.toUpperCase()) ? z[h.toUpperCase()] : [];
181
+ for (const de of j)
182
+ y.current.add(de);
182
183
  }
183
- J(r.concat(Array.from(y.current)).join(","));
184
+ K(r.concat(Array.from(y.current)).join(","));
184
185
  }
185
- function D(t) {
186
- A([]);
186
+ function T(t) {
187
+ B([]);
187
188
  let s = [];
188
- const f = Array.from(t);
189
- for (const r of f)
190
- r === null ? s.push("Not a file") : (p && !y.current.has(r.type) && s.push(r.name), c && M && r.size > M && s.indexOf(r.name) === -1 && s.push(r.name));
191
- s.length ? (E(!0), d.current && d.current.value && (d.current.value = "")) : (q(f), C(f)), A(s);
189
+ const m = Array.from(t);
190
+ for (const r of m)
191
+ r === null ? s.push("Not a file") : (p && !y.current.has(r.type) && s.push(r.name), f && A && r.size > A && s.indexOf(r.name) === -1 && s.push(r.name));
192
+ s.length ? (S(!0), u.current && u.current.value && (u.current.value = "")) : (H(m), D(m)), B(s);
192
193
  }
193
- function ae(t) {
194
- t.preventDefault(), E(!1), d.current && d.current.click();
195
- }
196
- function le() {
197
- N && N();
194
+ function le(t) {
195
+ t.preventDefault(), S(!1), u.current && u.current.click();
198
196
  }
199
- function oe(t) {
200
- t.stopPropagation(), D(t.target.files || []), d.current && d.current.value && (d.current.value = "");
197
+ function oe() {
198
+ P && P();
201
199
  }
202
200
  function ne(t) {
203
- t.preventDefault(), t.stopPropagation(), b(!0), E(!1);
201
+ t.stopPropagation(), T(t.target.files || []), u.current && u.current.value && (u.current.value = "");
204
202
  }
205
203
  function se(t) {
206
- t.preventDefault(), b(!0), E(!1);
204
+ t.preventDefault(), t.stopPropagation(), E(!0), S(!1);
207
205
  }
208
206
  function re(t) {
209
- t.preventDefault(), b(!1);
207
+ t.preventDefault(), E(!0), S(!1);
210
208
  }
211
209
  function pe(t) {
212
- t.preventDefault(), t.stopPropagation(), b(!1), t.dataTransfer.items ? D(
210
+ t.preventDefault(), E(!1);
211
+ }
212
+ function ce(t) {
213
+ t.preventDefault(), t.stopPropagation(), E(!1), t.dataTransfer.items ? T(
213
214
  Array.from(t.dataTransfer.items).map(
214
215
  (s) => s.getAsFile()
215
216
  )
216
- ) : D(t.dataTransfer.files);
217
+ ) : T(t.dataTransfer.files);
217
218
  }
218
219
  return /* @__PURE__ */ e.createElement(
219
220
  "div",
220
221
  {
221
- onDrop: pe,
222
- onDragOver: ne,
223
- onDragLeave: re,
224
- onDragEnter: se,
225
- className: B(xe({ active: Y, mini: v, error: g, shown: Z }), X),
226
- ...G
222
+ onDrop: c ? () => {
223
+ } : ce,
224
+ onDragOver: c ? () => {
225
+ } : se,
226
+ onDragLeave: c ? () => {
227
+ } : pe,
228
+ onDragEnter: c ? () => {
229
+ } : re,
230
+ className: I(be({ active: Q, mini: w, error: F, shown: q, disabled: c }), G),
231
+ ...Z
227
232
  },
228
- /* @__PURE__ */ e.createElement("div", { className: B(be({ constrainContentWidth: i })) }, n ? /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(ue, { size: "md", "aria-hidden": "true" }), /* @__PURE__ */ e.createElement("div", { className: L }, h("design-system:fileUpload.processing"))) : /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(
229
- me,
233
+ /* @__PURE__ */ e.createElement("div", { className: I(Ee({ constrainContentWidth: i, disabled: c })) }, n ? /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(me, { size: "md", "aria-hidden": "true" }), /* @__PURE__ */ e.createElement("div", { className: k }, v("design-system:fileUpload.processing"))) : /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(
234
+ he,
230
235
  {
231
- className: Ue({ mini: v, error: g }),
232
- icon: g ? "exclamation-circle" : "upload-cloud",
236
+ className: je({ mini: w, error: F, disabled: c }),
237
+ icon: F ? "exclamation-circle" : "upload-cloud",
233
238
  "aria-hidden": "true"
234
239
  }
235
- ), /* @__PURE__ */ e.createElement("div", { className: je({ mini: v }) }, g ? /* @__PURE__ */ e.createElement("div", null, h(
236
- j.length > 1 ? "design-system:fileUpload.cancelled_plural" : "design-system:fileUpload.cancelled"
237
- )) : /* @__PURE__ */ e.createElement("div", null, h("design-system:fileUpload.title", { description: $ }))), g ? /* @__PURE__ */ e.createElement("div", { className: Fe }, new Set(
238
- j.map((t, s) => {
239
- const f = Math.floor(t.length / 2);
240
- return /* @__PURE__ */ e.createElement("div", { className: ge, key: t }, /* @__PURE__ */ e.createElement("span", { className: R }, t.substr(0, f)), /* @__PURE__ */ e.createElement("div", { className: R }, /* @__PURE__ */ e.createElement("span", null, t.substr(f))), s < j.length - 1 ? "," : "");
240
+ ), /* @__PURE__ */ e.createElement("div", { className: De({ mini: w }) }, F ? /* @__PURE__ */ e.createElement("div", null, v(
241
+ O.length > 1 ? "design-system:fileUpload.cancelled_plural" : "design-system:fileUpload.cancelled"
242
+ )) : /* @__PURE__ */ e.createElement("div", null, v("design-system:fileUpload.title", { description: ee }))), F ? /* @__PURE__ */ e.createElement("div", { className: xe }, new Set(
243
+ O.map((t, s) => {
244
+ const m = Math.floor(t.length / 2);
245
+ return /* @__PURE__ */ e.createElement("div", { className: Fe, key: t }, /* @__PURE__ */ e.createElement("span", { className: R }, t.substr(0, m)), /* @__PURE__ */ e.createElement("div", { className: R }, /* @__PURE__ */ e.createElement("span", null, t.substr(m))), s < O.length - 1 ? "," : "");
241
246
  })
242
- )) : /* @__PURE__ */ e.createElement("span", null), /* @__PURE__ */ e.createElement("div", { className: L }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("span", null, O[0]), /* @__PURE__ */ e.createElement("a", { href: "", onClick: ae }, O[1]), /* @__PURE__ */ e.createElement("span", null, O[2]))), /* @__PURE__ */ e.createElement("div", { className: Ce }, p ? /* @__PURE__ */ e.createElement("span", null, "(", " ", h("design-system:fileUpload.acceptedTypes", {
243
- fileTypes: Q
244
- }), " ", ")") : "", 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", { className: Ee }, /* @__PURE__ */ e.createElement(I, { kind: "link", icon: "download-cloud", onClick: le }, w)))),
247
+ )) : /* @__PURE__ */ e.createElement("span", null), /* @__PURE__ */ e.createElement("div", { className: k }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("span", null, U[0]), c ? /* @__PURE__ */ e.createElement("u", null, U[1]) : /* @__PURE__ */ e.createElement("a", { href: "", onClick: le }, U[1]), /* @__PURE__ */ e.createElement("span", null, U[2]))), /* @__PURE__ */ e.createElement("div", { className: Ce }, p ? /* @__PURE__ */ e.createElement("span", null, "(", " ", v("design-system:fileUpload.acceptedTypes", {
248
+ fileTypes: _
249
+ }), " ", ")") : "", f ? /* @__PURE__ */ e.createElement("span", null, "( ", v("design-system:fileUpload.maximumSize", { size: f }), " )") : "", x ? /* @__PURE__ */ e.createElement("span", null, " ", x, " ") : ""), g && /* @__PURE__ */ e.createElement("div", { className: Se }, /* @__PURE__ */ e.createElement(V, { disabled: c, kind: "link", icon: "download-cloud", onClick: oe }, g)))),
245
250
  l && !n && /* @__PURE__ */ e.createElement("div", { className: ye }, /* @__PURE__ */ e.createElement(
246
- I,
251
+ V,
247
252
  {
253
+ disabled: c,
248
254
  kind: "icon",
249
255
  icon: "x",
250
- title: h("design-system:fileUpload.close"),
251
- onClick: ee
256
+ title: v("design-system:fileUpload.close"),
257
+ onClick: te
252
258
  }
253
259
  )),
254
- /* @__PURE__ */ e.createElement("form", { className: Se }, /* @__PURE__ */ e.createElement(
260
+ /* @__PURE__ */ e.createElement("form", { className: Ue }, /* @__PURE__ */ e.createElement(
255
261
  "input",
256
262
  {
257
- ref: d,
263
+ ref: u,
258
264
  type: "file",
259
- accept: H || "*/*",
265
+ accept: J || "*/*",
260
266
  multiple: a || void 0,
261
- onChange: oe
267
+ onChange: ne
262
268
  }
263
269
  ))
264
270
  );
265
271
  }
266
- de.set(k, {
272
+ fe.set(X, {
267
273
  name: "FileUpload",
268
274
  props: {
269
275
  constrainContentWidth: { type: "boolean" },
@@ -277,11 +283,12 @@ de.set(k, {
277
283
  customRequirement: { type: "string" },
278
284
  onSelection: { type: "(files: File[]) => void", required: !0 },
279
285
  dismissal: { type: "() => void" },
280
- download: { type: "() => void" }
286
+ download: { type: "() => void" },
287
+ disabled: { type: "boolean" }
281
288
  }
282
289
  });
283
290
  const Oe = {
284
- components: [k],
291
+ components: [X],
285
292
  examples: {
286
293
  basic: {
287
294
  label: "Basic File Upload",
@@ -289,7 +296,7 @@ const Oe = {
289
296
  examples: {
290
297
  basic: {
291
298
  description: "Single file upload",
292
- react: m`
299
+ react: d`
293
300
  import { FileUpload } from "@sps-woodland/file-upload";
294
301
 
295
302
  function Component() {
@@ -305,7 +312,7 @@ const Oe = {
305
312
  },
306
313
  multiple: {
307
314
  description: "Multiple file upload",
308
- react: m`
315
+ react: d`
309
316
  import { FileUpload } from "@sps-woodland/file-upload";
310
317
 
311
318
  function Component() {
@@ -327,7 +334,7 @@ const Oe = {
327
334
  examples: {
328
335
  maxSize: {
329
336
  description: "Maximum size",
330
- react: m`
337
+ react: d`
331
338
  import { FileUpload } from "@sps-woodland/file-upload";
332
339
 
333
340
  function Component() {
@@ -343,7 +350,7 @@ const Oe = {
343
350
  },
344
351
  fileWhitelist: {
345
352
  description: "File type whitelist",
346
- react: m`
353
+ react: d`
347
354
  import { FileUpload } from "@sps-woodland/file-upload";
348
355
 
349
356
  function Component() {
@@ -364,7 +371,7 @@ const Oe = {
364
371
  },
365
372
  bothRestrictions: {
366
373
  description: "Both restrictions",
367
- react: m`
374
+ react: d`
368
375
  import { FileUpload } from "@sps-woodland/file-upload";
369
376
 
370
377
  function Component() {
@@ -391,7 +398,7 @@ const Oe = {
391
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.",
392
399
  examples: {
393
400
  basic: {
394
- react: m`
401
+ react: d`
395
402
  import { FileUpload } from "@sps-woodland/file-upload";
396
403
  import { Button } from "@sps-woodland/buttons";
397
404
 
@@ -430,7 +437,7 @@ const Oe = {
430
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.",
431
438
  examples: {
432
439
  basic: {
433
- react: m`
440
+ react: d`
434
441
  import { FileUpload } from "@sps-woodland/file-upload";
435
442
 
436
443
  function Component() {
@@ -461,7 +468,7 @@ const Oe = {
461
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.",
462
469
  examples: {
463
470
  basic: {
464
- react: m`
471
+ react: d`
465
472
  import { FileUpload } from "@sps-woodland/file-upload";
466
473
 
467
474
  function Component() {
@@ -486,7 +493,7 @@ const Oe = {
486
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.",
487
494
  examples: {
488
495
  basic: {
489
- react: m`
496
+ react: d`
490
497
  import { FileUpload } from "@sps-woodland/file-upload";
491
498
 
492
499
  function Component() {
@@ -505,12 +512,39 @@ const Oe = {
505
512
  `
506
513
  }
507
514
  }
515
+ },
516
+ disabled: {
517
+ label: "Disabled State",
518
+ description: "File Upload have a disabled style for each possible state.",
519
+ examples: {
520
+ basic: {
521
+ description: "Disabled File Upload",
522
+ react: d`
523
+ import { FileUpload } from "@sps-woodland/file-upload";
524
+
525
+ function Component() {
526
+ function selectFile(file) {
527
+ console.log(file);
528
+ }
529
+
530
+ return (
531
+ <FileUpload
532
+ disabled
533
+ downloadLabel="Download Excel Template" download={() => {}}
534
+ dismissable onDismiss={() => {}}
535
+ acceptExtensions="XLS, xlsx, .csv" maxSize="100KB"
536
+ onSelection={selectFile} />
537
+ )
538
+ }
539
+ `
540
+ }
541
+ }
508
542
  }
509
543
  }
510
- }, Ae = {
544
+ }, Be = {
511
545
  "File Upload": Oe
512
546
  };
513
547
  export {
514
- k as FileUpload,
515
- Ae as MANIFEST
548
+ X as FileUpload,
549
+ Be as MANIFEST
516
550
  };
package/lib/style.css CHANGED
@@ -1 +1 @@
1
- .rh07jw0{border-width:.0625rem;border-style:dashed;border-radius:.25rem;display:block;padding:1rem;position:relative}.rh07jw1{background-color:#f4ecf2;border-color:#91467f;border-style:solid}.rh07jw3{padding:1rem}.rh07jw5{border-color:#de012e}.rh07jw8{display:none}.rh07jw9{color:#4b5356;margin:0 auto;text-align:center}.rh07jwa{width:50%}.rh07jwc{font-size:.75rem;line-height:1.25rem}.rh07jwd{color:#717779;display:block;margin-bottom:.25rem}.rh07jwe{font-size:1.5rem;line-height:1.5rem}.rh07jwf{font-size:3rem;line-height:3rem}.rh07jwg{color:#de012e}.rh07jwi{font-weight:600;margin-bottom:.25rem}.rh07jwj{font-size:1rem;line-height:1.25rem}.rh07jwk{font-size:1.125rem;line-height:1.25rem}.rh07jwl{font-size:.875rem;font-weight:600;line-height:1.25rem}.rh07jwm{display:flex;justify-content:center;white-space:nowrap}.rh07jwn{max-width:50%;overflow:hidden}.rh07jwn:first-child{text-overflow:ellipsis}.rh07jwn:last-child{float:right}.rh07jwo{font-size:.75rem;line-height:1.125rem;margin-top:.25rem}.rh07jwo>span+span{margin-left:.125rem}.rh07jwp{margin-top:1rem}.rh07jwq{position:absolute;right:.5rem;top:.5rem}.rh07jwr{display:none}
1
+ .rh07jw0{border-width:.0625rem;border-style:dashed;border-radius:.25rem;display:block;padding:1rem;position:relative}.rh07jw1{background-color:#f4ecf2;border-color:#91467f;border-style:solid}.rh07jw3{padding:1rem}.rh07jw5{border-color:#de012e}.rh07jw8{display:none}.rh07jw9{border-color:#d2d4d4}.rh07jwb{color:#4b5356;margin:0 auto;text-align:center}.rh07jwc{width:50%}.rh07jwe{color:#717779}.rh07jwg{font-size:.75rem;line-height:1.25rem}.rh07jwh{color:#717779;display:block;margin-bottom:.25rem}.rh07jwi{font-size:1.5rem;line-height:1.5rem}.rh07jwj{font-size:3rem;line-height:3rem}.rh07jwk{color:#de012e}.rh07jwm{opacity:.5}.rh07jwo{font-weight:600;margin-bottom:.25rem}.rh07jwp{font-size:1rem;line-height:1.25rem}.rh07jwq{font-size:1.125rem;line-height:1.25rem}.rh07jwr{font-size:.875rem;font-weight:600;line-height:1.25rem}.rh07jws{display:flex;justify-content:center;white-space:nowrap}.rh07jwt{max-width:50%;overflow:hidden}.rh07jwt:first-child{text-overflow:ellipsis}.rh07jwt:last-child{float:right}.rh07jwu{font-size:.75rem;line-height:1.125rem;margin-top:.25rem}.rh07jwu>span+span{margin-left:.125rem}.rh07jwv{margin-top:1rem}.rh07jww{position:absolute;right:.5rem;top:.5rem}.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.13.1",
4
+ "version": "8.14.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.13.1",
34
- "@sps-woodland/core": "8.13.1",
35
- "@sps-woodland/tokens": "8.13.1",
36
- "@spscommerce/ds-react": "8.13.1",
37
- "@spscommerce/ds-shared": "8.13.1"
33
+ "@sps-woodland/buttons": "8.14.0",
34
+ "@sps-woodland/core": "8.14.0",
35
+ "@sps-woodland/tokens": "8.14.0",
36
+ "@spscommerce/ds-react": "8.14.0",
37
+ "@spscommerce/ds-shared": "8.14.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.13.1",
47
- "@sps-woodland/core": "8.13.1",
48
- "@sps-woodland/tokens": "8.13.1",
49
- "@spscommerce/ds-colors": "8.13.1",
50
- "@spscommerce/ds-react": "8.13.1",
51
- "@spscommerce/ds-shared": "8.13.1"
46
+ "@sps-woodland/buttons": "8.14.0",
47
+ "@sps-woodland/core": "8.14.0",
48
+ "@sps-woodland/tokens": "8.14.0",
49
+ "@spscommerce/ds-colors": "8.14.0",
50
+ "@spscommerce/ds-react": "8.14.0",
51
+ "@spscommerce/ds-shared": "8.14.0"
52
52
  },
53
53
  "scripts": {
54
54
  "build": "pnpm run build:js && pnpm run build:types",