dtable-ui-component 5.2.11-alpha4 → 5.2.12

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.
@@ -18,6 +18,7 @@ class SelectOptionGroup extends _react.Component {
18
18
  constructor(props) {
19
19
  super(props);
20
20
  this.resetMenuStyle = () => {
21
+ if (!this.optionGroupRef) return;
21
22
  const {
22
23
  isInModal,
23
24
  position
package/lib/index.js CHANGED
@@ -106,12 +106,6 @@ Object.defineProperty(exports, "DTableFiltersPopover", {
106
106
  return _DTableFiltersPopover.default;
107
107
  }
108
108
  });
109
- Object.defineProperty(exports, "DTableGroupSelect", {
110
- enumerable: true,
111
- get: function () {
112
- return _index.default;
113
- }
114
- });
115
109
  Object.defineProperty(exports, "DTableModalHeader", {
116
110
  enumerable: true,
117
111
  get: function () {
@@ -484,7 +478,6 @@ var _DTableRadio = _interopRequireDefault(require("./DTableRadio"));
484
478
  var _DTableCommonAddTool = _interopRequireDefault(require("./DTableCommonAddTool"));
485
479
  var _NotificationPopover = _interopRequireDefault(require("./NotificationPopover"));
486
480
  var _DTableSelect = _interopRequireDefault(require("./DTableSelect"));
487
- var _index = _interopRequireDefault(require("./DTableGroupSelect/index"));
488
481
  var _dtableSelectLabel = _interopRequireDefault(require("./DTableSelect/dtable-select-label"));
489
482
  var _DTableSwitch = _interopRequireDefault(require("./DTableSwitch"));
490
483
  var _DTableCustomizeSelect = _interopRequireDefault(require("./DTableCustomizeSelect"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "5.2.11-alpha4",
3
+ "version": "5.2.12",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "3.0.1",
@@ -1,96 +0,0 @@
1
- .group-select {
2
- position: relative;
3
- }
4
-
5
- .group-select.custom-select {
6
- display: flex;
7
- padding: 5px 10px;
8
- border-radius: 3px;
9
- align-items: center;
10
- justify-content: space-between;
11
- max-width: 900px;
12
- user-select: none;
13
- text-align: left;
14
- border-color: 1px solid rgba(0, 40, 100, 0.12);
15
- height: auto;
16
- min-height: 38px;
17
- cursor: pointer;
18
- }
19
-
20
- .group-select.custom-select:focus,
21
- .group-select.custom-select.focus {
22
- border-color: #1991eb !important;
23
- box-shadow: 0 0 0 2px rgba(70, 127, 207, 0.25);
24
- }
25
-
26
- .group-select.custom-select.disabled:focus,
27
- .group-select.custom-select.focus.disabled,
28
- .group-select.custom-select.disabled:hover {
29
- border-color: rgba(0, 40, 100, 0.12) !important;
30
- box-shadow: unset;
31
- cursor: default;
32
- }
33
-
34
- .group-select .sf3-font-down {
35
- display: inline-block;
36
- color: #999;
37
- transform: translateY(2px);
38
- transition: all 0.1s;
39
- font-size: 14px !important;
40
- }
41
-
42
- .group-select .sf3-font-down:hover {
43
- color: #666;
44
- }
45
-
46
- .group-select .selected-option {
47
- display: flex;
48
- flex: 1;
49
- overflow: hidden;
50
- flex-wrap: nowrap;
51
- align-items: center;
52
- justify-content: space-between;
53
- background: #fff;
54
- }
55
-
56
- .group-select.selector-collaborator .option-group .option-group-content {
57
- padding: 10px;
58
- }
59
-
60
- .group-select.custom-select.selector-collaborator .option-group .option-group-content {
61
- padding: 10px 0;
62
- }
63
-
64
- .group-select.custom-select.selector-collaborator .option {
65
- padding: 5px 0 5px 10px !important;
66
- line-height: 20px;
67
- }
68
-
69
- .group-select .select-placeholder {
70
- line-height: 1;
71
- font-size: 14px;
72
- white-space: nowrap;
73
- }
74
-
75
- .group-select .selected-option-show {
76
- display: flex;
77
- flex-wrap: wrap;
78
- gap: 4px;
79
- }
80
-
81
- .group-select .selected-option-show .selected-option-item {
82
- background-color: rgb(240, 240, 240);
83
- border-radius: 16px;
84
- display: flex;
85
- align-items: center;
86
- }
87
-
88
- .group-select .selected-option-show .selected-option-item .selected-option-item-name {
89
- font-size: 13px;
90
- color: #212529;
91
- }
92
-
93
- .group-select .selected-option-show .selected-option-item .dtable-icon-x {
94
- cursor: pointer;
95
- color: rgb(103, 103, 103);
96
- }
@@ -1,127 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- var _modalPortal = _interopRequireDefault(require("../common/modal-portal.js"));
12
- var _selectOptionGroup = _interopRequireDefault(require("./select-option-group.js"));
13
- require("./index.css");
14
- class DTableGroupSelect extends _react.Component {
15
- constructor(props) {
16
- super(props);
17
- this.onSelectToggle = event => {
18
- event.preventDefault();
19
- if (this.state.isShowSelectOptions) event.stopPropagation();
20
- let eventClassName = event.target.className;
21
- if (eventClassName.indexOf('dtable-icon-x') > -1 || eventClassName === 'option-group-search') return;
22
- if (event.target.value === '') return;
23
- this.setState({
24
- isShowSelectOptions: !this.state.isShowSelectOptions
25
- });
26
- };
27
- this.onClickOutside = event => {
28
- if (this.props.isShowSelected && event.target.className.includes('icon-fork-number')) {
29
- return;
30
- }
31
- if (!this.selector.contains(event.target)) {
32
- this.closeSelect();
33
- }
34
- };
35
- this.closeSelect = () => {
36
- this.setState({
37
- isShowSelectOptions: false
38
- });
39
- };
40
- this.getSelectedOptionTop = () => {
41
- if (!this.selector) return 38;
42
- const {
43
- height
44
- } = this.selector.getBoundingClientRect();
45
- return height;
46
- };
47
- this.getFilterOptions = searchValue => {
48
- const {
49
- options
50
- } = this.props;
51
- const validSearchVal = searchValue.trim().toLowerCase();
52
- if (!validSearchVal) return options || [];
53
- return options.filter(option => option.name.toLowerCase().includes(validSearchVal));
54
- };
55
- this.state = {
56
- isShowSelectOptions: false
57
- };
58
- }
59
- UNSAFE_componentWillReceiveProps(nextProps) {
60
- if (nextProps.selectedOptions.length !== this.props.selectedOptions.length) {
61
- // when selectedOptions change and dom rendered, calculate top
62
- setTimeout(() => {
63
- this.forceUpdate();
64
- }, 1);
65
- }
66
- }
67
- render() {
68
- let {
69
- className,
70
- selectedOptions,
71
- options,
72
- placeholder,
73
- searchPlaceholder,
74
- noOptionsPlaceholder,
75
- isInModal
76
- } = this.props;
77
- return /*#__PURE__*/_react.default.createElement("div", {
78
- ref: node => this.selector = node,
79
- className: (0, _classnames.default)('group-select custom-select', {
80
- 'focus': this.state.isShowSelectOptions
81
- }, className),
82
- onClick: this.onSelectToggle
83
- }, /*#__PURE__*/_react.default.createElement("div", {
84
- className: "selected-option"
85
- }, selectedOptions.length > 0 ? /*#__PURE__*/_react.default.createElement("span", {
86
- className: "selected-option-show"
87
- }, selectedOptions.map(item => /*#__PURE__*/_react.default.createElement("span", {
88
- key: item.id,
89
- className: "selected-option-item mr-1 pr-1 pl-2"
90
- }, /*#__PURE__*/_react.default.createElement("span", {
91
- className: "selected-option-item-name"
92
- }, item.name), /*#__PURE__*/_react.default.createElement("i", {
93
- className: "dtable-font dtable-icon-x ml-1",
94
- onClick: () => {
95
- this.props.onDeleteOption(item);
96
- }
97
- })))) : /*#__PURE__*/_react.default.createElement("span", {
98
- className: "select-placeholder"
99
- }, placeholder), /*#__PURE__*/_react.default.createElement("i", {
100
- className: "sf3-font-down sf3-font"
101
- })), this.state.isShowSelectOptions && !isInModal && /*#__PURE__*/_react.default.createElement(_selectOptionGroup.default, {
102
- selectedOptions: selectedOptions,
103
- top: this.getSelectedOptionTop(),
104
- options: options,
105
- onSelectOption: this.props.onSelectOption,
106
- searchPlaceholder: searchPlaceholder,
107
- noOptionsPlaceholder: noOptionsPlaceholder,
108
- onClickOutside: this.onClickOutside,
109
- closeSelect: this.closeSelect,
110
- getFilterOptions: this.getFilterOptions
111
- }), this.state.isShowSelectOptions && isInModal && /*#__PURE__*/_react.default.createElement(_modalPortal.default, null, /*#__PURE__*/_react.default.createElement(_selectOptionGroup.default, {
112
- className: className,
113
- selectedOptions: selectedOptions,
114
- position: this.selector.getBoundingClientRect(),
115
- isInModal: isInModal,
116
- top: this.getSelectedOptionTop(),
117
- options: options,
118
- onSelectOption: this.props.onSelectOption,
119
- searchPlaceholder: searchPlaceholder,
120
- noOptionsPlaceholder: noOptionsPlaceholder,
121
- onClickOutside: this.onClickOutside,
122
- closeSelect: this.closeSelect,
123
- getFilterOptions: this.getFilterOptions
124
- })));
125
- }
126
- }
127
- var _default = exports.default = DTableGroupSelect;
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = _interopRequireWildcard(require("react"));
9
- class Option extends _react.Component {
10
- constructor() {
11
- super(...arguments);
12
- this.onSelectOption = e => {
13
- e.stopPropagation();
14
- this.props.onSelectOption(this.props.option);
15
- };
16
- this.onMouseEnter = () => {
17
- if (!this.props.disableHover) {
18
- this.props.changeIndex(this.props.index);
19
- }
20
- };
21
- this.onMouseLeave = () => {
22
- if (!this.props.disableHover) {
23
- this.props.changeIndex(-1);
24
- }
25
- };
26
- }
27
- render() {
28
- return /*#__PURE__*/_react.default.createElement("div", {
29
- className: this.props.isActive ? 'option option-active' : 'option',
30
- onClick: this.onSelectOption,
31
- onMouseEnter: this.onMouseEnter,
32
- onMouseLeave: this.onMouseLeave
33
- }, this.props.children);
34
- }
35
- }
36
- var _default = exports.default = Option;
@@ -1,91 +0,0 @@
1
- .option-group {
2
- position: absolute;
3
- left: 0;
4
- min-height: 60px;
5
- max-height: 300px;
6
- min-width: 100%;
7
- max-width: 15rem;
8
- padding: 0.5rem 0;
9
- box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
10
- background: #fff;
11
- border: 1px solid rgba(0, 40, 100, 0.12);
12
- border-radius: 3px;
13
- z-index: 10001;
14
- }
15
-
16
- .option-group .option-group-search {
17
- width: 100%;
18
- padding: 6px 10px;
19
- min-width: 170px;
20
- }
21
-
22
- .option-group-search .form-control {
23
- height: 31px;
24
- }
25
-
26
- .option-group .none-search-result {
27
- height: 100px;
28
- width: 100%;
29
- padding: 10px;
30
- color: #666666;
31
- }
32
-
33
- .option-group .option-group-content {
34
- max-height: 252px;
35
- overflow-y: auto;
36
- }
37
-
38
- .option {
39
- display: block;
40
- width: 100%;
41
- line-height: 24px;
42
- padding: 6px 10px;
43
- clear: both;
44
- font-weight: 400;
45
- text-align: inherit;
46
- background-color: transparent;
47
- border: 0;
48
- overflow: hidden;
49
- text-overflow: ellipsis;
50
- white-space: nowrap;
51
- display: flex;
52
- align-items: center;
53
- justify-content: space-between;
54
- }
55
-
56
- .option .dtable-icon-check-mark {
57
- font-size: 12px;
58
- color: #798d99;
59
- }
60
-
61
- .option.option-active {
62
- background-color: #20a0ff;
63
- color: #fff;
64
- cursor: pointer;
65
- }
66
-
67
- .option.option-active .dtable-icon-check-mark,
68
- .option.option-active .select-option-name {
69
- color: #fff !important;
70
- }
71
-
72
- .option .select-option-name .single-select-option {
73
- margin: 0 0 0 12px;
74
- }
75
-
76
- .option .select-option-name .multiple-select-option {
77
- margin: 0;
78
- }
79
-
80
- .option-group-selector-single-select .select-option-name {
81
- display: flex;
82
- align-items: center;
83
- justify-content: space-between;
84
- }
85
-
86
- .option-group-selector-single-select .option:hover,
87
- .option-group-selector-single-select .option.option-active,
88
- .option-group-selector-multiple-select .option:hover,
89
- .option-group-selector-multiple-select .option.option-active {
90
- background-color: #f5f5f5;
91
- }
@@ -1,227 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- var _DTableSearchInput = _interopRequireDefault(require("../DTableSearchInput"));
12
- var _option = _interopRequireDefault(require("./option"));
13
- var _KeyCodes = _interopRequireDefault(require("../SelectOptionGroup/KeyCodes"));
14
- var _ClickOutside = _interopRequireDefault(require("../ClickOutside"));
15
- require("./select-option-group.css");
16
- const OPTION_HEIGHT = 32;
17
- class SelectOptionGroup extends _react.Component {
18
- constructor(props) {
19
- super(props);
20
- this.resetMenuStyle = () => {
21
- const {
22
- isInModal,
23
- position
24
- } = this.props;
25
- const {
26
- top,
27
- height
28
- } = this.optionGroupRef.getBoundingClientRect();
29
- if (isInModal) {
30
- if (position.y + position.height + height > window.innerHeight) {
31
- this.optionGroupRef.style.top = position.y - height + 'px';
32
- }
33
- this.optionGroupRef.style.opacity = 1;
34
- this.searchInputRef.current && this.searchInputRef.current.inputRef.focus();
35
- } else {
36
- if (height + top > window.innerHeight) {
37
- const borderWidth = 2;
38
- this.optionGroupRef.style.top = -1 * (height + borderWidth) + 'px';
39
- }
40
- }
41
- };
42
- this.onHotKey = event => {
43
- const keyCode = event.keyCode;
44
- if (keyCode === _KeyCodes.default.UpArrow) {
45
- this.onPressUp();
46
- } else if (keyCode === _KeyCodes.default.DownArrow) {
47
- this.onPressDown();
48
- } else if (keyCode === _KeyCodes.default.Enter) {
49
- let option = this.filterOptions && this.filterOptions[this.state.activeIndex];
50
- if (option) {
51
- this.props.onSelectOption(option);
52
- }
53
- } else if (keyCode === _KeyCodes.default.Tab || keyCode === _KeyCodes.default.Escape) {
54
- this.props.closeSelect();
55
- }
56
- };
57
- this.onPressUp = () => {
58
- if (this.state.activeIndex > 0) {
59
- this.setState({
60
- activeIndex: this.state.activeIndex - 1
61
- }, () => {
62
- this.scrollContent();
63
- });
64
- }
65
- };
66
- this.onPressDown = () => {
67
- if (this.filterOptions && this.state.activeIndex < this.filterOptions.length - 1) {
68
- this.setState({
69
- activeIndex: this.state.activeIndex + 1
70
- }, () => {
71
- this.scrollContent();
72
- });
73
- }
74
- };
75
- this.onMouseDown = e => {
76
- const {
77
- isInModal
78
- } = this.props;
79
- // prevent event propagation when click option or search input
80
- if (isInModal) {
81
- e.stopPropagation();
82
- e.nativeEvent.stopImmediatePropagation();
83
- }
84
- };
85
- this.scrollContent = () => {
86
- const {
87
- offsetHeight,
88
- scrollTop
89
- } = this.optionGroupContentRef;
90
- this.setState({
91
- disableHover: true
92
- });
93
- this.timer = setTimeout(() => {
94
- this.setState({
95
- disableHover: false
96
- });
97
- }, 500);
98
- if (this.state.activeIndex * OPTION_HEIGHT === 0) {
99
- this.optionGroupContentRef.scrollTop = 0;
100
- return;
101
- }
102
- if (this.state.activeIndex * OPTION_HEIGHT < scrollTop) {
103
- this.optionGroupContentRef.scrollTop = scrollTop - OPTION_HEIGHT;
104
- } else if (this.state.activeIndex * OPTION_HEIGHT > offsetHeight + scrollTop) {
105
- this.optionGroupContentRef.scrollTop = scrollTop + OPTION_HEIGHT;
106
- }
107
- };
108
- this.changeIndex = index => {
109
- this.setState({
110
- activeIndex: index
111
- });
112
- };
113
- this.onChangeSearch = searchVal => {
114
- this.setState({
115
- searchVal: searchVal || '',
116
- activeIndex: -1
117
- });
118
- };
119
- this.clearValue = () => {
120
- this.setState({
121
- searchVal: '',
122
- activeIndex: -1
123
- });
124
- };
125
- this.renderOptGroup = searchVal => {
126
- let {
127
- noOptionsPlaceholder,
128
- onSelectOption,
129
- selectedOptions
130
- } = this.props;
131
- this.filterOptions = this.props.getFilterOptions(searchVal);
132
- if (this.filterOptions.length === 0) {
133
- return /*#__PURE__*/_react.default.createElement("div", {
134
- className: "none-search-result"
135
- }, noOptionsPlaceholder);
136
- }
137
- return this.filterOptions.map((option, index) => {
138
- const isSelected = selectedOptions.some(item => item.id === option.id);
139
- return /*#__PURE__*/_react.default.createElement(_option.default, {
140
- key: "".concat(option.id, "-").concat(index),
141
- index: index,
142
- isActive: this.state.activeIndex === index,
143
- option: option,
144
- onSelectOption: onSelectOption,
145
- changeIndex: this.changeIndex,
146
- disableHover: this.state.disableHover
147
- }, /*#__PURE__*/_react.default.createElement("div", {
148
- className: "option-label"
149
- }, option.label), isSelected && /*#__PURE__*/_react.default.createElement("i", {
150
- className: "dtable-font dtable-icon-check-mark"
151
- }));
152
- });
153
- };
154
- this.state = {
155
- searchVal: '',
156
- activeIndex: -1,
157
- disableHover: false
158
- };
159
- this.filterOptions = null;
160
- this.timer = null;
161
- this.searchInputRef = /*#__PURE__*/_react.default.createRef();
162
- }
163
- componentDidMount() {
164
- window.addEventListener('keydown', this.onHotKey);
165
- setTimeout(() => {
166
- this.resetMenuStyle();
167
- }, 1);
168
- }
169
- componentWillUnmount() {
170
- this.filterOptions = null;
171
- this.timer && clearTimeout(this.timer);
172
- window.removeEventListener('keydown', this.onHotKey);
173
- }
174
- render() {
175
- const {
176
- searchPlaceholder,
177
- top,
178
- left,
179
- minWidth,
180
- isInModal,
181
- position,
182
- className
183
- } = this.props;
184
- let {
185
- searchVal
186
- } = this.state;
187
- let style = {
188
- top: top || 0,
189
- left: left || 0
190
- };
191
- if (minWidth) {
192
- style = {
193
- top: top || 0,
194
- left: left || 0,
195
- minWidth
196
- };
197
- }
198
- if (isInModal) {
199
- style = {
200
- position: 'fixed',
201
- left: position.x,
202
- top: position.y + position.height,
203
- minWidth: position.width,
204
- opacity: 0
205
- };
206
- }
207
- return /*#__PURE__*/_react.default.createElement(_ClickOutside.default, {
208
- onClickOutside: this.props.onClickOutside
209
- }, /*#__PURE__*/_react.default.createElement("div", {
210
- className: (0, _classnames.default)('pt-0 option-group', className ? 'option-group-' + className : ''),
211
- ref: ref => this.optionGroupRef = ref,
212
- style: style,
213
- onMouseDown: this.onMouseDown
214
- }, /*#__PURE__*/_react.default.createElement("div", {
215
- className: "option-group-search position-relative"
216
- }, /*#__PURE__*/_react.default.createElement(_DTableSearchInput.default, {
217
- className: "option-search-control",
218
- placeholder: searchPlaceholder,
219
- onChange: this.onChangeSearch,
220
- ref: this.searchInputRef
221
- })), /*#__PURE__*/_react.default.createElement("div", {
222
- className: "option-group-content",
223
- ref: ref => this.optionGroupContentRef = ref
224
- }, this.renderOptGroup(searchVal))));
225
- }
226
- }
227
- var _default = exports.default = SelectOptionGroup;