@varlet/cli 1.22.0-alpha.3 → 1.22.0-alpha.64
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/README.en-US.md +11 -0
- package/README.md +11 -0
- package/generators/sfc/package.json +3 -3
- package/generators/sfc/varlet.config.js +5 -0
- package/generators/tsx/package.json +3 -3
- package/generators/tsx/varlet.config.js +5 -0
- package/lib/commands/dev.js +14 -3
- package/lib/commands/preview.d.ts +1 -0
- package/lib/commands/preview.js +65 -0
- package/lib/compiler/compileSiteEntry.d.ts +1 -4
- package/lib/compiler/compileSiteEntry.js +10 -20
- package/lib/config/jest.config.js +0 -1
- package/lib/config/vite.config.js +16 -7
- package/lib/index.js +2 -0
- package/lib/shared/constant.d.ts +1 -9
- package/lib/shared/constant.js +2 -10
- package/lib/site/components/app-bar/index.d.ts +3 -0
- package/lib/site/components/app-bar/index.js +12 -0
- package/lib/site/components/app-bar/props.d.ts +21 -0
- package/lib/site/components/app-bar/props.js +28 -0
- package/lib/site/components/button/index.d.ts +3 -0
- package/lib/site/components/button/index.js +12 -0
- package/lib/site/components/button/props.d.ts +62 -0
- package/lib/site/components/button/props.js +69 -0
- package/lib/site/components/cell/index.d.ts +3 -0
- package/lib/site/components/cell/index.js +12 -0
- package/lib/site/components/cell/props.d.ts +27 -0
- package/lib/site/components/cell/props.js +30 -0
- package/lib/site/components/context/index.d.ts +15 -0
- package/lib/site/components/context/index.js +11 -0
- package/lib/site/components/context/lock.d.ts +10 -0
- package/lib/site/components/context/lock.js +94 -0
- package/lib/site/components/context/zIndex.d.ts +4 -0
- package/lib/site/components/context/zIndex.js +19 -0
- package/lib/site/components/icon/index.d.ts +3 -0
- package/lib/site/components/icon/index.js +12 -0
- package/lib/site/components/icon/props.d.ts +23 -0
- package/lib/site/components/icon/props.js +25 -0
- package/lib/site/components/loading/index.d.ts +3 -0
- package/lib/site/components/loading/index.js +12 -0
- package/lib/site/components/loading/props.d.ts +26 -0
- package/lib/site/components/loading/props.js +34 -0
- package/lib/site/components/menu/index.d.ts +3 -0
- package/lib/site/components/menu/index.js +12 -0
- package/lib/site/components/menu/props.d.ts +40 -0
- package/lib/site/components/menu/props.js +43 -0
- package/lib/site/components/progress/index.d.ts +3 -0
- package/lib/site/components/progress/index.js +12 -0
- package/lib/site/components/progress/props.d.ts +43 -0
- package/lib/site/components/progress/props.js +57 -0
- package/lib/site/components/ripple/index.d.ts +8 -0
- package/lib/site/components/ripple/index.js +125 -0
- package/lib/site/components/utils/components.d.ts +53 -0
- package/lib/site/components/utils/components.js +279 -0
- package/lib/site/components/utils/elements.d.ts +30 -0
- package/lib/site/components/utils/elements.js +240 -0
- package/lib/site/components/utils/shared.d.ts +36 -0
- package/lib/site/components/utils/shared.js +181 -0
- package/lib/site/mobile/main.d.ts +3 -0
- package/lib/site/mobile/main.js +93 -0
- package/lib/site/pc/main.d.ts +3 -0
- package/lib/site/pc/main.js +69 -0
- package/lib/site/useProgress.d.ts +4 -0
- package/lib/site/useProgress.js +58 -0
- package/lib/site/utils.d.ts +24 -0
- package/lib/site/utils.js +133 -0
- package/package.json +10 -9
- package/site/.DS_Store +0 -0
- package/site/components/app-bar/AppBar.vue +45 -0
- package/site/components/app-bar/appBar.less +66 -0
- package/site/components/app-bar/index.ts +10 -0
- package/site/components/app-bar/props.ts +25 -0
- package/site/components/button/Button.vue +84 -0
- package/site/components/button/button.less +183 -0
- package/site/components/button/index.ts +10 -0
- package/site/components/button/props.ts +70 -0
- package/site/components/cell/Cell.vue +42 -0
- package/site/components/cell/cell.less +74 -0
- package/site/components/cell/index.ts +10 -0
- package/site/components/cell/props.ts +27 -0
- package/site/components/context/index.ts +17 -0
- package/site/components/context/lock.ts +103 -0
- package/site/components/context/zIndex.ts +20 -0
- package/site/components/icon/Icon.vue +68 -0
- package/site/components/icon/icon.less +25 -0
- package/site/components/icon/index.ts +10 -0
- package/site/components/icon/props.ts +24 -0
- package/site/components/loading/Loading.vue +55 -0
- package/site/components/loading/index.ts +10 -0
- package/site/components/loading/loading.less +420 -0
- package/site/components/loading/props.ts +37 -0
- package/site/components/menu/Menu.vue +113 -0
- package/site/components/menu/index.ts +10 -0
- package/site/components/menu/menu.less +27 -0
- package/site/components/menu/props.ts +43 -0
- package/site/components/progress/Progress.vue +108 -0
- package/site/components/progress/index.ts +10 -0
- package/site/components/progress/progress.less +98 -0
- package/site/components/progress/props.ts +55 -0
- package/site/components/ripple/index.ts +167 -0
- package/site/components/ripple/ripple.less +17 -0
- package/site/components/styles/common.less +64 -0
- package/site/components/styles/elevation.less +126 -0
- package/site/components/styles/var.less +27 -0
- package/site/components/utils/components.ts +53 -0
- package/site/components/utils/elements.ts +83 -0
- package/site/components/utils/shared.ts +27 -0
- package/site/mobile/App.vue +21 -17
- package/site/mobile/components/AppHome.vue +6 -6
- package/site/mobile/main.ts +15 -8
- package/site/pc/App.vue +16 -11
- package/site/pc/components/AppHeader.vue +15 -11
- package/site/pc/components/AppMobile.vue +3 -3
- package/site/pc/components/AppSidebar.vue +17 -21
- package/site/pc/main.ts +8 -5
- package/site/useProgress.ts +11 -9
- package/site/utils.ts +14 -3
- package/varlet.default.config.js +3 -2
- package/generators/sfc/yarn.lock +0 -11231
- package/generators/tsx/yarn.lock +0 -11231
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './ripple.less';
|
|
2
|
+
import '../styles/common.less';
|
|
3
|
+
import type { Directive, Plugin, App } from 'vue';
|
|
4
|
+
declare const Ripple: Directive & Plugin;
|
|
5
|
+
export declare const _RippleComponent: import("vue").ObjectDirective<any, any> & {
|
|
6
|
+
install: (app: App<any>, ...options: any[]) => any;
|
|
7
|
+
};
|
|
8
|
+
export default Ripple;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports._RippleComponent = void 0;
|
|
18
|
+
var context_1 = __importDefault(require("../context"));
|
|
19
|
+
require("./ripple.less");
|
|
20
|
+
require("../styles/common.less");
|
|
21
|
+
var ANIMATION_DURATION = 250;
|
|
22
|
+
function setStyles(element) {
|
|
23
|
+
var _a = window.getComputedStyle(element), zIndex = _a.zIndex, position = _a.position;
|
|
24
|
+
element.style.overflow = 'hidden';
|
|
25
|
+
element.style.overflowX = 'hidden';
|
|
26
|
+
element.style.overflowY = 'hidden';
|
|
27
|
+
position === 'static' && (element.style.position = 'relative');
|
|
28
|
+
zIndex === 'auto' && (element.style.zIndex = '1');
|
|
29
|
+
}
|
|
30
|
+
function computeRippleStyles(element, event) {
|
|
31
|
+
var _a = element.getBoundingClientRect(), top = _a.top, left = _a.left;
|
|
32
|
+
var clientWidth = element.clientWidth, clientHeight = element.clientHeight;
|
|
33
|
+
var radius = Math.sqrt(Math.pow(clientWidth, 2) + Math.pow(clientHeight, 2)) / 2;
|
|
34
|
+
var size = radius * 2;
|
|
35
|
+
var localX = event.touches[0].clientX - left;
|
|
36
|
+
var localY = event.touches[0].clientY - top;
|
|
37
|
+
var centerX = (clientWidth - radius * 2) / 2;
|
|
38
|
+
var centerY = (clientHeight - radius * 2) / 2;
|
|
39
|
+
var x = localX - radius;
|
|
40
|
+
var y = localY - radius;
|
|
41
|
+
return { x: x, y: y, centerX: centerX, centerY: centerY, size: size };
|
|
42
|
+
}
|
|
43
|
+
function createRipple(event) {
|
|
44
|
+
var _this = this;
|
|
45
|
+
var _ripple = this._ripple;
|
|
46
|
+
_ripple.removeRipple();
|
|
47
|
+
if (_ripple.disabled || _ripple.tasker) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
var task = function () {
|
|
51
|
+
var _a;
|
|
52
|
+
_ripple.tasker = null;
|
|
53
|
+
var _b = computeRippleStyles(_this, event), x = _b.x, y = _b.y, centerX = _b.centerX, centerY = _b.centerY, size = _b.size;
|
|
54
|
+
var ripple = document.createElement('div');
|
|
55
|
+
ripple.classList.add('var-site-ripple');
|
|
56
|
+
ripple.style.opacity = "0";
|
|
57
|
+
ripple.style.transform = "translate(" + x + "px, " + y + "px) scale3d(.3, .3, .3)";
|
|
58
|
+
ripple.style.width = size + "px";
|
|
59
|
+
ripple.style.height = size + "px";
|
|
60
|
+
ripple.style.backgroundColor = (_a = _ripple.color) !== null && _a !== void 0 ? _a : 'currentColor';
|
|
61
|
+
ripple.dataset.createdAt = String(performance.now());
|
|
62
|
+
setStyles(_this);
|
|
63
|
+
_this.appendChild(ripple);
|
|
64
|
+
window.setTimeout(function () {
|
|
65
|
+
ripple.style.transform = "translate(" + centerX + "px, " + centerY + "px) scale3d(1, 1, 1)";
|
|
66
|
+
ripple.style.opacity = ".25";
|
|
67
|
+
}, 20);
|
|
68
|
+
};
|
|
69
|
+
_ripple.tasker = window.setTimeout(task, 60);
|
|
70
|
+
}
|
|
71
|
+
function removeRipple() {
|
|
72
|
+
var _this = this;
|
|
73
|
+
var _ripple = this._ripple;
|
|
74
|
+
var task = function () {
|
|
75
|
+
var ripples = _this.querySelectorAll('.var-site-ripple');
|
|
76
|
+
if (!ripples.length) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
var lastRipple = ripples[ripples.length - 1];
|
|
80
|
+
var delay = ANIMATION_DURATION - performance.now() + Number(lastRipple.dataset.createdAt);
|
|
81
|
+
setTimeout(function () {
|
|
82
|
+
lastRipple.style.opacity = "0";
|
|
83
|
+
setTimeout(function () { var _a; return (_a = lastRipple.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(lastRipple); }, ANIMATION_DURATION);
|
|
84
|
+
}, delay);
|
|
85
|
+
};
|
|
86
|
+
_ripple.tasker ? setTimeout(task, 60) : task();
|
|
87
|
+
}
|
|
88
|
+
function forbidRippleTask() {
|
|
89
|
+
var _ripple = this._ripple;
|
|
90
|
+
if (!_ripple.touchmoveForbid) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
_ripple.tasker && window.clearTimeout(_ripple.tasker);
|
|
94
|
+
_ripple.tasker = null;
|
|
95
|
+
}
|
|
96
|
+
function mounted(el, binding) {
|
|
97
|
+
var _a, _b, _c;
|
|
98
|
+
el._ripple = __assign(__assign({ tasker: null }, ((_a = binding.value) !== null && _a !== void 0 ? _a : {})), { touchmoveForbid: (_c = (_b = binding.value) === null || _b === void 0 ? void 0 : _b.touchmoveForbid) !== null && _c !== void 0 ? _c : context_1.default.touchmoveForbid, removeRipple: removeRipple.bind(el) });
|
|
99
|
+
el.addEventListener('touchstart', createRipple, { passive: true });
|
|
100
|
+
el.addEventListener('touchmove', forbidRippleTask, { passive: true });
|
|
101
|
+
el.addEventListener('dragstart', removeRipple, { passive: true });
|
|
102
|
+
document.addEventListener('touchend', el._ripple.removeRipple, { passive: true });
|
|
103
|
+
document.addEventListener('touchcancel', el._ripple.removeRipple, { passive: true });
|
|
104
|
+
}
|
|
105
|
+
function unmounted(el) {
|
|
106
|
+
el.removeEventListener('touchstart', createRipple);
|
|
107
|
+
el.removeEventListener('touchmove', forbidRippleTask);
|
|
108
|
+
el.removeEventListener('dragstart', removeRipple);
|
|
109
|
+
document.removeEventListener('touchend', el._ripple.removeRipple);
|
|
110
|
+
document.removeEventListener('touchcancel', el._ripple.removeRipple);
|
|
111
|
+
}
|
|
112
|
+
function updated(el, binding) {
|
|
113
|
+
var _a, _b, _c;
|
|
114
|
+
el._ripple = __assign(__assign(__assign({}, el._ripple), ((_a = binding.value) !== null && _a !== void 0 ? _a : {})), { touchmoveForbid: (_c = (_b = binding.value) === null || _b === void 0 ? void 0 : _b.touchmoveForbid) !== null && _c !== void 0 ? _c : context_1.default.touchmoveForbid, tasker: null });
|
|
115
|
+
}
|
|
116
|
+
var Ripple = {
|
|
117
|
+
mounted: mounted,
|
|
118
|
+
unmounted: unmounted,
|
|
119
|
+
updated: updated,
|
|
120
|
+
install: function (app) {
|
|
121
|
+
app.directive('ripple', this);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
exports._RippleComponent = Ripple;
|
|
125
|
+
exports.default = Ripple;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Component, VNode, ComputedRef, ComponentInternalInstance, Ref } from 'vue';
|
|
2
|
+
export interface MountInstance {
|
|
3
|
+
instance: any;
|
|
4
|
+
unmount: () => void;
|
|
5
|
+
}
|
|
6
|
+
export interface ChildrenCounter {
|
|
7
|
+
collect(instance: ComponentInternalInstance): void;
|
|
8
|
+
clear(instance: ComponentInternalInstance): void;
|
|
9
|
+
instances: ComponentInternalInstance[];
|
|
10
|
+
}
|
|
11
|
+
export interface BaseParentProvider<C> {
|
|
12
|
+
collect(childProvider: C): void;
|
|
13
|
+
clear(childProvider: C): void;
|
|
14
|
+
}
|
|
15
|
+
export declare function pickProps(props: any, propsKey: string): any;
|
|
16
|
+
export declare function pickProps(props: any, propsKey: string[]): any;
|
|
17
|
+
export declare function mount(component: Component): MountInstance;
|
|
18
|
+
export declare function mountInstance(component: any, props?: Record<string, any>, eventListener?: Record<string, any>): {
|
|
19
|
+
unmountInstance: () => void;
|
|
20
|
+
};
|
|
21
|
+
export declare function flatVNodes(subTree: any): VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}>[];
|
|
24
|
+
export declare function useAtChildrenCounter(key: symbol): {
|
|
25
|
+
length: ComputedRef<number>;
|
|
26
|
+
};
|
|
27
|
+
export declare function useAtParentIndex(key: symbol): {
|
|
28
|
+
index: null;
|
|
29
|
+
} | {
|
|
30
|
+
index: ComputedRef<number>;
|
|
31
|
+
};
|
|
32
|
+
export declare function useChildren<P, C>(key: symbol): {
|
|
33
|
+
childProviders: C[];
|
|
34
|
+
bindChildren: (parentProvider: P) => void;
|
|
35
|
+
};
|
|
36
|
+
export declare function useParent<P, C>(key: symbol): {
|
|
37
|
+
parentProvider: null;
|
|
38
|
+
bindParent: null;
|
|
39
|
+
} | {
|
|
40
|
+
parentProvider: Omit<P & BaseParentProvider<C>, "collect" | "clear">;
|
|
41
|
+
bindParent: (childProvider: C) => void;
|
|
42
|
+
};
|
|
43
|
+
export declare function keyInProvides(key: symbol): boolean;
|
|
44
|
+
export declare function useValidation(): {
|
|
45
|
+
errorMessage: Ref<string>;
|
|
46
|
+
validate: (rules: any, value: any, apis?: any) => Promise<boolean>;
|
|
47
|
+
resetValidation: () => void;
|
|
48
|
+
validateWithTrigger: <T>(validateTrigger: T[], trigger: T, rules: any, value: any, apis?: any) => Promise<void>;
|
|
49
|
+
};
|
|
50
|
+
export declare function addRouteListener(cb: () => void): void;
|
|
51
|
+
export declare function useTeleport(): {
|
|
52
|
+
disabled: Ref<boolean>;
|
|
53
|
+
};
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
+
t[p] = s[p];
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
+
t[p[i]] = s[p[i]];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.useTeleport = exports.addRouteListener = exports.useValidation = exports.keyInProvides = exports.useParent = exports.useChildren = exports.useAtParentIndex = exports.useAtChildrenCounter = exports.flatVNodes = exports.mountInstance = exports.mount = exports.pickProps = void 0;
|
|
62
|
+
var vue_1 = require("vue");
|
|
63
|
+
var shared_1 = require("./shared");
|
|
64
|
+
function pickProps(props, propsKey) {
|
|
65
|
+
return Array.isArray(propsKey)
|
|
66
|
+
? propsKey.reduce(function (pickedProps, key) {
|
|
67
|
+
pickedProps[key] = props[key];
|
|
68
|
+
return pickedProps;
|
|
69
|
+
}, {})
|
|
70
|
+
: props[propsKey];
|
|
71
|
+
}
|
|
72
|
+
exports.pickProps = pickProps;
|
|
73
|
+
function mount(component) {
|
|
74
|
+
var app = vue_1.createApp(component);
|
|
75
|
+
var host = document.createElement('div');
|
|
76
|
+
document.body.appendChild(host);
|
|
77
|
+
return {
|
|
78
|
+
instance: app.mount(host),
|
|
79
|
+
unmount: function () {
|
|
80
|
+
app.unmount();
|
|
81
|
+
document.body.removeChild(host);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
exports.mount = mount;
|
|
86
|
+
function mountInstance(component, props, eventListener) {
|
|
87
|
+
if (props === void 0) { props = {}; }
|
|
88
|
+
if (eventListener === void 0) { eventListener = {}; }
|
|
89
|
+
var Host = {
|
|
90
|
+
setup: function () {
|
|
91
|
+
return function () {
|
|
92
|
+
return vue_1.h(component, __assign(__assign({}, props), eventListener));
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
var unmount = mount(Host).unmount;
|
|
97
|
+
return { unmountInstance: unmount };
|
|
98
|
+
}
|
|
99
|
+
exports.mountInstance = mountInstance;
|
|
100
|
+
function flatVNodes(subTree) {
|
|
101
|
+
var vNodes = [];
|
|
102
|
+
var flat = function (subTree) {
|
|
103
|
+
if (subTree === null || subTree === void 0 ? void 0 : subTree.component) {
|
|
104
|
+
flat(subTree === null || subTree === void 0 ? void 0 : subTree.component.subTree);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (Array.isArray(subTree === null || subTree === void 0 ? void 0 : subTree.children)) {
|
|
108
|
+
subTree.children.forEach(function (child) {
|
|
109
|
+
if (vue_1.isVNode(child)) {
|
|
110
|
+
vNodes.push(child);
|
|
111
|
+
flat(child);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
flat(subTree);
|
|
117
|
+
return vNodes;
|
|
118
|
+
}
|
|
119
|
+
exports.flatVNodes = flatVNodes;
|
|
120
|
+
function useAtChildrenCounter(key) {
|
|
121
|
+
var instances = vue_1.reactive([]);
|
|
122
|
+
var parentInstance = vue_1.getCurrentInstance();
|
|
123
|
+
var sortInstances = function () {
|
|
124
|
+
var vNodes = flatVNodes(parentInstance.subTree);
|
|
125
|
+
instances.sort(function (a, b) {
|
|
126
|
+
return vNodes.indexOf(a.vnode) - vNodes.indexOf(b.vnode);
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
var collect = function (instance) {
|
|
130
|
+
instances.push(instance);
|
|
131
|
+
sortInstances();
|
|
132
|
+
};
|
|
133
|
+
var clear = function (instance) {
|
|
134
|
+
shared_1.removeItem(instances, instance);
|
|
135
|
+
};
|
|
136
|
+
vue_1.provide(key, {
|
|
137
|
+
collect: collect,
|
|
138
|
+
clear: clear,
|
|
139
|
+
instances: instances,
|
|
140
|
+
});
|
|
141
|
+
var length = vue_1.computed(function () { return instances.length; });
|
|
142
|
+
return {
|
|
143
|
+
length: length,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
exports.useAtChildrenCounter = useAtChildrenCounter;
|
|
147
|
+
function useAtParentIndex(key) {
|
|
148
|
+
if (!keyInProvides(key)) {
|
|
149
|
+
return { index: null };
|
|
150
|
+
}
|
|
151
|
+
var childrenCounter = vue_1.inject(key);
|
|
152
|
+
var collect = childrenCounter.collect, clear = childrenCounter.clear, instances = childrenCounter.instances;
|
|
153
|
+
var instance = vue_1.getCurrentInstance();
|
|
154
|
+
vue_1.onMounted(function () {
|
|
155
|
+
vue_1.nextTick().then(function () { return collect(instance); });
|
|
156
|
+
});
|
|
157
|
+
vue_1.onUnmounted(function () {
|
|
158
|
+
vue_1.nextTick().then(function () { return clear(instance); });
|
|
159
|
+
});
|
|
160
|
+
var index = vue_1.computed(function () { return instances.indexOf(instance); });
|
|
161
|
+
return {
|
|
162
|
+
index: index,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
exports.useAtParentIndex = useAtParentIndex;
|
|
166
|
+
function useChildren(key) {
|
|
167
|
+
var childProviders = [];
|
|
168
|
+
var collect = function (childProvider) {
|
|
169
|
+
childProviders.push(childProvider);
|
|
170
|
+
};
|
|
171
|
+
var clear = function (childProvider) {
|
|
172
|
+
shared_1.removeItem(childProviders, childProvider);
|
|
173
|
+
};
|
|
174
|
+
var bindChildren = function (parentProvider) {
|
|
175
|
+
vue_1.provide(key, __assign({ collect: collect, clear: clear }, parentProvider));
|
|
176
|
+
};
|
|
177
|
+
return {
|
|
178
|
+
childProviders: childProviders,
|
|
179
|
+
bindChildren: bindChildren,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
exports.useChildren = useChildren;
|
|
183
|
+
function useParent(key) {
|
|
184
|
+
if (!keyInProvides(key)) {
|
|
185
|
+
return {
|
|
186
|
+
parentProvider: null,
|
|
187
|
+
bindParent: null,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
var rawParentProvider = vue_1.inject(key);
|
|
191
|
+
var collect = rawParentProvider.collect, clear = rawParentProvider.clear, parentProvider = __rest(rawParentProvider, ["collect", "clear"]);
|
|
192
|
+
var bindParent = function (childProvider) {
|
|
193
|
+
vue_1.onMounted(function () { return collect(childProvider); });
|
|
194
|
+
vue_1.onBeforeUnmount(function () { return clear(childProvider); });
|
|
195
|
+
};
|
|
196
|
+
return {
|
|
197
|
+
parentProvider: parentProvider,
|
|
198
|
+
bindParent: bindParent,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
exports.useParent = useParent;
|
|
202
|
+
function keyInProvides(key) {
|
|
203
|
+
var instance = vue_1.getCurrentInstance();
|
|
204
|
+
return key in instance.provides;
|
|
205
|
+
}
|
|
206
|
+
exports.keyInProvides = keyInProvides;
|
|
207
|
+
function useValidation() {
|
|
208
|
+
var _this = this;
|
|
209
|
+
var errorMessage = vue_1.ref('');
|
|
210
|
+
var validate = function (rules, value, apis) { return __awaiter(_this, void 0, void 0, function () {
|
|
211
|
+
var resArr;
|
|
212
|
+
return __generator(this, function (_a) {
|
|
213
|
+
switch (_a.label) {
|
|
214
|
+
case 0:
|
|
215
|
+
if (!shared_1.isArray(rules) || !rules.length) {
|
|
216
|
+
return [2 /*return*/, true];
|
|
217
|
+
}
|
|
218
|
+
return [4 /*yield*/, Promise.all(rules.map(function (rule) { return rule(value, apis); }))];
|
|
219
|
+
case 1:
|
|
220
|
+
resArr = _a.sent();
|
|
221
|
+
return [2 /*return*/, !resArr.some(function (res) {
|
|
222
|
+
if (res !== true) {
|
|
223
|
+
errorMessage.value = String(res);
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
return false;
|
|
227
|
+
})];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}); };
|
|
231
|
+
var resetValidation = function () {
|
|
232
|
+
errorMessage.value = '';
|
|
233
|
+
};
|
|
234
|
+
var validateWithTrigger = function (validateTrigger, trigger, rules, value, apis) { return __awaiter(_this, void 0, void 0, function () {
|
|
235
|
+
return __generator(this, function (_a) {
|
|
236
|
+
switch (_a.label) {
|
|
237
|
+
case 0:
|
|
238
|
+
if (!validateTrigger.includes(trigger)) return [3 /*break*/, 2];
|
|
239
|
+
;
|
|
240
|
+
return [4 /*yield*/, validate(rules, value, apis)];
|
|
241
|
+
case 1:
|
|
242
|
+
(_a.sent()) && (errorMessage.value = '');
|
|
243
|
+
_a.label = 2;
|
|
244
|
+
case 2: return [2 /*return*/];
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}); };
|
|
248
|
+
return {
|
|
249
|
+
errorMessage: errorMessage,
|
|
250
|
+
validate: validate,
|
|
251
|
+
resetValidation: resetValidation,
|
|
252
|
+
validateWithTrigger: validateWithTrigger,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
exports.useValidation = useValidation;
|
|
256
|
+
function addRouteListener(cb) {
|
|
257
|
+
vue_1.onMounted(function () {
|
|
258
|
+
window.addEventListener('hashchange', cb);
|
|
259
|
+
window.addEventListener('popstate', cb);
|
|
260
|
+
});
|
|
261
|
+
vue_1.onUnmounted(function () {
|
|
262
|
+
window.removeEventListener('hashchange', cb);
|
|
263
|
+
window.removeEventListener('popstate', cb);
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
exports.addRouteListener = addRouteListener;
|
|
267
|
+
function useTeleport() {
|
|
268
|
+
var disabled = vue_1.ref(false);
|
|
269
|
+
vue_1.onActivated(function () {
|
|
270
|
+
disabled.value = false;
|
|
271
|
+
});
|
|
272
|
+
vue_1.onDeactivated(function () {
|
|
273
|
+
disabled.value = true;
|
|
274
|
+
});
|
|
275
|
+
return {
|
|
276
|
+
disabled: disabled,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
exports.useTeleport = useTeleport;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { StyleVars } from '../../utils';
|
|
2
|
+
export declare function getLeft(element: HTMLElement): number;
|
|
3
|
+
export declare function getTop(element: HTMLElement): number;
|
|
4
|
+
export declare function getScrollTop(element: Element | Window): number;
|
|
5
|
+
export declare function getScrollLeft(element: Element | Window): number;
|
|
6
|
+
export declare function inViewport(element: HTMLElement): Promise<boolean>;
|
|
7
|
+
export declare function getTranslate(el: HTMLElement): number;
|
|
8
|
+
export declare function isHidden(el: HTMLElement): boolean;
|
|
9
|
+
export declare function getParentScroller(el: HTMLElement): HTMLElement | Window;
|
|
10
|
+
export declare function getAllParentScroller(el: HTMLElement): Array<HTMLElement | Window>;
|
|
11
|
+
export declare const isRem: (value: unknown) => boolean;
|
|
12
|
+
export declare const isPx: (value: unknown) => boolean;
|
|
13
|
+
export declare const isPercent: (value: unknown) => boolean;
|
|
14
|
+
export declare const isVw: (value: unknown) => boolean;
|
|
15
|
+
export declare const isVh: (value: unknown) => boolean;
|
|
16
|
+
export declare const toPxNum: (value: unknown) => number;
|
|
17
|
+
export declare const toSizeUnit: (value: unknown) => unknown;
|
|
18
|
+
export declare function requestAnimationFrame(fn: FrameRequestCallback): number;
|
|
19
|
+
export declare function cancelAnimationFrame(handle: number): void;
|
|
20
|
+
export declare function nextTickFrame(fn: FrameRequestCallback): void;
|
|
21
|
+
export declare function doubleRaf(): Promise<unknown>;
|
|
22
|
+
interface ScrollToOptions {
|
|
23
|
+
top?: number;
|
|
24
|
+
left?: number;
|
|
25
|
+
duration?: number;
|
|
26
|
+
animation: (progress: number) => number;
|
|
27
|
+
}
|
|
28
|
+
export declare function scrollTo(element: HTMLElement | Window, { top, left, duration, animation }: ScrollToOptions): Promise<void>;
|
|
29
|
+
export declare function formatStyleVars(styleVars: StyleVars): StyleVars;
|
|
30
|
+
export {};
|