dtable-ui-component 6.0.110-aol.8 → 6.0.110-apt.5

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.
@@ -118,7 +118,7 @@
118
118
  box-shadow: none !important;
119
119
  }
120
120
 
121
- .seatable-group-select .option-group-content .dtable-icon-check {
121
+ .option-group-content .dtable-icon-check {
122
122
  color: #666666;
123
123
  font-size: 14px;
124
124
  }
@@ -136,3 +136,19 @@
136
136
  .seatable-group-select .seatable-icon-btn:not(.disabled):hover {
137
137
  background-color:#FFFFFF;
138
138
  }
139
+
140
+ .option-group-dtable-filter-select-column .seatable-icon-btn {
141
+ height: 12px !important;
142
+ width: 12px !important;
143
+ font-size: 12px !important;
144
+ }
145
+
146
+ .option-group-dtable-filter-select-column .clear-search-text {
147
+ position: absolute;
148
+ display: inline-block;
149
+ height: 12px;
150
+ width: 12px;
151
+ line-height: 12px;
152
+ top: 12px;
153
+ right: 18px;
154
+ }
@@ -30,10 +30,11 @@ class DTableSelect extends _react.default.Component {
30
30
  autoFocus,
31
31
  className
32
32
  } = this.props;
33
+ const processedOptions = (0, _utils.processOptionsWithClear)(options, isClearable);
33
34
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactSelect.default, {
34
35
  value: value,
35
- onChange: onChange,
36
- options: options,
36
+ onChange: (0, _utils.createHandleChange)(onChange),
37
+ options: processedOptions,
37
38
  isMulti: isMulti,
38
39
  className: className,
39
40
  classNamePrefix: classNamePrefix,
@@ -41,12 +42,10 @@ class DTableSelect extends _react.default.Component {
41
42
  components: {
42
43
  Option: _utils.Option,
43
44
  DropdownIndicator: _utils.DropdownIndicator,
44
- MenuList: _utils.MenuList,
45
- ClearIndicator: _utils.ClearIndicator
45
+ MenuList: _utils.MenuList
46
46
  },
47
47
  placeholder: placeholder,
48
48
  isSearchable: isSearchable,
49
- isClearable: isClearable,
50
49
  menuPosition: menuPosition || 'fixed' // when use default menuPosition(absolute), menuPortalTarget is unnecessary.
51
50
  ,
52
51
  menuShouldScrollIntoView: true,
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.UserSelectStyle = exports.Option = exports.MenuSelectStyle = exports.MenuList = exports.DropdownIndicator = exports.ClearIndicator = void 0;
7
+ exports.processOptionsWithClear = exports.handleSelectChange = exports.createHandleChange = exports.UserSelectStyle = exports.Option = exports.MenuSelectStyle = exports.MenuList = exports.DropdownIndicator = exports.ClearIndicator = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactSelect = require("react-select");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
@@ -112,20 +112,24 @@ const MenuSelectStyle = exports.MenuSelectStyle = {
112
112
  } = state;
113
113
  return {
114
114
  ...provided,
115
+ padding: '8px',
115
116
  fontSize: '14px',
116
117
  color: '#212529',
117
118
  cursor: isDisabled ? 'default' : 'pointer',
118
119
  backgroundColor: isFocused ? '#f5f5f5' : '#fff',
119
- padding: '8px',
120
120
  borderRadius: '4px',
121
121
  ':active': {
122
122
  backgroundColor: '#f5f5f5'
123
123
  },
124
124
  '.header-icon .dtable-font': {
125
- color: '#aaa'
125
+ color: '#999'
126
126
  },
127
127
  '.header-icon .multicolor-icon': {
128
- color: '#aaa'
128
+ color: '#999'
129
+ },
130
+ '.seatable-ui-select-tip': {
131
+ fontSize: '12px',
132
+ color: '#666666'
129
133
  }
130
134
  };
131
135
  },
@@ -134,7 +138,19 @@ const MenuSelectStyle = exports.MenuSelectStyle = {
134
138
  ...base,
135
139
  zIndex: 9999
136
140
  }),
137
- indicatorSeparator: noneCallback
141
+ indicatorSeparator: noneCallback,
142
+ menuList: provided => ({
143
+ ...provided,
144
+ padding: '8px'
145
+ }),
146
+ valueContainer: (provided, state) => ({
147
+ ...provided,
148
+ padding: '2px 8px 2px 16px'
149
+ }),
150
+ dropdownIndicator: (provided, state) => ({
151
+ ...provided,
152
+ padding: 0
153
+ })
138
154
  };
