juxscript 1.1.239 → 1.1.243

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 (297) hide show
  1. package/index.js +7 -137
  2. package/lib/components/dataframe.ts +0 -569
  3. package/lib/components/tag.ts +68 -0
  4. package/lib/styles/shadcn.css +20 -7
  5. package/lib/utils/idgen.ts +6 -0
  6. package/package.json +5 -6
  7. package/index.d.ts +0 -239
  8. package/index.d.ts.map +0 -1
  9. package/lib/components/alert.d.ts +0 -36
  10. package/lib/components/alert.d.ts.map +0 -1
  11. package/lib/components/alert.js +0 -172
  12. package/lib/components/alert.ts +0 -219
  13. package/lib/components/app.d.ts +0 -89
  14. package/lib/components/app.d.ts.map +0 -1
  15. package/lib/components/app.js +0 -175
  16. package/lib/components/app.ts +0 -247
  17. package/lib/components/badge.d.ts +0 -26
  18. package/lib/components/badge.d.ts.map +0 -1
  19. package/lib/components/badge.js +0 -91
  20. package/lib/components/badge.ts +0 -118
  21. package/lib/components/base/Animations.d.ts +0 -36
  22. package/lib/components/base/Animations.d.ts.map +0 -1
  23. package/lib/components/base/Animations.js +0 -70
  24. package/lib/components/base/Animations.ts +0 -112
  25. package/lib/components/base/BaseComponent.d.ts +0 -294
  26. package/lib/components/base/BaseComponent.d.ts.map +0 -1
  27. package/lib/components/base/BaseComponent.js +0 -735
  28. package/lib/components/base/BaseComponent.ts +0 -884
  29. package/lib/components/base/FormInput.d.ts +0 -77
  30. package/lib/components/base/FormInput.d.ts.map +0 -1
  31. package/lib/components/base/FormInput.js +0 -171
  32. package/lib/components/base/FormInput.ts +0 -237
  33. package/lib/components/blueprint.d.ts +0 -40
  34. package/lib/components/blueprint.d.ts.map +0 -1
  35. package/lib/components/blueprint.js +0 -327
  36. package/lib/components/button.d.ts +0 -70
  37. package/lib/components/button.d.ts.map +0 -1
  38. package/lib/components/button.js +0 -177
  39. package/lib/components/button.ts +0 -237
  40. package/lib/components/card.d.ts +0 -35
  41. package/lib/components/card.d.ts.map +0 -1
  42. package/lib/components/card.js +0 -130
  43. package/lib/components/card.ts +0 -177
  44. package/lib/components/chart.d.ts +0 -49
  45. package/lib/components/chart.d.ts.map +0 -1
  46. package/lib/components/chart.js +0 -205
  47. package/lib/components/chart.ts +0 -254
  48. package/lib/components/checkbox.d.ts +0 -33
  49. package/lib/components/checkbox.d.ts.map +0 -1
  50. package/lib/components/checkbox.js +0 -202
  51. package/lib/components/checkbox.ts +0 -260
  52. package/lib/components/code.d.ts +0 -52
  53. package/lib/components/code.d.ts.map +0 -1
  54. package/lib/components/code.js +0 -201
  55. package/lib/components/code.ts +0 -260
  56. package/lib/components/container.d.ts +0 -60
  57. package/lib/components/container.d.ts.map +0 -1
  58. package/lib/components/container.js +0 -195
  59. package/lib/components/container.ts +0 -259
  60. package/lib/components/data.d.ts +0 -36
  61. package/lib/components/data.d.ts.map +0 -1
  62. package/lib/components/data.js +0 -110
  63. package/lib/components/data.ts +0 -135
  64. package/lib/components/dataframe/DataFrameSource.d.ts +0 -118
  65. package/lib/components/dataframe/DataFrameSource.d.ts.map +0 -1
  66. package/lib/components/dataframe/DataFrameSource.js +0 -421
  67. package/lib/components/dataframe/DataFrameSource.ts +0 -532
  68. package/lib/components/dataframe/ImportSettingsModal.d.ts +0 -60
  69. package/lib/components/dataframe/ImportSettingsModal.d.ts.map +0 -1
  70. package/lib/components/dataframe/ImportSettingsModal.js +0 -442
  71. package/lib/components/dataframe/ImportSettingsModal.ts +0 -531
  72. package/lib/components/dataframe.d.ts +0 -110
  73. package/lib/components/dataframe.d.ts.map +0 -1
  74. package/lib/components/dataframe.js +0 -470
  75. package/lib/components/datepicker.d.ts +0 -40
  76. package/lib/components/datepicker.d.ts.map +0 -1
  77. package/lib/components/datepicker.js +0 -193
  78. package/lib/components/datepicker.ts +0 -251
  79. package/lib/components/dialog.d.ts +0 -39
  80. package/lib/components/dialog.d.ts.map +0 -1
  81. package/lib/components/dialog.js +0 -131
  82. package/lib/components/dialog.ts +0 -178
  83. package/lib/components/divider.d.ts +0 -31
  84. package/lib/components/divider.d.ts.map +0 -1
  85. package/lib/components/divider.js +0 -72
  86. package/lib/components/divider.ts +0 -104
  87. package/lib/components/dropdown-menu.d.ts +0 -42
  88. package/lib/components/dropdown-menu.d.ts.map +0 -1
  89. package/lib/components/dropdown-menu.js +0 -177
  90. package/lib/components/dropdown-menu.ts +0 -214
  91. package/lib/components/dropdown.d.ts +0 -41
  92. package/lib/components/dropdown.d.ts.map +0 -1
  93. package/lib/components/dropdown.js +0 -136
  94. package/lib/components/dropdown.ts +0 -188
  95. package/lib/components/element.d.ts +0 -51
  96. package/lib/components/element.d.ts.map +0 -1
  97. package/lib/components/element.js +0 -209
  98. package/lib/components/element.ts +0 -271
  99. package/lib/components/event-chain.d.ts +0 -9
  100. package/lib/components/event-chain.d.ts.map +0 -1
  101. package/lib/components/event-chain.js +0 -33
  102. package/lib/components/fileupload.d.ts +0 -98
  103. package/lib/components/fileupload.d.ts.map +0 -1
  104. package/lib/components/fileupload.js +0 -351
  105. package/lib/components/fileupload.ts +0 -449
  106. package/lib/components/grid.d.ts +0 -88
  107. package/lib/components/grid.d.ts.map +0 -1
  108. package/lib/components/grid.js +0 -208
  109. package/lib/components/grid.ts +0 -295
  110. package/lib/components/heading.d.ts +0 -25
  111. package/lib/components/heading.d.ts.map +0 -1
  112. package/lib/components/heading.js +0 -83
  113. package/lib/components/heading.ts +0 -113
  114. package/lib/components/helpers.d.ts +0 -9
  115. package/lib/components/helpers.d.ts.map +0 -1
  116. package/lib/components/helpers.js +0 -30
  117. package/lib/components/helpers.ts +0 -41
  118. package/lib/components/hero.d.ts +0 -60
  119. package/lib/components/hero.d.ts.map +0 -1
  120. package/lib/components/hero.js +0 -239
  121. package/lib/components/hero.ts +0 -302
  122. package/lib/components/history/StateHistory.d.ts +0 -91
  123. package/lib/components/history/StateHistory.d.ts.map +0 -1
  124. package/lib/components/history/StateHistory.js +0 -154
  125. package/lib/components/history/StateHistory.ts +0 -200
  126. package/lib/components/icon.d.ts +0 -36
  127. package/lib/components/icon.d.ts.map +0 -1
  128. package/lib/components/icon.js +0 -135
  129. package/lib/components/icon.ts +0 -182
  130. package/lib/components/icons.d.ts +0 -25
  131. package/lib/components/icons.d.ts.map +0 -1
  132. package/lib/components/icons.js +0 -440
  133. package/lib/components/icons.ts +0 -464
  134. package/lib/components/image.d.ts +0 -42
  135. package/lib/components/image.d.ts.map +0 -1
  136. package/lib/components/image.js +0 -204
  137. package/lib/components/image.ts +0 -260
  138. package/lib/components/include.d.ts +0 -86
  139. package/lib/components/include.d.ts.map +0 -1
  140. package/lib/components/include.js +0 -238
  141. package/lib/components/include.ts +0 -281
  142. package/lib/components/input.d.ts +0 -85
  143. package/lib/components/input.d.ts.map +0 -1
  144. package/lib/components/input.js +0 -362
  145. package/lib/components/input.ts +0 -473
  146. package/lib/components/layer.d.ts +0 -72
  147. package/lib/components/layer.d.ts.map +0 -1
  148. package/lib/components/layer.js +0 -219
  149. package/lib/components/layer.ts +0 -304
  150. package/lib/components/link.d.ts +0 -41
  151. package/lib/components/link.d.ts.map +0 -1
  152. package/lib/components/link.js +0 -216
  153. package/lib/components/link.ts +0 -268
  154. package/lib/components/list.d.ts +0 -83
  155. package/lib/components/list.d.ts.map +0 -1
  156. package/lib/components/list.js +0 -314
  157. package/lib/components/list.ts +0 -423
  158. package/lib/components/loading.d.ts +0 -25
  159. package/lib/components/loading.d.ts.map +0 -1
  160. package/lib/components/loading.js +0 -76
  161. package/lib/components/loading.ts +0 -104
  162. package/lib/components/menu.d.ts +0 -38
  163. package/lib/components/menu.d.ts.map +0 -1
  164. package/lib/components/menu.js +0 -205
  165. package/lib/components/menu.ts +0 -279
  166. package/lib/components/modal.d.ts +0 -97
  167. package/lib/components/modal.d.ts.map +0 -1
  168. package/lib/components/modal.js +0 -463
  169. package/lib/components/modal.ts +0 -576
  170. package/lib/components/nav.d.ts +0 -46
  171. package/lib/components/nav.d.ts.map +0 -1
  172. package/lib/components/nav.js +0 -193
  173. package/lib/components/nav.ts +0 -261
  174. package/lib/components/paragraph.d.ts +0 -30
  175. package/lib/components/paragraph.d.ts.map +0 -1
  176. package/lib/components/paragraph.js +0 -93
  177. package/lib/components/paragraph.ts +0 -123
  178. package/lib/components/pen.d.ts +0 -125
  179. package/lib/components/pen.d.ts.map +0 -1
  180. package/lib/components/pen.js +0 -443
  181. package/lib/components/pen.ts +0 -567
  182. package/lib/components/progress.d.ts +0 -40
  183. package/lib/components/progress.d.ts.map +0 -1
  184. package/lib/components/progress.js +0 -116
  185. package/lib/components/progress.ts +0 -163
  186. package/lib/components/radio.d.ts +0 -43
  187. package/lib/components/radio.d.ts.map +0 -1
  188. package/lib/components/radio.js +0 -226
  189. package/lib/components/radio.ts +0 -303
  190. package/lib/components/registry.d.ts +0 -34
  191. package/lib/components/registry.d.ts.map +0 -1
  192. package/lib/components/registry.js +0 -163
  193. package/lib/components/registry.ts +0 -193
  194. package/lib/components/req.d.ts +0 -155
  195. package/lib/components/req.d.ts.map +0 -1
  196. package/lib/components/req.js +0 -253
  197. package/lib/components/req.ts +0 -303
  198. package/lib/components/script.d.ts +0 -14
  199. package/lib/components/script.d.ts.map +0 -1
  200. package/lib/components/script.js +0 -33
  201. package/lib/components/script.ts +0 -41
  202. package/lib/components/select.d.ts +0 -42
  203. package/lib/components/select.d.ts.map +0 -1
  204. package/lib/components/select.js +0 -209
  205. package/lib/components/select.ts +0 -281
  206. package/lib/components/sidebar.d.ts +0 -59
  207. package/lib/components/sidebar.d.ts.map +0 -1
  208. package/lib/components/sidebar.js +0 -298
  209. package/lib/components/sidebar.ts +0 -395
  210. package/lib/components/stack/BaseStack.d.ts +0 -65
  211. package/lib/components/stack/BaseStack.d.ts.map +0 -1
  212. package/lib/components/stack/BaseStack.js +0 -274
  213. package/lib/components/stack/BaseStack.ts +0 -328
  214. package/lib/components/stack/HStack.d.ts +0 -18
  215. package/lib/components/stack/HStack.d.ts.map +0 -1
  216. package/lib/components/stack/HStack.js +0 -22
  217. package/lib/components/stack/HStack.ts +0 -25
  218. package/lib/components/stack/VStack.d.ts +0 -19
  219. package/lib/components/stack/VStack.d.ts.map +0 -1
  220. package/lib/components/stack/VStack.js +0 -23
  221. package/lib/components/stack/VStack.ts +0 -26
  222. package/lib/components/stack/ZStack.d.ts +0 -18
  223. package/lib/components/stack/ZStack.d.ts.map +0 -1
  224. package/lib/components/stack/ZStack.js +0 -22
  225. package/lib/components/stack/ZStack.ts +0 -25
  226. package/lib/components/style.d.ts +0 -14
  227. package/lib/components/style.d.ts.map +0 -1
  228. package/lib/components/style.js +0 -33
  229. package/lib/components/style.ts +0 -41
  230. package/lib/components/switch.d.ts +0 -34
  231. package/lib/components/switch.d.ts.map +0 -1
  232. package/lib/components/switch.js +0 -209
  233. package/lib/components/switch.ts +0 -272
  234. package/lib/components/table.d.ts +0 -137
  235. package/lib/components/table.d.ts.map +0 -1
  236. package/lib/components/table.js +0 -1019
  237. package/lib/components/table.ts +0 -1225
  238. package/lib/components/tabs.d.ts +0 -53
  239. package/lib/components/tabs.d.ts.map +0 -1
  240. package/lib/components/tabs.js +0 -275
  241. package/lib/components/tabs.ts +0 -349
  242. package/lib/components/theme-toggle.d.ts +0 -45
  243. package/lib/components/theme-toggle.d.ts.map +0 -1
  244. package/lib/components/theme-toggle.js +0 -218
  245. package/lib/components/theme-toggle.ts +0 -297
  246. package/lib/components/tooltip.d.ts +0 -31
  247. package/lib/components/tooltip.d.ts.map +0 -1
  248. package/lib/components/tooltip.js +0 -112
  249. package/lib/components/tooltip.ts +0 -148
  250. package/lib/components/watcher.d.ts +0 -195
  251. package/lib/components/watcher.d.ts.map +0 -1
  252. package/lib/components/watcher.js +0 -241
  253. package/lib/components/watcher.ts +0 -261
  254. package/lib/components/write.d.ts +0 -107
  255. package/lib/components/write.d.ts.map +0 -1
  256. package/lib/components/write.js +0 -222
  257. package/lib/components/write.ts +0 -272
  258. package/lib/data/DataPipeline.d.ts +0 -113
  259. package/lib/data/DataPipeline.d.ts.map +0 -1
  260. package/lib/data/DataPipeline.js +0 -359
  261. package/lib/data/DataPipeline.ts +0 -452
  262. package/lib/facades/dataframe.jux +0 -0
  263. package/lib/globals.d.ts +0 -21
  264. package/lib/reactivity/state.d.ts +0 -36
  265. package/lib/reactivity/state.d.ts.map +0 -1
  266. package/lib/reactivity/state.js +0 -67
  267. package/lib/reactivity/state.ts +0 -78
  268. package/lib/storage/DataFrame.d.ts +0 -284
  269. package/lib/storage/DataFrame.d.ts.map +0 -1
  270. package/lib/storage/DataFrame.js +0 -1022
  271. package/lib/storage/DataFrame.ts +0 -1195
  272. package/lib/storage/DataFrameSource.d.ts +0 -158
  273. package/lib/storage/DataFrameSource.d.ts.map +0 -1
  274. package/lib/storage/DataFrameSource.js +0 -409
  275. package/lib/storage/DataFrameSource.ts +0 -556
  276. package/lib/storage/FileStorage.d.ts +0 -53
  277. package/lib/storage/FileStorage.d.ts.map +0 -1
  278. package/lib/storage/FileStorage.js +0 -80
  279. package/lib/storage/FileStorage.ts +0 -95
  280. package/lib/storage/IndexedDBDriver.d.ts +0 -75
  281. package/lib/storage/IndexedDBDriver.d.ts.map +0 -1
  282. package/lib/storage/IndexedDBDriver.js +0 -177
  283. package/lib/storage/IndexedDBDriver.ts +0 -226
  284. package/lib/storage/TabularDriver.d.ts +0 -118
  285. package/lib/storage/TabularDriver.d.ts.map +0 -1
  286. package/lib/storage/TabularDriver.js +0 -731
  287. package/lib/storage/TabularDriver.ts +0 -874
  288. package/lib/utils/codeparser.d.ts +0 -29
  289. package/lib/utils/codeparser.d.ts.map +0 -1
  290. package/lib/utils/codeparser.js +0 -409
  291. package/lib/utils/fetch.d.ts +0 -176
  292. package/lib/utils/fetch.d.ts.map +0 -1
  293. package/lib/utils/fetch.js +0 -427
  294. package/lib/utils/formatId.d.ts +0 -16
  295. package/lib/utils/formatId.d.ts.map +0 -1
  296. package/lib/utils/formatId.js +0 -27
  297. package/lib/utils/path-resolver.js +0 -23
