@spscommerce/ds-web-components 0.0.0-20260319-8230915ce
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/README.md +3 -0
- package/dist/README.md +3 -0
- package/dist/global.d.ts +15 -0
- package/dist/lib/components/file-upload/file-upload.d.ts +117 -0
- package/dist/lib/components/file-upload/file-upload.examples.d.ts +2 -0
- package/dist/lib/components/file-upload/mime-type.enum.d.ts +76 -0
- package/dist/lib/components/index.d.ts +11 -0
- package/dist/lib/components/insight-card/insight-card.d.ts +38 -0
- package/dist/lib/components/insight-card/insight-card.examples.d.ts +51 -0
- package/dist/lib/components/insight-card/insights.d.ts +18 -0
- package/dist/lib/components/nav-tabs/nav-tab-set.d.ts +7 -0
- package/dist/lib/components/nav-tabs/nav-tab.d.ts +24 -0
- package/dist/lib/components/nav-tabs/nav-tabs.examples.d.ts +11 -0
- package/dist/lib/components/photo/photo.d.ts +42 -0
- package/dist/lib/components/photo/photo.examples.d.ts +2 -0
- package/dist/lib/decorators/component.d.ts +32 -0
- package/dist/lib/decorators/content.d.ts +7 -0
- package/dist/lib/decorators/event-dispatcher.d.ts +9 -0
- package/dist/lib/decorators/event-listener.d.ts +5 -0
- package/dist/lib/decorators/index.d.ts +7 -0
- package/dist/lib/decorators/prop.d.ts +6 -0
- package/dist/lib/decorators/query-selector.d.ts +19 -0
- package/dist/lib/decorators/watch.d.ts +2 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.js +2227 -0
- package/dist/lib/index.umd.cjs +831 -0
- package/dist/lib/manifest.d.ts +2 -0
- package/dist/lib/utils/comment.d.ts +2 -0
- package/dist/lib/utils/index.d.ts +4 -0
- package/dist/lib/utils/metadata.d.ts +22 -0
- package/dist/lib/utils/pragma.d.ts +6 -0
- package/dist/lib/utils/register.d.ts +13 -0
- package/dist/package.json +53 -0
- package/global.d.ts +15 -0
- package/lib/components/file-upload/file-upload.d.ts +117 -0
- package/lib/components/file-upload/file-upload.examples.d.ts +2 -0
- package/lib/components/file-upload/mime-type.enum.d.ts +76 -0
- package/lib/components/index.d.ts +11 -0
- package/lib/components/insight-card/insight-card.d.ts +38 -0
- package/lib/components/insight-card/insight-card.examples.d.ts +51 -0
- package/lib/components/insight-card/insights.d.ts +18 -0
- package/lib/components/nav-tabs/nav-tab-set.d.ts +7 -0
- package/lib/components/nav-tabs/nav-tab.d.ts +24 -0
- package/lib/components/nav-tabs/nav-tabs.examples.d.ts +11 -0
- package/lib/components/photo/photo.d.ts +42 -0
- package/lib/components/photo/photo.examples.d.ts +2 -0
- package/lib/decorators/component.d.ts +32 -0
- package/lib/decorators/content.d.ts +7 -0
- package/lib/decorators/event-dispatcher.d.ts +9 -0
- package/lib/decorators/event-listener.d.ts +5 -0
- package/lib/decorators/index.d.ts +7 -0
- package/lib/decorators/prop.d.ts +6 -0
- package/lib/decorators/query-selector.d.ts +19 -0
- package/lib/decorators/watch.d.ts +2 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +2227 -0
- package/lib/index.umd.cjs +831 -0
- package/lib/manifest.d.ts +2 -0
- package/lib/utils/comment.d.ts +2 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/metadata.d.ts +22 -0
- package/lib/utils/pragma.d.ts +6 -0
- package/lib/utils/register.d.ts +13 -0
- package/package.json +53 -0
- package/vite.config.mjs +20 -0
|
@@ -0,0 +1,831 @@
|
|
|
1
|
+
(function(i,L){typeof exports=="object"&&typeof module<"u"?L(exports,require("@spscommerce/ds-shared"),require("@spscommerce/utils"),require("@spscommerce/i18n")):typeof define=="function"&&define.amd?define(["exports","@spscommerce/ds-shared","@spscommerce/utils","@spscommerce/i18n"],L):(i=typeof globalThis<"u"?globalThis:i||self,L(i.DSWebComponents={},i.dsShared,i.utils,i.i18n))})(this,function(i,L,f,D){"use strict";const Ke={};var g={},_e;function Qe(){if(_e)return g;_e=1,Object.defineProperty(g,"__esModule",{value:!0});/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/var e={default:"__default"};/**
|
|
17
|
+
* @license
|
|
18
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
19
|
+
*
|
|
20
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
* you may not use this file except in compliance with the License.
|
|
22
|
+
* You may obtain a copy of the License at
|
|
23
|
+
*
|
|
24
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
*
|
|
26
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
27
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
28
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
+
* See the License for the specific language governing permissions and
|
|
30
|
+
* limitations under the License.
|
|
31
|
+
*/var t=Object.prototype.hasOwnProperty;function a(){}a.prototype=Object.create(null);function r(n,s){return t.call(n,s)}function l(){return new a}function p(n,s){for(;n.length>s;)n.pop()}/**
|
|
32
|
+
* @license
|
|
33
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
34
|
+
*
|
|
35
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
36
|
+
* you may not use this file except in compliance with the License.
|
|
37
|
+
* You may obtain a copy of the License at
|
|
38
|
+
*
|
|
39
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
40
|
+
*
|
|
41
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
42
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
43
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
44
|
+
* See the License for the specific language governing permissions and
|
|
45
|
+
* limitations under the License.
|
|
46
|
+
*/function u(n){if(n.lastIndexOf("xml:",0)===0)return"http://www.w3.org/XML/1998/namespace";if(n.lastIndexOf("xlink:",0)===0)return"http://www.w3.org/1999/xlink"}function R(n,s,o){if(o==null)n.removeAttribute(s);else{var c=u(s);c?n.setAttributeNS(c,s,String(o)):n.setAttribute(s,String(o))}}function xe(n,s,o){n[s]=o}function mt(n,s,o){s.indexOf("-")>=0?n.setProperty(s,o):n[s]=o}function gt(n,s,o){if(typeof o=="string")n.style.cssText=o;else{n.style.cssText="";var c=n.style;for(var h in o)r(o,h)&&mt(c,h,o[h])}}function vt(n,s,o){var c=typeof o;c==="object"||c==="function"?xe(n,s,o):R(n,s,o)}var K=l();K[e.default]=vt,K.style=gt;function Q(n,s,o){var c=K[s]||K[e.default];c(n,s,o)}/**
|
|
47
|
+
* @license
|
|
48
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
49
|
+
*
|
|
50
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
51
|
+
* you may not use this file except in compliance with the License.
|
|
52
|
+
* You may obtain a copy of the License at
|
|
53
|
+
*
|
|
54
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
55
|
+
*
|
|
56
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
57
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
58
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
59
|
+
* See the License for the specific language governing permissions and
|
|
60
|
+
* limitations under the License.
|
|
61
|
+
*/var Z=!1,ge=!1;function Fe(n,s){if(!s)throw new Error("Cannot call "+n+"() unless in patch.")}function Ct(n,s){if(n!==s){for(var o=n,c=[];o&&o!==s;)c.push(o.nodeName.toLowerCase()),o=o.parentNode;throw new Error(`One or more tags were not closed:
|
|
62
|
+
`+c.join(`
|
|
63
|
+
`))}}function bt(n){n||console.warn("patchOuter requires the node have a parent if there is a key.")}function H(n){if(Z)throw new Error(n+"() can not be called between elementOpenStart() and elementOpenEnd().")}function ke(n){if(ge)throw new Error(n+"() may not be called inside an element that has called skip().")}function ve(n){if(!Z)throw new Error(n+"() can only be called after calling elementOpenStart().")}function wt(){if(Z)throw new Error("elementOpenEnd() must be called after calling elementOpenStart().")}function St(n,s){if(n!==s)throw new Error('Received a call to close "'+s+'" but "'+n+'" was open.')}function _t(n,s){if(s!==null)throw new Error(n+"() must come before any child declarations inside the current element.")}function Nt(n,s,o,c){ie(n);var h=n,m=s,y=m.nextSibling===o&&m.previousSibling===c,b=m.nextSibling===h.nextSibling&&m.previousSibling===c,A=m===h;if(!y&&!b&&!A)throw new Error("There must be exactly one top level call corresponding to the patched element.")}function ne(n){var s=Z;return Z=n,s}function se(n){var s=ge;return ge=n,s}function ie(n){if(process.env.NODE_ENV!=="production"&&!n)throw new Error("Expected value to be defined");return n}/**
|
|
64
|
+
* @license
|
|
65
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
66
|
+
*
|
|
67
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
68
|
+
* you may not use this file except in compliance with the License.
|
|
69
|
+
* You may obtain a copy of the License at
|
|
70
|
+
*
|
|
71
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
72
|
+
*
|
|
73
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
74
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
75
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
76
|
+
* See the License for the specific language governing permissions and
|
|
77
|
+
* limitations under the License.
|
|
78
|
+
*/var Y={nodesCreated:null,nodesDeleted:null};/**
|
|
79
|
+
* @license
|
|
80
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
81
|
+
*
|
|
82
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
83
|
+
* you may not use this file except in compliance with the License.
|
|
84
|
+
* You may obtain a copy of the License at
|
|
85
|
+
*
|
|
86
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
87
|
+
*
|
|
88
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
89
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
90
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
91
|
+
* See the License for the specific language governing permissions and
|
|
92
|
+
* limitations under the License.
|
|
93
|
+
*/var yt=function(){function n(){this.created=[],this.deleted=[]}return n.prototype.markCreated=function(s){this.created.push(s)},n.prototype.markDeleted=function(s){this.deleted.push(s)},n.prototype.notifyChanges=function(){Y.nodesCreated&&this.created.length>0&&Y.nodesCreated(this.created),Y.nodesDeleted&&this.deleted.length>0&&Y.nodesDeleted(this.deleted)},n}();/**
|
|
94
|
+
* @license
|
|
95
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
96
|
+
*
|
|
97
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
98
|
+
* you may not use this file except in compliance with the License.
|
|
99
|
+
* You may obtain a copy of the License at
|
|
100
|
+
*
|
|
101
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
102
|
+
*
|
|
103
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
104
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
105
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
106
|
+
* See the License for the specific language governing permissions and
|
|
107
|
+
* limitations under the License.
|
|
108
|
+
*/function At(n){return n.nodeType===11||n.nodeType===9}function Ce(n){return n.nodeType===1}function Ot(n){return n.nodeType===3}function Dt(n,s){for(var o=[],c=n;c!==s;){var h=c;o.push(h),c=h.parentNode}return o}var Pt=Node.prototype.getRootNode||function(){for(var n=this,s=n;n;)s=n,n=n.parentNode;return s};function Et(n){var s=Pt.call(n);return At(s)?s.activeElement:null}function It(n,s){var o=Et(n);return!o||!n.contains(o)?[]:Dt(o,s)}function xt(n,s,o){for(var c=s.nextSibling,h=o;h!==null&&h!==s;){var m=h.nextSibling;n.insertBefore(h,c),h=m}}/**
|
|
109
|
+
* @license
|
|
110
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
111
|
+
*
|
|
112
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
113
|
+
* you may not use this file except in compliance with the License.
|
|
114
|
+
* You may obtain a copy of the License at
|
|
115
|
+
*
|
|
116
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
117
|
+
*
|
|
118
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
119
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
120
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
121
|
+
* See the License for the specific language governing permissions and
|
|
122
|
+
* limitations under the License.
|
|
123
|
+
*/var Ft=function(){function n(s,o,c){this._attrsArr=null,this.staticsApplied=!1,this.nameOrCtor=s,this.key=o,this.text=c}return n.prototype.hasEmptyAttrsArr=function(){var s=this._attrsArr;return!s||!s.length},n.prototype.getAttrsArr=function(s){return this._attrsArr||(this._attrsArr=new Array(s))},n}();function be(n,s,o,c){var h=new Ft(s,o,c);return n.__incrementalDOMData=h,h}function q(n,s){return Le(n,s)}function kt(n){return!!n.__incrementalDOMData}function Lt(n){return ie(n.__incrementalDOMData),q(n).key}function Le(n,s){if(n.__incrementalDOMData)return n.__incrementalDOMData;var o=Ce(n)?n.localName:n.nodeName,c=Ce(n)?n.getAttribute("key")||s:null,h=Ot(n)?n.data:void 0,m=be(n,o,c,h);return Ce(n)&&Tt(n,m),m}function Te(n){Le(n);for(var s=n.firstChild;s;s=s.nextSibling)Te(s)}function Ue(n){n.__incrementalDOMData=null;for(var s=n.firstChild;s;s=s.nextSibling)Ue(s)}function Tt(n,s){var o=n.attributes,c=o.length;if(c)for(var h=s.getAttrsArr(c),m=0,y=0;m<c;m+=1,y+=2){var b=o[m],A=b.name,_=b.value;h[y]=A,h[y+1]=_}}/**
|
|
124
|
+
* @license
|
|
125
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
126
|
+
*
|
|
127
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
128
|
+
* you may not use this file except in compliance with the License.
|
|
129
|
+
* You may obtain a copy of the License at
|
|
130
|
+
*
|
|
131
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
132
|
+
*
|
|
133
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
134
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
135
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
136
|
+
* See the License for the specific language governing permissions and
|
|
137
|
+
* limitations under the License.
|
|
138
|
+
*/function Ut(n,s){return n==="svg"?"http://www.w3.org/2000/svg":n==="math"?"http://www.w3.org/1998/Math/MathML":s==null||q(s).nameOrCtor==="foreignObject"?null:s.namespaceURI}function Rt(n,s,o,c){var h;if(typeof o=="function")h=new o;else{var m=Ut(o,s);m?h=n.createElementNS(m,o):h=n.createElement(o)}return be(h,o,c),h}function $t(n){var s=n.createTextNode("");return be(s,"#text",null),s}/**
|
|
139
|
+
* @license
|
|
140
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
141
|
+
*
|
|
142
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
143
|
+
* you may not use this file except in compliance with the License.
|
|
144
|
+
* You may obtain a copy of the License at
|
|
145
|
+
*
|
|
146
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
147
|
+
*
|
|
148
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
149
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
150
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
151
|
+
* See the License for the specific language governing permissions and
|
|
152
|
+
* limitations under the License.
|
|
153
|
+
*/var G=null,C=null,N=null,z=null,ae=[],re=[];function oe(){return re}function Re(n){var s=function(o,c,h){var m=G,y=z,b=ae,A=re,_=C,I=N,k=!1,ce=!1;G=new yt,z=o.ownerDocument,re=[],N=o.parentNode,ae=It(o,N),process.env.NODE_ENV!=="production"&&(k=ne(!1),ce=se(!1));try{var Mt=n(o,c,h);return process.env.NODE_ENV!=="production"&&wt(),Mt}finally{z=y,re=A,C=_,N=I,ae=b,G.notifyChanges(),ne(k),se(ce),G=m}};return s}var $e=Re(function(n,s,o){return C=n,ze(),s(o),Ve(),process.env.NODE_ENV!=="production"&&Ct(C,n),n}),Bt=Re(function(n,s,o){var c={nextSibling:n},h=null,m=null;return process.env.NODE_ENV!=="production"&&(h=n.nextSibling,m=n.previousSibling),C=c,s(o),process.env.NODE_ENV!=="production"&&(bt(N),Nt(c,C,h,m)),N&&We(N,le(),n.nextSibling),c===C?null:C});function Be(n,s,o){var c=q(n,o);return s==c.nameOrCtor&&o==c.key}function jt(n,s,o){if(!n)return null;if(Be(n,s,o))return n;if(o){for(;n=n.nextSibling;)if(Be(n,s,o))return n}return null}function Wt(n,s){var o;return n==="#text"?o=$t(z):o=Rt(z,N,n,s),G.markCreated(o),o}function je(n,s){var o=jt(C,n,s),c=o||Wt(n,s);c!==C&&(ae.indexOf(c)>=0?xt(N,c,C):N.insertBefore(c,C),C=c)}function We(n,s,o){for(var c=n,h=s;h!==o;){var m=h.nextSibling;c.removeChild(h),G.markDeleted(h),h=m}}function ze(){N=C,C=null}function le(){return C?C.nextSibling:N.firstChild}function we(){C=le()}function Ve(){We(N,le(),null),C=N,N=N.parentNode}function He(n,s){return we(),je(n,s),ze(),N}function qe(){return process.env.NODE_ENV!=="production"&&se(!1),Ve(),C}function zt(){return we(),je("#text",null),C}function Vt(){return process.env.NODE_ENV!=="production"&&(Fe("currentElement",z),H("currentElement")),N}function Ht(){return process.env.NODE_ENV!=="production"&&(Fe("currentPointer",z),H("currentPointer")),le()}function qt(){process.env.NODE_ENV!=="production"&&(_t("skip",C),se(!0)),C=N.lastChild}/**
|
|
154
|
+
* @license
|
|
155
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
156
|
+
*
|
|
157
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
158
|
+
* you may not use this file except in compliance with the License.
|
|
159
|
+
* You may obtain a copy of the License at
|
|
160
|
+
*
|
|
161
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
162
|
+
*
|
|
163
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
164
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
165
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
166
|
+
* See the License for the specific language governing permissions and
|
|
167
|
+
* limitations under the License.
|
|
168
|
+
*/var Ge=3,x=l();function Gt(n,s,o){if(s.staticsApplied=!0,!(!o||!o.length)){if(s.hasEmptyAttrsArr()){for(var c=0;c<o.length;c+=2)Q(n,o[c],o[c+1]);return}for(var c=0;c<o.length;c+=2)x[o[c]]=c+1;for(var h=s.getAttrsArr(0),m=0,c=0;c<h.length;c+=2){var y=h[c],b=h[c+1],A=x[y];if(A){o[A]===b&&delete x[y];continue}h[m]=y,h[m+1]=b,m+=2}p(h,m);for(var y in x)Q(n,y,o[x[y]]),delete x[y]}}function Se(n,s,o){process.env.NODE_ENV!=="production"&&(H("elementOpen"),ke("elementOpen"));var c=He(n,s),h=q(c);h.staticsApplied||Gt(c,h,o);var m=Math.max(0,arguments.length-Ge),y=h.hasEmptyAttrsArr();if(!m&&y)return c;for(var b=h.getAttrsArr(m),A=Ge,_=0;A<arguments.length;A+=2,_+=2){var I=arguments[A];if(y)b[_]=I;else if(b[_]!==I)break;var k=arguments[A+1];(y||b[_+1]!==k)&&(b[_+1]=k,Q(c,I,k))}if(A<arguments.length||_<b.length){for(var ce=_;_<b.length;_+=2)x[b[_]]=b[_+1];for(_=ce;A<arguments.length;A+=2,_+=2){var I=arguments[A],k=arguments[A+1];x[I]!==k&&Q(c,I,k),b[_]=I,b[_+1]=k,delete x[I]}p(b,_);for(var I in x)Q(c,I,void 0),delete x[I]}return c}function Xt(n,s,o){var c=oe();process.env.NODE_ENV!=="production"&&(H("elementOpenStart"),ne(!0)),c[0]=n,c[1]=s,c[2]=o}function Kt(n){var s=oe();process.env.NODE_ENV!=="production"&&(ve("key"),ie(s)),s[1]=n}function Qt(n,s){var o=oe();process.env.NODE_ENV!=="production"&&ve("attr"),o.push(n),o.push(s)}function Zt(){var n=oe();process.env.NODE_ENV!=="production"&&(ve("elementOpenEnd"),ne(!1)),ie(n);var s=Se.apply(null,n);return p(n,0),s}function Xe(n){process.env.NODE_ENV!=="production"&&H("elementClose");var s=qe();return process.env.NODE_ENV!=="production"&&St(q(s).nameOrCtor,n),s}function Yt(n,s,o){return Se.apply(null,arguments),Xe(n)}function Jt(n){process.env.NODE_ENV!=="production"&&(H("text"),ke("text"));var s=zt(),o=q(s);if(o.text!==n){o.text=n;for(var c=n,h=1;h<arguments.length;h+=1){var m=arguments[h];c=m(c)}s.data=c}return s}/**
|
|
169
|
+
* @license
|
|
170
|
+
* Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
|
|
171
|
+
*
|
|
172
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
173
|
+
* you may not use this file except in compliance with the License.
|
|
174
|
+
* You may obtain a copy of the License at
|
|
175
|
+
*
|
|
176
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
177
|
+
*
|
|
178
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
179
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
180
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
181
|
+
* See the License for the specific language governing permissions and
|
|
182
|
+
* limitations under the License.
|
|
183
|
+
*/return g.applyAttr=R,g.applyProp=xe,g.attributes=K,g.close=qe,g.currentElement=Vt,g.currentPointer=Ht,g.open=He,g.patch=$e,g.patchInner=$e,g.patchOuter=Bt,g.skip=qt,g.skipNode=we,g.getKey=Lt,g.clearCache=Ue,g.importNode=Te,g.isDataInitialized=kt,g.notifications=Y,g.symbols=e,g.attr=Qt,g.elementClose=Xe,g.elementOpen=Se,g.elementOpenEnd=Zt,g.elementOpenStart=Xt,g.elementVoid=Yt,g.text=Jt,g.key=Kt,g}var O=Qe();function Ne(e){let t=O.currentPointer();return t instanceof Comment&&t.data!==e?t.data=e:(t=document.createComment(e),O.currentElement().appendChild(t)),O.skipNode(),t}const $=Symbol("ComponentMetadata"),P=Object.freeze({has(e,t){return!!(e[$]&&Object.prototype.hasOwnProperty.call(e[$],t))},add(e,t){e[$]?Object.assign(e[$],t):e[$]=t},get(e,t,a){return e[$]&&e[$][t]||a}}),ye=Symbol("ds-web-components:pragma:listeners-attached"),Ae="idom-pragma:content-begin",pe="idom-pragma:content-end";function de(e){for(const t of e)if(typeof t=="function")t();else if(typeof t=="string")O.text(t);else if(t instanceof Set)de(Array.from(t));else if(Array.isArray(t)&&t.length>0){let a=O.currentPointer();if(Ne(Ae),a===null){const r=O.currentElement();for(let l=0;l<t.length;l+=1)r.contains(t[l])||r.appendChild(t[l]),O.skipNode()}for(;a&&a.data!==pe;)O.skipNode(),a=O.currentPointer();Ne(pe)}}function d(e,t,...a){if(t){for(const r of Object.keys(t))if(r.toUpperCase()==="DATA-FRAGMENT")return()=>de(a)}return()=>{O.elementOpenStart(e);const r=[];if(t)for(const p of Object.keys(t))p.toUpperCase()==="CLASSNAME"?O.attr("class",t[p]):/^on[A-Z]/.test(p)?r.push(p):O.attr(p,t[p]);O.elementOpenEnd(e);const l=O.currentElement();if(!l[ye]){for(const p of r)l.addEventListener(p.substr(2).toLowerCase(),t[p]);l[ye]=!0}de(a),O.elementClose(e)}}function Oe(e,t){customElements.get(e)||customElements.define(e,t)}function Ze(...e){for(const t of e)Oe(P.get(t,"tag"),t)}function Ye(e){return function(...a){for(const r of a){const l=`${e}${P.get(r,"tag").substr(3)}`;Oe(l,r)}}}const he=Symbol("Component Attribute Bindings"),B=Symbol("Component Class Bindings"),J=Symbol("Component Style Bindings"),Je={__initialized:!1,__observer:null,__queuedUpdate:null,__managedClasses:new Set,__updateHostBindings(){const e=this;for(const t of Object.keys(e[he]||{}))e.setAttribute(t,e[he][t]);for(const t of Object.keys(e[J]||{}))e.style[t]=e[J][t];for(const t of e.__managedClasses)e.classList.remove(t);for(const t of(e[B]||[]).filter(Boolean))e.__managedClasses.add(t),e.classList.add(t);for(const t of(e.getAttribute("classname")||"").split(/\w+/).filter(Boolean))e.classList.add(t)},__updateChildQueries(e){const t=this;for(const a of P.get(t.constructor,"childQueries",[]))if(!e||e&&a.refresh){const r=a.all?t.querySelectorAll:t.querySelector;t[a.key]=r.call(t,a.selector)}},__gatherChildren(){const e=this;let t=Array.from(e.childNodes),a=null,r=t.length;for(let l=0;l<t.length;l+=1){const p=t[l];p instanceof Comment&&(p.data===Ae?a=l+1:p.data===pe&&(r=l-1))}if(a===null)for(const l of t)l.parentNode.removeChild(l);else t=t.slice(a,r);P.has(e.constructor,"contentProp")&&(e[P.get(e.constructor,"contentProp")]=t)},__startMutObs(){const e=this;e.__observer||(e.__observer=new MutationObserver(()=>{e.contentChangedCallback&&e.contentChangedCallback(),e.__gatherChildren(),e.update()})),e.__observer.observe(e,{childList:!0})},__stopMutObs(){const e=this;e.__observer&&e.__observer.disconnect()},__doRender(){const e=this;e.__stopMutObs(),O.patch(e,e.render()),e.__startMutObs()},update(){const e=this;e.__initialized&&!e.__queuedUpdate&&(e.__queuedUpdate=window.requestAnimationFrame(()=>{e.__doRender(),setTimeout(()=>{e.__updateChildQueries(!0),e.__updateHostBindings()},0),e.__queuedUpdate=null}))},attributeChangedCallback(e,t,a){const r=this,l=a===""?!0:a;l!==t&&(r.__cbAttributeChanged&&r.__cbAttributeChanged(e,r[e],l),e!=="style"&&(r[e]=l),r.__initialized&&r.update())},connectedCallback(){const e=this;e.__cbConnected&&e.__cbConnected();const t=P.get(e.constructor,"eventListeners",[]);setTimeout(()=>{if(!e.__initialized){e.__gatherChildren();for(const[,a]of t)e[a]=e[a].bind(e);e.__initialized=!0}for(const[a,r]of t)e.addEventListener(a,e[r]);e.__doRender(),setTimeout(()=>{e.__updateChildQueries(),e.__updateHostBindings()},0)},0)},disconnectedCallback(){const e=this;e.__cbDisconnected&&e.__cbDisconnected();for(const[t,a]of P.get(e.constructor,"eventListeners",[]))e.removeEventListener(t,e[a]);e.__stopMutObs()}};function j(e){return t=>{P.add(t,e),Object.assign(t.prototype,{__cbAttributeChanged:t.prototype.attributeChangedCallback,__cbConnected:t.prototype.connectedCallback,__cbDisconnected:t.prototype.disconnectedCallback},Je)}}function M(){return(e,t)=>{P.add(e.constructor,{contentProp:t})}}function ee(e){return(t,a)=>{Object.defineProperty(t,a,{get(){return Object.defineProperty(this,a,{value:{dispatch:r=>{const l=new CustomEvent(e||a,{detail:r});return this.dispatchEvent(l),l}}}),this[a]},configurable:!0})}}function X(e){return(t,a)=>{const r=P.get(t.constructor,"eventListeners",[]);r.push([e,a]),P.add(t.constructor,{eventListeners:r})}}function v(e){return(t,a)=>{const r=t.constructor,l=a.toLowerCase();if(r.observedAttributes=r.observedAttributes||["classname","className","style"],r.observedAttributes.push(a),r.observedAttributes.push(l),l!==a&&Object.defineProperty(t,a,{get(){return this[l]},set(p){this[l]=p}}),e){const p=Symbol.for(a);Object.defineProperty(t,l,{get(){return this[p]},set(u){let R=u;e===Boolean&&typeof u=="string"&&u.toLowerCase()==="false"?R=!1:R=e(u),this[p]=R}})}}}function De(e,t,a){return(r,l)=>{const p=P.get(r.constructor,"childQueries",[]);p.push({key:l,selector:e,all:a,refresh:t.refresh}),P.add(r.constructor,{childQueries:p})}}function te(e,t={}){return De(e,t)}function Pe(e,t={}){return De(e,t,!0)}function ue(){return(e,t)=>{const a=Symbol(t);Object.defineProperties(e,{[a]:{writable:!0,enumerable:!1,configurable:!1,value:e[t]},[t]:{get(){return this[a]},set(r){this[a]!==r&&(this[a]=r,this.update())}}})}}var fe=(e=>(e["7Z"]="application/x-7z-compressed",e.AAC="audio/aac",e.ABW="application/x-abiword",e.ARC="application/octet-stream",e.AVI="video/x-msvideo",e.AZW="application/vnd.amazon.ebook",e.BIN="application/octet-stream",e.BMP="image/bmp",e.BZ="application/x-bzip",e.BZ2="application/x-bzip2",e.CER="application/pkix-cert",e.CSH="application/x-csh",e.CSS="text/css",e.CSV="text/csv,application/vnd.ms-excel",e.DOC="application/msword",e.DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",e.EOT="application/vnd.ms-fontobject",e.EPUB="application/epub+zip",e.ES="application/ecmascript",e.FLV="video/x-flv",e.GIF="image/gif",e.GZ="application/x-gzip",e.HTM="text/html",e.HTML="text/html",e.ICO="image/x-icon",e.ICS="text/calendar",e.JAR="application/java-archive",e.JPEG="image/jpeg",e.JPG="image/jpeg",e.JS="application/javascript",e.JSON="application/json",e.M3U="audio/x-mpequrl",e.MID="audio/midi",e.MIDI="audio/midi",e.MOV="video/quicktime",e.MP3="audio/mpeg3",e.MP4="video/mp4",e.MPEG="video/mpeg",e.MPKG="application/vnd.apple.installer+xml",e.ODP="application/vnd.oasis.opendocument.presentation",e.ODS="application/vnd.oasis.opendocument.spreadsheet",e.ODT="application/vnd.oasis.opendocument.text",e.OGA="audio/ogg",e.OGV="video/ogg",e.OGX="application/ogg",e.OTF="font/otf",e.PNG="image/png",e.PDF="application/pdf",e.PPT="application/vnd.ms-powerpoint",e.PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",e.RAR="application/x-rar-compressed",e.RTF="application/rtf",e.SH="application/x-sh",e.SVG="image/svg+xml",e.SWF="application/x-shockwave-flash",e.TAR="application/x-tar",e.TIF="image/tiff",e.TIFF="image/tiff",e.TS="application/typescript",e.TTF="font/ttf",e.TXT="text/plain",e.VSD="application/vnd.visio",e.WAV="audio/wav",e.WEBA="audio/webm",e.WEBM="video/webm",e.WEBP="image/webp",e.WOFF="font/woff",e.WOFF2="font/woff2",e.XHTML="application/xhtml+xml",e.XLS="application/vnd.ms-excel",e.XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",e.XML="application/xml",e.XUL="application/vnd.mozilla.xul+xml",e.ZIP="application/zip",e))(fe||{}),Me=Object.defineProperty,et=Object.getOwnPropertyDescriptor,w=(e,t,a,r)=>{for(var l=r>1?void 0:r?et(t,a):t,p=e.length-1,u;p>=0;p--)(u=e[p])&&(l=(r?u(t,a,l):u(l))||l);return r&&l&&Me(t,a,l),l};const S="sps-file-upload";i.SpsFileUploadComponent=class extends HTMLElement{constructor(){super(),this.shown=!0,this.files=[],this.acceptMIMETypes=new Set,this.active=!1,this.error=!1,this.namesOfUnsupportedFiles=[],this.handleBrowseLinkClick=this.handleBrowseLinkClick.bind(this),this.handleDownloadButtonClick=this.handleDownloadButtonClick.bind(this),this.handleFileInputChange=this.handleFileInputChange.bind(this),this.dismiss=this.dismiss.bind(this)}get[B](){return[S,this.active&&`${S}--active`,this.error&&`${S}--error`,!this.shown&&`${S}--hidden`,this.mini&&`${S}--mini`,this.constrainContentWidth&&`${S}--constrained-content-width`]}connectedCallback(){this.description=this.description||(this.multiple?"Files":"File"),this.acceptExtensions&&this.processAcceptExtensions(this.acceptExtensions),this.maxSize&&this.parseAndValidateMaxSize(this.maxSize)}attributeChangedCallback(t,a,r){t==="acceptExtensions"&&this.processAcceptExtensions(r),t==="maxSize"&&this.parseAndValidateMaxSize(r)}dismiss(){this.dismissable&&(this.shown=!1,this.update(),this.dismissal.dispatch())}show(){this.dismissable&&(this.shown=!0,this.update())}render(){const t=this.error?L.SpsIcon.EXCLAMATION_CIRCLE:L.SpsIcon.UPLOAD_CLOUD,a=(this.multiple?D.i18nWoodland.t("fileUpload.instructions.other",{defaultValue:"Drag and drop your files here or |browse for files| on your desktop."}):D.i18nWoodland.t("fileUpload.instructions.one",{defaultValue:"Drag and drop your file here or |browse for a file| on your desktop."})).split("|");return d("div",{"data-fragment":!0},d("div",{className:`${S}__content`},this.processing?d("div",{"data-fragment":!0},d("i",{className:"sps-spinner sps-spinner--medium","aria-hidden":"true"}),d("div",{className:`${S}__instructions`},D.i18nWoodland.t("fileUpload.processing",{defaultValue:"Processing Upload..."}))):d("div",{"data-fragment":!0},d("i",{className:`sps-icon sps-icon-${t} ${S}__icon-primary`,"aria-hidden":"true"}),d("div",{className:`${S}__title`},this.error?d("div",{"data-fragment":!0},D.i18nWoodland.t(this.namesOfUnsupportedFiles.length>1?"fileUpload.cancelled_plural":"fileUpload.cancelled",{defaultValue:this.namesOfUnsupportedFiles.length>1?"File Upload(s) Failed":"File Upload Failed"})):d("div",{"data-fragment":!0},D.i18nWoodland.t("fileUpload.title",{description:this.description,defaultValue:`Upload Your ${this.description}`}))),this.error?d("div",{className:`${S}__errored-files`},new Set(this.namesOfUnsupportedFiles.map((r,l)=>{const p=Math.floor(r.length/2);return d("div",{className:`${S}__errored-filename`,key:r},d("span",{className:`${S}__errored-filename-segment`},r.substr(0,p)),d("div",{className:`${S}__errored-filename-segment`},d("span",null,r.substr(p))),l<this.namesOfUnsupportedFiles.length-1?",":"")}))):d("span",null),d("div",{className:`${S}__instructions`},d("div",{"data-fragment":!0},d("span",null,a[0]),d("a",{href:"",onClick:this.handleBrowseLinkClick},a[1]),d("span",null,a[2]))),d("div",{className:`${S}__requirements`},this.acceptExtensions?d("span",null,"("," ",D.i18nWoodland.t("fileUpload.acceptedTypes",{fileTypes:this.acceptExtensionsDescription,defaultValue:`${this.acceptExtensionsDescription} format accepted`})," ",")"):"",this.maxSize?d("span",null,"("," ",D.i18nWoodland.t("fileUpload.maximumSize",{size:this.maxSize,defaultValue:`${this.maxSize} maximum`})," ",")"):"",this.customRequirement?d("span",null," ",this.customRequirement," "):""),this.downloadLabel&&d("div",{className:`sps-button sps-button--link ${S}__download-button`,onClick:this.handleDownloadButtonClick},d("button",{type:"button"},d("i",{className:"sps-icon sps-icon-download-cloud","aria-hidden":"true"})," ",this.downloadLabel)))),this.dismissable&&!this.processing&&d("div",{className:`sps-button sps-button--icon ${S}__close-button`,onClick:this.dismiss},d("button",{type:"button",title:D.i18nWoodland.t("fileUpload.close",{defaultValue:"Close"})},d("i",{className:"sps-icon sps-icon-x","aria-hidden":"true"}))),d("form",null,d("input",{type:"file",accept:this.accept||"*/*",multiple:this.multiple||null,onChange:this.handleFileInputChange})))}parseAndValidateMaxSize(t){try{this.maxSizeBytes=f.parseFileSize(t)}catch{throw new Error(`Could not parse "${t}" as a file size.`)}}processAcceptExtensions(t){const r=(Array.isArray(t)?t:t.trim().split(/\s?,\s?/)).map(p=>p.replace(/^\./,"")),l=r.map(p=>`.${p}`.toLowerCase());this.acceptExtensionsDescription=l.map((p,u)=>u>0&&u===l.length-1?`or ${p}`:p).join(l.length>2?", ":" "),this.acceptMIMETypes.clear();for(const p of r)for(const u of fe[p.toUpperCase()].split(","))this.acceptMIMETypes.add(u);this.accept=l.concat(Array.from(this.acceptMIMETypes)).join(",")}selectFiles(t){this.namesOfUnsupportedFiles=[];const a=Array.from(t);for(const r of a)this.acceptExtensions&&!this.acceptMIMETypes.has(r.type)&&this.namesOfUnsupportedFiles.push(r.name),this.maxSize&&r.size>this.maxSizeBytes&&this.namesOfUnsupportedFiles.indexOf(r.name)===-1&&this.namesOfUnsupportedFiles.push(r.name);this.namesOfUnsupportedFiles.length?(this.error=!0,this.fileInput.value=null,this.update()):(this.files=a,this.selection.dispatch(a))}handleDragOver(t){t.preventDefault(),t.stopPropagation()}handleDragEnter(t){t.preventDefault(),this.active=!0,this.error=!1,this.update()}handleDragLeave(t){t.preventDefault(),this.active=!1,this.update()}handleDrop(t){t.preventDefault(),t.stopPropagation(),this.active=!1,t.dataTransfer.items?this.selectFiles(Array.from(t.dataTransfer.items).map(a=>a.getAsFile())):this.selectFiles(t.dataTransfer.files),this.update()}handleBrowseLinkClick(t){t.preventDefault(),this.error=!1,this.update(),this.fileInput.click()}handleDownloadButtonClick(){this.download.dispatch()}handleFileInputChange(t){t.stopPropagation(),this.selectFiles(t.target.files)}},i.SpsFileUploadComponent.displayName=S,i.SpsFileUploadComponent.props={description:"string",multiple:"boolean",dismissable:"boolean",processing:"boolean",mini:"boolean",downloadLabel:"string",acceptExtensions:"Array<string> | string",maxSize:"string",customRequirement:"string",selection:{event:!0,type:"CustomEvent<Array<File>>"},dismissal:{event:!0,type:"CustomEvent<void>"},download:{event:!0,type:"CustomEvent<void>"}},w([v()],i.SpsFileUploadComponent.prototype,"description",2),w([v(Boolean)],i.SpsFileUploadComponent.prototype,"multiple",2),w([v(Boolean)],i.SpsFileUploadComponent.prototype,"shown",2),w([v(Boolean)],i.SpsFileUploadComponent.prototype,"dismissable",2),w([v(Boolean)],i.SpsFileUploadComponent.prototype,"processing",2),w([v(Boolean)],i.SpsFileUploadComponent.prototype,"mini",2),w([v(Boolean)],i.SpsFileUploadComponent.prototype,"constrainContentWidth",2),w([v()],i.SpsFileUploadComponent.prototype,"downloadLabel",2),w([v()],i.SpsFileUploadComponent.prototype,"acceptExtensions",2),w([v()],i.SpsFileUploadComponent.prototype,"maxSize",2),w([v()],i.SpsFileUploadComponent.prototype,"customRequirement",2),w([ee()],i.SpsFileUploadComponent.prototype,"selection",2),w([ee()],i.SpsFileUploadComponent.prototype,"dismissal",2),w([ee()],i.SpsFileUploadComponent.prototype,"download",2),w([te("input[type='file']")],i.SpsFileUploadComponent.prototype,"fileInput",2),w([X("dragover")],i.SpsFileUploadComponent.prototype,"handleDragOver",1),w([X("dragenter")],i.SpsFileUploadComponent.prototype,"handleDragEnter",1),w([X("dragleave")],i.SpsFileUploadComponent.prototype,"handleDragLeave",1),w([X("drop")],i.SpsFileUploadComponent.prototype,"handleDrop",1),i.SpsFileUploadComponent=w([j({tag:S})],i.SpsFileUploadComponent);const tt={basic:{label:"Basic File Upload",description:f.code`
|
|
184
|
+
<p>Simply allow the user to drag-and-drop or select either a single file or multiple files at once.</p>
|
|
185
|
+
`,examples:{single:{description:"<p>Single file upload</p>",react:f.code`
|
|
186
|
+
function Component() {
|
|
187
|
+
const ref = React.useRef()
|
|
188
|
+
|
|
189
|
+
function handleChange(event) {
|
|
190
|
+
console.log(event.detail)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
React.useEffect(() => {
|
|
194
|
+
ref.current.addEventListener("selection", handleChange)
|
|
195
|
+
return () => {
|
|
196
|
+
ref.current.removeEventListener("selection", handleChange)
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<div className="sps-row">
|
|
202
|
+
<div className="col-12">
|
|
203
|
+
<sps-file-upload ref={ref}/>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
`},multiple:{description:"<p>Multiple file upload</p>",react:f.code`
|
|
209
|
+
function Component() {
|
|
210
|
+
const ref = React.useRef()
|
|
211
|
+
|
|
212
|
+
function handleChange(event) {
|
|
213
|
+
console.log(event.detail)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
React.useEffect(() => {
|
|
217
|
+
ref.current.addEventListener("selection", handleChange)
|
|
218
|
+
return () => {
|
|
219
|
+
ref.current.removeEventListener("selection", handleChange)
|
|
220
|
+
}
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
return (
|
|
224
|
+
<div className="sps-row">
|
|
225
|
+
<div className="col-12">
|
|
226
|
+
<sps-file-upload ref={ref} multiple/>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
`}}},restrictions:{label:"Restrictions",description:f.code`
|
|
232
|
+
<p>You can place restrictions on what files will be accepted with an extension whitelist and/or a maximum size.</p>
|
|
233
|
+
`,examples:{size:{description:"<p>Maximum size</p>",react:f.code`
|
|
234
|
+
function Component() {
|
|
235
|
+
const ref = React.useRef()
|
|
236
|
+
|
|
237
|
+
function handleChange(event) {
|
|
238
|
+
console.log(event.detail)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
React.useEffect(() => {
|
|
242
|
+
ref.current.addEventListener("selection", handleChange)
|
|
243
|
+
return () => {
|
|
244
|
+
ref.current.removeEventListener("selection", handleChange)
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
return (
|
|
249
|
+
<div className="sps-row">
|
|
250
|
+
<div className="col-12">
|
|
251
|
+
<sps-file-upload ref={ref} maxSize="100KB"/>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
`},type:{description:"<p>File type whitelist</p>",react:f.code`
|
|
257
|
+
function Component() {
|
|
258
|
+
const ref = React.useRef()
|
|
259
|
+
|
|
260
|
+
function handleChange(event) {
|
|
261
|
+
console.log(event.detail)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
React.useEffect(() => {
|
|
265
|
+
ref.current.addEventListener("selection", handleChange)
|
|
266
|
+
return () => {
|
|
267
|
+
ref.current.removeEventListener("selection", handleChange)
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
return (
|
|
272
|
+
<div className="sps-row">
|
|
273
|
+
<div className="col-12">
|
|
274
|
+
<sps-file-upload
|
|
275
|
+
ref={ref}
|
|
276
|
+
description="Spreadsheets"
|
|
277
|
+
multiple
|
|
278
|
+
acceptExtensions="XLS, xlsx, .csv"
|
|
279
|
+
/>
|
|
280
|
+
</div>
|
|
281
|
+
</div>
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
`},both:{description:"<p>Both restrictions</p>",react:f.code`
|
|
285
|
+
function Component() {
|
|
286
|
+
const ref = React.useRef()
|
|
287
|
+
|
|
288
|
+
function handleChange(event) {
|
|
289
|
+
console.log(event.detail)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
React.useEffect(() => {
|
|
293
|
+
ref.current.addEventListener("selection", handleChange)
|
|
294
|
+
return () => {
|
|
295
|
+
ref.current.removeEventListener("selection", handleChange)
|
|
296
|
+
}
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
return (
|
|
300
|
+
<div className="sps-row">
|
|
301
|
+
<div className="col-12">
|
|
302
|
+
<sps-file-upload
|
|
303
|
+
ref={ref}
|
|
304
|
+
description="Spreadsheets"
|
|
305
|
+
multiple
|
|
306
|
+
acceptExtensions="XLS, xlsx, .csv"
|
|
307
|
+
maxSize="25MB"
|
|
308
|
+
/>
|
|
309
|
+
</div>
|
|
310
|
+
</div>
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
`}}},dismissable:{label:"Dismissable",description:f.code`
|
|
314
|
+
<p>With this option, the file upload component can be dismissed by the user. If the user does dismiss it, you can
|
|
315
|
+
show it again programmatically if you need to.</p>
|
|
316
|
+
`,examples:{dismissable:{react:f.code`
|
|
317
|
+
function Component() {
|
|
318
|
+
const [showFileUpload, setShowFileUpload] = React.useState(true)
|
|
319
|
+
const ref = React.useRef()
|
|
320
|
+
|
|
321
|
+
function handleDismissal() {
|
|
322
|
+
setShowFileUpload(false)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
React.useEffect(() => {
|
|
326
|
+
ref.current.addEventListener("dismissal", handleDismissal)
|
|
327
|
+
return () => {
|
|
328
|
+
ref.current.removeEventListener("dismissal", handleDismissal)
|
|
329
|
+
}
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
return (
|
|
333
|
+
<div className="sps-row">
|
|
334
|
+
<div className="col-12">
|
|
335
|
+
<sps-file-upload
|
|
336
|
+
ref={ref}
|
|
337
|
+
dismissable
|
|
338
|
+
shown={showFileUpload}
|
|
339
|
+
/>
|
|
340
|
+
{!showFileUpload && (
|
|
341
|
+
<SpsButton onClick={() => setShowFileUpload(true)}>
|
|
342
|
+
Reset
|
|
343
|
+
</SpsButton>
|
|
344
|
+
)}
|
|
345
|
+
</div>
|
|
346
|
+
</div>
|
|
347
|
+
)
|
|
348
|
+
}
|
|
349
|
+
`}}},downloadButton:{label:"Download Button",description:f.code`
|
|
350
|
+
<p>You can optionally provide a button to download a file. Typically this will be a template for
|
|
351
|
+
whatever the user is expected to upload. They can then fill out the template, save it, and upload it.</p>
|
|
352
|
+
`,examples:{downloadButton:{react:f.code`
|
|
353
|
+
function Component() {
|
|
354
|
+
const ref = React.useRef()
|
|
355
|
+
|
|
356
|
+
function handleDownload() {
|
|
357
|
+
console.log("Download triggered.")
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
React.useEffect(() => {
|
|
361
|
+
ref.current.addEventListener("download", handleDownload)
|
|
362
|
+
return () => {
|
|
363
|
+
ref.current.removeEventListener("download", handleDownload)
|
|
364
|
+
}
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
return (
|
|
368
|
+
<div className="sps-row">
|
|
369
|
+
<div className="col-12">
|
|
370
|
+
<sps-file-upload
|
|
371
|
+
ref={ref}
|
|
372
|
+
description="Spreadsheet"
|
|
373
|
+
acceptExtensions="xlsx"
|
|
374
|
+
downloadLabel="Download Excel Template"
|
|
375
|
+
/>
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
)
|
|
379
|
+
}
|
|
380
|
+
`}}},mini:{label:"Mini File Upload",description:f.code`
|
|
381
|
+
<p>When the file upload component is to be placed in a small container,
|
|
382
|
+
it should be marked as a mini file upload so that everything fits.</p>
|
|
383
|
+
`,examples:{single:{react:f.code`
|
|
384
|
+
function Component() {
|
|
385
|
+
const ref = React.useRef()
|
|
386
|
+
|
|
387
|
+
function handleChange(event) {
|
|
388
|
+
console.log(event.detail)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
React.useEffect(() => {
|
|
392
|
+
ref.current.addEventListener("selection", handleChange)
|
|
393
|
+
return () => {
|
|
394
|
+
ref.current.removeEventListener("selection", handleChange)
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
|
|
398
|
+
return (
|
|
399
|
+
<div className="sps-row">
|
|
400
|
+
<div className="col-4">
|
|
401
|
+
<sps-file-upload ref={ref} mini/>
|
|
402
|
+
</div>
|
|
403
|
+
</div>
|
|
404
|
+
)
|
|
405
|
+
}
|
|
406
|
+
`}}},constrainContentWidth:{label:"Constrain Content Width",description:f.code`
|
|
407
|
+
<p>If this prop is provided, the content will be restricted to 50% of
|
|
408
|
+
the overall width of the component. Consult your product designer if
|
|
409
|
+
you're not sure whether to use this variant.</p>
|
|
410
|
+
`,examples:{constrainContentWidth:{react:f.code`
|
|
411
|
+
function Component() {
|
|
412
|
+
const ref = React.useRef()
|
|
413
|
+
|
|
414
|
+
function handleChange(event: CustomEvent<Array<File>>) {
|
|
415
|
+
console.log(event.detail)
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
React.useEffect(() => {
|
|
419
|
+
ref.current.addEventListener("selection", handleChange)
|
|
420
|
+
return () => {
|
|
421
|
+
ref.current.removeEventListener("selection", handleChange)
|
|
422
|
+
}
|
|
423
|
+
})
|
|
424
|
+
|
|
425
|
+
return (
|
|
426
|
+
<div className="sps-row">
|
|
427
|
+
<div className="col-4">
|
|
428
|
+
<sps-file-upload ref={ref} constrainContentWidth/>
|
|
429
|
+
</div>
|
|
430
|
+
</div>
|
|
431
|
+
)
|
|
432
|
+
}
|
|
433
|
+
`}}}};var nt=Object.defineProperty,st=Object.getOwnPropertyDescriptor,F=(e,t,a,r)=>{for(var l=r>1?void 0:r?st(t,a):t,p=e.length-1,u;p>=0;p--)(u=e[p])&&(l=(r?u(t,a,l):u(l))||l);return r&&l&&nt(t,a,l),l};const E="sps-insight-card";i.SpsInsightCardComponent=class extends HTMLElement{constructor(){super(...arguments),this.kind=L.SpsInsightCardKind.GENERAL}get[B](){return[E,`${E}--${this.kind}`,this.detail&&this.detail.children.length?`${E}--has-detail`:null]}render(){const t=d("div",{className:`${E}__metric-count`},this.metric),a=d("div",{className:`${E}__description`},d("div",{className:`${E}__title`,style:{"-webkit-box-orient":"vertical"}},this.title),d("div",{className:`${E}__detail`},this.content)),r=this.partnercount,l=this.totalpartners,[p,u,R]=(r?D.i18nWoodland.t("insightCard.partnerCount",{count:r,total:l,defaultValue:`${r} |of| ${l}`}):"").split("|");return d("div",{"data-fragment":!0},d("div",{className:`${E}__body`},this.icon?d("i",{className:`sps-icon sps-icon-${this.icon}`}):d("i",{className:`sps-icon sps-icon-${L.SpsInsightCardIcons[this.kind]}`}),t,a),r&&d("div",{className:`${E}__partner-count`},r===l?d("div",null,D.i18nWoodland.t("insightCard.all",{defaultValue:"ALL"})):d("div",{"data-fragment":!0},d("div",null,p),d("div",null,u),d("div",null,R)),d("div",{className:`${E}__partners-text`},D.i18nWoodland.t("insightCard.partners",{defaultValue:"PARTNERS"}))))}},i.SpsInsightCardComponent.displayName=E,i.SpsInsightCardComponent.props={icon:"SpsIcon",kind:"SpsInsightCardKind",title:"string",metric:"number",partnerCount:"number",totalPartners:"number",secondary:"boolean"},F([v()],i.SpsInsightCardComponent.prototype,"icon",2),F([v()],i.SpsInsightCardComponent.prototype,"kind",2),F([v()],i.SpsInsightCardComponent.prototype,"title",2),F([v()],i.SpsInsightCardComponent.prototype,"metric",2),F([v()],i.SpsInsightCardComponent.prototype,"partnerCount",2),F([v()],i.SpsInsightCardComponent.prototype,"totalPartners",2),F([v()],i.SpsInsightCardComponent.prototype,"secondary",2),F([M()],i.SpsInsightCardComponent.prototype,"content",2),F([te(`.${E}__detail`)],i.SpsInsightCardComponent.prototype,"detail",2),i.SpsInsightCardComponent=F([j({tag:E})],i.SpsInsightCardComponent);var it=Object.defineProperty,at=Object.getOwnPropertyDescriptor,me=(e,t,a,r)=>{for(var l=r>1?void 0:r?at(t,a):t,p=e.length-1,u;p>=0;p--)(u=e[p])&&(l=(r?u(t,a,l):u(l))||l);return r&&l&&it(t,a,l),l};const T="sps-insights";i.SpsInsightsComponent=class extends HTMLElement{constructor(){super(),this.content=[],this.showAdditionalInsights=!1,this.toggleAdditionalInsights=this.toggleAdditionalInsights.bind(this)}get[B](){return[T,this.showAdditionalInsights&&`${T}--show-additional`,this.details&&Array.from(this.details).every(t=>!t.textContent)?`${T}--no-details`:null,this.content.length===6?`${T}--break-4`:null,this.content.length===7?`${T}--break-5`:null,this.content.length===8?`${T}--break-5`:null]}toggleAdditionalInsights(){this.showAdditionalInsights=!this.showAdditionalInsights,this.update()}render(){return d("div",{"data-fragment":!0},this.content,this.content.length>10&&d("div",{className:"sps-button sps-button--link",onClick:this.toggleAdditionalInsights},d("button",{type:"button"},this.showAdditionalInsights?D.i18nWoodland.t("insights.hideAdditionalInsights",{defaultValue:"Hide Additional Insights"}):D.i18nWoodland.t("insights.showAdditionalInsights",{defaultValue:"Show Additional Insights"}))))}},i.SpsInsightsComponent.displayName=T,i.SpsInsightsComponent.props={},me([M()],i.SpsInsightsComponent.prototype,"content",2),me([Pe(".sps-insight-card__detail")],i.SpsInsightsComponent.prototype,"details",2),i.SpsInsightsComponent=me([j({tag:T})],i.SpsInsightsComponent);const rt={basic:{label:"Basic Insight Cards",examples:{basic:{jsx:f.code`
|
|
434
|
+
<sps-insights>
|
|
435
|
+
<sps-insight-card kind="general"
|
|
436
|
+
metric="1234"
|
|
437
|
+
title="Insight Card Title"
|
|
438
|
+
></sps-insight-card>
|
|
439
|
+
<sps-insight-card kind="processing"
|
|
440
|
+
metric="1234"
|
|
441
|
+
title="Insight Card Title"
|
|
442
|
+
></sps-insight-card>
|
|
443
|
+
<sps-insight-card kind="success"
|
|
444
|
+
metric="1234"
|
|
445
|
+
title="Insight Card Title"
|
|
446
|
+
></sps-insight-card>
|
|
447
|
+
<sps-insight-card kind="warning"
|
|
448
|
+
metric="1234"
|
|
449
|
+
title="Insight Card Title"
|
|
450
|
+
></sps-insight-card>
|
|
451
|
+
<sps-insight-card kind="error"
|
|
452
|
+
metric="1234"
|
|
453
|
+
title="Insight Card Title"
|
|
454
|
+
></sps-insight-card>
|
|
455
|
+
</sps-insights>
|
|
456
|
+
`}}},details:{label:"With Details",examples:{details:{jsx:f.code`
|
|
457
|
+
<sps-insights>
|
|
458
|
+
<sps-insight-card kind="general"
|
|
459
|
+
metric="1234"
|
|
460
|
+
title="Insight Card Title"
|
|
461
|
+
>
|
|
462
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
463
|
+
</sps-insight-card>
|
|
464
|
+
<sps-insight-card kind="processing"
|
|
465
|
+
metric="1234"
|
|
466
|
+
title="Insight Card Title"
|
|
467
|
+
>
|
|
468
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
469
|
+
</sps-insight-card>
|
|
470
|
+
<sps-insight-card kind="success"
|
|
471
|
+
metric="1234"
|
|
472
|
+
title="Insight Card Title"
|
|
473
|
+
>
|
|
474
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
475
|
+
</sps-insight-card>
|
|
476
|
+
<sps-insight-card kind="warning"
|
|
477
|
+
metric="1234"
|
|
478
|
+
title="Insight Card Title"
|
|
479
|
+
>
|
|
480
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
481
|
+
</sps-insight-card>
|
|
482
|
+
<sps-insight-card kind="error"
|
|
483
|
+
metric="1234"
|
|
484
|
+
title="Insight Card Title"
|
|
485
|
+
>
|
|
486
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
487
|
+
</sps-insight-card>
|
|
488
|
+
<sps-insight-card kind="success"
|
|
489
|
+
metric="1234"
|
|
490
|
+
title="Insight Card Title"
|
|
491
|
+
>
|
|
492
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
493
|
+
</sps-insight-card>
|
|
494
|
+
<sps-insight-card kind="error"
|
|
495
|
+
metric="1234"
|
|
496
|
+
title="Insight Card Title"
|
|
497
|
+
>
|
|
498
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
499
|
+
</sps-insight-card>
|
|
500
|
+
</sps-insights>
|
|
501
|
+
`}}},partner_count:{label:"Partner Count",examples:{partner_count:{jsx:f.code`
|
|
502
|
+
<sps-insights>
|
|
503
|
+
<sps-insight-card kind="general"
|
|
504
|
+
metric="1234"
|
|
505
|
+
title="Insight Card Title"
|
|
506
|
+
partnerCount="250"
|
|
507
|
+
totalPartners="250"
|
|
508
|
+
></sps-insight-card>
|
|
509
|
+
<sps-insight-card kind="processing"
|
|
510
|
+
metric="1234"
|
|
511
|
+
title="Insight Card Title"
|
|
512
|
+
partnerCount="122"
|
|
513
|
+
totalPartners="250"
|
|
514
|
+
></sps-insight-card>
|
|
515
|
+
<sps-insight-card kind="success"
|
|
516
|
+
metric="1234"
|
|
517
|
+
title="Insight Card Title"
|
|
518
|
+
partnerCount="207"
|
|
519
|
+
totalPartners="250"
|
|
520
|
+
></sps-insight-card>
|
|
521
|
+
<sps-insight-card kind="warning"
|
|
522
|
+
metric="1234"
|
|
523
|
+
title="Insight Card Title"
|
|
524
|
+
partnerCount="12"
|
|
525
|
+
totalPartners="250"
|
|
526
|
+
></sps-insight-card>
|
|
527
|
+
<sps-insight-card kind="error"
|
|
528
|
+
metric="1234"
|
|
529
|
+
title="Insight Card Title"
|
|
530
|
+
partnerCount="94"
|
|
531
|
+
totalPartners="250"
|
|
532
|
+
></sps-insight-card>
|
|
533
|
+
</sps-insights>
|
|
534
|
+
`}}},expansion:{label:"10+ Insight Cards",examples:{expansion:{jsx:f.code`
|
|
535
|
+
<sps-insights>
|
|
536
|
+
<sps-insight-card kind="general"
|
|
537
|
+
metric="1234"
|
|
538
|
+
title="Insight Card Title"
|
|
539
|
+
partnerCount="100"
|
|
540
|
+
totalPartners="200"
|
|
541
|
+
>
|
|
542
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
543
|
+
</sps-insight-card>
|
|
544
|
+
<sps-insight-card kind="processing"
|
|
545
|
+
metric="1234"
|
|
546
|
+
title="Insight Card Title"
|
|
547
|
+
partnerCount="100"
|
|
548
|
+
totalPartners="200"
|
|
549
|
+
></sps-insight-card>
|
|
550
|
+
<sps-insight-card kind="success"
|
|
551
|
+
metric="1234"
|
|
552
|
+
title="Insight Card Title"
|
|
553
|
+
partnerCount="100"
|
|
554
|
+
totalPartners="200"
|
|
555
|
+
>
|
|
556
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
557
|
+
</sps-insight-card>
|
|
558
|
+
<sps-insight-card kind="warning"
|
|
559
|
+
metric="1234"
|
|
560
|
+
title="Insight Card Title"
|
|
561
|
+
partnerCount="100"
|
|
562
|
+
totalPartners="200"
|
|
563
|
+
></sps-insight-card>
|
|
564
|
+
<sps-insight-card kind="error"
|
|
565
|
+
metric="1234"
|
|
566
|
+
title="Insight Card Title"
|
|
567
|
+
partnerCount="100"
|
|
568
|
+
totalPartners="200"
|
|
569
|
+
>
|
|
570
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
571
|
+
</sps-insight-card>
|
|
572
|
+
<sps-insight-card kind="general"
|
|
573
|
+
metric="1234"
|
|
574
|
+
title="Insight Card Title"
|
|
575
|
+
partnerCount="100"
|
|
576
|
+
totalPartners="200"
|
|
577
|
+
></sps-insight-card>
|
|
578
|
+
<sps-insight-card kind="processing"
|
|
579
|
+
metric="1234"
|
|
580
|
+
title="Insight Card Title"
|
|
581
|
+
partnerCount="100"
|
|
582
|
+
totalPartners="200"
|
|
583
|
+
>
|
|
584
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
585
|
+
</sps-insight-card>
|
|
586
|
+
<sps-insight-card kind="success"
|
|
587
|
+
metric="1234"
|
|
588
|
+
title="Insight Card Title"
|
|
589
|
+
partnerCount="100"
|
|
590
|
+
totalPartners="200"
|
|
591
|
+
></sps-insight-card>
|
|
592
|
+
<sps-insight-card kind="warning"
|
|
593
|
+
metric="1234"
|
|
594
|
+
title="Insight Card Title"
|
|
595
|
+
partnerCount="100"
|
|
596
|
+
totalPartners="200"
|
|
597
|
+
>
|
|
598
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
599
|
+
</sps-insight-card>
|
|
600
|
+
<sps-insight-card kind="error"
|
|
601
|
+
metric="1234"
|
|
602
|
+
title="Insight Card Title"
|
|
603
|
+
partnerCount="100"
|
|
604
|
+
totalPartners="200"
|
|
605
|
+
></sps-insight-card>
|
|
606
|
+
<sps-insight-card kind="general"
|
|
607
|
+
metric="1234"
|
|
608
|
+
title="Insight Card Title"
|
|
609
|
+
partnerCount="100"
|
|
610
|
+
totalPartners="200"
|
|
611
|
+
>
|
|
612
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
613
|
+
</sps-insight-card>
|
|
614
|
+
<sps-insight-card kind="processing"
|
|
615
|
+
metric="1234"
|
|
616
|
+
title="Insight Card Title"
|
|
617
|
+
partnerCount="100"
|
|
618
|
+
totalPartners="200"
|
|
619
|
+
></sps-insight-card>
|
|
620
|
+
<sps-insight-card kind="success"
|
|
621
|
+
metric="1234"
|
|
622
|
+
title="Insight Card Title"
|
|
623
|
+
partnerCount="100"
|
|
624
|
+
totalPartners="200"
|
|
625
|
+
>
|
|
626
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
627
|
+
</sps-insight-card>
|
|
628
|
+
<sps-insight-card kind="warning"
|
|
629
|
+
metric="1234"
|
|
630
|
+
title="Insight Card Title"
|
|
631
|
+
partnerCount="100"
|
|
632
|
+
totalPartners="200"
|
|
633
|
+
></sps-insight-card>
|
|
634
|
+
<sps-insight-card kind="error"
|
|
635
|
+
metric="1234"
|
|
636
|
+
title="Insight Card Title"
|
|
637
|
+
partnerCount="100"
|
|
638
|
+
totalPartners="200"
|
|
639
|
+
>
|
|
640
|
+
<span className="gray600 font-weight-bold">Detail:</span> 792 units
|
|
641
|
+
</sps-insight-card>
|
|
642
|
+
</sps-insights>
|
|
643
|
+
`}}},events:{label:"Adding a click handler",description:f.code`
|
|
644
|
+
<p>Attaching event handlers to native web components in React cannot be done the usual way at this time.
|
|
645
|
+
Here is how to do it:</p>
|
|
646
|
+
`,examples:{events:{react:f.code`
|
|
647
|
+
function Component() {
|
|
648
|
+
function handleClick() {
|
|
649
|
+
window.alert("Insight card clicked");
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
const ref = React.useRef();
|
|
653
|
+
React.useEffect(() => {
|
|
654
|
+
ref.current.addEventListener("click", handleClick);
|
|
655
|
+
return () => {
|
|
656
|
+
ref.current.removeEventListener("click", handleClick);
|
|
657
|
+
};
|
|
658
|
+
}, []);
|
|
659
|
+
|
|
660
|
+
return (
|
|
661
|
+
<sps-insights>
|
|
662
|
+
<sps-insight-card ref={ref}
|
|
663
|
+
kind="general"
|
|
664
|
+
metric="1234"
|
|
665
|
+
title="Insight Card Title"
|
|
666
|
+
></sps-insight-card>
|
|
667
|
+
<sps-insight-card kind="general"
|
|
668
|
+
metric="1234"
|
|
669
|
+
title="Insight Card Title"
|
|
670
|
+
></sps-insight-card>
|
|
671
|
+
<sps-insight-card kind="general"
|
|
672
|
+
metric="1234"
|
|
673
|
+
title="Insight Card Title"
|
|
674
|
+
></sps-insight-card>
|
|
675
|
+
</sps-insights>
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
`}}},alternateIcon:{label:"Using alternate icons",examples:{basic:{react:f.code`
|
|
679
|
+
function DemoComponent() {
|
|
680
|
+
return (
|
|
681
|
+
<sps-insights>
|
|
682
|
+
<sps-insight-card
|
|
683
|
+
kind="general"
|
|
684
|
+
metric="1234"
|
|
685
|
+
icon={SpsIcon.DOLLAR_SIGN}
|
|
686
|
+
title="Insight Card Title"
|
|
687
|
+
></sps-insight-card>
|
|
688
|
+
<sps-insight-card
|
|
689
|
+
kind="processing"
|
|
690
|
+
metric="1234"
|
|
691
|
+
icon={SpsIcon.ASTERISK}
|
|
692
|
+
title="Insight Card Title"
|
|
693
|
+
></sps-insight-card>
|
|
694
|
+
<sps-insight-card
|
|
695
|
+
kind="success"
|
|
696
|
+
metric="1234"
|
|
697
|
+
icon={SpsIcon.USER}
|
|
698
|
+
title="Insight Card Title"
|
|
699
|
+
></sps-insight-card>
|
|
700
|
+
<sps-insight-card
|
|
701
|
+
kind="warning"
|
|
702
|
+
metric="1234"
|
|
703
|
+
icon={SpsIcon.FOLDER_OPEN}
|
|
704
|
+
title="Insight Card Title"
|
|
705
|
+
></sps-insight-card>
|
|
706
|
+
<sps-insight-card
|
|
707
|
+
kind="error"
|
|
708
|
+
metric="1234"
|
|
709
|
+
icon={SpsIcon.BAN}
|
|
710
|
+
title="Insight Card Title"
|
|
711
|
+
></sps-insight-card>
|
|
712
|
+
</sps-insights>
|
|
713
|
+
)
|
|
714
|
+
}
|
|
715
|
+
`}}}};var ot=Object.defineProperty,lt=Object.getOwnPropertyDescriptor,W=(e,t,a,r)=>{for(var l=r>1?void 0:r?lt(t,a):t,p=e.length-1,u;p>=0;p--)(u=e[p])&&(l=(r?u(t,a,l):u(l))||l);return r&&l&&ot(t,a,l),l};i.SpsNavTabComponent=class extends HTMLElement{constructor(){super(...arguments),this.active=!1,this.label="",this.tag=""}get[B](){return["sps-tabbed-nav__nav-item",this.active&&"sps-tabbed-nav__nav-item--active"]}render(){return d("a",{href:this.href,target:this.target,className:"sps-tabbed-nav__nav-item-link",tabIndex:0},this.icon&&d("i",{className:`sps-icon sps-icon-${this.icon}`}),this.label&&d("span",null,this.label),this.tag&&d("span",{className:"sps-tag sps-tag--default"},this.tag))}},i.SpsNavTabComponent.displayName="sps-nav-tab",i.SpsNavTabComponent.props={active:"boolean",label:"string",icon:"SpsIcon",tag:"string",href:"string",target:"string"},W([v()],i.SpsNavTabComponent.prototype,"active",2),W([v()],i.SpsNavTabComponent.prototype,"label",2),W([v()],i.SpsNavTabComponent.prototype,"icon",2),W([v()],i.SpsNavTabComponent.prototype,"tag",2),W([v()],i.SpsNavTabComponent.prototype,"href",2),W([v()],i.SpsNavTabComponent.prototype,"target",2),i.SpsNavTabComponent=W([j({tag:"sps-nav-tab"})],i.SpsNavTabComponent);var ct=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,Ee=(e,t,a,r)=>{for(var l=r>1?void 0:r?pt(t,a):t,p=e.length-1,u;p>=0;p--)(u=e[p])&&(l=(r?u(t,a,l):u(l))||l);return r&&l&&ct(t,a,l),l};i.SpsNavTabSetComponent=class extends HTMLElement{constructor(){super(...arguments),this.content=[]}render(){return d("nav",{className:"sps-tabbed-nav"},this.content)}},i.SpsNavTabSetComponent.displayName="sps-nav-tab-set",i.SpsNavTabSetComponent.props={},Ee([M()],i.SpsNavTabSetComponent.prototype,"content",2),i.SpsNavTabSetComponent=Ee([j({tag:"sps-nav-tab-set"})],i.SpsNavTabSetComponent);const dt={basic:{label:"Basic Navigation Tabs",description:f.code`
|
|
716
|
+
<p>Navigation tabs native web component</p>
|
|
717
|
+
`,examples:{basic:{react:f.code`
|
|
718
|
+
function DemoComponent() {
|
|
719
|
+
const tabs = [
|
|
720
|
+
{ label: "Tab A", icon: "chart-line" },
|
|
721
|
+
{ label: "Tab B", icon: "chart-bar", tag: "12" },
|
|
722
|
+
{ label: "Tab C", icon: "chart-pie" }
|
|
723
|
+
]
|
|
724
|
+
|
|
725
|
+
const [activeTab, setActiveTab] = React.useState(0)
|
|
726
|
+
|
|
727
|
+
return (
|
|
728
|
+
<sps-nav-tab-set>
|
|
729
|
+
{tabs.map((tab, index) => (
|
|
730
|
+
<sps-nav-tab
|
|
731
|
+
key={index}
|
|
732
|
+
icon={tab.icon}
|
|
733
|
+
label={tab.label}
|
|
734
|
+
tag={tab.tag}
|
|
735
|
+
active={index === activeTab || null}
|
|
736
|
+
onClick={() => setActiveTab(index)}
|
|
737
|
+
/>
|
|
738
|
+
))}
|
|
739
|
+
</sps-nav-tab-set>
|
|
740
|
+
)
|
|
741
|
+
}
|
|
742
|
+
`}}}};var ht=Object.defineProperty,ut=Object.getOwnPropertyDescriptor,U=(e,t,a,r)=>{for(var l=r>1?void 0:r?ut(t,a):t,p=e.length-1,u;p>=0;p--)(u=e[p])&&(l=(r?u(t,a,l):u(l))||l);return r&&l&&ht(t,a,l),l},Ie=(e=>(e.FIT="fit",e.FILL="fill",e))(Ie||{});const V="sps-photo";i.SpsPhotoComponent=class extends HTMLElement{constructor(){super(...arguments),this.mode="fill"}get image(){return this.imageInternal}set image(t){this.imageInternal=t,t&&(this.waitForImgHeightInterval&&window.clearInterval(this.waitForImgHeightInterval),this.waitForImgHeightInterval=window.setInterval(()=>{const a=t.getBoundingClientRect();if(a.height){window.clearInterval(this.waitForImgHeightInterval),delete this.waitForImgHeightInterval;let r=a.width/a.height>1;this.fitWidth=r===(this.mode==="fit")}},1e3/60))}get[B](){return[V,this.fitWidth?`${V}--fit-width`:`${V}--fit-height`,this.placeholderIcon&&`${V}--placeholder`]}get[J](){return{fontSize:`${this.width*.05}rem`,width:`${this.width}rem`,height:`${.75*this.width}rem`}}connectedCallback(){this.waitForWidthInterval=window.setInterval(()=>{const t=this.getBoundingClientRect();t.width&&(this.setWidth(t.width),window.clearInterval(this.waitForWidthInterval),delete this.waitForWidthInterval)},1e3/60)}disconnectedCallback(){this.waitForWidthInterval&&window.clearInterval(this.waitForWidthInterval),this.waitForImgHeightInterval&&window.clearInterval(this.waitForImgHeightInterval)}render(){return this.src?this.width?d("img",{src:this.src,alt:this.altText}):d("span",null):d("i",{className:`sps-icon sps-icon-${this.placeholderIcon}`})}setWidth(t){if(t&&!this.width){const a=document.body.parentElement.style.fontSize||"16px",r=Number(a.substr(0,a.length-2));this.width=t/r}}},i.SpsPhotoComponent.displayName=V,i.SpsPhotoComponent.props={src:"string",altText:"string",mode:"SpsPhotoDisplayMode",placeholderIcon:"SpsIcon"},U([v()],i.SpsPhotoComponent.prototype,"src",2),U([v()],i.SpsPhotoComponent.prototype,"altText",2),U([v()],i.SpsPhotoComponent.prototype,"mode",2),U([v()],i.SpsPhotoComponent.prototype,"placeholderIcon",2),U([ue()],i.SpsPhotoComponent.prototype,"width",2),U([ue()],i.SpsPhotoComponent.prototype,"fitWidth",2),U([te("img",{refresh:!0})],i.SpsPhotoComponent.prototype,"image",1),i.SpsPhotoComponent=U([j({tag:V})],i.SpsPhotoComponent);const ft={sizing:{label:"Sizing",description:f.code`
|
|
743
|
+
<p>
|
|
744
|
+
Photos are block elements, so a photo fills its container's width unless
|
|
745
|
+
an explicit width is set. It is always a 4:3 aspect ratio. In this example,
|
|
746
|
+
photos have been placed in cards which have different widths in the 12
|
|
747
|
+
column grid.
|
|
748
|
+
</p>
|
|
749
|
+
`,examples:{basic:{jsx:f.code`
|
|
750
|
+
<div className="sfg-row">
|
|
751
|
+
<div className="sfg-col-2">
|
|
752
|
+
<sps-card>
|
|
753
|
+
<sps-photo src="assets/images/photo-landscape.jpg"></sps-photo>
|
|
754
|
+
</sps-card>
|
|
755
|
+
</div>
|
|
756
|
+
<div className="sfg-col-4">
|
|
757
|
+
<sps-card>
|
|
758
|
+
<sps-photo src="assets/images/photo-landscape.jpg"></sps-photo>
|
|
759
|
+
</sps-card>
|
|
760
|
+
</div>
|
|
761
|
+
<div className="sfg-col-6">
|
|
762
|
+
<sps-card>
|
|
763
|
+
<sps-photo src="assets/images/photo-landscape.jpg"></sps-photo>
|
|
764
|
+
</sps-card>
|
|
765
|
+
</div>
|
|
766
|
+
</div>
|
|
767
|
+
`}}},displayMode:{label:"Fill vs. Fit",description:f.code`
|
|
768
|
+
<p>
|
|
769
|
+
There are two display modes available:
|
|
770
|
+
<ul>
|
|
771
|
+
<li><b>"fill"</b> fills the entire 4:3 container, cropping off any excess portions of the image.
|
|
772
|
+
<li><b>"fit"</b> fits the entire image into the container, leaving any excess portions of the container blank.
|
|
773
|
+
</ul>
|
|
774
|
+
</p>
|
|
775
|
+
`,examples:{landscape:{description:"<p>Landscape oriented photo (container outline added for illustrative purposes)</p>",jsx:f.code`
|
|
776
|
+
<div className="sfg-row">
|
|
777
|
+
<div className="sfg-col-4">
|
|
778
|
+
<sps-photo src="assets/images/photo-landscape.jpg" mode="fill"></sps-photo>
|
|
779
|
+
</div>
|
|
780
|
+
<div className="sfg-col-4">
|
|
781
|
+
<sps-photo src="assets/images/photo-landscape.jpg" mode="fit"></sps-photo>
|
|
782
|
+
</div>
|
|
783
|
+
</div>
|
|
784
|
+
`},portrait:{description:"<p>Portrait oriented photo (container outline added for illustrative purposes)</p>",jsx:f.code`
|
|
785
|
+
<div className="sfg-row">
|
|
786
|
+
<div className="sfg-col-4">
|
|
787
|
+
<sps-photo src="assets/images/photo-portrait.jpg" mode="fill"></sps-photo>
|
|
788
|
+
</div>
|
|
789
|
+
<div className="sfg-col-4">
|
|
790
|
+
<sps-photo id="foo" src="assets/images/photo-portrait.jpg" mode="fit"></sps-photo>
|
|
791
|
+
</div>
|
|
792
|
+
</div>
|
|
793
|
+
`}}},placeholder:{label:"Placeholders",description:f.code`
|
|
794
|
+
<p>
|
|
795
|
+
When an image is not provided for a particular use case (such as a user avatar,
|
|
796
|
+
a company photo, item image, etc.), a placeholder should be shown in its place.
|
|
797
|
+
|
|
798
|
+
The placeholder's icon, selected from our SPS icon set, should represent the
|
|
799
|
+
type of image it is substituting for.
|
|
800
|
+
</p>
|
|
801
|
+
`,examples:{general:{description:"<p>General Photo</p>",jsx:f.code`
|
|
802
|
+
<div className="sfg-row">
|
|
803
|
+
<div className="sfg-col-3">
|
|
804
|
+
<sps-photo placeholderIcon="photo"></sps-photo>
|
|
805
|
+
</div>
|
|
806
|
+
</div>
|
|
807
|
+
`},photoAlt:{description:"<p>Photo Alt</p>",jsx:f.code`
|
|
808
|
+
<div className="sfg-row">
|
|
809
|
+
<div className="sfg-col-3">
|
|
810
|
+
<sps-photo placeholderIcon="camera"></sps-photo>
|
|
811
|
+
</div>
|
|
812
|
+
</div>
|
|
813
|
+
`},user:{description:"<p>User / Single Person</p>",jsx:f.code`
|
|
814
|
+
<div className="sfg-row">
|
|
815
|
+
<div className="sfg-col-3">
|
|
816
|
+
<sps-photo placeholderIcon="user"></sps-photo>
|
|
817
|
+
</div>
|
|
818
|
+
</div>
|
|
819
|
+
`},group:{description:"<p>Group / Multiple People</p>",jsx:f.code`
|
|
820
|
+
<div className="sfg-row">
|
|
821
|
+
<div className="sfg-col-3">
|
|
822
|
+
<sps-photo placeholderIcon="group"></sps-photo>
|
|
823
|
+
</div>
|
|
824
|
+
</div>
|
|
825
|
+
`},company:{description:"<p>Company / Building</p>",jsx:f.code`
|
|
826
|
+
<div className="sfg-row">
|
|
827
|
+
<div className="sfg-col-3">
|
|
828
|
+
<sps-photo placeholderIcon="building"></sps-photo>
|
|
829
|
+
</div>
|
|
830
|
+
</div>
|
|
831
|
+
`}}}};i.AttrBindings=he,i.ClassBindings=B,i.Component=j,i.Content=M,i.EventDispatcher=ee,i.EventListener=X,i.MANIFEST=Ke,i.MIMEType=fe,i.Prop=v,i.QuerySelector=te,i.QuerySelectorAll=Pe,i.SpsFileUploadExamples=tt,i.SpsInsightCardExamples=rt,i.SpsNavTabsExamples=dt,i.SpsPhotoDisplayMode=Ie,i.SpsPhotoExamples=ft,i.StyleBindings=J,i.Watch=ue,i.h=d,i.namespaceOverrideRegistrar=Ye,i.register=Ze,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|