@xqmsg/ui-core 0.9.3 → 0.11.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/button/index.d.ts +3 -7
- package/dist/components/input/Input.stories.d.ts +4 -0
- package/dist/components/input/InputTypes.d.ts +5 -3
- package/dist/components/input/StackedInput/StackedInput.d.ts +0 -3
- package/dist/components/input/StackedMultiSelect/index.d.ts +1 -1
- package/dist/components/input/StackedSelect/StackedSelect.d.ts +7 -3
- package/dist/components/input/components/dropdown/index.d.ts +10 -0
- package/dist/components/input/components/label/index.d.ts +9 -0
- package/dist/components/input/components/token/Token.stories.d.ts +5 -0
- package/dist/components/input/components/token/index.d.ts +7 -0
- package/dist/components/input/index.d.ts +1 -3
- package/dist/theme/components/button.d.ts +68 -207
- package/dist/theme/components/form-error.d.ts +3 -3
- package/dist/theme/components/form-label.d.ts +4 -6
- package/dist/theme/components/form.d.ts +3 -3
- package/dist/theme/components/input.d.ts +32 -161
- package/dist/theme/components/select.d.ts +27 -153
- package/dist/theme/components/textarea.d.ts +10 -117
- package/dist/theme/foundations/colors.d.ts +68 -16
- package/dist/ui-core.cjs.development.js +594 -860
- 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 +598 -864
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -2
- package/src/components/banner/index.tsx +7 -1
- package/src/components/button/Button.stories.tsx +19 -7
- package/src/components/button/index.tsx +7 -19
- package/src/components/button/spinner/index.tsx +2 -7
- package/src/components/input/Input.stories.tsx +60 -58
- package/src/components/input/InputTypes.ts +7 -1
- package/src/components/input/StackedInput/StackedInput.tsx +3 -15
- package/src/components/input/StackedMultiSelect/components/MultiValue/index.tsx +2 -2
- package/src/components/input/StackedMultiSelect/index.tsx +88 -92
- package/src/components/input/StackedPilledInput/index.tsx +139 -56
- package/src/components/input/StackedSelect/StackedSelect.tsx +63 -20
- package/src/components/input/StackedSelect/assets/svg/subtract.svg +3 -0
- package/src/components/input/components/dropdown/index.tsx +80 -0
- package/src/components/input/components/label/index.tsx +24 -0
- package/src/components/input/components/token/Token.stories.tsx +22 -0
- package/src/components/input/components/token/assets/svg/close.svg +3 -0
- package/src/components/input/components/token/index.tsx +37 -0
- package/src/components/input/index.tsx +7 -20
- package/src/components/loading/index.tsx +1 -1
- package/src/components/table/Table.stories.tsx +9 -1
- package/src/components/table/index.tsx +1 -1
- package/src/components/table/loading/index.tsx +2 -2
- package/src/components/tabs/index.tsx +1 -1
- package/src/components/text/index.tsx +1 -1
- package/src/theme/components/alert.ts +4 -4
- package/src/theme/components/button.ts +45 -186
- package/src/theme/components/form-error.ts +11 -14
- package/src/theme/components/form-label.ts +8 -8
- package/src/theme/components/form.ts +10 -13
- package/src/theme/components/input.ts +17 -191
- package/src/theme/components/link.ts +2 -1
- package/src/theme/components/select.ts +5 -10
- package/src/theme/components/tabs.ts +3 -3
- package/src/theme/components/textarea.ts +2 -38
- package/src/theme/customXQChakraTheme.ts +0 -2
- package/src/theme/foundations/colors.ts +31 -10
- package/src/theme/foundations/shadows.ts +3 -3
- package/dist/components/input/components/InputTag/index.d.ts +0 -7
- package/dist/theme/components/menu.d.ts +0 -48
- package/src/components/input/components/InputTag/index.tsx +0 -24
- package/src/theme/components/menu.ts +0 -70
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { Box, Flex, Input } from '@chakra-ui/react';
|
|
2
|
+
import { Box, Flex, Input, Text, useOutsideClick } from '@chakra-ui/react';
|
|
3
3
|
import { InputFieldProps } from '../InputTypes';
|
|
4
4
|
import {
|
|
5
5
|
Control,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useWatch,
|
|
9
9
|
} from 'react-hook-form';
|
|
10
10
|
import colors from '../../../theme/foundations/colors';
|
|
11
|
-
import
|
|
11
|
+
import Token from '../components/token';
|
|
12
12
|
|
|
13
13
|
export interface StackedPilledInputProps extends InputFieldProps {
|
|
14
14
|
setValue: UseFormSetValue<FieldValues>;
|
|
@@ -21,15 +21,17 @@ export interface StackedPilledInputProps extends InputFieldProps {
|
|
|
21
21
|
const StackedPilledInput = React.forwardRef<
|
|
22
22
|
HTMLInputElement,
|
|
23
23
|
StackedPilledInputProps
|
|
24
|
-
>(({ name, setValue, control }, _ref) => {
|
|
24
|
+
>(({ name, setValue, control, placeholder, disabled }, _ref) => {
|
|
25
25
|
const watchedValue = useWatch({ control, name: name as string });
|
|
26
26
|
const [lastestFormValueToArray, setLatestFormValueToArray] = useState<
|
|
27
27
|
string[]
|
|
28
28
|
>([]);
|
|
29
29
|
|
|
30
30
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
31
|
+
const inputWrapperRef = useRef(null);
|
|
31
32
|
|
|
32
|
-
const [
|
|
33
|
+
const [tokenIndex, setTokenIndex] = useState<number | null>(null);
|
|
34
|
+
const [isFocussed, setIsFocussed] = useState(false);
|
|
33
35
|
|
|
34
36
|
const [localValue, setLocalValue] = useState('');
|
|
35
37
|
|
|
@@ -44,17 +46,34 @@ const StackedPilledInput = React.forwardRef<
|
|
|
44
46
|
}
|
|
45
47
|
}, [watchedValue]);
|
|
46
48
|
|
|
47
|
-
// ensures after value addition that the input field is wiped
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (localValue === ' ' || localValue.trim() === ',') {
|
|
50
|
-
setLocalValue('');
|
|
51
|
-
}
|
|
52
|
-
}, [localValue]);
|
|
53
|
-
|
|
54
49
|
const onHandleKeyDown = (e: React.KeyboardEvent) => {
|
|
55
50
|
if (e.key === ' ' || e.key === 'Enter' || e.key === ',') {
|
|
56
|
-
if (
|
|
57
|
-
|
|
51
|
+
if (
|
|
52
|
+
e.key === 'Enter' &&
|
|
53
|
+
!localValue.trim().length &&
|
|
54
|
+
tokenIndex !== null
|
|
55
|
+
) {
|
|
56
|
+
setLocalValue(lastestFormValueToArray[tokenIndex]);
|
|
57
|
+
|
|
58
|
+
const filteredUniqueValues = Array.from(
|
|
59
|
+
new Set(
|
|
60
|
+
lastestFormValueToArray.filter(
|
|
61
|
+
value => value !== lastestFormValueToArray[tokenIndex]
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
setValue(
|
|
67
|
+
name as string,
|
|
68
|
+
filteredUniqueValues.toString().replace(/\s/g, ''),
|
|
69
|
+
{
|
|
70
|
+
shouldValidate: true,
|
|
71
|
+
shouldDirty: true,
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return setTokenIndex(null);
|
|
76
|
+
}
|
|
58
77
|
|
|
59
78
|
const filteredUniqueValues = Array.from(
|
|
60
79
|
new Set([...lastestFormValueToArray, ...localValue.trim().split(',')])
|
|
@@ -71,6 +90,55 @@ const StackedPilledInput = React.forwardRef<
|
|
|
71
90
|
}
|
|
72
91
|
);
|
|
73
92
|
}
|
|
93
|
+
|
|
94
|
+
if (!localValue.trim().length && lastestFormValueToArray.length) {
|
|
95
|
+
if (e.key === 'Backspace' && tokenIndex !== null) {
|
|
96
|
+
setLocalValue(
|
|
97
|
+
lastestFormValueToArray[tokenIndex].substring(
|
|
98
|
+
0,
|
|
99
|
+
lastestFormValueToArray[tokenIndex].length
|
|
100
|
+
)
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const filteredUniqueValues = Array.from(
|
|
104
|
+
new Set(
|
|
105
|
+
[...lastestFormValueToArray].filter(
|
|
106
|
+
value => value !== lastestFormValueToArray[tokenIndex]
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
setValue(
|
|
112
|
+
name as string,
|
|
113
|
+
filteredUniqueValues.toString().replace(/\s/g, ''),
|
|
114
|
+
{
|
|
115
|
+
shouldValidate: true,
|
|
116
|
+
shouldDirty: true,
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return setTokenIndex(null);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (e.key === 'ArrowLeft') {
|
|
124
|
+
if (tokenIndex === 0) return;
|
|
125
|
+
|
|
126
|
+
if (!tokenIndex) {
|
|
127
|
+
return setTokenIndex(lastestFormValueToArray.length - 1);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return setTokenIndex(prevTokenIndex => (prevTokenIndex as number) - 1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (e.key === 'ArrowRight') {
|
|
134
|
+
if (tokenIndex === null) return;
|
|
135
|
+
|
|
136
|
+
if (tokenIndex === lastestFormValueToArray.length - 1) {
|
|
137
|
+
return setTokenIndex(null);
|
|
138
|
+
}
|
|
139
|
+
return setTokenIndex(prevTokenIndex => (prevTokenIndex as number) + 1);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
74
142
|
};
|
|
75
143
|
|
|
76
144
|
const onRemoveTag = (index: number) => {
|
|
@@ -106,63 +174,78 @@ const StackedPilledInput = React.forwardRef<
|
|
|
106
174
|
);
|
|
107
175
|
setLocalValue('');
|
|
108
176
|
}
|
|
109
|
-
|
|
177
|
+
setIsFocussed(false);
|
|
110
178
|
};
|
|
111
179
|
|
|
180
|
+
useOutsideClick({ ref: inputWrapperRef, handler: onBlur });
|
|
181
|
+
|
|
112
182
|
return (
|
|
113
|
-
<
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
183
|
+
<Box position="relative">
|
|
184
|
+
<Flex
|
|
185
|
+
fontSize="13px"
|
|
186
|
+
border={isFocussed ? '2px solid' : '1px solid'}
|
|
187
|
+
borderColor={isFocussed ? colors.border.focus : colors.border.default}
|
|
188
|
+
py="5px"
|
|
189
|
+
pl="8px"
|
|
190
|
+
borderRadius="4px"
|
|
191
|
+
alignItems="center"
|
|
192
|
+
justifyContent="space-between"
|
|
193
|
+
onClick={() => {
|
|
194
|
+
if (!disabled) {
|
|
195
|
+
inputRef.current?.focus();
|
|
196
|
+
}
|
|
197
|
+
}}
|
|
198
|
+
bg={disabled ? colors.fill.light.quaternary : '#ffffff'}
|
|
199
|
+
cursor={disabled ? 'not-allowed' : 'pointer'}
|
|
200
|
+
ref={inputWrapperRef}
|
|
118
201
|
>
|
|
119
|
-
<Flex
|
|
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
|
-
|
|
202
|
+
<Flex height="28px" alignItems="center" width="fit-content">
|
|
203
|
+
{lastestFormValueToArray.length ? (
|
|
204
|
+
lastestFormValueToArray.map((label, index) => (
|
|
205
|
+
<Box
|
|
206
|
+
mr="4px"
|
|
207
|
+
border={
|
|
208
|
+
tokenIndex === index
|
|
209
|
+
? `2px solid ${colors.border.focus}`
|
|
210
|
+
: 'none'
|
|
211
|
+
}
|
|
212
|
+
borderRadius="full"
|
|
213
|
+
onClick={() => setTokenIndex(index)}
|
|
214
|
+
>
|
|
215
|
+
<Token
|
|
216
|
+
label={label}
|
|
217
|
+
onDelete={(e: any) => {
|
|
218
|
+
e.stopPropagation();
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
onRemoveTag(index);
|
|
221
|
+
}}
|
|
222
|
+
/>
|
|
223
|
+
</Box>
|
|
224
|
+
))
|
|
225
|
+
) : (
|
|
226
|
+
<Text color={colors.label.secondary.light} fontSize="13px">
|
|
227
|
+
{placeholder}
|
|
228
|
+
</Text>
|
|
229
|
+
)}
|
|
230
|
+
</Flex>
|
|
231
|
+
<Flex flex={1}>
|
|
149
232
|
<Input
|
|
150
233
|
onKeyDown={onHandleKeyDown}
|
|
151
234
|
type="text"
|
|
152
|
-
padding={
|
|
153
|
-
height={isInputFocused ? '46px' : '0px'}
|
|
235
|
+
padding={0}
|
|
154
236
|
width="100%"
|
|
155
237
|
border="none"
|
|
238
|
+
height="26px"
|
|
239
|
+
color={tokenIndex !== null ? 'transparent' : colors.label.primary}
|
|
156
240
|
_focus={{ boxShadow: 'none !important' }}
|
|
157
241
|
value={localValue}
|
|
158
|
-
|
|
159
|
-
onChange={e => setLocalValue(e.target.value)}
|
|
242
|
+
onChange={e => tokenIndex === null && setLocalValue(e.target.value)}
|
|
160
243
|
ref={inputRef}
|
|
161
|
-
onFocus={() =>
|
|
244
|
+
onFocus={() => setIsFocussed(true)}
|
|
162
245
|
/>
|
|
163
246
|
</Flex>
|
|
164
|
-
</
|
|
165
|
-
</
|
|
247
|
+
</Flex>
|
|
248
|
+
</Box>
|
|
166
249
|
);
|
|
167
250
|
});
|
|
168
251
|
|
|
@@ -1,31 +1,74 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Image,
|
|
5
|
+
Input,
|
|
6
|
+
InputGroup,
|
|
7
|
+
InputRightElement,
|
|
8
|
+
useOutsideClick,
|
|
9
|
+
} from '@chakra-ui/react';
|
|
10
|
+
import { FieldOptions } from '../InputTypes';
|
|
11
|
+
import { StackedInputProps } from '../StackedInput/StackedInput';
|
|
12
|
+
import colors from 'src/theme/foundations/colors';
|
|
13
|
+
import { UseFormSetValue, FieldValues, Control } from 'react-hook-form';
|
|
14
|
+
import SubtractIcon from './assets/svg/subtract.svg';
|
|
15
|
+
import { Dropdown } from '../components/dropdown';
|
|
4
16
|
|
|
5
|
-
export interface StackedSelectProps extends
|
|
17
|
+
export interface StackedSelectProps extends StackedInputProps {
|
|
6
18
|
options: FieldOptions;
|
|
19
|
+
setValue: UseFormSetValue<FieldValues>;
|
|
20
|
+
control: Control<FieldValues, any>;
|
|
7
21
|
}
|
|
8
22
|
|
|
9
23
|
/**
|
|
10
24
|
* A functional React component utilized to render the `StackedSelect` component.
|
|
11
25
|
*/
|
|
12
|
-
const StackedSelect = React.forwardRef<
|
|
13
|
-
({ isRequired, options, onChange, ...props }, _ref) => {
|
|
26
|
+
const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
|
|
27
|
+
({ isRequired, options, name, setValue, onChange, ...props }, _ref) => {
|
|
28
|
+
const dropdownRef = useRef(null);
|
|
29
|
+
const [isFocussed, setIsFocussed] = useState(false);
|
|
30
|
+
const [selectedOption, setSelectedOption] = useState('');
|
|
31
|
+
|
|
32
|
+
useOutsideClick({ ref: dropdownRef, handler: () => setIsFocussed(false) });
|
|
33
|
+
|
|
34
|
+
const handleOnSelectItem = (option: {
|
|
35
|
+
label: string;
|
|
36
|
+
value: string;
|
|
37
|
+
sortValue: number;
|
|
38
|
+
}) => {
|
|
39
|
+
setValue(name as string, option.value);
|
|
40
|
+
setSelectedOption(option.label);
|
|
41
|
+
setIsFocussed(false);
|
|
42
|
+
};
|
|
43
|
+
|
|
14
44
|
return (
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
<Box ref={dropdownRef} position="relative">
|
|
46
|
+
<InputGroup>
|
|
47
|
+
<Input
|
|
48
|
+
isRequired={isRequired}
|
|
49
|
+
{...props}
|
|
50
|
+
ref={_ref}
|
|
51
|
+
onClick={() => setIsFocussed(!isFocussed)}
|
|
52
|
+
cursor="pointer"
|
|
53
|
+
color="transparent"
|
|
54
|
+
fontSize="13px"
|
|
55
|
+
textShadow={`0 0 0 ${colors.label.primary.light}`}
|
|
56
|
+
value={selectedOption}
|
|
57
|
+
/>
|
|
58
|
+
<InputRightElement
|
|
59
|
+
cursor="pointer"
|
|
60
|
+
onClick={() => setIsFocussed(!isFocussed)}
|
|
61
|
+
>
|
|
62
|
+
<Image src={SubtractIcon} alt="subtract" boxSize="16px" />
|
|
63
|
+
</InputRightElement>
|
|
64
|
+
</InputGroup>
|
|
65
|
+
{isFocussed && (
|
|
66
|
+
<Dropdown
|
|
67
|
+
onSelectItem={(option) => handleOnSelectItem(option)}
|
|
68
|
+
options={options}
|
|
69
|
+
/>
|
|
70
|
+
)}
|
|
71
|
+
</Box>
|
|
29
72
|
);
|
|
30
73
|
}
|
|
31
74
|
);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 12C0.89543 12 -3.91405e-08 11.1046 -8.74228e-08 10L-4.37114e-07 2C-4.85396e-07 0.895431 0.89543 -3.91405e-08 2 -8.74228e-08L10 -4.37114e-07C11.1046 -4.85396e-07 12 0.89543 12 2L12 10C12 11.1046 11.1046 12 10 12L2 12ZM6 2.5C6.13261 2.5 6.25979 2.55268 6.35355 2.64645L7.85355 4.14645C8.04881 4.34171 8.04881 4.65829 7.85355 4.85355C7.65829 5.04882 7.34171 5.04882 7.14645 4.85355L6 3.70711L4.85355 4.85355C4.65829 5.04882 4.34171 5.04882 4.14645 4.85355C3.95118 4.65829 3.95118 4.34171 4.14645 4.14645L5.64645 2.64645C5.74021 2.55268 5.86739 2.5 6 2.5ZM5.64645 9.35355C5.74021 9.44732 5.86739 9.5 6 9.5C6.13261 9.5 6.25978 9.44732 6.35355 9.35355L7.85355 7.85355C8.04882 7.65829 8.04882 7.34171 7.85355 7.14645C7.65829 6.95118 7.34171 6.95118 7.14645 7.14645L6 8.29289L4.85355 7.14645C4.65829 6.95118 4.34171 6.95118 4.14645 7.14645C3.95118 7.34171 3.95118 7.65829 4.14645 7.85355L5.64645 9.35355Z" fill="#0082FF"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Box } from '@chakra-ui/react';
|
|
3
|
+
import colors from 'src/theme/foundations/colors';
|
|
4
|
+
import { FieldOption, FieldOptions } from '../../InputTypes';
|
|
5
|
+
|
|
6
|
+
export interface DropdownProps {
|
|
7
|
+
onSelectItem: (option: FieldOption) => void;
|
|
8
|
+
options: FieldOptions;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A functional React component utilized to render the `Dropdown` component
|
|
13
|
+
*/
|
|
14
|
+
export const Dropdown: React.FC<DropdownProps> = ({
|
|
15
|
+
onSelectItem,
|
|
16
|
+
options,
|
|
17
|
+
}) => {
|
|
18
|
+
const DropdownContent = useMemo(() => {
|
|
19
|
+
return options.map((option, idx) => (
|
|
20
|
+
<>
|
|
21
|
+
{option.value === 'section_header' &&
|
|
22
|
+
options[idx + 1] &&
|
|
23
|
+
options[idx + 1].value !== 'section_header' && (
|
|
24
|
+
<Box
|
|
25
|
+
color={colors.label.secondary.light}
|
|
26
|
+
fontSize="13px"
|
|
27
|
+
fontWeight="bold"
|
|
28
|
+
px="8px"
|
|
29
|
+
>
|
|
30
|
+
{idx > 0 && (
|
|
31
|
+
<Box
|
|
32
|
+
my="3px"
|
|
33
|
+
borderTop="2px solid"
|
|
34
|
+
borderColor={colors.border.default}
|
|
35
|
+
/>
|
|
36
|
+
)}
|
|
37
|
+
{option.label}
|
|
38
|
+
</Box>
|
|
39
|
+
)}
|
|
40
|
+
{option.value !== 'section_header' && (
|
|
41
|
+
<Box
|
|
42
|
+
cursor="pointer"
|
|
43
|
+
borderRadius="inherit"
|
|
44
|
+
onClick={() => onSelectItem(option)}
|
|
45
|
+
key={option.value}
|
|
46
|
+
fontSize="13px"
|
|
47
|
+
px="8px"
|
|
48
|
+
py="4px"
|
|
49
|
+
color={colors.label.primary.light}
|
|
50
|
+
_hover={{
|
|
51
|
+
color: colors.label.primary.dark,
|
|
52
|
+
bg: colors.fill.action,
|
|
53
|
+
borderRadius: '4px',
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
{option.label}
|
|
57
|
+
</Box>
|
|
58
|
+
)}
|
|
59
|
+
</>
|
|
60
|
+
));
|
|
61
|
+
}, [onSelectItem, options]);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Box
|
|
65
|
+
bg={colors.fill.light.quaternary}
|
|
66
|
+
backdropFilter="blur(64px)"
|
|
67
|
+
borderRadius="4px"
|
|
68
|
+
mt="3px"
|
|
69
|
+
maxH="320px"
|
|
70
|
+
overflowY="auto"
|
|
71
|
+
px="8px"
|
|
72
|
+
py="4px"
|
|
73
|
+
position="absolute"
|
|
74
|
+
width="100%"
|
|
75
|
+
zIndex="100"
|
|
76
|
+
>
|
|
77
|
+
{DropdownContent}
|
|
78
|
+
</Box>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, FormLabel } from '@chakra-ui/react';
|
|
3
|
+
import colors from 'src/theme/foundations/colors';
|
|
4
|
+
|
|
5
|
+
export interface LabelProps {
|
|
6
|
+
label: string;
|
|
7
|
+
isRequired?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A functional React component utilized to render the `Label` component
|
|
12
|
+
*/
|
|
13
|
+
export const Label: React.FC<LabelProps> = ({ isRequired, label }) => {
|
|
14
|
+
return (
|
|
15
|
+
<FormLabel>
|
|
16
|
+
{label}
|
|
17
|
+
{isRequired && (
|
|
18
|
+
<Box ml={1} color={colors.label.error}>
|
|
19
|
+
*
|
|
20
|
+
</Box>
|
|
21
|
+
)}
|
|
22
|
+
</FormLabel>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Meta, Story } from '@storybook/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Token, { TokenProps } from '.';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<TokenProps> = {
|
|
6
|
+
title: 'Token example',
|
|
7
|
+
component: Token,
|
|
8
|
+
argTypes: {},
|
|
9
|
+
parameters: {
|
|
10
|
+
controls: { expanded: true },
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
const Template: Story<TokenProps> = (args) => (
|
|
16
|
+
<Token {...args} onDelete={() => null} />
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const Default = Template.bind({});
|
|
20
|
+
Default.args = {
|
|
21
|
+
label: 'Label',
|
|
22
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="56" height="56" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M27.9995 56C43.4635 56 55.9995 43.464 55.9995 28C55.9995 12.536 43.4635 0 27.9995 0C12.5355 0 -0.000488281 12.536 -0.000488281 28C-0.000488281 43.464 12.5355 56 27.9995 56ZM21.9807 18.2688C20.9555 17.2437 19.2935 17.2437 18.2684 18.2688C17.2432 19.294 17.2432 20.956 18.2684 21.9812L24.2872 28L18.2684 34.0188C17.2432 35.044 17.2432 36.706 18.2684 37.7312C19.2935 38.7563 20.9555 38.7563 21.9807 37.7312L27.9995 31.7123L34.0184 37.7312C35.0435 38.7563 36.7055 38.7563 37.7307 37.7312C38.7558 36.706 38.7558 35.044 37.7307 34.0188L31.7118 28L37.7307 21.9812C38.7558 20.956 38.7558 19.294 37.7307 18.2688C36.7055 17.2437 35.0435 17.2437 34.0184 18.2688L27.9995 24.2877L21.9807 18.2688Z" fill="#3C3C43" fill-opacity="0.6"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Flex, Image, Text } from '@chakra-ui/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import colors from 'src/theme/foundations/colors';
|
|
4
|
+
import CloseIcon from './assets/svg/close.svg';
|
|
5
|
+
|
|
6
|
+
export interface TokenProps {
|
|
7
|
+
label: any;
|
|
8
|
+
onDelete: any;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Token: React.FC<TokenProps> = ({ label, onDelete }) => {
|
|
12
|
+
return (
|
|
13
|
+
<Flex
|
|
14
|
+
key={label}
|
|
15
|
+
borderRadius="full"
|
|
16
|
+
backgroundColor="#7676801F"
|
|
17
|
+
alignItems="center"
|
|
18
|
+
width="fit-content"
|
|
19
|
+
pl="8px"
|
|
20
|
+
pr="4px"
|
|
21
|
+
py="2px"
|
|
22
|
+
>
|
|
23
|
+
<Text color={colors.label.primary.light} fontSize="13px">
|
|
24
|
+
{label}
|
|
25
|
+
</Text>
|
|
26
|
+
<Image
|
|
27
|
+
pl="4px"
|
|
28
|
+
boxSize="16px"
|
|
29
|
+
src={CloseIcon}
|
|
30
|
+
onClick={onDelete}
|
|
31
|
+
cursor="pointer"
|
|
32
|
+
/>
|
|
33
|
+
</Flex>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default Token;
|
|
@@ -6,11 +6,9 @@ import StackedSelect from './StackedSelect/StackedSelect';
|
|
|
6
6
|
import StackedTextarea from './StackedTextarea/StackedTextarea';
|
|
7
7
|
import { FieldOptions, ValidationProps, InputType } from './InputTypes';
|
|
8
8
|
import {
|
|
9
|
-
Box,
|
|
10
9
|
FormControl,
|
|
11
10
|
FormErrorMessage,
|
|
12
11
|
FormHelperText,
|
|
13
|
-
FormLabel,
|
|
14
12
|
} from '@chakra-ui/react';
|
|
15
13
|
import {
|
|
16
14
|
Control,
|
|
@@ -24,6 +22,7 @@ import {
|
|
|
24
22
|
import StackedMultiSelect from './StackedMultiSelect';
|
|
25
23
|
import StackedPilledInput from './StackedPilledInput';
|
|
26
24
|
import StackedSwitch from './StackedSwitch';
|
|
25
|
+
import { Label } from './components/label';
|
|
27
26
|
|
|
28
27
|
export interface InputProps<T extends FieldValues> extends ValidationProps {
|
|
29
28
|
inputType: InputType;
|
|
@@ -36,8 +35,7 @@ export interface InputProps<T extends FieldValues> extends ValidationProps {
|
|
|
36
35
|
options?: FieldOptions;
|
|
37
36
|
maxLength?: number;
|
|
38
37
|
helperText?: React.ReactNode;
|
|
39
|
-
|
|
40
|
-
rightElement?: React.ReactNode;
|
|
38
|
+
|
|
41
39
|
control?: Control<T, any>;
|
|
42
40
|
onChange?: (args?: any) => void;
|
|
43
41
|
disabled?: boolean;
|
|
@@ -56,8 +54,6 @@ export function Input<T extends FieldValues>({
|
|
|
56
54
|
placeholder,
|
|
57
55
|
name,
|
|
58
56
|
helperText,
|
|
59
|
-
leftElement,
|
|
60
|
-
rightElement,
|
|
61
57
|
options,
|
|
62
58
|
isInvalid,
|
|
63
59
|
errorText,
|
|
@@ -87,8 +83,6 @@ export function Input<T extends FieldValues>({
|
|
|
87
83
|
placeholder={placeholder}
|
|
88
84
|
maxLength={maxLength}
|
|
89
85
|
isRequired={isRequired}
|
|
90
|
-
leftElement={leftElement}
|
|
91
|
-
rightElement={rightElement}
|
|
92
86
|
isInvalid={isInvalid}
|
|
93
87
|
onChange={onChange}
|
|
94
88
|
onBlur={onBlur}
|
|
@@ -124,9 +118,12 @@ export function Input<T extends FieldValues>({
|
|
|
124
118
|
options={options as FieldOptions}
|
|
125
119
|
onChange={onChange}
|
|
126
120
|
onBlur={onBlur}
|
|
121
|
+
setValue={setValue as UseFormSetValue<FieldValues>}
|
|
122
|
+
control={control as Control<FieldValues, any>}
|
|
127
123
|
ref={ref}
|
|
128
124
|
disabled={disabled}
|
|
129
125
|
value={value}
|
|
126
|
+
placeholder={placeholder}
|
|
130
127
|
/>
|
|
131
128
|
);
|
|
132
129
|
case 'textarea':
|
|
@@ -176,6 +173,7 @@ export function Input<T extends FieldValues>({
|
|
|
176
173
|
value={value}
|
|
177
174
|
setValue={setValue as UseFormSetValue<FieldValues>}
|
|
178
175
|
control={control as Control<FieldValues, any>}
|
|
176
|
+
placeholder={placeholder}
|
|
179
177
|
/>
|
|
180
178
|
);
|
|
181
179
|
case 'pilled-text':
|
|
@@ -220,12 +218,10 @@ export function Input<T extends FieldValues>({
|
|
|
220
218
|
inputType,
|
|
221
219
|
isInvalid,
|
|
222
220
|
isRequired,
|
|
223
|
-
leftElement,
|
|
224
221
|
maxLength,
|
|
225
222
|
name,
|
|
226
223
|
options,
|
|
227
224
|
placeholder,
|
|
228
|
-
rightElement,
|
|
229
225
|
setValue,
|
|
230
226
|
]
|
|
231
227
|
);
|
|
@@ -243,16 +239,7 @@ export function Input<T extends FieldValues>({
|
|
|
243
239
|
position="relative"
|
|
244
240
|
py={label ? 6 : 0}
|
|
245
241
|
>
|
|
246
|
-
{label &&
|
|
247
|
-
<FormLabel position="absolute" top={0} display="flex">
|
|
248
|
-
{label}
|
|
249
|
-
{isRequired && (
|
|
250
|
-
<Box ml={1} color="red.500">
|
|
251
|
-
*
|
|
252
|
-
</Box>
|
|
253
|
-
)}
|
|
254
|
-
</FormLabel>
|
|
255
|
-
)}
|
|
242
|
+
{label && <Label label={label} isRequired={isRequired} />}
|
|
256
243
|
{selectedInputField(
|
|
257
244
|
onChange ? onChange : fieldOnChange,
|
|
258
245
|
onBlur,
|
|
@@ -4,6 +4,7 @@ import { Text } from '../text';
|
|
|
4
4
|
import { Table, TableProps } from '.';
|
|
5
5
|
import { TableBody, TableHeaders } from './TableTypes';
|
|
6
6
|
import { useArgs } from '@storybook/addons';
|
|
7
|
+
import { Box } from '@chakra-ui/react';
|
|
7
8
|
|
|
8
9
|
const tableColumns = ['foo', 'bar'];
|
|
9
10
|
|
|
@@ -13,7 +14,14 @@ const tableHeaders: TableHeaders<typeof tableColumns> = {
|
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
const tableBody: TableBody<typeof tableColumns> = [
|
|
16
|
-
{
|
|
17
|
+
{
|
|
18
|
+
foo: (
|
|
19
|
+
<Box>
|
|
20
|
+
hi <Box>hi</Box>
|
|
21
|
+
</Box>
|
|
22
|
+
),
|
|
23
|
+
bar: 'hey',
|
|
24
|
+
},
|
|
17
25
|
{ foo: 'hi', bar: 'hey' },
|
|
18
26
|
{ foo: 'hi', bar: 'hey' },
|
|
19
27
|
];
|