@paperless/core 0.0.3-alpha.5 → 0.1.0-alpha.3

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 (156) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +14 -10
  3. package/dist/assets/icons/arrow.svg +2 -2
  4. package/dist/assets/icons/attachment.svg +2 -2
  5. package/dist/assets/icons/bread.svg +2 -2
  6. package/dist/assets/icons/calendar.svg +2 -2
  7. package/dist/assets/icons/car.svg +2 -2
  8. package/dist/assets/icons/checkmark.svg +2 -2
  9. package/dist/assets/icons/chevron.svg +2 -2
  10. package/dist/assets/icons/clock.svg +2 -2
  11. package/dist/assets/icons/cogs.svg +2 -2
  12. package/dist/assets/icons/comment.svg +2 -2
  13. package/dist/assets/icons/document.svg +2 -2
  14. package/dist/assets/icons/download.svg +2 -2
  15. package/dist/assets/icons/envelope.svg +2 -2
  16. package/dist/assets/icons/explanation.svg +2 -2
  17. package/dist/assets/icons/eye.svg +2 -2
  18. package/dist/assets/icons/filter.svg +2 -2
  19. package/dist/assets/icons/grid.svg +2 -2
  20. package/dist/assets/icons/headset.svg +2 -2
  21. package/dist/assets/icons/list.svg +2 -2
  22. package/dist/assets/icons/location.svg +2 -2
  23. package/dist/assets/icons/megaphone.svg +2 -2
  24. package/dist/assets/icons/minus.svg +2 -2
  25. package/dist/assets/icons/negative.svg +2 -2
  26. package/dist/assets/icons/pagination.svg +2 -2
  27. package/dist/assets/icons/payment.svg +2 -2
  28. package/dist/assets/icons/pencil.svg +2 -2
  29. package/dist/assets/icons/person.svg +2 -2
  30. package/dist/assets/icons/plus.svg +2 -2
  31. package/dist/assets/icons/question.svg +2 -2
  32. package/dist/assets/icons/receipt.svg +2 -2
  33. package/dist/assets/icons/report.svg +2 -2
  34. package/dist/assets/icons/search.svg +2 -2
  35. package/dist/assets/icons/settings.svg +2 -2
  36. package/dist/assets/icons/sick.svg +2 -2
  37. package/dist/assets/icons/tachometer.svg +2 -2
  38. package/dist/assets/icons/tool.svg +2 -2
  39. package/dist/assets/icons/trash.svg +2 -2
  40. package/dist/assets/icons/turn.svg +2 -2
  41. package/dist/assets/icons/upload.svg +2 -2
  42. package/dist/assets/icons/warning.svg +2 -2
  43. package/dist/build/p-4144f8a0.entry.js +1 -0
  44. package/dist/build/p-8538576c.entry.js +1 -0
  45. package/dist/build/p-f04c4de0.entry.js +1 -0
  46. package/dist/build/p-f33e1285.js +2 -0
  47. package/dist/build/paperless.css +21 -10
  48. package/dist/build/paperless.esm.js +1 -1
  49. package/dist/cjs/{index-e3e940d8.js → index-a2da05ae.js} +564 -14
  50. package/dist/cjs/loader.cjs.js +2 -2
  51. package/dist/cjs/p-button_3.cjs.entry.js +909 -0
  52. package/dist/cjs/p-illustration.cjs.entry.js +1426 -0
  53. package/dist/cjs/p-tooltip.cjs.entry.js +1873 -0
  54. package/dist/cjs/paperless.cjs.js +2 -2
  55. package/dist/collection/assets/icons/arrow.svg +2 -2
  56. package/dist/collection/assets/icons/attachment.svg +2 -2
  57. package/dist/collection/assets/icons/bread.svg +2 -2
  58. package/dist/collection/assets/icons/calendar.svg +2 -2
  59. package/dist/collection/assets/icons/car.svg +2 -2
  60. package/dist/collection/assets/icons/checkmark.svg +2 -2
  61. package/dist/collection/assets/icons/chevron.svg +2 -2
  62. package/dist/collection/assets/icons/clock.svg +2 -2
  63. package/dist/collection/assets/icons/cogs.svg +2 -2
  64. package/dist/collection/assets/icons/comment.svg +2 -2
  65. package/dist/collection/assets/icons/document.svg +2 -2
  66. package/dist/collection/assets/icons/download.svg +2 -2
  67. package/dist/collection/assets/icons/envelope.svg +2 -2
  68. package/dist/collection/assets/icons/explanation.svg +2 -2
  69. package/dist/collection/assets/icons/eye.svg +2 -2
  70. package/dist/collection/assets/icons/filter.svg +2 -2
  71. package/dist/collection/assets/icons/grid.svg +2 -2
  72. package/dist/collection/assets/icons/headset.svg +2 -2
  73. package/dist/collection/assets/icons/list.svg +2 -2
  74. package/dist/collection/assets/icons/location.svg +2 -2
  75. package/dist/collection/assets/icons/megaphone.svg +2 -2
  76. package/dist/collection/assets/icons/minus.svg +2 -2
  77. package/dist/collection/assets/icons/negative.svg +2 -2
  78. package/dist/collection/assets/icons/pagination.svg +2 -2
  79. package/dist/collection/assets/icons/payment.svg +2 -2
  80. package/dist/collection/assets/icons/pencil.svg +2 -2
  81. package/dist/collection/assets/icons/person.svg +2 -2
  82. package/dist/collection/assets/icons/plus.svg +2 -2
  83. package/dist/collection/assets/icons/question.svg +2 -2
  84. package/dist/collection/assets/icons/receipt.svg +2 -2
  85. package/dist/collection/assets/icons/report.svg +2 -2
  86. package/dist/collection/assets/icons/search.svg +2 -2
  87. package/dist/collection/assets/icons/settings.svg +2 -2
  88. package/dist/collection/assets/icons/sick.svg +2 -2
  89. package/dist/collection/assets/icons/tachometer.svg +2 -2
  90. package/dist/collection/assets/icons/tool.svg +2 -2
  91. package/dist/collection/assets/icons/trash.svg +2 -2
  92. package/dist/collection/assets/icons/turn.svg +2 -2
  93. package/dist/collection/assets/icons/upload.svg +2 -2
  94. package/dist/collection/assets/icons/warning.svg +2 -2
  95. package/dist/collection/collection-manifest.json +5 -1
  96. package/dist/collection/components/atoms/button/button.component.css +47 -0
  97. package/dist/collection/components/atoms/button/button.component.js +276 -0
  98. package/dist/collection/components/atoms/icon/icon.component.js +112 -0
  99. package/dist/collection/components/atoms/illustration/illustration.component.js +39 -0
  100. package/dist/collection/components/atoms/loader/loader.component.css +26 -0
  101. package/dist/collection/components/atoms/loader/loader.component.js +153 -0
  102. package/dist/collection/components/atoms/tooltip/tooltip.component.css +34 -0
  103. package/dist/collection/components/atoms/tooltip/tooltip.component.js +174 -0
  104. package/dist/collection/tailwind/border-radius.js +1 -0
  105. package/dist/collection/tailwind/grid.js +6 -0
  106. package/dist/collection/tailwind/rotate.js +8 -0
  107. package/dist/collection/tailwind/scale.js +3 -0
  108. package/dist/collection/tailwind.config.js +9 -5
  109. package/dist/collection/utils/icons.js +82 -0
  110. package/dist/collection/utils/illustrations.js +18 -0
  111. package/dist/components/icon.component.js +817 -0
  112. package/dist/components/index.d.ts +4 -0
  113. package/dist/components/index.js +4 -0
  114. package/dist/components/loader.component.js +74 -0
  115. package/dist/components/p-button.js +68 -9
  116. package/dist/components/p-icon.d.ts +11 -0
  117. package/dist/components/p-icon.js +6 -0
  118. package/dist/components/p-illustration.d.ts +11 -0
  119. package/dist/components/p-illustration.js +1441 -0
  120. package/dist/components/p-loader.d.ts +11 -0
  121. package/dist/components/p-loader.js +6 -0
  122. package/dist/components/p-tooltip.d.ts +11 -0
  123. package/dist/components/p-tooltip.js +1891 -0
  124. package/dist/esm/{index-100a5ae6.js → index-d08bfe75.js} +562 -15
  125. package/dist/esm/loader.js +2 -2
  126. package/dist/esm/p-button_3.entry.js +903 -0
  127. package/dist/esm/p-illustration.entry.js +1422 -0
  128. package/dist/esm/p-tooltip.entry.js +1869 -0
  129. package/dist/esm/paperless.js +2 -2
  130. package/dist/index.html +1 -1
  131. package/dist/paperless/p-4144f8a0.entry.js +1 -0
  132. package/dist/paperless/p-8538576c.entry.js +1 -0
  133. package/dist/paperless/p-f04c4de0.entry.js +1 -0
  134. package/dist/paperless/p-f33e1285.js +2 -0
  135. package/dist/paperless/paperless.css +11303 -7692
  136. package/dist/paperless/paperless.esm.js +1 -1
  137. package/dist/sw.js +117 -26
  138. package/dist/tailwind.config.js +9 -5
  139. package/dist/types/components/atoms/button/button.component.d.ts +51 -0
  140. package/dist/types/components/atoms/icon/icon.component.d.ts +23 -0
  141. package/dist/types/components/atoms/illustration/illustration.component.d.ts +9 -0
  142. package/dist/types/components/atoms/loader/loader.component.d.ts +30 -0
  143. package/dist/types/components/atoms/tooltip/tooltip.component.d.ts +28 -0
  144. package/dist/types/components.d.ts +245 -4
  145. package/dist/types/utils/icons.d.ts +43 -0
  146. package/dist/types/utils/illustrations.d.ts +11 -0
  147. package/package.json +5 -2
  148. package/dist/build/p-54459ae1.js +0 -2
  149. package/dist/build/p-e61ff856.entry.js +0 -1
  150. package/dist/cjs/p-button.cjs.entry.js +0 -23
  151. package/dist/collection/components/button/button.component.css +0 -6
  152. package/dist/collection/components/button/button.component.js +0 -41
  153. package/dist/esm/p-button.entry.js +0 -19
  154. package/dist/paperless/p-54459ae1.js +0 -2
  155. package/dist/paperless/p-e61ff856.entry.js +0 -1
  156. package/dist/types/components/button/button.component.d.ts +0 -7
