@livechat/design-system-react-components 1.14.0 → 1.16.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/Button.d.ts +3 -4
- package/dist/components/Button/Button.stories.d.ts +3 -2
- package/dist/components/Button/types.d.ts +1 -0
- package/dist/components/Picker/Picker.d.ts +1 -76
- package/dist/components/Picker/Picker.stories.d.ts +1 -1
- package/dist/components/Picker/components/PickerList.d.ts +25 -0
- package/dist/components/Picker/components/PickerListItem.d.ts +14 -0
- package/dist/components/Picker/components/PickerTrigger.d.ts +17 -0
- package/dist/components/Picker/components/PickerTriggerBody.d.ts +19 -0
- package/dist/components/Picker/constants.d.ts +18 -1
- package/dist/components/Picker/helpers.d.ts +2 -1
- package/dist/components/Picker/index.d.ts +2 -2
- package/dist/components/Picker/types.d.ts +103 -3
- package/dist/components/Popover/types.d.ts +2 -2
- package/dist/components/Tag/Tag.d.ts +1 -1
- package/dist/dsrc.cjs.js +1 -1
- package/dist/dsrc.es.js +2130 -2025
- package/dist/preview-stats.json +650 -623
- package/dist/stories/components/StoryDescriptor.d.ts +1 -0
- package/dist/style.css +1 -1
- package/dist/themes/design-token.d.ts +1 -0
- package/package.json +6 -8
- package/dist/components/Picker/PickerList.d.ts +0 -14
- package/dist/components/Picker/PickerListItem.d.ts +0 -11
- package/dist/components/Picker/Trigger.d.ts +0 -17
- package/dist/components/Picker/TriggerBody.d.ts +0 -16
- /package/dist/components/Picker/{PickerList.spec.d.ts → components/PickerList.spec.d.ts} +0 -0
- /package/dist/components/Picker/{Trigger.spec.d.ts → components/PickerTrigger.spec.d.ts} +0 -0
- /package/dist/components/Picker/{TriggerBody.spec.d.ts → components/PickerTriggerBody.spec.d.ts} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { ButtonKind } from './types';
|
|
2
|
+
import { ButtonKind, ButtonSize } from './types';
|
|
4
3
|
export type ButtonProps = {
|
|
5
4
|
/**
|
|
6
5
|
* Specify the button kind
|
|
@@ -9,7 +8,7 @@ export type ButtonProps = {
|
|
|
9
8
|
/**
|
|
10
9
|
* Specify the button size
|
|
11
10
|
*/
|
|
12
|
-
size?:
|
|
11
|
+
size?: ButtonSize;
|
|
13
12
|
/**
|
|
14
13
|
* Set the loading state
|
|
15
14
|
*/
|
|
@@ -39,7 +38,7 @@ export declare const Button: React.ForwardRefExoticComponent<{
|
|
|
39
38
|
/**
|
|
40
39
|
* Specify the button size
|
|
41
40
|
*/
|
|
42
|
-
size?:
|
|
41
|
+
size?: ButtonSize | undefined;
|
|
43
42
|
/**
|
|
44
43
|
* Set the loading state
|
|
45
44
|
*/
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ButtonProps } from './Button';
|
|
3
|
+
import { ButtonKind, ButtonSize } from './types';
|
|
3
4
|
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, {
|
|
4
|
-
kind?:
|
|
5
|
-
size?:
|
|
5
|
+
kind?: ButtonKind | undefined;
|
|
6
|
+
size?: ButtonSize | undefined;
|
|
6
7
|
loading?: boolean | undefined;
|
|
7
8
|
fullWidth?: boolean | undefined;
|
|
8
9
|
loaderLabel?: string | undefined;
|
|
@@ -1,78 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { IPickerListItem, PickerType } from './types';
|
|
4
|
-
export interface IPickerProps {
|
|
5
|
-
/**
|
|
6
|
-
* Specify the custom id
|
|
7
|
-
*/
|
|
8
|
-
id?: string;
|
|
9
|
-
/**
|
|
10
|
-
* The CSS class for picker container
|
|
11
|
-
*/
|
|
12
|
-
className?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Specify whether the picker should be disabled
|
|
15
|
-
*/
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Specify whether the picker should be in error state
|
|
19
|
-
*/
|
|
20
|
-
error?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Array of picker options
|
|
23
|
-
*/
|
|
24
|
-
options: IPickerListItem[];
|
|
25
|
-
/**
|
|
26
|
-
* Array of picker selected options
|
|
27
|
-
*/
|
|
28
|
-
selected?: IPickerListItem[] | null;
|
|
29
|
-
/**
|
|
30
|
-
* Specify the picker size
|
|
31
|
-
*/
|
|
32
|
-
size?: Size;
|
|
33
|
-
/**
|
|
34
|
-
* Specify the placeholder for search input
|
|
35
|
-
*/
|
|
36
|
-
placeholder?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Specify whether the option select is required
|
|
39
|
-
*/
|
|
40
|
-
isRequired?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Text if no search result were found
|
|
43
|
-
*/
|
|
44
|
-
noSearchResultText?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Text for `select all` option which will be visible if defined in multi select mode
|
|
47
|
-
*/
|
|
48
|
-
selectAllOptionText?: string;
|
|
49
|
-
/**
|
|
50
|
-
* Set `multi` to specify whether the picker should allow to multi selection
|
|
51
|
-
*/
|
|
52
|
-
type?: PickerType;
|
|
53
|
-
/**
|
|
54
|
-
* Set to disable search input
|
|
55
|
-
*/
|
|
56
|
-
searchDisabled?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Set to hide clear selection button
|
|
59
|
-
*/
|
|
60
|
-
hideClearButton?: boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Will open picker on component initialization
|
|
63
|
-
*/
|
|
64
|
-
openedOnInit?: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Test id passed to the picker trigger element
|
|
67
|
-
*/
|
|
68
|
-
['data-testid']?: string;
|
|
69
|
-
/**
|
|
70
|
-
* Callback called after item selection
|
|
71
|
-
*/
|
|
72
|
-
onSelect: (selectedItems: IPickerListItem[] | null) => void;
|
|
73
|
-
/**
|
|
74
|
-
* Clears the search input after item select
|
|
75
|
-
*/
|
|
76
|
-
clearSearchAfterSelection?: boolean;
|
|
77
|
-
}
|
|
2
|
+
import { IPickerProps } from './types';
|
|
78
3
|
export declare const Picker: React.FC<IPickerProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { IPickerProps } from './
|
|
2
|
+
import { IPickerProps } from './types';
|
|
3
3
|
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, IPickerProps & {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
5
|
}>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FloatingContext } from '@floating-ui/react';
|
|
3
|
+
import { VirtuosoProps } from 'react-virtuoso';
|
|
4
|
+
import { IPickerListItem } from '../types';
|
|
5
|
+
export interface IPickerListProps {
|
|
6
|
+
pickerType?: 'single' | 'multi';
|
|
7
|
+
options: IPickerListItem[];
|
|
8
|
+
context: FloatingContext<HTMLButtonElement>;
|
|
9
|
+
setFloating: (node: HTMLElement | null) => void;
|
|
10
|
+
floatingStyles: React.CSSProperties;
|
|
11
|
+
maxHeight: number;
|
|
12
|
+
listElementsRef: React.MutableRefObject<(HTMLElement | null)[]>;
|
|
13
|
+
isPositioned: boolean;
|
|
14
|
+
pointer: boolean;
|
|
15
|
+
activeIndex: number | null;
|
|
16
|
+
selectedKeys: string[];
|
|
17
|
+
setPointer: (pointer: boolean) => void;
|
|
18
|
+
onSelect: (key: string) => void;
|
|
19
|
+
getFloatingProps: (userProps?: React.HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
|
|
20
|
+
getItemProps: (userProps?: React.HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
|
|
21
|
+
emptyStateText?: string;
|
|
22
|
+
listClassName?: string;
|
|
23
|
+
virtuosoProps?: VirtuosoProps<IPickerListItem, unknown>;
|
|
24
|
+
}
|
|
25
|
+
export declare const PickerList: React.FC<IPickerListProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { IPickerListItem } from '../types';
|
|
3
|
+
interface IPickerListItemProps {
|
|
4
|
+
index: number;
|
|
5
|
+
isActive: boolean;
|
|
6
|
+
isSelected: boolean;
|
|
7
|
+
numberOfItems: number;
|
|
8
|
+
listElementsRef: React.MutableRefObject<(HTMLElement | null)[]>;
|
|
9
|
+
onSelect: (key: string) => void;
|
|
10
|
+
getItemProps: (userProps?: React.HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
|
|
11
|
+
item: IPickerListItem;
|
|
12
|
+
}
|
|
13
|
+
export declare const PickerListItem: React.FC<IPickerListItemProps>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Size } from '../../../utils';
|
|
3
|
+
export interface PickerTriggerProps {
|
|
4
|
+
setReference: (element: HTMLElement | null) => void;
|
|
5
|
+
getReferenceProps: (userProps?: React.HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
|
|
6
|
+
testId?: string;
|
|
7
|
+
size?: Size;
|
|
8
|
+
isMultiSelect?: boolean;
|
|
9
|
+
isItemSelected: boolean;
|
|
10
|
+
hideClearButton?: boolean;
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
isRequired?: boolean;
|
|
13
|
+
isError?: boolean;
|
|
14
|
+
isOpen: boolean;
|
|
15
|
+
onClear: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const PickerTrigger: React.FC<React.PropsWithChildren<PickerTriggerProps>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Size } from '../../../utils';
|
|
3
|
+
import { PickerType, IPickerListItem } from '../types';
|
|
4
|
+
export interface ITriggerBodyProps {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
isSearchDisabled?: boolean;
|
|
7
|
+
isDisabled?: boolean;
|
|
8
|
+
placeholder: string;
|
|
9
|
+
searchPhrase?: string;
|
|
10
|
+
selectedItems?: IPickerListItem[] | null;
|
|
11
|
+
type: PickerType;
|
|
12
|
+
clearSearchAfterSelection?: boolean;
|
|
13
|
+
size?: Size;
|
|
14
|
+
onItemRemove: (key: string) => void;
|
|
15
|
+
onSelect: (key: string) => void;
|
|
16
|
+
onFilter: (text: string) => void;
|
|
17
|
+
virtualItemRef: React.MutableRefObject<HTMLElement | null>;
|
|
18
|
+
}
|
|
19
|
+
export declare const PickerTriggerBody: React.FC<ITriggerBodyProps>;
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const ITEM_ROW_HEIGHT = 35;
|
|
2
|
+
export declare const ITEM_GAP_HEIGHT = 2;
|
|
3
|
+
export declare const ITEM_HEIGHT: number;
|
|
4
|
+
export declare const DEFAULT_LIST_HEIGHT = 400;
|
|
5
|
+
export declare const DEFAULT_PICKER_OPTIONS: ({
|
|
6
|
+
key: string;
|
|
7
|
+
name: string;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
} | {
|
|
10
|
+
key: string;
|
|
11
|
+
name: string;
|
|
12
|
+
groupHeader?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
key: string;
|
|
15
|
+
name: string;
|
|
16
|
+
groupHeader: boolean;
|
|
17
|
+
})[];
|
|
18
|
+
export declare const SELECTED_OPTIONS: {
|
|
2
19
|
key: string;
|
|
3
20
|
name: string;
|
|
4
21
|
}[];
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { IPickerListItem } from './types';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const findIndicesWhere: <T>(array: T[], predicate: (item: T) => boolean) => number[];
|
|
3
|
+
export declare const getNormalizedItems: (items: IPickerListItem[]) => IPickerListItem[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './Picker';
|
|
2
|
-
export * from './PickerList';
|
|
3
|
-
export type { PickerType, IPickerListItem } from './types';
|
|
2
|
+
export * from './components/PickerList';
|
|
3
|
+
export type { PickerType, IPickerListItem, IPickerProps } from './types';
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { Strategy, UseClickProps, UseDismissProps } from '@floating-ui/react';
|
|
3
|
+
import { VirtuosoProps } from 'react-virtuoso';
|
|
4
|
+
import { Size } from '../../utils';
|
|
2
5
|
import { IconSource } from '../Icon';
|
|
3
6
|
export interface IPickerListItem {
|
|
4
7
|
key: string;
|
|
5
8
|
name: string;
|
|
6
9
|
customElement?: {
|
|
7
|
-
listItemBody:
|
|
8
|
-
selectedItemBody:
|
|
10
|
+
listItemBody: ReactElement;
|
|
11
|
+
selectedItemBody: ReactElement;
|
|
9
12
|
};
|
|
10
13
|
groupHeader?: boolean;
|
|
11
14
|
disabled?: boolean;
|
|
@@ -15,3 +18,100 @@ export interface IPickerListItem {
|
|
|
15
18
|
showCheckbox?: boolean;
|
|
16
19
|
}
|
|
17
20
|
export type PickerType = 'single' | 'multi';
|
|
21
|
+
export interface IPickerProps {
|
|
22
|
+
/**
|
|
23
|
+
* Specify the custom id
|
|
24
|
+
*/
|
|
25
|
+
id?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The CSS class for picker container
|
|
28
|
+
*/
|
|
29
|
+
className?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The CSS class for picker list
|
|
32
|
+
*/
|
|
33
|
+
listClassName?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Specify whether the picker should be disabled
|
|
36
|
+
*/
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Specify whether the picker should be in error state
|
|
40
|
+
*/
|
|
41
|
+
error?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Array of picker options
|
|
44
|
+
*/
|
|
45
|
+
options: IPickerListItem[];
|
|
46
|
+
/**
|
|
47
|
+
* Array of picker selected options
|
|
48
|
+
*/
|
|
49
|
+
selected?: IPickerListItem[] | null;
|
|
50
|
+
/**
|
|
51
|
+
* Specify the picker size
|
|
52
|
+
*/
|
|
53
|
+
size?: Size;
|
|
54
|
+
/**
|
|
55
|
+
* Specify the placeholder for search input
|
|
56
|
+
*/
|
|
57
|
+
placeholder?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Specify whether the option select is required
|
|
60
|
+
*/
|
|
61
|
+
isRequired?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Text if no search result were found
|
|
64
|
+
*/
|
|
65
|
+
noSearchResultText?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Text for `select all` option which will be visible if defined in multi select mode
|
|
68
|
+
*/
|
|
69
|
+
selectAllOptionText?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Set `multi` to specify whether the picker should allow to multi selection
|
|
72
|
+
*/
|
|
73
|
+
type?: PickerType;
|
|
74
|
+
/**
|
|
75
|
+
* Set to disable search input
|
|
76
|
+
*/
|
|
77
|
+
searchDisabled?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Set to hide clear selection button
|
|
80
|
+
*/
|
|
81
|
+
hideClearButton?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Will open picker on component initialization
|
|
84
|
+
*/
|
|
85
|
+
openedOnInit?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Test id passed to the picker trigger element
|
|
88
|
+
*/
|
|
89
|
+
['data-testid']?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Callback called after item selection
|
|
92
|
+
*/
|
|
93
|
+
onSelect: (selectedItems: IPickerListItem[] | null) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Clears the search input after item select
|
|
96
|
+
*/
|
|
97
|
+
clearSearchAfterSelection?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Floating strategy for the picker component from @floating-ui/react
|
|
100
|
+
*/
|
|
101
|
+
floatingStrategy?: Strategy;
|
|
102
|
+
/**
|
|
103
|
+
* Set the `floating-ui` useDismiss hook params if you need more control
|
|
104
|
+
* https://floating-ui.com/docs/usedismiss
|
|
105
|
+
*/
|
|
106
|
+
useDismissHookProps?: UseDismissProps;
|
|
107
|
+
/**
|
|
108
|
+
* Set the `floating-ui` useClick hook params if you need more control
|
|
109
|
+
* https://floating-ui.com/docs/useclick
|
|
110
|
+
*/
|
|
111
|
+
useClickHookProps?: UseClickProps;
|
|
112
|
+
/**
|
|
113
|
+
* Props for the Virtuoso component
|
|
114
|
+
* https://virtuoso.dev/virtuoso-api-reference/
|
|
115
|
+
*/
|
|
116
|
+
virtuosoProps?: VirtuosoProps<IPickerListItem, unknown>;
|
|
117
|
+
}
|
|
@@ -17,11 +17,11 @@ export interface IPopoverProps {
|
|
|
17
17
|
/**
|
|
18
18
|
* Optional handler called on tooltip hide
|
|
19
19
|
*/
|
|
20
|
-
onClose?: () => void;
|
|
20
|
+
onClose?: (event?: Event) => void;
|
|
21
21
|
/**
|
|
22
22
|
* Optional handler called on tooltip show
|
|
23
23
|
*/
|
|
24
|
-
onOpen?: () => void;
|
|
24
|
+
onOpen?: (event?: Event) => void;
|
|
25
25
|
/**
|
|
26
26
|
* Set popover visibility
|
|
27
27
|
*/
|