cozy-ui 111.15.1 → 111.16.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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [111.16.0](https://github.com/cozy/cozy-ui/compare/v111.15.2...v111.16.0) (2024-10-10)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Icon:** Add `img` tag and `.png` file support ([c1eeb5d](https://github.com/cozy/cozy-ui/commit/c1eeb5d))
7
+
8
+ ## [111.15.2](https://github.com/cozy/cozy-ui/compare/v111.15.1...v111.15.2) (2024-10-09)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **BottomSheet:** Add safe area and flagship app height to compute toolbar height ([f452eca](https://github.com/cozy/cozy-ui/commit/f452eca))
14
+
1
15
  ## [111.15.1](https://github.com/cozy/cozy-ui/compare/v111.15.0...v111.15.1) (2024-10-09)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "111.15.1",
3
+ "version": "111.16.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -14,7 +14,11 @@ export const computeToolbarHeight = (toolbarProps = {}) => {
14
14
  computedToolbarHeight = ref.current.offsetHeight
15
15
  }
16
16
 
17
- return computedToolbarHeight
17
+ return (
18
+ computedToolbarHeight +
19
+ (getFlagshipMetadata().statusBarHeight || 0) +
20
+ getSafeAreaValue('top')
21
+ )
18
22
  }
19
23
 
20
24
  export const computeMaxHeight = toolbarProps => {
@@ -22,19 +22,19 @@ describe('computeMaxHeight', () => {
22
22
  it('should return correct value if no arg', () => {
23
23
  const res = computeMaxHeight({})
24
24
 
25
- expect(res).toBe(799)
25
+ expect(res).toBe(784)
26
26
  })
27
27
 
28
28
  it('should return correct value with height arg', () => {
29
29
  const res = computeMaxHeight({ height: 50 })
30
30
 
31
- expect(res).toBe(750)
31
+ expect(res).toBe(735)
32
32
  })
33
33
 
34
34
  it('should return correct value with ref arg', () => {
35
35
  const res = computeMaxHeight({ ref: { current: { offsetHeight: 50 } } })
36
36
 
37
- expect(res).toBe(750)
37
+ expect(res).toBe(735)
38
38
  })
39
39
  })
40
40
 
@@ -397,7 +397,7 @@ describe('computeBottomSpacer', () => {
397
397
  offset: 0
398
398
  })
399
399
 
400
- expect(res).toBe(1)
400
+ expect(res).toBe(16)
401
401
  })
402
402
 
403
403
  it('should return the toolbar height', () => {
@@ -409,7 +409,7 @@ describe('computeBottomSpacer', () => {
409
409
  offset: 0
410
410
  })
411
411
 
412
- expect(res).toBe(50)
412
+ expect(res).toBe(65)
413
413
  })
414
414
 
415
415
  it('should return the offset value and border', () => {
@@ -420,7 +420,7 @@ describe('computeBottomSpacer', () => {
420
420
  offset: 48
421
421
  })
422
422
 
423
- expect(res).toBe(49)
423
+ expect(res).toBe(64)
424
424
  })
425
425
 
426
426
  it('should return the offset value and border and toolbar height', () => {
@@ -432,7 +432,7 @@ describe('computeBottomSpacer', () => {
432
432
  offset: 48
433
433
  })
434
434
 
435
- expect(res).toBe(98)
435
+ expect(res).toBe(113)
436
436
  })
437
437
  })
438
438
  })
@@ -495,7 +495,7 @@ describe('computeBottomSpacer', () => {
495
495
  offset: 0
496
496
  })
497
497
 
498
- expect(res).toBe(1)
498
+ expect(res).toBe(16)
499
499
  })
500
500
 
501
501
  it('should return the toolbar height', () => {
@@ -507,7 +507,7 @@ describe('computeBottomSpacer', () => {
507
507
  offset: 0
508
508
  })
509
509
 
510
- expect(res).toBe(50)
510
+ expect(res).toBe(65)
511
511
  })
512
512
 
513
513
  it('should return the offset value', () => {
@@ -518,7 +518,7 @@ describe('computeBottomSpacer', () => {
518
518
  offset: 48
519
519
  })
520
520
 
521
- expect(res).toBe(49)
521
+ expect(res).toBe(64)
522
522
  })
523
523
 
524
524
  it('should return the offset value and toolbar height', () => {
@@ -530,7 +530,7 @@ describe('computeBottomSpacer', () => {
530
530
  offset: 48
531
531
  })
532
532
 
533
- expect(res).toBe(98)
533
+ expect(res).toBe(113)
534
534
  })
535
535
  })
536
536
  })
