@hubspot/ui-extensions 0.12.2 → 0.12.4

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 (144) hide show
  1. package/dist/__tests__/crm/utils/fetchAssociations.spec.js +2 -1
  2. package/dist/__tests__/crm/utils/fetchCrmProperties.spec.js +1 -1
  3. package/dist/crm/hooks/useAssociations.d.ts +3 -11
  4. package/dist/crm/hooks/useAssociations.js +3 -2
  5. package/dist/crm/hooks/useCrmProperties.d.ts +1 -1
  6. package/dist/crm/hooks/useCrmProperties.js +2 -2
  7. package/dist/crm/utils/fetchAssociations.d.ts +1 -9
  8. package/dist/crm/utils/fetchAssociations.js +0 -11
  9. package/dist/crm/utils/fetchCrmProperties.js +0 -1
  10. package/dist/experimental/pages/components/index.d.ts +1 -0
  11. package/dist/experimental/pages/components/index.js +1 -0
  12. package/dist/experimental/pages/components/page-routes.d.ts +83 -0
  13. package/dist/experimental/pages/components/page-routes.js +66 -0
  14. package/dist/experimental/pages/create-page-router.d.ts +35 -0
  15. package/dist/experimental/pages/create-page-router.js +123 -0
  16. package/dist/experimental/pages/create-page-router.test.d.ts +1 -0
  17. package/dist/experimental/pages/create-page-router.test.js +296 -0
  18. package/dist/experimental/pages/hooks.d.ts +8 -0
  19. package/dist/experimental/pages/hooks.js +15 -0
  20. package/dist/experimental/pages/index.d.ts +6 -0
  21. package/dist/experimental/pages/index.js +4 -0
  22. package/dist/experimental/pages/internal/app-page-route-context.d.ts +16 -0
  23. package/dist/experimental/pages/internal/app-page-route-context.js +12 -0
  24. package/dist/experimental/pages/internal/convert-page-routes-react-elements.d.ts +9 -0
  25. package/dist/experimental/pages/internal/convert-page-routes-react-elements.js +138 -0
  26. package/dist/experimental/pages/internal/page-router-internal-types.d.ts +40 -0
  27. package/dist/experimental/pages/internal/page-router-internal-types.js +5 -0
  28. package/dist/experimental/pages/internal/trie-router.d.ts +31 -0
  29. package/dist/experimental/pages/internal/trie-router.js +141 -0
  30. package/dist/experimental/pages/internal/trie-router.test.d.ts +1 -0
  31. package/dist/experimental/pages/internal/trie-router.test.js +263 -0
  32. package/dist/experimental/pages/internal/useAppPageLocation.d.ts +1 -0
  33. package/dist/experimental/pages/internal/useAppPageLocation.js +13 -0
  34. package/dist/experimental/pages/types.d.ts +29 -0
  35. package/dist/experimental/pages/types.js +1 -0
  36. package/dist/hs-internal/__tests__/createRemoteComponentInternal.spec.js +4 -4
  37. package/dist/hubspot.js +0 -1
  38. package/dist/internal/global-utils.d.ts +1 -1
  39. package/dist/internal/hook-utils.d.ts +7 -6
  40. package/dist/internal/hook-utils.js +8 -9
  41. package/dist/pages/index.d.ts +1 -0
  42. package/dist/pages/index.js +1 -0
  43. package/dist/shared/remoteComponents.d.ts +28 -2
  44. package/dist/shared/remoteComponents.js +32 -0
  45. package/dist/shared/types/components/accordion.d.ts +2 -2
  46. package/dist/shared/types/components/alert.d.ts +2 -2
  47. package/dist/shared/types/components/app-home-header-actions.d.ts +3 -3
  48. package/dist/shared/types/components/button-row.d.ts +2 -2
  49. package/dist/shared/types/components/button.d.ts +5 -5
  50. package/dist/shared/types/components/card.d.ts +2 -2
  51. package/dist/shared/types/components/chart.d.ts +1 -1
  52. package/dist/shared/types/components/description-list.d.ts +2 -2
  53. package/dist/shared/types/components/divider.d.ts +1 -1
  54. package/dist/shared/types/components/dropdown.d.ts +2 -3
  55. package/dist/shared/types/components/empty-state.d.ts +2 -2
  56. package/dist/shared/types/components/error-state.d.ts +2 -2
  57. package/dist/shared/types/components/form.d.ts +3 -3
  58. package/dist/shared/types/components/heading.d.ts +2 -2
  59. package/dist/shared/types/components/icon.d.ts +3 -3
  60. package/dist/shared/types/components/iframe.d.ts +1 -1
  61. package/dist/shared/types/components/illustration.d.ts +1 -1
  62. package/dist/shared/types/components/image.d.ts +4 -4
  63. package/dist/shared/types/components/inputs.d.ts +8 -2
  64. package/dist/shared/types/components/layouts.d.ts +2 -2
  65. package/dist/shared/types/components/link.d.ts +5 -5
  66. package/dist/shared/types/components/list.d.ts +2 -2
  67. package/dist/shared/types/components/loading-spinner.d.ts +1 -1
  68. package/dist/shared/types/components/modal.d.ts +2 -2
  69. package/dist/shared/types/components/panel.d.ts +2 -2
  70. package/dist/shared/types/components/progress-bar.d.ts +1 -1
  71. package/dist/shared/types/components/score.d.ts +2 -2
  72. package/dist/shared/types/components/selects.d.ts +1 -1
  73. package/dist/shared/types/components/spacer.d.ts +1 -1
  74. package/dist/shared/types/components/statistics.d.ts +2 -2
  75. package/dist/shared/types/components/status-tag.d.ts +2 -2
  76. package/dist/shared/types/components/step-indicator.d.ts +1 -1
  77. package/dist/shared/types/components/table.d.ts +2 -2
  78. package/dist/shared/types/components/tabs.d.ts +2 -2
  79. package/dist/shared/types/components/tag.d.ts +3 -3
  80. package/dist/shared/types/components/text.d.ts +2 -2
  81. package/dist/shared/types/components/tile.d.ts +2 -2
  82. package/dist/shared/types/components/toggle.d.ts +1 -1
  83. package/dist/shared/types/components/toggleInputs.d.ts +1 -1
  84. package/dist/shared/types/components/tooltip.d.ts +2 -2
  85. package/dist/shared/types/crm.d.ts +2 -2
  86. package/dist/shared/types/experimental.d.ts +1 -1
  87. package/dist/shared/types/extend.d.ts +2 -2
  88. package/dist/shared/types/extension-points.d.ts +4 -5
  89. package/dist/shared/types/pages/app-pages-types.d.ts +75 -0
  90. package/dist/shared/types/pages/app-pages-types.js +1 -0
  91. package/dist/shared/types/pages/components/index.d.ts +4 -0
  92. package/dist/shared/types/pages/components/index.js +1 -0
  93. package/dist/shared/types/pages/components/page-breadcrumbs.d.ts +34 -0
  94. package/dist/shared/types/pages/components/page-breadcrumbs.js +1 -0
  95. package/dist/shared/types/pages/components/page-header.d.ts +82 -0
  96. package/dist/shared/types/pages/components/page-header.js +1 -0
  97. package/dist/shared/types/pages/components/page-link.d.ts +25 -0
  98. package/dist/shared/types/pages/components/page-link.js +1 -0
  99. package/dist/shared/types/pages/components/page-routes.d.ts +115 -0
  100. package/dist/shared/types/pages/components/page-routes.js +1 -0
  101. package/dist/shared/types/pages/components/page-title.d.ts +12 -0
  102. package/dist/shared/types/pages/components/page-title.js +1 -0
  103. package/dist/shared/types/pages/index.d.ts +1 -0
  104. package/dist/shared/types/pages/index.js +1 -0
  105. package/dist/shared/types/pages.d.ts +1 -0
  106. package/dist/shared/types/pages.js +1 -0
  107. package/dist/shared/types/shared.d.ts +15 -1
  108. package/dist/shared/types/worker-globals.d.ts +8 -3
  109. package/dist/shared/utils/remote-component-registry.d.ts +1 -1
  110. package/dist/testing/__tests__/isMatch.spec.js +1 -1
  111. package/dist/testing/__tests__/mocks.runServerlessFunction.spec.js +1 -1
  112. package/dist/testing/__tests__/mocks.useAssociations.spec.js +2 -2
  113. package/dist/testing/__tests__/mocks.useCrmProperties.spec.js +2 -2
  114. package/dist/testing/__tests__/mocks.useExtensionActions.spec.js +1 -1
  115. package/dist/testing/__tests__/mocks.useExtensionApi.spec.js +1 -1
  116. package/dist/testing/__tests__/mocks.useExtensionContext.spec.js +1 -1
  117. package/dist/testing/internal/convert.d.ts +1 -1
  118. package/dist/testing/internal/convert.js +4 -5
  119. package/dist/testing/internal/debug.d.ts +1 -1
  120. package/dist/testing/internal/element.d.ts +1 -1
  121. package/dist/testing/internal/errors.d.ts +2 -2
  122. package/dist/testing/internal/fragment.d.ts +1 -1
  123. package/dist/testing/internal/match.d.ts +2 -2
  124. package/dist/testing/internal/mocks/index.d.ts +15 -7
  125. package/dist/testing/internal/mocks/index.js +20 -6
  126. package/dist/testing/internal/mocks/mock-app-page-location.d.ts +7 -0
  127. package/dist/testing/internal/mocks/mock-app-page-location.js +35 -0
  128. package/dist/testing/internal/mocks/mock-extension-point-api.d.ts +2 -1
  129. package/dist/testing/internal/mocks/mock-extension-point-api.js +1 -1
  130. package/dist/testing/internal/mocks/mock-hooks.d.ts +1 -1
  131. package/dist/testing/internal/mocks/mock-hooks.js +12 -7
  132. package/dist/testing/internal/text.d.ts +2 -2
  133. package/dist/testing/internal/type-utils-internal.d.ts +2 -2
  134. package/dist/testing/internal/types-internal.d.ts +6 -6
  135. package/dist/testing/render.d.ts +2 -2
  136. package/dist/testing/render.js +12 -12
  137. package/dist/testing/type-utils.d.ts +1 -1
  138. package/dist/testing/type-utils.js +1 -1
  139. package/dist/testing/types.d.ts +27 -11
  140. package/dist/testing/utils.d.ts +1 -1
  141. package/dist/testing/utils.js +1 -1
  142. package/dist/utils/pagination.d.ts +17 -0
  143. package/dist/utils/pagination.js +10 -0
  144. package/package.json +31 -23
