@xqmsg/ui-core 0.23.1-rc.0 → 0.23.1-rc.1
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/StackedInput/StackedInput.d.ts +1 -0
- package/dist/components/input/StackedPilledInput/index.d.ts +1 -0
- package/dist/components/input/StackedTextarea/StackedTextarea.d.ts +1 -0
- package/dist/theme/components/button.d.ts +0 -3
- package/dist/theme/components/checkbox.d.ts +5 -4
- package/dist/theme/components/input.d.ts +12 -1
- package/dist/theme/components/select.d.ts +12 -1
- package/dist/theme/components/textarea.d.ts +15 -3
- package/dist/ui-core.cjs.development.js +84 -77
- 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 +84 -77
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/input/Input.stories.tsx +1 -0
- package/src/components/input/StackedInput/StackedInput.tsx +8 -3
- package/src/components/input/StackedPilledInput/index.tsx +24 -0
- package/src/components/input/StackedTextarea/StackedTextarea.tsx +6 -4
- package/src/components/input/index.tsx +3 -0
- package/src/components/select/index.tsx +36 -80
- package/src/theme/components/button.ts +1 -1
- package/src/theme/components/checkbox.ts +5 -2
- package/src/theme/components/input.ts +9 -1
- package/src/theme/components/textarea.ts +4 -3
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ export interface StackedInputProps extends InputFieldProps {
|
|
|
8
8
|
leftElement?: React.ReactNode;
|
|
9
9
|
rightElement?: React.ReactNode;
|
|
10
10
|
variant?: string;
|
|
11
|
+
label?: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -23,21 +24,25 @@ const StackedInput = React.forwardRef<HTMLInputElement, StackedInputProps>(
|
|
|
23
24
|
defaultValue,
|
|
24
25
|
allowDefault,
|
|
25
26
|
variant,
|
|
27
|
+
label,
|
|
26
28
|
...props
|
|
27
29
|
},
|
|
28
30
|
_ref
|
|
29
31
|
) => {
|
|
32
|
+
const isMobile = variant === 'mobile';
|
|
33
|
+
const placeholder = isMobile && label ? label : undefined;
|
|
30
34
|
return (
|
|
31
35
|
<InputGroup>
|
|
32
36
|
{leftElement && leftElement}
|
|
33
|
-
{
|
|
37
|
+
{label}
|
|
34
38
|
<Input
|
|
39
|
+
{...props}
|
|
40
|
+
placeholder={placeholder}
|
|
35
41
|
type={type}
|
|
36
42
|
isRequired={isRequired}
|
|
37
|
-
{...props}
|
|
38
43
|
ref={_ref}
|
|
39
44
|
defaultValue={defaultValue}
|
|
40
|
-
fontSize={
|
|
45
|
+
fontSize={isMobile ? '17px' : '13px'}
|
|
41
46
|
variant={variant}
|
|
42
47
|
onKeyDown={e => {
|
|
43
48
|
if (e.key === 'Enter' && !allowDefault) {
|
|
@@ -19,6 +19,7 @@ export interface StackedPilledInputProps extends InputFieldProps {
|
|
|
19
19
|
control: Control<FieldValues, any>;
|
|
20
20
|
separators?: string[];
|
|
21
21
|
variant?: string;
|
|
22
|
+
label?: string;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -37,6 +38,7 @@ const StackedPilledInput = React.forwardRef<
|
|
|
37
38
|
disabled,
|
|
38
39
|
separators = ['Enter', ' ', ',', ';', 'Tab'],
|
|
39
40
|
variant,
|
|
41
|
+
label,
|
|
40
42
|
},
|
|
41
43
|
_ref
|
|
42
44
|
) => {
|
|
@@ -258,6 +260,22 @@ const StackedPilledInput = React.forwardRef<
|
|
|
258
260
|
borderRadius={isMobile ? '0' : '4px'}
|
|
259
261
|
alignItems="center"
|
|
260
262
|
justifyContent="space-between"
|
|
263
|
+
style={
|
|
264
|
+
isMobile
|
|
265
|
+
? {
|
|
266
|
+
cursor: 'pointer',
|
|
267
|
+
height: '48px',
|
|
268
|
+
fontSize: '17px',
|
|
269
|
+
lineHeight: '20px',
|
|
270
|
+
fontWeight: 400,
|
|
271
|
+
padding: '12px 16px 12px 0px',
|
|
272
|
+
borderRadius: 0,
|
|
273
|
+
border: '0.5px solid rgba(153, 153, 153, 0.1)',
|
|
274
|
+
borderLeft: 'none',
|
|
275
|
+
borderRight: 'none',
|
|
276
|
+
}
|
|
277
|
+
: undefined
|
|
278
|
+
}
|
|
261
279
|
onClick={() => {
|
|
262
280
|
if (isFocussed && tokenIndex !== null) {
|
|
263
281
|
setTokenIndex(null);
|
|
@@ -349,7 +367,13 @@ const StackedPilledInput = React.forwardRef<
|
|
|
349
367
|
setIsFocussed(false);
|
|
350
368
|
return setTokenIndex(null);
|
|
351
369
|
}}
|
|
370
|
+
placeholder={
|
|
371
|
+
isMobile && label && lastestFormValueToArray.length === 0
|
|
372
|
+
? (label as string)
|
|
373
|
+
: ''
|
|
374
|
+
}
|
|
352
375
|
variant={variant}
|
|
376
|
+
style={isMobile ? { border: 'none' } : undefined}
|
|
353
377
|
/>
|
|
354
378
|
</Flex>
|
|
355
379
|
)}
|
|
@@ -6,6 +6,7 @@ export interface StackedTextareaProps extends TextareaFieldProps {
|
|
|
6
6
|
isRequired?: boolean;
|
|
7
7
|
allowDefault?: boolean;
|
|
8
8
|
variant: string;
|
|
9
|
+
label?: string;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -14,16 +15,17 @@ export interface StackedTextareaProps extends TextareaFieldProps {
|
|
|
14
15
|
const StackedTextarea = React.forwardRef<
|
|
15
16
|
HTMLTextAreaElement,
|
|
16
17
|
StackedTextareaProps
|
|
17
|
-
>(({ isRequired, allowDefault, variant, ...props }, _ref) => {
|
|
18
|
-
|
|
18
|
+
>(({ isRequired, allowDefault, variant, label, ...props }, _ref) => {
|
|
19
|
+
const isMobile = variant === 'mobile';
|
|
20
|
+
if (isMobile) {
|
|
19
21
|
return (
|
|
20
22
|
<Flex>
|
|
21
|
-
{allowDefault}
|
|
22
23
|
<Textarea
|
|
23
24
|
ref={_ref}
|
|
24
25
|
{...props}
|
|
25
26
|
variant={variant}
|
|
26
27
|
fontSize="17px"
|
|
28
|
+
placeholder={label ?? ''}
|
|
27
29
|
onKeyDown={e => {
|
|
28
30
|
if (e.key === 'Enter' && !allowDefault) {
|
|
29
31
|
e.stopPropagation();
|
|
@@ -39,7 +41,7 @@ const StackedTextarea = React.forwardRef<
|
|
|
39
41
|
ref={_ref}
|
|
40
42
|
{...props}
|
|
41
43
|
variant={variant}
|
|
42
|
-
fontSize=
|
|
44
|
+
fontSize="13px"
|
|
43
45
|
onKeyDown={e => {
|
|
44
46
|
if (e.key === 'Enter' && !allowDefault) {
|
|
45
47
|
e.stopPropagation();
|
|
@@ -110,6 +110,7 @@ export function Input<T extends FieldValues>({
|
|
|
110
110
|
value={value}
|
|
111
111
|
allowDefault={allowDefault}
|
|
112
112
|
variant={variant}
|
|
113
|
+
label={label as string}
|
|
113
114
|
/>
|
|
114
115
|
);
|
|
115
116
|
case 'radio':
|
|
@@ -165,6 +166,7 @@ export function Input<T extends FieldValues>({
|
|
|
165
166
|
disabled={disabled}
|
|
166
167
|
value={value}
|
|
167
168
|
variant={variant}
|
|
169
|
+
label={label as string}
|
|
168
170
|
/>
|
|
169
171
|
);
|
|
170
172
|
case 'checkbox':
|
|
@@ -224,6 +226,7 @@ export function Input<T extends FieldValues>({
|
|
|
224
226
|
control={control as Control<FieldValues, any>}
|
|
225
227
|
maxLength={maxLength}
|
|
226
228
|
variant={variant}
|
|
229
|
+
label={label}
|
|
227
230
|
/>
|
|
228
231
|
);
|
|
229
232
|
case 'switch':
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useEffect
|
|
2
|
-
import {
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { Select } from '@chakra-ui/react';
|
|
3
3
|
import {
|
|
4
4
|
FormControl,
|
|
5
5
|
FormErrorMessage,
|
|
@@ -64,41 +64,37 @@ export const SelectNative: React.FC<SelectNativeProps<HTMLSelectElement>> = ({
|
|
|
64
64
|
...props
|
|
65
65
|
}) => {
|
|
66
66
|
// const [selectedOption, setSelectedOption] = useState(
|
|
67
|
-
// options
|
|
67
|
+
// options ? options[0] ?? '' : ''
|
|
68
68
|
// );
|
|
69
69
|
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// );
|
|
84
|
-
// }, [fullOptions, value]);
|
|
70
|
+
const style = {
|
|
71
|
+
cursor: 'pointer',
|
|
72
|
+
color: 'var(--chakra-colors-blue-500)',
|
|
73
|
+
height: '48px',
|
|
74
|
+
fontSize: '17px',
|
|
75
|
+
lineHeight: '20px',
|
|
76
|
+
fontWeight: 400,
|
|
77
|
+
padding: '12px 16px 12px 0px',
|
|
78
|
+
borderRadius: 0,
|
|
79
|
+
border: '0.5px solid rgba(153, 153, 153, 0.1)',
|
|
80
|
+
borderLeft: 'none',
|
|
81
|
+
borderRight: 'none',
|
|
82
|
+
};
|
|
85
83
|
|
|
86
84
|
const handleOnSelectItem = (selectedValue: string) => {
|
|
87
|
-
console.log(selectedValue);
|
|
88
85
|
const selectedOption = options?.find(
|
|
89
86
|
({ value: val }) => selectedValue === val
|
|
90
87
|
);
|
|
91
|
-
|
|
92
|
-
setValue(name as string, selectedValue);
|
|
88
|
+
|
|
93
89
|
if (selectedOption) {
|
|
94
90
|
if (onChange) {
|
|
95
91
|
onChange(selectedOption.value);
|
|
96
92
|
}
|
|
97
|
-
setSelectedOption(selectedOption);
|
|
98
93
|
setValue(name as string, selectedOption.value);
|
|
94
|
+
} else {
|
|
95
|
+
setValue(name as string, selectedValue);
|
|
99
96
|
}
|
|
100
97
|
};
|
|
101
|
-
console.log(selectedOption);
|
|
102
98
|
|
|
103
99
|
useEffect(() => {
|
|
104
100
|
if (defaultValue) {
|
|
@@ -110,68 +106,28 @@ export const SelectNative: React.FC<SelectNativeProps<HTMLSelectElement>> = ({
|
|
|
110
106
|
<Controller
|
|
111
107
|
control={control}
|
|
112
108
|
name={name}
|
|
113
|
-
// defaultValue={defaultValue as PathValue<T, Path<T>>}
|
|
114
109
|
rules={{ required: isRequired }}
|
|
115
110
|
/** @ts-ignore: issues with implicit */
|
|
116
111
|
render={({ field: { onBlur, onChange: fieldOnChange, ref, value } }) => (
|
|
117
112
|
<FormControl id={name} isInvalid={isInvalid} position="relative" py={0}>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
)} */}
|
|
127
|
-
<Box //ref={dropdownRef}
|
|
128
|
-
position="relative"
|
|
113
|
+
<Select
|
|
114
|
+
{...props}
|
|
115
|
+
required={isRequired}
|
|
116
|
+
ref={ref}
|
|
117
|
+
value={value}
|
|
118
|
+
disabled={disabled ?? false}
|
|
119
|
+
onChange={e => handleOnSelectItem(e.target.value)}
|
|
120
|
+
style={style}
|
|
129
121
|
>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
minWidth="100%"
|
|
140
|
-
zIndex={100}
|
|
141
|
-
tabIndex={-2000}
|
|
142
|
-
borderTop="0.5px solid #9999991A"
|
|
143
|
-
>
|
|
144
|
-
<Select
|
|
145
|
-
{...props}
|
|
146
|
-
required={isRequired}
|
|
147
|
-
ref={ref}
|
|
148
|
-
//value={selectedOption?.value ?? value}
|
|
149
|
-
// textShadow={`0 0 0 ${colors.label.primary.light}`}
|
|
150
|
-
disabled={disabled ?? false}
|
|
151
|
-
onChange={e => handleOnSelectItem(e.target.value)}
|
|
152
|
-
// onKeyDown={handleOnKeyDown}
|
|
153
|
-
style={{
|
|
154
|
-
cursor: 'pointer',
|
|
155
|
-
color: 'var(--chakra-colors-blue-500)',
|
|
156
|
-
height: '48px',
|
|
157
|
-
fontSize: '17px',
|
|
158
|
-
lineHeight: '20px',
|
|
159
|
-
fontWeight: 400,
|
|
160
|
-
padding: '12px 16px 12px 0px',
|
|
161
|
-
borderRadius: 0,
|
|
162
|
-
}}
|
|
163
|
-
>
|
|
164
|
-
{options &&
|
|
165
|
-
options.map(i => {
|
|
166
|
-
return (
|
|
167
|
-
<option value={i.value} key={i.sortValue}>
|
|
168
|
-
{i.label}
|
|
169
|
-
</option>
|
|
170
|
-
);
|
|
171
|
-
})}
|
|
172
|
-
</Select>
|
|
173
|
-
</Flex>
|
|
174
|
-
</Box>
|
|
122
|
+
{options &&
|
|
123
|
+
options.map(i => {
|
|
124
|
+
return (
|
|
125
|
+
<option value={i.value} key={i.sortValue}>
|
|
126
|
+
{i.label}
|
|
127
|
+
</option>
|
|
128
|
+
);
|
|
129
|
+
})}
|
|
130
|
+
</Select>
|
|
175
131
|
{isInvalid ? (
|
|
176
132
|
<FormErrorMessage>{errorText}</FormErrorMessage>
|
|
177
133
|
) : (
|
|
@@ -8,12 +8,15 @@ const {
|
|
|
8
8
|
|
|
9
9
|
const roundedCheckbox = definePartsStyle({
|
|
10
10
|
control: {
|
|
11
|
-
borderRadius: 50,
|
|
12
|
-
padding: 3,
|
|
11
|
+
//borderRadius: 50,
|
|
13
12
|
},
|
|
14
13
|
label: {
|
|
15
14
|
fontSize: '17px',
|
|
15
|
+
fontWeight: 400,
|
|
16
|
+
lineHeight: '20px',
|
|
17
|
+
padding: '12px 16px 12px 0px',
|
|
16
18
|
},
|
|
19
|
+
height: '44px',
|
|
17
20
|
});
|
|
18
21
|
|
|
19
22
|
const variants = {
|
|
@@ -26,6 +26,9 @@ const baseStyle = {
|
|
|
26
26
|
border: '2px solid',
|
|
27
27
|
borderColor: colors.border.focus,
|
|
28
28
|
},
|
|
29
|
+
_placeholder: {
|
|
30
|
+
color: colors.label.secondary.light,
|
|
31
|
+
},
|
|
29
32
|
},
|
|
30
33
|
};
|
|
31
34
|
|
|
@@ -33,13 +36,18 @@ const mobileInputs = {
|
|
|
33
36
|
...baseStyle,
|
|
34
37
|
field: {
|
|
35
38
|
fontSize: '17px',
|
|
36
|
-
border: 'none',
|
|
37
39
|
py: '14px',
|
|
38
40
|
px: '16px',
|
|
39
41
|
cursor: 'pointer',
|
|
40
42
|
lineHeight: '21px',
|
|
41
43
|
fontWeight: 400,
|
|
42
44
|
borderRadius: 0,
|
|
45
|
+
height: '48px',
|
|
46
|
+
padding: '12px 16px 12px 0px',
|
|
47
|
+
border: '0.5px solid rgba(153, 153, 153, 0.1)',
|
|
48
|
+
borderColor: 'rgba(153, 153, 153, 0.1)',
|
|
49
|
+
borderLeft: 'none',
|
|
50
|
+
borderRight: 'none',
|
|
43
51
|
},
|
|
44
52
|
};
|
|
45
53
|
|
|
@@ -17,15 +17,16 @@ const mobileInputs = defineStyle({
|
|
|
17
17
|
...Input.variants.mobile.field,
|
|
18
18
|
border: 'none',
|
|
19
19
|
borderRadius: 0,
|
|
20
|
-
paddingY: '
|
|
21
|
-
paddingX: '
|
|
22
|
-
padding: '
|
|
20
|
+
paddingY: '16px',
|
|
21
|
+
paddingX: '0',
|
|
22
|
+
// padding: '16px 16px',
|
|
23
23
|
cursor: 'pointer',
|
|
24
24
|
lineHeight: '21px',
|
|
25
25
|
fontWeight: 400,
|
|
26
26
|
resize: 'none',
|
|
27
27
|
overflowY: 'auto',
|
|
28
28
|
fontSize: '17px',
|
|
29
|
+
minHeight: '208px',
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
const variants = { default: baseStyle, mobile: mobileInputs };
|