@pega/cosmos-react-work 9.0.0-build.12.0 → 9.0.0-build.12.2

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 (27) hide show
  1. package/lib/components/GenAICoach/GenAICoach.d.ts +1 -1
  2. package/lib/components/GenAICoach/GenAICoach.d.ts.map +1 -1
  3. package/lib/components/GenAICoach/GenAICoach.js +24 -6
  4. package/lib/components/GenAICoach/GenAICoach.js.map +1 -1
  5. package/lib/components/GenAICoach/GenAICoach.styles.d.ts +7 -0
  6. package/lib/components/GenAICoach/GenAICoach.styles.d.ts.map +1 -1
  7. package/lib/components/GenAICoach/GenAICoach.styles.js +38 -1
  8. package/lib/components/GenAICoach/GenAICoach.styles.js.map +1 -1
  9. package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts +1 -1
  10. package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts.map +1 -1
  11. package/lib/components/GenAICoach/GenAICoach.test-ids.js +1 -0
  12. package/lib/components/GenAICoach/GenAICoach.test-ids.js.map +1 -1
  13. package/lib/components/GenAICoach/GenAICoach.types.d.ts +34 -2
  14. package/lib/components/GenAICoach/GenAICoach.types.d.ts.map +1 -1
  15. package/lib/components/GenAICoach/GenAICoach.types.js.map +1 -1
  16. package/lib/components/GenAICoach/GenAIMessage.d.ts.map +1 -1
  17. package/lib/components/GenAICoach/GenAIMessage.js +30 -26
  18. package/lib/components/GenAICoach/GenAIMessage.js.map +1 -1
  19. package/lib/components/GenAICoach/ToolConfirmationMessage.d.ts +4 -0
  20. package/lib/components/GenAICoach/ToolConfirmationMessage.d.ts.map +1 -0
  21. package/lib/components/GenAICoach/ToolConfirmationMessage.js +19 -0
  22. package/lib/components/GenAICoach/ToolConfirmationMessage.js.map +1 -0
  23. package/lib/components/GenAICoach/ToolDetails.d.ts +5 -0
  24. package/lib/components/GenAICoach/ToolDetails.d.ts.map +1 -0
  25. package/lib/components/GenAICoach/ToolDetails.js +91 -0
  26. package/lib/components/GenAICoach/ToolDetails.js.map +1 -0
  27. package/package.json +3 -3
