@paperless/core 0.1.0-alpha.2 → 0.1.0-alpha.20

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 (147) hide show
  1. package/CHANGELOG.md +180 -0
  2. package/README.md +18 -1
  3. package/dist/assets/images/avatar/company-default.svg +12 -0
  4. package/dist/assets/images/avatar/user-default.svg +12 -0
  5. package/dist/assets/images/helper/helper-hover.svg +15 -0
  6. package/dist/assets/images/helper/helper.svg +15 -0
  7. package/dist/build/{p-1d13a9d2.entry.js → p-14ceb308.entry.js} +1 -1
  8. package/dist/build/p-17c11169.entry.js +1 -0
  9. package/dist/build/p-42dab9d4.entry.js +1 -0
  10. package/dist/build/p-47b52f92.entry.js +1 -0
  11. package/dist/build/p-5ec6ea71.entry.js +1 -0
  12. package/dist/build/p-76464e0b.js +2 -0
  13. package/dist/build/{p-feec8ec1.entry.js → p-8501ba07.entry.js} +1 -1
  14. package/dist/build/p-aae3d4f0.entry.js +1 -0
  15. package/dist/build/p-adcb0b93.entry.js +1 -0
  16. package/dist/build/p-bbec0e86.entry.js +1 -0
  17. package/dist/build/p-d23e4d57.entry.js +1 -0
  18. package/dist/build/p-f65d7bbf.entry.js +1 -0
  19. package/dist/build/paperless.esm.js +1 -1
  20. package/dist/cjs/{index-5b30cb95.js → index-a46a39a5.js} +494 -9
  21. package/dist/cjs/loader.cjs.js +2 -2
  22. package/dist/cjs/{p-loader.cjs.entry.js → p-avatar.cjs.entry.js} +13 -38
  23. package/dist/cjs/{p-icon.cjs.entry.js → p-button_3.cjs.entry.js} +108 -5
  24. package/dist/cjs/p-counter.cjs.entry.js +19 -0
  25. package/dist/cjs/p-divider.cjs.entry.js +19 -0
  26. package/dist/cjs/{p-button.cjs.entry.js → p-helper.cjs.entry.js} +6 -10
  27. package/dist/cjs/p-illustration.cjs.entry.js +9 -12
  28. package/dist/cjs/p-info-panel.cjs.entry.js +31 -0
  29. package/dist/cjs/p-navigation-item.cjs.entry.js +23 -0
  30. package/dist/cjs/p-pagination-item.cjs.entry.js +23 -0
  31. package/dist/cjs/p-pagination.cjs.entry.js +167 -0
  32. package/dist/cjs/p-tooltip.cjs.entry.js +62 -20
  33. package/dist/cjs/paperless.cjs.js +2 -2
  34. package/dist/collection/assets/images/avatar/company-default.svg +12 -0
  35. package/dist/collection/assets/images/avatar/user-default.svg +12 -0
  36. package/dist/collection/assets/images/helper/helper-hover.svg +15 -0
  37. package/dist/collection/assets/images/helper/helper.svg +15 -0
  38. package/dist/collection/collection-manifest.json +9 -1
  39. package/dist/collection/components/atoms/avatar/avatar.component.css +31 -0
  40. package/dist/collection/components/atoms/avatar/avatar.component.js +105 -0
  41. package/dist/collection/components/atoms/button/button.component.css +68 -3
  42. package/dist/collection/components/atoms/button/button.component.js +241 -7
  43. package/dist/collection/components/atoms/counter/counter.component.css +5 -0
  44. package/dist/collection/components/atoms/counter/counter.component.js +15 -0
  45. package/dist/collection/components/atoms/divider/divider.component.css +3 -0
  46. package/dist/collection/components/atoms/divider/divider.component.js +14 -0
  47. package/dist/collection/components/atoms/helper/helper.component.css +7 -0
  48. package/dist/collection/components/atoms/helper/helper.component.js +18 -0
  49. package/dist/collection/components/atoms/icon/icon.component.js +2 -7
  50. package/dist/collection/components/atoms/illustration/illustration.component.js +2 -9
  51. package/dist/collection/components/atoms/info-panel/info-panel.component.css +28 -0
  52. package/dist/collection/components/atoms/info-panel/info-panel.component.js +106 -0
  53. package/dist/collection/components/atoms/loader/loader.component.js +1 -1
  54. package/dist/collection/components/atoms/pagination-item/pagination-item.component.css +16 -0
  55. package/dist/collection/components/atoms/pagination-item/pagination-item.component.js +41 -0
  56. package/dist/collection/components/atoms/tooltip/tooltip.component.css +15 -12
  57. package/dist/collection/components/atoms/tooltip/tooltip.component.js +122 -32
  58. package/dist/collection/components/molecules/navigation-item/navigation-item.component.css +28 -0
  59. package/dist/collection/components/molecules/navigation-item/navigation-item.component.js +118 -0
  60. package/dist/collection/components/molecules/pagination/pagination.component.css +3 -0
  61. package/dist/collection/components/molecules/pagination/pagination.component.js +238 -0
  62. package/dist/collection/components/molecules/pagination/pagination.value-accessor.js +6 -0
  63. package/dist/collection/tailwind/border-radius.js +1 -0
  64. package/dist/collection/tailwind/grid.js +24 -4
  65. package/dist/collection/tailwind.config.js +1 -1
  66. package/dist/collection/value-accessors.config.js +5 -0
  67. package/dist/components/counter.component.js +30 -0
  68. package/dist/{esm/p-icon.entry.js → components/icon.component.js} +26 -11
  69. package/dist/components/index.d.ts +8 -0
  70. package/dist/components/index.js +8 -0
  71. package/dist/{esm/p-loader.entry.js → components/loader.component.js} +30 -9
  72. package/dist/components/p-avatar.d.ts +11 -0
  73. package/dist/components/p-avatar.js +52 -0
  74. package/dist/components/p-button.js +67 -8
  75. package/dist/components/p-counter.d.ts +11 -0
  76. package/dist/components/p-counter.js +6 -0
  77. package/dist/components/p-divider.d.ts +11 -0
  78. package/dist/components/p-divider.js +33 -0
  79. package/dist/components/p-helper.d.ts +11 -0
  80. package/dist/components/p-helper.js +39 -0
  81. package/dist/components/p-icon.js +1 -815
  82. package/dist/components/p-illustration.js +0 -4
  83. package/dist/components/p-info-panel.d.ts +11 -0
  84. package/dist/components/p-info-panel.js +56 -0
  85. package/dist/components/p-loader.js +1 -72
  86. package/dist/components/p-navigation-item.d.ts +11 -0
  87. package/dist/components/p-navigation-item.js +55 -0
  88. package/dist/components/p-pagination-item.d.ts +11 -0
  89. package/dist/components/p-pagination-item.js +6 -0
  90. package/dist/components/p-pagination.d.ts +11 -0
  91. package/dist/components/p-pagination.js +196 -0
  92. package/dist/components/p-tooltip.js +1 -1886
  93. package/dist/components/pagination-item.component.js +36 -0
  94. package/dist/components/tooltip.component.js +1932 -0
  95. package/dist/esm/{index-111a6307.js → index-a68e547b.js} +494 -10
  96. package/dist/esm/loader.js +2 -2
  97. package/dist/esm/p-avatar.entry.js +28 -0
  98. package/dist/esm/p-button_3.entry.js +899 -0
  99. package/dist/esm/p-counter.entry.js +15 -0
  100. package/dist/esm/p-divider.entry.js +15 -0
  101. package/dist/esm/{p-button.entry.js → p-helper.entry.js} +6 -10
  102. package/dist/esm/p-illustration.entry.js +9 -12
  103. package/dist/esm/p-info-panel.entry.js +27 -0
  104. package/dist/esm/p-navigation-item.entry.js +19 -0
  105. package/dist/esm/p-pagination-item.entry.js +19 -0
  106. package/dist/esm/p-pagination.entry.js +163 -0
  107. package/dist/esm/p-tooltip.entry.js +62 -20
  108. package/dist/esm/paperless.js +2 -2
  109. package/dist/index.html +1 -1
  110. package/dist/paperless/{p-1d13a9d2.entry.js → p-14ceb308.entry.js} +1 -1
  111. package/dist/paperless/p-17c11169.entry.js +1 -0
  112. package/dist/paperless/p-42dab9d4.entry.js +1 -0
  113. package/dist/paperless/p-47b52f92.entry.js +1 -0
  114. package/dist/paperless/p-5ec6ea71.entry.js +1 -0
  115. package/dist/paperless/p-76464e0b.js +2 -0
  116. package/dist/paperless/{p-feec8ec1.entry.js → p-8501ba07.entry.js} +1 -1
  117. package/dist/paperless/p-aae3d4f0.entry.js +1 -0
  118. package/dist/paperless/p-adcb0b93.entry.js +1 -0
  119. package/dist/paperless/p-bbec0e86.entry.js +1 -0
  120. package/dist/paperless/p-d23e4d57.entry.js +1 -0
  121. package/dist/paperless/p-f65d7bbf.entry.js +1 -0
  122. package/dist/paperless/paperless.css +96 -0
  123. package/dist/paperless/paperless.esm.js +1 -1
  124. package/dist/sw.js +248 -51
  125. package/dist/tailwind.config.js +1 -1
  126. package/dist/types/components/atoms/avatar/avatar.component.d.ts +21 -0
  127. package/dist/types/components/atoms/button/button.component.d.ts +45 -1
  128. package/dist/types/components/atoms/counter/counter.component.d.ts +3 -0
  129. package/dist/types/components/atoms/divider/divider.component.d.ts +3 -0
  130. package/dist/types/components/atoms/helper/helper.component.d.ts +3 -0
  131. package/dist/types/components/atoms/info-panel/info-panel.component.d.ts +24 -0
  132. package/dist/types/components/atoms/pagination-item/pagination-item.component.d.ts +7 -0
  133. package/dist/types/components/atoms/tooltip/tooltip.component.d.ts +20 -8
  134. package/dist/types/components/molecules/navigation-item/navigation-item.component.d.ts +24 -0
  135. package/dist/types/components/molecules/pagination/pagination.component.d.ts +28 -0
  136. package/dist/types/components/molecules/pagination/pagination.value-accessor.d.ts +2 -0
  137. package/dist/types/components.d.ts +358 -16
  138. package/dist/types/value-accessors.config.d.ts +2 -0
  139. package/package.json +1 -1
  140. package/dist/build/p-208c1f28.entry.js +0 -1
  141. package/dist/build/p-98d07776.js +0 -2
  142. package/dist/build/p-bbd1d3df.entry.js +0 -1
  143. package/dist/build/p-cd525dcc.entry.js +0 -1
  144. package/dist/paperless/p-208c1f28.entry.js +0 -1
  145. package/dist/paperless/p-98d07776.js +0 -2
  146. package/dist/paperless/p-bbd1d3df.entry.js +0 -1
  147. package/dist/paperless/p-cd525dcc.entry.js +0 -1
