dtable-ui-component 0.3.6 → 0.3.7-beta.2

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.
@@ -4,7 +4,9 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import classnames from 'classnames';
7
+ import { SELECT_OPTION_COLORS } from 'dtable-utils';
7
8
  import './index.css';
9
+ var WHITE = '#FFFFFF';
8
10
 
9
11
  var ButtonFormatter = /*#__PURE__*/function (_React$Component) {
10
12
  _inherits(ButtonFormatter, _React$Component);
@@ -36,24 +38,19 @@ var ButtonFormatter = /*#__PURE__*/function (_React$Component) {
36
38
  value: function render() {
37
39
  var _this$props = this.props,
38
40
  data = _this$props.data,
39
- containerClassName = _this$props.containerClassName,
40
- optionColors = _this$props.optionColors;
41
+ containerClassName = _this$props.containerClassName;
41
42
 
42
43
  var _ref = data || {},
43
44
  button_color = _ref.button_color,
44
45
  button_name = _ref.button_name;
45
46
 
46
- var colorOption = Array.isArray(optionColors) ? optionColors.find(function (item) {
47
+ var colorObj = SELECT_OPTION_COLORS.find(function (item) {
47
48
  return item.COLOR === button_color;
48
- }) || optionColors[0] : {
49
- COLOR: '#FFFCB5',
50
- BORDER_COLOR: '#E8E79D',
51
- TEXT_COLOR: '#666'
52
- };
49
+ }) || SELECT_OPTION_COLORS[0];
53
50
  var btnStyle = {
54
- backgroundColor: colorOption.COLOR,
55
- borderColor: colorOption.BORDER_COLOR,
56
- color: colorOption.TEXT_COLOR
51
+ backgroundColor: colorObj.COLOR,
52
+ borderColor: colorObj.BORDER_COLOR,
53
+ color: colorObj.TEXT_COLOR === WHITE ? WHITE : '#666666'
57
54
  };
58
55
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", {
59
56
  className: classnames('dtable-ui cell-formatter-container button-formatter', containerClassName),
@@ -20,7 +20,7 @@
20
20
  display: flex;
21
21
  align-items: center;
22
22
  justify-content: center;
23
- margin: 0 4px 0 2px;
23
+ margin: 0 5px 0 2px;
24
24
  }
25
25
 
26
26
  .dtable-ui.collaborator-item .collaborator-avatar img {
@@ -5,6 +5,10 @@
5
5
  margin-right: 10px;
6
6
  }
7
7
 
8
+ .dtable-ui.dtable-row-expand-formatter .formula-formatter-content-item {
9
+ margin-top: 0.5rem;
10
+ margin-bottom: 5px;
11
+ }
8
12
 
9
13
  .dtable-ui.formula-formatter.multiple .formula-formatter-content-item.simple-cell-formatter {
10
14
  height: 20px;
@@ -76,7 +76,4 @@ RateFormatter.defaultProps = {
76
76
  value: '',
77
77
  containerClassName: ''
78
78
  };
79
- RateFormatter.defaultProps = {
80
- editable: true
81
- };
82
79
  export default RateFormatter;
@@ -0,0 +1,30 @@
1
+ @import url('../css/cell-formatter.css');
2
+
3
+ .dtable-row-expand-formatter .dtable-ui.email-formatter .email-formatter-value,
4
+ .dtable-row-expand-formatter .dtable-ui.url-formatter .url-formatter-value {
5
+ text-decoration: underline;
6
+ width: 95%;
7
+ display: inline-flex;
8
+ }
9
+
10
+ .dtable-row-expand-formatter .dtable-ui .row-expand-jump-link {
11
+ display: inline-flex;
12
+ align-items: center;
13
+ font-size: 14px;
14
+ height: 22px;
15
+ position: absolute;
16
+ top: 8px;
17
+ right: 22px;
18
+ border: 1px solid #eee;
19
+ padding: 0 4px;
20
+ color: #999;
21
+ border-radius: 2px;
22
+ background: #fff;
23
+ cursor: pointer;
24
+ box-shadow: 0 0 1px;
25
+ }
26
+
27
+ .dtable-row-expand-formatter .dtable-ui .row-expand-jump-link:hover {
28
+ background: #eee;
29
+ border: 1px solid #c9c9c9;
30
+ }
@@ -0,0 +1,56 @@
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 classnames from 'classnames';
7
+ import { getTrimmedString } from '../utils/editor-utils';
8
+ import './index.css';
9
+
10
+ var RowExpandEmailFormatter = /*#__PURE__*/function (_React$Component) {
11
+ _inherits(RowExpandEmailFormatter, _React$Component);
12
+
13
+ var _super = _createSuper(RowExpandEmailFormatter);
14
+
15
+ function RowExpandEmailFormatter() {
16
+ var _this;
17
+
18
+ _classCallCheck(this, RowExpandEmailFormatter);
19
+
20
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
21
+ args[_key] = arguments[_key];
22
+ }
23
+
24
+ _this = _super.call.apply(_super, [this].concat(args));
25
+
26
+ _this.onOpenEmailLink = function () {
27
+ var value = _this.props.value;
28
+ var newValue = value.trim();
29
+ window.location.href = "mailto:".concat(newValue);
30
+ };
31
+
32
+ return _this;
33
+ }
34
+
35
+ _createClass(RowExpandEmailFormatter, [{
36
+ key: "render",
37
+ value: function render() {
38
+ var _this$props = this.props,
39
+ containerClassName = _this$props.containerClassName,
40
+ value = _this$props.value;
41
+ var classname = classnames('dtable-ui cell-formatter-container email-formatter', containerClassName);
42
+ return /*#__PURE__*/React.createElement("div", {
43
+ className: classname
44
+ }, /*#__PURE__*/React.createElement("span", {
45
+ className: "email-formatter-value text-truncate"
46
+ }, value), getTrimmedString(value) && /*#__PURE__*/React.createElement("span", {
47
+ className: "dtable-font dtable-icon-email row-expand-jump-link",
48
+ onClick: this.onOpenEmailLink
49
+ }));
50
+ }
51
+ }]);
52
+
53
+ return RowExpandEmailFormatter;
54
+ }(React.Component);
55
+
56
+ export default RowExpandEmailFormatter;
@@ -43,6 +43,9 @@
43
43
 
44
44
  .dtable-ui.dtable-row-expand-formatter .form-control {
45
45
  background-color: #f8f9fa;
46
+ padding: 0 10px;
47
+ height: fit-content;
48
+ min-height: 2.375rem;
46
49
  }
47
50
 
48
51
  .dtable-ui.dtable-row-expand-formatter .checkbox-formatter-container {
@@ -63,7 +66,7 @@
63
66
  }
64
67
 
65
68
  .dtable-ui.dtable-row-expand-formatter .geolocation-formatter-container {
66
- height: 38px;
69
+ margin-top: 0.5rem;
67
70
  display: flex;
68
71
  align-items: center;
69
72
  }
@@ -9,7 +9,7 @@ var _emptyTypeMap;
9
9
 
10
10
  import React from 'react';
11
11
  import classnames from 'classnames';
12
- import { TextFormatter, NumberFormatter, CheckboxFormatter, DateFormatter, SingleSelectFormatter, MultipleSelectFormatter, CollaboratorFormatter, LongTextFormatter, GeolocationFormatter, CTimeFormatter, CreatorFormatter, LastModifierFormatter, MTimeFormatter, AutoNumberFormatter, UrlFormatter, EmailFormatter, DurationFormatter, RateFormatter, ButtonFormatter, RowExpandImageFormatter, RowExpandFileFormatter, RowExpandLinkFormatter, DigitalSignFormatter, FormulaFormatter } from '../index';
12
+ import { TextFormatter, NumberFormatter, CheckboxFormatter, DateFormatter, SingleSelectFormatter, MultipleSelectFormatter, CollaboratorFormatter, LongTextFormatter, GeolocationFormatter, CTimeFormatter, CreatorFormatter, LastModifierFormatter, MTimeFormatter, AutoNumberFormatter, DurationFormatter, ButtonFormatter, RowExpandUrlFormatter, RowExpandEmailFormatter, RowExpandRateFormatter, RowExpandImageFormatter, RowExpandFileFormatter, RowExpandLinkFormatter, DigitalSignFormatter, FormulaFormatter } from '../index';
13
13
  import { CellType } from '../constants';
14
14
  import './index.css';
15
15
  var emptyTypeMap = (_emptyTypeMap = {}, _defineProperty(_emptyTypeMap, CellType.TEXT, true), _defineProperty(_emptyTypeMap, CellType.LONG_TEXT, true), _defineProperty(_emptyTypeMap, CellType.GEOLOCATION, true), _defineProperty(_emptyTypeMap, CellType.SINGLE_SELECT, true), _defineProperty(_emptyTypeMap, CellType.MULTIPLE_SELECT, true), _defineProperty(_emptyTypeMap, CellType.CTIME, true), _defineProperty(_emptyTypeMap, CellType.MTIME, true), _defineProperty(_emptyTypeMap, CellType.DATE, true), _defineProperty(_emptyTypeMap, CellType.AUTO_NUMBER, true), _defineProperty(_emptyTypeMap, CellType.URL, true), _defineProperty(_emptyTypeMap, CellType.EMAIL, true), _defineProperty(_emptyTypeMap, CellType.IMAGE, true), _defineProperty(_emptyTypeMap, CellType.FILE, true), _defineProperty(_emptyTypeMap, CellType.CREATOR, true), _defineProperty(_emptyTypeMap, CellType.LAST_MODIFIER, true), _emptyTypeMap);
@@ -147,7 +147,10 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
147
147
  }
148
148
 
149
149
  return /*#__PURE__*/React.createElement("div", {
150
- className: "form-control d-flex align-items-center w-100"
150
+ className: "form-control d-flex align-items-center",
151
+ style: {
152
+ width: 320
153
+ }
151
154
  }, /*#__PURE__*/React.createElement(NumberFormatter, {
152
155
  value: cellValue,
153
156
  data: column.data,
@@ -158,7 +161,10 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
158
161
  case CellType.DATE:
159
162
  {
160
163
  return /*#__PURE__*/React.createElement("div", {
161
- className: "form-control d-flex align-items-center w-100"
164
+ className: "form-control d-flex align-items-center",
165
+ style: {
166
+ width: 320
167
+ }
162
168
  }, /*#__PURE__*/React.createElement(DateFormatter, {
163
169
  value: cellValue,
164
170
  format: column.data.format,
@@ -173,7 +179,10 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
173
179
  }
174
180
 
175
181
  return /*#__PURE__*/React.createElement("div", {
176
- className: "form-control d-flex align-items-center w-100"
182
+ className: "form-control d-flex align-items-center",
183
+ style: {
184
+ width: 320
185
+ }
177
186
  }, /*#__PURE__*/React.createElement(CTimeFormatter, {
178
187
  value: row._ctime,
179
188
  containerClassName: containerClassName
@@ -187,7 +196,10 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
187
196
  }
188
197
 
189
198
  return /*#__PURE__*/React.createElement("div", {
190
- className: "form-control d-flex align-items-center w-100"
199
+ className: "form-control d-flex align-items-center",
200
+ style: {
201
+ width: 320
202
+ }
191
203
  }, /*#__PURE__*/React.createElement(MTimeFormatter, {
192
204
  value: row._mtime,
193
205
  containerClassName: containerClassName
@@ -332,7 +344,7 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
332
344
  {
333
345
  return /*#__PURE__*/React.createElement("div", {
334
346
  className: "form-control d-flex align-items-center w-100"
335
- }, /*#__PURE__*/React.createElement(UrlFormatter, {
347
+ }, /*#__PURE__*/React.createElement(RowExpandUrlFormatter, {
336
348
  value: cellValue,
337
349
  containerClassName: containerClassName
338
350
  }));
@@ -342,7 +354,7 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
342
354
  {
343
355
  return /*#__PURE__*/React.createElement("div", {
344
356
  className: "form-control d-flex align-items-center w-100"
345
- }, /*#__PURE__*/React.createElement(EmailFormatter, {
357
+ }, /*#__PURE__*/React.createElement(RowExpandEmailFormatter, {
346
358
  value: cellValue,
347
359
  containerClassName: containerClassName
348
360
  }));
@@ -355,7 +367,10 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
355
367
  }
356
368
 
357
369
  return /*#__PURE__*/React.createElement("div", {
358
- className: "form-control d-flex align-items-center w-100"
370
+ className: "form-control d-flex align-items-center",
371
+ style: {
372
+ width: 320
373
+ }
359
374
  }, /*#__PURE__*/React.createElement(DurationFormatter, {
360
375
  value: cellValue,
361
376
  format: column.data.duration_format,
@@ -366,8 +381,11 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
366
381
  case CellType.RATE:
367
382
  {
368
383
  return /*#__PURE__*/React.createElement("div", {
369
- className: "form-control d-flex align-items-center w-100"
370
- }, /*#__PURE__*/React.createElement(RateFormatter, {
384
+ className: "form-control d-flex align-items-center",
385
+ style: {
386
+ width: 320
387
+ }
388
+ }, /*#__PURE__*/React.createElement(RowExpandRateFormatter, {
371
389
  value: cellValue,
372
390
  data: column.data,
373
391
  containerClassName: containerClassName
@@ -0,0 +1 @@
1
+ @import url('../css/cell-formatter.css');
@@ -0,0 +1,76 @@
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 classnames from 'classnames';
7
+ import './index.css';
8
+
9
+ var RateExpendRateFormatter = /*#__PURE__*/function (_React$Component) {
10
+ _inherits(RateExpendRateFormatter, _React$Component);
11
+
12
+ var _super = _createSuper(RateExpendRateFormatter);
13
+
14
+ function RateExpendRateFormatter() {
15
+ var _this;
16
+
17
+ _classCallCheck(this, RateExpendRateFormatter);
18
+
19
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
20
+ args[_key] = arguments[_key];
21
+ }
22
+
23
+ _this = _super.call.apply(_super, [this].concat(args));
24
+
25
+ _this.getRateList = function () {
26
+ var _this$props = _this.props,
27
+ data = _this$props.data,
28
+ value = _this$props.value;
29
+
30
+ var _ref = data || {},
31
+ _ref$rate_max_number = _ref.rate_max_number,
32
+ rate_max_number = _ref$rate_max_number === void 0 ? 5 : _ref$rate_max_number,
33
+ _ref$rate_style_color = _ref.rate_style_color,
34
+ rate_style_color = _ref$rate_style_color === void 0 ? '#e5e5e5' : _ref$rate_style_color,
35
+ _ref$rate_style_type = _ref.rate_style_type,
36
+ rate_style_type = _ref$rate_style_type === void 0 ? 'dtable-icon-rate' : _ref$rate_style_type;
37
+
38
+ var rateList = [];
39
+
40
+ for (var i = 0; i < rate_max_number; i++) {
41
+ var style = {
42
+ color: value >= i + 1 ? rate_style_color : '#e5e5e5'
43
+ };
44
+ rateList.push( /*#__PURE__*/React.createElement("i", {
45
+ key: "dtable-ui-component-rate-".concat(i),
46
+ className: "dtable-font ".concat(rate_style_type),
47
+ style: style
48
+ }));
49
+ }
50
+
51
+ return rateList;
52
+ };
53
+
54
+ return _this;
55
+ }
56
+
57
+ _createClass(RateExpendRateFormatter, [{
58
+ key: "render",
59
+ value: function render() {
60
+ var containerClassName = this.props.containerClassName;
61
+ var className = classnames('dtable-ui cell-formatter-container rate-formatter', containerClassName);
62
+ var rateList = this.getRateList();
63
+ return /*#__PURE__*/React.createElement("div", {
64
+ className: className
65
+ }, rateList);
66
+ }
67
+ }]);
68
+
69
+ return RateExpendRateFormatter;
70
+ }(React.Component);
71
+
72
+ RateExpendRateFormatter.defaultProps = {
73
+ value: '',
74
+ containerClassName: ''
75
+ };
76
+ export default RateExpendRateFormatter;
@@ -0,0 +1 @@
1
+ @import url('../css/cell-formatter.css');
@@ -0,0 +1,69 @@
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 classnames from 'classnames';
7
+ import toaster from '../toaster';
8
+ import { isValidUrl, getTrimmedString } from '../utils/editor-utils';
9
+ import './index.css';
10
+
11
+ var UrlFormatter = /*#__PURE__*/function (_React$Component) {
12
+ _inherits(UrlFormatter, _React$Component);
13
+
14
+ var _super = _createSuper(UrlFormatter);
15
+
16
+ function UrlFormatter() {
17
+ var _this;
18
+
19
+ _classCallCheck(this, UrlFormatter);
20
+
21
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
22
+ args[_key] = arguments[_key];
23
+ }
24
+
25
+ _this = _super.call.apply(_super, [this].concat(args));
26
+
27
+ _this.onOpenUrlLink = function () {
28
+ var value = _this.props.value;
29
+ var url = getTrimmedString(value);
30
+ var validUrl = isValidUrl(url) ? url : "http://".concat(url);
31
+
32
+ try {
33
+ var a = document.createElement('a');
34
+ document.body.appendChild(a);
35
+ a.href = validUrl;
36
+ a.target = '_blank';
37
+ a.rel = 'noopener noreferrer';
38
+ a.click();
39
+ document.body.removeChild(a);
40
+ } catch (_unused) {
41
+ toaster.danger('The url is invalid');
42
+ }
43
+ };
44
+
45
+ return _this;
46
+ }
47
+
48
+ _createClass(UrlFormatter, [{
49
+ key: "render",
50
+ value: function render() {
51
+ var _this$props = this.props,
52
+ containerClassName = _this$props.containerClassName,
53
+ value = _this$props.value;
54
+ var classname = classnames('dtable-ui cell-formatter-container url-formatter', containerClassName);
55
+ return /*#__PURE__*/React.createElement("div", {
56
+ className: classname
57
+ }, /*#__PURE__*/React.createElement("span", {
58
+ className: "url-formatter-value text-truncate"
59
+ }, value), getTrimmedString(value) && /*#__PURE__*/React.createElement("span", {
60
+ className: "dtable-font dtable-icon-url row-expand-jump-link",
61
+ onClick: this.onOpenUrlLink
62
+ }));
63
+ }
64
+ }]);
65
+
66
+ return UrlFormatter;
67
+ }(React.Component);
68
+
69
+ export default UrlFormatter;
@@ -1,4 +1,5 @@
1
1
  .dtable-ui.cell-formatter-container {
2
2
  overflow: hidden;
3
3
  line-height: 1;
4
+ width: 100%;
4
5
  }
@@ -1,4 +1,3 @@
1
- import { CellType } from '../constants';
2
1
  var DTABLE_VALUE = {
3
2
  'tables': [{
4
3
  '_id': '0000',
package/lib/index.js CHANGED
@@ -37,6 +37,9 @@ export { default as SimpleLongTextFormatter } from './SimpleLongTextFormatter';
37
37
  export { default as RowExpandFileFormatter } from './RowExpandFileFormatter';
38
38
  export { default as RowExpandImageFormatter } from './RowExpandImageFormatter';
39
39
  export { default as RowExpandLinkFormatter } from './RowExpandLinkFormatter';
40
+ export { default as RowExpandRateFormatter } from './RowExpandRateFormatter';
41
+ export { default as RowExpandEmailFormatter } from './RowExpandEmailFormatter';
42
+ export { default as RowExpandUrlFormatter } from './RowExpandUrlFormatter';
40
43
  export { default as RowExpandFormatter } from './RowExpandFormatter'; // editor
41
44
 
42
45
  export { default as TextEditor } from './TextEditor';
@@ -68,4 +68,11 @@ export var getSelectOptionItem = function getSelectOptionItem(options, optionId)
68
68
  return options.find(function (option) {
69
69
  return option.id === optionId;
70
70
  });
71
+ };
72
+ export var isValidUrl = function isValidUrl(url) {
73
+ var reg = /^(([-a-zA-Z0-9+.]+):\/\/)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/;
74
+ return reg.test(url);
75
+ };
76
+ export var getTrimmedString = function getTrimmedString(value) {
77
+ return typeof value === 'string' ? value.trim() : '';
71
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "0.3.6",
3
+ "version": "0.3.7-beta.2",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "dtable-utils": "0.0.2",