cozy-ui 130.9.0 → 130.11.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 +22 -0
- package/package.json +1 -1
- package/react/Checkbox/Readme.md +44 -39
- package/react/Checkbox/index.jsx +12 -2
- package/react/EditBadge/EditMenu.jsx +102 -0
- package/react/EditBadge/Readme.md +22 -0
- package/react/EditBadge/StatusWrapper.jsx +32 -0
- package/react/EditBadge/helpers.js +102 -0
- package/react/EditBadge/index.jsx +81 -0
- package/react/EditBadge/locales/en.json +18 -0
- package/react/EditBadge/locales/fr.json +18 -0
- package/react/EditBadge/locales/index.js +11 -0
- package/react/EditBadge/locales/ru.json +18 -0
- package/react/EditBadge/locales/vi.json +18 -0
- package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +4 -2
- package/react/Radios/Readme.md +63 -71
- package/react/Switch/Readme.md +93 -46
- package/react/utils/react.js +14 -1
- package/transpiled/react/Checkbox/index.d.ts +6 -2
- package/transpiled/react/Checkbox/index.js +6 -2
- package/transpiled/react/EditBadge/EditMenu.d.ts +11 -0
- package/transpiled/react/EditBadge/EditMenu.js +93 -0
- package/transpiled/react/EditBadge/StatusWrapper.d.ts +9 -0
- package/transpiled/react/EditBadge/StatusWrapper.js +44 -0
- package/transpiled/react/EditBadge/helpers.d.ts +20 -0
- package/transpiled/react/EditBadge/helpers.js +153 -0
- package/transpiled/react/EditBadge/index.d.ts +23 -0
- package/transpiled/react/EditBadge/index.js +89 -0
- package/transpiled/react/EditBadge/locales/index.d.ts +10 -0
- package/transpiled/react/EditBadge/locales/index.js +78 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +2 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +2 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +2 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +2 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +4 -2
- package/transpiled/react/utils/react.d.ts +1 -0
- package/transpiled/react/utils/react.js +19 -1
package/react/Radios/Readme.md
CHANGED
|
@@ -5,79 +5,80 @@ import Radio from 'cozy-ui/transpiled/react/Radios'
|
|
|
5
5
|
import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup'
|
|
6
6
|
import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel'
|
|
7
7
|
import Variants from 'cozy-ui/docs/components/Variants'
|
|
8
|
-
const Box = ({ children }) => {
|
|
9
|
-
return <div style={{ height: '3rem', width: '3rem', border: '2px dashed #CCC', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
|
10
|
-
{ children }
|
|
11
|
-
</div>
|
|
12
|
-
}
|
|
13
8
|
|
|
14
9
|
initialState = { radioValue: 'item1' }
|
|
15
10
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
]
|
|
11
|
+
const initialVariantsForScreenshots = [{ checked: false, disabled: false, secondary: false }]
|
|
12
|
+
const initialVariants = [{ before: false }]
|
|
19
13
|
|
|
20
14
|
const handleChange = event => {
|
|
21
15
|
setState({ radioValue: event.target.value })
|
|
22
16
|
}
|
|
23
17
|
|
|
24
|
-
const bboxStyle = { border: '1px solid red' }
|
|
25
|
-
|
|
26
18
|
;
|
|
27
19
|
|
|
28
20
|
<>
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
21
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
22
|
+
{variant => (
|
|
23
|
+
<RadioGroup
|
|
24
|
+
aria-label="radio"
|
|
25
|
+
name="radioName"
|
|
26
|
+
value={state.radioValue.toString()}
|
|
27
|
+
onChange={handleChange}
|
|
28
|
+
>
|
|
29
|
+
<FormControlLabel
|
|
30
|
+
value="item1"
|
|
31
|
+
label="This is a radio button"
|
|
32
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
33
|
+
control={
|
|
34
|
+
<Radio />
|
|
35
|
+
}
|
|
36
|
+
/>
|
|
37
|
+
<FormControlLabel
|
|
38
|
+
value="item2"
|
|
39
|
+
label="This is an intent radio button"
|
|
40
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
41
|
+
control={
|
|
42
|
+
<Radio color="secondary" />
|
|
43
|
+
}
|
|
44
|
+
/>
|
|
45
|
+
<FormControlLabel
|
|
46
|
+
value="item3"
|
|
47
|
+
label="This is a disabled radio button"
|
|
48
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
49
|
+
control={
|
|
50
|
+
<Radio disabled />
|
|
51
|
+
}
|
|
52
|
+
/>
|
|
53
|
+
<FormControlLabel
|
|
54
|
+
value="item4"
|
|
55
|
+
label="This is a checked disabled radio button"
|
|
56
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
57
|
+
control={
|
|
58
|
+
<Radio checked disabled />
|
|
59
|
+
}
|
|
60
|
+
/>
|
|
61
|
+
<FormControlLabel
|
|
62
|
+
value="item5"
|
|
63
|
+
label="This is a edge start radio button"
|
|
64
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
65
|
+
control={
|
|
66
|
+
<Radio edge="start" />
|
|
67
|
+
}
|
|
68
|
+
/>
|
|
69
|
+
<FormControlLabel
|
|
70
|
+
value="item6"
|
|
71
|
+
label="This is a edge end radio button"
|
|
72
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
73
|
+
control={
|
|
74
|
+
<Radio edge="end" />
|
|
75
|
+
}
|
|
76
|
+
/>
|
|
77
|
+
</RadioGroup>
|
|
78
|
+
)}
|
|
79
|
+
</Variants>
|
|
79
80
|
{isTesting() && (
|
|
80
|
-
<Variants initialVariants={
|
|
81
|
+
<Variants initialVariants={initialVariantsForScreenshots} screenshotAllVariants>
|
|
81
82
|
{variant => (
|
|
82
83
|
<Radio
|
|
83
84
|
color={variant.secondary ? 'secondary' : 'primary'}
|
|
@@ -99,22 +100,13 @@ import Radio from 'cozy-ui/transpiled/react/Radios'
|
|
|
99
100
|
import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup'
|
|
100
101
|
import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel'
|
|
101
102
|
import Variants from 'cozy-ui/docs/components/Variants'
|
|
103
|
+
|
|
102
104
|
const Box = ({ children }) => {
|
|
103
105
|
return <div style={{ height: '3rem', width: '3rem', border: '2px dashed #CCC', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
|
104
106
|
{ children }
|
|
105
107
|
</div>
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
initialState = { radioValue: 'item1' }
|
|
109
|
-
|
|
110
|
-
const initialVariants = [
|
|
111
|
-
{ checked: false, disabled: false, secondary: false }
|
|
112
|
-
]
|
|
113
|
-
|
|
114
|
-
const handleChange = event => {
|
|
115
|
-
setState({ radioValue: event.target.value })
|
|
116
|
-
}
|
|
117
|
-
|
|
118
110
|
const bboxStyle = { border: '1px solid red' }
|
|
119
111
|
|
|
120
112
|
;
|
package/react/Switch/Readme.md
CHANGED
|
@@ -6,14 +6,14 @@ import Switch from 'cozy-ui/transpiled/react/Switch'
|
|
|
6
6
|
import Typography from "cozy-ui/transpiled/react/Typography"
|
|
7
7
|
import Stack from "cozy-ui/transpiled/react/Stack"
|
|
8
8
|
import Box from 'cozy-ui/transpiled/react/Box'
|
|
9
|
+
import Divider from 'cozy-ui/transpiled/react/Divider'
|
|
9
10
|
import CheckIcon from 'cozy-ui/transpiled/react/Icons/Check'
|
|
10
11
|
import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel'
|
|
12
|
+
import FormGroup from 'cozy-ui/transpiled/react/FormGroup'
|
|
13
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
11
14
|
|
|
12
|
-
initialState = {
|
|
13
|
-
|
|
14
|
-
switch1: true,
|
|
15
|
-
switch2: false
|
|
16
|
-
}
|
|
15
|
+
initialState = { switch0: true, switch1: true, switch2: false }
|
|
16
|
+
const initialVariants = [{ before: false }]
|
|
17
17
|
|
|
18
18
|
const StateSwitch = ({ id, color }) => {
|
|
19
19
|
const [checked, setChecked] = useState(initialState[`switch${id}`])
|
|
@@ -28,47 +28,94 @@ const StateSwitch = ({ id, color }) => {
|
|
|
28
28
|
|
|
29
29
|
;
|
|
30
30
|
|
|
31
|
-
<
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
32
|
+
{variant => (
|
|
33
|
+
<Stack spacing='xs'>
|
|
34
|
+
{['primary', 'secondary', 'default'].map((color, i) => {
|
|
35
|
+
return (
|
|
36
|
+
<Box display='flex' alignItems='center' key={i}>
|
|
37
|
+
<Typography display="inline">{`${color}:`}</Typography>
|
|
38
|
+
<StateSwitch id={i} color={color} />
|
|
39
|
+
</Box>
|
|
40
|
+
)
|
|
41
|
+
})}
|
|
42
|
+
<Divider className="u-mv-1" />
|
|
43
|
+
<Typography variant="h4">With labels</Typography>
|
|
44
|
+
<FormGroup row>
|
|
45
|
+
<FormControlLabel
|
|
46
|
+
control={<Switch color="primary" />}
|
|
47
|
+
label="With label"
|
|
48
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
49
|
+
/>
|
|
50
|
+
<FormControlLabel
|
|
51
|
+
control={<Switch color="primary" checked />}
|
|
52
|
+
label="With label - checked"
|
|
53
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
54
|
+
/>
|
|
55
|
+
</FormGroup>
|
|
56
|
+
<Typography className="u-mv-1" variant="h5">With disable</Typography>
|
|
57
|
+
<FormGroup row>
|
|
58
|
+
<FormControlLabel
|
|
59
|
+
control={<Switch color="primary" disabled />}
|
|
60
|
+
label="Primary"
|
|
61
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
53
62
|
/>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
control={
|
|
59
|
-
<Switch
|
|
60
|
-
color="primary"
|
|
61
|
-
icon={CheckIcon}
|
|
62
|
-
checked
|
|
63
|
-
disabled
|
|
63
|
+
<FormControlLabel
|
|
64
|
+
control={<Switch color="primary" checked disabled />}
|
|
65
|
+
label="Primary - checked"
|
|
66
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
64
67
|
/>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
</FormGroup>
|
|
69
|
+
<FormGroup row>
|
|
70
|
+
<FormControlLabel
|
|
71
|
+
label="Primary"
|
|
72
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
73
|
+
control={
|
|
74
|
+
<Switch
|
|
75
|
+
color="primary"
|
|
76
|
+
icon={CheckIcon}
|
|
77
|
+
disabled
|
|
78
|
+
/>
|
|
79
|
+
}
|
|
80
|
+
/>
|
|
81
|
+
<FormControlLabel
|
|
82
|
+
label="Primary - checked"
|
|
83
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
84
|
+
control={
|
|
85
|
+
<Switch
|
|
86
|
+
color="primary"
|
|
87
|
+
icon={CheckIcon}
|
|
88
|
+
checked
|
|
89
|
+
disabled
|
|
90
|
+
/>
|
|
91
|
+
}
|
|
92
|
+
/>
|
|
93
|
+
</FormGroup>
|
|
94
|
+
<FormGroup row>
|
|
95
|
+
<FormControlLabel
|
|
96
|
+
control={<Switch color="secondary" disabled />}
|
|
97
|
+
label="Secondary"
|
|
98
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
99
|
+
/>
|
|
100
|
+
<FormControlLabel
|
|
101
|
+
control={<Switch color="secondary" checked disabled />}
|
|
102
|
+
label="Secondary - checked"
|
|
103
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
104
|
+
/>
|
|
105
|
+
</FormGroup>
|
|
106
|
+
<FormGroup row>
|
|
107
|
+
<FormControlLabel
|
|
108
|
+
control={<Switch disabled />}
|
|
109
|
+
label="Default"
|
|
110
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
111
|
+
/>
|
|
112
|
+
<FormControlLabel
|
|
113
|
+
control={<Switch checked disabled />}
|
|
114
|
+
label="Default - checked"
|
|
115
|
+
labelPlacement={variant.before ? "start" : "end"}
|
|
116
|
+
/>
|
|
117
|
+
</FormGroup>
|
|
118
|
+
</Stack>
|
|
119
|
+
)}
|
|
120
|
+
</Variants>
|
|
74
121
|
```
|
package/react/utils/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fragment, Children } from 'react'
|
|
1
|
+
import { Fragment, Children, isValidElement, cloneElement } from 'react'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Get the name of the node
|
|
@@ -33,3 +33,16 @@ export const getLastChild = props => {
|
|
|
33
33
|
? getChildren(lastChild.props)[0]
|
|
34
34
|
: lastChild
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Clone a React child and add props on it
|
|
39
|
+
* @param {React.ReactElement} children
|
|
40
|
+
* @param {Function} propsCallback - get child props as arg, return new props as object
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export const AddPropsToChildren = (children, propsCallback) =>
|
|
44
|
+
Children.map(children, child =>
|
|
45
|
+
isValidElement(child)
|
|
46
|
+
? cloneElement(child, { ...propsCallback(child.props) })
|
|
47
|
+
: null
|
|
48
|
+
)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export default Checkbox;
|
|
2
|
-
declare function Checkbox({ className, label, onChange, children, ...props }: {
|
|
2
|
+
declare function Checkbox({ className, label, labelPlacement, onChange, children, ...props }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
className: any;
|
|
5
5
|
label: any;
|
|
6
|
+
labelPlacement: any;
|
|
6
7
|
onChange: any;
|
|
7
8
|
children: any;
|
|
8
9
|
}): JSX.Element;
|
|
@@ -15,7 +16,8 @@ declare namespace Checkbox {
|
|
|
15
16
|
const mixed: PropTypes.Requireable<boolean>;
|
|
16
17
|
const disableEffect: PropTypes.Requireable<boolean>;
|
|
17
18
|
const size: PropTypes.Requireable<string>;
|
|
18
|
-
const
|
|
19
|
+
const labelPlacement: PropTypes.Requireable<string>;
|
|
20
|
+
const label: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
19
21
|
}
|
|
20
22
|
namespace defaultProps {
|
|
21
23
|
const className_1: string;
|
|
@@ -30,6 +32,8 @@ declare namespace Checkbox {
|
|
|
30
32
|
export { disableEffect_1 as disableEffect };
|
|
31
33
|
const size_1: string;
|
|
32
34
|
export { size_1 as size };
|
|
35
|
+
const labelPlacement_1: string;
|
|
36
|
+
export { labelPlacement_1 as labelPlacement };
|
|
33
37
|
const label_1: string;
|
|
34
38
|
export { label_1 as label };
|
|
35
39
|
}
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["className", "label", "error", "mixed", "disabled", "size", "disableEffect"],
|
|
5
|
-
_excluded2 = ["className", "label", "onChange", "children"];
|
|
5
|
+
_excluded2 = ["className", "label", "labelPlacement", "onChange", "children"];
|
|
6
6
|
import MUICheckbox from '@material-ui/core/Checkbox';
|
|
7
7
|
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
8
8
|
import cx from 'classnames';
|
|
@@ -53,6 +53,7 @@ var DefaultCheckbox = function DefaultCheckbox(_ref) {
|
|
|
53
53
|
var Checkbox = function Checkbox(_ref2) {
|
|
54
54
|
var className = _ref2.className,
|
|
55
55
|
label = _ref2.label,
|
|
56
|
+
labelPlacement = _ref2.labelPlacement,
|
|
56
57
|
onChange = _ref2.onChange,
|
|
57
58
|
children = _ref2.children,
|
|
58
59
|
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
@@ -67,6 +68,7 @@ var Checkbox = function Checkbox(_ref2) {
|
|
|
67
68
|
'FormControlLabel-error': props.error
|
|
68
69
|
}, className),
|
|
69
70
|
label: label || children,
|
|
71
|
+
labelPlacement: labelPlacement,
|
|
70
72
|
control: /*#__PURE__*/React.createElement(DefaultCheckbox, _extends({}, props, {
|
|
71
73
|
label: label
|
|
72
74
|
})),
|
|
@@ -89,7 +91,8 @@ Checkbox.propTypes = {
|
|
|
89
91
|
mixed: PropTypes.bool,
|
|
90
92
|
disableEffect: PropTypes.bool,
|
|
91
93
|
size: PropTypes.oneOf(['small', 'medium']),
|
|
92
|
-
|
|
94
|
+
labelPlacement: PropTypes.oneOf(['top', 'end', 'bottom', 'start']),
|
|
95
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
|
|
93
96
|
};
|
|
94
97
|
Checkbox.defaultProps = {
|
|
95
98
|
className: '',
|
|
@@ -98,6 +101,7 @@ Checkbox.defaultProps = {
|
|
|
98
101
|
mixed: false,
|
|
99
102
|
disableEffect: false,
|
|
100
103
|
size: 'medium',
|
|
104
|
+
labelPlacement: 'end',
|
|
101
105
|
label: ''
|
|
102
106
|
};
|
|
103
107
|
export default Checkbox;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default EditMenu;
|
|
2
|
+
declare function EditMenu({ anchorRef, status, showMenu, setShowMenu, setStatus, setTimestamp, onUpload, onDelete }: {
|
|
3
|
+
anchorRef: any;
|
|
4
|
+
status: any;
|
|
5
|
+
showMenu: any;
|
|
6
|
+
setShowMenu: any;
|
|
7
|
+
setStatus: any;
|
|
8
|
+
setTimestamp: any;
|
|
9
|
+
onUpload: any;
|
|
10
|
+
onDelete: any;
|
|
11
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { handleDelete, handleUpload } from "cozy-ui/transpiled/react/EditBadge/helpers";
|
|
3
|
+
import { locales } from "cozy-ui/transpiled/react/EditBadge/locales";
|
|
4
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
5
|
+
import CameraIcon from "cozy-ui/transpiled/react/Icons/Camera";
|
|
6
|
+
import TrashIcon from "cozy-ui/transpiled/react/Icons/Trash";
|
|
7
|
+
import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
|
|
8
|
+
import ListItemText from "cozy-ui/transpiled/react/ListItemText";
|
|
9
|
+
import Menu from "cozy-ui/transpiled/react/Menu";
|
|
10
|
+
import MenuItem from "cozy-ui/transpiled/react/MenuItem";
|
|
11
|
+
import { useAlert } from "cozy-ui/transpiled/react/providers/Alert";
|
|
12
|
+
import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
13
|
+
|
|
14
|
+
var EditMenu = function EditMenu(_ref) {
|
|
15
|
+
var anchorRef = _ref.anchorRef,
|
|
16
|
+
status = _ref.status,
|
|
17
|
+
showMenu = _ref.showMenu,
|
|
18
|
+
setShowMenu = _ref.setShowMenu,
|
|
19
|
+
setStatus = _ref.setStatus,
|
|
20
|
+
setTimestamp = _ref.setTimestamp,
|
|
21
|
+
onUpload = _ref.onUpload,
|
|
22
|
+
onDelete = _ref.onDelete;
|
|
23
|
+
useExtendI18n(locales);
|
|
24
|
+
|
|
25
|
+
var _useI18n = useI18n(),
|
|
26
|
+
t = _useI18n.t;
|
|
27
|
+
|
|
28
|
+
var _useAlert = useAlert(),
|
|
29
|
+
showAlert = _useAlert.showAlert;
|
|
30
|
+
|
|
31
|
+
var fileInputRef = useRef(null);
|
|
32
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", {
|
|
33
|
+
className: "u-dn",
|
|
34
|
+
type: "file",
|
|
35
|
+
ref: fileInputRef,
|
|
36
|
+
accept: "image/*",
|
|
37
|
+
onChange: function onChange(event) {
|
|
38
|
+
return handleUpload({
|
|
39
|
+
event: event,
|
|
40
|
+
t: t,
|
|
41
|
+
fileInputRef: fileInputRef,
|
|
42
|
+
status: status,
|
|
43
|
+
onUpload: onUpload,
|
|
44
|
+
setStatus: setStatus,
|
|
45
|
+
setTimestamp: setTimestamp,
|
|
46
|
+
setShowMenu: setShowMenu,
|
|
47
|
+
showAlert: showAlert
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}), showMenu && /*#__PURE__*/React.createElement(Menu, {
|
|
51
|
+
open: true,
|
|
52
|
+
anchorEl: anchorRef,
|
|
53
|
+
getContentAnchorEl: null,
|
|
54
|
+
anchorOrigin: {
|
|
55
|
+
vertical: 'bottom',
|
|
56
|
+
horizontal: 'left'
|
|
57
|
+
},
|
|
58
|
+
transformOrigin: {
|
|
59
|
+
vertical: 'top',
|
|
60
|
+
horizontal: 'left'
|
|
61
|
+
},
|
|
62
|
+
onClose: function onClose() {
|
|
63
|
+
return setShowMenu(false);
|
|
64
|
+
}
|
|
65
|
+
}, /*#__PURE__*/React.createElement(MenuItem, {
|
|
66
|
+
onClick: function onClick() {
|
|
67
|
+
setShowMenu(false);
|
|
68
|
+
fileInputRef.current.click(); // triggers onChange of the input
|
|
69
|
+
}
|
|
70
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
71
|
+
icon: CameraIcon
|
|
72
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
73
|
+
primary: t('EditBadge.menu.update')
|
|
74
|
+
})), /*#__PURE__*/React.createElement(MenuItem, {
|
|
75
|
+
onClick: function onClick() {
|
|
76
|
+
return handleDelete({
|
|
77
|
+
t: t,
|
|
78
|
+
status: status,
|
|
79
|
+
onDelete: onDelete,
|
|
80
|
+
setShowMenu: setShowMenu,
|
|
81
|
+
setStatus: setStatus,
|
|
82
|
+
setTimestamp: setTimestamp,
|
|
83
|
+
showAlert: showAlert
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
87
|
+
icon: TrashIcon
|
|
88
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
89
|
+
primary: t('EditBadge.menu.delete')
|
|
90
|
+
}))));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default EditMenu;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default StatusWrapper;
|
|
2
|
+
declare function StatusWrapper({ src, status, setStatus, timestamp, children }: {
|
|
3
|
+
src: any;
|
|
4
|
+
status: any;
|
|
5
|
+
setStatus: any;
|
|
6
|
+
timestamp: any;
|
|
7
|
+
children: any;
|
|
8
|
+
}): JSX.Element | (React.ReactElement<any, string | React.JSXElementConstructor<any>> | null)[];
|
|
9
|
+
import React from "react";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Spinner from "cozy-ui/transpiled/react/Spinner";
|
|
4
|
+
import { AddPropsToChildren } from "cozy-ui/transpiled/react/utils/react";
|
|
5
|
+
|
|
6
|
+
var StatusWrapper = function StatusWrapper(_ref) {
|
|
7
|
+
var src = _ref.src,
|
|
8
|
+
status = _ref.status,
|
|
9
|
+
setStatus = _ref.setStatus,
|
|
10
|
+
timestamp = _ref.timestamp,
|
|
11
|
+
children = _ref.children;
|
|
12
|
+
|
|
13
|
+
if (status === 'LOADING') {
|
|
14
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, AddPropsToChildren(children, function (childProps) {
|
|
15
|
+
return {
|
|
16
|
+
className: cx(childProps.className, 'u-o-50')
|
|
17
|
+
};
|
|
18
|
+
}), /*#__PURE__*/React.createElement(Spinner, {
|
|
19
|
+
className: "u-m-0",
|
|
20
|
+
middle: true,
|
|
21
|
+
size: "large"
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (status === 'PRESENT') {
|
|
26
|
+
return AddPropsToChildren(children, function () {
|
|
27
|
+
return {
|
|
28
|
+
key: timestamp,
|
|
29
|
+
src: src,
|
|
30
|
+
onError: function onError() {
|
|
31
|
+
return setStatus('ABSENT');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return AddPropsToChildren(children, function () {
|
|
38
|
+
return {
|
|
39
|
+
key: timestamp
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default StatusWrapper;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function handleUpload({ event, t, fileInputRef, status, onUpload, setStatus, setTimestamp, setShowMenu, showAlert }: {
|
|
2
|
+
event: any;
|
|
3
|
+
t: any;
|
|
4
|
+
fileInputRef: any;
|
|
5
|
+
status: any;
|
|
6
|
+
onUpload: any;
|
|
7
|
+
setStatus: any;
|
|
8
|
+
setTimestamp: any;
|
|
9
|
+
setShowMenu: any;
|
|
10
|
+
showAlert: any;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export function handleDelete({ t, status, onDelete, setShowMenu, setStatus, setTimestamp, showAlert }: {
|
|
13
|
+
t: any;
|
|
14
|
+
status: any;
|
|
15
|
+
onDelete: any;
|
|
16
|
+
setShowMenu: any;
|
|
17
|
+
setStatus: any;
|
|
18
|
+
setTimestamp: any;
|
|
19
|
+
showAlert: any;
|
|
20
|
+
}): Promise<void>;
|