@xqmsg/ui-core 0.24.10 → 0.25.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/SimpleTable/SimpleTable.d.ts +4 -2
- package/dist/components/SimpleTable/TableTypes.d.ts +3 -0
- package/dist/components/form/FormTypes.d.ts +2 -2
- package/dist/components/input/InputTypes.d.ts +0 -1
- package/dist/components/input/StackedMultiSelect/index.d.ts +2 -2
- package/dist/components/input/StackedPilledInput/index.d.ts +1 -0
- package/dist/components/input/StackedRadio/StackedRadioGroup.d.ts +2 -2
- package/dist/components/input/StackedSelect/index.d.ts +3 -3
- package/dist/components/input/components/dropdown/index.d.ts +2 -2
- package/dist/components/input/components/token/index.d.ts +2 -0
- package/dist/components/input/index.d.ts +5 -4
- package/dist/components/select/index.d.ts +3 -3
- package/dist/components/toolbar/components/actions/sort/index.d.ts +2 -2
- package/dist/components/toolbar/components/dropdown/index.d.ts +2 -2
- package/dist/theme/components/menu.d.ts +55 -0
- package/dist/ui-core.cjs.development.js +133 -43
- 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 +133 -43
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/SimpleTable/SimpleTable.tsx +10 -3
- package/src/components/SimpleTable/TableTypes.ts +4 -0
- package/src/components/form/FormTypes.ts +2 -2
- package/src/components/icons/close/index.tsx +1 -0
- package/src/components/input/Input.stories.tsx +15 -0
- package/src/components/input/InputTypes.ts +0 -2
- package/src/components/input/StackedMultiSelect/index.tsx +5 -9
- package/src/components/input/StackedPilledInput/index.tsx +11 -4
- package/src/components/input/StackedRadio/StackedRadioGroup.tsx +2 -3
- package/src/components/input/StackedSelect/index.tsx +4 -4
- package/src/components/input/components/dropdown/index.tsx +2 -2
- package/src/components/input/components/token/index.tsx +12 -1
- package/src/components/input/index.tsx +9 -6
- package/src/components/select/index.tsx +3 -3
- package/src/components/toolbar/components/actions/sort/index.tsx +2 -2
- package/src/components/toolbar/components/dropdown/index.tsx +2 -2
- package/src/theme/components/menu.ts +78 -0
- package/src/theme/customXQChakraTheme.ts +2 -0
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
ReadonlyTableColumns,
|
|
4
4
|
TableBody,
|
|
5
5
|
TableColumns,
|
|
6
|
+
TableColumnsWidths,
|
|
6
7
|
TableHeaders,
|
|
7
8
|
} from './TableTypes';
|
|
8
9
|
import { generateTableColumnsAsConst } from './utils/generateTableColumns';
|
|
@@ -27,6 +28,8 @@ export interface SimpleTableProps<T extends ReadonlyTableColumns> {
|
|
|
27
28
|
loading?: boolean;
|
|
28
29
|
loadMore?: () => void;
|
|
29
30
|
placeholder?: string;
|
|
31
|
+
layout?: 'fixed' | 'auto';
|
|
32
|
+
columnsWidths?: TableColumnsWidths<T>;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
/**
|
|
@@ -38,6 +41,8 @@ export function SimpleTable<T extends ReadonlyTableColumns>({
|
|
|
38
41
|
body,
|
|
39
42
|
loading,
|
|
40
43
|
loadMore,
|
|
44
|
+
layout = 'auto',
|
|
45
|
+
columnsWidths,
|
|
41
46
|
}: SimpleTableProps<T>) {
|
|
42
47
|
const columnsAsConst = generateTableColumnsAsConst(columns);
|
|
43
48
|
|
|
@@ -50,14 +55,16 @@ export function SimpleTable<T extends ReadonlyTableColumns>({
|
|
|
50
55
|
style={{
|
|
51
56
|
borderCollapse: 'separate',
|
|
52
57
|
borderSpacing: '0px',
|
|
58
|
+
tableLayout: layout,
|
|
53
59
|
}}
|
|
54
60
|
>
|
|
55
|
-
{headers && (
|
|
61
|
+
{(headers || columnsWidths) && (
|
|
56
62
|
<Thead>
|
|
57
63
|
<Tr _odd={{ bg: colors.label.primary.dark }}>
|
|
58
64
|
{columnsAsConst.map((column, idx) => (
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
<Th key={idx} width={columnsWidths?.[column as T[number]]}>
|
|
66
|
+
{headers && headers[column as T[number]]}
|
|
67
|
+
</Th>
|
|
61
68
|
))}
|
|
62
69
|
</Tr>
|
|
63
70
|
</Thead>
|
|
@@ -8,6 +8,10 @@ export type TableHeaders<K extends ReadonlyTableColumns> = {
|
|
|
8
8
|
[k in K[number]]: ReactNode;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
export type TableColumnsWidths<K extends ReadonlyTableColumns> = {
|
|
12
|
+
[k in K[number]]: string | number;
|
|
13
|
+
};
|
|
14
|
+
|
|
11
15
|
export type TableRow<K extends ReadonlyTableColumns> = {
|
|
12
16
|
[k in K[number]]: ReactNode;
|
|
13
17
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FieldOption, InputType } from '../input/InputTypes';
|
|
2
2
|
|
|
3
3
|
export interface FormInput {
|
|
4
4
|
label: string;
|
|
5
5
|
name: string;
|
|
6
6
|
ariaLabel: string;
|
|
7
7
|
inputType: InputType;
|
|
8
|
-
options?:
|
|
8
|
+
options?: FieldOption[];
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
isRequired: boolean;
|
|
11
11
|
maxLength?: number;
|
|
@@ -112,6 +112,21 @@ const Template: Story<InputProps<StoryFormSchema>> = args => {
|
|
|
112
112
|
|
|
113
113
|
return (
|
|
114
114
|
<Form formHandler={formHandler}>
|
|
115
|
+
<Input
|
|
116
|
+
label="To"
|
|
117
|
+
name="recipients"
|
|
118
|
+
inputType="pilled-text"
|
|
119
|
+
placeholder="Enter email address..."
|
|
120
|
+
isInvalid={!!form.formState.errors['prop5']?.message}
|
|
121
|
+
errorText={form.formState.errors['prop5']?.message}
|
|
122
|
+
control={form.control}
|
|
123
|
+
setValue={form.setValue}
|
|
124
|
+
setError={form.setError}
|
|
125
|
+
clearErrors={form.clearErrors}
|
|
126
|
+
ariaLabel="email input"
|
|
127
|
+
isRequired
|
|
128
|
+
truncatePillLength={1000}
|
|
129
|
+
/>
|
|
115
130
|
<Input
|
|
116
131
|
{...args}
|
|
117
132
|
inputType="multi-select"
|
|
@@ -5,11 +5,7 @@ import React, {
|
|
|
5
5
|
useState,
|
|
6
6
|
} from 'react';
|
|
7
7
|
import { Box, Flex, Text, Input } from '@chakra-ui/react';
|
|
8
|
-
import {
|
|
9
|
-
FieldOption,
|
|
10
|
-
FieldOptions,
|
|
11
|
-
ReactSelectFieldProps,
|
|
12
|
-
} from '../InputTypes';
|
|
8
|
+
import { FieldOption, ReactSelectFieldProps } from '../InputTypes';
|
|
13
9
|
import colors from '../../../theme/foundations/colors';
|
|
14
10
|
import {
|
|
15
11
|
Control,
|
|
@@ -25,7 +21,7 @@ import Token from '../components/token';
|
|
|
25
21
|
import { useOnClickOutside } from '../../../hooks/useOnOutsideClick';
|
|
26
22
|
|
|
27
23
|
export interface StackedMultiSelectProps extends ReactSelectFieldProps {
|
|
28
|
-
options:
|
|
24
|
+
options: FieldOption[];
|
|
29
25
|
setValue: UseFormSetValue<FieldValues>;
|
|
30
26
|
setError: UseFormSetError<FieldValues>;
|
|
31
27
|
clearErrors: UseFormClearErrors<FieldValues>;
|
|
@@ -51,9 +47,9 @@ const StackedMultiSelect = React.forwardRef<
|
|
|
51
47
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
52
48
|
|
|
53
49
|
const [isInit, setIsInit] = useState(false);
|
|
54
|
-
const [localValues, setLocalValues] = useState<
|
|
55
|
-
const [localOptions, setLocalOptions] = useState<
|
|
56
|
-
const [filteredOptions, setFilteredOptions] = useState<
|
|
50
|
+
const [localValues, setLocalValues] = useState<FieldOption[]>([]);
|
|
51
|
+
const [localOptions, setLocalOptions] = useState<FieldOption[]>(options);
|
|
52
|
+
const [filteredOptions, setFilteredOptions] = useState<FieldOption[]>(
|
|
57
53
|
localOptions
|
|
58
54
|
);
|
|
59
55
|
const [isFocussed, setIsFocussed] = useState(false);
|
|
@@ -21,6 +21,7 @@ export interface StackedPilledInputProps extends InputFieldProps {
|
|
|
21
21
|
variant?: string;
|
|
22
22
|
label?: string;
|
|
23
23
|
truncatePillLength?: number;
|
|
24
|
+
mode?: 'scroll' | 'wrap';
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -41,6 +42,7 @@ const StackedPilledInput = React.forwardRef<
|
|
|
41
42
|
variant,
|
|
42
43
|
label,
|
|
43
44
|
truncatePillLength,
|
|
45
|
+
mode = 'scroll',
|
|
44
46
|
},
|
|
45
47
|
_ref
|
|
46
48
|
) => {
|
|
@@ -60,7 +62,7 @@ const StackedPilledInput = React.forwardRef<
|
|
|
60
62
|
const latestTokenElement = document.getElementById(
|
|
61
63
|
`${name}_token_${lastestFormValueToArray.length - 1}`
|
|
62
64
|
);
|
|
63
|
-
|
|
65
|
+
const scrollMode = mode === 'scroll';
|
|
64
66
|
// gets latest watched form value (common delimited) from RHF state and creates a list
|
|
65
67
|
useEffect(() => {
|
|
66
68
|
if (watchedValue !== undefined && !watchedValue.length) {
|
|
@@ -290,12 +292,14 @@ const StackedPilledInput = React.forwardRef<
|
|
|
290
292
|
bg={disabled ? colors.fill.light.quaternary : '#ffffff'}
|
|
291
293
|
cursor={disabled ? 'not-allowed' : 'pointer'}
|
|
292
294
|
ref={inputWrapperRef}
|
|
293
|
-
h={isMobile ? '48px' : '26px'}
|
|
295
|
+
h={isMobile ? '48px' : scrollMode ? '26px' : 'auto'}
|
|
296
|
+
minH={isMobile ? '48px' : '26px'}
|
|
294
297
|
>
|
|
295
298
|
<Flex
|
|
296
299
|
h="100%"
|
|
297
300
|
alignItems="center"
|
|
298
|
-
overflowX=
|
|
301
|
+
overflowX={scrollMode ? 'scroll' : 'hidden'}
|
|
302
|
+
flexWrap={scrollMode ? 'nowrap' : 'wrap'}
|
|
299
303
|
overflowY="hidden"
|
|
300
304
|
maxWidth={isFocussed ? '80%' : '100%'}
|
|
301
305
|
style={{
|
|
@@ -323,11 +327,14 @@ const StackedPilledInput = React.forwardRef<
|
|
|
323
327
|
}
|
|
324
328
|
borderRadius="full"
|
|
325
329
|
onClick={() => setTokenIndex(index)}
|
|
326
|
-
width=
|
|
330
|
+
width={scrollMode ? '100%' : 'auto'}
|
|
331
|
+
maxWidth={'100%'}
|
|
327
332
|
id={`${name}_token_${index}`}
|
|
328
333
|
>
|
|
329
334
|
<Token
|
|
335
|
+
maxWidth={'100%'}
|
|
330
336
|
label={label}
|
|
337
|
+
showClose={!isFocussed || tokenIndex === index}
|
|
331
338
|
onDelete={(e: any) => {
|
|
332
339
|
e.stopPropagation();
|
|
333
340
|
e.preventDefault();
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Flex, InputGroup, Radio, RadioGroup } from '@chakra-ui/react';
|
|
3
|
-
import {
|
|
3
|
+
import { FieldOption, SelectFieldProps } from '../InputTypes';
|
|
4
4
|
|
|
5
5
|
export interface StackedRadioGroupProps extends SelectFieldProps {
|
|
6
6
|
flexDirection?: 'row' | 'column';
|
|
7
|
-
|
|
8
|
-
options: FieldOptions;
|
|
7
|
+
options: FieldOption[];
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -5,7 +5,7 @@ import React, {
|
|
|
5
5
|
useState,
|
|
6
6
|
} from 'react';
|
|
7
7
|
import { Box, Input, InputGroup, InputRightElement } from '@chakra-ui/react';
|
|
8
|
-
import {
|
|
8
|
+
import { FieldOption } from '../InputTypes';
|
|
9
9
|
import { StackedInputProps } from '../StackedInput/StackedInput';
|
|
10
10
|
import { UseFormSetValue, FieldValues, Control } from 'react-hook-form';
|
|
11
11
|
import { Dropdown } from '../components/dropdown';
|
|
@@ -13,8 +13,8 @@ import { useOnClickOutside } from '../../../hooks/useOnOutsideClick';
|
|
|
13
13
|
import { Dropdown as DropdownIcon } from '../../icons/dropdown';
|
|
14
14
|
|
|
15
15
|
export interface StackedSelectProps extends StackedInputProps {
|
|
16
|
-
options:
|
|
17
|
-
fullOptions?:
|
|
16
|
+
options: FieldOption[];
|
|
17
|
+
fullOptions?: FieldOption[];
|
|
18
18
|
setValue: UseFormSetValue<FieldValues>;
|
|
19
19
|
control: Control<FieldValues, any>;
|
|
20
20
|
handleOnChange: (value?: string) => void;
|
|
@@ -52,7 +52,7 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
|
|
|
52
52
|
const [optionIndex, setOptionIndex] = useState<number | null>(null);
|
|
53
53
|
const [position, setPosition] = useState<'top' | 'bottom'>('top');
|
|
54
54
|
const [searchValue, setSearchValue] = useState('');
|
|
55
|
-
const [filteredOptions, setFilteredOptions] = useState<
|
|
55
|
+
const [filteredOptions, setFilteredOptions] = useState<FieldOption[]>(
|
|
56
56
|
options
|
|
57
57
|
);
|
|
58
58
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { RefObject, useMemo } from 'react';
|
|
2
2
|
import { Box, Flex, Spinner } from '@chakra-ui/react';
|
|
3
3
|
import colors from '../../../../../src/theme/foundations/colors';
|
|
4
|
-
import { FieldOption
|
|
4
|
+
import { FieldOption } from '../../InputTypes';
|
|
5
5
|
|
|
6
6
|
export interface DropdownProps {
|
|
7
7
|
onSelectItem: (option: FieldOption) => void;
|
|
8
|
-
options:
|
|
8
|
+
options: FieldOption[];
|
|
9
9
|
dropdownRef: RefObject<HTMLDivElement>;
|
|
10
10
|
position: 'top' | 'bottom';
|
|
11
11
|
optionIndex?: number | null;
|
|
@@ -9,6 +9,8 @@ export interface TokenProps {
|
|
|
9
9
|
onDelete: any;
|
|
10
10
|
isMobile?: boolean;
|
|
11
11
|
truncateLength?: number;
|
|
12
|
+
showClose?: boolean;
|
|
13
|
+
maxWidth?: string | number;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
// For v1 we are truncating the label at 15 characters to avoid overflow
|
|
@@ -17,6 +19,8 @@ const Token: React.FC<TokenProps> = ({
|
|
|
17
19
|
onDelete,
|
|
18
20
|
isMobile = false,
|
|
19
21
|
truncateLength = 15,
|
|
22
|
+
showClose = true,
|
|
23
|
+
maxWidth = 'auto',
|
|
20
24
|
}) => {
|
|
21
25
|
return (
|
|
22
26
|
<Flex
|
|
@@ -26,6 +30,7 @@ const Token: React.FC<TokenProps> = ({
|
|
|
26
30
|
alignItems="center"
|
|
27
31
|
width="fit-content"
|
|
28
32
|
w="auto"
|
|
33
|
+
maxWidth={maxWidth}
|
|
29
34
|
h={isMobile ? '18px' : '16px'}
|
|
30
35
|
pl="6px"
|
|
31
36
|
pr="2px"
|
|
@@ -34,16 +39,22 @@ const Token: React.FC<TokenProps> = ({
|
|
|
34
39
|
>
|
|
35
40
|
<Text
|
|
36
41
|
whiteSpace="nowrap"
|
|
42
|
+
wordBreak="break-word"
|
|
37
43
|
color={colors.label.primary.light}
|
|
38
44
|
fontSize={isMobile ? '17px' : '13px'}
|
|
39
45
|
pr="4px"
|
|
46
|
+
maxWidth={maxWidth}
|
|
47
|
+
overflow="hidden"
|
|
48
|
+
textOverflow="ellipsis"
|
|
40
49
|
>
|
|
41
50
|
{truncate(label.trim(), {
|
|
42
51
|
length: truncateLength,
|
|
43
52
|
omission: '...',
|
|
44
53
|
})}
|
|
45
54
|
</Text>
|
|
46
|
-
|
|
55
|
+
{showClose && (
|
|
56
|
+
<Close boxSize={isMobile ? '17px' : '11px'} onClick={onDelete} />
|
|
57
|
+
)}
|
|
47
58
|
</Flex>
|
|
48
59
|
);
|
|
49
60
|
};
|
|
@@ -4,7 +4,7 @@ import StackedInput from './StackedInput/StackedInput';
|
|
|
4
4
|
import StackedRadioGroup from './StackedRadio/StackedRadioGroup';
|
|
5
5
|
import StackedSelect from './StackedSelect';
|
|
6
6
|
import StackedTextarea from './StackedTextarea/StackedTextarea';
|
|
7
|
-
import {
|
|
7
|
+
import { FieldOption, ValidationProps, InputType } from './InputTypes';
|
|
8
8
|
import {
|
|
9
9
|
FormControl,
|
|
10
10
|
FormErrorMessage,
|
|
@@ -35,8 +35,8 @@ export interface InputProps<T extends FieldValues = FieldValues>
|
|
|
35
35
|
defaultValue?: string;
|
|
36
36
|
label?: string;
|
|
37
37
|
className?: string;
|
|
38
|
-
options?:
|
|
39
|
-
fullOptions?:
|
|
38
|
+
options?: FieldOption[];
|
|
39
|
+
fullOptions?: FieldOption[];
|
|
40
40
|
maxLength?: number;
|
|
41
41
|
helperText?: React.ReactNode;
|
|
42
42
|
control: Control<T, any>;
|
|
@@ -53,6 +53,7 @@ export interface InputProps<T extends FieldValues = FieldValues>
|
|
|
53
53
|
loadingOptions?: boolean;
|
|
54
54
|
truncatePillLength?: number;
|
|
55
55
|
searchable?: boolean;
|
|
56
|
+
overflowMode?: 'scroll' | 'wrap';
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
/**
|
|
@@ -88,6 +89,7 @@ export function Input<T extends FieldValues>({
|
|
|
88
89
|
loadingOptions = false,
|
|
89
90
|
truncatePillLength,
|
|
90
91
|
searchable,
|
|
92
|
+
overflowMode = 'scroll',
|
|
91
93
|
}: InputProps<T>) {
|
|
92
94
|
function selectedInputField<T extends Element = Element>(
|
|
93
95
|
onChange: ((e: ChangeEvent<T>) => void) | ((v?: string) => void),
|
|
@@ -126,7 +128,7 @@ export function Input<T extends FieldValues>({
|
|
|
126
128
|
name={name}
|
|
127
129
|
id={name}
|
|
128
130
|
isInvalid={isInvalid}
|
|
129
|
-
options={options as
|
|
131
|
+
options={options as FieldOption[]}
|
|
130
132
|
onChange={onChange as (e: ChangeEvent) => void}
|
|
131
133
|
onBlur={onBlur}
|
|
132
134
|
ref={ref}
|
|
@@ -142,7 +144,7 @@ export function Input<T extends FieldValues>({
|
|
|
142
144
|
id={name}
|
|
143
145
|
isRequired={isRequired}
|
|
144
146
|
isInvalid={isInvalid}
|
|
145
|
-
options={options as
|
|
147
|
+
options={options as FieldOption[]}
|
|
146
148
|
handleOnChange={onChange as (v?: string) => void}
|
|
147
149
|
onBlur={onBlur}
|
|
148
150
|
setValue={setValue as UseFormSetValue<FieldValues>}
|
|
@@ -201,7 +203,7 @@ export function Input<T extends FieldValues>({
|
|
|
201
203
|
name={name}
|
|
202
204
|
id={name}
|
|
203
205
|
isInvalid={isInvalid}
|
|
204
|
-
options={options as
|
|
206
|
+
options={options as FieldOption[]}
|
|
205
207
|
onChange={onChange as (e: ChangeEvent) => void}
|
|
206
208
|
onBlur={onBlur}
|
|
207
209
|
ref={ref}
|
|
@@ -238,6 +240,7 @@ export function Input<T extends FieldValues>({
|
|
|
238
240
|
label={label}
|
|
239
241
|
separators={separators}
|
|
240
242
|
truncatePillLength={truncatePillLength}
|
|
243
|
+
mode={overflowMode}
|
|
241
244
|
/>
|
|
242
245
|
);
|
|
243
246
|
case 'switch':
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
UseFormSetError,
|
|
16
16
|
UseFormSetValue,
|
|
17
17
|
} from 'react-hook-form';
|
|
18
|
-
import {
|
|
18
|
+
import { FieldOption, ValidationProps } from 'src/components/input/InputTypes';
|
|
19
19
|
|
|
20
20
|
export interface SelectNativeProps<T extends FieldValues>
|
|
21
21
|
extends ValidationProps,
|
|
@@ -28,8 +28,8 @@ export interface SelectNativeProps<T extends FieldValues>
|
|
|
28
28
|
defaultValue?: string;
|
|
29
29
|
label?: string;
|
|
30
30
|
className?: string;
|
|
31
|
-
options?:
|
|
32
|
-
fullOptions?:
|
|
31
|
+
options?: FieldOption[];
|
|
32
|
+
fullOptions?: FieldOption[];
|
|
33
33
|
helperText?: React.ReactNode;
|
|
34
34
|
control: Control<T, unknown>;
|
|
35
35
|
onChange?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
@@ -2,11 +2,11 @@ import React, { useRef, useState } from 'react';
|
|
|
2
2
|
import { Box, Flex, useOutsideClick } from '@chakra-ui/react';
|
|
3
3
|
import { ChevronDown, TableOutline } from '../../../../icons';
|
|
4
4
|
import { Dropdown } from '../../dropdown';
|
|
5
|
-
import { FieldOption
|
|
5
|
+
import { FieldOption } from '../../../../input/InputTypes';
|
|
6
6
|
|
|
7
7
|
export interface SortProps {
|
|
8
8
|
onSelectItem: (option: FieldOption) => void;
|
|
9
|
-
sortOptions:
|
|
9
|
+
sortOptions: FieldOption[];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { RefObject, useMemo } from 'react';
|
|
2
2
|
import { Box, Flex } from '@chakra-ui/react';
|
|
3
3
|
import colors from '../../../../theme/foundations/colors';
|
|
4
|
-
import { FieldOption
|
|
4
|
+
import { FieldOption } from '../../../input/InputTypes';
|
|
5
5
|
import { Checkmark } from '../../../icons';
|
|
6
6
|
|
|
7
7
|
export interface DropdownProps {
|
|
8
8
|
onSelectItem: (option: FieldOption) => void;
|
|
9
|
-
options:
|
|
9
|
+
options: FieldOption[];
|
|
10
10
|
dropdownRef: RefObject<HTMLDivElement>;
|
|
11
11
|
position: 'top' | 'bottom';
|
|
12
12
|
optionIndex: number | null;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { mode } from '@chakra-ui/theme-tools';
|
|
2
|
+
import colors from '../foundations/colors';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
type Dict = Record<string, any>;
|
|
6
|
+
|
|
7
|
+
const parts = ['item', 'command', 'list', 'button', 'groupTitle'];
|
|
8
|
+
|
|
9
|
+
function baseStyleList(props: Dict) {
|
|
10
|
+
return {
|
|
11
|
+
bg: colors.fill.light.quaternary,
|
|
12
|
+
boxShadow: mode(`2xl`, `dark-lg`)(props),
|
|
13
|
+
color: 'inherit',
|
|
14
|
+
minW: '3xs',
|
|
15
|
+
py: 4,
|
|
16
|
+
px: 2,
|
|
17
|
+
zIndex: 'docked',
|
|
18
|
+
borderWidth: 0,
|
|
19
|
+
overflow: 'hidden',
|
|
20
|
+
backdropFilter: 'auto',
|
|
21
|
+
backdropBlur: '64px',
|
|
22
|
+
borderRadius: '4px',
|
|
23
|
+
border: '0.25px solid',
|
|
24
|
+
borderColor: colors.fill.light.tertiary,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function baseStyleItem(props: Dict) {
|
|
29
|
+
return {
|
|
30
|
+
fontSize: '13px;',
|
|
31
|
+
fontWeight: 500,
|
|
32
|
+
lineHeight: '16px',
|
|
33
|
+
py: 3,
|
|
34
|
+
px: 4,
|
|
35
|
+
borderRadius: '4px',
|
|
36
|
+
width: '100%',
|
|
37
|
+
transition: 'background 50ms ease-in 0s',
|
|
38
|
+
_hover: {
|
|
39
|
+
color: colors.white,
|
|
40
|
+
background: colors.fill.action,
|
|
41
|
+
},
|
|
42
|
+
_active: {
|
|
43
|
+
bg: mode(`gray.200`, `whiteAlpha.200`)(props),
|
|
44
|
+
},
|
|
45
|
+
_expanded: {
|
|
46
|
+
bg: mode(`gray.100`, `whiteAlpha.100`)(props),
|
|
47
|
+
},
|
|
48
|
+
_disabled: {
|
|
49
|
+
opacity: 0.4,
|
|
50
|
+
cursor: 'not-allowed',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const baseStyleGroupTitle = {
|
|
56
|
+
mx: 4,
|
|
57
|
+
my: 2,
|
|
58
|
+
fontWeight: 'semibold',
|
|
59
|
+
fontSize: 'sm',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const baseStyleCommand = {
|
|
63
|
+
opacity: 0.6,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const baseStyle = (props: Dict) => {
|
|
67
|
+
return {
|
|
68
|
+
list: baseStyleList(props),
|
|
69
|
+
item: baseStyleItem(props),
|
|
70
|
+
groupTitle: baseStyleGroupTitle,
|
|
71
|
+
command: baseStyleCommand,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default {
|
|
76
|
+
parts,
|
|
77
|
+
baseStyle,
|
|
78
|
+
};
|
|
@@ -13,6 +13,7 @@ import FormError from './components/form-error';
|
|
|
13
13
|
import FormLabel from './components/form-label';
|
|
14
14
|
import Input from './components/input';
|
|
15
15
|
import Link from './components/link';
|
|
16
|
+
import Menu from './components/menu';
|
|
16
17
|
import Modal from './components/modal';
|
|
17
18
|
import Popover from './components/popover';
|
|
18
19
|
import Select from './components/select';
|
|
@@ -39,6 +40,7 @@ const customXQChakraTheme = extendTheme({
|
|
|
39
40
|
FormLabel,
|
|
40
41
|
Input,
|
|
41
42
|
Link,
|
|
43
|
+
Menu,
|
|
42
44
|
Modal,
|
|
43
45
|
Popover,
|
|
44
46
|
Select,
|