@jobber/hooks 2.0.3-pre1.52 → 2.0.3-pre1.54

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 (51) hide show
  1. package/dist/index.d.ts +0 -3
  2. package/dist/index.js +23 -10
  3. package/dist/useAssert/index.js +5 -1
  4. package/dist/useAssert/useAssert.js +10 -3
  5. package/dist/useFocusTrap/index.js +5 -1
  6. package/dist/useFocusTrap/useFocusTrap.js +8 -4
  7. package/dist/useFormState/index.js +5 -1
  8. package/dist/useFormState/useFormState.js +7 -3
  9. package/dist/useIsMounted/index.js +5 -1
  10. package/dist/useIsMounted/useIsMounted.js +8 -4
  11. package/dist/useIsMounted/useIsMounted.test.js +6 -4
  12. package/dist/useLiveAnnounce/index.js +5 -1
  13. package/dist/useLiveAnnounce/useLiveAnnounce.js +8 -4
  14. package/dist/useLiveAnnounce/useLiveAnnounce.test.js +24 -19
  15. package/dist/usePasswordStrength/index.js +5 -1
  16. package/dist/usePasswordStrength/usePasswordStrength.js +11 -4
  17. package/dist/useRefocusOnActivator/index.js +5 -1
  18. package/dist/useRefocusOnActivator/useRefocusOnActivator.js +7 -3
  19. package/package.json +4 -3
  20. package/dist/useCollectionQuery/index.d.ts +0 -1
  21. package/dist/useCollectionQuery/index.js +0 -1
  22. package/dist/useCollectionQuery/mdxUtils.d.ts +0 -52
  23. package/dist/useCollectionQuery/mdxUtils.js +0 -148
  24. package/dist/useCollectionQuery/test-utilities/index.d.ts +0 -3
  25. package/dist/useCollectionQuery/test-utilities/index.js +0 -3
  26. package/dist/useCollectionQuery/test-utilities/mocks.d.ts +0 -107
  27. package/dist/useCollectionQuery/test-utilities/mocks.js +0 -120
  28. package/dist/useCollectionQuery/test-utilities/queries.d.ts +0 -37
  29. package/dist/useCollectionQuery/test-utilities/queries.js +0 -56
  30. package/dist/useCollectionQuery/test-utilities/utils.d.ts +0 -1
  31. package/dist/useCollectionQuery/test-utilities/utils.js +0 -14
  32. package/dist/useCollectionQuery/uniqueEdges.d.ts +0 -8
  33. package/dist/useCollectionQuery/uniqueEdges.js +0 -14
  34. package/dist/useCollectionQuery/uniqueNodes.d.ts +0 -5
  35. package/dist/useCollectionQuery/uniqueNodes.js +0 -7
  36. package/dist/useCollectionQuery/useCollectionQuery.d.ts +0 -71
  37. package/dist/useCollectionQuery/useCollectionQuery.js +0 -176
  38. package/dist/useCollectionQuery/useCollectionQuery.test.d.ts +0 -1
  39. package/dist/useCollectionQuery/useCollectionQuery.test.js +0 -327
  40. package/dist/useFocusTrap/useFocusTrap.test.d.ts +0 -1
  41. package/dist/useFocusTrap/useFocusTrap.test.js +0 -47
  42. package/dist/useOnKeyDown/index.d.ts +0 -1
  43. package/dist/useOnKeyDown/index.js +0 -1
  44. package/dist/useOnKeyDown/useOnKeyDown.d.ts +0 -13
  45. package/dist/useOnKeyDown/useOnKeyDown.js +0 -26
  46. package/dist/useOnKeyDown/useOnKeyDown.test.d.ts +0 -1
  47. package/dist/useOnKeyDown/useOnKeyDown.test.js +0 -18
  48. package/dist/useResizeObserver/index.d.ts +0 -1
  49. package/dist/useResizeObserver/index.js +0 -1
  50. package/dist/useResizeObserver/useResizeObserver.d.ts +0 -18
  51. package/dist/useResizeObserver/useResizeObserver.js +0 -51
