@react-ui-org/react-ui 0.64.0 → 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/scripts/write-lockfile-hash.sh +6 -0
- 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
package/src/components/Modal/_helpers/{dialogOnKeyDownHandler.js → dialogOnKeyDownHandler.ts}
RENAMED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
KeyboardEvent,
|
|
3
|
+
RefObject,
|
|
4
|
+
} from 'react';
|
|
5
|
+
|
|
6
|
+
// Declared locally so that consumers compiling the sources directly do not need `@types/node`.
|
|
7
|
+
// Bundlers replace `process.env.NODE_ENV` at build time.
|
|
8
|
+
declare const process: {
|
|
9
|
+
env: {
|
|
10
|
+
NODE_ENV?: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
1
14
|
// Disable coverage for the following function
|
|
2
15
|
/* istanbul ignore next */
|
|
3
16
|
|
|
@@ -19,11 +32,11 @@
|
|
|
19
32
|
* @param allowPrimaryActionOnEnterKey
|
|
20
33
|
*/
|
|
21
34
|
export const dialogOnKeyDownHandler = (
|
|
22
|
-
e
|
|
23
|
-
closeButtonRef,
|
|
24
|
-
primaryButtonRef,
|
|
25
|
-
allowCloseOnEscapeKey,
|
|
26
|
-
allowPrimaryActionOnEnterKey,
|
|
35
|
+
e: KeyboardEvent<HTMLDialogElement>,
|
|
36
|
+
closeButtonRef: RefObject<HTMLButtonElement | null> | undefined,
|
|
37
|
+
primaryButtonRef: RefObject<HTMLButtonElement | null> | undefined,
|
|
38
|
+
allowCloseOnEscapeKey: boolean,
|
|
39
|
+
allowPrimaryActionOnEnterKey: boolean,
|
|
27
40
|
) => {
|
|
28
41
|
if (e.key === 'Escape') {
|
|
29
42
|
// Prevent closing the modal using the Escape key when one of the following conditions is met:
|
|
@@ -55,7 +68,7 @@ export const dialogOnKeyDownHandler = (
|
|
|
55
68
|
&& primaryButtonRef?.current != null
|
|
56
69
|
&& primaryButtonRef?.current?.disabled === false
|
|
57
70
|
&& allowPrimaryActionOnEnterKey
|
|
58
|
-
&& ['INPUT', 'SELECT'].includes(e.target.nodeName)
|
|
71
|
+
&& ['INPUT', 'SELECT'].includes((e.target as HTMLElement).nodeName)
|
|
59
72
|
) {
|
|
60
73
|
primaryButtonRef.current.click();
|
|
61
74
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CssModuleClasses } from '../../../types';
|
|
2
|
+
import type { ModalJustify } from '../Modal.types';
|
|
3
|
+
|
|
4
|
+
export const getJustifyClassName = (styles: CssModuleClasses, value?: ModalJustify) => {
|
|
2
5
|
if (value === 'start') {
|
|
3
6
|
return styles.isRootJustifiedToStart;
|
|
4
7
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CssModuleClasses } from '../../../types';
|
|
2
|
+
import type { ModalPosition } from '../Modal.types';
|
|
3
|
+
|
|
4
|
+
export const getPositionClassName = (styles: CssModuleClasses, modalPosition?: ModalPosition) => {
|
|
5
|
+
if (modalPosition === 'top') {
|
|
6
|
+
return styles.isRootPositionTop;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return null;
|
|
10
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CssModuleClasses } from '../../../types';
|
|
2
|
+
import type { ModalScrolling } from '../Modal.types';
|
|
3
|
+
|
|
4
|
+
export const getScrollingClassName = (styles: CssModuleClasses, type?: ModalScrolling) => {
|
|
5
|
+
if (type === 'auto') {
|
|
6
|
+
return styles.isRootScrollingAuto;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (type === 'custom') {
|
|
10
|
+
return styles.isRootScrollingCustom;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CssModuleClasses } from '../../../types';
|
|
2
|
+
import type { ModalSize } from '../Modal.types';
|
|
3
|
+
|
|
4
|
+
export const getSizeClassName = (styles: CssModuleClasses, modalSize?: ModalSize) => {
|
|
2
5
|
if (modalSize === 'small') {
|
|
3
6
|
return styles.isRootSizeSmall;
|
|
4
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
+
import type { RefObject } from 'react';
|
|
2
3
|
|
|
3
4
|
export const useModalFocus = (
|
|
4
|
-
autoFocus,
|
|
5
|
-
dialogRef
|
|
6
|
-
primaryButtonRef,
|
|
5
|
+
autoFocus: boolean,
|
|
6
|
+
dialogRef: RefObject<HTMLDialogElement | null>,
|
|
7
|
+
primaryButtonRef: RefObject<HTMLButtonElement | null> | undefined,
|
|
7
8
|
) => {
|
|
8
9
|
useEffect(
|
|
9
10
|
() => {
|
|
@@ -21,7 +22,9 @@ export const useModalFocus = (
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const childrenFocusableElements = Array.from(
|
|
24
|
-
dialogElement.querySelectorAll(
|
|
25
|
+
dialogElement.querySelectorAll<HTMLElement>(
|
|
26
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',
|
|
27
|
+
),
|
|
25
28
|
);
|
|
26
29
|
|
|
27
30
|
const firstFocusableElement = childrenFocusableElements[0];
|
|
@@ -33,7 +36,8 @@ export const useModalFocus = (
|
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
const firstFormFieldEl = childrenFocusableElements.find(
|
|
36
|
-
(element) => ['INPUT', 'TEXTAREA', 'SELECT'].includes(element.nodeName)
|
|
39
|
+
(element) => ['INPUT', 'TEXTAREA', 'SELECT'].includes(element.nodeName)
|
|
40
|
+
&& !(element as HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement).disabled,
|
|
37
41
|
);
|
|
38
42
|
|
|
39
43
|
if (firstFormFieldEl) {
|
package/src/components/Modal/_hooks/{useModalScrollPrevention.js → useModalScrollPrevention.ts}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useLayoutEffect } from 'react';
|
|
2
|
+
import type { ModalScrollPrevention } from '../Modal.types';
|
|
2
3
|
|
|
3
|
-
export const useModalScrollPrevention = (preventScrollUnderneath) => {
|
|
4
|
+
export const useModalScrollPrevention = (preventScrollUnderneath: ModalScrollPrevention) => {
|
|
4
5
|
useLayoutEffect(
|
|
5
6
|
() => {
|
|
6
7
|
if (preventScrollUnderneath === 'off') {
|
|
@@ -14,6 +15,8 @@ export const useModalScrollPrevention = (preventScrollUnderneath) => {
|
|
|
14
15
|
const prevOverflow = scrollableElement.style.overflow;
|
|
15
16
|
const prevPaddingRight = scrollableElement.style.paddingRight;
|
|
16
17
|
|
|
18
|
+
// The element is a DOM node owned by the consumer, mutating its styles is the purpose of this hook.
|
|
19
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
17
20
|
scrollableElement.style.overflow = 'hidden';
|
|
18
21
|
|
|
19
22
|
if (Number.isNaN(parseInt(prevPaddingRight, 10))) {
|
|
@@ -5,3 +5,17 @@ export { default as ModalContent } from './ModalContent';
|
|
|
5
5
|
export { default as ModalHeader } from './ModalHeader';
|
|
6
6
|
export { default as ModalFooter } from './ModalFooter';
|
|
7
7
|
export { default as ModalTitle } from './ModalTitle';
|
|
8
|
+
export type {
|
|
9
|
+
ModalBodyProps,
|
|
10
|
+
ModalCloseButtonProps,
|
|
11
|
+
ModalContentProps,
|
|
12
|
+
ModalFooterProps,
|
|
13
|
+
ModalHeaderProps,
|
|
14
|
+
ModalJustify,
|
|
15
|
+
ModalPosition,
|
|
16
|
+
ModalProps,
|
|
17
|
+
ModalScrolling,
|
|
18
|
+
ModalScrollPrevention,
|
|
19
|
+
ModalSize,
|
|
20
|
+
ModalTitleProps,
|
|
21
|
+
} from './Modal.types';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import React 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 styles from './Paper.module.scss';
|
|
6
|
+
import type { PaperProps } from './Paper.types';
|
|
7
7
|
|
|
8
|
-
export const Paper = ({
|
|
8
|
+
export const Paper: React.FunctionComponent<PaperProps> = ({
|
|
9
9
|
children,
|
|
10
|
-
muted,
|
|
11
|
-
raised,
|
|
10
|
+
muted = false,
|
|
11
|
+
raised = false,
|
|
12
12
|
...restProps
|
|
13
|
-
}) => (
|
|
13
|
+
}: PaperProps) => (
|
|
14
14
|
<div
|
|
15
15
|
{...transferProps(restProps)}
|
|
16
16
|
className={classNames(
|
|
@@ -23,26 +23,6 @@ export const Paper = ({
|
|
|
23
23
|
</div>
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
muted: false,
|
|
28
|
-
raised: false,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
Paper.propTypes = {
|
|
32
|
-
/**
|
|
33
|
-
* Content to be placed onto Paper.
|
|
34
|
-
*/
|
|
35
|
-
children: PropTypes.node.isRequired,
|
|
36
|
-
/**
|
|
37
|
-
* Visually suppress Paper.
|
|
38
|
-
*/
|
|
39
|
-
muted: PropTypes.bool,
|
|
40
|
-
/**
|
|
41
|
-
* Add shadow to pull the Paper above surface.
|
|
42
|
-
*/
|
|
43
|
-
raised: PropTypes.bool,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const PaperWithGlobalProps = withGlobalProps(Paper, 'Paper');
|
|
26
|
+
export const PaperWithGlobalProps = withGlobalProps<PaperProps, never>(Paper, 'Paper');
|
|
47
27
|
|
|
48
28
|
export default PaperWithGlobalProps;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HTMLAttributes,
|
|
3
|
+
ReactNode,
|
|
4
|
+
} from 'react';
|
|
5
|
+
|
|
6
|
+
export type PaperProps = HTMLAttributes<HTMLDivElement> & {
|
|
7
|
+
/**
|
|
8
|
+
* Content to be placed onto Paper.
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Visually suppress Paper.
|
|
13
|
+
*/
|
|
14
|
+
muted?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Add shadow to pull the Paper above surface.
|
|
17
|
+
*/
|
|
18
|
+
raised?: boolean;
|
|
19
|
+
};
|
|
@@ -22,9 +22,8 @@ See [API](#api) for all available options.
|
|
|
22
22
|
|
|
23
23
|
## General Guidelines
|
|
24
24
|
|
|
25
|
-
- Paper is **designed for non-white background.** You may want to
|
|
26
|
-
[raised variant](#raised-paper)
|
|
27
|
-
the default appearance to make it stand out on white background.
|
|
25
|
+
- Paper is **designed for non-white background.** You may want to use its
|
|
26
|
+
[raised variant](#raised-paper) to make it stand out on white background.
|
|
28
27
|
|
|
29
28
|
- **Paper, or Card?** Paper is a basic surface to put content on. However,
|
|
30
29
|
there is also the [Card](/components/Card) component. While Paper is
|
|
@@ -67,7 +66,7 @@ helps to improve its accessibility.
|
|
|
67
66
|
|
|
68
67
|
## API
|
|
69
68
|
|
|
70
|
-
<docoff-react-props src="/components/Paper/Paper.
|
|
69
|
+
<docoff-react-props src="/components/Paper/Paper.tsx" name="Paper"></docoff-react-props>
|
|
71
70
|
|
|
72
71
|
## Theming
|
|
73
72
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { transferProps } from '../../helpers/transferProps';
|
|
4
|
+
import { classNames } from '../../helpers/classNames';
|
|
5
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
|
6
|
+
import cleanPlacementStyle from './_helpers/cleanPlacementStyle';
|
|
7
|
+
import getRootSideClassName from './_helpers/getRootSideClassName';
|
|
8
|
+
import getRootAlignmentClassName from './_helpers/getRootAlignmentClassName';
|
|
9
|
+
import styles from './Popover.module.scss';
|
|
10
|
+
import type { PopoverProps } from './Popover.types';
|
|
11
|
+
|
|
12
|
+
export const Popover = React.forwardRef<HTMLDivElement, PopoverProps>(({
|
|
13
|
+
placement = 'bottom',
|
|
14
|
+
children,
|
|
15
|
+
placementStyle,
|
|
16
|
+
popoverTargetId,
|
|
17
|
+
portalId,
|
|
18
|
+
...restProps
|
|
19
|
+
}, ref) => {
|
|
20
|
+
const PopoverEl = (
|
|
21
|
+
<>
|
|
22
|
+
{/**
|
|
23
|
+
* This hack is needed because the default behavior of the Popover API is to place the popover into a
|
|
24
|
+
* top-layer. It is currently not possible to position an element in the top-layer relative to a normal element.
|
|
25
|
+
* This will create a hidden browser popover, then with CSS it will open and close the RUI popover.
|
|
26
|
+
*/}
|
|
27
|
+
{!!popoverTargetId && (
|
|
28
|
+
<div
|
|
29
|
+
className={styles.helper}
|
|
30
|
+
id={popoverTargetId}
|
|
31
|
+
popover="auto"
|
|
32
|
+
/>
|
|
33
|
+
)}
|
|
34
|
+
<div
|
|
35
|
+
{...transferProps(restProps)}
|
|
36
|
+
className={classNames(
|
|
37
|
+
styles.root,
|
|
38
|
+
ref && styles.isRootControlled,
|
|
39
|
+
popoverTargetId && styles.controlledPopover,
|
|
40
|
+
getRootSideClassName(styles, placement),
|
|
41
|
+
getRootAlignmentClassName(styles, placement),
|
|
42
|
+
)}
|
|
43
|
+
ref={ref}
|
|
44
|
+
style={placementStyle ? cleanPlacementStyle(placementStyle) : undefined}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
<span className={styles.arrow} />
|
|
48
|
+
</div>
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
if (portalId === undefined) {
|
|
53
|
+
return PopoverEl;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return createPortal(PopoverEl, document.getElementById(portalId) as HTMLElement);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const PopoverWithGlobalProps = withGlobalProps<PopoverProps, HTMLDivElement>(Popover, 'Popover');
|
|
60
|
+
|
|
61
|
+
export default PopoverWithGlobalProps;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HTMLAttributes,
|
|
3
|
+
ReactNode,
|
|
4
|
+
} from 'react';
|
|
5
|
+
|
|
6
|
+
export type PopoverPlacement = 'top'
|
|
7
|
+
| 'top-start'
|
|
8
|
+
| 'top-end'
|
|
9
|
+
| 'right'
|
|
10
|
+
| 'right-start'
|
|
11
|
+
| 'right-end'
|
|
12
|
+
| 'bottom'
|
|
13
|
+
| 'bottom-start'
|
|
14
|
+
| 'bottom-end'
|
|
15
|
+
| 'left'
|
|
16
|
+
| 'left-start'
|
|
17
|
+
| 'left-end';
|
|
18
|
+
|
|
19
|
+
export type PopoverPlacementStyle = {
|
|
20
|
+
bottom?: string;
|
|
21
|
+
inset?: string;
|
|
22
|
+
'inset-block-end'?: string;
|
|
23
|
+
'inset-block-start'?: string;
|
|
24
|
+
'inset-inline-end'?: string;
|
|
25
|
+
'inset-inline-start'?: string;
|
|
26
|
+
left?: string;
|
|
27
|
+
position?: string;
|
|
28
|
+
right?: string;
|
|
29
|
+
top?: string;
|
|
30
|
+
'transform-origin'?: string;
|
|
31
|
+
translate?: string;
|
|
32
|
+
visibility?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Props of the `Popover` component.
|
|
37
|
+
*/
|
|
38
|
+
export type PopoverProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
39
|
+
/**
|
|
40
|
+
* Popover content.
|
|
41
|
+
*/
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* Popover placement affects position of the arrow.
|
|
45
|
+
* Compatible with [Floating UI API](https://floating-ui.com/docs/computePosition#placement).
|
|
46
|
+
*/
|
|
47
|
+
placement?: PopoverPlacement;
|
|
48
|
+
/**
|
|
49
|
+
* Used for positioning the popover with a library like Floating UI. It is filtered,
|
|
50
|
+
* then passed to the popover as the `style` prop.
|
|
51
|
+
*/
|
|
52
|
+
placementStyle?: PopoverPlacementStyle;
|
|
53
|
+
/**
|
|
54
|
+
* If set, the popover will become controlled, meaning it will be hidden by default and will need a trigger to open.
|
|
55
|
+
* This sets the ID of the internal helper element for the popover.
|
|
56
|
+
* Assign the same ID to `popovertarget` of a trigger to make it open and close.
|
|
57
|
+
*/
|
|
58
|
+
popoverTargetId?: string;
|
|
59
|
+
/**
|
|
60
|
+
* If set, popover is rendered in the React Portal with that ID.
|
|
61
|
+
*/
|
|
62
|
+
portalId?: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type PopoverWrapperProps = HTMLAttributes<HTMLElement> & {
|
|
66
|
+
/**
|
|
67
|
+
* Popover reference and the Popover itself.
|
|
68
|
+
*/
|
|
69
|
+
children: ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* HTML tag to render. Can be any valid HTML tag of your choice, usually a
|
|
72
|
+
* [block-level element](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements).
|
|
73
|
+
*/
|
|
74
|
+
tag?: string;
|
|
75
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ElementType } from 'react';
|
|
3
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
|
4
|
+
import { transferProps } from '../../helpers/transferProps';
|
|
5
|
+
import styles from './PopoverWrapper.module.scss';
|
|
6
|
+
import type { PopoverWrapperProps } from './Popover.types';
|
|
7
|
+
|
|
8
|
+
export const PopoverWrapper: React.FunctionComponent<PopoverWrapperProps> = ({
|
|
9
|
+
children,
|
|
10
|
+
tag = 'div',
|
|
11
|
+
...restProps
|
|
12
|
+
}: PopoverWrapperProps) => {
|
|
13
|
+
const Tag = tag as ElementType;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Tag
|
|
17
|
+
{...transferProps(restProps)}
|
|
18
|
+
className={styles.root}
|
|
19
|
+
>
|
|
20
|
+
{children}
|
|
21
|
+
</Tag>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const PopoverWrapperWithContext = withGlobalProps<PopoverWrapperProps, HTMLElement>(PopoverWrapper, 'PopoverWrapper');
|
|
26
|
+
|
|
27
|
+
export default PopoverWrapperWithContext;
|
|
@@ -312,28 +312,17 @@ React.createElement(() => {
|
|
|
312
312
|
});
|
|
313
313
|
```
|
|
314
314
|
|
|
315
|
-
##
|
|
315
|
+
## Scrollable Containers
|
|
316
316
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
317
|
+
When Popover is rendered inside a scrollable container (e.g. an element with
|
|
318
|
+
`overflow: auto`) and its closest positioned parent is the container itself or
|
|
319
|
+
an element inside it, Popover is clipped by the container and scrolls along
|
|
320
|
+
with its content. This is always the case inside
|
|
321
|
+
[ScrollView](/components/ScrollView), and it also applies to Popover wrapped in
|
|
322
|
+
PopoverWrapper.
|
|
321
323
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
globally or scoped to a specific context:
|
|
325
|
-
|
|
326
|
-
```css
|
|
327
|
-
/* Global override */
|
|
328
|
-
:root {
|
|
329
|
-
--rui-Popover__z-index: 1000;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/* Scoped override */
|
|
333
|
-
.my-context {
|
|
334
|
-
--rui-Popover__z-index: 1000;
|
|
335
|
-
}
|
|
336
|
-
```
|
|
324
|
+
If Popover needs to overflow the scrollable container, use Floating UI with the
|
|
325
|
+
`fixed` positioning strategy (see [Advanced Positioning](#advanced-positioning)).
|
|
337
326
|
|
|
338
327
|
## Controlled Popover
|
|
339
328
|
|
|
@@ -389,11 +378,11 @@ which enables [Advanced Positioning](#advanced-positioning).
|
|
|
389
378
|
|
|
390
379
|
## API
|
|
391
380
|
|
|
392
|
-
<docoff-react-props src="/components/Popover/Popover.
|
|
381
|
+
<docoff-react-props src="/components/Popover/Popover.tsx" name="Popover"></docoff-react-props>
|
|
393
382
|
|
|
394
383
|
### PopoverWrapper API
|
|
395
384
|
|
|
396
|
-
<docoff-react-props src="/components/Popover/PopoverWrapper.
|
|
385
|
+
<docoff-react-props src="/components/Popover/PopoverWrapper.tsx" name="PopoverWrapper"></docoff-react-props>
|
|
397
386
|
|
|
398
387
|
## Theming
|
|
399
388
|
|
|
@@ -409,6 +398,29 @@ which enables [Advanced Positioning](#advanced-positioning).
|
|
|
409
398
|
| `--rui-Popover__box-shadow` | Popover box shadow |
|
|
410
399
|
| `--rui-Popover__z-index` | Popover z-index (default: `auto`) |
|
|
411
400
|
|
|
401
|
+
### z-index
|
|
402
|
+
|
|
403
|
+
By default, the Popover's `z-index` is `auto`, which means it participates in
|
|
404
|
+
the stacking context of its nearest positioned ancestor. This works well in most
|
|
405
|
+
cases, but can cause the Popover to appear behind other positioned elements such
|
|
406
|
+
as sticky headers, fixed toolbars, or modals.
|
|
407
|
+
|
|
408
|
+
When that happens, set `--rui-Popover__z-index` to a numeric value high enough
|
|
409
|
+
to place the Popover above the conflicting layer. The override can be applied
|
|
410
|
+
globally or scoped to a specific context:
|
|
411
|
+
|
|
412
|
+
```css
|
|
413
|
+
/* Global override */
|
|
414
|
+
:root {
|
|
415
|
+
--rui-Popover__z-index: 1000;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/* Scoped override */
|
|
419
|
+
.my-context {
|
|
420
|
+
--rui-Popover__z-index: 1000;
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
412
424
|
[div-attributes]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes
|
|
413
425
|
[Floating UI]: https://floating-ui.com/docs/react-dom
|
|
414
426
|
[mdn-inset]: https://developer.mozilla.org/en-US/docs/Web/CSS/inset
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { PopoverPlacementStyle } from '../Popover.types';
|
|
3
|
+
|
|
4
|
+
export default (placementStyle: PopoverPlacementStyle): CSSProperties => {
|
|
2
5
|
const validProps = [
|
|
3
6
|
'position',
|
|
4
7
|
'inset',
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CssModuleClasses } from '../../../types';
|
|
2
|
+
import type { PopoverPlacement } from '../Popover.types';
|
|
3
|
+
|
|
4
|
+
export default (styles: CssModuleClasses, placement: PopoverPlacement) => {
|
|
2
5
|
const alignment = placement.split('-')[1];
|
|
3
6
|
|
|
4
7
|
if (alignment === 'start') {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CssModuleClasses } from '../../../types';
|
|
2
|
+
import type { PopoverPlacement } from '../Popover.types';
|
|
3
|
+
|
|
4
|
+
export default (styles: CssModuleClasses, placement: PopoverPlacement) => {
|
|
2
5
|
const side = placement.split('-')[0];
|
|
3
6
|
|
|
4
7
|
if (side === 'top') {
|