@zohodesk/dot 1.0.0-beta.218 → 1.0.0-beta.220

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  In this Library, we Provide Some Basic Components to Build Your Application
4
4
 
5
- # 1.0.0-beta.218
5
+ # 1.0.0-beta.218 , # 1.0.0-beta.219, # 1.0.0-beta.220
6
6
 
7
7
  - AttachmentViewer , AttachmentImage component added
8
8
 
@@ -3,10 +3,10 @@
3
3
  /** * Libraries ** */
4
4
  import React, { Component } from 'react';
5
5
  import PropTypes from 'prop-types';
6
+ import Image from '../Image/Image';
6
7
  /** * CSS ** */
7
8
 
8
9
  import style from './AttachmentViewer.module.css';
9
- import Image from '../Image/Image';
10
10
  export default class AttachmentImage extends Component {
11
11
  constructor(props) {
12
12
  super(props);
@@ -10,6 +10,7 @@ import Link from "../Link/Link";
10
10
  import IconButton from "../IconButton/IconButton";
11
11
  import FreezeLayer from "../FreezeLayer/FreezeLayer";
12
12
  import { isAudioFile, getExtensionFromFileName } from "./Attachment";
13
+ import { shallowDiff } from '../utils/General';
13
14
  import style from "./AttachmentViewer.module.css";
14
15
  export default class AttachmentViewer extends Component {
15
16
  constructor(props) {
@@ -37,6 +38,32 @@ export default class AttachmentViewer extends Component {
37
38
  this.zoomMaintain = this.zoomMaintain.bind(this);
38
39
  }
39
40
 
41
+ componentDidUpdate(prevProps) {
42
+ let {
43
+ previewObj
44
+ } = this.props;
45
+ let indexChanged = previewObj.selectedIndex != prevProps.previewObj.selectedIndex;
46
+
47
+ if (previewObj.previewData.length != prevProps.previewObj.previewData.length || indexChanged) {
48
+ let objChanged = previewObj.previewData.some((value, index) => {
49
+ return shallowDiff(value, prevProps.previewObj[index]);
50
+ });
51
+
52
+ if (objChanged || indexChanged) {
53
+ this.setState({
54
+ selectedIndex: previewObj.selectedIndex,
55
+ data: previewObj ? previewObj.previewData : [],
56
+ dataList: this.getUpdateDataList({
57
+ index: previewObj.selectedIndex,
58
+ data: previewObj ? previewObj.previewData : [],
59
+ dataList: []
60
+ }),
61
+ isPViewListOpen: !!(this.props.previewObj && this.props.previewObj.previewData)
62
+ });
63
+ }
64
+ }
65
+ }
66
+
40
67
  togglePViewList() {
41
68
  this.setState(prevState => ({
42
69
  isPViewListOpen: !prevState.isPViewListOpen
@@ -266,7 +293,8 @@ export default class AttachmentViewer extends Component {
266
293
  const {
267
294
  responsiveId,
268
295
  needDownload,
269
- i18nKeys
296
+ i18nKeys,
297
+ isActive
270
298
  } = this.props;
271
299
  const totalLen = data.length;
272
300
  const selectedAttachment = data[selectedIndex] || {};
@@ -276,7 +304,7 @@ export default class AttachmentViewer extends Component {
276
304
  let authorName;
277
305
  const {
278
306
  author
279
- } = data[selectedIndex] ? data[selectedIndex] : null;
307
+ } = data[selectedIndex] ? data[selectedIndex] : {};
280
308
 
281
309
  if (author) {
282
310
  authorHref = author.href;
@@ -285,7 +313,9 @@ export default class AttachmentViewer extends Component {
285
313
 
286
314
  const ariaId = this.getNextId();
287
315
  return /*#__PURE__*/React.createElement(FreezeLayer, {
288
- isActive: true
316
+ isActive: isActive && totalLen >= 1,
317
+ palette: "dark",
318
+ animationName: "expand"
289
319
  }, /*#__PURE__*/React.createElement(ResponsiveReceiver, {
290
320
  responsiveId: responsiveId,
291
321
  query: this.responsiveFunc
@@ -514,13 +544,15 @@ AttachmentViewer.propTypes = {
514
544
  needDownload: PropTypes.string,
515
545
  previewObj: PropTypes.object,
516
546
  responsiveId: PropTypes.string,
517
- maintainZoom: PropTypes.bool
547
+ maintainZoom: PropTypes.bool,
548
+ isActive: PropTypes.bool
518
549
  };
519
550
  AttachmentViewer.defaultProps = {
520
551
  responsiveId: "Helmet",
521
552
  needDownload: true,
522
553
  i18nKeys: {},
523
- maintainZoom: false
554
+ maintainZoom: false,
555
+ isActive: false
524
556
  };
525
557
 
526
558
  if (false) {
@@ -268,13 +268,13 @@
268
268
  cursor: zoom-in;
269
269
  }
270
270
 
271
- .normalImg {
271
+ .imgRef .normalImg {
272
272
  max-width: inherit;
273
273
  max-height: inherit;
274
274
  cursor: zoom-in;
275
275
  }
276
276
 
277
- .zoomedImg {
277
+ .imgRef .zoomedImg {
278
278
  max-width: initial;
279
279
  max-height: initial;
280
280
  cursor: zoom-out;
@@ -11,10 +11,10 @@ var _react = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
 
14
- var _AttachmentViewerModule = _interopRequireDefault(require("./AttachmentViewer.module.css"));
15
-
16
14
  var _Image = _interopRequireDefault(require("../Image/Image"));
17
15
 
16
+ var _AttachmentViewerModule = _interopRequireDefault(require("./AttachmentViewer.module.css"));
17
+
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
19
 
20
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -31,6 +31,8 @@ var _FreezeLayer = _interopRequireDefault(require("../FreezeLayer/FreezeLayer"))
31
31
 
32
32
  var _Attachment = require("./Attachment");
33
33
 
34
+ var _General = require("../utils/General");
35
+
34
36
  var _AttachmentViewerModule = _interopRequireDefault(require("./AttachmentViewer.module.css"));
35
37
 
36
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -107,6 +109,31 @@ var AttachmentViewer = /*#__PURE__*/function (_Component) {
107
109
  }
108
110
 
109
111
  _createClass(AttachmentViewer, [{
112
+ key: "componentDidUpdate",
113
+ value: function componentDidUpdate(prevProps) {
114
+ var previewObj = this.props.previewObj;
115
+ var indexChanged = previewObj.selectedIndex != prevProps.previewObj.selectedIndex;
116
+
117
+ if (previewObj.previewData.length != prevProps.previewObj.previewData.length || indexChanged) {
118
+ var objChanged = previewObj.previewData.some(function (value, index) {
119
+ return (0, _General.shallowDiff)(value, prevProps.previewObj[index]);
120
+ });
121
+
122
+ if (objChanged || indexChanged) {
123
+ this.setState({
124
+ selectedIndex: previewObj.selectedIndex,
125
+ data: previewObj ? previewObj.previewData : [],
126
+ dataList: this.getUpdateDataList({
127
+ index: previewObj.selectedIndex,
128
+ data: previewObj ? previewObj.previewData : [],
129
+ dataList: []
130
+ }),
131
+ isPViewListOpen: !!(this.props.previewObj && this.props.previewObj.previewData)
132
+ });
133
+ }
134
+ }
135
+ }
136
+ }, {
110
137
  key: "togglePViewList",
111
138
  value: function togglePViewList() {
112
139
  var _this2 = this;
@@ -344,7 +371,8 @@ var AttachmentViewer = /*#__PURE__*/function (_Component) {
344
371
  var _this$props = this.props,
345
372
  responsiveId = _this$props.responsiveId,
346
373
  needDownload = _this$props.needDownload,
347
- i18nKeys = _this$props.i18nKeys;
374
+ i18nKeys = _this$props.i18nKeys,
375
+ isActive = _this$props.isActive;
348
376
  var totalLen = data.length;
349
377
  var selectedAttachment = data[selectedIndex] || {};
350
378
  var selectedImgUrl = selectedAttachment.viewUrl;
@@ -352,7 +380,7 @@ var AttachmentViewer = /*#__PURE__*/function (_Component) {
352
380
  var authorHref;
353
381
  var authorName;
354
382
 
355
- var _ref3 = data[selectedIndex] ? data[selectedIndex] : null,
383
+ var _ref3 = data[selectedIndex] ? data[selectedIndex] : {},
356
384
  author = _ref3.author;
357
385
 
358
386
  if (author) {
@@ -362,7 +390,9 @@ var AttachmentViewer = /*#__PURE__*/function (_Component) {
362
390
 
363
391
  var ariaId = this.getNextId();
364
392
  return /*#__PURE__*/_react["default"].createElement(_FreezeLayer["default"], {
365
- isActive: true
393
+ isActive: isActive && totalLen >= 1,
394
+ palette: "dark",
395
+ animationName: "expand"
366
396
  }, /*#__PURE__*/_react["default"].createElement(_CustomResponsive.ResponsiveReceiver, {
367
397
  responsiveId: responsiveId,
368
398
  query: this.responsiveFunc
@@ -597,13 +627,15 @@ AttachmentViewer.propTypes = {
597
627
  needDownload: _propTypes["default"].string,
598
628
  previewObj: _propTypes["default"].object,
599
629
  responsiveId: _propTypes["default"].string,
600
- maintainZoom: _propTypes["default"].bool
630
+ maintainZoom: _propTypes["default"].bool,
631
+ isActive: _propTypes["default"].bool
601
632
  };
602
633
  AttachmentViewer.defaultProps = {
603
634
  responsiveId: "Helmet",
604
635
  needDownload: true,
605
636
  i18nKeys: {},
606
- maintainZoom: false
637
+ maintainZoom: false,
638
+ isActive: false
607
639
  };
608
640
 
609
641
  if (false) {
@@ -268,13 +268,13 @@
268
268
  cursor: zoom-in;
269
269
  }
270
270
 
271
- .normalImg {
271
+ .imgRef .normalImg {
272
272
  max-width: inherit;
273
273
  max-height: inherit;
274
274
  cursor: zoom-in;
275
275
  }
276
276
 
277
- .zoomedImg {
277
+ .imgRef .zoomedImg {
278
278
  max-width: initial;
279
279
  max-height: initial;
280
280
  cursor: zoom-out;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/dot",
3
- "version": "1.0.0-beta.218",
3
+ "version": "1.0.0-beta.220",
4
4
  "main": "lib/index",
5
5
  "module": "es/index.js",
6
6
  "jsnext:main": "es/index.js",