@neptune3d/dom 0.0.4 → 0.0.5

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/README.md CHANGED
@@ -22,7 +22,7 @@ const div = $("div")
22
22
 
23
23
  const body = $body();
24
24
 
25
- body.appendChild(div.dom);
25
+ body.append(div.dom);
26
26
  ```
27
27
 
28
28
  Use SVG elements:
@@ -34,9 +34,9 @@ const circle = $("circle")
34
34
  .attr("r", "40")
35
35
  .attr("fill", "red");
36
36
 
37
- const svg = $("svg").attr("width", "100").attr("height", "100").append(circle);
37
+ const svg = $("svg").attr("width", "100").attr("height", "100").add(circle);
38
38
 
39
- body.appendChild(svg.dom);
39
+ body.append(svg.dom);
40
40
  ```
41
41
 
42
42
  Define global styles:
package/dist/index.d.ts CHANGED
@@ -14,9 +14,11 @@ declare class MediaRule {
14
14
  }
15
15
  //#endregion
16
16
  //#region src/types.d.ts
17
- type CssProperties = PropertiesFallback<string | number>;
17
+ type CssProperties = PropertiesFallback<string | number> & {
18
+ [key: `--${string}`]: string | number | undefined;
19
+ };
18
20
  type Autocomplete<T$1 extends string> = T$1 | (string & {});
19
- type DomElementChild = DomElement<any> | string | number;
21
+ type DomElementChild = DomElement<any> | Node | string | number;
20
22
  type DomElementTagNameMap = HTMLElementTagNameMap & SvgElementTagNameMap;
