@swisspost/design-system-components 1.3.4 → 1.3.5

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 (65) hide show
  1. package/dist/cjs/{index-126f28cf.js → index-f95ab17b.js} +62 -20
  2. package/dist/cjs/index-f95ab17b.js.map +1 -0
  3. package/dist/cjs/loader.cjs.js +3 -3
  4. package/dist/cjs/loader.cjs.js.map +1 -1
  5. package/dist/cjs/{package-3838cb5b.js → package-5e7ba83a.js} +2 -2
  6. package/dist/cjs/{package-3838cb5b.js.map → package-5e7ba83a.js.map} +1 -1
  7. package/dist/cjs/post-collapsible.cjs.entry.js +3 -3
  8. package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
  9. package/dist/cjs/post-components.cjs.js +3 -3
  10. package/dist/cjs/post-components.cjs.js.map +1 -1
  11. package/dist/cjs/post-icon.cjs.entry.js +10 -86
  12. package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
  13. package/dist/collection/collection-manifest.json +2 -2
  14. package/dist/collection/components/post-collapsible/post-collapsible.css +1166 -48
  15. package/dist/collection/components/post-icon/post-icon.js +8 -85
  16. package/dist/collection/components/post-icon/post-icon.js.map +1 -1
  17. package/dist/collection/utils/property-checkers/tests/check-non-empty.spec.js +36 -0
  18. package/dist/collection/utils/property-checkers/tests/check-non-empty.spec.js.map +1 -0
  19. package/dist/collection/utils/property-checkers/tests/check-one-of.spec.js +13 -0
  20. package/dist/collection/utils/property-checkers/tests/check-one-of.spec.js.map +1 -0
  21. package/dist/collection/utils/property-checkers/tests/check-type.spec.js +103 -0
  22. package/dist/collection/utils/property-checkers/tests/check-type.spec.js.map +1 -0
  23. package/dist/collection/utils/property-checkers/tests/empty-or.spec.js +23 -0
  24. package/dist/collection/utils/property-checkers/tests/empty-or.spec.js.map +1 -0
  25. package/dist/collection/utils/tests/should-reduce-motion.spec.js +16 -0
  26. package/dist/collection/utils/tests/should-reduce-motion.spec.js.map +1 -0
  27. package/dist/components/package.js +1 -1
  28. package/dist/components/post-collapsible.js +2 -2
  29. package/dist/components/post-collapsible.js.map +1 -1
  30. package/dist/components/post-icon.js +9 -86
  31. package/dist/components/post-icon.js.map +1 -1
  32. package/dist/docs.json +3 -3
  33. package/dist/esm/{index-286143e7.js → index-0cfe0348.js} +62 -20
  34. package/dist/esm/index-0cfe0348.js.map +1 -0
  35. package/dist/esm/loader.js +4 -4
  36. package/dist/esm/loader.js.map +1 -1
  37. package/dist/esm/{package-fb4a74d0.js → package-1c534bc2.js} +2 -2
  38. package/dist/esm/{package-fb4a74d0.js.map → package-1c534bc2.js.map} +1 -1
  39. package/dist/esm/post-collapsible.entry.js +3 -3
  40. package/dist/esm/post-collapsible.entry.js.map +1 -1
  41. package/dist/esm/post-components.js +4 -4
  42. package/dist/esm/post-components.js.map +1 -1
  43. package/dist/esm/post-icon.entry.js +10 -86
  44. package/dist/esm/post-icon.entry.js.map +1 -1
  45. package/dist/post-components/{p-87bf3416.js → p-0049f179.js} +2 -2
  46. package/dist/post-components/p-50562794.entry.js +2 -0
  47. package/dist/post-components/{p-7dd960f1.entry.js.map → p-50562794.entry.js.map} +1 -1
  48. package/dist/post-components/p-8f4d1bc9.js +3 -0
  49. package/dist/post-components/p-8f4d1bc9.js.map +1 -0
  50. package/dist/post-components/p-fd9201c2.entry.js +2 -0
  51. package/dist/post-components/p-fd9201c2.entry.js.map +1 -0
  52. package/dist/post-components/post-components.esm.js +1 -1
  53. package/dist/post-components/post-components.esm.js.map +1 -1
  54. package/dist/types/components/post-icon/post-icon.d.ts +0 -8
  55. package/dist/types/stencil-public-runtime.d.ts +1 -0
  56. package/loader/index.d.ts +1 -1
  57. package/package.json +13 -14
  58. package/dist/cjs/index-126f28cf.js.map +0 -1
  59. package/dist/esm/index-286143e7.js.map +0 -1
  60. package/dist/post-components/p-0c286590.js +0 -3
  61. package/dist/post-components/p-0c286590.js.map +0 -1
  62. package/dist/post-components/p-6e225c16.entry.js +0 -2
  63. package/dist/post-components/p-6e225c16.entry.js.map +0 -1
  64. package/dist/post-components/p-7dd960f1.entry.js +0 -2
  65. /package/dist/post-components/{p-87bf3416.js.map → p-0049f179.js.map} +0 -0
@@ -613,15 +613,16 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
613
613
  * @param vnodes a list of virtual DOM nodes to remove
614
614
  * @param startIdx the index at which to start removing nodes (inclusive)
615
615
  * @param endIdx the index at which to stop removing nodes (inclusive)
616
- * @param vnode a VNode
617
- * @param elm an element
618
616
  */
