dtable-ui-component 0.1.75 → 0.1.79-beta

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 (163) hide show
  1. package/README.md +20 -2
  2. package/lib/AutoNumberFormatter/index.css +1 -0
  3. package/{es/components/cell-formatter/auto-number-formatter.js → lib/AutoNumberFormatter/index.js} +1 -0
  4. package/lib/ButtonFormatter/index.css +13 -0
  5. package/{es/components/cell-formatter/button-formatter.js → lib/ButtonFormatter/index.js} +1 -0
  6. package/lib/CTimeFormatter/index.css +1 -0
  7. package/{es/components/cell-formatter/ctime-formatter.js → lib/CTimeFormatter/index.js} +1 -0
  8. package/lib/CheckboxEditor/index.js +104 -0
  9. package/lib/CheckboxFormatter/index.css +1 -0
  10. package/{es/components/cell-formatter/checkbox-formatter.js → lib/CheckboxFormatter/index.js} +1 -0
  11. package/lib/CollaboratorEditor/index.css +48 -0
  12. package/lib/CollaboratorEditor/index.js +237 -0
  13. package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.css +86 -0
  14. package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +178 -0
  15. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.css +1 -0
  16. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +110 -0
  17. package/lib/CollaboratorFormatter/index.css +1 -0
  18. package/{es/components/cell-formatter/collaborator-formatter.js → lib/CollaboratorFormatter/index.js} +3 -2
  19. package/lib/CollaboratorItem/index.css +49 -0
  20. package/{es/components/common/collaborator-item.js → lib/CollaboratorItem/index.js} +1 -0
  21. package/lib/CreatorFormatter/index.css +1 -0
  22. package/{es/components/cell-formatter/creator-formatter.js → lib/CreatorFormatter/index.js} +3 -2
  23. package/lib/DateEditor/index.css +4 -0
  24. package/lib/DateEditor/index.js +152 -0
  25. package/{es/css → lib/DateEditor/mb-date-editor-popover}/custom-rc-calendar.css +0 -0
  26. package/lib/DateEditor/mb-date-editor-popover/index.css +45 -0
  27. package/lib/DateEditor/mb-date-editor-popover/index.js +245 -0
  28. package/lib/DateEditor/pc-date-editor-popover.js +142 -0
  29. package/lib/DateFormatter/index.css +1 -0
  30. package/{es/components/cell-formatter/date-formatter.js → lib/DateFormatter/index.js} +2 -1
  31. package/lib/DurationFormatter/index.css +1 -0
  32. package/{es/components/cell-formatter/duration-formatter.js → lib/DurationFormatter/index.js} +2 -1
  33. package/{es/components/common/edit-editor-button.js → lib/EditEditorButton/index.js} +0 -0
  34. package/lib/EmailFormatter/index.css +5 -0
  35. package/{es/components/cell-formatter/email-formatter.js → lib/EmailFormatter/index.js} +1 -0
  36. package/lib/FileEditor/index.js +46 -0
  37. package/lib/FileEditor/pc-files-addition/index.js +0 -0
  38. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -0
  39. package/lib/FileEditor/pc-files-preview/index.js +0 -0
  40. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -0
  41. package/lib/FileFormatter/index.css +29 -0
  42. package/{es/components/cell-formatter/file-formatter.js → lib/FileFormatter/index.js} +2 -1
  43. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/excel.png +0 -0
  44. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/file.png +0 -0
  45. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/music.png +0 -0
  46. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/pdf.png +0 -0
  47. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/pic.png +0 -0
  48. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/ppt.png +0 -0
  49. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/txt.png +0 -0
  50. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/video.png +0 -0
  51. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/word.png +0 -0
  52. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/excel.png +0 -0
  53. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/file.png +0 -0
  54. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/music.png +0 -0
  55. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/pdf.png +0 -0
  56. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/pic.png +0 -0
  57. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/ppt.png +0 -0
  58. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/txt.png +0 -0
  59. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/video.png +0 -0
  60. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/word.png +0 -0
  61. package/{es/assets/images → lib/FileItemFormatter/assets}/folder/folder-192.png +0 -0
  62. package/{es/assets/images → lib/FileItemFormatter/assets}/folder/folder-24.png +0 -0
  63. package/{es/components/cell-formatter/widgets/file-item-formatter.js → lib/FileItemFormatter/index.js} +2 -2
  64. package/lib/FileItemFormatter/utils.js +72 -0
  65. package/{es/components/file-uploader → lib/FileUploader}/index.js +0 -0
  66. package/{es/utils → lib/FormulaFormatter}/cell-value-validator.js +1 -2
  67. package/lib/FormulaFormatter/index.css +19 -0
  68. package/{es/components/cell-formatter/formula-formatter.js → lib/FormulaFormatter/index.js} +7 -8
  69. package/{es/utils/column-utils.js → lib/FormulaFormatter/utils.js} +5 -1
  70. package/lib/GeolocationFormatter/index.css +1 -0
  71. package/{es/components/cell-formatter/geolocation-formatter.js → lib/GeolocationFormatter/index.js} +2 -1
  72. package/lib/HtmlLongTextFormatter/index.css +63 -0
  73. package/{es/components/cell-formatter/widgets/long-text-formatter/html-long-text-formatter.js → lib/HtmlLongTextFormatter/index.js} +5 -2
  74. package/{es/utils → lib/HtmlLongTextFormatter}/markdown2html.js +2 -2
  75. package/{es/utils → lib/HtmlLongTextFormatter}/unified/index.js +8 -5
  76. package/{es/utils → lib/HtmlLongTextFormatter}/vfile/core.js +4 -2
  77. package/{es/utils → lib/HtmlLongTextFormatter}/vfile/index.js +4 -3
  78. package/{es/components/common → lib/ImageFormatter}/images-lazy-load.js +2 -2
  79. package/lib/ImageFormatter/index.css +34 -0
  80. package/{es/components/cell-formatter/image-formatter.js → lib/ImageFormatter/index.js} +4 -3
  81. package/lib/ImageFormatter/utils.js +7 -0
  82. package/{es/css/image-previewer-ligntbox.css → lib/ImagePreviewerLightbox/index.css} +0 -0
  83. package/{es/components/cell-formatter/widgets/image-previewer-lightbox.js → lib/ImagePreviewerLightbox/index.js} +3 -3
  84. package/lib/ImagePreviewerLightbox/utils.js +8 -0
  85. package/lib/LastModifierFormatter/index.css +1 -0
  86. package/{es/components/cell-formatter/last-modifier-formatter.js → lib/LastModifierFormatter/index.js} +5 -4
  87. package/lib/LinkEditor/index.css +9 -0
  88. package/lib/LinkEditor/index.js +304 -0
  89. package/{es/components/common → lib/LinkEditor}/link-editor-option.js +0 -0
  90. package/lib/LinkEditor/mb-link-editor-popover/index.css +85 -0
  91. package/lib/LinkEditor/mb-link-editor-popover/index.js +171 -0
  92. package/lib/LinkEditor/pc-link-editor-popover/index.css +63 -0
  93. package/lib/LinkEditor/pc-link-editor-popover/index.js +115 -0
  94. package/lib/LinkFormatter/index.css +27 -0
  95. package/{es/components/cell-formatter/link-formatter.js → lib/LinkFormatter/index.js} +2 -2
  96. package/{es/css/loading.css → lib/Loading/index.css} +0 -0
  97. package/{es/components/loading.js → lib/Loading/index.js} +1 -1
  98. package/{es/components/cell-formatter/long-text-formatter.js → lib/LongTextFormatter/index.js} +4 -6
  99. package/{es/components/common/mobile/mb-editor-header.js → lib/MBEditorHeader/index.js} +0 -0
  100. package/lib/MTimeFormatter/index.css +1 -0
  101. package/{es/components/cell-formatter/mtime-formatter.js → lib/MTimeFormatter/index.js} +1 -0
  102. package/{es/components/common/modal-portal.js → lib/ModalPortal/index.js} +0 -0
  103. package/lib/MultipleSelectEditor/index.css +9 -0
  104. package/lib/MultipleSelectEditor/index.js +236 -0
  105. package/lib/MultipleSelectFormatter/index.css +1 -0
  106. package/{es/components/cell-formatter/multiple-select-formatter.js → lib/MultipleSelectFormatter/index.js} +2 -1
  107. package/lib/NumberEditor/index.js +154 -0
  108. package/lib/NumberFormatter/index.css +1 -0
  109. package/{es/components/cell-formatter/number-formatter.js → lib/NumberFormatter/index.js} +2 -1
  110. package/lib/RateFormatter/index.css +1 -0
  111. package/{es/components/cell-formatter/rate-formatter.js → lib/RateFormatter/index.js} +1 -0
  112. package/{es/components/common/select-item.js → lib/SelectItem/index.js} +0 -0
  113. package/lib/SimpleLongTextFormatter/index.css +63 -0
  114. package/{es/components/cell-formatter/widgets/long-text-formatter/simple-long-text-formatter.js → lib/SimpleLongTextFormatter/index.js} +5 -2
  115. package/{es/utils → lib/SimpleLongTextFormatter}/normalize-long-text-value.js +3 -3
  116. package/lib/SingleSelectEditor/index.css +9 -0
  117. package/lib/SingleSelectEditor/index.js +201 -0
  118. package/lib/SingleSelectFormatter/index.css +1 -0
  119. package/{es/components/cell-formatter/single-select-formatter.js → lib/SingleSelectFormatter/index.js} +2 -1
  120. package/lib/TextEditor/index.js +122 -0
  121. package/lib/TextFormatter/index.css +1 -0
  122. package/{es/components/cell-formatter/text-formatter.js → lib/TextFormatter/index.js} +1 -0
  123. package/lib/UrlFormatter/index.css +5 -0
  124. package/{es/components/cell-formatter/url-formatter.js → lib/UrlFormatter/index.js} +1 -0
  125. package/{es → lib}/assets/images/avatar/default_avatar.png +0 -0
  126. package/{es/components/cell-factory/cell-formatter-factory.js → lib/cellFormatterFactory/index.js} +3 -3
  127. package/{es → lib}/constants/cell-types.js +0 -0
  128. package/lib/constants/index.js +49 -0
  129. package/lib/css/cell-editor.css +6 -0
  130. package/lib/css/cell-formatter.css +4 -0
  131. package/lib/css/mb-cell-editor.css +55 -0
  132. package/lib/formatterConfig/index.js +31 -0
  133. package/lib/index.js +44 -0
  134. package/{es → lib}/lang/index.js +0 -0
  135. package/{es → lib}/locals/de.js +0 -0
  136. package/{es → lib}/locals/en.js +0 -0
  137. package/{es → lib}/locals/fr.js +0 -0
  138. package/{es → lib}/locals/zh-CN.js +0 -0
  139. package/lib/select-editor/index.js +4 -0
  140. package/lib/select-editor/mb-select-editor-popover/index.css +127 -0
  141. package/lib/select-editor/mb-select-editor-popover/index.js +231 -0
  142. package/lib/select-editor/pc-select-editor-popover/index.css +72 -0
  143. package/lib/select-editor/pc-select-editor-popover/index.js +144 -0
  144. package/{es/components/common → lib/select-editor}/select-editor-option.js +0 -0
  145. package/{es/components/toast → lib/toaster}/alert.js +0 -0
  146. package/{es/components/toast → lib/toaster}/index.js +0 -0
  147. package/{es/components/toast → lib/toaster}/toast.js +0 -0
  148. package/{es/components/toast → lib/toaster}/toastManager.js +0 -0
  149. package/{es/components/toast → lib/toaster}/toaster.js +0 -0
  150. package/lib/utils/editor-utils.js +71 -0
  151. package/{es → lib}/utils/number-precision.js +1 -0
  152. package/lib/utils/utils.js +25 -0
  153. package/{es → lib}/utils/value-format-utils.js +7 -10
  154. package/package.json +8 -8
  155. package/es/app.css +0 -20
  156. package/es/app.js +0 -91
  157. package/es/components/cell-formatter/formatter-config.js +0 -31
  158. package/es/components/cell-formatter/index.js +0 -27
  159. package/es/constants/index.js +0 -48
  160. package/es/css/cell-editor.css +0 -614
  161. package/es/css/cell-formatter.css +0 -247
  162. package/es/index.js +0 -6
  163. package/es/utils/utils.js +0 -116