21
23
  type SvgElementTagNameMap = {
22
24
  svgA: SVGAElement;
@@ -116,16 +118,47 @@ declare class StyleSheet {
116
118
  * @param props - The CSS properties to apply.
117
119
  */
118
120
  globalMediaCss(mediaText: string, selector: string, props: CssProperties): void;
121
+ /**
122
+ * Retrieves or creates a CSSStyleRule for the given selector.
123
+ * If the rule doesn't exist, it is inserted at the end of the stylesheet and cached.
124
+ *
125
+ * This ensures stable indexing and avoids rule override issues caused by shifting positions.
126
+ * The returned rule can be used to modify style declarations programmatically.
127
+ *
128
+ * @param selector - The CSS selector string (e.g., ".button", "#header", "div > span").
129
+ * @return The corresponding CSSStyleRule instance.
130
+ */
119
131
  getCssRule(selector: string): CSSStyleRule;
120
132
  deleteCssRule(selector: string): void;
133
+ /**
134
+ * Retrieves or creates a CSSMediaRule for the given media query.
135
+ * If the rule doesn't exist, it is inserted at the end of the stylesheet and cached.
136
+ *
137
+ * This ensures consistent indexing and avoids rule override issues caused by shifting positions.
138
+ *
139
+ * @param mediaText - The media query string (e.g., "screen and (max-width: 600px)").
140
+ * @return A MediaRule wrapper containing the index and CSSMediaRule reference.
141
+ */
121
142
  getMediaRule(mediaText: string): MediaRule;
122
143
  deleteMediaRule(mediaText: string): void;
123
- static getSheet(): StyleSheet;
124
144
  setRuleCss(rule: CSSStyleRule, props: CssProperties): void;
125
145
  getStyleValue(name: Autocomplete<keyof CssProperties>, value: string | number): string;
126
146
  protected getCssMap(): Map<string, number>;
127
147
  protected getMediaMap(): Map<string, MediaRule>;
128
- static STYLE_ID: string;
148
+ /**
149
+ * Retrieves or creates a <style> element with the given ID and wraps it in a StyleSheet instance.
150
+ * If no element with the specified ID exists, a new <style> tag is created, appended to <head>,
151
+ * and assigned the ID. This allows multiple independently managed stylesheets via custom IDs.
152
+ *
153
+ * @param id - Optional ID of the <style> element to target. Defaults to DEFAULT_STYLE_ID.
154
+ * @return A StyleSheet instance bound to the specified <style> element.
155
+ */
156
+ static getSheet(id?: string): StyleSheet;
157
+ /**
158
+ * The default ID used for the primary stylesheet managed by the StyleSheet class.
159
+ * This ensures consistent lookup and avoids collisions with other style elements in the document.
160
+ */
161
+ static DEFAULT_STYLE_ID: string;
129
162
  }
130
163
  //#endregion
131
164
  //#region src/DomElement.d.ts
@@ -177,7 +210,26 @@ declare class DomElement<Tag extends keyof DomElementTagNameMap = keyof DomEleme
177
210
  get dom(): DomElementTagNameMap[Tag];
178
211
  get cssClassName(): string;
179
212
  getText(): string;
180
- text(txt: any): this;
213
+ /**
214
+ * Sets or clears the text content of the element.
215
+ * Converts any value to a string before assignment.
216
+ * Passing `undefined` or `null` removes the text by setting it to an empty string.
217
+ *
218
+ * @param value - The text content to set, or `undefined`/`null` to clear it.
219
+ * @return This DomElement instance for chaining.
220
+ */
221
+ text(value: any): this;
222
+ /**
223
+ * Appends one or more child nodes to the element.
224
+ * Accepts DomElement instances, regular DOM Nodes, strings, or numbers.
225
+ *
226
+ * - Strings and numbers are coerced to text nodes.
227
+ * - DomElement instances are unwrapped to their native DOM nodes.
228
+ * - DOM Nodes are appended directly.
229
+ *
230
+ * @param nodes - One or more child elements or text values to append.
231
+ * @return This DomElement instance for chaining.
232
+ */
181
233
  add(...nodes: DomElementChild[]): this;
182
234
  /**
183
235
  * Inserts one or more DomElements into a parent at the specified index.
@@ -205,6 +257,14 @@ declare class DomElement<Tag extends keyof DomElementTagNameMap = keyof DomEleme
205
257
  * @return This DomElement instance.
206
258
  */
207
259
  setChildrenFromIndex(index: number, ...nodes: DomElementChild[]): this;
260
+ /**
261
+ * Removes the element from the DOM tree.
262
+ * Equivalent to calling `element.remove()` on the native DOM node.
263
+ *
264
+ * This does not dispose internal state or event listeners — use `dispose()` if cleanup is needed.
265
+ *
266
+ * @return This DomElement instance for chaining.
267
+ */
208
268
  remove(): void;
209
269
  /**
210
270
  * Removes child elements within the specified index range.
@@ -269,29 +329,68 @@ declare class DomElement<Tag extends keyof DomElementTagNameMap = keyof DomEleme
269
329
  prop(name: string, value: any): this;
270
330
  /**
271
331
  * Sets multiple properties on the element.
272
- * @param properties - An object mapping property names to values.
332
+ * @param props - An object mapping property names to values.
273
333
  * Properties with undefined values are deleted.
274
334
  * @return This DomElement instance for chaining.
275
335
  */
276
- props(properties: Record<string, any>): this;
277
- style(obj: CssProperties): this;
278
- id(value: string): this;
336
+ props(props: Record<string, any>): this;
279
337
  /**
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.
338
+ * Applies a batch of CSS style properties to the element.
339
+ * Delegates each property to `setStyleProp`, which handles value normalization and kebab-case conversion.
340
+ *
341
+ * - Properties with `undefined` values are removed from the inline style.
342
+ * - Numeric values are passed through the style sheet for unit resolution.
343
+ * - Supports chainable usage for fluent DOM composition.
344
+ *
345
+ * @param props - A partial map of CSS properties and their values.
346
+ * @returns This DomElement instance for chaining.
347
+ */
348
+ style(props: CssProperties): this;
349
+ /**
350
+ * Sets or removes the `id` of the element.
351
+ * Passing `undefined` clears the ID by setting it to an empty string.
352
+ *
353
+ * @param value - The element's ID, or `undefined` to remove it.
354
+ * @return This DomElement instance for chaining.
355
+ */
356
+ id(value: string | undefined): this;
357
+ /**
358
+ * Sets or removes the user-defined class name and applies it alongside the internal CSS class.
359
+ * Uses `setAttribute("class", ...)` for both HTML and SVG elements.
360
+ *
361
+ * Passing `undefined` removes the user-defined class name entirely.
362
+ *
363
+ * @param value - The user-defined class name, or `undefined` to remove it.
283
364
  * @return This DomElement instance for chaining.
284
365
  */
285
- className(value: string): this;
286
- htmlFor(value: string): this;
366
+ className(value: string | undefined): this;
287
367
  /**
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.
368
+ * Sets or removes the `htmlFor` property on a <label> element.
369
+ * This links the label to a form control by its ID.
370
+ *
371
+ * Passing `undefined` removes the association.
372
+ * Has no effect if the element is not a <label>.
373
+ *
374
+ * @param value - The ID of the target form control, or `undefined` to remove it.
292
375
  * @return This DomElement instance for chaining.
293
376
  */
294
- title(value: string): this;
377
+ htmlFor(value: string | undefined): this;
378
+ /**
379
+ * Sets or removes the `title` attribute on the element.
380
+ * Applies to both HTML and SVG elements. Passing `undefined` removes the attribute.
381
+ *
382
+ * @param value - The tooltip text to show on hover, or `undefined` to remove it.
383
+ * @return This DomElement instance for chaining.
384
+ */
385
+ title(value: string | undefined): this;
386
+ /**
387
+ * Sets or removes the `disabled` attribute on the element.
388
+ * Applicable to form controls like <button>, <input>, <select>, etc.
389
+ *
390
+ * @param value - If true, sets the `disabled` attribute; if false, removes it.
391
+ * @return This DomElement instance for chaining.
392
+ */
393
+ disabled(value: boolean): this;
295
394
  /**
296
395
  * Sets the `disabled` attribute to disable the element.
297
396
  * Applicable to form controls like <button>, <input>, <select>, etc.
@@ -303,17 +402,113 @@ declare class DomElement<Tag extends keyof DomElementTagNameMap = keyof DomEleme
303
402
  * @return This DomElement instance for chaining.
304
403
  */
305
404
  enable(): this;
405
+ /**
406
+ * Sets or clears the `padding` style of the element.
407
+ * Accepts any valid CSS padding shorthand (e.g., "10px", "1em 2em").
408
+ * Passing `undefined` removes the padding style.
409
+ *
410
+ * @param value - The padding value to apply, or `undefined` to remove it.
411
+ * @return This DomElement instance for chaining.
412
+ */
306
413
  p(value: Property.Padding | undefined): this;
414
+ /**
415
+ * Sets or clears the `padding-top` style of the element.
416
+ * Accepts any valid CSS value (e.g., "10px", "1em").
417
+ * Passing `undefined` removes the top padding.
418
+ *
419
+ * @param value - The top padding value to apply, or `undefined` to remove it.
420
+ * @return This DomElement instance for chaining.
421
+ */
307
422
  pt(value: Property.PaddingTop | undefined): this;
423
+ /**
424
+ * Sets or clears the `padding-right` style of the element.
425
+ * Accepts any valid CSS value (e.g., "10px", "1em").
426
+ * Passing `undefined` removes the right padding.
427
+ *
428
+ * @param value - The right padding value to apply, or `undefined` to remove it.
429
+ * @return This DomElement instance for chaining.
430
+ */
308
431
  pr(value: Property.PaddingRight | undefined): this;
432
+ /**
433
+ * Sets or clears the `padding-bottom` style of the element.
434
+ * Accepts any valid CSS value (e.g., "10px", "1em").
435
+ * Passing `undefined` removes the bottom padding.
436
+ *
437
+ * @param value - The bottom padding value to apply, or `undefined` to remove it.
438
+ * @return This DomElement instance for chaining.
439
+ */
309
440
  pb(value: Property.PaddingBottom | undefined): this;
441
+ /**
442
+ * Sets or clears the `padding-left` style of the element.
443
+ * Accepts any valid CSS value (e.g., "10px", "1em").
444
+ * Passing `undefined` removes the left padding.
445
+ *
446
+ * @param value - The left padding value to apply, or `undefined` to remove it.
447
+ * @return This DomElement instance for chaining.
448
+ */
310
449
  pl(value: Property.PaddingLeft | undefined): this;
450
+ /**
451
+ * Sets or clears horizontal padding (`padding-left` and `padding-right`) simultaneously.
452
+ * Accepts any valid CSS value (e.g., "10px", "1em").
453
+ * Passing `undefined` removes both left and right padding.
454
+ *
455
+ * @param value - The horizontal padding value to apply, or `undefined` to remove it.
456
+ * @return This DomElement instance for chaining.
457
+ */
311
458
  px(value: Property.PaddingLeft | undefined): this;
459
+ /**
460
+ * Sets or clears vertical padding (`padding-top` and `padding-bottom`) simultaneously.
461
+ * Accepts any valid CSS value (e.g., "10px", "1em").
462
+ * Passing `undefined` removes both top and bottom padding.
463
+ *
464
+ * @param value - The vertical padding value to apply, or `undefined` to remove it.
465
+ * @return This DomElement instance for chaining.
466
+ */
312
467
  py(value: Property.PaddingTop | undefined): this;
468
+ /**
469
+ * Sets or clears the `margin` style of the element.
470
+ * Accepts any valid CSS margin shorthand (e.g., "10px", "1em 2em").
471
+ * Passing `undefined` removes the margin style.
472
+ *
473
+ * @param value - The margin value to apply, or `undefined` to remove it.
474
+ * @return This DomElement instance for chaining.
475
+ */
313
476
  m(value: Property.Margin | undefined): this;
477
+ /**
478
+ * Sets or clears the `margin-top` style of the element.
479
+ * Accepts any valid CSS value (e.g., "10px", "auto").
480
+ * Passing `undefined` removes the top margin.
481
+ *
482
+ * @param value - The top margin value to apply, or `undefined` to remove it.
483
+ * @return This DomElement instance for chaining.
484
+ */
314
485
  mt(value: Property.MarginTop | undefined): this;
486
+ /**
487
+ * Sets or clears the `margin-right` style of the element.
488
+ * Accepts any valid CSS value (e.g., "10px", "auto").
489
+ * Passing `undefined` removes the right margin.
490
+ *
491
+ * @param value - The right margin value to apply, or `undefined` to remove it.
492
+ * @return This DomElement instance for chaining.
493
+ */
315
494
  mr(value: Property.MarginRight | undefined): this;
495
+ /**
496
+ * Sets or clears the `margin-bottom` style of the element.
497
+ * Accepts any valid CSS value (e.g., "10px", "auto").
498
+ * Passing `undefined` removes the bottom margin.
499
+ *
500
+ * @param value - The bottom margin value to apply, or `undefined` to remove it.
501
+ * @return This DomElement instance for chaining.
502
+ */
316
503
  mb(value: Property.MarginBottom | undefined): this;
504
+ /**
505
+ * Sets or clears the `margin-left` style of the element.
506
+ * Accepts any valid CSS value (e.g., "10px", "auto").
507
+ * Passing `undefined` removes the left margin.
508
+ *
509
+ * @param value - The left margin value to apply, or `undefined` to remove it.
510
+ * @return This DomElement instance for chaining.
511
+ */
317
512
  ml(value: Property.MarginLeft | undefined): this;
318
513
  /**
319
514
  * Sets the overall border radius.
@@ -388,8 +583,24 @@ declare class DomElement<Tag extends keyof DomElementTagNameMap = keyof DomEleme
388
583
  flex(value: Property.Flex | undefined): this;
389
584
  bgColor(value: Property.BackgroundColor | undefined): this;
390
585
  color(value: Property.Color | undefined): this;
391
- h(value: Property.Height | number | undefined): this;
586
+ /**
587
+ * Sets or clears the `width` style of the element.
588
+ * Accepts CSS width values (e.g., "100px", "50%") or numeric pixel values.
589
+ * Passing `undefined` removes the width style.
590
+ *
591
+ * @param value - The width value to apply, or `undefined` to remove it.
592
+ * @return This DomElement instance for chaining.
593
+ */
392
594
  w(value: Property.Width | number | undefined): this;
595
+ /**
596
+ * Sets or clears the `height` style of the element.
597
+ * Accepts CSS height values (e.g., "100px", "auto") or numeric pixel values.
598
+ * Passing `undefined` removes the height style.
599
+ *
600
+ * @param value - The height value to apply, or `undefined` to remove it.
601
+ * @return This DomElement instance for chaining.
602
+ */
603
+ h(value: Property.Height | number | undefined): this;
393
604
  /**
394
605
  * Sets the full border style.
395
606
  * @param value - The CSS border value (e.g., "1px solid #ccc").
@@ -509,18 +720,136 @@ declare class DomElement<Tag extends keyof DomElementTagNameMap = keyof DomEleme
509
720
  * @return This DomElement instance for chaining.
510
721
  */
511
722
  userSelect(value: Property.UserSelect | undefined): this;
723
+ /**
724
+ * Sets the vertical alignment of the element.
725
+ * Common values include "middle", "top", "bottom", "baseline", or pixel/em units.
726
+ *
727
+ * @param value - The CSS vertical-align value (e.g., "middle", "top", "10px").
728
+ * @return This DomElement instance for chaining.
729
+ */
730
+ verticalAlign(value: Property.VerticalAlign | undefined): this;
731
+ /**
732
+ * Applies CSS styles to truncate overflowing text with an ellipsis.
733
+ * Ensures the text stays on a single line and hides overflow.
734
+ *
735
+ * Equivalent to:
736
+ * ```css
737
+ * overflow: hidden;
738
+ * white-space: nowrap;
739
+ * text-overflow: ellipsis;
740
+ * ```
741
+ *
742
+ * @return This DomElement instance for chaining.
743
+ */
512
744
  overflowEllipsis(): this;
513
745
  ref(refFn: (el: this) => void): this;
746
+ /**
747
+ * Applies scoped CSS styles to the element using a class-based selector.
748
+ * Ensures the element has a unique internal class name, then targets it with the given selector.
749
+ *
750
+ * For example, calling `css(":hover", { color: "red" })` will generate:
751
+ * ```css
752
+ * .<internalClassName>:hover { color: red; }
753
+ * ```
754
+ *
755
+ * This enables dynamic styling of pseudo-classes, child selectors, or media queries without inline styles.
756
+ *
757
+ * @param selector - A CSS selector suffix (e.g., ":hover", " > span") scoped to the internal class.
758
+ * @param props - A map of CSS properties to apply to the generated rule.
759
+ * @return This DomElement instance for chaining.
760
+ */
761
+ css(selector: string, props: CssProperties): this;
762
+ /**
763
+ * Applies scoped CSS styles directly to the root selector of the element.
764
+ * Equivalent to styling `.className` without any pseudo-classes or combinators.
765
+ *
766
+ * @param props - A map of CSS properties to apply to the root selector.
767
+ * @return This DomElement instance for chaining.
768
+ */
514
769
  rootCss(props: CssProperties): this;
770
+ /**
771
+ * Applies scoped CSS styles to the `:hover` state of the element.
772
+ * Useful for styling hover interactions without inline styles.
773
+ *
774
+ * @param props - A map of CSS properties to apply when the element is hovered.
775
+ * @return This DomElement instance for chaining.
776
+ */
515
777
  hoverCss(props: CssProperties): this;
778
+ /**
779
+ * Applies scoped CSS styles to the `:active` state of the element.
780
+ * Useful for styling active interactions (e.g., mouse down).
781
+ *
782
+ * @param props - A map of CSS properties to apply when the element is active.
783
+ * @return This DomElement instance for chaining.
784
+ */
516
785
  activeCss(props: CssProperties): this;
786
+ /**
787
+ * Applies scoped CSS styles to the `:focus` state of the element.
788
+ * Useful for styling keyboard or programmatic focus.
789
+ *
790
+ * @param props - A map of CSS properties to apply when the element is focused.
791
+ * @return This DomElement instance for chaining.
792
+ */
517
793
  focusCss(props: CssProperties): this;
518
- css(selector: string, props: CssProperties): this;
794
+ /**
795
+ * Applies scoped CSS styles to the `:focus-within` state of the element.
796
+ * Useful for styling when any child element has focus.
797
+ *
798
+ * @param props - A map of CSS properties to apply when the element or its descendants are focused.
799
+ * @return This DomElement instance for chaining.
800
+ */
801
+ focusWithinCss(props: CssProperties): this;
802
+ /**
803
+ * Applies scoped CSS styles to the element within a media query block.
804
+ * Ensures the element has a unique internal class name, then targets it with the given selector inside the specified media query.
805
+ *
806
+ * For example, calling `mediaCss("screen and (max-width: 600px)", ":hover", { color: "red" })` will generate:
807
+ * ```css
808
+ * \@media screen and (max-width: 600px) {
809
+ * .<internalClassName>:hover { color: red; }
810
+ * }
811
+ * ```
812
+ *
813
+ * This enables responsive styling and conditional behavior based on viewport or device characteristics.
814
+ *
815
+ * @param mediaText - The media query string (e.g., "screen and (max-width: 600px)").
816
+ * @param selector - A CSS selector suffix (e.g., ":hover", " > span") scoped to the internal class.
817
+ * @param props - A map of CSS properties to apply within the media rule.
818
+ * @return This DomElement instance for chaining.
819
+ */
519
820
  mediaCss(mediaText: string, selector: string, props: CssProperties): this;
821
+ /**
822
+ * Applies scoped CSS styles to the root selector of the element within a media query block.
823
+ * Useful for conditionally styling the element based on viewport or device characteristics.
824
+ *
825
+ * @param mediaText - The media query string (e.g., "screen and (max-width: 600px)").
826
+ * @param props - A map of CSS properties to apply within the media rule.
827
+ * @return This DomElement instance for chaining.
828
+ */
520
829
  mediaRootCss(mediaText: string, props: CssProperties): this;
830
+ /**
831
+ * Applies scoped CSS styles to the root selector of the element when the viewport width
832
+ * meets or exceeds the specified minimum.
833
+ *
834
+ * Automatically converts numeric values to pixel-based CSS width values.
835
+ *
836
+ * @param minWidth - The minimum width threshold (e.g., 600 or "40em").
837
+ * @param props - A map of CSS properties to apply when the condition is met.
838
+ * @return This DomElement instance for chaining.
839
+ */
521
840
  minWidthCss(minWidth: number | string, props: CssProperties): this;
841
+ /**
842
+ * Applies scoped CSS styles to the root selector of the element when the viewport width
843
+ * is less than or equal to the specified maximum.
844
+ *
845
+ * Automatically converts numeric values to pixel-based CSS width values.
846
+ *
847
+ * @param maxWidth - The maximum width threshold (e.g., 600 or "40em").
848
+ * @param props - A map of CSS properties to apply when the condition is met.
849
+ * @return This DomElement instance for chaining.
850
+ */
522
851
  maxWidthCss(maxWidth: number | string, props: CssProperties): this;
523
- protected resolveNode(child: DomElementChild): any;
852
+ protected resolveNode(child: DomElementChild): Node;
524
853
  protected setStyleProp(name: Autocomplete<keyof CssProperties>, value: string | number | undefined): this;
525
854
  protected setCssClassName(): this;
526
855
  }
