@svar-ui/kanban-provider 2.6.0 → 2.7.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/index.d.mts +123 -15
- package/dist/index.mjs +89 -5
- package/package.json +8 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
//#region ../../node_modules/.pnpm/@svar-ui+lib-state@1.9.6/node_modules/@svar-ui/lib-state/dist/index.d.ts
|
|
2
|
-
interface IEventConfig {
|
|
2
|
+
interface IEventConfig$1 {
|
|
3
3
|
intercept?: boolean;
|
|
4
4
|
tag?: number | string | symbol;
|
|
5
5
|
}
|
|
6
|
-
interface IEventBus<T> {
|
|
6
|
+
interface IEventBus$1<T> {
|
|
7
7
|
exec(name: keyof T, ev: T[keyof T]): Promise<T[keyof T]>;
|
|
8
|
-
setNext(next: IEventBus<T>): IEventBus<T>;
|
|
8
|
+
setNext(next: IEventBus$1<T>): IEventBus$1<T>;
|
|
9
9
|
}
|
|
10
|
-
declare class EventBus<T, A extends keyof T> {
|
|
10
|
+
declare class EventBus$1<T, A extends keyof T> {
|
|
11
11
|
private _handlers;
|
|
12
|
-
protected _nextHandler: IEventBus<T>;
|
|
12
|
+
protected _nextHandler: IEventBus$1<T>;
|
|
13
13
|
protected _tag: WeakMap<{
|
|
14
14
|
(v: T[A]): void | boolean | Promise<boolean>;
|
|
15
15
|
}, number | string | symbol>;
|
|
16
16
|
constructor();
|
|
17
|
-
on(name: A, handler: (v: T[A]) => void | boolean | Promise<boolean>, config?: IEventConfig): void;
|
|
18
|
-
intercept(name: A, handler: (v: T[A]) => void | boolean | Promise<boolean>, config?: IEventConfig): void;
|
|
17
|
+
on(name: A, handler: (v: T[A]) => void | boolean | Promise<boolean>, config?: IEventConfig$1): void;
|
|
18
|
+
intercept(name: A, handler: (v: T[A]) => void | boolean | Promise<boolean>, config?: IEventConfig$1): void;
|
|
19
19
|
detach(tag: number | string | symbol): void;
|
|
20
20
|
exec(name: A, ev: T[A]): Promise<T[A]>;
|
|
21
|
-
setNext(next: IEventBus<T>): IEventBus<T>;
|
|
21
|
+
setNext(next: IEventBus$1<T>): IEventBus$1<T>;
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region ../../node_modules/.pnpm/@svar-ui+lib-data-provider@1.7.2/node_modules/@svar-ui/lib-data-provider/dist/index.d.ts
|
|
@@ -27,7 +27,7 @@ type Action = {
|
|
|
27
27
|
debounce?: number;
|
|
28
28
|
handler: Handler;
|
|
29
29
|
};
|
|
30
|
-
type ActionMap<T> = { [P in keyof T]?: Action };
|
|
30
|
+
type ActionMap<T> = { [P in keyof T]?: Action; };
|
|
31
31
|
type DataObj = {
|
|
32
32
|
[key: string]: any;
|
|
33
33
|
};
|
|
@@ -41,6 +41,9 @@ type HandlerConfig = {
|
|
|
41
41
|
ignoreID?: boolean;
|
|
42
42
|
handler: Handler;
|
|
43
43
|
};
|
|
44
|
+
type DataProviderConfig = {
|
|
45
|
+
[key: string]: HandlerConfig | Handler;
|
|
46
|
+
};
|
|
44
47
|
type RestDataProviderConfig = {
|
|
45
48
|
batchURL?: string;
|
|
46
49
|
};
|
|
@@ -69,7 +72,7 @@ declare class ActionQueue {
|
|
|
69
72
|
execQueue(): void;
|
|
70
73
|
private _finishQueue;
|
|
71
74
|
}
|
|
72
|
-
declare class Rest<T> extends EventBus<T, keyof T> {
|
|
75
|
+
declare class Rest<T> extends EventBus$1<T, keyof T> {
|
|
73
76
|
private _queue;
|
|
74
77
|
private _customHeaders;
|
|
75
78
|
protected _url: string;
|
|
@@ -85,21 +88,47 @@ declare class Rest<T> extends EventBus<T, keyof T> {
|
|
|
85
88
|
protected toPayload(obj: object): string;
|
|
86
89
|
protected sendRequest<T>(url: string, method: string, data?: string | object, customHeaders?: Record<string, string>): Promise<T>;
|
|
87
90
|
}
|
|
91
|
+
declare class DataProvider<T> extends EventBus$1<T, keyof T> {
|
|
92
|
+
private _queue;
|
|
93
|
+
constructor(handlers: DataProviderConfig);
|
|
94
|
+
getQueue(): ActionQueue;
|
|
95
|
+
}
|
|
88
96
|
//#endregion
|
|
89
97
|
//#region ../store/dist/index.d.mts
|
|
90
98
|
type CardID = string | number;
|
|
91
99
|
type ColumnID = string | number;
|
|
100
|
+
type SwimlaneID = string | number;
|
|
101
|
+
type SwimlaneConfig = {
|
|
102
|
+
id: SwimlaneID;
|
|
103
|
+
label: string;
|
|
104
|
+
collapsed?: boolean;
|
|
105
|
+
css?: string;
|
|
106
|
+
metadata?: Record<string, any>;
|
|
107
|
+
};
|
|
92
108
|
type KanbanCard = {
|
|
93
109
|
id: CardID;
|
|
94
110
|
[key: string]: any;
|
|
95
111
|
};
|
|
112
|
+
type ColumnSummaryConfig<T = any> = {
|
|
113
|
+
id: string;
|
|
114
|
+
calculate: (cards: readonly KanbanCard[], column: ColumnConfig) => T;
|
|
115
|
+
format?: (value: T, column: ColumnConfig) => string;
|
|
116
|
+
css?: (value: T, column: ColumnConfig) => string;
|
|
117
|
+
};
|
|
118
|
+
/** Column dimensions are outer-box CSS pixels. */
|
|
96
119
|
type ColumnConfig = {
|
|
120
|
+
[key: string]: any;
|
|
121
|
+
summaries?: ColumnSummaryConfig[];
|
|
97
122
|
id: ColumnID;
|
|
98
123
|
label: string;
|
|
99
124
|
css?: string;
|
|
100
125
|
metadata?: Record<string, any>;
|
|
101
|
-
|
|
126
|
+
width?: number;
|
|
127
|
+
cardWidth?: number;
|
|
128
|
+
cardHeight?: number;
|
|
102
129
|
addCard?: boolean;
|
|
130
|
+
/** Shows the header menu button for an outer `ContextMenu target="column"` (default `false`). */
|
|
131
|
+
menu?: boolean;
|
|
103
132
|
collapsed?: boolean;
|
|
104
133
|
};
|
|
105
134
|
type SortCriterion = ((a: KanbanCard, b: KanbanCard) => number) | {
|
|
@@ -142,10 +171,37 @@ type ExportHelpers = {
|
|
|
142
171
|
serialize: (value: any) => string;
|
|
143
172
|
};
|
|
144
173
|
interface StoreActions {
|
|
174
|
+
["add-column"]: {
|
|
175
|
+
column: Partial<ColumnConfig>;
|
|
176
|
+
id?: ColumnID;
|
|
177
|
+
before?: ColumnID | null;
|
|
178
|
+
};
|
|
179
|
+
["delete-column"]: {
|
|
180
|
+
id: ColumnID;
|
|
181
|
+
};
|
|
182
|
+
["move-column"]: {
|
|
183
|
+
id: ColumnID;
|
|
184
|
+
before?: ColumnID | null;
|
|
185
|
+
};
|
|
186
|
+
["add-swimlane"]: {
|
|
187
|
+
swimlane: Partial<SwimlaneConfig>;
|
|
188
|
+
id?: SwimlaneID;
|
|
189
|
+
before?: SwimlaneID | null;
|
|
190
|
+
};
|
|
191
|
+
["delete-swimlane"]: {
|
|
192
|
+
id: SwimlaneID;
|
|
193
|
+
};
|
|
194
|
+
["move-swimlane"]: {
|
|
195
|
+
id: SwimlaneID;
|
|
196
|
+
before?: SwimlaneID | null;
|
|
197
|
+
};
|
|
145
198
|
["add-card"]: {
|
|
146
199
|
card: Partial<KanbanCard>;
|
|
147
200
|
edit?: boolean;
|
|
148
201
|
id?: CardID;
|
|
202
|
+
/** Insert before this card; `null` appends. Wins over `after`. */
|
|
203
|
+
before?: CardID | null;
|
|
204
|
+
/** Convenience hint, normalized to `before` by the handler. */
|
|
149
205
|
after?: CardID;
|
|
150
206
|
};
|
|
151
207
|
["update-card"]: {
|
|
@@ -155,11 +211,17 @@ interface StoreActions {
|
|
|
155
211
|
["move-card"]: {
|
|
156
212
|
id: CardID;
|
|
157
213
|
column?: ColumnID;
|
|
214
|
+
swimlane?: SwimlaneID;
|
|
158
215
|
before?: CardID | null;
|
|
159
216
|
};
|
|
217
|
+
["update-swimlane"]: {
|
|
218
|
+
id: SwimlaneID;
|
|
219
|
+
swimlane: Partial<SwimlaneConfig>;
|
|
220
|
+
};
|
|
160
221
|
["update-column"]: {
|
|
161
222
|
id: ColumnID;
|
|
162
223
|
column: Partial<ColumnConfig>;
|
|
224
|
+
skipProvider?: boolean;
|
|
163
225
|
};
|
|
164
226
|
["duplicate-card"]: {
|
|
165
227
|
id: CardID;
|
|
@@ -189,17 +251,63 @@ interface StoreActions {
|
|
|
189
251
|
["export-data"]: ExportConfig;
|
|
190
252
|
["undo"]: Record<string, never>;
|
|
191
253
|
["redo"]: Record<string, never>;
|
|
192
|
-
}
|
|
193
|
-
//#region src/kanban_store.d.ts
|
|
254
|
+
}
|
|
194
255
|
//#endregion
|
|
195
256
|
//#region src/RestDataProvider.d.ts
|
|
196
|
-
type TMethodsConfig = Pick<StoreActions, "add-card" | "update-card" | "delete-card" | "move-card" | "duplicate-card">;
|
|
257
|
+
type TMethodsConfig = Pick<StoreActions, "add-card" | "update-card" | "delete-card" | "move-card" | "duplicate-card" | "add-column" | "update-column" | "move-column" | "delete-column" | "add-swimlane" | "update-swimlane" | "move-swimlane" | "delete-swimlane">;
|
|
258
|
+
export declare const CARDS = 1;
|
|
259
|
+
export declare const COLUMNS = 2;
|
|
260
|
+
export declare const SWIMLANES = 3;
|
|
261
|
+
type TActionMap = { [P in keyof TMethodsConfig]?: ActionMap<TMethodsConfig>[P] & {
|
|
262
|
+
kind?: number;
|
|
263
|
+
}; };
|
|
197
264
|
declare class RestDataProvider extends Rest<TMethodsConfig> {
|
|
198
|
-
getHandlers():
|
|
265
|
+
getHandlers(): TActionMap;
|
|
199
266
|
getData(): Promise<KanbanCard[]>;
|
|
200
267
|
parseCards(data: KanbanCard[]): KanbanCard[];
|
|
201
268
|
protected toPayload(obj: object): string;
|
|
202
269
|
formatDate(date: Date): string;
|
|
203
270
|
}
|
|
204
271
|
//#endregion
|
|
272
|
+
//#region ../../node_modules/.pnpm/@svar-ui+lib-state@1.9.7/node_modules/@svar-ui/lib-state/dist/index.d.ts
|
|
273
|
+
interface IEventConfig {
|
|
274
|
+
intercept?: boolean;
|
|
275
|
+
tag?: number | string | symbol;
|
|
276
|
+
}
|
|
277
|
+
interface IEventBus<T> {
|
|
278
|
+
exec(name: keyof T, ev: T[keyof T]): Promise<T[keyof T]>;
|
|
279
|
+
setNext(next: IEventBus<T>): IEventBus<T>;
|
|
280
|
+
}
|
|
281
|
+
declare class EventBus<T, A extends keyof T> {
|
|
282
|
+
private _handlers;
|
|
283
|
+
protected _nextHandler: IEventBus<T>;
|
|
284
|
+
protected _tag: WeakMap<{
|
|
285
|
+
(v: T[A]): void | boolean | Promise<boolean>;
|
|
286
|
+
}, number | string | symbol>;
|
|
287
|
+
constructor();
|
|
288
|
+
on(name: A, handler: (v: T[A]) => void | boolean | Promise<boolean>, config?: IEventConfig): void;
|
|
289
|
+
intercept(name: A, handler: (v: T[A]) => void | boolean | Promise<boolean>, config?: IEventConfig): void;
|
|
290
|
+
detach(tag: number | string | symbol): void;
|
|
291
|
+
exec(name: A, ev: T[A]): Promise<T[A]>;
|
|
292
|
+
setNext(next: IEventBus<T>): IEventBus<T>;
|
|
293
|
+
}
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/EventBridge.d.ts
|
|
296
|
+
type EventHandler = (data: any) => void | boolean;
|
|
297
|
+
type EventConfigOption = EventHandler | number;
|
|
298
|
+
declare class EventBridge<E, T> {
|
|
299
|
+
private clientId;
|
|
300
|
+
private api;
|
|
301
|
+
private provider;
|
|
302
|
+
private es;
|
|
303
|
+
constructor(url: string, clientId: string, api: Pick<EventBus<E, keyof E>, "exec">, provider: Pick<DataProvider<T>, "getQueue">, events: Record<string, EventConfigOption>);
|
|
304
|
+
close(): void;
|
|
305
|
+
protected resolveId(id: number | string, kind: number): string | number;
|
|
306
|
+
protected correctId(data: any, kind: number): any;
|
|
307
|
+
private _eventHandler;
|
|
308
|
+
}
|
|
309
|
+
export declare class KanbanEventBridge extends EventBridge<any, any> {
|
|
310
|
+
protected correctId(data: any, kind: number): any;
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
205
313
|
export { RestDataProvider };
|
package/dist/index.mjs
CHANGED
|
@@ -275,14 +275,47 @@ var Rest = class extends EventBus {
|
|
|
275
275
|
};
|
|
276
276
|
//#endregion
|
|
277
277
|
//#region src/RestDataProvider.ts
|
|
278
|
+
const CARDS = 1;
|
|
279
|
+
const COLUMNS = 2;
|
|
280
|
+
const SWIMLANES = 3;
|
|
278
281
|
var RestDataProvider = class extends Rest {
|
|
279
282
|
getHandlers() {
|
|
280
283
|
return {
|
|
284
|
+
"add-column": {
|
|
285
|
+
ignoreID: true,
|
|
286
|
+
kind: 2,
|
|
287
|
+
handler: async (data) => this.send("columns", "POST", {
|
|
288
|
+
...data.column,
|
|
289
|
+
before: data.before == null || data.before === data.id ? null : await this.getQueue().waitId(data.before)
|
|
290
|
+
})
|
|
291
|
+
},
|
|
292
|
+
"update-column": {
|
|
293
|
+
debounce: 500,
|
|
294
|
+
handler: async (data) => this.send(`columns/${encodeURIComponent(data.id)}`, "PUT", data.column)
|
|
295
|
+
},
|
|
296
|
+
"move-column": { handler: async (data) => this.send(`columns/${encodeURIComponent(data.id)}/move`, "PUT", { before: data.before ?? null }) },
|
|
297
|
+
"delete-column": { handler: async (data) => this.send(`columns/${encodeURIComponent(data.id)}`, "DELETE") },
|
|
298
|
+
"add-swimlane": {
|
|
299
|
+
ignoreID: true,
|
|
300
|
+
kind: 3,
|
|
301
|
+
handler: async (data) => this.send("swimlanes", "POST", {
|
|
302
|
+
...data.swimlane,
|
|
303
|
+
before: data.before == null || data.before === data.id ? null : await this.getQueue().waitId(data.before)
|
|
304
|
+
})
|
|
305
|
+
},
|
|
306
|
+
"update-swimlane": {
|
|
307
|
+
debounce: 500,
|
|
308
|
+
handler: async (data) => this.send(`swimlanes/${encodeURIComponent(data.id)}`, "PUT", data.swimlane)
|
|
309
|
+
},
|
|
310
|
+
"move-swimlane": { handler: async (data) => this.send(`swimlanes/${encodeURIComponent(data.id)}/move`, "PUT", { before: data.before ?? null }) },
|
|
311
|
+
"delete-swimlane": { handler: async (data) => this.send(`swimlanes/${encodeURIComponent(data.id)}`, "DELETE") },
|
|
281
312
|
"add-card": {
|
|
282
313
|
ignoreID: true,
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
314
|
+
kind: 1,
|
|
315
|
+
handler: async (data) => this.send("cards", "POST", {
|
|
316
|
+
...data.card,
|
|
317
|
+
before: data.before == null || data.before === data.id ? null : await this.getQueue().waitId(data.before)
|
|
318
|
+
})
|
|
286
319
|
},
|
|
287
320
|
"update-card": {
|
|
288
321
|
debounce: 500,
|
|
@@ -295,7 +328,7 @@ var RestDataProvider = class extends Rest {
|
|
|
295
328
|
} },
|
|
296
329
|
"delete-card": { handler: async (data) => this.send(`cards/${data.id}`, "DELETE") },
|
|
297
330
|
"duplicate-card": {
|
|
298
|
-
|
|
331
|
+
kind: 1,
|
|
299
332
|
handler: async (data) => {
|
|
300
333
|
return this.send(`cards/${data.id}/duplicate`, "POST", data.card);
|
|
301
334
|
}
|
|
@@ -323,4 +356,55 @@ var RestDataProvider = class extends Rest {
|
|
|
323
356
|
}
|
|
324
357
|
};
|
|
325
358
|
//#endregion
|
|
326
|
-
|
|
359
|
+
//#region src/EventBridge.ts
|
|
360
|
+
var EventBridge = class {
|
|
361
|
+
clientId;
|
|
362
|
+
api;
|
|
363
|
+
provider;
|
|
364
|
+
es;
|
|
365
|
+
constructor(url, clientId, api, provider, events) {
|
|
366
|
+
this.clientId = clientId;
|
|
367
|
+
this.api = api;
|
|
368
|
+
this.provider = provider;
|
|
369
|
+
const es = this.es = new EventSource(url);
|
|
370
|
+
for (var key in events) es.addEventListener(key, this._eventHandler(key, events[key]));
|
|
371
|
+
}
|
|
372
|
+
close() {
|
|
373
|
+
this.es.close();
|
|
374
|
+
}
|
|
375
|
+
resolveId(id, kind) {
|
|
376
|
+
return this.provider.getQueue().resolve(id, kind);
|
|
377
|
+
}
|
|
378
|
+
correctId(data, kind) {
|
|
379
|
+
if (data[kind]) data[kind] = this.resolveId(data[kind], kind);
|
|
380
|
+
return data;
|
|
381
|
+
}
|
|
382
|
+
_eventHandler(event, handler) {
|
|
383
|
+
return (ev) => {
|
|
384
|
+
const data = JSON.parse(ev.data);
|
|
385
|
+
if (data.client === this.clientId) return;
|
|
386
|
+
let pack = { ...data.data };
|
|
387
|
+
if (typeof handler === "number") pack = this.correctId(pack, handler);
|
|
388
|
+
else if (typeof handler === "function") {
|
|
389
|
+
if (handler(pack) === false) return;
|
|
390
|
+
}
|
|
391
|
+
this.api.exec(data.op, {
|
|
392
|
+
skipProvider: true,
|
|
393
|
+
...pack
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
var KanbanEventBridge = class extends EventBridge {
|
|
399
|
+
correctId(data, kind) {
|
|
400
|
+
if (kind === 1) {
|
|
401
|
+
if (data.id) data.id = this.resolveId(data.id, kind);
|
|
402
|
+
if (data.before) data.before = this.resolveId(data.before, kind);
|
|
403
|
+
if (data.card && data.card.id) data.card.id = this.resolveId(data.card.id, kind);
|
|
404
|
+
if (data.card && typeof data.card.deadline === "string") data.card.deadline = new Date(data.card.deadline);
|
|
405
|
+
}
|
|
406
|
+
return data;
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
//#endregion
|
|
410
|
+
export { CARDS, COLUMNS, KanbanEventBridge, RestDataProvider, SWIMLANES };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svar-ui/kanban-provider",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Data provider and REST proxy for the SVAR Kanban",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -17,14 +17,18 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@svar-ui/lib-data-provider": "1.7.2",
|
|
20
|
+
"@svar-ui/lib-state": "1.9.7",
|
|
20
21
|
"@typescript/native-preview": "7.0.0-dev.20260316.1",
|
|
21
22
|
"typescript": "^5.9.3",
|
|
22
|
-
"vite-plus": "
|
|
23
|
-
"@svar-ui/kanban-store": "2.
|
|
23
|
+
"vite-plus": "1.1.0",
|
|
24
|
+
"@svar-ui/kanban-store": "2.7.0"
|
|
24
25
|
},
|
|
25
26
|
"inlinedDependencies": {
|
|
26
27
|
"@svar-ui/lib-data-provider": "1.7.2",
|
|
27
|
-
"@svar-ui/lib-state":
|
|
28
|
+
"@svar-ui/lib-state": [
|
|
29
|
+
"1.9.6",
|
|
30
|
+
"1.9.7"
|
|
31
|
+
]
|
|
28
32
|
},
|
|
29
33
|
"scripts": {
|
|
30
34
|
"build": "vp pack",
|