@hubspot/ui-extensions 0.12.1 → 0.12.3

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 (106) hide show
  1. package/dist/__tests__/crm/utils/fetchAssociations.spec.js +1 -1
  2. package/dist/__tests__/crm/utils/fetchCrmProperties.spec.js +1 -1
  3. package/dist/crm/hooks/useAssociations.d.ts +1 -1
  4. package/dist/crm/hooks/useAssociations.js +2 -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 -1
  8. package/dist/crm/utils/fetchAssociations.js +0 -1
  9. package/dist/crm/utils/fetchCrmProperties.js +0 -1
  10. package/dist/experimental/pages/index.d.ts +4 -0
  11. package/dist/experimental/pages/index.js +3 -0
  12. package/dist/hs-internal/__tests__/createRemoteComponentInternal.spec.js +4 -4
  13. package/dist/hubspot.js +0 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +1 -1
  16. package/dist/internal/global-utils.d.ts +1 -1
  17. package/dist/internal/hook-utils.d.ts +3 -3
  18. package/dist/shared/remoteComponents.d.ts +13 -2
  19. package/dist/shared/remoteComponents.js +13 -0
  20. package/dist/shared/types/components/accordion.d.ts +3 -3
  21. package/dist/shared/types/components/alert.d.ts +3 -3
  22. package/dist/shared/types/components/app-home-header-actions.d.ts +5 -5
  23. package/dist/shared/types/components/button-row.d.ts +3 -3
  24. package/dist/shared/types/components/button.d.ts +7 -6
  25. package/dist/shared/types/components/card.d.ts +2 -2
  26. package/dist/shared/types/components/chart.d.ts +3 -3
  27. package/dist/shared/types/components/description-list.d.ts +5 -5
  28. package/dist/shared/types/components/divider.d.ts +6 -2
  29. package/dist/shared/types/components/dropdown.d.ts +4 -5
  30. package/dist/shared/types/components/empty-state.d.ts +3 -3
  31. package/dist/shared/types/components/error-state.d.ts +3 -3
  32. package/dist/shared/types/components/form.d.ts +4 -4
  33. package/dist/shared/types/components/heading.d.ts +3 -3
  34. package/dist/shared/types/components/icon.d.ts +4 -4
  35. package/dist/shared/types/components/iframe.d.ts +1 -1
  36. package/dist/shared/types/components/illustration.d.ts +2 -2
  37. package/dist/shared/types/components/image.d.ts +5 -4
  38. package/dist/shared/types/components/index.d.ts +1 -0
  39. package/dist/shared/types/components/inputs.d.ts +9 -9
  40. package/dist/shared/types/components/layouts.d.ts +7 -7
  41. package/dist/shared/types/components/link.d.ts +6 -5
  42. package/dist/shared/types/components/list.d.ts +3 -3
  43. package/dist/shared/types/components/loading-spinner.d.ts +2 -2
  44. package/dist/shared/types/components/modal.d.ts +2 -2
  45. package/dist/shared/types/components/panel.d.ts +2 -2
  46. package/dist/shared/types/components/progress-bar.d.ts +2 -2
  47. package/dist/shared/types/components/score.d.ts +2 -2
  48. package/dist/shared/types/components/selects.d.ts +3 -3
  49. package/dist/shared/types/components/spacer.d.ts +14 -0
  50. package/dist/shared/types/components/spacer.js +1 -0
  51. package/dist/shared/types/components/statistics.d.ts +7 -7
  52. package/dist/shared/types/components/status-tag.d.ts +3 -3
  53. package/dist/shared/types/components/step-indicator.d.ts +2 -2
  54. package/dist/shared/types/components/table.d.ts +6 -6
  55. package/dist/shared/types/components/tabs.d.ts +2 -2
  56. package/dist/shared/types/components/tag.d.ts +6 -5
  57. package/dist/shared/types/components/text.d.ts +3 -3
  58. package/dist/shared/types/components/tile.d.ts +3 -3
  59. package/dist/shared/types/components/toggle.d.ts +2 -2
  60. package/dist/shared/types/components/toggleInputs.d.ts +4 -4
  61. package/dist/shared/types/components/tooltip.d.ts +2 -2
  62. package/dist/shared/types/crm.d.ts +188 -44
  63. package/dist/shared/types/experimental.d.ts +1 -1
  64. package/dist/shared/types/extend.d.ts +2 -2
  65. package/dist/shared/types/extension-points.d.ts +4 -5
  66. package/dist/shared/types/pages/app-pages-types.d.ts +75 -0
  67. package/dist/shared/types/pages/app-pages-types.js +1 -0
  68. package/dist/shared/types/pages/components/index.d.ts +2 -0
  69. package/dist/shared/types/pages/components/index.js +1 -0
  70. package/dist/shared/types/pages/components/page-link.d.ts +23 -0
  71. package/dist/shared/types/pages/components/page-link.js +1 -0
  72. package/dist/shared/types/pages/components/page-routes.d.ts +115 -0
  73. package/dist/shared/types/pages/components/page-routes.js +1 -0
  74. package/dist/shared/types/shared.d.ts +23 -1
  75. package/dist/shared/types/worker-globals.d.ts +17 -3
  76. package/dist/shared/utils/remote-component-registry.d.ts +1 -1
  77. package/dist/testing/__tests__/isMatch.spec.js +1 -1
  78. package/dist/testing/__tests__/mocks.runServerlessFunction.spec.js +1 -1
  79. package/dist/testing/__tests__/mocks.useAssociations.spec.js +2 -2
  80. package/dist/testing/__tests__/mocks.useCrmProperties.spec.js +2 -2
  81. package/dist/testing/__tests__/mocks.useExtensionActions.spec.js +1 -1
  82. package/dist/testing/__tests__/mocks.useExtensionApi.spec.js +1 -1
  83. package/dist/testing/__tests__/mocks.useExtensionContext.spec.js +1 -1
  84. package/dist/testing/internal/convert.d.ts +1 -1
  85. package/dist/testing/internal/convert.js +4 -5
  86. package/dist/testing/internal/debug.d.ts +1 -1
  87. package/dist/testing/internal/element.d.ts +1 -1
  88. package/dist/testing/internal/errors.d.ts +2 -2
  89. package/dist/testing/internal/fragment.d.ts +1 -1
  90. package/dist/testing/internal/match.d.ts +2 -2
  91. package/dist/testing/internal/mocks/index.d.ts +3 -3
  92. package/dist/testing/internal/mocks/index.js +1 -1
  93. package/dist/testing/internal/mocks/mock-extension-point-api.d.ts +2 -1
  94. package/dist/testing/internal/mocks/mock-extension-point-api.js +1 -1
  95. package/dist/testing/internal/mocks/mock-hooks.d.ts +1 -1
  96. package/dist/testing/internal/text.d.ts +2 -2
  97. package/dist/testing/internal/type-utils-internal.d.ts +2 -2
  98. package/dist/testing/internal/types-internal.d.ts +6 -6
  99. package/dist/testing/render.d.ts +2 -2
  100. package/dist/testing/render.js +5 -6
  101. package/dist/testing/type-utils.d.ts +1 -1
  102. package/dist/testing/type-utils.js +1 -1
  103. package/dist/testing/types.d.ts +9 -9
  104. package/dist/testing/utils.d.ts +1 -1
  105. package/dist/testing/utils.js +1 -1
  106. package/package.json +32 -24
