@umbraco-cms/backoffice 1.0.0-next.de0ffca0 → 1.0.0-next.e8be58ec

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/router.d.ts CHANGED
@@ -1,24 +1,6 @@
1
- import { UmbContextToken } from './context-api';
2
- import { UmbControllerHostElement } from './controller';
3
- import { UmbModalRouteRegistration } from './modal';
4
-
5
- interface UmbRouteLocation {
6
- name?: string;
7
- params: {
8
- [key: string]: string;
9
- };
10
- }
11
-
12
- declare class UmbRouteContext {
13
- #private;
14
- private _onGotModals;
15
- constructor(host: UmbControllerHostElement, _onGotModals: (contextRoutes: any) => void);
16
- registerModal(registration: UmbModalRouteRegistration): UmbModalRouteRegistration<object, any>;
17
- unregisterModal(registrationToken: ReturnType<typeof this$1.registerModal>): void;
18
- _internal_routerGotBasePath(routerBasePath: string): void;
19
- _internal_modalRouterChanged(activeModalPath: string | undefined): void;
20
- }
21
- declare const UMB_ROUTE_CONTEXT_TOKEN: UmbContextToken<UmbRouteContext>;
1
+ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
2
+ import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
3
+ import { UmbModalRouteRegistration } from '@umbraco-cms/backoffice/modal';
22
4
 