package/dist/index.d.ts CHANGED
@@ -1,10 +1,7 @@
1
1
  export * from "./useAssert/index.js";
2
- export * from "./useCollectionQuery/index.js";
3
2
  export * from "./useFocusTrap/index.js";
4
3
  export * from "./useFormState/index.js";
5
4
  export * from "./useIsMounted/index.js";
6
5
  export * from "./useLiveAnnounce/index.js";
7
- export * from "./useOnKeyDown/index.js";
8
6
  export * from "./usePasswordStrength/index.js";
9
7
  export * from "./useRefocusOnActivator/index.js";
10
- export * from "./useResizeObserver/index.js";
package/dist/index.js CHANGED
@@ -1,11 +1,24 @@
1
+ "use strict";
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
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
1
17
  /* eslint-disable import/no-internal-modules */
2
- export * from "./useAssert/index.js";
3
- export * from "./useCollectionQuery/index.js";
4
- export * from "./useFocusTrap/index.js";
5
- export * from "./useFormState/index.js";
6
- export * from "./useIsMounted/index.js";
7
- export * from "./useLiveAnnounce/index.js";
8
- export * from "./useOnKeyDown/index.js";
9
- export * from "./usePasswordStrength/index.js";
10
- export * from "./useRefocusOnActivator/index.js";
11
- export * from "./useResizeObserver/index.js";
18
+ __exportStar(require("./useAssert/index.js"), exports);
19
+ __exportStar(require("./useFocusTrap/index.js"), exports);
20
+ __exportStar(require("./useFormState/index.js"), exports);
21
+ __exportStar(require("./useIsMounted/index.js"), exports);
22
+ __exportStar(require("./useLiveAnnounce/index.js"), exports);
23
+ __exportStar(require("./usePasswordStrength/index.js"), exports);
24
+ __exportStar(require("./useRefocusOnActivator/index.js"), exports);
@@ -1 +1,5 @@
1
- export { useAssert } from "./useAssert.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAssert = void 0;
4
+ var useAssert_js_1 = require("./useAssert.js");
5
+ Object.defineProperty(exports, "useAssert", { enumerable: true, get: function () { return useAssert_js_1.useAssert; } });
@@ -1,6 +1,12 @@
1
- import process from "process";
2
- export function useAssert(shouldShow, message, options) {
3
- if (process.env.NODE_ENV !== "production" && shouldShow) {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useAssert = void 0;
7
+ const process_1 = __importDefault(require("process"));
8
+ function useAssert(shouldShow, message, options) {
9
+ if (process_1.default.env.NODE_ENV !== "production" && shouldShow) {
4
10
  if (options === null || options === void 0 ? void 0 : options.warn) {
5
11
  console.warn(message);
6
12
  }
@@ -9,3 +15,4 @@ export function useAssert(shouldShow, message, options) {
9
15
  }
10
16
  }
11
17
  }
18
+ exports.useAssert = useAssert;
@@ -1 +1,5 @@
1
- export { useFocusTrap } from "./useFocusTrap.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFocusTrap = void 0;
4
+ var useFocusTrap_js_1 = require("./useFocusTrap.js");
5
+ Object.defineProperty(exports, "useFocusTrap", { enumerable: true, get: function () { return useFocusTrap_js_1.useFocusTrap; } });
@@ -1,4 +1,7 @@
1
- import { useEffect, useRef } from "react";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFocusTrap = void 0;
4
+ const react_1 = require("react");
2
5
  /**
3
6
  * Traps the focus within the children of the ref element.
4
7
  *
@@ -7,11 +10,11 @@ import { useEffect, useRef } from "react";
7
10
  *
8
11
  * @returns ref
9
12
  */
10
- export function useFocusTrap(active) {
13
+ function useFocusTrap(active) {
11
14
  // There's an ongoing issue with useRef return type clashing with an element's
12
15
  // ref prop type. TLDR: Use null because useRef doesn't expect undefined.
13
16
  // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/35572
14
- const ref = useRef(null);
17
+ const ref = (0, react_1.useRef)(null);
15
18
  function handleKeyDown(event) {
16
19
  if (!(active && ref.current) || event.key !== "Tab") {
17
20
  return;
@@ -30,7 +33,7 @@ export function useFocusTrap(active) {
30
33
  }
31
34
  }
32
35
  }
33
- useEffect(() => {
36
+ (0, react_1.useEffect)(() => {
34
37
  var _a, _b;
35
38
  if (active) {
36
39
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
@@ -43,6 +46,7 @@ export function useFocusTrap(active) {
43
46
  }, [active]);
44
47
  return ref;
45
48
  }
49
+ exports.useFocusTrap = useFocusTrap;
46
50
  function getElements(ref) {
47
51
  const focusables = [
48
52
  "button",
@@ -1 +1,5 @@
1
- export { useFormState } from "./useFormState.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFormState = void 0;
4
+ var useFormState_js_1 = require("./useFormState.js");
5
+ Object.defineProperty(exports, "useFormState", { enumerable: true, get: function () { return useFormState_js_1.useFormState; } });
@@ -1,8 +1,12 @@
1
- import { useState } from "react";
2
- export function useFormState() {
3
- const [formState, setFormState] = useState({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFormState = void 0;
4
+ const react_1 = require("react");
5
+ function useFormState() {
6
+ const [formState, setFormState] = (0, react_1.useState)({
4
7
  isDirty: false,
5
8
  isValid: true,
6
9
  });
7
10
  return [formState, setFormState];
8
11
  }
12
+ exports.useFormState = useFormState;
@@ -1 +1,5 @@
1
- export { useIsMounted } from "./useIsMounted.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIsMounted = void 0;
4
+ var useIsMounted_js_1 = require("./useIsMounted.js");
5
+ Object.defineProperty(exports, "useIsMounted", { enumerable: true, get: function () { return useIsMounted_js_1.useIsMounted; } });
@@ -1,4 +1,7 @@
1
- import { useLayoutEffect, useRef } from "react";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIsMounted = void 0;
4
+ const react_1 = require("react");
2
5
  /**
3
6
  * Why does this work?
4
7
  *
@@ -15,9 +18,9 @@ import { useLayoutEffect, useRef } from "react";
15
18
  * When the component unmounts, it calls the cleanup function that sets `isMounted` to false.
16
19
  * This `useLayoutEffect` hook will only be run once.
17
20
  */
18
- export function useIsMounted() {
19
- const isMounted = useRef(false);
20
- useLayoutEffect(() => {
21
+ function useIsMounted() {
22
+ const isMounted = (0, react_1.useRef)(false);
23
+ (0, react_1.useLayoutEffect)(() => {
21
24
  isMounted.current = true;
22
25
  return () => {
23
26
  isMounted.current = false;
@@ -25,3 +28,4 @@ export function useIsMounted() {
25
28
  }, []);
26
29
  return isMounted;
27
30
  }
31
+ exports.useIsMounted = useIsMounted;
@@ -1,12 +1,14 @@
1
- import { renderHook } from "@testing-library/react-hooks";
2
- import { useIsMounted } from "./useIsMounted.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_hooks_1 = require("@testing-library/react-hooks");
4
+ const useIsMounted_js_1 = require("./useIsMounted.js");
3
5
  it("should return true when the component is currently mounted", () => {
4
- const { result } = renderHook(() => useIsMounted());
6
+ const { result } = (0, react_hooks_1.renderHook)(() => (0, useIsMounted_js_1.useIsMounted)());
5
7
  const isMounted = result.current;
6
8
  expect(isMounted.current).toBe(true);
7
9
  });
8
10
  it("should return false when the component is unmounted", () => {
9
- const { result, unmount } = renderHook(() => useIsMounted());
11
+ const { result, unmount } = (0, react_hooks_1.renderHook)(() => (0, useIsMounted_js_1.useIsMounted)());
10
12
  const isMounted = result.current;
11
13
  unmount();
12
14
  expect(isMounted.current).toBe(false);
@@ -1 +1,5 @@
1
- export { useLiveAnnounce } from "./useLiveAnnounce.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLiveAnnounce = void 0;
4
+ var useLiveAnnounce_js_1 = require("./useLiveAnnounce.js");
5
+ Object.defineProperty(exports, "useLiveAnnounce", { enumerable: true, get: function () { return useLiveAnnounce_js_1.useLiveAnnounce; } });
@@ -1,12 +1,15 @@
1
- import { useEffect, useState } from "react";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLiveAnnounce = void 0;
4
+ const react_1 = require("react");
2
5
  /**
3
6
  * Announce a message on voice over whenever you do an action. This is
4
7
  * especially helpful when you have an action that adds or deletes an element
5
8
  * from the screen.
6
9
  */
7
- export function useLiveAnnounce() {
8
- const [announcedMessage, setAnnouncedMessage] = useState("");
9
- useEffect(() => {
10
+ function useLiveAnnounce() {
11
+ const [announcedMessage, setAnnouncedMessage] = (0, react_1.useState)("");
12
+ (0, react_1.useEffect)(() => {
10
13
  let target;
11
14
  if (announcedMessage) {
12
15
  target = createAnnouncedElement();
@@ -20,6 +23,7 @@ export function useLiveAnnounce() {
20
23
  },
21
24
  };
22
25
  }
26
+ exports.useLiveAnnounce = useLiveAnnounce;
23
27
  // eslint-disable-next-line max-statements
24
28
  function createAnnouncedElement() {
25
29
  const el = document.createElement("div");
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,26 +8,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
10
- import React from "react";
11
- import { act, render, screen, waitFor } from "@testing-library/react";
12
- import { useLiveAnnounce } from "./index.js";
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const react_1 = __importDefault(require("react"));
16
+ const react_2 = require("@testing-library/react");
17
+ const index_js_1 = require("./index.js");
13
18
  function setupHook() {
14
19
  const returnVal = {
15
20
  liveAnnounce: jest.fn,
16
21
  };
17
22
  function TestComponent() {
18
- Object.assign(returnVal, useLiveAnnounce());
19
- return React.createElement(React.Fragment, null);
23
+ Object.assign(returnVal, (0, index_js_1.useLiveAnnounce)());
24
+ return react_1.default.createElement(react_1.default.Fragment, null);
20
25
  }
21
- const { rerender } = render(React.createElement(TestComponent, null));
22
- return Object.assign(Object.assign({}, returnVal), { rerenderComponent: () => rerender(React.createElement(TestComponent, null)) });
26
+ const { rerender } = (0, react_2.render)(react_1.default.createElement(TestComponent, null));
27
+ return Object.assign(Object.assign({}, returnVal), { rerenderComponent: () => rerender(react_1.default.createElement(TestComponent, null)) });
23
28
  }
24
29
  it("should render a div to announce", () => __awaiter(void 0, void 0, void 0, function* () {
25
30
  const { liveAnnounce } = setupHook();
26
31
  const message = "Huzzah";
27
- act(() => liveAnnounce(message));
28
- yield waitFor(() => {
29
- const expectedElement = screen.queryByRole("status");
32
+ (0, react_2.act)(() => liveAnnounce(message));
33
+ yield (0, react_2.waitFor)(() => {
34
+ const expectedElement = react_2.screen.queryByRole("status");
30
35
  expect(expectedElement).toBeInTheDocument();
31
36
  expect(expectedElement === null || expectedElement === void 0 ? void 0 : expectedElement.textContent).toBe(message);
32
37
  expect(expectedElement).toHaveAttribute("role", "status");
@@ -36,20 +41,20 @@ it("should render a div to announce", () => __awaiter(void 0, void 0, void 0, fu
36
41
  }));
37
42
  it("should not render the announced div", () => __awaiter(void 0, void 0, void 0, function* () {
38
43
  setupHook();
39
- expect(screen.queryByRole("status")).not.toBeInTheDocument();
44
+ expect(react_2.screen.queryByRole("status")).not.toBeInTheDocument();
40
45
  }));
41
46
  it("should only have 1 div to announce a message on a single instance of the hook", () => __awaiter(void 0, void 0, void 0, function* () {
42
47
  const { liveAnnounce } = setupHook();
43
48
  const firstMessage = "I am first";
44
49
  const secondMessage = "I am second";
45
- act(() => liveAnnounce(firstMessage));
46
- yield waitFor(() => {
47
- expect(screen.queryAllByRole("status")).toHaveLength(1);
48
- expect(screen.getByRole("status").textContent).toBe(firstMessage);
50
+ (0, react_2.act)(() => liveAnnounce(firstMessage));
51
+ yield (0, react_2.waitFor)(() => {
52
+ expect(react_2.screen.queryAllByRole("status")).toHaveLength(1);
53
+ expect(react_2.screen.getByRole("status").textContent).toBe(firstMessage);
49
54
  });
50
- act(() => liveAnnounce(secondMessage));
51
- yield waitFor(() => {
52
- expect(screen.queryAllByRole("status")).toHaveLength(1);
53
- expect(screen.getByRole("status").textContent).toBe(secondMessage);
55
+ (0, react_2.act)(() => liveAnnounce(secondMessage));
56
+ yield (0, react_2.waitFor)(() => {
57
+ expect(react_2.screen.queryAllByRole("status")).toHaveLength(1);
58
+ expect(react_2.screen.getByRole("status").textContent).toBe(secondMessage);
54
59
  });
55
60
  }));
@@ -1 +1,5 @@
1
- export { usePasswordStrength } from "./usePasswordStrength.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePasswordStrength = void 0;
4
+ var usePasswordStrength_js_1 = require("./usePasswordStrength.js");
5
+ Object.defineProperty(exports, "usePasswordStrength", { enumerable: true, get: function () { return usePasswordStrength_js_1.usePasswordStrength; } });
@@ -1,7 +1,13 @@
1
- import { useMemo } from "react";
2
- import calculateStrength from "zxcvbn";
3
- export function usePasswordStrength(password, dictionary) {
4
- const { guesses, score, feedback: { warning, suggestions }, crack_times_display: { offline_fast_hashing_1e10_per_second: timeToCrack }, } = useMemo(() => calculateStrength(password, dictionary), [password, dictionary]);
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.usePasswordStrength = void 0;
7
+ const react_1 = require("react");
8
+ const zxcvbn_1 = __importDefault(require("zxcvbn"));
9
+ function usePasswordStrength(password, dictionary) {
10
+ const { guesses, score, feedback: { warning, suggestions }, crack_times_display: { offline_fast_hashing_1e10_per_second: timeToCrack }, } = (0, react_1.useMemo)(() => (0, zxcvbn_1.default)(password, dictionary), [password, dictionary]);
5
11
  return {
6
12
  guesses,
7
13
  score,
@@ -10,3 +16,4 @@ export function usePasswordStrength(password, dictionary) {
10
16
  timeToCrack,
11
17
  };
12
18
  }
19
+ exports.usePasswordStrength = usePasswordStrength;
@@ -1 +1,5 @@
1
- export { useRefocusOnActivator } from "./useRefocusOnActivator.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useRefocusOnActivator = void 0;
4
+ var useRefocusOnActivator_js_1 = require("./useRefocusOnActivator.js");
5
+ Object.defineProperty(exports, "useRefocusOnActivator", { enumerable: true, get: function () { return useRefocusOnActivator_js_1.useRefocusOnActivator; } });
@@ -1,12 +1,15 @@
1
- import { useEffect } from "react";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useRefocusOnActivator = void 0;
4
+ const react_1 = require("react");
2
5
  /**
3
6
  * Brings back the focus to the element that opened an overlaid element once
4
7
  * said overlaid element is dismissed.
5
8
  *
6
9
  * @param active - Determines if it should focus or not
7
10
  */
8
- export function useRefocusOnActivator(active) {
9
- useEffect(() => {
11
+ function useRefocusOnActivator(active) {
12
+ (0, react_1.useEffect)(() => {
10
13
  let activator;
11
14
  if (active && !activator) {
12
15
  activator = document.activeElement;
@@ -21,3 +24,4 @@ export function useRefocusOnActivator(active) {
21
24
  };
22
25
  }, [active]);
23
26
  }
27
+ exports.useRefocusOnActivator = useRefocusOnActivator;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@jobber/hooks",
3
- "version": "2.0.3-pre1.52+dbd7fd38",
3
+ "version": "2.0.3-pre1.54+ae9d20c4",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
7
+ "type": "module",
7
8
  "exports": {
8
9
  ".": "./dist/index.js",
9
10
  "./useIsMounted": "./dist/useIsMounted/index.js"
@@ -21,7 +22,7 @@
21
22
  "@jobber/formatters": "^0.2.2",
22
23
  "@testing-library/react": "^14.0.0",
23
24
  "@testing-library/react-hooks": "^7.0.0",
24
- "@testing-library/user-event": "^12.0.2",
25
+ "@testing-library/user-event": "^14.4.3",
25
26
  "@types/lodash": "4.14.136",
26
27
  "@types/react": "^18.0.28",
27
28
  "@types/react-dom": "^18.0.11",
@@ -42,5 +43,5 @@
42
43
  "@apollo/client": "^3.7.10",
43
44
  "react": "^18"
44
45
  },
45
- "gitHead": "dbd7fd38ad63a18455a86f1b5faf72559d3009e1"
46
+ "gitHead": "ae9d20c457fb2418b4a7e9531a76c51198dad8e0"
46
47
  }
@@ -1 +0,0 @@
1
- export { useCollectionQuery } from "./useCollectionQuery.js";
@@ -1 +0,0 @@
1
- export { useCollectionQuery } from "./useCollectionQuery.js";
@@ -1,52 +0,0 @@
1
- export interface ListQueryType {
2
- allPlanets: {
3
- __typename?: "PlanetsConnection";
4
- pageInfo: {
5
- hasNextPage: boolean;
6
- endCursor: string;
7
- };
8
- edges: Array<{
9
- __typename?: "PlanetsEdge";
10
- node: {
11
- __typename?: "Planet";
12
- name: "string";
13
- id: "string";
14
- };
15
- cursor: string;
16
- }>;
17
- totalCount?: number;
18
- };
19
- }
20
- export declare const LIST_QUERY: any;
21
- export declare const apolloClient: any;
22
- interface LoadingState {
23
- loadingStatus: string;
24
- loading: boolean;
25
- }
26
- export declare function getLoadingState(loadingInitialContent: boolean, loadingRefresh: boolean, loadingNextPage: boolean): LoadingState;
27
- export declare const propsList: ({
28
- id: number;
29
- title: string;
30
- caption: string;
31
- value: string;
32
- url?: undefined;
33
- } | {
34
- id: number;
35
- title: string;
36
- caption: string;
37
- url: string;
38
- value: string;
39
- })[];
40
- export declare const subscriptionPropsList: {
41
- id: number;
42
- title: string;
43
- caption: string;
44
- value: string;
45
- }[];
46
- export declare const returnValues: {
47
- id: number;
48
- title: string;
49
- caption: string;
50
- value: string;
51
- }[];
52
- export {};
@@ -1,148 +0,0 @@
1
- import { ApolloClient, InMemoryCache, gql } from "@apollo/client";
2
- export const LIST_QUERY = gql `
3
- query ListQuery($cursor: String) {
4
- allPlanets(first: 4, after: $cursor) {
5
- pageInfo {
6
- hasNextPage
7
- endCursor
8
- }
9
- edges {
10
- node {
11
- name
12
- id
13
- }
14
- cursor
15
- }
16
- }
17
- }
18
- `;
19
- export const apolloClient = new ApolloClient({
20
- uri: "https://swapi-graphql.netlify.app/.netlify/functions/index",
21
- cache: new InMemoryCache(),
22
- });
23
- export function getLoadingState(loadingInitialContent, loadingRefresh, loadingNextPage) {
24
- if (loadingInitialContent) {
25
- return {
26
- loading: true,
27
- loadingStatus: "Initial Loading",
28
- };
29
- }
30
- if (loadingRefresh) {
31
- return {
32
- loading: true,
33
- loadingStatus: "Refreshing",
34
- };
35
- }
36
- if (loadingNextPage) {
37
- return {
38
- loading: true,
39
- loadingStatus: "Fetching More",
40
- };
41
- }
42
- return {
43
- loading: false,
44
- loadingStatus: "Loaded",
45
- };
46
- }
47
- export const propsList = [
48
- {
49
- id: 0,
50
- title: "query",
51
- caption: "The graphQL query that fetches the collection",
52
- value: "DocumentNode",
53
- },
54
- {
55
- id: 1,
56
- title: "queryOptions",
57
- caption: "A list of options for us to pass into the apollo `useQuery` hook. \
58
- Click to see more query options!",
59
- url: "https://www.apollographql.com/docs/react/data/queries/#options",
60
- value: "QueryHookOptions",
61
- },
62
- {
63
- id: 2,
64
- title: "getCollectionByPath",
65
- caption: "A function that returns the location where the \
66
- {@link Collection} is located. The collection is the part of the \
67
- result that needs to be paginated.",
68
- value: "GetCollectionByPathFunction<TQuery>",
69
- },
70
- {
71
- id: 3,
72
- title: "subscription (optional)",
73
- caption: "A list of subscription options if \
74
- you want to create a GraphQL subscription to listen for more content.",
75
- value: "SubscriptionProps",
76
- },
77
- ];
78
- export const subscriptionPropsList = [
79
- {
80
- id: 0,
81
- title: "document",
82
- caption: "The graphQL subscription that listens for more data. This query \
83
- should return a single Node that matches the data structure in \
84
- getCollectionByPath<TQuery>(...).edges.node and \
85
- getCollectionByPath<TQuery>(...).nodes",
86
- value: "DocumentNode",
87
- },
88
- {
89
- id: 1,
90
- title: "options",
91
- caption: " A list of variables to pass into the apollo `subscribeToMore` function.",
92
- value: "SubscribeToMoreOptions<TSubscription>",
93
- },
94
- {
95
- id: 2,
96
- title: "getNodeByPath",
97
- caption: " A function that returns the location where the `Node` is \
98
- located on the TSubscription object. It should return a single Node \
99
- that matches the data structure in \
100
- getCollectionByPath<TQuery>(...).edges.node and \
101
- getCollectionByPath<TQuery>(...).nodes",
102
- value: "GetNodeByPath<TSubscription>",
103
- },
104
- ];
105
- export const returnValues = [
106
- {
107
- id: 0,
108
- title: "data",
109
- caption: "The payload returned from the query",
110
- value: "ListQueryType | undefined",
111
- },
112
- {
113
- id: 1,
114
- title: "error",
115
- caption: "Any errors returned from the query",
116
- value: "ApolloError | undefined",
117
- },
118
- {
119
- id: 2,
120
- title: "refresh",
121
- caption: "A funtion that enables you to re-execute the query",
122
- value: "() => void",
123
- },
124
- {
125
- id: 3,
126
- title: "nextPage",
127
- caption: "A funtion that helps you fetch the next set of results for a paginated list",
128
- value: "() => void",
129
- },
130
- {
131
- id: 4,
132
- title: "loadingRefresh",
133
- caption: "An indicator that a refresh is in progress",
134
- value: "boolean",
135
- },
136
- {
137
- id: 5,
138
- title: "loadingNextPage",
139
- caption: "An indicator that a fetch more is in progress",
140
- value: "boolean",
141
- },
142
- {
143
- id: 6,
144
- title: "loadingInitialContent",
145
- caption: "An indicator that the initial content is being fetched",
146
- value: "boolean",
147
- },
148
- ];
@@ -1,3 +0,0 @@
1
- export * from "./queries.js";
2
- export * from "./utils.js";
3
- export * from "./mocks.js";
@@ -1,3 +0,0 @@
1
- export * from "./queries.js";
2
- export * from "./utils.js";
3
- export * from "./mocks.js";