@react-ui-org/react-ui 0.46.0 → 0.47.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 +15 -16
- package/dist/lib.development.js +106 -154
- package/dist/lib.js +1 -1
- package/package.json +2 -1
- package/src/lib/components/Alert/Alert.jsx +43 -43
- package/src/lib/components/Alert/README.mdx +2 -5
- package/src/lib/components/Badge/Badge.jsx +3 -3
- package/src/lib/components/Button/Button.jsx +4 -4
- package/src/lib/components/Button/README.mdx +4 -4
- package/src/lib/components/Button/_base.scss +6 -6
- package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +4 -4
- package/src/lib/components/ButtonGroup/ButtonGroup.jsx +10 -3
- package/src/lib/components/ButtonGroup/README.mdx +1 -1
- package/src/lib/components/Card/Card.jsx +3 -3
- package/src/lib/components/Card/CardBody.jsx +16 -5
- package/src/lib/components/Card/CardFooter.jsx +13 -5
- package/src/lib/components/CheckboxField/CheckboxField.jsx +3 -3
- package/src/lib/components/FileInputField/FileInputField.jsx +3 -3
- package/src/lib/components/FormLayout/FormLayout.jsx +3 -3
- package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +3 -3
- package/src/lib/components/FormLayout/README.mdx +4 -5
- package/src/lib/components/Grid/Grid.jsx +21 -21
- package/src/lib/components/Grid/Grid.scss +6 -0
- package/src/lib/components/Grid/GridSpan.jsx +7 -7
- package/src/lib/components/Grid/README.mdx +46 -20
- package/src/lib/components/Grid/_theme.scss +7 -7
- package/src/lib/components/Modal/Modal.jsx +30 -26
- package/src/lib/components/Modal/README.mdx +2 -5
- package/src/lib/components/Paper/Paper.jsx +3 -3
- package/src/lib/components/Popover/Popover.jsx +94 -0
- package/src/lib/components/Popover/Popover.scss +235 -0
- package/src/lib/components/Popover/PopoverWrapper.jsx +46 -0
- package/src/lib/components/Popover/README.mdx +333 -0
- package/src/lib/components/Popover/_helpers/getRootAlignmentClassName.js +13 -0
- package/src/lib/components/Popover/_helpers/getRootSideClassName.js +17 -0
- package/src/lib/components/Popover/_theme.scss +16 -0
- package/src/lib/components/Popover/index.js +2 -0
- package/src/lib/components/Radio/Radio.jsx +3 -3
- package/src/lib/components/ScrollView/README.mdx +2 -5
- package/src/lib/components/ScrollView/ScrollView.jsx +11 -13
- package/src/lib/components/SelectField/SelectField.jsx +3 -3
- package/src/lib/components/Table/README.mdx +1 -1
- package/src/lib/components/Table/Table.jsx +3 -3
- package/src/lib/components/Tabs/Tabs.jsx +3 -3
- package/src/lib/components/Tabs/TabsItem.jsx +3 -3
- package/src/lib/components/Text/README.mdx +2 -2
- package/src/lib/components/Text/Text.jsx +3 -3
- package/src/lib/components/TextArea/TextArea.jsx +3 -3
- package/src/lib/components/TextField/TextField.jsx +3 -3
- package/src/lib/components/TextLink/TextLink.jsx +3 -3
- package/src/lib/components/Toggle/Toggle.jsx +3 -3
- package/src/lib/components/Toolbar/README.mdx +18 -6
- package/src/lib/components/Toolbar/Toolbar.jsx +10 -3
- package/src/lib/components/Toolbar/Toolbar.scss +5 -23
- package/src/lib/components/Toolbar/ToolbarGroup.jsx +10 -3
- package/src/lib/components/Toolbar/ToolbarItem.jsx +10 -3
- package/src/lib/index.js +4 -9
- package/src/lib/provider/index.js +2 -1
- package/src/lib/provider/withGlobalProps.jsx +21 -0
- package/src/lib/styles/settings/_breakpoints.scss +2 -2
- package/src/lib/styles/theme-constants/_breakpoints.scss +2 -2
- package/src/lib/styles/tools/_spacing.scss +2 -6
- package/src/lib/theme.scss +19 -18
- package/src/lib/components/List/List.jsx +0 -73
- package/src/lib/components/List/List.scss +0 -53
- package/src/lib/components/List/ListItem.jsx +0 -32
- package/src/lib/components/List/README.mdx +0 -114
- package/src/lib/components/List/_theme.scss +0 -1
- package/src/lib/components/List/index.js +0 -2
- package/src/lib/components/Media/Media.jsx +0 -36
- package/src/lib/components/Media/Media.scss +0 -16
- package/src/lib/components/Media/MediaBody.jsx +0 -32
- package/src/lib/components/Media/MediaObject.jsx +0 -32
- package/src/lib/components/Media/README.mdx +0 -63
- package/src/lib/components/Media/index.js +0 -3
- package/src/lib/provider/withProviderContext.jsx +0 -32
@@ -0,0 +1,46 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import React from 'react';
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
|
+
import withForwardedRef from '../withForwardedRef';
|
5
|
+
import styles from './Popover.scss';
|
6
|
+
|
7
|
+
export const PopoverWrapper = ({
|
8
|
+
children,
|
9
|
+
id,
|
10
|
+
tag: Tag,
|
11
|
+
...restProps
|
12
|
+
}) => (
|
13
|
+
<Tag
|
14
|
+
className={styles.wrapper}
|
15
|
+
id={id}
|
16
|
+
{...restProps}
|
17
|
+
>
|
18
|
+
{children}
|
19
|
+
</Tag>
|
20
|
+
);
|
21
|
+
|
22
|
+
PopoverWrapper.defaultProps = {
|
23
|
+
id: undefined,
|
24
|
+
tag: 'div',
|
25
|
+
};
|
26
|
+
|
27
|
+
PopoverWrapper.propTypes = {
|
28
|
+
/**
|
29
|
+
* Popover reference and the Popover itself.
|
30
|
+
*/
|
31
|
+
children: PropTypes.node.isRequired,
|
32
|
+
/**
|
33
|
+
* ID of the root HTML element.
|
34
|
+
*/
|
35
|
+
id: PropTypes.string,
|
36
|
+
/**
|
37
|
+
* HTML tag to render. Can be any valid HTML tag of your choice, usually a
|
38
|
+
* [block-level element](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements).
|
39
|
+
*/
|
40
|
+
tag: PropTypes.string,
|
41
|
+
};
|
42
|
+
|
43
|
+
export const PopoverWrapperWithContext = withForwardedRef(withGlobalProps(PopoverWrapper, 'PopoverWrapper'));
|
44
|
+
|
45
|
+
export default PopoverWrapperWithContext;
|
46
|
+
|
@@ -0,0 +1,333 @@
|
|
1
|
+
---
|
2
|
+
name: Popover
|
3
|
+
menu: 'Miscellaneous'
|
4
|
+
route: /components/popover
|
5
|
+
---
|
6
|
+
|
7
|
+
# Popover
|
8
|
+
|
9
|
+
import {
|
10
|
+
useFloating,
|
11
|
+
autoUpdate,
|
12
|
+
flip,
|
13
|
+
} from '@floating-ui/react-dom'
|
14
|
+
import {
|
15
|
+
Playground,
|
16
|
+
Props,
|
17
|
+
} from 'docz'
|
18
|
+
import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
|
19
|
+
import { Button } from '../Button/Button'
|
20
|
+
import { ButtonGroup } from '../ButtonGroup/ButtonGroup'
|
21
|
+
import { SelectField } from '../SelectField/SelectField'
|
22
|
+
import { Toolbar } from '../Toolbar/Toolbar'
|
23
|
+
import { ToolbarItem } from '../Toolbar/ToolbarItem'
|
24
|
+
import { Popover } from './Popover'
|
25
|
+
import { PopoverWrapper } from './PopoverWrapper'
|
26
|
+
|
27
|
+
Popover displays additional information without interrupting user flow.
|
28
|
+
|
29
|
+
## Basic Usage
|
30
|
+
|
31
|
+
To implement the Popover component, you need to import it first:
|
32
|
+
|
33
|
+
```js
|
34
|
+
import { Popover, PopoverWrapper } from '@react-ui-org/react-ui';
|
35
|
+
```
|
36
|
+
|
37
|
+
And use it:
|
38
|
+
|
39
|
+
<Playground>
|
40
|
+
{() => {
|
41
|
+
const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);
|
42
|
+
// All inline styles in this example are for demonstration purposes only.
|
43
|
+
return (
|
44
|
+
<div
|
45
|
+
style={{
|
46
|
+
display: 'grid',
|
47
|
+
placeContent: 'center',
|
48
|
+
minWidth: '20rem',
|
49
|
+
minHeight: '10rem',
|
50
|
+
}}
|
51
|
+
>
|
52
|
+
<PopoverWrapper>
|
53
|
+
<Button
|
54
|
+
aria-describedby={isPopoverOpen ? 'my-popover' : undefined}
|
55
|
+
label="Want to see a popover? Click me!"
|
56
|
+
onClick={() => setIsPopoverOpen(!isPopoverOpen)}
|
57
|
+
/>
|
58
|
+
{isPopoverOpen && (
|
59
|
+
<Popover id="my-popover">
|
60
|
+
Hello there!
|
61
|
+
</Popover>
|
62
|
+
)}
|
63
|
+
</PopoverWrapper>
|
64
|
+
</div>
|
65
|
+
);
|
66
|
+
}}
|
67
|
+
</Playground>
|
68
|
+
|
69
|
+
See [API](#api) for all available options.
|
70
|
+
|
71
|
+
## Placement
|
72
|
+
|
73
|
+
Available placements are: top, right, bottom, and left. Additionally, all basic
|
74
|
+
placements can be aligned to the center (default, no suffix), start (e.g.
|
75
|
+
`top-start`), or end (e.g. `bottom-end`). Check Popover [API](#api) for the
|
76
|
+
complete list of accepted values.
|
77
|
+
|
78
|
+
<Playground>
|
79
|
+
{() => {
|
80
|
+
const [align, setAlign] = React.useState('');
|
81
|
+
// All inline styles in this example are for demonstration purposes only.
|
82
|
+
return (
|
83
|
+
<>
|
84
|
+
<Toolbar align="baseline">
|
85
|
+
<ToolbarItem>
|
86
|
+
<span id="alignment-options-label">Alignment:</span>
|
87
|
+
</ToolbarItem>
|
88
|
+
<ToolbarItem>
|
89
|
+
<ButtonGroup aria-labelledby="alignment-options-label">
|
90
|
+
<Button
|
91
|
+
color={align === '-start' ? 'dark' : 'primary'}
|
92
|
+
label="start"
|
93
|
+
onClick={() => setAlign('-start')}
|
94
|
+
/>
|
95
|
+
<Button
|
96
|
+
color={align === '' ? 'dark' : 'primary'}
|
97
|
+
label="center"
|
98
|
+
onClick={() => setAlign('')}
|
99
|
+
/>
|
100
|
+
<Button
|
101
|
+
color={align === '-end' ? 'dark' : 'primary'}
|
102
|
+
label="end"
|
103
|
+
onClick={() => setAlign('-end')}
|
104
|
+
/>
|
105
|
+
</ButtonGroup>
|
106
|
+
</ToolbarItem>
|
107
|
+
</Toolbar>
|
108
|
+
<div
|
109
|
+
style={{
|
110
|
+
display: 'grid',
|
111
|
+
placeContent: 'center',
|
112
|
+
minWidth: '20rem',
|
113
|
+
minHeight: '15rem',
|
114
|
+
}}
|
115
|
+
>
|
116
|
+
<PopoverWrapper>
|
117
|
+
<Placeholder bordered aria-describedby="my-popover-top">
|
118
|
+
Popovers
|
119
|
+
<br />
|
120
|
+
all day long…
|
121
|
+
</Placeholder>
|
122
|
+
<Popover id="my-popover-top" placement={`top${align}`}>
|
123
|
+
Top side
|
124
|
+
</Popover>
|
125
|
+
<Popover id="my-popover-right" placement={`right${align}`}>
|
126
|
+
Right side
|
127
|
+
</Popover>
|
128
|
+
<Popover id="my-popover-bottom" placement={`bottom${align}`}>
|
129
|
+
Bottom side
|
130
|
+
</Popover>
|
131
|
+
<Popover id="my-popover-left" placement={`left${align}`}>
|
132
|
+
Left side
|
133
|
+
</Popover>
|
134
|
+
</PopoverWrapper>
|
135
|
+
</div>
|
136
|
+
</>
|
137
|
+
);
|
138
|
+
}}
|
139
|
+
</Playground>
|
140
|
+
|
141
|
+
## PopoverWrapper
|
142
|
+
|
143
|
+
PopoverWrapper is an optional wrapper to make positioning of Popover even
|
144
|
+
easier.
|
145
|
+
|
146
|
+
By default, Popover is placed relative to the closest parent element with
|
147
|
+
`position: relative` or `position: absolute`. Maybe you already have one of
|
148
|
+
these in your CSS. PopoverWrapper is here for situations when you don't.
|
149
|
+
|
150
|
+
```jsx
|
151
|
+
<PopoverWrapper>
|
152
|
+
<Button
|
153
|
+
aria-describedby={isPopoverOpen ? 'my-popover' : undefined}
|
154
|
+
label="Want to see a popover? Click me!"
|
155
|
+
onClick={() => setIsPopoverOpen(!isPopoverOpen)}
|
156
|
+
/>
|
157
|
+
{isPopoverOpen && <Popover id="my-popover">Hello there!</Popover>}
|
158
|
+
</PopoverWrapper>
|
159
|
+
```
|
160
|
+
|
161
|
+
How do you know you may need PopoverWrapper?
|
162
|
+
|
163
|
+
- You are **not** rendering Popover in a React portal.
|
164
|
+
- You are using Popover in a complex layout and it does not pop up where you
|
165
|
+
need it.
|
166
|
+
- You are using Floating UI with `absolute` positioning strategy (see
|
167
|
+
[Advanced Positioning](#advanced-positioning) below) and your Popover keeps to
|
168
|
+
be misplaced.
|
169
|
+
- You have no idea what CSS `position` is and just want to get it working.
|
170
|
+
|
171
|
+
To sum it up, usually you will need either PopoverWrapper around your content or
|
172
|
+
`position: [ relative | absolute ]` somewhere in your CSS (but you never need
|
173
|
+
both!). Nevertheless, in the simplest situations, like in a single-column page
|
174
|
+
layout, you may not need either of these at all.
|
175
|
+
|
176
|
+
Head to PopoverWrapper [API](#popoverwrapper-api) for all available options.
|
177
|
+
|
178
|
+
## Advanced Positioning
|
179
|
+
|
180
|
+
While the basic setup can be sufficient in some scenarios, dropping a Popover
|
181
|
+
usually won't be so easy. To handle all tricky situations and edge cases
|
182
|
+
automatically, including smart position updates to ensure Popover visibility,
|
183
|
+
we recommend to involve an external library designed specifically for this
|
184
|
+
purpose.
|
185
|
+
|
186
|
+
ℹ️ The following example is using external library [Floating UI]. To use
|
187
|
+
Floating UI, install it first:
|
188
|
+
|
189
|
+
```shell
|
190
|
+
npm install --save @floating-ui/react-dom
|
191
|
+
```
|
192
|
+
|
193
|
+
And import it along with Popover, e.g.:
|
194
|
+
|
195
|
+
```js
|
196
|
+
import {
|
197
|
+
useFloating,
|
198
|
+
autoUpdate,
|
199
|
+
flip,
|
200
|
+
} from '@floating-ui/react-dom';
|
201
|
+
import { Popover } from '@react-ui-org/react-ui';
|
202
|
+
```
|
203
|
+
|
204
|
+
As opposed to the [basic setup](#placement), Popover will be placed according to
|
205
|
+
its triggering component (`reference`), but still recognizing the closest parent
|
206
|
+
element with `position: relative` or `position: absolute` if there is any.
|
207
|
+
|
208
|
+
Popover reacts on the `forwardedRef` option, necessary for advanced positioning:
|
209
|
+
when `forwardedRef` is set, Popover resets its built-in positioning and relies
|
210
|
+
on provided `style`.
|
211
|
+
|
212
|
+
👉 Please consult [Floating UI] documentation to understand how it works and to
|
213
|
+
get an idea of all possible cases you may need to cover.
|
214
|
+
|
215
|
+
🖱 Try scrolling the example to see how Popover placement is updated.
|
216
|
+
|
217
|
+
<Playground>
|
218
|
+
{() => {
|
219
|
+
const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);
|
220
|
+
const [placement, setPlacement] = React.useState('top');
|
221
|
+
const {
|
222
|
+
x,
|
223
|
+
y,
|
224
|
+
reference,
|
225
|
+
floating,
|
226
|
+
placement: finalPlacement,
|
227
|
+
strategy,
|
228
|
+
} = useFloating({
|
229
|
+
placement,
|
230
|
+
middleware: [flip()],
|
231
|
+
whileElementsMounted: autoUpdate,
|
232
|
+
});
|
233
|
+
const placementOptions = [
|
234
|
+
'top',
|
235
|
+
'top-start',
|
236
|
+
'top-end',
|
237
|
+
'right',
|
238
|
+
'right-start',
|
239
|
+
'right-end',
|
240
|
+
'bottom',
|
241
|
+
'bottom-start',
|
242
|
+
'bottom-end',
|
243
|
+
'left',
|
244
|
+
'left-start',
|
245
|
+
'left-end',
|
246
|
+
];
|
247
|
+
// All inline styles in this example EXCEPT Popover `style` are for
|
248
|
+
// demonstration purposes only.
|
249
|
+
return (
|
250
|
+
<>
|
251
|
+
<Toolbar>
|
252
|
+
<ToolbarItem>
|
253
|
+
<SelectField
|
254
|
+
label="Suggested placement:"
|
255
|
+
onChange={e => setPlacement(e.target.value)}
|
256
|
+
options={placementOptions.map((el) => ({
|
257
|
+
label: el,
|
258
|
+
value: el,
|
259
|
+
}))}
|
260
|
+
value={placement}
|
261
|
+
/>
|
262
|
+
</ToolbarItem>
|
263
|
+
<ToolbarItem>
|
264
|
+
<div className="mb-2">Final placement:</div>
|
265
|
+
<code>{finalPlacement}</code>
|
266
|
+
</ToolbarItem>
|
267
|
+
</Toolbar>
|
268
|
+
<div
|
269
|
+
style={{
|
270
|
+
width: '40rem',
|
271
|
+
maxWidth: '100%',
|
272
|
+
height: '10rem',
|
273
|
+
overflow: 'auto',
|
274
|
+
}}
|
275
|
+
>
|
276
|
+
<div
|
277
|
+
style={{
|
278
|
+
position: 'relative',
|
279
|
+
width: '60rem',
|
280
|
+
height: '20rem',
|
281
|
+
paddingBlock: '7rem',
|
282
|
+
textAlign: 'center',
|
283
|
+
}}
|
284
|
+
>
|
285
|
+
<Button
|
286
|
+
aria-describedby={isPopoverOpen ? 'my-advanced-popover' : undefined}
|
287
|
+
forwardedRef={reference}
|
288
|
+
label="Trigger Popover"
|
289
|
+
onClick={() => setIsPopoverOpen(!isPopoverOpen)}
|
290
|
+
/>
|
291
|
+
{isPopoverOpen && (
|
292
|
+
<Popover
|
293
|
+
forwardedRef={floating}
|
294
|
+
id="my-advanced-popover"
|
295
|
+
placement={finalPlacement}
|
296
|
+
style={{
|
297
|
+
position: strategy,
|
298
|
+
top: y ? y : '',
|
299
|
+
left: x ? x : '',
|
300
|
+
}}
|
301
|
+
>
|
302
|
+
Auto-flipping Popover
|
303
|
+
</Popover>
|
304
|
+
)}
|
305
|
+
</div>
|
306
|
+
</div>
|
307
|
+
</>
|
308
|
+
);
|
309
|
+
}}
|
310
|
+
</Playground>
|
311
|
+
|
312
|
+
## API
|
313
|
+
|
314
|
+
<Props table of={Popover} />
|
315
|
+
|
316
|
+
### PopoverWrapper API
|
317
|
+
|
318
|
+
<Props table of={PopoverWrapper} />
|
319
|
+
|
320
|
+
## Theming
|
321
|
+
|
322
|
+
| Custom Property | Description |
|
323
|
+
|------------------------------------------------------|--------------------------------------------------------------|
|
324
|
+
| `--rui-Popover__width` | Popover width |
|
325
|
+
| `--rui-Popover__padding` | Popover padding |
|
326
|
+
| `--rui-Popover__border-width` | Border width |
|
327
|
+
| `--rui-Popover__border-color` | Border color |
|
328
|
+
| `--rui-Popover__border-radius` | Corner radius |
|
329
|
+
| `--rui-Popover__color` | Text color |
|
330
|
+
| `--rui-Popover__background-color` | Background color |
|
331
|
+
| `--rui-Popover__box-shadow` | Popover box shadow |
|
332
|
+
|
333
|
+
[Floating UI]: https://floating-ui.com/docs/react-dom
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export default (placement, styles) => {
|
2
|
+
const alignment = placement.split('-')[1];
|
3
|
+
|
4
|
+
if (alignment === 'start') {
|
5
|
+
return styles.isRootAtStart;
|
6
|
+
}
|
7
|
+
|
8
|
+
if (alignment === 'end') {
|
9
|
+
return styles.isRootAtEnd;
|
10
|
+
}
|
11
|
+
|
12
|
+
return styles.isRootAtCenter;
|
13
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export default (placement, styles) => {
|
2
|
+
const side = placement.split('-')[0];
|
3
|
+
|
4
|
+
if (side === 'top') {
|
5
|
+
return styles.isRootAtTop;
|
6
|
+
}
|
7
|
+
|
8
|
+
if (side === 'right') {
|
9
|
+
return styles.isRootAtRight;
|
10
|
+
}
|
11
|
+
|
12
|
+
if (side === 'bottom') {
|
13
|
+
return styles.isRootAtBottom;
|
14
|
+
}
|
15
|
+
|
16
|
+
return styles.isRootAtLeft;
|
17
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// 1. Height must be linked to width to create 90-degree angle.
|
2
|
+
|
3
|
+
@use "sass:math";
|
4
|
+
|
5
|
+
$width: var(--rui-Popover__width);
|
6
|
+
$padding: var(--rui-Popover__padding);
|
7
|
+
$border-width: var(--rui-Popover__border-width);
|
8
|
+
$border-color: var(--rui-Popover__border-color);
|
9
|
+
$border-radius: var(--rui-Popover__border-radius);
|
10
|
+
$color: var(--rui-Popover__color);
|
11
|
+
$background-color: var(--rui-Popover__background-color);
|
12
|
+
$box-shadow: var(--rui-Popover__box-shadow);
|
13
|
+
|
14
|
+
$arrow-width: 1rem;
|
15
|
+
$arrow-height: math.div($arrow-width, 2); // 1.
|
16
|
+
$arrow-corner-offset: 0.75rem;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, { useContext } from 'react';
|
3
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
4
|
import { classNames } from '../../utils/classNames';
|
5
5
|
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
|
6
6
|
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
@@ -184,6 +184,6 @@ Radio.propTypes = {
|
|
184
184
|
]),
|
185
185
|
};
|
186
186
|
|
187
|
-
export const
|
187
|
+
export const RadioWithGlobalProps = withGlobalProps(Radio, 'Radio');
|
188
188
|
|
189
|
-
export default
|
189
|
+
export default RadioWithGlobalProps;
|
@@ -20,10 +20,7 @@ import Button from '../Button'
|
|
20
20
|
import Radio from '../Radio'
|
21
21
|
import { Toolbar } from '../Toolbar/Toolbar'
|
22
22
|
import { ToolbarItem } from '../Toolbar/ToolbarItem'
|
23
|
-
import {
|
24
|
-
ScrollViewWithContext as ScrollView,
|
25
|
-
ScrollView as ParsableScrollView,
|
26
|
-
} from './ScrollView'
|
23
|
+
import { ScrollView } from './ScrollView'
|
27
24
|
|
28
25
|
## Basic Usage
|
29
26
|
|
@@ -433,7 +430,7 @@ we use in the [Modal](/components/modal#scrolling-long-content) component.
|
|
433
430
|
|
434
431
|
## API
|
435
432
|
|
436
|
-
<Props table of={
|
433
|
+
<Props table of={ScrollView} />
|
437
434
|
|
438
435
|
## Theming
|
439
436
|
|
@@ -1,11 +1,15 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, {
|
3
|
+
useContext,
|
3
4
|
useEffect,
|
4
5
|
useLayoutEffect,
|
5
6
|
useRef,
|
6
7
|
useState,
|
7
8
|
} from 'react';
|
8
|
-
import {
|
9
|
+
import {
|
10
|
+
RUIContext,
|
11
|
+
withGlobalProps,
|
12
|
+
} from '../../provider';
|
9
13
|
import { classNames } from '../../utils/classNames';
|
10
14
|
import { getElementsPositionDifference } from './_helpers/getElementsPositionDifference';
|
11
15
|
import { useLoadResize } from './_hooks/useLoadResizeHook';
|
@@ -34,9 +38,10 @@ export const ScrollView = (props) => {
|
|
34
38
|
scrollbar,
|
35
39
|
shadowColor,
|
36
40
|
shadowSize,
|
37
|
-
translations,
|
38
41
|
} = props;
|
39
42
|
|
43
|
+
const { translations } = useContext(RUIContext);
|
44
|
+
|
40
45
|
const [isAutoScrollInProgress, setIsAutoScrollInProgress] = useState(false);
|
41
46
|
const [isScrolledAtStart, setIsScrolledAtStart] = useState(false);
|
42
47
|
const [isScrolledAtEnd, setIsScrolledAtEnd] = useState(false);
|
@@ -237,7 +242,7 @@ export const ScrollView = (props) => {
|
|
237
242
|
'prev',
|
238
243
|
arrowsScrollStep,
|
239
244
|
)}
|
240
|
-
title={translations.previous}
|
245
|
+
title={translations.ScrollView.previous}
|
241
246
|
id={id && `${id}__arrowPrevButton`}
|
242
247
|
>
|
243
248
|
{customPrevArrow || (
|
@@ -254,7 +259,7 @@ export const ScrollView = (props) => {
|
|
254
259
|
'next',
|
255
260
|
arrowsScrollStep,
|
256
261
|
)}
|
257
|
-
title={translations.next}
|
262
|
+
title={translations.ScrollView.next}
|
258
263
|
id={id && `${id}__arrowNextButton`}
|
259
264
|
>
|
260
265
|
{customNextArrow || (
|
@@ -374,15 +379,8 @@ ScrollView.propTypes = {
|
|
374
379
|
* mode.
|
375
380
|
*/
|
376
381
|
shadowSize: PropTypes.string,
|
377
|
-
/**
|
378
|
-
* Translations required by the component.
|
379
|
-
*/
|
380
|
-
translations: PropTypes.shape({
|
381
|
-
next: PropTypes.string.isRequired,
|
382
|
-
previous: PropTypes.string.isRequired,
|
383
|
-
}).isRequired,
|
384
382
|
};
|
385
383
|
|
386
|
-
export const
|
384
|
+
export const ScrollViewWithGlobalProps = withGlobalProps(ScrollView, 'ScrollView');
|
387
385
|
|
388
|
-
export default
|
386
|
+
export default ScrollViewWithGlobalProps;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, { useContext } from 'react';
|
3
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
4
|
import { classNames } from '../../utils/classNames';
|
5
5
|
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
6
6
|
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
|
@@ -215,6 +215,6 @@ SelectField.propTypes = {
|
|
215
215
|
variant: PropTypes.oneOf(['filled', 'outline']),
|
216
216
|
};
|
217
217
|
|
218
|
-
export const
|
218
|
+
export const SelectFieldWithGlobalProps = withForwardedRef(withGlobalProps(SelectField, 'SelectField'));
|
219
219
|
|
220
|
-
export default
|
220
|
+
export default SelectFieldWithGlobalProps;
|
@@ -77,7 +77,7 @@ See [API](#api) for all available options.
|
|
77
77
|
|
78
78
|
- Tables are **good for displaying complex tabular data.** For simpler data sets
|
79
79
|
or even plain key-value pairs, consider using the
|
80
|
-
[
|
80
|
+
[Grid](/components/grid) component.
|
81
81
|
|
82
82
|
- Tables make **lots of information easier to scan and compare.** If you have
|
83
83
|
fewer sections and want to emphasize each group more, consider using
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
4
|
import Button from '../Button';
|
5
5
|
import styles from './Table.scss';
|
6
6
|
|
@@ -145,6 +145,6 @@ Table.propTypes = {
|
|
145
145
|
}),
|
146
146
|
};
|
147
147
|
|
148
|
-
export const
|
148
|
+
export const TableWithGlobalProps = withGlobalProps(Table, 'Table');
|
149
149
|
|
150
|
-
export default
|
150
|
+
export default TableWithGlobalProps;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
4
|
import styles from './Tabs.scss';
|
5
5
|
|
6
6
|
export const Tabs = ({
|
@@ -33,6 +33,6 @@ Tabs.propTypes = {
|
|
33
33
|
id: PropTypes.string,
|
34
34
|
};
|
35
35
|
|
36
|
-
export const
|
36
|
+
export const TabsWithGlobalProps = withGlobalProps(Tabs, 'Tabs');
|
37
37
|
|
38
|
-
export default
|
38
|
+
export default TabsWithGlobalProps;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
4
|
import { classNames } from '../../utils/classNames';
|
5
5
|
import styles from './TabsItem.scss';
|
6
6
|
|
@@ -83,6 +83,6 @@ TabsItem.propTypes = {
|
|
83
83
|
onClick: PropTypes.func,
|
84
84
|
};
|
85
85
|
|
86
|
-
export const
|
86
|
+
export const TabsItemWithGlobalProps = withGlobalProps(TabsItem, 'TabsItem');
|
87
87
|
|
88
|
-
export default
|
88
|
+
export default TabsItemWithGlobalProps;
|
@@ -154,7 +154,7 @@ will override automatic break point selection in `auto` mode when present.
|
|
154
154
|
<span id="word-wrapping-options-label">Word wrapping:</span>
|
155
155
|
</ToolbarItem>
|
156
156
|
<ToolbarItem>
|
157
|
-
<ButtonGroup aria-labelledby="
|
157
|
+
<ButtonGroup aria-labelledby="word-wrapping-options-label">
|
158
158
|
<Button
|
159
159
|
color={wordWrapping === 'normal' ? 'dark' : 'primary'}
|
160
160
|
label="normal"
|
@@ -178,7 +178,7 @@ will override automatic break point selection in `auto` mode when present.
|
|
178
178
|
<span id="hyphens-options-label">Hyphens:</span>
|
179
179
|
</ToolbarItem>
|
180
180
|
<ToolbarItem>
|
181
|
-
<ButtonGroup aria-labelledby="
|
181
|
+
<ButtonGroup aria-labelledby="hyphens-options-label">
|
182
182
|
<Button
|
183
183
|
color={hyphens === 'none' ? 'dark' : 'primary'}
|
184
184
|
label="none"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
4
|
import { classNames } from '../../utils/classNames';
|
5
5
|
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
|
6
6
|
import { getRootClampClassName } from './_helpers/getRootClampClassName';
|
@@ -75,6 +75,6 @@ Text.propTypes = {
|
|
75
75
|
wordWrapping: PropTypes.oneOf(['normal', 'long-words', 'anywhere']),
|
76
76
|
};
|
77
77
|
|
78
|
-
export const
|
78
|
+
export const TextWithGlobalProps = withGlobalProps(Text, 'Text');
|
79
79
|
|
80
|
-
export default
|
80
|
+
export default TextWithGlobalProps;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, { useContext } from 'react';
|
3
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
4
|
import { classNames } from '../../utils/classNames';
|
5
5
|
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
6
6
|
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
|
@@ -202,6 +202,6 @@ TextArea.propTypes = {
|
|
202
202
|
variant: PropTypes.oneOf(['filled', 'outline']),
|
203
203
|
};
|
204
204
|
|
205
|
-
export const
|
205
|
+
export const TextAreaWithGlobalProps = withForwardedRef(withGlobalProps(TextArea, 'TextArea'));
|
206
206
|
|
207
|
-
export default
|
207
|
+
export default TextAreaWithGlobalProps;
|