@hoci/components 0.6.0 → 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 +487 -139
- package/dist/index.d.cts +304 -258
- package/dist/index.d.mts +304 -258
- package/dist/index.d.ts +304 -258
- package/dist/index.mjs +481 -134
- 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,
|
|
@@ -357,7 +741,7 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
357
741
|
setup(props, { emit, slots }) {
|
|
358
742
|
const options = vue.reactive([]);
|
|
359
743
|
function toArray(value) {
|
|
360
|
-
if (!
|
|
744
|
+
if (!isDefined(value)) {
|
|
361
745
|
return [];
|
|
362
746
|
}
|
|
363
747
|
if (props.multiple && Array.isArray(value)) {
|
|
@@ -384,7 +768,7 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
384
768
|
emit("update:modelValue", val);
|
|
385
769
|
}
|
|
386
770
|
});
|
|
387
|
-
|
|
771
|
+
syncRef(currentValue, modelValue, { immediate: true, deep: true });
|
|
388
772
|
const emitChange = () => emit("change", currentValue.value);
|
|
389
773
|
function isActive(value) {
|
|
390
774
|
return actives.includes(value);
|
|
@@ -481,60 +865,6 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
481
865
|
}
|
|
482
866
|
});
|
|
483
867
|
|
|
484
|
-
const HiTabs = vue.defineComponent({
|
|
485
|
-
props: {
|
|
486
|
-
...selectionProps,
|
|
487
|
-
headerClass: {
|
|
488
|
-
type: shared.classPropType
|
|
489
|
-
},
|
|
490
|
-
as: {
|
|
491
|
-
type: String,
|
|
492
|
-
default: "div"
|
|
493
|
-
},
|
|
494
|
-
headerAs: {
|
|
495
|
-
type: String,
|
|
496
|
-
default: "div"
|
|
497
|
-
},
|
|
498
|
-
contentAs: {
|
|
499
|
-
type: String,
|
|
500
|
-
default: "div"
|
|
501
|
-
},
|
|
502
|
-
contentClass: {
|
|
503
|
-
type: shared.classPropType
|
|
504
|
-
},
|
|
505
|
-
keepAlive: {
|
|
506
|
-
type: [Boolean, Object],
|
|
507
|
-
default: false
|
|
508
|
-
}
|
|
509
|
-
},
|
|
510
|
-
setup(props, context) {
|
|
511
|
-
const selection = useSelectionList(props, context);
|
|
512
|
-
return () => {
|
|
513
|
-
let component = selection.renderItem();
|
|
514
|
-
if (props.keepAlive) {
|
|
515
|
-
component = vue.h(vue.KeepAlive, {
|
|
516
|
-
...typeof props.keepAlive === "object" ? props.keepAlive : {}
|
|
517
|
-
}, component);
|
|
518
|
-
}
|
|
519
|
-
if (context.slots.content) {
|
|
520
|
-
component = context.slots.content({
|
|
521
|
-
component
|
|
522
|
-
});
|
|
523
|
-
} else {
|
|
524
|
-
component = vue.h(props.contentAs, {
|
|
525
|
-
class: props.contentClass
|
|
526
|
-
}, component);
|
|
527
|
-
}
|
|
528
|
-
return vue.h(props.as, [
|
|
529
|
-
vue.h(props.headerAs, {
|
|
530
|
-
class: props.headerClass
|
|
531
|
-
}, vue.renderSlot(context.slots, "default")),
|
|
532
|
-
component
|
|
533
|
-
]);
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
|
-
});
|
|
537
|
-
|
|
538
868
|
const itemProps = shared.defineHookProps({
|
|
539
869
|
value: {
|
|
540
870
|
type: shared.valuePropType,
|
|
@@ -601,7 +931,7 @@ const useSelectionItem = shared.defineHookComponent({
|
|
|
601
931
|
},
|
|
602
932
|
{ immediate: true }
|
|
603
933
|
);
|
|
604
|
-
|
|
934
|
+
tryOnScopeDispose(remove);
|
|
605
935
|
}
|
|
606
936
|
const isActive = vue.computed(() => context.isActive(props.value));
|
|
607
937
|
const isDisabled = vue.computed(() => props.disabled);
|
|
@@ -628,10 +958,12 @@ const useSelectionItem = shared.defineHookComponent({
|
|
|
628
958
|
});
|
|
629
959
|
|
|
630
960
|
const HiTabPane = vue.defineComponent({
|
|
961
|
+
name: "HiTabPane",
|
|
631
962
|
props: {
|
|
632
963
|
...itemProps
|
|
633
964
|
},
|
|
634
965
|
emits: itemEmits,
|
|
966
|
+
inheritAttrs: true,
|
|
635
967
|
setup(props, context) {
|
|
636
968
|
const { className, activateEvent, activate, isDisabled, label } = useSelectionItem(props, context);
|
|
637
969
|
return () => {
|
|
@@ -644,43 +976,57 @@ const HiTabPane = vue.defineComponent({
|
|
|
644
976
|
}
|
|
645
977
|
});
|
|
646
978
|
|
|
647
|
-
const
|
|
648
|
-
name: "
|
|
979
|
+
const HiTabs = vue.defineComponent({
|
|
980
|
+
name: "HiTabs",
|
|
649
981
|
props: {
|
|
650
|
-
...
|
|
982
|
+
...selectionProps,
|
|
983
|
+
headerClass: {
|
|
984
|
+
type: shared.classPropType
|
|
985
|
+
},
|
|
651
986
|
as: {
|
|
652
987
|
type: String,
|
|
653
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
|
|
654
1004
|
}
|
|
655
1005
|
},
|
|
656
|
-
|
|
1006
|
+
inheritAttrs: true,
|
|
657
1007
|
setup(props, context) {
|
|
658
|
-
const
|
|
1008
|
+
const selection = useSelectionList(props, context);
|
|
659
1009
|
return () => {
|
|
660
|
-
let
|
|
661
|
-
|
|
662
|
-
{
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
ref: popupRef
|
|
666
|
-
},
|
|
667
|
-
vue.renderSlot(context.slots, "popup")
|
|
668
|
-
);
|
|
669
|
-
if (props.teleport) {
|
|
670
|
-
content = vue.h(
|
|
671
|
-
vue.Teleport,
|
|
672
|
-
{
|
|
673
|
-
to: props.teleport === true ? "body" : props.teleport
|
|
674
|
-
},
|
|
675
|
-
content
|
|
676
|
-
);
|
|
1010
|
+
let component = selection.renderItem();
|
|
1011
|
+
if (props.keepAlive) {
|
|
1012
|
+
component = vue.h(vue.KeepAlive, {
|
|
1013
|
+
...typeof props.keepAlive === "object" ? props.keepAlive : {}
|
|
1014
|
+
}, component);
|
|
677
1015
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
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
|
|
684
1030
|
]);
|
|
685
1031
|
};
|
|
686
1032
|
}
|
|
@@ -691,6 +1037,7 @@ const components = {
|
|
|
691
1037
|
HiAffix: HiAffix,
|
|
692
1038
|
HiAffixTarget: HiAffixTarget,
|
|
693
1039
|
HiConfigProvider: HiConfigProvider,
|
|
1040
|
+
HiFileUpload: HiFileUpload,
|
|
694
1041
|
HiIcon: HiIcon,
|
|
695
1042
|
HiItem: HiItem,
|
|
696
1043
|
HiPopover: HiPopover,
|
|
@@ -709,6 +1056,7 @@ function install(app) {
|
|
|
709
1056
|
exports.HiAffix = HiAffix;
|
|
710
1057
|
exports.HiAffixTarget = HiAffixTarget;
|
|
711
1058
|
exports.HiConfigProvider = HiConfigProvider;
|
|
1059
|
+
exports.HiFileUpload = HiFileUpload;
|
|
712
1060
|
exports.HiIcon = HiIcon;
|
|
713
1061
|
exports.HiItem = HiItem;
|
|
714
1062
|
exports.HiPopover = HiPopover;
|