@pega/custom-dx-components 2.0.8 → 2.0.10

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