juxscript 1.1.39 → 1.1.41

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,12 +1,12 @@
1
1
  import { BaseComponent } from './base/BaseComponent.js';
2
2
  export interface CodeOptions {
3
- code?: string;
3
+ content?: string;
4
4
  language?: string;
5
5
  style?: string;
6
6
  class?: string;
7
7
  }
8
8
  type CodeState = {
9
- code: string;
9
+ content: string;
10
10
  language: string;
11
11
  style: string;
12
12
  class: string;
@@ -16,7 +16,7 @@ export declare class Code extends BaseComponent<CodeState> {
16
16
  protected getTriggerEvents(): readonly string[];
17
17
  protected getCallbackEvents(): readonly string[];
18
18
  update(prop: string, value: any): void;
19
- code(value: string): this;
19
+ content(value: string): this;
20
20
  language(value: string): this;
21
21
  render(targetId?: string | HTMLElement | BaseComponent<any>): this;
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAMxD,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,IAAK,SAAQ,aAAa,CAAC,SAAS,CAAC;gBACpC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IASjD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAIhD,MAAM,CAAC,IAAI,EAAE,M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AAG,CAAC,GAAG,IAAI;CA4DnE;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAEhE"}
@@ -5,7 +5,7 @@ const CALLBACK_EVENTS = [];
5
5
  export class Code extends BaseComponent {
6
6
  constructor(id, options = {}) {
7
7
  super(id, {
8
- code: options.code ?? '',
8
+ content: options.content ?? '',
9
9
  language: options.language ?? 'javascript',
10
10
  style: options.style ?? '',
11
11
  class: options.class ?? ''
@@ -23,9 +23,8 @@ export class Code extends BaseComponent {
23
23
  /* ═════════════════════════════════════════════════════════════════
24
24
  * FLUENT API
25
25
  * ═════════════════════════════════════════════════════════════════ */
26
- // ✅ Inherited from BaseComponent
27
- code(value) {
28
- this.state.code = value;
26
+ content(value) {
27
+ this.state.content = value;
29
28
  return this;
30
29
  }
31
30
  language(value) {
@@ -37,7 +36,7 @@ export class Code extends BaseComponent {
37
36
  * ═════════════════════════════════════════════════════════════════ */
38
37
  render(targetId) {
39
38
  const container = this._setupContainer(targetId);
40
- const { code, language, style, class: className } = this.state;
39
+ const { content, language, style, class: className } = this.state;
41
40
  const wrapper = document.createElement('div');
42
41
  wrapper.className = 'jux-code';
43
42
  wrapper.id = this._id;
@@ -48,18 +47,18 @@ export class Code extends BaseComponent {
48
47
  const pre = document.createElement('pre');
49
48
  const codeEl = document.createElement('code');
50
49
  codeEl.className = `language-${language}`;
51
- codeEl.textContent = code;
50
+ codeEl.textContent = content;
52
51
  pre.appendChild(codeEl);
53
52
  wrapper.appendChild(pre);
54
53
  this._wireStandardEvents(wrapper);
55
54
  // Wire sync bindings
56
55
  this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
57
- if (property === 'code') {
56
+ if (property === 'content') {
58
57
  const transform = toComponent || ((v) => String(v));
59
58
  stateObj.subscribe((val) => {
60
59
  const transformed = transform(val);
61
60
  codeEl.textContent = transformed;
62
- this.state.code = transformed;
61
+ this.state.content = transformed;
63
62
  if (window.Prism) {
64
63
  window.Prism.highlightElement(codeEl);
65
64
  }
@@ -5,14 +5,14 @@ const TRIGGER_EVENTS = [] as const;
5
5
  const CALLBACK_EVENTS = [] as const;
6
6
 
7
7
  export interface CodeOptions {
8
- code?: string;
8
+ content?: string;
9
9
  language?: string;
10
10
  style?: string;
11
11
  class?: string;
12
12
  }
13
13
 
14
14
  type CodeState = {
15
- code: string;
15
+ content: string;
16
16
  language: string;
17
17
  style: string;
18
18
  class: string;
@@ -21,7 +21,7 @@ type CodeState = {
21
21
  export class Code extends BaseComponent<CodeState> {
22
22
  constructor(id: string, options: CodeOptions = {}) {
23
23
  super(id, {
24
- code: options.code ?? '',
24
+ content: options.content ?? '',
25
25
  language: options.language ?? 'javascript',
26
26
  style: options.style ?? '',
27
27
  class: options.class ?? ''
@@ -44,10 +44,8 @@ export class Code extends BaseComponent<CodeState> {
44
44
  * FLUENT API
45
45
  * ═════════════════════════════════════════════════════════════════ */
46
46
 
47
- // Inherited from BaseComponent
48
-
49
- code(value: string): this {
50
- this.state.code = value;
47
+ content(value: string): this {
48
+ this.state.content = value;
51
49
  return this;
52
50
  }
53
51
 
@@ -63,7 +61,7 @@ export class Code extends BaseComponent<CodeState> {
63
61
  render(targetId?: string | HTMLElement | BaseComponent<any>): this {
64
62
  const container = this._setupContainer(targetId);
65
63
 
66
- const { code, language, style, class: className } = this.state;
64
+ const { content, language, style, class: className } = this.state;
67
65
 
68
66
  const wrapper = document.createElement('div');
69
67
  wrapper.className = 'jux-code';
@@ -74,7 +72,7 @@ export class Code extends BaseComponent<CodeState> {
74
72
  const pre = document.createElement('pre');
75
73
  const codeEl = document.createElement('code');
76
74
  codeEl.className = `language-${language}`;
77
- codeEl.textContent = code;
75
+ codeEl.textContent = content;
78
76
  pre.appendChild(codeEl);
79
77
  wrapper.appendChild(pre);
80
78
 
@@ -82,13 +80,13 @@ export class Code extends BaseComponent<CodeState> {
82
80
 
83
81
  // Wire sync bindings
84
82
  this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
85
- if (property === 'code') {
83
+ if (property === 'content') {
86
84
  const transform = toComponent || ((v: any) => String(v));
87
85
 
88
86
  stateObj.subscribe((val: any) => {
89
87
  const transformed = transform(val);
90
88
  codeEl.textContent = transformed;
91
- this.state.code = transformed;
89
+ this.state.content = transformed;
92
90
 
93
91
  if ((window as any).Prism) {
94
92
  (window as any).Prism.highlightElement(codeEl);
@@ -34,6 +34,11 @@ export declare class Tabs extends BaseComponent<TabsState> {
34
34
  * Update content of a specific tab by ID
35
35
  */
36
36
  updateTabContent(tabId: string, content: string | BaseComponent<any>): this;
37
+ /**
38
+ * ✅ NEW: Append content to a specific tab
39
+ * Accepts single item or array of strings/BaseComponents
40
+ */
41
+ addTabContent(tabId: string, content: string | BaseComponent<any> | Array<string | BaseComponent<any>>): this;
37
42
  /**
38
43
  * Get tab by ID
39
44
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["tabs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMnE,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,SAAS,GAAG,SAAS,GAAG;IAC3B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;C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C,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;IAqB3E;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI;IA2B7G;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAItC;;OAEG;IACH,aAAa,IAAI,GAAG,GAAG,SAAS;IAQhC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;CA+EnE;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAEhE"}
@@ -163,6 +163,34 @@ export class Tabs extends BaseComponent {
163
163
  }
164
164
  return this;
165
165
  }
166
+ /**
167
+ * ✅ NEW: Append content to a specific tab
168
+ * Accepts single item or array of strings/BaseComponents
169
+ */
170
+ addTabContent(tabId, content) {
171
+ const panel = document.getElementById(`${this._id}-${tabId}-panel`);
172
+ if (!panel) {
173
+ console.warn(`[Tabs] Panel not found for tab: ${tabId}`);
174
+ return this;
175
+ }
176
+ // Normalize to array
177
+ const items = Array.isArray(content) ? content : [content];
178
+ items.forEach(item => {
179
+ if (typeof item === 'string') {
180
+ // Append HTML string
181
+ const tempDiv = document.createElement('div');
182
+ tempDiv.innerHTML = item;
183
+ while (tempDiv.firstChild) {
184
+ panel.appendChild(tempDiv.firstChild);
185
+ }
186
+ }
187
+ else if (item instanceof BaseComponent) {
188
+ // Render component into panel
189
+ item.render(`#${panel.id}`);
190
+ }
191
+ });
192
+ return this;
193
+ }
166
194
  /**
167
195
  * Get tab by ID
168
196
  */
@@ -218,6 +218,37 @@ export class Tabs extends BaseComponent<TabsState> {
218
218
  return this;
219
219
  }
220
220
 
221
+ /**
222
+ * ✅ NEW: Append content to a specific tab
223
+ * Accepts single item or array of strings/BaseComponents
224
+ */
225
+ addTabContent(tabId: string, content: string | BaseComponent<any> | Array<string | BaseComponent<any>>): this {
226
+ const panel = document.getElementById(`${this._id}-${tabId}-panel`);
227
+ if (!panel) {
228
+ console.warn(`[Tabs] Panel not found for tab: ${tabId}`);
229
+ return this;
230
+ }
231
+
232
+ // Normalize to array
233
+ const items = Array.isArray(content) ? content : [content];
234
+
235
+ items.forEach(item => {
236
+ if (typeof item === 'string') {
237
+ // Append HTML string
238
+ const tempDiv = document.createElement('div');
239
+ tempDiv.innerHTML = item;
240
+ while (tempDiv.firstChild) {
241
+ panel.appendChild(tempDiv.firstChild);
242
+ }
243
+ } else if (item instanceof BaseComponent) {
244
+ // Render component into panel
245
+ item.render(`#${panel.id}`);
246
+ }
247
+ });
248
+
249
+ return this;
250
+ }
251
+
221
252
  /**
222
253
  * Get tab by ID
223
254
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juxscript",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
4
4
  "type": "module",
5
5
  "description": "A JavaScript UX authorship platform",
6
6
  "main": "index.js",