cozy-ui 110.0.1 → 110.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cozy-ui.min.css +1 -1
  3. package/package.json +1 -1
  4. package/react/BottomSheet/BottomSheet.jsx +7 -2
  5. package/react/Dialog/DialogEffects.spec.tsx +8 -4
  6. package/react/Dialog/DialogEffects.ts +14 -6
  7. package/react/IntentDialogOpener/IntentDialogOpener.md +4 -3
  8. package/react/IntentHeader/styles.styl +2 -2
  9. package/react/IntentIframe/Readme.md +8 -13
  10. package/react/IntentIframe/styles.styl +1 -2
  11. package/react/Layout/Layout.md +52 -14
  12. package/react/Sidebar/index.jsx +3 -1
  13. package/react/Viewer/ViewerInformationsWrapper.jsx +3 -1
  14. package/react/deprecated/ActionMenu/ActionMenuEffects.ts +7 -4
  15. package/react/deprecated/Modal/ModalEffects.ts +15 -6
  16. package/react/deprecated/Modal/index.jsx +21 -3
  17. package/react/providers/CozyTheme/index.jsx +10 -17
  18. package/stylus/components/modals.styl +4 -4
  19. package/stylus/elements/defaults.styl +0 -1
  20. package/stylus/objects/layouts.styl +2 -6
  21. package/transpiled/react/BottomSheet/BottomSheet.js +8 -4
  22. package/transpiled/react/Dialog/DialogEffects.d.ts +3 -2
  23. package/transpiled/react/Dialog/DialogEffects.js +15 -6
  24. package/transpiled/react/MuiCozyTheme/helpers.d.ts +138 -0
  25. package/transpiled/react/MuiCozyTheme/index.d.ts +19 -0
  26. package/transpiled/react/MuiCozyTheme/makePalette.d.ts +1 -0
  27. package/transpiled/react/MuiCozyTheme/makeTheme.d.ts +15 -0
  28. package/transpiled/react/MuiCozyTheme/makeTypography.d.ts +66 -0
  29. package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +1427 -0
  30. package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +1376 -0
  31. package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +1427 -0
  32. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +1376 -0
  33. package/transpiled/react/MuiCozyTheme/theme.d.ts +61 -0
  34. package/transpiled/react/Sidebar/index.js +6 -1
  35. package/transpiled/react/Viewer/ViewerInformationsWrapper.js +6 -1
  36. package/transpiled/react/deprecated/ActionMenu/ActionMenuEffects.js +9 -4
  37. package/transpiled/react/deprecated/Modal/ModalEffects.js +12 -6
  38. package/transpiled/react/deprecated/Modal/index.js +23 -9
  39. package/transpiled/react/helpers/isTesting.d.ts +2 -0
  40. package/transpiled/react/hooks/useMediaQuery.d.ts +2 -0
  41. package/transpiled/react/providers/CozyTheme/CozyThemeWithQuery.d.ts +2 -0
  42. package/transpiled/react/providers/CozyTheme/index.d.ts +38 -0
  43. package/transpiled/react/providers/CozyTheme/index.js +9 -10
  44. package/transpiled/react/providers/CozyTheme/queries.d.ts +8 -0
  45. package/transpiled/react/styles/index.d.ts +1 -0
  46. package/transpiled/react/stylesheet.css +1 -1
  47. package/transpiled/react/utils/color.d.ts +2 -0
