@spscommerce/ds-web-components 0.1.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.
Files changed (67) hide show
  1. package/README.md +3 -0
  2. package/dist/README.md +3 -0
  3. package/dist/global.d.ts +15 -0
  4. package/dist/lib/components/file-upload/file-upload.d.ts +119 -0
  5. package/dist/lib/components/file-upload/file-upload.examples.d.ts +2 -0
  6. package/dist/lib/components/file-upload/mime-type.enum.d.ts +75 -0
  7. package/dist/lib/components/index.d.ts +11 -0
  8. package/dist/lib/components/insight-card/insight-card.d.ts +40 -0
  9. package/dist/lib/components/insight-card/insight-card.examples.d.ts +51 -0
  10. package/dist/lib/components/insight-card/insights.d.ts +18 -0
  11. package/dist/lib/components/nav-tabs/nav-tab-set.d.ts +7 -0
  12. package/dist/lib/components/nav-tabs/nav-tab.d.ts +24 -0
  13. package/dist/lib/components/nav-tabs/nav-tabs.examples.d.ts +11 -0
  14. package/dist/lib/components/photo/photo.d.ts +42 -0
  15. package/dist/lib/components/photo/photo.examples.d.ts +2 -0
  16. package/dist/lib/decorators/component.d.ts +33 -0
  17. package/dist/lib/decorators/content.d.ts +7 -0
  18. package/dist/lib/decorators/event-dispatcher.d.ts +9 -0
  19. package/dist/lib/decorators/event-listener.d.ts +5 -0
  20. package/dist/lib/decorators/index.d.ts +7 -0
  21. package/dist/lib/decorators/prop.d.ts +6 -0
  22. package/dist/lib/decorators/query-selector.d.ts +19 -0
  23. package/dist/lib/decorators/watch.d.ts +2 -0
  24. package/dist/lib/index.cjs.js +829 -0
  25. package/dist/lib/index.d.ts +6 -0
  26. package/dist/lib/index.es.js +2802 -0
  27. package/dist/lib/manifest.d.ts +2 -0
  28. package/dist/lib/utils/comment.d.ts +2 -0
  29. package/dist/lib/utils/i18n.d.ts +3 -0
  30. package/dist/lib/utils/index.d.ts +5 -0
  31. package/dist/lib/utils/metadata.d.ts +22 -0
  32. package/dist/lib/utils/pragma.d.ts +6 -0
  33. package/dist/lib/utils/register.d.ts +13 -0
  34. package/dist/package.json +36 -0
  35. package/global.d.ts +15 -0
  36. package/lib/components/file-upload/file-upload.d.ts +119 -0
  37. package/lib/components/file-upload/file-upload.examples.d.ts +2 -0
  38. package/lib/components/file-upload/mime-type.enum.d.ts +75 -0
  39. package/lib/components/index.d.ts +11 -0
  40. package/lib/components/insight-card/insight-card.d.ts +40 -0
  41. package/lib/components/insight-card/insight-card.examples.d.ts +51 -0
  42. package/lib/components/insight-card/insights.d.ts +18 -0
  43. package/lib/components/nav-tabs/nav-tab-set.d.ts +7 -0
  44. package/lib/components/nav-tabs/nav-tab.d.ts +24 -0
  45. package/lib/components/nav-tabs/nav-tabs.examples.d.ts +11 -0
  46. package/lib/components/photo/photo.d.ts +42 -0
  47. package/lib/components/photo/photo.examples.d.ts +2 -0
  48. package/lib/decorators/component.d.ts +33 -0
  49. package/lib/decorators/content.d.ts +7 -0
  50. package/lib/decorators/event-dispatcher.d.ts +9 -0
  51. package/lib/decorators/event-listener.d.ts +5 -0
  52. package/lib/decorators/index.d.ts +7 -0
  53. package/lib/decorators/prop.d.ts +6 -0
  54. package/lib/decorators/query-selector.d.ts +19 -0
  55. package/lib/decorators/watch.d.ts +2 -0
  56. package/lib/index.cjs.js +829 -0
  57. package/lib/index.d.ts +6 -0
  58. package/lib/index.es.js +2802 -0
  59. package/lib/manifest.d.ts +2 -0
  60. package/lib/utils/comment.d.ts +2 -0
  61. package/lib/utils/i18n.d.ts +3 -0
  62. package/lib/utils/index.d.ts +5 -0
  63. package/lib/utils/metadata.d.ts +22 -0
  64. package/lib/utils/pragma.d.ts +6 -0
  65. package/lib/utils/register.d.ts +13 -0
  66. package/package.json +37 -0
  67. package/vite.config.js +20 -0
