@mdui/shared 1.0.2 → 1.0.3
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/base/mdui-element.d.ts +16 -0
- package/base/mdui-element.js +18 -0
- package/mixins/anchor.d.ts +1 -1
- package/mixins/anchor.js +0 -1
- package/mixins/focusable.d.ts +1 -1
- package/mixins/focusable.js +1 -2
- package/mixins/scrollBehavior.d.ts +1 -1
- package/mixins/scrollBehavior.js +0 -1
- package/package.json +2 -1
- package/helpers/event.d.ts +0 -7
- package/helpers/event.js +0 -17
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export type UnpackCustomEvent<T> = T extends CustomEvent<infer U> ? U : never;
|
|
3
|
+
export declare class MduiElement<E> extends LitElement {
|
|
4
|
+
/**
|
|
5
|
+
* 触发自定义事件。若返回 false,表示事件被取消
|
|
6
|
+
* @param type
|
|
7
|
+
* @param options 通常只用到 cancelable 和 detail;bubbles、composed 统一不用
|
|
8
|
+
*/
|
|
9
|
+
protected emit<K extends keyof E, D extends UnpackCustomEvent<E[K]>>(type: K, options?: CustomEventInit<D>): boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface MduiElement<E> {
|
|
12
|
+
addEventListener<K extends keyof M, M extends E & HTMLElementEventMap>(type: K, listener: (this: this, ev: M[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
|
|
13
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
14
|
+
removeEventListener<K extends keyof M, M extends E & HTMLElementEventMap>(type: K, listener: (this: this, ev: M[K]) => unknown, options?: boolean | EventListenerOptions): void;
|
|
15
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
3
|
+
export class MduiElement extends LitElement {
|
|
4
|
+
/**
|
|
5
|
+
* 触发自定义事件。若返回 false,表示事件被取消
|
|
6
|
+
* @param type
|
|
7
|
+
* @param options 通常只用到 cancelable 和 detail;bubbles、composed 统一不用
|
|
8
|
+
*/
|
|
9
|
+
emit(type, options) {
|
|
10
|
+
const event = new CustomEvent(type, Object.assign({
|
|
11
|
+
bubbles: true,
|
|
12
|
+
cancelable: false,
|
|
13
|
+
composed: true,
|
|
14
|
+
detail: {},
|
|
15
|
+
}, options));
|
|
16
|
+
return this.dispatchEvent(event);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/mixins/anchor.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ type RenderAnchorOptions = {
|
|
|
11
11
|
tabIndex?: number;
|
|
12
12
|
refDirective?: DirectiveResult<typeof RefDirective>;
|
|
13
13
|
};
|
|
14
|
-
export declare class AnchorMixinInterface
|
|
14
|
+
export declare class AnchorMixinInterface {
|
|
15
15
|
href?: string;
|
|
16
16
|
download?: string;
|
|
17
17
|
target?: '_blank' | '_parent' | '_self' | '_top';
|
package/mixins/anchor.js
CHANGED
package/mixins/focusable.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import '@mdui/jq/methods/each.js';
|
|
|
4
4
|
import '@mdui/jq/methods/removeAttr.js';
|
|
5
5
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
6
6
|
import type { LitElement } from 'lit';
|
|
7
|
-
export declare class FocusableMixinInterface
|
|
7
|
+
export declare class FocusableMixinInterface {
|
|
8
8
|
autofocus: boolean;
|
|
9
9
|
tabIndex: number;
|
|
10
10
|
protected get focusDisabled(): boolean;
|
package/mixins/focusable.js
CHANGED
|
@@ -246,8 +246,7 @@ export const FocusableMixin = (superclass) => {
|
|
|
246
246
|
})
|
|
247
247
|
], FocusableMixinClass.prototype, "focusVisible", void 0);
|
|
248
248
|
__decorate([
|
|
249
|
-
property({ type: Number })
|
|
249
|
+
property({ type: Number, attribute: 'tabindex' })
|
|
250
250
|
], FocusableMixinClass.prototype, "tabIndex", null);
|
|
251
|
-
// @ts-ignore
|
|
252
251
|
return FocusableMixinClass;
|
|
253
252
|
};
|
|
@@ -5,7 +5,7 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
|
5
5
|
import type { LitElement } from 'lit';
|
|
6
6
|
type ScrollBehavior = 'hide' | 'shrink' | 'elevate';
|
|
7
7
|
export type ScrollPaddingPosition = 'top' | 'bottom';
|
|
8
|
-
export declare class ScrollBehaviorMixinInterface
|
|
8
|
+
export declare class ScrollBehaviorMixinInterface {
|
|
9
9
|
scrollTarget?: string | HTMLElement | JQ<HTMLElement>;
|
|
10
10
|
scrollBehavior?: ScrollBehavior;
|
|
11
11
|
scrollThreshold?: number;
|
package/mixins/scrollBehavior.js
CHANGED
package/package.json
CHANGED
package/helpers/event.d.ts
DELETED
package/helpers/event.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 触发自定义事件
|
|
3
|
-
* @param element
|
|
4
|
-
* @param type
|
|
5
|
-
* @param options 通常只用到 cancelable 和 detail;bubbles、composed 统一不用
|
|
6
|
-
*/
|
|
7
|
-
export const emit = (element, type, options) => {
|
|
8
|
-
const event = new CustomEvent(type, {
|
|
9
|
-
bubbles: true,
|
|
10
|
-
cancelable: false,
|
|
11
|
-
composed: true,
|
|
12
|
-
detail: {},
|
|
13
|
-
...options,
|
|
14
|
-
});
|
|
15
|
-
element.dispatchEvent(event);
|
|
16
|
-
return event;
|
|
17
|
-
};
|