juxscript 1.1.298 → 1.1.299

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,27 @@
1
+ declare class Style {
2
+ id: string;
3
+ private _element;
4
+ constructor(id: string, css: string);
5
+ /** Replace the entire stylesheet content */
6
+ setContent(css: string): this;
7
+ /** Append additional CSS rules */
8
+ append(css: string): this;
9
+ /** Get current CSS content */
10
+ getContent(): string;
11
+ /** Remove the style tag from the document */
12
+ remove(): void;
13
+ getElement(): HTMLStyleElement;
14
+ }
15
+ /**
16
+ * Inject a CSS string into the document head.
17
+ *
18
+ * @example
19
+ * jux.style('my-styles', `
20
+ * .sidebar { background: hsl(var(--card)); }
21
+ * .nav-item:hover { background: hsl(var(--accent)); }
22
+ * `);
23
+ */
24
+ export declare function style(id: string, css: string): Style;
25
+ export { Style };
26
+ export default style;
27
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../lib/components/style.ts"],"names":[],"mappings":"AAEA,cAAM,KAAK;IACP,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,QAAQ,CAAmB;gBAEvB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IASnC,4CAA4C;IAC5C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK7B,kCAAkC;IAClC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKzB,8BAA8B;IAC9B,UAAU,IAAI,MAAM;IAIpB,6CAA6C;IAC7C,MAAM,IAAI,IAAI;IAId,UAAU,IAAI,gBAAgB;CAGjC;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,CAQpD;AAED,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,eAAe,KAAK,CAAC"}
@@ -0,0 +1,52 @@
1
+ import generateId from '../utils/idgen.js';
2
+ class Style {
3
+ constructor(id, css) {
4
+ this.id = id || generateId();
5
+ this._element = document.createElement('style');
6
+ this._element.id = this.id;
7
+ this._element.setAttribute('data-jux-style', '');
8
+ this._element.textContent = css;
9
+ document.head.appendChild(this._element);
10
+ }
11
+ /** Replace the entire stylesheet content */
12
+ setContent(css) {
13
+ this._element.textContent = css;
14
+ return this;
15
+ }
16
+ /** Append additional CSS rules */
17
+ append(css) {
18
+ this._element.textContent += '\n' + css;
19
+ return this;
20
+ }
21
+ /** Get current CSS content */
22
+ getContent() {
23
+ return this._element.textContent ?? '';
24
+ }
25
+ /** Remove the style tag from the document */
26
+ remove() {
27
+ this._element.remove();
28
+ }
29
+ getElement() {
30
+ return this._element;
31
+ }
32
+ }
33
+ /**
34
+ * Inject a CSS string into the document head.
35
+ *
36
+ * @example
37
+ * jux.style('my-styles', `
38
+ * .sidebar { background: hsl(var(--card)); }
39
+ * .nav-item:hover { background: hsl(var(--accent)); }
40
+ * `);
41
+ */
42
+ export function style(id, css) {
43
+ // If a style with this id already exists, update it
44
+ const existing = document.getElementById(id);
45
+ if (existing && existing instanceof HTMLStyleElement) {
46
+ existing.textContent = css;
47
+ return Object.assign(new Style('__skip__', ''), { _element: existing, id });
48
+ }
49
+ return new Style(id, css);
50
+ }
51
+ export { Style };
52
+ export default style;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juxscript",
3
- "version": "1.1.298",
3
+ "version": "1.1.299",
4
4
  "type": "module",
5
5
  "description": "A JavaScript UX authorship platform",
6
6
  "main": "./dist/lib/index.js",