@react5/ui 1.0.26 → 1.0.28
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/LICENSE +21 -21
- package/README.md +2 -2
- package/package.json +38 -38
- package/packages/app/README.md +50 -50
- package/packages/app/eslint.config.js +28 -28
- package/packages/app/index.html +13 -13
- package/packages/app/jest.config.js +12 -12
- package/packages/app/package.json +36 -36
- package/packages/app/src/App.css +5 -5
- package/packages/app/src/App.tsx +35 -35
- package/packages/app/src/i18n/config.ts +21 -21
- package/packages/app/src/i18n/en/translation.json +4 -4
- package/packages/app/src/i18n/fr/translation.json +4 -4
- package/packages/app/src/i18n/index.ts +3 -3
- package/packages/app/src/main.tsx +16 -16
- package/packages/app/src/styles/1-reset.scss +72 -72
- package/packages/app/src/styles/2-colors.scss +11 -11
- package/packages/app/src/vite-env.d.ts +1 -1
- package/packages/app/tsconfig.app.json +26 -26
- package/packages/app/tsconfig.json +7 -7
- package/packages/app/tsconfig.node.json +24 -24
- package/packages/app/vite.config.ts +7 -7
- package/packages/lib/.babelrc +9 -9
- package/packages/lib/.storybook/main.js +50 -50
- package/packages/lib/.storybook/preview.js +13 -13
- package/packages/lib/declaration.d.ts +9 -9
- package/packages/lib/dist/esm/index.esm.css +0 -2
- package/packages/lib/dist/esm/index.esm.js +1 -1
- package/packages/lib/dist/esm/index.esm.js.map +1 -1
- package/packages/lib/dist/esm/index.esm.scss +1401 -1403
- package/packages/lib/dist/index.css +0 -2
- package/packages/lib/dist/index.js +1 -1
- package/packages/lib/dist/index.js.map +1 -1
- package/packages/lib/dist/index.scss +1401 -1403
- package/packages/lib/jest.config.js +19 -19
- package/packages/lib/package.json +100 -102
- package/packages/lib/plop/component/index.js +43 -43
- package/packages/lib/plop/index.js +3 -3
- package/packages/lib/plop/templates/component/component.hbs +19 -19
- package/packages/lib/plop/templates/component/index.hbs +1 -1
- package/packages/lib/plop/templates/component/stories.hbs +17 -17
- package/packages/lib/plop/templates/component/style.hbs +1 -1
- package/packages/lib/plop/templates/component/test.hbs +11 -11
- package/packages/lib/plopfile.js +1 -1
- package/packages/lib/rollup.config.mjs +64 -64
- package/packages/lib/src/components/Accordion/Accordion.scss +67 -67
- package/packages/lib/src/components/Accordion/Accordion.tsx +36 -36
- package/packages/lib/src/components/Button/Button.scss +60 -62
- package/packages/lib/src/components/Button/Button.stories.tsx +26 -26
- package/packages/lib/src/components/Button/Button.tsx +40 -40
- package/packages/lib/src/components/Button/index.tsx +1 -1
- package/packages/lib/src/components/ButtonsGroup/ButtonsGroup.scss +3 -3
- package/packages/lib/src/components/ButtonsGroup/ButtonsGroup.stories.tsx +17 -17
- package/packages/lib/src/components/ButtonsGroup/ButtonsGroup.test.tsx +11 -11
- package/packages/lib/src/components/ButtonsGroup/ButtonsGroup.tsx +17 -17
- package/packages/lib/src/components/ButtonsGroup/index.tsx +1 -1
- package/packages/lib/src/components/CheckBox/CheckBox.scss +63 -63
- package/packages/lib/src/components/CheckBox/CheckBox.stories.tsx +22 -22
- package/packages/lib/src/components/CheckBox/CheckBox.tsx +42 -42
- package/packages/lib/src/components/CheckBox/index.tsx +1 -1
- package/packages/lib/src/components/DialogPrompt/DialogPrompt.scss +6 -6
- package/packages/lib/src/components/DialogPrompt/DialogPrompt.stories.tsx +17 -17
- package/packages/lib/src/components/DialogPrompt/DialogPrompt.test.tsx +11 -11
- package/packages/lib/src/components/DialogPrompt/DialogPrompt.tsx +41 -41
- package/packages/lib/src/components/DialogPrompt/index.tsx +1 -1
- package/packages/lib/src/components/Divider/Divider.scss +22 -22
- package/packages/lib/src/components/Divider/Divider.tsx +20 -20
- package/packages/lib/src/components/DropDown/DropDown.scss +70 -70
- package/packages/lib/src/components/DropDown/DropDown.stories.tsx +45 -45
- package/packages/lib/src/components/DropDown/DropDown.tsx +61 -61
- package/packages/lib/src/components/DropDown/index.tsx +1 -1
- package/packages/lib/src/components/Form/Form.scss +3 -3
- package/packages/lib/src/components/Form/Form.stories.tsx +20 -20
- package/packages/lib/src/components/Form/Form.tsx +25 -25
- package/packages/lib/src/components/FormButtons/FormButtons.scss +5 -5
- package/packages/lib/src/components/FormButtons/FormButtons.tsx +18 -18
- package/packages/lib/src/components/HeaderButtons/HeaderButtons.scss +6 -6
- package/packages/lib/src/components/HeaderButtons/HeaderButtons.stories.tsx +17 -17
- package/packages/lib/src/components/HeaderButtons/HeaderButtons.test.tsx +11 -11
- package/packages/lib/src/components/HeaderButtons/HeaderButtons.tsx +28 -28
- package/packages/lib/src/components/HeaderButtons/index.tsx +1 -1
- package/packages/lib/src/components/IconButton/IconButton.scss +64 -64
- package/packages/lib/src/components/IconButton/IconButton.tsx +44 -44
- package/packages/lib/src/components/MenuItem/MenuItem.scss +13 -13
- package/packages/lib/src/components/MenuItem/MenuItem.tsx +36 -36
- package/packages/lib/src/components/Modal/Modal.scss +71 -71
- package/packages/lib/src/components/Modal/Modal.tsx +60 -60
- package/packages/lib/src/components/Navbar/Navbar.scss +52 -52
- package/packages/lib/src/components/Navbar/Navbar.stories.tsx +25 -25
- package/packages/lib/src/components/Navbar/Navbar.tsx +38 -38
- package/packages/lib/src/components/NavbarLink/NavbarLink.scss +15 -15
- package/packages/lib/src/components/NavbarLink/NavbarLink.tsx +34 -34
- package/packages/lib/src/components/NavbarMenu/NavbarMenu.scss +156 -156
- package/packages/lib/src/components/NavbarMenu/NavbarMenu.stories.tsx +24 -24
- package/packages/lib/src/components/NavbarMenu/NavbarMenu.tsx +72 -72
- package/packages/lib/src/components/Panel/Panel.scss +29 -29
- package/packages/lib/src/components/Panel/Panel.stories.tsx +32 -32
- package/packages/lib/src/components/Panel/Panel.test.tsx +11 -11
- package/packages/lib/src/components/Panel/Panel.tsx +29 -29
- package/packages/lib/src/components/Panel/index.tsx +1 -1
- package/packages/lib/src/components/Paper/Paper.scss +5 -5
- package/packages/lib/src/components/Paper/Paper.stories.tsx +18 -18
- package/packages/lib/src/components/Paper/Paper.tsx +18 -18
- package/packages/lib/src/components/Paper/index.tsx +1 -1
- package/packages/lib/src/components/RangeSlider/RangeSlider.scss +83 -83
- package/packages/lib/src/components/RangeSlider/RangeSlider.stories.tsx +24 -24
- package/packages/lib/src/components/RangeSlider/RangeSlider.tsx +150 -150
- package/packages/lib/src/components/ResponsiveBar/ResponsiveBar.scss +72 -72
- package/packages/lib/src/components/ResponsiveBar/ResponsiveBar.tsx +38 -38
- package/packages/lib/src/components/ScrollView/ScrollView.scss +20 -20
- package/packages/lib/src/components/ScrollView/ScrollView.stories.tsx +17 -17
- package/packages/lib/src/components/ScrollView/ScrollView.test.tsx +11 -11
- package/packages/lib/src/components/ScrollView/ScrollView.tsx +19 -19
- package/packages/lib/src/components/ScrollView/index.tsx +1 -1
- package/packages/lib/src/components/Section/Section.scss +17 -17
- package/packages/lib/src/components/Section/Section.tsx +26 -26
- package/packages/lib/src/components/SelectField/SelectField.scss +42 -42
- package/packages/lib/src/components/SelectField/SelectField.stories.tsx +14 -14
- package/packages/lib/src/components/SelectField/SelectField.tsx +54 -54
- package/packages/lib/src/components/SelectField/index.tsx +1 -1
- package/packages/lib/src/components/Spacer/Spacer.scss +2 -2
- package/packages/lib/src/components/Spacer/Spacer.tsx +6 -6
- package/packages/lib/src/components/StackPanel/StackPanel.scss +8 -8
- package/packages/lib/src/components/StackPanel/StackPanel.stories.tsx +17 -17
- package/packages/lib/src/components/StackPanel/StackPanel.test.tsx +11 -11
- package/packages/lib/src/components/StackPanel/StackPanel.tsx +31 -31
- package/packages/lib/src/components/StackPanel/index.tsx +1 -1
- package/packages/lib/src/components/Submenu/Submenu.scss +55 -55
- package/packages/lib/src/components/Submenu/Submenu.stories.tsx +45 -45
- package/packages/lib/src/components/Submenu/Submenu.tsx +59 -59
- package/packages/lib/src/components/Submenu/index.tsx +1 -1
- package/packages/lib/src/components/SuccessCongratulation/SuccessCongratulation.scss +75 -75
- package/packages/lib/src/components/SuccessCongratulation/SuccessCongratulation.stories.tsx +17 -17
- package/packages/lib/src/components/SuccessCongratulation/SuccessCongratulation.test.tsx +11 -11
- package/packages/lib/src/components/SuccessCongratulation/SuccessCongratulation.tsx +63 -63
- package/packages/lib/src/components/SuccessCongratulation/index.tsx +1 -1
- package/packages/lib/src/components/TextArea/TextArea.scss +41 -41
- package/packages/lib/src/components/TextArea/TextArea.stories.tsx +14 -14
- package/packages/lib/src/components/TextArea/TextArea.tsx +50 -50
- package/packages/lib/src/components/TextArea/index.tsx +1 -1
- package/packages/lib/src/components/TextField/TextField.scss +56 -56
- package/packages/lib/src/components/TextField/TextField.stories.tsx +14 -14
- package/packages/lib/src/components/TextField/TextField.tsx +89 -89
- package/packages/lib/src/components/TextField/index.tsx +1 -1
- package/packages/lib/src/components/TitleEdit/TitleEdit.scss +17 -17
- package/packages/lib/src/components/TitleEdit/TitleEdit.tsx +69 -69
- package/packages/lib/src/components/Toast/Toast.scss +32 -32
- package/packages/lib/src/components/Toast/Toast.tsx +29 -29
- package/packages/lib/src/components/ToggleButton/ToggleButton.scss +47 -47
- package/packages/lib/src/components/ToggleButton/ToggleButton.stories.tsx +22 -22
- package/packages/lib/src/components/ToggleButton/ToggleButton.tsx +41 -41
- package/packages/lib/src/components/ToggleButton/index.tsx +1 -1
- package/packages/lib/src/components/Toolbar/Toolbar.scss +16 -16
- package/packages/lib/src/components/Toolbar/Toolbar.stories.tsx +17 -17
- package/packages/lib/src/components/Toolbar/Toolbar.test.tsx +11 -11
- package/packages/lib/src/components/Toolbar/Toolbar.tsx +20 -20
- package/packages/lib/src/components/Toolbar/index.tsx +1 -1
- package/packages/lib/src/components/Typography/Typography.scss +51 -51
- package/packages/lib/src/components/Typography/Typography.stories.tsx +18 -18
- package/packages/lib/src/components/Typography/Typography.tsx +19 -19
- package/packages/lib/src/components/index.tsx +34 -34
- package/packages/lib/src/hooks/index.tsx +3 -3
- package/packages/lib/src/hooks/use-click-outside.tsx +19 -19
- package/packages/lib/src/hooks/use-form.tsx +107 -107
- package/packages/lib/src/hooks/use-keys-enteresc.tsx +25 -25
- package/packages/lib/src/hooks/use-set-startup-focus.tsx +8 -8
- package/packages/lib/src/i18n/config.ts +8 -8
- package/packages/lib/src/i18n/en/translation.json +11 -11
- package/packages/lib/src/i18n/fr/translation.json +11 -11
- package/packages/lib/src/i18n/index.ts +11 -11
- package/packages/lib/src/index.tsx +7 -7
- package/packages/lib/src/stories/Intrduction.mdx +171 -171
- package/packages/lib/src/stories/assets/github.svg +3 -3
- package/packages/lib/src/styles/1-color-vars.scss +51 -51
- package/packages/lib/src/styles/2-font-variables.scss +2 -2
- package/packages/lib/src/styles/variables.scss +1 -1
- package/packages/lib/src/test/i18n.ts +17 -17
- package/packages/lib/src/utils/bem.ts +4 -4
- package/packages/lib/src/utils/formatError.ts +5 -5
- package/packages/lib/src/utils/index.ts +1 -1
- package/packages/lib/src/utils/interfaces.ts +5 -5
- package/packages/lib/tsconfig.json +26 -25
- package/packages/lib/vite.config.js +18 -18
- package/packages/ui-test/package-lock.json +97 -97
- package/packages/ui-test/package.json +19 -19
- package/packages/ui-test/playwright.config.ts +80 -80
- package/packages/ui-test/tests/example.spec.ts +18 -18
- package/packages/ui-test/tests-examples/demo-todo-app.spec.ts +437 -437
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
.r5ui-section {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: row;
|
|
4
|
-
&__fields {
|
|
5
|
-
margin: 0.5em;
|
|
6
|
-
display: flex;
|
|
7
|
-
flex-direction: column;
|
|
8
|
-
width: 100%;
|
|
9
|
-
}
|
|
10
|
-
&__with-border {
|
|
11
|
-
border: 1px solid $primary_border_color;
|
|
12
|
-
border-radius: $border_radius;
|
|
13
|
-
padding: 0.5em;
|
|
14
|
-
}
|
|
15
|
-
&__actions {
|
|
16
|
-
width: 32px;
|
|
17
|
-
}
|
|
1
|
+
.r5ui-section {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
&__fields {
|
|
5
|
+
margin: 0.5em;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
&__with-border {
|
|
11
|
+
border: 1px solid $primary_border_color;
|
|
12
|
+
border-radius: $border_radius;
|
|
13
|
+
padding: 0.5em;
|
|
14
|
+
}
|
|
15
|
+
&__actions {
|
|
16
|
+
width: 32px;
|
|
17
|
+
}
|
|
18
18
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import './Section.scss'
|
|
2
|
-
import { bem } from '../../utils/bem';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
import { IconButton } from '../IconButton';
|
|
5
|
-
import { FaXmark } from 'react-icons/fa6'
|
|
6
|
-
import clsx from 'clsx';
|
|
7
|
-
export interface ISectionProps {
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
onClose?: () => void;
|
|
10
|
-
isVisible?: boolean;
|
|
11
|
-
noBorder?: boolean;
|
|
12
|
-
}
|
|
13
|
-
const b = bem("section");
|
|
14
|
-
export const Section = ({ children, onClose, noBorder }: ISectionProps) => {
|
|
15
|
-
return (
|
|
16
|
-
<div className={b()}>
|
|
17
|
-
<div className={clsx(b("fields"), !noBorder && b("with-border"))}>
|
|
18
|
-
{children}
|
|
19
|
-
</div>
|
|
20
|
-
{onClose && <div className={b("actions")}>
|
|
21
|
-
<IconButton onClick={onClose}><FaXmark/></IconButton>
|
|
22
|
-
</div>}
|
|
23
|
-
</div>
|
|
24
|
-
)
|
|
25
|
-
}
|
|
26
|
-
export default Section
|
|
1
|
+
import './Section.scss'
|
|
2
|
+
import { bem } from '../../utils/bem';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { IconButton } from '../IconButton';
|
|
5
|
+
import { FaXmark } from 'react-icons/fa6'
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
export interface ISectionProps {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
isVisible?: boolean;
|
|
11
|
+
noBorder?: boolean;
|
|
12
|
+
}
|
|
13
|
+
const b = bem("section");
|
|
14
|
+
export const Section = ({ children, onClose, noBorder }: ISectionProps) => {
|
|
15
|
+
return (
|
|
16
|
+
<div className={b()}>
|
|
17
|
+
<div className={clsx(b("fields"), !noBorder && b("with-border"))}>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
{onClose && <div className={b("actions")}>
|
|
21
|
+
<IconButton onClick={onClose}><FaXmark/></IconButton>
|
|
22
|
+
</div>}
|
|
23
|
+
</div>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
export default Section
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
.r5ui-select-field {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
align-items: center;
|
|
5
|
-
justify-content: center;
|
|
6
|
-
|
|
7
|
-
margin: 0.5em;
|
|
8
|
-
|
|
9
|
-
&__label {
|
|
10
|
-
flex: 40%;
|
|
11
|
-
padding: 3px;
|
|
12
|
-
color: $page_text_color;
|
|
13
|
-
align-self: center;
|
|
14
|
-
margin-right: 0.5em;
|
|
15
|
-
&--left {
|
|
16
|
-
text-align: left;
|
|
17
|
-
}
|
|
18
|
-
&--center {
|
|
19
|
-
text-align: center;
|
|
20
|
-
}
|
|
21
|
-
&--right {
|
|
22
|
-
text-align: right;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
&__input {
|
|
26
|
-
flex: 60%;
|
|
27
|
-
border: $border_size solid $primary_border_color;
|
|
28
|
-
border-radius: $border_radius;
|
|
29
|
-
color: $control_text_color;
|
|
30
|
-
background-color: $control_bg_color;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&__wrapper {
|
|
34
|
-
display: flex;
|
|
35
|
-
justify-content: space-between;
|
|
36
|
-
flex-direction: row;
|
|
37
|
-
width: 100%;
|
|
38
|
-
}
|
|
39
|
-
&__error-container {
|
|
40
|
-
text-align: right;
|
|
41
|
-
color: $error_validation_color;
|
|
42
|
-
}
|
|
1
|
+
.r5ui-select-field {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
|
|
7
|
+
margin: 0.5em;
|
|
8
|
+
|
|
9
|
+
&__label {
|
|
10
|
+
flex: 40%;
|
|
11
|
+
padding: 3px;
|
|
12
|
+
color: $page_text_color;
|
|
13
|
+
align-self: center;
|
|
14
|
+
margin-right: 0.5em;
|
|
15
|
+
&--left {
|
|
16
|
+
text-align: left;
|
|
17
|
+
}
|
|
18
|
+
&--center {
|
|
19
|
+
text-align: center;
|
|
20
|
+
}
|
|
21
|
+
&--right {
|
|
22
|
+
text-align: right;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
&__input {
|
|
26
|
+
flex: 60%;
|
|
27
|
+
border: $border_size solid $primary_border_color;
|
|
28
|
+
border-radius: $border_radius;
|
|
29
|
+
color: $control_text_color;
|
|
30
|
+
background-color: $control_bg_color;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&__wrapper {
|
|
34
|
+
display: flex;
|
|
35
|
+
justify-content: space-between;
|
|
36
|
+
flex-direction: row;
|
|
37
|
+
width: 100%;
|
|
38
|
+
}
|
|
39
|
+
&__error-container {
|
|
40
|
+
text-align: right;
|
|
41
|
+
color: $error_validation_color;
|
|
42
|
+
}
|
|
43
43
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { SelectField } from './SelectField';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof SelectField> = {
|
|
5
|
-
title: 'Example/SelectField',
|
|
6
|
-
component: SelectField,
|
|
7
|
-
} as Meta;
|
|
8
|
-
export default meta;
|
|
9
|
-
|
|
10
|
-
type Story = StoryObj<typeof SelectField>;
|
|
11
|
-
|
|
12
|
-
export const TextButton: Story = {
|
|
13
|
-
render: () => <SelectField value="test" name="tf1" />,
|
|
14
|
-
};
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { SelectField } from './SelectField';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof SelectField> = {
|
|
5
|
+
title: 'Example/SelectField',
|
|
6
|
+
component: SelectField,
|
|
7
|
+
} as Meta;
|
|
8
|
+
export default meta;
|
|
9
|
+
|
|
10
|
+
type Story = StoryObj<typeof SelectField>;
|
|
11
|
+
|
|
12
|
+
export const TextButton: Story = {
|
|
13
|
+
render: () => <SelectField value="test" name="tf1" />,
|
|
14
|
+
};
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { ChangeEventHandler, forwardRef } from "react";
|
|
2
|
-
import { formatError } from "../../utils";
|
|
3
|
-
import "./SelectField.scss"
|
|
4
|
-
import clsx from "clsx";
|
|
5
|
-
import { bem } from '../../utils/bem';
|
|
6
|
-
|
|
7
|
-
export interface ILabelValuePair {
|
|
8
|
-
label: string;
|
|
9
|
-
value: string | number;
|
|
10
|
-
}
|
|
11
|
-
interface ISelectFieldProps {
|
|
12
|
-
label?: string;
|
|
13
|
-
name?: string;
|
|
14
|
-
error?: string;
|
|
15
|
-
validationError?: (name?: string) => string | undefined;
|
|
16
|
-
onChange?: ChangeEventHandler<HTMLSelectElement>;
|
|
17
|
-
onBlur?: ChangeEventHandler<HTMLSelectElement>;
|
|
18
|
-
value?: string;
|
|
19
|
-
autoFocus?: boolean;
|
|
20
|
-
className?: string;
|
|
21
|
-
disabled?: boolean;
|
|
22
|
-
placeholder?: string;
|
|
23
|
-
noLabel?: boolean;
|
|
24
|
-
options?: ILabelValuePair[] | null;
|
|
25
|
-
align?: "left" | "center" | "right";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const b = bem("select-field");
|
|
29
|
-
export const SelectField = forwardRef<HTMLSelectElement, ISelectFieldProps>(({value,
|
|
30
|
-
onChange, noLabel = false, onBlur, name, className, autoFocus = false,
|
|
31
|
-
disabled = false, label, error, options, align = "right" }: ISelectFieldProps, ref) => {
|
|
32
|
-
|
|
33
|
-
return (<div className={clsx(b(), className)}>
|
|
34
|
-
<div className={b("wrapper")}>
|
|
35
|
-
{!noLabel && <label
|
|
36
|
-
htmlFor={name} className={clsx(b("label"), b("label", align))}>{label}:</label>}
|
|
37
|
-
<select
|
|
38
|
-
id={name}
|
|
39
|
-
name={name}
|
|
40
|
-
className={b("input")}
|
|
41
|
-
disabled={disabled}
|
|
42
|
-
value={value}
|
|
43
|
-
onChange={onChange}
|
|
44
|
-
onBlur={onBlur}
|
|
45
|
-
ref={ref}
|
|
46
|
-
autoFocus={autoFocus}
|
|
47
|
-
autoComplete="on"
|
|
48
|
-
>
|
|
49
|
-
{options && options.map(o => <option value={o.value} key={o.value}>{o.label}</option>)}
|
|
50
|
-
</select>
|
|
51
|
-
</div>
|
|
52
|
-
{error && <div className={b("error-container")}>{formatError(error, label)}</div>}
|
|
53
|
-
</div>)
|
|
54
|
-
});
|
|
1
|
+
import { ChangeEventHandler, forwardRef } from "react";
|
|
2
|
+
import { formatError } from "../../utils";
|
|
3
|
+
import "./SelectField.scss"
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
import { bem } from '../../utils/bem';
|
|
6
|
+
|
|
7
|
+
export interface ILabelValuePair {
|
|
8
|
+
label: string;
|
|
9
|
+
value: string | number;
|
|
10
|
+
}
|
|
11
|
+
interface ISelectFieldProps {
|
|
12
|
+
label?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
validationError?: (name?: string) => string | undefined;
|
|
16
|
+
onChange?: ChangeEventHandler<HTMLSelectElement>;
|
|
17
|
+
onBlur?: ChangeEventHandler<HTMLSelectElement>;
|
|
18
|
+
value?: string;
|
|
19
|
+
autoFocus?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
noLabel?: boolean;
|
|
24
|
+
options?: ILabelValuePair[] | null;
|
|
25
|
+
align?: "left" | "center" | "right";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const b = bem("select-field");
|
|
29
|
+
export const SelectField = forwardRef<HTMLSelectElement, ISelectFieldProps>(({value,
|
|
30
|
+
onChange, noLabel = false, onBlur, name, className, autoFocus = false,
|
|
31
|
+
disabled = false, label, error, options, align = "right" }: ISelectFieldProps, ref) => {
|
|
32
|
+
|
|
33
|
+
return (<div className={clsx(b(), className)}>
|
|
34
|
+
<div className={b("wrapper")}>
|
|
35
|
+
{!noLabel && <label
|
|
36
|
+
htmlFor={name} className={clsx(b("label"), b("label", align))}>{label}:</label>}
|
|
37
|
+
<select
|
|
38
|
+
id={name}
|
|
39
|
+
name={name}
|
|
40
|
+
className={b("input")}
|
|
41
|
+
disabled={disabled}
|
|
42
|
+
value={value}
|
|
43
|
+
onChange={onChange}
|
|
44
|
+
onBlur={onBlur}
|
|
45
|
+
ref={ref}
|
|
46
|
+
autoFocus={autoFocus}
|
|
47
|
+
autoComplete="on"
|
|
48
|
+
>
|
|
49
|
+
{options && options.map(o => <option value={o.value} key={o.value}>{o.label}</option>)}
|
|
50
|
+
</select>
|
|
51
|
+
</div>
|
|
52
|
+
{error && <div className={b("error-container")}>{formatError(error, label)}</div>}
|
|
53
|
+
</div>)
|
|
54
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./SelectField";
|
|
1
|
+
export * from "./SelectField";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
.r5ui-spacer {
|
|
2
|
-
flex: 1;
|
|
1
|
+
.r5ui-spacer {
|
|
2
|
+
flex: 1;
|
|
3
3
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { bem } from '../../utils/bem';
|
|
2
|
-
import './Spacer.scss'
|
|
3
|
-
|
|
4
|
-
const b = bem("spacer");
|
|
5
|
-
export const Spacer = () => {
|
|
6
|
-
return <span className={b()}/>
|
|
1
|
+
import { bem } from '../../utils/bem';
|
|
2
|
+
import './Spacer.scss'
|
|
3
|
+
|
|
4
|
+
const b = bem("spacer");
|
|
5
|
+
export const Spacer = () => {
|
|
6
|
+
return <span className={b()}/>
|
|
7
7
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
.r5ui-stack-panel {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: row;
|
|
4
|
-
flex-wrap: wrap;
|
|
5
|
-
|
|
6
|
-
&__item {
|
|
7
|
-
margin-bottom: 1rem;
|
|
8
|
-
}
|
|
1
|
+
.r5ui-stack-panel {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
|
|
6
|
+
&__item {
|
|
7
|
+
margin-bottom: 1rem;
|
|
8
|
+
}
|
|
9
9
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { StackPanel } from './StackPanel';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof StackPanel> = {
|
|
5
|
-
title: 'Example/StackPanel',
|
|
6
|
-
component: StackPanel,
|
|
7
|
-
argTypes: {
|
|
8
|
-
backgroundColor: { control: 'color' },
|
|
9
|
-
},
|
|
10
|
-
} as Meta;
|
|
11
|
-
export default meta;
|
|
12
|
-
|
|
13
|
-
type Story = StoryObj<typeof StackPanel>;
|
|
14
|
-
|
|
15
|
-
export const TextStackPanel: Story = {
|
|
16
|
-
render: () => <StackPanel>Test</StackPanel>,
|
|
17
|
-
};
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { StackPanel } from './StackPanel';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof StackPanel> = {
|
|
5
|
+
title: 'Example/StackPanel',
|
|
6
|
+
component: StackPanel,
|
|
7
|
+
argTypes: {
|
|
8
|
+
backgroundColor: { control: 'color' },
|
|
9
|
+
},
|
|
10
|
+
} as Meta;
|
|
11
|
+
export default meta;
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof StackPanel>;
|
|
14
|
+
|
|
15
|
+
export const TextStackPanel: Story = {
|
|
16
|
+
render: () => <StackPanel>Test</StackPanel>,
|
|
17
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { StackPanel } from './StackPanel';
|
|
5
|
-
|
|
6
|
-
describe('StackPanel Component', () => {
|
|
7
|
-
test('renders the button with the correct label', () => {
|
|
8
|
-
render(<StackPanel >Click me</StackPanel>);
|
|
9
|
-
const div = screen.getByRole('StackPanel', { name: /click me/i });
|
|
10
|
-
expect(div).toBeInTheDocument();
|
|
11
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { StackPanel } from './StackPanel';
|
|
5
|
+
|
|
6
|
+
describe('StackPanel Component', () => {
|
|
7
|
+
test('renders the button with the correct label', () => {
|
|
8
|
+
render(<StackPanel >Click me</StackPanel>);
|
|
9
|
+
const div = screen.getByRole('StackPanel', { name: /click me/i });
|
|
10
|
+
expect(div).toBeInTheDocument();
|
|
11
|
+
});
|
|
12
12
|
});
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { FormEvent, ReactNode } from 'react';
|
|
2
|
-
import './StackPanel.scss'
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { bem } from '../../utils/bem';
|
|
5
|
-
|
|
6
|
-
interface StackPanelProps {
|
|
7
|
-
className?: string;
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
}
|
|
10
|
-
const b = bem("stack-panel");
|
|
11
|
-
export const StackPanel = ({children, className}: StackPanelProps) => {
|
|
12
|
-
return (
|
|
13
|
-
<div className={clsx(b(), className)}>
|
|
14
|
-
{children}
|
|
15
|
-
</div>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface StackPanelItemProps {
|
|
20
|
-
className?: string;
|
|
21
|
-
children: ReactNode;
|
|
22
|
-
}
|
|
23
|
-
const StackPanelItem = ({children, className}: StackPanelItemProps) => {
|
|
24
|
-
return (
|
|
25
|
-
<div className={clsx(b("item"), className)}>
|
|
26
|
-
{children}
|
|
27
|
-
</div>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
StackPanel.Item = StackPanelItem;
|
|
1
|
+
import { FormEvent, ReactNode } from 'react';
|
|
2
|
+
import './StackPanel.scss'
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { bem } from '../../utils/bem';
|
|
5
|
+
|
|
6
|
+
interface StackPanelProps {
|
|
7
|
+
className?: string;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
const b = bem("stack-panel");
|
|
11
|
+
export const StackPanel = ({children, className}: StackPanelProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<div className={clsx(b(), className)}>
|
|
14
|
+
{children}
|
|
15
|
+
</div>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface StackPanelItemProps {
|
|
20
|
+
className?: string;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
const StackPanelItem = ({children, className}: StackPanelItemProps) => {
|
|
24
|
+
return (
|
|
25
|
+
<div className={clsx(b("item"), className)}>
|
|
26
|
+
{children}
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
StackPanel.Item = StackPanelItem;
|
|
32
32
|
export default StackPanel
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./StackPanel";
|
|
1
|
+
export * from "./StackPanel";
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
.r5ui-submenu {
|
|
2
|
-
position: relative;
|
|
3
|
-
display: inline-block;
|
|
4
|
-
|
|
5
|
-
&__button {
|
|
6
|
-
border: none;
|
|
7
|
-
background: none;
|
|
8
|
-
margin: 0;
|
|
9
|
-
padding: 0;
|
|
10
|
-
color: $menu_text_color;
|
|
11
|
-
cursor: pointer;
|
|
12
|
-
&:hover {
|
|
13
|
-
text-decoration: underline;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&__indicator {
|
|
18
|
-
margin-left: 1em;
|
|
19
|
-
border: solid $menu_text_color;
|
|
20
|
-
border-width: 0 2px 2px 0;
|
|
21
|
-
display: inline-block;
|
|
22
|
-
padding: 3px;
|
|
23
|
-
transform: rotate(-45deg);
|
|
24
|
-
transition: transform 0.3s ease;
|
|
25
|
-
|
|
26
|
-
&--open {
|
|
27
|
-
transform: rotate(135deg);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&__list {
|
|
32
|
-
position: absolute;
|
|
33
|
-
background-color: $menu_bg_color;
|
|
34
|
-
min-width: 160px;
|
|
35
|
-
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
|
36
|
-
z-index: 1;
|
|
37
|
-
padding: 0;
|
|
38
|
-
margin: 0;
|
|
39
|
-
border-radius: $border_radius;
|
|
40
|
-
list-style-type: none;
|
|
41
|
-
right: 100%;
|
|
42
|
-
top: 0;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&__item {
|
|
46
|
-
color: $menu_text_color;
|
|
47
|
-
padding: 12px 16px;
|
|
48
|
-
text-decoration: none;
|
|
49
|
-
display: block;
|
|
50
|
-
cursor: pointer;
|
|
51
|
-
|
|
52
|
-
&:hover {
|
|
53
|
-
text-decoration: underline;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
.r5ui-submenu {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
|
|
5
|
+
&__button {
|
|
6
|
+
border: none;
|
|
7
|
+
background: none;
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 0;
|
|
10
|
+
color: $menu_text_color;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
&:hover {
|
|
13
|
+
text-decoration: underline;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&__indicator {
|
|
18
|
+
margin-left: 1em;
|
|
19
|
+
border: solid $menu_text_color;
|
|
20
|
+
border-width: 0 2px 2px 0;
|
|
21
|
+
display: inline-block;
|
|
22
|
+
padding: 3px;
|
|
23
|
+
transform: rotate(-45deg);
|
|
24
|
+
transition: transform 0.3s ease;
|
|
25
|
+
|
|
26
|
+
&--open {
|
|
27
|
+
transform: rotate(135deg);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&__list {
|
|
32
|
+
position: absolute;
|
|
33
|
+
background-color: $menu_bg_color;
|
|
34
|
+
min-width: 160px;
|
|
35
|
+
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
|
36
|
+
z-index: 1;
|
|
37
|
+
padding: 0;
|
|
38
|
+
margin: 0;
|
|
39
|
+
border-radius: $border_radius;
|
|
40
|
+
list-style-type: none;
|
|
41
|
+
right: 100%;
|
|
42
|
+
top: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&__item {
|
|
46
|
+
color: $menu_text_color;
|
|
47
|
+
padding: 12px 16px;
|
|
48
|
+
text-decoration: none;
|
|
49
|
+
display: block;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
|
|
52
|
+
&:hover {
|
|
53
|
+
text-decoration: underline;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
56
|
}
|