@xqmsg/ui-core 0.22.3 → 0.23.1-rc.0
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.
- package/dist/components/form/FormTypes.d.ts +2 -0
- package/dist/components/input/StackedCheckbox/StackedCheckbox.d.ts +3 -2
- package/dist/components/input/StackedInput/StackedInput.d.ts +1 -0
- package/dist/components/input/StackedPilledInput/index.d.ts +2 -0
- package/dist/components/input/StackedTextarea/StackedTextarea.d.ts +3 -0
- package/dist/components/input/components/token/index.d.ts +1 -0
- package/dist/components/input/index.d.ts +3 -2
- package/dist/components/select/index.d.ts +27 -0
- package/dist/index.d.ts +1 -0
- package/dist/theme/components/button.d.ts +116 -0
- package/dist/theme/components/checkbox.d.ts +28 -0
- package/dist/theme/components/input.d.ts +12 -0
- package/dist/theme/components/select.d.ts +12 -0
- package/dist/theme/components/textarea.d.ts +66 -0
- package/dist/ui-core.cjs.development.js +330 -55
- package/dist/ui-core.cjs.development.js.map +1 -1
- package/dist/ui-core.cjs.production.min.js +1 -1
- package/dist/ui-core.cjs.production.min.js.map +1 -1
- package/dist/ui-core.esm.js +332 -58
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +2 -1
- package/src/components/button/Button.stories.tsx +92 -27
- package/src/components/form/FormTypes.ts +2 -0
- package/src/components/form/section/index.tsx +2 -0
- package/src/components/input/Input.stories.tsx +66 -0
- package/src/components/input/StackedCheckbox/StackedCheckbox.tsx +12 -4
- package/src/components/input/StackedInput/StackedInput.tsx +5 -0
- package/src/components/input/StackedPilledInput/index.tsx +287 -251
- package/src/components/input/StackedTextarea/StackedTextarea.tsx +29 -5
- package/src/components/input/components/dropdown/index.tsx +1 -1
- package/src/components/input/components/token/index.tsx +6 -5
- package/src/components/input/index.tsx +22 -9
- package/src/components/select/index.tsx +184 -0
- package/src/components/tabs/TabsWrapper.stories.tsx +1 -1
- package/src/index.tsx +3 -0
- package/src/theme/components/button.ts +67 -0
- package/src/theme/components/checkbox.ts +25 -0
- package/src/theme/components/input.ts +15 -1
- package/src/theme/components/textarea.ts +20 -0
- package/src/theme/customXQChakraTheme.ts +2 -0
|
@@ -17,6 +17,8 @@ export interface StackedPilledInputProps extends InputFieldProps {
|
|
|
17
17
|
setError: UseFormSetError<FieldValues>;
|
|
18
18
|
clearErrors: UseFormClearErrors<FieldValues>;
|
|
19
19
|
control: Control<FieldValues, any>;
|
|
20
|
+
separators?: string[];
|
|
21
|
+
variant?: string;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
/**
|
|
@@ -25,302 +27,336 @@ export interface StackedPilledInputProps extends InputFieldProps {
|
|
|
25
27
|
const StackedPilledInput = React.forwardRef<
|
|
26
28
|
HTMLInputElement,
|
|
27
29
|
StackedPilledInputProps
|
|
28
|
-
>(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
30
|
+
>(
|
|
31
|
+
(
|
|
32
|
+
{
|
|
33
|
+
name,
|
|
34
|
+
setValue,
|
|
35
|
+
control,
|
|
36
|
+
placeholder,
|
|
37
|
+
disabled,
|
|
38
|
+
separators = ['Enter', ' ', ',', ';', 'Tab'],
|
|
39
|
+
variant,
|
|
40
|
+
},
|
|
41
|
+
_ref
|
|
42
|
+
) => {
|
|
43
|
+
const watchedValue = useWatch({ control, name: name as string });
|
|
44
|
+
const [lastestFormValueToArray, setLatestFormValueToArray] = useState<
|
|
45
|
+
string[]
|
|
46
|
+
>([]);
|
|
47
|
+
|
|
48
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
49
|
+
const inputWrapperRef = useRef(null);
|
|
50
|
+
const scrollRef = useRef<HTMLDivElement>(null);
|
|
51
|
+
|
|
52
|
+
const [tokenIndex, setTokenIndex] = useState<number | null>(null);
|
|
53
|
+
const [isFocussed, setIsFocussed] = useState(false);
|
|
54
|
+
const [localValue, setLocalValue] = useState('');
|
|
55
|
+
|
|
56
|
+
const latestTokenElement = document.getElementById(
|
|
57
|
+
`${name}_token_${lastestFormValueToArray.length - 1}`
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// gets latest watched form value (common delimited) from RHF state and creates a list
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (watchedValue !== undefined && !watchedValue.length) {
|
|
63
|
+
setLatestFormValueToArray([]);
|
|
61
64
|
}
|
|
62
|
-
}
|
|
63
|
-
}, [latestTokenElement, watchedValue]);
|
|
64
|
-
|
|
65
|
-
const onHandleKeyDown = (e: React.KeyboardEvent) => {
|
|
66
|
-
if (e.key === 'Enter') {
|
|
67
|
-
e.stopPropagation();
|
|
68
|
-
e.preventDefault();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
(e.key === ' ' ||
|
|
73
|
-
e.key === 'Enter' ||
|
|
74
|
-
e.key === ',' ||
|
|
75
|
-
e.key === 'Tab') &&
|
|
76
|
-
localValue.trim().length
|
|
77
|
-
) {
|
|
78
|
-
if (
|
|
79
|
-
e.key === 'Enter' &&
|
|
80
|
-
!localValue.trim().length &&
|
|
81
|
-
tokenIndex !== null
|
|
82
|
-
) {
|
|
83
|
-
setLocalValue(lastestFormValueToArray[tokenIndex]);
|
|
84
65
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
)
|
|
90
|
-
|
|
66
|
+
if (watchedValue !== undefined && watchedValue?.length) {
|
|
67
|
+
setLatestFormValueToArray(
|
|
68
|
+
watchedValue
|
|
69
|
+
.split(';')
|
|
70
|
+
.join(',')
|
|
71
|
+
.split(',')
|
|
72
|
+
.filter(Boolean)
|
|
91
73
|
);
|
|
92
74
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
75
|
+
if (latestTokenElement) {
|
|
76
|
+
latestTokenElement.scrollIntoView({
|
|
77
|
+
block: 'end',
|
|
78
|
+
inline: 'center',
|
|
79
|
+
behavior: 'smooth',
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}, [latestTokenElement, watchedValue]);
|
|
97
84
|
|
|
98
|
-
|
|
85
|
+
const handleOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
86
|
+
if (tokenIndex === null) {
|
|
87
|
+
setLocalValue(
|
|
88
|
+
e.target.value
|
|
89
|
+
.trim()
|
|
90
|
+
.replace(',', '')
|
|
91
|
+
.replace(';', '').length
|
|
92
|
+
? e.target.value
|
|
93
|
+
: ''
|
|
94
|
+
);
|
|
99
95
|
}
|
|
96
|
+
};
|
|
100
97
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
const onHandleKeyDown = (e: React.KeyboardEvent) => {
|
|
99
|
+
if (e.key === 'Enter') {
|
|
100
|
+
e.stopPropagation();
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
}
|
|
104
103
|
|
|
105
|
-
|
|
104
|
+
if (separators.includes(e.key)) {
|
|
105
|
+
if (
|
|
106
|
+
e.key === 'Enter' &&
|
|
107
|
+
!localValue.trim().length &&
|
|
108
|
+
tokenIndex !== null
|
|
109
|
+
) {
|
|
110
|
+
setLocalValue(lastestFormValueToArray[tokenIndex]);
|
|
111
|
+
|
|
112
|
+
const filteredUniqueValues = Array.from(
|
|
113
|
+
new Set(
|
|
114
|
+
lastestFormValueToArray.filter(
|
|
115
|
+
value => value !== lastestFormValueToArray[tokenIndex]
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
);
|
|
106
119
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
120
|
+
setValue(name as string, filteredUniqueValues.toString(), {
|
|
121
|
+
shouldValidate: true,
|
|
122
|
+
shouldDirty: true,
|
|
123
|
+
});
|
|
112
124
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
setLocalValue(
|
|
116
|
-
lastestFormValueToArray[tokenIndex].substring(
|
|
117
|
-
0,
|
|
118
|
-
lastestFormValueToArray[tokenIndex].length
|
|
119
|
-
)
|
|
120
|
-
);
|
|
125
|
+
return setTokenIndex(null);
|
|
126
|
+
}
|
|
121
127
|
|
|
122
128
|
const filteredUniqueValues = Array.from(
|
|
123
|
-
new Set(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
new Set([
|
|
130
|
+
...lastestFormValueToArray,
|
|
131
|
+
...localValue
|
|
132
|
+
.trim()
|
|
133
|
+
.split(';')
|
|
134
|
+
.join(',')
|
|
135
|
+
.split(','),
|
|
136
|
+
])
|
|
128
137
|
);
|
|
129
138
|
|
|
130
|
-
|
|
139
|
+
setLocalValue('');
|
|
140
|
+
|
|
141
|
+
return setValue(name as string, filteredUniqueValues.toString(), {
|
|
131
142
|
shouldValidate: true,
|
|
132
143
|
shouldDirty: true,
|
|
133
144
|
});
|
|
134
|
-
|
|
135
|
-
return setTokenIndex(null);
|
|
136
145
|
}
|
|
137
146
|
|
|
138
|
-
if (
|
|
139
|
-
if (
|
|
147
|
+
if (!localValue.trim().length && lastestFormValueToArray.length) {
|
|
148
|
+
if (e.key === 'Backspace' && tokenIndex !== null) {
|
|
149
|
+
setLocalValue(
|
|
150
|
+
lastestFormValueToArray[tokenIndex].substring(
|
|
151
|
+
0,
|
|
152
|
+
lastestFormValueToArray[tokenIndex].length
|
|
153
|
+
)
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const filteredUniqueValues = Array.from(
|
|
157
|
+
new Set(
|
|
158
|
+
[...lastestFormValueToArray].filter(
|
|
159
|
+
value => value !== lastestFormValueToArray[tokenIndex]
|
|
160
|
+
)
|
|
161
|
+
)
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
setValue(name as string, filteredUniqueValues.toString(), {
|
|
165
|
+
shouldValidate: true,
|
|
166
|
+
shouldDirty: true,
|
|
167
|
+
});
|
|
140
168
|
|
|
141
|
-
|
|
142
|
-
return setTokenIndex(lastestFormValueToArray.length - 1);
|
|
169
|
+
return setTokenIndex(null);
|
|
143
170
|
}
|
|
144
171
|
|
|
145
|
-
|
|
172
|
+
if (e.key === 'ArrowLeft') {
|
|
173
|
+
if (tokenIndex === 0) return;
|
|
146
174
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
175
|
+
if (!tokenIndex) {
|
|
176
|
+
return setTokenIndex(lastestFormValueToArray.length - 1);
|
|
177
|
+
}
|
|
150
178
|
|
|
151
|
-
|
|
179
|
+
setTokenIndex(prevTokenIndex => (prevTokenIndex as number) - 1);
|
|
152
180
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
});
|
|
157
|
-
}
|
|
181
|
+
const tokenElement = document.getElementById(
|
|
182
|
+
`${name}_token_${tokenIndex}`
|
|
183
|
+
);
|
|
158
184
|
|
|
159
|
-
|
|
160
|
-
if (tokenIndex === null) return;
|
|
185
|
+
if (!tokenElement || !scrollRef.current) return;
|
|
161
186
|
|
|
162
|
-
|
|
163
|
-
|
|
187
|
+
return scrollRef.current.scrollBy({
|
|
188
|
+
left: -1 * tokenElement.getBoundingClientRect().width,
|
|
189
|
+
behavior: 'smooth',
|
|
190
|
+
});
|
|
164
191
|
}
|
|
165
|
-
setTokenIndex(prevTokenIndex => (prevTokenIndex as number) + 1);
|
|
166
|
-
|
|
167
|
-
const tokenElement = document.getElementById(
|
|
168
|
-
`${name}_token_${tokenIndex}`
|
|
169
|
-
);
|
|
170
192
|
|
|
171
|
-
if (
|
|
193
|
+
if (e.key === 'ArrowRight') {
|
|
194
|
+
if (tokenIndex === null) return;
|
|
172
195
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
};
|
|
196
|
+
if (tokenIndex === lastestFormValueToArray.length - 1) {
|
|
197
|
+
return setTokenIndex(null);
|
|
198
|
+
}
|
|
199
|
+
setTokenIndex(prevTokenIndex => (prevTokenIndex as number) + 1);
|
|
180
200
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
);
|
|
201
|
+
const tokenElement = document.getElementById(
|
|
202
|
+
`${name}_token_${tokenIndex}`
|
|
203
|
+
);
|
|
185
204
|
|
|
186
|
-
|
|
205
|
+
if (!tokenElement || !scrollRef.current) return;
|
|
187
206
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
207
|
+
return scrollRef.current.scrollBy({
|
|
208
|
+
left: tokenElement.getBoundingClientRect().width,
|
|
209
|
+
behavior: 'smooth',
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
193
214
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
new Set([...lastestFormValueToArray, ...localValue.trim().split(',')])
|
|
215
|
+
const onRemoveTag = (index: number) => {
|
|
216
|
+
const filteredUniqueValues = lastestFormValueToArray.filter(
|
|
217
|
+
(_, i) => i !== index
|
|
198
218
|
);
|
|
199
219
|
|
|
220
|
+
setLatestFormValueToArray(filteredUniqueValues);
|
|
221
|
+
|
|
200
222
|
setValue(name as string, filteredUniqueValues.toString(), {
|
|
201
223
|
shouldValidate: true,
|
|
202
224
|
shouldDirty: true,
|
|
203
225
|
});
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
setIsFocussed(false);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
useOutsideClick({
|
|
210
|
-
ref: inputWrapperRef,
|
|
211
|
-
handler: () => {
|
|
212
|
-
onBlur();
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
return (
|
|
217
|
-
<Box position="relative">
|
|
218
|
-
<Flex
|
|
219
|
-
fontSize="13px"
|
|
220
|
-
border={isFocussed ? '2px solid' : '.5px solid'}
|
|
221
|
-
borderColor={isFocussed ? colors.border.focus : colors.border.default}
|
|
222
|
-
pl="8px"
|
|
223
|
-
borderRadius="4px"
|
|
224
|
-
alignItems="center"
|
|
225
|
-
justifyContent="space-between"
|
|
226
|
-
onClick={() => {
|
|
227
|
-
if (isFocussed && tokenIndex !== null) {
|
|
228
|
-
setTokenIndex(null);
|
|
229
|
-
}
|
|
226
|
+
};
|
|
230
227
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
228
|
+
const onBlur = () => {
|
|
229
|
+
if (localValue.trim().length) {
|
|
230
|
+
const filteredUniqueValues = Array.from(
|
|
231
|
+
new Set([...lastestFormValueToArray, ...localValue.trim().split(',')])
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
setValue(name as string, filteredUniqueValues.toString(), {
|
|
235
|
+
shouldValidate: true,
|
|
236
|
+
shouldDirty: true,
|
|
237
|
+
});
|
|
238
|
+
setLocalValue('');
|
|
239
|
+
}
|
|
240
|
+
setIsFocussed(false);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
useOutsideClick({
|
|
244
|
+
ref: inputWrapperRef,
|
|
245
|
+
handler: () => {
|
|
246
|
+
onBlur();
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
const isMobile = variant === 'mobile';
|
|
250
|
+
|
|
251
|
+
return (
|
|
252
|
+
<Box position="relative">
|
|
240
253
|
<Flex
|
|
241
|
-
|
|
254
|
+
fontSize={isMobile ? '17px' : '13px'}
|
|
255
|
+
border={isFocussed ? '2px solid' : '.5px solid'}
|
|
256
|
+
borderColor={isFocussed ? colors.border.focus : colors.border.default}
|
|
257
|
+
pl="8px"
|
|
258
|
+
borderRadius={isMobile ? '0' : '4px'}
|
|
242
259
|
alignItems="center"
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
260
|
+
justifyContent="space-between"
|
|
261
|
+
onClick={() => {
|
|
262
|
+
if (isFocussed && tokenIndex !== null) {
|
|
263
|
+
setTokenIndex(null);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (!disabled) {
|
|
267
|
+
inputRef.current?.focus();
|
|
268
|
+
}
|
|
249
269
|
}}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}}
|
|
255
|
-
ref={scrollRef}
|
|
256
|
-
zIndex={100}
|
|
257
|
-
onKeyDown={onHandleKeyDown}
|
|
270
|
+
bg={disabled ? colors.fill.light.quaternary : '#ffffff'}
|
|
271
|
+
cursor={disabled ? 'not-allowed' : 'pointer'}
|
|
272
|
+
ref={inputWrapperRef}
|
|
273
|
+
h={isMobile ? '48px' : '26px'}
|
|
258
274
|
>
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
onFocus={() => setIsFocussed(true)}
|
|
314
|
-
onBlur={() => {
|
|
315
|
-
setIsFocussed(false);
|
|
316
|
-
return setTokenIndex(null);
|
|
317
|
-
}}
|
|
318
|
-
/>
|
|
275
|
+
<Flex
|
|
276
|
+
h="100%"
|
|
277
|
+
alignItems="center"
|
|
278
|
+
overflowX="scroll"
|
|
279
|
+
overflowY="hidden"
|
|
280
|
+
maxWidth={isFocussed ? '80%' : '100%'}
|
|
281
|
+
style={{
|
|
282
|
+
scrollbarWidth: 'none' /* Firefox */,
|
|
283
|
+
msOverflowStyle: 'none',
|
|
284
|
+
}}
|
|
285
|
+
sx={{
|
|
286
|
+
'::-webkit-scrollbar': {
|
|
287
|
+
display: 'none',
|
|
288
|
+
},
|
|
289
|
+
}}
|
|
290
|
+
ref={scrollRef}
|
|
291
|
+
zIndex={100}
|
|
292
|
+
onKeyDown={onHandleKeyDown}
|
|
293
|
+
>
|
|
294
|
+
{lastestFormValueToArray.length
|
|
295
|
+
? lastestFormValueToArray.map((label, index) => (
|
|
296
|
+
<Box
|
|
297
|
+
key={index}
|
|
298
|
+
mr="4px"
|
|
299
|
+
border={
|
|
300
|
+
tokenIndex === index
|
|
301
|
+
? `1px solid ${colors.border.focus}`
|
|
302
|
+
: 'none'
|
|
303
|
+
}
|
|
304
|
+
borderRadius="full"
|
|
305
|
+
onClick={() => setTokenIndex(index)}
|
|
306
|
+
width="100%"
|
|
307
|
+
id={`${name}_token_${index}`}
|
|
308
|
+
>
|
|
309
|
+
<Token
|
|
310
|
+
label={label}
|
|
311
|
+
onDelete={(e: any) => {
|
|
312
|
+
e.stopPropagation();
|
|
313
|
+
e.preventDefault();
|
|
314
|
+
onRemoveTag(index);
|
|
315
|
+
}}
|
|
316
|
+
isMobile={isMobile}
|
|
317
|
+
/>
|
|
318
|
+
</Box>
|
|
319
|
+
))
|
|
320
|
+
: null}
|
|
321
|
+
{!lastestFormValueToArray.length && !isFocussed ? (
|
|
322
|
+
<Text
|
|
323
|
+
color={colors.label.secondary.light}
|
|
324
|
+
fontSize={isMobile ? '17px' : '13px'}
|
|
325
|
+
>
|
|
326
|
+
{placeholder}
|
|
327
|
+
</Text>
|
|
328
|
+
) : null}
|
|
319
329
|
</Flex>
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
330
|
+
{!disabled && (
|
|
331
|
+
<Flex flex={1} minWidth={isFocussed && !tokenIndex ? '20%' : 0}>
|
|
332
|
+
<Input
|
|
333
|
+
onKeyDown={onHandleKeyDown}
|
|
334
|
+
type="text"
|
|
335
|
+
padding={0}
|
|
336
|
+
alignContent="flex-start"
|
|
337
|
+
float="right"
|
|
338
|
+
border="none"
|
|
339
|
+
height="auto"
|
|
340
|
+
color={
|
|
341
|
+
tokenIndex !== null ? 'transparent' : colors.label.primary
|
|
342
|
+
}
|
|
343
|
+
_focus={{ boxShadow: 'none !important' }}
|
|
344
|
+
value={localValue}
|
|
345
|
+
onChange={handleOnChange}
|
|
346
|
+
ref={inputRef}
|
|
347
|
+
onFocus={() => setIsFocussed(true)}
|
|
348
|
+
onBlur={() => {
|
|
349
|
+
setIsFocussed(false);
|
|
350
|
+
return setTokenIndex(null);
|
|
351
|
+
}}
|
|
352
|
+
variant={variant}
|
|
353
|
+
/>
|
|
354
|
+
</Flex>
|
|
355
|
+
)}
|
|
356
|
+
</Flex>
|
|
357
|
+
</Box>
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
);
|
|
325
361
|
|
|
326
362
|
export default StackedPilledInput;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Textarea } from '@chakra-ui/react';
|
|
2
|
+
import { Flex, Textarea } from '@chakra-ui/react';
|
|
3
3
|
import { TextareaFieldProps } from '../InputTypes';
|
|
4
4
|
|
|
5
|
-
export interface StackedTextareaProps extends TextareaFieldProps {
|
|
5
|
+
export interface StackedTextareaProps extends TextareaFieldProps {
|
|
6
|
+
isRequired?: boolean;
|
|
7
|
+
allowDefault?: boolean;
|
|
8
|
+
variant: string;
|
|
9
|
+
}
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* A functional React component utilized to render the `StackedTextarea` component.
|
|
@@ -10,14 +14,34 @@ export interface StackedTextareaProps extends TextareaFieldProps {}
|
|
|
10
14
|
const StackedTextarea = React.forwardRef<
|
|
11
15
|
HTMLTextAreaElement,
|
|
12
16
|
StackedTextareaProps
|
|
13
|
-
>(({ ...props }, _ref) => {
|
|
17
|
+
>(({ isRequired, allowDefault, variant, ...props }, _ref) => {
|
|
18
|
+
if (variant === 'mobile') {
|
|
19
|
+
return (
|
|
20
|
+
<Flex>
|
|
21
|
+
{allowDefault}
|
|
22
|
+
<Textarea
|
|
23
|
+
ref={_ref}
|
|
24
|
+
{...props}
|
|
25
|
+
variant={variant}
|
|
26
|
+
fontSize="17px"
|
|
27
|
+
onKeyDown={e => {
|
|
28
|
+
if (e.key === 'Enter' && !allowDefault) {
|
|
29
|
+
e.stopPropagation();
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
}
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
</Flex>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
14
37
|
return (
|
|
15
38
|
<Textarea
|
|
16
39
|
ref={_ref}
|
|
17
40
|
{...props}
|
|
18
|
-
|
|
41
|
+
variant={variant}
|
|
42
|
+
fontSize={variant === '' ? '13px' : '17px'}
|
|
19
43
|
onKeyDown={e => {
|
|
20
|
-
if (e.key === 'Enter') {
|
|
44
|
+
if (e.key === 'Enter' && !allowDefault) {
|
|
21
45
|
e.stopPropagation();
|
|
22
46
|
e.preventDefault();
|
|
23
47
|
}
|
|
@@ -23,7 +23,7 @@ export const Dropdown: React.FC<DropdownProps> = ({
|
|
|
23
23
|
}) => {
|
|
24
24
|
const DropdownContent = useMemo(() => {
|
|
25
25
|
return options.map((option, idx) => (
|
|
26
|
-
<Box key={idx} width="100%">
|
|
26
|
+
<Box key={idx} width="100%" role="combobox">
|
|
27
27
|
{option.value === 'section_header' &&
|
|
28
28
|
options[idx + 1] &&
|
|
29
29
|
options[idx + 1].value !== 'section_header' && (
|