juxscript 1.1.298 → 1.1.300
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/dist/lib/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { pageState } from "./state/pageState.js";
|
|
|
8
8
|
import { data } from "./components/data.js";
|
|
9
9
|
import { store } from "./components/store.js";
|
|
10
10
|
import { devtools } from "./devtools/devtools.js";
|
|
11
|
+
import { style } from "./components/style.js";
|
|
11
12
|
export declare const jux: {
|
|
12
13
|
tag: typeof tag;
|
|
13
14
|
div: typeof div;
|
|
@@ -29,6 +30,7 @@ export declare const jux: {
|
|
|
29
30
|
data: typeof data;
|
|
30
31
|
store: typeof store;
|
|
31
32
|
devtools: typeof devtools;
|
|
33
|
+
style: typeof style;
|
|
32
34
|
};
|
|
33
35
|
export { pageState };
|
|
34
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;CAiBf,CAAA;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/lib/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { pageState } from "./state/pageState.js";
|
|
|
8
8
|
import { data } from "./components/data.js";
|
|
9
9
|
import { store } from "./components/store.js";
|
|
10
10
|
import { devtools } from "./devtools/devtools.js";
|
|
11
|
+
import { style } from "./components/style.js";
|
|
11
12
|
export const jux = {
|
|
12
13
|
tag,
|
|
13
14
|
div,
|
|
@@ -23,7 +24,8 @@ export const jux = {
|
|
|
23
24
|
checkboxGroup,
|
|
24
25
|
data,
|
|
25
26
|
store,
|
|
26
|
-
devtools
|
|
27
|
+
devtools,
|
|
28
|
+
style
|
|
27
29
|
};
|
|
28
30
|
export { pageState };
|
|
29
31
|
jux.watch = pageState.__watch;
|