From 6940731e9cc8815cfa93e94d78484135cca8323d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Dacer?= Date: Thu, 27 Jun 2024 15:34:13 +0200 Subject: [PATCH] Make `transferProps` available to users (#524) --- mkdocs.yml | 1 + src/components/Alert/Alert.jsx | 2 +- src/components/Alert/README.md | 9 ++-- src/components/Badge/Badge.jsx | 2 +- src/components/Badge/README.md | 9 ++-- src/components/Button/Button.jsx | 2 +- src/components/Button/README.md | 9 ++-- src/components/ButtonGroup/ButtonGroup.jsx | 2 +- src/components/ButtonGroup/README.md | 9 ++-- src/components/Card/Card.jsx | 2 +- src/components/Card/CardBody.jsx | 2 +- src/components/Card/CardFooter.jsx | 2 +- src/components/Card/README.md | 9 ++-- .../CheckboxField/CheckboxField.jsx | 2 +- src/components/CheckboxField/README.md | 9 ++-- .../FileInputField/FileInputField.jsx | 2 +- src/components/FileInputField/README.md | 9 ++-- src/components/FormLayout/FormLayout.jsx | 2 +- .../FormLayout/FormLayoutCustomField.jsx | 2 +- src/components/FormLayout/README.md | 9 ++-- src/components/Grid/Grid.jsx | 2 +- src/components/Grid/GridSpan.jsx | 2 +- src/components/Grid/README.md | 10 ++-- src/components/InputGroup/InputGroup.jsx | 2 +- src/components/InputGroup/README.md | 9 ++-- src/components/Modal/Modal.jsx | 2 +- src/components/Modal/ModalBody.jsx | 2 +- src/components/Modal/ModalCloseButton.jsx | 2 +- src/components/Modal/ModalContent.jsx | 2 +- src/components/Modal/ModalFooter.jsx | 2 +- src/components/Modal/ModalHeader.jsx | 6 +-- src/components/Modal/ModalTitle.jsx | 6 +-- src/components/Modal/README.md | 5 +- src/components/Paper/Paper.jsx | 2 +- src/components/Paper/README.md | 9 ++-- src/components/Popover/Popover.jsx | 2 +- src/components/Popover/PopoverWrapper.jsx | 2 +- src/components/Popover/README.md | 9 ++-- src/components/Radio/README.md | 9 ++-- src/components/Radio/Radio.jsx | 2 +- src/components/ScrollView/README.md | 9 ++-- src/components/ScrollView/ScrollView.jsx | 2 +- src/components/SelectField/README.md | 9 ++-- src/components/SelectField/SelectField.jsx | 2 +- src/components/Table/README.md | 9 ++-- src/components/Table/Table.jsx | 2 +- src/components/Tabs/README.md | 5 +- src/components/Tabs/Tabs.jsx | 2 +- src/components/Tabs/TabsItem.jsx | 2 +- src/components/Text/README.md | 5 +- src/components/Text/Text.jsx | 2 +- src/components/TextArea/README.md | 9 ++-- src/components/TextArea/TextArea.jsx | 2 +- src/components/TextField/README.md | 9 ++-- src/components/TextField/TextField.jsx | 2 +- src/components/TextLink/README.md | 9 ++-- src/components/TextLink/TextLink.jsx | 2 +- src/components/Toggle/README.md | 9 ++-- src/components/Toggle/Toggle.jsx | 2 +- src/components/Toolbar/README.md | 9 ++-- src/components/Toolbar/Toolbar.jsx | 2 +- src/components/Toolbar/ToolbarGroup.jsx | 2 +- src/components/Toolbar/ToolbarItem.jsx | 2 +- src/docs/js-helpers/transferProps.md | 46 +++++++++++++++++++ src/index.js | 1 + .../{classNames.js => classNames.test.js} | 0 .../__tests__/transferProps.test.js | 0 .../_helpers => utils}/transferProps.js | 8 ---- 68 files changed, 203 insertions(+), 142 deletions(-) create mode 100644 src/docs/js-helpers/transferProps.md rename src/utils/__tests__/{classNames.js => classNames.test.js} (100%) rename src/{components/_helpers => utils}/__tests__/transferProps.test.js (100%) rename src/{components/_helpers => utils}/transferProps.js (74%) diff --git a/mkdocs.yml b/mkdocs.yml index 5387bfc0..f6b49de7 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -131,6 +131,7 @@ nav: - Typography: 'docs/css-helpers/typography.md' - JS Helpers: - Classnames: 'docs/js-helpers/classnames.md' + - Transferring Props: 'docs/js-helpers/transferProps.md' - Guides: - Customize: - Theming: diff --git a/src/components/Alert/Alert.jsx b/src/components/Alert/Alert.jsx index 33a7b2bd..d07852e2 100644 --- a/src/components/Alert/Alert.jsx +++ b/src/components/Alert/Alert.jsx @@ -4,8 +4,8 @@ import { RUIContext, withGlobalProps, } from '../../provider'; -import { transferProps } from '../_helpers/transferProps'; import { classNames } from '../../utils/classNames'; +import { transferProps } from '../../utils/transferProps'; import { getRootColorClassName } from '../_helpers/getRootColorClassName'; import styles from './Alert.module.scss'; diff --git a/src/components/Alert/README.md b/src/components/Alert/README.md index 34d696f5..5abf8452 100644 --- a/src/components/Alert/README.md +++ b/src/components/Alert/README.md @@ -171,10 +171,11 @@ React.createElement(() => { ## Forwarding HTML Attributes In addition to the options below in the [component's API](#api) section, you -can specify **any HTML attribute you like.** All attributes that don't interfere -with the API of the React component are forwarded to the root `
` HTML -element. This enables making the component interactive and helps to improve -its accessibility. +can specify **any HTML attribute you like.** All attributes that don't +interfere with the API of the React component and that aren't filtered out by +[`transferProps`](/docs/js-helpers/transferProps) helper are forwarded to the +root `
` HTML element. This enables making the component interactive and +helps to improve its accessibility. 👉 For the full list of supported attributes refer to: diff --git a/src/components/Badge/Badge.jsx b/src/components/Badge/Badge.jsx index 53869644..56215029 100644 --- a/src/components/Badge/Badge.jsx +++ b/src/components/Badge/Badge.jsx @@ -1,8 +1,8 @@ import PropTypes from 'prop-types'; import React from 'react'; import { withGlobalProps } from '../../provider'; -import { transferProps } from '../_helpers/transferProps'; import { classNames } from '../../utils/classNames'; +import { transferProps } from '../../utils/transferProps'; import { getRootColorClassName } from '../_helpers/getRootColorClassName'; import styles from './Badge.module.scss'; diff --git a/src/components/Badge/README.md b/src/components/Badge/README.md index 1598f285..84f343d2 100644 --- a/src/components/Badge/README.md +++ b/src/components/Badge/README.md @@ -87,10 +87,11 @@ Medium-emphasis priority to provide additional context in an unobtrusive way. ## Forwarding HTML Attributes In addition to the options below in the [component's API](#api) section, you -can specify **any HTML attribute you like.** All attributes that don't interfere -with the API of the React component are forwarded to the root `
` HTML -element. This enables making the component interactive and helps to improve -its accessibility. +can specify **any HTML attribute you like.** All attributes that don't +interfere with the API of the React component and that aren't filtered out by +[`transferProps`](/docs/js-helpers/transferProps) helper are forwarded to the +root `
` HTML element. This enables making the component interactive and +helps to improve its accessibility. 👉 For the full list of supported attributes refer to: diff --git a/src/components/Button/Button.jsx b/src/components/Button/Button.jsx index b93d455c..cf948894 100644 --- a/src/components/Button/Button.jsx +++ b/src/components/Button/Button.jsx @@ -2,10 +2,10 @@ import PropTypes from 'prop-types'; import React, { useContext } from 'react'; import { withGlobalProps } from '../../provider'; import { classNames } from '../../utils/classNames'; +import { transferProps } from '../../utils/transferProps'; import { getRootColorClassName } from '../_helpers/getRootColorClassName'; import { getRootSizeClassName } from '../_helpers/getRootSizeClassName'; import { resolveContextOrProp } from '../_helpers/resolveContextOrProp'; -import { transferProps } from '../_helpers/transferProps'; import { ButtonGroupContext } from '../ButtonGroup'; import { InputGroupContext } from '../InputGroup/InputGroupContext'; import getRootPriorityClassName from '../_helpers/getRootPriorityClassName'; diff --git a/src/components/Button/README.md b/src/components/Button/README.md index c7c77238..7e43d509 100644 --- a/src/components/Button/README.md +++ b/src/components/Button/README.md @@ -389,10 +389,11 @@ animation is made. ## Forwarding HTML Attributes In addition to the options below in the [component's API](#api) section, you -can specify **any HTML attribute you like.** All attributes that don't interfere -with the API of the React component are forwarded to the root `