@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.
Files changed (40) hide show
  1. package/dist/index.js +24 -13
  2. package/dist/useAssert/index.js +2 -1
  3. package/dist/useAssert/useAssert.js +2 -1
  4. package/dist/useCollectionQuery/index.js +2 -1
  5. package/dist/useCollectionQuery/mdxUtils.js +19 -7
  6. package/dist/useCollectionQuery/test-utilities/index.js +17 -6
  7. package/dist/useCollectionQuery/test-utilities/mocks.d.ts +3 -3
  8. package/dist/useCollectionQuery/test-utilities/mocks.js +17 -17
  9. package/dist/useCollectionQuery/test-utilities/queries.js +57 -9
  10. package/dist/useCollectionQuery/test-utilities/utils.js +4 -38
  11. package/dist/useCollectionQuery/uniqueEdges.js +5 -4
  12. package/dist/useCollectionQuery/uniqueNodes.js +4 -3
  13. package/dist/useCollectionQuery/useCollectionQuery.d.ts +2 -2
  14. package/dist/useCollectionQuery/useCollectionQuery.js +60 -101
  15. package/dist/useCollectionQuery/useCollectionQuery.test.js +240 -429
  16. package/dist/useFocusTrap/index.js +2 -1
  17. package/dist/useFocusTrap/useFocusTrap.d.ts +0 -1
  18. package/dist/useFocusTrap/useFocusTrap.js +11 -10
  19. package/dist/useFocusTrap/useFocusTrap.test.js +19 -20
  20. package/dist/useFormState/index.js +2 -1
  21. package/dist/useFormState/useFormState.d.ts +0 -1
  22. package/dist/useFormState/useFormState.js +5 -20
  23. package/dist/useIsMounted/index.js +2 -1
  24. package/dist/useIsMounted/useIsMounted.js +5 -4
  25. package/dist/useIsMounted/useIsMounted.test.js +8 -8
  26. package/dist/useLiveAnnounce/index.js +2 -1
  27. package/dist/useLiveAnnounce/useLiveAnnounce.js +9 -24
  28. package/dist/useLiveAnnounce/useLiveAnnounce.test.js +36 -97
  29. package/dist/useOnKeyDown/index.js +2 -1
  30. package/dist/useOnKeyDown/useOnKeyDown.d.ts +2 -2
  31. package/dist/useOnKeyDown/useOnKeyDown.js +7 -6
  32. package/dist/useOnKeyDown/useOnKeyDown.test.js +9 -10
  33. package/dist/usePasswordStrength/index.js +2 -1
  34. package/dist/usePasswordStrength/usePasswordStrength.js +9 -8
  35. package/dist/useRefocusOnActivator/index.js +2 -1
  36. package/dist/useRefocusOnActivator/useRefocusOnActivator.js +5 -4
  37. package/dist/useResizeObserver/index.js +15 -4
  38. package/dist/useResizeObserver/useResizeObserver.d.ts +0 -1
  39. package/dist/useResizeObserver/useResizeObserver.js +20 -36
  40. package/package.json +6 -8
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
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
- __export(require("./useResizeObserver"));
17
+ __exportStar(require("./useResizeObserver"), exports);
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Breakpoints: {
3
2
  base: number;
4
3
  small: number;
@@ -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
- var react_1 = require("react");
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
- var polyfilled_1 = __importDefault(require("use-resize-observer/polyfilled"));
26
- var lodash_1 = require("lodash");
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
- var wait = 100;
35
- function useResizeObserver(_a) {
36
- var _b = _a === void 0 ? {} : _a, _c = _b.widths, widths = _c === void 0 ? exports.Breakpoints : _c, _d = _b.heights, heights = _d === void 0 ? exports.Breakpoints : _d;
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
- }), 2), exactSize = _e[0], setSize = _e[1];
41
- var onResize = react_1.useMemo(function () { return lodash_1.throttle(setSize, wait); }, [wait]);
42
- var ref = polyfilled_1.default({
43
- onResize: onResize,
44
- }).ref;
45
- var exactWidth = exactSize.width;
46
- var exactHeight = exactSize.height;
47
- var sizes = {
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: exactWidth,
51
- exactHeight: 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
- var sortedSizes = Object.values(sizes)
70
- .sort(function (a, b) { return a - b; })
53
+ const sortedSizes = Object.values(sizes)
54
+ .sort((a, b) => a - b)
71
55
  .reverse();
72
- return (sortedSizes.find(function (value) { return value <= comparable; }) ||
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": "1.13.3",
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
- "graphql": "^14.6.0",
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.3.16",
41
- "react": ">=16.8"
38
+ "@apollo/client": "^3.7.10",
39
+ "react": "^18"
42
40
  },
43
- "gitHead": "c92b6e7287a47c05434202bfbcd04375b6a7086f"
41
+ "gitHead": "514a966ad2c394e4b88de2b5af98ad61017a16fe"
44
42
  }