juxscript 1.1.307 → 1.1.308

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,58 @@
1
+ interface ContainerOptions {
2
+ layout?: 'flex' | 'grid' | 'block';
3
+ direction?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
4
+ wrap?: boolean;
5
+ gap?: string;
6
+ padding?: string;
7
+ align?: 'start' | 'center' | 'end' | 'stretch' | 'baseline';
8
+ justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';
9
+ columns?: number | string;
10
+ width?: string;
11
+ height?: string;
12
+ maxWidth?: string;
13
+ minHeight?: string;
14
+ class?: string;
15
+ style?: string;
16
+ target?: string;
17
+ tag?: string;
18
+ content?: string;
19
+ [key: string]: any;
20
+ }
21
+ declare class Container {
22
+ id: string;
23
+ opts: ContainerOptions;
24
+ private _element;
25
+ constructor(id: string, options?: ContainerOptions);
26
+ private _buildStyles;
27
+ getValue(): string;
28
+ getContent(): string;
29
+ setValue(val: string): this;
30
+ setContent(val: string): this;
31
+ setClass(val: string): this;
32
+ setStyle(val: string): this;
33
+ setInnerHTML(val: string): this;
34
+ getElement(): HTMLElement;
35
+ }
36
+ /**
37
+ * Create a layout container.
38
+ *
39
+ * @example
40
+ * // Flex column (default)
41
+ * jux.container('main', { gap: '16px', padding: '24px' });
42
+ *
43
+ * // Flex row
44
+ * jux.container('toolbar', { direction: 'row', gap: '8px', align: 'center' });
45
+ *
46
+ * // Grid
47
+ * jux.container('grid', { layout: 'grid', columns: 3, gap: '16px' });
48
+ *
49
+ * // Centered page wrapper
50
+ * jux.container('page', { maxWidth: '960px', padding: '24px 16px', align: 'center' });
51
+ *
52
+ * // Nested
53
+ * jux.container('card', { gap: '8px', padding: '16px', target: 'grid' });
54
+ */
55
+ export declare function container(id: string, options?: ContainerOptions): Container;
56
+ export { Container, ContainerOptions };
57
+ export default container;
58
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 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AAG,IAAI;IAM3B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAE7B,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;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAI/E;AAED,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;AACvC,eAAe,SAAS,CAAC"}
@@ -0,0 +1,151 @@
1
+ import generateId from '../utils/idgen.js';
2
+ import { pageState } from '../state/pageState.js';
3
+ const JUSTIFY_MAP = {
4
+ start: 'flex-start',
5
+ center: 'center',
6
+ end: 'flex-end',
7
+ between: 'space-between',
8
+ around: 'space-around',
9
+ evenly: 'space-evenly'
10
+ };
11
+ const ALIGN_MAP = {
12
+ start: 'flex-start',
13
+ center: 'center',
14
+ end: 'flex-end',
15
+ stretch: 'stretch',
16
+ baseline: 'baseline'
17
+ };
18
+ class Container {
19
+ constructor(id, options = {}) {
20
+ this.id = id || generateId();
21
+ this.opts = {
22
+ layout: 'flex',
23
+ direction: 'column',
24
+ tag: 'div',
25
+ ...options
26
+ };
27
+ this._element = document.createElement(this.opts.tag);
28
+ this._element.id = this.id;
29
+ // Classes
30
+ if (this.opts.class)
31
+ this._element.className = this.opts.class;
32
+ // Build computed style from layout options
33
+ const styles = this._buildStyles();
34
+ if (this.opts.style)
35
+ styles.push(this.opts.style);
36
+ if (styles.length)
37
+ this._element.setAttribute('style', styles.join(';'));
38
+ // Content (rare for containers, but supported)
39
+ if (this.opts.content)
40
+ this._element.textContent = this.opts.content;
41
+ // Extra attributes
42
+ for (const [key, value] of Object.entries(this.opts)) {
43
+ if ([
44
+ 'layout', 'direction', 'wrap', 'gap', 'padding', 'align', 'justify',
45
+ 'columns', 'width', 'height', 'maxWidth', 'minHeight',
46
+ 'class', 'style', 'target', 'tag', 'content'
47
+ ].includes(key))
48
+ continue;
49
+ this._element.setAttribute(`data-${key}`, String(value));
50
+ }
51
+ // Mount
52
+ const resolvedTarget = this.opts.target;
53
+ const parent = resolvedTarget
54
+ ? document.getElementById(resolvedTarget) || document.querySelector(resolvedTarget)
55
+ : document.getElementById('app');
56
+ parent?.appendChild(this._element);
57
+ }
58
+ // ═══════════════════════════════════════════════════════════
59
+ // LAYOUT HELPERS
60
+ // ═══════════════════════════════════════════════════════════
61
+ _buildStyles() {
62
+ const s = [];
63
+ const o = this.opts;
64
+ if (o.layout === 'grid') {
65
+ s.push('display:grid');
66
+ if (o.columns) {
67
+ const cols = typeof o.columns === 'number'
68
+ ? `repeat(${o.columns}, 1fr)`
69
+ : o.columns;
70
+ s.push(`grid-template-columns:${cols}`);
71
+ }
72
+ }
73
+ else if (o.layout === 'flex') {
74
+ s.push('display:flex');
75
+ if (o.direction)
76
+ s.push(`flex-direction:${o.direction}`);
77
+ if (o.wrap)
78
+ s.push('flex-wrap:wrap');
79
+ }
80
+ else {
81
+ s.push('display:block');
82
+ }
83
+ if (o.gap)
84
+ s.push(`gap:${o.gap}`);
85
+ if (o.padding)
86
+ s.push(`padding:${o.padding}`);
87
+ if (o.align)
88
+ s.push(`align-items:${ALIGN_MAP[o.align] || o.align}`);
89
+ if (o.justify)
90
+ s.push(`justify-content:${JUSTIFY_MAP[o.justify] || o.justify}`);
91
+ if (o.width)
92
+ s.push(`width:${o.width}`);
93
+ if (o.height)
94
+ s.push(`height:${o.height}`);
95
+ if (o.maxWidth)
96
+ s.push(`max-width:${o.maxWidth}`);
97
+ if (o.minHeight)
98
+ s.push(`min-height:${o.minHeight}`);
99
+ return s;
100
+ }
101
+ // ═══════════════════════════════════════════════════════════
102
+ // PAGESTATE INTEGRATION
103
+ // ═══════════════════════════════════════════════════════════
104
+ getValue() { return this._element.textContent ?? ''; }
105
+ getContent() { return this._element.textContent ?? this.opts.content ?? ''; }
106
+ setValue(val) {
107
+ this.opts.content = val;
108
+ this._element.textContent = val;
109
+ return this;
110
+ }
111
+ setContent(val) { return this.setValue(val); }
112
+ setClass(val) {
113
+ this._element.className = val;
114
+ return this;
115
+ }
116
+ setStyle(val) {
117
+ this._element.setAttribute('style', val);
118
+ return this;
119
+ }
120
+ setInnerHTML(val) {
121
+ this._element.innerHTML = val;
122
+ return this;
123
+ }
124
+ getElement() { return this._element; }
125
+ }
126
+ /**
127
+ * Create a layout container.
128
+ *
129
+ * @example
130
+ * // Flex column (default)
131
+ * jux.container('main', { gap: '16px', padding: '24px' });
132
+ *
133
+ * // Flex row
134
+ * jux.container('toolbar', { direction: 'row', gap: '8px', align: 'center' });
135
+ *
136
+ * // Grid
137
+ * jux.container('grid', { layout: 'grid', columns: 3, gap: '16px' });
138
+ *
139
+ * // Centered page wrapper
140
+ * jux.container('page', { maxWidth: '960px', padding: '24px 16px', align: 'center' });
141
+ *
142
+ * // Nested
143
+ * jux.container('card', { gap: '8px', padding: '16px', target: 'grid' });
144
+ */
145
+ export function container(id, options = {}) {
146
+ const c = new Container(id, options);
147
+ pageState.__register(c);
148
+ return c;
149
+ }
150
+ export { Container };
151
+ export default container;
@@ -15,6 +15,7 @@ import { list } from "./components/list.js";
15
15
  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
+ import { container } from "./components/container.js";
18
19
  export declare const jux: {
19
20
  tag: typeof tag;
20
21
  div: typeof div;
@@ -46,6 +47,7 @@ export declare const jux: {
46
47
  btn: typeof btn;
47
48
  link: typeof link;
48
49
  a: typeof a;
50
+ container: typeof container;
49
51
  };
50
52
  export { pageState };
51
53
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,G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js";
15
15
  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
+ import { container } from "./components/container.js";
18
19
  export const jux = {
19
20
  tag,
20
21
  div,
@@ -40,7 +41,8 @@ export const jux = {
40
41
  button,
41
42
  btn,
42
43
  link,
43
- a
44
+ a,
45
+ container
44
46
  };
45
47
  export { pageState };
46
48
  jux.watch = pageState.__watch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juxscript",
3
- "version": "1.1.307",
3
+ "version": "1.1.308",
4
4
  "type": "module",
5
5
  "description": "A JavaScript UX authorship platform",
6
6
  "main": "./dist/lib/index.js",