dtable-ui-component 0.1.84 → 0.1.87

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 (124) hide show
  1. package/lib/DTableCustomizeCollaboratorSelect/index.css +124 -0
  2. package/lib/DTableCustomizeCollaboratorSelect/index.js +187 -0
  3. package/lib/DTableCustomizeCollaboratorSelect/utils.js +24 -0
  4. package/lib/DTableCustomizeSelect/index.js +155 -0
  5. package/lib/DTablePopover/index.js +115 -0
  6. package/lib/DTablePopover/utils.js +5 -0
  7. package/lib/DTableSearchInput/index.js +161 -0
  8. package/lib/DTableSearchInput/utils.js +4 -0
  9. package/lib/DTableSelect/index.js +141 -0
  10. package/lib/DTableSwitch/index.js +27 -0
  11. package/lib/SelectOptionGroup/KeyCodes.js +10 -0
  12. package/lib/SelectOptionGroup/index.js +217 -0
  13. package/lib/SelectOptionGroup/option.js +60 -0
  14. package/lib/assets/css/DTableCustomSelect.css +148 -0
  15. package/lib/index.js +8 -1
  16. package/package.json +2 -1
  17. package/es/app.css +0 -20
  18. package/es/app.js +0 -91
  19. package/es/assets/images/avatar/default_avatar.png +0 -0
  20. package/es/assets/images/file/192/excel.png +0 -0
  21. package/es/assets/images/file/192/file.png +0 -0
  22. package/es/assets/images/file/192/music.png +0 -0
  23. package/es/assets/images/file/192/pdf.png +0 -0
  24. package/es/assets/images/file/192/pic.png +0 -0
  25. package/es/assets/images/file/192/ppt.png +0 -0
  26. package/es/assets/images/file/192/txt.png +0 -0
  27. package/es/assets/images/file/192/video.png +0 -0
  28. package/es/assets/images/file/192/word.png +0 -0
  29. package/es/assets/images/file/24/excel.png +0 -0
  30. package/es/assets/images/file/24/file.png +0 -0
  31. package/es/assets/images/file/24/music.png +0 -0
  32. package/es/assets/images/file/24/pdf.png +0 -0
  33. package/es/assets/images/file/24/pic.png +0 -0
  34. package/es/assets/images/file/24/ppt.png +0 -0
  35. package/es/assets/images/file/24/txt.png +0 -0
  36. package/es/assets/images/file/24/video.png +0 -0
  37. package/es/assets/images/file/24/word.png +0 -0
  38. package/es/assets/images/folder/folder-192.png +0 -0
  39. package/es/assets/images/folder/folder-24.png +0 -0
  40. package/es/components/cell-editor/checkbox-editor.js +0 -104
  41. package/es/components/cell-editor/collaborator-editor.js +0 -236
  42. package/es/components/cell-editor/date-editor.js +0 -151
  43. package/es/components/cell-editor/index.js +0 -9
  44. package/es/components/cell-editor/link-editor.js +0 -303
  45. package/es/components/cell-editor/multiple-select-editor.js +0 -237
  46. package/es/components/cell-editor/number-editor.js +0 -154
  47. package/es/components/cell-editor/single-select-editor.js +0 -202
  48. package/es/components/cell-editor/text-editor.js +0 -122
  49. package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
  50. package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
  51. package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
  52. package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
  53. package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
  54. package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +0 -177
  55. package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
  56. package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
  57. package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
  58. package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
  59. package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
  60. package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
  61. package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
  62. package/es/components/cell-factory/cell-formatter-factory.js +0 -25
  63. package/es/components/cell-formatter/auto-number-formatter.js +0 -35
  64. package/es/components/cell-formatter/button-formatter.js +0 -55
  65. package/es/components/cell-formatter/checkbox-formatter.js +0 -44
  66. package/es/components/cell-formatter/collaborator-formatter.js +0 -91
  67. package/es/components/cell-formatter/creator-formatter.js +0 -87
  68. package/es/components/cell-formatter/ctime-formatter.js +0 -57
  69. package/es/components/cell-formatter/date-formatter.js +0 -59
  70. package/es/components/cell-formatter/duration-formatter.js +0 -37
  71. package/es/components/cell-formatter/email-formatter.js +0 -35
  72. package/es/components/cell-formatter/file-formatter.js +0 -63
  73. package/es/components/cell-formatter/formatter-config.js +0 -31
  74. package/es/components/cell-formatter/formula-formatter.js +0 -164
  75. package/es/components/cell-formatter/geolocation-formatter.js +0 -52
  76. package/es/components/cell-formatter/image-formatter.js +0 -153
  77. package/es/components/cell-formatter/index.js +0 -27
  78. package/es/components/cell-formatter/last-modifier-formatter.js +0 -87
  79. package/es/components/cell-formatter/link-formatter.js +0 -144
  80. package/es/components/cell-formatter/long-text-formatter.js +0 -106
  81. package/es/components/cell-formatter/mtime-formatter.js +0 -57
  82. package/es/components/cell-formatter/multiple-select-formatter.js +0 -69
  83. package/es/components/cell-formatter/number-formatter.js +0 -46
  84. package/es/components/cell-formatter/rate-formatter.js +0 -79
  85. package/es/components/cell-formatter/single-select-formatter.js +0 -69
  86. package/es/components/cell-formatter/text-formatter.js +0 -55
  87. package/es/components/cell-formatter/url-formatter.js +0 -35
  88. package/es/components/cell-formatter/widgets/file-item-formatter.js +0 -50
  89. package/es/components/cell-formatter/widgets/image-previewer-lightbox.js +0 -119
  90. package/es/components/common/collaborator-item.js +0 -63
  91. package/es/components/common/edit-editor-button.js +0 -56
  92. package/es/components/common/images-lazy-load.js +0 -150
  93. package/es/components/common/link-editor-option.js +0 -113
  94. package/es/components/common/mobile/mb-editor-header.js +0 -48
  95. package/es/components/common/modal-portal.js +0 -44
  96. package/es/components/common/select-editor-option.js +0 -106
  97. package/es/components/common/select-item.js +0 -58
  98. package/es/components/file-uploader/index.js +0 -53
  99. package/es/components/loading.js +0 -7
  100. package/es/components/toast/alert.js +0 -150
  101. package/es/components/toast/index.js +0 -3
  102. package/es/components/toast/toast.js +0 -179
  103. package/es/components/toast/toastManager.js +0 -170
  104. package/es/components/toast/toaster.js +0 -76
  105. package/es/constants/cell-types.js +0 -25
  106. package/es/constants/index.js +0 -48
  107. package/es/css/cell-editor.css +0 -614
  108. package/es/css/cell-formatter.css +0 -241
  109. package/es/css/custom-rc-calendar.css +0 -118
  110. package/es/css/image-previewer-ligntbox.css +0 -87
  111. package/es/css/loading.css +0 -54
  112. package/es/index.js +0 -6
  113. package/es/lang/index.js +0 -50
  114. package/es/locals/de.js +0 -2
  115. package/es/locals/en.js +0 -17
  116. package/es/locals/fr.js +0 -2
  117. package/es/locals/zh-CN.js +0 -17
  118. package/es/utils/cell-value-validator.js +0 -32
  119. package/es/utils/column-utils.js +0 -7
  120. package/es/utils/editor-utils.js +0 -71
  121. package/es/utils/normalize-long-text-value.js +0 -68
  122. package/es/utils/number-precision.js +0 -163
  123. package/es/utils/utils.js +0 -116
  124. package/es/utils/value-format-utils.js +0 -495
