@pega/custom-dx-components 0.0.1 → 0.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/.vscode/extensions.json +1 -1
  2. package/README.md +6 -189
  3. package/package.json +34 -32
  4. package/src/auth.js +608 -0
  5. package/src/cli.js +42 -0
  6. package/src/constants.js +125 -8
  7. package/src/tasks/authenticate/helper.js +91 -8
  8. package/src/tasks/authenticate/index.js +169 -49
  9. package/src/tasks/build/helper.js +122 -0
  10. package/src/tasks/build/index.js +54 -0
  11. package/src/tasks/build-all/helper.js +70 -0
  12. package/src/tasks/build-all/index.js +79 -0
  13. package/src/tasks/{publish/bundle → bundle}/builder/index.js +49 -5
  14. package/src/tasks/{publish/bundle → bundle}/builder/webpack.config.js +5 -3
  15. package/src/tasks/{publish/bundle → bundle}/index.js +2 -2
  16. package/src/tasks/create/index.js +87 -64
  17. package/src/tasks/create/templates/Constellation/Field/Boolean/Boolean.js.mustache +38 -0
  18. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +26 -0
  19. package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +146 -0
  20. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +61 -0
  21. package/src/tasks/create/templates/Constellation/Field/Boolean/event-utils.js.mustache +18 -0
  22. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +170 -0
  23. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
  24. package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +7 -0
  25. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
  26. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
  27. package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +196 -0
  28. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +439 -0
  29. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +73 -0
  30. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +256 -0
  31. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
  32. package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +7 -0
  33. package/src/tasks/create/templates/Constellation/Field/Date/suggestions-handler.js +10 -0
  34. package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +257 -0
  35. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +92 -0
  36. package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +287 -0
  37. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +328 -0
  38. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +73 -0
  39. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +254 -0
  40. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
  41. package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +7 -0
  42. package/src/tasks/create/templates/Constellation/Field/DateTime/suggestions-handler.js +10 -0
  43. package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +279 -0
  44. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +49 -0
  45. package/src/tasks/create/templates/Constellation/Field/Decimal/event-utils.js.mustache +18 -0
  46. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +273 -0
  47. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
  48. package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +7 -0
  49. package/src/tasks/create/templates/Constellation/Field/Decimal/suggestions-handler.js +10 -0
  50. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +292 -0
  51. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +53 -0
  52. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/event-utils.js.mustache +18 -0
  53. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +299 -0
  54. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
  55. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +7 -0
  56. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/suggestions-handler.js +10 -0
  57. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +94 -0
  58. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +49 -0
  59. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/event-utils.js.mustache +18 -0
  60. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +281 -0
  61. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
  62. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +7 -0
  63. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/suggestions-handler.js +10 -0
  64. package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +348 -0
  65. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +49 -0
  66. package/src/tasks/create/templates/Constellation/Field/Integer/event-utils.js.mustache +18 -0
  67. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +336 -0
  68. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
  69. package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +7 -0
  70. package/src/tasks/create/templates/Constellation/Field/Integer/suggestions-handler.js +10 -0
  71. package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +115 -0
  72. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +78 -0
  73. package/src/tasks/create/templates/Constellation/Field/Picklist/event-utils.js.mustache +18 -0
  74. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +351 -0
  75. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
  76. package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +7 -0
  77. package/src/tasks/create/templates/Constellation/Field/Picklist/suggestions-handler.js +10 -0
  78. package/src/tasks/create/{template → templates/Constellation/Field/Text}/config.json.mustache +15 -5
  79. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +51 -0
  80. package/src/tasks/create/{template → templates/Constellation/Field/Text}/index.jsx.mustache +5 -0
  81. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
  82. package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +7 -0
  83. package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +112 -0
  84. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +48 -0
  85. package/src/tasks/create/templates/Constellation/Field/Text-Email/event-utils.js.mustache +18 -0
  86. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +231 -0
  87. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
  88. package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +7 -0
  89. package/src/tasks/create/templates/Constellation/Field/Text-Email/suggestions-handler.js +10 -0
  90. package/src/tasks/create/templates/Constellation/Field/Text-Input/StatusWork.jsx +26 -0
  91. package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +112 -0
  92. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +48 -0
  93. package/src/tasks/create/templates/Constellation/Field/Text-Input/event-utils.js.mustache +18 -0
  94. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +239 -0
  95. package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
  96. package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +7 -0
  97. package/src/tasks/create/templates/Constellation/Field/Text-Input/suggestions-handler.js +10 -0
  98. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +112 -0
  99. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +48 -0
  100. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/event-utils.js.mustache +18 -0
  101. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +231 -0
  102. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
  103. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +7 -0
  104. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/suggestions-handler.js +10 -0
  105. package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +124 -0
  106. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +46 -0
  107. package/src/tasks/create/templates/Constellation/Field/Text-Phone/event-utils.js.mustache +18 -0
  108. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +267 -0
  109. package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
  110. package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +7 -0
  111. package/src/tasks/create/templates/Constellation/Field/Text-Phone/suggestions-handler.js +10 -0
  112. package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +238 -0
  113. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +46 -0
  114. package/src/tasks/create/templates/Constellation/Field/Text-URL/event-utils.js.mustache +18 -0
  115. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +232 -0
  116. package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
  117. package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +7 -0
  118. package/src/tasks/create/templates/Constellation/Field/Text-URL/suggestions-handler.js +10 -0
  119. package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.jsx.mustache +173 -0
  120. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/config.json.mustache +186 -0
  121. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/demo.stories.jsx.mustache +57 -0
  122. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/index.jsx.mustache +213 -0
  123. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/mock.stories.js.mustache +20 -0
  124. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/styles.js.mustache +7 -0
  125. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/suggestions-handler.js +10 -0
  126. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/time-of-day.js.mustache +287 -0
  127. package/src/tasks/create/templates/Constellation/Template/DETAILS/OneColumnDetails.svg +22 -0
  128. package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
  129. package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +36 -0
  130. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +132 -0
  131. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +86 -0
  132. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +189 -0
  133. package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +7 -0
  134. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +152 -0
  135. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
  136. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/TwoColumnDetails.svg +28 -0
  137. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +43 -0
  138. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +136 -0
  139. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +86 -0
  140. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +230 -0
  141. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +7 -0
  142. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +155 -0
  143. package/src/tasks/create/templates/Constellation/Template/FORM/DefaultForm.svg +29 -0
  144. package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +46 -0
  145. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +169 -0
  146. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +45 -0
  147. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +137 -0
  148. package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +7 -0
  149. package/src/tasks/create/templates/Constellation/Template/FORM-region/TwoColumn.svg +38 -0
  150. package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +28 -0
  151. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +178 -0
  152. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +48 -0
  153. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +143 -0
  154. package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +7 -0
  155. package/src/tasks/create/templates/Constellation/Template/PAGE/GetNextWork.jsx.mustache +35 -0
  156. package/src/tasks/create/templates/Constellation/Template/PAGE/OneColumnPage.svg +36 -0
  157. package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +33 -0
  158. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
  159. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +70 -0
  160. package/src/tasks/create/templates/Constellation/Template/PAGE/localizations.json.mustache +4 -0
  161. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
  162. package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +7 -0
  163. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +229 -0
  164. package/src/tasks/create/templates/Constellation/Widget/CASE/OneColumnPage.svg +36 -0
  165. package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +24 -0
  166. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
  167. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +76 -0
  168. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +390 -0
  169. package/src/tasks/create/{template → templates/Constellation/Widget/CASE}/styles.js.mustache +1 -1
  170. package/src/tasks/create/templates/Constellation/Widget/PAGE/OneColumnPage.svg +36 -0
  171. package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +60 -0
  172. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
  173. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +48 -0
  174. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +23 -0
  175. package/src/tasks/{init/template/src/components/Organization_Library_VideoPlayer/styles.js → create/templates/Constellation/Widget/PAGE/styles.js.mustache} +3 -1
  176. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.jsx.mustache +75 -0
  177. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/OneColumnPage.svg +36 -0
  178. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Operator.jsx.mustache +240 -0
  179. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +67 -0
  180. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
  181. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +110 -0
  182. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
  183. package/src/tasks/{init/template/src/components/Organization_Library_MediaURL/MediaURL.styles.ts → create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache} +3 -1
  184. package/src/tasks/create-all/index.js +398 -0
  185. package/src/tasks/delete/helper.js +6 -4
  186. package/src/tasks/delete/index.js +4 -0
  187. package/src/tasks/delete-all/helper.js +153 -0
  188. package/src/tasks/delete-all/index.js +49 -0
  189. package/src/tasks/generate-ai/aiPrompt.txt.mustache +23 -0
  190. package/src/tasks/generate-ai/aiPromptDavinci.txt.mustache +14 -0
  191. package/src/tasks/generate-ai/helper.js +357 -0
  192. package/src/tasks/generate-ai/index.js +34 -0
  193. package/src/tasks/index.js +7 -0
  194. package/src/tasks/init/index.js +9 -3
  195. package/src/tasks/init/template/.eslintignore +8 -0
  196. package/src/tasks/init/template/.eslintrc.json +186 -5
  197. package/src/tasks/init/template/.vscode/extensions.json +1 -1
  198. package/src/tasks/init/template/README.md +80 -61
  199. package/src/tasks/init/template/keys/DX-ComponentDev.zip +0 -0
  200. package/src/tasks/init/template/keys/dxcb.crt +32 -0
  201. package/src/tasks/init/template/keys/dxcb.key +51 -0
  202. package/src/tasks/init/template/package.json.mustache +44 -21
  203. package/src/tasks/init/template/src/components/_components.md +1 -0
  204. package/src/tasks/init/template/tasks.config.json +19 -5
  205. package/src/tasks/init/template/templateNPMRC.txt +8 -0
  206. package/src/tasks/linter/index.js +46 -0
  207. package/src/tasks/list/helper.js +19 -6
  208. package/src/tasks/list/index.js +4 -0
  209. package/src/tasks/publish/helper.js +13 -4
  210. package/src/tasks/publish/index.js +14 -1
  211. package/src/tasks/publish-all/helper.js +154 -0
  212. package/src/tasks/publish-all/index.js +95 -0
  213. package/src/tasks/rename/index.js +314 -0
  214. package/src/tasks/validator/index.js +291 -18
  215. package/src/util.js +372 -6
  216. package/src/tasks/create/template/demo.stories.jsx.mustache +0 -44
  217. package/src/tasks/init/template/src/components/MBTAList/MBTAList.stories.tsx +0 -10
  218. package/src/tasks/init/template/src/components/MBTAList/MBTAList.tsx +0 -122
  219. package/src/tasks/init/template/src/components/MBTAList/icons/accessible.icon.tsx +0 -14
  220. package/src/tasks/init/template/src/components/MBTAList/icons/bus.icon.tsx +0 -13
  221. package/src/tasks/init/template/src/components/MBTAList/icons/mbta.icon.tsx +0 -10
  222. package/src/tasks/init/template/src/components/MBTAList/icons/subway.icon.tsx +0 -14
  223. package/src/tasks/init/template/src/components/MBTAList/index.ts +0 -2
  224. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.stories.tsx +0 -19
  225. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.types.ts +0 -10
  226. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURLDisplay.tsx +0 -25
  227. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURLInput.tsx +0 -24
  228. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/config.json +0 -13
  229. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/index.ts +0 -2
  230. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/config.json +0 -44
  231. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/demo.stories.jsx +0 -40
  232. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/index.jsx +0 -42
  233. /package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
  234. /package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
