@pega/custom-dx-components 0.24.15 → 0.24.17
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/README.md +1 -1
- package/package.json +1 -1
- package/src/tasks/build-all/helper.js +1 -1
- package/src/tasks/build-comp/helper.js +4 -2
- package/src/tasks/build-comp/index.js +8 -2
- package/src/tasks/create/templates/Constellation/Field/Boolean/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Date/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Date/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/demo.stories.tsx.mustache +14 -15
- package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Text/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/Avatar.tsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/Operator.tsx.mustache +218 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.tsx.mustache +46 -13
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.tsx.mustache +3 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.ts.mustache +55 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/Avatar.tsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/Operator.tsx.mustache +218 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.tsx.mustache +46 -12
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.tsx.mustache +3 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.ts.mustache +55 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.tsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Template/FORM-region/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.tsx.mustache +3 -2
- package/src/tasks/create/templates/Constellation/Template/PAGE/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.tsx.mustache +21 -23
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.tsx.mustache +14 -17
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Widget/CASE/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Launchpad/Widget/CASE/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/create-nonce.ts.mustache +6 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/index.tsx.mustache +1 -0
- package/src/tasks/delete/helper.js +21 -3
- package/src/tasks/init/helper.js +5 -5
- package/src/tasks/init/template/package.json.mustache +4 -4
- package/src/tasks/list/helper.js +4 -1
- package/src/tasks/promote-webpack/webpack.config.js +26 -0
- package/src/tasks/publish/helper.js +46 -45
- package/src/tasks/publish/index.js +8 -2
- package/src/tasks/rename/index.js +10 -2
- package/src/tasks/revert-webpack/index.js +1 -5
- package/src/util.js +6 -6
- package/tests/assets/components/create/Pega_DXIL_MyTestText/create-nonce.ts +6 -0
- package/tests/assets/components/create/Pega_DXIL_MyTestText/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyBoolean/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyBoolean/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/demo.stories.tsx +21 -23
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCurrency/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCurrency/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDecimal/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDecimal/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/demo.stories.tsx +46 -13
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/index.tsx +3 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyEmail/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyEmail/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/index.tsx +2 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyIconButtonURL/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyIconButtonURL/demo.stories.tsx +14 -15
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyIconButtonURL/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyInteger/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyInteger/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageWidget/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageWidget/demo.stories.tsx +14 -17
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageWidget/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyParagraph/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyParagraph/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPercentage/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPercentage/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPhone/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPhone/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPicklist/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPicklist/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyRadioButtons/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyRadioButtons/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MySearchbox/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MySearchbox/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyText/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyText/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTextInput/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTextInput/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/index.tsx +1 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/demo.stories.tsx +46 -12
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/index.tsx +3 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/index.tsx +3 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyBoolean/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyBoolean/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCaseWidget/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCaseWidget/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCurrency/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCurrency/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDecimal/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDecimal/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/demo.stories.tsx +46 -13
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/index.tsx +3 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyEmail/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyEmail/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/index.tsx +2 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyIconButtonURL/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyIconButtonURL/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyInteger/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyInteger/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyParagraph/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyParagraph/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPercentage/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPercentage/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPhone/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPhone/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPicklist/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPicklist/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyRadioButtons/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyRadioButtons/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MySearchbox/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MySearchbox/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyText/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyText/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTextInput/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTextInput/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/index.tsx +1 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/demo.stories.tsx +46 -12
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/index.tsx +3 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/index.tsx +3 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/create-nonce.ts +6 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/index.tsx +1 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { useState, useEffect, Fragment } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
Link,
|
|
5
|
+
Button,
|
|
6
|
+
Popover,
|
|
7
|
+
useOuterEvent,
|
|
8
|
+
useElement,
|
|
9
|
+
Progress,
|
|
10
|
+
FormField,
|
|
11
|
+
useTheme,
|
|
12
|
+
withConfiguration
|
|
13
|
+
} from '@pega/cosmos-react-core';
|
|
14
|
+
import { Glimpse } from '@pega/cosmos-react-work';
|
|
15
|
+
import { EmailDisplay } from '@pega/cosmos-react-core';
|
|
16
|
+
|
|
17
|
+
import type { PConnFieldProps } from './PConnProps';
|
|
18
|
+
|
|
19
|
+
import Avatar from './Avatar';
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
// interface for props
|
|
23
|
+
interface {{COMPONENT_CLASS_NAME}}OperatorProps extends PConnFieldProps {
|
|
24
|
+
// If any, enter additional props that only exist on TextInput here
|
|
25
|
+
name: string;
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
metaObj: any;
|
|
29
|
+
externalUser: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let pTarget = null;
|
|
33
|
+
|
|
34
|
+
function Operator(props: {{COMPONENT_CLASS_NAME}}OperatorProps) {
|
|
35
|
+
const { id, name, label, testId, helperText, externalUser, metaObj } = props;
|
|
36
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
37
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
38
|
+
const [popoverEl, setPopoverEl] = useElement(null);
|
|
39
|
+
const [popoverContent, setpopoverContent] = useState(null);
|
|
40
|
+
const theme: any = useTheme();
|
|
41
|
+
|
|
42
|
+
/* If the id has changed, we need to reset the popover */
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
pTarget = null;
|
|
45
|
+
}, [id]);
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
{{! pick new delimiters for mustache }}
|
|
49
|
+
{{=<% %>=}}
|
|
50
|
+
|
|
51
|
+
const OperatorPreview = () => {
|
|
52
|
+
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
|
|
53
|
+
const localeCategory = 'Operator';
|
|
54
|
+
setpopoverContent(
|
|
55
|
+
<Progress variant='ring' message={localizedVal('Loading operator...', localeCategory)} placement='local' />
|
|
56
|
+
);
|
|
57
|
+
if (externalUser && externalUser.classID !== 'Data-Party-Operator') {
|
|
58
|
+
const fields = [
|
|
59
|
+
{
|
|
60
|
+
id: 'pyFirstName',
|
|
61
|
+
name: localizedVal('Name', localeCategory),
|
|
62
|
+
value: externalUser.name
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'pyEmail1',
|
|
66
|
+
name: localizedVal('Email', localeCategory),
|
|
67
|
+
value:
|
|
68
|
+
externalUser.email !== '' ? <Link href={`mailto:${externalUser.email}`}>{externalUser.email}</Link> : ''
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'pyPhoneNumber',
|
|
72
|
+
name: localizedVal('Phone', localeCategory),
|
|
73
|
+
value: externalUser.phone !== '' ? <Link href={`tel:${externalUser.phone}`}>{externalUser.phone}</Link> : ''
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
setIsLoading(false);
|
|
77
|
+
setpopoverContent(
|
|
78
|
+
<Glimpse
|
|
79
|
+
visual={
|
|
80
|
+
<Avatar
|
|
81
|
+
metaObj={{
|
|
82
|
+
name: externalUser.name
|
|
83
|
+
}}
|
|
84
|
+
/>
|
|
85
|
+
}
|
|
86
|
+
primary={externalUser.name}
|
|
87
|
+
secondary={[externalUser.position]}
|
|
88
|
+
fields={fields}
|
|
89
|
+
target={pTarget}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
} else {
|
|
93
|
+
return PCore.getUserApi()
|
|
94
|
+
.getOperatorDetails(id, true)
|
|
95
|
+
.then(res => {
|
|
96
|
+
if (res.data?.pyOperatorInfo) {
|
|
97
|
+
const fields = [];
|
|
98
|
+
const data = res.data;
|
|
99
|
+
if (data.pyOperatorInfo && data.pyOperatorInfo.pyUserName) {
|
|
100
|
+
fields.push({
|
|
101
|
+
id: 'Name',
|
|
102
|
+
name: localizedVal('Name', localeCategory),
|
|
103
|
+
value: data.pyOperatorInfo.pyUserName
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (data.pyOperatorInfo && data.pyOperatorInfo.pyEmailAddress) {
|
|
107
|
+
fields.push({
|
|
108
|
+
id: 'Email',
|
|
109
|
+
name: localizedVal('Email address', localeCategory),
|
|
110
|
+
value: <EmailDisplay value={data.pyOperatorInfo.pyEmailAddress} />
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const opAvatar = (
|
|
114
|
+
<Avatar
|
|
115
|
+
metaObj={{
|
|
116
|
+
image: '',
|
|
117
|
+
name: data.pyOperatorInfo.pyUserName
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
setIsLoading(false);
|
|
123
|
+
setpopoverContent(
|
|
124
|
+
<Glimpse
|
|
125
|
+
heading={{
|
|
126
|
+
primary: data.pyOperatorInfo.pyUserName,
|
|
127
|
+
secondary: data.pyOperatorInfo.pyEmailAddress,
|
|
128
|
+
visual: opAvatar
|
|
129
|
+
}}
|
|
130
|
+
fields={fields}
|
|
131
|
+
target={pTarget}
|
|
132
|
+
onDismiss={() => {pTarget = null;}}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
<%={{ }}=%> {{! revert delimiters for mustache }}
|
|
141
|
+
|
|
142
|
+
const clickAction = (e: any) => {
|
|
143
|
+
|
|
144
|
+
setIsOpen(!isOpen);
|
|
145
|
+
if (pTarget === null) {
|
|
146
|
+
pTarget = e.currentTarget;
|
|
147
|
+
OperatorPreview();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const hidePopover = () => {
|
|
152
|
+
if (isOpen) {
|
|
153
|
+
setIsOpen(false);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
useOuterEvent('mousedown', [popoverEl], hidePopover); // Call the method on clicking outside these elements
|
|
158
|
+
|
|
159
|
+
const hideOnEscape = (e: any) => {
|
|
160
|
+
if (e.key === 'Escape') hidePopover(); // Call the method when Escape key is pressed
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const comp = (
|
|
164
|
+
<Fragment>
|
|
165
|
+
{metaObj ? (
|
|
166
|
+
<Button
|
|
167
|
+
variant='text'
|
|
168
|
+
aria-haspopup
|
|
169
|
+
aria-expanded={isOpen}
|
|
170
|
+
onClick={clickAction}
|
|
171
|
+
onKeyDown={hideOnEscape}
|
|
172
|
+
data-test-id={testId}
|
|
173
|
+
style={label !== null ? { width: 'max-content', height: theme.components.input.height } : undefined}
|
|
174
|
+
>
|
|
175
|
+
<Avatar {...props} />
|
|
176
|
+
</Button>
|
|
177
|
+
) : (
|
|
178
|
+
<Button
|
|
179
|
+
variant='link'
|
|
180
|
+
aria-haspopup
|
|
181
|
+
aria-expanded={isOpen}
|
|
182
|
+
onClick={clickAction}
|
|
183
|
+
onKeyDown={hideOnEscape}
|
|
184
|
+
data-test-id={testId}
|
|
185
|
+
style={label !== null ? { width: 'max-content', height: theme.components.input.height } : undefined}
|
|
186
|
+
>
|
|
187
|
+
{name}
|
|
188
|
+
</Button>
|
|
189
|
+
)}
|
|
190
|
+
|
|
191
|
+
{isOpen && (
|
|
192
|
+
<Popover
|
|
193
|
+
ref={setPopoverEl}
|
|
194
|
+
groupId='operator'
|
|
195
|
+
target={pTarget}
|
|
196
|
+
placement='bottom-start'
|
|
197
|
+
style={isLoading ? { position: 'relative', width: '10rem', minHeight: '4rem' } : undefined}
|
|
198
|
+
strategy='fixed'
|
|
199
|
+
>
|
|
200
|
+
{popoverContent}
|
|
201
|
+
</Popover>
|
|
202
|
+
)}
|
|
203
|
+
</Fragment>
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
if (label !== null) {
|
|
207
|
+
return (
|
|
208
|
+
<FormField label={label} info={helperText}>
|
|
209
|
+
{comp}
|
|
210
|
+
</FormField>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return comp;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
export default withConfiguration(Operator);
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
5
|
import { Text, FieldValueList, Button, DateTimeDisplay, useTheme } from '@pega/cosmos-react-core';
|
|
6
6
|
import {{COMPONENT_CLASS_NAME}} from './index';
|
|
7
|
-
import { pyReviewRaw, pyReviewResolved, regionChildrenResolved } from './mock';
|
|
7
|
+
import { pyReviewRaw, pyReviewResolved, regionChildrenResolved, operatorDetails, configProps } from './mock';
|
|
8
8
|
import StatusWorkRenderer from './StatusWork';
|
|
9
|
-
|
|
9
|
+
import Operator from './Operator';
|
|
10
10
|
|
|
11
11
|
const meta: Meta<typeof {{COMPONENT_CLASS_NAME}}> = {
|
|
12
12
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -20,6 +20,28 @@ const meta: Meta<typeof {{COMPONENT_CLASS_NAME}}> = {
|
|
|
20
20
|
export default meta;
|
|
21
21
|
type Story = StoryObj<typeof {{COMPONENT_CLASS_NAME}}>;
|
|
22
22
|
|
|
23
|
+
if (!window.PCore) {
|
|
24
|
+
window.PCore = {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
window.PCore.getLocaleUtils = () => {
|
|
28
|
+
return {
|
|
29
|
+
getLocaleValue: value => {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
window.PCore.getUserApi = () => {
|
|
36
|
+
return {
|
|
37
|
+
getOperatorDetails: () => {
|
|
38
|
+
return new Promise(resolve => {
|
|
39
|
+
resolve(operatorDetails);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
23
45
|
const Region = props => {
|
|
24
46
|
return <></>;
|
|
25
47
|
};
|
|
@@ -60,19 +82,30 @@ const renderField = resolvedProps => {
|
|
|
60
82
|
|
|
61
83
|
if (displayAsStatus === true) val = <StatusWorkRenderer value={value} key={key} />;
|
|
62
84
|
|
|
85
|
+
const [_label] =
|
|
86
|
+
label === 'Create operator'
|
|
87
|
+
? [configProps.createLabel, configProps.createOperator, configProps.createDateTime]
|
|
88
|
+
: label === 'Update operator'
|
|
89
|
+
? [configProps.updateLabel, configProps.updateOperator, configProps.updateDateTime]
|
|
90
|
+
: [configProps.resolveLabel, configProps.resolveOperator, configProps.resolveDateTime];
|
|
91
|
+
|
|
63
92
|
if (label === 'Create Operator')
|
|
64
93
|
val = (
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
|
|
94
|
+
<Operator
|
|
95
|
+
label={configProps.hideLabel ? '' : _label}
|
|
96
|
+
name={configProps.createOperator.userName}
|
|
97
|
+
id={configProps.createOperator.userId}
|
|
98
|
+
value={undefined}
|
|
99
|
+
validatemessage=''
|
|
100
|
+
hideLabel={false}
|
|
101
|
+
readOnly={false}
|
|
102
|
+
required={false}
|
|
103
|
+
disabled={false}
|
|
104
|
+
externalUser={undefined}
|
|
105
|
+
metaObj={undefined}
|
|
106
|
+
testId=''
|
|
107
|
+
helperText=''
|
|
108
|
+
/>
|
|
76
109
|
);
|
|
77
110
|
|
|
78
111
|
if (variant === 'inline') {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment, Children, ReactElement } from 'react';
|
|
2
2
|
import { Grid, Flex, FieldGroup, withConfiguration, GridContainerProps } from '@pega/cosmos-react-core';
|
|
3
3
|
import type { PConnFieldProps } from './PConnProps';
|
|
4
|
+
import './create-nonce';
|
|
4
5
|
import DetailsRender from './DetailsRender';
|
|
5
6
|
import HighlightRender from './HighlightRender';
|
|
6
7
|
|
|
@@ -41,7 +42,7 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
41
42
|
const numRegions = getAllFields(getPConnect)?.length;
|
|
42
43
|
const gridRepeat = "repeat(".concat(numRegions).concat(", 1fr)");
|
|
43
44
|
|
|
44
|
-
const gridContainer: GridContainerProps = { colGap:
|
|
45
|
+
const gridContainer: GridContainerProps = { colGap: 6 };
|
|
45
46
|
gridContainer.cols = gridRepeat;
|
|
46
47
|
gridContainer.alignItems = 'start';
|
|
47
48
|
|
|
@@ -84,7 +85,7 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
84
85
|
|
|
85
86
|
<Flex
|
|
86
87
|
// @ts-ignore
|
|
87
|
-
container={{ direction: 'column', alignItems: 'normal', colGap:
|
|
88
|
+
container={{ direction: 'column', alignItems: 'normal', colGap: 1, rowGap: 1.5 }}
|
|
88
89
|
key={`r-${i + 1}`}
|
|
89
90
|
>
|
|
90
91
|
<DetailsRender child={child} />
|
|
@@ -193,3 +193,58 @@ export const regionChildrenResolved = [
|
|
|
193
193
|
key: 'SLA Start Time'
|
|
194
194
|
}
|
|
195
195
|
];
|
|
196
|
+
|
|
197
|
+
export const operatorDetails = {
|
|
198
|
+
data: {
|
|
199
|
+
pzLoadTime: 'January 18, 2023 10:33:19 AM EST',
|
|
200
|
+
pzPageNameHash: '_pa1519192551088960pz',
|
|
201
|
+
pyOperatorInfo: {
|
|
202
|
+
pyUserName: 'french DigV2',
|
|
203
|
+
pyPosition: '',
|
|
204
|
+
pyImageInsKey: '',
|
|
205
|
+
pySkills: [
|
|
206
|
+
{
|
|
207
|
+
pySkillName: '',
|
|
208
|
+
pzIndexOwnerKey: 'DATA-ADMIN-OPERATOR-ID FRENCHTEST.DIGV2',
|
|
209
|
+
pySkillRating: 0
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
pyReportToUserName: '',
|
|
213
|
+
pyReportTo: '',
|
|
214
|
+
pyOrganization: 'DXIL',
|
|
215
|
+
pyTitle: '',
|
|
216
|
+
pyLabel: 'frenchTest.DigV2',
|
|
217
|
+
pyEmailAddress: 'User@DigV2',
|
|
218
|
+
pyTelephone: ''
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
status: 200,
|
|
222
|
+
statusText: '',
|
|
223
|
+
headers: {
|
|
224
|
+
'content-length': '435',
|
|
225
|
+
'content-type': 'application/json;charset=UTF-8'
|
|
226
|
+
},
|
|
227
|
+
request: {}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export const configProps = {
|
|
231
|
+
label: 'Create operator',
|
|
232
|
+
createLabel: 'Created',
|
|
233
|
+
updateLabel: 'Updated',
|
|
234
|
+
updateDateTime: '2023-01-16T14:53:33.280Z',
|
|
235
|
+
createDateTime: '2023-01-16T14:53:33.198Z',
|
|
236
|
+
updateOperator: {
|
|
237
|
+
userId: 'admin@mediaco',
|
|
238
|
+
userName: 'admin'
|
|
239
|
+
},
|
|
240
|
+
createOperator: {
|
|
241
|
+
userId: 'admin@mediaco',
|
|
242
|
+
userName: 'admin'
|
|
243
|
+
},
|
|
244
|
+
resolveLabel: '',
|
|
245
|
+
resolveOperator: '',
|
|
246
|
+
resolveDateTime: '',
|
|
247
|
+
hideLabel: true,
|
|
248
|
+
key: '_532zx1dah',
|
|
249
|
+
displayMode: 'LABELS_LEFT'
|
|
250
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { Avatar as CosmosAvatar, withConfiguration } from '@pega/cosmos-react-core';
|
|
5
|
+
import type { PConnFieldProps } from './PConnProps';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// interface for props
|
|
9
|
+
interface {{COMPONENT_CLASS_NAME}}AvatarProps extends PConnFieldProps {
|
|
10
|
+
// If any, enter additional props that only exist on TextInput here
|
|
11
|
+
metaObj: any;
|
|
12
|
+
showStatus: boolean;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function Avatar(props: {{COMPONENT_CLASS_NAME}}AvatarProps) {
|
|
17
|
+
const { metaObj, showStatus = false } = props;
|
|
18
|
+
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
|
+
|
|
22
|
+
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
|
+
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
|
+
if (!metaObj) {
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
27
|
+
} else {
|
|
28
|
+
userName = metaObj.name;
|
|
29
|
+
userIdentifier = metaObj.ID;
|
|
30
|
+
}
|
|
31
|
+
if (!userName && userIdentifier) {
|
|
32
|
+
userName = userIdentifier;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const imageKey = !metaObj ? PCore.getEnvironmentInfo().getOperatorImageInsKey() : metaObj.image;
|
|
37
|
+
if (imageKey) {
|
|
38
|
+
PCore.getAssetLoader()
|
|
39
|
+
.getSvcImage(imageKey)
|
|
40
|
+
.then((blob) => window.URL.createObjectURL(blob))
|
|
41
|
+
.then((imagePath) => setImageBlobUrl(imagePath as React.SetStateAction<any>));
|
|
42
|
+
}
|
|
43
|
+
}, [metaObj]);
|
|
44
|
+
|
|
45
|
+
if (showStatus) {
|
|
46
|
+
const currentState = PCore.getMessagingServiceManager().getUserPresence().getUserState(userIdentifier);
|
|
47
|
+
const [userState, setUserState]: any = useState(currentState === 'online' ? 'active' : 'inactive');
|
|
48
|
+
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
const handleUserStateChange = ({ state }) => {
|
|
51
|
+
setUserState(state === 'online' ? 'active' : 'inactive');
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const subId = PCore.getMessagingServiceManager()
|
|
56
|
+
.getUserPresence()
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
.subscribe(userIdentifier, handleUserStateChange);
|
|
59
|
+
|
|
60
|
+
return function cleanup() {
|
|
61
|
+
PCore.getMessagingServiceManager().getUserPresence().unsubscribe(userIdentifier, subId);
|
|
62
|
+
};
|
|
63
|
+
}, [userIdentifier, handleUserStateChange]);
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
return <CosmosAvatar name={userName} imageSrc={imageBlobUrl as React.SetStateAction<any>} status={userState} />;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Do not render when userName does not exists
|
|
69
|
+
// TODO : In CNR case, pxRequestor is not available, please remove this condition once it populates
|
|
70
|
+
if (!userName) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return <CosmosAvatar name={userName} imageSrc={imageBlobUrl as React.SetStateAction<any>} />;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
export default withConfiguration(Avatar);
|
package/src/tasks/create/templates/Constellation/Template/DETAILS-region/Operator.tsx.mustache
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { useState, useEffect, Fragment } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
Link,
|
|
5
|
+
Button,
|
|
6
|
+
Popover,
|
|
7
|
+
useOuterEvent,
|
|
8
|
+
useElement,
|
|
9
|
+
Progress,
|
|
10
|
+
FormField,
|
|
11
|
+
useTheme,
|
|
12
|
+
withConfiguration
|
|
13
|
+
} from '@pega/cosmos-react-core';
|
|
14
|
+
import { Glimpse } from '@pega/cosmos-react-work';
|
|
15
|
+
import { EmailDisplay } from '@pega/cosmos-react-core';
|
|
16
|
+
|
|
17
|
+
import type { PConnFieldProps } from './PConnProps';
|
|
18
|
+
|
|
19
|
+
import Avatar from './Avatar';
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
// interface for props
|
|
23
|
+
interface {{COMPONENT_CLASS_NAME}}OperatorProps extends PConnFieldProps {
|
|
24
|
+
// If any, enter additional props that only exist on TextInput here
|
|
25
|
+
name: string;
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
metaObj: any;
|
|
29
|
+
externalUser: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let pTarget = null;
|
|
33
|
+
|
|
34
|
+
function Operator(props: {{COMPONENT_CLASS_NAME}}OperatorProps) {
|
|
35
|
+
const { id, name, label, testId, helperText, externalUser, metaObj } = props;
|
|
36
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
37
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
38
|
+
const [popoverEl, setPopoverEl] = useElement(null);
|
|
39
|
+
const [popoverContent, setpopoverContent] = useState(null);
|
|
40
|
+
const theme: any = useTheme();
|
|
41
|
+
|
|
42
|
+
/* If the id has changed, we need to reset the popover */
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
pTarget = null;
|
|
45
|
+
}, [id]);
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
{{! pick new delimiters for mustache }}
|
|
49
|
+
{{=<% %>=}}
|
|
50
|
+
|
|
51
|
+
const OperatorPreview = () => {
|
|
52
|
+
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
|
|
53
|
+
const localeCategory = 'Operator';
|
|
54
|
+
setpopoverContent(
|
|
55
|
+
<Progress variant='ring' message={localizedVal('Loading operator...', localeCategory)} placement='local' />
|
|
56
|
+
);
|
|
57
|
+
if (externalUser && externalUser.classID !== 'Data-Party-Operator') {
|
|
58
|
+
const fields = [
|
|
59
|
+
{
|
|
60
|
+
id: 'pyFirstName',
|
|
61
|
+
name: localizedVal('Name', localeCategory),
|
|
62
|
+
value: externalUser.name
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'pyEmail1',
|
|
66
|
+
name: localizedVal('Email', localeCategory),
|
|
67
|
+
value:
|
|
68
|
+
externalUser.email !== '' ? <Link href={`mailto:${externalUser.email}`}>{externalUser.email}</Link> : ''
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'pyPhoneNumber',
|
|
72
|
+
name: localizedVal('Phone', localeCategory),
|
|
73
|
+
value: externalUser.phone !== '' ? <Link href={`tel:${externalUser.phone}`}>{externalUser.phone}</Link> : ''
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
setIsLoading(false);
|
|
77
|
+
setpopoverContent(
|
|
78
|
+
<Glimpse
|
|
79
|
+
visual={
|
|
80
|
+
<Avatar
|
|
81
|
+
metaObj={{
|
|
82
|
+
name: externalUser.name
|
|
83
|
+
}}
|
|
84
|
+
/>
|
|
85
|
+
}
|
|
86
|
+
primary={externalUser.name}
|
|
87
|
+
secondary={[externalUser.position]}
|
|
88
|
+
fields={fields}
|
|
89
|
+
target={pTarget}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
} else {
|
|
93
|
+
return PCore.getUserApi()
|
|
94
|
+
.getOperatorDetails(id, true)
|
|
95
|
+
.then(res => {
|
|
96
|
+
if (res.data?.pyOperatorInfo) {
|
|
97
|
+
const fields = [];
|
|
98
|
+
const data = res.data;
|
|
99
|
+
if (data.pyOperatorInfo && data.pyOperatorInfo.pyUserName) {
|
|
100
|
+
fields.push({
|
|
101
|
+
id: 'Name',
|
|
102
|
+
name: localizedVal('Name', localeCategory),
|
|
103
|
+
value: data.pyOperatorInfo.pyUserName
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (data.pyOperatorInfo && data.pyOperatorInfo.pyEmailAddress) {
|
|
107
|
+
fields.push({
|
|
108
|
+
id: 'Email',
|
|
109
|
+
name: localizedVal('Email address', localeCategory),
|
|
110
|
+
value: <EmailDisplay value={data.pyOperatorInfo.pyEmailAddress} />
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const opAvatar = (
|
|
114
|
+
<Avatar
|
|
115
|
+
metaObj={{
|
|
116
|
+
image: '',
|
|
117
|
+
name: data.pyOperatorInfo.pyUserName
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
setIsLoading(false);
|
|
123
|
+
setpopoverContent(
|
|
124
|
+
<Glimpse
|
|
125
|
+
heading={{
|
|
126
|
+
primary: data.pyOperatorInfo.pyUserName,
|
|
127
|
+
secondary: data.pyOperatorInfo.pyEmailAddress,
|
|
128
|
+
visual: opAvatar
|
|
129
|
+
}}
|
|
130
|
+
fields={fields}
|
|
131
|
+
target={pTarget}
|
|
132
|
+
onDismiss={() => {pTarget = null;}}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
<%={{ }}=%> {{! revert delimiters for mustache }}
|
|
141
|
+
|
|
142
|
+
const clickAction = (e: any) => {
|
|
143
|
+
|
|
144
|
+
setIsOpen(!isOpen);
|
|
145
|
+
if (pTarget === null) {
|
|
146
|
+
pTarget = e.currentTarget;
|
|
147
|
+
OperatorPreview();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const hidePopover = () => {
|
|
152
|
+
if (isOpen) {
|
|
153
|
+
setIsOpen(false);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
useOuterEvent('mousedown', [popoverEl], hidePopover); // Call the method on clicking outside these elements
|
|
158
|
+
|
|
159
|
+
const hideOnEscape = (e: any) => {
|
|
160
|
+
if (e.key === 'Escape') hidePopover(); // Call the method when Escape key is pressed
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const comp = (
|
|
164
|
+
<Fragment>
|
|
165
|
+
{metaObj ? (
|
|
166
|
+
<Button
|
|
167
|
+
variant='text'
|
|
168
|
+
aria-haspopup
|
|
169
|
+
aria-expanded={isOpen}
|
|
170
|
+
onClick={clickAction}
|
|
171
|
+
onKeyDown={hideOnEscape}
|
|
172
|
+
data-test-id={testId}
|
|
173
|
+
style={label !== null ? { width: 'max-content', height: theme.components.input.height } : undefined}
|
|
174
|
+
>
|
|
175
|
+
<Avatar {...props} />
|
|
176
|
+
</Button>
|
|
177
|
+
) : (
|
|
178
|
+
<Button
|
|
179
|
+
variant='link'
|
|
180
|
+
aria-haspopup
|
|
181
|
+
aria-expanded={isOpen}
|
|
182
|
+
onClick={clickAction}
|
|
183
|
+
onKeyDown={hideOnEscape}
|
|
184
|
+
data-test-id={testId}
|
|
185
|
+
style={label !== null ? { width: 'max-content', height: theme.components.input.height } : undefined}
|
|
186
|
+
>
|
|
187
|
+
{name}
|
|
188
|
+
</Button>
|
|
189
|
+
)}
|
|
190
|
+
|
|
191
|
+
{isOpen && (
|
|
192
|
+
<Popover
|
|
193
|
+
ref={setPopoverEl}
|
|
194
|
+
groupId='operator'
|
|
195
|
+
target={pTarget}
|
|
196
|
+
placement='bottom-start'
|
|
197
|
+
style={isLoading ? { position: 'relative', width: '10rem', minHeight: '4rem' } : undefined}
|
|
198
|
+
strategy='fixed'
|
|
199
|
+
>
|
|
200
|
+
{popoverContent}
|
|
201
|
+
</Popover>
|
|
202
|
+
)}
|
|
203
|
+
</Fragment>
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
if (label !== null) {
|
|
207
|
+
return (
|
|
208
|
+
<FormField label={label} info={helperText}>
|
|
209
|
+
{comp}
|
|
210
|
+
</FormField>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return comp;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
export default withConfiguration(Operator);
|