@pega/custom-dx-components 8.8.16 → 8.8.18

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 (246) hide show
  1. package/.prettierrc.json +7 -1
  2. package/babel.config.cjs +13 -0
  3. package/jest.config.cjs +37 -0
  4. package/package.json +12 -4
  5. package/src/auth.js +9 -3
  6. package/src/cli.js +12 -0
  7. package/src/constants.js +9 -4
  8. package/src/currentPath.cjs +1 -0
  9. package/src/tasks/authenticate/index.js +43 -40
  10. package/src/tasks/build/helper.js +18 -31
  11. package/src/tasks/build/index.js +26 -6
  12. package/src/tasks/build-all/index.js +15 -3
  13. package/src/tasks/bundle/builder/index.js +5 -0
  14. package/src/tasks/bundle/builder/webpack.config.js +1 -3
  15. package/src/tasks/create/index.js +17 -7
  16. package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +13 -6
  17. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +7 -7
  18. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +8 -8
  19. package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +13 -6
  20. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +10 -10
  21. package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +6 -5
  22. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +6 -3
  23. package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +13 -6
  24. package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +13 -6
  25. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +13 -6
  26. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +13 -6
  27. package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +13 -6
  28. package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +13 -6
  29. package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +13 -6
  30. package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +13 -6
  31. package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +13 -6
  32. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +13 -6
  33. package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +13 -6
  34. package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +13 -6
  35. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/styles.js.mustache +13 -6
  36. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/time-of-day.js.mustache +6 -5
  37. package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +13 -6
  38. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +13 -6
  39. package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +13 -6
  40. package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +13 -6
  41. package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +13 -6
  42. package/src/tasks/create/templates/Constellation/Widget/CASE/styles.js.mustache +13 -6
  43. package/src/tasks/create/templates/Constellation/Widget/PAGE/styles.js.mustache +13 -6
  44. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +13 -6
  45. package/src/tasks/create-all/index.js +109 -150
  46. package/src/tasks/delete/helper.js +87 -53
  47. package/src/tasks/delete/index.js +8 -15
  48. package/src/tasks/delete-all/helper.js +132 -85
  49. package/src/tasks/delete-all/index.js +8 -15
  50. package/src/tasks/index.js +2 -0
  51. package/src/tasks/init/index.js +20 -22
  52. package/src/tasks/init/template/babel.config.cjs +13 -0
  53. package/src/tasks/init/template/jest.config.cjs +21 -0
  54. package/src/tasks/init/template/package.json.mustache +6 -4
  55. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/config.json +55 -0
  56. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/demo.stories.jsx +51 -0
  57. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/index.jsx +60 -0
  58. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/mock.stories.js +13 -0
  59. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/styles.js +14 -0
  60. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/Boolean.js +38 -0
  61. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/boolean-format.js +26 -0
  62. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/config.json +145 -0
  63. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/demo.stories.jsx +61 -0
  64. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/event-utils.js +18 -0
  65. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/index.jsx +170 -0
  66. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/mock.stories.js +21 -0
  67. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/styles.js +14 -0
  68. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/OneColumnPage.svg +36 -0
  69. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/config.json +23 -0
  70. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/demo.stories.jsx +78 -0
  71. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/index.jsx +73 -0
  72. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/mock.stories.js +390 -0
  73. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/styles.js +14 -0
  74. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/config.json +291 -0
  75. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/demo.stories.jsx +53 -0
  76. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/event-utils.js +18 -0
  77. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/index.jsx +296 -0
  78. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/mock.stories.js +23 -0
  79. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/styles.js +14 -0
  80. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/suggestions-handler.js +10 -0
  81. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/DateFormatter.js +61 -0
  82. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/FormattedText.jsx +41 -0
  83. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/config.json +195 -0
  84. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/date.js +439 -0
  85. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/demo.stories.jsx +73 -0
  86. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/index.jsx +256 -0
  87. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/mock.stories.js +23 -0
  88. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/styles.js +14 -0
  89. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/suggestions-handler.js +10 -0
  90. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/config.json +256 -0
  91. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/date-time.js +92 -0
  92. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/date-utils.js +288 -0
  93. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/date.js +331 -0
  94. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/demo.stories.jsx +73 -0
  95. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/index.jsx +254 -0
  96. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/mock.stories.js +23 -0
  97. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/styles.js +14 -0
  98. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/suggestions-handler.js +10 -0
  99. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/config.json +278 -0
  100. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/demo.stories.jsx +49 -0
  101. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/event-utils.js +18 -0
  102. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/index.jsx +270 -0
  103. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/mock.stories.js +21 -0
  104. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/styles.js +14 -0
  105. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/suggestions-handler.js +10 -0
  106. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/OneColumnDetails.svg +22 -0
  107. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/StatusWork.jsx +26 -0
  108. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/config.json +35 -0
  109. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/demo.stories.jsx +132 -0
  110. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/index.jsx +83 -0
  111. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/mock.stories.js +189 -0
  112. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/styles.js +14 -0
  113. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/utils.js +152 -0
  114. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/config.json +111 -0
  115. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/demo.stories.jsx +48 -0
  116. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/event-utils.js +18 -0
  117. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/index.jsx +231 -0
  118. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/mock.stories.js +22 -0
  119. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/styles.js +14 -0
  120. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/suggestions-handler.js +10 -0
  121. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/DefaultForm.svg +29 -0
  122. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/config.json +45 -0
  123. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/demo.stories.jsx +166 -0
  124. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/index.jsx +42 -0
  125. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/mock.stories.js +137 -0
  126. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/styles.js +14 -0
  127. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/config.json +344 -0
  128. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/demo.stories.jsx +49 -0
  129. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/event-utils.js +18 -0
  130. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/index.jsx +333 -0
  131. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/mock.stories.js +21 -0
  132. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/styles.js +14 -0
  133. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/suggestions-handler.js +10 -0
  134. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/GetNextWork.jsx +35 -0
  135. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/OneColumnPage.svg +36 -0
  136. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/config.json +32 -0
  137. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/demo.stories.jsx +102 -0
  138. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/index.jsx +70 -0
  139. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/localizations.json +4 -0
  140. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/mock.stories.js +94 -0
  141. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/styles.js +14 -0
  142. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/utils.js +229 -0
  143. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/Avatar.jsx +75 -0
  144. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/OneColumnPage.svg +36 -0
  145. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/Operator.jsx +237 -0
  146. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/config.json +66 -0
  147. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/demo.stories.jsx +68 -0
  148. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/index.jsx +108 -0
  149. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/mock.stories.js +51 -0
  150. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/styles.js +14 -0
  151. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/OneColumnPage.svg +36 -0
  152. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/config.json +59 -0
  153. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/demo.stories.jsx +30 -0
  154. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/index.jsx +48 -0
  155. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/mock.stories.js +23 -0
  156. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/styles.js +14 -0
  157. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/config.json +111 -0
  158. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/demo.stories.jsx +48 -0
  159. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/event-utils.js +18 -0
  160. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/index.jsx +231 -0
  161. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/mock.stories.js +20 -0
  162. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/styles.js +14 -0
  163. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/suggestions-handler.js +10 -0
  164. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/config.json +93 -0
  165. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/demo.stories.jsx +49 -0
  166. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/event-utils.js +18 -0
  167. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/index.jsx +275 -0
  168. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/mock.stories.js +21 -0
  169. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/styles.js +14 -0
  170. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/suggestions-handler.js +10 -0
  171. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/config.json +123 -0
  172. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/demo.stories.jsx +46 -0
  173. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/event-utils.js +18 -0
  174. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/index.jsx +266 -0
  175. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/mock.stories.js +37 -0
  176. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/styles.js +14 -0
  177. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/suggestions-handler.js +10 -0
  178. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/config.json +114 -0
  179. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/demo.stories.jsx +78 -0
  180. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/event-utils.js +18 -0
  181. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/index.jsx +351 -0
  182. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/mock.stories.js +67 -0
  183. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/styles.js +14 -0
  184. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/suggestions-handler.js +10 -0
  185. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/config.json +55 -0
  186. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/demo.stories.jsx +51 -0
  187. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/index.jsx +60 -0
  188. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/mock.stories.js +13 -0
  189. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/styles.js +14 -0
  190. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/StatusWork.jsx +26 -0
  191. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/config.json +111 -0
  192. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/demo.stories.jsx +48 -0
  193. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/event-utils.js +18 -0
  194. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/index.jsx +239 -0
  195. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/mock.stories.js +21 -0
  196. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/styles.js +14 -0
  197. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/suggestions-handler.js +10 -0
  198. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/config.json +185 -0
  199. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/demo.stories.jsx +57 -0
  200. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/index.jsx +213 -0
  201. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/mock.stories.js +20 -0
  202. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/styles.js +14 -0
  203. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/suggestions-handler.js +10 -0
  204. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/time-of-day.js +288 -0
  205. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/StatusWork.jsx +26 -0
  206. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/TwoColumnDetails.svg +28 -0
  207. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/config.json +42 -0
  208. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/demo.stories.jsx +136 -0
  209. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/index.jsx +83 -0
  210. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/mock.stories.js +230 -0
  211. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/styles.js +14 -0
  212. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/utils.js +155 -0
  213. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/TwoColumn.svg +38 -0
  214. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/config.json +27 -0
  215. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/demo.stories.jsx +175 -0
  216. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/index.jsx +45 -0
  217. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/mock.stories.js +143 -0
  218. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/styles.js +14 -0
  219. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/config.json +237 -0
  220. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/demo.stories.jsx +46 -0
  221. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/event-utils.js +18 -0
  222. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/index.jsx +232 -0
  223. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/mock.stories.js +22 -0
  224. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/styles.js +14 -0
  225. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/suggestions-handler.js +10 -0
  226. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/text-url.jsx +173 -0
  227. package/src/tasks/init/template/test/functionTest/localCreateAllListDeleteAll.test.js +157 -0
  228. package/src/tasks/init/template/test/functionTest/localCreateBuildAllDeleteAll.test.js +148 -0
  229. package/src/tasks/init/template/test/functionTest/localCreateBuildDelete.test.js +84 -0
  230. package/src/tasks/init/template/test/functionTest/localCreateListDelete.test.js +108 -0
  231. package/src/tasks/init/template/test/functionTest/localCreatePublishAllDeleteAll.test.js +148 -0
  232. package/src/tasks/init/template/test/functionTest/localCreatePublishDelete.test.js +84 -0
  233. package/src/tasks/init/template/test/functionTest/localCreateRenameDelete.test.js +84 -0
  234. package/src/tasks/init/template/test/functionTest/localPromoteRevertWP.test.js +59 -0
  235. package/src/tasks/list/helper.js +129 -61
  236. package/src/tasks/list/index.js +3 -4
  237. package/src/tasks/promote-webpack/index.js +126 -0
  238. package/src/tasks/promote-webpack/webpack.config.js +376 -0
  239. package/src/tasks/publish/helper.js +69 -80
  240. package/src/tasks/publish/index.js +29 -12
  241. package/src/tasks/publish-all/helper.js +66 -83
  242. package/src/tasks/publish-all/index.js +30 -18
  243. package/src/tasks/rename/index.js +127 -97
  244. package/src/tasks/revert-webpack/index.js +71 -0
  245. package/src/util.js +205 -108
  246. package/test/unitTest/util.test.js +544 -0
