nuclo 0.1.46 → 0.1.48

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.
@@ -1 +1 @@
1
- {"version":3,"file":"renderables.d.ts","sourceRoot":"","sources":["../../src/utility/renderables.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,EAChF,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,EAC/B,KAAK,EAAE,MAAM,GACZ,eAAe,CAAC,QAAQ,CAAC,GAAG,IAAI,CAclC"}
1
+ {"version":3,"file":"renderables.d.ts","sourceRoot":"","sources":["../../src/utility/renderables.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,IACjE,SAAS,CAAC,QAAQ,CAAC,GACnB,eAAe,CAAC,QAAQ,CAAC,GACzB,IAAI,GACJ,IAAI,GACJ,SAAS,CAAC;AAEd,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,EAChF,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,EACjC,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,EAC/B,KAAK,EAAE,MAAM,GACZ,eAAe,CAAC,QAAQ,CAAC,GAAG,IAAI,CAclC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuclo",
3
3
  "private": false,
4
- "version": "0.1.46",
4
+ "version": "0.1.48",
5
5
  "type": "module",
6
6
  "main": "./dist/nuclo.cjs",
7
7
  "module": "./dist/nuclo.js",
@@ -33,8 +33,8 @@ declare global {
33
33
  | (() => Primitive)
34
34
  | ExpandedElementAttributes<TTagName>
35
35
  | ExpandedElement<TTagName>
36
- | SVGElement // Allow SVG elements as children of HTML elements
37
- | ((parent?: any, index?: number) => SVGElement); // Allow SVG element builders
36
+ | Node // Allow any DOM Node (including Comment, Text, SVGElement, etc.)
37
+ | ((parent: ExpandedElement<TTagName>, index: number) => Node); // Allow Node builders
38
38
 
39
39
  export type NodeModFn<TTagName extends ElementTagName = ElementTagName> = (
40
40
  parent: ExpandedElement<TTagName>,
@@ -0,0 +1,126 @@
1
+ // Style utility functions type definitions
2
+
3
+ /**
4
+ * Creates a CSS class with the given styles and injects it into the document
5
+ */
6
+ declare global {
7
+ function createCSSClass(className: string, styles: Record<string, string>): void;
8
+
9
+ /**
10
+ * Creates a breakpoint-aware class name generator
11
+ */
12
+ function createBreakpoints<T extends string>(
13
+ breakpoints: Record<T, string>
14
+ ): (styles?: Partial<Record<T, StyleBuilder>>) => string;
15
+
16
+ /**
17
+ * Style builder class for chaining CSS properties
18
+ */
19
+ class StyleBuilder {
20
+ getStyles(): Record<string, string>;
21
+ add(property: string, value: string): this;
22
+
23
+ // Display
24
+ display(value: string): this;
25
+ flex(value?: string): this;
26
+ grid(): this;
27
+
28
+ // Colors
29
+ bg(color: string): this;
30
+ color(color: string): this;
31
+ accentColor(value: string): this;
32
+
33
+ // Typography
34
+ fontSize(size: string): this;
35
+ fontWeight(value: string): this;
36
+ fontFamily(value: string): this;
37
+ lineHeight(value: string): this;
38
+ letterSpacing(value: string): this;
39
+ textAlign(value: string): this;
40
+ textDecoration(value: string): this;
41
+ bold(): this;
42
+
43
+ // Layout
44
+ position(value: string): this;
45
+ padding(value: string): this;
46
+ margin(value: string): this;
47
+ width(value: string): this;
48
+ height(value: string): this;
49
+ minWidth(value: string): this;
50
+ maxWidth(value: string): this;
51
+ minHeight(value: string): this;
52
+
53
+ // Flexbox
54
+ flexDirection(value: string): this;
55
+ alignItems(value: string): this;
56
+ justifyContent(value: string): this;
57
+ center(): this;
58
+ gap(value: string): this;
59
+
60
+ // Borders
61
+ border(value: string): this;
62
+ borderRadius(value: string): this;
63
+ outline(value: string): this;
64
+
65
+ // Effects
66
+ boxShadow(value: string): this;
67
+ opacity(value: string): this;
68
+ transition(value: string): this;
69
+
70
+ // Interaction
71
+ cursor(value: string): this;
72
+ }
73
+
74
+ // Utility functions that return StyleBuilders
75
+ // Display
76
+ function display(value: string): StyleBuilder;
77
+ function flex(value?: string): StyleBuilder;
78
+ function grid(): StyleBuilder;
79
+
80
+ // Colors
81
+ function bg(color: string): StyleBuilder;
82
+ function color(colorValue: string): StyleBuilder;
83
+ function accentColor(value: string): StyleBuilder;
84
+
85
+ // Typography
86
+ function fontSize(size: string): StyleBuilder;
87
+ function fontWeight(value: string): StyleBuilder;
88
+ function fontFamily(value: string): StyleBuilder;
89
+ function lineHeight(value: string): StyleBuilder;
90
+ function letterSpacing(value: string): StyleBuilder;
91
+ function textAlign(value: string): StyleBuilder;
92
+ function textDecoration(value: string): StyleBuilder;
93
+ function bold(): StyleBuilder;
94
+
95
+ // Layout
96
+ function position(value: string): StyleBuilder;
97
+ function padding(value: string): StyleBuilder;
98
+ function margin(value: string): StyleBuilder;
99
+ function width(value: string): StyleBuilder;
100
+ function height(value: string): StyleBuilder;
101
+ function minWidth(value: string): StyleBuilder;
102
+ function maxWidth(value: string): StyleBuilder;
103
+ function minHeight(value: string): StyleBuilder;
104
+
105
+ // Flexbox
106
+ function flexDirection(value: string): StyleBuilder;
107
+ function alignItems(value: string): StyleBuilder;
108
+ function justifyContent(value: string): StyleBuilder;
109
+ function center(): StyleBuilder;
110
+ function gap(value: string): StyleBuilder;
111
+
112
+ // Borders
113
+ function border(value: string): StyleBuilder;
114
+ function borderRadius(value: string): StyleBuilder;
115
+ function outline(value: string): StyleBuilder;
116
+
117
+ // Effects
118
+ function boxShadow(value: string): StyleBuilder;
119
+ function opacity(value: string): StyleBuilder;
120
+ function transition(value: string): StyleBuilder;
121
+
122
+ // Interaction
123
+ function cursor(value: string): StyleBuilder;
124
+ }
125
+
126
+ export {};
package/types/index.d.ts CHANGED
@@ -8,17 +8,18 @@ import "./features/when";
8
8
  import "./features/update";
9
9
  import "./features/on";
10
10
  import "./features/render";
11
+ import "./features/style";
11
12
 
12
13
  // Re-export on() helper for module-style consumers (import { on } from "nuclo")
13
- export function on<K extends keyof HTMLElementEventMap>(
14
+ export function on<K extends keyof HTMLElementEventMap, TTagName extends ElementTagName = ElementTagName>(
14
15
  type: K,
15
- listener: (ev: HTMLElementEventMap[K]) => any,
16
+ listener: (ev: HTMLElementEventMap[K]) => unknown,
16
17
  options?: boolean | AddEventListenerOptions
17
- ): NodeModFn<any>;
18
- export function on<K extends string, E extends Event = Event>(
18
+ ): NodeModFn<TTagName>;
19
+ export function on<K extends string, E extends Event = Event, TTagName extends ElementTagName = ElementTagName>(
19
20
  type: K,
20
- listener: (ev: E) => any,
21
+ listener: (ev: E) => unknown,
21
22
  options?: boolean | AddEventListenerOptions
22
- ): NodeModFn<any>;
23
+ ): NodeModFn<TTagName>;
23
24
 
24
25
  export {};
@@ -77,20 +77,22 @@ declare global {
77
77
  | SVGAttributes
78
78
  | SVGElementTagNameMap[TTagName]
79
79
  | SVGElement // Allow any SVG element as a child
80
- | ((parent?: any, index?: number) => SVGElement); // Allow SVG element builders as children
80
+ | ((parent: SVGElementTagNameMap[TTagName], index: number) => SVGElement); // Allow SVG element builders as children
81
81
 
82
82
  export type SVGElementModifierFn<TTagName extends keyof SVGElementTagNameMap = keyof SVGElementTagNameMap> = (
83
83
  parent: SVGElementTagNameMap[TTagName],
84
84
  index: number,
85
85
  ) => SVGElementModifier<TTagName> | void;
86
86
 
87
- // SVG builder type
87
+ // SVG builder type - returns a NodeModFn-compatible function
88
+ // Parameters are optional to allow standalone usage (e.g., svg()() for creating detached SVG)
89
+ // but the function signature is compatible with NodeModFn when used as a child
88
90
  export type ExpandedSVGElementBuilder<
89
91
  TTagName extends keyof SVGElementTagNameMap = keyof SVGElementTagNameMap,
90
92
  > = (
91
93
  ...rawMods: Array<SVGElementModifier<TTagName> | SVGElementModifierFn<TTagName>>
92
94
  ) => (
93
- parent?: SVGElementTagNameMap[TTagName],
95
+ parent?: SVGElementTagNameMap[TTagName] | ExpandedElement<ElementTagName>,
94
96
  index?: number,
95
97
  ) => SVGElementTagNameMap[TTagName];
96
98
  }