@v-c/select 1.2.1 → 1.2.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.
@@ -1,7 +1,7 @@
1
1
  import { AlignType, BuildInPlacements } from '@v-c/trigger';
2
2
  import { VueNode } from '@v-c/util/dist/type';
3
3
  import { ScrollConfig, ScrollTo } from '@v-c/virtual-list';
4
- import { CSSProperties } from 'vue';
4
+ import { CSSProperties, StyleValue } from 'vue';
5
5
  import { ComponentsConfig } from '../hooks';
6
6
  import { DisplayInfoType, DisplayValueType, Mode, Placement, RawValueType, RenderDOMFunc, RenderNode } from '../interface';
7
7
  export type BaseSelectSemanticName = 'prefix' | 'suffix' | 'input' | 'clear' | 'placeholder' | 'content' | 'item' | 'itemContent' | 'itemRemove';
@@ -62,7 +62,7 @@ export interface BaseSelectPrivateProps {
62
62
  export type BaseSelectPropsWithoutPrivate = Omit<BaseSelectProps, keyof BaseSelectPrivateProps>;
63
63
  export interface BaseSelectProps extends BaseSelectPrivateProps {
64
64
  className?: string;
65
- style?: CSSProperties;
65
+ style?: StyleValue;
66
66
  classNames?: Partial<Record<BaseSelectSemanticName, string>>;
67
67
  styles?: Partial<Record<BaseSelectSemanticName, CSSProperties>>;
68
68
  showSearch?: boolean;
@@ -390,7 +390,13 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
390
390
  default: void 0
391
391
  },
392
392
  style: {
393
- type: Object,
393
+ type: [
394
+ Boolean,
395
+ null,
396
+ String,
397
+ Object,
398
+ Array
399
+ ],
394
400
  required: false,
395
401
  default: void 0
396
402
  },
@@ -425,6 +431,15 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
425
431
  default: void 0
426
432
  },
427
433
  placeholder: {
434
+ type: [
435
+ Object,
436
+ Function,
437
+ String,
438
+ Number,
439
+ null,
440
+ Boolean,
441
+ Array
442
+ ],
428
443
  required: false,
429
444
  default: void 0
430
445
  },
@@ -444,6 +459,15 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
444
459
  default: void 0
445
460
  },
446
461
  notFoundContent: {
462
+ type: [
463
+ Object,
464
+ Function,
465
+ String,
466
+ Number,
467
+ null,
468
+ Boolean,
469
+ Array
470
+ ],
447
471
  required: false,
448
472
  default: void 0
449
473
  },
@@ -518,9 +542,16 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
518
542
  default: void 0
519
543
  },
520
544
  maxTagPlaceholder: {
521
- type: Function,
545
+ type: [
546
+ Object,
547
+ Function,
548
+ String,
549
+ Number,
550
+ null,
551
+ Boolean,
552
+ Array
553
+ ],
522
554
  required: false,
523
- skipCheck: true,
524
555
  default: void 0
525
556
  },
526
557
  tokenSeparators: {
@@ -534,29 +565,68 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
534
565
  default: void 0
535
566
  },
536
567
  prefix: {
568
+ type: [
569
+ Object,
570
+ Function,
571
+ String,
572
+ Number,
573
+ null,
574
+ Boolean,
575
+ Array
576
+ ],
537
577
  required: false,
538
578
  default: void 0
539
579
  },
540
580
  suffixIcon: {
541
- type: Function,
581
+ type: [
582
+ Object,
583
+ Function,
584
+ String,
585
+ Number,
586
+ null,
587
+ Boolean,
588
+ Array
589
+ ],
542
590
  required: false,
543
- skipCheck: true,
544
591
  default: void 0
545
592
  },
546
593
  suffix: {
547
- type: Function,
594
+ type: [
595
+ Object,
596
+ Function,
597
+ String,
598
+ Number,
599
+ null,
600
+ Boolean,
601
+ Array
602
+ ],
548
603
  required: false,
549
- skipCheck: true,
550
604
  default: void 0
551
605
  },
552
606
  clearIcon: {
607
+ type: [
608
+ Object,
609
+ Function,
610
+ String,
611
+ Number,
612
+ null,
613
+ Boolean,
614
+ Array
615
+ ],
553
616
  required: false,
554
617
  default: void 0
555
618
  },
556
619
  removeIcon: {
557
- type: Function,
620
+ type: [
621
+ Object,
622
+ Function,
623
+ String,
624
+ Number,
625
+ null,
626
+ Boolean,
627
+ Array
628
+ ],
558
629
  required: false,
559
- skipCheck: true,
560
630
  default: void 0
561
631
  },
