cloud-web-corejs 1.1.0-dev.71 → 1.1.0-dev.72

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.1.0-dev.71",
4
+ "version": "1.1.0-dev.72",
5
5
  "scripts": {
6
6
  "build:ace-resources": "node build/build-ace-resources.js",
7
7
  "build:tinymce-resources": "node build/build-tinymce-resources.js",
@@ -74,6 +74,7 @@ methods: {
74
74
  | `prefixIcon` | String | `""` | 前置图标类名 |
75
75
  | `suffixIcon` | String | `el-icon-tickets` | 后置图标类名。有内容并悬停出清空按钮时,这个图标会隐藏。传 `""` 可去掉 |
76
76
  | `popperClass` | String | `""` | 追加到下拉浮层上的类名 |
77
+ | `dropdownMaxWidth` | Number / String | `480` | 下拉最大宽度。最小宽度是输入框宽度,文字超出后换行 |
77
78
  | `itemTemplate` | Function | `null` | `(item) => html`。自定义下拉项 HTML。写了默认插槽时不使用 |
78
79
 
79
80
  `props.label` 是候选项上的字段名,`label` 是当前显示出来的文字,两者不是同一个值。
@@ -153,6 +153,13 @@ export default {
153
153
  type: String,
154
154
  default: "",
155
155
  },
156
+ /**
157
+ * 下拉最大宽度。最小宽度始终是输入框宽度,超出后换行。
158
+ */
159
+ dropdownMaxWidth: {
160
+ type: [Number, String],
161
+ default: 480,
162
+ },
156
163
  },
157
164
  data() {
158
165
  return {
@@ -198,6 +205,9 @@ export default {
198
205
  this.displayValue = this.storedLabel;
199
206
  this.lookupLabel(this.value);
200
207
  },
208
+ mounted() {
209
+ this.syncDropdownWidth();
210
+ },
201
211
  methods: {
202
212
  focus() {
203
213
  const input = this.$refs.input;
@@ -224,6 +234,7 @@ export default {
224
234
  && this._lastSuggestions.length
225
235
  ) {
226
236
  cb(this._lastSuggestions);
237
+ this.syncDropdownWidth();
227
238
  return;
228
239
  }
229
240
  this.lastQueryKeyword = keyword;
@@ -248,6 +259,7 @@ export default {
248
259
  const list = Array.isArray(rows) ? rows : [];
249
260
  this._lastSuggestions = list;
250
261
  cb(list);
262
+ this.syncDropdownWidth();
251
263
  };
252
264
  try {
253
265
  const ret = this.load(keyword, done);
@@ -336,8 +348,37 @@ export default {
336
348
  this.focused = true;
337
349
  const input = this.$refs.input;
338
350
  if (input) input.suggestionDisabled = false;
351
+ this.syncDropdownWidth();
339
352
  this.$emit("focus", event);
340
353
  },
354
+ syncDropdownWidth() {
355
+ this.$nextTick(() => {
356
+ const ac = this.$refs.input;
357
+ if (!ac || !ac.$el) return;
358
+ const popper = ac.$refs.suggestions && ac.$refs.suggestions.$el;
359
+ if (!popper) return;
360
+ const inputWidth = ac.$el.offsetWidth;
361
+ if (inputWidth) {
362
+ popper.style.setProperty(
363
+ "--base-autocomplete-min-width",
364
+ inputWidth + "px"
365
+ );
366
+ }
367
+ const maxWidth = this.dropdownMaxWidth;
368
+ let maxText = "";
369
+ if (typeof maxWidth === "number") {
370
+ maxText = maxWidth + "px";
371
+ } else if (maxWidth) {
372
+ maxText = String(maxWidth);
373
+ }
374
+ if (maxText) {
375
+ popper.style.setProperty("--base-autocomplete-max-width", maxText);
376
+ }
377
+ if (ac.$refs.suggestions.updatePopper) {
378
+ ac.$refs.suggestions.updatePopper();
379
+ }
380
+ });
381
+ },
341
382
  handleBlur(event) {
342
383
  this.focused = false;
343
384
  this.$emit("blur", event);
@@ -410,10 +451,24 @@ export default {
410
451
  display: none;
411
452
  }
412
453
 
454
+ .base-autocomplete-popper.el-autocomplete-suggestion {
455
+ width: auto !important;
456
+ min-width: var(--base-autocomplete-min-width) !important;
457
+ max-width: var(--base-autocomplete-max-width, 480px) !important;
458
+ }
459
+
413
460
  .base-autocomplete-popper {
414
461
  .el-autocomplete-suggestion__list li {
462
+ height: auto;
463
+ padding-top: 6px;
464
+ padding-bottom: 6px;
415
465
  font-size: 13px;
416
466
  line-height: 1.6;
467
+ white-space: normal;
468
+ word-break: break-word;
469
+ overflow-wrap: anywhere;
470
+ overflow: visible;
471
+ text-overflow: unset;
417
472
  }
418
473
  }
419
474