@react-ui-org/react-ui 0.64.1 → 0.65.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 +1928 -0
- package/dist/react-ui.development.css +2916 -2915
- package/dist/react-ui.development.js +2019 -1051
- 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} +4 -1
- 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.tsx +81 -0
- package/src/components/CheckboxField/CheckboxField.types.ts +63 -0
- package/src/components/CheckboxField/README.md +67 -42
- package/src/components/CheckboxField/index.ts +5 -0
- package/src/components/FileInputField/{FileInputField.jsx → FileInputField.tsx} +42 -128
- package/src/components/FileInputField/FileInputField.types.ts +100 -0
- package/src/components/FileInputField/README.md +1 -1
- package/src/components/FileInputField/index.ts +6 -0
- package/src/components/FormLayout/FormLayout.module.scss +1 -1
- 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.jsx → FormLayoutCustomField.tsx} +10 -65
- package/src/components/FormLayout/FormLayoutCustomField.types.ts +59 -0
- package/src/components/FormLayout/FormLayoutCustomFieldContext.ts +4 -0
- package/src/components/FormLayout/README.md +4 -6
- 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 +32 -0
- package/src/components/Grid/index.ts +9 -0
- package/src/components/InputGroup/{InputGroup.jsx → InputGroup.tsx} +25 -89
- package/src/components/InputGroup/InputGroup.types.ts +80 -0
- package/src/components/InputGroup/InputGroupContext.ts +4 -0
- package/src/components/InputGroup/README.md +5 -1
- 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 +85 -45
- package/src/components/Radio/{Radio.jsx → Radio.tsx} +11 -107
- package/src/components/Radio/Radio.types.ts +90 -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 +84 -45
- package/src/components/SelectField/SelectField.tsx +139 -0
- package/src/components/SelectField/SelectField.types.ts +120 -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 +5 -8
- package/src/components/TextArea/TextArea.tsx +95 -0
- package/src/components/TextArea/TextArea.types.ts +75 -0
- package/src/components/TextArea/index.ts +5 -0
- package/src/components/TextField/README.md +5 -7
- package/src/components/TextField/TextField.tsx +112 -0
- package/src/components/TextField/TextField.types.ts +94 -0
- package/src/components/TextField/index.ts +6 -0
- package/src/components/TextLink/README.md +1 -1
- 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 +67 -42
- package/src/components/Toggle/Toggle.tsx +82 -0
- package/src/components/Toggle/Toggle.types.ts +58 -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} +6 -1
- package/src/components/_helpers/{getRootPriorityClassName.js → getRootPriorityClassName.ts} +6 -1
- package/src/components/_helpers/{getRootSizeClassName.js → getRootSizeClassName.ts} +6 -1
- package/src/components/_helpers/{getRootValidationStateClassName.js → getRootValidationStateClassName.ts} +6 -1
- 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/tools/_accessibility.scss +2 -2
- 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/styles.ts +4 -0
- package/src/types/validationStates.ts +1 -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/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/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
|
@@ -269,18 +269,10 @@ React.createElement(() => {
|
|
|
269
269
|
})
|
|
270
270
|
```
|
|
271
271
|
|
|
272
|
-
####
|
|
273
|
-
|
|
274
|
-
All form fields in React UI can be
|
|
275
|
-
[styled](/docs/customize/theming/forms/#required-state)
|
|
276
|
-
to indicate the required state.
|
|
277
|
-
|
|
278
|
-
However, you may find yourself in a situation where a form field is valid in
|
|
279
|
-
both selected and unselected states, for example to turn on or off a feature.
|
|
280
|
-
If your project uses the label color as the primary means to indicate the
|
|
281
|
-
required state of input fields and the usual asterisk `*` is omitted, you may
|
|
282
|
-
want to keep the label color consistent for both states to avoid confusion.
|
|
272
|
+
#### Rendering as Required
|
|
283
273
|
|
|
274
|
+
A form field may be valid in both selected and unselected states, for example
|
|
275
|
+
to turn on or off a feature, while your design still needs it to look required.
|
|
284
276
|
For this edge case, there is the `renderAsRequired` prop:
|
|
285
277
|
|
|
286
278
|
```docoff-react-preview
|
|
@@ -301,40 +293,23 @@ React.createElement(() => {
|
|
|
301
293
|
},
|
|
302
294
|
];
|
|
303
295
|
return (
|
|
304
|
-
|
|
305
|
-
<
|
|
306
|
-
|
|
307
|
-
.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
.
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
</style>
|
|
320
|
-
<div class="example example--themed-form-fields">
|
|
321
|
-
<Radio
|
|
322
|
-
label="This field is optional"
|
|
323
|
-
onChange={(e) => setFruit(e.target.value)}
|
|
324
|
-
options={options}
|
|
325
|
-
value={fruit}
|
|
326
|
-
/>
|
|
327
|
-
<Radio
|
|
328
|
-
label="This field is optional but looks like required"
|
|
329
|
-
onChange={(e) => setFruit(e.target.value)}
|
|
330
|
-
options={options}
|
|
331
|
-
value={fruit}
|
|
332
|
-
renderAsRequired
|
|
333
|
-
/>
|
|
334
|
-
</div>
|
|
335
|
-
</React.Fragment>
|
|
296
|
+
<>
|
|
297
|
+
<Radio
|
|
298
|
+
label="This field is optional"
|
|
299
|
+
onChange={(e) => setFruit(e.target.value)}
|
|
300
|
+
options={options}
|
|
301
|
+
value={fruit}
|
|
302
|
+
/>
|
|
303
|
+
<Radio
|
|
304
|
+
label="This field is optional but looks like required"
|
|
305
|
+
onChange={(e) => setFruit(e.target.value)}
|
|
306
|
+
options={options}
|
|
307
|
+
value={fruit}
|
|
308
|
+
renderAsRequired
|
|
309
|
+
/>
|
|
310
|
+
</>
|
|
336
311
|
);
|
|
337
|
-
})
|
|
312
|
+
});
|
|
338
313
|
```
|
|
339
314
|
|
|
340
315
|
It renders the field as if it was required, but doesn't add the `required`
|
|
@@ -398,7 +373,7 @@ to improve its accessibility.
|
|
|
398
373
|
|
|
399
374
|
## API
|
|
400
375
|
|
|
401
|
-
<docoff-react-props src="/components/Radio/Radio.
|
|
376
|
+
<docoff-react-props src="/components/Radio/Radio.tsx" name="Radio"></docoff-react-props>
|
|
402
377
|
|
|
403
378
|
## Theming
|
|
404
379
|
|
|
@@ -410,6 +385,71 @@ options. On top of that, the following options are available for Radio.
|
|
|
410
385
|
| `--rui-FormField--check__input--radio__border-radius` | Input corner radius |
|
|
411
386
|
| `--rui-FormField--check__input--radio--checked__background-image` | Checked input background image (inline, URL, …) |
|
|
412
387
|
|
|
388
|
+
### Theming the Required State
|
|
389
|
+
|
|
390
|
+
Required fields are indicated by
|
|
391
|
+
[shared theming options](/docs/customize/theming/forms/#required-state).
|
|
392
|
+
|
|
393
|
+
If your project uses the label color as the primary means to indicate the
|
|
394
|
+
required state of input fields and the usual asterisk `*` is omitted, you may
|
|
395
|
+
want to keep the label color consistent for fields that are valid in both
|
|
396
|
+
selected and unselected states. Pair the theming options with the
|
|
397
|
+
[`renderAsRequired`](#rendering-as-required) prop to achieve that:
|
|
398
|
+
|
|
399
|
+
```docoff-react-preview
|
|
400
|
+
React.createElement(() => {
|
|
401
|
+
const [fruit, setFruit] = React.useState('apple');
|
|
402
|
+
const options = [
|
|
403
|
+
{
|
|
404
|
+
label: 'Apple',
|
|
405
|
+
value: 'apple',
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
label: 'Banana',
|
|
409
|
+
value: 'banana',
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
label: 'Grapefruit',
|
|
413
|
+
value: 'grapefruit',
|
|
414
|
+
},
|
|
415
|
+
];
|
|
416
|
+
return (
|
|
417
|
+
<React.Fragment>
|
|
418
|
+
<style>
|
|
419
|
+
{`
|
|
420
|
+
.example {
|
|
421
|
+
display: flex;
|
|
422
|
+
flex-wrap: wrap;
|
|
423
|
+
gap: 1rem 0.5rem;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.example--themed-form-fields {
|
|
427
|
+
--rui-FormField__label__color: var(--rui-color-text-secondary);
|
|
428
|
+
--rui-FormField--required__label__color: var(--rui-color-text-primary);
|
|
429
|
+
--rui-FormField--required__sign: '';
|
|
430
|
+
}
|
|
431
|
+
`}
|
|
432
|
+
</style>
|
|
433
|
+
<div class="example example--themed-form-fields">
|
|
434
|
+
<Radio
|
|
435
|
+
label="This field is optional"
|
|
436
|
+
onChange={(e) => setFruit(e.target.value)}
|
|
437
|
+
options={options}
|
|
438
|
+
value={fruit}
|
|
439
|
+
/>
|
|
440
|
+
<Radio
|
|
441
|
+
label="This field is optional but looks like required"
|
|
442
|
+
onChange={(e) => setFruit(e.target.value)}
|
|
443
|
+
options={options}
|
|
444
|
+
value={fruit}
|
|
445
|
+
renderAsRequired
|
|
446
|
+
/>
|
|
447
|
+
</div>
|
|
448
|
+
</React.Fragment>
|
|
449
|
+
);
|
|
450
|
+
});
|
|
451
|
+
```
|
|
452
|
+
|
|
413
453
|
[accessibility]: https://www.w3.org/WAI/tutorials/forms/grouping/
|
|
414
454
|
[fieldset]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldset
|
|
415
455
|
[nng-radio]: https://www.nngroup.com/articles/checkboxes-vs-radio-buttons/
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import React, { useContext } from 'react';
|
|
3
2
|
import { withGlobalProps } from '../../providers/globalProps';
|
|
4
3
|
import { classNames } from '../../helpers/classNames/classNames';
|
|
5
4
|
import { transferProps } from '../../helpers/transferProps';
|
|
6
5
|
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
|
|
7
6
|
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
|
8
|
-
import { FormLayoutContext } from '../FormLayout';
|
|
7
|
+
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
9
8
|
import styles from './Radio.module.scss';
|
|
9
|
+
import type { RadioProps } from './Radio.types';
|
|
10
10
|
|
|
11
|
-
export const Radio = ({
|
|
12
|
-
disabled,
|
|
11
|
+
export const Radio: React.FunctionComponent<RadioProps> = ({
|
|
12
|
+
disabled = false,
|
|
13
13
|
helpText,
|
|
14
14
|
id,
|
|
15
|
-
isLabelVisible,
|
|
15
|
+
isLabelVisible = true,
|
|
16
16
|
label,
|
|
17
|
-
layout,
|
|
17
|
+
layout = 'vertical',
|
|
18
18
|
options,
|
|
19
|
-
renderAsRequired,
|
|
20
|
-
required,
|
|
19
|
+
renderAsRequired = false,
|
|
20
|
+
required = false,
|
|
21
21
|
validationState,
|
|
22
22
|
validationText,
|
|
23
23
|
value,
|
|
24
24
|
...restProps
|
|
25
|
-
}) => {
|
|
25
|
+
}: RadioProps) => {
|
|
26
26
|
const context = useContext(FormLayoutContext);
|
|
27
27
|
|
|
28
28
|
return (
|
|
@@ -35,7 +35,7 @@ export const Radio = ({
|
|
|
35
35
|
: styles.isRootLayoutVertical,
|
|
36
36
|
disabled && styles.isRootDisabled,
|
|
37
37
|
(renderAsRequired || required) && styles.isRootRequired,
|
|
38
|
-
getRootValidationStateClassName(
|
|
38
|
+
getRootValidationStateClassName(styles, validationState),
|
|
39
39
|
)}
|
|
40
40
|
disabled={disabled}
|
|
41
41
|
id={id}
|
|
@@ -111,102 +111,6 @@ export const Radio = ({
|
|
|
111
111
|
);
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
disabled: false,
|
|
116
|
-
helpText: undefined,
|
|
117
|
-
id: undefined,
|
|
118
|
-
isLabelVisible: true,
|
|
119
|
-
layout: 'vertical',
|
|
120
|
-
renderAsRequired: false,
|
|
121
|
-
required: false,
|
|
122
|
-
validationState: undefined,
|
|
123
|
-
validationText: undefined,
|
|
124
|
-
value: undefined,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
Radio.propTypes = {
|
|
128
|
-
/**
|
|
129
|
-
* If `true`, the input will be disabled.
|
|
130
|
-
*/
|
|
131
|
-
disabled: PropTypes.bool,
|
|
132
|
-
/**
|
|
133
|
-
* Optional help text.
|
|
134
|
-
*/
|
|
135
|
-
helpText: PropTypes.node,
|
|
136
|
-
/**
|
|
137
|
-
* ID of the root HTML element.
|
|
138
|
-
*
|
|
139
|
-
* Also serves as base for ids of nested elements:
|
|
140
|
-
* * `<ID>__label`
|
|
141
|
-
* * `<ID>__displayLabel`
|
|
142
|
-
* * `<ID>__helpText`
|
|
143
|
-
* * `<ID>__validationText`
|
|
144
|
-
*
|
|
145
|
-
* and of individual options (`<input>`):
|
|
146
|
-
* * `<ID>__item__<VALUE>`
|
|
147
|
-
* * `<ID>__item__<VALUE>__label`
|
|
148
|
-
* * `<ID>__item__<VALUE>__labelText`
|
|
149
|
-
*
|
|
150
|
-
* If `key` in the option definition object is set,
|
|
151
|
-
* then `option.key` is used instead of `option.value` in place of `<VALUE>`.
|
|
152
|
-
*/
|
|
153
|
-
id: PropTypes.string,
|
|
154
|
-
/**
|
|
155
|
-
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
|
156
|
-
* technologies).
|
|
157
|
-
*/
|
|
158
|
-
isLabelVisible: PropTypes.bool,
|
|
159
|
-
/**
|
|
160
|
-
* Label of the group of options.
|
|
161
|
-
*/
|
|
162
|
-
label: PropTypes.node.isRequired,
|
|
163
|
-
/**
|
|
164
|
-
* Layout of the field.
|
|
165
|
-
*
|
|
166
|
-
* Ignored if the component is rendered within `FormLayout` component
|
|
167
|
-
* as the value is inherited in such case.
|
|
168
|
-
*/
|
|
169
|
-
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
170
|
-
/**
|
|
171
|
-
* Set of options to be chosen from.
|
|
172
|
-
*
|
|
173
|
-
* For generating unique IDs the `option.value` is normally used. For cases when this is not practical or
|
|
174
|
-
* the `option.value` values are not unique the `option.key` attribute can be set manually.
|
|
175
|
-
*/
|
|
176
|
-
options: PropTypes.arrayOf(PropTypes.shape({
|
|
177
|
-
disabled: PropTypes.bool,
|
|
178
|
-
key: PropTypes.string,
|
|
179
|
-
label: PropTypes.string.isRequired,
|
|
180
|
-
value: PropTypes.oneOfType([
|
|
181
|
-
PropTypes.string,
|
|
182
|
-
PropTypes.number,
|
|
183
|
-
]),
|
|
184
|
-
})).isRequired,
|
|
185
|
-
/**
|
|
186
|
-
* If `true`, the input will be rendered as if it was required.
|
|
187
|
-
*/
|
|
188
|
-
renderAsRequired: PropTypes.bool,
|
|
189
|
-
/**
|
|
190
|
-
* If `true`, the input will be made and rendered as required, regardless of the `renderAsRequired` prop.
|
|
191
|
-
*/
|
|
192
|
-
required: PropTypes.bool,
|
|
193
|
-
/**
|
|
194
|
-
* Alter the field to provide feedback based on validation result.
|
|
195
|
-
*/
|
|
196
|
-
validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
|
|
197
|
-
/**
|
|
198
|
-
* Validation message to be displayed.
|
|
199
|
-
*/
|
|
200
|
-
validationText: PropTypes.node,
|
|
201
|
-
/**
|
|
202
|
-
* Value of the input.
|
|
203
|
-
*/
|
|
204
|
-
value: PropTypes.oneOfType([
|
|
205
|
-
PropTypes.string,
|
|
206
|
-
PropTypes.number,
|
|
207
|
-
]),
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
export const RadioWithGlobalProps = withGlobalProps(Radio, 'Radio');
|
|
114
|
+
export const RadioWithGlobalProps = withGlobalProps<RadioProps, never>(Radio, 'Radio');
|
|
211
115
|
|
|
212
116
|
export default RadioWithGlobalProps;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InputHTMLAttributes,
|
|
3
|
+
ReactNode,
|
|
4
|
+
} from 'react';
|
|
5
|
+
import type {
|
|
6
|
+
Layout,
|
|
7
|
+
ValidationState,
|
|
8
|
+
} from '../../types';
|
|
9
|
+
|
|
10
|
+
export type RadioOption = {
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
key?: string;
|
|
13
|
+
label: string;
|
|
14
|
+
value: string | number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Props of the `Radio` component.
|
|
19
|
+
*/
|
|
20
|
+
export type RadioProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value'> & {
|
|
21
|
+
/**
|
|
22
|
+
* If `true`, the input will be disabled.
|
|
23
|
+
*/
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Optional help text.
|
|
27
|
+
*/
|
|
28
|
+
helpText?: ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* ID of the root HTML element.
|
|
31
|
+
*
|
|
32
|
+
* Also serves as base for ids of nested elements:
|
|
33
|
+
* * `<ID>__label`
|
|
34
|
+
* * `<ID>__displayLabel`
|
|
35
|
+
* * `<ID>__helpText`
|
|
36
|
+
* * `<ID>__validationText`
|
|
37
|
+
*
|
|
38
|
+
* and of individual options (`<input>`):
|
|
39
|
+
* * `<ID>__item__<VALUE>`
|
|
40
|
+
* * `<ID>__item__<VALUE>__label`
|
|
41
|
+
* * `<ID>__item__<VALUE>__labelText`
|
|
42
|
+
*
|
|
43
|
+
* If `key` in the option definition object is set,
|
|
44
|
+
* then `option.key` is used instead of `option.value` in place of `<VALUE>`.
|
|
45
|
+
*/
|
|
46
|
+
id?: string;
|
|
47
|
+
/**
|
|
48
|
+
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
|
49
|
+
* technologies).
|
|
50
|
+
*/
|
|
51
|
+
isLabelVisible?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Label of the group of options.
|
|
54
|
+
*/
|
|
55
|
+
label: ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* Layout of the field.
|
|
58
|
+
*
|
|
59
|
+
* Ignored if the component is rendered within `FormLayout` component
|
|
60
|
+
* as the value is inherited in such case.
|
|
61
|
+
*/
|
|
62
|
+
layout?: Layout;
|
|
63
|
+
/**
|
|
64
|
+
* Set of options to be chosen from.
|
|
65
|
+
*
|
|
66
|
+
* For generating unique IDs the `option.value` is normally used. For cases when this is not practical or
|
|
67
|
+
* the `option.value` values are not unique the `option.key` attribute can be set manually.
|
|
68
|
+
*/
|
|
69
|
+
options: RadioOption[];
|
|
70
|
+
/**
|
|
71
|
+
* If `true`, the input will be rendered as if it was required.
|
|
72
|
+
*/
|
|
73
|
+
renderAsRequired?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* If `true`, the input will be made and rendered as required, regardless of the `renderAsRequired` prop.
|
|
76
|
+
*/
|
|
77
|
+
required?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Alter the field to provide feedback based on validation result.
|
|
80
|
+
*/
|
|
81
|
+
validationState?: ValidationState;
|
|
82
|
+
/**
|
|
83
|
+
* Validation message to be displayed.
|
|
84
|
+
*/
|
|
85
|
+
validationText?: ReactNode;
|
|
86
|
+
/**
|
|
87
|
+
* Value of the input.
|
|
88
|
+
*/
|
|
89
|
+
value?: string | number;
|
|
90
|
+
};
|
|
@@ -498,7 +498,7 @@ If you provide [ref], it is forwarded to the scrolling viewport native HTML
|
|
|
498
498
|
|
|
499
499
|
## API
|
|
500
500
|
|
|
501
|
-
<docoff-react-props src="/components/ScrollView/ScrollView.
|
|
501
|
+
<docoff-react-props src="/components/ScrollView/ScrollView.tsx" name="ScrollView"></docoff-react-props>
|
|
502
502
|
|
|
503
503
|
[div-attributes]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes
|
|
504
504
|
[linear gradients]: https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
//
|
|
24
24
|
// 8. Use the `clip` value for `overflow` to prevent the content from unwanted scrolling on the
|
|
25
25
|
// cross axis during keyboard navigation.
|
|
26
|
+
//
|
|
27
|
+
// 9. Make `.viewport` the containing block of absolutely positioned content (e.g. visually hidden
|
|
28
|
+
// labels). Otherwise such content resolves to `.root`, escapes the scroll container, and
|
|
29
|
+
// enlarges the scrollable area of the parent elements.
|
|
26
30
|
|
|
27
31
|
@use "../../styles/tools/accessibility";
|
|
28
32
|
@use "../../styles/tools/caret";
|
|
@@ -72,6 +76,7 @@ $_arrow-outer-spacing: spacing.of(4);
|
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
.viewport {
|
|
79
|
+
position: relative; // 9.
|
|
75
80
|
z-index: 1; // 2.
|
|
76
81
|
width: 100%;
|
|
77
82
|
scroll-behavior: smooth;
|