juxscript 1.1.33 → 1.1.35

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.
Files changed (118) hide show
  1. package/index.d.ts +0 -2
  2. package/index.d.ts.map +1 -1
  3. package/index.js +0 -2
  4. package/lib/components/alert.d.ts +1 -1
  5. package/lib/components/alert.d.ts.map +1 -1
  6. package/lib/components/alert.ts +1 -1
  7. package/lib/components/badge.d.ts +1 -1
  8. package/lib/components/badge.d.ts.map +1 -1
  9. package/lib/components/badge.ts +1 -1
  10. package/lib/components/base/BaseComponent.d.ts +2 -3
  11. package/lib/components/base/BaseComponent.d.ts.map +1 -1
  12. package/lib/components/base/BaseComponent.js +18 -12
  13. package/lib/components/base/BaseComponent.ts +18 -15
  14. package/lib/components/button.d.ts +1 -1
  15. package/lib/components/button.d.ts.map +1 -1
  16. package/lib/components/button.ts +1 -1
  17. package/lib/components/card.d.ts +1 -1
  18. package/lib/components/card.d.ts.map +1 -1
  19. package/lib/components/card.ts +1 -1
  20. package/lib/components/chart.d.ts +1 -1
  21. package/lib/components/chart.d.ts.map +1 -1
  22. package/lib/components/chart.ts +1 -1
  23. package/lib/components/checkbox.d.ts +2 -1
  24. package/lib/components/checkbox.d.ts.map +1 -1
  25. package/lib/components/checkbox.ts +2 -1
  26. package/lib/components/code.d.ts +1 -1
  27. package/lib/components/code.d.ts.map +1 -1
  28. package/lib/components/code.ts +1 -1
  29. package/lib/components/container.d.ts +1 -1
  30. package/lib/components/container.d.ts.map +1 -1
  31. package/lib/components/container.ts +1 -1
  32. package/lib/components/datepicker.d.ts +2 -1
  33. package/lib/components/datepicker.d.ts.map +1 -1
  34. package/lib/components/datepicker.ts +2 -1
  35. package/lib/components/dialog.d.ts +1 -1
  36. package/lib/components/dialog.d.ts.map +1 -1
  37. package/lib/components/dialog.ts +1 -1
  38. package/lib/components/divider.d.ts +1 -1
  39. package/lib/components/divider.d.ts.map +1 -1
  40. package/lib/components/divider.ts +1 -1
  41. package/lib/components/dropdown.d.ts +1 -1
  42. package/lib/components/dropdown.d.ts.map +1 -1
  43. package/lib/components/dropdown.ts +1 -1
  44. package/lib/components/element.d.ts +1 -1
  45. package/lib/components/element.d.ts.map +1 -1
  46. package/lib/components/element.ts +1 -1
  47. package/lib/components/fileupload.d.ts +2 -1
  48. package/lib/components/fileupload.d.ts.map +1 -1
  49. package/lib/components/fileupload.ts +2 -1
  50. package/lib/components/grid.d.ts +1 -1
  51. package/lib/components/grid.d.ts.map +1 -1
  52. package/lib/components/grid.ts +1 -1
  53. package/lib/components/heading.d.ts +1 -1
  54. package/lib/components/heading.d.ts.map +1 -1
  55. package/lib/components/heading.ts +1 -1
  56. package/lib/components/hero.d.ts +1 -1
  57. package/lib/components/hero.d.ts.map +1 -1
  58. package/lib/components/hero.ts +1 -1
  59. package/lib/components/icon.d.ts +1 -1
  60. package/lib/components/icon.d.ts.map +1 -1
  61. package/lib/components/icon.ts +1 -1
  62. package/lib/components/input.d.ts +2 -1
  63. package/lib/components/input.d.ts.map +1 -1
  64. package/lib/components/input.ts +2 -1
  65. package/lib/components/list.d.ts +1 -1
  66. package/lib/components/list.d.ts.map +1 -1
  67. package/lib/components/list.ts +1 -1
  68. package/lib/components/loading.d.ts +1 -1
  69. package/lib/components/loading.d.ts.map +1 -1
  70. package/lib/components/loading.ts +1 -1
  71. package/lib/components/menu.d.ts +1 -1
  72. package/lib/components/menu.d.ts.map +1 -1
  73. package/lib/components/menu.ts +1 -1
  74. package/lib/components/modal.d.ts +1 -1
  75. package/lib/components/modal.d.ts.map +1 -1
  76. package/lib/components/modal.ts +1 -1
  77. package/lib/components/nav.d.ts +1 -1
  78. package/lib/components/nav.d.ts.map +1 -1
  79. package/lib/components/nav.ts +1 -1
  80. package/lib/components/paragraph.d.ts +1 -1
  81. package/lib/components/paragraph.d.ts.map +1 -1
  82. package/lib/components/paragraph.ts +1 -1
  83. package/lib/components/pen.d.ts +1 -1
  84. package/lib/components/pen.d.ts.map +1 -1
  85. package/lib/components/pen.ts +1 -1
  86. package/lib/components/progress.d.ts +1 -1
  87. package/lib/components/progress.d.ts.map +1 -1
  88. package/lib/components/progress.ts +1 -1
  89. package/lib/components/radio.d.ts +2 -1
  90. package/lib/components/radio.d.ts.map +1 -1
  91. package/lib/components/radio.ts +2 -1
  92. package/lib/components/select.d.ts +2 -1
  93. package/lib/components/select.d.ts.map +1 -1
  94. package/lib/components/select.ts +4 -3
  95. package/lib/components/sidebar.d.ts +1 -1
  96. package/lib/components/sidebar.d.ts.map +1 -1
  97. package/lib/components/sidebar.ts +1 -1
  98. package/lib/components/switch.d.ts +2 -1
  99. package/lib/components/switch.d.ts.map +1 -1
  100. package/lib/components/switch.ts +2 -2
  101. package/lib/components/table.d.ts +2 -3
  102. package/lib/components/table.d.ts.map +1 -1
  103. package/lib/components/table.js +20 -14
  104. package/lib/components/table.ts +20 -17
  105. package/lib/components/tabs.d.ts +1 -1
  106. package/lib/components/tabs.d.ts.map +1 -1
  107. package/lib/components/tabs.ts +1 -1
  108. package/lib/components/theme-toggle.d.ts +1 -1
  109. package/lib/components/theme-toggle.d.ts.map +1 -1
  110. package/lib/components/theme-toggle.ts +1 -1
  111. package/lib/components/tooltip.d.ts +1 -1
  112. package/lib/components/tooltip.d.ts.map +1 -1
  113. package/lib/components/tooltip.ts +1 -1
  114. package/package.json +1 -1
  115. package/lib/components/view.d.ts +0 -48
  116. package/lib/components/view.d.ts.map +0 -1
  117. package/lib/components/view.js +0 -149
  118. package/lib/components/view.ts +0 -190