@@ -23,7 +23,11 @@ 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;
27
31
  let isSvgMode = false;
28
32
  let queuePending = false;
29
33
  const win = typeof window !== 'undefined' ? window : {};
@@ -50,7 +54,7 @@ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
50
54
  const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
51
55
  if (listeners) {
52
56
  listeners.map(([flags, name, method]) => {
53
- const target = elm;
57
+ const target = getHostListenerTarget(elm, flags) ;
54
58
  const handler = hostListenerProxy(hostRef, method);
55
59
  const opts = hostListenerOpts(flags);
56
60
  plt.ael(target, name, handler, opts);
@@ -74,6 +78,11 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
74
78
  consoleError(e);
75
79
  }
76
80
  };
81
+ const getHostListenerTarget = (elm, flags) => {
82
+ if (flags & 4 /* TargetDocument */)
83
+ return doc;
84
+ return elm;
85
+ };
77
86
  // prettier-ignore
78
87
  const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
79
88
  const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
@@ -183,6 +192,7 @@ const isComplexType = (o) => {
183
192
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
184
193
  const h = (nodeName, vnodeData, ...children) => {
185
194
  let child = null;
195
+ let slotName = null;
186
196
  let simple = false;
187
197
  let lastSimple = false;
188
198
  const vNodeChildren = [];
@@ -210,6 +220,9 @@ const h = (nodeName, vnodeData, ...children) => {
210
220
  };
211
221
  walk(children);
212
222
  if (vnodeData) {
223
+ if (vnodeData.name) {
224
+ slotName = vnodeData.name;
225
+ }
213
226
  {
214
227
  const classData = vnodeData.className || vnodeData.class;
215
228
  if (classData) {
@@ -222,11 +235,18 @@ const h = (nodeName, vnodeData, ...children) => {
222
235
  }
223
236
  }
224
237
  }
238
+ if (typeof nodeName === 'function') {
239
+ // nodeName is a functional component
240
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
241
+ }
225
242
  const vnode = newVNode(nodeName, null);
226
243
  vnode.$attrs$ = vnodeData;
227
244
  if (vNodeChildren.length > 0) {
228
245
  vnode.$children$ = vNodeChildren;
229
246
  }
247
+ {
248
+ vnode.$name$ = slotName;
249
+ }
230
250
  return vnode;
231
251
  };
232
252
  const newVNode = (tag, text) => {
@@ -240,10 +260,43 @@ const newVNode = (tag, text) => {
240
260
  {
241
261
  vnode.$attrs$ = null;
242
262
  }
263
+ {
264
+ vnode.$name$ = null;
265
+ }
243
266
  return vnode;
244
267
  };
245
268
  const Host = {};
246
269
  const isHost = (node) => node && node.$tag$ === Host;
270
+ const vdomFnUtils = {
271
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
272
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
273
+ };
274
+ const convertToPublic = (node) => ({
275
+ vattrs: node.$attrs$,
276
+ vchildren: node.$children$,
277
+ vkey: node.$key$,
278
+ vname: node.$name$,
279
+ vtag: node.$tag$,
280
+ vtext: node.$text$,
281
+ });
282
+ const convertToPrivate = (node) => {
283
+ if (typeof node.vtag === 'function') {
284
+ const vnodeData = Object.assign({}, node.vattrs);
285
+ if (node.vkey) {
286
+ vnodeData.key = node.vkey;
287
+ }
288
+ if (node.vname) {
289
+ vnodeData.name = node.vname;
290
+ }
291
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
292
+ }
293
+ const vnode = newVNode(node.vtag, node.vtext);
294
+ vnode.$attrs$ = node.vattrs;
295
+ vnode.$children$ = node.vchildren;
296
+ vnode.$key$ = node.vkey;
297
+ vnode.$name$ = node.vname;
298
+ return vnode;
299
+ };
247
300
  /**
248
301
  * Production setAccessor() function based on Preact by
249
302
  * Jason Miller (@developit)
@@ -255,7 +308,7 @@ const isHost = (node) => node && node.$tag$ === Host;
255
308
  const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
256
309
  if (oldValue !== newValue) {
257
310
  let isProp = isMemberInElement(elm, memberName);
258
- memberName.toLowerCase();
311
+ let ln = memberName.toLowerCase();
259
312
  if (memberName === 'class') {
260
313
  const classList = elm.classList;
261
314
  const oldClasses = parseClassList(oldValue);
@@ -269,6 +322,45 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
269
322
  newValue(elm);
270
323
  }
271
324
  }
325
+ else if ((!isProp ) &&
326
+ memberName[0] === 'o' &&
327
+ memberName[1] === 'n') {
328
+ // Event Handlers
329
+ // so if the member name starts with "on" and the 3rd characters is
330
+ // a capital letter, and it's not already a member on the element,
331
+ // then we're assuming it's an event listener
332
+ if (memberName[2] === '-') {
333
+ // on- prefixed events
334
+ // allows to be explicit about the dom event to listen without any magic
335
+ // under the hood:
336
+ // <my-cmp on-click> // listens for "click"
337
+ // <my-cmp on-Click> // listens for "Click"
338
+ // <my-cmp on-ionChange> // listens for "ionChange"
339
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
340
+ memberName = memberName.slice(3);
341
+ }
342
+ else if (isMemberInElement(win, ln)) {
343
+ // standard event
344
+ // the JSX attribute could have been "onMouseOver" and the
345
+ // member name "onmouseover" is on the window's prototype
346
+ // so let's add the listener "mouseover", which is all lowercased
347
+ memberName = ln.slice(2);
348
+ }
349
+ else {
350
+ // custom event
351
+ // the JSX attribute could have been "onMyCustomEvent"
352
+ // so let's trim off the "on" prefix and lowercase the first character
353
+ // and add the listener "myCustomEvent"
354
+ // except for the first character, we keep the event name case
355
+ memberName = ln[2] + memberName.slice(3);
356
+ }
357
+ if (oldValue) {
358
+ plt.rel(elm, memberName, oldValue, false);
359
+ }
360
+ if (newValue) {
361
+ plt.ael(elm, memberName, newValue, false);
362
+ }
363
+ }
272
364
  else {
273
365
  // Set property if it exists and it's not a SVG
274
366
  const isComplex = isComplexType(newValue);
@@ -336,13 +428,36 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
336
428
  let i = 0;
337
429
  let elm;
338
430
  let childNode;
431
+ let oldVNode;
432
+ if (!useNativeShadowDom) {
433
+ // remember for later we need to check to relocate nodes
434
+ checkSlotRelocate = true;
435
+ if (newVNode.$tag$ === 'slot') {
436
+ if (scopeId) {
437
+ // scoped css needs to add its scoped id to the parent element
438
+ parentElm.classList.add(scopeId + '-s');
439
+ }
440
+ newVNode.$flags$ |= newVNode.$children$
441
+ ? // slot element has fallback content
442
+ 2 /* isSlotFallback */
443
+ : // slot element does not have fallback content
444
+ 1 /* isSlotReference */;
445
+ }
446
+ }
339
447
  if (newVNode.$text$ !== null) {
340
448
  // create text node
341
449
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
342
450
  }
451
+ else if (newVNode.$flags$ & 1 /* isSlotReference */) {
452
+ // create a slot reference node
453
+ elm = newVNode.$elm$ =
454
+ doc.createTextNode('');
455
+ }
343
456
  else {
344
457
  // create element
345
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
458
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
459
+ ? 'slot-fb'
460
+ : newVNode.$tag$));
346
461
  // add css classes, attrs, props, listeners, etc.
347
462
  {
348
463
  updateElement(null, newVNode, isSvgMode);
@@ -355,7 +470,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
355
470
  if (newVNode.$children$) {
356
471
  for (i = 0; i < newVNode.$children$.length; ++i) {
357
472
  // create the node
358
- childNode = createElm(oldParentVNode, newVNode, i);
473
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
359
474
  // return node could have been null
360
475
  if (childNode) {
361
476
  // append our new node
@@ -364,20 +479,62 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
364
479
  }
365
480
  }
366
481
  }
482
+ {
483
+ elm['s-hn'] = hostTagName;
484
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
485
+ // remember the content reference comment
486
+ elm['s-sr'] = true;
487
+ // remember the content reference comment
488
+ elm['s-cr'] = contentRef;
489
+ // remember the slot name, or empty string for default slot
490
+ elm['s-sn'] = newVNode.$name$ || '';
491
+ // check if we've got an old vnode for this slot
492
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
493
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
494
+ // we've got an old slot vnode and the wrapper is being replaced
495
+ // so let's move the old slot content back to it's original location
496
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
497
+ }
498
+ }
499
+ }
367
500
  return elm;
