qidian-vue-ui 2.0.30 → 2.0.31

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.
@@ -16,6 +16,9 @@ export declare const QdConfigProvider: import("vue").DefineComponent<{
16
16
  loading?: {
17
17
  text?: string;
18
18
  };
19
+ serviceSelect?: {
20
+ createText?: string;
21
+ };
19
22
  timeFormat?: {
20
23
  seconds?: string;
21
24
  minutes?: string;
@@ -157,6 +160,9 @@ export declare const QdConfigProvider: import("vue").DefineComponent<{
157
160
  loading?: {
158
161
  text?: string;
159
162
  };
163
+ serviceSelect?: {
164
+ createText?: string;
165
+ };
160
166
  timeFormat?: {
161
167
  seconds?: string;
162
168
  minutes?: string;
@@ -283,6 +289,9 @@ export declare const QdConfigProvider: import("vue").DefineComponent<{
283
289
  loading?: {
284
290
  text?: string;
285
291
  };
292
+ serviceSelect?: {
293
+ createText?: string;
294
+ };
286
295
  timeFormat?: {
287
296
  seconds?: string;
288
297
  minutes?: string;
@@ -33,6 +33,9 @@ export interface QdConfigProviderProps {
33
33
  loading?: {
34
34
  text?: string;
35
35
  };
36
+ serviceSelect?: {
37
+ createText?: string;
38
+ };
36
39
  timeFormat?: {
37
40
  seconds?: string;
38
41
  minutes?: string;
@@ -4,6 +4,9 @@ export declare function useConfig<T extends keyof NonNullable<QdConfigProviderPr
4
4
  loading?: {
5
5
  text?: string;
6
6
  };
7
+ serviceSelect?: {
8
+ createText?: string;
9
+ };
7
10
  timeFormat?: {
8
11
  seconds?: string;
9
12
  minutes?: string;
@@ -128,6 +131,9 @@ export declare function useConfig<T extends keyof NonNullable<QdConfigProviderPr
128
131
  loading?: {
129
132
  text?: string;
130
133
  };
134
+ serviceSelect?: {
135
+ createText?: string;
136
+ };
131
137
  timeFormat?: {
132
138
  seconds?: string;
133
139
  minutes?: string;
@@ -252,6 +258,9 @@ export declare function useConfig<T extends keyof NonNullable<QdConfigProviderPr
252
258
  loading?: {
253
259
  text?: string;
254
260
  };
261
+ serviceSelect?: {
262
+ createText?: string;
263
+ };
255
264
  timeFormat?: {
256
265
  seconds?: string;
257
266
  minutes?: string;
@@ -377,6 +386,9 @@ export declare function useConfig<T extends keyof NonNullable<QdConfigProviderPr
377
386
  loading?: {
378
387
  text?: string;
379
388
  };
389
+ serviceSelect?: {
390
+ createText?: string;
391
+ };
380
392
  timeFormat?: {
381
393
  seconds?: string;
382
394
  minutes?: string;
@@ -1,4 +1,4 @@
1
- .qd-service-select__load[data-v-b5b98d92] {
1
+ .qd-service-select__load[data-v-d3c475ee] {
2
2
  width: 100%;
3
3
  border-top: 1px solid var(--td-component-stroke);
4
4
  padding: 6px;
@@ -1,8 +1,10 @@
1
+ import './index2.css'
1
2
  import './index.css'
2
3
  import _sfc_main from "./index.vue2.mjs";
3
4
  /* empty css */
5
+ /* empty css */
4
6
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
5
- const QdServiceSelect = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b5b98d92"]]);
7
+ const QdServiceSelect = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d3c475ee"]]);
6
8
  export {
7
9
  QdServiceSelect as default
8
10
  };
@@ -1,3 +1,4 @@
1
+ import './index2.css'
1
2
  import './index.css'
2
3
  import { defineComponent, mergeDefaults, computed, ref, unref, watch, onMounted, onActivated, onDeactivated, createBlock, openBlock, mergeProps, isRef, createSlots, withCtx, renderSlot, createCommentVNode, renderList, normalizeProps, guardReactiveProps } from "vue";
3
4
  import { useVModels } from "../../node_modules/.pnpm/@vueuse_core@14.2.0_vue@3.5.26_typescript@5.9.3_/node_modules/@vueuse/core/dist/index.mjs";
@@ -148,9 +149,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
148
149
  }
149
150
  }
150
151
  });
151
- const { t } = useConfig("loading");
152
+ const { t: loadingT } = useConfig("loading");
153
+ const { t: serviceSelectT } = useConfig("serviceSelect");
152
154
  const search = ref("");
155
+ const searchPending = ref(false);
153
156
  const autofocus = ref(false);
157
+ const createOptionText = computed(() => JSON.stringify(serviceSelectT("createText")));
154
158
  let autoOpenedOnce = false;
155
159
  const reProps = computed(() => {
156
160
  const {
@@ -174,18 +178,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
174
178
  options: inOptions,
175
179
  valueLabel: valueLabel2,
176
180
  popupProps,
181
+ creatable,
177
182
  filterable,
178
183
  filter,
179
184
  autofocus: autofocus2,
180
185
  onSearch,
186
+ onInputChange,
181
187
  onPopupVisibleChange,
182
188
  onFocus,
189
+ onCreate,
183
190
  onChange,
184
191
  ...selectOptions
185
192
  } = props;
186
193
  const mergedManual = manual ?? unref(pagination) !== false;
187
194
  const rePopupProps = {
188
195
  ...popupProps,
196
+ overlayClassName: ["qd-service-select__popup", popupProps?.overlayClassName],
197
+ overlayStyle: (triggerElement, popupElement) => ({
198
+ ...typeof popupProps?.overlayStyle === "function" ? popupProps.overlayStyle(triggerElement, popupElement) : popupProps?.overlayStyle,
199
+ "--qd-service-select-create-text": createOptionText.value
200
+ }),
189
201
  onScrollToBottom: (context) => {
190
202
  popupProps?.onScrollToBottom?.(context);
191
203
  if (loading.value || noMore.value) return;
@@ -198,6 +210,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
198
210
  if (!service) return;
199
211
  refresh();
200
212
  };
213
+ const reOnInputChange = (value, context) => {
214
+ onInputChange?.(value, context);
215
+ search.value = String(value ?? "").trim();
216
+ searchPending.value = !!service && !!search.value;
217
+ };
201
218
  const reOnPopupVisibleChange = (visible, context) => {
202
219
  onPopupVisibleChange?.(visible, context);
203
220
  if (!service || loading.value) return;
@@ -213,6 +230,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
213
230
  popupVisible.value = true;
214
231
  }
215
232
  };
233
+ const reOnCreate = (value) => {
234
+ if (!reCreatable.value) return;
235
+ onCreate?.(value);
236
+ };
216
237
  const reOnChange = (value, context) => {
217
238
  onChange?.(value, context);
218
239
  const { selectOptions: selectOptions2 } = reProps.value;
@@ -244,14 +265,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
244
265
  defaultSelectFirst,
245
266
  fillOptions,
246
267
  convStr,
268
+ creatable,
247
269
  selectOptions: {
248
270
  ...selectOptions,
249
271
  filterable: reFilterable,
250
272
  filter: reFilter,
251
273
  popupProps: rePopupProps,
252
274
  onSearch: reOnSearch,
275
+ onInputChange: reOnInputChange,
253
276
  onPopupVisibleChange: reOnPopupVisibleChange,
254
277
  onFocus: reOnFocus,
278
+ onCreate: reOnCreate,
255
279
  onChange: reOnChange
256
280
  },
257
281
  serviceOptions: {
@@ -301,6 +325,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
301
325
  onBefore: () => {
302
326
  reProps.value.serviceOptions.onBefore?.();
303
327
  },
328
+ onAfter: () => {
329
+ searchPending.value = false;
330
+ reProps.value.serviceOptions.onAfter?.();
331
+ },
304
332
  onSuccess: (res) => {
305
333
  reProps.value.serviceOptions.onSuccess?.(res);
306
334
  const list = data.value?.list || [];
@@ -322,6 +350,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
322
350
  }
323
351
  });
324
352
  const selectLoad = computed(() => reProps.value.externalLoad || firstLoad.value);
353
+ const reCreatable = computed(() => {
354
+ if (!reProps.value.creatable || !reProps.value.selectOptions.filterable || selectLoad.value || loading.value || searchPending.value) {
355
+ return false;
356
+ }
357
+ const value = search.value;
358
+ if (!value) return false;
359
+ const labelKey = reProps.value.selectOptions.keys?.label || qdServiceSelectKeys.label;
360
+ return !options.value?.some(
361
+ (option) => String(option[labelKey] ?? "").trim() === value
362
+ );
363
+ });
325
364
  function handleFilter(filterWords, option) {
326
365
  if (!filterWords) return true;
327
366
  if ("value" in option) {
@@ -335,6 +374,30 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
335
374
  const value = filterWords.trim().toLowerCase();
336
375
  return option.label.toLowerCase().includes(value);
337
376
  }
377
+ function getSelectedOptions(value) {
378
+ const values = Array.isArray(value) ? value : [value];
379
+ const valueKey = reProps.value.selectOptions.keys?.value || qdServiceSelectKeys.value;
380
+ return (options.value || []).filter(
381
+ (option) => values.some(
382
+ (item) => typeof item === "object" && item !== null ? item[valueKey] === option[valueKey] : item === option[valueKey]
383
+ )
384
+ );
385
+ }
386
+ function handleKeydownCapture(event) {
387
+ if (event.key !== "Enter" || event.isComposing || !reCreatable.value) return;
388
+ event.preventDefault();
389
+ event.stopImmediatePropagation();
390
+ const value = search.value;
391
+ const { multiple, onEnter, onCreate, onChange } = reProps.value.selectOptions;
392
+ const currentValue = reModelValue.value;
393
+ const selectedOptions = getSelectedOptions(currentValue);
394
+ const nextValue = multiple ? [...Array.isArray(currentValue) ? currentValue : [], value] : value;
395
+ onEnter?.({ inputValue: value, e: event, value: currentValue });
396
+ onCreate?.(value);
397
+ reModelValue.value = nextValue;
398
+ onChange?.(nextValue, { selectedOptions, trigger: "check", e: event });
399
+ popupVisible.value = false;
400
+ }
338
401
  function setAutoSelectedWatch() {
339
402
  if (!reProps.value.defaultSelectFirst) return;
340
403
  unWatchAutoSelected = watch(options, setDefaultSelectFirst, { immediate: true });
@@ -409,13 +472,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
409
472
  }, {
410
473
  ...reProps.value.selectOptions,
411
474
  ..._ctx.$slots.default ? {} : { options: unref(options) }
475
+ }, {
476
+ creatable: reCreatable.value,
477
+ onKeydownCapture: handleKeydownCapture
412
478
  }), createSlots({
413
479
  "panel-bottom-content": withCtx(() => [
414
480
  unref(loading) && !unref(firstLoad) ? (openBlock(), createBlock(unref(Loading), {
415
481
  key: 0,
416
482
  class: "qd-service-select__load",
417
483
  size: "small",
418
- text: unref(t)("text")
484
+ text: unref(loadingT)("text")
419
485
  }, null, 8, ["text"])) : _ctx.$slots["panel-bottom-content"] ? renderSlot(_ctx.$slots, "panel-bottom-content", { key: 1 }, void 0, true) : createCommentVNode("", true)
420
486
  ]),
421
487
  default: withCtx(() => [
@@ -433,7 +499,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
433
499
  ])
434
500
  };
435
501
  })
436
- ]), 1040, ["modelValue", "input", "popup-visible", "autofocus", "loading"]);
502
+ ]), 1040, ["modelValue", "input", "popup-visible", "autofocus", "loading", "creatable"]);
437
503
  };
438
504
  }
439
505
  });
@@ -0,0 +1,6 @@
1
+ .qd-service-select__popup .t-select__create-option--special > span::before {
2
+ content: var(--qd-service-select-create-text) '“';
3
+ }
4
+ .qd-service-select__popup .t-select__create-option--special > span::after {
5
+ content: '”';
6
+ }
@@ -265,6 +265,9 @@ declare const _default: {
265
265
  loading: {
266
266
  text: string;
267
267
  };
268
+ serviceSelect: {
269
+ createText: string;
270
+ };
268
271
  timeFormat: {
269
272
  seconds: string;
270
273
  minutes: string;
@@ -4,6 +4,9 @@ const enUS = merge(enUS$1, {
4
4
  loading: {
5
5
  text: "loading"
6
6
  },
7
+ serviceSelect: {
8
+ createText: "Create "
9
+ },
7
10
  timeFormat: {
8
11
  seconds: "Seconds",
9
12
  minutes: "Minutes",
@@ -265,6 +265,9 @@ declare const _default: {
265
265
  loading: {
266
266
  text: string;
267
267
  };
268
+ serviceSelect: {
269
+ createText: string;
270
+ };
268
271
  timeFormat: {
269
272
  seconds: string;
270
273
  minutes: string;
@@ -4,6 +4,9 @@ const zhCN = merge(zhCN$1, {
4
4
  loading: {
5
5
  text: "加载中"
6
6
  },
7
+ serviceSelect: {
8
+ createText: "创建"
9
+ },
7
10
  timeFormat: {
8
11
  seconds: "秒",
9
12
  minutes: "分钟",
@@ -265,6 +265,9 @@ declare const _default: {
265
265
  loading: {
266
266
  text: string;
267
267
  };
268
+ serviceSelect: {
269
+ createText: string;
270
+ };
268
271
  timeFormat: {
269
272
  seconds: string;
270
273
  minutes: string;
@@ -4,6 +4,9 @@ const zhTW = merge(zhTW$1, {
4
4
  loading: {
5
5
  text: "載入中"
6
6
  },
7
+ serviceSelect: {
8
+ createText: "建立"
9
+ },
7
10
  timeFormat: {
8
11
  seconds: "秒",
9
12
  minutes: "分鐘",
@@ -174,9 +174,12 @@ p {
174
174
  .t-table__cell--title {
175
175
  justify-content: space-between;
176
176
  }
177
- .t-table__body > tr > td .t-input__extra {
177
+ .t-table__body > tr > td > .t-form__item:last-child {
178
+ margin-bottom: 0 !important;
179
+ }
180
+ .t-table__body > tr > td > .t-form__item:last-child .t-form__controls > .t-input__extra {
178
181
  position: initial;
179
- text-align: left;
182
+ bottom: auto;
180
183
  }
181
184
  .t-table__content tbody > tr:last-child:not(.t-table__empty-row) > td,
182
185
  .t-table__content tfoot > tr:last-child > td {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qidian-vue-ui",
3
- "version": "2.0.30",
3
+ "version": "2.0.31",
4
4
  "description": "基于 TDesign 的 QiDian Vue UI 组件库",
5
5
  "author": "qidian",
6
6
  "license": "MIT",