@pega/cosmos-react-build 4.0.0-dev.2.0 → 4.0.0-dev.20.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/lib/components/AppShell/AppShell.d.ts +3 -2
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +42 -80
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.d.ts +12 -16
- package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +208 -283
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +63 -31
- package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.types.js.map +1 -1
- package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellContext.js +3 -5
- package/lib/components/AppShell/AppShellContext.js.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.d.ts.map +1 -0
- package/lib/components/AppShell/Header/AppHeader.js +73 -0
- package/lib/components/AppShell/Header/AppHeader.js.map +1 -0
- package/lib/components/{AppHeader → AppShell/Header}/AppHeader.styles.d.ts +7 -7
- package/lib/components/AppShell/Header/AppHeader.styles.d.ts.map +1 -0
- package/lib/components/AppShell/Header/AppHeader.styles.js +158 -0
- package/lib/components/AppShell/Header/AppHeader.styles.js.map +1 -0
- package/lib/components/{AppHeader → AppShell/Header}/AppHeader.types.d.ts +6 -5
- package/lib/components/AppShell/Header/AppHeader.types.d.ts.map +1 -0
- package/lib/components/AppShell/Header/AppHeader.types.js.map +1 -0
- package/lib/components/AppShell/Header/BranchButton.d.ts.map +1 -0
- package/lib/components/{AppHeader → AppShell/Header}/BranchButton.js +5 -5
- package/lib/components/AppShell/Header/BranchButton.js.map +1 -0
- package/lib/components/AppShell/NavigationList.d.ts +6 -0
- package/lib/components/AppShell/NavigationList.d.ts.map +1 -0
- package/lib/components/AppShell/NavigationList.js +97 -0
- package/lib/components/AppShell/NavigationList.js.map +1 -0
- package/lib/components/AppShell/index.d.ts +3 -1
- package/lib/components/AppShell/index.d.ts.map +1 -1
- package/lib/components/AppShell/index.js.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.js +27 -27
- package/lib/components/DynamicContentEditor/DynamicContentEditor.js.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/PegaCustomElement.d.ts +41 -27
- package/lib/components/DynamicContentEditor/PegaCustomElement.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.js +17 -33
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.js.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.js +6 -6
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.js.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.d.ts +4 -3
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.js.map +1 -1
- package/lib/components/ExpressionBuilder/index.d.ts +1 -1
- package/lib/components/ExpressionBuilder/index.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/index.js.map +1 -1
- package/lib/components/FlowModeller/AddNode.d.ts.map +1 -1
- package/lib/components/FlowModeller/AddNode.js +3 -4
- package/lib/components/FlowModeller/AddNode.js.map +1 -1
- package/lib/components/FlowModeller/Connector.d.ts +2 -2
- package/lib/components/FlowModeller/Connector.d.ts.map +1 -1
- package/lib/components/FlowModeller/Connector.js +2 -4
- package/lib/components/FlowModeller/Connector.js.map +1 -1
- package/lib/components/FlowModeller/DeletePopover.d.ts +3 -3
- package/lib/components/FlowModeller/DeletePopover.d.ts.map +1 -1
- package/lib/components/FlowModeller/DeletePopover.js.map +1 -1
- package/lib/components/FlowModeller/FlowModeller.d.ts.map +1 -1
- package/lib/components/FlowModeller/FlowModeller.js +1 -3
- package/lib/components/FlowModeller/FlowModeller.js.map +1 -1
- package/lib/components/FlowModeller/Node/Node.types.d.ts +5 -0
- package/lib/components/FlowModeller/Node/Node.types.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/Node.types.js.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts +5 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.js +10 -3
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.js.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.js +11 -29
- package/lib/components/FlowModeller/Node/NodeTemplates.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/Graph.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.js +3 -3
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.js.map +1 -1
- package/lib/components/ItemLibrary/ItemLibrary.d.ts.map +1 -1
- package/lib/components/ItemLibrary/ItemLibrary.js +2 -2
- package/lib/components/ItemLibrary/ItemLibrary.js.map +1 -1
- package/lib/components/LifeCycle/Category.d.ts.map +1 -1
- package/lib/components/LifeCycle/Category.js +2 -2
- package/lib/components/LifeCycle/Category.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.types.d.ts +22 -1
- package/lib/components/LifeCycle/LifeCycle.types.d.ts.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.types.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycleList.d.ts +11 -0
- package/lib/components/LifeCycle/LifeCycleList.d.ts.map +1 -1
- package/lib/components/LifeCycle/LifeCycleList.js +1 -1
- package/lib/components/LifeCycle/LifeCycleList.js.map +1 -1
- package/lib/components/LifeCycle/Stage.d.ts +2 -0
- package/lib/components/LifeCycle/Stage.d.ts.map +1 -1
- package/lib/components/LifeCycle/Stage.js +4 -10
- package/lib/components/LifeCycle/Stage.js.map +1 -1
- package/lib/components/LifeCycle/Step.d.ts +6 -2
- package/lib/components/LifeCycle/Step.d.ts.map +1 -1
- package/lib/components/LifeCycle/Step.js +30 -24
- package/lib/components/LifeCycle/Step.js.map +1 -1
- package/lib/components/LifeCycle/Task.d.ts +1 -0
- package/lib/components/LifeCycle/Task.d.ts.map +1 -1
- package/lib/components/LifeCycle/Task.js +6 -12
- package/lib/components/LifeCycle/Task.js.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.d.ts +0 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.d.ts.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.js +5 -16
- package/lib/components/MobileBuildSummary/MobileBuildSummary.js.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.types.d.ts +5 -3
- package/lib/components/MobileBuildSummary/MobileBuildSummary.types.d.ts.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.types.js.map +1 -1
- package/lib/components/ObjectPreview/ObjectPreview.d.ts +2 -2
- package/lib/components/ObjectPreview/ObjectPreview.d.ts.map +1 -1
- package/lib/components/ObjectPreview/ObjectPreview.js +1 -1
- package/lib/components/ObjectPreview/ObjectPreview.js.map +1 -1
- package/lib/components/ObjectSelect/ObjectSummary.d.ts +11 -3
- package/lib/components/ObjectSelect/ObjectSummary.d.ts.map +1 -1
- package/lib/components/ObjectSelect/ObjectSummary.js +50 -14
- package/lib/components/ObjectSelect/ObjectSummary.js.map +1 -1
- package/lib/components/ObjectSelect/useCreateModal.d.ts +9 -11
- package/lib/components/ObjectSelect/useCreateModal.d.ts.map +1 -1
- package/lib/components/ObjectSelect/useCreateModal.js +5 -6
- package/lib/components/ObjectSelect/useCreateModal.js.map +1 -1
- package/lib/components/PageBanner/PageBanner.d.ts +22 -0
- package/lib/components/PageBanner/PageBanner.d.ts.map +1 -0
- package/lib/components/PageBanner/PageBanner.js +59 -0
- package/lib/components/PageBanner/PageBanner.js.map +1 -0
- package/lib/components/PageBanner/index.d.ts +3 -0
- package/lib/components/PageBanner/index.d.ts.map +1 -0
- package/lib/components/PageBanner/index.js +2 -0
- package/lib/components/PageBanner/index.js.map +1 -0
- package/lib/components/PageTemplates/GalleryPage.d.ts +10 -10
- package/lib/components/PageTemplates/GalleryPage.d.ts.map +1 -1
- package/lib/components/PageTemplates/GalleryPage.js +35 -11
- package/lib/components/PageTemplates/GalleryPage.js.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.d.ts +1 -1
- package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.js +8 -45
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/PageTemplates/ShowcasePage.d.ts +16 -0
- package/lib/components/PageTemplates/ShowcasePage.d.ts.map +1 -0
- package/lib/components/PageTemplates/ShowcasePage.js +29 -0
- package/lib/components/PageTemplates/ShowcasePage.js.map +1 -0
- package/lib/components/PageTemplates/index.d.ts +3 -1
- package/lib/components/PageTemplates/index.d.ts.map +1 -1
- package/lib/components/PageTemplates/index.js +2 -1
- package/lib/components/PageTemplates/index.js.map +1 -1
- package/lib/components/SummaryCard/SummaryCard.d.ts.map +1 -1
- package/lib/components/SummaryCard/SummaryCard.js +4 -7
- package/lib/components/SummaryCard/SummaryCard.js.map +1 -1
- package/lib/components/Workbench/Workbench.types.d.ts +2 -2
- package/lib/components/Workbench/Workbench.types.d.ts.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/utils/utils.d.ts +1 -1
- package/lib/utils/utils.d.ts.map +1 -1
- package/package.json +16 -9
- package/lib/components/AppHeader/AppHeader.d.ts.map +0 -1
- package/lib/components/AppHeader/AppHeader.js +0 -40
- package/lib/components/AppHeader/AppHeader.js.map +0 -1
- package/lib/components/AppHeader/AppHeader.styles.d.ts.map +0 -1
- package/lib/components/AppHeader/AppHeader.styles.js +0 -118
- package/lib/components/AppHeader/AppHeader.styles.js.map +0 -1
- package/lib/components/AppHeader/AppHeader.types.d.ts.map +0 -1
- package/lib/components/AppHeader/AppHeader.types.js.map +0 -1
- package/lib/components/AppHeader/BranchButton.d.ts.map +0 -1
- package/lib/components/AppHeader/BranchButton.js.map +0 -1
- package/lib/components/AppHeader/index.d.ts +0 -4
- package/lib/components/AppHeader/index.d.ts.map +0 -1
- package/lib/components/AppHeader/index.js +0 -3
- package/lib/components/AppHeader/index.js.map +0 -1
- package/lib/components/PageTemplates/GalleryPage.styles.d.ts +0 -9
- package/lib/components/PageTemplates/GalleryPage.styles.d.ts.map +0 -1
- package/lib/components/PageTemplates/GalleryPage.styles.js +0 -70
- package/lib/components/PageTemplates/GalleryPage.styles.js.map +0 -1
- /package/lib/components/{AppHeader → AppShell/Header}/AppHeader.d.ts +0 -0
- /package/lib/components/{AppHeader → AppShell/Header}/AppHeader.types.js +0 -0
- /package/lib/components/{AppHeader → AppShell/Header}/BranchButton.d.ts +0 -0
|
@@ -1,40 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AppHeaderProps } from '
|
|
5
|
-
export interface
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
import { AsProp, BaseProps, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
|
+
import { openCloseStates } from '@pega/cosmos-react-core/lib/hooks/useTransitionState';
|
|
4
|
+
import { AppHeaderProps } from './Header/AppHeader.types';
|
|
5
|
+
export interface NestedNavItemProps {
|
|
6
|
+
/** Unique id for the nav item. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** The display text of the nav item. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** URL or DOM id to navigate to. This will render the nav item as a link. */
|
|
11
|
+
href?: string;
|
|
12
|
+
/** Click handler for the nav item. */
|
|
13
|
+
onClick?: (id: string, e: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>) => void;
|
|
14
|
+
/** A set of nested nav items. */
|
|
15
|
+
items?: NestedNavItemProps[];
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
items
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
devMode?: boolean;
|
|
17
|
+
interface ParentNavItemProps {
|
|
18
|
+
/** A set of nested nav items. */
|
|
19
|
+
items?: NestedNavItemProps[];
|
|
20
|
+
href?: never;
|
|
21
|
+
onClick?: never;
|
|
20
22
|
}
|
|
21
|
-
|
|
23
|
+
interface NavLinkProps {
|
|
24
|
+
/** URL or DOM id to navigate to. This will render the nav item as a link. */
|
|
25
|
+
href?: string;
|
|
26
|
+
/** Click handler for the link. If no href if passed, this will render the nav item as a button. */
|
|
27
|
+
onClick?: (id: string, e: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>) => void;
|
|
28
|
+
items?: never;
|
|
29
|
+
}
|
|
30
|
+
export type NavItemProps = {
|
|
31
|
+
/** Unique id for the nav item. */
|
|
22
32
|
id: string;
|
|
33
|
+
/** The display text of the nav item. */
|
|
23
34
|
label: string;
|
|
35
|
+
/** The name of the Cosmos Icon to render as a visual. Only applies to top-level nav items. */
|
|
36
|
+
icon: string;
|
|
37
|
+
} & (ParentNavItemProps | NavLinkProps);
|
|
38
|
+
export interface NavProps {
|
|
39
|
+
/** A set of nav items that will render as a list in the App Shell. */
|
|
40
|
+
items: NavItemProps[];
|
|
41
|
+
/** The id of the active nav item. */
|
|
42
|
+
currentItemId?: NavItemProps['id'];
|
|
43
|
+
/**
|
|
44
|
+
* If true, the nav will be expanded on initial load.
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
defaultExpanded?: boolean;
|
|
24
48
|
}
|
|
25
|
-
export interface
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
49
|
+
export interface AppShellProps extends NoChildrenProp {
|
|
50
|
+
/** The content of the application. */
|
|
51
|
+
main: ReactNode;
|
|
52
|
+
/** Props related to the App Shell header. */
|
|
53
|
+
appHeader: AppHeaderProps;
|
|
54
|
+
/** Props related to the App Shell side navigation. */
|
|
55
|
+
nav?: NavProps;
|
|
29
56
|
}
|
|
30
57
|
export interface AppShellContextValue {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
58
|
+
navOpen: boolean;
|
|
59
|
+
navState: (typeof openCloseStates)[keyof typeof openCloseStates];
|
|
60
|
+
openNav: () => void;
|
|
61
|
+
}
|
|
62
|
+
export interface NavItemRenderProps extends AsProp, BaseProps, NoChildrenProp {
|
|
63
|
+
id: NavItemProps['id'];
|
|
64
|
+
label: NavItemProps['label'];
|
|
65
|
+
visual: ReactNode;
|
|
66
|
+
href?: NavLinkProps['href'];
|
|
67
|
+
onClick?: NavLinkProps['onClick'];
|
|
68
|
+
items?: NestedNavItemProps['items'];
|
|
69
|
+
currentItemId?: NavItemProps['id'];
|
|
39
70
|
}
|
|
71
|
+
export {};
|
|
40
72
|
//# sourceMappingURL=AppShell.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppShell.types.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShell.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"AppShell.types.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShell.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UA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AAExC,MAAM,WAAW,QAAQ;IACvB,sEAAsE;IACtE,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,qCAAqC;IACrC,aAAa,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc;IACnD,sCAAsC;IACtC,IAAI,EAAE,SAAS,CAAC;IAChB,6CAA6C;IAC7C,SAAS,EAAE,cAAc,CAAC;IAC1B,sDAAsD;IACtD,GAAG,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;IACjE,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,kBAAmB,SAAQ,MAAM,EAAE,SAAS,EAAE,cAAc;IAC3E,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IACvB,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC7B,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACpC,aAAa,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;CACpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppShell.types.js","sourceRoot":"","sources":["../../../src/components/AppShell/AppShell.types.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"AppShell.types.js","sourceRoot":"","sources":["../../../src/components/AppShell/AppShell.types.ts"],"names":[],"mappings":"","sourcesContent":["import { KeyboardEvent, MouseEvent, ReactNode } from 'react';\n\nimport { AsProp, BaseProps, NoChildrenProp } from '@pega/cosmos-react-core';\nimport { openCloseStates } from '@pega/cosmos-react-core/lib/hooks/useTransitionState';\n\nimport { AppHeaderProps } from './Header/AppHeader.types';\n\nexport interface NestedNavItemProps {\n /** Unique id for the nav item. */\n id: string;\n /** The display text of the nav item. */\n label: string;\n /** URL or DOM id to navigate to. This will render the nav item as a link. */\n href?: string;\n /** Click handler for the nav item. */\n onClick?: (id: string, e: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>) => void;\n /** A set of nested nav items. */\n items?: NestedNavItemProps[];\n}\n\ninterface ParentNavItemProps {\n /** A set of nested nav items. */\n items?: NestedNavItemProps[];\n href?: never;\n onClick?: never;\n}\n\ninterface NavLinkProps {\n /** URL or DOM id to navigate to. This will render the nav item as a link. */\n href?: string;\n /** Click handler for the link. If no href if passed, this will render the nav item as a button. */\n onClick?: (id: string, e: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>) => void;\n items?: never;\n}\n\nexport type NavItemProps = {\n /** Unique id for the nav item. */\n id: string;\n /** The display text of the nav item. */\n label: string;\n /** The name of the Cosmos Icon to render as a visual. Only applies to top-level nav items. */\n icon: string;\n} & (ParentNavItemProps | NavLinkProps);\n\nexport interface NavProps {\n /** A set of nav items that will render as a list in the App Shell. */\n items: NavItemProps[];\n /** The id of the active nav item. */\n currentItemId?: NavItemProps['id'];\n /**\n * If true, the nav will be expanded on initial load.\n * @default true\n */\n defaultExpanded?: boolean;\n}\n\nexport interface AppShellProps extends NoChildrenProp {\n /** The content of the application. */\n main: ReactNode;\n /** Props related to the App Shell header. */\n appHeader: AppHeaderProps;\n /** Props related to the App Shell side navigation. */\n nav?: NavProps;\n}\n\nexport interface AppShellContextValue {\n navOpen: boolean;\n navState: (typeof openCloseStates)[keyof typeof openCloseStates];\n openNav: () => void;\n}\n\nexport interface NavItemRenderProps extends AsProp, BaseProps, NoChildrenProp {\n id: NavItemProps['id'];\n label: NavItemProps['label'];\n visual: ReactNode;\n href?: NavLinkProps['href'];\n onClick?: NavLinkProps['onClick'];\n items?: NestedNavItemProps['items'];\n currentItemId?: NavItemProps['id'];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppShellContext.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShellContext.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,QAAA,MAAM,eAAe,+
|
|
1
|
+
{"version":3,"file":"AppShellContext.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShellContext.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,QAAA,MAAM,eAAe,+CAInB,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
const AppShellContext = createContext({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
setDrawerData: () => { },
|
|
7
|
-
navState: 'expanded'
|
|
3
|
+
navOpen: false,
|
|
4
|
+
navState: 'closed',
|
|
5
|
+
openNav: () => { }
|
|
8
6
|
});
|
|
9
7
|
export default AppShellContext;
|
|
10
8
|
//# sourceMappingURL=AppShellContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppShellContext.js","sourceRoot":"","sources":["../../../src/components/AppShell/AppShellContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC,MAAM,eAAe,GAAG,aAAa,CAAuB;IAC1D,
|
|
1
|
+
{"version":3,"file":"AppShellContext.js","sourceRoot":"","sources":["../../../src/components/AppShell/AppShellContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC,MAAM,eAAe,GAAG,aAAa,CAAuB;IAC1D,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;CAClB,CAAC,CAAC;AAEH,eAAe,eAAe,CAAC","sourcesContent":["import { createContext } from 'react';\n\nimport { AppShellContextValue } from './AppShell.types';\n\nconst AppShellContext = createContext<AppShellContextValue>({\n navOpen: false,\n navState: 'closed',\n openNav: () => {}\n});\n\nexport default AppShellContext;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppHeader.d.ts","sourceRoot":"","sources":["../../../../src/components/AppShell/Header/AppHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAUlB,MAAM,OAAO,CAAC;AAEf,OAAO,EAIL,YAAY,EASb,MAAM,yBAAyB,CAAC;AAmBjC,OAAO,EAAE,cAAc,EAAyB,MAAM,mBAAmB,CAAC;AAkJ1E,QAAA,MAAM,SAAS,EAAE,iBAAiB,CAAC,cAAc,GAAG,YAAY,CAoG/D,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useState, useRef } from 'react';
|
|
3
|
+
import { ContextSwitcher, Flex, SearchInput, useBreakpoint, Button, Icon, useI18n, Tooltip, useElement, Avatar } from '@pega/cosmos-react-core';
|
|
4
|
+
import AppShellOperator from '@pega/cosmos-react-core/lib/components/AppShell/Operator';
|
|
5
|
+
import { StyledAppHeaderSearchForm, StyledAppHeaderOperator } from '@pega/cosmos-react-core/lib/components/AppShell/AppHeader.styles';
|
|
6
|
+
import { StyledAppHeader, StyledTabs, StyledUtilsContainer, StyledBrandContainer, StyledAppHeaderSearch, StyledAppName, StyledAppVersion, StyledBrandButton, StyledBrandImage, StyledContext } from './AppHeader.styles';
|
|
7
|
+
import BranchButton from './BranchButton';
|
|
8
|
+
const Links = ({ links }) => {
|
|
9
|
+
const [currentTabId, setCurrentTabId] = useState(links[0].id);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setCurrentTabId(links[0].id);
|
|
12
|
+
}, [links]);
|
|
13
|
+
const handleTabClick = useCallback((id, e) => {
|
|
14
|
+
const newActiveTab = links.find(item => item.id === id);
|
|
15
|
+
if (newActiveTab) {
|
|
16
|
+
newActiveTab.onClick?.(id, e);
|
|
17
|
+
setCurrentTabId(newActiveTab.id);
|
|
18
|
+
}
|
|
19
|
+
}, [links]);
|
|
20
|
+
return _jsx(StyledTabs, { tabs: links, currentTabId: currentTabId, onTabClick: handleTabClick });
|
|
21
|
+
};
|
|
22
|
+
const AppHeaderSearch = ({ showSearchButton, setShowSearchButton, ...restProps }) => {
|
|
23
|
+
const isMediumOrAbove = useBreakpoint('md');
|
|
24
|
+
const t = useI18n();
|
|
25
|
+
const searchInputRef = useCallback(node => {
|
|
26
|
+
if (!showSearchButton && node) {
|
|
27
|
+
node.focus();
|
|
28
|
+
}
|
|
29
|
+
}, [showSearchButton]);
|
|
30
|
+
const focusSearchBtn = useRef(false);
|
|
31
|
+
const searchButtonRef = useCallback(node => {
|
|
32
|
+
if (node && focusSearchBtn.current) {
|
|
33
|
+
node.focus();
|
|
34
|
+
}
|
|
35
|
+
}, []);
|
|
36
|
+
return isMediumOrAbove || !showSearchButton ? (_jsxs(Flex, { as: StyledAppHeaderSearch, item: { shrink: 0, grow: 1 }, md: { item: { grow: 0, shrink: 1 } }, container: { justify: 'between', alignItems: 'center', gap: 1 }, children: [_jsx(StyledAppHeaderSearchForm, { role: 'search', "aria-label": t('sitewide'), onSubmit: e => e.preventDefault(), isMediumOrAbove: isMediumOrAbove, children: _jsx(SearchInput, { ...restProps, ref: searchInputRef }) }), _jsx(Button, { variant: 'simple', icon: true, onClick: () => {
|
|
37
|
+
setShowSearchButton(true);
|
|
38
|
+
focusSearchBtn.current = true;
|
|
39
|
+
}, label: t('collapse_search'), children: _jsx(Icon, { name: 'times' }) })] })) : (_jsx(Button, { variant: 'simple', icon: true, onClick: () => setShowSearchButton(false), ref: searchButtonRef, label: t('expand_search'), children: _jsx(Icon, { name: 'search' }) }));
|
|
40
|
+
};
|
|
41
|
+
const Utils = ({ operator, branch, action, appInfo }) => {
|
|
42
|
+
const isMediumOrAbove = useBreakpoint('md');
|
|
43
|
+
const isSmallOrAbove = useBreakpoint('sm');
|
|
44
|
+
const [appInfoEl, setAppInfoEl] = useElement(null);
|
|
45
|
+
return (_jsxs(Flex, { container: { justify: 'between', alignItems: 'center' }, md: { container: { justify: 'end' } }, item: { shrink: 1 }, as: StyledUtilsContainer, children: [appInfo && (_jsxs(Flex, { container: { justify: 'between', alignItems: 'center', gap: 0.5 }, item: { shrink: 1 }, ref: setAppInfoEl, children: [_jsx(Flex, { as: StyledAppName, item: { shrink: 1 }, children: appInfo.name }), _jsx(StyledAppVersion, { children: appInfo.version }), _jsx(Tooltip, { target: appInfoEl, hideDelay: 'none', children: `${appInfo.name} ${appInfo.version}` })] })), _jsxs(Flex, { container: { alignItems: 'center' }, children: [branch && _jsx(BranchButton, { ...branch, compact: isSmallOrAbove ? branch.compact : true }), action && (_jsxs(Flex, { container: { justify: 'between', alignItems: 'center', gap: 0.5 }, item: { shrink: 0 }, as: Button, variant: 'secondary', icon: !isMediumOrAbove, label: isMediumOrAbove ? undefined : action.text, onClick: (e) => action.onClick?.(action.id, e), disabled: action.disabled, children: [action.icon && _jsx(Icon, { name: action.icon }), isMediumOrAbove && action.text] }))] }), isMediumOrAbove && (_jsx(AppShellOperator, { as: StyledAppHeaderOperator, actions: operator.actions, popover: { placement: 'bottom-end' }, children: _jsx(Avatar, { ...operator.avatar }) }))] }));
|
|
46
|
+
};
|
|
47
|
+
const AppHeader = forwardRef(({ contextSwitcher: { contexts, onContextClick, label: contextSwitcherLabel } = {}, brand, utils, links }, ref) => {
|
|
48
|
+
const selectedContext = contexts?.length > 1 ? contexts.find(ctx => ctx.selected) : contexts[0];
|
|
49
|
+
const isMediumOrAbove = useBreakpoint('md');
|
|
50
|
+
const [showSearchButton, setShowSearchButton] = useState(true);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (isMediumOrAbove && !showSearchButton) {
|
|
53
|
+
setShowSearchButton(true);
|
|
54
|
+
}
|
|
55
|
+
}, [isMediumOrAbove]);
|
|
56
|
+
return (_jsxs(Flex, { as: StyledAppHeader, container: {
|
|
57
|
+
justify: 'between',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
colGap: 2,
|
|
60
|
+
wrap: 'wrap',
|
|
61
|
+
pad: [0, 1]
|
|
62
|
+
}, md: { container: { wrap: 'nowrap' } }, ref: ref, children: [showSearchButton && (_jsxs(Flex, { as: StyledBrandContainer, container: {
|
|
63
|
+
justify: 'between',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
gap: 1
|
|
66
|
+
}, item: { shrink: 0, alignSelf: 'stretch' }, children: [contexts && onContextClick && contexts.length > 1 && (_jsx(ContextSwitcher, { contexts: contexts, onContextClick: onContextClick, label: contextSwitcherLabel })), _jsxs(Flex, { as: brand.onClick || brand.href ? StyledBrandButton : 'div', variant: 'simple', container: { alignItems: 'center', justify: 'between', gap: 2, pad: 1 }, "aria-label": `${brand.label} - ${selectedContext.primary}`, onClick: brand.onClick, href: brand.href, children: [_jsx(Flex, { item: { shrink: 0 }, as: StyledBrandImage, src: brand.logo, alt: brand.label }), _jsxs(Flex, { container: { justify: 'between', alignItems: 'center', gap: 1 }, children: [selectedContext.visual, _jsx(StyledContext, { children: selectedContext.primary })] })] })] })), links && links.length > 0 && _jsx(Links, { links: links }), _jsxs(Flex, { container: {
|
|
67
|
+
gap: 1,
|
|
68
|
+
justify: 'center',
|
|
69
|
+
alignItems: 'center'
|
|
70
|
+
}, item: { grow: showSearchButton ? 0 : 1 }, md: { item: { grow: showSearchButton ? 1 : 0 } }, children: [utils?.search && (_jsx(AppHeaderSearch, { ...utils.search, showSearchButton: showSearchButton, setShowSearchButton: setShowSearchButton })), showSearchButton && !isMediumOrAbove && utils?.operator && (_jsx(AppShellOperator, { as: StyledAppHeaderOperator, actions: utils.operator.actions, popover: { placement: 'bottom-start' }, children: _jsx(Avatar, { ...utils.operator.avatar }) }))] }), utils && _jsx(Utils, { ...utils })] }));
|
|
71
|
+
});
|
|
72
|
+
export default AppHeader;
|
|
73
|
+
//# sourceMappingURL=AppHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppHeader.js","sourceRoot":"","sources":["../../../../src/components/AppShell/Header/AppHeader.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,WAAW,EACX,SAAS,EACT,QAAQ,EACR,MAAM,EAGP,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,eAAe,EACf,IAAI,EACJ,WAAW,EAGX,aAAa,EACb,MAAM,EACN,IAAI,EACJ,OAAO,EACP,OAAO,EACP,UAAU,EACV,MAAM,EACP,MAAM,yBAAyB,CAAC;AACjC,OAAO,gBAAgB,MAAM,0DAA0D,CAAC;AACxF,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,kEAAkE,CAAC;AAE1E,OAAO,EACL,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,MAAM,KAAK,GAA+B,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACtD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACb,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,MAAM,cAAc,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SAAS,EAAE,cAAc,EAAE,YAEtC,KAAC,MAAM,OAAK,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAI,GACpB,CACpB,IACI,EACN,KAAK,IAAI,KAAC,KAAK,OAAK,KAAK,GAAI,IACzB,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n MouseEvent,\n FC,\n PropsWithoutRef,\n useCallback,\n useEffect,\n useState,\n useRef,\n Dispatch,\n SetStateAction\n} from 'react';\n\nimport {\n ContextSwitcher,\n Flex,\n SearchInput,\n ForwardProps,\n SearchInputProps,\n useBreakpoint,\n Button,\n Icon,\n useI18n,\n Tooltip,\n useElement,\n Avatar\n} from '@pega/cosmos-react-core';\nimport AppShellOperator from '@pega/cosmos-react-core/lib/components/AppShell/Operator';\nimport {\n StyledAppHeaderSearchForm,\n StyledAppHeaderOperator\n} from '@pega/cosmos-react-core/lib/components/AppShell/AppHeader.styles';\n\nimport {\n StyledAppHeader,\n StyledTabs,\n StyledUtilsContainer,\n StyledBrandContainer,\n StyledAppHeaderSearch,\n StyledAppName,\n StyledAppVersion,\n StyledBrandButton,\n StyledBrandImage,\n StyledContext\n} from './AppHeader.styles';\nimport { AppHeaderProps, LinkProps, UtilsProps } from './AppHeader.types';\nimport BranchButton from './BranchButton';\n\nconst Links: FC<{ links: LinkProps[] }> = ({ links }) => {\n const [currentTabId, setCurrentTabId] = useState(links[0].id);\n\n useEffect(() => {\n setCurrentTabId(links[0].id);\n }, [links]);\n\n const handleTabClick = useCallback(\n (id: string, e?: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n const newActiveTab = links.find(item => item.id === id);\n if (newActiveTab) {\n newActiveTab.onClick?.(id, e);\n setCurrentTabId(newActiveTab.id);\n }\n },\n [links]\n );\n\n return <StyledTabs tabs={links} currentTabId={currentTabId} onTabClick={handleTabClick} />;\n};\n\nconst AppHeaderSearch: FC<\n SearchInputProps & {\n showSearchButton: boolean;\n setShowSearchButton: Dispatch<SetStateAction<boolean>>;\n }\n> = ({ showSearchButton, setShowSearchButton, ...restProps }) => {\n const isMediumOrAbove = useBreakpoint('md');\n const t = useI18n();\n\n const searchInputRef = useCallback(\n node => {\n if (!showSearchButton && node) {\n node.focus();\n }\n },\n [showSearchButton]\n );\n const focusSearchBtn = useRef(false);\n const searchButtonRef = useCallback(node => {\n if (node && focusSearchBtn.current) {\n node.focus();\n }\n }, []);\n\n return isMediumOrAbove || !showSearchButton ? (\n <Flex\n as={StyledAppHeaderSearch}\n item={{ shrink: 0, grow: 1 }}\n md={{ item: { grow: 0, shrink: 1 } }}\n container={{ justify: 'between', alignItems: 'center', gap: 1 }}\n >\n <StyledAppHeaderSearchForm\n role='search'\n aria-label={t('sitewide')}\n onSubmit={e => e.preventDefault()}\n isMediumOrAbove={isMediumOrAbove}\n >\n <SearchInput {...restProps} ref={searchInputRef} />\n </StyledAppHeaderSearchForm>\n <Button\n variant='simple'\n icon\n onClick={() => {\n setShowSearchButton(true);\n focusSearchBtn.current = true;\n }}\n label={t('collapse_search')}\n >\n <Icon name='times' />\n </Button>\n </Flex>\n ) : (\n <Button\n variant='simple'\n icon\n onClick={() => setShowSearchButton(false)}\n ref={searchButtonRef}\n label={t('expand_search')}\n >\n <Icon name='search' />\n </Button>\n );\n};\n\nconst Utils: FC<UtilsProps> = ({ operator, branch, action, appInfo }) => {\n const isMediumOrAbove = useBreakpoint('md');\n const isSmallOrAbove = useBreakpoint('sm');\n const [appInfoEl, setAppInfoEl] = useElement(null);\n\n return (\n <Flex\n container={{ justify: 'between', alignItems: 'center' }}\n md={{ container: { justify: 'end' } }}\n item={{ shrink: 1 }}\n as={StyledUtilsContainer}\n >\n {appInfo && (\n <Flex\n container={{ justify: 'between', alignItems: 'center', gap: 0.5 }}\n item={{ shrink: 1 }}\n ref={setAppInfoEl}\n >\n <Flex as={StyledAppName} item={{ shrink: 1 }}>\n {appInfo.name}\n </Flex>\n <StyledAppVersion>{appInfo.version}</StyledAppVersion>\n <Tooltip target={appInfoEl} hideDelay='none'>\n {`${appInfo.name} ${appInfo.version}`}\n </Tooltip>\n </Flex>\n )}\n <Flex container={{ alignItems: 'center' }}>\n {branch && <BranchButton {...branch} compact={isSmallOrAbove ? branch.compact : true} />}\n {action && (\n <Flex\n container={{ justify: 'between', alignItems: 'center', gap: 0.5 }}\n item={{ shrink: 0 }}\n as={Button}\n variant='secondary'\n icon={!isMediumOrAbove}\n label={isMediumOrAbove ? undefined : action.text}\n onClick={(e: MouseEvent<HTMLButtonElement>) => action.onClick?.(action.id, e)}\n disabled={action.disabled}\n >\n {action.icon && <Icon name={action.icon} />}\n {isMediumOrAbove && action.text}\n </Flex>\n )}\n </Flex>\n {isMediumOrAbove && (\n <AppShellOperator\n as={StyledAppHeaderOperator}\n actions={operator.actions}\n popover={{ placement: 'bottom-end' }}\n >\n <Avatar {...operator.avatar} />\n </AppShellOperator>\n )}\n </Flex>\n );\n};\n\nconst AppHeader: FunctionComponent<AppHeaderProps & ForwardProps> = forwardRef(\n (\n {\n contextSwitcher: { contexts, onContextClick, label: contextSwitcherLabel } = {},\n brand,\n utils,\n links\n }: PropsWithoutRef<AppHeaderProps>,\n ref: AppHeaderProps['ref']\n ) => {\n const selectedContext =\n contexts?.length > 1 ? contexts.find(ctx => ctx.selected)! : contexts[0];\n\n const isMediumOrAbove = useBreakpoint('md');\n const [showSearchButton, setShowSearchButton] = useState(true);\n\n useEffect(() => {\n if (isMediumOrAbove && !showSearchButton) {\n setShowSearchButton(true);\n }\n }, [isMediumOrAbove]);\n\n return (\n <Flex\n as={StyledAppHeader}\n container={{\n justify: 'between',\n alignItems: 'center',\n colGap: 2,\n wrap: 'wrap',\n pad: [0, 1]\n }}\n md={{ container: { wrap: 'nowrap' } }}\n ref={ref}\n >\n {showSearchButton && (\n <Flex\n as={StyledBrandContainer}\n container={{\n justify: 'between',\n alignItems: 'center',\n gap: 1\n }}\n item={{ shrink: 0, alignSelf: 'stretch' }}\n >\n {contexts && onContextClick && contexts.length > 1 && (\n <ContextSwitcher\n contexts={contexts}\n onContextClick={onContextClick}\n label={contextSwitcherLabel}\n />\n )}\n <Flex\n as={brand.onClick || brand.href ? StyledBrandButton : 'div'}\n variant='simple'\n container={{ alignItems: 'center', justify: 'between', gap: 2, pad: 1 }}\n aria-label={`${brand.label} - ${selectedContext.primary}`}\n onClick={brand.onClick}\n href={brand.href}\n >\n <Flex item={{ shrink: 0 }} as={StyledBrandImage} src={brand.logo} alt={brand.label} />\n <Flex container={{ justify: 'between', alignItems: 'center', gap: 1 }}>\n {selectedContext.visual}\n <StyledContext>{selectedContext.primary}</StyledContext>\n </Flex>\n </Flex>\n </Flex>\n )}\n {links && links.length > 0 && <Links links={links} />}\n\n <Flex\n container={{\n gap: 1,\n justify: 'center',\n alignItems: 'center'\n }}\n item={{ grow: showSearchButton ? 0 : 1 }}\n md={{ item: { grow: showSearchButton ? 1 : 0 } }}\n >\n {utils?.search && (\n <AppHeaderSearch\n {...utils.search}\n showSearchButton={showSearchButton}\n setShowSearchButton={setShowSearchButton}\n />\n )}\n {showSearchButton && !isMediumOrAbove && utils?.operator && (\n <AppShellOperator\n as={StyledAppHeaderOperator}\n actions={utils.operator.actions}\n popover={{ placement: 'bottom-start' }}\n >\n <Avatar {...utils.operator.avatar} />\n </AppShellOperator>\n )}\n </Flex>\n {utils && <Utils {...utils} />}\n </Flex>\n );\n }\n);\n\nexport default AppHeader;\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { Text, Tabs } from '@pega/cosmos-react-core';
|
|
3
3
|
export declare const StyledAppHeader: import("styled-components").StyledComponent<"header", import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const StyledBrandContainer: typeof Flex;
|
|
4
|
+
export declare const StyledBrandContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
6
5
|
export declare const StyledBrandButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core/lib/components/Button/BareButton").BareButtonProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
6
|
+
export declare const StyledBrandImage: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").ImageProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
7
|
+
export declare const StyledContext: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
7
8
|
export declare const StyledTabs: typeof Tabs;
|
|
8
|
-
export declare const StyledUtilsContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
9
9
|
export declare const StyledAppHeaderSearch: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
10
|
+
export declare const StyledUtilsContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
11
|
+
export declare const StyledAppName: typeof Text;
|
|
12
|
+
export declare const StyledAppVersion: typeof Text;
|
|
13
13
|
//# sourceMappingURL=AppHeader.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppHeader.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/AppShell/Header/AppHeader.styles.ts"],"names":[],"mappings":";AAEA,OAAO,EAAoB,IAAI,EAAE,IAAI,EAAuB,MAAM,yBAAyB,CAAC;AAI5F,eAAO,MAAM,eAAe,4GA8B3B,CAAC;AAIF,eAAO,MAAM,oBAAoB,yGAkBhC,CAAC;AAIF,eAAO,MAAM,iBAAiB,0QAa5B,CAAC;AAIH,eAAO,MAAM,gBAAgB,oOAgB5B,CAAC;AAEF,eAAO,MAAM,aAAa,0GAIzB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,OAAO,IA8B/B,CAAC;AAIF,eAAO,MAAM,qBAAqB,yGA0BjC,CAAC;AAIF,eAAO,MAAM,oBAAoB,yGAmBhC,CAAC;AAIF,eAAO,MAAM,aAAa,EAAE,OAAO,IAUjC,CAAC;AAIH,eAAO,MAAM,gBAAgB,EAAE,OAAO,IAKpC,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { defaultThemeProp, Text, Tabs, Image, StyledButton } from '@pega/cosmos-react-core';
|
|
3
|
+
import { StyledAppHeaderSearchForm } from '@pega/cosmos-react-core/lib/components/AppShell/AppHeader.styles';
|
|
4
|
+
import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
|
|
5
|
+
export const StyledAppHeader = styled.header(({ theme: { base: { palette, breakpoints, 'z-index': zIndex } } }) => {
|
|
6
|
+
return css `
|
|
7
|
+
height: 6rem;
|
|
8
|
+
border-bottom: 0.0625rem solid ${palette['border-line']};
|
|
9
|
+
background-color: ${palette['primary-background']};
|
|
10
|
+
position: sticky;
|
|
11
|
+
top: 0;
|
|
12
|
+
z-index: calc(${zIndex.drawer + 1});
|
|
13
|
+
& > div {
|
|
14
|
+
height: 50%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@media (pointer: coarse) {
|
|
18
|
+
height: 8rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@media (min-width: ${breakpoints.md}) {
|
|
22
|
+
height: 3rem;
|
|
23
|
+
|
|
24
|
+
& > div {
|
|
25
|
+
height: 100%;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
});
|
|
30
|
+
StyledAppHeader.defaultProps = defaultThemeProp;
|
|
31
|
+
export const StyledBrandContainer = styled.div(({ theme: { base: { 'hit-area': hitArea, breakpoints, spacing } } }) => {
|
|
32
|
+
return css `
|
|
33
|
+
max-width: calc(100% - calc(3 * ${hitArea.mouse}));
|
|
34
|
+
|
|
35
|
+
@media (min-width: ${breakpoints.xs}) and (pointer: coarse) {
|
|
36
|
+
max-width: calc(100% - calc(3 * ${hitArea.mouse}) - calc(2 * ${spacing}));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@media (min-width: ${breakpoints.md}) {
|
|
40
|
+
max-width: 30%;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
});
|
|
44
|
+
StyledBrandContainer.defaultProps = defaultThemeProp;
|
|
45
|
+
export const StyledBrandButton = styled(BareButton)(({ theme }) => {
|
|
46
|
+
return css `
|
|
47
|
+
text-decoration: none;
|
|
48
|
+
min-width: 0;
|
|
49
|
+
|
|
50
|
+
& > div:last-child {
|
|
51
|
+
min-width: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&:not([disabled]):focus {
|
|
55
|
+
box-shadow: ${theme.base.shadow.focus};
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
});
|
|
59
|
+
StyledBrandButton.defaultProps = defaultThemeProp;
|
|
60
|
+
export const StyledBrandImage = styled(Image)(({ theme: { base: { breakpoints } } }) => {
|
|
61
|
+
return css `
|
|
62
|
+
height: 1.5rem;
|
|
63
|
+
max-width: 17ch;
|
|
64
|
+
display: none;
|
|
65
|
+
|
|
66
|
+
@media (min-width: ${breakpoints.sm}) {
|
|
67
|
+
display: unset;
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
});
|
|
71
|
+
export const StyledContext = styled.span `
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
text-overflow: ellipsis;
|
|
74
|
+
white-space: nowrap;
|
|
75
|
+
`;
|
|
76
|
+
export const StyledTabs = styled(Tabs)(({ theme: { base: { breakpoints, 'font-weight': fontWeight } } }) => {
|
|
77
|
+
return css `
|
|
78
|
+
display: none;
|
|
79
|
+
border: none;
|
|
80
|
+
min-height: 3rem;
|
|
81
|
+
[role='tab'] {
|
|
82
|
+
height: auto;
|
|
83
|
+
span:first-of-type {
|
|
84
|
+
text-transform: none;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
[role='tab'][aria-selected='false'] > span {
|
|
88
|
+
font-weight: ${fontWeight['semi-bold']};
|
|
89
|
+
}
|
|
90
|
+
[role='tab']:hover,
|
|
91
|
+
[role='tab']:focus,
|
|
92
|
+
[role='tab']:active {
|
|
93
|
+
box-shadow: none;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@media (min-width: ${breakpoints.md}) {
|
|
97
|
+
display: inherit;
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
});
|
|
101
|
+
StyledTabs.defaultProps = defaultThemeProp;
|
|
102
|
+
export const StyledAppHeaderSearch = styled.div(({ theme: { base: { spacing, breakpoints, 'content-width': contentWidth } } }) => {
|
|
103
|
+
return css `
|
|
104
|
+
padding-block: ${spacing};
|
|
105
|
+
width: 100%;
|
|
106
|
+
${StyledAppHeaderSearchForm} {
|
|
107
|
+
margin-inline-start: 0;
|
|
108
|
+
max-width: 100%;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@media (min-width: ${breakpoints.md}) {
|
|
112
|
+
${StyledAppHeaderSearchForm} {
|
|
113
|
+
margin-inline-start: auto;
|
|
114
|
+
max-width: ${contentWidth.lg};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
${StyledButton} {
|
|
118
|
+
display: none;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
});
|
|
123
|
+
StyledAppHeaderSearch.defaultProps = defaultThemeProp;
|
|
124
|
+
export const StyledUtilsContainer = styled.div(({ theme: { base: { spacing, breakpoints } } }) => {
|
|
125
|
+
return css `
|
|
126
|
+
width: 100%;
|
|
127
|
+
& > div,
|
|
128
|
+
& > span,
|
|
129
|
+
& > button {
|
|
130
|
+
margin-inline-start: ${spacing};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@media (min-width: ${breakpoints.md}) {
|
|
134
|
+
width: auto;
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
});
|
|
138
|
+
StyledUtilsContainer.defaultProps = defaultThemeProp;
|
|
139
|
+
export const StyledAppName = styled(Text)(({ theme }) => {
|
|
140
|
+
return css `
|
|
141
|
+
max-width: ${theme.base['content-width'].sm};
|
|
142
|
+
text-overflow: ellipsis;
|
|
143
|
+
overflow: hidden;
|
|
144
|
+
white-space: nowrap;
|
|
145
|
+
color: ${theme.base.palette['foreground-color']};
|
|
146
|
+
font-weight: ${theme.base['font-weight']['semi-bold']};
|
|
147
|
+
margin-inline-start: 0;
|
|
148
|
+
`;
|
|
149
|
+
});
|
|
150
|
+
StyledAppName.defaultProps = defaultThemeProp;
|
|
151
|
+
export const StyledAppVersion = styled(Text)(({ theme }) => {
|
|
152
|
+
return css `
|
|
153
|
+
font-weight: ${theme.base['font-weight']['semi-bold']};
|
|
154
|
+
margin-inline-start: 0;
|
|
155
|
+
`;
|
|
156
|
+
});
|
|
157
|
+
StyledAppVersion.defaultProps = defaultThemeProp;
|
|
158
|
+
//# sourceMappingURL=AppHeader.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppHeader.styles.js","sourceRoot":"","sources":["../../../../src/components/AppShell/Header/AppHeader.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,kEAAkE,CAAC;AAC7G,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAElF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAC1C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,EAClD,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;;uCAEyB,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Ae,CAAC,CAAC,EAAE;;;;aAIlC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;mBAChC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC;;GAEtD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,aAAa,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACtE,OAAO,GAAG,CAAA;mBACO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC;;GAEtD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp, Text, Tabs, Image, StyledButton } from '@pega/cosmos-react-core';\nimport { StyledAppHeaderSearchForm } from '@pega/cosmos-react-core/lib/components/AppShell/AppHeader.styles';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\n\nexport const StyledAppHeader = styled.header(\n ({\n theme: {\n base: { palette, breakpoints, 'z-index': zIndex }\n }\n }) => {\n return css`\n height: 6rem;\n border-bottom: 0.0625rem solid ${palette['border-line']};\n background-color: ${palette['primary-background']};\n position: sticky;\n top: 0;\n z-index: calc(${zIndex.drawer + 1});\n & > div {\n height: 50%;\n }\n\n @media (pointer: coarse) {\n height: 8rem;\n }\n\n @media (min-width: ${breakpoints.md}) {\n height: 3rem;\n\n & > div {\n height: 100%;\n }\n }\n `;\n }\n);\n\nStyledAppHeader.defaultProps = defaultThemeProp;\n\nexport const StyledBrandContainer = styled.div(\n ({\n theme: {\n base: { 'hit-area': hitArea, breakpoints, spacing }\n }\n }) => {\n return css`\n max-width: calc(100% - calc(3 * ${hitArea.mouse}));\n\n @media (min-width: ${breakpoints.xs}) and (pointer: coarse) {\n max-width: calc(100% - calc(3 * ${hitArea.mouse}) - calc(2 * ${spacing}));\n }\n\n @media (min-width: ${breakpoints.md}) {\n max-width: 30%;\n }\n `;\n }\n);\n\nStyledBrandContainer.defaultProps = defaultThemeProp;\n\nexport const StyledBrandButton = styled(BareButton)(({ theme }) => {\n return css`\n text-decoration: none;\n min-width: 0;\n\n & > div:last-child {\n min-width: 0;\n }\n\n &:not([disabled]):focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n});\n\nStyledBrandButton.defaultProps = defaultThemeProp;\n\nexport const StyledBrandImage = styled(Image)(\n ({\n theme: {\n base: { breakpoints }\n }\n }) => {\n return css`\n height: 1.5rem;\n max-width: 17ch;\n display: none;\n\n @media (min-width: ${breakpoints.sm}) {\n display: unset;\n }\n `;\n }\n);\n\nexport const StyledContext = styled.span`\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n`;\n\nexport const StyledTabs: typeof Tabs = styled(Tabs)(\n ({\n theme: {\n base: { breakpoints, 'font-weight': fontWeight }\n }\n }) => {\n return css`\n display: none;\n border: none;\n min-height: 3rem;\n [role='tab'] {\n height: auto;\n span:first-of-type {\n text-transform: none;\n }\n }\n [role='tab'][aria-selected='false'] > span {\n font-weight: ${fontWeight['semi-bold']};\n }\n [role='tab']:hover,\n [role='tab']:focus,\n [role='tab']:active {\n box-shadow: none;\n }\n\n @media (min-width: ${breakpoints.md}) {\n display: inherit;\n }\n `;\n }\n);\n\nStyledTabs.defaultProps = defaultThemeProp;\n\nexport const StyledAppHeaderSearch = styled.div(\n ({\n theme: {\n base: { spacing, breakpoints, 'content-width': contentWidth }\n }\n }) => {\n return css`\n padding-block: ${spacing};\n width: 100%;\n ${StyledAppHeaderSearchForm} {\n margin-inline-start: 0;\n max-width: 100%;\n }\n\n @media (min-width: ${breakpoints.md}) {\n ${StyledAppHeaderSearchForm} {\n margin-inline-start: auto;\n max-width: ${contentWidth.lg};\n }\n\n ${StyledButton} {\n display: none;\n }\n }\n `;\n }\n);\n\nStyledAppHeaderSearch.defaultProps = defaultThemeProp;\n\nexport const StyledUtilsContainer = styled.div(\n ({\n theme: {\n base: { spacing, breakpoints }\n }\n }) => {\n return css`\n width: 100%;\n & > div,\n & > span,\n & > button {\n margin-inline-start: ${spacing};\n }\n\n @media (min-width: ${breakpoints.md}) {\n width: auto;\n }\n `;\n }\n);\n\nStyledUtilsContainer.defaultProps = defaultThemeProp;\n\nexport const StyledAppName: typeof Text = styled(Text)(({ theme }) => {\n return css`\n max-width: ${theme.base['content-width'].sm};\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n color: ${theme.base.palette['foreground-color']};\n font-weight: ${theme.base['font-weight']['semi-bold']};\n margin-inline-start: 0;\n `;\n});\n\nStyledAppName.defaultProps = defaultThemeProp;\n\nexport const StyledAppVersion: typeof Text = styled(Text)(({ theme }) => {\n return css`\n font-weight: ${theme.base['font-weight']['semi-bold']};\n margin-inline-start: 0;\n `;\n});\n\nStyledAppVersion.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Ref, MouseEvent } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { AppShellProps, OmitStrict, Action, BaseProps, NoChildrenProp, Tab, AvatarProps, SearchInputProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { ContextSwitcherProps } from '@pega/cosmos-react-core/lib/components/AppShell/AppShell.types';
|
|
3
4
|
import { BranchButtonProps } from './BranchButton';
|
|
4
|
-
export interface
|
|
5
|
+
export interface OperatorProps extends OmitStrict<AppShellProps['operator'], 'avatar'> {
|
|
6
|
+
avatar: Pick<AvatarProps, 'name' | 'imageSrc'>;
|
|
5
7
|
}
|
|
6
8
|
export interface AppHeaderProps extends BaseProps, NoChildrenProp {
|
|
7
|
-
|
|
8
|
-
onContextClick?: MenuProps['onItemClick'];
|
|
9
|
+
contextSwitcher: ContextSwitcherProps;
|
|
9
10
|
brand: {
|
|
10
11
|
label: string;
|
|
11
12
|
logo: string;
|
|
@@ -20,7 +21,7 @@ export interface LinkProps extends Tab {
|
|
|
20
21
|
onClick?: (id: string, e?: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
|
|
21
22
|
}
|
|
22
23
|
export interface UtilsProps {
|
|
23
|
-
|
|
24
|
+
operator: OperatorProps;
|
|
24
25
|
search?: SearchInputProps;
|
|
25
26
|
branch?: BranchButtonProps;
|
|
26
27
|
action?: Pick<Action, 'id' | 'text' | 'onClick' | 'disabled' | 'icon'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppHeader.types.d.ts","sourceRoot":"","sources":["../../../../src/components/AppShell/Header/AppHeader.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EACL,aAAa,EACb,UAAU,EACV,MAAM,EACN,SAAS,EACT,cAAc,EACd,GAAG,EACH,WAAW,EACX,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAC;AAEtG,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,aAAc,SAAQ,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC;IACpF,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;CAChD;AACD,MAAM,WAAW,cAAe,SAAQ,SAAS,EAAE,cAAc;IAC/D,eAAe,EAAE,oBAAoB,CAAC;IACtC,KAAK,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,KAAK,IAAI,CAAC;KAC1E,CAAC;IACF,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,MAAM,WAAW,SAAU,SAAQ,GAAG;IACpC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,KAAK,IAAI,CAAC;CACvF;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;IACvE,OAAO,CAAC,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppHeader.types.js","sourceRoot":"","sources":["../../../../src/components/AppShell/Header/AppHeader.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref, MouseEvent } from 'react';\n\nimport {\n AppShellProps,\n OmitStrict,\n Action,\n BaseProps,\n NoChildrenProp,\n Tab,\n AvatarProps,\n SearchInputProps\n} from '@pega/cosmos-react-core';\nimport { ContextSwitcherProps } from '@pega/cosmos-react-core/lib/components/AppShell/AppShell.types';\n\nimport { BranchButtonProps } from './BranchButton';\n\nexport interface OperatorProps extends OmitStrict<AppShellProps['operator'], 'avatar'> {\n avatar: Pick<AvatarProps, 'name' | 'imageSrc'>;\n}\nexport interface AppHeaderProps extends BaseProps, NoChildrenProp {\n contextSwitcher: ContextSwitcherProps;\n brand: {\n label: string;\n logo: string;\n href?: string;\n onClick?: (e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;\n };\n links?: LinkProps[];\n utils?: UtilsProps;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport interface LinkProps extends Tab {\n onClick?: (id: string, e?: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;\n}\n\nexport interface UtilsProps {\n operator: OperatorProps;\n search?: SearchInputProps;\n branch?: BranchButtonProps;\n action?: Pick<Action, 'id' | 'text' | 'onClick' | 'disabled' | 'icon'>;\n appInfo?: {\n name: string;\n version: string;\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BranchButton.d.ts","sourceRoot":"","sources":["../../../../src/components/AppShell/Header/BranchButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,iBAAiB,EAAiB,MAAM,OAAO,CAAC;AAInE,OAAO,EACL,MAAM,EACN,UAAU,EAGV,IAAI,EAGJ,SAAS,EAMT,WAAW,EAGZ,MAAM,yBAAyB,CAAC;AAQjC,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;IAChE,6CAA6C;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,KAAK,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/B,iCAAiC;IACjC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,kBAAkB,EAAE,OAAO,MAuDvC,CAAC;AAqBF,eAAO,MAAM,cAAc,EAAE,OAAO,IAIlC,CAAC;AAgBH,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAoEtD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -9,7 +9,7 @@ import * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icon
|
|
|
9
9
|
import { StyledCount } from '@pega/cosmos-react-core/lib/components/Badges/Count';
|
|
10
10
|
registerIcon(nodesDownSolidIcon, warnSolidIcon, caretDownIcon);
|
|
11
11
|
export const StyledBranchButton = styled(Button)(({ theme, branchVariant }) => {
|
|
12
|
-
const { base: { colors, palette: { 'primary-background': primaryBackground }, shadow: { focus }, spacing }, components: { badges: { status, count: {
|
|
12
|
+
const { base: { colors, palette: { 'primary-background': primaryBackground }, shadow: { focus }, spacing }, components: { badges: { status, count: { default: { background, foreground } } } } } = theme;
|
|
13
13
|
const backgroundColor = branchVariant ? status[branchVariant].background : primaryBackground;
|
|
14
14
|
const borderColor = !branchVariant ? colors.gray.medium : 'transparent';
|
|
15
15
|
const countBgColor = branchVariant === 'success' ? colors.green.medium : background;
|
|
@@ -54,7 +54,7 @@ export const StyledWarnIcon = styled(Icon)(({ theme }) => {
|
|
|
54
54
|
`;
|
|
55
55
|
});
|
|
56
56
|
StyledWarnIcon.defaultProps = defaultThemeProp;
|
|
57
|
-
const
|
|
57
|
+
const StyledEllipsizedText = styled.span(({ theme }) => {
|
|
58
58
|
return css `
|
|
59
59
|
max-width: ${theme.base['content-width'].xs};
|
|
60
60
|
white-space: nowrap;
|
|
@@ -63,7 +63,7 @@ const StyledEllipsisedText = styled.span(({ theme }) => {
|
|
|
63
63
|
line-height: 1.5;
|
|
64
64
|
`;
|
|
65
65
|
});
|
|
66
|
-
|
|
66
|
+
StyledEllipsizedText.defaultProps = defaultThemeProp;
|
|
67
67
|
const BranchButton = (props) => {
|
|
68
68
|
const { text, variant, count, compact = false, items = [] } = props;
|
|
69
69
|
const [open, setOpen] = useState(false);
|
|
@@ -82,10 +82,10 @@ const BranchButton = (props) => {
|
|
|
82
82
|
else if (variant === 'urgent') {
|
|
83
83
|
ariaLabel = t('branch_with_potential_conflicts', [text]);
|
|
84
84
|
}
|
|
85
|
-
return (_jsxs(_Fragment, { children: [_jsx(StyledBranchButton, { ref: setButtonEl, "aria-expanded": open, "aria-haspopup": 'menu', "aria-controls": 'branch-popover', "aria-label": ariaLabel, branchVariant: variant, label: !open ? text : undefined, onClick: () => setOpen(cur => !cur), onKeyDown: (e) => {
|
|
85
|
+
return (_jsxs(_Fragment, { children: [_jsx(StyledBranchButton, { ref: setButtonEl, "aria-expanded": open, "aria-haspopup": 'menu', "aria-controls": 'branch-popover', "aria-label": ariaLabel, branchVariant: variant, label: !open && compact ? text : undefined, onClick: () => setOpen(cur => !cur), onKeyDown: (e) => {
|
|
86
86
|
if (e.key === 'Escape')
|
|
87
87
|
setOpen(false);
|
|
88
|
-
}, children: _jsxs(Flex, { container: { alignItems: 'center', gap: compact ? 1 : 0.5 }, children: [_jsx(Icon, { name: 'nodes-down-solid' }), !compact && (_jsxs(_Fragment, { children: [_jsx(
|
|
88
|
+
}, children: _jsxs(Flex, { container: { alignItems: 'center', gap: compact ? 1 : 0.5 }, children: [_jsx(Icon, { name: 'nodes-down-solid' }), !compact && (_jsxs(_Fragment, { children: [_jsx(StyledEllipsizedText, { children: text }), variant === 'urgent' ? (_jsx(StyledWarnIcon, { name: 'warn-solid' })) : (count !== undefined && _jsx(Count, { children: count }))] })), _jsx(Icon, { name: 'caret-down' })] }) }), _jsx(StyledBranchButtonPopover, { placement: rtl ? 'bottom-end' : 'bottom-start', id: 'branch-popover', hideOnTargetHidden: true, show: open, target: buttonEl, ref: setPopoverRef, children: _jsx(Menu, { items: items, scrollAt: 20, onItemClick: () => setOpen(false), focusControlEl: buttonEl || undefined }) })] }));
|
|
89
89
|
};
|
|
90
90
|
export default BranchButton;
|
|
91
91
|
//# sourceMappingURL=BranchButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BranchButton.js","sourceRoot":"","sources":["../../../../src/components/AppShell/Header/BranchButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAoC,MAAM,OAAO,CAAC;AACnE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAgB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,M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,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useState, FunctionComponent, KeyboardEvent } from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport {\n Button,\n CountProps,\n defaultThemeProp,\n Flex,\n Icon,\n Menu,\n Count,\n MenuProps,\n Popover,\n useDirection,\n useElement,\n registerIcon,\n useOuterEvent,\n StatusProps,\n useI18n,\n tryCatch\n} from '@pega/cosmos-react-core';\nimport * as nodesDownSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/nodes-down-solid.icon';\nimport * as warnSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/warn-solid.icon';\nimport * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';\nimport { StyledCount } from '@pega/cosmos-react-core/lib/components/Badges/Count';\n\nregisterIcon(nodesDownSolidIcon, warnSolidIcon, caretDownIcon);\n\nexport interface BranchButtonProps {\n /** The text for the BranchButton also used to set the aria-label. */\n text: string;\n /** Determines the variant for the BranchButton. */\n variant?: Extract<StatusProps['variant'], 'success' | 'urgent'>;\n /** Only display the branch and caret icon */\n compact?: boolean;\n /** The total count representing the number of unmerged changes. */\n count?: CountProps['children'];\n /** An array of MenuItemProps. */\n items: MenuProps['items'];\n}\n\nexport const StyledBranchButton: typeof Button = styled(Button)(\n ({\n theme,\n branchVariant\n }: {\n theme: DefaultTheme;\n branchVariant: BranchButtonProps['variant'];\n }) => {\n const {\n base: {\n colors,\n palette: { 'primary-background': primaryBackground },\n shadow: { focus },\n spacing\n },\n components: {\n badges: {\n status,\n count: {\n default: { background, foreground }\n }\n }\n }\n } = theme;\n\n const backgroundColor = branchVariant ? status[branchVariant].background : primaryBackground;\n const borderColor = !branchVariant ? colors.gray.medium : 'transparent';\n const countBgColor = branchVariant === 'success' ? colors.green.medium : background;\n const countColor = branchVariant === 'success' ? colors.white : foreground;\n const buttonColor = tryCatch(() => readableColor(backgroundColor));\n\n return css`\n flex-shrink: 0;\n background-color: ${backgroundColor};\n border-color: ${borderColor};\n color: ${buttonColor};\n padding-inline-start: ${spacing};\n padding-inline-end: ${spacing};\n\n &:hover {\n background-color: ${backgroundColor};\n box-shadow: ${focus};\n }\n\n svg {\n height: 1rem;\n width: 1rem;\n }\n\n ${StyledCount} {\n background-color: ${countBgColor};\n color: ${countColor};\n }\n `;\n }\n);\n\nStyledBranchButton.defaultProps = defaultThemeProp;\n\nconst StyledBranchButtonPopover = styled(Popover)(\n ({\n theme: {\n base: { spacing, 'content-width': contentWidth }\n }\n }) => {\n const minWidth = `calc(${contentWidth.xs} + (2 * ${spacing}))`;\n\n return css`\n min-width: ${minWidth};\n max-width: calc(${minWidth} + 5ch);\n `;\n }\n);\n\nStyledBranchButtonPopover.defaultProps = defaultThemeProp;\n\nexport const StyledWarnIcon: typeof Icon = styled(Icon)(({ theme }) => {\n return css`\n color: ${theme.base.colors.red.medium};\n `;\n});\n\nStyledWarnIcon.defaultProps = defaultThemeProp;\n\nconst StyledEllipsizedText = styled.span(({ theme }) => {\n return css`\n max-width: ${theme.base['content-width'].xs};\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.5;\n `;\n});\n\nStyledEllipsizedText.defaultProps = defaultThemeProp;\n\nconst BranchButton: FunctionComponent<BranchButtonProps> = (props: BranchButtonProps) => {\n const { text, variant, count, compact = false, items = [] } = props;\n\n const [open, setOpen] = useState(false);\n\n const [popoverEl, setPopoverRef] = useElement<HTMLElement>();\n const [buttonEl, setButtonEl] = useElement<HTMLElement>();\n const { rtl } = useDirection();\n const t = useI18n();\n\n useOuterEvent('mousedown', [popoverEl, buttonEl], () => {\n if (open) setOpen(false);\n });\n\n let ariaLabel = t('branch_with_no_changes', [text]);\n if (variant === 'success') {\n ariaLabel = t('branch_with_no_potential_conflicts', [text, count ?? 0]);\n } else if (variant === 'urgent') {\n ariaLabel = t('branch_with_potential_conflicts', [text]);\n }\n\n return (\n <>\n <StyledBranchButton\n ref={setButtonEl}\n aria-expanded={open}\n aria-haspopup='menu'\n aria-controls='branch-popover'\n aria-label={ariaLabel}\n branchVariant={variant}\n label={!open && compact ? text : undefined}\n onClick={() => setOpen(cur => !cur)}\n onKeyDown={(e: KeyboardEvent) => {\n if (e.key === 'Escape') setOpen(false);\n }}\n >\n <Flex container={{ alignItems: 'center', gap: compact ? 1 : 0.5 }}>\n <Icon name='nodes-down-solid' />\n {!compact && (\n <>\n <StyledEllipsizedText>{text}</StyledEllipsizedText>\n {variant === 'urgent' ? (\n <StyledWarnIcon name='warn-solid' />\n ) : (\n count !== undefined && <Count>{count}</Count>\n )}\n </>\n )}\n <Icon name='caret-down' />\n </Flex>\n </StyledBranchButton>\n <StyledBranchButtonPopover\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n id='branch-popover'\n hideOnTargetHidden\n show={open}\n target={buttonEl}\n ref={setPopoverRef}\n >\n <Menu\n items={items}\n scrollAt={20}\n onItemClick={() => setOpen(false)}\n focusControlEl={buttonEl || undefined}\n />\n </StyledBranchButtonPopover>\n </>\n );\n};\n\nexport default BranchButton;\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { NavProps, NavItemRenderProps } from './AppShell.types';
|
|
3
|
+
export declare const NavLinkItem: FunctionComponent<NavItemRenderProps>;
|
|
4
|
+
declare const NavigationList: FunctionComponent<NavProps>;
|
|
5
|
+
export default NavigationList;
|
|
6
|
+
//# sourceMappingURL=NavigationList.d.ts.map
|