@creopse/vue 0.0.46 → 0.0.47

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.
package/dist/index.mjs CHANGED
@@ -5951,8 +5951,8 @@ class jm {
5951
5951
  constructor(t) {
5952
5952
  this.state = bl({ props: t });
5953
5953
  }
5954
- update(t) {
5955
- this.state.props = this.deepMerge(this.state.props, t);
5954
+ update(t, n = "merge") {
5955
+ this.state.props = n === "merge" ? this.deepMerge(this.state.props, t) : this.deepOverride(this.state.props, t);
5956
5956
  }
5957
5957
  getState() {
5958
5958
  return Ol(this.state);
@@ -5966,6 +5966,14 @@ class jm {
5966
5966
  this.isObject(n[s]) && s in t ? r[s] = this.deepMerge(t[s], n[s]) : r[s] = n[s];
5967
5967
  }), r;
5968
5968
  }
5969
+ deepOverride(t, n) {
5970
+ if (!this.isObject(n))
5971
+ return n;
5972
+ const r = { ...n };
5973
+ return this.isObject(t) && Object.keys(n).forEach((s) => {
5974
+ this.isObject(n[s]) && this.isObject(t[s]) && (r[s] = this.deepOverride(t[s], n[s]));
5975
+ }), r;
5976
+ }
5969
5977
  isObject(t) {
5970
5978
  return t && typeof t == "object" && !Array.isArray(t);
5971
5979
  }
@@ -6004,7 +6012,7 @@ const lp = () => {
6004
6012
  throw new Error("[@creopse/vue] resolveSections is required");
6005
6013
  const n = new jm(t.initialProps);
6006
6014
  t?.router ? (t.router.on("navigate", (r) => {
6007
- n.update(r.detail.page.props);
6015
+ n.sync(r.detail.page.props);
6008
6016
  }), e.provide(Ar, t.router)) : console.warn("[@creopse/vue] No router - props won't sync"), e.provide(Rr, n), e.config.globalProperties.$props = n, e.provide(xr, t.config), e.config.globalProperties.$config = t.config, e.provide(Ei, t.resolveSections), e.config.globalProperties.$resolveSections = t.resolveSections, e.component("RootContainer", Mm), e.component("CustomTransition", Am), e.component("MountedTeleport", Cm), e.component("StickyBottom", Fm), e.component("StickyTop", Wm), e.component("ReadMore", Um), e.component("AsyncImg", Va), e.component("Image", Nm);
6009
6017
  }
6010
6018
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@creopse/vue",
3
3
  "description": "Creopse Vue Toolkit",
4
- "version": "0.0.46",
4
+ "version": "0.0.47",
5
5
  "private": false,
6
6
  "author": "Noé Gnanih <noegnanih@gmail.com>",
7
7
  "license": "MIT",
@@ -2,7 +2,7 @@ import type { Props } from '@/types/plugin';
2
2
  declare class PropsManager<T extends Props = Props> {
3
3
  private state;
4
4
  constructor(initialProps: T);
5
- update(payload: T): void;
5
+ update(payload: T, strategy?: 'merge' | 'override'): void;
6
6
  getState(): {
7
7
  readonly props: {
8
8
  readonly [x: string]: any;
@@ -4657,6 +4657,7 @@ declare class PropsManager<T extends Props = Props> {
4657
4657
  };
4658
4658
  sync(newProps: T): void;
4659
4659
  private deepMerge;
4660
+ private deepOverride;
4660
4661
  private isObject;
4661
4662
  }
4662
4663
  export default PropsManager;