@@ -0,0 +1,61 @@
1
+ export const lightNormalTheme: {
2
+ overrides: any;
3
+ shape: import("@material-ui/core/styles/shape").Shape;
4
+ breakpoints: import("@material-ui/core/styles/createBreakpoints").Breakpoints;
5
+ direction: import("@material-ui/core").Direction;
6
+ mixins: import("@material-ui/core/styles/createMixins").Mixins;
7
+ palette: import("@material-ui/core/styles/createPalette").Palette;
8
+ props?: import("@material-ui/core/styles/props").ComponentsProps | undefined;
9
+ shadows: import("@material-ui/core/styles/shadows").Shadows;
10
+ spacing: import("@material-ui/core/styles/createSpacing").Spacing;
11
+ transitions: import("@material-ui/core").Transitions;
12
+ typography: import("@material-ui/core/styles/createTypography").Typography;
13
+ zIndex: import("@material-ui/core/styles/zIndex").ZIndex;
14
+ unstable_strictMode?: boolean | undefined;
15
+ };
16
+ export const lightInvertedTheme: {
17
+ overrides: any;
18
+ shape: import("@material-ui/core/styles/shape").Shape;
19
+ breakpoints: import("@material-ui/core/styles/createBreakpoints").Breakpoints;
20
+ direction: import("@material-ui/core").Direction;
21
+ mixins: import("@material-ui/core/styles/createMixins").Mixins;
22
+ palette: import("@material-ui/core/styles/createPalette").Palette;
23
+ props?: import("@material-ui/core/styles/props").ComponentsProps | undefined;
24
+ shadows: import("@material-ui/core/styles/shadows").Shadows;
25
+ spacing: import("@material-ui/core/styles/createSpacing").Spacing;
26
+ transitions: import("@material-ui/core").Transitions;
27
+ typography: import("@material-ui/core/styles/createTypography").Typography;
28
+ zIndex: import("@material-ui/core/styles/zIndex").ZIndex;
29
+ unstable_strictMode?: boolean | undefined;
30
+ };
31
+ export const darkNormalTheme: {
32
+ overrides: any;
33
+ shape: import("@material-ui/core/styles/shape").Shape;
34
+ breakpoints: import("@material-ui/core/styles/createBreakpoints").Breakpoints;
35
+ direction: import("@material-ui/core").Direction;
36
+ mixins: import("@material-ui/core/styles/createMixins").Mixins;
37
+ palette: import("@material-ui/core/styles/createPalette").Palette;
38
+ props?: import("@material-ui/core/styles/props").ComponentsProps | undefined;
39
+ shadows: import("@material-ui/core/styles/shadows").Shadows;
40
+ spacing: import("@material-ui/core/styles/createSpacing").Spacing;
41
+ transitions: import("@material-ui/core").Transitions;
42
+ typography: import("@material-ui/core/styles/createTypography").Typography;
43
+ zIndex: import("@material-ui/core/styles/zIndex").ZIndex;
44
+ unstable_strictMode?: boolean | undefined;
45
+ };
46
+ export const darkInvertedTheme: {
47
+ overrides: any;
48
+ shape: import("@material-ui/core/styles/shape").Shape;
49
+ breakpoints: import("@material-ui/core/styles/createBreakpoints").Breakpoints;
50
+ direction: import("@material-ui/core").Direction;
51
+ mixins: import("@material-ui/core/styles/createMixins").Mixins;
52
+ palette: import("@material-ui/core/styles/createPalette").Palette;
53
+ props?: import("@material-ui/core/styles/props").ComponentsProps | undefined;
54
+ shadows: import("@material-ui/core/styles/shadows").Shadows;
55
+ spacing: import("@material-ui/core/styles/createSpacing").Spacing;
56
+ transitions: import("@material-ui/core").Transitions;
57
+ typography: import("@material-ui/core/styles/createTypography").Typography;
58
+ zIndex: import("@material-ui/core/styles/zIndex").ZIndex;
59
+ unstable_strictMode?: boolean | undefined;
60
+ };
61
+ export function getTheme(type: any, variant: any): any;
@@ -8,6 +8,7 @@ var styles = {
8
8
  "o-sidebar": "styles__o-sidebar___1295j"
9
9
  };
10
10
  import { useSetFlagshipUI } from "cozy-ui/transpiled/react/hooks/useSetFlagshipUi/useSetFlagshipUI";
11
+ import { useCozyTheme } from "cozy-ui/transpiled/react/providers/CozyTheme";
11
12
  import { useTheme } from '@material-ui/core';
12
13
 
