cozy-ui 119.1.0 → 119.2.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [119.2.0](https://github.com/cozy/cozy-ui/compare/v119.1.0...v119.2.0) (2025-03-12)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Switch:** Adjust style component ([4e89011](https://github.com/cozy/cozy-ui/commit/4e89011))
7
+
1
8
  # [119.1.0](https://github.com/cozy/cozy-ui/compare/v119.0.3...v119.1.0) (2025-03-12)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "119.1.0",
3
+ "version": "119.2.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -10,6 +10,60 @@ export const makeLightNormalTwakeOverrides = theme => {
10
10
  padding: 8
11
11
  }
12
12
  },
13
+ MuiSwitch: {
14
+ root: {
15
+ width: 50,
16
+ height: 40,
17
+ padding: '6px 1px'
18
+ },
19
+ switchBase: {
20
+ padding: 5,
21
+ top: 5,
22
+ color: theme.palette.text.icon,
23
+ '& .cozySwitchThumb': {
24
+ display: 'flex',
25
+ alignItems: 'center',
26
+ justifyContent: 'center',
27
+ width: 20,
28
+ height: 20,
29
+ borderRadius: '50%',
30
+ boxShadow: theme.shadows[1],
31
+ backgroundColor: theme.palette.common.white
32
+ }
33
+ },
34
+ track: {
35
+ width: 44,
36
+ height: '100%',
37
+ borderRadius: 100
38
+ },
39
+ thumb: {
40
+ width: 20,
41
+ height: 20
42
+ },
43
+ colorPrimary: {
44
+ '&$disabled + $track': {
45
+ opacity: 1,
46
+ backgroundColor: theme.palette.action.disabledBackground
47
+ }
48
+ },
49
+ colorSecondary: {
50
+ '&$checked': {
51
+ color: theme.palette.success.main
52
+ },
53
+ '&$disabled + $track': {
54
+ opacity: 1,
55
+ backgroundColor: theme.palette.action.disabledBackground
56
+ }
57
+ },
58
+ disabled: {
59
+ '&$checked + $track': {
60
+ backgroundColor: theme.palette.action.disabledBackground
61
+ },
62
+ '& .cozySwitchThumb': {
63
+ backgroundColor: theme.palette.background.default
64
+ }
65
+ }
66
+ },
13
67
  MuiButton: {
14
68
  root: {
15
69
  borderRadius: 100,
@@ -1,14 +1,13 @@
1
1
  Used to present a binary choice to the user.
2
2
 
3
- Uses [Material UI's Switch](https://material-ui.com/components/switches/).
4
-
5
3
  ```jsx
6
4
  import { useState, useCallback } from 'react'
7
- import { Media, Img } from 'cozy-ui/transpiled/react/deprecated/Media'
8
5
  import Switch from 'cozy-ui/transpiled/react/Switch'
9
6
  import Typography from "cozy-ui/transpiled/react/Typography"
10
7
  import Stack from "cozy-ui/transpiled/react/Stack"
11
- import Box from '@material-ui/core/Box'
8
+ import Box from 'cozy-ui/transpiled/react/Box'
9
+ import CheckIcon from 'cozy-ui/transpiled/react/Icons/Check'
10
+ import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel'
12
11
 
13
12
  initialState = {
14
13
  switch0: true,
@@ -22,26 +21,54 @@ const StateSwitch = ({ id, color }) => {
22
21
  return <Switch
23
22
  color={color}
24
23
  checked={checked}
24
+ {...(isTwakeTheme() && { icon: CheckIcon })}
25
25
  onChange={handleClick}
26
26
  />
27
27
  }
28
28
 
29
- const Switches = () => {
30
- return <Stack spacing='xs'>
31
- {['primary', 'secondary', 'default'].map((color, i) => {
32
- return (
33
- <Box display='flex' alignItems='center' key={i}>
34
- <Typography variant='body1' display="inline">
35
- { color }
36
- </Typography>
37
- <StateSwitch id={i} color={color} />
38
- </Box>
39
- )
40
- })}
41
- </Stack>
42
- }
43
-
44
29
  ;
45
30
 
46
- <Switches />
31
+ <Stack spacing='xs'>
32
+ {['primary', 'secondary', 'default'].map((color, i) => {
33
+ return (
34
+ <Box display='flex' alignItems='center' key={i}>
35
+ <Typography variant='body1' display="inline">{ color }</Typography>
36
+ <StateSwitch id={i} color={color} />
37
+ </Box>
38
+ )
39
+ })}
40
+ <FormControlLabel control={<Switch color="primary" />} label="With label" />
41
+ <FormControlLabel control={<Switch color="primary" checked />} label="With label" />
42
+ <br />
43
+ <FormControlLabel control={<Switch color="primary" disabled />} label="Primary, disabled with label" />
44
+ <FormControlLabel control={<Switch color="primary" checked disabled />} label="Primary, checked - disabled with label" />
45
+ <br />
46
+ <FormControlLabel
47
+ label="Primary, disabled with label"
48
+ control={
49
+ <Switch
50
+ color="primary"
51
+ {...(isTwakeTheme() && { icon: CheckIcon })}
52
+ disabled
53
+ />
54
+ }
55
+ />
56
+ <FormControlLabel
57
+ label="Primary, checked - disabled with label"
58
+ control={
59
+ <Switch
60
+ color="primary"
61
+ {...(isTwakeTheme() && { icon: CheckIcon })}
62
+ checked
63
+ disabled
64
+ />
65
+ }
66
+ />
67
+ <br />
68
+ <FormControlLabel control={<Switch color="secondary" disabled />} label="Secondary, checked with label" />
69
+ <FormControlLabel control={<Switch color="secondary" checked disabled />} label="Secondary, checked - disabled with label" />
70
+ <br />
71
+ <FormControlLabel control={<Switch disabled />} label="Default, checked with label" />
72
+ <FormControlLabel control={<Switch checked disabled />} label="Default, checked - disabled with label" />
73
+ </Stack>
47
74
  ```
@@ -1,3 +1,22 @@
1
- import Switch from '@material-ui/core/Switch'
1
+ import MuiSwitch from '@material-ui/core/Switch'
2
+ import React from 'react'
3
+
4
+ import Icon from '../Icon'
5
+ import { isTwakeTheme } from '../helpers/isTwakeTheme'
6
+
7
+ const Switch = ({ icon, ...props }) => {
8
+ const _icon = (
9
+ <span className="cozySwitchThumb">
10
+ {!!icon && <Icon icon={icon} size={14} />}
11
+ </span>
12
+ )
13
+
14
+ return (
15
+ <MuiSwitch
16
+ {...props}
17
+ {...(isTwakeTheme() && { icon: _icon, checkedIcon: _icon })}
18
+ />
19
+ )
20
+ }
2
21
 
3
22
  export default Switch
@@ -1417,6 +1417,60 @@ export function makeDarkInvertedTwakeOverrides(theme: any): {
1417
1417
  padding: number;
1418
1418
  };
1419
1419
  };
1420
+ MuiSwitch: {
1421
+ root: {
1422
+ width: number;
1423
+ height: number;
1424
+ padding: string;
1425
+ };
1426
+ switchBase: {
1427
+ padding: number;
1428
+ top: number;
1429
+ color: any;
1430
+ '& .cozySwitchThumb': {
1431
+ display: string;
1432
+ alignItems: string;
1433
+ justifyContent: string;
1434
+ width: number;
1435
+ height: number;
1436
+ borderRadius: string;
1437
+ boxShadow: any;
1438
+ backgroundColor: any;
1439
+ };
1440
+ };
1441
+ track: {
1442
+ width: number;
1443
+ height: string;
1444
+ borderRadius: number;
1445
+ };
1446
+ thumb: {
1447
+ width: number;
1448
+ height: number;
1449
+ };
1450
+ colorPrimary: {
1451
+ '&$disabled + $track': {
1452
+ opacity: number;
1453
+ backgroundColor: any;
1454
+ };
1455
+ };
1456
+ colorSecondary: {
1457
+ '&$checked': {
1458
+ color: any;
1459
+ };
1460
+ '&$disabled + $track': {
1461
+ opacity: number;
1462
+ backgroundColor: any;
1463
+ };
1464
+ };
1465
+ disabled: {
1466
+ '&$checked + $track': {
1467
+ backgroundColor: any;
1468
+ };
1469
+ '& .cozySwitchThumb': {
1470
+ backgroundColor: any;
1471
+ };
1472
+ };
1473
+ };
1420
1474
  MuiButton: {
1421
1475
  root: {
1422
1476
  borderRadius: number;
@@ -1417,6 +1417,60 @@ export function makeDarkNormalTwakeOverrides(theme: any): {
1417
1417
  padding: number;
1418
1418
  };
1419
1419
  };
1420
+ MuiSwitch: {
1421
+ root: {
1422
+ width: number;
1423
+ height: number;
1424
+ padding: string;
1425
+ };
1426
+ switchBase: {
1427
+ padding: number;
1428
+ top: number;
1429
+ color: any;
1430
+ '& .cozySwitchThumb': {
1431
+ display: string;
1432
+ alignItems: string;
1433
+ justifyContent: string;
1434
+ width: number;
1435
+ height: number;
1436
+ borderRadius: string;
1437
+ boxShadow: any;
1438
+ backgroundColor: any;
1439
+ };
1440
+ };
1441
+ track: {
1442
+ width: number;
1443
+ height: string;
1444
+ borderRadius: number;
1445
+ };
1446
+ thumb: {
1447
+ width: number;
1448
+ height: number;
1449
+ };
1450
+ colorPrimary: {
1451
+ '&$disabled + $track': {
1452
+ opacity: number;
1453
+ backgroundColor: any;
1454
+ };
1455
+ };
1456
+ colorSecondary: {
1457
+ '&$checked': {
1458
+ color: any;
1459
+ };
1460
+ '&$disabled + $track': {
1461
+ opacity: number;
1462
+ backgroundColor: any;
1463
+ };
1464
+ };
1465
+ disabled: {
1466
+ '&$checked + $track': {
1467
+ backgroundColor: any;
1468
+ };
1469
+ '& .cozySwitchThumb': {
1470
+ backgroundColor: any;
1471
+ };
1472
+ };
1473
+ };
1420
1474
  MuiButton: {
1421
1475
  root: {
1422
1476
  borderRadius: number;
@@ -1417,6 +1417,60 @@ export function makeLightInvertedTwakeOverrides(theme: any): {
1417
1417
  padding: number;
1418
1418
  };
1419
1419
  };
1420
+ MuiSwitch: {
1421
+ root: {
1422
+ width: number;
1423
+ height: number;
1424
+ padding: string;
1425
+ };
1426
+ switchBase: {
1427
+ padding: number;
1428
+ top: number;
1429
+ color: any;
1430
+ '& .cozySwitchThumb': {
1431
+ display: string;
1432
+ alignItems: string;
1433
+ justifyContent: string;
1434
+ width: number;
1435
+ height: number;
1436
+ borderRadius: string;
1437
+ boxShadow: any;
1438
+ backgroundColor: any;
1439
+ };
1440
+ };
1441
+ track: {
1442
+ width: number;
1443
+ height: string;
1444
+ borderRadius: number;
1445
+ };
1446
+ thumb: {
1447
+ width: number;
1448
+ height: number;
1449
+ };
1450
+ colorPrimary: {
1451
+ '&$disabled + $track': {
1452
+ opacity: number;
1453
+ backgroundColor: any;
1454
+ };
1455
+ };
1456
+ colorSecondary: {
1457
+ '&$checked': {
1458
+ color: any;
1459
+ };
1460
+ '&$disabled + $track': {
1461
+ opacity: number;
1462
+ backgroundColor: any;
1463
+ };
1464
+ };
1465
+ disabled: {
1466
+ '&$checked + $track': {
1467
+ backgroundColor: any;
1468
+ };
1469
+ '& .cozySwitchThumb': {
1470
+ backgroundColor: any;
1471
+ };
1472
+ };
1473
+ };
1420
1474
  MuiButton: {
1421
1475
  root: {
1422
1476
  borderRadius: number;
@@ -1417,6 +1417,60 @@ export function makeLightNormalTwakeOverrides(theme: any): {
1417
1417
  padding: number;
1418
1418
  };
1419
1419
  };
1420
+ MuiSwitch: {
1421
+ root: {
1422
+ width: number;
1423
+ height: number;
1424
+ padding: string;
1425
+ };
1426
+ switchBase: {
1427
+ padding: number;
1428
+ top: number;
1429
+ color: any;
1430
+ '& .cozySwitchThumb': {
1431
+ display: string;
1432
+ alignItems: string;
1433
+ justifyContent: string;
1434
+ width: number;
1435
+ height: number;
1436
+ borderRadius: string;
1437
+ boxShadow: any;
1438
+ backgroundColor: any;
1439
+ };
1440
+ };
1441
+ track: {
1442
+ width: number;
1443
+ height: string;
1444
+ borderRadius: number;
1445
+ };
1446
+ thumb: {
1447
+ width: number;
1448
+ height: number;
1449
+ };
1450
+ colorPrimary: {
1451
+ '&$disabled + $track': {
1452
+ opacity: number;
1453
+ backgroundColor: any;
1454
+ };
1455
+ };
1456
+ colorSecondary: {
1457
+ '&$checked': {
1458
+ color: any;
1459
+ };
1460
+ '&$disabled + $track': {
1461
+ opacity: number;
1462
+ backgroundColor: any;
1463
+ };
1464
+ };
1465
+ disabled: {
1466
+ '&$checked + $track': {
1467
+ backgroundColor: any;
1468
+ };
1469
+ '& .cozySwitchThumb': {
1470
+ backgroundColor: any;
1471
+ };
1472
+ };
1473
+ };
1420
1474
  MuiButton: {
1421
1475
  root: {
1422
1476
  borderRadius: number;
@@ -9,6 +9,60 @@ export var makeLightNormalTwakeOverrides = function makeLightNormalTwakeOverride
9
9
  padding: 8
10
10
  }
11
11
  },
12
+ MuiSwitch: {
13
+ root: {
14
+ width: 50,
15
+ height: 40,
16
+ padding: '6px 1px'
17
+ },
18
+ switchBase: {
19
+ padding: 5,
20
+ top: 5,
21
+ color: theme.palette.text.icon,
22
+ '& .cozySwitchThumb': {
23
+ display: 'flex',
24
+ alignItems: 'center',
25
+ justifyContent: 'center',
26
+ width: 20,
27
+ height: 20,
28
+ borderRadius: '50%',
29
+ boxShadow: theme.shadows[1],
30
+ backgroundColor: theme.palette.common.white
31
+ }
32
+ },
33
+ track: {
34
+ width: 44,
35
+ height: '100%',
36
+ borderRadius: 100
37
+ },
38
+ thumb: {
39
+ width: 20,
40
+ height: 20
41
+ },
42
+ colorPrimary: {
43
+ '&$disabled + $track': {
44
+ opacity: 1,
45
+ backgroundColor: theme.palette.action.disabledBackground
46
+ }
47
+ },
48
+ colorSecondary: {
49
+ '&$checked': {
50
+ color: theme.palette.success.main
51
+ },
52
+ '&$disabled + $track': {
53
+ opacity: 1,
54
+ backgroundColor: theme.palette.action.disabledBackground
55
+ }
56
+ },
57
+ disabled: {
58
+ '&$checked + $track': {
59
+ backgroundColor: theme.palette.action.disabledBackground
60
+ },
61
+ '& .cozySwitchThumb': {
62
+ backgroundColor: theme.palette.background.default
63
+ }
64
+ }
65
+ },
12
66
  MuiButton: {
13
67
  root: {
14
68
  borderRadius: 100,
@@ -1,2 +1,26 @@
1
- import Switch from '@material-ui/core/Switch';
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["icon"];
4
+ import MuiSwitch from '@material-ui/core/Switch';
5
+ import React from 'react';
6
+ import Icon from "cozy-ui/transpiled/react/Icon";
7
+ import { isTwakeTheme } from "cozy-ui/transpiled/react/helpers/isTwakeTheme";
8
+
9
+ var Switch = function Switch(_ref) {
10
+ var icon = _ref.icon,
11
+ props = _objectWithoutProperties(_ref, _excluded);
12
+
13
+ var _icon = /*#__PURE__*/React.createElement("span", {
14
+ className: "cozySwitchThumb"
15
+ }, !!icon && /*#__PURE__*/React.createElement(Icon, {
16
+ icon: icon,
17
+ size: 14
18
+ }));
19
+
20
+ return /*#__PURE__*/React.createElement(MuiSwitch, _extends({}, props, isTwakeTheme() && {
21
+ icon: _icon,
22
+ checkedIcon: _icon
23
+ }));
24
+ };
25
+
2
26
  export default Switch;