@@ -0,0 +1,254 @@
1
+ /* eslint-disable no-undef */
2
+ import { useEffect, useState } from 'react';
3
+ import { DateTimeInput, FieldValueList, DateTimeDisplay, Text } from "@pega/cosmos-react-core";
4
+ import PropTypes from "prop-types";
5
+
6
+ // includes in bundle
7
+ import DateTimeFormatter from "./date-time";
8
+ import {datetimedisplayformatter,formatExists} from "./date";
9
+ import {
10
+ getFullYear,
11
+ getMaxDate,
12
+ getMinDate,
13
+ parseClockFormat,
14
+ correctDateTimeToSeconds,
15
+ datetimeFireChangeBlurEvents
16
+ } from "./date-utils";
17
+ import { suggestionsHandler } from './suggestions-handler';
18
+
19
+
20
+ import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
21
+
22
+ // Duplicated runtime code from Constellation Design System Component
23
+
24
+ // props passed in combination of props from property panel (config.json) and run time props from Constellation
25
+ // any default values in config.pros should be set in defaultProps at bottom of this file
26
+ const {{COMPONENT_CLASS_NAME}} = props => {
27
+ const {
28
+ getPConnect,
29
+ value,
30
+ validatemessage,
31
+ label,
32
+ hideLabel,
33
+ helperText,
34
+ withSeconds,
35
+ nextYearRange,
36
+ previousYearRange,
37
+ showWeekNumber,
38
+ pickerInterval,
39
+ testId,
40
+ additionalProps,
41
+ displayMode,
42
+ variant,
43
+ hasSuggestions
44
+ } = props;
45
+ let { formatter } = props;
46
+ const pConn = getPConnect();
47
+ const actions = pConn.getActionsApi();
48
+ const propName = pConn.getStateProps().value;
49
+
50
+ const environmentInfo = PCore.getEnvironmentInfo();
51
+ const timezone = environmentInfo && environmentInfo.getTimeZone();
52
+
53
+ let { readOnly, required, disabled } = props;
54
+ [readOnly, required, disabled] = [readOnly, required, disabled].map(
55
+ (prop) => prop === true || (typeof prop === 'string' && prop === 'true')
56
+ );
57
+
58
+ const [status, setStatus] = useState(hasSuggestions ? 'pending' : '');
59
+
60
+ useEffect(() => {
61
+ if (validatemessage !== '') {
62
+ setStatus('error');
63
+ }
64
+ if (hasSuggestions) {
65
+ setStatus('pending');
66
+ } else if (!hasSuggestions && status !== 'success') {
67
+ setStatus(validatemessage !== '' ? 'error' : undefined);
68
+ }
69
+ }, [validatemessage, hasSuggestions]);
70
+
71
+ let { clockFormat } = props;
72
+ clockFormat = parseClockFormat(clockFormat);
73
+
74
+ // calculate min and max range of calendar
75
+ const currentYear = getFullYear();
76
+ const yearFromValue = getFullYear(value);
77
+ const maxDate = getMaxDate(parseInt(nextYearRange, 10), currentYear, yearFromValue);
78
+ const minDate = getMinDate(parseInt(previousYearRange, 10), currentYear, yearFromValue);
79
+
80
+ const onResolveSuggestionHandler = (accepted) => {
81
+ suggestionsHandler(accepted, pConn, setStatus);
82
+ };
83
+
84
+ function handleBlur(onBlurValue) {
85
+ const { valueAsISOString: datetimeTZ, state: errorState } = onBlurValue;
86
+ const datetimeGMT = DateTimeFormatter.convertFromTimezone(datetimeTZ, timezone);
87
+
88
+ const datetimeGMTCorrectedToSeconds = datetimeGMT
89
+ ? correctDateTimeToSeconds(datetimeGMT, withSeconds)
90
+ : datetimeGMT;
91
+
92
+ datetimeFireChangeBlurEvents(errorState, value, datetimeGMTCorrectedToSeconds, actions, propName, pConn);
93
+ const isValueChanged =
94
+ !(value === undefined && datetimeGMTCorrectedToSeconds === '') && value !== datetimeGMTCorrectedToSeconds;
95
+ if (hasSuggestions && isValueChanged) {
96
+ pConn.ignoreSuggestion();
97
+ }
98
+ }
99
+
100
+ function handleChange(onChangeValue) {
101
+ const { valueAsISOString: datetimeTZ } = onChangeValue;
102
+ const datetimeGMT = DateTimeFormatter.convertFromTimezone(datetimeTZ, timezone);
103
+ const datetimeGMTCorrectedToSeconds = datetimeGMT
104
+ ? correctDateTimeToSeconds(datetimeGMT, withSeconds)
105
+ : datetimeGMT;
106
+ if (hasSuggestions && value !== datetimeGMTCorrectedToSeconds) {
107
+ setStatus(undefined);
108
+ }
109
+ pConn.clearErrorMessages({
110
+ property: propName
111
+ });
112
+ }
113
+
114
+ if (displayMode === 'LABELS_LEFT' || displayMode === 'STACKED_LARGE_VAL' || displayMode === 'DISPLAY_ONLY') {
115
+ let variantValue = 'datetime';
116
+ let formatValue = withSeconds ? 'long' : 'short';
117
+ const runtimeformatter = pConn.getConfigProps()?.formatter;
118
+ if (formatter !== runtimeformatter) {
119
+ formatter = runtimeformatter;
120
+ }
121
+ if (formatExists(formatter)) {
122
+ const { variantVal, formatVal } = datetimedisplayformatter(formatter);
123
+ variantValue = variantVal;
124
+ formatValue = withSeconds && formatter === 'Time-Only' ? 'long' : formatVal;
125
+ }
126
+ const displayComp = (
127
+ <DateTimeDisplay
128
+ variant={variantValue}
129
+ format={formatValue}
130
+ value={
131
+ formatter === 'DateTime-Since' ? value : DateTimeFormatter.convertToTimezone(value, { timezone }) || undefined
132
+ }
133
+ clockFormat={clockFormat || undefined}
134
+ />
135
+ );
136
+ switch (displayMode) {
137
+ case 'DISPLAY_ONLY': {
138
+ return ( <Styled{{COMPONENT_CLASS_NAME}}Wrapper> displayComp </Styled{{COMPONENT_CLASS_NAME}}Wrapper>);
139
+ }
140
+ case 'LABELS_LEFT': {
141
+ return (
142
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
143
+ <FieldValueList
144
+ variant={hideLabel ? 'stacked' : variant}
145
+ data-testid={testId}
146
+ fields={[{ id: '1', name: hideLabel ? '' : label, value: displayComp }]}
147
+ />
148
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
149
+ );
150
+ }
151
+ case 'STACKED_LARGE_VAL': {
152
+ return (
153
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
154
+ <FieldValueList
155
+ variant='stacked'
156
+ data-testid={testId}
157
+ fields={[
158
+ {
159
+ id: '2',
160
+ name: hideLabel ? '' : label,
161
+ value: (
162
+ <Text variant='h1' as='span'>
163
+ {displayComp}
164
+ </Text>
165
+ )
166
+ }
167
+ ]}
168
+ />
169
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
170
+ );
171
+ }
172
+ // no default
173
+ }
174
+ }
175
+
176
+
177
+ return (
178
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
179
+ <DateTimeInput
180
+ {...additionalProps}
181
+ label={label}
182
+ labelHidden={hideLabel}
183
+ info={validatemessage || helperText}
184
+ status={status}
185
+ value={DateTimeFormatter.convertToTimezone(value, { timezone }) || undefined}
186
+ withSeconds={withSeconds}
187
+ disabled={disabled}
188
+ readOnly={readOnly}
189
+ required={required}
190
+ pickerInterval={pickerInterval}
191
+ clockFormat={clockFormat || undefined}
192
+ showWeekNumber={showWeekNumber}
193
+ min={minDate}
194
+ max={maxDate}
195
+ data-testid={testId}
196
+ onFocus={actions.onFocus}
197
+ onChange={handleChange}
198
+ onBlur={handleBlur}
199
+ onResolveSuggestion={onResolveSuggestionHandler}
200
+ />
201
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
202
+ );
203
+ }
204
+
205
+
206
+
207
+ {{COMPONENT_CLASS_NAME}}.defaultProps = {
208
+ value: undefined,
209
+ withSeconds: false,
210
+ validatemessage: "",
211
+ helperText: "",
212
+ hideLabel: false,
213
+ disabled: false,
214
+ readOnly: false,
215
+ required: false,
216
+ pickerInterval: "30",
217
+ clockFormat: 0,
218
+ showWeekNumber: false,
219
+ nextYearRange: "",
220
+ previousYearRange: "",
221
+ testId: null,
222
+ additionalProps: {},
223
+ displayMode: null,
224
+ variant: "inline",
225
+ Format: "defaultDateTime",
226
+ hasSuggestions: false
227
+ };
228
+
229
+ {{COMPONENT_CLASS_NAME}}.propTypes = {
230
+ value: PropTypes.string,
231
+ label: PropTypes.string.isRequired,
232
+ hideLabel: PropTypes.bool,
233
+ withSeconds: PropTypes.bool,
234
+ getPConnect: PropTypes.func.isRequired,
235
+ validatemessage: PropTypes.string,
236
+ helperText: PropTypes.string,
237
+ disabled: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
238
+ readOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
239
+ required: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
240
+ pickerInterval: PropTypes.string,
241
+ clockFormat: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
242
+ showWeekNumber: PropTypes.bool,
243
+ nextYearRange: PropTypes.string,
244
+ previousYearRange: PropTypes.string,
245
+ testId: PropTypes.string,
246
+ additionalProps: PropTypes.objectOf(PropTypes.any),
247
+ displayMode: PropTypes.string,
248
+ variant: PropTypes.string,
249
+ formatter: PropTypes.string,
250
+ Format: PropTypes.string,
251
+ hasSuggestions: PropTypes.bool
252
+ };
253
+
254
+ export default {{COMPONENT_CLASS_NAME}};
@@ -0,0 +1,23 @@
1
+ export const configProps = {
2
+ value: '2023-01-24T16:45:00.000Z',
3
+ validatemessage: '',
4
+ label: 'DateTime Label',
5
+ hideLabel: false,
6
+ helperText: 'DateTime helper text',
7
+ withSeconds: false,
8
+ nextYearRange: '10',
9
+ previousYearRange: '5',
10
+ showWeekNumber: false,
11
+ testId: '12345678',
12
+ additionalProps: {},
13
+ displayMode: '',
14
+ variant: '',
15
+ hasSuggestions: false,
16
+ readOnly: false,
17
+ required: false,
18
+ disabled: false
19
+ };
20
+
21
+ export const stateProps = {
22
+ value: '.DateTimeLabel'
23
+ };
@@ -0,0 +1,7 @@
1
+ import styled, { css } from 'styled-components';
2
+
3
+ export default styled.div(() => {
4
+ return css`
5
+ margin: 0px 0px;
6
+ `;
7
+ });
@@ -0,0 +1,10 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+ export const suggestionsHandler = (accepted, pConn, setStatus) => {
3
+ if (accepted) {
4
+ pConn.acceptSuggestion();
5
+ setStatus('success');
6
+ } else {
7
+ pConn.ignoreSuggestion();
8
+ setStatus(undefined);
9
+ }
10
+ };
@@ -0,0 +1,279 @@
1
+ {
2
+ "name": "{{COMPONENT_KEY}}",
3
+ "label": "{{COMPONENT_LABEL}}",
4
+ "description": "{{DESCRIPTION}}",
5
+ "organization": "{{ORGANIZATION}}",
6
+ "version": "{{VERSION}}",
7
+ "library": "{{LIBRARY}}",
8
+ "allowedApplications": {{{ALLOWEDAPPS}}},
9
+ "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
11
+ "type": "{{TYPE}}",
12
+ "subtype": {{{SUB_TYPE}}},
13
+ "icon": "images/pz-decimal-active.svg",
14
+ "properties": [
15
+ {
16
+ "name": "label",
17
+ "label": "Field label",
18
+ "format": "TEXT",
19
+ "required": true
20
+ },
21
+ {
22
+ "name": "readOnly",
23
+ "label": "Edit mode",
24
+ "format": "READONLY"
25
+ },
26
+ {
27
+ "name": "decimalPrecision",
28
+ "label": "Decimal places",
29
+ "format": "NUMBER",
30
+ "min": 0,
31
+ "max": 20
32
+ },
33
+ {
34
+ "name": "showGroupSeparators",
35
+ "label": "Show thousands separator",
36
+ "format": "BOOLEAN"
37
+ },
38
+ {
39
+ "label": "Column settings",
40
+ "format": "GROUP",
41
+ "visibility": "@VIEWTYPE == 'MultiRecordDisplayAsTable'",
42
+ "properties": [
43
+ {
44
+ "name": "columnWidth",
45
+ "label": "Column width",
46
+ "format": "SELECT",
47
+ "source": [
48
+ {
49
+ "key": "auto",
50
+ "value": "Auto"
51
+ },
52
+ {
53
+ "key": "custom",
54
+ "value": "Custom"
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ "name": "width",
60
+ "label": "Width (px)",
61
+ "format": "NUMBER",
62
+ "visibility": "$this.columnWidth == 'custom'"
63
+ }
64
+ ]
65
+ },
66
+ {
67
+ "label": "Input settings",
68
+ "format": "GROUP",
69
+ "visibility": "(!readOnly = true)",
70
+ "properties": [
71
+ {
72
+ "name": "placeholder",
73
+ "label": "Placeholder",
74
+ "format": "TEXT"
75
+ },
76
+ {
77
+ "name": "helperText",
78
+ "label": "Helper text",
79
+ "format": "TEXT"
80
+ }
81
+ ]
82
+ },
83
+ {
84
+ "label": "Read-only settings",
85
+ "format": "GROUP",
86
+ "properties": [
87
+ {
88
+ "format": "SELECT",
89
+ "name": "formatter",
90
+ "label": "Format",
91
+ "defaultValue": "defaultDecimal",
92
+ "source": [
93
+ {
94
+ "key": "defaultDecimal",
95
+ "value": "Default"
96
+ },
97
+ {
98
+ "key": "Integer",
99
+ "value": "Integer"
100
+ },
101
+ {
102
+ "key": "Currency",
103
+ "value": "Currency"
104
+ },
105
+ {
106
+ "key": "Percentage",
107
+ "value": "Percentage"
108
+ }
109
+ ]
110
+ }
111
+ ]
112
+ },
113
+ {
114
+ "format": "CASCADE",
115
+ "visibility": "(formatter = Currency)",
116
+ "source": {
117
+ "format": "SELECT",
118
+ "label": "ISO Code Selection",
119
+ "name": "isoCodeSelection",
120
+ "defaultValue": "constant",
121
+ "source": [
122
+ {
123
+ "key": "constant",
124
+ "value": "Constant"
125
+ },
126
+ {
127
+ "key": "propertyRef",
128
+ "value": "Property Reference"
129
+ }
130
+ ]
131
+ },
132
+ "cascadeElements": [
133
+ {
134
+ "key": "currencyISOCode",
135
+ "format": "TEXT",
136
+ "name": "currencyISOCode",
137
+ "label": "Currency ISO Code",
138
+ "defaultValue": "USD",
139
+ "match": "constant"
140
+ },
141
+ {
142
+ "key": "currencyISOCode",
143
+ "format": "PROPERTY",
144
+ "name": "currencyISOCode",
145
+ "label": "Currency ISO Code",
146
+ "match": "propertyRef"
147
+ }
148
+ ]
149
+ },
150
+ {
151
+ "format": "SELECT",
152
+ "name": "currencyDisplay",
153
+ "label": "Currency display",
154
+ "visibility": "(formatter = Currency)",
155
+ "defaultValue": "symbol",
156
+ "source": [
157
+ {
158
+ "key": "symbol",
159
+ "value": "Auto"
160
+ },
161
+ {
162
+ "key": "code",
163
+ "value": "Code"
164
+ },
165
+ {
166
+ "key": "name",
167
+ "value": "Name"
168
+ }
169
+ ]
170
+ },
171
+ {
172
+ "format": "SELECT",
173
+ "name": "negative",
174
+ "label": "Negative number display",
175
+ "visibility": "(formatter = Currency)",
176
+ "defaultValue": "minus-sign",
177
+ "source": [
178
+ {
179
+ "key": "minus-sign",
180
+ "value": "Standard"
181
+ },
182
+ {
183
+ "key": "parentheses",
184
+ "value": "Accounting"
185
+ }
186
+ ]
187
+ },
188
+ {
189
+ "format": "SELECT",
190
+ "name": "notation",
191
+ "label": "Notation",
192
+ "visibility": "(!negative = parentheses)&&(!formatter = Percentage)",
193
+ "defaultValue": "standard",
194
+ "source": [
195
+ {
196
+ "key": "standard",
197
+ "value": "Standard"
198
+ },
199
+ {
200
+ "key": "compact",
201
+ "value": "Compact"
202
+ }
203
+ ]
204
+ },
205
+ {
206
+ "format": "SELECT",
207
+ "name": "currencyDecimalPrecision",
208
+ "label": "Decimal places shown",
209
+ "visibility": "(formatter = Currency)",
210
+ "defaultValue": "auto",
211
+ "source": [
212
+ {
213
+ "key": "auto",
214
+ "value": "Auto"
215
+ },
216
+ {
217
+ "key": "0",
218
+ "value": "None"
219
+ },
220
+ {
221
+ "key": "1",
222
+ "value": "1"
223
+ },
224
+ {
225
+ "key": "2",
226
+ "value": "2"
227
+ },
228
+ {
229
+ "key": "3",
230
+ "value": "3"
231
+ },
232
+ {
233
+ "key": "4",
234
+ "value": "4"
235
+ }
236
+ ]
237
+ },
238
+ {
239
+ "label": "Conditions",
240
+ "format": "GROUP",
241
+ "properties": [
242
+ {
243
+ "name": "required",
244
+ "label": "Required",
245
+ "format": "REQUIRED",
246
+ "visibility": "(!readOnly = true)"
247
+ },
248
+ {
249
+ "name": "disabled",
250
+ "label": "Disabled",
251
+ "format": "DISABLED",
252
+ "visibility": "(!readOnly = true)"
253
+ },
254
+ {
255
+ "name": "visibility",
256
+ "label": "Visibility",
257
+ "format": "VISIBILITY"
258
+ }
259
+ ]
260
+ },
261
+ {
262
+ "label": "Advanced",
263
+ "format": "GROUP",
264
+ "collapsible": true,
265
+ "properties": [
266
+ {
267
+ "name": "testId",
268
+ "label": "Test ID",
269
+ "format": "TEXT",
270
+ "ignorePattern": "[^-_\\p{N}\\p{L}]",
271
+ "includeAnnotations": false
272
+ }
273
+ ]
274
+ }
275
+ ],
276
+ "defaultConfig": {
277
+ "label": "@L $this.label"
278
+ }
279
+ }
@@ -0,0 +1,49 @@
1
+ import { withKnobs } from '@storybook/addon-knobs';
2
+
3
+ import { configProps, fieldMetadata, stateProps } from './mock.stories.js';
4
+
5
+ import {{COMPONENT_CLASS_NAME}} from './index.jsx';
6
+
7
+ export default {
8
+ title: '{{COMPONENT_CLASS_NAME}}',
9
+ decorators: [withKnobs],
10
+ component: {{COMPONENT_CLASS_NAME}}
11
+ };
12
+
13
+ export const base{{COMPONENT_CLASS_NAME}} = () => {
14
+
15
+ const props = {
16
+ value: configProps.value,
17
+ placeholder: configProps.placeholder,
18
+ label: configProps.label,
19
+ helperText: configProps.helperText,
20
+ showGroupSeparators: configProps.showGroupSeparators,
21
+ hasSuggestions: configProps.hasSuggestions,
22
+ testId: configProps.testId,
23
+ fieldMetadata,
24
+
25
+ getPConnect: () => {
26
+ return {
27
+ getStateProps: () => {
28
+ return stateProps;
29
+ },
30
+ getActionsApi: () => {
31
+ return {
32
+ updateFieldValue: () => {/* nothing */},
33
+ triggerFieldChange: () => {/* nothing */}
34
+ };
35
+ },
36
+ ignoreSuggestion: () => {/* nothing */},
37
+ acceptSuggestion: () => {/* nothing */},
38
+ setInheritedProps: () => {/* nothing */},
39
+ resolveConfigProps: () => {/* nothing */}
40
+ };
41
+ }
42
+ };
43
+
44
+ return (
45
+ <>
46
+ <{{COMPONENT_CLASS_NAME}} {...props} />
47
+ </>
48
+ );
49
+ };
@@ -0,0 +1,18 @@
1
+ const handleEvent = (actions, eventType, propName, value) => {
2
+ switch (eventType) {
3
+ case "change":
4
+ actions.updateFieldValue(propName, value);
5
+ break;
6
+ case "blur":
7
+ actions.triggerFieldChange(propName, value);
8
+ break;
9
+ case "changeNblur":
10
+ actions.updateFieldValue(propName, value);
11
+ actions.triggerFieldChange(propName, value);
12
+ break;
13
+ default:
14
+ break;
15
+ }
16
+ };
17
+
18
+ export default handleEvent;