@wirekyt/angular 0.0.8 → 0.0.9
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/fesm2022/wirekyt-angular-collection.mjs +122 -0
- package/dist/fesm2022/wirekyt-angular-collection.mjs.map +1 -0
- package/dist/package.json +5 -1
- package/dist/types/wirekyt-angular-collection.d.ts +81 -0
- package/dist/types/wirekyt-angular-collection.d.ts.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { GridCollection, ListCollection, TreeCollection, filePathToTree, Selection } from '@wirekyt/dom/collection';
|
|
2
|
+
import { useMachine } from '@wirekyt/angular';
|
|
3
|
+
import * as asyncList from '@wirekyt/dom/machines/async-list';
|
|
4
|
+
import { computed, signal, effect, untracked } from '@angular/core';
|
|
5
|
+
|
|
6
|
+
const createGridCollection = (options) => new GridCollection(options);
|
|
7
|
+
|
|
8
|
+
const createListCollection = (options) => new ListCollection(options);
|
|
9
|
+
|
|
10
|
+
const createTreeCollection = (options) => new TreeCollection(options);
|
|
11
|
+
const createFileTreeCollection = (paths) => filePathToTree(paths);
|
|
12
|
+
|
|
13
|
+
function useAsyncList(options) {
|
|
14
|
+
return useMachine({
|
|
15
|
+
machine: asyncList.machine,
|
|
16
|
+
context: options.context,
|
|
17
|
+
connect: (service) => asyncList.connect(service),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function useListCollection(options) {
|
|
22
|
+
const props = computed(() => options.context(), /* @ts-ignore */
|
|
23
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
24
|
+
const items = signal(props().initialItems ?? [], /* @ts-ignore */
|
|
25
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
26
|
+
const filterText = signal("", /* @ts-ignore */
|
|
27
|
+
...(ngDevMode ? [{ debugName: "filterText" }] : /* istanbul ignore next */ []));
|
|
28
|
+
const setItems = (value) => {
|
|
29
|
+
items.set(value);
|
|
30
|
+
filterText.set("");
|
|
31
|
+
};
|
|
32
|
+
const create = (value) => {
|
|
33
|
+
const { initialItems: _initialItems, filter: _filter, limit: _limit, ...collectionOptions } = props();
|
|
34
|
+
return createListCollection({ ...collectionOptions, items: value });
|
|
35
|
+
};
|
|
36
|
+
const collection = computed(() => {
|
|
37
|
+
const { filter, limit } = props();
|
|
38
|
+
let activeItems = items();
|
|
39
|
+
if (filterText() && filter) {
|
|
40
|
+
activeItems = create(activeItems).filter((itemText, _index, item) => filter(itemText, filterText(), item)).items;
|
|
41
|
+
}
|
|
42
|
+
const limitedItems = limit == null ? activeItems : activeItems.slice(0, limit);
|
|
43
|
+
return create(limitedItems);
|
|
44
|
+
}, /* @ts-ignore */
|
|
45
|
+
...(ngDevMode ? [{ debugName: "collection" }] : /* istanbul ignore next */ []));
|
|
46
|
+
return {
|
|
47
|
+
collection,
|
|
48
|
+
filter: (value = "") => filterText.set(value),
|
|
49
|
+
set: setItems,
|
|
50
|
+
reset: () => setItems(props().initialItems),
|
|
51
|
+
clear: () => setItems([]),
|
|
52
|
+
insert: (index, ...values) => setItems(create(items()).insert(index, ...values).items),
|
|
53
|
+
insertBefore: (value, ...values) => setItems(create(items()).insertBefore(value, ...values).items),
|
|
54
|
+
insertAfter: (value, ...values) => setItems(create(items()).insertAfter(value, ...values).items),
|
|
55
|
+
remove: (...values) => setItems(create(items()).remove(...values).items),
|
|
56
|
+
move: (value, to) => setItems(create(items()).move(value, to).items),
|
|
57
|
+
moveBefore: (value, ...values) => setItems(create(items()).moveBefore(value, ...values).items),
|
|
58
|
+
moveAfter: (value, ...values) => setItems(create(items()).moveAfter(value, ...values).items),
|
|
59
|
+
reorder: (from, to) => setItems(create(items()).reorder(from, to).items),
|
|
60
|
+
append: (...values) => setItems(create(items()).append(...values).items),
|
|
61
|
+
upsert: (value, item, mode = "append") => setItems(create(items()).upsert(value, item, mode).items),
|
|
62
|
+
prepend: (...values) => setItems(create(items()).prepend(...values).items),
|
|
63
|
+
update: (value, item) => setItems(create(items()).update(value, item).items),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function useListSelection(options) {
|
|
68
|
+
const props = computed(() => options.context(), /* @ts-ignore */
|
|
69
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
70
|
+
const createSelection = (values = []) => {
|
|
71
|
+
const selection = new Selection(values);
|
|
72
|
+
selection.selectionMode = props().selectionMode ?? "single";
|
|
73
|
+
selection.deselectable = props().deselectable ?? true;
|
|
74
|
+
return selection;
|
|
75
|
+
};
|
|
76
|
+
const selection = signal(createSelection(props().initialSelectedValues), /* @ts-ignore */
|
|
77
|
+
...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
|
|
78
|
+
effect(() => {
|
|
79
|
+
const { collection, resetOnCollectionChange } = props();
|
|
80
|
+
collection.getValues();
|
|
81
|
+
if (resetOnCollectionChange)
|
|
82
|
+
untracked(() => selection.set(createSelection()));
|
|
83
|
+
});
|
|
84
|
+
const selectedValues = computed(() => Array.from(selection()), /* @ts-ignore */
|
|
85
|
+
...(ngDevMode ? [{ debugName: "selectedValues" }] : /* istanbul ignore next */ []));
|
|
86
|
+
const isEmpty = computed(() => selection().isEmpty(), /* @ts-ignore */
|
|
87
|
+
...(ngDevMode ? [{ debugName: "isEmpty" }] : /* istanbul ignore next */ []));
|
|
88
|
+
const firstSelectedValue = computed(() => selection().firstSelectedValue(props().collection), /* @ts-ignore */
|
|
89
|
+
...(ngDevMode ? [{ debugName: "firstSelectedValue" }] : /* istanbul ignore next */ []));
|
|
90
|
+
const lastSelectedValue = computed(() => selection().lastSelectedValue(props().collection), /* @ts-ignore */
|
|
91
|
+
...(ngDevMode ? [{ debugName: "lastSelectedValue" }] : /* istanbul ignore next */ []));
|
|
92
|
+
return {
|
|
93
|
+
selectedValues,
|
|
94
|
+
isEmpty,
|
|
95
|
+
firstSelectedValue,
|
|
96
|
+
lastSelectedValue,
|
|
97
|
+
isSelected: (value) => selection().isSelected(value),
|
|
98
|
+
isAllSelected: () => {
|
|
99
|
+
const values = props().collection.getValues();
|
|
100
|
+
return values.length > 0 && values.every((value) => selection().isSelected(value));
|
|
101
|
+
},
|
|
102
|
+
isSomeSelected: () => props()
|
|
103
|
+
.collection.getValues()
|
|
104
|
+
.some((value) => selection().isSelected(value)),
|
|
105
|
+
canSelect: (value) => selection().canSelect(props().collection, value),
|
|
106
|
+
select: (value, forceToggle) => selection.set(selection().select(props().collection, value, forceToggle)),
|
|
107
|
+
deselect: (value) => selection.set(selection().deselect(value)),
|
|
108
|
+
toggle: (value) => selection.set(selection().toggleSelection(props().collection, value)),
|
|
109
|
+
replace: (value) => selection.set(selection().replaceSelection(props().collection, value)),
|
|
110
|
+
extend: (anchorValue, targetValue) => selection.set(selection().extendSelection(props().collection, anchorValue, targetValue)),
|
|
111
|
+
setSelectedValues: (values) => selection.set(selection().setSelection(values)),
|
|
112
|
+
clear: () => selection.set(selection().clearSelection()),
|
|
113
|
+
resetSelection: () => selection.set(createSelection()),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Generated bundle index. Do not edit.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
export { createFileTreeCollection, createGridCollection, createListCollection, createTreeCollection, useAsyncList, useListCollection, useListSelection };
|
|
122
|
+
//# sourceMappingURL=wirekyt-angular-collection.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wirekyt-angular-collection.mjs","sources":["../../src/components/collection/grid.ts","../../src/components/collection/list.ts","../../src/components/collection/tree.ts","../../src/components/collection/use-async-list.ts","../../src/components/collection/use-list.ts","../../src/components/collection/use-list-selection.ts","../../src/components/collection/wirekyt-angular-collection.ts"],"sourcesContent":["import {\n type CollectionItem,\n type GridCollectionOptions,\n GridCollection,\n} from \"@wirekyt/dom/collection\";\n\nexport const createGridCollection = <T extends CollectionItem>(\n options: GridCollectionOptions<T>,\n): GridCollection<T> => new GridCollection(options);\n\nexport type { GridCollection, GridCollectionOptions };\n","import {\n type CollectionItem,\n type CollectionOptions,\n ListCollection,\n} from \"@wirekyt/dom/collection\";\n\nexport const createListCollection = <T extends CollectionItem>(\n options: CollectionOptions<T>,\n): ListCollection<T> => new ListCollection(options);\n\nexport type { CollectionItem, CollectionOptions, ListCollection };\n","import {\n type FilePathTreeNode,\n type FlatTreeNode,\n type TreeCollectionOptions,\n type TreeNode,\n TreeCollection,\n filePathToTree,\n} from \"@wirekyt/dom/collection\";\n\nexport const createTreeCollection = <T extends TreeNode>(\n options: TreeCollectionOptions<T>,\n): TreeCollection<T> => new TreeCollection(options);\n\nexport const createFileTreeCollection = (paths: string[]): TreeCollection<FilePathTreeNode> =>\n filePathToTree(paths);\n\nexport type { FilePathTreeNode, FlatTreeNode, TreeCollection, TreeCollectionOptions, TreeNode };\n","import type { Machine } from \"@wirekyt/dom\";\n\nimport { useMachine, type UseMachineReturn } from \"@wirekyt/angular\";\nimport * as asyncList from \"@wirekyt/dom/machines/async-list\";\n\nexport interface UseAsyncListOptions<T, C = string> {\n context: () => asyncList.Props<T, C>;\n}\n\nexport type UseAsyncListReturn<T, C = string> = UseMachineReturn<\n asyncList.Service<T, C>[\"state\"],\n asyncList.Api<T, C>,\n asyncList.Service<T, C>\n>;\n\ntype AsyncListSchema<T, C> =\n asyncList.Machine<T, C> extends Machine<infer TSchema> ? TSchema : never;\n\nexport function useAsyncList<T, C = string>(\n options: UseAsyncListOptions<T, C>,\n): UseAsyncListReturn<T, C> {\n return useMachine<AsyncListSchema<T, C>, asyncList.Api<T, C>>({\n machine: asyncList.machine as asyncList.Machine<T, C>,\n context: options.context,\n connect: (service) => asyncList.connect(service),\n });\n}\n","import { type Signal, computed, signal } from \"@angular/core\";\n\nimport { type CollectionOptions, type ListCollection, createListCollection } from \"./list\";\n\nexport interface UseListCollectionProps<T> extends Omit<CollectionOptions<T>, \"items\"> {\n initialItems: T[] | readonly T[];\n filter?: (itemText: string, filterText: string, item: T) => boolean;\n limit?: number;\n}\n\nexport interface UseListCollectionOptions<T> {\n context: () => UseListCollectionProps<T>;\n}\n\nexport function useListCollection<T>(\n options: UseListCollectionOptions<T>,\n): UseListCollectionReturn<T> {\n const props = computed(() => options.context());\n const items = signal<T[] | readonly T[]>(props().initialItems ?? []);\n const filterText = signal(\"\");\n\n const setItems = (value: T[] | readonly T[]) => {\n items.set(value);\n filterText.set(\"\");\n };\n\n const create = (value: T[] | readonly T[]) => {\n const {\n initialItems: _initialItems,\n filter: _filter,\n limit: _limit,\n ...collectionOptions\n } = props();\n return createListCollection({ ...collectionOptions, items: value });\n };\n\n const collection = computed(() => {\n const { filter, limit } = props();\n let activeItems = items();\n\n if (filterText() && filter) {\n activeItems = create(activeItems).filter((itemText, _index, item) =>\n filter(itemText, filterText(), item),\n ).items;\n }\n\n const limitedItems = limit == null ? activeItems : activeItems.slice(0, limit);\n return create(limitedItems);\n });\n\n return {\n collection,\n filter: (value = \"\") => filterText.set(value),\n set: setItems,\n reset: () => setItems(props().initialItems),\n clear: () => setItems([]),\n insert: (index, ...values) => setItems(create(items()).insert(index, ...values).items),\n insertBefore: (value, ...values) =>\n setItems(create(items()).insertBefore(value, ...values).items),\n insertAfter: (value, ...values) =>\n setItems(create(items()).insertAfter(value, ...values).items),\n remove: (...values) => setItems(create(items()).remove(...values).items),\n move: (value, to) => setItems(create(items()).move(value, to).items),\n moveBefore: (value, ...values) => setItems(create(items()).moveBefore(value, ...values).items),\n moveAfter: (value, ...values) => setItems(create(items()).moveAfter(value, ...values).items),\n reorder: (from, to) => setItems(create(items()).reorder(from, to).items),\n append: (...values) => setItems(create(items()).append(...values).items),\n upsert: (value, item, mode = \"append\") =>\n setItems(create(items()).upsert(value, item, mode).items),\n prepend: (...values) => setItems(create(items()).prepend(...values).items),\n update: (value, item) => setItems(create(items()).update(value, item).items),\n };\n}\n\nexport interface UseListCollectionReturn<T> {\n collection: Signal<ListCollection<T>>;\n filter(inputValue: string): void;\n set(items: T[] | readonly T[]): void;\n reset(): void;\n clear(): void;\n insert(index: number, ...items: T[]): void;\n insertBefore(value: string, ...items: T[]): void;\n insertAfter(value: string, ...items: T[]): void;\n remove(...itemOrValues: Array<T | string>): void;\n move(value: string, to: number): void;\n moveBefore(value: string, ...values: string[]): void;\n moveAfter(value: string, ...values: string[]): void;\n reorder(from: number, to: number): void;\n append(...items: T[]): void;\n upsert(value: string, item: T, mode?: \"append\" | \"prepend\"): void;\n prepend(...items: T[]): void;\n update(value: string, item: T): void;\n}\n","import { type Signal, computed, effect, signal, untracked } from \"@angular/core\";\nimport { Selection, type SelectionMode } from \"@wirekyt/dom/collection\";\n\nimport type { CollectionItem, ListCollection } from \"./list\";\n\nexport interface UseListSelectionProps<T extends CollectionItem> {\n selectionMode?: SelectionMode;\n deselectable?: boolean;\n initialSelectedValues?: string[];\n resetOnCollectionChange?: boolean;\n collection: ListCollection<T>;\n}\n\nexport interface UseListSelectionOptions<T extends CollectionItem> {\n context: () => UseListSelectionProps<T>;\n}\n\nexport function useListSelection<T extends CollectionItem>(\n options: UseListSelectionOptions<T>,\n): UseListSelectionReturn {\n const props = computed(() => options.context());\n const createSelection = (values: string[] = []) => {\n const selection = new Selection(values);\n selection.selectionMode = props().selectionMode ?? \"single\";\n selection.deselectable = props().deselectable ?? true;\n return selection;\n };\n const selection = signal(createSelection(props().initialSelectedValues));\n\n effect(() => {\n const { collection, resetOnCollectionChange } = props();\n collection.getValues();\n if (resetOnCollectionChange) untracked(() => selection.set(createSelection()));\n });\n\n const selectedValues = computed(() => Array.from(selection()));\n const isEmpty = computed(() => selection().isEmpty());\n const firstSelectedValue = computed(() => selection().firstSelectedValue(props().collection));\n const lastSelectedValue = computed(() => selection().lastSelectedValue(props().collection));\n\n return {\n selectedValues,\n isEmpty,\n firstSelectedValue,\n lastSelectedValue,\n isSelected: (value) => selection().isSelected(value),\n isAllSelected: () => {\n const values = props().collection.getValues();\n return values.length > 0 && values.every((value) => selection().isSelected(value));\n },\n isSomeSelected: () =>\n props()\n .collection.getValues()\n .some((value) => selection().isSelected(value)),\n canSelect: (value) => selection().canSelect(props().collection, value),\n select: (value, forceToggle) =>\n selection.set(selection().select(props().collection, value, forceToggle)),\n deselect: (value) => selection.set(selection().deselect(value)),\n toggle: (value) => selection.set(selection().toggleSelection(props().collection, value)),\n replace: (value) => selection.set(selection().replaceSelection(props().collection, value)),\n extend: (anchorValue, targetValue) =>\n selection.set(selection().extendSelection(props().collection, anchorValue, targetValue)),\n setSelectedValues: (values) => selection.set(selection().setSelection(values)),\n clear: () => selection.set(selection().clearSelection()),\n resetSelection: () => selection.set(createSelection()),\n };\n}\n\nexport interface UseListSelectionReturn {\n selectedValues: Signal<string[]>;\n isEmpty: Signal<boolean>;\n firstSelectedValue: Signal<string | null>;\n lastSelectedValue: Signal<string | null>;\n isSelected(value: string | null): boolean;\n canSelect(value: string): boolean;\n select(value: string, forceToggle?: boolean): void;\n deselect(value: string): void;\n toggle(value: string): void;\n replace(value: string | null): void;\n extend(anchorValue: string, targetValue: string): void;\n setSelectedValues(values: string[]): void;\n clear(): void;\n resetSelection(): void;\n isAllSelected(): boolean;\n isSomeSelected(): boolean;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAMO,MAAM,oBAAoB,GAAG,CAClC,OAAiC,KACX,IAAI,cAAc,CAAC,OAAO;;ACF3C,MAAM,oBAAoB,GAAG,CAClC,OAA6B,KACP,IAAI,cAAc,CAAC,OAAO;;ACC3C,MAAM,oBAAoB,GAAG,CAClC,OAAiC,KACX,IAAI,cAAc,CAAC,OAAO;AAE3C,MAAM,wBAAwB,GAAG,CAAC,KAAe,KACtD,cAAc,CAAC,KAAK;;ACIhB,SAAU,YAAY,CAC1B,OAAkC,EAAA;AAElC,IAAA,OAAO,UAAU,CAA6C;QAC5D,OAAO,EAAE,SAAS,CAAC,OAAkC;QACrD,OAAO,EAA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CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AAC9E,QAAA,KAAK,EAAE,MAAM,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,cAAc,EAAE,CAAC;QACxD,cAAc,EAAE,MAAM,SAAS,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;KACvD;AACH;;AClEA;;AAEG;;;;"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirekyt/angular",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Angular adapter for Wirekyt",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
"types": "./types/wirekyt-angular-collapsible.d.ts",
|
|
47
47
|
"default": "./fesm2022/wirekyt-angular-collapsible.mjs"
|
|
48
48
|
},
|
|
49
|
+
"./collection": {
|
|
50
|
+
"types": "./types/wirekyt-angular-collection.d.ts",
|
|
51
|
+
"default": "./fesm2022/wirekyt-angular-collection.mjs"
|
|
52
|
+
},
|
|
49
53
|
"./field": {
|
|
50
54
|
"types": "./types/wirekyt-angular-field.d.ts",
|
|
51
55
|
"default": "./fesm2022/wirekyt-angular-field.mjs"
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { CollectionItem, GridCollectionOptions, GridCollection, CollectionOptions, ListCollection, TreeCollection, FilePathTreeNode, TreeNode, TreeCollectionOptions, SelectionMode } from '@wirekyt/dom/collection';
|
|
2
|
+
export { CollectionItem, CollectionOptions, FilePathTreeNode, FlatTreeNode, GridCollection, GridCollectionOptions, ListCollection, TreeCollection, TreeCollectionOptions, TreeNode } from '@wirekyt/dom/collection';
|
|
3
|
+
import { UseMachineReturn } from '@wirekyt/angular';
|
|
4
|
+
import * as asyncList from '@wirekyt/dom/machines/async-list';
|
|
5
|
+
import { Signal } from '@angular/core';
|
|
6
|
+
|
|
7
|
+
declare const createGridCollection: <T extends CollectionItem>(options: GridCollectionOptions<T>) => GridCollection<T>;
|
|
8
|
+
|
|
9
|
+
declare const createListCollection: <T extends CollectionItem>(options: CollectionOptions<T>) => ListCollection<T>;
|
|
10
|
+
|
|
11
|
+
declare const createTreeCollection: <T extends TreeNode>(options: TreeCollectionOptions<T>) => TreeCollection<T>;
|
|
12
|
+
declare const createFileTreeCollection: (paths: string[]) => TreeCollection<FilePathTreeNode>;
|
|
13
|
+
|
|
14
|
+
interface UseAsyncListOptions<T, C = string> {
|
|
15
|
+
context: () => asyncList.Props<T, C>;
|
|
16
|
+
}
|
|
17
|
+
type UseAsyncListReturn<T, C = string> = UseMachineReturn<asyncList.Service<T, C>["state"], asyncList.Api<T, C>, asyncList.Service<T, C>>;
|
|
18
|
+
declare function useAsyncList<T, C = string>(options: UseAsyncListOptions<T, C>): UseAsyncListReturn<T, C>;
|
|
19
|
+
|
|
20
|
+
interface UseListCollectionProps<T> extends Omit<CollectionOptions<T>, "items"> {
|
|
21
|
+
initialItems: T[] | readonly T[];
|
|
22
|
+
filter?: (itemText: string, filterText: string, item: T) => boolean;
|
|
23
|
+
limit?: number;
|
|
24
|
+
}
|
|
25
|
+
interface UseListCollectionOptions<T> {
|
|
26
|
+
context: () => UseListCollectionProps<T>;
|
|
27
|
+
}
|
|
28
|
+
declare function useListCollection<T>(options: UseListCollectionOptions<T>): UseListCollectionReturn<T>;
|
|
29
|
+
interface UseListCollectionReturn<T> {
|
|
30
|
+
collection: Signal<ListCollection<T>>;
|
|
31
|
+
filter(inputValue: string): void;
|
|
32
|
+
set(items: T[] | readonly T[]): void;
|
|
33
|
+
reset(): void;
|
|
34
|
+
clear(): void;
|
|
35
|
+
insert(index: number, ...items: T[]): void;
|
|
36
|
+
insertBefore(value: string, ...items: T[]): void;
|
|
37
|
+
insertAfter(value: string, ...items: T[]): void;
|
|
38
|
+
remove(...itemOrValues: Array<T | string>): void;
|
|
39
|
+
move(value: string, to: number): void;
|
|
40
|
+
moveBefore(value: string, ...values: string[]): void;
|
|
41
|
+
moveAfter(value: string, ...values: string[]): void;
|
|
42
|
+
reorder(from: number, to: number): void;
|
|
43
|
+
append(...items: T[]): void;
|
|
44
|
+
upsert(value: string, item: T, mode?: "append" | "prepend"): void;
|
|
45
|
+
prepend(...items: T[]): void;
|
|
46
|
+
update(value: string, item: T): void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface UseListSelectionProps<T extends CollectionItem> {
|
|
50
|
+
selectionMode?: SelectionMode;
|
|
51
|
+
deselectable?: boolean;
|
|
52
|
+
initialSelectedValues?: string[];
|
|
53
|
+
resetOnCollectionChange?: boolean;
|
|
54
|
+
collection: ListCollection<T>;
|
|
55
|
+
}
|
|
56
|
+
interface UseListSelectionOptions<T extends CollectionItem> {
|
|
57
|
+
context: () => UseListSelectionProps<T>;
|
|
58
|
+
}
|
|
59
|
+
declare function useListSelection<T extends CollectionItem>(options: UseListSelectionOptions<T>): UseListSelectionReturn;
|
|
60
|
+
interface UseListSelectionReturn {
|
|
61
|
+
selectedValues: Signal<string[]>;
|
|
62
|
+
isEmpty: Signal<boolean>;
|
|
63
|
+
firstSelectedValue: Signal<string | null>;
|
|
64
|
+
lastSelectedValue: Signal<string | null>;
|
|
65
|
+
isSelected(value: string | null): boolean;
|
|
66
|
+
canSelect(value: string): boolean;
|
|
67
|
+
select(value: string, forceToggle?: boolean): void;
|
|
68
|
+
deselect(value: string): void;
|
|
69
|
+
toggle(value: string): void;
|
|
70
|
+
replace(value: string | null): void;
|
|
71
|
+
extend(anchorValue: string, targetValue: string): void;
|
|
72
|
+
setSelectedValues(values: string[]): void;
|
|
73
|
+
clear(): void;
|
|
74
|
+
resetSelection(): void;
|
|
75
|
+
isAllSelected(): boolean;
|
|
76
|
+
isSomeSelected(): boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { createFileTreeCollection, createGridCollection, createListCollection, createTreeCollection, useAsyncList, useListCollection, useListSelection };
|
|
80
|
+
export type { UseAsyncListOptions, UseAsyncListReturn, UseListCollectionOptions, UseListCollectionProps, UseListCollectionReturn, UseListSelectionOptions, UseListSelectionProps, UseListSelectionReturn };
|
|
81
|
+
//# sourceMappingURL=wirekyt-angular-collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wirekyt-angular-collection.d.ts","sources":["../../src/components/collection/grid.ts","../../src/components/collection/list.ts","../../src/components/collection/tree.ts","../../src/components/collection/use-async-list.ts","../../src/components/collection/use-list.ts","../../src/components/collection/use-list-selection.ts"],"mappings":";;;;;;AAMA,cAAa,oBAAoB,aAAc,cAAc,WAClD,qBAAqB,QAC7B,cAAc;;ACFjB,cAAa,oBAAoB,aAAc,cAAc,WAClD,iBAAiB,QACzB,cAAc;;ACCjB,cAAa,oBAAoB,aAAc,QAAQ,WAC5C,qBAAqB,QAC7B,cAAc;AAEjB,cAAa,wBAAwB,uBAAsB,cAAc,CAAC,gBAAgB;;UCRzE,mBAAmB;mBACnB,SAAS,CAAC,KAAK;AAC/B;KAEW,kBAAkB,kBAAkB,gBAAgB,CAC9D,SAAS,CAAC,OAAO,iBACjB,SAAS,CAAC,GAAG,QACb,SAAS,CAAC,OAAO;AAMnB,iBAAgB,YAAY,yBACjB,mBAAmB,SAC3B,kBAAkB;;AChBf,UAAW,sBAAsB,YAAY,IAAI,CAAC,iBAAiB;AACvE;AACA;;AAED;AAEK,UAAW,wBAAwB;AACvC,mBAAe,sBAAsB;AACtC;AAED,iBAAgB,iBAAiB,aACtB,wBAAwB,MAChC,uBAAuB;AA0DpB,UAAW,uBAAuB;gBAC1B,MAAM,CAAC,cAAc;AACjC;;;;AAIA;AACA;AACA;AACA,4BAAwB,KAAK;;AAE7B;AACA;;;AAGA;;;AAGD;;ACvFK,UAAW,qBAAqB,WAAW,cAAc;oBAC7C,aAAa;;AAE7B;;AAEA,gBAAY,cAAc;AAC3B;AAEK,UAAW,uBAAuB,WAAW,cAAc;AAC/D,mBAAe,qBAAqB;AACrC;AAED,iBAAgB,gBAAgB,WAAW,cAAc,WAC9C,uBAAuB,MAC/B,sBAAsB;UAiDR,sBAAsB;AACrC,oBAAgB,MAAM;AACtB,aAAS,MAAM;AACf,wBAAoB,MAAM;AAC1B,uBAAmB,MAAM;;AAEzB;;AAEA;AACA;;;AAGA;;;;;AAKD;;;;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirekyt/angular",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Angular adapter for Wirekyt",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
"types": "./dist/types/wirekyt-angular-collapsible.d.ts",
|
|
47
47
|
"default": "./dist/fesm2022/wirekyt-angular-collapsible.mjs"
|
|
48
48
|
},
|
|
49
|
+
"./collection": {
|
|
50
|
+
"types": "./dist/types/wirekyt-angular-collection.d.ts",
|
|
51
|
+
"default": "./dist/fesm2022/wirekyt-angular-collection.mjs"
|
|
52
|
+
},
|
|
49
53
|
"./field": {
|
|
50
54
|
"types": "./dist/types/wirekyt-angular-field.d.ts",
|
|
51
55
|
"default": "./dist/fesm2022/wirekyt-angular-field.mjs"
|
|
@@ -64,7 +68,7 @@
|
|
|
64
68
|
"@internationalized/date": "^3.12.3",
|
|
65
69
|
"@internationalized/number": "^3.6.7",
|
|
66
70
|
"tslib": "^2.8.1",
|
|
67
|
-
"@wirekyt/dom": "0.0.
|
|
71
|
+
"@wirekyt/dom": "0.0.9"
|
|
68
72
|
},
|
|
69
73
|
"peerDependencies": {
|
|
70
74
|
"@angular/common": ">=22.0.0",
|