139
155
  const DropdownIndicator = props => {
140
156
  return _reactSelect.components.DropdownIndicator && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactSelect.components.DropdownIndicator, {
@@ -143,7 +159,9 @@ const DropdownIndicator = props => {
143
159
  className: "dtable-font dtable-icon-down3",
144
160
  style: {
145
161
  fontSize: '12px',
146
- marginLeft: '-2px'
162
+ marginLeft: '-2px',
163
+ color: '#666666',
164
+ paddingRight: '16px'
147
165
  }
148
166
  })
149
167
  });
@@ -185,27 +203,56 @@ const MenuList = props => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
185
203
  exports.MenuList = MenuList;
186
204
  const Option = props => {
187
205
  const {
188
- isSelected
206
+ isSelected,
207
+ label
189
208
  } = props;
190
- const baseStyle = props.data.style || {};
191
- const containerStyle = {
192
- ...baseStyle,
193
- display: 'flex',
194
- alignItems: 'center',
195
- justifyContent: 'space-between'
196
- };
197
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
198
- style: containerStyle,
199
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactSelect.components.Option, {
200
- ...props
201
- }), isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
202
- className: "dtable-font dtable-icon-check-mark",
209
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactSelect.components.Option, {
210
+ ...props,
211
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
203
212
  style: {
204
- fontSize: '14px',
205
- color: '#666666',
206
- flexShrink: 0
207
- }
208
- })]
213
+ display: 'flex',
214
+ alignItems: 'center',
215
+ justifyContent: 'space-between',
216
+ width: '100%'
217
+ },
218
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
219
+ children: label
220
+ }), isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
221
+ className: "dtable-font dtable-icon-check",
222
+ style: {
223
+ fontSize: '14px',
224
+ color: '#666666',
225
+ paddingLeft: '16px'
226
+ }
227
+ })]
228
+ })
209
229
  });
210
230
  };
211
- exports.Option = Option;
231
+ exports.Option = Option;
232
+ const processOptionsWithClear = (options, isClearable) => {
233
+ if (isClearable && options && options.length > 0) {
234
+ return [{
235
+ label: '--',
236
+ value: '__clear__'
237
+ }, ...options];
238
+ }
239
+ return options;
240
+ };
241
+ exports.processOptionsWithClear = processOptionsWithClear;
242
+ const handleSelectChange = (selectedOption, actionMeta, onChangeCallback) => {
243
+ if (selectedOption && selectedOption.value === '__clear__') {
244
+ onChangeCallback(null, {
245
+ ...actionMeta,
246
+ action: 'clear'
247
+ });
248
+ } else {
249
+ onChangeCallback(selectedOption, actionMeta);
250
+ }
251
+ };
252
+ exports.handleSelectChange = handleSelectChange;
253
+ const createHandleChange = onChange => {
254
+ return (selectedOption, actionMeta) => {
255
+ handleSelectChange(selectedOption, actionMeta, onChange);
256
+ };
257
+ };
258
+ exports.createHandleChange = createHandleChange;
@@ -20,6 +20,12 @@
20
20
  padding: 0 0 8px 0 !important;
21
21
  }
22
22
 
23
+ .option-group .option-group-content .label-space {
24
+ display: flex;
25
+ justify-content: space-between;
26
+ align-items: center;
27
+ }
28
+
23
29
  .option-group-search .form-control {
24
30
  height: 32px;
25
31
  }
