@commercetools-uikit/hooks 20.2.2 → 20.3.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.
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _Map = require('@babel/runtime-corejs3/core-js-stable/map');
|
|
6
6
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
7
7
|
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
8
|
-
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
9
8
|
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
10
9
|
var _spliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/splice');
|
|
11
10
|
var react = require('react');
|
|
@@ -30,7 +29,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
|
|
|
30
29
|
var _Map__default = /*#__PURE__*/_interopDefault(_Map);
|
|
31
30
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
32
31
|
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
33
|
-
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
34
32
|
var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
|
|
35
33
|
var _spliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_spliceInstanceProperty);
|
|
36
34
|
var rafSchd__default = /*#__PURE__*/_interopDefault(rafSchd);
|
|
@@ -98,27 +96,29 @@ function createMutationObserver() {
|
|
|
98
96
|
const callbacks = new _Map__default["default"]();
|
|
99
97
|
const observer = new MutationObserver(rafSchd__default["default"]((mutationsList, observer) => {
|
|
100
98
|
const mutationsByTarget = _reduceInstanceProperty__default["default"](mutationsList).call(mutationsList, (_mutationsByTarget, mutation) => {
|
|
101
|
-
|
|
99
|
+
var _mutationsByTarget$ge;
|
|
100
|
+
const callbacksForTarget = (_mutationsByTarget$ge = _mutationsByTarget.get(mutation.target)) !== null && _mutationsByTarget$ge !== void 0 ? _mutationsByTarget$ge : [];
|
|
102
101
|
callbacksForTarget.push(mutation);
|
|
103
102
|
_mutationsByTarget.set(mutation.target, callbacksForTarget);
|
|
104
103
|
return _mutationsByTarget;
|
|
105
104
|
}, new _Map__default["default"]());
|
|
106
105
|
_forEachInstanceProperty__default["default"](mutationsByTarget).call(mutationsByTarget, (mutations, target) => {
|
|
107
|
-
var _context, _context2;
|
|
108
106
|
const targetCallbacks = callbacks.get(target);
|
|
109
|
-
|
|
107
|
+
targetCallbacks === null || targetCallbacks === void 0 || _forEachInstanceProperty__default["default"](targetCallbacks).call(targetCallbacks, cb => cb(mutations, observer));
|
|
110
108
|
});
|
|
111
109
|
}));
|
|
112
110
|
return {
|
|
113
111
|
observer,
|
|
114
112
|
subscribe(target, callback, options) {
|
|
113
|
+
var _callbacks$get;
|
|
115
114
|
observer.observe(target, options);
|
|
116
|
-
const targetCallbacks = callbacks.get(target)
|
|
115
|
+
const targetCallbacks = (_callbacks$get = callbacks.get(target)) !== null && _callbacks$get !== void 0 ? _callbacks$get : [];
|
|
117
116
|
targetCallbacks.push(callback);
|
|
118
117
|
callbacks.set(target, targetCallbacks);
|
|
119
118
|
},
|
|
120
119
|
unsubscribe(target, callback) {
|
|
121
|
-
|
|
120
|
+
var _callbacks$get2;
|
|
121
|
+
const targetCallbacks = (_callbacks$get2 = callbacks.get(target)) !== null && _callbacks$get2 !== void 0 ? _callbacks$get2 : [];
|
|
122
122
|
if (targetCallbacks.length === 1) {
|
|
123
123
|
observer.disconnect();
|
|
124
124
|
callbacks.delete(target);
|
|
@@ -159,7 +159,7 @@ const getInitialState$1 = (keyName, rows) => _reduceInstanceProperty__default["d
|
|
|
159
159
|
const initialValue = currentItem[keyName];
|
|
160
160
|
return _objectSpread$2(_objectSpread$2({}, items), {}, {
|
|
161
161
|
// if there is an initial value: use it, otherwise default to false
|
|
162
|
-
[currentItem.id]: initialValue
|
|
162
|
+
[currentItem.id]: initialValue !== null && initialValue !== void 0 ? initialValue : false
|
|
163
163
|
});
|
|
164
164
|
}, {});
|
|
165
165
|
function selectionReducer(state, action) {
|
|
@@ -359,7 +359,7 @@ const useDataTableSortingState = function () {
|
|
|
359
359
|
var useDataTableSortingState$1 = useDataTableSortingState;
|
|
360
360
|
|
|
361
361
|
// NOTE: This string will be replaced on build time with the package version.
|
|
362
|
-
var version = "20.
|
|
362
|
+
var version = "20.3.0";
|
|
363
363
|
|
|
364
364
|
exports.useDataTableSortingState = useDataTableSortingState$1;
|
|
365
365
|
exports.useFieldId = useFieldId$1;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _Map = require('@babel/runtime-corejs3/core-js-stable/map');
|
|
6
6
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
7
7
|
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
8
|
-
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
9
8
|
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
10
9
|
var _spliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/splice');
|
|
11
10
|
var react = require('react');
|
|
@@ -30,7 +29,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
|
|
|
30
29
|
var _Map__default = /*#__PURE__*/_interopDefault(_Map);
|
|
31
30
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
32
31
|
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
33
|
-
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
34
32
|
var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
|
|
35
33
|
var _spliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_spliceInstanceProperty);
|
|
36
34
|
var rafSchd__default = /*#__PURE__*/_interopDefault(rafSchd);
|
|
@@ -98,27 +96,29 @@ function createMutationObserver() {
|
|
|
98
96
|
const callbacks = new _Map__default["default"]();
|
|
99
97
|
const observer = new MutationObserver(rafSchd__default["default"]((mutationsList, observer) => {
|
|
100
98
|
const mutationsByTarget = _reduceInstanceProperty__default["default"](mutationsList).call(mutationsList, (_mutationsByTarget, mutation) => {
|
|
101
|
-
|
|
99
|
+
var _mutationsByTarget$ge;
|
|
100
|
+
const callbacksForTarget = (_mutationsByTarget$ge = _mutationsByTarget.get(mutation.target)) !== null && _mutationsByTarget$ge !== void 0 ? _mutationsByTarget$ge : [];
|
|
102
101
|
callbacksForTarget.push(mutation);
|
|
103
102
|
_mutationsByTarget.set(mutation.target, callbacksForTarget);
|
|
104
103
|
return _mutationsByTarget;
|
|
105
104
|
}, new _Map__default["default"]());
|
|
106
105
|
_forEachInstanceProperty__default["default"](mutationsByTarget).call(mutationsByTarget, (mutations, target) => {
|
|
107
|
-
var _context, _context2;
|
|
108
106
|
const targetCallbacks = callbacks.get(target);
|
|
109
|
-
|
|
107
|
+
targetCallbacks === null || targetCallbacks === void 0 || _forEachInstanceProperty__default["default"](targetCallbacks).call(targetCallbacks, cb => cb(mutations, observer));
|
|
110
108
|
});
|
|
111
109
|
}));
|
|
112
110
|
return {
|
|
113
111
|
observer,
|
|
114
112
|
subscribe(target, callback, options) {
|
|
113
|
+
var _callbacks$get;
|
|
115
114
|
observer.observe(target, options);
|
|
116
|
-
const targetCallbacks = callbacks.get(target)
|
|
115
|
+
const targetCallbacks = (_callbacks$get = callbacks.get(target)) !== null && _callbacks$get !== void 0 ? _callbacks$get : [];
|
|
117
116
|
targetCallbacks.push(callback);
|
|
118
117
|
callbacks.set(target, targetCallbacks);
|
|
119
118
|
},
|
|
120
119
|
unsubscribe(target, callback) {
|
|
121
|
-
|
|
120
|
+
var _callbacks$get2;
|
|
121
|
+
const targetCallbacks = (_callbacks$get2 = callbacks.get(target)) !== null && _callbacks$get2 !== void 0 ? _callbacks$get2 : [];
|
|
122
122
|
if (targetCallbacks.length === 1) {
|
|
123
123
|
observer.disconnect();
|
|
124
124
|
callbacks.delete(target);
|
|
@@ -159,7 +159,7 @@ const getInitialState$1 = (keyName, rows) => _reduceInstanceProperty__default["d
|
|
|
159
159
|
const initialValue = currentItem[keyName];
|
|
160
160
|
return _objectSpread$2(_objectSpread$2({}, items), {}, {
|
|
161
161
|
// if there is an initial value: use it, otherwise default to false
|
|
162
|
-
[currentItem.id]: initialValue
|
|
162
|
+
[currentItem.id]: initialValue !== null && initialValue !== void 0 ? initialValue : false
|
|
163
163
|
});
|
|
164
164
|
}, {});
|
|
165
165
|
function selectionReducer(state, action) {
|
|
@@ -359,7 +359,7 @@ const useDataTableSortingState = function () {
|
|
|
359
359
|
var useDataTableSortingState$1 = useDataTableSortingState;
|
|
360
360
|
|
|
361
361
|
// NOTE: This string will be replaced on build time with the package version.
|
|
362
|
-
var version = "20.
|
|
362
|
+
var version = "20.3.0";
|
|
363
363
|
|
|
364
364
|
exports.useDataTableSortingState = useDataTableSortingState$1;
|
|
365
365
|
exports.useFieldId = useFieldId$1;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _Map from '@babel/runtime-corejs3/core-js-stable/map';
|
|
2
2
|
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
3
3
|
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
4
|
-
import _bindInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/bind';
|
|
5
4
|
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/index-of';
|
|
6
5
|
import _spliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/splice';
|
|
7
6
|
import { useState, useCallback, useRef, useEffect, useLayoutEffect, useReducer, useDebugValue } from 'react';
|
|
@@ -73,27 +72,29 @@ function createMutationObserver() {
|
|
|
73
72
|
const callbacks = new _Map();
|
|
74
73
|
const observer = new MutationObserver(rafSchd((mutationsList, observer) => {
|
|
75
74
|
const mutationsByTarget = _reduceInstanceProperty(mutationsList).call(mutationsList, (_mutationsByTarget, mutation) => {
|
|
76
|
-
|
|
75
|
+
var _mutationsByTarget$ge;
|
|
76
|
+
const callbacksForTarget = (_mutationsByTarget$ge = _mutationsByTarget.get(mutation.target)) !== null && _mutationsByTarget$ge !== void 0 ? _mutationsByTarget$ge : [];
|
|
77
77
|
callbacksForTarget.push(mutation);
|
|
78
78
|
_mutationsByTarget.set(mutation.target, callbacksForTarget);
|
|
79
79
|
return _mutationsByTarget;
|
|
80
80
|
}, new _Map());
|
|
81
81
|
_forEachInstanceProperty(mutationsByTarget).call(mutationsByTarget, (mutations, target) => {
|
|
82
|
-
var _context, _context2;
|
|
83
82
|
const targetCallbacks = callbacks.get(target);
|
|
84
|
-
|
|
83
|
+
targetCallbacks === null || targetCallbacks === void 0 || _forEachInstanceProperty(targetCallbacks).call(targetCallbacks, cb => cb(mutations, observer));
|
|
85
84
|
});
|
|
86
85
|
}));
|
|
87
86
|
return {
|
|
88
87
|
observer,
|
|
89
88
|
subscribe(target, callback, options) {
|
|
89
|
+
var _callbacks$get;
|
|
90
90
|
observer.observe(target, options);
|
|
91
|
-
const targetCallbacks = callbacks.get(target)
|
|
91
|
+
const targetCallbacks = (_callbacks$get = callbacks.get(target)) !== null && _callbacks$get !== void 0 ? _callbacks$get : [];
|
|
92
92
|
targetCallbacks.push(callback);
|
|
93
93
|
callbacks.set(target, targetCallbacks);
|
|
94
94
|
},
|
|
95
95
|
unsubscribe(target, callback) {
|
|
96
|
-
|
|
96
|
+
var _callbacks$get2;
|
|
97
|
+
const targetCallbacks = (_callbacks$get2 = callbacks.get(target)) !== null && _callbacks$get2 !== void 0 ? _callbacks$get2 : [];
|
|
97
98
|
if (targetCallbacks.length === 1) {
|
|
98
99
|
observer.disconnect();
|
|
99
100
|
callbacks.delete(target);
|
|
@@ -134,7 +135,7 @@ const getInitialState$1 = (keyName, rows) => _reduceInstanceProperty(rows).call(
|
|
|
134
135
|
const initialValue = currentItem[keyName];
|
|
135
136
|
return _objectSpread$2(_objectSpread$2({}, items), {}, {
|
|
136
137
|
// if there is an initial value: use it, otherwise default to false
|
|
137
|
-
[currentItem.id]: initialValue
|
|
138
|
+
[currentItem.id]: initialValue !== null && initialValue !== void 0 ? initialValue : false
|
|
138
139
|
});
|
|
139
140
|
}, {});
|
|
140
141
|
function selectionReducer(state, action) {
|
|
@@ -334,6 +335,6 @@ const useDataTableSortingState = function () {
|
|
|
334
335
|
var useDataTableSortingState$1 = useDataTableSortingState;
|
|
335
336
|
|
|
336
337
|
// NOTE: This string will be replaced on build time with the package version.
|
|
337
|
-
var version = "20.
|
|
338
|
+
var version = "20.3.0";
|
|
338
339
|
|
|
339
340
|
export { useDataTableSortingState$1 as useDataTableSortingState, useFieldId$1 as useFieldId, useMutationObserver, usePaginationState$1 as usePaginationState, usePrevious$1 as usePrevious, useRowSelection$1 as useRowSelection, useSorting$1 as useSorting, useToggleState$1 as useToggleState, version };
|
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": "20.
|
|
4
|
+
"version": "20.3.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": "20.
|
|
27
|
+
"@commercetools-uikit/utils": "20.3.0",
|
|
28
28
|
"@types/raf-schd": "^4.0.1",
|
|
29
29
|
"lodash": "4.17.21",
|
|
30
30
|
"raf-schd": "^4.0.3"
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@testing-library/dom": "^10.4.0",
|
|
34
34
|
"@testing-library/react": "^16.2.0",
|
|
35
|
-
"react": "19.
|
|
36
|
-
"react-dom": "19.
|
|
35
|
+
"react": "19.2.0",
|
|
36
|
+
"react-dom": "19.2.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "19.x",
|