@react-ui-org/react-ui 0.47.0 → 0.48.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. package/dist/lib.development.js +330 -54
  2. package/dist/lib.js +1 -1
  3. package/package.json +1 -1
  4. package/src/lib/components/Alert/README.mdx +4 -2
  5. package/src/lib/components/Alert/index.js +1 -1
  6. package/src/lib/components/Badge/README.mdx +1 -1
  7. package/src/lib/components/Badge/index.js +1 -1
  8. package/src/lib/components/Button/Button.jsx +31 -31
  9. package/src/lib/components/Button/README.mdx +4 -2
  10. package/src/lib/components/Button/index.js +1 -1
  11. package/src/lib/components/ButtonGroup/ButtonGroup.jsx +2 -1
  12. package/src/lib/components/ButtonGroup/README.mdx +4 -2
  13. package/src/lib/components/Card/README.mdx +7 -5
  14. package/src/lib/components/CheckboxField/CheckboxField.jsx +27 -28
  15. package/src/lib/components/CheckboxField/README.mdx +1 -1
  16. package/src/lib/components/CheckboxField/index.js +1 -1
  17. package/src/lib/components/FileInputField/FileInputField.jsx +27 -27
  18. package/src/lib/components/FileInputField/README.mdx +1 -1
  19. package/src/lib/components/FileInputField/index.js +1 -1
  20. package/src/lib/components/FormLayout/README.mdx +15 -13
  21. package/src/lib/components/Grid/Grid.jsx +31 -28
  22. package/src/lib/components/Grid/Grid.scss +10 -15
  23. package/src/lib/components/Grid/GridSpan.jsx +5 -4
  24. package/src/lib/components/Grid/README.mdx +34 -36
  25. package/src/lib/components/Grid/_helpers/generateResponsiveCustomProperties.js +11 -3
  26. package/src/lib/components/Grid/_settings.scss +18 -0
  27. package/src/lib/components/Grid/_tools.scss +5 -5
  28. package/src/lib/components/Modal/Modal.jsx +147 -250
  29. package/src/lib/components/Modal/Modal.scss +7 -55
  30. package/src/lib/components/Modal/ModalBody.jsx +64 -0
  31. package/src/lib/components/Modal/ModalBody.scss +18 -0
  32. package/src/lib/components/Modal/ModalCloseButton.jsx +61 -0
  33. package/src/lib/components/Modal/ModalCloseButton.scss +18 -0
  34. package/src/lib/components/Modal/ModalContent.jsx +43 -0
  35. package/src/lib/components/Modal/ModalContent.scss +5 -0
  36. package/src/lib/components/Modal/ModalFooter.jsx +46 -0
  37. package/src/lib/components/Modal/ModalFooter.scss +35 -0
  38. package/src/lib/components/Modal/ModalHeader.jsx +48 -0
  39. package/src/lib/components/Modal/ModalHeader.scss +30 -0
  40. package/src/lib/components/Modal/ModalTitle.jsx +45 -0
  41. package/src/lib/components/Modal/ModalTitle.scss +10 -0
  42. package/src/lib/components/Modal/README.mdx +842 -197
  43. package/src/lib/components/Modal/_helpers/getJustifyClassName.js +19 -0
  44. package/src/lib/components/Modal/_helpers/getScrollingClassName.js +11 -0
  45. package/src/lib/components/Modal/_settings.scss +1 -5
  46. package/src/lib/components/Modal/_theme.scss +6 -0
  47. package/src/lib/components/Modal/index.js +7 -1
  48. package/src/lib/components/Paper/README.mdx +1 -1
  49. package/src/lib/components/Paper/index.js +1 -1
  50. package/src/lib/components/Popover/Popover.jsx +24 -24
  51. package/src/lib/components/Popover/Popover.scss +7 -6
  52. package/src/lib/components/Popover/PopoverWrapper.jsx +5 -5
  53. package/src/lib/components/Popover/PopoverWrapper.scss +3 -0
  54. package/src/lib/components/Popover/README.mdx +13 -11
  55. package/src/lib/components/Popover/_theme.scss +1 -1
  56. package/src/lib/components/Radio/README.mdx +1 -1
  57. package/src/lib/components/Radio/Radio.jsx +37 -27
  58. package/src/lib/components/Radio/index.js +1 -1
  59. package/src/lib/components/ScrollView/README.mdx +146 -84
  60. package/src/lib/components/ScrollView/ScrollView.jsx +104 -113
  61. package/src/lib/components/ScrollView/ScrollView.scss +18 -16
  62. package/src/lib/components/ScrollView/index.js +1 -1
  63. package/src/lib/components/SelectField/README.mdx +66 -2
  64. package/src/lib/components/SelectField/SelectField.jsx +93 -49
  65. package/src/lib/components/SelectField/_components/Option/Option.jsx +46 -0
  66. package/src/lib/components/SelectField/_components/Option/index.js +1 -0
  67. package/src/lib/components/SelectField/index.js +1 -1
  68. package/src/lib/components/Table/README.mdx +4 -2
  69. package/src/lib/components/Table/Table.jsx +1 -1
  70. package/src/lib/components/Table/index.js +1 -1
  71. package/src/lib/components/Tabs/README.mdx +5 -3
  72. package/src/lib/components/Tabs/TabsItem.scss +1 -2
  73. package/src/lib/components/Text/README.mdx +9 -7
  74. package/src/lib/components/Text/index.js +1 -1
  75. package/src/lib/components/TextArea/README.mdx +1 -1
  76. package/src/lib/components/TextArea/TextArea.jsx +33 -33
  77. package/src/lib/components/TextArea/index.js +1 -1
  78. package/src/lib/components/TextField/README.mdx +3 -3
  79. package/src/lib/components/TextField/TextField.jsx +33 -34
  80. package/src/lib/components/TextField/index.js +1 -1
  81. package/src/lib/components/TextLink/README.mdx +1 -1
  82. package/src/lib/components/TextLink/index.js +1 -1
  83. package/src/lib/components/Toggle/README.mdx +1 -1
  84. package/src/lib/components/Toggle/Toggle.jsx +28 -28
  85. package/src/lib/components/Toggle/index.js +1 -1
  86. package/src/lib/components/Toolbar/README.mdx +8 -6
  87. package/src/lib/components/_helpers/transferProps.js +1 -1
  88. package/src/lib/index.js +24 -16
  89. package/src/lib/provider/withGlobalProps.jsx +20 -3
  90. package/src/lib/theme.scss +18 -26
  91. package/src/lib/translations/en.js +1 -1
  92. package/src/lib/components/Grid/_theme.scss +0 -11
  93. package/src/lib/components/ScrollView/_theme.scss +0 -2
  94. package/src/lib/components/withForwardedRef.jsx +0 -11