@@ -23,7 +23,12 @@ function _interopNamespace(e) {
23
23
  const NAMESPACE = 'paperless';
24
24
 
25
25
  let scopeId;
26
+ let contentRef;
26
27
  let hostTagName;
28
+ let useNativeShadowDom = false;
29
+ let checkSlotFallbackVisibility = false;
30
+ let checkSlotRelocate = false;
31
+ let isSvgMode = false;
27
32
  let queuePending = false;
28
33
  const win = typeof window !== 'undefined' ? window : {};
29
34
  const doc = win.document || { head: {} };
@@ -46,6 +51,35 @@ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
46
51
  return false;
47
52
  })()
48
53
  ;
54
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
55
+ if (listeners) {
56
+ listeners.map(([flags, name, method]) => {
57
+ const target = elm;
58
+ const handler = hostListenerProxy(hostRef, method);
59
+ const opts = hostListenerOpts(flags);
60
+ plt.ael(target, name, handler, opts);
61
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
62
+ });
63
+ }
64
+ };
65
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
66
+ try {
67
+ {
68
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
69
+ // instance is ready, let's call it's member method for this event
70
+ hostRef.$lazyInstance$[methodName](ev);
71
+ }
72
+ else {
73
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
74
+ }
75
+ }
76
+ }
77
+ catch (e) {
78
+ consoleError(e);
79
+ }
80
+ };
81
+ // prettier-ignore
82
+ const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
49
83
  const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
