@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectPreview.js","sourceRoot":"","sources":["../../../src/components/ObjectPreview/ObjectPreview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAIV,MAAM,EACN,SAAS,EAEV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAEL,OAAO,EAEP,MAAM,EACN,IAAI,EAEJ,IAAI,EACJ,aAAa,EAEb,MAAM,EACN,OAAO,EACP,kBAAkB,EAEnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,UAAU,EACV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AiB,GAAG,CAAC,CAAC;IAC3D,MAAM,gBAAgB,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAEzD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE;YAC9B,UAAU,CAAC,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;SACtD;IACH,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CACL,KAAC,mBAAmB,IAClB,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,CAAC,CAAC,IAAI,EACZ,cAAc,QACd,QAAQ,EAAC,OAAO,EAChB,IAAI,EAAC,KAAK,EACV,MAAM,QACN,SAAS,EAAC,OAAO,EACjB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,YAE5B,KAAC,aAAa,IACZ,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,EAAE,EAAE,UAAU,EACd,MAAM,EACJ,KAAC,aAAa,IAAC,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,KAAM,SAAS,GAAI,EAEtF,aAAa,QACb,CAAC,EAAE,OAAO,GACV,GACkB,CACvB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import {\n FC,\n forwardRef,\n PropsWithoutRef,\n ReactNode,\n Ref,\n useRef,\n useEffect,\n RefObject\n} from 'react';\nimport styled from 'styled-components';\n\nimport {\n Action,\n Actions,\n ActionsProps,\n Button,\n Flex,\n ForwardProps,\n Icon,\n OneColumnPage,\n OmitStrict,\n Drawer,\n useI18n,\n useConsolidatedRef,\n DrawerProps\n} from '@pega/cosmos-react-core';\nimport {\n PageHeaderProps,\n PageHeader,\n StyledPage\n} from '@pega/cosmos-react-build/lib/components/PageTemplates/PageTemplates';\n\nexport interface ObjectPreviewProps\n extends Pick<DrawerProps, 'onAfterOpen' | 'onAfterClose' | 'onBeforeOpen' | 'onBeforeClose'> {\n open?: boolean;\n header: OmitStrict<PageHeaderProps, 'status'>;\n primaryAction?: Pick<Action, 'text' | 'onClick' | 'disabled'>;\n secondaryAction?: Pick<Action, 'text' | 'onClick' | 'disabled'>;\n additionalActions?: ActionsProps;\n content: ReactNode;\n onDismiss: () => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledObjectPreview = styled(Drawer)`\n height: calc(100vh - 3rem);\n top: 3rem;\n`;\n\nconst PreviewHeader: FC<\n OmitStrict<ObjectPreviewProps, 'ref' | 'content' | 'open'> & {\n dismissButtonRef: RefObject<HTMLButtonElement>;\n }\n> = ({\n header,\n primaryAction,\n secondaryAction,\n additionalActions,\n onDismiss,\n dismissButtonRef\n}) => {\n const t = useI18n();\n return (\n <Flex container={{ direction: 'column', rowGap: 1 }}>\n <Flex container={{ justify: 'between' }}>\n <Button\n icon\n variant='simple'\n ref={dismissButtonRef}\n label={t('dismiss_label_a11y')}\n onClick={onDismiss}\n >\n <Icon name='times' />\n </Button>\n <Flex container>\n {secondaryAction && (\n <Button onClick={secondaryAction.onClick} disabled={secondaryAction.disabled}>\n {secondaryAction.text}\n </Button>\n )}\n {primaryAction && (\n <Button\n variant='primary'\n onClick={primaryAction.onClick}\n disabled={primaryAction.disabled}\n >\n {primaryAction.text}\n </Button>\n )}\n {additionalActions && <Actions {...additionalActions} />}\n </Flex>\n </Flex>\n <PageHeader {...header} titleTag='h2' />\n </Flex>\n );\n};\n\nconst ObjectPreview: FC<PropsWithoutRef<ObjectPreviewProps> & ForwardProps> = forwardRef(\n (\n { content, header, open, onAfterOpen, onAfterClose, onBeforeOpen, onBeforeClose, ...restprops },\n ref: ObjectPreviewProps['ref']\n ) => {\n const contentRef = useConsolidatedRef<HTMLDivElement>(ref);\n const dismissButtonRef = useRef<HTMLButtonElement>(null);\n\n useEffect(() => {\n if (open && contentRef.current) {\n contentRef.current?.querySelector('button')?.focus();\n }\n }, [open]);\n\n return (\n <StyledObjectPreview\n ref={contentRef}\n open={!!open}\n nullWhenClosed\n position='fixed'\n size='30%'\n shadow\n placement='right'\n onAfterOpen={onAfterOpen}\n onAfterClose={onAfterClose}\n onBeforeOpen={onBeforeOpen}\n onBeforeClose={onBeforeClose}\n >\n <OneColumnPage\n ref={contentRef}\n title={header.title}\n as={StyledPage}\n header={\n <PreviewHeader dismissButtonRef={dismissButtonRef} header={header} {...restprops} />\n }\n scrollContent\n a={content}\n />\n </StyledObjectPreview>\n );\n }\n);\n\nexport default ObjectPreview;\n"]}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { FC, Ref, PropsWithoutRef, MouseEvent } from 'react';
|
|
2
|
-
import { BaseProps, ForwardProps, FormControlProps, MenuItemProps
|
|
2
|
+
import { BaseProps, ForwardProps, FormControlProps, MenuItemProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { BaseDialogProps, FormDialogProps } from '@pega/cosmos-react-core/lib/components/Dialog/Dialog.types';
|
|
3
4
|
interface ObjectSummaryValueProps {
|
|
4
5
|
id: MenuItemProps['id'];
|
|
5
6
|
primary: MenuItemProps['primary'];
|
|
6
|
-
href
|
|
7
|
+
href?: string;
|
|
7
8
|
meta?: string;
|
|
8
9
|
}
|
|
9
|
-
interface ObjectConfigProps extends
|
|
10
|
+
interface ObjectConfigProps extends Pick<BaseDialogProps, 'children' | 'ref'> {
|
|
11
|
+
heading: NonNullable<FormDialogProps['heading']>;
|
|
10
12
|
label: string;
|
|
13
|
+
onOpen?: () => void;
|
|
14
|
+
onClose?: () => void;
|
|
15
|
+
onSubmit: (arg: {
|
|
16
|
+
close: () => void;
|
|
17
|
+
}) => void;
|
|
18
|
+
loading?: BaseDialogProps['progress'];
|
|
11
19
|
}
|
|
12
20
|
export interface ObjectSummaryProps extends BaseProps, Omit<FormControlProps, 'value'> {
|
|
13
21
|
value: ObjectSummaryValueProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectSummary.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSummary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAc,GAAG,EAAE,eAAe,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"ObjectSummary.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSummary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAc,GAAG,EAAE,eAAe,EAAE,UAAU,EAAsB,MAAM,OAAO,CAAC;AAG7F,OAAO,EACL,SAAS,EAIT,YAAY,EAGZ,gBAAgB,EAChB,aAAa,EAad,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,eAAe,EACf,eAAe,EAChB,MAAM,4DAA4D,CAAC;AAIpE,UAAU,uBAAuB;IAC/B,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IACxB,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,iBAAkB,SAAQ,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,KAAK,CAAC;IAC3E,OAAO,EAAE,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/C,OAAO,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,kBAAmB,SAAQ,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACpF,KAAK,EAAE,uBAAuB,CAAC;IAC/B,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,QAAQ,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACrD,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAC/D,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC1B;AAoDD,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC,GAAG,YAAY,CA+HzE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
2
|
+
import { forwardRef, useEffect, useMemo } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { SummaryItem, Button, Icon, StyledFormControl, FormField, useI18n, registerIcon, Text,
|
|
4
|
+
import { SummaryItem, Button, Icon, StyledFormControl, FormField, useI18n, registerIcon, Text, useElement, Link, defaultThemeProp, StyledLink, useUID, FormDialog, InfoDialog, StyledButton, StyledSummaryItemActions } from '@pega/cosmos-react-core';
|
|
5
5
|
import * as times from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
6
6
|
import * as gear from '@pega/cosmos-react-core/lib/components/Icon/icons/gear.icon';
|
|
7
7
|
registerIcon(times, gear);
|
|
8
|
-
const StyledObjectSummary = styled(StyledFormControl)(({ theme: { base: { spacing, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }, shadow: { 'focus-inset': focusInset } } }, meta }) => {
|
|
8
|
+
const StyledObjectSummary = styled(StyledFormControl)(({ theme: { base: { spacing, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }, shadow: { 'focus-inset': focusInset } }, components: { 'form-control': { 'border-width': borderWidth } } }, meta }) => {
|
|
9
9
|
return css `
|
|
10
10
|
padding-block: ${meta ? spacing : '0'};
|
|
11
11
|
padding-inline-start: ${spacing};
|
|
@@ -15,8 +15,19 @@ const StyledObjectSummary = styled(StyledFormControl)(({ theme: { base: { spacin
|
|
|
15
15
|
box-shadow: ${focusInset};
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
${StyledSummaryItemActions} > ${StyledButton} {
|
|
19
|
+
margin-block: calc(-1 * ${borderWidth});
|
|
20
|
+
min-width: calc(${hitAreaMouse} - 2 * ${borderWidth});
|
|
21
|
+
min-height: calc(${hitAreaMouse} - 2 * ${borderWidth});
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
@media (pointer: coarse) {
|
|
19
25
|
min-height: ${hitAreaFinger};
|
|
26
|
+
|
|
27
|
+
${StyledSummaryItemActions} > ${StyledButton} {
|
|
28
|
+
min-width: calc(${hitAreaFinger} - 2 * ${borderWidth});
|
|
29
|
+
min-height: calc(${hitAreaFinger} - 2 * ${borderWidth});
|
|
30
|
+
}
|
|
20
31
|
}
|
|
21
32
|
`;
|
|
22
33
|
});
|
|
@@ -27,19 +38,44 @@ const StyledMetaText = styled(Text) `
|
|
|
27
38
|
-webkit-line-clamp: 2;
|
|
28
39
|
overflow: hidden;
|
|
29
40
|
`;
|
|
30
|
-
const ScrollContainer = styled.div(({ theme: { base: { spacing } } }) => {
|
|
31
|
-
return css `
|
|
32
|
-
max-height: 12rem;
|
|
33
|
-
overflow: auto;
|
|
34
|
-
padding: calc(0.25 * ${spacing});
|
|
35
|
-
`;
|
|
36
|
-
});
|
|
37
|
-
ScrollContainer.defaultProps = defaultThemeProp;
|
|
38
41
|
const ObjectSummary = forwardRef(({ value, configuration, label, disabled, status, readOnly, onDelete, onPreview, onLinkClick, ...restProps }, ref) => {
|
|
39
|
-
const [
|
|
42
|
+
const [configTarget, setConfigTarget] = useElement();
|
|
40
43
|
const t = useI18n();
|
|
41
|
-
const
|
|
42
|
-
|
|
44
|
+
const describedById = useUID();
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (configTarget)
|
|
47
|
+
configuration?.onOpen?.();
|
|
48
|
+
}, [configTarget]);
|
|
49
|
+
const configDialog = useMemo(() => {
|
|
50
|
+
if (!configuration || !configTarget || disabled)
|
|
51
|
+
return null;
|
|
52
|
+
const commonProps = {
|
|
53
|
+
heading: configuration.heading,
|
|
54
|
+
target: configTarget,
|
|
55
|
+
progress: configuration.loading,
|
|
56
|
+
ref: configuration.ref,
|
|
57
|
+
children: configuration.children
|
|
58
|
+
};
|
|
59
|
+
if (readOnly) {
|
|
60
|
+
return (_jsx(InfoDialog, { ...commonProps, onDismiss: () => {
|
|
61
|
+
setConfigTarget(null);
|
|
62
|
+
configuration.onClose?.();
|
|
63
|
+
} }));
|
|
64
|
+
}
|
|
65
|
+
return (_jsx(FormDialog, { ...commonProps, onCancel: () => {
|
|
66
|
+
setConfigTarget(null);
|
|
67
|
+
configuration.onClose?.();
|
|
68
|
+
}, onSubmit: () => {
|
|
69
|
+
configuration.onSubmit({
|
|
70
|
+
close: () => {
|
|
71
|
+
setConfigTarget(null);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
} }));
|
|
75
|
+
}, [configTarget, configuration, disabled, readOnly]);
|
|
76
|
+
return (_jsx(FormField, { ...restProps, ref: ref, label: label, status: status, disabled: disabled, children: _jsx(SummaryItem, { as: StyledObjectSummary, status: status, meta: value.meta, readOnly: readOnly, overflowStrategy: 'ellipsis', primary: disabled || !value.href ? (_jsx(Text, { id: describedById, children: value.primary })) : (_jsx(Link, { href: value.href, "aria-label": `${label} ${value.primary}`, previewable: true, onPreview: onPreview, onClick: onLinkClick ? (e) => onLinkClick(value.id, e) : undefined, children: value.primary })), secondary: value.meta && _jsx(StyledMetaText, { variant: 'secondary', children: value.meta }), actions: _jsxs(_Fragment, { children: [configuration && (_jsx(Button, { disabled: disabled, label: configuration?.label, icon: true, variant: 'simple', onClick: (e) => {
|
|
77
|
+
setConfigTarget(e.currentTarget);
|
|
78
|
+
}, "aria-describedby": describedById, children: _jsx(Icon, { name: 'gear' }) })), !readOnly && (_jsx(Button, { disabled: disabled, label: t('clear_object_summary', [String(label)]), icon: true, variant: 'simple', onClick: onDelete, "aria-describedby": describedById, children: _jsx(Icon, { name: 'times' }) })), configDialog] }) }) }));
|
|
43
79
|
});
|
|
44
80
|
export default ObjectSummary;
|
|
45
81
|
//# sourceMappingURL=ObjectSummary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectSummary.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSummary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAoC,MAAM,OAAO,CAAC;AACzE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAEL,WAAW,EACX,MAAM,EACN,IAAI,EAEJ,iBAAiB,EACjB,SAAS,EAGT,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,MAAM,EACN,gBAAgB,EAGhB,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,8DAA8D,CAAC;AACtF,OAAO,KAAK,IAAI,MAAM,6DAA6D,CAAC;AAEpF,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAsB1B,MAAM,mBAAmB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CACnD,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EACP,UAAU,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,EACtE,MAAM,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,EACtC,EACF,EACD,IAA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E,aAAa,CAAC,MAAM,EAC5B,OAAO,EAAE,aAAa,CAAC,OAAO,EAC9B,QAAQ,EAAE,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,EAAE,QAAQ,EACpE,OAAO,EAAE,aAAa,CAAC,OAAO,EAC9B,GAAG,EAAE,aAAa,CAAC,GAAG,YAEtB,KAAC,eAAe,cAAE,aAAa,EAAE,QAAQ,GAAmB,GACrD,CACV,IACA,GAEL,GACQ,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FC, forwardRef, Ref, PropsWithoutRef, MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n BaseProps,\n SummaryItem,\n Button,\n Icon,\n ForwardProps,\n StyledFormControl,\n FormField,\n FormControlProps,\n MenuItemProps,\n useI18n,\n registerIcon,\n Text,\n useDirection,\n useElement,\n Link,\n Dialog,\n defaultThemeProp,\n DialogProps,\n OmitStrict,\n StyledLink\n} from '@pega/cosmos-react-core';\nimport * as times from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as gear from '@pega/cosmos-react-core/lib/components/Icon/icons/gear.icon';\n\nregisterIcon(times, gear);\n\ninterface ObjectSummaryValueProps {\n id: MenuItemProps['id'];\n primary: MenuItemProps['primary'];\n href: string;\n meta?: string;\n}\n\ninterface ObjectConfigProps extends OmitStrict<DialogProps, 'target'> {\n label: string;\n}\n\nexport interface ObjectSummaryProps extends BaseProps, Omit<FormControlProps, 'value'> {\n value: ObjectSummaryValueProps;\n configuration?: ObjectConfigProps;\n onDelete: (e: MouseEvent<HTMLButtonElement>) => void;\n onPreview?: (e: { href: string }) => void;\n onLinkClick?: (id: MenuItemProps['id'], e: MouseEvent) => void;\n ref: Ref<HTMLDivElement>;\n}\n\nconst StyledObjectSummary = styled(StyledFormControl)<{ meta: string }>(\n ({\n theme: {\n base: {\n spacing,\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger },\n shadow: { 'focus-inset': focusInset }\n }\n },\n meta\n }) => {\n return css`\n padding-block: ${meta ? spacing : '0'};\n padding-inline-start: ${spacing};\n min-height: ${hitAreaMouse};\n\n ${StyledLink}:focus {\n box-shadow: ${focusInset};\n }\n\n @media (pointer: coarse) {\n min-height: ${hitAreaFinger};\n }\n `;\n }\n);\n\nStyledObjectSummary.defaultProps = defaultThemeProp;\n\nconst StyledMetaText = styled(Text)`\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n overflow: hidden;\n`;\n\nconst ScrollContainer = styled.div(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n max-height: 12rem;\n overflow: auto;\n padding: calc(0.25 * ${spacing});\n `;\n }\n);\n\nScrollContainer.defaultProps = defaultThemeProp;\n\nconst ObjectSummary: FC<PropsWithoutRef<ObjectSummaryProps> & ForwardProps> = forwardRef(\n (\n {\n value,\n configuration,\n label,\n disabled,\n status,\n readOnly,\n onDelete,\n onPreview,\n onLinkClick,\n ...restProps\n },\n ref: ObjectSummaryProps['ref']\n ) => {\n const [buttonEl, setButtonEl] = useElement<HTMLButtonElement>();\n const t = useI18n();\n const { rtl } = useDirection();\n\n return (\n <FormField {...restProps} ref={ref} label={label} status={status} disabled={disabled}>\n <SummaryItem\n as={StyledObjectSummary}\n status={status}\n meta={value.meta}\n readOnly={readOnly}\n overflowStrategy='ellipsis'\n primary={\n disabled ? (\n <Text>{value.primary}</Text>\n ) : (\n <Link\n href={value.href}\n aria-label={`${label} ${value.primary}`}\n previewable\n onPreview={onPreview}\n onClick={onLinkClick ? (e: MouseEvent) => onLinkClick(value.id, e) : undefined}\n >\n {value.primary}\n </Link>\n )\n }\n secondary={\n value.meta && <StyledMetaText variant='secondary'>{value.meta}</StyledMetaText>\n }\n actions={\n <>\n {configuration && (\n <Button\n disabled={disabled}\n ref={setButtonEl}\n label={configuration?.label}\n icon\n variant='simple'\n >\n <Icon name='gear' />\n </Button>\n )}\n {!readOnly && (\n <Button\n disabled={disabled}\n label={t('clear_object_summary', [String(label)])}\n icon\n variant='simple'\n onClick={onDelete}\n >\n <Icon name='times' />\n </Button>\n )}\n {configuration && (\n <Dialog\n heading={configuration.heading}\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n target={buttonEl}\n onOpen={configuration.onOpen}\n onClose={configuration.onClose}\n onSubmit={readOnly || disabled ? undefined : configuration?.onSubmit}\n loading={configuration.loading}\n ref={configuration.ref}\n >\n <ScrollContainer>{configuration?.children}</ScrollContainer>\n </Dialog>\n )}\n </>\n }\n />\n </FormField>\n );\n }\n);\n\nexport default ObjectSummary;\n"]}
|
|
1
|
+
{"version":3,"file":"ObjectSummary.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSummary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAoC,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAEL,WAAW,EACX,MAAM,EACN,IAAI,EAEJ,iBAAiB,EACjB,SAAS,EAGT,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,UAAU,EACV,UAAU,EACV,YAAY,EACZ,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,8DAA8D,CAAC;AACtF,OAAO,KAAK,IAAI,MAAM,6DAA6D,CAAC;AAMpF,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AA2B1B,MAAM,mBAAmB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CACnD,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EACP,UAAU,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,EACtE,MAAM,EAA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FC, forwardRef, Ref, PropsWithoutRef, MouseEvent, useEffect, useMemo } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n BaseProps,\n SummaryItem,\n Button,\n Icon,\n ForwardProps,\n StyledFormControl,\n FormField,\n FormControlProps,\n MenuItemProps,\n useI18n,\n registerIcon,\n Text,\n useElement,\n Link,\n defaultThemeProp,\n StyledLink,\n useUID,\n FormDialog,\n InfoDialog,\n StyledButton,\n StyledSummaryItemActions\n} from '@pega/cosmos-react-core';\nimport * as times from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as gear from '@pega/cosmos-react-core/lib/components/Icon/icons/gear.icon';\nimport {\n BaseDialogProps,\n FormDialogProps\n} from '@pega/cosmos-react-core/lib/components/Dialog/Dialog.types';\n\nregisterIcon(times, gear);\n\ninterface ObjectSummaryValueProps {\n id: MenuItemProps['id'];\n primary: MenuItemProps['primary'];\n href?: string;\n meta?: string;\n}\n\ninterface ObjectConfigProps extends Pick<BaseDialogProps, 'children' | 'ref'> {\n heading: NonNullable<FormDialogProps['heading']>;\n label: string;\n onOpen?: () => void;\n onClose?: () => void;\n onSubmit: (arg: { close: () => void }) => void;\n loading?: BaseDialogProps['progress'];\n}\n\nexport interface ObjectSummaryProps extends BaseProps, Omit<FormControlProps, 'value'> {\n value: ObjectSummaryValueProps;\n configuration?: ObjectConfigProps;\n onDelete: (e: MouseEvent<HTMLButtonElement>) => void;\n onPreview?: (e: { href: string }) => void;\n onLinkClick?: (id: MenuItemProps['id'], e: MouseEvent) => void;\n ref: Ref<HTMLDivElement>;\n}\n\nconst StyledObjectSummary = styled(StyledFormControl)<{ meta: string }>(\n ({\n theme: {\n base: {\n spacing,\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger },\n shadow: { 'focus-inset': focusInset }\n },\n components: {\n 'form-control': { 'border-width': borderWidth }\n }\n },\n meta\n }) => {\n return css`\n padding-block: ${meta ? spacing : '0'};\n padding-inline-start: ${spacing};\n min-height: ${hitAreaMouse};\n\n ${StyledLink}:focus {\n box-shadow: ${focusInset};\n }\n\n ${StyledSummaryItemActions} > ${StyledButton} {\n margin-block: calc(-1 * ${borderWidth});\n min-width: calc(${hitAreaMouse} - 2 * ${borderWidth});\n min-height: calc(${hitAreaMouse} - 2 * ${borderWidth});\n }\n\n @media (pointer: coarse) {\n min-height: ${hitAreaFinger};\n\n ${StyledSummaryItemActions} > ${StyledButton} {\n min-width: calc(${hitAreaFinger} - 2 * ${borderWidth});\n min-height: calc(${hitAreaFinger} - 2 * ${borderWidth});\n }\n }\n `;\n }\n);\n\nStyledObjectSummary.defaultProps = defaultThemeProp;\n\nconst StyledMetaText = styled(Text)`\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n overflow: hidden;\n`;\n\nconst ObjectSummary: FC<PropsWithoutRef<ObjectSummaryProps> & ForwardProps> = forwardRef(\n (\n {\n value,\n configuration,\n label,\n disabled,\n status,\n readOnly,\n onDelete,\n onPreview,\n onLinkClick,\n ...restProps\n },\n ref: ObjectSummaryProps['ref']\n ) => {\n const [configTarget, setConfigTarget] = useElement<HTMLButtonElement>();\n const t = useI18n();\n const describedById = useUID();\n\n useEffect(() => {\n if (configTarget) configuration?.onOpen?.();\n }, [configTarget]);\n\n const configDialog = useMemo(() => {\n if (!configuration || !configTarget || disabled) return null;\n\n const commonProps: Pick<BaseDialogProps, 'target' | 'progress' | 'ref' | 'children'> &\n Pick<ObjectConfigProps, 'heading'> = {\n heading: configuration.heading,\n target: configTarget,\n progress: configuration.loading,\n ref: configuration.ref,\n children: configuration.children\n };\n\n if (readOnly) {\n return (\n <InfoDialog\n {...commonProps}\n onDismiss={() => {\n setConfigTarget(null);\n configuration.onClose?.();\n }}\n />\n );\n }\n\n return (\n <FormDialog\n {...commonProps}\n onCancel={() => {\n setConfigTarget(null);\n configuration.onClose?.();\n }}\n onSubmit={() => {\n configuration.onSubmit({\n close: () => {\n setConfigTarget(null);\n }\n });\n }}\n />\n );\n }, [configTarget, configuration, disabled, readOnly]);\n\n return (\n <FormField {...restProps} ref={ref} label={label} status={status} disabled={disabled}>\n <SummaryItem\n as={StyledObjectSummary}\n status={status}\n meta={value.meta}\n readOnly={readOnly}\n overflowStrategy='ellipsis'\n primary={\n disabled || !value.href ? (\n <Text id={describedById}>{value.primary}</Text>\n ) : (\n <Link\n href={value.href}\n aria-label={`${label} ${value.primary}`}\n previewable\n onPreview={onPreview}\n onClick={onLinkClick ? (e: MouseEvent) => onLinkClick(value.id, e) : undefined}\n >\n {value.primary}\n </Link>\n )\n }\n secondary={\n value.meta && <StyledMetaText variant='secondary'>{value.meta}</StyledMetaText>\n }\n actions={\n <>\n {configuration && (\n <Button\n disabled={disabled}\n label={configuration?.label}\n icon\n variant='simple'\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n setConfigTarget(e.currentTarget);\n }}\n aria-describedby={describedById}\n >\n <Icon name='gear' />\n </Button>\n )}\n {!readOnly && (\n <Button\n disabled={disabled}\n label={t('clear_object_summary', [String(label)])}\n icon\n variant='simple'\n onClick={onDelete}\n aria-describedby={describedById}\n >\n <Icon name='times' />\n </Button>\n )}\n {configDialog}\n </>\n }\n />\n </FormField>\n );\n }\n);\n\nexport default ObjectSummary;\n"]}
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { ModalProps } from '@pega/cosmos-react-core';
|
|
3
3
|
export interface UseCreateModalConfig<P extends object = object> {
|
|
4
|
-
renderer: ComponentType<P>;
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* Heading for the Modal.
|
|
6
|
+
* @default 'Create new'
|
|
7
7
|
*/
|
|
8
|
+
heading?: string;
|
|
9
|
+
/** A component to render the add new form. */
|
|
10
|
+
renderer: ComponentType<P>;
|
|
11
|
+
/** Called when a user submits a form. */
|
|
8
12
|
onSubmit: ({ close }: {
|
|
9
13
|
close: () => void;
|
|
10
14
|
}) => void;
|
|
11
|
-
/**
|
|
12
|
-
* Called when a user cancels a form.
|
|
13
|
-
*/
|
|
15
|
+
/** Called when a user cancels a form. */
|
|
14
16
|
onDismiss: ({ close }: {
|
|
15
17
|
close: () => void;
|
|
16
18
|
}) => void;
|
|
17
|
-
/**
|
|
18
|
-
* Called before the modal opens.
|
|
19
|
-
*/
|
|
19
|
+
/** Called before the modal opens. */
|
|
20
20
|
onBeforeOpen?: ModalProps['onBeforeOpen'];
|
|
21
|
-
/**
|
|
22
|
-
* Called after the modal closes.
|
|
23
|
-
*/
|
|
21
|
+
/** Called after the modal closes. */
|
|
24
22
|
onAfterClose?: ModalProps['onAfterClose'];
|
|
25
23
|
}
|
|
26
24
|
export interface CreateModalActionProps<P extends object = object> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateModal.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/useCreateModal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAIL,UAAU,EAIX,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"useCreateModal.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/useCreateModal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAIL,UAAU,EAIX,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAC7D;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAC3B,yCAAyC;IACzC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IACrD,yCAAyC;IACzC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IACtD,qCAAqC;IACrC,YAAY,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IAC1C,qCAAqC;IACrC,YAAY,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,CAAC,CAAC;CAClB;AAED,QAAA,MAAM,cAAc;;CA0FnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -7,12 +7,9 @@ const useCreateModal = (config) => {
|
|
|
7
7
|
const modalMethods = useRef();
|
|
8
8
|
const { create: createModal } = useModalManager();
|
|
9
9
|
if (config) {
|
|
10
|
-
const { renderer: Renderer, onSubmit, onDismiss, onBeforeOpen, onAfterClose } = config;
|
|
10
|
+
const { renderer: Renderer, onSubmit, onDismiss, onBeforeOpen, onAfterClose, heading = t('create_new') } = config;
|
|
11
11
|
const renderModal = ({ rendererProps, loading = false }) => {
|
|
12
|
-
|
|
13
|
-
if (!loading) {
|
|
14
|
-
modalContent = _jsx(Renderer, { ...rendererProps });
|
|
15
|
-
}
|
|
12
|
+
const modalContent = _jsx(Renderer, { ...rendererProps });
|
|
16
13
|
let formActions = null;
|
|
17
14
|
if (!loading || submittingRef.current) {
|
|
18
15
|
const close = () => {
|
|
@@ -40,12 +37,14 @@ const useCreateModal = (config) => {
|
|
|
40
37
|
else {
|
|
41
38
|
modalMethods.current = createModal(Modal, {
|
|
42
39
|
...modalProps,
|
|
43
|
-
heading
|
|
40
|
+
heading,
|
|
44
41
|
onBeforeOpen,
|
|
45
42
|
onAfterClose: () => {
|
|
46
43
|
onAfterClose?.();
|
|
47
44
|
submittingRef.current = false;
|
|
48
45
|
}
|
|
46
|
+
}, {
|
|
47
|
+
dismissible: false
|
|
49
48
|
});
|
|
50
49
|
}
|
|
51
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateModal.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/useCreateModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAA4B,MAAM,OAAO,CAAC;AAEzD,OAAO,EAEL,MAAM,EAGN,KAAK,EACL,eAAe,EACf,OAAO,EACR,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"useCreateModal.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/useCreateModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAA4B,MAAM,OAAO,CAAC;AAEzD,OAAO,EAEL,MAAM,EAGN,KAAK,EACL,eAAe,EACf,OAAO,EACR,MAAM,yBAAyB,CAAC;AAyBjC,MAAM,cAAc,GAAG,CAA4B,MAA2C,EAAE,EAAE;IAChG,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,YAAY,GAAG,MAAM,EAAgB,CAAC;IAC5C,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,eAAe,EAAE,CAAC;IAElD,IAAI,MAAM,EAAE;QACV,MAAM,EACJ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,OAAO,GAAG,CAAC,CAAC,YAAY,CAAC,EAC1B,GAAG,MAAM,CAAC;QACX,MAAM,WAAW,GAAG,CAAC,EAAE,aAAa,EAAE,OAAO,GAAG,KAAK,EAA6B,EAAE,EAAE;YACpF,MAAM,YAAY,GAAc,KAAC,QAAQ,OAAK,aAAa,GAAI,CAAC;YAEhE,IAAI,WAAW,GAAc,IAAI,CAAC;YAElC,IAAI,CAAC,OAAO,IAAI,aAAa,CAAC,OAAO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;oBACP,YAAY;oBACZ,YAAY,EAAE,GAAG,EAAE;wBACjB,YAAY,EAAE,EAAE,CAAC;wBACjB,aAAa,CAAC,OAAO,GAAG,KAAK,CAAC;oBAChC,CAAC;iBACF,EACD;oBACE,WAAW,EAAE,KAAK;iBACnB,CACF,CAAC;aACH;QACH,CAAC,CAAC;QAEF,OAAO;YACL,WAAW;SACZ,CAAC;KACH;IAED,OAAO;QACL,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;KACtB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useRef, ReactNode, ComponentType } from 'react';\n\nimport {\n ModalMethods,\n Button,\n OmitStrict,\n ModalProps,\n Modal,\n useModalManager,\n useI18n\n} from '@pega/cosmos-react-core';\n\nexport interface UseCreateModalConfig<P extends object = object> {\n /**\n * Heading for the Modal.\n * @default 'Create new'\n */\n heading?: string;\n /** A component to render the add new form. */\n renderer: ComponentType<P>;\n /** Called when a user submits a form. */\n onSubmit: ({ close }: { close: () => void }) => void;\n /** Called when a user cancels a form. */\n onDismiss: ({ close }: { close: () => void }) => void;\n /** Called before the modal opens. */\n onBeforeOpen?: ModalProps['onBeforeOpen'];\n /** Called after the modal closes. */\n onAfterClose?: ModalProps['onAfterClose'];\n}\n\nexport interface CreateModalActionProps<P extends object = object> {\n loading?: boolean;\n rendererProps: P;\n}\n\nconst useCreateModal = <P extends object = object>(config: UseCreateModalConfig<P> | undefined) => {\n const t = useI18n();\n\n const submittingRef = useRef(false);\n const modalMethods = useRef<ModalMethods>();\n const { create: createModal } = useModalManager();\n\n if (config) {\n const {\n renderer: Renderer,\n onSubmit,\n onDismiss,\n onBeforeOpen,\n onAfterClose,\n heading = t('create_new')\n } = config;\n const renderModal = ({ rendererProps, loading = false }: CreateModalActionProps<P>) => {\n const modalContent: ReactNode = <Renderer {...rendererProps} />;\n\n let formActions: ReactNode = null;\n\n if (!loading || submittingRef.current) {\n const close = () => {\n modalMethods.current?.dismiss();\n modalMethods.current = undefined;\n };\n\n formActions = (\n <>\n <Button\n disabled={loading}\n onClick={() => {\n onDismiss({ close });\n }}\n >\n {t('cancel')}\n </Button>\n <Button\n disabled={loading}\n type='submit'\n variant='primary'\n onClick={() => {\n submittingRef.current = true;\n onSubmit({ close });\n }}\n >\n {t('submit')}\n </Button>\n </>\n );\n }\n\n const modalProps: OmitStrict<ModalProps, 'heading'> = {\n progress: loading\n ? { message: submittingRef.current ? t('submitting') : t('loading') }\n : undefined,\n children: modalContent,\n actions: formActions,\n onRequestDismiss: loading && submittingRef.current ? () => false : undefined\n };\n\n if (modalMethods.current) {\n modalMethods.current.update(modalProps);\n } else {\n modalMethods.current = createModal(\n Modal,\n {\n ...modalProps,\n heading,\n onBeforeOpen,\n onAfterClose: () => {\n onAfterClose?.();\n submittingRef.current = false;\n }\n },\n {\n dismissible: false\n }\n );\n }\n };\n\n return {\n renderModal\n };\n }\n\n return {\n renderModal: () => {}\n };\n};\n\nexport default useCreateModal;\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FunctionComponent, MouseEventHandler } from 'react';
|
|
2
|
+
import { ImageProps, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
|
+
interface Action {
|
|
4
|
+
label: string;
|
|
5
|
+
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
6
|
+
}
|
|
7
|
+
export interface PageBannerProps extends NoChildrenProp {
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
image?: ImageProps;
|
|
11
|
+
actions?: [Action] | [Action, Action];
|
|
12
|
+
link?: {
|
|
13
|
+
label: string;
|
|
14
|
+
href: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare const StyledPageBanner: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
18
|
+
export declare const StyledImageContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
19
|
+
export declare const StyledActions: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
20
|
+
declare const PageBanner: FunctionComponent<PageBannerProps>;
|
|
21
|
+
export default PageBanner;
|
|
22
|
+
//# sourceMappingURL=PageBanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageBanner.d.ts","sourceRoot":"","sources":["../../../src/components/PageBanner/PageBanner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAU,MAAM,OAAO,CAAC;AAIrE,OAAO,EASL,UAAU,EAMV,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,IAAI,CAAC,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,eAAO,MAAM,gBAAgB,yGAqC3B,CAAC;AAIH,eAAO,MAAM,oBAAoB,yGAOhC,CAAC;AAEF,eAAO,MAAM,aAAa,yGAEzB,CAAC;AAEF,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAqDlD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { readableColor } from 'polished';
|
|
5
|
+
import { Flex, Grid, Image, Text, Button, defaultThemeProp, tryCatch, StyledButton, Link, StyledLink, useBreakpoint, ShowMoreLess, StyledShowMoreLessButton } from '@pega/cosmos-react-core';
|
|
6
|
+
export const StyledPageBanner = styled.div(({ theme }) => {
|
|
7
|
+
const { base: { palette: { 'brand-primary': brandBackground }, 'font-weight': fontWeight, 'content-width': contentWidth } } = theme;
|
|
8
|
+
const color = tryCatch(() => readableColor(brandBackground));
|
|
9
|
+
return css `
|
|
10
|
+
background: ${brandBackground};
|
|
11
|
+
color: ${color};
|
|
12
|
+
|
|
13
|
+
h1:focus-visible {
|
|
14
|
+
outline: transparent;
|
|
15
|
+
box-shadow: ${theme.base.shadow.focus};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
${StyledButton} {
|
|
19
|
+
width: max-content;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
${StyledButton} + ${StyledButton} {
|
|
23
|
+
margin-inline-start: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
${StyledLink}, ${StyledShowMoreLessButton} {
|
|
27
|
+
font-weight: ${fontWeight['semi-bold']};
|
|
28
|
+
color: ${color};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
p {
|
|
32
|
+
max-width: ${contentWidth.xl};
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
});
|
|
36
|
+
StyledPageBanner.defaultProps = defaultThemeProp;
|
|
37
|
+
export const StyledImageContainer = styled.div `
|
|
38
|
+
min-width: 100%;
|
|
39
|
+
|
|
40
|
+
img {
|
|
41
|
+
object-fit: contain;
|
|
42
|
+
max-height: 10rem;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
export const StyledActions = styled.div `
|
|
46
|
+
margin-block-start: auto;
|
|
47
|
+
`;
|
|
48
|
+
const PageBanner = ({ title, description, image, actions, link }) => {
|
|
49
|
+
const bannerRef = useRef(null);
|
|
50
|
+
const isMediumOrAbove = useBreakpoint('md', { breakpointRef: bannerRef });
|
|
51
|
+
const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: bannerRef });
|
|
52
|
+
return (_jsxs(Grid, { container: {
|
|
53
|
+
cols: isSmallOrAbove && image ? '1fr 25%' : '1fr',
|
|
54
|
+
pad: isMediumOrAbove ? [0, 8, 0, 4] : [0, 4],
|
|
55
|
+
gap: isMediumOrAbove ? 8 : 4
|
|
56
|
+
}, as: StyledPageBanner, ref: bannerRef, children: [_jsxs(Flex, { container: { direction: 'column', pad: [2, 0], gap: 1 }, children: [_jsx(Text, { variant: 'h1', children: title }), _jsx(ShowMoreLess, { lines: 3, children: _jsx(Text, { as: 'p', children: description }) }), !isSmallOrAbove && image && (_jsx(Flex, { as: StyledImageContainer, container: { justify: 'center', alignItems: 'center' }, children: _jsx(Image, { ...image }) })), !!actions?.length && (_jsxs(Flex, { as: StyledActions, container: { alignItems: 'center', pad: [1, 0, 0, 0], gap: 1, wrap: 'wrap' }, children: [actions.map(action => (_jsx(Button, { onClick: action.onClick, children: action.label }, action.label))), link && _jsx(Link, { href: link.href, children: link.label })] }))] }), isSmallOrAbove && image && (_jsx(Flex, { as: StyledImageContainer, container: { justify: 'end', alignItems: 'center' }, children: _jsx(Image, { ...image }) }))] }));
|
|
57
|
+
};
|
|
58
|
+
export default PageBanner;
|
|
59
|
+
//# sourceMappingURL=PageBanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageBanner.js","sourceRoot":"","sources":["../../../src/components/PageBanner/PageBanner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAwC,MAAM,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,MAAM,EACN,gBAAgB,EAChB,QAAQ,EACR,YAAY,EAEZ,IAAI,EACJ,UAAU,EACV,aAAa,EACb,YAAY,EACZ,w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AoB,OAAO,EAAE,MAAM,CAAC,OAAO,YAC/C,MAAM,CAAC,KAAK,IADF,MAAM,CAAC,KAAK,CAEhB,CACV,CAAC,EACD,IAAI,IAAI,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,YAAG,IAAI,CAAC,KAAK,GAAQ,IAC9C,CACR,IACI,EACN,cAAc,IAAI,KAAK,IAAI,CAC1B,KAAC,IAAI,IAAC,EAAE,EAAE,oBAAoB,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,YACjF,KAAC,KAAK,OAAK,KAAK,GAAI,GACf,CACR,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FunctionComponent, MouseEventHandler, useRef } from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport {\n Flex,\n Grid,\n Image,\n Text,\n Button,\n defaultThemeProp,\n tryCatch,\n StyledButton,\n ImageProps,\n Link,\n StyledLink,\n useBreakpoint,\n ShowMoreLess,\n StyledShowMoreLessButton,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\n\ninterface Action {\n label: string;\n onClick: MouseEventHandler<HTMLButtonElement>;\n}\n\nexport interface PageBannerProps extends NoChildrenProp {\n title: string;\n description: string;\n image?: ImageProps;\n actions?: [Action] | [Action, Action];\n link?: {\n label: string;\n href: string;\n };\n}\n\nexport const StyledPageBanner = styled.div(({ theme }) => {\n const {\n base: {\n palette: { 'brand-primary': brandBackground },\n 'font-weight': fontWeight,\n 'content-width': contentWidth\n }\n } = theme;\n\n const color = tryCatch(() => readableColor(brandBackground));\n\n return css`\n background: ${brandBackground};\n color: ${color};\n\n h1:focus-visible {\n outline: transparent;\n box-shadow: ${theme.base.shadow.focus};\n }\n\n ${StyledButton} {\n width: max-content;\n }\n\n ${StyledButton} + ${StyledButton} {\n margin-inline-start: 0;\n }\n\n ${StyledLink}, ${StyledShowMoreLessButton} {\n font-weight: ${fontWeight['semi-bold']};\n color: ${color};\n }\n\n p {\n max-width: ${contentWidth.xl};\n }\n `;\n});\n\nStyledPageBanner.defaultProps = defaultThemeProp;\n\nexport const StyledImageContainer = styled.div`\n min-width: 100%;\n\n img {\n object-fit: contain;\n max-height: 10rem;\n }\n`;\n\nexport const StyledActions = styled.div`\n margin-block-start: auto;\n`;\n\nconst PageBanner: FunctionComponent<PageBannerProps> = ({\n title,\n description,\n image,\n actions,\n link\n}) => {\n const bannerRef = useRef<HTMLDivElement>(null);\n\n const isMediumOrAbove = useBreakpoint('md', { breakpointRef: bannerRef });\n const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: bannerRef });\n\n return (\n <Grid\n container={{\n cols: isSmallOrAbove && image ? '1fr 25%' : '1fr',\n pad: isMediumOrAbove ? [0, 8, 0, 4] : [0, 4],\n gap: isMediumOrAbove ? 8 : 4\n }}\n as={StyledPageBanner}\n ref={bannerRef}\n >\n <Flex container={{ direction: 'column', pad: [2, 0], gap: 1 }}>\n <Text variant='h1'>{title}</Text>\n <ShowMoreLess lines={3}>\n <Text as='p'>{description}</Text>\n </ShowMoreLess>\n {!isSmallOrAbove && image && (\n <Flex as={StyledImageContainer} container={{ justify: 'center', alignItems: 'center' }}>\n <Image {...image} />\n </Flex>\n )}\n {!!actions?.length && (\n <Flex\n as={StyledActions}\n container={{ alignItems: 'center', pad: [1, 0, 0, 0], gap: 1, wrap: 'wrap' }}\n >\n {actions.map(action => (\n <Button key={action.label} onClick={action.onClick}>\n {action.label}\n </Button>\n ))}\n {link && <Link href={link.href}>{link.label}</Link>}\n </Flex>\n )}\n </Flex>\n {isSmallOrAbove && image && (\n <Flex as={StyledImageContainer} container={{ justify: 'end', alignItems: 'center' }}>\n <Image {...image} />\n </Flex>\n )}\n </Grid>\n );\n};\n\nexport default PageBanner;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PageBanner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/PageBanner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { default, StyledPageBanner } from './PageBanner';\nexport type { PageBannerProps } from './PageBanner';\n"]}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { FC, Ref, MouseEvent } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
3
|
import { SummaryCardProps } from '../SummaryCard';
|
|
4
|
+
import { PageBannerProps } from '../PageBanner';
|
|
4
5
|
interface EmptyStateProps {
|
|
5
6
|
heading: string;
|
|
6
7
|
description?: string;
|
|
7
8
|
}
|
|
8
|
-
export interface GalleryPageProps extends NoChildrenProp {
|
|
9
|
-
|
|
10
|
-
description?: string;
|
|
11
|
-
image?: ImageProps;
|
|
12
|
-
action: {
|
|
13
|
-
text: string;
|
|
14
|
-
onClick: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
15
|
-
};
|
|
9
|
+
export interface GalleryPageProps extends NoChildrenProp, PageBannerProps {
|
|
10
|
+
/** Props to render the empty state content. */
|
|
16
11
|
emptyState: EmptyStateProps;
|
|
12
|
+
/** A list of cards to render as a grid. */
|
|
17
13
|
items?: SummaryCardProps[];
|
|
14
|
+
/** Callback function that is fired when an item is clicked. */
|
|
18
15
|
onItemClick: (id: SummaryCardProps['id'], e: MouseEvent<HTMLDivElement>) => void;
|
|
16
|
+
/** Ref for the wrapping element. */
|
|
19
17
|
ref?: Ref<HTMLDivElement>;
|
|
20
18
|
}
|
|
21
|
-
declare const
|
|
19
|
+
export declare const StyledGalleryPage: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
20
|
+
export declare const StyledContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
21
|
+
declare const GalleryPage: FC<GalleryPageProps>;
|
|
22
22
|
export default GalleryPage;
|
|
23
23
|
//# sourceMappingURL=GalleryPage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GalleryPage.d.ts","sourceRoot":"","sources":["../../../src/components/PageTemplates/GalleryPage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,GAAG,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"GalleryPage.d.ts","sourceRoot":"","sources":["../../../src/components/PageTemplates/GalleryPage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,GAAG,EAAE,UAAU,EAAa,MAAM,OAAO,CAAC;AAGpF,OAAO,EAIL,cAAc,EAOf,MAAM,yBAAyB,CAAC;AAEjC,OAAoB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAmB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5D,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc,EAAE,eAAe;IACvE,+CAA+C;IAC/C,UAAU,EAAE,eAAe,CAAC;IAC5B,2CAA2C;IAC3C,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC3B,+DAA+D;IAC/D,WAAW,EAAE,CAAC,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACjF,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,iBAAiB,yGAE7B,CAAC;AAEF,eAAO,MAAM,aAAa,yGAMxB,CAAC;AA+CH,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAiDrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,23 +1,47 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import
|
|
2
|
+
import { forwardRef, useEffect } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { Flex, Grid, Button, ShowMoreLess, Text, defaultThemeProp, useConfiguration, focusHeadingOrContainer, useConsolidatedRef } from '@pega/cosmos-react-core';
|
|
4
5
|
import SummaryCard from '../SummaryCard';
|
|
5
|
-
import
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import PageBanner from '../PageBanner';
|
|
7
|
+
export const StyledGalleryPage = styled.div `
|
|
8
|
+
min-height: inherit;
|
|
9
|
+
`;
|
|
10
|
+
export const StyledContent = styled.div(({ theme }) => {
|
|
11
|
+
return css `
|
|
12
|
+
padding-block: calc(3 * ${theme.base.spacing});
|
|
13
|
+
padding-inline: calc(4 * ${theme.base.spacing});
|
|
14
|
+
min-height: 100%;
|
|
15
|
+
`;
|
|
16
|
+
});
|
|
17
|
+
StyledContent.defaultProps = defaultThemeProp;
|
|
9
18
|
const SummaryCardList = ({ items, onItemClick }) => {
|
|
10
19
|
return (_jsx(Grid, { container: {
|
|
11
20
|
cols: 'repeat(auto-fill, minmax(18.75rem, 1fr))',
|
|
12
21
|
autoRows: '10rem',
|
|
13
22
|
gap: 2
|
|
14
|
-
},
|
|
23
|
+
}, children: items && items.map(item => _jsx(SummaryCard, { ...item, onClick: onItemClick }, item.id)) }));
|
|
15
24
|
};
|
|
16
|
-
const EmptyState = ({ heading, description,
|
|
17
|
-
return (_jsxs(Flex, { container: { direction: 'column', alignItems: 'center', justify: 'center', rowGap: 2 }, item: { grow: 1 }, children: [_jsx(
|
|
25
|
+
const EmptyState = ({ heading, description, actions }) => {
|
|
26
|
+
return (_jsxs(Flex, { container: { direction: 'column', alignItems: 'center', justify: 'center', rowGap: 2 }, item: { grow: 1 }, children: [_jsx(Text, { variant: 'h2', children: heading }), description && (_jsx(ShowMoreLess, { lines: 2, children: _jsx(Text, { as: 'p', children: description }) })), !!actions?.length &&
|
|
27
|
+
actions.map(action => (_jsx(Button, { variant: 'primary', onClick: action.onClick, children: action.label }, action.label)))] }));
|
|
18
28
|
};
|
|
19
|
-
const GalleryPage = forwardRef(({
|
|
20
|
-
|
|
29
|
+
const GalleryPage = forwardRef(({ title, description, image, items, onItemClick, emptyState, actions, link }, ref) => {
|
|
30
|
+
const { loadedRef } = useConfiguration();
|
|
31
|
+
const pageRef = useConsolidatedRef(ref);
|
|
32
|
+
// Focus heading on initial mount
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!pageRef.current)
|
|
35
|
+
return;
|
|
36
|
+
if (loadedRef.current) {
|
|
37
|
+
focusHeadingOrContainer(pageRef.current, title);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
loadedRef.current = true;
|
|
41
|
+
}
|
|
42
|
+
}, [title]);
|
|
43
|
+
const noItems = !items || items.length === 0;
|
|
44
|
+
return (_jsxs(StyledGalleryPage, { ref: pageRef, children: [_jsx(PageBanner, { title: title, description: description, actions: noItems ? undefined : actions, link: link, image: image }), _jsx(StyledContent, { children: noItems ? (_jsx(EmptyState, { ...emptyState, actions: actions })) : (_jsx(SummaryCardList, { items: items, onItemClick: onItemClick })) })] }));
|
|
21
45
|
});
|
|
22
46
|
export default GalleryPage;
|
|
23
47
|
//# sourceMappingURL=GalleryPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GalleryPage.js","sourceRoot":"","sources":["../../../src/components/PageTemplates/GalleryPage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAuB,UAAU,EAAmB,MAAM,OAAO,CAAC;
|
|
1
|
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IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IAE7C,OAAO,CACL,MAAC,iBAAiB,IAAC,GAAG,EAAE,OAAO,aAC7B,KAAC,UAAU,IACT,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EACtC,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,GACZ,EACF,KAAC,aAAa,cACX,OAAO,CAAC,CAAC,CAAC,CACT,KAAC,UAAU,OAAK,UAAU,EAAE,OAAO,EAAE,OAAO,GAAI,CACjD,CAAC,CAAC,CAAC,CACF,KAAC,eAAe,IAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,GAAI,CAC5D,GACa,IACE,CACrB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FC, PropsWithoutRef, forwardRef, Ref, MouseEvent, useEffect } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n Grid,\n Button,\n NoChildrenProp,\n ShowMoreLess,\n Text,\n defaultThemeProp,\n useConfiguration,\n focusHeadingOrContainer,\n useConsolidatedRef\n} from '@pega/cosmos-react-core';\n\nimport SummaryCard, { SummaryCardProps } from '../SummaryCard';\nimport PageBanner, { PageBannerProps } from '../PageBanner';\n\ninterface EmptyStateProps {\n heading: string;\n description?: string;\n}\n\nexport interface GalleryPageProps extends NoChildrenProp, PageBannerProps {\n /** Props to render the empty state content. */\n emptyState: EmptyStateProps;\n /** A list of cards to render as a grid. */\n items?: SummaryCardProps[];\n /** Callback function that is fired when an item is clicked. */\n onItemClick: (id: SummaryCardProps['id'], e: MouseEvent<HTMLDivElement>) => void;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledGalleryPage = styled.div`\n min-height: inherit;\n`;\n\nexport const StyledContent = styled.div(({ theme }) => {\n return css`\n padding-block: calc(3 * ${theme.base.spacing});\n padding-inline: calc(4 * ${theme.base.spacing});\n min-height: 100%;\n `;\n});\n\nStyledContent.defaultProps = defaultThemeProp;\n\nconst SummaryCardList: FC<{\n items: GalleryPageProps['items'];\n onItemClick: GalleryPageProps['onItemClick'];\n}> = ({ items, onItemClick }) => {\n return (\n <Grid\n container={{\n cols: 'repeat(auto-fill, minmax(18.75rem, 1fr))',\n autoRows: '10rem',\n gap: 2\n }}\n >\n {items && items.map(item => <SummaryCard key={item.id} {...item} onClick={onItemClick} />)}\n </Grid>\n );\n};\n\nconst EmptyState: FC<EmptyStateProps & Pick<GalleryPageProps, 'actions'>> = ({\n heading,\n description,\n actions\n}) => {\n return (\n <Flex\n container={{ direction: 'column', alignItems: 'center', justify: 'center', rowGap: 2 }}\n item={{ grow: 1 }}\n >\n <Text variant='h2'>{heading}</Text>\n {description && (\n <ShowMoreLess lines={2}>\n <Text as='p'>{description}</Text>\n </ShowMoreLess>\n )}\n {!!actions?.length &&\n actions.map(action => (\n <Button key={action.label} variant='primary' onClick={action.onClick}>\n {action.label}\n </Button>\n ))}\n </Flex>\n );\n};\n\nconst GalleryPage: FC<GalleryPageProps> = forwardRef(\n (\n {\n title,\n description,\n image,\n items,\n onItemClick,\n emptyState,\n actions,\n link\n }: PropsWithoutRef<GalleryPageProps>,\n ref: GalleryPageProps['ref']\n ) => {\n const { loadedRef } = useConfiguration();\n const pageRef = useConsolidatedRef(ref);\n\n // Focus heading on initial mount\n useEffect(() => {\n if (!pageRef.current) return;\n\n if (loadedRef.current) {\n focusHeadingOrContainer(pageRef.current, title);\n } else {\n loadedRef.current = true;\n }\n }, [title]);\n\n const noItems = !items || items.length === 0;\n\n return (\n <StyledGalleryPage ref={pageRef}>\n <PageBanner\n title={title}\n description={description}\n actions={noItems ? undefined : actions}\n link={link}\n image={image}\n />\n <StyledContent>\n {noItems ? (\n <EmptyState {...emptyState} actions={actions} />\n ) : (\n <SummaryCardList items={items} onItemClick={onItemClick} />\n )}\n </StyledContent>\n </StyledGalleryPage>\n );\n }\n);\n\nexport default GalleryPage;\n"]}
|
|
@@ -14,7 +14,7 @@ export interface PageHeaderProps extends Pick<PageTemplateProps, 'title' | 'acti
|
|
|
14
14
|
onEdit?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
type OmittedPageProps = 'header' | 'scrollContent';
|
|
18
18
|
export interface OneColumnPageProps extends OmitStrict<CoreOneColumnPageProps, OmittedPageProps>, PageHeaderProps {
|
|
19
19
|
}
|
|
20
20
|
export interface TabbedPageProps extends OmitStrict<CoreTabbedPageProps, OmittedPageProps>, PageHeaderProps {
|