@pega/cosmos-react-demos 3.0.0-dev.3.0 → 3.0.0-dev.4.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/jsx/build/DynamicContentEditor/DynamicContentEditor.stories.d.ts +4 -1
- package/jsx/build/DynamicContentEditor/DynamicContentEditor.stories.d.ts.map +1 -1
- package/jsx/build/DynamicContentEditor/DynamicContentEditor.stories.jsx +17 -2
- package/jsx/build/DynamicContentEditor/DynamicContentEditor.stories.jsx.map +1 -1
- package/jsx/build/ObjectSelect/ObjectSelect.mocks.d.ts +16 -0
- package/jsx/build/ObjectSelect/ObjectSelect.mocks.d.ts.map +1 -0
- package/jsx/build/ObjectSelect/ObjectSelect.mocks.js +136 -0
- package/jsx/build/ObjectSelect/ObjectSelect.mocks.js.map +1 -0
- package/jsx/build/ObjectSelect/ObjectSelect.stories.d.ts +14 -0
- package/jsx/build/ObjectSelect/ObjectSelect.stories.d.ts.map +1 -0
- package/jsx/build/ObjectSelect/ObjectSelect.stories.jsx +312 -0
- package/jsx/build/ObjectSelect/ObjectSelect.stories.jsx.map +1 -0
- package/jsx/build/ObjectSelect/ObjectSelect.styles.d.ts +4 -0
- package/jsx/build/ObjectSelect/ObjectSelect.styles.d.ts.map +1 -0
- package/jsx/build/ObjectSelect/ObjectSelect.styles.js +27 -0
- package/jsx/build/ObjectSelect/ObjectSelect.styles.js.map +1 -0
- package/jsx/build/Workbench/Workbench.stories.d.ts.map +1 -1
- package/jsx/build/Workbench/Workbench.stories.jsx +2 -5
- package/jsx/build/Workbench/Workbench.stories.jsx.map +1 -1
- package/jsx/core/AppShell/AppShell.stories.d.ts +1 -0
- package/jsx/core/AppShell/AppShell.stories.d.ts.map +1 -1
- package/jsx/core/AppShell/AppShell.stories.jsx +3 -1
- package/jsx/core/AppShell/AppShell.stories.jsx.map +1 -1
- package/jsx/core/FieldGroup/FieldGroup.stories.d.ts +2 -0
- package/jsx/core/FieldGroup/FieldGroup.stories.d.ts.map +1 -1
- package/jsx/core/FieldGroup/FieldGroup.stories.jsx +8 -4
- package/jsx/core/FieldGroup/FieldGroup.stories.jsx.map +1 -1
- package/jsx/core/File/FileDisplay.stories.d.ts.map +1 -1
- package/jsx/core/File/FileDisplay.stories.jsx +16 -38
- package/jsx/core/File/FileDisplay.stories.jsx.map +1 -1
- package/jsx/core/HTML/HTML.stories.d.ts +6 -0
- package/jsx/core/HTML/HTML.stories.d.ts.map +1 -0
- package/jsx/core/HTML/HTML.stories.jsx +13 -0
- package/jsx/core/HTML/HTML.stories.jsx.map +1 -0
- package/jsx/rte/Editor/Editor.stories.jsx +1 -1
- package/jsx/rte/Editor/Editor.stories.jsx.map +1 -1
- package/jsx/social/Email/Email.stories.d.ts.map +1 -1
- package/jsx/social/Email/Email.stories.jsx +23 -1
- package/jsx/social/Email/Email.stories.jsx.map +1 -1
- package/lib/build/DynamicContentEditor/DynamicContentEditor.stories.d.ts +4 -1
- package/lib/build/DynamicContentEditor/DynamicContentEditor.stories.d.ts.map +1 -1
- package/lib/build/DynamicContentEditor/DynamicContentEditor.stories.js +17 -2
- package/lib/build/DynamicContentEditor/DynamicContentEditor.stories.js.map +1 -1
- package/lib/build/ObjectSelect/ObjectSelect.mocks.d.ts +16 -0
- package/lib/build/ObjectSelect/ObjectSelect.mocks.d.ts.map +1 -0
- package/lib/build/ObjectSelect/ObjectSelect.mocks.js +136 -0
- package/lib/build/ObjectSelect/ObjectSelect.mocks.js.map +1 -0
- package/lib/build/ObjectSelect/ObjectSelect.stories.d.ts +14 -0
- package/lib/build/ObjectSelect/ObjectSelect.stories.d.ts.map +1 -0
- package/lib/build/ObjectSelect/ObjectSelect.stories.js +247 -0
- package/lib/build/ObjectSelect/ObjectSelect.stories.js.map +1 -0
- package/lib/build/ObjectSelect/ObjectSelect.styles.d.ts +4 -0
- package/lib/build/ObjectSelect/ObjectSelect.styles.d.ts.map +1 -0
- package/lib/build/ObjectSelect/ObjectSelect.styles.js +27 -0
- package/lib/build/ObjectSelect/ObjectSelect.styles.js.map +1 -0
- package/lib/build/Workbench/Workbench.stories.d.ts.map +1 -1
- package/lib/build/Workbench/Workbench.stories.js +2 -5
- package/lib/build/Workbench/Workbench.stories.js.map +1 -1
- package/lib/core/AppShell/AppShell.stories.d.ts +1 -0
- package/lib/core/AppShell/AppShell.stories.d.ts.map +1 -1
- package/lib/core/AppShell/AppShell.stories.js +3 -1
- package/lib/core/AppShell/AppShell.stories.js.map +1 -1
- package/lib/core/FieldGroup/FieldGroup.stories.d.ts +2 -0
- package/lib/core/FieldGroup/FieldGroup.stories.d.ts.map +1 -1
- package/lib/core/FieldGroup/FieldGroup.stories.js +7 -3
- package/lib/core/FieldGroup/FieldGroup.stories.js.map +1 -1
- package/lib/core/File/FileDisplay.stories.d.ts.map +1 -1
- package/lib/core/File/FileDisplay.stories.js +17 -29
- package/lib/core/File/FileDisplay.stories.js.map +1 -1
- package/lib/core/HTML/HTML.stories.d.ts +6 -0
- package/lib/core/HTML/HTML.stories.d.ts.map +1 -0
- package/lib/core/HTML/HTML.stories.js +14 -0
- package/lib/core/HTML/HTML.stories.js.map +1 -0
- package/lib/rte/Editor/Editor.stories.js +1 -1
- package/lib/rte/Editor/Editor.stories.js.map +1 -1
- package/lib/social/Email/Email.stories.d.ts.map +1 -1
- package/lib/social/Email/Email.stories.js +23 -1
- package/lib/social/Email/Email.stories.js.map +1 -1
- package/package.json +16 -16
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Meta } from '@storybook/react';
|
|
3
|
+
import { DynamicContentEditorProps } from '@pega/cosmos-react-build';
|
|
3
4
|
declare const _default: Meta<import("@storybook/react").Args>;
|
|
4
5
|
export default _default;
|
|
5
|
-
export
|
|
6
|
+
export interface DynamicContentEditorStoryProps extends DynamicContentEditorProps {
|
|
7
|
+
}
|
|
8
|
+
export declare const DynamicContentEditorDemo: (args: DynamicContentEditorStoryProps) => JSX.Element;
|
|
6
9
|
//# sourceMappingURL=DynamicContentEditor.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicContentEditor.stories.d.ts","sourceRoot":"","sources":["../../../src/build/DynamicContentEditor/DynamicContentEditor.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;;
|
|
1
|
+
{"version":3,"file":"DynamicContentEditor.stories.d.ts","sourceRoot":"","sources":["../../../src/build/DynamicContentEditor/DynamicContentEditor.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAexC,OAAO,EAEL,yBAAyB,EAE1B,MAAM,0BAA0B,CAAC;;AAIlC,wBAGU;AAEV,MAAM,WAAW,8BAA+B,SAAQ,yBAAyB;CAAG;AAEpF,eAAO,MAAM,wBAAwB,SAAU,8BAA8B,gBA0G5E,CAAC"}
|
|
@@ -6,9 +6,23 @@ export default {
|
|
|
6
6
|
title: 'Build/DynamicContentEditor',
|
|
7
7
|
component: DynamicContentEditor
|
|
8
8
|
};
|
|
9
|
-
export const DynamicContentEditorDemo = () => {
|
|
9
|
+
export const DynamicContentEditorDemo = (args) => {
|
|
10
10
|
const [html, setHtml] = useState('<p>Hi <pega-reference role="button" contenteditable="false" data-rule-type="field" data-rule-id="CustomerName">CustomerName</pega-reference><p>please check this <a href="https://google.com">link</a></p></p>');
|
|
11
11
|
const rteRef = useRef(null);
|
|
12
|
+
const fieldItems = [
|
|
13
|
+
{ id: 'CustomerName', primary: 'CustomerName' },
|
|
14
|
+
{ id: 'Address', primary: 'Address' },
|
|
15
|
+
{ id: 'Locality', primary: 'Locality' },
|
|
16
|
+
{ id: 'Country', primary: 'Country' },
|
|
17
|
+
{ id: 'Region', primary: 'Region' },
|
|
18
|
+
{ id: 'Occupation', primary: 'Occupation' },
|
|
19
|
+
{ id: 'City', primary: 'City' },
|
|
20
|
+
{ id: 'Colony', primary: 'Colony' },
|
|
21
|
+
{ id: 'Lastname', primary: 'Lastname' },
|
|
22
|
+
{ id: 'Preference', primary: 'Preference' },
|
|
23
|
+
{ id: 'Currency', primary: 'Currency' },
|
|
24
|
+
{ id: 'Iconname', primary: 'Iconname' }
|
|
25
|
+
];
|
|
12
26
|
const onImageAdded = (image, id) => {
|
|
13
27
|
const src = URL.createObjectURL(image);
|
|
14
28
|
rteRef.current?.appendImage({ src, alt: image.name }, id);
|
|
@@ -44,6 +58,7 @@ export const DynamicContentEditorDemo = () => {
|
|
|
44
58
|
{ id: 'Occupation', text: 'Occupation' }
|
|
45
59
|
]} key={selectedField?.id} label='Field' updateSelection={updateSelection} placeholder={t('select')} defaultSelection={selectedField}/>
|
|
46
60
|
</Flex>);
|
|
61
|
+
const onActiveFieldChange = (field) => setSelectedField(field);
|
|
47
62
|
return (<Flex container={{ direction: 'column', gap: 2 }}>
|
|
48
63
|
<Card>
|
|
49
64
|
<CardContent>
|
|
@@ -55,7 +70,7 @@ export const DynamicContentEditorDemo = () => {
|
|
|
55
70
|
</Button>
|
|
56
71
|
</CardFooter>
|
|
57
72
|
</Card>
|
|
58
|
-
<DynamicContentEditor defaultValue={html} onImageAdded={onImageAdded} ref={rteRef} label='Dynamic content editor' toolbar={['inline-styling', 'lists', 'indentation', 'links', 'images']} form={{ onSubmit, dynamicContentPicker }} onActiveFieldChange={
|
|
73
|
+
<DynamicContentEditor defaultValue={args.defaultValue || html} onImageAdded={onImageAdded} ref={rteRef} label='Dynamic content editor' toolbar={['inline-styling', 'lists', 'indentation', 'links', 'images']} form={args.form || { onSubmit, dynamicContentPicker }} onActiveFieldChange={args.onActiveFieldChange || onActiveFieldChange} fieldItems={args.fieldItems || fieldItems}/>
|
|
59
74
|
<Flex container={{ gap: 1 }}>
|
|
60
75
|
<Button onClick={() => handleShowHtml()}>Show HTML</Button>
|
|
61
76
|
</Flex>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicContentEditor.stories.jsx","sourceRoot":"","sources":["../../../src/build/DynamicContentEditor/DynamicContentEditor.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,OAAO,EACR,MAAM,yBAAyB,CAAC;AAEjC,OAAO,
|
|
1
|
+
{"version":3,"file":"DynamicContentEditor.stories.jsx","sourceRoot":"","sources":["../../../src/build/DynamicContentEditor/DynamicContentEditor.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,OAAO,EACR,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,oBAAoB,EAGrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,aAAqC,MAAM,iBAAiB,CAAC;AAEpE,eAAe;IACb,KAAK,EAAE,4BAA4B;IACnC,SAAS,EAAE,oBAAoB;CACxB,CAAC;AAIV,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAoC,EAAE,EAAE;IAC/E,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAC9B,gNAAgN,CACjN,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAc,IAAI,CAAC,CAAC;IAEzC,MAAM,UAAU,GAA4C;QAC1D,EAAE,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE;QAC/C,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE;QACrC,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE;QACvC,EAAE,EAAE,EAAE,SAAS,EAAE,O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,CAC1B;QAAA,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC,SAAS,EAAE,MAAM,CAC5D;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { Meta } from '@storybook/react';\nimport { useRef, useState, useCallback } from 'react';\n\nimport {\n Button,\n Card,\n CardContent,\n CardFooter,\n Flex,\n TextArea,\n useAutoResize,\n useConsolidatedRef,\n useI18n\n} from '@pega/cosmos-react-core';\nimport { EditorState } from '@pega/cosmos-react-rte';\nimport {\n DynamicContentEditor,\n DynamicContentEditorProps,\n ItemType\n} from '@pega/cosmos-react-build';\n\nimport FieldSelector, { FieldSelectorProps } from './FieldSelector';\n\nexport default {\n title: 'Build/DynamicContentEditor',\n component: DynamicContentEditor\n} as Meta;\n\nexport interface DynamicContentEditorStoryProps extends DynamicContentEditorProps {}\n\nexport const DynamicContentEditorDemo = (args: DynamicContentEditorStoryProps) => {\n const [html, setHtml] = useState(\n '<p>Hi <pega-reference role=\"button\" contenteditable=\"false\" data-rule-type=\"field\" data-rule-id=\"CustomerName\">CustomerName</pega-reference><p>please check this <a href=\"https://google.com\">link</a></p></p>'\n );\n const rteRef = useRef<EditorState>(null);\n\n const fieldItems: DynamicContentEditorProps['fieldItems'] = [\n { id: 'CustomerName', primary: 'CustomerName' },\n { id: 'Address', primary: 'Address' },\n { id: 'Locality', primary: 'Locality' },\n { id: 'Country', primary: 'Country' },\n { id: 'Region', primary: 'Region' },\n { id: 'Occupation', primary: 'Occupation' },\n { id: 'City', primary: 'City' },\n { id: 'Colony', primary: 'Colony' },\n { id: 'Lastname', primary: 'Lastname' },\n { id: 'Preference', primary: 'Preference' },\n { id: 'Currency', primary: 'Currency' },\n { id: 'Iconname', primary: 'Iconname' }\n ];\n\n const onImageAdded = (image: File, id: string) => {\n const src = URL.createObjectURL(image);\n rteRef.current?.appendImage({ src, alt: image.name }, id);\n };\n const [textAreaRef, resizeTextArea] = useAutoResize<HTMLTextAreaElement>(undefined, 100);\n const ref = useRef(null);\n const consolidatedRef = useConsolidatedRef(textAreaRef, ref);\n const handleShowHtml = () => {\n resizeTextArea();\n setHtml(rteRef.current?.getHtml() || '');\n };\n const t = useI18n();\n const [selectedField, setSelectedField] = useState<ItemType>({\n id: '',\n text: ''\n });\n\n const updateSelection: FieldSelectorProps['updateSelection'] = (selectedItem: ItemType) => {\n setSelectedField(selectedItem);\n };\n const onSubmit = useCallback(\n (insertField: (selectedField: ItemType) => void) => {\n insertField(selectedField);\n },\n [selectedField]\n );\n\n const dynamicContentPicker = (\n <Flex\n container={{\n gap: 2,\n direction: 'column'\n }}\n >\n <FieldSelector\n itemList={[\n { id: 'CustomerName', text: 'CustomerName' },\n { id: 'Address', text: 'Address' },\n { id: 'Locality', text: 'Locality' },\n { id: 'Country', text: 'Country' },\n { id: 'Region', text: 'Region' },\n { id: 'Occupation', text: 'Occupation' }\n ]}\n key={selectedField?.id}\n label='Field'\n updateSelection={updateSelection}\n placeholder={t('select')}\n defaultSelection={selectedField}\n />\n </Flex>\n );\n const onActiveFieldChange = (field: ItemType) => setSelectedField(field);\n\n return (\n <Flex container={{ direction: 'column', gap: 2 }}>\n <Card>\n <CardContent>\n <TextArea\n value={html}\n onChange={e => setHtml(e.target.value)}\n autoResize\n ref={consolidatedRef}\n />\n </CardContent>\n <CardFooter>\n <Button onClick={() => rteRef.current?.insertHtml(html.trim(), true)}>\n Overwrite RTE with new HTML\n </Button>\n </CardFooter>\n </Card>\n <DynamicContentEditor\n defaultValue={args.defaultValue || html}\n onImageAdded={onImageAdded}\n ref={rteRef}\n label='Dynamic content editor'\n toolbar={['inline-styling', 'lists', 'indentation', 'links', 'images']}\n form={args.form || { onSubmit, dynamicContentPicker }}\n onActiveFieldChange={args.onActiveFieldChange || onActiveFieldChange}\n fieldItems={args.fieldItems || fieldItems}\n />\n <Flex container={{ gap: 1 }}>\n <Button onClick={() => handleShowHtml()}>Show HTML</Button>\n </Flex>\n </Flex>\n );\n};\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DateFunctionsByType, Field } from '@pega/cosmos-react-condition-builder';
|
|
2
|
+
export declare const skeletonData: {
|
|
3
|
+
id: string;
|
|
4
|
+
primary: string;
|
|
5
|
+
secondary: string[];
|
|
6
|
+
href: string;
|
|
7
|
+
}[];
|
|
8
|
+
export declare const dataPages: {
|
|
9
|
+
id: string;
|
|
10
|
+
primary: string;
|
|
11
|
+
secondary: string[];
|
|
12
|
+
href: string;
|
|
13
|
+
}[];
|
|
14
|
+
export declare const demoFields: Field[];
|
|
15
|
+
export declare const demoDateFunctions: DateFunctionsByType;
|
|
16
|
+
//# sourceMappingURL=ObjectSelect.mocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectSelect.mocks.d.ts","sourceRoot":"","sources":["../../../src/build/ObjectSelect/ObjectSelect.mocks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAElF,eAAO,MAAM,YAAY;;;;;GAmCxB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;GAyBrB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAAK,EAkD7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,mBAqB/B,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
export const skeletonData = [
|
|
2
|
+
{
|
|
3
|
+
id: '01-1',
|
|
4
|
+
primary: 'primary-link-1',
|
|
5
|
+
secondary: ['secondary-1'],
|
|
6
|
+
href: 'http://www.pega.com'
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
id: '01-2',
|
|
10
|
+
primary: 'primary-link-2',
|
|
11
|
+
secondary: [
|
|
12
|
+
'secondary-1',
|
|
13
|
+
'secondary-2',
|
|
14
|
+
'secondary-3',
|
|
15
|
+
'secondary-4',
|
|
16
|
+
'secondary-5',
|
|
17
|
+
'secondary-6',
|
|
18
|
+
'secondary-7',
|
|
19
|
+
'secondary-8',
|
|
20
|
+
'secondary-9'
|
|
21
|
+
],
|
|
22
|
+
href: 'http://www.pega.com'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: '01-3',
|
|
26
|
+
primary: 'primary-link-3',
|
|
27
|
+
secondary: ['secondary-1', 'secondary-2'],
|
|
28
|
+
href: 'http://www.pega.com'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: '01-4',
|
|
32
|
+
primary: 'primary-link-4',
|
|
33
|
+
secondary: ['secondary-1', 'secondary-2'],
|
|
34
|
+
href: 'http://www.pega.com'
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
export const dataPages = [
|
|
38
|
+
{
|
|
39
|
+
id: '01-1',
|
|
40
|
+
primary: 'MortgageRequestList-DataSource',
|
|
41
|
+
secondary: ['Scope', 'O1XPTI-CCompass-Work-MortgageRequest'],
|
|
42
|
+
href: 'http://www.pega.com'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: '01-2',
|
|
46
|
+
primary: 'Credit Scores List Data Source',
|
|
47
|
+
secondary: ['Scope', 'CreditScore'],
|
|
48
|
+
href: 'http://www.pega.com'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: '01-3',
|
|
52
|
+
primary: 'GetAutoLoanByIDDataSource',
|
|
53
|
+
secondary: ['Scope', 'O1XPTI-CCompass-Work-AutoLoan'],
|
|
54
|
+
href: 'http://www.pega.com'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: '01-4',
|
|
58
|
+
primary: 'DS_pyMyWorkList',
|
|
59
|
+
secondary: ['Scope', 'Assign-Worklist'],
|
|
60
|
+
href: 'http://www.pega.com'
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
export const demoFields = [
|
|
64
|
+
{ name: 'employeeId', label: 'Employee ID', type: 'TEXT' },
|
|
65
|
+
{ name: 'firstName', label: 'First Name', type: 'TEXT' },
|
|
66
|
+
{ name: 'lastName', label: 'Last Name', type: 'TEXT' },
|
|
67
|
+
{ name: 'gender', label: 'Gender', type: 'TEXT' },
|
|
68
|
+
{
|
|
69
|
+
name: 'department',
|
|
70
|
+
label: 'Department',
|
|
71
|
+
type: 'TEXT',
|
|
72
|
+
possibleValues: [
|
|
73
|
+
'Customer Service',
|
|
74
|
+
'Engineering',
|
|
75
|
+
'Facilities',
|
|
76
|
+
'Finance',
|
|
77
|
+
'HR',
|
|
78
|
+
'IT',
|
|
79
|
+
'Sales'
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
{ name: 'age', label: 'Age', type: 'NUMBER' },
|
|
83
|
+
{ name: 'experience', label: 'Experience (yrs)', type: 'NUMBER' },
|
|
84
|
+
{ name: 'salary', label: 'Salary', type: 'NUMBER' },
|
|
85
|
+
{ name: 'hireDate', label: 'Hire Date', type: 'DATE_ONLY' },
|
|
86
|
+
{ name: 'dateOfBirth', label: 'Date of Birth', type: 'DATE_ONLY' },
|
|
87
|
+
{
|
|
88
|
+
name: 'shiftStartTime',
|
|
89
|
+
label: 'Shift start time',
|
|
90
|
+
type: 'TIME_ONLY',
|
|
91
|
+
groupLabel: 'Technical details'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'shiftEndTime',
|
|
95
|
+
label: 'Shift end time',
|
|
96
|
+
type: 'TIME_ONLY',
|
|
97
|
+
groupLabel: 'Technical details'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'lastActivityAt',
|
|
101
|
+
label: 'Last activity at',
|
|
102
|
+
type: 'DATE_TIME',
|
|
103
|
+
groupLabel: 'Technical details'
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'nextPasswordReset',
|
|
107
|
+
label: 'Next password reset',
|
|
108
|
+
type: 'DATE_TIME',
|
|
109
|
+
groupLabel: 'Technical details'
|
|
110
|
+
},
|
|
111
|
+
{ name: 'isSeniorCitizen', label: 'Is Senior Citizen', type: 'BOOLEAN' },
|
|
112
|
+
{ name: 'isRemoteEmployee', label: 'Is Remote Employee', type: 'BOOLEAN' }
|
|
113
|
+
];
|
|
114
|
+
export const demoDateFunctions = {
|
|
115
|
+
DATE_TIME: [
|
|
116
|
+
'YEARS',
|
|
117
|
+
'QUARTERS',
|
|
118
|
+
'MONTHS',
|
|
119
|
+
'WEEKS',
|
|
120
|
+
'DAYS',
|
|
121
|
+
'HOURS',
|
|
122
|
+
'MONTHS_OF_YEAR',
|
|
123
|
+
'DAYS_OF_MONTH',
|
|
124
|
+
'DAYS_OF_WEEK'
|
|
125
|
+
],
|
|
126
|
+
DATE_ONLY: [
|
|
127
|
+
'YEARS',
|
|
128
|
+
'QUARTERS',
|
|
129
|
+
'MONTHS',
|
|
130
|
+
'WEEKS',
|
|
131
|
+
'MONTHS_OF_YEAR',
|
|
132
|
+
'DAYS_OF_MONTH',
|
|
133
|
+
'DAYS_OF_WEEK'
|
|
134
|
+
]
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=ObjectSelect.mocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectSelect.mocks.js","sourceRoot":"","sources":["../../../src/build/ObjectSelect/ObjectSelect.mocks.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B;QACE,EAAE,EAAE,MAAM;QACV,OAAO,EAAE,gBAAgB;QACzB,SAAS,EAAE,CAAC,aAAa,CAAC;QAC1B,IAAI,EAAE,qBAAqB;KAC5B;IACD;QACE,EAAE,EAAE,MAAM;QACV,OAAO,EAAE,gBAAgB;QACzB,SAAS,EAAE;YACT,aAAa;YACb,aAAa;YACb,aAAa;YACb,aAAa;YACb,aAAa;YACb,aAAa;YACb,aAAa;YACb,aAAa;YACb,aAAa;SACd;QACD,IAAI,EAAE,qBAAqB;KAC5B;IACD;QACE,EAAE,EAAE,MAAM;QACV,O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AE;CAC3E,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAwB;IACpD,SAAS,EAAE;QACT,OAAO;QACP,UAAU;QACV,QAAQ;QACR,OAAO;QACP,MAAM;QACN,OAAO;QACP,gBAAgB;QAChB,eAAe;QACf,cAAc;KACf;IACD,SAAS,EAAE;QACT,OAAO;QACP,UAAU;QACV,QAAQ;QACR,OAAO;QACP,gBAAgB;QAChB,eAAe;QACf,cAAc;KACf;CACF,CAAC","sourcesContent":["// cSpell:words XPTI\nimport { DateFunctionsByType, Field } from '@pega/cosmos-react-condition-builder';\n\nexport const skeletonData = [\n {\n id: '01-1',\n primary: 'primary-link-1',\n secondary: ['secondary-1'],\n href: 'http://www.pega.com'\n },\n {\n id: '01-2',\n primary: 'primary-link-2',\n secondary: [\n 'secondary-1',\n 'secondary-2',\n 'secondary-3',\n 'secondary-4',\n 'secondary-5',\n 'secondary-6',\n 'secondary-7',\n 'secondary-8',\n 'secondary-9'\n ],\n href: 'http://www.pega.com'\n },\n {\n id: '01-3',\n primary: 'primary-link-3',\n secondary: ['secondary-1', 'secondary-2'],\n href: 'http://www.pega.com'\n },\n {\n id: '01-4',\n primary: 'primary-link-4',\n secondary: ['secondary-1', 'secondary-2'],\n href: 'http://www.pega.com'\n }\n];\n\nexport const dataPages = [\n {\n id: '01-1',\n primary: 'MortgageRequestList-DataSource',\n secondary: ['Scope', 'O1XPTI-CCompass-Work-MortgageRequest'],\n href: 'http://www.pega.com'\n },\n {\n id: '01-2',\n primary: 'Credit Scores List Data Source',\n secondary: ['Scope', 'CreditScore'],\n href: 'http://www.pega.com'\n },\n {\n id: '01-3',\n primary: 'GetAutoLoanByIDDataSource',\n secondary: ['Scope', 'O1XPTI-CCompass-Work-AutoLoan'],\n href: 'http://www.pega.com'\n },\n {\n id: '01-4',\n primary: 'DS_pyMyWorkList',\n secondary: ['Scope', 'Assign-Worklist'],\n href: 'http://www.pega.com'\n }\n];\n\nexport const demoFields: Field[] = [\n { name: 'employeeId', label: 'Employee ID', type: 'TEXT' },\n { name: 'firstName', label: 'First Name', type: 'TEXT' },\n { name: 'lastName', label: 'Last Name', type: 'TEXT' },\n { name: 'gender', label: 'Gender', type: 'TEXT' },\n {\n name: 'department',\n label: 'Department',\n type: 'TEXT',\n possibleValues: [\n 'Customer Service',\n 'Engineering',\n 'Facilities',\n 'Finance',\n 'HR',\n 'IT',\n 'Sales'\n ]\n },\n { name: 'age', label: 'Age', type: 'NUMBER' },\n { name: 'experience', label: 'Experience (yrs)', type: 'NUMBER' },\n { name: 'salary', label: 'Salary', type: 'NUMBER' },\n { name: 'hireDate', label: 'Hire Date', type: 'DATE_ONLY' },\n { name: 'dateOfBirth', label: 'Date of Birth', type: 'DATE_ONLY' },\n {\n name: 'shiftStartTime',\n label: 'Shift start time',\n type: 'TIME_ONLY',\n groupLabel: 'Technical details'\n },\n {\n name: 'shiftEndTime',\n label: 'Shift end time',\n type: 'TIME_ONLY',\n groupLabel: 'Technical details'\n },\n {\n name: 'lastActivityAt',\n label: 'Last activity at',\n type: 'DATE_TIME',\n groupLabel: 'Technical details'\n },\n {\n name: 'nextPasswordReset',\n label: 'Next password reset',\n type: 'DATE_TIME',\n groupLabel: 'Technical details'\n },\n { name: 'isSeniorCitizen', label: 'Is Senior Citizen', type: 'BOOLEAN' },\n { name: 'isRemoteEmployee', label: 'Is Remote Employee', type: 'BOOLEAN' }\n];\n\nexport const demoDateFunctions: DateFunctionsByType = {\n DATE_TIME: [\n 'YEARS',\n 'QUARTERS',\n 'MONTHS',\n 'WEEKS',\n 'DAYS',\n 'HOURS',\n 'MONTHS_OF_YEAR',\n 'DAYS_OF_MONTH',\n 'DAYS_OF_WEEK'\n ],\n DATE_ONLY: [\n 'YEARS',\n 'QUARTERS',\n 'MONTHS',\n 'WEEKS',\n 'MONTHS_OF_YEAR',\n 'DAYS_OF_MONTH',\n 'DAYS_OF_WEEK'\n ]\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Meta, Story } from '@storybook/react';
|
|
2
|
+
import { MouseEvent } from 'react';
|
|
3
|
+
import { ObjectSelectProps } from '@pega/cosmos-react-build';
|
|
4
|
+
declare const _default: Meta<import("@storybook/react").Args>;
|
|
5
|
+
export default _default;
|
|
6
|
+
export interface ObjectSelectStoryProps extends ObjectSelectProps {
|
|
7
|
+
onSubmit?: (id: string, e: MouseEvent<HTMLElement>) => void;
|
|
8
|
+
onCancel?: (id: string, e: MouseEvent<HTMLElement>) => void;
|
|
9
|
+
popoverContent?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const ObjectSelectSkeleton: Story<ObjectSelectStoryProps>;
|
|
12
|
+
export declare const ObjectSelectDemo: Story<ObjectSelectStoryProps>;
|
|
13
|
+
export declare const ObjectSelectDemoInForm: () => JSX.Element | null;
|
|
14
|
+
//# sourceMappingURL=ObjectSelect.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectSelect.stories.d.ts","sourceRoot":"","sources":["../../../src/build/ObjectSelect/ObjectSelect.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAOL,UAAU,EAEX,MAAM,OAAO,CAAC;AAuBf,OAAO,EAAgB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;;AAoB3E,wBAGU;AAcV,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC5D,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,sBAAsB,CA2C9D,CAAC;AA6PF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,sBAAsB,CAK1D,CAAC;AAqFF,eAAO,MAAM,sBAAsB,0BA8ElC,CAAC"}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { useReducer, useContext, useState } from 'react';
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
3
|
+
import { Form, Button, Flex, Input, ToasterContext, TextArea, Card, CardContent, Drawer, Text, FieldValueList, Icon, registerIcon, menuHelpers, useI18n, StyledRegion } from '@pega/cosmos-react-core';
|
|
4
|
+
import { ObjectSelect } from '@pega/cosmos-react-build';
|
|
5
|
+
import { AtomicCondition, getInitConditionForLhs, formatCondition } from '@pega/cosmos-react-condition-builder';
|
|
6
|
+
import * as times from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
7
|
+
import { StyledDrawerContent, StyledCodeBlock, StyledConfigurationContent } from './ObjectSelect.styles';
|
|
8
|
+
import { skeletonData, dataPages, demoFields, demoDateFunctions } from './ObjectSelect.mocks';
|
|
9
|
+
registerIcon(times);
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Build/ObjectSelect',
|
|
12
|
+
component: ObjectSelect
|
|
13
|
+
};
|
|
14
|
+
export const ObjectSelectSkeleton = (args) => {
|
|
15
|
+
const [value, setValue] = useState(args.value);
|
|
16
|
+
return (<ObjectSelect {...args} items={skeletonData} value={value} onChange={id => {
|
|
17
|
+
const data = menuHelpers.getItem(skeletonData, id);
|
|
18
|
+
if (data) {
|
|
19
|
+
setValue({
|
|
20
|
+
id: data.id,
|
|
21
|
+
primary: data.primary,
|
|
22
|
+
href: data.href ?? '#',
|
|
23
|
+
meta: data.id !== '01-4' ? data.secondary?.join(' ') : ''
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
else
|
|
27
|
+
setValue(undefined);
|
|
28
|
+
}} configuration={{
|
|
29
|
+
label: 'Gear button label',
|
|
30
|
+
heading: 'Popover heading',
|
|
31
|
+
primaryAction: {
|
|
32
|
+
id: 'primaryAction',
|
|
33
|
+
text: 'Primary action text',
|
|
34
|
+
onClick: args.onSubmit
|
|
35
|
+
},
|
|
36
|
+
secondaryAction: {
|
|
37
|
+
id: 'secondaryAction',
|
|
38
|
+
text: 'Secondary action text',
|
|
39
|
+
onClick: args.onCancel
|
|
40
|
+
},
|
|
41
|
+
content: (<StyledConfigurationContent>
|
|
42
|
+
<StyledRegion style={{ minHeight: '20vh' }}/>
|
|
43
|
+
</StyledConfigurationContent>)
|
|
44
|
+
}} onPreview={args.onPreview}/>);
|
|
45
|
+
};
|
|
46
|
+
ObjectSelectSkeleton.args = {
|
|
47
|
+
label: 'Object select label',
|
|
48
|
+
labelHidden: false,
|
|
49
|
+
info: 'Object select info text',
|
|
50
|
+
placeholder: '',
|
|
51
|
+
status: undefined,
|
|
52
|
+
required: false,
|
|
53
|
+
disabled: false,
|
|
54
|
+
readOnly: false,
|
|
55
|
+
onPreview: action('Clicked preview link'),
|
|
56
|
+
onSubmit: action('Clicked submit button'),
|
|
57
|
+
onCancel: action('Clicked cancel button')
|
|
58
|
+
};
|
|
59
|
+
ObjectSelectSkeleton.argTypes = {
|
|
60
|
+
label: { control: { type: 'text' } },
|
|
61
|
+
labelHidden: { control: { type: 'boolean' } },
|
|
62
|
+
info: { control: { type: 'text' } },
|
|
63
|
+
placeholder: { control: { type: 'text' } },
|
|
64
|
+
status: { options: [undefined, 'success', 'warning', 'error'], control: { type: 'select' } },
|
|
65
|
+
required: { control: { type: 'boolean' } },
|
|
66
|
+
disabled: { control: { type: 'boolean' } },
|
|
67
|
+
readOnly: { control: { type: 'boolean' } },
|
|
68
|
+
onPreview: { table: { disable: true } },
|
|
69
|
+
onSubmit: { table: { disable: true } },
|
|
70
|
+
onCancel: { table: { disable: true } }
|
|
71
|
+
};
|
|
72
|
+
const ViewportDrawer = ({ drawerData, drawerOpen, setDrawerOpen }) => {
|
|
73
|
+
const fields = drawerData?.secondary?.map((data, index) => {
|
|
74
|
+
return {
|
|
75
|
+
id: (index + 1).toString(),
|
|
76
|
+
name: data?.toString() ?? '',
|
|
77
|
+
value: data
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
return (<Drawer open={drawerOpen} onOuterClick={() => {
|
|
81
|
+
setDrawerOpen(false);
|
|
82
|
+
}} position='fixed' size='30rem' nullWhenClosed shadow>
|
|
83
|
+
<Flex as={StyledDrawerContent} container={{
|
|
84
|
+
direction: 'column',
|
|
85
|
+
alignItems: 'start',
|
|
86
|
+
gap: 2,
|
|
87
|
+
pad: 4
|
|
88
|
+
}}>
|
|
89
|
+
<Flex container={{ direction: 'column', gap: 1 }}>
|
|
90
|
+
<Flex container={{ gap: 2, alignItems: 'center' }}>
|
|
91
|
+
<Button variant='simple' label='Close drawer' icon onClick={() => setDrawerOpen(false)}>
|
|
92
|
+
<Icon name='times'/>
|
|
93
|
+
</Button>
|
|
94
|
+
<Text variant='h3'>{drawerData?.primary}</Text>
|
|
95
|
+
</Flex>
|
|
96
|
+
<Flex container={{ direction: 'column', gap: 2, pad: 1 }}>
|
|
97
|
+
<Text as='p'>
|
|
98
|
+
This is a mock representation for the parameters of the {drawerData?.primary} rule
|
|
99
|
+
</Text>
|
|
100
|
+
<FieldValueList variant='inline' fields={fields}/>
|
|
101
|
+
</Flex>
|
|
102
|
+
</Flex>
|
|
103
|
+
</Flex>
|
|
104
|
+
</Drawer>);
|
|
105
|
+
};
|
|
106
|
+
const ConfigurationContent = (args) => {
|
|
107
|
+
const [showErrorIndicators] = useState(false);
|
|
108
|
+
const ConditionBuilder = (<AtomicCondition condition={args.condition} fields={demoFields} indicateErrors={showErrorIndicators} dateFunctions={demoDateFunctions} onChange={c => args.setCondition(c)} itemDirection='row' showLhsAsLabel={false} validRhsTypes={args.validRHSTypes}/>);
|
|
109
|
+
const Inputs = (<Flex container={{ direction: 'column', gap: 2 }}>
|
|
110
|
+
<Text variant='h4'>Inputs</Text>
|
|
111
|
+
<Flex container={{ direction: 'column', gap: 1 }}>
|
|
112
|
+
<Flex container={{ alignItems: 'end', gap: 1 }}>
|
|
113
|
+
<Input label='Name' type='text' defaultValue='Sample key 1' disabled readOnly={args.readOnly}/>
|
|
114
|
+
<Input label='Value' type='text' defaultValue='Sample value 1' readOnly={args.readOnly} disabled={args.disabled}/>
|
|
115
|
+
</Flex>
|
|
116
|
+
<Flex container={{ alignItems: 'end', gap: 1 }}>
|
|
117
|
+
<Input label='Name 2' labelHidden type='text' defaultValue='Sample key 2' disabled readOnly={args.readOnly}/>
|
|
118
|
+
<Input label='Value 2' labelHidden type='text' defaultValue='Sample value 2' readOnly={args.readOnly} disabled={args.disabled}/>
|
|
119
|
+
</Flex>
|
|
120
|
+
</Flex>
|
|
121
|
+
</Flex>);
|
|
122
|
+
return args.popoverContent === 'advanced' ? ConditionBuilder : Inputs;
|
|
123
|
+
};
|
|
124
|
+
const ObjectSelectComp = ({ popoverContent, ...args }) => {
|
|
125
|
+
const t = useI18n();
|
|
126
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
127
|
+
const [drawerData, setDrawerData] = useState(dataPages[0]);
|
|
128
|
+
const [value, setValue] = useState(args.value);
|
|
129
|
+
const convertRhsTypes = (useLiteralRHSType, useFieldRHSType, useRelativeDatesType, dateFunctions) => {
|
|
130
|
+
const setRhsTypes = new Set();
|
|
131
|
+
if (useLiteralRHSType)
|
|
132
|
+
setRhsTypes.add('LITERAL');
|
|
133
|
+
if (useFieldRHSType)
|
|
134
|
+
setRhsTypes.add('FIELD');
|
|
135
|
+
if (dateFunctions)
|
|
136
|
+
setRhsTypes.add('DATE_FUNCTION');
|
|
137
|
+
if (useRelativeDatesType)
|
|
138
|
+
setRhsTypes.add('RELATIVE_DATE');
|
|
139
|
+
return setRhsTypes;
|
|
140
|
+
};
|
|
141
|
+
const validRHSTypes = convertRhsTypes(true, true, true, demoDateFunctions);
|
|
142
|
+
const [submitCondition, setSubmitCondition] = useState(undefined);
|
|
143
|
+
const [condition, setCondition] = useState(() => submitCondition ||
|
|
144
|
+
getInitConditionForLhs({ field: 'age' }, demoFields, validRHSTypes, undefined, demoDateFunctions));
|
|
145
|
+
const handleSubmission = () => {
|
|
146
|
+
setSubmitCondition(condition);
|
|
147
|
+
};
|
|
148
|
+
return (<Flex container={{ direction: 'column', gap: 1 }}>
|
|
149
|
+
<ObjectSelect {...args} onChange={id => {
|
|
150
|
+
const data = menuHelpers.getItem(dataPages, id);
|
|
151
|
+
if (data) {
|
|
152
|
+
setValue({
|
|
153
|
+
id: data.id,
|
|
154
|
+
primary: data.primary,
|
|
155
|
+
href: data.href ?? '#',
|
|
156
|
+
meta: data.id !== '01-4' ? data.secondary?.join(' ') : ''
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
else
|
|
160
|
+
setValue(undefined);
|
|
161
|
+
}} items={dataPages} configuration={{
|
|
162
|
+
label: args.disabled || args.readOnly ? 'View Configuration' : 'Edit Configuration',
|
|
163
|
+
heading: 'Map Parameters',
|
|
164
|
+
primaryAction: {
|
|
165
|
+
id: 'submit',
|
|
166
|
+
text: 'Submit',
|
|
167
|
+
onClick: popoverContent === 'advanced' ? handleSubmission : args.onSubmit
|
|
168
|
+
},
|
|
169
|
+
secondaryAction: {
|
|
170
|
+
id: 'cancel',
|
|
171
|
+
text: 'Cancel',
|
|
172
|
+
onClick: args.onCancel
|
|
173
|
+
},
|
|
174
|
+
content: (<ConfigurationContent {...args} popoverContent={popoverContent} condition={condition} setCondition={setCondition} validRHSTypes={validRHSTypes}/>)
|
|
175
|
+
}} value={value} onPreview={(id, e) => {
|
|
176
|
+
const data = menuHelpers.getItem(dataPages, id);
|
|
177
|
+
if (data)
|
|
178
|
+
setDrawerData(data);
|
|
179
|
+
setDrawerOpen(true);
|
|
180
|
+
args.onPreview?.(id, e);
|
|
181
|
+
}}/>
|
|
182
|
+
<ViewportDrawer drawerData={drawerData} drawerOpen={drawerOpen} setDrawerOpen={setDrawerOpen}/>
|
|
183
|
+
{popoverContent === 'advanced' && (<Card>
|
|
184
|
+
<CardContent>
|
|
185
|
+
<Text variant='h4'>Output:</Text>
|
|
186
|
+
<StyledCodeBlock>
|
|
187
|
+
{submitCondition ? JSON.stringify(submitCondition, null, 2) : '(No condition)'}
|
|
188
|
+
</StyledCodeBlock>
|
|
189
|
+
|
|
190
|
+
<Text variant='h4'>Formatted Output:</Text>
|
|
191
|
+
<StyledCodeBlock>
|
|
192
|
+
{submitCondition
|
|
193
|
+
? formatCondition({ condition: submitCondition }, demoFields, t)
|
|
194
|
+
: '(No condition)'}
|
|
195
|
+
</StyledCodeBlock>
|
|
196
|
+
</CardContent>
|
|
197
|
+
</Card>)}
|
|
198
|
+
</Flex>);
|
|
199
|
+
};
|
|
200
|
+
export const ObjectSelectDemo = ({ popoverContent, ...args }) => {
|
|
201
|
+
return <ObjectSelectComp {...args} popoverContent={popoverContent}/>;
|
|
202
|
+
};
|
|
203
|
+
ObjectSelectDemo.args = {
|
|
204
|
+
label: 'Data source',
|
|
205
|
+
labelHidden: false,
|
|
206
|
+
info: 'Select an appropriate data source',
|
|
207
|
+
placeholder: '',
|
|
208
|
+
status: undefined,
|
|
209
|
+
required: false,
|
|
210
|
+
disabled: false,
|
|
211
|
+
readOnly: false,
|
|
212
|
+
popoverContent: 'simple',
|
|
213
|
+
onPreview: () => { },
|
|
214
|
+
onSubmit: action('Clicked submit button'),
|
|
215
|
+
onCancel: action('Clicked cancel button')
|
|
216
|
+
};
|
|
217
|
+
ObjectSelectDemo.argTypes = {
|
|
218
|
+
label: { control: { type: 'text' } },
|
|
219
|
+
labelHidden: { control: { type: 'boolean' } },
|
|
220
|
+
info: { control: { type: 'text' } },
|
|
221
|
+
placeholder: { control: { type: 'text' } },
|
|
222
|
+
status: { options: [undefined, 'success', 'warning', 'error'], control: { type: 'select' } },
|
|
223
|
+
required: { control: { type: 'boolean' } },
|
|
224
|
+
disabled: { control: { type: 'boolean' } },
|
|
225
|
+
readOnly: { control: { type: 'boolean' } },
|
|
226
|
+
popoverContent: { options: ['simple', 'advanced'], control: { type: 'radio' } },
|
|
227
|
+
onPreview: { table: { disable: true } },
|
|
228
|
+
onSubmit: { table: { disable: true } },
|
|
229
|
+
onCancel: { table: { disable: true } }
|
|
230
|
+
};
|
|
231
|
+
const initFields = () => {
|
|
232
|
+
const common = { value: undefined, status: undefined };
|
|
233
|
+
return [
|
|
234
|
+
{
|
|
235
|
+
...common,
|
|
236
|
+
name: 'name',
|
|
237
|
+
required: true,
|
|
238
|
+
error: 'Please enter a valid name for table',
|
|
239
|
+
validator() {
|
|
240
|
+
if (!this.value)
|
|
241
|
+
return false;
|
|
242
|
+
return /^[a-z]{1}[a-z0-9]+$/i.test(this.value);
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
...common,
|
|
247
|
+
name: 'description',
|
|
248
|
+
required: true,
|
|
249
|
+
help: 'Give an appropriate description for the table',
|
|
250
|
+
error: 'Field cannot be empty',
|
|
251
|
+
validator() {
|
|
252
|
+
if (!this.value)
|
|
253
|
+
return false;
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
];
|
|
258
|
+
};
|
|
259
|
+
const fieldReducer = (fields, { target, type }) => {
|
|
260
|
+
return fields.map(field => {
|
|
261
|
+
if (field.name === target.name) {
|
|
262
|
+
field.value = target.value;
|
|
263
|
+
if (type === 'blur' || field.status === 'error') {
|
|
264
|
+
if ((field.required || field.value) && !field.validator()) {
|
|
265
|
+
field.status = 'error';
|
|
266
|
+
field.info = field.error;
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
field.status = undefined;
|
|
270
|
+
field.info = field.help;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return field;
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
export const ObjectSelectDemoInForm = () => {
|
|
278
|
+
const [fields, setField] = useReducer(fieldReducer, undefined, initFields);
|
|
279
|
+
const { push } = useContext(ToasterContext);
|
|
280
|
+
const name = fields.find(field => field.name === 'name');
|
|
281
|
+
const description = fields.find(field => field.name === 'description');
|
|
282
|
+
if (!name || !description)
|
|
283
|
+
return null;
|
|
284
|
+
const canSubmit = fields.every(field => field.value && field.validator());
|
|
285
|
+
const actions = (<>
|
|
286
|
+
<Button name='Cancel' variant='secondary' onClick={() => {
|
|
287
|
+
push({ content: 'Form cancelled!' });
|
|
288
|
+
}}>
|
|
289
|
+
Cancel
|
|
290
|
+
</Button>
|
|
291
|
+
<Button name='Submit' type='submit' variant='primary' disabled={!canSubmit}>
|
|
292
|
+
Submit
|
|
293
|
+
</Button>
|
|
294
|
+
</>);
|
|
295
|
+
return (<Card style={{ margin: 'auto', maxWidth: '37.5rem' }}>
|
|
296
|
+
<CardContent>
|
|
297
|
+
<Form actions={actions} onSubmit={(e) => {
|
|
298
|
+
e.preventDefault();
|
|
299
|
+
push({ content: 'Form submitted!' });
|
|
300
|
+
}} heading='Configure Table'>
|
|
301
|
+
<Flex container={{ direction: 'column', gap: 2 }} item={{ grow: 1 }}>
|
|
302
|
+
<Input name='name' label='Table name' value={name.value} required={name.required} status={name.status} info='Enter a valid table name' onChange={(e) => setField({ ...e })} onBlur={(e) => setField({ ...e })} autoComplete='off'/>
|
|
303
|
+
|
|
304
|
+
<TextArea name='description' required={description.required} label='Table description' status={description.status} info={description.info || description.help} onChange={(e) => setField({ ...e })} onBlur={(e) => setField({ ...e })}/>
|
|
305
|
+
<ObjectSelectComp label='Data page' info='Select an appropriate data page' items={[]} onChange={() => { }}/>
|
|
306
|
+
<ObjectSelectComp label='Visibility condition' info='Choose a when condition from list' items={[]} onChange={() => { }}/>
|
|
307
|
+
</Flex>
|
|
308
|
+
</Form>
|
|
309
|
+
</CardContent>
|
|
310
|
+
</Card>);
|
|
311
|
+
};
|
|
312
|
+
//# sourceMappingURL=ObjectSelect.stories.jsx.map
|