@pega/cosmos-react-demos 4.0.0-dev.15.5 → 4.0.0-dev.16.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.
Files changed (59) hide show
  1. package/jsx/core/AIButton/AIButton.mocks.d.ts +22 -0
  2. package/jsx/core/AIButton/AIButton.mocks.d.ts.map +1 -0
  3. package/jsx/core/AIButton/AIButton.mocks.js +136 -0
  4. package/jsx/core/AIButton/AIButton.mocks.js.map +1 -0
  5. package/jsx/core/AIButton/AIButton.stories.d.ts +19 -0
  6. package/jsx/core/AIButton/AIButton.stories.d.ts.map +1 -0
  7. package/jsx/core/AIButton/AIButton.stories.jsx +279 -0
  8. package/jsx/core/AIButton/AIButton.stories.jsx.map +1 -0
  9. package/jsx/core/FieldGroup/FieldGroup.stories.d.ts.map +1 -1
  10. package/jsx/core/FieldGroup/FieldGroup.stories.jsx +16 -5
  11. package/jsx/core/FieldGroup/FieldGroup.stories.jsx.map +1 -1
  12. package/jsx/core/MenuButton/MenuButton.stories.d.ts +1 -0
  13. package/jsx/core/MenuButton/MenuButton.stories.d.ts.map +1 -1
  14. package/jsx/core/MenuButton/MenuButton.stories.jsx +1 -1
  15. package/jsx/core/MenuButton/MenuButton.stories.jsx.map +1 -1
  16. package/jsx/core/SummaryList/SummaryList.stories.jsx +2 -2
  17. package/jsx/core/SummaryList/SummaryList.stories.jsx.map +1 -1
  18. package/jsx/work/Assignments/Assignments.stories.d.ts +11 -0
  19. package/jsx/work/Assignments/Assignments.stories.d.ts.map +1 -0
  20. package/jsx/work/Assignments/Assignments.stories.jsx +90 -0
  21. package/jsx/work/Assignments/Assignments.stories.jsx.map +1 -0
  22. package/jsx/work/CaseView/Attachments.mocks.d.ts.map +1 -1
  23. package/jsx/work/CaseView/Attachments.mocks.jsx +9 -1
  24. package/jsx/work/CaseView/Attachments.mocks.jsx.map +1 -1
  25. package/jsx/work/CaseView/CaseView.mocks.jsx +1 -1
  26. package/jsx/work/CaseView/CaseView.mocks.jsx.map +1 -1
  27. package/jsx/work/Timeline/Timeline.stories.d.ts.map +1 -1
  28. package/jsx/work/Timeline/Timeline.stories.jsx +1 -1
  29. package/jsx/work/Timeline/Timeline.stories.jsx.map +1 -1
  30. package/lib/core/AIButton/AIButton.mocks.d.ts +22 -0
  31. package/lib/core/AIButton/AIButton.mocks.d.ts.map +1 -0
  32. package/lib/core/AIButton/AIButton.mocks.js +139 -0
  33. package/lib/core/AIButton/AIButton.mocks.js.map +1 -0
  34. package/lib/core/AIButton/AIButton.stories.d.ts +19 -0
  35. package/lib/core/AIButton/AIButton.stories.d.ts.map +1 -0
  36. package/lib/core/AIButton/AIButton.stories.js +195 -0
  37. package/lib/core/AIButton/AIButton.stories.js.map +1 -0
  38. package/lib/core/FieldGroup/FieldGroup.stories.d.ts.map +1 -1
  39. package/lib/core/FieldGroup/FieldGroup.stories.js +15 -4
  40. package/lib/core/FieldGroup/FieldGroup.stories.js.map +1 -1
  41. package/lib/core/MenuButton/MenuButton.stories.d.ts +1 -0
  42. package/lib/core/MenuButton/MenuButton.stories.d.ts.map +1 -1
  43. package/lib/core/MenuButton/MenuButton.stories.js +1 -1
  44. package/lib/core/MenuButton/MenuButton.stories.js.map +1 -1
  45. package/lib/core/SummaryList/SummaryList.stories.js +2 -2
  46. package/lib/core/SummaryList/SummaryList.stories.js.map +1 -1
  47. package/lib/work/Assignments/Assignments.stories.d.ts +11 -0
  48. package/lib/work/Assignments/Assignments.stories.d.ts.map +1 -0
  49. package/lib/work/Assignments/Assignments.stories.js +69 -0
  50. package/lib/work/Assignments/Assignments.stories.js.map +1 -0
  51. package/lib/work/CaseView/Attachments.mocks.d.ts.map +1 -1
  52. package/lib/work/CaseView/Attachments.mocks.js +9 -1
  53. package/lib/work/CaseView/Attachments.mocks.js.map +1 -1
  54. package/lib/work/CaseView/CaseView.mocks.js +1 -1
  55. package/lib/work/CaseView/CaseView.mocks.js.map +1 -1
  56. package/lib/work/Timeline/Timeline.stories.d.ts.map +1 -1
  57. package/lib/work/Timeline/Timeline.stories.js +1 -1
  58. package/lib/work/Timeline/Timeline.stories.js.map +1 -1
  59. package/package.json +9 -9
