@vobs/table 1.0.0 → 1.2.0
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 +38 -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,1034 @@
|
|
|
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 untrack(fn) {
|
|
121
|
+
const previous = currentSubscriber;
|
|
122
|
+
currentSubscriber = null;
|
|
123
|
+
try {
|
|
124
|
+
return fn();
|
|
125
|
+
} finally {
|
|
126
|
+
currentSubscriber = previous;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
__name(untrack, "untrack");
|
|
130
|
+
function trackDependency(dependency) {
|
|
131
|
+
if (!currentSubscriber || currentSubscriber.disposed) return;
|
|
132
|
+
!currentSubscriber.dependencies.has(dependency);
|
|
133
|
+
currentSubscriber.dependencies.add(dependency);
|
|
134
|
+
}
|
|
135
|
+
__name(trackDependency, "trackDependency");
|
|
136
|
+
function state(initialValue, debugName) {
|
|
137
|
+
let value = initialValue;
|
|
138
|
+
let disposed = false;
|
|
139
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
140
|
+
const signalInstance = {
|
|
141
|
+
get value() {
|
|
142
|
+
const subscriber = getCurrentSubscriber();
|
|
143
|
+
if (subscriber && !subscriber.disposed) {
|
|
144
|
+
subscribers.add(subscriber);
|
|
145
|
+
trackDependency(signalInstance);
|
|
146
|
+
}
|
|
147
|
+
return value;
|
|
148
|
+
},
|
|
149
|
+
set value(nextValue) {
|
|
150
|
+
if (disposed || Object.is(value, nextValue)) return;
|
|
151
|
+
value = nextValue;
|
|
152
|
+
for (const subscriber of [...subscribers]) subscriber.notify();
|
|
153
|
+
},
|
|
154
|
+
unsubscribe(subscriber) {
|
|
155
|
+
subscribers.delete(subscriber);
|
|
156
|
+
},
|
|
157
|
+
// 与 `.value =` 赋值同一条路径:判等短路、debug hook、notify 全部一致。
|
|
158
|
+
// 以闭包实现,可安全地作为回调直接传递(无 this 绑定问题)。
|
|
159
|
+
set(next) {
|
|
160
|
+
signalInstance.value = next;
|
|
161
|
+
},
|
|
162
|
+
dispose() {
|
|
163
|
+
if (disposed) return;
|
|
164
|
+
disposed = true;
|
|
165
|
+
subscribers.clear();
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const owner = getCurrentOwner();
|
|
169
|
+
owner?.addCleanup(signalInstance.dispose);
|
|
170
|
+
if (debugName?.trim()) setSignalDebugName(signalInstance, debugName.trim());
|
|
171
|
+
return signalInstance;
|
|
172
|
+
}
|
|
173
|
+
__name(state, "state");
|
|
174
|
+
|
|
175
|
+
// packages/reactivity/src/scheduler.ts
|
|
176
|
+
var _Scheduler = class _Scheduler {
|
|
177
|
+
constructor() {
|
|
178
|
+
this.dirtyEffects = /* @__PURE__ */ new Set();
|
|
179
|
+
this.lowPriorityEffects = /* @__PURE__ */ new Set();
|
|
180
|
+
// flush 不可重入(flushing 标志保证),缓冲数组可在轮次间安全复用,避免每轮分配。
|
|
181
|
+
this.normalBuffer = [];
|
|
182
|
+
this.lowBuffer = [];
|
|
183
|
+
this.flushing = false;
|
|
184
|
+
this.scheduled = false;
|
|
185
|
+
this.batchDepth = 0;
|
|
186
|
+
}
|
|
187
|
+
schedule(effect2) {
|
|
188
|
+
if (effect2.disposed) return;
|
|
189
|
+
this.dirtyEffects.add(effect2);
|
|
190
|
+
this.lowPriorityEffects.delete(effect2);
|
|
191
|
+
this.ensureScheduled();
|
|
192
|
+
}
|
|
193
|
+
/** Queue an effect behind normal updates while preserving deterministic order. */
|
|
194
|
+
scheduleLow(effect2) {
|
|
195
|
+
if (effect2.disposed) return;
|
|
196
|
+
if (!this.dirtyEffects.has(effect2)) this.lowPriorityEffects.add(effect2);
|
|
197
|
+
this.ensureScheduled();
|
|
198
|
+
}
|
|
199
|
+
ensureScheduled() {
|
|
200
|
+
if (this.batchDepth === 0 && !this.flushing && !this.scheduled) {
|
|
201
|
+
this.scheduled = true;
|
|
202
|
+
queueMicrotask(() => {
|
|
203
|
+
this.scheduled = false;
|
|
204
|
+
this.flush();
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
remove(effect2) {
|
|
209
|
+
this.dirtyEffects.delete(effect2);
|
|
210
|
+
this.lowPriorityEffects.delete(effect2);
|
|
211
|
+
}
|
|
212
|
+
batch(fn) {
|
|
213
|
+
this.batchDepth++;
|
|
214
|
+
try {
|
|
215
|
+
return fn();
|
|
216
|
+
} finally {
|
|
217
|
+
this.batchDepth--;
|
|
218
|
+
if (this.batchDepth === 0) this.flush();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
flush() {
|
|
222
|
+
if (this.flushing || this.batchDepth > 0) return;
|
|
223
|
+
this.flushing = true;
|
|
224
|
+
let rounds = 0;
|
|
225
|
+
let firstError;
|
|
226
|
+
let hasError = false;
|
|
227
|
+
try {
|
|
228
|
+
while (this.dirtyEffects.size > 0 || this.lowPriorityEffects.size > 0) {
|
|
229
|
+
if (++rounds > 100) {
|
|
230
|
+
this.dirtyEffects.clear();
|
|
231
|
+
this.lowPriorityEffects.clear();
|
|
232
|
+
throw new Error("Vobs: \u54CD\u5E94\u5F0F\u66F4\u65B0\u8D85\u8FC7 100 \u8F6E\uFF0C\u53EF\u80FD\u5B58\u5728\u5FAA\u73AF\u4F9D\u8D56");
|
|
233
|
+
}
|
|
234
|
+
this.collectRunnable(this.dirtyEffects, this.normalBuffer);
|
|
235
|
+
this.collectRunnable(this.lowPriorityEffects, this.lowBuffer);
|
|
236
|
+
sortEffects(this.normalBuffer);
|
|
237
|
+
sortEffects(this.lowBuffer);
|
|
238
|
+
for (const effect2 of this.normalBuffer) {
|
|
239
|
+
try {
|
|
240
|
+
effect2.run();
|
|
241
|
+
} catch (error) {
|
|
242
|
+
if (!hasError) {
|
|
243
|
+
firstError = error;
|
|
244
|
+
hasError = true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
for (const effect2 of this.lowBuffer) {
|
|
249
|
+
try {
|
|
250
|
+
effect2.run();
|
|
251
|
+
} catch (error) {
|
|
252
|
+
if (!hasError) {
|
|
253
|
+
firstError = error;
|
|
254
|
+
hasError = true;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
this.normalBuffer.length = 0;
|
|
259
|
+
this.lowBuffer.length = 0;
|
|
260
|
+
}
|
|
261
|
+
} finally {
|
|
262
|
+
this.normalBuffer.length = 0;
|
|
263
|
+
this.lowBuffer.length = 0;
|
|
264
|
+
this.flushing = false;
|
|
265
|
+
}
|
|
266
|
+
if (hasError) throw firstError;
|
|
267
|
+
}
|
|
268
|
+
/** 收集未 disposed 的 effect 并清空源集合;run() 期间新调度的 effect 留给下一轮。 */
|
|
269
|
+
collectRunnable(source, target) {
|
|
270
|
+
for (const effect2 of source) {
|
|
271
|
+
if (!effect2.disposed) target.push(effect2);
|
|
272
|
+
}
|
|
273
|
+
source.clear();
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
__name(_Scheduler, "Scheduler");
|
|
277
|
+
var Scheduler = _Scheduler;
|
|
278
|
+
function sortEffects(effects) {
|
|
279
|
+
if (effects.length > 1) {
|
|
280
|
+
effects.sort((a, b) => b.depth - a.depth || a.order - b.order);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
__name(sortEffects, "sortEffects");
|
|
284
|
+
var scheduler = new Scheduler();
|
|
285
|
+
|
|
286
|
+
// packages/reactivity/src/effect.ts
|
|
287
|
+
var nextEffectOrder = 1;
|
|
288
|
+
function cleanupDependencies(subscriber) {
|
|
289
|
+
for (const dependency of subscriber.dependencies) {
|
|
290
|
+
dependency.unsubscribe(subscriber);
|
|
291
|
+
}
|
|
292
|
+
subscriber.dependencies.clear();
|
|
293
|
+
}
|
|
294
|
+
__name(cleanupDependencies, "cleanupDependencies");
|
|
295
|
+
function effect(callback) {
|
|
296
|
+
const owner = getCurrentOwner();
|
|
297
|
+
let cleanup;
|
|
298
|
+
let dirty = true;
|
|
299
|
+
let disposed = false;
|
|
300
|
+
const eff = {
|
|
301
|
+
order: nextEffectOrder++,
|
|
302
|
+
depth: owner?.depth ?? 0,
|
|
303
|
+
dependencies: /* @__PURE__ */ new Set(),
|
|
304
|
+
get disposed() {
|
|
305
|
+
return disposed;
|
|
306
|
+
},
|
|
307
|
+
notify() {
|
|
308
|
+
if (disposed || dirty) return;
|
|
309
|
+
dirty = true;
|
|
310
|
+
scheduler.schedule(eff);
|
|
311
|
+
},
|
|
312
|
+
run() {
|
|
313
|
+
if (disposed || !dirty) return;
|
|
314
|
+
dirty = false;
|
|
315
|
+
const previousCleanup = cleanup;
|
|
316
|
+
cleanup = void 0;
|
|
317
|
+
let cleanupError;
|
|
318
|
+
if (previousCleanup) {
|
|
319
|
+
try {
|
|
320
|
+
previousCleanup();
|
|
321
|
+
} catch (error) {
|
|
322
|
+
const handled2 = owner?.handleError(error) ?? false;
|
|
323
|
+
if (!handled2) cleanupError = error;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
cleanupDependencies(eff);
|
|
327
|
+
const previous = getCurrentSubscriber();
|
|
328
|
+
setCurrentSubscriber(eff);
|
|
329
|
+
let thrown;
|
|
330
|
+
let handled = false;
|
|
331
|
+
try {
|
|
332
|
+
const result = owner ? owner.run(callback) : callback();
|
|
333
|
+
cleanup = typeof result === "function" ? result : void 0;
|
|
334
|
+
} catch (error) {
|
|
335
|
+
thrown = error;
|
|
336
|
+
handled = owner?.handleError(error) ?? false;
|
|
337
|
+
if (!handled) throw error;
|
|
338
|
+
} finally {
|
|
339
|
+
setCurrentSubscriber(previous);
|
|
340
|
+
}
|
|
341
|
+
if (cleanupError && !thrown) throw cleanupError;
|
|
342
|
+
},
|
|
343
|
+
scheduleLow() {
|
|
344
|
+
if (disposed || dirty) return;
|
|
345
|
+
dirty = true;
|
|
346
|
+
scheduler.scheduleLow(eff);
|
|
347
|
+
},
|
|
348
|
+
dispose() {
|
|
349
|
+
if (disposed) return;
|
|
350
|
+
disposed = true;
|
|
351
|
+
dirty = false;
|
|
352
|
+
scheduler.remove(eff);
|
|
353
|
+
const previousCleanup = cleanup;
|
|
354
|
+
cleanup = void 0;
|
|
355
|
+
let cleanupError;
|
|
356
|
+
if (previousCleanup) {
|
|
357
|
+
try {
|
|
358
|
+
previousCleanup();
|
|
359
|
+
} catch (error) {
|
|
360
|
+
const handled = owner?.handleError(error) ?? false;
|
|
361
|
+
if (!handled) cleanupError = error;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
cleanupDependencies(eff);
|
|
365
|
+
if (cleanupError) throw cleanupError;
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
owner?.addCleanup(eff.dispose);
|
|
369
|
+
eff.run();
|
|
370
|
+
return eff;
|
|
371
|
+
}
|
|
372
|
+
__name(effect, "effect");
|
|
373
|
+
|
|
374
|
+
// packages/runtime/src/debug.ts
|
|
375
|
+
var activeRuntimeDebugHooks = null;
|
|
376
|
+
function getRuntimeDebugHooks() {
|
|
377
|
+
return activeRuntimeDebugHooks;
|
|
378
|
+
}
|
|
379
|
+
__name(getRuntimeDebugHooks, "getRuntimeDebugHooks");
|
|
380
|
+
function invokeRuntimeDebug(name, ...args) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
__name(invokeRuntimeDebug, "invokeRuntimeDebug");
|
|
384
|
+
function readDebugValue(read) {
|
|
385
|
+
try {
|
|
386
|
+
return read();
|
|
387
|
+
} catch {
|
|
388
|
+
return "[Uninspectable]";
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
__name(readDebugValue, "readDebugValue");
|
|
392
|
+
function describeDebugNode(node) {
|
|
393
|
+
if (!node || typeof node !== "object") return "node";
|
|
394
|
+
const value = node;
|
|
395
|
+
const name = typeof value.tagName === "string" ? value.tagName.toLowerCase() : typeof value.nodeName === "string" ? value.nodeName.toLowerCase() : "node";
|
|
396
|
+
const id = typeof value.id === "string" && value.id ? `#${value.id}` : "";
|
|
397
|
+
const className = typeof value.className === "string" && value.className ? `.${value.className.trim().split(/\s+/).filter(Boolean).join(".")}` : "";
|
|
398
|
+
return `${name}${id}${className}`;
|
|
399
|
+
}
|
|
400
|
+
__name(describeDebugNode, "describeDebugNode");
|
|
401
|
+
|
|
402
|
+
// packages/runtime/src/hmr.ts
|
|
403
|
+
var globalTarget = globalThis;
|
|
404
|
+
var hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: /* @__PURE__ */ new Map() };
|
|
405
|
+
globalTarget.__VOBS_HMR__ = hmrGlobal;
|
|
406
|
+
function markHmrInstanceMounted(node, parent) {
|
|
407
|
+
const instance = hmrInstances.get(node);
|
|
408
|
+
if (instance) instance.parent = parent;
|
|
409
|
+
}
|
|
410
|
+
__name(markHmrInstanceMounted, "markHmrInstanceMounted");
|
|
411
|
+
var hmrInstances = /* @__PURE__ */ new WeakMap();
|
|
412
|
+
var nodeOwners = /* @__PURE__ */ new WeakMap();
|
|
413
|
+
var eventBindings = /* @__PURE__ */ new WeakMap();
|
|
414
|
+
function getRenderer() {
|
|
415
|
+
{
|
|
416
|
+
throw new Error("\u6E32\u67D3\u5668\u672A\u521D\u59CB\u5316");
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
__name(getRenderer, "getRenderer");
|
|
420
|
+
function createText(content) {
|
|
421
|
+
return getRenderer().createText(content);
|
|
422
|
+
}
|
|
423
|
+
__name(createText, "createText");
|
|
424
|
+
function createElement(tag) {
|
|
425
|
+
return getRenderer().createElement(tag);
|
|
426
|
+
}
|
|
427
|
+
__name(createElement, "createElement");
|
|
428
|
+
function createComment(content) {
|
|
429
|
+
return getRenderer().createComment(content);
|
|
430
|
+
}
|
|
431
|
+
__name(createComment, "createComment");
|
|
432
|
+
function insertBefore(parent, child, anchor) {
|
|
433
|
+
if (isVobsFragment(child)) {
|
|
434
|
+
child.mount(parent, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
getRenderer().insertBefore(parent, child, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
438
|
+
markHmrInstanceMounted(child, parent);
|
|
439
|
+
}
|
|
440
|
+
__name(insertBefore, "insertBefore");
|
|
441
|
+
function removeChild(parent, child) {
|
|
442
|
+
disposeNodeOwner(child);
|
|
443
|
+
if (isVobsFragment(child)) {
|
|
444
|
+
child.unmount(parent);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
getRenderer().removeChild(parent, child);
|
|
448
|
+
}
|
|
449
|
+
__name(removeChild, "removeChild");
|
|
450
|
+
function setTextContent(node, content) {
|
|
451
|
+
getRenderer().setTextContent(node, content);
|
|
452
|
+
}
|
|
453
|
+
__name(setTextContent, "setTextContent");
|
|
454
|
+
function setProperty(node, key, value) {
|
|
455
|
+
getRenderer().setProperty(node, key, value);
|
|
456
|
+
}
|
|
457
|
+
__name(setProperty, "setProperty");
|
|
458
|
+
function setAttribute(node, key, value) {
|
|
459
|
+
getRenderer().setAttribute(node, key, value);
|
|
460
|
+
}
|
|
461
|
+
__name(setAttribute, "setAttribute");
|
|
462
|
+
function addEventListener(node, event, handler) {
|
|
463
|
+
const renderer = getRenderer();
|
|
464
|
+
const owner = getCurrentOwner();
|
|
465
|
+
let bindings = eventBindings.get(node);
|
|
466
|
+
if (!bindings) {
|
|
467
|
+
bindings = /* @__PURE__ */ new Map();
|
|
468
|
+
eventBindings.set(node, bindings);
|
|
469
|
+
}
|
|
470
|
+
const previous = bindings.get(event);
|
|
471
|
+
if (previous && previous.original === handler && previous.owner === owner) return;
|
|
472
|
+
if (previous) renderer.removeEventListener(node, event, previous.handler);
|
|
473
|
+
const listener = owner ? (reason) => {
|
|
474
|
+
try {
|
|
475
|
+
owner.run(() => handler(reason));
|
|
476
|
+
} catch (error) {
|
|
477
|
+
const handled = owner.handleError(error);
|
|
478
|
+
invokeRuntimeDebug("error", {
|
|
479
|
+
error,
|
|
480
|
+
owner,
|
|
481
|
+
phase: "event",
|
|
482
|
+
handled,
|
|
483
|
+
recovery: handled ? "handled" : "propagated"
|
|
484
|
+
});
|
|
485
|
+
if (!handled) throw error;
|
|
486
|
+
}
|
|
487
|
+
} : handler;
|
|
488
|
+
const binding = { handler: listener, owner, original: handler };
|
|
489
|
+
bindings.set(event, binding);
|
|
490
|
+
renderer.addEventListener(node, event, listener);
|
|
491
|
+
owner?.onDispose(() => {
|
|
492
|
+
if (bindings?.get(event) !== binding) return;
|
|
493
|
+
bindings.delete(event);
|
|
494
|
+
renderer.removeEventListener(node, event, listener);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
__name(addEventListener, "addEventListener");
|
|
498
|
+
function createBlock(factory) {
|
|
499
|
+
const owner = createOwner();
|
|
500
|
+
setOwnerDebugName(owner, "dynamic");
|
|
501
|
+
let node;
|
|
502
|
+
try {
|
|
503
|
+
node = owner.run(factory);
|
|
504
|
+
} catch (error) {
|
|
505
|
+
owner.dispose();
|
|
506
|
+
throw error;
|
|
507
|
+
}
|
|
508
|
+
if (!node) {
|
|
509
|
+
owner.dispose();
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
associateNodeOwner(node, owner);
|
|
513
|
+
return node;
|
|
514
|
+
}
|
|
515
|
+
__name(createBlock, "createBlock");
|
|
516
|
+
function associateNodeOwner(node, owner) {
|
|
517
|
+
nodeOwners.set(node, owner);
|
|
518
|
+
}
|
|
519
|
+
__name(associateNodeOwner, "associateNodeOwner");
|
|
520
|
+
function disposeNodeOwner(node) {
|
|
521
|
+
const owner = nodeOwners.get(node);
|
|
522
|
+
if (!owner) return;
|
|
523
|
+
nodeOwners.delete(node);
|
|
524
|
+
owner.dispose();
|
|
525
|
+
}
|
|
526
|
+
__name(disposeNodeOwner, "disposeNodeOwner");
|
|
527
|
+
|
|
528
|
+
// packages/runtime/src/fragment.ts
|
|
529
|
+
function createFragment(factory) {
|
|
530
|
+
const start = createComment("vobs:fragment:start");
|
|
531
|
+
const end = createComment("vobs:fragment:end");
|
|
532
|
+
let parent = null;
|
|
533
|
+
let initialized = false;
|
|
534
|
+
const owner = getCurrentOwner();
|
|
535
|
+
const fragment = {
|
|
536
|
+
kind: "vobs-fragment",
|
|
537
|
+
start,
|
|
538
|
+
end,
|
|
539
|
+
mount(nextParent, anchor) {
|
|
540
|
+
if (parent && parent !== nextParent) {
|
|
541
|
+
throw new Error("Vobs Fragment: \u4E0D\u80FD\u8DE8\u7236\u8282\u70B9\u79FB\u52A8 Fragment");
|
|
542
|
+
}
|
|
543
|
+
if (initialized) {
|
|
544
|
+
moveRange(nextParent, start, end, anchor);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
const renderer = getRenderer();
|
|
548
|
+
renderer.insertBefore(nextParent, start, anchor);
|
|
549
|
+
renderer.insertBefore(nextParent, end, anchor);
|
|
550
|
+
parent = nextParent;
|
|
551
|
+
initialized = true;
|
|
552
|
+
if (owner) owner.run(() => factory(nextParent, end));
|
|
553
|
+
else factory(nextParent, end);
|
|
554
|
+
},
|
|
555
|
+
unmount(nextParent) {
|
|
556
|
+
if (!initialized || parent !== nextParent) {
|
|
557
|
+
throw new Error("Vobs Fragment: Fragment \u4E0D\u5C5E\u4E8E\u6307\u5B9A\u7236\u8282\u70B9");
|
|
558
|
+
}
|
|
559
|
+
const renderer = getRenderer();
|
|
560
|
+
let current = renderer.nextSibling(start);
|
|
561
|
+
while (current && current !== end) {
|
|
562
|
+
const next = renderer.nextSibling(current);
|
|
563
|
+
renderer.removeChild(nextParent, current);
|
|
564
|
+
current = next;
|
|
565
|
+
}
|
|
566
|
+
renderer.removeChild(nextParent, start);
|
|
567
|
+
renderer.removeChild(nextParent, end);
|
|
568
|
+
parent = null;
|
|
569
|
+
initialized = false;
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
return fragment;
|
|
573
|
+
}
|
|
574
|
+
__name(createFragment, "createFragment");
|
|
575
|
+
function isVobsFragment(value) {
|
|
576
|
+
return Boolean(value) && typeof value === "object" && value.kind === "vobs-fragment";
|
|
577
|
+
}
|
|
578
|
+
__name(isVobsFragment, "isVobsFragment");
|
|
579
|
+
function moveRange(parent, start, end, anchor) {
|
|
580
|
+
const renderer = getRenderer();
|
|
581
|
+
const nodes = [start];
|
|
582
|
+
let current = renderer.nextSibling(start);
|
|
583
|
+
while (current) {
|
|
584
|
+
nodes.push(current);
|
|
585
|
+
if (current === end) break;
|
|
586
|
+
current = renderer.nextSibling(current);
|
|
587
|
+
}
|
|
588
|
+
if (nodes[nodes.length - 1] !== end) {
|
|
589
|
+
throw new Error("Vobs Fragment: \u627E\u4E0D\u5230\u7ED3\u675F\u951A\u70B9");
|
|
590
|
+
}
|
|
591
|
+
for (const node of nodes) renderer.insertBefore(parent, node, anchor);
|
|
592
|
+
}
|
|
593
|
+
__name(moveRange, "moveRange");
|
|
594
|
+
|
|
595
|
+
// packages/runtime/src/dynamic.ts
|
|
596
|
+
function insertDynamic(parent, anchor, factory) {
|
|
597
|
+
const marker = createComment("vobs:dynamic");
|
|
598
|
+
insertBefore(parent, marker, anchor);
|
|
599
|
+
let current = null;
|
|
600
|
+
effect(() => {
|
|
601
|
+
const next = createBlock(factory);
|
|
602
|
+
if (next === current) return;
|
|
603
|
+
if (current) removeChild(parent, current);
|
|
604
|
+
current = next;
|
|
605
|
+
if (current) insertBefore(parent, current, marker);
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
__name(insertDynamic, "insertDynamic");
|
|
609
|
+
|
|
610
|
+
// packages/table/src/utils.ts
|
|
611
|
+
function readProp(props, name, fallback) {
|
|
612
|
+
const value = Reflect.get(props, name);
|
|
613
|
+
return value === void 0 ? fallback : value;
|
|
614
|
+
}
|
|
615
|
+
__name(readProp, "readProp");
|
|
616
|
+
function hasProp(props, name) {
|
|
617
|
+
return name in props;
|
|
618
|
+
}
|
|
619
|
+
__name(hasProp, "hasProp");
|
|
620
|
+
function bindClassList(root, props, classes) {
|
|
621
|
+
effect(() => {
|
|
622
|
+
const userClasses = [readString(props, "class"), readString(props, "className")];
|
|
623
|
+
setAttribute(root, "class", [...classes(), ...userClasses].filter(Boolean).join(" "));
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
__name(bindClassList, "bindClassList");
|
|
627
|
+
function bindCommonAttributes(root, props, skip) {
|
|
628
|
+
const ignored = /* @__PURE__ */ new Set([...skip, "class", "className", "style", "children"]);
|
|
629
|
+
effect(() => {
|
|
630
|
+
for (const name of Object.keys(props)) {
|
|
631
|
+
if (ignored.has(name) || name.startsWith("on")) continue;
|
|
632
|
+
if (name !== "id" && name !== "title" && name !== "role" && name !== "tabIndex" && !name.startsWith("aria-") && !name.startsWith("data-")) continue;
|
|
633
|
+
const value = Reflect.get(props, name);
|
|
634
|
+
if (value === void 0 || value === null || value === false) removeAttribute(root, normalizeAttributeName(name));
|
|
635
|
+
else setAttribute(root, normalizeAttributeName(name), String(value));
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
__name(bindCommonAttributes, "bindCommonAttributes");
|
|
640
|
+
function bindText2(node, read) {
|
|
641
|
+
effect(() => setTextContent(node, String(read() ?? "")));
|
|
642
|
+
}
|
|
643
|
+
__name(bindText2, "bindText");
|
|
644
|
+
function resolveSlot(value) {
|
|
645
|
+
const resolved = typeof value === "function" ? value() : value;
|
|
646
|
+
if (resolved === void 0 || resolved === null) return null;
|
|
647
|
+
if (typeof resolved === "string" || typeof resolved === "number") return createText(String(resolved));
|
|
648
|
+
if (Array.isArray(resolved)) {
|
|
649
|
+
return createFragment((parent, anchor) => {
|
|
650
|
+
for (const child of resolved) {
|
|
651
|
+
const node = resolveSlot(child);
|
|
652
|
+
if (node) insertBefore(parent, node, anchor);
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
return resolved;
|
|
657
|
+
}
|
|
658
|
+
__name(resolveSlot, "resolveSlot");
|
|
659
|
+
function createDefaultColumnSettings(columns, visibleColumnIds) {
|
|
660
|
+
const columnOrder = columns.map((column) => column.id);
|
|
661
|
+
const requested = new Set(visibleColumnIds ?? columns.filter((column) => column.visible !== false).map((column) => column.id));
|
|
662
|
+
const visible = columnOrder.filter((id) => requested.has(id) && columns.some((column) => column.id === id && column.visible !== false));
|
|
663
|
+
if (visible.length === 0) {
|
|
664
|
+
const fallback = columns.find((column) => column.visible !== false);
|
|
665
|
+
if (fallback) visible.push(fallback.id);
|
|
666
|
+
}
|
|
667
|
+
return { visibleColumnIds: visible, columnOrder, columnWidths: {} };
|
|
668
|
+
}
|
|
669
|
+
__name(createDefaultColumnSettings, "createDefaultColumnSettings");
|
|
670
|
+
function normalizeColumnSettings(columns, settings, visibleColumnIds) {
|
|
671
|
+
const fallback = createDefaultColumnSettings(columns, visibleColumnIds);
|
|
672
|
+
const knownIds = new Set(fallback.columnOrder);
|
|
673
|
+
const configuredOrder = Array.isArray(settings?.columnOrder) ? settings.columnOrder : void 0;
|
|
674
|
+
const order = uniqueKnownIds(configuredOrder, knownIds);
|
|
675
|
+
for (const id of fallback.columnOrder) {
|
|
676
|
+
if (!order.includes(id)) order.push(id);
|
|
677
|
+
}
|
|
678
|
+
const configuredVisible = Array.isArray(settings?.visibleColumnIds) ? settings.visibleColumnIds : void 0;
|
|
679
|
+
const requestedVisible = new Set(configuredVisible ?? fallback.visibleColumnIds);
|
|
680
|
+
const visible = order.filter((id) => requestedVisible.has(id) && columns.some((column) => column.id === id && column.visible !== false));
|
|
681
|
+
if (visible.length === 0) {
|
|
682
|
+
const fallbackVisible = order.find((id) => columns.some((column) => column.id === id && column.visible !== false));
|
|
683
|
+
if (fallbackVisible) visible.push(fallbackVisible);
|
|
684
|
+
}
|
|
685
|
+
const columnWidths = {};
|
|
686
|
+
const configuredWidths = settings?.columnWidths && typeof settings.columnWidths === "object" && !Array.isArray(settings.columnWidths) ? settings.columnWidths : {};
|
|
687
|
+
for (const [id, width] of Object.entries(configuredWidths)) {
|
|
688
|
+
if (knownIds.has(id) && isColumnWidthValue(width)) columnWidths[id] = width;
|
|
689
|
+
}
|
|
690
|
+
return { visibleColumnIds: visible, columnOrder: order, columnWidths };
|
|
691
|
+
}
|
|
692
|
+
__name(normalizeColumnSettings, "normalizeColumnSettings");
|
|
693
|
+
function orderColumns(columns, columnOrder) {
|
|
694
|
+
if (!columnOrder || columnOrder.length === 0) return columns;
|
|
695
|
+
const byId = new Map(columns.map((column) => [column.id, column]));
|
|
696
|
+
const ordered = [];
|
|
697
|
+
const seen = /* @__PURE__ */ new Set();
|
|
698
|
+
for (const id of columnOrder) {
|
|
699
|
+
const column = byId.get(id);
|
|
700
|
+
if (column && !seen.has(id)) {
|
|
701
|
+
ordered.push(column);
|
|
702
|
+
seen.add(id);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
for (const column of columns) {
|
|
706
|
+
if (!seen.has(column.id)) ordered.push(column);
|
|
707
|
+
}
|
|
708
|
+
return ordered;
|
|
709
|
+
}
|
|
710
|
+
__name(orderColumns, "orderColumns");
|
|
711
|
+
function isColumnWidthValue(value) {
|
|
712
|
+
return typeof value === "number" ? Number.isFinite(value) && value > 0 : typeof value === "string" && value.trim().length > 0 && !/[;{}]/u.test(value);
|
|
713
|
+
}
|
|
714
|
+
__name(isColumnWidthValue, "isColumnWidthValue");
|
|
715
|
+
function uniqueKnownIds(values, knownIds) {
|
|
716
|
+
const result = [];
|
|
717
|
+
for (const id of values ?? []) {
|
|
718
|
+
if (knownIds.has(id) && !result.includes(id)) result.push(id);
|
|
719
|
+
}
|
|
720
|
+
return result;
|
|
721
|
+
}
|
|
722
|
+
__name(uniqueKnownIds, "uniqueKnownIds");
|
|
723
|
+
function readString(props, name) {
|
|
724
|
+
const value = Reflect.get(props, name);
|
|
725
|
+
return typeof value === "string" ? value : void 0;
|
|
726
|
+
}
|
|
727
|
+
__name(readString, "readString");
|
|
728
|
+
function normalizeAttributeName(name) {
|
|
729
|
+
return name === "tabIndex" ? "tabindex" : name;
|
|
730
|
+
}
|
|
731
|
+
__name(normalizeAttributeName, "normalizeAttributeName");
|
|
732
|
+
function removeAttribute(node, name) {
|
|
733
|
+
node.removeAttribute(name);
|
|
734
|
+
}
|
|
735
|
+
__name(removeAttribute, "removeAttribute");
|
|
736
|
+
|
|
737
|
+
// packages/table/src/column-settings.ts
|
|
738
|
+
function KitColumnSettings(props = {}) {
|
|
739
|
+
const root = createElement("details");
|
|
740
|
+
const summary = createElement("summary");
|
|
741
|
+
const panel = createElement("div");
|
|
742
|
+
const columns = readColumns(props);
|
|
743
|
+
const internalSettings = state(untrack(() => initialSettings(props, columns)));
|
|
744
|
+
const panelOpen = state(false);
|
|
745
|
+
untrack(() => restoreSettings(props, columns, internalSettings));
|
|
746
|
+
effect(() => {
|
|
747
|
+
currentSettings(props, internalSettings, columns);
|
|
748
|
+
if (panelOpen.value) setProperty(root, "open", true);
|
|
749
|
+
});
|
|
750
|
+
bindClassList(root, props, () => ["vobs-column-settings"]);
|
|
751
|
+
bindCommonAttributes(root, props, [
|
|
752
|
+
"columns",
|
|
753
|
+
"settings",
|
|
754
|
+
"persistence",
|
|
755
|
+
"visibleColumnIds",
|
|
756
|
+
"trigger",
|
|
757
|
+
"label",
|
|
758
|
+
"closeLabel",
|
|
759
|
+
"resetLabel",
|
|
760
|
+
"onChange",
|
|
761
|
+
"onSettingsChange",
|
|
762
|
+
"onReset",
|
|
763
|
+
"onPersistenceError"
|
|
764
|
+
]);
|
|
765
|
+
setAttribute(summary, "class", "vobs-column-settings__trigger");
|
|
766
|
+
setAttribute(panel, "class", "vobs-column-settings__panel");
|
|
767
|
+
setAttribute(panel, "role", "group");
|
|
768
|
+
addEventListener(summary, "click", (event) => {
|
|
769
|
+
event.preventDefault();
|
|
770
|
+
panelOpen.value = !root.open;
|
|
771
|
+
setProperty(root, "open", panelOpen.value);
|
|
772
|
+
});
|
|
773
|
+
if (hasProp(props, "trigger")) {
|
|
774
|
+
insertDynamic(summary, null, () => resolveSlot(readProp(props, "trigger", void 0)));
|
|
775
|
+
} else {
|
|
776
|
+
const label = createText("");
|
|
777
|
+
bindText2(label, () => readProp(props, "label", "Columns"));
|
|
778
|
+
insertBefore(summary, label, null);
|
|
779
|
+
}
|
|
780
|
+
insertDynamic(panel, null, () => createColumnOptions(props, internalSettings, columns, root));
|
|
781
|
+
insertBefore(root, summary, null);
|
|
782
|
+
insertBefore(root, panel, null);
|
|
783
|
+
return root;
|
|
784
|
+
}
|
|
785
|
+
__name(KitColumnSettings, "KitColumnSettings");
|
|
786
|
+
function createColumnOptions(props, internalSettings, columns, root) {
|
|
787
|
+
const settings = currentSettings(props, internalSettings, columns);
|
|
788
|
+
return createFragment((parent, anchor) => {
|
|
789
|
+
const reset = createElement("button");
|
|
790
|
+
const resetLabel = createText("");
|
|
791
|
+
setAttribute(reset, "type", "button");
|
|
792
|
+
setAttribute(reset, "class", "vobs-column-settings__reset");
|
|
793
|
+
bindText2(resetLabel, () => readProp(props, "resetLabel", "Reset columns"));
|
|
794
|
+
addEventListener(reset, "click", (event) => {
|
|
795
|
+
event.preventDefault();
|
|
796
|
+
event.stopPropagation();
|
|
797
|
+
resetSettings(props, internalSettings, columns, root);
|
|
798
|
+
});
|
|
799
|
+
insertBefore(reset, resetLabel, null);
|
|
800
|
+
insertBefore(parent, reset, anchor);
|
|
801
|
+
const visibility = createElement("div");
|
|
802
|
+
setAttribute(visibility, "class", "vobs-column-settings__visibility");
|
|
803
|
+
for (const column of columns) {
|
|
804
|
+
insertBefore(visibility, createVisibilityOption(props, internalSettings, columns, column), null);
|
|
805
|
+
}
|
|
806
|
+
insertBefore(parent, visibility, anchor);
|
|
807
|
+
const layout = createElement("div");
|
|
808
|
+
setAttribute(layout, "class", "vobs-column-settings__layout");
|
|
809
|
+
const ordered = orderColumns(columns, settings.columnOrder);
|
|
810
|
+
for (const [index, column] of ordered.entries()) {
|
|
811
|
+
insertBefore(layout, createLayoutOption(
|
|
812
|
+
props,
|
|
813
|
+
internalSettings,
|
|
814
|
+
columns,
|
|
815
|
+
column,
|
|
816
|
+
root,
|
|
817
|
+
index === 0,
|
|
818
|
+
index === ordered.length - 1
|
|
819
|
+
), null);
|
|
820
|
+
}
|
|
821
|
+
insertBefore(parent, layout, anchor);
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
__name(createColumnOptions, "createColumnOptions");
|
|
825
|
+
function createVisibilityOption(props, internalSettings, columns, column) {
|
|
826
|
+
const option = createElement("label");
|
|
827
|
+
const input = createElement("input");
|
|
828
|
+
const text = createText(column.label);
|
|
829
|
+
const settings = currentSettings(props, internalSettings, columns);
|
|
830
|
+
setAttribute(option, "class", "vobs-column-settings__option");
|
|
831
|
+
setAttribute(input, "type", "checkbox");
|
|
832
|
+
setProperty(input, "checked", settings.visibleColumnIds.includes(column.id));
|
|
833
|
+
setProperty(input, "disabled", settings.visibleColumnIds.length <= 1 && input.checked);
|
|
834
|
+
addEventListener(input, "change", () => {
|
|
835
|
+
const current = currentSettings(props, internalSettings, columns);
|
|
836
|
+
const visible = new Set(current.visibleColumnIds);
|
|
837
|
+
if (input.checked) visible.add(column.id);
|
|
838
|
+
else if (visible.size > 1) visible.delete(column.id);
|
|
839
|
+
const ordered = orderColumns(columns, current.columnOrder);
|
|
840
|
+
const nextIds = ordered.filter((candidate) => visible.has(candidate.id)).map((candidate) => candidate.id);
|
|
841
|
+
commitSettings(props, internalSettings, columns, {
|
|
842
|
+
...current,
|
|
843
|
+
visibleColumnIds: nextIds
|
|
844
|
+
});
|
|
845
|
+
});
|
|
846
|
+
insertBefore(option, input, null);
|
|
847
|
+
insertBefore(option, text, null);
|
|
848
|
+
return option;
|
|
849
|
+
}
|
|
850
|
+
__name(createVisibilityOption, "createVisibilityOption");
|
|
851
|
+
function createLayoutOption(props, internalSettings, columns, column, root, isFirst, isLast) {
|
|
852
|
+
const option = createElement("div");
|
|
853
|
+
const label = createElement("span");
|
|
854
|
+
const controls = createElement("div");
|
|
855
|
+
const up = createMoveButton("up", column.label, isFirst);
|
|
856
|
+
const down = createMoveButton("down", column.label, isLast);
|
|
857
|
+
const width = createElement("input");
|
|
858
|
+
const current = currentSettings(props, internalSettings, columns);
|
|
859
|
+
const configuredWidth = current.columnWidths[column.id] ?? column.width;
|
|
860
|
+
setAttribute(option, "class", "vobs-column-settings__layout-option");
|
|
861
|
+
setAttribute(option, "data-column-id", column.id);
|
|
862
|
+
setAttribute(label, "class", "vobs-column-settings__layout-label");
|
|
863
|
+
setProperty(label, "textContent", column.label);
|
|
864
|
+
setAttribute(controls, "class", "vobs-column-settings__layout-controls");
|
|
865
|
+
setAttribute(width, "type", "text");
|
|
866
|
+
setAttribute(width, "class", "vobs-column-settings__width");
|
|
867
|
+
setAttribute(width, "placeholder", "auto");
|
|
868
|
+
setAttribute(width, "aria-label", `${column.label} width`);
|
|
869
|
+
setProperty(width, "value", displayWidth(configuredWidth));
|
|
870
|
+
addEventListener(up, "click", (event) => {
|
|
871
|
+
event.preventDefault();
|
|
872
|
+
event.stopPropagation();
|
|
873
|
+
moveColumn(props, internalSettings, columns, column.id, -1, root);
|
|
874
|
+
});
|
|
875
|
+
addEventListener(down, "click", (event) => {
|
|
876
|
+
event.preventDefault();
|
|
877
|
+
event.stopPropagation();
|
|
878
|
+
moveColumn(props, internalSettings, columns, column.id, 1, root);
|
|
879
|
+
});
|
|
880
|
+
const commitWidth = /* @__PURE__ */ __name(() => {
|
|
881
|
+
const value = width.value.trim();
|
|
882
|
+
const currentSettingsValue = currentSettings(props, internalSettings, columns);
|
|
883
|
+
const currentWidth = displayWidth(currentSettingsValue.columnWidths[column.id] ?? column.width);
|
|
884
|
+
if (value === currentWidth) return;
|
|
885
|
+
if (value && !isColumnWidthValue(value)) {
|
|
886
|
+
width.value = currentWidth;
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
const nextWidths = { ...currentSettingsValue.columnWidths };
|
|
890
|
+
if (value) nextWidths[column.id] = value;
|
|
891
|
+
else delete nextWidths[column.id];
|
|
892
|
+
commitSettings(props, internalSettings, columns, {
|
|
893
|
+
...currentSettingsValue,
|
|
894
|
+
columnWidths: nextWidths
|
|
895
|
+
});
|
|
896
|
+
}, "commitWidth");
|
|
897
|
+
addEventListener(width, "change", commitWidth);
|
|
898
|
+
addEventListener(width, "blur", commitWidth);
|
|
899
|
+
addEventListener(width, "keydown", (event) => {
|
|
900
|
+
if (event.key !== "Enter") return;
|
|
901
|
+
event.preventDefault();
|
|
902
|
+
commitWidth();
|
|
903
|
+
});
|
|
904
|
+
insertBefore(controls, up, null);
|
|
905
|
+
insertBefore(controls, down, null);
|
|
906
|
+
insertBefore(controls, width, null);
|
|
907
|
+
insertBefore(option, label, null);
|
|
908
|
+
insertBefore(option, controls, null);
|
|
909
|
+
return option;
|
|
910
|
+
}
|
|
911
|
+
__name(createLayoutOption, "createLayoutOption");
|
|
912
|
+
function createMoveButton(direction, columnLabel, disabled) {
|
|
913
|
+
const button = createElement("button");
|
|
914
|
+
setAttribute(button, "type", "button");
|
|
915
|
+
setAttribute(button, "class", `vobs-column-settings__move vobs-column-settings__move--${direction}`);
|
|
916
|
+
setAttribute(button, "aria-label", `Move ${columnLabel} ${direction}`);
|
|
917
|
+
setAttribute(button, "title", `Move ${columnLabel} ${direction}`);
|
|
918
|
+
setProperty(button, "disabled", disabled);
|
|
919
|
+
insertBefore(button, createText(direction === "up" ? "\u2191" : "\u2193"), null);
|
|
920
|
+
return button;
|
|
921
|
+
}
|
|
922
|
+
__name(createMoveButton, "createMoveButton");
|
|
923
|
+
function moveColumn(props, internalSettings, columns, columnId, offset, root) {
|
|
924
|
+
const current = currentSettings(props, internalSettings, columns);
|
|
925
|
+
const order = [...current.columnOrder];
|
|
926
|
+
const index = order.indexOf(columnId);
|
|
927
|
+
const target = index + offset;
|
|
928
|
+
if (index < 0 || target < 0 || target >= order.length) return;
|
|
929
|
+
[order[index], order[target]] = [order[target], order[index]];
|
|
930
|
+
commitSettings(props, internalSettings, columns, { ...current, columnOrder: order });
|
|
931
|
+
reopenPanel(root);
|
|
932
|
+
}
|
|
933
|
+
__name(moveColumn, "moveColumn");
|
|
934
|
+
function resetSettings(props, internalSettings, columns, root) {
|
|
935
|
+
const persistence = readProp(props, "persistence", void 0);
|
|
936
|
+
let cleared = false;
|
|
937
|
+
if (persistence?.reset) {
|
|
938
|
+
try {
|
|
939
|
+
persistence.reset();
|
|
940
|
+
cleared = true;
|
|
941
|
+
} catch (error) {
|
|
942
|
+
reportPersistenceError(props, error);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
const defaults = createDefaultColumnSettings(columns);
|
|
946
|
+
commitSettings(props, internalSettings, columns, defaults, !persistence || !cleared);
|
|
947
|
+
reopenPanel(root);
|
|
948
|
+
readProp(props, "onReset", void 0)?.();
|
|
949
|
+
}
|
|
950
|
+
__name(resetSettings, "resetSettings");
|
|
951
|
+
function commitSettings(props, internalSettings, columns, settings, persist = true) {
|
|
952
|
+
const normalized = normalizeColumnSettings(columns, settings);
|
|
953
|
+
if (!isControlled(props)) internalSettings.value = normalized;
|
|
954
|
+
if (persist) saveSettings(props, normalized);
|
|
955
|
+
readProp(props, "onSettingsChange", void 0)?.(normalized);
|
|
956
|
+
readProp(props, "onChange", void 0)?.(normalized.visibleColumnIds);
|
|
957
|
+
}
|
|
958
|
+
__name(commitSettings, "commitSettings");
|
|
959
|
+
function initialSettings(props, columns) {
|
|
960
|
+
const settings = readProp(props, "settings", void 0);
|
|
961
|
+
if (settings !== void 0) return normalizeColumnSettings(columns, settings);
|
|
962
|
+
return normalizeColumnSettings(
|
|
963
|
+
columns,
|
|
964
|
+
void 0,
|
|
965
|
+
readProp(props, "visibleColumnIds", void 0)
|
|
966
|
+
);
|
|
967
|
+
}
|
|
968
|
+
__name(initialSettings, "initialSettings");
|
|
969
|
+
function restoreSettings(props, columns, internalSettings) {
|
|
970
|
+
if (isControlled(props)) return;
|
|
971
|
+
const persistence = readProp(props, "persistence", void 0);
|
|
972
|
+
if (!persistence) return;
|
|
973
|
+
try {
|
|
974
|
+
const stored = persistence.load();
|
|
975
|
+
if (stored) internalSettings.value = normalizeColumnSettings(columns, stored);
|
|
976
|
+
} catch (error) {
|
|
977
|
+
reportPersistenceError(props, error);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
__name(restoreSettings, "restoreSettings");
|
|
981
|
+
function currentSettings(props, internalSettings, columns) {
|
|
982
|
+
const external = readProp(props, "settings", void 0);
|
|
983
|
+
if (external !== void 0) return normalizeColumnSettings(columns, external);
|
|
984
|
+
const visibleColumnIds = readProp(props, "visibleColumnIds", void 0);
|
|
985
|
+
if (visibleColumnIds !== void 0) {
|
|
986
|
+
return normalizeColumnSettings(columns, {
|
|
987
|
+
...internalSettings.value,
|
|
988
|
+
visibleColumnIds
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
return normalizeColumnSettings(columns, internalSettings.value);
|
|
992
|
+
}
|
|
993
|
+
__name(currentSettings, "currentSettings");
|
|
994
|
+
function saveSettings(props, settings) {
|
|
995
|
+
const persistence = readProp(props, "persistence", void 0);
|
|
996
|
+
if (!persistence) return;
|
|
997
|
+
try {
|
|
998
|
+
persistence.save(settings);
|
|
999
|
+
} catch (error) {
|
|
1000
|
+
reportPersistenceError(props, error);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
__name(saveSettings, "saveSettings");
|
|
1004
|
+
function readColumns(props) {
|
|
1005
|
+
return readProp(props, "columns", []);
|
|
1006
|
+
}
|
|
1007
|
+
__name(readColumns, "readColumns");
|
|
1008
|
+
function displayWidth(value) {
|
|
1009
|
+
if (value === void 0) return "";
|
|
1010
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
1011
|
+
}
|
|
1012
|
+
__name(displayWidth, "displayWidth");
|
|
1013
|
+
function isControlled(props) {
|
|
1014
|
+
return isProvided(props, "settings") || isProvided(props, "visibleColumnIds");
|
|
1015
|
+
}
|
|
1016
|
+
__name(isControlled, "isControlled");
|
|
1017
|
+
function isProvided(props, name) {
|
|
1018
|
+
return hasProp(props, name) && Reflect.get(props, name) !== void 0;
|
|
1019
|
+
}
|
|
1020
|
+
__name(isProvided, "isProvided");
|
|
1021
|
+
function reportPersistenceError(props, error) {
|
|
1022
|
+
readProp(props, "onPersistenceError", void 0)?.(error);
|
|
1023
|
+
}
|
|
1024
|
+
__name(reportPersistenceError, "reportPersistenceError");
|
|
1025
|
+
function reopenPanel(root) {
|
|
1026
|
+
setTimeout(() => {
|
|
1027
|
+
setProperty(root, "open", true);
|
|
1028
|
+
}, 0);
|
|
1029
|
+
}
|
|
1030
|
+
__name(reopenPanel, "reopenPanel");
|
|
1031
|
+
|
|
1032
|
+
export { KitColumnSettings };
|
|
1033
|
+
//# sourceMappingURL=column-settings.js.map
|
|
1034
|
+
//# sourceMappingURL=column-settings.js.map
|