juxscript 1.0.132 → 1.1.2

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 (133) hide show
  1. package/README.md +1 -32
  2. package/bin/cli.js +4 -2
  3. package/index.d.ts +200 -0
  4. package/index.js +96 -22
  5. package/juxconfig.example.js +58 -63
  6. package/lib/components/alert.ts +200 -0
  7. package/lib/components/app.ts +247 -0
  8. package/lib/components/badge.ts +101 -0
  9. package/lib/components/base/BaseComponent.ts +421 -0
  10. package/lib/components/base/FormInput.ts +227 -0
  11. package/lib/components/button.ts +178 -0
  12. package/lib/components/card.ts +173 -0
  13. package/lib/components/chart.ts +231 -0
  14. package/lib/components/checkbox.ts +242 -0
  15. package/lib/components/code.ts +123 -0
  16. package/lib/components/container.ts +140 -0
  17. package/lib/components/data.ts +135 -0
  18. package/lib/components/datepicker.ts +234 -0
  19. package/lib/components/dialog.ts +172 -0
  20. package/lib/components/divider.ts +100 -0
  21. package/lib/components/dropdown.ts +186 -0
  22. package/lib/components/element.ts +267 -0
  23. package/lib/components/fileupload.ts +309 -0
  24. package/lib/components/grid.ts +291 -0
  25. package/lib/components/guard.ts +92 -0
  26. package/lib/components/heading.ts +96 -0
  27. package/lib/components/helpers.ts +41 -0
  28. package/lib/components/hero.ts +224 -0
  29. package/lib/components/icon.ts +178 -0
  30. package/lib/components/icons.ts +464 -0
  31. package/lib/components/include.ts +410 -0
  32. package/lib/components/input.ts +457 -0
  33. package/lib/components/list.ts +419 -0
  34. package/lib/components/loading.ts +100 -0
  35. package/lib/components/menu.ts +275 -0
  36. package/lib/components/modal.ts +284 -0
  37. package/lib/components/nav.ts +257 -0
  38. package/lib/components/paragraph.ts +97 -0
  39. package/lib/components/progress.ts +159 -0
  40. package/lib/components/radio.ts +278 -0
  41. package/lib/components/req.ts +303 -0
  42. package/lib/components/script.ts +41 -0
  43. package/lib/components/select.ts +252 -0
  44. package/lib/components/sidebar.ts +275 -0
  45. package/lib/components/style.ts +41 -0
  46. package/lib/components/switch.ts +246 -0
  47. package/lib/components/table.ts +1249 -0
  48. package/lib/components/tabs.ts +250 -0
  49. package/lib/components/theme-toggle.ts +293 -0
  50. package/lib/components/tooltip.ts +144 -0
  51. package/lib/components/view.ts +190 -0
  52. package/lib/components/write.ts +272 -0
  53. package/lib/globals.d.ts +19 -5
  54. package/lib/layouts/default.css +260 -0
  55. package/lib/layouts/figma.css +334 -0
  56. package/lib/reactivity/state.ts +78 -0
  57. package/lib/utils/{fetch.js → fetch.ts} +206 -81
  58. package/machinery/ast.js +347 -0
  59. package/machinery/build.js +466 -0
  60. package/machinery/compiler3.js +6 -66
  61. package/machinery/config.js +6 -93
  62. package/machinery/doc-generator.js +136 -0
  63. package/machinery/imports.js +155 -0
  64. package/machinery/server.js +166 -0
  65. package/machinery/ts-shim.js +46 -0
  66. package/machinery/watcher.js +162 -50
  67. package/package.json +9 -30
  68. package/create/index.jux +0 -77
  69. package/create/layout.jux +0 -18
  70. package/create/style.css +0 -57
  71. package/create/themes/assets/jux.svg +0 -34
  72. package/create/themes/base.css +0 -197
  73. package/create/themes/base2.css +0 -54
  74. package/create/themes/layouts/base.jux +0 -16
  75. package/create/themes/layouts/base_marketing.jux +0 -0
  76. package/create/themes/layouts/base_saas.jux +0 -0
  77. package/lib/componentsv2/base/BaseEngine.d.ts +0 -112
  78. package/lib/componentsv2/base/BaseEngine.js +0 -279
  79. package/lib/componentsv2/base/BaseSkin.d.ts +0 -74
  80. package/lib/componentsv2/base/BaseSkin.js +0 -130
  81. package/lib/componentsv2/base/Neighborhood.d.ts +0 -22
  82. package/lib/componentsv2/base/Neighborhood.js +0 -56
  83. package/lib/componentsv2/base/OptionsContract.d.ts +0 -20
  84. package/lib/componentsv2/base/OptionsContract.js +0 -107
  85. package/lib/componentsv2/base/State.d.ts +0 -18
  86. package/lib/componentsv2/base/State.js +0 -68
  87. package/lib/componentsv2/element/Element.d.ts +0 -30
  88. package/lib/componentsv2/element/Element.js +0 -50
  89. package/lib/componentsv2/element/ElementEngine.d.ts +0 -59
  90. package/lib/componentsv2/element/ElementEngine.js +0 -118
  91. package/lib/componentsv2/element/ElementSkin.d.ts +0 -10
  92. package/lib/componentsv2/element/ElementSkin.js +0 -56
  93. package/lib/componentsv2/element/structure.css +0 -261
  94. package/lib/componentsv2/grid/Grid.d.ts +0 -13
  95. package/lib/componentsv2/grid/Grid.js +0 -27
  96. package/lib/componentsv2/grid/GridEngine.d.ts +0 -77
  97. package/lib/componentsv2/grid/GridEngine.js +0 -153
  98. package/lib/componentsv2/grid/GridSkin.d.ts +0 -11
  99. package/lib/componentsv2/grid/GridSkin.js +0 -84
  100. package/lib/componentsv2/grid/structure.css +0 -27
  101. package/lib/componentsv2/input/Input.d.ts +0 -6
  102. package/lib/componentsv2/input/Input.js +0 -21
  103. package/lib/componentsv2/input/InputEngine.d.ts +0 -70
  104. package/lib/componentsv2/input/InputEngine.js +0 -143
  105. package/lib/componentsv2/input/InputSkin.d.ts +0 -11
  106. package/lib/componentsv2/input/InputSkin.js +0 -89
  107. package/lib/componentsv2/input/structure.css +0 -47
  108. package/lib/componentsv2/list/List.d.ts +0 -49
  109. package/lib/componentsv2/list/List.js +0 -105
  110. package/lib/componentsv2/list/ListEngine.d.ts +0 -121
  111. package/lib/componentsv2/list/ListEngine.js +0 -322
  112. package/lib/componentsv2/list/ListSkin.d.ts +0 -20
  113. package/lib/componentsv2/list/ListSkin.js +0 -345
  114. package/lib/componentsv2/list/structure.css +0 -359
  115. package/lib/componentsv2/plugins/ClientSQLitePlugin.d.ts +0 -21
  116. package/lib/componentsv2/plugins/ClientSQLitePlugin.js +0 -130
  117. package/lib/componentsv2/plugins/IndexedDBPlugin.d.ts +0 -18
  118. package/lib/componentsv2/plugins/IndexedDBPlugin.js +0 -75
  119. package/lib/componentsv2/plugins/LocalStoragePlugin.d.ts +0 -20
  120. package/lib/componentsv2/plugins/LocalStoragePlugin.js +0 -65
  121. package/lib/componentsv2/plugins/ServerSQLitePlugin.d.ts +0 -25
  122. package/lib/componentsv2/plugins/ServerSQLitePlugin.js +0 -70
  123. package/lib/componentsv2/stubs/ComponentComposition.ts.stub +0 -32
  124. package/lib/componentsv2/stubs/ComponentEngine.ts.stub +0 -36
  125. package/lib/componentsv2/stubs/ComponentSkin.ts.stub +0 -35
  126. package/lib/componentsv2/stubs/ComponentStructure.css.d.ts.stub +0 -2
  127. package/lib/componentsv2/stubs/ComponentStructure.css.stub +0 -13
  128. package/lib/utils/fetch.d.ts +0 -176
  129. package/machinery/serve.js +0 -255
  130. package/types/css.d.ts +0 -10
  131. /package/{create/themes/layouts/base_blog.jux → machinery/bundleAssets.js} +0 -0
  132. /package/{create/themes/layouts/base_docs.jux → machinery/bundleJux.js} +0 -0
  133. /package/{create/themes/layouts/base_login.jux → machinery/bundleVendors.js} +0 -0
