@vobs/table 1.1.0 → 1.2.1
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/dist/column-settings.cjs +1036 -0
- package/dist/column-settings.cjs.map +1 -0
- package/dist/column-settings.d.cts +7 -0
- package/dist/column-settings.d.ts +7 -0
- package/dist/column-settings.js +1034 -0
- package/dist/column-settings.js.map +1 -0
- package/dist/data-table.cjs +1671 -0
- package/dist/data-table.cjs.map +1 -0
- package/dist/data-table.d.cts +7 -0
- package/dist/data-table.d.ts +7 -0
- package/dist/data-table.js +1669 -0
- package/dist/data-table.js.map +1 -0
- package/dist/icons.cjs +835 -0
- package/dist/icons.cjs.map +1 -0
- package/dist/icons.d.cts +8 -0
- package/dist/icons.d.ts +8 -0
- package/dist/icons.js +833 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.cjs +2067 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +2059 -0
- package/dist/index.js.map +1 -0
- package/dist/persistence.cjs +86 -0
- package/dist/persistence.cjs.map +1 -0
- package/dist/persistence.d.cts +8 -0
- package/dist/persistence.d.ts +8 -0
- package/dist/persistence.js +83 -0
- package/dist/persistence.js.map +1 -0
- package/dist/styles/styles.css +1 -0
- package/dist/styles/table.css +209 -0
- package/dist/types.cjs +4 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +164 -0
- package/dist/types.d.ts +164 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.cjs +525 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +19 -0
- package/dist/utils.d.ts +19 -0
- package/dist/utils.js +511 -0
- package/dist/utils.js.map +1 -0
- package/package.json +42 -11
- package/src/data-table.ts +26 -10
- package/src/icons.ts +14 -0
- package/src/index.ts +1 -0
- package/src/types.ts +4 -2
|
@@ -0,0 +1,1669 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// packages/reactivity/src/debug.ts
|
|
5
|
+
var activeDebugHooks = null;
|
|
6
|
+
var signalNames = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
function hasDebugHooks() {
|
|
8
|
+
return activeDebugHooks !== null;
|
|
9
|
+
}
|
|
10
|
+
__name(hasDebugHooks, "hasDebugHooks");
|
|
11
|
+
function setSignalDebugName(signal, name) {
|
|
12
|
+
signalNames.set(signal, name);
|
|
13
|
+
invokeDebug("signalNamed", signal, name);
|
|
14
|
+
}
|
|
15
|
+
__name(setSignalDebugName, "setSignalDebugName");
|
|
16
|
+
function invokeDebug(name, ...args) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
__name(invokeDebug, "invokeDebug");
|
|
20
|
+
|
|
21
|
+
// packages/reactivity/src/owner.ts
|
|
22
|
+
var currentOwner = null;
|
|
23
|
+
var nextOwnerId = 1;
|
|
24
|
+
var ownerNames = /* @__PURE__ */ new WeakMap();
|
|
25
|
+
function createOwner() {
|
|
26
|
+
const parent = currentOwner;
|
|
27
|
+
let disposed = parent?.disposed ?? false;
|
|
28
|
+
const children = [];
|
|
29
|
+
const cleanups = [];
|
|
30
|
+
const errorHandlers = /* @__PURE__ */ new Set();
|
|
31
|
+
const owner = {
|
|
32
|
+
id: `owner-${nextOwnerId++}`,
|
|
33
|
+
parent,
|
|
34
|
+
children,
|
|
35
|
+
depth: (parent?.depth ?? -1) + 1,
|
|
36
|
+
get disposed() {
|
|
37
|
+
return disposed;
|
|
38
|
+
},
|
|
39
|
+
run(fn) {
|
|
40
|
+
if (disposed) throw new Error("Vobs: \u5DF2\u9500\u6BC1\u7684 Owner \u4E0D\u80FD\u7EE7\u7EED\u8FD0\u884C");
|
|
41
|
+
const previous = currentOwner;
|
|
42
|
+
currentOwner = owner;
|
|
43
|
+
try {
|
|
44
|
+
return fn();
|
|
45
|
+
} finally {
|
|
46
|
+
currentOwner = previous;
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
addCleanup(cleanup) {
|
|
50
|
+
if (disposed) {
|
|
51
|
+
cleanup();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
cleanups.push(cleanup);
|
|
55
|
+
},
|
|
56
|
+
onDispose(cleanup) {
|
|
57
|
+
owner.addCleanup(cleanup);
|
|
58
|
+
},
|
|
59
|
+
onError(handler) {
|
|
60
|
+
errorHandlers.add(handler);
|
|
61
|
+
const remove = /* @__PURE__ */ __name(() => errorHandlers.delete(handler), "remove");
|
|
62
|
+
owner.addCleanup(remove);
|
|
63
|
+
return remove;
|
|
64
|
+
},
|
|
65
|
+
handleError(error) {
|
|
66
|
+
for (const handler of [...errorHandlers].reverse()) {
|
|
67
|
+
try {
|
|
68
|
+
handler(error);
|
|
69
|
+
return true;
|
|
70
|
+
} catch (handlerError) {
|
|
71
|
+
return parent?.handleError(handlerError) ?? false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return parent?.handleError(error) ?? false;
|
|
75
|
+
},
|
|
76
|
+
dispose() {
|
|
77
|
+
if (disposed) return;
|
|
78
|
+
disposed = true;
|
|
79
|
+
for (const child of [...children]) child.dispose();
|
|
80
|
+
children.length = 0;
|
|
81
|
+
let firstError;
|
|
82
|
+
for (let index = cleanups.length - 1; index >= 0; index--) {
|
|
83
|
+
try {
|
|
84
|
+
cleanups[index]();
|
|
85
|
+
} catch (error) {
|
|
86
|
+
firstError ?? (firstError = error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
cleanups.length = 0;
|
|
90
|
+
if (parent) {
|
|
91
|
+
const index = parent.children.indexOf(owner);
|
|
92
|
+
if (index >= 0) parent.children.splice(index, 1);
|
|
93
|
+
}
|
|
94
|
+
if (firstError) throw firstError;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
if (parent && !parent.disposed) parent.children.push(owner);
|
|
98
|
+
return owner;
|
|
99
|
+
}
|
|
100
|
+
__name(createOwner, "createOwner");
|
|
101
|
+
function setOwnerDebugName(owner, name) {
|
|
102
|
+
ownerNames.set(owner, name);
|
|
103
|
+
}
|
|
104
|
+
__name(setOwnerDebugName, "setOwnerDebugName");
|
|
105
|
+
function getCurrentOwner() {
|
|
106
|
+
return currentOwner;
|
|
107
|
+
}
|
|
108
|
+
__name(getCurrentOwner, "getCurrentOwner");
|
|
109
|
+
|
|
110
|
+
// packages/reactivity/src/signal.ts
|
|
111
|
+
var currentSubscriber = null;
|
|
112
|
+
function getCurrentSubscriber() {
|
|
113
|
+
return currentSubscriber;
|
|
114
|
+
}
|
|
115
|
+
__name(getCurrentSubscriber, "getCurrentSubscriber");
|
|
116
|
+
function setCurrentSubscriber(subscriber) {
|
|
117
|
+
currentSubscriber = subscriber;
|
|
118
|
+
}
|
|
119
|
+
__name(setCurrentSubscriber, "setCurrentSubscriber");
|
|
120
|
+
function trackDependency(dependency) {
|
|
121
|
+
if (!currentSubscriber || currentSubscriber.disposed) return;
|
|
122
|
+
!currentSubscriber.dependencies.has(dependency);
|
|
123
|
+
currentSubscriber.dependencies.add(dependency);
|
|
124
|
+
}
|
|
125
|
+
__name(trackDependency, "trackDependency");
|
|
126
|
+
function state(initialValue, debugName) {
|
|
127
|
+
let value = initialValue;
|
|
128
|
+
let disposed = false;
|
|
129
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
130
|
+
const signalInstance = {
|
|
131
|
+
get value() {
|
|
132
|
+
const subscriber = getCurrentSubscriber();
|
|
133
|
+
if (subscriber && !subscriber.disposed) {
|
|
134
|
+
subscribers.add(subscriber);
|
|
135
|
+
trackDependency(signalInstance);
|
|
136
|
+
}
|
|
137
|
+
return value;
|
|
138
|
+
},
|
|
139
|
+
set value(nextValue) {
|
|
140
|
+
if (disposed || Object.is(value, nextValue)) return;
|
|
141
|
+
value = nextValue;
|
|
142
|
+
for (const subscriber of [...subscribers]) subscriber.notify();
|
|
143
|
+
},
|
|
144
|
+
unsubscribe(subscriber) {
|
|
145
|
+
subscribers.delete(subscriber);
|
|
146
|
+
},
|
|
147
|
+
// 与 `.value =` 赋值同一条路径:判等短路、debug hook、notify 全部一致。
|
|
148
|
+
// 以闭包实现,可安全地作为回调直接传递(无 this 绑定问题)。
|
|
149
|
+
set(next) {
|
|
150
|
+
signalInstance.value = next;
|
|
151
|
+
},
|
|
152
|
+
dispose() {
|
|
153
|
+
if (disposed) return;
|
|
154
|
+
disposed = true;
|
|
155
|
+
subscribers.clear();
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const owner = getCurrentOwner();
|
|
159
|
+
owner?.addCleanup(signalInstance.dispose);
|
|
160
|
+
if (debugName?.trim()) setSignalDebugName(signalInstance, debugName.trim());
|
|
161
|
+
return signalInstance;
|
|
162
|
+
}
|
|
163
|
+
__name(state, "state");
|
|
164
|
+
|
|
165
|
+
// packages/reactivity/src/scheduler.ts
|
|
166
|
+
var _Scheduler = class _Scheduler {
|
|
167
|
+
constructor() {
|
|
168
|
+
this.dirtyEffects = /* @__PURE__ */ new Set();
|
|
169
|
+
this.lowPriorityEffects = /* @__PURE__ */ new Set();
|
|
170
|
+
// flush 不可重入(flushing 标志保证),缓冲数组可在轮次间安全复用,避免每轮分配。
|
|
171
|
+
this.normalBuffer = [];
|
|
172
|
+
this.lowBuffer = [];
|
|
173
|
+
this.flushing = false;
|
|
174
|
+
this.scheduled = false;
|
|
175
|
+
this.batchDepth = 0;
|
|
176
|
+
}
|
|
177
|
+
schedule(effect2) {
|
|
178
|
+
if (effect2.disposed) return;
|
|
179
|
+
this.dirtyEffects.add(effect2);
|
|
180
|
+
this.lowPriorityEffects.delete(effect2);
|
|
181
|
+
this.ensureScheduled();
|
|
182
|
+
}
|
|
183
|
+
/** Queue an effect behind normal updates while preserving deterministic order. */
|
|
184
|
+
scheduleLow(effect2) {
|
|
185
|
+
if (effect2.disposed) return;
|
|
186
|
+
if (!this.dirtyEffects.has(effect2)) this.lowPriorityEffects.add(effect2);
|
|
187
|
+
this.ensureScheduled();
|
|
188
|
+
}
|
|
189
|
+
ensureScheduled() {
|
|
190
|
+
if (this.batchDepth === 0 && !this.flushing && !this.scheduled) {
|
|
191
|
+
this.scheduled = true;
|
|
192
|
+
queueMicrotask(() => {
|
|
193
|
+
this.scheduled = false;
|
|
194
|
+
this.flush();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
remove(effect2) {
|
|
199
|
+
this.dirtyEffects.delete(effect2);
|
|
200
|
+
this.lowPriorityEffects.delete(effect2);
|
|
201
|
+
}
|
|
202
|
+
batch(fn) {
|
|
203
|
+
this.batchDepth++;
|
|
204
|
+
try {
|
|
205
|
+
return fn();
|
|
206
|
+
} finally {
|
|
207
|
+
this.batchDepth--;
|
|
208
|
+
if (this.batchDepth === 0) this.flush();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
flush() {
|
|
212
|
+
if (this.flushing || this.batchDepth > 0) return;
|
|
213
|
+
this.flushing = true;
|
|
214
|
+
let rounds = 0;
|
|
215
|
+
let firstError;
|
|
216
|
+
let hasError = false;
|
|
217
|
+
try {
|
|
218
|
+
while (this.dirtyEffects.size > 0 || this.lowPriorityEffects.size > 0) {
|
|
219
|
+
if (++rounds > 100) {
|
|
220
|
+
this.dirtyEffects.clear();
|
|
221
|
+
this.lowPriorityEffects.clear();
|
|
222
|
+
throw new Error("Vobs: \u54CD\u5E94\u5F0F\u66F4\u65B0\u8D85\u8FC7 100 \u8F6E\uFF0C\u53EF\u80FD\u5B58\u5728\u5FAA\u73AF\u4F9D\u8D56");
|
|
223
|
+
}
|
|
224
|
+
this.collectRunnable(this.dirtyEffects, this.normalBuffer);
|
|
225
|
+
this.collectRunnable(this.lowPriorityEffects, this.lowBuffer);
|
|
226
|
+
sortEffects(this.normalBuffer);
|
|
227
|
+
sortEffects(this.lowBuffer);
|
|
228
|
+
for (const effect2 of this.normalBuffer) {
|
|
229
|
+
try {
|
|
230
|
+
effect2.run();
|
|
231
|
+
} catch (error) {
|
|
232
|
+
if (!hasError) {
|
|
233
|
+
firstError = error;
|
|
234
|
+
hasError = true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
for (const effect2 of this.lowBuffer) {
|
|
239
|
+
try {
|
|
240
|
+
effect2.run();
|
|
241
|
+
} catch (error) {
|
|
242
|
+
if (!hasError) {
|
|
243
|
+
firstError = error;
|
|
244
|
+
hasError = true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
this.normalBuffer.length = 0;
|
|
249
|
+
this.lowBuffer.length = 0;
|
|
250
|
+
}
|
|
251
|
+
} finally {
|
|
252
|
+
this.normalBuffer.length = 0;
|
|
253
|
+
this.lowBuffer.length = 0;
|
|
254
|
+
this.flushing = false;
|
|
255
|
+
}
|
|
256
|
+
if (hasError) throw firstError;
|
|
257
|
+
}
|
|
258
|
+
/** 收集未 disposed 的 effect 并清空源集合;run() 期间新调度的 effect 留给下一轮。 */
|
|
259
|
+
collectRunnable(source, target) {
|
|
260
|
+
for (const effect2 of source) {
|
|
261
|
+
if (!effect2.disposed) target.push(effect2);
|
|
262
|
+
}
|
|
263
|
+
source.clear();
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
__name(_Scheduler, "Scheduler");
|
|
267
|
+
var Scheduler = _Scheduler;
|
|
268
|
+
function sortEffects(effects) {
|
|
269
|
+
if (effects.length > 1) {
|
|
270
|
+
effects.sort((a, b) => b.depth - a.depth || a.order - b.order);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
__name(sortEffects, "sortEffects");
|
|
274
|
+
var scheduler = new Scheduler();
|
|
275
|
+
|
|
276
|
+
// packages/reactivity/src/effect.ts
|
|
277
|
+
var nextEffectOrder = 1;
|
|
278
|
+
function cleanupDependencies(subscriber) {
|
|
279
|
+
for (const dependency of subscriber.dependencies) {
|
|
280
|
+
dependency.unsubscribe(subscriber);
|
|
281
|
+
}
|
|
282
|
+
subscriber.dependencies.clear();
|
|
283
|
+
}
|
|
284
|
+
__name(cleanupDependencies, "cleanupDependencies");
|
|
285
|
+
function effect(callback) {
|
|
286
|
+
const owner = getCurrentOwner();
|
|
287
|
+
let cleanup;
|
|
288
|
+
let dirty = true;
|
|
289
|
+
let disposed = false;
|
|
290
|
+
const eff = {
|
|
291
|
+
order: nextEffectOrder++,
|
|
292
|
+
depth: owner?.depth ?? 0,
|
|
293
|
+
dependencies: /* @__PURE__ */ new Set(),
|
|
294
|
+
get disposed() {
|
|
295
|
+
return disposed;
|
|
296
|
+
},
|
|
297
|
+
notify() {
|
|
298
|
+
if (disposed || dirty) return;
|
|
299
|
+
dirty = true;
|
|
300
|
+
scheduler.schedule(eff);
|
|
301
|
+
},
|
|
302
|
+
run() {
|
|
303
|
+
if (disposed || !dirty) return;
|
|
304
|
+
dirty = false;
|
|
305
|
+
const previousCleanup = cleanup;
|
|
306
|
+
cleanup = void 0;
|
|
307
|
+
let cleanupError;
|
|
308
|
+
if (previousCleanup) {
|
|
309
|
+
try {
|
|
310
|
+
previousCleanup();
|
|
311
|
+
} catch (error) {
|
|
312
|
+
const handled2 = owner?.handleError(error) ?? false;
|
|
313
|
+
if (!handled2) cleanupError = error;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
cleanupDependencies(eff);
|
|
317
|
+
const previous = getCurrentSubscriber();
|
|
318
|
+
setCurrentSubscriber(eff);
|
|
319
|
+
let thrown;
|
|
320
|
+
let handled = false;
|
|
321
|
+
try {
|
|
322
|
+
const result = owner ? owner.run(callback) : callback();
|
|
323
|
+
cleanup = typeof result === "function" ? result : void 0;
|
|
324
|
+
} catch (error) {
|
|
325
|
+
thrown = error;
|
|
326
|
+
handled = owner?.handleError(error) ?? false;
|
|
327
|
+
if (!handled) throw error;
|
|
328
|
+
} finally {
|
|
329
|
+
setCurrentSubscriber(previous);
|
|
330
|
+
}
|
|
331
|
+
if (cleanupError && !thrown) throw cleanupError;
|
|
332
|
+
},
|
|
333
|
+
scheduleLow() {
|
|
334
|
+
if (disposed || dirty) return;
|
|
335
|
+
dirty = true;
|
|
336
|
+
scheduler.scheduleLow(eff);
|
|
337
|
+
},
|
|
338
|
+
dispose() {
|
|
339
|
+
if (disposed) return;
|
|
340
|
+
disposed = true;
|
|
341
|
+
dirty = false;
|
|
342
|
+
scheduler.remove(eff);
|
|
343
|
+
const previousCleanup = cleanup;
|
|
344
|
+
cleanup = void 0;
|
|
345
|
+
let cleanupError;
|
|
346
|
+
if (previousCleanup) {
|
|
347
|
+
try {
|
|
348
|
+
previousCleanup();
|
|
349
|
+
} catch (error) {
|
|
350
|
+
const handled = owner?.handleError(error) ?? false;
|
|
351
|
+
if (!handled) cleanupError = error;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
cleanupDependencies(eff);
|
|
355
|
+
if (cleanupError) throw cleanupError;
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
owner?.addCleanup(eff.dispose);
|
|
359
|
+
eff.run();
|
|
360
|
+
return eff;
|
|
361
|
+
}
|
|
362
|
+
__name(effect, "effect");
|
|
363
|
+
|
|
364
|
+
// packages/runtime/src/debug.ts
|
|
365
|
+
var activeRuntimeDebugHooks = null;
|
|
366
|
+
function getRuntimeDebugHooks() {
|
|
367
|
+
return activeRuntimeDebugHooks;
|
|
368
|
+
}
|
|
369
|
+
__name(getRuntimeDebugHooks, "getRuntimeDebugHooks");
|
|
370
|
+
function invokeRuntimeDebug(name, ...args) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
__name(invokeRuntimeDebug, "invokeRuntimeDebug");
|
|
374
|
+
function readDebugValue(read) {
|
|
375
|
+
try {
|
|
376
|
+
return read();
|
|
377
|
+
} catch {
|
|
378
|
+
return "[Uninspectable]";
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
__name(readDebugValue, "readDebugValue");
|
|
382
|
+
function describeDebugNode(node) {
|
|
383
|
+
if (!node || typeof node !== "object") return "node";
|
|
384
|
+
const value = node;
|
|
385
|
+
const name = typeof value.tagName === "string" ? value.tagName.toLowerCase() : typeof value.nodeName === "string" ? value.nodeName.toLowerCase() : "node";
|
|
386
|
+
const id = typeof value.id === "string" && value.id ? `#${value.id}` : "";
|
|
387
|
+
const className = typeof value.className === "string" && value.className ? `.${value.className.trim().split(/\s+/).filter(Boolean).join(".")}` : "";
|
|
388
|
+
return `${name}${id}${className}`;
|
|
389
|
+
}
|
|
390
|
+
__name(describeDebugNode, "describeDebugNode");
|
|
391
|
+
|
|
392
|
+
// packages/runtime/src/hmr.ts
|
|
393
|
+
var globalTarget = globalThis;
|
|
394
|
+
var hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: /* @__PURE__ */ new Map() };
|
|
395
|
+
globalTarget.__VOBS_HMR__ = hmrGlobal;
|
|
396
|
+
function registerHmrInstance(moduleId, instance) {
|
|
397
|
+
const instances = getModule(moduleId).instances;
|
|
398
|
+
instances.add(instance);
|
|
399
|
+
return () => instances.delete(instance);
|
|
400
|
+
}
|
|
401
|
+
__name(registerHmrInstance, "registerHmrInstance");
|
|
402
|
+
function markHmrInstanceMounted(node, parent) {
|
|
403
|
+
const instance = hmrInstances.get(node);
|
|
404
|
+
if (instance) instance.parent = parent;
|
|
405
|
+
}
|
|
406
|
+
__name(markHmrInstanceMounted, "markHmrInstanceMounted");
|
|
407
|
+
function getModule(moduleId) {
|
|
408
|
+
let module = hmrGlobal.modules.get(moduleId);
|
|
409
|
+
if (!module) {
|
|
410
|
+
module = { components: /* @__PURE__ */ new Map(), state: /* @__PURE__ */ new Map(), instances: /* @__PURE__ */ new Set() };
|
|
411
|
+
hmrGlobal.modules.set(moduleId, module);
|
|
412
|
+
}
|
|
413
|
+
return module;
|
|
414
|
+
}
|
|
415
|
+
__name(getModule, "getModule");
|
|
416
|
+
var hmrInstances = /* @__PURE__ */ new WeakMap();
|
|
417
|
+
function associateHmrInstance(node, instance) {
|
|
418
|
+
hmrInstances.set(node, instance);
|
|
419
|
+
}
|
|
420
|
+
__name(associateHmrInstance, "associateHmrInstance");
|
|
421
|
+
var nodeOwners = /* @__PURE__ */ new WeakMap();
|
|
422
|
+
var eventBindings = /* @__PURE__ */ new WeakMap();
|
|
423
|
+
function getRenderer() {
|
|
424
|
+
{
|
|
425
|
+
throw new Error("\u6E32\u67D3\u5668\u672A\u521D\u59CB\u5316");
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
__name(getRenderer, "getRenderer");
|
|
429
|
+
function createText(content) {
|
|
430
|
+
return getRenderer().createText(content);
|
|
431
|
+
}
|
|
432
|
+
__name(createText, "createText");
|
|
433
|
+
function createElement(tag) {
|
|
434
|
+
return getRenderer().createElement(tag);
|
|
435
|
+
}
|
|
436
|
+
__name(createElement, "createElement");
|
|
437
|
+
function createComment(content) {
|
|
438
|
+
return getRenderer().createComment(content);
|
|
439
|
+
}
|
|
440
|
+
__name(createComment, "createComment");
|
|
441
|
+
function insertBefore(parent, child, anchor) {
|
|
442
|
+
if (isVobsFragment(child)) {
|
|
443
|
+
child.mount(parent, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
getRenderer().insertBefore(parent, child, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
447
|
+
markHmrInstanceMounted(child, parent);
|
|
448
|
+
}
|
|
449
|
+
__name(insertBefore, "insertBefore");
|
|
450
|
+
function removeChild(parent, child) {
|
|
451
|
+
disposeNodeOwner(child);
|
|
452
|
+
if (isVobsFragment(child)) {
|
|
453
|
+
child.unmount(parent);
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
getRenderer().removeChild(parent, child);
|
|
457
|
+
}
|
|
458
|
+
__name(removeChild, "removeChild");
|
|
459
|
+
function setProperty(node, key, value) {
|
|
460
|
+
getRenderer().setProperty(node, key, value);
|
|
461
|
+
}
|
|
462
|
+
__name(setProperty, "setProperty");
|
|
463
|
+
function setAttribute(node, key, value) {
|
|
464
|
+
getRenderer().setAttribute(node, key, value);
|
|
465
|
+
}
|
|
466
|
+
__name(setAttribute, "setAttribute");
|
|
467
|
+
function addEventListener(node, event, handler) {
|
|
468
|
+
const renderer = getRenderer();
|
|
469
|
+
const owner = getCurrentOwner();
|
|
470
|
+
let bindings = eventBindings.get(node);
|
|
471
|
+
if (!bindings) {
|
|
472
|
+
bindings = /* @__PURE__ */ new Map();
|
|
473
|
+
eventBindings.set(node, bindings);
|
|
474
|
+
}
|
|
475
|
+
const previous = bindings.get(event);
|
|
476
|
+
if (previous && previous.original === handler && previous.owner === owner) return;
|
|
477
|
+
if (previous) renderer.removeEventListener(node, event, previous.handler);
|
|
478
|
+
const listener = owner ? (reason) => {
|
|
479
|
+
try {
|
|
480
|
+
owner.run(() => handler(reason));
|
|
481
|
+
} catch (error) {
|
|
482
|
+
const handled = owner.handleError(error);
|
|
483
|
+
invokeRuntimeDebug("error", {
|
|
484
|
+
error,
|
|
485
|
+
owner,
|
|
486
|
+
phase: "event",
|
|
487
|
+
handled,
|
|
488
|
+
recovery: handled ? "handled" : "propagated"
|
|
489
|
+
});
|
|
490
|
+
if (!handled) throw error;
|
|
491
|
+
}
|
|
492
|
+
} : handler;
|
|
493
|
+
const binding = { handler: listener, owner, original: handler };
|
|
494
|
+
bindings.set(event, binding);
|
|
495
|
+
renderer.addEventListener(node, event, listener);
|
|
496
|
+
owner?.onDispose(() => {
|
|
497
|
+
if (bindings?.get(event) !== binding) return;
|
|
498
|
+
bindings.delete(event);
|
|
499
|
+
renderer.removeEventListener(node, event, listener);
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
__name(addEventListener, "addEventListener");
|
|
503
|
+
function createComponent(component, props, source) {
|
|
504
|
+
const owner = createOwner();
|
|
505
|
+
const componentName = component.displayName || component.name || "anonymous";
|
|
506
|
+
setOwnerDebugName(owner, source ? `${componentName} (${source.file}:${source.line}:${source.column})` : componentName);
|
|
507
|
+
owner.onError((reason) => {
|
|
508
|
+
attachSourceLocation(reason, source);
|
|
509
|
+
attachComponentContext(reason, componentName, owner.id);
|
|
510
|
+
throw reason;
|
|
511
|
+
});
|
|
512
|
+
let node;
|
|
513
|
+
try {
|
|
514
|
+
node = owner.run(() => component(props));
|
|
515
|
+
} catch (error) {
|
|
516
|
+
owner.dispose();
|
|
517
|
+
attachSourceLocation(error, source);
|
|
518
|
+
attachComponentContext(error, componentName, owner.id);
|
|
519
|
+
throw error;
|
|
520
|
+
}
|
|
521
|
+
associateNodeOwner(node, owner);
|
|
522
|
+
const hmrKey = component.hmrKey;
|
|
523
|
+
if (hmrKey) {
|
|
524
|
+
const instance = {
|
|
525
|
+
node,
|
|
526
|
+
parent: null,
|
|
527
|
+
refresh() {
|
|
528
|
+
const previous = instance.node;
|
|
529
|
+
const next = owner.run(() => component(props));
|
|
530
|
+
if (instance.parent && !isVobsFragment(previous) && !isVobsFragment(next)) {
|
|
531
|
+
getRenderer().insertBefore(instance.parent, next, previous);
|
|
532
|
+
getRenderer().removeChild(instance.parent, previous);
|
|
533
|
+
}
|
|
534
|
+
nodeOwners.delete(previous);
|
|
535
|
+
nodeOwners.set(next, owner);
|
|
536
|
+
associateHmrInstance(next, instance);
|
|
537
|
+
instance.node = next;
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
associateHmrInstance(node, instance);
|
|
541
|
+
const separator = hmrKey.lastIndexOf(":");
|
|
542
|
+
const moduleId = separator < 0 ? hmrKey : hmrKey.slice(0, separator);
|
|
543
|
+
const cleanup = registerHmrInstance(moduleId, instance);
|
|
544
|
+
owner.onDispose(cleanup);
|
|
545
|
+
}
|
|
546
|
+
return node;
|
|
547
|
+
}
|
|
548
|
+
__name(createComponent, "createComponent");
|
|
549
|
+
function attachSourceLocation(reason, source) {
|
|
550
|
+
if (!source || (!reason || typeof reason !== "object" && typeof reason !== "function")) return;
|
|
551
|
+
const error = reason;
|
|
552
|
+
if (error.vobsSource) return;
|
|
553
|
+
try {
|
|
554
|
+
Object.defineProperty(error, "vobsSource", {
|
|
555
|
+
configurable: true,
|
|
556
|
+
enumerable: false,
|
|
557
|
+
value: source,
|
|
558
|
+
writable: false
|
|
559
|
+
});
|
|
560
|
+
} catch {
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
__name(attachSourceLocation, "attachSourceLocation");
|
|
564
|
+
function attachComponentContext(reason, component, ownerId) {
|
|
565
|
+
if (!reason || typeof reason !== "object" && typeof reason !== "function") return;
|
|
566
|
+
const error = reason;
|
|
567
|
+
try {
|
|
568
|
+
if (!error.vobsComponent) Object.defineProperty(error, "vobsComponent", { configurable: true, enumerable: false, value: component, writable: false });
|
|
569
|
+
if (!error.vobsOwnerId) Object.defineProperty(error, "vobsOwnerId", { configurable: true, enumerable: false, value: ownerId, writable: false });
|
|
570
|
+
} catch {
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
__name(attachComponentContext, "attachComponentContext");
|
|
574
|
+
function createBlock(factory) {
|
|
575
|
+
const owner = createOwner();
|
|
576
|
+
setOwnerDebugName(owner, "dynamic");
|
|
577
|
+
let node;
|
|
578
|
+
try {
|
|
579
|
+
node = owner.run(factory);
|
|
580
|
+
} catch (error) {
|
|
581
|
+
owner.dispose();
|
|
582
|
+
throw error;
|
|
583
|
+
}
|
|
584
|
+
if (!node) {
|
|
585
|
+
owner.dispose();
|
|
586
|
+
return null;
|
|
587
|
+
}
|
|
588
|
+
associateNodeOwner(node, owner);
|
|
589
|
+
return node;
|
|
590
|
+
}
|
|
591
|
+
__name(createBlock, "createBlock");
|
|
592
|
+
function associateNodeOwner(node, owner) {
|
|
593
|
+
nodeOwners.set(node, owner);
|
|
594
|
+
}
|
|
595
|
+
__name(associateNodeOwner, "associateNodeOwner");
|
|
596
|
+
function disposeNodeOwner(node) {
|
|
597
|
+
const owner = nodeOwners.get(node);
|
|
598
|
+
if (!owner) return;
|
|
599
|
+
nodeOwners.delete(node);
|
|
600
|
+
owner.dispose();
|
|
601
|
+
}
|
|
602
|
+
__name(disposeNodeOwner, "disposeNodeOwner");
|
|
603
|
+
|
|
604
|
+
// packages/runtime/src/fragment.ts
|
|
605
|
+
function createFragment(factory) {
|
|
606
|
+
const start = createComment("vobs:fragment:start");
|
|
607
|
+
const end = createComment("vobs:fragment:end");
|
|
608
|
+
let parent = null;
|
|
609
|
+
let initialized = false;
|
|
610
|
+
const owner = getCurrentOwner();
|
|
611
|
+
const fragment = {
|
|
612
|
+
kind: "vobs-fragment",
|
|
613
|
+
start,
|
|
614
|
+
end,
|
|
615
|
+
mount(nextParent, anchor) {
|
|
616
|
+
if (parent && parent !== nextParent) {
|
|
617
|
+
throw new Error("Vobs Fragment: \u4E0D\u80FD\u8DE8\u7236\u8282\u70B9\u79FB\u52A8 Fragment");
|
|
618
|
+
}
|
|
619
|
+
if (initialized) {
|
|
620
|
+
moveRange(nextParent, start, end, anchor);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
const renderer = getRenderer();
|
|
624
|
+
renderer.insertBefore(nextParent, start, anchor);
|
|
625
|
+
renderer.insertBefore(nextParent, end, anchor);
|
|
626
|
+
parent = nextParent;
|
|
627
|
+
initialized = true;
|
|
628
|
+
if (owner) owner.run(() => factory(nextParent, end));
|
|
629
|
+
else factory(nextParent, end);
|
|
630
|
+
},
|
|
631
|
+
unmount(nextParent) {
|
|
632
|
+
if (!initialized || parent !== nextParent) {
|
|
633
|
+
throw new Error("Vobs Fragment: Fragment \u4E0D\u5C5E\u4E8E\u6307\u5B9A\u7236\u8282\u70B9");
|
|
634
|
+
}
|
|
635
|
+
const renderer = getRenderer();
|
|
636
|
+
let current = renderer.nextSibling(start);
|
|
637
|
+
while (current && current !== end) {
|
|
638
|
+
const next = renderer.nextSibling(current);
|
|
639
|
+
renderer.removeChild(nextParent, current);
|
|
640
|
+
current = next;
|
|
641
|
+
}
|
|
642
|
+
renderer.removeChild(nextParent, start);
|
|
643
|
+
renderer.removeChild(nextParent, end);
|
|
644
|
+
parent = null;
|
|
645
|
+
initialized = false;
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
return fragment;
|
|
649
|
+
}
|
|
650
|
+
__name(createFragment, "createFragment");
|
|
651
|
+
function isVobsFragment(value) {
|
|
652
|
+
return Boolean(value) && typeof value === "object" && value.kind === "vobs-fragment";
|
|
653
|
+
}
|
|
654
|
+
__name(isVobsFragment, "isVobsFragment");
|
|
655
|
+
function moveRange(parent, start, end, anchor) {
|
|
656
|
+
const renderer = getRenderer();
|
|
657
|
+
const nodes = [start];
|
|
658
|
+
let current = renderer.nextSibling(start);
|
|
659
|
+
while (current) {
|
|
660
|
+
nodes.push(current);
|
|
661
|
+
if (current === end) break;
|
|
662
|
+
current = renderer.nextSibling(current);
|
|
663
|
+
}
|
|
664
|
+
if (nodes[nodes.length - 1] !== end) {
|
|
665
|
+
throw new Error("Vobs Fragment: \u627E\u4E0D\u5230\u7ED3\u675F\u951A\u70B9");
|
|
666
|
+
}
|
|
667
|
+
for (const node of nodes) renderer.insertBefore(parent, node, anchor);
|
|
668
|
+
}
|
|
669
|
+
__name(moveRange, "moveRange");
|
|
670
|
+
|
|
671
|
+
// packages/runtime/src/dynamic.ts
|
|
672
|
+
function insertDynamic(parent, anchor, factory) {
|
|
673
|
+
const marker = createComment("vobs:dynamic");
|
|
674
|
+
insertBefore(parent, marker, anchor);
|
|
675
|
+
let current = null;
|
|
676
|
+
effect(() => {
|
|
677
|
+
const next = createBlock(factory);
|
|
678
|
+
if (next === current) return;
|
|
679
|
+
if (current) removeChild(parent, current);
|
|
680
|
+
current = next;
|
|
681
|
+
if (current) insertBefore(parent, current, marker);
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
__name(insertDynamic, "insertDynamic");
|
|
685
|
+
|
|
686
|
+
// packages/table/src/utils.ts
|
|
687
|
+
function readProp(props, name, fallback) {
|
|
688
|
+
const value = Reflect.get(props, name);
|
|
689
|
+
return value === void 0 ? fallback : value;
|
|
690
|
+
}
|
|
691
|
+
__name(readProp, "readProp");
|
|
692
|
+
function hasProp(props, name) {
|
|
693
|
+
return name in props;
|
|
694
|
+
}
|
|
695
|
+
__name(hasProp, "hasProp");
|
|
696
|
+
function bindClassList(root, props, classes) {
|
|
697
|
+
effect(() => {
|
|
698
|
+
const userClasses = [readString(props, "class"), readString(props, "className")];
|
|
699
|
+
setAttribute(root, "class", [...classes(), ...userClasses].filter(Boolean).join(" "));
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
__name(bindClassList, "bindClassList");
|
|
703
|
+
function bindCommonAttributes(root, props, skip) {
|
|
704
|
+
const ignored = /* @__PURE__ */ new Set([...skip, "class", "className", "style", "children"]);
|
|
705
|
+
effect(() => {
|
|
706
|
+
for (const name of Object.keys(props)) {
|
|
707
|
+
if (ignored.has(name) || name.startsWith("on")) continue;
|
|
708
|
+
if (name !== "id" && name !== "title" && name !== "role" && name !== "tabIndex" && !name.startsWith("aria-") && !name.startsWith("data-")) continue;
|
|
709
|
+
const value = Reflect.get(props, name);
|
|
710
|
+
if (value === void 0 || value === null || value === false) removeAttribute(root, normalizeAttributeName(name));
|
|
711
|
+
else setAttribute(root, normalizeAttributeName(name), String(value));
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
__name(bindCommonAttributes, "bindCommonAttributes");
|
|
716
|
+
function bindStyle(root, props, internal = () => "") {
|
|
717
|
+
effect(() => {
|
|
718
|
+
const value = [internal(), readString(props, "style")].filter(Boolean).join("; ");
|
|
719
|
+
if (value) setAttribute(root, "style", value);
|
|
720
|
+
else removeAttribute(root, "style");
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
__name(bindStyle, "bindStyle");
|
|
724
|
+
function resolveSlot(value) {
|
|
725
|
+
const resolved = typeof value === "function" ? value() : value;
|
|
726
|
+
if (resolved === void 0 || resolved === null) return null;
|
|
727
|
+
if (typeof resolved === "string" || typeof resolved === "number") return createText(String(resolved));
|
|
728
|
+
if (Array.isArray(resolved)) {
|
|
729
|
+
return createFragment((parent, anchor) => {
|
|
730
|
+
for (const child of resolved) {
|
|
731
|
+
const node = resolveSlot(child);
|
|
732
|
+
if (node) insertBefore(parent, node, anchor);
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
return resolved;
|
|
737
|
+
}
|
|
738
|
+
__name(resolveSlot, "resolveSlot");
|
|
739
|
+
function setOptionalAttribute(node, name, value) {
|
|
740
|
+
if (value === void 0 || value === null || value === false || value === "") removeAttribute(node, name);
|
|
741
|
+
else setAttribute(node, name, String(value));
|
|
742
|
+
}
|
|
743
|
+
__name(setOptionalAttribute, "setOptionalAttribute");
|
|
744
|
+
function normalizePixels(value) {
|
|
745
|
+
if (value === void 0) return void 0;
|
|
746
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
747
|
+
}
|
|
748
|
+
__name(normalizePixels, "normalizePixels");
|
|
749
|
+
function createDefaultColumnSettings(columns, visibleColumnIds) {
|
|
750
|
+
const columnOrder = columns.map((column) => column.id);
|
|
751
|
+
const requested = new Set(visibleColumnIds ?? columns.filter((column) => column.visible !== false).map((column) => column.id));
|
|
752
|
+
const visible = columnOrder.filter((id) => requested.has(id) && columns.some((column) => column.id === id && column.visible !== false));
|
|
753
|
+
if (visible.length === 0) {
|
|
754
|
+
const fallback = columns.find((column) => column.visible !== false);
|
|
755
|
+
if (fallback) visible.push(fallback.id);
|
|
756
|
+
}
|
|
757
|
+
return { visibleColumnIds: visible, columnOrder, columnWidths: {} };
|
|
758
|
+
}
|
|
759
|
+
__name(createDefaultColumnSettings, "createDefaultColumnSettings");
|
|
760
|
+
function normalizeColumnSettings(columns, settings, visibleColumnIds) {
|
|
761
|
+
const fallback = createDefaultColumnSettings(columns, visibleColumnIds);
|
|
762
|
+
const knownIds = new Set(fallback.columnOrder);
|
|
763
|
+
const configuredOrder = Array.isArray(settings?.columnOrder) ? settings.columnOrder : void 0;
|
|
764
|
+
const order = uniqueKnownIds(configuredOrder, knownIds);
|
|
765
|
+
for (const id of fallback.columnOrder) {
|
|
766
|
+
if (!order.includes(id)) order.push(id);
|
|
767
|
+
}
|
|
768
|
+
const configuredVisible = Array.isArray(settings?.visibleColumnIds) ? settings.visibleColumnIds : void 0;
|
|
769
|
+
const requestedVisible = new Set(configuredVisible ?? fallback.visibleColumnIds);
|
|
770
|
+
const visible = order.filter((id) => requestedVisible.has(id) && columns.some((column) => column.id === id && column.visible !== false));
|
|
771
|
+
if (visible.length === 0) {
|
|
772
|
+
const fallbackVisible = order.find((id) => columns.some((column) => column.id === id && column.visible !== false));
|
|
773
|
+
if (fallbackVisible) visible.push(fallbackVisible);
|
|
774
|
+
}
|
|
775
|
+
const columnWidths = {};
|
|
776
|
+
const configuredWidths = settings?.columnWidths && typeof settings.columnWidths === "object" && !Array.isArray(settings.columnWidths) ? settings.columnWidths : {};
|
|
777
|
+
for (const [id, width] of Object.entries(configuredWidths)) {
|
|
778
|
+
if (knownIds.has(id) && isColumnWidthValue(width)) columnWidths[id] = width;
|
|
779
|
+
}
|
|
780
|
+
return { visibleColumnIds: visible, columnOrder: order, columnWidths };
|
|
781
|
+
}
|
|
782
|
+
__name(normalizeColumnSettings, "normalizeColumnSettings");
|
|
783
|
+
function orderColumns(columns, columnOrder) {
|
|
784
|
+
if (!columnOrder || columnOrder.length === 0) return columns;
|
|
785
|
+
const byId = new Map(columns.map((column) => [column.id, column]));
|
|
786
|
+
const ordered = [];
|
|
787
|
+
const seen = /* @__PURE__ */ new Set();
|
|
788
|
+
for (const id of columnOrder) {
|
|
789
|
+
const column = byId.get(id);
|
|
790
|
+
if (column && !seen.has(id)) {
|
|
791
|
+
ordered.push(column);
|
|
792
|
+
seen.add(id);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
for (const column of columns) {
|
|
796
|
+
if (!seen.has(column.id)) ordered.push(column);
|
|
797
|
+
}
|
|
798
|
+
return ordered;
|
|
799
|
+
}
|
|
800
|
+
__name(orderColumns, "orderColumns");
|
|
801
|
+
function isColumnWidthValue(value) {
|
|
802
|
+
return typeof value === "number" ? Number.isFinite(value) && value > 0 : typeof value === "string" && value.trim().length > 0 && !/[;{}]/u.test(value);
|
|
803
|
+
}
|
|
804
|
+
__name(isColumnWidthValue, "isColumnWidthValue");
|
|
805
|
+
function uniqueKnownIds(values, knownIds) {
|
|
806
|
+
const result = [];
|
|
807
|
+
for (const id of values ?? []) {
|
|
808
|
+
if (knownIds.has(id) && !result.includes(id)) result.push(id);
|
|
809
|
+
}
|
|
810
|
+
return result;
|
|
811
|
+
}
|
|
812
|
+
__name(uniqueKnownIds, "uniqueKnownIds");
|
|
813
|
+
function readString(props, name) {
|
|
814
|
+
const value = Reflect.get(props, name);
|
|
815
|
+
return typeof value === "string" ? value : void 0;
|
|
816
|
+
}
|
|
817
|
+
__name(readString, "readString");
|
|
818
|
+
function normalizeAttributeName(name) {
|
|
819
|
+
return name === "tabIndex" ? "tabindex" : name;
|
|
820
|
+
}
|
|
821
|
+
__name(normalizeAttributeName, "normalizeAttributeName");
|
|
822
|
+
function removeAttribute(node, name) {
|
|
823
|
+
node.removeAttribute(name);
|
|
824
|
+
}
|
|
825
|
+
__name(removeAttribute, "removeAttribute");
|
|
826
|
+
|
|
827
|
+
// packages/ui/src/utils.ts
|
|
828
|
+
function readProp2(props, name, fallback) {
|
|
829
|
+
const value = Reflect.get(props, name);
|
|
830
|
+
return value === void 0 ? fallback : value;
|
|
831
|
+
}
|
|
832
|
+
__name(readProp2, "readProp");
|
|
833
|
+
function hasProp2(props, name) {
|
|
834
|
+
return name in props;
|
|
835
|
+
}
|
|
836
|
+
__name(hasProp2, "hasProp");
|
|
837
|
+
function mountSlot(parent, props, propName) {
|
|
838
|
+
insertDynamic(parent, null, () => resolveSlot2(Reflect.get(props, propName)));
|
|
839
|
+
}
|
|
840
|
+
__name(mountSlot, "mountSlot");
|
|
841
|
+
function resolveSlot2(value) {
|
|
842
|
+
const resolved = typeof value === "function" ? value() : value;
|
|
843
|
+
if (resolved === void 0 || resolved === null || resolved === false) return null;
|
|
844
|
+
if (typeof resolved === "string" || typeof resolved === "number") return createText(String(resolved));
|
|
845
|
+
if (Array.isArray(resolved)) {
|
|
846
|
+
const children = resolved;
|
|
847
|
+
return createFragment((parent, anchor) => {
|
|
848
|
+
for (const child of children) {
|
|
849
|
+
const node = resolveSlot2(child);
|
|
850
|
+
if (node) insertBefore(parent, node, anchor);
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
return resolved;
|
|
855
|
+
}
|
|
856
|
+
__name(resolveSlot2, "resolveSlot");
|
|
857
|
+
|
|
858
|
+
// packages/icon-core/src/index.ts
|
|
859
|
+
function createSvgIconNode(source, props = {}, options = {}) {
|
|
860
|
+
const root = createElement("span");
|
|
861
|
+
effect(() => {
|
|
862
|
+
updateSvgIconNode(root, typeof source === "function" ? source() : source, props, options);
|
|
863
|
+
});
|
|
864
|
+
return root;
|
|
865
|
+
}
|
|
866
|
+
__name(createSvgIconNode, "createSvgIconNode");
|
|
867
|
+
function updateSvgIconNode(root, definition, props, options) {
|
|
868
|
+
const size = readProp3(props, "size", void 0);
|
|
869
|
+
const width = readProp3(props, "width", size);
|
|
870
|
+
const height = readProp3(props, "height", size);
|
|
871
|
+
const normalizedWidth = normalizeSvgLength(width);
|
|
872
|
+
const normalizedHeight = normalizeSvgLength(height);
|
|
873
|
+
const userClass = [
|
|
874
|
+
readProp3(props, "class", void 0),
|
|
875
|
+
readProp3(props, "className", void 0)
|
|
876
|
+
].filter(hasText).join(" ");
|
|
877
|
+
const className = [options.class, options.className, userClass].filter(hasText).join(" ");
|
|
878
|
+
setAttribute(root, "class", className);
|
|
879
|
+
const internalStyle = size === void 0 ? "" : `width: ${normalizeCssLength(size)}; height: ${normalizeCssLength(size)}`;
|
|
880
|
+
const userStyle = readProp3(props, "style", void 0);
|
|
881
|
+
const style = [internalStyle, userStyle].filter(hasText).join("; ");
|
|
882
|
+
setOptionalAttribute2(root, "style", style || void 0);
|
|
883
|
+
const managedAttributes = /* @__PURE__ */ new Map();
|
|
884
|
+
for (const name of Object.keys(props)) {
|
|
885
|
+
if (name === "class" || name === "className" || name === "style" || name === "children") continue;
|
|
886
|
+
if (!name.startsWith("aria-") && !name.startsWith("data-") && !["id", "title", "role", "tabIndex"].includes(name)) continue;
|
|
887
|
+
const value = Reflect.get(props, name);
|
|
888
|
+
if (value === void 0 || value === null || value === false) continue;
|
|
889
|
+
managedAttributes.set(name === "tabIndex" ? "tabindex" : name, String(value));
|
|
890
|
+
}
|
|
891
|
+
for (const [name, value] of managedAttributes) setAttribute(root, name, value);
|
|
892
|
+
clearStaleAttributes(root, managedAttributes);
|
|
893
|
+
const title = readProp3(props, "title", void 0);
|
|
894
|
+
const ariaLabel = Reflect.get(props, "aria-label");
|
|
895
|
+
const decorative = readProp3(props, "decorative", title === void 0 && ariaLabel === void 0);
|
|
896
|
+
setOptionalAttribute2(root, "aria-hidden", decorative ? "true" : void 0);
|
|
897
|
+
setOptionalAttribute2(root, "aria-label", ariaLabel === void 0 ? title : void 0);
|
|
898
|
+
setOptionalAttribute2(root, "data-icon-name", options.dataIconName ?? definition?.name);
|
|
899
|
+
setOptionalAttribute2(root, "color", readProp3(props, "color", void 0));
|
|
900
|
+
if (!definition) {
|
|
901
|
+
setProperty(root, "innerHTML", "");
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
const svgAttributes = {
|
|
905
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
906
|
+
viewBox: definition.viewBox ?? "0 0 24 24",
|
|
907
|
+
...options.defaultSvgAttributes,
|
|
908
|
+
...definition.attributes,
|
|
909
|
+
...normalizedWidth === void 0 ? {} : { width: normalizedWidth },
|
|
910
|
+
...normalizedHeight === void 0 ? {} : { height: normalizedHeight },
|
|
911
|
+
...readProp3(props, "color", void 0) === void 0 ? {} : { color: readProp3(props, "color", void 0) },
|
|
912
|
+
...readProp3(props, "stroke", void 0) === void 0 ? {} : { stroke: readProp3(props, "stroke", void 0) },
|
|
913
|
+
...readProp3(props, "fill", void 0) === void 0 ? {} : { fill: readProp3(props, "fill", void 0) },
|
|
914
|
+
...readProp3(props, "strokeWidth", void 0) === void 0 ? {} : { "stroke-width": readProp3(props, "strokeWidth", void 0) }
|
|
915
|
+
};
|
|
916
|
+
const markup = Object.entries(svgAttributes).filter(([, value]) => value !== void 0).map(([name, value]) => `${name}="${escapeXml(String(value))}"`).join(" ");
|
|
917
|
+
const titleMarkup = title === void 0 ? "" : `<title>${escapeXml(title)}</title>`;
|
|
918
|
+
setProperty(root, "innerHTML", `<svg ${markup} aria-hidden="true">${titleMarkup}${definition.body}</svg>`);
|
|
919
|
+
}
|
|
920
|
+
__name(updateSvgIconNode, "updateSvgIconNode");
|
|
921
|
+
function readProp3(props, name, fallback) {
|
|
922
|
+
const value = Reflect.get(props, name);
|
|
923
|
+
return value === void 0 ? fallback : value;
|
|
924
|
+
}
|
|
925
|
+
__name(readProp3, "readProp");
|
|
926
|
+
function hasText(value) {
|
|
927
|
+
return value !== void 0 && value.trim() !== "";
|
|
928
|
+
}
|
|
929
|
+
__name(hasText, "hasText");
|
|
930
|
+
function normalizeSvgLength(value) {
|
|
931
|
+
if (value === void 0) return void 0;
|
|
932
|
+
return typeof value === "number" ? String(value) : value;
|
|
933
|
+
}
|
|
934
|
+
__name(normalizeSvgLength, "normalizeSvgLength");
|
|
935
|
+
function normalizeCssLength(value) {
|
|
936
|
+
return typeof value === "number" || /^\d+(?:\.\d+)?$/u.test(value) ? `${value}px` : value;
|
|
937
|
+
}
|
|
938
|
+
__name(normalizeCssLength, "normalizeCssLength");
|
|
939
|
+
function setOptionalAttribute2(node, name, value) {
|
|
940
|
+
if (value === void 0 || value === null || value === false || value === "") {
|
|
941
|
+
node.removeAttribute(name);
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
setAttribute(node, name, String(value));
|
|
945
|
+
}
|
|
946
|
+
__name(setOptionalAttribute2, "setOptionalAttribute");
|
|
947
|
+
function clearStaleAttributes(node, next) {
|
|
948
|
+
const previous = node.__vobsIconAttributes ?? /* @__PURE__ */ new Set();
|
|
949
|
+
for (const name of previous) {
|
|
950
|
+
if (!next.has(name)) node.removeAttribute(name);
|
|
951
|
+
}
|
|
952
|
+
node.__vobsIconAttributes = new Set(next.keys());
|
|
953
|
+
}
|
|
954
|
+
__name(clearStaleAttributes, "clearStaleAttributes");
|
|
955
|
+
function escapeXml(value) {
|
|
956
|
+
return value.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">").replace(/"/gu, """);
|
|
957
|
+
}
|
|
958
|
+
__name(escapeXml, "escapeXml");
|
|
959
|
+
|
|
960
|
+
// packages/ui/src/icon.ts
|
|
961
|
+
function Icon(props = {}) {
|
|
962
|
+
const root = createSvgIconNode(() => {
|
|
963
|
+
const definition = resolveIcon(
|
|
964
|
+
readProp2(props, "icon", void 0) ?? readProp2(props, "name", void 0)
|
|
965
|
+
);
|
|
966
|
+
if (!definition) {
|
|
967
|
+
if (hasProp2(props, "children")) return void 0;
|
|
968
|
+
throw new Error("Vobs UI: Icon requires a registered `name` or an `icon` definition");
|
|
969
|
+
}
|
|
970
|
+
return iconDefinitionToSvg(definition);
|
|
971
|
+
}, props, {
|
|
972
|
+
class: "vui-icon icon",
|
|
973
|
+
defaultSvgAttributes: {
|
|
974
|
+
fill: "none",
|
|
975
|
+
stroke: "currentColor",
|
|
976
|
+
"stroke-width": 2,
|
|
977
|
+
"stroke-linecap": "butt",
|
|
978
|
+
"stroke-linejoin": "miter"
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
if (hasProp2(props, "children")) mountSlot(root, props, "children");
|
|
982
|
+
return root;
|
|
983
|
+
}
|
|
984
|
+
__name(Icon, "Icon");
|
|
985
|
+
function iconDefinitionToSvg(definition) {
|
|
986
|
+
return {
|
|
987
|
+
name: definition.name,
|
|
988
|
+
body: definition.path,
|
|
989
|
+
viewBox: definition.viewBox
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
__name(iconDefinitionToSvg, "iconDefinitionToSvg");
|
|
993
|
+
var VUI_ICON_PATHS = {
|
|
994
|
+
search: '<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',
|
|
995
|
+
check: '<polyline points="4 12 10 18 20 6"/>',
|
|
996
|
+
x: '<line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/>',
|
|
997
|
+
plus: '<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',
|
|
998
|
+
minus: '<line x1="5" y1="12" x2="19" y2="12"/>',
|
|
999
|
+
"chevron-right": '<polyline points="9 6 15 12 9 18"/>',
|
|
1000
|
+
"chevron-down": '<polyline points="6 9 12 15 18 9"/>',
|
|
1001
|
+
"chevron-up": '<polyline points="6 15 12 9 18 15"/>',
|
|
1002
|
+
"chevron-left": '<polyline points="15 6 9 12 15 18"/>',
|
|
1003
|
+
"arrow-left": '<line x1="20" y1="12" x2="4" y2="12"/><polyline points="10 6 4 12 10 18"/>',
|
|
1004
|
+
"arrow-right": '<line x1="4" y1="12" x2="20" y2="12"/><polyline points="14 6 20 12 14 18"/>',
|
|
1005
|
+
"arrow-up": '<line x1="12" y1="20" x2="12" y2="4"/><polyline points="6 10 12 4 18 10"/>',
|
|
1006
|
+
"arrow-down": '<line x1="12" y1="4" x2="12" y2="20"/><polyline points="6 14 12 20 18 14"/>',
|
|
1007
|
+
atom: '<circle cx="12" cy="12" r="2"/><ellipse cx="12" cy="12" rx="10" ry="4"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(60 12 12)"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(120 12 12)"/>',
|
|
1008
|
+
globe: '<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"/>',
|
|
1009
|
+
"arrow-expand": '<polyline points="14 4 20 4 20 10"/><line x1="14" y1="10" x2="20" y2="4"/><polyline points="10 20 4 20 4 14"/><line x1="10" y1="14" x2="4" y2="20"/>',
|
|
1010
|
+
"arrow-minimize": '<polyline points="20 4 14 10 20 10"/><line x1="14" y1="10" x2="14" y2="4"/><polyline points="4 20 10 14 4 14"/><line x1="10" y1="14" x2="10" y2="20"/>',
|
|
1011
|
+
"check-circle": '<circle cx="12" cy="12" r="9"/><polyline points="8 12 11 15 16 9"/>',
|
|
1012
|
+
"alert-circle": '<circle cx="12" cy="12" r="9"/><line x1="12" y1="8" x2="12" y2="13"/><line x1="12" y1="16" x2="12" y2="16.01"/>',
|
|
1013
|
+
"alert-triangle": '<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',
|
|
1014
|
+
info: '<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',
|
|
1015
|
+
home: '<polygon points="3 11 12 3 21 11 21 21 14 21 14 14 10 14 10 21 3 21 3 11"/>',
|
|
1016
|
+
user: '<path d="M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1"/><circle cx="12" cy="8" r="4"/>',
|
|
1017
|
+
settings: '<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>',
|
|
1018
|
+
menu: '<line x1="4" y1="6" x2="20" y2="6"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/>',
|
|
1019
|
+
"more-h": '<circle cx="5" cy="12" r="1.5" fill="currentColor"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/><circle cx="19" cy="12" r="1.5" fill="currentColor"/>',
|
|
1020
|
+
calendar: '<rect x="3" y="5" width="18" height="16"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="8" y1="3" x2="8" y2="7"/><line x1="16" y1="3" x2="16" y2="7"/>',
|
|
1021
|
+
filter: '<polygon points="3 4 21 4 14 12 14 20 10 18 10 12 3 4"/>',
|
|
1022
|
+
sort: '<path d="M8 20V4"/><polyline points="4 8 8 4 12 8"/><path d="M16 4v16"/><polyline points="12 16 16 20 20 16"/>',
|
|
1023
|
+
edit: '<path d="M4 20h4l10-10-4-4L4 16v4z"/><path d="M14 6l4 4"/>',
|
|
1024
|
+
trash: '<polyline points="4 6 20 6"/><path d="M6 6v14h12V6"/><path d="M9 6V4h6v2"/><line x1="10" y1="10" x2="10" y2="17"/><line x1="14" y1="10" x2="14" y2="17"/>',
|
|
1025
|
+
download: '<path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><line x1="3" y1="21" x2="21" y2="21"/>',
|
|
1026
|
+
upload: '<path d="M12 21V6"/><polyline points="7 11 12 6 17 11"/><line x1="3" y1="21" x2="21" y2="21"/>',
|
|
1027
|
+
pause: '<line x1="9" y1="5" x2="9" y2="19"/><line x1="15" y1="5" x2="15" y2="19"/>',
|
|
1028
|
+
play: '<polygon points="8 5 19 12 8 19 8 5"/>',
|
|
1029
|
+
refresh: '<polyline points="21 4 21 10 15 10"/><polyline points="3 20 3 14 9 14"/><path d="M20.5 9A9 9 0 0 0 5 5.5L3 7M3.5 15A9 9 0 0 0 19 18.5L21 17"/>',
|
|
1030
|
+
bell: '<path d="M6 8a6 6 0 0 1 12 0c0 7 3 8 3 8H3s3-1 3-8z"/><path d="M10 21a2 2 0 0 0 4 0"/>',
|
|
1031
|
+
folder: '<path d="M3 6h6l2 3h10v10H3z"/>',
|
|
1032
|
+
code: '<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>',
|
|
1033
|
+
sparkles: '<path d="M12 3l1.8 4.2L18 9l-4.2 1.8L12 15l-1.8-4.2L6 9l4.2-1.8L12 3z"/><path d="M19 14l1 2.2 2.2 1-2.2 1L19 20.4l-1-2.2-2.2-1 2.2-1L19 14z"/>',
|
|
1034
|
+
zap: '<polygon points="13 2 4 14 12 14 11 22 20 10 12 10 13 2"/>',
|
|
1035
|
+
sun: '<circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="5"/><line x1="12" y1="19" x2="12" y2="22"/><line x1="2" y1="12" x2="5" y2="12"/><line x1="19" y1="12" x2="22" y2="12"/><line x1="4.6" y1="4.6" x2="6.7" y2="6.7"/><line x1="17.3" y1="17.3" x2="19.4" y2="19.4"/><line x1="4.6" y1="19.4" x2="6.7" y2="17.3"/><line x1="17.3" y1="6.7" x2="19.4" y2="4.6"/>',
|
|
1036
|
+
moon: '<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>',
|
|
1037
|
+
terminal: '<polyline points="4 7 9 12 4 17"/><line x1="12" y1="17" x2="20" y2="17"/>'
|
|
1038
|
+
};
|
|
1039
|
+
var iconRegistry = new Map(
|
|
1040
|
+
Object.entries(VUI_ICON_PATHS).map(([name, path]) => [name, { name, path }])
|
|
1041
|
+
);
|
|
1042
|
+
function resolveIcon(icon) {
|
|
1043
|
+
return typeof icon === "string" ? iconRegistry.get(icon) : icon;
|
|
1044
|
+
}
|
|
1045
|
+
__name(resolveIcon, "resolveIcon");
|
|
1046
|
+
|
|
1047
|
+
// packages/table/src/icons.ts
|
|
1048
|
+
function defaultIcons() {
|
|
1049
|
+
return {
|
|
1050
|
+
ascending: /* @__PURE__ */ __name(() => createComponent(Icon, { name: "chevron-up" }), "ascending"),
|
|
1051
|
+
descending: /* @__PURE__ */ __name(() => createComponent(Icon, { name: "chevron-down" }), "descending"),
|
|
1052
|
+
unsorted: /* @__PURE__ */ __name(() => createComponent(Icon, { name: "sort" }), "unsorted"),
|
|
1053
|
+
previous: /* @__PURE__ */ __name(() => createComponent(Icon, { name: "chevron-left" }), "previous"),
|
|
1054
|
+
next: /* @__PURE__ */ __name(() => createComponent(Icon, { name: "chevron-right" }), "next")
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
__name(defaultIcons, "defaultIcons");
|
|
1058
|
+
|
|
1059
|
+
// packages/table/src/data-table.ts
|
|
1060
|
+
var internalQueries = /* @__PURE__ */ new WeakMap();
|
|
1061
|
+
var DEFAULT_PAGE_SIZE = 25;
|
|
1062
|
+
var DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100];
|
|
1063
|
+
var DEFAULT_ROW_HEIGHT = 40;
|
|
1064
|
+
var DEFAULT_VIRTUAL_HEIGHT = 400;
|
|
1065
|
+
var textCollator = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
|
|
1066
|
+
function KitDataTable(props = {}) {
|
|
1067
|
+
const root = createElement("section");
|
|
1068
|
+
const toolbar = createElement("div");
|
|
1069
|
+
const viewport = createElement("div");
|
|
1070
|
+
const table = createElement("table");
|
|
1071
|
+
const head = createElement("thead");
|
|
1072
|
+
const body = createElement("tbody");
|
|
1073
|
+
const footer = createElement("footer");
|
|
1074
|
+
const scrollTop = state(0);
|
|
1075
|
+
internalQueries.set(props, state({
|
|
1076
|
+
page: 1,
|
|
1077
|
+
pageSize: DEFAULT_PAGE_SIZE,
|
|
1078
|
+
sort: null,
|
|
1079
|
+
filters: {}
|
|
1080
|
+
}));
|
|
1081
|
+
bindClassList(root, props, () => [
|
|
1082
|
+
"vobs-data-table",
|
|
1083
|
+
readProp(props, "stickyHeader", true) ? "vobs-data-table--sticky-header" : void 0
|
|
1084
|
+
]);
|
|
1085
|
+
bindCommonAttributes(root, props, [
|
|
1086
|
+
"columns",
|
|
1087
|
+
"rows",
|
|
1088
|
+
"resource",
|
|
1089
|
+
"rowKey",
|
|
1090
|
+
"page",
|
|
1091
|
+
"pageSize",
|
|
1092
|
+
"total",
|
|
1093
|
+
"sort",
|
|
1094
|
+
"filters",
|
|
1095
|
+
"columnSettings",
|
|
1096
|
+
"sortingMode",
|
|
1097
|
+
"visibleColumnIds",
|
|
1098
|
+
"virtual",
|
|
1099
|
+
"stickyHeader",
|
|
1100
|
+
"virtualHeight",
|
|
1101
|
+
"rowHeight",
|
|
1102
|
+
"overscan",
|
|
1103
|
+
"loading",
|
|
1104
|
+
"empty",
|
|
1105
|
+
"error",
|
|
1106
|
+
"toolbar",
|
|
1107
|
+
"footer",
|
|
1108
|
+
"pagination",
|
|
1109
|
+
"paginationMode",
|
|
1110
|
+
"icons",
|
|
1111
|
+
"previousLabel",
|
|
1112
|
+
"nextLabel",
|
|
1113
|
+
"jumpToLabel",
|
|
1114
|
+
"jumpToPlaceholder",
|
|
1115
|
+
"jumpToSubmitLabel",
|
|
1116
|
+
"pageSizeOptions",
|
|
1117
|
+
"pageSizeLabel",
|
|
1118
|
+
"pageLabel",
|
|
1119
|
+
"onQueryChange",
|
|
1120
|
+
"onRowClick",
|
|
1121
|
+
"onVisibleColumnIdsChange"
|
|
1122
|
+
]);
|
|
1123
|
+
bindStyle(root, props);
|
|
1124
|
+
setAttribute(toolbar, "class", "vobs-data-table__toolbar");
|
|
1125
|
+
setAttribute(viewport, "class", "vobs-data-table__viewport");
|
|
1126
|
+
setAttribute(viewport, "data-vobs-scrollable", "true");
|
|
1127
|
+
setAttribute(table, "class", "vobs-data-table__table");
|
|
1128
|
+
setAttribute(footer, "class", "vobs-data-table__footer");
|
|
1129
|
+
if (hasProp(props, "toolbar")) insertDynamic(toolbar, null, () => resolveSlot(readProp(props, "toolbar", void 0)));
|
|
1130
|
+
effect(() => {
|
|
1131
|
+
setProperty(toolbar, "hidden", !hasProp(props, "toolbar"));
|
|
1132
|
+
});
|
|
1133
|
+
effect(() => {
|
|
1134
|
+
const virtual = readProp(props, "virtual", false);
|
|
1135
|
+
setProperty(viewport, "tabIndex", virtual ? 0 : -1);
|
|
1136
|
+
setAttribute(viewport, "style", virtual ? `max-height: ${normalizeHeight(readProp(props, "virtualHeight", DEFAULT_VIRTUAL_HEIGHT))}; overflow: auto` : "");
|
|
1137
|
+
});
|
|
1138
|
+
addEventListener(viewport, "scroll", () => {
|
|
1139
|
+
scrollTop.value = viewport.scrollTop;
|
|
1140
|
+
});
|
|
1141
|
+
insertDynamic(head, null, () => createHeader(props));
|
|
1142
|
+
insertDynamic(body, null, () => createBody(props, scrollTop.value));
|
|
1143
|
+
insertBefore(table, head, null);
|
|
1144
|
+
insertBefore(table, body, null);
|
|
1145
|
+
insertBefore(viewport, table, null);
|
|
1146
|
+
insertDynamic(footer, null, () => createFooter(props));
|
|
1147
|
+
effect(() => {
|
|
1148
|
+
setProperty(footer, "hidden", !shouldShowFooter(props));
|
|
1149
|
+
});
|
|
1150
|
+
insertBefore(root, toolbar, null);
|
|
1151
|
+
insertBefore(root, viewport, null);
|
|
1152
|
+
insertBefore(root, footer, null);
|
|
1153
|
+
return root;
|
|
1154
|
+
}
|
|
1155
|
+
__name(KitDataTable, "KitDataTable");
|
|
1156
|
+
function createHeader(props) {
|
|
1157
|
+
const columns = visibleColumns(props);
|
|
1158
|
+
return createFragment((parent, anchor) => {
|
|
1159
|
+
const row = createElement("tr");
|
|
1160
|
+
for (const column of columns) {
|
|
1161
|
+
const cell = createElement("th");
|
|
1162
|
+
setAttribute(cell, "scope", "col");
|
|
1163
|
+
setAttribute(cell, "data-column-id", column.id);
|
|
1164
|
+
applyColumnStyle(cell, column, readProp(props, "columnSettings", void 0));
|
|
1165
|
+
if (column.sortable) insertBefore(cell, createSortButton(props, column, cell), null);
|
|
1166
|
+
else insertBefore(cell, createText(column.label), null);
|
|
1167
|
+
insertBefore(row, cell, null);
|
|
1168
|
+
}
|
|
1169
|
+
insertBefore(parent, row, anchor);
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
__name(createHeader, "createHeader");
|
|
1173
|
+
function createSortButton(props, column, cell) {
|
|
1174
|
+
const button = createElement("button");
|
|
1175
|
+
const label = createElement("span");
|
|
1176
|
+
const icon = createElement("span");
|
|
1177
|
+
setAttribute(button, "type", "button");
|
|
1178
|
+
setAttribute(button, "class", "vobs-data-table__sort");
|
|
1179
|
+
setAttribute(button, "aria-label", `Sort by ${column.label}`);
|
|
1180
|
+
setAttribute(label, "class", "vobs-data-table__sort-label");
|
|
1181
|
+
setAttribute(icon, "class", "vobs-data-table__sort-icon");
|
|
1182
|
+
insertBefore(label, createText(column.label), null);
|
|
1183
|
+
insertDynamic(icon, null, () => resolveSlot(sortIcon(props, currentSort(props), column.id)));
|
|
1184
|
+
effect(() => {
|
|
1185
|
+
const sort = currentSort(props);
|
|
1186
|
+
const direction = sort?.columnId === column.id ? sort.direction : void 0;
|
|
1187
|
+
setOptionalAttribute(cell, "aria-sort", direction ? direction === "asc" ? "ascending" : "descending" : void 0);
|
|
1188
|
+
setOptionalAttribute(cell, "data-sort-direction", direction);
|
|
1189
|
+
});
|
|
1190
|
+
addEventListener(button, "click", () => {
|
|
1191
|
+
const current = currentSort(props);
|
|
1192
|
+
const next = current?.columnId === column.id ? current.direction === "asc" ? createSort(column, "desc") : null : createSort(column, "asc");
|
|
1193
|
+
emitQuery(props, { ...currentQuery(props), sort: next, page: 1 });
|
|
1194
|
+
});
|
|
1195
|
+
insertBefore(button, label, null);
|
|
1196
|
+
insertBefore(button, icon, null);
|
|
1197
|
+
return button;
|
|
1198
|
+
}
|
|
1199
|
+
__name(createSortButton, "createSortButton");
|
|
1200
|
+
function createBody(props, scrollTop) {
|
|
1201
|
+
const resource = readProp(props, "resource", void 0);
|
|
1202
|
+
if (resource?.error.value) return createStateRow(props, "error", resource.error.value);
|
|
1203
|
+
if (resource?.loading.value && resource.data.value === null) return createStateRow(props, "loading");
|
|
1204
|
+
const page = resolvePage(props);
|
|
1205
|
+
if (page.rows.length === 0) return createStateRow(props, "empty");
|
|
1206
|
+
const columns = visibleColumns(props);
|
|
1207
|
+
const window = resolveWindow(props, page.rows.length, scrollTop);
|
|
1208
|
+
const fragment = createFragment((parent, anchor) => {
|
|
1209
|
+
if (window.before > 0) insertBefore(parent, createSpacerRow(columns.length, window.before), anchor);
|
|
1210
|
+
for (let index = window.start; index < window.end; index++) {
|
|
1211
|
+
insertBefore(parent, createRow(props, page.rows[index], index, columns), anchor);
|
|
1212
|
+
}
|
|
1213
|
+
if (window.after > 0) insertBefore(parent, createSpacerRow(columns.length, window.after), anchor);
|
|
1214
|
+
});
|
|
1215
|
+
return fragment;
|
|
1216
|
+
}
|
|
1217
|
+
__name(createBody, "createBody");
|
|
1218
|
+
function createStateRow(props, kind, error) {
|
|
1219
|
+
const row = createElement("tr");
|
|
1220
|
+
const cell = createElement("td");
|
|
1221
|
+
setAttribute(cell, "class", `vobs-data-table__state vobs-data-table__state--${kind}`);
|
|
1222
|
+
setAttribute(cell, "colspan", String(Math.max(1, visibleColumns(props).length)));
|
|
1223
|
+
let content;
|
|
1224
|
+
if (kind === "error") {
|
|
1225
|
+
const fallback = readProp(props, "error", void 0);
|
|
1226
|
+
const resource = readProp(props, "resource", void 0);
|
|
1227
|
+
content = fallback ? resolveSlot(fallback(error, () => resource?.refetch() ?? Promise.resolve())) : createText(error?.message ?? "Unable to load data");
|
|
1228
|
+
} else {
|
|
1229
|
+
content = resolveSlot(readProp(props, kind, void 0)) ?? createText(kind === "loading" ? "Loading..." : "No data");
|
|
1230
|
+
}
|
|
1231
|
+
if (content) insertBefore(cell, content, null);
|
|
1232
|
+
insertBefore(row, cell, null);
|
|
1233
|
+
return row;
|
|
1234
|
+
}
|
|
1235
|
+
__name(createStateRow, "createStateRow");
|
|
1236
|
+
function createRow(props, row, index, columns) {
|
|
1237
|
+
const tableRow = createElement("tr");
|
|
1238
|
+
const rowKey = readProp(props, "rowKey", void 0);
|
|
1239
|
+
if (rowKey) setOptionalAttribute(tableRow, "data-row-key", rowKey(row, index));
|
|
1240
|
+
const onRowClick = readProp(props, "onRowClick", void 0);
|
|
1241
|
+
if (onRowClick) {
|
|
1242
|
+
setProperty(tableRow, "tabIndex", 0);
|
|
1243
|
+
setAttribute(tableRow, "data-clickable", "true");
|
|
1244
|
+
addEventListener(tableRow, "click", () => onRowClick(row, index));
|
|
1245
|
+
}
|
|
1246
|
+
for (const column of columns) {
|
|
1247
|
+
const cell = createElement("td");
|
|
1248
|
+
setAttribute(cell, "data-column-id", column.id);
|
|
1249
|
+
applyColumnStyle(cell, column, readProp(props, "columnSettings", void 0));
|
|
1250
|
+
insertDynamic(cell, null, () => resolveSlot(column.render ? column.render(row, index) : column.key === void 0 ? void 0 : readRowValue(row, column.key)));
|
|
1251
|
+
insertBefore(tableRow, cell, null);
|
|
1252
|
+
}
|
|
1253
|
+
return tableRow;
|
|
1254
|
+
}
|
|
1255
|
+
__name(createRow, "createRow");
|
|
1256
|
+
function createSpacerRow(columnCount, height) {
|
|
1257
|
+
const row = createElement("tr");
|
|
1258
|
+
const cell = createElement("td");
|
|
1259
|
+
setAttribute(cell, "class", "vobs-data-table__spacer");
|
|
1260
|
+
setAttribute(cell, "colspan", String(Math.max(1, columnCount)));
|
|
1261
|
+
setAttribute(cell, "style", `height: ${height}px`);
|
|
1262
|
+
insertBefore(row, cell, null);
|
|
1263
|
+
return row;
|
|
1264
|
+
}
|
|
1265
|
+
__name(createSpacerRow, "createSpacerRow");
|
|
1266
|
+
function createFooter(props) {
|
|
1267
|
+
const custom = readProp(props, "footer", void 0);
|
|
1268
|
+
if (custom !== void 0) return resolveSlot(custom) ?? createText("");
|
|
1269
|
+
const pagination = resolvePaginationState(props);
|
|
1270
|
+
const root = createElement("div");
|
|
1271
|
+
const summary = createElement("span");
|
|
1272
|
+
setAttribute(root, "class", "vobs-data-table__footer-content");
|
|
1273
|
+
setAttribute(summary, "class", "vobs-data-table__summary");
|
|
1274
|
+
insertBefore(summary, createText(pageLabel(
|
|
1275
|
+
props,
|
|
1276
|
+
pagination.page,
|
|
1277
|
+
pagination.pageCount,
|
|
1278
|
+
pagination.total,
|
|
1279
|
+
pagination.visibleCount,
|
|
1280
|
+
pagination.pageSize
|
|
1281
|
+
)), null);
|
|
1282
|
+
const actions = hasProp(props, "pagination") ? createCustomPagination(props, pagination) : createPagination(props, pagination);
|
|
1283
|
+
insertBefore(root, summary, null);
|
|
1284
|
+
if (actions) insertBefore(root, actions, null);
|
|
1285
|
+
return root;
|
|
1286
|
+
}
|
|
1287
|
+
__name(createFooter, "createFooter");
|
|
1288
|
+
function createCustomPagination(props, pagination) {
|
|
1289
|
+
const custom = readProp(props, "pagination", void 0);
|
|
1290
|
+
if (custom === void 0) return null;
|
|
1291
|
+
const value = typeof custom === "function" ? custom({
|
|
1292
|
+
page: pagination.page,
|
|
1293
|
+
pageCount: pagination.pageCount,
|
|
1294
|
+
pageSize: pagination.pageSize,
|
|
1295
|
+
pageSizeOptions: pageSizeOptions(props, pagination.pageSize),
|
|
1296
|
+
total: pagination.total,
|
|
1297
|
+
visibleCount: pagination.visibleCount,
|
|
1298
|
+
goToPage: /* @__PURE__ */ __name((page) => goToPage(props, page, pagination.pageCount), "goToPage"),
|
|
1299
|
+
setPageSize: /* @__PURE__ */ __name((pageSize) => setPageSize(props, pageSize), "setPageSize")
|
|
1300
|
+
}) : custom;
|
|
1301
|
+
return resolveSlot(value);
|
|
1302
|
+
}
|
|
1303
|
+
__name(createCustomPagination, "createCustomPagination");
|
|
1304
|
+
function createPagination(props, pagination) {
|
|
1305
|
+
const root = createElement("div");
|
|
1306
|
+
const mode = readProp(props, "paginationMode", "simple");
|
|
1307
|
+
setAttribute(root, "class", "vobs-data-table__pagination");
|
|
1308
|
+
setAttribute(root, "data-mode", mode);
|
|
1309
|
+
insertBefore(root, createPageButton(props, "previous", pagination), null);
|
|
1310
|
+
if (mode !== "simple") {
|
|
1311
|
+
const pages = createElement("div");
|
|
1312
|
+
setAttribute(pages, "class", "vobs-data-table__pagination-pages");
|
|
1313
|
+
for (const item of buildPaginationItems(pagination.page, pagination.pageCount)) {
|
|
1314
|
+
insertBefore(pages, typeof item === "number" ? createPageNumberButton(props, item, pagination.page) : createPageEllipsis(item), null);
|
|
1315
|
+
}
|
|
1316
|
+
insertBefore(root, pages, null);
|
|
1317
|
+
}
|
|
1318
|
+
insertBefore(root, createPageButton(props, "next", pagination), null);
|
|
1319
|
+
if (mode === "all") insertBefore(root, createJumpControl(props, pagination), null);
|
|
1320
|
+
insertBefore(root, createPageSizeControl(props, pagination), null);
|
|
1321
|
+
return root;
|
|
1322
|
+
}
|
|
1323
|
+
__name(createPagination, "createPagination");
|
|
1324
|
+
function createPageButton(props, direction, pagination) {
|
|
1325
|
+
const button = createElement("button");
|
|
1326
|
+
const label = direction === "previous" ? readProp(props, "previousLabel", "Previous") : readProp(props, "nextLabel", "Next");
|
|
1327
|
+
const disabled = direction === "previous" ? pagination.page <= 1 : pagination.page >= pagination.pageCount;
|
|
1328
|
+
setAttribute(button, "type", "button");
|
|
1329
|
+
setAttribute(button, "class", "vobs-data-table__page-button");
|
|
1330
|
+
setAttribute(button, "aria-label", label);
|
|
1331
|
+
setProperty(button, "disabled", disabled);
|
|
1332
|
+
const icons = resolveIcons(props);
|
|
1333
|
+
const icon = direction === "previous" ? icons.previous : icons.next;
|
|
1334
|
+
const node = icon === void 0 ? void 0 : resolveSlot(icon);
|
|
1335
|
+
if (node) insertBefore(button, node, null);
|
|
1336
|
+
addEventListener(button, "click", () => {
|
|
1337
|
+
if (disabled) return;
|
|
1338
|
+
const query = currentQuery(props);
|
|
1339
|
+
goToPage(props, direction === "previous" ? query.page - 1 : query.page + 1, pagination.pageCount);
|
|
1340
|
+
});
|
|
1341
|
+
return button;
|
|
1342
|
+
}
|
|
1343
|
+
__name(createPageButton, "createPageButton");
|
|
1344
|
+
function createPageNumberButton(props, page, currentPage) {
|
|
1345
|
+
const button = createElement("button");
|
|
1346
|
+
const active = page === currentPage;
|
|
1347
|
+
setAttribute(button, "type", "button");
|
|
1348
|
+
setAttribute(button, "class", `vobs-data-table__page-button${active ? " is-active" : ""}`);
|
|
1349
|
+
setAttribute(button, "aria-label", `Page ${page}`);
|
|
1350
|
+
if (active) setAttribute(button, "aria-current", "page");
|
|
1351
|
+
insertBefore(button, createText(String(page)), null);
|
|
1352
|
+
addEventListener(button, "click", () => goToPage(props, page, resolvePaginationState(props).pageCount));
|
|
1353
|
+
return button;
|
|
1354
|
+
}
|
|
1355
|
+
__name(createPageNumberButton, "createPageNumberButton");
|
|
1356
|
+
function createPageEllipsis(side) {
|
|
1357
|
+
const ellipsis = createElement("span");
|
|
1358
|
+
setAttribute(ellipsis, "class", "vobs-data-table__page-ellipsis");
|
|
1359
|
+
setAttribute(ellipsis, "aria-hidden", "true");
|
|
1360
|
+
setAttribute(ellipsis, "data-side", side);
|
|
1361
|
+
insertBefore(ellipsis, createText("..."), null);
|
|
1362
|
+
return ellipsis;
|
|
1363
|
+
}
|
|
1364
|
+
__name(createPageEllipsis, "createPageEllipsis");
|
|
1365
|
+
function createJumpControl(props, pagination) {
|
|
1366
|
+
const root = createElement("form");
|
|
1367
|
+
const label = createElement("label");
|
|
1368
|
+
const input = createElement("input");
|
|
1369
|
+
const submit = createElement("button");
|
|
1370
|
+
const jumpLabel = readProp(props, "jumpToLabel", "Go to");
|
|
1371
|
+
setAttribute(root, "class", "vobs-data-table__pagination-jump");
|
|
1372
|
+
setAttribute(label, "class", "vobs-data-table__jump-label");
|
|
1373
|
+
setAttribute(input, "class", "vobs-data-table__jump-input");
|
|
1374
|
+
setAttribute(input, "type", "text");
|
|
1375
|
+
setAttribute(input, "inputmode", "numeric");
|
|
1376
|
+
setAttribute(input, "pattern", "[0-9]*");
|
|
1377
|
+
setAttribute(input, "autocomplete", "off");
|
|
1378
|
+
setAttribute(input, "aria-label", jumpLabel);
|
|
1379
|
+
setAttribute(input, "placeholder", readProp(props, "jumpToPlaceholder", "Page"));
|
|
1380
|
+
setProperty(input, "value", String(pagination.page));
|
|
1381
|
+
setAttribute(submit, "type", "submit");
|
|
1382
|
+
setAttribute(submit, "class", "vobs-data-table__page-button vobs-data-table__jump-submit");
|
|
1383
|
+
setAttribute(submit, "aria-label", readProp(props, "jumpToSubmitLabel", "Go"));
|
|
1384
|
+
insertBefore(label, createText(jumpLabel), null);
|
|
1385
|
+
insertBefore(label, input, null);
|
|
1386
|
+
insertBefore(submit, createText(readProp(props, "jumpToSubmitLabel", "Go")), null);
|
|
1387
|
+
addEventListener(input, "input", () => {
|
|
1388
|
+
const value = input.value.replace(/[^0-9]/gu, "");
|
|
1389
|
+
if (value !== input.value) setProperty(input, "value", value);
|
|
1390
|
+
});
|
|
1391
|
+
addEventListener(root, "submit", (event) => {
|
|
1392
|
+
event.preventDefault();
|
|
1393
|
+
if (!/^\d+$/u.test(input.value)) return;
|
|
1394
|
+
const requested = Number(input.value);
|
|
1395
|
+
if (!Number.isSafeInteger(requested)) return;
|
|
1396
|
+
goToPage(props, requested, pagination.pageCount);
|
|
1397
|
+
});
|
|
1398
|
+
insertBefore(root, label, null);
|
|
1399
|
+
insertBefore(root, submit, null);
|
|
1400
|
+
return root;
|
|
1401
|
+
}
|
|
1402
|
+
__name(createJumpControl, "createJumpControl");
|
|
1403
|
+
function createPageSizeControl(props, pagination) {
|
|
1404
|
+
const root = createElement("label");
|
|
1405
|
+
const select = createElement("select");
|
|
1406
|
+
const label = readProp(props, "pageSizeLabel", "Rows per page");
|
|
1407
|
+
setAttribute(root, "class", "vobs-data-table__page-size");
|
|
1408
|
+
setAttribute(select, "class", "vobs-data-table__page-size-select");
|
|
1409
|
+
setAttribute(select, "aria-label", label);
|
|
1410
|
+
insertBefore(root, createText(label), null);
|
|
1411
|
+
for (const optionValue of pageSizeOptions(props, pagination.pageSize)) {
|
|
1412
|
+
const option = createElement("option");
|
|
1413
|
+
setAttribute(option, "value", String(optionValue));
|
|
1414
|
+
setProperty(option, "textContent", String(optionValue));
|
|
1415
|
+
insertBefore(select, option, null);
|
|
1416
|
+
}
|
|
1417
|
+
setProperty(select, "value", String(pagination.pageSize));
|
|
1418
|
+
addEventListener(select, "change", () => {
|
|
1419
|
+
setPageSize(props, Number(select.value));
|
|
1420
|
+
});
|
|
1421
|
+
insertBefore(root, select, null);
|
|
1422
|
+
return root;
|
|
1423
|
+
}
|
|
1424
|
+
__name(createPageSizeControl, "createPageSizeControl");
|
|
1425
|
+
function resolvePage(props) {
|
|
1426
|
+
const resource = readProp(props, "resource", void 0);
|
|
1427
|
+
const supplied = resource?.data.value ?? readProp(props, "rows", []);
|
|
1428
|
+
const source = normalizeRows(supplied);
|
|
1429
|
+
const query = currentQuery(props);
|
|
1430
|
+
const rows = applyFiltersAndSort(source.rows, visibleColumns(props), query, readProp(props, "sortingMode", "client"));
|
|
1431
|
+
const remoteTotal = source.total ?? readProp(props, "total", void 0);
|
|
1432
|
+
const total = remoteTotal ?? rows.length;
|
|
1433
|
+
const isRemotePage = source.total !== void 0 || readProp(props, "total", void 0) !== void 0;
|
|
1434
|
+
if (isRemotePage) return { rows, total };
|
|
1435
|
+
const start = (query.page - 1) * query.pageSize;
|
|
1436
|
+
return { rows: rows.slice(start, start + query.pageSize), total };
|
|
1437
|
+
}
|
|
1438
|
+
__name(resolvePage, "resolvePage");
|
|
1439
|
+
function normalizeRows(value) {
|
|
1440
|
+
if (isRowArray(value)) return { rows: value };
|
|
1441
|
+
return { rows: value.rows ?? [], total: value.total };
|
|
1442
|
+
}
|
|
1443
|
+
__name(normalizeRows, "normalizeRows");
|
|
1444
|
+
function isRowArray(value) {
|
|
1445
|
+
return Array.isArray(value);
|
|
1446
|
+
}
|
|
1447
|
+
__name(isRowArray, "isRowArray");
|
|
1448
|
+
function applyFiltersAndSort(rows, columns, query, sortingMode) {
|
|
1449
|
+
let result = rows;
|
|
1450
|
+
for (const column2 of columns) {
|
|
1451
|
+
const value = query.filters[column2.id];
|
|
1452
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
1453
|
+
result = result.filter((row) => column2.filter ? column2.filter(row, value) : String(column2.key === void 0 ? "" : readRowValue(row, column2.key)).toLocaleLowerCase().includes(String(value).toLocaleLowerCase()));
|
|
1454
|
+
}
|
|
1455
|
+
if (!query.sort || sortingMode === "server") return result;
|
|
1456
|
+
const column = columns.find((candidate) => candidate.id === query.sort.columnId);
|
|
1457
|
+
if (!column) return result;
|
|
1458
|
+
const direction = query.sort.direction;
|
|
1459
|
+
return result.map((row, index) => ({ row, index })).sort((left, right) => {
|
|
1460
|
+
const compared = compareRows(left.row, right.row, column, direction);
|
|
1461
|
+
return compared === 0 ? left.index - right.index : compared;
|
|
1462
|
+
}).map((entry) => entry.row);
|
|
1463
|
+
}
|
|
1464
|
+
__name(applyFiltersAndSort, "applyFiltersAndSort");
|
|
1465
|
+
function compareRows(left, right, column, direction) {
|
|
1466
|
+
const multiplier = direction === "asc" ? 1 : -1;
|
|
1467
|
+
if (column.compare) return multiplier * column.compare(left, right);
|
|
1468
|
+
const leftValue = column.sortValue ? column.sortValue(left) : column.key === void 0 ? void 0 : readRowValue(left, column.key);
|
|
1469
|
+
const rightValue = column.sortValue ? column.sortValue(right) : column.key === void 0 ? void 0 : readRowValue(right, column.key);
|
|
1470
|
+
const leftMissing = isMissingSortValue(leftValue, column.sortType);
|
|
1471
|
+
const rightMissing = isMissingSortValue(rightValue, column.sortType);
|
|
1472
|
+
if (leftMissing || rightMissing) {
|
|
1473
|
+
if (leftMissing && rightMissing) return 0;
|
|
1474
|
+
return leftMissing ? 1 : -1;
|
|
1475
|
+
}
|
|
1476
|
+
return multiplier * compareSortValues(leftValue, rightValue, column.sortType);
|
|
1477
|
+
}
|
|
1478
|
+
__name(compareRows, "compareRows");
|
|
1479
|
+
function compareSortValues(left, right, sortType) {
|
|
1480
|
+
if (sortType === "number") return compareNumbers(left, right);
|
|
1481
|
+
if (sortType === "date") return compareDates(left, right);
|
|
1482
|
+
if (sortType === "boolean") return Number(Boolean(left)) - Number(Boolean(right));
|
|
1483
|
+
if (sortType === "text") return compareText(left, right);
|
|
1484
|
+
if (typeof left === "number" && typeof right === "number") return compareNumbers(left, right);
|
|
1485
|
+
if (left instanceof Date && right instanceof Date) return compareNumbers(left.getTime(), right.getTime());
|
|
1486
|
+
if (typeof left === "boolean" && typeof right === "boolean") return Number(left) - Number(right);
|
|
1487
|
+
return compareText(left, right);
|
|
1488
|
+
}
|
|
1489
|
+
__name(compareSortValues, "compareSortValues");
|
|
1490
|
+
function compareNumbers(left, right) {
|
|
1491
|
+
return Number(left) - Number(right);
|
|
1492
|
+
}
|
|
1493
|
+
__name(compareNumbers, "compareNumbers");
|
|
1494
|
+
function compareDates(left, right) {
|
|
1495
|
+
const leftTime = left instanceof Date ? left.getTime() : Date.parse(String(left));
|
|
1496
|
+
const rightTime = right instanceof Date ? right.getTime() : Date.parse(String(right));
|
|
1497
|
+
return leftTime - rightTime;
|
|
1498
|
+
}
|
|
1499
|
+
__name(compareDates, "compareDates");
|
|
1500
|
+
function compareText(left, right) {
|
|
1501
|
+
return textCollator.compare(String(left), String(right));
|
|
1502
|
+
}
|
|
1503
|
+
__name(compareText, "compareText");
|
|
1504
|
+
function createSort(column, direction) {
|
|
1505
|
+
return column.sortKey ? { columnId: column.id, direction, sortKey: column.sortKey } : { columnId: column.id, direction };
|
|
1506
|
+
}
|
|
1507
|
+
__name(createSort, "createSort");
|
|
1508
|
+
function isMissingSortValue(value, sortType) {
|
|
1509
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
1510
|
+
if (sortType === "number") return !Number.isFinite(Number(value));
|
|
1511
|
+
if (sortType === "date") {
|
|
1512
|
+
const timestamp = value instanceof Date ? value.getTime() : Date.parse(String(value));
|
|
1513
|
+
return !Number.isFinite(timestamp);
|
|
1514
|
+
}
|
|
1515
|
+
return false;
|
|
1516
|
+
}
|
|
1517
|
+
__name(isMissingSortValue, "isMissingSortValue");
|
|
1518
|
+
function resolveWindow(props, count, scrollTop) {
|
|
1519
|
+
if (!readProp(props, "virtual", false)) return { start: 0, end: count, before: 0, after: 0 };
|
|
1520
|
+
const rowHeight = normalizePositive(readProp(props, "rowHeight", DEFAULT_ROW_HEIGHT), DEFAULT_ROW_HEIGHT);
|
|
1521
|
+
const viewportHeight = normalizePositive(readProp(props, "virtualHeight", DEFAULT_VIRTUAL_HEIGHT), DEFAULT_VIRTUAL_HEIGHT);
|
|
1522
|
+
const overscan = Math.max(0, Math.floor(readProp(props, "overscan", 5)));
|
|
1523
|
+
const start = Math.max(0, Math.floor(scrollTop / rowHeight) - overscan);
|
|
1524
|
+
const end = Math.min(count, Math.ceil((scrollTop + viewportHeight) / rowHeight) + overscan);
|
|
1525
|
+
return { start, end, before: start * rowHeight, after: (count - end) * rowHeight };
|
|
1526
|
+
}
|
|
1527
|
+
__name(resolveWindow, "resolveWindow");
|
|
1528
|
+
function unwrapQueryValue(value) {
|
|
1529
|
+
return typeof value === "number" ? value : value.value;
|
|
1530
|
+
}
|
|
1531
|
+
__name(unwrapQueryValue, "unwrapQueryValue");
|
|
1532
|
+
function currentQuery(props) {
|
|
1533
|
+
const internal = internalQueries.get(props)?.value;
|
|
1534
|
+
const page = unwrapQueryValue(readProp(props, "page", internal?.page ?? 1));
|
|
1535
|
+
const pageSize = unwrapQueryValue(readProp(props, "pageSize", internal?.pageSize ?? DEFAULT_PAGE_SIZE));
|
|
1536
|
+
return {
|
|
1537
|
+
page: Math.max(1, Math.floor(page)),
|
|
1538
|
+
pageSize: normalizePositive(pageSize, DEFAULT_PAGE_SIZE),
|
|
1539
|
+
sort: readProp(props, "sort", internal?.sort ?? null),
|
|
1540
|
+
filters: readProp(props, "filters", internal?.filters ?? {})
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
__name(currentQuery, "currentQuery");
|
|
1544
|
+
function readSignalProp(props, name) {
|
|
1545
|
+
const value = Reflect.get(props, name);
|
|
1546
|
+
return value && typeof value === "object" && "value" in value ? value : void 0;
|
|
1547
|
+
}
|
|
1548
|
+
__name(readSignalProp, "readSignalProp");
|
|
1549
|
+
function emitQuery(props, query) {
|
|
1550
|
+
const internal = internalQueries.get(props);
|
|
1551
|
+
if (internal) internal.value = query;
|
|
1552
|
+
const pageSignal = readSignalProp(props, "page");
|
|
1553
|
+
if (pageSignal) pageSignal.value = query.page;
|
|
1554
|
+
const pageSizeSignal = readSignalProp(props, "pageSize");
|
|
1555
|
+
if (pageSizeSignal) pageSizeSignal.value = query.pageSize;
|
|
1556
|
+
readProp(props, "onQueryChange", void 0)?.(query);
|
|
1557
|
+
}
|
|
1558
|
+
__name(emitQuery, "emitQuery");
|
|
1559
|
+
function currentSort(props) {
|
|
1560
|
+
return currentQuery(props).sort;
|
|
1561
|
+
}
|
|
1562
|
+
__name(currentSort, "currentSort");
|
|
1563
|
+
function visibleColumns(props) {
|
|
1564
|
+
const columns = readProp(props, "columns", []);
|
|
1565
|
+
const rawSettings = readProp(props, "columnSettings", void 0);
|
|
1566
|
+
const settings = rawSettings ? normalizeColumnSettings(columns, rawSettings) : void 0;
|
|
1567
|
+
const ids = settings?.visibleColumnIds ?? readProp(props, "visibleColumnIds", void 0);
|
|
1568
|
+
const visible = ids ? new Set(ids) : void 0;
|
|
1569
|
+
return orderColumns(columns, settings?.columnOrder).filter((column) => column.visible !== false && (!visible || visible.has(column.id)));
|
|
1570
|
+
}
|
|
1571
|
+
__name(visibleColumns, "visibleColumns");
|
|
1572
|
+
function resolveIcons(props) {
|
|
1573
|
+
return { ...defaultIcons(), ...readProp(props, "icons", void 0) ?? {} };
|
|
1574
|
+
}
|
|
1575
|
+
__name(resolveIcons, "resolveIcons");
|
|
1576
|
+
function sortIcon(props, sort, columnId) {
|
|
1577
|
+
const icons = resolveIcons(props);
|
|
1578
|
+
if (sort?.columnId !== columnId) return icons.unsorted;
|
|
1579
|
+
return sort.direction === "asc" ? icons.ascending : icons.descending;
|
|
1580
|
+
}
|
|
1581
|
+
__name(sortIcon, "sortIcon");
|
|
1582
|
+
function pageLabel(props, page, pageCount, total, visibleCount, pageSize) {
|
|
1583
|
+
return readProp(props, "pageLabel", void 0)?.(page, pageCount, total, visibleCount, pageSize) ?? `${visibleCount}/${pageSize} - ${page}/${pageCount}`;
|
|
1584
|
+
}
|
|
1585
|
+
__name(pageLabel, "pageLabel");
|
|
1586
|
+
function shouldShowFooter(props) {
|
|
1587
|
+
return hasProp(props, "footer") || hasProp(props, "pagination") || hasProp(props, "paginationMode") || hasProp(props, "pageSizeOptions") || resolvePage(props).total > currentQuery(props).pageSize;
|
|
1588
|
+
}
|
|
1589
|
+
__name(shouldShowFooter, "shouldShowFooter");
|
|
1590
|
+
function resolvePaginationState(props) {
|
|
1591
|
+
const page = resolvePage(props);
|
|
1592
|
+
const query = currentQuery(props);
|
|
1593
|
+
return {
|
|
1594
|
+
page: query.page,
|
|
1595
|
+
pageCount: Math.max(1, Math.ceil(page.total / query.pageSize)),
|
|
1596
|
+
pageSize: query.pageSize,
|
|
1597
|
+
total: page.total,
|
|
1598
|
+
visibleCount: page.rows.length
|
|
1599
|
+
};
|
|
1600
|
+
}
|
|
1601
|
+
__name(resolvePaginationState, "resolvePaginationState");
|
|
1602
|
+
function goToPage(props, page, pageCount) {
|
|
1603
|
+
const query = currentQuery(props);
|
|
1604
|
+
const nextPage = clampPage(page, pageCount);
|
|
1605
|
+
if (nextPage === query.page) return;
|
|
1606
|
+
emitQuery(props, { ...query, page: nextPage });
|
|
1607
|
+
}
|
|
1608
|
+
__name(goToPage, "goToPage");
|
|
1609
|
+
function setPageSize(props, pageSize) {
|
|
1610
|
+
const query = currentQuery(props);
|
|
1611
|
+
const nextPageSize = normalizePositive(pageSize, query.pageSize);
|
|
1612
|
+
if (nextPageSize === query.pageSize) return;
|
|
1613
|
+
emitQuery(props, { ...query, page: 1, pageSize: nextPageSize });
|
|
1614
|
+
}
|
|
1615
|
+
__name(setPageSize, "setPageSize");
|
|
1616
|
+
function pageSizeOptions(props, currentPageSize) {
|
|
1617
|
+
const configured = readProp(props, "pageSizeOptions", void 0) ?? DEFAULT_PAGE_SIZE_OPTIONS;
|
|
1618
|
+
const values = configured.map((value) => normalizePositive(value, 0)).filter((value) => value > 0);
|
|
1619
|
+
if (!values.includes(currentPageSize)) values.push(currentPageSize);
|
|
1620
|
+
return [...new Set(values)].sort((left, right) => left - right);
|
|
1621
|
+
}
|
|
1622
|
+
__name(pageSizeOptions, "pageSizeOptions");
|
|
1623
|
+
function buildPaginationItems(page, pageCount) {
|
|
1624
|
+
const siblingCount = 1;
|
|
1625
|
+
const totalVisible = siblingCount * 2 + 5;
|
|
1626
|
+
if (pageCount <= totalVisible) {
|
|
1627
|
+
return Array.from({ length: pageCount }, (_, index) => index + 1);
|
|
1628
|
+
}
|
|
1629
|
+
const left = Math.max(page - siblingCount, 2);
|
|
1630
|
+
const right = Math.min(page + siblingCount, pageCount - 1);
|
|
1631
|
+
const items = [1];
|
|
1632
|
+
if (left > 2) items.push("ellipsis-left");
|
|
1633
|
+
for (let value = left; value <= right; value++) items.push(value);
|
|
1634
|
+
if (right < pageCount - 1) items.push("ellipsis-right");
|
|
1635
|
+
items.push(pageCount);
|
|
1636
|
+
return items;
|
|
1637
|
+
}
|
|
1638
|
+
__name(buildPaginationItems, "buildPaginationItems");
|
|
1639
|
+
function clampPage(page, pageCount) {
|
|
1640
|
+
if (pageCount <= 0) return 1;
|
|
1641
|
+
return Math.min(pageCount, Math.max(1, Math.floor(Number.isFinite(page) ? page : 1)));
|
|
1642
|
+
}
|
|
1643
|
+
__name(clampPage, "clampPage");
|
|
1644
|
+
function applyColumnStyle(cell, column, settings) {
|
|
1645
|
+
const width = settings?.columnWidths[column.id] ?? column.width;
|
|
1646
|
+
const styles = [
|
|
1647
|
+
normalizePixels(width) ? `width: ${normalizePixels(width)}` : "",
|
|
1648
|
+
normalizePixels(column.minWidth) ? `min-width: ${normalizePixels(column.minWidth)}` : ""
|
|
1649
|
+
].filter(Boolean).join("; ");
|
|
1650
|
+
if (styles) setAttribute(cell, "style", styles);
|
|
1651
|
+
setOptionalAttribute(cell, "data-align", column.align);
|
|
1652
|
+
}
|
|
1653
|
+
__name(applyColumnStyle, "applyColumnStyle");
|
|
1654
|
+
function normalizeHeight(value) {
|
|
1655
|
+
return `${normalizePositive(value, DEFAULT_VIRTUAL_HEIGHT)}px`;
|
|
1656
|
+
}
|
|
1657
|
+
__name(normalizeHeight, "normalizeHeight");
|
|
1658
|
+
function normalizePositive(value, fallback) {
|
|
1659
|
+
return Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;
|
|
1660
|
+
}
|
|
1661
|
+
__name(normalizePositive, "normalizePositive");
|
|
1662
|
+
function readRowValue(row, key) {
|
|
1663
|
+
return row === null || row === void 0 ? void 0 : Reflect.get(row, key);
|
|
1664
|
+
}
|
|
1665
|
+
__name(readRowValue, "readRowValue");
|
|
1666
|
+
|
|
1667
|
+
export { KitDataTable };
|
|
1668
|
+
//# sourceMappingURL=data-table.js.map
|
|
1669
|
+
//# sourceMappingURL=data-table.js.map
|