@livechat/design-system-react-components 1.16.5 → 1.16.6
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 +82 -0
- package/dist/components/Icon/IconsShowcase/IconsShowcase.d.ts +11 -0
- package/dist/components/Icon/IconsShowcase/constans.d.ts +2 -0
- package/dist/components/Icon/IconsShowcase/helpers.d.ts +2 -0
- package/dist/components/Icon/IconsShowcase/types.d.ts +9 -0
- package/dist/components/Picker/helpers.d.ts +1 -0
- package/dist/components/Picker/hooks/useFloatingPicker.d.ts +33 -0
- package/dist/components/Picker/hooks/usePickerItems.d.ts +20 -0
- package/dist/components/Picker/types.d.ts +17 -1
- package/dist/dsrc.cjs.js +1 -1
- package/dist/dsrc.es.js +1827 -1719
- package/dist/{themes → foundations}/design-token.d.ts +2 -0
- package/dist/foundations/radius-token.d.ts +6 -0
- package/dist/foundations/shadow-token.d.ts +1 -0
- package/dist/foundations/spacing-token.d.ts +4 -0
- package/dist/foundations/transition-token.d.ts +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/preview-stats.json +598 -568
- package/dist/stories/components/Table/Table.d.ts +13 -0
- package/dist/stories/foundations/Color/ColorTable.d.ts +7 -0
- package/dist/stories/foundations/Color/constants.d.ts +2 -0
- package/dist/stories/foundations/Color/data.d.ts +7 -0
- package/dist/stories/foundations/Color/helpers.d.ts +2 -0
- package/dist/stories/foundations/Color/types.d.ts +43 -0
- package/dist/stories/foundations/Radius/RadiusTable.d.ts +7 -0
- package/dist/stories/foundations/Radius/constants.d.ts +2 -0
- package/dist/stories/foundations/Radius/types.d.ts +8 -0
- package/dist/stories/foundations/Shadow/ShadowTable.d.ts +7 -0
- package/dist/stories/foundations/Shadow/constants.d.ts +2 -0
- package/dist/stories/foundations/Shadow/types.d.ts +6 -0
- package/dist/stories/foundations/Spacing/SpacingTable.d.ts +7 -0
- package/dist/stories/foundations/Spacing/constants.d.ts +2 -0
- package/dist/stories/foundations/Spacing/types.d.ts +7 -0
- package/dist/stories/foundations/Transition/TransitionTable.d.ts +7 -0
- package/dist/stories/foundations/Transition/components/TransitionDelayExample.d.ts +2 -0
- package/dist/stories/foundations/Transition/components/TransitionDurationExample.d.ts +2 -0
- package/dist/stories/foundations/Transition/components/TransitionTimingExample.d.ts +2 -0
- package/dist/stories/foundations/Transition/constants.d.ts +4 -0
- package/dist/stories/foundations/Transition/types.d.ts +16 -0
- package/dist/stories/helpers.d.ts +6 -0
- package/dist/style.css +1 -1
- package/package.json +3 -3
- package/dist/docs/components/ColorTokens.d.ts +0 -2
- package/dist/docs/components/Icons/TablerIconsShowcase.d.ts +0 -6
- package/dist/docs/components/Radius/Radius.d.ts +0 -2
- package/dist/docs/components/Radius/RadiusExamples.d.ts +0 -2
- package/dist/docs/components/Shadow/Shadow.d.ts +0 -2
- package/dist/docs/components/Shadow/ShadowExamples.d.ts +0 -2
- package/dist/docs/components/Spacing/Spacing.d.ts +0 -2
- package/dist/docs/components/Spacing/SpacingExamples.d.ts +0 -2
- package/dist/docs/components/Transition/TransitionTable.d.ts +0 -10
- package/dist/docs/components/Transition/transitionDelay.d.ts +0 -6
- package/dist/docs/components/Transition/transitionDuration.d.ts +0 -5
- package/dist/docs/components/Transition/transitionTiming.d.ts +0 -5
- /package/dist/{docs → stories}/components/BlockColumns/BlockColumns.d.ts +0 -0
- /package/dist/{docs → stories}/components/StoryDescriptor.d.ts +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<img src="./../../docs/assets/logo.png" alt="livechat design-system logo" /><br />
|
|
3
|
+
LiveChat Design System React Components
|
|
4
|
+
</h1>
|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a href="https://www.npmjs.com/@livechat/design-system-react-components">
|
|
8
|
+
<img alt="npm version react-components" src="https://img.shields.io/npm/v/@livechat/design-system-react-components.svg?label=react-components">
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://design.livechat.com/">
|
|
11
|
+
<img src="https://img.shields.io/static/v1?label=documentation&message=storybook&color=ff4685">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://github.com/livechat/design-system/actions/workflows/tests.yml">
|
|
14
|
+
<img src="https://github.com/livechat/design-system/actions/workflows/tests.yml/badge.svg" alt="Workflow status badge" loading="lazy">
|
|
15
|
+
</a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
This package contains a library of reusable React components designed to be used in various projects. These components are the building blocks of our design system and can be easily integrated into your applications.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
Run the following command using [npm](https://www.npmjs.com/) (or with you other favorite package manager, eg. [yarn](https://yarnpkg.com/)):
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
npm install @livechat/design-system-react-components @livechat/design-system-icons --save
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Basic usage
|
|
30
|
+
|
|
31
|
+
It is required to import the `CSS` directly into your project so it could be applied to components:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import '@livechat/design-system-react-components/dist/style.css';
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
You can import components directly from the npm package:
|
|
38
|
+
|
|
39
|
+
```jsx
|
|
40
|
+
import { Button } from '@livechat/design-system-react-components';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
In case of icons there is a separate package (`@livechat/design-system-icons`) to be used in conjunction:
|
|
44
|
+
|
|
45
|
+
```jsx
|
|
46
|
+
import { Edit } from '@livechat/design-system-icons';
|
|
47
|
+
import { Icon } from '@livechat/design-system-react-components';
|
|
48
|
+
|
|
49
|
+
<Icon source={Edit} kind="primary" />;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Documentation
|
|
53
|
+
|
|
54
|
+
At this stage of the project we consider Storybook and Figma as parts of our documentation ecosystem.
|
|
55
|
+
|
|
56
|
+
[Storybook](https://design.livechat.com/) - includes design system foundations, describes components API and allows to familiarize with the thier capabilities
|
|
57
|
+
[Figma](https://www.figma.com/file/2pFu80PXO5A2tfyrAGnx91/Product-Components) - it's not an official documentation from design perspective but we follow a simple rule of working in public
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### Development
|
|
61
|
+
|
|
62
|
+
Required version of `node.js` is `16.13.2`.
|
|
63
|
+
|
|
64
|
+
If you're a [volta](https://volta.sh/) user, the project maintains node version entry within `package.json`.
|
|
65
|
+
|
|
66
|
+
You should start with installing dependencies:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
npm install
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
After that just execute the `start` command. It will build all necessary packages in `watch` mode. `Storybook` should start automatically (if not - try visiting http://localhost:6006).
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
npm start
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
If `Storybook` is not enough, you can additionaly run `npm start:example` which will run `example-react` package in `watch` mode. `example-react` is a simple [React](https://reactjs.org/) app based on [vite-react boilterplate](https://github.com/vitejs/vite/tree/main/packages/create-vite). It has a direct dependency on `react-components` package, so every change should be reflected in the app via auto-reload.
|
|
79
|
+
|
|
80
|
+
### Contributing
|
|
81
|
+
|
|
82
|
+
For the `contribution/testing/releasing` guides please refer to the [main repository](https://github.com/livechat/design-system/) documentation.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { IconSource } from '../index';
|
|
3
|
+
import { IconName } from './types';
|
|
4
|
+
export type IconsMap = {
|
|
5
|
+
[key: string]: IconSource;
|
|
6
|
+
};
|
|
7
|
+
interface IProps {
|
|
8
|
+
data: IconName[];
|
|
9
|
+
}
|
|
10
|
+
export declare const IconsShowcase: React.FC<IProps>;
|
|
11
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { IPickerListItem } from './types';
|
|
2
2
|
export declare const findIndicesWhere: <T>(array: T[], predicate: (item: T) => boolean) => number[];
|
|
3
3
|
export declare const getNormalizedItems: (items: IPickerListItem[]) => IPickerListItem[];
|
|
4
|
+
export declare const getPickerListItemKey: ({ key }: IPickerListItem) => string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FloatingContext, Placement, Strategy, UseClickProps, UseDismissProps } from '@floating-ui/react';
|
|
3
|
+
import { IPickerListItem } from '../types';
|
|
4
|
+
interface UseFloatingPickerProps {
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
items: IPickerListItem[];
|
|
7
|
+
placement?: Placement;
|
|
8
|
+
floatingStrategy?: Strategy;
|
|
9
|
+
useClickHookProps?: UseClickProps;
|
|
10
|
+
useDismissHookProps?: UseDismissProps;
|
|
11
|
+
openedOnInit: boolean;
|
|
12
|
+
isOpen?: boolean;
|
|
13
|
+
onVisibilityChange?: (open: boolean, event?: Event | undefined) => void;
|
|
14
|
+
}
|
|
15
|
+
interface IUseFloatingPicker {
|
|
16
|
+
getReferenceProps: (userProps?: React.HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
|
|
17
|
+
setReference: (element: HTMLElement | null) => void;
|
|
18
|
+
getFloatingProps: (userProps?: React.HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
|
|
19
|
+
getItemProps: (userProps?: React.HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
|
|
20
|
+
floatingStyles: React.CSSProperties;
|
|
21
|
+
isPositioned: boolean;
|
|
22
|
+
context: FloatingContext<HTMLButtonElement>;
|
|
23
|
+
nodeId: string;
|
|
24
|
+
setFloating: (node: HTMLElement | null) => void;
|
|
25
|
+
activeIndex: number | null;
|
|
26
|
+
listElementsRef: React.MutableRefObject<(HTMLElement | null)[]>;
|
|
27
|
+
virtualItemRef: React.RefObject<HTMLDivElement>;
|
|
28
|
+
maxHeight: number;
|
|
29
|
+
pointer: boolean;
|
|
30
|
+
setPointer: (pointer: boolean) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare const useFloatingPicker: ({ disabled, items, placement, floatingStrategy, useDismissHookProps, useClickHookProps, isOpen, onVisibilityChange, }: UseFloatingPickerProps) => IUseFloatingPicker;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IPickerListItem } from '../types';
|
|
2
|
+
interface UsePickerItemsProps {
|
|
3
|
+
selected?: IPickerListItem[] | null;
|
|
4
|
+
options: IPickerListItem[];
|
|
5
|
+
type: 'single' | 'multi';
|
|
6
|
+
selectAllOptionText?: string;
|
|
7
|
+
onSelect: (items: IPickerListItem[] | null) => void;
|
|
8
|
+
setOpen: (isOpen: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
interface IUsePickerItems {
|
|
11
|
+
selectedKeys: string[];
|
|
12
|
+
items: IPickerListItem[];
|
|
13
|
+
searchPhrase: string;
|
|
14
|
+
handleSelect: (key: string) => void;
|
|
15
|
+
handleOnFilter: (text: string) => void;
|
|
16
|
+
handleItemRemove: (itemKey: string) => void;
|
|
17
|
+
handleClear: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const usePickerItems: ({ selected, options, type, selectAllOptionText, onSelect, setOpen, }: UsePickerItemsProps) => IUsePickerItems;
|
|
20
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { Strategy, UseClickProps, UseDismissProps } from '@floating-ui/react';
|
|
2
|
+
import { Placement, Strategy, UseClickProps, UseDismissProps } from '@floating-ui/react';
|
|
3
3
|
import { VirtuosoProps } from 'react-virtuoso';
|
|
4
4
|
import { Size } from '../../utils';
|
|
5
5
|
import { ComponentCoreProps } from '../../utils/types';
|
|
@@ -80,6 +80,18 @@ export interface IPickerProps extends ComponentCoreProps {
|
|
|
80
80
|
* Set to hide clear selection button
|
|
81
81
|
*/
|
|
82
82
|
hideClearButton?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Set picker visibility
|
|
85
|
+
*/
|
|
86
|
+
isVisible?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Optional handler called on picker list hide
|
|
89
|
+
*/
|
|
90
|
+
onClose?: (event?: Event) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Optional handler called on picker list show
|
|
93
|
+
*/
|
|
94
|
+
onOpen?: (event?: Event) => void;
|
|
83
95
|
/**
|
|
84
96
|
* Will open picker on component initialization
|
|
85
97
|
*/
|
|
@@ -92,6 +104,10 @@ export interface IPickerProps extends ComponentCoreProps {
|
|
|
92
104
|
* Clears the search input after item select
|
|
93
105
|
*/
|
|
94
106
|
clearSearchAfterSelection?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* The popover placement related to the trigger element
|
|
109
|
+
*/
|
|
110
|
+
placement?: Placement;
|
|
95
111
|
/**
|
|
96
112
|
* Floating strategy for the picker component from @floating-ui/react
|
|
97
113
|
*/
|