@hubspot/ui-extensions 0.10.0 → 0.11.0
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/{pages/home/components.d.ts → __synced__/appHomeRemoteComponents.synced.d.ts} +7 -7
- package/dist/{pages/home/components.js → __synced__/appHomeRemoteComponents.synced.js} +1 -0
- package/dist/{crm/components.d.ts → __synced__/crmRemoteComponents.synced.d.ts} +40 -41
- package/dist/__synced__/crmRemoteComponents.synced.js +15 -0
- package/dist/__synced__/experimental/types.synced.d.ts +241 -0
- package/dist/__synced__/experimental/types.synced.js +5 -0
- package/dist/__synced__/experimentalRemoteComponents.synced.d.ts +94 -0
- package/dist/__synced__/experimentalRemoteComponents.synced.js +56 -0
- package/dist/__synced__/remoteComponents.synced.d.ts +848 -0
- package/dist/__synced__/remoteComponents.synced.js +583 -0
- package/dist/__synced__/types/actions.synced.d.ts +57 -0
- package/dist/__synced__/types/actions.synced.js +1 -0
- package/dist/__synced__/types/components/accordion.synced.d.ts +48 -0
- package/dist/__synced__/types/components/accordion.synced.js +1 -0
- package/dist/__synced__/types/components/alert.synced.d.ts +24 -0
- package/dist/__synced__/types/components/alert.synced.js +1 -0
- package/dist/__synced__/types/components/app-home-header-actions.synced.d.ts +39 -0
- package/dist/__synced__/types/components/app-home-header-actions.synced.js +1 -0
- package/dist/__synced__/types/components/button-row.synced.d.ts +44 -0
- package/dist/__synced__/types/components/button-row.synced.js +1 -0
- package/dist/__synced__/types/components/button.synced.d.ts +89 -0
- package/dist/__synced__/types/components/button.synced.js +1 -0
- package/dist/__synced__/types/components/card.synced.d.ts +12 -0
- package/dist/__synced__/types/components/card.synced.js +1 -0
- package/dist/__synced__/types/components/chart.synced.d.ts +137 -0
- package/dist/__synced__/types/components/chart.synced.js +5 -0
- package/dist/__synced__/types/components/description-list.synced.d.ts +36 -0
- package/dist/__synced__/types/components/description-list.synced.js +1 -0
- package/dist/__synced__/types/components/divider.synced.d.ts +14 -0
- package/dist/__synced__/types/components/divider.synced.js +1 -0
- package/dist/__synced__/types/components/dropdown.synced.d.ts +84 -0
- package/dist/__synced__/types/components/dropdown.synced.js +1 -0
- package/dist/__synced__/types/components/empty-state.synced.d.ts +51 -0
- package/dist/__synced__/types/components/empty-state.synced.js +1 -0
- package/dist/__synced__/types/components/error-state.synced.d.ts +24 -0
- package/dist/__synced__/types/components/error-state.synced.js +1 -0
- package/dist/__synced__/types/components/form.synced.d.ts +29 -0
- package/dist/__synced__/types/components/form.synced.js +1 -0
- package/dist/__synced__/types/components/heading.synced.d.ts +19 -0
- package/dist/__synced__/types/components/heading.synced.js +1 -0
- package/dist/__synced__/types/components/icon.synced.d.ts +29 -0
- package/dist/__synced__/types/components/icon.synced.js +1 -0
- package/dist/__synced__/types/components/iframe.synced.d.ts +20 -0
- package/dist/__synced__/types/components/iframe.synced.js +1 -0
- package/dist/__synced__/types/components/illustration.synced.d.ts +53 -0
- package/dist/__synced__/types/components/illustration.synced.js +43 -0
- package/dist/__synced__/types/components/image.synced.d.ts +40 -0
- package/dist/__synced__/types/components/image.synced.js +1 -0
- package/dist/__synced__/types/components/index.synced.d.ts +38 -0
- package/dist/__synced__/types/components/index.synced.js +1 -0
- package/dist/__synced__/types/components/inputs.synced.d.ts +350 -0
- package/dist/__synced__/types/components/inputs.synced.js +1 -0
- package/dist/__synced__/types/components/layouts.synced.d.ts +172 -0
- package/dist/__synced__/types/components/layouts.synced.js +1 -0
- package/dist/__synced__/types/components/link.synced.d.ts +38 -0
- package/dist/__synced__/types/components/link.synced.js +1 -0
- package/dist/__synced__/types/components/list.synced.d.ts +18 -0
- package/dist/__synced__/types/components/list.synced.js +1 -0
- package/dist/__synced__/types/components/loading-spinner.synced.d.ts +31 -0
- package/dist/__synced__/types/components/loading-spinner.synced.js +1 -0
- package/dist/__synced__/types/components/modal.synced.d.ts +60 -0
- package/dist/__synced__/types/components/modal.synced.js +1 -0
- package/dist/__synced__/types/components/panel.synced.d.ts +73 -0
- package/dist/__synced__/types/components/panel.synced.js +1 -0
- package/dist/__synced__/types/components/progress-bar.synced.d.ts +48 -0
- package/dist/__synced__/types/components/progress-bar.synced.js +1 -0
- package/dist/__synced__/types/components/selects.synced.d.ts +130 -0
- package/dist/__synced__/types/components/selects.synced.js +1 -0
- package/dist/__synced__/types/components/statistics.synced.d.ts +56 -0
- package/dist/__synced__/types/components/statistics.synced.js +1 -0
- package/dist/__synced__/types/components/status-tag.synced.d.ts +42 -0
- package/dist/__synced__/types/components/status-tag.synced.js +1 -0
- package/dist/__synced__/types/components/step-indicator.synced.d.ts +44 -0
- package/dist/__synced__/types/components/step-indicator.synced.js +1 -0
- package/dist/__synced__/types/components/table.synced.d.ts +138 -0
- package/dist/__synced__/types/components/table.synced.js +1 -0
- package/dist/__synced__/types/components/tabs.synced.d.ts +55 -0
- package/dist/__synced__/types/components/tabs.synced.js +1 -0
- package/dist/__synced__/types/components/tag.synced.d.ts +32 -0
- package/dist/__synced__/types/components/tag.synced.js +1 -0
- package/dist/__synced__/types/components/text.synced.d.ts +93 -0
- package/dist/__synced__/types/components/text.synced.js +1 -0
- package/dist/__synced__/types/components/tile.synced.d.ts +24 -0
- package/dist/__synced__/types/components/tile.synced.js +1 -0
- package/dist/__synced__/types/components/toggle.synced.d.ts +60 -0
- package/dist/__synced__/types/components/toggle.synced.js +1 -0
- package/dist/__synced__/types/components/toggleInputs.synced.d.ts +191 -0
- package/dist/__synced__/types/components/toggleInputs.synced.js +1 -0
- package/dist/__synced__/types/components/tooltip.synced.d.ts +12 -0
- package/dist/__synced__/types/components/tooltip.synced.js +1 -0
- package/dist/__synced__/types/context.synced.d.ts +82 -0
- package/dist/__synced__/types/context.synced.js +1 -0
- package/dist/__synced__/types/crm.synced.d.ts +248 -0
- package/dist/__synced__/types/crm.synced.js +1 -0
- package/dist/__synced__/types/extension-points.synced.d.ts +122 -0
- package/dist/__synced__/types/extension-points.synced.js +9 -0
- package/dist/__synced__/types/http-requests.synced.d.ts +106 -0
- package/dist/__synced__/types/http-requests.synced.js +8 -0
- package/dist/__synced__/types/index.synced.d.ts +8 -0
- package/dist/__synced__/types/index.synced.js +9 -0
- package/dist/__synced__/types/reactions.synced.d.ts +12 -0
- package/dist/__synced__/types/reactions.synced.js +1 -0
- package/dist/__synced__/types/shared.synced.d.ts +197 -0
- package/dist/__synced__/types/shared.synced.js +179 -0
- package/dist/coreComponents.d.ts +21 -5
- package/dist/coreComponents.js +23 -1
- package/dist/crm/hooks/useAssociations.d.ts +3 -0
- package/dist/crm/hooks/useAssociations.js +3 -5
- package/dist/crm/hooks/useCrmProperties.d.ts +0 -2
- package/dist/crm/hooks/useCrmProperties.js +0 -7
- package/dist/crm/index.d.ts +2 -2
- package/dist/crm/index.js +1 -2
- package/dist/experimental/index.d.ts +2 -79
- package/dist/experimental/index.js +1 -36
- package/dist/experimental/testing/internal/types-internal.d.ts +47 -0
- package/dist/experimental/testing/internal/types-internal.js +1 -0
- package/dist/experimental/testing/type-utils.d.ts +29 -0
- package/dist/experimental/testing/type-utils.js +37 -0
- package/dist/experimental/testing/types.d.ts +240 -0
- package/dist/experimental/testing/types.js +10 -0
- package/dist/experimental/types.d.ts +4 -9
- package/dist/pages/home/index.d.ts +1 -0
- package/dist/pages/home/index.js +1 -0
- package/dist/types.d.ts +90 -4
- package/dist/types.js +0 -3
- package/package.json +4 -7
- package/dist/crm/components.js +0 -15
- package/dist/experimental/testing/index.d.ts +0 -14
- package/dist/experimental/testing/index.js +0 -33
- package/dist/experimental/testing/jest/matchers/index.d.ts +0 -6
- package/dist/experimental/testing/jest/matchers/index.js +0 -6
- package/dist/utils/createExtensionComponent.d.ts +0 -3
- package/dist/utils/createExtensionComponent.js +0 -4
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import { ReactNode, ComponentType } from 'react';
|
|
1
|
+
import { ReactNode, ComponentType, ReactElement } from 'react';
|
|
2
2
|
import { RemoteFragment } from '@remote-ui/core';
|
|
3
|
+
export type UnknownComponentProps = Record<string, any>;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a HubSpot-provided React component.
|
|
6
|
+
*/
|
|
7
|
+
export type HubSpotReactComponent<TProps extends UnknownComponentProps = UnknownComponentProps> = ComponentType<TProps>;
|
|
8
|
+
/**
|
|
9
|
+
* Represents a fragment property for a HubSpot-provided React component that accepts a React.ReactElement, string, or null.
|
|
10
|
+
* NOTE: UI extension components do _not_ support arrays as a fragment property values.
|
|
11
|
+
*/
|
|
12
|
+
export type HubSpotReactFragmentProp = ReactElement | string | null;
|
|
3
13
|
export declare class ExtensionEvent {
|
|
4
14
|
type: string;
|
|
5
15
|
bubbles: boolean;
|
|
@@ -670,6 +680,9 @@ export interface DividerProps {
|
|
|
670
680
|
*/
|
|
671
681
|
distance?: AllDistances;
|
|
672
682
|
}
|
|
683
|
+
/**
|
|
684
|
+
* @deprecated This type is deprecated and will be removed in a future release. Please use the `DropdownButtonItem` component instead.
|
|
685
|
+
*/
|
|
673
686
|
export interface DropdownOption {
|
|
674
687
|
/**
|
|
675
688
|
* Text to be displayed as the menu item text.
|
|
@@ -684,6 +697,25 @@ export interface DropdownOption {
|
|
|
684
697
|
*/
|
|
685
698
|
onClick?: () => void;
|
|
686
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* The props type for {@link !components.DropdownButtonItem}.
|
|
702
|
+
*
|
|
703
|
+
* @category Component Props
|
|
704
|
+
*/
|
|
705
|
+
export interface DropdownButtonItemProps extends OverlayComponentProps {
|
|
706
|
+
/**
|
|
707
|
+
* Text to be displayed as the menu item text.
|
|
708
|
+
* Can also accept ReactNode for more complex content.
|
|
709
|
+
*/
|
|
710
|
+
children: ReactNode;
|
|
711
|
+
/**
|
|
712
|
+
* A function that will be invoked when the item is clicked.
|
|
713
|
+
* It receives no arguments and its return value is ignored.
|
|
714
|
+
*
|
|
715
|
+
* @event
|
|
716
|
+
*/
|
|
717
|
+
onClick?: ReactionsHandler<ExtensionEvent>;
|
|
718
|
+
}
|
|
687
719
|
/**
|
|
688
720
|
* The props type for {@link !components.Dropdown}.
|
|
689
721
|
*
|
|
@@ -693,8 +725,12 @@ export interface DropdownProps {
|
|
|
693
725
|
/**
|
|
694
726
|
* The list of options to be rendered within the dropdown menu.
|
|
695
727
|
* Each option represents an entry in the Dropdown.
|
|
728
|
+
*
|
|
729
|
+
* @deprecated This prop is deprecated and will be removed in a future release.
|
|
730
|
+
* Use child components instead to define dropdown menu items. For example,
|
|
731
|
+
* use `<Dropdown.ButtonItem>` to render an action button within a dropdown menu.
|
|
696
732
|
*/
|
|
697
|
-
options
|
|
733
|
+
options?: DropdownOption[];
|
|
698
734
|
/**
|
|
699
735
|
* Controls the appearance of the dropdown button
|
|
700
736
|
*
|
|
@@ -719,7 +755,12 @@ export interface DropdownProps {
|
|
|
719
755
|
* @defaultValue `false`
|
|
720
756
|
*/
|
|
721
757
|
disabled?: boolean;
|
|
758
|
+
/**
|
|
759
|
+
* Sets the content that will render inside the Dropdown. You have to use `DropdownOption` component as a child of the `Dropdown` component.
|
|
760
|
+
*/
|
|
761
|
+
children?: ReactNode;
|
|
722
762
|
}
|
|
763
|
+
export type EmptyStateImageName = 'addOnReporting' | 'announcement' | 'api' | 'automatedTesting' | 'beta' | 'building' | 'callingSetUp' | 'companies' | 'components' | 'cone' | 'contacts' | 'contentStrategy' | 'customObjects' | 'customerExperience' | 'customerSupport' | 'deals' | 'developerSecurityUpdate' | 'electronicSignature' | 'electronicSignatureEmptyState' | 'emailConfirmation' | 'emptyStateCharts' | 'idea' | 'integrations' | 'leads' | 'lock' | 'meetings' | 'missedGoal' | 'multipleObjects' | 'object' | 'productsShoppingCart' | 'registration' | 'sandboxAddOn' | 'social' | 'store' | 'storeDisabled' | 'successfullyConnectedEmail' | 'target' | 'task' | 'tickets' | 'voteAndSearch';
|
|
723
764
|
/**
|
|
724
765
|
* The props type for {@link !components.EmptyState}.
|
|
725
766
|
*
|
|
@@ -762,6 +803,12 @@ export interface EmptyStateProps {
|
|
|
762
803
|
* @defaultValue `250`
|
|
763
804
|
*/
|
|
764
805
|
imageWidth?: number;
|
|
806
|
+
/**
|
|
807
|
+
* The name of the image to display.
|
|
808
|
+
*
|
|
809
|
+
* @defaultValue `"emptyStateCharts"`
|
|
810
|
+
*/
|
|
811
|
+
imageName?: EmptyStateImageName;
|
|
765
812
|
}
|
|
766
813
|
/**
|
|
767
814
|
* The props type for {@link !components.ErrorState}.
|
|
@@ -830,12 +877,19 @@ export interface HeadingProps {
|
|
|
830
877
|
*/
|
|
831
878
|
inline?: boolean;
|
|
832
879
|
}
|
|
880
|
+
export type IconColor = 'alert' | 'warning' | 'success' | 'inherit';
|
|
833
881
|
/**
|
|
834
882
|
* The props type for {@link !components.Icon}.
|
|
835
883
|
*
|
|
836
884
|
* @category Component Props
|
|
837
885
|
*/
|
|
838
886
|
export interface IconProps {
|
|
887
|
+
/**
|
|
888
|
+
* Sets the icon color. By default, the icon will use `inherit`, which inherits the color from its parent element.
|
|
889
|
+
*
|
|
890
|
+
* @defaultValue `"inherit"`
|
|
891
|
+
*/
|
|
892
|
+
color?: IconColor;
|
|
839
893
|
/**
|
|
840
894
|
* Sets the specific icon to display.
|
|
841
895
|
*/
|
|
@@ -1448,6 +1502,38 @@ export interface InlineProps {
|
|
|
1448
1502
|
*/
|
|
1449
1503
|
gap?: AllDistances;
|
|
1450
1504
|
}
|
|
1505
|
+
/**
|
|
1506
|
+
* The props type for {@link !components.AutoGrid}.
|
|
1507
|
+
*
|
|
1508
|
+
* @category Component Props
|
|
1509
|
+
*/
|
|
1510
|
+
export interface AutoGridProps {
|
|
1511
|
+
/**
|
|
1512
|
+
* Sets the width of each column in the grid.
|
|
1513
|
+
* When `flexible` is true, columns will be at least this width (or collapse to container width if smaller), then expand equally to fill available space.
|
|
1514
|
+
* When `flexible` is false, columns are exactly this width.
|
|
1515
|
+
*/
|
|
1516
|
+
columnWidth: number;
|
|
1517
|
+
/**
|
|
1518
|
+
* Sets the spacing between grid items.
|
|
1519
|
+
*
|
|
1520
|
+
* @defaultValue `"flush"`
|
|
1521
|
+
*/
|
|
1522
|
+
gap?: AllDistances;
|
|
1523
|
+
/**
|
|
1524
|
+
* Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components.
|
|
1525
|
+
*
|
|
1526
|
+
*/
|
|
1527
|
+
children?: ReactNode;
|
|
1528
|
+
/**
|
|
1529
|
+
* Whether columns should expand to fill available space.
|
|
1530
|
+
* When true, columns will be at least `columnWidth` but grow equally to fill the container.
|
|
1531
|
+
* When false, columns are exactly `columnWidth`.
|
|
1532
|
+
*
|
|
1533
|
+
* @defaultValue `false`
|
|
1534
|
+
*/
|
|
1535
|
+
flexible?: boolean;
|
|
1536
|
+
}
|
|
1451
1537
|
/**
|
|
1452
1538
|
* The props type for {@link !components.Link}.
|
|
1453
1539
|
*
|
|
@@ -1820,7 +1906,7 @@ export interface MultiSelectProps extends BaseSelectProps {
|
|
|
1820
1906
|
* The value of the select input.
|
|
1821
1907
|
*
|
|
1822
1908
|
*/
|
|
1823
|
-
value?: (string | number)[];
|
|
1909
|
+
value?: (string | number | boolean)[];
|
|
1824
1910
|
/**
|
|
1825
1911
|
* A callback function that is invoked when the value is committed.
|
|
1826
1912
|
*
|
|
@@ -1834,7 +1920,7 @@ export interface MultiSelectProps extends BaseSelectProps {
|
|
|
1834
1920
|
/** Will be used as the display text. **/
|
|
1835
1921
|
label: string;
|
|
1836
1922
|
/** Should be the option's unique identifier, which is submitted with the form. **/
|
|
1837
|
-
value: string | number;
|
|
1923
|
+
value: string | number | boolean;
|
|
1838
1924
|
}[];
|
|
1839
1925
|
}
|
|
1840
1926
|
/**
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/ui-extensions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,15 +24,12 @@
|
|
|
24
24
|
"exports": {
|
|
25
25
|
".": "./dist/index.js",
|
|
26
26
|
"./crm": "./dist/crm/index.js",
|
|
27
|
-
"./pages/home": "./dist/pages/home/
|
|
28
|
-
"./experimental": "./dist/experimental/index.js"
|
|
29
|
-
"./experimental/testing": "./dist/experimental/testing/index.js",
|
|
30
|
-
"./experimental/testing/jest-matchers": "./dist/experimental/testing/jest/matchers/index.js"
|
|
27
|
+
"./pages/home": "./dist/pages/home/index.js",
|
|
28
|
+
"./experimental": "./dist/experimental/index.js"
|
|
31
29
|
},
|
|
32
30
|
"license": "MIT",
|
|
33
31
|
"dependencies": {
|
|
34
32
|
"@remote-ui/react": "5.0.2",
|
|
35
|
-
"@remote-ui/testing": "1.4.3",
|
|
36
33
|
"react": "18.2.0"
|
|
37
34
|
},
|
|
38
35
|
"engines": {
|
|
@@ -72,5 +69,5 @@
|
|
|
72
69
|
"tsd": {
|
|
73
70
|
"directory": "src/__tests__/test-d"
|
|
74
71
|
},
|
|
75
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "aeebbd7fb6aefc9aeb948cc9ca4028e94d5320cc"
|
|
76
73
|
}
|
package/dist/crm/components.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createExtensionComponent } from '../utils/createExtensionComponent';
|
|
2
|
-
const CrmPropertyList = createExtensionComponent('CrmPropertyList');
|
|
3
|
-
const CrmAssociationTable = createExtensionComponent('CrmAssociationTable');
|
|
4
|
-
const CrmDataHighlight = createExtensionComponent('CrmDataHighlight');
|
|
5
|
-
const CrmReport = createExtensionComponent('CrmReport');
|
|
6
|
-
const CrmAssociationPivot = createExtensionComponent('CrmAssociationPivot');
|
|
7
|
-
const CrmAssociationPropertyList = createExtensionComponent('CrmAssociationPropertyList');
|
|
8
|
-
const CrmAssociationStageTracker = createExtensionComponent('CrmAssociationStageTracker');
|
|
9
|
-
const CrmSimpleDeadline = createExtensionComponent('CrmSimpleDeadline');
|
|
10
|
-
const CrmStageTracker = createExtensionComponent('CrmStageTracker');
|
|
11
|
-
const CrmStatistics = createExtensionComponent('CrmStatistics');
|
|
12
|
-
const CrmActionButton = createExtensionComponent('CrmActionButton');
|
|
13
|
-
const CrmActionLink = createExtensionComponent('CrmActionLink');
|
|
14
|
-
const CrmCardActions = createExtensionComponent('CrmCardActions');
|
|
15
|
-
export { CrmPropertyList, CrmAssociationTable, CrmDataHighlight, CrmReport, CrmAssociationPivot, CrmAssociationPropertyList, CrmAssociationStageTracker, CrmSimpleDeadline, CrmStageTracker, CrmStatistics, CrmActionButton, CrmActionLink, CrmCardActions, };
|
|
@@ -1,14 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { RemoteComponentType } from '@remote-ui/core';
|
|
2
|
-
import type { ReactComponentTypeFromRemoteComponentType } from '@remote-ui/react';
|
|
3
|
-
export declare function createExtensionComponent<ComponentType extends string, Props = Record<string, never>, AllowedChildren extends RemoteComponentType<string, any> | boolean = true>(componentType: ComponentType | RemoteComponentType<ComponentType, Props, AllowedChildren>): RemoteComponentType<ComponentType, Props, AllowedChildren> & ReactComponentTypeFromRemoteComponentType<RemoteComponentType<ComponentType, Props, AllowedChildren>>;
|