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,193 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- import { renderIcon } from './icons.js';
3
- import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
4
- // Event definitions
5
- const TRIGGER_EVENTS = [];
6
- const CALLBACK_EVENTS = ['change'];
7
- export class DatePicker extends BaseComponent {
8
- constructor(id, options = {}) {
9
- super(id, {
10
- visible: true,
11
- disabled: options.disabled ?? false,
12
- loading: false,
13
- class: options.class ?? '',
14
- style: options.style ?? '',
15
- attributes: {},
16
- label: options.label ?? formatIdAsLabel(id), // ✅ Auto-generate
17
- required: options.required ?? false,
18
- name: options.name ?? id,
19
- errorMessage: undefined,
20
- value: options.value ?? '',
21
- placeholder: options.placeholder ?? 'Select a date',
22
- min: options.min,
23
- max: options.max
24
- });
25
- if (options.onValidate) {
26
- this._onValidate = options.onValidate;
27
- }
28
- }
29
- getTriggerEvents() {
30
- return TRIGGER_EVENTS;
31
- }
32
- getCallbackEvents() {
33
- return CALLBACK_EVENTS;
34
- }
35
- /* ═════════════════════════════════════════════════════════════════
36
- * FLUENT API
37
- * ═════════════════════════════════════════════════════════════════ */
38
- value(value) {
39
- return this.setValue(value);
40
- }
41
- placeholder(value) {
42
- this.state.placeholder = value;
43
- return this;
44
- }
45
- min(value) {
46
- this.state.min = value;
47
- return this;
48
- }
49
- max(value) {
50
- this.state.max = value;
51
- return this;
52
- }
53
- /* ═════════════════════════════════════════════════════════════════
54
- * FORM INPUT IMPLEMENTATION
55
- * ═════════════════════════════════════════════════════════════════ */
56
- getValue() {
57
- return this.state.value;
58
- }
59
- setValue(value) {
60
- this.state.value = value;
61
- if (this._inputElement) {
62
- this._inputElement.value = value;
63
- }
64
- return this;
65
- }
66
- getDate() {
67
- if (!this.state.value)
68
- return null;
69
- const date = new Date(this.state.value);
70
- return isNaN(date.getTime()) ? null : date;
71
- }
72
- validate() {
73
- this._hasBeenValidated = true;
74
- const value = this.getValue();
75
- const result = this._validateValue(value);
76
- if (result === true) {
77
- this._clearError();
78
- return true;
79
- }
80
- else {
81
- this._showError(result);
82
- return false;
83
- }
84
- }
85
- isValid() {
86
- const value = this.getValue();
87
- return this._validateValue(value) === true;
88
- }
89
- _validateValue(value) {
90
- const { required, min, max } = this.state;
91
- if (required && !value) {
92
- return 'Please select a date';
93
- }
94
- if (value) {
95
- const date = new Date(value);
96
- if (isNaN(date.getTime())) {
97
- return 'Invalid date';
98
- }
99
- if (min) {
100
- const minDate = new Date(min);
101
- if (date < minDate) {
102
- return `Date must be on or after ${min}`;
103
- }
104
- }
105
- if (max) {
106
- const maxDate = new Date(max);
107
- if (date > maxDate) {
108
- return `Date must be on or before ${max}`;
109
- }
110
- }
111
- }
112
- if (this._onValidate) {
113
- const result = this._onValidate(value);
114
- if (result !== true) {
115
- return result || 'Invalid date';
116
- }
117
- }
118
- return true;
119
- }
120
- _buildInputElement() {
121
- const { value, placeholder, required, disabled, name, min, max } = this.state;
122
- const input = document.createElement('input');
123
- input.type = 'date';
124
- input.className = 'jux-input-element jux-datepicker-input';
125
- input.id = `${this._id}-input`;
126
- input.name = name;
127
- input.value = value;
128
- input.placeholder = placeholder;
129
- input.required = required;
130
- input.disabled = disabled;
131
- if (min)
132
- input.min = min;
133
- if (max)
134
- input.max = max;
135
- return input;
136
- }
137
- /* ═════════════════════════════════════════════════════════════════
138
- * RENDER
139
- * ═════════════════════════════════════════════════════════════════ */
140
- render(targetId) {
141
- const container = this._setupContainer(targetId);
142
- const { style, class: className } = this.state;
143
- // Build wrapper
144
- const wrapper = document.createElement('div');
145
- wrapper.className = 'jux-input jux-datepicker';
146
- wrapper.id = this._id;
147
- if (className)
148
- wrapper.className += ` ${className}`;
149
- if (style)
150
- wrapper.setAttribute('style', style);
151
- // Label
152
- if (this.state.label) {
153
- wrapper.appendChild(this._renderLabel());
154
- }
155
- // Input container
156
- const inputContainer = document.createElement('div');
157
- inputContainer.className = 'jux-input-container jux-datepicker-container';
158
- // Calendar icon
159
- const iconEl = document.createElement('span');
160
- iconEl.className = 'jux-input-icon';
161
- iconEl.appendChild(renderIcon('calendar'));
162
- inputContainer.appendChild(iconEl);
163
- // Date input
164
- const inputEl = this._buildInputElement();
165
- this._inputElement = inputEl;
166
- inputContainer.appendChild(inputEl);
167
- wrapper.appendChild(inputContainer);
168
- // Error element
169
- wrapper.appendChild(this._renderError());
170
- // Wire events
171
- this._wireStandardEvents(wrapper);
172
- this._wireFormSync(inputEl, 'change');
173
- // Find the existing change listener and replace with:
174
- inputEl.addEventListener('change', (e) => {
175
- const date = inputEl.value;
176
- this.state.value = date;
177
- this._triggerCallback('change', date, e, this);
178
- });
179
- // Sync label changes
180
- const labelSync = this._syncBindings.find(b => b.property === 'label');
181
- if (labelSync) {
182
- const transform = labelSync.toComponent || ((v) => String(v));
183
- labelSync.stateObj.subscribe((val) => {
184
- this.label(transform(val));
185
- });
186
- }
187
- container.appendChild(wrapper);
188
- return this;
189
- }
190
- }
191
- export function datepicker(id, options = {}) {
192
- return new DatePicker(id, options);
193
- }
@@ -1,251 +0,0 @@
1
- import { BaseComponent, BaseState } from './base/BaseComponent.js';
2
- import { renderIcon } from './icons.js';
3
- import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
4
-
5
- // Event definitions
6
- const TRIGGER_EVENTS = [] as const;
7
- const CALLBACK_EVENTS = ['change'] as const;
8
-
9
- export interface DatePickerOptions {
10
- value?: string;
11
- label?: string;
12
- placeholder?: string;
13
- required?: boolean;
14
- disabled?: boolean;
15
- name?: string;
16
- min?: string;
17
- max?: string;
18
- style?: string;
19
- class?: string;
20
- onValidate?: (value: string) => boolean | string;
21
- }
22
-
23
- interface DatePickerState extends BaseState {
24
- value: string;
25
- placeholder: string;
26
- min?: string;
27
- max?: string;
28
- }
29
-
30
- export class DatePicker extends BaseComponent<DatePickerState> {
31
- constructor(id: string, options: DatePickerOptions = {}) {
32
- super(id, {
33
- visible: true,
34
- disabled: options.disabled ?? false,
35
- loading: false,
36
- class: options.class ?? '',
37
- style: options.style ?? '',
38
- attributes: {},
39
- label: options.label ?? formatIdAsLabel(id), // ✅ Auto-generate
40
- required: options.required ?? false,
41
- name: options.name ?? id,
42
- errorMessage: undefined,
43
- value: options.value ?? '',
44
- placeholder: options.placeholder ?? 'Select a date',
45
- min: options.min,
46
- max: options.max
47
- });
48
-
49
- if (options.onValidate) {
50
- this._onValidate = options.onValidate;
51
- }
52
- }
53
-
54
- protected getTriggerEvents(): readonly string[] {
55
- return TRIGGER_EVENTS;
56
- }
57
-
58
- protected getCallbackEvents(): readonly string[] {
59
- return CALLBACK_EVENTS;
60
- }
61
-
62
- /* ═════════════════════════════════════════════════════════════════
63
- * FLUENT API
64
- * ═════════════════════════════════════════════════════════════════ */
65
-
66
- value(value: string): this {
67
- return this.setValue(value);
68
- }
69
-
70
- placeholder(value: string): this {
71
- this.state.placeholder = value;
72
- return this;
73
- }
74
-
75
- min(value: string): this {
76
- this.state.min = value;
77
- return this;
78
- }
79
-
80
- max(value: string): this {
81
- this.state.max = value;
82
- return this;
83
- }
84
-
85
- /* ═════════════════════════════════════════════════════════════════
86
- * FORM INPUT IMPLEMENTATION
87
- * ═════════════════════════════════════════════════════════════════ */
88
-
89
- getValue(): string {
90
- return this.state.value;
91
- }
92
-
93
- setValue(value: string): this {
94
- this.state.value = value;
95
- if (this._inputElement) {
96
- (this._inputElement as HTMLInputElement).value = value;
97
- }
98
- return this;
99
- }
100
-
101
- getDate(): Date | null {
102
- if (!this.state.value) return null;
103
- const date = new Date(this.state.value);
104
- return isNaN(date.getTime()) ? null : date;
105
- }
106
-
107
- validate(): boolean {
108
- this._hasBeenValidated = true;
109
- const value = this.getValue();
110
- const result = this._validateValue(value);
111
-
112
- if (result === true) {
113
- this._clearError();
114
- return true;
115
- } else {
116
- this._showError(result as string);
117
- return false;
118
- }
119
- }
120
-
121
- isValid(): boolean {
122
- const value = this.getValue();
123
- return this._validateValue(value) === true;
124
- }
125
-
126
- protected _validateValue(value: string): boolean | string {
127
- const { required, min, max } = this.state;
128
-
129
- if (required && !value) {
130
- return 'Please select a date';
131
- }
132
-
133
- if (value) {
134
- const date = new Date(value);
135
-
136
- if (isNaN(date.getTime())) {
137
- return 'Invalid date';
138
- }
139
-
140
- if (min) {
141
- const minDate = new Date(min);
142
- if (date < minDate) {
143
- return `Date must be on or after ${min}`;
144
- }
145
- }
146
-
147
- if (max) {
148
- const maxDate = new Date(max);
149
- if (date > maxDate) {
150
- return `Date must be on or before ${max}`;
151
- }
152
- }
153
- }
154
-
155
- if (this._onValidate) {
156
- const result = this._onValidate(value);
157
- if (result !== true) {
158
- return result || 'Invalid date';
159
- }
160
- }
161
-
162
- return true;
163
- }
164
-
165
- protected _buildInputElement(): HTMLElement {
166
- const { value, placeholder, required, disabled, name, min, max } = this.state;
167
-
168
- const input = document.createElement('input');
169
- input.type = 'date';
170
- input.className = 'jux-input-element jux-datepicker-input';
171
- input.id = `${this._id}-input`;
172
- input.name = name!;
173
- input.value = value;
174
- input.placeholder = placeholder;
175
- input.required = required!;
176
- input.disabled = disabled!;
177
-
178
- if (min) input.min = min;
179
- if (max) input.max = max;
180
-
181
- return input;
182
- }
183
-
184
- /* ═════════════════════════════════════════════════════════════════
185
- * RENDER
186
- * ═════════════════════════════════════════════════════════════════ */
187
-
188
- render(targetId?: string | HTMLElement | BaseComponent<any>): this {
189
- const container = this._setupContainer(targetId);
190
-
191
- const { style, class: className } = this.state;
192
-
193
- // Build wrapper
194
- const wrapper = document.createElement('div');
195
- wrapper.className = 'jux-input jux-datepicker';
196
- wrapper.id = this._id;
197
- if (className) wrapper.className += ` ${className}`;
198
- if (style) wrapper.setAttribute('style', style);
199
-
200
- // Label
201
- if (this.state.label) {
202
- wrapper.appendChild(this._renderLabel());
203
- }
204
-
205
- // Input container
206
- const inputContainer = document.createElement('div');
207
- inputContainer.className = 'jux-input-container jux-datepicker-container';
208
-
209
- // Calendar icon
210
- const iconEl = document.createElement('span');
211
- iconEl.className = 'jux-input-icon';
212
- iconEl.appendChild(renderIcon('calendar'));
213
- inputContainer.appendChild(iconEl);
214
-
215
- // Date input
216
- const inputEl = this._buildInputElement();
217
- this._inputElement = inputEl;
218
- inputContainer.appendChild(inputEl);
219
- wrapper.appendChild(inputContainer);
220
-
221
- // Error element
222
- wrapper.appendChild(this._renderError());
223
-
224
- // Wire events
225
- this._wireStandardEvents(wrapper);
226
- this._wireFormSync(inputEl, 'change');
227
-
228
- // Find the existing change listener and replace with:
229
- inputEl.addEventListener('change', (e) => {
230
- const date = (inputEl as HTMLInputElement).value;
231
- this.state.value = date;
232
- this._triggerCallback('change', date, e, this);
233
- });
234
-
235
- // Sync label changes
236
- const labelSync = this._syncBindings.find(b => b.property === 'label');
237
- if (labelSync) {
238
- const transform = labelSync.toComponent || ((v: any) => String(v));
239
- labelSync.stateObj.subscribe((val: any) => {
240
- this.label(transform(val));
241
- });
242
- }
243
-
244
- container.appendChild(wrapper);
245
- return this;
246
- }
247
- }
248
-
249
- export function datepicker(id: string, options: DatePickerOptions = {}): DatePicker {
250
- return new DatePicker(id, options);
251
- }
@@ -1,39 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- export interface DialogOptions {
3
- title?: string;
4
- message?: string;
5
- confirmText?: string;
6
- cancelText?: string;
7
- variant?: 'default' | 'danger' | 'warning';
8
- style?: string;
9
- class?: string;
10
- }
11
- type DialogState = {
12
- title: string;
13
- message: string;
14
- confirmText: string;
15
- cancelText: string;
16
- variant: string;
17
- open: boolean;
18
- style: string;
19
- class: string;
20
- };
21
- export declare class Dialog extends BaseComponent<DialogState> {
22
- private _dialog;
23
- private _overlay;
24
- constructor(id: string, options?: DialogOptions);
25
- protected getTriggerEvents(): readonly string[];
26
- protected getCallbackEvents(): readonly string[];
27
- title(value: string): this;
28
- message(value: string): this;
29
- confirmText(value: string): this;
30
- cancelText(value: string): this;
31
- variant(value: 'default' | 'danger' | 'warning'): this;
32
- open(): this;
33
- close(): this;
34
- update(prop: string, value: any): void;
35
- render(targetId?: string | HTMLElement | BaseComponent<any>): this;
36
- }
37
- export declare function dialog(id: string, options?: DialogOptions): Dialog;
38
- export {};
39
- //# sourceMappingURL=dialog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAMxD,MAAM,WAAW,aAAa;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,KAAK,WAAW,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,MAAO,SAAQ,aAAa,CAAC,WAAW,CAAC;IAClD,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,QAAQ,CAA4B;gBAEhC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;IAanD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAQhD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKhC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK/B,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,IAAI;IAKtD,IAAI,IAAI,IAAI;IASZ,KAAK,IAAI,IAAI;IASb,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAQtC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;CAkErE;AAED,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CAEtE"}
@@ -1,131 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- // Event definitions
3
- const TRIGGER_EVENTS = [];
4
- const CALLBACK_EVENTS = ['confirm', 'cancel'];
5
- export class Dialog extends BaseComponent {
6
- constructor(id, options = {}) {
7
- super(id, {
8
- title: options.title ?? 'Confirm',
9
- message: options.message ?? 'Are you sure?',
10
- confirmText: options.confirmText ?? 'Confirm',
11
- cancelText: options.cancelText ?? 'Cancel',
12
- variant: options.variant ?? 'default',
13
- open: false,
14
- style: options.style ?? '',
15
- class: options.class ?? ''
16
- });
17
- this._dialog = null;
18
- this._overlay = null;
19
- }
20
- getTriggerEvents() {
21
- return TRIGGER_EVENTS;
22
- }
23
- getCallbackEvents() {
24
- return CALLBACK_EVENTS;
25
- }
26
- /* ═════════════════════════════════════════════════════════════════
27
- * FLUENT API
28
- * ═════════════════════════════════════════════════════════════════ */
29
- title(value) {
30
- this.state.title = value;
31
- return this;
32
- }
33
- message(value) {
34
- this.state.message = value;
35
- return this;
36
- }
37
- confirmText(value) {
38
- this.state.confirmText = value;
39
- return this;
40
- }
41
- cancelText(value) {
42
- this.state.cancelText = value;
43
- return this;
44
- }
45
- variant(value) {
46
- this.state.variant = value;
47
- return this;
48
- }
49
- open() {
50
- this.state.open = true;
51
- if (this._overlay) {
52
- this._overlay.style.display = 'flex';
53
- }
54
- this._triggerCallback('open', true, null, this);
55
- return this;
56
- }
57
- close() {
58
- this.state.open = false;
59
- if (this._overlay) {
60
- this._overlay.style.display = 'none';
61
- }
62
- this._triggerCallback('close', false, null, this);
63
- return this;
64
- }
65
- update(prop, value) {
66
- // No reactive updates needed
67
- }
68
- /* ═════════════════════════════════════════════════════════════════
69
- * RENDER
70
- * ═════════════════════════════════════════════════════════════════ */
71
- render(targetId) {
72
- const { title, message, confirmText, cancelText, variant, style, class: className } = this.state;
73
- // Overlay
74
- const overlay = document.createElement('div');
75
- overlay.className = 'jux-dialog-overlay';
76
- overlay.style.display = 'none';
77
- this._overlay = overlay;
78
- // Dialog
79
- const dialog = document.createElement('div');
80
- dialog.className = `jux-dialog jux-dialog-${variant}`;
81
- dialog.id = this._id;
82
- if (className)
83
- dialog.className += ` ${className}`;
84
- if (style)
85
- dialog.setAttribute('style', style);
86
- this._dialog = dialog;
87
- // Title
88
- const titleEl = document.createElement('div');
89
- titleEl.className = 'jux-dialog-title';
90
- titleEl.textContent = title;
91
- dialog.appendChild(titleEl);
92
- // Message
93
- const messageEl = document.createElement('div');
94
- messageEl.className = 'jux-dialog-message';
95
- messageEl.textContent = message;
96
- dialog.appendChild(messageEl);
97
- // Actions
98
- const actions = document.createElement('div');
99
- actions.className = 'jux-dialog-actions';
100
- const cancelBtn = document.createElement('button');
101
- cancelBtn.className = 'jux-dialog-button jux-dialog-button-cancel';
102
- cancelBtn.textContent = cancelText;
103
- cancelBtn.addEventListener('click', () => {
104
- this._triggerCallback('cancel');
105
- this.close();
106
- });
107
- const confirmBtn = document.createElement('button');
108
- confirmBtn.className = `jux-dialog-button jux-dialog-button-confirm jux-dialog-button-${variant}`;
109
- confirmBtn.textContent = confirmText;
110
- confirmBtn.addEventListener('click', () => {
111
- this._triggerCallback('confirm');
112
- this.close();
113
- });
114
- actions.appendChild(cancelBtn);
115
- actions.appendChild(confirmBtn);
116
- dialog.appendChild(actions);
117
- // Close on overlay click
118
- overlay.addEventListener('click', (e) => {
119
- if (e.target === overlay) {
120
- this._triggerCallback('cancel');
121
- this.close();
122
- }
123
- });
124
- overlay.appendChild(dialog);
125
- document.body.appendChild(overlay);
126
- return this;
127
- }
128
- }
129
- export function dialog(id, options = {}) {
130
- return new Dialog(id, options);
131
- }