@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
|
@@ -146,7 +146,7 @@ React.createElement(() => {
|
|
|
146
146
|
</>
|
|
147
147
|
)}
|
|
148
148
|
onChange={() => setAgree(!agree)}
|
|
149
|
-
|
|
149
|
+
state="valid"
|
|
150
150
|
/>
|
|
151
151
|
<CheckboxField
|
|
152
152
|
checked={agree}
|
|
@@ -158,7 +158,7 @@ React.createElement(() => {
|
|
|
158
158
|
</>
|
|
159
159
|
)}
|
|
160
160
|
onChange={() => setAgree(!agree)}
|
|
161
|
-
|
|
161
|
+
state="warning"
|
|
162
162
|
validationText={(
|
|
163
163
|
<>
|
|
164
164
|
Please wait 10 minutes until we verify your data.
|
|
@@ -178,7 +178,7 @@ React.createElement(() => {
|
|
|
178
178
|
)}
|
|
179
179
|
onChange={() => setAgree(!agree)}
|
|
180
180
|
required
|
|
181
|
-
|
|
181
|
+
state="invalid"
|
|
182
182
|
validationText="You must agree to be able to proceed."
|
|
183
183
|
/>
|
|
184
184
|
</>
|
|
@@ -186,6 +186,28 @@ React.createElement(() => {
|
|
|
186
186
|
});
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
+
### Changed State
|
|
190
|
+
|
|
191
|
+
Changed state highlights fields whose value differs from the saved one, so users
|
|
192
|
+
can review their edits before saving.
|
|
193
|
+
|
|
194
|
+
A field shows one state at a time. When a changed value is also invalid, it's
|
|
195
|
+
up to you to pick the state that matters more to the user.
|
|
196
|
+
|
|
197
|
+
```docoff-react-preview
|
|
198
|
+
React.createElement(() => {
|
|
199
|
+
const [newsletter, setNewsletter] = React.useState(true);
|
|
200
|
+
return (
|
|
201
|
+
<CheckboxField
|
|
202
|
+
checked={newsletter}
|
|
203
|
+
label="Subscribe to newsletter"
|
|
204
|
+
onChange={() => setNewsletter(!newsletter)}
|
|
205
|
+
state="changed"
|
|
206
|
+
/>
|
|
207
|
+
);
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
189
211
|
### Required State
|
|
190
212
|
|
|
191
213
|
The required state indicates that the input is mandatory. Required fields
|
|
@@ -205,18 +227,10 @@ React.createElement(() => {
|
|
|
205
227
|
});
|
|
206
228
|
```
|
|
207
229
|
|
|
208
|
-
####
|
|
209
|
-
|
|
210
|
-
All form fields in React UI can be
|
|
211
|
-
[styled](/docs/customize/theming/forms/#required-state)
|
|
212
|
-
to indicate the required state.
|
|
213
|
-
|
|
214
|
-
However, you may find yourself in a situation where a form field is valid in
|
|
215
|
-
both checked and unchecked states, for example to turn on or off a feature.
|
|
216
|
-
If your project uses the label color as the primary means to indicate the
|
|
217
|
-
required state of input fields and the usual asterisk `*` is omitted, you may
|
|
218
|
-
want to keep the label color consistent for both states to avoid confusion.
|
|
230
|
+
#### Rendering as Required
|
|
219
231
|
|
|
232
|
+
A form field may be valid in both checked and unchecked states, for example to
|
|
233
|
+
turn on or off a feature, while your design still needs it to look required.
|
|
220
234
|
For this edge case, there is the `renderAsRequired` prop:
|
|
221
235
|
|
|
222
236
|
```docoff-react-preview
|
|
@@ -224,36 +238,19 @@ React.createElement(() => {
|
|
|
224
238
|
const [optional, setOptional] = React.useState(false);
|
|
225
239
|
const [renderAsRequired, setRenderAsRequired] = React.useState(false);
|
|
226
240
|
return (
|
|
227
|
-
|
|
228
|
-
<
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
`}
|
|
242
|
-
</style>
|
|
243
|
-
<div class="example example--themed-form-fields">
|
|
244
|
-
<CheckboxField
|
|
245
|
-
checked={optional}
|
|
246
|
-
label="This field is optional"
|
|
247
|
-
onChange={() => setOptional(!optional)}
|
|
248
|
-
/>
|
|
249
|
-
<CheckboxField
|
|
250
|
-
checked={renderAsRequired}
|
|
251
|
-
label="This field is optional but looks like required"
|
|
252
|
-
onChange={() => setRenderAsRequired(!renderAsRequired)}
|
|
253
|
-
renderAsRequired
|
|
254
|
-
/>
|
|
255
|
-
</div>
|
|
256
|
-
</React.Fragment>
|
|
241
|
+
<>
|
|
242
|
+
<CheckboxField
|
|
243
|
+
checked={optional}
|
|
244
|
+
label="This field is optional"
|
|
245
|
+
onChange={() => setOptional(!optional)}
|
|
246
|
+
/>
|
|
247
|
+
<CheckboxField
|
|
248
|
+
checked={renderAsRequired}
|
|
249
|
+
label="This field is optional but looks like required"
|
|
250
|
+
onChange={() => setRenderAsRequired(!renderAsRequired)}
|
|
251
|
+
renderAsRequired
|
|
252
|
+
/>
|
|
253
|
+
</>
|
|
257
254
|
);
|
|
258
255
|
});
|
|
259
256
|
```
|
|
@@ -297,7 +294,7 @@ If you provide [ref], it is forwarded to the native HTML `<input>` element.
|
|
|
297
294
|
|
|
298
295
|
## API
|
|
299
296
|
|
|
300
|
-
<docoff-react-props src="/components/CheckboxField/CheckboxField.
|
|
297
|
+
<docoff-react-props src="/components/CheckboxField/CheckboxField.tsx" name="CheckboxField"></docoff-react-props>
|
|
301
298
|
|
|
302
299
|
## Theming
|
|
303
300
|
|
|
@@ -309,6 +306,56 @@ options. On top of that, the following options are available for CheckboxField.
|
|
|
309
306
|
| `--rui-FormField--check__input--checkbox__border-radius` | Input corner radius |
|
|
310
307
|
| `--rui-FormField--check__input--checkbox--checked__background-image` | Background image of checked input |
|
|
311
308
|
|
|
309
|
+
### Theming the Required State
|
|
310
|
+
|
|
311
|
+
Required fields are indicated by
|
|
312
|
+
[shared theming options](/docs/customize/theming/forms/#required-state).
|
|
313
|
+
|
|
314
|
+
If your project uses the label color as the primary means to indicate the
|
|
315
|
+
required state of input fields and the usual asterisk `*` is omitted, you may
|
|
316
|
+
want to keep the label color consistent for fields that are valid in both
|
|
317
|
+
checked and unchecked states. Pair the theming options with the
|
|
318
|
+
[`renderAsRequired`](#rendering-as-required) prop to achieve that:
|
|
319
|
+
|
|
320
|
+
```docoff-react-preview
|
|
321
|
+
React.createElement(() => {
|
|
322
|
+
const [optional, setOptional] = React.useState(false);
|
|
323
|
+
const [renderAsRequired, setRenderAsRequired] = React.useState(false);
|
|
324
|
+
return (
|
|
325
|
+
<React.Fragment>
|
|
326
|
+
<style>
|
|
327
|
+
{`
|
|
328
|
+
.example {
|
|
329
|
+
display: flex;
|
|
330
|
+
flex-wrap: wrap;
|
|
331
|
+
gap: 1rem 0.5rem;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.example--themed-form-fields {
|
|
335
|
+
--rui-FormField__label__color: var(--rui-color-text-secondary);
|
|
336
|
+
--rui-FormField--required__label__color: var(--rui-color-text-primary);
|
|
337
|
+
--rui-FormField--required__sign: '';
|
|
338
|
+
}
|
|
339
|
+
`}
|
|
340
|
+
</style>
|
|
341
|
+
<div class="example example--themed-form-fields">
|
|
342
|
+
<CheckboxField
|
|
343
|
+
checked={optional}
|
|
344
|
+
label="This field is optional"
|
|
345
|
+
onChange={() => setOptional(!optional)}
|
|
346
|
+
/>
|
|
347
|
+
<CheckboxField
|
|
348
|
+
checked={renderAsRequired}
|
|
349
|
+
label="This field is optional but looks like required"
|
|
350
|
+
onChange={() => setRenderAsRequired(!renderAsRequired)}
|
|
351
|
+
renderAsRequired
|
|
352
|
+
/>
|
|
353
|
+
</div>
|
|
354
|
+
</React.Fragment>
|
|
355
|
+
);
|
|
356
|
+
});
|
|
357
|
+
```
|
|
358
|
+
|
|
312
359
|
[checkbox-attributes]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#additional_attributes
|
|
313
360
|
[React common props]: https://react.dev/reference/react-dom/components/common#common-props
|
|
314
361
|
[ref]: https://reactjs.org/docs/refs-and-the-dom.html
|
|
@@ -100,16 +100,20 @@
|
|
|
100
100
|
cursor: inherit;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
.isRootStateChanged {
|
|
104
|
+
@include variants.state(changed);
|
|
105
|
+
}
|
|
106
|
+
|
|
103
107
|
.isRootStateInvalid {
|
|
104
|
-
@include variants.
|
|
108
|
+
@include variants.state(invalid);
|
|
105
109
|
}
|
|
106
110
|
|
|
107
111
|
.isRootStateValid {
|
|
108
|
-
@include variants.
|
|
112
|
+
@include variants.state(valid);
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
.isRootStateWarning {
|
|
112
|
-
@include variants.
|
|
116
|
+
@include variants.state(warning);
|
|
113
117
|
}
|
|
114
118
|
|
|
115
119
|
// Invisible label
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import React, {
|
|
3
2
|
useCallback,
|
|
4
3
|
useEffect,
|
|
@@ -7,52 +6,57 @@ import React, {
|
|
|
7
6
|
useRef,
|
|
8
7
|
useState,
|
|
9
8
|
} from 'react';
|
|
9
|
+
import type {
|
|
10
|
+
ChangeEvent,
|
|
11
|
+
DragEvent,
|
|
12
|
+
} from 'react';
|
|
10
13
|
import { withGlobalProps } from '../../providers/globalProps';
|
|
11
14
|
import { classNames } from '../../helpers/classNames';
|
|
12
15
|
import { transferProps } from '../../helpers/transferProps';
|
|
13
16
|
import { TranslationsContext } from '../../providers/translations';
|
|
14
17
|
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
|
15
|
-
import {
|
|
18
|
+
import { getRootStateClassName } from '../_helpers/getRootStateClassName';
|
|
16
19
|
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
|
17
|
-
import { InputGroupContext } from '../InputGroup';
|
|
20
|
+
import { InputGroupContext } from '../InputGroup/InputGroupContext';
|
|
18
21
|
import { Text } from '../Text';
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
FormLayoutCustomFieldContext,
|
|
22
|
-
} from '../FormLayout';
|
|
22
|
+
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
23
|
+
import { FormLayoutCustomFieldContext } from '../FormLayout/FormLayoutCustomFieldContext';
|
|
23
24
|
import styles from './FileInputField.module.scss';
|
|
25
|
+
import type {
|
|
26
|
+
FileInputFieldFilesChangedEvent,
|
|
27
|
+
FileInputFieldProps,
|
|
28
|
+
FileInputFieldRef,
|
|
29
|
+
} from './FileInputField.types';
|
|
24
30
|
|
|
25
31
|
/* istanbul ignore file */
|
|
26
32
|
|
|
27
|
-
export const FileInputField = React.forwardRef((
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} = props;
|
|
44
|
-
|
|
33
|
+
export const FileInputField = React.forwardRef<FileInputFieldRef, FileInputFieldProps>(({
|
|
34
|
+
disabled = false,
|
|
35
|
+
fullWidth = false,
|
|
36
|
+
helpText,
|
|
37
|
+
id,
|
|
38
|
+
isLabelVisible = true,
|
|
39
|
+
label,
|
|
40
|
+
layout = 'vertical',
|
|
41
|
+
multiple = false,
|
|
42
|
+
onFilesChanged,
|
|
43
|
+
required = false,
|
|
44
|
+
size = 'medium',
|
|
45
|
+
state,
|
|
46
|
+
validationText,
|
|
47
|
+
...restProps
|
|
48
|
+
}, ref) => {
|
|
45
49
|
const formLayoutContext = useContext(FormLayoutContext);
|
|
46
50
|
const formLayoutCustomFieldContext = useContext(FormLayoutCustomFieldContext);
|
|
47
51
|
const inputGroupContext = useContext(InputGroupContext);
|
|
48
52
|
const translations = useContext(TranslationsContext);
|
|
49
53
|
|
|
50
|
-
const [selectedFileNames, setSelectedFileNames] = useState([]);
|
|
54
|
+
const [selectedFileNames, setSelectedFileNames] = useState<string[]>([]);
|
|
51
55
|
const [isDragging, setIsDragging] = useState(false);
|
|
52
56
|
|
|
53
|
-
const internalInputRef = useRef();
|
|
57
|
+
const internalInputRef = useRef<HTMLInputElement>(null);
|
|
54
58
|
|
|
55
|
-
const handleReset = useCallback((event) => {
|
|
59
|
+
const handleReset = useCallback((event: FileInputFieldFilesChangedEvent) => {
|
|
56
60
|
if (internalInputRef.current) {
|
|
57
61
|
internalInputRef.current.value = '';
|
|
58
62
|
}
|
|
@@ -70,7 +74,7 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
70
74
|
// The reason of extending object instead of using spread operator is that
|
|
71
75
|
// if it is transformed to the object, it changes the reference of the object
|
|
72
76
|
// and its prototype chain.
|
|
73
|
-
const inputEl = internalInputRef?.current ?? {};
|
|
77
|
+
const inputEl = (internalInputRef?.current ?? {}) as FileInputFieldRef;
|
|
74
78
|
inputEl.resetState = () => {
|
|
75
79
|
handleReset(null);
|
|
76
80
|
};
|
|
@@ -79,7 +83,7 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
79
83
|
[handleReset],
|
|
80
84
|
);
|
|
81
85
|
|
|
82
|
-
const handleFileChange = (files, event) => {
|
|
86
|
+
const handleFileChange = (files: FileList, event: FileInputFieldFilesChangedEvent) => {
|
|
83
87
|
if (files.length === 0) {
|
|
84
88
|
setSelectedFileNames([]);
|
|
85
89
|
onFilesChanged([], event);
|
|
@@ -94,7 +98,7 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
94
98
|
return;
|
|
95
99
|
}
|
|
96
100
|
|
|
97
|
-
const fileNames = [];
|
|
101
|
+
const fileNames: string[] = [];
|
|
98
102
|
|
|
99
103
|
[...files].forEach((file) => {
|
|
100
104
|
fileNames.push(file.name);
|
|
@@ -104,21 +108,21 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
104
108
|
onFilesChanged(files, event);
|
|
105
109
|
};
|
|
106
110
|
|
|
107
|
-
const handleInputChange = (event) => {
|
|
108
|
-
handleFileChange(event.target.files, event);
|
|
111
|
+
const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
112
|
+
handleFileChange(event.target.files as FileList, event);
|
|
109
113
|
};
|
|
110
114
|
|
|
111
115
|
const handleClick = () => {
|
|
112
|
-
internalInputRef?.current
|
|
116
|
+
internalInputRef?.current?.click();
|
|
113
117
|
};
|
|
114
118
|
|
|
115
|
-
const handleDrop = (event) => {
|
|
119
|
+
const handleDrop = (event: DragEvent<HTMLDivElement>) => {
|
|
116
120
|
event.preventDefault();
|
|
117
121
|
handleFileChange(event.dataTransfer.files, event);
|
|
118
122
|
setIsDragging(false);
|
|
119
123
|
};
|
|
120
124
|
|
|
121
|
-
const handleDragOver = (event) => {
|
|
125
|
+
const handleDragOver = (event: DragEvent<HTMLDivElement>) => {
|
|
122
126
|
if (!isDragging) {
|
|
123
127
|
setIsDragging(true);
|
|
124
128
|
}
|
|
@@ -163,10 +167,10 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
163
167
|
isDragging && styles.isRootDragging,
|
|
164
168
|
required && styles.isRootRequired,
|
|
165
169
|
getRootSizeClassName(
|
|
166
|
-
resolveContextOrProp(inputGroupContext && inputGroupContext.size, size),
|
|
167
170
|
styles,
|
|
171
|
+
resolveContextOrProp(inputGroupContext && inputGroupContext.size, size),
|
|
168
172
|
),
|
|
169
|
-
|
|
173
|
+
getRootStateClassName(styles, state),
|
|
170
174
|
)}
|
|
171
175
|
id={`${id}__root`}
|
|
172
176
|
onDragLeave={!disabled ? handleDragLeave : undefined}
|
|
@@ -248,96 +252,6 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
248
252
|
);
|
|
249
253
|
});
|
|
250
254
|
|
|
251
|
-
|
|
252
|
-
disabled: false,
|
|
253
|
-
fullWidth: false,
|
|
254
|
-
helpText: undefined,
|
|
255
|
-
isLabelVisible: true,
|
|
256
|
-
layout: 'vertical',
|
|
257
|
-
multiple: false,
|
|
258
|
-
required: false,
|
|
259
|
-
size: 'medium',
|
|
260
|
-
validationState: undefined,
|
|
261
|
-
validationText: undefined,
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
FileInputField.propTypes = {
|
|
265
|
-
/**
|
|
266
|
-
* If `true`, the input will be disabled.
|
|
267
|
-
*/
|
|
268
|
-
disabled: PropTypes.bool,
|
|
269
|
-
/**
|
|
270
|
-
* If `true`, the field will span the full width of its parent.
|
|
271
|
-
*/
|
|
272
|
-
fullWidth: PropTypes.bool,
|
|
273
|
-
/**
|
|
274
|
-
* Optional help text.
|
|
275
|
-
*
|
|
276
|
-
* Help text is never rendered when the component is placed into `InputGroup`.
|
|
277
|
-
* If a help text is needed, it must be defined on the `InputGroup` component instead.
|
|
278
|
-
*/
|
|
279
|
-
helpText: PropTypes.node,
|
|
280
|
-
/**
|
|
281
|
-
* ID of the `<input>` HTML element.
|
|
282
|
-
*
|
|
283
|
-
* Also serves as base for ids of nested elements:
|
|
284
|
-
* * `<ID>__label`
|
|
285
|
-
* * `<ID>__labelText`
|
|
286
|
-
* * `<ID>__helpText`
|
|
287
|
-
* * `<ID>__validationText`
|
|
288
|
-
*/
|
|
289
|
-
id: PropTypes.string.isRequired,
|
|
290
|
-
/**
|
|
291
|
-
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
|
292
|
-
* technologies).
|
|
293
|
-
*
|
|
294
|
-
* Automatically set to `false` when the component is rendered within `FormLayoutCustomField`
|
|
295
|
-
* component.
|
|
296
|
-
*/
|
|
297
|
-
isLabelVisible: PropTypes.bool,
|
|
298
|
-
/**
|
|
299
|
-
* File input field label.
|
|
300
|
-
*/
|
|
301
|
-
label: PropTypes.node.isRequired,
|
|
302
|
-
/**
|
|
303
|
-
* Layout of the field.
|
|
304
|
-
*
|
|
305
|
-
* Ignored if the component is rendered within `FormLayout` component
|
|
306
|
-
* as the value is inherited in such case.
|
|
307
|
-
*
|
|
308
|
-
*/
|
|
309
|
-
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
310
|
-
/**
|
|
311
|
-
* If `true`, the input will accept multiple files.
|
|
312
|
-
*/
|
|
313
|
-
multiple: PropTypes.bool,
|
|
314
|
-
/**
|
|
315
|
-
* Callback fired when the value of the input changes.
|
|
316
|
-
*/
|
|
317
|
-
onFilesChanged: PropTypes.func.isRequired,
|
|
318
|
-
/**
|
|
319
|
-
* If `true`, the input will be required.
|
|
320
|
-
*/
|
|
321
|
-
required: PropTypes.bool,
|
|
322
|
-
/**
|
|
323
|
-
* Size of the field.
|
|
324
|
-
*
|
|
325
|
-
* Ignored if the component is rendered within `InputGroup` component as the value is inherited in such case.
|
|
326
|
-
*/
|
|
327
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
328
|
-
/**
|
|
329
|
-
* Alter the field to provide feedback based on validation result.
|
|
330
|
-
*/
|
|
331
|
-
validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
|
|
332
|
-
/**
|
|
333
|
-
* Validation message to be displayed.
|
|
334
|
-
*
|
|
335
|
-
* Validation text is never rendered when the component is placed into `InputGroup`.
|
|
336
|
-
* If a validation text is needed, it must be defined on the `InputGroup` component instead.
|
|
337
|
-
*/
|
|
338
|
-
validationText: PropTypes.node,
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
export const FileInputFieldWithGlobalProps = withGlobalProps(FileInputField, 'FileInputField');
|
|
255
|
+
export const FileInputFieldWithGlobalProps = withGlobalProps<FileInputFieldProps, FileInputFieldRef>(FileInputField, 'FileInputField');
|
|
342
256
|
|
|
343
257
|
export default FileInputFieldWithGlobalProps;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
DragEvent,
|
|
4
|
+
InputHTMLAttributes,
|
|
5
|
+
ReactNode,
|
|
6
|
+
} from 'react';
|
|
7
|
+
import type {
|
|
8
|
+
Layout,
|
|
9
|
+
Size,
|
|
10
|
+
State,
|
|
11
|
+
} from '../../types';
|
|
12
|
+
|
|
13
|
+
export type FileInputFieldFilesChangedEvent = ChangeEvent<HTMLInputElement> | DragEvent<HTMLDivElement> | Event | null;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Element exposed through `ref`: the `<input>` element extended with `resetState()`.
|
|
17
|
+
*/
|
|
18
|
+
export type FileInputFieldRef = HTMLInputElement & {
|
|
19
|
+
resetState: () => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Props of the `FileInputField` component.
|
|
24
|
+
*/
|
|
25
|
+
export type FileInputFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size' | 'type'> & {
|
|
26
|
+
/**
|
|
27
|
+
* If `true`, the input will be disabled.
|
|
28
|
+
*/
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* If `true`, the field will span the full width of its parent.
|
|
32
|
+
*/
|
|
33
|
+
fullWidth?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Optional help text.
|
|
36
|
+
*
|
|
37
|
+
* Help text is never rendered when the component is placed into `InputGroup`.
|
|
38
|
+
* If a help text is needed, it must be defined on the `InputGroup` component instead.
|
|
39
|
+
*/
|
|
40
|
+
helpText?: ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* ID of the `<input>` HTML element.
|
|
43
|
+
*
|
|
44
|
+
* Also serves as base for ids of nested elements:
|
|
45
|
+
* * `<ID>__label`
|
|
46
|
+
* * `<ID>__labelText`
|
|
47
|
+
* * `<ID>__helpText`
|
|
48
|
+
* * `<ID>__validationText`
|
|
49
|
+
*/
|
|
50
|
+
id: string;
|
|
51
|
+
/**
|
|
52
|
+
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
|
53
|
+
* technologies).
|
|
54
|
+
*
|
|
55
|
+
* Automatically set to `false` when the component is rendered within `FormLayoutCustomField`
|
|
56
|
+
* component.
|
|
57
|
+
*/
|
|
58
|
+
isLabelVisible?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* File input field label.
|
|
61
|
+
*/
|
|
62
|
+
label: ReactNode;
|
|
63
|
+
/**
|
|
64
|
+
* Layout of the field.
|
|
65
|
+
*
|
|
66
|
+
* Ignored if the component is rendered within `FormLayout` component
|
|
67
|
+
* as the value is inherited in such case.
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
layout?: Layout;
|
|
71
|
+
/**
|
|
72
|
+
* If `true`, the input will accept multiple files.
|
|
73
|
+
*/
|
|
74
|
+
multiple?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Callback fired when the value of the input changes.
|
|
77
|
+
*/
|
|
78
|
+
onFilesChanged: (files: FileList | File[], event: FileInputFieldFilesChangedEvent) => void;
|
|
79
|
+
/**
|
|
80
|
+
* If `true`, the input will be required.
|
|
81
|
+
*/
|
|
82
|
+
required?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Size of the field.
|
|
85
|
+
*
|
|
86
|
+
* Ignored if the component is rendered within `InputGroup` component as the value is inherited in such case.
|
|
87
|
+
*/
|
|
88
|
+
size?: Size;
|
|
89
|
+
/**
|
|
90
|
+
* Alter the field to reflect the state of its data, e.g. a validation result or a change
|
|
91
|
+
* against the saved value.
|
|
92
|
+
*/
|
|
93
|
+
state?: State;
|
|
94
|
+
/**
|
|
95
|
+
* Validation message to be displayed.
|
|
96
|
+
*
|
|
97
|
+
* Validation text is never rendered when the component is placed into `InputGroup`.
|
|
98
|
+
* If a validation text is needed, it must be defined on the `InputGroup` component instead.
|
|
99
|
+
*/
|
|
100
|
+
validationText?: ReactNode;
|
|
101
|
+
};
|
|
@@ -166,21 +166,21 @@ have.
|
|
|
166
166
|
id="my-file-valid"
|
|
167
167
|
label="Attachment"
|
|
168
168
|
onFilesChanged={() => {}}
|
|
169
|
-
|
|
169
|
+
state="valid"
|
|
170
170
|
validationText="Looks good!"
|
|
171
171
|
/>
|
|
172
172
|
<FileInputField
|
|
173
173
|
id="my-file-invalid"
|
|
174
174
|
label="Attachment"
|
|
175
175
|
onFilesChanged={() => {}}
|
|
176
|
-
|
|
176
|
+
state="invalid"
|
|
177
177
|
validationText="Your file is too big. Please select something smaller."
|
|
178
178
|
/>
|
|
179
179
|
<FileInputField
|
|
180
180
|
id="my-file-warning"
|
|
181
181
|
label="Attachment"
|
|
182
182
|
onFilesChanged={() => {}}
|
|
183
|
-
|
|
183
|
+
state="warning"
|
|
184
184
|
validationText={`
|
|
185
185
|
You selected more than 10 files.
|
|
186
186
|
It may take some time before we process them.
|
|
@@ -188,6 +188,23 @@ have.
|
|
|
188
188
|
/>
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
+
### Changed State
|
|
192
|
+
|
|
193
|
+
Changed state highlights fields whose value differs from the saved one, so users
|
|
194
|
+
can review their edits before saving.
|
|
195
|
+
|
|
196
|
+
A field shows one state at a time. When a changed value is also invalid, it's
|
|
197
|
+
up to you to pick the state that matters more to the user.
|
|
198
|
+
|
|
199
|
+
```docoff-react-preview
|
|
200
|
+
<FileInputField
|
|
201
|
+
id="my-file-changed"
|
|
202
|
+
label="Attachment"
|
|
203
|
+
onFilesChanged={() => {}}
|
|
204
|
+
state="changed"
|
|
205
|
+
/>
|
|
206
|
+
```
|
|
207
|
+
|
|
191
208
|
### Disabled State
|
|
192
209
|
|
|
193
210
|
It's possible to disable the whole input.
|
|
@@ -307,7 +324,7 @@ If you provide [ref], it is forwarded to the native HTML `<input>` element.
|
|
|
307
324
|
|
|
308
325
|
## API
|
|
309
326
|
|
|
310
|
-
<docoff-react-props src="/components/FileInputField/FileInputField.
|
|
327
|
+
<docoff-react-props src="/components/FileInputField/FileInputField.tsx" name="FileInputField"></docoff-react-props>
|
|
311
328
|
|
|
312
329
|
## Theming
|
|
313
330
|
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
// 1. Form field label width is defined using custom property. FormLayout variants are created just
|
|
2
2
|
// by adjusting this value, either through a particular modification class, or manually through
|
|
3
|
-
// a prop. Form fields then inherit the layout using
|
|
4
|
-
// possible to turn on automatic size of grid column with labels
|
|
3
|
+
// a prop. Form fields then inherit the layout using `subgrid` (or `display: contents` for
|
|
4
|
+
// `<fieldset>`) which makes it possible to turn on automatic size of grid column with labels,
|
|
5
|
+
// see 4.
|
|
5
6
|
//
|
|
6
7
|
// 2. By default, form field label width is set to a configurable global value.
|
|
7
8
|
//
|
|
8
9
|
// 3. Custom label width can be entered individually through a prop for each use of FormLayout.
|
|
9
10
|
//
|
|
10
11
|
// 4. FormLayout can also automatically adjust the width of column with labels according to the
|
|
11
|
-
// longest label
|
|
12
|
-
// supported only in Firefox so a fallback value is necessary for non-supporting browsers
|
|
13
|
-
// (a global default which can be customised per use).
|
|
14
|
-
// https://github.com/react-ui-org/react-ui/issues/232
|
|
12
|
+
// longest label.
|
|
15
13
|
|
|
16
14
|
@use "../../styles/settings/forms";
|
|
17
15
|
@use "../../styles/tools/breakpoint";
|
|
@@ -29,7 +27,7 @@
|
|
|
29
27
|
.isRootFieldLayoutHorizontal {
|
|
30
28
|
display: grid;
|
|
31
29
|
grid-template-columns: var(--rui-local-field-width);
|
|
32
|
-
|
|
30
|
+
row-gap: theme.$row-gap;
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
.isRootFieldLayoutHorizontal {
|