@hoci/core 0.5.8 → 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 +24 -15
- package/dist/index.d.cts +33 -42
- package/dist/index.d.mts +33 -42
- package/dist/index.d.ts +33 -42
- package/dist/index.mjs +24 -15
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -34,9 +34,9 @@ const affixProps = shared.defineHookProps(
|
|
|
34
34
|
type: [String, Object, Function]
|
|
35
35
|
},
|
|
36
36
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
* @zh z-index 值
|
|
38
|
+
* @en Z index value
|
|
39
|
+
*/
|
|
40
40
|
zIndex: {
|
|
41
41
|
type: Number,
|
|
42
42
|
default: 998
|
|
@@ -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(
|
|
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 (
|
|
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
|
-
|
|
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:
|
|
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),
|
|
@@ -343,9 +355,6 @@ const itemProps = shared.defineHookProps({
|
|
|
343
355
|
type: Boolean,
|
|
344
356
|
default: () => true
|
|
345
357
|
},
|
|
346
|
-
key: {
|
|
347
|
-
type: [String, Number, Symbol]
|
|
348
|
-
},
|
|
349
358
|
activateEvent: {
|
|
350
359
|
type: String
|
|
351
360
|
},
|
|
@@ -370,7 +379,7 @@ const useSelectionItem = shared.defineHookComponent({
|
|
|
370
379
|
};
|
|
371
380
|
const label = vue.computed(() => {
|
|
372
381
|
let label2 = props.label ?? context.label;
|
|
373
|
-
if (label2 && typeof label2
|
|
382
|
+
if (label2 && typeof label2 === "function") {
|
|
374
383
|
label2 = label2(props.value);
|
|
375
384
|
}
|
|
376
385
|
return Array.isArray(label2) ? label2 : [label2];
|
|
@@ -391,7 +400,7 @@ const useSelectionItem = shared.defineHookComponent({
|
|
|
391
400
|
remove();
|
|
392
401
|
remove = init({
|
|
393
402
|
id: Math.random().toString(16).slice(2),
|
|
394
|
-
label: typeof props.label
|
|
403
|
+
label: typeof props.label === "string" ? props.label : void 0,
|
|
395
404
|
value,
|
|
396
405
|
render
|
|
397
406
|
});
|
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,12 +30,12 @@ declare const affixProps: {
|
|
|
30
30
|
* @en Scroll container, default is `window`
|
|
31
31
|
*/
|
|
32
32
|
target: {
|
|
33
|
-
type: PropType<string |
|
|
33
|
+
type: PropType<string | Element | (() => Element | null | undefined)>;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
* @zh z-index 值
|
|
37
|
+
* @en Z index value
|
|
38
|
+
*/
|
|
39
39
|
zIndex: {
|
|
40
40
|
type: NumberConstructor;
|
|
41
41
|
default: number;
|
|
@@ -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 |
|
|
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,12 +77,12 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
77
77
|
* @en Scroll container, default is `window`
|
|
78
78
|
*/
|
|
79
79
|
target: {
|
|
80
|
-
type: PropType<string |
|
|
80
|
+
type: PropType<string | Element | (() => Element | null | undefined)>;
|
|
81
81
|
};
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
* @zh z-index 值
|
|
84
|
+
* @en Z index value
|
|
85
|
+
*/
|
|
86
86
|
zIndex: {
|
|
87
87
|
type: NumberConstructor;
|
|
88
88
|
default: number;
|
|
@@ -112,12 +112,12 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
112
112
|
* @en Scroll container, default is `window`
|
|
113
113
|
*/
|
|
114
114
|
target: {
|
|
115
|
-
type: PropType<string |
|
|
115
|
+
type: PropType<string | Element | (() => Element | null | undefined)>;
|
|
116
116
|
};
|
|
117
117
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
* @zh z-index 值
|
|
119
|
+
* @en Z index value
|
|
120
|
+
*/
|
|
121
121
|
zIndex: {
|
|
122
122
|
type: NumberConstructor;
|
|
123
123
|
default: number;
|
|
@@ -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
|
|
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:
|
|
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
|
|
215
|
-
label?: string
|
|
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:
|
|
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:
|
|
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,15 +346,12 @@ declare const itemProps: {
|
|
|
345
346
|
default(): string;
|
|
346
347
|
};
|
|
347
348
|
label: {
|
|
348
|
-
type: PropType<
|
|
349
|
+
type: PropType<string | ((val: any) => string) | ElementLike | null>;
|
|
349
350
|
};
|
|
350
351
|
keepAlive: {
|
|
351
352
|
type: BooleanConstructor;
|
|
352
353
|
default: () => true;
|
|
353
354
|
};
|
|
354
|
-
key: {
|
|
355
|
-
type: PropType<string | number | symbol>;
|
|
356
|
-
};
|
|
357
355
|
activateEvent: {
|
|
358
356
|
type: PropType<ActivateEvent>;
|
|
359
357
|
};
|
|
@@ -370,22 +368,21 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
|
|
|
370
368
|
isDisabled: vue.ComputedRef<boolean>;
|
|
371
369
|
className: vue.ComputedRef<string>;
|
|
372
370
|
activateEvent: vue.ComputedRef<ActivateEvent>;
|
|
373
|
-
label: vue.ComputedRef<ElementLike[] | (string |
|
|
371
|
+
label: vue.ComputedRef<ElementLike[] | (string | vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
372
|
+
[key: string]: any;
|
|
373
|
+
}> | null | undefined)[]>;
|
|
374
374
|
}, "reject"[], {
|
|
375
375
|
value: {
|
|
376
376
|
type: PropType<any>;
|
|
377
377
|
default(): string;
|
|
378
378
|
};
|
|
379
379
|
label: {
|
|
380
|
-
type: PropType<
|
|
380
|
+
type: PropType<string | ((val: any) => string) | ElementLike | null>;
|
|
381
381
|
};
|
|
382
382
|
keepAlive: {
|
|
383
383
|
type: BooleanConstructor;
|
|
384
384
|
default: () => true;
|
|
385
385
|
};
|
|
386
|
-
key: {
|
|
387
|
-
type: PropType<string | number | symbol>;
|
|
388
|
-
};
|
|
389
386
|
activateEvent: {
|
|
390
387
|
type: PropType<ActivateEvent>;
|
|
391
388
|
};
|
|
@@ -399,15 +396,12 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
|
|
|
399
396
|
default(): string;
|
|
400
397
|
};
|
|
401
398
|
label: {
|
|
402
|
-
type: PropType<
|
|
399
|
+
type: PropType<string | ((val: any) => string) | ElementLike | null>;
|
|
403
400
|
};
|
|
404
401
|
keepAlive: {
|
|
405
402
|
type: BooleanConstructor;
|
|
406
403
|
default: () => true;
|
|
407
404
|
};
|
|
408
|
-
key: {
|
|
409
|
-
type: PropType<string | number | symbol>;
|
|
410
|
-
};
|
|
411
405
|
activateEvent: {
|
|
412
406
|
type: PropType<ActivateEvent>;
|
|
413
407
|
};
|
|
@@ -588,13 +582,10 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
588
582
|
|
|
589
583
|
declare const configProviderProps: {
|
|
590
584
|
icon: {
|
|
591
|
-
type: PropType<Partial<
|
|
592
|
-
size: number | undefined;
|
|
593
|
-
sizeUnit: string | undefined;
|
|
594
|
-
}>>;
|
|
585
|
+
type: PropType<Partial<SharedConfig["icon"]>>;
|
|
595
586
|
};
|
|
596
587
|
activateEvent: {
|
|
597
|
-
type: PropType<Partial<
|
|
588
|
+
type: PropType<Partial<SharedConfig["activateEvent"]>>;
|
|
598
589
|
};
|
|
599
590
|
};
|
|
600
591
|
|
|
@@ -629,7 +620,7 @@ declare const popoverProps: {
|
|
|
629
620
|
default: () => false;
|
|
630
621
|
};
|
|
631
622
|
teleport: {
|
|
632
|
-
type: PropType<string |
|
|
623
|
+
type: PropType<string | HTMLElement | boolean>;
|
|
633
624
|
default: () => true;
|
|
634
625
|
};
|
|
635
626
|
};
|
|
@@ -689,7 +680,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
|
|
|
689
680
|
default: () => false;
|
|
690
681
|
};
|
|
691
682
|
teleport: {
|
|
692
|
-
type: PropType<string |
|
|
683
|
+
type: PropType<string | HTMLElement | boolean>;
|
|
693
684
|
default: () => true;
|
|
694
685
|
};
|
|
695
686
|
}, vue.ExtractPropTypes<{
|
|
@@ -721,7 +712,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
|
|
|
721
712
|
default: () => false;
|
|
722
713
|
};
|
|
723
714
|
teleport: {
|
|
724
|
-
type: PropType<string |
|
|
715
|
+
type: PropType<string | HTMLElement | boolean>;
|
|
725
716
|
default: () => true;
|
|
726
717
|
};
|
|
727
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,12 +30,12 @@ declare const affixProps: {
|
|
|
30
30
|
* @en Scroll container, default is `window`
|
|
31
31
|
*/
|
|
32
32
|
target: {
|
|
33
|
-
type: PropType<string |
|
|
33
|
+
type: PropType<string | Element | (() => Element | null | undefined)>;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
* @zh z-index 值
|
|
37
|
+
* @en Z index value
|
|
38
|
+
*/
|
|
39
39
|
zIndex: {
|
|
40
40
|
type: NumberConstructor;
|
|
41
41
|
default: number;
|
|
@@ -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 |
|
|
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,12 +77,12 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
77
77
|
* @en Scroll container, default is `window`
|
|
78
78
|
*/
|
|
79
79
|
target: {
|
|
80
|
-
type: PropType<string |
|
|
80
|
+
type: PropType<string | Element | (() => Element | null | undefined)>;
|
|
81
81
|
};
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
* @zh z-index 值
|
|
84
|
+
* @en Z index value
|
|
85
|
+
*/
|
|
86
86
|
zIndex: {
|
|
87
87
|
type: NumberConstructor;
|
|
88
88
|
default: number;
|
|
@@ -112,12 +112,12 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
112
112
|
* @en Scroll container, default is `window`
|
|
113
113
|
*/
|
|
114
114
|
target: {
|
|
115
|
-
type: PropType<string |
|
|
115
|
+
type: PropType<string | Element | (() => Element | null | undefined)>;
|
|
116
116
|
};
|
|
117
117
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
* @zh z-index 值
|
|
119
|
+
* @en Z index value
|
|
120
|
+
*/
|
|
121
121
|
zIndex: {
|
|
122
122
|
type: NumberConstructor;
|
|
123
123
|
default: number;
|
|
@@ -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
|
|
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:
|
|
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
|
|
215
|
-
label?: string
|
|
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:
|
|
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:
|
|
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,15 +346,12 @@ declare const itemProps: {
|
|
|
345
346
|
default(): string;
|
|
346
347
|
};
|
|
347
348
|
label: {
|
|
348
|
-
type: PropType<
|
|
349
|
+
type: PropType<string | ((val: any) => string) | ElementLike | null>;
|
|
349
350
|
};
|
|
350
351
|
keepAlive: {
|
|
351
352
|
type: BooleanConstructor;
|
|
352
353
|
default: () => true;
|
|
353
354
|
};
|
|
354
|
-
key: {
|
|
355
|
-
type: PropType<string | number | symbol>;
|
|
356
|
-
};
|
|
357
355
|
activateEvent: {
|
|
358
356
|
type: PropType<ActivateEvent>;
|
|
359
357
|
};
|
|
@@ -370,22 +368,21 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
|
|
|
370
368
|
isDisabled: vue.ComputedRef<boolean>;
|
|
371
369
|
className: vue.ComputedRef<string>;
|
|
372
370
|
activateEvent: vue.ComputedRef<ActivateEvent>;
|
|
373
|
-
label: vue.ComputedRef<ElementLike[] | (string |
|
|
371
|
+
label: vue.ComputedRef<ElementLike[] | (string | vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
372
|
+
[key: string]: any;
|
|
373
|
+
}> | null | undefined)[]>;
|
|
374
374
|
}, "reject"[], {
|
|
375
375
|
value: {
|
|
376
376
|
type: PropType<any>;
|
|
377
377
|
default(): string;
|
|
378
378
|
};
|
|
379
379
|
label: {
|
|
380
|
-
type: PropType<
|
|
380
|
+
type: PropType<string | ((val: any) => string) | ElementLike | null>;
|
|
381
381
|
};
|
|
382
382
|
keepAlive: {
|
|
383
383
|
type: BooleanConstructor;
|
|
384
384
|
default: () => true;
|
|
385
385
|
};
|
|
386
|
-
key: {
|
|
387
|
-
type: PropType<string | number | symbol>;
|
|
388
|
-
};
|
|
389
386
|
activateEvent: {
|
|
390
387
|
type: PropType<ActivateEvent>;
|
|
391
388
|
};
|
|
@@ -399,15 +396,12 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
|
|
|
399
396
|
default(): string;
|
|
400
397
|
};
|
|
401
398
|
label: {
|
|
402
|
-
type: PropType<
|
|
399
|
+
type: PropType<string | ((val: any) => string) | ElementLike | null>;
|
|
403
400
|
};
|
|
404
401
|
keepAlive: {
|
|
405
402
|
type: BooleanConstructor;
|
|
406
403
|
default: () => true;
|
|
407
404
|
};
|
|
408
|
-
key: {
|
|
409
|
-
type: PropType<string | number | symbol>;
|
|
410
|
-
};
|
|
411
405
|
activateEvent: {
|
|
412
406
|
type: PropType<ActivateEvent>;
|
|
413
407
|
};
|
|
@@ -588,13 +582,10 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
588
582
|
|
|
589
583
|
declare const configProviderProps: {
|
|
590
584
|
icon: {
|
|
591
|
-
type: PropType<Partial<
|
|
592
|
-
size: number | undefined;
|
|
593
|
-
sizeUnit: string | undefined;
|
|
594
|
-
}>>;
|
|
585
|
+
type: PropType<Partial<SharedConfig["icon"]>>;
|
|
595
586
|
};
|
|
596
587
|
activateEvent: {
|
|
597
|
-
type: PropType<Partial<
|
|
588
|
+
type: PropType<Partial<SharedConfig["activateEvent"]>>;
|
|
598
589
|
};
|
|
599
590
|
};
|
|
600
591
|
|
|
@@ -629,7 +620,7 @@ declare const popoverProps: {
|
|
|
629
620
|
default: () => false;
|
|
630
621
|
};
|
|
631
622
|
teleport: {
|
|
632
|
-
type: PropType<string |
|
|
623
|
+
type: PropType<string | HTMLElement | boolean>;
|
|
633
624
|
default: () => true;
|
|
634
625
|
};
|
|
635
626
|
};
|
|
@@ -689,7 +680,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
|
|
|
689
680
|
default: () => false;
|
|
690
681
|
};
|
|
691
682
|
teleport: {
|
|
692
|
-
type: PropType<string |
|
|
683
|
+
type: PropType<string | HTMLElement | boolean>;
|
|
693
684
|
default: () => true;
|
|
694
685
|
};
|
|
695
686
|
}, vue.ExtractPropTypes<{
|
|
@@ -721,7 +712,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
|
|
|
721
712
|
default: () => false;
|
|
722
713
|
};
|
|
723
714
|
teleport: {
|
|
724
|
-
type: PropType<string |
|
|
715
|
+
type: PropType<string | HTMLElement | boolean>;
|
|
725
716
|
default: () => true;
|
|
726
717
|
};
|
|
727
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,12 +30,12 @@ declare const affixProps: {
|
|
|
30
30
|
* @en Scroll container, default is `window`
|
|
31
31
|
*/
|
|
32
32
|
target: {
|
|
33
|
-
type: PropType<string |
|
|
33
|
+
type: PropType<string | Element | (() => Element | null | undefined)>;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
* @zh z-index 值
|
|
37
|
+
* @en Z index value
|
|
38
|
+
*/
|
|
39
39
|
zIndex: {
|
|
40
40
|
type: NumberConstructor;
|
|
41
41
|
default: number;
|
|
@@ -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 |
|
|
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,12 +77,12 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
77
77
|
* @en Scroll container, default is `window`
|
|
78
78
|
*/
|
|
79
79
|
target: {
|
|
80
|
-
type: PropType<string |
|
|
80
|
+
type: PropType<string | Element | (() => Element | null | undefined)>;
|
|
81
81
|
};
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
* @zh z-index 值
|
|
84
|
+
* @en Z index value
|
|
85
|
+
*/
|
|
86
86
|
zIndex: {
|
|
87
87
|
type: NumberConstructor;
|
|
88
88
|
default: number;
|
|
@@ -112,12 +112,12 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
112
112
|
* @en Scroll container, default is `window`
|
|
113
113
|
*/
|
|
114
114
|
target: {
|
|
115
|
-
type: PropType<string |
|
|
115
|
+
type: PropType<string | Element | (() => Element | null | undefined)>;
|
|
116
116
|
};
|
|
117
117
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
* @zh z-index 值
|
|
119
|
+
* @en Z index value
|
|
120
|
+
*/
|
|
121
121
|
zIndex: {
|
|
122
122
|
type: NumberConstructor;
|
|
123
123
|
default: number;
|
|
@@ -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
|
|
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:
|
|
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
|
|
215
|
-
label?: string
|
|
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:
|
|
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:
|
|
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,15 +346,12 @@ declare const itemProps: {
|
|
|
345
346
|
default(): string;
|
|
346
347
|
};
|
|
347
348
|
label: {
|
|
348
|
-
type: PropType<
|
|
349
|
+
type: PropType<string | ((val: any) => string) | ElementLike | null>;
|
|
349
350
|
};
|
|
350
351
|
keepAlive: {
|
|
351
352
|
type: BooleanConstructor;
|
|
352
353
|
default: () => true;
|
|
353
354
|
};
|
|
354
|
-
key: {
|
|
355
|
-
type: PropType<string | number | symbol>;
|
|
356
|
-
};
|
|
357
355
|
activateEvent: {
|
|
358
356
|
type: PropType<ActivateEvent>;
|
|
359
357
|
};
|
|
@@ -370,22 +368,21 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
|
|
|
370
368
|
isDisabled: vue.ComputedRef<boolean>;
|
|
371
369
|
className: vue.ComputedRef<string>;
|
|
372
370
|
activateEvent: vue.ComputedRef<ActivateEvent>;
|
|
373
|
-
label: vue.ComputedRef<ElementLike[] | (string |
|
|
371
|
+
label: vue.ComputedRef<ElementLike[] | (string | vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
372
|
+
[key: string]: any;
|
|
373
|
+
}> | null | undefined)[]>;
|
|
374
374
|
}, "reject"[], {
|
|
375
375
|
value: {
|
|
376
376
|
type: PropType<any>;
|
|
377
377
|
default(): string;
|
|
378
378
|
};
|
|
379
379
|
label: {
|
|
380
|
-
type: PropType<
|
|
380
|
+
type: PropType<string | ((val: any) => string) | ElementLike | null>;
|
|
381
381
|
};
|
|
382
382
|
keepAlive: {
|
|
383
383
|
type: BooleanConstructor;
|
|
384
384
|
default: () => true;
|
|
385
385
|
};
|
|
386
|
-
key: {
|
|
387
|
-
type: PropType<string | number | symbol>;
|
|
388
|
-
};
|
|
389
386
|
activateEvent: {
|
|
390
387
|
type: PropType<ActivateEvent>;
|
|
391
388
|
};
|
|
@@ -399,15 +396,12 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
|
|
|
399
396
|
default(): string;
|
|
400
397
|
};
|
|
401
398
|
label: {
|
|
402
|
-
type: PropType<
|
|
399
|
+
type: PropType<string | ((val: any) => string) | ElementLike | null>;
|
|
403
400
|
};
|
|
404
401
|
keepAlive: {
|
|
405
402
|
type: BooleanConstructor;
|
|
406
403
|
default: () => true;
|
|
407
404
|
};
|
|
408
|
-
key: {
|
|
409
|
-
type: PropType<string | number | symbol>;
|
|
410
|
-
};
|
|
411
405
|
activateEvent: {
|
|
412
406
|
type: PropType<ActivateEvent>;
|
|
413
407
|
};
|
|
@@ -588,13 +582,10 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
588
582
|
|
|
589
583
|
declare const configProviderProps: {
|
|
590
584
|
icon: {
|
|
591
|
-
type: PropType<Partial<
|
|
592
|
-
size: number | undefined;
|
|
593
|
-
sizeUnit: string | undefined;
|
|
594
|
-
}>>;
|
|
585
|
+
type: PropType<Partial<SharedConfig["icon"]>>;
|
|
595
586
|
};
|
|
596
587
|
activateEvent: {
|
|
597
|
-
type: PropType<Partial<
|
|
588
|
+
type: PropType<Partial<SharedConfig["activateEvent"]>>;
|
|
598
589
|
};
|
|
599
590
|
};
|
|
600
591
|
|
|
@@ -629,7 +620,7 @@ declare const popoverProps: {
|
|
|
629
620
|
default: () => false;
|
|
630
621
|
};
|
|
631
622
|
teleport: {
|
|
632
|
-
type: PropType<string |
|
|
623
|
+
type: PropType<string | HTMLElement | boolean>;
|
|
633
624
|
default: () => true;
|
|
634
625
|
};
|
|
635
626
|
};
|
|
@@ -689,7 +680,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
|
|
|
689
680
|
default: () => false;
|
|
690
681
|
};
|
|
691
682
|
teleport: {
|
|
692
|
-
type: PropType<string |
|
|
683
|
+
type: PropType<string | HTMLElement | boolean>;
|
|
693
684
|
default: () => true;
|
|
694
685
|
};
|
|
695
686
|
}, vue.ExtractPropTypes<{
|
|
@@ -721,7 +712,7 @@ declare const usePopover: _hoci_shared.HookComponent<{
|
|
|
721
712
|
default: () => false;
|
|
722
713
|
};
|
|
723
714
|
teleport: {
|
|
724
|
-
type: PropType<string |
|
|
715
|
+
type: PropType<string | HTMLElement | boolean>;
|
|
725
716
|
default: () => true;
|
|
726
717
|
};
|
|
727
718
|
}>, {
|
package/dist/index.mjs
CHANGED
|
@@ -33,9 +33,9 @@ const affixProps = defineHookProps(
|
|
|
33
33
|
type: [String, Object, Function]
|
|
34
34
|
},
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
* @zh z-index 值
|
|
37
|
+
* @en Z index value
|
|
38
|
+
*/
|
|
39
39
|
zIndex: {
|
|
40
40
|
type: Number,
|
|
41
41
|
default: 998
|
|
@@ -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(
|
|
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 (
|
|
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
|
-
|
|
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:
|
|
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),
|
|
@@ -342,9 +354,6 @@ const itemProps = defineHookProps({
|
|
|
342
354
|
type: Boolean,
|
|
343
355
|
default: () => true
|
|
344
356
|
},
|
|
345
|
-
key: {
|
|
346
|
-
type: [String, Number, Symbol]
|
|
347
|
-
},
|
|
348
357
|
activateEvent: {
|
|
349
358
|
type: String
|
|
350
359
|
},
|
|
@@ -369,7 +378,7 @@ const useSelectionItem = defineHookComponent({
|
|
|
369
378
|
};
|
|
370
379
|
const label = computed(() => {
|
|
371
380
|
let label2 = props.label ?? context.label;
|
|
372
|
-
if (label2 && typeof label2
|
|
381
|
+
if (label2 && typeof label2 === "function") {
|
|
373
382
|
label2 = label2(props.value);
|
|
374
383
|
}
|
|
375
384
|
return Array.isArray(label2) ? label2 : [label2];
|
|
@@ -390,7 +399,7 @@ const useSelectionItem = defineHookComponent({
|
|
|
390
399
|
remove();
|
|
391
400
|
remove = init({
|
|
392
401
|
id: Math.random().toString(16).slice(2),
|
|
393
|
-
label: typeof props.label
|
|
402
|
+
label: typeof props.label === "string" ? props.label : void 0,
|
|
394
403
|
value,
|
|
395
404
|
render
|
|
396
405
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hoci/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Chizuki <chizukicn@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
17
|
},
|
|
18
18
|
"./*": "./dist/*"
|
|
19
19
|
},
|
|
@@ -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.
|
|
33
|
+
"@hoci/shared": "0.6.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "unbuild",
|