@elliemae/ds-global-header 2.2.1 → 2.3.0-alpha.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/cjs/GlobalHeader.js +55 -35
- package/cjs/GlobalHeader.js.map +7 -0
- package/cjs/GlobalHeaderContainer.js +40 -23
- package/cjs/GlobalHeaderContainer.js.map +7 -0
- package/cjs/GlobalHeaderContext.js +39 -13
- package/cjs/GlobalHeaderContext.js.map +7 -0
- package/cjs/GlobalHeaderTypes.js +27 -2
- package/cjs/GlobalHeaderTypes.js.map +7 -0
- package/cjs/components/Breadcrumb/GlobalHeaderBreadcrumb.js +59 -59
- package/cjs/components/Breadcrumb/GlobalHeaderBreadcrumb.js.map +7 -0
- package/cjs/components/Breadcrumb/PureBreadcrumb.js +50 -59
- package/cjs/components/Breadcrumb/PureBreadcrumb.js.map +7 -0
- package/cjs/components/Breadcrumb/styles.js +82 -58
- package/cjs/components/Breadcrumb/styles.js.map +7 -0
- package/cjs/components/Title/GlobalHeaderTitle.js +43 -24
- package/cjs/components/Title/GlobalHeaderTitle.js.map +7 -0
- package/cjs/components/Toolbar/GlobalHeaderToolbar.js +41 -22
- package/cjs/components/Toolbar/GlobalHeaderToolbar.js.map +7 -0
- package/cjs/components/Toolbar/ToolbarItems.js +83 -94
- package/cjs/components/Toolbar/ToolbarItems.js.map +7 -0
- package/cjs/components/Toolbar/styles.js +60 -24
- package/cjs/components/Toolbar/styles.js.map +7 -0
- package/cjs/config/useGetPropsWithDefaults.js +42 -30
- package/cjs/config/useGetPropsWithDefaults.js.map +7 -0
- package/cjs/config/useGlobalHeader.js +44 -30
- package/cjs/config/useGlobalHeader.js.map +7 -0
- package/cjs/config/useValidateProps.js +81 -64
- package/cjs/config/useValidateProps.js.map +7 -0
- package/cjs/config/validateHelpers.js +95 -41
- package/cjs/config/validateHelpers.js.map +7 -0
- package/cjs/defaultProps.js +34 -7
- package/cjs/defaultProps.js.map +7 -0
- package/cjs/index.js +36 -11
- package/cjs/index.js.map +7 -0
- package/cjs/outOfTheBox/AppPicker/AppPicker.js +83 -90
- package/cjs/outOfTheBox/AppPicker/AppPicker.js.map +7 -0
- package/cjs/outOfTheBox/PopupMenu/PopupMenu.js +70 -75
- package/cjs/outOfTheBox/PopupMenu/PopupMenu.js.map +7 -0
- package/cjs/outOfTheBox/PopupMenu/PopupMenuContent.js +76 -83
- package/cjs/outOfTheBox/PopupMenu/PopupMenuContent.js.map +7 -0
- package/cjs/outOfTheBox/PopupMenu/styles.js +66 -31
- package/cjs/outOfTheBox/PopupMenu/styles.js.map +7 -0
- package/cjs/outOfTheBox/SearchToggle/SearchToggle.js +80 -85
- package/cjs/outOfTheBox/SearchToggle/SearchToggle.js.map +7 -0
- package/cjs/outOfTheBox/SearchToggle/styles.js +76 -9
- package/cjs/outOfTheBox/SearchToggle/styles.js.map +7 -0
- package/cjs/outOfTheBox/index.js +30 -13
- package/cjs/outOfTheBox/index.js.map +7 -0
- package/cjs/propTypes.js +52 -25
- package/cjs/propTypes.js.map +7 -0
- package/cjs/styles.js +42 -20
- package/cjs/styles.js.map +7 -0
- package/esm/GlobalHeader.js +21 -21
- package/esm/GlobalHeader.js.map +7 -0
- package/esm/GlobalHeaderContainer.js +11 -15
- package/esm/GlobalHeaderContainer.js.map +7 -0
- package/esm/GlobalHeaderContext.js +9 -8
- package/esm/GlobalHeaderContext.js.map +7 -0
- package/esm/GlobalHeaderTypes.js +2 -1
- package/esm/GlobalHeaderTypes.js.map +7 -0
- package/esm/components/Breadcrumb/GlobalHeaderBreadcrumb.js +26 -45
- package/esm/components/Breadcrumb/GlobalHeaderBreadcrumb.js.map +7 -0
- package/esm/components/Breadcrumb/PureBreadcrumb.js +22 -49
- package/esm/components/Breadcrumb/PureBreadcrumb.js.map +7 -0
- package/esm/components/Breadcrumb/styles.js +54 -48
- package/esm/components/Breadcrumb/styles.js.map +7 -0
- package/esm/components/Title/GlobalHeaderTitle.js +13 -15
- package/esm/components/Title/GlobalHeaderTitle.js.map +7 -0
- package/esm/components/Toolbar/GlobalHeaderToolbar.js +12 -14
- package/esm/components/Toolbar/GlobalHeaderToolbar.js.map +7 -0
- package/esm/components/Toolbar/ToolbarItems.js +53 -83
- package/esm/components/Toolbar/ToolbarItems.js.map +7 -0
- package/esm/components/Toolbar/styles.js +32 -17
- package/esm/components/Toolbar/styles.js.map +7 -0
- package/esm/config/useGetPropsWithDefaults.js +13 -22
- package/esm/config/useGetPropsWithDefaults.js.map +7 -0
- package/esm/config/useGlobalHeader.js +12 -19
- package/esm/config/useGlobalHeader.js.map +7 -0
- package/esm/config/useValidateProps.js +58 -58
- package/esm/config/useValidateProps.js.map +7 -0
- package/esm/config/validateHelpers.js +66 -28
- package/esm/config/validateHelpers.js.map +7 -0
- package/esm/defaultProps.js +5 -3
- package/esm/defaultProps.js.map +7 -0
- package/esm/index.js +7 -1
- package/esm/index.js.map +7 -0
- package/esm/outOfTheBox/AppPicker/AppPicker.js +50 -76
- package/esm/outOfTheBox/AppPicker/AppPicker.js.map +7 -0
- package/esm/outOfTheBox/PopupMenu/PopupMenu.js +37 -61
- package/esm/outOfTheBox/PopupMenu/PopupMenu.js.map +7 -0
- package/esm/outOfTheBox/PopupMenu/PopupMenuContent.js +45 -71
- package/esm/outOfTheBox/PopupMenu/PopupMenuContent.js.map +7 -0
- package/esm/outOfTheBox/PopupMenu/styles.js +38 -21
- package/esm/outOfTheBox/PopupMenu/styles.js.map +7 -0
- package/esm/outOfTheBox/SearchToggle/SearchToggle.js +46 -70
- package/esm/outOfTheBox/SearchToggle/SearchToggle.js.map +7 -0
- package/esm/outOfTheBox/SearchToggle/styles.js +51 -5
- package/esm/outOfTheBox/SearchToggle/styles.js.map +7 -0
- package/esm/outOfTheBox/index.js +5 -3
- package/esm/outOfTheBox/index.js.map +7 -0
- package/esm/propTypes.js +21 -17
- package/esm/propTypes.js.map +7 -0
- package/esm/styles.js +14 -13
- package/esm/styles.js.map +7 -0
- package/package.json +7 -7
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
throwToolbarPopupItemError,
|
|
4
|
+
throwToolbarAppPickerItemError,
|
|
5
|
+
throwToolbarItemGenericError,
|
|
6
|
+
throwLogoError,
|
|
7
|
+
throwBreadcrumbItemError,
|
|
8
|
+
isValidToolbarType,
|
|
9
|
+
isObject
|
|
10
|
+
} from "./validateHelpers";
|
|
11
|
+
const validatePopupItem = (componentProps) => {
|
|
7
12
|
if (componentProps.options && !Array.isArray(componentProps.options)) {
|
|
8
|
-
throwToolbarPopupItemError(
|
|
13
|
+
throwToolbarPopupItemError("options", componentProps.options);
|
|
9
14
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
throwToolbarPopupItemError('closeOnClick', componentProps.closeOnClick);
|
|
15
|
+
if (componentProps.closeOnClick && typeof componentProps.closeOnClick !== "boolean") {
|
|
16
|
+
throwToolbarPopupItemError("closeOnClick", componentProps.closeOnClick);
|
|
13
17
|
}
|
|
14
18
|
};
|
|
15
|
-
|
|
16
|
-
const validateAppPickerItem = componentProps => {
|
|
19
|
+
const validateAppPickerItem = (componentProps) => {
|
|
17
20
|
if (componentProps.apps && !Array.isArray(componentProps.apps)) {
|
|
18
|
-
throwToolbarAppPickerItemError(
|
|
21
|
+
throwToolbarAppPickerItemError("apps", componentProps.apps);
|
|
19
22
|
}
|
|
20
|
-
|
|
21
23
|
if (componentProps.customApps && !Array.isArray(componentProps.customApps)) {
|
|
22
|
-
throwToolbarAppPickerItemError(
|
|
24
|
+
throwToolbarAppPickerItemError("customApps", componentProps.customApps);
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
throwToolbarAppPickerItemError('sectionTitle', componentProps.sectionTitle);
|
|
26
|
+
if (componentProps.sectionTitle && typeof componentProps.sectionTitle !== "string") {
|
|
27
|
+
throwToolbarAppPickerItemError("sectionTitle", componentProps.sectionTitle);
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
throwToolbarAppPickerItemError('customSectionTitle', componentProps.customSectionTitle);
|
|
29
|
+
if (componentProps.customSectionTitle && typeof componentProps.customSectionTitle !== "string") {
|
|
30
|
+
throwToolbarAppPickerItemError("customSectionTitle", componentProps.customSectionTitle);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
breadcrumb,
|
|
37
|
-
toolbar,
|
|
38
|
-
Logo,
|
|
39
|
-
LogoWithBrand
|
|
40
|
-
} = props;
|
|
41
|
-
|
|
42
|
-
if (Logo && typeof Logo !== 'function') {
|
|
43
|
-
throwLogoError('Logo', Logo);
|
|
33
|
+
const validateGenericToolbarItem = (item) => {
|
|
34
|
+
if (item.label && typeof item.label !== "string") {
|
|
35
|
+
throwToolbarItemGenericError("label", item.label);
|
|
44
36
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
throwLogoError('LogoWithBrand', LogoWithBrand);
|
|
37
|
+
if (item.onClick && typeof item.onClick !== "function") {
|
|
38
|
+
throwToolbarItemGenericError("onClick", item.onClick);
|
|
48
39
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
if (item.Icon && typeof item.Icon !== "function") {
|
|
41
|
+
if (item.type === "ds-app-picker")
|
|
42
|
+
return;
|
|
43
|
+
throwToolbarItemGenericError("Icon", item.Icon);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const useValidateProps = (props) => {
|
|
47
|
+
const { breadcrumb, toolbar, Logo, LogoWithBrand } = props;
|
|
48
|
+
if (Logo && typeof Logo !== "function") {
|
|
49
|
+
throwLogoError("Logo", Logo);
|
|
50
|
+
}
|
|
51
|
+
if (LogoWithBrand && typeof LogoWithBrand !== "function") {
|
|
52
|
+
throwLogoError("LogoWithBrand", LogoWithBrand);
|
|
53
|
+
}
|
|
54
|
+
breadcrumb?.forEach((breadcrumbItem) => {
|
|
55
|
+
if (breadcrumbItem.label && typeof breadcrumbItem.label !== "string") {
|
|
56
|
+
throwBreadcrumbItemError("label", breadcrumbItem.label);
|
|
53
57
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
throwBreadcrumbItemError('onClick', breadcrumbItem.onClick);
|
|
58
|
+
if (breadcrumbItem.onClick && typeof breadcrumbItem.onClick !== "function") {
|
|
59
|
+
throwBreadcrumbItemError("onClick", breadcrumbItem.onClick);
|
|
57
60
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
throwBreadcrumbItemError('hasNext', breadcrumbItem.hasNext);
|
|
61
|
+
if (breadcrumbItem.hasNext && typeof breadcrumbItem.hasNext !== "boolean") {
|
|
62
|
+
throwBreadcrumbItemError("hasNext", breadcrumbItem.hasNext);
|
|
61
63
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
throwBreadcrumbItemError('isSelected', breadcrumbItem.isSelected);
|
|
64
|
+
if (breadcrumbItem.isSelected && typeof breadcrumbItem.isSelected !== "boolean") {
|
|
65
|
+
throwBreadcrumbItemError("isSelected", breadcrumbItem.isSelected);
|
|
65
66
|
}
|
|
66
67
|
});
|
|
67
|
-
toolbar
|
|
68
|
+
toolbar?.forEach((toolbarItem) => {
|
|
68
69
|
if (toolbarItem.type) {
|
|
69
70
|
if (!isValidToolbarType(toolbarItem.type)) {
|
|
70
|
-
throwToolbarItemGenericError(
|
|
71
|
+
throwToolbarItemGenericError("type", toolbarItem.type);
|
|
71
72
|
}
|
|
72
|
-
|
|
73
73
|
if (toolbarItem.componentProps && !isObject(toolbarItem.componentProps)) {
|
|
74
|
-
throwToolbarItemGenericError(
|
|
74
|
+
throwToolbarItemGenericError("componentProps", toolbarItem.componentProps);
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
if (toolbarItem.type === 'ds-popup-menu') {
|
|
76
|
+
if (toolbarItem.type === "ds-popup-menu") {
|
|
78
77
|
validatePopupItem(toolbarItem.componentProps);
|
|
79
78
|
}
|
|
80
|
-
|
|
81
|
-
if (toolbarItem.type === 'ds-app-picker') {
|
|
79
|
+
if (toolbarItem.type === "ds-app-picker") {
|
|
82
80
|
validateAppPickerItem(toolbarItem.componentProps);
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
});
|
|
86
84
|
};
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
export {
|
|
86
|
+
useValidateProps
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=useValidateProps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useValidateProps.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { AppPickerProps, GlobalHeaderPropsT, PopupPropsT, ToolbarItemT } from '../GlobalHeaderTypes';\nimport {\n throwToolbarPopupItemError,\n throwToolbarAppPickerItemError,\n throwToolbarItemGenericError,\n throwLogoError,\n throwBreadcrumbItemError,\n isValidToolbarType,\n isObject,\n} from './validateHelpers';\n\nconst validatePopupItem = (componentProps: PopupPropsT): void => {\n if (componentProps.options && !Array.isArray(componentProps.options)) {\n throwToolbarPopupItemError('options', componentProps.options);\n }\n if (componentProps.closeOnClick && typeof componentProps.closeOnClick !== 'boolean') {\n throwToolbarPopupItemError('closeOnClick', componentProps.closeOnClick);\n }\n};\n\nconst validateAppPickerItem = (componentProps: AppPickerProps): void => {\n if (componentProps.apps && !Array.isArray(componentProps.apps)) {\n throwToolbarAppPickerItemError('apps', componentProps.apps);\n }\n if (componentProps.customApps && !Array.isArray(componentProps.customApps)) {\n throwToolbarAppPickerItemError('customApps', componentProps.customApps);\n }\n if (componentProps.sectionTitle && typeof componentProps.sectionTitle !== 'string') {\n throwToolbarAppPickerItemError('sectionTitle', componentProps.sectionTitle);\n }\n if (componentProps.customSectionTitle && typeof componentProps.customSectionTitle !== 'string') {\n throwToolbarAppPickerItemError('customSectionTitle', componentProps.customSectionTitle);\n }\n};\n\nconst validateGenericToolbarItem = (item: ToolbarItemT): void => {\n if (item.label && typeof item.label !== 'string') {\n throwToolbarItemGenericError('label', item.label);\n }\n if (item.onClick && typeof item.onClick !== 'function') {\n throwToolbarItemGenericError('onClick', item.onClick);\n }\n if (item.Icon && typeof item.Icon !== 'function') {\n if (item.type === 'ds-app-picker') return;\n throwToolbarItemGenericError('Icon', item.Icon);\n }\n};\n\nexport const useValidateProps = (props: GlobalHeaderPropsT): void => {\n const { breadcrumb, toolbar, Logo, LogoWithBrand } = props;\n\n if (Logo && typeof Logo !== 'function') {\n throwLogoError('Logo', Logo);\n }\n\n if (LogoWithBrand && typeof LogoWithBrand !== 'function') {\n throwLogoError('LogoWithBrand', LogoWithBrand);\n }\n\n breadcrumb?.forEach((breadcrumbItem) => {\n if (breadcrumbItem.label && typeof breadcrumbItem.label !== 'string') {\n throwBreadcrumbItemError('label', breadcrumbItem.label);\n }\n if (breadcrumbItem.onClick && typeof breadcrumbItem.onClick !== 'function') {\n throwBreadcrumbItemError('onClick', breadcrumbItem.onClick);\n }\n if (breadcrumbItem.hasNext && typeof breadcrumbItem.hasNext !== 'boolean') {\n throwBreadcrumbItemError('hasNext', breadcrumbItem.hasNext);\n }\n if (breadcrumbItem.isSelected && typeof breadcrumbItem.isSelected !== 'boolean') {\n throwBreadcrumbItemError('isSelected', breadcrumbItem.isSelected);\n }\n });\n\n toolbar?.forEach((toolbarItem) => {\n if (toolbarItem.type) {\n if (!isValidToolbarType(toolbarItem.type)) {\n throwToolbarItemGenericError('type', toolbarItem.type);\n }\n if (toolbarItem.componentProps && !isObject(toolbarItem.componentProps)) {\n throwToolbarItemGenericError('componentProps', toolbarItem.componentProps);\n }\n if (toolbarItem.type === 'ds-popup-menu') {\n validatePopupItem(toolbarItem.componentProps as PopupPropsT);\n }\n if (toolbarItem.type === 'ds-app-picker') {\n validateAppPickerItem(toolbarItem.componentProps as AppPickerProps);\n }\n }\n });\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,MAAM,oBAAoB,CAAC,mBAAsC;AAC/D,MAAI,eAAe,WAAW,CAAC,MAAM,QAAQ,eAAe,UAAU;AACpE,+BAA2B,WAAW,eAAe;AAAA;AAEvD,MAAI,eAAe,gBAAgB,OAAO,eAAe,iBAAiB,WAAW;AACnF,+BAA2B,gBAAgB,eAAe;AAAA;AAAA;AAI9D,MAAM,wBAAwB,CAAC,mBAAyC;AACtE,MAAI,eAAe,QAAQ,CAAC,MAAM,QAAQ,eAAe,OAAO;AAC9D,mCAA+B,QAAQ,eAAe;AAAA;AAExD,MAAI,eAAe,cAAc,CAAC,MAAM,QAAQ,eAAe,aAAa;AAC1E,mCAA+B,cAAc,eAAe;AAAA;AAE9D,MAAI,eAAe,gBAAgB,OAAO,eAAe,iBAAiB,UAAU;AAClF,mCAA+B,gBAAgB,eAAe;AAAA;AAEhE,MAAI,eAAe,sBAAsB,OAAO,eAAe,uBAAuB,UAAU;AAC9F,mCAA+B,sBAAsB,eAAe;AAAA;AAAA;AAIxE,MAAM,6BAA6B,CAAC,SAA6B;AAC/D,MAAI,KAAK,SAAS,OAAO,KAAK,UAAU,UAAU;AAChD,iCAA6B,SAAS,KAAK;AAAA;AAE7C,MAAI,KAAK,WAAW,OAAO,KAAK,YAAY,YAAY;AACtD,iCAA6B,WAAW,KAAK;AAAA;AAE/C,MAAI,KAAK,QAAQ,OAAO,KAAK,SAAS,YAAY;AAChD,QAAI,KAAK,SAAS;AAAiB;AACnC,iCAA6B,QAAQ,KAAK;AAAA;AAAA;AAIvC,MAAM,mBAAmB,CAAC,UAAoC;AACnE,QAAM,EAAE,YAAY,SAAS,MAAM,kBAAkB;AAErD,MAAI,QAAQ,OAAO,SAAS,YAAY;AACtC,mBAAe,QAAQ;AAAA;AAGzB,MAAI,iBAAiB,OAAO,kBAAkB,YAAY;AACxD,mBAAe,iBAAiB;AAAA;AAGlC,cAAY,QAAQ,CAAC,mBAAmB;AACtC,QAAI,eAAe,SAAS,OAAO,eAAe,UAAU,UAAU;AACpE,+BAAyB,SAAS,eAAe;AAAA;AAEnD,QAAI,eAAe,WAAW,OAAO,eAAe,YAAY,YAAY;AAC1E,+BAAyB,WAAW,eAAe;AAAA;AAErD,QAAI,eAAe,WAAW,OAAO,eAAe,YAAY,WAAW;AACzE,+BAAyB,WAAW,eAAe;AAAA;AAErD,QAAI,eAAe,cAAc,OAAO,eAAe,eAAe,WAAW;AAC/E,+BAAyB,cAAc,eAAe;AAAA;AAAA;AAI1D,WAAS,QAAQ,CAAC,gBAAgB;AAChC,QAAI,YAAY,MAAM;AACpB,UAAI,CAAC,mBAAmB,YAAY,OAAO;AACzC,qCAA6B,QAAQ,YAAY;AAAA;AAEnD,UAAI,YAAY,kBAAkB,CAAC,SAAS,YAAY,iBAAiB;AACvE,qCAA6B,kBAAkB,YAAY;AAAA;AAE7D,UAAI,YAAY,SAAS,iBAAiB;AACxC,0BAAkB,YAAY;AAAA;AAEhC,UAAI,YAAY,SAAS,iBAAiB;AACxC,8BAAsB,YAAY;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,44 +1,82 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
const breadcrumbProps = {
|
|
2
|
-
label:
|
|
3
|
-
onClick:
|
|
4
|
-
hasNext:
|
|
5
|
-
isSelected:
|
|
3
|
+
label: "string",
|
|
4
|
+
onClick: "function",
|
|
5
|
+
hasNext: "boolean",
|
|
6
|
+
isSelected: "boolean"
|
|
6
7
|
};
|
|
7
8
|
const toolbarProps = {
|
|
8
|
-
label:
|
|
9
|
+
label: "string",
|
|
9
10
|
type: '"ds-app-picker" or "ds-popup-menu" or "ds-search-toggle"',
|
|
10
|
-
componentProps:
|
|
11
|
-
Icon:
|
|
12
|
-
onClick:
|
|
13
|
-
options:
|
|
14
|
-
closeOnClick:
|
|
15
|
-
apps:
|
|
16
|
-
customApps:
|
|
17
|
-
sectionTitle:
|
|
18
|
-
customSectionTitle:
|
|
19
|
-
};
|
|
20
|
-
const isObject = obj => typeof obj ===
|
|
21
|
-
const getVariableType = arg => {
|
|
22
|
-
if (Array.isArray(arg))
|
|
23
|
-
|
|
24
|
-
if (arg ===
|
|
11
|
+
componentProps: "object",
|
|
12
|
+
Icon: "react component",
|
|
13
|
+
onClick: "function",
|
|
14
|
+
options: "array",
|
|
15
|
+
closeOnClick: "boolean",
|
|
16
|
+
apps: "array",
|
|
17
|
+
customApps: "array",
|
|
18
|
+
sectionTitle: "string",
|
|
19
|
+
customSectionTitle: "string"
|
|
20
|
+
};
|
|
21
|
+
const isObject = (obj) => typeof obj === "object" && !!obj && !Array.isArray(obj);
|
|
22
|
+
const getVariableType = (arg) => {
|
|
23
|
+
if (Array.isArray(arg))
|
|
24
|
+
return "array";
|
|
25
|
+
if (arg === null)
|
|
26
|
+
return "null";
|
|
27
|
+
if (arg === void 0)
|
|
28
|
+
return "undefined";
|
|
25
29
|
return typeof arg;
|
|
26
30
|
};
|
|
27
|
-
const isValidToolbarType = string => string ===
|
|
31
|
+
const isValidToolbarType = (string) => string === "ds-app-picker" || string === "ds-popup-menu" || string === "ds-search-toggle" || string === "custom";
|
|
28
32
|
const throwBreadcrumbItemError = (validPropKey, invalidProp) => {
|
|
29
|
-
throw new Error(
|
|
33
|
+
throw new Error(`You are trying to pass a not valid "${validPropKey}" property for a breadcrumb item, please provide a valid type.
|
|
34
|
+
|
|
35
|
+
Received: ${invalidProp} (${typeof invalidProp})
|
|
36
|
+
Expected: (${breadcrumbProps[validPropKey]})
|
|
37
|
+
`);
|
|
30
38
|
};
|
|
31
39
|
const throwToolbarPopupItemError = (validPropKey, invalidProp) => {
|
|
32
|
-
throw new Error(
|
|
40
|
+
throw new Error(`You are trying to pass a not valid "${validPropKey}" property inside componentProps for a ds-popup-menu
|
|
41
|
+
toolbar item, please provide a valid type.
|
|
42
|
+
|
|
43
|
+
Received: ${invalidProp} (${getVariableType(invalidProp)})
|
|
44
|
+
Expected: (${toolbarProps[validPropKey]})
|
|
45
|
+
`);
|
|
33
46
|
};
|
|
34
47
|
const throwToolbarAppPickerItemError = (validPropKey, invalidProp) => {
|
|
35
|
-
throw new Error(
|
|
48
|
+
throw new Error(`You are trying to pass a not valid "${validPropKey}" property inside componentProps for a ds-app-picker
|
|
49
|
+
toolbar item, please provide a valid type.
|
|
50
|
+
|
|
51
|
+
Received: ${invalidProp} (${getVariableType(invalidProp)})
|
|
52
|
+
Expected: (${toolbarProps[validPropKey]})
|
|
53
|
+
`);
|
|
36
54
|
};
|
|
37
55
|
const throwToolbarItemGenericError = (validPropKey, invalidProp) => {
|
|
38
|
-
throw new Error(
|
|
56
|
+
throw new Error(`You are trying to pass a not valid "${validPropKey}" property for a toolbar item, please provide a valid type.
|
|
57
|
+
|
|
58
|
+
Received: ${invalidProp} (${getVariableType(invalidProp)})
|
|
59
|
+
Expected: (${toolbarProps[validPropKey]})
|
|
60
|
+
`);
|
|
39
61
|
};
|
|
40
62
|
const throwLogoError = (validPropKey, invalidProp) => {
|
|
41
|
-
throw new Error(
|
|
42
|
-
|
|
63
|
+
throw new Error(`You are trying to pass a not valid "${validPropKey}" property for a global header,
|
|
64
|
+
remember to provide both Logo and LogoWithBrand properties with a valid type.
|
|
43
65
|
|
|
44
|
-
|
|
66
|
+
Received: ${invalidProp} (${getVariableType(invalidProp)}).
|
|
67
|
+
Expected: (react component).
|
|
68
|
+
`);
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
breadcrumbProps,
|
|
72
|
+
getVariableType,
|
|
73
|
+
isObject,
|
|
74
|
+
isValidToolbarType,
|
|
75
|
+
throwBreadcrumbItemError,
|
|
76
|
+
throwLogoError,
|
|
77
|
+
throwToolbarAppPickerItemError,
|
|
78
|
+
throwToolbarItemGenericError,
|
|
79
|
+
throwToolbarPopupItemError,
|
|
80
|
+
toolbarProps
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=validateHelpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/validateHelpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const breadcrumbProps = {\n label: 'string',\n onClick: 'function',\n hasNext: 'boolean',\n isSelected: 'boolean',\n};\n\nexport const toolbarProps = {\n label: 'string',\n type: '\"ds-app-picker\" or \"ds-popup-menu\" or \"ds-search-toggle\"',\n componentProps: 'object',\n Icon: 'react component',\n onClick: 'function',\n options: 'array',\n closeOnClick: 'boolean',\n apps: 'array',\n customApps: 'array',\n sectionTitle: 'string',\n customSectionTitle: 'string',\n};\n\nexport const isObject = (obj: unknown): boolean => typeof obj === 'object' && !!obj && !Array.isArray(obj);\n\nexport const getVariableType = (arg: unknown): string => {\n if (Array.isArray(arg)) return 'array';\n if (arg === null) return 'null';\n if (arg === undefined) return 'undefined';\n return typeof arg;\n};\n\nexport const isValidToolbarType = (string: unknown): boolean =>\n string === 'ds-app-picker' || string === 'ds-popup-menu' || string === 'ds-search-toggle' || string === 'custom';\n\nexport const throwBreadcrumbItemError = (validPropKey: keyof typeof breadcrumbProps, invalidProp: unknown): void => {\n throw new Error(\n `You are trying to pass a not valid \"${validPropKey}\" property for a breadcrumb item, please provide a valid type.\n\n Received: ${invalidProp} (${typeof invalidProp})\n Expected: (${breadcrumbProps[validPropKey]})\n `,\n );\n};\n\nexport const throwToolbarPopupItemError = (validPropKey: keyof typeof toolbarProps, invalidProp: unknown): void => {\n throw new Error(\n `You are trying to pass a not valid \"${validPropKey}\" property inside componentProps for a ds-popup-menu \n toolbar item, please provide a valid type.\n\n Received: ${invalidProp} (${getVariableType(invalidProp)})\n Expected: (${toolbarProps[validPropKey]})\n `,\n );\n};\n\nexport const throwToolbarAppPickerItemError = (validPropKey: keyof typeof toolbarProps, invalidProp: unknown): void => {\n throw new Error(\n `You are trying to pass a not valid \"${validPropKey}\" property inside componentProps for a ds-app-picker \n toolbar item, please provide a valid type.\n\n Received: ${invalidProp} (${getVariableType(invalidProp)})\n Expected: (${toolbarProps[validPropKey]})\n `,\n );\n};\n\nexport const throwToolbarItemGenericError = (validPropKey: keyof typeof toolbarProps, invalidProp: unknown): void => {\n throw new Error(\n `You are trying to pass a not valid \"${validPropKey}\" property for a toolbar item, please provide a valid type.\n\n Received: ${invalidProp} (${getVariableType(invalidProp)})\n Expected: (${toolbarProps[validPropKey]})\n `,\n );\n};\n\nexport const throwLogoError = (validPropKey: string, invalidProp: unknown): void => {\n throw new Error(\n `You are trying to pass a not valid \"${validPropKey}\" property for a global header, \n remember to provide both Logo and LogoWithBrand properties with a valid type.\n\n Received: ${invalidProp} (${getVariableType(invalidProp)}).\n Expected: (react component).\n `,\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAO,MAAM,kBAAkB;AAAA,EAC7B,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA;AAGP,MAAM,eAAe;AAAA,EAC1B,OAAO;AAAA,EACP,MAAM;AAAA,EACN,gBAAgB;AAAA,EAChB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,cAAc;AAAA,EACd,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,oBAAoB;AAAA;AAGf,MAAM,WAAW,CAAC,QAA0B,OAAO,QAAQ,YAAY,CAAC,CAAC,OAAO,CAAC,MAAM,QAAQ;AAE/F,MAAM,kBAAkB,CAAC,QAAyB;AACvD,MAAI,MAAM,QAAQ;AAAM,WAAO;AAC/B,MAAI,QAAQ;AAAM,WAAO;AACzB,MAAI,QAAQ;AAAW,WAAO;AAC9B,SAAO,OAAO;AAAA;AAGT,MAAM,qBAAqB,CAAC,WACjC,WAAW,mBAAmB,WAAW,mBAAmB,WAAW,sBAAsB,WAAW;AAEnG,MAAM,2BAA2B,CAAC,cAA4C,gBAA+B;AAClH,QAAM,IAAI,MACR,uCAAuC;AAAA;AAAA,cAE7B,gBAAgB,OAAO;AAAA,eACtB,gBAAgB;AAAA;AAAA;AAKxB,MAAM,6BAA6B,CAAC,cAAyC,gBAA+B;AACjH,QAAM,IAAI,MACR,uCAAuC;AAAA;AAAA;AAAA,cAG7B,gBAAgB,gBAAgB;AAAA,eAC/B,aAAa;AAAA;AAAA;AAKrB,MAAM,iCAAiC,CAAC,cAAyC,gBAA+B;AACrH,QAAM,IAAI,MACR,uCAAuC;AAAA;AAAA;AAAA,cAG7B,gBAAgB,gBAAgB;AAAA,eAC/B,aAAa;AAAA;AAAA;AAKrB,MAAM,+BAA+B,CAAC,cAAyC,gBAA+B;AACnH,QAAM,IAAI,MACR,uCAAuC;AAAA;AAAA,cAE7B,gBAAgB,gBAAgB;AAAA,eAC/B,aAAa;AAAA;AAAA;AAKrB,MAAM,iBAAiB,CAAC,cAAsB,gBAA+B;AAClF,QAAM,IAAI,MACR,uCAAuC;AAAA;AAAA;AAAA,cAG7B,gBAAgB,gBAAgB;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/defaultProps.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
const emptyComp = () => null;
|
|
2
|
-
|
|
3
3
|
const defaultProps = {
|
|
4
4
|
breadcrumb: [],
|
|
5
5
|
toolbar: [],
|
|
6
6
|
LogoWithBrand: emptyComp,
|
|
7
7
|
Logo: emptyComp
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
export {
|
|
10
|
+
defaultProps
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=defaultProps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/defaultProps.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { GlobalHeaderPropsT } from './GlobalHeaderTypes';\n\nconst emptyComp = () => null;\n\nexport const defaultProps: GlobalHeaderPropsT = {\n breadcrumb: [],\n toolbar: [],\n LogoWithBrand: emptyComp,\n Logo: emptyComp,\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACEA,MAAM,YAAY,MAAM;AAEjB,MAAM,eAAmC;AAAA,EAC9C,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,eAAe;AAAA,EACf,MAAM;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/index.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export * from "./GlobalHeader";
|
|
3
|
+
import { GlobalHeader } from "./GlobalHeader";
|
|
4
|
+
export {
|
|
5
|
+
GlobalHeader as default
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './GlobalHeader';\nexport { GlobalHeader as default } from './GlobalHeader';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,35 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { Button } from '../../components/Toolbar/styles.js';
|
|
15
|
-
import { getDataProps } from '@elliemae/ds-props-helpers';
|
|
16
|
-
import { jsx } from 'react/jsx-runtime';
|
|
17
|
-
|
|
18
|
-
var _MenuPicker;
|
|
19
|
-
|
|
20
|
-
const _excluded = ["label", "id", "componentProps"];
|
|
21
|
-
|
|
22
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
-
|
|
24
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
-
const AppPicker = _ref => {
|
|
26
|
-
let {
|
|
27
|
-
label,
|
|
28
|
-
id,
|
|
29
|
-
componentProps
|
|
30
|
-
} = _ref,
|
|
31
|
-
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useState, useRef, useCallback, useMemo } from "react";
|
|
3
|
+
import { DSAppPicker } from "@elliemae/ds-app-picker";
|
|
4
|
+
import { mergeRefs } from "@elliemae/ds-utilities";
|
|
5
|
+
import { MenuPicker } from "@elliemae/ds-icons";
|
|
6
|
+
import { getDataProps } from "@elliemae/ds-props-helpers";
|
|
7
|
+
import { Button } from "../../components/Toolbar/styles";
|
|
8
|
+
const AppPicker = ({
|
|
9
|
+
label,
|
|
10
|
+
id,
|
|
11
|
+
componentProps,
|
|
12
|
+
...otherProps
|
|
13
|
+
}) => {
|
|
33
14
|
const [isOpen, setIsOpen] = useState(false);
|
|
34
15
|
const buttonRef = useRef(null);
|
|
35
16
|
const {
|
|
@@ -47,17 +28,15 @@ const AppPicker = _ref => {
|
|
|
47
28
|
triggerRef,
|
|
48
29
|
triggerOnClick
|
|
49
30
|
} = componentProps;
|
|
50
|
-
const handleTriggerKeyDown = useCallback(e => {
|
|
51
|
-
if (e.code ===
|
|
31
|
+
const handleTriggerKeyDown = useCallback((e) => {
|
|
32
|
+
if (e.code === "Enter" || e.code === "Space") {
|
|
52
33
|
setIsOpen(true);
|
|
53
34
|
}
|
|
54
35
|
}, []);
|
|
55
|
-
const handleAppPickerOnKeyDown = useCallback(e => {
|
|
56
|
-
if (e.code ===
|
|
57
|
-
var _buttonRef$current;
|
|
58
|
-
|
|
36
|
+
const handleAppPickerOnKeyDown = useCallback((e) => {
|
|
37
|
+
if (e.code === "Escape") {
|
|
59
38
|
setIsOpen(false);
|
|
60
|
-
buttonRef
|
|
39
|
+
buttonRef?.current?.focus();
|
|
61
40
|
}
|
|
62
41
|
}, []);
|
|
63
42
|
const handleOnClickOutside = useCallback(() => {
|
|
@@ -66,42 +45,37 @@ const AppPicker = _ref => {
|
|
|
66
45
|
const handleOnClick = useCallback(() => {
|
|
67
46
|
setIsOpen(true);
|
|
68
47
|
}, []);
|
|
69
|
-
const renderTrigger = useMemo(() =>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
onKeyDown: userOnKeyDown !== null && userOnKeyDown !== void 0 ? userOnKeyDown : handleAppPickerOnKeyDown,
|
|
98
|
-
actionRef: actionRef,
|
|
99
|
-
onClickOutside: userOnClickOutside !== null && userOnClickOutside !== void 0 ? userOnClickOutside : handleOnClickOutside,
|
|
100
|
-
renderTrigger: userRenderTrigger !== null && userRenderTrigger !== void 0 ? userRenderTrigger : renderTrigger,
|
|
101
|
-
isOpen: userIsOpen !== null && userIsOpen !== void 0 ? userIsOpen : isOpen,
|
|
102
|
-
onClose: onClose,
|
|
103
|
-
triggerRef: triggerRef
|
|
48
|
+
const renderTrigger = useMemo(() => ({ ref }) => /* @__PURE__ */ React2.createElement("div", {
|
|
49
|
+
ref
|
|
50
|
+
}, /* @__PURE__ */ React2.createElement(Button, {
|
|
51
|
+
onClick: triggerOnClick ?? handleOnClick,
|
|
52
|
+
onKeyDown: handleTriggerKeyDown,
|
|
53
|
+
ref: mergeRefs(buttonRef, triggerRef),
|
|
54
|
+
title: label,
|
|
55
|
+
"data-testid": "gh-toolbar-item",
|
|
56
|
+
id,
|
|
57
|
+
...getDataProps(otherProps)
|
|
58
|
+
}, /* @__PURE__ */ React2.createElement(MenuPicker, {
|
|
59
|
+
fill: "#FFF",
|
|
60
|
+
width: 20.73,
|
|
61
|
+
height: 20.73
|
|
62
|
+
}))), [triggerOnClick, handleOnClick, handleTriggerKeyDown, triggerRef, label, id, otherProps]);
|
|
63
|
+
return /* @__PURE__ */ React2.createElement(DSAppPicker, {
|
|
64
|
+
apps,
|
|
65
|
+
customApps,
|
|
66
|
+
sectionTitle,
|
|
67
|
+
customSectionTitle,
|
|
68
|
+
icon,
|
|
69
|
+
onKeyDown: userOnKeyDown ?? handleAppPickerOnKeyDown,
|
|
70
|
+
actionRef,
|
|
71
|
+
onClickOutside: userOnClickOutside ?? handleOnClickOutside,
|
|
72
|
+
renderTrigger: userRenderTrigger ?? renderTrigger,
|
|
73
|
+
isOpen: userIsOpen ?? isOpen,
|
|
74
|
+
onClose,
|
|
75
|
+
triggerRef
|
|
104
76
|
});
|
|
105
77
|
};
|
|
106
|
-
|
|
107
|
-
|
|
78
|
+
export {
|
|
79
|
+
AppPicker
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=AppPicker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/outOfTheBox/AppPicker/AppPicker.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useRef, useCallback, useMemo } from 'react';\nimport { DSAppPicker } from '@elliemae/ds-app-picker';\nimport { mergeRefs } from '@elliemae/ds-utilities';\nimport { MenuPicker } from '@elliemae/ds-icons';\nimport { getDataProps } from '@elliemae/ds-props-helpers';\nimport { Button } from '../../components/Toolbar/styles';\n\ntype AppPickerProps = React.ComponentProps<typeof DSAppPicker>;\n\nexport const AppPicker = ({\n label,\n id,\n componentProps,\n ...otherProps\n}: AppPickerProps & {\n label: string;\n triggerOnClick?: React.MouseEventHandler;\n}): JSX.Element => {\n const [isOpen, setIsOpen] = useState<boolean>(false);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n const {\n apps,\n icon,\n customApps,\n sectionTitle,\n customSectionTitle,\n actionRef,\n isOpen: userIsOpen,\n onKeyDown: userOnKeyDown,\n onClickOutside: userOnClickOutside,\n renderTrigger: userRenderTrigger,\n onClose,\n triggerRef,\n triggerOnClick,\n } = componentProps;\n\n const handleTriggerKeyDown: React.KeyboardEventHandler = useCallback((e) => {\n if (e.code === 'Enter' || e.code === 'Space') {\n setIsOpen(true);\n }\n }, []);\n\n const handleAppPickerOnKeyDown: AppPickerProps['onKeyDown'] = useCallback((e) => {\n if (e.code === 'Escape') {\n setIsOpen(false);\n buttonRef?.current?.focus();\n }\n }, []);\n\n const handleOnClickOutside: AppPickerProps['onClickOutside'] = useCallback(() => {\n setIsOpen(false);\n }, []);\n\n const handleOnClick: React.MouseEventHandler = useCallback(() => {\n setIsOpen(true);\n }, []);\n\n const renderTrigger: AppPickerProps['renderTrigger'] = useMemo(\n () =>\n ({ ref }) =>\n (\n <div ref={ref}>\n <Button\n onClick={triggerOnClick ?? handleOnClick}\n onKeyDown={handleTriggerKeyDown}\n ref={mergeRefs(buttonRef, triggerRef)}\n title={label}\n data-testid=\"gh-toolbar-item\"\n id={id}\n {...getDataProps(otherProps)}\n >\n <MenuPicker fill=\"#FFF\" width={20.73} height={20.73} />\n </Button>\n </div>\n ),\n [triggerOnClick, handleOnClick, handleTriggerKeyDown, triggerRef, label, id, otherProps],\n );\n\n return (\n <DSAppPicker\n apps={apps}\n customApps={customApps}\n sectionTitle={sectionTitle}\n customSectionTitle={customSectionTitle}\n icon={icon}\n onKeyDown={userOnKeyDown ?? handleAppPickerOnKeyDown}\n actionRef={actionRef}\n onClickOutside={userOnClickOutside ?? handleOnClickOutside}\n renderTrigger={userRenderTrigger ?? renderTrigger}\n isOpen={userIsOpen ?? isOpen}\n onClose={onClose}\n triggerRef={triggerRef}\n />\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AAIO,MAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,KACG;AAAA,MAIc;AACjB,QAAM,CAAC,QAAQ,aAAa,SAAkB;AAC9C,QAAM,YAAY,OAA0B;AAE5C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE;AAEJ,QAAM,uBAAmD,YAAY,CAAC,MAAM;AAC1E,QAAI,EAAE,SAAS,WAAW,EAAE,SAAS,SAAS;AAC5C,gBAAU;AAAA;AAAA,KAEX;AAEH,QAAM,2BAAwD,YAAY,CAAC,MAAM;AAC/E,QAAI,EAAE,SAAS,UAAU;AACvB,gBAAU;AACV,iBAAW,SAAS;AAAA;AAAA,KAErB;AAEH,QAAM,uBAAyD,YAAY,MAAM;AAC/E,cAAU;AAAA,KACT;AAEH,QAAM,gBAAyC,YAAY,MAAM;AAC/D,cAAU;AAAA,KACT;AAEH,QAAM,gBAAiD,QACrD,MACE,CAAC,EAAE,UAEC,qCAAC,OAAD;AAAA,IAAK;AAAA,KACH,qCAAC,QAAD;AAAA,IACE,SAAS,kBAAkB;AAAA,IAC3B,WAAW;AAAA,IACX,KAAK,UAAU,WAAW;AAAA,IAC1B,OAAO;AAAA,IACP,eAAY;AAAA,IACZ;AAAA,OACI,aAAa;AAAA,KAEjB,qCAAC,YAAD;AAAA,IAAY,MAAK;AAAA,IAAO,OAAO;AAAA,IAAO,QAAQ;AAAA,QAIxD,CAAC,gBAAgB,eAAe,sBAAsB,YAAY,OAAO,IAAI;AAG/E,SACE,qCAAC,aAAD;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,iBAAiB;AAAA,IAC5B;AAAA,IACA,gBAAgB,sBAAsB;AAAA,IACtC,eAAe,qBAAqB;AAAA,IACpC,QAAQ,cAAc;AAAA,IACtB;AAAA,IACA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,36 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
10
|
-
import { useState, useCallback, useMemo } from 'react';
|
|
11
|
-
import { DSPopperJS } from '@elliemae/ds-popperjs';
|
|
12
|
-
import { PopupMenuContent } from './PopupMenuContent.js';
|
|
13
|
-
import { Button } from '../../components/Toolbar/styles.js';
|
|
14
|
-
import { getDataProps } from '@elliemae/ds-props-helpers';
|
|
15
|
-
import { jsx } from 'react/jsx-runtime';
|
|
16
|
-
|
|
17
|
-
const _excluded = ["Icon", "title", "onClick", "id", "componentProps"];
|
|
18
|
-
|
|
19
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
-
|
|
21
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
-
const PopupMenu = _ref => {
|
|
23
|
-
var _PopupMenuContent;
|
|
24
|
-
|
|
25
|
-
let {
|
|
26
|
-
Icon,
|
|
27
|
-
title,
|
|
28
|
-
onClick,
|
|
29
|
-
id,
|
|
30
|
-
componentProps
|
|
31
|
-
} = _ref,
|
|
32
|
-
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useState, useCallback, useMemo } from "react";
|
|
3
|
+
import { DSPopperJS } from "@elliemae/ds-popperjs";
|
|
4
|
+
import { PopupMenuContent } from "./PopupMenuContent";
|
|
5
|
+
import { Button } from "../../components/Toolbar/styles";
|
|
6
|
+
import { getDataProps } from "@elliemae/ds-props-helpers";
|
|
7
|
+
const PopupMenu = ({ Icon, title, onClick, id, componentProps, ...otherProps }) => {
|
|
34
8
|
const [isOpen, setIsOpen] = useState(false);
|
|
35
9
|
const [buttonRef, setButtonRef] = useState(null);
|
|
36
10
|
const {
|
|
@@ -41,51 +15,53 @@ const PopupMenu = _ref => {
|
|
|
41
15
|
options,
|
|
42
16
|
closeOnClick
|
|
43
17
|
} = componentProps;
|
|
44
|
-
const handleKeyPress = useCallback(e => {
|
|
45
|
-
if (e.code ===
|
|
18
|
+
const handleKeyPress = useCallback((e) => {
|
|
19
|
+
if (e.code === "Enter" || e.code === "Space") {
|
|
46
20
|
setIsOpen(true);
|
|
47
21
|
}
|
|
48
|
-
|
|
49
|
-
|
|
22
|
+
if (onKeyPress)
|
|
23
|
+
onKeyPress(e);
|
|
50
24
|
}, [onKeyPress]);
|
|
51
25
|
const handleOnClose = useCallback(() => {
|
|
52
|
-
if (userIsOpen ===
|
|
26
|
+
if (userIsOpen === void 0) {
|
|
53
27
|
setIsOpen(false);
|
|
54
28
|
}
|
|
55
|
-
|
|
56
|
-
buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.focus();
|
|
29
|
+
buttonRef?.focus();
|
|
57
30
|
}, [buttonRef, userIsOpen]);
|
|
58
|
-
const handleTriggerOnClick = useCallback(e => {
|
|
59
|
-
if (userIsOpen ===
|
|
31
|
+
const handleTriggerOnClick = useCallback((e) => {
|
|
32
|
+
if (userIsOpen === void 0)
|
|
33
|
+
setIsOpen(true);
|
|
60
34
|
onClick(e);
|
|
61
35
|
}, [onClick, userIsOpen]);
|
|
62
36
|
const handleItemClick = useCallback(() => {
|
|
63
|
-
if (closeOnClick && userIsOpen ===
|
|
37
|
+
if (closeOnClick && userIsOpen === void 0)
|
|
38
|
+
handleOnClose();
|
|
64
39
|
}, [closeOnClick, handleOnClose, userIsOpen]);
|
|
65
|
-
const content = useMemo(() =>
|
|
66
|
-
options
|
|
40
|
+
const content = useMemo(() => /* @__PURE__ */ React2.createElement(PopupMenuContent, {
|
|
41
|
+
options,
|
|
67
42
|
onItemClick: handleItemClick,
|
|
68
43
|
onClose: handleOnClose,
|
|
69
|
-
popupOnKeyPress
|
|
70
|
-
})
|
|
71
|
-
return
|
|
44
|
+
popupOnKeyPress
|
|
45
|
+
}), [options, handleItemClick, handleOnClose, popupOnKeyPress]);
|
|
46
|
+
return /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(Button, {
|
|
72
47
|
onClick: handleTriggerOnClick,
|
|
73
48
|
onKeyPress: handleKeyPress,
|
|
74
|
-
title
|
|
49
|
+
title,
|
|
75
50
|
ref: setButtonRef,
|
|
76
51
|
"data-testid": "gh-toolbar-item",
|
|
77
|
-
id
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})), /*#__PURE__*/_jsx(DSPopperJS, {
|
|
52
|
+
id,
|
|
53
|
+
...getDataProps(otherProps)
|
|
54
|
+
}, Icon && /* @__PURE__ */ React2.createElement(Icon, {
|
|
55
|
+
fill: "#FFF",
|
|
56
|
+
size: "m"
|
|
57
|
+
})), /* @__PURE__ */ React2.createElement(DSPopperJS, {
|
|
84
58
|
referenceElement: buttonRef,
|
|
85
|
-
showPopover: userIsOpen
|
|
59
|
+
showPopover: userIsOpen ?? isOpen,
|
|
86
60
|
closeContextMenu: handleOnClose,
|
|
87
|
-
onClickOutside
|
|
88
|
-
},
|
|
61
|
+
onClickOutside
|
|
62
|
+
}, content));
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
PopupMenu
|
|
89
66
|
};
|
|
90
|
-
|
|
91
|
-
export { PopupMenu };
|
|
67
|
+
//# sourceMappingURL=PopupMenu.js.map
|