@xqmsg/ui-core 0.14.0 → 0.14.2
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/input/StackedMultiSelect/index.d.ts +4 -1
- package/dist/components/input/StackedPilledInput/index.d.ts +4 -1
- package/dist/components/input/index.d.ts +4 -2
- package/dist/ui-core.cjs.development.js +119 -29
- 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 +122 -32
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/form/section/index.tsx +2 -0
- package/src/components/input/Input.stories.tsx +10 -0
- package/src/components/input/StackedMultiSelect/index.tsx +153 -101
- package/src/components/input/StackedPilledInput/index.tsx +231 -191
- package/src/components/input/StackedSelect/StackedSelect.tsx +9 -10
- package/src/components/input/components/dropdown/index.tsx +7 -2
- package/src/components/input/components/token/assets/svg/close.svg +1 -1
- package/src/components/input/components/token/index.tsx +15 -9
- package/src/components/input/index.tsx +155 -160
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import StackedCheckBoxGroup from './StackedCheckbox/StackedCheckboxGroup';
|
|
3
3
|
import StackedInput from './StackedInput/StackedInput';
|
|
4
4
|
import StackedRadioGroup from './StackedRadio/StackedRadioGroup';
|
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
Path,
|
|
18
18
|
PathValue,
|
|
19
19
|
RefCallBack,
|
|
20
|
+
UseFormClearErrors,
|
|
21
|
+
UseFormSetError,
|
|
20
22
|
UseFormSetValue,
|
|
21
23
|
} from 'react-hook-form';
|
|
22
24
|
import StackedMultiSelect from './StackedMultiSelect';
|
|
@@ -39,6 +41,8 @@ export interface InputProps<T extends FieldValues> extends ValidationProps {
|
|
|
39
41
|
onChange?: (value?: string) => void;
|
|
40
42
|
disabled?: boolean;
|
|
41
43
|
setValue: UseFormSetValue<T>;
|
|
44
|
+
setError: UseFormSetError<T>;
|
|
45
|
+
clearErrors: UseFormClearErrors<T>;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
/**
|
|
@@ -63,166 +67,157 @@ export function Input<T extends FieldValues>({
|
|
|
63
67
|
disabled,
|
|
64
68
|
onChange,
|
|
65
69
|
setValue,
|
|
70
|
+
setError,
|
|
71
|
+
clearErrors,
|
|
66
72
|
}: InputProps<T>) {
|
|
67
|
-
const selectedInputField =
|
|
68
|
-
(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
disabled,
|
|
216
|
-
inputType,
|
|
217
|
-
isInvalid,
|
|
218
|
-
isRequired,
|
|
219
|
-
maxLength,
|
|
220
|
-
name,
|
|
221
|
-
options,
|
|
222
|
-
placeholder,
|
|
223
|
-
setValue,
|
|
224
|
-
]
|
|
225
|
-
);
|
|
73
|
+
const selectedInputField = (
|
|
74
|
+
onChange: () => void,
|
|
75
|
+
onBlur: () => void,
|
|
76
|
+
ref: RefCallBack,
|
|
77
|
+
value: string
|
|
78
|
+
) => {
|
|
79
|
+
switch (inputType) {
|
|
80
|
+
case 'text':
|
|
81
|
+
return (
|
|
82
|
+
<StackedInput
|
|
83
|
+
className={`input-${inputType} ${className ?? ''}`}
|
|
84
|
+
aria-label={ariaLabel}
|
|
85
|
+
name={name}
|
|
86
|
+
id={name}
|
|
87
|
+
placeholder={placeholder}
|
|
88
|
+
maxLength={maxLength}
|
|
89
|
+
isRequired={isRequired}
|
|
90
|
+
isInvalid={isInvalid}
|
|
91
|
+
onChange={onChange}
|
|
92
|
+
onBlur={onBlur}
|
|
93
|
+
ref={ref}
|
|
94
|
+
disabled={disabled}
|
|
95
|
+
value={value}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
case 'radio':
|
|
99
|
+
return (
|
|
100
|
+
<StackedRadioGroup
|
|
101
|
+
className={`input-${inputType} ${className ?? ''}`}
|
|
102
|
+
name={name}
|
|
103
|
+
id={name}
|
|
104
|
+
isInvalid={isInvalid}
|
|
105
|
+
options={options as FieldOptions}
|
|
106
|
+
onChange={onChange}
|
|
107
|
+
onBlur={onBlur}
|
|
108
|
+
ref={ref}
|
|
109
|
+
disabled={disabled}
|
|
110
|
+
value={value}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
case 'select':
|
|
114
|
+
return (
|
|
115
|
+
<StackedSelect
|
|
116
|
+
className={`input-${inputType} ${className ?? ''}`}
|
|
117
|
+
name={name}
|
|
118
|
+
id={name}
|
|
119
|
+
isRequired={isRequired}
|
|
120
|
+
isInvalid={isInvalid}
|
|
121
|
+
options={options as FieldOptions}
|
|
122
|
+
handleOnChange={onChange}
|
|
123
|
+
onBlur={onBlur}
|
|
124
|
+
setValue={setValue as UseFormSetValue<FieldValues>}
|
|
125
|
+
control={control as Control<FieldValues, any>}
|
|
126
|
+
ref={ref}
|
|
127
|
+
disabled={disabled}
|
|
128
|
+
value={value}
|
|
129
|
+
defaultValue={defaultValue}
|
|
130
|
+
placeholder={placeholder}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
case 'textarea':
|
|
134
|
+
return (
|
|
135
|
+
<StackedTextarea
|
|
136
|
+
className={`input-${inputType} ${className ?? ''}`}
|
|
137
|
+
name={name}
|
|
138
|
+
id={name}
|
|
139
|
+
maxLength={maxLength}
|
|
140
|
+
isInvalid={isInvalid}
|
|
141
|
+
onChange={onChange}
|
|
142
|
+
onBlur={onBlur}
|
|
143
|
+
ref={ref}
|
|
144
|
+
disabled={disabled}
|
|
145
|
+
value={value}
|
|
146
|
+
/>
|
|
147
|
+
);
|
|
148
|
+
case 'checkbox':
|
|
149
|
+
return (
|
|
150
|
+
<StackedCheckBoxGroup
|
|
151
|
+
className={`input-${inputType} ${className ?? ''}`}
|
|
152
|
+
name={name}
|
|
153
|
+
id={name}
|
|
154
|
+
isInvalid={isInvalid}
|
|
155
|
+
options={options as FieldOptions}
|
|
156
|
+
onChange={onChange}
|
|
157
|
+
onBlur={onBlur}
|
|
158
|
+
ref={ref}
|
|
159
|
+
disabled={disabled}
|
|
160
|
+
value={value}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
163
|
+
case 'multi-select':
|
|
164
|
+
return (
|
|
165
|
+
<StackedMultiSelect
|
|
166
|
+
className={`input-${inputType} ${className ?? ''}`}
|
|
167
|
+
name={name}
|
|
168
|
+
id={name}
|
|
169
|
+
isInvalid={isInvalid}
|
|
170
|
+
options={options as FieldOptions}
|
|
171
|
+
onChange={onChange}
|
|
172
|
+
onBlur={onBlur}
|
|
173
|
+
ref={ref}
|
|
174
|
+
disabled={disabled}
|
|
175
|
+
value={value}
|
|
176
|
+
setValue={setValue as UseFormSetValue<FieldValues>}
|
|
177
|
+
control={control as Control<FieldValues, any>}
|
|
178
|
+
setError={setError as UseFormSetError<FieldValues>}
|
|
179
|
+
clearErrors={clearErrors as UseFormClearErrors<FieldValues>}
|
|
180
|
+
placeholder={placeholder}
|
|
181
|
+
maxLength={maxLength}
|
|
182
|
+
/>
|
|
183
|
+
);
|
|
184
|
+
case 'pilled-text':
|
|
185
|
+
return (
|
|
186
|
+
<StackedPilledInput
|
|
187
|
+
className={`input-${inputType} ${className ?? ''}`}
|
|
188
|
+
aria-label={ariaLabel}
|
|
189
|
+
name={name}
|
|
190
|
+
id={name}
|
|
191
|
+
isInvalid={isInvalid}
|
|
192
|
+
onChange={onChange}
|
|
193
|
+
onBlur={onBlur}
|
|
194
|
+
ref={ref}
|
|
195
|
+
disabled={disabled}
|
|
196
|
+
value={value}
|
|
197
|
+
setValue={setValue as UseFormSetValue<FieldValues>}
|
|
198
|
+
setError={setError as UseFormSetError<FieldValues>}
|
|
199
|
+
clearErrors={clearErrors as UseFormClearErrors<FieldValues>}
|
|
200
|
+
control={control as Control<FieldValues, any>}
|
|
201
|
+
maxLength={maxLength}
|
|
202
|
+
/>
|
|
203
|
+
);
|
|
204
|
+
case 'switch':
|
|
205
|
+
return (
|
|
206
|
+
<StackedSwitch
|
|
207
|
+
className={`input-${inputType} ${className ?? ''}`}
|
|
208
|
+
name={name}
|
|
209
|
+
id={name}
|
|
210
|
+
isInvalid={isInvalid}
|
|
211
|
+
onChange={onChange}
|
|
212
|
+
onBlur={onBlur}
|
|
213
|
+
ref={ref}
|
|
214
|
+
value={value}
|
|
215
|
+
/>
|
|
216
|
+
);
|
|
217
|
+
default:
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
226
221
|
|
|
227
222
|
return (
|
|
228
223
|
<Controller
|