@@ -1,205 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- import { renderIcon } from './icons.js';
3
- import { req } from './req.js';
4
- // Event definitions
5
- const TRIGGER_EVENTS = [];
6
- const CALLBACK_EVENTS = ['itemClick']; // ✅ Fire when menu item is clicked
7
- export class Menu extends BaseComponent {
8
- constructor(id, options = {}) {
9
- super(id, {
10
- items: options.items ?? [],
11
- orientation: options.orientation ?? 'vertical',
12
- style: options.style ?? '',
13
- class: options.class ?? ''
14
- });
15
- this._setActiveStates();
16
- }
17
- getTriggerEvents() {
18
- return TRIGGER_EVENTS;
19
- }
20
- getCallbackEvents() {
21
- return CALLBACK_EVENTS;
22
- }
23
- _setActiveStates() {
24
- this.state.items = this.state.items.map(item => ({
25
- ...item,
26
- active: item.href ? req.isActiveNavItem(item.href) : false,
27
- items: item.items?.map(subItem => ({
28
- ...subItem,
29
- active: subItem.href ? req.isActiveNavItem(subItem.href) : false
30
- }))
31
- }));
32
- }
33
- /* ═════════════════════════════════════════════════════════════════
34
- * FLUENT API
35
- * ═════════════════════════════════════════════════════════════════ */
36
- // ✅ Inherited from BaseComponent
37
- items(value) {
38
- this.state.items = value;
39
- this._setActiveStates();
40
- return this;
41
- }
42
- addItem(item) {
43
- this.state.items = [...this.state.items, item];
44
- this._setActiveStates();
45
- return this;
46
- }
47
- itemClass(className) {
48
- this.state.items = this.state.items.map(item => ({
49
- ...item,
50
- itemClass: className,
51
- items: item.items?.map(subItem => ({
52
- ...subItem,
53
- itemClass: className
54
- }))
55
- }));
56
- return this;
57
- }
58
- orientation(value) {
59
- this.state.orientation = value;
60
- return this;
61
- }
62
- update(prop, value) {
63
- // No reactive updates needed
64
- }
65
- /* ═════════════════════════════════════════════════════════════════
66
- * HELPERS
67
- * ═════════════════════════════════════════════════════════════════ */
68
- _renderMenuItem(item) {
69
- const menuItem = document.createElement('div');
70
- menuItem.className = 'jux-menu-item';
71
- if (item.itemClass) {
72
- menuItem.className += ` ${item.itemClass}`;
73
- }
74
- if (item.active) {
75
- menuItem.classList.add('jux-menu-item-active');
76
- }
77
- if (item.href) {
78
- const link = document.createElement('a');
79
- link.className = 'jux-menu-link';
80
- link.href = item.href;
81
- if (item.active) {
82
- link.classList.add('jux-menu-link-active');
83
- }
84
- if (item.icon) {
85
- const icon = document.createElement('span');
86
- icon.className = 'jux-menu-icon';
87
- icon.appendChild(renderIcon(item.icon));
88
- link.appendChild(icon);
89
- }
90
- const label = document.createElement('span');
91
- label.className = 'jux-menu-label';
92
- label.textContent = item.label;
93
- link.appendChild(label);
94
- // ✅ Fire itemClick callback when link is clicked
95
- link.addEventListener('click', (e) => {
96
- this._triggerCallback('itemClick', { item, event: e });
97
- });
98
- menuItem.appendChild(link);
99
- }
100
- else {
101
- const button = document.createElement('button');
102
- button.className = 'jux-menu-button';
103
- if (item.icon) {
104
- const icon = document.createElement('span');
105
- icon.className = 'jux-menu-icon';
106
- icon.appendChild(renderIcon(item.icon));
107
- button.appendChild(icon);
108
- }
109
- const label = document.createElement('span');
110
- label.className = 'jux-menu-label';
111
- label.textContent = item.label;
112
- button.appendChild(label);
113
- menuItem.appendChild(button);
114
- // ✅ Fire both the item's click handler AND the callback event
115
- button.addEventListener('click', (e) => {
116
- if (item.click) {
117
- item.click();
118
- }
119
- this._triggerCallback('itemClick', { item, event: e });
120
- });
121
- }
122
- if (item.items && item.items.length > 0) {
123
- // Mark item as having submenu
124
- menuItem.classList.add('jux-menu-item-has-submenu');
125
- const submenu = document.createElement('div');
126
- submenu.className = 'jux-menu-submenu';
127
- item.items.forEach(subItem => {
128
- submenu.appendChild(this._renderMenuItem(subItem));
129
- });
130
- menuItem.appendChild(submenu);
131
- // Add click handler to toggle submenu expansion
132
- const clickTarget = menuItem.querySelector('a, button');
133
- if (clickTarget) {
134
- clickTarget.addEventListener('click', (e) => {
135
- // Prevent default link behavior if it has submenus
136
- if (!item.href) {
137
- e.preventDefault();
138
- }
139
- menuItem.classList.toggle('jux-menu-item-expanded');
140
- });
141
- }
142
- }
143
- return menuItem;
144
- }
145
- /* ═════════════════════════════════════════════════════════════════
146
- * RENDER
147
- * ═════════════════════════════════════════════════════════════════ */
148
- render(targetId) {
149
- const container = this._setupContainer(targetId);
150
- const { items, orientation, style, class: className } = this.state;
151
- const menu = document.createElement('nav');
152
- menu.className = `jux-menu jux-menu-${orientation}`;
153
- menu.id = this._id;
154
- if (className) {
155
- menu.className += ` ${className}`;
156
- }
157
- if (style) {
158
- menu.setAttribute('style', style);
159
- }
160
- items.forEach(item => {
161
- menu.appendChild(this._renderMenuItem(item));
162
- });
163
- this._wireStandardEvents(menu);
164
- // Wire sync bindings
165
- this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
166
- if (property === 'items') {
167
- const transform = toComponent || ((v) => v);
168
- stateObj.subscribe((val) => {
169
- const transformed = transform(val);
170
- this.state.items = transformed;
171
- this._setActiveStates();
172
- const existingItems = menu.querySelectorAll('.jux-menu-item');
173
- existingItems.forEach(item => item.remove());
174
- this.state.items.forEach(item => {
175
- menu.appendChild(this._renderMenuItem(item));
176
- });
177
- requestAnimationFrame(() => {
178
- if (window.lucide) {
179
- window.lucide.createIcons();
180
- }
181
- });
182
- });
183
- }
184
- else if (property === 'orientation') {
185
- const transform = toComponent || ((v) => String(v));
186
- stateObj.subscribe((val) => {
187
- const transformed = transform(val);
188
- menu.classList.remove(`jux-menu-${this.state.orientation}`);
189
- this.state.orientation = transformed;
190
- menu.classList.add(`jux-menu-${transformed}`);
191
- });
192
- }
193
- });
194
- container.appendChild(menu);
195
- requestAnimationFrame(() => {
196
- if (window.lucide) {
197
- window.lucide.createIcons();
198
- }
199
- });
200
- return this;
201
- }
202
- }
203
- export function menu(id, options = {}) {
204
- return new Menu(id, options);
205
- }
@@ -1,279 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- import { renderIcon } from './icons.js';
3
- import { req } from './req.js';
4
-
5
- // Event definitions
6
- const TRIGGER_EVENTS = [] as const;
7
- const CALLBACK_EVENTS = ['itemClick'] as const; // ✅ Fire when menu item is clicked
8
-
9
- export interface MenuItem {
10
- label: string;
11
- href?: string;
12
- click?: () => void;
13
- icon?: string;
14
- items?: MenuItem[];
15
- active?: boolean;
16
- itemClass?: string;
17
- }
18
-
19
- export interface MenuOptions {
20
- items?: MenuItem[];
21
- orientation?: 'vertical' | 'horizontal';
22
- style?: string;
23
- class?: string;
24
- }
25
-
26
- type MenuState = {
27
- items: MenuItem[];
28
- orientation: string;
29
- style: string;
30
- class: string;
31
- };
32
-
33
- export class Menu extends BaseComponent<MenuState> {
34
- constructor(id: string, options: MenuOptions = {}) {
35
- super(id, {
36
- items: options.items ?? [],
37
- orientation: options.orientation ?? 'vertical',
38
- style: options.style ?? '',
39
- class: options.class ?? ''
40
- });
41
-
42
- this._setActiveStates();
43
- }
44
-
45
- protected getTriggerEvents(): readonly string[] {
46
- return TRIGGER_EVENTS;
47
- }
48
-
49
- protected getCallbackEvents(): readonly string[] {
50
- return CALLBACK_EVENTS;
51
- }
52
-
53
- private _setActiveStates(): void {
54
- this.state.items = this.state.items.map(item => ({
55
- ...item,
56
- active: item.href ? req.isActiveNavItem(item.href) : false,
57
- items: item.items?.map(subItem => ({
58
- ...subItem,
59
- active: subItem.href ? req.isActiveNavItem(subItem.href) : false
60
- }))
61
- }));
62
- }
63
-
64
- /* ═════════════════════════════════════════════════════════════════
65
- * FLUENT API
66
- * ═════════════════════════════════════════════════════════════════ */
67
-
68
- // ✅ Inherited from BaseComponent
69
-
70
- items(value: MenuItem[]): this {
71
- this.state.items = value;
72
- this._setActiveStates();
73
- return this;
74
- }
75
-
76
- addItem(item: MenuItem): this {
77
- this.state.items = [...this.state.items, item];
78
- this._setActiveStates();
79
- return this;
80
- }
81
-
82
- itemClass(className: string): this {
83
- this.state.items = this.state.items.map(item => ({
84
- ...item,
85
- itemClass: className,
86
- items: item.items?.map(subItem => ({
87
- ...subItem,
88
- itemClass: className
89
- }))
90
- }));
91
- return this;
92
- }
93
-
94
- orientation(value: 'vertical' | 'horizontal'): this {
95
- this.state.orientation = value;
96
- return this;
97
- }
98
-
99
- update(prop: string, value: any): void {
100
- // No reactive updates needed
101
- }
102
-
103
- /* ═════════════════════════════════════════════════════════════════
104
- * HELPERS
105
- * ═════════════════════════════════════════════════════════════════ */
106
-
107
- private _renderMenuItem(item: MenuItem): HTMLElement {
108
- const menuItem = document.createElement('div');
109
- menuItem.className = 'jux-menu-item';
110
-
111
- if (item.itemClass) {
112
- menuItem.className += ` ${item.itemClass}`;
113
- }
114
-
115
- if (item.active) {
116
- menuItem.classList.add('jux-menu-item-active');
117
- }
118
-
119
- if (item.href) {
120
- const link = document.createElement('a');
121
- link.className = 'jux-menu-link';
122
- link.href = item.href;
123
-
124
- if (item.active) {
125
- link.classList.add('jux-menu-link-active');
126
- }
127
-
128
- if (item.icon) {
129
- const icon = document.createElement('span');
130
- icon.className = 'jux-menu-icon';
131
- icon.appendChild(renderIcon(item.icon));
132
- link.appendChild(icon);
133
- }
134
-
135
- const label = document.createElement('span');
136
- label.className = 'jux-menu-label';
137
- label.textContent = item.label;
138
- link.appendChild(label);
139
-
140
- // ✅ Fire itemClick callback when link is clicked
141
- link.addEventListener('click', (e) => {
142
- this._triggerCallback('itemClick', { item, event: e });
143
- });
144
-
145
- menuItem.appendChild(link);
146
- } else {
147
- const button = document.createElement('button');
148
- button.className = 'jux-menu-button';
149
-
150
- if (item.icon) {
151
- const icon = document.createElement('span');
152
- icon.className = 'jux-menu-icon';
153
- icon.appendChild(renderIcon(item.icon));
154
- button.appendChild(icon);
155
- }
156
-
157
- const label = document.createElement('span');
158
- label.className = 'jux-menu-label';
159
- label.textContent = item.label;
160
- button.appendChild(label);
161
-
162
- menuItem.appendChild(button);
163
-
164
- // ✅ Fire both the item's click handler AND the callback event
165
- button.addEventListener('click', (e) => {
166
- if (item.click) {
167
- item.click();
168
- }
169
- this._triggerCallback('itemClick', { item, event: e });
170
- });
171
- }
172
-
173
- if (item.items && item.items.length > 0) {
174
- // Mark item as having submenu
175
- menuItem.classList.add('jux-menu-item-has-submenu');
176
-
177
- const submenu = document.createElement('div');
178
- submenu.className = 'jux-menu-submenu';
179
-
180
- item.items.forEach(subItem => {
181
- submenu.appendChild(this._renderMenuItem(subItem));
182
- });
183
-
184
- menuItem.appendChild(submenu);
185
-
186
- // Add click handler to toggle submenu expansion
187
- const clickTarget = menuItem.querySelector('a, button');
188
- if (clickTarget) {
189
- clickTarget.addEventListener('click', (e) => {
190
- // Prevent default link behavior if it has submenus
191
- if (!item.href) {
192
- e.preventDefault();
193
- }
194
- menuItem.classList.toggle('jux-menu-item-expanded');
195
- });
196
- }
197
- }
198
-
199
- return menuItem;
200
- }
201
-
202
- /* ═════════════════════════════════════════════════════════════════
203
- * RENDER
204
- * ═════════════════════════════════════════════════════════════════ */
205
-
206
- render(targetId?: string | HTMLElement | BaseComponent<any>): this {
207
- const container = this._setupContainer(targetId);
208
-
209
- const { items, orientation, style, class: className } = this.state;
210
-
211
- const menu = document.createElement('nav');
212
- menu.className = `jux-menu jux-menu-${orientation}`;
213
- menu.id = this._id;
214
-
215
- if (className) {
216
- menu.className += ` ${className}`;
217
- }
218
-
219
- if (style) {
220
- menu.setAttribute('style', style);
221
- }
222
-
223
- items.forEach(item => {
224
- menu.appendChild(this._renderMenuItem(item));
225
- });
226
-
227
- this._wireStandardEvents(menu);
228
-
229
- // Wire sync bindings
230
- this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
231
- if (property === 'items') {
232
- const transform = toComponent || ((v: any) => v);
233
-
234
- stateObj.subscribe((val: any) => {
235
- const transformed = transform(val);
236
- this.state.items = transformed;
237
- this._setActiveStates();
238
-
239
- const existingItems = menu.querySelectorAll('.jux-menu-item');
240
- existingItems.forEach(item => item.remove());
241
-
242
- this.state.items.forEach(item => {
243
- menu.appendChild(this._renderMenuItem(item));
244
- });
245
-
246
- requestAnimationFrame(() => {
247
- if ((window as any).lucide) {
248
- (window as any).lucide.createIcons();
249
- }
250
- });
251
- });
252
- }
253
- else if (property === 'orientation') {
254
- const transform = toComponent || ((v: any) => String(v));
255
-
256
- stateObj.subscribe((val: any) => {
257
- const transformed = transform(val);
258
- menu.classList.remove(`jux-menu-${this.state.orientation}`);
259
- this.state.orientation = transformed;
260
- menu.classList.add(`jux-menu-${transformed}`);
261
- });
262
- }
263
- });
264
-
265
- container.appendChild(menu);
266
-
267
- requestAnimationFrame(() => {
268
- if ((window as any).lucide) {
269
- (window as any).lucide.createIcons();
270
- }
271
- });
272
-
273
- return this;
274
- }
275
- }
276
-
277
- export function menu(id: string, options: MenuOptions = {}): Menu {
278
- return new Menu(id, options);
279
- }
@@ -1,97 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- export type EmojiIconType = {
3
- icon: string;
4
- collection?: 'lucide' | 'heroicons' | 'material-symbols' | 'material' | 'icon-park' | string;
5
- };
6
- export interface ModalOptions {
7
- title?: string;
8
- content?: string | BaseComponent<any> | Array<string | BaseComponent<any>>;
9
- icon?: EmojiIconType | undefined;
10
- close?: boolean;
11
- backdropClose?: boolean;
12
- position?: 'bottom' | 'center' | 'top' | 'fullscreen' | 'popover' | 'popover-top' | 'popover-bottom' | 'popover-left' | 'popover-right';
13
- size?: 'small' | 'medium' | 'large';
14
- actions?: Array<{
15
- label: string;
16
- variant?: string;
17
- click?: () => void;
18
- } | Array<BaseComponent<any>>>;
19
- style?: string;
20
- class?: string;
21
- }
22
- type ModalState = {
23
- title: string;
24
- content: string | BaseComponent<any> | Array<string | BaseComponent<any>>;
25
- icon: EmojiIconType | undefined;
26
- close: boolean;
27
- backdropClose: boolean;
28
- position?: 'bottom' | 'center' | 'top' | 'fullscreen' | 'popover' | 'popover-top' | 'popover-bottom' | 'popover-left' | 'popover-right';
29
- size: string;
30
- open: boolean;
31
- actions: Array<{
32
- label: string;
33
- variant?: string;
34
- click?: () => void;
35
- } | Array<BaseComponent<any>>>;
36
- style: string;
37
- class: string;
38
- };
39
- export declare class Modal extends BaseComponent<ModalState> {
40
- private _overlay;
41
- constructor(id: string, options?: ModalOptions);
42
- protected getTriggerEvents(): readonly string[];
43
- protected getCallbackEvents(): readonly string[];
44
- update(prop: string, value: any): void;
45
- private _updateTitle;
46
- private _updateIcon;
47
- private _updateContent;
48
- private _rebuildActions;
49
- title(value: string): this;
50
- content(value: string | BaseComponent<any> | Array<string | BaseComponent<any>>): this;
51
- icon(value: EmojiIconType): this;
52
- close(value: boolean): this;
53
- backdropClose(value: boolean): this;
54
- size(value: 'small' | 'medium' | 'large'): this;
55
- position(value: 'bottom' | 'center' | 'top' | 'fullscreen' | 'popover' | 'popover-top' | 'popover-bottom' | 'popover-left' | 'popover-right'): this;
56
- actions(value: Array<{
57
- label: string;
58
- variant?: string;
59
- click?: () => void;
60
- }>): this;
61
- addAction(action: {
62
- label: string;
63
- variant?: string;
64
- click?: () => void;
65
- }): this;
66
- open(): this;
67
- closeModal(): this;
68
- toggle(): this;
69
- /**
70
- * Check if modal is currently open
71
- */
72
- isOpen(): boolean;
73
- /**
74
- * Check if modal is currently closed
75
- */
76
- isClosed(): boolean;
77
- /**
78
- * Add content to modal (supports strings and BaseComponents)
79
- */
80
- addContent(content: string | BaseComponent<any> | Array<string | BaseComponent<any>>): this;
81
- /**
82
- * Clear all content from modal
83
- */
84
- clearContent(): this;
85
- /**
86
- * Get the modal content element ID for rendering child components
87
- */
88
- contentId(): string;
89
- /**
90
- * Get the modal content element (only available after render)
91
- */
92
- getContentElement(): HTMLElement | null;
93
- render(targetId?: string | HTMLElement | BaseComponent<any>): this;
94
- }
95
- export declare function modal(id: string, options?: ModalOptions): Modal;
96
- export {};
97
- //# sourceMappingURL=modal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAOxD,MAAM,MAAM,aAAa,GAAG;IAE1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,kBAAkB,GAAG,UAAU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