@neptune3d/dom 0.0.4 → 0.0.6

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/dist/index.d.ts CHANGED
@@ -1,22 +1,74 @@
1
1
  import { PropertiesFallback, Property, Property as CssProperty } from "csstype";
2
2
 
3
- //#region src/MediaRule.d.ts
4
- declare class MediaRule {
5
- constructor(index: number, rule: CSSMediaRule);
6
- protected _index: number;
7
- protected _rule: CSSMediaRule;
8
- protected cssMap: Map<string, number>;
9
- get index(): number;
10
- get rule(): CSSMediaRule;
11
- get length(): number;
12
- getCssRule(selector: string): CSSStyleRule;
13
- delete(index: number): void;
3
+ //#region src/InputCheckbox.d.ts
4
+ declare class InputCheckbox extends DomElement<"input"> {
5
+ constructor();
6
+ name(value: string): this;
7
+ checked(value: boolean): this;
8
+ isChecked(): boolean;
9
+ }
10
+ //#endregion
11
+ //#region src/InputColor.d.ts
12
+ declare class InputColor extends DomElement<"input"> {
13
+ constructor();
14
+ protected _rgb: {
15
+ r: number;
16
+ g: number;
17
+ b: number;
18
+ };
19
+ name(value: string): this;
20
+ value(value: string): this;
21
+ getValue(): string;
22
+ getRGB(): {
23
+ r: number;
24
+ g: number;
25
+ b: number;
26
+ };
27
+ getNormalizedRGB(): {
28
+ r: number;
29
+ g: number;
30
+ b: number;
31
+ };
32
+ }
33
+ //#endregion
34
+ //#region src/InputNumber.d.ts
35
+ declare class InputNumber extends DomElement<"input"> {
36
+ constructor();
37
+ name(value: string): this;
38
+ value(value: number): this;
39
+ getValue(): number;
40
+ min(value: number): this;
41
+ max(value: number): this;
42
+ step(value: number): this;
43
+ placeholder(value: string): this;
44
+ }
45
+ //#endregion
46
+ //#region src/InputRange.d.ts
47
+ declare class InputRange extends DomElement<"input"> {
48
+ constructor();
49
+ name(value: string): this;
50
+ value(value: number): this;
51
+ getValue(): number;
52
+ min(value: number): this;
53
+ max(value: number): this;
54
+ step(value: number): this;
55
+ }
56
+ //#endregion
57
+ //#region src/InputText.d.ts
58
+ declare class InputText extends DomElement<"input"> {
59
+ constructor();
60
+ name(value: string): this;
61
+ value(value: string): this;
62
+ getValue(): string;
63
+ placeholder(value: string): this;
14
64
  }
15
65
  //#endregion
16
66
  //#region src/types.d.ts
17
- type CssProperties = PropertiesFallback<string | number>;
67
+ type CssProperties = PropertiesFallback<string | number> & {
68
+ [key: `--${string}`]: string | number | undefined;
69
+ };
18
70
  type Autocomplete<T$1 extends string> = T$1 | (string & {});
19
- type DomElementChild = DomElement<any> | string | number;
71
+ type DomElementChild = DomElement<any> | Node | string | number;
20
72
  type DomElementTagNameMap = HTMLElementTagNameMap & SvgElementTagNameMap;
21
73
  type SvgElementTagNameMap = {
22
74
  svgA: SVGAElement;
@@ -84,445 +136,829 @@ type SvgElementTagNameMap = {
84
136
  view: SVGViewElement;
85
137
  };
86
138
  type DomElementEventMap = HTMLElementEventMap & SVGElementEventMap;
139
+ type InputElementMap = {
140
+ color: InputColor;
141
+ text: InputText;
142
+ number: InputNumber;
143
+ range: InputRange;
144
+ checkbox: InputCheckbox;
145
+ };
87
146
  //#endregion
88
- //#region src/StyleSheet.d.ts
89
- /**
90
- * Manages a dedicated `<style>` element and provides programmatic access to its CSS rules.
91
- * Supports dynamic insertion, retrieval, and deletion of both standard and media-specific rules,
92
- * with internal indexing for fast lookup and reuse.
93
- *
94
- * This class ensures a single shared stylesheet instance via `StyleSheet.getSheet()`,
95
- * and maintains selector-to-index and media-to-rule maps on the global `window` object.
96
- *
97
- * Designed for use with component-level styling systems or DOM abstractions that require
98
- * granular control over rule injection without relying on inline styles.
99
- */
100
- declare class StyleSheet {
101
- constructor(el: HTMLStyleElement);
102
- protected _dom: HTMLStyleElement;
103
- get dom(): HTMLStyleElement;
104
- get sheet(): CSSStyleSheet;
105
- get length(): number;
106
- /**
107
- * Inserts or updates a global CSS rule for a given selector.
108
- * @param selector - A global class selector (e.g., ".list-item").
109
- * @param props - The CSS properties to apply.
110
- */
111
- globalCss(selector: string, props: CssProperties): void;
112
- /**
113
- * Inserts or updates a global CSS rule inside a media query.
114
- * @param mediaText - The media query condition (e.g., "max-width: 600px").
115
- * @param selector - The global class selector.
116
- * @param props - The CSS properties to apply.
117
- */
118
- globalMediaCss(mediaText: string, selector: string, props: CssProperties): void;
119
- getCssRule(selector: string): CSSStyleRule;
120
- deleteCssRule(selector: string): void;
121
- getMediaRule(mediaText: string): MediaRule;
122
- deleteMediaRule(mediaText: string): void;
123
- static getSheet(): StyleSheet;
124
- setRuleCss(rule: CSSStyleRule, props: CssProperties): void;
125
- getStyleValue(name: Autocomplete<keyof CssProperties>, value: string | number): string;
126
- protected getCssMap(): Map<string, number>;
127
- protected getMediaMap(): Map<string, MediaRule>;
128
- static STYLE_ID: string;
129
- }
130
- //#endregion
131
- //#region src/DomElement.d.ts
132
- /**
133
- * A unified wrapper for HTML and SVG elements that provides a fluent, type-safe API
134
- * for DOM manipulation, styling, and event handling.
135
- *
136
- * Supports both `HTMLElementTagNameMap` and `SVGElementTagNameMap` via the generic `Tag`,
137
- * and automatically handles namespace creation for SVG elements.
138
- *
139
- * Provides ergonomic methods for setting styles, attributes, classes, and event listeners,
140
- * while abstracting away platform-specific quirks (e.g., `className` vs `setAttribute("class")`).
141
- *
142
- * @template Tag - The tag name of the element, inferred from `DomElementTagNameMap`.
143
- */
144
- declare class DomElement<Tag extends keyof DomElementTagNameMap = keyof DomElementTagNameMap> {
147
+ //#region src/BaseStyle.d.ts
148
+ declare abstract class BaseStyle {
149
+ protected abstract setStyleProp(name: Autocomplete<keyof CssProperties>, value: string | number | undefined): this;
145
150
  /**
146
- * Creates a new DomElement instance for the specified tag.
147
- * Automatically detects whether the tag is an SVG element and uses the appropriate namespace.
148
- * Optionally wraps an existing DOM element instead of creating a new one.
151
+ * Sets or clears the `padding` style of the element.
152
+ * Accepts any valid CSS padding shorthand (e.g., "10px", "1em 2em").
153
+ * Passing `undefined` removes the padding style.
149
154
  *
150
- * @param tag - The tag name of the element (e.g., "div", "circle", "svg").
151
- * @param el - An optional existing DOM element to wrap. If omitted, a new element is created.
152
- */
153
- constructor(tag: Tag, el?: DomElementTagNameMap[Tag]);
154
- protected _tag: Tag extends "svgA" ? {
155
- svgA: "a";
156
- }[Tag] : Tag;
157
- protected _isSvg: boolean;
158
- protected _dom: DomElementTagNameMap[Tag];
159
- protected _sheet: StyleSheet;
160
- protected _cssClassName: string | undefined;
161
- protected _userClassName: string | undefined;
162
- /**
163
- * Gets the tag name of the element (e.g., "div", "svg", "circle").
164
- */
165
- get tag(): Tag extends "svgA" ? {
166
- svgA: "a";
167
- }[Tag] : Tag;
168
- /**
169
- * Indicates whether the element is an SVG element.
170
- * Returns `true` for tags like "svg", "circle", "path", etc.
171
- */
172
- get isSvg(): boolean;
173
- /**
174
- * Gets the underlying DOM element instance.
175
- * This will be either an `HTMLElement` or `SVGElement` depending on the tag.
155
+ * @param value - The padding value to apply, or `undefined` to remove it.
156
+ * @return This instance for chaining.
176
157
  */
177
- get dom(): DomElementTagNameMap[Tag];
178
- get cssClassName(): string;
179
- getText(): string;
180
- text(txt: any): this;
181
- add(...nodes: DomElementChild[]): this;
158
+ p(value: Property.Padding | undefined): this;
182
159
  /**
183
- * Inserts one or more DomElements into a parent at the specified index.
184
- * Each node is inserted sequentially starting from the given index.
160
+ * Sets or clears the `padding-top` style of the element.
161
+ * Accepts any valid CSS value (e.g., "10px", "1em").
162
+ * Passing `undefined` removes the top padding.
185
163
  *
186
- * @param index - The zero-based index at which to start inserting.
187
- * @param nodes - One or more DomElements to insert.
188
- * @return This DomElement instance.
164
+ * @param value - The top padding value to apply, or `undefined` to remove it.
165
+ * @return This instance for chaining.
189
166
  */
190
- insertAtIndex(index: number, ...nodes: DomElementChild[]): this;
167
+ pt(value: Property.PaddingTop | undefined): this;
191
168
  /**
192
- * Replaces all existing child elements of this DOM node with the provided ones.
193
- * Internally clears the current children and appends the new nodes in order.
169
+ * Sets or clears the `padding-right` style of the element.
170
+ * Accepts any valid CSS value (e.g., "10px", "1em").
171
+ * Passing `undefined` removes the right padding.
194
172
  *
195
- * @param nodes - One or more DomElement instances to set as children.
196
- * @return This DomElement instance.
173
+ * @param value - The right padding value to apply, or `undefined` to remove it.
174
+ * @return This instance for chaining.
197
175
  */
198
- setChildren(...nodes: DomElementChild[]): this;
176
+ pr(value: Property.PaddingRight | undefined): this;
199
177
  /**
200
- * Replaces child elements starting from the specified index with the provided nodes.
201
- * All children before the index are preserved.
178
+ * Sets or clears the `padding-bottom` style of the element.
179
+ * Accepts any valid CSS value (e.g., "10px", "1em").
180
+ * Passing `undefined` removes the bottom padding.
202
181
  *
203
- * @param index - The zero-based index at which replacement begins.
204
- * @param nodes - One or more DomElement instances to insert.
205
- * @return This DomElement instance.
182
+ * @param value - The bottom padding value to apply, or `undefined` to remove it.
183
+ * @return This instance for chaining.
206
184
  */
207
- setChildrenFromIndex(index: number, ...nodes: DomElementChild[]): this;
208
- remove(): void;
185
+ pb(value: Property.PaddingBottom | undefined): this;
209
186
  /**
210
- * Removes child elements within the specified index range.
211
- * If no range is provided, removes all children.
187
+ * Sets or clears the `padding-left` style of the element.
188
+ * Accepts any valid CSS value (e.g., "10px", "1em").
189
+ * Passing `undefined` removes the left padding.
212
190
  *
213
- * @param from - The starting index (inclusive). Defaults to 0.
214
- * @param to - The ending index (exclusive). Defaults to all children.
215
- * @returns This DomElement instance.
216
- */
217
- clear(from?: number, to?: number): this;
218
- /**
219
- * Adds an event listener to the element.
220
- * Supports both HTML and SVG elements.
221
- * @param type - The event type (e.g., "click", "input", "mouseenter").
222
- * @param handler - The event handler function.
223
- * @param options - Optional event listener options.
224
- * @return This DomElement instance for chaining.
225
- */
226
- on<T extends keyof DomElementEventMap>(type: T, handler: (ev: DomElementEventMap[T] & {
227
- currentTarget: DomElementTagNameMap[Tag];
228
- }) => void, options?: boolean | AddEventListenerOptions): this;
229
- /**
230
- * Removes an event listener from the element.
231
- * Supports both HTML and SVG elements.
232
- * @param type - The event type to remove.
233
- * @param handler - The original handler function.
234
- * @param options - Optional event listener options.
235
- */
236
- off<T extends keyof DomElementEventMap>(type: T, handler: (ev: DomElementEventMap[T]) => void, options?: boolean | EventListenerOptions): void;
237
- /**
238
- * Retrieves the value of a single attribute.
239
- * @param name - The attribute name to read (e.g. "aria-label", "role").
240
- * @return The attribute value as a string, or null if not present.
241
- */
242
- getAttr(name: string): string | null;
243
- /**
244
- * Sets a single attribute on the element.
245
- * @param name - The attribute name (e.g. "aria-label", "role", "disabled").
246
- * @param value - The attribute value. If undefined, the attribute is removed.
247
- * @return This DomElement instance for chaining.
248
- */
249
- attr(name: string, value: string | number | boolean | undefined): this;
250
- /**
251
- * Sets multiple attributes on the element.
252
- * @param attributes - An object mapping attribute names to values.
253
- * Attributes with undefined values are removed.
254
- * @return This DomElement instance for chaining.
191
+ * @param value - The left padding value to apply, or `undefined` to remove it.
192
+ * @return This instance for chaining.
255
193
  */
256
- attrs(attributes: Record<string, string | number | boolean | undefined>): this;
194
+ pl(value: Property.PaddingLeft | undefined): this;
257
195
  /**
258
- * Retrieves the value of a single property.
259
- * @param name - The property name to read (e.g. "value", "checked", "disabled").
260
- * @return The property value, or undefined if not present.
196
+ * Sets or clears horizontal padding (`padding-left` and `padding-right`) simultaneously.
197
+ * Accepts any valid CSS value (e.g., "10px", "1em").
198
+ * Passing `undefined` removes both left and right padding.
199
+ *
200
+ * @param value - The horizontal padding value to apply, or `undefined` to remove it.
201
+ * @return This instance for chaining.
261
202
  */
262
- getProp(name: string): any;
203
+ px(value: Property.PaddingLeft | undefined): this;
263
204
  /**
264
- * Sets a single property on the element.
265
- * @param name - The property name (e.g. "checked", "value", "disabled").
266
- * @param value - The property value. If undefined, the property is deleted.
267
- * @return This DomElement instance for chaining.
205
+ * Sets or clears vertical padding (`padding-top` and `padding-bottom`) simultaneously.
206
+ * Accepts any valid CSS value (e.g., "10px", "1em").
207
+ * Passing `undefined` removes both top and bottom padding.
208
+ *
209
+ * @param value - The vertical padding value to apply, or `undefined` to remove it.
210
+ * @return This instance for chaining.
268
211
  */
269
- prop(name: string, value: any): this;
212
+ py(value: Property.PaddingTop | undefined): this;
270
213
  /**
271
- * Sets multiple properties on the element.
272
- * @param properties - An object mapping property names to values.
273
- * Properties with undefined values are deleted.
274
- * @return This DomElement instance for chaining.
214
+ * Sets or clears the `margin` style of the element.
215
+ * Accepts any valid CSS margin shorthand (e.g., "10px", "1em 2em").
216
+ * Passing `undefined` removes the margin style.
217
+ *
218
+ * @param value - The margin value to apply, or `undefined` to remove it.
219
+ * @return This instance for chaining.
275
220
  */
276
- props(properties: Record<string, any>): this;
277
- style(obj: CssProperties): this;
278
- id(value: string): this;
221
+ m(value: Property.Margin | undefined): this;
279
222
  /**
280
- * Sets the user-defined class name and applies it alongside the internal CSS class.
281
- * For SVG elements, uses `setAttribute("class", ...)`.
282
- * @param value - The user-defined class name.
283
- * @return This DomElement instance for chaining.
223
+ * Sets or clears the `margin-top` style of the element.
224
+ * Accepts any valid CSS value (e.g., "10px", "auto").
225
+ * Passing `undefined` removes the top margin.
226
+ *
227
+ * @param value - The top margin value to apply, or `undefined` to remove it.
228
+ * @return This instance for chaining.
284
229
  */
285
- className(value: string): this;
286
- htmlFor(value: string): this;
230
+ mt(value: Property.MarginTop | undefined): this;
287
231
  /**
288
- * Sets the title of the element.
289
- * For HTML elements, sets the `title` property.
290
- * For SVG elements, sets the `title` attribute.
291
- * @param value - The tooltip text to show on hover.
292
- * @return This DomElement instance for chaining.
232
+ * Sets or clears the `margin-right` style of the element.
233
+ * Accepts any valid CSS value (e.g., "10px", "auto").
234
+ * Passing `undefined` removes the right margin.
235
+ *
236
+ * @param value - The right margin value to apply, or `undefined` to remove it.
237
+ * @return This instance for chaining.
293
238
  */
294
- title(value: string): this;
239
+ mr(value: Property.MarginRight | undefined): this;
295
240
  /**
296
- * Sets the `disabled` attribute to disable the element.
297
- * Applicable to form controls like <button>, <input>, <select>, etc.
298
- * @return This DomElement instance for chaining.
241
+ * Sets or clears the `margin-bottom` style of the element.
242
+ * Accepts any valid CSS value (e.g., "10px", "auto").
243
+ * Passing `undefined` removes the bottom margin.
244
+ *
245
+ * @param value - The bottom margin value to apply, or `undefined` to remove it.
246
+ * @return This instance for chaining.
299
247
  */
300
- disable(): this;
248
+ mb(value: Property.MarginBottom | undefined): this;
301
249
  /**
302
- * Removes the `disabled` attribute to enable the element.
303
- * @return This DomElement instance for chaining.
250
+ * Sets or clears the `margin-left` style of the element.
251
+ * Accepts any valid CSS value (e.g., "10px", "auto").
252
+ * Passing `undefined` removes the left margin.
253
+ *
254
+ * @param value - The left margin value to apply, or `undefined` to remove it.
255
+ * @return This instance for chaining.
304
256
  */
305
- enable(): this;
306
- p(value: Property.Padding | undefined): this;
307
- pt(value: Property.PaddingTop | undefined): this;
308
- pr(value: Property.PaddingRight | undefined): this;
309
- pb(value: Property.PaddingBottom | undefined): this;
310
- pl(value: Property.PaddingLeft | undefined): this;
311
- px(value: Property.PaddingLeft | undefined): this;
312
- py(value: Property.PaddingTop | undefined): this;
313
- m(value: Property.Margin | undefined): this;
314
- mt(value: Property.MarginTop | undefined): this;
315
- mr(value: Property.MarginRight | undefined): this;
316
- mb(value: Property.MarginBottom | undefined): this;
317
257
  ml(value: Property.MarginLeft | undefined): this;
318
258
  /**
319
259
  * Sets the overall border radius.
320
260
  * @param value - The CSS border-radius value (e.g., "8px", "50%").
321
- * @return This DomElement instance for chaining.
261
+ * @return This instance for chaining.
322
262
  */
323
263
  radius(value: Property.BorderRadius | undefined): this;
324
264
  /**
325
265
  * Sets the top-left corner border radius.
326
266
  * @param value - The CSS border-top-left-radius value.
327
- * @return This DomElement instance for chaining.
267
+ * @return This instance for chaining.
328
268
  */
329
269
  radiusTopLeft(value: Property.BorderTopLeftRadius | undefined): this;
330
270
  /**
331
271
  * Sets the top-right corner border radius.
332
272
  * @param value - The CSS border-top-right-radius value.
333
- * @return This DomElement instance for chaining.
273
+ * @return This instance for chaining.
334
274
  */
335
275
  radiusTopRight(value: Property.BorderTopRightRadius | undefined): this;
336
276
  /**
337
277
  * Sets the bottom-left corner border radius.
338
278
  * @param value - The CSS border-bottom-left-radius value.
339
- * @return This DomElement instance for chaining.
279
+ * @return This instance for chaining.
340
280
  */
341
281
  radiusBottomLeft(value: Property.BorderBottomLeftRadius | undefined): this;
342
282
  /**
343
283
  * Sets the bottom-right corner border radius.
344
284
  * @param value - The CSS border-bottom-right-radius value.
345
- * @return This DomElement instance for chaining.
285
+ * @return This instance for chaining.
346
286
  */
347
287
  radiusBottomRight(value: Property.BorderBottomRightRadius | undefined): this;
348
288
  /**
349
289
  * Sets the border radius for both top corners.
350
290
  * @param value - The CSS border-radius value to apply to top-left and top-right corners.
351
- * @return This DomElement instance for chaining.
291
+ * @return This instance for chaining.
352
292
  */
353
293
  radiusTop(value: Property.BorderTopLeftRadius | undefined): this;
354
294
  /**
355
295
  * Sets the border radius for both bottom corners.
356
296
  * @param value - The CSS border-radius value to apply to bottom-left and bottom-right corners.
357
- * @return This DomElement instance for chaining.
297
+ * @return This instance for chaining.
358
298
  */
359
299
  radiusBottom(value: Property.BorderBottomLeftRadius | undefined): this;
360
300
  /**
361
301
  * Sets the border radius for both left corners.
362
302
  * @param value - The CSS border-radius value to apply to top-left and bottom-left corners.
363
- * @return This DomElement instance for chaining.
303
+ * @return This instance for chaining.
364
304
  */
365
305
  radiusLeft(value: Property.BorderTopLeftRadius | undefined): this;
366
306
  /**
367
307
  * Sets the border radius for both right corners.
368
308
  * @param value - The CSS border-radius value to apply to top-right and bottom-right corners.
369
- * @return This DomElement instance for chaining.
309
+ * @return This instance for chaining.
370
310
  */
371
311
  radiusRight(value: Property.BorderTopRightRadius | undefined): this;
372
312
  /**
373
313
  * Sets the border radius for both left and right sides (horizontal corners).
374
314
  * Applies to top-left, top-right, bottom-left, and bottom-right corners on the X axis.
375
315
  * @param value - The CSS border-radius value to apply horizontally.
376
- * @return This DomElement instance for chaining.
316
+ * @return This instance for chaining.
377
317
  */
378
318
  radiusX(value: Property.BorderRadius | undefined): this;
379
319
  /**
380
320
  * Sets the border radius for both top and bottom sides (vertical corners).
381
321
  * Applies to top-left, top-right, bottom-left, and bottom-right corners on the Y axis.
382
322
  * @param value - The CSS border-radius value to apply vertically.
383
- * @return This DomElement instance for chaining.
323
+ * @return This instance for chaining.
384
324
  */
385
325
  radiusY(value: Property.BorderRadius | undefined): this;
386
- display(value: Property.Display | undefined): this;
326
+ /**
327
+ * Sets the `display` style of the element.
328
+ * Common values include "block", "inline", "flex", "grid", or "none".
329
+ * Controls the element's layout behavior in the document flow.
330
+ *
331
+ * @param value - The CSS display value, or `undefined` to remove it.
332
+ * @return This instance for chaining.
333
+ */
334
+ display(value: Property.Display | undefined): this;
335
+ /**
336
+ * Sets the `flex-shrink` style of the element.
337
+ * Defines how much the element should shrink relative to its siblings in a flex container.
338
+ *
339
+ * @param value - A numeric shrink factor (e.g., 0, 1), or `undefined` to remove it.
340
+ * @return This instance for chaining.
341
+ */
387
342
  flexShrink(value: Property.FlexShrink | undefined): this;
343
+ /**
344
+ * Sets the `flex` shorthand style of the element.
345
+ * Combines `flex-grow`, `flex-shrink`, and `flex-basis` into a single declaration.
346
+ *
347
+ * @param value - A flex shorthand value (e.g., "1 0 auto"), or `undefined` to remove it.
348
+ * @return This instance for chaining.
349
+ */
388
350
  flex(value: Property.Flex | undefined): this;
351
+ /**
352
+ * Sets the `background-color` style of the element.
353
+ * Accepts named colors, hex codes, RGB/RGBA values, or CSS variables.
354
+ *
355
+ * @param value - The background color value (e.g., "#fff", "rgba(0,0,0,0.5)"), or `undefined` to remove it.
356
+ * @return This instance for chaining.
357
+ */
389
358
  bgColor(value: Property.BackgroundColor | undefined): this;
359
+ /**
360
+ * Sets the `color` style of the element.
361
+ * Defines the foreground text color using named colors, hex codes, RGB/RGBA values, or CSS variables.
362
+ *
363
+ * @param value - The text color value (e.g., "black", "#333"), or `undefined` to remove it.
364
+ * @return This instance for chaining.
365
+ */
390
366
  color(value: Property.Color | undefined): this;
391
- h(value: Property.Height | number | undefined): this;
367
+ /**
368
+ * Sets or clears the `width` style of the element.
369
+ * Accepts CSS width values (e.g., "100px", "50%") or numeric pixel values.
370
+ * Passing `undefined` removes the width style.
371
+ *
372
+ * @param value - The width value to apply, or `undefined` to remove it.
373
+ * @return This instance for chaining.
374
+ */
392
375
  w(value: Property.Width | number | undefined): this;
376
+ /**
377
+ * Sets or clears the `height` style of the element.
378
+ * Accepts CSS height values (e.g., "100px", "auto") or numeric pixel values.
379
+ * Passing `undefined` removes the height style.
380
+ *
381
+ * @param value - The height value to apply, or `undefined` to remove it.
382
+ * @return This instance for chaining.
383
+ */
384
+ h(value: Property.Height | number | undefined): this;
393
385
  /**
394
386
  * Sets the full border style.
395
387
  * @param value - The CSS border value (e.g., "1px solid #ccc").
396
- * @return This DomElement instance for chaining.
388
+ * @return This instance for chaining.
397
389
  */
398
390
  b(value: Property.Border | undefined): this;
399
391
  /**
400
392
  * Sets the top border style.
401
393
  * @param value - The CSS border-top value.
402
- * @return This DomElement instance for chaining.
394
+ * @return This instance for chaining.
403
395
  */
404
396
  bt(value: Property.BorderTop | undefined): this;
405
397
  /**
406
398
  * Sets the right border style.
407
399
  * @param value - The CSS border-right value.
408
- * @return This DomElement instance for chaining.
400
+ * @return This instance for chaining.
409
401
  */
410
402
  br(value: Property.BorderRight | undefined): this;
411
403
  /**
412
404
  * Sets the bottom border style.
413
405
  * @param value - The CSS border-bottom value.
414
- * @return This DomElement instance for chaining.
406
+ * @return This instance for chaining.
415
407
  */
416
408
  bb(value: Property.BorderBottom | undefined): this;
417
409
  /**
418
410
  * Sets the left border style.
419
411
  * @param value - The CSS border-left value.
420
- * @return This DomElement instance for chaining.
412
+ * @return This instance for chaining.
421
413
  */
422
414
  bl(value: Property.BorderLeft | undefined): this;
423
415
  /**
424
416
  * Sets the left and right border styles.
425
417
  * @param value - The CSS border value to apply to both left and right sides.
426
- * @return This DomElement instance for chaining.
418
+ * @return This instance for chaining.
427
419
  */
428
420
  bx(value: Property.BorderLeft | Property.BorderRight | undefined): this;
429
421
  /**
430
422
  * Sets the top and bottom border styles.
431
423
  * @param value - The CSS border value to apply to both top and bottom sides.
432
- * @return This DomElement instance for chaining.
424
+ * @return This instance for chaining.
433
425
  */
434
426
  by(value: Property.BorderTop | Property.BorderBottom | undefined): this;
435
427
  /**
436
428
  * Sets the top and left border styles.
437
429
  * @param value - The CSS border value to apply to both top and left sides.
438
- * @return This DomElement instance for chaining.
430
+ * @return This instance for chaining.
439
431
  */
440
432
  btl(value: Property.BorderTop | Property.BorderLeft | undefined): this;
441
433
  /**
442
434
  * Sets the top and right border styles.
443
435
  * @param value - The CSS border value to apply to both top and right sides.
444
- * @return This DomElement instance for chaining.
436
+ * @return This instance for chaining.
445
437
  */
446
438
  btr(value: Property.BorderTop | Property.BorderRight | undefined): this;
447
439
  /**
448
440
  * Sets the bottom and left border styles.
449
441
  * @param value - The CSS border value to apply to both bottom and left sides.
450
- * @return This DomElement instance for chaining.
442
+ * @return This instance for chaining.
451
443
  */
452
444
  bbl(value: Property.BorderBottom | Property.BorderLeft | undefined): this;
453
445
  /**
454
446
  * Sets the bottom and right border styles.
455
447
  * @param value - The CSS border value to apply to both bottom and right sides.
456
- * @return This DomElement instance for chaining.
448
+ * @return This instance for chaining.
457
449
  */
458
450
  bbr(value: Property.BorderBottom | Property.BorderRight | undefined): this;
451
+ /**
452
+ * Sets the `overflow` style of the element.
453
+ * Controls how content that exceeds the element's bounds is handled on both axes.
454
+ * Common values include "visible", "hidden", "scroll", and "auto".
455
+ *
456
+ * @param value - The overflow behavior for both axes, or `undefined` to remove it.
457
+ * @return This instance for chaining.
458
+ */
459
459
  overflow(value: Property.Overflow | undefined): this;
460
+ /**
461
+ * Sets the `overflow-y` style of the element.
462
+ * Controls vertical overflow behavior independently of horizontal overflow.
463
+ * Common values include "visible", "hidden", "scroll", and "auto".
464
+ *
465
+ * @param value - The vertical overflow behavior, or `undefined` to remove it.
466
+ * @return This instance for chaining.
467
+ */
460
468
  overflowY(value: Property.OverflowY | undefined): this;
469
+ /**
470
+ * Sets the `overflow-x` style of the element.
471
+ * Controls horizontal overflow behavior independently of vertical overflow.
472
+ * Common values include "visible", "hidden", "scroll", and "auto".
473
+ *
474
+ * @param value - The horizontal overflow behavior, or `undefined` to remove it.
475
+ * @return This instance for chaining.
476
+ */
461
477
  overflowX(value: Property.OverflowX | undefined): this;
478
+ /**
479
+ * Sets the `font-size` style of the element.
480
+ * Accepts absolute units (e.g., "16px", "1rem") or relative keywords (e.g., "small", "larger").
481
+ *
482
+ * @param value - The font size value, or `undefined` to remove it.
483
+ * @return This instance for chaining.
484
+ */
462
485
  fontSize(value: Property.FontSize | undefined): this;
486
+ /**
487
+ * Sets the `font-weight` style of the element.
488
+ * Accepts numeric weights (e.g., 400, 700) or keywords like "bold", "normal", "lighter".
489
+ *
490
+ * @param value - The font weight value, or `undefined` to remove it.
491
+ * @return This instance for chaining.
492
+ */
463
493
  fontWeight(value: Property.FontWeight | undefined): this;
494
+ /**
495
+ * Sets the `font-family` style of the element.
496
+ * Accepts a comma-separated list of font names or CSS variables.
497
+ *
498
+ * @param value - The font family string (e.g., "Arial, sans-serif"), or `undefined` to remove it.
499
+ * @return This instance for chaining.
500
+ */
464
501
  fontFamily(value: Property.FontFamily | undefined): this;
502
+ /**
503
+ * Sets the `font-style` style of the element.
504
+ * Common values include "normal", "italic", or "oblique".
505
+ *
506
+ * @param value - The font style value, or `undefined` to remove it.
507
+ * @return This instance for chaining.
508
+ */
465
509
  fontStyle(value: Property.FontStyle | undefined): this;
510
+ /**
511
+ * Sets the `text-align` style of the element.
512
+ * Controls horizontal alignment of inline content. Common values include "left", "right", "center", or "justify".
513
+ *
514
+ * @param value - The text alignment value, or `undefined` to remove it.
515
+ * @return This instance for chaining.
516
+ */
466
517
  textAlign(value: Property.TextAlign | undefined): this;
518
+ /**
519
+ * Sets the `text-decoration` style of the element.
520
+ * Common values include "underline", "line-through", "none", or combinations like "underline overline".
521
+ *
522
+ * @param value - The text decoration value, or `undefined` to remove it.
523
+ * @return This instance for chaining.
524
+ */
467
525
  textDecoration(value: Property.TextDecoration | undefined): this;
468
526
  /**
469
527
  * Sets the CSS `position` property.
470
528
  * @param value - The positioning mode (e.g., "absolute", "relative", "fixed").
471
- * @return This DomElement instance for chaining.
529
+ * @return This instance for chaining.
472
530
  */
473
531
  pos(value: Property.Position | undefined): this;
474
532
  /**
475
533
  * Sets the CSS `top` offset.
476
534
  * @param value - The top offset value (e.g., "10px", "50%").
477
- * @return This DomElement instance for chaining.
535
+ * @return This instance for chaining.
478
536
  */
479
- posTop(value: Property.Top | undefined): this;
537
+ posTop(value: Property.Top | number | undefined): this;
480
538
  /**
481
539
  * Sets the CSS `bottom` offset.
482
540
  * @param value - The bottom offset value (e.g., "0", "2rem").
483
- * @return This DomElement instance for chaining.
541
+ * @return This instance for chaining.
484
542
  */
485
- posBottom(value: Property.Bottom | undefined): this;
543
+ posBottom(value: Property.Bottom | number | undefined): this;
486
544
  /**
487
545
  * Sets the CSS `left` offset.
488
546
  * @param value - The left offset value (e.g., "5px", "auto").
489
- * @return This DomElement instance for chaining.
547
+ * @return This instance for chaining.
490
548
  */
491
- posLeft(value: Property.Left | undefined): this;
549
+ posLeft(value: Property.Left | number | undefined): this;
492
550
  /**
493
551
  * Sets the CSS `right` offset.
494
552
  * @param value - The right offset value (e.g., "1em", "0").
495
- * @return This DomElement instance for chaining.
553
+ * @return This instance for chaining.
554
+ */
555
+ posRight(value: Property.Right | number | undefined): this;
556
+ /**
557
+ * Sets the `cursor` style of the element.
558
+ * Controls the mouse cursor appearance when hovering over the element.
559
+ * Common values include "pointer", "default", "text", "move", or "not-allowed".
560
+ *
561
+ * @param value - The cursor style value, or `undefined` to remove it.
562
+ * @return This instance for chaining.
496
563
  */
497
- posRight(value: Property.Right | undefined): this;
498
564
  cursor(value: Property.Cursor | undefined): this;
565
+ /**
566
+ * Sets the `align-items` style of the element.
567
+ * Defines how flex or grid children are aligned along the cross axis.
568
+ * Common values include "flex-start", "center", "baseline", or "stretch".
569
+ *
570
+ * @param value - The alignment value for child items, or `undefined` to remove it.
571
+ * @return This instance for chaining.
572
+ */
499
573
  alignItems(value: Property.AlignItems | undefined): this;
574
+ /**
575
+ * Sets the `justify-content` style of the element.
576
+ * Defines how flex or grid children are distributed along the main axis.
577
+ * Common values include "flex-start", "center", "space-between", or "space-around".
578
+ *
579
+ * @param value - The justification value for child items, or `undefined` to remove it.
580
+ * @return This instance for chaining.
581
+ */
500
582
  justifyContent(value: Property.JustifyContent | undefined): this;
583
+ /**
584
+ * Sets the `gap` style of the element.
585
+ * Defines spacing between flex or grid children, supporting both row and column gaps.
586
+ * Accepts length units (e.g., "10px", "1rem") or shorthand values.
587
+ *
588
+ * @param value - The gap size between child elements, or `undefined` to remove it.
589
+ * @return This instance for chaining.
590
+ */
501
591
  gap(value: Property.Gap | undefined): this;
592
+ /**
593
+ * Sets the `flex-direction` style of the element.
594
+ * Controls the direction of child elements in a flex container.
595
+ * Common values include "row", "column", "row-reverse", or "column-reverse".
596
+ *
597
+ * @param value - The flex direction value, or `undefined` to remove it.
598
+ * @return This instance for chaining.
599
+ */
502
600
  flexDirection(value: Property.FlexDirection | undefined): this;
601
+ /**
602
+ * Sets the `grid-template-columns` style of the element.
603
+ * Defines the column structure of a CSS grid container using track sizes, repeat(), or auto-fit/auto-fill.
604
+ * For example: "1fr 2fr", "repeat(3, 100px)", or "auto-fit, minmax(200px, 1fr)".
605
+ *
606
+ * @param value - The grid column template string, or `undefined` to remove it.
607
+ * @return This instance for chaining.
608
+ */
503
609
  templateColumns(value: Property.GridTemplateColumns | undefined): this;
610
+ /**
611
+ * Sets the `grid-template-rows` style of the element.
612
+ * Defines the row structure of a CSS grid container using track sizes, repeat(), or auto-fit/auto-fill.
613
+ * For example: "100px auto", "repeat(2, 1fr)", or "minmax(50px, auto)".
614
+ *
615
+ * @param value - The grid row template string, or `undefined` to remove it.
616
+ * @return This instance for chaining.
617
+ */
504
618
  templateRows(value: Property.GridTemplateRows | undefined): this;
619
+ /**
620
+ * Sets the `appearance` style of the element.
621
+ * Controls native platform styling of UI elements like buttons and inputs.
622
+ * Common values include "none" to remove default styling, or platform-specific keywords.
623
+ *
624
+ * @param value - The appearance value (e.g., "none", "auto"), or `undefined` to remove it.
625
+ * @return This instance for chaining.
626
+ */
505
627
  appearance(value: Property.Appearance | undefined): this;
506
628
  /**
507
629
  * Sets the CSS `user-select` property to control text selection behavior.
508
630
  * @param value - The user-select value (e.g., "none", "text", "auto", "contain", "all").
509
- * @return This DomElement instance for chaining.
631
+ * @return This instance for chaining.
510
632
  */
511
633
  userSelect(value: Property.UserSelect | undefined): this;
634
+ /**
635
+ * Sets the vertical alignment of the element.
636
+ * Common values include "middle", "top", "bottom", "baseline", or pixel/em units.
637
+ *
638
+ * @param value - The CSS vertical-align value (e.g., "middle", "top", "10px").
639
+ * @return This instance for chaining.
640
+ */
641
+ verticalAlign(value: Property.VerticalAlign | undefined): this;
642
+ /**
643
+ * Sets the `white-space` style of the element.
644
+ * Common values include "normal", "nowrap", "pre", "pre-wrap", or "pre-line".
645
+ * Controls how whitespace and line breaks are handled within the element.
646
+ *
647
+ * @param value - The CSS white-space value (e.g., "nowrap", "pre-wrap"), or `undefined` to remove it.
648
+ * @return This instance for chaining.
649
+ */
650
+ whiteSpace(value: Property.WhiteSpace | undefined): this;
651
+ /**
652
+ * Sets the `text-overflow` style of the element.
653
+ * Common values include "ellipsis", "clip", or "string" for custom overflow indicators.
654
+ * Controls how overflowed inline content is rendered when it exceeds the container bounds.
655
+ *
656
+ * @param value - The CSS text-overflow value (e.g., "ellipsis", "clip"), or `undefined` to remove it.
657
+ * @return This instance for chaining.
658
+ */
659
+ textOverflow(value: Property.TextOverflow | undefined): this;
660
+ /**
661
+ * Sets the `z-index` style of the element.
662
+ * Controls the stacking order of positioned elements. Higher values appear in front of lower ones.
663
+ * Only applies to elements with a position other than `static`.
664
+ *
665
+ * @param value - The z-index value (e.g., 10, 1000), or `undefined` to remove it.
666
+ * @return This instance for chaining.
667
+ */
668
+ zIndex(value: Property.ZIndex | undefined): this;
669
+ /**
670
+ * Applies CSS styles to truncate overflowing text with an ellipsis.
671
+ * Ensures the text stays on a single line and hides overflow.
672
+ *
673
+ * Equivalent to:
674
+ * ```css
675
+ * overflow: hidden;
676
+ * white-space: nowrap;
677
+ * text-overflow: ellipsis;
678
+ * ```
679
+ *
680
+ * @return This instance for chaining.
681
+ */
512
682
  overflowEllipsis(): this;
683
+ /**
684
+ * Applies a batch of CSS style properties to the element.
685
+ * Delegates each property to `setStyleProp`, which handles value normalization and kebab-case conversion.
686
+ *
687
+ * - Properties with `undefined` values are removed from the inline style.
688
+ * - Numeric values are passed through the style sheet for unit resolution.
689
+ * - Supports chainable usage for fluent DOM composition.
690
+ *
691
+ * @param props - A partial map of CSS properties and their values.
692
+ * @returns This instance for chaining.
693
+ */
694
+ style(props: CssProperties): this;
695
+ }
696
+ //#endregion
697
+ //#region src/BaseDom.d.ts
698
+ /**
699
+ * Base class for DOM-backed elements with style and event utilities.
700
+ * Supports both HTML and SVG elements via generic parameter `E`.
701
+ */
702
+ declare abstract class BaseDom<E extends HTMLElement | SVGElement> extends BaseStyle {
703
+ abstract dom: E;
704
+ /**
705
+ * Sets or removes the user-defined class name and applies it alongside the internal CSS class.
706
+ * Uses `setAttribute("class", ...)` for both HTML and SVG elements.
707
+ *
708
+ * Passing `undefined` removes the user-defined class name entirely.
709
+ *
710
+ * @param value - The user-defined class name, or `undefined` to remove it.
711
+ * @return This DomElement instance for chaining.
712
+ */
713
+ className(value: string | undefined): this;
714
+ /**
715
+ * Adds an event listener to the element.
716
+ * @param type - The event type (e.g., "click", "input", "mouseenter").
717
+ * @param handler - The event handler function.
718
+ * @param options - Optional event listener options.
719
+ * @return This DomElement instance for chaining.
720
+ */
721
+ on<T extends keyof DomElementEventMap>(type: T, handler: (ev: DomElementEventMap[T] & {
722
+ currentTarget: E;
723
+ }) => void, options?: boolean | AddEventListenerOptions): this;
724
+ /**
725
+ * Removes an event listener from the element.
726
+ * @param type - The event type to remove.
727
+ * @param handler - The original handler function.
728
+ * @param options - Optional event listener options.
729
+ */
730
+ off<T extends keyof DomElementEventMap>(type: T, handler: (ev: DomElementEventMap[T]) => void, options?: boolean | EventListenerOptions): void;
731
+ /**
732
+ * Appends one or more child nodes to the element.
733
+ * Accepts DomElement instances, regular DOM Nodes, strings, or numbers.
734
+ *
735
+ * - Strings and numbers are coerced to text nodes.
736
+ * - DomElement instances are unwrapped to their native DOM nodes.
737
+ * - DOM Nodes are appended directly.
738
+ *
739
+ * @param nodes - One or more child elements or text values to append.
740
+ * @return This DomElement instance for chaining.
741
+ */
742
+ add(...nodes: DomElementChild[]): this;
743
+ /**
744
+ * Inserts one or more DomElements into a parent at the specified index.
745
+ * Each node is inserted sequentially starting from the given index.
746
+ *
747
+ * @param index - The zero-based index at which to start inserting.
748
+ * @param nodes - One or more DomElements to insert.
749
+ * @return This DomElement instance.
750
+ */
751
+ insertAtIndex(index: number, ...nodes: DomElementChild[]): this;
752
+ /**
753
+ * Replaces all existing child elements of this DOM node with the provided ones.
754
+ * Internally clears the current children and appends the new nodes in order.
755
+ *
756
+ * @param nodes - One or more DomElement instances to set as children.
757
+ * @return This DomElement instance.
758
+ */
759
+ setChildren(...nodes: DomElementChild[]): this;
760
+ /**
761
+ * Replaces child elements starting from the specified index with the provided nodes.
762
+ * All children before the index are preserved.
763
+ *
764
+ * @param index - The zero-based index at which replacement begins.
765
+ * @param nodes - One or more DomElement instances to insert.
766
+ * @return This DomElement instance.
767
+ */
768
+ setChildrenFromIndex(index: number, ...nodes: DomElementChild[]): this;
769
+ /**
770
+ * Removes child elements within the specified index range.
771
+ * If no range is provided, removes all children.
772
+ *
773
+ * @param from - The starting index (inclusive). Defaults to 0.
774
+ * @param to - The ending index (exclusive). Defaults to all children.
775
+ * @returns This DomElement instance.
776
+ */
777
+ clear(from?: number, to?: number): this;
513
778
  ref(refFn: (el: this) => void): this;
514
- rootCss(props: CssProperties): this;
515
- hoverCss(props: CssProperties): this;
516
- activeCss(props: CssProperties): this;
517
- focusCss(props: CssProperties): this;
518
- css(selector: string, props: CssProperties): this;
519
- mediaCss(mediaText: string, selector: string, props: CssProperties): this;
520
- mediaRootCss(mediaText: string, props: CssProperties): this;
521
- minWidthCss(minWidth: number | string, props: CssProperties): this;
522
- maxWidthCss(maxWidth: number | string, props: CssProperties): this;
523
- protected resolveNode(child: DomElementChild): any;
779
+ protected resolveNode(child: DomElementChild): Node;
524
780
  protected setStyleProp(name: Autocomplete<keyof CssProperties>, value: string | number | undefined): this;
525
- protected setCssClassName(): this;
781
+ }
782
+ //#endregion
783
+ //#region src/DomElement.d.ts
784
+ /**
785
+ * A unified wrapper for HTML and SVG elements that provides a fluent, type-safe API
786
+ * for DOM manipulation, styling, and event handling.
787
+ *
788
+ * Supports both `HTMLElementTagNameMap` and `SVGElementTagNameMap` via the generic `Tag`,
789
+ * and automatically handles namespace creation for SVG elements.
790
+ *
791
+ * Provides ergonomic methods for setting styles, attributes, classes, and event listeners,
792
+ * while abstracting away platform-specific quirks (e.g., `className` vs `setAttribute("class")`).
793
+ *
794
+ * @template Tag - The tag name of the element, inferred from `DomElementTagNameMap`.
795
+ */
796
+ declare class DomElement<Tag extends keyof DomElementTagNameMap = keyof DomElementTagNameMap> extends BaseDom<DomElementTagNameMap[Tag]> {
797
+ /**
798
+ * Creates a new DomElement instance for the specified tag.
799
+ * Automatically detects whether the tag is an SVG element and uses the appropriate namespace.
800
+ * Optionally wraps an existing DOM element instead of creating a new one.
801
+ *
802
+ * @param tag - The tag name of the element (e.g., "div", "circle", "svg").
803
+ * @param el - An optional existing DOM element to wrap. If omitted, a new element is created.
804
+ */
805
+ constructor(tag: Tag, el?: DomElementTagNameMap[Tag]);
806
+ protected _tag: Tag extends "svgA" ? {
807
+ svgA: "a";
808
+ }[Tag] : Tag;
809
+ protected _isSvg: boolean;
810
+ protected _dom: DomElementTagNameMap[Tag];
811
+ /**
812
+ * Gets the tag name of the element (e.g., "div", "svg", "circle").
813
+ */
814
+ get tag(): Tag extends "svgA" ? {
815
+ svgA: "a";
816
+ }[Tag] : Tag;
817
+ /**
818
+ * Indicates whether the element is an SVG element.
819
+ * Returns `true` for tags like "svg", "circle", "path", etc.
820
+ */
821
+ get isSvg(): boolean;
822
+ /**
823
+ * Gets the underlying DOM element instance.
824
+ * This will be either an `HTMLElement` or `SVGElement` depending on the tag.
825
+ */
826
+ get dom(): DomElementTagNameMap[Tag];
827
+ /**
828
+ * Gets the textContent property of the DOM element.
829
+ */
830
+ getText(): string;
831
+ /**
832
+ * Sets or clears the text content of the element.
833
+ * Converts any value to a string before assignment.
834
+ * Passing `undefined` or `null` removes the text by setting it to an empty string.
835
+ *
836
+ * @param value - The text content to set, or `undefined`/`null` to clear it.
837
+ * @return This DomElement instance for chaining.
838
+ */
839
+ text(value: any): this;
840
+ /**
841
+ * Removes the element from the DOM tree.
842
+ * Equivalent to calling `element.remove()` on the native DOM node.
843
+ *
844
+ * This does not dispose internal state or event listeners — use `dispose()` if cleanup is needed.
845
+ *
846
+ * @return This DomElement instance for chaining.
847
+ */
848
+ remove(): void;
849
+ /**
850
+ * Retrieves the value of a single attribute.
851
+ * @param name - The attribute name to read (e.g. "aria-label", "role").
852
+ * @return The attribute value as a string, or null if not present.
853
+ */
854
+ getAttr(name: string): string | null;
855
+ /**
856
+ * Sets a single attribute on the element.
857
+ * @param name - The attribute name (e.g. "aria-label", "role", "disabled").
858
+ * @param value - The attribute value. If undefined, the attribute is removed.
859
+ * @return This DomElement instance for chaining.
860
+ */
861
+ attr(name: string, value: string | number | boolean | undefined): this;
862
+ /**
863
+ * Sets multiple attributes on the element.
864
+ * @param attributes - An object mapping attribute names to values.
865
+ * Attributes with undefined values are removed.
866
+ * @return This DomElement instance for chaining.
867
+ */
868
+ attrs(attributes: Record<string, string | number | boolean | undefined>): this;
869
+ /**
870
+ * Retrieves the value of a single property.
871
+ * @param name - The property name to read (e.g. "value", "checked", "disabled").
872
+ * @return The property value, or undefined if not present.
873
+ */
874
+ getProp(name: string): any;
875
+ /**
876
+ * Sets a single property on the element.
877
+ * @param name - The property name (e.g. "checked", "value", "disabled").
878
+ * @param value - The property value. If undefined, the property is deleted.
879
+ * @return This DomElement instance for chaining.
880
+ */
881
+ prop(name: string, value: any): this;
882
+ /**
883
+ * Sets multiple properties on the element.
884
+ * @param props - An object mapping property names to values.
885
+ * Properties with undefined values are deleted.
886
+ * @return This DomElement instance for chaining.
887
+ */
888
+ props(props: Record<string, any>): this;
889
+ /**
890
+ * Sets or removes the `id` of the element.
891
+ * Passing `undefined` clears the ID by setting it to an empty string.
892
+ *
893
+ * @param value - The element's ID, or `undefined` to remove it.
894
+ * @return This DomElement instance for chaining.
895
+ */
896
+ id(value: string | undefined): this;
897
+ /**
898
+ * Sets or removes the `htmlFor` property on a <label> element.
899
+ * This links the label to a form control by its ID.
900
+ *
901
+ * Passing `undefined` removes the association.
902
+ * Has no effect if the element is not a <label>.
903
+ *
904
+ * @param value - The ID of the target form control, or `undefined` to remove it.
905
+ * @return This DomElement instance for chaining.
906
+ */
907
+ htmlFor(value: string | undefined): this;
908
+ /**
909
+ * Sets or removes the `title` attribute on the element.
910
+ * Applies to both HTML and SVG elements. Passing `undefined` removes the attribute.
911
+ *
912
+ * @param value - The tooltip text to show on hover, or `undefined` to remove it.
913
+ * @return This DomElement instance for chaining.
914
+ */
915
+ title(value: string | undefined): this;
916
+ /**
917
+ * Sets or removes the `disabled` attribute on the element.
918
+ * Applicable to form controls like <button>, <input>, <select>, etc.
919
+ *
920
+ * @param value - If true, sets the `disabled` attribute; if false, removes it.
921
+ * @return This DomElement instance for chaining.
922
+ */
923
+ disabled(value: boolean): this;
924
+ /**
925
+ * Sets the `disabled` attribute to disable the element.
926
+ * Applicable to form controls like <button>, <input>, <select>, etc.
927
+ * @return This DomElement instance for chaining.
928
+ */
929
+ disable(): this;
930
+ /**
931
+ * Removes the `disabled` attribute to enable the element.
932
+ * @return This DomElement instance for chaining.
933
+ */
934
+ enable(): this;
935
+ /**
936
+ * Sets or removes the `popover` attribute on the element.
937
+ * Applies to HTML elements that support the popover API (e.g., `<div popover>`).
938
+ * Passing `undefined` removes the attribute.
939
+ *
940
+ * Common values include:
941
+ * - `"auto"` → Automatically shows/hides based on user interaction.
942
+ * - `"manual"` → Requires explicit show/hide via JavaScript.
943
+ *
944
+ * @param value - The popover mode (`"auto"` or `"manual"`), or `undefined` to remove it.
945
+ * @return This DomElement instance for chaining.
946
+ */
947
+ popover(value: "auto" | "manual" | undefined): this;
948
+ /**
949
+ * Shows the popover on this element.
950
+ * Requires the element to have a `popover="manual"` attribute and be in the DOM.
951
+ *
952
+ * @return This DomElement instance for chaining.
953
+ */
954
+ showPopover(): this;
955
+ /**
956
+ * Hides the popover on this element.
957
+ * Requires the element to have a `popover="manual"` attribute and be in the DOM.
958
+ *
959
+ * @return This DomElement instance for chaining.
960
+ */
961
+ hidePopover(): this;
526
962
  }
527
963
  /**
528
964
  * Creates a new DomElement instance for the given tag name.
@@ -543,12 +979,14 @@ declare class AnchorElement extends DomElement<"a"> {
543
979
  constructor();
544
980
  href(value: string): this;
545
981
  }
982
+ declare function $a(): AnchorElement;
546
983
  //#endregion
547
984
  //#region src/Button.d.ts
548
985
  declare class Button extends DomElement<"button"> {
549
986
  constructor();
550
987
  type(value: "button" | "submit" | "reset"): this;
551
988
  }
989
+ declare function $btn(): Button;
552
990
  //#endregion
553
991
  //#region src/Canvas.d.ts
554
992
  declare class Canvas extends DomElement<"canvas"> {
@@ -577,6 +1015,7 @@ declare class Canvas extends DomElement<"canvas"> {
577
1015
  z: number;
578
1016
  };
579
1017
  }
1018
+ declare function $canvas(): Canvas;
580
1019
  //#endregion
581
1020
  //#region src/constants.d.ts
582
1021
  declare const UNITLESS_CSS_PROPS: Record<string, 1>;
@@ -587,16 +1026,266 @@ declare const TAG_ALIAS: {
587
1026
  };
588
1027
  type TagAlias = typeof TAG_ALIAS;
589
1028
  //#endregion
1029
+ //#region src/MediaRule.d.ts
1030
+ declare class MediaRule {
1031
+ constructor(sheet: StyleSheet, index: number, rule: CSSMediaRule);
1032
+ protected _sheet: StyleSheet;
1033
+ protected _index: number;
1034
+ protected _rule: CSSMediaRule;
1035
+ /**
1036
+ * Returns the StyleSheet instance that owns this media rule.
1037
+ * Useful for accessing shared rule management and stylesheet-level operations.
1038
+ */
1039
+ get sheet(): StyleSheet;
1040
+ /**
1041
+ * Returns the index of this media rule within its parent stylesheet.
1042
+ * This index is used for rule lookup, insertion, and removal.
1043
+ */
1044
+ get index(): number;
1045
+ /**
1046
+ * Returns the underlying CSSMediaRule object.
1047
+ * Provides direct access to the media query and its nested CSS rules.
1048
+ */
1049
+ get rule(): CSSMediaRule;
1050
+ /**
1051
+ * Returns the number of CSS rules contained within this media block.
1052
+ * Useful for determining insertion index or iterating over nested rules.
1053
+ */
1054
+ get length(): number;
1055
+ /**
1056
+ * Returns the media query string associated with this rule.
1057
+ * For example: "screen and (max-width: 600px)".
1058
+ */
1059
+ get mediaText(): string;
1060
+ /**
1061
+ * Inserts a new CSSStyleRule into this media block at the end of its rule list.
1062
+ * The rule is created with an empty declaration block and wrapped in a CssRule instance for programmatic styling.
1063
+ *
1064
+ * For example, calling `cssRule(".box:hover")` will generate:
1065
+ * ```css
1066
+ * @media ... {
1067
+ * .box:hover {}
1068
+ * }
1069
+ * ```
1070
+ *
1071
+ * @param selector - The CSS selector to target (e.g., ".box", ":hover", "div > span").
1072
+ * @return A CssRule instance representing the newly inserted rule.
1073
+ */
1074
+ cssRule(selector: string): CssRule;
1075
+ /**
1076
+ * Removes this media rule from its parent stylesheet.
1077
+ * Delegates to the StyleSheet instance, which handles cleanup and index management.
1078
+ */
1079
+ remove(): void;
1080
+ /**
1081
+ * Removes a nested CSSStyleRule from this media block.
1082
+ * Uses the rule's index to delete it from the internal rule list.
1083
+ *
1084
+ * @param rule - The CssRule instance to remove from this media query block.
1085
+ */
1086
+ removeRule(rule: CssRule): void;
1087
+ }
1088
+ //#endregion
1089
+ //#region src/StyleSheet.d.ts
1090
+ /**
1091
+ * Manages a dedicated `<style>` element and provides programmatic access to its CSS rules.
1092
+ * Supports dynamic insertion, retrieval, and deletion of both standard and media-specific rules,
1093
+ * with internal indexing for fast lookup and reuse.
1094
+ *
1095
+ * This class ensures a single shared stylesheet instance via `StyleSheet.getSheet()`,
1096
+ * and maintains selector-to-index and media-to-rule maps on the global `window` object.
1097
+ *
1098
+ * Designed for use with component-level styling systems or DOM abstractions that require
1099
+ * granular control over rule injection without relying on inline styles.
1100
+ */
1101
+ declare class StyleSheet {
1102
+ constructor(el: HTMLStyleElement);
1103
+ protected _dom: HTMLStyleElement;
1104
+ /**
1105
+ * Returns the underlying `<style>` DOM element.
1106
+ * This element is used to inject and manage dynamic CSS rules.
1107
+ */
1108
+ get dom(): HTMLStyleElement;
1109
+ /**
1110
+ * Returns the associated `CSSStyleSheet` object for this `<style>` element.
1111
+ * Provides access to rule-level operations like `insertRule()` and `deleteRule()`.
1112
+ * Assumes the sheet is available and attached to the document.
1113
+ */
1114
+ get sheet(): CSSStyleSheet;
1115
+ /**
1116
+ * Returns the number of CSS rules currently defined in the stylesheet.
1117
+ * Useful for indexing, iteration, or conditional rule management.
1118
+ */
1119
+ get length(): number;
1120
+ /**
1121
+ * Inserts a new empty CSS rule into the stylesheet for the given selector.
1122
+ * Returns a `CssRule` wrapper for fluent manipulation of the inserted rule.
1123
+ *
1124
+ * The rule is appended at the end of the current stylesheet (`insertRule()` at index `length`).
1125
+ * This is useful for dynamically constructing scoped styles tied to specific selectors.
1126
+ *
1127
+ * @param selector - The CSS selector to target (e.g., ".btn", "#header", "body > div").
1128
+ * @return A `CssRule` instance representing the inserted rule.
1129
+ */
1130
+ cssRule(selector: string): CssRule;
1131
+ /**
1132
+ * Inserts a new empty `@media` rule into the stylesheet using the provided media query string.
1133
+ * Returns a `MediaRule` wrapper for fluent manipulation of the inserted media block.
1134
+ *
1135
+ * The rule is appended at the end of the current stylesheet (`insertRule()` at index `length`).
1136
+ * Useful for dynamically scoping styles to specific viewport conditions or device capabilities.
1137
+ *
1138
+ * @param mediaText - The media query string (e.g., "screen and (max-width: 600px)").
1139
+ * @return A `MediaRule` instance representing the inserted media rule.
1140
+ */
1141
+ mediaRule(mediaText: string): MediaRule;
1142
+ /**
1143
+ * Inserts a new `@media (min-width: …)` rule into the stylesheet.
1144
+ * Returns a `MediaRule` wrapper for fluent manipulation of styles targeting wider viewports.
1145
+ *
1146
+ * Equivalent to: `mediaRule("min-width: 768px")`
1147
+ *
1148
+ * @param minWidth - The minimum width value (e.g., `768`, `"50em"`, `"80vw"`).
1149
+ * @return A `MediaRule` instance representing the inserted media rule.
1150
+ */
1151
+ mediaMinWidth(minWidth: number | string): MediaRule;
1152
+ /**
1153
+ * Inserts a new `@media (max-width: …)` rule into the stylesheet.
1154
+ * Returns a `MediaRule` wrapper for fluent manipulation of styles targeting narrower viewports.
1155
+ *
1156
+ * Equivalent to: `mediaRule("max-width: 600px")`
1157
+ *
1158
+ * @param maxWidth - The maximum width value (e.g., `600`, `"40em"`, `"80vw"`).
1159
+ * @return A `MediaRule` instance representing the inserted media rule.
1160
+ */
1161
+ mediaMaxWidth(maxWidth: number | string): MediaRule;
1162
+ /**
1163
+ * Removes a CSS rule from the stylesheet by its index.
1164
+ * Accepts either a `CssRule` or `MediaRule` instance, which internally tracks its position.
1165
+ *
1166
+ * This is useful for dynamically cleaning up injected styles or media blocks.
1167
+ * Note: Rule indices may shift after insertion or deletion — ensure index accuracy before calling.
1168
+ *
1169
+ * @param rule - The rule instance to remove (`CssRule` or `MediaRule`).
1170
+ */
1171
+ removeRule(rule: CssRule | MediaRule): void;
1172
+ /**
1173
+ * Retrieves or creates a <style> element with the given ID and wraps it in a StyleSheet instance.
1174
+ * If no element with the specified ID exists, a new <style> tag is created, appended to <head>,
1175
+ * and assigned the ID. This allows multiple independently managed stylesheets via custom IDs.
1176
+ *
1177
+ * @param id - Optional ID of the <style> element to target. Defaults to DEFAULT_STYLE_ID.
1178
+ * @return A StyleSheet instance bound to the specified <style> element.
1179
+ */
1180
+ static getSheet(id?: string): StyleSheet;
1181
+ /**
1182
+ * The default ID used for the primary stylesheet managed by the StyleSheet class.
1183
+ * This ensures consistent lookup and avoids collisions with other style elements in the document.
1184
+ */
1185
+ static DEFAULT_STYLE_ID: string;
1186
+ }
1187
+ //#endregion
1188
+ //#region src/CssRule.d.ts
1189
+ declare class CssRule extends BaseStyle {
1190
+ constructor(sheet: StyleSheet, index: number, rule: CSSStyleRule);
1191
+ protected _sheet: StyleSheet;
1192
+ protected _index: number;
1193
+ protected _rule: CSSStyleRule;
1194
+ /**
1195
+ * Returns the StyleSheet instance that owns this rule.
1196
+ * Useful for accessing rule management utilities or shared configuration.
1197
+ */
1198
+ get sheet(): StyleSheet;
1199
+ /**
1200
+ * Returns the index of this rule within its parent stylesheet.
1201
+ * This index is stable and used for rule lookup and removal.
1202
+ */
1203
+ get index(): number;
1204
+ /**
1205
+ * Returns the underlying CSSStyleRule object.
1206
+ * Provides direct access to selector text and style declarations.
1207
+ */
1208
+ get rule(): CSSStyleRule;
1209
+ /**
1210
+ * Returns the selector text of the underlying CSSStyleRule.
1211
+ * For example: ".box:hover", "div > span", or ".my-class[data-active]".
1212
+ */
1213
+ get selectorText(): string;
1214
+ /**
1215
+ * Removes this rule from its parent stylesheet.
1216
+ * Delegates to the StyleSheet instance to ensure proper cleanup and cache invalidation.
1217
+ */
1218
+ remove(): void;
1219
+ /**
1220
+ * Applies a style property to the underlying CSS rule.
1221
+ * Removes the property if `undefined` is passed.
1222
+ *
1223
+ * @param name - The camelCase CSS property name.
1224
+ * @param value - The value to apply, or `undefined` to remove it.
1225
+ * @return This instance for chaining.
1226
+ */
1227
+ protected setStyleProp(name: Autocomplete<keyof CssProperties>, value: string | number | undefined): this;
1228
+ }
1229
+ //#endregion
590
1230
  //#region src/DomBody.d.ts
591
- declare class DomBody {
1231
+ /**
1232
+ * Wrapper for document.body with style and DOM composition utilities.
1233
+ * Enables fluent styling and child node management.
1234
+ */
1235
+ declare class DomBody extends BaseDom<HTMLBodyElement> {
592
1236
  get dom(): HTMLBodyElement;
593
- style(obj: CssProperties): this;
594
- protected getStyleValue(name: string, value: string | number): string;
595
- add(...nodes: DomElement<any>[]): this;
596
- clear(): this;
597
1237
  }
1238
+ /**
1239
+ * Creates a new DomBody instance bound to `document.body`.
1240
+ * Provides fluent access to body-level styling, DOM composition, and event utilities.
1241
+ *
1242
+ * Useful for global layout scaffolding, dynamic content injection, or body-wide style control.
1243
+ *
1244
+ * @return A DomBody instance wrapping `document.body`.
1245
+ */
598
1246
  declare function $body(): DomBody;
599
1247
  //#endregion
1248
+ //#region src/DomWindow.d.ts
1249
+ /**
1250
+ * Wrapper for the global `window` object with typed event listener utilities.
1251
+ * Useful for managing global events like resize, scroll, or keyboard shortcuts.
1252
+ */
1253
+ declare class DomWindow {
1254
+ /**
1255
+ * Adds an event listener to the window.
1256
+ * @param type - The event type (e.g., "click", "input", "mouseenter").
1257
+ * @param handler - The event handler function.
1258
+ * @param options - Optional event listener options.
1259
+ * @return This instance for chaining.
1260
+ */
1261
+ on<T extends keyof WindowEventMap>(type: T, handler: (ev: WindowEventMap[T] & {
1262
+ currentTarget: Window;
1263
+ }) => void, options?: boolean | AddEventListenerOptions): this;
1264
+ /**
1265
+ * Removes an event listener from the window.
1266
+ * @param type - The event type to remove.
1267
+ * @param handler - The original handler function.
1268
+ * @param options - Optional event listener options.
1269
+ */
1270
+ off<T extends keyof WindowEventMap>(type: T, handler: (ev: WindowEventMap[T]) => void, options?: boolean | EventListenerOptions): void;
1271
+ /**
1272
+ * Dispatches a DOM event on the window object.
1273
+ *
1274
+ * @param event - The corresponding event instance (e.g., `new Event("resize")`, `new KeyboardEvent("keydown")`).
1275
+ * @return This instance for chaining.
1276
+ */
1277
+ dispatch(event: Event): this;
1278
+ }
1279
+ /**
1280
+ * Creates a new DomWindow instance bound to the global `window` object.
1281
+ * Provides typed event listener utilities and fluent dispatching for built-in DOM events.
1282
+ *
1283
+ * Useful for managing global interactions like resize, scroll, keyboard shortcuts, or visibility changes.
1284
+ *
1285
+ * @return A DomWindow instance wrapping the global `window`.
1286
+ */
1287
+ declare function $window(): DomWindow;
1288
+ //#endregion
600
1289
  //#region src/IFrame.d.ts
601
1290
  declare class IFrame extends DomElement<"iframe"> {
602
1291
  constructor();
@@ -607,6 +1296,7 @@ declare class IFrame extends DomElement<"iframe"> {
607
1296
  setSize(width: number, height: number): this;
608
1297
  reload(): void;
609
1298
  }
1299
+ declare function $iframe(): IFrame;
610
1300
  //#endregion
611
1301
  //#region src/ImageElement.d.ts
612
1302
  declare class ImageElement extends DomElement<"img"> {
@@ -617,69 +1307,26 @@ declare class ImageElement extends DomElement<"img"> {
617
1307
  setSize(width: number, height: number): this;
618
1308
  alt(value: string): this;
619
1309
  }
1310
+ declare function $img(): ImageElement;
620
1311
  //#endregion
621
- //#region src/InputCheckbox.d.ts
622
- declare class InputCheckbox extends DomElement<"input"> {
623
- constructor();
624
- name(value: string): this;
625
- checked(value: boolean): this;
626
- isChecked(): boolean;
627
- }
628
- //#endregion
629
- //#region src/InputColor.d.ts
630
- declare class InputColor extends DomElement<"input"> {
631
- constructor();
632
- protected _rgb: {
633
- r: number;
634
- g: number;
635
- b: number;
636
- };
637
- name(value: string): this;
638
- value(value: string): this;
639
- getValue(): string;
640
- getRGB(): {
641
- r: number;
642
- g: number;
643
- b: number;
644
- };
645
- getNormalizedRGB(): {
646
- r: number;
647
- g: number;
648
- b: number;
649
- };
650
- }
651
- //#endregion
652
- //#region src/InputNumber.d.ts
653
- declare class InputNumber extends DomElement<"input"> {
654
- constructor();
655
- name(value: string): this;
656
- value(value: number): this;
657
- getValue(): number;
658
- min(value: number): this;
659
- max(value: number): this;
660
- step(value: number): this;
661
- placeholder(value: string): this;
662
- }
663
- //#endregion
664
- //#region src/InputRange.d.ts
665
- declare class InputRange extends DomElement<"input"> {
666
- constructor();
667
- name(value: string): this;
668
- value(value: number): this;
669
- getValue(): number;
670
- min(value: number): this;
671
- max(value: number): this;
672
- step(value: number): this;
673
- }
674
- //#endregion
675
- //#region src/InputText.d.ts
676
- declare class InputText extends DomElement<"input"> {
677
- constructor();
678
- name(value: string): this;
679
- value(value: string): this;
680
- getValue(): string;
681
- placeholder(value: string): this;
682
- }
1312
+ //#region src/input.d.ts
1313
+ /**
1314
+ * Creates a typed input element instance based on the specified input type.
1315
+ * Returns a subclass of `DomElement` with type-safe access to input-specific properties and behaviors.
1316
+ *
1317
+ * Supported types include:
1318
+ * - `"text"` → `InputText`
1319
+ * - `"number"` → `InputNumber`
1320
+ * - `"checkbox"` → `InputCheckbox`
1321
+ * - `"color"` → `InputColor`
1322
+ * - `"range"` → `InputRange`
1323
+ *
1324
+ * Each returned instance supports fluent styling, DOM composition, and event binding.
1325
+ *
1326
+ * @param type - The input type to create.
1327
+ * @return A typed input element instance matching the given type.
1328
+ */
1329
+ declare function $input<T$1 extends keyof InputElementMap>(type: T$1): InputElementMap[T$1];
683
1330
  //#endregion
684
1331
  //#region src/OptionElement.d.ts
685
1332
  declare class OptionElement extends DomElement<"option"> {
@@ -687,6 +1334,7 @@ declare class OptionElement extends DomElement<"option"> {
687
1334
  value(value: string | number): this;
688
1335
  getValue(): string;
689
1336
  }
1337
+ declare function $option(): OptionElement;
690
1338
  //#endregion
691
1339
  //#region src/ProgressElement.d.ts
692
1340
  /**
@@ -727,6 +1375,7 @@ declare class ProgressElement extends DomElement<"progress"> {
727
1375
  */
728
1376
  indeterminate(): this;
729
1377
  }
1378
+ declare function $progress(): ProgressElement;
730
1379
  //#endregion
731
1380
  //#region src/SelectElement.d.ts
732
1381
  declare class SelectElement extends DomElement<"select"> {
@@ -735,9 +1384,11 @@ declare class SelectElement extends DomElement<"select"> {
735
1384
  value(value: string | number): this;
736
1385
  getValue(): string;
737
1386
  }
1387
+ declare function $select(): SelectElement;
738
1388
  //#endregion
739
1389
  //#region src/utils.d.ts
740
1390
  declare function uniqueId(): string;
741
1391
  declare function camelToKebab(prop: string): string;
1392
+ declare function getStyleValue(name: Autocomplete<keyof CssProperties>, value: string | number): string;
742
1393
  //#endregion
743
- export { $, $body, $query, AnchorElement, Autocomplete, Button, Canvas, CssProperties, type CssProperty, DomBody, DomElement, DomElementChild, DomElementEventMap, DomElementTagNameMap, IFrame, ImageElement, InputCheckbox, InputColor, InputNumber, InputRange, InputText, MediaRule, OptionElement, ProgressElement, SVG_TAGS, SelectElement, StyleSheet, TAG_ALIAS, TagAlias, UNITLESS_CSS_PROPS, VENDOR_CSS_PROPS, camelToKebab, uniqueId };
1394
+ export { $, $a, $body, $btn, $canvas, $iframe, $img, $input, $option, $progress, $query, $select, $window, AnchorElement, Autocomplete, BaseDom, BaseStyle, Button, Canvas, CssProperties, type CssProperty, CssRule, DomBody, DomElement, DomElementChild, DomElementEventMap, DomElementTagNameMap, DomWindow, IFrame, ImageElement, InputCheckbox, InputColor, InputElementMap, InputNumber, InputRange, InputText, MediaRule, OptionElement, ProgressElement, SVG_TAGS, SelectElement, StyleSheet, TAG_ALIAS, TagAlias, UNITLESS_CSS_PROPS, VENDOR_CSS_PROPS, camelToKebab, getStyleValue, uniqueId };