@@ -0,0 +1,94 @@
1
+ export const pyHome1Raw = {
2
+ name: 'pyHome1',
3
+ type: 'View',
4
+ config: {
5
+ type: 'landingpage',
6
+ template: 'OneColumnPage',
7
+ icon: 'home-solid',
8
+ title: '@ENV APPLICATION_DESC',
9
+ ruleClass: 'DIXL-MediaCo-UIPages',
10
+ localeReference: '@LR DIXL-MEDIACO-UIPAGES!PAGE!PYHOME1',
11
+ enableGetNextWork: true,
12
+ context: 'pyPortal'
13
+ },
14
+ children: [
15
+ {
16
+ name: 'A',
17
+ type: 'Region',
18
+ children: [
19
+ {
20
+ type: 'AppAnnouncement',
21
+ config: {
22
+ label: '@L App announcement',
23
+ description:
24
+ "We've launched a brand new experience to accelerate your workflow. Check out the guides to help you get the most of Cosmos.",
25
+ whatsnewlink: 'https://design.pega.com',
26
+ image:
27
+ 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOSAxMSI+PHRpdGxlPlBlZ2EgdGV4dC1vbmx5IGxvZ288L3RpdGxlPjxwYXRoIHN0eWxlPSJmaWxsLW9wYWNpdHk6IC4yNTsiIGZpbGw9IiNmZmYiIGQ9Ik03LjcyIDMuODJjMCAyLjI1LTEuNzggMy40MS00IDMuNDFoLTEuNnYzSDBWLjQyaDMuOTRjMi4zNiAwIDMuNzggMS4zOSAzLjc4IDMuNHptLTQtMS40N2gtMS42djNoMS43QTEuNDcgMS40NyAwIDAgMCA1LjUgMy44MmMwLS45MS0uNjUtMS40Ny0xLjc1LTEuNDd6bTcuNjggNS45MWg1LjN2Mkg5LjI5Vi40Mmg3LjM4djEuOTNoLTUuMjR2Mmg0LjI0djEuOWgtNC4yNHpNMjMuMTggMGE1IDUgMCAwIDEgMy41NyAxLjI4TDI1LjYzIDIuOGEzLjc4IDMuNzggMCAwIDAtMS4wNS0uNjNBNC4zMiA0LjMyIDAgMCAwIDIzLjMxIDIgMy4xNyAzLjE3IDAgMCAwIDIwIDUuMjdhMy4xNiAzLjE2IDAgMCAwIDEgMi4zOSAzLjA3IDMuMDcgMCAwIDAgMi4xNy44NCA0LjYgNC42IDAgMCAwIDIuMDktLjVWNi4xOWgtMi4yVjQuMzhoNC4yNXY0LjU2YTUuNDEgNS40MSAwIDAgMS00LjA4IDEuNTdBNS4zNSA1LjM1IDAgMCAxIDE5LjQzIDlhNS4wNSA1LjA1IDAgMCAxLTEuNTYtMy43NCA1LjIxIDUuMjEgMCAwIDEgMS41Ni0zLjc2QTUuMzEgNS4zMSAwIDAgMSAyMy4xOCAwem0xMS4yOS40Mmw0LjEzIDkuNzloLTIuMjVMMzUuNDggOGgtNC4wNmwtLjkgMi4xOGgtMi4yTDMyLjUxLjQyem0uMjUgNS43MkwzMy40NCAzbC0xLjI5IDMuMTR6bTMtNWEuNzEuNzEgMCAwIDEtLjc0Ljc1LjcxLjcxIDAgMCAxLS43My0uNzUuNzMuNzMgMCAwIDEgLjc1LS43Mi43Mi43MiAwIDAgMSAuNzUuNzF6TTM3IC41M2EuNTkuNTkgMCAwIDAtLjYuNi42MS42MSAwIDEgMCAxLjIxIDAgLjYuNiAwIDAgMC0uNjEtLjZ6bS0uMjQgMVYuNzFIMzdjLjEyIDAgLjE4LjA2LjI1LjA2YS4yMS4yMSAwIDAgMSAuMDcuMTguMTkuMTkgMCAwIDEtLjA3LjE4cy0uMDcuMDgtLjEzLjA4bC4yNi4zNmgtLjJMMzcgMS4yOGgtLjF2LjI5em0uMTMtLjQ0aC4yM2EuMjYuMjYgMCAwIDAgLjA3LS4wOWgtLjA2Yy0uMDUtLjE3LS4wNS0uMTctLjEzLS4xN2gtLjF6Ii8+PC9zdmc+',
28
+ datasource: {
29
+ source: '@DATASOURCE D_pyAnnouncements.pxResults',
30
+ fields: {
31
+ name: '@P .pyLabel'
32
+ }
33
+ }
34
+ }
35
+ }
36
+ ]
37
+ }
38
+ ],
39
+ classID: 'DIXL-MediaCo-UIPages'
40
+ };
41
+
42
+ export const pyHome1Resolved = {
43
+ name: 'pyHome1',
44
+ type: 'View',
45
+ config: {
46
+ type: 'landingpage',
47
+ template: 'OneColumnPage',
48
+ icon: 'home-solid',
49
+ title: '@ENV APPLICATION_DESC',
50
+ ruleClass: 'DIXL-MediaCo-UIPages',
51
+ localeReference: '@LR DIXL-MEDIACO-UIPAGES!PAGE!PYHOME1',
52
+ enableGetNextWork: true,
53
+ context: 'pyPortal'
54
+ },
55
+ children: [
56
+ {
57
+ name: 'A',
58
+ type: 'Region',
59
+ getPConnect: () => {
60
+ return {
61
+ getComponentName: () => {
62
+ return '';
63
+ },
64
+ getComponent: () => {
65
+ return pyHome1Resolved.children[0];
66
+ },
67
+ getConfigProps: () => {
68
+ return {};
69
+ }
70
+ };
71
+ },
72
+ children: [
73
+ {
74
+ type: 'AppAnnouncement',
75
+ config: {
76
+ label: '@L App announcement',
77
+ description:
78
+ "We've launched a brand new experience to accelerate your workflow. Check out the guides to help you get the most of Cosmos.",
79
+ whatsnewlink: 'https://design.pega.com',
80
+ image:
81
+ 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOSAxMSI+PHRpdGxlPlBlZ2EgdGV4dC1vbmx5IGxvZ288L3RpdGxlPjxwYXRoIHN0eWxlPSJmaWxsLW9wYWNpdHk6IC4yNTsiIGZpbGw9IiNmZmYiIGQ9Ik03LjcyIDMuODJjMCAyLjI1LTEuNzggMy40MS00IDMuNDFoLTEuNnYzSDBWLjQyaDMuOTRjMi4zNiAwIDMuNzggMS4zOSAzLjc4IDMuNHptLTQtMS40N2gtMS42djNoMS43QTEuNDcgMS40NyAwIDAgMCA1LjUgMy44MmMwLS45MS0uNjUtMS40Ny0xLjc1LTEuNDd6bTcuNjggNS45MWg1LjN2Mkg5LjI5Vi40Mmg3LjM4djEuOTNoLTUuMjR2Mmg0LjI0djEuOWgtNC4yNHpNMjMuMTggMGE1IDUgMCAwIDEgMy41NyAxLjI4TDI1LjYzIDIuOGEzLjc4IDMuNzggMCAwIDAtMS4wNS0uNjNBNC4zMiA0LjMyIDAgMCAwIDIzLjMxIDIgMy4xNyAzLjE3IDAgMCAwIDIwIDUuMjdhMy4xNiAzLjE2IDAgMCAwIDEgMi4zOSAzLjA3IDMuMDcgMCAwIDAgMi4xNy44NCA0LjYgNC42IDAgMCAwIDIuMDktLjVWNi4xOWgtMi4yVjQuMzhoNC4yNXY0LjU2YTUuNDEgNS40MSAwIDAgMS00LjA4IDEuNTdBNS4zNSA1LjM1IDAgMCAxIDE5LjQzIDlhNS4wNSA1LjA1IDAgMCAxLTEuNTYtMy43NCA1LjIxIDUuMjEgMCAwIDEgMS41Ni0zLjc2QTUuMzEgNS4zMSAwIDAgMSAyMy4xOCAwem0xMS4yOS40Mmw0LjEzIDkuNzloLTIuMjVMMzUuNDggOGgtNC4wNmwtLjkgMi4xOGgtMi4yTDMyLjUxLjQyem0uMjUgNS43MkwzMy40NCAzbC0xLjI5IDMuMTR6bTMtNWEuNzEuNzEgMCAwIDEtLjc0Ljc1LjcxLjcxIDAgMCAxLS43My0uNzUuNzMuNzMgMCAwIDEgLjc1LS43Mi43Mi43MiAwIDAgMSAuNzUuNzF6TTM3IC41M2EuNTkuNTkgMCAwIDAtLjYuNi42MS42MSAwIDEgMCAxLjIxIDAgLjYuNiAwIDAgMC0uNjEtLjZ6bS0uMjQgMVYuNzFIMzdjLjEyIDAgLjE4LjA2LjI1LjA2YS4yMS4yMSAwIDAgMSAuMDcuMTguMTkuMTkgMCAwIDEtLjA3LjE4cy0uMDcuMDgtLjEzLjA4bC4yNi4zNmgtLjJMMzcgMS4yOGgtLjF2LjI5em0uMTMtLjQ0aC4yM2EuMjYuMjYgMCAwIDAgLjA3LS4wOWgtLjA2Yy0uMDUtLjE3LS4wNS0uMTctLjEzLS4xN2gtLjF6Ii8+PC9zdmc+',
82
+ datasource: {
83
+ source: '@DATASOURCE D_pyAnnouncements.pxResults',
84
+ fields: {
85
+ name: '@P .pyLabel'
86
+ }
87
+ }
88
+ }
89
+ }
90
+ ]
91
+ }
92
+ ],
93
+ classID: 'DIXL-MediaCo-UIPages'
94
+ };
@@ -0,0 +1,14 @@
1
+ // utilizing theming, comment out, if want individual style
2
+ import styled from 'styled-components';
3
+ import { Configuration } from '@pega/cosmos-react-core';
4
+
5
+ export default styled(Configuration)``;
6
+
7
+ // individual style, comment out above, and uncomment here and add styles
8
+ // import styled, { css } from 'styled-components';
9
+ //
10
+ // export default styled.div(() => {
11
+ // return css`
12
+ // margin: 0px 0;
13
+ // `;
14
+ // });
@@ -0,0 +1,229 @@
1
+ /* eslint-disable no-undef */
2
+ import { createUID } from '@pega/cosmos-react-core';
3
+
4
+ // import { LazyMap as LazyComponentMap } from '../../components_map';
5
+
6
+ const LazyComponentMap = {};
7
+
8
+ /**
9
+ * Given the PConnect object of a Template component, retrieve the children
10
+ * metadata of all regions.
11
+ * @param {Function} pConnect PConnect of a Template component.
12
+ */
13
+ export function getAllFields(pConnect) {
14
+ const metadata = pConnect().getRawMetadata();
15
+ if (!metadata.children) {
16
+ return [];
17
+ }
18
+
19
+ let allFields = [];
20
+
21
+ const makeField = (f) => ({
22
+ ...pConnect().resolveConfigProps(f.config),
23
+ type: f.type
24
+ });
25
+
26
+ const hasRegions = !!metadata.children[0]?.children;
27
+ if (hasRegions) {
28
+ allFields = metadata.children.map((region) =>
29
+ region.children.map((field) => {
30
+ // Do not resolve the config props if is status work, instead create component here as status badge and mark as status display
31
+ if (field.config?.value === '@P .pyStatusWork') {
32
+ field.type = 'TextInput';
33
+ field.config.displayAsStatus = true;
34
+ return pConnect().createComponent(field);
35
+ }
36
+
37
+ return makeField(field);
38
+ })
39
+ );
40
+ } else {
41
+ allFields = metadata.children.map(makeField);
42
+ }
43
+
44
+ return allFields;
45
+ }
46
+
47
+ /**
48
+ * A helper function to create an object consisting react component as per the type.
49
+ * This is used by CaseSummary template.
50
+ * @param {object} configObject Object containing meta information for the particular field authored
51
+ * @param {Function} getPConnect PConnect function passed along to other components.
52
+ * @param {string} displayMode displayMode string contains information about the layout of component in review mode.
53
+ */
54
+ export function prepareComponentInCaseSummary(configObject, getPConnect, displayMode) {
55
+ const { config, children } = configObject;
56
+ let { type } = configObject;
57
+ const caseSummaryComponentObject = {};
58
+ let showAddressLabel = true;
59
+ if (config && config.value === '@P .pyStatusWork') {
60
+ config.displayAsStatus = true;
61
+ type = 'TextInput'; // force the type to be TextInput for status field.
62
+ // As TextInput is loaded forcefully sometimes, TextInput component might not be available in lazy map.
63
+ // Load TextInput if it is not available.
64
+ if (!LazyComponentMap[type]) {
65
+ PCore.getAssetLoader().getLoader('component-loader')([type]);
66
+ }
67
+ }
68
+
69
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
70
+ label: config.label
71
+ }).label;
72
+ if (type === 'CaseOperator') {
73
+ switch (caseSummaryComponentObject.name) {
74
+ case 'Create operator':
75
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
76
+ createLabel: config.createLabel
77
+ }).createLabel;
78
+ break;
79
+ case 'Update operator':
80
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
81
+ updateLabel: config.updateLabel
82
+ }).updateLabel;
83
+ break;
84
+ default:
85
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
86
+ resolveLabel: config.resolveLabel
87
+ }).resolveLabel;
88
+ break;
89
+ }
90
+ } else if (type === 'Checkbox') {
91
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
92
+ label: config.caption
93
+ }).label;
94
+ } else if (type === 'Address') {
95
+ showAddressLabel = false;
96
+ }
97
+ const createdComponent = getPConnect().createComponent({
98
+ type,
99
+ children: children ? [...children] : [],
100
+ showAddressLabel,
101
+ config: {
102
+ ...config,
103
+ hideLabel: true,
104
+ key: createUID() // Need a unique key on render of the summary so that the component is recreated each time
105
+ }
106
+ });
107
+ createdComponent.props.getPConnect().setInheritedProp('displayMode', displayMode);
108
+ if (type === 'Address') {
109
+ createdComponent.props.getPConnect().setInheritedProp('showAddressLabel', showAddressLabel);
110
+ }
111
+ // createdComponent.props.getPConnect().setInheritedProp("hideLabel", true);
112
+ caseSummaryComponentObject.value = createdComponent;
113
+ if (type === 'reference') {
114
+ caseSummaryComponentObject.name = createdComponent.props.getPConnect().getInheritedProps().label;
115
+ }
116
+
117
+ return caseSummaryComponentObject;
118
+ }
119
+
120
+ export function getFilteredFields(getPConnect) {
121
+ let primaryFieldsRaw;
122
+ let secondaryFieldsRaw;
123
+ const metadata = getPConnect().getRawMetadata();
124
+ const hasRegions = !!metadata.children[0]?.children;
125
+ if (hasRegions) {
126
+ primaryFieldsRaw = metadata.children[0].children;
127
+ secondaryFieldsRaw = metadata.children[1].children;
128
+ } else {
129
+ [primaryFieldsRaw, secondaryFieldsRaw] = metadata.children;
130
+ }
131
+
132
+ // Filter out fields that are not visible and unsupported types for primary fields (for CaseSummary)
133
+ primaryFieldsRaw = primaryFieldsRaw.filter((item) => {
134
+ const resolvedItem = getPConnect().resolveConfigProps(item.config);
135
+ return resolvedItem.visibility !== false && item.type !== 'TextContent';
136
+ });
137
+
138
+ secondaryFieldsRaw = secondaryFieldsRaw.filter((item) => {
139
+ const resolvedItem = getPConnect().resolveConfigProps(item.config);
140
+ return resolvedItem.visibility !== false && item.type !== 'TextContent';
141
+ });
142
+
143
+ return [primaryFieldsRaw, secondaryFieldsRaw];
144
+ }
145
+
146
+ /**
147
+ * Returns ConfigurableLayout mapped content. With pre-populated default layout configs.
148
+ * @param {object[]} regionData template children item.
149
+ * @returns {object[]} ConfigurableLayout content.
150
+ */
151
+ export function getLayoutDataFromRegion(regionData) {
152
+ const defaultLayoutConfig = {
153
+ width: 'full',
154
+ fillAvailable: true,
155
+ minWidth: [300, 'px']
156
+ };
157
+
158
+ return regionData.props
159
+ ?.getPConnect()
160
+ ?.getChildren()
161
+ ?.map((item, index) => {
162
+ const itemPConnect = item?.getPConnect();
163
+
164
+ return {
165
+ id: itemPConnect?.getComponentName() ? `${itemPConnect.getComponentName()}--${index}` : `item--${index}`,
166
+ content: itemPConnect?.getComponent(),
167
+ layoutConfig: {
168
+ ...defaultLayoutConfig,
169
+ ...itemPConnect?.getConfigProps().layoutConfig
170
+ }
171
+ };
172
+ });
173
+ }
174
+
175
+ /**
176
+ * Determine if the current view is the view of the case step/assignment.
177
+ * @param {Function} pConnect PConnect object for the component
178
+ */
179
+ export function getIsAssignmentView(pConnect) {
180
+ // Get caseInfo content from the store which contains the view info about the current assignment/step
181
+ // TODO To be replaced with pConnect.getCaseInfo().getCurrentAssignmentView when it's available
182
+ const assignmentViewClass = pConnect.getValue(PCore.getConstants().CASE_INFO.CASE_INFO_CLASSID);
183
+ const assignmentViewName = pConnect.getValue(PCore.getConstants().CASE_INFO.ASSIGNMENTACTION_ID);
184
+
185
+ const assignmentViewId = `${assignmentViewName}!${assignmentViewClass}`;
186
+
187
+ // Get the info about the current view from pConnect
188
+ const currentViewId = `${pConnect.getCurrentView()}!${pConnect.getCurrentClassID()}`;
189
+
190
+ return assignmentViewId === currentViewId;
191
+ }
192
+
193
+ /**
194
+ * A hook that gets the instructions content for a view.
195
+ * @param {Function} pConnect PConnect object for the component
196
+ * @param {string} [instructions="casestep"] 'casestep', 'none', or the html content of a Rule-UI-Paragraph rule (processed via core's paragraph annotation handler)
197
+ */
198
+ export function getInstructions(pConnect, instructions = 'casestep') {
199
+ const caseStepInstructions = pConnect.getValue(PCore.getConstants().CASE_INFO.INSTRUCTIONS);
200
+
201
+ // Determine if this view is the current assignment/step view
202
+ const isCurrentAssignmentView = getIsAssignmentView(pConnect);
203
+
204
+ // Case step instructions
205
+ if (instructions === 'casestep' && isCurrentAssignmentView && caseStepInstructions?.length) {
206
+ return caseStepInstructions;
207
+ }
208
+
209
+ // No instructions
210
+ if (instructions === 'none') {
211
+ return undefined;
212
+ }
213
+
214
+ // If the annotation wasn't processed correctly, don't return any instruction text
215
+ if (instructions?.startsWith('@PARAGRAPH')) {
216
+ /* eslint-disable no-console */
217
+ console.error('@PARAGRAPH annotation was not processed. Hiding custom instructions.');
218
+ /* eslint-enable no-console */
219
+ return undefined;
220
+ }
221
+
222
+ // Custom instructions from the view
223
+ // The raw metadata for `instructions` will be something like '@PARAGRAPH .SomeParagraphRule' but
224
+ // it is evaluated by core logic to the content
225
+ if (instructions !== 'casestep' && instructions !== 'none') {
226
+ return instructions;
227
+ }
228
+ return undefined;
229
+ }
@@ -0,0 +1,75 @@
1
+ /* eslint-disable no-undef */
2
+ /* eslint-disable react-hooks/rules-of-hooks */
3
+ import { useEffect, useState } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { Avatar as CosmosAvatar } from '@pega/cosmos-react-core';
6
+
7
+ function Avatar(props) {
8
+ const { metaObj, showStatus } = props;
9
+ const [imageBlobUrl, setImageBlobUrl] = useState(null);
10
+ let userName;
11
+ let userIdentifier;
12
+
13
+ // TODO Below if conditions can be removed once we have apis to get worklist/mywork info
14
+ // This is non CaseView case (Dashboard, MyWork etc)
15
+ if (!metaObj) {
16
+ userName = PCore.getEnvironmentInfo().getOperatorName();
17
+ userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
18
+ } else {
19
+ userName = metaObj.name;
20
+ userIdentifier = metaObj.ID;
21
+ }
22
+ if (!userName && userIdentifier) {
23
+ userName = userIdentifier;
24
+ }
25
+
26
+ useEffect(() => {
27
+ const imageKey = !metaObj ? PCore.getEnvironmentInfo().getOperatorImageInsKey() : metaObj.image;
28
+ if (imageKey) {
29
+ PCore.getAssetLoader()
30
+ .getSvcImage(imageKey)
31
+ .then((blob) => window.URL.createObjectURL(blob))
32
+ .then((imagePath) => setImageBlobUrl(imagePath));
33
+ }
34
+ }, []);
35
+
36
+ if (showStatus) {
37
+ const currentState = PCore.getMessagingServiceManager().getUserPresence().getUserState(userIdentifier);
38
+ const [userState, setUserState] = useState(currentState === 'online' ? 'active' : 'inactive');
39
+
40
+ const handleUserStateChange = ({ state }) => {
41
+ setUserState(state === 'online' ? 'active' : 'inactive');
42
+ };
43
+
44
+ useEffect(() => {
45
+ const subId = PCore.getMessagingServiceManager()
46
+ .getUserPresence()
47
+ .subscribe(userIdentifier, handleUserStateChange);
48
+
49
+ return function cleanup() {
50
+ PCore.getMessagingServiceManager().getUserPresence().unsubscribe(userIdentifier, subId);
51
+ };
52
+ }, []);
53
+ return <CosmosAvatar name={userName} imageSrc={imageBlobUrl} status={userState} />;
54
+ }
55
+
56
+ // Do not render when userName does not exists
57
+ // TODO : In CNR case, pxRequestor is not available, please remove this condition once it populates
58
+ if (!userName) {
59
+ return null;
60
+ }
61
+
62
+ return <CosmosAvatar name={userName} imageSrc={imageBlobUrl} />;
63
+ }
64
+
65
+ Avatar.propTypes = {
66
+ metaObj: PropTypes.objectOf(PropTypes.any),
67
+ showStatus: PropTypes.bool
68
+ };
69
+
70
+ Avatar.defaultProps = {
71
+ metaObj: null,
72
+ showStatus: false
73
+ };
74
+
75
+ export default Avatar;
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="100px" height="70px" viewBox="0 0 100 70" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>1 col </title>
4
+ <defs>
5
+ <rect id="path-1" x="0" y="0" width="100" height="70"></rect>
6
+ </defs>
7
+ <g id="Concepts" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
8
+ <g id="Templates" transform="translate(-98.000000, -108.000000)">
9
+ <g id="Change-template" transform="translate(42.000000, 36.000000)">
10
+ <g id="1-col-" transform="translate(56.000000, 72.000000)">
11
+ <mask id="mask-2" fill="white">
12
+ <use xlink:href="#path-1"></use>
13
+ </mask>
14
+ <rect stroke="#A5A8BC" stroke-width="0.5" x="0.25" y="0.25" width="99.5" height="69.5"></rect>
15
+ <g id="white" mask="url(#mask-2)" fill="#FFFFFF">
16
+ <g transform="translate(3.000000, 3.000000)" id="Rectangle">
17
+ <rect x="0" y="0" width="94" height="66.5"></rect>
18
+ </g>
19
+ </g>
20
+ <g id="gray" mask="url(#mask-2)" fill="#8084A7">
21
+ <g transform="translate(6.000000, 6.000000)" id="Rectangle">
22
+ <rect x="0" y="-2.84217094e-14" width="88" height="77.8"></rect>
23
+ </g>
24
+ </g>
25
+ <g id="labels" mask="url(#mask-2)" font-family="OpenSans-Semibold, Open Sans" font-size="11" font-weight="500">
26
+ <g transform="translate(44.000000, 17.000000)" id="A">
27
+ <text>
28
+ <tspan x="0.75" y="12" fill="#FFFFFF">A</tspan>
29
+ </text>
30
+ </g>
31
+ </g>
32
+ </g>
33
+ </g>
34
+ </g>
35
+ </g>
36
+ </svg>
@@ -0,0 +1,237 @@
1
+ /* eslint-disable no-undef */
2
+ import { useState, useEffect, Fragment } from 'react';
3
+ import {
4
+ Link,
5
+ Button,
6
+ Popover,
7
+ Flex,
8
+ useOuterEvent,
9
+ useElement,
10
+ Progress,
11
+ FormField,
12
+ useTheme
13
+ } from '@pega/cosmos-react-core';
14
+ import { Glimpse } from '@pega/cosmos-react-work';
15
+ import PropTypes from 'prop-types';
16
+
17
+ import Avatar from './Avatar.jsx';
18
+
19
+ const Operator = (props) => {
20
+ const { id, name, label, testId, helperText, externalUser, metaObj } = props;
21
+ const [isOpen, setIsOpen] = useState(false);
22
+ const [isLoading, setIsLoading] = useState(true);
23
+ const [popoverTarget, setPopoverTarget] = useState(null);
24
+ const [popoverEl, setPopoverEl] = useElement(null);
25
+ const [popoverContent, setpopoverContent] = useState(null);
26
+ const theme = useTheme();
27
+
28
+ /* If the id has changed, we need to reset the popover */
29
+ useEffect(() => {
30
+ setPopoverTarget(null);
31
+ }, [id]);
32
+
33
+
34
+
35
+ const OperatorPreview = () => {
36
+ const localizedVal = PCore.getLocaleUtils().getLocaleValue;
37
+ const localeCategory = 'Operator';
38
+ setpopoverContent(
39
+ <Progress variant='ring' message={localizedVal('Loading operator...', localeCategory)} placement='local' />
40
+ );
41
+ if (externalUser && externalUser.classID !== 'Data-Party-Operator') {
42
+ const fields = [
43
+ {
44
+ id: 'pyFirstName',
45
+ name: localizedVal('Name', localeCategory),
46
+ value: externalUser.name
47
+ },
48
+ {
49
+ id: 'pyEmail1',
50
+ name: localizedVal('Email', localeCategory),
51
+ value:
52
+ externalUser.email !== '' ? <Link href={`mailto:${externalUser.email}`}>{externalUser.email}</Link> : ''
53
+ },
54
+ {
55
+ id: 'pyPhoneNumber',
56
+ name: localizedVal('Phone', localeCategory),
57
+ value: externalUser.phone !== '' ? <Link href={`tel:${externalUser.phone}`}>{externalUser.phone}</Link> : ''
58
+ }
59
+ ];
60
+ setIsLoading(false);
61
+ setpopoverContent(
62
+ <Glimpse
63
+ visual={
64
+ <Avatar
65
+ metaObj={{
66
+ name: externalUser.name
67
+ }}
68
+ />
69
+ }
70
+ primary={externalUser.name}
71
+ secondary={[externalUser.position]}
72
+ fields={fields}
73
+ />
74
+ );
75
+ } else {
76
+ const { getOperatorDetails } = PCore.getUserApi();
77
+ getOperatorDetails(id)
78
+ .then((res) => {
79
+ if (res.data && res.data.pyOperatorInfo && res.data.pyOperatorInfo.pyUserName) {
80
+ const fields = [
81
+ {
82
+ id: 'pyOrganization',
83
+ name: localizedVal('Organization', localeCategory),
84
+ value: res.data.pyOperatorInfo.pyOrganization
85
+ },
86
+ {
87
+ id: 'pyTelephone',
88
+ name: localizedVal('Telephone', localeCategory),
89
+ value:
90
+ res.data.pyOperatorInfo.pyTelephone !== '' ? (
91
+ <Link href={`tel:${res.data.pyOperatorInfo.pyTelephone}`}>
92
+ {res.data.pyOperatorInfo.pyTelephone}
93
+ </Link>
94
+ ) : (
95
+ ''
96
+ )
97
+ },
98
+ {
99
+ id: 'pyEmailAddress',
100
+ name: localizedVal('Email address', localeCategory),
101
+ value:
102
+ res.data.pyOperatorInfo.pyEmailAddress !== '' ? (
103
+ <Link href={`mailto:${res.data.pyOperatorInfo.pyEmailAddress}`}>
104
+ {res.data.pyOperatorInfo.pyEmailAddress}
105
+ </Link>
106
+ ) : (
107
+ ''
108
+ )
109
+ },
110
+ {
111
+ id: 'ReportToUserName',
112
+ name: localizedVal('Reports to', localeCategory),
113
+ value: res.data.pyOperatorInfo.pyReportToUserName
114
+ }
115
+ ];
116
+ setIsLoading(false);
117
+ setpopoverContent(
118
+ <Glimpse
119
+ visual={
120
+ <Avatar
121
+ metaObj={{
122
+ image: res.data.pyOperatorInfo.pyImageInsKey || '',
123
+ name: res.data.pyOperatorInfo.pyUserName
124
+ }}
125
+ />
126
+ }
127
+ primary={res.data.pyOperatorInfo.pyUserName}
128
+ secondary={[res.data.pyOperatorInfo.pyPosition]}
129
+ fields={fields}
130
+ />
131
+ );
132
+ } else {
133
+ setIsLoading(false);
134
+ setpopoverContent(<Flex container={{ pad: 1 }}>{localizedVal('Operator not found', localeCategory)}</Flex>);
135
+ }
136
+ })
137
+ .catch(() => {
138
+ setIsLoading(false);
139
+ setpopoverContent(
140
+ <Flex container={{ pad: 1 }}>{localizedVal('Error loading the operator profile', localeCategory)}</Flex>
141
+ );
142
+ });
143
+ }
144
+ };
145
+
146
+
147
+ const clickAction = (e) => {
148
+ setPopoverTarget(e.currentTarget);
149
+ setIsOpen(!isOpen);
150
+ if (popoverTarget === null) {
151
+ OperatorPreview();
152
+ }
153
+ };
154
+
155
+ const hidePopover = () => {
156
+ if (isOpen) {
157
+ setIsOpen(false);
158
+ }
159
+ };
160
+ useOuterEvent('mousedown', [popoverEl, popoverTarget], hidePopover); // Call the method on clicking outside these elements
161
+ const hideOnEscape = (e) => {
162
+ if (e.key === 'Escape') hidePopover(); // Call the method when Escape key is pressed
163
+ };
164
+
165
+ const comp = (
166
+ <Fragment>
167
+ {metaObj ? (
168
+ <Button
169
+ variant='text'
170
+ aria-haspopup
171
+ aria-expanded={isOpen}
172
+ onClick={clickAction}
173
+ onKeyDown={hideOnEscape}
174
+ data-test-id={testId}
175
+ style={label !== null ? { width: 'max-content', height: theme.components.input.height } : undefined}
176
+ >
177
+ <Avatar metaObj={metaObj}></Avatar>
178
+ </Button>
179
+ ) : (
180
+ <Button
181
+ variant='link'
182
+ aria-haspopup
183
+ aria-expanded={isOpen}
184
+ onClick={clickAction}
185
+ onKeyDown={hideOnEscape}
186
+ data-test-id={testId}
187
+ style={label !== null ? { width: 'max-content', height: theme.components.input.height } : undefined}
188
+ >
189
+ {name}
190
+ </Button>
191
+ )}
192
+
193
+ {isOpen && (
194
+ <Popover
195
+ ref={setPopoverEl}
196
+ groupId='operator'
197
+ target={popoverTarget}
198
+ placement='bottom-start'
199
+ style={isLoading ? { position: 'relative', width: '10rem', minHeight: '4rem' } : undefined}
200
+ strategy='fixed'
201
+ >
202
+ {popoverContent}
203
+ </Popover>
204
+ )}
205
+ </Fragment>
206
+ );
207
+
208
+ if (label !== null) {
209
+ return (
210
+ <FormField label={label} info={helperText}>
211
+ {comp}
212
+ </FormField>
213
+ );
214
+ }
215
+
216
+ return comp;
217
+ };
218
+
219
+ Operator.propTypes = {
220
+ name: PropTypes.string,
221
+ id: PropTypes.string,
222
+ label: PropTypes.string,
223
+ testId: PropTypes.string,
224
+ helperText: PropTypes.string,
225
+ metaObj: PropTypes.object
226
+ };
227
+
228
+ Operator.defaultProps = {
229
+ name: '',
230
+ id: '',
231
+ label: null,
232
+ testId: null,
233
+ helperText: null,
234
+ metaObj: null
235
+ };
236
+
237
+ export default Operator;