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.
- package/README.md +1 -32
- package/bin/cli.js +4 -2
- package/index.d.ts +200 -0
- package/index.js +96 -22
- package/juxconfig.example.js +58 -63
- package/lib/components/alert.ts +200 -0
- package/lib/components/app.ts +247 -0
- package/lib/components/badge.ts +101 -0
- package/lib/components/base/BaseComponent.ts +421 -0
- package/lib/components/base/FormInput.ts +227 -0
- package/lib/components/button.ts +178 -0
- package/lib/components/card.ts +173 -0
- package/lib/components/chart.ts +231 -0
- package/lib/components/checkbox.ts +242 -0
- package/lib/components/code.ts +123 -0
- package/lib/components/container.ts +140 -0
- package/lib/components/data.ts +135 -0
- package/lib/components/datepicker.ts +234 -0
- package/lib/components/dialog.ts +172 -0
- package/lib/components/divider.ts +100 -0
- package/lib/components/dropdown.ts +186 -0
- package/lib/components/element.ts +267 -0
- package/lib/components/fileupload.ts +309 -0
- package/lib/components/grid.ts +291 -0
- package/lib/components/guard.ts +92 -0
- package/lib/components/heading.ts +96 -0
- package/lib/components/helpers.ts +41 -0
- package/lib/components/hero.ts +224 -0
- package/lib/components/icon.ts +178 -0
- package/lib/components/icons.ts +464 -0
- package/lib/components/include.ts +410 -0
- package/lib/components/input.ts +457 -0
- package/lib/components/list.ts +419 -0
- package/lib/components/loading.ts +100 -0
- package/lib/components/menu.ts +275 -0
- package/lib/components/modal.ts +284 -0
- package/lib/components/nav.ts +257 -0
- package/lib/components/paragraph.ts +97 -0
- package/lib/components/progress.ts +159 -0
- package/lib/components/radio.ts +278 -0
- package/lib/components/req.ts +303 -0
- package/lib/components/script.ts +41 -0
- package/lib/components/select.ts +252 -0
- package/lib/components/sidebar.ts +275 -0
- package/lib/components/style.ts +41 -0
- package/lib/components/switch.ts +246 -0
- package/lib/components/table.ts +1249 -0
- package/lib/components/tabs.ts +250 -0
- package/lib/components/theme-toggle.ts +293 -0
- package/lib/components/tooltip.ts +144 -0
- package/lib/components/view.ts +190 -0
- package/lib/components/write.ts +272 -0
- package/lib/globals.d.ts +19 -5
- package/lib/layouts/default.css +260 -0
- package/lib/layouts/figma.css +334 -0
- package/lib/reactivity/state.ts +78 -0
- package/lib/utils/{fetch.js → fetch.ts} +206 -81
- package/machinery/ast.js +347 -0
- package/machinery/build.js +466 -0
- package/machinery/compiler3.js +6 -66
- package/machinery/config.js +6 -93
- package/machinery/doc-generator.js +136 -0
- package/machinery/imports.js +155 -0
- package/machinery/server.js +166 -0
- package/machinery/ts-shim.js +46 -0
- package/machinery/watcher.js +162 -50
- package/package.json +9 -30
- package/create/index.jux +0 -77
- package/create/layout.jux +0 -18
- package/create/style.css +0 -57
- package/create/themes/assets/jux.svg +0 -34
- package/create/themes/base.css +0 -197
- package/create/themes/base2.css +0 -54
- package/create/themes/layouts/base.jux +0 -16
- package/create/themes/layouts/base_marketing.jux +0 -0
- package/create/themes/layouts/base_saas.jux +0 -0
- package/lib/componentsv2/base/BaseEngine.d.ts +0 -112
- package/lib/componentsv2/base/BaseEngine.js +0 -279
- package/lib/componentsv2/base/BaseSkin.d.ts +0 -74
- package/lib/componentsv2/base/BaseSkin.js +0 -130
- package/lib/componentsv2/base/Neighborhood.d.ts +0 -22
- package/lib/componentsv2/base/Neighborhood.js +0 -56
- package/lib/componentsv2/base/OptionsContract.d.ts +0 -20
- package/lib/componentsv2/base/OptionsContract.js +0 -107
- package/lib/componentsv2/base/State.d.ts +0 -18
- package/lib/componentsv2/base/State.js +0 -68
- package/lib/componentsv2/element/Element.d.ts +0 -30
- package/lib/componentsv2/element/Element.js +0 -50
- package/lib/componentsv2/element/ElementEngine.d.ts +0 -59
- package/lib/componentsv2/element/ElementEngine.js +0 -118
- package/lib/componentsv2/element/ElementSkin.d.ts +0 -10
- package/lib/componentsv2/element/ElementSkin.js +0 -56
- package/lib/componentsv2/element/structure.css +0 -261
- package/lib/componentsv2/grid/Grid.d.ts +0 -13
- package/lib/componentsv2/grid/Grid.js +0 -27
- package/lib/componentsv2/grid/GridEngine.d.ts +0 -77
- package/lib/componentsv2/grid/GridEngine.js +0 -153
- package/lib/componentsv2/grid/GridSkin.d.ts +0 -11
- package/lib/componentsv2/grid/GridSkin.js +0 -84
- package/lib/componentsv2/grid/structure.css +0 -27
- package/lib/componentsv2/input/Input.d.ts +0 -6
- package/lib/componentsv2/input/Input.js +0 -21
- package/lib/componentsv2/input/InputEngine.d.ts +0 -70
- package/lib/componentsv2/input/InputEngine.js +0 -143
- package/lib/componentsv2/input/InputSkin.d.ts +0 -11
- package/lib/componentsv2/input/InputSkin.js +0 -89
- package/lib/componentsv2/input/structure.css +0 -47
- package/lib/componentsv2/list/List.d.ts +0 -49
- package/lib/componentsv2/list/List.js +0 -105
- package/lib/componentsv2/list/ListEngine.d.ts +0 -121
- package/lib/componentsv2/list/ListEngine.js +0 -322
- package/lib/componentsv2/list/ListSkin.d.ts +0 -20
- package/lib/componentsv2/list/ListSkin.js +0 -345
- package/lib/componentsv2/list/structure.css +0 -359
- package/lib/componentsv2/plugins/ClientSQLitePlugin.d.ts +0 -21
- package/lib/componentsv2/plugins/ClientSQLitePlugin.js +0 -130
- package/lib/componentsv2/plugins/IndexedDBPlugin.d.ts +0 -18
- package/lib/componentsv2/plugins/IndexedDBPlugin.js +0 -75
- package/lib/componentsv2/plugins/LocalStoragePlugin.d.ts +0 -20
- package/lib/componentsv2/plugins/LocalStoragePlugin.js +0 -65
- package/lib/componentsv2/plugins/ServerSQLitePlugin.d.ts +0 -25
- package/lib/componentsv2/plugins/ServerSQLitePlugin.js +0 -70
- package/lib/componentsv2/stubs/ComponentComposition.ts.stub +0 -32
- package/lib/componentsv2/stubs/ComponentEngine.ts.stub +0 -36
- package/lib/componentsv2/stubs/ComponentSkin.ts.stub +0 -35
- package/lib/componentsv2/stubs/ComponentStructure.css.d.ts.stub +0 -2
- package/lib/componentsv2/stubs/ComponentStructure.css.stub +0 -13
- package/lib/utils/fetch.d.ts +0 -176
- package/machinery/serve.js +0 -255
- package/types/css.d.ts +0 -10
- /package/{create/themes/layouts/base_blog.jux → machinery/bundleAssets.js} +0 -0
- /package/{create/themes/layouts/base_docs.jux → machinery/bundleJux.js} +0 -0
- /package/{create/themes/layouts/base_login.jux → machinery/bundleVendors.js} +0 -0
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _ListSkin_instances, _ListSkin_showSearch, _ListSkin_showAdd, _ListSkin_showDelete, _ListSkin_showEdit, _ListSkin_showMove, _ListSkin_showSort, _ListSkin_dragSourceIndex, _ListSkin_toolbar, _ListSkin_listContainer, _ListSkin_searchInput, _ListSkin_addBtn, _ListSkin_sortBtn, _ListSkin_openEditModal, _ListSkin_renderToolbar, _ListSkin_renderListItem;
|
|
13
|
-
import { BaseSkin } from '../base/BaseSkin.js';
|
|
14
|
-
import structureCss from './structure.css';
|
|
15
|
-
export class ListSkin extends BaseSkin {
|
|
16
|
-
constructor(engine) {
|
|
17
|
-
super(engine);
|
|
18
|
-
_ListSkin_instances.add(this);
|
|
19
|
-
// UI Feature Flags
|
|
20
|
-
_ListSkin_showSearch.set(this, false);
|
|
21
|
-
_ListSkin_showAdd.set(this, false);
|
|
22
|
-
_ListSkin_showDelete.set(this, false);
|
|
23
|
-
_ListSkin_showEdit.set(this, false);
|
|
24
|
-
_ListSkin_showMove.set(this, false);
|
|
25
|
-
_ListSkin_showSort.set(this, false);
|
|
26
|
-
// Internal Drag State
|
|
27
|
-
_ListSkin_dragSourceIndex.set(this, null);
|
|
28
|
-
// DOM References (Stable elements to prevent re-render thrashing)
|
|
29
|
-
_ListSkin_toolbar.set(this, null);
|
|
30
|
-
_ListSkin_listContainer.set(this, null);
|
|
31
|
-
// Toolbar Componenets
|
|
32
|
-
_ListSkin_searchInput.set(this, null);
|
|
33
|
-
_ListSkin_addBtn.set(this, null);
|
|
34
|
-
_ListSkin_sortBtn.set(this, null);
|
|
35
|
-
}
|
|
36
|
-
// --- Public UI API ---
|
|
37
|
-
enableSearch(enabled) { __classPrivateFieldSet(this, _ListSkin_showSearch, enabled, "f"); __classPrivateFieldGet(this, _ListSkin_instances, "m", _ListSkin_renderToolbar).call(this); }
|
|
38
|
-
enableAdd(enabled) { __classPrivateFieldSet(this, _ListSkin_showAdd, enabled, "f"); __classPrivateFieldGet(this, _ListSkin_instances, "m", _ListSkin_renderToolbar).call(this); }
|
|
39
|
-
enableDelete(enabled) { __classPrivateFieldSet(this, _ListSkin_showDelete, enabled, "f"); this.updateSkin(this.engine.state); }
|
|
40
|
-
enableMove(enabled) { __classPrivateFieldSet(this, _ListSkin_showMove, enabled, "f"); this.updateSkin(this.engine.state); }
|
|
41
|
-
enableSort(enabled) { __classPrivateFieldSet(this, _ListSkin_showSort, enabled, "f"); __classPrivateFieldGet(this, _ListSkin_instances, "m", _ListSkin_renderToolbar).call(this); }
|
|
42
|
-
enableNoItems(message = 'No items found.') { this.engine.enableNoItems(message); }
|
|
43
|
-
enableEdit(enabled) {
|
|
44
|
-
__classPrivateFieldSet(this, _ListSkin_showEdit, enabled, "f");
|
|
45
|
-
this.updateSkin(this.engine.state);
|
|
46
|
-
}
|
|
47
|
-
get structureCss() {
|
|
48
|
-
return structureCss;
|
|
49
|
-
}
|
|
50
|
-
// --- Template Skin Implementation ---
|
|
51
|
-
bindEvents(root) {
|
|
52
|
-
// 1. Delegation: Toolbar Events (Handled via direct element ref where possible now, or delegation fallback)
|
|
53
|
-
// We attach the input listener globally on root for delegation,
|
|
54
|
-
// but now that we hold the #searchInput ref, we could bind directly.
|
|
55
|
-
// Delegation is still safer if elements are recreated.
|
|
56
|
-
root.addEventListener('input', (e) => {
|
|
57
|
-
const target = e.target;
|
|
58
|
-
if (target.matches('.jux-search-input')) {
|
|
59
|
-
this.engine.filter(target.value);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
root.addEventListener('click', (e) => {
|
|
63
|
-
const target = e.target;
|
|
64
|
-
// Toolbar: Add
|
|
65
|
-
if (target.closest('.jux-action-add')) {
|
|
66
|
-
this.engine.addItem('New Item');
|
|
67
|
-
const newIndex = this.engine.state.items.length - 1;
|
|
68
|
-
if (newIndex >= 0)
|
|
69
|
-
__classPrivateFieldGet(this, _ListSkin_instances, "m", _ListSkin_openEditModal).call(this, newIndex);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
// Toolbar: Sort
|
|
73
|
-
if (target.closest('.jux-action-sort')) {
|
|
74
|
-
this.engine.toggleSort();
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
// List Item Actions
|
|
78
|
-
const li = target.closest('li');
|
|
79
|
-
if (!li)
|
|
80
|
-
return;
|
|
81
|
-
// ✅ USE ID for robust targeting
|
|
82
|
-
const id = li.dataset.id;
|
|
83
|
-
const indexStr = li.dataset.index;
|
|
84
|
-
if (!indexStr || !id)
|
|
85
|
-
return;
|
|
86
|
-
const index = parseInt(indexStr, 10);
|
|
87
|
-
// Action: Delete
|
|
88
|
-
if (target.closest('.jux-action-delete')) {
|
|
89
|
-
this.engine.removeItem(id); // ✅ Valid per new engine signature
|
|
90
|
-
e.stopImmediatePropagation();
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
// Action: Edit
|
|
94
|
-
if (target.closest('.jux-action-edit')) {
|
|
95
|
-
__classPrivateFieldGet(this, _ListSkin_instances, "m", _ListSkin_openEditModal).call(this, index);
|
|
96
|
-
e.stopImmediatePropagation();
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
// List Item: Selection
|
|
100
|
-
if (!target.closest('.jux-control')) {
|
|
101
|
-
this.engine.toggleSelection(index);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
// 2. Drag & Drop Logic
|
|
105
|
-
root.addEventListener('dragstart', (e) => {
|
|
106
|
-
if (!__classPrivateFieldGet(this, _ListSkin_showMove, "f"))
|
|
107
|
-
return;
|
|
108
|
-
const li = e.target.closest('li');
|
|
109
|
-
if (li) {
|
|
110
|
-
__classPrivateFieldSet(this, _ListSkin_dragSourceIndex, parseInt(li.dataset.index || '-1', 10), "f");
|
|
111
|
-
e.dataTransfer.effectAllowed = 'move';
|
|
112
|
-
e.dataTransfer.setData('text/plain', li.dataset.index || '');
|
|
113
|
-
requestAnimationFrame(() => li.classList.add('jux-dragging'));
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
root.addEventListener('dragend', (e) => {
|
|
117
|
-
const li = e.target.closest('li');
|
|
118
|
-
if (li)
|
|
119
|
-
li.classList.remove('jux-dragging');
|
|
120
|
-
root.querySelectorAll('.jux-item-drop-target').forEach(el => el.classList.remove('jux-item-drop-target'));
|
|
121
|
-
__classPrivateFieldSet(this, _ListSkin_dragSourceIndex, null, "f");
|
|
122
|
-
});
|
|
123
|
-
root.addEventListener('dragover', (e) => {
|
|
124
|
-
if (!__classPrivateFieldGet(this, _ListSkin_showMove, "f"))
|
|
125
|
-
return;
|
|
126
|
-
e.preventDefault();
|
|
127
|
-
const li = e.target.closest('li');
|
|
128
|
-
if (li && !li.classList.contains('jux-dragging')) {
|
|
129
|
-
e.dataTransfer.dropEffect = 'move';
|
|
130
|
-
root.querySelectorAll('.jux-item-drop-target').forEach(el => el.classList.remove('jux-item-drop-target'));
|
|
131
|
-
li.classList.add('jux-item-drop-target');
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
root.addEventListener('drop', (e) => {
|
|
135
|
-
if (!__classPrivateFieldGet(this, _ListSkin_showMove, "f"))
|
|
136
|
-
return;
|
|
137
|
-
e.preventDefault();
|
|
138
|
-
const li = e.target.closest('li');
|
|
139
|
-
if (li && __classPrivateFieldGet(this, _ListSkin_dragSourceIndex, "f") !== null) {
|
|
140
|
-
const toIndex = parseInt(li.dataset.index || '-1', 10);
|
|
141
|
-
if (toIndex !== -1 && __classPrivateFieldGet(this, _ListSkin_dragSourceIndex, "f") !== toIndex) {
|
|
142
|
-
this.engine.moveItem(__classPrivateFieldGet(this, _ListSkin_dragSourceIndex, "f"), toIndex);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Skin Contract: Update/Changes
|
|
149
|
-
*/
|
|
150
|
-
updateSkin(state) {
|
|
151
|
-
if (!this.root)
|
|
152
|
-
return;
|
|
153
|
-
// ✅ Ensure standard ID is set
|
|
154
|
-
this.root.id = state.id;
|
|
155
|
-
// Perform the DOM Update
|
|
156
|
-
const performUpdate = () => {
|
|
157
|
-
this.applySkinAttributes(this.root, state);
|
|
158
|
-
// Lazy Creation
|
|
159
|
-
if (!__classPrivateFieldGet(this, _ListSkin_listContainer, "f")) {
|
|
160
|
-
this.root.innerHTML = '';
|
|
161
|
-
__classPrivateFieldSet(this, _ListSkin_toolbar, document.createElement('div'), "f");
|
|
162
|
-
__classPrivateFieldGet(this, _ListSkin_toolbar, "f").className = 'jux-list-toolbar';
|
|
163
|
-
this.root.appendChild(__classPrivateFieldGet(this, _ListSkin_toolbar, "f"));
|
|
164
|
-
__classPrivateFieldSet(this, _ListSkin_listContainer, document.createElement('div'), "f");
|
|
165
|
-
this.root.appendChild(__classPrivateFieldGet(this, _ListSkin_listContainer, "f"));
|
|
166
|
-
__classPrivateFieldGet(this, _ListSkin_instances, "m", _ListSkin_renderToolbar).call(this); // Initial render
|
|
167
|
-
}
|
|
168
|
-
// Always update toolbar state (e.g. icon direction) without destroying inputs
|
|
169
|
-
__classPrivateFieldGet(this, _ListSkin_instances, "m", _ListSkin_renderToolbar).call(this);
|
|
170
|
-
// Container Classes
|
|
171
|
-
const classes = [...state.classes];
|
|
172
|
-
if (state.selectionMode !== 'none')
|
|
173
|
-
classes.push('jux-list-selectable');
|
|
174
|
-
__classPrivateFieldGet(this, _ListSkin_listContainer, "f").className = classes.join(' ');
|
|
175
|
-
// Filtering
|
|
176
|
-
const visibleItems = state.items
|
|
177
|
-
.map((item, originalIndex) => ({ item, originalIndex }))
|
|
178
|
-
.filter(({ item }) => state.filterText
|
|
179
|
-
? item.text.toLowerCase().includes(state.filterText.toLowerCase())
|
|
180
|
-
: true);
|
|
181
|
-
// Rendering Content
|
|
182
|
-
if (visibleItems.length === 0 && state.noItemsMessage) {
|
|
183
|
-
__classPrivateFieldGet(this, _ListSkin_listContainer, "f").innerHTML = `<div class="jux-list-empty-state">${state.noItemsMessage}</div>`;
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
const tag = state.listType === 'ordered' ? 'ol' : 'ul';
|
|
187
|
-
const html = visibleItems
|
|
188
|
-
.map(({ item, originalIndex }) => __classPrivateFieldGet(this, _ListSkin_instances, "m", _ListSkin_renderListItem).call(this, item, originalIndex, state))
|
|
189
|
-
.join('');
|
|
190
|
-
__classPrivateFieldGet(this, _ListSkin_listContainer, "f").innerHTML = `<${tag} class="jux-list-element jux-list-type-${tag}">${html}</${tag}>`;
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
// ✨ View Transitions Logic
|
|
194
|
-
// We SKIP transition if the search input is focused, otherwise typing janks the UI.
|
|
195
|
-
const isSearching = document.activeElement &&
|
|
196
|
-
(document.activeElement === __classPrivateFieldGet(this, _ListSkin_searchInput, "f"));
|
|
197
|
-
if (!isSearching && typeof document !== 'undefined' && 'startViewTransition' in document) {
|
|
198
|
-
// @ts-ignore
|
|
199
|
-
document.startViewTransition(performUpdate);
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
performUpdate();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
_ListSkin_showSearch = new WeakMap(), _ListSkin_showAdd = new WeakMap(), _ListSkin_showDelete = new WeakMap(), _ListSkin_showEdit = new WeakMap(), _ListSkin_showMove = new WeakMap(), _ListSkin_showSort = new WeakMap(), _ListSkin_dragSourceIndex = new WeakMap(), _ListSkin_toolbar = new WeakMap(), _ListSkin_listContainer = new WeakMap(), _ListSkin_searchInput = new WeakMap(), _ListSkin_addBtn = new WeakMap(), _ListSkin_sortBtn = new WeakMap(), _ListSkin_instances = new WeakSet(), _ListSkin_openEditModal = function _ListSkin_openEditModal(index) {
|
|
207
|
-
const item = this.engine.state.items[index];
|
|
208
|
-
if (!item)
|
|
209
|
-
return;
|
|
210
|
-
const overlay = document.createElement('div');
|
|
211
|
-
overlay.className = 'jux-modal-overlay';
|
|
212
|
-
overlay.innerHTML = `
|
|
213
|
-
<div class="jux-modal">
|
|
214
|
-
<h3>Edit Item</h3>
|
|
215
|
-
<input type="text" id="jux-edit-input" value="${item.text.replace(/"/g, '"')}" />
|
|
216
|
-
<div class="jux-modal-actions">
|
|
217
|
-
<button class="jux-modal-btn jux-btn-cancel" id="jux-edit-cancel">Cancel</button>
|
|
218
|
-
<button class="jux-modal-btn jux-btn-save" id="jux-edit-save">Save</button>
|
|
219
|
-
</div>
|
|
220
|
-
</div>
|
|
221
|
-
`;
|
|
222
|
-
document.body.appendChild(overlay);
|
|
223
|
-
const input = overlay.querySelector('#jux-edit-input');
|
|
224
|
-
const close = () => document.body.removeChild(overlay);
|
|
225
|
-
const save = () => {
|
|
226
|
-
if (input.value.trim())
|
|
227
|
-
this.engine.updateItem(index, input.value);
|
|
228
|
-
close();
|
|
229
|
-
};
|
|
230
|
-
overlay.querySelector('#jux-edit-cancel')?.addEventListener('click', close);
|
|
231
|
-
overlay.querySelector('#jux-edit-save')?.addEventListener('click', save);
|
|
232
|
-
overlay.addEventListener('click', (e) => { if (e.target === overlay)
|
|
233
|
-
close(); });
|
|
234
|
-
input.addEventListener('keydown', (e) => {
|
|
235
|
-
if (e.key === 'Enter')
|
|
236
|
-
save();
|
|
237
|
-
if (e.key === 'Escape')
|
|
238
|
-
close();
|
|
239
|
-
});
|
|
240
|
-
setTimeout(() => { input.focus(); input.select(); }, 0);
|
|
241
|
-
}, _ListSkin_renderToolbar = function _ListSkin_renderToolbar() {
|
|
242
|
-
if (!__classPrivateFieldGet(this, _ListSkin_toolbar, "f"))
|
|
243
|
-
return;
|
|
244
|
-
// 1. Search Logic
|
|
245
|
-
if (__classPrivateFieldGet(this, _ListSkin_showSearch, "f")) {
|
|
246
|
-
if (!__classPrivateFieldGet(this, _ListSkin_searchInput, "f")) {
|
|
247
|
-
__classPrivateFieldSet(this, _ListSkin_searchInput, document.createElement('input'), "f");
|
|
248
|
-
__classPrivateFieldGet(this, _ListSkin_searchInput, "f").type = 'text';
|
|
249
|
-
__classPrivateFieldGet(this, _ListSkin_searchInput, "f").className = 'jux-search-input';
|
|
250
|
-
__classPrivateFieldGet(this, _ListSkin_searchInput, "f").placeholder = 'Filter items...';
|
|
251
|
-
// Insert at start
|
|
252
|
-
__classPrivateFieldGet(this, _ListSkin_toolbar, "f").prepend(__classPrivateFieldGet(this, _ListSkin_searchInput, "f"));
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
else if (__classPrivateFieldGet(this, _ListSkin_searchInput, "f")) {
|
|
256
|
-
__classPrivateFieldGet(this, _ListSkin_searchInput, "f").remove();
|
|
257
|
-
__classPrivateFieldSet(this, _ListSkin_searchInput, null, "f");
|
|
258
|
-
}
|
|
259
|
-
// 2. Sort Logic
|
|
260
|
-
if (__classPrivateFieldGet(this, _ListSkin_showSort, "f")) {
|
|
261
|
-
if (!__classPrivateFieldGet(this, _ListSkin_sortBtn, "f")) {
|
|
262
|
-
__classPrivateFieldSet(this, _ListSkin_sortBtn, document.createElement('button'), "f");
|
|
263
|
-
__classPrivateFieldGet(this, _ListSkin_sortBtn, "f").className = 'jux-action-sort';
|
|
264
|
-
__classPrivateFieldGet(this, _ListSkin_sortBtn, "f").type = 'button';
|
|
265
|
-
__classPrivateFieldGet(this, _ListSkin_sortBtn, "f").ariaLabel = 'Sort';
|
|
266
|
-
__classPrivateFieldGet(this, _ListSkin_toolbar, "f").appendChild(__classPrivateFieldGet(this, _ListSkin_sortBtn, "f"));
|
|
267
|
-
}
|
|
268
|
-
// Update Icon state
|
|
269
|
-
const s = this.engine.state.sorted;
|
|
270
|
-
const icon = s === 'asc' ? '↑' : (s === 'desc' ? '↓' : '↕');
|
|
271
|
-
if (__classPrivateFieldGet(this, _ListSkin_sortBtn, "f").textContent !== icon) {
|
|
272
|
-
__classPrivateFieldGet(this, _ListSkin_sortBtn, "f").textContent = icon;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
else if (__classPrivateFieldGet(this, _ListSkin_sortBtn, "f")) {
|
|
276
|
-
__classPrivateFieldGet(this, _ListSkin_sortBtn, "f").remove();
|
|
277
|
-
__classPrivateFieldSet(this, _ListSkin_sortBtn, null, "f");
|
|
278
|
-
}
|
|
279
|
-
// 3. Add Logic
|
|
280
|
-
if (__classPrivateFieldGet(this, _ListSkin_showAdd, "f")) {
|
|
281
|
-
if (!__classPrivateFieldGet(this, _ListSkin_addBtn, "f")) {
|
|
282
|
-
__classPrivateFieldSet(this, _ListSkin_addBtn, document.createElement('button'), "f");
|
|
283
|
-
__classPrivateFieldGet(this, _ListSkin_addBtn, "f").className = 'jux-action-add';
|
|
284
|
-
__classPrivateFieldGet(this, _ListSkin_addBtn, "f").type = 'button';
|
|
285
|
-
__classPrivateFieldGet(this, _ListSkin_addBtn, "f").ariaLabel = 'Add Item';
|
|
286
|
-
__classPrivateFieldGet(this, _ListSkin_addBtn, "f").textContent = '+';
|
|
287
|
-
__classPrivateFieldGet(this, _ListSkin_toolbar, "f").appendChild(__classPrivateFieldGet(this, _ListSkin_addBtn, "f"));
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
else if (__classPrivateFieldGet(this, _ListSkin_addBtn, "f")) {
|
|
291
|
-
__classPrivateFieldGet(this, _ListSkin_addBtn, "f").remove();
|
|
292
|
-
__classPrivateFieldSet(this, _ListSkin_addBtn, null, "f");
|
|
293
|
-
}
|
|
294
|
-
// Parent Visibility
|
|
295
|
-
const hasChildren = __classPrivateFieldGet(this, _ListSkin_showSearch, "f") || __classPrivateFieldGet(this, _ListSkin_showSort, "f") || __classPrivateFieldGet(this, _ListSkin_showAdd, "f");
|
|
296
|
-
__classPrivateFieldGet(this, _ListSkin_toolbar, "f").style.display = hasChildren ? 'flex' : 'none';
|
|
297
|
-
// ensure Search input is first by re-prepending if it exists
|
|
298
|
-
if (__classPrivateFieldGet(this, _ListSkin_searchInput, "f") && __classPrivateFieldGet(this, _ListSkin_toolbar, "f").firstChild !== __classPrivateFieldGet(this, _ListSkin_searchInput, "f")) {
|
|
299
|
-
__classPrivateFieldGet(this, _ListSkin_toolbar, "f").prepend(__classPrivateFieldGet(this, _ListSkin_searchInput, "f"));
|
|
300
|
-
}
|
|
301
|
-
}, _ListSkin_renderListItem = function _ListSkin_renderListItem(item, index, state) {
|
|
302
|
-
const css = [
|
|
303
|
-
'jux-list-item',
|
|
304
|
-
item.selected ? 'jux-selected' : '',
|
|
305
|
-
...(item.classes || [])
|
|
306
|
-
].filter(Boolean).join(' ');
|
|
307
|
-
// ✅ Determine Content based on Columns configuration
|
|
308
|
-
let content = item.text;
|
|
309
|
-
if (state.columns && state.columns.length > 0) {
|
|
310
|
-
content = state.columns.map(col => {
|
|
311
|
-
const key = typeof col === 'string' ? col : col.key;
|
|
312
|
-
const cssClass = (typeof col === 'object' && col.label) ? `jux-col-${key}` : ''; // Basic class hook
|
|
313
|
-
const value = item[key] ?? '';
|
|
314
|
-
// If complex object, stringify or fallback
|
|
315
|
-
const displayVal = (typeof value === 'object') ? JSON.stringify(value) : String(value);
|
|
316
|
-
return `<span class="jux-col ${cssClass}">${displayVal}</span>`;
|
|
317
|
-
}).join(' <span class="jux-col-sep"> </span> ');
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
// Default Fallback logic: If no columns but item.text is boring ("[object Object]"), try to find keys
|
|
321
|
-
if (content === '[object Object]') {
|
|
322
|
-
const keys = Object.keys(item).filter(k => k !== 'id' && k !== 'selected' && k !== 'classes' && k !== 'text' && k !== 'value');
|
|
323
|
-
if (keys.length > 0) {
|
|
324
|
-
content = `${item[keys[0]]}`;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
const moveBtn = __classPrivateFieldGet(this, _ListSkin_showMove, "f") ? `<span class="jux-action-drag jux-control" title="Drag to reorder">≡</span>` : '';
|
|
329
|
-
const editBtn = __classPrivateFieldGet(this, _ListSkin_showEdit, "f") ? `<button class="jux-action-edit jux-control" aria-label="Edit">✎</button>` : '';
|
|
330
|
-
const deleteBtn = __classPrivateFieldGet(this, _ListSkin_showDelete, "f") ? `<button class="jux-action-delete jux-control" aria-label="Delete">×</button>` : '';
|
|
331
|
-
const draggableAttr = __classPrivateFieldGet(this, _ListSkin_showMove, "f") ? 'draggable="true"' : '';
|
|
332
|
-
const transitionName = `jux-item-${item.id.replace(/[^a-zA-Z0-9-_]/g, '-')}`;
|
|
333
|
-
return `
|
|
334
|
-
<li data-id="${item.id}" data-index="${index}" class="${css}" ${draggableAttr} style="view-transition-name: ${transitionName}">
|
|
335
|
-
<div class="jux-list-item-content">
|
|
336
|
-
${content}
|
|
337
|
-
</div>
|
|
338
|
-
<div class="jux-item-controls">
|
|
339
|
-
${moveBtn}
|
|
340
|
-
${editBtn}
|
|
341
|
-
${deleteBtn}
|
|
342
|
-
</div>
|
|
343
|
-
</li>`;
|
|
344
|
-
};
|
|
345
|
-
//# sourceMappingURL=ListSkin.js.map
|