dtable-ui-component 0.1.84 → 0.1.85

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.
Files changed (115) hide show
  1. package/lib/DTablePopover/index.js +115 -0
  2. package/lib/DTablePopover/utils.js +5 -0
  3. package/lib/DTableSelect/index.js +140 -0
  4. package/lib/DTableSwitch/index.js +27 -0
  5. package/lib/FormulaFormatter/index.js +7 -7
  6. package/lib/index.js +5 -1
  7. package/package.json +2 -1
  8. package/es/app.css +0 -20
  9. package/es/app.js +0 -91
  10. package/es/assets/images/avatar/default_avatar.png +0 -0
  11. package/es/assets/images/file/192/excel.png +0 -0
  12. package/es/assets/images/file/192/file.png +0 -0
  13. package/es/assets/images/file/192/music.png +0 -0
  14. package/es/assets/images/file/192/pdf.png +0 -0
  15. package/es/assets/images/file/192/pic.png +0 -0
  16. package/es/assets/images/file/192/ppt.png +0 -0
  17. package/es/assets/images/file/192/txt.png +0 -0
  18. package/es/assets/images/file/192/video.png +0 -0
  19. package/es/assets/images/file/192/word.png +0 -0
  20. package/es/assets/images/file/24/excel.png +0 -0
  21. package/es/assets/images/file/24/file.png +0 -0
  22. package/es/assets/images/file/24/music.png +0 -0
  23. package/es/assets/images/file/24/pdf.png +0 -0
  24. package/es/assets/images/file/24/pic.png +0 -0
  25. package/es/assets/images/file/24/ppt.png +0 -0
  26. package/es/assets/images/file/24/txt.png +0 -0
  27. package/es/assets/images/file/24/video.png +0 -0
  28. package/es/assets/images/file/24/word.png +0 -0
  29. package/es/assets/images/folder/folder-192.png +0 -0
  30. package/es/assets/images/folder/folder-24.png +0 -0
  31. package/es/components/cell-editor/checkbox-editor.js +0 -104
  32. package/es/components/cell-editor/collaborator-editor.js +0 -236
  33. package/es/components/cell-editor/date-editor.js +0 -151
  34. package/es/components/cell-editor/index.js +0 -9
  35. package/es/components/cell-editor/link-editor.js +0 -303
  36. package/es/components/cell-editor/multiple-select-editor.js +0 -237
  37. package/es/components/cell-editor/number-editor.js +0 -154
  38. package/es/components/cell-editor/single-select-editor.js +0 -202
  39. package/es/components/cell-editor/text-editor.js +0 -122
  40. package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
  41. package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
  42. package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
  43. package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
  44. package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
  45. package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +0 -177
  46. package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
  47. package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
  48. package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
  49. package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
  50. package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
  51. package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
  52. package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
  53. package/es/components/cell-factory/cell-formatter-factory.js +0 -25
  54. package/es/components/cell-formatter/auto-number-formatter.js +0 -35
  55. package/es/components/cell-formatter/button-formatter.js +0 -55
  56. package/es/components/cell-formatter/checkbox-formatter.js +0 -44
  57. package/es/components/cell-formatter/collaborator-formatter.js +0 -91
  58. package/es/components/cell-formatter/creator-formatter.js +0 -87
  59. package/es/components/cell-formatter/ctime-formatter.js +0 -57
  60. package/es/components/cell-formatter/date-formatter.js +0 -59
  61. package/es/components/cell-formatter/duration-formatter.js +0 -37
  62. package/es/components/cell-formatter/email-formatter.js +0 -35
  63. package/es/components/cell-formatter/file-formatter.js +0 -63
  64. package/es/components/cell-formatter/formatter-config.js +0 -31
  65. package/es/components/cell-formatter/formula-formatter.js +0 -164
  66. package/es/components/cell-formatter/geolocation-formatter.js +0 -52
  67. package/es/components/cell-formatter/image-formatter.js +0 -153
  68. package/es/components/cell-formatter/index.js +0 -27
  69. package/es/components/cell-formatter/last-modifier-formatter.js +0 -87
  70. package/es/components/cell-formatter/link-formatter.js +0 -144
  71. package/es/components/cell-formatter/long-text-formatter.js +0 -106
  72. package/es/components/cell-formatter/mtime-formatter.js +0 -57
  73. package/es/components/cell-formatter/multiple-select-formatter.js +0 -69
  74. package/es/components/cell-formatter/number-formatter.js +0 -46
  75. package/es/components/cell-formatter/rate-formatter.js +0 -79
  76. package/es/components/cell-formatter/single-select-formatter.js +0 -69
  77. package/es/components/cell-formatter/text-formatter.js +0 -55
  78. package/es/components/cell-formatter/url-formatter.js +0 -35
  79. package/es/components/cell-formatter/widgets/file-item-formatter.js +0 -50
  80. package/es/components/cell-formatter/widgets/image-previewer-lightbox.js +0 -119
  81. package/es/components/common/collaborator-item.js +0 -63
  82. package/es/components/common/edit-editor-button.js +0 -56
  83. package/es/components/common/images-lazy-load.js +0 -150
  84. package/es/components/common/link-editor-option.js +0 -113
  85. package/es/components/common/mobile/mb-editor-header.js +0 -48
  86. package/es/components/common/modal-portal.js +0 -44
  87. package/es/components/common/select-editor-option.js +0 -106
  88. package/es/components/common/select-item.js +0 -58
  89. package/es/components/file-uploader/index.js +0 -53
  90. package/es/components/loading.js +0 -7
  91. package/es/components/toast/alert.js +0 -150
  92. package/es/components/toast/index.js +0 -3
  93. package/es/components/toast/toast.js +0 -179
  94. package/es/components/toast/toastManager.js +0 -170
  95. package/es/components/toast/toaster.js +0 -76
  96. package/es/constants/cell-types.js +0 -25
  97. package/es/constants/index.js +0 -48
  98. package/es/css/cell-editor.css +0 -614
  99. package/es/css/cell-formatter.css +0 -241
  100. package/es/css/custom-rc-calendar.css +0 -118
  101. package/es/css/image-previewer-ligntbox.css +0 -87
  102. package/es/css/loading.css +0 -54
  103. package/es/index.js +0 -6
  104. package/es/lang/index.js +0 -50
  105. package/es/locals/de.js +0 -2
  106. package/es/locals/en.js +0 -17
  107. package/es/locals/fr.js +0 -2
  108. package/es/locals/zh-CN.js +0 -17
  109. package/es/utils/cell-value-validator.js +0 -32
  110. package/es/utils/column-utils.js +0 -7
  111. package/es/utils/editor-utils.js +0 -71
  112. package/es/utils/normalize-long-text-value.js +0 -68
  113. package/es/utils/number-precision.js +0 -163
  114. package/es/utils/utils.js +0 -116
  115. package/es/utils/value-format-utils.js +0 -495