@@ -22,22 +22,22 @@
22
22
 
23
23
  @use "sass:map";
24
24
  @use "../../styles/tools/spacing";
25
- @use "theme";
25
+ @use "settings";
26
26
  @use "tools";
27
27
 
28
28
  .root {
29
- @include tools.assign-responsive-custom-properties(theme.$responsive-properties); // 1.
29
+ @include tools.assign-responsive-custom-properties(settings.$grid-responsive-properties); // 1.
30
30
  @include spacing.bottom(layouts);
31
31
 
32
32
  display: grid;
33
33
  grid-template-columns: var(--rui-local-columns); // 2.
34
34
  grid-template-rows: var(--rui-local-rows); // 2.
35
- grid-auto-flow: var(--rui-local-auto-flow, #{map.get(theme.$responsive-properties, auto-flow)}); // 2.
35
+ grid-auto-flow: var(--rui-local-auto-flow); // 2.
36
36
  grid-gap: var(--rui-local-row-gap) var(--rui-local-column-gap); // 2.
37
- align-content: var(--rui-local-align-content, #{map.get(theme.$responsive-properties, align-content)}); // 2.
38
- align-items: var(--rui-local-align-items, #{map.get(theme.$responsive-properties, align-items)}); // 2.
39
- justify-content: var(--rui-local-justify-content, #{map.get(theme.$responsive-properties, justify-content)}); // 2.
40
- justify-items: var(--rui-local-justify-items, #{map.get(theme.$responsive-properties, justify-items)}); // 2.
37
+ align-content: var(--rui-local-align-content); // 2.
38
+ align-items: var(--rui-local-align-items); // 2.
39
+ justify-content: var(--rui-local-justify-content); // 2.
40
+ justify-items: var(--rui-local-justify-items); // 2.
41
41
  }
42
42
 
43
43
  // stylelint-disable-next-line selector-max-universal -- Reset any previously added margins.
@@ -46,15 +46,10 @@
46
46
  }
47
47
 
48
48
  .span {
49
- $responsive-properties: (
50
- column-span: 1,
51
- row-span: 1,
52
- );
49
+ @include tools.assign-responsive-custom-properties(settings.$grid-span-responsive-properties); // 1.
53
50
 
54
- @include tools.assign-responsive-custom-properties($responsive-properties); // 1.
55
-
56
- grid-column: span var(--rui-local-column-span, 1); // 2.
57
- grid-row: span var(--rui-local-row-span, 1); // 2.
51
+ grid-column: span var(--rui-local-column-span); // 2.
52
+ grid-row: span var(--rui-local-row-span); // 2.
58
53
  }
59
54
 
60
55
  // stylelint-disable selector-no-qualifying-type
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
4
  import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
5
+ import { transferProps } from '../_helpers/transferProps';
5
6
  import { generateResponsiveCustomProperties } from './_helpers/generateResponsiveCustomProperties';
6
7
  import styles from './Grid.scss';
7
8
 
@@ -11,7 +12,7 @@ export const GridSpan = ({
11
12
  id,
12
13
  rows,
13
14
  tag: Tag,
14
- ...other
15
+ ...restProps
15
16
  }) => {
16
17
  if (isChildrenEmpty(children)) {
17
18
  return null;
@@ -19,13 +20,13 @@ export const GridSpan = ({
19
20
 
20
21
  return (
21
22
  <Tag
23
+ {...transferProps(restProps)}
22
24
  id={id}
23
25
  className={styles.span}
24
26
  style={{
25
27
  ...generateResponsiveCustomProperties(columns, 'column-span'),
26
28
  ...generateResponsiveCustomProperties(rows, 'row-span'),
27
29
  }}
28
- {...other}
29
30
  >
30
31
  {children}
31
32
  </Tag>
@@ -37,9 +38,9 @@ export const GridSpan = ({
37
38
 
38
39
  GridSpan.defaultProps = {
39
40
  children: null,
40
- columns: undefined,
41
+ columns: 1,
41
42
  id: undefined,
42
- rows: undefined,
43
+ rows: 1,
43
44
  tag: 'div',
44
45
  };
45
46
 
@@ -11,8 +11,10 @@ import {
11
11
  Props,
12
12
  } from 'docz'
13
13
  import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
14
- import { Grid } from './Grid'
15
- import { GridSpan } from './GridSpan'
14
+ import {
15
+ Grid,
16
+ GridSpan,
17
+ } from '../..'
16
18
 
17
19
  The responsive Grid layout aligns content into an organized grid.
18
20
 
@@ -38,12 +40,11 @@ See [API](#api) for all available options.
38
40
 
39
41
  ## General Guidelines
40
42
 
41
- - This component implements native [CSS grid layout][grid-layout], a powerful
42
- tool for two-dimensional layouts. You may use any value accepted by
43
- [grid-template-columns], [grid-template-rows], [grid-column-gap],
44
- [grid-row-gap], [grid-auto-flow], [align-content], [align-items],
45
- [justify-content], [justify-items], and CSS properties in corresponding API
46
- options of the component.
43
+ - This component implements the native [CSS grid layout][grid-layout], a
44
+ powerful tool for two-dimensional layouts. You may use any value accepted by
45
+ [grid-template-columns], [grid-template-rows], [grid-auto-flow],
46
+ [align-content], [align-items], [justify-content], [justify-items], and CSS
47
+ properties in corresponding API options of the component.
47
48
 
48
49
  - To align your items in the grid, **simply wrap** them with the Grid
49
50
  component. Unlike other grid frameworks and UI libraries, **no additional
@@ -62,7 +63,7 @@ See [API](#api) for all available options.
62
63
  ## Columns
63
64
 
64
65
  Stack is the default outcome of Grid. Use the `columns` option to organize your
65
- items into grid.
66
+ items into a grid.
66
67
 
67
68
  <Playground>
68
69
  <Grid columns="1fr 1fr 1fr">
@@ -89,7 +90,9 @@ You can use the [`repeat()`][repeat] function to specify a recurring pattern.
89
90
  </Playground>
90
91
 
91
92
  Combine `repeat()` with `auto-fit` and [`minmax()`][minmax] to build automatic
92
- responsive layouts. Resize the playground to see it in action.
93
+ responsive layouts.
94
+
95
+ 📐 Try resizing the playground to see it in action.
93
96
 
94
97
  <Playground>
95
98
  <Grid columns="repeat(auto-fit, minmax(200px, auto))">
@@ -102,8 +105,8 @@ responsive layouts. Resize the playground to see it in action.
102
105
  </Grid>
103
106
  </Playground>
104
107
 
105
- 👉 If you need your items to have **equal height** even with content of varying
106
- length, it may be necessary to set `height: 100%` on them.
108
+ 👉 If you need your items to have **equal height** even with the content of
109
+ varying lengths, it may be necessary to set `height: 100%` on them.
107
110
 
108
111
  ## Rows
109
112
 
@@ -122,10 +125,11 @@ Use `columns` and `rows` to specify a more complicated grid layout.
122
125
 
123
126
  ## Gaps
124
127
 
125
- Both column and row gaps can be customized.
128
+ Both column and row gaps can be customized. The value must correspond to any of
129
+ [available spacings](/foundation/spacing).
126
130
 
127
131
  <Playground>
128
- <Grid columns="repeat(3, 1fr)" columnGap="0.75rem" rowGap="2rem">
132
+ <Grid columns="repeat(3, 1fr)" columnGap={2} rowGap={6}>
129
133
  <Placeholder bordered>Grid item</Placeholder>
130
134
  <Placeholder bordered>Grid item</Placeholder>
131
135
  <Placeholder bordered>Grid item</Placeholder>
@@ -137,7 +141,7 @@ Both column and row gaps can be customized.
137
141
 
138
142
  ## Alignment
139
143
 
140
- Individual items and the entire grid content can be aligned and along both axes.
144
+ Individual items and the entire grid content can be aligned along both axes.
141
145
 
142
146
  <Playground>
143
147
  <Grid
@@ -157,8 +161,8 @@ Individual items and the entire grid content can be aligned and along both axes.
157
161
 
158
162
  ## Custom HTML Tag
159
163
 
160
- To render as list for example, just change the output `tag` to `ul` or `ol` and
161
- wrap your items with `<li>`.
164
+ To render as a list, for example, just change the output `tag` to `ul` or `ol`
165
+ and wrap your items with `<li>`.
162
166
 
163
167
  <Playground>
164
168
  <Grid tag="ul">
@@ -180,9 +184,11 @@ If you need to build more complicated layouts, you have full control over the
180
184
  grid definition. Just specify your grid layout for
181
185
  [breakpoints](/foundation/breakpoints) where a change of layout is needed.
182
186
  The Grid component is written with the mobile-first approach so values for small
183
- breakpoints are used until they're overridden by a bigger breakpoint. If `xs`
184
- settings are omitted, theme defaults are used. Resize your browser to see how it
185
- works.
187
+ breakpoints are used until they're overridden by a bigger breakpoint.
188
+
189
+ 👉 With this syntax there are no defaults for individual breakpoints.
190
+
191
+ 📐 Try resizing your browser to see how it works.
186
192
 
187
193
  <Playground>
188
194
  <Grid
@@ -191,16 +197,17 @@ works.
191
197
  md: '1fr 2fr',
192
198
  }}
193
199
  columnGap={{
194
- md: 'var(--rui-spacing-2)',
195
- lg: 'var(--rui-spacing-4)',
200
+ xs: 4,
201
+ md: 2,
202
+ lg: 4,
196
203
  }}
197
204
  rows={{
198
205
  xs: 'auto auto 200px 200px',
199
206
  md: 'auto 200px auto',
200
207
  }}
201
208
  rowGap={{
202
- xs: 'var(--rui-spacing-3)',
203
- md: 'var(--rui-spacing-4)',
209
+ xs: 3,
210
+ md: 4,
204
211
  }}
205
212
  >
206
213
  <Placeholder bordered>Grid item</Placeholder>
@@ -214,9 +221,9 @@ works.
214
221
 
215
222
  ## Advanced Layouts
216
223
 
217
- Wrap your content with GridSpan component to span it over multiple columns or
218
- rows. Use the `autoFlow` option to control the layout when combined with
219
- responsive columns and rows.
224
+ Wrap your content with the GridSpan component to span it over multiple
225
+ columns or rows. Use the `autoFlow` option to control the layout when combined
226
+ with responsive columns and rows.
220
227
 
221
228
  <Playground>
222
229
  <Grid
@@ -266,18 +273,9 @@ Wrapper for content that should span multiple rows or columns.
266
273
 
267
274
  <Props table of={GridSpan} />
268
275
 
269
- ## Theming
270
-
271
- | Custom Property | Description |
272
- |------------------------------------------------------|--------------------------------------------------------------|
273
- | `--rui-Grid__column-gap` | Default column gap |
274
- | `--rui-Grid__row-gap` | Default row gap |
275
-
276
276
  [grid-layout]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
277
277
  [grid-template-columns]: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns
278
278
  [grid-template-rows]: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows
279
- [grid-column-gap]: https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap
280
- [grid-row-gap]: https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap
281
279
  [grid-auto-flow]: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow
282
280
  [align-content]: https://developer.mozilla.org/en-US/docs/Web/CSS/align-content
283
281
  [align-items]: https://developer.mozilla.org/en-US/docs/Web/CSS/align-items
@@ -1,14 +1,22 @@
1
- export const generateResponsiveCustomProperties = (prop, infix) => {
1
+ const prepareValueByType = (value, type) => {
2
+ if (type === 'spacing') {
3
+ return `var(--rui-spacing-${value})`;
4
+ }
5
+
6
+ return value;
7
+ };
8
+
9
+ export const generateResponsiveCustomProperties = (prop, infix, type = null) => {
2
10
  if (typeof prop === 'undefined') {
3
11
  return null;
4
12
  }
5
13
 
6
14
  if (typeof prop !== 'object') {
7
- return { [`--rui-local-${infix}-xs`]: prop };
15
+ return { [`--rui-local-${infix}-xs`]: prepareValueByType(prop, type) };
8
16
  }
9
17
 
10
18
  return Object.keys(prop).reduce((acc, breakpoint) => ({
11
19
  ...acc,
12
- [`--rui-local-${infix}-${breakpoint}`]: prop[breakpoint],
20
+ [`--rui-local-${infix}-${breakpoint}`]: prepareValueByType(prop[breakpoint], type),
13
21
  }), {});
14
22
  };
@@ -0,0 +1,18 @@
1
+ $grid-responsive-properties: [
2
+ columns,
3
+ column-gap,
4
+ rows,
5
+ row-gap,
6
+ auto-flow,
7
+ align-content,
8
+ align-items,
9
+ justify-content,
10
+ justify-items,
11
+ ]; // stylelint-disable-line indentation -- Broken rule?
12
+
13
+ $grid-span-responsive-properties: [
14
+ column-span,
15
+ row-span,
16
+ ]; // stylelint-disable-line indentation -- Broken rule?
17
+
18
+ $initial-fallback-value: initial;
@@ -1,14 +1,14 @@
1
1
  @use "sass:map";
2
2
  @use "../../styles/settings/breakpoints";
3
3
  @use "../../styles/tools/breakpoint";
4
+ @use "settings";
4
5
 
5
6
  // Generate fallback cascade using `var()` function fallbacks.
6
7
  //
7
8
  // $property-name: <string> Custom property name
8
- // $initial-fallback: <string> Initial fallback value
9
9
  // $current-breakpoint: <one of $breakpoint-values> Generate cascade for breakpoints smaller than this one
10
- @function _generate-custom-property-fallback-cascade($property-name, $initial-fallback, $current-breakpoint) {
11
- $fallback-cascade: $initial-fallback;
10
+ @function _generate-custom-property-fallback-cascade($property-name, $current-breakpoint) {
11
+ $fallback-cascade: settings.$initial-fallback-value;
12
12
 
13
13
  @each $breakpoint in map.keys(breakpoints.$values) {
14
14
  @if $breakpoint == $current-breakpoint {
@@ -26,11 +26,11 @@
26
26
  @mixin assign-responsive-custom-properties($properties) {
27
27
  @each $breakpoint in map.keys(breakpoints.$values) {
28
28
  @include breakpoint.up($breakpoint) {
29
- @each $property-name, $initial-fallback in $properties {
29
+ @each $property-name in $properties {
30
30
  --rui-local-#{$property-name}:
31
31
  var(
32
32
  --rui-local-#{$property-name}-#{$breakpoint},
33
- #{_generate-custom-property-fallback-cascade($property-name, $initial-fallback, $breakpoint)}
33
+ #{_generate-custom-property-fallback-cascade($property-name, $breakpoint)}
34
34
  );
35
35
  }
36
36
  }