368
501
  };
502
+ const putBackInOriginalLocation = (parentElm, recursive) => {
503
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
504
+ const oldSlotChildNodes = parentElm.childNodes;
505
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
506
+ const childNode = oldSlotChildNodes[i];
507
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
508
+ // // this child node in the old element is from another component
509
+ // // remove this node from the old slot's parent
510
+ // childNode.remove();
511
+ // and relocate it back to it's original location
512
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
513
+ // remove the old original location comment entirely
514
+ // later on the patch function will know what to do
515
+ // and move this to the correct spot in need be
516
+ childNode['s-ol'].remove();
517
+ childNode['s-ol'] = undefined;
518
+ checkSlotRelocate = true;
519
+ }
520
+ if (recursive) {
521
+ putBackInOriginalLocation(childNode, recursive);
522
+ }
523
+ }
524
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
525
+ };
369
526
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
370
- let containerElm = (parentElm);
527
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
371
528
  let childNode;
372
529
  if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
373
530
  containerElm = containerElm.shadowRoot;
374
531
  }
375
532
  for (; startIdx <= endIdx; ++startIdx) {
376
533
  if (vnodes[startIdx]) {
377
- childNode = createElm(null, parentVNode, startIdx);
534
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
378
535
  if (childNode) {
379
536
  vnodes[startIdx].$elm$ = childNode;
380
- containerElm.insertBefore(childNode, before);
537
+ containerElm.insertBefore(childNode, referenceNode(before) );
381
538
  }
382
539
  }
383
540
  }