23
5
  interface IRouterSlot<D = any, P = any> extends HTMLElement {
24
6
  readonly route: IRoute<D> | null;
@@ -40,14 +22,20 @@ type IRoutingInfo<D = any, P = any> = {
40
22
  };
41
23
  type CustomResolver<D = any, P = any> = ((info: IRoutingInfo<D>) => boolean | void | Promise<boolean> | Promise<void>);
42
24
  type Guard<D = any, P = any> = ((info: IRoutingInfo<D, P>) => boolean | Promise<boolean>);
43
- type PageComponent = HTMLElement;
25
+ type PageComponent = HTMLElement | undefined;
44
26
  type ModuleResolver = Promise<{
45
27
  default: any;
46
28
  }>;
47
29
  type Class<T extends PageComponent = PageComponent> = {
48
30
  new (...args: any[]): T;
49
31
  };
32
+ type Component = Class | ModuleResolver | PageComponent | (() => Class) | (() => PromiseLike<Class>) | (() => PageComponent) | (() => PromiseLike<PageComponent>) | (() => ModuleResolver) | (() => PromiseLike<ModuleResolver>);
50
33
  type Setup<D = any> = ((component: PageComponent, info: IRoutingInfo<D>) => void);
34
+ type RouterTree<D = any, P = any> = {
35
+ slot: IRouterSlot<D, P>;
36
+ } & {
37
+ child?: RouterTree;
38
+ } | null | undefined;
51
39
  type PathMatch = "prefix" | "suffix" | "full" | "fuzzy";
52
40
  /**
53
41
  * The base route interface.
@@ -70,7 +58,7 @@ interface IRedirectRoute<D = any> extends IRouteBase<D> {
70
58
  * Route type used to resolve and stamp components.
71
59
  */
72
60
  interface IComponentRoute<D = any> extends IRouteBase<D> {
73
- component: Class | ModuleResolver | PageComponent | (() => Class) | (() => PageComponent) | (() => ModuleResolver);
61
+ component: Component | PromiseLike<Component>;
74
62
  setup?: Setup;
75
63
  }
76
64
  /**
@@ -106,10 +94,18 @@ type NavigationEndEvent<D = any> = CustomEvent<IRoutingInfo<D>>;
106
94
  type Params = {
107
95
  [key: string]: string;
108
96
  };
97
+ type Query = {
98
+ [key: string]: string;
99
+ };
100
+ type EventListenerSubscription = (() => void);
109
101
  /**
110
102
  * History related events.
111
103
  */
112
104
  type GlobalRouterEvent = "pushstate" | "replacestate" | "popstate" | "changestate" | "willchangestate" | "navigationstart" | "navigationcancel" | "navigationerror" | "navigationsuccess" | "navigationend";
105
+ interface ISlashOptions {
106
+ start: boolean;
107
+ end: boolean;
108
+ }
113
109
  declare global {
114
110
  interface GlobalEventHandlersEventMap {
115
111
  "pushstate": PushStateEvent;
@@ -125,6 +121,248 @@ declare global {
125
121
  }
126
122
  }
127
123
 
128
- type UmbRoute = IRoute;
124
+ /**
125
+ * Dispatches a did change route event.
126
+ * @param $elem
127
+ * @param {IRoute} detail
128
+ */
129
+ declare function dispatchRouteChangeEvent<D = any>($elem: HTMLElement, detail: IRoutingInfo<D>): void;
130
+ /**
131
+ * Dispatches an event on the window object.
132
+ * @param name
133
+ * @param detail
134
+ */
135
+ declare function dispatchGlobalRouterEvent<D = any>(name: GlobalRouterEvent, detail?: IRoutingInfo<D>): void;
136
+ /**
137
+ * Adds an event listener (or more) to an element and returns a function to unsubscribe.
138
+ * @param $elem
139
+ * @param type
140
+ * @param listener
141
+ * @param options
142
+ */
143
+ declare function addListener<T extends Event, eventType extends string>($elem: EventTarget, type: eventType[] | eventType, listener: ((e: T) => void), options?: boolean | AddEventListenerOptions): EventListenerSubscription;
144
+ /**
145
+ * Removes the event listeners in the array.
146
+ * @param listeners
147
+ */
148
+ declare function removeListeners(listeners: EventListenerSubscription[]): void;
149
+
150
+ declare const historyPatches: [string, GlobalRouterEvent[]][];
151
+ /**
152
+ * Patches the history object by ensuring correct events are dispatches when the history changes.
153
+ */
154
+ declare function ensureHistoryEvents(): void;
155
+ /**
156
+ * Attaches a global router event after the native function on the object has been invoked.
157
+ * Stores the original function at the _name.
158
+ * @param obj
159
+ * @param functionName
160
+ * @param eventName
161
+ */
162
+ declare function attachCallback(obj: any, functionName: string, eventName: GlobalRouterEvent): void;
163
+ /**
164
+ * Saves the native function on the history object.
165
+ * @param obj
166
+ * @param name
167
+ * @param func
168
+ */
169
+ declare function saveNativeFunction(obj: any, name: string, func: (() => void)): void;
170
+ declare global {
171
+ interface History {
172
+ "native": {
173
+ "back": ((distance?: any) => void);
174
+ "forward": ((distance?: any) => void);
175
+ "go": ((delta?: any) => void);
176
+ "pushState": ((data: any, title?: string, url?: string | null) => void);
177
+ "replaceState": ((data: any, title?: string, url?: string | null) => void);
178
+ };
179
+ }
180
+ }
181
+
182
+ /**
183
+ * Determines whether the path is active.
184
+ * If the full path starts with the path and is followed by the end of the string or a "/" the path is considered active.
185
+ * @param path
186
+ * @param fullPath
187
+ */
188
+ declare function isPathActive(path: string | PathFragment, fullPath?: string): boolean;
189
+ /**
190
+ * Matches a route.
191
+ * @param route
192
+ * @param path
193
+ */
194
+ declare function matchRoute<D = any>(route: IRoute<D>, path: string | PathFragment): IRouteMatch<D> | null;
195
+ /**
196
+ * Matches the first route that matches the given path.
197
+ * @param routes
198
+ * @param path
199
+ */
200
+ declare function matchRoutes<D = any>(routes: IRoute<D>[], path: string | PathFragment): IRouteMatch<D> | null;
201
+ /**
202
+ * Returns the page from the route.
203
+ * If the component provided is a function (and not a class) call the function to get the promise.
204
+ * @param route
205
+ * @param info
206
+ */
207
+ declare function resolvePageComponent(route: IComponentRoute, info: IRoutingInfo): Promise<PageComponent>;
208
+ /**
209
+ * Determines if a route is a redirect route.
210
+ * @param route
211
+ */
212
+ declare function isRedirectRoute(route: IRoute): route is IRedirectRoute;
213
+ /**
214
+ * Determines if a route is a resolver route.
215
+ * @param route
216
+ */
217
+ declare function isResolverRoute(route: IRoute): route is IResolverRoute;
218
+ /**
219
+ * Traverses the router tree up to the root route.
220
+ * @param slot
221
+ */
222
+ declare function traverseRouterTree(slot: IRouterSlot): {
223
+ tree: RouterTree;
224
+ depth: number;
225
+ };
226
+ /**
227
+ * Generates a path based on the router tree.
228
+ * @param tree
229
+ * @param depth
230
+ */
231
+ declare function getFragments(tree: RouterTree, depth: number): PathFragment[];
232
+ /**
233
+ * Constructs the correct absolute path based on a router.
234
+ * - Handles relative paths: "mypath"
235
+ * - Handles absolute paths: "/mypath"
236
+ * - Handles traversing paths: "../../mypath"
237
+ * @param slot
238
+ * @param path
239
+ */
240
+ declare function constructAbsolutePath<D = any, P = any>(slot: IRouterSlot<D, P>, path?: string | PathFragment): string;
241
+ /**
242
+ * Handles a redirect.
243
+ * @param slot
244
+ * @param route
245
+ */
246
+ declare function handleRedirect(slot: IRouterSlot, route: IRedirectRoute): void;
247
+ /**
248
+ * Determines whether the navigation should start based on the current match and the new match.
249
+ * @param currentMatch
250
+ * @param newMatch
251
+ */
252
+ declare function shouldNavigate<D>(currentMatch: IRouteMatch<D> | null, newMatch: IRouteMatch<D>): boolean;
253
+
254
+ /**
255
+ * Queries the parent router.
256
+ * @param $elem
257
+ */
258
+ declare function queryParentRouterSlot<D = any>($elem: Element): IRouterSlot<D> | null;
259
+ /**
260
+ * Traverses the roots and returns the first match.
261
+ * The minRoots parameter indicates how many roots should be traversed before we started matching with the query.
262
+ * @param $elem
263
+ * @param query
264
+ * @param minRoots
265
+ * @param roots
266
+ */
267
+ declare function queryParentRoots<T>($elem: Element, query: string, minRoots?: number, roots?: number): T | null;
268
+
269
+ /**
270
+ * The current path of the location.
271
+ * As default slashes are included at the start and end.
272
+ * @param options
273
+ */
274
+ declare function path(options?: Partial<ISlashOptions>): string;
275
+ /**
276
+ * Returns the path without the base path.
277
+ * @param options
278
+ */
279
+ declare function pathWithoutBasePath(options?: Partial<ISlashOptions>): string;
280
+ /**
281
+ * Returns the base path as defined in the <base> tag in the head in a reliable way.
282
+ * If eg. <base href="/router-slot/"> is defined this function will return "/router-slot/".
283
+ *
284
+ * An alternative would be to use regex on document.baseURI,
285
+ * but that will be unreliable in some cases because it
286
+ * doesn't use the built in HTMLHyperlinkElementUtils.
287
+ *
288
+ * To make this method more performant we could cache the anchor element.
289
+ * As default it will return the base path with slashes in front and at the end.
290
+ */
291
+ declare function basePath(options?: Partial<ISlashOptions>): string;
292
+ /**
293
+ * Creates an URL using the built in HTMLHyperlinkElementUtils.
294
+ * An alternative would be to use regex on document.baseURI,
295
+ * but that will be unreliable in some cases because it
296
+ * doesn't use the built in HTMLHyperlinkElementUtils.
297
+ *
298
+ * As default it will return the base path with slashes in front and at the end.
299
+ * @param path
300
+ * @param options
301
+ */
302
+ declare function constructPathWithBasePath(path: string, options?: Partial<ISlashOptions>): string;
303
+ /**
304
+ * Removes the start of the path that matches the part.
305
+ * @param path
306
+ * @param part
307
+ */
308
+ declare function stripStart(path: string, part: string): string;
309
+ /**
310
+ * Returns the query string.
311
+ */
312
+ declare function queryString(): string;
313
+ /**
314
+ * Returns the params for the current path.
315
+ * @returns Params
316
+ */
317
+ declare function query(): Query;
318
+ /**
319
+ * Strips the slash from the start and end of a path.
320
+ * @param path
321
+ */
322
+ declare function stripSlash(path: string): string;
323
+ /**
324
+ * Ensures the path starts and ends with a slash
325
+ * @param path
326
+ */
327
+ declare function ensureSlash(path: string): string;
328
+ /**
329
+ * Makes sure that the start and end slashes are present or not depending on the options.
330
+ * @param path
331
+ * @param start
332
+ * @param end
333
+ */
334
+ declare function slashify(path: string, { start, end }?: Partial<ISlashOptions>): string;
335
+ /**
336
+ * Turns a query string into an object.
337
+ * @param {string} queryString (example: ("test=123&hejsa=LOL&wuhuu"))
338
+ * @returns {Query}
339
+ */
340
+ declare function toQuery(queryString: string): Query;
341
+ /**
342
+ * Turns a query object into a string query.
343
+ * @param query
344
+ */
345
+ declare function toQueryString(query: Query): string;
346
+
347
+ /**
348
+ * Hook up a click listener to the window that, for all anchor tags
349
+ * that has a relative HREF, uses the history API instead.
350
+ */
351
+ declare function ensureAnchorHistory(): void;
352
+
353
+ declare class UmbRouteContext {
354
+ #private;
355
+ private _onGotModals;
356
+ constructor(host: UmbControllerHostElement, _onGotModals: (contextRoutes: any) => void);
357
+ registerModal(registration: UmbModalRouteRegistration): UmbModalRouteRegistration<object, any>;
358
+ unregisterModal(registrationToken: ReturnType<typeof this$1.registerModal>): void;
359
+ _internal_routerGotBasePath(routerBasePath: string): void;
360
+ _internal_modalRouterChanged(activeModalPath: string | undefined): void;
361
+ }
362
+ declare const UMB_ROUTE_CONTEXT_TOKEN: UmbContextToken<UmbRouteContext>;
363
+
364
+ declare function generateRoutePathBuilder(path: string): (params: {
365
+ [key: string]: string | number;
366
+ }) => string;
129
367
 
130
- export { UMB_ROUTE_CONTEXT_TOKEN, UmbRoute, UmbRouteContext, UmbRouteLocation };
368
+ export { Guard, IComponentRoute, IRedirectRoute, IResolverRoute, IRoutingInfo, PageComponent, Params, Query, UMB_ROUTE_CONTEXT_TOKEN, IRoute as UmbRoute, UmbRouteContext, addListener, attachCallback, basePath, constructAbsolutePath, constructPathWithBasePath, dispatchGlobalRouterEvent, dispatchRouteChangeEvent, ensureAnchorHistory, ensureHistoryEvents, ensureSlash, generateRoutePathBuilder, getFragments, handleRedirect, historyPatches, isPathActive, isRedirectRoute, isResolverRoute, matchRoute, matchRoutes, path, pathWithoutBasePath, query, queryParentRoots, queryParentRouterSlot, queryString, removeListeners, resolvePageComponent, saveNativeFunction, shouldNavigate, slashify, stripSlash, stripStart, toQuery, toQueryString, traverseRouterTree };
package/section.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import * as rxjs from 'rxjs';
2
+ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
3
+ import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
4
+ import { ManifestSection } from '@umbraco-cms/backoffice/extensions-registry';
5
+
6
+ declare class UmbSectionSidebarContext {
7
+ #private;
8
+ contextMenuIsOpen: rxjs.Observable<boolean>;
9
+ entityType: rxjs.Observable<string | undefined>;
10
+ unique: rxjs.Observable<string | null | undefined>;
11
+ headline: rxjs.Observable<string | undefined>;
12
+ constructor(host: UmbControllerHostElement);
13
+ toggleContextMenu(entityType: string, unique: string | null | undefined, headline: string): void;
14
+ openContextMenu(entityType: string, unique: string | null | undefined, headline: string): void;
15
+ closeContextMenu(): void;
16
+ }
17
+ declare const UMB_SECTION_SIDEBAR_CONTEXT_TOKEN: UmbContextToken<UmbSectionSidebarContext>;
18
+
19
+ declare class UmbSectionContext {
20
+ #private;
21
+ readonly alias: rxjs.Observable<string | undefined>;
22
+ readonly pathname: rxjs.Observable<string | undefined>;
23
+ readonly label: rxjs.Observable<string | undefined>;
24
+ constructor(manifest: ManifestSection);
25
+ setManifest(manifest?: ManifestSection): void;
26
+ }
27
+ declare const UMB_SECTION_CONTEXT_TOKEN: UmbContextToken<UmbSectionContext>;
28
+
29
+ export { UMB_SECTION_CONTEXT_TOKEN, UMB_SECTION_SIDEBAR_CONTEXT_TOKEN, UmbSectionContext, UmbSectionSidebarContext };
package/sorter.d.ts ADDED
@@ -0,0 +1,103 @@
1
+ import { UmbControllerInterface, UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
2
+
3
+ type INTERNAL_UmbSorterConfig<T> = {
4
+ compareElementToModel: (el: HTMLElement, modelEntry: T) => boolean;
5
+ querySelectModelToElement: (container: HTMLElement, modelEntry: T) => HTMLElement | null;
6
+ identifier: string;
7
+ itemSelector: string;
8
+ disabledItemSelector?: string;
9
+ containerSelector: string;
10
+ ignorerSelector: string;
11
+ placeholderClass: string;
12
+ draggableSelector?: string;
13
+ boundarySelector?: string;
14
+ dataTransferResolver?: (dataTransfer: DataTransfer | null, currentItem: T) => void;
15
+ onStart?: (argument: {
16
+ item: T;
17
+ element: HTMLElement;
18
+ }) => void;
19
+ onChange?: (argument: {
20
+ item: T;
21
+ element: HTMLElement;
22
+ }) => void;
23
+ onContainerChange?: (argument: {
24
+ item: T;
25
+ element: HTMLElement;
26
+ }) => void;
27
+ onEnd?: (argument: {
28
+ item: T;
29
+ element: HTMLElement;
30
+ }) => void;
31
+ onSync?: (argument: {
32
+ item: T;
33
+ fromController: UmbSorterController<T>;
34
+ toController: UmbSorterController<T>;
35
+ }) => void;
36
+ itemHasNestedContainersResolver?: (element: HTMLElement) => boolean;
37
+ onDisallowed?: () => void;
38
+ onAllowed?: () => void;
39
+ onRequestDrop?: (argument: {
40
+ item: T;
41
+ }) => boolean | void;
42
+ resolveVerticalDirection?: (argument: {
43
+ containerElement: Element;
44
+ containerRect: DOMRect;
45
+ item: T;
46
+ element: HTMLElement;
47
+ elementRect: DOMRect;
48
+ relatedElement: HTMLElement;
49
+ relatedRect: DOMRect;
50
+ placeholderIsInThisRow: boolean;
51
+ horizontalPlaceAfter: boolean;
52
+ }) => void;
53
+ performItemInsert?: (argument: {
54
+ item: T;
55
+ newIndex: number;
56
+ }) => Promise<boolean> | boolean;
57
+ performItemRemove?: (argument: {
58
+ item: T;
59
+ }) => Promise<boolean> | boolean;
60
+ };
61
+ type UmbSorterConfig<T> = Omit<INTERNAL_UmbSorterConfig<T>, 'placeholderClass' | 'ignorerSelector' | 'containerSelector'> & Partial<Pick<INTERNAL_UmbSorterConfig<T>, 'placeholderClass' | 'ignorerSelector' | 'containerSelector'>>;
62
+ /**
63
+ * @export
64
+ * @class UmbSorterController
65
+ * @implements {UmbControllerInterface}
66
+ * @description This controller can make user able to sort items.
67
+ */
68
+ declare class UmbSorterController<T> implements UmbControllerInterface {
69
+ #private;
70
+ private _lastIndicationContainerVM;
71
+ get unique(): string;
72
+ constructor(host: UmbControllerHostElement, config: UmbSorterConfig<T>);
73
+ setModel(model: Array<T>): void;
74
+ hostConnected(): void;
75
+ private _onFirstRender;
76
+ hostDisconnected(): void;
77
+ setupItem(element: HTMLElement): void;
78
+ destroyItem(element: HTMLElement): void;
79
+ handleDragStart: (event: DragEvent) => void;
80
+ handleDragEnd: () => Promise<void>;
81
+ handleDragMove: (event: DragEvent) => void;
82
+ moveCurrentElement: () => void;
83
+ move(orderedContainerElements: Array<Element>, newElIndex: number): void;
84
+ /** Management methods: */
85
+ getItemOfElement(element: HTMLElement): T | null | undefined;
86
+ removeItem(item: T): Promise<boolean | T | null>;
87
+ hasOtherItemsThan(item: T): boolean;
88
+ sync(element: HTMLElement, fromVm: UmbSorterController<T>): Promise<boolean>;
89
+ updateAllowIndication(contextVM: UmbSorterController<T>, item: T): boolean;
90
+ removeAllowIndication(): void;
91
+ private autoScrollX;
92
+ private autoScrollY;
93
+ private handleAutoScroll;
94
+ private _performAutoScroll;
95
+ private stopAutoScroll;
96
+ notifySync(data: any): void;
97
+ notifyDisallowed(): void;
98
+ notifyAllowed(): void;
99
+ notifyRequestDrop(data: any): boolean;
100
+ destroy(): void;
101
+ }
102
+
103
+ export { UmbSorterConfig, UmbSorterController };
package/store.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import * as rxjs from 'rxjs';
2
2
  import { Observable } from 'rxjs';
3
- import { UmbControllerHostElement } from './controller';
4
- import { EntityTreeItemResponseModel, FileSystemTreeItemPresentationModel } from './backend-api';
5
- import { UmbStoreBase as UmbStoreBase$1, UmbTreeStore as UmbTreeStore$1 } from './store';
3
+ import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
4
+ import { UmbArrayState } from '@umbraco-cms/backoffice/observable-api';
5
+ import { EntityTreeItemResponseModel, FileSystemTreeItemPresentationModel } from '@umbraco-cms/backoffice/backend-api';
6
+ import { UmbStoreBase as UmbStoreBase$1, UmbTreeStore as UmbTreeStore$1 } from '@umbraco-cms/backoffice/store';
6
7
 
7
8
  interface UmbDataStoreIdentifiers {
8
9
  key?: string;
@@ -18,7 +19,7 @@ interface UmbEntityDetailStore<T> extends UmbDataStore {
18
19
  * @return {*} {T}
19
20
  * @memberof UmbEntityDetailStore
20
21
  */
21
- getScaffold: (entityType: string, parentKey: string | null) => T;
22
+ getScaffold: (entityType: string, parentId: string | null) => T;
22
23
  /**
23
24
  * @description - Request data by key. The data is added to the store and is returned as an Observable.
24
25
  * @param {string} key
@@ -38,39 +39,46 @@ interface UmbContentStore<T> extends UmbEntityDetailStore<T> {
38
39
  save(data: T[]): Promise<void>;
39
40
  }
40
41
 
41
- declare class UmbStoreBase {
42
- protected _host: UmbControllerHostElement;
43
- readonly storeAlias: string;
44
- constructor(_host: UmbControllerHostElement, storeAlias: string);
42
+ interface UmbStore<T> {
43
+ appendItems: (items: Array<T>) => void;
44
+ updateItem: (unique: string, item: Partial<T>) => void;
45
+ removeItem: (unique: string) => void;
45
46
  }
46
47
 
47
- /**
48
- * @export
49
- * @class UmbEntityTreeStore
50
- * @extends {UmbStoreBase}
51
- * @description - General Tree Data Store
52
- */
53
- declare class UmbEntityTreeStore extends UmbStoreBase$1 implements UmbTreeStore$1<EntityTreeItemResponseModel> {
54
- #private;
48
+ declare class UmbStoreBase<StoreItemType = any> implements UmbStore<StoreItemType> {
49
+ protected _host: UmbControllerHostElement;
50
+ protected _data: UmbArrayState<StoreItemType>;
51
+ readonly storeAlias: string;
52
+ constructor(_host: UmbControllerHostElement, storeAlias: string, data: UmbArrayState<StoreItemType>);
55
53
  /**
56
54
  * Appends items to the store
57
- * @param {Array<EntityTreeItemResponseModel>} items
55
+ * @param {Array<StoreItemType>} items
58
56
  * @memberof UmbEntityTreeStore
59
57
  */
60
- appendItems(items: Array<EntityTreeItemResponseModel>): void;
58
+ appendItems(items: Array<StoreItemType>): void;
61
59
  /**
62
60
  * Updates an item in the store
63
- * @param {string} key
64
- * @param {Partial<EntityTreeItemResponseModel>} data
61
+ * @param {string} id
62
+ * @param {Partial<StoreItemType>} data
65
63
  * @memberof UmbEntityTreeStore
66
64
  */
67
- updateItem(key: string, data: Partial<EntityTreeItemResponseModel>): void;
65
+ updateItem(unique: string, data: Partial<StoreItemType>): void;
68
66
  /**
69
67
  * Removes an item from the store
70
- * @param {string} key
68
+ * @param {string} id
71
69
  * @memberof UmbEntityTreeStore
72
70
  */
73
- removeItem(key: string): void;
71
+ removeItem(unique: string): void;
72
+ }
73
+
74
+ /**
75
+ * @export
76
+ * @class UmbEntityTreeStore
77
+ * @extends {UmbStoreBase}
78
+ * @description - Entity Tree Store
79
+ */
80
+ declare class UmbEntityTreeStore extends UmbStoreBase$1<EntityTreeItemResponseModel> implements UmbTreeStore$1<EntityTreeItemResponseModel> {
81
+ constructor(host: UmbControllerHostElement, storeAlias: string);
74
82
  /**
75
83
  * An observable to observe the root items
76
84
  * @memberof UmbEntityTreeStore
@@ -78,47 +86,28 @@ declare class UmbEntityTreeStore extends UmbStoreBase$1 implements UmbTreeStore$
78
86
  rootItems: rxjs.Observable<EntityTreeItemResponseModel[]>;
79
87
  /**
80
88
  * Returns an observable to observe the children of a given parent
81
- * @param {(string | null)} parentKey
89
+ * @param {(string | null)} parentId
82
90
  * @return {*}
83
91
  * @memberof UmbEntityTreeStore
84
92
  */
85
- childrenOf(parentKey: string | null): rxjs.Observable<EntityTreeItemResponseModel[]>;
93
+ childrenOf(parentId: string | null): rxjs.Observable<EntityTreeItemResponseModel[]>;
86
94
  /**
87
- * Returns an observable to observe the items with the given keys
88
- * @param {Array<string>} keys
95
+ * Returns an observable to observe the items with the given ids
96
+ * @param {Array<string>} ids
89
97
  * @return {*}
90
98
  * @memberof UmbEntityTreeStore
91
99
  */
92
- items(keys: Array<string>): rxjs.Observable<EntityTreeItemResponseModel[]>;
100
+ items(ids: Array<string | null>): rxjs.Observable<EntityTreeItemResponseModel[]>;
93
101
  }
94
102
 
95
103
  /**
96
104
  * @export
97
105
  * @class UmbFileSystemTreeStore
98
106
  * @extends {UmbStoreBase}
99
- * @description - General Tree Data Store
107
+ * @description - File System Tree Store
100
108
  */
101
- declare class UmbFileSystemTreeStore extends UmbStoreBase$1 implements UmbTreeStore$1<FileSystemTreeItemPresentationModel> {
102
- #private;
103
- /**
104
- * Appends items to the store
105
- * @param {Array<FileSystemTreeItemPresentationModel>} items
106
- * @memberof UmbFileSystemTreeStore
107
- */
108
- appendItems(items: Array<FileSystemTreeItemPresentationModel>): void;
109
- /**
110
- * Updates an item in the store
111
- * @param {string} path
112
- * @param {Partial<FileSystemTreeItemPresentationModel>} data
113
- * @memberof UmbFileSystemTreeStore
114
- */
115
- updateItem(path: string, data: Partial<FileSystemTreeItemPresentationModel>): void;
116
- /**
117
- * Removes an item from the store
118
- * @param {string} path
119
- * @memberof UmbFileSystemTreeStore
120
- */
121
- removeItem(path: string): void;
109
+ declare class UmbFileSystemTreeStore extends UmbStoreBase$1<FileSystemTreeItemPresentationModel> implements UmbTreeStore$1<FileSystemTreeItemPresentationModel> {
110
+ constructor(host: UmbControllerHostElement, storeAlias: string);
122
111
  /**
123
112
  * An observable to observe the root items
124
113
  * @memberof UmbFileSystemTreeStore
@@ -132,7 +121,7 @@ declare class UmbFileSystemTreeStore extends UmbStoreBase$1 implements UmbTreeSt
132
121
  */
133
122
  childrenOf(parentPath: string | null): rxjs.Observable<FileSystemTreeItemPresentationModel[]>;
134
123
  /**
135
- * Returns an observable to observe the items with the given keys
124
+ * Returns an observable to observe the items with the given ids
136
125
  * @param {Array<string>} paths
137
126
  * @return {*}
138
127
  * @memberof UmbFileSystemTreeStore
@@ -147,13 +136,19 @@ type TreeItemPresentationModel = {
147
136
  hasChildren?: boolean;
148
137
  };
149
138
 
150
- interface UmbTreeStore<T extends TreeItemPresentationModel = any> {
151
- appendItems: (items: Array<T>) => void;
152
- updateItem: (unique: string, item: Partial<T>) => void;
153
- removeItem: (unique: string) => void;
139
+ type ItemResponseModelBaseModel = {
140
+ name?: string;
141
+ id?: string;
142
+ };
143
+
144
+ interface UmbTreeStore<T extends TreeItemPresentationModel = any> extends UmbStore<T> {
154
145
  rootItems: Observable<Array<T>>;
155
146
  childrenOf: (parentUnique: string | null) => Observable<Array<T>>;
156
147
  items: (uniques: Array<string>) => Observable<Array<T>>;
157
148
  }
158
149
 
159
- export { UmbContentStore, UmbDataStore, UmbDataStoreIdentifiers, UmbEntityDetailStore, UmbEntityTreeStore, UmbFileSystemTreeStore, UmbStoreBase, UmbTreeStore };
150
+ interface UmbItemStore<T extends ItemResponseModelBaseModel = any> extends UmbStore<T> {
151
+ items: (uniques: Array<string>) => Observable<Array<T>>;
152
+ }
153
+
154
+ export { UmbContentStore, UmbDataStore, UmbDataStoreIdentifiers, UmbEntityDetailStore, UmbEntityTreeStore, UmbFileSystemTreeStore, UmbItemStore, UmbStoreBase, UmbTreeStore };
package/tree.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ interface UmbTreeRootModel {
2
+ type: string;
3
+ name: string;
4
+ hasChildren: boolean;
5
+ icon?: string;
6
+ }
7
+ interface UmbTreeRootEntityModel extends UmbTreeRootModel {
8
+ id: string | null;
9
+ }
10
+ interface UmbTreeRootFileSystemModel extends UmbTreeRootModel {
11
+ path: string | null;
12
+ }
13
+
14
+ export { UmbTreeRootEntityModel, UmbTreeRootFileSystemModel, UmbTreeRootModel };