@syncfusion/ej2-vue-base 33.2.3 → 34.1.32

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.
@@ -646,6 +646,137 @@ var __assign = (undefined && undefined.__assign) || function () {
646
646
  return __assign.apply(this, arguments);
647
647
  };
648
648
  var stringCompiler = getTemplateEngine();
649
+ /**
650
+ * Returns true if the given Vue 3 component instance is inside a keep-alive.
651
+ *
652
+ * @param {any} vueInstance - Vue component instance.
653
+ * @returns {boolean} Returns true when inside keep-alive.
654
+ */
655
+ function isInsideKeepAlive(vueInstance) {
656
+ var parent = vueInstance && vueInstance.$ && vueInstance.$.parent;
657
+ while (parent) {
658
+ if (parent.type && parent.type.__isKeepAlive) {
659
+ return true;
660
+ }
661
+ parent = parent.parent;
662
+ }
663
+ return false;
664
+ }
665
+ /**
666
+ * Collect activated/deactivated hooks from rendered vnode tree.
667
+ *
668
+ * @param {any} vnode - VNode instance.
669
+ * @param {any[]} out - Collection of hooks.
670
+ * @returns {void}
671
+ */
672
+ function collectHooks(vnode, out) {
673
+ if (!vnode) {
674
+ return;
675
+ }
676
+ var ci = vnode.component;
677
+ if (ci && ci.type && ci.proxy && !ci.isUnmounted) {
678
+ if (typeof ci.type.activated === 'function' ||
679
+ typeof ci.type.deactivated === 'function') {
680
+ out.push({
681
+ activated: ci.type.activated ?
682
+ ci.type.activated.bind(ci.proxy) : null,
683
+ deactivated: ci.type.deactivated ?
684
+ ci.type.deactivated.bind(ci.proxy) : null
685
+ });
686
+ }
687
+ collectHooks(ci.subTree, out);
688
+ }
689
+ if (Array.isArray(vnode.children)) {
690
+ for (var i = 0; i < vnode.children.length; i++) {
691
+ // eslint-disable-next-line security/detect-object-injection
692
+ collectHooks(vnode.children[i], out);
693
+ }
694
+ }
695
+ }
696
+ /**
697
+ * Collect hooks from template collection.
698
+ *
699
+ * @param {any} proxy - Vue component proxy.
700
+ * @returns {any[]} Returns collected hooks.
701
+ */
702
+ function collectFromTemplates(proxy) {
703
+ var hooks = [];
704
+ var tc = proxy.templateCollection;
705
+ if (!tc) {
706
+ return hooks;
707
+ }
708
+ var keys = Object.keys(tc);
709
+ for (var k = 0; k < keys.length; k++) {
710
+ // eslint-disable-next-line security/detect-object-injection
711
+ var key = keys[k];
712
+ // eslint-disable-next-line security/detect-object-injection
713
+ var elems = tc[key];
714
+ for (var i = 0; i < elems.length; i++) {
715
+ // eslint-disable-next-line security/detect-object-injection
716
+ var ele = elems[i];
717
+ if (ele && ele._vnode) {
718
+ collectHooks(ele._vnode, hooks);
719
+ }
720
+ }
721
+ }
722
+ return hooks;
723
+ }
724
+ /**
725
+ * Patch keep-alive lifecycle handling for slot templates.
726
+ *
727
+ * @param {any} vueInstance - Vue component instance.
728
+ * @param {any} app - Rendered vnode.
729
+ * @returns {void}
730
+ */
731
+ function patchKeepAlive(vueInstance, app) {
732
+ // Walk up to find the direct child of keep-alive.
733
+ var start = vueInstance.$;
734
+ var cur = start;
735
+ var keepAliveChild = null;
736
+ while (cur) {
737
+ if (cur.parent &&
738
+ cur.parent.type &&
739
+ cur.parent.type.__isKeepAlive) {
740
+ keepAliveChild = cur;
741
+ break;
742
+ }
743
+ cur = cur.parent;
744
+ }
745
+ if (!keepAliveChild) {
746
+ return;
747
+ }
748
+ // templateCollection is on ejs-grid vueInstance
749
+ var gridProxy = vueInstance;
750
+ if (!keepAliveChild.isDeactivated) {
751
+ var immediateHooks = [];
752
+ collectHooks(app, immediateHooks);
753
+ immediateHooks.forEach(function (h) {
754
+ var activated = h.activated;
755
+ if (activated) {
756
+ activated();
757
+ }
758
+ });
759
+ }
760
+ if (!keepAliveChild._sfPatched) {
761
+ keepAliveChild._sfPatched = true;
762
+ (keepAliveChild.a || (keepAliveChild.a = [])).push(function () {
763
+ collectFromTemplates(gridProxy).forEach(function (h) {
764
+ var activated = h.activated;
765
+ if (activated) {
766
+ activated();
767
+ }
768
+ });
769
+ });
770
+ (keepAliveChild.da || (keepAliveChild.da = [])).push(function () {
771
+ collectFromTemplates(gridProxy).forEach(function (h) {
772
+ var deactivated = h.deactivated;
773
+ if (deactivated) {
774
+ deactivated();
775
+ }
776
+ });
777
+ });
778
+ }
779
+ }
649
780
  /**
650
781
  * Compiler function that convert the template property to DOM element.
651
782
  *
@@ -694,6 +825,10 @@ function compile(templateElement, helper) {
694
825
  }
695
826
  templateInstance["" + propName].push(ele);
696
827
  }
828
+ // Keep-alive support for Vue 3 slot templates.
829
+ if (isInsideKeepAlive(vueInstance)) {
830
+ patchKeepAlive(vueInstance, app);
831
+ }
697
832
  }
698
833
  detach(ele);
699
834
  }
@@ -796,8 +931,12 @@ function compile(templateElement, helper) {
796
931
  if (vueinstance['$parent']) {
797
932
  getProvideValues_1(vueinstance.$parent);
798
933
  }
799
- if (vueinstance['_provided'] && Object.keys(vueinstance['_provided']).length > 0) {
800
- provided_1 = __assign({}, provided_1, vueinstance._provided);
934
+ if (vueinstance['_provided']) {
935
+ // eslint-disable-next-line guard-for-in
936
+ for (var key in vueinstance['_provided']) {
937
+ // eslint-disable-next-line security/detect-object-injection
938
+ provided_1[key] = vueinstance['_provided'][key];
939
+ }
801
940
  }
802
941
  };
803
942
  var vueInstance_1 = context.vueInstance ? context.vueInstance :
@@ -901,8 +1040,12 @@ function getValues(app, cInstance, root) {
901
1040
  if (vueinstance['$'] && vueinstance['$']['parent']) {
902
1041
  getProvideValue(vueinstance.$.parent);
903
1042
  }
904
- if (vueinstance['provides'] && Object.keys(vueinstance['provides']).length > 0) {
905
- provided = __assign({}, provided, vueinstance.provides);
1043
+ if (vueinstance['provides']) {
1044
+ // eslint-disable-next-line guard-for-in
1045
+ for (var key in vueinstance['provides']) {
1046
+ // eslint-disable-next-line security/detect-object-injection
1047
+ provided[key] = vueinstance['provides'][key];
1048
+ }
906
1049
  }
907
1050
  };
908
1051
  getProvideValue(vueInstance);