@@ -0,0 +1,22 @@
1
+ import { FormControlProps } from '@pega/cosmos-react-core';
2
+ interface Value {
3
+ name: string;
4
+ email: string;
5
+ locations: string;
6
+ meetings: string;
7
+ meals: string;
8
+ notes: string;
9
+ }
10
+ interface Field extends FormControlProps {
11
+ help?: FormControlProps['info'];
12
+ validator?: (this: Field) => string;
13
+ }
14
+ export declare const AIValues: Value[];
15
+ export declare const initFields: () => Field[];
16
+ export declare const fieldReducer: (fields: Field[], { type, name, value }: {
17
+ type: 'blur' | 'change' | 'submit' | 'cancel' | 'ai';
18
+ name?: string | undefined;
19
+ value?: string | undefined;
20
+ }) => Field[];
21
+ export {};
22
+ //# sourceMappingURL=AIButton.mocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AIButton.mocks.d.ts","sourceRoot":"","sources":["../../../src/core/AIButton/AIButton.mocks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,KAAM,SAAQ,gBAAgB;IACtC,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC;CACrC;AAGD,eAAO,MAAM,QAAQ,EAAE,KAAK,EAyC3B,CAAC;AAGF,eAAO,MAAM,UAAU,QAAO,KAAK,EAqDlC,CAAC;AAGF,eAAO,MAAM,YAAY,WACf,KAAK,EAAE;UAMP,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI;;;aAoCvD,CAAC"}
@@ -0,0 +1,136 @@
1
+ export const AIValues = [
2
+ {
3
+ name: 'Cindy Turner',
4
+ email: 'cindy.turner@pega.com',
5
+ locations: 'Waltham',
6
+ meetings: 'No',
7
+ meals: 'Pizza',
8
+ notes: 'If I could have a window seat, that would be much appreciated!'
9
+ },
10
+ {
11
+ name: 'Seth DeAngelo',
12
+ email: 'seth.deangelo@pega.com',
13
+ locations: 'Waltham,Cambridge',
14
+ meetings: 'Yes',
15
+ meals: 'Salad',
16
+ notes: `I selected salad for my meal, but it that is not available, I'm okay with any sandwich you have.`
17
+ },
18
+ {
19
+ name: 'Janet Moore',
20
+ email: 'janet.moore@pega.com',
21
+ locations: 'Krakow',
22
+ meetings: 'No',
23
+ meals: 'Sandwich',
24
+ notes: `I'm allergic to nuts, so please don't add any peanut butter to my sandwich.`
25
+ },
26
+ {
27
+ name: 'Dean Thomas',
28
+ email: 'dean.thomas@pega.com',
29
+ locations: 'Hyderabad',
30
+ meetings: 'Yes',
31
+ meals: 'Pizza',
32
+ notes: 'I would like to arrange my hours to avoid rush hour.'
33
+ },
34
+ {
35
+ name: 'Kate Mirin',
36
+ email: 'kate.mirin@pega.com',
37
+ locations: 'Waltham,Krakow,Bangalore',
38
+ meetings: 'Yes',
39
+ meals: 'Salad',
40
+ notes: `I'm not too picky!`
41
+ }
42
+ ];
43
+ export const initFields = () => {
44
+ const common = { value: undefined, status: undefined };
45
+ return [
46
+ {
47
+ ...common,
48
+ name: 'name',
49
+ label: 'Name',
50
+ required: true,
51
+ validator() {
52
+ if (!this.value)
53
+ return 'Please enter a first and last name';
54
+ return /^[a-z]+\s[a-z]+$/i.test(this.value)
55
+ ? ''
56
+ : 'You need to enter a first and last name';
57
+ }
58
+ },
59
+ {
60
+ ...common,
61
+ name: 'email',
62
+ label: 'Email',
63
+ required: true,
64
+ validator() {
65
+ if (!this.value)
66
+ return 'Please enter an email address';
67
+ return /^\S+@pega\.com$/.test(this.value) ? '' : 'Please enter an @pega.com address';
68
+ }
69
+ },
70
+ {
71
+ ...common,
72
+ name: 'locations',
73
+ label: 'Which office(s) have you worked in?',
74
+ required: true,
75
+ validator() {
76
+ if (!this.value)
77
+ return 'Select at least one location';
78
+ return '';
79
+ }
80
+ },
81
+ {
82
+ ...common,
83
+ name: 'meetings',
84
+ label: 'Do you enjoy early morning meetings?'
85
+ },
86
+ {
87
+ ...common,
88
+ name: 'meals',
89
+ label: 'What would you like to eat?',
90
+ help: 'Selections will be made on a first-come basis'
91
+ },
92
+ {
93
+ ...common,
94
+ name: 'notes',
95
+ label: 'Special requests',
96
+ help: 'We will take any of your requests into consideration'
97
+ }
98
+ ];
99
+ };
100
+ export const fieldReducer = (fields, { type, name, value }) => {
101
+ return fields.map(field => {
102
+ if (field.name === name) {
103
+ if (name === 'locations' && field.value && value && type === 'change') {
104
+ const selectedValues = field.value.split(',');
105
+ const indexOfValue = selectedValues.findIndex(i => i === value);
106
+ if (indexOfValue !== -1) {
107
+ selectedValues.splice(indexOfValue, 1);
108
+ }
109
+ else {
110
+ selectedValues.push(value);
111
+ }
112
+ field.value = selectedValues.join(',');
113
+ }
114
+ else {
115
+ field.value = value;
116
+ }
117
+ if (type === 'cancel') {
118
+ field.status = undefined;
119
+ field.info = field.help;
120
+ }
121
+ else if (type === 'blur' || type === 'submit' || field.status === 'error') {
122
+ const error = field.validator?.() || '';
123
+ if ((field.required || field.value) && error) {
124
+ field.status = 'error';
125
+ field.info = error;
126
+ }
127
+ else {
128
+ field.status = undefined;
129
+ field.info = field.help;
130
+ }
131
+ }
132
+ }
133
+ return field;
134
+ });
135
+ };
136
+ //# sourceMappingURL=AIButton.mocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AIButton.mocks.js","sourceRoot":"","sources":["../../../src/core/AIButton/AIButton.mocks.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,QAAQ,GAAY;IAC/B;QACE,IAAI,EAA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gBAC9C,MAAM,YAAY,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;gBAChE,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE;oBACvB,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;iBACxC;qBAAM;oBACL,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBAC5B;gBACD,KAAK,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACxC;iBAAM;gBACL,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;aACrB;YAED,IAAI,IAAI,KAAK,QAAQ,EAAE;gBACrB,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;gBACzB,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;aACzB;iBAAM,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO,EAAE;gBAC3E,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE;oBAC5C,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC;oBACvB,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC;iBACpB;qBAAM;oBACL,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;oBACzB,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;iBACzB;aACF;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { FormControlProps } from '@pega/cosmos-react-core';\n\ninterface Value {\n name: string;\n email: string;\n locations: string;\n meetings: string;\n meals: string;\n notes: string;\n}\n\ninterface Field extends FormControlProps {\n help?: FormControlProps['info'];\n validator?: (this: Field) => string;\n}\n\n// Value sets used by the mock AI\nexport const AIValues: Value[] = [\n {\n name: 'Cindy Turner',\n email: 'cindy.turner@pega.com',\n locations: 'Waltham',\n meetings: 'No',\n meals: 'Pizza',\n notes: 'If I could have a window seat, that would be much appreciated!'\n },\n {\n name: 'Seth DeAngelo',\n email: 'seth.deangelo@pega.com',\n locations: 'Waltham,Cambridge',\n meetings: 'Yes',\n meals: 'Salad',\n notes: `I selected salad for my meal, but it that is not available, I'm okay with any sandwich you have.`\n },\n {\n name: 'Janet Moore',\n email: 'janet.moore@pega.com',\n locations: 'Krakow',\n meetings: 'No',\n meals: 'Sandwich',\n notes: `I'm allergic to nuts, so please don't add any peanut butter to my sandwich.`\n },\n {\n name: 'Dean Thomas',\n email: 'dean.thomas@pega.com',\n locations: 'Hyderabad',\n meetings: 'Yes',\n meals: 'Pizza',\n notes: 'I would like to arrange my hours to avoid rush hour.'\n },\n {\n name: 'Kate Mirin',\n email: 'kate.mirin@pega.com',\n locations: 'Waltham,Krakow,Bangalore',\n meetings: 'Yes',\n meals: 'Salad',\n notes: `I'm not too picky!`\n }\n];\n\n// Get initial field properties\nexport const initFields = (): Field[] => {\n const common = { value: undefined, status: undefined };\n return [\n {\n ...common,\n name: 'name',\n label: 'Name',\n required: true,\n validator() {\n if (!this.value) return 'Please enter a first and last name';\n return /^[a-z]+\\s[a-z]+$/i.test(this.value)\n ? ''\n : 'You need to enter a first and last name';\n }\n },\n {\n ...common,\n name: 'email',\n label: 'Email',\n required: true,\n validator() {\n if (!this.value) return 'Please enter an email address';\n return /^\\S+@pega\\.com$/.test(this.value) ? '' : 'Please enter an @pega.com address';\n }\n },\n {\n ...common,\n name: 'locations',\n label: 'Which office(s) have you worked in?',\n required: true,\n validator() {\n if (!this.value) return 'Select at least one location';\n return '';\n }\n },\n {\n ...common,\n name: 'meetings',\n label: 'Do you enjoy early morning meetings?'\n },\n {\n ...common,\n name: 'meals',\n label: 'What would you like to eat?',\n help: 'Selections will be made on a first-come basis'\n },\n {\n ...common,\n name: 'notes',\n label: 'Special requests',\n help: 'We will take any of your requests into consideration'\n }\n ];\n};\n\n// Handles setting of state for all fields\nexport const fieldReducer = (\n fields: Field[],\n {\n type,\n name,\n value\n }: {\n type: 'blur' | 'change' | 'submit' | 'cancel' | 'ai';\n name?: string;\n value?: string;\n }\n) => {\n return fields.map(field => {\n if (field.name === name) {\n if (name === 'locations' && field.value && value && type === 'change') {\n const selectedValues = field.value.split(',');\n const indexOfValue = selectedValues.findIndex(i => i === value);\n if (indexOfValue !== -1) {\n selectedValues.splice(indexOfValue, 1);\n } else {\n selectedValues.push(value);\n }\n field.value = selectedValues.join(',');\n } else {\n field.value = value;\n }\n\n if (type === 'cancel') {\n field.status = undefined;\n field.info = field.help;\n } else if (type === 'blur' || type === 'submit' || field.status === 'error') {\n const error = field.validator?.() || '';\n if ((field.required || field.value) && error) {\n field.status = 'error';\n field.info = error;\n } else {\n field.status = undefined;\n field.info = field.help;\n }\n }\n }\n return field;\n });\n};\n"]}
@@ -0,0 +1,19 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import { AIButtonProps } from '@pega/cosmos-react-core';
3
+ declare const _default: Meta;
4
+ export default _default;
5
+ export declare const AIButtonDemo: Story<AIButtonProps>;
6
+ interface AIButtonFormProps {
7
+ throwAIError: boolean;
8
+ }
9
+ export declare const AIButtonFormDemo: Story<AIButtonFormProps>;
10
+ export declare const AIButtonFormInModalDemo: Story<AIButtonFormProps>;
11
+ interface ConfigurableButtonProps {
12
+ borderWidth?: string;
13
+ borderRadius?: number;
14
+ color?: string;
15
+ secondaryColor?: string;
16
+ padding?: string;
17
+ }
18
+ export declare const ConfigurableAIButton: Story<ConfigurableButtonProps>;
19
+ //# sourceMappingURL=AIButton.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AIButton.stories.d.ts","sourceRoot":"","sources":["../../../src/core/AIButton/AIButton.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAEL,aAAa,EAqBd,MAAM,yBAAyB,CAAC;;AAIjC,wBAOU;AAEV,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,aAAa,CAE7C,CAAC;AAYF,UAAU,iBAAiB;IACzB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,iBAAiB,CA0MrD,CAAC;AAUF,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,iBAAiB,CAiO5D,CAAC;AASF,UAAU,uBAAuB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,uBAAuB,CAuB/D,CAAC"}
@@ -0,0 +1,279 @@
1
+ import { useReducer, useState } from 'react';
2
+ import { AIButton, Banner, Button, Checkbox, CheckboxGroup, Configuration, ErrorState, Flex, Form, Grid, Input, Modal, Progress, RadioButton, RadioButtonGroup, Select, Option, TextArea, useModalContext, useModalManager, useToaster } from '@pega/cosmos-react-core';
3
+ import { AIValues, fieldReducer, initFields } from './AIButton.mocks';
4
+ export default {
5
+ title: 'Core/AIButton',
6
+ component: AIButton,
7
+ excludeStories: ['ConfigurableAIButton'],
8
+ parameters: {
9
+ layout: 'centered'
10
+ }
11
+ };
12
+ export const AIButtonDemo = (args) => {
13
+ return <AIButton label={args.label} disabled={args.disabled}/>;
14
+ };
15
+ AIButtonDemo.args = {
16
+ label: 'Fill form with AI',
17
+ disabled: false
18
+ };
19
+ AIButtonDemo.argTypes = {
20
+ label: { control: { type: 'text' } },
21
+ disabled: { control: { type: 'boolean' } }
22
+ };
23
+ export const AIButtonFormDemo = (args) => {
24
+ const [fields, setField] = useReducer(fieldReducer, undefined, initFields);
25
+ const [bannerMessages, setBannerMessages] = useState([]);
26
+ const [loadingMessage, setLoadingMessage] = useState('');
27
+ const [submitting, setSubmitting] = useState(false);
28
+ const { push } = useToaster();
29
+ const name = fields.find(field => field.name === 'name');
30
+ const email = fields.find(field => field.name === 'email');
31
+ const locations = fields.find(field => field.name === 'locations');
32
+ const meetings = fields.find(field => field.name === 'meetings');
33
+ const meals = fields.find(field => field.name === 'meals');
34
+ const notes = fields.find(field => field.name === 'notes');
35
+ if (!name || !email || !locations || !meetings || !meals || !notes)
36
+ return <ErrorState />;
37
+ const banners = bannerMessages.length > 0 ? <Banner variant='urgent' messages={bannerMessages}/> : undefined;
38
+ const clearForm = () => {
39
+ fields.forEach(field => setField({ type: 'cancel', name: field.name, value: undefined }));
40
+ };
41
+ const fillWithAI = () => {
42
+ setLoadingMessage('AI is filling out the form...');
43
+ setTimeout(() => {
44
+ if (args.throwAIError) {
45
+ setBannerMessages(curr => [
46
+ 'An error occurred while generating responses from the AI.',
47
+ ...curr
48
+ ]);
49
+ }
50
+ else {
51
+ const values = AIValues[Math.floor(Math.random() * AIValues.length)];
52
+ Object.keys(values).forEach(field => {
53
+ setField({ type: 'ai', name: field, value: values[field] });
54
+ });
55
+ }
56
+ setLoadingMessage('');
57
+ }, 2000);
58
+ };
59
+ const trySubmit = () => {
60
+ const errors = [];
61
+ fields.forEach(field => {
62
+ setField({ type: 'submit', name: field.name, value: field.value });
63
+ const error = field.validator?.() || '';
64
+ if (error)
65
+ errors.push(error);
66
+ });
67
+ setBannerMessages(errors);
68
+ if (errors.length === 0) {
69
+ setSubmitting(true);
70
+ setLoadingMessage('Submitting form...');
71
+ setTimeout(() => {
72
+ setLoadingMessage('');
73
+ setSubmitting(false);
74
+ push({ content: 'Form submitted!' });
75
+ clearForm();
76
+ }, 1000);
77
+ }
78
+ };
79
+ return (<Form heading='AI Form' description='The AI in this demo is a mock and not a functional AI.' actions={<>
80
+ <Button onClick={clearForm} disabled={submitting}>
81
+ Cancel
82
+ </Button>
83
+ <Flex container={{ alignItems: 'center', gap: 1 }}>
84
+ <AIButton label='Fill form with AI' onClick={fillWithAI} disabled={!!loadingMessage}/>
85
+ <Button variant='primary' disabled={!!loadingMessage} onClick={trySubmit}>
86
+ Submit
87
+ </Button>
88
+ </Flex>
89
+ </>} banners={banners} style={{ margin: 'auto', maxWidth: '37.5rem' }}>
90
+ <Progress visible={!!loadingMessage} focusOnVisible message={loadingMessage}/>
91
+ <Grid container={{ gap: 1, cols: `repeat(2, minmax(0, 1fr))` }}>
92
+ <Input name={name.name} label={name.label} required={name.required} info={name.info || name.help} value={name.value} status={name.status} onChange={(e) => setField({ type: 'change', name: e.target.name, value: e.target.value })} onBlur={(e) => setField({ type: 'blur', name: e.target.name, value: e.target.value })}/>
93
+
94
+ <Input name={email.name} label={email.label} required={email.required} info={email.info || email.help} value={email.value} status={email.status} type='email' onChange={(e) => setField({ type: 'change', name: e.target.name, value: e.target.value })} onBlur={(e) => setField({ type: 'blur', name: e.target.name, value: e.target.value })}/>
95
+
96
+ <Grid item={{ colStartEnd: '1/-1' }}>
97
+ <CheckboxGroup name={locations.name} label={locations.label} required={locations.required} info={locations.info || locations.help} status={locations.status}>
98
+ {['Cambridge', 'Waltham', 'Krakow', 'Hyderabad', 'Bangalore'].map(office => (<Checkbox key={office} label={office} value={office} checked={locations.value?.includes(office)} onChange={(e) => setField({
99
+ type: 'change',
100
+ name: e.target.name,
101
+ value: e.target.value
102
+ })}/>))}
103
+ </CheckboxGroup>
104
+ </Grid>
105
+
106
+ <Grid item={{ colStartEnd: '1/-1' }}>
107
+ <RadioButtonGroup name={meetings.name} label={meetings.label} required={meetings.required} info={meetings.info || meetings.help} status={meetings.status}>
108
+ {['Yes', 'No'].map(option => (<RadioButton key={option} label={option} value={option} checked={meetings.value === option} onChange={(e) => setField({ type: 'change', name: e.target.name, value: e.target.value })}/>))}
109
+ </RadioButtonGroup>
110
+ </Grid>
111
+
112
+ <Select name={meals.name} label={meals.label} required={meals.required} info={meals.info || meals.help} value={meals.value || 'choose meal...'} status={meals.status} onChange={(e) => setField({ type: 'change', name: e.target.name, value: e.target.value })}>
113
+ <Option>choose meal...</Option>
114
+ <Option>Pizza</Option>
115
+ <Option>Sandwich</Option>
116
+ <Option>Salad</Option>
117
+ </Select>
118
+
119
+ <Grid item={{ colStartEnd: '1/-1' }}>
120
+ <TextArea name={notes.name} label={notes.label} required={notes.required} info={notes.info || notes.help} value={notes.value} status={notes.status} maxLength={200} displayCharCount onChange={(e) => setField({ type: 'change', name: e.target.name, value: e.target.value })} onBlur={(e) => setField({ type: 'blur', name: e.target.name, value: e.target.value })}/>
121
+ </Grid>
122
+ </Grid>
123
+ </Form>);
124
+ };
125
+ AIButtonFormDemo.args = {
126
+ throwAIError: false
127
+ };
128
+ AIButtonFormDemo.argTypes = {
129
+ throwAIError: { control: { type: 'boolean' } }
130
+ };
131
+ export const AIButtonFormInModalDemo = (args) => {
132
+ const AIModal = () => {
133
+ const [fields, setField] = useReducer(fieldReducer, undefined, initFields);
134
+ const [bannerMessages, setBannerMessages] = useState([]);
135
+ const [loadingMessage, setLoadingMessage] = useState('');
136
+ const [submitting, setSubmitting] = useState(false);
137
+ const { push } = useToaster();
138
+ const { dismiss } = useModalContext();
139
+ const name = fields.find(field => field.name === 'name');
140
+ const email = fields.find(field => field.name === 'email');
141
+ const locations = fields.find(field => field.name === 'locations');
142
+ const meetings = fields.find(field => field.name === 'meetings');
143
+ const meals = fields.find(field => field.name === 'meals');
144
+ const notes = fields.find(field => field.name === 'notes');
145
+ if (!name || !email || !locations || !meetings || !meals || !notes)
146
+ return <ErrorState />;
147
+ const banners = bannerMessages.length > 0 ? <Banner variant='urgent' messages={bannerMessages}/> : undefined;
148
+ const fillWithAI = () => {
149
+ setLoadingMessage('AI is filling out the form...');
150
+ setTimeout(() => {
151
+ if (args.throwAIError) {
152
+ setBannerMessages(curr => [
153
+ 'An error occurred while generating responses from the AI.',
154
+ ...curr
155
+ ]);
156
+ }
157
+ else {
158
+ const values = AIValues[Math.floor(Math.random() * AIValues.length)];
159
+ Object.keys(values).forEach(field => {
160
+ setField({ type: 'ai', name: field, value: values[field] });
161
+ });
162
+ }
163
+ setLoadingMessage('');
164
+ }, 2000);
165
+ };
166
+ const trySubmit = () => {
167
+ const errors = [];
168
+ fields.forEach(field => {
169
+ setField({ type: 'submit', name: field.name, value: field.value });
170
+ const error = field.validator?.() || '';
171
+ if (error)
172
+ errors.push(error);
173
+ });
174
+ setBannerMessages(errors);
175
+ if (errors.length === 0) {
176
+ setSubmitting(true);
177
+ setLoadingMessage('Submitting form...');
178
+ setTimeout(() => {
179
+ setLoadingMessage('');
180
+ setSubmitting(false);
181
+ push({ content: 'Form submitted!' });
182
+ dismiss();
183
+ }, 1000);
184
+ }
185
+ };
186
+ return (<Modal heading='AI Form in a Modal' progress={loadingMessage ? { message: loadingMessage } : undefined} onRequestDismiss={() => !submitting} actions={<>
187
+ <Button onClick={dismiss} disabled={submitting}>
188
+ Cancel
189
+ </Button>
190
+ <Flex container={{ alignItems: 'center', gap: 1 }}>
191
+ <AIButton label='Fill form with AI' onClick={fillWithAI} disabled={!!loadingMessage}/>
192
+ <Button variant='primary' disabled={!!loadingMessage} onClick={trySubmit}>
193
+ Submit
194
+ </Button>
195
+ </Flex>
196
+ </>}>
197
+ <Form description='The AI in this demo is a mock and not a functional AI.' banners={banners} style={{ margin: 'auto', maxWidth: '37.5rem' }}>
198
+ <Grid container={{ gap: 1, cols: `repeat(2, minmax(0, 1fr))` }}>
199
+ <Input name={name.name} label={name.label} required={name.required} info={name.info || name.help} value={name.value} status={name.status} onChange={(e) => setField({ type: 'change', name: e.target.name, value: e.target.value })} onBlur={(e) => setField({ type: 'blur', name: e.target.name, value: e.target.value })}/>
200
+
201
+ <Input name={email.name} label={email.label} required={email.required} info={email.info || email.help} value={email.value} status={email.status} type='email' onChange={(e) => setField({ type: 'change', name: e.target.name, value: e.target.value })} onBlur={(e) => setField({ type: 'blur', name: e.target.name, value: e.target.value })}/>
202
+
203
+ <Grid item={{ colStartEnd: '1/-1' }}>
204
+ <CheckboxGroup name={locations.name} label={locations.label} required={locations.required} info={locations.info || locations.help} status={locations.status}>
205
+ {['Cambridge', 'Waltham', 'Krakow', 'Hyderabad', 'Bangalore'].map(office => (<Checkbox key={office} label={office} value={office} checked={locations.value?.includes(office)} onChange={(e) => setField({
206
+ type: 'change',
207
+ name: e.target.name,
208
+ value: e.target.value
209
+ })}/>))}
210
+ </CheckboxGroup>
211
+ </Grid>
212
+
213
+ <Grid item={{ colStartEnd: '1/-1' }}>
214
+ <RadioButtonGroup name={meetings.name} label={meetings.label} required={meetings.required} info={meetings.info || meetings.help} status={meetings.status}>
215
+ {['Yes', 'No'].map(option => (<RadioButton key={option} label={option} value={option} checked={meetings.value === option} onChange={(e) => setField({ type: 'change', name: e.target.name, value: e.target.value })}/>))}
216
+ </RadioButtonGroup>
217
+ </Grid>
218
+
219
+ <Select name={meals.name} label={meals.label} required={meals.required} info={meals.info || meals.help} value={meals.value || 'choose meal...'} status={meals.status} onChange={(e) => setField({ type: 'change', name: e.target.name, value: e.target.value })}>
220
+ <Option>choose meal...</Option>
221
+ <Option>Pizza</Option>
222
+ <Option>Sandwich</Option>
223
+ <Option>Salad</Option>
224
+ </Select>
225
+
226
+ <Grid item={{ colStartEnd: '1/-1' }}>
227
+ <TextArea name={notes.name} label={notes.label} required={notes.required} info={notes.info || notes.help} value={notes.value} status={notes.status} maxLength={200} displayCharCount onChange={(e) => setField({ type: 'change', name: e.target.name, value: e.target.value })} onBlur={(e) => setField({ type: 'blur', name: e.target.name, value: e.target.value })}/>
228
+ </Grid>
229
+ </Grid>
230
+ </Form>
231
+ </Modal>);
232
+ };
233
+ const ModalButton = () => {
234
+ const { create } = useModalManager();
235
+ return (<Button onClick={() => {
236
+ create(AIModal);
237
+ }}>
238
+ Open Modal
239
+ </Button>);
240
+ };
241
+ return <ModalButton />;
242
+ };
243
+ AIButtonFormInModalDemo.args = {
244
+ throwAIError: false
245
+ };
246
+ AIButtonFormInModalDemo.argTypes = {
247
+ throwAIError: { control: { type: 'boolean' } }
248
+ };
249
+ export const ConfigurableAIButton = (args) => {
250
+ return (<Configuration theme={{
251
+ base: {
252
+ palette: {
253
+ ai: args.color
254
+ }
255
+ },
256
+ components: {
257
+ button: {
258
+ 'border-width': args.borderWidth,
259
+ 'border-radius': args.borderRadius,
260
+ padding: args.padding
261
+ }
262
+ }
263
+ }}>
264
+ <AIButton label='Configurable Button'/>
265
+ </Configuration>);
266
+ };
267
+ ConfigurableAIButton.args = {
268
+ borderWidth: '0.0625rem',
269
+ borderRadius: 9999,
270
+ color: '#681fc3',
271
+ padding: '0rem 1rem'
272
+ };
273
+ ConfigurableAIButton.argTypes = {
274
+ borderWidth: { control: { type: 'text' } },
275
+ borderRadius: { control: { type: 'number' } },
276
+ color: { control: { type: 'color' } },
277
+ padding: { control: { type: 'text' } }
278
+ };
279
+ //# sourceMappingURL=AIButton.stories.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AIButton.stories.jsx","sourceRoot":"","sources":["../../../src/core/AIButton/AIButton.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2B,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtE,OAAO,EACL,QAAQ,EAER,MAAM,EACN,MAAM,EACN,QAAQ,EACR,aAAa,EACb,aAAa,EACb,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,MAAM,EACN,MAAM,EACN,QAAQ,EACR,eAAe,EACf,eAAe,EACf,UAAU,EACX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEtE,eAAe;IACb,KAAK,EAAE,eAAe;IACtB,SAAS,EAAE,QAAQ;IACnB,cAAc,EAAE,C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AE,IAAI;IAClB,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,WAAW;CACrB,CAAC;AAEF,oBAAoB,CAAC,QAAQ,GAAG;IAC9B,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;IAC1C,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;IAC7C,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IACrC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;CACvC,CAAC","sourcesContent":["import { ChangeEvent, FocusEvent, useReducer, useState } from 'react';\nimport { Meta, Story } from '@storybook/react';\n\nimport {\n AIButton,\n AIButtonProps,\n Banner,\n Button,\n Checkbox,\n CheckboxGroup,\n Configuration,\n ErrorState,\n Flex,\n Form,\n Grid,\n Input,\n Modal,\n Progress,\n RadioButton,\n RadioButtonGroup,\n Select,\n Option,\n TextArea,\n useModalContext,\n useModalManager,\n useToaster\n} from '@pega/cosmos-react-core';\n\nimport { AIValues, fieldReducer, initFields } from './AIButton.mocks';\n\nexport default {\n title: 'Core/AIButton',\n component: AIButton,\n excludeStories: ['ConfigurableAIButton'],\n parameters: {\n layout: 'centered'\n }\n} as Meta;\n\nexport const AIButtonDemo: Story<AIButtonProps> = (args: AIButtonProps) => {\n return <AIButton label={args.label} disabled={args.disabled} />;\n};\n\nAIButtonDemo.args = {\n label: 'Fill form with AI',\n disabled: false\n};\n\nAIButtonDemo.argTypes = {\n label: { control: { type: 'text' } },\n disabled: { control: { type: 'boolean' } }\n};\n\ninterface AIButtonFormProps {\n throwAIError: boolean;\n}\n\nexport const AIButtonFormDemo: Story<AIButtonFormProps> = (args: AIButtonFormProps) => {\n const [fields, setField] = useReducer(fieldReducer, undefined, initFields);\n const [bannerMessages, setBannerMessages] = useState<string[]>([]);\n const [loadingMessage, setLoadingMessage] = useState('');\n const [submitting, setSubmitting] = useState(false);\n\n const { push } = useToaster();\n\n const name = fields.find(field => field.name === 'name');\n const email = fields.find(field => field.name === 'email');\n const locations = fields.find(field => field.name === 'locations');\n const meetings = fields.find(field => field.name === 'meetings');\n const meals = fields.find(field => field.name === 'meals');\n const notes = fields.find(field => field.name === 'notes');\n\n if (!name || !email || !locations || !meetings || !meals || !notes) return <ErrorState />;\n\n const banners =\n bannerMessages.length > 0 ? <Banner variant='urgent' messages={bannerMessages} /> : undefined;\n\n const clearForm = () => {\n fields.forEach(field => setField({ type: 'cancel', name: field.name, value: undefined }));\n };\n\n const fillWithAI = () => {\n setLoadingMessage('AI is filling out the form...');\n setTimeout(() => {\n if (args.throwAIError) {\n setBannerMessages(curr => [\n 'An error occurred while generating responses from the AI.',\n ...curr\n ]);\n } else {\n const values = AIValues[Math.floor(Math.random() * AIValues.length)];\n Object.keys(values).forEach(field => {\n setField({ type: 'ai', name: field, value: values[field as keyof typeof values] });\n });\n }\n setLoadingMessage('');\n }, 2000);\n };\n\n const trySubmit = () => {\n const errors: string[] = [];\n fields.forEach(field => {\n setField({ type: 'submit', name: field.name, value: field.value });\n const error = field.validator?.() || '';\n if (error) errors.push(error);\n });\n setBannerMessages(errors);\n\n if (errors.length === 0) {\n setSubmitting(true);\n setLoadingMessage('Submitting form...');\n setTimeout(() => {\n setLoadingMessage('');\n setSubmitting(false);\n push({ content: 'Form submitted!' });\n clearForm();\n }, 1000);\n }\n };\n\n return (\n <Form\n heading='AI Form'\n description='The AI in this demo is a mock and not a functional AI.'\n actions={\n <>\n <Button onClick={clearForm} disabled={submitting}>\n Cancel\n </Button>\n <Flex container={{ alignItems: 'center', gap: 1 }}>\n <AIButton label='Fill form with AI' onClick={fillWithAI} disabled={!!loadingMessage} />\n <Button variant='primary' disabled={!!loadingMessage} onClick={trySubmit}>\n Submit\n </Button>\n </Flex>\n </>\n }\n banners={banners}\n style={{ margin: 'auto', maxWidth: '37.5rem' }}\n >\n <Progress visible={!!loadingMessage} focusOnVisible message={loadingMessage} />\n <Grid container={{ gap: 1, cols: `repeat(2, minmax(0, 1fr))` }}>\n <Input\n name={name.name}\n label={name.label}\n required={name.required}\n info={name.info || name.help}\n value={name.value}\n status={name.status}\n onChange={(e: ChangeEvent<HTMLInputElement>) =>\n setField({ type: 'change', name: e.target.name, value: e.target.value })\n }\n onBlur={(e: FocusEvent<HTMLInputElement>) =>\n setField({ type: 'blur', name: e.target.name, value: e.target.value })\n }\n />\n\n <Input\n name={email.name}\n label={email.label}\n required={email.required}\n info={email.info || email.help}\n value={email.value}\n status={email.status}\n type='email'\n onChange={(e: ChangeEvent<HTMLInputElement>) =>\n setField({ type: 'change', name: e.target.name, value: e.target.value })\n }\n onBlur={(e: FocusEvent<HTMLInputElement>) =>\n setField({ type: 'blur', name: e.target.name, value: e.target.value })\n }\n />\n\n <Grid item={{ colStartEnd: '1/-1' }}>\n <CheckboxGroup\n name={locations.name}\n label={locations.label}\n required={locations.required}\n info={locations.info || locations.help}\n status={locations.status}\n >\n {['Cambridge', 'Waltham', 'Krakow', 'Hyderabad', 'Bangalore'].map(office => (\n <Checkbox\n key={office}\n label={office}\n value={office}\n checked={locations.value?.includes(office)}\n onChange={(e: ChangeEvent<HTMLInputElement>) =>\n setField({\n type: 'change',\n name: e.target.name,\n value: e.target.value\n })\n }\n />\n ))}\n </CheckboxGroup>\n </Grid>\n\n <Grid item={{ colStartEnd: '1/-1' }}>\n <RadioButtonGroup\n name={meetings.name}\n label={meetings.label}\n required={meetings.required}\n info={meetings.info || meetings.help}\n status={meetings.status}\n >\n {['Yes', 'No'].map(option => (\n <RadioButton\n key={option}\n label={option}\n value={option}\n checked={meetings.value === option}\n onChange={(e: ChangeEvent<HTMLInputElement>) =>\n setField({ type: 'change', name: e.target.name, value: e.target.value })\n }\n />\n ))}\n </RadioButtonGroup>\n </Grid>\n\n <Select\n name={meals.name}\n label={meals.label}\n required={meals.required}\n info={meals.info || meals.help}\n value={meals.value || 'choose meal...'}\n status={meals.status}\n onChange={(e: ChangeEvent<HTMLSelectElement>) =>\n setField({ type: 'change', name: e.target.name, value: e.target.value })\n }\n >\n <Option>choose meal...</Option>\n <Option>Pizza</Option>\n <Option>Sandwich</Option>\n <Option>Salad</Option>\n </Select>\n\n <Grid item={{ colStartEnd: '1/-1' }}>\n <TextArea\n name={notes.name}\n label={notes.label}\n required={notes.required}\n info={notes.info || notes.help}\n value={notes.value}\n status={notes.status}\n maxLength={200}\n displayCharCount\n onChange={(e: ChangeEvent<HTMLTextAreaElement>) =>\n setField({ type: 'change', name: e.target.name, value: e.target.value })\n }\n onBlur={(e: FocusEvent<HTMLInputElement>) =>\n setField({ type: 'blur', name: e.target.name, value: e.target.value })\n }\n />\n </Grid>\n </Grid>\n </Form>\n );\n};\n\nAIButtonFormDemo.args = {\n throwAIError: false\n};\n\nAIButtonFormDemo.argTypes = {\n throwAIError: { control: { type: 'boolean' } }\n};\n\nexport const AIButtonFormInModalDemo: Story<AIButtonFormProps> = (args: AIButtonFormProps) => {\n const AIModal = () => {\n const [fields, setField] = useReducer(fieldReducer, undefined, initFields);\n const [bannerMessages, setBannerMessages] = useState<string[]>([]);\n const [loadingMessage, setLoadingMessage] = useState('');\n const [submitting, setSubmitting] = useState(false);\n\n const { push } = useToaster();\n const { dismiss } = useModalContext();\n\n const name = fields.find(field => field.name === 'name');\n const email = fields.find(field => field.name === 'email');\n const locations = fields.find(field => field.name === 'locations');\n const meetings = fields.find(field => field.name === 'meetings');\n const meals = fields.find(field => field.name === 'meals');\n const notes = fields.find(field => field.name === 'notes');\n\n if (!name || !email || !locations || !meetings || !meals || !notes) return <ErrorState />;\n\n const banners =\n bannerMessages.length > 0 ? <Banner variant='urgent' messages={bannerMessages} /> : undefined;\n\n const fillWithAI = () => {\n setLoadingMessage('AI is filling out the form...');\n setTimeout(() => {\n if (args.throwAIError) {\n setBannerMessages(curr => [\n 'An error occurred while generating responses from the AI.',\n ...curr\n ]);\n } else {\n const values = AIValues[Math.floor(Math.random() * AIValues.length)];\n Object.keys(values).forEach(field => {\n setField({ type: 'ai', name: field, value: values[field as keyof typeof values] });\n });\n }\n setLoadingMessage('');\n }, 2000);\n };\n\n const trySubmit = () => {\n const errors: string[] = [];\n fields.forEach(field => {\n setField({ type: 'submit', name: field.name, value: field.value });\n const error = field.validator?.() || '';\n if (error) errors.push(error);\n });\n setBannerMessages(errors);\n\n if (errors.length === 0) {\n setSubmitting(true);\n setLoadingMessage('Submitting form...');\n setTimeout(() => {\n setLoadingMessage('');\n setSubmitting(false);\n push({ content: 'Form submitted!' });\n dismiss();\n }, 1000);\n }\n };\n\n return (\n <Modal\n heading='AI Form in a Modal'\n progress={loadingMessage ? { message: loadingMessage } : undefined}\n onRequestDismiss={() => !submitting}\n actions={\n <>\n <Button onClick={dismiss} disabled={submitting}>\n Cancel\n </Button>\n <Flex container={{ alignItems: 'center', gap: 1 }}>\n <AIButton\n label='Fill form with AI'\n onClick={fillWithAI}\n disabled={!!loadingMessage}\n />\n <Button variant='primary' disabled={!!loadingMessage} onClick={trySubmit}>\n Submit\n </Button>\n </Flex>\n </>\n }\n >\n <Form\n description='The AI in this demo is a mock and not a functional AI.'\n banners={banners}\n style={{ margin: 'auto', maxWidth: '37.5rem' }}\n >\n <Grid container={{ gap: 1, cols: `repeat(2, minmax(0, 1fr))` }}>\n <Input\n name={name.name}\n label={name.label}\n required={name.required}\n info={name.info || name.help}\n value={name.value}\n status={name.status}\n onChange={(e: ChangeEvent<HTMLInputElement>) =>\n setField({ type: 'change', name: e.target.name, value: e.target.value })\n }\n onBlur={(e: FocusEvent<HTMLInputElement>) =>\n setField({ type: 'blur', name: e.target.name, value: e.target.value })\n }\n />\n\n <Input\n name={email.name}\n label={email.label}\n required={email.required}\n info={email.info || email.help}\n value={email.value}\n status={email.status}\n type='email'\n onChange={(e: ChangeEvent<HTMLInputElement>) =>\n setField({ type: 'change', name: e.target.name, value: e.target.value })\n }\n onBlur={(e: FocusEvent<HTMLInputElement>) =>\n setField({ type: 'blur', name: e.target.name, value: e.target.value })\n }\n />\n\n <Grid item={{ colStartEnd: '1/-1' }}>\n <CheckboxGroup\n name={locations.name}\n label={locations.label}\n required={locations.required}\n info={locations.info || locations.help}\n status={locations.status}\n >\n {['Cambridge', 'Waltham', 'Krakow', 'Hyderabad', 'Bangalore'].map(office => (\n <Checkbox\n key={office}\n label={office}\n value={office}\n checked={locations.value?.includes(office)}\n onChange={(e: ChangeEvent<HTMLInputElement>) =>\n setField({\n type: 'change',\n name: e.target.name,\n value: e.target.value\n })\n }\n />\n ))}\n </CheckboxGroup>\n </Grid>\n\n <Grid item={{ colStartEnd: '1/-1' }}>\n <RadioButtonGroup\n name={meetings.name}\n label={meetings.label}\n required={meetings.required}\n info={meetings.info || meetings.help}\n status={meetings.status}\n >\n {['Yes', 'No'].map(option => (\n <RadioButton\n key={option}\n label={option}\n value={option}\n checked={meetings.value === option}\n onChange={(e: ChangeEvent<HTMLInputElement>) =>\n setField({ type: 'change', name: e.target.name, value: e.target.value })\n }\n />\n ))}\n </RadioButtonGroup>\n </Grid>\n\n <Select\n name={meals.name}\n label={meals.label}\n required={meals.required}\n info={meals.info || meals.help}\n value={meals.value || 'choose meal...'}\n status={meals.status}\n onChange={(e: ChangeEvent<HTMLSelectElement>) =>\n setField({ type: 'change', name: e.target.name, value: e.target.value })\n }\n >\n <Option>choose meal...</Option>\n <Option>Pizza</Option>\n <Option>Sandwich</Option>\n <Option>Salad</Option>\n </Select>\n\n <Grid item={{ colStartEnd: '1/-1' }}>\n <TextArea\n name={notes.name}\n label={notes.label}\n required={notes.required}\n info={notes.info || notes.help}\n value={notes.value}\n status={notes.status}\n maxLength={200}\n displayCharCount\n onChange={(e: ChangeEvent<HTMLTextAreaElement>) =>\n setField({ type: 'change', name: e.target.name, value: e.target.value })\n }\n onBlur={(e: FocusEvent<HTMLInputElement>) =>\n setField({ type: 'blur', name: e.target.name, value: e.target.value })\n }\n />\n </Grid>\n </Grid>\n </Form>\n </Modal>\n );\n };\n\n const ModalButton = () => {\n const { create } = useModalManager();\n\n return (\n <Button\n onClick={() => {\n create(AIModal);\n }}\n >\n Open Modal\n </Button>\n );\n };\n\n return <ModalButton />;\n};\n\nAIButtonFormInModalDemo.args = {\n throwAIError: false\n};\n\nAIButtonFormInModalDemo.argTypes = {\n throwAIError: { control: { type: 'boolean' } }\n};\ninterface ConfigurableButtonProps {\n borderWidth?: string;\n borderRadius?: number;\n color?: string;\n secondaryColor?: string;\n padding?: string;\n}\n\nexport const ConfigurableAIButton: Story<ConfigurableButtonProps> = (\n args: ConfigurableButtonProps\n) => {\n return (\n <Configuration\n theme={{\n base: {\n palette: {\n ai: args.color\n }\n },\n components: {\n button: {\n 'border-width': args.borderWidth,\n 'border-radius': args.borderRadius,\n padding: args.padding\n }\n }\n }}\n >\n <AIButton label='Configurable Button' />\n </Configuration>\n );\n};\n\nConfigurableAIButton.args = {\n borderWidth: '0.0625rem',\n borderRadius: 9999,\n color: '#681fc3',\n padding: '0rem 1rem'\n};\n\nConfigurableAIButton.argTypes = {\n borderWidth: { control: { type: 'text' } },\n borderRadius: { control: { type: 'number' } },\n color: { control: { type: 'color' } },\n padding: { control: { type: 'text' } }\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FieldGroup.stories.d.ts","sourceRoot":"","sources":["../../../src/core/FieldGroup/FieldGroup.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAQL,eAAe,EAChB,MAAM,yBAAyB,CAAC;;AAEjC,wBAGU;AAEV,UAAU,oBAAoB;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACrD,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACtD,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,oBAAoB,CAuDtD,CAAC"}
1
+ {"version":3,"file":"FieldGroup.stories.d.ts","sourceRoot":"","sources":["../../../src/core/FieldGroup/FieldGroup.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAQL,eAAe,EAChB,MAAM,yBAAyB,CAAC;;AAEjC,wBAGU;AAEV,UAAU,oBAAoB;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACrD,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACtD,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,oBAAoB,CAuEtD,CAAC"}
@@ -1,11 +1,18 @@
1
+ import { useState } from 'react';
1
2
  import { DateInput, FieldGroup, Grid, Input, Select, Option, TextArea } from '@pega/cosmos-react-core';
2
3
  export default {
3
4
  title: 'Core/FieldGroup',
4
5
  component: FieldGroup
5
6
  };
6
7
  export const FieldGroupDemo = (args) => {
7
- return (<Grid container={{ rowGap: 1 }}>
8
- <FieldGroup name={args.firstGroupName} headingTag={args.showfirstGroupHeadingTag ? args.firstGroupHeadingTag : undefined} description={args.firstGroupDescription} collapsible={args.firstGroupCollapsible} additionalInfo={args.showFirstAdditionalInfo
8
+ const [firstGroupCollapsed, setFirstGroupCollapsed] = useState(false);
9
+ const [secondGroupCollapsed, setSecondGroupCollapsed] = useState(false);
10
+ return (<Grid container={{ rowGap: 2 }}>
11
+ <FieldGroup name={args.firstGroupName} headingTag={args.showfirstGroupHeadingTag ? args.firstGroupHeadingTag : undefined} description={args.firstGroupDescription} collapsed={args.firstGroupCollapsible ? firstGroupCollapsed : undefined} onToggleCollapsed={args.firstGroupCollapsible
12
+ ? () => {
13
+ setFirstGroupCollapsed(state => !state);
14
+ }
15
+ : undefined} additionalInfo={args.showFirstAdditionalInfo
9
16
  ? { heading: 'Additional Info', content: 'This is a field group' }
10
17
  : undefined}>
11
18
  <Grid container={{ gap: 1, cols: 'repeat(auto-fit, minmax(min(40ch, 100%), 1fr))' }}>
@@ -22,7 +29,11 @@ export const FieldGroupDemo = (args) => {
22
29
  <Input disabled type='text' label='Disabled 1'/>
23
30
  </Grid>
24
31
  </FieldGroup>
25
- <FieldGroup name={args.secondGroupName} headingTag={args.showsecondGroupHeadingTag ? args.secondGroupHeadingTag : undefined} description={args.secondGroupDescription} collapsible={args.secondGroupCollapsible} additionalInfo={args.showSecondAdditionalInfo
32
+ <FieldGroup name={args.secondGroupName} headingTag={args.showsecondGroupHeadingTag ? args.secondGroupHeadingTag : undefined} description={args.secondGroupDescription} collapsed={args.secondGroupCollapsible ? secondGroupCollapsed : undefined} onToggleCollapsed={args.secondGroupCollapsible
33
+ ? () => {
34
+ setSecondGroupCollapsed(state => !state);
35
+ }
36
+ : undefined} additionalInfo={args.showSecondAdditionalInfo
26
37
  ? { heading: 'Additional Info', content: 'This is another field group' }
27
38
  : undefined}>
28
39
  <Grid container={{ gap: 1, cols: 'repeat(auto-fill, minmax(min(40ch, 100%), 1fr))' }}>
@@ -43,13 +54,13 @@ export const FieldGroupDemo = (args) => {
43
54
  };
44
55
  FieldGroupDemo.args = {
45
56
  firstGroupName: 'Field group 1',
46
- firstGroupHeadingTag: 'h1',
57
+ firstGroupHeadingTag: undefined,
47
58
  showfirstGroupHeadingTag: true,
48
59
  firstGroupCollapsible: true,
49
60
  firstGroupDescription: '',
50
61
  showFirstAdditionalInfo: true,
51
62
  secondGroupName: 'Field group 2',
52
- secondGroupHeadingTag: 'h1',
63
+ secondGroupHeadingTag: undefined,
53
64
  showsecondGroupHeadingTag: true,
54
65
  secondGroupCollapsible: true,
55
66
  secondGroupDescription: '',