562
632
  animation: {
@@ -590,6 +660,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
590
660
  default: void 0
591
661
  },
592
662
  popupAlign: {
663
+ type: Object,
593
664
  required: false,
594
665
  default: void 0
595
666
  },
@@ -599,6 +670,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
599
670
  default: void 0
600
671
  },
601
672
  builtinPlacements: {
673
+ type: Object,
602
674
  required: false,
603
675
  default: void 0
604
676
  },
@@ -145,6 +145,23 @@ var OptionList = /* @__PURE__ */ defineComponent({
145
145
  }
146
146
  };
147
147
  const onKeyUp = () => {};
148
+ const optionPositionInfo = computed(() => {
149
+ let count = 0;
150
+ let group = null;
151
+ const positions = [];
152
+ const groups = [];
153
+ memoFlattenOptions.value.forEach((item) => {
154
+ if (item.group) {
155
+ group = item;
156
+ positions.push(count);
157
+ groups.push(null);
158
+ } else {
159
+ positions.push(count += 1);
160
+ groups.push(item.groupOption ? group : null);
161
+ }
162
+ });
163
+ return [positions, groups];
164
+ });
148
165
  expose({
149
166
  onKeyDown,
150
167
  onKeyUp,
@@ -170,18 +187,49 @@ var OptionList = /* @__PURE__ */ defineComponent({
170
187
  id: `${id}_list_${index}`
171
188
  };
172
189
  }
190
+ const [optionPositions, itemGroups] = optionPositionInfo.value;
173
191
  const renderItem = (index) => {
174
192
  const item = memoFlattenOptions.value[index];
175
193
  if (!item) return null;
176
194
  const itemData = item.data || {};
177
195
  const { value, disabled } = itemData;
178
- const { group } = item;
179
196
  const attrs = pickAttrs(itemData, true);
180
197
  const mergedLabel = getLabel(item);
181
- return item ? createVNode("div", mergeProps({ "aria-label": typeof mergedLabel === "string" && !group ? mergedLabel : void 0 }, attrs, { "key": index }, getItemAriaProps(item, index), {
198
+ return createVNode("div", mergeProps({
199
+ "aria-label": isTitleType(mergedLabel) ? String(mergedLabel) : void 0,
200
+ "aria-setsize": optionPositions[optionPositions.length - 1] ?? 0,
201
+ "aria-posinset": optionPositions[index]
202
+ }, attrs, { "key": index }, getItemAriaProps(item, index), {
182
203
  "aria-selected": isAriaSelected(value),
183
204
  "aria-disabled": disabled
184
- }), [value]) : null;
205
+ }), [value]);
206
+ };
207
+ const renderHiddenItems = () => {
208
+ const segments = [];
209
+ [
210
+ activeIndex.value - 1,
211
+ activeIndex.value,
212
+ activeIndex.value + 1
213
+ ].forEach((index) => {
214
+ const item = memoFlattenOptions.value[index];
215
+ if (!item || item.group) return;
216
+ const groupItem = itemGroups[index];
217
+ const lastSegment = segments[segments.length - 1];
218
+ if (lastSegment && lastSegment.group === groupItem) lastSegment.indexes.push(index);
219
+ else segments.push({
220
+ group: groupItem,
221
+ indexes: [index]
222
+ });
223
+ });
224
+ return segments.map(({ group, indexes }) => {
225
+ if (!group) return indexes.map(renderItem);
226
+ const groupLabel = getLabel(group);
227
+ return createVNode("div", {
228
+ "key": group.key,
229
+ "role": "group",
230
+ "aria-label": group.data.title ?? (isTitleType(groupLabel) ? String(groupLabel) : void 0)
231
+ }, [indexes.map(renderItem)]);
232
+ });
185
233
  };
186
234
  const a11yProps = {
187
235
  role: "listbox",
@@ -191,11 +239,7 @@ var OptionList = /* @__PURE__ */ defineComponent({
191
239
  height: 0,
192
240
  width: 0,
193
241
  overflow: "hidden"
194
- } }), [
195
- renderItem(activeIndex.value - 1),
196
- renderItem(activeIndex.value),
197
- renderItem(activeIndex.value + 1)
198
- ]), createVNode(List, mergeProps({
242
+ } }), [renderHiddenItems()]), createVNode(List, mergeProps({
199
243
  "prefixCls": `${baseProps.value?.prefixCls}-dropdown-list`,
200
244
  "itemKey": "key",
201
245
  "ref": (el) => {
package/dist/Select.js CHANGED
@@ -172,9 +172,16 @@ var Select = /* @__PURE__ */ defineComponent({
172
172
  default: void 0
173
173
  },
174
174
  menuItemSelectedIcon: {
175
- type: Function,
175
+ type: [
176
+ Object,
177
+ Function,
178
+ String,
179
+ Number,
180
+ null,
181
+ Boolean,
182
+ Array
183
+ ],
176
184
  required: false,
177
- skipCheck: true,
178
185
  default: void 0
179
186
  },
180
187
  mode: {
@@ -221,7 +228,13 @@ var Select = /* @__PURE__ */ defineComponent({
221
228
  default: void 0
222
229
  },
223
230
  style: {
224
- type: Object,
231
+ type: [
232
+ Boolean,
233
+ null,
234
+ String,
235
+ Object,
236
+ Array
237
+ ],
225
238
  required: false,
226
239
  default: void 0
227
240
  },
@@ -236,6 +249,15 @@ var Select = /* @__PURE__ */ defineComponent({
236
249
  default: void 0
237
250
  },
238
251
  placeholder: {
252
+ type: [
253
+ Object,
254
+ Function,
255
+ String,
256
+ Number,
257
+ null,
258
+ Boolean,
259
+ Array
260
+ ],
239
261
  required: false,
240
262
  default: void 0
241
263
  },
@@ -250,6 +272,15 @@ var Select = /* @__PURE__ */ defineComponent({
250
272
  default: void 0
251
273
  },
252
274
  notFoundContent: {
275
+ type: [
276
+ Object,
277
+ Function,
278
+ String,
279
+ Number,
280
+ null,
281
+ Boolean,
282
+ Array
283
+ ],
253
284
  required: false,
254
285
  default: void 0
255
286
  },
@@ -319,9 +350,16 @@ var Select = /* @__PURE__ */ defineComponent({
319
350
  default: void 0
320
351
  },
321
352
  maxTagPlaceholder: {
322
- type: Function,
353
+ type: [
354
+ Object,
355
+ Function,
356
+ String,
357
+ Number,
358
+ null,
359
+ Boolean,
360
+ Array
361
+ ],
323
362
  required: false,
324
- skipCheck: true,
325
363
  default: void 0
326
364
  },
327
365
  tokenSeparators: {
@@ -335,29 +373,68 @@ var Select = /* @__PURE__ */ defineComponent({
335
373
  default: void 0
336
374
  },
337
375
  prefix: {
376
+ type: [
377
+ Object,
378
+ Function,
379
+ String,
380
+ Number,
381
+ null,
382
+ Boolean,
383
+ Array
384
+ ],
338
385
  required: false,
339
386
  default: void 0
340
387
  },
341
388
  suffixIcon: {
342
- type: Function,
389
+ type: [
390
+ Object,
391
+ Function,
392
+ String,
393
+ Number,
394
+ null,
395
+ Boolean,
396
+ Array
397
+ ],
343
398
  required: false,
344
- skipCheck: true,
345
399
  default: void 0
346
400
  },
347
401
  suffix: {
348
- type: Function,
402
+ type: [
403
+ Object,
404
+ Function,
405
+ String,
406
+ Number,
407
+ null,
408
+ Boolean,
409
+ Array
410
+ ],
349
411
  required: false,
350
- skipCheck: true,
351
412
  default: void 0
352
413
  },
353
414
  clearIcon: {
415
+ type: [
416
+ Object,
417
+ Function,
418
+ String,
419
+ Number,
420
+ null,
421
+ Boolean,
422
+ Array
423
+ ],
354
424
  required: false,
355
425
  default: void 0
356
426
  },
357
427
  removeIcon: {
358
- type: Function,
428
+ type: [
429
+ Object,
430
+ Function,
431
+ String,
432
+ Number,
433
+ null,
434
+ Boolean,
435
+ Array
436
+ ],
359
437
  required: false,
360
- skipCheck: true,
361
438
  default: void 0
362
439
  },
363
440
  animation: {
@@ -391,6 +468,7 @@ var Select = /* @__PURE__ */ defineComponent({
391
468
  default: void 0
392
469
  },
393
470
  popupAlign: {
471
+ type: Object,
394
472
  required: false,
395
473
  default: void 0
396
474
  },
@@ -400,6 +478,7 @@ var Select = /* @__PURE__ */ defineComponent({
400
478
  default: void 0
401
479
  },
402
480
  builtinPlacements: {
481
+ type: Object,
403
482
  required: false,
404
483
  default: void 0
405
484
  },
@@ -1,5 +1,5 @@
1
1
  import { VueNode } from '@v-c/util/dist/type';
2
- import { CSSProperties } from 'vue';
2
+ import { StyleValue } from 'vue';
3
3
  import { ComponentsConfig } from '../hooks';
4
4
  import { DisplayValueType, Mode, RenderNode } from '../interface';
5
5
  export interface SelectInputRef {
@@ -32,7 +32,7 @@ export interface SelectInputProps {
32
32
  /** Check if `tokenSeparators` contains `\n` or `\r\n` */
33
33
  tokenWithEnter?: boolean;
34
34
  className?: string;
35
- style?: CSSProperties;
35
+ style?: StyleValue;
36
36
  focused?: boolean;
37
37
  components: ComponentsConfig;
38
38
  onFocus?: (event: FocusEvent) => void;
@@ -178,14 +178,41 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
178
178
  required: true
179
179
  },
180
180
  prefix: {
181
+ type: [
182
+ Object,
183
+ Function,
184
+ String,
185
+ Number,
186
+ null,
187
+ Boolean,
188
+ Array
189
+ ],
181
190
  required: false,
182
191
  default: void 0
183
192
  },
184
193
  suffix: {
194
+ type: [
195
+ Object,
196
+ Function,
197
+ String,
198
+ Number,
199
+ null,
200
+ Boolean,
201
+ Array
202
+ ],
185
203
  required: false,
186
204
  default: void 0
187
205
  },
188
206
  clearIcon: {
207
+ type: [
208
+ Object,
209
+ Function,
210
+ String,
211
+ Number,
212
+ null,
213
+ Boolean,
214
+ Array
215
+ ],
189
216
  required: false,
190
217
  default: void 0
191
218
  },
@@ -195,9 +222,16 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
195
222
  default: void 0
196
223
  },
197
224
  removeIcon: {
198
- type: Function,
225
+ type: [
226
+ Object,
227
+ Function,
228
+ String,
229
+ Number,
230
+ null,
231
+ Boolean,
232
+ Array
233
+ ],
199
234
  required: false,
200
- skipCheck: true,
201
235
  default: void 0
202
236
  },
203
237
  multiple: {
@@ -210,6 +244,15 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
210
244
  required: true
211
245
  },
212
246
  placeholder: {
247
+ type: [
248
+ Object,
249
+ Function,
250
+ String,
251
+ Number,
252
+ null,
253
+ Boolean,
254
+ Array
255
+ ],
213
256
  required: false,
214
257
  default: void 0
215
258
  },
@@ -284,7 +327,13 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
284
327
  default: void 0
285
328
  },
286
329
  style: {
287
- type: Object,
330
+ type: [
331
+ Boolean,
332
+ null,
333
+ String,
334
+ Object,
335
+ Array
336
+ ],
288
337
  required: false,
289
338
  default: void 0
290
339
  },
@@ -114,6 +114,7 @@ var SelectTrigger = /* @__PURE__ */ defineComponent((props, { slots, attrs, expo
114
114
  default: void 0
115
115
  },
116
116
  builtinPlacements: {
117
+ type: Object,
117
118
  required: false,
118
119
  default: void 0
119
120
  },
@@ -148,6 +149,7 @@ var SelectTrigger = /* @__PURE__ */ defineComponent((props, { slots, attrs, expo
148
149
  default: void 0
149
150
  },
150
151
  popupAlign: {
152
+ type: Object,
151
153
  required: false,
152
154
  default: void 0
153
155
  },
package/dist/TransBtn.js CHANGED
@@ -43,9 +43,16 @@ var TransBtn = /* @__PURE__ */ defineComponent((props, { slots }) => {
43
43
  default: void 0
44
44
  },
45
45
  customizeIcon: {
46
- type: Function,
46
+ type: [
47
+ Object,
48
+ Function,
49
+ String,
50
+ Number,
51
+ null,
52
+ Boolean,
53
+ Array
54
+ ],
47
55
  required: false,
48
- skipCheck: true,
49
56
  default: void 0
50
57
  },
51
58
  customizeIconProps: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/select",
3
3
  "type": "module",
4
- "version": "1.2.1",
4
+ "version": "1.2.2",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "MIT",
@@ -35,9 +35,9 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@v-c/overflow": "^1.1.1",
38
- "@v-c/util": "^1.1.0",
38
+ "@v-c/trigger": "^1.1.0",
39
39
  "@v-c/virtual-list": "^1.1.1",
40
- "@v-c/trigger": "^1.1.0"
40
+ "@v-c/util": "^1.1.0"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "vite build",