cozy-ui 135.2.0 → 135.4.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.
Files changed (28) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/assets/icons/ui/article.svg +1 -0
  3. package/assets/icons/ui/cross-circle.svg +1 -1
  4. package/package.json +2 -3
  5. package/react/ActionsBar/Readme.md +61 -11
  6. package/react/ActionsBar/ResponsiveAction.jsx +3 -5
  7. package/react/ActionsBar/index.jsx +98 -71
  8. package/react/AppBar/index.js +66 -1
  9. package/react/Icon/Readme.md +3 -1
  10. package/react/Icons/Article.jsx +12 -0
  11. package/react/Icons/CrossCircle.jsx +1 -4
  12. package/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.js +16 -1
  13. package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +6 -0
  14. package/transpiled/react/ActionsBar/ResponsiveAction.js +3 -2
  15. package/transpiled/react/ActionsBar/index.js +37 -24
  16. package/transpiled/react/AppBar/index.d.ts +3 -2
  17. package/transpiled/react/AppBar/index.js +53 -1
  18. package/transpiled/react/Icon/icons-sprite.d.ts +1 -1
  19. package/transpiled/react/Icon/icons-sprite.js +1 -1
  20. package/transpiled/react/Icons/Article.d.ts +2 -0
  21. package/transpiled/react/Icons/Article.js +14 -0
  22. package/transpiled/react/Icons/CrossCircle.js +1 -2
  23. package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +6 -0
  24. package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +12 -0
  25. package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.js +13 -1
  26. package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +6 -0
  27. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +6 -0
  28. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +6 -0
@@ -19,7 +19,6 @@ import DotsIcon from "cozy-ui/transpiled/react/Icons/Dots";
19
19
  import Toolbar from "cozy-ui/transpiled/react/Toolbar";
20
20
  import Typography from "cozy-ui/transpiled/react/Typography";
21
21
  import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
22
- import CozyTheme, { useCozyTheme } from "cozy-ui/transpiled/react/providers/CozyTheme";
23
22
  import { makeStyles } from "cozy-ui/transpiled/react/styles";
