@pega/custom-dx-components 2.0.7 → 2.0.9

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 (142) hide show
  1. package/package.json +1 -1
  2. package/src/constants.js +29 -17
  3. package/src/tasks/create/index.js +46 -23
  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 +99 -0
  105. package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +7 -0
  106. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/TwoColumnDetails.svg +28 -0
  107. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +42 -0
  108. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +99 -0
  109. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +7 -0
  110. package/src/tasks/create/templates/Constellation/Template/FORM/DefaultForm.svg +29 -0
  111. package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +45 -0
  112. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +49 -0
  113. package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +7 -0
  114. package/src/tasks/create/templates/Constellation/Template/FORM-region/TwoColumn.svg +38 -0
  115. package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +27 -0
  116. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +43 -0
  117. package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +7 -0
  118. package/src/tasks/create/templates/Constellation/Template/PAGE/GetNextWork.js.mustache +29 -0
  119. package/src/tasks/create/templates/Constellation/Template/PAGE/OneColumnPage.svg +36 -0
  120. package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +32 -0
  121. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +68 -0
  122. package/src/tasks/create/templates/Constellation/Template/PAGE/localizations.json.mustache +4 -0
  123. package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +7 -0
  124. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +226 -0
  125. package/src/tasks/create/templates/Constellation/Widget/CASE/OneColumnPage.svg +36 -0
  126. package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +23 -0
  127. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +75 -0
  128. package/src/tasks/create/templates/Constellation/Widget/CASE/styles.js.mustache +7 -0
  129. package/src/tasks/create/templates/Constellation/Widget/PAGE/OneColumnPage.svg +36 -0
  130. package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +59 -0
  131. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +48 -0
  132. package/src/tasks/create/templates/Constellation/Widget/PAGE/styles.js.mustache +7 -0
  133. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.js.mustache +73 -0
  134. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/OneColumnPage.svg +36 -0
  135. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Operator.js.mustache +239 -0
  136. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +66 -0
  137. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +110 -0
  138. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +7 -0
  139. package/src/tasks/init/template/package.json.mustache +7 -2
  140. package/src/tasks/publish/bundle/builder/index.js +49 -5
  141. package/src/tasks/publish/bundle/builder/webpack.config.js +7 -3
  142. package/src/tasks/validator/index.js +107 -8
