@sps-woodland/file-upload 8.7.4 → 8.7.6
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 +1 -1
- package/lib/index.es.js +8 -5
- package/lib/style.css +1 -1
- package/package.json +12 -12
- /package/{vite.config.js → vite.config.mjs} +0 -0
package/lib/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.
|
|
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`
|
|
2
2
|
import { FileUpload } from "@sps-woodland/file-upload";
|
|
3
3
|
|
|
4
4
|
function Component() {
|
package/lib/index.es.js
CHANGED
|
@@ -122,7 +122,10 @@ var we = (i, o, a) => {
|
|
|
122
122
|
if (w != null) {
|
|
123
123
|
var p = w;
|
|
124
124
|
typeof p == "boolean" && (p = p === !0 ? "true" : "false");
|
|
125
|
-
var c =
|
|
125
|
+
var c = (
|
|
126
|
+
// @ts-expect-error
|
|
127
|
+
i.variantClassNames[n][p]
|
|
128
|
+
);
|
|
126
129
|
c && (a += " " + c);
|
|
127
130
|
}
|
|
128
131
|
}
|
|
@@ -149,7 +152,7 @@ function k({
|
|
|
149
152
|
children: De,
|
|
150
153
|
...G
|
|
151
154
|
}) {
|
|
152
|
-
const y = e.useRef(/* @__PURE__ */ new Set()), [Z, P] = e.useState(x), [Te, q] = e.useState([]), [H, J] = e.useState(""), [M, K] = e.useState(), [
|
|
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);
|
|
153
156
|
e.useEffect(() => {
|
|
154
157
|
x && P(x);
|
|
155
158
|
}, [x]), e.useEffect(() => {
|
|
@@ -169,7 +172,7 @@ function k({
|
|
|
169
172
|
}
|
|
170
173
|
function ie(t) {
|
|
171
174
|
const f = (Array.isArray(t) ? t : t.trim().split(/\s?,\s?/)).map((u) => u.replace(/^\./, "")), r = f.map((u) => `.${u}`.toLowerCase());
|
|
172
|
-
|
|
175
|
+
_(
|
|
173
176
|
r.map((u, S) => S > 0 && S === r.length - 1 ? `or ${u}` : u).join(r.length > 2 ? ", " : " ")
|
|
174
177
|
), y.current.clear();
|
|
175
178
|
for (const u of f) {
|
|
@@ -219,7 +222,7 @@ function k({
|
|
|
219
222
|
onDragOver: ne,
|
|
220
223
|
onDragLeave: re,
|
|
221
224
|
onDragEnter: se,
|
|
222
|
-
className: B(xe({ active:
|
|
225
|
+
className: B(xe({ active: Y, mini: v, error: g, shown: Z }), X),
|
|
223
226
|
...G
|
|
224
227
|
},
|
|
225
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(
|
|
@@ -237,7 +240,7 @@ function k({
|
|
|
237
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 ? "," : "");
|
|
238
241
|
})
|
|
239
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", {
|
|
240
|
-
fileTypes:
|
|
243
|
+
fileTypes: Q
|
|
241
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)))),
|
|
242
245
|
l && !n && /* @__PURE__ */ e.createElement("div", { className: ye }, /* @__PURE__ */ e.createElement(
|
|
243
246
|
I,
|
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
|
|
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}
|
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.7.
|
|
4
|
+
"version": "8.7.6",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/file-upload",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"@spscommerce/ds-illustrations": "^6.12.1",
|
|
31
31
|
"react": "^16.14.0",
|
|
32
32
|
"react-dom": "^16.14.0",
|
|
33
|
-
"@sps-woodland/core": "8.7.
|
|
34
|
-
"@sps-woodland/tokens": "8.7.
|
|
35
|
-
"@sps-woodland/buttons": "8.7.
|
|
36
|
-
"@spscommerce/ds-react": "8.7.
|
|
37
|
-
"@spscommerce/ds-shared": "8.7.
|
|
33
|
+
"@sps-woodland/core": "8.7.6",
|
|
34
|
+
"@sps-woodland/tokens": "8.7.6",
|
|
35
|
+
"@sps-woodland/buttons": "8.7.6",
|
|
36
|
+
"@spscommerce/ds-react": "8.7.6",
|
|
37
|
+
"@spscommerce/ds-shared": "8.7.6"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@spscommerce/utils": "^6.12.1",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"@vanilla-extract/recipes": "^0.2.5",
|
|
44
44
|
"react": "^16.14.0",
|
|
45
45
|
"react-dom": "^16.14.0",
|
|
46
|
-
"@sps-woodland/core": "8.7.
|
|
47
|
-
"@sps-woodland/tokens": "8.7.
|
|
48
|
-
"@sps-woodland/buttons": "8.7.
|
|
49
|
-
"@spscommerce/ds-react": "8.7.
|
|
50
|
-
"@spscommerce/ds-shared": "8.7.
|
|
51
|
-
"@spscommerce/ds-colors": "8.7.
|
|
46
|
+
"@sps-woodland/core": "8.7.6",
|
|
47
|
+
"@sps-woodland/tokens": "8.7.6",
|
|
48
|
+
"@sps-woodland/buttons": "8.7.6",
|
|
49
|
+
"@spscommerce/ds-react": "8.7.6",
|
|
50
|
+
"@spscommerce/ds-shared": "8.7.6",
|
|
51
|
+
"@spscommerce/ds-colors": "8.7.6"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "pnpm run build:js && pnpm run build:types",
|
|
File without changes
|