@jobber/hooks 1.13.3 → 2.0.1
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.js +24 -13
- package/dist/useAssert/index.js +2 -1
- package/dist/useAssert/useAssert.js +2 -1
- package/dist/useCollectionQuery/index.js +2 -1
- package/dist/useCollectionQuery/mdxUtils.js +19 -7
- package/dist/useCollectionQuery/test-utilities/index.js +17 -6
- package/dist/useCollectionQuery/test-utilities/mocks.d.ts +3 -3
- package/dist/useCollectionQuery/test-utilities/mocks.js +17 -17
- package/dist/useCollectionQuery/test-utilities/queries.js +57 -9
- package/dist/useCollectionQuery/test-utilities/utils.js +4 -38
- package/dist/useCollectionQuery/uniqueEdges.js +5 -4
- package/dist/useCollectionQuery/uniqueNodes.js +4 -3
- package/dist/useCollectionQuery/useCollectionQuery.d.ts +2 -2
- package/dist/useCollectionQuery/useCollectionQuery.js +60 -101
- package/dist/useCollectionQuery/useCollectionQuery.test.js +240 -429
- package/dist/useFocusTrap/index.js +2 -1
- package/dist/useFocusTrap/useFocusTrap.d.ts +0 -1
- package/dist/useFocusTrap/useFocusTrap.js +11 -10
- package/dist/useFocusTrap/useFocusTrap.test.js +19 -20
- package/dist/useFormState/index.js +2 -1
- package/dist/useFormState/useFormState.d.ts +0 -1
- package/dist/useFormState/useFormState.js +5 -20
- package/dist/useIsMounted/index.js +2 -1
- package/dist/useIsMounted/useIsMounted.js +5 -4
- package/dist/useIsMounted/useIsMounted.test.js +8 -8
- package/dist/useLiveAnnounce/index.js +2 -1
- package/dist/useLiveAnnounce/useLiveAnnounce.js +9 -24
- package/dist/useLiveAnnounce/useLiveAnnounce.test.js +36 -97
- package/dist/useOnKeyDown/index.js +2 -1
- package/dist/useOnKeyDown/useOnKeyDown.d.ts +2 -2
- package/dist/useOnKeyDown/useOnKeyDown.js +7 -6
- package/dist/useOnKeyDown/useOnKeyDown.test.js +9 -10
- package/dist/usePasswordStrength/index.js +2 -1
- package/dist/usePasswordStrength/usePasswordStrength.js +9 -8
- package/dist/useRefocusOnActivator/index.js +2 -1
- package/dist/useRefocusOnActivator/useRefocusOnActivator.js +5 -4
- package/dist/useResizeObserver/index.js +15 -4
- package/dist/useResizeObserver/useResizeObserver.d.ts +0 -1
- package/dist/useResizeObserver/useResizeObserver.js +20 -36
- package/package.json +6 -8
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
17
|
+
__exportStar(require("./useResizeObserver"), exports);
|
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
21
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
|
|
6
|
+
exports.useResizeObserver = exports.Breakpoints = void 0;
|
|
7
|
+
const react_1 = require("react");
|
|
23
8
|
// Importing the polyfilled version of ResizeObserver
|
|
24
9
|
// eslint-disable-next-line import/no-internal-modules
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
const polyfilled_1 = __importDefault(require("use-resize-observer/polyfilled"));
|
|
11
|
+
const lodash_1 = require("lodash");
|
|
27
12
|
exports.Breakpoints = {
|
|
28
13
|
base: 640,
|
|
29
14
|
small: 500,
|
|
@@ -31,24 +16,23 @@ exports.Breakpoints = {
|
|
|
31
16
|
large: 750,
|
|
32
17
|
larger: 1024,
|
|
33
18
|
};
|
|
34
|
-
|
|
35
|
-
function useResizeObserver(
|
|
36
|
-
|
|
37
|
-
var _e = __read(react_1.useState({
|
|
19
|
+
const wait = 100;
|
|
20
|
+
function useResizeObserver({ widths = exports.Breakpoints, heights = exports.Breakpoints, } = {}) {
|
|
21
|
+
const [exactSize, setSize] = (0, react_1.useState)({
|
|
38
22
|
width: undefined,
|
|
39
23
|
height: undefined,
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
onResize
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
24
|
+
});
|
|
25
|
+
const onResize = (0, react_1.useMemo)(() => (0, lodash_1.throttle)(setSize, wait), [wait]);
|
|
26
|
+
const { ref } = (0, polyfilled_1.default)({
|
|
27
|
+
onResize,
|
|
28
|
+
});
|
|
29
|
+
const exactWidth = exactSize.width;
|
|
30
|
+
const exactHeight = exactSize.height;
|
|
31
|
+
const sizes = {
|
|
48
32
|
width: getSize(widths, exactSize.width),
|
|
49
33
|
height: getSize(heights, exactSize.height),
|
|
50
|
-
exactWidth
|
|
51
|
-
exactHeight
|
|
34
|
+
exactWidth,
|
|
35
|
+
exactHeight,
|
|
52
36
|
};
|
|
53
37
|
return [ref, sizes];
|
|
54
38
|
}
|
|
@@ -66,9 +50,9 @@ function getSize(sizes, comparable) {
|
|
|
66
50
|
* Sort the values of our object so that we know they are in proper
|
|
67
51
|
* order to be compared by
|
|
68
52
|
*/
|
|
69
|
-
|
|
70
|
-
.sort(
|
|
53
|
+
const sortedSizes = Object.values(sizes)
|
|
54
|
+
.sort((a, b) => a - b)
|
|
71
55
|
.reverse();
|
|
72
|
-
return (sortedSizes.find(
|
|
56
|
+
return (sortedSizes.find(value => value <= comparable) ||
|
|
73
57
|
sortedSizes[sortedSizes.length - 1]);
|
|
74
58
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/hooks",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.js",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsc --project .",
|
|
8
|
+
"build": "tsc --project . --skipLibCheck",
|
|
9
9
|
"clean": "rm -rf dist/* tsconfig.tsbuildinfo",
|
|
10
10
|
"prepare": "npm run clean; npm run build"
|
|
11
11
|
},
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"dist/*"
|
|
14
14
|
],
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@apollo/client": "^3.3.16",
|
|
17
16
|
"@apollo/react-testing": "^4.0.0",
|
|
18
17
|
"@jobber/formatters": "^0.2.2",
|
|
19
18
|
"@testing-library/react": "^14.0.0",
|
|
@@ -24,8 +23,7 @@
|
|
|
24
23
|
"@types/react-dom": "^18.0.11",
|
|
25
24
|
"@types/uuid": "^8.3.3",
|
|
26
25
|
"@types/zxcvbn": "^4.4.1",
|
|
27
|
-
"
|
|
28
|
-
"typescript": "^3.8.3",
|
|
26
|
+
"typescript": "^4.9.5",
|
|
29
27
|
"uuid": "^8.3.2"
|
|
30
28
|
},
|
|
31
29
|
"dependencies": {
|
|
@@ -37,8 +35,8 @@
|
|
|
37
35
|
"zxcvbn": "^4.4.2"
|
|
38
36
|
},
|
|
39
37
|
"peerDependencies": {
|
|
40
|
-
"@apollo/client": "^3.
|
|
41
|
-
"react": "
|
|
38
|
+
"@apollo/client": "^3.7.10",
|
|
39
|
+
"react": "^18"
|
|
42
40
|
},
|
|
43
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "514a966ad2c394e4b88de2b5af98ad61017a16fe"
|
|
44
42
|
}
|