@@ -67,11 +73,6 @@
67
73
  color: #fff;
68
74
  }
69
75
 
70
- .optio .dtable-ui-explanation-tip {
71
- color: #666666;
72
- font-size: 12px !important;
73
- }
74
-
75
76
  .option.option-active .header-icon .dtable-font,
76
77
  .option.option-active .header-icon .multicolor-icon {
77
78
  color: #fff;
@@ -12,6 +12,8 @@ var _option = _interopRequireDefault(require("./option"));
12
12
  var _DTableSearchInput = _interopRequireDefault(require("../DTableSearchInput"));
13
13
  var _KeyCodes = _interopRequireDefault(require("./KeyCodes"));
14
14
  var _ClickOutside = _interopRequireDefault(require("../ClickOutside"));
15
+ var _IconButton = _interopRequireDefault(require("../IconButton"));
16
+ var _lang = require("../lang");
15
17
  require("./index.css");
16
18
  var _jsxRuntime = require("react/jsx-runtime");
17
19
  const OPTION_HEIGHT = 32;
@@ -135,7 +137,8 @@ class SelectOptionGroup extends _react.Component {
135
137
  this.renderOptGroup = searchVal => {
136
138
  let {
137
139
  noOptionsPlaceholder,
138
- onSelectOption
140
+ onSelectOption,
141
+ value
139
142
  } = this.props;
140
143
  this.filterOptions = this.props.getFilterOptions(searchVal);
141
144
  if (this.filterOptions.length === 0) {
@@ -147,6 +150,7 @@ class SelectOptionGroup extends _react.Component {
147
150
  return this.filterOptions.map((opt, i) => {
148
151
  let key = opt.value.column ? opt.value.column.key : i;
149
152
  let isActive = this.state.activeIndex === i;
153
+ let isSelected = value && (typeof value === 'object' && value.value.column.key === opt.value.column.key || typeof value === 'string' && value === opt.value);
150
154
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_option.default, {
151
155
  index: i,
152
156
  isActive: isActive,
@@ -155,10 +159,23 @@ class SelectOptionGroup extends _react.Component {
155
159
  changeIndex: this.changeIndex,
156
160
  supportMultipleSelect: this.props.supportMultipleSelect,
157
161
  disableHover: this.state.disableHover,
158
- children: opt.label
162
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
163
+ className: "label-space",
164
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
165
+ children: [" ", opt.label]
166
+ }), isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
167
+ className: "dtable-font dtable-icon-check"
168
+ })]
169
+ })
159
170
  }, `${key}-${i}`);
160
171
  });
161
172
  };
173
+ this.clearValue = () => {
174
+ this.setState({
175
+ searchVal: '',
176
+ activeIndex: -1
177
+ });
178
+ };
162
179
  this.state = {
163
180
  searchVal: '',
164
181
  activeIndex: -1,
@@ -243,7 +260,22 @@ class SelectOptionGroup extends _react.Component {
243
260
  placeholder: searchPlaceholder,
244
261
  onChange: this.onChangeSearch,
245
262
  autoFocus: true,
246
- ref: this.searchInputRef
263
+ ref: this.searchInputRef,
264
+ clearValue: this.clearValue,
265
+ isClearable: true,
266
+ components: {
267
+ ClearIndicator: props => {
268
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
269
+ className: "clear-search-text",
270
+ onClick: props.clearValue,
271
+ title: (0, _lang.getLocale)('Clear_search_text'),
272
+ "aria-label": (0, _lang.getLocale)('Clear_search_text'),
273
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
274
+ icon: "x"
275
+ })
276
+ });
277
+ }
278
+ }
247
279
  })
248
280
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
249
281
  className: `option-group-content ${!searchable && !supportMultipleSelect ? 'option-group-top' : ''}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.110-aol.8",
3
+ "version": "6.0.110-apt.5",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "^5.0.4",