@pega/cosmos-react-build 3.0.0-dev.9.1 → 3.0.0-rc.1
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/AppHeader/AppHeader.d.ts +1 -1
- package/lib/components/AppHeader/AppHeader.d.ts.map +1 -1
- package/lib/components/AppHeader/AppHeader.js +7 -6
- package/lib/components/AppHeader/AppHeader.js.map +1 -1
- package/lib/components/AppHeader/AppHeader.styles.d.ts +1 -2
- package/lib/components/AppHeader/AppHeader.styles.d.ts.map +1 -1
- package/lib/components/AppHeader/AppHeader.styles.js +5 -7
- package/lib/components/AppHeader/AppHeader.styles.js.map +1 -1
- package/lib/components/AppHeader/BranchButton.d.ts.map +1 -1
- package/lib/components/AppHeader/BranchButton.js +22 -18
- package/lib/components/AppHeader/BranchButton.js.map +1 -1
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +19 -2
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +0 -3
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.js +46 -35
- package/lib/components/DynamicContentEditor/DynamicContentEditor.js.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts +2 -2
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.js.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.d.ts +8 -0
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.js +124 -0
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.js.map +1 -0
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.d.ts +8 -0
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.js +517 -0
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.js.map +1 -0
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.d.ts +35 -0
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.js +2 -0
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.js.map +1 -0
- package/lib/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.d.ts +13 -0
- package/lib/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.js +46 -0
- package/lib/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.js.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.d.ts +6 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.js +51 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.js.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.d.ts +14 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.js +81 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.js.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.types.d.ts +74 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.types.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.types.js +2 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilder.types.js.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilderContext.d.ts +7 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilderContext.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilderContext.js +6 -0
- package/lib/components/ExpressionBuilder/ExpressionBuilderContext.js.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionDetails.d.ts +6 -0
- package/lib/components/ExpressionBuilder/ExpressionDetails.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionDetails.js +12 -0
- package/lib/components/ExpressionBuilder/ExpressionDetails.js.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionItem.d.ts +6 -0
- package/lib/components/ExpressionBuilder/ExpressionItem.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionItem.js +39 -0
- package/lib/components/ExpressionBuilder/ExpressionItem.js.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionList.d.ts +6 -0
- package/lib/components/ExpressionBuilder/ExpressionList.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/ExpressionList.js +32 -0
- package/lib/components/ExpressionBuilder/ExpressionList.js.map +1 -0
- package/lib/components/ExpressionBuilder/index.d.ts +8 -0
- package/lib/components/ExpressionBuilder/index.d.ts.map +1 -0
- package/lib/components/ExpressionBuilder/index.js +6 -0
- package/lib/components/ExpressionBuilder/index.js.map +1 -0
- package/lib/components/FlowModeller/AddNode.d.ts +2 -2
- package/lib/components/FlowModeller/AddNode.d.ts.map +1 -1
- package/lib/components/FlowModeller/AddNode.js.map +1 -1
- package/lib/components/FlowModeller/Connector.d.ts +3 -3
- package/lib/components/FlowModeller/Connector.d.ts.map +1 -1
- package/lib/components/FlowModeller/Connector.js +41 -4
- package/lib/components/FlowModeller/Connector.js.map +1 -1
- package/lib/components/FlowModeller/DeletePopover.d.ts.map +1 -1
- package/lib/components/FlowModeller/DeletePopover.js +56 -25
- package/lib/components/FlowModeller/DeletePopover.js.map +1 -1
- package/lib/components/FlowModeller/FlowModeller.d.ts +3 -23
- package/lib/components/FlowModeller/FlowModeller.d.ts.map +1 -1
- package/lib/components/FlowModeller/FlowModeller.js +88 -15
- package/lib/components/FlowModeller/FlowModeller.js.map +1 -1
- package/lib/components/FlowModeller/FlowModeller.types.d.ts +25 -0
- package/lib/components/FlowModeller/FlowModeller.types.d.ts.map +1 -0
- package/lib/components/FlowModeller/FlowModeller.types.js +2 -0
- package/lib/components/FlowModeller/FlowModeller.types.js.map +1 -0
- package/lib/components/FlowModeller/FlowModellerContext.d.ts +6 -0
- package/lib/components/FlowModeller/FlowModellerContext.d.ts.map +1 -0
- package/lib/components/FlowModeller/FlowModellerContext.js +7 -0
- package/lib/components/FlowModeller/FlowModellerContext.js.map +1 -0
- package/lib/components/FlowModeller/Node/Node.types.d.ts +11 -4
- 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.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.js +4 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.js.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.d.ts +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.js +25 -12
- package/lib/components/FlowModeller/Node/NodeTemplates.js.map +1 -1
- package/lib/components/FlowModeller/Node.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node.js +3 -4
- package/lib/components/FlowModeller/Node.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.js +37 -6
- package/lib/components/FlowModeller/Renderer/Renderer.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.types.d.ts +3 -9
- package/lib/components/FlowModeller/Renderer/Renderer.types.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.types.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/Graph.d.ts +5 -0
- package/lib/components/FlowModeller/Renderer/Utils/Graph.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/Graph.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.d.ts +2 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.js +19 -6
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.d.ts +1 -2
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.js.map +1 -1
- package/lib/components/FlowModeller/Utils/addNodeUtils.d.ts +6 -5
- package/lib/components/FlowModeller/Utils/addNodeUtils.d.ts.map +1 -1
- package/lib/components/FlowModeller/Utils/addNodeUtils.js +57 -34
- package/lib/components/FlowModeller/Utils/addNodeUtils.js.map +1 -1
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.d.ts +3 -2
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.d.ts.map +1 -1
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.js +11 -1
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.js.map +1 -1
- package/lib/components/FlowModeller/helper.d.ts +15 -2
- package/lib/components/FlowModeller/helper.d.ts.map +1 -1
- package/lib/components/FlowModeller/helper.js +80 -45
- package/lib/components/FlowModeller/helper.js.map +1 -1
- package/lib/components/FlowModeller/index.d.ts +3 -2
- package/lib/components/FlowModeller/index.d.ts.map +1 -1
- package/lib/components/FlowModeller/index.js.map +1 -1
- package/lib/components/ItemLibrary/ItemLibrary.d.ts.map +1 -1
- package/lib/components/ItemLibrary/ItemLibrary.js +1 -4
- 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 +10 -9
- package/lib/components/LifeCycle/Category.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.types.js.map +1 -1
- package/lib/components/LifeCycle/Stage.d.ts +1 -1
- package/lib/components/LifeCycle/Stage.d.ts.map +1 -1
- package/lib/components/LifeCycle/Stage.js +1 -1
- package/lib/components/LifeCycle/Stage.js.map +1 -1
- package/lib/components/LifeCycle/Step.d.ts +3 -7
- package/lib/components/LifeCycle/Step.d.ts.map +1 -1
- package/lib/components/LifeCycle/Step.js +4 -4
- package/lib/components/LifeCycle/Step.js.map +1 -1
- package/lib/components/LifeCycle/Task.d.ts +1 -2
- package/lib/components/LifeCycle/Task.d.ts.map +1 -1
- package/lib/components/LifeCycle/Task.js +2 -2
- package/lib/components/LifeCycle/Task.js.map +1 -1
- package/lib/components/ObjectPreview/ObjectPreview.d.ts +1 -1
- 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/ObjectPicker.d.ts +9 -5
- package/lib/components/ObjectSelect/ObjectPicker.d.ts.map +1 -1
- package/lib/components/ObjectSelect/ObjectPicker.js +19 -5
- package/lib/components/ObjectSelect/ObjectPicker.js.map +1 -1
- package/lib/components/ObjectSelect/ObjectSelect.d.ts +10 -5
- package/lib/components/ObjectSelect/ObjectSelect.d.ts.map +1 -1
- package/lib/components/ObjectSelect/ObjectSelect.js +24 -8
- package/lib/components/ObjectSelect/ObjectSelect.js.map +1 -1
- package/lib/components/ObjectSelect/ObjectSummary.d.ts +6 -4
- package/lib/components/ObjectSelect/ObjectSummary.d.ts.map +1 -1
- package/lib/components/ObjectSelect/ObjectSummary.js +28 -33
- package/lib/components/ObjectSelect/ObjectSummary.js.map +1 -1
- package/lib/components/ObjectSelect/useCreateModal.d.ts +34 -0
- package/lib/components/ObjectSelect/useCreateModal.d.ts.map +1 -0
- package/lib/components/ObjectSelect/useCreateModal.js +61 -0
- package/lib/components/ObjectSelect/useCreateModal.js.map +1 -0
- package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.js +26 -8
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/Workbench/ConfigurationPanel.d.ts.map +1 -1
- package/lib/components/Workbench/ConfigurationPanel.js +4 -14
- package/lib/components/Workbench/ConfigurationPanel.js.map +1 -1
- package/lib/components/Workbench/Workbench.d.ts.map +1 -1
- package/lib/components/Workbench/Workbench.js +2 -2
- package/lib/components/Workbench/Workbench.js.map +1 -1
- package/lib/components/Workbench/Workbench.styles.d.ts +1 -0
- package/lib/components/Workbench/Workbench.styles.d.ts.map +1 -1
- package/lib/components/Workbench/Workbench.styles.js +4 -0
- package/lib/components/Workbench/Workbench.styles.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/components/Workbench/Workbench.types.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/package.json +11 -6
- package/lib/components/FlowModeller/Renderer/Connectors.d.ts +0 -15
- package/lib/components/FlowModeller/Renderer/Connectors.d.ts.map +0 -1
- package/lib/components/FlowModeller/Renderer/Connectors.js +0 -49
- package/lib/components/FlowModeller/Renderer/Connectors.js.map +0 -1
- package/lib/components/FlowModeller/Renderer/Nodes.d.ts +0 -11
- package/lib/components/FlowModeller/Renderer/Nodes.d.ts.map +0 -1
- package/lib/components/FlowModeller/Renderer/Nodes.js +0 -31
- package/lib/components/FlowModeller/Renderer/Nodes.js.map +0 -1
- package/lib/components/ObjectSelect/ObjectConfig.d.ts +0 -18
- package/lib/components/ObjectSelect/ObjectConfig.d.ts.map +0 -1
- package/lib/components/ObjectSelect/ObjectConfig.js +0 -14
- package/lib/components/ObjectSelect/ObjectConfig.js.map +0 -1
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseProps,
|
|
1
|
+
import { FunctionComponent, MouseEventHandler } from 'react';
|
|
2
|
+
import { BaseProps, MenuProps, MenuItemProps, ComboBoxProps, NoChildrenProp, ButtonProps } from '@pega/cosmos-react-core';
|
|
3
3
|
export interface ObjectPickerProps extends BaseProps, NoChildrenProp, Pick<ComboBoxProps, 'id' | 'label' | 'labelHidden' | 'required' | 'disabled' | 'readOnly' | 'name' | 'status' | 'info' | 'placeholder'> {
|
|
4
4
|
items: MenuProps['items'];
|
|
5
5
|
loading: MenuProps['loading'];
|
|
6
|
-
onSelect:
|
|
7
|
-
|
|
6
|
+
onSelect: MenuItemProps['onClick'];
|
|
7
|
+
createProps?: {
|
|
8
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
9
|
+
href?: ButtonProps['href'];
|
|
10
|
+
};
|
|
11
|
+
ref?: ComboBoxProps['ref'];
|
|
8
12
|
}
|
|
9
|
-
declare const ObjectPicker:
|
|
13
|
+
declare const ObjectPicker: FunctionComponent<ObjectPickerProps>;
|
|
10
14
|
export default ObjectPicker;
|
|
11
15
|
//# sourceMappingURL=ObjectPicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectPicker.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ObjectPicker.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,SAAS,EAGT,SAAS,EACT,aAAa,EAEb,aAAa,EACb,cAAc,EAMd,WAAW,EAEZ,MAAM,yBAAyB,CAAC;AAMjC,MAAM,WAAW,iBACf,SAAQ,SAAS,EACf,cAAc,EACd,IAAI,CACF,aAAa,EACX,IAAI,GACJ,OAAO,GACP,aAAa,GACb,UAAU,GACV,UAAU,GACV,UAAU,GACV,MAAM,GACN,QAAQ,GACR,MAAM,GACN,aAAa,CAChB;IACH,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1B,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC9B,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;QAAC,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC;IAC7F,GAAG,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAC5B;AAED,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CA6DtD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useState, useMemo } from 'react';
|
|
3
|
-
import { ComboBox, menuHelpers, createStringMatcher } from '@pega/cosmos-react-core';
|
|
4
|
-
|
|
3
|
+
import { ComboBox, menuHelpers, createStringMatcher, Flex, Button, Icon, useI18n, useConsolidatedRef, registerIcon } from '@pega/cosmos-react-core';
|
|
4
|
+
import * as openIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/open.icon';
|
|
5
|
+
import * as plusIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/plus.icon';
|
|
6
|
+
registerIcon(openIcon, plusIcon);
|
|
7
|
+
const ObjectPicker = forwardRef(({ items, onSelect, createProps, loading, ...restProps }, ref) => {
|
|
5
8
|
const [filterValue, setFilterValue] = useState('');
|
|
6
9
|
const filterRegex = filterValue ? createStringMatcher(filterValue) : undefined;
|
|
10
|
+
const t = useI18n();
|
|
11
|
+
const comboboxRef = useConsolidatedRef(ref);
|
|
7
12
|
const itemsToRender = useMemo(() => {
|
|
8
13
|
const newItems = filterValue
|
|
9
14
|
? menuHelpers.flatten(items).filter(({ primary }) => {
|
|
@@ -15,11 +20,20 @@ const ObjectPicker = forwardRef(({ items, onSelect, loading, ...restProps }, ref
|
|
|
15
20
|
selected: item.items ? undefined : !!item.selected
|
|
16
21
|
}));
|
|
17
22
|
}, [filterValue, items]);
|
|
18
|
-
return (_jsx(ComboBox, { ...restProps, ref:
|
|
23
|
+
return (_jsx(ComboBox, { ...restProps, ref: comboboxRef, mode: 'single-select', value: filterValue, onChange: (e) => setFilterValue(e.target.value), onBlur: () => setFilterValue(''), menu: {
|
|
19
24
|
items: itemsToRender,
|
|
20
25
|
onItemClick: onSelect,
|
|
21
26
|
accent: filterRegex,
|
|
22
|
-
loading
|
|
27
|
+
loading,
|
|
28
|
+
footer: createProps ? (_jsx(Flex, { container: { justify: 'start' }, children: _jsxs(Button, { type: 'button', variant: 'simple', onClick: createProps.onClick, ...(createProps.href && {
|
|
29
|
+
href: createProps.href,
|
|
30
|
+
target: '_blank',
|
|
31
|
+
'aria-label': t('create_in_new_tab')
|
|
32
|
+
}), children: [_jsx(Icon, { name: 'plus' }), t('create_new'), createProps.href && _jsx(Icon, { name: 'open' })] }) })) : undefined
|
|
33
|
+
}, onKeyDown: e => {
|
|
34
|
+
if (e.key === 'Tab') {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
23
37
|
} }));
|
|
24
38
|
});
|
|
25
39
|
export default ObjectPicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectPicker.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ObjectPicker.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,OAAO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":["import {\n forwardRef,\n useState,\n useMemo,\n ChangeEvent,\n FunctionComponent,\n MouseEventHandler\n} from 'react';\n\nimport {\n BaseProps,\n ComboBox,\n menuHelpers,\n MenuProps,\n MenuItemProps,\n createStringMatcher,\n ComboBoxProps,\n NoChildrenProp,\n Flex,\n Button,\n Icon,\n useI18n,\n useConsolidatedRef,\n ButtonProps,\n registerIcon\n} from '@pega/cosmos-react-core';\nimport * as openIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/open.icon';\nimport * as plusIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/plus.icon';\n\nregisterIcon(openIcon, plusIcon);\n\nexport interface ObjectPickerProps\n extends BaseProps,\n NoChildrenProp,\n Pick<\n ComboBoxProps,\n | 'id'\n | 'label'\n | 'labelHidden'\n | 'required'\n | 'disabled'\n | 'readOnly'\n | 'name'\n | 'status'\n | 'info'\n | 'placeholder'\n > {\n items: MenuProps['items'];\n loading: MenuProps['loading'];\n onSelect: MenuItemProps['onClick'];\n createProps?: { onClick?: MouseEventHandler<HTMLButtonElement>; href?: ButtonProps['href'] };\n ref?: ComboBoxProps['ref'];\n}\n\nconst ObjectPicker: FunctionComponent<ObjectPickerProps> = forwardRef(\n ({ items, onSelect, createProps, loading, ...restProps }, ref: ObjectPickerProps['ref']) => {\n const [filterValue, setFilterValue] = useState('');\n const filterRegex = filterValue ? createStringMatcher(filterValue) : undefined;\n\n const t = useI18n();\n const comboboxRef = useConsolidatedRef(ref);\n\n const itemsToRender = useMemo(() => {\n const newItems = filterValue\n ? menuHelpers.flatten(items).filter(({ primary }: MenuItemProps) => {\n return filterRegex?.test(primary);\n })\n : items;\n\n return menuHelpers.mapTree(newItems, item => ({\n ...item,\n selected: item.items ? undefined : !!item.selected\n }));\n }, [filterValue, items]);\n\n return (\n <ComboBox\n {...restProps}\n ref={comboboxRef}\n mode='single-select'\n value={filterValue}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setFilterValue(e.target.value)}\n onBlur={() => setFilterValue('')}\n menu={{\n items: itemsToRender,\n onItemClick: onSelect,\n accent: filterRegex,\n loading,\n footer: createProps ? (\n <Flex container={{ justify: 'start' }}>\n <Button\n type='button'\n variant='simple'\n onClick={createProps.onClick}\n {...(createProps.href && {\n href: createProps.href,\n target: '_blank',\n 'aria-label': t('create_in_new_tab')\n })}\n >\n <Icon name='plus' />\n {t('create_new')}\n {createProps.href && <Icon name='open' />}\n </Button>\n </Flex>\n ) : undefined\n }}\n onKeyDown={e => {\n if (e.key === 'Tab') {\n return false;\n }\n }}\n />\n );\n }\n);\n\nexport default ObjectPicker;\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseProps,
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import { BaseProps, FormControlProps, MenuItemProps, NoChildrenProp, MenuProps, ForwardProps } from '@pega/cosmos-react-core';
|
|
3
3
|
import { ObjectPickerProps } from './ObjectPicker';
|
|
4
4
|
import { ObjectSummaryProps } from './ObjectSummary';
|
|
5
|
-
|
|
5
|
+
import { CreateModalActionProps, UseCreateModalConfig } from './useCreateModal';
|
|
6
|
+
export interface ObjectSelectProps<P extends object = object> extends BaseProps, NoChildrenProp, Omit<FormControlProps, 'value'> {
|
|
6
7
|
/** An array of MenuItemProps to be shown in the ObjectPicker menu. */
|
|
7
8
|
items: MenuProps['items'];
|
|
8
9
|
/** Boolean to trigger loading state for combobox menu */
|
|
@@ -12,16 +13,20 @@ export interface ObjectSelectProps extends BaseProps, NoChildrenProp, Omit<FormC
|
|
|
12
13
|
/** Props for configuration popover */
|
|
13
14
|
configuration?: ObjectSummaryProps['configuration'];
|
|
14
15
|
/** Callback fired when a new item is selected and on clearing the selected item. */
|
|
15
|
-
onChange:
|
|
16
|
+
onChange: MenuItemProps['onClick'];
|
|
16
17
|
/** Callback fired when the preview in the ObjectSummary link is clicked. */
|
|
17
18
|
onPreview?: (id: MenuItemProps['id'], e: {
|
|
18
19
|
href: string;
|
|
19
20
|
}) => void;
|
|
20
21
|
/** Callback fired on click of the link inside summary item */
|
|
21
22
|
onLinkClick?: ObjectSummaryProps['onLinkClick'];
|
|
23
|
+
/** New object creation form options or a link */
|
|
24
|
+
createConfiguration?: (UseCreateModalConfig<P> & CreateModalActionProps<P>) | {
|
|
25
|
+
href: string;
|
|
26
|
+
};
|
|
22
27
|
/** Ref placed on the element. */
|
|
23
28
|
ref?: Ref<HTMLDivElement>;
|
|
24
29
|
}
|
|
25
|
-
declare const ObjectSelect:
|
|
30
|
+
declare const ObjectSelect: <P extends object = object>(props: ObjectSelectProps<P> & ForwardProps) => JSX.Element | null;
|
|
26
31
|
export default ObjectSelect;
|
|
27
32
|
//# sourceMappingURL=ObjectSelect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectSelect.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ObjectSelect.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,GAAG,EAA+B,MAAM,OAAO,CAAC;AAEtF,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,SAAS,EACT,YAAY,EAGb,MAAM,yBAAyB,CAAC;AAEjC,OAAqB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAsB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAuB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEhG,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAC1D,SAAQ,SAAS,EACf,cAAc,EACd,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACjC,sEAAsE;IACtE,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1B,yDAAyD;IACzD,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACvC,sCAAsC;IACtC,KAAK,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACpC,sCAAsC;IACtC,aAAa,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACpD,oFAAoF;IACpF,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,4EAA4E;IAC5E,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACnE,8DAA8D;IAC9D,WAAW,CAAC,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAChD,iDAAiD;IACjD,mBAAmB,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/F,iCAAiC;IACjC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,QAAA,MAAM,YAAY,6EAmF8D,WAAW,GAAG,IAAI,CAAC;AAEnG,eAAe,YAAY,CAAC"}
|
|
@@ -1,25 +1,41 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useRef, useState } from 'react';
|
|
3
|
-
import { useAfterInitialEffect } from '@pega/cosmos-react-core';
|
|
2
|
+
import { forwardRef, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useAfterInitialEffect, hasProp } from '@pega/cosmos-react-core';
|
|
4
4
|
import ObjectPicker from './ObjectPicker';
|
|
5
5
|
import ObjectSummary from './ObjectSummary';
|
|
6
|
-
|
|
6
|
+
import useCreateModal from './useCreateModal';
|
|
7
|
+
const ObjectSelect = forwardRef(({ items, value, configuration, disabled, onChange, onPreview, onLinkClick, loading, createConfiguration, ...restProps }, ref) => {
|
|
7
8
|
const [mode, setMode] = useState(value ? 'summary' : 'picker');
|
|
8
9
|
const objectPickerRef = useRef(null);
|
|
9
10
|
const objectSummaryRef = useRef(null);
|
|
11
|
+
const isCreateModalConfig = createConfiguration && hasProp(createConfiguration, 'renderer');
|
|
10
12
|
useAfterInitialEffect(() => {
|
|
11
13
|
const element = mode === 'summary'
|
|
12
14
|
? objectSummaryRef.current?.querySelector('a')
|
|
13
15
|
: objectPickerRef.current?.querySelector('input');
|
|
14
16
|
element?.focus();
|
|
15
17
|
}, [mode]);
|
|
16
|
-
|
|
18
|
+
const { renderModal } = useCreateModal(isCreateModalConfig
|
|
19
|
+
? {
|
|
20
|
+
...createConfiguration,
|
|
21
|
+
onAfterClose: () => {
|
|
22
|
+
createConfiguration.onAfterClose?.();
|
|
23
|
+
setMode('summary');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
: undefined);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (mode === 'create' && isCreateModalConfig) {
|
|
29
|
+
renderModal(createConfiguration);
|
|
30
|
+
}
|
|
31
|
+
}, [mode, createConfiguration]);
|
|
32
|
+
return (_jsx("div", { ref: ref, children: value ? (_jsx(ObjectSummary, { ...restProps, value: value, disabled: disabled, onDelete: e => {
|
|
17
33
|
setMode('picker');
|
|
18
|
-
onChange('');
|
|
19
|
-
}, ref: objectSummaryRef, configuration: configuration, onPreview: e => onPreview?.(value.id, e), onLinkClick: onLinkClick })) : (_jsx(ObjectPicker, { ...restProps, loading: loading, disabled: disabled, ref: objectPickerRef, items: items, onSelect: id => {
|
|
34
|
+
onChange?.('', e);
|
|
35
|
+
}, ref: objectSummaryRef, configuration: configuration, onPreview: e => onPreview?.(value.id, e), onLinkClick: onLinkClick })) : (_jsx(ObjectPicker, { ...restProps, loading: loading, disabled: disabled, ref: objectPickerRef, items: items, onSelect: (id, e) => {
|
|
20
36
|
setMode('summary');
|
|
21
|
-
onChange(id);
|
|
22
|
-
} })) }));
|
|
37
|
+
onChange?.(id, e);
|
|
38
|
+
}, createProps: isCreateModalConfig ? { onClick: () => setMode('create') } : createConfiguration })) }));
|
|
23
39
|
});
|
|
24
40
|
export default ObjectSelect;
|
|
25
41
|
//# sourceMappingURL=ObjectSelect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectSelect.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"ObjectSelect.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAwB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtF,OAAO,EAOL,qBAAqB,EACrB,OAAO,EACR,MAAM,yBAAyB,CAAC;AAEjC,OAAO,YAAmC,MAAM,gBAAgB,CAAC;AACjE,OAAO,aAAqC,MAAM,iBAAiB,CAAC;AACpE,OAAO,cAAgE,MAAM,kBAAkB,CAAC;AA0BhG,MAAM,YAAY,GAAG,UAAU,CAC7B,CACE,EACE,KAAK,EACL,KAAK,EACL,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,GAAG,SAAS,EACyC,EACvD,GAA6B,EAC7B,EAAE;IACF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAkC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAChG,MAAM,eAAe,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACrD,MAAM,gBAAgB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEtD,MAAM,mBAAmB,GAAG,mBAAmB,IAAI,OAAO,CAAC,mBAAmB,EAAE,UAAU,CAAC,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CAAC,CAAC,CACF,KAAC,YAAY,OACP,SAAS,EACb,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE;gBAClB,OAAO,CAAC,SAAS,CAAC,CAAC;gBACnB,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YACpB,CAAC,EACD,WAAW,EACT,mBAAmB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,GAElF,CACH,GACG,CACP,CAAC;AACJ,CAAC,CAC+F,CAAC;AAEnG,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, Ref, useEffect, useRef, useState } from 'react';\n\nimport {\n BaseProps,\n FormControlProps,\n MenuItemProps,\n NoChildrenProp,\n MenuProps,\n ForwardProps,\n useAfterInitialEffect,\n hasProp\n} from '@pega/cosmos-react-core';\n\nimport ObjectPicker, { ObjectPickerProps } from './ObjectPicker';\nimport ObjectSummary, { ObjectSummaryProps } from './ObjectSummary';\nimport useCreateModal, { CreateModalActionProps, UseCreateModalConfig } from './useCreateModal';\n\nexport interface ObjectSelectProps<P extends object = object>\n extends BaseProps,\n NoChildrenProp,\n Omit<FormControlProps, 'value'> {\n /** An array of MenuItemProps to be shown in the ObjectPicker menu. */\n items: MenuProps['items'];\n /** Boolean to trigger loading state for combobox menu */\n loading?: ObjectPickerProps['loading'];\n /** The value for the ObjectSummary */\n value?: ObjectSummaryProps['value'];\n /** Props for configuration popover */\n configuration?: ObjectSummaryProps['configuration'];\n /** Callback fired when a new item is selected and on clearing the selected item. */\n onChange: MenuItemProps['onClick'];\n /** Callback fired when the preview in the ObjectSummary link is clicked. */\n onPreview?: (id: MenuItemProps['id'], e: { href: string }) => void;\n /** Callback fired on click of the link inside summary item */\n onLinkClick?: ObjectSummaryProps['onLinkClick'];\n /** New object creation form options or a link */\n createConfiguration?: (UseCreateModalConfig<P> & CreateModalActionProps<P>) | { href: string };\n /** Ref placed on the element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst ObjectSelect = forwardRef(\n <P extends object = object>(\n {\n items,\n value,\n configuration,\n disabled,\n onChange,\n onPreview,\n onLinkClick,\n loading,\n createConfiguration,\n ...restProps\n }: PropsWithoutRef<ObjectSelectProps<P>> & ForwardProps,\n ref: ObjectSelectProps['ref']\n ) => {\n const [mode, setMode] = useState<'picker' | 'summary' | 'create'>(value ? 'summary' : 'picker');\n const objectPickerRef = useRef<HTMLDivElement>(null);\n const objectSummaryRef = useRef<HTMLDivElement>(null);\n\n const isCreateModalConfig = createConfiguration && hasProp(createConfiguration, 'renderer');\n\n useAfterInitialEffect(() => {\n const element =\n mode === 'summary'\n ? objectSummaryRef.current?.querySelector('a')\n : objectPickerRef.current?.querySelector('input');\n element?.focus();\n }, [mode]);\n\n const { renderModal } = useCreateModal(\n isCreateModalConfig\n ? {\n ...createConfiguration,\n onAfterClose: () => {\n createConfiguration.onAfterClose?.();\n setMode('summary');\n }\n }\n : undefined\n );\n\n useEffect(() => {\n if (mode === 'create' && isCreateModalConfig) {\n renderModal(createConfiguration);\n }\n }, [mode, createConfiguration]);\n\n return (\n <div ref={ref}>\n {value ? (\n <ObjectSummary\n {...restProps}\n value={value}\n disabled={disabled}\n onDelete={e => {\n setMode('picker');\n onChange?.('', e);\n }}\n ref={objectSummaryRef}\n configuration={configuration}\n onPreview={e => onPreview?.(value.id, e)}\n onLinkClick={onLinkClick}\n />\n ) : (\n <ObjectPicker\n {...restProps}\n loading={loading}\n disabled={disabled}\n ref={objectPickerRef}\n items={items}\n onSelect={(id, e) => {\n setMode('summary');\n onChange?.(id, e);\n }}\n createProps={\n isCreateModalConfig ? { onClick: () => setMode('create') } : createConfiguration\n }\n />\n )}\n </div>\n );\n }\n) as <P extends object = object>(props: ObjectSelectProps<P> & ForwardProps) => JSX.Element | null;\n\nexport default ObjectSelect;\n"]}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { FC, Ref, PropsWithoutRef } from 'react';
|
|
2
|
-
import { BaseProps, ForwardProps, FormControlProps, MenuItemProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { ObjectConfigProps } from './ObjectConfig';
|
|
1
|
+
import { FC, Ref, PropsWithoutRef, MouseEvent } from 'react';
|
|
2
|
+
import { BaseProps, ForwardProps, FormControlProps, MenuItemProps, DialogProps, OmitStrict } from '@pega/cosmos-react-core';
|
|
4
3
|
interface ObjectSummaryValueProps {
|
|
5
4
|
id: MenuItemProps['id'];
|
|
6
5
|
primary: MenuItemProps['primary'];
|
|
7
6
|
href: string;
|
|
8
7
|
meta?: string;
|
|
9
8
|
}
|
|
9
|
+
interface ObjectConfigProps extends OmitStrict<DialogProps, 'target'> {
|
|
10
|
+
label: string;
|
|
11
|
+
}
|
|
10
12
|
export interface ObjectSummaryProps extends BaseProps, Omit<FormControlProps, 'value'> {
|
|
11
13
|
value: ObjectSummaryValueProps;
|
|
12
14
|
configuration?: ObjectConfigProps;
|
|
13
|
-
onDelete: () => void;
|
|
15
|
+
onDelete: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
14
16
|
onPreview?: (e: {
|
|
15
17
|
href: string;
|
|
16
18
|
}) => void;
|
|
@@ -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,
|
|
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,EAAE,MAAM,OAAO,CAAC;AAGzE,OAAO,EACL,SAAS,EAIT,YAAY,EAGZ,gBAAgB,EAChB,aAAa,EASb,WAAW,EACX,UAAU,EAEX,MAAM,yBAAyB,CAAC;AAMjC,UAAU,uBAAuB;IAC/B,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IACxB,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,iBAAkB,SAAQ,UAAU,CAAC,WAAW,EAAE,QAAQ,CAAC;IACnE,KAAK,EAAE,MAAM,CAAC;CACf;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;AAsDD,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC,GAAG,YAAY,CAgFzE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,50 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { SummaryItem, Button, Icon, StyledFormControl, FormField, useI18n, registerIcon, Text,
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { SummaryItem, Button, Icon, StyledFormControl, FormField, useI18n, registerIcon, Text, useDirection, useElement, Link, Dialog, defaultThemeProp, StyledLink } 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
|
-
import ObjectConfig from './ObjectConfig';
|
|
8
7
|
registerIcon(times, gear);
|
|
9
|
-
const StyledObjectSummary = styled(StyledFormControl)
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const StyledObjectSummary = styled(StyledFormControl)(({ theme: { base: { spacing, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }, shadow: { focus } } }, meta }) => {
|
|
9
|
+
return css `
|
|
10
|
+
padding-block: ${meta ? spacing : '0'};
|
|
11
|
+
padding-inline-start: ${spacing};
|
|
12
|
+
min-height: ${hitAreaMouse};
|
|
13
|
+
|
|
14
|
+
${StyledLink}:focus {
|
|
15
|
+
box-shadow: inset ${focus};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@media (pointer: coarse) {
|
|
19
|
+
min-height: ${hitAreaFinger};
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
});
|
|
23
|
+
StyledObjectSummary.defaultProps = defaultThemeProp;
|
|
12
24
|
const StyledMetaText = styled(Text) `
|
|
13
25
|
display: -webkit-box;
|
|
14
26
|
-webkit-box-orient: vertical;
|
|
15
27
|
-webkit-line-clamp: 2;
|
|
16
28
|
overflow: hidden;
|
|
17
29
|
`;
|
|
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;
|
|
18
38
|
const ObjectSummary = forwardRef(({ value, configuration, label, disabled, status, readOnly, onDelete, onPreview, onLinkClick, ...restProps }, ref) => {
|
|
19
|
-
const [open, setOpen] = useState(false);
|
|
20
39
|
const [buttonEl, setButtonEl] = useElement();
|
|
21
|
-
const [popoverEl, setPopoverEl] = useElement();
|
|
22
|
-
const popoverRef = useConsolidatedRef(configuration?.ref, setPopoverEl);
|
|
23
40
|
const t = useI18n();
|
|
24
41
|
const { rtl } = useDirection();
|
|
25
|
-
|
|
26
|
-
configuration?.onBeforeOpen?.();
|
|
27
|
-
setOpen(true);
|
|
28
|
-
};
|
|
29
|
-
const dismissPopover = (id) => {
|
|
30
|
-
setOpen(false);
|
|
31
|
-
configuration?.onAfterClose?.(id);
|
|
32
|
-
};
|
|
33
|
-
const onKeydown = (e) => {
|
|
34
|
-
const { key } = e;
|
|
35
|
-
if (key === 'Escape') {
|
|
36
|
-
setOpen(false);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
useEvent('keydown', onKeydown, { target: popoverEl });
|
|
40
|
-
useFocusTrap(popoverRef);
|
|
41
|
-
useAfterInitialEffect(() => {
|
|
42
|
-
if (open)
|
|
43
|
-
popoverEl?.querySelector('button')?.focus();
|
|
44
|
-
else
|
|
45
|
-
buttonEl?.focus();
|
|
46
|
-
}, [open, popoverEl]);
|
|
47
|
-
return (_jsx(FormField, { ...restProps, ref: ref, label: label, status: status, children: _jsx(SummaryItem, { as: StyledObjectSummary, status: status, meta: value.meta, 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, { ref: setButtonEl, label: configuration?.label, icon: true, variant: 'simple', onClick: openPopover, children: _jsx(Icon, { name: 'gear' }) })), !readOnly && (_jsx(Button, { disabled: disabled, label: t('clear_object_summary', [String(label)]), icon: true, variant: 'simple', onClick: onDelete, children: _jsx(Icon, { name: 'times' }) })), _jsx(Popover, { ref: popoverRef, placement: rtl ? 'bottom-end' : 'bottom-start', hideOnTargetHidden: true, show: open, target: buttonEl, children: configuration && open && (_jsx(ObjectConfig, { ...configuration, disabled: disabled, dismissPopover: dismissPopover })) })] }) }) }));
|
|
42
|
+
return (_jsx(FormField, { ...restProps, ref: ref, label: label, status: status, children: _jsx(SummaryItem, { as: StyledObjectSummary, status: status, meta: value.meta, readOnly: readOnly, overflowStrategy: 'ellipsis', 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, { ref: setButtonEl, label: configuration?.label, icon: true, variant: 'simple', children: _jsx(Icon, { name: 'gear' }) })), !readOnly && (_jsx(Button, { disabled: disabled, label: t('clear_object_summary', [String(label)]), icon: true, variant: 'simple', onClick: onDelete, children: _jsx(Icon, { name: 'times' }) })), configuration && (_jsx(Dialog, { heading: configuration.heading, placement: rtl ? 'bottom-end' : 'bottom-start', target: buttonEl, onOpen: configuration.onOpen, onClose: configuration.onClose, onSubmit: readOnly || disabled ? undefined : configuration?.onSubmit, loading: configuration.loading, ref: configuration.ref, children: _jsx(ScrollContainer, { children: configuration?.children }) }))] }) }) }));
|
|
48
43
|
});
|
|
49
44
|
export default ObjectSummary;
|
|
50
45
|
//# 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,
|
|
1
|
+
{"version":3,"file":"ObjectSummary.js","s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AAW,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,QAAC,OAAO,EAAC,QAAQ,YAC1E,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,GACb,CACV,EACA,CAAC,QAAQ,IAAI,CACZ,KAAC,MAAM,IACL,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,CAAC,CAAC,sBAAsB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EACjD,IAAI,QACJ,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,QAAQ,YAEjB,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,CACV,EACA,aAAa,IAAI,CAChB,KAAC,MAAM,IACL,OAAO,EAAE,aAAa,CAAC,OAAO,EAC9B,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,EAC9C,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,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 }\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: inset ${focus};\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}>\n <SummaryItem\n as={StyledObjectSummary}\n status={status}\n meta={value.meta}\n readOnly={readOnly}\n overflowStrategy='ellipsis'\n primary={\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 secondary={\n value.meta && <StyledMetaText variant='secondary'>{value.meta}</StyledMetaText>\n }\n actions={\n <>\n {configuration && (\n <Button ref={setButtonEl} label={configuration?.label} icon variant='simple'>\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"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { ModalProps } from '@pega/cosmos-react-core';
|
|
3
|
+
export interface UseCreateModalConfig<P extends object = object> {
|
|
4
|
+
renderer: ComponentType<P>;
|
|
5
|
+
/**
|
|
6
|
+
* Called when a user submits a form.
|
|
7
|
+
*/
|
|
8
|
+
onSubmit: ({ close }: {
|
|
9
|
+
close: () => void;
|
|
10
|
+
}) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Called when a user cancels a form.
|
|
13
|
+
*/
|
|
14
|
+
onDismiss: ({ close }: {
|
|
15
|
+
close: () => void;
|
|
16
|
+
}) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Called before the modal opens.
|
|
19
|
+
*/
|
|
20
|
+
onBeforeOpen?: ModalProps['onBeforeOpen'];
|
|
21
|
+
/**
|
|
22
|
+
* Called after the modal closes.
|
|
23
|
+
*/
|
|
24
|
+
onAfterClose?: ModalProps['onAfterClose'];
|
|
25
|
+
}
|
|
26
|
+
export interface CreateModalActionProps<P extends object = object> {
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
rendererProps: P;
|
|
29
|
+
}
|
|
30
|
+
declare const useCreateModal: <P extends object = object>(config: UseCreateModalConfig<P> | undefined) => {
|
|
31
|
+
renderModal: ({ rendererProps, loading }: CreateModalActionProps<P>) => void;
|
|
32
|
+
};
|
|
33
|
+
export default useCreateModal;
|
|
34
|
+
//# sourceMappingURL=useCreateModal.d.ts.map
|
|
@@ -0,0 +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;IAI7D,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAC3B;;OAEG;IACH,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IACrD;;OAEG;IACH,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IACtD;;OAEG;IACH,YAAY,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IAC1C;;OAEG;IACH,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;;CAgFnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { Button, Modal, useModalManager, useI18n } from '@pega/cosmos-react-core';
|
|
4
|
+
const useCreateModal = (config) => {
|
|
5
|
+
const t = useI18n();
|
|
6
|
+
const submittingRef = useRef(false);
|
|
7
|
+
const modalMethods = useRef();
|
|
8
|
+
const { create: createModal } = useModalManager();
|
|
9
|
+
if (config) {
|
|
10
|
+
const { renderer: Renderer, onSubmit, onDismiss, onBeforeOpen, onAfterClose } = config;
|
|
11
|
+
const renderModal = ({ rendererProps, loading = false }) => {
|
|
12
|
+
let modalContent = null;
|
|
13
|
+
if (!loading) {
|
|
14
|
+
modalContent = _jsx(Renderer, { ...rendererProps });
|
|
15
|
+
}
|
|
16
|
+
let formActions = null;
|
|
17
|
+
if (!loading || submittingRef.current) {
|
|
18
|
+
const close = () => {
|
|
19
|
+
modalMethods.current?.dismiss();
|
|
20
|
+
modalMethods.current = undefined;
|
|
21
|
+
};
|
|
22
|
+
formActions = (_jsxs(_Fragment, { children: [_jsx(Button, { disabled: loading, onClick: () => {
|
|
23
|
+
onDismiss({ close });
|
|
24
|
+
}, children: t('cancel') }), _jsx(Button, { disabled: loading, type: 'submit', variant: 'primary', onClick: () => {
|
|
25
|
+
submittingRef.current = true;
|
|
26
|
+
onSubmit({ close });
|
|
27
|
+
}, children: t('submit') })] }));
|
|
28
|
+
}
|
|
29
|
+
const modalProps = {
|
|
30
|
+
progress: loading
|
|
31
|
+
? { message: submittingRef.current ? t('submitting') : t('loading') }
|
|
32
|
+
: undefined,
|
|
33
|
+
children: modalContent,
|
|
34
|
+
actions: formActions,
|
|
35
|
+
onRequestDismiss: loading && submittingRef.current ? () => false : undefined
|
|
36
|
+
};
|
|
37
|
+
if (modalMethods.current) {
|
|
38
|
+
modalMethods.current.update(modalProps);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
modalMethods.current = createModal(Modal, {
|
|
42
|
+
...modalProps,
|
|
43
|
+
heading: t('create_new'),
|
|
44
|
+
onBeforeOpen,
|
|
45
|
+
onAfterClose: () => {
|
|
46
|
+
onAfterClose?.();
|
|
47
|
+
submittingRef.current = false;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
renderModal
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
renderModal: () => { }
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export default useCreateModal;
|
|
61
|
+
//# sourceMappingURL=useCreateModal.js.map
|
|
@@ -0,0 +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;AA8BjC,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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AC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;oBACrE,CAAC,CAAC,SAAS;gBACb,QAAQ,EAAE,YAAY;gBACtB,OAAO,EAAE,WAAW;gBACpB,gBAAgB,EAAE,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;aAC7E,CAAC;YAEF,IAAI,YAAY,CAAC,OAAO,EAAE;gBACxB,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;aACzC;iBAAM;gBACL,YAAY,CAAC,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE;oBACxC,GAAG,UAAU;oBACb,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC;oBACxB,YAAY;oBACZ,YAAY,EAAE,GAAG,EAAE;wBACjB,YAAY,EAAE,EAAE,CAAC;wBACjB,aAAa,CAAC,OAAO,GAAG,KAAK,CAAC;oBAChC,CAAC;iBACF,CAAC,CAAC;aACJ;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 * A component to render the add new form.\n */\n renderer: ComponentType<P>;\n /**\n * Called when a user submits a form.\n */\n onSubmit: ({ close }: { close: () => void }) => void;\n /**\n * Called when a user cancels a form.\n */\n onDismiss: ({ close }: { close: () => void }) => void;\n /**\n * Called before the modal opens.\n */\n onBeforeOpen?: ModalProps['onBeforeOpen'];\n /**\n * Called after the modal closes.\n */\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 { renderer: Renderer, onSubmit, onDismiss, onBeforeOpen, onAfterClose } = config;\n const renderModal = ({ rendererProps, loading = false }: CreateModalActionProps<P>) => {\n let modalContent: ReactNode = null;\n\n if (!loading) {\n modalContent = <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(Modal, {\n ...modalProps,\n heading: t('create_new'),\n onBeforeOpen,\n onAfterClose: () => {\n onAfterClose?.();\n submittingRef.current = false;\n }\n });\n }\n };\n\n return {\n renderModal\n };\n }\n\n return {\n renderModal: () => {}\n };\n};\n\nexport default useCreateModal;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageTemplates.d.ts","sourceRoot":"","sources":["../../../src/components/PageTemplates/PageTemplates.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAIjB,UAAU,
|
|
1
|
+
{"version":3,"file":"PageTem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YAAY,CAaxE,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAoB9E,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import { forwardRef, useState, useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { OneColumnPage as CoreOneColumnPage, TabbedPage as CoreTabbedPage, Flex, Status, SummaryItem, Text, Button, Popover, FieldValueList, Icon, defaultThemeProp, useI18n, useDirection, useElement, useOuterEvent, StyledSummaryItemActions, registerIcon, StyledRegion, MetaList, StyledBreadcrumbs, StyledPageHeader } from '@pega/cosmos-react-core';
|
|
4
|
+
import { OneColumnPage as CoreOneColumnPage, TabbedPage as CoreTabbedPage, Flex, Status, SummaryItem, Text, Button, Popover, FieldValueList, Icon, defaultThemeProp, useI18n, useDirection, useElement, useOuterEvent, StyledSummaryItemActions, registerIcon, StyledRegion, MetaList, StyledBreadcrumbs, StyledPageHeader, useAfterInitialEffect } from '@pega/cosmos-react-core';
|
|
5
5
|
import * as nodesDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/nodes-down.icon';
|
|
6
6
|
import * as informationIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/information.icon';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { StyledForm } from '@pega/cosmos-react-core/lib/components/MultiStepForm/MultiStepForm';
|
|
8
|
+
import { StyledBanner } from '@pega/cosmos-react-core/lib/components/Banner/Banner';
|
|
9
|
+
import { StyledTabs } from '@pega/cosmos-react-core/lib/components/Tabs/Tabs';
|
|
10
|
+
import { StyledDialogTitle } from '@pega/cosmos-react-core/lib/components/Dialog/Dialog';
|
|
9
11
|
import { StyledWorkbench } from '../Workbench/Workbench.styles';
|
|
10
12
|
registerIcon(nodesDownIcon, informationIcon);
|
|
11
13
|
const StyledTextWithEllipsis = styled(Text) `
|
|
@@ -28,10 +30,15 @@ export const StyledPage = styled.div(({ theme: { base: { spacing, palette: { 'pr
|
|
|
28
30
|
background: ${primaryBackground};
|
|
29
31
|
height: 100%;
|
|
30
32
|
|
|
31
|
-
${
|
|
32
|
-
|
|
33
|
+
${StyledBanner},
|
|
34
|
+
${StyledTabs} {
|
|
35
|
+
margin-block-start: calc(1.5 * ${spacing});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
${StyledRegion} ${StyledWorkbench} {
|
|
33
39
|
position: absolute;
|
|
34
|
-
width:
|
|
40
|
+
width: 100%;
|
|
41
|
+
margin: 0 calc(-2 * ${spacing});
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
${StyledRegion} ${StyledForm} {
|
|
@@ -50,6 +57,7 @@ export const PageHeader = ({ title, metadata, additionalInfo, actions, status, t
|
|
|
50
57
|
const [buttonEl, setButtonEl] = useElement();
|
|
51
58
|
const t = useI18n();
|
|
52
59
|
const { rtl } = useDirection();
|
|
60
|
+
const popoverTitleRef = useRef(null);
|
|
53
61
|
useOuterEvent('mousedown', [popoverEl, buttonEl], () => {
|
|
54
62
|
if (open)
|
|
55
63
|
setOpen(false);
|
|
@@ -72,8 +80,18 @@ export const PageHeader = ({ title, metadata, additionalInfo, actions, status, t
|
|
|
72
80
|
popoverEl?.removeEventListener('keydown', closePopover);
|
|
73
81
|
};
|
|
74
82
|
}, [popoverEl]);
|
|
83
|
+
useAfterInitialEffect(() => {
|
|
84
|
+
if (open && popoverEl) {
|
|
85
|
+
if (popoverTitleRef.current) {
|
|
86
|
+
popoverTitleRef.current.focus();
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
buttonEl?.focus();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, [open, popoverEl]);
|
|
75
93
|
const metaListItems = useMemo(() => metadata?.map(({ name, value }) => `${name}: ${value}`), [metadata]);
|
|
76
|
-
return (_jsx(StyledHeaderContent, { container: true, primary: _jsxs(Flex, { container: { alignItems: 'center', gap: 0.5, wrap: 'wrap' }, children: [_jsxs(Flex, { container: { gap: 0.5 }, item: { shrink: 0 }, children: [_jsx(StyledTextWithEllipsis, { variant: 'h1', forwardedAs: titleTag, children: title }), additionalInfo && (_jsxs(_Fragment, { children: [_jsx(Button, { label: t('additional_info'), variant: 'simple', icon: true, ref: setButtonEl, onClick: () => setOpen(cur => !cur), children: _jsx(Icon, { name: 'information' }) }), _jsx(StyledInfoPopover, { ref: setPopoverRef, show: open, target: buttonEl, placement: rtl ? 'bottom-end' : 'bottom-start', children: _jsxs(Flex, { container: { direction: 'column', alignItems: 'start', gap: 2, pad: 2 }, children: [_jsxs(Flex, { container: { direction: 'column', gap: 1 }, children: [_jsx(
|
|
94
|
+
return (_jsx(StyledHeaderContent, { container: true, primary: _jsxs(Flex, { container: { alignItems: 'center', gap: 0.5, wrap: 'wrap' }, children: [_jsxs(Flex, { container: { gap: 0.5 }, item: { shrink: 0 }, children: [_jsx(StyledTextWithEllipsis, { variant: 'h1', forwardedAs: titleTag, children: title }), additionalInfo && (_jsxs(_Fragment, { children: [_jsx(Button, { label: t('additional_info'), variant: 'simple', icon: true, ref: setButtonEl, onClick: () => setOpen(cur => !cur), children: _jsx(Icon, { name: 'information' }) }), _jsx(StyledInfoPopover, { ref: setPopoverRef, show: open, target: buttonEl, placement: rtl ? 'bottom-end' : 'bottom-start', children: _jsxs(Flex, { container: { direction: 'column', alignItems: 'start', gap: 2, pad: 2 }, children: [_jsxs(Flex, { container: { direction: 'column', gap: 1 }, children: [_jsx(StyledDialogTitle, { variant: 'h3', tabIndex: -1, ref: popoverTitleRef, children: additionalInfo.title }), additionalInfo.description && (_jsx(Text, { as: 'p', children: additionalInfo.description })), _jsx(FieldValueList, { variant: 'inline', fields: additionalInfo.fields })] }), additionalInfo.onEdit && (_jsx(Button, { onClick: (e) => {
|
|
77
95
|
setOpen(false);
|
|
78
96
|
additionalInfo.onEdit?.(e);
|
|
79
97
|
}, children: t('edit_details') }))] }) })] }))] }), status && _jsx(Status, { variant: status.type, children: status.label })] }), secondary: metaListItems && _jsx(MetaList, { items: metaListItems }), actions: actions }));
|