@hubspot/ui-extensions 0.8.37 → 0.8.39
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/coreComponents.d.ts +8 -0
- package/dist/coreComponents.js +8 -0
- package/dist/experimental/testing/index.d.ts +14 -0
- package/dist/experimental/testing/index.js +33 -0
- package/dist/experimental/testing/jest/matchers/index.d.ts +6 -0
- package/dist/experimental/testing/jest/matchers/index.js +6 -0
- package/package.json +12 -3
package/dist/coreComponents.d.ts
CHANGED
|
@@ -7,6 +7,14 @@ export declare const Alert: "Alert" & {
|
|
|
7
7
|
readonly props?: types.AlertProps | undefined;
|
|
8
8
|
readonly children?: true | undefined;
|
|
9
9
|
} & import("@remote-ui/react").ReactComponentTypeFromRemoteComponentType<import("@remote-ui/types").RemoteComponentType<"Alert", types.AlertProps, true>>;
|
|
10
|
+
/**
|
|
11
|
+
* The `Button` component renders a single button. Use this component to enable users to perform actions, such as submitting a form, sending data to an external system, or deleting data.
|
|
12
|
+
*
|
|
13
|
+
* **Links:**
|
|
14
|
+
*
|
|
15
|
+
* - {@link https://developers.hubspot.com/beta-docs/reference/ui-components/standard-components/button Docs}
|
|
16
|
+
* - {@link https://developers.hubspot.com/beta-docs/reference/ui-components/standard-components/button#usage-examples Examples}
|
|
17
|
+
*/
|
|
10
18
|
export declare const Button: "Button" & {
|
|
11
19
|
readonly type?: "Button" | undefined;
|
|
12
20
|
readonly props?: types.ButtonProps | undefined;
|
package/dist/coreComponents.js
CHANGED
|
@@ -3,6 +3,14 @@ import { createRemoteReactComponent } from '@remote-ui/react';
|
|
|
3
3
|
* @link https://developers.hubspot.com/beta-docs/reference/ui-components/standard-components/alert
|
|
4
4
|
*/
|
|
5
5
|
export const Alert = createRemoteReactComponent('Alert');
|
|
6
|
+
/**
|
|
7
|
+
* The `Button` component renders a single button. Use this component to enable users to perform actions, such as submitting a form, sending data to an external system, or deleting data.
|
|
8
|
+
*
|
|
9
|
+
* **Links:**
|
|
10
|
+
*
|
|
11
|
+
* - {@link https://developers.hubspot.com/beta-docs/reference/ui-components/standard-components/button Docs}
|
|
12
|
+
* - {@link https://developers.hubspot.com/beta-docs/reference/ui-components/standard-components/button#usage-examples Examples}
|
|
13
|
+
*/
|
|
6
14
|
export const Button = createRemoteReactComponent('Button', {
|
|
7
15
|
fragmentProps: ['overlay'],
|
|
8
16
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type RootNode, type Node } from '@remote-ui/testing';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
type CoreComponentName = keyof typeof import('../../coreComponents');
|
|
4
|
+
type CrmComponentName = keyof typeof import('../../crm');
|
|
5
|
+
interface HubSpotRoot extends RootNode<unknown> {
|
|
6
|
+
findByName: (name: CoreComponentName | CrmComponentName) => ReturnType<Node<unknown>['find']>;
|
|
7
|
+
}
|
|
8
|
+
interface RenderReturn {
|
|
9
|
+
extension: HubSpotRoot;
|
|
10
|
+
flushAsync: () => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
/** @experimental This function is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates. */
|
|
13
|
+
export declare function render(ui: ReactNode): RenderReturn;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createRoot } from '@remote-ui/react';
|
|
2
|
+
import { mount } from '@remote-ui/testing';
|
|
3
|
+
/** @experimental This function is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates. */
|
|
4
|
+
export function render(ui) {
|
|
5
|
+
const mountedExtension = mount((coreRemoteRoot) => {
|
|
6
|
+
// create the react appliction to render remote react component
|
|
7
|
+
createRoot(coreRemoteRoot).render(ui);
|
|
8
|
+
});
|
|
9
|
+
function findByName(name) {
|
|
10
|
+
return mountedExtension.find(name);
|
|
11
|
+
}
|
|
12
|
+
// @ts-expect-error ts doesn't know the type of object that we are forwarding to
|
|
13
|
+
const extension = new Proxy({ findByName }, //target object
|
|
14
|
+
{
|
|
15
|
+
// traps and modifies calls to target object
|
|
16
|
+
get(target, key, receiver) {
|
|
17
|
+
// if target object has the key, invoke.
|
|
18
|
+
if (Reflect.ownKeys(target).includes(key)) {
|
|
19
|
+
return Reflect.get(target, key, receiver);
|
|
20
|
+
}
|
|
21
|
+
// if our target object doesn't have the key, pass to the extension
|
|
22
|
+
return Reflect.get(mountedExtension, key);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
function flushAsync() {
|
|
26
|
+
// the promise with the setTimeout is what flushes the promise stack
|
|
27
|
+
return new Promise((resolve) => setTimeout(resolve, 0)).then(() => {
|
|
28
|
+
// the act call on the extension forces the UI to update
|
|
29
|
+
mountedExtension.act(() => null);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return { extension, flushAsync };
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/ui-extensions",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.39",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,11 +22,14 @@
|
|
|
22
22
|
"exports": {
|
|
23
23
|
".": "./dist/index.js",
|
|
24
24
|
"./crm": "./dist/crm/index.js",
|
|
25
|
-
"./experimental": "./dist/experimental/index.js"
|
|
25
|
+
"./experimental": "./dist/experimental/index.js",
|
|
26
|
+
"./experimental/testing": "./dist/experimental/testing/index.js",
|
|
27
|
+
"./experimental/testing/jest-matchers": "./dist/experimental/testing/jest/matchers/index.js"
|
|
26
28
|
},
|
|
27
29
|
"license": "MIT",
|
|
28
30
|
"dependencies": {
|
|
29
31
|
"@remote-ui/react": "^5.0.0",
|
|
32
|
+
"@remote-ui/testing": "^1.4.3",
|
|
30
33
|
"react": "^18.2.0"
|
|
31
34
|
},
|
|
32
35
|
"engines": {
|
|
@@ -46,10 +49,16 @@
|
|
|
46
49
|
},
|
|
47
50
|
"typescript": {
|
|
48
51
|
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"jest": {
|
|
54
|
+
"optional": true
|
|
49
55
|
}
|
|
50
56
|
},
|
|
51
57
|
"devDependencies": {
|
|
58
|
+
"@types/jest": "^29.5.13",
|
|
59
|
+
"jest": "^29.7.0",
|
|
60
|
+
"react-reconciler": "^0.29.0",
|
|
52
61
|
"typescript": "5.0.4"
|
|
53
62
|
},
|
|
54
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "3dbfe0afee58682d51c4a5eb7e0e40a6e3920631"
|
|
55
64
|
}
|