@@ -548,6 +877,7 @@ declare class AnchorElement extends DomElement<"a"> {
548
877
  declare class Button extends DomElement<"button"> {
549
878
  constructor();
550
879
  type(value: "button" | "submit" | "reset"): this;
880
+ disabledCss(props: CssProperties): this;
551
881
  }
552
882
  //#endregion
553
883
  //#region src/Canvas.d.ts
@@ -624,6 +954,7 @@ declare class InputCheckbox extends DomElement<"input"> {
624
954
  name(value: string): this;
625
955
  checked(value: boolean): this;
626
956
  isChecked(): boolean;
957
+ disabledCss(props: CssProperties): this;
627
958
  }
628
959
  //#endregion
629
960
  //#region src/InputColor.d.ts
@@ -647,6 +978,7 @@ declare class InputColor extends DomElement<"input"> {
647
978
  g: number;
648
979
  b: number;
649
980
  };
981
+ disabledCss(props: CssProperties): this;
650
982
  }
651
983
  //#endregion
652
984
  //#region src/InputNumber.d.ts
@@ -659,6 +991,7 @@ declare class InputNumber extends DomElement<"input"> {
659
991
  max(value: number): this;
660
992
  step(value: number): this;
661
993
  placeholder(value: string): this;
994
+ disabledCss(props: CssProperties): this;
662
995
  }
