@commercetools-uikit/hooks 19.11.0 → 19.12.0
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/commercetools-uikit-hooks.cjs.dev.js +5 -8
- package/dist/commercetools-uikit-hooks.cjs.prod.js +5 -8
- package/dist/commercetools-uikit-hooks.esm.js +5 -8
- package/package.json +2 -2
- package/polyfills/dist/commercetools-uikit-hooks-polyfills.cjs.dev.js +1 -2
- package/polyfills/dist/commercetools-uikit-hooks-polyfills.cjs.prod.js +1 -2
- package/polyfills/dist/commercetools-uikit-hooks-polyfills.esm.js +1 -2
|
@@ -96,29 +96,26 @@ function createMutationObserver() {
|
|
|
96
96
|
const callbacks = new _Map__default["default"]();
|
|
97
97
|
const observer = new MutationObserver(rafSchd__default["default"]((mutationsList, observer) => {
|
|
98
98
|
const mutationsByTarget = _reduceInstanceProperty__default["default"](mutationsList).call(mutationsList, (_mutationsByTarget, mutation) => {
|
|
99
|
-
|
|
100
|
-
const callbacksForTarget = (_mutationsByTarget$ge = _mutationsByTarget.get(mutation.target)) !== null && _mutationsByTarget$ge !== void 0 ? _mutationsByTarget$ge : [];
|
|
99
|
+
const callbacksForTarget = _mutationsByTarget.get(mutation.target) ?? [];
|
|
101
100
|
callbacksForTarget.push(mutation);
|
|
102
101
|
_mutationsByTarget.set(mutation.target, callbacksForTarget);
|
|
103
102
|
return _mutationsByTarget;
|
|
104
103
|
}, new _Map__default["default"]());
|
|
105
104
|
_forEachInstanceProperty__default["default"](mutationsByTarget).call(mutationsByTarget, (mutations, target) => {
|
|
106
105
|
const targetCallbacks = callbacks.get(target);
|
|
107
|
-
targetCallbacks
|
|
106
|
+
targetCallbacks?.forEach(cb => cb(mutations, observer));
|
|
108
107
|
});
|
|
109
108
|
}));
|
|
110
109
|
return {
|
|
111
110
|
observer,
|
|
112
111
|
subscribe(target, callback, options) {
|
|
113
|
-
var _callbacks$get;
|
|
114
112
|
observer.observe(target, options);
|
|
115
|
-
const targetCallbacks =
|
|
113
|
+
const targetCallbacks = callbacks.get(target) ?? [];
|
|
116
114
|
targetCallbacks.push(callback);
|
|
117
115
|
callbacks.set(target, targetCallbacks);
|
|
118
116
|
},
|
|
119
117
|
unsubscribe(target, callback) {
|
|
120
|
-
|
|
121
|
-
const targetCallbacks = (_callbacks$get2 = callbacks.get(target)) !== null && _callbacks$get2 !== void 0 ? _callbacks$get2 : [];
|
|
118
|
+
const targetCallbacks = callbacks.get(target) ?? [];
|
|
122
119
|
if (targetCallbacks.length === 1) {
|
|
123
120
|
observer.disconnect();
|
|
124
121
|
callbacks.delete(target);
|
|
@@ -159,7 +156,7 @@ const getInitialState$1 = (keyName, rows) => _reduceInstanceProperty__default["d
|
|
|
159
156
|
const initialValue = currentItem[keyName];
|
|
160
157
|
return _objectSpread$2(_objectSpread$2({}, items), {}, {
|
|
161
158
|
// if there is an initial value: use it, otherwise default to false
|
|
162
|
-
[currentItem.id]: initialValue
|
|
159
|
+
[currentItem.id]: initialValue ?? false
|
|
163
160
|
});
|
|
164
161
|
}, {});
|
|
165
162
|
function selectionReducer(state, action) {
|
|
@@ -96,29 +96,26 @@ function createMutationObserver() {
|
|
|
96
96
|
const callbacks = new _Map__default["default"]();
|
|
97
97
|
const observer = new MutationObserver(rafSchd__default["default"]((mutationsList, observer) => {
|
|
98
98
|
const mutationsByTarget = _reduceInstanceProperty__default["default"](mutationsList).call(mutationsList, (_mutationsByTarget, mutation) => {
|
|
99
|
-
|
|
100
|
-
const callbacksForTarget = (_mutationsByTarget$ge = _mutationsByTarget.get(mutation.target)) !== null && _mutationsByTarget$ge !== void 0 ? _mutationsByTarget$ge : [];
|
|
99
|
+
const callbacksForTarget = _mutationsByTarget.get(mutation.target) ?? [];
|
|
101
100
|
callbacksForTarget.push(mutation);
|
|
102
101
|
_mutationsByTarget.set(mutation.target, callbacksForTarget);
|
|
103
102
|
return _mutationsByTarget;
|
|
104
103
|
}, new _Map__default["default"]());
|
|
105
104
|
_forEachInstanceProperty__default["default"](mutationsByTarget).call(mutationsByTarget, (mutations, target) => {
|
|
106
105
|
const targetCallbacks = callbacks.get(target);
|
|
107
|
-
targetCallbacks
|
|
106
|
+
targetCallbacks?.forEach(cb => cb(mutations, observer));
|
|
108
107
|
});
|
|
109
108
|
}));
|
|
110
109
|
return {
|
|
111
110
|
observer,
|
|
112
111
|
subscribe(target, callback, options) {
|
|
113
|
-
var _callbacks$get;
|
|
114
112
|
observer.observe(target, options);
|
|
115
|
-
const targetCallbacks =
|
|
113
|
+
const targetCallbacks = callbacks.get(target) ?? [];
|
|
116
114
|
targetCallbacks.push(callback);
|
|
117
115
|
callbacks.set(target, targetCallbacks);
|
|
118
116
|
},
|
|
119
117
|
unsubscribe(target, callback) {
|
|
120
|
-
|
|
121
|
-
const targetCallbacks = (_callbacks$get2 = callbacks.get(target)) !== null && _callbacks$get2 !== void 0 ? _callbacks$get2 : [];
|
|
118
|
+
const targetCallbacks = callbacks.get(target) ?? [];
|
|
122
119
|
if (targetCallbacks.length === 1) {
|
|
123
120
|
observer.disconnect();
|
|
124
121
|
callbacks.delete(target);
|
|
@@ -159,7 +156,7 @@ const getInitialState$1 = (keyName, rows) => _reduceInstanceProperty__default["d
|
|
|
159
156
|
const initialValue = currentItem[keyName];
|
|
160
157
|
return _objectSpread$2(_objectSpread$2({}, items), {}, {
|
|
161
158
|
// if there is an initial value: use it, otherwise default to false
|
|
162
|
-
[currentItem.id]: initialValue
|
|
159
|
+
[currentItem.id]: initialValue ?? false
|
|
163
160
|
});
|
|
164
161
|
}, {});
|
|
165
162
|
function selectionReducer(state, action) {
|
|
@@ -72,29 +72,26 @@ function createMutationObserver() {
|
|
|
72
72
|
const callbacks = new _Map();
|
|
73
73
|
const observer = new MutationObserver(rafSchd((mutationsList, observer) => {
|
|
74
74
|
const mutationsByTarget = _reduceInstanceProperty(mutationsList).call(mutationsList, (_mutationsByTarget, mutation) => {
|
|
75
|
-
|
|
76
|
-
const callbacksForTarget = (_mutationsByTarget$ge = _mutationsByTarget.get(mutation.target)) !== null && _mutationsByTarget$ge !== void 0 ? _mutationsByTarget$ge : [];
|
|
75
|
+
const callbacksForTarget = _mutationsByTarget.get(mutation.target) ?? [];
|
|
77
76
|
callbacksForTarget.push(mutation);
|
|
78
77
|
_mutationsByTarget.set(mutation.target, callbacksForTarget);
|
|
79
78
|
return _mutationsByTarget;
|
|
80
79
|
}, new _Map());
|
|
81
80
|
_forEachInstanceProperty(mutationsByTarget).call(mutationsByTarget, (mutations, target) => {
|
|
82
81
|
const targetCallbacks = callbacks.get(target);
|
|
83
|
-
targetCallbacks
|
|
82
|
+
targetCallbacks?.forEach(cb => cb(mutations, observer));
|
|
84
83
|
});
|
|
85
84
|
}));
|
|
86
85
|
return {
|
|
87
86
|
observer,
|
|
88
87
|
subscribe(target, callback, options) {
|
|
89
|
-
var _callbacks$get;
|
|
90
88
|
observer.observe(target, options);
|
|
91
|
-
const targetCallbacks =
|
|
89
|
+
const targetCallbacks = callbacks.get(target) ?? [];
|
|
92
90
|
targetCallbacks.push(callback);
|
|
93
91
|
callbacks.set(target, targetCallbacks);
|
|
94
92
|
},
|
|
95
93
|
unsubscribe(target, callback) {
|
|
96
|
-
|
|
97
|
-
const targetCallbacks = (_callbacks$get2 = callbacks.get(target)) !== null && _callbacks$get2 !== void 0 ? _callbacks$get2 : [];
|
|
94
|
+
const targetCallbacks = callbacks.get(target) ?? [];
|
|
98
95
|
if (targetCallbacks.length === 1) {
|
|
99
96
|
observer.disconnect();
|
|
100
97
|
callbacks.delete(target);
|
|
@@ -135,7 +132,7 @@ const getInitialState$1 = (keyName, rows) => _reduceInstanceProperty(rows).call(
|
|
|
135
132
|
const initialValue = currentItem[keyName];
|
|
136
133
|
return _objectSpread$2(_objectSpread$2({}, items), {}, {
|
|
137
134
|
// if there is an initial value: use it, otherwise default to false
|
|
138
|
-
[currentItem.id]: initialValue
|
|
135
|
+
[currentItem.id]: initialValue ?? false
|
|
139
136
|
});
|
|
140
137
|
}, {});
|
|
141
138
|
function selectionReducer(state, action) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/hooks",
|
|
3
3
|
"description": "A collection of React hooks used across some of the UI-Kit components.",
|
|
4
|
-
"version": "19.
|
|
4
|
+
"version": "19.12.0",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@babel/runtime": "^7.20.13",
|
|
26
26
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
27
|
-
"@commercetools-uikit/utils": "19.
|
|
27
|
+
"@commercetools-uikit/utils": "19.12.0",
|
|
28
28
|
"@types/raf-schd": "^4.0.1",
|
|
29
29
|
"lodash": "4.17.21",
|
|
30
30
|
"raf-schd": "^4.0.3"
|
|
@@ -14,7 +14,7 @@ _globalThis__default["default"].MutationObserver = typeof window !== 'undefined'
|
|
|
14
14
|
function MutationObserver() {
|
|
15
15
|
_classCallCheck(this, MutationObserver);
|
|
16
16
|
}
|
|
17
|
-
_createClass(MutationObserver, [{
|
|
17
|
+
return _createClass(MutationObserver, [{
|
|
18
18
|
key: "observe",
|
|
19
19
|
value: function observe() {}
|
|
20
20
|
}, {
|
|
@@ -26,5 +26,4 @@ _globalThis__default["default"].MutationObserver = typeof window !== 'undefined'
|
|
|
26
26
|
return [];
|
|
27
27
|
}
|
|
28
28
|
}]);
|
|
29
|
-
return MutationObserver;
|
|
30
29
|
}();
|
|
@@ -14,7 +14,7 @@ _globalThis__default["default"].MutationObserver = typeof window !== 'undefined'
|
|
|
14
14
|
function MutationObserver() {
|
|
15
15
|
_classCallCheck(this, MutationObserver);
|
|
16
16
|
}
|
|
17
|
-
_createClass(MutationObserver, [{
|
|
17
|
+
return _createClass(MutationObserver, [{
|
|
18
18
|
key: "observe",
|
|
19
19
|
value: function observe() {}
|
|
20
20
|
}, {
|
|
@@ -26,5 +26,4 @@ _globalThis__default["default"].MutationObserver = typeof window !== 'undefined'
|
|
|
26
26
|
return [];
|
|
27
27
|
}
|
|
28
28
|
}]);
|
|
29
|
-
return MutationObserver;
|
|
30
29
|
}();
|
|
@@ -8,7 +8,7 @@ _globalThis.MutationObserver = typeof window !== 'undefined' && 'MutationObserve
|
|
|
8
8
|
function MutationObserver() {
|
|
9
9
|
_classCallCheck(this, MutationObserver);
|
|
10
10
|
}
|
|
11
|
-
_createClass(MutationObserver, [{
|
|
11
|
+
return _createClass(MutationObserver, [{
|
|
12
12
|
key: "observe",
|
|
13
13
|
value: function observe() {}
|
|
14
14
|
}, {
|
|
@@ -20,5 +20,4 @@ _globalThis.MutationObserver = typeof window !== 'undefined' && 'MutationObserve
|
|
|
20
20
|
return [];
|
|
21
21
|
}
|
|
22
22
|
}]);
|
|
23
|
-
return MutationObserver;
|
|
24
23
|
}();
|