50
84
  const createTime = (fnName, tagName = '') => {
51
85
  {
@@ -153,6 +187,7 @@ const isComplexType = (o) => {
153
187
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
154
188
  const h = (nodeName, vnodeData, ...children) => {
155
189
  let child = null;
190
+ let slotName = null;
156
191
  let simple = false;
157
192
  let lastSimple = false;
158
193
  const vNodeChildren = [];
@@ -180,6 +215,9 @@ const h = (nodeName, vnodeData, ...children) => {
180
215
  };
181
216
  walk(children);
182
217
  if (vnodeData) {
218
+ if (vnodeData.name) {
219
+ slotName = vnodeData.name;
220
+ }
183
221
  {
184
222
  const classData = vnodeData.className || vnodeData.class;
185
223
  if (classData) {
@@ -192,11 +230,18 @@ const h = (nodeName, vnodeData, ...children) => {
192
230
  }
193
231
  }
194
232
  }
233
+ if (typeof nodeName === 'function') {
234
+ // nodeName is a functional component
235
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
236
+ }
195
237
  const vnode = newVNode(nodeName, null);
196
238
  vnode.$attrs$ = vnodeData;
197
239
  if (vNodeChildren.length > 0) {
198
240
  vnode.$children$ = vNodeChildren;
199
241
  }
242
+ {
243
+ vnode.$name$ = slotName;
244
+ }
200
245
  return vnode;
201
246
  };
202
247
  const newVNode = (tag, text) => {
@@ -210,10 +255,43 @@ const newVNode = (tag, text) => {
210
255
  {
211
256
  vnode.$attrs$ = null;
212
257
  }
258
+ {
259
+ vnode.$name$ = null;
260
+ }
213
261
  return vnode;
214
262
  };
215
263
  const Host = {};
216
264
  const isHost = (node) => node && node.$tag$ === Host;
265
+ const vdomFnUtils = {
266
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
267
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
268
+ };
269
+ const convertToPublic = (node) => ({
270
+ vattrs: node.$attrs$,
271
+ vchildren: node.$children$,
272
+ vkey: node.$key$,
273
+ vname: node.$name$,
274
+ vtag: node.$tag$,
275
+ vtext: node.$text$,
276
+ });
277
+ const convertToPrivate = (node) => {
278
+ if (typeof node.vtag === 'function') {
279
+ const vnodeData = Object.assign({}, node.vattrs);
280
+ if (node.vkey) {
281
+ vnodeData.key = node.vkey;
282
+ }
283
+ if (node.vname) {
284
+ vnodeData.name = node.vname;
285
+ }
286
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
287
+ }
288
+ const vnode = newVNode(node.vtag, node.vtext);
289
+ vnode.$attrs$ = node.vattrs;
290
+ vnode.$children$ = node.vchildren;
291
+ vnode.$key$ = node.vkey;
292
+ vnode.$name$ = node.vname;
293
+ return vnode;
294
+ };
217
295
  /**
218
296
  * Production setAccessor() function based on Preact by
219
297
  * Jason Miller (@developit)
@@ -224,6 +302,7 @@ const isHost = (node) => node && node.$tag$ === Host;
224
302
  */
225
303
  const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
226
304
  if (oldValue !== newValue) {
305
+ let isProp = isMemberInElement(elm, memberName);
227
306
  memberName.toLowerCase();
228
307
  if (memberName === 'class') {
229
308
  const classList = elm.classList;
@@ -232,6 +311,47 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
232
311
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
233
312
  classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
234
313
  }
314
+ else if (memberName === 'ref') {
315
+ // minifier will clean this up
316
+ if (newValue) {
317
+ newValue(elm);
318
+ }
319
+ }
320
+ else {
321
+ // Set property if it exists and it's not a SVG
322
+ const isComplex = isComplexType(newValue);
323
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
324
+ try {
325
+ if (!elm.tagName.includes('-')) {
326
+ const n = newValue == null ? '' : newValue;
327
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
328
+ if (memberName === 'list') {
329
+ isProp = false;
330
+ }
331
+ else if (oldValue == null || elm[memberName] != n) {
332
+ elm[memberName] = n;
333
+ }
334
+ }
335
+ else {
336
+ elm[memberName] = newValue;
337
+ }
338
+ }
339
+ catch (e) { }
340
+ }
341
+ if (newValue == null || newValue === false) {
342
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
343
+ {
344
+ elm.removeAttribute(memberName);
345
+ }
346
+ }
347
+ }
348
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
349
+ newValue = newValue === true ? '' : newValue;
350
+ {
351
+ elm.setAttribute(memberName, newValue);
352
+ }
353
+ }
354
+ }
235
355
  }
236
356
  };
237
357
  const parseClassListRegex = /\s/;
@@ -249,13 +369,13 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
249
369
  // remove attributes no longer present on the vnode by setting them to undefined
250
370
  for (memberName in oldVnodeAttrs) {
251
371
  if (!(memberName in newVnodeAttrs)) {
252
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined);
372
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
253
373
  }
254
374
  }
