dtable-ui-component 0.3.6-beta.6 → 0.3.7-beta.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.
@@ -4,6 +4,7 @@ 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';
8
9
 
9
10
  var ButtonFormatter = /*#__PURE__*/function (_React$Component) {
@@ -36,24 +37,18 @@ var ButtonFormatter = /*#__PURE__*/function (_React$Component) {
36
37
  value: function render() {
37
38
  var _this$props = this.props,
38
39
  data = _this$props.data,
39
- containerClassName = _this$props.containerClassName,
40
- optionColors = _this$props.optionColors;
40
+ containerClassName = _this$props.containerClassName;
41
41
 
42
42
  var _ref = data || {},
43
43
  button_color = _ref.button_color,
44
44
  button_name = _ref.button_name;
45
45
 
46
- var colorOption = Array.isArray(optionColors) ? optionColors.find(function (item) {
46
+ var colorObj = SELECT_OPTION_COLORS.find(function (item) {
47
47
  return item.COLOR === button_color;
48
- }) || optionColors[0] : {
49
- COLOR: '#FFFCB5',
50
- BORDER_COLOR: '#E8E79D',
51
- TEXT_COLOR: '#666'
52
- };
48
+ }) || SELECT_OPTION_COLORS[0];
53
49
  var btnStyle = {
54
- backgroundColor: colorOption.COLOR,
55
- borderColor: colorOption.BORDER_COLOR,
56
- color: colorOption.TEXT_COLOR
50
+ backgroundColor: colorObj.COLOR,
51
+ borderColor: colorObj.BORDER_COLOR
57
52
  };
58
53
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", {
59
54
  className: classnames('dtable-ui cell-formatter-container button-formatter', containerClassName),
@@ -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,60 @@
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 RowExpandEmailFormatter = /*#__PURE__*/function (_React$Component) {
10
+ _inherits(RowExpandEmailFormatter, _React$Component);
11
+
12
+ var _super = _createSuper(RowExpandEmailFormatter);
13
+
14
+ function RowExpandEmailFormatter() {
15
+ var _this;
16
+
17
+ _classCallCheck(this, RowExpandEmailFormatter);
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.getTrimmedString = function () {
26
+ var value = _this.props.value;
27
+ return typeof value === 'string' ? value.trim() : '';
28
+ };
29
+
30
+ _this.onOpenEmailLink = function () {
31
+ var value = _this.props.value;
32
+ var newValue = value.trim();
33
+ window.location.href = "mailto:".concat(newValue);
34
+ };
35
+
36
+ return _this;
37
+ }
38
+
39
+ _createClass(RowExpandEmailFormatter, [{
40
+ key: "render",
41
+ value: function render() {
42
+ var _this$props = this.props,
43
+ containerClassName = _this$props.containerClassName,
44
+ value = _this$props.value;
45
+ var classname = classnames('dtable-ui cell-formatter-container email-formatter', containerClassName);
46
+ return /*#__PURE__*/React.createElement("div", {
47
+ className: classname
48
+ }, /*#__PURE__*/React.createElement("span", {
49
+ className: "email-formatter-value text-truncate"
50
+ }, value), this.getTrimmedString() && /*#__PURE__*/React.createElement("span", {
51
+ className: "dtable-font dtable-icon-email row-expand-jump-link",
52
+ onClick: this.onOpenEmailLink
53
+ }));
54
+ }
55
+ }]);
56
+
57
+ return RowExpandEmailFormatter;
58
+ }(React.Component);
59
+
60
+ export default RowExpandEmailFormatter;
@@ -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,
@@ -332,7 +338,7 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
332
338
  {
333
339
  return /*#__PURE__*/React.createElement("div", {
334
340
  className: "form-control d-flex align-items-center w-100"
335
- }, /*#__PURE__*/React.createElement(UrlFormatter, {
341
+ }, /*#__PURE__*/React.createElement(RowExpandUrlFormatter, {
336
342
  value: cellValue,
337
343
  containerClassName: containerClassName
338
344
  }));
@@ -342,7 +348,7 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
342
348
  {
343
349
  return /*#__PURE__*/React.createElement("div", {
344
350
  className: "form-control d-flex align-items-center w-100"
345
- }, /*#__PURE__*/React.createElement(EmailFormatter, {
351
+ }, /*#__PURE__*/React.createElement(RowExpandEmailFormatter, {
346
352
  value: cellValue,
347
353
  containerClassName: containerClassName
348
354
  }));
@@ -355,7 +361,10 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
355
361
  }
356
362
 
357
363
  return /*#__PURE__*/React.createElement("div", {
358
- className: "form-control d-flex align-items-center w-100"
364
+ className: "form-control d-flex align-items-center",
365
+ style: {
366
+ width: 320
367
+ }
359
368
  }, /*#__PURE__*/React.createElement(DurationFormatter, {
360
369
  value: cellValue,
361
370
  format: column.data.duration_format,
@@ -366,8 +375,11 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
366
375
  case CellType.RATE:
367
376
  {
368
377
  return /*#__PURE__*/React.createElement("div", {
369
- className: "form-control d-flex align-items-center w-100"
370
- }, /*#__PURE__*/React.createElement(RateFormatter, {
378
+ className: "form-control d-flex align-items-center",
379
+ style: {
380
+ width: 320
381
+ }
382
+ }, /*#__PURE__*/React.createElement(RowExpandRateFormatter, {
371
383
  value: cellValue,
372
384
  data: column.data,
373
385
  containerClassName: containerClassName
@@ -0,0 +1 @@
1
+ @import url('../css/cell-formatter.css');
@@ -0,0 +1,79 @@
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
+ RateExpendRateFormatter.defaultProps = {
77
+ editable: true
78
+ };
79
+ export default RateExpendRateFormatter;
@@ -0,0 +1 @@
1
+ @import url('../css/cell-formatter.css');
@@ -0,0 +1,79 @@
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 UrlFormatter = /*#__PURE__*/function (_React$Component) {
10
+ _inherits(UrlFormatter, _React$Component);
11
+
12
+ var _super = _createSuper(UrlFormatter);
13
+
14
+ function UrlFormatter() {
15
+ var _this;
16
+
17
+ _classCallCheck(this, UrlFormatter);
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.isValidUrl = function (url) {
26
+ var reg = /^(([-a-zA-Z0-9+.]+):\/\/)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/;
27
+ return reg.test(url);
28
+ };
29
+
30
+ _this.getTrimmedString = function () {
31
+ var value = _this.props.value;
32
+ return typeof value === 'string' ? value.trim() : '';
33
+ };
34
+
35
+ _this.onOpenUrlLink = function () {
36
+ var value = _this.props.value;
37
+
38
+ var url = _this.getTrimmedString(value);
39
+
40
+ var validUrl = _this.isValidUrl(url) ? url : "http://".concat(url);
41
+
42
+ try {
43
+ var a = document.createElement('a');
44
+ document.body.appendChild(a);
45
+ a.href = validUrl;
46
+ a.target = '_blank';
47
+ a.rel = 'noopener noreferrer';
48
+ a.click();
49
+ document.body.removeChild(a);
50
+ } catch (_unused) {
51
+ throw new Error('The url is invalid');
52
+ }
53
+ };
54
+
55
+ return _this;
56
+ }
57
+
58
+ _createClass(UrlFormatter, [{
59
+ key: "render",
60
+ value: function render() {
61
+ var _this$props = this.props,
62
+ containerClassName = _this$props.containerClassName,
63
+ value = _this$props.value;
64
+ var classname = classnames('dtable-ui cell-formatter-container url-formatter', containerClassName);
65
+ return /*#__PURE__*/React.createElement("div", {
66
+ className: classname
67
+ }, /*#__PURE__*/React.createElement("span", {
68
+ className: "url-formatter-value text-truncate"
69
+ }, value), this.getTrimmedString() && /*#__PURE__*/React.createElement("span", {
70
+ className: "dtable-font dtable-icon-url row-expand-jump-link",
71
+ onClick: this.onOpenUrlLink
72
+ }));
73
+ }
74
+ }]);
75
+
76
+ return UrlFormatter;
77
+ }(React.Component);
78
+
79
+ 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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "0.3.6-beta.6",
3
+ "version": "0.3.7-beta.1",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "dtable-utils": "0.0.2",