dtable-ui-component 6.0.110-xko.2 → 6.0.110-xms.2

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,
@@ -58,10 +57,7 @@ class DTableSelect extends _react.default.Component {
58
57
  ref: innerRef,
59
58
  filterOption: customFilterOption,
60
59
  form: form,
61
- autoFocus: autoFocus,
62
- menuIsOpen: true,
63
- onMenuClose: () => {},
64
- onMenuOpen: () => {}
60
+ autoFocus: autoFocus
65
61
  });
66
62
  }
67
63
  }
@@ -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");
@@ -122,10 +122,10 @@ const MenuSelectStyle = exports.MenuSelectStyle = {
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
129
  },
130
130
  '.seatable-ui-select-tip': {
131
131
  fontSize: '12px',
@@ -146,6 +146,10 @@ const MenuSelectStyle = exports.MenuSelectStyle = {
146
146
  valueContainer: (provided, state) => ({
147
147
  ...provided,
148
148
  padding: '2px 8px 2px 16px'
149
+ }),
150
+ dropdownIndicator: (provided, state) => ({
151
+ ...provided,
152
+ padding: 0
149
153
  })
150
154
  };
151
155
  const DropdownIndicator = props => {
@@ -224,4 +228,31 @@ const Option = props => {
224
228
  })
225
229
  });
226
230
  };
227
- 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
  }
@@ -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;
@@ -81,6 +83,11 @@ class SelectOptionGroup extends _react.Component {
81
83
  });
82
84
  }
83
85
  };
86
+ this.isEqual = (obj1, obj2) => {
87
+ if (obj1 === obj2) return true;
88
+ if (!obj1 || !obj2) return false;
89
+ return JSON.stringify(obj1) === JSON.stringify(obj2);
90
+ };
84
91
  this.onMouseDown = e => {
85
92
  const {
86
93
  isInModal
@@ -132,10 +139,17 @@ class SelectOptionGroup extends _react.Component {
132
139
  });
133
140
  }
134
141
  };
142
+ this.isEqual = (obj1, obj2) => {
143
+ if (obj1 === obj2) return true;
144
+ if (!obj1 || !obj2) return false;
145
+ return JSON.stringify(obj1) === JSON.stringify(obj2);
146
+ };
135
147
  this.renderOptGroup = searchVal => {
136
148
  let {
137
149
  noOptionsPlaceholder,
138
- onSelectOption
150
+ onSelectOption,
151
+ value,
152
+ supportMultipleSelect
139
153
  } = this.props;
140
154
  this.filterOptions = this.props.getFilterOptions(searchVal);
141
155
  if (this.filterOptions.length === 0) {
@@ -147,6 +161,7 @@ class SelectOptionGroup extends _react.Component {
147
161
  return this.filterOptions.map((opt, i) => {
148
162
  let key = opt.value.column ? opt.value.column.key : i;
149
163
  let isActive = this.state.activeIndex === i;
164
+ let isSelected = value && typeof value === 'object' && !supportMultipleSelect ? this.isEqual(value.value, opt.value) : Array.isArray(value.value) ? value.value.includes(opt.value.column_key) : false;
150
165
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_option.default, {
151
166
  index: i,
152
167
  isActive: isActive,
@@ -155,10 +170,23 @@ class SelectOptionGroup extends _react.Component {
155
170
  changeIndex: this.changeIndex,
156
171
  supportMultipleSelect: this.props.supportMultipleSelect,
157
172
  disableHover: this.state.disableHover,
158
- children: opt.label
173
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
174
+ className: "label-space",
175
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
176
+ children: [" ", opt.label]
177
+ }), isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
178
+ className: "dtable-font dtable-icon-check"
179
+ })]
180
+ })
159
181
  }, `${key}-${i}`);
160
182
  });
161
183
  };
184
+ this.clearValue = () => {
185
+ this.setState({
186
+ searchVal: '',
187
+ activeIndex: -1
188
+ });
189
+ };
162
190
  this.state = {
163
191
  searchVal: '',
164
192
  activeIndex: -1,
@@ -243,7 +271,22 @@ class SelectOptionGroup extends _react.Component {
243
271
  placeholder: searchPlaceholder,
244
272
  onChange: this.onChangeSearch,
245
273
  autoFocus: true,
246
- ref: this.searchInputRef
274
+ ref: this.searchInputRef,
275
+ clearValue: this.clearValue,
276
+ isClearable: true,
277
+ components: {
278
+ ClearIndicator: props => {
279
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
280
+ className: "clear-search-text",
281
+ onClick: props.clearValue,
282
+ title: (0, _lang.getLocale)('Clear_search_text'),
283
+ "aria-label": (0, _lang.getLocale)('Clear_search_text'),
284
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
285
+ icon: "x"
286
+ })
287
+ });
288
+ }
289
+ }
247
290
  })
248
291
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
249
292
  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-xko.2",
3
+ "version": "6.0.110-xms.2",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "^5.0.4",