663
996
  //#endregion
664
997
  //#region src/InputRange.d.ts
@@ -670,6 +1003,7 @@ declare class InputRange extends DomElement<"input"> {
670
1003
  min(value: number): this;
671
1004
  max(value: number): this;
672
1005
  step(value: number): this;
1006
+ disabledCss(props: CssProperties): this;
673
1007
  }
674
1008
  //#endregion
675
1009
  //#region src/InputText.d.ts
@@ -679,6 +1013,7 @@ declare class InputText extends DomElement<"input"> {
679
1013
  value(value: string): this;
680
1014
  getValue(): string;
681
1015
  placeholder(value: string): this;
1016
+ disabledCss(props: CssProperties): this;
682
1017
  }
683
1018
  //#endregion
684
1019
  //#region src/OptionElement.d.ts
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- const e={opacity:1,zIndex:1,fontWeight:1,lineHeight:1,flexGrow:1,flexShrink:1,order:1,zoom:1,scale:1,counterIncrement:1,counterReset:1,tabSize:1,orphans:1,widows:1,columns:1,columnCount:1,gridRow:1,gridColumn:1},t={WebkitAppearance:1},n=[`svg`,`circle`,`rect`,`path`,`line`,`polyline`,`polygon`,`g`,`text`,`defs`,`use`,`symbol`,`clipPath`,`mask`],r={svgA:`a`};var i=class{constructor(e,t){this._index=e,this._rule=t,this.cssMap=new Map}_index;_rule;cssMap;get index(){return this._index}get rule(){return this._rule}get length(){return this._rule.cssRules.length}getCssRule(e){let t=this.cssMap.get(e);return t??=this._rule.insertRule(`${e}{}`,this.length),this._rule.cssRules.item(t)}delete(e){this._rule.deleteRule(e)}};function a(){return`${Date.now().toString(36)}-${(o++).toString(36)}`}let o=0;function s(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}var c=class n{constructor(e){this._dom=e}_dom;get dom(){return this._dom}get sheet(){return this.dom.sheet}get length(){return this.sheet.cssRules.length}globalCss(e,t){let n=this.getCssRule(e);this.setRuleCss(n,t)}globalMediaCss(e,t,n){let r=this.getMediaRule(e).getCssRule(t);this.setRuleCss(r,n)}getCssRule(e){let t=this.getCssMap(),n=t.get(e);return n??(n=this.sheet.insertRule(`${e}{}`),t.set(e,n)),this.sheet.cssRules.item(n)}deleteCssRule(e){let t=this.getCssMap(),n=t.get(e);n!=null&&(this.sheet.deleteRule(n),t.delete(e))}getMediaRule(e){let t=this.getMediaMap(),n=t.get(e);if(!n){let r=this.sheet.insertRule(`@media(${e}){}`);n=new i(r,this.sheet.cssRules.item(r)),t.set(e,n)}return n}deleteMediaRule(e){let t=this.getMediaMap(),n=t.get(e);n!=null&&(this.sheet.deleteRule(n.index),t.delete(e))}static getSheet(){let e=document.head.querySelector(`#${n.STYLE_ID}`);if(e==null){let e=document.createElement(`style`);return e.id=n.STYLE_ID,e.setAttribute(`type`,`text/css`),document.head.append(e),new n(e)}else return new n(e)}setRuleCss(e,n){for(let r in n){let i=!!t[r],a=s(r);e.style.setProperty(i?`-${a}`:a,this.getStyleValue(r,n[r]))}}getStyleValue(t,n){return typeof n==`number`?e[t]?String(n):`${n}px`:n}getCssMap(){let e=window.__neptuneCssMap__;return e||(e=new Map,window.__neptuneCssMap__=e),e}getMediaMap(){let e=window.__neptuneMediaMap__;return e||(e=new Map,window.__neptuneMediaMap__=e),e}static STYLE_ID=`__neptune-style__`},l=class{constructor(e,t){this._tag=r[e]??e,this._isSvg=n.includes(this._tag),this._dom=t??(this._isSvg?document.createElementNS(`http://www.w3.org/2000/svg`,this._tag):document.createElement(this._tag)),this._sheet=c.getSheet()}_tag;_isSvg;_dom;_sheet;_cssClassName;_userClassName;get tag(){return this._tag}get isSvg(){return this._isSvg}get dom(){return this._dom}get cssClassName(){return this._cssClassName||=a(),this._cssClassName}getText(){return this._dom.textContent}text(e){return this._dom.textContent=String(e),this}add(...e){return this._dom.append(...e.map(e=>this.resolveNode(e))),this}insertAtIndex(e,...t){let n=Array.from(this.dom.children),r=Math.max(0,Math.min(e,n.length));for(let e of t){let t=n[r]??null;this.dom.insertBefore(this.resolveNode(e),t),r++}return this}setChildren(...e){return this.clear().add(...e)}setChildrenFromIndex(e,...t){let n=Array.from(this._dom.children),r=n.length,i=Math.max(0,Math.min(e,r));for(let e=i;e<r;e++)this._dom.removeChild(n[e]);let a=this._dom.children[i]??null;for(let e of t)this._dom.insertBefore(this.resolveNode(e),a);return this}remove(){this.dom.remove()}clear(e,t){let n=Array.from(this._dom.children),r=Math.max(0,e??0),i=Math.min(n.length,t??n.length);for(let e=r;e<i;e++)this._dom.removeChild(n[e]);return this}on(e,t,n){return this._dom.addEventListener(e,t,n),this}off(e,t,n){this._dom.removeEventListener(e,t,n)}getAttr(e){return this.dom.getAttribute(e)}attr(e,t){return t===void 0?this.dom.removeAttribute(e):this.dom.setAttribute(e,String(t)),this}attrs(e){for(let[t,n]of Object.entries(e))this.attr(t,n);return this}getProp(e){return this.dom[e]}prop(e,t){return this.dom[e]=t,this}props(e){for(let[t,n]of Object.entries(e))this.prop(t,n);return this}style(e){for(let t in e)this._dom.style[t]=this._sheet.getStyleValue(t,e[t]);return this}id(e){return this._dom.id=e,this}className(e){this._userClassName=e;let t=this._cssClassName?`${e} ${this.cssClassName}`:e;return this.isSvg?this.dom.setAttribute(`class`,t):this.dom.className=t,this}htmlFor(e){return this._tag===`label`&&(this._dom.htmlFor=e),this}title(e){return this.isSvg?this.dom.setAttribute(`title`,e):this.dom.title=e,this}disable(){return this.dom.setAttribute(`disabled`,``),this}enable(){return this.dom.removeAttribute(`disabled`),this}p(e){return this.setStyleProp(`padding`,e)}pt(e){return this.setStyleProp(`paddingTop`,e)}pr(e){return this.setStyleProp(`paddingRight`,e)}pb(e){return this.setStyleProp(`paddingBottom`,e)}pl(e){return this.setStyleProp(`paddingLeft`,e)}px(e){return this.pl(e).pr(e)}py(e){return this.pt(e).pb(e)}m(e){return this.setStyleProp(`margin`,e)}mt(e){return this.setStyleProp(`marginTop`,e)}mr(e){return this.setStyleProp(`marginRight`,e)}mb(e){return this.setStyleProp(`marginBottom`,e)}ml(e){return this.setStyleProp(`marginLeft`,e)}radius(e){return this.setStyleProp(`borderRadius`,e)}radiusTopLeft(e){return this.setStyleProp(`borderTopLeftRadius`,e)}radiusTopRight(e){return this.setStyleProp(`borderTopRightRadius`,e)}radiusBottomLeft(e){return this.setStyleProp(`borderBottomLeftRadius`,e)}radiusBottomRight(e){return this.setStyleProp(`borderBottomRightRadius`,e)}radiusTop(e){return this.radiusTopLeft(e).radiusTopRight(e)}radiusBottom(e){return this.radiusBottomLeft(e).radiusBottomRight(e)}radiusLeft(e){return this.radiusTopLeft(e).radiusBottomLeft(e)}radiusRight(e){return this.radiusTopRight(e).radiusBottomRight(e)}radiusX(e){return this.radiusLeft(e).radiusRight(e)}radiusY(e){return this.radiusTop(e).radiusBottom(e)}display(e){return this.setStyleProp(`display`,e)}flexShrink(e){return this.setStyleProp(`flexShrink`,e)}flex(e){return this.setStyleProp(`flex`,e)}bgColor(e){return this.setStyleProp(`backgroundColor`,e)}color(e){return this.setStyleProp(`color`,e)}h(e){return this.setStyleProp(`height`,e)}w(e){return this.setStyleProp(`width`,e)}b(e){return this.setStyleProp(`border`,e)}bt(e){return this.setStyleProp(`borderTop`,e)}br(e){return this.setStyleProp(`borderRight`,e)}bb(e){return this.setStyleProp(`borderBottom`,e)}bl(e){return this.setStyleProp(`borderLeft`,e)}bx(e){return this.setStyleProp(`borderLeft`,e),this.setStyleProp(`borderRight`,e),this}by(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderBottom`,e),this}btl(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderLeft`,e),this}btr(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderRight`,e),this}bbl(e){return this.setStyleProp(`borderBottom`,e),this.setStyleProp(`borderLeft`,e),this}bbr(e){return this.setStyleProp(`borderBottom`,e),this.setStyleProp(`borderRight`,e),this}overflow(e){return this.setStyleProp(`overflow`,e)}overflowY(e){return this.setStyleProp(`overflowY`,e)}overflowX(e){return this.setStyleProp(`overflowX`,e)}fontSize(e){return this.setStyleProp(`fontSize`,e)}fontWeight(e){return this.setStyleProp(`fontWeight`,e)}fontFamily(e){return this.setStyleProp(`fontFamily`,e)}fontStyle(e){return this.setStyleProp(`fontStyle`,e)}textAlign(e){return this.setStyleProp(`textAlign`,e)}textDecoration(e){return this.setStyleProp(`textDecoration`,e)}pos(e){return this.setStyleProp(`position`,e)}posTop(e){return this.setStyleProp(`top`,e)}posBottom(e){return this.setStyleProp(`bottom`,e)}posLeft(e){return this.setStyleProp(`left`,e)}posRight(e){return this.setStyleProp(`right`,e)}cursor(e){return this.setStyleProp(`cursor`,e)}alignItems(e){return this.setStyleProp(`alignItems`,e)}justifyContent(e){return this.setStyleProp(`justifyContent`,e)}gap(e){return this.setStyleProp(`gap`,e)}flexDirection(e){return this.setStyleProp(`flexDirection`,e)}templateColumns(e){return this.setStyleProp(`gridTemplateColumns`,e)}templateRows(e){return this.setStyleProp(`gridTemplateRows`,e)}appearance(e){return this.setStyleProp(`appearance`,e)}userSelect(e){return this.setStyleProp(`userSelect`,e)}overflowEllipsis(){return this.style({overflow:`hidden`,whiteSpace:`nowrap`,textOverflow:`ellipsis`})}ref(e){return e(this),this}rootCss(e){return this.css(``,e)}hoverCss(e){return this.css(`:hover`,e)}activeCss(e){return this.css(`:active`,e)}focusCss(e){return this.css(`:focus`,e)}css(e,t){this.setCssClassName();let n=this._sheet.getCssRule(`.${this.cssClassName}${e}`);return this._sheet.setRuleCss(n,t),this}mediaCss(e,t,n){this.setCssClassName();let r=this._sheet.getMediaRule(e).getCssRule(`.${this.cssClassName}${t}`);return this._sheet.setRuleCss(r,n),this}mediaRootCss(e,t){return this.mediaCss(e,``,t)}minWidthCss(e,t){return this.mediaCss(`min-width:${this._sheet.getStyleValue(`width`,e)}`,``,t)}maxWidthCss(e,t){return this.mediaCss(`max-width:${this._sheet.getStyleValue(`width`,e)}`,``,t)}resolveNode(e){return typeof e==`string`||typeof e==`number`?String(e):e.dom}setStyleProp(e,t){return t===void 0?(this.dom.style.removeProperty(s(e)),this):(this.dom.style.setProperty(s(e),this._sheet.getStyleValue(e,t)),this)}setCssClassName(){let e=this._userClassName?`${this._userClassName} ${this.cssClassName}`:this.cssClassName;return this.isSvg?this.dom.setAttribute(`class`,e):this.dom.className=e,this}};function u(e){return new l(e)}function d(e){let t=document.querySelector(e);return new l(t.tagName.toLowerCase(),t)}var f=class extends l{constructor(){super(`a`)}href(e){return this._dom.href=e,this}},p=class extends l{constructor(){super(`button`)}type(e){return this.dom.type=e,this}},m=class extends l{constructor(e){super(`canvas`,e)}_size={width:this._dom.width,height:this._dom.height};getWidth(){return this._dom.width}getHeight(){return this._dom.height}width(e){return this._dom.width=e,this}height(e){return this._dom.height=e,this}setSize(e,t){return this._dom.width=e,this._dom.height=t,this}getSize(){return this._size.width=this._dom.width,this._size.height=this._dom.height,this._size}getAspect(){return this._dom.width/this._dom.height}getAspectScale(e){let t=this._dom.width/this._dom.height,n,r,i;return t>=1?(n=1/t,r=1,i=1):(n=1,r=t,i=1),e.x=n,e.y=r,e.z=i,e}},h=class{get dom(){return document.body}style(e){for(let t in e)this.dom.style[t]=this.getStyleValue(t,e[t]);return this}getStyleValue(t,n){return typeof n==`number`?e[t]?String(n):`${n}px`:n}add(...e){return this.dom.append(...e.map(e=>e.dom)),this}clear(){return this.dom.innerHTML=``,this}};function g(){return new h}var _=class extends l{constructor(){super(`iframe`)}src(e){return this._dom.src=e,this}allowFullscreen(e=!0){return this._dom.allowFullscreen=e,this}width(e){return this._dom.width=this._sheet.getStyleValue(`width`,e),this}height(e){return this._dom.height=this._sheet.getStyleValue(`height`,e),this}setSize(e,t){return this._dom.width=this._sheet.getStyleValue(`width`,e),this._dom.height=this._sheet.getStyleValue(`height`,t),this}reload(){this.dom.src=this.dom.src}},v=class extends l{constructor(){super(`img`)}src(e){return this._dom.src=e,this}width(e){return this._dom.width=e,this}height(e){return this._dom.height=e,this}setSize(e,t){return this._dom.width=e,this._dom.height=t,this}alt(e){return this.dom.alt=e,this}},y=class extends l{constructor(){super(`input`),this._dom.type=`checkbox`}name(e){return this._dom.name=e,this}checked(e){return this.prop(`checked`,e),this}isChecked(){return this.getProp(`checked`)}},b=class extends l{constructor(){super(`input`),this._dom.type=`color`}_rgb={r:1,g:1,b:1};name(e){return this._dom.name=e,this}value(e){return this._dom.value=e,this}getValue(){return this._dom.value}getRGB(){let e=this._dom.value,t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return this._rgb.r=t,this._rgb.g=n,this._rgb.b=r,this._rgb}getNormalizedRGB(){let e=this._dom.value,t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return this._rgb.r=t/255,this._rgb.g=n/255,this._rgb.b=r/255,this._rgb}},x=class extends l{constructor(){super(`input`),this._dom.type=`number`}name(e){return this._dom.name=e,this}value(e){return this._dom.value=String(e),this}getValue(){return Number(this._dom.value)}min(e){return this._dom.min=String(e),this}max(e){return this._dom.max=String(e),this}step(e){return this._dom.step=String(e),this}placeholder(e){return this.dom.placeholder=e,this}},S=class extends l{constructor(){super(`input`),this._dom.type=`range`}name(e){return this._dom.name=e,this}value(e){return this._dom.value=String(e),this}getValue(){return Number(this._dom.value)}min(e){return this._dom.min=String(e),this}max(e){return this._dom.max=String(e),this}step(e){return this._dom.step=String(e),this}},C=class extends l{constructor(){super(`input`),this._dom.type=`text`}name(e){return this._dom.name=e,this}value(e){return this._dom.value=e,this}getValue(){return this._dom.value}placeholder(e){return this.dom.placeholder=e,this}},w=class extends l{constructor(){super(`option`)}value(e){return this.dom.value=String(e),this}getValue(){return this.dom.value}},T=class extends l{constructor(){super(`progress`)}value(e){return this.dom.value=e,this}getValue(){return this.dom.value}max(e){return this.dom.max=e,this}getMax(){return this.dom.max}indeterminate(){return this.dom.removeAttribute(`value`),this}},E=class extends l{constructor(){super(`select`)}name(e){return this.dom.name=e,this}value(e){return this.dom.value=String(e),this}getValue(){return this.dom.value}};export{u as $,g as $body,d as $query,f as AnchorElement,p as Button,m as Canvas,h as DomBody,l as DomElement,_ as IFrame,v as ImageElement,y as InputCheckbox,b as InputColor,x as InputNumber,S as InputRange,C as InputText,i as MediaRule,w as OptionElement,T as ProgressElement,n as SVG_TAGS,E as SelectElement,c as StyleSheet,r as TAG_ALIAS,e as UNITLESS_CSS_PROPS,t as VENDOR_CSS_PROPS,s as camelToKebab,a as uniqueId};
1
+ const e={opacity:1,zIndex:1,fontWeight:1,lineHeight:1,flexGrow:1,flexShrink:1,order:1,zoom:1,scale:1,counterIncrement:1,counterReset:1,tabSize:1,orphans:1,widows:1,columns:1,columnCount:1,gridRow:1,gridColumn:1},t={WebkitAppearance:1},n=`svg.svgA.animate.animateMotion.animateTransform.circle.clipPath.defs.desc.ellipse.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.filter.foreignObject.g.image.line.linearGradient.marker.mask.metadata.mpath.path.pattern.polygon.polyline.radialGradient.rect.script.set.stop.style.switch.symbol.text.textPath.title.tspan.use.view`.split(`.`),r={svgA:`a`};var i=class{constructor(e,t){this._index=e,this._rule=t,this.cssMap=new Map}_index;_rule;cssMap;get index(){return this._index}get rule(){return this._rule}get length(){return this._rule.cssRules.length}getCssRule(e){let t=this.cssMap.get(e);return t??=this._rule.insertRule(`${e}{}`,this.length),this._rule.cssRules.item(t)}delete(e){this._rule.deleteRule(e)}};function a(){return`${Date.now().toString(36)}-${(o++).toString(36)}`}let o=0;function s(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}var c=class n{constructor(e){this._dom=e}_dom;get dom(){return this._dom}get sheet(){return this.dom.sheet}get length(){return this.sheet.cssRules.length}globalCss(e,t){let n=this.getCssRule(e);this.setRuleCss(n,t)}globalMediaCss(e,t,n){let r=this.getMediaRule(e).getCssRule(t);this.setRuleCss(r,n)}getCssRule(e){let t=this.getCssMap(),n=t.get(e);return n??(n=this.sheet.cssRules.length,this.sheet.insertRule(`${e}{}`,n),t.set(e,n)),this.sheet.cssRules.item(n)}deleteCssRule(e){let t=this.getCssMap(),n=t.get(e);n!=null&&(this.sheet.deleteRule(n),t.delete(e))}getMediaRule(e){let t=this.getMediaMap(),n=t.get(e);if(!n){let r=this.sheet.cssRules.length;this.sheet.insertRule(`@media(${e}){}`,r),n=new i(r,this.sheet.cssRules.item(r)),t.set(e,n)}return n}deleteMediaRule(e){let t=this.getMediaMap(),n=t.get(e);n!=null&&(this.sheet.deleteRule(n.index),t.delete(e))}setRuleCss(e,n){for(let r in n){let i=!!t[r],a=s(r);e.style.setProperty(i?`-${a}`:a,this.getStyleValue(r,n[r]))}}getStyleValue(t,n){return typeof n==`number`?e[t]?String(n):`${n}px`:n}getCssMap(){let e=l.get(this.sheet);return e||(e=new Map,l.set(this.sheet,e)),e}getMediaMap(){let e=u.get(this.sheet);return e||(e=new Map,u.set(this.sheet,e)),e}static getSheet(e=n.DEFAULT_STYLE_ID){let t=document.head.querySelector(`#${e}`);if(t==null){let t=document.createElement(`style`);return t.id=e,t.setAttribute(`type`,`text/css`),document.head.append(t),new n(t)}else return new n(t)}static DEFAULT_STYLE_ID=`__neptune-style__`};const l=new WeakMap,u=new WeakMap;var d=class{constructor(e,t){this._tag=r[e]??e,this._isSvg=n.includes(this._tag),this._dom=t??(this._isSvg?document.createElementNS(`http://www.w3.org/2000/svg`,this._tag):document.createElement(this._tag)),this._sheet=c.getSheet()}_tag;_isSvg;_dom;_sheet;_cssClassName;_userClassName;get tag(){return this._tag}get isSvg(){return this._isSvg}get dom(){return this._dom}get cssClassName(){return this._cssClassName||=a(),this._cssClassName}getText(){return this._dom.textContent}text(e){return this._dom.textContent=e==null?``:String(e),this}add(...e){return this._dom.append(...e.map(e=>this.resolveNode(e))),this}insertAtIndex(e,...t){let n=Array.from(this.dom.children),r=Math.max(0,Math.min(e,n.length));for(let e of t){let t=n[r]??null;this.dom.insertBefore(this.resolveNode(e),t),r++}return this}setChildren(...e){return this.clear().add(...e)}setChildrenFromIndex(e,...t){let n=Array.from(this._dom.children),r=n.length,i=Math.max(0,Math.min(e,r));for(let e=i;e<r;e++)this._dom.removeChild(n[e]);let a=this._dom.children[i]??null;for(let e of t)this._dom.insertBefore(this.resolveNode(e),a);return this}remove(){this.dom.remove()}clear(e,t){let n=Array.from(this._dom.children),r=Math.max(0,e??0),i=Math.min(n.length,t??n.length);for(let e=r;e<i;e++)this._dom.removeChild(n[e]);return this}on(e,t,n){return this._dom.addEventListener(e,t,n),this}off(e,t,n){this._dom.removeEventListener(e,t,n)}getAttr(e){return this.dom.getAttribute(e)}attr(e,t){return t===void 0?this.dom.removeAttribute(e):this.dom.setAttribute(e,String(t)),this}attrs(e){for(let[t,n]of Object.entries(e))this.attr(t,n);return this}getProp(e){return this.dom[e]}prop(e,t){return this.dom[e]=t,this}props(e){for(let[t,n]of Object.entries(e))this.prop(t,n);return this}style(e){for(let t of Object.keys(e))this.setStyleProp(t,e[t]);return this}id(e){return this._dom.id=e??``,this}className(e){this._userClassName=e??``;let t=this._cssClassName?`${this._userClassName} ${this.cssClassName}`.trim():this._userClassName;return this.dom.setAttribute(`class`,t),this}htmlFor(e){return this.tag===`label`&&(this.dom.htmlFor=e??``),this}title(e){return e===void 0?this.dom.removeAttribute(`title`):this.dom.setAttribute(`title`,e),this}disabled(e){return e?this.dom.setAttribute(`disabled`,``):this.dom.removeAttribute(`disabled`),this}disable(){return this.disabled(!0)}enable(){return this.disabled(!1)}p(e){return this.setStyleProp(`padding`,e)}pt(e){return this.setStyleProp(`paddingTop`,e)}pr(e){return this.setStyleProp(`paddingRight`,e)}pb(e){return this.setStyleProp(`paddingBottom`,e)}pl(e){return this.setStyleProp(`paddingLeft`,e)}px(e){return this.pl(e).pr(e)}py(e){return this.pt(e).pb(e)}m(e){return this.setStyleProp(`margin`,e)}mt(e){return this.setStyleProp(`marginTop`,e)}mr(e){return this.setStyleProp(`marginRight`,e)}mb(e){return this.setStyleProp(`marginBottom`,e)}ml(e){return this.setStyleProp(`marginLeft`,e)}radius(e){return this.setStyleProp(`borderRadius`,e)}radiusTopLeft(e){return this.setStyleProp(`borderTopLeftRadius`,e)}radiusTopRight(e){return this.setStyleProp(`borderTopRightRadius`,e)}radiusBottomLeft(e){return this.setStyleProp(`borderBottomLeftRadius`,e)}radiusBottomRight(e){return this.setStyleProp(`borderBottomRightRadius`,e)}radiusTop(e){return this.radiusTopLeft(e).radiusTopRight(e)}radiusBottom(e){return this.radiusBottomLeft(e).radiusBottomRight(e)}radiusLeft(e){return this.radiusTopLeft(e).radiusBottomLeft(e)}radiusRight(e){return this.radiusTopRight(e).radiusBottomRight(e)}radiusX(e){return this.radiusLeft(e).radiusRight(e)}radiusY(e){return this.radiusTop(e).radiusBottom(e)}display(e){return this.setStyleProp(`display`,e)}flexShrink(e){return this.setStyleProp(`flexShrink`,e)}flex(e){return this.setStyleProp(`flex`,e)}bgColor(e){return this.setStyleProp(`backgroundColor`,e)}color(e){return this.setStyleProp(`color`,e)}w(e){return this.setStyleProp(`width`,e)}h(e){return this.setStyleProp(`height`,e)}b(e){return this.setStyleProp(`border`,e)}bt(e){return this.setStyleProp(`borderTop`,e)}br(e){return this.setStyleProp(`borderRight`,e)}bb(e){return this.setStyleProp(`borderBottom`,e)}bl(e){return this.setStyleProp(`borderLeft`,e)}bx(e){return this.setStyleProp(`borderLeft`,e),this.setStyleProp(`borderRight`,e),this}by(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderBottom`,e),this}btl(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderLeft`,e),this}btr(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderRight`,e),this}bbl(e){return this.setStyleProp(`borderBottom`,e),this.setStyleProp(`borderLeft`,e),this}bbr(e){return this.setStyleProp(`borderBottom`,e),this.setStyleProp(`borderRight`,e),this}overflow(e){return this.setStyleProp(`overflow`,e)}overflowY(e){return this.setStyleProp(`overflowY`,e)}overflowX(e){return this.setStyleProp(`overflowX`,e)}fontSize(e){return this.setStyleProp(`fontSize`,e)}fontWeight(e){return this.setStyleProp(`fontWeight`,e)}fontFamily(e){return this.setStyleProp(`fontFamily`,e)}fontStyle(e){return this.setStyleProp(`fontStyle`,e)}textAlign(e){return this.setStyleProp(`textAlign`,e)}textDecoration(e){return this.setStyleProp(`textDecoration`,e)}pos(e){return this.setStyleProp(`position`,e)}posTop(e){return this.setStyleProp(`top`,e)}posBottom(e){return this.setStyleProp(`bottom`,e)}posLeft(e){return this.setStyleProp(`left`,e)}posRight(e){return this.setStyleProp(`right`,e)}cursor(e){return this.setStyleProp(`cursor`,e)}alignItems(e){return this.setStyleProp(`alignItems`,e)}justifyContent(e){return this.setStyleProp(`justifyContent`,e)}gap(e){return this.setStyleProp(`gap`,e)}flexDirection(e){return this.setStyleProp(`flexDirection`,e)}templateColumns(e){return this.setStyleProp(`gridTemplateColumns`,e)}templateRows(e){return this.setStyleProp(`gridTemplateRows`,e)}appearance(e){return this.setStyleProp(`appearance`,e)}userSelect(e){return this.setStyleProp(`userSelect`,e)}verticalAlign(e){return this.setStyleProp(`verticalAlign`,e)}overflowEllipsis(){return this.style({overflow:`hidden`,whiteSpace:`nowrap`,textOverflow:`ellipsis`})}ref(e){return e(this),this}css(e,t){this.setCssClassName();let n=this._sheet.getCssRule(`.${this.cssClassName}${e}`);return this._sheet.setRuleCss(n,t),this}rootCss(e){return this.css(``,e)}hoverCss(e){return this.css(`:hover`,e)}activeCss(e){return this.css(`:active`,e)}focusCss(e){return this.css(`:focus`,e)}focusWithinCss(e){return this.css(`:focus-within`,e)}mediaCss(e,t,n){this.setCssClassName();let r=this._sheet.getMediaRule(e).getCssRule(`.${this.cssClassName}${t}`);return this._sheet.setRuleCss(r,n),this}mediaRootCss(e,t){return this.mediaCss(e,``,t)}minWidthCss(e,t){return this.mediaCss(`min-width:${this._sheet.getStyleValue(`width`,e)}`,``,t)}maxWidthCss(e,t){return this.mediaCss(`max-width:${this._sheet.getStyleValue(`width`,e)}`,``,t)}resolveNode(e){return typeof e==`string`||typeof e==`number`?document.createTextNode(String(e)):`dom`in e?e.dom:e}setStyleProp(e,t){return t===void 0?(this.dom.style.removeProperty(s(e)),this):(this.dom.style.setProperty(s(e),this._sheet.getStyleValue(e,t)),this)}setCssClassName(){let e=this._userClassName?`${this._userClassName} ${this.cssClassName}`:this.cssClassName;return this.isSvg?this.dom.setAttribute(`class`,e):this.dom.className=e,this}};function f(e){return new d(e)}function p(e){let t=document.querySelector(e);return new d(t.tagName.toLowerCase(),t)}var m=class extends d{constructor(){super(`a`)}href(e){return this._dom.href=e,this}},h=class extends d{constructor(){super(`button`)}type(e){return this.dom.type=e,this}disabledCss(e){return this.css(`:disabled`,e)}},g=class extends d{constructor(e){super(`canvas`,e)}_size={width:this._dom.width,height:this._dom.height};getWidth(){return this._dom.width}getHeight(){return this._dom.height}width(e){return this._dom.width=e,this}height(e){return this._dom.height=e,this}setSize(e,t){return this._dom.width=e,this._dom.height=t,this}getSize(){return this._size.width=this._dom.width,this._size.height=this._dom.height,this._size}getAspect(){return this._dom.width/this._dom.height}getAspectScale(e){let t=this._dom.width/this._dom.height,n,r,i;return t>=1?(n=1/t,r=1,i=1):(n=1,r=t,i=1),e.x=n,e.y=r,e.z=i,e}},_=class{get dom(){return document.body}style(e){for(let t in e)this.dom.style[t]=this.getStyleValue(t,e[t]);return this}getStyleValue(t,n){return typeof n==`number`?e[t]?String(n):`${n}px`:n}add(...e){return this.dom.append(...e.map(e=>e.dom)),this}clear(){return this.dom.innerHTML=``,this}};function v(){return new _}var y=class extends d{constructor(){super(`iframe`)}src(e){return this._dom.src=e,this}allowFullscreen(e=!0){return this._dom.allowFullscreen=e,this}width(e){return this._dom.width=this._sheet.getStyleValue(`width`,e),this}height(e){return this._dom.height=this._sheet.getStyleValue(`height`,e),this}setSize(e,t){return this._dom.width=this._sheet.getStyleValue(`width`,e),this._dom.height=this._sheet.getStyleValue(`height`,t),this}reload(){this.dom.src=this.dom.src}},b=class extends d{constructor(){super(`img`)}src(e){return this._dom.src=e,this}width(e){return this._dom.width=e,this}height(e){return this._dom.height=e,this}setSize(e,t){return this._dom.width=e,this._dom.height=t,this}alt(e){return this.dom.alt=e,this}},x=class extends d{constructor(){super(`input`),this._dom.type=`checkbox`}name(e){return this._dom.name=e,this}checked(e){return this.prop(`checked`,e),this}isChecked(){return this.getProp(`checked`)}disabledCss(e){return this.css(`:disabled`,e)}},S=class extends d{constructor(){super(`input`),this._dom.type=`color`}_rgb={r:1,g:1,b:1};name(e){return this._dom.name=e,this}value(e){return this._dom.value=e,this}getValue(){return this._dom.value}getRGB(){let e=this._dom.value,t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return this._rgb.r=t,this._rgb.g=n,this._rgb.b=r,this._rgb}getNormalizedRGB(){let e=this._dom.value,t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return this._rgb.r=t/255,this._rgb.g=n/255,this._rgb.b=r/255,this._rgb}disabledCss(e){return this.css(`:disabled`,e)}},C=class extends d{constructor(){super(`input`),this._dom.type=`number`}name(e){return this._dom.name=e,this}value(e){return this._dom.value=String(e),this}getValue(){return Number(this._dom.value)}min(e){return this._dom.min=String(e),this}max(e){return this._dom.max=String(e),this}step(e){return this._dom.step=String(e),this}placeholder(e){return this.dom.placeholder=e,this}disabledCss(e){return this.css(`:disabled`,e)}},w=class extends d{constructor(){super(`input`),this._dom.type=`range`}name(e){return this._dom.name=e,this}value(e){return this._dom.value=String(e),this}getValue(){return Number(this._dom.value)}min(e){return this._dom.min=String(e),this}max(e){return this._dom.max=String(e),this}step(e){return this._dom.step=String(e),this}disabledCss(e){return this.css(`:disabled`,e)}},T=class extends d{constructor(){super(`input`),this._dom.type=`text`}name(e){return this._dom.name=e,this}value(e){return this._dom.value=e,this}getValue(){return this._dom.value}placeholder(e){return this.dom.placeholder=e,this}disabledCss(e){return this.css(`:disabled`,e)}},E=class extends d{constructor(){super(`option`)}value(e){return this.dom.value=String(e),this}getValue(){return this.dom.value}},D=class extends d{constructor(){super(`progress`)}value(e){return this.dom.value=e,this}getValue(){return this.dom.value}max(e){return this.dom.max=e,this}getMax(){return this.dom.max}indeterminate(){return this.dom.removeAttribute(`value`),this}},O=class extends d{constructor(){super(`select`)}name(e){return this.dom.name=e,this}value(e){return this.dom.value=String(e),this}getValue(){return this.dom.value}};export{f as $,v as $body,p as $query,m as AnchorElement,h as Button,g as Canvas,_ as DomBody,d as DomElement,y as IFrame,b as ImageElement,x as InputCheckbox,S as InputColor,C as InputNumber,w as InputRange,T as InputText,i as MediaRule,E as OptionElement,D as ProgressElement,n as SVG_TAGS,O as SelectElement,c as StyleSheet,r as TAG_ALIAS,e as UNITLESS_CSS_PROPS,t as VENDOR_CSS_PROPS,s as camelToKebab,a as uniqueId};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neptune3d/dom",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Helper classes and functions for the DOM.",
5
5
  "type": "module",
6
6
  "license": "MIT",