@@ -387,6 +544,20 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
387
544
  if ((vnode = vnodes[startIdx])) {
388
545
  elm = vnode.$elm$;
389
546
  callNodeRefs(vnode);
547
+ {
548
+ // we're removing this element
549
+ // so it's possible we need to show slot fallback content now
550
+ checkSlotFallbackVisibility = true;
551
+ if (elm['s-ol']) {
552
+ // remove the original location comment
553
+ elm['s-ol'].remove();
554
+ }
555
+ else {
556
+ // it's possible that child nodes of the node
557
+ // that's being removed are slot nodes
558
+ putBackInOriginalLocation(elm, true);
559
+ }
560
+ }
390
561
  // remove the vnode's element from the dom
391
562
  elm.remove();
392
563
  }
@@ -427,12 +598,20 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
427
598
  newEndVnode = newCh[--newEndIdx];
428
599
  }
429
600
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
601
+ // Vnode moved right
602
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
603
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
604
+ }
430
605
  patch(oldStartVnode, newEndVnode);
431
606
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
432
607
  oldStartVnode = oldCh[++oldStartIdx];
433
608
  newEndVnode = newCh[--newEndIdx];
434
609
  }
435
610
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
611
+ // Vnode moved left
612
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
613
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
614
+ }
436
615
  patch(oldEndVnode, newStartVnode);
