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