255
375
  }
256
376
  // add new & update changed attributes
257
377
  for (memberName in newVnodeAttrs) {
258
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName]);
378
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
259
379
  }
260
380
  };
261
381
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
@@ -264,12 +384,39 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
264
384
  let i = 0;
265
385
  let elm;
266
386
  let childNode;
267
- {
387
+ let oldVNode;
388
+ if (!useNativeShadowDom) {
389
+ // remember for later we need to check to relocate nodes
390
+ checkSlotRelocate = true;
391
+ if (newVNode.$tag$ === 'slot') {
392
+ if (scopeId) {
393
+ // scoped css needs to add its scoped id to the parent element
394
+ parentElm.classList.add(scopeId + '-s');
395
+ }
396
+ newVNode.$flags$ |= newVNode.$children$
397
+ ? // slot element has fallback content
398
+ 2 /* isSlotFallback */
399
+ : // slot element does not have fallback content
400
+ 1 /* isSlotReference */;
401
+ }
402
+ }
403
+ if (newVNode.$text$ !== null) {
404
+ // create text node
405
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
406
+ }
407
+ else if (newVNode.$flags$ & 1 /* isSlotReference */) {
408
+ // create a slot reference node
409
+ elm = newVNode.$elm$ =
410
+ doc.createTextNode('');
411
+ }
412
+ else {
268
413
  // create element
269
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
414
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
415
+ ? 'slot-fb'
416
+ : newVNode.$tag$));
270
417
  // add css classes, attrs, props, listeners, etc.
271
418
  {
272
- updateElement(null, newVNode);
419
+ updateElement(null, newVNode, isSvgMode);
273
420
  }
274
421
  if (isDef(scopeId) && elm['s-si'] !== scopeId) {
275
422
  // if there is a scopeId and this is the initial render
@@ -279,7 +426,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
279
426
  if (newVNode.$children$) {
280
427
  for (i = 0; i < newVNode.$children$.length; ++i) {
281
428
  // create the node
282
- childNode = createElm(oldParentVNode, newVNode, i);
429
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
283
430
  // return node could have been null
284
431
  if (childNode) {
285
432
  // append our new node
@@ -288,20 +435,62 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
288
435
  }
289
436
  }
290
437
  }
438
+ {
439
+ elm['s-hn'] = hostTagName;
440
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
441
+ // remember the content reference comment
442
+ elm['s-sr'] = true;
443
+ // remember the content reference comment
444
+ elm['s-cr'] = contentRef;
445
+ // remember the slot name, or empty string for default slot
446
+ elm['s-sn'] = newVNode.$name$ || '';
447
+ // check if we've got an old vnode for this slot
448
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
449
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
450
+ // we've got an old slot vnode and the wrapper is being replaced
451
+ // so let's move the old slot content back to it's original location
452
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
453
+ }
454
+ }
455
+ }
291
456
  return elm;
292
457
  };