@@ -540,18 +540,18 @@ describe('computeToolbarHeight', () => {
540
540
  it('should return the height prop', () => {
541
541
  const res = computeToolbarHeight({ height: 50 })
542
542
 
543
- expect(res).toBe(50)
543
+ expect(res).toBe(65)
544
544
  })
545
545
 
546
546
  it('should return the height from ref', () => {
547
547
  const res = computeToolbarHeight({ ref: { current: { offsetHeight: 50 } } })
548
548
 
549
- expect(res).toBe(50)
549
+ expect(res).toBe(65)
550
550
  })
551
551
 
552
552
  it('should return default value', () => {
553
553
  const res = computeToolbarHeight()
554
554
 
555
- expect(res).toBe(1)
555
+ expect(res).toBe(16)
556
556
  })
557
557
  })
@@ -92,6 +92,8 @@ const hideBottomSheet = () => setState({ bottomSheetOpened: false })
92
92
  const showBottomSheet = () => setState({ bottomSheetOpened: true })
93
93
  const hideSecondConfirmDialog = () => setState({ secondConfirmDialogOpened: false })
94
94
  const showSecondConfirmDialog = () => setState({ secondConfirmDialogOpened: true })
95
+ const hideSecondDialog = () => setState({ secondDialogOpened: false })
96
+ const showSecondDialog = () => setState({ secondDialogOpened: true })
95
97
  const hideBSConfirmDialog = () => setState({ BSConfirmDialogOpened: false })
96
98
  const showBSConfirmDialog = () => setState({ BSConfirmDialogOpened: true })
97
99
 
@@ -188,6 +190,7 @@ initialState = {
188
190
  modalOpened: isTesting(),
189
191
  bottomSheetOpened: false,
190
192
  secondConfirmDialogOpened: false,
193
+ secondDialogOpened: false,
191
194
  BSConfirmDialogOpened: false,
192
195
  modal: Dialog,
193
196
  size: 'medium',
@@ -323,6 +326,9 @@ const initialVariants = [{
323
326
  <div>
324
327
  <Button label="Show inner confirm dialog" onClick={showSecondConfirmDialog}/>
325
328
  </div>
329
+ <div>
330
+ <Button label="Show inner dialog" onClick={showSecondDialog}/>
331
+ </div>
326
332
  </Stack>
327
333
  </Typography>
328
334
 
@@ -333,6 +339,13 @@ const initialVariants = [{
333
339
  />
334
340
  )}
335
341
 
342
+ {state.secondDialogOpened && (
343
+ <Dialog open onClose={hideSecondDialog}
344
+ title="This is a simple title"
345
+ content="This is a simple content"
346
+ />
347
+ )}
348
+
336
349
  {state.bottomSheetOpened && (
337
350
  <BottomSheet backdrop onClose={hideBottomSheet}>
338
351
  <BottomSheetItem>
@@ -51,8 +51,23 @@ function Icon(props) {
51
51
  if (!icon) return null
52
52
 
53
53
  const isIconComp = icon.type === Icon
54
-
55
- if (isIconComp) return icon
54
+ const isImg = icon.type === 'img'
55
+
56
+ if (isIconComp || isImg) return icon
57
+
58
+ const isPngPath = typeof icon === 'string' && icon.includes('.png')
59
+
60
+ if (isPngPath)
61
+ return (
62
+ <img
63
+ src={icon}
64
+ className={className}
65
+ style={style}
66
+ width={width || size || DEFAULT_SIZE}
67
+ height={height || size || DEFAULT_SIZE}
68
+ {...restProps}
69
+ />
70
+ )
56
71
 
57
72
  const Svg = isFunction(icon) ? icon : makeSvgObject(icon)
58
73
 
@@ -14,7 +14,7 @@ export var computeToolbarHeight = function computeToolbarHeight() {
14
14
  computedToolbarHeight = ref.current.offsetHeight;
15
15
  }
16
16
 
17
- return computedToolbarHeight;
17
+ return computedToolbarHeight + (getFlagshipMetadata().statusBarHeight || 0) + getSafeAreaValue('top');
18
18
  };
19
19
  export var computeMaxHeight = function computeMaxHeight(toolbarProps) {
20
20
  var toolbarHeight = computeToolbarHeight(toolbarProps);
@@ -1,5 +1,5 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  var _excluded = ["icon", "width", "height", "color", "style", "className", "preserveColor", "rotate", "size", "spin"];
5
5
  import cx from 'classnames';
@@ -56,7 +56,16 @@ function Icon(props) {
56
56
 
57
57
  if (!icon) return null;
58
58
  var isIconComp = icon.type === Icon;
59
- if (isIconComp) return icon;
59
+ var isImg = icon.type === 'img';
60
+ if (isIconComp || isImg) return icon;
61
+ var isPngPath = typeof icon === 'string' && icon.includes('.png');
62
+ if (isPngPath) return /*#__PURE__*/React.createElement("img", _extends({
63
+ src: icon,
64
+ className: className,
65
+ style: style,
66
+ width: width || size || DEFAULT_SIZE,
67
+ height: height || size || DEFAULT_SIZE
68
+ }, restProps));
60
69
  var Svg = isFunction(icon) ? icon : makeSvgObject(icon);
61
70
  var selfStyle = style;
62
71
  selfStyle = Object.assign({}, selfStyle);