cozy-ui 62.2.0 → 62.4.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 CHANGED
@@ -1,3 +1,24 @@
1
+ ## [62.4.1](https://github.com/cozy/cozy-ui/compare/v62.4.0...v62.4.1) (2022-03-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump @semantic-release/npm from 5.3.4 to 9.0.1 ([cfb30eb](https://github.com/cozy/cozy-ui/commit/cfb30eb))
7
+
8
+ # [62.4.0](https://github.com/cozy/cozy-ui/compare/v62.3.0...v62.4.0) (2022-03-28)
9
+
10
+
11
+ ### Features
12
+
13
+ * Add tiny size for FileImageLoader ([ae6ba29](https://github.com/cozy/cozy-ui/commit/ae6ba29))
14
+
15
+ # [62.3.0](https://github.com/cozy/cozy-ui/compare/v62.2.0...v62.3.0) (2022-03-25)
16
+
17
+
18
+ ### Features
19
+
20
+ * Implement openApp animation from cozy-ui ([45e9e3b](https://github.com/cozy/cozy-ui/commit/45e9e3b))
21
+
1
22
  # [62.2.0](https://github.com/cozy/cozy-ui/compare/v62.1.4...v62.2.0) (2022-03-22)
2
23
 
3
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "62.2.0",
3
+ "version": "62.4.1",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -76,7 +76,7 @@
76
76
  "@material-ui/core": "4.12.3",
77
77
  "@semantic-release/changelog": "5.0.1",
78
78
  "@semantic-release/git": "7.0.18",
79
- "@semantic-release/npm": "5.3.4",
79
+ "@semantic-release/npm": "9.0.1",
80
80
  "@svgr/cli": "^5.4.0",
81
81
  "@testing-library/jest-dom": "^5.14.1",
82
82
  "@testing-library/react": "11.2.7",
@@ -111,8 +111,9 @@ export class AppIcon extends Component {
111
111
  <img
112
112
  alt={alt}
113
113
  className={cx(styles['c-app-icon'], className)}
114
- src={icon}
115
114
  onError={this.handleError}
115
+ ref={this.props.iconRef}
116
+ src={icon}
116
117
  />
117
118
  )
118
119
  case ERRORED:
@@ -128,6 +129,7 @@ export class AppIcon extends Component {
128
129
  icon={fallbackIcon || CubeIcon}
129
130
  width="100%"
130
131
  color={palette['coolGrey']}
132
+ iconRef={this.props.iconRef}
131
133
  />
132
134
  )
133
135
  }
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
2
  import PropTypes from 'prop-types'
3
+
3
4
  import {
4
5
  checkApp,
5
6
  startApp,
@@ -9,6 +10,8 @@ import {
9
10
  isAndroid,
10
11
  isFlagshipApp
11
12
  } from 'cozy-device-helper'
13
+ import { WebviewContext } from 'cozy-intent'
14
+ import logger from 'cozy-logger'
12
15
 
13
16
  import {
14
17
  generateUniversalLink,
@@ -17,7 +20,6 @@ import {
17
20
  } from './native'
18
21
  import { NATIVE_APP_INFOS } from './native.config'
19
22
  import expiringMemoize from './expiringMemoize'
20
- import { WebviewContext } from 'cozy-intent'
21
23
 
22
24
  const expirationDelay = 10 * 1000
23
25
  const memoizedCheckApp = expiringMemoize(
@@ -36,6 +38,13 @@ export class AppLinker extends React.Component {
36
38
 
37
39
  constructor(props) {
38
40
  super(props)
41
+
42
+ this.imgRef = null
43
+ }
44
+
45
+ setImgRef = img => {
46
+ this.imgRef = img
47
+ this.setState({ imgRef: this.imgRef })
39
48
  }
40
49
 
41
50
  componentDidMount() {
@@ -69,7 +78,7 @@ export class AppLinker extends React.Component {
69
78
  }
70
79
  }
71
80
 
72
- static getOnClickHref(props, nativeAppIsAvailable, context) {
81
+ static getOnClickHref(props, nativeAppIsAvailable, context, imgRef) {
73
82
  const { app, nativePath } = props
74
83
  const slug = AppLinker.getSlug(props)
75
84
  let href = props.href
@@ -79,15 +88,21 @@ export class AppLinker extends React.Component {
79
88
 
80
89
  if (isFlagshipApp()) {
81
90
  if (!context)
82
- console.warn(
83
- 'FlagshipApp detected but no context found. Is the app wrapped in WebviewIntentProvider?'
91
+ logger.warn(
92
+ 'FlagshipApp detected but no context found. Is the app wrapped in <WebviewIntentProvider? />'
84
93
  )
85
94
 
86
95
  if (context) {
96
+ const imgPayload =
97
+ imgRef &&
98
+ JSON.stringify({
99
+ ...imgRef.getBoundingClientRect().toJSON()
100
+ })
101
+
87
102
  return {
88
103
  onClick: event => {
89
104
  event.preventDefault()
90
- context.call('openApp', href, app)
105
+ context.call('openApp', href, app, imgPayload)
91
106
  },
92
107
  href: '#'
93
108
  }
@@ -180,9 +195,16 @@ export class AppLinker extends React.Component {
180
195
  const { href, onClick } = AppLinker.getOnClickHref(
181
196
  this.props,
182
197
  nativeAppIsAvailable,
183
- this.context
198
+ this.context,
199
+ this.state.imgRef
184
200
  )
185
- return children({ ...appInfo, onClick: onClick, href })
201
+
202
+ return children({
203
+ ...appInfo,
204
+ iconRef: this.setImgRef,
205
+ onClick: onClick,
206
+ href
207
+ })
186
208
  }
187
209
  }
188
210
 
@@ -160,7 +160,14 @@ export class FileImageLoader extends Component {
160
160
  FileImageLoader.propTypes = {
161
161
  file: PropTypes.object.isRequired,
162
162
  render: PropTypes.func.isRequired,
163
- linkType: PropTypes.oneOf(['small', 'medium', 'large', 'preview', 'icon']),
163
+ linkType: PropTypes.oneOf([
164
+ 'tiny',
165
+ 'small',
166
+ 'medium',
167
+ 'large',
168
+ 'preview',
169
+ 'icon'
170
+ ]),
164
171
  onError: PropTypes.func,
165
172
  renderFallback: PropTypes.func
166
173
  }
@@ -1,9 +1,9 @@
1
1
  // Automatically created, please run `scripts/generate-svg-icon.sh assets/icons/ui/cube.svg` to regenerate;
2
2
  import React from 'react'
3
3
 
4
- function SvgCube(props) {
4
+ function SvgCube({ iconRef, ...props }) {
5
5
  return (
6
- <svg viewBox="0 0 16 16" {...props}>
6
+ <svg viewBox="0 0 16 16" {...props} ref={iconRef}>
7
7
  <path d="M1 11.009V5.5c0-.55.39-.773.872-.498l5.256 3.003c.476.272.872.944.872 1.495v5.508c0 .549-.39.772-.872.497l-5.256-3.003C1.396 12.231 1 11.56 1 11.01zm15 0c0 .55-.396 1.222-.872 1.494l-5.256 3.003c-.481.275-.872.052-.872-.497V9.5c0-.55.396-1.223.872-1.495l5.256-3.003c.481-.275.872-.052.872.498v5.508zM9.35 6.982c-.47.288-1.237.284-1.7 0l-4.8-2.954c-.47-.29-.463-.732.027-.995L7.623.477c.485-.261 1.264-.264 1.754 0l4.746 2.556c.485.26.49.71.027.995l-4.8 2.954z" />
8
8
  </svg>
9
9
  )
@@ -175,8 +175,9 @@ export var AppIcon = /*#__PURE__*/function (_Component) {
175
175
  return /*#__PURE__*/React.createElement("img", {
176
176
  alt: alt,
177
177
  className: cx(styles['c-app-icon'], className),
178
- src: icon,
179
- onError: this.handleError
178
+ onError: this.handleError,
179
+ ref: this.props.iconRef,
180
+ src: icon
180
181
  });
181
182
 
182
183
  case ERRORED:
@@ -186,7 +187,8 @@ export var AppIcon = /*#__PURE__*/function (_Component) {
186
187
  height: "100%",
187
188
  icon: fallbackIcon || CubeIcon,
188
189
  width: "100%",
189
- color: palette['coolGrey']
190
+ color: palette['coolGrey'],
191
+ iconRef: this.props.iconRef
190
192
  });
191
193
  }
192
194
  }
@@ -20,10 +20,11 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
20
20
  import React from 'react';
21
21
  import PropTypes from 'prop-types';
22
22
  import { checkApp, startApp, isMobileApp, isMobile, openDeeplinkOrRedirect, isAndroid, isFlagshipApp } from 'cozy-device-helper';
23
+ import { WebviewContext } from 'cozy-intent';
24
+ import logger from 'cozy-logger';
23
25
  import { generateUniversalLink, generateWebLink, getUniversalLinkDomain } from "cozy-ui/transpiled/react/AppLinker/native";
24
26
  import { NATIVE_APP_INFOS } from "cozy-ui/transpiled/react/AppLinker/native.config";
25
27
  import expiringMemoize from "cozy-ui/transpiled/react/AppLinker/expiringMemoize";
26
- import { WebviewContext } from 'cozy-intent';
27
28
  var expirationDelay = 10 * 1000;
28
29
  var memoizedCheckApp = expiringMemoize(function (appInfo) {
29
30
  return checkApp(appInfo).catch(function () {
@@ -49,6 +50,15 @@ export var AppLinker = /*#__PURE__*/function (_React$Component) {
49
50
  isFetchingAppInfo: false
50
51
  });
51
52
 
53
+ _defineProperty(_assertThisInitialized(_this), "setImgRef", function (img) {
54
+ _this.imgRef = img;
55
+
56
+ _this.setState({
57
+ imgRef: _this.imgRef
58
+ });
59
+ });
60
+
61
+ _this.imgRef = null;
52
62
  return _this;
53
63
  }
54
64
 
@@ -110,11 +120,12 @@ export var AppLinker = /*#__PURE__*/function (_React$Component) {
110
120
  var nativeAppIsAvailable = this.state.nativeAppIsAvailable;
111
121
  var appInfo = NATIVE_APP_INFOS[slug];
112
122
 
113
- var _AppLinker$getOnClick = AppLinker.getOnClickHref(this.props, nativeAppIsAvailable, this.context),
123
+ var _AppLinker$getOnClick = AppLinker.getOnClickHref(this.props, nativeAppIsAvailable, this.context, this.state.imgRef),
114
124
  href = _AppLinker$getOnClick.href,
115
125
  onClick = _AppLinker$getOnClick.onClick;
116
126
 
117
127
  return children(_objectSpread(_objectSpread({}, appInfo), {}, {
128
+ iconRef: this.setImgRef,
118
129
  onClick: onClick,
119
130
  href: href
120
131
  }));
@@ -137,7 +148,7 @@ export var AppLinker = /*#__PURE__*/function (_React$Component) {
137
148
  }
138
149
  }, {
139
150
  key: "getOnClickHref",
140
- value: function getOnClickHref(props, nativeAppIsAvailable, context) {
151
+ value: function getOnClickHref(props, nativeAppIsAvailable, context, imgRef) {
141
152
  var app = props.app,
142
153
  nativePath = props.nativePath;
143
154
  var slug = AppLinker.getSlug(props);
@@ -147,13 +158,14 @@ export var AppLinker = /*#__PURE__*/function (_React$Component) {
147
158
  var appInfo = NATIVE_APP_INFOS[slug];
148
159
 
149
160
  if (isFlagshipApp()) {
150
- if (!context) console.warn('FlagshipApp detected but no context found. Is the app wrapped in WebviewIntentProvider?');
161
+ if (!context) logger.warn('FlagshipApp detected but no context found. Is the app wrapped in <WebviewIntentProvider? />');
151
162
 
152
163
  if (context) {
164
+ var imgPayload = imgRef && JSON.stringify(_objectSpread({}, imgRef.getBoundingClientRect().toJSON()));
153
165
  return {
154
166
  onClick: function onClick(event) {
155
167
  event.preventDefault();
156
- context.call('openApp', href, app);
168
+ context.call('openApp', href, app, imgPayload);
157
169
  },
158
170
  href: '#'
159
171
  };
@@ -338,7 +338,7 @@ export var FileImageLoader = /*#__PURE__*/function (_Component) {
338
338
  FileImageLoader.propTypes = {
339
339
  file: PropTypes.object.isRequired,
340
340
  render: PropTypes.func.isRequired,
341
- linkType: PropTypes.oneOf(['small', 'medium', 'large', 'preview', 'icon']),
341
+ linkType: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'preview', 'icon']),
342
342
  onError: PropTypes.func,
343
343
  renderFallback: PropTypes.func
344
344
  };
@@ -1,11 +1,18 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["iconRef"];
2
4
  // Automatically created, please run `scripts/generate-svg-icon.sh assets/icons/ui/cube.svg` to regenerate;
3
5
  import React from 'react';
4
6
 
5
- function SvgCube(props) {
7
+ function SvgCube(_ref) {
8
+ var iconRef = _ref.iconRef,
9
+ props = _objectWithoutProperties(_ref, _excluded);
10
+
6
11
  return /*#__PURE__*/React.createElement("svg", _extends({
7
12
  viewBox: "0 0 16 16"
8
- }, props), /*#__PURE__*/React.createElement("path", {
13
+ }, props, {
14
+ ref: iconRef
15
+ }), /*#__PURE__*/React.createElement("path", {
9
16
  d: "M1 11.009V5.5c0-.55.39-.773.872-.498l5.256 3.003c.476.272.872.944.872 1.495v5.508c0 .549-.39.772-.872.497l-5.256-3.003C1.396 12.231 1 11.56 1 11.01zm15 0c0 .55-.396 1.222-.872 1.494l-5.256 3.003c-.481.275-.872.052-.872-.497V9.5c0-.55.396-1.223.872-1.495l5.256-3.003c.481-.275.872-.052.872.498v5.508zM9.35 6.982c-.47.288-1.237.284-1.7 0l-4.8-2.954c-.47-.29-.463-.732.027-.995L7.623.477c.485-.261 1.264-.264 1.754 0l4.746 2.556c.485.26.49.71.027.995l-4.8 2.954z"
10
17
  }));
11
18
  }