@react-ui-org/react-ui 0.47.0 → 0.49.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/lib.development.js +465 -93
- package/dist/lib.js +1 -1
- package/package.json +1 -1
- package/src/lib/components/Alert/Alert.jsx +3 -0
- package/src/lib/components/Alert/Alert.scss +10 -10
- package/src/lib/components/Alert/README.mdx +18 -2
- package/src/lib/components/Alert/index.js +1 -1
- package/src/lib/components/Badge/Badge.jsx +4 -8
- package/src/lib/components/Badge/Badge.scss +21 -21
- package/src/lib/components/Badge/README.mdx +15 -1
- package/src/lib/components/Badge/index.js +1 -1
- package/src/lib/components/Button/Button.jsx +23 -34
- package/src/lib/components/Button/README.mdx +21 -7
- package/src/lib/components/Button/_base.scss +20 -20
- package/src/lib/components/Button/_priorities.scss +35 -35
- package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +7 -7
- package/src/lib/components/Button/helpers/getRootPriorityClassName.js +3 -3
- package/src/lib/components/Button/index.js +1 -1
- package/src/lib/components/ButtonGroup/ButtonGroup.jsx +2 -8
- package/src/lib/components/ButtonGroup/README.mdx +18 -2
- package/src/lib/components/Card/Card.jsx +6 -10
- package/src/lib/components/Card/Card.scss +13 -13
- package/src/lib/components/Card/CardBody.jsx +6 -10
- package/src/lib/components/Card/CardFooter.jsx +6 -7
- package/src/lib/components/Card/README.mdx +21 -5
- package/src/lib/components/CheckboxField/CheckboxField.jsx +17 -44
- package/src/lib/components/CheckboxField/README.mdx +18 -6
- package/src/lib/components/CheckboxField/index.js +1 -1
- package/src/lib/components/FileInputField/FileInputField.jsx +20 -29
- package/src/lib/components/FileInputField/FileInputField.scss +3 -3
- package/src/lib/components/FileInputField/README.mdx +30 -28
- package/src/lib/components/FileInputField/index.js +1 -1
- package/src/lib/components/FormLayout/FormLayout.jsx +5 -9
- package/src/lib/components/FormLayout/FormLayout.scss +3 -3
- package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +4 -1
- package/src/lib/components/FormLayout/FormLayoutCustomField.scss +8 -8
- package/src/lib/components/FormLayout/README.mdx +28 -13
- package/src/lib/components/Grid/Grid.jsx +31 -35
- package/src/lib/components/Grid/Grid.scss +10 -15
- package/src/lib/components/Grid/GridSpan.jsx +5 -11
- package/src/lib/components/Grid/README.mdx +48 -36
- package/src/lib/components/Grid/_helpers/generateResponsiveCustomProperties.js +11 -3
- package/src/lib/components/Grid/_settings.scss +18 -0
- package/src/lib/components/Grid/_tools.scss +5 -5
- package/src/lib/components/Modal/Modal.jsx +147 -254
- package/src/lib/components/Modal/Modal.scss +7 -55
- package/src/lib/components/Modal/ModalBody.jsx +60 -0
- package/src/lib/components/Modal/ModalBody.scss +18 -0
- package/src/lib/components/Modal/ModalCloseButton.jsx +45 -0
- package/src/lib/components/Modal/ModalCloseButton.scss +18 -0
- package/src/lib/components/Modal/ModalContent.jsx +39 -0
- package/src/lib/components/Modal/ModalContent.scss +5 -0
- package/src/lib/components/Modal/ModalFooter.jsx +42 -0
- package/src/lib/components/Modal/ModalFooter.scss +35 -0
- package/src/lib/components/Modal/ModalHeader.jsx +44 -0
- package/src/lib/components/Modal/ModalHeader.scss +30 -0
- package/src/lib/components/Modal/ModalTitle.jsx +44 -0
- package/src/lib/components/Modal/ModalTitle.scss +10 -0
- package/src/lib/components/Modal/README.mdx +865 -195
- package/src/lib/components/Modal/_helpers/getJustifyClassName.js +19 -0
- package/src/lib/components/Modal/_helpers/getScrollingClassName.js +11 -0
- package/src/lib/components/Modal/_settings.scss +1 -5
- package/src/lib/components/Modal/_theme.scss +6 -0
- package/src/lib/components/Modal/index.js +7 -1
- package/src/lib/components/Paper/Paper.jsx +5 -9
- package/src/lib/components/Paper/Paper.scss +2 -2
- package/src/lib/components/Paper/README.mdx +15 -1
- package/src/lib/components/Paper/index.js +1 -1
- package/src/lib/components/Popover/Popover.jsx +14 -30
- package/src/lib/components/Popover/Popover.scss +7 -6
- package/src/lib/components/Popover/PopoverWrapper.jsx +5 -12
- package/src/lib/components/Popover/PopoverWrapper.scss +3 -0
- package/src/lib/components/Popover/README.mdx +32 -11
- package/src/lib/components/Popover/_theme.scss +1 -1
- package/src/lib/components/Radio/README.mdx +13 -6
- package/src/lib/components/Radio/Radio.jsx +39 -29
- package/src/lib/components/Radio/Radio.scss +3 -3
- package/src/lib/components/Radio/index.js +1 -1
- package/src/lib/components/ScrollView/README.mdx +165 -84
- package/src/lib/components/ScrollView/ScrollView.jsx +115 -117
- package/src/lib/components/ScrollView/ScrollView.scss +18 -16
- package/src/lib/components/ScrollView/index.js +1 -1
- package/src/lib/components/SelectField/README.mdx +83 -7
- package/src/lib/components/SelectField/SelectField.jsx +86 -61
- package/src/lib/components/SelectField/SelectField.scss +8 -8
- package/src/lib/components/SelectField/_components/Option/Option.jsx +46 -0
- package/src/lib/components/SelectField/_components/Option/index.js +1 -0
- package/src/lib/components/SelectField/index.js +1 -1
- package/src/lib/components/Table/README.mdx +25 -9
- package/src/lib/components/Table/Table.jsx +43 -101
- package/src/lib/components/Table/Table.scss +0 -24
- package/src/lib/components/Table/_components/TableBodyCell/TableBodyCell.jsx +46 -0
- package/src/lib/components/Table/_components/TableBodyCell/index.js +1 -0
- package/src/lib/components/Table/_components/TableCell.scss +25 -0
- package/src/lib/components/Table/_components/TableHeaderCell/TableHeaderCell.jsx +71 -0
- package/src/lib/components/Table/_components/TableHeaderCell/index.js +1 -0
- package/src/lib/components/Table/index.js +1 -1
- package/src/lib/components/Tabs/README.mdx +21 -3
- package/src/lib/components/Tabs/Tabs.jsx +6 -1
- package/src/lib/components/Tabs/TabsItem.jsx +3 -0
- package/src/lib/components/Tabs/TabsItem.scss +1 -2
- package/src/lib/components/Text/README.mdx +25 -7
- package/src/lib/components/Text/Text.jsx +3 -7
- package/src/lib/components/Text/Text.scss +6 -6
- package/src/lib/components/Text/_helpers/getRootClampClassName.js +2 -2
- package/src/lib/components/Text/_helpers/getRootHyphensClassName.js +2 -2
- package/src/lib/components/Text/_helpers/getRootWordWrappingClassName.js +2 -2
- package/src/lib/components/Text/index.js +1 -1
- package/src/lib/components/TextArea/README.mdx +34 -31
- package/src/lib/components/TextArea/TextArea.jsx +23 -63
- package/src/lib/components/TextArea/TextArea.scss +8 -8
- package/src/lib/components/TextArea/index.js +1 -1
- package/src/lib/components/TextField/README.mdx +56 -54
- package/src/lib/components/TextField/TextField.jsx +25 -52
- package/src/lib/components/TextField/TextField.scss +9 -9
- package/src/lib/components/TextField/index.js +1 -1
- package/src/lib/components/TextLink/README.mdx +13 -6
- package/src/lib/components/TextLink/TextLink.jsx +0 -10
- package/src/lib/components/TextLink/index.js +1 -1
- package/src/lib/components/Toggle/README.mdx +18 -6
- package/src/lib/components/Toggle/Toggle.jsx +18 -44
- package/src/lib/components/Toggle/index.js +1 -1
- package/src/lib/components/Toolbar/README.mdx +21 -6
- package/src/lib/components/Toolbar/Toolbar.jsx +9 -43
- package/src/lib/components/Toolbar/Toolbar.scss +24 -12
- package/src/lib/components/Toolbar/ToolbarGroup.jsx +7 -26
- package/src/lib/components/Toolbar/ToolbarItem.jsx +3 -7
- package/src/lib/components/Toolbar/_helpers/getAlignClassName.js +19 -0
- package/src/lib/components/Toolbar/_helpers/getJustifyClassName.js +16 -0
- package/src/lib/components/_helpers/getRootColorClassName.js +10 -10
- package/src/lib/components/_helpers/getRootSizeClassName.js +3 -3
- package/src/lib/components/_helpers/transferProps.js +1 -1
- package/src/lib/index.js +24 -16
- package/src/lib/provider/withGlobalProps.jsx +20 -3
- package/src/lib/styles/tools/form-fields/_box-field-layout.scss +15 -15
- package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +1 -1
- package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +9 -9
- package/src/lib/theme.scss +18 -26
- package/src/lib/translations/en.js +1 -1
- package/src/lib/components/Grid/_theme.scss +0 -11
- package/src/lib/components/ScrollView/_theme.scss +0 -2
- package/src/lib/components/withForwardedRef.jsx +0 -11
@@ -11,6 +11,7 @@ import {
|
|
11
11
|
withGlobalProps,
|
12
12
|
} from '../../provider';
|
13
13
|
import { classNames } from '../../utils/classNames';
|
14
|
+
import { transferProps } from '../_helpers/transferProps';
|
14
15
|
import { getElementsPositionDifference } from './_helpers/getElementsPositionDifference';
|
15
16
|
import { useLoadResize } from './_hooks/useLoadResizeHook';
|
16
17
|
import { useScrollPosition } from './_hooks/useScrollPositionHook';
|
@@ -21,23 +22,30 @@ import styles from './ScrollView.scss';
|
|
21
22
|
// every value less or equal to 1px as start/end.
|
22
23
|
const EDGE_DETECTION_INACCURACY_PX = 1;
|
23
24
|
|
24
|
-
export const ScrollView = (props) => {
|
25
|
+
export const ScrollView = React.forwardRef((props, ref) => {
|
25
26
|
const {
|
26
27
|
arrows,
|
27
|
-
arrowsColor,
|
28
28
|
arrowsScrollStep,
|
29
29
|
autoScroll,
|
30
30
|
children,
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
customStartShadowStyle,
|
31
|
+
endShadowBackground,
|
32
|
+
endShadowInitialOffset,
|
33
|
+
endShadowSize,
|
35
34
|
id,
|
36
35
|
debounce,
|
37
36
|
direction,
|
37
|
+
nextArrowColor,
|
38
|
+
nextArrowElement,
|
39
|
+
nextArrowInitialOffset,
|
40
|
+
prevArrowColor,
|
41
|
+
prevArrowElement,
|
42
|
+
prevArrowInitialOffset,
|
38
43
|
scrollbar,
|
39
|
-
|
40
|
-
|
44
|
+
shadows,
|
45
|
+
startShadowBackground,
|
46
|
+
startShadowInitialOffset,
|
47
|
+
startShadowSize,
|
48
|
+
...restProps
|
41
49
|
} = props;
|
42
50
|
|
43
51
|
const { translations } = useContext(RUIContext);
|
@@ -49,7 +57,8 @@ export const ScrollView = (props) => {
|
|
49
57
|
const scrollPositionStart = direction === 'horizontal' ? 'left' : 'top';
|
50
58
|
const scrollPositionEnd = direction === 'horizontal' ? 'right' : 'bottom';
|
51
59
|
const scrollViewContentEl = useRef(null);
|
52
|
-
const
|
60
|
+
const blankRef = useRef(null);
|
61
|
+
const scrollViewViewportEl = ref ?? blankRef;
|
53
62
|
|
54
63
|
const handleScrollViewState = (currentPosition) => {
|
55
64
|
const isScrolledAtStartActive = currentPosition[scrollPositionStart]
|
@@ -84,7 +93,7 @@ export const ScrollView = (props) => {
|
|
84
93
|
|
85
94
|
/**
|
86
95
|
* If autoScroll is enabled, it automatically scrolls viewport element to the end of the
|
87
|
-
*
|
96
|
+
* viewport when content is changed. It is performed only when viewport element is
|
88
97
|
* scrolled to the end of the viewport or when viewport element is in any position but
|
89
98
|
* autoScroll triggered by previous change is still in progress.
|
90
99
|
*/
|
@@ -156,43 +165,6 @@ export const ScrollView = (props) => {
|
|
156
165
|
[autoScroll, autoScrollChildrenKeys, autoScrollChildrenLength],
|
157
166
|
);
|
158
167
|
|
159
|
-
const setAlpha = (rgba, alpha) => ({
|
160
|
-
...rgba,
|
161
|
-
alpha,
|
162
|
-
});
|
163
|
-
|
164
|
-
const rgbaToString = (rgba) => (
|
165
|
-
`rgba(${rgba.red}, ${rgba.green}, ${rgba.blue}, ${rgba.alpha})`
|
166
|
-
);
|
167
|
-
|
168
|
-
const inlineStyle = (
|
169
|
-
scrollDirection,
|
170
|
-
customArrowsColor,
|
171
|
-
customShadowColor,
|
172
|
-
customShadowSize,
|
173
|
-
startShadowStyle,
|
174
|
-
endShadowStyle,
|
175
|
-
) => {
|
176
|
-
const shadowStartColor = rgbaToString(customShadowColor);
|
177
|
-
const shadowEndColor = rgbaToString(setAlpha(customShadowColor, 0));
|
178
|
-
|
179
|
-
/* eslint-disable sort-keys */
|
180
|
-
return {
|
181
|
-
'--rui-local-arrow-color': customArrowsColor || 'inherit',
|
182
|
-
'--rui-local-shadow-width': scrollDirection === 'horizontal' ? shadowSize : 'auto',
|
183
|
-
'--rui-local-shadow-height': scrollDirection === 'horizontal' ? 'auto' : shadowSize,
|
184
|
-
'--rui-local-start-shadow-background':
|
185
|
-
startShadowStyle.background
|
186
|
-
|| `linear-gradient(${direction === 'horizontal' ? 'to right' : 'to bottom'}, ${shadowStartColor}, ${shadowEndColor})`,
|
187
|
-
'--rui-local-start-shadow-box-shadow': startShadowStyle.boxShadow || 'none',
|
188
|
-
'--rui-local-end-shadow-background':
|
189
|
-
endShadowStyle.background
|
190
|
-
|| `linear-gradient(${direction === 'horizontal' ? 'to left' : 'to top'}, ${shadowStartColor}, ${shadowEndColor})`,
|
191
|
-
'--rui-local-end-shadow-box-shadow': endShadowStyle.boxShadow || 'none',
|
192
|
-
};
|
193
|
-
/* eslint-enable sort-keys */
|
194
|
-
};
|
195
|
-
|
196
168
|
const arrowHandler = (contentEl, viewportEl, scrollViewDirection, shiftDirection, step) => {
|
197
169
|
const offset = shiftDirection === 'next' ? step : -1 * step;
|
198
170
|
const differenceX = scrollViewDirection === 'horizontal' ? offset : 0;
|
@@ -203,6 +175,7 @@ export const ScrollView = (props) => {
|
|
203
175
|
|
204
176
|
return (
|
205
177
|
<div
|
178
|
+
{...transferProps(restProps)}
|
206
179
|
className={classNames(
|
207
180
|
styles.root,
|
208
181
|
isScrolledAtStart && styles.isRootScrolledAtStart,
|
@@ -210,31 +183,42 @@ export const ScrollView = (props) => {
|
|
210
183
|
!scrollbar && styles.hasRootScrollbarDisabled,
|
211
184
|
direction === 'horizontal' ? styles.isRootHorizontal : styles.isRootVertical,
|
212
185
|
)}
|
213
|
-
style={inlineStyle(
|
214
|
-
direction,
|
215
|
-
arrowsColor,
|
216
|
-
shadowColor,
|
217
|
-
shadowSize,
|
218
|
-
customStartShadowStyle,
|
219
|
-
customEndShadowStyle,
|
220
|
-
)}
|
221
186
|
id={id}
|
187
|
+
style={{
|
188
|
+
'--rui-local-end-shadow-background': endShadowBackground,
|
189
|
+
'--rui-local-end-shadow-direction': direction === 'horizontal' ? 'to left' : 'to top',
|
190
|
+
'--rui-local-end-shadow-initial-offset': endShadowInitialOffset,
|
191
|
+
'--rui-local-end-shadow-size': endShadowSize,
|
192
|
+
'--rui-local-next-arrow-color': nextArrowColor,
|
193
|
+
'--rui-local-next-arrow-initial-offset': nextArrowInitialOffset,
|
194
|
+
'--rui-local-prev-arrow-color': prevArrowColor,
|
195
|
+
'--rui-local-prev-arrow-initial-offset': prevArrowInitialOffset,
|
196
|
+
'--rui-local-start-shadow-background': startShadowBackground,
|
197
|
+
'--rui-local-start-shadow-direction': direction === 'horizontal' ? 'to right' : 'to bottom',
|
198
|
+
'--rui-local-start-shadow-initial-offset': startShadowInitialOffset,
|
199
|
+
'--rui-local-start-shadow-size': startShadowSize,
|
200
|
+
}}
|
222
201
|
>
|
223
|
-
<div
|
202
|
+
<div
|
203
|
+
className={styles.viewport}
|
204
|
+
ref={scrollViewViewportEl}
|
205
|
+
>
|
224
206
|
<div
|
225
207
|
className={styles.content}
|
226
|
-
ref={scrollViewContentEl}
|
227
208
|
id={id && `${id}__content`}
|
209
|
+
ref={scrollViewContentEl}
|
228
210
|
>
|
229
211
|
{children}
|
230
212
|
</div>
|
231
213
|
</div>
|
232
|
-
|
214
|
+
{shadows && (
|
215
|
+
<div className={styles.scrollingShadows} aria-hidden />
|
216
|
+
)}
|
233
217
|
{arrows && (
|
234
218
|
<>
|
235
219
|
<button
|
236
|
-
type="button"
|
237
220
|
className={styles.arrowPrev}
|
221
|
+
id={id && `${id}__arrowPrevButton`}
|
238
222
|
onClick={() => arrowHandler(
|
239
223
|
scrollViewContentEl,
|
240
224
|
scrollViewViewportEl,
|
@@ -243,15 +227,15 @@ export const ScrollView = (props) => {
|
|
243
227
|
arrowsScrollStep,
|
244
228
|
)}
|
245
229
|
title={translations.ScrollView.previous}
|
246
|
-
|
230
|
+
type="button"
|
247
231
|
>
|
248
|
-
{
|
232
|
+
{prevArrowElement || (
|
249
233
|
<span className={styles.arrowIcon} aria-hidden />
|
250
234
|
)}
|
251
235
|
</button>
|
252
236
|
<button
|
253
|
-
type="button"
|
254
237
|
className={styles.arrowNext}
|
238
|
+
id={id && `${id}__arrowNextButton`}
|
255
239
|
onClick={() => arrowHandler(
|
256
240
|
scrollViewContentEl,
|
257
241
|
scrollViewViewportEl,
|
@@ -260,9 +244,9 @@ export const ScrollView = (props) => {
|
|
260
244
|
arrowsScrollStep,
|
261
245
|
)}
|
262
246
|
title={translations.ScrollView.next}
|
263
|
-
|
247
|
+
type="button"
|
264
248
|
>
|
265
|
-
{
|
249
|
+
{nextArrowElement || (
|
266
250
|
<span className={styles.arrowIcon} aria-hidden />
|
267
251
|
)}
|
268
252
|
</button>
|
@@ -270,29 +254,30 @@ export const ScrollView = (props) => {
|
|
270
254
|
)}
|
271
255
|
</div>
|
272
256
|
);
|
273
|
-
};
|
257
|
+
});
|
274
258
|
|
275
259
|
ScrollView.defaultProps = {
|
276
260
|
arrows: false,
|
277
|
-
arrowsColor: undefined,
|
278
261
|
arrowsScrollStep: 200,
|
279
262
|
autoScroll: 'off',
|
280
263
|
children: null,
|
281
|
-
customEndShadowStyle: {},
|
282
|
-
customNextArrow: null,
|
283
|
-
customPrevArrow: null,
|
284
|
-
customStartShadowStyle: {},
|
285
264
|
debounce: 50,
|
286
265
|
direction: 'vertical',
|
266
|
+
endShadowBackground: 'linear-gradient(var(--rui-local-end-shadow-direction), rgba(255 255 255 / 1), rgba(255 255 255 / 0))',
|
267
|
+
endShadowInitialOffset: '-1rem',
|
268
|
+
endShadowSize: '2em',
|
287
269
|
id: undefined,
|
270
|
+
nextArrowColor: undefined,
|
271
|
+
nextArrowElement: null,
|
272
|
+
nextArrowInitialOffset: '-0.5rem',
|
273
|
+
prevArrowColor: undefined,
|
274
|
+
prevArrowElement: null,
|
275
|
+
prevArrowInitialOffset: '-0.5rem',
|
288
276
|
scrollbar: true,
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
red: 255,
|
294
|
-
},
|
295
|
-
shadowSize: '2em',
|
277
|
+
shadows: true,
|
278
|
+
startShadowBackground: 'linear-gradient(var(--rui-local-start-shadow-direction), rgba(255 255 255 / 1), rgba(255 255 255 / 0))',
|
279
|
+
startShadowInitialOffset: '-1rem',
|
280
|
+
startShadowSize: '2em',
|
296
281
|
};
|
297
282
|
|
298
283
|
ScrollView.propTypes = {
|
@@ -300,21 +285,17 @@ ScrollView.propTypes = {
|
|
300
285
|
* If `true`, display the arrow controls.
|
301
286
|
*/
|
302
287
|
arrows: PropTypes.bool,
|
303
|
-
/**
|
304
|
-
* Text color of the arrow controls. Accepts any valid CSS color value.
|
305
|
-
*/
|
306
|
-
arrowsColor: PropTypes.string,
|
307
288
|
/**
|
308
289
|
* Portion to scroll by when the arrows are clicked, in px.
|
309
290
|
*/
|
310
291
|
arrowsScrollStep: PropTypes.number,
|
311
292
|
/**
|
312
|
-
*
|
313
|
-
*
|
293
|
+
* The auto-scroll mechanism requires having the `key` prop set for every child present in `children`
|
294
|
+
* because it detects changes of those keys. Without the keys, the auto-scroll will not work.
|
314
295
|
*
|
315
|
-
* Option `always` means
|
316
|
-
* Option `detectEnd` means
|
317
|
-
* and the user scrolled at the end of the viewport at the moment of the change.
|
296
|
+
* Option `always` means the auto-scroll scrolls to the end every time the content changes.
|
297
|
+
* Option `detectEnd` means the auto-scroll scrolls to the end only when the content is changed
|
298
|
+
* and the user has scrolled at the end of the viewport at the moment of the change.
|
318
299
|
*
|
319
300
|
* See https://reactjs.org/docs/lists-and-keys.html#keys
|
320
301
|
*/
|
@@ -324,35 +305,26 @@ ScrollView.propTypes = {
|
|
324
305
|
*/
|
325
306
|
children: PropTypes.node,
|
326
307
|
/**
|
327
|
-
*
|
328
|
-
*/
|
329
|
-
customEndShadowStyle: PropTypes.shape({
|
330
|
-
background: PropTypes.string,
|
331
|
-
boxShadow: PropTypes.string,
|
332
|
-
}),
|
333
|
-
/**
|
334
|
-
* Custom HTML or React Component to replace the default next-arrow control.
|
308
|
+
* Delay in ms before the display of arrows and scrolling shadows is evaluated during interaction.
|
335
309
|
*/
|
336
|
-
|
310
|
+
debounce: PropTypes.number,
|
337
311
|
/**
|
338
|
-
*
|
312
|
+
* Direction of scrolling.
|
339
313
|
*/
|
340
|
-
|
314
|
+
direction: PropTypes.oneOf(['horizontal', 'vertical']),
|
341
315
|
/**
|
342
|
-
* Custom
|
316
|
+
* Custom background of the end scrolling shadow. Can be a CSS gradient or an image `url()`.
|
343
317
|
*/
|
344
|
-
|
345
|
-
background: PropTypes.string,
|
346
|
-
boxShadow: PropTypes.string,
|
347
|
-
}),
|
318
|
+
endShadowBackground: PropTypes.string,
|
348
319
|
/**
|
349
|
-
*
|
320
|
+
* Initial offset of the end scrolling shadow (transitioned). If set, the end scrolling shadow slides in
|
321
|
+
* by this distance.
|
350
322
|
*/
|
351
|
-
|
323
|
+
endShadowInitialOffset: PropTypes.string,
|
352
324
|
/**
|
353
|
-
*
|
325
|
+
* Size of the end scrolling shadow. Accepts any valid CSS length value.
|
354
326
|
*/
|
355
|
-
|
327
|
+
endShadowSize: PropTypes.string,
|
356
328
|
/**
|
357
329
|
* ID of the root HTML element. It also serves as base for nested elements:
|
358
330
|
* * `<ID>__content`
|
@@ -360,25 +332,51 @@ ScrollView.propTypes = {
|
|
360
332
|
* * `<ID>__arrowNextButton`
|
361
333
|
*/
|
362
334
|
id: PropTypes.string,
|
335
|
+
/**
|
336
|
+
* Text color of the end arrow control. Accepts any valid CSS color value.
|
337
|
+
*/
|
338
|
+
nextArrowColor: PropTypes.string,
|
339
|
+
/**
|
340
|
+
* Custom HTML or React Component to replace the default next-arrow control.
|
341
|
+
*/
|
342
|
+
nextArrowElement: PropTypes.node,
|
343
|
+
/**
|
344
|
+
* Initial offset of the end arrow control (transitioned). If set, the next arrow slides in by this distance.
|
345
|
+
*/
|
346
|
+
nextArrowInitialOffset: PropTypes.string,
|
347
|
+
/**
|
348
|
+
* Text color of the start arrow control. Accepts any valid CSS color value.
|
349
|
+
*/
|
350
|
+
prevArrowColor: PropTypes.string,
|
351
|
+
/**
|
352
|
+
* Custom HTML or React Component to replace the default prev-arrow control.
|
353
|
+
*/
|
354
|
+
prevArrowElement: PropTypes.node,
|
355
|
+
/**
|
356
|
+
* Initial offset of the start arrow control (transitioned). If set, the prev arrow slides in by this distance.
|
357
|
+
*/
|
358
|
+
prevArrowInitialOffset: PropTypes.string,
|
363
359
|
/**
|
364
360
|
* If `false`, the system scrollbar will be hidden.
|
365
361
|
*/
|
366
362
|
scrollbar: PropTypes.bool,
|
367
363
|
/**
|
368
|
-
*
|
369
|
-
|
364
|
+
* If `true`, display scrolling shadows.
|
365
|
+
*/
|
366
|
+
shadows: PropTypes.bool,
|
367
|
+
/**
|
368
|
+
* Custom background of the start scrolling shadow. Can be a CSS gradient or an image `url()`.
|
369
|
+
*/
|
370
|
+
startShadowBackground: PropTypes.string,
|
371
|
+
/**
|
372
|
+
* Initial offset of the start scrolling shadow (transitioned). If set, the start scrolling shadow slides in
|
373
|
+
* by this distance.
|
370
374
|
*/
|
371
|
-
|
372
|
-
alpha: PropTypes.number.isRequired,
|
373
|
-
blue: PropTypes.number.isRequired,
|
374
|
-
green: PropTypes.number.isRequired,
|
375
|
-
red: PropTypes.number.isRequired,
|
376
|
-
}),
|
375
|
+
startShadowInitialOffset: PropTypes.string,
|
377
376
|
/**
|
378
|
-
* Size of scrolling
|
379
|
-
* mode.
|
377
|
+
* Size of the start scrolling shadow. Accepts any valid CSS length value.
|
380
378
|
*/
|
381
|
-
|
379
|
+
startShadowSize: PropTypes.string,
|
382
380
|
};
|
383
381
|
|
384
382
|
export const ScrollViewWithGlobalProps = withGlobalProps(ScrollView, 'ScrollView');
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// 1. Scrolling shadows are implemented as pseudo elements. This way we can customise them only
|
2
2
|
// with custom properties.
|
3
3
|
//
|
4
|
-
// 2. Stack scrolling shadows
|
4
|
+
// 2. Stack scrolling shadows over viewport content while keeping the content interactive.
|
5
5
|
//
|
6
6
|
// - `.scrollingShadows` is positioned absolutely over the `.root`, with auto `z-index` (this is
|
7
7
|
// important!), and with `overflow: hidden` to clip the shadows (ie. its pseudo elements).
|
@@ -27,7 +27,6 @@
|
|
27
27
|
@use "../../styles/tools/scrollbar";
|
28
28
|
@use "../../styles/tools/spacing";
|
29
29
|
@use "../../styles/tools/transition";
|
30
|
-
@use "theme";
|
31
30
|
|
32
31
|
$_arrow-inner-spacing: spacing.of(2);
|
33
32
|
$_arrow-outer-spacing: spacing.of(4);
|
@@ -45,6 +44,7 @@ $_arrow-outer-spacing: spacing.of(4);
|
|
45
44
|
width: 100%; // 2.
|
46
45
|
height: 100%; // 2.
|
47
46
|
overflow: hidden; // 2.
|
47
|
+
pointer-events: none; // 2.
|
48
48
|
|
49
49
|
&::before,
|
50
50
|
&::after {
|
@@ -54,20 +54,16 @@ $_arrow-outer-spacing: spacing.of(4);
|
|
54
54
|
position: absolute;
|
55
55
|
z-index: 2; // 2.
|
56
56
|
display: block;
|
57
|
-
width: var(--rui-local-shadow-width);
|
58
|
-
height: var(--rui-local-shadow-height);
|
59
57
|
visibility: hidden;
|
60
58
|
opacity: 0;
|
61
59
|
}
|
62
60
|
|
63
61
|
&::before {
|
64
62
|
background: var(--rui-local-start-shadow-background);
|
65
|
-
box-shadow: var(--rui-local-start-shadow-box-shadow);
|
66
63
|
}
|
67
64
|
|
68
65
|
&::after {
|
69
66
|
background: var(--rui-local-end-shadow-background);
|
70
|
-
box-shadow: var(--rui-local-end-shadow-box-shadow);
|
71
67
|
}
|
72
68
|
}
|
73
69
|
|
@@ -75,7 +71,6 @@ $_arrow-outer-spacing: spacing.of(4);
|
|
75
71
|
z-index: 1; // 2.
|
76
72
|
width: 100%;
|
77
73
|
scroll-behavior: smooth;
|
78
|
-
-webkit-overflow-scrolling: touch;
|
79
74
|
}
|
80
75
|
|
81
76
|
.arrowPrev,
|
@@ -89,7 +84,6 @@ $_arrow-outer-spacing: spacing.of(4);
|
|
89
84
|
display: flex;
|
90
85
|
align-items: center;
|
91
86
|
justify-content: center;
|
92
|
-
color: var(--rui-local-arrow-color);
|
93
87
|
visibility: hidden;
|
94
88
|
opacity: 0;
|
95
89
|
}
|
@@ -116,7 +110,8 @@ $_arrow-outer-spacing: spacing.of(4);
|
|
116
110
|
width: 100%;
|
117
111
|
padding-top: $_arrow-outer-spacing;
|
118
112
|
padding-bottom: $_arrow-inner-spacing;
|
119
|
-
|
113
|
+
color: var(--rui-local-prev-arrow-color);
|
114
|
+
transform: translateY(var(--rui-local-prev-arrow-initial-offset));
|
120
115
|
}
|
121
116
|
|
122
117
|
.isRootVertical .arrowPrev .arrowIcon {
|
@@ -130,7 +125,8 @@ $_arrow-outer-spacing: spacing.of(4);
|
|
130
125
|
width: 100%;
|
131
126
|
padding-top: $_arrow-inner-spacing;
|
132
127
|
padding-bottom: $_arrow-outer-spacing;
|
133
|
-
|
128
|
+
color: var(--rui-local-next-arrow-color);
|
129
|
+
transform: translateY(calc(-1 * var(--rui-local-next-arrow-initial-offset)));
|
134
130
|
}
|
135
131
|
|
136
132
|
.isRootHorizontal {
|
@@ -143,7 +139,7 @@ $_arrow-outer-spacing: spacing.of(4);
|
|
143
139
|
left: 0;
|
144
140
|
padding-right: $_arrow-inner-spacing;
|
145
141
|
padding-left: $_arrow-outer-spacing;
|
146
|
-
transform: translateX(
|
142
|
+
transform: translateX(var(--rui-local-prev-arrow-initial-offset));
|
147
143
|
}
|
148
144
|
|
149
145
|
.isRootHorizontal .arrowPrev .arrowIcon {
|
@@ -156,7 +152,7 @@ $_arrow-outer-spacing: spacing.of(4);
|
|
156
152
|
bottom: 0;
|
157
153
|
padding-right: $_arrow-outer-spacing;
|
158
154
|
padding-left: $_arrow-inner-spacing;
|
159
|
-
transform: translateX(calc(-1 *
|
155
|
+
transform: translateX(calc(-1 * var(--rui-local-next-arrow-initial-offset)));
|
160
156
|
}
|
161
157
|
|
162
158
|
.isRootHorizontal .arrowNext .arrowIcon {
|
@@ -167,16 +163,19 @@ $_arrow-outer-spacing: spacing.of(4);
|
|
167
163
|
.isRootVertical .scrollingShadows::after {
|
168
164
|
right: 0;
|
169
165
|
left: 0;
|
166
|
+
width: auto;
|
170
167
|
}
|
171
168
|
|
172
169
|
.isRootVertical .scrollingShadows::before {
|
173
170
|
top: 0;
|
174
|
-
|
171
|
+
height: var(--rui-local-start-shadow-size);
|
172
|
+
transform: translateY(var(--rui-local-start-shadow-initial-offset));
|
175
173
|
}
|
176
174
|
|
177
175
|
.isRootVertical .scrollingShadows::after {
|
178
176
|
bottom: 0;
|
179
|
-
|
177
|
+
height: var(--rui-local-end-shadow-size);
|
178
|
+
transform: translateY(calc(-1 * var(--rui-local-end-shadow-initial-offset)));
|
180
179
|
}
|
181
180
|
|
182
181
|
.isRootHorizontal .viewport {
|
@@ -193,16 +192,19 @@ $_arrow-outer-spacing: spacing.of(4);
|
|
193
192
|
.isRootHorizontal .scrollingShadows::after {
|
194
193
|
top: 0;
|
195
194
|
bottom: 0;
|
195
|
+
height: auto;
|
196
196
|
}
|
197
197
|
|
198
198
|
.isRootHorizontal .scrollingShadows::before {
|
199
199
|
left: 0;
|
200
|
-
|
200
|
+
width: var(--rui-local-start-shadow-size);
|
201
|
+
transform: translateX(var(--rui-local-start-shadow-initial-offset));
|
201
202
|
}
|
202
203
|
|
203
204
|
.isRootHorizontal .scrollingShadows::after {
|
204
205
|
right: 0;
|
205
|
-
|
206
|
+
width: var(--rui-local-end-shadow-size);
|
207
|
+
transform: translateX(calc(-1 * var(--rui-local-end-shadow-initial-offset)));
|
206
208
|
}
|
207
209
|
|
208
210
|
.isRootScrolledAtStart .scrollingShadows::before,
|
@@ -1 +1 @@
|
|
1
|
-
export { default } from './ScrollView';
|
1
|
+
export { default as ScrollView } from './ScrollView';
|
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
Playground,
|
13
13
|
Props,
|
14
14
|
} from 'docz'
|
15
|
-
import { SelectField } from '
|
15
|
+
import { SelectField } from '../..'
|
16
16
|
|
17
17
|
## Basic Usage
|
18
18
|
|
@@ -79,7 +79,7 @@ See [API](#api) for all available options.
|
|
79
79
|
entered.
|
80
80
|
|
81
81
|
- In case of a large amount of options, consider **grouping related items
|
82
|
-
together** by nesting them
|
82
|
+
together** by nesting them.
|
83
83
|
|
84
84
|
👉 We use the **native `select`** HTML element to improve user experience on
|
85
85
|
mobile devices by using the native select of the platform.
|
@@ -240,6 +240,70 @@ Full-width fields span the full width of a parent:
|
|
240
240
|
}}
|
241
241
|
</Playground>
|
242
242
|
|
243
|
+
## Grouping Related Options
|
244
|
+
|
245
|
+
For a large amount of options you can group related items together by nesting
|
246
|
+
them (implements the `optgroup` HTML element).
|
247
|
+
|
248
|
+
<Playground>
|
249
|
+
{() => {
|
250
|
+
const [crop, setCrop] = React.useState('apple');
|
251
|
+
const options = [
|
252
|
+
{
|
253
|
+
label: 'Fruits',
|
254
|
+
options: [
|
255
|
+
{
|
256
|
+
label: 'Apple',
|
257
|
+
value: 'apple',
|
258
|
+
},
|
259
|
+
{
|
260
|
+
label: 'Banana',
|
261
|
+
value: 'banana',
|
262
|
+
},
|
263
|
+
{
|
264
|
+
label: 'Grapefruit',
|
265
|
+
value: 'grapefruit',
|
266
|
+
},
|
267
|
+
],
|
268
|
+
},
|
269
|
+
{
|
270
|
+
label: 'Vegetables',
|
271
|
+
options: [
|
272
|
+
{
|
273
|
+
label: 'Beetroot',
|
274
|
+
value: 'beetroot',
|
275
|
+
},
|
276
|
+
{
|
277
|
+
label: 'Carrot',
|
278
|
+
value: 'carrot',
|
279
|
+
},
|
280
|
+
{
|
281
|
+
label: 'Tomato',
|
282
|
+
value: 'tomato',
|
283
|
+
},
|
284
|
+
],
|
285
|
+
},
|
286
|
+
];
|
287
|
+
return (
|
288
|
+
<>
|
289
|
+
<SelectField
|
290
|
+
label="Your favourite crop"
|
291
|
+
onChange={(e) => setCrop(e.target.value)}
|
292
|
+
options={options}
|
293
|
+
value={crop}
|
294
|
+
/>
|
295
|
+
<SelectField
|
296
|
+
label="Your favourite crop"
|
297
|
+
onChange={(e) => setCrop(e.target.value)}
|
298
|
+
options={options}
|
299
|
+
value={crop}
|
300
|
+
variant="filled"
|
301
|
+
/>
|
302
|
+
</>
|
303
|
+
);
|
304
|
+
}}
|
305
|
+
</Playground>
|
306
|
+
|
243
307
|
## Invisible Label
|
244
308
|
|
245
309
|
While it may be acceptable for login screens with just a few fields or for other
|
@@ -594,12 +658,22 @@ It's possible to disable just some options or the whole input.
|
|
594
658
|
}}
|
595
659
|
</Playground>
|
596
660
|
|
597
|
-
##
|
661
|
+
## Forwarding HTML Attributes
|
662
|
+
|
663
|
+
In addition to the options below in the [component's API](#api) section, you
|
664
|
+
can specify [React synthetic events] or you can **add whatever HTML attribute
|
665
|
+
you like.** All attributes that don't interfere with the API are forwarded to
|
666
|
+
the native HTML `<select>`. This enables making the component interactive and helps
|
667
|
+
to improve its accessibility.
|
668
|
+
|
669
|
+
👉 Refer to the MDN reference for the full list of supported attributes of the
|
670
|
+
[select] element.
|
598
671
|
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
672
|
+
## Forwarding ref
|
673
|
+
|
674
|
+
If you provide [ref], it is forwarded to the native HTML `<select>` element.
|
675
|
+
|
676
|
+
## API
|
603
677
|
|
604
678
|
<Props table of={SelectField} />
|
605
679
|
|
@@ -615,3 +689,5 @@ options. On top of that, the following options are available for SelectField.
|
|
615
689
|
| `--rui-FormField--box--select__option--disabled__color` | Text color of disabled SelectField options |
|
616
690
|
|
617
691
|
[React synthetic events]: https://reactjs.org/docs/events.html
|
692
|
+
[select]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#attributes
|
693
|
+
[ref]: https://reactjs.org/docs/refs-and-the-dom.html
|