@@ -1,63 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import cn from 'astro-classname';
7
- import FileItemFormatter from './widgets/file-item-formatter';
8
-
9
- var FileFormatter = /*#__PURE__*/function (_React$PureComponent) {
10
- _inherits(FileFormatter, _React$PureComponent);
11
-
12
- var _super = _createSuper(FileFormatter);
13
-
14
- function FileFormatter() {
15
- _classCallCheck(this, FileFormatter);
16
-
17
- return _super.apply(this, arguments);
18
- }
19
-
20
- _createClass(FileFormatter, [{
21
- key: "render",
22
- value: function render() {
23
- var _this$props = this.props,
24
- isSample = _this$props.isSample,
25
- value = _this$props.value,
26
- containerClassName = _this$props.containerClassName;
27
- var className = cn('dtable-ui cell-formatter-container file-formatter', containerClassName);
28
-
29
- if (!Array.isArray(value) || value.length === 0) {
30
- return null;
31
- }
32
-
33
- if (isSample) {
34
- var item = value[0];
35
- return /*#__PURE__*/React.createElement("div", {
36
- className: className
37
- }, /*#__PURE__*/React.createElement(FileItemFormatter, {
38
- file: item
39
- }), value.length !== 1 && /*#__PURE__*/React.createElement("span", {
40
- className: "file-item-count"
41
- }, "+".concat(value.length)));
42
- }
43
-
44
- return /*#__PURE__*/React.createElement("div", {
45
- className: className
46
- }, value.map(function (item, index) {
47
- return /*#__PURE__*/React.createElement(FileItemFormatter, {
48
- file: item,
49
- key: index
50
- });
51
- }));
52
- }
53
- }]);
54
-
55
- return FileFormatter;
56
- }(React.PureComponent);
57
-
58
- FileFormatter.defaultProps = {
59
- isSample: false,
60
- value: [],
61
- containerClassName: ''
62
- };
63
- export default FileFormatter;
@@ -1,31 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
-
3
- var _FormatterConfig;
4
-
5
- import React from 'react';
6
- import * as CellTypes from '../../constants/cell-types';
7
- import CheckboxFormatter from './checkbox-formatter';
8
- import ImageFormatter from './image-formatter';
9
- import LongTextFormatter from './long-text-formatter';
10
- import TextCellFormatter from './text-formatter';
11
- import SingleSelectFormatter from './single-select-formatter';
12
- import MultipleSelectFormatter from './multiple-select-formatter';
13
- import FileFormatter from './file-formatter';
14
- import LinkFormatter from './link-formatter';
15
- import CollaboratorFormatter from './collaborator-formatter';
16
- import NumberFormatter from './number-formatter';
17
- import DateFormatter from './date-formatter';
18
- import CreatorFormatter from './creator-formatter';
19
- import CTimeFormatter from './ctime-formatter';
20
- import LastModifierFormatter from './last-modifier-formatter';
21
- import MTimeFormatter from './mtime-formatter';
22
- import GeolocationFormatter from './geolocation-formatter';
23
- import FormulaFormatter from './formula-formatter';
24
- import AutoNumberFormatter from './auto-number-formatter';
25
- import UrlFormatter from './url-formatter';
26
- import EmailFormatter from './email-formatter';
27
- import DurationFormatter from './duration-formatter';
28
- import RateFormatter from './rate-formatter';
29
- import ButtonFormatter from './button-formatter';
30
- var FormatterConfig = (_FormatterConfig = {}, _defineProperty(_FormatterConfig, CellTypes.DEFAULT, /*#__PURE__*/React.createElement(TextCellFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.TEXT, /*#__PURE__*/React.createElement(TextCellFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.CHECKBOX, /*#__PURE__*/React.createElement(CheckboxFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.LONG_TEXT, /*#__PURE__*/React.createElement(LongTextFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.SINGLE_SELECT, /*#__PURE__*/React.createElement(SingleSelectFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.IMAGE, /*#__PURE__*/React.createElement(ImageFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.FILE, /*#__PURE__*/React.createElement(FileFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.MULTIPLE_SELECT, /*#__PURE__*/React.createElement(MultipleSelectFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.COLLABORATOR, /*#__PURE__*/React.createElement(CollaboratorFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.NUMBER, /*#__PURE__*/React.createElement(NumberFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.DATE, /*#__PURE__*/React.createElement(DateFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.LINK, /*#__PURE__*/React.createElement(LinkFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.CREATOR, /*#__PURE__*/React.createElement(CreatorFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.CTIME, /*#__PURE__*/React.createElement(CTimeFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.LAST_MODIFIER, /*#__PURE__*/React.createElement(LastModifierFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.MTIME, /*#__PURE__*/React.createElement(MTimeFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.GEOLOCATION, /*#__PURE__*/React.createElement(GeolocationFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.FORMULA, /*#__PURE__*/React.createElement(FormulaFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.AUTO_NUMBER, /*#__PURE__*/React.createElement(AutoNumberFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.URL, /*#__PURE__*/React.createElement(UrlFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.EMAIL, /*#__PURE__*/React.createElement(EmailFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.DURATION, /*#__PURE__*/React.createElement(DurationFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.RATE, /*#__PURE__*/React.createElement(RateFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.BUTTON, /*#__PURE__*/React.createElement(ButtonFormatter, null)), _FormatterConfig);
31
- export default FormatterConfig;
@@ -1,164 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
- import React from 'react';
7
- import { FORMULA_RESULT_TYPE } from '../../constants';
8
- import cellFormatterFactory from '../cell-factory/cell-formatter-factory';
9
- import * as CellType from '../../constants/cell-types';
10
- import { isFunction } from '../../utils/utils';
11
- import TextFormatter from './text-formatter';
12
- import { isArrayFormalColumn, isSimpleCellFormatter } from '../../utils/column-utils';
13
- import cellValueValidator from '../../utils/cell-value-validator';
14
- import { getFormulaDisplayString } from '../../utils/value-format-utils';
15
-
16
- var FormulaFormatter = /*#__PURE__*/function (_React$Component) {
17
- _inherits(FormulaFormatter, _React$Component);
18
-
19
- var _super = _createSuper(FormulaFormatter);
20
-
21
- function FormulaFormatter() {
22
- var _this;
23
-
24
- _classCallCheck(this, FormulaFormatter);
25
-
26
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
27
- args[_key] = arguments[_key];
28
- }
29
-
30
- _this = _super.call.apply(_super, [this].concat(args));
31
-
32
- _this.getGridCellClassName = function (resultType) {
33
- switch (resultType) {
34
- case FORMULA_RESULT_TYPE.NUMBER:
35
- {
36
- return 'text-right';
37
- }
38
-
39
- default:
40
- {
41
- return '';
42
- }
43
- }
44
- };
45
-
46
- _this.renderOtherColumnFormatter = function () {
47
- var _this$props = _this.props,
48
- value = _this$props.value,
49
- column = _this$props.column,
50
- collaborators = _this$props.collaborators;
51
- var columnData = column.data;
52
- var array_type = columnData.array_type,
53
- array_data = columnData.array_data;
54
-
55
- if (!array_type || array_type === CellType.LINK) {
56
- return null;
57
- }
58
-
59
- var Formatter = cellFormatterFactory.createFormatter(array_type);
60
-
61
- var formatterProps = _this.getFormatterProps(array_type, array_data, collaborators);
62
-
63
- if (isArrayFormalColumn(array_type)) {
64
- formatterProps.value = value;
65
- return _this.createColumnFormatter(Formatter, formatterProps);
66
- }
67
-
68
- var _isSimpleCellFormatterColumn = isSimpleCellFormatter(array_type);
69
-
70
- var cellValue = value;
71
-
72
- if (!Array.isArray(value)) {
73
- cellValue = cellValueValidator(value, array_type) ? [value] : [];
74
- }
75
-
76
- var contentItemClassName = "formula-formatter-content-item ".concat(_isSimpleCellFormatterColumn ? 'simple-cell-formatter' : '');
77
- return /*#__PURE__*/React.createElement("div", {
78
- className: "dtable-ui formula-formatter multiple"
79
- }, cellValue.map(function (v, index) {
80
- formatterProps.value = v;
81
- return /*#__PURE__*/React.createElement("div", {
82
- className: contentItemClassName,
83
- key: "formula-formatter-content-item-".concat(index)
84
- }, _this.createColumnFormatter(Formatter, formatterProps));
85
- }));
86
- };
87
-
88
- _this.getFormatterProps = function (array_type, array_data, collaborators) {
89
- switch (array_type) {
90
- case CellType.DURATION:
91
- {
92
- var duration_format = array_data.duration_format;
93
- return {
94
- format: duration_format
95
- };
96
- }
97
-
98
- case CellType.NUMBER:
99
- case CellType.RATE:
100
- case CellType.GEOLOCATION:
101
- {
102
- return {
103
- data: array_data
104
- };
105
- }
106
-
107
- default:
108
- {
109
- return _objectSpread(_objectSpread({}, array_data), {}, {
110
- collaborators: collaborators
111
- });
112
- }
113
- }
114
- };
115
-
116
- return _this;
117
- }
118
-
119
- _createClass(FormulaFormatter, [{
120
- key: "createColumnFormatter",
121
- value: function createColumnFormatter(Formatter, formatterProps) {
122
- if (React.isValidElement(Formatter)) {
123
- return React.cloneElement(Formatter, _objectSpread({}, formatterProps));
124
- } else if (isFunction(Formatter)) {
125
- return /*#__PURE__*/React.createElement(Formatter, formatterProps);
126
- }
127
-
128
- return /*#__PURE__*/React.createElement(TextFormatter, formatterProps);
129
- }
130
- }, {
131
- key: "render",
132
- value: function render() {
133
- var _this$props2 = this.props,
134
- value = _this$props2.value,
135
- containerClassName = _this$props2.containerClassName,
136
- column = _this$props2.column,
137
- collaborators = _this$props2.collaborators;
138
- var columnData = column.data;
139
- var resultType = columnData.result_type;
140
-
141
- if (resultType === FORMULA_RESULT_TYPE.ARRAY) {
142
- return this.renderOtherColumnFormatter();
143
- }
144
-
145
- if (typeof value === 'object') {
146
- return null;
147
- }
148
-
149
- var gridCellClassName = this.getGridCellClassName(resultType);
150
- var formattedValue = getFormulaDisplayString(value, columnData, {
151
- collaborators: collaborators
152
- });
153
- return /*#__PURE__*/React.createElement("div", {
154
- className: "dtable-ui cell-formatter-container formula-formatter ".concat(containerClassName, " ").concat(gridCellClassName),
155
- title: formattedValue,
156
- "aria-label": formattedValue
157
- }, formattedValue);
158
- }
159
- }]);
160
-
161
- return FormulaFormatter;
162
- }(React.Component);
163
-
164
- export default FormulaFormatter;
@@ -1,52 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import cn from 'astro-classname';
7
- import { getGeolocationDisplayString } from '../../utils/value-format-utils';
8
-
9
- var GeolocationFormatter = /*#__PURE__*/function (_React$Component) {
10
- _inherits(GeolocationFormatter, _React$Component);
11
-
12
- var _super = _createSuper(GeolocationFormatter);
13
-
14
- function GeolocationFormatter() {
15
- _classCallCheck(this, GeolocationFormatter);
16
-
17
- return _super.apply(this, arguments);
18
- }
19
-
20
- _createClass(GeolocationFormatter, [{
21
- key: "render",
22
- value: function render() {
23
- var _this$props = this.props,
24
- value = _this$props.value,
25
- data = _this$props.data,
26
- containerClassName = _this$props.containerClassName;
27
- var className = cn('dtable-ui cell-formatter-container geolocation-formatter', containerClassName);
28
-
29
- if (typeof value !== 'object') {
30
- return null;
31
- }
32
-
33
- return /*#__PURE__*/React.createElement("div", {
34
- className: className
35
- }, getGeolocationDisplayString(value, data));
36
- }
37
- }]);
38
-
39
- return GeolocationFormatter;
40
- }(React.Component);
41
-
42
- GeolocationFormatter.defaultProps = {
43
- value: {
44
- province: '',
45
- city: '',
46
- district: '',
47
- detail: ''
48
- },
49
- data: {},
50
- containerClassName: ''
51
- };
52
- export default GeolocationFormatter;
@@ -1,153 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React, { Fragment } from 'react';
6
- import cn from 'astro-classname';
7
- import ImagesLazyLoad from '../common/images-lazy-load';
8
- import { getImageThumbnailUrl } from '../../utils/utils';
9
- import ImagePreviewerLightbox from './widgets/image-previewer-lightbox';
10
-
11
- var ImageFormatter = /*#__PURE__*/function (_React$Component) {
12
- _inherits(ImageFormatter, _React$Component);
13
-
14
- var _super = _createSuper(ImageFormatter);
15
-
16
- function ImageFormatter(props) {
17
- var _this;
18
-
19
- _classCallCheck(this, ImageFormatter);
20
-
21
- _this = _super.call(this, props);
22
-
23
- _this.onImageClick = function (index) {
24
- if (!_this.props.isSupportPreview) return;
25
-
26
- _this.setState({
27
- isPreviewImage: true,
28
- previewImageIndex: index
29
- });
30
- };
31
-
32
- _this.closeImagePopup = function () {
33
- if (!_this.props.isSupportPreview) return;
34
-
35
- _this.setState({
36
- isPreviewImage: false,
37
- previewImageIndex: -1
38
- });
39
- };
40
-
41
- _this.movePrev = function () {
42
- var images = _this.props.value;
43
-
44
- _this.setState(function (prevState) {
45
- return {
46
- previewImageIndex: (prevState.previewImageIndex + images.length - 1) % images.length
47
- };
48
- });
49
- };
50
-
51
- _this.moveNext = function () {
52
- var images = _this.props.value;
53
-
54
- _this.setState(function (prevState) {
55
- return {
56
- previewImageIndex: (prevState.previewImageIndex + 1) % images.length
57
- };
58
- });
59
- };
60
-
61
- _this.downloadImage = function (imageItemUrl) {
62
- if (!_this.props.downloadImage) return;
63
-
64
- _this.props.downloadImage(imageItemUrl);
65
- };
66
-
67
- _this.deleteImage = function (index) {
68
- var readOnly = _this.props.readOnly;
69
- if (readOnly) return;
70
- if (!_this.props.deleteImage) return;
71
-
72
- _this.props.deleteImage(index);
73
- };
74
-
75
- _this.onRotateImage = function (index, degree) {
76
- var readOnly = _this.props.readOnly;
77
- if (readOnly) return;
78
- if (!_this.props.rotateImage) return;
79
-
80
- _this.props.rotateImage(index, degree);
81
- };
82
-
83
- _this.state = {
84
- isPreviewImage: false,
85
- previewImageIndex: -1
86
- };
87
- return _this;
88
- }
89
-
90
- _createClass(ImageFormatter, [{
91
- key: "render",
92
- value: function render() {
93
- var _this$props = this.props,
94
- isSample = _this$props.isSample,
95
- value = _this$props.value,
96
- server = _this$props.server,
97
- containerClassName = _this$props.containerClassName,
98
- readOnly = _this$props.readOnly;
99
- var className = cn('dtable-ui cell-formatter-container image-formatter', containerClassName);
100
- var _this$state = this.state,
101
- isPreviewImage = _this$state.isPreviewImage,
102
- previewImageIndex = _this$state.previewImageIndex;
103
-
104
- if (!Array.isArray(value) || value.length === 0) {
105
- return null;
106
- }
107
-
108
- if (isSample) {
109
- var item = value[0];
110
- var url = getImageThumbnailUrl(item, server);
111
- return /*#__PURE__*/React.createElement("div", {
112
- className: className
113
- }, /*#__PURE__*/React.createElement("img", {
114
- className: "image-item",
115
- src: url,
116
- alt: ""
117
- }), value.length !== 1 && /*#__PURE__*/React.createElement("span", {
118
- className: "image-item-count"
119
- }, "+".concat(value.length)));
120
- }
121
-
122
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
123
- className: className
124
- }, /*#__PURE__*/React.createElement(ImagesLazyLoad, {
125
- images: value,
126
- server: server,
127
- onImageClick: this.onImageClick
128
- })), isPreviewImage && /*#__PURE__*/React.createElement(ImagePreviewerLightbox, {
129
- imageItems: value,
130
- imageIndex: previewImageIndex,
131
- closeImagePopup: this.closeImagePopup,
132
- moveToPrevImage: this.movePrev,
133
- moveToNextImage: this.moveNext,
134
- deleteImage: readOnly ? null : this.deleteImage,
135
- downloadImage: this.downloadImage,
136
- onRotateImage: readOnly ? null : this.onRotateImage,
137
- readOnly: readOnly
138
- }));
139
- }
140
- }]);
141
-
142
- return ImageFormatter;
143
- }(React.Component);
144
-
145
- ImageFormatter.defaultProps = {
146
- isSample: false,
147
- isSupportPreview: false,
148
- readOnly: true,
149
- value: [],
150
- server: '',
151
- containerClassName: ''
152
- };
153
- export default ImageFormatter;
@@ -1,27 +0,0 @@
1
- import '../../css/cell-formatter.css';
2
- export { default as TextFormatter } from './text-formatter';
3
- export { default as NumberFormatter } from './number-formatter';
4
- export { default as DateFormatter } from './date-formatter';
5
- export { default as CheckboxFormatter } from './checkbox-formatter';
6
- export { default as CollaboratorFormatter } from './collaborator-formatter';
7
- export { default as SingleSelectFormatter } from './single-select-formatter';
8
- export { default as MultipleSelectFormatter } from './multiple-select-formatter';
9
- export { default as LongTextFormatter } from './long-text-formatter';
10
- export { default as FileFormatter } from './file-formatter';
11
- export { default as ImageFormatter } from './image-formatter';
12
- export { default as GeolocationFormatter } from './geolocation-formatter';
13
- export { default as CTimeFormatter } from './ctime-formatter';
14
- export { default as CreatorFormatter } from './creator-formatter';
15
- export { default as LastModifierFormatter } from './last-modifier-formatter';
16
- export { default as MTimeFormatter } from './mtime-formatter';
17
- export { default as FormulaFormatter } from './formula-formatter';
18
- export { default as LinkFormatter } from './link-formatter';
19
- export { default as AutoNumberFormatter } from './auto-number-formatter';
20
- export { default as UrlFormatter } from './url-formatter';
21
- export { default as EmailFormatter } from './email-formatter';
22
- export { default as DurationFormatter } from './duration-formatter';
23
- export { default as RateFormatter } from './rate-formatter';
24
- export { default as ButtonFormatter } from './button-formatter';
25
- export { default as FileItemFormatter } from './widgets/file-item-formatter';
26
- export { default as ImagePreviewerLightbox } from './widgets/image-previewer-lightbox';
27
- export { default as CollaboratorItem } from '../common/collaborator-item';
@@ -1,87 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import cn from 'astro-classname';
7
- import ColloboratorItem from '../common/collaborator-item';
8
- import DefaultAvatar from '../../assets/images/avatar/default_avatar.png';
9
-
10
- // there will be there conditions
11
- // 1 value is not exist, typeof value is array, but it's length is 0
12
- // 2 value is exist, but can't find in collaborators
13
- // 3 value is exist, typeof value is a string
14
- // 4 vlaue is exist, typeof value is array
15
- var LastModifierFormatter = /*#__PURE__*/function (_React$PureComponent) {
16
- _inherits(LastModifierFormatter, _React$PureComponent);
17
-
18
- var _super = _createSuper(LastModifierFormatter);
19
-
20
- function LastModifierFormatter() {
21
- var _this;
22
-
23
- _classCallCheck(this, LastModifierFormatter);
24
-
25
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
- args[_key] = arguments[_key];
27
- }
28
-
29
- _this = _super.call.apply(_super, [this].concat(args));
30
-
31
- _this.getCollaborators = function () {
32
- var _this$props = _this.props,
33
- value = _this$props.value,
34
- collaborators = _this$props.collaborators;
35
-
36
- if (!Array.isArray(value)) {
37
- value = [value];
38
- }
39
-
40
- return value.map(function (item, index) {
41
- var collaborator = collaborators.find(function (collaborator) {
42
- return collaborator.email === item;
43
- }); // the collaborator can be not exist, beacuse the row modified by third app
44
-
45
- if (!collaborator) {
46
- collaborator = {
47
- name: item,
48
- avatar_url: DefaultAvatar
49
- };
50
- }
51
-
52
- ;
53
- return /*#__PURE__*/React.createElement(ColloboratorItem, {
54
- key: index,
55
- collaborator: collaborator
56
- });
57
- });
58
- };
59
-
60
- return _this;
61
- }
62
-
63
- _createClass(LastModifierFormatter, [{
64
- key: "render",
65
- value: function render() {
66
- var _this$props2 = this.props,
67
- containerClassName = _this$props2.containerClassName,
68
- value = _this$props2.value;
69
- var classname = cn('dtable-ui cell-formatter-container last-modified-formatter', containerClassName);
70
-
71
- if (!value || Array.isArray(value) && value.length === 0) {
72
- return /*#__PURE__*/React.createElement("div", {
73
- className: classname
74
- });
75
- }
76
-
77
- var collaborators = this.getCollaborators();
78
- return /*#__PURE__*/React.createElement("div", {
79
- className: classname
80
- }, collaborators);
81
- }
82
- }]);
83
-
84
- return LastModifierFormatter;
85
- }(React.PureComponent);
86
-
87
- export default LastModifierFormatter;