cozy-ui 130.11.0 → 131.0.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/CHANGELOG.md +21 -0
- package/package.json +1 -1
- package/react/Contacts/GroupsSelect/GroupCreation.jsx +1 -1
- package/react/Contacts/GroupsSelect/SelectBox/EditGroupName.jsx +1 -1
- package/react/CozyDialogs/SpecificDialogs/locales/en.json +1 -1
- package/react/CozyDialogs/SpecificDialogs/locales/fr.json +1 -1
- package/react/CozyDialogs/SpecificDialogs/locales/ru.json +1 -1
- package/react/CozyDialogs/SpecificDialogs/locales/vi.json +1 -1
- package/react/Field/index.jsx +1 -1
- package/react/Input/index.js +3 -0
- package/react/InputGroup/Readme.md +7 -7
- package/react/InputLabel/index.js +3 -0
- package/react/Label/Readme.md +3 -3
- package/react/Labs/PasswordInput/index.jsx +1 -1
- package/react/ListItem/ListItemBase/Renaming/RenameInput.jsx +1 -1
- package/react/TextField/MobileSelect.jsx +60 -18
- package/react/TextField/Readme.md +50 -3
- package/react/TextField/helpers.js +23 -0
- package/react/TextField/index.jsx +36 -33
- package/react/Wizard/index.jsx +1 -1
- package/react/index.js +0 -1
- package/react/{Input → legacy/Input}/Readme.md +7 -7
- package/react/{Input → legacy/Input}/styles.styl +1 -1
- package/stylus/cozy-ui/build.styl +1 -1
- package/transpiled/react/Contacts/GroupsSelect/GroupCreation.js +1 -1
- package/transpiled/react/Contacts/GroupsSelect/SelectBox/EditGroupName.js +1 -1
- package/transpiled/react/CozyDialogs/SpecificDialogs/withSpecificDialogsLocales.js +4 -4
- package/transpiled/react/Field/index.js +1 -1
- package/transpiled/react/Input/index.d.ts +1 -2
- package/transpiled/react/Input/index.js +1 -64
- package/transpiled/react/InputLabel/index.d.ts +2 -0
- package/transpiled/react/InputLabel/index.js +2 -0
- package/transpiled/react/Labs/PasswordInput/index.js +1 -1
- package/transpiled/react/ListItem/ListItemBase/Renaming/RenameInput.js +1 -1
- package/transpiled/react/TextField/MobileSelect.js +29 -18
- package/transpiled/react/TextField/helpers.d.ts +2 -0
- package/transpiled/react/TextField/helpers.js +30 -0
- package/transpiled/react/TextField/index.js +10 -3
- package/transpiled/react/Wizard/index.js +1 -1
- package/transpiled/react/index.d.ts +0 -1
- package/transpiled/react/index.js +0 -1
- package/transpiled/react/legacy/Input/index.d.ts +3 -0
- package/transpiled/react/legacy/Input/index.js +65 -0
- package/transpiled/react/stylesheet.css +1 -1
- /package/react/{Input → legacy/Input}/index.jsx +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# [131.0.0](https://github.com/cozy/cozy-ui/compare/v130.11.1...v131.0.0) (2025-10-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add `Input` and `InputLabel` from Mui ([ee37ba9](https://github.com/cozy/cozy-ui/commit/ee37ba9))
|
|
7
|
+
* **Input:** Move it in `legacy` folder ([2995365](https://github.com/cozy/cozy-ui/commit/2995365))
|
|
8
|
+
* **TextField:** Add multiple select ([8629645](https://github.com/cozy/cozy-ui/commit/8629645))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### BREAKING CHANGES
|
|
12
|
+
|
|
13
|
+
* **Input:** Input component has been moved. You must replace `cozy-ui/transpiled/react/Input` by `cozy-ui/transpiled/react/legacy/Input`
|
|
14
|
+
|
|
15
|
+
## [130.11.1](https://github.com/cozy/cozy-ui/compare/v130.11.0...v130.11.1) (2025-10-21)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **ShortcutDialog:** Change "edit button" wording ([247ef1a](https://github.com/cozy/cozy-ui/commit/247ef1a))
|
|
21
|
+
|
|
1
22
|
# [130.11.0](https://github.com/cozy/cozy-ui/compare/v130.10.0...v130.11.0) (2025-10-21)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import React, { Component } from 'react'
|
|
|
4
4
|
import styles from './styles.styl'
|
|
5
5
|
import Icon from '../../Icon'
|
|
6
6
|
import PlusIcon from '../../Icons/Plus'
|
|
7
|
-
import Input from '../../Input'
|
|
7
|
+
import Input from '../../legacy/Input'
|
|
8
8
|
import { translate } from '../../providers/I18n'
|
|
9
9
|
|
|
10
10
|
const normalizeGroupData = name => {
|
package/react/Field/index.jsx
CHANGED
|
@@ -5,7 +5,7 @@ import React, { useState } from 'react'
|
|
|
5
5
|
|
|
6
6
|
import styles from './styles.styl'
|
|
7
7
|
import ContactPicker from '../ContactPicker'
|
|
8
|
-
import Input from '../Input'
|
|
8
|
+
import Input from '../legacy/Input'
|
|
9
9
|
import Label from '../Label'
|
|
10
10
|
import labelStyles from '../Label/styles.styl'
|
|
11
11
|
import SelectBox from '../SelectBox'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
```jsx
|
|
4
4
|
import InputGroup from 'cozy-ui/transpiled/react/InputGroup';
|
|
5
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
5
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
6
6
|
<form>
|
|
7
7
|
<div>
|
|
8
8
|
<InputGroup append={<InputGroup.Unit>€</InputGroup.Unit>}>
|
|
@@ -16,7 +16,7 @@ import Input from 'cozy-ui/transpiled/react/Input';
|
|
|
16
16
|
|
|
17
17
|
```jsx
|
|
18
18
|
import InputGroup from 'cozy-ui/transpiled/react/InputGroup';
|
|
19
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
19
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
20
20
|
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
21
21
|
<form>
|
|
22
22
|
<div>
|
|
@@ -33,7 +33,7 @@ You will need to set a width to the side component, with a utility class for exa
|
|
|
33
33
|
|
|
34
34
|
```jsx
|
|
35
35
|
import InputGroup from 'cozy-ui/transpiled/react/InputGroup';
|
|
36
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
36
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
37
37
|
<form>
|
|
38
38
|
<div>
|
|
39
39
|
<InputGroup append={<Input placeholder="@domain.tld" className="u-w-4"/>}>
|
|
@@ -49,7 +49,7 @@ You will need to set a width to the side component, with a utility class for exa
|
|
|
49
49
|
|
|
50
50
|
```jsx
|
|
51
51
|
import InputGroup from 'cozy-ui/transpiled/react/InputGroup';
|
|
52
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
52
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
53
53
|
import SelectBox from 'cozy-ui/transpiled/react/SelectBox';
|
|
54
54
|
const options = [
|
|
55
55
|
{ value: 'cozy.io', label: '.cozy.io' },
|
|
@@ -68,7 +68,7 @@ const options = [
|
|
|
68
68
|
|
|
69
69
|
```jsx
|
|
70
70
|
import InputGroup from 'cozy-ui/transpiled/react/InputGroup';
|
|
71
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
71
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
72
72
|
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
73
73
|
<form>
|
|
74
74
|
<div>
|
|
@@ -83,7 +83,7 @@ import Typography from "cozy-ui/transpiled/react/Typography";
|
|
|
83
83
|
|
|
84
84
|
```jsx
|
|
85
85
|
import InputGroup from 'cozy-ui/transpiled/react/InputGroup';
|
|
86
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
86
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
87
87
|
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
88
88
|
<form>
|
|
89
89
|
<div>
|
|
@@ -98,7 +98,7 @@ import Typography from "cozy-ui/transpiled/react/Typography";
|
|
|
98
98
|
|
|
99
99
|
```jsx
|
|
100
100
|
import InputGroup from 'cozy-ui/transpiled/react/InputGroup';
|
|
101
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
101
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
102
102
|
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
103
103
|
<form>
|
|
104
104
|
<div>
|
package/react/Label/Readme.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
```jsx
|
|
4
4
|
import Label from 'cozy-ui/transpiled/react/Label';
|
|
5
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
5
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
6
6
|
<form>
|
|
7
7
|
<div>
|
|
8
8
|
<Label htmlFor="idInput">This is a label</Label>
|
|
@@ -15,7 +15,7 @@ import Input from 'cozy-ui/transpiled/react/Input';
|
|
|
15
15
|
|
|
16
16
|
```jsx
|
|
17
17
|
import Label from 'cozy-ui/transpiled/react/Label';
|
|
18
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
18
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
19
19
|
<form>
|
|
20
20
|
<div>
|
|
21
21
|
<Label htmlFor="idInput2" block={false}>This is an inline label</Label>
|
|
@@ -28,7 +28,7 @@ import Input from 'cozy-ui/transpiled/react/Input';
|
|
|
28
28
|
|
|
29
29
|
```jsx
|
|
30
30
|
import Label from 'cozy-ui/transpiled/react/Label';
|
|
31
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
31
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
32
32
|
<form>
|
|
33
33
|
<div>
|
|
34
34
|
<Label htmlFor="idInput2" error>This is an error label</Label>
|
|
@@ -7,7 +7,7 @@ import styles from './styles.styl'
|
|
|
7
7
|
import Icon from '../../Icon'
|
|
8
8
|
import EyeIcon from '../../Icons/Eye'
|
|
9
9
|
import EyeClosedIcon from '../../Icons/EyeClosed'
|
|
10
|
-
import Input from '../../Input'
|
|
10
|
+
import Input from '../../legacy/Input'
|
|
11
11
|
import InputGroup from '../../InputGroup'
|
|
12
12
|
|
|
13
13
|
const HideShowButton = props => {
|
|
@@ -6,7 +6,7 @@ import { splitFilename } from 'cozy-client/dist/models/file'
|
|
|
6
6
|
|
|
7
7
|
import RenameDialog from './RenameDialog'
|
|
8
8
|
import { renameFile } from './helpers'
|
|
9
|
-
import Input from '../../../Input'
|
|
9
|
+
import Input from '../../../legacy/Input'
|
|
10
10
|
import InputGroup from '../../../InputGroup'
|
|
11
11
|
import Spinner from '../../../Spinner'
|
|
12
12
|
import { makeStyles } from '../../../styles'
|
|
@@ -3,8 +3,10 @@ import merge from 'lodash/merge'
|
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import React, { forwardRef, useEffect, useState } from 'react'
|
|
5
5
|
|
|
6
|
+
import { getLabelByValue, toggleInArray } from './helpers'
|
|
6
7
|
import ActionsMenuItem from '../ActionsMenu/ActionsMenuItem'
|
|
7
8
|
import ActionsMenuWrapper from '../ActionsMenu/ActionsMenuWrapper'
|
|
9
|
+
import Checkbox from '../Checkbox'
|
|
8
10
|
import Icon from '../Icon'
|
|
9
11
|
import BottomIcon from '../Icons/Bottom'
|
|
10
12
|
import InputAdornment from '../InputAdornment'
|
|
@@ -14,17 +16,32 @@ import Radio from '../Radios'
|
|
|
14
16
|
|
|
15
17
|
const MobileSelect = forwardRef(
|
|
16
18
|
(
|
|
17
|
-
{
|
|
19
|
+
{
|
|
20
|
+
id,
|
|
21
|
+
name,
|
|
22
|
+
options,
|
|
23
|
+
disabled,
|
|
24
|
+
value,
|
|
25
|
+
children,
|
|
26
|
+
onClick,
|
|
27
|
+
onChange,
|
|
28
|
+
...props
|
|
29
|
+
},
|
|
18
30
|
ref
|
|
19
31
|
) => {
|
|
32
|
+
const isMultiple = Array.isArray(value)
|
|
33
|
+
|
|
20
34
|
// As they are controlled input, we have to set empty string as default
|
|
21
35
|
// because values can't be undefined and then defined
|
|
22
|
-
const [state, setState] = useState({
|
|
36
|
+
const [state, setState] = useState({
|
|
37
|
+
label: '',
|
|
38
|
+
value: isMultiple ? [] : ''
|
|
39
|
+
})
|
|
23
40
|
const [showDrawer, setShowDrawer] = useState(false)
|
|
24
41
|
|
|
25
|
-
const initialLabel =
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
const initialLabel = isMultiple
|
|
43
|
+
? value.map(v => getLabelByValue(options, v)).join(', ')
|
|
44
|
+
: getLabelByValue(options, value)
|
|
28
45
|
|
|
29
46
|
const handleClick = () => {
|
|
30
47
|
setShowDrawer(true)
|
|
@@ -34,9 +51,11 @@ const MobileSelect = forwardRef(
|
|
|
34
51
|
const handleItemClick =
|
|
35
52
|
({ value, children, onClick }) =>
|
|
36
53
|
ev => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
const _value = isMultiple ? toggleInArray(state.value, value) : value
|
|
55
|
+
|
|
56
|
+
onClick?.(merge({}, ev, { target: { value: _value } }))
|
|
57
|
+
setState({ label: children, value: _value })
|
|
58
|
+
onChange?.({ target: { value: _value } })
|
|
40
59
|
}
|
|
41
60
|
|
|
42
61
|
const handleClose = () => {
|
|
@@ -44,12 +63,16 @@ const MobileSelect = forwardRef(
|
|
|
44
63
|
}
|
|
45
64
|
|
|
46
65
|
useEffect(() => {
|
|
47
|
-
setState({
|
|
48
|
-
|
|
66
|
+
setState({
|
|
67
|
+
label: initialLabel || '',
|
|
68
|
+
value: value || (isMultiple ? [] : '')
|
|
69
|
+
})
|
|
70
|
+
}, [initialLabel, value, isMultiple])
|
|
49
71
|
|
|
50
72
|
return (
|
|
51
73
|
<>
|
|
52
74
|
<MuiTextField
|
|
75
|
+
id={id}
|
|
53
76
|
style={{ display: 'none' }}
|
|
54
77
|
type="hidden"
|
|
55
78
|
name={name}
|
|
@@ -70,6 +93,7 @@ const MobileSelect = forwardRef(
|
|
|
70
93
|
<InputAdornment position="end">
|
|
71
94
|
<Icon
|
|
72
95
|
icon={BottomIcon}
|
|
96
|
+
rotate={showDrawer ? 180 : 0}
|
|
73
97
|
color={
|
|
74
98
|
disabled
|
|
75
99
|
? 'var(--disabledTextColor)'
|
|
@@ -83,21 +107,37 @@ const MobileSelect = forwardRef(
|
|
|
83
107
|
/>
|
|
84
108
|
|
|
85
109
|
{showDrawer && (
|
|
86
|
-
<ActionsMenuWrapper
|
|
110
|
+
<ActionsMenuWrapper
|
|
111
|
+
open
|
|
112
|
+
autoClose={!isMultiple}
|
|
113
|
+
onClose={handleClose}
|
|
114
|
+
>
|
|
87
115
|
{React.Children.map(children, child => {
|
|
88
116
|
return React.isValidElement(child) ? (
|
|
89
117
|
<ActionsMenuItem
|
|
90
118
|
{...child.props}
|
|
91
119
|
size="small"
|
|
92
|
-
autoFocus={
|
|
120
|
+
autoFocus={
|
|
121
|
+
isMultiple
|
|
122
|
+
? child.props.value === value[0]
|
|
123
|
+
: child.props.value === value
|
|
124
|
+
}
|
|
93
125
|
onClick={handleItemClick(child.props)}
|
|
94
126
|
>
|
|
95
127
|
<ListItemIcon>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
128
|
+
{isMultiple ? (
|
|
129
|
+
<Checkbox
|
|
130
|
+
aria-hidden="true"
|
|
131
|
+
tabIndex="-1"
|
|
132
|
+
checked={state.value.includes(child.props.value)}
|
|
133
|
+
/>
|
|
134
|
+
) : (
|
|
135
|
+
<Radio
|
|
136
|
+
aria-hidden="true"
|
|
137
|
+
tabIndex="-1"
|
|
138
|
+
checked={child.props.value === state.value}
|
|
139
|
+
/>
|
|
140
|
+
)}
|
|
101
141
|
</ListItemIcon>
|
|
102
142
|
<ListItemText primary={child.props.children} />
|
|
103
143
|
</ActionsMenuItem>
|
|
@@ -110,11 +150,13 @@ const MobileSelect = forwardRef(
|
|
|
110
150
|
}
|
|
111
151
|
)
|
|
112
152
|
|
|
153
|
+
MobileSelect.displayName = 'MobileSelect'
|
|
154
|
+
|
|
113
155
|
MobileSelect.propTypes = {
|
|
114
156
|
name: PropTypes.string,
|
|
115
157
|
options: PropTypes.array,
|
|
116
158
|
disabled: PropTypes.bool,
|
|
117
|
-
value: PropTypes.string,
|
|
159
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
118
160
|
children: PropTypes.oneOfType([
|
|
119
161
|
PropTypes.node,
|
|
120
162
|
PropTypes.arrayOf(PropTypes.node)
|
|
@@ -2,14 +2,14 @@ Cozy themed MUI TextField. See [the official API](https://v4.mui.com/api/text-fi
|
|
|
2
2
|
|
|
3
3
|
```jsx
|
|
4
4
|
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
5
|
-
import TextField
|
|
5
|
+
import TextField from 'cozy-ui/transpiled/react/TextField'
|
|
6
6
|
import Variants from 'cozy-ui/docs/components/Variants'
|
|
7
7
|
import FileIcon from 'cozy-ui/transpiled/react/Icons/File'
|
|
8
8
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
9
9
|
import InputAdornment from 'cozy-ui/transpiled/react/InputAdornment'
|
|
10
10
|
import MenuItem from 'cozy-ui/transpiled/react/MenuItem'
|
|
11
11
|
|
|
12
|
-
initialState = { option: 'value2' }
|
|
12
|
+
initialState = { option: 'value2', options: ['value2','value3'] }
|
|
13
13
|
|
|
14
14
|
const initialVariants = [{
|
|
15
15
|
required: false,
|
|
@@ -44,8 +44,13 @@ const options = [
|
|
|
44
44
|
label: 'Item 3',
|
|
45
45
|
},
|
|
46
46
|
]
|
|
47
|
+
|
|
47
48
|
const handleChange = (event) => {
|
|
48
|
-
setState({ option: event.target.value })
|
|
49
|
+
setState(v => ({ ...v, option: event.target.value }))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const handleMultipleChange = event => {
|
|
53
|
+
setState(v => ({ ...v, options: event.target.value }))
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
;
|
|
@@ -210,6 +215,48 @@ const handleChange = (event) => {
|
|
|
210
215
|
</MenuItem>
|
|
211
216
|
))}
|
|
212
217
|
</TextField>
|
|
218
|
+
|
|
219
|
+
<div className="u-mb-1 u-mt-2">Multiple Select</div>
|
|
220
|
+
<TextField
|
|
221
|
+
select
|
|
222
|
+
SelectProps={{ multiple: true }}
|
|
223
|
+
options={options}
|
|
224
|
+
value={state.options}
|
|
225
|
+
error={variant.error}
|
|
226
|
+
size={variant.small ? 'small' : 'medium'}
|
|
227
|
+
helperText={variant.helperText ? 'This is an helper text' : undefined}
|
|
228
|
+
required={variant.required}
|
|
229
|
+
label="Label"
|
|
230
|
+
variant="outlined"
|
|
231
|
+
onChange={handleMultipleChange}
|
|
232
|
+
>
|
|
233
|
+
{options.map((option) => (
|
|
234
|
+
<MenuItem key={option.value} value={option.value}>
|
|
235
|
+
{option.label}
|
|
236
|
+
</MenuItem>
|
|
237
|
+
))}
|
|
238
|
+
</TextField>
|
|
239
|
+
<TextField
|
|
240
|
+
className="u-ml-1"
|
|
241
|
+
select
|
|
242
|
+
SelectProps={{ multiple: true }}
|
|
243
|
+
options={options}
|
|
244
|
+
value={state.options}
|
|
245
|
+
disabled
|
|
246
|
+
error={variant.error}
|
|
247
|
+
size={variant.small ? 'small' : 'medium'}
|
|
248
|
+
helperText={variant.helperText ? 'This is an helper text' : undefined}
|
|
249
|
+
required={variant.required}
|
|
250
|
+
label="Label"
|
|
251
|
+
variant="outlined"
|
|
252
|
+
onChange={handleMultipleChange}
|
|
253
|
+
>
|
|
254
|
+
{options.map((option) => (
|
|
255
|
+
<MenuItem key={option.value} value={option.value}>
|
|
256
|
+
{option.label}
|
|
257
|
+
</MenuItem>
|
|
258
|
+
))}
|
|
259
|
+
</TextField>
|
|
213
260
|
</>
|
|
214
261
|
)}
|
|
215
262
|
</Variants>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add or Remove a value inside an array
|
|
3
|
+
* @param {array} arr
|
|
4
|
+
* @param {string} value
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export const toggleInArray = (arr, value) => {
|
|
8
|
+
const s = new Set(arr)
|
|
9
|
+
if (s.has(value)) {
|
|
10
|
+
s.delete(value)
|
|
11
|
+
} else {
|
|
12
|
+
s.add(value)
|
|
13
|
+
}
|
|
14
|
+
return Array.from(s)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {array} options
|
|
19
|
+
* @param {string} value
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export const getLabelByValue = (options, value) =>
|
|
23
|
+
options.find(option => option.value === value)?.label
|
|
@@ -7,44 +7,47 @@ import BottomIcon from '../Icons/Bottom'
|
|
|
7
7
|
import { getRandomUUID } from '../helpers/getRandomUUID'
|
|
8
8
|
import { useBreakpoints } from '../providers/Breakpoints'
|
|
9
9
|
|
|
10
|
-
const TextField = forwardRef(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const TextField = forwardRef(
|
|
11
|
+
({ select, SelectProps, options, children, ...props }, ref) => {
|
|
12
|
+
// A11Y, https://v4.mui.com/api/text-field/#props
|
|
13
|
+
const uuid = getRandomUUID()
|
|
14
|
+
const { isMobile } = useBreakpoints()
|
|
15
|
+
|
|
16
|
+
// options is not required to avoid breaking change but needed to have the mobile behavior
|
|
17
|
+
if (isMobile && select && options) {
|
|
18
|
+
return (
|
|
19
|
+
<MobileSelect ref={ref} id={uuid} options={options} {...props}>
|
|
20
|
+
{children}
|
|
21
|
+
</MobileSelect>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
14
24
|
|
|
15
|
-
// options is not required to avoid breaking change but needed to have the mobile behavior
|
|
16
|
-
if (isMobile && select && options) {
|
|
17
25
|
return (
|
|
18
|
-
<
|
|
26
|
+
<MuiTextField
|
|
27
|
+
ref={ref}
|
|
28
|
+
id={uuid}
|
|
29
|
+
select={select}
|
|
30
|
+
SelectProps={{
|
|
31
|
+
...SelectProps,
|
|
32
|
+
IconComponent: iconProps => (
|
|
33
|
+
<Icon
|
|
34
|
+
{...iconProps}
|
|
35
|
+
icon={BottomIcon}
|
|
36
|
+
color={
|
|
37
|
+
props.disabled
|
|
38
|
+
? 'var(--disabledTextColor)'
|
|
39
|
+
: 'var(--iconTextColor)'
|
|
40
|
+
}
|
|
41
|
+
/>
|
|
42
|
+
)
|
|
43
|
+
}}
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
19
46
|
{children}
|
|
20
|
-
</
|
|
47
|
+
</MuiTextField>
|
|
21
48
|
)
|
|
22
49
|
}
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<MuiTextField
|
|
26
|
-
ref={ref}
|
|
27
|
-
id={uuid}
|
|
28
|
-
select={select}
|
|
29
|
-
SelectProps={{
|
|
30
|
-
IconComponent: iconProps => (
|
|
31
|
-
<Icon
|
|
32
|
-
{...iconProps}
|
|
33
|
-
icon={BottomIcon}
|
|
34
|
-
color={
|
|
35
|
-
props.disabled
|
|
36
|
-
? 'var(--disabledTextColor)'
|
|
37
|
-
: 'var(--iconTextColor)'
|
|
38
|
-
}
|
|
39
|
-
/>
|
|
40
|
-
)
|
|
41
|
-
}}
|
|
42
|
-
{...props}
|
|
43
|
-
>
|
|
44
|
-
{children}
|
|
45
|
-
</MuiTextField>
|
|
46
|
-
)
|
|
47
|
-
})
|
|
50
|
+
)
|
|
48
51
|
|
|
49
52
|
TextField.displayName = 'TextField'
|
|
50
53
|
|
package/react/Wizard/index.jsx
CHANGED
|
@@ -4,7 +4,7 @@ import React from 'react'
|
|
|
4
4
|
import styles from './styles.styl'
|
|
5
5
|
import Icon from '../Icon'
|
|
6
6
|
import CloudIcon from '../Icons/Cloud'
|
|
7
|
-
import Input from '../Input'
|
|
7
|
+
import Input from '../legacy/Input'
|
|
8
8
|
import Typography from '../Typography'
|
|
9
9
|
import Button from '../deprecated/Button'
|
|
10
10
|
|
package/react/index.js
CHANGED
|
@@ -44,7 +44,6 @@ export {
|
|
|
44
44
|
export { default as ActionsMenu } from './ActionsMenu'
|
|
45
45
|
export { default as Overlay } from './deprecated/Overlay'
|
|
46
46
|
export { default as Label } from './Label'
|
|
47
|
-
export { default as Input } from './Input'
|
|
48
47
|
export { default as Checkbox } from './Checkbox'
|
|
49
48
|
export { default as Radio } from './deprecated/Radio'
|
|
50
49
|
export { default as Textarea } from './Textarea'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
### Input's available types (text, password, email, url)
|
|
2
2
|
|
|
3
3
|
```jsx
|
|
4
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
4
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
5
5
|
<form>
|
|
6
6
|
<p><Input placeholder="This is a input[type=text]" /></p>
|
|
7
7
|
<p><Input type="password" placeholder="This is a input[type=password]" /></p>
|
|
@@ -14,7 +14,7 @@ import Input from 'cozy-ui/transpiled/react/Input';
|
|
|
14
14
|
### Disabled Input
|
|
15
15
|
|
|
16
16
|
```jsx
|
|
17
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
17
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
18
18
|
<form>
|
|
19
19
|
<Input disabled value="I'm disabled" />
|
|
20
20
|
</form>
|
|
@@ -23,7 +23,7 @@ import Input from 'cozy-ui/transpiled/react/Input';
|
|
|
23
23
|
### Input when there's an error
|
|
24
24
|
|
|
25
25
|
```jsx
|
|
26
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
26
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
27
27
|
<Input error placeholder="This is a input[type=text] with error" />
|
|
28
28
|
```
|
|
29
29
|
|
|
@@ -32,7 +32,7 @@ import Input from 'cozy-ui/transpiled/react/Input';
|
|
|
32
32
|
By default, the size is `large`.
|
|
33
33
|
|
|
34
34
|
```jsx
|
|
35
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
35
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
36
36
|
<div>
|
|
37
37
|
<p>
|
|
38
38
|
<Input placeholder="I have a tiny size" size="tiny" />
|
|
@@ -46,7 +46,7 @@ import Input from 'cozy-ui/transpiled/react/Input';
|
|
|
46
46
|
### Full width inputs
|
|
47
47
|
|
|
48
48
|
```jsx
|
|
49
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
49
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
50
50
|
<Input placeholder="I'm full width" fullwidth />
|
|
51
51
|
```
|
|
52
52
|
|
|
@@ -55,7 +55,7 @@ import Input from 'cozy-ui/transpiled/react/Input';
|
|
|
55
55
|
If you need to programmatically access the underlying `<input />` for example to give focus or move the caret, you can use the `inputRef` prop, that is passed to the `ref` property of the `<input />`.
|
|
56
56
|
|
|
57
57
|
```jsx
|
|
58
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
58
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
59
59
|
import Button from 'cozy-ui/transpiled/react/deprecated/Button';
|
|
60
60
|
class InputComponent extends React.Component {
|
|
61
61
|
constructor() {
|
|
@@ -83,7 +83,7 @@ class InputComponent extends React.Component {
|
|
|
83
83
|
`Input` forwards unknown props to the underlying `<input />` element.
|
|
84
84
|
|
|
85
85
|
```jsx
|
|
86
|
-
import Input from 'cozy-ui/transpiled/react/Input';
|
|
86
|
+
import Input from 'cozy-ui/transpiled/react/legacy/Input';
|
|
87
87
|
<div>
|
|
88
88
|
<Input placeholder='Type to see changes' value={state.value} onChange={ev => setState({value: ev.target.value})} />
|
|
89
89
|
Value: { state.value }
|