cozy-ui 133.0.0 → 134.0.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 +41 -5
- package/package.json +1 -1
- package/react/ActionsBar/index.jsx +3 -2
- package/react/BottomSheet/BottomSheet.jsx +4 -2
- package/react/CozyDialogs/SpecificDialogs/Readme.md +0 -58
- package/react/index.js +0 -2
- package/react/providers/CozyTheme/index.jsx +12 -23
- package/transpiled/react/ActionsBar/index.js +5 -1
- package/transpiled/react/BottomSheet/BottomSheet.js +2 -0
- package/transpiled/react/index.js +0 -2
- package/transpiled/react/providers/CozyTheme/index.d.ts +3 -4
- package/transpiled/react/providers/CozyTheme/index.js +16 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
# [134.0.0](https://github.com/cozy/cozy-ui/compare/v133.0.1...v134.0.0) (2025-11-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **ActionsBar:** Theme type wasn't set correctly ([89f4cc7](https://github.com/cozy/cozy-ui/commit/89f4cc7))
|
|
7
|
+
* **BottomSheet:** Theme type wasn't set correctly ([3f5e3e3](https://github.com/cozy/cozy-ui/commit/3f5e3e3))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **CozyTheme:** Rename prop `settingsThemeType` in `type` ([f397f65](https://github.com/cozy/cozy-ui/commit/f397f65))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### BREAKING CHANGES
|
|
16
|
+
|
|
17
|
+
* **CozyTheme:** If you use `import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'` you must replace `settingsThemeType` prop by `type`. Expl: `<CozyTheme settingsThemeType={}>` becomes `<CozyTheme type={}>`
|
|
18
|
+
|
|
19
|
+
## [133.0.1](https://github.com/cozy/cozy-ui/compare/v133.0.0...v133.0.1) (2025-11-05)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* Some export of component that doesn't exist anymore ([0667bcc](https://github.com/cozy/cozy-ui/commit/0667bcc))
|
|
25
|
+
|
|
1
26
|
# [133.0.0](https://github.com/cozy/cozy-ui/compare/v132.1.0...v133.0.0) (2025-10-30)
|
|
2
27
|
|
|
3
28
|
|
|
@@ -17,7 +42,18 @@
|
|
|
17
42
|
|
|
18
43
|
* If you use a component in that list, you must import it from `cozy-ui-plus` instead: `AppIcon, AppLinker, AppSections, AppTitle, CipherIcon, ContactPicker, Contacts/AddModal, Contacts/GroupsSelect, Contacts/Header, ContactsList, ContactsListModal, AuthenticationDialogs, Field, FileImageLoader, FilePicker, hooks/useClientErrors, IntentDialogOpener, IntentIframe, Labs/CollectionField, ListItem/ListItemByDoc, ListItem/ListItemBase, ListItem/ListItemContact, ListItem/ListItemFile, Paywall, providers/CozyTheme, providers/Intent, QualificationGrid, QualificationIcon, QualificationItem, QualificationModal, ShortcutTile, SquareAppIcon, Storage, UploadQueue, Wizard`.
|
|
19
44
|
|
|
20
|
-
|
|
45
|
+
You can use this codemods to migrate:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
yarn add cozy-ui-plus
|
|
49
|
+
yarn global add @cozy/codemods
|
|
50
|
+
yarn global add jscodeshift@0.13.1
|
|
51
|
+
jscodeshift -t $(yarn global dir)/node_modules/@cozy/codemods/src/transforms/transform-ui-bc-133.js src babel --ignore-pattern=src/targets/ --extensions js,jsx,tsx --parser tsx
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
You probably will need to fix linter issue after that with something like `yarn lint --fix`.
|
|
55
|
+
|
|
56
|
+
* Please note that these components have been completely removed: `deprecated/IntentModal, deprecated/IntentOpener, deprecated/QuotaAlert`
|
|
21
57
|
* If you used `deprecated/ActionMenu/Actions/modif` and `deprecated/ActionMenu/Actions/viewInContacts` please use those in `/ActionsMenu/Actions` instead
|
|
22
58
|
* **BarContextProvider:** If you use `BarContextProvider` you must create it yourself. Take a look to the code to copy/paste
|
|
23
59
|
* **Actions:** You must `import { fetchBlobFileById, isFile } from 'cozy-client/dist/models/file'` and pass it as action's option `makeActions([], { fetchBlobFileById, isFile })` when using `print` action.
|
|
@@ -3045,7 +3081,7 @@ jscodeshift -t $(yarn global dir)/node_modules/@cozy/codemods/src/transforms/tra
|
|
|
3045
3081
|
|
|
3046
3082
|
### BREAKING CHANGES
|
|
3047
3083
|
|
|
3048
|
-
* **Viewer:** The `toolbarProps` attribute from Viewer property has been moved into the `componentsProps` attribute.
|
|
3084
|
+
* **Viewer:** The `toolbarProps` attribute from Viewer property has been moved into the `componentsProps` attribute.
|
|
3049
3085
|
|
|
3050
3086
|
You can use this codemods to migrate. **Don't forget to run js linter after the codemods.**
|
|
3051
3087
|
|
|
@@ -3058,7 +3094,7 @@ jscodeshift -t $(yarn global dir)/node_modules/@cozy/codemods/src/transforms/tra
|
|
|
3058
3094
|
```
|
|
3059
3095
|
|
|
3060
3096
|
You can do this manually by transferring the contents of `toolbarProps` to `componentsProps` under a `toolbarProps` property.
|
|
3061
|
-
* **Viewer:** The `onlyOfficeProps` attribute from Viewer property has been moved into the `componentsProps` attribute.
|
|
3097
|
+
* **Viewer:** The `onlyOfficeProps` attribute from Viewer property has been moved into the `componentsProps` attribute.
|
|
3062
3098
|
|
|
3063
3099
|
You have to move the contents of `onlyOfficeProps ` to `componentsProps` under a `OnlyOfficeViewer` property.
|
|
3064
3100
|
|
|
@@ -3300,7 +3336,7 @@ set to `1`
|
|
|
3300
3336
|
|
|
3301
3337
|
This is the list of impacted components: `MuiCozyTheme/Buttons`, `MuiCozyTheme/MuiBreadcrumbs`, `MuiCozyTheme/Dialog`, `MuiCozyTheme/Accordion`, `MuiCozyTheme/AccordionDetails`, `MuiCozyTheme/AccordionSummary`, `MuiCozyTheme/Divider`, `MuiCozyTheme/Grid`, `MuiCozyTheme/List`, `MuiCozyTheme/ListItem`, `MuiCozyTheme/ListItemIcon`, `MuiCozyTheme/ListItemSecondaryAction`, `MuiCozyTheme/ListSubheader`, `MuiCozyTheme/Menu`, `MuiCozyTheme/Switch`, `MuiCozyTheme/TextField`
|
|
3302
3338
|
|
|
3303
|
-
You can use this codemods to migrate:
|
|
3339
|
+
You can use this codemods to migrate:
|
|
3304
3340
|
|
|
3305
3341
|
```
|
|
3306
3342
|
$ yarn global add @cozy/codemods
|
|
@@ -3321,7 +3357,7 @@ $ jscodeshift -t $(yarn global dir)/node_modules/@cozy/codemods/src/transforms/t
|
|
|
3321
3357
|
* This is the list of deprecated component
|
|
3322
3358
|
`ActionMenu`, `Alerter`, `BottomDrawer`, `Button`, `ButtonAction`, `Chip`, `CompositeRow`, `GridItem`, `Infos`, `InfosCarrousel`, `InlineCard`, `IntentModal`, `IntentOpener`, `Media`, `Menus`, `Modal`, `NarrowContent`, `Overlay`, `PercentageBar`, `PercentageLine`, `PushClientButton`, `QuotaAlert`, `Radio`, `RaisedList`, `ViewStack`
|
|
3323
3359
|
|
|
3324
|
-
These components are now in a `deprecated` subfolder. Use this codemods to migrate:
|
|
3360
|
+
These components are now in a `deprecated` subfolder. Use this codemods to migrate:
|
|
3325
3361
|
|
|
3326
3362
|
```
|
|
3327
3363
|
$ yarn global add @cozy/codemods
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ import DotsIcon from '../Icons/Dots'
|
|
|
18
18
|
import Toolbar from '../Toolbar'
|
|
19
19
|
import Typography from '../Typography'
|
|
20
20
|
import useBreakpoints from '../providers/Breakpoints'
|
|
21
|
-
import CozyTheme from '../providers/CozyTheme'
|
|
21
|
+
import CozyTheme, { useCozyTheme } from '../providers/CozyTheme'
|
|
22
22
|
import { useI18n } from '../providers/I18n'
|
|
23
23
|
import { makeStyles } from '../styles'
|
|
24
24
|
|
|
@@ -111,6 +111,7 @@ const ActionsBar = ({
|
|
|
111
111
|
onClose
|
|
112
112
|
}) => {
|
|
113
113
|
const { isMobile } = useBreakpoints()
|
|
114
|
+
const { type } = useCozyTheme()
|
|
114
115
|
const anchorRef = useRef()
|
|
115
116
|
const [showMenu, setShowMenu] = useState(false)
|
|
116
117
|
const styles = useStyles({ isMobile })
|
|
@@ -137,7 +138,7 @@ const ActionsBar = ({
|
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
return (
|
|
140
|
-
<CozyTheme variant="inverted">
|
|
141
|
+
<CozyTheme type={type} variant="inverted">
|
|
141
142
|
<AppBar className={styles.appBar} position="fixed" color="inherit">
|
|
142
143
|
<Toolbar
|
|
143
144
|
className={styles.toolbar}
|
|
@@ -436,9 +436,11 @@ BottomSheet.propTypes = {
|
|
|
436
436
|
}
|
|
437
437
|
|
|
438
438
|
const BottomSheetPortal = forwardRef(({ portalProps, ...props }, ref) => {
|
|
439
|
-
const { variant } = useCozyTheme()
|
|
439
|
+
const { type, variant } = useCozyTheme()
|
|
440
440
|
const CozyThemeWrapper = portalProps?.disablePortal ? Fragment : CozyTheme
|
|
441
|
-
const wrapperProps = portalProps?.disablePortal
|
|
441
|
+
const wrapperProps = portalProps?.disablePortal
|
|
442
|
+
? undefined
|
|
443
|
+
: { type, variant }
|
|
442
444
|
|
|
443
445
|
return (
|
|
444
446
|
<Portal {...portalProps}>
|
|
@@ -45,64 +45,6 @@ const [open, setOpen] = useState(isTesting());
|
|
|
45
45
|
</DemoProvider>
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
### Authentification dialog
|
|
49
|
-
|
|
50
|
-
Dialog used to authenticate a user in the cozy system. The authentication logic is implemented in the applications.
|
|
51
|
-
|
|
52
|
-
```jsx
|
|
53
|
-
import { AuthentificationDialog } from 'cozy-ui/transpiled/react/CozyDialogs'
|
|
54
|
-
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
55
|
-
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
56
|
-
import Variants from 'cozy-ui/docs/components/Variants'
|
|
57
|
-
import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel'
|
|
58
|
-
import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup'
|
|
59
|
-
import Radio from 'cozy-ui/transpiled/react/Radios'
|
|
60
|
-
import FormControl from 'cozy-ui/transpiled/react/FormControl'
|
|
61
|
-
import FormLabel from 'cozy-ui/transpiled/react/FormLabel'
|
|
62
|
-
|
|
63
|
-
initialState = { showModal: false };
|
|
64
|
-
|
|
65
|
-
const initialVariants = [{
|
|
66
|
-
closable: true,
|
|
67
|
-
loading: false,
|
|
68
|
-
oidc: false
|
|
69
|
-
}]
|
|
70
|
-
|
|
71
|
-
const initialErrors = [{
|
|
72
|
-
default: true,
|
|
73
|
-
invalid_password: false,
|
|
74
|
-
server_error: false
|
|
75
|
-
}]
|
|
76
|
-
|
|
77
|
-
const onClose = () => setState({ showModal: false })
|
|
78
|
-
|
|
79
|
-
const onAuthentification = () => {
|
|
80
|
-
alert('authentification')
|
|
81
|
-
setState({ showModal: false })
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
<Variants initialVariants={initialVariants}>
|
|
85
|
-
{variant => (
|
|
86
|
-
<Variants initialVariants={initialErrors} radio>
|
|
87
|
-
{error => (
|
|
88
|
-
<DemoProvider>
|
|
89
|
-
<Button label="Open modal" onClick={() => setState({ showModal: true })}/>
|
|
90
|
-
{state.showModal && (
|
|
91
|
-
<AuthentificationDialog
|
|
92
|
-
onSubmit={onAuthentification}
|
|
93
|
-
onClose={variant.closable && onClose}
|
|
94
|
-
error={error.invalid_password ? 'invalid_password' : error.server_error ? 'server_error' : undefined }
|
|
95
|
-
isLoading={variant.loading}
|
|
96
|
-
isOIDC={variant.oidc}
|
|
97
|
-
/>
|
|
98
|
-
)}
|
|
99
|
-
</DemoProvider>
|
|
100
|
-
)}
|
|
101
|
-
</Variants>
|
|
102
|
-
)}
|
|
103
|
-
</Variants>
|
|
104
|
-
```
|
|
105
|
-
|
|
106
48
|
### ShortcutDialog dialog
|
|
107
49
|
|
|
108
50
|
⚠️ Must be used within AlertProvider.
|
package/react/index.js
CHANGED
|
@@ -68,7 +68,6 @@ export { default as Stack } from './Stack'
|
|
|
68
68
|
export { default as PercentageLine } from './deprecated/PercentageLine'
|
|
69
69
|
export { default as Popup } from './Popup'
|
|
70
70
|
export { default as IconStack } from './IconStack'
|
|
71
|
-
export { default as QuotaAlert } from './deprecated/QuotaAlert'
|
|
72
71
|
export {
|
|
73
72
|
default as ViewStack,
|
|
74
73
|
ModalStack,
|
|
@@ -83,7 +82,6 @@ export {
|
|
|
83
82
|
ExperimentalDialogTitle
|
|
84
83
|
} from './Labs/ExperimentalDialog'
|
|
85
84
|
|
|
86
|
-
export { default as BarContextProvider } from './BarContextProvider'
|
|
87
85
|
export { default as BarTitle } from './BarTitle'
|
|
88
86
|
export { default as CozyTheme } from './providers/CozyTheme'
|
|
89
87
|
export { default as Paper } from './Paper'
|
|
@@ -10,7 +10,7 @@ import useMediaQuery from '../../hooks/useMediaQuery'
|
|
|
10
10
|
export const CozyThemeContext = createContext()
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @returns {{ type: 'light'|'dark', variant: 'normal'|'inverted', isLight: boolean
|
|
13
|
+
* @returns {{ type: 'light'|'dark', variant: 'normal'|'inverted', isLight: boolean }}
|
|
14
14
|
*/
|
|
15
15
|
export const useCozyTheme = () => {
|
|
16
16
|
const context = useContext(CozyThemeContext)
|
|
@@ -31,42 +31,32 @@ export const useCozyTheme = () => {
|
|
|
31
31
|
return context
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const CozyTheme = ({
|
|
35
|
-
variant,
|
|
36
|
-
className,
|
|
37
|
-
ignoreItself,
|
|
38
|
-
settingsThemeType,
|
|
39
|
-
children
|
|
40
|
-
}) => {
|
|
34
|
+
const CozyTheme = ({ type, variant, className, ignoreItself, children }) => {
|
|
41
35
|
const uiThemeType = localStorage.getItem('ui-theme-type') // use only for cozy-ui documentation and argos screenshots
|
|
42
36
|
const uiThemeVariant = localStorage.getItem('ui-theme-variant') // use only for cozy-ui documentation and argos screenshots
|
|
43
37
|
|
|
44
38
|
const deviceThemeType = useMediaQuery('(prefers-color-scheme: dark)')
|
|
45
39
|
? 'dark'
|
|
46
40
|
: 'light'
|
|
47
|
-
const filteredSettingsThemeType = ['light', 'dark'].includes(
|
|
48
|
-
|
|
49
|
-
)
|
|
50
|
-
? settingsThemeType
|
|
41
|
+
const filteredSettingsThemeType = ['light', 'dark'].includes(type)
|
|
42
|
+
? type
|
|
51
43
|
: undefined
|
|
52
44
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const selfThemeVariant = uiThemeVariant || variant
|
|
45
|
+
const _type = uiThemeType || filteredSettingsThemeType || deviceThemeType
|
|
46
|
+
const _variant = uiThemeVariant || variant
|
|
56
47
|
|
|
57
48
|
return (
|
|
58
49
|
<CozyThemeContext.Provider
|
|
59
50
|
value={{
|
|
60
|
-
type:
|
|
61
|
-
variant:
|
|
62
|
-
isLight:
|
|
51
|
+
type: _type,
|
|
52
|
+
variant: _variant,
|
|
53
|
+
isLight: _type === 'light'
|
|
63
54
|
}}
|
|
64
55
|
>
|
|
65
|
-
<MuiCozyTheme type={
|
|
56
|
+
<MuiCozyTheme type={_type} variant={_variant}>
|
|
66
57
|
<div
|
|
67
58
|
className={cx(className, {
|
|
68
|
-
[`TwakeTheme--${
|
|
69
|
-
Boolean(selfThemeVariant),
|
|
59
|
+
[`TwakeTheme--${_type}-${_variant}`]: Boolean(_variant),
|
|
70
60
|
'u-dc': ignoreItself
|
|
71
61
|
})}
|
|
72
62
|
>
|
|
@@ -78,11 +68,10 @@ const CozyTheme = ({
|
|
|
78
68
|
}
|
|
79
69
|
|
|
80
70
|
CozyTheme.propTypes = {
|
|
71
|
+
type: PropTypes.oneOf(['light', 'dark', 'auto']),
|
|
81
72
|
variant: PropTypes.oneOf(['normal', 'inverted']),
|
|
82
73
|
/** Causes this element's children to appear as if they were direct children of the element's parent, ignoring the element itself. */
|
|
83
74
|
ignoreItself: PropTypes.bool,
|
|
84
|
-
/** Theme type from io.cozy.settings.instance */
|
|
85
|
-
settingsThemeType: PropTypes.oneOf(['light', 'dark', 'auto']),
|
|
86
75
|
className: PropTypes.string,
|
|
87
76
|
children: PropTypes.node
|
|
88
77
|
}
|
|
@@ -18,7 +18,7 @@ import DotsIcon from "cozy-ui/transpiled/react/Icons/Dots";
|
|
|
18
18
|
import Toolbar from "cozy-ui/transpiled/react/Toolbar";
|
|
19
19
|
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
20
20
|
import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
|
|
21
|
-
import CozyTheme from "cozy-ui/transpiled/react/providers/CozyTheme";
|
|
21
|
+
import CozyTheme, { useCozyTheme } from "cozy-ui/transpiled/react/providers/CozyTheme";
|
|
22
22
|
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
23
23
|
import { makeStyles } from "cozy-ui/transpiled/react/styles";
|
|
24
24
|
var useStyles = makeStyles({
|
|
@@ -121,6 +121,9 @@ var ActionsBar = function ActionsBar(_ref5) {
|
|
|
121
121
|
var _useBreakpoints2 = useBreakpoints(),
|
|
122
122
|
isMobile = _useBreakpoints2.isMobile;
|
|
123
123
|
|
|
124
|
+
var _useCozyTheme = useCozyTheme(),
|
|
125
|
+
type = _useCozyTheme.type;
|
|
126
|
+
|
|
124
127
|
var anchorRef = useRef();
|
|
125
128
|
|
|
126
129
|
var _useState = useState(false),
|
|
@@ -147,6 +150,7 @@ var ActionsBar = function ActionsBar(_ref5) {
|
|
|
147
150
|
};
|
|
148
151
|
|
|
149
152
|
return /*#__PURE__*/React.createElement(CozyTheme, {
|
|
153
|
+
type: type,
|
|
150
154
|
variant: "inverted"
|
|
151
155
|
}, /*#__PURE__*/React.createElement(AppBar, {
|
|
152
156
|
className: styles.appBar,
|
|
@@ -436,10 +436,12 @@ var BottomSheetPortal = /*#__PURE__*/forwardRef(function (_ref4, ref) {
|
|
|
436
436
|
props = _objectWithoutProperties(_ref4, _excluded);
|
|
437
437
|
|
|
438
438
|
var _useCozyTheme2 = useCozyTheme(),
|
|
439
|
+
type = _useCozyTheme2.type,
|
|
439
440
|
variant = _useCozyTheme2.variant;
|
|
440
441
|
|
|
441
442
|
var CozyThemeWrapper = portalProps !== null && portalProps !== void 0 && portalProps.disablePortal ? Fragment : CozyTheme;
|
|
442
443
|
var wrapperProps = portalProps !== null && portalProps !== void 0 && portalProps.disablePortal ? undefined : {
|
|
444
|
+
type: type,
|
|
443
445
|
variant: variant
|
|
444
446
|
};
|
|
445
447
|
return /*#__PURE__*/React.createElement(Portal, portalProps, /*#__PURE__*/React.createElement(CozyThemeWrapper, wrapperProps, /*#__PURE__*/React.createElement(BottomSheet, _extends({
|
|
@@ -55,12 +55,10 @@ export { default as Stack } from './Stack';
|
|
|
55
55
|
export { default as PercentageLine } from './deprecated/PercentageLine';
|
|
56
56
|
export { default as Popup } from './Popup';
|
|
57
57
|
export { default as IconStack } from './IconStack';
|
|
58
|
-
export { default as QuotaAlert } from './deprecated/QuotaAlert';
|
|
59
58
|
export { default as ViewStack, ModalStack, useViewStack, ViewStackContext } from './deprecated/ViewStack';
|
|
60
59
|
export { default as DateMonthPicker } from './DateMonthPicker';
|
|
61
60
|
export { default as NestedSelect, NestedSelectModal } from './NestedSelect';
|
|
62
61
|
export { default as ExperimentalDialog, ExperimentalDialogActions, ExperimentalDialogTitle } from './Labs/ExperimentalDialog';
|
|
63
|
-
export { default as BarContextProvider } from './BarContextProvider';
|
|
64
62
|
export { default as BarTitle } from './BarTitle';
|
|
65
63
|
export { default as CozyTheme } from './providers/CozyTheme';
|
|
66
64
|
export { default as Paper } from './Paper';
|
|
@@ -3,22 +3,21 @@ export function useCozyTheme(): {
|
|
|
3
3
|
type: 'light' | 'dark';
|
|
4
4
|
variant: 'normal' | 'inverted';
|
|
5
5
|
isLight: boolean;
|
|
6
|
-
name: 'Twake' | 'Cozy';
|
|
7
6
|
};
|
|
8
7
|
export default CozyTheme;
|
|
9
8
|
import React from "react";
|
|
10
|
-
declare function CozyTheme({ variant, className, ignoreItself,
|
|
9
|
+
declare function CozyTheme({ type, variant, className, ignoreItself, children }: {
|
|
10
|
+
type: any;
|
|
11
11
|
variant: any;
|
|
12
12
|
className: any;
|
|
13
13
|
ignoreItself: any;
|
|
14
|
-
settingsThemeType: any;
|
|
15
14
|
children: any;
|
|
16
15
|
}): JSX.Element;
|
|
17
16
|
declare namespace CozyTheme {
|
|
18
17
|
namespace propTypes {
|
|
18
|
+
const type: PropTypes.Requireable<string>;
|
|
19
19
|
const variant: PropTypes.Requireable<string>;
|
|
20
20
|
const ignoreItself: PropTypes.Requireable<boolean>;
|
|
21
|
-
const settingsThemeType: PropTypes.Requireable<string>;
|
|
22
21
|
const className: PropTypes.Requireable<string>;
|
|
23
22
|
const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
24
23
|
}
|
|
@@ -7,7 +7,7 @@ import MuiCozyTheme from "cozy-ui/transpiled/react/MuiCozyTheme";
|
|
|
7
7
|
import useMediaQuery from "cozy-ui/transpiled/react/hooks/useMediaQuery";
|
|
8
8
|
export var CozyThemeContext = /*#__PURE__*/createContext();
|
|
9
9
|
/**
|
|
10
|
-
* @returns {{ type: 'light'|'dark', variant: 'normal'|'inverted', isLight: boolean
|
|
10
|
+
* @returns {{ type: 'light'|'dark', variant: 'normal'|'inverted', isLight: boolean }}
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
export var useCozyTheme = function useCozyTheme() {
|
|
@@ -28,41 +28,42 @@ export var useCozyTheme = function useCozyTheme() {
|
|
|
28
28
|
var CozyTheme = function CozyTheme(_ref) {
|
|
29
29
|
var _cx;
|
|
30
30
|
|
|
31
|
-
var
|
|
31
|
+
var type = _ref.type,
|
|
32
|
+
variant = _ref.variant,
|
|
32
33
|
className = _ref.className,
|
|
33
34
|
ignoreItself = _ref.ignoreItself,
|
|
34
|
-
settingsThemeType = _ref.settingsThemeType,
|
|
35
35
|
children = _ref.children;
|
|
36
36
|
var uiThemeType = localStorage.getItem('ui-theme-type'); // use only for cozy-ui documentation and argos screenshots
|
|
37
37
|
|
|
38
38
|
var uiThemeVariant = localStorage.getItem('ui-theme-variant'); // use only for cozy-ui documentation and argos screenshots
|
|
39
39
|
|
|
40
40
|
var deviceThemeType = useMediaQuery('(prefers-color-scheme: dark)') ? 'dark' : 'light';
|
|
41
|
-
var filteredSettingsThemeType = ['light', 'dark'].includes(
|
|
42
|
-
|
|
43
|
-
var
|
|
41
|
+
var filteredSettingsThemeType = ['light', 'dark'].includes(type) ? type : undefined;
|
|
42
|
+
|
|
43
|
+
var _type = uiThemeType || filteredSettingsThemeType || deviceThemeType;
|
|
44
|
+
|
|
45
|
+
var _variant = uiThemeVariant || variant;
|
|
46
|
+
|
|
44
47
|
return /*#__PURE__*/React.createElement(CozyThemeContext.Provider, {
|
|
45
48
|
value: {
|
|
46
|
-
type:
|
|
47
|
-
variant:
|
|
48
|
-
isLight:
|
|
49
|
+
type: _type,
|
|
50
|
+
variant: _variant,
|
|
51
|
+
isLight: _type === 'light'
|
|
49
52
|
}
|
|
50
53
|
}, /*#__PURE__*/React.createElement(MuiCozyTheme, {
|
|
51
|
-
type:
|
|
52
|
-
variant:
|
|
54
|
+
type: _type,
|
|
55
|
+
variant: _variant
|
|
53
56
|
}, /*#__PURE__*/React.createElement("div", {
|
|
54
|
-
className: cx(className, (_cx = {}, _defineProperty(_cx, "TwakeTheme--".concat(
|
|
57
|
+
className: cx(className, (_cx = {}, _defineProperty(_cx, "TwakeTheme--".concat(_type, "-").concat(_variant), Boolean(_variant)), _defineProperty(_cx, 'u-dc', ignoreItself), _cx))
|
|
55
58
|
}, children)));
|
|
56
59
|
};
|
|
57
60
|
|
|
58
61
|
CozyTheme.propTypes = {
|
|
62
|
+
type: PropTypes.oneOf(['light', 'dark', 'auto']),
|
|
59
63
|
variant: PropTypes.oneOf(['normal', 'inverted']),
|
|
60
64
|
|
|
61
65
|
/** Causes this element's children to appear as if they were direct children of the element's parent, ignoring the element itself. */
|
|
62
66
|
ignoreItself: PropTypes.bool,
|
|
63
|
-
|
|
64
|
-
/** Theme type from io.cozy.settings.instance */
|
|
65
|
-
settingsThemeType: PropTypes.oneOf(['light', 'dark', 'auto']),
|
|
66
67
|
className: PropTypes.string,
|
|
67
68
|
children: PropTypes.node
|
|
68
69
|
};
|