@svar-ui/kanban-store 2.6.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.
@@ -0,0 +1,231 @@
1
+ import { EventBus, Store, TDataConfig, TWritableCreator } from "@svar-ui/lib-state";
2
+
3
+ //#region src/cards_store.d.ts
4
+ declare class CardsStore {
5
+ private _cards;
6
+ constructor(initial?: KanbanCard[]);
7
+ getCards(): KanbanCard[];
8
+ getById(id: CardID): KanbanCard | undefined;
9
+ add(card: KanbanCard, after?: CardID): KanbanCard;
10
+ update(id: CardID, patch: Partial<KanbanCard>): KanbanCard | undefined;
11
+ upsert(card: KanbanCard): KanbanCard;
12
+ remove(id: CardID): boolean;
13
+ move(id: CardID, before?: CardID | null): boolean;
14
+ private _assertHasId;
15
+ }
16
+ //#endregion
17
+ //#region src/types.d.ts
18
+ type Brandmark = {
19
+ text: string;
20
+ link?: string;
21
+ style: string;
22
+ };
23
+ type CardID = string | number;
24
+ type ColumnID = string | number;
25
+ type ColumnDataStatus = "unknown" | "loading" | "loaded";
26
+ type ColumnDataState = {
27
+ status: ColumnDataStatus;
28
+ };
29
+ type KanbanCard = {
30
+ id: CardID;
31
+ [key: string]: any;
32
+ };
33
+ type ColumnConfig = {
34
+ id: ColumnID;
35
+ label: string;
36
+ css?: string;
37
+ metadata?: Record<string, any>;
38
+ cardLimit?: number | boolean;
39
+ addCard?: boolean;
40
+ collapsed?: boolean;
41
+ };
42
+ type ColumnView = {
43
+ id: ColumnID;
44
+ label: string;
45
+ css?: string;
46
+ metadata?: Record<string, any>;
47
+ cardLimit?: number | boolean;
48
+ addCard: boolean;
49
+ collapsed: boolean;
50
+ overLimit: boolean;
51
+ dataStatus: ColumnDataStatus;
52
+ cards: KanbanCard[];
53
+ };
54
+ type KanbanModel$1 = {
55
+ columns: ColumnView[];
56
+ };
57
+ type ColumnAccessor = string | {
58
+ get: (card: KanbanCard) => ColumnID;
59
+ set: (card: KanbanCard, value: ColumnID) => KanbanCard;
60
+ };
61
+ type SortCriterion = ((a: KanbanCard, b: KanbanCard) => number) | {
62
+ field: string;
63
+ dir?: "asc" | "desc";
64
+ } | null;
65
+ type FilterPredicate = (card: KanbanCard) => boolean;
66
+ type State = {
67
+ renderMode: string;
68
+ cards: CardsStore;
69
+ columns: ColumnConfig[];
70
+ columnAccessor: ColumnAccessor;
71
+ filters: Map<string, FilterPredicate>;
72
+ sort: SortCriterion;
73
+ editorData: KanbanCard | null;
74
+ dynamicData: boolean;
75
+ columnData: Map<ColumnID, ColumnDataState>;
76
+ history: HistoryState;
77
+ viewData: KanbanModel$1;
78
+ };
79
+ type IData = State;
80
+ type StateInput = Partial<Omit<State, "cards" | "columns" | "filters"> & {
81
+ cards: KanbanCard[] | CardsStore;
82
+ columns: ColumnConfig[];
83
+ filters: Map<string, FilterPredicate>;
84
+ }>;
85
+ type KanbanStoreOptions = {
86
+ undo?: boolean;
87
+ };
88
+ type HistoryState = {
89
+ undo: number;
90
+ redo: number;
91
+ };
92
+ type HistoryActionName = "add-card" | "update-card" | "move-card" | "duplicate-card" | "delete-card";
93
+ type ExportConfig = {
94
+ url?: string | ((data: ExportConfig, records: KanbanCard[], helpers: ExportHelpers) => void);
95
+ format?: string;
96
+ fileName?: string;
97
+ skin?: string;
98
+ paper?: {
99
+ fitSize?: boolean;
100
+ size?: string | {
101
+ width: number;
102
+ height: number;
103
+ };
104
+ landscape?: boolean;
105
+ styles?: string | string[];
106
+ margins?: {
107
+ top?: number;
108
+ bottom?: number;
109
+ left?: number;
110
+ right?: number;
111
+ };
112
+ header?: string;
113
+ footer?: string;
114
+ scale?: number;
115
+ };
116
+ excel?: {
117
+ sheetNames?: string[];
118
+ dateFormat?: string;
119
+ indent?: "native" | "spaces";
120
+ };
121
+ data?: Record<string, any>;
122
+ };
123
+ type ExportHelpers = {
124
+ post: (url: string, data: Record<string, string>) => void;
125
+ serialize: (value: any) => string;
126
+ };
127
+ interface IKanbanStore {
128
+ getState(): State;
129
+ setState(state: StateInput, ctx?: any): any;
130
+ pushUndo<A extends HistoryActionName>(action: A, ev: StoreActions[A]): void;
131
+ undo(): void;
132
+ redo(): void;
133
+ resetHistory(): void;
134
+ }
135
+ interface StoreActions {
136
+ ["add-card"]: {
137
+ card: Partial<KanbanCard>;
138
+ edit?: boolean;
139
+ id?: CardID;
140
+ after?: CardID;
141
+ };
142
+ ["update-card"]: {
143
+ id: CardID;
144
+ card: Partial<KanbanCard>;
145
+ };
146
+ ["move-card"]: {
147
+ id: CardID;
148
+ column?: ColumnID;
149
+ before?: CardID | null;
150
+ };
151
+ ["update-column"]: {
152
+ id: ColumnID;
153
+ column: Partial<ColumnConfig>;
154
+ };
155
+ ["duplicate-card"]: {
156
+ id: CardID;
157
+ card?: Partial<KanbanCard>;
158
+ edit?: boolean;
159
+ };
160
+ ["delete-card"]: {
161
+ id: CardID;
162
+ };
163
+ ["select-card"]: {
164
+ id: CardID | null;
165
+ };
166
+ ["filter-cards"]: {
167
+ filter?: FilterPredicate | null;
168
+ tag?: string;
169
+ };
170
+ ["sort-cards"]: {
171
+ sort?: SortCriterion;
172
+ };
173
+ ["request-data"]: {
174
+ id: ColumnID;
175
+ };
176
+ ["provide-data"]: {
177
+ id?: ColumnID;
178
+ cards: KanbanCard[];
179
+ };
180
+ ["export-data"]: ExportConfig;
181
+ ["undo"]: Record<string, never>;
182
+ ["redo"]: Record<string, never>;
183
+ }
184
+ //#endregion
185
+ //#region src/kanban_store.d.ts
186
+ declare class KanbanStore extends Store<IData> {
187
+ in: EventBus<StoreActions, keyof StoreActions>;
188
+ meta: Record<string, any>;
189
+ private _router;
190
+ constructor(w: TWritableCreator, options?: KanbanStoreOptions);
191
+ init(state: StateInput): void;
192
+ getCards(): KanbanCard[];
193
+ pushUndo<A extends HistoryActionName>(action: A, ev: StoreActions[A]): void;
194
+ undo(): void;
195
+ redo(): void;
196
+ resetHistory(): void;
197
+ getBrandmark(): Brandmark | null;
198
+ setState(state: Partial<IData>, ctx?: TDataConfig): {
199
+ [key: string]: (() => void) | null;
200
+ };
201
+ }
202
+ //#endregion
203
+ //#region src/model.d.ts
204
+ declare class KanbanModel implements KanbanModel$1 {
205
+ columns: ColumnView[];
206
+ constructor(data?: Partial<KanbanModel$1>);
207
+ }
208
+ //#endregion
209
+ //#region src/locale/index.d.ts
210
+ declare function locale(initialData: any): {
211
+ data: any;
212
+ _(key: string): any;
213
+ __(group: string, key: string): any;
214
+ getGroup(group: string): (key: string) => any;
215
+ extend(values: any): /*elided*/any;
216
+ };
217
+ //#endregion
218
+ //#region src/constants.d.ts
219
+ declare function getMenuOptions(): {
220
+ id: string;
221
+ text: string;
222
+ icon: string;
223
+ }[];
224
+ type ToolbarButtonConfig = {
225
+ add?: boolean;
226
+ undo?: boolean;
227
+ sort?: boolean;
228
+ };
229
+ declare function getToolbarItems(config?: ToolbarButtonConfig): any[];
230
+ //#endregion
231
+ export { Brandmark, CardID, CardsStore, ColumnAccessor, ColumnConfig, ColumnDataState, ColumnDataStatus, ColumnID, ColumnView, ExportConfig, ExportHelpers, FilterPredicate, HistoryActionName, HistoryState, IData, IKanbanStore, KanbanCard, KanbanModel, KanbanStore, KanbanStoreOptions, SortCriterion, State, StateInput, StoreActions, type ToolbarButtonConfig, getMenuOptions, getToolbarItems, locale };
package/dist/index.mjs ADDED
@@ -0,0 +1,512 @@
1
+ import { DataRouter, EventBus, Store, tempID } from "@svar-ui/lib-state";
2
+
3
+ //#region src/cards_store.ts
4
+ var CardsStore = class {
5
+ _cards;
6
+ constructor(initial = []) {
7
+ this._cards = initial.slice();
8
+ this._cards.forEach((card) => this._assertHasId(card));
9
+ }
10
+ getCards() {
11
+ return this._cards;
12
+ }
13
+ getById(id) {
14
+ return this._cards.find((card) => card.id === id);
15
+ }
16
+ add(card, after) {
17
+ this._assertHasId(card);
18
+ const next = { ...card };
19
+ const index = after === void 0 ? -1 : this._cards.findIndex((item) => item.id === after);
20
+ if (index === -1) this._cards.push(next);
21
+ else this._cards.splice(index + 1, 0, next);
22
+ return next;
23
+ }
24
+ update(id, patch) {
25
+ const index = this._cards.findIndex((card) => card.id === id);
26
+ if (index === -1) return;
27
+ const next = {
28
+ ...this._cards[index],
29
+ ...patch
30
+ };
31
+ this._assertHasId(next);
32
+ this._cards[index] = next;
33
+ return next;
34
+ }
35
+ upsert(card) {
36
+ this._assertHasId(card);
37
+ const next = { ...card };
38
+ const index = this._cards.findIndex((item) => item.id === card.id);
39
+ if (index === -1) this._cards.push(next);
40
+ else this._cards[index] = next;
41
+ return next;
42
+ }
43
+ remove(id) {
44
+ const index = this._cards.findIndex((card) => card.id === id);
45
+ if (index === -1) return false;
46
+ this._cards.splice(index, 1);
47
+ return true;
48
+ }
49
+ move(id, before) {
50
+ const from = this._cards.findIndex((card) => card.id === id);
51
+ if (from === -1) return false;
52
+ if (before === id) return true;
53
+ let to = this._cards.length;
54
+ if (before != null) {
55
+ to = this._cards.findIndex((card) => card.id === before);
56
+ if (to === -1) return false;
57
+ }
58
+ const [card] = this._cards.splice(from, 1);
59
+ if (from < to) to -= 1;
60
+ this._cards.splice(to, 0, card);
61
+ return true;
62
+ }
63
+ _assertHasId(card) {
64
+ if (card.id == null) throw new Error("Kanban cards must have an id");
65
+ }
66
+ };
67
+
68
+ //#endregion
69
+ //#region src/model.ts
70
+ var KanbanModel = class {
71
+ columns;
72
+ constructor(data = {}) {
73
+ this.columns = data.columns || [];
74
+ }
75
+ };
76
+
77
+ //#endregion
78
+ //#region src/actions/add-card.ts
79
+ function add_card_default(store, ev) {
80
+ const { cards, columns, columnAccessor } = store.getState();
81
+ let card = {
82
+ ...ev.card,
83
+ id: ev.id ?? ev.card.id ?? tempID()
84
+ };
85
+ const columnId = readColumn$1(card, columnAccessor);
86
+ if (!columns.some((column) => column.id === columnId) && columns.length) card = writeColumn$2(card, columnAccessor, columns[0].id);
87
+ const added = cards.add(card, ev.after);
88
+ ev.id = added.id;
89
+ store.setState({
90
+ cards,
91
+ ...ev.edit ? { editorData: { ...added } } : {}
92
+ });
93
+ }
94
+ function readColumn$1(card, accessor) {
95
+ return typeof accessor === "string" ? card[accessor] : accessor.get(card);
96
+ }
97
+ function writeColumn$2(card, accessor, column) {
98
+ return typeof accessor === "string" ? {
99
+ ...card,
100
+ [accessor]: column
101
+ } : accessor.set(card, column);
102
+ }
103
+
104
+ //#endregion
105
+ //#region src/actions/update-card.ts
106
+ function update_card_default(store, ev) {
107
+ const { cards } = store.getState();
108
+ if (cards.update(ev.id, ev.card)) store.setState({ cards });
109
+ }
110
+
111
+ //#endregion
112
+ //#region src/actions/move-card.ts
113
+ function move_card_default(store, ev) {
114
+ const { cards, columns, columnAccessor } = store.getState();
115
+ const card = cards.getById(ev.id);
116
+ if (!card) return;
117
+ const currentColumn = readColumn(card, columnAccessor);
118
+ const targetColumn = ev.column ?? currentColumn;
119
+ if (ev.column !== void 0 && !columns.some((column) => column.id === targetColumn)) return;
120
+ if (ev.before != null) {
121
+ const beforeCard = cards.getById(ev.before);
122
+ const beforeColumn = ev.before === ev.id ? targetColumn : beforeCard && readColumn(beforeCard, columnAccessor);
123
+ if (!beforeCard || beforeColumn !== targetColumn) return;
124
+ }
125
+ if (targetColumn !== currentColumn) {
126
+ const nextCard = writeColumn$1(card, columnAccessor, targetColumn);
127
+ cards.update(ev.id, nextCard);
128
+ }
129
+ if (cards.move(ev.id, ev.before)) store.setState({ cards });
130
+ }
131
+ function readColumn(card, accessor) {
132
+ return typeof accessor === "string" ? card[accessor] : accessor.get(card);
133
+ }
134
+ function writeColumn$1(card, accessor, column) {
135
+ return typeof accessor === "string" ? { [accessor]: column } : accessor.set(card, column);
136
+ }
137
+
138
+ //#endregion
139
+ //#region src/actions/duplicate-card.ts
140
+ function duplicate_card_default(store, ev) {
141
+ const { cards } = store.getState();
142
+ const source = cards.getById(ev.id);
143
+ if (!source) return;
144
+ const duplicate = {
145
+ ...source,
146
+ ...ev.card,
147
+ id: tempID()
148
+ };
149
+ const added = cards.add(duplicate, ev.id);
150
+ store.setState({
151
+ cards,
152
+ ...ev.edit ? { editorData: { ...added } } : {}
153
+ });
154
+ }
155
+
156
+ //#endregion
157
+ //#region src/actions/delete-card.ts
158
+ function delete_card_default(store, ev) {
159
+ const { cards, editorData } = store.getState();
160
+ if (!cards.remove(ev.id)) return;
161
+ store.setState({
162
+ cards,
163
+ ...editorData?.id === ev.id ? { editorData: null } : {}
164
+ });
165
+ }
166
+
167
+ //#endregion
168
+ //#region src/actions/select-card.ts
169
+ function select_card_default(store, ev) {
170
+ if (ev.id === null) {
171
+ store.setState({ editorData: null });
172
+ return;
173
+ }
174
+ const card = store.getState().cards.getById(ev.id);
175
+ if (card) store.setState({ editorData: { ...card } });
176
+ }
177
+
178
+ //#endregion
179
+ //#region src/actions/update-column.ts
180
+ function update_column_default(store, ev) {
181
+ const { columns } = store.getState();
182
+ const index = columns.findIndex((column) => column.id === ev.id);
183
+ if (index === -1) return;
184
+ columns[index] = {
185
+ ...columns[index],
186
+ ...ev.column
187
+ };
188
+ store.setState({ columns });
189
+ }
190
+
191
+ //#endregion
192
+ //#region src/actions/filter-cards.ts
193
+ function filter_cards_default(store, ev = {}) {
194
+ const { filters } = store.getState();
195
+ const hasFilter = Object.prototype.hasOwnProperty.call(ev, "filter");
196
+ const hasTag = Object.prototype.hasOwnProperty.call(ev, "tag");
197
+ const tag = ev.tag ?? "_default";
198
+ if (!hasFilter) if (hasTag) filters.delete(tag);
199
+ else filters.clear();
200
+ else if (ev.filter == null) if (hasTag) filters.delete(tag);
201
+ else filters.clear();
202
+ else filters.set(tag, ev.filter);
203
+ store.setState({ filters });
204
+ }
205
+
206
+ //#endregion
207
+ //#region src/actions/sort-cards.ts
208
+ function sort_cards_default(store, ev = {}) {
209
+ if (!Object.prototype.hasOwnProperty.call(ev, "sort") || ev.sort === void 0) return;
210
+ store.setState({ sort: ev.sort });
211
+ }
212
+
213
+ //#endregion
214
+ //#region src/actions/provide-data.ts
215
+ function provide_data_default(store, ev) {
216
+ const { cards, columns, columnAccessor, columnData } = store.getState();
217
+ if (ev.id) {
218
+ if (!columns.some((column) => column.id === ev.id)) return;
219
+ ev.cards.forEach((card) => {
220
+ cards.upsert(writeColumn(card, columnAccessor, ev.id));
221
+ });
222
+ const next = new Map(columnData);
223
+ next.set(ev.id, { status: "loaded" });
224
+ store.setState({
225
+ cards,
226
+ columnData: next
227
+ });
228
+ } else {
229
+ ev.cards.forEach((card) => {
230
+ cards.upsert(card);
231
+ });
232
+ store.setState({ cards });
233
+ }
234
+ }
235
+ function writeColumn(card, accessor, column) {
236
+ return typeof accessor === "string" ? {
237
+ ...card,
238
+ [accessor]: column
239
+ } : accessor.set(card, column);
240
+ }
241
+
242
+ //#endregion
243
+ //#region src/actions/index.ts
244
+ function init(inBus, store) {
245
+ inBus.on("add-card", (params) => add_card_default(store, params));
246
+ inBus.on("update-card", (params) => update_card_default(store, params));
247
+ inBus.on("move-card", (params) => move_card_default(store, params));
248
+ inBus.on("duplicate-card", (params) => duplicate_card_default(store, params));
249
+ inBus.on("delete-card", (params) => delete_card_default(store, params));
250
+ inBus.on("select-card", (params) => select_card_default(store, params));
251
+ inBus.on("update-column", (params) => update_column_default(store, params));
252
+ inBus.on("filter-cards", (params) => filter_cards_default(store, params));
253
+ inBus.on("sort-cards", (params) => sort_cards_default(store, params));
254
+ inBus.on("provide-data", (params) => provide_data_default(store, params));
255
+ }
256
+
257
+ //#endregion
258
+ //#region src/kanban_reactive.ts
259
+ function reactive(store) {
260
+ return [{
261
+ in: [
262
+ "cards",
263
+ "columns",
264
+ "columnAccessor",
265
+ "filters",
266
+ "sort",
267
+ "dynamicData",
268
+ "columnData"
269
+ ],
270
+ out: ["viewData"],
271
+ exec: () => {
272
+ store.setState({ viewData: projectKanbanModel(store.getState()) });
273
+ }
274
+ }];
275
+ }
276
+ function projectKanbanModel(state) {
277
+ const { cards, columns, columnAccessor, filters, sort, dynamicData, columnData } = state;
278
+ const getColumn = getColumnReader(columnAccessor);
279
+ const buckets = /* @__PURE__ */ new Map();
280
+ const knownColumns = new Set(columns.map((column) => column.id));
281
+ columns.forEach((column) => {
282
+ buckets.set(column.id, []);
283
+ });
284
+ cards.getCards().forEach((card) => {
285
+ const columnId = getColumn(card);
286
+ if (knownColumns.has(columnId)) buckets.get(columnId).push(card);
287
+ });
288
+ const predicates = Array.from(filters.values());
289
+ const compare = getComparator(sort);
290
+ return new KanbanModel({ columns: columns.map((column) => {
291
+ let columnCards = buckets.get(column.id) || [];
292
+ if (predicates.length) columnCards = columnCards.filter((card) => predicates.every((predicate) => predicate(card)));
293
+ else columnCards = columnCards.slice();
294
+ if (compare) columnCards.sort(compare);
295
+ return toColumnView(column, columnCards, getColumnStatus(dynamicData, columnData, column.id));
296
+ }) });
297
+ }
298
+ function getColumnReader(accessor) {
299
+ return typeof accessor === "string" ? (card) => card[accessor] : accessor.get;
300
+ }
301
+ function getComparator(sort) {
302
+ if (!sort) return null;
303
+ if (typeof sort === "function") return sort;
304
+ const direction = sort.dir === "desc" ? -1 : 1;
305
+ return (a, b) => {
306
+ const left = a[sort.field];
307
+ const right = b[sort.field];
308
+ if (left === right) return 0;
309
+ if (left === void 0) return -1 * direction;
310
+ if (right === void 0) return 1 * direction;
311
+ if (left < right) return -1 * direction;
312
+ if (left > right) return 1 * direction;
313
+ return 0;
314
+ };
315
+ }
316
+ function getColumnStatus(dynamicData, columnData, id) {
317
+ return dynamicData ? columnData.get(id)?.status ?? "unknown" : "loaded";
318
+ }
319
+ function toColumnView(column, cards, dataStatus) {
320
+ const view = {
321
+ id: column.id,
322
+ label: column.label,
323
+ collapsed: column.collapsed ?? false,
324
+ addCard: column.addCard !== false,
325
+ overLimit: typeof column.cardLimit === "number" && cards.length > column.cardLimit,
326
+ dataStatus,
327
+ cards
328
+ };
329
+ if (column.css !== void 0) view.css = column.css;
330
+ if (column.metadata !== void 0) view.metadata = column.metadata;
331
+ if (column.cardLimit !== void 0) view.cardLimit = column.cardLimit;
332
+ return view;
333
+ }
334
+
335
+ //#endregion
336
+ //#region src/kanban_store.ts
337
+ var KanbanStore = class extends Store {
338
+ in;
339
+ meta;
340
+ _router;
341
+ constructor(w, options) {
342
+ super({
343
+ writable: w,
344
+ async: false
345
+ });
346
+ this.meta = {};
347
+ this._router = new DataRouter(super.setState.bind(this), reactive(this), {
348
+ columns: (v) => [...v],
349
+ cards: (v) => new CardsStore(v)
350
+ });
351
+ super.setState({
352
+ cards: new CardsStore([]),
353
+ columns: [],
354
+ columnAccessor: "column",
355
+ filters: /* @__PURE__ */ new Map(),
356
+ sort: null,
357
+ editorData: null,
358
+ dynamicData: false,
359
+ columnData: /* @__PURE__ */ new Map(),
360
+ history: {
361
+ undo: 0,
362
+ redo: 0
363
+ },
364
+ viewData: new KanbanModel({ columns: [] })
365
+ });
366
+ init(this.in = new EventBus(), this);
367
+ }
368
+ init(state) {
369
+ this._router.init(state);
370
+ }
371
+ getCards() {
372
+ return this.getState().cards.getCards();
373
+ }
374
+ pushUndo(action, ev) {
375
+ this._history.pushUndo(action, ev);
376
+ }
377
+ undo() {
378
+ this._history.undo();
379
+ }
380
+ redo() {
381
+ this._history.redo();
382
+ }
383
+ resetHistory() {
384
+ this._history.reset();
385
+ }
386
+ getBrandmark() {
387
+ return null;
388
+ }
389
+ setState(state, ctx) {
390
+ if (state.cards && Array.isArray(state.cards)) state = {
391
+ ...state,
392
+ cards: new CardsStore(state.cards)
393
+ };
394
+ return this._router.setState(state, ctx);
395
+ }
396
+ };
397
+
398
+ //#endregion
399
+ //#region src/locale/index.ts
400
+ function locale(initialData) {
401
+ let data = initialData;
402
+ return {
403
+ data,
404
+ _(key) {
405
+ return data[key] || key;
406
+ },
407
+ __(group, key) {
408
+ const block = data[group];
409
+ return block ? block[key] || key : key;
410
+ },
411
+ getGroup(group) {
412
+ return (key) => this.__(group, key);
413
+ },
414
+ extend(values) {
415
+ this.data = data = {
416
+ ...data,
417
+ ...values
418
+ };
419
+ return this;
420
+ }
421
+ };
422
+ }
423
+
424
+ //#endregion
425
+ //#region src/constants.ts
426
+ function getMenuOptions() {
427
+ return [
428
+ {
429
+ id: "edit-card",
430
+ text: "Edit card",
431
+ icon: "wxi-edit"
432
+ },
433
+ {
434
+ id: "duplicate-card",
435
+ text: "Duplicate card",
436
+ icon: "wxi-content-copy"
437
+ },
438
+ {
439
+ id: "delete-card",
440
+ text: "Delete card",
441
+ icon: "wxi-delete"
442
+ }
443
+ ];
444
+ }
445
+ function getToolbarItems(config) {
446
+ const items = [];
447
+ if (config?.add) {
448
+ items.push({
449
+ id: "add-card",
450
+ comp: "button",
451
+ icon: "wxi-plus",
452
+ type: "primary"
453
+ });
454
+ items.push({ comp: "separator" });
455
+ }
456
+ if (config?.undo) items.push({
457
+ id: "undo",
458
+ comp: "icon",
459
+ icon: "wxi-undo",
460
+ title: "Undo",
461
+ menuText: "Undo"
462
+ }, {
463
+ id: "redo",
464
+ comp: "icon",
465
+ icon: "wxi-redo",
466
+ title: "Redo",
467
+ menuText: "Redo"
468
+ });
469
+ if (config?.sort) items.push({
470
+ text: "Sort",
471
+ title: "Sort",
472
+ icon: "wxi-sort",
473
+ collapsed: true,
474
+ layout: "column",
475
+ items: [
476
+ {
477
+ id: "sort-label-asc",
478
+ comp: "item",
479
+ icon: "wxi-asc",
480
+ text: "Title A-Z"
481
+ },
482
+ {
483
+ id: "sort-label-desc",
484
+ comp: "item",
485
+ icon: "wxi-desc",
486
+ text: "Title Z-A"
487
+ },
488
+ {
489
+ id: "sort-priority-asc",
490
+ comp: "item",
491
+ icon: "wxi-asc",
492
+ text: "Priority Low-High"
493
+ },
494
+ {
495
+ id: "sort-priority-desc",
496
+ comp: "item",
497
+ icon: "wxi-desc",
498
+ text: "Priority High-Low"
499
+ },
500
+ { comp: "separator" },
501
+ {
502
+ id: "sort-clear",
503
+ comp: "item",
504
+ text: "Clear sorting"
505
+ }
506
+ ]
507
+ });
508
+ return items;
509
+ }
510
+
511
+ //#endregion
512
+ export { CardsStore, KanbanModel, KanbanStore, getMenuOptions, getToolbarItems, locale };
package/license.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 XB Software Sp. z o.o.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@svar-ui/kanban-store",
3
+ "version": "2.6.0",
4
+ "description": "State and models for SVAR Kanban",
5
+ "homepage": "https://svar.dev",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/svar-widgets/kanban.git"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "license.txt"
14
+ ],
15
+ "type": "module",
16
+ "exports": {
17
+ ".": "./dist/index.mjs",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "dependencies": {
24
+ "@svar-ui/lib-dom": "0.13.1",
25
+ "@svar-ui/lib-state": "1.9.7"
26
+ },
27
+ "devDependencies": {
28
+ "@svar-ui/lib-state": "1.9.7",
29
+ "@typescript/native-preview": "7.0.0-dev.20260316.1",
30
+ "typescript": "^5.9.3",
31
+ "vite-plus": "0.1.16"
32
+ },
33
+ "scripts": {
34
+ "build": "vp pack",
35
+ "dev": "vp pack --watch",
36
+ "test": "vp test",
37
+ "check": "vp check"
38
+ }
39
+ }
package/readme.md ADDED
@@ -0,0 +1,5 @@
1
+ # SVAR Kanban Store
2
+
3
+ This package is part of the **SVAR Kanban (Open-Source Edition)** functionality and is distributed under the MIT license.
4
+
5
+ The **kanban-store** package handles the internal state management used by the Kanban component.