cozy-ui 60.2.0 → 60.3.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 +9 -0
- package/assets/icons/ui/radio-checked.svg +3 -0
- package/assets/icons/ui/radio-unchecked.svg +3 -0
- package/package.json +1 -1
- package/react/Icon/Readme.md +5 -1
- package/react/Icon/icons-sprite.js +4 -0
- package/react/Icons/RadioChecked.jsx +16 -0
- package/react/Icons/RadioUnchecked.jsx +16 -0
- package/react/MuiCozyTheme/makeOverrides.js +29 -0
- package/react/Radio/index.jsx +10 -0
- package/react/Radios/Readme.md +133 -0
- package/react/Radios/index.jsx +23 -0
- package/react/__snapshots__/examples.spec.jsx.snap +84 -79
- package/react/examples.spec.jsx +1 -1
- package/react/index.js +1 -0
- package/transpiled/react/Icon/icons-sprite.js +1 -1
- package/transpiled/react/Icons/RadioChecked.js +15 -0
- package/transpiled/react/Icons/RadioUnchecked.js +15 -0
- package/transpiled/react/MuiCozyTheme/makeOverrides.js +29 -0
- package/transpiled/react/Radio/index.js +6 -0
- package/transpiled/react/Radios/index.js +22 -0
- package/transpiled/react/index.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# [60.3.0](https://github.com/cozy/cozy-ui/compare/v60.2.0...v60.3.0) (2022-01-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add new icons radio-checked and radio-unchecked ([d441d6c](https://github.com/cozy/cozy-ui/commit/d441d6c))
|
|
7
|
+
* Add new Radios button ([13cf089](https://github.com/cozy/cozy-ui/commit/13cf089))
|
|
8
|
+
* Deprecates old Radio component ([b5785b4](https://github.com/cozy/cozy-ui/commit/b5785b4))
|
|
9
|
+
|
|
1
10
|
# [60.2.0](https://github.com/cozy/cozy-ui/compare/v60.1.0...v60.2.0) (2022-01-19)
|
|
2
11
|
|
|
3
12
|
|
package/package.json
CHANGED
package/react/Icon/Readme.md
CHANGED
|
@@ -182,6 +182,8 @@ import PlusSmall from 'cozy-ui/transpiled/react/Icons/PlusSmall'
|
|
|
182
182
|
import Previous from 'cozy-ui/transpiled/react/Icons/Previous'
|
|
183
183
|
import Printer from 'cozy-ui/transpiled/react/Icons/Printer'
|
|
184
184
|
import Qualify from 'cozy-ui/transpiled/react/Icons/Qualify'
|
|
185
|
+
import RadioChecked from 'cozy-ui/transpiled/react/Icons/RadioChecked'
|
|
186
|
+
import RadioUnchecked from 'cozy-ui/transpiled/react/Icons/RadioUnchecked'
|
|
185
187
|
import Rename from 'cozy-ui/transpiled/react/Icons/Rename'
|
|
186
188
|
import Repare from 'cozy-ui/transpiled/react/Icons/Repare'
|
|
187
189
|
import Reply from 'cozy-ui/transpiled/react/Icons/Reply'
|
|
@@ -388,6 +390,8 @@ const icons = [
|
|
|
388
390
|
Previous,
|
|
389
391
|
Printer,
|
|
390
392
|
Qualify,
|
|
393
|
+
RadioChecked,
|
|
394
|
+
RadioUnchecked,
|
|
391
395
|
Rename,
|
|
392
396
|
Repare,
|
|
393
397
|
Reply,
|
|
@@ -694,7 +698,7 @@ import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
|
694
698
|
|
|
695
699
|
const colors = ['#297EF2', '#08b442', '#B449E7', '#F52D2D', '#FF962F']
|
|
696
700
|
let i = 0
|
|
697
|
-
const availableIcons = ['album-add','album-remove','album','answer','apple','archive','attachment','attention','bank','banking-add','banking','bell','bike','bill','bottom','browser-brave','browser-chrome','browser-duckduckgo','browser-edge','browser-edge-chromium','browser-firefox','browser-ie','browser-opera','browser-safari','burger','bus','calendar','camera','car','carbonCopy','categories','certified','check-circle','check-list','check-square','check','checkbox','circle-filled','clock','cloud-happy','cloud','collect','comment','company','compass','connector','contract','contrast','cozy-laugh','cozy-text','credit-card-add','credit-card','credit','crop','cross-circle','cross-medium','cross-small','cross','cube','dash','dashboard','data-control','debit','devices','dots','down','download','drawing-arrow-up','dropdown-close','dropdown-open','dropdown','dropup','email-notification','email','eu','euro','exchange','eye-closed','eye','file-add','file-duotone','file-new','file-none','file-outline','file','filter','fingerprint','fitness','flag-outlined','flag','flash-auto','flashlight','folder-add','folder','forbidden','from-user','gear','globe','graph-circle','grid','group-list','groups','heart','help','history','home','hourglass','image','info-outlined','info','key','laptop','left','lightbulb','link-out','link','list','location','lock','logout','magic-trick','magnet','magnifier','merge','mountain','movement-in','movement-out','mouvement','moveto','multi-files','music','new','next','note','notification-email','offline','online','openwith','palette','paperplane','password','pen','people','percent-circle','percent','personal-data','phone-download','phone','pie-chart','pin','plane','plus-small','plus','previous','printer','qualify','
|
|
701
|
+
const availableIcons = ['album-add','album-remove','album','answer','apple','archive','attachment','attention','bank','banking-add','banking','bell','bike','bill','bottom','browser-brave','browser-chrome','browser-duckduckgo','browser-edge','browser-edge-chromium','browser-firefox','browser-ie','browser-opera','browser-safari','burger','bus','calendar','camera','car','carbonCopy','categories','certified','check-circle','check-list','check-square','check','checkbox','circle-filled','clock','cloud-happy','cloud','collect','comment','company','compass','connector','contract','contrast','cozy-laugh','cozy-text','credit-card-add','credit-card','credit','crop','cross-circle','cross-medium','cross-small','cross','cube','dash','dashboard','data-control','debit','devices','dots','down','download','drawing-arrow-up','dropdown-close','dropdown-open','dropdown','dropup','email-notification','email','eu','euro','exchange','eye-closed','eye','file-add','file-duotone','file-new','file-none','file-outline','file','filter','fingerprint','fitness','flag-outlined','flag','flash-auto','flashlight','folder-add','folder','forbidden','from-user','gear','globe','graph-circle','grid','group-list','groups','heart','help','history','home','hourglass','image','info-outlined','info','key','laptop','left','lightbulb','link-out','link','list','location','lock','logout','magic-trick','magnet','magnifier','merge','mountain','movement-in','movement-out','mouvement','moveto','multi-files','music','new','next','note','notification-email','offline','online','openwith','palette','paperplane','password','pen','people','percent-circle','percent','personal-data','phone-download','phone','pie-chart','pin','plane','plus-small','plus','previous','printer','qualify','radio-checked','radio-unchecked','repare','reply','restaurant','restore-straight','restore','right','rise','rotate-left','rotate-right','sad-cozy','safe','school','select-all','setting','share-circle','share','shield','shop','sound','spinner','stack','star','stats','subway','sync-cozy','sync','target','team','telephone','to-the-cloud','top','train','trash','trophy','unknow','unlink','unlock','up','upload','videos','walk','wallet-add','wallet-new','wallet','warn','warning-circle','warning','wrench-circle']
|
|
698
702
|
;
|
|
699
703
|
<div style={{ fontSize: '2rem', display: 'grid', gridTemplateColumns: 'repeat(6, 1fr)' }}>
|
|
700
704
|
<Sprite />
|
|
@@ -465,6 +465,10 @@ module.exports = `<svg><defs>
|
|
|
465
465
|
<path fill-rule="evenodd" d="M13 12v3c0 .552-.456 1-.995 1h-8.01A.995.995 0 0 1 3 15v-3H1c-.552 0-1-.438-1-1.003V6.003A1 1 0 0 1 1 5h14c.552 0 1 .438 1 1.003v4.994A1 1 0 0 1 15 12h-2zM3 1.01C3 .451 3.456 0 3.995 0h8.01c.55 0 .995.443.995 1.01V4H3V1.01zM5 10v4h6v-4H5zm9-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/>
|
|
466
466
|
</symbol><symbol id="qualify" viewBox="0 0 16 16">
|
|
467
467
|
<path fill-rule="evenodd" d="M2 2h8.002a2 2 0 0 1 1.414.586l4 4a2 2 0 0 1 0 2.828l-4 4a2 2 0 0 1-1.414.586H2a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z"/>
|
|
468
|
+
</symbol><symbol id="radio-checked" viewBox="0 0 16 16">
|
|
469
|
+
<path fill-rule="evenodd" d="M8 16A8 8 0 108 0a8 8 0 000 16zm0-6a2 2 0 100-4 2 2 0 000 4z" clip-rule="evenodd"/>
|
|
470
|
+
</symbol><symbol id="radio-unchecked" viewBox="0 0 16 16">
|
|
471
|
+
<path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zm0 14A6 6 0 108 2a6 6 0 000 12z" clip-rule="evenodd"/>
|
|
468
472
|
</symbol><symbol id="rename" viewBox="0 0 16 16">
|
|
469
473
|
<path fill-rule="evenodd" d="M201.5,99.5 L192,109.025391 L192,112 L195.03772,112 L204.5,102.5 L201.5,99.5 Z M206.912154,96.9121541 C206.132243,96.1322429 204.869144,96.1308556 204.089264,96.9107361 L203,98 L206.030762,101 L207.092271,99.9252663 C207.869738,99.1381134 207.863777,97.8637772 207.087846,97.0878459 L206.912154,96.9121541 Z M199,110 L204.997071,110 C205.550973,110 206,110.443865 206,111 C206,111.552285 205.553689,112 205.002455,112 L197,112 L199,110 Z" transform="translate(-192 -96)"/>
|
|
470
474
|
</symbol><symbol id="repare" viewBox="0 0 16 16">
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Automatically created, please run `scripts/generate-svgr-icon.sh assets/icons/ui/radio-checked.svg` to regenerate;
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
function SvgRadioChecked(props) {
|
|
5
|
+
return (
|
|
6
|
+
<svg viewBox="0 0 16 16" {...props}>
|
|
7
|
+
<path
|
|
8
|
+
fillRule="evenodd"
|
|
9
|
+
d="M8 16A8 8 0 108 0a8 8 0 000 16zm0-6a2 2 0 100-4 2 2 0 000 4z"
|
|
10
|
+
clipRule="evenodd"
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default SvgRadioChecked
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Automatically created, please run `scripts/generate-svgr-icon.sh assets/icons/ui/radio-unchecked.svg` to regenerate;
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
function SvgRadioUnchecked(props) {
|
|
5
|
+
return (
|
|
6
|
+
<svg viewBox="0 0 16 16" {...props}>
|
|
7
|
+
<path
|
|
8
|
+
fillRule="evenodd"
|
|
9
|
+
d="M8 0a8 8 0 100 16A8 8 0 008 0zm0 14A6 6 0 108 2a6 6 0 000 12z"
|
|
10
|
+
clipRule="evenodd"
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default SvgRadioUnchecked
|
|
@@ -629,6 +629,35 @@ const makeOverrides = theme => ({
|
|
|
629
629
|
minWidth: '.375rem'
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
|
+
},
|
|
633
|
+
MuiRadio: {
|
|
634
|
+
root: {
|
|
635
|
+
padding: '12px',
|
|
636
|
+
'&.Mui-disabled svg': {
|
|
637
|
+
borderRadius: '50%',
|
|
638
|
+
backgroundColor: theme.palette.background.default,
|
|
639
|
+
fill: theme.palette.border.disabled
|
|
640
|
+
},
|
|
641
|
+
'&:not(.Mui-checked) svg': {
|
|
642
|
+
fill: theme.palette.border.main
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
colorPrimary: {
|
|
646
|
+
'&.Mui-checked svg': {
|
|
647
|
+
fill: theme.palette.primary.main
|
|
648
|
+
},
|
|
649
|
+
'&.Mui-disabled&.Mui-checked svg': {
|
|
650
|
+
fill: theme.palette.text.disabled
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
colorSecondary: {
|
|
654
|
+
'&.Mui-checked svg': {
|
|
655
|
+
fill: theme.palette.error.main
|
|
656
|
+
},
|
|
657
|
+
'&.Mui-disabled&.Mui-checked svg': {
|
|
658
|
+
fill: theme.palette.text.disabled
|
|
659
|
+
}
|
|
660
|
+
}
|
|
632
661
|
}
|
|
633
662
|
})
|
|
634
663
|
|
package/react/Radio/index.jsx
CHANGED
|
@@ -4,6 +4,13 @@ import PropTypes from 'prop-types'
|
|
|
4
4
|
import styles from './styles.styl'
|
|
5
5
|
import { useRadioGroup } from '@material-ui/core/RadioGroup'
|
|
6
6
|
|
|
7
|
+
import createDepreciationLogger from '../helpers/createDepreciationLogger'
|
|
8
|
+
|
|
9
|
+
const logRadioDepecrated = createDepreciationLogger()
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Please use [Radios](#/Radios)
|
|
13
|
+
*/
|
|
7
14
|
const Radio = props => {
|
|
8
15
|
const {
|
|
9
16
|
className,
|
|
@@ -18,6 +25,9 @@ const Radio = props => {
|
|
|
18
25
|
checked: checkedProp,
|
|
19
26
|
...restProps
|
|
20
27
|
} = props
|
|
28
|
+
logRadioDepecrated(
|
|
29
|
+
'The Radio component is deprecated, please use `<Radios />` instead. You can replace `<Radio value="" label="" />` by `<FormControlLabel value="" label="" control={<Radios />} />`. See documentation for more details.'
|
|
30
|
+
)
|
|
21
31
|
const radioGroup = useRadioGroup()
|
|
22
32
|
|
|
23
33
|
let checked = checkedProp
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
### Radios
|
|
2
|
+
|
|
3
|
+
```jsx
|
|
4
|
+
import Radio from 'cozy-ui/transpiled/react/Radios'
|
|
5
|
+
import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup'
|
|
6
|
+
import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel'
|
|
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
|
+
|
|
14
|
+
initialState = { radioValue: 'item1' }
|
|
15
|
+
|
|
16
|
+
const initialVariants = [
|
|
17
|
+
{ checked: false, disabled: false, secondary: false }
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
const handleChange = event => {
|
|
21
|
+
setState({ radioValue: event.target.value })
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const bboxStyle = { border: '1px solid red' }
|
|
25
|
+
|
|
26
|
+
;
|
|
27
|
+
|
|
28
|
+
<>
|
|
29
|
+
<RadioGroup
|
|
30
|
+
aria-label="radio"
|
|
31
|
+
name="radioName"
|
|
32
|
+
value={state.radioValue.toString()}
|
|
33
|
+
onChange={handleChange}
|
|
34
|
+
>
|
|
35
|
+
<FormControlLabel
|
|
36
|
+
value="item1"
|
|
37
|
+
label="This is a radio button"
|
|
38
|
+
control={
|
|
39
|
+
<Radio />
|
|
40
|
+
}
|
|
41
|
+
/>
|
|
42
|
+
<FormControlLabel
|
|
43
|
+
value="item2"
|
|
44
|
+
label="This is an intent radio button"
|
|
45
|
+
control={
|
|
46
|
+
<Radio color="secondary" />
|
|
47
|
+
}
|
|
48
|
+
/>
|
|
49
|
+
<FormControlLabel
|
|
50
|
+
value="item3"
|
|
51
|
+
label="This is a disabled radio button"
|
|
52
|
+
control={
|
|
53
|
+
<Radio disabled />
|
|
54
|
+
}
|
|
55
|
+
/>
|
|
56
|
+
<FormControlLabel
|
|
57
|
+
value="item4"
|
|
58
|
+
label="This is a checked disabled radio button"
|
|
59
|
+
control={
|
|
60
|
+
<Radio checked disabled />
|
|
61
|
+
}
|
|
62
|
+
/>
|
|
63
|
+
<FormControlLabel
|
|
64
|
+
value="item5"
|
|
65
|
+
label="This is a edge start radio button"
|
|
66
|
+
control={
|
|
67
|
+
<Radio edge="start" />
|
|
68
|
+
}
|
|
69
|
+
/>
|
|
70
|
+
<FormControlLabel
|
|
71
|
+
value="item6"
|
|
72
|
+
label="This is a edge end radio button"
|
|
73
|
+
control={
|
|
74
|
+
<Radio edge="end" />
|
|
75
|
+
}
|
|
76
|
+
/>
|
|
77
|
+
</RadioGroup>
|
|
78
|
+
|
|
79
|
+
{isTesting() && (
|
|
80
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
81
|
+
{variant => (
|
|
82
|
+
<Radio
|
|
83
|
+
color={variant.secondary ? 'secondary' : 'primary'}
|
|
84
|
+
checked={variant.checked}
|
|
85
|
+
disabled={variant.disabled}
|
|
86
|
+
/>
|
|
87
|
+
)}
|
|
88
|
+
</Variants>
|
|
89
|
+
)}
|
|
90
|
+
</>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Radios position
|
|
94
|
+
|
|
95
|
+
By default Radio are centered. It's possible to move the radio inside a container with `edge` property.
|
|
96
|
+
|
|
97
|
+
```jsx
|
|
98
|
+
import Radio from 'cozy-ui/transpiled/react/Radios'
|
|
99
|
+
import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup'
|
|
100
|
+
import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel'
|
|
101
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
102
|
+
const Box = ({ children }) => {
|
|
103
|
+
return <div style={{ height: '3rem', width: '3rem', border: '2px dashed #CCC', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
|
104
|
+
{ children }
|
|
105
|
+
</div>
|
|
106
|
+
}
|
|
107
|
+
|
|
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
|
+
const bboxStyle = { border: '1px solid red' }
|
|
119
|
+
|
|
120
|
+
;
|
|
121
|
+
|
|
122
|
+
<>
|
|
123
|
+
<Box>
|
|
124
|
+
<Radio edge={false} style={bboxStyle} />
|
|
125
|
+
</Box>
|
|
126
|
+
<Box>
|
|
127
|
+
<Radio edge="start" style={bboxStyle} />
|
|
128
|
+
</Box>
|
|
129
|
+
<Box>
|
|
130
|
+
<Radio edge="end" style={bboxStyle} />
|
|
131
|
+
</Box>
|
|
132
|
+
</>
|
|
133
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import MuiRadio from '@material-ui/core/Radio'
|
|
4
|
+
|
|
5
|
+
import Icon from '../Icon'
|
|
6
|
+
import RadioCheckedIcon from '../Icons/RadioChecked'
|
|
7
|
+
import RadioUncheckedIcon from '../Icons/RadioUnchecked'
|
|
8
|
+
|
|
9
|
+
const Radios = props => {
|
|
10
|
+
return (
|
|
11
|
+
<MuiRadio
|
|
12
|
+
{...props}
|
|
13
|
+
icon={<Icon icon={RadioUncheckedIcon} />}
|
|
14
|
+
checkedIcon={<Icon icon={RadioCheckedIcon} />}
|
|
15
|
+
/>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Radios.defaultProps = {
|
|
20
|
+
color: 'primary'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default Radios
|