@domql/state 2.5.56 → 2.5.64
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/create.js +3 -3
- package/dist/cjs/create.js +2 -2
- package/dist/cjs/inherit.js +1 -1
- package/dist/cjs/methods.js +2 -2
- package/inherit.js +2 -2
- package/methods.js +3 -3
- package/package.json +2 -2
package/create.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { triggerEventOn } from '@domql/event'
|
|
4
|
-
import {
|
|
4
|
+
import { deepCloneWithExtend, exec, is, isArray, isFunction, isObject, isUndefined } from '@domql/utils'
|
|
5
5
|
import { IGNORE_STATE_PARAMS } from './ignore'
|
|
6
6
|
import {
|
|
7
7
|
add,
|
|
@@ -27,7 +27,7 @@ export const createState = function (element, parent, options) {
|
|
|
27
27
|
export const applyInitialState = function (element, parent, options) {
|
|
28
28
|
const objectizeState = checkForTypes(element)
|
|
29
29
|
if (objectizeState === false) return parent.state || {}
|
|
30
|
-
else element.state =
|
|
30
|
+
else element.state = deepCloneWithExtend(objectizeState, IGNORE_STATE_PARAMS)
|
|
31
31
|
|
|
32
32
|
const whatInitReturns = triggerEventOn('stateInit', element, options)
|
|
33
33
|
if (whatInitReturns === false) return element.state
|
|
@@ -51,7 +51,7 @@ export const applyInitialState = function (element, parent, options) {
|
|
|
51
51
|
const applyDependentState = (element, state) => {
|
|
52
52
|
const { __ref: ref } = state
|
|
53
53
|
if (!ref) return
|
|
54
|
-
const dependentState =
|
|
54
|
+
const dependentState = deepCloneWithExtend(ref, IGNORE_STATE_PARAMS)
|
|
55
55
|
const newDepends = { [element.key]: dependentState }
|
|
56
56
|
ref.__depends = isObject(ref.__depends)
|
|
57
57
|
? { ...ref.__depends, ...newDepends }
|
package/dist/cjs/create.js
CHANGED
|
@@ -37,7 +37,7 @@ const applyInitialState = function(element, parent, options) {
|
|
|
37
37
|
if (objectizeState === false)
|
|
38
38
|
return parent.state || {};
|
|
39
39
|
else
|
|
40
|
-
element.state = (0, import_utils.
|
|
40
|
+
element.state = (0, import_utils.deepCloneWithExtend)(objectizeState, import_ignore.IGNORE_STATE_PARAMS);
|
|
41
41
|
const whatInitReturns = (0, import_event.triggerEventOn)("stateInit", element, options);
|
|
42
42
|
if (whatInitReturns === false)
|
|
43
43
|
return element.state;
|
|
@@ -56,7 +56,7 @@ const applyDependentState = (element, state) => {
|
|
|
56
56
|
const { __ref: ref } = state;
|
|
57
57
|
if (!ref)
|
|
58
58
|
return;
|
|
59
|
-
const dependentState = (0, import_utils.
|
|
59
|
+
const dependentState = (0, import_utils.deepCloneWithExtend)(ref, import_ignore.IGNORE_STATE_PARAMS);
|
|
60
60
|
const newDepends = { [element.key]: dependentState };
|
|
61
61
|
ref.__depends = (0, import_utils.isObject)(ref.__depends) ? { ...ref.__depends, ...newDepends } : newDepends;
|
|
62
62
|
return dependentState;
|
package/dist/cjs/inherit.js
CHANGED
|
@@ -96,7 +96,7 @@ const createInheritedState = (element, parent) => {
|
|
|
96
96
|
if ((0, import_utils.isUndefined)(inheritedState))
|
|
97
97
|
return element.state;
|
|
98
98
|
if ((0, import_utils.is)(inheritedState)("object", "array")) {
|
|
99
|
-
return (0, import_utils.
|
|
99
|
+
return (0, import_utils.deepCloneWithExtend)(inheritedState, import_ignore.IGNORE_STATE_PARAMS);
|
|
100
100
|
} else if ((0, import_utils.is)(inheritedState)("string", "number", "boolean")) {
|
|
101
101
|
ref.__stateType = typeof inheritedState;
|
|
102
102
|
return { value: inheritedState };
|
package/dist/cjs/methods.js
CHANGED
|
@@ -132,12 +132,12 @@ const remove = function(key, options = {}) {
|
|
|
132
132
|
};
|
|
133
133
|
const set = function(val, options = {}) {
|
|
134
134
|
const state = this;
|
|
135
|
-
const value = (0, import_utils.
|
|
135
|
+
const value = (0, import_utils.deepCloneWithExtend)(val);
|
|
136
136
|
return state.clean({ preventStateUpdate: true, ...options }).update(value, { replace: true, ...options });
|
|
137
137
|
};
|
|
138
138
|
const reset = function(options = {}) {
|
|
139
139
|
const state = this;
|
|
140
|
-
const value = (0, import_utils.
|
|
140
|
+
const value = (0, import_utils.deepCloneWithExtend)(state.parse());
|
|
141
141
|
return state.set(value, { replace: true, ...options });
|
|
142
142
|
};
|
|
143
143
|
const apply = function(func, options = {}) {
|
package/inherit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { deepCloneWithExtend, is, isObjectLike, isUndefined } from '@domql/utils'
|
|
4
4
|
import { IGNORE_STATE_PARAMS } from './ignore'
|
|
5
5
|
|
|
6
6
|
export const getRootStateInKey = (stateKey, parentState) => {
|
|
@@ -69,7 +69,7 @@ export const createInheritedState = (element, parent) => {
|
|
|
69
69
|
if (isUndefined(inheritedState)) return element.state
|
|
70
70
|
|
|
71
71
|
if (is(inheritedState)('object', 'array')) {
|
|
72
|
-
return
|
|
72
|
+
return deepCloneWithExtend(inheritedState, IGNORE_STATE_PARAMS)
|
|
73
73
|
} else if (is(inheritedState)('string', 'number', 'boolean')) {
|
|
74
74
|
ref.__stateType = typeof inheritedState
|
|
75
75
|
return { value: inheritedState }
|
package/methods.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isArray,
|
|
3
|
+
import { isArray, deepCloneWithExtend, isFunction, isObject, isString, removeFromArray, removeFromObject } from '@domql/utils'
|
|
4
4
|
|
|
5
5
|
import { IGNORE_STATE_PARAMS } from './ignore'
|
|
6
6
|
|
|
@@ -109,14 +109,14 @@ export const remove = function (key, options = {}) {
|
|
|
109
109
|
|
|
110
110
|
export const set = function (val, options = {}) {
|
|
111
111
|
const state = this
|
|
112
|
-
const value =
|
|
112
|
+
const value = deepCloneWithExtend(val)
|
|
113
113
|
return state.clean({ preventStateUpdate: true, ...options })
|
|
114
114
|
.update(value, { replace: true, ...options })
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
export const reset = function (options = {}) {
|
|
118
118
|
const state = this
|
|
119
|
-
const value =
|
|
119
|
+
const value = deepCloneWithExtend(state.parse())
|
|
120
120
|
return state.set(value, { replace: true, ...options })
|
|
121
121
|
}
|
|
122
122
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/state",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.64",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"@domql/report": "latest",
|
|
32
32
|
"@domql/utils": "latest"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "ed8570ce73011589d920684013958c081147a39c"
|
|
35
35
|
}
|