458
+ const putBackInOriginalLocation = (parentElm, recursive) => {
459
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
460
+ const oldSlotChildNodes = parentElm.childNodes;
461
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
462
+ const childNode = oldSlotChildNodes[i];
463
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
464
+ // // this child node in the old element is from another component
465
+ // // remove this node from the old slot's parent
466
+ // childNode.remove();
467
+ // and relocate it back to it's original location
468
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
469
+ // remove the old original location comment entirely
470
+ // later on the patch function will know what to do
471
+ // and move this to the correct spot in need be
472
+ childNode['s-ol'].remove();
473
+ childNode['s-ol'] = undefined;
474
+ checkSlotRelocate = true;
475
+ }
476
+ if (recursive) {
477
+ putBackInOriginalLocation(childNode, recursive);
478
+ }
479
+ }
480
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
481
+ };
293
482
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
294
- let containerElm = (parentElm);
483
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
295
484
  let childNode;
296
485
  if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
297
486
  containerElm = containerElm.shadowRoot;
298
487
  }
299
488
  for (; startIdx <= endIdx; ++startIdx) {
300
489
  if (vnodes[startIdx]) {
301
- childNode = createElm(null, parentVNode, startIdx);
490
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
302
491
  if (childNode) {
303
492
  vnodes[startIdx].$elm$ = childNode;
304
- containerElm.insertBefore(childNode, before);
493
+ containerElm.insertBefore(childNode, referenceNode(before) );
305
494
  }
306
495
  }
307
496
  }
@@ -310,6 +499,21 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
310
499
  for (; startIdx <= endIdx; ++startIdx) {
311
500
  if ((vnode = vnodes[startIdx])) {
312
501
  elm = vnode.$elm$;
502
+ callNodeRefs(vnode);
503
+ {
504
+ // we're removing this element
505
+ // so it's possible we need to show slot fallback content now
506
+ checkSlotFallbackVisibility = true;
507
+ if (elm['s-ol']) {
508
+ // remove the original location comment
509
+ elm['s-ol'].remove();
510
+ }
511
+ else {
512
+ // it's possible that child nodes of the node
513
+ // that's being removed are slot nodes
514
+ putBackInOriginalLocation(elm, true);
515
+ }
516
+ }
313
517
  // remove the vnode's element from the dom
314
518
  elm.remove();
315
519
  }
@@ -350,12 +554,20 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
350
554
  newEndVnode = newCh[--newEndIdx];
351
555
  }
352
556
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
557
+ // Vnode moved right
558
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
559
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
560
+ }
353
561
  patch(oldStartVnode, newEndVnode);
354
562
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
355
563
  oldStartVnode = oldCh[++oldStartIdx];
356
564
  newEndVnode = newCh[--newEndIdx];
357
565
  }
358
566
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
567
+ // Vnode moved left
568
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
569
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
570
+ }
359
571
  patch(oldEndVnode, newStartVnode);
360
572
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
361
573
  oldEndVnode = oldCh[--oldEndIdx];
@@ -364,12 +576,12 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
364
576
  else {
365
577
  {
366
578
  // new element
367
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
579
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
368
580
  newStartVnode = newCh[++newStartIdx];
369
581
  }
370
582
  if (node) {
371
583
  {
372
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
584
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
373
585
  }
374
586
  }
375
587
  }
@@ -385,16 +597,29 @@ const isSameVnode = (vnode1, vnode2) => {
385
597
  // compare if two vnode to see if they're "technically" the same
386
598
  // need to have the same element tag, and same key to be the same
387
599
  if (vnode1.$tag$ === vnode2.$tag$) {
600
+ if (vnode1.$tag$ === 'slot') {
601
+ return vnode1.$name$ === vnode2.$name$;
602
+ }
388
603
  return true;
389
604
  }
390
605
  return false;
391
606
  };
