@hoci/components 0.5.9 → 0.7.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 +505 -145
- package/dist/index.d.cts +308 -269
- package/dist/index.d.mts +308 -269
- package/dist/index.d.ts +308 -269
- package/dist/index.mjs +499 -140
- package/package.json +3 -4
package/dist/index.cjs
CHANGED
|
@@ -1,28 +1,316 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const vue = require('vue');
|
|
4
|
-
const core = require('@hoci/core');
|
|
5
|
-
const core$1 = require('@vueuse/core');
|
|
6
3
|
const shared = require('@hoci/shared');
|
|
4
|
+
const vue = require('vue');
|
|
7
5
|
const tslx = require('tslx');
|
|
6
|
+
const core = require('@hoci/core');
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
var _a;
|
|
9
|
+
const isClient = typeof window !== "undefined";
|
|
10
|
+
const isString = (val) => typeof val === "string";
|
|
11
|
+
const noop = () => {
|
|
12
|
+
};
|
|
13
|
+
isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
14
|
+
|
|
15
|
+
function resolveUnref(r) {
|
|
16
|
+
return typeof r === "function" ? r() : vue.unref(r);
|
|
17
|
+
}
|
|
18
|
+
function identity(arg) {
|
|
19
|
+
return arg;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function tryOnScopeDispose(fn) {
|
|
23
|
+
if (vue.getCurrentScope()) {
|
|
24
|
+
vue.onScopeDispose(fn);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isDefined(v) {
|
|
31
|
+
return vue.unref(v) != null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function syncRef(left, right, options = {}) {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
const {
|
|
37
|
+
flush = "sync",
|
|
38
|
+
deep = false,
|
|
39
|
+
immediate = true,
|
|
40
|
+
direction = "both",
|
|
41
|
+
transform = {}
|
|
42
|
+
} = options;
|
|
43
|
+
let watchLeft;
|
|
44
|
+
let watchRight;
|
|
45
|
+
const transformLTR = (_a = transform.ltr) != null ? _a : (v) => v;
|
|
46
|
+
const transformRTL = (_b = transform.rtl) != null ? _b : (v) => v;
|
|
47
|
+
if (direction === "both" || direction === "ltr") {
|
|
48
|
+
watchLeft = vue.watch(left, (newValue) => right.value = transformLTR(newValue), { flush, deep, immediate });
|
|
49
|
+
}
|
|
50
|
+
if (direction === "both" || direction === "rtl") {
|
|
51
|
+
watchRight = vue.watch(right, (newValue) => left.value = transformRTL(newValue), { flush, deep, immediate });
|
|
52
|
+
}
|
|
53
|
+
return () => {
|
|
54
|
+
watchLeft == null ? void 0 : watchLeft();
|
|
55
|
+
watchRight == null ? void 0 : watchRight();
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function tryOnMounted(fn, sync = true) {
|
|
60
|
+
if (vue.getCurrentInstance())
|
|
61
|
+
vue.onMounted(fn);
|
|
62
|
+
else if (sync)
|
|
63
|
+
fn();
|
|
64
|
+
else
|
|
65
|
+
vue.nextTick(fn);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function unrefElement(elRef) {
|
|
69
|
+
var _a;
|
|
70
|
+
const plain = resolveUnref(elRef);
|
|
71
|
+
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const defaultWindow = isClient ? window : void 0;
|
|
75
|
+
|
|
76
|
+
function useEventListener(...args) {
|
|
77
|
+
let target;
|
|
78
|
+
let events;
|
|
79
|
+
let listeners;
|
|
80
|
+
let options;
|
|
81
|
+
if (isString(args[0]) || Array.isArray(args[0])) {
|
|
82
|
+
[events, listeners, options] = args;
|
|
83
|
+
target = defaultWindow;
|
|
84
|
+
} else {
|
|
85
|
+
[target, events, listeners, options] = args;
|
|
86
|
+
}
|
|
87
|
+
if (!target)
|
|
88
|
+
return noop;
|
|
89
|
+
if (!Array.isArray(events))
|
|
90
|
+
events = [events];
|
|
91
|
+
if (!Array.isArray(listeners))
|
|
92
|
+
listeners = [listeners];
|
|
93
|
+
const cleanups = [];
|
|
94
|
+
const cleanup = () => {
|
|
95
|
+
cleanups.forEach((fn) => fn());
|
|
96
|
+
cleanups.length = 0;
|
|
97
|
+
};
|
|
98
|
+
const register = (el, event, listener) => {
|
|
99
|
+
el.addEventListener(event, listener, options);
|
|
100
|
+
return () => el.removeEventListener(event, listener, options);
|
|
101
|
+
};
|
|
102
|
+
const stopWatch = vue.watch(() => unrefElement(target), (el) => {
|
|
103
|
+
cleanup();
|
|
104
|
+
if (!el)
|
|
105
|
+
return;
|
|
106
|
+
cleanups.push(...events.flatMap((event) => {
|
|
107
|
+
return listeners.map((listener) => register(el, event, listener));
|
|
108
|
+
}));
|
|
109
|
+
}, { immediate: true, flush: "post" });
|
|
110
|
+
const stop = () => {
|
|
111
|
+
stopWatch();
|
|
112
|
+
cleanup();
|
|
113
|
+
};
|
|
114
|
+
tryOnScopeDispose(stop);
|
|
115
|
+
return stop;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function useSupported(callback, sync = false) {
|
|
119
|
+
const isSupported = vue.ref();
|
|
120
|
+
const update = () => isSupported.value = Boolean(callback());
|
|
121
|
+
update();
|
|
122
|
+
tryOnMounted(update, sync);
|
|
123
|
+
return isSupported;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
127
|
+
const globalKey = "__vueuse_ssr_handlers__";
|
|
128
|
+
_global[globalKey] = _global[globalKey] || {};
|
|
129
|
+
|
|
130
|
+
var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
|
|
131
|
+
var __hasOwnProp$f = Object.prototype.hasOwnProperty;
|
|
132
|
+
var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
|
|
133
|
+
var __objRest$2 = (source, exclude) => {
|
|
134
|
+
var target = {};
|
|
135
|
+
for (var prop in source)
|
|
136
|
+
if (__hasOwnProp$f.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
137
|
+
target[prop] = source[prop];
|
|
138
|
+
if (source != null && __getOwnPropSymbols$f)
|
|
139
|
+
for (var prop of __getOwnPropSymbols$f(source)) {
|
|
140
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$f.call(source, prop))
|
|
141
|
+
target[prop] = source[prop];
|
|
16
142
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
143
|
+
return target;
|
|
144
|
+
};
|
|
145
|
+
function useResizeObserver(target, callback, options = {}) {
|
|
146
|
+
const _a = options, { window = defaultWindow } = _a, observerOptions = __objRest$2(_a, ["window"]);
|
|
147
|
+
let observer;
|
|
148
|
+
const isSupported = useSupported(() => window && "ResizeObserver" in window);
|
|
149
|
+
const cleanup = () => {
|
|
150
|
+
if (observer) {
|
|
151
|
+
observer.disconnect();
|
|
152
|
+
observer = void 0;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const stopWatch = vue.watch(() => unrefElement(target), (el) => {
|
|
156
|
+
cleanup();
|
|
157
|
+
if (isSupported.value && window && el) {
|
|
158
|
+
observer = new ResizeObserver(callback);
|
|
159
|
+
observer.observe(el, observerOptions);
|
|
160
|
+
}
|
|
161
|
+
}, { immediate: true, flush: "post" });
|
|
162
|
+
const stop = () => {
|
|
163
|
+
cleanup();
|
|
164
|
+
stopWatch();
|
|
165
|
+
};
|
|
166
|
+
tryOnScopeDispose(stop);
|
|
167
|
+
return {
|
|
168
|
+
isSupported,
|
|
169
|
+
stop
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function useElementBounding(target, options = {}) {
|
|
174
|
+
const {
|
|
175
|
+
reset = true,
|
|
176
|
+
windowResize = true,
|
|
177
|
+
windowScroll = true,
|
|
178
|
+
immediate = true
|
|
179
|
+
} = options;
|
|
180
|
+
const height = vue.ref(0);
|
|
181
|
+
const bottom = vue.ref(0);
|
|
182
|
+
const left = vue.ref(0);
|
|
183
|
+
const right = vue.ref(0);
|
|
184
|
+
const top = vue.ref(0);
|
|
185
|
+
const width = vue.ref(0);
|
|
186
|
+
const x = vue.ref(0);
|
|
187
|
+
const y = vue.ref(0);
|
|
188
|
+
function update() {
|
|
189
|
+
const el = unrefElement(target);
|
|
190
|
+
if (!el) {
|
|
191
|
+
if (reset) {
|
|
192
|
+
height.value = 0;
|
|
193
|
+
bottom.value = 0;
|
|
194
|
+
left.value = 0;
|
|
195
|
+
right.value = 0;
|
|
196
|
+
top.value = 0;
|
|
197
|
+
width.value = 0;
|
|
198
|
+
x.value = 0;
|
|
199
|
+
y.value = 0;
|
|
200
|
+
}
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const rect = el.getBoundingClientRect();
|
|
204
|
+
height.value = rect.height;
|
|
205
|
+
bottom.value = rect.bottom;
|
|
206
|
+
left.value = rect.left;
|
|
207
|
+
right.value = rect.right;
|
|
208
|
+
top.value = rect.top;
|
|
209
|
+
width.value = rect.width;
|
|
210
|
+
x.value = rect.x;
|
|
211
|
+
y.value = rect.y;
|
|
24
212
|
}
|
|
25
|
-
|
|
213
|
+
useResizeObserver(target, update);
|
|
214
|
+
vue.watch(() => unrefElement(target), (ele) => !ele && update());
|
|
215
|
+
if (windowScroll)
|
|
216
|
+
useEventListener("scroll", update, { capture: true, passive: true });
|
|
217
|
+
if (windowResize)
|
|
218
|
+
useEventListener("resize", update, { passive: true });
|
|
219
|
+
tryOnMounted(() => {
|
|
220
|
+
if (immediate)
|
|
221
|
+
update();
|
|
222
|
+
});
|
|
223
|
+
return {
|
|
224
|
+
height,
|
|
225
|
+
bottom,
|
|
226
|
+
left,
|
|
227
|
+
right,
|
|
228
|
+
top,
|
|
229
|
+
width,
|
|
230
|
+
x,
|
|
231
|
+
y,
|
|
232
|
+
update
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function useElementVisibility(element, { window = defaultWindow, scrollTarget } = {}) {
|
|
237
|
+
const elementIsVisible = vue.ref(false);
|
|
238
|
+
const testBounding = () => {
|
|
239
|
+
if (!window)
|
|
240
|
+
return;
|
|
241
|
+
const document = window.document;
|
|
242
|
+
const el = unrefElement(element);
|
|
243
|
+
if (!el) {
|
|
244
|
+
elementIsVisible.value = false;
|
|
245
|
+
} else {
|
|
246
|
+
const rect = el.getBoundingClientRect();
|
|
247
|
+
elementIsVisible.value = rect.top <= (window.innerHeight || document.documentElement.clientHeight) && rect.left <= (window.innerWidth || document.documentElement.clientWidth) && rect.bottom >= 0 && rect.right >= 0;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
vue.watch(() => unrefElement(element), () => testBounding(), { immediate: true, flush: "post" });
|
|
251
|
+
if (window) {
|
|
252
|
+
useEventListener(scrollTarget || window, "scroll", testBounding, {
|
|
253
|
+
capture: false,
|
|
254
|
+
passive: true
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
return elementIsVisible;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
var SwipeDirection;
|
|
261
|
+
(function(SwipeDirection2) {
|
|
262
|
+
SwipeDirection2["UP"] = "UP";
|
|
263
|
+
SwipeDirection2["RIGHT"] = "RIGHT";
|
|
264
|
+
SwipeDirection2["DOWN"] = "DOWN";
|
|
265
|
+
SwipeDirection2["LEFT"] = "LEFT";
|
|
266
|
+
SwipeDirection2["NONE"] = "NONE";
|
|
267
|
+
})(SwipeDirection || (SwipeDirection = {}));
|
|
268
|
+
|
|
269
|
+
var __defProp = Object.defineProperty;
|
|
270
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
271
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
272
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
273
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
274
|
+
var __spreadValues = (a, b) => {
|
|
275
|
+
for (var prop in b || (b = {}))
|
|
276
|
+
if (__hasOwnProp.call(b, prop))
|
|
277
|
+
__defNormalProp(a, prop, b[prop]);
|
|
278
|
+
if (__getOwnPropSymbols)
|
|
279
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
280
|
+
if (__propIsEnum.call(b, prop))
|
|
281
|
+
__defNormalProp(a, prop, b[prop]);
|
|
282
|
+
}
|
|
283
|
+
return a;
|
|
284
|
+
};
|
|
285
|
+
const _TransitionPresets = {
|
|
286
|
+
easeInSine: [0.12, 0, 0.39, 0],
|
|
287
|
+
easeOutSine: [0.61, 1, 0.88, 1],
|
|
288
|
+
easeInOutSine: [0.37, 0, 0.63, 1],
|
|
289
|
+
easeInQuad: [0.11, 0, 0.5, 0],
|
|
290
|
+
easeOutQuad: [0.5, 1, 0.89, 1],
|
|
291
|
+
easeInOutQuad: [0.45, 0, 0.55, 1],
|
|
292
|
+
easeInCubic: [0.32, 0, 0.67, 0],
|
|
293
|
+
easeOutCubic: [0.33, 1, 0.68, 1],
|
|
294
|
+
easeInOutCubic: [0.65, 0, 0.35, 1],
|
|
295
|
+
easeInQuart: [0.5, 0, 0.75, 0],
|
|
296
|
+
easeOutQuart: [0.25, 1, 0.5, 1],
|
|
297
|
+
easeInOutQuart: [0.76, 0, 0.24, 1],
|
|
298
|
+
easeInQuint: [0.64, 0, 0.78, 0],
|
|
299
|
+
easeOutQuint: [0.22, 1, 0.36, 1],
|
|
300
|
+
easeInOutQuint: [0.83, 0, 0.17, 1],
|
|
301
|
+
easeInExpo: [0.7, 0, 0.84, 0],
|
|
302
|
+
easeOutExpo: [0.16, 1, 0.3, 1],
|
|
303
|
+
easeInOutExpo: [0.87, 0, 0.13, 1],
|
|
304
|
+
easeInCirc: [0.55, 0, 1, 0.45],
|
|
305
|
+
easeOutCirc: [0, 0.55, 0.45, 1],
|
|
306
|
+
easeInOutCirc: [0.85, 0, 0.15, 1],
|
|
307
|
+
easeInBack: [0.36, 0, 0.66, -0.56],
|
|
308
|
+
easeOutBack: [0.34, 1.56, 0.64, 1],
|
|
309
|
+
easeInOutBack: [0.68, -0.6, 0.32, 1.6]
|
|
310
|
+
};
|
|
311
|
+
__spreadValues({
|
|
312
|
+
linear: identity
|
|
313
|
+
}, _TransitionPresets);
|
|
26
314
|
|
|
27
315
|
const affixProps = shared.defineHookProps(
|
|
28
316
|
{
|
|
@@ -73,8 +361,8 @@ function getTargetRect(target) {
|
|
|
73
361
|
shared.defineHookComponent({
|
|
74
362
|
props: affixProps,
|
|
75
363
|
setup(props, { emit }) {
|
|
76
|
-
const wrapperRef =
|
|
77
|
-
const wrapperRect = shared.toReactive(
|
|
364
|
+
const wrapperRef = shared.elementRef();
|
|
365
|
+
const wrapperRect = shared.toReactive(useElementBounding(wrapperRef));
|
|
78
366
|
const parentRef = vue.inject(AFFIX_TARGET_KEY, void 0);
|
|
79
367
|
const targetRef = shared.useElement(props.target, parentRef);
|
|
80
368
|
const isFixed = vue.ref(false);
|
|
@@ -83,7 +371,7 @@ shared.defineHookComponent({
|
|
|
83
371
|
const className = vue.computed(() => {
|
|
84
372
|
return isFixed.value ? props.fixedClass : "";
|
|
85
373
|
});
|
|
86
|
-
const wrapperVisible =
|
|
374
|
+
const wrapperVisible = useElementVisibility(wrapperRef);
|
|
87
375
|
const containerRef = vue.computed(() => {
|
|
88
376
|
if (!wrapperVisible.value) {
|
|
89
377
|
return null;
|
|
@@ -130,11 +418,11 @@ shared.defineHookComponent({
|
|
|
130
418
|
...newIsFixed ? newPlaceholderStyles : {}
|
|
131
419
|
};
|
|
132
420
|
});
|
|
133
|
-
|
|
421
|
+
useEventListener(containerRef, "scroll", () => {
|
|
134
422
|
emit("scroll");
|
|
135
423
|
updatePosition();
|
|
136
424
|
});
|
|
137
|
-
|
|
425
|
+
useEventListener(containerRef, "resize", updatePosition);
|
|
138
426
|
vue.watchPostEffect(updatePosition);
|
|
139
427
|
return {
|
|
140
428
|
className,
|
|
@@ -154,7 +442,7 @@ function provideAffixTarget(target) {
|
|
|
154
442
|
const HiAffixTarget = vue.defineComponent({
|
|
155
443
|
name: "HiAffixTarget",
|
|
156
444
|
setup(_, context) {
|
|
157
|
-
const targetRef =
|
|
445
|
+
const targetRef = shared.elementRef();
|
|
158
446
|
provideAffixTarget(targetRef);
|
|
159
447
|
return () => vue.h("div", {
|
|
160
448
|
ref: targetRef,
|
|
@@ -163,19 +451,94 @@ const HiAffixTarget = vue.defineComponent({
|
|
|
163
451
|
}
|
|
164
452
|
});
|
|
165
453
|
|
|
166
|
-
const
|
|
167
|
-
name: "
|
|
454
|
+
const HiAffix = vue.defineComponent({
|
|
455
|
+
name: "HiAffix",
|
|
168
456
|
props: {
|
|
169
|
-
...core.
|
|
457
|
+
...core.affixProps,
|
|
170
458
|
as: {
|
|
171
459
|
type: String,
|
|
172
460
|
default: "div"
|
|
173
461
|
}
|
|
174
462
|
},
|
|
175
|
-
emits: core.selectionEmits,
|
|
176
463
|
setup(props, context) {
|
|
177
|
-
const {
|
|
178
|
-
return () => vue.h(props.as, {},
|
|
464
|
+
const { className, wrapperRef, isFixed, placeholderStyle, fixedStyle } = core.useAffix(props, context);
|
|
465
|
+
return () => vue.h(props.as, { ref: wrapperRef }, [
|
|
466
|
+
isFixed.value && vue.h("div", { style: placeholderStyle.value }),
|
|
467
|
+
vue.h("div", { class: className.value, style: fixedStyle.value }, vue.renderSlot(context.slots, "default"))
|
|
468
|
+
]);
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
const HiConfigProvider = vue.defineComponent({
|
|
473
|
+
props: {
|
|
474
|
+
...core.configProviderProps,
|
|
475
|
+
as: {
|
|
476
|
+
type: String
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
setup(props, context) {
|
|
480
|
+
core.provideSharedConfig(props);
|
|
481
|
+
return () => {
|
|
482
|
+
const content = vue.renderSlot(context.slots, "default", void 0);
|
|
483
|
+
if (props.as) {
|
|
484
|
+
return vue.h(props.as, content);
|
|
485
|
+
}
|
|
486
|
+
return content;
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
const HiFileUpload = vue.defineComponent({
|
|
492
|
+
name: "HiFileUpload",
|
|
493
|
+
props: {
|
|
494
|
+
...core.fileUploadProps,
|
|
495
|
+
accept: {
|
|
496
|
+
type: String,
|
|
497
|
+
default: "*/*"
|
|
498
|
+
},
|
|
499
|
+
as: {
|
|
500
|
+
type: String,
|
|
501
|
+
default: "div"
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
emits: core.fileUploadEmits,
|
|
505
|
+
setup(props, context) {
|
|
506
|
+
const { slots } = context;
|
|
507
|
+
const { fileInputRef, files, openFileInput } = core.useFileUpload(props, context);
|
|
508
|
+
return () => {
|
|
509
|
+
return vue.h(props.as, {
|
|
510
|
+
onClick: openFileInput
|
|
511
|
+
}, [
|
|
512
|
+
vue.h("input", {
|
|
513
|
+
ref: fileInputRef,
|
|
514
|
+
type: "file",
|
|
515
|
+
accept: props.accept,
|
|
516
|
+
multiple: props.multiple,
|
|
517
|
+
style: { display: "none" }
|
|
518
|
+
}),
|
|
519
|
+
vue.renderSlot(slots, "default", {
|
|
520
|
+
files: files.value
|
|
521
|
+
})
|
|
522
|
+
]);
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
const HiIcon = vue.defineComponent({
|
|
528
|
+
props: {
|
|
529
|
+
...core.iconProps,
|
|
530
|
+
as: {
|
|
531
|
+
type: String,
|
|
532
|
+
default: "div"
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
setup(props, context) {
|
|
536
|
+
const { style } = core.useIcon(props, context);
|
|
537
|
+
return () => {
|
|
538
|
+
return vue.h(props.as, {
|
|
539
|
+
style: style.value
|
|
540
|
+
});
|
|
541
|
+
};
|
|
179
542
|
}
|
|
180
543
|
});
|
|
181
544
|
|
|
@@ -206,24 +569,64 @@ const HiItem = vue.defineComponent({
|
|
|
206
569
|
}
|
|
207
570
|
});
|
|
208
571
|
|
|
209
|
-
const
|
|
572
|
+
const HiPopover = vue.defineComponent({
|
|
573
|
+
name: "HiPopover",
|
|
210
574
|
props: {
|
|
211
|
-
...core.
|
|
575
|
+
...core.popoverProps,
|
|
212
576
|
as: {
|
|
213
577
|
type: String,
|
|
214
578
|
default: "div"
|
|
215
579
|
}
|
|
216
580
|
},
|
|
581
|
+
emits: core.popoverEmits,
|
|
217
582
|
setup(props, context) {
|
|
218
|
-
const {
|
|
583
|
+
const { triggerRef, popupClass, events, popupRef, popupStyle } = core.usePopover(props, context);
|
|
219
584
|
return () => {
|
|
585
|
+
let content = vue.h(
|
|
586
|
+
"div",
|
|
587
|
+
{
|
|
588
|
+
class: popupClass.value,
|
|
589
|
+
style: popupStyle.value,
|
|
590
|
+
ref: popupRef
|
|
591
|
+
},
|
|
592
|
+
vue.renderSlot(context.slots, "popup")
|
|
593
|
+
);
|
|
594
|
+
if (props.teleport) {
|
|
595
|
+
content = vue.h(
|
|
596
|
+
vue.Teleport,
|
|
597
|
+
{
|
|
598
|
+
to: props.teleport === true ? "body" : props.teleport
|
|
599
|
+
},
|
|
600
|
+
content
|
|
601
|
+
);
|
|
602
|
+
}
|
|
220
603
|
return vue.h(props.as, {
|
|
221
|
-
|
|
222
|
-
|
|
604
|
+
ref: triggerRef,
|
|
605
|
+
...events
|
|
606
|
+
}, [
|
|
607
|
+
vue.renderSlot(context.slots, "default"),
|
|
608
|
+
content
|
|
609
|
+
]);
|
|
223
610
|
};
|
|
224
611
|
}
|
|
225
612
|
});
|
|
226
613
|
|
|
614
|
+
const HiSelection = vue.defineComponent({
|
|
615
|
+
name: "HiSelection",
|
|
616
|
+
props: {
|
|
617
|
+
...core.selectionProps,
|
|
618
|
+
as: {
|
|
619
|
+
type: String,
|
|
620
|
+
default: "div"
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
emits: core.selectionEmits,
|
|
624
|
+
setup(props, context) {
|
|
625
|
+
const { render } = core.useSelectionList(props, context);
|
|
626
|
+
return () => vue.h(props.as, {}, render());
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
|
|
227
630
|
const HiSwitch = vue.defineComponent({
|
|
228
631
|
name: "HiSwitch",
|
|
229
632
|
props: {
|
|
@@ -253,25 +656,6 @@ const HiSwitch = vue.defineComponent({
|
|
|
253
656
|
}
|
|
254
657
|
});
|
|
255
658
|
|
|
256
|
-
const HiConfigProvider = vue.defineComponent({
|
|
257
|
-
props: {
|
|
258
|
-
...core.configProviderProps,
|
|
259
|
-
as: {
|
|
260
|
-
type: String
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
setup(props, context) {
|
|
264
|
-
core.provideSharedConfig(props);
|
|
265
|
-
return () => {
|
|
266
|
-
const content = vue.renderSlot(context.slots, "default", void 0);
|
|
267
|
-
if (props.as) {
|
|
268
|
-
return vue.h(props.as, content);
|
|
269
|
-
}
|
|
270
|
-
return content;
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
|
|
275
659
|
const selectionProps = shared.defineHookProps({
|
|
276
660
|
modelValue: {
|
|
277
661
|
type: shared.valuePropType,
|
|
@@ -306,7 +690,7 @@ const selectionProps = shared.defineHookProps({
|
|
|
306
690
|
* 多选模式
|
|
307
691
|
*/
|
|
308
692
|
multiple: {
|
|
309
|
-
type: [Boolean, Number],
|
|
693
|
+
type: [Boolean, Number, Array],
|
|
310
694
|
default: () => false
|
|
311
695
|
},
|
|
312
696
|
/**
|
|
@@ -347,7 +731,8 @@ function useSelectionContext() {
|
|
|
347
731
|
itemClass: "",
|
|
348
732
|
activateEvent: sharedConfig.activateEvent,
|
|
349
733
|
label: null,
|
|
350
|
-
multiple: false
|
|
734
|
+
multiple: false,
|
|
735
|
+
limit: [0, Number.POSITIVE_INFINITY]
|
|
351
736
|
});
|
|
352
737
|
}
|
|
353
738
|
const useSelectionList = shared.defineHookComponent({
|
|
@@ -356,7 +741,7 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
356
741
|
setup(props, { emit, slots }) {
|
|
357
742
|
const options = vue.reactive([]);
|
|
358
743
|
function toArray(value) {
|
|
359
|
-
if (!
|
|
744
|
+
if (!isDefined(value)) {
|
|
360
745
|
return [];
|
|
361
746
|
}
|
|
362
747
|
if (props.multiple && Array.isArray(value)) {
|
|
@@ -383,21 +768,31 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
383
768
|
emit("update:modelValue", val);
|
|
384
769
|
}
|
|
385
770
|
});
|
|
386
|
-
|
|
771
|
+
syncRef(currentValue, modelValue, { immediate: true, deep: true });
|
|
387
772
|
const emitChange = () => emit("change", currentValue.value);
|
|
388
773
|
function isActive(value) {
|
|
389
774
|
return actives.includes(value);
|
|
390
775
|
}
|
|
776
|
+
const multipleActive = vue.computed(() => !!props.multiple);
|
|
777
|
+
const multipleLimit = vue.computed(() => {
|
|
778
|
+
if (Array.isArray(props.multiple)) {
|
|
779
|
+
if (props.multiple[1] === void 0) {
|
|
780
|
+
return [props.multiple[0], Number.POSITIVE_INFINITY];
|
|
781
|
+
}
|
|
782
|
+
return props.multiple;
|
|
783
|
+
}
|
|
784
|
+
return [0, Number.POSITIVE_INFINITY];
|
|
785
|
+
});
|
|
391
786
|
function activate(value) {
|
|
787
|
+
const [min, max] = multipleLimit.value;
|
|
392
788
|
if (isActive(value)) {
|
|
393
|
-
if (
|
|
789
|
+
if (multipleActive.value && actives.length > min || props.clearable) {
|
|
394
790
|
actives.splice(actives.indexOf(value), 1);
|
|
395
791
|
emitChange();
|
|
396
792
|
}
|
|
397
793
|
} else {
|
|
398
794
|
if (props.multiple) {
|
|
399
|
-
|
|
400
|
-
if (actives.length < limit) {
|
|
795
|
+
if (actives.length < max) {
|
|
401
796
|
actives.push(value);
|
|
402
797
|
emitChange();
|
|
403
798
|
}
|
|
@@ -435,7 +830,8 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
435
830
|
disabledClass: vue.computed(() => tslx.cls(props.disabledClass)),
|
|
436
831
|
itemClass: vue.computed(() => tslx.cls(props.itemClass)),
|
|
437
832
|
label: vue.computed(() => props.label),
|
|
438
|
-
multiple:
|
|
833
|
+
multiple: multipleActive,
|
|
834
|
+
limit: multipleLimit,
|
|
439
835
|
clearable: vue.computed(() => props.clearable),
|
|
440
836
|
defaultValue: vue.computed(() => props.defaultValue),
|
|
441
837
|
activateEvent: vue.computed(() => props.activateEvent ?? sharedConfig.activateEvent),
|
|
@@ -469,60 +865,6 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
469
865
|
}
|
|
470
866
|
});
|
|
471
867
|
|
|
472
|
-
const HiTabs = vue.defineComponent({
|
|
473
|
-
props: {
|
|
474
|
-
...selectionProps,
|
|
475
|
-
headerClass: {
|
|
476
|
-
type: shared.classPropType
|
|
477
|
-
},
|
|
478
|
-
as: {
|
|
479
|
-
type: String,
|
|
480
|
-
default: "div"
|
|
481
|
-
},
|
|
482
|
-
headerAs: {
|
|
483
|
-
type: String,
|
|
484
|
-
default: "div"
|
|
485
|
-
},
|
|
486
|
-
contentAs: {
|
|
487
|
-
type: String,
|
|
488
|
-
default: "div"
|
|
489
|
-
},
|
|
490
|
-
contentClass: {
|
|
491
|
-
type: shared.classPropType
|
|
492
|
-
},
|
|
493
|
-
keepAlive: {
|
|
494
|
-
type: [Boolean, Object],
|
|
495
|
-
default: false
|
|
496
|
-
}
|
|
497
|
-
},
|
|
498
|
-
setup(props, context) {
|
|
499
|
-
const selection = useSelectionList(props, context);
|
|
500
|
-
return () => {
|
|
501
|
-
let component = selection.renderItem();
|
|
502
|
-
if (props.keepAlive) {
|
|
503
|
-
component = vue.h(vue.KeepAlive, {
|
|
504
|
-
...typeof props.keepAlive === "object" ? props.keepAlive : {}
|
|
505
|
-
}, component);
|
|
506
|
-
}
|
|
507
|
-
if (context.slots.content) {
|
|
508
|
-
component = context.slots.content({
|
|
509
|
-
component
|
|
510
|
-
});
|
|
511
|
-
} else {
|
|
512
|
-
component = vue.h(props.contentAs, {
|
|
513
|
-
class: props.contentClass
|
|
514
|
-
}, component);
|
|
515
|
-
}
|
|
516
|
-
return vue.h(props.as, [
|
|
517
|
-
vue.h(props.headerAs, {
|
|
518
|
-
class: props.headerClass
|
|
519
|
-
}, vue.renderSlot(context.slots, "default")),
|
|
520
|
-
component
|
|
521
|
-
]);
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
|
|
526
868
|
const itemProps = shared.defineHookProps({
|
|
527
869
|
value: {
|
|
528
870
|
type: shared.valuePropType,
|
|
@@ -589,7 +931,7 @@ const useSelectionItem = shared.defineHookComponent({
|
|
|
589
931
|
},
|
|
590
932
|
{ immediate: true }
|
|
591
933
|
);
|
|
592
|
-
|
|
934
|
+
tryOnScopeDispose(remove);
|
|
593
935
|
}
|
|
594
936
|
const isActive = vue.computed(() => context.isActive(props.value));
|
|
595
937
|
const isDisabled = vue.computed(() => props.disabled);
|
|
@@ -616,10 +958,12 @@ const useSelectionItem = shared.defineHookComponent({
|
|
|
616
958
|
});
|
|
617
959
|
|
|
618
960
|
const HiTabPane = vue.defineComponent({
|
|
961
|
+
name: "HiTabPane",
|
|
619
962
|
props: {
|
|
620
963
|
...itemProps
|
|
621
964
|
},
|
|
622
965
|
emits: itemEmits,
|
|
966
|
+
inheritAttrs: true,
|
|
623
967
|
setup(props, context) {
|
|
624
968
|
const { className, activateEvent, activate, isDisabled, label } = useSelectionItem(props, context);
|
|
625
969
|
return () => {
|
|
@@ -632,43 +976,57 @@ const HiTabPane = vue.defineComponent({
|
|
|
632
976
|
}
|
|
633
977
|
});
|
|
634
978
|
|
|
635
|
-
const
|
|
636
|
-
name: "
|
|
979
|
+
const HiTabs = vue.defineComponent({
|
|
980
|
+
name: "HiTabs",
|
|
637
981
|
props: {
|
|
638
|
-
...
|
|
982
|
+
...selectionProps,
|
|
983
|
+
headerClass: {
|
|
984
|
+
type: shared.classPropType
|
|
985
|
+
},
|
|
639
986
|
as: {
|
|
640
987
|
type: String,
|
|
641
988
|
default: "div"
|
|
989
|
+
},
|
|
990
|
+
headerAs: {
|
|
991
|
+
type: String,
|
|
992
|
+
default: "div"
|
|
993
|
+
},
|
|
994
|
+
contentAs: {
|
|
995
|
+
type: String,
|
|
996
|
+
default: "div"
|
|
997
|
+
},
|
|
998
|
+
contentClass: {
|
|
999
|
+
type: shared.classPropType
|
|
1000
|
+
},
|
|
1001
|
+
keepAlive: {
|
|
1002
|
+
type: [Boolean, Object],
|
|
1003
|
+
default: false
|
|
642
1004
|
}
|
|
643
1005
|
},
|
|
644
|
-
|
|
1006
|
+
inheritAttrs: true,
|
|
645
1007
|
setup(props, context) {
|
|
646
|
-
const
|
|
1008
|
+
const selection = useSelectionList(props, context);
|
|
647
1009
|
return () => {
|
|
648
|
-
let
|
|
649
|
-
|
|
650
|
-
{
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
ref: popupRef
|
|
654
|
-
},
|
|
655
|
-
vue.renderSlot(context.slots, "popup")
|
|
656
|
-
);
|
|
657
|
-
if (props.teleport) {
|
|
658
|
-
content = vue.h(
|
|
659
|
-
vue.Teleport,
|
|
660
|
-
{
|
|
661
|
-
to: props.teleport === true ? "body" : props.teleport
|
|
662
|
-
},
|
|
663
|
-
content
|
|
664
|
-
);
|
|
1010
|
+
let component = selection.renderItem();
|
|
1011
|
+
if (props.keepAlive) {
|
|
1012
|
+
component = vue.h(vue.KeepAlive, {
|
|
1013
|
+
...typeof props.keepAlive === "object" ? props.keepAlive : {}
|
|
1014
|
+
}, component);
|
|
665
1015
|
}
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
1016
|
+
if (context.slots.content) {
|
|
1017
|
+
component = context.slots.content({
|
|
1018
|
+
component
|
|
1019
|
+
});
|
|
1020
|
+
} else {
|
|
1021
|
+
component = vue.h(props.contentAs, {
|
|
1022
|
+
class: props.contentClass
|
|
1023
|
+
}, component);
|
|
1024
|
+
}
|
|
1025
|
+
return vue.h(props.as, [
|
|
1026
|
+
vue.h(props.headerAs, {
|
|
1027
|
+
class: props.headerClass
|
|
1028
|
+
}, vue.renderSlot(context.slots, "default")),
|
|
1029
|
+
component
|
|
672
1030
|
]);
|
|
673
1031
|
};
|
|
674
1032
|
}
|
|
@@ -679,6 +1037,7 @@ const components = {
|
|
|
679
1037
|
HiAffix: HiAffix,
|
|
680
1038
|
HiAffixTarget: HiAffixTarget,
|
|
681
1039
|
HiConfigProvider: HiConfigProvider,
|
|
1040
|
+
HiFileUpload: HiFileUpload,
|
|
682
1041
|
HiIcon: HiIcon,
|
|
683
1042
|
HiItem: HiItem,
|
|
684
1043
|
HiPopover: HiPopover,
|
|
@@ -697,6 +1056,7 @@ function install(app) {
|
|
|
697
1056
|
exports.HiAffix = HiAffix;
|
|
698
1057
|
exports.HiAffixTarget = HiAffixTarget;
|
|
699
1058
|
exports.HiConfigProvider = HiConfigProvider;
|
|
1059
|
+
exports.HiFileUpload = HiFileUpload;
|
|
700
1060
|
exports.HiIcon = HiIcon;
|
|
701
1061
|
exports.HiItem = HiItem;
|
|
702
1062
|
exports.HiPopover = HiPopover;
|