@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.
@@ -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
+ }
@@ -11,7 +11,7 @@ type RenderAnchorOptions = {
11
11
  tabIndex?: number;
12
12
  refDirective?: DirectiveResult<typeof RefDirective>;
13
13
  };
14
- export declare class AnchorMixinInterface extends LitElement {
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
@@ -20,6 +20,5 @@ export const AnchorMixin = (superclass) => {
20
20
  __decorate([
21
21
  property({ reflect: true })
22
22
  ], AnchorMixinClass.prototype, "rel", void 0);
23
- // @ts-ignore
24
23
  return AnchorMixinClass;
25
24
  };
@@ -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 extends LitElement {
7
+ export declare class FocusableMixinInterface {
8
8
  autofocus: boolean;
9
9
  tabIndex: number;
10
10
  protected get focusDisabled(): boolean;
@@ -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 extends LitElement {
8
+ export declare class ScrollBehaviorMixinInterface {
9
9
  scrollTarget?: string | HTMLElement | JQ<HTMLElement>;
10
10
  scrollBehavior?: ScrollBehavior;
11
11
  scrollThreshold?: number;
@@ -205,6 +205,5 @@ export const ScrollBehaviorMixin = (superclass) => {
205
205
  __decorate([
206
206
  watch('scrollBehavior')
207
207
  ], ScrollBehaviorMixinClass.prototype, "onScrollBehaviorChange", null);
208
- // @ts-ignore
209
208
  return ScrollBehaviorMixinClass;
210
209
  };
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@mdui/shared",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "mdui 项目的公共部分",
5
5
  "type": "module",
6
6
  "files": [
7
+ "base",
7
8
  "controllers",
8
9
  "decorators",
9
10
  "helpers",
@@ -1,7 +0,0 @@
1
- /**
2
- * 触发自定义事件
3
- * @param element
4
- * @param type
5
- * @param options 通常只用到 cancelable 和 detail;bubbles、composed 统一不用
6
- */
7
- export declare const emit: (element: HTMLElement, type: string, options?: CustomEventInit) => CustomEvent;
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
- };