@react-ui-org/react-ui 0.55.1 → 0.57.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/.nvmrc +1 -1
  2. package/dist/react-ui.css +15 -20
  3. package/dist/react-ui.development.css +2336 -846
  4. package/dist/react-ui.development.js +106 -96
  5. package/dist/react-ui.js +1 -1
  6. package/package.json +41 -39
  7. package/src/CNAME +1 -0
  8. package/src/components/Alert/Alert.jsx +3 -2
  9. package/src/components/Alert/Alert.module.scss +9 -31
  10. package/src/components/Alert/README.md +11 -9
  11. package/src/components/Alert/_settings.scss +5 -0
  12. package/src/components/Alert/_theme.scss +0 -43
  13. package/src/components/Badge/Badge.jsx +5 -3
  14. package/src/components/Badge/Badge.module.scss +29 -74
  15. package/src/components/Badge/README.md +24 -6
  16. package/src/components/Badge/_settings.scss +8 -0
  17. package/src/components/Button/Button.jsx +4 -3
  18. package/src/components/Button/Button.module.scss +183 -2
  19. package/src/components/Button/README.md +28 -24
  20. package/src/components/Button/_settings.scss +8 -3
  21. package/src/components/Button/_theme.scss +0 -3
  22. package/src/components/Button/_tools.scss +7 -71
  23. package/src/components/ButtonGroup/ButtonGroup.jsx +2 -2
  24. package/src/components/ButtonGroup/README.md +5 -4
  25. package/src/components/Card/Card.jsx +3 -2
  26. package/src/components/Card/Card.module.scss +10 -31
  27. package/src/components/Card/CardBody.jsx +1 -1
  28. package/src/components/Card/CardFooter.jsx +1 -1
  29. package/src/components/Card/README.md +11 -10
  30. package/src/components/Card/_settings.scss +5 -0
  31. package/src/components/Card/_theme.scss +0 -43
  32. package/src/components/CheckboxField/CheckboxField.jsx +2 -2
  33. package/src/components/CheckboxField/README.md +8 -4
  34. package/src/components/FileInputField/FileInputField.jsx +3 -3
  35. package/src/components/FileInputField/README.md +8 -4
  36. package/src/components/FormLayout/FormLayout.jsx +1 -1
  37. package/src/components/FormLayout/FormLayoutCustomField.jsx +1 -1
  38. package/src/components/FormLayout/README.md +5 -4
  39. package/src/components/Grid/Grid.jsx +1 -1
  40. package/src/components/Grid/Grid.module.scss +5 -0
  41. package/src/components/Grid/GridSpan.jsx +1 -1
  42. package/src/components/Grid/README.md +6 -4
  43. package/src/components/Grid/_settings.scss +2 -2
  44. package/src/components/InputGroup/InputGroup.jsx +2 -2
  45. package/src/components/InputGroup/README.md +5 -4
  46. package/src/components/Modal/Modal.jsx +1 -1
  47. package/src/components/Modal/Modal.module.scss +1 -1
  48. package/src/components/Modal/ModalBody.jsx +1 -1
  49. package/src/components/Modal/ModalCloseButton.jsx +1 -1
  50. package/src/components/Modal/ModalContent.jsx +1 -1
  51. package/src/components/Modal/ModalFooter.jsx +1 -1
  52. package/src/components/Modal/ModalHeader.jsx +2 -4
  53. package/src/components/Modal/ModalTitle.jsx +2 -4
  54. package/src/components/Modal/README.md +3 -2
  55. package/src/components/Paper/Paper.jsx +1 -1
  56. package/src/components/Paper/README.md +5 -4
  57. package/src/components/Popover/Popover.jsx +1 -1
  58. package/src/components/Popover/Popover.module.scss +16 -16
  59. package/src/components/Popover/PopoverWrapper.jsx +1 -1
  60. package/src/components/Popover/README.md +5 -4
  61. package/src/components/Popover/_theme.scss +4 -2
  62. package/src/components/Radio/README.md +8 -4
  63. package/src/components/Radio/Radio.jsx +2 -2
  64. package/src/components/ScrollView/README.md +5 -4
  65. package/src/components/ScrollView/ScrollView.jsx +1 -1
  66. package/src/components/ScrollView/ScrollView.module.scss +2 -4
  67. package/src/components/SelectField/README.md +8 -4
  68. package/src/components/SelectField/SelectField.jsx +2 -2
  69. package/src/components/Table/README.md +5 -4
  70. package/src/components/Table/Table.jsx +1 -1
  71. package/src/components/Tabs/README.md +3 -2
  72. package/src/components/Tabs/Tabs.jsx +1 -1
  73. package/src/components/Tabs/TabsItem.jsx +1 -1
  74. package/src/components/Text/README.md +3 -2
  75. package/src/components/Text/Text.jsx +1 -1
  76. package/src/components/TextArea/README.md +8 -4
  77. package/src/components/TextArea/TextArea.jsx +2 -2
  78. package/src/components/TextField/README.md +8 -4
  79. package/src/components/TextField/TextField.jsx +2 -2
  80. package/src/components/TextLink/README.md +5 -4
  81. package/src/components/TextLink/TextLink.jsx +1 -1
  82. package/src/components/Toggle/README.md +8 -4
  83. package/src/components/Toggle/Toggle.jsx +2 -2
  84. package/src/components/Toolbar/README.md +5 -4
  85. package/src/components/Toolbar/Toolbar.jsx +1 -1
  86. package/src/components/Toolbar/ToolbarGroup.jsx +1 -1
  87. package/src/components/Toolbar/ToolbarItem.jsx +1 -1
  88. package/src/components/_helpers/getRootPriorityClassName.js +1 -1
  89. package/src/index.js +1 -0
  90. package/src/provider/RUIProvider.jsx +6 -3
  91. package/src/styles/settings/_collections.scss +9 -0
  92. package/src/styles/tools/_collections.scss +191 -0
  93. package/src/styles/tools/_string.scss +5 -2
  94. package/src/styles/tools/form-fields/_box-field-layout.scss +5 -0
  95. package/src/styles/tools/form-fields/_inline-field-layout.scss +1 -0
  96. package/src/theme.scss +64 -0
  97. package/src/utils/mergeDeep.js +28 -0
  98. package/src/{components/_helpers → utils}/transferProps.js +0 -8
  99. package/src/components/Alert/_tools.scss +0 -10
  100. package/src/components/Button/_base.scss +0 -159
  101. package/src/components/Button/_priorities.scss +0 -149
  102. package/src/components/Card/_tools.scss +0 -10