@@ -15,6 +15,13 @@ const createFakeProperties = (propertyNames) => {
15
15
  }, {});
16
16
  };
17
17
  export const createMockHooks = () => {
18
+ const useRequiredMocksContext = () => {
19
+ const mocksContext = useMocksContext();
20
+ if (!mocksContext) {
21
+ throw new Error('Illegal State: Mocks context not found.');
22
+ }
23
+ return mocksContext;
24
+ };
18
25
  // Build a mocks object with the default mock functions.
19
26
  // NOTE: The mock implementations can be overridden by tests using the spies that are provided in the returned `spies` object.
20
27
  return {
@@ -61,20 +68,18 @@ export const createMockHooks = () => {
61
68
  };
62
69
  },
63
70
  useExtensionContext: () => {
64
- const mocks = useMocksContext();
71
+ const { mocks } = useRequiredMocksContext();
65
72
  return mocks.context;
66
73
  },
67
74
  useExtensionActions: () => {
68
- const mocks = useMocksContext();
69
- return mocks
70
- .actions;
75
+ const { mocks } = useRequiredMocksContext();
76
+ return mocks.actions;
71
77
  },
72
78
  useExtensionApi: () => {
73
- const mocks = useMocksContext();
79
+ const { mocks } = useRequiredMocksContext();
74
80
  return {
75
81
  context: mocks.context,
76
- actions: mocks
77
- .actions,
82
+ actions: mocks.actions,
78
83
  runServerlessFunction: mocks.runServerlessFunction,
79
84
  };
80
85
  },
@@ -1,6 +1,6 @@
1
1
  import { type RemoteRoot, type RemoteText } from '@remote-ui/core';
2
- import { RenderedTextNode } from '../types.ts';
3
- import { RenderedDocumentInternal } from './types-internal.ts';
2
+ import type { RenderedTextNode } from '../types.ts';
3
+ import type { RenderedDocumentInternal } from './types-internal.ts';
4
4
  /**
5
5
  * Creates a rendered text node.
6
6
  *
@@ -1,5 +1,5 @@
1
- import { RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedParentNode, RenderedRootNode, RenderedTextNode } from '../types.ts';
2
- import { RenderedElementNodeInternal, RenderedFragmentNodeInternal, RenderedNodeInternal, RenderedRootNodeInternal, RenderedParentNodeInternal, RenderedTextNodeInternal } from './types-internal.ts';
1
+ import type { RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedParentNode, RenderedRootNode, RenderedTextNode } from '../types.ts';
2
+ import type { RenderedElementNodeInternal, RenderedFragmentNodeInternal, RenderedNodeInternal, RenderedParentNodeInternal, RenderedRootNodeInternal, RenderedTextNodeInternal } from './types-internal.ts';
3
3
  /**
4
4
  * Converts an internal rendered node to a public rendered node using a type assertion.
5
5
  *
@@ -1,10 +1,10 @@
1
1
  import type { RemoteComponent, RemoteFragment, RemoteRoot, RemoteText } from '@remote-ui/core';
2
- import { ExtensionPointApi, ExtensionPointLocation } from '../../shared/types/extension-points.ts';
3
- import { HubSpotReactComponent, UnknownComponentProps } from '../../shared/types/shared.ts';
4
- import { useAssociations, useCrmProperties } from '../../crm/index.ts';
5
- import { useExtensionContext } from '../../hooks/useExtensionContext.tsx';
6
- import { useExtensionActions } from '../../hooks/useExtensionActions.tsx';
7
- import { useExtensionApi } from '../../hooks/useExtensionApi.tsx';
2
+ import type { useAssociations, useCrmProperties } from '../../crm/index.ts';
3
+ import type { useExtensionActions } from '../../hooks/useExtensionActions.tsx';
4
+ import type { useExtensionApi } from '../../hooks/useExtensionApi.tsx';
5
+ import type { useExtensionContext } from '../../hooks/useExtensionContext.tsx';
6
+ import type { ExtensionPointApi, ExtensionPointLocation } from '../../shared/types/extension-points.ts';
7
+ import type { HubSpotReactComponent, UnknownComponentProps } from '../../shared/types/shared.ts';
8
8
  import type { ElementMatcher, RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedParentNode, RenderedRootNode, RenderedTextNode } from '../types.ts';
9
9
  export type RemoteChildNode = RemoteComponent<any, RemoteRoot> | RemoteText<RemoteRoot>;
10
10
  export type RemoteParentNode = RemoteRoot | RemoteComponent<any, RemoteRoot> | RemoteFragment;
@@ -1,5 +1,5 @@
1
- import { ExtensionPointLocation } from '../shared/types/extension-points.ts';
2
- import { Renderer } from './types.ts';
1
+ import type { ExtensionPointLocation } from '../shared/types/extension-points.ts';
2
+ import type { Renderer } from './types.ts';
3
3
  /**
4
4
  * Creates a renderer object with methods for rendering and testing UI extension components.
5
5
  * Mocks for supported React hooks and the Extension Point API are automatically provided based on the extension point location.
@@ -1,16 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createRemoteRoot } from '@remote-ui/core';
3
3
  import { createRoot as createReactRoot } from '@remote-ui/react';
4
+ import { MocksContextProvider } from "../internal/hook-utils.js";
5
+ import { EXTENSION_POINT_LOCATIONS } from "../shared/types/extension-points.js";
4
6
  import { convertRemoteRoot } from "./internal/convert.js";
5
7
  import { createDocument } from "./internal/document.js";
6
8
  import { InvalidComponentsError, InvalidExtensionPointLocationError, WaitForTimeoutError, } from "./internal/errors.js";
7
- import { EXTENSION_POINT_LOCATIONS, } from "../shared/types/extension-points.js";
8
- import { MocksContextProvider } from "../internal/hook-utils.js";
9
- import { createMocksWithSpies } from "./internal/mocks/index.js";
9
+ import { createRendererMocksContext, } from "./internal/mocks/index.js";
10
10
  import { find, findAll, findAllChildren, findByTestId, findChild, maybeFind, maybeFindByTestId, maybeFindChild, } from "./internal/query.js";
11
11
  import { createRootNode } from "./internal/root.js";
12
12
  import { asRenderedRootNode } from "./internal/type-utils-internal.js";
13
- import { createDeferred, } from "./internal/utils/promise-utils.js";
13
+ import { createDeferred } from "./internal/utils/promise-utils.js";
14
14
  const DEFAULT_WAIT_FOR_TIMEOUT_IN_MS = 1000;
15
15
  const DEFAULT_WAIT_FOR_OPTIONS = {
16
16
  timeoutInMs: DEFAULT_WAIT_FOR_TIMEOUT_IN_MS,
@@ -21,14 +21,13 @@ const DEFAULT_WAIT_FOR_OPTIONS = {
21
21
  * @param node The React node to render.
22
22
  * @returns A render result object
23
23
  */
24
- const render = (node, mocksWithSpies) => {
24
+ const render = (node, mocksContext) => {
25
25
  let dirty = true;
26
26
  let waitForChecksQueued = false;
27
27
  let waitForList = [];
28
28
  const runWaitForChecks = () => {
29
29
  waitForChecksQueued = false;
30
30
  waitForList = waitForList.filter((waitFor) => {
31
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
32
31
  const renderedRootNode = getLatestRootNode();
33
32
  if (renderedRootNode.document.hasInvalidComponentNames()) {
34
33
  // Reject the waitFor promise if we detect invalid components in the rendered output.
@@ -50,7 +49,7 @@ const render = (node, mocksWithSpies) => {
50
49
  waitFor.deferred.resolve(); // Resolve the promise that was originally returned by the waitFor function.
51
50
  return false; // Remove the waitFor from the list since the check passed and we resolved the promise
52
51
  }
53
- catch (error) {
52
+ catch {
54
53
  return true; // Keep the waitFor in the list since the check failed and we didn't resolve the promise.
55
54
  }
56
55
  });
@@ -75,7 +74,7 @@ const render = (node, mocksWithSpies) => {
75
74
  };
76
75
  const remoteRoot = createRemoteRoot(remoteChannel);
77
76
  const reactRoot = createReactRoot(remoteRoot);
78
- reactRoot.render(_jsx(MocksContextProvider, { value: mocksWithSpies, children: node }));
77
+ reactRoot.render(_jsx(MocksContextProvider, { value: mocksContext, children: node }));
79
78
  remoteRoot.mount();
80
79
  let maybeRenderedRootNode;
81
80
  /**
@@ -112,7 +111,7 @@ const render = (node, mocksWithSpies) => {
112
111
  // Nothing to wait for since the check passed! Resolve the promise immediately.
113
112
  return Promise.resolve();
114
113
  }
115
- catch (error) {
114
+ catch {
116
115
  // If the check failed then we need to put it in the waitForList so that we
117
116
  // can check it again later. We return a promise that will be resolved when
118
117
  // the provided check passes.
@@ -175,13 +174,14 @@ export const createRenderer = (extensionPointLocation) => {
175
174
  return renderResult;
176
175
  };
177
176
  const getLatestRootNode = () => getRenderResult().getLatestRootNode();
178
- const { spies: mocksWithSpies } = createMocksWithSpies(extensionPointLocation);
177
+ const mocksContext = createRendererMocksContext(extensionPointLocation);
178
+ const { mocks } = mocksContext;
179
179
  return {
180
180
  render: (node) => {
181
- renderResult = render(node, mocksWithSpies);
181
+ renderResult = render(node, mocksContext);
182
182
  return asRenderedRootNode(renderResult.getLatestRootNode());
183
183
  },
184
- mocks: mocksWithSpies,
184
+ mocks: mocks,
185
185
  find: (component, matcher) => {
186
186
  return find(getLatestRootNode(), component, matcher);
187
187
  },
@@ -1,4 +1,4 @@
1
- import { type RenderedElementNode, type RenderedFragmentNode, type RenderedNode, type RenderedRootNode, type RenderedTextNode } from './types.ts';
1
+ import type { RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedRootNode, RenderedTextNode } from './types.ts';
2
2
  /**
3
3
  * Type guard to check if a node is a rendered element node.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { RenderedNodeType, } from "./types.js";
1
+ import { RenderedNodeType } from "./types.js";
2
2
  /**
3
3
  * Type guard to check if a node is a rendered element node.
4
4
  *
@@ -1,12 +1,13 @@
1
- import { ExtensionPointApi, ExtensionPointApiActions, ExtensionPointLocation } from '../shared/types/extension-points.ts';
2
- import { ServerlessFuncRunner } from '../shared/types/http-requests.ts';
3
- import { SpyImpl } from 'tinyspy';
4
- import { HubSpotReactComponent, HubSpotReactFragmentProp, UnknownComponentProps } from '../shared/types/shared.ts';
5
- import { useAssociations, useCrmProperties } from '../crm/index.ts';
6
- import { useExtensionContext } from '../hooks/useExtensionContext.tsx';
7
- import { AnyFunction } from './internal/types-internal.ts';
8
- import { useExtensionActions } from '../hooks/useExtensionActions.tsx';
9
- import { useExtensionApi } from '../hooks/useExtensionApi.tsx';
1
+ import type { SpyImpl } from 'tinyspy';
2
+ import type { useAssociations, useCrmProperties } from '../crm/index.ts';
3
+ import type { useAppPageLocation } from '../experimental/pages/internal/useAppPageLocation.tsx';
4
+ import type { useExtensionActions } from '../hooks/useExtensionActions.tsx';
5
+ import type { useExtensionApi } from '../hooks/useExtensionApi.tsx';
6
+ import type { useExtensionContext } from '../hooks/useExtensionContext.tsx';
7
+ import type { ExtensionPointApi, ExtensionPointApiActions, ExtensionPointLocation } from '../shared/types/extension-points.ts';
8
+ import type { ServerlessFuncRunner } from '../shared/types/http-requests.ts';
9
+ import type { AppPageLocation, HubSpotReactComponent, HubSpotReactFragmentProp, UnknownComponentProps } from '../shared/types/shared.ts';
10
+ import type { AnyFunction } from './internal/types-internal.ts';
10
11
  /**
11
12
  * The type of a rendered node.
12
13
  */
@@ -261,7 +262,7 @@ export type ExtensionPointApiActionSpies<TExtensionPointLocation extends Extensi
261
262
  /**
262
263
  * An object containing the spies for the various functions.
263
264
  */
264
- export interface RendererSpies<TExtensionPointLocation extends ExtensionPointLocation = ExtensionPointLocation> {
265
+ export interface RendererMocks<TExtensionPointLocation extends ExtensionPointLocation = ExtensionPointLocation> {
265
266
  /**
266
267
  * A spy for the `useCrmProperties` hook function.
267
268
  * The spy can be used to track the calls to the hook function and also control the
@@ -307,6 +308,15 @@ export interface RendererSpies<TExtensionPointLocation extends ExtensionPointLoc
307
308
  * information about spies and the supported API.
308
309
  */
309
310
  useExtensionApi: FunctionSpy<typeof useExtensionApi>;
311
+ /**
312
+ * A spy for the `useAppPageLocation` hook function.
313
+ * The spy can be used to track the calls to the hook function and also control the
314
+ * return result of the hook function.
315
+ *
316
+ * See the [tinyspy](https://github.com/tiny-spy/tinyspy) library for more
317
+ * information about spies and the supported API.
318
+ */
319
+ useAppPageLocation: FunctionSpy<typeof useAppPageLocation>;
310
320
  /**
311
321
  * Mock context object that contains fake context data for the extension point API.
312
322
  */
@@ -329,6 +339,12 @@ export interface RendererSpies<TExtensionPointLocation extends ExtensionPointLoc
329
339
  * information about spies and the supported API.
330
340
  */
331
341
  runServerlessFunction: FunctionSpy<ServerlessFuncRunner>;
342
+ /**
343
+ * Sets the current app page location for testing page routing.
344
+ *
345
+ * @param location The app page location to set.
346
+ */
347
+ setPageLocation: (location: AppPageLocation) => void;
332
348
  }
333
349
  /**
334
350
  * A result of a render operation.
@@ -363,7 +379,7 @@ export interface Renderer<TExtensionPointLocation extends ExtensionPointLocation
363
379
  /**
364
380
  * The mocks that can be used to control the behavior of the various functions.
365
381
  */
366
- mocks: RendererSpies<TExtensionPointLocation>;
382
+ mocks: RendererMocks<TExtensionPointLocation>;
367
383
  /**
368
384
  * Finds the first descendant element node that matches the given component and test ID.
369
385
  *
@@ -1,5 +1,5 @@
1
1
  import { type HubSpotReactComponent, type UnknownComponentProps } from '../shared/types/shared.ts';
2
- import { type ElementMatcher, type RenderedElementNode, type RenderedNode } from './types.ts';
2
+ import type { ElementMatcher, RenderedElementNode, RenderedNode } from './types.ts';
3
3
  /**
4
4
  * Checks if the node matches the component and matcher.
5
5
  *
@@ -1,6 +1,6 @@
1
- import { RenderedNodeType, } from "./types.js";
2
1
  import { __hubSpotComponentRegistry } from "../shared/remoteComponents.js";
3
2
  import { checkElementMatches } from "./internal/match.js";
3
+ import { RenderedNodeType } from "./types.js";
4
4
  /**
5
5
  * Checks if the node matches the component and matcher.
6
6
  *
@@ -0,0 +1,17 @@
1
+ export interface PaginationResult {
2
+ hasNextPage: boolean;
3
+ hasPreviousPage: boolean;
4
+ currentPage: number;
5
+ pageSize: number;
6
+ nextPage: () => void;
7
+ previousPage: () => void;
8
+ reset: () => void;
9
+ }
10
+ export declare const DEFAULT_PAGE_SIZE = 10;
11
+ /**
12
+ * Calculate pagination flags based on current page and API hasMore flag
13
+ */
14
+ export declare function calculatePaginationFlags(currentPage: number, hasMore: boolean): {
15
+ hasNextPage: boolean;
16
+ hasPreviousPage: boolean;
17
+ };
@@ -0,0 +1,10 @@
1
+ export const DEFAULT_PAGE_SIZE = 10;
2
+ /**
3
+ * Calculate pagination flags based on current page and API hasMore flag
4
+ */
5
+ export function calculatePaginationFlags(currentPage, hasMore) {
6
+ return {
7
+ hasNextPage: hasMore,
8
+ hasPreviousPage: currentPage > 1,
9
+ };
10
+ }
package/package.json CHANGED
@@ -1,22 +1,11 @@
1
1
  {
2
2
  "name": "@hubspot/ui-extensions",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
- "scripts": {
9
- "clean": "rm -rf dist/",
10
- "build": "npm run clean && tsc",
11
- "check:tsc": "tsc",
12
- "watch": "npm run clean && tsc --watch",
13
- "prepare": "npm run build",
14
- "lint": "echo 'No linter configured for @hubspot/ui-extensions'",
15
- "test": "vitest run && tsd",
16
- "test:coverage": "vitest run --coverage",
17
- "test:watch": "vitest",
18
- "test:types": "tsd"
19
- },
8
+ "prettier": "@private/prettier-config",
20
9
  "files": [
21
10
  "dist"
22
11
  ],
@@ -26,6 +15,7 @@
26
15
  "exports": {
27
16
  ".": "./dist/index.js",
28
17
  "./crm": "./dist/crm/index.js",
18
+ "./experimental/pages": "./dist/experimental/pages/index.js",
29
19
  "./pages/home": "./dist/pages/home/index.js",
30
20
  "./experimental": "./dist/experimental/index.js",
31
21
  "./testing": "./dist/testing/index.js",
@@ -59,21 +49,39 @@
59
49
  }
60
50
  },
61
51
  "devDependencies": {
62
- "@testing-library/dom": "^10.4.0",
63
- "@testing-library/react": "^14.1.2",
64
- "@types/node": "^22.14.0",
65
- "@types/react": "^18.3.1",
66
- "@types/react-dom": "^18.3.1",
52
+ "@testing-library/dom": "10.4.1",
53
+ "@testing-library/react": "14.3.1",
54
+ "@types/node": "22.19.7",
55
+ "@types/react": "18.3.26",
56
+ "@types/react-dom": "18.3.7",
67
57
  "@vitest/coverage-v8": "4.0.18",
58
+ "@vitest/eslint-plugin": "1.6.6",
59
+ "eslint": "9.39.2",
68
60
  "jsdom": "26.1.0",
61
+ "prettier": "3.8.1",
69
62
  "react-dom": "18.3.1",
70
- "react-reconciler": "^0.29.0",
71
- "tsd": "^0.33.0",
63
+ "react-reconciler": "0.29.2",
64
+ "tsd": "0.33.0",
72
65
  "typescript": "5.9.3",
73
- "vitest": "4.0.18"
66
+ "vitest": "4.0.18",
67
+ "@private/eslint-config": "1.0.0",
68
+ "@private/prettier-config": "1.0.0"
74
69
  },
75
70
  "tsd": {
76
71
  "directory": "src/__tests__/test-d"
77
72
  },
78
- "gitHead": "b8c8170048a28b28112833cb552be43d4587c2ed"
79
- }
73
+ "gitHead": "3da4a07183d48528ef431d46a8d327c053c4fe94",
74
+ "scripts": {
75
+ "clean": "rm -rf dist/ *.tsbuildinfo .turbo",
76
+ "format": "prettier --write . --ignore-path ../../.prettierignore",
77
+ "format:check": "prettier --check . --ignore-path ../../.prettierignore",
78
+ "lint": "eslint src/",
79
+ "lint:fix": "eslint src/ --fix",
80
+ "tsc": "tsc",
81
+ "test": "vitest run && tsd",
82
+ "test:coverage": "vitest run --coverage",
83
+ "test:types": "tsd",
84
+ "test:watch": "vitest",
85
+ "tsc:watch": "tsc --watch"
86
+ }
87
+ }