@@ -1,190 +0,0 @@
1
- import { getOrCreateContainer } from './helpers.js';
2
-
3
- /**
4
- * View component options
5
- */
6
- export interface ViewOptions {
7
- title?: string;
8
- description?: string;
9
- children?: any[];
10
- }
11
-
12
- /**
13
- * View component state
14
- */
15
- type ViewState = {
16
- title: string;
17
- description: string;
18
- children: any[];
19
- };
20
-
21
- /**
22
- * View component - container for organizing page content
23
- *
24
- * Usage:
25
- * const view = jux.view('myView', {
26
- * title: 'Dashboard',
27
- * description: 'Main dashboard view'
28
- * });
29
- * view.add(component1);
30
- * await view.render();
31
- */
32
- export class View {
33
- state: ViewState;
34
- container: HTMLElement | null = null;
35
- _id: string;
36
- id: string;
37
-
38
- constructor(id: string, options: ViewOptions = {}) {
39
- this._id = id;
40
- this.id = id;
41
-
42
- this.state = {
43
- title: options.title ?? '',
44
- description: options.description ?? '',
45
- children: Array.isArray(options.children) ? [...options.children] : []
46
- };
47
- }
48
-
49
- /* -------------------------
50
- * Fluent API
51
- * ------------------------- */
52
-
53
- title(value: string): this {
54
- this.state.title = value;
55
- return this;
56
- }
57
-
58
- description(value: string): this {
59
- this.state.description = value;
60
- return this;
61
- }
62
-
63
- add(component: any | any[]): this {
64
- if (Array.isArray(component)) {
65
- this.state.children.push(...component);
66
- } else {
67
- this.state.children.push(component);
68
- }
69
- return this;
70
- }
71
-
72
- /* -------------------------
73
- * Render
74
- * ------------------------- */
75
-
76
- async render(targetId?: string): Promise<this> {
77
- let container: HTMLElement;
78
-
79
- if (targetId) {
80
- const target = document.querySelector(targetId);
81
- if (!target || !(target instanceof HTMLElement)) {
82
- throw new Error(`View: Target element "${targetId}" not found`);
83
- }
84
- container = target;
85
- } else {
86
- container = getOrCreateContainer(this._id);
87
- }
88
-
89
- this.container = container;
90
- const { title, description, children } = this.state;
91
-
92
- const view = document.createElement('div');
93
- view.className = 'jux-view';
94
- view.id = this._id;
95
-
96
- // View header
97
- if (title || description) {
98
- const header = document.createElement('div');
99
- header.className = 'jux-view-header';
100
-
101
- if (title) {
102
- const titleEl = document.createElement('h1');
103
- titleEl.className = 'jux-view-title';
104
- titleEl.textContent = title;
105
- header.appendChild(titleEl);
106
- }
107
-
108
- if (description) {
109
- const descEl = document.createElement('p');
110
- descEl.className = 'jux-view-description';
111
- descEl.textContent = description;
112
- header.appendChild(descEl);
113
- }
114
-
115
- view.appendChild(header);
116
- }
117
-
118
- // View content
119
- const content = document.createElement('div');
120
- content.className = 'jux-view-content';
121
-
122
- // Render children
123
- for (let i = 0; i < children.length; i++) {
124
- const child = children[i];
125
- if (!child) continue;
126
-
127
- // Get child ID
128
- let childId: string | null = null;
129
- if ((child as any).id) {
130
- childId = (child as any).id;
131
- } else if ((child as any)._id) {
132
- childId = (child as any)._id;
133
- } else {
134
- childId = `${this._id}-child-${i}`;
135
- }
136
-
137
- // Create wrapper for child
138
- const childWrapper = document.createElement('div');
139
- childWrapper.className = 'jux-view-item';
140
- childWrapper.id = `${childId}-wrapper`;
141
- content.appendChild(childWrapper);
142
-
143
- // Render child INTO the wrapper
144
- if (typeof (child as any).render === 'function') {
145
- try {
146
- // Pass the wrapper element directly
147
- const result = (child as any).render(childWrapper);
148
- if (result && typeof (result as any).then === 'function') {
149
- await result;
150
- }
151
- } catch (err) {
152
- console.error(`View: Error rendering child ${i}:`, err);
153
- childWrapper.innerHTML = `<div style="color: #ff6b6b; padding: 1rem;">Error: ${(err as Error).message}</div>`;
154
- }
155
- } else {
156
- // If no render method, try to append directly
157
- if (child instanceof HTMLElement) {
158
- childWrapper.appendChild(child);
159
- }
160
- }
161
- }
162
-
163
- view.appendChild(content);
164
- container.appendChild(view);
165
-
166
- return this;
167
- }
168
-
169
- /**
170
- * Render to another Jux component's container
171
- */
172
- async renderTo(juxComponent: any): Promise<this> {
173
- if (!juxComponent || typeof juxComponent !== 'object') {
174
- throw new Error('View.renderTo: Invalid component - not an object');
175
- }
176
-
177
- if (!juxComponent._id || typeof juxComponent._id !== 'string') {
178
- throw new Error('View.renderTo: Invalid component - missing _id (not a Jux component)');
179
- }
180
-
181
- return this.render(`#${juxComponent._id}`);
182
- }
183
- }
184
-
185
- /**
186
- * Factory helper
187
- */
188
- export function view(id: string, options: ViewOptions = {}): View {
189
- return new View(id, options);
190
- }