@@ -0,0 +1,300 @@
1
+ import { useState, useEffect } from 'react';
2
+ import {
3
+ CurrencyInput as CosmosCurrency,
4
+ CurrencyDisplay,
5
+ NumberDisplay,
6
+ FieldValueList,
7
+ Text,
8
+ useConfiguration,
9
+ useAfterInitialEffect
10
+ } from '@pega/cosmos-react-core';
11
+ import PropTypes from 'prop-types';
12
+
13
+ // includes in bundle
14
+ import handleEvent from './event-utils';
15
+ import { suggestionsHandler } from './suggestions-handler';
16
+
17
+ const formatValue = (value) => {
18
+ if (!value && value !== 0) return '';
19
+ const [integer, decimal = ''] = value.toString().split('.');
20
+ return `${integer}.${decimal.padEnd(3, '0')}`;
21
+ };
22
+
23
+
24
+
25
+ import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
26
+
27
+ // Duplicated runtime code from Constellation Design System Component
28
+
29
+ // props passed in combination of props from property panel (config.json) and run time props from Constellation
30
+ // any default values in config.pros should be set in defaultProps at bottom of this file
31
+ const {{COMPONENT_CLASS_NAME}} = props => {
32
+ const {
33
+ getPConnect,
34
+ value,
35
+ placeholder,
36
+ validatemessage,
37
+ label,
38
+ hideLabel,
39
+ helperText,
40
+ testId,
41
+ allowDecimals,
42
+ currencyISOCode,
43
+ alwaysShowISOCode,
44
+ displayMode,
45
+ additionalProps,
46
+ variant,
47
+ formatter,
48
+ negative,
49
+ notation,
50
+ isTableFormatter,
51
+ hasSuggestions
52
+ } = props;
53
+ let { currencyDisplay } = props;
54
+ const pConn = getPConnect();
55
+ const actions = pConn.getActionsApi();
56
+ const propName = pConn.getStateProps().value;
57
+ const [currencyValue, setCurrencyValue] = useState(() => formatValue(value));
58
+
59
+ let { readOnly, required, disabled } = props;
60
+
61
+ [readOnly, required, disabled] = [readOnly, required, disabled].map(
62
+ (prop) => prop === true || (typeof prop === 'string' && prop === 'true')
63
+ );
64
+
65
+ const [status, setStatus] = useState(hasSuggestions ? 'pending' : undefined);
66
+
67
+ useEffect(() => {
68
+ if (validatemessage !== '') {
69
+ setStatus('error');
70
+ }
71
+ if (hasSuggestions) {
72
+ setStatus('pending');
73
+ } else if (!hasSuggestions && status !== 'success') {
74
+ setStatus(validatemessage !== '' ? 'error' : undefined);
75
+ }
76
+ }, [validatemessage, hasSuggestions]);
77
+
78
+ useAfterInitialEffect(() => {
79
+ setCurrencyValue(formatValue(value));
80
+ }, [value]);
81
+
82
+ const { decimalPrecision, currencyDecimalPrecision } = props;
83
+ let noOfDecimals = parseInt(decimalPrecision, 10);
84
+ if (Number.isNaN(noOfDecimals)) noOfDecimals = undefined;
85
+ let noOfFractionDigits = currencyDecimalPrecision === 'auto' ? undefined : parseInt(currencyDecimalPrecision, 10);
86
+
87
+ if (displayMode === 'LABELS_LEFT' || displayMode === 'STACKED_LARGE_VAL' || displayMode === 'DISPLAY_ONLY') {
88
+ let displayComp;
89
+ let { showGroupSeparators } = props;
90
+ if (displayMode === 'LABELS_LEFT' && isTableFormatter) {
91
+ noOfFractionDigits = undefined;
92
+ showGroupSeparators = true;
93
+ if (formatter === 'Currency-Code') {
94
+ currencyDisplay = 'code';
95
+ }
96
+ }
97
+
98
+ const displayValue = !value && value !== 0 ? undefined : Number(currencyValue);
99
+
100
+ {{! pick new delimiteres for mustache }}
101
+ {{=<% %>=}}
102
+
103
+ displayComp = (
104
+ <CurrencyDisplay
105
+ value={displayValue}
106
+ currencyISOCode={currencyISOCode}
107
+ formattingOptions={{
108
+ groupSeparators: true,
109
+ fractionDigits: noOfFractionDigits,
110
+ currency: currencyDisplay,
111
+ negative,
112
+ notation: negative === 'parentheses' ? 'standard' : notation
113
+ }}
114
+ />
115
+ );
116
+
117
+
118
+
119
+
120
+ if (['Integer', 'Decimal', 'Percentage', 'Decimal-Auto'].includes(formatter)) {
121
+ let unit;
122
+
123
+ switch (formatter) {
124
+ case 'Integer': {
125
+ noOfDecimals = 0;
126
+ break;
127
+ }
128
+ case 'Decimal': {
129
+ break;
130
+ }
131
+ case 'Decimal-Auto': {
132
+ noOfDecimals = Number.isInteger(currencyValue) ? 0 : 2;
133
+ break;
134
+ }
135
+ case 'Percentage': {
136
+ showGroupSeparators = false;
137
+ unit = 'percent';
138
+ break;
139
+ }
140
+ // no default
141
+ }
142
+
143
+ displayComp = (
144
+ <NumberDisplay
145
+ value={displayValue}
146
+ formattingOptions={{
147
+ fractionDigits: noOfDecimals,
148
+ groupSeparators: showGroupSeparators,
149
+ notation
150
+ }}
151
+ unit={unit}
152
+ />
153
+ );
154
+ }
155
+
156
+ <%={{ }}=%> {{! revert delimiteres for mustache }}
157
+
158
+ switch (displayMode) {
159
+ case 'DISPLAY_ONLY': {
160
+ return (<Styled{{COMPONENT_CLASS_NAME}}Wrapper> displayComp </Styled{{COMPONENT_CLASS_NAME}}Wrapper>) ;
161
+ }
162
+ case 'LABELS_LEFT': {
163
+ return (
164
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
165
+ <FieldValueList
166
+ variant={hideLabel ? 'stacked' : variant}
167
+ data-testid={testId}
168
+ fields={[{ id: '1', name: hideLabel ? '' : label, value: displayComp }]}
169
+ />
170
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
171
+ );
172
+ }
173
+ case 'STACKED_LARGE_VAL': {
174
+ return (
175
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
176
+ <FieldValueList
177
+ variant='stacked'
178
+ data-testid={testId}
179
+ fields={[
180
+ {
181
+ id: '2',
182
+ name: hideLabel ? '' : label,
183
+ value: (
184
+ <Text variant='h1' as='span'>
185
+ {displayComp}
186
+ </Text>
187
+ )
188
+ }
189
+ ]}
190
+ />
191
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
192
+ );
193
+ }
194
+ // no default
195
+ }
196
+ }
197
+
198
+ const onResolveSuggestionHandler = (accepted) => {
199
+ suggestionsHandler(accepted, pConn, setStatus);
200
+ };
201
+
202
+ return (
203
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
204
+ <CosmosCurrency
205
+ {...additionalProps}
206
+ label={label}
207
+ labelHidden={hideLabel}
208
+ info={validatemessage || helperText}
209
+ value={currencyValue}
210
+ status={status}
211
+ showDecimal={allowDecimals}
212
+ currencyISOCode={currencyISOCode}
213
+ alwaysShowISOCode={alwaysShowISOCode}
214
+ placeholder={placeholder}
215
+ disabled={disabled}
216
+ readOnly={readOnly}
217
+ required={required}
218
+ data-testid={testId}
219
+ onChange={(enteredValue) => {
220
+ if (hasSuggestions) {
221
+ setStatus(undefined);
222
+ }
223
+ setCurrencyValue(enteredValue);
224
+ pConn.clearErrorMessages({
225
+ property: propName
226
+ });
227
+ }}
228
+ onBlur={(enteredValue) => {
229
+ const parsedValue = enteredValue !== '' ? Number(enteredValue) : enteredValue;
230
+ if (!readOnly && (!value || value !== parsedValue)) {
231
+ handleEvent(actions, 'changeNblur', propName, parsedValue);
232
+ if (hasSuggestions) {
233
+ pConn.ignoreSuggestion();
234
+ }
235
+ }
236
+ }}
237
+ onResolveSuggestion={onResolveSuggestionHandler}
238
+ />
239
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
240
+ );
241
+ }
242
+
243
+ {{COMPONENT_CLASS_NAME}}.defaultProps = {
244
+ value: 0,
245
+ placeholder: '',
246
+ validatemessage: '',
247
+ helperText: '',
248
+ hideLabel: false,
249
+ disabled: false,
250
+ readOnly: false,
251
+ required: false,
252
+ decimalPrecision: null,
253
+ allowDecimals: true,
254
+ currencyISOCode: 'USD',
255
+ isoCodeSelection: 'constant',
256
+ testId: null,
257
+ displayMode: null,
258
+ additionalProps: {},
259
+ variant: 'inline',
260
+ showGroupSeparators: false,
261
+ formatter: 'defaultCurrency',
262
+ currencyDisplay: 'symbol',
263
+ negative: 'minus-sign',
264
+ notation: 'standard',
265
+ currencyDecimalPrecision: 'auto',
266
+ isTableFormatter: false,
267
+ alwaysShowISOCode: false,
268
+ hasSuggestions: false
269
+ };
270
+
271
+ {{COMPONENT_CLASS_NAME}}.propTypes = {
272
+ value: PropTypes.number,
273
+ placeholder: PropTypes.string,
274
+ label: PropTypes.string.isRequired,
275
+ decimalPrecision: PropTypes.number,
276
+ allowDecimals: PropTypes.bool,
277
+ currencyISOCode: PropTypes.string,
278
+ hideLabel: PropTypes.bool,
279
+ getPConnect: PropTypes.func.isRequired,
280
+ validatemessage: PropTypes.string,
281
+ helperText: PropTypes.string,
282
+ disabled: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
283
+ readOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
284
+ required: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
285
+ testId: PropTypes.string,
286
+ displayMode: PropTypes.string,
287
+ additionalProps: PropTypes.objectOf(PropTypes.any),
288
+ variant: PropTypes.string,
289
+ showGroupSeparators: PropTypes.bool,
290
+ formatter: PropTypes.string,
291
+ currencyDisplay: PropTypes.string,
292
+ negative: PropTypes.string,
293
+ notation: PropTypes.string,
294
+ currencyDecimalPrecision: PropTypes.string,
295
+ isTableFormatter: PropTypes.bool,
296
+ alwaysShowISOCode: PropTypes.bool,
297
+ hasSuggestions: PropTypes.bool
298
+ };
299
+
300
+ 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,93 @@
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-text-input-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
+ },
31
+ {
32
+ "name": "showGroupSeparators",
33
+ "label": "Show thousands separator",
34
+ "format": "BOOLEAN"
35
+ },
36
+ {
37
+ "label": "Input settings",
38
+ "format": "GROUP",
39
+ "visibility": "(!readOnly = true)",
40
+ "properties": [
41
+ {
42
+ "name": "placeholder",
43
+ "label": "Placeholder",
44
+ "format": "TEXT"
45
+ },
46
+ {
47
+ "name": "helperText",
48
+ "label": "Helper text",
49
+ "format": "TEXT"
50
+ }
51
+ ]
52
+ },
53
+ {
54
+ "label": "Conditions",
55
+ "format": "GROUP",
56
+ "properties": [
57
+ {
58
+ "name": "required",
59
+ "label": "Required",
60
+ "format": "REQUIRED",
61
+ "visibility": "(!readOnly = true)"
62
+ },
63
+ {
64
+ "name": "disabled",
65
+ "label": "Disabled",
66
+ "format": "DISABLED",
67
+ "visibility": "(!readOnly = true)"
68
+ },
69
+ {
70
+ "name": "visibility",
71
+ "label": "Visibility",
72
+ "format": "VISIBILITY"
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ "label": "Advanced",
78
+ "format": "GROUP",
79
+ "collapsible": true,
80
+ "properties": [
81
+ {
82
+ "name": "testId",
83
+ "label": "Test ID",
84
+ "format": "TEXT",
85
+ "ignorePattern": "[^-_\\p{N}\\p{L}]"
86
+ }
87
+ ]
88
+ }
89
+ ],
90
+ "defaultConfig": {
91
+ "label": "@L $this.label"
92
+ }
93
+ }
@@ -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;