607
+ const referenceNode = (node) => {
608
+ // this node was relocated to a new location in the dom
609
+ // because of some other component's slot
610
+ // but we still have an html comment in place of where
611
+ // it's original location was according to it's original vdom
612
+ return (node && node['s-ol']) || node;
613
+ };
614
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
392
615
  const patch = (oldVNode, newVNode) => {
393
616
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
394
617
  const oldChildren = oldVNode.$children$;
395
618
  const newChildren = newVNode.$children$;
396
619
  const tag = newVNode.$tag$;
397
- {
620
+ const text = newVNode.$text$;
621
+ let defaultHolder;
622
+ if (text === null) {
398
623
  // element node
399
624
  {
400
625
  if (tag === 'slot')
@@ -403,7 +628,7 @@ const patch = (oldVNode, newVNode) => {
403
628
  // either this is the first render of an element OR it's an update
404
629
  // AND we already know it's possible it could have changed
405
630
  // this updates the element's css classes, attrs, props, listeners, etc.
406
- updateElement(oldVNode, newVNode);
631
+ updateElement(oldVNode, newVNode, isSvgMode);
407
632
  }
408
633
  }
409
634
  if (oldChildren !== null && newChildren !== null) {
@@ -411,6 +636,11 @@ const patch = (oldVNode, newVNode) => {
411
636
  updateChildren(elm, oldChildren, newVNode, newChildren);
412
637
  }
413
638
  else if (newChildren !== null) {
639
+ // no old child vnodes, but there are new child vnodes to add
640
+ if (oldVNode.$text$ !== null) {
641
+ // the old vnode was text, so be sure to clear it out
642
+ elm.textContent = '';
643
+ }
414
644
  // add the new vnode children
415
645
  addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
416
646
  }
@@ -419,9 +649,156 @@ const patch = (oldVNode, newVNode) => {
419
649
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
420
650
  }
421
651
  }
652
+ else if ((defaultHolder = elm['s-cr'])) {
653
+ // this element has slotted content
654
+ defaultHolder.parentNode.textContent = text;
655
+ }
656
+ else if (oldVNode.$text$ !== text) {
657
+ // update the text content for the text only vnode
658
+ // and also only if the text is different than before
659
+ elm.data = text;
660
+ }
661
+ };
662
+ const updateFallbackSlotVisibility = (elm) => {
663
+ // tslint:disable-next-line: prefer-const
664
+ const childNodes = elm.childNodes;
665
+ let childNode;
666
+ let i;
667
+ let ilen;
668
+ let j;
669
+ let slotNameAttr;
670
+ let nodeType;
671
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
672
+ childNode = childNodes[i];
673
+ if (childNode.nodeType === 1 /* ElementNode */) {
674
+ if (childNode['s-sr']) {
675
+ // this is a slot fallback node
676
+ // get the slot name for this slot reference node
677
+ slotNameAttr = childNode['s-sn'];
678
+ // by default always show a fallback slot node
679
+ // then hide it if there are other slots in the light dom
680
+ childNode.hidden = false;
681
+ for (j = 0; j < ilen; j++) {
682
+ nodeType = childNodes[j].nodeType;
683
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
684
+ // this sibling node is from a different component OR is a named fallback slot node
685
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
686
+ childNode.hidden = true;
687
+ break;
688
+ }
689
+ }
690
+ else {
691
+ // this is a default fallback slot node
692
+ // any element or text node (with content)
693
+ // should hide the default fallback slot node
694
+ if (nodeType === 1 /* ElementNode */ ||
695
+ (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
696
+ childNode.hidden = true;
697
+ break;
698
+ }
699
+ }
700
+ }
701
+ }
702
+ // keep drilling down
703
+ updateFallbackSlotVisibility(childNode);
704
+ }
705
+ }
706
+ };
707
+ const relocateNodes = [];
708
+ const relocateSlotContent = (elm) => {
709
+ // tslint:disable-next-line: prefer-const
710
+ let childNode;
711
+ let node;
712
+ let hostContentNodes;
713
+ let slotNameAttr;
714
+ let relocateNodeData;
715
+ let j;
716
+ let i = 0;
717
+ const childNodes = elm.childNodes;
718
+ const ilen = childNodes.length;
719
+ for (; i < ilen; i++) {
720
+ childNode = childNodes[i];
721
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
722
+ // first got the content reference comment node
723
+ // then we got it's parent, which is where all the host content is in now
724
+ hostContentNodes = node.parentNode.childNodes;
725
+ slotNameAttr = childNode['s-sn'];
726
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
727
+ node = hostContentNodes[j];
728
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
729
+ // let's do some relocating to its new home
730
+ // but never relocate a content reference node
731
+ // that is suppose to always represent the original content location
732
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
733
+ // it's possible we've already decided to relocate this node
734
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
735
+ // made some changes to slots
736
+ // let's make sure we also double check
737
+ // fallbacks are correctly hidden or shown
738
+ checkSlotFallbackVisibility = true;
739
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
740
+ if (relocateNodeData) {
741
+ // previously we never found a slot home for this node
742
+ // but turns out we did, so let's remember it now
743
+ relocateNodeData.$slotRefNode$ = childNode;
744
+ }
745
+ else {
746
+ // add to our list of nodes to relocate
747
+ relocateNodes.push({
748
+ $slotRefNode$: childNode,
749
+ $nodeToRelocate$: node,
750
+ });
751
+ }
752
+ if (node['s-sr']) {
753
+ relocateNodes.map((relocateNode) => {
754
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
755
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
756
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
757
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
758
+ }
759
+ }
760
+ });
761
+ }
762
+ }
763
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
764
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
765
+ // if we never find a home for this element then we'll need to hide it
766
+ relocateNodes.push({
767
+ $nodeToRelocate$: node,
768
+ });
769
+ }
770
+ }
771
+ }
772
+ }
773
+ if (childNode.nodeType === 1 /* ElementNode */) {
774
+ relocateSlotContent(childNode);
775
+ }
776
+ }
777
+ };
778
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
779
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
780
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
781
+ return true;
782
+ }
783
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
784
+ return true;
785
+ }
786
+ return false;
787
+ }
788
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
789
+ return true;
790
+ }
791
+ return slotNameAttr === '';
792
+ };
793
+ const callNodeRefs = (vNode) => {
794
+ {
795
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
796
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
797
+ }
422
798
  };
