@xqmsg/ui-core 0.24.1 → 0.24.3
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/README.md +8 -13
- package/dist/components/{table/index.d.ts → SimpleTable/SimpleTable.d.ts} +2 -2
- package/dist/components/SimpleTable/SimpleTable.stories.d.ts +6 -0
- package/dist/components/icons/workspace/index.d.ts +1 -0
- package/dist/components/input/components/dropdown/index.d.ts +1 -0
- package/dist/components/input/components/label/index.d.ts +1 -1
- package/dist/components/input/index.d.ts +1 -1
- package/dist/components/tabs/TabsWrapper.stories.d.ts +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/theme/components/popover.d.ts +8 -0
- package/dist/ui-core.cjs.development.js +230 -131
- 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 +234 -136
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +6 -2
- package/src/components/{table/Table.stories.tsx → SimpleTable/SimpleTable.stories.tsx} +8 -5
- package/src/components/{table/index.tsx → SimpleTable/SimpleTable.tsx} +3 -3
- package/src/components/{table → SimpleTable}/components/text/index.tsx +1 -1
- package/src/components/icons/checkmark/index.tsx +1 -1
- package/src/components/icons/chevron/down/index.tsx +7 -1
- package/src/components/icons/chevron/right/index.tsx +1 -1
- package/src/components/icons/clock/index.tsx +1 -1
- package/src/components/icons/dropdown/index.tsx +5 -1
- package/src/components/icons/error/index.tsx +1 -1
- package/src/components/icons/file/fill/index.tsx +1 -1
- package/src/components/icons/file/outline/index.tsx +1 -1
- package/src/components/icons/folder/add/fill/index.tsx +1 -1
- package/src/components/icons/folder/add/outline/index.tsx +1 -1
- package/src/components/icons/folder/outline/index.tsx +1 -1
- package/src/components/icons/group/index.tsx +1 -1
- package/src/components/icons/home/index.tsx +1 -1
- package/src/components/icons/image/index.tsx +1 -1
- package/src/components/icons/link/index.tsx +1 -1
- package/src/components/icons/menu/index.tsx +1 -1
- package/src/components/icons/microsoft/index.tsx +1 -1
- package/src/components/icons/neutral/index.tsx +3 -1
- package/src/components/icons/page/index.tsx +1 -1
- package/src/components/icons/positive/index.tsx +1 -1
- package/src/components/icons/question/index.tsx +1 -1
- package/src/components/icons/search/index.tsx +1 -1
- package/src/components/icons/services/index.tsx +1 -1
- package/src/components/icons/settings/index.tsx +3 -1
- package/src/components/icons/table/fill/index.tsx +1 -1
- package/src/components/icons/table/outline/index.tsx +1 -1
- package/src/components/icons/task/index.tsx +1 -1
- package/src/components/icons/trash/index.tsx +1 -1
- package/src/components/icons/video/index.tsx +1 -1
- package/src/components/icons/warning/index.tsx +1 -1
- package/src/components/icons/workspace/index.tsx +9 -1
- package/src/components/icons/workspace/workspace.svg +8 -0
- package/src/components/input/Input.stories.tsx +45 -0
- package/src/components/input/StackedMultiSelect/index.tsx +34 -27
- package/src/components/input/StackedSelect/index.tsx +30 -25
- package/src/components/input/components/dropdown/index.tsx +39 -11
- package/src/components/input/components/label/index.tsx +22 -6
- package/src/components/input/index.tsx +1 -1
- package/src/components/tabs/TabsWrapper.stories.tsx +4 -4
- package/src/index.tsx +4 -1
- package/src/theme/components/popover.ts +7 -0
- package/src/theme/customXQChakraTheme.ts +2 -0
- package/dist/components/table/Table.stories.d.ts +0 -6
- /package/dist/components/{table → SimpleTable}/TableTypes.d.ts +0 -0
- /package/dist/components/{table → SimpleTable}/components/loading/index.d.ts +0 -0
- /package/dist/components/{table → SimpleTable}/components/text/index.d.ts +0 -0
- /package/dist/components/{table → SimpleTable}/empty/index.d.ts +0 -0
- /package/dist/components/{table → SimpleTable}/utils/generateTableColumns.d.ts +0 -0
- /package/src/components/{table → SimpleTable}/TableTypes.ts +0 -0
- /package/src/components/{table → SimpleTable}/components/loading/index.tsx +0 -0
- /package/src/components/{table → SimpleTable}/empty/index.tsx +0 -0
- /package/src/components/{table → SimpleTable}/utils/generateTableColumns.ts +0 -0
|
@@ -2,18 +2,15 @@ import React, {
|
|
|
2
2
|
KeyboardEventHandler,
|
|
3
3
|
useEffect,
|
|
4
4
|
useRef,
|
|
5
|
-
useMemo,
|
|
6
5
|
useState,
|
|
7
6
|
} from 'react';
|
|
8
7
|
import { Box, Input, InputGroup, InputRightElement } from '@chakra-ui/react';
|
|
9
8
|
import { FieldOptions } from '../InputTypes';
|
|
10
9
|
import { StackedInputProps } from '../StackedInput/StackedInput';
|
|
11
|
-
import colors from '../../../theme/foundations/colors';
|
|
12
10
|
import { UseFormSetValue, FieldValues, Control } from 'react-hook-form';
|
|
13
11
|
import { Dropdown } from '../components/dropdown';
|
|
14
12
|
import { useOnClickOutside } from '../../../hooks/useOnOutsideClick';
|
|
15
13
|
import { Dropdown as DropdownIcon } from '../../icons/dropdown';
|
|
16
|
-
import { debounce } from 'lodash';
|
|
17
14
|
|
|
18
15
|
export interface StackedSelectProps extends StackedInputProps {
|
|
19
16
|
options: FieldOptions;
|
|
@@ -51,7 +48,9 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
|
|
|
51
48
|
const [optionIndex, setOptionIndex] = useState<number | null>(null);
|
|
52
49
|
const [position, setPosition] = useState<'top' | 'bottom'>('top');
|
|
53
50
|
const [searchValue, setSearchValue] = useState('');
|
|
54
|
-
const [
|
|
51
|
+
const [filteredOptions, setFilteredOptions] = useState<FieldOptions>(
|
|
52
|
+
options
|
|
53
|
+
);
|
|
55
54
|
|
|
56
55
|
const boundingClientRect = dropdownRef.current?.getBoundingClientRect() as DOMRect;
|
|
57
56
|
|
|
@@ -70,9 +69,12 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
|
|
|
70
69
|
(fullOptions || options).find(option => option.value === value)
|
|
71
70
|
?.label ?? ''
|
|
72
71
|
);
|
|
73
|
-
}, [fullOptions, value]);
|
|
72
|
+
}, [fullOptions, options, value]);
|
|
74
73
|
|
|
75
|
-
useOnClickOutside(dropdownRef, () =>
|
|
74
|
+
useOnClickOutside(dropdownRef, () => {
|
|
75
|
+
setIsFocussed(false);
|
|
76
|
+
setSearchValue('');
|
|
77
|
+
});
|
|
76
78
|
|
|
77
79
|
const handleOnSelectItem = (option: {
|
|
78
80
|
label: string;
|
|
@@ -85,6 +87,7 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
|
|
|
85
87
|
setValue(name as string, option.value);
|
|
86
88
|
setSelectedOption(option.label);
|
|
87
89
|
setIsFocussed(false);
|
|
90
|
+
setSearchValue('');
|
|
88
91
|
};
|
|
89
92
|
|
|
90
93
|
const handleOnKeyDown: KeyboardEventHandler<HTMLInputElement> = e => {
|
|
@@ -173,22 +176,27 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
|
|
|
173
176
|
top: idx * 24,
|
|
174
177
|
behavior: 'smooth',
|
|
175
178
|
});
|
|
176
|
-
|
|
177
|
-
setSearchValue('');
|
|
178
|
-
setDebouncedSearchValue('');
|
|
179
179
|
}
|
|
180
180
|
}, [options, searchValue]);
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
setFilteredOptions(
|
|
184
|
+
options.filter(element => {
|
|
185
|
+
return element.label
|
|
186
|
+
.toLowerCase()
|
|
187
|
+
.includes(searchValue.toLowerCase());
|
|
188
|
+
})
|
|
189
|
+
);
|
|
190
|
+
}, [options, searchValue]);
|
|
187
191
|
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
192
|
+
const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
193
|
+
const initialOptionIndex =
|
|
194
|
+
filteredOptions[0]?.value === 'section_header' ? 1 : 0;
|
|
195
|
+
setOptionIndex(initialOptionIndex);
|
|
196
|
+
const { value } = e.target;
|
|
197
|
+
setSearchValue(value);
|
|
191
198
|
};
|
|
199
|
+
console.log(searchValue);
|
|
192
200
|
|
|
193
201
|
return (
|
|
194
202
|
<Box ref={dropdownRef} position="relative">
|
|
@@ -198,21 +206,18 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
|
|
|
198
206
|
{...props}
|
|
199
207
|
ref={_ref}
|
|
200
208
|
onClick={() => setIsFocussed(!isFocussed)}
|
|
201
|
-
cursor=
|
|
202
|
-
color="transparent"
|
|
209
|
+
cursor={isFocussed ? 'select' : 'pointer'}
|
|
203
210
|
fontSize="13px"
|
|
204
|
-
|
|
205
|
-
value={selectedOption}
|
|
206
|
-
disabled={disabled}
|
|
211
|
+
value={isFocussed ? searchValue : selectedOption}
|
|
207
212
|
autoComplete="off"
|
|
208
|
-
onChange={
|
|
213
|
+
onChange={handleInput}
|
|
209
214
|
onKeyDown={handleOnKeyDown}
|
|
210
215
|
/>
|
|
211
216
|
<InputRightElement
|
|
212
217
|
cursor={disabled ? 'not-allowed' : 'pointer'}
|
|
213
218
|
onClick={() => !disabled && setIsFocussed(!isFocussed)}
|
|
214
219
|
>
|
|
215
|
-
<DropdownIcon boxSize="
|
|
220
|
+
<DropdownIcon boxSize="12px" disabled={disabled} />
|
|
216
221
|
</InputRightElement>
|
|
217
222
|
</InputGroup>
|
|
218
223
|
{isFocussed && (
|
|
@@ -220,7 +225,7 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
|
|
|
220
225
|
position={position}
|
|
221
226
|
dropdownRef={dropdownMenuRef}
|
|
222
227
|
onSelectItem={handleOnSelectItem}
|
|
223
|
-
options={
|
|
228
|
+
options={filteredOptions}
|
|
224
229
|
optionIndex={optionIndex}
|
|
225
230
|
/>
|
|
226
231
|
)}
|
|
@@ -9,6 +9,7 @@ export interface DropdownProps {
|
|
|
9
9
|
dropdownRef: RefObject<HTMLDivElement>;
|
|
10
10
|
position: 'top' | 'bottom';
|
|
11
11
|
optionIndex?: number | null;
|
|
12
|
+
children?: React.ReactNode;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -20,8 +21,25 @@ export const Dropdown: React.FC<DropdownProps> = ({
|
|
|
20
21
|
dropdownRef,
|
|
21
22
|
position,
|
|
22
23
|
optionIndex,
|
|
24
|
+
children,
|
|
23
25
|
}) => {
|
|
24
26
|
const DropdownContent = useMemo(() => {
|
|
27
|
+
if (!options || options.length === 0) {
|
|
28
|
+
return (
|
|
29
|
+
<Box
|
|
30
|
+
borderRadius="inherit"
|
|
31
|
+
fontSize="13px"
|
|
32
|
+
px="8px"
|
|
33
|
+
py="4px"
|
|
34
|
+
width="100%"
|
|
35
|
+
color={colors.label.primary.light}
|
|
36
|
+
bg="inherit"
|
|
37
|
+
whiteSpace="nowrap"
|
|
38
|
+
>
|
|
39
|
+
No options
|
|
40
|
+
</Box>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
25
43
|
return options.map((option, idx) => (
|
|
26
44
|
<Box key={idx} width="100%" role="combobox">
|
|
27
45
|
{option.value === 'section_header' &&
|
|
@@ -79,13 +97,8 @@ export const Dropdown: React.FC<DropdownProps> = ({
|
|
|
79
97
|
));
|
|
80
98
|
}, [onSelectItem, optionIndex, options]);
|
|
81
99
|
|
|
82
|
-
if (!options) return null;
|
|
83
|
-
|
|
84
100
|
return (
|
|
85
101
|
<Flex
|
|
86
|
-
flexDirection="column"
|
|
87
|
-
ref={dropdownRef}
|
|
88
|
-
scrollMargin="15px"
|
|
89
102
|
bg={colors.fill.light.quaternary}
|
|
90
103
|
backdropFilter="auto"
|
|
91
104
|
backdropBlur="64px"
|
|
@@ -94,18 +107,33 @@ export const Dropdown: React.FC<DropdownProps> = ({
|
|
|
94
107
|
borderColor={colors.fill.light.tertiary}
|
|
95
108
|
mt="3px"
|
|
96
109
|
maxH="240px"
|
|
97
|
-
|
|
110
|
+
position="absolute"
|
|
98
111
|
px="8px"
|
|
99
112
|
py="4px"
|
|
100
|
-
|
|
101
|
-
top={position === 'top' ? 26 : undefined}
|
|
102
|
-
bottom={position === 'bottom' ? 30 : undefined}
|
|
103
|
-
width="fit-content"
|
|
113
|
+
overflow="hidden"
|
|
104
114
|
minWidth="100%"
|
|
105
115
|
zIndex={100}
|
|
106
116
|
tabIndex={-2000}
|
|
117
|
+
alignItems="flex-start"
|
|
118
|
+
flexDirection="column"
|
|
119
|
+
top={position === 'top' ? 26 : undefined}
|
|
120
|
+
bottom={position === 'bottom' ? 30 : undefined}
|
|
107
121
|
>
|
|
108
|
-
{
|
|
122
|
+
{children && (
|
|
123
|
+
<Box width="100%" mb={2} mt={1}>
|
|
124
|
+
{children}
|
|
125
|
+
</Box>
|
|
126
|
+
)}
|
|
127
|
+
<Flex
|
|
128
|
+
width="fit-content"
|
|
129
|
+
overflowY="auto"
|
|
130
|
+
flexDirection="column"
|
|
131
|
+
ref={dropdownRef}
|
|
132
|
+
minWidth="100%"
|
|
133
|
+
scrollMargin="15px"
|
|
134
|
+
>
|
|
135
|
+
{DropdownContent}
|
|
136
|
+
</Flex>
|
|
109
137
|
</Flex>
|
|
110
138
|
);
|
|
111
139
|
};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
FormLabel,
|
|
5
|
+
Popover,
|
|
6
|
+
PopoverArrow,
|
|
7
|
+
PopoverBody,
|
|
8
|
+
PopoverContent,
|
|
9
|
+
PopoverTrigger,
|
|
10
|
+
} from '@chakra-ui/react';
|
|
3
11
|
import colors from '../../../../../src/theme/foundations/colors';
|
|
4
|
-
import {
|
|
12
|
+
import { QuestionIcon } from '@chakra-ui/icons';
|
|
5
13
|
|
|
6
14
|
export interface LabelProps {
|
|
7
15
|
label: string;
|
|
8
|
-
tooltipText?: string;
|
|
16
|
+
tooltipText?: string | React.ReactNode;
|
|
9
17
|
isRequired?: boolean;
|
|
10
18
|
}
|
|
11
19
|
|
|
@@ -26,9 +34,17 @@ export const Label: React.FC<LabelProps> = ({
|
|
|
26
34
|
</Box>
|
|
27
35
|
)}
|
|
28
36
|
{!!tooltipText && (
|
|
29
|
-
<
|
|
30
|
-
<
|
|
31
|
-
|
|
37
|
+
<Popover trigger="hover" placement="top">
|
|
38
|
+
<PopoverTrigger>
|
|
39
|
+
<Box as="span">
|
|
40
|
+
<QuestionIcon boxSize="13px" ml={1} color={colors.fill.action} />
|
|
41
|
+
</Box>
|
|
42
|
+
</PopoverTrigger>
|
|
43
|
+
<PopoverContent>
|
|
44
|
+
<PopoverArrow />
|
|
45
|
+
<PopoverBody>{tooltipText}</PopoverBody>
|
|
46
|
+
</PopoverContent>
|
|
47
|
+
</Popover>
|
|
32
48
|
)}
|
|
33
49
|
</FormLabel>
|
|
34
50
|
);
|
|
@@ -42,7 +42,7 @@ export interface InputProps<T extends FieldValues = FieldValues>
|
|
|
42
42
|
control: Control<T, any>;
|
|
43
43
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
44
44
|
disabled?: boolean;
|
|
45
|
-
tooltipText?: string;
|
|
45
|
+
tooltipText?: string | React.ReactNode;
|
|
46
46
|
setValue: UseFormSetValue<T>;
|
|
47
47
|
setError: UseFormSetError<T>;
|
|
48
48
|
clearErrors: UseFormClearErrors<T>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Meta, Story } from '@storybook/react';
|
|
3
3
|
import { Text } from '../text';
|
|
4
|
-
import {
|
|
5
|
-
import { TableBody, TableHeaders } from '../
|
|
4
|
+
import { SimpleTable, SimpleTableProps } from '../SimpleTable/SimpleTable';
|
|
5
|
+
import { TableBody, TableHeaders } from '../SimpleTable/TableTypes';
|
|
6
6
|
import { useMemo, useState } from '@storybook/addons';
|
|
7
7
|
import { TabsWrapper, TabsWrapperProps } from '.';
|
|
8
8
|
|
|
@@ -48,7 +48,7 @@ enum Foo {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
export default meta;
|
|
51
|
-
const Template: Story<
|
|
51
|
+
const Template: Story<SimpleTableProps<typeof tableColumns>> = args => {
|
|
52
52
|
const [index, setIndex] = useState(Foo.ALL);
|
|
53
53
|
|
|
54
54
|
const body = useMemo(() => {
|
|
@@ -69,7 +69,7 @@ const Template: Story<TableProps<typeof tableColumns>> = args => {
|
|
|
69
69
|
navIndex={index}
|
|
70
70
|
setNavIndex={(index: number) => setIndex(index)}
|
|
71
71
|
>
|
|
72
|
-
<
|
|
72
|
+
<SimpleTable
|
|
73
73
|
{...args}
|
|
74
74
|
body={body}
|
|
75
75
|
borderTopRadius={false}
|
package/src/index.tsx
CHANGED
|
@@ -38,6 +38,9 @@ export * from './components/input';
|
|
|
38
38
|
// Select
|
|
39
39
|
export { SelectNative } from './components/select';
|
|
40
40
|
|
|
41
|
+
// Label
|
|
42
|
+
export * from './components/input/components/label';
|
|
43
|
+
|
|
41
44
|
// Layout
|
|
42
45
|
export * from './components/layout';
|
|
43
46
|
|
|
@@ -54,7 +57,7 @@ export * from './components/modal';
|
|
|
54
57
|
export * from './components/navigation';
|
|
55
58
|
|
|
56
59
|
// Table
|
|
57
|
-
export
|
|
60
|
+
export { SimpleTable } from './components/SimpleTable/SimpleTable';
|
|
58
61
|
|
|
59
62
|
// Table Nav
|
|
60
63
|
export * from './components/tabs';
|
|
@@ -14,6 +14,7 @@ import FormLabel from './components/form-label';
|
|
|
14
14
|
import Input from './components/input';
|
|
15
15
|
import Link from './components/link';
|
|
16
16
|
import Modal from './components/modal';
|
|
17
|
+
import Popover from './components/popover';
|
|
17
18
|
import Select from './components/select';
|
|
18
19
|
import Switch from './components/switch';
|
|
19
20
|
import Table from './components/table';
|
|
@@ -39,6 +40,7 @@ const customXQChakraTheme = extendTheme({
|
|
|
39
40
|
Input,
|
|
40
41
|
Link,
|
|
41
42
|
Modal,
|
|
43
|
+
Popover,
|
|
42
44
|
Select,
|
|
43
45
|
Switch,
|
|
44
46
|
Table,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/react';
|
|
2
|
-
import { TableProps } from '.';
|
|
3
|
-
declare const tableColumns: string[];
|
|
4
|
-
declare const meta: Meta<TableProps<typeof tableColumns>>;
|
|
5
|
-
export default meta;
|
|
6
|
-
export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, TableProps<string[]>>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|