cozy-ui 75.0.0 → 75.1.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 +14 -0
- package/package.json +1 -1
- package/react/ActionMenu/ActionMenuHeader.jsx +18 -0
- package/react/ActionMenu/ActionMenuItem.jsx +47 -0
- package/react/ActionMenu/ActionMenuRadio.jsx +9 -0
- package/react/ActionMenu/ActionMenuWrapper.jsx +32 -0
- package/react/ActionMenu/NotInlineWrapper.jsx +59 -0
- package/react/ActionMenu/index.jsx +6 -138
- package/react/Field/index.jsx +45 -52
- package/react/Input/index.jsx +0 -4
- package/react/Viewer/Panel/ActionMenuWrapper.jsx +1 -1
- package/transpiled/react/ActionMenu/ActionMenuHeader.js +21 -0
- package/transpiled/react/ActionMenu/ActionMenuItem.js +44 -0
- package/transpiled/react/ActionMenu/ActionMenuRadio.js +15 -0
- package/transpiled/react/ActionMenu/ActionMenuWrapper.js +29 -0
- package/transpiled/react/ActionMenu/NotInlineWrapper.js +59 -0
- package/transpiled/react/ActionMenu/index.js +17 -146
- package/transpiled/react/Field/index.js +38 -78
- package/transpiled/react/Input/index.js +0 -5
- package/transpiled/react/Viewer/Panel/ActionMenuWrapper.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [75.1.0](https://github.com/cozy/cozy-ui/compare/v75.0.1...v75.1.0) (2022-09-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **Viewer:** Contact can now be edited ([2b9cee9](https://github.com/cozy/cozy-ui/commit/2b9cee9))
|
|
7
|
+
|
|
8
|
+
## [75.0.1](https://github.com/cozy/cozy-ui/compare/v75.0.0...v75.0.1) (2022-09-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **Field:** Use ref instead of inputRef when using Input comp ([d7317a9](https://github.com/cozy/cozy-ui/commit/d7317a9))
|
|
14
|
+
|
|
1
15
|
# [75.0.0](https://github.com/cozy/cozy-ui/compare/v74.7.0...v75.0.0) (2022-09-16)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import cx from 'classnames'
|
|
4
|
+
|
|
5
|
+
import styles from './styles.styl'
|
|
6
|
+
|
|
7
|
+
export const ActionMenuHeader = ({ children, className }) => {
|
|
8
|
+
return (
|
|
9
|
+
<div className={cx(styles['c-actionmenu-header'], className)}>
|
|
10
|
+
{children}
|
|
11
|
+
</div>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
ActionMenuHeader.propTypes = {
|
|
16
|
+
children: PropTypes.node,
|
|
17
|
+
className: PropTypes.string
|
|
18
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import cx from 'classnames'
|
|
4
|
+
|
|
5
|
+
import { Media, Bd, Img } from '../Media'
|
|
6
|
+
import { spacingProp } from '../Stack'
|
|
7
|
+
|
|
8
|
+
import styles from './styles.styl'
|
|
9
|
+
|
|
10
|
+
export const ActionMenuItem = ({
|
|
11
|
+
left,
|
|
12
|
+
children,
|
|
13
|
+
right,
|
|
14
|
+
onClick,
|
|
15
|
+
className,
|
|
16
|
+
contentSpacing
|
|
17
|
+
}) => {
|
|
18
|
+
return (
|
|
19
|
+
<Media
|
|
20
|
+
className={cx(styles['c-actionmenu-item'], className)}
|
|
21
|
+
onClick={onClick}
|
|
22
|
+
align="top"
|
|
23
|
+
>
|
|
24
|
+
{left && <Img className="u-mh-1">{left}</Img>}
|
|
25
|
+
<Bd
|
|
26
|
+
className={cx(left ? 'u-mr-1' : 'u-mh-1', `u-stack-${contentSpacing}`)}
|
|
27
|
+
>
|
|
28
|
+
{children}
|
|
29
|
+
</Bd>
|
|
30
|
+
{right && <Img className="u-mr-1">{right}</Img>}
|
|
31
|
+
</Media>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
ActionMenuItem.propTypes = {
|
|
36
|
+
left: PropTypes.node,
|
|
37
|
+
right: PropTypes.node,
|
|
38
|
+
children: PropTypes.node,
|
|
39
|
+
onClick: PropTypes.func,
|
|
40
|
+
className: PropTypes.string,
|
|
41
|
+
/** Controls spacing between between children of the ActionMenuItem */
|
|
42
|
+
contentSpacing: spacingProp
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ActionMenuItem.defaultProps = {
|
|
46
|
+
contentSpacing: 'xs'
|
|
47
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import BottomDrawer from '../BottomDrawer'
|
|
4
|
+
import NotInlineWrapper from './NotInlineWrapper'
|
|
5
|
+
|
|
6
|
+
const ActionMenuWrapper = ({
|
|
7
|
+
inline,
|
|
8
|
+
onClose,
|
|
9
|
+
anchorElRef,
|
|
10
|
+
popperOptions,
|
|
11
|
+
placement,
|
|
12
|
+
preventOverflow,
|
|
13
|
+
children
|
|
14
|
+
}) => {
|
|
15
|
+
if (!inline) {
|
|
16
|
+
return <BottomDrawer onClose={onClose}>{children}</BottomDrawer>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<NotInlineWrapper
|
|
21
|
+
anchorElRef={anchorElRef}
|
|
22
|
+
popperOptions={popperOptions}
|
|
23
|
+
placement={placement}
|
|
24
|
+
preventOverflow={preventOverflow}
|
|
25
|
+
onClose={onClose}
|
|
26
|
+
>
|
|
27
|
+
{children}
|
|
28
|
+
</NotInlineWrapper>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default ActionMenuWrapper
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { usePopper } from 'react-popper'
|
|
3
|
+
import ClickAwayListener from '@material-ui/core/ClickAwayListener'
|
|
4
|
+
|
|
5
|
+
import { getCssVariableValue } from '../utils/color'
|
|
6
|
+
|
|
7
|
+
const NotInlineWrapper = ({
|
|
8
|
+
anchorElRef,
|
|
9
|
+
popperOptions,
|
|
10
|
+
placement,
|
|
11
|
+
preventOverflow,
|
|
12
|
+
onClose,
|
|
13
|
+
children
|
|
14
|
+
}) => {
|
|
15
|
+
const [popperElement, setPopperElement] = useState(null)
|
|
16
|
+
const referenceElement = anchorElRef ? anchorElRef.current : null
|
|
17
|
+
|
|
18
|
+
const normalOverflowModifiers = [
|
|
19
|
+
{
|
|
20
|
+
name: 'preventOverflow',
|
|
21
|
+
enabled: false
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'hide',
|
|
25
|
+
enabled: false
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
const options = popperOptions || {
|
|
29
|
+
placement,
|
|
30
|
+
modifiers: preventOverflow ? undefined : normalOverflowModifiers
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const { styles, attributes } = usePopper(
|
|
34
|
+
referenceElement,
|
|
35
|
+
popperElement,
|
|
36
|
+
options
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
const handleClose = e => {
|
|
40
|
+
if (referenceElement.contains(e.target)) return
|
|
41
|
+
onClose(e)
|
|
42
|
+
}
|
|
43
|
+
return (
|
|
44
|
+
<div
|
|
45
|
+
ref={setPopperElement}
|
|
46
|
+
style={{
|
|
47
|
+
...styles.popper,
|
|
48
|
+
zIndex: getCssVariableValue('zIndex-popover')
|
|
49
|
+
}}
|
|
50
|
+
{...attributes.popper}
|
|
51
|
+
>
|
|
52
|
+
<ClickAwayListener onClickAway={handleClose}>
|
|
53
|
+
{children}
|
|
54
|
+
</ClickAwayListener>
|
|
55
|
+
</div>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default NotInlineWrapper
|
|
@@ -1,93 +1,17 @@
|
|
|
1
|
-
import ClickAwayListener from '@material-ui/core/ClickAwayListener'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
1
|
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
4
3
|
import cx from 'classnames'
|
|
5
|
-
import { usePopper } from 'react-popper'
|
|
6
4
|
|
|
7
|
-
import BottomDrawer from '../BottomDrawer'
|
|
8
|
-
import Radio from '../Radio'
|
|
9
5
|
import createDepreciationLogger from '../helpers/createDepreciationLogger'
|
|
10
|
-
import styles from './styles.styl'
|
|
11
6
|
import useBreakpoints from '../hooks/useBreakpoints'
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
7
|
+
import ActionMenuWrapper from './ActionMenuWrapper'
|
|
8
|
+
import { ActionMenuHeader } from './ActionMenuHeader'
|
|
9
|
+
import { ActionMenuItem } from './ActionMenuItem'
|
|
10
|
+
import { ActionMenuRadio } from './ActionMenuRadio'
|
|
15
11
|
import { useActionMenuEffects } from './ActionMenuEffects'
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
inline,
|
|
19
|
-
onClose,
|
|
20
|
-
anchorElRef,
|
|
21
|
-
popperOptions,
|
|
22
|
-
placement,
|
|
23
|
-
preventOverflow,
|
|
24
|
-
children
|
|
25
|
-
}) => {
|
|
26
|
-
if (!inline) return <BottomDrawer onClose={onClose}>{children}</BottomDrawer>
|
|
27
|
-
return (
|
|
28
|
-
<NotInlineWrapper
|
|
29
|
-
anchorElRef={anchorElRef}
|
|
30
|
-
popperOptions={popperOptions}
|
|
31
|
-
placement={placement}
|
|
32
|
-
preventOverflow={preventOverflow}
|
|
33
|
-
onClose={onClose}
|
|
34
|
-
>
|
|
35
|
-
{children}
|
|
36
|
-
</NotInlineWrapper>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const NotInlineWrapper = ({
|
|
41
|
-
anchorElRef,
|
|
42
|
-
popperOptions,
|
|
43
|
-
placement,
|
|
44
|
-
preventOverflow,
|
|
45
|
-
onClose,
|
|
46
|
-
children
|
|
47
|
-
}) => {
|
|
48
|
-
const [popperElement, setPopperElement] = React.useState(null)
|
|
49
|
-
const referenceElement = anchorElRef ? anchorElRef.current : null
|
|
50
|
-
|
|
51
|
-
const normalOverflowModifiers = [
|
|
52
|
-
{
|
|
53
|
-
name: 'preventOverflow',
|
|
54
|
-
enabled: false
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'hide',
|
|
58
|
-
enabled: false
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
const options = popperOptions || {
|
|
62
|
-
placement,
|
|
63
|
-
modifiers: preventOverflow ? undefined : normalOverflowModifiers
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const { styles, attributes } = usePopper(
|
|
67
|
-
referenceElement,
|
|
68
|
-
popperElement,
|
|
69
|
-
options
|
|
70
|
-
)
|
|
13
|
+
import styles from './styles.styl'
|
|
71
14
|
|
|
72
|
-
const handleClose = e => {
|
|
73
|
-
if (referenceElement.contains(e.target)) return
|
|
74
|
-
onClose(e)
|
|
75
|
-
}
|
|
76
|
-
return (
|
|
77
|
-
<div
|
|
78
|
-
ref={setPopperElement}
|
|
79
|
-
style={{
|
|
80
|
-
...styles.popper,
|
|
81
|
-
zIndex: getCssVariableValue('zIndex-popover')
|
|
82
|
-
}}
|
|
83
|
-
{...attributes.popper}
|
|
84
|
-
>
|
|
85
|
-
<ClickAwayListener onClickAway={handleClose}>
|
|
86
|
-
{children}
|
|
87
|
-
</ClickAwayListener>
|
|
88
|
-
</div>
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
15
|
const logDepecratedPlacement = createDepreciationLogger()
|
|
92
16
|
const logDepecratedOverflow = createDepreciationLogger()
|
|
93
17
|
const logDepecratedContainer = createDepreciationLogger()
|
|
@@ -183,61 +107,5 @@ ActionMenu.defaultProps = {
|
|
|
183
107
|
autoclose: false
|
|
184
108
|
}
|
|
185
109
|
|
|
186
|
-
const ActionMenuHeader = ({ children, className }) => {
|
|
187
|
-
return (
|
|
188
|
-
<div className={cx(styles['c-actionmenu-header'], className)}>
|
|
189
|
-
{children}
|
|
190
|
-
</div>
|
|
191
|
-
)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
ActionMenuHeader.propTypes = {
|
|
195
|
-
children: PropTypes.node,
|
|
196
|
-
className: PropTypes.string
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const ActionMenuItem = ({
|
|
200
|
-
left,
|
|
201
|
-
children,
|
|
202
|
-
right,
|
|
203
|
-
onClick,
|
|
204
|
-
className,
|
|
205
|
-
contentSpacing
|
|
206
|
-
}) => {
|
|
207
|
-
return (
|
|
208
|
-
<Media
|
|
209
|
-
className={cx(styles['c-actionmenu-item'], className)}
|
|
210
|
-
onClick={onClick}
|
|
211
|
-
align="top"
|
|
212
|
-
>
|
|
213
|
-
{left && <Img className="u-mh-1">{left}</Img>}
|
|
214
|
-
<Bd
|
|
215
|
-
className={cx(left ? 'u-mr-1' : 'u-mh-1', `u-stack-${contentSpacing}`)}
|
|
216
|
-
>
|
|
217
|
-
{children}
|
|
218
|
-
</Bd>
|
|
219
|
-
{right && <Img className="u-mr-1">{right}</Img>}
|
|
220
|
-
</Media>
|
|
221
|
-
)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const ActionMenuRadio = props => {
|
|
225
|
-
return <Radio {...props} className={styles['c-actionmenu-radio']} />
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
ActionMenuItem.propTypes = {
|
|
229
|
-
left: PropTypes.node,
|
|
230
|
-
right: PropTypes.node,
|
|
231
|
-
children: PropTypes.node,
|
|
232
|
-
onClick: PropTypes.func,
|
|
233
|
-
className: PropTypes.string,
|
|
234
|
-
/** Controls spacing between between children of the ActionMenuItem */
|
|
235
|
-
contentSpacing: spacingProp
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
ActionMenuItem.defaultProps = {
|
|
239
|
-
contentSpacing: 'xs'
|
|
240
|
-
}
|
|
241
|
-
|
|
242
110
|
export default ActionMenu
|
|
243
111
|
export { ActionMenuHeader, ActionMenuItem, ActionMenuRadio }
|
package/react/Field/index.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
2
|
import cx from 'classnames'
|
|
3
3
|
import omit from 'lodash/omit'
|
|
4
4
|
import PropTypes from 'prop-types'
|
|
@@ -21,59 +21,52 @@ const inputSpecificPropTypes = {
|
|
|
21
21
|
onKeyUp: PropTypes.func
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const InputPassword = ({
|
|
25
|
+
hideLabel,
|
|
26
|
+
showLabel,
|
|
27
|
+
fullwidth,
|
|
28
|
+
secondaryComponent,
|
|
29
|
+
inputRef,
|
|
30
|
+
...restProps
|
|
31
|
+
}) => {
|
|
32
|
+
const [visible, setVisible] = useState(false)
|
|
28
33
|
|
|
29
|
-
toggleVisibility() {
|
|
30
|
-
|
|
34
|
+
const toggleVisibility = () => {
|
|
35
|
+
setVisible(visible => !visible)
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
visible
|
|
66
|
-
})}
|
|
67
|
-
</div>
|
|
68
|
-
)}
|
|
69
|
-
<Input
|
|
70
|
-
{...restProps}
|
|
71
|
-
fullwidth={fullwidth}
|
|
72
|
-
type={visible ? 'text' : 'password'}
|
|
73
|
-
/>
|
|
74
|
-
</div>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
38
|
+
return (
|
|
39
|
+
<div className={styles['o-field-input']}>
|
|
40
|
+
{!secondaryComponent && (
|
|
41
|
+
<div
|
|
42
|
+
className={cx(
|
|
43
|
+
labelStyles['c-label'],
|
|
44
|
+
styles['o-field-input-action'],
|
|
45
|
+
{ [styles['o-side-fullwidth']]: fullwidth }
|
|
46
|
+
)}
|
|
47
|
+
onClick={toggleVisibility}
|
|
48
|
+
>
|
|
49
|
+
{visible ? hideLabel : showLabel}
|
|
50
|
+
</div>
|
|
51
|
+
)}
|
|
52
|
+
{secondaryComponent && (
|
|
53
|
+
<div
|
|
54
|
+
className={cx(styles['o-field-input-action'], {
|
|
55
|
+
[styles['o-side-fullwidth']]: fullwidth
|
|
56
|
+
})}
|
|
57
|
+
onClick={toggleVisibility}
|
|
58
|
+
>
|
|
59
|
+
{secondaryComponent({ visible })}
|
|
60
|
+
</div>
|
|
61
|
+
)}
|
|
62
|
+
<Input
|
|
63
|
+
{...restProps}
|
|
64
|
+
ref={inputRef}
|
|
65
|
+
fullwidth={fullwidth}
|
|
66
|
+
type={visible ? 'text' : 'password'}
|
|
67
|
+
/>
|
|
68
|
+
</div>
|
|
69
|
+
)
|
|
77
70
|
}
|
|
78
71
|
|
|
79
72
|
InputPassword.propTypes = {
|
|
@@ -207,7 +200,7 @@ const Field = props => {
|
|
|
207
200
|
disabled={disabled}
|
|
208
201
|
fullwidth={fullwidth}
|
|
209
202
|
id={id}
|
|
210
|
-
|
|
203
|
+
ref={inputRef}
|
|
211
204
|
name={name}
|
|
212
205
|
type={type}
|
|
213
206
|
placeholder={placeholder}
|
package/react/Input/index.jsx
CHANGED
|
@@ -62,10 +62,6 @@ Input.propTypes = {
|
|
|
62
62
|
error: PropTypes.bool,
|
|
63
63
|
size: PropTypes.oneOf(['tiny', 'medium', 'large']),
|
|
64
64
|
fullwidth: PropTypes.bool,
|
|
65
|
-
/**
|
|
66
|
-
* Use that property to pass a ref callback to the native input component.
|
|
67
|
-
*/
|
|
68
|
-
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
69
65
|
onChange: PropTypes.func,
|
|
70
66
|
onKeyUp: PropTypes.func
|
|
71
67
|
}
|
|
@@ -14,7 +14,7 @@ import ActionMenuDesktop from './ActionMenuDesktop'
|
|
|
14
14
|
const mespapiersAppSlug = 'mespapiers'
|
|
15
15
|
|
|
16
16
|
const checkEditableAttribute = name => {
|
|
17
|
-
const isNotEditableAttributes = ['datetime', 'qualification'
|
|
17
|
+
const isNotEditableAttributes = ['datetime', 'qualification']
|
|
18
18
|
return !isNotEditableAttributes.includes(name)
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
var styles = {
|
|
5
|
+
"c-actionmenu": "styles__c-actionmenu___22Fp1",
|
|
6
|
+
"c-actionmenu--inline": "styles__c-actionmenu--inline___1SXZa",
|
|
7
|
+
"c-actionmenu-header": "styles__c-actionmenu-header___2rcGc",
|
|
8
|
+
"c-actionmenu-item": "styles__c-actionmenu-item___gODqd",
|
|
9
|
+
"c-actionmenu-radio": "styles__c-actionmenu-radio___Km9uj"
|
|
10
|
+
};
|
|
11
|
+
export var ActionMenuHeader = function ActionMenuHeader(_ref) {
|
|
12
|
+
var children = _ref.children,
|
|
13
|
+
className = _ref.className;
|
|
14
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
className: cx(styles['c-actionmenu-header'], className)
|
|
16
|
+
}, children);
|
|
17
|
+
};
|
|
18
|
+
ActionMenuHeader.propTypes = {
|
|
19
|
+
children: PropTypes.node,
|
|
20
|
+
className: PropTypes.string
|
|
21
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import { Media, Bd, Img } from "cozy-ui/transpiled/react/Media";
|
|
5
|
+
import { spacingProp } from "cozy-ui/transpiled/react/Stack";
|
|
6
|
+
var styles = {
|
|
7
|
+
"c-actionmenu": "styles__c-actionmenu___22Fp1",
|
|
8
|
+
"c-actionmenu--inline": "styles__c-actionmenu--inline___1SXZa",
|
|
9
|
+
"c-actionmenu-header": "styles__c-actionmenu-header___2rcGc",
|
|
10
|
+
"c-actionmenu-item": "styles__c-actionmenu-item___gODqd",
|
|
11
|
+
"c-actionmenu-radio": "styles__c-actionmenu-radio___Km9uj"
|
|
12
|
+
};
|
|
13
|
+
export var ActionMenuItem = function ActionMenuItem(_ref) {
|
|
14
|
+
var left = _ref.left,
|
|
15
|
+
children = _ref.children,
|
|
16
|
+
right = _ref.right,
|
|
17
|
+
onClick = _ref.onClick,
|
|
18
|
+
className = _ref.className,
|
|
19
|
+
contentSpacing = _ref.contentSpacing;
|
|
20
|
+
return /*#__PURE__*/React.createElement(Media, {
|
|
21
|
+
className: cx(styles['c-actionmenu-item'], className),
|
|
22
|
+
onClick: onClick,
|
|
23
|
+
align: "top"
|
|
24
|
+
}, left && /*#__PURE__*/React.createElement(Img, {
|
|
25
|
+
className: "u-mh-1"
|
|
26
|
+
}, left), /*#__PURE__*/React.createElement(Bd, {
|
|
27
|
+
className: cx(left ? 'u-mr-1' : 'u-mh-1', "u-stack-".concat(contentSpacing))
|
|
28
|
+
}, children), right && /*#__PURE__*/React.createElement(Img, {
|
|
29
|
+
className: "u-mr-1"
|
|
30
|
+
}, right));
|
|
31
|
+
};
|
|
32
|
+
ActionMenuItem.propTypes = {
|
|
33
|
+
left: PropTypes.node,
|
|
34
|
+
right: PropTypes.node,
|
|
35
|
+
children: PropTypes.node,
|
|
36
|
+
onClick: PropTypes.func,
|
|
37
|
+
className: PropTypes.string,
|
|
38
|
+
|
|
39
|
+
/** Controls spacing between between children of the ActionMenuItem */
|
|
40
|
+
contentSpacing: spacingProp
|
|
41
|
+
};
|
|
42
|
+
ActionMenuItem.defaultProps = {
|
|
43
|
+
contentSpacing: 'xs'
|
|
44
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Radio from "cozy-ui/transpiled/react/Radio";
|
|
4
|
+
var styles = {
|
|
5
|
+
"c-actionmenu": "styles__c-actionmenu___22Fp1",
|
|
6
|
+
"c-actionmenu--inline": "styles__c-actionmenu--inline___1SXZa",
|
|
7
|
+
"c-actionmenu-header": "styles__c-actionmenu-header___2rcGc",
|
|
8
|
+
"c-actionmenu-item": "styles__c-actionmenu-item___gODqd",
|
|
9
|
+
"c-actionmenu-radio": "styles__c-actionmenu-radio___Km9uj"
|
|
10
|
+
};
|
|
11
|
+
export var ActionMenuRadio = function ActionMenuRadio(props) {
|
|
12
|
+
return /*#__PURE__*/React.createElement(Radio, _extends({}, props, {
|
|
13
|
+
className: styles['c-actionmenu-radio']
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import BottomDrawer from "cozy-ui/transpiled/react/BottomDrawer";
|
|
3
|
+
import NotInlineWrapper from "cozy-ui/transpiled/react/ActionMenu/NotInlineWrapper";
|
|
4
|
+
|
|
5
|
+
var ActionMenuWrapper = function ActionMenuWrapper(_ref) {
|
|
6
|
+
var inline = _ref.inline,
|
|
7
|
+
onClose = _ref.onClose,
|
|
8
|
+
anchorElRef = _ref.anchorElRef,
|
|
9
|
+
popperOptions = _ref.popperOptions,
|
|
10
|
+
placement = _ref.placement,
|
|
11
|
+
preventOverflow = _ref.preventOverflow,
|
|
12
|
+
children = _ref.children;
|
|
13
|
+
|
|
14
|
+
if (!inline) {
|
|
15
|
+
return /*#__PURE__*/React.createElement(BottomDrawer, {
|
|
16
|
+
onClose: onClose
|
|
17
|
+
}, children);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return /*#__PURE__*/React.createElement(NotInlineWrapper, {
|
|
21
|
+
anchorElRef: anchorElRef,
|
|
22
|
+
popperOptions: popperOptions,
|
|
23
|
+
placement: placement,
|
|
24
|
+
preventOverflow: preventOverflow,
|
|
25
|
+
onClose: onClose
|
|
26
|
+
}, children);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default ActionMenuWrapper;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
+
|
|
9
|
+
import React, { useState } from 'react';
|
|
10
|
+
import { usePopper } from 'react-popper';
|
|
11
|
+
import ClickAwayListener from '@material-ui/core/ClickAwayListener';
|
|
12
|
+
import { getCssVariableValue } from "cozy-ui/transpiled/react/utils/color";
|
|
13
|
+
|
|
14
|
+
var NotInlineWrapper = function NotInlineWrapper(_ref) {
|
|
15
|
+
var anchorElRef = _ref.anchorElRef,
|
|
16
|
+
popperOptions = _ref.popperOptions,
|
|
17
|
+
placement = _ref.placement,
|
|
18
|
+
preventOverflow = _ref.preventOverflow,
|
|
19
|
+
onClose = _ref.onClose,
|
|
20
|
+
children = _ref.children;
|
|
21
|
+
|
|
22
|
+
var _useState = useState(null),
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
popperElement = _useState2[0],
|
|
25
|
+
setPopperElement = _useState2[1];
|
|
26
|
+
|
|
27
|
+
var referenceElement = anchorElRef ? anchorElRef.current : null;
|
|
28
|
+
var normalOverflowModifiers = [{
|
|
29
|
+
name: 'preventOverflow',
|
|
30
|
+
enabled: false
|
|
31
|
+
}, {
|
|
32
|
+
name: 'hide',
|
|
33
|
+
enabled: false
|
|
34
|
+
}];
|
|
35
|
+
var options = popperOptions || {
|
|
36
|
+
placement: placement,
|
|
37
|
+
modifiers: preventOverflow ? undefined : normalOverflowModifiers
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var _usePopper = usePopper(referenceElement, popperElement, options),
|
|
41
|
+
styles = _usePopper.styles,
|
|
42
|
+
attributes = _usePopper.attributes;
|
|
43
|
+
|
|
44
|
+
var handleClose = function handleClose(e) {
|
|
45
|
+
if (referenceElement.contains(e.target)) return;
|
|
46
|
+
onClose(e);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
50
|
+
ref: setPopperElement,
|
|
51
|
+
style: _objectSpread(_objectSpread({}, styles.popper), {}, {
|
|
52
|
+
zIndex: getCssVariableValue('zIndex-popover')
|
|
53
|
+
})
|
|
54
|
+
}, attributes.popper), /*#__PURE__*/React.createElement(ClickAwayListener, {
|
|
55
|
+
onClickAway: handleClose
|
|
56
|
+
}, children));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default NotInlineWrapper;
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
-
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
|
|
9
|
-
import ClickAwayListener from '@material-ui/core/ClickAwayListener';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
2
|
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
12
4
|
import cx from 'classnames';
|
|
13
|
-
import { usePopper } from 'react-popper';
|
|
14
|
-
import BottomDrawer from "cozy-ui/transpiled/react/BottomDrawer";
|
|
15
|
-
import Radio from "cozy-ui/transpiled/react/Radio";
|
|
16
5
|
import createDepreciationLogger from "cozy-ui/transpiled/react/helpers/createDepreciationLogger";
|
|
6
|
+
import useBreakpoints from "cozy-ui/transpiled/react/hooks/useBreakpoints";
|
|
7
|
+
import ActionMenuWrapper from "cozy-ui/transpiled/react/ActionMenu/ActionMenuWrapper";
|
|
8
|
+
import { ActionMenuHeader } from "cozy-ui/transpiled/react/ActionMenu/ActionMenuHeader";
|
|
9
|
+
import { ActionMenuItem } from "cozy-ui/transpiled/react/ActionMenu/ActionMenuItem";
|
|
10
|
+
import { ActionMenuRadio } from "cozy-ui/transpiled/react/ActionMenu/ActionMenuRadio";
|
|
11
|
+
import { useActionMenuEffects } from "cozy-ui/transpiled/react/ActionMenu/ActionMenuEffects";
|
|
17
12
|
var styles = {
|
|
18
13
|
"c-actionmenu": "styles__c-actionmenu___22Fp1",
|
|
19
14
|
"c-actionmenu--inline": "styles__c-actionmenu--inline___1SXZa",
|
|
@@ -21,91 +16,20 @@ var styles = {
|
|
|
21
16
|
"c-actionmenu-item": "styles__c-actionmenu-item___gODqd",
|
|
22
17
|
"c-actionmenu-radio": "styles__c-actionmenu-radio___Km9uj"
|
|
23
18
|
};
|
|
24
|
-
import useBreakpoints from "cozy-ui/transpiled/react/hooks/useBreakpoints";
|
|
25
|
-
import { Media, Bd, Img } from "cozy-ui/transpiled/react/Media";
|
|
26
|
-
import { getCssVariableValue } from "cozy-ui/transpiled/react/utils/color";
|
|
27
|
-
import { spacingProp } from "cozy-ui/transpiled/react/Stack";
|
|
28
|
-
import { useActionMenuEffects } from "cozy-ui/transpiled/react/ActionMenu/ActionMenuEffects";
|
|
29
|
-
|
|
30
|
-
var ActionMenuWrapper = function ActionMenuWrapper(_ref) {
|
|
31
|
-
var inline = _ref.inline,
|
|
32
|
-
onClose = _ref.onClose,
|
|
33
|
-
anchorElRef = _ref.anchorElRef,
|
|
34
|
-
popperOptions = _ref.popperOptions,
|
|
35
|
-
placement = _ref.placement,
|
|
36
|
-
preventOverflow = _ref.preventOverflow,
|
|
37
|
-
children = _ref.children;
|
|
38
|
-
if (!inline) return /*#__PURE__*/React.createElement(BottomDrawer, {
|
|
39
|
-
onClose: onClose
|
|
40
|
-
}, children);
|
|
41
|
-
return /*#__PURE__*/React.createElement(NotInlineWrapper, {
|
|
42
|
-
anchorElRef: anchorElRef,
|
|
43
|
-
popperOptions: popperOptions,
|
|
44
|
-
placement: placement,
|
|
45
|
-
preventOverflow: preventOverflow,
|
|
46
|
-
onClose: onClose
|
|
47
|
-
}, children);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
var NotInlineWrapper = function NotInlineWrapper(_ref2) {
|
|
51
|
-
var anchorElRef = _ref2.anchorElRef,
|
|
52
|
-
popperOptions = _ref2.popperOptions,
|
|
53
|
-
placement = _ref2.placement,
|
|
54
|
-
preventOverflow = _ref2.preventOverflow,
|
|
55
|
-
onClose = _ref2.onClose,
|
|
56
|
-
children = _ref2.children;
|
|
57
|
-
|
|
58
|
-
var _React$useState = React.useState(null),
|
|
59
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
60
|
-
popperElement = _React$useState2[0],
|
|
61
|
-
setPopperElement = _React$useState2[1];
|
|
62
|
-
|
|
63
|
-
var referenceElement = anchorElRef ? anchorElRef.current : null;
|
|
64
|
-
var normalOverflowModifiers = [{
|
|
65
|
-
name: 'preventOverflow',
|
|
66
|
-
enabled: false
|
|
67
|
-
}, {
|
|
68
|
-
name: 'hide',
|
|
69
|
-
enabled: false
|
|
70
|
-
}];
|
|
71
|
-
var options = popperOptions || {
|
|
72
|
-
placement: placement,
|
|
73
|
-
modifiers: preventOverflow ? undefined : normalOverflowModifiers
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
var _usePopper = usePopper(referenceElement, popperElement, options),
|
|
77
|
-
styles = _usePopper.styles,
|
|
78
|
-
attributes = _usePopper.attributes;
|
|
79
|
-
|
|
80
|
-
var handleClose = function handleClose(e) {
|
|
81
|
-
if (referenceElement.contains(e.target)) return;
|
|
82
|
-
onClose(e);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
return /*#__PURE__*/React.createElement("div", _extends({
|
|
86
|
-
ref: setPopperElement,
|
|
87
|
-
style: _objectSpread(_objectSpread({}, styles.popper), {}, {
|
|
88
|
-
zIndex: getCssVariableValue('zIndex-popover')
|
|
89
|
-
})
|
|
90
|
-
}, attributes.popper), /*#__PURE__*/React.createElement(ClickAwayListener, {
|
|
91
|
-
onClickAway: handleClose
|
|
92
|
-
}, children));
|
|
93
|
-
};
|
|
94
|
-
|
|
95
19
|
var logDepecratedPlacement = createDepreciationLogger();
|
|
96
20
|
var logDepecratedOverflow = createDepreciationLogger();
|
|
97
21
|
var logDepecratedContainer = createDepreciationLogger();
|
|
98
22
|
|
|
99
|
-
var ActionMenu = function ActionMenu(
|
|
100
|
-
var children =
|
|
101
|
-
autoclose =
|
|
102
|
-
className =
|
|
103
|
-
onClose =
|
|
104
|
-
placement =
|
|
105
|
-
preventOverflow =
|
|
106
|
-
popperOptions =
|
|
107
|
-
anchorElRef =
|
|
108
|
-
containerElRef =
|
|
23
|
+
var ActionMenu = function ActionMenu(_ref) {
|
|
24
|
+
var children = _ref.children,
|
|
25
|
+
autoclose = _ref.autoclose,
|
|
26
|
+
className = _ref.className,
|
|
27
|
+
onClose = _ref.onClose,
|
|
28
|
+
placement = _ref.placement,
|
|
29
|
+
preventOverflow = _ref.preventOverflow,
|
|
30
|
+
popperOptions = _ref.popperOptions,
|
|
31
|
+
anchorElRef = _ref.anchorElRef,
|
|
32
|
+
containerElRef = _ref.containerElRef;
|
|
109
33
|
if (placement) logDepecratedPlacement('<ActionMenu placement /> is deprecated, use <ActionMenu popperOptions={{ placement }} /> instead');
|
|
110
34
|
if (preventOverflow) logDepecratedOverflow('<ActionMenu preventOverflow /> is deprecated, use <ActionMenu popperOptions={{ modifiers }} /> instead');
|
|
111
35
|
if (containerElRef) logDepecratedContainer('<ActionMenu containerElRef /> is not needed anymore, it can be removed.');
|
|
@@ -158,58 +82,5 @@ ActionMenu.defaultProps = {
|
|
|
158
82
|
},
|
|
159
83
|
autoclose: false
|
|
160
84
|
};
|
|
161
|
-
|
|
162
|
-
var ActionMenuHeader = function ActionMenuHeader(_ref4) {
|
|
163
|
-
var children = _ref4.children,
|
|
164
|
-
className = _ref4.className;
|
|
165
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
166
|
-
className: cx(styles['c-actionmenu-header'], className)
|
|
167
|
-
}, children);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
ActionMenuHeader.propTypes = {
|
|
171
|
-
children: PropTypes.node,
|
|
172
|
-
className: PropTypes.string
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
var ActionMenuItem = function ActionMenuItem(_ref5) {
|
|
176
|
-
var left = _ref5.left,
|
|
177
|
-
children = _ref5.children,
|
|
178
|
-
right = _ref5.right,
|
|
179
|
-
onClick = _ref5.onClick,
|
|
180
|
-
className = _ref5.className,
|
|
181
|
-
contentSpacing = _ref5.contentSpacing;
|
|
182
|
-
return /*#__PURE__*/React.createElement(Media, {
|
|
183
|
-
className: cx(styles['c-actionmenu-item'], className),
|
|
184
|
-
onClick: onClick,
|
|
185
|
-
align: "top"
|
|
186
|
-
}, left && /*#__PURE__*/React.createElement(Img, {
|
|
187
|
-
className: "u-mh-1"
|
|
188
|
-
}, left), /*#__PURE__*/React.createElement(Bd, {
|
|
189
|
-
className: cx(left ? 'u-mr-1' : 'u-mh-1', "u-stack-".concat(contentSpacing))
|
|
190
|
-
}, children), right && /*#__PURE__*/React.createElement(Img, {
|
|
191
|
-
className: "u-mr-1"
|
|
192
|
-
}, right));
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
var ActionMenuRadio = function ActionMenuRadio(props) {
|
|
196
|
-
return /*#__PURE__*/React.createElement(Radio, _extends({}, props, {
|
|
197
|
-
className: styles['c-actionmenu-radio']
|
|
198
|
-
}));
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
ActionMenuItem.propTypes = {
|
|
202
|
-
left: PropTypes.node,
|
|
203
|
-
right: PropTypes.node,
|
|
204
|
-
children: PropTypes.node,
|
|
205
|
-
onClick: PropTypes.func,
|
|
206
|
-
className: PropTypes.string,
|
|
207
|
-
|
|
208
|
-
/** Controls spacing between between children of the ActionMenuItem */
|
|
209
|
-
contentSpacing: spacingProp
|
|
210
|
-
};
|
|
211
|
-
ActionMenuItem.defaultProps = {
|
|
212
|
-
contentSpacing: 'xs'
|
|
213
|
-
};
|
|
214
85
|
export default ActionMenu;
|
|
215
86
|
export { ActionMenuHeader, ActionMenuItem, ActionMenuRadio };
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
9
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
10
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
|
-
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
6
|
+
var _excluded = ["hideLabel", "showLabel", "fullwidth", "secondaryComponent", "inputRef"],
|
|
12
7
|
_excluded2 = ["className", "variant"];
|
|
13
8
|
|
|
14
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
10
|
|
|
16
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
-
|
|
22
|
-
import React from 'react';
|
|
13
|
+
import React, { useState } from 'react';
|
|
23
14
|
import cx from 'classnames';
|
|
24
15
|
import omit from 'lodash/omit';
|
|
25
16
|
import PropTypes from 'prop-types';
|
|
@@ -56,72 +47,41 @@ var inputSpecificPropTypes = {
|
|
|
56
47
|
onKeyUp: PropTypes.func
|
|
57
48
|
};
|
|
58
49
|
|
|
59
|
-
var InputPassword =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
76
|
-
visible: false
|
|
50
|
+
var InputPassword = function InputPassword(_ref) {
|
|
51
|
+
var hideLabel = _ref.hideLabel,
|
|
52
|
+
showLabel = _ref.showLabel,
|
|
53
|
+
fullwidth = _ref.fullwidth,
|
|
54
|
+
secondaryComponent = _ref.secondaryComponent,
|
|
55
|
+
inputRef = _ref.inputRef,
|
|
56
|
+
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
57
|
+
|
|
58
|
+
var _useState = useState(false),
|
|
59
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
+
visible = _useState2[0],
|
|
61
|
+
setVisible = _useState2[1];
|
|
62
|
+
|
|
63
|
+
var toggleVisibility = function toggleVisibility() {
|
|
64
|
+
setVisible(function (visible) {
|
|
65
|
+
return !visible;
|
|
77
66
|
});
|
|
67
|
+
};
|
|
78
68
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}, {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
hideLabel = _this$props.hideLabel,
|
|
96
|
-
showLabel = _this$props.showLabel,
|
|
97
|
-
fullwidth = _this$props.fullwidth,
|
|
98
|
-
secondaryComponent = _this$props.secondaryComponent,
|
|
99
|
-
restProps = _objectWithoutProperties(_this$props, _excluded);
|
|
100
|
-
|
|
101
|
-
var visible = this.state.visible;
|
|
102
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
103
|
-
className: styles['o-field-input']
|
|
104
|
-
}, !secondaryComponent && /*#__PURE__*/React.createElement("div", {
|
|
105
|
-
className: cx(labelStyles['c-label'], styles['o-field-input-action'], _defineProperty({}, styles['o-side-fullwidth'], fullwidth)),
|
|
106
|
-
onClick: function onClick() {
|
|
107
|
-
return _this2.toggleVisibility();
|
|
108
|
-
}
|
|
109
|
-
}, visible ? hideLabel : showLabel), secondaryComponent && /*#__PURE__*/React.createElement("div", {
|
|
110
|
-
className: cx(styles['o-field-input-action'], _defineProperty({}, styles['o-side-fullwidth'], fullwidth)),
|
|
111
|
-
onClick: function onClick() {
|
|
112
|
-
return _this2.toggleVisibility();
|
|
113
|
-
}
|
|
114
|
-
}, secondaryComponent({
|
|
115
|
-
visible: visible
|
|
116
|
-
})), /*#__PURE__*/React.createElement(Input, _extends({}, restProps, {
|
|
117
|
-
fullwidth: fullwidth,
|
|
118
|
-
type: visible ? 'text' : 'password'
|
|
119
|
-
})));
|
|
120
|
-
}
|
|
121
|
-
}]);
|
|
122
|
-
|
|
123
|
-
return InputPassword;
|
|
124
|
-
}(React.Component);
|
|
69
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: styles['o-field-input']
|
|
71
|
+
}, !secondaryComponent && /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
className: cx(labelStyles['c-label'], styles['o-field-input-action'], _defineProperty({}, styles['o-side-fullwidth'], fullwidth)),
|
|
73
|
+
onClick: toggleVisibility
|
|
74
|
+
}, visible ? hideLabel : showLabel), secondaryComponent && /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: cx(styles['o-field-input-action'], _defineProperty({}, styles['o-side-fullwidth'], fullwidth)),
|
|
76
|
+
onClick: toggleVisibility
|
|
77
|
+
}, secondaryComponent({
|
|
78
|
+
visible: visible
|
|
79
|
+
})), /*#__PURE__*/React.createElement(Input, _extends({}, restProps, {
|
|
80
|
+
ref: inputRef,
|
|
81
|
+
fullwidth: fullwidth,
|
|
82
|
+
type: visible ? 'text' : 'password'
|
|
83
|
+
})));
|
|
84
|
+
};
|
|
125
85
|
|
|
126
86
|
InputPassword.propTypes = _objectSpread(_objectSpread({}, Input.propTypes), {}, {
|
|
127
87
|
hideLabel: PropTypes.string,
|
|
@@ -236,7 +196,7 @@ var Field = function Field(props) {
|
|
|
236
196
|
disabled: disabled,
|
|
237
197
|
fullwidth: fullwidth,
|
|
238
198
|
id: id,
|
|
239
|
-
|
|
199
|
+
ref: inputRef,
|
|
240
200
|
name: name,
|
|
241
201
|
type: type,
|
|
242
202
|
placeholder: placeholder,
|
|
@@ -54,11 +54,6 @@ Input.propTypes = {
|
|
|
54
54
|
error: PropTypes.bool,
|
|
55
55
|
size: PropTypes.oneOf(['tiny', 'medium', 'large']),
|
|
56
56
|
fullwidth: PropTypes.bool,
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Use that property to pass a ref callback to the native input component.
|
|
60
|
-
*/
|
|
61
|
-
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
62
57
|
onChange: PropTypes.func,
|
|
63
58
|
onKeyUp: PropTypes.func
|
|
64
59
|
};
|
|
@@ -11,7 +11,7 @@ import ActionMenuDesktop from "cozy-ui/transpiled/react/Viewer/Panel/ActionMenuD
|
|
|
11
11
|
var mespapiersAppSlug = 'mespapiers';
|
|
12
12
|
|
|
13
13
|
var checkEditableAttribute = function checkEditableAttribute(name) {
|
|
14
|
-
var isNotEditableAttributes = ['datetime', 'qualification'
|
|
14
|
+
var isNotEditableAttributes = ['datetime', 'qualification'];
|
|
15
15
|
return !isNotEditableAttributes.includes(name);
|
|
16
16
|
};
|
|
17
17
|
|