@hoci/core 0.5.9 → 0.6.0

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/dist/index.cjs CHANGED
@@ -54,7 +54,7 @@ function getTargetRect(target) {
54
54
  const useAffix = shared.defineHookComponent({
55
55
  props: affixProps,
56
56
  setup(props, { emit }) {
57
- const wrapperRef = vue.ref(null);
57
+ const wrapperRef = vue.ref();
58
58
  const wrapperRect = shared.toReactive(core.useElementBounding(wrapperRef));
59
59
  const parentRef = vue.inject(AFFIX_TARGET_KEY, void 0);
60
60
  const targetRef = shared.useElement(props.target, parentRef);
@@ -166,7 +166,7 @@ const selectionProps = shared.defineHookProps({
166
166
  * 多选模式
167
167
  */
168
168
  multiple: {
169
- type: [Boolean, Number],
169
+ type: [Boolean, Number, Array],
170
170
  default: () => false
171
171
  },
172
172
  /**
@@ -207,7 +207,8 @@ function useSelectionContext() {
207
207
  itemClass: "",
208
208
  activateEvent: sharedConfig.activateEvent,
209
209
  label: null,
210
- multiple: false
210
+ multiple: false,
211
+ limit: [0, Number.POSITIVE_INFINITY]
211
212
  });
212
213
  }
213
214
  const useSelectionList = shared.defineHookComponent({
@@ -248,16 +249,26 @@ const useSelectionList = shared.defineHookComponent({
248
249
  function isActive(value) {
249
250
  return actives.includes(value);
250
251
  }
252
+ const multipleActive = vue.computed(() => !!props.multiple);
253
+ const multipleLimit = vue.computed(() => {
254
+ if (Array.isArray(props.multiple)) {
255
+ if (props.multiple[1] === void 0) {
256
+ return [props.multiple[0], Number.POSITIVE_INFINITY];
257
+ }
258
+ return props.multiple;
259
+ }
260
+ return [0, Number.POSITIVE_INFINITY];
261
+ });
251
262
  function activate(value) {
263
+ const [min, max] = multipleLimit.value;
252
264
  if (isActive(value)) {
253
- if (props.multiple || props.clearable) {
265
+ if (multipleActive.value && actives.length > min || props.clearable) {
254
266
  actives.splice(actives.indexOf(value), 1);
255
267
  emitChange();
256
268
  }
257
269
  } else {
258
270
  if (props.multiple) {
259
- const limit = typeof props.multiple === "number" ? props.multiple : Number.POSITIVE_INFINITY;
260
- if (actives.length < limit) {
271
+ if (actives.length < max) {
261
272
  actives.push(value);
262
273
  emitChange();
263
274
  }
@@ -295,7 +306,8 @@ const useSelectionList = shared.defineHookComponent({
295
306
  disabledClass: vue.computed(() => tslx.cls(props.disabledClass)),
296
307
  itemClass: vue.computed(() => tslx.cls(props.itemClass)),
297
308
  label: vue.computed(() => props.label),
298
- multiple: vue.computed(() => props.multiple),
309
+ multiple: multipleActive,
310
+ limit: multipleLimit,
299
311
  clearable: vue.computed(() => props.clearable),
300
312
  defaultValue: vue.computed(() => props.defaultValue),
301
313
  activateEvent: vue.computed(() => props.activateEvent ?? sharedConfig.activateEvent),
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _hoci_shared from '@hoci/shared';
2
- import { ElementLike, ActivateEvent } from '@hoci/shared';
2
+ import { ElementLike, ActivateEvent, SharedConfig } from '@hoci/shared';
3
3
  export * from '@hoci/shared';
4
4
  import * as vue from 'vue';
5
5
  import { PropType, InjectionKey, MaybeRefOrGetter, Ref, CSSProperties as CSSProperties$1 } from 'vue';
@@ -30,7 +30,7 @@ declare const affixProps: {
30
30
  * @en Scroll container, default is `window`
31
31
  */
32
32
  target: {
33
- type: PropType<string | HTMLElement>;
33
+ type: PropType<string | Element | (() => Element | null | undefined)>;
34
34
  };
35
35
  /**
36
36
  * @zh z-index 值
@@ -46,7 +46,7 @@ declare const affixEmits: ("scroll" | "change")[];
46
46
  declare const AFFIX_TARGET_KEY: InjectionKey<MaybeRefOrGetter<Element | null | undefined>>;
47
47
  declare const useAffix: _hoci_shared.HookComponent<{
48
48
  className: vue.ComputedRef<string>;
49
- wrapperRef: Ref<HTMLElement | null>;
49
+ wrapperRef: Ref<HTMLElement | undefined>;
50
50
  containerRef: vue.ComputedRef<Element | (Window & typeof globalThis) | null>;
51
51
  isFixed: Ref<boolean>;
52
52
  placeholderStyle: Ref<CSSProperties>;
@@ -77,7 +77,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
77
77
  * @en Scroll container, default is `window`
78
78
  */
79
79
  target: {
80
- type: PropType<string | HTMLElement>;
80
+ type: PropType<string | Element | (() => Element | null | undefined)>;
81
81
  };
82
82
  /**
83
83
  * @zh z-index 值
@@ -112,7 +112,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
112
112
  * @en Scroll container, default is `window`
113
113
  */
114
114
  target: {
115
- type: PropType<string | HTMLElement>;
115
+ type: PropType<string | Element | (() => Element | null | undefined)>;
116
116
  };
117
117
  /**
118
118
  * @zh z-index 值
@@ -153,7 +153,8 @@ interface HiSelectionContext {
153
153
  unactiveClass: string;
154
154
  disabledClass: string;
155
155
  label: string | ((_: any) => ElementLike | null | undefined) | null | undefined;
156
- multiple: boolean | number;
156
+ multiple: boolean;
157
+ limit: [number, number];
157
158
  }
158
159
  declare const selectionProps: {
159
160
  modelValue: {
@@ -189,7 +190,7 @@ declare const selectionProps: {
189
190
  * 多选模式
190
191
  */
191
192
  multiple: {
192
- type: (NumberConstructor | BooleanConstructor)[];
193
+ type: PropType<boolean | number | [number, number?]>;
193
194
  default: () => false;
194
195
  };
195
196
  /**
@@ -211,8 +212,8 @@ declare const selectionEmits: ("change" | "load" | "unload" | "update:modelValue
211
212
  declare function useSelectionContext(): HiSelectionContext;
212
213
  declare const useSelectionList: _hoci_shared.HookComponent<{
213
214
  options: {
214
- id?: string | undefined;
215
- label?: string | undefined;
215
+ id?: string;
216
+ label?: string;
216
217
  value: any | null;
217
218
  render: () => ElementLike;
218
219
  }[];
@@ -257,7 +258,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
257
258
  * 多选模式
258
259
  */
259
260
  multiple: {
260
- type: (NumberConstructor | BooleanConstructor)[];
261
+ type: PropType<boolean | number | [number, number?]>;
261
262
  default: () => false;
262
263
  };
263
264
  /**
@@ -307,7 +308,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
307
308
  * 多选模式
308
309
  */
309
310
  multiple: {
310
- type: (NumberConstructor | BooleanConstructor)[];
311
+ type: PropType<boolean | number | [number, number?]>;
311
312
  default: () => false;
312
313
  };
313
314
  /**
@@ -324,7 +325,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
324
325
  type: PropType<ActivateEvent>;
325
326
  };
326
327
  }>, {
327
- multiple: number | boolean;
328
+ multiple: number | boolean | [number, (number | undefined)?];
328
329
  modelValue: any;
329
330
  activeClass: string | string[] | Record<string, boolean>;
330
331
  itemClass: string | string[] | Record<string, boolean>;
@@ -345,7 +346,7 @@ declare const itemProps: {
345
346
  default(): string;
346
347
  };
347
348
  label: {
348
- type: PropType<ElementLike | ((val: any) => string) | null>;
349
+ type: PropType<string | ((val: any) => string) | ElementLike | null>;
349
350
  };
350
351
  keepAlive: {
351
352
  type: BooleanConstructor;
@@ -376,7 +377,7 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
376
377
  default(): string;
377
378
  };
378
379
  label: {
379
- type: PropType<ElementLike | ((val: any) => string) | null>;
380
+ type: PropType<string | ((val: any) => string) | ElementLike | null>;
380
381
  };
381
382
  keepAlive: {
382
383
  type: BooleanConstructor;
@@ -395,7 +396,7 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
395
396
  default(): string;
396
397
  };
397
398
  label: {
398
- type: PropType<ElementLike | ((val: any) => string) | null>;
399
+ type: PropType<string | ((val: any) => string) | ElementLike | null>;
399
400
  };
400
401
  keepAlive: {
401
402
  type: BooleanConstructor;
@@ -581,13 +582,10 @@ declare const useIcon: _hoci_shared.HookComponent<{
581
582
 
582
583
  declare const configProviderProps: {
583
584
  icon: {
584
- type: PropType<Partial<{
585
- size: number | undefined;
586
- sizeUnit: string | undefined;
587
- }>>;
585
+ type: PropType<Partial<SharedConfig["icon"]>>;
588
586
  };
589
587
  activateEvent: {
590
- type: PropType<Partial<_hoci_shared.ActivateEvent>>;
588
+ type: PropType<Partial<SharedConfig["activateEvent"]>>;
591
589
  };
592
590
  };
593
591
 
@@ -622,7 +620,7 @@ declare const popoverProps: {
622
620
  default: () => false;
623
621
  };
624
622
  teleport: {
625
- type: PropType<string | boolean | HTMLElement>;
623
+ type: PropType<string | HTMLElement | boolean>;
626
624
  default: () => true;
627
625
  };
628
626
  };
@@ -682,7 +680,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
682
680
  default: () => false;
683
681
  };
684
682
  teleport: {
685
- type: PropType<string | boolean | HTMLElement>;
683
+ type: PropType<string | HTMLElement | boolean>;
686
684
  default: () => true;
687
685
  };
688
686
  }, vue.ExtractPropTypes<{
@@ -714,7 +712,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
714
712
  default: () => false;
715
713
  };
716
714
  teleport: {
717
- type: PropType<string | boolean | HTMLElement>;
715
+ type: PropType<string | HTMLElement | boolean>;
718
716
  default: () => true;
719
717
  };
720
718
  }>, {
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _hoci_shared from '@hoci/shared';
2
- import { ElementLike, ActivateEvent } from '@hoci/shared';
2
+ import { ElementLike, ActivateEvent, SharedConfig } from '@hoci/shared';
3
3
  export * from '@hoci/shared';
4
4
  import * as vue from 'vue';
5
5
  import { PropType, InjectionKey, MaybeRefOrGetter, Ref, CSSProperties as CSSProperties$1 } from 'vue';
@@ -30,7 +30,7 @@ declare const affixProps: {
30
30
  * @en Scroll container, default is `window`
31
31
  */
32
32
  target: {
33
- type: PropType<string | HTMLElement>;
33
+ type: PropType<string | Element | (() => Element | null | undefined)>;
34
34
  };
35
35
  /**
36
36
  * @zh z-index 值
@@ -46,7 +46,7 @@ declare const affixEmits: ("scroll" | "change")[];
46
46
  declare const AFFIX_TARGET_KEY: InjectionKey<MaybeRefOrGetter<Element | null | undefined>>;
47
47
  declare const useAffix: _hoci_shared.HookComponent<{
48
48
  className: vue.ComputedRef<string>;
49
- wrapperRef: Ref<HTMLElement | null>;
49
+ wrapperRef: Ref<HTMLElement | undefined>;
50
50
  containerRef: vue.ComputedRef<Element | (Window & typeof globalThis) | null>;
51
51
  isFixed: Ref<boolean>;
52
52
  placeholderStyle: Ref<CSSProperties>;
@@ -77,7 +77,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
77
77
  * @en Scroll container, default is `window`
78
78
  */
79
79
  target: {
80
- type: PropType<string | HTMLElement>;
80
+ type: PropType<string | Element | (() => Element | null | undefined)>;
81
81
  };
82
82
  /**
83
83
  * @zh z-index 值
@@ -112,7 +112,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
112
112
  * @en Scroll container, default is `window`
113
113
  */
114
114
  target: {
115
- type: PropType<string | HTMLElement>;
115
+ type: PropType<string | Element | (() => Element | null | undefined)>;
116
116
  };
117
117
  /**
118
118
  * @zh z-index 值
@@ -153,7 +153,8 @@ interface HiSelectionContext {
153
153
  unactiveClass: string;
154
154
  disabledClass: string;
155
155
  label: string | ((_: any) => ElementLike | null | undefined) | null | undefined;
156
- multiple: boolean | number;
156
+ multiple: boolean;
157
+ limit: [number, number];
157
158
  }
158
159
  declare const selectionProps: {
159
160
  modelValue: {
@@ -189,7 +190,7 @@ declare const selectionProps: {
189
190
  * 多选模式
190
191
  */
191
192
  multiple: {
192
- type: (NumberConstructor | BooleanConstructor)[];
193
+ type: PropType<boolean | number | [number, number?]>;
193
194
  default: () => false;
194
195
  };
195
196
  /**
@@ -211,8 +212,8 @@ declare const selectionEmits: ("change" | "load" | "unload" | "update:modelValue
211
212
  declare function useSelectionContext(): HiSelectionContext;
212
213
  declare const useSelectionList: _hoci_shared.HookComponent<{
213
214
  options: {
214
- id?: string | undefined;
215
- label?: string | undefined;
215
+ id?: string;
216
+ label?: string;
216
217
  value: any | null;
217
218
  render: () => ElementLike;
218
219
  }[];
@@ -257,7 +258,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
257
258
  * 多选模式
258
259
  */
259
260
  multiple: {
260
- type: (NumberConstructor | BooleanConstructor)[];
261
+ type: PropType<boolean | number | [number, number?]>;
261
262
  default: () => false;
262
263
  };
263
264
  /**
@@ -307,7 +308,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
307
308
  * 多选模式
308
309
  */
309
310
  multiple: {
310
- type: (NumberConstructor | BooleanConstructor)[];
311
+ type: PropType<boolean | number | [number, number?]>;
311
312
  default: () => false;
312
313
  };
313
314
  /**
@@ -324,7 +325,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
324
325
  type: PropType<ActivateEvent>;
325
326
  };
326
327
  }>, {
327
- multiple: number | boolean;
328
+ multiple: number | boolean | [number, (number | undefined)?];
328
329
  modelValue: any;
329
330
  activeClass: string | string[] | Record<string, boolean>;
330
331
  itemClass: string | string[] | Record<string, boolean>;
@@ -345,7 +346,7 @@ declare const itemProps: {
345
346
  default(): string;
346
347
  };
347
348
  label: {
348
- type: PropType<ElementLike | ((val: any) => string) | null>;
349
+ type: PropType<string | ((val: any) => string) | ElementLike | null>;
349
350
  };
350
351
  keepAlive: {
351
352
  type: BooleanConstructor;
@@ -376,7 +377,7 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
376
377
  default(): string;
377
378
  };
378
379
  label: {
379
- type: PropType<ElementLike | ((val: any) => string) | null>;
380
+ type: PropType<string | ((val: any) => string) | ElementLike | null>;
380
381
  };
381
382
  keepAlive: {
382
383
  type: BooleanConstructor;
@@ -395,7 +396,7 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
395
396
  default(): string;
396
397
  };
397
398
  label: {
398
- type: PropType<ElementLike | ((val: any) => string) | null>;
399
+ type: PropType<string | ((val: any) => string) | ElementLike | null>;
399
400
  };
400
401
  keepAlive: {
401
402
  type: BooleanConstructor;
@@ -581,13 +582,10 @@ declare const useIcon: _hoci_shared.HookComponent<{
581
582
 
582
583
  declare const configProviderProps: {
583
584
  icon: {
584
- type: PropType<Partial<{
585
- size: number | undefined;
586
- sizeUnit: string | undefined;
587
- }>>;
585
+ type: PropType<Partial<SharedConfig["icon"]>>;
588
586
  };
589
587
  activateEvent: {
590
- type: PropType<Partial<_hoci_shared.ActivateEvent>>;
588
+ type: PropType<Partial<SharedConfig["activateEvent"]>>;
591
589
  };
592
590
  };
593
591
 
@@ -622,7 +620,7 @@ declare const popoverProps: {
622
620
  default: () => false;
623
621
  };
624
622
  teleport: {
625
- type: PropType<string | boolean | HTMLElement>;
623
+ type: PropType<string | HTMLElement | boolean>;
626
624
  default: () => true;
627
625
  };
628
626
  };
@@ -682,7 +680,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
682
680
  default: () => false;
683
681
  };
684
682
  teleport: {
685
- type: PropType<string | boolean | HTMLElement>;
683
+ type: PropType<string | HTMLElement | boolean>;
686
684
  default: () => true;
687
685
  };
688
686
  }, vue.ExtractPropTypes<{
@@ -714,7 +712,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
714
712
  default: () => false;
715
713
  };
716
714
  teleport: {
717
- type: PropType<string | boolean | HTMLElement>;
715
+ type: PropType<string | HTMLElement | boolean>;
718
716
  default: () => true;
719
717
  };
720
718
  }>, {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _hoci_shared from '@hoci/shared';
2
- import { ElementLike, ActivateEvent } from '@hoci/shared';
2
+ import { ElementLike, ActivateEvent, SharedConfig } from '@hoci/shared';
3
3
  export * from '@hoci/shared';
4
4
  import * as vue from 'vue';
5
5
  import { PropType, InjectionKey, MaybeRefOrGetter, Ref, CSSProperties as CSSProperties$1 } from 'vue';
@@ -30,7 +30,7 @@ declare const affixProps: {
30
30
  * @en Scroll container, default is `window`
31
31
  */
32
32
  target: {
33
- type: PropType<string | HTMLElement>;
33
+ type: PropType<string | Element | (() => Element | null | undefined)>;
34
34
  };
35
35
  /**
36
36
  * @zh z-index 值
@@ -46,7 +46,7 @@ declare const affixEmits: ("scroll" | "change")[];
46
46
  declare const AFFIX_TARGET_KEY: InjectionKey<MaybeRefOrGetter<Element | null | undefined>>;
47
47
  declare const useAffix: _hoci_shared.HookComponent<{
48
48
  className: vue.ComputedRef<string>;
49
- wrapperRef: Ref<HTMLElement | null>;
49
+ wrapperRef: Ref<HTMLElement | undefined>;
50
50
  containerRef: vue.ComputedRef<Element | (Window & typeof globalThis) | null>;
51
51
  isFixed: Ref<boolean>;
52
52
  placeholderStyle: Ref<CSSProperties>;
@@ -77,7 +77,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
77
77
  * @en Scroll container, default is `window`
78
78
  */
79
79
  target: {
80
- type: PropType<string | HTMLElement>;
80
+ type: PropType<string | Element | (() => Element | null | undefined)>;
81
81
  };
82
82
  /**
83
83
  * @zh z-index 值
@@ -112,7 +112,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
112
112
  * @en Scroll container, default is `window`
113
113
  */
114
114
  target: {
115
- type: PropType<string | HTMLElement>;
115
+ type: PropType<string | Element | (() => Element | null | undefined)>;
116
116
  };
117
117
  /**
118
118
  * @zh z-index 值
@@ -153,7 +153,8 @@ interface HiSelectionContext {
153
153
  unactiveClass: string;
154
154
  disabledClass: string;
155
155
  label: string | ((_: any) => ElementLike | null | undefined) | null | undefined;
156
- multiple: boolean | number;
156
+ multiple: boolean;
157
+ limit: [number, number];
157
158
  }
158
159
  declare const selectionProps: {
159
160
  modelValue: {
@@ -189,7 +190,7 @@ declare const selectionProps: {
189
190
  * 多选模式
190
191
  */
191
192
  multiple: {
192
- type: (NumberConstructor | BooleanConstructor)[];
193
+ type: PropType<boolean | number | [number, number?]>;
193
194
  default: () => false;
194
195
  };
195
196
  /**
@@ -211,8 +212,8 @@ declare const selectionEmits: ("change" | "load" | "unload" | "update:modelValue
211
212
  declare function useSelectionContext(): HiSelectionContext;
212
213
  declare const useSelectionList: _hoci_shared.HookComponent<{
213
214
  options: {
214
- id?: string | undefined;
215
- label?: string | undefined;
215
+ id?: string;
216
+ label?: string;
216
217
  value: any | null;
217
218
  render: () => ElementLike;
218
219
  }[];
@@ -257,7 +258,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
257
258
  * 多选模式
258
259
  */
259
260
  multiple: {
260
- type: (NumberConstructor | BooleanConstructor)[];
261
+ type: PropType<boolean | number | [number, number?]>;
261
262
  default: () => false;
262
263
  };
263
264
  /**
@@ -307,7 +308,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
307
308
  * 多选模式
308
309
  */
309
310
  multiple: {
310
- type: (NumberConstructor | BooleanConstructor)[];
311
+ type: PropType<boolean | number | [number, number?]>;
311
312
  default: () => false;
312
313
  };
313
314
  /**
@@ -324,7 +325,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
324
325
  type: PropType<ActivateEvent>;
325
326
  };
326
327
  }>, {
327
- multiple: number | boolean;
328
+ multiple: number | boolean | [number, (number | undefined)?];
328
329
  modelValue: any;
329
330
  activeClass: string | string[] | Record<string, boolean>;
330
331
  itemClass: string | string[] | Record<string, boolean>;
@@ -345,7 +346,7 @@ declare const itemProps: {
345
346
  default(): string;
346
347
  };
347
348
  label: {
348
- type: PropType<ElementLike | ((val: any) => string) | null>;
349
+ type: PropType<string | ((val: any) => string) | ElementLike | null>;
349
350
  };
350
351
  keepAlive: {
351
352
  type: BooleanConstructor;
@@ -376,7 +377,7 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
376
377
  default(): string;
377
378
  };
378
379
  label: {
379
- type: PropType<ElementLike | ((val: any) => string) | null>;
380
+ type: PropType<string | ((val: any) => string) | ElementLike | null>;
380
381
  };
381
382
  keepAlive: {
382
383
  type: BooleanConstructor;
@@ -395,7 +396,7 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
395
396
  default(): string;
396
397
  };
397
398
  label: {
398
- type: PropType<ElementLike | ((val: any) => string) | null>;
399
+ type: PropType<string | ((val: any) => string) | ElementLike | null>;
399
400
  };
400
401
  keepAlive: {
401
402
  type: BooleanConstructor;
@@ -581,13 +582,10 @@ declare const useIcon: _hoci_shared.HookComponent<{
581
582
 
582
583
  declare const configProviderProps: {
583
584
  icon: {
584
- type: PropType<Partial<{
585
- size: number | undefined;
586
- sizeUnit: string | undefined;
587
- }>>;
585
+ type: PropType<Partial<SharedConfig["icon"]>>;
588
586
  };
589
587
  activateEvent: {
590
- type: PropType<Partial<_hoci_shared.ActivateEvent>>;
588
+ type: PropType<Partial<SharedConfig["activateEvent"]>>;
591
589
  };
592
590
  };
593
591
 
@@ -622,7 +620,7 @@ declare const popoverProps: {
622
620
  default: () => false;
623
621
  };
624
622
  teleport: {
625
- type: PropType<string | boolean | HTMLElement>;
623
+ type: PropType<string | HTMLElement | boolean>;
626
624
  default: () => true;
627
625
  };
628
626
  };
@@ -682,7 +680,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
682
680
  default: () => false;
683
681
  };
684
682
  teleport: {
685
- type: PropType<string | boolean | HTMLElement>;
683
+ type: PropType<string | HTMLElement | boolean>;
686
684
  default: () => true;
687
685
  };
688
686
  }, vue.ExtractPropTypes<{
@@ -714,7 +712,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
714
712
  default: () => false;
715
713
  };
716
714
  teleport: {
717
- type: PropType<string | boolean | HTMLElement>;
715
+ type: PropType<string | HTMLElement | boolean>;
718
716
  default: () => true;
719
717
  };
720
718
  }>, {
package/dist/index.mjs CHANGED
@@ -53,7 +53,7 @@ function getTargetRect(target) {
53
53
  const useAffix = defineHookComponent({
54
54
  props: affixProps,
55
55
  setup(props, { emit }) {
56
- const wrapperRef = ref(null);
56
+ const wrapperRef = ref();
57
57
  const wrapperRect = toReactive(useElementBounding(wrapperRef));
58
58
  const parentRef = inject(AFFIX_TARGET_KEY, void 0);
59
59
  const targetRef = useElement(props.target, parentRef);
@@ -165,7 +165,7 @@ const selectionProps = defineHookProps({
165
165
  * 多选模式
166
166
  */
167
167
  multiple: {
168
- type: [Boolean, Number],
168
+ type: [Boolean, Number, Array],
169
169
  default: () => false
170
170
  },
171
171
  /**
@@ -206,7 +206,8 @@ function useSelectionContext() {
206
206
  itemClass: "",
207
207
  activateEvent: sharedConfig.activateEvent,
208
208
  label: null,
209
- multiple: false
209
+ multiple: false,
210
+ limit: [0, Number.POSITIVE_INFINITY]
210
211
  });
211
212
  }
212
213
  const useSelectionList = defineHookComponent({
@@ -247,16 +248,26 @@ const useSelectionList = defineHookComponent({
247
248
  function isActive(value) {
248
249
  return actives.includes(value);
249
250
  }
251
+ const multipleActive = computed(() => !!props.multiple);
252
+ const multipleLimit = computed(() => {
253
+ if (Array.isArray(props.multiple)) {
254
+ if (props.multiple[1] === void 0) {
255
+ return [props.multiple[0], Number.POSITIVE_INFINITY];
256
+ }
257
+ return props.multiple;
258
+ }
259
+ return [0, Number.POSITIVE_INFINITY];
260
+ });
250
261
  function activate(value) {
262
+ const [min, max] = multipleLimit.value;
251
263
  if (isActive(value)) {
252
- if (props.multiple || props.clearable) {
264
+ if (multipleActive.value && actives.length > min || props.clearable) {
253
265
  actives.splice(actives.indexOf(value), 1);
254
266
  emitChange();
255
267
  }
256
268
  } else {
257
269
  if (props.multiple) {
258
- const limit = typeof props.multiple === "number" ? props.multiple : Number.POSITIVE_INFINITY;
259
- if (actives.length < limit) {
270
+ if (actives.length < max) {
260
271
  actives.push(value);
261
272
  emitChange();
262
273
  }
@@ -294,7 +305,8 @@ const useSelectionList = defineHookComponent({
294
305
  disabledClass: computed(() => cls(props.disabledClass)),
295
306
  itemClass: computed(() => cls(props.itemClass)),
296
307
  label: computed(() => props.label),
297
- multiple: computed(() => props.multiple),
308
+ multiple: multipleActive,
309
+ limit: multipleLimit,
298
310
  clearable: computed(() => props.clearable),
299
311
  defaultValue: computed(() => props.defaultValue),
300
312
  activateEvent: computed(() => props.activateEvent ?? sharedConfig.activateEvent),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoci/core",
3
- "version": "0.5.9",
3
+ "version": "0.6.0",
4
4
  "description": "",
5
5
  "author": "Chizuki <chizukicn@outlook.com>",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "@vueuse/core": "9.0.0",
31
31
  "maybe-types": "^0.2.0",
32
32
  "tslx": "^0.1.1",
33
- "@hoci/shared": "0.5.9"
33
+ "@hoci/shared": "0.6.0"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "unbuild",