cozy-ui 70.2.2 → 70.2.3

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/.bundlemonrc CHANGED
@@ -12,8 +12,7 @@
12
12
  ],
13
13
  "groups": [
14
14
  {
15
- "path": "transpiled/react/**",
16
- "maxPercentIncrease": 0.5,
15
+ "path": "transpiled/react/**"
17
16
  },
18
17
  ],
19
18
  "reportOutput": ["github"]
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [70.2.3](https://github.com/cozy/cozy-ui/compare/v70.2.2...v70.2.3) (2022-07-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **BottomSheet:** Remove bouncerSafer when clicking in backdrop ([93233dd](https://github.com/cozy/cozy-ui/commit/93233dd))
7
+ * **CozyDialogs:** Close and Back button z-index ([a943399](https://github.com/cozy/cozy-ui/commit/a943399))
8
+
1
9
  ## [70.2.2](https://github.com/cozy/cozy-ui/compare/v70.2.1...v70.2.2) (2022-07-26)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "70.2.2",
3
+ "version": "70.2.3",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -16,10 +16,10 @@ import {
16
16
  computeMinHeight,
17
17
  makeOverridenChildren,
18
18
  setTopPosition,
19
- setBottomPosition
19
+ setBottomPosition,
20
+ minimizeAndClose
20
21
  } from './helpers'
21
-
22
- const ANIMATION_DURATION = 250
22
+ import { ANIMATION_DURATION } from './constants'
23
23
 
24
24
  const createStyles = ({ squared, hasToolbarProps }) => ({
25
25
  root: {
@@ -125,13 +125,6 @@ const BottomSheet = ({
125
125
  onClose && onClose()
126
126
  }, [onClose])
127
127
 
128
- const handleMinimizeAndClose = () => {
129
- if (backdrop) {
130
- setCurrentIndex(0)
131
- setTimeout(handleClose, ANIMATION_DURATION)
132
- }
133
- }
134
-
135
128
  const handleOnIndexChange = snapIndex => {
136
129
  const maxHeightSnapIndex = peekHeights.length - 1
137
130
 
@@ -232,7 +225,17 @@ const BottomSheet = ({
232
225
  hidden={isHidden}
233
226
  snapPointSeekerMode="next"
234
227
  >
235
- <ClickAwayListener onClickAway={handleMinimizeAndClose}>
228
+ <ClickAwayListener
229
+ onClickAway={() =>
230
+ minimizeAndClose({
231
+ backdrop,
232
+ setCurrentIndex,
233
+ setIsTopPosition,
234
+ setIsBottomPosition,
235
+ handleClose
236
+ })
237
+ }
238
+ >
236
239
  <span>
237
240
  <div ref={innerContentRef}>
238
241
  <Paper
@@ -0,0 +1 @@
1
+ export const ANIMATION_DURATION = 250
@@ -1,6 +1,8 @@
1
1
  import React from 'react'
2
2
  import { getFlagshipMetadata } from 'cozy-device-helper'
3
3
 
4
+ import { ANIMATION_DURATION } from './constants'
5
+
4
6
  export const computeMaxHeight = toolbarProps => {
5
7
  const { ref, height } = toolbarProps
6
8
  let computedToolbarHeight = 1
@@ -94,3 +96,18 @@ export const setBottomPosition = ({
94
96
  setIsBottomPosition(false)
95
97
  }
96
98
  }
99
+
100
+ export const minimizeAndClose = ({
101
+ backdrop,
102
+ setCurrentIndex,
103
+ setIsTopPosition,
104
+ setIsBottomPosition,
105
+ handleClose
106
+ }) => {
107
+ if (backdrop) {
108
+ setCurrentIndex(0)
109
+ setIsTopPosition(false)
110
+ setIsBottomPosition(true)
111
+ setTimeout(handleClose, ANIMATION_DURATION)
112
+ }
113
+ }
@@ -3,7 +3,8 @@ import {
3
3
  computeMediumHeight,
4
4
  computeMinHeight,
5
5
  setTopPosition,
6
- setBottomPosition
6
+ setBottomPosition,
7
+ minimizeAndClose
7
8
  } from './helpers'
8
9
 
9
10
  jest.mock('cozy-device-helper', () => ({
@@ -233,3 +234,51 @@ describe('setBottomPosition', () => {
233
234
  })
234
235
  })
235
236
  })
237
+
238
+ describe('minimizeAndClose', () => {
239
+ jest.useFakeTimers()
240
+
241
+ it('should not trigger function if no backdrop', () => {
242
+ const setCurrentIndex = jest.fn()
243
+ const setIsTopPosition = jest.fn()
244
+ const setIsBottomPosition = jest.fn()
245
+ const handleClose = jest.fn()
246
+
247
+ minimizeAndClose({
248
+ backdrop: false,
249
+ setCurrentIndex,
250
+ setIsTopPosition,
251
+ setIsBottomPosition,
252
+ handleClose
253
+ })
254
+
255
+ jest.runAllTimers()
256
+
257
+ expect(setCurrentIndex).not.toHaveBeenCalled()
258
+ expect(setIsTopPosition).not.toHaveBeenCalled()
259
+ expect(setIsBottomPosition).not.toHaveBeenCalled()
260
+ expect(handleClose).not.toHaveBeenCalled()
261
+ })
262
+
263
+ it('should trigger every function if backdrop is true', () => {
264
+ const setCurrentIndex = jest.fn()
265
+ const setIsTopPosition = jest.fn()
266
+ const setIsBottomPosition = jest.fn()
267
+ const handleClose = jest.fn()
268
+
269
+ minimizeAndClose({
270
+ backdrop: true,
271
+ setCurrentIndex,
272
+ setIsTopPosition,
273
+ setIsBottomPosition,
274
+ handleClose
275
+ })
276
+
277
+ jest.runAllTimers()
278
+
279
+ expect(setCurrentIndex).toHaveBeenCalledWith(0)
280
+ expect(setIsTopPosition).toHaveBeenCalledWith(false)
281
+ expect(setIsBottomPosition).toHaveBeenCalledWith(true)
282
+ expect(handleClose).toHaveBeenCalled()
283
+ })
284
+ })
@@ -4,7 +4,7 @@
4
4
  position absolute
5
5
  top 1.15rem
6
6
  right 1.15rem
7
- z-index var(--zIndex-modal) //needed for an iOS bug https://github.com/cozy/cozy-ui/pull/1790
7
+ z-index 1
8
8
  transform translateY(var(--flagship-top-height))
9
9
  +small-screen()
10
10
  top 0.25rem
@@ -14,7 +14,7 @@
14
14
  position absolute
15
15
  top 1.15rem
16
16
  left 1.15rem
17
- z-index var(--zIndex-modal) //needed for an iOS bug https://github.com/cozy/cozy-ui/pull/1790
17
+ z-index 1
18
18
  +small-screen()
19
19
  top 0.25rem
20
20
  left 0.25rem
@@ -16,8 +16,8 @@ import Stack from "cozy-ui/transpiled/react/Stack";
16
16
  import Paper from "cozy-ui/transpiled/react/Paper";
17
17
  import ClickAwayListener from "cozy-ui/transpiled/react/ClickAwayListener";
18
18
  import BackdropOrFragment from "cozy-ui/transpiled/react/BottomSheet/BackdropOrFragment";
19
- import { computeMaxHeight, computeMediumHeight, computeMinHeight, makeOverridenChildren, setTopPosition, setBottomPosition } from "cozy-ui/transpiled/react/BottomSheet/helpers";
20
- var ANIMATION_DURATION = 250;
19
+ import { computeMaxHeight, computeMediumHeight, computeMinHeight, makeOverridenChildren, setTopPosition, setBottomPosition, minimizeAndClose } from "cozy-ui/transpiled/react/BottomSheet/helpers";
20
+ import { ANIMATION_DURATION } from "cozy-ui/transpiled/react/BottomSheet/constants";
21
21
 
22
22
  var createStyles = function createStyles(_ref) {
23
23
  var squared = _ref.squared,
@@ -148,13 +148,6 @@ var BottomSheet = function BottomSheet(_ref2) {
148
148
  onClose && onClose();
149
149
  }, [onClose]);
150
150
 
151
- var handleMinimizeAndClose = function handleMinimizeAndClose() {
152
- if (backdrop) {
153
- setCurrentIndex(0);
154
- setTimeout(handleClose, ANIMATION_DURATION);
155
- }
156
- };
157
-
158
151
  var handleOnIndexChange = function handleOnIndexChange(snapIndex) {
159
152
  var maxHeightSnapIndex = peekHeights.length - 1;
160
153
  setCurrentIndex(snapIndex);
@@ -239,7 +232,15 @@ var BottomSheet = function BottomSheet(_ref2) {
239
232
  hidden: isHidden,
240
233
  snapPointSeekerMode: "next"
241
234
  }, /*#__PURE__*/React.createElement(ClickAwayListener, {
242
- onClickAway: handleMinimizeAndClose
235
+ onClickAway: function onClickAway() {
236
+ return minimizeAndClose({
237
+ backdrop: backdrop,
238
+ setCurrentIndex: setCurrentIndex,
239
+ setIsTopPosition: setIsTopPosition,
240
+ setIsBottomPosition: setIsBottomPosition,
241
+ handleClose: handleClose
242
+ });
243
+ }
243
244
  }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("div", {
244
245
  ref: innerContentRef
245
246
  }, /*#__PURE__*/React.createElement(Paper, {
@@ -0,0 +1 @@
1
+ export var ANIMATION_DURATION = 250;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { getFlagshipMetadata } from 'cozy-device-helper';
3
+ import { ANIMATION_DURATION } from "cozy-ui/transpiled/react/BottomSheet/constants";
3
4
  export var computeMaxHeight = function computeMaxHeight(toolbarProps) {
4
5
  var ref = toolbarProps.ref,
5
6
  height = toolbarProps.height;
@@ -82,4 +83,18 @@ export var setBottomPosition = function setBottomPosition(_ref4) {
82
83
  if (snapIndex !== 0 && isBottomPosition) {
83
84
  setIsBottomPosition(false);
84
85
  }
86
+ };
87
+ export var minimizeAndClose = function minimizeAndClose(_ref5) {
88
+ var backdrop = _ref5.backdrop,
89
+ setCurrentIndex = _ref5.setCurrentIndex,
90
+ setIsTopPosition = _ref5.setIsTopPosition,
91
+ setIsBottomPosition = _ref5.setIsBottomPosition,
92
+ handleClose = _ref5.handleClose;
93
+
94
+ if (backdrop) {
95
+ setCurrentIndex(0);
96
+ setIsTopPosition(false);
97
+ setIsBottomPosition(true);
98
+ setTimeout(handleClose, ANIMATION_DURATION);
99
+ }
85
100
  };