cozy-ui 111.1.1 → 111.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.
@@ -6,33 +6,25 @@ export function useCozyTheme(): {
6
6
  };
7
7
  export default CozyTheme;
8
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;
9
+ declare function CozyTheme({ ignoreCozySettings, ...props }: {
10
+ [x: string]: any;
11
+ ignoreCozySettings: any;
20
12
  }): 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 };
13
+ declare namespace CozyTheme {
14
+ namespace propTypes {
15
+ const variant: PropTypes.Requireable<string>;
16
+ const ignoreItself: PropTypes.Requireable<boolean>;
17
+ const ignoreCozySettings: PropTypes.Requireable<boolean>;
18
+ const className: PropTypes.Requireable<string>;
19
+ const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
20
+ }
21
+ namespace defaultProps {
22
+ const variant_1: string;
23
+ export { variant_1 as variant };
24
+ const ignoreCozySettings_1: boolean;
25
+ export { ignoreCozySettings_1 as ignoreCozySettings };
26
+ const ignoreItself_1: boolean;
27
+ export { ignoreItself_1 as ignoreItself };
28
+ }
37
29
  }
38
30
  import PropTypes from "prop-types";
@@ -1,13 +1,11 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ var _excluded = ["ignoreCozySettings"];
2
3
  import React, { createContext, useContext } from 'react';
3
4
  import PropTypes from 'prop-types';
4
- import cx from 'classnames';
5
- import flag from 'cozy-flags';
6
5
  import log from 'cozy-logger';
7
6
  import { isRsg } from "cozy-ui/transpiled/react/hooks/useSetFlagshipUi/helpers";
8
- import useMediaQuery from "cozy-ui/transpiled/react/hooks/useMediaQuery";
9
- import MuiCozyTheme from "cozy-ui/transpiled/react/MuiCozyTheme";
10
7
  import CozyThemeWithQuery from "cozy-ui/transpiled/react/providers/CozyTheme/CozyThemeWithQuery";
8
+ import DumbCozyTheme from "cozy-ui/transpiled/react/providers/CozyTheme/DumbCozyTheme";
11
9
  export var CozyThemeContext = /*#__PURE__*/createContext();
12
10
  /**
13
11
  * @returns {{ type: 'light'|'dark', variant: 'normal'|'inverted', isLight: boolean }}
@@ -28,60 +26,28 @@ export var useCozyTheme = function useCozyTheme() {
28
26
  return context;
29
27
  };
30
28
 
31
- var DumbCozyTheme = function DumbCozyTheme(_ref) {
32
- var _cx;
29
+ var CozyTheme = function CozyTheme(_ref) {
30
+ var ignoreCozySettings = _ref.ignoreCozySettings,
31
+ props = _objectWithoutProperties(_ref, _excluded);
33
32
 
34
- var variant = _ref.variant,
35
- className = _ref.className,
36
- ignoreItself = _ref.ignoreItself,
37
- settingsThemeType = _ref.settingsThemeType,
38
- children = _ref.children;
39
- var uiThemeType = localStorage.getItem('ui-theme-type'); // use only for cozy-ui documentation and argos screenshots
40
-
41
- var uiThemeVariant = localStorage.getItem('ui-theme-variant'); // use only for cozy-ui documentation and argos screenshots
42
-
43
- var isOnlyLight = !!flag('ui.darkmode.enabled'); // should be remove when dark mode is validated on all apps
44
-
45
- var deviceThemeType = useMediaQuery('(prefers-color-scheme: dark)') ? isOnlyLight ? 'dark' : 'light' : 'light';
46
- var selfThemeType = uiThemeType || (['light', 'dark'].includes(settingsThemeType) ? settingsThemeType : deviceThemeType);
47
- var selfThemeVariant = uiThemeVariant || variant;
48
- return /*#__PURE__*/React.createElement(CozyThemeContext.Provider, {
49
- value: {
50
- type: selfThemeType,
51
- variant: selfThemeVariant,
52
- isLight: selfThemeType === 'light'
53
- }
54
- }, /*#__PURE__*/React.createElement(MuiCozyTheme, {
55
- type: selfThemeType,
56
- variant: selfThemeVariant
57
- }, /*#__PURE__*/React.createElement("div", {
58
- className: cx(className, (_cx = {}, _defineProperty(_cx, "CozyTheme--".concat(selfThemeType, "-").concat(selfThemeVariant), Boolean(selfThemeVariant)), _defineProperty(_cx, 'u-dc', ignoreItself), _cx))
59
- }, children)));
60
- };
61
-
62
- DumbCozyTheme.propTypes = CozyThemeProptypes;
63
- DumbCozyTheme.defaultProps = CozyThemeDefaultProps;
64
-
65
- var CozyTheme = function CozyTheme(props) {
66
- var Comp = process.env.NODE_ENV === 'test' || isRsg ? DumbCozyTheme : CozyThemeWithQuery;
33
+ var Comp = ignoreCozySettings || process.env.NODE_ENV === 'test' || isRsg ? DumbCozyTheme : CozyThemeWithQuery;
67
34
  return /*#__PURE__*/React.createElement(Comp, props);
68
35
  };
69
36
 
70
- var CozyThemeProptypes = {
37
+ CozyTheme.propTypes = {
71
38
  variant: PropTypes.oneOf(['normal', 'inverted']),
72
39
 
73
40
  /** Causes this element's children to appear as if they were direct children of the element's parent, ignoring the element itself. */
74
41
  ignoreItself: PropTypes.bool,
42
+
43
+ /** Bypasses the request that retrieves the app's settings in order to define the theme type */
44
+ ignoreCozySettings: PropTypes.bool,
75
45
  className: PropTypes.string,
76
- settingsThemeType: PropTypes.string,
77
46
  children: PropTypes.node
78
47
  };
79
- var CozyThemeDefaultProps = {
48
+ CozyTheme.defaultProps = {
80
49
  variant: 'normal',
50
+ ignoreCozySettings: false,
81
51
  ignoreItself: true
82
52
  };
83
- CozyTheme.propTypes = CozyThemeProptypes;
84
- CozyTheme.defaultProps = CozyThemeDefaultProps; // export this way to help doc generates correct component and props
85
-
86
- export default CozyTheme;
87
- export { DumbCozyTheme };
53
+ export default CozyTheme;