@react-ui-org/react-ui 0.55.1 → 0.56.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.nvmrc +1 -1
- package/dist/react-ui.css +16 -21
- package/dist/react-ui.development.css +18 -37
- package/dist/react-ui.development.js +101 -91
- package/dist/react-ui.js +1 -1
- package/package.json +41 -39
- package/src/components/Alert/Alert.jsx +1 -1
- package/src/components/Alert/README.md +5 -4
- package/src/components/Badge/Badge.jsx +1 -1
- package/src/components/Badge/README.md +5 -4
- package/src/components/Button/Button.jsx +1 -1
- package/src/components/Button/README.md +20 -18
- package/src/components/Button/_base.scss +1 -4
- package/src/components/ButtonGroup/ButtonGroup.jsx +1 -1
- package/src/components/ButtonGroup/README.md +5 -4
- package/src/components/Card/Card.jsx +1 -1
- package/src/components/Card/CardBody.jsx +1 -1
- package/src/components/Card/CardFooter.jsx +1 -1
- package/src/components/Card/README.md +5 -4
- package/src/components/CheckboxField/CheckboxField.jsx +2 -2
- package/src/components/CheckboxField/README.md +8 -4
- package/src/components/FileInputField/FileInputField.jsx +3 -3
- package/src/components/FileInputField/README.md +8 -4
- package/src/components/FormLayout/FormLayout.jsx +1 -1
- package/src/components/FormLayout/FormLayoutCustomField.jsx +1 -1
- package/src/components/FormLayout/README.md +5 -4
- package/src/components/Grid/Grid.jsx +1 -1
- package/src/components/Grid/Grid.module.scss +2 -4
- package/src/components/Grid/GridSpan.jsx +1 -1
- package/src/components/Grid/README.md +6 -4
- package/src/components/Grid/_settings.scss +2 -2
- package/src/components/InputGroup/InputGroup.jsx +2 -2
- package/src/components/InputGroup/README.md +5 -4
- package/src/components/Modal/Modal.jsx +1 -1
- package/src/components/Modal/Modal.module.scss +1 -1
- package/src/components/Modal/ModalBody.jsx +1 -1
- package/src/components/Modal/ModalCloseButton.jsx +1 -1
- package/src/components/Modal/ModalContent.jsx +1 -1
- package/src/components/Modal/ModalFooter.jsx +1 -1
- package/src/components/Modal/ModalHeader.jsx +2 -4
- package/src/components/Modal/ModalTitle.jsx +2 -4
- package/src/components/Modal/README.md +3 -2
- package/src/components/Paper/Paper.jsx +1 -1
- package/src/components/Paper/README.md +5 -4
- package/src/components/Popover/Popover.jsx +1 -1
- package/src/components/Popover/PopoverWrapper.jsx +1 -1
- package/src/components/Popover/README.md +5 -4
- package/src/components/Radio/README.md +8 -4
- package/src/components/Radio/Radio.jsx +2 -2
- package/src/components/ScrollView/README.md +5 -4
- package/src/components/ScrollView/ScrollView.jsx +1 -1
- package/src/components/ScrollView/ScrollView.module.scss +2 -4
- package/src/components/SelectField/README.md +8 -4
- package/src/components/SelectField/SelectField.jsx +2 -2
- package/src/components/Table/README.md +5 -4
- package/src/components/Table/Table.jsx +1 -1
- package/src/components/Tabs/README.md +3 -2
- package/src/components/Tabs/Tabs.jsx +1 -1
- package/src/components/Tabs/TabsItem.jsx +1 -1
- package/src/components/Text/README.md +3 -2
- package/src/components/Text/Text.jsx +1 -1
- package/src/components/TextArea/README.md +8 -4
- package/src/components/TextArea/TextArea.jsx +2 -2
- package/src/components/TextField/README.md +8 -4
- package/src/components/TextField/TextField.jsx +2 -2
- package/src/components/TextLink/README.md +5 -4
- package/src/components/TextLink/TextLink.jsx +1 -1
- package/src/components/Toggle/README.md +8 -4
- package/src/components/Toggle/Toggle.jsx +2 -2
- package/src/components/Toolbar/README.md +5 -4
- package/src/components/Toolbar/Toolbar.jsx +1 -1
- package/src/components/Toolbar/ToolbarGroup.jsx +1 -1
- package/src/components/Toolbar/ToolbarItem.jsx +1 -1
- package/src/index.js +1 -0
- package/src/provider/RUIProvider.jsx +6 -3
- package/src/styles/tools/form-fields/_box-field-layout.scss +1 -2
- package/src/styles/tools/form-fields/_inline-field-layout.scss +1 -0
- package/src/utils/mergeDeep.js +28 -0
- package/src/{components/_helpers → utils}/transferProps.js +0 -8
@@ -1,8 +1,10 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, {
|
3
|
+
useContext,
|
3
4
|
useMemo,
|
4
5
|
} from 'react';
|
5
6
|
import defaultTranslations from '../translations/en';
|
7
|
+
import { mergeDeep } from '../utils/mergeDeep';
|
6
8
|
import RUIContext from './RUIContext';
|
7
9
|
|
8
10
|
const RUIProvider = ({
|
@@ -10,10 +12,11 @@ const RUIProvider = ({
|
|
10
12
|
globalProps,
|
11
13
|
translations,
|
12
14
|
}) => {
|
15
|
+
const context = useContext(RUIContext);
|
13
16
|
const childProps = useMemo(() => ({
|
14
|
-
globalProps,
|
15
|
-
translations,
|
16
|
-
}), [globalProps, translations]);
|
17
|
+
globalProps: mergeDeep(context?.globalProps || {}, globalProps),
|
18
|
+
translations: mergeDeep(context?.translations || {}, translations),
|
19
|
+
}), [context, globalProps, translations]);
|
17
20
|
|
18
21
|
return (
|
19
22
|
<RUIContext.Provider
|
@@ -0,0 +1,28 @@
|
|
1
|
+
const isObject = (obj) => obj && typeof obj === 'object' && !Array.isArray(obj);
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Performs a deep merge of objects and returns new object.
|
5
|
+
*
|
6
|
+
* @param {...object} objects
|
7
|
+
* @returns {object}
|
8
|
+
*/
|
9
|
+
export const mergeDeep = (...objects) => objects.reduce((prev, obj) => {
|
10
|
+
if (obj == null) {
|
11
|
+
return prev;
|
12
|
+
}
|
13
|
+
|
14
|
+
const newObject = { ...prev };
|
15
|
+
|
16
|
+
Object.keys(obj).forEach((key) => {
|
17
|
+
const previousVal = prev[key];
|
18
|
+
const currentVal = obj[key];
|
19
|
+
|
20
|
+
if (isObject(previousVal) && isObject(currentVal)) {
|
21
|
+
newObject[key] = mergeDeep(previousVal, currentVal);
|
22
|
+
} else {
|
23
|
+
newObject[key] = currentVal;
|
24
|
+
}
|
25
|
+
});
|
26
|
+
|
27
|
+
return newObject;
|
28
|
+
}, {});
|
@@ -1,12 +1,4 @@
|
|
1
1
|
/**
|
2
|
-
* Controls passing of props from the React component to the HTML element
|
3
|
-
*
|
4
|
-
* Sometimes it is useful to have a mechanism to pass props from the React component to a rendered HTML element.
|
5
|
-
* It enables making the component interactive and helps improve its accessibility. However some props should
|
6
|
-
* never be passed to the HTML element as it would break things. This function is used to filter out such props.
|
7
|
-
*
|
8
|
-
* When run in development mode, the function will log the error to the console if any invalid props are passed.
|
9
|
-
*
|
10
2
|
* @param props The props that were passed to the React component and were not used by it
|
11
3
|
* @returns The props to be passed to the HTML element
|
12
4
|
*/
|