@hoci/core 0.3.0 → 0.4.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.
- package/dist/index.cjs +68 -109
- package/dist/index.d.cts +12 -18
- package/dist/index.d.mts +12 -18
- package/dist/index.d.ts +12 -18
- package/dist/index.mjs +71 -112
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -5,42 +5,6 @@ const core = require('@vueuse/core');
|
|
|
5
5
|
const shared = require('@hoci/shared');
|
|
6
6
|
const tslx = require('tslx');
|
|
7
7
|
|
|
8
|
-
var __defProp$1 = Object.defineProperty;
|
|
9
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
10
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues$1 = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
16
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols$1)
|
|
18
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
19
|
-
if (__propIsEnum$1.call(b, prop))
|
|
20
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __async = (__this, __arguments, generator) => {
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
var fulfilled = (value) => {
|
|
27
|
-
try {
|
|
28
|
-
step(generator.next(value));
|
|
29
|
-
} catch (e) {
|
|
30
|
-
reject(e);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var rejected = (value) => {
|
|
34
|
-
try {
|
|
35
|
-
step(generator.throw(value));
|
|
36
|
-
} catch (e) {
|
|
37
|
-
reject(e);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
8
|
const affixProps = shared.defineHookProps(
|
|
45
9
|
{
|
|
46
10
|
fixedClass: {
|
|
@@ -88,29 +52,27 @@ const useAffix = shared.defineHookComponent({
|
|
|
88
52
|
props: affixProps,
|
|
89
53
|
setup(props, { emit }) {
|
|
90
54
|
const wrapperRef = vue.ref(null);
|
|
91
|
-
const parentRef = vue.inject(AFFIX_TARGET_KEY,
|
|
55
|
+
const parentRef = vue.inject(AFFIX_TARGET_KEY, void 0);
|
|
92
56
|
const targetRef = shared.useElement(props.target, parentRef);
|
|
93
57
|
const isFixed = vue.ref(false);
|
|
94
58
|
const placeholderStyle = vue.ref({});
|
|
95
59
|
const fixedStyle = vue.ref({});
|
|
96
|
-
const
|
|
60
|
+
const className = vue.computed(() => {
|
|
97
61
|
return isFixed.value ? props.fixedClass : "";
|
|
98
62
|
});
|
|
99
63
|
const wrapperVisible = core.useElementVisibility(wrapperRef);
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
if (!targetRef.value || !wrapperVisible.value) {
|
|
64
|
+
const containerRef = vue.computed(() => {
|
|
65
|
+
if (!wrapperVisible.value) {
|
|
103
66
|
return null;
|
|
104
67
|
}
|
|
105
|
-
return
|
|
68
|
+
return targetRef.value ?? window;
|
|
106
69
|
});
|
|
107
|
-
const updatePosition = shared.throttleByRaf(() =>
|
|
108
|
-
if (!wrapperRef.value || !
|
|
70
|
+
const updatePosition = shared.throttleByRaf(async () => {
|
|
71
|
+
if (!wrapperRef.value || !containerRef.value) {
|
|
109
72
|
return;
|
|
110
73
|
}
|
|
111
|
-
yield vue.nextTick();
|
|
112
74
|
const wrapperRect = wrapperRef.value.getBoundingClientRect();
|
|
113
|
-
const targetRect = getTargetRect(
|
|
75
|
+
const targetRect = getTargetRect(containerRef.value);
|
|
114
76
|
let newIsFixed = false;
|
|
115
77
|
let newFixedStyles = {};
|
|
116
78
|
const newPlaceholderStyles = {
|
|
@@ -137,17 +99,21 @@ const useAffix = shared.defineHookComponent({
|
|
|
137
99
|
emit("change", newIsFixed);
|
|
138
100
|
}
|
|
139
101
|
placeholderStyle.value = newPlaceholderStyles;
|
|
140
|
-
fixedStyle.value =
|
|
141
|
-
|
|
142
|
-
|
|
102
|
+
fixedStyle.value = {
|
|
103
|
+
...newFixedStyles,
|
|
104
|
+
...newIsFixed ? newPlaceholderStyles : {}
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
core.useEventListener(containerRef, "scroll", () => {
|
|
143
108
|
emit("scroll");
|
|
144
109
|
updatePosition();
|
|
145
110
|
});
|
|
146
|
-
core.useEventListener(
|
|
111
|
+
core.useEventListener(containerRef, "resize", updatePosition);
|
|
147
112
|
vue.watchPostEffect(updatePosition);
|
|
148
113
|
return {
|
|
149
|
-
|
|
114
|
+
className,
|
|
150
115
|
wrapperRef,
|
|
116
|
+
containerRef,
|
|
151
117
|
isFixed,
|
|
152
118
|
placeholderStyle,
|
|
153
119
|
fixedStyle,
|
|
@@ -207,8 +173,7 @@ const selectionProps = shared.defineHookProps({
|
|
|
207
173
|
default: () => null
|
|
208
174
|
},
|
|
209
175
|
activateEvent: {
|
|
210
|
-
type: String
|
|
211
|
-
default: () => "click"
|
|
176
|
+
type: String
|
|
212
177
|
}
|
|
213
178
|
});
|
|
214
179
|
const selectionEmits = shared.defineHookEmits([
|
|
@@ -219,6 +184,7 @@ const selectionEmits = shared.defineHookEmits([
|
|
|
219
184
|
]);
|
|
220
185
|
const HiSelectionContextSymbol = Symbol("[hi-selection]context");
|
|
221
186
|
function useSelectionContext() {
|
|
187
|
+
const sharedConfig = shared.useSharedConfig();
|
|
222
188
|
return vue.inject(HiSelectionContextSymbol, {
|
|
223
189
|
isActive: () => false,
|
|
224
190
|
changeActive: () => {
|
|
@@ -227,7 +193,7 @@ function useSelectionContext() {
|
|
|
227
193
|
unactiveClass: "unactive",
|
|
228
194
|
disabledClass: "disabled",
|
|
229
195
|
itemClass: "",
|
|
230
|
-
activateEvent:
|
|
196
|
+
activateEvent: sharedConfig.activateEvent,
|
|
231
197
|
label: null,
|
|
232
198
|
multiple: false
|
|
233
199
|
});
|
|
@@ -236,7 +202,6 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
236
202
|
props: selectionProps,
|
|
237
203
|
emits: selectionEmits,
|
|
238
204
|
setup(props, { emit }) {
|
|
239
|
-
var _a;
|
|
240
205
|
const options = vue.reactive([]);
|
|
241
206
|
function toArray(value) {
|
|
242
207
|
if (!core.isDefined(value)) {
|
|
@@ -248,7 +213,7 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
248
213
|
return [value];
|
|
249
214
|
}
|
|
250
215
|
const actives = vue.reactive([
|
|
251
|
-
...toArray(
|
|
216
|
+
...toArray(props.modelValue ?? props.defaultValue)
|
|
252
217
|
]);
|
|
253
218
|
const currentValue = vue.computed({
|
|
254
219
|
get() {
|
|
@@ -260,8 +225,7 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
260
225
|
});
|
|
261
226
|
const modelValue = vue.computed({
|
|
262
227
|
get() {
|
|
263
|
-
|
|
264
|
-
return (_a2 = props.modelValue) != null ? _a2 : props.defaultValue;
|
|
228
|
+
return props.modelValue ?? props.defaultValue;
|
|
265
229
|
},
|
|
266
230
|
set(val) {
|
|
267
231
|
emit("update:modelValue", val);
|
|
@@ -309,6 +273,7 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
309
273
|
emit("load", option);
|
|
310
274
|
return remove;
|
|
311
275
|
};
|
|
276
|
+
const sharedConfig = shared.useSharedConfig();
|
|
312
277
|
vue.provide(HiSelectionContextSymbol, core.toReactive({
|
|
313
278
|
activeClass: vue.computed(() => tslx.cls(props.activeClass)),
|
|
314
279
|
unactiveClass: vue.computed(() => tslx.cls(props.unactiveClass)),
|
|
@@ -318,7 +283,7 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
318
283
|
multiple: vue.computed(() => props.multiple),
|
|
319
284
|
clearable: vue.computed(() => props.clearable),
|
|
320
285
|
defaultValue: vue.computed(() => props.defaultValue),
|
|
321
|
-
activateEvent: vue.computed(() => props.activateEvent),
|
|
286
|
+
activateEvent: vue.computed(() => props.activateEvent ?? sharedConfig.activateEvent),
|
|
322
287
|
active: currentValue,
|
|
323
288
|
changeActive,
|
|
324
289
|
isActive,
|
|
@@ -378,8 +343,7 @@ const useSelectionItem = shared.defineHookComponent({
|
|
|
378
343
|
active: context.isActive(props.value),
|
|
379
344
|
activate
|
|
380
345
|
}, () => {
|
|
381
|
-
|
|
382
|
-
let label = (_a = props.label) != null ? _a : context.label;
|
|
346
|
+
let label = props.label ?? context.label;
|
|
383
347
|
if (label && typeof label == "function") {
|
|
384
348
|
label = label(props.value);
|
|
385
349
|
}
|
|
@@ -416,7 +380,7 @@ const useSelectionItem = shared.defineHookComponent({
|
|
|
416
380
|
}
|
|
417
381
|
return tslx.cls(array);
|
|
418
382
|
});
|
|
419
|
-
const activateEvent = vue.computed(() => context.activateEvent);
|
|
383
|
+
const activateEvent = vue.computed(() => props.activateEvent ?? context.activateEvent);
|
|
420
384
|
return {
|
|
421
385
|
activate,
|
|
422
386
|
render,
|
|
@@ -446,8 +410,7 @@ const switchProps = shared.defineHookProps({
|
|
|
446
410
|
default: "unchecked"
|
|
447
411
|
},
|
|
448
412
|
activateEvent: {
|
|
449
|
-
type: String
|
|
450
|
-
default: "click"
|
|
413
|
+
type: String
|
|
451
414
|
},
|
|
452
415
|
disabled: {
|
|
453
416
|
type: Boolean,
|
|
@@ -486,39 +449,25 @@ const useSwitch = shared.defineHookComponent({
|
|
|
486
449
|
isDisabled.value ? props.disabledClass : ""
|
|
487
450
|
]);
|
|
488
451
|
});
|
|
452
|
+
const sharedConfig = shared.useSharedConfig();
|
|
453
|
+
const activateEvent = vue.computed(() => props.activateEvent ?? sharedConfig.activateEvent);
|
|
489
454
|
return {
|
|
490
455
|
toggle,
|
|
491
456
|
modelValue,
|
|
492
457
|
className,
|
|
493
|
-
isDisabled
|
|
458
|
+
isDisabled,
|
|
459
|
+
activateEvent
|
|
494
460
|
};
|
|
495
461
|
}
|
|
496
462
|
});
|
|
497
463
|
|
|
498
|
-
var __defProp = Object.defineProperty;
|
|
499
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
500
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
501
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
502
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
503
|
-
var __spreadValues = (a, b) => {
|
|
504
|
-
for (var prop in b || (b = {}))
|
|
505
|
-
if (__hasOwnProp.call(b, prop))
|
|
506
|
-
__defNormalProp(a, prop, b[prop]);
|
|
507
|
-
if (__getOwnPropSymbols)
|
|
508
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
509
|
-
if (__propIsEnum.call(b, prop))
|
|
510
|
-
__defNormalProp(a, prop, b[prop]);
|
|
511
|
-
}
|
|
512
|
-
return a;
|
|
513
|
-
};
|
|
514
464
|
const iconProps = shared.defineHookProps({
|
|
515
465
|
src: {
|
|
516
466
|
type: String,
|
|
517
467
|
required: true
|
|
518
468
|
},
|
|
519
469
|
size: {
|
|
520
|
-
type: [Number, String]
|
|
521
|
-
default: "1rem"
|
|
470
|
+
type: [Number, String]
|
|
522
471
|
},
|
|
523
472
|
width: {
|
|
524
473
|
type: [Number, String]
|
|
@@ -527,7 +476,8 @@ const iconProps = shared.defineHookProps({
|
|
|
527
476
|
type: [Number, String]
|
|
528
477
|
},
|
|
529
478
|
color: {
|
|
530
|
-
type: String
|
|
479
|
+
type: String,
|
|
480
|
+
default: "currentColor"
|
|
531
481
|
},
|
|
532
482
|
mask: {
|
|
533
483
|
type: [Boolean, String],
|
|
@@ -537,38 +487,47 @@ const iconProps = shared.defineHookProps({
|
|
|
537
487
|
const useIcon = shared.defineHookComponent({
|
|
538
488
|
props: iconProps,
|
|
539
489
|
setup(props, context) {
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
const
|
|
543
|
-
const
|
|
544
|
-
const
|
|
545
|
-
const
|
|
546
|
-
const width =
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
490
|
+
const sharedConfig = shared.useSharedConfig("icon");
|
|
491
|
+
const sizeStyle = vue.computed(() => {
|
|
492
|
+
const s = props.size ?? sharedConfig.size;
|
|
493
|
+
const size = s ? tslx.unit_f(s, sharedConfig.sizeUnit) : void 0;
|
|
494
|
+
const w = props.width ?? size;
|
|
495
|
+
const h = props.height ?? size;
|
|
496
|
+
const width = w ? tslx.unit_f(w, sharedConfig.sizeUnit) : void 0;
|
|
497
|
+
const height = h ? tslx.unit_f(h, sharedConfig.sizeUnit) : void 0;
|
|
498
|
+
return {
|
|
499
|
+
width,
|
|
500
|
+
height
|
|
501
|
+
};
|
|
502
|
+
});
|
|
503
|
+
const dynamicStyle = vue.computed(() => {
|
|
504
|
+
const mask = props.mask === "auto" ? props.src.endsWith(".svg") : props.mask;
|
|
551
505
|
if (!mask) {
|
|
552
|
-
return
|
|
553
|
-
"--icon-url": `url('${icon}')`,
|
|
506
|
+
return {
|
|
554
507
|
"background-image": "var(--icon-url)",
|
|
555
|
-
"background-size": "100% 100%"
|
|
556
|
-
|
|
557
|
-
"width": width,
|
|
558
|
-
"display": "inline-block"
|
|
559
|
-
}, (_e = context.attrs.style) != null ? _e : {});
|
|
508
|
+
"background-size": "100% 100%"
|
|
509
|
+
};
|
|
560
510
|
}
|
|
561
|
-
return
|
|
562
|
-
"--icon-url": `url('${icon}')`,
|
|
511
|
+
return {
|
|
563
512
|
"mask": "var(--icon-url) no-repeat",
|
|
564
513
|
"mask-size": "100% 100%",
|
|
565
514
|
"-webkit-mask": "var(--icon-url) no-repeat",
|
|
566
515
|
"-webkit-mask-size": "100% 100%",
|
|
567
|
-
"background-color": color
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
516
|
+
"background-color": props.color
|
|
517
|
+
};
|
|
518
|
+
});
|
|
519
|
+
const staticStyle = vue.computed(() => {
|
|
520
|
+
return {
|
|
521
|
+
"--icon-url": `url('${props.src}')`
|
|
522
|
+
};
|
|
523
|
+
});
|
|
524
|
+
const style = vue.computed(() => {
|
|
525
|
+
return {
|
|
526
|
+
...staticStyle.value,
|
|
527
|
+
...dynamicStyle.value,
|
|
528
|
+
...sizeStyle.value,
|
|
529
|
+
...context.attrs.style ?? {}
|
|
530
|
+
};
|
|
572
531
|
});
|
|
573
532
|
return {
|
|
574
533
|
style
|
package/dist/index.d.cts
CHANGED
|
@@ -27,7 +27,7 @@ declare const affixProps: {
|
|
|
27
27
|
* @en Scroll container, default is `window`
|
|
28
28
|
*/
|
|
29
29
|
target: {
|
|
30
|
-
type: PropType<string |
|
|
30
|
+
type: PropType<string | HTMLElement>;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* @zh z-index 值
|
|
@@ -40,10 +40,11 @@ declare const affixProps: {
|
|
|
40
40
|
};
|
|
41
41
|
type AffixProps = typeof affixProps;
|
|
42
42
|
declare const affixEmits: ("scroll" | "change")[];
|
|
43
|
-
declare const AFFIX_TARGET_KEY: InjectionKey<MaybeRefOrGetter<
|
|
43
|
+
declare const AFFIX_TARGET_KEY: InjectionKey<MaybeRefOrGetter<Element | null | undefined>>;
|
|
44
44
|
declare const useAffix: _hoci_shared.HookComponent<{
|
|
45
|
-
|
|
45
|
+
className: vue.ComputedRef<string>;
|
|
46
46
|
wrapperRef: Ref<HTMLElement | null>;
|
|
47
|
+
containerRef: vue.ComputedRef<Element | (Window & typeof globalThis) | null>;
|
|
47
48
|
isFixed: Ref<boolean>;
|
|
48
49
|
placeholderStyle: Ref<CSSProperties>;
|
|
49
50
|
fixedStyle: Ref<CSSProperties>;
|
|
@@ -70,7 +71,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
70
71
|
* @en Scroll container, default is `window`
|
|
71
72
|
*/
|
|
72
73
|
target: {
|
|
73
|
-
type: PropType<string |
|
|
74
|
+
type: PropType<string | HTMLElement>;
|
|
74
75
|
};
|
|
75
76
|
/**
|
|
76
77
|
* @zh z-index 值
|
|
@@ -102,7 +103,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
102
103
|
* @en Scroll container, default is `window`
|
|
103
104
|
*/
|
|
104
105
|
target: {
|
|
105
|
-
type: PropType<string |
|
|
106
|
+
type: PropType<string | HTMLElement>;
|
|
106
107
|
};
|
|
107
108
|
/**
|
|
108
109
|
* @zh z-index 值
|
|
@@ -118,7 +119,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
118
119
|
offsetType: "top" | "bottom";
|
|
119
120
|
zIndex: number;
|
|
120
121
|
}>;
|
|
121
|
-
declare function provideAffixTarget(target: MaybeRefOrGetter<
|
|
122
|
+
declare function provideAffixTarget(target: MaybeRefOrGetter<Element | null | undefined>): void;
|
|
122
123
|
|
|
123
124
|
type InitFunction = (option: Option) => () => void;
|
|
124
125
|
interface Option {
|
|
@@ -188,7 +189,6 @@ declare const selectionProps: {
|
|
|
188
189
|
};
|
|
189
190
|
activateEvent: {
|
|
190
191
|
type: PropType<ActivateEvent>;
|
|
191
|
-
default: () => "click";
|
|
192
192
|
};
|
|
193
193
|
};
|
|
194
194
|
type SelectionProps = typeof selectionProps;
|
|
@@ -254,7 +254,6 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
|
|
|
254
254
|
};
|
|
255
255
|
activateEvent: {
|
|
256
256
|
type: PropType<ActivateEvent>;
|
|
257
|
-
default: () => "click";
|
|
258
257
|
};
|
|
259
258
|
}, vue.ExtractPropTypes<{
|
|
260
259
|
modelValue: {
|
|
@@ -305,7 +304,6 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
|
|
|
305
304
|
};
|
|
306
305
|
activateEvent: {
|
|
307
306
|
type: PropType<ActivateEvent>;
|
|
308
|
-
default: () => "click";
|
|
309
307
|
};
|
|
310
308
|
}>, {
|
|
311
309
|
multiple: number | boolean;
|
|
@@ -316,7 +314,6 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
|
|
|
316
314
|
unactiveClass: string | string[] | Record<string, boolean>;
|
|
317
315
|
clearable: boolean;
|
|
318
316
|
defaultValue: any;
|
|
319
|
-
activateEvent: ActivateEvent;
|
|
320
317
|
}>;
|
|
321
318
|
interface HiSelectionSlotData extends Record<string, unknown> {
|
|
322
319
|
isActive: (value: any) => boolean;
|
|
@@ -429,7 +426,6 @@ declare const switchProps: {
|
|
|
429
426
|
};
|
|
430
427
|
activateEvent: {
|
|
431
428
|
type: PropType<ActivateEvent>;
|
|
432
|
-
default: string;
|
|
433
429
|
};
|
|
434
430
|
disabled: {
|
|
435
431
|
type: BooleanConstructor;
|
|
@@ -447,6 +443,7 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
447
443
|
modelValue: vue.Ref<boolean>;
|
|
448
444
|
className: vue.ComputedRef<string>;
|
|
449
445
|
isDisabled: vue.ComputedRef<boolean>;
|
|
446
|
+
activateEvent: vue.ComputedRef<ActivateEvent>;
|
|
450
447
|
}, ("change" | "update:modelValue")[], {
|
|
451
448
|
modelValue: {
|
|
452
449
|
type: BooleanConstructor;
|
|
@@ -466,7 +463,6 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
466
463
|
};
|
|
467
464
|
activateEvent: {
|
|
468
465
|
type: PropType<ActivateEvent>;
|
|
469
|
-
default: string;
|
|
470
466
|
};
|
|
471
467
|
disabled: {
|
|
472
468
|
type: BooleanConstructor;
|
|
@@ -495,7 +491,6 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
495
491
|
};
|
|
496
492
|
activateEvent: {
|
|
497
493
|
type: PropType<ActivateEvent>;
|
|
498
|
-
default: string;
|
|
499
494
|
};
|
|
500
495
|
disabled: {
|
|
501
496
|
type: BooleanConstructor;
|
|
@@ -511,7 +506,6 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
511
506
|
activeClass: string | string[] | Record<string, boolean>;
|
|
512
507
|
disabledClass: string | string[] | Record<string, boolean>;
|
|
513
508
|
unactiveClass: string | string[] | Record<string, boolean>;
|
|
514
|
-
activateEvent: ActivateEvent;
|
|
515
509
|
}>;
|
|
516
510
|
|
|
517
511
|
declare const iconProps: {
|
|
@@ -521,7 +515,6 @@ declare const iconProps: {
|
|
|
521
515
|
};
|
|
522
516
|
size: {
|
|
523
517
|
type: (StringConstructor | NumberConstructor)[];
|
|
524
|
-
default: string;
|
|
525
518
|
};
|
|
526
519
|
width: {
|
|
527
520
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -531,6 +524,7 @@ declare const iconProps: {
|
|
|
531
524
|
};
|
|
532
525
|
color: {
|
|
533
526
|
type: StringConstructor;
|
|
527
|
+
default: string;
|
|
534
528
|
};
|
|
535
529
|
mask: {
|
|
536
530
|
type: PropType<boolean | "auto">;
|
|
@@ -547,7 +541,6 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
547
541
|
};
|
|
548
542
|
size: {
|
|
549
543
|
type: (StringConstructor | NumberConstructor)[];
|
|
550
|
-
default: string;
|
|
551
544
|
};
|
|
552
545
|
width: {
|
|
553
546
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -557,6 +550,7 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
557
550
|
};
|
|
558
551
|
color: {
|
|
559
552
|
type: StringConstructor;
|
|
553
|
+
default: string;
|
|
560
554
|
};
|
|
561
555
|
mask: {
|
|
562
556
|
type: PropType<boolean | "auto">;
|
|
@@ -569,7 +563,6 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
569
563
|
};
|
|
570
564
|
size: {
|
|
571
565
|
type: (StringConstructor | NumberConstructor)[];
|
|
572
|
-
default: string;
|
|
573
566
|
};
|
|
574
567
|
width: {
|
|
575
568
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -579,6 +572,7 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
579
572
|
};
|
|
580
573
|
color: {
|
|
581
574
|
type: StringConstructor;
|
|
575
|
+
default: string;
|
|
582
576
|
};
|
|
583
577
|
mask: {
|
|
584
578
|
type: PropType<boolean | "auto">;
|
|
@@ -586,7 +580,7 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
586
580
|
};
|
|
587
581
|
}>, {
|
|
588
582
|
mask: boolean | "auto";
|
|
589
|
-
|
|
583
|
+
color: string;
|
|
590
584
|
}>;
|
|
591
585
|
|
|
592
586
|
export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type SelectionProps, affixEmits, affixProps, iconProps, itemProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
|
package/dist/index.d.mts
CHANGED
|
@@ -27,7 +27,7 @@ declare const affixProps: {
|
|
|
27
27
|
* @en Scroll container, default is `window`
|
|
28
28
|
*/
|
|
29
29
|
target: {
|
|
30
|
-
type: PropType<string |
|
|
30
|
+
type: PropType<string | HTMLElement>;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* @zh z-index 值
|
|
@@ -40,10 +40,11 @@ declare const affixProps: {
|
|
|
40
40
|
};
|
|
41
41
|
type AffixProps = typeof affixProps;
|
|
42
42
|
declare const affixEmits: ("scroll" | "change")[];
|
|
43
|
-
declare const AFFIX_TARGET_KEY: InjectionKey<MaybeRefOrGetter<
|
|
43
|
+
declare const AFFIX_TARGET_KEY: InjectionKey<MaybeRefOrGetter<Element | null | undefined>>;
|
|
44
44
|
declare const useAffix: _hoci_shared.HookComponent<{
|
|
45
|
-
|
|
45
|
+
className: vue.ComputedRef<string>;
|
|
46
46
|
wrapperRef: Ref<HTMLElement | null>;
|
|
47
|
+
containerRef: vue.ComputedRef<Element | (Window & typeof globalThis) | null>;
|
|
47
48
|
isFixed: Ref<boolean>;
|
|
48
49
|
placeholderStyle: Ref<CSSProperties>;
|
|
49
50
|
fixedStyle: Ref<CSSProperties>;
|
|
@@ -70,7 +71,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
70
71
|
* @en Scroll container, default is `window`
|
|
71
72
|
*/
|
|
72
73
|
target: {
|
|
73
|
-
type: PropType<string |
|
|
74
|
+
type: PropType<string | HTMLElement>;
|
|
74
75
|
};
|
|
75
76
|
/**
|
|
76
77
|
* @zh z-index 值
|
|
@@ -102,7 +103,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
102
103
|
* @en Scroll container, default is `window`
|
|
103
104
|
*/
|
|
104
105
|
target: {
|
|
105
|
-
type: PropType<string |
|
|
106
|
+
type: PropType<string | HTMLElement>;
|
|
106
107
|
};
|
|
107
108
|
/**
|
|
108
109
|
* @zh z-index 值
|
|
@@ -118,7 +119,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
118
119
|
offsetType: "top" | "bottom";
|
|
119
120
|
zIndex: number;
|
|
120
121
|
}>;
|
|
121
|
-
declare function provideAffixTarget(target: MaybeRefOrGetter<
|
|
122
|
+
declare function provideAffixTarget(target: MaybeRefOrGetter<Element | null | undefined>): void;
|
|
122
123
|
|
|
123
124
|
type InitFunction = (option: Option) => () => void;
|
|
124
125
|
interface Option {
|
|
@@ -188,7 +189,6 @@ declare const selectionProps: {
|
|
|
188
189
|
};
|
|
189
190
|
activateEvent: {
|
|
190
191
|
type: PropType<ActivateEvent>;
|
|
191
|
-
default: () => "click";
|
|
192
192
|
};
|
|
193
193
|
};
|
|
194
194
|
type SelectionProps = typeof selectionProps;
|
|
@@ -254,7 +254,6 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
|
|
|
254
254
|
};
|
|
255
255
|
activateEvent: {
|
|
256
256
|
type: PropType<ActivateEvent>;
|
|
257
|
-
default: () => "click";
|
|
258
257
|
};
|
|
259
258
|
}, vue.ExtractPropTypes<{
|
|
260
259
|
modelValue: {
|
|
@@ -305,7 +304,6 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
|
|
|
305
304
|
};
|
|
306
305
|
activateEvent: {
|
|
307
306
|
type: PropType<ActivateEvent>;
|
|
308
|
-
default: () => "click";
|
|
309
307
|
};
|
|
310
308
|
}>, {
|
|
311
309
|
multiple: number | boolean;
|
|
@@ -316,7 +314,6 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
|
|
|
316
314
|
unactiveClass: string | string[] | Record<string, boolean>;
|
|
317
315
|
clearable: boolean;
|
|
318
316
|
defaultValue: any;
|
|
319
|
-
activateEvent: ActivateEvent;
|
|
320
317
|
}>;
|
|
321
318
|
interface HiSelectionSlotData extends Record<string, unknown> {
|
|
322
319
|
isActive: (value: any) => boolean;
|
|
@@ -429,7 +426,6 @@ declare const switchProps: {
|
|
|
429
426
|
};
|
|
430
427
|
activateEvent: {
|
|
431
428
|
type: PropType<ActivateEvent>;
|
|
432
|
-
default: string;
|
|
433
429
|
};
|
|
434
430
|
disabled: {
|
|
435
431
|
type: BooleanConstructor;
|
|
@@ -447,6 +443,7 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
447
443
|
modelValue: vue.Ref<boolean>;
|
|
448
444
|
className: vue.ComputedRef<string>;
|
|
449
445
|
isDisabled: vue.ComputedRef<boolean>;
|
|
446
|
+
activateEvent: vue.ComputedRef<ActivateEvent>;
|
|
450
447
|
}, ("change" | "update:modelValue")[], {
|
|
451
448
|
modelValue: {
|
|
452
449
|
type: BooleanConstructor;
|
|
@@ -466,7 +463,6 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
466
463
|
};
|
|
467
464
|
activateEvent: {
|
|
468
465
|
type: PropType<ActivateEvent>;
|
|
469
|
-
default: string;
|
|
470
466
|
};
|
|
471
467
|
disabled: {
|
|
472
468
|
type: BooleanConstructor;
|
|
@@ -495,7 +491,6 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
495
491
|
};
|
|
496
492
|
activateEvent: {
|
|
497
493
|
type: PropType<ActivateEvent>;
|
|
498
|
-
default: string;
|
|
499
494
|
};
|
|
500
495
|
disabled: {
|
|
501
496
|
type: BooleanConstructor;
|
|
@@ -511,7 +506,6 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
511
506
|
activeClass: string | string[] | Record<string, boolean>;
|
|
512
507
|
disabledClass: string | string[] | Record<string, boolean>;
|
|
513
508
|
unactiveClass: string | string[] | Record<string, boolean>;
|
|
514
|
-
activateEvent: ActivateEvent;
|
|
515
509
|
}>;
|
|
516
510
|
|
|
517
511
|
declare const iconProps: {
|
|
@@ -521,7 +515,6 @@ declare const iconProps: {
|
|
|
521
515
|
};
|
|
522
516
|
size: {
|
|
523
517
|
type: (StringConstructor | NumberConstructor)[];
|
|
524
|
-
default: string;
|
|
525
518
|
};
|
|
526
519
|
width: {
|
|
527
520
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -531,6 +524,7 @@ declare const iconProps: {
|
|
|
531
524
|
};
|
|
532
525
|
color: {
|
|
533
526
|
type: StringConstructor;
|
|
527
|
+
default: string;
|
|
534
528
|
};
|
|
535
529
|
mask: {
|
|
536
530
|
type: PropType<boolean | "auto">;
|
|
@@ -547,7 +541,6 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
547
541
|
};
|
|
548
542
|
size: {
|
|
549
543
|
type: (StringConstructor | NumberConstructor)[];
|
|
550
|
-
default: string;
|
|
551
544
|
};
|
|
552
545
|
width: {
|
|
553
546
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -557,6 +550,7 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
557
550
|
};
|
|
558
551
|
color: {
|
|
559
552
|
type: StringConstructor;
|
|
553
|
+
default: string;
|
|
560
554
|
};
|
|
561
555
|
mask: {
|
|
562
556
|
type: PropType<boolean | "auto">;
|
|
@@ -569,7 +563,6 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
569
563
|
};
|
|
570
564
|
size: {
|
|
571
565
|
type: (StringConstructor | NumberConstructor)[];
|
|
572
|
-
default: string;
|
|
573
566
|
};
|
|
574
567
|
width: {
|
|
575
568
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -579,6 +572,7 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
579
572
|
};
|
|
580
573
|
color: {
|
|
581
574
|
type: StringConstructor;
|
|
575
|
+
default: string;
|
|
582
576
|
};
|
|
583
577
|
mask: {
|
|
584
578
|
type: PropType<boolean | "auto">;
|
|
@@ -586,7 +580,7 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
586
580
|
};
|
|
587
581
|
}>, {
|
|
588
582
|
mask: boolean | "auto";
|
|
589
|
-
|
|
583
|
+
color: string;
|
|
590
584
|
}>;
|
|
591
585
|
|
|
592
586
|
export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type SelectionProps, affixEmits, affixProps, iconProps, itemProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
|
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ declare const affixProps: {
|
|
|
27
27
|
* @en Scroll container, default is `window`
|
|
28
28
|
*/
|
|
29
29
|
target: {
|
|
30
|
-
type: PropType<string |
|
|
30
|
+
type: PropType<string | HTMLElement>;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* @zh z-index 值
|
|
@@ -40,10 +40,11 @@ declare const affixProps: {
|
|
|
40
40
|
};
|
|
41
41
|
type AffixProps = typeof affixProps;
|
|
42
42
|
declare const affixEmits: ("scroll" | "change")[];
|
|
43
|
-
declare const AFFIX_TARGET_KEY: InjectionKey<MaybeRefOrGetter<
|
|
43
|
+
declare const AFFIX_TARGET_KEY: InjectionKey<MaybeRefOrGetter<Element | null | undefined>>;
|
|
44
44
|
declare const useAffix: _hoci_shared.HookComponent<{
|
|
45
|
-
|
|
45
|
+
className: vue.ComputedRef<string>;
|
|
46
46
|
wrapperRef: Ref<HTMLElement | null>;
|
|
47
|
+
containerRef: vue.ComputedRef<Element | (Window & typeof globalThis) | null>;
|
|
47
48
|
isFixed: Ref<boolean>;
|
|
48
49
|
placeholderStyle: Ref<CSSProperties>;
|
|
49
50
|
fixedStyle: Ref<CSSProperties>;
|
|
@@ -70,7 +71,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
70
71
|
* @en Scroll container, default is `window`
|
|
71
72
|
*/
|
|
72
73
|
target: {
|
|
73
|
-
type: PropType<string |
|
|
74
|
+
type: PropType<string | HTMLElement>;
|
|
74
75
|
};
|
|
75
76
|
/**
|
|
76
77
|
* @zh z-index 值
|
|
@@ -102,7 +103,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
102
103
|
* @en Scroll container, default is `window`
|
|
103
104
|
*/
|
|
104
105
|
target: {
|
|
105
|
-
type: PropType<string |
|
|
106
|
+
type: PropType<string | HTMLElement>;
|
|
106
107
|
};
|
|
107
108
|
/**
|
|
108
109
|
* @zh z-index 值
|
|
@@ -118,7 +119,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
|
|
|
118
119
|
offsetType: "top" | "bottom";
|
|
119
120
|
zIndex: number;
|
|
120
121
|
}>;
|
|
121
|
-
declare function provideAffixTarget(target: MaybeRefOrGetter<
|
|
122
|
+
declare function provideAffixTarget(target: MaybeRefOrGetter<Element | null | undefined>): void;
|
|
122
123
|
|
|
123
124
|
type InitFunction = (option: Option) => () => void;
|
|
124
125
|
interface Option {
|
|
@@ -188,7 +189,6 @@ declare const selectionProps: {
|
|
|
188
189
|
};
|
|
189
190
|
activateEvent: {
|
|
190
191
|
type: PropType<ActivateEvent>;
|
|
191
|
-
default: () => "click";
|
|
192
192
|
};
|
|
193
193
|
};
|
|
194
194
|
type SelectionProps = typeof selectionProps;
|
|
@@ -254,7 +254,6 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
|
|
|
254
254
|
};
|
|
255
255
|
activateEvent: {
|
|
256
256
|
type: PropType<ActivateEvent>;
|
|
257
|
-
default: () => "click";
|
|
258
257
|
};
|
|
259
258
|
}, vue.ExtractPropTypes<{
|
|
260
259
|
modelValue: {
|
|
@@ -305,7 +304,6 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
|
|
|
305
304
|
};
|
|
306
305
|
activateEvent: {
|
|
307
306
|
type: PropType<ActivateEvent>;
|
|
308
|
-
default: () => "click";
|
|
309
307
|
};
|
|
310
308
|
}>, {
|
|
311
309
|
multiple: number | boolean;
|
|
@@ -316,7 +314,6 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
|
|
|
316
314
|
unactiveClass: string | string[] | Record<string, boolean>;
|
|
317
315
|
clearable: boolean;
|
|
318
316
|
defaultValue: any;
|
|
319
|
-
activateEvent: ActivateEvent;
|
|
320
317
|
}>;
|
|
321
318
|
interface HiSelectionSlotData extends Record<string, unknown> {
|
|
322
319
|
isActive: (value: any) => boolean;
|
|
@@ -429,7 +426,6 @@ declare const switchProps: {
|
|
|
429
426
|
};
|
|
430
427
|
activateEvent: {
|
|
431
428
|
type: PropType<ActivateEvent>;
|
|
432
|
-
default: string;
|
|
433
429
|
};
|
|
434
430
|
disabled: {
|
|
435
431
|
type: BooleanConstructor;
|
|
@@ -447,6 +443,7 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
447
443
|
modelValue: vue.Ref<boolean>;
|
|
448
444
|
className: vue.ComputedRef<string>;
|
|
449
445
|
isDisabled: vue.ComputedRef<boolean>;
|
|
446
|
+
activateEvent: vue.ComputedRef<ActivateEvent>;
|
|
450
447
|
}, ("change" | "update:modelValue")[], {
|
|
451
448
|
modelValue: {
|
|
452
449
|
type: BooleanConstructor;
|
|
@@ -466,7 +463,6 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
466
463
|
};
|
|
467
464
|
activateEvent: {
|
|
468
465
|
type: PropType<ActivateEvent>;
|
|
469
|
-
default: string;
|
|
470
466
|
};
|
|
471
467
|
disabled: {
|
|
472
468
|
type: BooleanConstructor;
|
|
@@ -495,7 +491,6 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
495
491
|
};
|
|
496
492
|
activateEvent: {
|
|
497
493
|
type: PropType<ActivateEvent>;
|
|
498
|
-
default: string;
|
|
499
494
|
};
|
|
500
495
|
disabled: {
|
|
501
496
|
type: BooleanConstructor;
|
|
@@ -511,7 +506,6 @@ declare const useSwitch: _hoci_shared.HookComponent<{
|
|
|
511
506
|
activeClass: string | string[] | Record<string, boolean>;
|
|
512
507
|
disabledClass: string | string[] | Record<string, boolean>;
|
|
513
508
|
unactiveClass: string | string[] | Record<string, boolean>;
|
|
514
|
-
activateEvent: ActivateEvent;
|
|
515
509
|
}>;
|
|
516
510
|
|
|
517
511
|
declare const iconProps: {
|
|
@@ -521,7 +515,6 @@ declare const iconProps: {
|
|
|
521
515
|
};
|
|
522
516
|
size: {
|
|
523
517
|
type: (StringConstructor | NumberConstructor)[];
|
|
524
|
-
default: string;
|
|
525
518
|
};
|
|
526
519
|
width: {
|
|
527
520
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -531,6 +524,7 @@ declare const iconProps: {
|
|
|
531
524
|
};
|
|
532
525
|
color: {
|
|
533
526
|
type: StringConstructor;
|
|
527
|
+
default: string;
|
|
534
528
|
};
|
|
535
529
|
mask: {
|
|
536
530
|
type: PropType<boolean | "auto">;
|
|
@@ -547,7 +541,6 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
547
541
|
};
|
|
548
542
|
size: {
|
|
549
543
|
type: (StringConstructor | NumberConstructor)[];
|
|
550
|
-
default: string;
|
|
551
544
|
};
|
|
552
545
|
width: {
|
|
553
546
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -557,6 +550,7 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
557
550
|
};
|
|
558
551
|
color: {
|
|
559
552
|
type: StringConstructor;
|
|
553
|
+
default: string;
|
|
560
554
|
};
|
|
561
555
|
mask: {
|
|
562
556
|
type: PropType<boolean | "auto">;
|
|
@@ -569,7 +563,6 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
569
563
|
};
|
|
570
564
|
size: {
|
|
571
565
|
type: (StringConstructor | NumberConstructor)[];
|
|
572
|
-
default: string;
|
|
573
566
|
};
|
|
574
567
|
width: {
|
|
575
568
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -579,6 +572,7 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
579
572
|
};
|
|
580
573
|
color: {
|
|
581
574
|
type: StringConstructor;
|
|
575
|
+
default: string;
|
|
582
576
|
};
|
|
583
577
|
mask: {
|
|
584
578
|
type: PropType<boolean | "auto">;
|
|
@@ -586,7 +580,7 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
586
580
|
};
|
|
587
581
|
}>, {
|
|
588
582
|
mask: boolean | "auto";
|
|
589
|
-
|
|
583
|
+
color: string;
|
|
590
584
|
}>;
|
|
591
585
|
|
|
592
586
|
export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type SelectionProps, affixEmits, affixProps, iconProps, itemProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
|
package/dist/index.mjs
CHANGED
|
@@ -1,45 +1,9 @@
|
|
|
1
|
-
import { ref, inject, computed, watchPostEffect,
|
|
1
|
+
import { ref, inject, computed, watchPostEffect, provide, reactive, watch, renderSlot } from 'vue';
|
|
2
2
|
import { useElementVisibility, useEventListener, syncRef, toReactive, isDefined, tryOnScopeDispose, useVModel } from '@vueuse/core';
|
|
3
|
-
import { defineHookProps, defineHookEmits, defineHookComponent, useElement, throttleByRaf, isWindow, valuePropType, classPropType, labelPropType } from '@hoci/shared';
|
|
3
|
+
import { defineHookProps, defineHookEmits, defineHookComponent, useElement, throttleByRaf, isWindow, valuePropType, classPropType, labelPropType, useSharedConfig } from '@hoci/shared';
|
|
4
4
|
export * from '@hoci/shared';
|
|
5
|
-
import { cls } from 'tslx';
|
|
5
|
+
import { cls, unit_f } from 'tslx';
|
|
6
6
|
|
|
7
|
-
var __defProp$1 = Object.defineProperty;
|
|
8
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
9
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues$1 = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
15
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols$1)
|
|
17
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
18
|
-
if (__propIsEnum$1.call(b, prop))
|
|
19
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __async = (__this, __arguments, generator) => {
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
var fulfilled = (value) => {
|
|
26
|
-
try {
|
|
27
|
-
step(generator.next(value));
|
|
28
|
-
} catch (e) {
|
|
29
|
-
reject(e);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var rejected = (value) => {
|
|
33
|
-
try {
|
|
34
|
-
step(generator.throw(value));
|
|
35
|
-
} catch (e) {
|
|
36
|
-
reject(e);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
40
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
7
|
const affixProps = defineHookProps(
|
|
44
8
|
{
|
|
45
9
|
fixedClass: {
|
|
@@ -87,29 +51,27 @@ const useAffix = defineHookComponent({
|
|
|
87
51
|
props: affixProps,
|
|
88
52
|
setup(props, { emit }) {
|
|
89
53
|
const wrapperRef = ref(null);
|
|
90
|
-
const parentRef = inject(AFFIX_TARGET_KEY,
|
|
54
|
+
const parentRef = inject(AFFIX_TARGET_KEY, void 0);
|
|
91
55
|
const targetRef = useElement(props.target, parentRef);
|
|
92
56
|
const isFixed = ref(false);
|
|
93
57
|
const placeholderStyle = ref({});
|
|
94
58
|
const fixedStyle = ref({});
|
|
95
|
-
const
|
|
59
|
+
const className = computed(() => {
|
|
96
60
|
return isFixed.value ? props.fixedClass : "";
|
|
97
61
|
});
|
|
98
62
|
const wrapperVisible = useElementVisibility(wrapperRef);
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
if (!targetRef.value || !wrapperVisible.value) {
|
|
63
|
+
const containerRef = computed(() => {
|
|
64
|
+
if (!wrapperVisible.value) {
|
|
102
65
|
return null;
|
|
103
66
|
}
|
|
104
|
-
return
|
|
67
|
+
return targetRef.value ?? window;
|
|
105
68
|
});
|
|
106
|
-
const updatePosition = throttleByRaf(() =>
|
|
107
|
-
if (!wrapperRef.value || !
|
|
69
|
+
const updatePosition = throttleByRaf(async () => {
|
|
70
|
+
if (!wrapperRef.value || !containerRef.value) {
|
|
108
71
|
return;
|
|
109
72
|
}
|
|
110
|
-
yield nextTick();
|
|
111
73
|
const wrapperRect = wrapperRef.value.getBoundingClientRect();
|
|
112
|
-
const targetRect = getTargetRect(
|
|
74
|
+
const targetRect = getTargetRect(containerRef.value);
|
|
113
75
|
let newIsFixed = false;
|
|
114
76
|
let newFixedStyles = {};
|
|
115
77
|
const newPlaceholderStyles = {
|
|
@@ -136,17 +98,21 @@ const useAffix = defineHookComponent({
|
|
|
136
98
|
emit("change", newIsFixed);
|
|
137
99
|
}
|
|
138
100
|
placeholderStyle.value = newPlaceholderStyles;
|
|
139
|
-
fixedStyle.value =
|
|
140
|
-
|
|
141
|
-
|
|
101
|
+
fixedStyle.value = {
|
|
102
|
+
...newFixedStyles,
|
|
103
|
+
...newIsFixed ? newPlaceholderStyles : {}
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
useEventListener(containerRef, "scroll", () => {
|
|
142
107
|
emit("scroll");
|
|
143
108
|
updatePosition();
|
|
144
109
|
});
|
|
145
|
-
useEventListener(
|
|
110
|
+
useEventListener(containerRef, "resize", updatePosition);
|
|
146
111
|
watchPostEffect(updatePosition);
|
|
147
112
|
return {
|
|
148
|
-
|
|
113
|
+
className,
|
|
149
114
|
wrapperRef,
|
|
115
|
+
containerRef,
|
|
150
116
|
isFixed,
|
|
151
117
|
placeholderStyle,
|
|
152
118
|
fixedStyle,
|
|
@@ -206,8 +172,7 @@ const selectionProps = defineHookProps({
|
|
|
206
172
|
default: () => null
|
|
207
173
|
},
|
|
208
174
|
activateEvent: {
|
|
209
|
-
type: String
|
|
210
|
-
default: () => "click"
|
|
175
|
+
type: String
|
|
211
176
|
}
|
|
212
177
|
});
|
|
213
178
|
const selectionEmits = defineHookEmits([
|
|
@@ -218,6 +183,7 @@ const selectionEmits = defineHookEmits([
|
|
|
218
183
|
]);
|
|
219
184
|
const HiSelectionContextSymbol = Symbol("[hi-selection]context");
|
|
220
185
|
function useSelectionContext() {
|
|
186
|
+
const sharedConfig = useSharedConfig();
|
|
221
187
|
return inject(HiSelectionContextSymbol, {
|
|
222
188
|
isActive: () => false,
|
|
223
189
|
changeActive: () => {
|
|
@@ -226,7 +192,7 @@ function useSelectionContext() {
|
|
|
226
192
|
unactiveClass: "unactive",
|
|
227
193
|
disabledClass: "disabled",
|
|
228
194
|
itemClass: "",
|
|
229
|
-
activateEvent:
|
|
195
|
+
activateEvent: sharedConfig.activateEvent,
|
|
230
196
|
label: null,
|
|
231
197
|
multiple: false
|
|
232
198
|
});
|
|
@@ -235,7 +201,6 @@ const useSelectionList = defineHookComponent({
|
|
|
235
201
|
props: selectionProps,
|
|
236
202
|
emits: selectionEmits,
|
|
237
203
|
setup(props, { emit }) {
|
|
238
|
-
var _a;
|
|
239
204
|
const options = reactive([]);
|
|
240
205
|
function toArray(value) {
|
|
241
206
|
if (!isDefined(value)) {
|
|
@@ -247,7 +212,7 @@ const useSelectionList = defineHookComponent({
|
|
|
247
212
|
return [value];
|
|
248
213
|
}
|
|
249
214
|
const actives = reactive([
|
|
250
|
-
...toArray(
|
|
215
|
+
...toArray(props.modelValue ?? props.defaultValue)
|
|
251
216
|
]);
|
|
252
217
|
const currentValue = computed({
|
|
253
218
|
get() {
|
|
@@ -259,8 +224,7 @@ const useSelectionList = defineHookComponent({
|
|
|
259
224
|
});
|
|
260
225
|
const modelValue = computed({
|
|
261
226
|
get() {
|
|
262
|
-
|
|
263
|
-
return (_a2 = props.modelValue) != null ? _a2 : props.defaultValue;
|
|
227
|
+
return props.modelValue ?? props.defaultValue;
|
|
264
228
|
},
|
|
265
229
|
set(val) {
|
|
266
230
|
emit("update:modelValue", val);
|
|
@@ -308,6 +272,7 @@ const useSelectionList = defineHookComponent({
|
|
|
308
272
|
emit("load", option);
|
|
309
273
|
return remove;
|
|
310
274
|
};
|
|
275
|
+
const sharedConfig = useSharedConfig();
|
|
311
276
|
provide(HiSelectionContextSymbol, toReactive({
|
|
312
277
|
activeClass: computed(() => cls(props.activeClass)),
|
|
313
278
|
unactiveClass: computed(() => cls(props.unactiveClass)),
|
|
@@ -317,7 +282,7 @@ const useSelectionList = defineHookComponent({
|
|
|
317
282
|
multiple: computed(() => props.multiple),
|
|
318
283
|
clearable: computed(() => props.clearable),
|
|
319
284
|
defaultValue: computed(() => props.defaultValue),
|
|
320
|
-
activateEvent: computed(() => props.activateEvent),
|
|
285
|
+
activateEvent: computed(() => props.activateEvent ?? sharedConfig.activateEvent),
|
|
321
286
|
active: currentValue,
|
|
322
287
|
changeActive,
|
|
323
288
|
isActive,
|
|
@@ -377,8 +342,7 @@ const useSelectionItem = defineHookComponent({
|
|
|
377
342
|
active: context.isActive(props.value),
|
|
378
343
|
activate
|
|
379
344
|
}, () => {
|
|
380
|
-
|
|
381
|
-
let label = (_a = props.label) != null ? _a : context.label;
|
|
345
|
+
let label = props.label ?? context.label;
|
|
382
346
|
if (label && typeof label == "function") {
|
|
383
347
|
label = label(props.value);
|
|
384
348
|
}
|
|
@@ -415,7 +379,7 @@ const useSelectionItem = defineHookComponent({
|
|
|
415
379
|
}
|
|
416
380
|
return cls(array);
|
|
417
381
|
});
|
|
418
|
-
const activateEvent = computed(() => context.activateEvent);
|
|
382
|
+
const activateEvent = computed(() => props.activateEvent ?? context.activateEvent);
|
|
419
383
|
return {
|
|
420
384
|
activate,
|
|
421
385
|
render,
|
|
@@ -445,8 +409,7 @@ const switchProps = defineHookProps({
|
|
|
445
409
|
default: "unchecked"
|
|
446
410
|
},
|
|
447
411
|
activateEvent: {
|
|
448
|
-
type: String
|
|
449
|
-
default: "click"
|
|
412
|
+
type: String
|
|
450
413
|
},
|
|
451
414
|
disabled: {
|
|
452
415
|
type: Boolean,
|
|
@@ -485,39 +448,25 @@ const useSwitch = defineHookComponent({
|
|
|
485
448
|
isDisabled.value ? props.disabledClass : ""
|
|
486
449
|
]);
|
|
487
450
|
});
|
|
451
|
+
const sharedConfig = useSharedConfig();
|
|
452
|
+
const activateEvent = computed(() => props.activateEvent ?? sharedConfig.activateEvent);
|
|
488
453
|
return {
|
|
489
454
|
toggle,
|
|
490
455
|
modelValue,
|
|
491
456
|
className,
|
|
492
|
-
isDisabled
|
|
457
|
+
isDisabled,
|
|
458
|
+
activateEvent
|
|
493
459
|
};
|
|
494
460
|
}
|
|
495
461
|
});
|
|
496
462
|
|
|
497
|
-
var __defProp = Object.defineProperty;
|
|
498
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
499
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
500
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
501
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
502
|
-
var __spreadValues = (a, b) => {
|
|
503
|
-
for (var prop in b || (b = {}))
|
|
504
|
-
if (__hasOwnProp.call(b, prop))
|
|
505
|
-
__defNormalProp(a, prop, b[prop]);
|
|
506
|
-
if (__getOwnPropSymbols)
|
|
507
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
508
|
-
if (__propIsEnum.call(b, prop))
|
|
509
|
-
__defNormalProp(a, prop, b[prop]);
|
|
510
|
-
}
|
|
511
|
-
return a;
|
|
512
|
-
};
|
|
513
463
|
const iconProps = defineHookProps({
|
|
514
464
|
src: {
|
|
515
465
|
type: String,
|
|
516
466
|
required: true
|
|
517
467
|
},
|
|
518
468
|
size: {
|
|
519
|
-
type: [Number, String]
|
|
520
|
-
default: "1rem"
|
|
469
|
+
type: [Number, String]
|
|
521
470
|
},
|
|
522
471
|
width: {
|
|
523
472
|
type: [Number, String]
|
|
@@ -526,7 +475,8 @@ const iconProps = defineHookProps({
|
|
|
526
475
|
type: [Number, String]
|
|
527
476
|
},
|
|
528
477
|
color: {
|
|
529
|
-
type: String
|
|
478
|
+
type: String,
|
|
479
|
+
default: "currentColor"
|
|
530
480
|
},
|
|
531
481
|
mask: {
|
|
532
482
|
type: [Boolean, String],
|
|
@@ -536,38 +486,47 @@ const iconProps = defineHookProps({
|
|
|
536
486
|
const useIcon = defineHookComponent({
|
|
537
487
|
props: iconProps,
|
|
538
488
|
setup(props, context) {
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
const
|
|
543
|
-
const
|
|
544
|
-
const
|
|
545
|
-
const width =
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
489
|
+
const sharedConfig = useSharedConfig("icon");
|
|
490
|
+
const sizeStyle = computed(() => {
|
|
491
|
+
const s = props.size ?? sharedConfig.size;
|
|
492
|
+
const size = s ? unit_f(s, sharedConfig.sizeUnit) : void 0;
|
|
493
|
+
const w = props.width ?? size;
|
|
494
|
+
const h = props.height ?? size;
|
|
495
|
+
const width = w ? unit_f(w, sharedConfig.sizeUnit) : void 0;
|
|
496
|
+
const height = h ? unit_f(h, sharedConfig.sizeUnit) : void 0;
|
|
497
|
+
return {
|
|
498
|
+
width,
|
|
499
|
+
height
|
|
500
|
+
};
|
|
501
|
+
});
|
|
502
|
+
const dynamicStyle = computed(() => {
|
|
503
|
+
const mask = props.mask === "auto" ? props.src.endsWith(".svg") : props.mask;
|
|
550
504
|
if (!mask) {
|
|
551
|
-
return
|
|
552
|
-
"--icon-url": `url('${icon}')`,
|
|
505
|
+
return {
|
|
553
506
|
"background-image": "var(--icon-url)",
|
|
554
|
-
"background-size": "100% 100%"
|
|
555
|
-
|
|
556
|
-
"width": width,
|
|
557
|
-
"display": "inline-block"
|
|
558
|
-
}, (_e = context.attrs.style) != null ? _e : {});
|
|
507
|
+
"background-size": "100% 100%"
|
|
508
|
+
};
|
|
559
509
|
}
|
|
560
|
-
return
|
|
561
|
-
"--icon-url": `url('${icon}')`,
|
|
510
|
+
return {
|
|
562
511
|
"mask": "var(--icon-url) no-repeat",
|
|
563
512
|
"mask-size": "100% 100%",
|
|
564
513
|
"-webkit-mask": "var(--icon-url) no-repeat",
|
|
565
514
|
"-webkit-mask-size": "100% 100%",
|
|
566
|
-
"background-color": color
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
515
|
+
"background-color": props.color
|
|
516
|
+
};
|
|
517
|
+
});
|
|
518
|
+
const staticStyle = computed(() => {
|
|
519
|
+
return {
|
|
520
|
+
"--icon-url": `url('${props.src}')`
|
|
521
|
+
};
|
|
522
|
+
});
|
|
523
|
+
const style = computed(() => {
|
|
524
|
+
return {
|
|
525
|
+
...staticStyle.value,
|
|
526
|
+
...dynamicStyle.value,
|
|
527
|
+
...sizeStyle.value,
|
|
528
|
+
...context.attrs.style ?? {}
|
|
529
|
+
};
|
|
571
530
|
});
|
|
572
531
|
return {
|
|
573
532
|
style
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hoci/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "chizuki",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
9
10
|
"require": "./dist/index.cjs",
|
|
10
11
|
"import": "./dist/index.mjs"
|
|
11
12
|
},
|
|
@@ -22,11 +23,10 @@
|
|
|
22
23
|
"vue": "^3.3.4"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@vueuse/core": "^10.
|
|
26
|
-
"maybe-types": "^0.0
|
|
27
|
-
"tslx": "^0.1.
|
|
28
|
-
"@hoci/
|
|
29
|
-
"@hoci/shared": "0.3.0"
|
|
26
|
+
"@vueuse/core": "^10.5.0",
|
|
27
|
+
"maybe-types": "^0.1.0",
|
|
28
|
+
"tslx": "^0.1.1",
|
|
29
|
+
"@hoci/shared": "0.4.2"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "unbuild",
|