437
616
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
438
617
  oldEndVnode = oldCh[--oldEndIdx];
@@ -441,12 +620,12 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
441
620
  else {
442
621
  {
443
622
  // new element
444
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
623
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
445
624
  newStartVnode = newCh[++newStartIdx];
446
625
  }
447
626
  if (node) {
448
627
  {
449
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
628
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
450
629
  }
451
630
  }
452
631
  }
@@ -462,16 +641,28 @@ const isSameVnode = (vnode1, vnode2) => {
462
641
  // compare if two vnode to see if they're "technically" the same
463
642
  // need to have the same element tag, and same key to be the same
464
643
  if (vnode1.$tag$ === vnode2.$tag$) {
644
+ if (vnode1.$tag$ === 'slot') {
645
+ return vnode1.$name$ === vnode2.$name$;
646
+ }
465
647
  return true;
466
648
  }
467
649
  return false;
468
650
  };
651
+ const referenceNode = (node) => {
652
+ // this node was relocated to a new location in the dom
653
+ // because of some other component's slot
654
+ // but we still have an html comment in place of where
655
+ // it's original location was according to it's original vdom
656
+ return (node && node['s-ol']) || node;
657
+ };
658
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
469
659
  const patch = (oldVNode, newVNode) => {
470
660
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
471
661
  const oldChildren = oldVNode.$children$;
472
662
  const newChildren = newVNode.$children$;
473
663
  const tag = newVNode.$tag$;
474
664
  const text = newVNode.$text$;
665
+ let defaultHolder;
475
666
  if (text === null) {
476
667
  // element node
477
668
  {
@@ -502,12 +693,147 @@ const patch = (oldVNode, newVNode) => {
502
693
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
503
694
  }
504
695
  }
696
+ else if ((defaultHolder = elm['s-cr'])) {
697
+ // this element has slotted content
698
+ defaultHolder.parentNode.textContent = text;
699
+ }
505
700
  else if (oldVNode.$text$ !== text) {
506
701
  // update the text content for the text only vnode
507
702
  // and also only if the text is different than before
508
703
  elm.data = text;
509
704
  }
510
705
  };
706
+ const updateFallbackSlotVisibility = (elm) => {
707
+ // tslint:disable-next-line: prefer-const
708
+ const childNodes = elm.childNodes;
709
+ let childNode;
710
+ let i;
711
+ let ilen;
712
+ let j;
713
+ let slotNameAttr;
714
+ let nodeType;
715
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
716
+ childNode = childNodes[i];
717
+ if (childNode.nodeType === 1 /* ElementNode */) {
718
+ if (childNode['s-sr']) {
719
+ // this is a slot fallback node
720
+ // get the slot name for this slot reference node
721
+ slotNameAttr = childNode['s-sn'];
722
+ // by default always show a fallback slot node
723
+ // then hide it if there are other slots in the light dom
724
+ childNode.hidden = false;
725
+ for (j = 0; j < ilen; j++) {
726
+ nodeType = childNodes[j].nodeType;
727
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
728
+ // this sibling node is from a different component OR is a named fallback slot node
729
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
730
+ childNode.hidden = true;
731
+ break;
732
+ }
733
+ }
734
+ else {
735
+ // this is a default fallback slot node
736
+ // any element or text node (with content)
737
+ // should hide the default fallback slot node
738
+ if (nodeType === 1 /* ElementNode */ ||
739
+ (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
740
+ childNode.hidden = true;
741
+ break;
742
+ }
743
+ }
744
+ }
745
+ }
746
+ // keep drilling down
747
+ updateFallbackSlotVisibility(childNode);
748
+ }
749
+ }
750
+ };
751
+ const relocateNodes = [];
752
+ const relocateSlotContent = (elm) => {
753
+ // tslint:disable-next-line: prefer-const
754
+ let childNode;
755
+ let node;
756
+ let hostContentNodes;
757
+ let slotNameAttr;
758
+ let relocateNodeData;
759
+ let j;
760
+ let i = 0;
761
+ const childNodes = elm.childNodes;
762
+ const ilen = childNodes.length;
763
+ for (; i < ilen; i++) {
764
+ childNode = childNodes[i];
765
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
766
+ // first got the content reference comment node
767
+ // then we got it's parent, which is where all the host content is in now
768
+ hostContentNodes = node.parentNode.childNodes;
769
+ slotNameAttr = childNode['s-sn'];
770
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
771
+ node = hostContentNodes[j];
772
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
773
+ // let's do some relocating to its new home
774
+ // but never relocate a content reference node
775
+ // that is suppose to always represent the original content location
776
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
777
+ // it's possible we've already decided to relocate this node
778
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
779
+ // made some changes to slots
780
+ // let's make sure we also double check
781
+ // fallbacks are correctly hidden or shown
782
+ checkSlotFallbackVisibility = true;
783
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
784
+ if (relocateNodeData) {
785
+ // previously we never found a slot home for this node
786
+ // but turns out we did, so let's remember it now
787
+ relocateNodeData.$slotRefNode$ = childNode;
788
+ }
789
+ else {
790
+ // add to our list of nodes to relocate
791
+ relocateNodes.push({
792
+ $slotRefNode$: childNode,
793
+ $nodeToRelocate$: node,
794
+ });
795
+ }
796
+ if (node['s-sr']) {
797
+ relocateNodes.map((relocateNode) => {
798
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
799
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
800
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
801
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
802
+ }
803
+ }
804
+ });
805
+ }
806
+ }
807
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
808
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
809
+ // if we never find a home for this element then we'll need to hide it
810
+ relocateNodes.push({
811
+ $nodeToRelocate$: node,
812
+ });
813
+ }
814
+ }
815
+ }
816
+ }
817
+ if (childNode.nodeType === 1 /* ElementNode */) {
818
+ relocateSlotContent(childNode);
819
+ }
820
+ }
821
+ };
822
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
823
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
824
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
825
+ return true;
826
+ }
827
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
828
+ return true;
829
+ }
830
+ return false;
831
+ }
832
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
833
+ return true;
834
+ }
835
+ return slotNameAttr === '';
836
+ };
511
837
  const callNodeRefs = (vNode) => {
512
838
  {
513
839
  vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
@@ -516,9 +842,14 @@ const callNodeRefs = (vNode) => {
516
842
  };
517
843
  const renderVdom = (hostRef, renderFnResults) => {
518
844
  const hostElm = hostRef.$hostElement$;
845
+ const cmpMeta = hostRef.$cmpMeta$;
519
846
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
520
847
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
521
848
  hostTagName = hostElm.tagName;
849
+ if (cmpMeta.$attrsToReflect$) {
850
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
851
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
852
+ }
522
853
  rootVnode.$tag$ = null;
523
854
  rootVnode.$flags$ |= 4 /* isHost */;
524
855
  hostRef.$vnode$ = rootVnode;
@@ -526,10 +857,105 @@ const renderVdom = (hostRef, renderFnResults) => {
526
857
  {
527
858
  scopeId = hostElm['s-sc'];
528
859
  }
860
+ {
861
+ contentRef = hostElm['s-cr'];
862
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
863
+ // always reset
864
+ checkSlotFallbackVisibility = false;
865
+ }
529
866
  // synchronous patch
530
867
  patch(oldVNode, rootVnode);
868
+ {
869
+ // while we're moving nodes around existing nodes, temporarily disable
870
+ // the disconnectCallback from working
871
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
872
+ if (checkSlotRelocate) {
873
+ relocateSlotContent(rootVnode.$elm$);
874
+ let relocateData;
875
+ let nodeToRelocate;
876
+ let orgLocationNode;
877
+ let parentNodeRef;
878
+ let insertBeforeNode;
879
+ let refNode;
880
+ let i = 0;
881
+ for (; i < relocateNodes.length; i++) {
882
+ relocateData = relocateNodes[i];
883
+ nodeToRelocate = relocateData.$nodeToRelocate$;
884
+ if (!nodeToRelocate['s-ol']) {
885
+ // add a reference node marking this node's original location
886
+ // keep a reference to this node for later lookups
887
+ orgLocationNode =
888
+ doc.createTextNode('');
889
+ orgLocationNode['s-nr'] = nodeToRelocate;
890
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
891
+ }
892
+ }
893
+ for (i = 0; i < relocateNodes.length; i++) {
894
+ relocateData = relocateNodes[i];
895
+ nodeToRelocate = relocateData.$nodeToRelocate$;
896
+ if (relocateData.$slotRefNode$) {
897
+ // by default we're just going to insert it directly
898
+ // after the slot reference node
899
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
900
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
901
+ orgLocationNode = nodeToRelocate['s-ol'];
902
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
903
+ refNode = orgLocationNode['s-nr'];
904
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
905
+ refNode = refNode.nextSibling;
906
+ if (!refNode || !refNode['s-nr']) {
907
+ insertBeforeNode = refNode;
908
+ break;
909
+ }
910
+ }
911
+ }
912
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
913
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
914
+ // we've checked that it's worth while to relocate
915
+ // since that the node to relocate
916
+ // has a different next sibling or parent relocated
917
+ if (nodeToRelocate !== insertBeforeNode) {
918
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
919
+ // probably a component in the index.html that doesn't have it's hostname set
920
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
921
+ }
922
+ // add it back to the dom but in its new home
923
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
924
+ }
925
+ }
926
+ }
927
+ else {
928
+ // this node doesn't have a slot home to go to, so let's hide it
929
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
930
+ nodeToRelocate.hidden = true;
931
+ }
932
+ }
933
+ }
934
+ }
935
+ if (checkSlotFallbackVisibility) {
936
+ updateFallbackSlotVisibility(rootVnode.$elm$);
937
+ }
938
+ // done moving nodes around
939
+ // allow the disconnect callback to work again
940
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
941
+ // always reset
942
+ relocateNodes.length = 0;
943
+ }
531
944
  };