423
799
  const renderVdom = (hostRef, renderFnResults) => {
424
800
  const hostElm = hostRef.$hostElement$;
801
+ const cmpMeta = hostRef.$cmpMeta$;
425
802
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
426
803
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
427
804
  hostTagName = hostElm.tagName;
@@ -432,8 +809,104 @@ const renderVdom = (hostRef, renderFnResults) => {
432
809
  {
433
810
  scopeId = hostElm['s-sc'];
434
811
  }
812
+ {
813
+ contentRef = hostElm['s-cr'];
814
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
815
+ // always reset
816
+ checkSlotFallbackVisibility = false;
817
+ }
435
818
  // synchronous patch
436
819
  patch(oldVNode, rootVnode);
820
+ {
821
+ // while we're moving nodes around existing nodes, temporarily disable
822
+ // the disconnectCallback from working
823
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
824
+ if (checkSlotRelocate) {
825
+ relocateSlotContent(rootVnode.$elm$);
826
+ let relocateData;
827
+ let nodeToRelocate;
828
+ let orgLocationNode;
829
+ let parentNodeRef;
830
+ let insertBeforeNode;
831
+ let refNode;
832
+ let i = 0;
833
+ for (; i < relocateNodes.length; i++) {
834
+ relocateData = relocateNodes[i];
835
+ nodeToRelocate = relocateData.$nodeToRelocate$;
836
+ if (!nodeToRelocate['s-ol']) {
837
+ // add a reference node marking this node's original location
838
+ // keep a reference to this node for later lookups
839
+ orgLocationNode =
840
+ doc.createTextNode('');
841
+ orgLocationNode['s-nr'] = nodeToRelocate;
842
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
843
+ }
844
+ }
845
+ for (i = 0; i < relocateNodes.length; i++) {
846
+ relocateData = relocateNodes[i];
847
+ nodeToRelocate = relocateData.$nodeToRelocate$;
848
+ if (relocateData.$slotRefNode$) {
849
+ // by default we're just going to insert it directly
850
+ // after the slot reference node
851
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
852
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
853
+ orgLocationNode = nodeToRelocate['s-ol'];
854
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
855
+ refNode = orgLocationNode['s-nr'];
856
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
857
+ refNode = refNode.nextSibling;
858
+ if (!refNode || !refNode['s-nr']) {
859
+ insertBeforeNode = refNode;
860
+ break;
861
+ }
862
+ }
863
+ }
864
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
865
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
866
+ // we've checked that it's worth while to relocate
867
+ // since that the node to relocate
868
+ // has a different next sibling or parent relocated
869
+ if (nodeToRelocate !== insertBeforeNode) {
870
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
871
+ // probably a component in the index.html that doesn't have it's hostname set
872
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
873
+ }
874
+ // add it back to the dom but in its new home
875
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
876
+ }
877
+ }
878
+ }
879
+ else {
880
+ // this node doesn't have a slot home to go to, so let's hide it
881
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
882
+ nodeToRelocate.hidden = true;
883
+ }
884
+ }
885
+ }
886
+ }
887
+ if (checkSlotFallbackVisibility) {
888
+ updateFallbackSlotVisibility(rootVnode.$elm$);
889
+ }
890
+ // done moving nodes around
891
+ // allow the disconnect callback to work again
892
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
893
+ // always reset
894
+ relocateNodes.length = 0;
895
+ }
896
+ };
897
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
898
+ const createEvent = (ref, name, flags) => {
899
+ const elm = getElement(ref);
900
+ return {
901
+ emit: (detail) => {
902
+ return emitEvent(elm, name, {
903
+ bubbles: !!(flags & 4 /* Bubbles */),
904
+ composed: !!(flags & 2 /* Composed */),
905
+ cancelable: !!(flags & 1 /* Cancellable */),
906
+ detail,
907
+ });
908
+ },
909
+ };
437
910
  };
438
911
  /**
439
912
  * Helper function to create & dispatch a custom Event on a provided target
@@ -471,6 +944,18 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
471
944
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
472
945
  const instance = hostRef.$lazyInstance$ ;
473
946
  let promise;
947
+ if (isInitialLoad) {
948
+ {
949
+ hostRef.$flags$ |= 256 /* isListenReady */;
950
+ if (hostRef.$queuedListeners$) {
951
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
952
+ hostRef.$queuedListeners$ = null;
953
+ }
954
+ }
955
+ }
956
+ {
957
+ promise = then(promise, () => safeCall(instance, 'componentWillRender'));
958
+ }
474
959
  endSchedule();
475
960
  return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
476
961
  };
@@ -580,6 +1065,17 @@ const appDidLoad = (who) => {
580
1065
  }
581
1066
  nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
582
1067
  };
1068
+ const safeCall = (instance, method, arg) => {
1069
+ if (instance && instance[method]) {
1070
+ try {
1071
+ return instance[method](arg);
1072
+ }
1073
+ catch (e) {
1074
+ consoleError(e);
1075
+ }
1076
+ }
1077
+ return undefined;
1078
+ };
583
1079
  const then = (promise, thenFn) => {
584
1080
  return promise && promise.then ? promise.then(thenFn) : thenFn();
585
1081
  };
