@pega/custom-dx-components 2.0.8 → 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 -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 +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 +6 -1
  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,275 @@
1
+ import { useState, useEffect, useRef } from 'react';
2
+ import { NumberInput, NumberDisplay, CurrencyDisplay, FieldValueList, Text } from '@pega/cosmos-react-core';
3
+ import PropTypes from 'prop-types';
4
+
5
+ //inlcudes in bundle
6
+ import handleEvent from './event-utils';
7
+ import { suggestionsHandler } from './suggestions-handler';
8
+
9
+ import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
10
+
11
+
12
+ // Duplicated runtime code from Constellation Design System Component
13
+
14
+ // props passed in combination of props from property panel (config.json) and run time props from Constellation
15
+ // any default values in config.pros should be set in defaultProps at bottom of this file
16
+ const {{COMPONENT_CLASS_NAME}} = props => {
17
+ const {
18
+ getPConnect,
19
+ value,
20
+ placeholder,
21
+ validatemessage,
22
+ label,
23
+ hideLabel,
24
+ helperText,
25
+ testId,
26
+ decimalPrecision,
27
+ additionalProps,
28
+ displayMode,
29
+ variant,
30
+ formatter,
31
+ isTableFormatter,
32
+ hasSuggestions
33
+ } = props;
34
+ let { showGroupSeparators } = props;
35
+ const pConn = getPConnect();
36
+ const actions = pConn.getActionsApi();
37
+ const propName = pConn.getStateProps().value;
38
+ const [percentageValue, setPercentageValue] = useState(value?.toString());
39
+ const hasValueChange = useRef(false);
40
+
41
+ let { readOnly, required, disabled } = props;
42
+ [readOnly, required, disabled] = [readOnly, required, disabled].map(
43
+ (prop) => prop === true || (typeof prop === 'string' && prop === 'true')
44
+ );
45
+
46
+ const [status, setStatus] = useState(hasSuggestions ? 'pending' : undefined);
47
+
48
+ useEffect(() => {
49
+ if (validatemessage !== '') {
50
+ setStatus('error');
51
+ }
52
+ if (hasSuggestions) {
53
+ setStatus('pending');
54
+ } else if (!hasSuggestions && status !== 'success') {
55
+ setStatus(validatemessage !== '' ? 'error' : undefined);
56
+ }
57
+ }, [validatemessage, hasSuggestions]);
58
+
59
+ let numberOfDecimals = parseInt(decimalPrecision, 10);
60
+ if (Number.isNaN(numberOfDecimals)) {
61
+ numberOfDecimals = decimalPrecision === '' ? undefined : 2;
62
+ }
63
+
64
+ useEffect(() => {
65
+ setPercentageValue(value?.toString());
66
+ }, [value]);
67
+
68
+ if (displayMode === 'LABELS_LEFT' || displayMode === 'DISPLAY_ONLY') {
69
+ let unit = 'percent';
70
+ let displayComp = null;
71
+
72
+ if (isTableFormatter) {
73
+ switch (formatter) {
74
+ case 'Integer': {
75
+ numberOfDecimals = 0;
76
+ showGroupSeparators = true;
77
+ unit = '';
78
+ break;
79
+ }
80
+ case 'Decimal': {
81
+ showGroupSeparators = true;
82
+ unit = '';
83
+ break;
84
+ }
85
+ case 'Decimal-Auto': {
86
+ numberOfDecimals = Number.isInteger(percentageValue) ? 0 : 2;
87
+ showGroupSeparators = true;
88
+ unit = '';
89
+ break;
90
+ }
91
+ default: {
92
+ showGroupSeparators = false;
93
+ break;
94
+ }
95
+ }
96
+ }
97
+
98
+ {{! pick new delimiteres for mustache }}
99
+ {{=<% %>=}}
100
+
101
+ displayComp = (
102
+ <NumberDisplay
103
+ value={percentageValue}
104
+ formattingOptions={{
105
+ fractionDigits: numberOfDecimals,
106
+ groupSeparators: showGroupSeparators
107
+ }}
108
+ unit={unit}
109
+ />
110
+ );
111
+ if (isTableFormatter && (formatter === 'Currency' || formatter === 'Currency-Code')) {
112
+ const { currencyISOCode } = props;
113
+ let showIsoCode = true;
114
+ if (formatter === 'Currency') {
115
+ showIsoCode = false;
116
+ }
117
+ displayComp = (
118
+ <CurrencyDisplay
119
+ value={percentageValue}
120
+ currencyISOCode={currencyISOCode}
121
+ formattingOptions={{
122
+ groupSeparators: showGroupSeparators,
123
+ currency: showIsoCode ? 'code' : 'symbol'
124
+ }}
125
+ />
126
+ );
127
+ }
128
+
129
+ <%={{ }}=%> {{! revert delimiteres for mustache }}
130
+
131
+ return displayMode === 'DISPLAY_ONLY' ? (
132
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
133
+ displayComp
134
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
135
+ ) : (
136
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
137
+ <FieldValueList
138
+ variant={hideLabel ? 'stacked' : variant}
139
+ data-testid={testId}
140
+ fields={[{ id: '1', name: hideLabel ? '' : label, value: displayComp }]}
141
+ />
142
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
143
+ );
144
+ }
145
+
146
+ {{! pick new delimiteres for mustache }}
147
+ {{=<% %>=}}
148
+
149
+ if (displayMode === 'STACKED_LARGE_VAL') {
150
+ const displayComp = (
151
+ <NumberDisplay
152
+ value={percentageValue}
153
+ formattingOptions={{
154
+ fractionDigits: numberOfDecimals,
155
+ groupSeparators: showGroupSeparators
156
+ }}
157
+ unit='percent'
158
+ />
159
+ );
160
+
161
+ <%={{ }}=%> {{! revert delimiteres for mustache }}
162
+
163
+ return (
164
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
165
+ <FieldValueList
166
+ variant='stacked'
167
+ data-testid={testId}
168
+ fields={[
169
+ {
170
+ id: '2',
171
+ name: hideLabel ? '' : label,
172
+ value: (
173
+ <Text variant='h1' as='span'>
174
+ {displayComp}
175
+ </Text>
176
+ )
177
+ }
178
+ ]}
179
+ />
180
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
181
+ );
182
+ }
183
+
184
+ const onResolveSuggestionHandler = (accepted) => {
185
+ suggestionsHandler(accepted, pConn, setStatus);
186
+ };
187
+
188
+ return (
189
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
190
+ <NumberInput
191
+ {...additionalProps}
192
+ label={label}
193
+ labelHidden={hideLabel}
194
+ info={validatemessage || helperText}
195
+ value={percentageValue}
196
+ status={status}
197
+ placeholder={placeholder}
198
+ disabled={disabled}
199
+ readOnly={readOnly}
200
+ required={required}
201
+ numberOfDecimals={numberOfDecimals}
202
+ showGroupSeparators={showGroupSeparators}
203
+ unit='percent'
204
+ data-testid={testId}
205
+ onChange={(enteredValue) => {
206
+ if (hasSuggestions) {
207
+ setStatus(undefined);
208
+ }
209
+ setPercentageValue(enteredValue);
210
+ if (value !== enteredValue) {
211
+ handleEvent(actions, 'change', propName, enteredValue);
212
+ hasValueChange.current = true;
213
+ }
214
+ }}
215
+ onBlur={() => {
216
+ const parsedValue = percentageValue !== '' ? Number(percentageValue) : '';
217
+ if (!value || hasValueChange.current) {
218
+ handleEvent(actions, 'blur', propName, parsedValue);
219
+ if (hasSuggestions) {
220
+ pConn.ignoreSuggestion();
221
+ }
222
+ hasValueChange.current = false;
223
+ }
224
+ }}
225
+ onResolveSuggestion={onResolveSuggestionHandler}
226
+ />
227
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
228
+ );
229
+ }
230
+
231
+ {{COMPONENT_CLASS_NAME}}.defaultProps = {
232
+ value: '',
233
+ placeholder: '',
234
+ validatemessage: '',
235
+ helperText: '',
236
+ hideLabel: false,
237
+ disabled: false,
238
+ readOnly: false,
239
+ required: false,
240
+ testId: null,
241
+ decimalPrecision: '',
242
+ showGroupSeparators: false,
243
+ additionalProps: {},
244
+ displayMode: null,
245
+ variant: 'inline',
246
+ currencyISOCode: 'USD',
247
+ formatter: '',
248
+ isTableFormatter: false,
249
+ hasSuggestions: false
250
+ };
251
+
252
+ {{COMPONENT_CLASS_NAME}}.propTypes = {
253
+ value: PropTypes.string,
254
+ placeholder: PropTypes.string,
255
+ label: PropTypes.string.isRequired,
256
+ hideLabel: PropTypes.bool,
257
+ getPConnect: PropTypes.func.isRequired,
258
+ validatemessage: PropTypes.string,
259
+ helperText: PropTypes.string,
260
+ disabled: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
261
+ readOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
262
+ required: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
263
+ testId: PropTypes.string,
264
+ decimalPrecision: PropTypes.string,
265
+ showGroupSeparators: PropTypes.bool,
266
+ additionalProps: PropTypes.objectOf(PropTypes.any),
267
+ displayMode: PropTypes.string,
268
+ variant: PropTypes.string,
269
+ formatter: PropTypes.string,
270
+ currencyISOCode: PropTypes.string,
271
+ isTableFormatter: PropTypes.bool,
272
+ hasSuggestions: PropTypes.bool
273
+ };
274
+
275
+ 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,347 @@
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
+ {{#IS_TEMPLATE}}
13
+ "icon": "images/pz-integer-active.svg",
14
+ {{/IS_TEMPLATE}}
15
+ "properties": [
16
+ {
17
+ "name": "label",
18
+ "label": "Field label",
19
+ "format": "TEXT",
20
+ "required": true
21
+ },
22
+ {
23
+ "name": "readOnly",
24
+ "label": "Edit mode",
25
+ "format": "READONLY"
26
+ },
27
+ {
28
+ "name": "showGroupSeparators",
29
+ "label": "Show thousands separator",
30
+ "format": "BOOLEAN",
31
+ "visibility": "(!displayAs = slider)"
32
+ },
33
+ {
34
+ "label": "Column settings",
35
+ "format": "GROUP",
36
+ "visibility": "@VIEWTYPE == 'MultiRecordDisplayAsTable'",
37
+ "properties": [
38
+ {
39
+ "name": "columnWidth",
40
+ "label": "Column width",
41
+ "format": "SELECT",
42
+ "source": [
43
+ {
44
+ "key": "auto",
45
+ "value": "Auto"
46
+ },
47
+ {
48
+ "key": "custom",
49
+ "value": "Custom"
50
+ }
51
+ ]
52
+ },
53
+ {
54
+ "name": "width",
55
+ "label": "Width (px)",
56
+ "format": "NUMBER",
57
+ "visibility": "$this.columnWidth == 'custom'"
58
+ }
59
+ ]
60
+ },
61
+ {
62
+ "label": "Input settings",
63
+ "format": "GROUP",
64
+ "visibility": "(!readOnly = true)",
65
+ "properties": [
66
+ {
67
+ "name": "displayAs",
68
+ "label": "Display as",
69
+ "format": "SELECT",
70
+ "defaultValue": "input",
71
+ "source": [
72
+ {
73
+ "key": "input",
74
+ "value": "Input"
75
+ },
76
+ {
77
+ "key": "stepper",
78
+ "value": "Stepper"
79
+ },
80
+ {
81
+ "key": "slider",
82
+ "value": "Slider"
83
+ }
84
+ ]
85
+ },
86
+ {
87
+ "name": "min",
88
+ "label": "Min value",
89
+ "format": "NUMBER",
90
+ "defaultValue": "0",
91
+ "required": true,
92
+ "visibility": "(displayAs = slider)"
93
+ },
94
+ {
95
+ "name": "max",
96
+ "label": "Max value",
97
+ "format": "NUMBER",
98
+ "defaultValue": "100",
99
+ "required": true,
100
+ "visibility": "(displayAs = slider)"
101
+ },
102
+ {
103
+ "name": "defaultValue",
104
+ "label": "Default value",
105
+ "format": "NUMBER",
106
+ "visibility": "(displayAs = slider)"
107
+ },
108
+ {
109
+ "name": "step",
110
+ "label": "Increment",
111
+ "format": "NUMBER",
112
+ "defaultValue": "1",
113
+ "min": 1,
114
+ "visibility": "(displayAs = slider)"
115
+ },
116
+ {
117
+ "name": "placeholder",
118
+ "label": "Placeholder",
119
+ "format": "TEXT",
120
+ "visibility": "(!displayAs = slider && !displayAs = stepper)"
121
+ },
122
+ {
123
+ "name": "helperText",
124
+ "label": "Helper text",
125
+ "format": "TEXT"
126
+ },
127
+ {
128
+ "name": "showInput",
129
+ "label": "Show numeric input",
130
+ "format": "BOOLEAN",
131
+ "defaultValue": true,
132
+ "visibility": "(displayAs = slider)"
133
+ },
134
+ {
135
+ "name": "showTicks",
136
+ "label": "Show ticks",
137
+ "format": "BOOLEAN",
138
+ "defaultValue": true,
139
+ "visibility": "(displayAs = slider)"
140
+ }
141
+ ]
142
+ },
143
+ {
144
+ "label": "Read-only settings",
145
+ "format": "GROUP",
146
+ "properties": [
147
+ {
148
+ "format": "SELECT",
149
+ "name": "formatter",
150
+ "label": "Format",
151
+ "defaultValue": "defaultInteger",
152
+ "source": [
153
+ {
154
+ "key": "defaultInteger",
155
+ "value": "Default"
156
+ },
157
+ {
158
+ "key": "Decimal",
159
+ "value": "Decimal"
160
+ },
161
+ {
162
+ "key": "Currency",
163
+ "value": "Currency"
164
+ },
165
+ {
166
+ "key": "Percentage",
167
+ "value": "Percentage"
168
+ }
169
+ ]
170
+ }
171
+ ]
172
+ },
173
+ {
174
+ "format": "CASCADE",
175
+ "visibility": "(formatter = Currency)",
176
+ "source": {
177
+ "format": "SELECT",
178
+ "label": "ISO Code Selection",
179
+ "name": "isoCodeSelection",
180
+ "defaultValue": "constant",
181
+ "source": [
182
+ {
183
+ "key": "constant",
184
+ "value": "Constant"
185
+ },
186
+ {
187
+ "key": "propertyRef",
188
+ "value": "Property Reference"
189
+ }
190
+ ]
191
+ },
192
+ "cascadeElements": [
193
+ {
194
+ "key": "currencyISOCode",
195
+ "format": "TEXT",
196
+ "name": "currencyISOCode",
197
+ "label": "Currency ISO Code",
198
+ "defaultValue": "USD",
199
+ "match": "constant"
200
+ },
201
+ {
202
+ "key": "currencyISOCode",
203
+ "format": "PROPERTY",
204
+ "name": "currencyISOCode",
205
+ "label": "Currency ISO Code",
206
+ "match": "propertyRef"
207
+ }
208
+ ]
209
+ },
210
+ {
211
+ "format": "SELECT",
212
+ "name": "currencyDisplay",
213
+ "label": "Currency display",
214
+ "visibility": "(formatter = Currency)",
215
+ "defaultValue": "symbol",
216
+ "source": [
217
+ {
218
+ "key": "symbol",
219
+ "value": "Auto"
220
+ },
221
+ {
222
+ "key": "code",
223
+ "value": "Code"
224
+ },
225
+ {
226
+ "key": "name",
227
+ "value": "Name"
228
+ }
229
+ ]
230
+ },
231
+ {
232
+ "format": "SELECT",
233
+ "name": "negative",
234
+ "label": "Negative number display",
235
+ "visibility": "(formatter = Currency)",
236
+ "defaultValue": "minus-sign",
237
+ "source": [
238
+ {
239
+ "key": "minus-sign",
240
+ "value": "Standard"
241
+ },
242
+ {
243
+ "key": "parentheses",
244
+ "value": "Accounting"
245
+ }
246
+ ]
247
+ },
248
+ {
249
+ "format": "SELECT",
250
+ "name": "notation",
251
+ "label": "Notation",
252
+ "visibility": "(!negative = parentheses)&&(!formatter = Percentage)",
253
+ "defaultValue": "standard",
254
+ "source": [
255
+ {
256
+ "key": "standard",
257
+ "value": "Standard"
258
+ },
259
+ {
260
+ "key": "compact",
261
+ "value": "Compact"
262
+ }
263
+ ]
264
+ },
265
+ {
266
+ "name": "decimalPrecision",
267
+ "label": "Decimal places",
268
+ "format": "NUMBER",
269
+ "visibility": "(formatter = Decimal)||(formatter = Percentage)",
270
+ "min": 0,
271
+ "max": 20
272
+ },
273
+ {
274
+ "format": "SELECT",
275
+ "name": "currencyDecimalPrecision",
276
+ "label": "Decimal places shown",
277
+ "visibility": "(formatter = Currency)",
278
+ "defaultValue": "auto",
279
+ "source": [
280
+ {
281
+ "key": "auto",
282
+ "value": "Auto"
283
+ },
284
+ {
285
+ "key": "0",
286
+ "value": "None"
287
+ },
288
+ {
289
+ "key": "1",
290
+ "value": "1"
291
+ },
292
+ {
293
+ "key": "2",
294
+ "value": "2"
295
+ },
296
+ {
297
+ "key": "3",
298
+ "value": "3"
299
+ },
300
+ {
301
+ "key": "4",
302
+ "value": "4"
303
+ }
304
+ ]
305
+ },
306
+ {
307
+ "label": "Conditions",
308
+ "format": "GROUP",
309
+ "properties": [
310
+ {
311
+ "name": "required",
312
+ "label": "Required",
313
+ "format": "REQUIRED",
314
+ "visibility": "(!readOnly = true)"
315
+ },
316
+ {
317
+ "name": "disabled",
318
+ "label": "Disabled",
319
+ "format": "DISABLED",
320
+ "visibility": "(!readOnly = true)"
321
+ },
322
+ {
323
+ "name": "visibility",
324
+ "label": "Visibility",
325
+ "format": "VISIBILITY"
326
+ }
327
+ ]
328
+ },
329
+ {
330
+ "label": "Advanced",
331
+ "format": "GROUP",
332
+ "collapsible": true,
333
+ "properties": [
334
+ {
335
+ "name": "testId",
336
+ "label": "Test ID",
337
+ "format": "TEXT",
338
+ "ignorePattern": "[^-_\\p{N}\\p{L}]",
339
+ "includeAnnotations": false
340
+ }
341
+ ]
342
+ }
343
+ ],
344
+ "defaultConfig": {
345
+ "label": "@L $this.label"
346
+ }
347
+ }
@@ -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;