13
14
  var Sidebar = function Sidebar(_ref) {
@@ -16,9 +17,13 @@ var Sidebar = function Sidebar(_ref) {
16
17
  restProps = _objectWithoutProperties(_ref, _excluded);
17
18
 
18
19
  var theme = useTheme();
20
+
21
+ var _useCozyTheme = useCozyTheme(),
22
+ isLight = _useCozyTheme.isLight;
23
+
19
24
  useSetFlagshipUI({
20
25
  bottomBackground: theme.palette.background.default,
21
- bottomTheme: 'dark'
26
+ bottomTheme: isLight ? 'dark' : 'light'
22
27
  }, {
23
28
  bottomBackground: theme.palette.background.paper
24
29
  }, 'cozy-ui/Sidebar');
@@ -7,6 +7,7 @@ import Footer from "cozy-ui/transpiled/react/Viewer/components/Footer";
7
7
  import PanelContent from "cozy-ui/transpiled/react/Viewer/Panel/PanelContent";
8
8
  import FooterContent from "cozy-ui/transpiled/react/Viewer/Footer/FooterContent";
9
9
  import { useSetFlagshipUI } from "cozy-ui/transpiled/react/hooks/useSetFlagshipUi/useSetFlagshipUI";
10
+ import { useCozyTheme } from "cozy-ui/transpiled/react/providers/CozyTheme";
10
11
 
11
12
  var ViewerInformationsWrapper = function ViewerInformationsWrapper(_ref) {
12
13
  var currentFile = _ref.currentFile,
@@ -16,10 +17,14 @@ var ViewerInformationsWrapper = function ViewerInformationsWrapper(_ref) {
16
17
  isPublic = _ref.isPublic,
17
18
  children = _ref.children;
18
19
  var theme = useTheme();
20
+
21
+ var _useCozyTheme = useCozyTheme(),
22
+ isLight = _useCozyTheme.isLight;
23
+
19
24
  var sidebar = document.querySelector('[class*="sidebar"]');
20
25
  useSetFlagshipUI({
21
26
  bottomBackground: theme.palette.background.paper,
22
- bottomTheme: 'dark'
27
+ bottomTheme: isLight ? 'dark' : 'light'
23
28
  }, {
24
29
  bottomBackground: theme.palette.background[sidebar ? 'default' : 'paper']
25
30
  });
@@ -4,6 +4,7 @@ import { useTheme } from '@material-ui/core';
4
4
  import { isFlagshipApp } from 'cozy-device-helper';
5
5
  import { useSetFlagshipUI } from "cozy-ui/transpiled/react/hooks/useSetFlagshipUi/useSetFlagshipUI";
6
6
  import { isRsg } from "cozy-ui/transpiled/react/hooks/useSetFlagshipUi/helpers";
7
+ import { useCozyTheme } from "cozy-ui/transpiled/react/providers/CozyTheme";
7
8
 
8
9
  var getBottomBackground = function getBottomBackground(theme) {
9
10
  var sidebar = document.getElementById('sidebar');
@@ -12,20 +13,24 @@ var getBottomBackground = function getBottomBackground(theme) {
12
13
 
13
14
  var useHook = function useHook() {
14
15
  var theme = useTheme();
16
+
17
+ var _useCozyTheme = useCozyTheme(),
18
+ isLight = _useCozyTheme.isLight;
19
+
15
20
  useSetFlagshipUI({
16
21
  bottomBackground: theme.palette.background.paper,
17
22
  // @ts-ignore
18
- bottomTheme: 'dark',
19
- topOverlay: 'var(--overlay)',
23
+ bottomTheme: isLight ? 'dark' : 'light',
24
+ topOverlay: 'rgba(0, 0, 0, 0.5)',
20
25
  topBackground: theme.palette.background.paper,
21
26
  // @ts-ignore
22
27
  topTheme: 'light'
23
28
  }, {
24
29
  bottomBackground: getBottomBackground(theme),
25
- bottomTheme: 'dark',
30
+ bottomTheme: isLight ? 'dark' : 'light',
26
31
  topOverlay: 'transparent',
27
32
  topBackground: theme.palette.background.paper,
28
- topTheme: 'dark'
33
+ topTheme: isLight ? 'dark' : 'light'
29
34
  }, 'cozy-ui/ActionMenu');
30
35
  };
31
36
 
@@ -4,33 +4,39 @@ import { useTheme } from '@material-ui/core';
4
4
  import { isFlagshipApp } from 'cozy-device-helper';
5
5
  import { useSetFlagshipUI } from "cozy-ui/transpiled/react/hooks/useSetFlagshipUi/useSetFlagshipUI";
6
6
  import { getFlagshipMetadata } from "cozy-ui/transpiled/react/hooks/useSetFlagshipUi/helpers";
7
+ import { useCozyTheme } from "cozy-ui/transpiled/react/providers/CozyTheme";
7
8
 
8
9
  var getTopBackground = function getTopBackground(theme, cozyBar) {
9
10
  return cozyBar && getComputedStyle(cozyBar).getPropertyValue('background-color') || theme.palette.background.paper;
10
11
  };
11
12
 
12
- var getTopTheme = function getTopTheme(cozyBar) {
13
- return getFlagshipMetadata().immersive || cozyBar && cozyBar.classList.contains('coz-theme-primary') ? 'light' : 'dark';
13
+ var getTopTheme = function getTopTheme(cozyBar, isLight) {
14
+ return getFlagshipMetadata().immersive || cozyBar && cozyBar.classList.contains('coz-theme-primary') || // Needed for previous versions of cozy-bar like v7. Can be removed when all apps in v12.
15
+ !isLight ? 'light' : 'dark';
14
16
  };
15
17
 
16
18
  var useHook = function useHook() {
17
19
  var theme = useTheme();
20
+
21
+ var _useCozyTheme = useCozyTheme(),
22
+ isLight = _useCozyTheme.isLight;
23
+
18
24
  var cozyBar = document.querySelector('.coz-bar-wrapper');
19
25
  var sidebar = document.getElementById('sidebar');
20
26
  useSetFlagshipUI({
21
27
  bottomBackground: theme.palette.background.paper,
22
28
  // @ts-ignore
23
- bottomTheme: 'dark',
29
+ bottomTheme: isLight ? 'dark' : 'light',
24
30
  topBackground: theme.palette.background.paper,
25
31
  // @ts-ignore
26
- topTheme: 'dark'
32
+ topTheme: isLight ? 'dark' : 'light'
27
33
  }, {
28
34
  bottomBackground: theme.palette.background[sidebar ? 'default' : 'paper'],
29
- bottomTheme: getFlagshipMetadata().immersive ? 'light' : 'dark',
35
+ bottomTheme: getFlagshipMetadata().immersive || !isLight ? 'light' : 'dark',
30
36
  bottomOverlay: 'transparent',
31
37
  topOverlay: 'transparent',
32
38
  topBackground: getTopBackground(theme, cozyBar),
33
- topTheme: getTopTheme(cozyBar)
39
+ topTheme: getTopTheme(cozyBar, isLight)
34
40
  }, 'cozy-ui/Modal');
35
41
  };
36
42
 
@@ -68,6 +68,7 @@ import ModalButtons from "cozy-ui/transpiled/react/deprecated/Modal/ModalButtons
68
68
  import AnimatedContentHeader from "cozy-ui/transpiled/react/deprecated/Modal/AnimatedContentHeader";
69
69
  import ModalBackButton from "cozy-ui/transpiled/react/deprecated/Modal/ModalBackButton";
70
70
  import { ModalEffects } from "cozy-ui/transpiled/react/deprecated/Modal/ModalEffects";
71
+ import { useCozyTheme } from "cozy-ui/transpiled/react/providers/CozyTheme";
71
72
  var ModalDescription = ModalContent;
72
73
 
73
74
  var ModalTitle = function ModalTitle(props) {
@@ -82,15 +83,15 @@ export var BODY_CLASS = 'has-modal';
82
83
  * @deprecated Please use [CozyDialogs](#/CozyDialogs) or [Dialog](#/Dialog).
83
84
  */
84
85
 
85
- var Modal = /*#__PURE__*/function (_Component) {
86
- _inherits(Modal, _Component);
86
+ var ModalWithoutTheme = /*#__PURE__*/function (_Component) {
87
+ _inherits(ModalWithoutTheme, _Component);
87
88
 
88
- var _super = _createSuper(Modal);
89
+ var _super = _createSuper(ModalWithoutTheme);
89
90
 
90
- function Modal(props) {
91
+ function ModalWithoutTheme(props) {
91
92
  var _this;
92
93
 
93
- _classCallCheck(this, Modal);
94
+ _classCallCheck(this, ModalWithoutTheme);
94
95
 
95
96
  _this = _super.call(this, props);
96
97
 
@@ -102,7 +103,7 @@ var Modal = /*#__PURE__*/function (_Component) {
102
103
  return _this;
103
104
  }
104
105
 
105
- _createClass(Modal, [{
106
+ _createClass(ModalWithoutTheme, [{
106
107
  key: "componentDidMount",
107
108
  value: function componentDidMount() {
108
109
  if (!this.props.title && !this.props['aria-label']) {
@@ -196,10 +197,10 @@ var Modal = /*#__PURE__*/function (_Component) {
196
197
  }
197
198
  }]);
198
199
 
199
- return Modal;
200
+ return ModalWithoutTheme;
200
201
  }(Component);
201
202
 
202
- Modal.propTypes = {
203
+ ModalWithoutTheme.propTypes = {
203
204
  /** Modal title */
204
205
  title: PropTypes.node,
205
206
 
@@ -262,7 +263,7 @@ Modal.propTypes = {
262
263
  /** A function to be executed when the modal is dismissed */
263
264
  dismissAction: PropTypes.func
264
265
  };
265
- Modal.defaultProps = {
266
+ ModalWithoutTheme.defaultProps = {
266
267
  primaryType: 'regular',
267
268
  secondaryType: 'secondary',
268
269
  closable: true,
@@ -288,6 +289,19 @@ ModalContent.propTypes = {
288
289
  iconDest: PropTypes.node,
289
290
  fixed: PropTypes.bool
290
291
  };
292
+
293
+ var Modal = function Modal(props) {
294
+ var _useCozyTheme = useCozyTheme(),
295
+ type = _useCozyTheme.type,
296
+ variant = _useCozyTheme.variant;
297
+
298
+ return /*#__PURE__*/React.createElement(ModalWithoutTheme, _extends({}, props, {
299
+ containerClassName: cx(props.containerClassName, "CozyTheme--".concat(type, "-").concat(variant))
300
+ }));
301
+ };
302
+
303
+ Modal.propTypes = ModalWithoutTheme.propTypes;
304
+ Modal.defaultProps = ModalWithoutTheme.defaultProps;
291
305
  var EnhancedModal = migrateProps([{
292
306
  src: 'withCross',
293
307
  dest: 'closable'
@@ -0,0 +1,2 @@
1
+ declare function _exports(): boolean | "";
2
+ export = _exports;
@@ -0,0 +1,2 @@
1
+ export default useMediaQuery;
2
+ declare function useMediaQuery(args: any, options: any): boolean;
@@ -0,0 +1,2 @@
1
+ export default CozyThemeWithQuery;
2
+ declare function CozyThemeWithQuery(props: any): JSX.Element | null;
@@ -0,0 +1,38 @@
1
+ export const CozyThemeContext: React.Context<any>;
2
+ export function useCozyTheme(): {
3
+ type: 'light' | 'dark';
4
+ variant: 'normal' | 'inverted';
5
+ isLight: boolean;
6
+ };
7
+ export default CozyTheme;
8
+ import React from "react";
9
+ declare function CozyTheme(props: any): JSX.Element;
10
+ declare namespace CozyTheme {
11
+ export { CozyThemeProptypes as propTypes };
12
+ export { CozyThemeDefaultProps as defaultProps };
13
+ }
14
+ export function DumbCozyTheme({ variant, className, ignoreItself, settingsThemeType, children }: {
15
+ variant: any;
16
+ className: any;
17
+ ignoreItself: any;
18
+ settingsThemeType: any;
19
+ children: any;
20
+ }): JSX.Element;
21
+ export namespace DumbCozyTheme {
22
+ export { CozyThemeProptypes as propTypes };
23
+ export { CozyThemeDefaultProps as defaultProps };
24
+ }
25
+ declare namespace CozyThemeProptypes {
26
+ const variant: PropTypes.Requireable<string>;
27
+ const ignoreItself: PropTypes.Requireable<boolean>;
28
+ const className: PropTypes.Requireable<string>;
29
+ const settingsThemeType: PropTypes.Requireable<string>;
30
+ const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
31
+ }
32
+ declare namespace CozyThemeDefaultProps {
33
+ const variant_1: string;
34
+ export { variant_1 as variant };
35
+ const ignoreItself_1: boolean;
36
+ export { ignoreItself_1 as ignoreItself };
37
+ }
38
+ import PropTypes from "prop-types";
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import React, { createContext, useContext, useLayoutEffect } from 'react';
2
+ import React, { createContext, useContext } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import cx from 'classnames';
5
5
  import flag from 'cozy-flags';
@@ -9,6 +9,10 @@ import useMediaQuery from "cozy-ui/transpiled/react/hooks/useMediaQuery";
9
9
  import MuiCozyTheme from "cozy-ui/transpiled/react/MuiCozyTheme";
10
10
  import CozyThemeWithQuery from "cozy-ui/transpiled/react/providers/CozyTheme/CozyThemeWithQuery";
11
11
  export var CozyThemeContext = /*#__PURE__*/createContext();
12
+ /**
13
+ * @returns {{ type: 'light'|'dark', variant: 'normal'|'inverted', isLight: boolean }}
14
+ */
15
+
12
16
  export var useCozyTheme = function useCozyTheme() {
13
17
  var context = useContext(CozyThemeContext);
14
18
 
@@ -16,7 +20,8 @@ export var useCozyTheme = function useCozyTheme() {
16
20
  log('error', '`CozyThemeContext` is missing. `useCozyTheme()` must be used within a `<CozyTheme>`. `light normal` is returned as fallback value.');
17
21
  return {
18
22
  type: 'light',
19
- variant: 'normal'
23
+ variant: 'normal',
24
+ isLight: true
20
25
  };
21
26
  }
22
27
 
@@ -40,17 +45,11 @@ var DumbCozyTheme = function DumbCozyTheme(_ref) {
40
45
  var deviceThemeType = useMediaQuery('(prefers-color-scheme: dark)') ? isOnlyLight ? 'dark' : 'light' : 'light';
41
46
  var selfThemeType = uiThemeType || (['light', 'dark'].includes(settingsThemeType) ? settingsThemeType : deviceThemeType);
42
47
  var selfThemeVariant = uiThemeVariant || variant;
43
- useLayoutEffect(function () {
44
- var negativeThemeType = selfThemeType === 'light' ? 'dark' : 'light'; // remove "negative" value because can be changed without refresh
45
-
46
- document.querySelector('body').classList.remove("CozyTheme--".concat(negativeThemeType, "-normal")); // add css var to body to be able to use them on it
47
-
48
- document.querySelector('body').classList.add("CozyTheme--".concat(selfThemeType, "-normal")); // `add` omits if already present
49
- }, [selfThemeType]);
50
48
  return /*#__PURE__*/React.createElement(CozyThemeContext.Provider, {
51
49
  value: {
52
50
  type: selfThemeType,
53
- variant: selfThemeVariant
51
+ variant: selfThemeVariant,
52
+ isLight: selfThemeType === 'light'
54
53
  }
55
54
  }, /*#__PURE__*/React.createElement(MuiCozyTheme, {
56
55
  type: selfThemeType,
@@ -0,0 +1,8 @@
1
+ export function buildSettingsInstanceQuery(): {
2
+ definition: import("cozy-client").QueryDefinition;
3
+ options: {
4
+ as: string;
5
+ fetchPolicy: Function;
6
+ singleDocData: boolean;
7
+ };
8
+ };
@@ -0,0 +1 @@
1
+ export * from "@material-ui/core/styles";