532
945
  const getElement = (ref) => (getHostRef(ref).$hostElement$ );
946
+ const createEvent = (ref, name, flags) => {
947
+ const elm = getElement(ref);
948
+ return {
949
+ emit: (detail) => {
950
+ return emitEvent(elm, name, {
951
+ bubbles: !!(flags & 4 /* Bubbles */),
952
+ composed: !!(flags & 2 /* Composed */),
953
+ cancelable: !!(flags & 1 /* Cancellable */),
954
+ detail,
955
+ });
956
+ },
957
+ };
958
+ };
533
959
  /**
534
960
  * Helper function to create & dispatch a custom Event on a provided target
535
961
  * @param elm the target of the Event
@@ -754,6 +1180,7 @@ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propNam
754
1180
  const setValue = (ref, propName, newVal, cmpMeta) => {
755
1181
  // check our new property value against our internal value
756
1182
  const hostRef = getHostRef(ref);
1183
+ const elm = hostRef.$hostElement$ ;
757
1184
  const oldVal = hostRef.$instanceValues$.get(propName);
758
1185
  const flags = hostRef.$flags$;
759
1186
  const instance = hostRef.$lazyInstance$ ;
@@ -766,6 +1193,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
766
1193
  // set our new value!
767
1194
  hostRef.$instanceValues$.set(propName, newVal);
768
1195
  if (instance) {
1196
+ // get an array of method names of watch functions to call
1197
+ if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1198
+ const watchMethods = cmpMeta.$watchers$[propName];
1199
+ if (watchMethods) {
1200
+ // this instance is watching for when this property changed
1201
+ watchMethods.map((watchMethodName) => {
1202
+ try {
1203
+ // fire off each of the watch methods that are watching this property
1204
+ instance[watchMethodName](newVal, oldVal, propName);
1205
+ }
1206
+ catch (e) {
1207
+ consoleError(e, elm);
1208
+ }
1209
+ });
1210
+ }
1211
+ }
769
1212
  if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
770
1213
  if (instance.componentShouldUpdate) {
771
1214
  if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
@@ -783,6 +1226,9 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
783
1226
  };
784
1227
  const proxyComponent = (Cstr, cmpMeta, flags) => {
785
1228
  if (cmpMeta.$members$) {
1229
+ if (Cstr.watchers) {
1230
+ cmpMeta.$watchers$ = Cstr.watchers;
1231
+ }
786
1232
  // It's better to have a const than two Object.entries()
787
1233
  const members = Object.entries(cmpMeta.$members$);
788
1234
  const prototype = Cstr.prototype;
@@ -864,6 +1310,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
864
1310
  .map(([propName, m]) => {
865
1311
  const attrName = m[1] || propName;
866
1312
  attrNameToPropName.set(attrName, propName);
1313
+ if (m[0] & 512 /* ReflectAttr */) {
1314
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
1315
+ }
867
1316
  return attrName;