package/lib/index.js ADDED
@@ -0,0 +1,44 @@
1
+ // toaster
2
+ export { default as toaster } from './toaster'; // Loading
3
+
4
+ export { default as Loading } from './Loading';
5
+ export { setLocale } from './lang'; // utils
6
+
7
+ export { getDateDisplayString, getNumberDisplayString, formatStringToNumber, formatNumberString } from './utils/value-format-utils'; // formatter
8
+
9
+ export { default as CheckboxFormatter } from './CheckboxFormatter';
10
+ export { default as ImageFormatter } from './ImageFormatter';
11
+ export { default as LongTextFormatter } from './LongTextFormatter';
12
+ export { default as TextFormatter } from './TextFormatter';
13
+ export { default as SingleSelectFormatter } from './SingleSelectFormatter';
14
+ export { default as MultipleSelectFormatter } from './MultipleSelectFormatter';
15
+ export { default as SelectItem } from './SelectItem';
16
+ export { default as FileFormatter } from './FileFormatter';
17
+ export { default as LinkFormatter } from './LinkFormatter';
18
+ export { default as CollaboratorFormatter } from './CollaboratorFormatter';
19
+ export { default as NumberFormatter } from './NumberFormatter';
20
+ export { default as DateFormatter } from './DateFormatter';
21
+ export { default as CreatorFormatter } from './CreatorFormatter';
22
+ export { default as CTimeFormatter } from './CTimeFormatter';
23
+ export { default as LastModifierFormatter } from './LastModifierFormatter';
24
+ export { default as MTimeFormatter } from './MTimeFormatter';
25
+ export { default as GeolocationFormatter } from './GeolocationFormatter';
26
+ export { default as FormulaFormatter } from './FormulaFormatter';
27
+ export { default as AutoNumberFormatter } from './AutoNumberFormatter';
28
+ export { default as UrlFormatter } from './UrlFormatter';
29
+ export { default as EmailFormatter } from './EmailFormatter';
30
+ export { default as DurationFormatter } from './DurationFormatter';
31
+ export { default as RateFormatter } from './RateFormatter';
32
+ export { default as ButtonFormatter } from './ButtonFormatter';
33
+ export { default as ImagePreviewerLightbox } from './ImagePreviewerLightbox';
34
+ export { default as CollaboratorItem } from './CollaboratorItem';
35
+ export { default as FileItemFormatter } from './FileItemFormatter'; // editor
36
+
37
+ export { default as TextEditor } from './TextEditor';
38
+ export { default as NumberEditor } from './NumberEditor';
39
+ export { default as CheckboxEditor } from './CheckboxEditor';
40
+ export { default as SingleSelectEditor } from './SingleSelectEditor';
41
+ export { default as MultipleSelectEditor } from './MultipleSelectEditor';
42
+ export { default as CollaboratorEditor } from './CollaboratorEditor';
43
+ export { default as DateEditor } from './DateEditor';
44
+ export { default as LinkEditor } from './LinkEditor';
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ import MBSelectEditorPopover from './mb-select-editor-popover';
2
+ import PCSelectEditorPopover from './pc-select-editor-popover';
3
+ import SelectEditorOption from './select-editor-option';
4
+ export { MBSelectEditorPopover, PCSelectEditorPopover, SelectEditorOption };
@@ -0,0 +1,127 @@
1
+ @import url('../../css/mb-cell-editor.css');
2
+
3
+ @media screen and (max-width: 767.8px) {
4
+ .dtable-ui-mb-select-editor-body .mb-selected-item {
5
+ margin-top: 10px;
6
+ display: flex;
7
+ flex-direction: column;
8
+ }
9
+
10
+ .dtable-ui-mb-select-editor-body .mb-selected-item .title {
11
+ padding: 6px 16px;
12
+ border-bottom: 1px solid #e9e9e9;
13
+ }
14
+
15
+ .dtable-ui-mb-select-editor-body .mb-selected-item .content {
16
+ display: flex;
17
+ flex-wrap: wrap;
18
+ align-items: center;
19
+ min-height: 50px;
20
+ padding: 8px 16px;
21
+ border-bottom: 1px solid #e9e9e9;
22
+ overflow: auto;
23
+ background-color: #fff;
24
+ }
25
+
26
+ .dtable-ui-mb-select-editor-body .mb-selected-item .content .select-option-item {
27
+ margin: 3px 10px 3px 0;
28
+ }
29
+
30
+ .dtable-ui-mb-select-editor-body .mb-search-select-items {
31
+ padding: 8px 16px;
32
+ margin-top: 20px;
33
+ border-top: 1px solid #e9e9e9;
34
+ border-bottom: 1px solid #e9e9e9;
35
+ background-color: #fff;
36
+ }
37
+
38
+ .dtable-ui-mb-select-editor-body .mb-search-select-items > input {
39
+ outline: none;
40
+ height: 30px;
41
+ padding: 0;
42
+ line-height: 30px;
43
+ border: none;
44
+ }
45
+ .dtable-ui-mb-select-editor-body .mb-search-select-items > input:focus,
46
+ .dtable-ui-mb-select-editor-body .mb-search-select-items > input:active {
47
+ outline: none;
48
+ box-shadow: none;
49
+ }
50
+
51
+ .dtable-ui-mb-select-editor-body .mb-select-options-container {
52
+ display: flex;
53
+ flex-direction: column;
54
+ margin-top: 10px;
55
+ }
56
+
57
+ .dtable-ui-mb-select-editor-body .mb-select-options-container .title {
58
+ padding: 6px 16px;
59
+ border-bottom: 1px solid #e9e9e9;
60
+ }
61
+
62
+ .dtable-ui-mb-select-editor-body .mb-select-options-container .content {
63
+ display: flex;
64
+ flex-direction: column;
65
+ border-bottom: 1px solid #e9e9e9;
66
+ }
67
+
68
+ .dtable-ui-mb-select-editor-body .mb-select-options-container .search-result-none {
69
+ padding: 16px 0;
70
+ }
71
+
72
+ .dtable-ui-mb-select-editor-body .mb-select-options-container .mb-select-option-item {
73
+ display: flex;
74
+ align-items: center;
75
+ justify-content: space-between;
76
+ height: 50px;
77
+ padding: 10px 10px 10px 16px;
78
+ font-size: 13px;
79
+ background-color: #fff;
80
+ color: #202428;
81
+ }
82
+
83
+ .dtable-ui-mb-select-editor-body .mb-select-options-container .mb-select-option-item + .mb-select-option-item {
84
+ border-top: 1px solid #e9e9e9;
85
+ }
86
+
87
+ .dtable-ui-mb-select-editor-body .mb-select-options-container .mb-select-option-item .item-name {
88
+ display: inline-block;
89
+ padding: 0 10px;
90
+ margin-top: 5px;
91
+ height: 20px;
92
+ line-height: 20px;
93
+ text-align: center;
94
+ text-overflow: ellipsis;
95
+ border-radius: 10px;
96
+ overflow: hidden;
97
+ }
98
+
99
+ .dtable-ui-mb-select-editor-body .mb-select-options-container .mb-select-option-item .dtable-font {
100
+ font-size: 12px;
101
+ color: #798d99;
102
+ }
103
+
104
+ .dtable-ui-mb-select-editor-body .mb-create-select-item {
105
+ display: flex;
106
+ align-items: center;
107
+ height: 50px;
108
+ padding: 0 10px;
109
+ margin-top: 20px;
110
+ border-top: 1px solid #dedede;
111
+ border-bottom: 1px solid #e9e9e9;
112
+ background-color: #fff;
113
+ }
114
+
115
+ .dtable-ui-mb-select-editor-body .mb-create-select-item .dtable-font {
116
+ margin-right: 10px;
117
+ font-size: 12px;
118
+ font-weight: 600px;
119
+ transition: translateY(1px);
120
+ }
121
+
122
+ .dtable-ui-mb-select-editor-body .mb-create-select-item .add-new-option {
123
+ font-size: 14px;
124
+ font-weight: 500px;
125
+ }
126
+
127
+ }
@@ -0,0 +1,231 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
+ import React, { Fragment } from 'react';
7
+ import { getLocale } from '../../lang';
8
+ import SelectEditorOption from '../select-editor-option';
9
+ import MBEditorHeader from '../../MBEditorHeader';
10
+ import './index.css';
11
+
12
+ var MBSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
13
+ _inherits(MBSelectEditorPopover, _React$Component);
14
+
15
+ var _super = _createSuper(MBSelectEditorPopover);
16
+
17
+ function MBSelectEditorPopover(props) {
18
+ var _this;
19
+
20
+ _classCallCheck(this, MBSelectEditorPopover);
21
+
22
+ _this = _super.call(this, props);
23
+
24
+ _this.handleHistaryBack = function (e) {
25
+ e.preventDefault();
26
+
27
+ _this.props.onClosePopover();
28
+ };
29
+
30
+ _this.onContainerClick = function (event) {
31
+ if (_this.editorPopover && _this.editorPopover.contains(event.target)) {
32
+ event.stopPropagation();
33
+ event.nativeEvent.stopImmediatePropagation();
34
+ return false;
35
+ }
36
+ };
37
+
38
+ _this.onChangeSearch = function (event) {
39
+ var searchVal = _this.state.searchVal;
40
+
41
+ if (searchVal === event.target.value) {
42
+ return;
43
+ }
44
+
45
+ searchVal = event.target.value;
46
+
47
+ _this.setState({
48
+ searchVal: searchVal
49
+ });
50
+ };
51
+
52
+ _this.getSelectedOptions = function () {
53
+ var _this$props = _this.props,
54
+ value = _this$props.value,
55
+ options = _this$props.options;
56
+
57
+ if (!Array.isArray(value)) {
58
+ return [];
59
+ }
60
+
61
+ return options.filter(function (option) {
62
+ return value.indexOf(option.id) > -1;
63
+ });
64
+ };
65
+
66
+ _this.getFilteredOptions = function () {
67
+ var options = _this.props.options;
68
+ var searchVal = _this.state.searchVal;
69
+ return searchVal ? options.filter(function (item) {
70
+ return item.name.indexOf(searchVal) > -1;
71
+ }) : options;
72
+ };
73
+
74
+ _this.onSelectOption = function (option) {
75
+ _this.props.onOptionItemToggle(option);
76
+ };
77
+
78
+ _this.onAddNewOption = function (event) {
79
+ event.stopPropagation();
80
+ event.nativeEvent.stopImmediatePropagation();
81
+
82
+ var newOption = _this.state.searchVal.trim();
83
+
84
+ if (newOption) {
85
+ _this.props.onAddNewOption(newOption);
86
+
87
+ _this.props.onClosePopover();
88
+ }
89
+ };
90
+
91
+ _this.onRemoveOption = function (option) {
92
+ _this.props.onOptionItemToggle(option);
93
+ };
94
+
95
+ _this.renderSelectOptions = function (options) {
96
+ var value = _this.props.value;
97
+ return options.map(function (option, index) {
98
+ var isSelect = value.some(function (item) {
99
+ return item === option.id;
100
+ });
101
+ var style = {
102
+ backgroundColor: option.color,
103
+ color: option.textColor || null
104
+ };
105
+ return /*#__PURE__*/React.createElement("div", {
106
+ className: "mb-select-option-item",
107
+ key: index,
108
+ onMouseDown: _this.onSelectOption.bind(_assertThisInitialized(_this), option)
109
+ }, /*#__PURE__*/React.createElement("span", {
110
+ className: "mb-select-item"
111
+ }, /*#__PURE__*/React.createElement("span", {
112
+ className: "item-name",
113
+ style: style
114
+ }, option.name)), /*#__PURE__*/React.createElement("span", {
115
+ className: "mb-item-checked"
116
+ }, isSelect && /*#__PURE__*/React.createElement("i", {
117
+ className: "dtable-font dtable-icon-check-mark"
118
+ })));
119
+ });
120
+ };
121
+
122
+ _this.setEditorPopover = function (editorPopover) {
123
+ _this.editorPopover = editorPopover;
124
+ };
125
+
126
+ _this.state = {
127
+ searchVal: ''
128
+ };
129
+ return _this;
130
+ }
131
+
132
+ _createClass(MBSelectEditorPopover, [{
133
+ key: "componentDidMount",
134
+ value: function componentDidMount() {
135
+ history.pushState(null, null, '#'); // eslint-disable-line
136
+
137
+ window.addEventListener('popstate', this.handleHistaryBack, false);
138
+ }
139
+ }, {
140
+ key: "componentWillUnmount",
141
+ value: function componentWillUnmount() {
142
+ window.removeEventListener('popstate', this.handleHistaryBack, false);
143
+ }
144
+ }, {
145
+ key: "render",
146
+ value: function render() {
147
+ var _this2 = this;
148
+
149
+ var _this$props2 = this.props,
150
+ isReadOnly = _this$props2.isReadOnly,
151
+ column = _this$props2.column,
152
+ isSupportNewOption = _this$props2.isSupportNewOption,
153
+ isShowRemoveIcon = _this$props2.isShowRemoveIcon;
154
+ var searchVal = this.state.searchVal;
155
+ var selectedOptions = this.getSelectedOptions();
156
+ var filteredOptions = this.getFilteredOptions();
157
+ var isShowRemoveBtn = !isReadOnly && isShowRemoveIcon;
158
+ var isShowCreateBtn = !isReadOnly && isSupportNewOption && !!searchVal;
159
+
160
+ if (isShowCreateBtn) {
161
+ isShowCreateBtn = filteredOptions.length === 0;
162
+ }
163
+
164
+ return /*#__PURE__*/React.createElement("div", {
165
+ ref: this.setEditorPopover,
166
+ className: "dtable-ui-mb-editor-popover mb-select-editor-popover",
167
+ style: {
168
+ zIndex: 99
169
+ },
170
+ onClick: this.onContainerClick
171
+ }, /*#__PURE__*/React.createElement(MBEditorHeader, {
172
+ title: column.name,
173
+ leftContent: /*#__PURE__*/React.createElement("i", {
174
+ className: "dtable-font dtable-icon-return"
175
+ }),
176
+ onLeftClick: this.props.onClosePopover
177
+ }), /*#__PURE__*/React.createElement("div", {
178
+ className: "dtable-ui-mb-editor-body dtable-ui-mb-select-editor-body"
179
+ }, /*#__PURE__*/React.createElement("div", {
180
+ className: "mb-selected-item"
181
+ }, /*#__PURE__*/React.createElement("div", {
182
+ className: "title"
183
+ }, getLocale('Current_option')), /*#__PURE__*/React.createElement("div", {
184
+ className: "content"
185
+ }, selectedOptions.length === 0 && /*#__PURE__*/React.createElement("span", {
186
+ className: "empty-placeholder"
187
+ }, getLocale('No_option')), selectedOptions.length > 0 && selectedOptions.map(function (selectedOption) {
188
+ return /*#__PURE__*/React.createElement(SelectEditorOption, {
189
+ key: selectedOption.id,
190
+ option: selectedOption,
191
+ isShowRemoveIcon: isShowRemoveBtn,
192
+ onDeleteSelectOption: _this2.onRemoveOption
193
+ });
194
+ }))), /*#__PURE__*/React.createElement("div", {
195
+ className: "mb-search-select-items"
196
+ }, /*#__PURE__*/React.createElement("input", {
197
+ className: "form-control",
198
+ type: "text",
199
+ placeholder: getLocale('Find_an_option'),
200
+ value: searchVal,
201
+ onChange: this.onChangeSearch,
202
+ onClick: this.onInputClick
203
+ })), /*#__PURE__*/React.createElement("div", {
204
+ className: "mb-select-options-container"
205
+ }, /*#__PURE__*/React.createElement("div", {
206
+ className: "title"
207
+ }, /*#__PURE__*/React.createElement("span", null, getLocale('Choose_an_option'))), /*#__PURE__*/React.createElement("div", {
208
+ className: "content"
209
+ }, /*#__PURE__*/React.createElement(Fragment, null, filteredOptions.length === 0 && /*#__PURE__*/React.createElement("div", {
210
+ className: "search-result-none"
211
+ }, getLocale('No_options_available')), filteredOptions.length > 0 && this.renderSelectOptions(filteredOptions)))), isShowCreateBtn && /*#__PURE__*/React.createElement("div", {
212
+ className: "mb-create-select-item",
213
+ onClick: this.onAddNewOption
214
+ }, /*#__PURE__*/React.createElement("i", {
215
+ className: "dtable-font dtable-icon-add-table"
216
+ }), /*#__PURE__*/React.createElement("span", {
217
+ className: "add-new-option"
218
+ }, "".concat(getLocale('Add_an_option'), " ").concat(searchVal)))));
219
+ }
220
+ }]);
221
+
222
+ return MBSelectEditorPopover;
223
+ }(React.Component);
224
+
225
+ MBSelectEditorPopover.defaultProps = {
226
+ isReadOnly: false,
227
+ isShowRemoveIcon: false,
228
+ isSupportNewOption: false,
229
+ value: []
230
+ };
231
+ export default MBSelectEditorPopover;
@@ -0,0 +1,72 @@
1
+ @import url('../../css/cell-editor.css');
2
+
3
+ .dtable-ui-select-editor-popover .select-options-search {
4
+ padding: 10px 10px 0 10px;
5
+ }
6
+
7
+ .dtable-ui-select-editor-popover .select-options-search input {
8
+ height: 28px;
9
+ }
10
+
11
+ .dtable-ui-select-editor-popover .select-options-container {
12
+ min-height: 160px;
13
+ max-height: 200px;
14
+ margin: 10px 0;
15
+ padding: 0 10px;
16
+ overflow: auto;
17
+ }
18
+
19
+ /* option item */
20
+ .dtable-ui-select-editor-popover .select-option-item {
21
+ display: flex;
22
+ height: 30px;
23
+ padding-left: 12px;
24
+ font-size: 14px;
25
+ line-height: 30px;
26
+ margin-left: 10px;
27
+ cursor: pointer;
28
+ }
29
+
30
+ .dtable-ui-select-editor-popover .select-option-item:hover {
31
+ background-color: #f5f5f5;
32
+ }
33
+
34
+ .dtable-ui-select-editor-popover .option-info {
35
+ flex: 1;
36
+ display: flex;
37
+ align-items: center;
38
+ }
39
+
40
+ .dtable-ui-select-editor-popover .option-checked {
41
+ width: 20px;
42
+ text-align: center;
43
+ }
44
+
45
+ .dtable-ui-select-editor-popover .option-checked .dtable-font {
46
+ font-size: 12px;
47
+ color: #798d99;
48
+ }
49
+
50
+ .dtable-ui-select-editor-popover .select-options-add {
51
+ display: flex;
52
+ align-items: center;
53
+ padding: 0 10px;
54
+ height: 30px;
55
+ border-top: 1px solid #ccc;
56
+ }
57
+
58
+ .dtable-ui-select-editor-popover .select-options-add .dtable-font {
59
+ margin-right: 5px;
60
+ font-size: 12px;
61
+ font-weight: 600;
62
+ }
63
+
64
+ .dtable-ui-select-editor-popover .select-options-add > span {
65
+ display: inline-block;
66
+ font-size: 14px;
67
+ font-weight: 500;
68
+ color: #212529;
69
+ white-space: nowrap;
70
+ overflow: hidden;
71
+ text-overflow: ellipsis;
72
+ }
@@ -0,0 +1,144 @@
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 { getLocale } from '../../lang';
8
+ import './index.css';
9
+
10
+ var PCSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
11
+ _inherits(PCSelectEditorPopover, _React$Component);
12
+
13
+ var _super = _createSuper(PCSelectEditorPopover);
14
+
15
+ function PCSelectEditorPopover(props) {
16
+ var _this;
17
+
18
+ _classCallCheck(this, PCSelectEditorPopover);
19
+
20
+ _this = _super.call(this, props);
21
+
22
+ _this.onValueChanged = function (event) {
23
+ var value = event.target.value;
24
+
25
+ _this.setState({
26
+ searchValue: value
27
+ });
28
+ };
29
+
30
+ _this.onInputClick = function (event) {
31
+ event.nativeEvent.stopImmediatePropagation();
32
+ event.stopPropagation();
33
+ };
34
+
35
+ _this.onAddNewOption = function () {
36
+ var name = _this.state.searchValue.trim();
37
+
38
+ _this.props.onAddNewOption(name);
39
+ };
40
+
41
+ _this.onOptionItemToggle = function (item) {
42
+ _this.props.onOptionItemToggle(item);
43
+ };
44
+
45
+ _this.getFilterOptions = function () {
46
+ var options = _this.props.options;
47
+
48
+ var filter = _this.state.searchValue.toLowerCase();
49
+
50
+ if (!filter) {
51
+ return options;
52
+ }
53
+
54
+ return options.filter(function (option) {
55
+ return option.name.toString().toLowerCase().indexOf(filter) > -1;
56
+ });
57
+ };
58
+
59
+ _this.getOptionStyle = function (option) {
60
+ var textColor = option.textColor || null;
61
+ return {
62
+ display: 'inline-block',
63
+ padding: '0px 10px',
64
+ height: '20px',
65
+ lineHeight: '20px',
66
+ borderRadius: '10px',
67
+ fontSize: '13px',
68
+ backgroundColor: option.color,
69
+ color: textColor
70
+ };
71
+ };
72
+
73
+ _this.state = {
74
+ searchValue: ''
75
+ };
76
+ return _this;
77
+ }
78
+
79
+ _createClass(PCSelectEditorPopover, [{
80
+ key: "render",
81
+ value: function render() {
82
+ var _this2 = this;
83
+
84
+ var options = this.getFilterOptions();
85
+ var _this$props = this.props,
86
+ popoverPosition = _this$props.popoverPosition,
87
+ selectedOptions = _this$props.selectedOptions,
88
+ isSupportNewOption = _this$props.isSupportNewOption;
89
+ var searchValue = this.state.searchValue;
90
+ var popoverStyle = Object.assign({}, _objectSpread({}, popoverPosition), {
91
+ position: 'absolute'
92
+ });
93
+ return /*#__PURE__*/React.createElement("div", {
94
+ className: "dtable-ui-editor-popover dtable-ui-select-editor-popover",
95
+ style: popoverStyle
96
+ }, /*#__PURE__*/React.createElement("div", {
97
+ className: "select-options-search"
98
+ }, /*#__PURE__*/React.createElement("input", {
99
+ className: "form-control",
100
+ onChange: this.onValueChanged,
101
+ onClick: this.onInputClick,
102
+ placeholder: getLocale('Find_an_option')
103
+ })), /*#__PURE__*/React.createElement("div", {
104
+ className: "select-options-container"
105
+ }, options.length > 0 && options.map(function (option, index) {
106
+ var optionStyle = _this2.getOptionStyle(option);
107
+
108
+ var isSelect = selectedOptions.some(function (selectedOption) {
109
+ return selectedOption.id === option.id;
110
+ });
111
+ return /*#__PURE__*/React.createElement("div", {
112
+ key: index,
113
+ className: "select-option-item",
114
+ onClick: _this2.onOptionItemToggle.bind(_this2, option)
115
+ }, /*#__PURE__*/React.createElement("div", {
116
+ className: "option-info"
117
+ }, /*#__PURE__*/React.createElement("div", {
118
+ className: "option-name",
119
+ style: optionStyle
120
+ }, option.name)), /*#__PURE__*/React.createElement("div", {
121
+ className: "option-checked"
122
+ }, isSelect && /*#__PURE__*/React.createElement("i", {
123
+ className: "dtable-font dtable-icon-check-mark"
124
+ })));
125
+ }), options.length === 0 && /*#__PURE__*/React.createElement("div", {
126
+ className: "search-option-null"
127
+ }, getLocale('No_options_available'))), isSupportNewOption && !!searchValue && /*#__PURE__*/React.createElement("div", {
128
+ className: "select-options-add",
129
+ onClick: this.onAddNewOption
130
+ }, /*#__PURE__*/React.createElement("i", {
131
+ className: "dtable-font dtable-icon-add-table"
132
+ }), /*#__PURE__*/React.createElement("span", null, getLocale('Add_an_option'), ' ', searchValue)));
133
+ }
134
+ }]);
135
+
136
+ return PCSelectEditorPopover;
137
+ }(React.Component);
138
+
139
+ PCSelectEditorPopover.defaultProps = {
140
+ popoverPosition: {},
141
+ options: [],
142
+ isShowAddBtn: false
143
+ };
144
+ export default PCSelectEditorPopover;
File without changes
File without changes
File without changes
File without changes