@@ -611,6 +1107,15 @@ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
611
1107
  const parsePropertyValue = (propValue, propType) => {
612
1108
  // ensure this value is of the correct prop type
613
1109
  if (propValue != null && !isComplexType(propValue)) {
1110
+ if (propType & 4 /* Boolean */) {
1111
+ // per the HTML spec, any string value means it is a boolean true value
1112
+ // but we'll cheat here and say that the string "false" is the boolean false
1113
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
1114
+ }
1115
+ if (propType & 2 /* Number */) {
1116
+ // force it to be a number
1117
+ return parseFloat(propValue);
1118
+ }
614
1119
  if (propType & 1 /* String */) {
615
1120
  // could have been passed as a number or boolean
616
1121
  // but we still want it as a string
@@ -640,6 +1145,11 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
640
1145
  hostRef.$instanceValues$.set(propName, newVal);
641
1146
  if (instance) {
642
1147
  if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1148
+ if (instance.componentShouldUpdate) {
1149
+ if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1150
+ return;
1151
+ }
1152
+ }
643
1153
  // looks like this value actually changed, so we've got work to do!
644
1154
  // but only if we've already rendered, otherwise just chill out
645
1155
  // queue that we need to do an update, but don't worry about queuing
@@ -815,6 +1325,15 @@ const connectedCallback = (elm) => {
815
1325
  if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
816
1326
  // first time this component has connected
817
1327
  hostRef.$flags$ |= 1 /* hasConnected */;
1328
+ {
1329
+ // initUpdate
1330
+ // if the slot polyfill is required we'll need to put some nodes
1331
+ // in here to act as original content anchors as we move nodes around
1332
+ // host element has been connected to the DOM
1333
+ if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1334
+ setContentReference(elm);
1335
+ }
1336
+ }
818
1337
  {
819
1338
  // find the first ancestor component (if there is one) and register
820
1339
  // this component as one of the actively loading child components for its ancestor
@@ -845,12 +1364,35 @@ const connectedCallback = (elm) => {
845
1364
  initializeComponent(elm, hostRef, cmpMeta);
846
1365
  }
847
1366
  }
1367
+ else {
1368
+ // not the first time this has connected
1369
+ // reattach any event listeners to the host
1370
+ // since they would have been removed when disconnected
1371
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1372
+ }
848
1373
  endConnected();
849
1374
  }
850
1375
  };
1376
+ const setContentReference = (elm) => {
1377
+ // only required when we're NOT using native shadow dom (slot)
1378
+ // or this browser doesn't support native shadow dom
1379
+ // and this host element was NOT created with SSR
1380
+ // let's pick out the inner content for slot projection
1381
+ // create a node to represent where the original
1382
+ // content was first placed, which is useful later on
1383
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1384
+ contentRefElm['s-cn'] = true;
1385
+ elm.insertBefore(contentRefElm, elm.firstChild);
1386
+ };
851
1387
  const disconnectedCallback = (elm) => {
852
1388
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
853
- getHostRef(elm);
1389
+ const hostRef = getHostRef(elm);
1390
+ {
1391
+ if (hostRef.$rmListeners$) {
1392
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1393
+ hostRef.$rmListeners$ = undefined;
1394
+ }
1395
+ }
854
1396
  }
855
1397
  };
856
1398
  const bootstrapLazy = (lazyBundles, options = {}) => {
@@ -877,6 +1419,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
877
1419
  {
878
1420
  cmpMeta.$members$ = compactMeta[2];
879
1421
  }
1422
+ {
1423
+ cmpMeta.$listeners$ = compactMeta[3];
1424
+ }
880
1425
  const tagName = cmpMeta.$tagName$;
881
1426
  const HostElement = class extends HTMLElement {
882
1427
  // StencilLazyHost
@@ -957,8 +1502,10 @@ const registerHost = (elm, cmpMeta) => {
957
1502
  elm['s-p'] = [];
958
1503
  elm['s-rc'] = [];
959
1504
  }
1505
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
960
1506
  return hostRefs.set(elm, hostRef);
961
1507
  };
1508
+ const isMemberInElement = (elm, memberName) => memberName in elm;
962
1509
  const consoleError = (e, el) => (0, console.error)(e, el);
963
1510
  const cmpModules = /*@__PURE__*/ new Map();
964
1511
  const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
@@ -1026,7 +1573,10 @@ const flush = () => {
1026
1573
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1027
1574
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1028
1575
 
1576
+ exports.Host = Host;
1029
1577
  exports.bootstrapLazy = bootstrapLazy;
1578
+ exports.createEvent = createEvent;
1579
+ exports.getElement = getElement;
1030
1580
  exports.h = h;
1031
1581
  exports.promiseResolve = promiseResolve;
1032
1582
  exports.registerInstance = registerInstance;