@xqmsg/ui-core 0.22.4 → 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 +328 -53
- 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 +330 -56
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -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 +286 -266
- 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,318 +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
|
-
.split(',')
|
|
58
|
-
.filter(Boolean)
|
|
59
|
-
);
|
|
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
|
+
);
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
behavior: 'smooth',
|
|
66
|
-
});
|
|
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([]);
|
|
67
64
|
}
|
|
68
|
-
}
|
|
69
|
-
}, [latestTokenElement, watchedValue]);
|
|
70
|
-
|
|
71
|
-
const onHandleKeyDown = (e: React.KeyboardEvent) => {
|
|
72
|
-
if (e.key === 'Enter') {
|
|
73
|
-
e.stopPropagation();
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
(e.key === 'Enter' ||
|
|
79
|
-
e.key === ',' ||
|
|
80
|
-
e.key === ';' ||
|
|
81
|
-
e.key === 'Tab') &&
|
|
82
|
-
localValue.trim().length
|
|
83
|
-
) {
|
|
84
|
-
if (
|
|
85
|
-
e.key === 'Enter' &&
|
|
86
|
-
!localValue.trim().length &&
|
|
87
|
-
tokenIndex !== null
|
|
88
|
-
) {
|
|
89
|
-
setLocalValue(lastestFormValueToArray[tokenIndex]);
|
|
90
65
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
)
|
|
96
|
-
|
|
66
|
+
if (watchedValue !== undefined && watchedValue?.length) {
|
|
67
|
+
setLatestFormValueToArray(
|
|
68
|
+
watchedValue
|
|
69
|
+
.split(';')
|
|
70
|
+
.join(',')
|
|
71
|
+
.split(',')
|
|
72
|
+
.filter(Boolean)
|
|
97
73
|
);
|
|
98
74
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
75
|
+
if (latestTokenElement) {
|
|
76
|
+
latestTokenElement.scrollIntoView({
|
|
77
|
+
block: 'end',
|
|
78
|
+
inline: 'center',
|
|
79
|
+
behavior: 'smooth',
|
|
80
|
+
});
|
|
81
|
+
}
|
|
105
82
|
}
|
|
83
|
+
}, [latestTokenElement, watchedValue]);
|
|
106
84
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
85
|
+
const handleOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
86
|
+
if (tokenIndex === null) {
|
|
87
|
+
setLocalValue(
|
|
88
|
+
e.target.value
|
|
111
89
|
.trim()
|
|
112
|
-
.
|
|
113
|
-
.
|
|
114
|
-
.
|
|
115
|
-
|
|
116
|
-
|
|
90
|
+
.replace(',', '')
|
|
91
|
+
.replace(';', '').length
|
|
92
|
+
? e.target.value
|
|
93
|
+
: ''
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
117
97
|
|
|
118
|
-
|
|
98
|
+
const onHandleKeyDown = (e: React.KeyboardEvent) => {
|
|
99
|
+
if (e.key === 'Enter') {
|
|
100
|
+
e.stopPropagation();
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
}
|
|
119
103
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
+
);
|
|
125
119
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
);
|
|
120
|
+
setValue(name as string, filteredUniqueValues.toString(), {
|
|
121
|
+
shouldValidate: true,
|
|
122
|
+
shouldDirty: true,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return setTokenIndex(null);
|
|
126
|
+
}
|
|
134
127
|
|
|
135
128
|
const filteredUniqueValues = Array.from(
|
|
136
|
-
new Set(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
129
|
+
new Set([
|
|
130
|
+
...lastestFormValueToArray,
|
|
131
|
+
...localValue
|
|
132
|
+
.trim()
|
|
133
|
+
.split(';')
|
|
134
|
+
.join(',')
|
|
135
|
+
.split(','),
|
|
136
|
+
])
|
|
141
137
|
);
|
|
142
138
|
|
|
143
|
-
|
|
139
|
+
setLocalValue('');
|
|
140
|
+
|
|
141
|
+
return setValue(name as string, filteredUniqueValues.toString(), {
|
|
144
142
|
shouldValidate: true,
|
|
145
143
|
shouldDirty: true,
|
|
146
144
|
});
|
|
147
|
-
|
|
148
|
-
return setTokenIndex(null);
|
|
149
145
|
}
|
|
150
146
|
|
|
151
|
-
if (
|
|
152
|
-
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
|
+
);
|
|
153
155
|
|
|
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
|
+
});
|
|
168
|
+
|
|
169
|
+
return setTokenIndex(null);
|
|
156
170
|
}
|
|
157
171
|
|
|
158
|
-
|
|
172
|
+
if (e.key === 'ArrowLeft') {
|
|
173
|
+
if (tokenIndex === 0) return;
|
|
159
174
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
175
|
+
if (!tokenIndex) {
|
|
176
|
+
return setTokenIndex(lastestFormValueToArray.length - 1);
|
|
177
|
+
}
|
|
163
178
|
|
|
164
|
-
|
|
179
|
+
setTokenIndex(prevTokenIndex => (prevTokenIndex as number) - 1);
|
|
165
180
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
170
|
-
}
|
|
181
|
+
const tokenElement = document.getElementById(
|
|
182
|
+
`${name}_token_${tokenIndex}`
|
|
183
|
+
);
|
|
171
184
|
|
|
172
|
-
|
|
173
|
-
if (tokenIndex === null) return;
|
|
185
|
+
if (!tokenElement || !scrollRef.current) return;
|
|
174
186
|
|
|
175
|
-
|
|
176
|
-
|
|
187
|
+
return scrollRef.current.scrollBy({
|
|
188
|
+
left: -1 * tokenElement.getBoundingClientRect().width,
|
|
189
|
+
behavior: 'smooth',
|
|
190
|
+
});
|
|
177
191
|
}
|
|
178
|
-
setTokenIndex(prevTokenIndex => (prevTokenIndex as number) + 1);
|
|
179
|
-
|
|
180
|
-
const tokenElement = document.getElementById(
|
|
181
|
-
`${name}_token_${tokenIndex}`
|
|
182
|
-
);
|
|
183
192
|
|
|
184
|
-
if (
|
|
193
|
+
if (e.key === 'ArrowRight') {
|
|
194
|
+
if (tokenIndex === null) return;
|
|
185
195
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
};
|
|
196
|
+
if (tokenIndex === lastestFormValueToArray.length - 1) {
|
|
197
|
+
return setTokenIndex(null);
|
|
198
|
+
}
|
|
199
|
+
setTokenIndex(prevTokenIndex => (prevTokenIndex as number) + 1);
|
|
193
200
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
);
|
|
201
|
+
const tokenElement = document.getElementById(
|
|
202
|
+
`${name}_token_${tokenIndex}`
|
|
203
|
+
);
|
|
198
204
|
|
|
199
|
-
|
|
205
|
+
if (!tokenElement || !scrollRef.current) return;
|
|
200
206
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
207
|
+
return scrollRef.current.scrollBy({
|
|
208
|
+
left: tokenElement.getBoundingClientRect().width,
|
|
209
|
+
behavior: 'smooth',
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
206
214
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
new Set([...lastestFormValueToArray, ...localValue.trim().split(',')])
|
|
215
|
+
const onRemoveTag = (index: number) => {
|
|
216
|
+
const filteredUniqueValues = lastestFormValueToArray.filter(
|
|
217
|
+
(_, i) => i !== index
|
|
211
218
|
);
|
|
212
219
|
|
|
220
|
+
setLatestFormValueToArray(filteredUniqueValues);
|
|
221
|
+
|
|
213
222
|
setValue(name as string, filteredUniqueValues.toString(), {
|
|
214
223
|
shouldValidate: true,
|
|
215
224
|
shouldDirty: true,
|
|
216
225
|
});
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
setIsFocussed(false);
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
useOutsideClick({
|
|
223
|
-
ref: inputWrapperRef,
|
|
224
|
-
handler: () => {
|
|
225
|
-
onBlur();
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
return (
|
|
230
|
-
<Box position="relative">
|
|
231
|
-
<Flex
|
|
232
|
-
fontSize="13px"
|
|
233
|
-
border={isFocussed ? '2px solid' : '.5px solid'}
|
|
234
|
-
borderColor={isFocussed ? colors.border.focus : colors.border.default}
|
|
235
|
-
pl="8px"
|
|
236
|
-
borderRadius="4px"
|
|
237
|
-
alignItems="center"
|
|
238
|
-
justifyContent="space-between"
|
|
239
|
-
onClick={() => {
|
|
240
|
-
if (isFocussed && tokenIndex !== null) {
|
|
241
|
-
setTokenIndex(null);
|
|
242
|
-
}
|
|
226
|
+
};
|
|
243
227
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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">
|
|
253
253
|
<Flex
|
|
254
|
-
|
|
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'}
|
|
255
259
|
alignItems="center"
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
260
|
+
justifyContent="space-between"
|
|
261
|
+
onClick={() => {
|
|
262
|
+
if (isFocussed && tokenIndex !== null) {
|
|
263
|
+
setTokenIndex(null);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (!disabled) {
|
|
267
|
+
inputRef.current?.focus();
|
|
268
|
+
}
|
|
262
269
|
}}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}}
|
|
268
|
-
ref={scrollRef}
|
|
269
|
-
zIndex={100}
|
|
270
|
-
onKeyDown={onHandleKeyDown}
|
|
270
|
+
bg={disabled ? colors.fill.light.quaternary : '#ffffff'}
|
|
271
|
+
cursor={disabled ? 'not-allowed' : 'pointer'}
|
|
272
|
+
ref={inputWrapperRef}
|
|
273
|
+
h={isMobile ? '48px' : '26px'}
|
|
271
274
|
>
|
|
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
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
)
|
|
327
|
-
}
|
|
328
|
-
ref={inputRef}
|
|
329
|
-
onFocus={() => setIsFocussed(true)}
|
|
330
|
-
onBlur={() => {
|
|
331
|
-
setIsFocussed(false);
|
|
332
|
-
return setTokenIndex(null);
|
|
333
|
-
}}
|
|
334
|
-
/>
|
|
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}
|
|
335
329
|
</Flex>
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
+
);
|
|
341
361
|
|
|
342
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' && (
|