juxscript 1.1.313 → 1.1.314
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,44 @@
|
|
|
1
|
+
type GridDensity = 'dense' | 'normal' | 'inflated';
|
|
2
|
+
interface GridOptions {
|
|
3
|
+
rows?: number;
|
|
4
|
+
cols?: number;
|
|
5
|
+
density?: GridDensity;
|
|
6
|
+
class?: string;
|
|
7
|
+
style?: string;
|
|
8
|
+
target?: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
declare class Grid {
|
|
12
|
+
id: string;
|
|
13
|
+
opts: GridOptions;
|
|
14
|
+
private _element;
|
|
15
|
+
constructor(id: string, options?: GridOptions);
|
|
16
|
+
getValue(): string;
|
|
17
|
+
getContent(): string;
|
|
18
|
+
setContent(val: string): this;
|
|
19
|
+
setClass(val: string): this;
|
|
20
|
+
setStyle(val: string): this;
|
|
21
|
+
setInnerHTML(val: string): this;
|
|
22
|
+
getElement(): HTMLElement;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a CSS grid layout container.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // 3-column grid, normal spacing
|
|
29
|
+
* jux.grid('cards', { cols: 3 });
|
|
30
|
+
*
|
|
31
|
+
* // 2x4 tight grid
|
|
32
|
+
* jux.grid('dashboard', { cols: 4, rows: 2, density: 'dense' });
|
|
33
|
+
*
|
|
34
|
+
* // Spacious 2-col grid inside a target
|
|
35
|
+
* jux.grid('content', { cols: 2, density: 'inflated', target: 'main' });
|
|
36
|
+
*
|
|
37
|
+
* // Add children into it
|
|
38
|
+
* jux.div('cell-1', { content: 'A', target: 'cards' });
|
|
39
|
+
* jux.div('cell-2', { content: 'B', target: 'cards' });
|
|
40
|
+
*/
|
|
41
|
+
export declare function grid(id: string, options?: GridOptions): Grid;
|
|
42
|
+
export { Grid, GridOptions, GridDensity };
|
|
43
|
+
export default grid;
|
|
44
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../lib/components/grid.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEnD,UAAU,WAAW;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAQD,cAAM,IAAI;IACN,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,QAAQ,CAAc;gBAElB,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IA0CjD,QAAQ,IAAI,MAAM;IAClB,UAAU,IAAI,MAAM;IAEpB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK7B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK3B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK3B,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK/B,UAAU,IAAI,WAAW;CAC5B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAIhE;AAED,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AAC1C,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import generateId from '../utils/idgen.js';
|
|
2
|
+
import { pageState } from '../state/pageState.js';
|
|
3
|
+
const DENSITY_MAP = {
|
|
4
|
+
dense: { gap: '4px', padding: '4px' },
|
|
5
|
+
normal: { gap: '12px', padding: '12px' },
|
|
6
|
+
inflated: { gap: '24px', padding: '24px' },
|
|
7
|
+
};
|
|
8
|
+
class Grid {
|
|
9
|
+
constructor(id, options = {}) {
|
|
10
|
+
this.id = id || generateId();
|
|
11
|
+
this.opts = {
|
|
12
|
+
cols: 2,
|
|
13
|
+
density: 'normal',
|
|
14
|
+
...options
|
|
15
|
+
};
|
|
16
|
+
this._element = document.createElement('div');
|
|
17
|
+
this._element.id = this.id;
|
|
18
|
+
if (this.opts.class)
|
|
19
|
+
this._element.className = this.opts.class;
|
|
20
|
+
const d = DENSITY_MAP[this.opts.density] || DENSITY_MAP.normal;
|
|
21
|
+
const parts = [
|
|
22
|
+
'display:grid',
|
|
23
|
+
`grid-template-columns:repeat(${this.opts.cols}, 1fr)`,
|
|
24
|
+
`gap:${d.gap}`,
|
|
25
|
+
`padding:${d.padding}`,
|
|
26
|
+
];
|
|
27
|
+
if (this.opts.rows) {
|
|
28
|
+
parts.push(`grid-template-rows:repeat(${this.opts.rows}, auto)`);
|
|
29
|
+
}
|
|
30
|
+
if (this.opts.style)
|
|
31
|
+
parts.push(this.opts.style);
|
|
32
|
+
this._element.setAttribute('style', parts.join(';'));
|
|
33
|
+
// Extra attributes
|
|
34
|
+
for (const [key, value] of Object.entries(this.opts)) {
|
|
35
|
+
if (['rows', 'cols', 'density', 'class', 'style', 'target'].includes(key))
|
|
36
|
+
continue;
|
|
37
|
+
this._element.setAttribute(`data-${key}`, String(value));
|
|
38
|
+
}
|
|
39
|
+
const resolvedTarget = this.opts.target;
|
|
40
|
+
const parent = resolvedTarget
|
|
41
|
+
? document.getElementById(resolvedTarget) || document.querySelector(resolvedTarget)
|
|
42
|
+
: document.getElementById('app');
|
|
43
|
+
parent?.appendChild(this._element);
|
|
44
|
+
}
|
|
45
|
+
// ═══════════════════════════════════════════════════════════
|
|
46
|
+
// PAGESTATE INTEGRATION
|
|
47
|
+
// ═══════════════════════════════════════════════════════════
|
|
48
|
+
getValue() { return ''; }
|
|
49
|
+
getContent() { return this._element.textContent ?? ''; }
|
|
50
|
+
setContent(val) {
|
|
51
|
+
this._element.textContent = val;
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
setClass(val) {
|
|
55
|
+
this._element.className = val;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
setStyle(val) {
|
|
59
|
+
this._element.setAttribute('style', val);
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
setInnerHTML(val) {
|
|
63
|
+
this._element.innerHTML = val;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
getElement() { return this._element; }
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a CSS grid layout container.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // 3-column grid, normal spacing
|
|
73
|
+
* jux.grid('cards', { cols: 3 });
|
|
74
|
+
*
|
|
75
|
+
* // 2x4 tight grid
|
|
76
|
+
* jux.grid('dashboard', { cols: 4, rows: 2, density: 'dense' });
|
|
77
|
+
*
|
|
78
|
+
* // Spacious 2-col grid inside a target
|
|
79
|
+
* jux.grid('content', { cols: 2, density: 'inflated', target: 'main' });
|
|
80
|
+
*
|
|
81
|
+
* // Add children into it
|
|
82
|
+
* jux.div('cell-1', { content: 'A', target: 'cards' });
|
|
83
|
+
* jux.div('cell-2', { content: 'B', target: 'cards' });
|
|
84
|
+
*/
|
|
85
|
+
export function grid(id, options = {}) {
|
|
86
|
+
const g = new Grid(id, options);
|
|
87
|
+
pageState.__register(g);
|
|
88
|
+
return g;
|
|
89
|
+
}
|
|
90
|
+
export { Grid };
|
|
91
|
+
export default grid;
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { tabs } from "./components/tabs.js";
|
|
|
16
16
|
import { button, btn } from "./components/button.js";
|
|
17
17
|
import { link, a } from "./components/link.js";
|
|
18
18
|
import { container } from "./components/container.js";
|
|
19
|
+
import { grid } from "./components/grid.js";
|
|
19
20
|
export declare const jux: {
|
|
20
21
|
tag: typeof tag;
|
|
21
22
|
div: typeof div;
|
|
@@ -61,6 +62,7 @@ export declare const jux: {
|
|
|
61
62
|
link: typeof link;
|
|
62
63
|
a: typeof a;
|
|
63
64
|
container: typeof container;
|
|
65
|
+
grid: typeof grid;
|
|
64
66
|
};
|
|
65
67
|
export { pageState };
|
|
66
68
|
//# 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,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3I,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,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AAI,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;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCf,CAAA;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/lib/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { tabs } from "./components/tabs.js";
|
|
|
16
16
|
import { button, btn } from "./components/button.js";
|
|
17
17
|
import { link, a } from "./components/link.js";
|
|
18
18
|
import { container } from "./components/container.js";
|
|
19
|
+
import { grid } from "./components/grid.js";
|
|
19
20
|
export const jux = {
|
|
20
21
|
tag,
|
|
21
22
|
div,
|
|
@@ -55,7 +56,8 @@ export const jux = {
|
|
|
55
56
|
btn,
|
|
56
57
|
link,
|
|
57
58
|
a,
|
|
58
|
-
container
|
|
59
|
+
container,
|
|
60
|
+
grid
|
|
59
61
|
};
|
|
60
62
|
export { pageState };
|
|
61
63
|
jux.watch = pageState.__watch;
|