@@ -1,322 +0,0 @@
1
- import { BaseEngine } from '../base/BaseEngine.js';
2
- export class ListEngine extends BaseEngine {
3
- constructor(id, options = {}) {
4
- super(id, options);
5
- }
6
- /**
7
- * OPTIONS CONTRACT
8
- * Defines valid options with types, defaults, and aliases for common mistakes.
9
- */
10
- get optionsSchema() {
11
- return {
12
- items: {
13
- type: 'array',
14
- default: [],
15
- description: 'Array of list items (strings or objects)',
16
- aliases: ['data', 'list', 'values', 'options', 'entries']
17
- },
18
- listType: {
19
- type: 'string',
20
- default: 'unordered',
21
- description: 'List type: "unordered" (ul) or "ordered" (ol)',
22
- aliases: ['type', 'ordered', 'ul', 'ol']
23
- },
24
- selectionMode: {
25
- type: 'string',
26
- default: 'none',
27
- description: 'Selection mode: "single", "multiple", or "none"',
28
- aliases: ['selection', 'mode', 'selectable', 'multiselect']
29
- },
30
- filterText: {
31
- type: 'string',
32
- default: '',
33
- description: 'Initial filter/search text',
34
- aliases: ['filter', 'search', 'query', 'searchText']
35
- },
36
- sorted: {
37
- type: 'string',
38
- default: 'none',
39
- description: 'Sort order: "asc", "desc", or "none"',
40
- aliases: ['sort', 'order', 'sortOrder', 'sortDirection']
41
- },
42
- noItemsMessage: {
43
- type: 'string',
44
- default: null,
45
- description: 'Message shown when list is empty',
46
- aliases: ['emptyMessage', 'emptyText', 'placeholder', 'noItems']
47
- },
48
- columns: {
49
- type: 'array',
50
- default: [],
51
- description: 'Column definitions for tabular display',
52
- aliases: ['cols', 'fields', 'headers']
53
- },
54
- idField: {
55
- type: 'string',
56
- default: '_juxId',
57
- description: 'Property name to use as item ID',
58
- aliases: ['idKey', 'idProperty', 'keyField']
59
- }
60
- };
61
- }
62
- /**
63
- * CONTRACT IMPLEMENTATION:
64
- * Convert loose Options into STRICT initial state.
65
- */
66
- prepareState(id, options) {
67
- const idField = options.idField || '_juxId';
68
- return {
69
- id,
70
- classes: ['jux-list'],
71
- visible: true,
72
- disabled: false,
73
- loading: false,
74
- attributes: {},
75
- items: (options && Array.isArray(options.items) ? options.items : []).map((input, i) => ListEngine.normalizeItem(input, idField, i)),
76
- listType: options.listType || 'unordered',
77
- selectionMode: options.selectionMode || 'none',
78
- filterText: options.filterText || '',
79
- sorted: options.sorted || 'none',
80
- noItemsMessage: options.noItemsMessage ?? null,
81
- columns: options.columns || [],
82
- idField
83
- };
84
- }
85
- // ✅ Normalization Helper (Static to allow usage in prepareState)
86
- static normalizeItem(input, idField, index) {
87
- const isObj = typeof input === 'object' && input !== null;
88
- const fallbackId = `item-${Date.now()}-${index ?? Math.random().toString(36).substr(2, 5)}`;
89
- // Extract known props or fallback
90
- let text = String(input);
91
- if (isObj) {
92
- // Prioritize standard fields if they exist, otherwise first string prop?
93
- // For now, assume 'text' or 'label' or fallback to stringified
94
- text = input.text || input.label || input.title || text;
95
- }
96
- // ID resolution
97
- let id = fallbackId;
98
- if (isObj) {
99
- id = input[idField] || input.id || fallbackId;
100
- }
101
- const classes = isObj ? (input.className ? [input.className] : (input.classes || [])) : [];
102
- const selected = false;
103
- // Merge all props for column access
104
- const extraProps = isObj ? { ...input } : { value: input };
105
- return {
106
- ...extraProps,
107
- id: String(id),
108
- text,
109
- selected,
110
- classes
111
- };
112
- }
113
- // --- State-Aligned Methods ---
114
- /**
115
- * Set items array
116
- * Method name matches state property: items
117
- */
118
- items(value) {
119
- const normalized = value.map((input, i) => ListEngine.normalizeItem(input, this.state.idField, i));
120
- this.updateState({ items: normalized });
121
- this.emit('items', { items: normalized });
122
- return this;
123
- }
124
- /**
125
- * Set list type
126
- * Method name matches state property: listType
127
- */
128
- listType(type) {
129
- if (this.state.listType !== type) {
130
- this.updateState({ listType: type });
131
- this.emit('layout', { type });
132
- }
133
- return this;
134
- }
135
- /**
136
- * Set selection mode
137
- * Method name matches state property: selectionMode
138
- */
139
- selectionMode(mode) {
140
- this.updateState({ selectionMode: mode });
141
- this.emit('selectionConfig', { mode });
142
- return this;
143
- }
144
- /**
145
- * Set filter text
146
- * Method name matches state property: filterText
147
- */
148
- filterText(text) {
149
- this.updateState({ filterText: text });
150
- this.emit('filter', { text });
151
- return this;
152
- }
153
- /**
154
- * Set sort order
155
- * Method name matches state property: sorted
156
- */
157
- sorted(order) {
158
- let sortedItems = [...this.state.items];
159
- if (order !== 'none') {
160
- sortedItems.sort((a, b) => {
161
- const textA = a.text.toLowerCase();
162
- const textB = b.text.toLowerCase();
163
- if (textA < textB)
164
- return order === 'asc' ? -1 : 1;
165
- if (textA > textB)
166
- return order === 'asc' ? 1 : -1;
167
- return 0;
168
- });
169
- }
170
- this.updateState({ sorted: order, items: sortedItems });
171
- this.emit('sort', { order });
172
- return this;
173
- }
174
- /**
175
- * Set no items message
176
- * Method name matches state property: noItemsMessage
177
- */
178
- noItemsMessage(message) {
179
- this.updateState({ noItemsMessage: message });
180
- this.emit('config:noItems', { message });
181
- return this;
182
- }
183
- /**
184
- * Set columns configuration
185
- * Method name matches state property: columns
186
- */
187
- columns(cols) {
188
- this.updateState({ columns: cols });
189
- this.emit('config:columns', { columns: cols });
190
- return this;
191
- }
192
- // --- Convenience Aliases ---
193
- /** @alias for selectionMode() */
194
- setSelectionMode(mode) {
195
- return this.selectionMode(mode);
196
- }
197
- /** @alias for columns() */
198
- setColumns(cols) {
199
- return this.columns(cols);
200
- }
201
- /** @alias for filterText() */
202
- filter(text) {
203
- return this.filterText(text);
204
- }
205
- /** @alias for noItemsMessage() */
206
- enableNoItems(message = 'No items found.') {
207
- return this.noItemsMessage(message);
208
- }
209
- /**
210
- * Toggle sort order (cycles: none -> asc -> desc -> none)
211
- * @alias Convenience method that cycles sorted state
212
- */
213
- toggleSort(order) {
214
- if (order) {
215
- return this.sorted(order);
216
- }
217
- const current = this.state.sorted;
218
- const next = current === 'none' ? 'asc' : (current === 'asc' ? 'desc' : 'none');
219
- return this.sorted(next);
220
- }
221
- /**
222
- * Toggle list type between ordered/unordered
223
- * @alias Convenience method that toggles listType state
224
- */
225
- toggleListType() {
226
- const next = this.state.listType === 'unordered' ? 'ordered' : 'unordered';
227
- return this.listType(next);
228
- }
229
- addItem(input) {
230
- const newItem = ListEngine.normalizeItem(input, this.state.idField);
231
- this.updateState({ items: [...this.state.items, newItem] });
232
- this.emit('add', { item: newItem });
233
- return this;
234
- }
235
- addItems(items) {
236
- const newItems = items.map((input, i) => ListEngine.normalizeItem(input, this.state.idField, i));
237
- this.updateState({ items: [...this.state.items, ...newItems] });
238
- this.emit('addItems', { items: newItems });
239
- return this;
240
- }
241
- clearItems() {
242
- const count = this.state.items.length;
243
- if (count > 0) {
244
- this.updateState({ items: [] });
245
- this.emit('clear', { count });
246
- }
247
- return this;
248
- }
249
- // ✅ Modified: Accepts ID string OR Index
250
- removeItem(identifier) {
251
- let index = -1;
252
- if (typeof identifier === 'number') {
253
- index = identifier;
254
- }
255
- else {
256
- // Find by ID string
257
- index = this.state.items.findIndex(i => String(i.id) === String(identifier));
258
- }
259
- if (index < 0 || index >= this.state.items.length) {
260
- // console.warn(`Jux List: removeItem item not found (${identifier})`);
261
- return this;
262
- }
263
- const itemToRemove = this.state.items[index];
264
- const newItems = this.state.items.filter((_, i) => i !== index);
265
- this.updateState({ items: newItems });
266
- this.emit('remove', { item: itemToRemove, index });
267
- return this;
268
- }
269
- updateItem(index, updates) {
270
- const items = [...this.state.items];
271
- if (index < 0 || index >= items.length) {
272
- console.warn(`Jux List: updateItem index ${index} out of bounds.`);
273
- return this;
274
- }
275
- const currentItem = items[index];
276
- const changes = typeof updates === 'string' ? { text: updates } : updates;
277
- items[index] = { ...currentItem, ...changes };
278
- this.updateState({ items });
279
- this.emit('update', { item: items[index], changes, index });
280
- return this;
281
- }
282
- moveItem(fromIndex, toIndex) {
283
- const items = [...this.state.items];
284
- // Bounds check
285
- if (fromIndex < 0 || fromIndex >= items.length || toIndex < 0 || toIndex >= items.length) {
286
- console.warn(`Jux List: moveItem indices out of bounds (${fromIndex} -> ${toIndex}).`);
287
- return this;
288
- }
289
- const movingItem = items[fromIndex];
290
- const [movedItem] = items.splice(fromIndex, 1);
291
- items.splice(toIndex, 0, movedItem);
292
- this.updateState({ items });
293
- this.emit('move', { item: movingItem, from: fromIndex, to: toIndex });
294
- return this;
295
- }
296
- toggleSelection(index) {
297
- const mode = this.state.selectionMode;
298
- if (mode === 'none')
299
- return this;
300
- const items = [...this.state.items];
301
- if (index < 0 || index >= items.length)
302
- return this;
303
- if (mode === 'multiple') {
304
- items[index] = { ...items[index], selected: !items[index].selected };
305
- }
306
- else {
307
- const willBeSelected = !items[index].selected;
308
- for (let i = 0; i < items.length; i++) {
309
- if (i === index) {
310
- items[i] = { ...items[i], selected: willBeSelected };
311
- }
312
- else if (willBeSelected && items[i].selected) {
313
- items[i] = { ...items[i], selected: false };
314
- }
315
- }
316
- }
317
- this.updateState({ items });
318
- this.emit('select', { item: items[index], index, selected: items[index].selected });
319
- return this;
320
- }
321
- }
322
- //# sourceMappingURL=ListEngine.js.map
@@ -1,20 +0,0 @@
1
- import { BaseSkin } from '../base/BaseSkin.js';
2
- import { ListEngine, ListState } from './ListEngine.js';
3
- export declare class ListSkin extends BaseSkin<ListState, ListEngine> {
4
- #private;
5
- constructor(engine: ListEngine);
6
- enableSearch(enabled: boolean): void;
7
- enableAdd(enabled: boolean): void;
8
- enableDelete(enabled: boolean): void;
9
- enableMove(enabled: boolean): void;
10
- enableSort(enabled: boolean): void;
11
- enableNoItems(message?: string): void;
12
- enableEdit(enabled: boolean): void;
13
- protected get structureCss(): string;
14
- protected bindEvents(root: HTMLElement): void;
15
- /**
16
- * Skin Contract: Update/Changes
17
- */
18
- protected updateSkin(state: ListState): void;
19
- }
20
- //# sourceMappingURL=ListSkin.d.ts.map