dtable-ui-component 6.0.110-aol.8 → 6.0.110-gon.1

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.
@@ -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;
@@ -67,11 +67,6 @@
67
67
  color: #fff;
68
68
  }
69
69
 
70
- .optio .dtable-ui-explanation-tip {
71
- color: #666666;
72
- font-size: 12px !important;
73
- }
74
-
75
70
  .option.option-active .header-icon .dtable-font,
76
71
  .option.option-active .header-icon .multicolor-icon {
77
72
  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;
@@ -159,6 +161,12 @@ class SelectOptionGroup extends _react.Component {
159
161
  }, `${key}-${i}`);
160
162
  });
161
163
  };
164
+ this.clearValue = () => {
165
+ this.setState({
166
+ searchVal: '',
167
+ activeIndex: -1
168
+ });
169
+ };
162
170
  this.state = {
163
171
  searchVal: '',
164
172
  activeIndex: -1,
@@ -243,7 +251,21 @@ class SelectOptionGroup extends _react.Component {
243
251
  placeholder: searchPlaceholder,
244
252
  onChange: this.onChangeSearch,
245
253
  autoFocus: true,
246
- ref: this.searchInputRef
254
+ ref: this.searchInputRef,
255
+ clearValue: this.clearValue,
256
+ components: {
257
+ ClearIndicator: props => {
258
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
259
+ className: "clear-search-text",
260
+ onClick: props.clearValue,
261
+ title: (0, _lang.getLocale)('Clear_search_text'),
262
+ "aria-label": (0, _lang.getLocale)('Clear_search_text'),
263
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
264
+ icon: "x"
265
+ })
266
+ });
267
+ }
268
+ }
247
269
  })
248
270
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
249
271
  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-gon.1",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "^5.0.4",