@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.
- package/dist/__tests__/crm/utils/fetchAssociations.spec.js +2 -1
- package/dist/__tests__/crm/utils/fetchCrmProperties.spec.js +1 -1
- package/dist/crm/hooks/useAssociations.d.ts +3 -11
- package/dist/crm/hooks/useAssociations.js +3 -2
- package/dist/crm/hooks/useCrmProperties.d.ts +1 -1
- package/dist/crm/hooks/useCrmProperties.js +2 -2
- package/dist/crm/utils/fetchAssociations.d.ts +1 -9
- package/dist/crm/utils/fetchAssociations.js +0 -11
- package/dist/crm/utils/fetchCrmProperties.js +0 -1
- package/dist/experimental/pages/components/index.d.ts +1 -0
- package/dist/experimental/pages/components/index.js +1 -0
- package/dist/experimental/pages/components/page-routes.d.ts +83 -0
- package/dist/experimental/pages/components/page-routes.js +66 -0
- package/dist/experimental/pages/create-page-router.d.ts +35 -0
- package/dist/experimental/pages/create-page-router.js +123 -0
- package/dist/experimental/pages/create-page-router.test.d.ts +1 -0
- package/dist/experimental/pages/create-page-router.test.js +296 -0
- package/dist/experimental/pages/hooks.d.ts +8 -0
- package/dist/experimental/pages/hooks.js +15 -0
- package/dist/experimental/pages/index.d.ts +6 -0
- package/dist/experimental/pages/index.js +4 -0
- package/dist/experimental/pages/internal/app-page-route-context.d.ts +16 -0
- package/dist/experimental/pages/internal/app-page-route-context.js +12 -0
- package/dist/experimental/pages/internal/convert-page-routes-react-elements.d.ts +9 -0
- package/dist/experimental/pages/internal/convert-page-routes-react-elements.js +138 -0
- package/dist/experimental/pages/internal/page-router-internal-types.d.ts +40 -0
- package/dist/experimental/pages/internal/page-router-internal-types.js +5 -0
- package/dist/experimental/pages/internal/trie-router.d.ts +31 -0
- package/dist/experimental/pages/internal/trie-router.js +141 -0
- package/dist/experimental/pages/internal/trie-router.test.d.ts +1 -0
- package/dist/experimental/pages/internal/trie-router.test.js +263 -0
- package/dist/experimental/pages/internal/useAppPageLocation.d.ts +1 -0
- package/dist/experimental/pages/internal/useAppPageLocation.js +13 -0
- package/dist/experimental/pages/types.d.ts +29 -0
- package/dist/experimental/pages/types.js +1 -0
- package/dist/hs-internal/__tests__/createRemoteComponentInternal.spec.js +4 -4
- package/dist/hubspot.js +0 -1
- package/dist/internal/global-utils.d.ts +1 -1
- package/dist/internal/hook-utils.d.ts +7 -6
- package/dist/internal/hook-utils.js +8 -9
- package/dist/pages/index.d.ts +1 -0
- package/dist/pages/index.js +1 -0
- package/dist/shared/remoteComponents.d.ts +28 -2
- package/dist/shared/remoteComponents.js +32 -0
- package/dist/shared/types/components/accordion.d.ts +2 -2
- package/dist/shared/types/components/alert.d.ts +2 -2
- package/dist/shared/types/components/app-home-header-actions.d.ts +3 -3
- package/dist/shared/types/components/button-row.d.ts +2 -2
- package/dist/shared/types/components/button.d.ts +5 -5
- package/dist/shared/types/components/card.d.ts +2 -2
- package/dist/shared/types/components/chart.d.ts +1 -1
- package/dist/shared/types/components/description-list.d.ts +2 -2
- package/dist/shared/types/components/divider.d.ts +1 -1
- package/dist/shared/types/components/dropdown.d.ts +2 -3
- package/dist/shared/types/components/empty-state.d.ts +2 -2
- package/dist/shared/types/components/error-state.d.ts +2 -2
- package/dist/shared/types/components/form.d.ts +3 -3
- package/dist/shared/types/components/heading.d.ts +2 -2
- package/dist/shared/types/components/icon.d.ts +3 -3
- package/dist/shared/types/components/iframe.d.ts +1 -1
- package/dist/shared/types/components/illustration.d.ts +1 -1
- package/dist/shared/types/components/image.d.ts +4 -4
- package/dist/shared/types/components/inputs.d.ts +8 -2
- package/dist/shared/types/components/layouts.d.ts +2 -2
- package/dist/shared/types/components/link.d.ts +5 -5
- package/dist/shared/types/components/list.d.ts +2 -2
- package/dist/shared/types/components/loading-spinner.d.ts +1 -1
- package/dist/shared/types/components/modal.d.ts +2 -2
- package/dist/shared/types/components/panel.d.ts +2 -2
- package/dist/shared/types/components/progress-bar.d.ts +1 -1
- package/dist/shared/types/components/score.d.ts +2 -2
- package/dist/shared/types/components/selects.d.ts +1 -1
- package/dist/shared/types/components/spacer.d.ts +1 -1
- package/dist/shared/types/components/statistics.d.ts +2 -2
- package/dist/shared/types/components/status-tag.d.ts +2 -2
- package/dist/shared/types/components/step-indicator.d.ts +1 -1
- package/dist/shared/types/components/table.d.ts +2 -2
- package/dist/shared/types/components/tabs.d.ts +2 -2
- package/dist/shared/types/components/tag.d.ts +3 -3
- package/dist/shared/types/components/text.d.ts +2 -2
- package/dist/shared/types/components/tile.d.ts +2 -2
- package/dist/shared/types/components/toggle.d.ts +1 -1
- package/dist/shared/types/components/toggleInputs.d.ts +1 -1
- package/dist/shared/types/components/tooltip.d.ts +2 -2
- package/dist/shared/types/crm.d.ts +2 -2
- package/dist/shared/types/experimental.d.ts +1 -1
- package/dist/shared/types/extend.d.ts +2 -2
- package/dist/shared/types/extension-points.d.ts +4 -5
- package/dist/shared/types/pages/app-pages-types.d.ts +75 -0
- package/dist/shared/types/pages/app-pages-types.js +1 -0
- package/dist/shared/types/pages/components/index.d.ts +4 -0
- package/dist/shared/types/pages/components/index.js +1 -0
- package/dist/shared/types/pages/components/page-breadcrumbs.d.ts +34 -0
- package/dist/shared/types/pages/components/page-breadcrumbs.js +1 -0
- package/dist/shared/types/pages/components/page-header.d.ts +82 -0
- package/dist/shared/types/pages/components/page-header.js +1 -0
- package/dist/shared/types/pages/components/page-link.d.ts +25 -0
- package/dist/shared/types/pages/components/page-link.js +1 -0
- package/dist/shared/types/pages/components/page-routes.d.ts +115 -0
- package/dist/shared/types/pages/components/page-routes.js +1 -0
- package/dist/shared/types/pages/components/page-title.d.ts +12 -0
- package/dist/shared/types/pages/components/page-title.js +1 -0
- package/dist/shared/types/pages/index.d.ts +1 -0
- package/dist/shared/types/pages/index.js +1 -0
- package/dist/shared/types/pages.d.ts +1 -0
- package/dist/shared/types/pages.js +1 -0
- package/dist/shared/types/shared.d.ts +15 -1
- package/dist/shared/types/worker-globals.d.ts +8 -3
- package/dist/shared/utils/remote-component-registry.d.ts +1 -1
- package/dist/testing/__tests__/isMatch.spec.js +1 -1
- package/dist/testing/__tests__/mocks.runServerlessFunction.spec.js +1 -1
- package/dist/testing/__tests__/mocks.useAssociations.spec.js +2 -2
- package/dist/testing/__tests__/mocks.useCrmProperties.spec.js +2 -2
- package/dist/testing/__tests__/mocks.useExtensionActions.spec.js +1 -1
- package/dist/testing/__tests__/mocks.useExtensionApi.spec.js +1 -1
- package/dist/testing/__tests__/mocks.useExtensionContext.spec.js +1 -1
- package/dist/testing/internal/convert.d.ts +1 -1
- package/dist/testing/internal/convert.js +4 -5
- package/dist/testing/internal/debug.d.ts +1 -1
- package/dist/testing/internal/element.d.ts +1 -1
- package/dist/testing/internal/errors.d.ts +2 -2
- package/dist/testing/internal/fragment.d.ts +1 -1
- package/dist/testing/internal/match.d.ts +2 -2
- package/dist/testing/internal/mocks/index.d.ts +15 -7
- package/dist/testing/internal/mocks/index.js +20 -6
- package/dist/testing/internal/mocks/mock-app-page-location.d.ts +7 -0
- package/dist/testing/internal/mocks/mock-app-page-location.js +35 -0
- package/dist/testing/internal/mocks/mock-extension-point-api.d.ts +2 -1
- package/dist/testing/internal/mocks/mock-extension-point-api.js +1 -1
- package/dist/testing/internal/mocks/mock-hooks.d.ts +1 -1
- package/dist/testing/internal/mocks/mock-hooks.js +12 -7
- package/dist/testing/internal/text.d.ts +2 -2
- package/dist/testing/internal/type-utils-internal.d.ts +2 -2
- package/dist/testing/internal/types-internal.d.ts +6 -6
- package/dist/testing/render.d.ts +2 -2
- package/dist/testing/render.js +12 -12
- package/dist/testing/type-utils.d.ts +1 -1
- package/dist/testing/type-utils.js +1 -1
- package/dist/testing/types.d.ts +27 -11
- package/dist/testing/utils.d.ts +1 -1
- package/dist/testing/utils.js +1 -1
- package/dist/utils/pagination.d.ts +17 -0
- package/dist/utils/pagination.js +10 -0
- 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 =
|
|
71
|
+
const { mocks } = useRequiredMocksContext();
|
|
65
72
|
return mocks.context;
|
|
66
73
|
},
|
|
67
74
|
useExtensionActions: () => {
|
|
68
|
-
const mocks =
|
|
69
|
-
return mocks
|
|
70
|
-
.actions;
|
|
75
|
+
const { mocks } = useRequiredMocksContext();
|
|
76
|
+
return mocks.actions;
|
|
71
77
|
},
|
|
72
78
|
useExtensionApi: () => {
|
|
73
|
-
const mocks =
|
|
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,
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useExtensionContext } from '../../hooks/useExtensionContext.tsx';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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;
|
package/dist/testing/render.d.ts
CHANGED
|
@@ -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.
|
package/dist/testing/render.js
CHANGED
|
@@ -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 {
|
|
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
|
|
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,
|
|
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
|
|
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:
|
|
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
|
|
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
|
|
177
|
+
const mocksContext = createRendererMocksContext(extensionPointLocation);
|
|
178
|
+
const { mocks } = mocksContext;
|
|
179
179
|
return {
|
|
180
180
|
render: (node) => {
|
|
181
|
-
renderResult = render(node,
|
|
181
|
+
renderResult = render(node, mocksContext);
|
|
182
182
|
return asRenderedRootNode(renderResult.getLatestRootNode());
|
|
183
183
|
},
|
|
184
|
-
mocks:
|
|
184
|
+
mocks: mocks,
|
|
185
185
|
find: (component, matcher) => {
|
|
186
186
|
return find(getLatestRootNode(), component, matcher);
|
|
187
187
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
*
|
package/dist/testing/types.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { useExtensionContext } from '../hooks/useExtensionContext.tsx';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
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
|
|
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:
|
|
382
|
+
mocks: RendererMocks<TExtensionPointLocation>;
|
|
367
383
|
/**
|
|
368
384
|
* Finds the first descendant element node that matches the given component and test ID.
|
|
369
385
|
*
|
package/dist/testing/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type HubSpotReactComponent, type UnknownComponentProps } from '../shared/types/shared.ts';
|
|
2
|
-
import {
|
|
2
|
+
import type { ElementMatcher, RenderedElementNode, RenderedNode } from './types.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Checks if the node matches the component and matcher.
|
|
5
5
|
*
|
package/dist/testing/utils.js
CHANGED
|
@@ -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.
|
|
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
|
-
"
|
|
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": "
|
|
63
|
-
"@testing-library/react": "
|
|
64
|
-
"@types/node": "
|
|
65
|
-
"@types/react": "
|
|
66
|
-
"@types/react-dom": "
|
|
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": "
|
|
71
|
-
"tsd": "
|
|
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": "
|
|
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
|
+
}
|