@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
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { ReactionsHandler } from '../../reactions.ts';
|
|
3
|
+
import type { BaseComponentProps, ExtensionEvent } from '../../shared.ts';
|
|
4
|
+
/**
|
|
5
|
+
* The props type for [PageHeader](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-header).
|
|
6
|
+
*
|
|
7
|
+
* @category Component Props
|
|
8
|
+
*/
|
|
9
|
+
export interface PageHeaderProps extends BaseComponentProps {
|
|
10
|
+
/**
|
|
11
|
+
* Sets the content that will render inside the component. Can contain only <code>PageHeader.PrimaryAction</code> and/or <code>PageHeader.SecondaryActions</code> components.
|
|
12
|
+
*/
|
|
13
|
+
children: ReactElement<PageHeaderPrimaryActionProps> | ReactElement<PageHeaderSecondaryActionsProps>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The props type for [PageHeader.PrimaryAction](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-header#pageheader-primaryaction).
|
|
17
|
+
*
|
|
18
|
+
* @category Component Props
|
|
19
|
+
*/
|
|
20
|
+
export interface PageHeaderPrimaryActionProps extends BaseComponentProps {
|
|
21
|
+
/**
|
|
22
|
+
* Must be a <code>PageHeader.PageLink</code> component (for internal app pages) or a <code>PageHeader.Link</code> component (for URLs outside your app). No other component types are supported.
|
|
23
|
+
*/
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The props type for [PageHeader.SecondaryActions](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-header#pageheader-secondaryactions).
|
|
28
|
+
*
|
|
29
|
+
* @category Component Props
|
|
30
|
+
*/
|
|
31
|
+
export interface PageHeaderSecondaryActionsProps extends BaseComponentProps {
|
|
32
|
+
/**
|
|
33
|
+
* Must contain one or more <code>PageHeader.PageLink</code> component (for internal app pages) or a <code>PageHeader.Link</code> component (for URLs outside your app). No other component types are supported.
|
|
34
|
+
*/
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The props type for [PageHeader.Link](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-header#pageheader-link).
|
|
39
|
+
*
|
|
40
|
+
* @category Component Props
|
|
41
|
+
*/
|
|
42
|
+
export interface PageHeaderLinkProps extends BaseComponentProps {
|
|
43
|
+
/**
|
|
44
|
+
* A URL that will be opened when the button is clicked. If the value is a URL external to `hubspot.com` it will be opened in a new tab.
|
|
45
|
+
*/
|
|
46
|
+
href?: string;
|
|
47
|
+
/**
|
|
48
|
+
* A function that will be invoked when the button is clicked. Do not use this function for submitting a form; use Form's `onSubmit` function instead.
|
|
49
|
+
*
|
|
50
|
+
* @event
|
|
51
|
+
*/
|
|
52
|
+
onClick?: ReactionsHandler<ExtensionEvent>;
|
|
53
|
+
/**
|
|
54
|
+
* Determines whether or not the button should be disabled.
|
|
55
|
+
*/
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The visible label of the link button. This prop is passed implicitly by providing sub-components.
|
|
59
|
+
*/
|
|
60
|
+
children: ReactNode;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The props type for [PageHeader.PageLink](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-header#pageheader-pagelink).
|
|
64
|
+
*
|
|
65
|
+
* @category Component Props
|
|
66
|
+
*/
|
|
67
|
+
export interface PageHeaderPageLinkProps extends BaseComponentProps {
|
|
68
|
+
/**
|
|
69
|
+
* The path to navigate to when the link is clicked. Supports path parameters (e.g. `/view-contact/:contactId`).
|
|
70
|
+
*/
|
|
71
|
+
to: string;
|
|
72
|
+
/**
|
|
73
|
+
* Values for path parameters and query string entries.
|
|
74
|
+
* Parameters matching `:paramName` tokens in `to` are substituted into the path.
|
|
75
|
+
* Any remaining parameters are appended as query string entries.
|
|
76
|
+
*/
|
|
77
|
+
params?: Record<string, string>;
|
|
78
|
+
/**
|
|
79
|
+
* The visible label of the link button. This prop is passed implicitly by providing sub-components.
|
|
80
|
+
*/
|
|
81
|
+
children: ReactNode;
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { BaseComponentProps } from '../../shared.ts';
|
|
3
|
+
/**
|
|
4
|
+
* The props type for [PageLink](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-link).
|
|
5
|
+
*
|
|
6
|
+
* @category Component Props
|
|
7
|
+
*/
|
|
8
|
+
export interface PageLinkProps extends BaseComponentProps {
|
|
9
|
+
/**
|
|
10
|
+
* The path to navigate to. Can be a simple path (e.g., <code>"/docs"</code>) or a path with parameters
|
|
11
|
+
* (e.g., <code>"/view-contact/:contactId"</code>). When using path parameters, provide the parameter
|
|
12
|
+
* values in the <code>params</code> prop.
|
|
13
|
+
*/
|
|
14
|
+
to: string;
|
|
15
|
+
/**
|
|
16
|
+
* Values for path parameters and query string entries.
|
|
17
|
+
* Parameters matching `:paramName` tokens in `to` are substituted into the path.
|
|
18
|
+
* Any remaining parameters are appended as query string entries.
|
|
19
|
+
*/
|
|
20
|
+
params?: Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* The content to display inside the link.
|
|
23
|
+
*/
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import type { EmptyProps } from '../../shared.ts';
|
|
3
|
+
/**
|
|
4
|
+
* The props type for the layout component of [PageRoutes](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes).
|
|
5
|
+
*/
|
|
6
|
+
export interface PageRoutesLayoutProps {
|
|
7
|
+
/**
|
|
8
|
+
* The content to render inside the layout.
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
interface BaseRouteProps {
|
|
13
|
+
/**
|
|
14
|
+
* The component to render when the route is matched.
|
|
15
|
+
*/
|
|
16
|
+
component: ComponentType<EmptyProps>;
|
|
17
|
+
/**
|
|
18
|
+
* A unique identifier for the route.
|
|
19
|
+
*/
|
|
20
|
+
id?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The props type for [PageRoutes.IndexRoute](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes-indexroute).
|
|
24
|
+
*/
|
|
25
|
+
export type IndexRouteProps = BaseRouteProps;
|
|
26
|
+
/**
|
|
27
|
+
* The props type for [PageRoutes.Route](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes-route).
|
|
28
|
+
*/
|
|
29
|
+
export interface RouteProps extends BaseRouteProps {
|
|
30
|
+
/**
|
|
31
|
+
* The path pattern of the route to match.
|
|
32
|
+
*/
|
|
33
|
+
path: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The props type for [PageRoutes.AnyRoute](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes-anyroute).
|
|
37
|
+
*/
|
|
38
|
+
export type AnyRouteProps = BaseRouteProps;
|
|
39
|
+
/**
|
|
40
|
+
* The component type for the layout component of [PageRoutes](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes).
|
|
41
|
+
*/
|
|
42
|
+
export type PageRoutesLayoutComponent = ComponentType<PageRoutesLayoutProps>;
|
|
43
|
+
/**
|
|
44
|
+
* The props type for [PageRoutes](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes).
|
|
45
|
+
*/
|
|
46
|
+
export interface PageRoutesProps {
|
|
47
|
+
/**
|
|
48
|
+
* The path pattern of the route to include with all nested routes.
|
|
49
|
+
*/
|
|
50
|
+
path?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The component to render for the layout of the page routes.
|
|
53
|
+
*/
|
|
54
|
+
layoutComponent?: PageRoutesLayoutComponent;
|
|
55
|
+
/**
|
|
56
|
+
* The nested route definitions.
|
|
57
|
+
*/
|
|
58
|
+
children: ReactNode;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Used as a descriptor for a collection of page routes.
|
|
62
|
+
*
|
|
63
|
+
* Example usage:
|
|
64
|
+
*
|
|
65
|
+
* ```tsx
|
|
66
|
+
* const PageRouter = createPageRouter(<PageRoutes>
|
|
67
|
+
* <PageRoutes.IndexRoute component={HomePage} />
|
|
68
|
+
* <PageRoutes.Route path="/docs" component={DocsPage} />
|
|
69
|
+
* <PageRoutes.AnyRoute component={NotFoundPage} />
|
|
70
|
+
* </PageRoutes>);
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* See [PageRoutes](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes) for more information.
|
|
74
|
+
*
|
|
75
|
+
* @experimental This component is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates.
|
|
76
|
+
*/
|
|
77
|
+
export interface PageRoutesComponent {
|
|
78
|
+
(props: PageRoutesProps): null;
|
|
79
|
+
/**
|
|
80
|
+
* Used as a descriptor for an index (i.e., "/") route.
|
|
81
|
+
*
|
|
82
|
+
* Example usage:
|
|
83
|
+
*
|
|
84
|
+
* ```tsx
|
|
85
|
+
* <PageRoutes.IndexRoute component={HomePage} />
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @experimental This component is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates.
|
|
89
|
+
*/
|
|
90
|
+
IndexRoute: (props: IndexRouteProps) => null;
|
|
91
|
+
/**
|
|
92
|
+
* Used as a descriptor for a route with a path pattern.
|
|
93
|
+
*
|
|
94
|
+
* Example usage:
|
|
95
|
+
*
|
|
96
|
+
* ```tsx
|
|
97
|
+
* <PageRoutes.Route path="/docs" component={DocsPage} />
|
|
98
|
+
* ```
|
|
99
|
+
* @experimental This component is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates.
|
|
100
|
+
*/
|
|
101
|
+
Route: (props: RouteProps) => null;
|
|
102
|
+
/**
|
|
103
|
+
* Used as a descriptor for a route that matches any path.
|
|
104
|
+
*
|
|
105
|
+
* Example usage:
|
|
106
|
+
*
|
|
107
|
+
* ```tsx
|
|
108
|
+
* <PageRoutes.AnyRoute component={NotFoundPage} />
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @experimental This component is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates.
|
|
112
|
+
*/
|
|
113
|
+
AnyRoute: (props: AnyRouteProps) => null;
|
|
114
|
+
}
|
|
115
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BaseComponentProps } from '../../shared.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The props type for [PageTitle](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-title).
|
|
4
|
+
*
|
|
5
|
+
* @category Component Props
|
|
6
|
+
*/
|
|
7
|
+
export interface PageTitleProps extends BaseComponentProps {
|
|
8
|
+
/**
|
|
9
|
+
* The text to display as the page heading. Also sets the browser tab title.
|
|
10
|
+
*/
|
|
11
|
+
children: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './components/index.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './pages/index.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentType, ReactElement, ReactNode } from 'react';
|
|
2
2
|
export type UnknownComponentProps = Record<string, any>;
|
|
3
3
|
/**
|
|
4
4
|
* Represents a HubSpot-provided React component.
|
|
@@ -255,3 +255,17 @@ export interface BaseComponentProps {
|
|
|
255
255
|
*/
|
|
256
256
|
testId?: string;
|
|
257
257
|
}
|
|
258
|
+
export type EmptyProps = Record<string, never>;
|
|
259
|
+
/**
|
|
260
|
+
* Represents the current page location and its parameters. This is used to support app page routing.
|
|
261
|
+
*/
|
|
262
|
+
export interface AppPageLocation {
|
|
263
|
+
path: string;
|
|
264
|
+
params: Record<string, string>;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* The props type for a React fragment component.
|
|
268
|
+
*/
|
|
269
|
+
export interface ReactFragmentProps {
|
|
270
|
+
children?: ReactNode | undefined;
|
|
271
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
1
|
+
import type { HubspotExtendFunction } from './extend.ts';
|
|
2
|
+
import type { ExtensionPointApiActions, ExtensionPointApiContext, ExtensionPointFullApi, ExtensionPoints } from './extension-points.ts';
|
|
3
|
+
import type { Logger } from './logger.ts';
|
|
4
|
+
import type { AppPageLocation } from './shared.ts';
|
|
4
5
|
export interface WorkersApi {
|
|
5
6
|
/**
|
|
6
7
|
* Hook added to worker globals so customer code can access extension context at runtime.
|
|
@@ -14,6 +15,10 @@ export interface WorkersApi {
|
|
|
14
15
|
* Hook added to worker globals so customer code can access extension API at runtime.
|
|
15
16
|
*/
|
|
16
17
|
useExtensionApi: <ExtensionPoint extends keyof ExtensionPoints>() => ExtensionPointFullApi<ExtensionPoint>;
|
|
18
|
+
/**
|
|
19
|
+
* Hook added to worker globals so page router can access the current app page location at runtime.
|
|
20
|
+
*/
|
|
21
|
+
useAppPageLocation: () => AppPageLocation;
|
|
17
22
|
}
|
|
18
23
|
export interface WorkerGlobalsInternal {
|
|
19
24
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HubSpotReactComponent, HubSpotReactFragmentProp, UnknownComponentProps } from '../types/shared.ts';
|
|
1
|
+
import type { HubSpotReactComponent, HubSpotReactFragmentProp, UnknownComponentProps } from '../types/shared.ts';
|
|
2
2
|
/**
|
|
3
3
|
* Options for creating a remote React component.
|
|
4
4
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { Alert, Button } from "../../index.js";
|
|
4
|
-
import { createRenderer, isMatch, isRenderedFragmentNode
|
|
4
|
+
import { createRenderer, isMatch, isRenderedFragmentNode } from "../index.js";
|
|
5
5
|
describe('isMatch()', () => {
|
|
6
6
|
describe('isMatch() utility function', () => {
|
|
7
7
|
it('should allow assertions against a mix of text and element nodes', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it } from 'vitest';
|
|
2
|
+
import { ServerlessExecutionStatus } from "../../shared/types/http-requests.js";
|
|
2
3
|
import { createRenderer } from "../index.js";
|
|
3
|
-
import { ServerlessExecutionStatus, } from "../../shared/types/http-requests.js";
|
|
4
4
|
describe('mock runServerlessFunction', () => {
|
|
5
5
|
it('should provide the ability to spy on the runServerlessFunction function', async () => {
|
|
6
6
|
const { mocks } = createRenderer('crm.record.tab');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
-
import { Text, Button } from "../../index.js";
|
|
4
|
-
import { createRenderer } from "../index.js";
|
|
5
3
|
import { useAssociations } from "../../crm/index.js";
|
|
4
|
+
import { Button, Text } from "../../index.js";
|
|
5
|
+
import { createRenderer } from "../index.js";
|
|
6
6
|
function MyComponent() {
|
|
7
7
|
const { results, isLoading, isRefetching, error, refetch } = useAssociations({
|
|
8
8
|
toObjectType: '0-1',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
-
import { Text, Button } from "../../index.js";
|
|
4
|
-
import { createRenderer } from "../index.js";
|
|
5
3
|
import { useCrmProperties } from "../../crm/index.js";
|
|
4
|
+
import { Button, Text } from "../../index.js";
|
|
5
|
+
import { createRenderer } from "../index.js";
|
|
6
6
|
function MyComponent() {
|
|
7
7
|
const { properties, isLoading, isRefetching, error, refetch } = useCrmProperties(['firstname', 'lastname']);
|
|
8
8
|
if (isLoading) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createRenderer } from "../index.js";
|
|
3
2
|
import { useExtensionActions } from "../../hooks/useExtensionActions.js";
|
|
4
3
|
import { Button } from "../../index.js";
|
|
4
|
+
import { createRenderer } from "../index.js";
|
|
5
5
|
function MyActionsCrmComponent() {
|
|
6
6
|
const actions = useExtensionActions();
|
|
7
7
|
return (_jsxs(_Fragment, { children: [_jsx(Button, { testId: "reloadButton", onClick: () => actions.reloadPage(), children: "Reload Page" }), _jsx(Button, { testId: "fetchButton", onClick: () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { useExtensionApi } from "../../hooks/useExtensionApi.js";
|
|
3
4
|
import { Button, Text } from "../../index.js";
|
|
4
5
|
import { createRenderer } from "../index.js";
|
|
5
|
-
import { useExtensionApi } from "../../hooks/useExtensionApi.js";
|
|
6
6
|
function MyComponent() {
|
|
7
7
|
const { context } = useExtensionApi();
|
|
8
8
|
return (_jsxs(_Fragment, { children: [_jsx(Text, { testId: "location-text", children: context.location }), _jsx(Text, { testId: "user-email", children: context.user.email }), _jsx(Text, { testId: "user-firstName", children: context.user.firstName }), _jsx(Text, { testId: "user-lastName", children: context.user.lastName }), _jsx(Text, { testId: "portal-id", children: context.portal.id }), _jsx(Text, { testId: "portal-timezone", children: context.portal.timezone }), 'crm' in context && (_jsxs(_Fragment, { children: [_jsx(Text, { testId: "crm-objectId", children: context.crm.objectId }), _jsx(Text, { testId: "crm-objectTypeId", children: context.crm.objectTypeId })] }))] }));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { useExtensionContext } from "../../hooks/useExtensionContext.js";
|
|
3
4
|
import { Text } from "../../index.js";
|
|
4
5
|
import { createRenderer } from "../index.js";
|
|
5
|
-
import { useExtensionContext } from "../../hooks/useExtensionContext.js";
|
|
6
6
|
function MyComponent() {
|
|
7
7
|
const context = useExtensionContext();
|
|
8
8
|
return (_jsxs(_Fragment, { children: [_jsx(Text, { testId: "location-text", children: context.location }), _jsx(Text, { testId: "user-email", children: context.user.email }), _jsx(Text, { testId: "user-firstName", children: context.user.firstName }), _jsx(Text, { testId: "user-lastName", children: context.user.lastName }), _jsx(Text, { testId: "portal-id", children: context.portal.id }), _jsx(Text, { testId: "portal-timezone", children: context.portal.timezone }), 'crm' in context && (_jsxs(_Fragment, { children: [_jsx(Text, { testId: "crm-objectId", children: context.crm.objectId }), _jsx(Text, { testId: "crm-objectTypeId", children: context.crm.objectTypeId })] }))] }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RemoteRoot } from '@remote-ui/core';
|
|
2
2
|
import type { RenderedRootNodeInternal } from './types-internal.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Converts a remote root node to a rendered root node. After conversion, the rendered root node will
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { KIND_COMPONENT, KIND_FRAGMENT, KIND_TEXT
|
|
1
|
+
import { KIND_COMPONENT, KIND_FRAGMENT, KIND_TEXT } from '@remote-ui/core';
|
|
2
|
+
import { __hubSpotComponentRegistry } from "../../shared/remoteComponents.js";
|
|
3
|
+
import { isRenderedTextNode } from "../type-utils.js";
|
|
4
|
+
import { EMPTY_RENDERED_CHILD_NODES } from "./constants.js";
|
|
2
5
|
import { createElementNode } from "./element.js";
|
|
3
6
|
import { DuplicateTestIdError, InvalidFragmentPropArrayError, } from "./errors.js";
|
|
4
7
|
import { createFragmentNode } from "./fragment.js";
|
|
5
8
|
import { createTextNode } from "./text.js";
|
|
6
|
-
import { __hubSpotComponentRegistry } from "../../shared/remoteComponents.js";
|
|
7
|
-
import { isRenderedTextNode } from "../type-utils.js";
|
|
8
|
-
import { EMPTY_RENDERED_CHILD_NODES } from "./constants.js";
|
|
9
9
|
import { asRenderedParentNode } from "./type-utils-internal.js";
|
|
10
|
-
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
11
10
|
/**
|
|
12
11
|
* Converts a remote props object to a props object that can be attached to a rendered element node.
|
|
13
12
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UnknownComponentProps } from '../../shared/types/shared.ts';
|
|
2
|
-
import { RenderedElementNode } from '../types.ts';
|
|
2
|
+
import type { RenderedElementNode } from '../types.ts';
|
|
3
3
|
import type { RenderedDocumentInternal } from './types-internal.ts';
|
|
4
4
|
/**
|
|
5
5
|
* Creates a rendered element node.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RenderedElementNode, RenderedParentNode } from '../types.ts';
|
|
2
|
-
import { RenderedRootNodeInternal } from './types-internal.ts';
|
|
1
|
+
import type { RenderedElementNode, RenderedParentNode } from '../types.ts';
|
|
2
|
+
import type { RenderedRootNodeInternal } from './types-internal.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Thrown when trying to trigger an event that has a handler prop that is not a function.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UnknownComponentProps } from '../../shared/types/shared.ts';
|
|
2
|
-
import { ElementMatcher, RenderedElementNode } from '../types.ts';
|
|
1
|
+
import type { UnknownComponentProps } from '../../shared/types/shared.ts';
|
|
2
|
+
import type { ElementMatcher, RenderedElementNode } from '../types.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Checks if the element matches the matcher.
|
|
5
5
|
*
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { type useAppPageLocation } from '../../../experimental/pages/internal/useAppPageLocation.tsx';
|
|
2
|
+
import type { ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
|
|
3
|
+
import type { RendererMocks } from '../../types.ts';
|
|
4
|
+
import { type MocksAppPageLocationStore } from './mock-app-page-location.tsx';
|
|
4
5
|
/**
|
|
5
6
|
* An object containing the mocks and spies.
|
|
6
7
|
*/
|
|
7
|
-
export interface
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
export interface RendererMocksContext {
|
|
9
|
+
/**
|
|
10
|
+
* The mocks object provided by the testing utilities.
|
|
11
|
+
*/
|
|
12
|
+
mocks: RendererMocks<ExtensionPointLocation>;
|
|
13
|
+
/**
|
|
14
|
+
* The app page location store.
|
|
15
|
+
*/
|
|
16
|
+
appPageLocationStore: MocksAppPageLocationStore;
|
|
17
|
+
useAppPageLocation: typeof useAppPageLocation;
|
|
10
18
|
}
|
|
11
19
|
/**
|
|
12
20
|
* Creates a set of mocks and spies for the various functions such as the `useCrmProperties` and `useAssociations`
|
|
@@ -14,4 +22,4 @@ export interface MocksWithSpies<TExtensionPointLocation extends ExtensionPointLo
|
|
|
14
22
|
*
|
|
15
23
|
* @returns An object containing the mocks and spies.
|
|
16
24
|
*/
|
|
17
|
-
export declare const
|
|
25
|
+
export declare const createRendererMocksContext: <TExtensionPointLocation extends ExtensionPointLocation>(extensionPointLocation: TExtensionPointLocation) => RendererMocksContext;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { act as reactAct, useSyncExternalStore } from 'react';
|
|
1
2
|
import { spyOn } from 'tinyspy';
|
|
2
|
-
import {
|
|
3
|
+
import { createMocksAppPageLocationStore, } from "./mock-app-page-location.js";
|
|
3
4
|
import { createMockExtensionPointApi } from "./mock-extension-point-api.js";
|
|
5
|
+
import { createMockHooks } from "./mock-hooks.js";
|
|
4
6
|
/**
|
|
5
7
|
* This function replaces all methods with a spy using the `spyOn` function from the `tinyspy` library.
|
|
6
8
|
* The object tree is walked recursively to replace all methods with spies. The original object is not modified.
|
|
@@ -29,7 +31,7 @@ const spyOnAllFunctionsRecursive = (object) => {
|
|
|
29
31
|
*
|
|
30
32
|
* @returns An object containing the mocks and spies.
|
|
31
33
|
*/
|
|
32
|
-
export const
|
|
34
|
+
export const createRendererMocksContext = (extensionPointLocation) => {
|
|
33
35
|
const mockExtensionPointApi = createMockExtensionPointApi(extensionPointLocation);
|
|
34
36
|
// Build a mocks object with the default mock functions.
|
|
35
37
|
// NOTE: The mock implementations can be overridden by tests using the spies that are provided in the returned `spies` object.
|
|
@@ -37,10 +39,22 @@ export const createMocksWithSpies = (extensionPointLocation) => {
|
|
|
37
39
|
...createMockHooks(),
|
|
38
40
|
...mockExtensionPointApi,
|
|
39
41
|
};
|
|
40
|
-
//
|
|
41
|
-
const
|
|
42
|
+
// Recursively create spies for all functions in the mocks object.
|
|
43
|
+
const mocksWithSpies = spyOnAllFunctionsRecursive(mocks);
|
|
44
|
+
const appPageLocationStore = createMocksAppPageLocationStore();
|
|
42
45
|
return {
|
|
43
|
-
mocks
|
|
44
|
-
|
|
46
|
+
mocks: {
|
|
47
|
+
// NOTE: These mocks are exposed as part of our public API.
|
|
48
|
+
...mocksWithSpies,
|
|
49
|
+
setPageLocation: (location) => {
|
|
50
|
+
reactAct(() => {
|
|
51
|
+
appPageLocationStore.setPageLocation(location);
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
appPageLocationStore,
|
|
56
|
+
useAppPageLocation: () => {
|
|
57
|
+
return useSyncExternalStore(appPageLocationStore.subscribe, appPageLocationStore.getSnapshot);
|
|
58
|
+
},
|
|
45
59
|
};
|
|
46
60
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppPageLocation } from '../../../shared/types/shared.ts';
|
|
2
|
+
export interface MocksAppPageLocationStore {
|
|
3
|
+
getSnapshot: () => AppPageLocation;
|
|
4
|
+
setPageLocation: (location: AppPageLocation) => void;
|
|
5
|
+
subscribe: (listener: () => void) => () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const createMocksAppPageLocationStore: (initialLocation?: AppPageLocation) => MocksAppPageLocationStore;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const DEFAULT_PAGE_LOCATION = { path: '/', params: {} };
|
|
2
|
+
const areParamsEqual = (a, b) => {
|
|
3
|
+
const keysA = Object.keys(a);
|
|
4
|
+
const keysB = Object.keys(b);
|
|
5
|
+
if (keysA.length !== keysB.length)
|
|
6
|
+
return false;
|
|
7
|
+
for (const key of keysA) {
|
|
8
|
+
if (a[key] !== b[key])
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
const areAppPageLocationsEqual = (a, b) => a.path === b.path && areParamsEqual(a.params, b.params);
|
|
14
|
+
export const createMocksAppPageLocationStore = (initialLocation = DEFAULT_PAGE_LOCATION) => {
|
|
15
|
+
let currentLocation = initialLocation;
|
|
16
|
+
let listeners = [];
|
|
17
|
+
return {
|
|
18
|
+
getSnapshot: () => currentLocation,
|
|
19
|
+
setPageLocation: (location) => {
|
|
20
|
+
if (areAppPageLocationsEqual(location, currentLocation)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
currentLocation = location;
|
|
24
|
+
for (const listener of listeners) {
|
|
25
|
+
listener();
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
subscribe: (listener) => {
|
|
29
|
+
listeners = [...listeners, listener];
|
|
30
|
+
return () => {
|
|
31
|
+
listeners = listeners.filter((l) => l !== listener);
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { ExtensionPointApi
|
|
1
|
+
import type { ExtensionPointApi } from '../../../shared/types/extension-points.ts';
|
|
2
|
+
import { type ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
|
|
2
3
|
export declare const createMockExtensionPointApi: (extensionPointLocation: ExtensionPointLocation) => ExtensionPointApi<ExtensionPointLocation>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ServerlessExecutionStatus
|
|
1
|
+
import { ServerlessExecutionStatus } from "../../../shared/types/http-requests.js";
|
|
2
2
|
const fakePrefix = 'fake_';
|
|
3
3
|
const createMockServerlessFuncRunner = () => {
|
|
4
4
|
return () => Promise.resolve({
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RendererMockHooksInternal } from '../types-internal.ts';
|
|
2
1
|
import type { ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
|
|
2
|
+
import type { RendererMockHooksInternal } from '../types-internal.ts';
|
|
3
3
|
export declare const createMockHooks: <TExtensionPointLocation extends ExtensionPointLocation>() => RendererMockHooksInternal;
|