@mantou/gem 1.7.11 → 2.0.0-alpha.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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/gem.es.js +1962 -1689
- package/dist/gem.umd.js +52 -54
- package/elements/base/dialog.d.ts +0 -11
- package/elements/base/dialog.d.ts.map +1 -1
- package/elements/base/dialog.js +93 -66
- package/elements/base/dialog.js.map +1 -1
- package/elements/base/gesture.d.ts +1 -2
- package/elements/base/gesture.d.ts.map +1 -1
- package/elements/base/gesture.js +157 -96
- package/elements/base/gesture.js.map +1 -1
- package/elements/base/link.d.ts +5 -5
- package/elements/base/link.d.ts.map +1 -1
- package/elements/base/link.js +249 -145
- package/elements/base/link.js.map +1 -1
- package/elements/base/modal-factory.d.ts +147 -139
- package/elements/base/modal-factory.d.ts.map +1 -1
- package/elements/base/modal-factory.js +84 -25
- package/elements/base/modal-factory.js.map +1 -1
- package/elements/base/reflect.d.ts +0 -1
- package/elements/base/reflect.d.ts.map +1 -1
- package/elements/base/reflect.js +83 -38
- package/elements/base/reflect.js.map +1 -1
- package/elements/base/route.d.ts +12 -24
- package/elements/base/route.d.ts.map +1 -1
- package/elements/base/route.js +263 -164
- package/elements/base/route.js.map +1 -1
- package/elements/base/title.d.ts +3 -11
- package/elements/base/title.d.ts.map +1 -1
- package/elements/base/title.js +110 -59
- package/elements/base/title.js.map +1 -1
- package/elements/base/unsafe.d.ts +0 -1
- package/elements/base/unsafe.d.ts.map +1 -1
- package/elements/base/unsafe.js +82 -33
- package/elements/base/unsafe.js.map +1 -1
- package/elements/base/use.d.ts.map +1 -1
- package/elements/base/use.js +95 -47
- package/elements/base/use.js.map +1 -1
- package/helper/i18n.d.ts +4 -9
- package/helper/i18n.d.ts.map +1 -1
- package/helper/i18n.js +69 -65
- package/helper/i18n.js.map +1 -1
- package/helper/logger.js +10 -9
- package/helper/logger.js.map +1 -1
- package/helper/react-shim.d.ts +15 -0
- package/helper/react-shim.d.ts.map +1 -0
- package/helper/react-shim.js +56 -0
- package/helper/react-shim.js.map +1 -0
- package/helper/react-utils.d.ts +15 -0
- package/helper/react-utils.d.ts.map +1 -0
- package/helper/react-utils.js +50 -0
- package/helper/react-utils.js.map +1 -0
- package/helper/request.d.ts +17 -7
- package/helper/request.d.ts.map +1 -1
- package/helper/request.js +103 -53
- package/helper/request.js.map +1 -1
- package/helper/ssr-shim.d.ts.map +1 -1
- package/helper/ssr-shim.js +8 -1
- package/helper/ssr-shim.js.map +1 -1
- package/helper/theme.d.ts +14 -21
- package/helper/theme.d.ts.map +1 -1
- package/helper/theme.js +55 -38
- package/helper/theme.js.map +1 -1
- package/index.d.ts +4 -3
- package/index.d.ts.map +1 -1
- package/index.js +5 -3
- package/index.js.map +1 -1
- package/lib/decorators.d.ts +74 -41
- package/lib/decorators.d.ts.map +1 -1
- package/lib/decorators.js +324 -84
- package/lib/decorators.js.map +1 -1
- package/lib/directives.d.ts +4 -0
- package/lib/directives.d.ts.map +1 -0
- package/lib/directives.js +5 -0
- package/lib/directives.js.map +1 -0
- package/lib/element.d.ts +112 -110
- package/lib/element.d.ts.map +1 -1
- package/lib/element.js +431 -470
- package/lib/element.js.map +1 -1
- package/lib/history.d.ts +4 -0
- package/lib/history.d.ts.map +1 -1
- package/lib/history.js +12 -13
- package/lib/history.js.map +1 -1
- package/lib/store.d.ts +1 -1
- package/lib/store.d.ts.map +1 -1
- package/lib/store.js +4 -5
- package/lib/store.js.map +1 -1
- package/lib/utils.d.ts +3 -43
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +61 -246
- package/lib/utils.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.d.ts.map +1 -1
- package/lib/version.js +2 -1
- package/lib/version.js.map +1 -1
- package/package.json +12 -11
- package/src/dist.ts +3 -2
- package/src/elements/base/dialog.ts +10 -20
- package/src/elements/base/gesture.ts +16 -14
- package/src/elements/base/link.ts +65 -44
- package/src/elements/base/modal-factory.ts +14 -14
- package/src/elements/base/reflect.ts +24 -32
- package/src/elements/base/route.ts +55 -68
- package/src/elements/base/title.ts +25 -42
- package/src/elements/base/unsafe.ts +12 -21
- package/src/elements/base/use.ts +17 -13
- package/src/helper/i18n.ts +20 -14
- package/src/helper/react-utils.ts +66 -0
- package/src/helper/request.ts +122 -53
- package/src/helper/ssr-shim.ts +8 -1
- package/src/helper/theme.ts +72 -45
- package/src/index.ts +6 -4
- package/src/lib/decorators.ts +394 -93
- package/src/lib/directives.ts +6 -0
- package/src/lib/element.ts +473 -499
- package/src/lib/history.ts +4 -3
- package/src/lib/store.ts +2 -1
- package/src/lib/utils.ts +19 -205
- package/src/lib/version.ts +2 -1
- package/src/test/elements/link.test.ts +1 -1
- package/src/test/elements/title.test.ts +1 -0
- package/src/test/gem-element/advance.test.ts +72 -49
- package/src/test/gem-element/basic.test.ts +37 -50
- package/src/test/gem-element/decorators.test.ts +22 -21
- package/src/test/gem-element/multi.test.ts +5 -5
- package/src/test/utils.test.ts +16 -38
|
@@ -12,17 +12,6 @@ export declare abstract class GemDialogBaseElement extends GemElement {
|
|
|
12
12
|
#private;
|
|
13
13
|
label: string;
|
|
14
14
|
opened: boolean;
|
|
15
|
-
constructor();
|
|
16
|
-
/**
|
|
17
|
-
* @final
|
|
18
|
-
* 进入关闭状态
|
|
19
|
-
*/
|
|
20
|
-
closeHandle: () => symbol;
|
|
21
|
-
/**
|
|
22
|
-
* @final
|
|
23
|
-
* 进入打开状态
|
|
24
|
-
*/
|
|
25
|
-
openHandle: () => symbol;
|
|
26
15
|
/**@final */
|
|
27
16
|
open: () => typeof final | undefined;
|
|
28
17
|
shouldClose(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/elements/base/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,QAAA,MAAM,KAAK,eAAW,CAAC;AAEvB;;;;;;;GAOG;AACH,
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/elements/base/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,QAAA,MAAM,KAAK,eAAW,CAAC;AAEvB;;;;;;;GAOG;AACH,8BAEsB,oBAAqB,SAAQ,UAAU;;IAChD,KAAK,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAuCvB,YAAY;IACZ,IAAI,iCAUF;IAEF,WAAW;IAIX,YAAY;IACZ,KAAK,eAGH;IAEF;;;;;OAKG;IACH,UAAU,eAIR;CACH"}
|
package/elements/base/dialog.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
11
27
|
};
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
17
34
|
};
|
|
18
|
-
var _GemDialogBaseElement_nextSibling, _GemDialogBaseElement_parentElement, _GemDialogBaseElement_inertStore;
|
|
19
35
|
import { GemElement } from '../../lib/element';
|
|
20
|
-
import { attribute, state, connectStore } from '../../lib/decorators';
|
|
36
|
+
import { attribute, state, connectStore, aria, willMount } from '../../lib/decorators';
|
|
21
37
|
import { history } from '../../lib/history';
|
|
22
38
|
const final = Symbol();
|
|
23
39
|
/**
|
|
@@ -28,61 +44,89 @@ const final = Symbol();
|
|
|
28
44
|
* @fires open
|
|
29
45
|
* @fires close
|
|
30
46
|
*/
|
|
31
|
-
let GemDialogBaseElement =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
47
|
+
let GemDialogBaseElement = (() => {
|
|
48
|
+
let _classDecorators = [connectStore(history.store), aria({ role: 'dialog', ariaModal: 'true' })];
|
|
49
|
+
let _classDescriptor;
|
|
50
|
+
let _classExtraInitializers = [];
|
|
51
|
+
let _classThis;
|
|
52
|
+
let _classSuper = GemElement;
|
|
53
|
+
let _label_decorators;
|
|
54
|
+
let _label_initializers = [];
|
|
55
|
+
let _label_extraInitializers = [];
|
|
56
|
+
let _opened_decorators;
|
|
57
|
+
let _opened_initializers = [];
|
|
58
|
+
let _opened_extraInitializers = [];
|
|
59
|
+
let _private_init_decorators;
|
|
60
|
+
let _private_init_initializers = [];
|
|
61
|
+
let _private_init_extraInitializers = [];
|
|
62
|
+
var GemDialogBaseElement = class extends _classSuper {
|
|
63
|
+
static { _classThis = this; }
|
|
64
|
+
static {
|
|
65
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
66
|
+
_label_decorators = [attribute];
|
|
67
|
+
_opened_decorators = [state];
|
|
68
|
+
_private_init_decorators = [willMount()];
|
|
69
|
+
__esDecorate(null, null, _label_decorators, { kind: "field", name: "label", static: false, private: false, access: { has: obj => "label" in obj, get: obj => obj.label, set: (obj, value) => { obj.label = value; } }, metadata: _metadata }, _label_initializers, _label_extraInitializers);
|
|
70
|
+
__esDecorate(null, null, _opened_decorators, { kind: "field", name: "opened", static: false, private: false, access: { has: obj => "opened" in obj, get: obj => obj.opened, set: (obj, value) => { obj.opened = value; } }, metadata: _metadata }, _opened_initializers, _opened_extraInitializers);
|
|
71
|
+
__esDecorate(null, null, _private_init_decorators, { kind: "field", name: "#init", static: false, private: true, access: { has: obj => #init in obj, get: obj => obj.#init, set: (obj, value) => { obj.#init = value; } }, metadata: _metadata }, _private_init_initializers, _private_init_extraInitializers);
|
|
72
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
73
|
+
GemDialogBaseElement = _classThis = _classDescriptor.value;
|
|
74
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
75
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
76
|
+
}
|
|
77
|
+
label = __runInitializers(this, _label_initializers, void 0);
|
|
78
|
+
opened = (__runInitializers(this, _label_extraInitializers), __runInitializers(this, _opened_initializers, void 0));
|
|
79
|
+
#nextSibling = __runInitializers(this, _opened_extraInitializers);
|
|
80
|
+
#parentElement;
|
|
81
|
+
#inertStore = [];
|
|
37
82
|
/**
|
|
38
|
-
* @final
|
|
39
83
|
* 进入关闭状态
|
|
40
84
|
*/
|
|
41
|
-
|
|
42
|
-
var _a;
|
|
85
|
+
#closeHandle = () => {
|
|
43
86
|
this.inert = true;
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
|
|
87
|
+
this.#inertStore.forEach((e) => (e.inert = false));
|
|
88
|
+
if (this.#nextSibling) {
|
|
89
|
+
this.#nextSibling.before(this);
|
|
47
90
|
}
|
|
48
|
-
else if (
|
|
49
|
-
|
|
91
|
+
else if (this.#parentElement) {
|
|
92
|
+
this.#parentElement?.appendChild(this);
|
|
50
93
|
}
|
|
51
94
|
this.dispatchEvent(new CustomEvent('close'));
|
|
52
95
|
this.opened = false;
|
|
53
|
-
return final;
|
|
54
96
|
};
|
|
55
97
|
/**
|
|
56
|
-
* @final
|
|
57
98
|
* 进入打开状态
|
|
58
99
|
*/
|
|
59
|
-
|
|
100
|
+
#openHandle = () => {
|
|
60
101
|
this.hidden = false;
|
|
61
102
|
this.inert = false;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
103
|
+
this.#nextSibling = this.nextSibling;
|
|
104
|
+
this.#parentElement = this.parentElement || this.getRootNode();
|
|
105
|
+
this.#inertStore = [...document.body.children].filter((e) => !e.inert);
|
|
106
|
+
this.#inertStore.forEach((e) => (e.inert = true));
|
|
66
107
|
document.body.append(this);
|
|
67
108
|
this.dispatchEvent(new CustomEvent('open'));
|
|
68
109
|
this.opened = true;
|
|
69
|
-
return final;
|
|
70
110
|
};
|
|
111
|
+
#init = __runInitializers(this, _private_init_initializers, () => (this.inert = true));
|
|
71
112
|
/**@final */
|
|
72
|
-
|
|
113
|
+
open = (__runInitializers(this, _private_init_extraInitializers), () => {
|
|
73
114
|
if (this.opened)
|
|
74
115
|
return;
|
|
75
|
-
this
|
|
116
|
+
this.#openHandle();
|
|
76
117
|
history.push({
|
|
77
118
|
title: this.label,
|
|
78
|
-
open: this
|
|
79
|
-
close: this
|
|
119
|
+
open: this.#openHandle,
|
|
120
|
+
close: this.#closeHandle,
|
|
80
121
|
shouldClose: this.shouldClose,
|
|
81
122
|
});
|
|
82
123
|
return final;
|
|
83
|
-
};
|
|
124
|
+
});
|
|
125
|
+
shouldClose() {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
84
128
|
/**@final */
|
|
85
|
-
|
|
129
|
+
close = () => {
|
|
86
130
|
history.back();
|
|
87
131
|
return final;
|
|
88
132
|
};
|
|
@@ -92,30 +136,13 @@ let GemDialogBaseElement = class GemDialogBaseElement extends GemElement {
|
|
|
92
136
|
* 避免 `shouldClose` 中造成无限循环
|
|
93
137
|
* 延时关闭避免同步操作 history
|
|
94
138
|
*/
|
|
95
|
-
|
|
139
|
+
forceClose = () => {
|
|
96
140
|
this.opened = false;
|
|
97
141
|
setTimeout(this.close, 100);
|
|
98
142
|
return final;
|
|
99
143
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
shouldClose() {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
_GemDialogBaseElement_nextSibling = new WeakMap();
|
|
109
|
-
_GemDialogBaseElement_parentElement = new WeakMap();
|
|
110
|
-
_GemDialogBaseElement_inertStore = new WeakMap();
|
|
111
|
-
__decorate([
|
|
112
|
-
attribute
|
|
113
|
-
], GemDialogBaseElement.prototype, "label", void 0);
|
|
114
|
-
__decorate([
|
|
115
|
-
state
|
|
116
|
-
], GemDialogBaseElement.prototype, "opened", void 0);
|
|
117
|
-
GemDialogBaseElement = __decorate([
|
|
118
|
-
connectStore(history.store)
|
|
119
|
-
], GemDialogBaseElement);
|
|
144
|
+
};
|
|
145
|
+
return GemDialogBaseElement = _classThis;
|
|
146
|
+
})();
|
|
120
147
|
export { GemDialogBaseElement };
|
|
121
148
|
//# sourceMappingURL=dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/elements/base/dialog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/elements/base/dialog.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GemElement } from '../../lib/element';
|
|
2
|
-
import { Emitter } from '../../lib/decorators';
|
|
2
|
+
import type { Emitter } from '../../lib/decorators';
|
|
3
3
|
export type PanEventDetail = {
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
@@ -47,7 +47,6 @@ export declare class GemGestureElement extends GemElement {
|
|
|
47
47
|
press: Emitter<null>;
|
|
48
48
|
end: Emitter<null>;
|
|
49
49
|
touchAction: string;
|
|
50
|
-
constructor();
|
|
51
50
|
/** 指针移动事件记录 */
|
|
52
51
|
movesMap: Map<number, PanEventDetail[]>;
|
|
53
52
|
render(): import("lit-html/lib/template-result").TemplateResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gesture.d.ts","sourceRoot":"","sources":["../../src/elements/base/gesture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,mBAAmB,CAAC;AACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"gesture.d.ts","sourceRoot":"","sources":["../../src/elements/base/gesture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,MAAM,MAAM,cAAc,GAAG;IAE3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,KAAK,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,gBAAgB;IAE/B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,iBAAiB;IAEhC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;CAChB;AAiBD;;;;;;;;;;;;;;GAcG;AACH,qBACa,iBAAkB,SAAQ,UAAU;;IACtC,GAAG,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAC7B,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjC,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACnC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,WAAW,EAAE,MAAM,CAAC;IAO/B,eAAe;IACf,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAa;IAmLpD,MAAM;CAYP"}
|
package/elements/base/gesture.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
11
27
|
};
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
17
34
|
};
|
|
18
|
-
var _GemGestureElement_pressed, _GemGestureElement_pressTimer, _GemGestureElement_startEventMap, _GemGestureElement_getMoves, _GemGestureElement_getStartEvent, _GemGestureElement_getOtherLastMove, _GemGestureElement_getMovementX, _GemGestureElement_getMovementY, _GemGestureElement_onStart, _GemGestureElement_onMove, _GemGestureElement_onMoveSet, _GemGestureElement_onEnd;
|
|
19
35
|
import { GemElement, html } from '../../lib/element';
|
|
20
|
-
import { attribute, emitter } from '../../lib/decorators';
|
|
36
|
+
import { attribute, emitter, mounted, shadow } from '../../lib/decorators';
|
|
21
37
|
function angleAB(a, b, c, { clientX: x1, clientY: y1 }, { clientX: x2, clientY: y2 }, { clientX: x3, clientY: y3 }) {
|
|
22
38
|
// https://en.wikipedia.org/wiki/Law_of_cosines
|
|
23
39
|
// https://blog.csdn.net/z278930050/article/details/53319091
|
|
@@ -38,29 +54,88 @@ function angleAB(a, b, c, { clientX: x1, clientY: y1 }, { clientX: x2, clientY:
|
|
|
38
54
|
*
|
|
39
55
|
* @attr touch-action
|
|
40
56
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
let GemGestureElement = (() => {
|
|
58
|
+
let _classDecorators = [shadow()];
|
|
59
|
+
let _classDescriptor;
|
|
60
|
+
let _classExtraInitializers = [];
|
|
61
|
+
let _classThis;
|
|
62
|
+
let _classSuper = GemElement;
|
|
63
|
+
let _pan_decorators;
|
|
64
|
+
let _pan_initializers = [];
|
|
65
|
+
let _pan_extraInitializers = [];
|
|
66
|
+
let _pinch_decorators;
|
|
67
|
+
let _pinch_initializers = [];
|
|
68
|
+
let _pinch_extraInitializers = [];
|
|
69
|
+
let _rotate_decorators;
|
|
70
|
+
let _rotate_initializers = [];
|
|
71
|
+
let _rotate_extraInitializers = [];
|
|
72
|
+
let _swipe_decorators;
|
|
73
|
+
let _swipe_initializers = [];
|
|
74
|
+
let _swipe_extraInitializers = [];
|
|
75
|
+
let _press_decorators;
|
|
76
|
+
let _press_initializers = [];
|
|
77
|
+
let _press_extraInitializers = [];
|
|
78
|
+
let _end_decorators;
|
|
79
|
+
let _end_initializers = [];
|
|
80
|
+
let _end_extraInitializers = [];
|
|
81
|
+
let _touchAction_decorators;
|
|
82
|
+
let _touchAction_initializers = [];
|
|
83
|
+
let _touchAction_extraInitializers = [];
|
|
84
|
+
let _private_init_decorators;
|
|
85
|
+
let _private_init_initializers = [];
|
|
86
|
+
let _private_init_extraInitializers = [];
|
|
87
|
+
var GemGestureElement = class extends _classSuper {
|
|
88
|
+
static { _classThis = this; }
|
|
89
|
+
static {
|
|
90
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
91
|
+
_pan_decorators = [emitter];
|
|
92
|
+
_pinch_decorators = [emitter];
|
|
93
|
+
_rotate_decorators = [emitter];
|
|
94
|
+
_swipe_decorators = [emitter];
|
|
95
|
+
_press_decorators = [emitter];
|
|
96
|
+
_end_decorators = [emitter];
|
|
97
|
+
_touchAction_decorators = [attribute];
|
|
98
|
+
_private_init_decorators = [mounted()];
|
|
99
|
+
__esDecorate(null, null, _pan_decorators, { kind: "field", name: "pan", static: false, private: false, access: { has: obj => "pan" in obj, get: obj => obj.pan, set: (obj, value) => { obj.pan = value; } }, metadata: _metadata }, _pan_initializers, _pan_extraInitializers);
|
|
100
|
+
__esDecorate(null, null, _pinch_decorators, { kind: "field", name: "pinch", static: false, private: false, access: { has: obj => "pinch" in obj, get: obj => obj.pinch, set: (obj, value) => { obj.pinch = value; } }, metadata: _metadata }, _pinch_initializers, _pinch_extraInitializers);
|
|
101
|
+
__esDecorate(null, null, _rotate_decorators, { kind: "field", name: "rotate", static: false, private: false, access: { has: obj => "rotate" in obj, get: obj => obj.rotate, set: (obj, value) => { obj.rotate = value; } }, metadata: _metadata }, _rotate_initializers, _rotate_extraInitializers);
|
|
102
|
+
__esDecorate(null, null, _swipe_decorators, { kind: "field", name: "swipe", static: false, private: false, access: { has: obj => "swipe" in obj, get: obj => obj.swipe, set: (obj, value) => { obj.swipe = value; } }, metadata: _metadata }, _swipe_initializers, _swipe_extraInitializers);
|
|
103
|
+
__esDecorate(null, null, _press_decorators, { kind: "field", name: "press", static: false, private: false, access: { has: obj => "press" in obj, get: obj => obj.press, set: (obj, value) => { obj.press = value; } }, metadata: _metadata }, _press_initializers, _press_extraInitializers);
|
|
104
|
+
__esDecorate(null, null, _end_decorators, { kind: "field", name: "end", static: false, private: false, access: { has: obj => "end" in obj, get: obj => obj.end, set: (obj, value) => { obj.end = value; } }, metadata: _metadata }, _end_initializers, _end_extraInitializers);
|
|
105
|
+
__esDecorate(null, null, _touchAction_decorators, { kind: "field", name: "touchAction", static: false, private: false, access: { has: obj => "touchAction" in obj, get: obj => obj.touchAction, set: (obj, value) => { obj.touchAction = value; } }, metadata: _metadata }, _touchAction_initializers, _touchAction_extraInitializers);
|
|
106
|
+
__esDecorate(null, null, _private_init_decorators, { kind: "field", name: "#init", static: false, private: true, access: { has: obj => #init in obj, get: obj => obj.#init, set: (obj, value) => { obj.#init = value; } }, metadata: _metadata }, _private_init_initializers, _private_init_extraInitializers);
|
|
107
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
108
|
+
GemGestureElement = _classThis = _classDescriptor.value;
|
|
109
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
110
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
111
|
+
}
|
|
112
|
+
pan = __runInitializers(this, _pan_initializers, void 0);
|
|
113
|
+
pinch = (__runInitializers(this, _pan_extraInitializers), __runInitializers(this, _pinch_initializers, void 0));
|
|
114
|
+
rotate = (__runInitializers(this, _pinch_extraInitializers), __runInitializers(this, _rotate_initializers, void 0));
|
|
115
|
+
swipe = (__runInitializers(this, _rotate_extraInitializers), __runInitializers(this, _swipe_initializers, void 0));
|
|
116
|
+
press = (__runInitializers(this, _swipe_extraInitializers), __runInitializers(this, _press_initializers, void 0));
|
|
117
|
+
end = (__runInitializers(this, _press_extraInitializers), __runInitializers(this, _end_initializers, void 0));
|
|
118
|
+
touchAction = (__runInitializers(this, _end_extraInitializers), __runInitializers(this, _touchAction_initializers, void 0));
|
|
119
|
+
#pressed = (__runInitializers(this, _touchAction_extraInitializers), false); // 触发 press 之后不触发其他事件
|
|
120
|
+
#pressTimer = 0;
|
|
121
|
+
#startEventMap = new Map();
|
|
47
122
|
/** 指针移动事件记录 */
|
|
48
|
-
|
|
49
|
-
|
|
123
|
+
movesMap = new Map();
|
|
124
|
+
#getMoves = (pointerId) => {
|
|
50
125
|
return this.movesMap.get(pointerId) || [];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
126
|
+
};
|
|
127
|
+
#getStartEvent = (pointerId) => {
|
|
128
|
+
return this.#startEventMap.get(pointerId);
|
|
129
|
+
};
|
|
130
|
+
#getOtherLastMove = (pointerId) => {
|
|
56
131
|
for (const id of this.movesMap.keys()) {
|
|
57
132
|
if (id !== pointerId) {
|
|
58
|
-
const moves =
|
|
59
|
-
return moves[moves.length - 1] ||
|
|
133
|
+
const moves = this.#getMoves(id);
|
|
134
|
+
return moves[moves.length - 1] || this.#getStartEvent(id);
|
|
60
135
|
}
|
|
61
136
|
}
|
|
62
|
-
}
|
|
63
|
-
|
|
137
|
+
};
|
|
138
|
+
#getMovementX = (x, y) => {
|
|
64
139
|
const touchAction = this.touchAction;
|
|
65
140
|
if ((touchAction.includes('pan-right') && x > 0) ||
|
|
66
141
|
(touchAction.includes('pan-left') && x < 0) ||
|
|
@@ -73,8 +148,8 @@ export class GemGestureElement extends GemElement {
|
|
|
73
148
|
return 0;
|
|
74
149
|
}
|
|
75
150
|
return x;
|
|
76
|
-
}
|
|
77
|
-
|
|
151
|
+
};
|
|
152
|
+
#getMovementY = (x, y) => {
|
|
78
153
|
const touchAction = this.touchAction;
|
|
79
154
|
if ((touchAction.includes('pan-down') && y > 0) ||
|
|
80
155
|
(touchAction.includes('pan-up') && y < 0) ||
|
|
@@ -87,33 +162,33 @@ export class GemGestureElement extends GemElement {
|
|
|
87
162
|
return 0;
|
|
88
163
|
}
|
|
89
164
|
return y;
|
|
90
|
-
}
|
|
91
|
-
|
|
165
|
+
};
|
|
166
|
+
#onStart = (evt) => {
|
|
92
167
|
evt.stopPropagation();
|
|
93
168
|
this.setPointerCapture(evt.pointerId);
|
|
94
169
|
this.movesMap.set(evt.pointerId, []);
|
|
95
|
-
|
|
170
|
+
this.#startEventMap.set(evt.pointerId, evt);
|
|
96
171
|
if (evt.isPrimary) {
|
|
97
|
-
|
|
98
|
-
|
|
172
|
+
this.#pressed = false;
|
|
173
|
+
this.#pressTimer = window.setTimeout(() => {
|
|
99
174
|
this.press(null);
|
|
100
|
-
|
|
101
|
-
}, 251)
|
|
175
|
+
this.#pressed = true;
|
|
176
|
+
}, 251);
|
|
102
177
|
}
|
|
103
|
-
}
|
|
104
|
-
|
|
178
|
+
};
|
|
179
|
+
#onMove = (evt) => {
|
|
105
180
|
const { pointerId, clientX, clientY, isPrimary, pointerType, timeStamp } = evt;
|
|
106
|
-
if (!
|
|
107
|
-
const moves =
|
|
108
|
-
const startEvent =
|
|
181
|
+
if (!this.#pressed && this.hasPointerCapture(pointerId)) {
|
|
182
|
+
const moves = this.#getMoves(pointerId);
|
|
183
|
+
const startEvent = this.#getStartEvent(pointerId);
|
|
109
184
|
const lastMove = moves[moves.length - 1] || startEvent;
|
|
110
185
|
// https://bugs.webkit.org/show_bug.cgi?id=220194
|
|
111
186
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=1092358
|
|
112
187
|
const movementX = clientX - lastMove.clientX;
|
|
113
188
|
const movementY = clientY - lastMove.clientY;
|
|
114
189
|
const move = {
|
|
115
|
-
x:
|
|
116
|
-
y:
|
|
190
|
+
x: this.#getMovementX(movementX, movementY),
|
|
191
|
+
y: this.#getMovementY(movementX, movementY),
|
|
117
192
|
clientX,
|
|
118
193
|
clientY,
|
|
119
194
|
timeStamp,
|
|
@@ -123,7 +198,7 @@ export class GemGestureElement extends GemElement {
|
|
|
123
198
|
moves.push(move);
|
|
124
199
|
this.pan(move);
|
|
125
200
|
if (this.movesMap.size !== 1) {
|
|
126
|
-
const secondaryPoint =
|
|
201
|
+
const secondaryPoint = this.#getOtherLastMove(pointerId);
|
|
127
202
|
const moveLen = Math.sqrt(movementX ** 2 + movementY ** 2);
|
|
128
203
|
const distanceLen = Math.sqrt((lastMove.clientX - secondaryPoint.clientX) ** 2 + (lastMove.clientY - secondaryPoint.clientY) ** 2);
|
|
129
204
|
const newDistanceLen = Math.sqrt((clientX - secondaryPoint.clientX) ** 2 + (clientY - secondaryPoint.clientY) ** 2);
|
|
@@ -137,30 +212,30 @@ export class GemGestureElement extends GemElement {
|
|
|
137
212
|
Math.abs(movementY) > accuracy ||
|
|
138
213
|
Math.abs(move.clientX - startEvent.clientX) > accuracy ||
|
|
139
214
|
Math.abs(move.clientY - startEvent.clientY) > accuracy) {
|
|
140
|
-
window.clearTimeout(
|
|
215
|
+
window.clearTimeout(this.#pressTimer);
|
|
141
216
|
}
|
|
142
217
|
}
|
|
143
|
-
}
|
|
144
|
-
|
|
218
|
+
};
|
|
219
|
+
#onMoveSet = (evt) => {
|
|
145
220
|
evt.stopPropagation();
|
|
146
221
|
// https://bugs.webkit.org/show_bug.cgi?id=210454
|
|
147
222
|
if ('getCoalescedEvents' in evt) {
|
|
148
|
-
evt.getCoalescedEvents().forEach((
|
|
223
|
+
evt.getCoalescedEvents().forEach((event) => this.#onMove(event));
|
|
149
224
|
}
|
|
150
225
|
else {
|
|
151
|
-
|
|
226
|
+
this.#onMove(evt);
|
|
152
227
|
}
|
|
153
|
-
}
|
|
154
|
-
|
|
228
|
+
};
|
|
229
|
+
#onEnd = (evt) => {
|
|
155
230
|
evt.stopPropagation();
|
|
156
231
|
const { pointerId } = evt;
|
|
157
|
-
window.clearTimeout(
|
|
232
|
+
window.clearTimeout(this.#pressTimer);
|
|
158
233
|
if (this.movesMap.size === 1) {
|
|
159
234
|
this.end(null);
|
|
160
235
|
}
|
|
161
236
|
// auto release: https://javascript.info/pointer-events#pointer-capturing
|
|
162
|
-
if (!
|
|
163
|
-
const moves =
|
|
237
|
+
if (!this.#pressed && this.hasPointerCapture(pointerId)) {
|
|
238
|
+
const moves = this.#getMoves(pointerId);
|
|
164
239
|
if (moves.length > 2) {
|
|
165
240
|
const { x, y, timeStamp, clientX, clientY } = moves[moves.length - 1];
|
|
166
241
|
const move2 = moves[moves.length - 3];
|
|
@@ -189,18 +264,19 @@ export class GemGestureElement extends GemElement {
|
|
|
189
264
|
}
|
|
190
265
|
}
|
|
191
266
|
this.movesMap.delete(pointerId);
|
|
192
|
-
|
|
267
|
+
this.#startEventMap.delete(pointerId);
|
|
268
|
+
};
|
|
269
|
+
#init = __runInitializers(this, _private_init_initializers, () => {
|
|
270
|
+
this.addEventListener('pointerdown', this.#onStart);
|
|
271
|
+
this.addEventListener('pointermove', this.#onMoveSet);
|
|
272
|
+
this.addEventListener('pointerup', this.#onEnd);
|
|
273
|
+
this.addEventListener('pointerleave', this.#onEnd); // 有时候 up 没有触发?
|
|
274
|
+
// 为什么空白区域会自动触发 `pointercancel`?
|
|
275
|
+
this.addEventListener('pointercancel', this.#onEnd);
|
|
276
|
+
this.addEventListener('dragstart', (evt) => evt.preventDefault());
|
|
193
277
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
this.addEventListener('pointerup', __classPrivateFieldGet(this, _GemGestureElement_onEnd, "f"));
|
|
197
|
-
this.addEventListener('pointerleave', __classPrivateFieldGet(this, _GemGestureElement_onEnd, "f")); // 有时候 up 没有触发?
|
|
198
|
-
// 为什么空白区域会自动触发 `pointercancel`?
|
|
199
|
-
this.addEventListener('pointercancel', __classPrivateFieldGet(this, _GemGestureElement_onEnd, "f"));
|
|
200
|
-
this.addEventListener('dragstart', (evt) => evt.preventDefault());
|
|
201
|
-
}
|
|
202
|
-
render() {
|
|
203
|
-
return html `
|
|
278
|
+
render() {
|
|
279
|
+
return html `
|
|
204
280
|
<style>
|
|
205
281
|
:host(:where(:not([hidden]))) {
|
|
206
282
|
display: block;
|
|
@@ -210,28 +286,13 @@ export class GemGestureElement extends GemElement {
|
|
|
210
286
|
</style>
|
|
211
287
|
<slot></slot>
|
|
212
288
|
`;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
__decorate([
|
|
223
|
-
emitter
|
|
224
|
-
], GemGestureElement.prototype, "rotate", void 0);
|
|
225
|
-
__decorate([
|
|
226
|
-
emitter
|
|
227
|
-
], GemGestureElement.prototype, "swipe", void 0);
|
|
228
|
-
__decorate([
|
|
229
|
-
emitter
|
|
230
|
-
], GemGestureElement.prototype, "press", void 0);
|
|
231
|
-
__decorate([
|
|
232
|
-
emitter
|
|
233
|
-
], GemGestureElement.prototype, "end", void 0);
|
|
234
|
-
__decorate([
|
|
235
|
-
attribute
|
|
236
|
-
], GemGestureElement.prototype, "touchAction", void 0);
|
|
289
|
+
}
|
|
290
|
+
constructor() {
|
|
291
|
+
super(...arguments);
|
|
292
|
+
__runInitializers(this, _private_init_extraInitializers);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
return GemGestureElement = _classThis;
|
|
296
|
+
})();
|
|
297
|
+
export { GemGestureElement };
|
|
237
298
|
//# sourceMappingURL=gesture.js.map
|