@react-ui-org/react-ui 0.59.0 → 0.59.2
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/dist/react-ui.css +2 -2
- package/dist/react-ui.development.css +3 -3
- package/dist/react-ui.development.js +1 -1
- package/dist/react-ui.js +1 -1
- package/package.json +1 -1
- package/src/components/Alert/README.md +1 -1
- package/src/components/Card/Card.module.scss +1 -1
- package/src/components/Card/README.md +11 -10
- package/src/components/Card/_theme.scss +1 -0
- package/src/components/FileInputField/FileInputField.jsx +45 -7
- package/src/components/FileInputField/README.md +38 -0
- package/src/components/FormLayout/README.md +7 -6
- package/src/components/InputGroup/README.md +1 -1
- package/src/theme.scss +2 -2
package/package.json
CHANGED
@@ -32,7 +32,7 @@ See [API](#api) for all available options.
|
|
32
32
|
## Color Variants
|
33
33
|
|
34
34
|
To cover all possible needs of your project, Alert is available in colors from
|
35
|
-
[Feedback
|
35
|
+
[Feedback color collection](/docs/foundation/collections#colors).
|
36
36
|
|
37
37
|
### Success
|
38
38
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
flex-direction: column;
|
13
13
|
min-width: 0; // 1.
|
14
14
|
color: var(--rui-local-color);
|
15
|
-
border: theme.$border-width solid var(--rui-local-border-color,
|
15
|
+
border: theme.$border-width solid var(--rui-local-border-color, theme.$border-color);
|
16
16
|
border-radius: theme.$border-radius;
|
17
17
|
background-color: var(--rui-local-background-color, theme.$background-color);
|
18
18
|
}
|
@@ -289,16 +289,17 @@ Separate your card actions with CardFooter. See
|
|
289
289
|
|
290
290
|
### Common Theming Options
|
291
291
|
|
292
|
-
| Custom Property
|
293
|
-
|
294
|
-
| `--rui-Card__padding`
|
295
|
-
| `--rui-Card__border-width`
|
296
|
-
| `--rui-Card__border-
|
297
|
-
| `--rui-
|
298
|
-
| `--rui-
|
299
|
-
| `--rui-Card--
|
300
|
-
| `--rui-Card--
|
301
|
-
| `--rui-Card--
|
292
|
+
| Custom Property | Description |
|
293
|
+
|------------------------------------------|------------------------------------------------|
|
294
|
+
| `--rui-Card__padding` | Padding shared by card header, body and footer |
|
295
|
+
| `--rui-Card__border-width` | Border width |
|
296
|
+
| `--rui-Card__border-color` | Border color |
|
297
|
+
| `--rui-Card__border-radius` | Corner radius |
|
298
|
+
| `--rui-Card__background-color` | Card background color |
|
299
|
+
| `--rui-Card--dense__padding` | Padding of dense card |
|
300
|
+
| `--rui-Card--raised__box-shadow` | Box shadow of raised card |
|
301
|
+
| `--rui-Card--disabled__background-color` | Card background color in disabled state |
|
302
|
+
| `--rui-Card--disabled__opacity` | Card opacity in disabled state |
|
302
303
|
|
303
304
|
### Theming Variants
|
304
305
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, {
|
3
|
+
useCallback,
|
4
|
+
useEffect,
|
3
5
|
useContext,
|
4
6
|
useImperativeHandle,
|
5
7
|
useRef,
|
@@ -35,13 +37,6 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
35
37
|
...restProps
|
36
38
|
} = props;
|
37
39
|
|
38
|
-
const internalInputRef = useRef();
|
39
|
-
|
40
|
-
// We need to have a reference to the input element to be able to call its methods,
|
41
|
-
// but at the same time we want to expose this reference to the parent component for
|
42
|
-
// case someone wants to call input methods from outside the component.
|
43
|
-
useImperativeHandle(ref, () => internalInputRef.current);
|
44
|
-
|
45
40
|
const formLayoutContext = useContext(FormLayoutContext);
|
46
41
|
const inputGroupContext = useContext(InputGroupContext);
|
47
42
|
const translations = useContext(TranslationsContext);
|
@@ -49,6 +44,31 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
49
44
|
const [selectedFileNames, setSelectedFileNames] = useState([]);
|
50
45
|
const [isDragging, setIsDragging] = useState(false);
|
51
46
|
|
47
|
+
const internalInputRef = useRef();
|
48
|
+
|
49
|
+
const handleReset = useCallback((event) => {
|
50
|
+
setSelectedFileNames([]);
|
51
|
+
onFilesChanged([], event);
|
52
|
+
}, [onFilesChanged]);
|
53
|
+
|
54
|
+
// We need to have a reference to the input element to be able to call its methods,
|
55
|
+
// but at the same time we want to expose this reference to the parent component in
|
56
|
+
// case someone wants to call input methods from outside the component.
|
57
|
+
useImperativeHandle(
|
58
|
+
ref,
|
59
|
+
() => {
|
60
|
+
// The reason of extending object instead of using spread operator is that
|
61
|
+
// if it is transformed to the object, it changes the reference of the object
|
62
|
+
// and its prototype chain.
|
63
|
+
const inputEl = internalInputRef?.current ?? {};
|
64
|
+
inputEl.resetState = () => {
|
65
|
+
handleReset(null);
|
66
|
+
};
|
67
|
+
return inputEl;
|
68
|
+
},
|
69
|
+
[handleReset],
|
70
|
+
);
|
71
|
+
|
52
72
|
const handleFileChange = (files, event) => {
|
53
73
|
if (files.length === 0) {
|
54
74
|
setSelectedFileNames([]);
|
@@ -99,6 +119,24 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
99
119
|
}
|
100
120
|
};
|
101
121
|
|
122
|
+
useEffect(() => {
|
123
|
+
const inputEl = internalInputRef.current;
|
124
|
+
if (!inputEl) {
|
125
|
+
return () => {};
|
126
|
+
}
|
127
|
+
|
128
|
+
const { form } = inputEl;
|
129
|
+
if (!form) {
|
130
|
+
return () => {};
|
131
|
+
}
|
132
|
+
|
133
|
+
form.addEventListener('reset', handleReset);
|
134
|
+
|
135
|
+
return () => {
|
136
|
+
form.removeEventListener('reset', handleReset);
|
137
|
+
};
|
138
|
+
}, [handleReset]);
|
139
|
+
|
102
140
|
return (
|
103
141
|
<div
|
104
142
|
className={classNames(
|
@@ -236,6 +236,44 @@ set the `multiple` prop to `true`.
|
|
236
236
|
/>
|
237
237
|
```
|
238
238
|
|
239
|
+
## Resetting Input State
|
240
|
+
|
241
|
+
If you need to reset the input state, you can do it by calling the
|
242
|
+
`resetState` method on the component's ref.
|
243
|
+
|
244
|
+
```docoff-react-preview
|
245
|
+
React.createElement(() => {
|
246
|
+
const fileInputRef = React.useRef();
|
247
|
+
|
248
|
+
return (
|
249
|
+
<Toolbar align="bottom">
|
250
|
+
<ToolbarItem>
|
251
|
+
<FileInputField
|
252
|
+
id="my-file"
|
253
|
+
label="Attachment"
|
254
|
+
onFilesChanged={() => {}}
|
255
|
+
ref={fileInputRef}
|
256
|
+
/>
|
257
|
+
</ToolbarItem>
|
258
|
+
<ToolbarItem>
|
259
|
+
<Button
|
260
|
+
label="Reset file input state"
|
261
|
+
onClick={() => {
|
262
|
+
if (!fileInputRef.current) {
|
263
|
+
return;
|
264
|
+
}
|
265
|
+
fileInputRef.current.resetState();
|
266
|
+
}}
|
267
|
+
/>
|
268
|
+
</ToolbarItem>
|
269
|
+
</Toolbar>
|
270
|
+
);
|
271
|
+
});
|
272
|
+
```
|
273
|
+
|
274
|
+
You can also reset the input state by clicking the button with the `reset` type
|
275
|
+
inside a form.
|
276
|
+
|
239
277
|
## Forwarding HTML Attributes
|
240
278
|
|
241
279
|
In addition to the options below in the [component's API](#api) section, you
|
@@ -300,7 +300,7 @@ This is a demo of all components supported by FormLayout.
|
|
300
300
|
|
301
301
|
```docoff-react-preview
|
302
302
|
React.createElement(() => {
|
303
|
-
const [fieldLayout, setFieldLayout] = React.useState('
|
303
|
+
const [fieldLayout, setFieldLayout] = React.useState('horizontal');
|
304
304
|
const [fruit, setFruit] = React.useState('apple');
|
305
305
|
const [isDeliveryAddress, setIsDeliveryAddress] = React.useState(true);
|
306
306
|
const [receiveNewsletter, setReceiveNewsletter] = React.useState(true);
|
@@ -323,16 +323,16 @@ React.createElement(() => {
|
|
323
323
|
<Toolbar>
|
324
324
|
<ToolbarItem>
|
325
325
|
<ButtonGroup>
|
326
|
-
<Button
|
327
|
-
color={fieldLayout === 'vertical' ? 'selected' : 'secondary'}
|
328
|
-
label="Vertical layout"
|
329
|
-
onClick={() => setFieldLayout('vertical')}
|
330
|
-
/>
|
331
326
|
<Button
|
332
327
|
color={fieldLayout === 'horizontal' ? 'selected' : 'secondary'}
|
333
328
|
label="Horizontal layout"
|
334
329
|
onClick={() => setFieldLayout('horizontal')}
|
335
330
|
/>
|
331
|
+
<Button
|
332
|
+
color={fieldLayout === 'vertical' ? 'selected' : 'secondary'}
|
333
|
+
label="Vertical layout"
|
334
|
+
onClick={() => setFieldLayout('vertical')}
|
335
|
+
/>
|
336
336
|
</ButtonGroup>
|
337
337
|
</ToolbarItem>
|
338
338
|
</Toolbar>
|
@@ -388,6 +388,7 @@ React.createElement(() => {
|
|
388
388
|
rows={3}
|
389
389
|
/>
|
390
390
|
<FileInputField
|
391
|
+
id="my-file"
|
391
392
|
label="Attachment"
|
392
393
|
onFilesChanged={() => {}}
|
393
394
|
/>
|
@@ -145,7 +145,7 @@ supports this kind of layout as well.
|
|
145
145
|
label="Horizontal layout"
|
146
146
|
layout="horizontal"
|
147
147
|
>
|
148
|
-
<FileInputField label="Attachment" onFilesChanged={() => {}} />
|
148
|
+
<FileInputField id="my-file" label="Attachment" onFilesChanged={() => {}} />
|
149
149
|
<Button label="Submit" />
|
150
150
|
</InputGroup>
|
151
151
|
```
|
package/src/theme.scss
CHANGED
@@ -5,8 +5,7 @@
|
|
5
5
|
@use "styles/theme-constants/svg";
|
6
6
|
|
7
7
|
@layer theme {
|
8
|
-
:root
|
9
|
-
:host {
|
8
|
+
:root {
|
10
9
|
// ============================================================================================ //
|
11
10
|
// GLOBAL TOKENS //
|
12
11
|
// ============================================================================================ //
|
@@ -826,6 +825,7 @@
|
|
826
825
|
|
827
826
|
--rui-Card__padding: var(--rui-dimension-space-4);
|
828
827
|
--rui-Card__border-width: var(--rui-dimension-border-width-1);
|
828
|
+
--rui-Card__border-color: var(--rui-color-border-primary);
|
829
829
|
--rui-Card__border-radius: var(--rui-dimension-radius-2);
|
830
830
|
--rui-Card__background-color: var(--rui-color-background-layer-1);
|
831
831
|
--rui-Card--dense__padding: var(--rui-dimension-space-2);
|