619
- const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
620
- for (; startIdx <= endIdx; ++startIdx) {
621
- if ((vnode = vnodes[startIdx])) {
622
- elm = vnode.$elm$;
623
- // remove the vnode's element from the dom
624
- elm.remove();
617
+ const removeVnodes = (vnodes, startIdx, endIdx) => {
618
+ for (let index = startIdx; index <= endIdx; ++index) {
619
+ const vnode = vnodes[index];
620
+ if (vnode) {
621
+ const elm = vnode.$elm$;
622
+ if (elm) {
623
+ // remove the vnode's element from the dom
624
+ elm.remove();
625
+ }
625
626
  }
626
627
  }
627
628
  };
@@ -916,23 +917,67 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
916
917
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
917
918
  return writeTask(dispatch) ;
918
919
  };
920
+ /**
921
+ * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
922
+ * component lifecycle methods like `componentWillLoad` as well as
923
+ * {@link updateComponent}, which will kick off the virtual DOM re-render.
924
+ *
925
+ * @param hostRef a reference to a host DOM node
926
+ * @param isInitialLoad whether we're on the initial load or not
927
+ * @returns an empty Promise which is used to enqueue a series of operations for
928
+ * the component
929
+ */
919
930
  const dispatchHooks = (hostRef, isInitialLoad) => {
920
931
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
921
932
  const instance = hostRef.$lazyInstance$ ;
922
- let promise;
933
+ // We're going to use this variable together with `enqueue` to implement a
934
+ // little promise-based queue. We start out with it `undefined`. When we add
935
+ // the first function to the queue we'll set this variable to be that
936
+ // function's return value. When we attempt to add subsequent values to the
937
+ // queue we'll check that value and, if it was a `Promise`, we'll then chain
938
+ // the new function off of that `Promise` using `.then()`. This will give our
939
+ // queue two nice properties:
940
+ //
941
+ // 1. If all functions added to the queue are synchronous they'll be called
942
+ // synchronously right away.
943
+ // 2. If all functions added to the queue are asynchronous they'll all be
944
+ // called in order after `dispatchHooks` exits.
945
+ let maybePromise;
923
946
  if (isInitialLoad) {
924
947
  {
925
- promise = safeCall(instance, 'componentWillLoad');
948
+ // If `componentWillLoad` returns a `Promise` then we want to wait on
949
+ // whatever's going on in that `Promise` before we launch into
950
+ // rendering the component, doing other lifecycle stuff, etc. So
951
+ // in that case we assign the returned promise to the variable we
952
+ // declared above to hold a possible 'queueing' Promise
953
+ maybePromise = safeCall(instance, 'componentWillLoad');
926
954
  }
927
955
  }
928
956
  {
929
- promise = then(promise, () => safeCall(instance, 'componentWillRender'));
957
+ maybePromise = enqueue(maybePromise, () => safeCall(instance, 'componentWillRender'));
930
958
  }
931
959
  endSchedule();
932
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
960
+ return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
933
961
  };
962
+ /**
963
+ * This function uses a Promise to implement a simple first-in, first-out queue
964
+ * of functions to be called.
965
+ *
966
+ * The queue is ordered on the basis of the first argument. If it's
967
+ * `undefined`, then nothing is on the queue yet, so the provided function can
968
+ * be called synchronously (although note that this function may return a
969
+ * `Promise`). The idea is that then the return value of that enqueueing
970
+ * operation is kept around, so that if it was a `Promise` then subsequent
971
+ * functions can be enqueued by calling this function again with that `Promise`
972
+ * as the first argument.
973
+ *
974
+ * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
975
+ * @param fn a function to enqueue
976
+ * @returns either a `Promise` or the return value of the provided function
977
+ */
978
+ const enqueue = (maybePromise, fn) => maybePromise instanceof Promise ? maybePromise.then(fn) : fn();
934
979
  const updateComponent = async (hostRef, instance, isInitialLoad) => {
935
- // updateComponent
980
+ var _a;
936
981
  const elm = hostRef.$hostElement$;
937
982
  const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
938
983
  const rc = elm['s-rc'];
@@ -954,7 +999,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
954
999
  endRender();
955
1000
  endUpdate();
956
1001
  {
957
- const childrenPromises = elm['s-p'];
1002
+ const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
958
1003
  const postUpdate = () => postUpdateComponent(hostRef);
959
1004
  if (childrenPromises.length === 0) {
960
1005
  postUpdate();
@@ -1055,9 +1100,6 @@ const safeCall = (instance, method, arg) => {
1055
1100
  }
1056
1101
  return undefined;
1057
1102
  };
1058
- const then = (promise, thenFn) => {
1059
- return promise && promise.then ? promise.then(thenFn) : thenFn();
1060
- };
1061
1103
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1062
1104
  ;
1063
1105
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
@@ -1218,9 +1260,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1218
1260
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1219
1261
  // initializeComponent
1220
1262
  if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1263
+ // Let the runtime know that the component has been initialized
1264
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1221
1265
  {
1222
- // we haven't initialized this element yet
1223
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1224
1266
  // lazy loaded components
1225
1267
  // request the component's implementation to be
1226
1268
  // wired up with the host element
@@ -1561,4 +1603,4 @@ exports.promiseResolve = promiseResolve;
1561
1603
  exports.registerInstance = registerInstance;
1562
1604
  exports.setNonce = setNonce;
1563
1605
 
1564
- //# sourceMappingURL=index-126f28cf.js.map
1606
+ //# sourceMappingURL=index-f95ab17b.js.map