@umbraco-cms/backoffice 1.0.0-next.b82f3242 → 1.0.0-next.ba26bec7

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/resources.d.ts CHANGED
@@ -1,25 +1,20 @@
1
1
  import { UmbNotificationOptions } from '@umbraco-cms/backoffice/notification';
2
- import { ProblemDetailsModel } from '@umbraco-cms/backoffice/backend-api';
3
2
  import { UmbController, UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
4
3
  import { DataSourceResponse as DataSourceResponse$1 } from '@umbraco-cms/backoffice/repository';
4
+ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
5
+ import { ApiError, CancelError } from '@umbraco-cms/backoffice/backend-api';
5
6
 
6
7
  declare class UmbResourceController extends UmbController {
7
8
  #private;
8
9
  constructor(host: UmbControllerHostElement, promise: Promise<any>, alias?: string);
9
10
  hostConnected(): void;
10
11
  hostDisconnected(): void;
11
- /**
12
- * Extract the ProblemDetailsModel object from an ApiError.
13
- *
14
- * This assumes that all ApiErrors contain a ProblemDetailsModel object in their body.
15
- */
16
- static toProblemDetailsModel(error: unknown): ProblemDetailsModel | undefined;
17
12
  /**
18
13
  * Base execute function with a try/catch block and return a tuple with the result and the error.
19
14
  */
20
15
  static tryExecute<T>(promise: Promise<T>): Promise<DataSourceResponse$1<T>>;
21
16
  /**
22
- * Wrap the {execute} function in a try/catch block and return the result.
17
+ * Wrap the {tryExecute} function in a try/catch block and return the result.
23
18
  * If the executor function throws an error, then show the details in a notification.
24
19
  */
25
20
  tryExecuteAndNotify<T>(options?: UmbNotificationOptions): Promise<DataSourceResponse$1<T>>;
@@ -38,15 +33,27 @@ declare class UmbResourceController extends UmbController {
38
33
  destroy(): void;
39
34
  }
40
35
 
36
+ /**
37
+ * The base URL of the configured Umbraco server.
38
+ * If the server is local, this will be an empty string.
39
+ *
40
+ * @remarks This is the base URL of the Umbraco server, not the base URL of the backoffice.
41
+ *
42
+ * @example https://localhost:44300
43
+ * @example https://my-umbraco-site.com
44
+ * @example ''
45
+ */
46
+ declare const UMB_SERVER_URL: UmbContextToken<string>;
47
+
41
48
  interface DataSourceResponse<T = undefined> extends UmbDataSourceErrorResponse {
42
49
  data?: T;
43
50
  }
44
51
  interface UmbDataSourceErrorResponse {
45
- error?: ProblemDetailsModel;
52
+ error?: ApiError | CancelError;
46
53
  }
47
54
 
48
55
  declare function tryExecute<T>(promise: Promise<T>): Promise<DataSourceResponse<T>>;
49
56
 
50
- declare function tryExecuteAndNotify<T>(host: UmbControllerHostElement, resource: Promise<T>, options?: UmbNotificationOptions<any>): Promise<DataSourceResponse<T>>;
57
+ declare function tryExecuteAndNotify<T>(host: UmbControllerHostElement, resource: Promise<T>, options?: UmbNotificationOptions): Promise<DataSourceResponse<T>>;
51
58
 
52
- export { UmbResourceController, tryExecute, tryExecuteAndNotify };
59
+ export { UMB_SERVER_URL, UmbResourceController, tryExecute, tryExecuteAndNotify };
package/router.d.ts CHANGED
@@ -22,7 +22,6 @@ type IRoutingInfo<D = any, P = any> = {
22
22
  };
23
23
  type CustomResolver<D = any, P = any> = ((info: IRoutingInfo<D>) => boolean | void | Promise<boolean> | Promise<void>);
24
24
  type Guard<D = any, P = any> = ((info: IRoutingInfo<D, P>) => boolean | Promise<boolean>);
25
- type Cancel = (() => boolean);
26
25
  type PageComponent = HTMLElement | undefined;
27
26
  type ModuleResolver = Promise<{
28
27
  default: any;
@@ -99,10 +98,6 @@ type Query = {
99
98
  [key: string]: string;
100
99
  };
101
100
  type EventListenerSubscription = (() => void);
102
- /**
103
- * RouterSlot related events.
104
- */
105
- type RouterSlotEvent = "changestate";
106
101
  /**
107
102
  * History related events.
108
103
  */
@@ -355,13 +350,6 @@ declare function toQueryString(query: Query): string;
355
350
  */
356
351
  declare function ensureAnchorHistory(): void;
357
352
 
358
- interface UmbRouteLocation {
359
- name?: string;
360
- params: {
361
- [key: string]: string;
362
- };
363
- }
364
-
365
353
  declare class UmbRouteContext {
366
354
  #private;
367
355
  private _onGotModals;
@@ -377,4 +365,4 @@ declare function generateRoutePathBuilder(path: string): (params: {
377
365
  [key: string]: string | number;
378
366
  }) => string;
379
367
 
380
- export { Cancel, ChangeStateEvent, Class, Component, CustomResolver, EventListenerSubscription, GlobalRouterEvent, Guard, IComponentRoute, IPathFragments, IRedirectRoute, IResolverRoute, IRoute, IRouteBase, IRouteMatch, IRouterSlot, IRoutingInfo, ISlashOptions, ModuleResolver, NavigationCancelEvent, NavigationEndEvent, NavigationErrorEvent, NavigationStartEvent, NavigationSuccessEvent, PageComponent, Params, PathFragment, PathMatch, PushStateEvent, Query, ReplaceStateEvent, RouterSlotEvent, RouterTree, Setup, UMB_ROUTE_CONTEXT_TOKEN, IRoute as UmbRoute, UmbRouteContext, UmbRouteLocation, WillChangeStateEvent, 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 };
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/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 };