868
1317
  });
869
1318
  }
@@ -887,6 +1336,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
887
1336
  endLoad();
888
1337
  }
889
1338
  if (!Cstr.isProxied) {
1339
+ // we've never proxied this Constructor before
1340
+ // let's add the getters/setters to its prototype before
1341
+ // the first time we create an instance of the implementation
1342
+ {
1343
+ cmpMeta.$watchers$ = Cstr.watchers;
1344
+ }
890
1345
  proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
891
1346
  Cstr.isProxied = true;
892
1347
  }
@@ -910,6 +1365,9 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
910
1365
  {
911
1366
  hostRef.$flags$ &= ~8 /* isConstructingInstance */;
912
1367
  }
1368
+ {
1369
+ hostRef.$flags$ |= 128 /* isWatchReady */;
1370
+ }
913
1371
  endNewInstance();
914
1372
  }
915
1373
  if (Cstr.style) {
@@ -947,6 +1405,15 @@ const connectedCallback = (elm) => {
947
1405
  if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
948
1406
  // first time this component has connected
949
1407
  hostRef.$flags$ |= 1 /* hasConnected */;
1408
+ {
1409
+ // initUpdate
1410
+ // if the slot polyfill is required we'll need to put some nodes
1411
+ // in here to act as original content anchors as we move nodes around
1412
+ // host element has been connected to the DOM
1413
+ if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1414
+ setContentReference(elm);
1415
+ }
1416
+ }
950
1417
  {
951
1418
  // find the first ancestor component (if there is one) and register
952
1419
  // this component as one of the actively loading child components for its ancestor
@@ -986,6 +1453,17 @@ const connectedCallback = (elm) => {
986
1453
  endConnected();
987
1454
  }
988
1455
  };
1456
+ const setContentReference = (elm) => {
1457
+ // only required when we're NOT using native shadow dom (slot)
1458
+ // or this browser doesn't support native shadow dom
1459
+ // and this host element was NOT created with SSR
1460
+ // let's pick out the inner content for slot projection
1461
+ // create a node to represent where the original
1462
+ // content was first placed, which is useful later on
1463
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1464
+ contentRefElm['s-cn'] = true;
1465
+ elm.insertBefore(contentRefElm, elm.firstChild);
1466
+ };
989
1467
  const disconnectedCallback = (elm) => {
990
1468
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
991
1469
  const hostRef = getHostRef(elm);
@@ -1024,6 +1502,12 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1024
1502
  {
1025
1503
  cmpMeta.$listeners$ = compactMeta[3];
1026
1504
  }
1505
+ {
1506
+ cmpMeta.$attrsToReflect$ = [];
1507
+ }
1508
+ {
1509
+ cmpMeta.$watchers$ = {};
1510
+ }
1027
1511
  const tagName = cmpMeta.$tagName$;
1028
1512
  const HostElement = class extends HTMLElement {
1029
1513
  // StencilLazyHost
@@ -1177,6 +1661,7 @@ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1177
1661
 
1178
1662
  exports.Host = Host;
1179
1663
  exports.bootstrapLazy = bootstrapLazy;
1664
+ exports.createEvent = createEvent;
1180
1665
  exports.getElement = getElement;
1181
1666
  exports.h = h;
1182
1667
  exports.promiseResolve = promiseResolve;