@@ -0,0 +1,124 @@
1
+ .dtable-customize-collaborator-select.dtable-select {
2
+ position: unset;
3
+ }
4
+
5
+ .dtable-customize-collaborator-select .collaborator-avatar {
6
+ width: 16px;
7
+ height: 16px;
8
+ transform: translateY(-1px);
9
+ }
10
+
11
+ .dtable-customize-collaborator-select .option-group {
12
+ position: absolute;
13
+ left: 0px;
14
+ min-height: 60px;
15
+ max-height: unset;
16
+ min-width: 100%;
17
+ max-width: 15rem;
18
+ padding: 0.5rem 0;
19
+ box-shadow: 0 1px 2px 0 rgb(0 0 0 / 5%);
20
+ background: #fff;
21
+ border: 1px solid rgba(0,40,100,.12);
22
+ border-radius: 3px;
23
+ z-index: 10001;
24
+ }
25
+
26
+ .dtable-customize-collaborator-select .option-group .option-group-search {
27
+ width: 100%;
28
+ padding: 0 10px;
29
+ min-width: 170px;
30
+ }
31
+
32
+ .dtable-customize-collaborator-select .option-group-search .form-control {
33
+ height: 31px;
34
+ }
35
+
36
+ .dtable-customize-collaborator-select .option-group .none-search-result {
37
+ height: 100px;
38
+ width: 100%;
39
+ padding: 10px;
40
+ opacity: .5;
41
+ }
42
+
43
+ .dtable-customize-collaborator-select .option-group .option-group-content {
44
+ max-height: 252px;
45
+ overflow-y: auto;
46
+ padding: 10px;
47
+ }
48
+
49
+ .dtable-customize-collaborator-select .selected-option-show {
50
+ width: calc(100% - 20px);
51
+ height: 20px;
52
+ }
53
+
54
+ .dtable-customize-collaborator-select .selected-option {
55
+ width: auto;
56
+ overflow-x: auto;
57
+ }
58
+
59
+ .dtable-customize-collaborator-select .dtable-icon-drop-down {
60
+ margin-left: .5rem;
61
+ }
62
+
63
+ .dtable-customize-collaborator-select .option-collaborator {
64
+ display: flex;
65
+ }
66
+
67
+ .dtable-customize-collaborator-select .collaborator-container {
68
+ flex: 1 1;
69
+ }
70
+
71
+ .dtable-customize-collaborator-select .editor-list-delete .collaborator-container {
72
+ flex: 1 1;
73
+ display: inline;
74
+ }
75
+
76
+ .dtable-customize-collaborator-select .multiple-check-icon {
77
+ display: inline-flex;
78
+ width: 20px;
79
+ text-align: center;
80
+ }
81
+
82
+ .dtable-customize-collaborator-select .collaborator-check-icon .dtable-icon-check-mark,
83
+ .dtable-customize-collaborator-select .multiple-check-icon .dtable-icon-check-mark {
84
+ font-size: 12px;
85
+ color: #798d99;
86
+ }
87
+
88
+ .dtable-customize-collaborator-select.dtable-select .option-active,
89
+ .dtable-customize-collaborator-select.dtable-select .option:hover {
90
+ color: #212529;
91
+ background-color: #f7f7f7;
92
+ }
93
+
94
+ .dtable-customize-collaborator-select.dtable-select .option.option-active .select-option-name {
95
+ color: #202428;
96
+ }
97
+
98
+ .collaborator-select .option-group-content .collaborator,
99
+ .dtable-customize-collaborator-select .option-group .option-group-content .collaborator {
100
+ background: none;
101
+ }
102
+
103
+ .dtable-customize-collaborator-select .collaborator-avatar-container {
104
+ width: 16px;
105
+ }
106
+
107
+ .dtable-customize-collaborator-select .option-group-content .remove-container {
108
+ display: none;
109
+ }
110
+
111
+ .dtable-customize-collaborator-select .collaborator-container {
112
+ display: flex;
113
+ justify-content: space-between;
114
+ }
115
+
116
+ .collaborator-container .collaborator-name {
117
+ margin-left: 5px;
118
+ max-width: 200px;
119
+ color: #212529;
120
+ }
121
+
122
+ .collaborator-select .option-group {
123
+ max-height: fit-content;
124
+ }
@@ -0,0 +1,187 @@
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, { Component } from 'react';
6
+ import classnames from 'classnames';
7
+ import { Popover } from 'reactstrap';
8
+ import SelectOptionGroup from '../SelectOptionGroup';
9
+ import { searchCollaborators } from './utils';
10
+ import './index.css';
11
+
12
+ var CollaboratorSelect = /*#__PURE__*/function (_Component) {
13
+ _inherits(CollaboratorSelect, _Component);
14
+
15
+ var _super = _createSuper(CollaboratorSelect);
16
+
17
+ function CollaboratorSelect(props) {
18
+ var _this;
19
+
20
+ _classCallCheck(this, CollaboratorSelect);
21
+
22
+ _this = _super.call(this, props);
23
+
24
+ _this.onSelectToggle = function (event) {
25
+ event.preventDefault();
26
+ /*
27
+ if select is showing, click events do not need to be monitored by other click events,
28
+ so it can be closed when other select is clicked.
29
+ */
30
+
31
+ if (_this.state.isShowSelectOptions) event.nativeEvent.stopImmediatePropagation();
32
+ var eventClassName = event.target.className;
33
+ if (_this.props.isLocked || eventClassName.indexOf('option-search-control') > -1 || eventClassName === 'option-group-search') return; //Prevent closing by pressing the spacebar in the search input
34
+
35
+ if (event.target.value === '') return;
36
+ _this.selectedOptionWidth = _this.selectedOptionRef.clientWidth;
37
+
38
+ _this.setState({
39
+ isShowSelectOptions: !_this.state.isShowSelectOptions
40
+ });
41
+ };
42
+
43
+ _this.onClick = function (event) {
44
+ var name = event.target.className;
45
+
46
+ if (name === 'select-placeholder' || name.includes('icon-fork-number')) {
47
+ return;
48
+ }
49
+
50
+ if (!_this.selector.contains(event.target)) {
51
+ _this.closeSelect();
52
+ }
53
+ };
54
+
55
+ _this.closeSelect = function () {
56
+ _this.setState({
57
+ isShowSelectOptions: false
58
+ });
59
+ };
60
+
61
+ _this.getFilterOptions = function (searchValue) {
62
+ var _this$props = _this.props,
63
+ options = _this$props.options,
64
+ searchable = _this$props.searchable;
65
+ if (!searchable) return options || [];
66
+ return searchCollaborators(options, searchValue);
67
+ };
68
+
69
+ _this.renderOptionGroup = function () {
70
+ var _this$props2 = _this.props,
71
+ value = _this$props2.value,
72
+ options = _this$props2.options,
73
+ searchable = _this$props2.searchable,
74
+ searchPlaceholder = _this$props2.searchPlaceholder,
75
+ noOptionsPlaceholder = _this$props2.noOptionsPlaceholder,
76
+ top = _this$props2.top,
77
+ left = _this$props2.left,
78
+ isUsePopover = _this$props2.isUsePopover;
79
+
80
+ if (!isUsePopover) {
81
+ return /*#__PURE__*/React.createElement(SelectOptionGroup, {
82
+ value: value,
83
+ top: top,
84
+ left: left,
85
+ minWidth: _this.btnWidth + 8 // 8px is padding
86
+ ,
87
+ options: options,
88
+ onSelectOption: _this.props.onSelectOption,
89
+ searchable: searchable,
90
+ searchPlaceholder: searchPlaceholder,
91
+ noOptionsPlaceholder: noOptionsPlaceholder,
92
+ closeSelect: _this.closeSelect,
93
+ getFilterOptions: _this.getFilterOptions,
94
+ supportMultipleSelect: _this.props.supportMultipleSelect,
95
+ stopClickEvent: true,
96
+ isShowSelected: true
97
+ });
98
+ }
99
+
100
+ return /*#__PURE__*/React.createElement(Popover, {
101
+ placement: "bottom",
102
+ isOpen: true,
103
+ target: _this.id,
104
+ fade: false,
105
+ hideArrow: true,
106
+ className: "dtable-customize-collaborator-select dtable-select"
107
+ }, /*#__PURE__*/React.createElement(SelectOptionGroup, {
108
+ value: value,
109
+ top: top,
110
+ left: left,
111
+ minWidth: _this.btnWidth + 8 // 8px is padding
112
+ ,
113
+ options: options,
114
+ onSelectOption: _this.props.onSelectOption,
115
+ searchable: searchable,
116
+ searchPlaceholder: searchPlaceholder,
117
+ noOptionsPlaceholder: noOptionsPlaceholder,
118
+ closeSelect: _this.closeSelect,
119
+ getFilterOptions: _this.getFilterOptions,
120
+ supportMultipleSelect: _this.props.supportMultipleSelect,
121
+ stopClickEvent: true,
122
+ isShowSelected: true
123
+ }));
124
+ };
125
+
126
+ _this.state = {
127
+ isShowSelectOptions: false
128
+ };
129
+ _this.id = 'collaborator-select-' + Math.trunc(Math.random() * 10000);
130
+ return _this;
131
+ }
132
+
133
+ _createClass(CollaboratorSelect, [{
134
+ key: "componentDidMount",
135
+ value: function componentDidMount() {
136
+ document.addEventListener('click', this.onClick);
137
+ this.btnWidth = this.selector.clientWidth;
138
+ }
139
+ }, {
140
+ key: "componentWillUnmount",
141
+ value: function componentWillUnmount() {
142
+ document.removeEventListener('click', this.onClick);
143
+ }
144
+ }, {
145
+ key: "render",
146
+ value: function render() {
147
+ var _this2 = this;
148
+
149
+ var _this$props3 = this.props,
150
+ className = _this$props3.className,
151
+ value = _this$props3.value,
152
+ placeholder = _this$props3.placeholder,
153
+ isLocked = _this$props3.isLocked;
154
+ return /*#__PURE__*/React.createElement("button", {
155
+ ref: function ref(node) {
156
+ return _this2.selector = node;
157
+ },
158
+ className: classnames('dtable-select custom-select collaborator-select', {
159
+ 'focus': this.state.isShowSelectOptions
160
+ }, {
161
+ 'disabled': isLocked
162
+ }, className),
163
+ id: this.id,
164
+ onClick: this.onSelectToggle
165
+ }, /*#__PURE__*/React.createElement("div", {
166
+ className: "selected-option",
167
+ ref: function ref(node) {
168
+ return _this2.selectedOptionRef = node;
169
+ }
170
+ }, value.label ? /*#__PURE__*/React.createElement("span", {
171
+ className: "selected-option-show"
172
+ }, value.label) : /*#__PURE__*/React.createElement("span", {
173
+ className: "select-placeholder"
174
+ }, placeholder), !isLocked && /*#__PURE__*/React.createElement("i", {
175
+ className: "dtable-font dtable-icon-drop-down"
176
+ })), this.state.isShowSelectOptions && this.renderOptionGroup());
177
+ }
178
+ }]);
179
+
180
+ return CollaboratorSelect;
181
+ }(Component);
182
+
183
+ CollaboratorSelect.defaultProps = {
184
+ top: -3,
185
+ left: -3
186
+ };
187
+ export default CollaboratorSelect;
@@ -0,0 +1,24 @@
1
+ export var searchCollaborators = function searchCollaborators(collaborators, searchValue) {
2
+ var validSearchValue = searchValue ? searchValue.trim().toLowerCase() : '';
3
+ var validCollaborators = Array.isArray(collaborators) && collaborators.length > 0 ? collaborators : [];
4
+ if (!validSearchValue) return validCollaborators;
5
+ return validCollaborators.filter(function (collaborator) {
6
+ var name = collaborator.name,
7
+ _collaborator$name_pi = collaborator.name_pinyin,
8
+ name_pinyin = _collaborator$name_pi === void 0 ? '' : _collaborator$name_pi;
9
+ if (name.toString().toLowerCase().indexOf(validSearchValue) > -1) return true;
10
+ if (!name_pinyin) return false;
11
+ var validNamePinyin = name_pinyin.toString().toLowerCase();
12
+ var validSearchPinyinValue = validSearchValue.replace(/ |'/g, ''); // complete
13
+
14
+ if (validNamePinyin.indexOf(validSearchPinyinValue) > -1) return true;
15
+ if (validNamePinyin.replace(/'/g, '').indexOf(validSearchPinyinValue) > -1) return true;
16
+ var validNamePinyinList = validNamePinyin.split('\''); // acronym
17
+
18
+ var namePinyinAcronym = validNamePinyinList.map(function (item) {
19
+ return item && item.trim() ? item.trim().slice(0, 1) : '';
20
+ });
21
+ if (namePinyinAcronym.join('').indexOf(validSearchPinyinValue) > -1) return true;
22
+ return false;
23
+ });
24
+ };
@@ -0,0 +1,155 @@
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, { Component } from 'react';
6
+ import SelectOptionGroup from '../SelectOptionGroup';
7
+ import classnames from 'classnames';
8
+ import '../assets/css/DTableCustomSelect.css';
9
+
10
+ var DTableCustomizeSelect = /*#__PURE__*/function (_Component) {
11
+ _inherits(DTableCustomizeSelect, _Component);
12
+
13
+ var _super = _createSuper(DTableCustomizeSelect);
14
+
15
+ function DTableCustomizeSelect(props) {
16
+ var _this;
17
+
18
+ _classCallCheck(this, DTableCustomizeSelect);
19
+
20
+ _this = _super.call(this, props);
21
+
22
+ _this.onSelectToggle = function (event) {
23
+ event.preventDefault();
24
+ /*
25
+ if select is showing, click events do not need to be monitored by other click events,
26
+ so it can be closed when other select is clicked.
27
+ */
28
+
29
+ if (_this.state.isShowSelectOptions) event.nativeEvent.stopImmediatePropagation();
30
+ var eventClassName = event.target.className;
31
+ if (_this.props.isLocked || eventClassName.indexOf('option-search-control') > -1 || eventClassName === 'option-group-search') return; //Prevent closing by pressing the spacebar in the search input
32
+
33
+ if (event.target.value === '') return;
34
+
35
+ _this.setState({
36
+ isShowSelectOptions: !_this.state.isShowSelectOptions
37
+ });
38
+ };
39
+
40
+ _this.onClick = function (event) {
41
+ if (_this.props.isShowSelected && event.target.className.includes('icon-fork-number')) {
42
+ return;
43
+ }
44
+
45
+ if (!_this.selector.contains(event.target)) {
46
+ _this.closeSelect();
47
+ }
48
+ };
49
+
50
+ _this.closeSelect = function () {
51
+ _this.setState({
52
+ isShowSelectOptions: false
53
+ });
54
+ };
55
+
56
+ _this.getSelectedOptionTop = function () {
57
+ if (!_this.selector) return 38;
58
+
59
+ var _this$selector$getBou = _this.selector.getBoundingClientRect(),
60
+ height = _this$selector$getBou.height;
61
+
62
+ return height;
63
+ };
64
+
65
+ _this.getFilterOptions = function (searchValue) {
66
+ var _this$props = _this.props,
67
+ options = _this$props.options,
68
+ searchable = _this$props.searchable;
69
+ if (!searchable) return options || [];
70
+ var validSearchVal = searchValue.trim().toLowerCase();
71
+ if (!validSearchVal) return options || [];
72
+ return options.filter(function (option) {
73
+ var value = option.value,
74
+ name = option.name;
75
+
76
+ if (typeof name === 'string') {
77
+ return name.toLowerCase().indexOf(validSearchVal) > -1;
78
+ }
79
+
80
+ if (typeof value === 'object') {
81
+ return value.columnOption && value.columnOption.name.toLowerCase().indexOf(validSearchVal) > -1;
82
+ }
83
+
84
+ return false;
85
+ });
86
+ };
87
+
88
+ _this.state = {
89
+ isShowSelectOptions: false
90
+ };
91
+ return _this;
92
+ }
93
+
94
+ _createClass(DTableCustomizeSelect, [{
95
+ key: "componentDidMount",
96
+ value: function componentDidMount() {
97
+ document.addEventListener('click', this.onClick);
98
+ }
99
+ }, {
100
+ key: "componentWillUnmount",
101
+ value: function componentWillUnmount() {
102
+ document.removeEventListener('click', this.onClick);
103
+ }
104
+ }, {
105
+ key: "render",
106
+ value: function render() {
107
+ var _this2 = this;
108
+
109
+ var _this$props2 = this.props,
110
+ className = _this$props2.className,
111
+ value = _this$props2.value,
112
+ options = _this$props2.options,
113
+ placeholder = _this$props2.placeholder,
114
+ searchable = _this$props2.searchable,
115
+ searchPlaceholder = _this$props2.searchPlaceholder,
116
+ noOptionsPlaceholder = _this$props2.noOptionsPlaceholder,
117
+ isLocked = _this$props2.isLocked;
118
+ return /*#__PURE__*/React.createElement("div", {
119
+ ref: function ref(node) {
120
+ return _this2.selector = node;
121
+ },
122
+ className: classnames('dtable-select custom-select', {
123
+ 'focus': this.state.isShowSelectOptions
124
+ }, {
125
+ 'disabled': isLocked
126
+ }, className),
127
+ onClick: this.onSelectToggle
128
+ }, /*#__PURE__*/React.createElement("div", {
129
+ className: "selected-option"
130
+ }, value.label ? /*#__PURE__*/React.createElement("span", {
131
+ className: "selected-option-show"
132
+ }, value.label) : /*#__PURE__*/React.createElement("span", {
133
+ className: "select-placeholder"
134
+ }, placeholder), !isLocked && /*#__PURE__*/React.createElement("i", {
135
+ className: "dtable-font dtable-icon-drop-down"
136
+ })), this.state.isShowSelectOptions && /*#__PURE__*/React.createElement(SelectOptionGroup, {
137
+ value: value,
138
+ isShowSelected: this.props.isShowSelected,
139
+ top: this.getSelectedOptionTop(),
140
+ options: options,
141
+ onSelectOption: this.props.onSelectOption,
142
+ searchable: searchable,
143
+ searchPlaceholder: searchPlaceholder,
144
+ noOptionsPlaceholder: noOptionsPlaceholder,
145
+ closeSelect: this.closeSelect,
146
+ getFilterOptions: this.getFilterOptions,
147
+ supportMultipleSelect: this.props.supportMultipleSelect
148
+ }));
149
+ }
150
+ }]);
151
+
152
+ return DTableCustomizeSelect;
153
+ }(Component);
154
+
155
+ export default DTableCustomizeSelect;
@@ -0,0 +1,115 @@
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 { Popover } from 'reactstrap';
7
+ import { getEventClassName } from './utils';
8
+
9
+ var DTablePopover = /*#__PURE__*/function (_React$Component) {
10
+ _inherits(DTablePopover, _React$Component);
11
+
12
+ var _super = _createSuper(DTablePopover);
13
+
14
+ function DTablePopover() {
15
+ var _this;
16
+
17
+ _classCallCheck(this, DTablePopover);
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
+ _this.dtablePopoverRef = null;
25
+
26
+ _this.onHistoryState = function (e) {
27
+ e.preventDefault();
28
+
29
+ _this.props.hideDTablePopover(e);
30
+ };
31
+
32
+ _this.onKeyDown = function (e) {
33
+ var _this$props = _this.props,
34
+ canHideDTablePopover = _this$props.canHideDTablePopover,
35
+ hideDTablePopoverWithEsc = _this$props.hideDTablePopoverWithEsc;
36
+
37
+ if (e.keyCode === 27 && typeof hideDTablePopoverWithEsc === 'function') {
38
+ e.preventDefault();
39
+ hideDTablePopoverWithEsc();
40
+ } else if (e.keyCode === 13) {
41
+ // Resolve the default behavior of the enter key when entering formulas is blocked
42
+ if (canHideDTablePopover) return;
43
+ e.stopImmediatePropagation();
44
+ }
45
+ };
46
+
47
+ _this.onClick = function (e) {
48
+ var canHideDTablePopover = _this.props.canHideDTablePopover;
49
+ if (!canHideDTablePopover) return;
50
+
51
+ if (_this.dtablePopoverRef && e && getEventClassName(e).indexOf('popover') === -1 && !_this.dtablePopoverRef.contains(e.target)) {
52
+ _this.props.hideDTablePopover(e);
53
+ }
54
+ };
55
+
56
+ _this.onPopoverInsideClick = function (e) {
57
+ e.stopPropagation();
58
+ };
59
+
60
+ return _this;
61
+ }
62
+
63
+ _createClass(DTablePopover, [{
64
+ key: "componentDidMount",
65
+ value: function componentDidMount() {
66
+ document.addEventListener('click', this.onClick);
67
+ document.addEventListener('keydown', this.onKeyDown);
68
+ window.addEventListener('popstate', this.onHistoryState);
69
+ }
70
+ }, {
71
+ key: "componentWillUnmount",
72
+ value: function componentWillUnmount() {
73
+ document.removeEventListener('click', this.onClick);
74
+ document.removeEventListener('keydown', this.onKeyDown);
75
+ window.removeEventListener('popstate', this.onHistoryState);
76
+ }
77
+ }, {
78
+ key: "render",
79
+ value: function render() {
80
+ var _this2 = this;
81
+
82
+ var _this$props2 = this.props,
83
+ target = _this$props2.target,
84
+ innerClassName = _this$props2.innerClassName,
85
+ popoverClassName = _this$props2.popoverClassName,
86
+ hideArrow = _this$props2.hideArrow,
87
+ modifiers = _this$props2.modifiers,
88
+ placement = _this$props2.placement;
89
+ return /*#__PURE__*/React.createElement(Popover, {
90
+ placement: placement,
91
+ isOpen: true,
92
+ target: target,
93
+ fade: false,
94
+ hideArrow: hideArrow,
95
+ innerClassName: innerClassName,
96
+ className: popoverClassName,
97
+ modifiers: modifiers
98
+ }, /*#__PURE__*/React.createElement("div", {
99
+ ref: function ref(_ref) {
100
+ return _this2.dtablePopoverRef = _ref;
101
+ },
102
+ onClick: this.onPopoverInsideClick
103
+ }, this.props.children));
104
+ }
105
+ }]);
106
+
107
+ return DTablePopover;
108
+ }(React.Component);
109
+
110
+ DTablePopover.defaultProps = {
111
+ placement: 'bottom-start',
112
+ hideArrow: true,
113
+ canHideDTablePopover: true
114
+ };
115
+ export default DTablePopover;
@@ -0,0 +1,5 @@
1
+ export var getEventClassName = function getEventClassName(e) {
2
+ // svg mouseEvent event.target.className is an object
3
+ if (!e || !e.target) return '';
4
+ return e.target.getAttribute('class') || '';
5
+ };