@react-ui-org/react-ui 0.64.1 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -6
- package/dist/react-ui.css +16 -16
- package/dist/react-ui.d.ts +1936 -0
- package/dist/react-ui.development.css +3591 -3003
- package/dist/react-ui.development.js +2028 -1060
- package/dist/react-ui.js +1 -1
- package/package.json +74 -70
- package/src/components/Alert/{Alert.jsx → Alert.tsx} +8 -43
- package/src/components/Alert/Alert.types.ts +34 -0
- package/src/components/Alert/README.md +1 -1
- package/src/components/Alert/index.ts +2 -0
- package/src/components/Badge/Badge.tsx +30 -0
- package/src/components/Badge/Badge.types.ts +24 -0
- package/src/components/Badge/README.md +1 -1
- package/src/components/Badge/index.ts +5 -0
- package/src/components/Button/Button.tsx +110 -0
- package/src/components/Button/Button.types.ts +93 -0
- package/src/components/Button/README.md +1 -1
- package/src/components/Button/helpers/{getRootLabelVisibilityClassName.js → getRootLabelVisibilityClassName.ts} +5 -2
- package/src/components/Button/index.ts +6 -0
- package/src/components/ButtonGroup/{ButtonGroup.jsx → ButtonGroup.tsx} +9 -40
- package/src/components/ButtonGroup/ButtonGroup.types.ts +45 -0
- package/src/components/ButtonGroup/ButtonGroupContext.ts +4 -0
- package/src/components/ButtonGroup/README.md +1 -1
- package/src/components/ButtonGroup/{index.js → index.ts} +4 -0
- package/src/components/Card/Card.tsx +33 -0
- package/src/components/Card/Card.types.ts +46 -0
- package/src/components/Card/{CardBody.jsx → CardBody.tsx} +4 -11
- package/src/components/Card/{CardFooter.jsx → CardFooter.tsx} +4 -15
- package/src/components/Card/README.md +6 -7
- package/src/components/Card/{index.js → index.ts} +5 -0
- package/src/components/CheckboxField/CheckboxField.module.scss +7 -3
- package/src/components/CheckboxField/CheckboxField.tsx +81 -0
- package/src/components/CheckboxField/CheckboxField.types.ts +64 -0
- package/src/components/CheckboxField/README.md +92 -45
- package/src/components/CheckboxField/index.ts +5 -0
- package/src/components/FileInputField/FileInputField.module.scss +7 -3
- package/src/components/FileInputField/{FileInputField.jsx → FileInputField.tsx} +43 -129
- package/src/components/FileInputField/FileInputField.types.ts +101 -0
- package/src/components/FileInputField/README.md +21 -4
- package/src/components/FileInputField/index.ts +6 -0
- package/src/components/FormLayout/FormLayout.module.scss +5 -7
- package/src/components/FormLayout/{FormLayout.jsx → FormLayout.tsx} +15 -50
- package/src/components/FormLayout/FormLayout.types.ts +55 -0
- package/src/components/FormLayout/FormLayoutContext.ts +4 -0
- package/src/components/FormLayout/FormLayoutCustomField.module.scss +7 -3
- package/src/components/FormLayout/{FormLayoutCustomField.jsx → FormLayoutCustomField.tsx} +12 -67
- package/src/components/FormLayout/FormLayoutCustomField.types.ts +60 -0
- package/src/components/FormLayout/FormLayoutCustomFieldContext.ts +4 -0
- package/src/components/FormLayout/README.md +6 -15
- package/src/components/FormLayout/index.ts +14 -0
- package/src/components/Grid/Grid.module.scss +1 -1
- package/src/components/Grid/Grid.tsx +50 -0
- package/src/components/Grid/Grid.types.ts +108 -0
- package/src/components/Grid/GridSpan.tsx +36 -0
- package/src/components/Grid/README.md +2 -2
- package/src/components/Grid/_helpers/generateResponsiveCustomProperties.ts +33 -0
- package/src/components/Grid/index.ts +9 -0
- package/src/components/InputGroup/InputGroup.module.scss +7 -3
- package/src/components/InputGroup/{InputGroup.jsx → InputGroup.tsx} +25 -95
- package/src/components/InputGroup/InputGroup.types.ts +80 -0
- package/src/components/InputGroup/InputGroupContext.ts +4 -0
- package/src/components/InputGroup/README.md +40 -8
- package/src/components/InputGroup/{index.js → index.ts} +4 -0
- package/src/components/Modal/Modal.tsx +172 -0
- package/src/components/Modal/Modal.types.ts +181 -0
- package/src/components/Modal/ModalBody.tsx +34 -0
- package/src/components/Modal/{ModalCloseButton.jsx → ModalCloseButton.tsx} +6 -19
- package/src/components/Modal/{ModalContent.jsx → ModalContent.tsx} +4 -15
- package/src/components/Modal/ModalFooter.tsx +27 -0
- package/src/components/Modal/ModalHeader.tsx +27 -0
- package/src/components/Modal/ModalTitle.tsx +29 -0
- package/src/components/Modal/README.md +9 -9
- package/src/components/Modal/_helpers/{dialogOnCancelHandler.js → dialogOnCancelHandler.ts} +11 -1
- package/src/components/Modal/_helpers/{dialogOnClickHandler.js → dialogOnClickHandler.ts} +13 -7
- package/src/components/Modal/_helpers/{dialogOnCloseHandler.js → dialogOnCloseHandler.ts} +11 -1
- package/src/components/Modal/_helpers/{dialogOnKeyDownHandler.js → dialogOnKeyDownHandler.ts} +19 -6
- package/src/components/Modal/_helpers/{getJustifyClassName.js → getJustifyClassName.ts} +4 -1
- package/src/components/Modal/_helpers/getPositionClassName.ts +10 -0
- package/src/components/Modal/_helpers/getScrollingClassName.ts +14 -0
- package/src/components/Modal/_helpers/{getSizeClassName.js → getSizeClassName.ts} +4 -1
- package/src/components/Modal/_hooks/{useModalFocus.js → useModalFocus.ts} +9 -5
- package/src/components/Modal/_hooks/{useModalScrollPrevention.js → useModalScrollPrevention.ts} +4 -1
- package/src/components/Modal/{index.js → index.ts} +14 -0
- package/src/components/Paper/{Paper.jsx → Paper.tsx} +6 -26
- package/src/components/Paper/Paper.types.ts +19 -0
- package/src/components/Paper/README.md +3 -4
- package/src/components/Paper/index.ts +2 -0
- package/src/components/Popover/Popover.module.scss +1 -1
- package/src/components/Popover/Popover.tsx +61 -0
- package/src/components/Popover/Popover.types.ts +75 -0
- package/src/components/Popover/PopoverWrapper.tsx +27 -0
- package/src/components/Popover/README.md +34 -22
- package/src/components/Popover/_helpers/{cleanPlacementStyle.js → cleanPlacementStyle.ts} +4 -1
- package/src/components/Popover/_helpers/{getRootAlignmentClassName.js → getRootAlignmentClassName.ts} +4 -1
- package/src/components/Popover/_helpers/{getRootSideClassName.js → getRootSideClassName.ts} +4 -1
- package/src/components/Popover/index.ts +8 -0
- package/src/components/Radio/README.md +125 -48
- package/src/components/Radio/Radio.module.scss +7 -3
- package/src/components/Radio/Radio.tsx +116 -0
- package/src/components/Radio/Radio.types.ts +91 -0
- package/src/components/Radio/index.ts +5 -0
- package/src/components/ScrollView/README.md +1 -1
- package/src/components/ScrollView/ScrollView.module.scss +5 -0
- package/src/components/ScrollView/{ScrollView.jsx → ScrollView.tsx} +55 -166
- package/src/components/ScrollView/ScrollView.types.ts +121 -0
- package/src/components/ScrollView/_helpers/getElementsPositionDifference.ts +17 -0
- package/src/components/ScrollView/_hooks/{useLoadResizeHook.js → useLoadResizeHook.ts} +14 -3
- package/src/components/ScrollView/_hooks/{useScrollPositionHook.js → useScrollPositionHook.ts} +11 -4
- package/src/components/ScrollView/index.ts +6 -0
- package/src/components/SelectField/README.md +137 -51
- package/src/components/SelectField/SelectField.module.scss +7 -3
- package/src/components/SelectField/SelectField.tsx +139 -0
- package/src/components/SelectField/SelectField.types.ts +121 -0
- package/src/components/SelectField/_components/Option/Option.tsx +19 -0
- package/src/components/SelectField/_components/Option/Option.types.ts +21 -0
- package/src/components/SelectField/_components/Option/index.ts +2 -0
- package/src/components/SelectField/index.ts +7 -0
- package/src/components/Table/README.md +1 -1
- package/src/components/Table/{Table.jsx → Table.tsx} +4 -43
- package/src/components/Table/Table.types.ts +51 -0
- package/src/components/Table/_components/TableBodyCell/TableBodyCell.tsx +20 -0
- package/src/components/Table/_components/TableBodyCell/TableBodyCell.types.ts +20 -0
- package/src/components/Table/_components/TableBodyCell/index.ts +2 -0
- package/src/components/Table/_components/TableHeaderCell/{TableHeaderCell.jsx → TableHeaderCell.tsx} +3 -34
- package/src/components/Table/_components/TableHeaderCell/TableHeaderCell.types.ts +20 -0
- package/src/components/Table/_components/TableHeaderCell/index.ts +2 -0
- package/src/components/Table/index.ts +8 -0
- package/src/components/Tabs/README.md +2 -2
- package/src/components/Tabs/{Tabs.jsx → Tabs.tsx} +4 -20
- package/src/components/Tabs/Tabs.types.ts +19 -0
- package/src/components/Tabs/TabsItem.tsx +49 -0
- package/src/components/Tabs/TabsItem.types.ts +42 -0
- package/src/components/Tabs/index.ts +4 -0
- package/src/components/Text/README.md +1 -1
- package/src/components/Text/Text.module.scss +5 -7
- package/src/components/Text/Text.tsx +46 -0
- package/src/components/Text/Text.types.ts +31 -0
- package/src/components/Text/_helpers/getRootClampClassName.ts +13 -0
- package/src/components/Text/_helpers/getRootHyphensClassName.ts +14 -0
- package/src/components/Text/_helpers/getRootWordWrappingClassName.ts +14 -0
- package/src/components/Text/index.ts +6 -0
- package/src/components/TextArea/README.md +35 -14
- package/src/components/TextArea/TextArea.module.scss +7 -3
- package/src/components/TextArea/TextArea.tsx +95 -0
- package/src/components/TextArea/TextArea.types.ts +76 -0
- package/src/components/TextArea/index.ts +5 -0
- package/src/components/TextField/README.md +35 -13
- package/src/components/TextField/TextField.module.scss +7 -3
- package/src/components/TextField/TextField.tsx +112 -0
- package/src/components/TextField/TextField.types.ts +95 -0
- package/src/components/TextField/index.ts +6 -0
- package/src/components/TextLink/README.md +2 -2
- package/src/components/TextLink/{TextLink.jsx → TextLink.tsx} +4 -15
- package/src/components/TextLink/TextLink.types.ts +12 -0
- package/src/components/TextLink/index.ts +2 -0
- package/src/components/Toggle/README.md +92 -45
- package/src/components/Toggle/Toggle.module.scss +7 -3
- package/src/components/Toggle/Toggle.tsx +82 -0
- package/src/components/Toggle/Toggle.types.ts +59 -0
- package/src/components/Toggle/index.ts +5 -0
- package/src/components/Toolbar/README.md +3 -3
- package/src/components/Toolbar/Toolbar.tsx +41 -0
- package/src/components/Toolbar/Toolbar.types.ts +74 -0
- package/src/components/Toolbar/ToolbarGroup.tsx +38 -0
- package/src/components/Toolbar/{ToolbarItem.jsx → ToolbarItem.tsx} +5 -21
- package/src/components/Toolbar/_helpers/{getAlignClassName.js → getAlignClassName.ts} +8 -1
- package/src/components/Toolbar/_helpers/{getJustifyClassName.js → getJustifyClassName.ts} +4 -1
- package/src/components/Toolbar/{index.js → index.ts} +7 -0
- package/src/components/_helpers/{getRootColorClassName.js → getRootColorClassName.ts} +7 -2
- package/src/components/_helpers/{getRootPriorityClassName.js → getRootPriorityClassName.ts} +7 -2
- package/src/components/_helpers/{getRootSizeClassName.js → getRootSizeClassName.ts} +7 -2
- package/src/components/_helpers/getRootStateClassName.ts +24 -0
- package/src/components/_helpers/resolveContextOrProp.ts +13 -0
- package/src/helpers/classNames/{classNames.js → classNames.ts} +2 -2
- package/src/helpers/isChildrenEmpty/isChildrenEmpty.ts +5 -0
- package/src/helpers/transferProps/transferProps.ts +50 -0
- package/src/helpers/transferProps/transferProps.types.ts +11 -0
- package/src/index.ts +211 -0
- package/src/providers/globalProps/GlobalProps.types.ts +30 -0
- package/src/providers/globalProps/GlobalPropsContext.ts +6 -0
- package/src/providers/globalProps/{GlobalPropsProvider.jsx → GlobalPropsProvider.tsx} +8 -15
- package/src/providers/globalProps/{index.js → index.ts} +4 -0
- package/src/providers/globalProps/withGlobalProps.tsx +36 -0
- package/src/providers/translations/Translations.types.ts +26 -0
- package/src/providers/translations/TranslationsContext.ts +7 -0
- package/src/providers/translations/{TranslationsProvider.jsx → TranslationsProvider.tsx} +8 -15
- package/src/providers/translations/{index.js → index.ts} +5 -0
- package/src/styles/settings/_form-fields.scss +2 -1
- package/src/styles/theme/_form-fields.scss +16 -11
- package/src/styles/theme-constants/_colors.scss +21 -0
- package/src/styles/tools/_accessibility.scss +2 -2
- package/src/styles/tools/form-fields/_box-field-layout.scss +5 -8
- package/src/styles/tools/form-fields/_inline-field-elements.scss +0 -7
- package/src/styles/tools/form-fields/_inline-field-layout.scss +0 -8
- package/src/styles/tools/form-fields/_variants.scss +7 -7
- package/src/theme.scss +37 -12
- package/src/translations/{en.js → en.ts} +3 -1
- package/src/types/breakpoints.ts +1 -0
- package/src/types/colors.ts +7 -0
- package/src/types/index.ts +13 -0
- package/src/types/labelPositions.ts +1 -0
- package/src/types/layouts.ts +1 -0
- package/src/types/modules.d.ts +16 -0
- package/src/types/priorities.ts +1 -0
- package/src/types/sizes.ts +1 -0
- package/src/types/states.ts +1 -0
- package/src/types/styles.ts +4 -0
- package/src/utils/mergeDeep.ts +34 -0
- package/src/utils/mergeDeep.types.ts +4 -0
- package/.claude/agents/code-reviewer.md +0 -122
- package/.claude/rules/code.md +0 -22
- package/.claude/rules/docs.md +0 -35
- package/.claude/rules/frontend.md +0 -72
- package/.claude/rules/git.md +0 -13
- package/.claude/rules/safety-guards.md +0 -9
- package/.claude/rules/styling.md +0 -32
- package/.claude/rules/testing.md +0 -59
- package/.claude/settings.json +0 -32
- package/.claude/skills/commit/SKILL.md +0 -54
- package/.devcontainer/devcontainer.json +0 -23
- package/.eslintrc-ts +0 -40
- package/.mcp.json +0 -8
- package/.nvmrc +0 -1
- package/CLAUDE.md +0 -82
- package/docker-compose.base.yml +0 -93
- package/docker-compose.yml.dist +0 -41
- package/jest.config-ts.js +0 -34
- package/opencode.json +0 -10
- package/playwright-ct.config.ts +0 -68
- package/scripts/auto-start-mkdocs.sh +0 -5
- package/scripts/auto-start-node.sh +0 -33
- package/scripts/mcps/chrome-host/README.md +0 -118
- package/scripts/mcps/chrome-host/cdp_proxy.py +0 -90
- package/scripts/mcps/chrome-host/mcp-entry.sh +0 -33
- package/scripts/mcps/chrome-host/mcp-launch.sh +0 -36
- package/scripts/mcps/chrome-host/mcp-setup.sh +0 -70
- package/scripts/mcps/chrome-host/start-host-chrome.sh +0 -267
- package/setup.sh +0 -107
- package/src/CNAME +0 -1
- package/src/components/Alert/index.js +0 -1
- package/src/components/Badge/Badge.jsx +0 -51
- package/src/components/Badge/index.js +0 -1
- package/src/components/Button/Button.jsx +0 -203
- package/src/components/Button/helpers/getRootPriorityClassName.js +0 -15
- package/src/components/Button/index.js +0 -1
- package/src/components/ButtonGroup/ButtonGroupContext.js +0 -3
- package/src/components/Card/Card.jsx +0 -67
- package/src/components/CheckboxField/CheckboxField.jsx +0 -144
- package/src/components/CheckboxField/index.js +0 -1
- package/src/components/FileInputField/index.js +0 -1
- package/src/components/FormLayout/FormLayoutContext.js +0 -3
- package/src/components/FormLayout/FormLayoutCustomFieldContext.js +0 -3
- package/src/components/FormLayout/index.js +0 -4
- package/src/components/Grid/Grid.jsx +0 -225
- package/src/components/Grid/GridSpan.jsx +0 -88
- package/src/components/Grid/_helpers/generateResponsiveCustomProperties.js +0 -22
- package/src/components/Grid/index.js +0 -2
- package/src/components/InputGroup/InputGroupContext.js +0 -3
- package/src/components/Modal/Modal.jsx +0 -262
- package/src/components/Modal/ModalBody.jsx +0 -60
- package/src/components/Modal/ModalFooter.jsx +0 -42
- package/src/components/Modal/ModalHeader.jsx +0 -42
- package/src/components/Modal/ModalTitle.jsx +0 -42
- package/src/components/Modal/_helpers/getPositionClassName.js +0 -7
- package/src/components/Modal/_helpers/getScrollingClassName.js +0 -11
- package/src/components/Paper/index.js +0 -1
- package/src/components/Popover/Popover.jsx +0 -124
- package/src/components/Popover/PopoverWrapper.jsx +0 -38
- package/src/components/Popover/index.js +0 -2
- package/src/components/Radio/Radio.jsx +0 -212
- package/src/components/Radio/index.js +0 -1
- package/src/components/ScrollView/_helpers/getElementsPositionDifference.js +0 -11
- package/src/components/ScrollView/index.js +0 -1
- package/src/components/SelectField/SelectField.jsx +0 -272
- package/src/components/SelectField/_components/Option/Option.jsx +0 -46
- package/src/components/SelectField/_components/Option/index.js +0 -1
- package/src/components/SelectField/index.js +0 -1
- package/src/components/Table/_components/TableBodyCell/TableBodyCell.jsx +0 -46
- package/src/components/Table/_components/TableBodyCell/index.js +0 -1
- package/src/components/Table/_components/TableHeaderCell/index.js +0 -1
- package/src/components/Table/index.js +0 -1
- package/src/components/Tabs/TabsItem.jsx +0 -91
- package/src/components/Tabs/index.js +0 -2
- package/src/components/Text/Text.jsx +0 -76
- package/src/components/Text/_helpers/getRootClampClassName.js +0 -11
- package/src/components/Text/_helpers/getRootHyphensClassName.js +0 -11
- package/src/components/Text/_helpers/getRootWordWrappingClassName.js +0 -11
- package/src/components/Text/index.js +0 -1
- package/src/components/TextArea/TextArea.jsx +0 -174
- package/src/components/TextArea/index.js +0 -1
- package/src/components/TextField/TextField.jsx +0 -208
- package/src/components/TextField/index.js +0 -1
- package/src/components/TextLink/index.js +0 -1
- package/src/components/Toggle/Toggle.jsx +0 -144
- package/src/components/Toggle/index.js +0 -1
- package/src/components/Toolbar/Toolbar.jsx +0 -76
- package/src/components/Toolbar/ToolbarGroup.jsx +0 -64
- package/src/components/_helpers/getRootValidationStateClassName.js +0 -15
- package/src/components/_helpers/resolveContextOrProp.js +0 -10
- package/src/helpers/isChildrenEmpty/isChildrenEmpty.js +0 -3
- package/src/helpers/transferProps/transferProps.js +0 -38
- package/src/index.js +0 -67
- package/src/providers/globalProps/GlobalPropsContext.jsx +0 -5
- package/src/providers/globalProps/withGlobalProps.jsx +0 -38
- package/src/providers/translations/TranslationsContext.jsx +0 -6
- package/src/utils/mergeDeep.js +0 -28
- package/tsconfig.json +0 -27
- /package/src/helpers/classNames/{index.js → index.ts} +0 -0
- /package/src/helpers/isChildrenEmpty/{index.js → index.ts} +0 -0
- /package/src/helpers/transferProps/{index.js → index.ts} +0 -0
|
@@ -60,7 +60,7 @@ helps to improve its accessibility.
|
|
|
60
60
|
|
|
61
61
|
## API
|
|
62
62
|
|
|
63
|
-
<docoff-react-props src="/components/TextLink/TextLink.
|
|
63
|
+
<docoff-react-props src="/components/TextLink/TextLink.tsx" name="TextLink"></docoff-react-props>
|
|
64
64
|
|
|
65
65
|
## Theming
|
|
66
66
|
|
|
@@ -68,7 +68,7 @@ helps to improve its accessibility.
|
|
|
68
68
|
parent component. This applies for components using
|
|
69
69
|
[Feedback color collection](/docs/foundation/collections#colors) and for
|
|
70
70
|
components in any of the supported
|
|
71
|
-
[
|
|
71
|
+
[states](../../docs/foundation/colors.md#states).
|
|
72
72
|
In such cases, the custom properties marked with an asterisk (\*) are ignored.
|
|
73
73
|
|
|
74
74
|
| Custom Property | Description |
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { withGlobalProps } from '../../providers/globalProps';
|
|
4
3
|
import { transferProps } from '../../helpers/transferProps';
|
|
5
4
|
import styles from './TextLink.module.scss';
|
|
5
|
+
import type { TextLinkProps } from './TextLink.types';
|
|
6
6
|
|
|
7
|
-
export const TextLink = ({
|
|
7
|
+
export const TextLink: React.FunctionComponent<TextLinkProps> = ({
|
|
8
8
|
href,
|
|
9
9
|
label,
|
|
10
10
|
...restProps
|
|
11
|
-
}) => (
|
|
11
|
+
}: TextLinkProps) => (
|
|
12
12
|
<a
|
|
13
13
|
{...transferProps(restProps)}
|
|
14
14
|
className={styles.root}
|
|
@@ -18,17 +18,6 @@ export const TextLink = ({
|
|
|
18
18
|
</a>
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Link's `href` attribute.
|
|
24
|
-
*/
|
|
25
|
-
href: PropTypes.string.isRequired,
|
|
26
|
-
/**
|
|
27
|
-
* Link label.
|
|
28
|
-
*/
|
|
29
|
-
label: PropTypes.string.isRequired,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const LinkWithGlobalProps = withGlobalProps(TextLink, 'TextLink');
|
|
21
|
+
export const LinkWithGlobalProps = withGlobalProps<TextLinkProps, never>(TextLink, 'TextLink');
|
|
33
22
|
|
|
34
23
|
export default LinkWithGlobalProps;
|
|
@@ -131,13 +131,13 @@ React.createElement(() => {
|
|
|
131
131
|
checked={studioQuality}
|
|
132
132
|
label="Listen in studio quality"
|
|
133
133
|
onChange={() => setStudioQuality(!studioQuality)}
|
|
134
|
-
|
|
134
|
+
state="valid"
|
|
135
135
|
/>
|
|
136
136
|
<Toggle
|
|
137
137
|
checked={studioQuality}
|
|
138
138
|
label="Listen in studio quality"
|
|
139
139
|
onChange={() => setStudioQuality(!studioQuality)}
|
|
140
|
-
|
|
140
|
+
state="warning"
|
|
141
141
|
validationText={
|
|
142
142
|
'Looks like you are connected over cellular network. '
|
|
143
143
|
+ 'Please make sure you know what you are doing.'
|
|
@@ -147,7 +147,7 @@ React.createElement(() => {
|
|
|
147
147
|
checked={studioQuality}
|
|
148
148
|
label="Listen in studio quality"
|
|
149
149
|
onChange={() => setStudioQuality(!studioQuality)}
|
|
150
|
-
|
|
150
|
+
state="invalid"
|
|
151
151
|
validationText={(
|
|
152
152
|
<>
|
|
153
153
|
Please
|
|
@@ -163,6 +163,28 @@ React.createElement(() => {
|
|
|
163
163
|
});
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
+
### Changed State
|
|
167
|
+
|
|
168
|
+
Changed state highlights fields whose value differs from the saved one, so users
|
|
169
|
+
can review their edits before saving.
|
|
170
|
+
|
|
171
|
+
A field shows one state at a time. When a changed value is also invalid, it's
|
|
172
|
+
up to you to pick the state that matters more to the user.
|
|
173
|
+
|
|
174
|
+
```docoff-react-preview
|
|
175
|
+
React.createElement(() => {
|
|
176
|
+
const [studioQuality, setStudioQuality] = React.useState(true);
|
|
177
|
+
return (
|
|
178
|
+
<Toggle
|
|
179
|
+
checked={studioQuality}
|
|
180
|
+
label="Listen in studio quality"
|
|
181
|
+
onChange={() => setStudioQuality(!studioQuality)}
|
|
182
|
+
state="changed"
|
|
183
|
+
/>
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
166
188
|
### Required State
|
|
167
189
|
|
|
168
190
|
The required state indicates that the input is mandatory.
|
|
@@ -181,18 +203,10 @@ React.createElement(() => {
|
|
|
181
203
|
});
|
|
182
204
|
```
|
|
183
205
|
|
|
184
|
-
####
|
|
185
|
-
|
|
186
|
-
All form fields in React UI can be
|
|
187
|
-
[styled](/docs/customize/theming/forms/#required-state)
|
|
188
|
-
to indicate the required state.
|
|
189
|
-
|
|
190
|
-
However, you may find yourself in a situation where a form field is valid in
|
|
191
|
-
both checked and unchecked states, for example to turn on or off a feature.
|
|
192
|
-
If your project uses the label color as the primary means to indicate the
|
|
193
|
-
required state of input fields and the usual asterisk `*` is omitted, you may
|
|
194
|
-
want to keep the label color consistent for both states to avoid confusion.
|
|
206
|
+
#### Rendering as Required
|
|
195
207
|
|
|
208
|
+
A form field may be valid in both checked and unchecked states, for example to
|
|
209
|
+
turn on or off a feature, while your design still needs it to look required.
|
|
196
210
|
For this edge case, there is the `renderAsRequired` prop:
|
|
197
211
|
|
|
198
212
|
```docoff-react-preview
|
|
@@ -200,36 +214,19 @@ React.createElement(() => {
|
|
|
200
214
|
const [optional, setOptional] = React.useState(false);
|
|
201
215
|
const [renderAsRequired, setRenderAsRequired] = React.useState(false);
|
|
202
216
|
return (
|
|
203
|
-
|
|
204
|
-
<
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
`}
|
|
218
|
-
</style>
|
|
219
|
-
<div class="example example--themed-form-fields">
|
|
220
|
-
<Toggle
|
|
221
|
-
checked={optional}
|
|
222
|
-
label="This field is optional"
|
|
223
|
-
onChange={() => setOptional(!optional)}
|
|
224
|
-
/>
|
|
225
|
-
<Toggle
|
|
226
|
-
checked={renderAsRequired}
|
|
227
|
-
label="This field is optional but looks like required"
|
|
228
|
-
onChange={() => setRenderAsRequired(!renderAsRequired)}
|
|
229
|
-
renderAsRequired
|
|
230
|
-
/>
|
|
231
|
-
</div>
|
|
232
|
-
</React.Fragment>
|
|
217
|
+
<>
|
|
218
|
+
<Toggle
|
|
219
|
+
checked={optional}
|
|
220
|
+
label="This field is optional"
|
|
221
|
+
onChange={() => setOptional(!optional)}
|
|
222
|
+
/>
|
|
223
|
+
<Toggle
|
|
224
|
+
checked={renderAsRequired}
|
|
225
|
+
label="This field is optional but looks like required"
|
|
226
|
+
onChange={() => setRenderAsRequired(!renderAsRequired)}
|
|
227
|
+
renderAsRequired
|
|
228
|
+
/>
|
|
229
|
+
</>
|
|
233
230
|
);
|
|
234
231
|
});
|
|
235
232
|
```
|
|
@@ -270,7 +267,7 @@ If you provide [ref], it is forwarded to the native HTML `<input>` element.
|
|
|
270
267
|
|
|
271
268
|
## API
|
|
272
269
|
|
|
273
|
-
<docoff-react-props src="/components/Toggle/Toggle.
|
|
270
|
+
<docoff-react-props src="/components/Toggle/Toggle.tsx" name="Toggle"></docoff-react-props>
|
|
274
271
|
|
|
275
272
|
## Theming
|
|
276
273
|
|
|
@@ -287,6 +284,56 @@ options. On top of that, the following options are available for Toggle.
|
|
|
287
284
|
| `--rui-FormField--check__input--toggle--checked__background-image` | Background image of checked input |
|
|
288
285
|
| `--rui-FormField--check__input--toggle--checked__background-position` | Background position of checked input |
|
|
289
286
|
|
|
287
|
+
### Theming the Required State
|
|
288
|
+
|
|
289
|
+
Required fields are indicated by
|
|
290
|
+
[shared theming options](/docs/customize/theming/forms/#required-state).
|
|
291
|
+
|
|
292
|
+
If your project uses the label color as the primary means to indicate the
|
|
293
|
+
required state of input fields and the usual asterisk `*` is omitted, you may
|
|
294
|
+
want to keep the label color consistent for fields that are valid in both
|
|
295
|
+
checked and unchecked states. Pair the theming options with the
|
|
296
|
+
[`renderAsRequired`](#rendering-as-required) prop to achieve that:
|
|
297
|
+
|
|
298
|
+
```docoff-react-preview
|
|
299
|
+
React.createElement(() => {
|
|
300
|
+
const [optional, setOptional] = React.useState(false);
|
|
301
|
+
const [renderAsRequired, setRenderAsRequired] = React.useState(false);
|
|
302
|
+
return (
|
|
303
|
+
<React.Fragment>
|
|
304
|
+
<style>
|
|
305
|
+
{`
|
|
306
|
+
.example {
|
|
307
|
+
display: flex;
|
|
308
|
+
flex-wrap: wrap;
|
|
309
|
+
gap: 1rem 0.5rem;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.example--themed-form-fields {
|
|
313
|
+
--rui-FormField__label__color: var(--rui-color-text-secondary);
|
|
314
|
+
--rui-FormField--required__label__color: var(--rui-color-text-primary);
|
|
315
|
+
--rui-FormField--required__sign: '';
|
|
316
|
+
}
|
|
317
|
+
`}
|
|
318
|
+
</style>
|
|
319
|
+
<div class="example example--themed-form-fields">
|
|
320
|
+
<Toggle
|
|
321
|
+
checked={optional}
|
|
322
|
+
label="This field is optional"
|
|
323
|
+
onChange={() => setOptional(!optional)}
|
|
324
|
+
/>
|
|
325
|
+
<Toggle
|
|
326
|
+
checked={renderAsRequired}
|
|
327
|
+
label="This field is optional but looks like required"
|
|
328
|
+
onChange={() => setRenderAsRequired(!renderAsRequired)}
|
|
329
|
+
renderAsRequired
|
|
330
|
+
/>
|
|
331
|
+
</div>
|
|
332
|
+
</React.Fragment>
|
|
333
|
+
);
|
|
334
|
+
});
|
|
335
|
+
```
|
|
336
|
+
|
|
290
337
|
[checkbox-attributes]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#additional_attributes
|
|
291
338
|
[React common props]: https://react.dev/reference/react-dom/components/common#common-props
|
|
292
339
|
[ref]: https://reactjs.org/docs/refs-and-the-dom.html
|
|
@@ -35,16 +35,20 @@
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// States
|
|
38
|
+
.isRootStateChanged {
|
|
39
|
+
@include variants.state(changed);
|
|
40
|
+
}
|
|
41
|
+
|
|
38
42
|
.isRootStateInvalid {
|
|
39
|
-
@include variants.
|
|
43
|
+
@include variants.state(invalid);
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
.isRootStateValid {
|
|
43
|
-
@include variants.
|
|
47
|
+
@include variants.state(valid);
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
.isRootStateWarning {
|
|
47
|
-
@include variants.
|
|
51
|
+
@include variants.state(warning);
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
// Invisible label
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
|
3
|
+
import { classNames } from '../../helpers/classNames/classNames';
|
|
4
|
+
import { transferProps } from '../../helpers/transferProps';
|
|
5
|
+
import { getRootStateClassName } from '../_helpers/getRootStateClassName';
|
|
6
|
+
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
7
|
+
import styles from './Toggle.module.scss';
|
|
8
|
+
import type { ToggleProps } from './Toggle.types';
|
|
9
|
+
|
|
10
|
+
export const Toggle = React.forwardRef<HTMLInputElement, ToggleProps>(({
|
|
11
|
+
disabled = false,
|
|
12
|
+
helpText,
|
|
13
|
+
id,
|
|
14
|
+
isLabelVisible = true,
|
|
15
|
+
label,
|
|
16
|
+
labelPosition = 'after',
|
|
17
|
+
renderAsRequired = false,
|
|
18
|
+
required = false,
|
|
19
|
+
state,
|
|
20
|
+
validationText,
|
|
21
|
+
...restProps
|
|
22
|
+
}, ref) => {
|
|
23
|
+
const context = useContext(FormLayoutContext);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<label
|
|
27
|
+
className={classNames(
|
|
28
|
+
styles.root,
|
|
29
|
+
context && styles.isRootInFormLayout,
|
|
30
|
+
context && context.layout === 'horizontal' ? styles.isRootLayoutHorizontal : styles.isRootLayoutVertical,
|
|
31
|
+
labelPosition === 'before' && styles.hasRootLabelBefore,
|
|
32
|
+
disabled && styles.isRootDisabled,
|
|
33
|
+
(required || renderAsRequired) && styles.isRootRequired,
|
|
34
|
+
getRootStateClassName(styles, state),
|
|
35
|
+
)}
|
|
36
|
+
htmlFor={id}
|
|
37
|
+
id={id && `${id}__label`}
|
|
38
|
+
>
|
|
39
|
+
<div className={styles.field}>
|
|
40
|
+
<div
|
|
41
|
+
className={classNames(
|
|
42
|
+
styles.label,
|
|
43
|
+
!isLabelVisible && styles.isLabelHidden,
|
|
44
|
+
)}
|
|
45
|
+
id={id && `${id}__labelText`}
|
|
46
|
+
>
|
|
47
|
+
{label}
|
|
48
|
+
</div>
|
|
49
|
+
<input
|
|
50
|
+
{...transferProps(restProps)}
|
|
51
|
+
className={styles.input}
|
|
52
|
+
disabled={disabled}
|
|
53
|
+
id={id}
|
|
54
|
+
name={id}
|
|
55
|
+
ref={ref}
|
|
56
|
+
required={required}
|
|
57
|
+
type="checkbox"
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
{helpText && (
|
|
61
|
+
<div
|
|
62
|
+
className={styles.helpText}
|
|
63
|
+
id={id && `${id}__helpText`}
|
|
64
|
+
>
|
|
65
|
+
{helpText}
|
|
66
|
+
</div>
|
|
67
|
+
)}
|
|
68
|
+
{validationText && (
|
|
69
|
+
<div
|
|
70
|
+
className={styles.validationText}
|
|
71
|
+
id={id && `${id}__validationText`}
|
|
72
|
+
>
|
|
73
|
+
{validationText}
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
</label>
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const ToggleWithGlobalProps = withGlobalProps<ToggleProps, HTMLInputElement>(Toggle, 'Toggle');
|
|
81
|
+
|
|
82
|
+
export default ToggleWithGlobalProps;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InputHTMLAttributes,
|
|
3
|
+
ReactNode,
|
|
4
|
+
} from 'react';
|
|
5
|
+
import type {
|
|
6
|
+
LabelPosition,
|
|
7
|
+
State,
|
|
8
|
+
} from '../../types';
|
|
9
|
+
|
|
10
|
+
export type ToggleLabelPosition = LabelPosition;
|
|
11
|
+
|
|
12
|
+
export type ToggleProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> & {
|
|
13
|
+
/**
|
|
14
|
+
* If `true`, the input will be disabled.
|
|
15
|
+
*/
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Optional help text.
|
|
19
|
+
*/
|
|
20
|
+
helpText?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* ID of the input HTML element. It also serves as a prefix for nested elements:
|
|
23
|
+
* * `<ID>__label`
|
|
24
|
+
* * `<ID>__labelText`
|
|
25
|
+
* * `<ID>__helpText`
|
|
26
|
+
* * `<ID>__validationText`
|
|
27
|
+
*/
|
|
28
|
+
id?: string;
|
|
29
|
+
/**
|
|
30
|
+
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
|
31
|
+
* technologies).
|
|
32
|
+
*/
|
|
33
|
+
isLabelVisible?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Toggle label.
|
|
36
|
+
*/
|
|
37
|
+
label: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Placement of the label relative to the input.
|
|
40
|
+
*/
|
|
41
|
+
labelPosition?: ToggleLabelPosition;
|
|
42
|
+
/**
|
|
43
|
+
* If `true`, the input will be rendered as if it was required.
|
|
44
|
+
*/
|
|
45
|
+
renderAsRequired?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* If `true`, the input will be made and rendered as required, regardless of the `renderAsRequired` prop.
|
|
48
|
+
*/
|
|
49
|
+
required?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Alter the field to reflect the state of its data, e.g. a validation result or a change
|
|
52
|
+
* against the saved value.
|
|
53
|
+
*/
|
|
54
|
+
state?: State;
|
|
55
|
+
/**
|
|
56
|
+
* Validation message to be displayed.
|
|
57
|
+
*/
|
|
58
|
+
validationText?: ReactNode;
|
|
59
|
+
};
|
|
@@ -335,19 +335,19 @@ helps to improve its accessibility.
|
|
|
335
335
|
|
|
336
336
|
## API
|
|
337
337
|
|
|
338
|
-
<docoff-react-props src="/components/Toolbar/Toolbar.
|
|
338
|
+
<docoff-react-props src="/components/Toolbar/Toolbar.tsx" name="Toolbar"></docoff-react-props>
|
|
339
339
|
|
|
340
340
|
### ToolbarGroup API
|
|
341
341
|
|
|
342
342
|
A wrapper for grouping ToolbarItems together.
|
|
343
343
|
|
|
344
|
-
<docoff-react-props src="/components/Toolbar/ToolbarGroup.
|
|
344
|
+
<docoff-react-props src="/components/Toolbar/ToolbarGroup.tsx" name="ToolbarGroup"></docoff-react-props>
|
|
345
345
|
|
|
346
346
|
### ToolbarItem API
|
|
347
347
|
|
|
348
348
|
A wrapper for individual toolbar items.
|
|
349
349
|
|
|
350
|
-
<docoff-react-props src="/components/Toolbar/ToolbarItem.
|
|
350
|
+
<docoff-react-props src="/components/Toolbar/ToolbarItem.tsx" name="ToolbarItem"></docoff-react-props>
|
|
351
351
|
|
|
352
352
|
## Theming
|
|
353
353
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
|
3
|
+
import { classNames } from '../../helpers/classNames/classNames';
|
|
4
|
+
import { transferProps } from '../../helpers/transferProps';
|
|
5
|
+
import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
|
|
6
|
+
import { getAlignClassName } from './_helpers/getAlignClassName';
|
|
7
|
+
import { getJustifyClassName } from './_helpers/getJustifyClassName';
|
|
8
|
+
import styles from './Toolbar.module.scss';
|
|
9
|
+
import type { ToolbarProps } from './Toolbar.types';
|
|
10
|
+
|
|
11
|
+
export const Toolbar: React.FunctionComponent<ToolbarProps> = ({
|
|
12
|
+
align = 'top',
|
|
13
|
+
children,
|
|
14
|
+
dense = false,
|
|
15
|
+
justify = 'start',
|
|
16
|
+
nowrap = false,
|
|
17
|
+
...restProps
|
|
18
|
+
}: ToolbarProps) => {
|
|
19
|
+
if (isChildrenEmpty(children)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div
|
|
25
|
+
{...transferProps(restProps)}
|
|
26
|
+
className={classNames(
|
|
27
|
+
styles.toolbar,
|
|
28
|
+
dense && styles.isToolbarDense,
|
|
29
|
+
nowrap && styles.isToolbarNowrap,
|
|
30
|
+
getAlignClassName(styles, 'toolbar', align),
|
|
31
|
+
getJustifyClassName(styles, justify),
|
|
32
|
+
)}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const ToolbarWithGlobalProps = withGlobalProps<ToolbarProps, never>(Toolbar, 'Toolbar');
|
|
40
|
+
|
|
41
|
+
export default ToolbarWithGlobalProps;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HTMLAttributes,
|
|
3
|
+
ReactNode,
|
|
4
|
+
} from 'react';
|
|
5
|
+
|
|
6
|
+
export type ToolbarAlign = 'top' | 'middle' | 'bottom' | 'baseline';
|
|
7
|
+
|
|
8
|
+
export type ToolbarJustify = 'start' | 'center' | 'end' | 'space-between';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Props of the `Toolbar` component.
|
|
12
|
+
*/
|
|
13
|
+
export type ToolbarProps = HTMLAttributes<HTMLDivElement> & {
|
|
14
|
+
/**
|
|
15
|
+
* Vertical alignment of toolbar items and groups.
|
|
16
|
+
*/
|
|
17
|
+
align?: ToolbarAlign;
|
|
18
|
+
/**
|
|
19
|
+
* Nested elements. Supported types are:
|
|
20
|
+
* * `ToolbarItems`
|
|
21
|
+
* * `ToolbarGroups`
|
|
22
|
+
*
|
|
23
|
+
* If none are provided nothing is rendered.
|
|
24
|
+
*/
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* If `true`, spacing of all toolbar items in the toolbar will be reduced.
|
|
28
|
+
*/
|
|
29
|
+
dense?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Horizontal alignment (distribution) of toolbar items and groups.
|
|
32
|
+
*/
|
|
33
|
+
justify?: ToolbarJustify;
|
|
34
|
+
/**
|
|
35
|
+
* If set, the toolbar will not wrap.
|
|
36
|
+
*/
|
|
37
|
+
nowrap?: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Props of the `ToolbarGroup` component.
|
|
42
|
+
*/
|
|
43
|
+
export type ToolbarGroupProps = HTMLAttributes<HTMLDivElement> & {
|
|
44
|
+
/**
|
|
45
|
+
* Vertical alignment of toolbar items in the group.
|
|
46
|
+
*/
|
|
47
|
+
align?: ToolbarAlign;
|
|
48
|
+
/**
|
|
49
|
+
* Grouped ToolbarItems. If none are provided nothing is rendered.
|
|
50
|
+
*/
|
|
51
|
+
children?: ReactNode;
|
|
52
|
+
/**
|
|
53
|
+
* If `true`, spacing of toolbar items in the group will be reduced.
|
|
54
|
+
*/
|
|
55
|
+
dense?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* If set, the toolbar group will not wrap.
|
|
58
|
+
*/
|
|
59
|
+
nowrap?: boolean;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Props of the `ToolbarItem` component.
|
|
64
|
+
*/
|
|
65
|
+
export type ToolbarItemProps = HTMLAttributes<HTMLDivElement> & {
|
|
66
|
+
/**
|
|
67
|
+
* Content of the toolbar item. If none are provided nothing is rendered.
|
|
68
|
+
*/
|
|
69
|
+
children?: ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* Allow item to grow and shrink if needed.
|
|
72
|
+
*/
|
|
73
|
+
flexible?: boolean;
|
|
74
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
|
3
|
+
import { classNames } from '../../helpers/classNames/classNames';
|
|
4
|
+
import { transferProps } from '../../helpers/transferProps';
|
|
5
|
+
import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
|
|
6
|
+
import { getAlignClassName } from './_helpers/getAlignClassName';
|
|
7
|
+
import styles from './Toolbar.module.scss';
|
|
8
|
+
import type { ToolbarGroupProps } from './Toolbar.types';
|
|
9
|
+
|
|
10
|
+
export const ToolbarGroup: React.FunctionComponent<ToolbarGroupProps> = ({
|
|
11
|
+
align = 'top',
|
|
12
|
+
children,
|
|
13
|
+
dense = false,
|
|
14
|
+
nowrap = false,
|
|
15
|
+
...restProps
|
|
16
|
+
}: ToolbarGroupProps) => {
|
|
17
|
+
if (isChildrenEmpty(children)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
{...transferProps(restProps)}
|
|
24
|
+
className={classNames(
|
|
25
|
+
styles.group,
|
|
26
|
+
dense && styles.isGroupDense,
|
|
27
|
+
nowrap && styles.isGroupNowrap,
|
|
28
|
+
getAlignClassName(styles, 'group', align),
|
|
29
|
+
)}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const ToolbarGroupWithGlobalProps = withGlobalProps<ToolbarGroupProps, never>(ToolbarGroup, 'ToolbarGroup');
|
|
37
|
+
|
|
38
|
+
export default ToolbarGroupWithGlobalProps;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { classNames } from '../../helpers/classNames/classNames';
|
|
4
3
|
import { transferProps } from '../../helpers/transferProps';
|
|
5
4
|
import { withGlobalProps } from '../../providers/globalProps';
|
|
6
5
|
import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
|
|
7
6
|
import styles from './Toolbar.module.scss';
|
|
7
|
+
import type { ToolbarItemProps } from './Toolbar.types';
|
|
8
8
|
|
|
9
|
-
export const ToolbarItem = ({
|
|
9
|
+
export const ToolbarItem: React.FunctionComponent<ToolbarItemProps> = ({
|
|
10
10
|
children,
|
|
11
|
-
flexible,
|
|
11
|
+
flexible = false,
|
|
12
12
|
...restProps
|
|
13
|
-
}) => {
|
|
13
|
+
}: ToolbarItemProps) => {
|
|
14
14
|
if (isChildrenEmpty(children)) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
@@ -28,22 +28,6 @@ export const ToolbarItem = ({
|
|
|
28
28
|
);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
children: undefined,
|
|
33
|
-
flexible: false,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
ToolbarItem.propTypes = {
|
|
37
|
-
/**
|
|
38
|
-
* Content of the toolbar item. If none are provided nothing is rendered.
|
|
39
|
-
*/
|
|
40
|
-
children: PropTypes.node,
|
|
41
|
-
/**
|
|
42
|
-
* Allow item to grow and shrink if needed.
|
|
43
|
-
*/
|
|
44
|
-
flexible: PropTypes.bool,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const ToolbarItemWithGlobalProps = withGlobalProps(ToolbarItem, 'ToolbarItem');
|
|
31
|
+
export const ToolbarItemWithGlobalProps = withGlobalProps<ToolbarItemProps, never>(ToolbarItem, 'ToolbarItem');
|
|
48
32
|
|
|
49
33
|
export default ToolbarItemWithGlobalProps;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CssModuleClasses } from '../../../types';
|
|
2
|
+
import type { ToolbarAlign } from '../Toolbar.types';
|
|
3
|
+
|
|
4
|
+
export const getAlignClassName = (
|
|
5
|
+
styles: CssModuleClasses,
|
|
6
|
+
type: 'toolbar' | 'group',
|
|
7
|
+
value?: ToolbarAlign,
|
|
8
|
+
) => {
|
|
2
9
|
if (value === 'top') {
|
|
3
10
|
if (type === 'group') {
|
|
4
11
|
return styles.isGroupAlignedToTop;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CssModuleClasses } from '../../../types';
|
|
2
|
+
import type { ToolbarJustify } from '../Toolbar.types';
|
|
3
|
+
|
|
4
|
+
export const getJustifyClassName = (styles: CssModuleClasses, value?: ToolbarJustify) => {
|
|
2
5
|
if (value === 'start') {
|
|
3
6
|
return styles.isToolbarJustifiedToStart;
|
|
4
7
|
}
|