@livechat/design-system-react-components 1.0.0-alpha.4 → 1.0.0-alpha.7
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/dsrc.cjs.js +1 -0
- package/dist/dsrc.es.js +2213 -0
- package/dist/dsrc.umd.js +1 -0
- package/dist/src/components/Alert/Alert.d.ts +19 -0
- package/{src/components/Alert/index.ts → dist/src/components/Alert/index.d.ts} +0 -0
- package/dist/src/components/Badge/Badge.d.ts +5 -0
- package/{src/components/Badge/index.ts → dist/src/components/Badge/index.d.ts} +0 -0
- package/dist/src/components/Button/Button.d.ts +13 -0
- package/{src/components/Button/index.ts → dist/src/components/Button/index.d.ts} +0 -0
- package/dist/src/components/ButtonGroup/ButtonGroup.d.ts +11 -0
- package/{src/components/ButtonGroup/index.ts → dist/src/components/ButtonGroup/index.d.ts} +0 -0
- package/dist/src/components/Card/Card.d.ts +6 -0
- package/{src/components/Card/index.ts → dist/src/components/Card/index.d.ts} +0 -0
- package/dist/src/components/Checkbox/Checkbox.d.ts +7 -0
- package/dist/src/components/Checkbox/CheckboxField.d.ts +7 -0
- package/{src/components/Checkbox/index.ts → dist/src/components/Checkbox/index.d.ts} +0 -0
- package/dist/src/components/FieldDescription/FieldDescription.d.ts +3 -0
- package/{src/components/FieldDescription/index.ts → dist/src/components/FieldDescription/index.d.ts} +0 -0
- package/dist/src/components/FieldError/FieldError.d.ts +3 -0
- package/{src/components/FieldError/index.ts → dist/src/components/FieldError/index.d.ts} +0 -0
- package/dist/src/components/FieldGroup/FieldGroup.d.ts +8 -0
- package/{src/components/FieldGroup/index.ts → dist/src/components/FieldGroup/index.d.ts} +0 -0
- package/dist/src/components/Form/Form.d.ts +7 -0
- package/{src/components/Form/index.ts → dist/src/components/Form/index.d.ts} +0 -0
- package/dist/src/components/FormGroup/FormGroup.d.ts +7 -0
- package/{src/components/FormGroup/index.ts → dist/src/components/FormGroup/index.d.ts} +0 -0
- package/dist/src/components/Icon/Icon.d.ts +70 -0
- package/{src/components/Icon/index.ts → dist/src/components/Icon/index.d.ts} +0 -0
- package/dist/src/components/InputField/InputField.d.ts +15 -0
- package/{src/components/InputField/index.ts → dist/src/components/InputField/index.d.ts} +0 -0
- package/{src/components/Link/Link.tsx → dist/src/components/Link/Link.d.ts} +3 -26
- package/{src/components/Link/index.ts → dist/src/components/Link/index.d.ts} +0 -0
- package/dist/src/components/Loader/Loader.d.ts +10 -0
- package/{src/components/Loader/index.ts → dist/src/components/Loader/index.d.ts} +0 -0
- package/dist/src/components/Modal/ActionModal.d.ts +8 -0
- package/dist/src/components/Modal/Modal.d.ts +7 -0
- package/dist/src/components/Modal/ModalBase.d.ts +6 -0
- package/dist/src/components/Modal/ModalCloseButton.d.ts +3 -0
- package/dist/src/components/Modal/ModalPortal.d.ts +7 -0
- package/{src/components/Modal/index.ts → dist/src/components/Modal/index.d.ts} +0 -1
- package/dist/src/components/NumericInput/NumericInput.d.ts +14 -0
- package/dist/src/components/NumericInput/NumericInputField.d.ts +19 -0
- package/{src/components/NumericInput/index.ts → dist/src/components/NumericInput/index.d.ts} +0 -0
- package/dist/src/components/Popover/Popover.d.ts +15 -0
- package/{src/components/Popover/index.ts → dist/src/components/Popover/index.d.ts} +0 -0
- package/dist/src/components/Progress/ProgressCircle.d.ts +9 -0
- package/dist/src/components/Progress/constants.d.ts +12 -0
- package/dist/src/components/Progress/helpers.d.ts +3 -0
- package/{src/components/Progress/index.ts → dist/src/components/Progress/index.d.ts} +0 -0
- package/dist/src/components/PromoBanner/PromoBanner.d.ts +19 -0
- package/{src/components/PromoBanner/index.ts → dist/src/components/PromoBanner/index.d.ts} +0 -0
- package/dist/src/components/RadioButton/RadioButton.d.ts +7 -0
- package/{src/components/RadioButton/index.ts → dist/src/components/RadioButton/index.d.ts} +0 -0
- package/dist/src/components/Switch/Switch.d.ts +20 -0
- package/{src/components/Switch/index.ts → dist/src/components/Switch/index.d.ts} +0 -0
- package/dist/src/components/Tab/Tab.d.ts +12 -0
- package/dist/src/components/Tab/TabsWrapper.d.ts +3 -0
- package/{src/components/Tab/index.ts → dist/src/components/Tab/index.d.ts} +0 -0
- package/dist/src/components/Tag/Tag.d.ts +12 -0
- package/{src/components/Tag/index.ts → dist/src/components/Tag/index.d.ts} +0 -0
- package/dist/src/components/TagInput/EditableTag.d.ts +11 -0
- package/dist/src/components/TagInput/EditableTagContent.d.ts +11 -0
- package/dist/src/components/TagInput/EmailTagInput.d.ts +5 -0
- package/dist/src/components/TagInput/TagInput.d.ts +12 -0
- package/{src/components/TagInput/index.ts → dist/src/components/TagInput/index.d.ts} +0 -0
- package/dist/src/components/TextField/TextField.d.ts +13 -0
- package/{src/components/TextField/index.ts → dist/src/components/TextField/index.d.ts} +0 -0
- package/dist/src/components/Toast/Toast.d.ts +22 -0
- package/dist/src/components/Toast/ToastWrapper.d.ts +27 -0
- package/{src/components/Toast/index.ts → dist/src/components/Toast/index.d.ts} +0 -0
- package/dist/src/components/Typography/Heading.d.ts +11 -0
- package/dist/src/components/Typography/Text.d.ts +15 -0
- package/{src/components/Typography/index.ts → dist/src/components/Typography/index.d.ts} +0 -0
- package/{src/index.ts → dist/src/index.d.ts} +0 -3
- package/dist/src/themes/designTokens.d.ts +126 -0
- package/dist/src/utils/keyCodes.d.ts +12 -0
- package/dist/src/utils/noop.d.ts +1 -0
- package/{src → dist/src}/vite-env.d.ts +0 -0
- package/dist/style.css +1 -0
- package/{src/themes/dark.scss → dist/themes/dark.css} +2 -0
- package/dist/themes/dark.css.map +1 -0
- package/{src/themes/legacy.scss → dist/themes/legacy.css} +2 -0
- package/dist/themes/legacy.css.map +1 -0
- package/{src/themes/light.scss → dist/themes/light.css} +2 -0
- package/dist/themes/light.css.map +1 -0
- package/package.json +8 -5
- package/.eslintrc +0 -9
- package/.storybook/main.js +0 -20
- package/.storybook/preview-head.html +0 -31
- package/.storybook/preview.js +0 -21
- package/src/components/Alert/Alert.module.scss +0 -88
- package/src/components/Alert/Alert.spec.tsx +0 -78
- package/src/components/Alert/Alert.stories.tsx +0 -73
- package/src/components/Alert/Alert.tsx +0 -94
- package/src/components/Badge/Badge.module.scss +0 -23
- package/src/components/Badge/Badge.spec.tsx +0 -12
- package/src/components/Badge/Badge.stories.tsx +0 -24
- package/src/components/Badge/Badge.tsx +0 -24
- package/src/components/Button/Button.module.scss +0 -257
- package/src/components/Button/Button.spec.tsx +0 -110
- package/src/components/Button/Button.stories.tsx +0 -152
- package/src/components/Button/Button.tsx +0 -88
- package/src/components/ButtonGroup/ButtonGroup.module.scss +0 -31
- package/src/components/ButtonGroup/ButtonGroup.spec.tsx +0 -61
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +0 -53
- package/src/components/ButtonGroup/ButtonGroup.tsx +0 -75
- package/src/components/Card/Card.module.scss +0 -31
- package/src/components/Card/Card.spec.tsx +0 -38
- package/src/components/Card/Card.stories.tsx +0 -30
- package/src/components/Card/Card.tsx +0 -34
- package/src/components/Checkbox/Checkbox.module.scss +0 -99
- package/src/components/Checkbox/Checkbox.tsx +0 -39
- package/src/components/Checkbox/CheckboxField.spec.tsx +0 -58
- package/src/components/Checkbox/CheckboxField.stories.tsx +0 -30
- package/src/components/Checkbox/CheckboxField.tsx +0 -46
- package/src/components/FieldDescription/FieldDescription.module.scss +0 -5
- package/src/components/FieldDescription/FieldDescription.tsx +0 -23
- package/src/components/FieldError/FieldError.module.scss +0 -5
- package/src/components/FieldError/FieldError.tsx +0 -23
- package/src/components/FieldGroup/FieldGroup.module.scss +0 -25
- package/src/components/FieldGroup/FieldGroup.spec.tsx +0 -42
- package/src/components/FieldGroup/FieldGroup.stories.tsx +0 -34
- package/src/components/FieldGroup/FieldGroup.tsx +0 -38
- package/src/components/Form/Form.module.scss +0 -22
- package/src/components/Form/Form.spec.tsx +0 -38
- package/src/components/Form/Form.stories.tsx +0 -42
- package/src/components/Form/Form.tsx +0 -46
- package/src/components/FormGroup/FormGroup.module.scss +0 -20
- package/src/components/FormGroup/FormGroup.spec.tsx +0 -34
- package/src/components/FormGroup/FormGroup.stories.tsx +0 -30
- package/src/components/FormGroup/FormGroup.tsx +0 -44
- package/src/components/Icon/Icon.module.scss +0 -70
- package/src/components/Icon/Icon.stories.tsx +0 -53
- package/src/components/Icon/Icon.tsx +0 -118
- package/src/components/InputField/InputField.module.scss +0 -37
- package/src/components/InputField/InputField.spec.tsx +0 -53
- package/src/components/InputField/InputField.stories.tsx +0 -73
- package/src/components/InputField/InputField.tsx +0 -72
- package/src/components/Link/Link.module.scss +0 -18
- package/src/components/Link/Link.stories.tsx +0 -17
- package/src/components/Loader/Loader.module.scss +0 -66
- package/src/components/Loader/Loader.spec.tsx +0 -64
- package/src/components/Loader/Loader.stories.tsx +0 -25
- package/src/components/Loader/Loader.tsx +0 -48
- package/src/components/Modal/ActionModal.tsx +0 -37
- package/src/components/Modal/Modal.module.scss +0 -131
- package/src/components/Modal/Modal.stories.tsx +0 -85
- package/src/components/Modal/Modal.tsx +0 -41
- package/src/components/Modal/ModalBase.spec.tsx +0 -58
- package/src/components/Modal/ModalBase.tsx +0 -66
- package/src/components/Modal/ModalCloseButton.tsx +0 -20
- package/src/components/Modal/ModalPortal.tsx +0 -35
- package/src/components/NumericInput/NumericInput.module.scss +0 -110
- package/src/components/NumericInput/NumericInput.spec.tsx +0 -129
- package/src/components/NumericInput/NumericInput.stories.tsx +0 -56
- package/src/components/NumericInput/NumericInput.tsx +0 -161
- package/src/components/NumericInput/NumericInputField.stories.tsx +0 -58
- package/src/components/NumericInput/NumericInputField.tsx +0 -57
- package/src/components/Popover/Popover.module.scss +0 -16
- package/src/components/Popover/Popover.spec.tsx +0 -39
- package/src/components/Popover/Popover.stories.css +0 -23
- package/src/components/Popover/Popover.stories.tsx +0 -164
- package/src/components/Popover/Popover.tsx +0 -124
- package/src/components/Progress/ProgressBar.module.scss +0 -48
- package/src/components/Progress/ProgressBar.spec.tsx +0 -33
- package/src/components/Progress/ProgressBar.stories.tsx +0 -23
- package/src/components/Progress/ProgressBar.tsx +0 -62
- package/src/components/Progress/ProgressCircle.module.scss +0 -64
- package/src/components/Progress/ProgressCircle.spec.tsx +0 -34
- package/src/components/Progress/ProgressCircle.stories.tsx +0 -28
- package/src/components/Progress/ProgressCircle.tsx +0 -104
- package/src/components/Progress/constants.ts +0 -23
- package/src/components/Progress/helpers.ts +0 -23
- package/src/components/PromoBanner/PromoBanner.module.scss +0 -121
- package/src/components/PromoBanner/PromoBanner.spec.tsx +0 -119
- package/src/components/PromoBanner/PromoBanner.stories.tsx +0 -125
- package/src/components/PromoBanner/PromoBanner.tsx +0 -99
- package/src/components/RadioButton/RadioButton.module.scss +0 -100
- package/src/components/RadioButton/RadioButton.spec.tsx +0 -70
- package/src/components/RadioButton/RadioButton.stories.tsx +0 -34
- package/src/components/RadioButton/RadioButton.tsx +0 -54
- package/src/components/Switch/Switch.module.scss +0 -126
- package/src/components/Switch/Switch.spec.tsx +0 -40
- package/src/components/Switch/Switch.stories.tsx +0 -23
- package/src/components/Switch/Switch.tsx +0 -100
- package/src/components/Tab/Tab.module.scss +0 -56
- package/src/components/Tab/Tab.spec.tsx +0 -34
- package/src/components/Tab/Tab.stories.tsx +0 -20
- package/src/components/Tab/Tab.tsx +0 -49
- package/src/components/Tab/TabsWrapper.module.scss +0 -11
- package/src/components/Tab/TabsWrapper.spec.tsx +0 -19
- package/src/components/Tab/TabsWrapper.stories.tsx +0 -46
- package/src/components/Tab/TabsWrapper.tsx +0 -24
- package/src/components/Tag/Tag.module.scss +0 -131
- package/src/components/Tag/Tag.spec.tsx +0 -93
- package/src/components/Tag/Tag.stories.tsx +0 -151
- package/src/components/Tag/Tag.tsx +0 -129
- package/src/components/TagInput/EditableTag.tsx +0 -54
- package/src/components/TagInput/EditableTagContent.tsx +0 -81
- package/src/components/TagInput/EmailTagInput.tsx +0 -31
- package/src/components/TagInput/TagInput.module.scss +0 -81
- package/src/components/TagInput/TagInput.spec.tsx +0 -58
- package/src/components/TagInput/TagInput.stories.tsx +0 -49
- package/src/components/TagInput/TagInput.tsx +0 -133
- package/src/components/TextField/TextField.module.scss +0 -90
- package/src/components/TextField/TextField.spec.tsx +0 -40
- package/src/components/TextField/TextField.stories.tsx +0 -60
- package/src/components/TextField/TextField.tsx +0 -100
- package/src/components/Toast/Toast.module.scss +0 -218
- package/src/components/Toast/Toast.spec.tsx +0 -96
- package/src/components/Toast/Toast.stories.tsx +0 -64
- package/src/components/Toast/Toast.tsx +0 -121
- package/src/components/Toast/ToastWrapper.spec.tsx +0 -13
- package/src/components/Toast/ToastWrapper.stories.tsx +0 -55
- package/src/components/Toast/ToastWrapper.tsx +0 -87
- package/src/components/Typography/Heading.tsx +0 -36
- package/src/components/Typography/Text.tsx +0 -49
- package/src/components/Typography/Typography.module.scss +0 -132
- package/src/index.scss +0 -9
- package/src/stories/ColorTokens.stories.mdx +0 -10
- package/src/stories/Icons.stories.mdx +0 -12
- package/src/stories/Typography.stories.mdx +0 -65
- package/src/stories/components/ColorTokens.tsx +0 -99
- package/src/stories/components/IconsShowcase.tsx +0 -25
- package/src/stories/components/iconsShowcase.css +0 -13
- package/src/test/setup.ts +0 -1
- package/src/test/utils.ts +0 -3
- package/src/themes/designTokens.ts +0 -126
- package/src/utils/keyCodes.ts +0 -12
- package/src/utils/noop.ts +0 -2
- package/tsconfig.json +0 -25
- package/tsconfig.node.json +0 -8
- package/vite.config.ts +0 -44
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentMeta } from '@storybook/react';
|
|
3
|
-
import { Button } from '../Button';
|
|
4
|
-
import { Popover as PopoverComponent } from './Popover';
|
|
5
|
-
import {
|
|
6
|
-
Block,
|
|
7
|
-
Chats,
|
|
8
|
-
DropDown,
|
|
9
|
-
Email,
|
|
10
|
-
Tickets,
|
|
11
|
-
} from '@livechat/design-system-icons/react/material';
|
|
12
|
-
import { Icon } from '../Icon';
|
|
13
|
-
|
|
14
|
-
import * as PopperCore from '@popperjs/core';
|
|
15
|
-
import './Popover.stories.css';
|
|
16
|
-
|
|
17
|
-
const OpenChat = () => {
|
|
18
|
-
return (
|
|
19
|
-
<div className="lc-listElement">
|
|
20
|
-
<Icon source={Chats} /> <span className="lc-label">Open chat</span>{' '}
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const CreateTicket = () => {
|
|
26
|
-
return (
|
|
27
|
-
<div className="lc-listElement">
|
|
28
|
-
<Icon source={Tickets} />{' '}
|
|
29
|
-
<span className="lc-label">Create a ticket</span>{' '}
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const SendTranscript = () => {
|
|
35
|
-
return (
|
|
36
|
-
<div className="lc-listElement lc-divider">
|
|
37
|
-
<Icon source={Email} /> <span className="lc-label">Send transcript</span>{' '}
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const BanCustomer = () => {
|
|
43
|
-
return (
|
|
44
|
-
<div className="lc-listElement">
|
|
45
|
-
<Icon source={Block} />{' '}
|
|
46
|
-
<span className="lc-label">Ban this customer</span>{' '}
|
|
47
|
-
</div>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const Popover = ({
|
|
52
|
-
placement,
|
|
53
|
-
isVisible,
|
|
54
|
-
}: {
|
|
55
|
-
placement: PopperCore.Placement;
|
|
56
|
-
isVisible: boolean;
|
|
57
|
-
}): React.ReactElement => (
|
|
58
|
-
<div style={{ minHeight: '400px' }}>
|
|
59
|
-
<PopoverComponent
|
|
60
|
-
placement={placement}
|
|
61
|
-
isVisible={isVisible}
|
|
62
|
-
triggerRenderer={() => (
|
|
63
|
-
<div>
|
|
64
|
-
<Button icon={<Icon source={DropDown}></Icon>} iconPosition={'right'}>
|
|
65
|
-
Open Popover
|
|
66
|
-
</Button>
|
|
67
|
-
</div>
|
|
68
|
-
)}
|
|
69
|
-
modifiers={{
|
|
70
|
-
preventOverflow: {
|
|
71
|
-
enabled: true,
|
|
72
|
-
},
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
75
|
-
<div
|
|
76
|
-
style={{
|
|
77
|
-
display: 'flex',
|
|
78
|
-
justifyContent: 'center',
|
|
79
|
-
alignItems: 'center',
|
|
80
|
-
padding: '12px',
|
|
81
|
-
width: '308px',
|
|
82
|
-
height: '308px',
|
|
83
|
-
}}
|
|
84
|
-
>
|
|
85
|
-
<div
|
|
86
|
-
style={{
|
|
87
|
-
display: 'flex',
|
|
88
|
-
justifyContent: 'center',
|
|
89
|
-
alignItems: 'center',
|
|
90
|
-
border: '1px dashed var(--border-default)',
|
|
91
|
-
backgroundColor: 'var(--surface-basic-default)',
|
|
92
|
-
width: '100%',
|
|
93
|
-
height: '100%',
|
|
94
|
-
borderRadius: '4px',
|
|
95
|
-
}}
|
|
96
|
-
>
|
|
97
|
-
Popover content
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
</PopoverComponent>
|
|
101
|
-
</div>
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
Popover.args = {
|
|
105
|
-
placement: 'bottom-start',
|
|
106
|
-
isVisible: true,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const Actions = ({
|
|
110
|
-
placement,
|
|
111
|
-
isVisible,
|
|
112
|
-
}: {
|
|
113
|
-
placement: PopperCore.Placement;
|
|
114
|
-
isVisible: boolean;
|
|
115
|
-
}): React.ReactElement => (
|
|
116
|
-
<div style={{ minHeight: '200px' }}>
|
|
117
|
-
<PopoverComponent
|
|
118
|
-
placement={placement}
|
|
119
|
-
isVisible={isVisible}
|
|
120
|
-
triggerRenderer={() => (
|
|
121
|
-
<div>
|
|
122
|
-
<Button icon={<Icon source={DropDown}></Icon>} iconPosition={'right'}>
|
|
123
|
-
Actions
|
|
124
|
-
</Button>
|
|
125
|
-
</div>
|
|
126
|
-
)}
|
|
127
|
-
modifiers={{
|
|
128
|
-
preventOverflow: {
|
|
129
|
-
enabled: true,
|
|
130
|
-
},
|
|
131
|
-
}}
|
|
132
|
-
>
|
|
133
|
-
<div
|
|
134
|
-
style={{
|
|
135
|
-
minWidth: '200px',
|
|
136
|
-
}}
|
|
137
|
-
>
|
|
138
|
-
<OpenChat />
|
|
139
|
-
<CreateTicket />
|
|
140
|
-
<SendTranscript />
|
|
141
|
-
<BanCustomer />
|
|
142
|
-
</div>
|
|
143
|
-
</PopoverComponent>
|
|
144
|
-
</div>
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
Actions.args = {
|
|
148
|
-
placement: 'bottom-start',
|
|
149
|
-
isVisible: true,
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
export default {
|
|
153
|
-
title: 'Components/Popover',
|
|
154
|
-
component: Popover,
|
|
155
|
-
argTypes: {
|
|
156
|
-
placement: {
|
|
157
|
-
options: PopperCore.placements,
|
|
158
|
-
control: {
|
|
159
|
-
type: 'select',
|
|
160
|
-
labels: PopperCore.placements,
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
} as ComponentMeta<typeof Popover>;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { usePopper } from 'react-popper';
|
|
3
|
-
import * as PopperCore from '@popperjs/core';
|
|
4
|
-
import cx from 'clsx';
|
|
5
|
-
|
|
6
|
-
import cssStyles from './Popover.module.scss';
|
|
7
|
-
|
|
8
|
-
type PopoverModifiers = {
|
|
9
|
-
[key: string]: Partial<PopperCore.StrictModifiers>;
|
|
10
|
-
};
|
|
11
|
-
export interface IPopoverProps {
|
|
12
|
-
children?: React.ReactNode;
|
|
13
|
-
className?: string;
|
|
14
|
-
modifiers?: PopoverModifiers;
|
|
15
|
-
placement?: PopperCore.Placement;
|
|
16
|
-
isVisible?: boolean;
|
|
17
|
-
triggerRenderer: () => React.ReactNode;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const buildPopperModifiers = (modifiers: PopoverModifiers) => {
|
|
21
|
-
const { offset, flip, preventOverflow } = modifiers;
|
|
22
|
-
|
|
23
|
-
const calculatedOffset = [
|
|
24
|
-
{
|
|
25
|
-
name: 'offset',
|
|
26
|
-
options: {
|
|
27
|
-
offset: [0, 4],
|
|
28
|
-
...(offset?.options || {}),
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const calculateFlip = [
|
|
34
|
-
{
|
|
35
|
-
name: 'flip',
|
|
36
|
-
options: {
|
|
37
|
-
...(flip?.options || {}),
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
const calculatePreventOverflow = [
|
|
43
|
-
{
|
|
44
|
-
name: 'preventOverlow',
|
|
45
|
-
options: {
|
|
46
|
-
rootBoundary: 'viewport',
|
|
47
|
-
...(preventOverflow || {}),
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
return [...calculatedOffset, ...calculateFlip, ...calculatePreventOverflow];
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const Popover: React.FC<IPopoverProps> = (props) => {
|
|
56
|
-
const {
|
|
57
|
-
triggerRenderer,
|
|
58
|
-
children,
|
|
59
|
-
className,
|
|
60
|
-
placement,
|
|
61
|
-
isVisible = false,
|
|
62
|
-
} = props;
|
|
63
|
-
|
|
64
|
-
const rendererRef = React.useRef<HTMLDivElement | null>(null);
|
|
65
|
-
const popperRef = React.useRef<HTMLDivElement | null>(null);
|
|
66
|
-
|
|
67
|
-
const [visible, setVisibility] = React.useState(false);
|
|
68
|
-
|
|
69
|
-
React.useEffect(() => {
|
|
70
|
-
setVisibility(isVisible);
|
|
71
|
-
}, [isVisible]);
|
|
72
|
-
|
|
73
|
-
function handleDocumentClick(event: MouseEvent) {
|
|
74
|
-
if (popperRef.current?.contains(event.target as Node)) {
|
|
75
|
-
return;
|
|
76
|
-
} else if (rendererRef.current?.contains(event.target as Node)) {
|
|
77
|
-
setVisibility((prevVisible) => !prevVisible);
|
|
78
|
-
} else {
|
|
79
|
-
setVisibility(false);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const handleHideOnEscape = (event: KeyboardEvent) => {
|
|
84
|
-
if (event.key === 'Escape') {
|
|
85
|
-
setVisibility(false);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
React.useEffect(() => {
|
|
90
|
-
document.addEventListener('keydown', handleHideOnEscape);
|
|
91
|
-
document.addEventListener('mousedown', handleDocumentClick);
|
|
92
|
-
return () => {
|
|
93
|
-
document.removeEventListener('keydown', handleHideOnEscape);
|
|
94
|
-
document.removeEventListener('mousedown', handleDocumentClick);
|
|
95
|
-
};
|
|
96
|
-
}, []);
|
|
97
|
-
|
|
98
|
-
const { styles, attributes } = usePopper(
|
|
99
|
-
rendererRef.current,
|
|
100
|
-
popperRef.current,
|
|
101
|
-
{
|
|
102
|
-
modifiers: props.modifiers ? buildPopperModifiers(props.modifiers) : [],
|
|
103
|
-
placement: placement,
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
const mergedClassNames = cx(cssStyles['popover'], className, {
|
|
108
|
-
[cssStyles['popover--visible']]: visible,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<>
|
|
113
|
-
<div ref={rendererRef}>{triggerRenderer()}</div>
|
|
114
|
-
<div
|
|
115
|
-
ref={popperRef}
|
|
116
|
-
className={mergedClassNames}
|
|
117
|
-
style={styles.popper}
|
|
118
|
-
{...attributes.popper}
|
|
119
|
-
>
|
|
120
|
-
{children}
|
|
121
|
-
</div>
|
|
122
|
-
</>
|
|
123
|
-
);
|
|
124
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
.progress-bar {
|
|
2
|
-
background-color: var(--color-action-disabled);
|
|
3
|
-
border-radius: 100px;
|
|
4
|
-
display: inline-block;
|
|
5
|
-
height: 4px;
|
|
6
|
-
position: relative;
|
|
7
|
-
width: 100%;
|
|
8
|
-
|
|
9
|
-
&--small {
|
|
10
|
-
height: 3px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
&--medium {
|
|
14
|
-
height: 4px;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&--large {
|
|
18
|
-
height: 6px;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&--error {
|
|
22
|
-
background-color: var(--color-negative-disabled);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&--success {
|
|
26
|
-
background-color: var(--color-positive-disabled);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&--normal {
|
|
30
|
-
background-color: var(--color-action-disabled);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&__indicator--success {
|
|
34
|
-
background-color: var(--color-positive-default);
|
|
35
|
-
border-radius: 100px;
|
|
36
|
-
height: 100%;
|
|
37
|
-
position: relative;
|
|
38
|
-
transition: all 0.4s cubic-bezier(0.08, 0.82, 0.17, 1) 0s;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&__indicator--normal {
|
|
42
|
-
background-color: var(--color-action-default);
|
|
43
|
-
border-radius: 100px;
|
|
44
|
-
height: 100%;
|
|
45
|
-
position: relative;
|
|
46
|
-
transition: all 0.4s cubic-bezier(0.08, 0.82, 0.17, 1) 0s;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import { render } from 'test-utils';
|
|
4
|
-
import { ProgressStatus } from './constants';
|
|
5
|
-
import { ProgressBar } from './ProgressBar';
|
|
6
|
-
|
|
7
|
-
import styles from './ProgressBar.module.scss';
|
|
8
|
-
|
|
9
|
-
describe('<ProgressBar /> component', () => {
|
|
10
|
-
it('should render normal ProgressBar by default', () => {
|
|
11
|
-
const { getByRole } = render(<ProgressBar percent={10} />);
|
|
12
|
-
expect(getByRole('progressbar')).toHaveClass(styles['progress-bar']);
|
|
13
|
-
expect(getByRole('progressbar')).toHaveClass(
|
|
14
|
-
styles['progress-bar--normal']
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should render success ProgressBar when success status is passed', () => {
|
|
19
|
-
const { getByRole } = render(
|
|
20
|
-
<ProgressBar status={ProgressStatus.Success} percent={10} />
|
|
21
|
-
);
|
|
22
|
-
expect(getByRole('progressbar')).toHaveClass(
|
|
23
|
-
styles['progress-bar--success']
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should render error ProgressBar when error status is passed', () => {
|
|
28
|
-
const { getByRole } = render(
|
|
29
|
-
<ProgressBar status={ProgressStatus.Error} percent={10} />
|
|
30
|
-
);
|
|
31
|
-
expect(getByRole('progressbar')).toHaveClass(styles['progress-bar--error']);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
ProgressBar as ProgressBarComponent,
|
|
6
|
-
ProgressBarProps,
|
|
7
|
-
} from './ProgressBar';
|
|
8
|
-
import { ProgressSize, ProgressStatus } from './constants';
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
title: 'Components/Progress',
|
|
12
|
-
component: ProgressBarComponent,
|
|
13
|
-
} as ComponentMeta<typeof ProgressBarComponent>;
|
|
14
|
-
|
|
15
|
-
export const ProgressBar = (args: ProgressBarProps): React.ReactElement => {
|
|
16
|
-
return <ProgressBarComponent {...args} />;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
ProgressBar.args = {
|
|
20
|
-
percent: 10,
|
|
21
|
-
status: ProgressStatus.Normal,
|
|
22
|
-
size: ProgressSize.Medium,
|
|
23
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import cx from 'clsx';
|
|
3
|
-
|
|
4
|
-
import { ProgressSize, ProgressStatus } from './constants';
|
|
5
|
-
import { getPercentNumber, getProgressStatus } from './helpers';
|
|
6
|
-
|
|
7
|
-
import styles from './ProgressBar.module.scss';
|
|
8
|
-
|
|
9
|
-
const baseClass = 'progress-bar';
|
|
10
|
-
|
|
11
|
-
export interface ProgressBarProps {
|
|
12
|
-
className?: string;
|
|
13
|
-
percent: number;
|
|
14
|
-
status?: ProgressStatus;
|
|
15
|
-
size?: ProgressSize;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const ProgressBar: React.ExoticComponent<
|
|
19
|
-
ProgressBarProps & React.RefAttributes<HTMLInputElement>
|
|
20
|
-
> = React.forwardRef(
|
|
21
|
-
(
|
|
22
|
-
{
|
|
23
|
-
status = ProgressStatus.Normal,
|
|
24
|
-
percent,
|
|
25
|
-
size = ProgressSize.Medium,
|
|
26
|
-
className = '',
|
|
27
|
-
...restProps
|
|
28
|
-
},
|
|
29
|
-
ref: React.LegacyRef<HTMLInputElement>
|
|
30
|
-
) => {
|
|
31
|
-
const progressStatus = getProgressStatus(status, percent);
|
|
32
|
-
const percentNumber = getPercentNumber(progressStatus, percent);
|
|
33
|
-
|
|
34
|
-
const mergedClassNames = cx(
|
|
35
|
-
styles[baseClass],
|
|
36
|
-
{
|
|
37
|
-
[styles[`${baseClass}--${size}`]]: size,
|
|
38
|
-
[styles[`${baseClass}--error`]]:
|
|
39
|
-
progressStatus === ProgressStatus.Error,
|
|
40
|
-
[styles[`${baseClass}--success`]]:
|
|
41
|
-
progressStatus === ProgressStatus.Success,
|
|
42
|
-
[styles[`${baseClass}--normal`]]:
|
|
43
|
-
progressStatus === ProgressStatus.Normal,
|
|
44
|
-
},
|
|
45
|
-
className
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div
|
|
50
|
-
{...restProps}
|
|
51
|
-
className={mergedClassNames}
|
|
52
|
-
ref={ref}
|
|
53
|
-
role="progressbar"
|
|
54
|
-
>
|
|
55
|
-
<div
|
|
56
|
-
className={styles[`${baseClass}__indicator--${status}`]}
|
|
57
|
-
style={{ width: `${percentNumber}%` }}
|
|
58
|
-
/>
|
|
59
|
-
</div>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
);
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
.progress-circle {
|
|
2
|
-
height: 36px;
|
|
3
|
-
transform: rotate(-90deg);
|
|
4
|
-
width: 36px;
|
|
5
|
-
|
|
6
|
-
&--small {
|
|
7
|
-
height: 15px;
|
|
8
|
-
width: 15px;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
&--medium {
|
|
12
|
-
height: 36px;
|
|
13
|
-
width: 36px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&--large {
|
|
17
|
-
height: 56px;
|
|
18
|
-
width: 56px;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&__bg-line--normal {
|
|
22
|
-
stroke: var(--color-action-disabled);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&__bg-line--success {
|
|
26
|
-
stroke: var(--color-positive-disabled);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&__bg-line--error {
|
|
30
|
-
stroke: var(--color-negative-disabled);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&__indicator--normal {
|
|
34
|
-
stroke: var(--color-action-default);
|
|
35
|
-
transition: all 0.4s cubic-bezier(0.08, 0.82, 0.17, 1) 0s;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&__indicator--success {
|
|
39
|
-
stroke: var(--color-positive-default);
|
|
40
|
-
transition: all 0.4s cubic-bezier(0.08, 0.82, 0.17, 1) 0s;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
&__indicator--error {
|
|
44
|
-
transition: all 0.4s cubic-bezier(0.08, 0.82, 0.17, 1) 0s;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
&--error {
|
|
48
|
-
.progress-circle__bg-line {
|
|
49
|
-
stroke: var(--color-negative-disabled);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
&--success {
|
|
54
|
-
.progress-circle__bg-line {
|
|
55
|
-
stroke: var(--color-positive-disabled);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
&--normal {
|
|
60
|
-
.progress-circle__bg-line {
|
|
61
|
-
stroke: var(--color-action-disabled);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { render } from 'test-utils';
|
|
3
|
-
import { ProgressStatus } from './constants';
|
|
4
|
-
import { ProgressCircle } from './ProgressCircle';
|
|
5
|
-
|
|
6
|
-
import styles from './ProgressCircle.module.scss';
|
|
7
|
-
|
|
8
|
-
describe('<ProgressCircle /> component', () => {
|
|
9
|
-
it('should render ProgressCircle by default', () => {
|
|
10
|
-
const { getByRole } = render(<ProgressCircle percent={10} />);
|
|
11
|
-
expect(getByRole('progressbar')).toHaveClass(styles['progress-circle']);
|
|
12
|
-
expect(getByRole('progressbar')).toHaveClass(
|
|
13
|
-
styles['progress-circle--normal']
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should render success ProgressCircle when success status is passed', () => {
|
|
18
|
-
const { getByRole } = render(
|
|
19
|
-
<ProgressCircle status={ProgressStatus.Success} percent={10} />
|
|
20
|
-
);
|
|
21
|
-
expect(getByRole('progressbar')).toHaveClass(
|
|
22
|
-
styles['progress-circle--success']
|
|
23
|
-
);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should render error ProgressCircle when error status is passed', () => {
|
|
27
|
-
const { getByRole } = render(
|
|
28
|
-
<ProgressCircle status={ProgressStatus.Error} percent={10} />
|
|
29
|
-
);
|
|
30
|
-
expect(getByRole('progressbar')).toHaveClass(
|
|
31
|
-
styles['progress-circle--error']
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
ProgressCircle as ProgressCircleComponent,
|
|
6
|
-
ProgressCircleProps,
|
|
7
|
-
} from './ProgressCircle';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
title: 'Components/Progress',
|
|
11
|
-
component: ProgressCircleComponent,
|
|
12
|
-
} as ComponentMeta<typeof ProgressCircleComponent>;
|
|
13
|
-
|
|
14
|
-
export const ProgressCircle = (
|
|
15
|
-
args: ProgressCircleProps
|
|
16
|
-
): React.ReactElement => {
|
|
17
|
-
return (
|
|
18
|
-
<div>
|
|
19
|
-
<ProgressCircleComponent {...args} />
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
ProgressCircle.args = {
|
|
25
|
-
percent: 10,
|
|
26
|
-
status: 'normal',
|
|
27
|
-
size: 'medium',
|
|
28
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import cx from 'clsx';
|
|
3
|
-
import { ProgressSize, ProgressStatus } from './constants';
|
|
4
|
-
import { getPercentNumber, getProgressStatus } from './helpers';
|
|
5
|
-
|
|
6
|
-
import styles from './ProgressCircle.module.scss';
|
|
7
|
-
|
|
8
|
-
const THICKNESS_FROM_SIZE = {
|
|
9
|
-
[ProgressSize.Small]: 2,
|
|
10
|
-
[ProgressSize.Medium]: 3,
|
|
11
|
-
[ProgressSize.Large]: 4,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const SIZE_VALUE_FROM_SIZE = {
|
|
15
|
-
[ProgressSize.Small]: 15,
|
|
16
|
-
[ProgressSize.Medium]: 36,
|
|
17
|
-
[ProgressSize.Large]: 56,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const baseClass = 'progress-circle';
|
|
21
|
-
|
|
22
|
-
export interface ProgressCircleProps {
|
|
23
|
-
className?: string;
|
|
24
|
-
percent: number;
|
|
25
|
-
status?: ProgressStatus;
|
|
26
|
-
size?: ProgressSize;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const ProgressCircle: React.ExoticComponent<
|
|
30
|
-
ProgressCircleProps & React.RefAttributes<HTMLInputElement>
|
|
31
|
-
> = React.forwardRef(
|
|
32
|
-
(
|
|
33
|
-
{
|
|
34
|
-
status = ProgressStatus.Normal,
|
|
35
|
-
percent,
|
|
36
|
-
className,
|
|
37
|
-
size = ProgressSize.Medium,
|
|
38
|
-
...restProps
|
|
39
|
-
},
|
|
40
|
-
ref: React.LegacyRef<HTMLInputElement>
|
|
41
|
-
) => {
|
|
42
|
-
const progressStatus = getProgressStatus(status, percent);
|
|
43
|
-
const percentNumber = getPercentNumber(progressStatus, percent);
|
|
44
|
-
const thickness = THICKNESS_FROM_SIZE[size];
|
|
45
|
-
const sizeValue = SIZE_VALUE_FROM_SIZE[size];
|
|
46
|
-
|
|
47
|
-
const mergedClassNames = cx(
|
|
48
|
-
styles[baseClass],
|
|
49
|
-
{
|
|
50
|
-
[styles[`${baseClass}--${size}`]]: size,
|
|
51
|
-
[styles[`${baseClass}--error`]]:
|
|
52
|
-
progressStatus === ProgressStatus.Error,
|
|
53
|
-
[styles[`${baseClass}--success`]]:
|
|
54
|
-
progressStatus === ProgressStatus.Success,
|
|
55
|
-
[styles[`${baseClass}--normal`]]:
|
|
56
|
-
progressStatus === ProgressStatus.Normal,
|
|
57
|
-
},
|
|
58
|
-
className
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const circumference = 2 * Math.PI * ((sizeValue - thickness) / 2);
|
|
62
|
-
|
|
63
|
-
const indicatorStyle = {
|
|
64
|
-
strokeDasharray: circumference.toFixed(3),
|
|
65
|
-
strokeDashoffset: `${(
|
|
66
|
-
((100 - percentNumber) / 100) *
|
|
67
|
-
circumference
|
|
68
|
-
).toFixed(3)}px`,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const svgViewBox = `${sizeValue / 2} ${
|
|
72
|
-
sizeValue / 2
|
|
73
|
-
} ${sizeValue} ${sizeValue}`;
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<div
|
|
77
|
-
className={mergedClassNames}
|
|
78
|
-
ref={ref}
|
|
79
|
-
role="progressbar"
|
|
80
|
-
{...restProps}
|
|
81
|
-
>
|
|
82
|
-
<svg viewBox={svgViewBox}>
|
|
83
|
-
<circle
|
|
84
|
-
className={styles[`${baseClass}__bg-line--${status}`]}
|
|
85
|
-
cx={sizeValue}
|
|
86
|
-
cy={sizeValue}
|
|
87
|
-
r={(sizeValue - thickness) / 2}
|
|
88
|
-
fill="none"
|
|
89
|
-
strokeWidth={thickness}
|
|
90
|
-
/>
|
|
91
|
-
<circle
|
|
92
|
-
className={styles[`${baseClass}__indicator--${status}`]}
|
|
93
|
-
style={indicatorStyle}
|
|
94
|
-
cx={sizeValue}
|
|
95
|
-
cy={sizeValue}
|
|
96
|
-
r={(sizeValue - thickness) / 2}
|
|
97
|
-
fill="none"
|
|
98
|
-
strokeWidth={thickness}
|
|
99
|
-
/>
|
|
100
|
-
</svg>
|
|
101
|
-
</div>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
);
|