amateras 0.3.0 → 0.4.1

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/src/lib/assign.ts CHANGED
@@ -1,17 +1,15 @@
1
1
  import { Signal } from "../structure/Signal";
2
- import { _instanceof, _Object_defineProperty, isUndefined } from "./native";
2
+ import { _instanceof, _Object_defineProperty, forEach, isUndefined } from "./native";
3
3
 
4
- export function assign(target: any, {set, get, fn}: {
4
+ export const assign = (target: any, {set, get, fn}: {
5
5
  set?: string[],
6
6
  get?: string[],
7
7
  fn?: string[]
8
- }) {
8
+ }) => {
9
9
  const [GET, SET, FN] = ['get', 'set', 'fn'] as const;
10
- const filterAndMap = (type: 'get' | 'set' | 'fn', arr: string[] | undefined) => {
11
- return arr?.map(prop => [type, prop]) ?? []
12
- }
10
+ const filterAndMap = (type: 'get' | 'set' | 'fn', arr: string[] | undefined) => arr?.map(prop => [type, prop]) ?? []
13
11
  const list = [...filterAndMap(GET, get), ...filterAndMap(SET, set), ...filterAndMap(FN, fn)] as [string, string][];
14
- for (const [type, prop] of list) {
12
+ forEach(list, ([type, prop]) =>
15
13
  _Object_defineProperty(target.prototype, prop, {
16
14
  ...(type === GET ? {
17
15
  get() { return this.node[prop as any] }
@@ -19,21 +17,22 @@ export function assign(target: any, {set, get, fn}: {
19
17
  writable: true,
20
18
  ...(type === SET ? {
21
19
  // set
22
- value: function (this, args: any) {
20
+ value(this, args: any) {
23
21
  if (!arguments.length) return this.node[prop];
24
- const set = (value: any) => !isUndefined(value) && (this.node[prop] = value);
22
+ let set = (value: any) => !isUndefined(value) && (this.node[prop] = value);
25
23
  if (_instanceof(args, Signal)) args = args.subscribe(set).value();
26
24
  set(args)
27
25
  return this;
28
26
  }
29
27
  } : {
30
28
  // fn
31
- value: function (this, ...args : any[]) {
32
- return this.node[prop](...args) ?? this;
29
+ value(this, ...args : any[]) {
30
+ let result = this.node[prop](...args)
31
+ return isUndefined(result) ? this : result;
33
32
  }
34
33
  })
35
34
  }),
36
35
 
37
36
  })
38
- }
37
+ )
39
38
  }
@@ -1,16 +1,17 @@
1
1
  import type { $Node } from "#node/$Node";
2
2
  import { assign } from "./assign";
3
- import { _Object_entries, _Object_getOwnPropertyDescriptors } from "./native";
3
+ import { _Object_entries, _Object_getOwnPropertyDescriptors, forEach } from "./native";
4
4
 
5
- export function assignHelper(object: Constructor<Node>, target: Constructor<$Node>, tagname?: string) {
5
+ export const assignHelper = (object: Constructor<EventTarget>, target: Constructor<$Node>, tagname?: string) => {
6
6
  const [set, get, fn] = [[], [], []] as [string[], string[], string[]]
7
7
  // assign native object properties to target
8
- for (const [prop, value] of _Object_entries(_Object_getOwnPropertyDescriptors(object.prototype))) {
9
- if (prop in target.prototype) continue;
10
- if (value.get && !value.set) get.push(prop);
11
- else if (value.value) fn.push(prop);
12
- else if (value.get && value.set) set.push(prop);
13
- }
8
+ forEach(_Object_entries(_Object_getOwnPropertyDescriptors(object.prototype)), ([prop, value]) => {
9
+ if (!(prop in target.prototype)) {
10
+ if (value.get && !value.set) get.push(prop);
11
+ else if (value.value) fn.push(prop);
12
+ else if (value.get && value.set) set.push(prop);
13
+ }
14
+ })
14
15
  assign(target, {set, get, fn})
15
16
  // register tagname
16
17
  if (tagname) $.assign(tagname, target)
@@ -0,0 +1,13 @@
1
+ import { isUndefined } from "./native";
2
+
3
+ export const chain: chain = <T, R, V>(_this: T, args: IArguments | null, get: (() => R) | null, value: V, set: (value: Exclude<V, undefined>) => any) =>
4
+ args && get && !args.length
5
+ ? get()
6
+ : isUndefined(value)
7
+ ? _this
8
+ : (set(value as any), _this);
9
+
10
+ interface chain {
11
+ <T, V>(_this: T, args: null, get: null, value: V, set: (value: Exclude<V, undefined>) => any): T
12
+ <T, R, V>(_this: T, args: IArguments, get: (() => R), value: V, set: (value: Exclude<V, undefined>) => any): T | R
13
+ }
@@ -0,0 +1,7 @@
1
+ export const debounce = () => {
2
+ let timer: ReturnType<typeof setTimeout>;
3
+ return (fn: Function, timeout: number) => {
4
+ if (timer) clearTimeout(timer);
5
+ timer = setTimeout(fn, timeout);
6
+ }
7
+ }
package/src/lib/env.ts ADDED
@@ -0,0 +1,2 @@
1
+ // window and document
2
+ export const _document = document;
package/src/lib/native.ts CHANGED
@@ -1,5 +1,5 @@
1
- // document
2
- export const _document = document;
1
+ // Value
2
+ export const _null = null;
3
3
  // Object
4
4
  export const _Object_fromEntries = Object.fromEntries;
5
5
  export const _Object_entries = Object.entries;
@@ -9,37 +9,27 @@ export const _Object_defineProperty = Object.defineProperty;
9
9
  export const _Object_getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors;
10
10
  // Array
11
11
  export const _Array_from = Array.from;
12
- export function forEach<N extends Node>(set: NodeListOf<N>, fn: (value: N, index: number, parent: NodeListOf<N>) => any, thisArgs?: any): void;
13
- export function forEach<K, V>(set: Map<K, V>, fn: (value: V, key: K, index: number, map: Map<K, V>) => any, thisArgs?: any): void;
14
- export function forEach<T>(set: Set<T>, fn: (value: T, index: number, set: Set<T>) => any, thisArgs?: any): void;
15
- export function forEach<T>(arr: Array<T>, fn: (value: T, index: number, array: Array<T>) => any, thisArgs?: any): void;
16
- export function forEach<T>(arr: any, fn: any, thisArgs?: any) {
17
- arr.forEach(fn, thisArgs)
18
- }
19
- // typeof
20
- export function _typeof(target: any, type: 'string' | 'number' | 'object' | 'boolean' | 'function' | 'bigint' | 'symbol' | 'undefined') {
21
- return typeof target === type;
22
- }
23
- export function isString(target: any): target is string {
24
- return _typeof(target, 'string');
25
- }
26
- export function isNumber(target: any): target is number {
27
- return _typeof(target, 'number')
28
- }
29
- export function isObject(target: any): target is object {
30
- return _typeof(target, 'object')
31
- }
32
- export function isFunction(target: any): target is Function {
33
- return _typeof(target, 'function')
34
- }
35
- export function isUndefined(target: any): target is undefined {
36
- return _typeof(target, 'undefined')
37
- }
38
- export function isNull(target: any): target is null {
39
- return target === null;
40
- }
41
- export function _instanceof<T extends (abstract new (...args: any[]) => any)[]>(target: any, ...instance: T): target is InstanceType<T[number]> {
42
- return !!instance.find(i => target instanceof i);
43
- }
12
+ export const forEach: forEach = <T>(arr: any, fn: any, thisArgs?: any) => arr.forEach(fn, thisArgs);
13
+ // type check
14
+ export const _typeof = (target: any, type: 'string' | 'number' | 'object' | 'boolean' | 'function' | 'bigint' | 'symbol' | 'undefined') => typeof target === type;
15
+ export const equal = <T, V extends T>(target: T, ...args: V[]): target is V => !!args.find(a => a === target);
16
+ export const isString = (target: any): target is string => _typeof(target, 'string');
17
+ export const isNumber = (target: any): target is number => _typeof(target, 'number')
18
+ export const isObject = (target: any): target is object => _typeof(target, 'object')
19
+ export const isFunction = (target: any): target is Function => _typeof(target, 'function')
20
+ export const isUndefined = (target: any): target is undefined => target === undefined;
21
+ export const isNull = (target: any): target is null => target === _null;
22
+ export const _instanceof = <T extends (abstract new (...args: any[]) => any)[]>(target: any, ...instance: T): target is InstanceType<T[number]> => !!instance.find(i => target instanceof i);
44
23
  // JSON
45
- export const _JSON_stringify = JSON.stringify;
24
+ export const _JSON_stringify = JSON.stringify;
25
+ export const _JSON_parse = JSON.parse;
26
+ // String
27
+ export const startsWith = (target: string, ...str: string[]) => !!str.find(s => target.startsWith(s));
28
+ // Function
29
+ export const _bind = (target: Function, obj: Object) => target.bind(obj);
30
+ interface forEach {
31
+ <T>(arr: Array<T>, fn: (value: T, index: number, array: Array<T>) => any, thisArgs?: any): void;
32
+ <T>(set: Set<T>, fn: (value: T, index: number, set: Set<T>) => any, thisArgs?: any): void;
33
+ <K, V>(set: Map<K, V>, fn: (value: V, key: K, index: number, map: Map<K, V>) => any, thisArgs?: any): void;
34
+ <N extends Node>(set: NodeListOf<N>, fn: (value: N, index: number, parent: NodeListOf<N>) => any, thisArgs?: any): void;
35
+ }
@@ -2,10 +2,8 @@ import { _Array_from } from "./native";
2
2
 
3
3
  const LOWER = 'abcdefghijklmnopqrstuvwxyz';
4
4
  const UPPER = LOWER.toUpperCase();
5
- export function randomId(options?: {length?: number, lettercase?: 'any' | 'lower' | 'upper'}): string {
5
+ export const randomId = (options?: {length?: number, lettercase?: 'any' | 'lower' | 'upper'}): string => {
6
6
  options = {length: 5, lettercase: 'any', ...options};
7
7
  const char = options.lettercase === 'any' ? LOWER + UPPER : options.lettercase === 'lower' ? LOWER : UPPER;
8
- return _Array_from({length: options.length as number}, (_, i) => {
9
- const rand = Math.round(Math.random() * char.length); return char[rand]
10
- }).join('');
8
+ return _Array_from({length: options.length as number}, (_, i) => char[Math.round(Math.random() * char.length)]).join('');
11
9
  }
package/src/lib/sleep.ts CHANGED
@@ -1,3 +1 @@
1
- export async function sleep(ms: number) {
2
- return new Promise(resolve => setTimeout(resolve, ms))
3
- }
1
+ export const sleep = async (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
@@ -1,6 +1,7 @@
1
1
  import { Signal } from "#structure/Signal";
2
2
  import { $Node } from "#node/$Node";
3
- import { _Array_from, _document, _instanceof, _Object_assign, _Object_entries, _Object_fromEntries, isFunction, isString, isUndefined } from "#lib/native";
3
+ import { _Array_from, _instanceof, _Object_assign, _Object_entries, _Object_fromEntries, isNull, isString, isUndefined } from "#lib/native";
4
+ import { _document } from "#lib/env";
4
5
 
5
6
  export class $Element<Ele extends Element = Element, EvMap = ElementEventMap> extends $Node {
6
7
  declare node: Ele
@@ -12,12 +13,12 @@ export class $Element<Ele extends Element = Element, EvMap = ElementEventMap> ex
12
13
 
13
14
  attr(): {[key: string]: string};
14
15
  attr(key: string): string | null;
15
- attr(obj: {[key: string]: string | number | boolean | Signal<any>}): this;
16
- attr(resolver?: {[key: string]: string | number | boolean | Signal<any>} | string) {
16
+ attr(obj: {[key: string]: string | number | boolean | Signal<any> | null}): this;
17
+ attr(resolver?: {[key: string]: string | number | boolean | Signal<any> | null} | string) {
17
18
  if (!arguments.length) return _Object_fromEntries(_Array_from(this.attributes).map(attr => [attr.name, attr.value]));
18
19
  if (isString(resolver)) return this.getAttribute(resolver);
19
20
  if (resolver) for (let [key, value] of _Object_entries(resolver)) {
20
- const set = (value: any) => !isUndefined(value) && this.setAttribute(key, `${value}`)
21
+ const set = (value: any) => !isUndefined(value) && isNull(value) ? this.removeAttribute(key) : this.setAttribute(key, `${value}`)
21
22
  if (_instanceof(value, Signal)) value = value.subscribe(set).value();
22
23
  set(value);
23
24
  }
@@ -25,8 +26,7 @@ export class $Element<Ele extends Element = Element, EvMap = ElementEventMap> ex
25
26
  }
26
27
 
27
28
  class(...token: (string | null | undefined)[]) {
28
- this.classList(token.filter(isString).join(' '));
29
- return this;
29
+ return this.classList(token.filter(isString).join(' '));
30
30
  }
31
31
 
32
32
  addClass(...token: (string | null | undefined)[]) {
@@ -39,28 +39,16 @@ export class $Element<Ele extends Element = Element, EvMap = ElementEventMap> ex
39
39
  return this;
40
40
  }
41
41
 
42
- use(callback: ($ele: this) => void) {
43
- callback(this);
44
- return this;
45
- }
46
-
47
42
  on<K extends keyof EvMap, Ev extends EvMap[K]>(type: K, listener: $EventListener<this, Ev> | $EventListenerObject<this, Ev>, options?: boolean | AddEventListenerOptions) {
48
- this.node.addEventListener(type as string, listener as any, options);
49
- return this;
43
+ return this.addEventListener(type as string, listener as any, options);
50
44
  }
51
45
 
52
46
  off<K extends keyof EvMap, Ev extends EvMap[K]>(type: K, listener: $EventListener<this, Ev> | $EventListenerObject<this, Ev>, options?: boolean | EventListenerOptions) {
53
- this.node.removeEventListener(type as string, listener as any, options);
54
- return this;
47
+ return this.removeEventListener(type as string, listener as any, options);
55
48
  }
56
49
 
57
50
  once<K extends keyof EvMap, Ev extends EvMap[K]>(type: K, listener: $EventListener<this, Ev> | $EventListenerObject<this, Ev>, options?: boolean | AddEventListenerOptions) {
58
- const handler = (event: $Event<any>) => {
59
- this.off(type, handler, options);
60
- isFunction(listener) ? listener(event) : listener.handleEvent(event);
61
- }
62
- this.on(type, handler, options);
63
- return this;
51
+ return this.on(type, listener, {once: true})
64
52
  }
65
53
 
66
54
  toString() {
@@ -68,14 +56,15 @@ export class $Element<Ele extends Element = Element, EvMap = ElementEventMap> ex
68
56
  }
69
57
  }
70
58
 
71
- export type EventMap = {[key: string]: Event}
72
- export type $Event<E extends $Element, Ev = any> = Ev & {target: {$: E}};
59
+ export type $Event<E extends $Element, Ev = any> = Ev & {currentTarget: {$: E}};
73
60
  export type $EventListener<E extends $Element, Ev> = (event: $Event<E, Ev>) => void;
74
61
  export type $EventListenerObject<E extends $Element, Ev> = { handleEvent(object: $Event<E, Ev>): void; }
75
62
 
76
63
  function createNode(nodeName: string) {
64
+ return !_document
77
65
  //@ts-expect-error
78
- return !_document ? new Node(nodeName) as unknown as Node & ChildNode : _document.createElement(nodeName);
66
+ ? new Node(nodeName) as unknown as Node & ChildNode
67
+ : _document.createElement(nodeName);
79
68
  }
80
69
 
81
70
  export interface $Element<Ele extends Element, EvMap> {
@@ -107,6 +96,20 @@ export interface $Element<Ele extends Element, EvMap> {
107
96
  readonly shadowRoot: ShadowRoot | null;
108
97
  /** {@link Element.tagName} */
109
98
  readonly tagName: string;
99
+ /** {@link Element.nextElementSibling} */
100
+ readonly nextElementSibling: Element | null;
101
+ /** {@link Element.previousElementSibling} */
102
+ readonly previousElementSibling: Element | null;
103
+ /** {@link Element.childElementCount} */
104
+ readonly childElementCount: number;
105
+ /** {@link Element.children} */
106
+ readonly children: HTMLCollection;
107
+ /** {@link Element.firstElementChild} */
108
+ readonly firstElementChild: Element | null;
109
+ /** {@link Element.lastElementChild} */
110
+ readonly lastElementChild: Element | null;
111
+ /** {@link Element.assignedSlot} */
112
+ readonly assignedSlot: HTMLSlotElement | null;
110
113
 
111
114
  /** {@link Element.attachShadow} */
112
115
  attachShadow(init: ShadowRootInit): ShadowRoot;
@@ -200,6 +203,24 @@ export interface $Element<Ele extends Element, EvMap> {
200
203
  setPointerCapture(pointerId: number): this;
201
204
  /** {@link Element.toggleAttribute} */
202
205
  toggleAttribute(qualifiedName: string, force?: boolean): boolean;
206
+ /** {@link Element.animate} */
207
+ animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions): Animation;
208
+ /** {@link Element.getAnimations} */
209
+ getAnimations(options?: GetAnimationsOptions): Animation[];
210
+ /** {@link Element.append} */
211
+ append(...nodes: (Node | string)[]): this;
212
+ /** {@link Element.prepend} */
213
+ prepend(...nodes: (Node | string)[]): this;
214
+ /** {@link Element.querySelector} */
215
+ querySelector<K extends keyof HTMLElementTagNameMap>(selectors: K): HTMLElementTagNameMap[K] | null;
216
+ querySelector<K extends keyof SVGElementTagNameMap>(selectors: K): SVGElementTagNameMap[K] | null;
217
+ querySelector<K extends keyof MathMLElementTagNameMap>(selectors: K): MathMLElementTagNameMap[K] | null;
218
+ /** {@link Element.querySelectorAll} */
219
+ querySelectorAll<K extends keyof HTMLElementTagNameMap>(selectors: K): NodeListOf<HTMLElementTagNameMap[K]>;
220
+ querySelectorAll<K extends keyof SVGElementTagNameMap>(selectors: K): NodeListOf<SVGElementTagNameMap[K]>;
221
+ querySelectorAll<K extends keyof MathMLElementTagNameMap>(selectors: K): NodeListOf<MathMLElementTagNameMap[K]>;
222
+ /** {@link Element.replaceChildren} */
223
+ replaceChildren(...nodes: (Node | string)[]): this;
203
224
 
204
225
  /** {@link Element.classList} */
205
226
  classList(): DOMTokenList;
@@ -228,6 +249,144 @@ export interface $Element<Ele extends Element, EvMap> {
228
249
  /** {@link Element.slot} */
229
250
  slot(): string;
230
251
  slot(slot: $Parameter<string>): this;
252
+
253
+ // ARIAMixin
254
+ /** {@link ARIAMixin.ariaAtomic} */
255
+ ariaAtomic(): string | null;
256
+ ariaAtomic(ariaAtomic: $Parameter<string | null>): this;
257
+ /** {@link ARIAMixin.ariaAutoComplete} */
258
+ ariaAutoComplete(): string | null;
259
+ ariaAutoComplete(ariaAutoComplete: $Parameter<string | null>): this;
260
+ /** {@link ARIAMixin.ariaBrailleLabel} */
261
+ ariaBrailleLabel(): string | null;
262
+ ariaBrailleLabel(ariaBrailleLabel: $Parameter<string | null>): this;
263
+ /** {@link ARIAMixin.ariaBrailleRoleDescription} */
264
+ ariaBrailleRoleDescription(): string | null;
265
+ ariaBrailleRoleDescription(ariaBrailleRoleDescription: $Parameter<string | null>): this;
266
+ /** {@link ARIAMixin.ariaBusy} */
267
+ ariaBusy(): string | null;
268
+ ariaBusy(ariaBusy: $Parameter<string | null>): this;
269
+ /** {@link ARIAMixin.ariaChecked} */
270
+ ariaChecked(): string | null;
271
+ ariaChecked(ariaChecked: $Parameter<string | null>): this;
272
+ /** {@link ARIAMixin.ariaColCount} */
273
+ ariaColCount(): string | null;
274
+ ariaColCount(ariaColCount: $Parameter<string | null>): this;
275
+ /** {@link ARIAMixin.ariaColIndex} */
276
+ ariaColIndex(): string | null;
277
+ ariaColIndex(ariaColIndex: $Parameter<string | null>): this;
278
+ /** {@link ARIAMixin.ariaColIndexText} */
279
+ ariaColIndexText(): string | null;
280
+ ariaColIndexText(ariaColIndexText: $Parameter<string | null>): this;
281
+ /** {@link ARIAMixin.ariaColSpan} */
282
+ ariaColSpan(): string | null;
283
+ ariaColSpan(ariaColSpan: $Parameter<string | null>): this;
284
+ /** {@link ARIAMixin.ariaCurrent} */
285
+ ariaCurrent(): string | null;
286
+ ariaCurrent(ariaCurrent: $Parameter<string | null>): this;
287
+ /** {@link ARIAMixin.ariaDescription} */
288
+ ariaDescription(): string | null;
289
+ ariaDescription(ariaDescription: $Parameter<string | null>): this;
290
+ /** {@link ARIAMixin.ariaDisabled} */
291
+ ariaDisabled(): string | null;
292
+ ariaDisabled(ariaDisabled: $Parameter<string | null>): this;
293
+ /** {@link ARIAMixin.ariaExpanded} */
294
+ ariaExpanded(): string | null;
295
+ ariaExpanded(ariaExpanded: $Parameter<string | null>): this;
296
+ /** {@link ARIAMixin.ariaHasPopup} */
297
+ ariaHasPopup(): string | null;
298
+ ariaHasPopup(ariaHasPopup: $Parameter<string | null>): this;
299
+ /** {@link ARIAMixin.ariaHidden} */
300
+ ariaHidden(): string | null;
301
+ ariaHidden(ariaHidden: $Parameter<string | null>): this;
302
+ /** {@link ARIAMixin.ariaInvalid} */
303
+ ariaInvalid(): string | null;
304
+ ariaInvalid(ariaInvalid: $Parameter<string | null>): this;
305
+ /** {@link ARIAMixin.ariaKeyShortcuts} */
306
+ ariaKeyShortcuts(): string | null;
307
+ ariaKeyShortcuts(ariaKeyShortcuts: $Parameter<string | null>): this;
308
+ /** {@link ARIAMixin.ariaLabel} */
309
+ ariaLabel(): string | null;
310
+ ariaLabel(ariaLabel: $Parameter<string | null>): this;
311
+ /** {@link ARIAMixin.ariaLevel} */
312
+ ariaLevel(): string | null;
313
+ ariaLevel(ariaLevel: $Parameter<string | null>): this;
314
+ /** {@link ARIAMixin.ariaLive} */
315
+ ariaLive(): string | null;
316
+ ariaLive(ariaLive: $Parameter<string | null>): this;
317
+ /** {@link ARIAMixin.ariaModal} */
318
+ ariaModal(): string | null;
319
+ ariaModal(ariaModal: $Parameter<string | null>): this;
320
+ /** {@link ARIAMixin.ariaMultiLine} */
321
+ ariaMultiLine(): string | null;
322
+ ariaMultiLine(ariaMultiLine: $Parameter<string | null>): this;
323
+ /** {@link ARIAMixin.ariaMultiSelectable} */
324
+ ariaMultiSelectable(): string | null;
325
+ ariaMultiSelectable(ariaMultiSelectable: $Parameter<string | null>): this;
326
+ /** {@link ARIAMixin.ariaOrientation} */
327
+ ariaOrientation(): string | null;
328
+ ariaOrientation(ariaOrientation: $Parameter<string | null>): this;
329
+ /** {@link ARIAMixin.ariaPlaceholder} */
330
+ ariaPlaceholder(): string | null;
331
+ ariaPlaceholder(ariaPlaceholder: $Parameter<string | null>): this;
332
+ /** {@link ARIAMixin.ariaPosInSet} */
333
+ ariaPosInSet(): string | null;
334
+ ariaPosInSet(ariaPosInSet: $Parameter<string | null>): this;
335
+ /** {@link ARIAMixin.ariaPressed} */
336
+ ariaPressed(): string | null;
337
+ ariaPressed(ariaPressed: $Parameter<string | null>): this;
338
+ /** {@link ARIAMixin.ariaReadOnly} */
339
+ ariaReadOnly(): string | null;
340
+ ariaReadOnly(ariaReadOnly: $Parameter<string | null>): this;
341
+ /** {@link ARIAMixin.ariaRelevant} */
342
+ ariaRelevant(): string | null;
343
+ ariaRelevant(ariaRelevant: $Parameter<string | null>): this;
344
+ /** {@link ARIAMixin.ariaRequired} */
345
+ ariaRequired(): string | null;
346
+ ariaRequired(ariaRequired: $Parameter<string | null>): this;
347
+ /** {@link ARIAMixin.ariaRoleDescription} */
348
+ ariaRoleDescription(): string | null;
349
+ ariaRoleDescription(ariaRoleDescription: $Parameter<string | null>): this;
350
+ /** {@link ARIAMixin.ariaRowCount} */
351
+ ariaRowCount(): string | null;
352
+ ariaRowCount(ariaRowCount: $Parameter<string | null>): this;
353
+ /** {@link ARIAMixin.ariaRowIndex} */
354
+ ariaRowIndex(): string | null;
355
+ ariaRowIndex(ariaRowIndex: $Parameter<string | null>): this;
356
+ /** {@link ARIAMixin.ariaRowIndexText} */
357
+ ariaRowIndexText(): string | null;
358
+ ariaRowIndexText(ariaRowIndexText: $Parameter<string | null>): this;
359
+ /** {@link ARIAMixin.ariaRowSpan} */
360
+ ariaRowSpan(): string | null;
361
+ ariaRowSpan(ariaRowSpan: $Parameter<string | null>): this;
362
+ /** {@link ARIAMixin.ariaSelected} */
363
+ ariaSelected(): string | null;
364
+ ariaSelected(ariaSelected: $Parameter<string | null>): this;
365
+ /** {@link ARIAMixin.ariaSetSize} */
366
+ ariaSetSize(): string | null;
367
+ ariaSetSize(ariaSetSize: $Parameter<string | null>): this;
368
+ /** {@link ARIAMixin.ariaSort} */
369
+ ariaSort(): string | null;
370
+ ariaSort(ariaSort: $Parameter<string | null>): this;
371
+ /** {@link ARIAMixin.ariaValueMax} */
372
+ ariaValueMax(): string | null;
373
+ ariaValueMax(ariaValueMax: $Parameter<string | null>): this;
374
+ /** {@link ARIAMixin.ariaValueMin} */
375
+ ariaValueMin(): string | null;
376
+ ariaValueMin(ariaValueMin: $Parameter<string | null>): this;
377
+ /** {@link ARIAMixin.ariaValueNow} */
378
+ ariaValueNow(): string | null;
379
+ ariaValueNow(ariaValueNow: $Parameter<string | null>): this;
380
+ /** {@link ARIAMixin.ariaValueText} */
381
+ ariaValueText(): string | null;
382
+ ariaValueText(ariaValueText: $Parameter<string | null>): this;
383
+ /** {@link ARIAMixin.role} */
384
+ role(): string | null;
385
+ role(role: $Parameter<string | null>): this;
386
+ addEventListener<K extends keyof EvMap, Ev extends EvMap[K]>(type: K, listener: $EventListener<this, Ev> | $EventListenerObject<this, Ev>, options?: boolean | AddEventListenerOptions): this;
387
+ addEventListener(type: string, listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | AddEventListenerOptions): this;
388
+ removeEventListener<K extends keyof EvMap, Ev extends EvMap[K]>(type: K, listener: $EventListener<this, Ev> | $EventListenerObject<this, Ev>, options?: boolean | EventListenerOptions): this;
389
+ removeEventListener(type: string, listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | EventListenerOptions): this;
231
390
 
232
391
 
233
392
  on(type: string, listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | AddEventListenerOptions): this;
@@ -1,11 +1,23 @@
1
+ import { _Object_entries, forEach } from "#lib/native";
1
2
  import { $Element } from "#node/$Element";
2
3
 
3
4
  export class $HTMLElement<Ele extends HTMLElement = HTMLElement, EvMap = HTMLElementEventMap> extends $Element<Ele, EvMap> {
4
5
  constructor(resolver: string | Ele) {
5
6
  super(resolver);
6
7
  }
8
+
9
+ style(): CSSStyleDeclaration;
10
+ style(style: Partial<CSSStyleDeclarationOptions> | undefined): this
11
+ style(style?: Partial<CSSStyleDeclarationOptions> | undefined) {
12
+ let _style = this.node.style
13
+ if (!arguments.length) return _style
14
+ if (style) forEach(_Object_entries(style), ([key, value]) => _style[key as any] = value ?? '');
15
+ return this;
16
+ }
7
17
  }
8
18
 
19
+ type CSSStyleDeclarationOptions = Omit<CSSStyleDeclaration, 'parentRule' | 'length' | 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty'>;
20
+
9
21
  export interface $HTMLElement<Ele extends HTMLElement = HTMLElement, EvMap = HTMLElementEventMap> extends $Element<Ele, EvMap> {
10
22
  /** {@link HTMLElement.accessKeyLabel} */
11
23
  readonly accessKeyLabel: string;
@@ -19,6 +31,8 @@ export interface $HTMLElement<Ele extends HTMLElement = HTMLElement, EvMap = HTM
19
31
  readonly offsetTop: number;
20
32
  /** {@link HTMLElement.offsetWidth} */
21
33
  readonly offsetWidth: number;
34
+ /** {@link HTMLElement.isContentEditable} */
35
+ readonly isContentEditable: boolean;
22
36
 
23
37
  /** {@link HTMLElement.attachInternals} */
24
38
  attachInternals(): ElementInternals;
@@ -73,4 +87,13 @@ export interface $HTMLElement<Ele extends HTMLElement = HTMLElement, EvMap = HTM
73
87
  /** {@link HTMLElement.writingSuggestions} */
74
88
  writingSuggestions(): string;
75
89
  writingSuggestions(writingSuggestions: $Parameter<string>): this;
90
+ /** {@link HTMLElement.contentEditable} */
91
+ contentEditable(): string;
92
+ contentEditable(contentEditable: $Parameter<string>): this;
93
+ /** {@link HTMLElement.enterKeyHint} */
94
+ enterKeyHint(): string;
95
+ enterKeyHint(enterKeyHint: $Parameter<string>): this;
96
+ /** {@link HTMLElement.inputMode} */
97
+ inputMode(): string;
98
+ inputMode(inputMode: $Parameter<string>): this;
76
99
  }