cozy-ui 140.6.0 → 142.0.1
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 +35 -0
- package/package.json +4 -4
- package/react/Dialog/Readme.md +1 -3
- package/react/Markdown/index.jsx +29 -20
- package/react/Markdown/index.spec.jsx +29 -0
- package/react/providers/Breakpoints/index.jsx +2 -2
- package/react/providers/Breakpoints/index.spec.jsx +27 -0
- package/react/providers/Breakpoints/useIframeConnection.jsx +3 -3
- package/react/providers/Breakpoints/useIframeToSendWidth.jsx +7 -15
- package/transpiled/react/Markdown/index.js +43 -30
- package/transpiled/react/Markdown/index.spec.d.ts +1 -0
- package/transpiled/react/providers/Breakpoints/index.js +2 -2
- package/transpiled/react/providers/Breakpoints/index.spec.d.ts +1 -0
- package/transpiled/react/providers/Breakpoints/useIframeConnection.d.ts +1 -1
- package/transpiled/react/providers/Breakpoints/useIframeConnection.js +5 -5
- package/transpiled/react/providers/Breakpoints/useIframeToSendWidth.d.ts +2 -2
- package/transpiled/react/providers/Breakpoints/useIframeToSendWidth.js +7 -15
- package/transpiled/react/stylesheet.css +1 -1
- package/react/deprecated/InfosCarrousel/Readme.md +0 -64
- package/react/deprecated/InfosCarrousel/index.jsx +0 -107
- package/react/deprecated/InfosCarrousel/styles.styl +0 -31
- package/react/deprecated/ViewStack/ModalStack.jsx +0 -43
- package/react/deprecated/ViewStack/Readme.md +0 -10
- package/react/deprecated/ViewStack/ViewStack.jsx +0 -41
- package/react/deprecated/ViewStack/context.js +0 -4
- package/react/deprecated/ViewStack/example.jsx +0 -41
- package/react/deprecated/ViewStack/hooks.js +0 -30
- package/react/deprecated/ViewStack/index.js +0 -3
- package/transpiled/react/deprecated/InfosCarrousel/index.d.ts +0 -24
- package/transpiled/react/deprecated/InfosCarrousel/index.js +0 -118
- package/transpiled/react/deprecated/ViewStack/ModalStack.d.ts +0 -16
- package/transpiled/react/deprecated/ViewStack/ModalStack.js +0 -47
- package/transpiled/react/deprecated/ViewStack/ViewStack.d.ts +0 -13
- package/transpiled/react/deprecated/ViewStack/ViewStack.js +0 -49
- package/transpiled/react/deprecated/ViewStack/context.d.ts +0 -3
- package/transpiled/react/deprecated/ViewStack/context.js +0 -5
- package/transpiled/react/deprecated/ViewStack/example.d.ts +0 -3
- package/transpiled/react/deprecated/ViewStack/example.js +0 -66
- package/transpiled/react/deprecated/ViewStack/hooks.d.ts +0 -1
- package/transpiled/react/deprecated/ViewStack/hooks.js +0 -77
- package/transpiled/react/deprecated/ViewStack/index.d.ts +0 -3
- package/transpiled/react/deprecated/ViewStack/index.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
## [142.0.1](https://github.com/cozy/cozy-ui/compare/v142.0.0...v142.0.1) (2026-09-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Dialog doc ([1d28879](https://github.com/cozy/cozy-ui/commit/1d28879))
|
|
7
|
+
|
|
8
|
+
# [142.0.0](https://github.com/cozy/cozy-ui/compare/v141.0.0...v142.0.0) (2026-09-03)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Build docs with transpiled [@react-spring](https://github.com/react-spring) ([07af455](https://github.com/cozy/cozy-ui/commit/07af455))
|
|
14
|
+
* Remove ViewStack and InfosCarrousel ([db3eeef](https://github.com/cozy/cozy-ui/commit/db3eeef))
|
|
15
|
+
* Update mui-bottom-sheet ([384f167](https://github.com/cozy/cozy-ui/commit/384f167))
|
|
16
|
+
* Update react-markdown ([7eb612c](https://github.com/cozy/cozy-ui/commit/7eb612c))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
* ViewStack and InfosCarrousel have been removed without replacement.
|
|
22
|
+
|
|
23
|
+
# [141.0.0](https://github.com/cozy/cozy-ui/compare/v140.6.0...v141.0.0) (2026-07-30)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
* fix(breakpoints)!: target the requesting iframe ([b222ae2](https://github.com/cozy/cozy-ui/commit/b222ae2)), closes [#2949](https://github.com/cozy/cozy-ui/issues/2949)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### BREAKING CHANGES
|
|
30
|
+
|
|
31
|
+
* replace the old hook usage with:
|
|
32
|
+
|
|
33
|
+
const { iframeWindow } = useIframeConnection({ parentBasedIframe })
|
|
34
|
+
useIframeToSendWidth({ iframeWindow })
|
|
35
|
+
|
|
1
36
|
# [140.6.0](https://github.com/cozy/cozy-ui/compare/v140.5.2...v140.6.0) (2026-07-29)
|
|
2
37
|
|
|
3
38
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "142.0.1",
|
|
4
4
|
"description": "Cozy apps UI SDK",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "24.x"
|
|
@@ -169,18 +169,18 @@
|
|
|
169
169
|
"date-fns": "2.30.0",
|
|
170
170
|
"hammerjs": "^2.0.8",
|
|
171
171
|
"intersection-observer": "0.11.0",
|
|
172
|
-
"mui-bottom-sheet": "https://github.com/cozy/mui-bottom-sheet.git#v1.0.
|
|
172
|
+
"mui-bottom-sheet": "https://github.com/cozy/mui-bottom-sheet.git#v1.0.10",
|
|
173
173
|
"node-polyglot": "^2.5.0",
|
|
174
174
|
"normalize.css": "^8.0.0",
|
|
175
175
|
"patch-package": "^8.0.0",
|
|
176
176
|
"pdf-lib": "1.17.1",
|
|
177
177
|
"react-colorful": "5.7.0",
|
|
178
|
-
"react-markdown": "^
|
|
178
|
+
"react-markdown": "^6.0.3",
|
|
179
179
|
"react-popper": "^2.2.3",
|
|
180
180
|
"react-remove-scroll": "^2.4.0",
|
|
181
181
|
"react-select": "^4.3.0",
|
|
182
|
-
"react-swipeable-views": "^0.13.3",
|
|
183
182
|
"react-virtuoso": "^4.13.0",
|
|
183
|
+
"remark-gfm": "^1.0.0",
|
|
184
184
|
"rooks": "7.14.1"
|
|
185
185
|
},
|
|
186
186
|
"peerDependencies": {
|
package/react/Dialog/Readme.md
CHANGED
|
@@ -18,9 +18,7 @@ import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
|
18
18
|
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
19
19
|
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
20
20
|
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/ListItemSecondaryAction'
|
|
21
|
-
import { FileTypeFolder, FileTypeText, Icon } from '@linagora/twake-icons'
|
|
22
|
-
|
|
23
|
-
import { Dots } from '@linagora/twake-icons'
|
|
21
|
+
import { FileTypeFolder, FileTypeText, Icon, Dots } from '@linagora/twake-icons'
|
|
24
22
|
|
|
25
23
|
const handleClose = () => setState({ modalOpened: !state.modalOpened })
|
|
26
24
|
|
package/react/Markdown/index.jsx
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import ReactMarkdown from 'react-markdown'
|
|
3
|
+
import remarkGfm from 'remark-gfm'
|
|
3
4
|
|
|
4
5
|
import Link from '../Link'
|
|
5
6
|
import Typography from '../Typography'
|
|
6
7
|
|
|
8
|
+
const heading =
|
|
9
|
+
level =>
|
|
10
|
+
({ children }) =>
|
|
11
|
+
(
|
|
12
|
+
<Typography variant={`h${level}`} className="u-mb-1">
|
|
13
|
+
{children}
|
|
14
|
+
</Typography>
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
const components = {
|
|
18
|
+
a: ({ children, href }) => (
|
|
19
|
+
<Link href={href} rel="noreferrer" target="_blank">
|
|
20
|
+
{children}
|
|
21
|
+
</Link>
|
|
22
|
+
),
|
|
23
|
+
p: ({ children }) => (
|
|
24
|
+
<Typography variant="body1" className="u-mb-1">
|
|
25
|
+
{children}
|
|
26
|
+
</Typography>
|
|
27
|
+
),
|
|
28
|
+
...Object.fromEntries(
|
|
29
|
+
[1, 2, 3, 4, 5, 6].map(level => [`h${level}`, heading(level)])
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
7
33
|
const Markdown = ({ content }) => {
|
|
8
34
|
return (
|
|
9
|
-
<ReactMarkdown
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
link: ({ children, href }) => (
|
|
13
|
-
<Link href={href} rel="noreferrer" target="_blank">
|
|
14
|
-
{children}
|
|
15
|
-
</Link>
|
|
16
|
-
),
|
|
17
|
-
heading: ({ children, level }) => (
|
|
18
|
-
<Typography variant={`h${level}`} className="u-mb-1">
|
|
19
|
-
{children}
|
|
20
|
-
</Typography>
|
|
21
|
-
),
|
|
22
|
-
paragraph: ({ children }) => (
|
|
23
|
-
<Typography variant="body1" className="u-mb-1">
|
|
24
|
-
{children}
|
|
25
|
-
</Typography>
|
|
26
|
-
)
|
|
27
|
-
}}
|
|
28
|
-
/>
|
|
35
|
+
<ReactMarkdown remarkPlugins={[remarkGfm]} components={components}>
|
|
36
|
+
{content}
|
|
37
|
+
</ReactMarkdown>
|
|
29
38
|
)
|
|
30
39
|
}
|
|
31
40
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import Markdown from '.'
|
|
5
|
+
|
|
6
|
+
describe('Markdown', () => {
|
|
7
|
+
it('renders headings and paragraphs', () => {
|
|
8
|
+
render(<Markdown content={'# Title\n\nSome text.'} />)
|
|
9
|
+
|
|
10
|
+
expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('Title')
|
|
11
|
+
expect(screen.getByText('Some text.')).toBeInTheDocument()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('renders links that open in a new tab', () => {
|
|
15
|
+
render(<Markdown content="[cozy](https://cozy.io)" />)
|
|
16
|
+
|
|
17
|
+
const link = screen.getByRole('link', { name: 'cozy' })
|
|
18
|
+
|
|
19
|
+
expect(link).toHaveAttribute('href', 'https://cozy.io')
|
|
20
|
+
expect(link).toHaveAttribute('target', '_blank')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('renders strikethrough', () => {
|
|
24
|
+
render(<Markdown content="~~gone~~" />)
|
|
25
|
+
|
|
26
|
+
expect(screen.getByText('gone')).toBeInTheDocument()
|
|
27
|
+
expect(document.querySelector('del')).toBeInTheDocument()
|
|
28
|
+
})
|
|
29
|
+
})
|
|
@@ -13,8 +13,8 @@ export const BreakpointsProvider = ({ parentBasedIframe, children }) => {
|
|
|
13
13
|
const [breakpoints, setBreakpoints] = useState(
|
|
14
14
|
getBreakpointsStatus(breakpointDefs)
|
|
15
15
|
)
|
|
16
|
-
const {
|
|
17
|
-
useIframeToSendWidth({
|
|
16
|
+
const { iframeWindow } = useIframeConnection({ parentBasedIframe })
|
|
17
|
+
useIframeToSendWidth({ iframeWindow })
|
|
18
18
|
const { parentBreakpoints } = useParentBreakpoints({ parentBasedIframe })
|
|
19
19
|
|
|
20
20
|
useEffect(() => {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { act, render } from '@testing-library/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { BreakpointsProvider } from './index'
|
|
5
|
+
|
|
6
|
+
it('sends parent breakpoints to the requesting iframe', () => {
|
|
7
|
+
const iframeWindow = { postMessage: jest.fn() }
|
|
8
|
+
const message = new MessageEvent('message', {
|
|
9
|
+
data: 'UI-breakpoints-needParentBreakpoints'
|
|
10
|
+
})
|
|
11
|
+
Object.defineProperty(message, 'source', { value: iframeWindow })
|
|
12
|
+
|
|
13
|
+
render(
|
|
14
|
+
<BreakpointsProvider>
|
|
15
|
+
<div />
|
|
16
|
+
</BreakpointsProvider>
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
act(() => {
|
|
20
|
+
window.dispatchEvent(message)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
expect(iframeWindow.postMessage).toHaveBeenCalledWith(
|
|
24
|
+
`UI-breakpoints-value:${window.innerWidth}`,
|
|
25
|
+
'*'
|
|
26
|
+
)
|
|
27
|
+
})
|
|
@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react'
|
|
|
3
3
|
import { isInsideIframe } from '../../helpers/breakpoints'
|
|
4
4
|
|
|
5
5
|
export const useIframeConnection = ({ parentBasedIframe }) => {
|
|
6
|
-
const [
|
|
6
|
+
const [iframeWindow, setIframeWindow] = useState(null)
|
|
7
7
|
|
|
8
8
|
const isIframe = parentBasedIframe && isInsideIframe()
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ export const useIframeConnection = ({ parentBasedIframe }) => {
|
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
const handleMessage = ev => {
|
|
13
13
|
if (ev.data === 'UI-breakpoints-needParentBreakpoints') {
|
|
14
|
-
|
|
14
|
+
setIframeWindow(ev.source)
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -27,5 +27,5 @@ export const useIframeConnection = ({ parentBasedIframe }) => {
|
|
|
27
27
|
}
|
|
28
28
|
}, [isIframe])
|
|
29
29
|
|
|
30
|
-
return {
|
|
30
|
+
return { iframeWindow }
|
|
31
31
|
}
|
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
import throttle from 'lodash/throttle'
|
|
2
2
|
import { useEffect } from 'react'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
const sendWidthToIframe = () =>
|
|
9
|
-
window.frames[1].postMessage(`UI-breakpoints-value:${window.innerWidth}`, '*')
|
|
4
|
+
const sendWidthToIframe = iframeWindow =>
|
|
5
|
+
iframeWindow?.postMessage(`UI-breakpoints-value:${window.innerWidth}`, '*')
|
|
10
6
|
|
|
11
|
-
export const useIframeToSendWidth = ({
|
|
7
|
+
export const useIframeToSendWidth = ({ iframeWindow }) => {
|
|
12
8
|
// parent window send its innerWidth
|
|
13
9
|
useEffect(() => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
}, [hasIframe])
|
|
10
|
+
sendWidthToIframe(iframeWindow)
|
|
11
|
+
}, [iframeWindow])
|
|
18
12
|
|
|
19
13
|
// parent window send its innerWidth on resize
|
|
20
14
|
useEffect(() => {
|
|
21
15
|
const handleResize = throttle(() => {
|
|
22
|
-
|
|
23
|
-
sendWidthToIframe()
|
|
24
|
-
}
|
|
16
|
+
sendWidthToIframe(iframeWindow)
|
|
25
17
|
}, 100)
|
|
26
18
|
|
|
27
19
|
window.addEventListener('resize', handleResize)
|
|
@@ -29,5 +21,5 @@ export const useIframeToSendWidth = ({ hasIframe }) => {
|
|
|
29
21
|
return () => {
|
|
30
22
|
window.removeEventListener('resize', handleResize)
|
|
31
23
|
}
|
|
32
|
-
}, [
|
|
24
|
+
}, [iframeWindow])
|
|
33
25
|
}
|
|
@@ -1,39 +1,52 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
1
7
|
import React from 'react';
|
|
2
8
|
import ReactMarkdown from 'react-markdown';
|
|
9
|
+
import remarkGfm from 'remark-gfm';
|
|
3
10
|
import Link from "cozy-ui/transpiled/react/Link";
|
|
4
11
|
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
5
12
|
|
|
6
|
-
var
|
|
7
|
-
|
|
13
|
+
var heading = function heading(level) {
|
|
14
|
+
return function (_ref) {
|
|
15
|
+
var children = _ref.children;
|
|
16
|
+
return /*#__PURE__*/React.createElement(Typography, {
|
|
17
|
+
variant: "h".concat(level),
|
|
18
|
+
className: "u-mb-1"
|
|
19
|
+
}, children);
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var components = _objectSpread({
|
|
24
|
+
a: function a(_ref2) {
|
|
25
|
+
var children = _ref2.children,
|
|
26
|
+
href = _ref2.href;
|
|
27
|
+
return /*#__PURE__*/React.createElement(Link, {
|
|
28
|
+
href: href,
|
|
29
|
+
rel: "noreferrer",
|
|
30
|
+
target: "_blank"
|
|
31
|
+
}, children);
|
|
32
|
+
},
|
|
33
|
+
p: function p(_ref3) {
|
|
34
|
+
var children = _ref3.children;
|
|
35
|
+
return /*#__PURE__*/React.createElement(Typography, {
|
|
36
|
+
variant: "body1",
|
|
37
|
+
className: "u-mb-1"
|
|
38
|
+
}, children);
|
|
39
|
+
}
|
|
40
|
+
}, Object.fromEntries([1, 2, 3, 4, 5, 6].map(function (level) {
|
|
41
|
+
return ["h".concat(level), heading(level)];
|
|
42
|
+
})));
|
|
43
|
+
|
|
44
|
+
var Markdown = function Markdown(_ref4) {
|
|
45
|
+
var content = _ref4.content;
|
|
8
46
|
return /*#__PURE__*/React.createElement(ReactMarkdown, {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var children = _ref2.children,
|
|
13
|
-
href = _ref2.href;
|
|
14
|
-
return /*#__PURE__*/React.createElement(Link, {
|
|
15
|
-
href: href,
|
|
16
|
-
rel: "noreferrer",
|
|
17
|
-
target: "_blank"
|
|
18
|
-
}, children);
|
|
19
|
-
},
|
|
20
|
-
heading: function heading(_ref3) {
|
|
21
|
-
var children = _ref3.children,
|
|
22
|
-
level = _ref3.level;
|
|
23
|
-
return /*#__PURE__*/React.createElement(Typography, {
|
|
24
|
-
variant: "h".concat(level),
|
|
25
|
-
className: "u-mb-1"
|
|
26
|
-
}, children);
|
|
27
|
-
},
|
|
28
|
-
paragraph: function paragraph(_ref4) {
|
|
29
|
-
var children = _ref4.children;
|
|
30
|
-
return /*#__PURE__*/React.createElement(Typography, {
|
|
31
|
-
variant: "body1",
|
|
32
|
-
className: "u-mb-1"
|
|
33
|
-
}, children);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
});
|
|
47
|
+
remarkPlugins: [remarkGfm],
|
|
48
|
+
components: components
|
|
49
|
+
}, content);
|
|
37
50
|
};
|
|
38
51
|
|
|
39
52
|
export default Markdown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -19,10 +19,10 @@ export var BreakpointsProvider = function BreakpointsProvider(_ref) {
|
|
|
19
19
|
var _useIframeConnection = useIframeConnection({
|
|
20
20
|
parentBasedIframe: parentBasedIframe
|
|
21
21
|
}),
|
|
22
|
-
|
|
22
|
+
iframeWindow = _useIframeConnection.iframeWindow;
|
|
23
23
|
|
|
24
24
|
useIframeToSendWidth({
|
|
25
|
-
|
|
25
|
+
iframeWindow: iframeWindow
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
var _useParentBreakpoints = useParentBreakpoints({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,17 +4,17 @@ import { isInsideIframe } from "cozy-ui/transpiled/react/helpers/breakpoints";
|
|
|
4
4
|
export var useIframeConnection = function useIframeConnection(_ref) {
|
|
5
5
|
var parentBasedIframe = _ref.parentBasedIframe;
|
|
6
6
|
|
|
7
|
-
var _useState = useState(
|
|
7
|
+
var _useState = useState(null),
|
|
8
8
|
_useState2 = _slicedToArray(_useState, 2),
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
iframeWindow = _useState2[0],
|
|
10
|
+
setIframeWindow = _useState2[1];
|
|
11
11
|
|
|
12
12
|
var isIframe = parentBasedIframe && isInsideIframe(); // parent window receives from iframe to give breakpoints
|
|
13
13
|
|
|
14
14
|
useEffect(function () {
|
|
15
15
|
var handleMessage = function handleMessage(ev) {
|
|
16
16
|
if (ev.data === 'UI-breakpoints-needParentBreakpoints') {
|
|
17
|
-
|
|
17
|
+
setIframeWindow(ev.source);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -30,6 +30,6 @@ export var useIframeConnection = function useIframeConnection(_ref) {
|
|
|
30
30
|
}
|
|
31
31
|
}, [isIframe]);
|
|
32
32
|
return {
|
|
33
|
-
|
|
33
|
+
iframeWindow: iframeWindow
|
|
34
34
|
};
|
|
35
35
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function useIframeToSendWidth({
|
|
2
|
-
|
|
1
|
+
export function useIframeToSendWidth({ iframeWindow }: {
|
|
2
|
+
iframeWindow: any;
|
|
3
3
|
}): void;
|
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
import throttle from 'lodash/throttle';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* To send window innerWidth to first iframe
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
3
|
|
|
8
|
-
var sendWidthToIframe = function sendWidthToIframe() {
|
|
9
|
-
return
|
|
4
|
+
var sendWidthToIframe = function sendWidthToIframe(iframeWindow) {
|
|
5
|
+
return iframeWindow === null || iframeWindow === void 0 ? void 0 : iframeWindow.postMessage("UI-breakpoints-value:".concat(window.innerWidth), '*');
|
|
10
6
|
};
|
|
11
7
|
|
|
12
8
|
export var useIframeToSendWidth = function useIframeToSendWidth(_ref) {
|
|
13
|
-
var
|
|
9
|
+
var iframeWindow = _ref.iframeWindow;
|
|
14
10
|
// parent window send its innerWidth
|
|
15
11
|
useEffect(function () {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}, [hasIframe]); // parent window send its innerWidth on resize
|
|
12
|
+
sendWidthToIframe(iframeWindow);
|
|
13
|
+
}, [iframeWindow]); // parent window send its innerWidth on resize
|
|
20
14
|
|
|
21
15
|
useEffect(function () {
|
|
22
16
|
var handleResize = throttle(function () {
|
|
23
|
-
|
|
24
|
-
sendWidthToIframe();
|
|
25
|
-
}
|
|
17
|
+
sendWidthToIframe(iframeWindow);
|
|
26
18
|
}, 100);
|
|
27
19
|
window.addEventListener('resize', handleResize);
|
|
28
20
|
return function () {
|
|
29
21
|
window.removeEventListener('resize', handleResize);
|
|
30
22
|
};
|
|
31
|
-
}, [
|
|
23
|
+
}, [iframeWindow]);
|
|
32
24
|
};
|