24
23
  var useStyles = makeStyles({
25
24
  appBar: function appBar(_ref) {
@@ -78,9 +77,17 @@ var useStyles = makeStyles({
78
77
  }
79
78
  });
80
79
 
80
+ var DefaultIcon = function DefaultIcon() {
81
+ return /*#__PURE__*/React.createElement(Icon, {
82
+ className: "u-mr-1",
83
+ icon: CheckCircleIcon
84
+ });
85
+ };
86
+
81
87
  var SelectedCount = function SelectedCount(_ref4) {
82
88
  var docs = _ref4.docs,
83
- onClose = _ref4.onClose;
89
+ onClose = _ref4.onClose,
90
+ IconComponent = _ref4.IconComponent;
84
91
 
85
92
  var _useBreakpoints = useBreakpoints(),
86
93
  isMobile = _useBreakpoints.isMobile;
@@ -88,11 +95,12 @@ var SelectedCount = function SelectedCount(_ref4) {
88
95
  var _useI18n = useI18n(),
89
96
  t = _useI18n.t;
90
97
 
98
+ var SelectedIcon = IconComponent || DefaultIcon;
91
99
  if (isMobile) return /*#__PURE__*/React.createElement(Box, {
92
100
  className: "u-flex u-flex-items-center u-h-100 u-pr-1",
93
101
  borderRadius: "15px 0 0 0",
94
- bgcolor: "primary.main",
95
- color: "primary.contrastText"
102
+ bgcolor: "background.paper",
103
+ color: "text.primary"
96
104
  }, /*#__PURE__*/React.createElement(IconButton, {
97
105
  color: "inherit",
98
106
  onClick: onClose
@@ -101,13 +109,10 @@ var SelectedCount = function SelectedCount(_ref4) {
101
109
  })), docs.length);
102
110
  return /*#__PURE__*/React.createElement("div", {
103
111
  className: "u-flex u-flex-items-center u-h-100 u-ph-1"
104
- }, /*#__PURE__*/React.createElement(Icon, {
105
- className: "u-mr-1",
106
- icon: CheckCircleIcon,
107
- color: "var(--iconTextColor)"
108
- }), /*#__PURE__*/React.createElement(Typography, {
112
+ }, /*#__PURE__*/React.createElement(SelectedIcon, null), /*#__PURE__*/React.createElement(Typography, {
109
113
  variant: "body1",
110
- component: "span"
114
+ component: "span",
115
+ color: "inherit"
111
116
  }, t('selected_light', docs.length)));
112
117
  };
113
118
 
@@ -116,14 +121,13 @@ var ActionsBar = function ActionsBar(_ref5) {
116
121
  docs = _ref5.docs,
117
122
  autoClose = _ref5.autoClose,
118
123
  maxDesktopActions = _ref5.maxDesktopActions,
119
- onClose = _ref5.onClose;
124
+ onClose = _ref5.onClose,
125
+ color = _ref5.color,
126
+ IconComponent = _ref5.IconComponent;
120
127
 
121
128
  var _useBreakpoints2 = useBreakpoints(),
122
129
  isMobile = _useBreakpoints2.isMobile;
123
130
 
124
- var _useCozyTheme = useCozyTheme(),
125
- type = _useCozyTheme.type;
126
-
127
131
  var anchorRef = useRef();
128
132
 
129
133
  var _useState = useState(false),
@@ -149,25 +153,24 @@ var ActionsBar = function ActionsBar(_ref5) {
149
153
  autoClose && (onClose === null || onClose === void 0 ? void 0 : onClose());
150
154
  };
151
155
 
152
- return /*#__PURE__*/React.createElement(CozyTheme, {
153
- type: type,
154
- variant: "inverted"
155
- }, /*#__PURE__*/React.createElement(AppBar, {
156
+ return /*#__PURE__*/React.createElement(AppBar, {
156
157
  className: styles.appBar,
157
158
  position: "fixed",
158
- color: "inherit"
159
+ color: color
159
160
  }, /*#__PURE__*/React.createElement(Toolbar, {
160
161
  className: styles.toolbar,
161
162
  variant: isMobile ? 'regular' : 'dense',
162
163
  disableGutters: true
163
164
  }, showDesktopCloseButton && /*#__PURE__*/React.createElement(IconButton, {
164
165
  className: styles.desktopCloseButton,
165
- onClick: onClose
166
+ onClick: onClose,
167
+ color: "inherit"
166
168
  }, /*#__PURE__*/React.createElement(Icon, {
167
169
  icon: CrossIcon
168
170
  })), /*#__PURE__*/React.createElement(SelectedCount, {
169
171
  docs: docs,
170
- onClose: onClose
172
+ onClose: onClose,
173
+ IconComponent: IconComponent
171
174
  }), /*#__PURE__*/React.createElement("div", {
172
175
  className: styles.actionsContainer
173
176
  }, /*#__PURE__*/React.createElement(ActionsItems, {
@@ -183,6 +186,7 @@ var ActionsBar = function ActionsBar(_ref5) {
183
186
  return setShowMenu(true);
184
187
  }
185
188
  }) : /*#__PURE__*/React.createElement(IconButton, {
189
+ color: "inherit",
186
190
  ref: anchorRef,
187
191
  onClick: function onClick() {
188
192
  return setShowMenu(true);
@@ -206,7 +210,7 @@ var ActionsBar = function ActionsBar(_ref5) {
206
210
  onClose: function onClose() {
207
211
  return setShowMenu(false);
208
212
  }
209
- }))))));
213
+ })))));
210
214
  };
211
215
 
212
216
  ActionsBar.propTypes = {
@@ -216,10 +220,19 @@ ActionsBar.propTypes = {
216
220
  * Only works on desktop since maximum number is forced in mobile
217
221
  */
218
222
  maxDesktopActions: PropTypes.number,
219
- autoClose: PropTypes.bool
223
+ autoClose: PropTypes.bool,
224
+ color: PropTypes.oneOf(['default', 'inherit', 'primary', 'secondary', 'transparent', 'error', 'warning', 'info', 'success']),
225
+
226
+ /**
227
+ * Custom React component to replace the default Icon with CheckCircleIcon
228
+ * displayed next to the selection count on desktop.
229
+ * The component will be rendered as-is, giving full control over the icon styling.
230
+ */
231
+ IconComponent: PropTypes.elementType
220
232
  };
221
233
  ActionsBar.defaultProps = {
222
234
  maxDesktopActions: 5,
223
- autoClose: true
235
+ autoClose: true,
236
+ color: 'default'
224
237
  };
225
238
  export default withActionsLocales(ActionsBar);
@@ -1,2 +1,3 @@
1
- export default MuiAppBar;
2
- import MuiAppBar from "@material-ui/core/AppBar";
1
+ export default AppBar;
2
+ declare const AppBar: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
+ import React from "react";
@@ -1,2 +1,54 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["color", "className"];
1
4
  import MuiAppBar from '@material-ui/core/AppBar';
2
- export default MuiAppBar;
5
+ import PropTypes from 'prop-types';
6
+ import React from 'react';
7
+ import { makeStyles } from "cozy-ui/transpiled/react/styles";
8
+ var useStyles = makeStyles(function (theme) {
9
+ return {
10
+ colorError: {
11
+ backgroundColor: theme.palette.error.main,
12
+ color: theme.palette.error.contrastText
13
+ },
14
+ colorWarning: {
15
+ backgroundColor: theme.palette.warning.main,
16
+ color: theme.palette.warning.contrastText
17
+ },
18
+ colorInfo: {
19
+ backgroundColor: theme.palette.info.main,
20
+ color: theme.palette.info.contrastText
21
+ },
22
+ colorSuccess: {
23
+ backgroundColor: theme.palette.success.main,
24
+ color: theme.palette.success.contrastText
25
+ }
26
+ };
27
+ });
28
+ var CUSTOM_COLOR_CLASSES = {
29
+ error: 'colorError',
30
+ warning: 'colorWarning',
31
+ info: 'colorInfo',
32
+ success: 'colorSuccess'
33
+ };
34
+ var AppBar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
35
+ var color = _ref.color,
36
+ className = _ref.className,
37
+ props = _objectWithoutProperties(_ref, _excluded);
38
+
39
+ var styles = useStyles();
40
+ var appBarColor = CUSTOM_COLOR_CLASSES[color] ? 'default' : color;
41
+ var customColorClass = CUSTOM_COLOR_CLASSES[color] ? styles[CUSTOM_COLOR_CLASSES[color]] : undefined;
42
+ return /*#__PURE__*/React.createElement(MuiAppBar, _extends({}, props, {
43
+ ref: ref,
44
+ color: appBarColor,
45
+ className: "".concat(className || '', " ").concat(customColorClass || '')
46
+ }));
47
+ });
48
+ AppBar.propTypes = {
49
+ color: PropTypes.oneOf(['default', 'inherit', 'primary', 'secondary', 'transparent', 'error', 'warning', 'info', 'success'])
50
+ };
51
+ AppBar.defaultProps = {
52
+ color: 'default'
53
+ };
54
+ export default AppBar;