@@ -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 {};
@@ -1,4 +1,4 @@
1
- import type { ReactElement, ComponentType, ReactNode } from 'react';
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.
@@ -21,6 +21,13 @@ export declare class FormSubmitExtensionEvent<V> extends ExtensionEvent {
21
21
  constructor(value: V, event: Event);
22
22
  }
23
23
  export type OverlayComponentProps = {
24
+ /**
25
+ * Include a [Modal](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/standard-components/modal) or
26
+ * [Panel](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/standard-components/panel) component to
27
+ * open it as an overlay on click.
28
+ *
29
+ * Learn more about [using overlays](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-extensions-sdk#open-overlays).
30
+ */
24
31
  overlay?: ReactNode;
25
32
  };
26
33
  export type HrefOptions = {
@@ -36,6 +43,7 @@ export interface TShirtSizes {
36
43
  xl: 'extra-large' | 'xl';
37
44
  }
38
45
  export type AllSizes = TShirtSizes['xs'] | TShirtSizes['sm'] | TShirtSizes['md'] | TShirtSizes['lg'] | TShirtSizes['xl'];
46
+ export type AllSizesUnaliased = 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large';
39
47
  export type AllDistances = 'flush' | AllSizes;
40
48
  export declare const iconNames: {
41
49
  readonly add: "add";
@@ -247,3 +255,17 @@ export interface BaseComponentProps {
247
255
  */
248
256
  testId?: string;
249
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,8 @@
1
- import { Logger } from './logger.ts';
2
- import { HubspotExtendFunction } from './extend.ts';
3
- import type { ExtensionPoints, ExtensionPointApiContext, ExtensionPointApiActions, ExtensionPointFullApi } from './extension-points.ts';
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 { CreatePageRouterFunction, UsePageRouteHook } from './pages/app-pages-types.ts';
5
+ import type { PageRoutesComponent } from './pages/components/page-routes.ts';
4
6
  export interface WorkersApi {
5
7
  /**
6
8
  * Hook added to worker globals so customer code can access extension context at runtime.
@@ -14,6 +16,18 @@ export interface WorkersApi {
14
16
  * Hook added to worker globals so customer code can access extension API at runtime.
15
17
  */
16
18
  useExtensionApi: <ExtensionPoint extends keyof ExtensionPoints>() => ExtensionPointFullApi<ExtensionPoint>;
19
+ /**
20
+ * The PageRoutes component.
21
+ */
22
+ PageRoutes: PageRoutesComponent;
23
+ /**
24
+ * Hook added to worker globals so customer code can access the current page route at runtime.
25
+ */
26
+ usePageRoute: UsePageRouteHook;
27
+ /**
28
+ * Function added to worker globals so customer code can create a page router at runtime.
29
+ */
30
+ createPageRouter: CreatePageRouterFunction;
17
31
  }
18
32
  export interface WorkerGlobalsInternal {
19
33
  /**
@@ -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, } from "../index.js";
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 { type RemoteRoot } from '@remote-ui/core';
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, } from '@remote-ui/core';
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,4 +1,4 @@
1
- import { RenderedNode } from '../types.ts';
1
+ import type { RenderedNode } from '../types.ts';
2
2
  /**
3
3
  * Logs a rendered node tree to the console for debugging purposes.
4
4
  *
@@ -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,4 +1,4 @@
1
- import { RenderedFragmentNode } from '../types.ts';
1
+ import type { RenderedFragmentNode } from '../types.ts';
2
2
  import type { RenderedDocumentInternal } from './types-internal.ts';
3
3
  /**
4
4
  * Creates a rendered fragment node.
@@ -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,6 +1,6 @@
1
- import { RendererSpies } from '../../types.ts';
2
- import { RendererMocksInternal } from '../types-internal.ts';
3
- import { ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
1
+ import type { ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
2
+ import type { RendererSpies } from '../../types.ts';
3
+ import type { RendererMocksInternal } from '../types-internal.ts';
4
4
  /**
5
5
  * An object containing the mocks and spies.
6
6
  */
@@ -1,6 +1,6 @@
1
1
  import { spyOn } from 'tinyspy';
2
- import { createMockHooks } from "./mock-hooks.js";
3
2
  import { createMockExtensionPointApi } from "./mock-extension-point-api.js";
3
+ import { createMockHooks } from "./mock-hooks.js";
4
4
  /**
5
5
  * This function replaces all methods with a spy using the `spyOn` function from the `tinyspy` library.
6
6
  * The object tree is walked recursively to replace all methods with spies. The original object is not modified.
@@ -1,2 +1,3 @@
1
- import { ExtensionPointApi, type ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
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, } from "../../../shared/types/http-requests.js";
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;
@@ -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
9
  import { createMocksWithSpies } 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,
@@ -28,7 +28,6 @@ const render = (node, mocksWithSpies) => {
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
  });
@@ -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.
@@ -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,12 @@
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 { 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, ExtensionPointApiActions, ExtensionPointLocation } from '../shared/types/extension-points.ts';
7
+ import type { ServerlessFuncRunner } from '../shared/types/http-requests.ts';
8
+ import type { HubSpotReactComponent, HubSpotReactFragmentProp, UnknownComponentProps } from '../shared/types/shared.ts';
9
+ import type { AnyFunction } from './internal/types-internal.ts';
10
10
  /**
11
11
  * The type of a rendered node.
12
12
  */
@@ -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
  *
package/package.json CHANGED
@@ -1,22 +1,11 @@
1
1
  {
2
2
  "name": "@hubspot/ui-extensions",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
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": "^20.11.0",
65
- "@types/react": "^18.3.1",
66
- "@types/react-dom": "^18.3.1",
67
- "@vitest/coverage-v8": "2.1.8",
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",
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": "2.1.9"
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": "3da4a07183d48528ef431d46a8d327c053c4fe94"
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
+ }