@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,34 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { render } from 'test-utils';
|
|
3
|
-
import { FormGroup } from './FormGroup';
|
|
4
|
-
|
|
5
|
-
import styles from './FormGroup.module.scss';
|
|
6
|
-
|
|
7
|
-
const baseClass = 'form-group';
|
|
8
|
-
|
|
9
|
-
describe('<FormGroup> component', () => {
|
|
10
|
-
it('should allow for custom class', () => {
|
|
11
|
-
const { container } = render(
|
|
12
|
-
<FormGroup className="my-css-class">test</FormGroup>
|
|
13
|
-
);
|
|
14
|
-
expect(container.firstChild).toHaveClass('my-css-class');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should render label text', () => {
|
|
18
|
-
const text = 'Label text';
|
|
19
|
-
const { queryByText } = render(
|
|
20
|
-
<FormGroup labelText={text}>test</FormGroup>
|
|
21
|
-
);
|
|
22
|
-
expect(queryByText(text)).toBeTruthy();
|
|
23
|
-
expect(queryByText(text)).toHaveClass(styles[`${baseClass}__label`]);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should render helper text', () => {
|
|
27
|
-
const text = 'Helper text';
|
|
28
|
-
const { queryByText } = render(
|
|
29
|
-
<FormGroup helperText={text}>test</FormGroup>
|
|
30
|
-
);
|
|
31
|
-
expect(queryByText(text)).toBeTruthy();
|
|
32
|
-
expect(queryByText(text)).toHaveClass(styles[`${baseClass}__helper`]);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import { FormGroup as FormGroupComponent, FormGroupProps } from './FormGroup';
|
|
5
|
-
import { RadioButton } from '../RadioButton';
|
|
6
|
-
import { FieldGroup } from '../FieldGroup';
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
title: 'Forms (WIP)/Form Group',
|
|
10
|
-
component: FormGroupComponent,
|
|
11
|
-
parameters: {
|
|
12
|
-
componentSubtitle: `
|
|
13
|
-
Use FormGroup component to group related fieldsets. Component provides label for group of fields which improves accessibility of your form.
|
|
14
|
-
`,
|
|
15
|
-
},
|
|
16
|
-
} as ComponentMeta<typeof FormGroupComponent>;
|
|
17
|
-
|
|
18
|
-
export const FormGroup = ({ ...args }: FormGroupProps): React.ReactElement => (
|
|
19
|
-
<FormGroupComponent {...args}>
|
|
20
|
-
<FieldGroup>
|
|
21
|
-
<RadioButton id="field-group-example-1">Radio button label</RadioButton>
|
|
22
|
-
<RadioButton id="field-group-example-2">Radio button label</RadioButton>
|
|
23
|
-
</FieldGroup>
|
|
24
|
-
</FormGroupComponent>
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
FormGroup.args = {
|
|
28
|
-
labelText: 'Form Group example',
|
|
29
|
-
helperText: 'Form Group helper text',
|
|
30
|
-
} as FormGroupProps;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import cx from 'clsx';
|
|
3
|
-
import { Text, Heading } from '../Typography';
|
|
4
|
-
|
|
5
|
-
import styles from './FormGroup.module.scss';
|
|
6
|
-
|
|
7
|
-
export interface FormGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
-
className?: string;
|
|
9
|
-
labelText?: string;
|
|
10
|
-
helperText?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const baseClass = 'form-group';
|
|
14
|
-
|
|
15
|
-
export const FormGroup: React.FC<FormGroupProps> = ({
|
|
16
|
-
className = '',
|
|
17
|
-
children,
|
|
18
|
-
labelText,
|
|
19
|
-
helperText,
|
|
20
|
-
...props
|
|
21
|
-
}) => {
|
|
22
|
-
const mergedClassNames = cx(styles[baseClass], className);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<div
|
|
26
|
-
{...props}
|
|
27
|
-
role="group"
|
|
28
|
-
{...(labelText && { 'aria-label': labelText })}
|
|
29
|
-
className={mergedClassNames}
|
|
30
|
-
>
|
|
31
|
-
<div className={styles[`${baseClass}__header`]}>
|
|
32
|
-
<Heading as="div" size="sm" className={styles[`${baseClass}__label`]}>
|
|
33
|
-
{labelText}
|
|
34
|
-
</Heading>
|
|
35
|
-
{helperText && (
|
|
36
|
-
<Text as="div" size="sm" className={styles[`${baseClass}__helper`]}>
|
|
37
|
-
{helperText}
|
|
38
|
-
</Text>
|
|
39
|
-
)}
|
|
40
|
-
</div>
|
|
41
|
-
{children}
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
.icon {
|
|
2
|
-
align-items: center;
|
|
3
|
-
display: flex;
|
|
4
|
-
|
|
5
|
-
&--primary {
|
|
6
|
-
color: var(--content-default);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
&--subtle {
|
|
10
|
-
color: var(--content-subtle);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
&--inverted {
|
|
14
|
-
color: var(--content-invert-default);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&--inverted-subtle {
|
|
18
|
-
color: var(--content-invert-subtle);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&--link {
|
|
22
|
-
color: var(--color-action-default);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&--success {
|
|
26
|
-
color: var(--color-positive-default);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&--warning {
|
|
30
|
-
color: var(--color-warning-default);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&--error {
|
|
34
|
-
color: var(--color-negative-default);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&--disabled {
|
|
38
|
-
&--primary {
|
|
39
|
-
color: var(--content-disabled);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&--subtle {
|
|
43
|
-
color: var(--content-disabled);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&--inverted {
|
|
47
|
-
color: var(--content-invert-disabled);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&--inverted-subtle {
|
|
51
|
-
color: var(--content-invert-disabled);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
&--link {
|
|
55
|
-
color: var(--color-action-disabled);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&--success {
|
|
59
|
-
color: var(--color-positive-disabled);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&--warning {
|
|
63
|
-
color: var(--color-warning-default);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
&--error {
|
|
67
|
-
color: var(--color-negative-disabled);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentMeta } from '@storybook/react';
|
|
3
|
-
import * as MaterialIcons from '@livechat/design-system-icons/react/material';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
Icon as IconComponent,
|
|
7
|
-
IconSizeName,
|
|
8
|
-
IconTypeName,
|
|
9
|
-
IconProps,
|
|
10
|
-
} from './Icon';
|
|
11
|
-
|
|
12
|
-
const iterator = Object.keys(MaterialIcons);
|
|
13
|
-
|
|
14
|
-
export default {
|
|
15
|
-
title: 'Components/Icon',
|
|
16
|
-
component: IconComponent,
|
|
17
|
-
argTypes: {
|
|
18
|
-
source: {
|
|
19
|
-
options: iterator,
|
|
20
|
-
mapping: MaterialIcons,
|
|
21
|
-
control: {
|
|
22
|
-
type: 'select',
|
|
23
|
-
labels: iterator,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
size: {
|
|
27
|
-
table: {
|
|
28
|
-
defaultValue: {
|
|
29
|
-
summary: IconSizeName.Medium,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
iconType: {
|
|
34
|
-
table: {
|
|
35
|
-
defaultValue: {
|
|
36
|
-
summary: IconTypeName.Primary,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
} as ComponentMeta<typeof IconComponent>;
|
|
42
|
-
|
|
43
|
-
export const Icon = (args: IconProps): React.ReactElement => (
|
|
44
|
-
<div style={{ width: '300px' }}>
|
|
45
|
-
<IconComponent {...args} />
|
|
46
|
-
</div>
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
Icon.args = {
|
|
50
|
-
source: MaterialIcons.Email,
|
|
51
|
-
size: IconSizeName.Medium,
|
|
52
|
-
iconType: IconTypeName.Primary,
|
|
53
|
-
};
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import cx from 'clsx';
|
|
3
|
-
import styles from './Icon.module.scss';
|
|
4
|
-
|
|
5
|
-
export enum IconSizeName {
|
|
6
|
-
XSmall = 'xsmall',
|
|
7
|
-
Small = 'small',
|
|
8
|
-
Medium = 'medium',
|
|
9
|
-
Large = 'large',
|
|
10
|
-
XLarge = 'xlarge',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const IconSize = {
|
|
14
|
-
[IconSizeName.XSmall]: {
|
|
15
|
-
width: 12,
|
|
16
|
-
height: 12,
|
|
17
|
-
},
|
|
18
|
-
[IconSizeName.Small]: {
|
|
19
|
-
width: 16,
|
|
20
|
-
height: 16,
|
|
21
|
-
},
|
|
22
|
-
[IconSizeName.Medium]: {
|
|
23
|
-
width: 20,
|
|
24
|
-
height: 20,
|
|
25
|
-
},
|
|
26
|
-
[IconSizeName.Large]: {
|
|
27
|
-
width: 24,
|
|
28
|
-
height: 24,
|
|
29
|
-
},
|
|
30
|
-
[IconSizeName.XLarge]: {
|
|
31
|
-
width: 32,
|
|
32
|
-
height: 32,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export enum IconTypeName {
|
|
37
|
-
Primary = 'primary',
|
|
38
|
-
Subtle = 'subtle',
|
|
39
|
-
Inverted = 'inverted',
|
|
40
|
-
InvertedSubtle = 'inverted_subtle',
|
|
41
|
-
Link = 'link',
|
|
42
|
-
Success = 'success',
|
|
43
|
-
Warning = 'warning',
|
|
44
|
-
Error = 'error',
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export const IconColorMapper = {
|
|
48
|
-
[IconTypeName.Primary]: 'primary',
|
|
49
|
-
[IconTypeName.Subtle]: 'subtle',
|
|
50
|
-
[IconTypeName.Inverted]: 'inverted',
|
|
51
|
-
[IconTypeName.InvertedSubtle]: 'inverted-subtle',
|
|
52
|
-
[IconTypeName.Link]: 'link',
|
|
53
|
-
[IconTypeName.Success]: 'success',
|
|
54
|
-
[IconTypeName.Warning]: 'warning',
|
|
55
|
-
[IconTypeName.Error]: 'error',
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const IconColorDisabledMapper = {
|
|
59
|
-
[IconTypeName.Primary]: 'disabled--primary',
|
|
60
|
-
[IconTypeName.Subtle]: 'disabled--subtle',
|
|
61
|
-
[IconTypeName.Inverted]: 'disabled--inverted',
|
|
62
|
-
[IconTypeName.InvertedSubtle]: 'disabled--inverted-subtle',
|
|
63
|
-
[IconTypeName.Link]: 'disabled--link',
|
|
64
|
-
[IconTypeName.Success]: 'disabled--success',
|
|
65
|
-
[IconTypeName.Warning]: 'disabled--warning',
|
|
66
|
-
[IconTypeName.Error]: 'disabled--error',
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export interface IconProps {
|
|
70
|
-
source: React.FC<React.SVGProps<SVGSVGElement>> | string;
|
|
71
|
-
size?: IconSizeName;
|
|
72
|
-
iconType?: IconTypeName;
|
|
73
|
-
disabled?: boolean;
|
|
74
|
-
className?: string;
|
|
75
|
-
customColor?: string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const baseClass = 'icon';
|
|
79
|
-
|
|
80
|
-
export const Icon: React.FC<IconProps> = (props) => {
|
|
81
|
-
const {
|
|
82
|
-
source,
|
|
83
|
-
size = IconSizeName.Medium,
|
|
84
|
-
iconType,
|
|
85
|
-
disabled,
|
|
86
|
-
className,
|
|
87
|
-
customColor,
|
|
88
|
-
...restProps
|
|
89
|
-
} = props;
|
|
90
|
-
let filledColor;
|
|
91
|
-
|
|
92
|
-
if (iconType) {
|
|
93
|
-
filledColor = IconColorMapper[iconType];
|
|
94
|
-
|
|
95
|
-
if (disabled) {
|
|
96
|
-
filledColor = IconColorDisabledMapper[iconType];
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const GeneratedIcon = React.createElement(source, {
|
|
101
|
-
...IconSize[size],
|
|
102
|
-
color: customColor,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const mergedClassNames = cx(
|
|
106
|
-
className,
|
|
107
|
-
styles[baseClass],
|
|
108
|
-
filledColor && styles[`${baseClass}--${filledColor}`]
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<span {...restProps} className={mergedClassNames}>
|
|
113
|
-
{GeneratedIcon}
|
|
114
|
-
</span>
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export default Icon;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
.input-field {
|
|
2
|
-
background-clip: padding-box;
|
|
3
|
-
border: 1px solid var(--border-default);
|
|
4
|
-
border-radius: 4px;
|
|
5
|
-
box-sizing: border-box;
|
|
6
|
-
color: var(--content-default);
|
|
7
|
-
font-size: 15px;
|
|
8
|
-
line-height: 1.2;
|
|
9
|
-
padding: 8px 10px;
|
|
10
|
-
transition: border 0.25s ease-in-out;
|
|
11
|
-
width: 100%;
|
|
12
|
-
will-change: border-color;
|
|
13
|
-
|
|
14
|
-
&::placeholder {
|
|
15
|
-
color: var(--content-disabled);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
&:hover {
|
|
19
|
-
border-color: var(--border-hover);
|
|
20
|
-
outline: 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
&:focus {
|
|
24
|
-
border-color: var(--color-action-default);
|
|
25
|
-
outline: 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&--error,
|
|
29
|
-
&--error:focus {
|
|
30
|
-
border-color: var(--color-negative-default);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&:disabled {
|
|
34
|
-
color: var(--content-disabled);
|
|
35
|
-
cursor: not-allowed;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { render, fireEvent, vi } from 'test-utils';
|
|
3
|
-
import { InputFieldProps, InputField } from './InputField';
|
|
4
|
-
|
|
5
|
-
import styles from './InputField.module.scss';
|
|
6
|
-
|
|
7
|
-
const renderComponent = (props: InputFieldProps) => {
|
|
8
|
-
return render(<InputField {...props} className="my-css-class" />);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
describe('<InputField> component', () => {
|
|
12
|
-
it('should allow for custom class', () => {
|
|
13
|
-
const { container } = renderComponent({
|
|
14
|
-
id: 'input-field-example',
|
|
15
|
-
onChange: vi.fn(),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
expect(container.firstChild).toHaveClass('my-css-class');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should allow for field custom class', () => {
|
|
22
|
-
const { getByRole } = renderComponent({
|
|
23
|
-
id: 'input-field-example',
|
|
24
|
-
onChange: vi.fn(),
|
|
25
|
-
placeholder: 'placeholder',
|
|
26
|
-
fieldClassName: 'my-field-css-class',
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
expect(getByRole('textbox')).toHaveClass('my-field-css-class');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should have error class', () => {
|
|
33
|
-
const { getByRole } = renderComponent({
|
|
34
|
-
id: 'input-field-example',
|
|
35
|
-
onChange: vi.fn(),
|
|
36
|
-
error: 'Error',
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
expect(getByRole('textbox')).toHaveClass(styles['input-field--error']);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should call onChange when value changes', () => {
|
|
43
|
-
const mockedFunction = vi.fn();
|
|
44
|
-
const { getByRole } = renderComponent({
|
|
45
|
-
id: 'input-field-example',
|
|
46
|
-
onChange: mockedFunction,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
fireEvent.change(getByRole('textbox'), { target: { value: 'test' } });
|
|
50
|
-
const event = mockedFunction.mock.calls[0][0];
|
|
51
|
-
expect(event.target.value).toEqual('test');
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentMeta, Story } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
InputFieldProps,
|
|
6
|
-
InputField as InputFieldComponent,
|
|
7
|
-
} from './InputField';
|
|
8
|
-
import { Text } from '../Typography';
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
title: 'Forms (WIP)/InputField',
|
|
12
|
-
component: InputFieldComponent,
|
|
13
|
-
parameters: {
|
|
14
|
-
componentSubtitle: `
|
|
15
|
-
InputField contains a TextField component, so most of the props are directed to
|
|
16
|
-
handle TextField elements, e.g. label or description.
|
|
17
|
-
The InputField itself is prepared to accept props dedicated to the <input>,
|
|
18
|
-
which we can pass by InputField.
|
|
19
|
-
`,
|
|
20
|
-
},
|
|
21
|
-
} as ComponentMeta<typeof InputFieldComponent>;
|
|
22
|
-
|
|
23
|
-
const StoryTemplate: Story<InputFieldProps> = (args: InputFieldProps) => (
|
|
24
|
-
<div>
|
|
25
|
-
<InputFieldComponent
|
|
26
|
-
labelText="Input Field label"
|
|
27
|
-
placeholder="Placeholder..."
|
|
28
|
-
description={
|
|
29
|
-
<div>
|
|
30
|
-
<Text as="span" size="sm">
|
|
31
|
-
Help text
|
|
32
|
-
</Text>
|
|
33
|
-
</div>
|
|
34
|
-
}
|
|
35
|
-
{...args}
|
|
36
|
-
/>
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
export const InputField = StoryTemplate.bind({});
|
|
41
|
-
InputField.args = {};
|
|
42
|
-
|
|
43
|
-
export const InputFieldWithInline = StoryTemplate.bind({});
|
|
44
|
-
InputFieldWithInline.args = {
|
|
45
|
-
inline: true,
|
|
46
|
-
id: 'withInline',
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const InputFieldWithDisabled = StoryTemplate.bind({});
|
|
50
|
-
InputFieldWithDisabled.args = {
|
|
51
|
-
disabled: true,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const InputFieldWithCustomInputStyles = StoryTemplate.bind({});
|
|
55
|
-
InputFieldWithCustomInputStyles.args = {
|
|
56
|
-
style: {
|
|
57
|
-
width: 400,
|
|
58
|
-
height: 50,
|
|
59
|
-
borderColor: 'var(--color-positive-default)',
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const InputFieldWithMaxLength = StoryTemplate.bind({});
|
|
64
|
-
InputFieldWithMaxLength.args = {
|
|
65
|
-
maxLength: 20,
|
|
66
|
-
id: 'withMaxLength',
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const InputFieldWithError = StoryTemplate.bind({});
|
|
70
|
-
InputFieldWithError.args = {
|
|
71
|
-
error: 'Error text',
|
|
72
|
-
id: 'withError',
|
|
73
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import cx from 'clsx';
|
|
3
|
-
import { TextField } from '../TextField';
|
|
4
|
-
|
|
5
|
-
import styles from './InputField.module.scss';
|
|
6
|
-
|
|
7
|
-
const baseClass = 'input-field';
|
|
8
|
-
|
|
9
|
-
export interface InputFieldProps
|
|
10
|
-
extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
11
|
-
id: string;
|
|
12
|
-
labelText?: string;
|
|
13
|
-
labelAdornment?: React.ReactNode;
|
|
14
|
-
className?: string;
|
|
15
|
-
inline?: boolean;
|
|
16
|
-
error?: string;
|
|
17
|
-
description?: React.ReactNode;
|
|
18
|
-
labelRightNode?: React.ReactNode;
|
|
19
|
-
fieldClassName?: string;
|
|
20
|
-
maxLength?: number;
|
|
21
|
-
onChange: () => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const InputField: React.FC<InputFieldProps> = React.forwardRef(
|
|
25
|
-
(
|
|
26
|
-
{
|
|
27
|
-
id,
|
|
28
|
-
labelText,
|
|
29
|
-
labelAdornment,
|
|
30
|
-
className,
|
|
31
|
-
inline,
|
|
32
|
-
error,
|
|
33
|
-
description,
|
|
34
|
-
labelRightNode,
|
|
35
|
-
fieldClassName,
|
|
36
|
-
style,
|
|
37
|
-
type = 'text',
|
|
38
|
-
...restProps
|
|
39
|
-
},
|
|
40
|
-
ref: React.Ref<HTMLInputElement>
|
|
41
|
-
) => {
|
|
42
|
-
const mergedClassNames = cx(
|
|
43
|
-
styles[baseClass],
|
|
44
|
-
{
|
|
45
|
-
[styles[`${baseClass}--error`]]: error,
|
|
46
|
-
},
|
|
47
|
-
fieldClassName
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<TextField
|
|
52
|
-
inline={inline}
|
|
53
|
-
error={error}
|
|
54
|
-
description={description}
|
|
55
|
-
labelText={labelText}
|
|
56
|
-
labelAdornment={labelAdornment}
|
|
57
|
-
className={className}
|
|
58
|
-
labelFor={id}
|
|
59
|
-
labelRightNode={labelRightNode}
|
|
60
|
-
>
|
|
61
|
-
<input
|
|
62
|
-
{...restProps}
|
|
63
|
-
id={id}
|
|
64
|
-
ref={ref}
|
|
65
|
-
className={mergedClassNames}
|
|
66
|
-
style={style}
|
|
67
|
-
type={type}
|
|
68
|
-
/>
|
|
69
|
-
</TextField>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
.link {
|
|
2
|
-
color: var(--color-action-default);
|
|
3
|
-
cursor: pointer;
|
|
4
|
-
text-decoration: none;
|
|
5
|
-
|
|
6
|
-
&:hover {
|
|
7
|
-
color: var(--color-action-hover);
|
|
8
|
-
text-decoration: underline;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
&:active {
|
|
12
|
-
color: var(--color-action-active);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
&--bold {
|
|
16
|
-
font-weight: 600;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import { Link as LinkComponent, LinkProps } from './Link';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Components/Link',
|
|
8
|
-
component: LinkComponent,
|
|
9
|
-
} as ComponentMeta<typeof LinkComponent>;
|
|
10
|
-
|
|
11
|
-
export const Link = ({ ...args }: LinkProps): React.ReactElement => (
|
|
12
|
-
<LinkComponent {...args}>This is a link</LinkComponent>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
Link.args = {
|
|
16
|
-
bold: false,
|
|
17
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
@keyframes rotate {
|
|
2
|
-
from {
|
|
3
|
-
transform: rotate(0deg);
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
to {
|
|
7
|
-
transform: rotate(1turn);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.loader {
|
|
12
|
-
align-items: center;
|
|
13
|
-
display: inline-flex;
|
|
14
|
-
flex-direction: row;
|
|
15
|
-
flex-wrap: nowrap;
|
|
16
|
-
|
|
17
|
-
&__spinner {
|
|
18
|
-
flex-shrink: 0;
|
|
19
|
-
height: 36px;
|
|
20
|
-
width: 36px;
|
|
21
|
-
|
|
22
|
-
&--small {
|
|
23
|
-
height: 15px;
|
|
24
|
-
width: 15px;
|
|
25
|
-
|
|
26
|
-
[class*='spinner-circle'] {
|
|
27
|
-
border-width: 2px;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&--medium {
|
|
32
|
-
height: 36px;
|
|
33
|
-
width: 36px;
|
|
34
|
-
|
|
35
|
-
[class*='spinner-circle'] {
|
|
36
|
-
border-width: 3px;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&--large {
|
|
41
|
-
height: 56px;
|
|
42
|
-
width: 56px;
|
|
43
|
-
|
|
44
|
-
[class*='spinner-circle'] {
|
|
45
|
-
border-width: 4px;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
&-circle {
|
|
50
|
-
animation: rotate 1s infinite linear;
|
|
51
|
-
border-color: var(--surface-secondary-subtle);
|
|
52
|
-
border-radius: 50%;
|
|
53
|
-
border-style: solid;
|
|
54
|
-
border-top-color: var(--color-action-default);
|
|
55
|
-
border-width: 3px;
|
|
56
|
-
box-sizing: border-box;
|
|
57
|
-
height: 100%;
|
|
58
|
-
width: 100%;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&__label {
|
|
63
|
-
color: var(--content-subtle);
|
|
64
|
-
margin-left: 10px;
|
|
65
|
-
}
|
|
66
|
-
}
|