cozy-ui 107.2.0 → 107.4.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,23 @@
1
+ # [107.4.0](https://github.com/cozy/cozy-ui/compare/v107.3.0...v107.4.0) (2024-06-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **useSetFlagshipUi:** The navbar and statusbar height should be dynamic ([bb931d1](https://github.com/cozy/cozy-ui/commit/bb931d1))
7
+
8
+
9
+ ### Features
10
+
11
+ * **BottomSheet:** Open BottomSheet at minimum height ([53e00bb](https://github.com/cozy/cozy-ui/commit/53e00bb))
12
+ * **Viewer:** Open BottomSheet at minimum height in public view ([479f998](https://github.com/cozy/cozy-ui/commit/479f998))
13
+
14
+ # [107.3.0](https://github.com/cozy/cozy-ui/compare/v107.2.0...v107.3.0) (2024-06-04)
15
+
16
+
17
+ ### Features
18
+
19
+ * Remove jobs for argos on branch master ([a4512d1](https://github.com/cozy/cozy-ui/commit/a4512d1))
20
+
1
21
  # [107.2.0](https://github.com/cozy/cozy-ui/compare/v107.1.0...v107.2.0) (2024-05-29)
2
22
 
3
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "107.2.0",
3
+ "version": "107.4.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -129,7 +129,8 @@ export const defaultBottomSheetSpringConfig = {
129
129
 
130
130
  const defaultSettings = {
131
131
  mediumHeightRatio: 0.75,
132
- mediumHeight: null
132
+ mediumHeight: null,
133
+ isOpenMin: false
133
134
  }
134
135
 
135
136
  const BottomSheet = memo(
@@ -142,7 +143,7 @@ const BottomSheet = memo(
142
143
  offset,
143
144
  children
144
145
  }) => {
145
- const { mediumHeightRatio, mediumHeight } = {
146
+ const { mediumHeightRatio, mediumHeight, isOpenMin } = {
146
147
  ...defaultSettings,
147
148
  ...settings
148
149
  }
@@ -240,21 +241,25 @@ const BottomSheet = memo(
240
241
  toolbarProps,
241
242
  offset
242
243
  })
243
- const computedMediumHeight = computeMediumHeight({
244
- backdrop,
245
- maxHeight,
246
- mediumHeight,
247
- mediumHeightRatio,
248
- innerContentHeight,
249
- bottomSpacerHeight,
250
- offset
251
- })
252
244
  const minHeight = computeMinHeight({
253
245
  isClosable,
246
+ isOpenMin,
254
247
  headerRef,
255
248
  actionButtonsHeight,
256
249
  actionButtonsBottomMargin
257
250
  })
251
+ const computedMediumHeight =
252
+ isOpenMin && actionButtonsHeight > 0
253
+ ? minHeight + 1
254
+ : computeMediumHeight({
255
+ backdrop,
256
+ maxHeight,
257
+ mediumHeight,
258
+ mediumHeightRatio,
259
+ innerContentHeight,
260
+ bottomSpacerHeight,
261
+ offset
262
+ })
258
263
 
259
264
  const newPeekHeights = [
260
265
  ...new Set([minHeight, computedMediumHeight, maxHeight])
@@ -408,7 +413,9 @@ BottomSheet.propTypes = {
408
413
  /** Height in pixel of the middle snap point */
409
414
  mediumHeight: PropTypes.number,
410
415
  /** Height of the middle snap point, expressed as a percentage of the viewport height */
411
- mediumHeightRatio: PropTypes.number
416
+ mediumHeightRatio: PropTypes.number,
417
+ /** To open the BottomSheet at the minimum height, if have an header */
418
+ isOpenMin: PropTypes.bool
412
419
  }),
413
420
  /** To add a backdrop */
414
421
  backdrop: PropTypes.bool,
@@ -88,7 +88,8 @@ const initialVariants = [{
88
88
  withFakeToolbar: false,
89
89
  withHeader: true,
90
90
  withListContent: false,
91
- withTitle: false
91
+ withTitle: false,
92
+ isOpenMin: false
92
93
  }]
93
94
  const initialState = {
94
95
  isBottomSheetDisplayed: isTesting(),
@@ -112,10 +113,14 @@ const handleChangeOffset = el => {
112
113
  setState({ offset: Number(el.target.value) })
113
114
  }
114
115
 
116
+ const makeSettings = variant => {
115
117
  const settings = state.mediumHeight === undefined && state.mediumHeightRatio === undefined
116
118
  ? undefined
117
119
  : { mediumHeight: state.mediumHeight, mediumHeightRatio: state.mediumHeightRatio }
118
120
 
121
+ return { ...settings, isOpenMin: variant.isOpenMin }
122
+ }
123
+
119
124
  // -->
120
125
 
121
126
  ;
@@ -163,7 +168,7 @@ const settings = state.mediumHeight === undefined && state.mediumHeightRatio ===
163
168
  {state.isBottomSheetDisplayed && (
164
169
  <BottomSheet
165
170
  toolbarProps={variant.withFakeToolbar ? { height: 50 } : undefined}
166
- settings={settings}
171
+ settings={makeSettings(variant)}
167
172
  backdrop={variant.backdrop}
168
173
  skipAnimation={isTesting()}
169
174
  offset={state.offset}
@@ -55,11 +55,12 @@ export const computeMediumHeight = ({
55
55
 
56
56
  export const computeMinHeight = ({
57
57
  isClosable,
58
+ isOpenMin,
58
59
  headerRef,
59
60
  actionButtonsHeight,
60
61
  actionButtonsBottomMargin
61
62
  }) => {
62
- if (isClosable) return 0
63
+ if (isClosable && !isOpenMin) return 0
63
64
 
64
65
  return (
65
66
  headerRef.current.offsetHeight +
@@ -153,9 +153,10 @@ const files = [
153
153
  metadata: {
154
154
  number: 12345,
155
155
  refTaxIncome: '153',
156
- datetime: new Date(Date.now()).toISOString(),
157
- referencedDate: new Date(Date.now()).toISOString(),
158
- expirationDate: new Date(Date.now() + 10 * 24 * 60 * 60 * 1000).toISOString(),
156
+ datetime: '2024-01-11T12:00:00.000Z',
157
+ datetimeLabel: 'expirationDate',
158
+ referencedDate: '2024-01-01T12:00:00.000Z',
159
+ expirationDate: '2024-01-11T12:00:00.000Z',
159
160
  noticePeriod: '30',
160
161
  qualification: {
161
162
  label: 'driver_license'
@@ -48,12 +48,17 @@ const FooterContent = ({ file, toolbarRef, children, isPublic }) => {
48
48
  name: 'FooterActionButtons'
49
49
  })
50
50
 
51
+ const bottomSheetSettings = {
52
+ isOpenMin: isPublic ? true : false,
53
+ mediumHeightRatio: isPublic ? undefined : 0.5
54
+ }
55
+
51
56
  if (isValidForPanel({ file })) {
52
57
  return (
53
58
  <BottomSheet
54
59
  toolbarProps={toolbarProps}
55
60
  portalProps={{ disablePortal: true }}
56
- settings={{ mediumHeightRatio: isPublic ? 0 : 0.5 }}
61
+ settings={bottomSheetSettings}
57
62
  >
58
63
  <BottomSheetHeader
59
64
  className={cx('u-ph-1 u-pb-1', styles.bottomSheetHeader)}
@@ -26,6 +26,7 @@ The `Viewer` can display an **information panel** to show additional information
26
26
  * **page** : `<string>` – URL used to edit the file when editing a `page` type metadata (side of the document)
27
27
  * **onChangeRequest** : `<function>` - Called with (nextFile, nextIndex) when the user requests to navigate to another file
28
28
  * **onCloseRequest** : `<function>` - Called when the user wants to leave the Viewer
29
+ * **isPublic**: `<boolean>` - Whether the viewer is used in a public page or not
29
30
  * **componentsProps** : `<object>` – Props passed to components with the same name
30
31
  * **modalProps** : `<object>` – Props passed to Modal component
31
32
  * **OnlyOfficeViewer** : `<object>` – Used to open an Only Office file
@@ -204,7 +205,7 @@ initialState = {
204
205
  }
205
206
 
206
207
  const initialVariants = [
207
- { navigation: true, toolbar: true, onlyOfficeEnabled: true, disableModal: false }
208
+ { navigation: true, toolbar: true, onlyOfficeEnabled: true, disableModal: false, isPublic: false }
208
209
  ]
209
210
 
210
211
  const getURL = (file) => {
@@ -252,6 +253,7 @@ const editPathByModelProps = {
252
253
  {state.viewerOpened && (
253
254
  <Viewer
254
255
  files={files}
256
+ isPublic={variant.isPublic}
255
257
  currentIndex={state.currentIndex}
256
258
  currentURL={state.currentURL}
257
259
  disableModal={variant.disableModal}
@@ -91,13 +91,16 @@ export const isRsg = !!document.getElementById('rsg-root')
91
91
  */
92
92
  export const getFlagshipMetadata =
93
93
  isRsg || process.env.NODE_ENV === 'test'
94
- ? () => ({
95
- immersive:
96
- JSON.parse(localStorage.getItem('flagship-app'))?.contained ===
97
- 'off' || false,
98
- statusBarHeight: 40,
99
- navbarHeight: 40
100
- })
94
+ ? () => {
95
+ const isFlagshipAppContained =
96
+ JSON.parse(localStorage.getItem('flagship-app'))?.contained === 'on'
97
+
98
+ return {
99
+ immersive: isFlagshipAppContained ? false : true,
100
+ statusBarHeight: isFlagshipAppContained ? 0 : 40,
101
+ navbarHeight: isFlagshipAppContained ? 0 : 40
102
+ }
103
+ }
101
104
  : getFlagshipMetadataFromDeviceHelper
102
105
 
103
106
  /**
@@ -125,7 +125,8 @@ export var defaultBottomSheetSpringConfig = {
125
125
  };
126
126
  var defaultSettings = {
127
127
  mediumHeightRatio: 0.75,
128
- mediumHeight: null
128
+ mediumHeight: null,
129
+ isOpenMin: false
129
130
  };
130
131
  var BottomSheet = /*#__PURE__*/memo(function (_ref3) {
131
132
  var toolbarProps = _ref3.toolbarProps,
@@ -138,7 +139,8 @@ var BottomSheet = /*#__PURE__*/memo(function (_ref3) {
138
139
 
139
140
  var _defaultSettings$sett = _objectSpread(_objectSpread({}, defaultSettings), settings),
140
141
  mediumHeightRatio = _defaultSettings$sett.mediumHeightRatio,
141
- mediumHeight = _defaultSettings$sett.mediumHeight;
142
+ mediumHeight = _defaultSettings$sett.mediumHeight,
143
+ isOpenMin = _defaultSettings$sett.isOpenMin;
142
144
 
143
145
  var innerContentRef = useRef();
144
146
  var headerRef = useRef();
@@ -263,7 +265,14 @@ var BottomSheet = /*#__PURE__*/memo(function (_ref3) {
263
265
  toolbarProps: toolbarProps,
264
266
  offset: offset
265
267
  });
266
- var computedMediumHeight = computeMediumHeight({
268
+ var minHeight = computeMinHeight({
269
+ isClosable: isClosable,
270
+ isOpenMin: isOpenMin,
271
+ headerRef: headerRef,
272
+ actionButtonsHeight: actionButtonsHeight,
273
+ actionButtonsBottomMargin: actionButtonsBottomMargin
274
+ });
275
+ var computedMediumHeight = isOpenMin && actionButtonsHeight > 0 ? minHeight + 1 : computeMediumHeight({
267
276
  backdrop: backdrop,
268
277
  maxHeight: maxHeight,
269
278
  mediumHeight: mediumHeight,
@@ -272,12 +281,6 @@ var BottomSheet = /*#__PURE__*/memo(function (_ref3) {
272
281
  bottomSpacerHeight: bottomSpacerHeight,
273
282
  offset: offset
274
283
  });
275
- var minHeight = computeMinHeight({
276
- isClosable: isClosable,
277
- headerRef: headerRef,
278
- actionButtonsHeight: actionButtonsHeight,
279
- actionButtonsBottomMargin: actionButtonsBottomMargin
280
- });
281
284
 
282
285
  var newPeekHeights = _toConsumableArray(new Set([minHeight, computedMediumHeight, maxHeight]));
283
286
 
@@ -400,7 +403,10 @@ BottomSheet.propTypes = {
400
403
  mediumHeight: PropTypes.number,
401
404
 
402
405
  /** Height of the middle snap point, expressed as a percentage of the viewport height */
403
- mediumHeightRatio: PropTypes.number
406
+ mediumHeightRatio: PropTypes.number,
407
+
408
+ /** To open the BottomSheet at the minimum height, if have an header */
409
+ isOpenMin: PropTypes.bool
404
410
  }),
405
411
 
406
412
  /** To add a backdrop */
@@ -43,10 +43,11 @@ export var computeMediumHeight = function computeMediumHeight(_ref) {
43
43
  };
44
44
  export var computeMinHeight = function computeMinHeight(_ref2) {
45
45
  var isClosable = _ref2.isClosable,
46
+ isOpenMin = _ref2.isOpenMin,
46
47
  headerRef = _ref2.headerRef,
47
48
  actionButtonsHeight = _ref2.actionButtonsHeight,
48
49
  actionButtonsBottomMargin = _ref2.actionButtonsBottomMargin;
49
- if (isClosable) return 0;
50
+ if (isClosable && !isOpenMin) return 0;
50
51
  return headerRef.current.offsetHeight + actionButtonsHeight + actionButtonsBottomMargin + (getFlagshipMetadata().navbarHeight || 0) + getSafeAreaValue('bottom');
51
52
  };
52
53
  export var makeOverridenChildren = function makeOverridenChildren(children, headerContentRef) {
@@ -54,6 +54,10 @@ var FooterContent = function FooterContent(_ref2) {
54
54
  file: file,
55
55
  name: 'FooterActionButtons'
56
56
  });
57
+ var bottomSheetSettings = {
58
+ isOpenMin: isPublic ? true : false,
59
+ mediumHeightRatio: isPublic ? undefined : 0.5
60
+ };
57
61
 
58
62
  if (isValidForPanel({
59
63
  file: file
@@ -63,9 +67,7 @@ var FooterContent = function FooterContent(_ref2) {
63
67
  portalProps: {
64
68
  disablePortal: true
65
69
  },
66
- settings: {
67
- mediumHeightRatio: isPublic ? 0 : 0.5
68
- }
70
+ settings: bottomSheetSettings
69
71
  }, /*#__PURE__*/React.createElement(BottomSheetHeader, {
70
72
  className: cx('u-ph-1 u-pb-1', styles.bottomSheetHeader)
71
73
  }, /*#__PURE__*/React.createElement(FooterButtons, {
@@ -92,10 +92,11 @@ export var isRsg = !!document.getElementById('rsg-root');
92
92
  export var getFlagshipMetadata = isRsg || process.env.NODE_ENV === 'test' ? function () {
93
93
  var _JSON$parse;
94
94
 
95
+ var isFlagshipAppContained = ((_JSON$parse = JSON.parse(localStorage.getItem('flagship-app'))) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.contained) === 'on';
95
96
  return {
96
- immersive: ((_JSON$parse = JSON.parse(localStorage.getItem('flagship-app'))) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.contained) === 'off' || false,
97
- statusBarHeight: 40,
98
- navbarHeight: 40
97
+ immersive: isFlagshipAppContained ? false : true,
98
+ statusBarHeight: isFlagshipAppContained ? 0 : 40,
99
+ navbarHeight: isFlagshipAppContained ? 0 : 40
99
100
  };
100
101
  } : getFlagshipMetadataFromDeviceHelper;
101
102
  /**