@@ -0,0 +1,91 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useState } from 'react';
3
+ import { Button, Flex, FormField, Grid, Input, Modal, MultiStepForm, RadioButton, RadioButtonGroup, Text, useI18n, useModalContext, useUID } from '@pega/cosmos-react-core';
4
+ import { StyledConfirmationMsg } from './GenAICoach.styles';
5
+ const CurrentToolContent = ({ tool, baseToolDetails, onDecisionChange, onParameterChange, setHasError, toolsConfirmed }) => {
6
+ const t = useI18n();
7
+ const { decision = 'approve' } = tool;
8
+ useEffect(() => {
9
+ if (tool.decision === 'modify' && tool.parameters) {
10
+ const hasEmptyParam = tool.parameters.some(param => !param.value);
11
+ setHasError?.(hasEmptyParam);
12
+ }
13
+ }, [tool.parameters, tool.decision]);
14
+ const id = useUID();
15
+ const accept = 'accept';
16
+ const modify = 'modify';
17
+ const reject = 'reject';
18
+ return (_jsxs(Flex, { container: { direction: 'column', gap: 1 }, children: [_jsx(FormField, { label: t('current_action'), readOnly: true, children: _jsx(StyledConfirmationMsg, { content: tool.message, type: 'markdown' }) }), _jsxs(RadioButtonGroup, { name: 'decision', label: t('tool_decision'), required: true, inline: true, onChange: (e) => {
19
+ if (e.target.checked) {
20
+ const value = e.target.value;
21
+ if (value === accept || value === modify || value === reject) {
22
+ onDecisionChange?.(tool.id, value);
23
+ }
24
+ }
25
+ }, readOnly: toolsConfirmed, children: [_jsx(RadioButton, { label: t('accept'), checked: decision === 'accept', id: `${id}-${accept}-${tool.id}`, value: accept }), _jsx(RadioButton, { label: t('modify'), checked: decision === 'modify', id: `${id}-${modify}-${tool.id}`, value: modify }), _jsx(RadioButton, { label: t('reject'), checked: decision === 'reject', id: `${id}-${reject}-${tool.id}`, value: reject })] }), tool.decision === modify && tool.parameters && (_jsxs(Flex, { container: { direction: 'column' }, children: [_jsx(Text, { variant: 'h2', children: t('modify_details') }), _jsx(Grid, { container: { gap: 1, cols: 'repeat(2, minmax(0, 1fr))' }, children: tool.parameters.map(param => {
26
+ const baseParamInfo = baseToolDetails?.parameters?.find(currentParam => currentParam.id === param.id);
27
+ const info = baseParamInfo ? t('current_details', [baseParamInfo.value]) : undefined;
28
+ if (param.type === 'text' || param.type === 'number') {
29
+ return (_jsx(Input, { required: true, label: param.label, defaultValue: param.value, readOnly: toolsConfirmed, type: param.type, status: !param.value ? 'error' : undefined, info: !param.value ? t('value_cannot_be_blank') : info, onChange: e => {
30
+ onParameterChange?.(tool.id, param.id, e.target.value);
31
+ } }, param.id));
32
+ }
33
+ if (param.type === 'boolean') {
34
+ return (_jsxs(RadioButtonGroup, { name: param.label, label: param.label, required: true, inline: true, onChange: (e) => {
35
+ if (e.target.checked) {
36
+ onParameterChange?.(tool.id, param.id, e.target.value);
37
+ }
38
+ }, readOnly: toolsConfirmed, info: !toolsConfirmed ? info : undefined, children: [_jsx(RadioButton, { label: t('true'), checked: param.value === 'true', id: `${id}-true`, value: 'true' }), _jsx(RadioButton, { label: t('false'), checked: param.value === 'false', id: `${id}-false`, value: 'false' })] }));
39
+ }
40
+ return null;
41
+ }) })] }))] }));
42
+ };
43
+ const ToolDetails = ({ tools: toolProps, onSubmit, onCancel, toolsConfirmed }) => {
44
+ const t = useI18n();
45
+ const { dismiss } = useModalContext();
46
+ const [currentStepIndex, setCurrentStepIndex] = useState(0);
47
+ const finalStep = currentStepIndex === (toolProps ? toolProps.length - 1 : 0);
48
+ const [tools, setTools] = useState(toolProps || []);
49
+ const [hasError, setHasError] = useState(false);
50
+ const handleDecisionChange = (toolId, currentDecision) => {
51
+ setTools(prevTools => prevTools.map(tool => (tool.id === toolId ? { ...tool, decision: currentDecision } : tool)));
52
+ };
53
+ const handleParameterChange = (toolId, parameterId, currentVal) => {
54
+ setTools(prevTools => prevTools.map(tool => {
55
+ if (tool.id === toolId && tool.parameters) {
56
+ const updatedParameters = tool.parameters.map(param => param.id === parameterId ? { ...param, value: currentVal } : param);
57
+ return { ...tool, parameters: updatedParameters };
58
+ }
59
+ return tool;
60
+ }));
61
+ };
62
+ const stepActions = useMemo(() => {
63
+ return (_jsxs(_Fragment, { children: [_jsxs(_Fragment, { children: [_jsx(Button, { onClick: () => {
64
+ if (!toolsConfirmed)
65
+ onCancel?.();
66
+ dismiss();
67
+ }, children: toolsConfirmed ? t('close') : t('cancel') }), currentStepIndex > 0 && (_jsx(Button, { onClick: () => {
68
+ if (!hasError)
69
+ setCurrentStepIndex(currentStepIndex - 1);
70
+ }, children: t('previous') }))] }), _jsxs(_Fragment, { children: [!finalStep && (_jsx(Button, { variant: 'primary', onClick: () => {
71
+ if (!hasError)
72
+ setCurrentStepIndex(currentStepIndex + 1);
73
+ }, children: t('pagination_next') })), finalStep && !toolsConfirmed && (_jsx(Button, { type: 'submit', variant: 'primary', onClick: () => {
74
+ if (!hasError) {
75
+ if (tools)
76
+ onSubmit?.(tools);
77
+ dismiss();
78
+ }
79
+ }, children: t('submit') }))] })] }));
80
+ }, [currentStepIndex, hasError, tools]);
81
+ const stepData = useMemo(() => {
82
+ return tools.map(tool => ({
83
+ id: tool.id,
84
+ name: tool.name,
85
+ content: (_jsx(CurrentToolContent, { tool: tool, baseToolDetails: toolProps?.find(toolVal => toolVal.id === tool.id), setHasError: setHasError, toolsConfirmed: toolsConfirmed, onDecisionChange: handleDecisionChange, onParameterChange: handleParameterChange }))
86
+ }));
87
+ }, [tools]);
88
+ return (_jsx(Modal, { heading: t('confirm_details'), actions: stepActions, children: _jsx(MultiStepForm, { steps: stepData, currentStepId: stepData[currentStepIndex].id, stepIndicator: 'horizontal' }) }));
89
+ };
90
+ export default ToolDetails;
91
+ //# sourceMappingURL=ToolDetails.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolDetails.js","sourceRoot":"","sources":["../../../src/components/GenAICoach/ToolDetails.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EA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CAAC;IACJ,CAAC,EAAE,CAAC,gBAAgB,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IAExC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACxB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,CACP,KAAC,kBAAkB,IACjB,IAAI,EAAE,IAAI,EACV,eAAe,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,EACnE,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,oBAAoB,EACtC,iBAAiB,EAAE,qBAAqB,GACxC,CACH;SACF,CAAC,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CACL,KAAC,KAAK,IAAC,OAAO,EAAE,CAAC,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,WAAW,YACxD,KAAC,aAAa,IACZ,KAAK,EAAE,QAAQ,EACf,aAAa,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC,EAAE,EAC5C,aAAa,EAAC,YAAY,GAC1B,GACI,CACT,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { useEffect, useMemo, useState } from 'react';\nimport type { ChangeEvent, Dispatch, SetStateAction } from 'react';\n\nimport {\n Button,\n Flex,\n FormField,\n Grid,\n Input,\n Modal,\n MultiStepForm,\n RadioButton,\n RadioButtonGroup,\n Text,\n useI18n,\n useModalContext,\n useUID\n} from '@pega/cosmos-react-core';\nimport type { OmitStrict } from '@pega/cosmos-react-core';\n\nimport type { Tool, ToolDetailsProps, ToolParameters } from './GenAICoach.types';\nimport { StyledConfirmationMsg } from './GenAICoach.styles';\n\nconst CurrentToolContent = ({\n tool,\n baseToolDetails,\n onDecisionChange,\n onParameterChange,\n setHasError,\n toolsConfirmed\n}: {\n tool: Tool;\n baseToolDetails?: Tool;\n toolsConfirmed?: boolean;\n setHasError?: Dispatch<SetStateAction<boolean>>;\n onDecisionChange: (toolId: Tool['id'], currentDecision: Tool['decision']) => void;\n onParameterChange?: (\n toolId: Tool['id'],\n parameterId: ToolParameters['id'],\n currentVal: ToolParameters['value']\n ) => void;\n}) => {\n const t = useI18n();\n const { decision = 'approve' } = tool;\n\n useEffect(() => {\n if (tool.decision === 'modify' && tool.parameters) {\n const hasEmptyParam = tool.parameters.some(param => !param.value);\n\n setHasError?.(hasEmptyParam);\n }\n }, [tool.parameters, tool.decision]);\n\n const id = useUID();\n const accept = 'accept';\n const modify = 'modify';\n const reject = 'reject';\n return (\n <Flex container={{ direction: 'column', gap: 1 }}>\n <FormField label={t('current_action')} readOnly>\n <StyledConfirmationMsg content={tool.message} type='markdown' />\n </FormField>\n\n <RadioButtonGroup\n name='decision'\n label={t('tool_decision')}\n required\n inline\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.checked) {\n const value = e.target.value;\n if (value === accept || value === modify || value === reject) {\n onDecisionChange?.(tool.id, value);\n }\n }\n }}\n readOnly={toolsConfirmed}\n >\n <RadioButton\n label={t('accept')}\n checked={decision === 'accept'}\n id={`${id}-${accept}-${tool.id}`}\n value={accept}\n />\n <RadioButton\n label={t('modify')}\n checked={decision === 'modify'}\n id={`${id}-${modify}-${tool.id}`}\n value={modify}\n />\n <RadioButton\n label={t('reject')}\n checked={decision === 'reject'}\n id={`${id}-${reject}-${tool.id}`}\n value={reject}\n />\n </RadioButtonGroup>\n\n {tool.decision === modify && tool.parameters && (\n <Flex container={{ direction: 'column' }}>\n <Text variant='h2'>{t('modify_details')}</Text>\n <Grid container={{ gap: 1, cols: 'repeat(2, minmax(0, 1fr))' }}>\n {tool.parameters.map(param => {\n const baseParamInfo = baseToolDetails?.parameters?.find(\n currentParam => currentParam.id === param.id\n );\n const info = baseParamInfo ? t('current_details', [baseParamInfo.value]) : undefined;\n if (param.type === 'text' || param.type === 'number') {\n return (\n <Input\n key={param.id}\n required\n label={param.label}\n defaultValue={param.value}\n readOnly={toolsConfirmed}\n type={param.type}\n status={!param.value ? 'error' : undefined}\n info={!param.value ? t('value_cannot_be_blank') : info}\n onChange={e => {\n onParameterChange?.(tool.id, param.id, e.target.value);\n }}\n />\n );\n }\n if (param.type === 'boolean') {\n return (\n <RadioButtonGroup\n name={param.label}\n label={param.label}\n required\n inline\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.checked) {\n onParameterChange?.(tool.id, param.id, e.target.value);\n }\n }}\n readOnly={toolsConfirmed}\n info={!toolsConfirmed ? info : undefined}\n >\n <RadioButton\n label={t('true')}\n checked={param.value === 'true'}\n id={`${id}-true`}\n value='true'\n />\n <RadioButton\n label={t('false')}\n checked={param.value === 'false'}\n id={`${id}-false`}\n value='false'\n />\n </RadioButtonGroup>\n );\n }\n return null;\n })}\n </Grid>\n </Flex>\n )}\n </Flex>\n );\n};\n\nconst ToolDetails = ({\n tools: toolProps,\n onSubmit,\n onCancel,\n toolsConfirmed\n}: OmitStrict<ToolDetailsProps, 'isToolConfirmation'>) => {\n const t = useI18n();\n const { dismiss } = useModalContext();\n const [currentStepIndex, setCurrentStepIndex] = useState(0);\n const finalStep = currentStepIndex === (toolProps ? toolProps.length - 1 : 0);\n\n const [tools, setTools] = useState<Tool[]>(toolProps || []);\n const [hasError, setHasError] = useState(false);\n\n const handleDecisionChange = (toolId: Tool['id'], currentDecision: Tool['decision']) => {\n setTools(prevTools =>\n prevTools.map(tool => (tool.id === toolId ? { ...tool, decision: currentDecision } : tool))\n );\n };\n\n const handleParameterChange = (\n toolId: Tool['id'],\n parameterId: ToolParameters['id'],\n currentVal: ToolParameters['value']\n ) => {\n setTools(prevTools =>\n prevTools.map(tool => {\n if (tool.id === toolId && tool.parameters) {\n const updatedParameters = tool.parameters.map(param =>\n param.id === parameterId ? { ...param, value: currentVal } : param\n );\n return { ...tool, parameters: updatedParameters };\n }\n return tool;\n })\n );\n };\n\n const stepActions = useMemo(() => {\n return (\n <>\n <>\n <Button\n onClick={() => {\n if (!toolsConfirmed) onCancel?.();\n dismiss();\n }}\n >\n {toolsConfirmed ? t('close') : t('cancel')}\n </Button>\n {currentStepIndex > 0 && (\n <Button\n onClick={() => {\n if (!hasError) setCurrentStepIndex(currentStepIndex - 1);\n }}\n >\n {t('previous')}\n </Button>\n )}\n </>\n\n <>\n {!finalStep && (\n <Button\n variant='primary'\n onClick={() => {\n if (!hasError) setCurrentStepIndex(currentStepIndex + 1);\n }}\n >\n {t('pagination_next')}\n </Button>\n )}\n {finalStep && !toolsConfirmed && (\n <Button\n type='submit'\n variant='primary'\n onClick={() => {\n if (!hasError) {\n if (tools) onSubmit?.(tools);\n dismiss();\n }\n }}\n >\n {t('submit')}\n </Button>\n )}\n </>\n </>\n );\n }, [currentStepIndex, hasError, tools]);\n\n const stepData = useMemo(() => {\n return tools.map(tool => ({\n id: tool.id,\n name: tool.name,\n content: (\n <CurrentToolContent\n tool={tool}\n baseToolDetails={toolProps?.find(toolVal => toolVal.id === tool.id)}\n setHasError={setHasError}\n toolsConfirmed={toolsConfirmed}\n onDecisionChange={handleDecisionChange}\n onParameterChange={handleParameterChange}\n />\n )\n }));\n }, [tools]);\n\n return (\n <Modal heading={t('confirm_details')} actions={stepActions}>\n <MultiStepForm\n steps={stepData}\n currentStepId={stepData[currentStepIndex].id}\n stepIndicator='horizontal'\n />\n </Modal>\n );\n};\n\nexport default ToolDetails;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-work",
3
- "version": "9.0.0-build.12.0",
3
+ "version": "9.0.0-build.12.2",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "Pegasystems",
6
6
  "sideEffects": false,
@@ -14,8 +14,8 @@
14
14
  "build": "tsc -b tsconfig.build.json"
15
15
  },
16
16
  "dependencies": {
17
- "@pega/cosmos-react-core": "9.0.0-build.12.0",
18
- "@pega/cosmos-react-rte": "9.0.0-build.12.0",
17
+ "@pega/cosmos-react-core": "9.0.0-build.12.2",
18
+ "@pega/cosmos-react-rte": "9.0.0-build.12.2",
19
19
  "@types/react": "^17.0.62 || ^18.3.3",
20
20
  "@types/react-dom": "^17.0.20 || ^18.3.0",
21
21
  "@types/styled-components": "^5.1.26",