@@ -56,6 +56,9 @@ See [API](#api) for all available options.
56
56
  polite phrases like _Please select your favourite fruit_. Short labels will
57
57
  help your users accomplish their task faster.
58
58
 
59
+ - **Use text labels** unless it is necessary to wrap text label into
60
+ Popover-like to component to provide additional info about the field.
61
+
59
62
  - Only make the SelectField's label invisible when there is **another visual
60
63
  clue** to guide users through filling the input. Using the first option as
61
64
  label is not recommended either — it disappears once user makes their choice.
@@ -649,10 +652,11 @@ React.createElement(() => {
649
652
  ## Forwarding HTML Attributes
650
653
 
651
654
  In addition to the options below in the [component's API](#api) section, you
652
- can specify **any HTML attribute you like.** All attributes that don't interfere
653
- with the API of the React component are forwarded to the root `<select>` HTML
654
- element. This enables making the component interactive and helps to improve
655
- its accessibility.
655
+ can specify **any HTML attribute you like.** All attributes that don't
656
+ interfere with the API of the React component and that aren't filtered out by
657
+ [`transferProps`](/docs/js-helpers/transferProps) helper are forwarded to the
658
+ `<select>` HTML element. This enables making the component interactive and
659
+ helps to improve its accessibility.
656
660
 
657
661
  👉 For the full list of supported attributes refer to:
658
662
 
@@ -2,10 +2,10 @@ import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
4
  import { classNames } from '../../utils/classNames';
5
+ import { transferProps } from '../../utils/transferProps';
5
6
  import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
6
7
  import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
7
8
  import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
8
- import { transferProps } from '../_helpers/transferProps';
9
9
  import { FormLayoutContext } from '../FormLayout';
10
10
  import { InputGroupContext } from '../InputGroup/InputGroupContext';
11
11
  import { Option } from './_components/Option';
@@ -182,7 +182,7 @@ SelectField.propTypes = {
182
182
  /**
183
183
  * Select field label.
184
184
  */
185
- label: PropTypes.string.isRequired,
185
+ label: PropTypes.node.isRequired,
186
186
  /**
187
187
  * Layout of the field.
188
188
  *
@@ -243,10 +243,11 @@ React.createElement(() => {
243
243
  ## Forwarding HTML Attributes
244
244
 
245
245
  In addition to the options below in the [component's API](#api) section, you
246
- can specify **any HTML attribute you like.** All attributes that don't interfere
247
- with the API of the React component are forwarded to the root `<table>` HTML
248
- element. This enables making the component interactive and helps to improve
249
- its accessibility.
246
+ can specify **any HTML attribute you like.** All attributes that don't
247
+ interfere with the API of the React component and that aren't filtered out by
248
+ [`transferProps`](/docs/js-helpers/transferProps) helper are forwarded to the
249
+ root `<table>` HTML element. This enables making the component interactive and
250
+ helps to improve its accessibility.
250
251
 
251
252
  👉 For the full list of supported attributes refer to:
252
253
 
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
- import { transferProps } from '../_helpers/transferProps';
4
+ import { transferProps } from '../../utils/transferProps';
5
5
  import { TableHeaderCell } from './_components/TableHeaderCell';
6
6
  import { TableBodyCell } from './_components/TableBodyCell';
7
7
  import styles from './Table.module.scss';
@@ -157,8 +157,9 @@ React.createElement(() => {
157
157
  ## Forwarding HTML Attributes
158
158
 
159
159
  In addition to the options below in the [component's API](#api) section, you
160
- can specify **any HTML attribute you like.** All attributes that don't interfere
161
- with the API of the React component are forwarded to:
160
+ can specify **any HTML attribute you like.** All attributes that don't
161
+ interfere with the API of the React component and that aren't filtered out by
162
+ [`transferProps`](/docs/js-helpers/transferProps) helper are forwarded to:
162
163
 
163
164
  - the root `<nav>` HTML element in case of `Tabs` component
164
165
  - the `<a>` HTML element in case of `TabsItem`
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
- import { transferProps } from '../_helpers/transferProps';
4
+ import { transferProps } from '../../utils/transferProps';
5
5
  import styles from './Tabs.module.scss';
6
6
 
7
7
  export const Tabs = ({
@@ -1,8 +1,8 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
- import { transferProps } from '../_helpers/transferProps';
5
4
  import { classNames } from '../../utils/classNames';
5
+ import { transferProps } from '../../utils/transferProps';
6
6
  import styles from './TabsItem.module.scss';
7
7
 
8
8
  export const TabsItem = ({
@@ -202,8 +202,9 @@ React.createElement(() => {
202
202
  ## Forwarding HTML Attributes
203
203
 
204
204
  In addition to the options below in the [component's API](#api) section, you
205
- can specify **any HTML attribute you like.** All attributes that don't interfere
206
- with the API of the React component are forwarded to the root:
205
+ can specify **any HTML attribute you like.** All attributes that don't
206
+ interfere with the API of the React component and that aren't filtered out by
207
+ [`transferProps`](/docs/js-helpers/transferProps) helper are forwarded to:
207
208
 
208
209
  - `<span>` HTML element in case that `blockLevel` is set to `false`
209
210
  - `<div>` HTML element in case that `blockLevel` is set to `true`
@@ -1,8 +1,8 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
- import { transferProps } from '../_helpers/transferProps';
5
4
  import { classNames } from '../../utils/classNames';
5
+ import { transferProps } from '../../utils/transferProps';
6
6
  import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
7
7
  import { getRootClampClassName } from './_helpers/getRootClampClassName';
8
8
  import { getRootHyphensClassName } from './_helpers/getRootHyphensClassName';
@@ -24,6 +24,9 @@ See [API](#api) for all available options.
24
24
  polite phrases like _Please enter your message_. Short labels will help your
25
25
  users accomplish their task faster.
26
26
 
27
+ - **Use text labels** unless it is necessary to wrap text label into
28
+ Popover-like to component to provide additional info about the field.
29
+
27
30
  - Only make the TextArea's label invisible when there is **another visual
28
31
  clue** to guide users through filling the input. Using the first option as
29
32
  label is not recommended either — it disappears once user makes their choice.
@@ -317,10 +320,11 @@ It's possible to disable the whole input.
317
320
  ## Forwarding HTML Attributes
318
321
 
319
322
  In addition to the options below in the [component's API](#api) section, you
320
- can specify **any HTML attribute you like.** All attributes that don't interfere
321
- with the API of the React component are forwarded to the root `<textarea>` HTML
322
- element. This enables making the component interactive and helps to improve
323
- its accessibility.
323
+ can specify **any HTML attribute you like.** All attributes that don't
324
+ interfere with the API of the React component and that aren't filtered out by
325
+ [`transferProps`](/docs/js-helpers/transferProps) helper are forwarded to the
326
+ `<textarea>` HTML element. This enables making the component interactive and
327
+ helps to improve its accessibility.
324
328
 
325
329
  ```docoff-react-preview
326
330
  <TextArea
@@ -2,10 +2,10 @@ import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
4
  import { classNames } from '../../utils/classNames';
5
+ import { transferProps } from '../../utils/transferProps';
5
6
  import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
6
7
  import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
7
8
  import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
8
- import { transferProps } from '../_helpers/transferProps';
9
9
  import { FormLayoutContext } from '../FormLayout';
10
10
  import styles from './TextArea.module.scss';
11
11
 
@@ -132,7 +132,7 @@ TextArea.propTypes = {
132
132
  /**
133
133
  * Text field label.
134
134
  */
135
- label: PropTypes.string.isRequired,
135
+ label: PropTypes.node.isRequired,
136
136
  /**
137
137
  * Layout of the field.
138
138
  *
@@ -36,6 +36,9 @@ See [API](#api) for all available options.
36
36
  polite phrases like _Please enter your first name_. Short labels will help
37
37
  your users accomplish their task faster.
38
38
 
39
+ - **Use text labels** unless it is necessary to wrap text label into
40
+ Popover-like to component to provide additional info about the field.
41
+
39
42
  - Only make the TextField's label invisible when there is **another visual
40
43
  clue** to guide users through filling the input.
41
44
 
@@ -445,10 +448,11 @@ It's possible to disable the whole input.
445
448
  ## Forwarding HTML Attributes
446
449
 
447
450
  In addition to the options below in the [component's API](#api) section, you
448
- can specify **any HTML attribute you like.** All attributes that don't interfere
449
- with the API of the React component are forwarded to the root `<input>` HTML
450
- element. This enables making the component interactive and helps to improve
451
- its accessibility.
451
+ can specify **any HTML attribute you like.** All attributes that don't
452
+ interfere with the API of the React component and that aren't filtered out by
453
+ [`transferProps`](/docs/js-helpers/transferProps) helper are forwarded to the
454
+ `<input>` HTML element. This enables making the component interactive and helps
455
+ to improve its accessibility.
452
456
 
453
457
  ```docoff-react-preview
454
458
  <TextField
@@ -2,10 +2,10 @@ import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
4
  import { classNames } from '../../utils/classNames';
5
+ import { transferProps } from '../../utils/transferProps';
5
6
  import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
6
7
  import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
7
8
  import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
8
- import { transferProps } from '../_helpers/transferProps';
9
9
  import { FormLayoutContext } from '../FormLayout';
10
10
  import { InputGroupContext } from '../InputGroup/InputGroupContext';
11
11
  import styles from './TextField.module.scss';
@@ -156,7 +156,7 @@ TextField.propTypes = {
156
156
  /**
157
157
  * Text field label.
158
158
  */
159
- label: PropTypes.string.isRequired,
159
+ label: PropTypes.node.isRequired,
160
160
  /**
161
161
  * Layout of the field.
162
162
  *
@@ -47,10 +47,11 @@ It's common to use custom function for routing within SPAs. Use the
47
47
  ## Forwarding HTML Attributes
48
48
 
49
49
  In addition to the options below in the [component's API](#api) section, you
50
- can specify **any HTML attribute you like.** All attributes that don't interfere
51
- with the API of the React component are forwarded to the root `<a>` HTML
52
- element. This enables making the component interactive and helps to improve
53
- its accessibility.
50
+ can specify **any HTML attribute you like.** All attributes that don't
51
+ interfere with the API of the React component and that aren't filtered out by
52
+ [`transferProps`](/docs/js-helpers/transferProps) helper are forwarded to the
53
+ root `<a>` HTML element. This enables making the component interactive and
54
+ helps to improve its accessibility.
54
55
 
55
56
  👉 For the full list of supported attributes refer to:
56
57
 
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
- import { transferProps } from '../_helpers/transferProps';
4
+ import { transferProps } from '../../utils/transferProps';
5
5
  import styles from './TextLink.module.scss';
6
6
 
7
7
  export const TextLink = ({
@@ -39,6 +39,9 @@ See [API](#api) for all available options.
39
39
  me any emails” which would mean that the user needs to turn the toggle **on**
40
40
  in order for something **not** to happen.
41
41
 
42
+ - **Use text labels** unless it is necessary to wrap text label into
43
+ Popover-like to component to provide additional info about the field.
44
+
42
45
  - Only make the Toggle's label invisible when there is **another visual clue**
43
46
  to guide users through using the input.
44
47
 
@@ -168,10 +171,11 @@ Disabled state makes the input unavailable.
168
171
  ## Forwarding HTML Attributes
169
172
 
170
173
  In addition to the options below in the [component's API](#api) section, you
171
- can specify **any HTML attribute you like.** All attributes that don't interfere
172
- with the API of the React component are forwarded to the root `<input>` HTML
173
- element. This enables making the component interactive and helps to improve
174
- its accessibility.
174
+ can specify **any HTML attribute you like.** All attributes that don't
175
+ interfere with the API of the React component and that aren't filtered out by
176
+ [`transferProps`](/docs/js-helpers/transferProps) helper are forwarded to the
177
+ `<input>` HTML element. This enables making the component interactive and helps
178
+ to improve its accessibility.
175
179
 
176
180
  👉 For the full list of supported attributes refer to:
177
181
 
@@ -2,8 +2,8 @@ import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
4
  import { classNames } from '../../utils/classNames';
5
+ import { transferProps } from '../../utils/transferProps';
5
6
  import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
6
- import { transferProps } from '../_helpers/transferProps';
7
7
  import { FormLayoutContext } from '../FormLayout';
8
8
  import styles from './Toggle.module.scss';
9
9
 
@@ -114,7 +114,7 @@ Toggle.propTypes = {
114
114
  /**
115
115
  * Toggle label.
116
116
  */
117
- label: PropTypes.string.isRequired,
117
+ label: PropTypes.node.isRequired,
118
118
  /**
119
119
  * Placement of the label relative to the input.
120
120
  */
@@ -322,10 +322,11 @@ Or to build a classic media layout with image on the left and text on the right:
322
322
  ## Forwarding HTML Attributes
323
323
 
324
324
  In addition to the options below in the [component's API](#api) section, you
325
- can specify **any HTML attribute you like.** All attributes that don't interfere
326
- with the API of the React component are forwarded to the root `<div>` HTML
327
- element. This enables making the component interactive and helps to improve
328
- its accessibility.
325
+ can specify **any HTML attribute you like.** All attributes that don't
326
+ interfere with the API of the React component and that aren't filtered out by
327
+ [`transferProps`](/docs/js-helpers/transferProps) helper are forwarded to the
328
+ root `<div>` HTML element. This enables making the component interactive and
329
+ helps to improve its accessibility.
329
330
 
330
331
  👉 For the full list of supported attributes refer to:
331
332
 
@@ -1,8 +1,8 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
- import { transferProps } from '../_helpers/transferProps';
5
4
  import { classNames } from '../../utils/classNames';
5
+ import { transferProps } from '../../utils/transferProps';
6
6
  import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
7
7
  import { getAlignClassName } from './_helpers/getAlignClassName';
8
8
  import { getJustifyClassName } from './_helpers/getJustifyClassName';
@@ -1,8 +1,8 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
- import { transferProps } from '../_helpers/transferProps';
5
4
  import { classNames } from '../../utils/classNames';
5
+ import { transferProps } from '../../utils/transferProps';
6
6
  import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
7
7
  import { getAlignClassName } from './_helpers/getAlignClassName';
8
8
  import styles from './Toolbar.module.scss';
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { transferProps } from '../_helpers/transferProps';
4
3
  import { classNames } from '../../utils/classNames';
4
+ import { transferProps } from '../../utils/transferProps';
5
5
  import { withGlobalProps } from '../../provider';
6
6
  import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
7
7
  import styles from './Toolbar.module.scss';
@@ -1,4 +1,4 @@
1
- export default (priority, styles) => {
1
+ export const getRootPriorityClassName = (priority, styles) => {
2
2
  if (priority === 'filled') {
3
3
  return styles.isRootPriorityFilled;
4
4
  }
package/src/index.js CHANGED
@@ -62,3 +62,4 @@ export { RUIProvider } from './provider';
62
62
 
63
63
  // Utils
64
64
  export { classNames } from './utils/classNames';
65
+ export { transferProps } from './utils/transferProps';
@@ -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,9 @@
1
+ $action-colors: primary, secondary, selected;
2
+ $feedback-colors: success, warning, danger, info, help, note;
3
+ $neutral-colors: light, dark;
4
+
5
+ $colors: (
6
+ action: $action-colors,
7
+ feedback: $feedback-colors,
8
+ neutral: $neutral-colors,
9
+ );
@@ -0,0 +1,191 @@
1
+ @use "string" as rui-string;
2
+
3
+ // Mixin to generate CSS custom properties for a set of visual properties.
4
+ //
5
+ // 1. Generates a CSS custom property for each property in the `$properties` list.
6
+ // 2. Theming of the disabled state is optional, so the `default` theme options are used (via CSS custom property
7
+ // fallback) if no `disabled` styling for the specific variant is provided by user.
8
+ //
9
+ // @param {String} $prefix - The prefix for the CSS custom properties.
10
+ // @param {String} $component-name - The name of the component.
11
+ // @param {String} $modifier-value - The value of the modifier.
12
+ // @param {String} $variant-value - The value of the variant.
13
+ // @param {String} $interaction-state - The interaction state.
14
+ // @param {List} $properties - The list of properties to generate CSS custom properties for.
15
+ //
16
+ // Example:
17
+ //
18
+ // @include generate-properties(
19
+ // $prefix: "rui-",
20
+ // $component-name: "Card",
21
+ // $variant-name: "color",
22
+ // $variant-value: "success",
23
+ // $properties: color, border-color, background-color,
24
+ // );
25
+ //
26
+ // … will output:
27
+ //
28
+ // --rui-local-color: var(--rui-Card--success__color);
29
+ // --rui-local-border-color: var(--rui-Card--success__border-color);
30
+ // --rui-local-background-color: var(--rui-Card--success__background-color);
31
+
32
+ @mixin generate-properties(
33
+ $prefix,
34
+ $component-name,
35
+ $modifier-value: null,
36
+ $variant-value,
37
+ $interaction-state: null,
38
+ $properties,
39
+ ) {
40
+ @each $property in $properties {
41
+ $modifier: if($modifier-value, "--" + $modifier-value, "");
42
+ $state: if($interaction-state, "--" + $interaction-state, "");
43
+
44
+ // 1.
45
+ --#{$prefix}local-#{$property}:
46
+ var(
47
+ #{
48
+ "--"
49
+ + $prefix
50
+ + $component-name
51
+ + $modifier
52
+ + "--"
53
+ + $variant-value
54
+ + $state
55
+ + "__"
56
+ + $property
57
+ }
58
+ #{if(
59
+ $interaction-state and $interaction-state == "disabled",
60
+ ", var(--"
61
+ + $prefix
62
+ + $component-name
63
+ + $modifier
64
+ + "--"
65
+ + $variant-value
66
+ + "--default__"
67
+ + $property
68
+ + ")",
69
+ ""
70
+ )}
71
+ ); // 2.
72
+ }
73
+ }
74
+
75
+ // Mixin to generate CSS classes for a component variant.
76
+ //
77
+ // @param {String} $prefix - The prefix for the CSS custom properties.
78
+ // @param {String} $component-name - The name of the component.
79
+ // @param {String} $modifier-name - Optional name of the class name modifier.
80
+ // @param {String} $modifier-name - Optional value of the class name modifier.
81
+ // @param {String} $variant-name - The name of the variant.
82
+ // @param {String} $variant-value - The value of the variant.
83
+ // @param {Boolean} $generate-interaction-states - Whether to generate interaction states (disabled, hover, active).
84
+ // @param {List} $properties - The list of properties to generate CSS custom properties for.
85
+ //
86
+ // Examples:
87
+ //
88
+ // @include collections.generate-class(
89
+ // $prefix: "rui-",
90
+ // $component-name: "Card",
91
+ // $variant-name: "color",
92
+ // $variant-value: "success",
93
+ // $properties: color, border-color, background-color,
94
+ // );
95
+ //
96
+ // … will output:
97
+ //
98
+ // .isRootColorSuccess {
99
+ // --rui-local-color: var(--rui-Card--success__color);
100
+ // --rui-local-border-color: var(--rui-Card--success__border-color);
101
+ // --rui-local-background-color: var(--rui-Card--success__background-color);
102
+ // }
103
+ //
104
+ // @include collections.generate-class(
105
+ // $prefix: "rui-",
106
+ // $component-name: "Button",
107
+ // $modifier-name: "priority",
108
+ // $modifier-value: "flat",
109
+ // $variant-name: "color",
110
+ // $variant-value: "success",
111
+ // $generate-interaction-states: true,
112
+ // $properties: color, background,
113
+ // );
114
+ //
115
+ // … will output:
116
+ //
117
+ // .isRootPriorityFlat.isRootColorSuccess {
118
+ // --rui-local-color: var(--rui-Button--flat--success--default__color);
119
+ // --rui-local-background: var(--rui-Button--flat--success--default__background);
120
+ // }
121
+ // .isRootPriorityFlat.isRootColorSuccess:disabled {
122
+ // --rui-local-color:
123
+ // var(
124
+ // --rui-Button--flat--success--disabled__color,
125
+ // var(--rui-Button--flat--success--default__color)
126
+ // );
127
+ // --rui-local-background:
128
+ // var(
129
+ // --rui-Button--flat--success--disabled__background,
130
+ // var(--rui-Button--flat--success--default__background)
131
+ // );
132
+ // }
133
+ // .isRootPriorityFlat.isRootColorSuccess:not(:disabled):hover {
134
+ // --rui-local-color: var(--rui-Button--flat--success--hover__color);
135
+ // --rui-local-background: var(--rui-Button--flat--success--hover__background);
136
+ // }
137
+ // .isRootPriorityFlat.isRootColorSuccess:not(:disabled):active {
138
+ // --rui-local-color: var(--rui-Button--flat--success--active__color);
139
+ // --rui-local-background: var(--rui-Button--flat--success--active__background);
140
+ // }
141
+
142
+ @mixin generate-class(
143
+ $prefix,
144
+ $component-name,
145
+ $modifier-name: null,
146
+ $modifier-value: null,
147
+ $variant-name,
148
+ $variant-value,
149
+ $generate-interaction-states: false,
150
+ $properties,
151
+ ) {
152
+ $modifier-class-name:
153
+ if(
154
+ $modifier-name and $modifier-value,
155
+ ".isRoot#{rui-string.capitalize($modifier-name)}#{rui-string.capitalize($modifier-value)}",
156
+ ""
157
+ );
158
+ $variant-class-name: ".isRoot#{rui-string.capitalize($variant-name)}#{rui-string.capitalize($variant-value)}";
159
+
160
+ #{$modifier-class-name}#{$variant-class-name} {
161
+ @if $generate-interaction-states {
162
+ $interaction-state-selector-map: (
163
+ default: "&",
164
+ disabled: "&:disabled",
165
+ hover: "&:not(:disabled):hover",
166
+ active: "&:not(:disabled):active",
167
+ );
168
+
169
+ @each $interaction-state, $interaction-state-selector in $interaction-state-selector-map {
170
+ #{$interaction-state-selector} {
171
+ @include generate-properties(
172
+ $prefix: $prefix,
173
+ $component-name: $component-name,
174
+ $modifier-value: $modifier-value,
175
+ $variant-value: $variant-value,
176
+ $interaction-state: $interaction-state,
177
+ $properties: $properties,
178
+ );
179
+ }
180
+ }
181
+ } @else {
182
+ @include generate-properties(
183
+ $prefix: $prefix,
184
+ $component-name: $component-name,
185
+ $modifier-value: $modifier-value,
186
+ $variant-value: $variant-value,
187
+ $properties: $properties,
188
+ );
189
+ }
190
+ }
191
+ }
@@ -1,7 +1,10 @@
1
- // Author: Hugo Giraudel
2
-
3
1
  @use "sass:string";
4
2
 
3
+ @function capitalize($string) {
4
+ @return string.to-upper-case(string.slice($string, 1, 1)) + string.slice($string, 2);
5
+ }
6
+
7
+ // Author: Hugo Giraudel
5
8
  @function replace($string, $search, $replace: "") {
6
9
  $index: string.index($string, $search);
7
10
 
@@ -55,6 +55,9 @@
55
55
  //
56
56
  // 13. Label and field are vertically aligned to top (start) by default (see 10.). Vertical
57
57
  // alignment of each block can be changed by theme configuration.
58
+ //
59
+ // 14. Intentionally use longhand properties because the custom property fallback mechanism evaluates `initial` values
60
+ // as empty. That makes the other value of the shorthand property unexpectedly used for both axes.
58
61
 
59
62
  @use "../../settings/forms";
60
63
  @use "../../settings/form-fields" as settings;
@@ -125,8 +128,10 @@
125
128
 
126
129
  .field {
127
130
  grid-area: field;
131
+ // stylelint-disable declaration-block-no-redundant-longhand-properties -- 14.
128
132
  align-self: theme.$horizontal-field-vertical-alignment; // 13.
129
133
  justify-self: start; // 7.
134
+ // stylelint-enable declaration-block-no-redundant-longhand-properties
130
135
  }
131
136
  }
132
137
  }
@@ -85,6 +85,7 @@
85
85
 
86
86
  &.isRootLayoutHorizontal .label {
87
87
  grid-column-start: 1;
88
+ align-self: start;
88
89
  width: auto;
89
90
  padding-right: settings.$horizontal-inner-gap;
90
91
  margin-left: 0;