@@ -0,0 +1,2802 @@
1
+ import { noI18nI18n, SpsIcon, SpsInsightCardKind, SpsInsightCardIcons } from "@spscommerce/ds-shared";
2
+ import { parseFileSize, code } from "@spscommerce/utils";
3
+ var incrementalDomCjs = {};
4
+ Object.defineProperty(incrementalDomCjs, "__esModule", { value: true });
5
+ /**
6
+ * @license
7
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS-IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
+ */
21
+ var symbols = {
22
+ default: "__default"
23
+ };
24
+ /**
25
+ * @license
26
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
27
+ *
28
+ * Licensed under the Apache License, Version 2.0 (the "License");
29
+ * you may not use this file except in compliance with the License.
30
+ * You may obtain a copy of the License at
31
+ *
32
+ * http://www.apache.org/licenses/LICENSE-2.0
33
+ *
34
+ * Unless required by applicable law or agreed to in writing, software
35
+ * distributed under the License is distributed on an "AS-IS" BASIS,
36
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37
+ * See the License for the specific language governing permissions and
38
+ * limitations under the License.
39
+ */
40
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
41
+ function Blank() {
42
+ }
43
+ Blank.prototype = Object.create(null);
44
+ function has(map, property) {
45
+ return hasOwnProperty.call(map, property);
46
+ }
47
+ function createMap() {
48
+ return new Blank();
49
+ }
50
+ function truncateArray(arr, length) {
51
+ while (arr.length > length) {
52
+ arr.pop();
53
+ }
54
+ }
55
+ /**
56
+ * @license
57
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
58
+ *
59
+ * Licensed under the Apache License, Version 2.0 (the "License");
60
+ * you may not use this file except in compliance with the License.
61
+ * You may obtain a copy of the License at
62
+ *
63
+ * http://www.apache.org/licenses/LICENSE-2.0
64
+ *
65
+ * Unless required by applicable law or agreed to in writing, software
66
+ * distributed under the License is distributed on an "AS-IS" BASIS,
67
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
68
+ * See the License for the specific language governing permissions and
69
+ * limitations under the License.
70
+ */
71
+ function getNamespace(name) {
72
+ if (name.lastIndexOf("xml:", 0) === 0) {
73
+ return "http://www.w3.org/XML/1998/namespace";
74
+ }
75
+ if (name.lastIndexOf("xlink:", 0) === 0) {
76
+ return "http://www.w3.org/1999/xlink";
77
+ }
78
+ return void 0;
79
+ }
80
+ function applyAttr(el, name, value) {
81
+ if (value == null) {
82
+ el.removeAttribute(name);
83
+ } else {
84
+ var attrNS = getNamespace(name);
85
+ if (attrNS) {
86
+ el.setAttributeNS(attrNS, name, String(value));
87
+ } else {
88
+ el.setAttribute(name, String(value));
89
+ }
90
+ }
91
+ }
92
+ function applyProp(el, name, value) {
93
+ el[name] = value;
94
+ }
95
+ function setStyleValue(style, prop, value) {
96
+ if (prop.indexOf("-") >= 0) {
97
+ style.setProperty(prop, value);
98
+ } else {
99
+ style[prop] = value;
100
+ }
101
+ }
102
+ function applyStyle(el, name, style) {
103
+ if (typeof style === "string") {
104
+ el.style.cssText = style;
105
+ } else {
106
+ el.style.cssText = "";
107
+ var elStyle = el.style;
108
+ for (var prop in style) {
109
+ if (has(style, prop)) {
110
+ setStyleValue(elStyle, prop, style[prop]);
111
+ }
112
+ }
113
+ }
114
+ }
115
+ function applyAttributeTyped(el, name, value) {
116
+ var type = typeof value;
117
+ if (type === "object" || type === "function") {
118
+ applyProp(el, name, value);
119
+ } else {
120
+ applyAttr(el, name, value);
121
+ }
122
+ }
123
+ var attributes = createMap();
124
+ attributes[symbols.default] = applyAttributeTyped;
125
+ attributes["style"] = applyStyle;
126
+ function updateAttribute(el, name, value) {
127
+ var mutator = attributes[name] || attributes[symbols.default];
128
+ mutator(el, name, value);
129
+ }
130
+ /**
131
+ * @license
132
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
133
+ *
134
+ * Licensed under the Apache License, Version 2.0 (the "License");
135
+ * you may not use this file except in compliance with the License.
136
+ * You may obtain a copy of the License at
137
+ *
138
+ * http://www.apache.org/licenses/LICENSE-2.0
139
+ *
140
+ * Unless required by applicable law or agreed to in writing, software
141
+ * distributed under the License is distributed on an "AS-IS" BASIS,
142
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
143
+ * See the License for the specific language governing permissions and
144
+ * limitations under the License.
145
+ */
146
+ var inAttributes = false;
147
+ function assertNoUnclosedTags(openElement, root) {
148
+ if (openElement === root) {
149
+ return;
150
+ }
151
+ var currentElement2 = openElement;
152
+ var openTags = [];
153
+ while (currentElement2 && currentElement2 !== root) {
154
+ openTags.push(currentElement2.nodeName.toLowerCase());
155
+ currentElement2 = currentElement2.parentNode;
156
+ }
157
+ throw new Error("One or more tags were not closed:\n" + openTags.join("\n"));
158
+ }
159
+ function assertPatchOuterHasParentNode(parent) {
160
+ if (!parent) {
161
+ console.warn("patchOuter requires the node have a parent if there is a key.");
162
+ }
163
+ }
164
+ function assertVirtualAttributesClosed() {
165
+ if (inAttributes) {
166
+ throw new Error("elementOpenEnd() must be called after calling elementOpenStart().");
167
+ }
168
+ }
169
+ function assertPatchElementNoExtras(maybeStartNode, maybeCurrentNode, expectedNextNode, expectedPrevNode) {
170
+ var startNode = maybeStartNode;
171
+ var currentNode2 = maybeCurrentNode;
172
+ var wasUpdated = currentNode2.nextSibling === expectedNextNode && currentNode2.previousSibling === expectedPrevNode;
173
+ var wasChanged = currentNode2.nextSibling === startNode.nextSibling && currentNode2.previousSibling === expectedPrevNode;
174
+ var wasRemoved = currentNode2 === startNode;
175
+ if (!wasUpdated && !wasChanged && !wasRemoved) {
176
+ throw new Error("There must be exactly one top level call corresponding to the patched element.");
177
+ }
178
+ }
179
+ function setInAttributes(value) {
180
+ var previous = inAttributes;
181
+ inAttributes = value;
182
+ return previous;
183
+ }
184
+ function assert(val) {
185
+ return val;
186
+ }
187
+ /**
188
+ * @license
189
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
190
+ *
191
+ * Licensed under the Apache License, Version 2.0 (the "License");
192
+ * you may not use this file except in compliance with the License.
193
+ * You may obtain a copy of the License at
194
+ *
195
+ * http://www.apache.org/licenses/LICENSE-2.0
196
+ *
197
+ * Unless required by applicable law or agreed to in writing, software
198
+ * distributed under the License is distributed on an "AS-IS" BASIS,
199
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ * See the License for the specific language governing permissions and
201
+ * limitations under the License.
202
+ */
203
+ var notifications = {
204
+ nodesCreated: null,
205
+ nodesDeleted: null
206
+ };
207
+ /**
208
+ * @license
209
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
210
+ *
211
+ * Licensed under the Apache License, Version 2.0 (the "License");
212
+ * you may not use this file except in compliance with the License.
213
+ * You may obtain a copy of the License at
214
+ *
215
+ * http://www.apache.org/licenses/LICENSE-2.0
216
+ *
217
+ * Unless required by applicable law or agreed to in writing, software
218
+ * distributed under the License is distributed on an "AS-IS" BASIS,
219
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
220
+ * See the License for the specific language governing permissions and
221
+ * limitations under the License.
222
+ */
223
+ var Context = function() {
224
+ function Context2() {
225
+ this.created = [];
226
+ this.deleted = [];
227
+ }
228
+ Context2.prototype.markCreated = function(node) {
229
+ this.created.push(node);
230
+ };
231
+ Context2.prototype.markDeleted = function(node) {
232
+ this.deleted.push(node);
233
+ };
234
+ Context2.prototype.notifyChanges = function() {
235
+ if (notifications.nodesCreated && this.created.length > 0) {
236
+ notifications.nodesCreated(this.created);
237
+ }
238
+ if (notifications.nodesDeleted && this.deleted.length > 0) {
239
+ notifications.nodesDeleted(this.deleted);
240
+ }
241
+ };
242
+ return Context2;
243
+ }();
244
+ /**
245
+ * @license
246
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
247
+ *
248
+ * Licensed under the Apache License, Version 2.0 (the "License");
249
+ * you may not use this file except in compliance with the License.
250
+ * You may obtain a copy of the License at
251
+ *
252
+ * http://www.apache.org/licenses/LICENSE-2.0
253
+ *
254
+ * Unless required by applicable law or agreed to in writing, software
255
+ * distributed under the License is distributed on an "AS-IS" BASIS,
256
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
257
+ * See the License for the specific language governing permissions and
258
+ * limitations under the License.
259
+ */
260
+ function isDocumentRoot(node) {
261
+ return node.nodeType === 11 || node.nodeType === 9;
262
+ }
263
+ function isElement(node) {
264
+ return node.nodeType === 1;
265
+ }
266
+ function isText(node) {
267
+ return node.nodeType === 3;
268
+ }
269
+ function getAncestry(node, root) {
270
+ var ancestry = [];
271
+ var cur = node;
272
+ while (cur !== root) {
273
+ var n = cur;
274
+ ancestry.push(n);
275
+ cur = n.parentNode;
276
+ }
277
+ return ancestry;
278
+ }
279
+ var getRootNode = Node.prototype.getRootNode || function() {
280
+ var cur = this;
281
+ var prev = cur;
282
+ while (cur) {
283
+ prev = cur;
284
+ cur = cur.parentNode;
285
+ }
286
+ return prev;
287
+ };
288
+ function getActiveElement(node) {
289
+ var root = getRootNode.call(node);
290
+ return isDocumentRoot(root) ? root.activeElement : null;
291
+ }
292
+ function getFocusedPath(node, root) {
293
+ var activeElement = getActiveElement(node);
294
+ if (!activeElement || !node.contains(activeElement)) {
295
+ return [];
296
+ }
297
+ return getAncestry(activeElement, root);
298
+ }
299
+ function moveBefore(parentNode, node, referenceNode) {
300
+ var insertReferenceNode = node.nextSibling;
301
+ var cur = referenceNode;
302
+ while (cur !== null && cur !== node) {
303
+ var next = cur.nextSibling;
304
+ parentNode.insertBefore(cur, insertReferenceNode);
305
+ cur = next;
306
+ }
307
+ }
308
+ /**
309
+ * @license
310
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
311
+ *
312
+ * Licensed under the Apache License, Version 2.0 (the "License");
313
+ * you may not use this file except in compliance with the License.
314
+ * You may obtain a copy of the License at
315
+ *
316
+ * http://www.apache.org/licenses/LICENSE-2.0
317
+ *
318
+ * Unless required by applicable law or agreed to in writing, software
319
+ * distributed under the License is distributed on an "AS-IS" BASIS,
320
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
321
+ * See the License for the specific language governing permissions and
322
+ * limitations under the License.
323
+ */
324
+ var NodeData = function() {
325
+ function NodeData2(nameOrCtor, key2, text2) {
326
+ this._attrsArr = null;
327
+ this.staticsApplied = false;
328
+ this.nameOrCtor = nameOrCtor;
329
+ this.key = key2;
330
+ this.text = text2;
331
+ }
332
+ NodeData2.prototype.hasEmptyAttrsArr = function() {
333
+ var attrs = this._attrsArr;
334
+ return !attrs || !attrs.length;
335
+ };
336
+ NodeData2.prototype.getAttrsArr = function(length) {
337
+ return this._attrsArr || (this._attrsArr = new Array(length));
338
+ };
339
+ return NodeData2;
340
+ }();
341
+ function initData(node, nameOrCtor, key2, text2) {
342
+ var data = new NodeData(nameOrCtor, key2, text2);
343
+ node["__incrementalDOMData"] = data;
344
+ return data;
345
+ }
346
+ function getData(node, key2) {
347
+ return importSingleNode(node, key2);
348
+ }
349
+ function isDataInitialized(node) {
350
+ return Boolean(node["__incrementalDOMData"]);
351
+ }
352
+ function getKey(node) {
353
+ assert(node["__incrementalDOMData"]);
354
+ return getData(node).key;
355
+ }
356
+ function importSingleNode(node, fallbackKey) {
357
+ if (node["__incrementalDOMData"]) {
358
+ return node["__incrementalDOMData"];
359
+ }
360
+ var nodeName = isElement(node) ? node.localName : node.nodeName;
361
+ var key2 = isElement(node) ? node.getAttribute("key") || fallbackKey : null;
362
+ var text2 = isText(node) ? node.data : void 0;
363
+ var data = initData(node, nodeName, key2, text2);
364
+ if (isElement(node)) {
365
+ recordAttributes(node, data);
366
+ }
367
+ return data;
368
+ }
369
+ function importNode(node) {
370
+ importSingleNode(node);
371
+ for (var child = node.firstChild; child; child = child.nextSibling) {
372
+ importNode(child);
373
+ }
374
+ }
375
+ function clearCache(node) {
376
+ node["__incrementalDOMData"] = null;
377
+ for (var child = node.firstChild; child; child = child.nextSibling) {
378
+ clearCache(child);
379
+ }
380
+ }
381
+ function recordAttributes(node, data) {
382
+ var attributes2 = node.attributes;
383
+ var length = attributes2.length;
384
+ if (!length) {
385
+ return;
386
+ }
387
+ var attrsArr = data.getAttrsArr(length);
388
+ for (var i = 0, j = 0; i < length; i += 1, j += 2) {
389
+ var attr2 = attributes2[i];
390
+ var name = attr2.name;
391
+ var value = attr2.value;
392
+ attrsArr[j] = name;
393
+ attrsArr[j + 1] = value;
394
+ }
395
+ }
396
+ /**
397
+ * @license
398
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
399
+ *
400
+ * Licensed under the Apache License, Version 2.0 (the "License");
401
+ * you may not use this file except in compliance with the License.
402
+ * You may obtain a copy of the License at
403
+ *
404
+ * http://www.apache.org/licenses/LICENSE-2.0
405
+ *
406
+ * Unless required by applicable law or agreed to in writing, software
407
+ * distributed under the License is distributed on an "AS-IS" BASIS,
408
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
409
+ * See the License for the specific language governing permissions and
410
+ * limitations under the License.
411
+ */
412
+ function getNamespaceForTag(tag, parent) {
413
+ if (tag === "svg") {
414
+ return "http://www.w3.org/2000/svg";
415
+ }
416
+ if (tag === "math") {
417
+ return "http://www.w3.org/1998/Math/MathML";
418
+ }
419
+ if (parent == null) {
420
+ return null;
421
+ }
422
+ if (getData(parent).nameOrCtor === "foreignObject") {
423
+ return null;
424
+ }
425
+ return parent.namespaceURI;
426
+ }
427
+ function createElement(doc2, parent, nameOrCtor, key2) {
428
+ var el;
429
+ if (typeof nameOrCtor === "function") {
430
+ el = new nameOrCtor();
431
+ } else {
432
+ var namespace = getNamespaceForTag(nameOrCtor, parent);
433
+ if (namespace) {
434
+ el = doc2.createElementNS(namespace, nameOrCtor);
435
+ } else {
436
+ el = doc2.createElement(nameOrCtor);
437
+ }
438
+ }
439
+ initData(el, nameOrCtor, key2);
440
+ return el;
441
+ }
442
+ function createText(doc2) {
443
+ var node = doc2.createTextNode("");
444
+ initData(node, "#text", null);
445
+ return node;
446
+ }
447
+ /**
448
+ * @license
449
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
450
+ *
451
+ * Licensed under the Apache License, Version 2.0 (the "License");
452
+ * you may not use this file except in compliance with the License.
453
+ * You may obtain a copy of the License at
454
+ *
455
+ * http://www.apache.org/licenses/LICENSE-2.0
456
+ *
457
+ * Unless required by applicable law or agreed to in writing, software
458
+ * distributed under the License is distributed on an "AS-IS" BASIS,
459
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
460
+ * See the License for the specific language governing permissions and
461
+ * limitations under the License.
462
+ */
463
+ var context = null;
464
+ var currentNode = null;
465
+ var currentParent = null;
466
+ var doc = null;
467
+ var focusPath = [];
468
+ var argsBuilder = [];
469
+ function getArgsBuilder() {
470
+ return argsBuilder;
471
+ }
472
+ function patchFactory(run) {
473
+ var f = function(node, fn, data) {
474
+ var prevContext = context;
475
+ var prevDoc = doc;
476
+ var prevFocusPath = focusPath;
477
+ var prevArgsBuilder = argsBuilder;
478
+ var prevCurrentNode = currentNode;
479
+ var prevCurrentParent = currentParent;
480
+ var previousInAttributes = false;
481
+ context = new Context();
482
+ doc = node.ownerDocument;
483
+ argsBuilder = [];
484
+ currentParent = node.parentNode;
485
+ focusPath = getFocusedPath(node, currentParent);
486
+ try {
487
+ var retVal = run(node, fn, data);
488
+ if (false)
489
+ ;
490
+ return retVal;
491
+ } finally {
492
+ doc = prevDoc;
493
+ argsBuilder = prevArgsBuilder;
494
+ currentNode = prevCurrentNode;
495
+ currentParent = prevCurrentParent;
496
+ focusPath = prevFocusPath;
497
+ context.notifyChanges();
498
+ setInAttributes(previousInAttributes);
499
+ context = prevContext;
500
+ }
501
+ };
502
+ return f;
503
+ }
504
+ var patchInner = patchFactory(function(node, fn, data) {
505
+ currentNode = node;
506
+ enterNode();
507
+ fn(data);
508
+ exitNode();
509
+ if (false)
510
+ ;
511
+ return node;
512
+ });
513
+ var patchOuter = patchFactory(function(node, fn, data) {
514
+ var startNode = { nextSibling: node };
515
+ var expectedNextNode = null;
516
+ var expectedPrevNode = null;
517
+ if (false)
518
+ ;
519
+ currentNode = startNode;
520
+ fn(data);
521
+ if (false)
522
+ ;
523
+ if (currentParent) {
524
+ clearUnvisitedDOM(currentParent, getNextNode(), node.nextSibling);
525
+ }
526
+ return startNode === currentNode ? null : currentNode;
527
+ });
528
+ function matches(matchNode, nameOrCtor, key2) {
529
+ var data = getData(matchNode, key2);
530
+ return nameOrCtor == data.nameOrCtor && key2 == data.key;
531
+ }
532
+ function getMatchingNode(matchNode, nameOrCtor, key2) {
533
+ if (!matchNode) {
534
+ return null;
535
+ }
536
+ if (matches(matchNode, nameOrCtor, key2)) {
537
+ return matchNode;
538
+ }
539
+ if (key2) {
540
+ while (matchNode = matchNode.nextSibling) {
541
+ if (matches(matchNode, nameOrCtor, key2)) {
542
+ return matchNode;
543
+ }
544
+ }
545
+ }
546
+ return null;
547
+ }
548
+ function createNode(nameOrCtor, key2) {
549
+ var node;
550
+ if (nameOrCtor === "#text") {
551
+ node = createText(doc);
552
+ } else {
553
+ node = createElement(doc, currentParent, nameOrCtor, key2);
554
+ }
555
+ context.markCreated(node);
556
+ return node;
557
+ }
558
+ function alignWithDOM(nameOrCtor, key2) {
559
+ var existingNode = getMatchingNode(currentNode, nameOrCtor, key2);
560
+ var node = existingNode || createNode(nameOrCtor, key2);
561
+ if (node === currentNode) {
562
+ return;
563
+ }
564
+ if (focusPath.indexOf(node) >= 0) {
565
+ moveBefore(currentParent, node, currentNode);
566
+ } else {
567
+ currentParent.insertBefore(node, currentNode);
568
+ }
569
+ currentNode = node;
570
+ }
571
+ function clearUnvisitedDOM(maybeParentNode, startNode, endNode) {
572
+ var parentNode = maybeParentNode;
573
+ var child = startNode;
574
+ while (child !== endNode) {
575
+ var next = child.nextSibling;
576
+ parentNode.removeChild(child);
577
+ context.markDeleted(child);
578
+ child = next;
579
+ }
580
+ }
581
+ function enterNode() {
582
+ currentParent = currentNode;
583
+ currentNode = null;
584
+ }
585
+ function getNextNode() {
586
+ if (currentNode) {
587
+ return currentNode.nextSibling;
588
+ } else {
589
+ return currentParent.firstChild;
590
+ }
591
+ }
592
+ function nextNode() {
593
+ currentNode = getNextNode();
594
+ }
595
+ function exitNode() {
596
+ clearUnvisitedDOM(currentParent, getNextNode(), null);
597
+ currentNode = currentParent;
598
+ currentParent = currentParent.parentNode;
599
+ }
600
+ function open(nameOrCtor, key2) {
601
+ nextNode();
602
+ alignWithDOM(nameOrCtor, key2);
603
+ enterNode();
604
+ return currentParent;
605
+ }
606
+ function close() {
607
+ exitNode();
608
+ return currentNode;
609
+ }
610
+ function text() {
611
+ nextNode();
612
+ alignWithDOM("#text", null);
613
+ return currentNode;
614
+ }
615
+ function currentElement() {
616
+ return currentParent;
617
+ }
618
+ function currentPointer() {
619
+ return getNextNode();
620
+ }
621
+ function skip() {
622
+ currentNode = currentParent.lastChild;
623
+ }
624
+ /**
625
+ * @license
626
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
627
+ *
628
+ * Licensed under the Apache License, Version 2.0 (the "License");
629
+ * you may not use this file except in compliance with the License.
630
+ * You may obtain a copy of the License at
631
+ *
632
+ * http://www.apache.org/licenses/LICENSE-2.0
633
+ *
634
+ * Unless required by applicable law or agreed to in writing, software
635
+ * distributed under the License is distributed on an "AS-IS" BASIS,
636
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
637
+ * See the License for the specific language governing permissions and
638
+ * limitations under the License.
639
+ */
640
+ var ATTRIBUTES_OFFSET = 3;
641
+ var prevAttrsMap = createMap();
642
+ function applyStatics(node, data, statics) {
643
+ data.staticsApplied = true;
644
+ if (!statics || !statics.length) {
645
+ return;
646
+ }
647
+ if (data.hasEmptyAttrsArr()) {
648
+ for (var i = 0; i < statics.length; i += 2) {
649
+ updateAttribute(node, statics[i], statics[i + 1]);
650
+ }
651
+ return;
652
+ }
653
+ for (var i = 0; i < statics.length; i += 2) {
654
+ prevAttrsMap[statics[i]] = i + 1;
655
+ }
656
+ var attrsArr = data.getAttrsArr(0);
657
+ var j = 0;
658
+ for (var i = 0; i < attrsArr.length; i += 2) {
659
+ var name = attrsArr[i];
660
+ var value = attrsArr[i + 1];
661
+ var staticsIndex = prevAttrsMap[name];
662
+ if (staticsIndex) {
663
+ if (statics[staticsIndex] === value) {
664
+ delete prevAttrsMap[name];
665
+ }
666
+ continue;
667
+ }
668
+ attrsArr[j] = name;
669
+ attrsArr[j + 1] = value;
670
+ j += 2;
671
+ }
672
+ truncateArray(attrsArr, j);
673
+ for (var name in prevAttrsMap) {
674
+ updateAttribute(node, name, statics[prevAttrsMap[name]]);
675
+ delete prevAttrsMap[name];
676
+ }
677
+ }
678
+ function elementOpen(nameOrCtor, key2, statics) {
679
+ var varArgs = [];
680
+ for (var _i = 3; _i < arguments.length; _i++) {
681
+ varArgs[_i - 3] = arguments[_i];
682
+ }
683
+ var node = open(nameOrCtor, key2);
684
+ var data = getData(node);
685
+ if (!data.staticsApplied) {
686
+ applyStatics(node, data, statics);
687
+ }
688
+ var attrsLength = Math.max(0, arguments.length - ATTRIBUTES_OFFSET);
689
+ var hadNoAttrs = data.hasEmptyAttrsArr();
690
+ if (!attrsLength && hadNoAttrs) {
691
+ return node;
692
+ }
693
+ var attrsArr = data.getAttrsArr(attrsLength);
694
+ var i = ATTRIBUTES_OFFSET;
695
+ var j = 0;
696
+ for (; i < arguments.length; i += 2, j += 2) {
697
+ var name = arguments[i];
698
+ if (hadNoAttrs) {
699
+ attrsArr[j] = name;
700
+ } else if (attrsArr[j] !== name) {
701
+ break;
702
+ }
703
+ var value = arguments[i + 1];
704
+ if (hadNoAttrs || attrsArr[j + 1] !== value) {
705
+ attrsArr[j + 1] = value;
706
+ updateAttribute(node, name, value);
707
+ }
708
+ }
709
+ if (i < arguments.length || j < attrsArr.length) {
710
+ var attrsStart = j;
711
+ for (; j < attrsArr.length; j += 2) {
712
+ prevAttrsMap[attrsArr[j]] = attrsArr[j + 1];
713
+ }
714
+ for (j = attrsStart; i < arguments.length; i += 2, j += 2) {
715
+ var name = arguments[i];
716
+ var value = arguments[i + 1];
717
+ if (prevAttrsMap[name] !== value) {
718
+ updateAttribute(node, name, value);
719
+ }
720
+ attrsArr[j] = name;
721
+ attrsArr[j + 1] = value;
722
+ delete prevAttrsMap[name];
723
+ }
724
+ truncateArray(attrsArr, j);
725
+ for (var name in prevAttrsMap) {
726
+ updateAttribute(node, name, void 0);
727
+ delete prevAttrsMap[name];
728
+ }
729
+ }
730
+ return node;
731
+ }
732
+ function elementOpenStart(nameOrCtor, key2, statics) {
733
+ var argsBuilder2 = getArgsBuilder();
734
+ argsBuilder2[0] = nameOrCtor;
735
+ argsBuilder2[1] = key2;
736
+ argsBuilder2[2] = statics;
737
+ }
738
+ function key(key2) {
739
+ var argsBuilder2 = getArgsBuilder();
740
+ argsBuilder2[1] = key2;
741
+ }
742
+ function attr(name, value) {
743
+ var argsBuilder2 = getArgsBuilder();
744
+ argsBuilder2.push(name);
745
+ argsBuilder2.push(value);
746
+ }
747
+ function elementOpenEnd() {
748
+ var argsBuilder2 = getArgsBuilder();
749
+ var node = elementOpen.apply(null, argsBuilder2);
750
+ truncateArray(argsBuilder2, 0);
751
+ return node;
752
+ }
753
+ function elementClose(nameOrCtor) {
754
+ var node = close();
755
+ return node;
756
+ }
757
+ function elementVoid(nameOrCtor, key2, statics) {
758
+ var varArgs = [];
759
+ for (var _i = 3; _i < arguments.length; _i++) {
760
+ varArgs[_i - 3] = arguments[_i];
761
+ }
762
+ elementOpen.apply(null, arguments);
763
+ return elementClose();
764
+ }
765
+ function text$1(value) {
766
+ var varArgs = [];
767
+ for (var _i = 1; _i < arguments.length; _i++) {
768
+ varArgs[_i - 1] = arguments[_i];
769
+ }
770
+ var node = text();
771
+ var data = getData(node);
772
+ if (data.text !== value) {
773
+ data.text = value;
774
+ var formatted = value;
775
+ for (var i = 1; i < arguments.length; i += 1) {
776
+ var fn = arguments[i];
777
+ formatted = fn(formatted);
778
+ }
779
+ node.data = formatted;
780
+ }
781
+ return node;
782
+ }
783
+ /**
784
+ * @license
785
+ * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.
786
+ *
787
+ * Licensed under the Apache License, Version 2.0 (the "License");
788
+ * you may not use this file except in compliance with the License.
789
+ * You may obtain a copy of the License at
790
+ *
791
+ * http://www.apache.org/licenses/LICENSE-2.0
792
+ *
793
+ * Unless required by applicable law or agreed to in writing, software
794
+ * distributed under the License is distributed on an "AS-IS" BASIS,
795
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
796
+ * See the License for the specific language governing permissions and
797
+ * limitations under the License.
798
+ */
799
+ incrementalDomCjs.applyAttr = applyAttr;
800
+ incrementalDomCjs.applyProp = applyProp;
801
+ incrementalDomCjs.attributes = attributes;
802
+ incrementalDomCjs.close = close;
803
+ var currentElement_1 = incrementalDomCjs.currentElement = currentElement;
804
+ var currentPointer_1 = incrementalDomCjs.currentPointer = currentPointer;
805
+ incrementalDomCjs.open = open;
806
+ var patch = incrementalDomCjs.patch = patchInner;
807
+ incrementalDomCjs.patchInner = patchInner;
808
+ incrementalDomCjs.patchOuter = patchOuter;
809
+ incrementalDomCjs.skip = skip;
810
+ var skipNode = incrementalDomCjs.skipNode = nextNode;
811
+ incrementalDomCjs.getKey = getKey;
812
+ incrementalDomCjs.clearCache = clearCache;
813
+ incrementalDomCjs.importNode = importNode;
814
+ incrementalDomCjs.isDataInitialized = isDataInitialized;
815
+ incrementalDomCjs.notifications = notifications;
816
+ incrementalDomCjs.symbols = symbols;
817
+ var attr_1 = incrementalDomCjs.attr = attr;
818
+ var elementClose_1 = incrementalDomCjs.elementClose = elementClose;
819
+ incrementalDomCjs.elementOpen = elementOpen;
820
+ var elementOpenEnd_1 = incrementalDomCjs.elementOpenEnd = elementOpenEnd;
821
+ var elementOpenStart_1 = incrementalDomCjs.elementOpenStart = elementOpenStart;
822
+ incrementalDomCjs.elementVoid = elementVoid;
823
+ var text_1 = incrementalDomCjs.text = text$1;
824
+ incrementalDomCjs.key = key;
825
+ function comment(content) {
826
+ let node = currentPointer_1();
827
+ if (node instanceof Comment && node.data !== content) {
828
+ node.data = content;
829
+ } else {
830
+ node = document.createComment(content);
831
+ currentElement_1().appendChild(node);
832
+ }
833
+ skipNode();
834
+ return node;
835
+ }
836
+ let theI18n = noI18nI18n;
837
+ function webComponentsUseI18n(i18n) {
838
+ theI18n = i18n;
839
+ }
840
+ function getI18n() {
841
+ return theI18n;
842
+ }
843
+ const SYMBOL_COMPONENT_META = Symbol("ComponentMetadata");
844
+ const Metadata = Object.freeze({
845
+ has(target, key2) {
846
+ return Boolean(target[SYMBOL_COMPONENT_META] && Object.prototype.hasOwnProperty.call(target[SYMBOL_COMPONENT_META], key2));
847
+ },
848
+ add(target, metadata) {
849
+ if (target[SYMBOL_COMPONENT_META]) {
850
+ Object.assign(target[SYMBOL_COMPONENT_META], metadata);
851
+ } else {
852
+ target[SYMBOL_COMPONENT_META] = metadata;
853
+ }
854
+ },
855
+ get(target, key2, defaultValue) {
856
+ return target[SYMBOL_COMPONENT_META] ? target[SYMBOL_COMPONENT_META][key2] || defaultValue : defaultValue;
857
+ }
858
+ });
859
+ const SYMBOL_LISTENERS_ATTACHED = Symbol("ds-web-components:pragma:listeners-attached");
860
+ const MARK_CONTENT_START = "idom-pragma:content-begin";
861
+ const MARK_CONTENT_END = "idom-pragma:content-end";
862
+ function handleChildren(children) {
863
+ for (const child of children) {
864
+ if (typeof child === "function") {
865
+ child();
866
+ } else if (typeof child === "string") {
867
+ text_1(child);
868
+ } else if (child instanceof Set) {
869
+ handleChildren(Array.from(child));
870
+ } else if (Array.isArray(child) && child.length > 0) {
871
+ let ptr = currentPointer_1();
872
+ comment(MARK_CONTENT_START);
873
+ if (ptr === null) {
874
+ const ce = currentElement_1();
875
+ for (let i = 0; i < child.length; i += 1) {
876
+ if (!ce.contains(child[i])) {
877
+ ce.appendChild(child[i]);
878
+ }
879
+ skipNode();
880
+ }
881
+ }
882
+ while (ptr && ptr.data !== MARK_CONTENT_END) {
883
+ skipNode();
884
+ ptr = currentPointer_1();
885
+ }
886
+ comment(MARK_CONTENT_END);
887
+ }
888
+ }
889
+ }
890
+ function h(tagName, attrs, ...children) {
891
+ if (attrs) {
892
+ for (const key2 of Object.keys(attrs)) {
893
+ if (key2.toUpperCase() === "DATA-FRAGMENT") {
894
+ return () => handleChildren(children);
895
+ }
896
+ }
897
+ }
898
+ return () => {
899
+ elementOpenStart_1(tagName);
900
+ const eventListenerKeys = [];
901
+ if (attrs) {
902
+ for (const key2 of Object.keys(attrs)) {
903
+ if (key2.toUpperCase() === "CLASSNAME") {
904
+ attr_1("class", attrs[key2]);
905
+ } else if (/^on[A-Z]/.test(key2)) {
906
+ eventListenerKeys.push(key2);
907
+ } else {
908
+ attr_1(key2, attrs[key2]);
909
+ }
910
+ }
911
+ }
912
+ elementOpenEnd_1(tagName);
913
+ const ce = currentElement_1();
914
+ if (!ce[SYMBOL_LISTENERS_ATTACHED]) {
915
+ for (const key2 of eventListenerKeys) {
916
+ ce.addEventListener(key2.substr(2).toLowerCase(), attrs[key2]);
917
+ }
918
+ ce[SYMBOL_LISTENERS_ATTACHED] = true;
919
+ }
920
+ handleChildren(children);
921
+ elementClose_1(tagName);
922
+ };
923
+ }
924
+ function ensureDefined(tag, Component2) {
925
+ if (!customElements.get(tag)) {
926
+ customElements.define(tag, Component2);
927
+ }
928
+ }
929
+ function register(...Components) {
930
+ for (const Component2 of Components) {
931
+ ensureDefined(Metadata.get(Component2, "tag"), Component2);
932
+ }
933
+ }
934
+ function namespaceOverrideRegistrar(overrideNamespace) {
935
+ return function register2(...Components) {
936
+ for (const Component2 of Components) {
937
+ const tag = `${overrideNamespace}${Metadata.get(Component2, "tag").substr(3)}`;
938
+ ensureDefined(tag, Component2);
939
+ }
940
+ };
941
+ }
942
+ const AttrBindings = Symbol("Component Attribute Bindings");
943
+ const ClassBindings = Symbol("Component Class Bindings");
944
+ const StyleBindings = Symbol("Component Style Bindings");
945
+ const ext = {
946
+ __initialized: false,
947
+ __observer: null,
948
+ __queuedUpdate: null,
949
+ __managedClasses: new Set(),
950
+ __updateHostBindings() {
951
+ const self = this;
952
+ for (const attrName of Object.keys(self[AttrBindings] || {})) {
953
+ self.setAttribute(attrName, self[AttrBindings][attrName]);
954
+ }
955
+ for (const styleKey of Object.keys(self[StyleBindings] || {})) {
956
+ self.style[styleKey] = self[StyleBindings][styleKey];
957
+ }
958
+ for (const className of self.__managedClasses) {
959
+ self.classList.remove(className);
960
+ }
961
+ for (const className of (self[ClassBindings] || []).filter(Boolean)) {
962
+ self.__managedClasses.add(className);
963
+ self.classList.add(className);
964
+ }
965
+ for (const className of (self.getAttribute("classname") || "").split(/\w+/).filter(Boolean)) {
966
+ self.classList.add(className);
967
+ }
968
+ },
969
+ __updateChildQueries(adhereToRefreshOption) {
970
+ const self = this;
971
+ for (const childQuery of Metadata.get(self.constructor, "childQueries", [])) {
972
+ if (!adhereToRefreshOption || adhereToRefreshOption && childQuery.refresh) {
973
+ const queryMethod = childQuery.all ? self.querySelectorAll : self.querySelector;
974
+ self[childQuery.key] = queryMethod.call(self, childQuery.selector);
975
+ }
976
+ }
977
+ },
978
+ __gatherChildren() {
979
+ const self = this;
980
+ let childNodes = Array.from(self.childNodes);
981
+ let contentStartIndex = null;
982
+ let contentEndIndex = childNodes.length;
983
+ for (let i = 0; i < childNodes.length; i += 1) {
984
+ const node = childNodes[i];
985
+ if (node instanceof Comment) {
986
+ if (node.data === MARK_CONTENT_START) {
987
+ contentStartIndex = i + 1;
988
+ } else if (node.data === MARK_CONTENT_END) {
989
+ contentEndIndex = i - 1;
990
+ }
991
+ }
992
+ }
993
+ if (contentStartIndex === null) {
994
+ for (const node of childNodes) {
995
+ node.parentNode.removeChild(node);
996
+ }
997
+ } else {
998
+ childNodes = childNodes.slice(contentStartIndex, contentEndIndex);
999
+ }
1000
+ if (Metadata.has(self.constructor, "contentProp")) {
1001
+ self[Metadata.get(self.constructor, "contentProp")] = childNodes;
1002
+ }
1003
+ },
1004
+ __startMutObs() {
1005
+ const self = this;
1006
+ if (!self.__observer) {
1007
+ self.__observer = new MutationObserver(() => {
1008
+ if (self.contentChangedCallback) {
1009
+ self.contentChangedCallback();
1010
+ }
1011
+ self.__gatherChildren();
1012
+ self.update();
1013
+ });
1014
+ }
1015
+ self.__observer.observe(self, { childList: true });
1016
+ },
1017
+ __stopMutObs() {
1018
+ const self = this;
1019
+ if (self.__observer) {
1020
+ self.__observer.disconnect();
1021
+ }
1022
+ },
1023
+ __doRender() {
1024
+ const self = this;
1025
+ self.__stopMutObs();
1026
+ patch(self, self.render(getI18n()));
1027
+ self.__startMutObs();
1028
+ },
1029
+ update() {
1030
+ const self = this;
1031
+ if (self.__initialized && !self.__queuedUpdate) {
1032
+ self.__queuedUpdate = window.requestAnimationFrame(() => {
1033
+ self.__doRender();
1034
+ setTimeout(() => {
1035
+ self.__updateChildQueries(true);
1036
+ self.__updateHostBindings();
1037
+ }, 0);
1038
+ self.__queuedUpdate = null;
1039
+ });
1040
+ }
1041
+ },
1042
+ attributeChangedCallback(key2, oldValue, newValue) {
1043
+ const self = this;
1044
+ const value = newValue === "" ? true : newValue;
1045
+ if (value !== oldValue) {
1046
+ if (self.__cbAttributeChanged) {
1047
+ self.__cbAttributeChanged(key2, self[key2], value);
1048
+ }
1049
+ if (key2 !== "style") {
1050
+ self[key2] = value;
1051
+ }
1052
+ if (self.__initialized) {
1053
+ self.update();
1054
+ }
1055
+ }
1056
+ },
1057
+ connectedCallback() {
1058
+ const self = this;
1059
+ if (self.__cbConnected) {
1060
+ self.__cbConnected();
1061
+ }
1062
+ const listeners = Metadata.get(self.constructor, "eventListeners", []);
1063
+ setTimeout(() => {
1064
+ if (!self.__initialized) {
1065
+ self.__gatherChildren();
1066
+ for (const [, key2] of listeners) {
1067
+ self[key2] = self[key2].bind(self);
1068
+ }
1069
+ self.__initialized = true;
1070
+ }
1071
+ for (const [eventName, key2] of listeners) {
1072
+ self.addEventListener(eventName, self[key2]);
1073
+ }
1074
+ self.__doRender();
1075
+ setTimeout(() => {
1076
+ self.__updateChildQueries();
1077
+ self.__updateHostBindings();
1078
+ }, 0);
1079
+ }, 0);
1080
+ },
1081
+ disconnectedCallback() {
1082
+ const self = this;
1083
+ if (self.__cbDisconnected) {
1084
+ self.__cbDisconnected();
1085
+ }
1086
+ for (const [eventName, key2] of Metadata.get(self.constructor, "eventListeners", [])) {
1087
+ self.removeEventListener(eventName, self[key2]);
1088
+ }
1089
+ self.__stopMutObs();
1090
+ }
1091
+ };
1092
+ function Component(config) {
1093
+ return (target) => {
1094
+ Metadata.add(target, config);
1095
+ Object.assign(target.prototype, {
1096
+ __cbAttributeChanged: target.prototype.attributeChangedCallback,
1097
+ __cbConnected: target.prototype.connectedCallback,
1098
+ __cbDisconnected: target.prototype.disconnectedCallback
1099
+ }, ext);
1100
+ };
1101
+ }
1102
+ function Content() {
1103
+ return (target, key2) => {
1104
+ Metadata.add(target.constructor, { contentProp: key2 });
1105
+ };
1106
+ }
1107
+ function EventDispatcher(eventName) {
1108
+ return (target, key2) => {
1109
+ Object.defineProperty(target, key2, {
1110
+ get() {
1111
+ Object.defineProperty(this, key2, {
1112
+ value: {
1113
+ dispatch: (detail) => {
1114
+ const event = new CustomEvent(eventName || key2, { detail });
1115
+ this.dispatchEvent(event);
1116
+ return event;
1117
+ }
1118
+ }
1119
+ });
1120
+ return this[key2];
1121
+ },
1122
+ configurable: true
1123
+ });
1124
+ };
1125
+ }
1126
+ function EventListener(eventName) {
1127
+ return (target, key2) => {
1128
+ const eventListeners = Metadata.get(target.constructor, "eventListeners", []);
1129
+ eventListeners.push([eventName, key2]);
1130
+ Metadata.add(target.constructor, { eventListeners });
1131
+ };
1132
+ }
1133
+ function Prop(castToType) {
1134
+ return (target, key2) => {
1135
+ const c = target.constructor;
1136
+ const keyLowercase = key2.toLowerCase();
1137
+ c.observedAttributes = c.observedAttributes || [
1138
+ "classname",
1139
+ "className",
1140
+ "style"
1141
+ ];
1142
+ c.observedAttributes.push(key2);
1143
+ c.observedAttributes.push(keyLowercase);
1144
+ if (keyLowercase !== key2) {
1145
+ Object.defineProperty(target, key2, {
1146
+ get() {
1147
+ return this[keyLowercase];
1148
+ },
1149
+ set(newValue) {
1150
+ this[keyLowercase] = newValue;
1151
+ }
1152
+ });
1153
+ }
1154
+ if (castToType) {
1155
+ const privateKey = Symbol.for(key2);
1156
+ Object.defineProperty(target, keyLowercase, {
1157
+ get() {
1158
+ return this[privateKey];
1159
+ },
1160
+ set(newValue) {
1161
+ let castValue = newValue;
1162
+ if (castToType === Boolean && typeof newValue === "string" && newValue.toLowerCase() === "false") {
1163
+ castValue = false;
1164
+ } else {
1165
+ castValue = castToType(newValue);
1166
+ }
1167
+ this[privateKey] = castValue;
1168
+ }
1169
+ });
1170
+ }
1171
+ };
1172
+ }
1173
+ function querySelectorDecorator(selector, options, all) {
1174
+ return (target, key2) => {
1175
+ const childQueries = Metadata.get(target.constructor, "childQueries", []);
1176
+ childQueries.push({
1177
+ key: key2,
1178
+ selector,
1179
+ all,
1180
+ refresh: options.refresh
1181
+ });
1182
+ Metadata.add(target.constructor, { childQueries });
1183
+ };
1184
+ }
1185
+ function QuerySelector(selector, options = {}) {
1186
+ return querySelectorDecorator(selector, options);
1187
+ }
1188
+ function QuerySelectorAll(selector, options = {}) {
1189
+ return querySelectorDecorator(selector, options, true);
1190
+ }
1191
+ function Watch() {
1192
+ return (target, key2) => {
1193
+ const privateKey = Symbol(key2);
1194
+ Object.defineProperties(target, {
1195
+ [privateKey]: {
1196
+ writable: true,
1197
+ enumerable: false,
1198
+ configurable: false,
1199
+ value: target[key2]
1200
+ },
1201
+ [key2]: {
1202
+ get() {
1203
+ return this[privateKey];
1204
+ },
1205
+ set(newValue) {
1206
+ if (this[privateKey] !== newValue) {
1207
+ this[privateKey] = newValue;
1208
+ this.update();
1209
+ }
1210
+ }
1211
+ }
1212
+ });
1213
+ };
1214
+ }
1215
+ var MIMEType;
1216
+ (function(MIMEType2) {
1217
+ MIMEType2["7Z"] = "application/x-7z-compressed";
1218
+ MIMEType2["AAC"] = "audio/aac";
1219
+ MIMEType2["ABW"] = "application/x-abiword";
1220
+ MIMEType2["ARC"] = "application/octet-stream";
1221
+ MIMEType2["AVI"] = "video/x-msvideo";
1222
+ MIMEType2["AZW"] = "application/vnd.amazon.ebook";
1223
+ MIMEType2["BIN"] = "application/octet-stream";
1224
+ MIMEType2["BMP"] = "image/bmp";
1225
+ MIMEType2["BZ"] = "application/x-bzip";
1226
+ MIMEType2["BZ2"] = "application/x-bzip2";
1227
+ MIMEType2["CSH"] = "application/x-csh";
1228
+ MIMEType2["CSS"] = "text/css";
1229
+ MIMEType2["CSV"] = "text/csv,application/vnd.ms-excel";
1230
+ MIMEType2["DOC"] = "application/msword";
1231
+ MIMEType2["DOCX"] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
1232
+ MIMEType2["EOT"] = "application/vnd.ms-fontobject";
1233
+ MIMEType2["EPUB"] = "application/epub+zip";
1234
+ MIMEType2["ES"] = "application/ecmascript";
1235
+ MIMEType2["FLV"] = "video/x-flv";
1236
+ MIMEType2["GIF"] = "image/gif";
1237
+ MIMEType2["GZ"] = "application/x-gzip";
1238
+ MIMEType2["HTM"] = "text/html";
1239
+ MIMEType2["HTML"] = "text/html";
1240
+ MIMEType2["ICO"] = "image/x-icon";
1241
+ MIMEType2["ICS"] = "text/calendar";
1242
+ MIMEType2["JAR"] = "application/java-archive";
1243
+ MIMEType2["JPEG"] = "image/jpeg";
1244
+ MIMEType2["JPG"] = "image/jpeg";
1245
+ MIMEType2["JS"] = "application/javascript";
1246
+ MIMEType2["JSON"] = "application/json";
1247
+ MIMEType2["M3U"] = "audio/x-mpequrl";
1248
+ MIMEType2["MID"] = "audio/midi";
1249
+ MIMEType2["MIDI"] = "audio/midi";
1250
+ MIMEType2["MOV"] = "video/quicktime";
1251
+ MIMEType2["MP3"] = "audio/mpeg3";
1252
+ MIMEType2["MP4"] = "video/mp4";
1253
+ MIMEType2["MPEG"] = "video/mpeg";
1254
+ MIMEType2["MPKG"] = "application/vnd.apple.installer+xml";
1255
+ MIMEType2["ODP"] = "application/vnd.oasis.opendocument.presentation";
1256
+ MIMEType2["ODS"] = "application/vnd.oasis.opendocument.spreadsheet";
1257
+ MIMEType2["ODT"] = "application/vnd.oasis.opendocument.text";
1258
+ MIMEType2["OGA"] = "audio/ogg";
1259
+ MIMEType2["OGV"] = "video/ogg";
1260
+ MIMEType2["OGX"] = "application/ogg";
1261
+ MIMEType2["OTF"] = "font/otf";
1262
+ MIMEType2["PNG"] = "image/png";
1263
+ MIMEType2["PDF"] = "application/pdf";
1264
+ MIMEType2["PPT"] = "application/vnd.ms-powerpoint";
1265
+ MIMEType2["PPTX"] = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
1266
+ MIMEType2["RAR"] = "application/x-rar-compressed";
1267
+ MIMEType2["RTF"] = "application/rtf";
1268
+ MIMEType2["SH"] = "application/x-sh";
1269
+ MIMEType2["SVG"] = "image/svg+xml";
1270
+ MIMEType2["SWF"] = "application/x-shockwave-flash";
1271
+ MIMEType2["TAR"] = "application/x-tar";
1272
+ MIMEType2["TIF"] = "image/tiff";
1273
+ MIMEType2["TIFF"] = "image/tiff";
1274
+ MIMEType2["TS"] = "application/typescript";
1275
+ MIMEType2["TTF"] = "font/ttf";
1276
+ MIMEType2["TXT"] = "text/plain";
1277
+ MIMEType2["VSD"] = "application/vnd.visio";
1278
+ MIMEType2["WAV"] = "audio/wav";
1279
+ MIMEType2["WEBA"] = "audio/webm";
1280
+ MIMEType2["WEBM"] = "video/webm";
1281
+ MIMEType2["WEBP"] = "image/webp";
1282
+ MIMEType2["WOFF"] = "font/woff";
1283
+ MIMEType2["WOFF2"] = "font/woff2";
1284
+ MIMEType2["XHTML"] = "application/xhtml+xml";
1285
+ MIMEType2["XLS"] = "application/vnd.ms-excel";
1286
+ MIMEType2["XLSX"] = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
1287
+ MIMEType2["XML"] = "application/xml";
1288
+ MIMEType2["XUL"] = "application/vnd.mozilla.xul+xml";
1289
+ MIMEType2["ZIP"] = "application/zip";
1290
+ })(MIMEType || (MIMEType = {}));
1291
+ var __defProp$5 = Object.defineProperty;
1292
+ var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
1293
+ var __decorateClass$5 = (decorators, target, key2, kind) => {
1294
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key2) : target;
1295
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1296
+ if (decorator = decorators[i])
1297
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
1298
+ if (kind && result)
1299
+ __defProp$5(target, key2, result);
1300
+ return result;
1301
+ };
1302
+ const CPT_NAME$3 = "sps-file-upload";
1303
+ let SpsFileUploadComponent = class extends HTMLElement {
1304
+ constructor() {
1305
+ super();
1306
+ this.shown = true;
1307
+ this.files = [];
1308
+ this.acceptMIMETypes = new Set();
1309
+ this.active = false;
1310
+ this.error = false;
1311
+ this.namesOfUnsupportedFiles = [];
1312
+ this.handleBrowseLinkClick = this.handleBrowseLinkClick.bind(this);
1313
+ this.handleDownloadButtonClick = this.handleDownloadButtonClick.bind(this);
1314
+ this.handleFileInputChange = this.handleFileInputChange.bind(this);
1315
+ this.dismiss = this.dismiss.bind(this);
1316
+ }
1317
+ get [ClassBindings]() {
1318
+ return [
1319
+ CPT_NAME$3,
1320
+ this.active && `${CPT_NAME$3}--active`,
1321
+ this.error && `${CPT_NAME$3}--error`,
1322
+ !this.shown && `${CPT_NAME$3}--hidden`,
1323
+ this.mini && `${CPT_NAME$3}--mini`,
1324
+ this.constrainContentWidth && `${CPT_NAME$3}--constrained-content-width`
1325
+ ];
1326
+ }
1327
+ connectedCallback() {
1328
+ this.description = this.description || (this.multiple ? "Files" : "File");
1329
+ if (this.acceptExtensions) {
1330
+ this.processAcceptExtensions(this.acceptExtensions);
1331
+ }
1332
+ if (this.maxSize) {
1333
+ this.parseAndValidateMaxSize(this.maxSize);
1334
+ }
1335
+ }
1336
+ attributeChangedCallback(attrName, oldValue, newValue) {
1337
+ if (attrName === "acceptExtensions") {
1338
+ this.processAcceptExtensions(newValue);
1339
+ }
1340
+ if (attrName === "maxSize") {
1341
+ this.parseAndValidateMaxSize(newValue);
1342
+ }
1343
+ }
1344
+ dismiss() {
1345
+ if (this.dismissable) {
1346
+ this.shown = false;
1347
+ this.update();
1348
+ this.dismissal.dispatch();
1349
+ }
1350
+ }
1351
+ show() {
1352
+ if (this.dismissable) {
1353
+ this.shown = true;
1354
+ this.update();
1355
+ }
1356
+ }
1357
+ render({ t }) {
1358
+ const icon = this.error ? SpsIcon.EXCLAMATION_CIRCLE : SpsIcon.UPLOAD_CLOUD;
1359
+ const instructions = (this.multiple ? t("design-system:fileUpload.instructions_plural") : t("design-system:fileUpload.instructions")).split("|");
1360
+ return /* @__PURE__ */ h("div", {
1361
+ "data-fragment": true
1362
+ }, /* @__PURE__ */ h("div", {
1363
+ className: `${CPT_NAME$3}__content`
1364
+ }, this.processing ? /* @__PURE__ */ h("div", {
1365
+ "data-fragment": true
1366
+ }, /* @__PURE__ */ h("i", {
1367
+ className: "sps-spinner sps-spinner--medium",
1368
+ "aria-hidden": "true"
1369
+ }), /* @__PURE__ */ h("div", {
1370
+ className: `${CPT_NAME$3}__instructions`
1371
+ }, t("design-system:fileUpload.processing"))) : /* @__PURE__ */ h("div", {
1372
+ "data-fragment": true
1373
+ }, /* @__PURE__ */ h("i", {
1374
+ className: `sps-icon sps-icon-${icon} ${CPT_NAME$3}__icon-primary`,
1375
+ "aria-hidden": "true"
1376
+ }), /* @__PURE__ */ h("div", {
1377
+ className: `${CPT_NAME$3}__title`
1378
+ }, this.error ? /* @__PURE__ */ h("div", {
1379
+ "data-fragment": true
1380
+ }, t(this.namesOfUnsupportedFiles.length > 1 ? "design-system:fileUpload.cancelled_plural" : "design-system:fileUpload.cancelled")) : /* @__PURE__ */ h("div", {
1381
+ "data-fragment": true
1382
+ }, t("design-system:fileUpload.title", { description: this.description }))), this.error ? /* @__PURE__ */ h("div", {
1383
+ className: `${CPT_NAME$3}__errored-files`
1384
+ }, new Set(this.namesOfUnsupportedFiles.map((name, i) => {
1385
+ const breakpoint = Math.floor(name.length / 2);
1386
+ return /* @__PURE__ */ h("div", {
1387
+ className: `${CPT_NAME$3}__errored-filename`,
1388
+ key: name
1389
+ }, /* @__PURE__ */ h("span", {
1390
+ className: `${CPT_NAME$3}__errored-filename-segment`
1391
+ }, name.substr(0, breakpoint)), /* @__PURE__ */ h("div", {
1392
+ className: `${CPT_NAME$3}__errored-filename-segment`
1393
+ }, /* @__PURE__ */ h("span", null, name.substr(breakpoint))), i < this.namesOfUnsupportedFiles.length - 1 ? "," : "");
1394
+ }))) : /* @__PURE__ */ h("span", null), /* @__PURE__ */ h("div", {
1395
+ className: `${CPT_NAME$3}__instructions`
1396
+ }, /* @__PURE__ */ h("div", {
1397
+ "data-fragment": true
1398
+ }, /* @__PURE__ */ h("span", null, instructions[0]), /* @__PURE__ */ h("a", {
1399
+ href: "",
1400
+ onClick: this.handleBrowseLinkClick
1401
+ }, instructions[1]), /* @__PURE__ */ h("span", null, instructions[2]))), /* @__PURE__ */ h("div", {
1402
+ className: `${CPT_NAME$3}__requirements`
1403
+ }, this.acceptExtensions ? /* @__PURE__ */ h("span", null, "(", " ", t("design-system:fileUpload.acceptedTypes", { fileTypes: this.acceptExtensionsDescription }), " ", ")") : "", this.maxSize ? /* @__PURE__ */ h("span", null, "(", " ", t("design-system:fileUpload.maximumSize", { size: this.maxSize }), " ", ")") : "", this.customRequirement ? /* @__PURE__ */ h("span", null, " ", this.customRequirement, " ") : ""), this.downloadLabel && /* @__PURE__ */ h("div", {
1404
+ className: `sps-button sps-button--link ${CPT_NAME$3}__download-button`,
1405
+ onClick: this.handleDownloadButtonClick
1406
+ }, /* @__PURE__ */ h("button", {
1407
+ type: "button"
1408
+ }, /* @__PURE__ */ h("i", {
1409
+ className: "sps-icon sps-icon-download-cloud",
1410
+ "aria-hidden": "true"
1411
+ }), " ", this.downloadLabel)))), this.dismissable && !this.processing && /* @__PURE__ */ h("div", {
1412
+ className: `sps-button sps-button--icon ${CPT_NAME$3}__close-button`,
1413
+ onClick: this.dismiss
1414
+ }, /* @__PURE__ */ h("button", {
1415
+ type: "button",
1416
+ title: t("design-system:fileUpload.close")
1417
+ }, /* @__PURE__ */ h("i", {
1418
+ className: "sps-icon sps-icon-x",
1419
+ "aria-hidden": "true"
1420
+ }))), /* @__PURE__ */ h("form", null, /* @__PURE__ */ h("input", {
1421
+ type: "file",
1422
+ accept: this.accept || "*/*",
1423
+ multiple: this.multiple || null,
1424
+ onChange: this.handleFileInputChange
1425
+ })));
1426
+ }
1427
+ parseAndValidateMaxSize(maxSize) {
1428
+ try {
1429
+ this.maxSizeBytes = parseFileSize(maxSize);
1430
+ } catch (error) {
1431
+ throw new Error(`Could not parse "${maxSize}" as a file size.`);
1432
+ }
1433
+ }
1434
+ processAcceptExtensions(acceptExtensions) {
1435
+ const splitExtensions = Array.isArray(acceptExtensions) ? acceptExtensions : acceptExtensions.trim().split(/\s?,\s?/);
1436
+ const trimmedExtensions = splitExtensions.map((ext2) => ext2.replace(/^\./, ""));
1437
+ const extList = trimmedExtensions.map((ext2) => `.${ext2}`.toLowerCase());
1438
+ this.acceptExtensionsDescription = extList.map((ext2, i) => i > 0 && i === extList.length - 1 ? `or ${ext2}` : ext2).join(extList.length > 2 ? ", " : " ");
1439
+ this.acceptMIMETypes.clear();
1440
+ for (const ext2 of trimmedExtensions) {
1441
+ for (const type of MIMEType[ext2.toUpperCase()].split(",")) {
1442
+ this.acceptMIMETypes.add(type);
1443
+ }
1444
+ }
1445
+ this.accept = extList.concat(Array.from(this.acceptMIMETypes)).join(",");
1446
+ }
1447
+ selectFiles(files) {
1448
+ this.namesOfUnsupportedFiles = [];
1449
+ const fileArray = Array.from(files);
1450
+ for (const file of fileArray) {
1451
+ if (this.acceptExtensions && !this.acceptMIMETypes.has(file.type)) {
1452
+ this.namesOfUnsupportedFiles.push(file.name);
1453
+ }
1454
+ if (this.maxSize && file.size > this.maxSizeBytes && this.namesOfUnsupportedFiles.indexOf(file.name) === -1) {
1455
+ this.namesOfUnsupportedFiles.push(file.name);
1456
+ }
1457
+ }
1458
+ if (this.namesOfUnsupportedFiles.length) {
1459
+ this.error = true;
1460
+ this.fileInput.value = null;
1461
+ this.update();
1462
+ } else {
1463
+ this.files = fileArray;
1464
+ this.selection.dispatch(fileArray);
1465
+ }
1466
+ }
1467
+ handleDragOver(event) {
1468
+ event.preventDefault();
1469
+ event.stopPropagation();
1470
+ }
1471
+ handleDragEnter(event) {
1472
+ event.preventDefault();
1473
+ this.active = true;
1474
+ this.error = false;
1475
+ this.update();
1476
+ }
1477
+ handleDragLeave(event) {
1478
+ event.preventDefault();
1479
+ this.active = false;
1480
+ this.update();
1481
+ }
1482
+ handleDrop(event) {
1483
+ event.preventDefault();
1484
+ event.stopPropagation();
1485
+ this.active = false;
1486
+ if (event.dataTransfer.items) {
1487
+ this.selectFiles(Array.from(event.dataTransfer.items).map((item) => item.getAsFile()));
1488
+ } else {
1489
+ this.selectFiles(event.dataTransfer.files);
1490
+ }
1491
+ this.update();
1492
+ }
1493
+ handleBrowseLinkClick(event) {
1494
+ event.preventDefault();
1495
+ this.error = false;
1496
+ this.update();
1497
+ this.fileInput.click();
1498
+ }
1499
+ handleDownloadButtonClick() {
1500
+ this.download.dispatch();
1501
+ }
1502
+ handleFileInputChange(event) {
1503
+ event.stopPropagation();
1504
+ this.selectFiles(event.target.files);
1505
+ }
1506
+ };
1507
+ SpsFileUploadComponent.displayName = CPT_NAME$3;
1508
+ SpsFileUploadComponent.props = {
1509
+ description: "string",
1510
+ multiple: "boolean",
1511
+ dismissable: "boolean",
1512
+ processing: "boolean",
1513
+ mini: "boolean",
1514
+ downloadLabel: "string",
1515
+ acceptExtensions: "Array<string> | string",
1516
+ maxSize: "string",
1517
+ customRequirement: "string",
1518
+ selection: { event: true, type: "CustomEvent<Array<File>>" },
1519
+ dismissal: { event: true, type: "CustomEvent<void>" },
1520
+ download: { event: true, type: "CustomEvent<void>" }
1521
+ };
1522
+ __decorateClass$5([
1523
+ Prop()
1524
+ ], SpsFileUploadComponent.prototype, "description", 2);
1525
+ __decorateClass$5([
1526
+ Prop(Boolean)
1527
+ ], SpsFileUploadComponent.prototype, "multiple", 2);
1528
+ __decorateClass$5([
1529
+ Prop(Boolean)
1530
+ ], SpsFileUploadComponent.prototype, "shown", 2);
1531
+ __decorateClass$5([
1532
+ Prop(Boolean)
1533
+ ], SpsFileUploadComponent.prototype, "dismissable", 2);
1534
+ __decorateClass$5([
1535
+ Prop(Boolean)
1536
+ ], SpsFileUploadComponent.prototype, "processing", 2);
1537
+ __decorateClass$5([
1538
+ Prop(Boolean)
1539
+ ], SpsFileUploadComponent.prototype, "mini", 2);
1540
+ __decorateClass$5([
1541
+ Prop(Boolean)
1542
+ ], SpsFileUploadComponent.prototype, "constrainContentWidth", 2);
1543
+ __decorateClass$5([
1544
+ Prop()
1545
+ ], SpsFileUploadComponent.prototype, "downloadLabel", 2);
1546
+ __decorateClass$5([
1547
+ Prop()
1548
+ ], SpsFileUploadComponent.prototype, "acceptExtensions", 2);
1549
+ __decorateClass$5([
1550
+ Prop()
1551
+ ], SpsFileUploadComponent.prototype, "maxSize", 2);
1552
+ __decorateClass$5([
1553
+ Prop()
1554
+ ], SpsFileUploadComponent.prototype, "customRequirement", 2);
1555
+ __decorateClass$5([
1556
+ EventDispatcher()
1557
+ ], SpsFileUploadComponent.prototype, "selection", 2);
1558
+ __decorateClass$5([
1559
+ EventDispatcher()
1560
+ ], SpsFileUploadComponent.prototype, "dismissal", 2);
1561
+ __decorateClass$5([
1562
+ EventDispatcher()
1563
+ ], SpsFileUploadComponent.prototype, "download", 2);
1564
+ __decorateClass$5([
1565
+ QuerySelector("input[type='file']")
1566
+ ], SpsFileUploadComponent.prototype, "fileInput", 2);
1567
+ __decorateClass$5([
1568
+ EventListener("dragover")
1569
+ ], SpsFileUploadComponent.prototype, "handleDragOver", 1);
1570
+ __decorateClass$5([
1571
+ EventListener("dragenter")
1572
+ ], SpsFileUploadComponent.prototype, "handleDragEnter", 1);
1573
+ __decorateClass$5([
1574
+ EventListener("dragleave")
1575
+ ], SpsFileUploadComponent.prototype, "handleDragLeave", 1);
1576
+ __decorateClass$5([
1577
+ EventListener("drop")
1578
+ ], SpsFileUploadComponent.prototype, "handleDrop", 1);
1579
+ SpsFileUploadComponent = __decorateClass$5([
1580
+ Component({ tag: CPT_NAME$3 })
1581
+ ], SpsFileUploadComponent);
1582
+ const SpsFileUploadExamples = {
1583
+ basic: {
1584
+ label: "Basic File Upload",
1585
+ description: code`
1586
+ <p>Simply allow the user to drag-and-drop or select either a single file or multiple files at once.</p>
1587
+ `,
1588
+ examples: {
1589
+ single: {
1590
+ description: "<p>Single file upload</p>",
1591
+ react: code`
1592
+ function Component() {
1593
+ const ref = React.useRef()
1594
+
1595
+ function handleChange(event) {
1596
+ console.log(event.detail)
1597
+ }
1598
+
1599
+ React.useEffect(() => {
1600
+ ref.current.addEventListener("selection", handleChange)
1601
+ return () => {
1602
+ ref.current.removeEventListener("selection", handleChange)
1603
+ }
1604
+ })
1605
+
1606
+ return (
1607
+ <div className="sps-row">
1608
+ <div className="col-12">
1609
+ <sps-file-upload ref={ref}/>
1610
+ </div>
1611
+ </div>
1612
+ )
1613
+ }
1614
+ `
1615
+ },
1616
+ multiple: {
1617
+ description: "<p>Multiple file upload</p>",
1618
+ react: code`
1619
+ function Component() {
1620
+ const ref = React.useRef()
1621
+
1622
+ function handleChange(event) {
1623
+ console.log(event.detail)
1624
+ }
1625
+
1626
+ React.useEffect(() => {
1627
+ ref.current.addEventListener("selection", handleChange)
1628
+ return () => {
1629
+ ref.current.removeEventListener("selection", handleChange)
1630
+ }
1631
+ })
1632
+
1633
+ return (
1634
+ <div className="sps-row">
1635
+ <div className="col-12">
1636
+ <sps-file-upload ref={ref} multiple/>
1637
+ </div>
1638
+ </div>
1639
+ )
1640
+ }
1641
+ `
1642
+ }
1643
+ }
1644
+ },
1645
+ restrictions: {
1646
+ label: "Restrictions",
1647
+ description: code`
1648
+ <p>You can place restrictions on what files will be accepted with an extension whitelist and/or a maximum size.</p>
1649
+ `,
1650
+ examples: {
1651
+ size: {
1652
+ description: "<p>Maximum size</p>",
1653
+ react: code`
1654
+ function Component() {
1655
+ const ref = React.useRef()
1656
+
1657
+ function handleChange(event) {
1658
+ console.log(event.detail)
1659
+ }
1660
+
1661
+ React.useEffect(() => {
1662
+ ref.current.addEventListener("selection", handleChange)
1663
+ return () => {
1664
+ ref.current.removeEventListener("selection", handleChange)
1665
+ }
1666
+ })
1667
+
1668
+ return (
1669
+ <div className="sps-row">
1670
+ <div className="col-12">
1671
+ <sps-file-upload ref={ref} maxSize="100KB"/>
1672
+ </div>
1673
+ </div>
1674
+ )
1675
+ }
1676
+ `
1677
+ },
1678
+ type: {
1679
+ description: "<p>File type whitelist</p>",
1680
+ react: code`
1681
+ function Component() {
1682
+ const ref = React.useRef()
1683
+
1684
+ function handleChange(event) {
1685
+ console.log(event.detail)
1686
+ }
1687
+
1688
+ React.useEffect(() => {
1689
+ ref.current.addEventListener("selection", handleChange)
1690
+ return () => {
1691
+ ref.current.removeEventListener("selection", handleChange)
1692
+ }
1693
+ })
1694
+
1695
+ return (
1696
+ <div className="sps-row">
1697
+ <div className="col-12">
1698
+ <sps-file-upload
1699
+ ref={ref}
1700
+ description="Spreadsheets"
1701
+ multiple
1702
+ acceptExtensions="XLS, xlsx, .csv"
1703
+ />
1704
+ </div>
1705
+ </div>
1706
+ )
1707
+ }
1708
+ `
1709
+ },
1710
+ both: {
1711
+ description: "<p>Both restrictions</p>",
1712
+ react: code`
1713
+ function Component() {
1714
+ const ref = React.useRef()
1715
+
1716
+ function handleChange(event) {
1717
+ console.log(event.detail)
1718
+ }
1719
+
1720
+ React.useEffect(() => {
1721
+ ref.current.addEventListener("selection", handleChange)
1722
+ return () => {
1723
+ ref.current.removeEventListener("selection", handleChange)
1724
+ }
1725
+ })
1726
+
1727
+ return (
1728
+ <div className="sps-row">
1729
+ <div className="col-12">
1730
+ <sps-file-upload
1731
+ ref={ref}
1732
+ description="Spreadsheets"
1733
+ multiple
1734
+ acceptExtensions="XLS, xlsx, .csv"
1735
+ maxSize="25MB"
1736
+ />
1737
+ </div>
1738
+ </div>
1739
+ )
1740
+ }
1741
+ `
1742
+ }
1743
+ }
1744
+ },
1745
+ dismissable: {
1746
+ label: "Dismissable",
1747
+ description: code`
1748
+ <p>With this option, the file upload component can be dismissed by the user. If the user does dismiss it, you can
1749
+ show it again programmatically if you need to.</p>
1750
+ `,
1751
+ examples: {
1752
+ dismissable: {
1753
+ react: code`
1754
+ function Component() {
1755
+ const [showFileUpload, setShowFileUpload] = React.useState(true)
1756
+ const ref = React.useRef()
1757
+
1758
+ function handleDismissal() {
1759
+ setShowFileUpload(false)
1760
+ }
1761
+
1762
+ React.useEffect(() => {
1763
+ ref.current.addEventListener("dismissal", handleDismissal)
1764
+ return () => {
1765
+ ref.current.removeEventListener("dismissal", handleDismissal)
1766
+ }
1767
+ })
1768
+
1769
+ return (
1770
+ <div className="sps-row">
1771
+ <div className="col-12">
1772
+ <sps-file-upload
1773
+ ref={ref}
1774
+ dismissable
1775
+ shown={showFileUpload}
1776
+ />
1777
+ {!showFileUpload && (
1778
+ <SpsButton onClick={() => setShowFileUpload(true)}>
1779
+ Reset
1780
+ </SpsButton>
1781
+ )}
1782
+ </div>
1783
+ </div>
1784
+ )
1785
+ }
1786
+ `
1787
+ }
1788
+ }
1789
+ },
1790
+ downloadButton: {
1791
+ label: "Download Button",
1792
+ description: code`
1793
+ <p>You can optionally provide a button to download a file. Typically this will be a template for
1794
+ whatever the user is expected to upload. They can then fill out the template, save it, and upload it.</p>
1795
+ `,
1796
+ examples: {
1797
+ downloadButton: {
1798
+ react: code`
1799
+ function Component() {
1800
+ const ref = React.useRef()
1801
+
1802
+ function handleDownload() {
1803
+ console.log("Download triggered.")
1804
+ }
1805
+
1806
+ React.useEffect(() => {
1807
+ ref.current.addEventListener("download", handleDownload)
1808
+ return () => {
1809
+ ref.current.removeEventListener("download", handleDownload)
1810
+ }
1811
+ })
1812
+
1813
+ return (
1814
+ <div className="sps-row">
1815
+ <div className="col-12">
1816
+ <sps-file-upload
1817
+ ref={ref}
1818
+ description="Spreadsheet"
1819
+ acceptExtensions="xlsx"
1820
+ downloadLabel="Download Excel Template"
1821
+ />
1822
+ </div>
1823
+ </div>
1824
+ )
1825
+ }
1826
+ `
1827
+ }
1828
+ }
1829
+ },
1830
+ mini: {
1831
+ label: "Mini File Upload",
1832
+ description: code`
1833
+ <p>When the file upload component is to be placed in a small container,
1834
+ it should be marked as a mini file upload so that everything fits.</p>
1835
+ `,
1836
+ examples: {
1837
+ single: {
1838
+ react: code`
1839
+ function Component() {
1840
+ const ref = React.useRef()
1841
+
1842
+ function handleChange(event) {
1843
+ console.log(event.detail)
1844
+ }
1845
+
1846
+ React.useEffect(() => {
1847
+ ref.current.addEventListener("selection", handleChange)
1848
+ return () => {
1849
+ ref.current.removeEventListener("selection", handleChange)
1850
+ }
1851
+ })
1852
+
1853
+ return (
1854
+ <div className="sps-row">
1855
+ <div className="col-4">
1856
+ <sps-file-upload ref={ref} mini/>
1857
+ </div>
1858
+ </div>
1859
+ )
1860
+ }
1861
+ `
1862
+ }
1863
+ }
1864
+ },
1865
+ constrainContentWidth: {
1866
+ label: "Constrain Content Width",
1867
+ description: code`
1868
+ <p>If this prop is provided, the content will be restricted to 50% of
1869
+ the overall width of the component. Consult your product designer if
1870
+ you're not sure whether to use this variant.</p>
1871
+ `,
1872
+ examples: {
1873
+ constrainContentWidth: {
1874
+ react: code`
1875
+ function Component() {
1876
+ const ref = React.useRef()
1877
+
1878
+ function handleChange(event: CustomEvent<Array<File>>) {
1879
+ console.log(event.detail)
1880
+ }
1881
+
1882
+ React.useEffect(() => {
1883
+ ref.current.addEventListener("selection", handleChange)
1884
+ return () => {
1885
+ ref.current.removeEventListener("selection", handleChange)
1886
+ }
1887
+ })
1888
+
1889
+ return (
1890
+ <div className="sps-row">
1891
+ <div className="col-4">
1892
+ <sps-file-upload ref={ref} constrainContentWidth/>
1893
+ </div>
1894
+ </div>
1895
+ )
1896
+ }
1897
+ `
1898
+ }
1899
+ }
1900
+ }
1901
+ };
1902
+ var __defProp$4 = Object.defineProperty;
1903
+ var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
1904
+ var __decorateClass$4 = (decorators, target, key2, kind) => {
1905
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key2) : target;
1906
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1907
+ if (decorator = decorators[i])
1908
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
1909
+ if (kind && result)
1910
+ __defProp$4(target, key2, result);
1911
+ return result;
1912
+ };
1913
+ let SpsNavTabComponent = class extends HTMLElement {
1914
+ constructor() {
1915
+ super(...arguments);
1916
+ this.active = false;
1917
+ this.label = "";
1918
+ this.tag = "";
1919
+ }
1920
+ get [ClassBindings]() {
1921
+ return [
1922
+ "sps-tabbed-nav__nav-item",
1923
+ this.active && "sps-tabbed-nav__nav-item--active"
1924
+ ];
1925
+ }
1926
+ render() {
1927
+ return /* @__PURE__ */ h("a", {
1928
+ href: this.href,
1929
+ target: this.target,
1930
+ className: "sps-tabbed-nav__nav-item-link",
1931
+ tabIndex: 0
1932
+ }, this.icon && /* @__PURE__ */ h("i", {
1933
+ className: `sps-icon sps-icon-${this.icon}`
1934
+ }), this.label && /* @__PURE__ */ h("span", null, this.label), this.tag && /* @__PURE__ */ h("span", {
1935
+ className: "sps-tag sps-tag--default"
1936
+ }, this.tag));
1937
+ }
1938
+ };
1939
+ SpsNavTabComponent.displayName = "sps-nav-tab";
1940
+ SpsNavTabComponent.props = {
1941
+ active: "boolean",
1942
+ label: "string",
1943
+ icon: "SpsIcon",
1944
+ tag: "string",
1945
+ href: "string",
1946
+ target: "string"
1947
+ };
1948
+ __decorateClass$4([
1949
+ Prop()
1950
+ ], SpsNavTabComponent.prototype, "active", 2);
1951
+ __decorateClass$4([
1952
+ Prop()
1953
+ ], SpsNavTabComponent.prototype, "label", 2);
1954
+ __decorateClass$4([
1955
+ Prop()
1956
+ ], SpsNavTabComponent.prototype, "icon", 2);
1957
+ __decorateClass$4([
1958
+ Prop()
1959
+ ], SpsNavTabComponent.prototype, "tag", 2);
1960
+ __decorateClass$4([
1961
+ Prop()
1962
+ ], SpsNavTabComponent.prototype, "href", 2);
1963
+ __decorateClass$4([
1964
+ Prop()
1965
+ ], SpsNavTabComponent.prototype, "target", 2);
1966
+ SpsNavTabComponent = __decorateClass$4([
1967
+ Component({ tag: "sps-nav-tab" })
1968
+ ], SpsNavTabComponent);
1969
+ var __defProp$3 = Object.defineProperty;
1970
+ var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
1971
+ var __decorateClass$3 = (decorators, target, key2, kind) => {
1972
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key2) : target;
1973
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1974
+ if (decorator = decorators[i])
1975
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
1976
+ if (kind && result)
1977
+ __defProp$3(target, key2, result);
1978
+ return result;
1979
+ };
1980
+ let SpsNavTabSetComponent = class extends HTMLElement {
1981
+ constructor() {
1982
+ super(...arguments);
1983
+ this.content = [];
1984
+ }
1985
+ render() {
1986
+ return /* @__PURE__ */ h("nav", {
1987
+ className: "sps-tabbed-nav"
1988
+ }, this.content);
1989
+ }
1990
+ };
1991
+ SpsNavTabSetComponent.displayName = "sps-nav-tab-set";
1992
+ SpsNavTabSetComponent.props = {};
1993
+ __decorateClass$3([
1994
+ Content()
1995
+ ], SpsNavTabSetComponent.prototype, "content", 2);
1996
+ SpsNavTabSetComponent = __decorateClass$3([
1997
+ Component({ tag: "sps-nav-tab-set" })
1998
+ ], SpsNavTabSetComponent);
1999
+ const SpsNavTabsExamples = {
2000
+ basic: {
2001
+ label: "Basic Navigation Tabs",
2002
+ description: code`
2003
+ <p>Navigation tabs native web component</p>
2004
+ `,
2005
+ examples: {
2006
+ basic: {
2007
+ react: code`
2008
+ function DemoComponent() {
2009
+ const tabs = [
2010
+ { label: "Tab A", icon: "chart-line" },
2011
+ { label: "Tab B", icon: "chart-bar", tag: "12" },
2012
+ { label: "Tab C", icon: "chart-pie" }
2013
+ ]
2014
+
2015
+ const [activeTab, setActiveTab] = React.useState(0)
2016
+
2017
+ return (
2018
+ <sps-nav-tab-set>
2019
+ {tabs.map((tab, index) => (
2020
+ <sps-nav-tab
2021
+ key={index}
2022
+ icon={tab.icon}
2023
+ label={tab.label}
2024
+ tag={tab.tag}
2025
+ active={index === activeTab || null}
2026
+ onClick={() => setActiveTab(index)}
2027
+ />
2028
+ ))}
2029
+ </sps-nav-tab-set>
2030
+ )
2031
+ }
2032
+ `
2033
+ }
2034
+ }
2035
+ }
2036
+ };
2037
+ var __defProp$2 = Object.defineProperty;
2038
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
2039
+ var __decorateClass$2 = (decorators, target, key2, kind) => {
2040
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key2) : target;
2041
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2042
+ if (decorator = decorators[i])
2043
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
2044
+ if (kind && result)
2045
+ __defProp$2(target, key2, result);
2046
+ return result;
2047
+ };
2048
+ var SpsPhotoDisplayMode;
2049
+ (function(SpsPhotoDisplayMode2) {
2050
+ SpsPhotoDisplayMode2["FIT"] = "fit";
2051
+ SpsPhotoDisplayMode2["FILL"] = "fill";
2052
+ })(SpsPhotoDisplayMode || (SpsPhotoDisplayMode = {}));
2053
+ const CPT_NAME$2 = "sps-photo";
2054
+ let SpsPhotoComponent = class extends HTMLElement {
2055
+ constructor() {
2056
+ super(...arguments);
2057
+ this.mode = SpsPhotoDisplayMode.FILL;
2058
+ }
2059
+ get image() {
2060
+ return this.imageInternal;
2061
+ }
2062
+ set image(newValue) {
2063
+ this.imageInternal = newValue;
2064
+ if (newValue) {
2065
+ if (this.waitForImgHeightInterval) {
2066
+ window.clearInterval(this.waitForImgHeightInterval);
2067
+ }
2068
+ this.waitForImgHeightInterval = window.setInterval(() => {
2069
+ const imgRect = newValue.getBoundingClientRect();
2070
+ if (imgRect.height) {
2071
+ window.clearInterval(this.waitForImgHeightInterval);
2072
+ delete this.waitForImgHeightInterval;
2073
+ let imageIsLandscape = true;
2074
+ imageIsLandscape = imgRect.width / imgRect.height > 1;
2075
+ this.fitWidth = imageIsLandscape === (this.mode === SpsPhotoDisplayMode.FIT);
2076
+ }
2077
+ }, 1e3 / 60);
2078
+ }
2079
+ }
2080
+ get [ClassBindings]() {
2081
+ return [
2082
+ CPT_NAME$2,
2083
+ this.fitWidth ? `${CPT_NAME$2}--fit-width` : `${CPT_NAME$2}--fit-height`,
2084
+ this.placeholderIcon && `${CPT_NAME$2}--placeholder`
2085
+ ];
2086
+ }
2087
+ get [StyleBindings]() {
2088
+ return {
2089
+ fontSize: `${this.width * 0.05}rem`,
2090
+ width: `${this.width}rem`,
2091
+ height: `${0.75 * this.width}rem`
2092
+ };
2093
+ }
2094
+ connectedCallback() {
2095
+ this.waitForWidthInterval = window.setInterval(() => {
2096
+ const boundingClientRect = this.getBoundingClientRect();
2097
+ if (boundingClientRect.width) {
2098
+ this.setWidth(boundingClientRect.width);
2099
+ window.clearInterval(this.waitForWidthInterval);
2100
+ delete this.waitForWidthInterval;
2101
+ }
2102
+ }, 1e3 / 60);
2103
+ }
2104
+ disconnectedCallback() {
2105
+ if (this.waitForWidthInterval) {
2106
+ window.clearInterval(this.waitForWidthInterval);
2107
+ }
2108
+ if (this.waitForImgHeightInterval) {
2109
+ window.clearInterval(this.waitForImgHeightInterval);
2110
+ }
2111
+ }
2112
+ render() {
2113
+ if (this.src) {
2114
+ return this.width ? /* @__PURE__ */ h("img", {
2115
+ src: this.src,
2116
+ alt: this.altText
2117
+ }) : /* @__PURE__ */ h("span", null);
2118
+ }
2119
+ return /* @__PURE__ */ h("i", {
2120
+ className: `sps-icon sps-icon-${this.placeholderIcon}`
2121
+ });
2122
+ }
2123
+ setWidth(hostWidth) {
2124
+ if (hostWidth && !this.width) {
2125
+ const baseFontSize = document.body.parentElement.style.fontSize || "16px";
2126
+ const remPx = Number(baseFontSize.substr(0, baseFontSize.length - 2));
2127
+ this.width = hostWidth / remPx;
2128
+ }
2129
+ }
2130
+ };
2131
+ SpsPhotoComponent.displayName = CPT_NAME$2;
2132
+ SpsPhotoComponent.props = {
2133
+ src: "string",
2134
+ altText: "string",
2135
+ mode: "SpsPhotoDisplayMode",
2136
+ placeholderIcon: "SpsIcon"
2137
+ };
2138
+ __decorateClass$2([
2139
+ Prop()
2140
+ ], SpsPhotoComponent.prototype, "src", 2);
2141
+ __decorateClass$2([
2142
+ Prop()
2143
+ ], SpsPhotoComponent.prototype, "altText", 2);
2144
+ __decorateClass$2([
2145
+ Prop()
2146
+ ], SpsPhotoComponent.prototype, "mode", 2);
2147
+ __decorateClass$2([
2148
+ Prop()
2149
+ ], SpsPhotoComponent.prototype, "placeholderIcon", 2);
2150
+ __decorateClass$2([
2151
+ Watch()
2152
+ ], SpsPhotoComponent.prototype, "width", 2);
2153
+ __decorateClass$2([
2154
+ Watch()
2155
+ ], SpsPhotoComponent.prototype, "fitWidth", 2);
2156
+ __decorateClass$2([
2157
+ QuerySelector("img", { refresh: true })
2158
+ ], SpsPhotoComponent.prototype, "image", 1);
2159
+ SpsPhotoComponent = __decorateClass$2([
2160
+ Component({ tag: CPT_NAME$2 })
2161
+ ], SpsPhotoComponent);
2162
+ const SpsPhotoExamples = {
2163
+ sizing: {
2164
+ label: "Sizing",
2165
+ description: code`
2166
+ <p>
2167
+ Photos are block elements, so a photo fills its container's width unless
2168
+ an explicit width is set. It is always a 4:3 aspect ratio. In this example,
2169
+ photos have been placed in cards which have different widths in the 12
2170
+ column grid.
2171
+ </p>
2172
+ `,
2173
+ examples: {
2174
+ basic: {
2175
+ jsx: code`
2176
+ <div className="sfg-row">
2177
+ <div className="sfg-col-2">
2178
+ <sps-card>
2179
+ <sps-photo src="assets/images/photo-landscape.jpg"></sps-photo>
2180
+ </sps-card>
2181
+ </div>
2182
+ <div className="sfg-col-4">
2183
+ <sps-card>
2184
+ <sps-photo src="assets/images/photo-landscape.jpg"></sps-photo>
2185
+ </sps-card>
2186
+ </div>
2187
+ <div className="sfg-col-6">
2188
+ <sps-card>
2189
+ <sps-photo src="assets/images/photo-landscape.jpg"></sps-photo>
2190
+ </sps-card>
2191
+ </div>
2192
+ </div>
2193
+ `
2194
+ }
2195
+ }
2196
+ },
2197
+ displayMode: {
2198
+ label: "Fill vs. Fit",
2199
+ description: code`
2200
+ <p>
2201
+ There are two display modes available:
2202
+ <ul>
2203
+ <li><b>"fill"</b> fills the entire 4:3 container, cropping off any excess portions of the image.
2204
+ <li><b>"fit"</b> fits the entire image into the container, leaving any excess portions of the container blank.
2205
+ </ul>
2206
+ </p>
2207
+ `,
2208
+ examples: {
2209
+ landscape: {
2210
+ description: "<p>Landscape oriented photo (container outline added for illustrative purposes)</p>",
2211
+ jsx: code`
2212
+ <div className="sfg-row">
2213
+ <div className="sfg-col-4">
2214
+ <sps-photo src="assets/images/photo-landscape.jpg" mode="fill"></sps-photo>
2215
+ </div>
2216
+ <div className="sfg-col-4">
2217
+ <sps-photo src="assets/images/photo-landscape.jpg" mode="fit"></sps-photo>
2218
+ </div>
2219
+ </div>
2220
+ `
2221
+ },
2222
+ portrait: {
2223
+ description: "<p>Portrait oriented photo (container outline added for illustrative purposes)</p>",
2224
+ jsx: code`
2225
+ <div className="sfg-row">
2226
+ <div className="sfg-col-4">
2227
+ <sps-photo src="assets/images/photo-portrait.jpg" mode="fill"></sps-photo>
2228
+ </div>
2229
+ <div className="sfg-col-4">
2230
+ <sps-photo id="foo" src="assets/images/photo-portrait.jpg" mode="fit"></sps-photo>
2231
+ </div>
2232
+ </div>
2233
+ `
2234
+ }
2235
+ }
2236
+ },
2237
+ placeholder: {
2238
+ label: "Placeholders",
2239
+ description: code`
2240
+ <p>
2241
+ When an image is not provided for a particular use case (such as a user avatar,
2242
+ a company photo, item image, etc.), a placeholder should be shown in its place.
2243
+
2244
+ The placeholder's icon, selected from our SPS icon set, should represent the
2245
+ type of image it is substituting for.
2246
+ </p>
2247
+ `,
2248
+ examples: {
2249
+ general: {
2250
+ description: "<p>General Photo</p>",
2251
+ jsx: code`
2252
+ <div className="sfg-row">
2253
+ <div className="sfg-col-3">
2254
+ <sps-photo placeholderIcon="photo"></sps-photo>
2255
+ </div>
2256
+ </div>
2257
+ `
2258
+ },
2259
+ photoAlt: {
2260
+ description: "<p>Photo Alt</p>",
2261
+ jsx: code`
2262
+ <div className="sfg-row">
2263
+ <div className="sfg-col-3">
2264
+ <sps-photo placeholderIcon="camera"></sps-photo>
2265
+ </div>
2266
+ </div>
2267
+ `
2268
+ },
2269
+ user: {
2270
+ description: "<p>User / Single Person</p>",
2271
+ jsx: code`
2272
+ <div className="sfg-row">
2273
+ <div className="sfg-col-3">
2274
+ <sps-photo placeholderIcon="user"></sps-photo>
2275
+ </div>
2276
+ </div>
2277
+ `
2278
+ },
2279
+ group: {
2280
+ description: "<p>Group / Multiple People</p>",
2281
+ jsx: code`
2282
+ <div className="sfg-row">
2283
+ <div className="sfg-col-3">
2284
+ <sps-photo placeholderIcon="group"></sps-photo>
2285
+ </div>
2286
+ </div>
2287
+ `
2288
+ },
2289
+ company: {
2290
+ description: "<p>Company / Building</p>",
2291
+ jsx: code`
2292
+ <div className="sfg-row">
2293
+ <div className="sfg-col-3">
2294
+ <sps-photo placeholderIcon="building"></sps-photo>
2295
+ </div>
2296
+ </div>
2297
+ `
2298
+ }
2299
+ }
2300
+ }
2301
+ };
2302
+ const MANIFEST = {
2303
+ "File Upload": {
2304
+ components: [SpsFileUploadComponent],
2305
+ examples: SpsFileUploadExamples
2306
+ },
2307
+ "Tabbed Navigation": {
2308
+ components: [SpsNavTabComponent, SpsNavTabSetComponent],
2309
+ examples: SpsNavTabsExamples
2310
+ },
2311
+ Photos: {
2312
+ components: [SpsPhotoComponent],
2313
+ examples: SpsPhotoExamples
2314
+ }
2315
+ };
2316
+ var __defProp$1 = Object.defineProperty;
2317
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
2318
+ var __decorateClass$1 = (decorators, target, key2, kind) => {
2319
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key2) : target;
2320
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2321
+ if (decorator = decorators[i])
2322
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
2323
+ if (kind && result)
2324
+ __defProp$1(target, key2, result);
2325
+ return result;
2326
+ };
2327
+ const CPT_NAME$1 = "sps-insight-card";
2328
+ let SpsInsightCardComponent = class extends HTMLElement {
2329
+ constructor() {
2330
+ super(...arguments);
2331
+ this.kind = SpsInsightCardKind.GENERAL;
2332
+ }
2333
+ get [ClassBindings]() {
2334
+ return [
2335
+ CPT_NAME$1,
2336
+ `${CPT_NAME$1}--${this.kind}`,
2337
+ this.detail && this.detail.children.length ? `${CPT_NAME$1}--has-detail` : null
2338
+ ];
2339
+ }
2340
+ render({ t }) {
2341
+ const metric = /* @__PURE__ */ h("div", {
2342
+ className: `${CPT_NAME$1}__metric-count`
2343
+ }, this.metric);
2344
+ const description = /* @__PURE__ */ h("div", {
2345
+ className: `${CPT_NAME$1}__description`
2346
+ }, /* @__PURE__ */ h("div", {
2347
+ className: `${CPT_NAME$1}__title`,
2348
+ style: { "-webkit-box-orient": "vertical" }
2349
+ }, this.title), /* @__PURE__ */ h("div", {
2350
+ className: `${CPT_NAME$1}__detail`
2351
+ }, this.content));
2352
+ const [
2353
+ count,
2354
+ ofText,
2355
+ total
2356
+ ] = (this.partnerCount ? t("design-system:insightCard.partnerCount", { count: this.partnerCount, total: this.totalPartners }) : "").split("|");
2357
+ return /* @__PURE__ */ h("div", {
2358
+ "data-fragment": true
2359
+ }, /* @__PURE__ */ h("div", {
2360
+ className: `${CPT_NAME$1}__body`
2361
+ }, this.icon ? /* @__PURE__ */ h("i", {
2362
+ className: `sps-icon sps-icon-${this.icon}`
2363
+ }) : /* @__PURE__ */ h("i", {
2364
+ className: `sps-icon sps-icon-${SpsInsightCardIcons[this.kind]}`
2365
+ }), metric, description), this.partnerCount && /* @__PURE__ */ h("div", {
2366
+ className: `${CPT_NAME$1}__partner-count`
2367
+ }, this.partnerCount === this.totalPartners ? /* @__PURE__ */ h("div", null, t("design-system:insightCard.all")) : /* @__PURE__ */ h("div", {
2368
+ "data-fragment": true
2369
+ }, /* @__PURE__ */ h("div", null, count), /* @__PURE__ */ h("div", null, ofText), /* @__PURE__ */ h("div", null, total)), /* @__PURE__ */ h("div", {
2370
+ className: `${CPT_NAME$1}__partners-text`
2371
+ }, t("design-system:insightCard.partners"))));
2372
+ }
2373
+ };
2374
+ SpsInsightCardComponent.displayName = CPT_NAME$1;
2375
+ SpsInsightCardComponent.props = {
2376
+ icon: "SpsIcon",
2377
+ kind: "SpsInsightCardKind",
2378
+ title: "string",
2379
+ metric: "number",
2380
+ partnerCount: "number",
2381
+ totalPartners: "number",
2382
+ secondary: "boolean"
2383
+ };
2384
+ __decorateClass$1([
2385
+ Prop()
2386
+ ], SpsInsightCardComponent.prototype, "icon", 2);
2387
+ __decorateClass$1([
2388
+ Prop()
2389
+ ], SpsInsightCardComponent.prototype, "kind", 2);
2390
+ __decorateClass$1([
2391
+ Prop()
2392
+ ], SpsInsightCardComponent.prototype, "title", 2);
2393
+ __decorateClass$1([
2394
+ Prop()
2395
+ ], SpsInsightCardComponent.prototype, "metric", 2);
2396
+ __decorateClass$1([
2397
+ Prop()
2398
+ ], SpsInsightCardComponent.prototype, "partnerCount", 2);
2399
+ __decorateClass$1([
2400
+ Prop()
2401
+ ], SpsInsightCardComponent.prototype, "totalPartners", 2);
2402
+ __decorateClass$1([
2403
+ Prop()
2404
+ ], SpsInsightCardComponent.prototype, "secondary", 2);
2405
+ __decorateClass$1([
2406
+ Content()
2407
+ ], SpsInsightCardComponent.prototype, "content", 2);
2408
+ __decorateClass$1([
2409
+ QuerySelector(`.${CPT_NAME$1}__detail`)
2410
+ ], SpsInsightCardComponent.prototype, "detail", 2);
2411
+ SpsInsightCardComponent = __decorateClass$1([
2412
+ Component({ tag: CPT_NAME$1 })
2413
+ ], SpsInsightCardComponent);
2414
+ var __defProp = Object.defineProperty;
2415
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
2416
+ var __decorateClass = (decorators, target, key2, kind) => {
2417
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key2) : target;
2418
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2419
+ if (decorator = decorators[i])
2420
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
2421
+ if (kind && result)
2422
+ __defProp(target, key2, result);
2423
+ return result;
2424
+ };
2425
+ const CPT_NAME = "sps-insights";
2426
+ let SpsInsightsComponent = class extends HTMLElement {
2427
+ constructor() {
2428
+ super();
2429
+ this.content = [];
2430
+ this.showAdditionalInsights = false;
2431
+ this.toggleAdditionalInsights = this.toggleAdditionalInsights.bind(this);
2432
+ }
2433
+ get [ClassBindings]() {
2434
+ return [
2435
+ CPT_NAME,
2436
+ this.showAdditionalInsights && `${CPT_NAME}--show-additional`,
2437
+ this.details && Array.from(this.details).every((d) => !d.textContent) ? `${CPT_NAME}--no-details` : null,
2438
+ this.content.length === 6 ? `${CPT_NAME}--break-4` : null,
2439
+ this.content.length === 7 ? `${CPT_NAME}--break-5` : null,
2440
+ this.content.length === 8 ? `${CPT_NAME}--break-5` : null
2441
+ ];
2442
+ }
2443
+ toggleAdditionalInsights() {
2444
+ this.showAdditionalInsights = !this.showAdditionalInsights;
2445
+ this.update();
2446
+ }
2447
+ render() {
2448
+ return /* @__PURE__ */ h("div", {
2449
+ "data-fragment": true
2450
+ }, this.content, this.content.length > 10 && /* @__PURE__ */ h("div", {
2451
+ className: "sps-button sps-button--link",
2452
+ onClick: this.toggleAdditionalInsights
2453
+ }, /* @__PURE__ */ h("button", {
2454
+ type: "button"
2455
+ }, this.showAdditionalInsights ? "Hide " : "Show ", "Additional Insights")));
2456
+ }
2457
+ };
2458
+ SpsInsightsComponent.displayName = CPT_NAME;
2459
+ SpsInsightsComponent.props = {};
2460
+ __decorateClass([
2461
+ Content()
2462
+ ], SpsInsightsComponent.prototype, "content", 2);
2463
+ __decorateClass([
2464
+ QuerySelectorAll(".sps-insight-card__detail")
2465
+ ], SpsInsightsComponent.prototype, "details", 2);
2466
+ SpsInsightsComponent = __decorateClass([
2467
+ Component({ tag: CPT_NAME })
2468
+ ], SpsInsightsComponent);
2469
+ const SpsInsightCardExamples = {
2470
+ basic: {
2471
+ label: "Basic Insight Cards",
2472
+ examples: {
2473
+ basic: {
2474
+ jsx: code`
2475
+ <sps-insights>
2476
+ <sps-insight-card kind="general"
2477
+ metric="1234"
2478
+ title="Insight Card Title"
2479
+ ></sps-insight-card>
2480
+ <sps-insight-card kind="processing"
2481
+ metric="1234"
2482
+ title="Insight Card Title"
2483
+ ></sps-insight-card>
2484
+ <sps-insight-card kind="success"
2485
+ metric="1234"
2486
+ title="Insight Card Title"
2487
+ ></sps-insight-card>
2488
+ <sps-insight-card kind="warning"
2489
+ metric="1234"
2490
+ title="Insight Card Title"
2491
+ ></sps-insight-card>
2492
+ <sps-insight-card kind="error"
2493
+ metric="1234"
2494
+ title="Insight Card Title"
2495
+ ></sps-insight-card>
2496
+ </sps-insights>
2497
+ `
2498
+ }
2499
+ }
2500
+ },
2501
+ details: {
2502
+ label: "With Details",
2503
+ examples: {
2504
+ details: {
2505
+ jsx: code`
2506
+ <sps-insights>
2507
+ <sps-insight-card kind="general"
2508
+ metric="1234"
2509
+ title="Insight Card Title"
2510
+ >
2511
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2512
+ </sps-insight-card>
2513
+ <sps-insight-card kind="processing"
2514
+ metric="1234"
2515
+ title="Insight Card Title"
2516
+ >
2517
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2518
+ </sps-insight-card>
2519
+ <sps-insight-card kind="success"
2520
+ metric="1234"
2521
+ title="Insight Card Title"
2522
+ >
2523
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2524
+ </sps-insight-card>
2525
+ <sps-insight-card kind="warning"
2526
+ metric="1234"
2527
+ title="Insight Card Title"
2528
+ >
2529
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2530
+ </sps-insight-card>
2531
+ <sps-insight-card kind="error"
2532
+ metric="1234"
2533
+ title="Insight Card Title"
2534
+ >
2535
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2536
+ </sps-insight-card>
2537
+ <sps-insight-card kind="success"
2538
+ metric="1234"
2539
+ title="Insight Card Title"
2540
+ >
2541
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2542
+ </sps-insight-card>
2543
+ <sps-insight-card kind="error"
2544
+ metric="1234"
2545
+ title="Insight Card Title"
2546
+ >
2547
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2548
+ </sps-insight-card>
2549
+ </sps-insights>
2550
+ `
2551
+ }
2552
+ }
2553
+ },
2554
+ partner_count: {
2555
+ label: "Partner Count",
2556
+ examples: {
2557
+ partner_count: {
2558
+ jsx: code`
2559
+ <sps-insights>
2560
+ <sps-insight-card kind="general"
2561
+ metric="1234"
2562
+ title="Insight Card Title"
2563
+ partnerCount="250"
2564
+ totalPartners="250"
2565
+ ></sps-insight-card>
2566
+ <sps-insight-card kind="processing"
2567
+ metric="1234"
2568
+ title="Insight Card Title"
2569
+ partnerCount="122"
2570
+ totalPartners="250"
2571
+ ></sps-insight-card>
2572
+ <sps-insight-card kind="success"
2573
+ metric="1234"
2574
+ title="Insight Card Title"
2575
+ partnerCount="207"
2576
+ totalPartners="250"
2577
+ ></sps-insight-card>
2578
+ <sps-insight-card kind="warning"
2579
+ metric="1234"
2580
+ title="Insight Card Title"
2581
+ partnerCount="12"
2582
+ totalPartners="250"
2583
+ ></sps-insight-card>
2584
+ <sps-insight-card kind="error"
2585
+ metric="1234"
2586
+ title="Insight Card Title"
2587
+ partnerCount="94"
2588
+ totalPartners="250"
2589
+ ></sps-insight-card>
2590
+ </sps-insights>
2591
+ `
2592
+ }
2593
+ }
2594
+ },
2595
+ expansion: {
2596
+ label: "10+ Insight Cards",
2597
+ examples: {
2598
+ expansion: {
2599
+ jsx: code`
2600
+ <sps-insights>
2601
+ <sps-insight-card kind="general"
2602
+ metric="1234"
2603
+ title="Insight Card Title"
2604
+ partnerCount="100"
2605
+ totalPartners="200"
2606
+ >
2607
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2608
+ </sps-insight-card>
2609
+ <sps-insight-card kind="processing"
2610
+ metric="1234"
2611
+ title="Insight Card Title"
2612
+ partnerCount="100"
2613
+ totalPartners="200"
2614
+ ></sps-insight-card>
2615
+ <sps-insight-card kind="success"
2616
+ metric="1234"
2617
+ title="Insight Card Title"
2618
+ partnerCount="100"
2619
+ totalPartners="200"
2620
+ >
2621
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2622
+ </sps-insight-card>
2623
+ <sps-insight-card kind="warning"
2624
+ metric="1234"
2625
+ title="Insight Card Title"
2626
+ partnerCount="100"
2627
+ totalPartners="200"
2628
+ ></sps-insight-card>
2629
+ <sps-insight-card kind="error"
2630
+ metric="1234"
2631
+ title="Insight Card Title"
2632
+ partnerCount="100"
2633
+ totalPartners="200"
2634
+ >
2635
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2636
+ </sps-insight-card>
2637
+ <sps-insight-card kind="general"
2638
+ metric="1234"
2639
+ title="Insight Card Title"
2640
+ partnerCount="100"
2641
+ totalPartners="200"
2642
+ ></sps-insight-card>
2643
+ <sps-insight-card kind="processing"
2644
+ metric="1234"
2645
+ title="Insight Card Title"
2646
+ partnerCount="100"
2647
+ totalPartners="200"
2648
+ >
2649
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2650
+ </sps-insight-card>
2651
+ <sps-insight-card kind="success"
2652
+ metric="1234"
2653
+ title="Insight Card Title"
2654
+ partnerCount="100"
2655
+ totalPartners="200"
2656
+ ></sps-insight-card>
2657
+ <sps-insight-card kind="warning"
2658
+ metric="1234"
2659
+ title="Insight Card Title"
2660
+ partnerCount="100"
2661
+ totalPartners="200"
2662
+ >
2663
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2664
+ </sps-insight-card>
2665
+ <sps-insight-card kind="error"
2666
+ metric="1234"
2667
+ title="Insight Card Title"
2668
+ partnerCount="100"
2669
+ totalPartners="200"
2670
+ ></sps-insight-card>
2671
+ <sps-insight-card kind="general"
2672
+ metric="1234"
2673
+ title="Insight Card Title"
2674
+ partnerCount="100"
2675
+ totalPartners="200"
2676
+ >
2677
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2678
+ </sps-insight-card>
2679
+ <sps-insight-card kind="processing"
2680
+ metric="1234"
2681
+ title="Insight Card Title"
2682
+ partnerCount="100"
2683
+ totalPartners="200"
2684
+ ></sps-insight-card>
2685
+ <sps-insight-card kind="success"
2686
+ metric="1234"
2687
+ title="Insight Card Title"
2688
+ partnerCount="100"
2689
+ totalPartners="200"
2690
+ >
2691
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2692
+ </sps-insight-card>
2693
+ <sps-insight-card kind="warning"
2694
+ metric="1234"
2695
+ title="Insight Card Title"
2696
+ partnerCount="100"
2697
+ totalPartners="200"
2698
+ ></sps-insight-card>
2699
+ <sps-insight-card kind="error"
2700
+ metric="1234"
2701
+ title="Insight Card Title"
2702
+ partnerCount="100"
2703
+ totalPartners="200"
2704
+ >
2705
+ <span className="gray600 font-weight-bold">Detail:</span> 792 units
2706
+ </sps-insight-card>
2707
+ </sps-insights>
2708
+ `
2709
+ }
2710
+ }
2711
+ },
2712
+ events: {
2713
+ label: "Adding a click handler",
2714
+ description: code`
2715
+ <p>Attaching event handlers to native web components in React cannot be done the usual way at this time.
2716
+ Here is how to do it:</p>
2717
+ `,
2718
+ examples: {
2719
+ events: {
2720
+ react: code`
2721
+ function Component() {
2722
+ function handleClick() {
2723
+ window.alert("Insight card clicked");
2724
+ }
2725
+
2726
+ const ref = React.useRef();
2727
+ React.useEffect(() => {
2728
+ ref.current.addEventListener("click", handleClick);
2729
+ return () => {
2730
+ ref.current.removeEventListener("click", handleClick);
2731
+ };
2732
+ }, []);
2733
+
2734
+ return (
2735
+ <sps-insights>
2736
+ <sps-insight-card ref={ref}
2737
+ kind="general"
2738
+ metric="1234"
2739
+ title="Insight Card Title"
2740
+ ></sps-insight-card>
2741
+ <sps-insight-card kind="general"
2742
+ metric="1234"
2743
+ title="Insight Card Title"
2744
+ ></sps-insight-card>
2745
+ <sps-insight-card kind="general"
2746
+ metric="1234"
2747
+ title="Insight Card Title"
2748
+ ></sps-insight-card>
2749
+ </sps-insights>
2750
+ );
2751
+ }
2752
+ `
2753
+ }
2754
+ }
2755
+ },
2756
+ alternateIcon: {
2757
+ label: "Using alternate icons",
2758
+ examples: {
2759
+ basic: {
2760
+ react: code`
2761
+ function DemoComponent() {
2762
+ return (
2763
+ <sps-insights>
2764
+ <sps-insight-card
2765
+ kind="general"
2766
+ metric="1234"
2767
+ icon={SpsIcon.DOLLAR_SIGN}
2768
+ title="Insight Card Title"
2769
+ ></sps-insight-card>
2770
+ <sps-insight-card
2771
+ kind="processing"
2772
+ metric="1234"
2773
+ icon={SpsIcon.ASTERISK}
2774
+ title="Insight Card Title"
2775
+ ></sps-insight-card>
2776
+ <sps-insight-card
2777
+ kind="success"
2778
+ metric="1234"
2779
+ icon={SpsIcon.USER}
2780
+ title="Insight Card Title"
2781
+ ></sps-insight-card>
2782
+ <sps-insight-card
2783
+ kind="warning"
2784
+ metric="1234"
2785
+ icon={SpsIcon.FOLDER_OPEN}
2786
+ title="Insight Card Title"
2787
+ ></sps-insight-card>
2788
+ <sps-insight-card
2789
+ kind="error"
2790
+ metric="1234"
2791
+ icon={SpsIcon.BAN}
2792
+ title="Insight Card Title"
2793
+ ></sps-insight-card>
2794
+ </sps-insights>
2795
+ )
2796
+ }
2797
+ `
2798
+ }
2799
+ }
2800
+ }
2801
+ };
2802
+ export { AttrBindings, ClassBindings, Component, Content, EventDispatcher, EventListener, MANIFEST, MIMEType, Prop, QuerySelector, QuerySelectorAll, SpsFileUploadComponent, SpsFileUploadExamples, SpsInsightCardComponent, SpsInsightCardExamples, SpsInsightsComponent, SpsNavTabComponent, SpsNavTabSetComponent, SpsNavTabsExamples, SpsPhotoComponent, SpsPhotoDisplayMode, SpsPhotoExamples, StyleBindings, Watch, h, namespaceOverrideRegistrar, register, webComponentsUseI18n };