@arcgis/lumina 5.2.0-next.2 → 5.2.0-next.21
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/{ControllerManager-DpJfvft9.js → ControllerManager-4cSEnB5Y.js} +12 -8
- package/dist/{Controller-Cer_6Z29.js → GenericController-C8NSb50b.js} +59 -23
- package/dist/LitElement.d.ts +179 -250
- package/dist/PublicLitElement.d.ts +64 -30
- package/dist/config.d.ts +22 -16
- package/dist/context.d.ts +24 -24
- package/dist/controllers/Controller.d.ts +106 -139
- package/dist/controllers/ControllerInternals.d.ts +33 -25
- package/dist/controllers/ControllerManager.d.ts +40 -61
- package/dist/controllers/GenericController.d.ts +26 -0
- package/dist/controllers/accessor/index.d.ts +6 -4
- package/dist/controllers/accessor/index.js +23 -5
- package/dist/controllers/accessor/reEmitEvent.d.ts +6 -3
- package/dist/controllers/accessor/store.d.ts +21 -14
- package/dist/controllers/accessor/useAccessor.d.ts +86 -68
- package/dist/controllers/functional.d.ts +11 -4
- package/dist/controllers/index.d.ts +35 -36
- package/dist/controllers/index.js +5 -7
- package/dist/controllers/load.d.ts +3 -2
- package/dist/controllers/proxyExports.d.ts +6 -5
- package/dist/controllers/toFunction.d.ts +4 -2
- package/dist/controllers/trackKey.d.ts +9 -4
- package/dist/controllers/trackPropKey.d.ts +8 -2
- package/dist/controllers/trackPropertyKey.d.ts +11 -6
- package/dist/controllers/types.d.ts +99 -170
- package/dist/controllers/useDirection.d.ts +5 -6
- package/dist/controllers/useMedia.d.ts +3 -2
- package/dist/controllers/usePropertyChange.d.ts +9 -10
- package/dist/controllers/useSlottableRequest.d.ts +15 -10
- package/dist/controllers/useT9n.d.ts +44 -38
- package/dist/controllers/useWatchAttributes.d.ts +6 -3
- package/dist/controllers/utils.d.ts +13 -5
- package/dist/createEvent.d.ts +32 -32
- package/dist/decorators.d.ts +16 -9
- package/dist/formAssociatedUtils.d.ts +5 -47
- package/dist/globalTypes/importMeta.d.ts +18 -10
- package/dist/globalTypes/index.d.ts +6 -4
- package/dist/globalTypes/jsxGlobals.d.ts +36 -23
- package/dist/globalTypes/loadLitCss.d.ts +61 -40
- package/dist/globalTypes/viteEnv.d.ts +60 -26
- package/dist/hmrSupport.d.ts +24 -28
- package/dist/index.d.ts +17 -16
- package/dist/index.js +27 -7
- package/dist/jsx/baseTypes.d.ts +26 -26
- package/dist/jsx/directives.d.ts +30 -42
- package/dist/jsx/generatedTypes.d.ts +3002 -2923
- package/dist/jsx/types.d.ts +214 -171
- package/dist/jsx/utils.d.ts +19 -14
- package/dist/lazyLoad.d.ts +31 -110
- package/dist/makeRuntime.d.ts +104 -127
- package/dist/{proxyExports-BkN6hND0.js → proxyExports-ZRLty8oJ.js} +1 -1
- package/dist/render.d.ts +4 -2
- package/dist/utils.d.ts +9 -14
- package/dist/wrappersUtils.d.ts +25 -26
- package/package.json +7 -4
- package/dist/devOnlyDetectIncorrectLazyUsages.d.ts +0 -14
- package/dist/lifecycleSupport.d.ts +0 -8
- package/dist/tests/wrappersUtils.typeTest.d.ts +0 -1
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type Accessor from "@arcgis/core/core/Accessor.js";
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* @param initializer
|
|
5
|
+
* @see https://webgis.esri.com/references/lumina/controllers/useAccessor#createstore-utility
|
|
4
6
|
*/
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
export function createStore<T extends object>(initializer: T | (() => T)): Accessor & T;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use [createStore()](https://developers.arcgis.com/javascript/latest/references/lumina/controllers/accessor/store/#createStore) instead
|
|
11
|
+
* @param defaultState
|
|
12
|
+
*/
|
|
13
|
+
export function createLegacyStore<T extends object>(defaultState: T | (() => T)): ObservableMap<T>;
|
|
14
|
+
|
|
15
|
+
/** @deprecated Use [createStore()](https://developers.arcgis.com/javascript/latest/references/lumina/controllers/accessor/store/#createStore) instead */
|
|
9
16
|
export type ObservableMap<T> = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
17
|
+
state: Accessor & T;
|
|
18
|
+
/** @deprecated Use state[propertyName] instead */
|
|
19
|
+
get: <P extends keyof T>(propName: P & string) => T[P];
|
|
20
|
+
/** @deprecated Use state[propertyName]=value instead */
|
|
21
|
+
set: <P extends keyof T>(propName: P & string, value: T[P]) => void;
|
|
22
|
+
/** @deprecated Use reactiveUtils.watch instead */
|
|
23
|
+
onChange: <Key extends keyof T>(propName: Key, callback: (newValue: T[Key]) => void) => () => void;
|
|
24
|
+
};
|
|
@@ -1,77 +1,95 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type coreAccessor from "@arcgis/core/core/Accessor.js";
|
|
2
|
+
import type { GenericController } from "../GenericController.js";
|
|
3
|
+
import type { LitElement } from "../../LitElement.js";
|
|
4
|
+
|
|
5
|
+
export type AccessorControllerRequires<Props, Accessor extends coreAccessor, OmitProps extends string = never> = LitElement
|
|
6
|
+
& Omit<Pick<Accessor, keyof Accessor & keyof Props>, AlwaysOmit | OmitProps>
|
|
7
|
+
& {
|
|
8
|
+
/** This must be present for the accessor instance to be garbage collected correctly */
|
|
9
|
+
autoDestroyDisabled: boolean;
|
|
10
|
+
/** This must be present for the accessor instance to be garbage collected correctly */
|
|
11
|
+
destroy: () => Promise<void>;
|
|
7
12
|
};
|
|
8
|
-
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* If Accessor class does not override constructor, constructor parameter will
|
|
16
|
+
* be "any". In such cases, all accessor properties are assumed to be required
|
|
17
|
+
* for binding. We add a few exceptions for well known built-in properties
|
|
18
|
+
*/
|
|
19
|
+
export type AlwaysOmit = "addHandles" | "declaredClass" | "destroyed" | "hasHandles" | "initialized" | "removeHandles" | "set" | "watch";
|
|
20
|
+
|
|
9
21
|
/**
|
|
10
22
|
* Given an Accessor class, create a controller that will do two-way binding of
|
|
11
23
|
* props between the component and the Accessor.
|
|
12
24
|
*
|
|
13
25
|
* See https://webgis.esri.com/references/lumina/controllers/useAccessor for
|
|
14
26
|
* documentation & examples.
|
|
27
|
+
*
|
|
28
|
+
* @param createInstance
|
|
29
|
+
* @param options
|
|
15
30
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* `makeAccessorController(..., { omitProps: ["propName"] })`, you can
|
|
37
|
-
* set it like this:
|
|
38
|
-
* `makeAccessorController(..., {} as { omitProps: ["propName"] })`
|
|
39
|
-
*/
|
|
40
|
-
omitProps: OmitProps[];
|
|
41
|
-
}) => (component: Requires<Props, Accessor, OmitProps>) => Accessor;
|
|
42
|
-
export declare class AccessorController<Props, Accessor extends coreAccessor, ExtraRequires = Record<never, never>> extends GenericController<Accessor, ExtraRequires & Requires<Props, Accessor>> {
|
|
43
|
-
#private;
|
|
44
|
-
protected instance: Accessor;
|
|
45
|
-
/**
|
|
46
|
-
* Use getAccessorControllerBoundProperties() helper to get access to this map
|
|
47
|
-
* @private
|
|
48
|
-
*/
|
|
49
|
-
_boundAccessorProperties: Map<string & keyof Accessor, string>;
|
|
50
|
-
/** @private */
|
|
51
|
-
_currentlyBindingPropertyName?: string;
|
|
52
|
-
/**
|
|
53
|
-
* (development only) Allow these props to mismatch the name of the Accessor's
|
|
54
|
-
* property to avoid collisions
|
|
55
|
-
*
|
|
56
|
-
* @private
|
|
57
|
-
*/
|
|
58
|
-
static devOnly$allowedPropNameMismatches?: ReadonlySet<string>;
|
|
59
|
-
get exports(): Accessor;
|
|
60
|
-
set exports(value: Accessor);
|
|
61
|
-
constructor(component: ExtraRequires & Requires<Props, Accessor>, createInstance: ((props?: Props) => Accessor) | (new (props?: Props) => Accessor));
|
|
62
|
-
/** @private */
|
|
63
|
-
_createAccessorInstance(): void;
|
|
64
|
-
hostConnected(): void;
|
|
65
|
-
hostDestroy(): void;
|
|
31
|
+
export function makeAccessorController<Props, Accessor extends coreAccessor, OmitProps extends string = never>(createInstance: ((props?: Props) => Accessor) | (new (props?: Props) => Accessor), options?: MakeAccessorControllerOptions<OmitProps>): ((component: AccessorControllerRequires<Props, Accessor, OmitProps>) => Accessor);
|
|
32
|
+
|
|
33
|
+
export interface MakeAccessorControllerOptions<OmitProps extends string> {
|
|
34
|
+
/**
|
|
35
|
+
* By default, to ensure that you didn't accidentally forget to bind any
|
|
36
|
+
* of the Accessor's properties on your component, every property that
|
|
37
|
+
* is accepted by the Accessor's constructor will be required to be bound
|
|
38
|
+
* on your component. If you do not wish to bind certain properties
|
|
39
|
+
* (or you wish to bind them but with a different type), you can omit
|
|
40
|
+
* them using this option.
|
|
41
|
+
*
|
|
42
|
+
* You can also bind the property to \@state rather than \@property if you
|
|
43
|
+
* wish to use it internally only:
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* \@State() timeZone = this.viewModel.timeZone;
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
omitProps: OmitProps[];
|
|
66
51
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
52
|
+
|
|
53
|
+
export class AccessorController<Props, Accessor extends coreAccessor, ExtraRequires = Record<never, never>> extends GenericController<Accessor, AccessorControllerRequires<Props, Accessor> & ExtraRequires> {
|
|
54
|
+
static devOnly$allowedPropNameMismatches?: ReadonlySet<string>;
|
|
55
|
+
constructor(component: AccessorControllerRequires<Props, Accessor> & ExtraRequires, createInstance: ((props?: Props) => Accessor) | (new (props?: Props) => Accessor));
|
|
56
|
+
/**
|
|
57
|
+
* Setting .exports set controller's exports property for usage with
|
|
58
|
+
* proxyExports() and marks the controller as ready for usage in other
|
|
59
|
+
* controllers. Also, this triggers re-render of the component.
|
|
60
|
+
*/
|
|
61
|
+
accessor exports: Accessor;
|
|
62
|
+
protected instance: Accessor;
|
|
63
|
+
/**
|
|
64
|
+
* If you subclass this controller and override this method, make sure to call
|
|
65
|
+
* super.hostConnected();
|
|
66
|
+
*/
|
|
67
|
+
hostConnected(): void;
|
|
68
|
+
/**
|
|
69
|
+
* If you subclass this controller and override this method, make sure to call
|
|
70
|
+
* super.hostDestroy();
|
|
71
|
+
*/
|
|
72
|
+
hostDestroy(): void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface MinimalAccessorController extends Pick<AccessorController<never, coreAccessor>, "exports"> {
|
|
76
|
+
component: LitElement;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param component
|
|
81
|
+
* @param accessorControllerRef
|
|
82
|
+
* @param accessorControllerIndex
|
|
83
|
+
* @param instance
|
|
84
|
+
* @param boundProperties
|
|
85
|
+
*/
|
|
86
|
+
export function makeBinderProxy(component: LitElement, accessorControllerRef: WeakRef<MinimalAccessorController & { constructor: MinimalAccessorController["constructor"] & { devOnly$allowedPropNameMismatches?: ReadonlySet<string>; }; }>, accessorControllerIndex: number, instance: coreAccessor, boundProperties: Map<string, string>): unknown;
|
|
87
|
+
|
|
88
|
+
/** @param controller */
|
|
89
|
+
export function getAccessorControllerBoundProperties<Accessor extends coreAccessor>(controller: AccessorController<unknown, Accessor>): Map<string & keyof Accessor, string>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param instance
|
|
93
|
+
* @param component
|
|
94
|
+
*/
|
|
95
|
+
export function reCreateAccessor(instance: coreAccessor, component: LitElement): void;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { LitElement } from
|
|
2
|
-
import { GenericControllerType
|
|
1
|
+
import type { LitElement } from "../LitElement.js";
|
|
2
|
+
import type { GenericControllerType } from "./GenericController.js";
|
|
3
|
+
import type { Controller } from "./Controller.js";
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Controller is a function that takes a component instance and then can
|
|
5
7
|
* export some values to the component, or hook into component's lifecycle
|
|
6
8
|
*
|
|
7
9
|
* See controllers documentation for many example controllers and their usages
|
|
10
|
+
*
|
|
11
|
+
* @param constructor
|
|
8
12
|
*/
|
|
9
|
-
export
|
|
13
|
+
export function makeController<Exports>(constructor: (component: LitElement, controller: Controller<Exports>) => Exports | Promise<Exports>): Exports;
|
|
14
|
+
|
|
10
15
|
/**
|
|
11
16
|
* If your controller requires some specific properties to be present on the
|
|
12
17
|
* component, besides what's included in the LitElement, use
|
|
@@ -15,5 +20,7 @@ export declare const makeController: <Exports>(constructor: (component: LitEleme
|
|
|
15
20
|
* When using a controller created using makeGenericController(), consumer must
|
|
16
21
|
* pass in "this" explicitly for proper type-checking. If controller was
|
|
17
22
|
* created using makeController(), that is not necessary
|
|
23
|
+
*
|
|
24
|
+
* @param constructor
|
|
18
25
|
*/
|
|
19
|
-
export
|
|
26
|
+
export function makeGenericController<Exports, Component = LitElement>(constructor: (component: Component & LitElement, controller: GenericControllerType<Exports, Component>) => Exports | Promise<Exports>): ((component: Component & LitElement) => Exports);
|
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
import { EventEmitter as _EventEmitter } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import type { EventEmitter as _EventEmitter } from "../createEvent.js";
|
|
2
|
+
import type { setAmbientComponent } from "./ControllerInternals.js";
|
|
3
|
+
import type { autoDestroyOnDisconnectTimeout, setAutoDestroyOnDisconnectTimeout } from "./ControllerManager.js";
|
|
4
|
+
|
|
5
|
+
export { type GenericControllerType } from "./GenericController.js";
|
|
6
|
+
export { GenericController } from "./GenericController.js";
|
|
7
|
+
export { Controller } from "./Controller.js";
|
|
8
|
+
export { type ControllerManager } from "./ControllerManager.js";
|
|
9
|
+
export { retrieveComponent, bypassReadOnly } from "./ControllerInternals.js";
|
|
10
|
+
export { trackPropertyKey, propertyTrackResolve } from "./trackPropertyKey.js";
|
|
11
|
+
export { trackPropKey } from "./trackPropKey.js";
|
|
12
|
+
export { trackKey } from "./trackKey.js";
|
|
13
|
+
export { makeController, makeGenericController } from "./functional.js";
|
|
14
|
+
export { useWatchAttributes } from "./useWatchAttributes.js";
|
|
15
|
+
export { load } from "./load.js";
|
|
16
|
+
export { proxyExports } from "./proxyExports.js";
|
|
17
|
+
export { toFunction } from "./toFunction.js";
|
|
18
|
+
export { useSlottableRequest } from "./useSlottableRequest.js";
|
|
19
|
+
export { controllerSymbol } from "./types.js";
|
|
20
|
+
export { type TrackKeyResolution, type Use, type ControllerLifecycleMethods, type BaseController, type LuminaPropertyDeclaration } from "./types.js";
|
|
21
|
+
export { useMedia } from "./useMedia.js";
|
|
22
|
+
export { useDirection } from "./useDirection.js";
|
|
23
|
+
export { type Direction } from "./useDirection.js";
|
|
24
|
+
export { type UseT9n, type T9nMeta } from "./useT9n.js";
|
|
25
|
+
export { makeT9nController } from "./useT9n.js";
|
|
26
|
+
export { usePropertyChange } from "./usePropertyChange.js";
|
|
27
|
+
export { isController, getControllersCount } from "./utils.js";
|
|
28
|
+
|
|
29
|
+
/** @deprecated import from "@arcgis/lumina" instead */
|
|
26
30
|
export type EventEmitter<T = undefined> = _EventEmitter<T>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
34
|
-
export declare const exportsForTests: {
|
|
35
|
-
setAmbientComponent: (component: import('../LitElement.ts').LitElement) => void;
|
|
36
|
-
autoDestroyOnDisconnectTimeout: number;
|
|
31
|
+
|
|
32
|
+
/** @internal */
|
|
33
|
+
export const exportsForTests: {
|
|
34
|
+
setAmbientComponent: typeof setAmbientComponent;
|
|
35
|
+
autoDestroyOnDisconnectTimeout: typeof autoDestroyOnDisconnectTimeout;
|
|
37
36
|
setAutoDestroyOnDisconnectTimeout: typeof setAutoDestroyOnDisconnectTimeout;
|
|
38
|
-
};
|
|
37
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { C as Controller, c as createEvent, t as trackKey, a as createEventFactory
|
|
2
|
-
import { G, b, d } from "../
|
|
1
|
+
import { C as Controller, c as createEvent, t as trackKey, a as createEventFactory } from "../GenericController-C8NSb50b.js";
|
|
2
|
+
import { G, p, b, d } from "../GenericController-C8NSb50b.js";
|
|
3
3
|
import { a as setAmbientComponent, i as isPromise, b as setParentController, d as retrieveParentControllers, r as retrieveComponent } from "../ControllerInternals-CeDntN3G.js";
|
|
4
4
|
import { e, c, g, f } from "../ControllerInternals-CeDntN3G.js";
|
|
5
|
-
import { p as proxyExports } from "../proxyExports-
|
|
5
|
+
import { p as proxyExports } from "../proxyExports-ZRLty8oJ.js";
|
|
6
6
|
import { isServer } from "lit";
|
|
7
7
|
import { isEsriInternalEnv } from "@arcgis/toolkit/error";
|
|
8
8
|
import { observeAncestorsMutation, getElementAttribute } from "@arcgis/toolkit/dom";
|
|
9
9
|
import { getElementLocale, startLocaleObserver } from "@arcgis/toolkit/intl";
|
|
10
|
-
import { s as setAutoDestroyOnDisconnectTimeout, b as autoDestroyOnDisconnectTimeout } from "../ControllerManager-
|
|
10
|
+
import { s as setAutoDestroyOnDisconnectTimeout, b as autoDestroyOnDisconnectTimeout } from "../ControllerManager-4cSEnB5Y.js";
|
|
11
11
|
const makeController = (constructor) => proxy(void 0, constructor);
|
|
12
12
|
const makeGenericController = (constructor) => (component) => proxy(
|
|
13
13
|
component,
|
|
@@ -296,7 +296,6 @@ const propertyChangeController = (...toWatch) => {
|
|
|
296
296
|
}
|
|
297
297
|
return eventEmitter;
|
|
298
298
|
};
|
|
299
|
-
const keyTrackResolve = propertyTrackResolve;
|
|
300
299
|
const exportsForTests = {
|
|
301
300
|
setAmbientComponent,
|
|
302
301
|
autoDestroyOnDisconnectTimeout,
|
|
@@ -310,12 +309,11 @@ export {
|
|
|
310
309
|
exportsForTests,
|
|
311
310
|
g as getControllersCount,
|
|
312
311
|
f as isController,
|
|
313
|
-
keyTrackResolve,
|
|
314
312
|
load,
|
|
315
313
|
makeController,
|
|
316
314
|
makeGenericController,
|
|
317
315
|
makeT9nController,
|
|
318
|
-
propertyTrackResolve,
|
|
316
|
+
p as propertyTrackResolve,
|
|
319
317
|
proxyExports,
|
|
320
318
|
retrieveComponent,
|
|
321
319
|
toFunction,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Load a value from a promise and provide it to the component
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* @param loader
|
|
5
|
+
* @see https://webgis.esri.com/references/lumina/controllers/load
|
|
5
6
|
*/
|
|
6
|
-
export
|
|
7
|
+
export function load<T>(loader: () => Promise<T>): T;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Controller } from
|
|
2
|
-
import { ControllerLifecycleMethods } from
|
|
1
|
+
import type { Controller } from "./Controller.js";
|
|
2
|
+
import type { ControllerLifecycleMethods } from "./types.js";
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* If you wish to directly expose the "exports" property of your controller,
|
|
5
6
|
* rather than the entire controller class, wrap your class definition in
|
|
@@ -12,16 +13,16 @@ import { ControllerLifecycleMethods } from './types.ts';
|
|
|
12
13
|
* "proxyExports" is the default behavior for all controllers declared using
|
|
13
14
|
* the makeController()/makeGenericController() function
|
|
14
15
|
*
|
|
15
|
-
* @remarks
|
|
16
16
|
* If using readonly(), and controller updates its exports, the readonly prop
|
|
17
17
|
* will still get updated
|
|
18
18
|
*
|
|
19
|
-
* @remarks
|
|
20
19
|
* (Advanced) If you wish to use proxyExports() in a class that does not
|
|
21
20
|
* extend Controller class and does not have a useControllerManager(), then your
|
|
22
21
|
* class must subclass a class with the following constructor:
|
|
23
22
|
* `constructor() { setAmbientController(this); }`. This
|
|
24
23
|
* is necessary for proxyExports() to receive a reference to your object
|
|
25
24
|
* implicitly, and before any of your default values are assigned.
|
|
25
|
+
*
|
|
26
|
+
* @param Class
|
|
26
27
|
*/
|
|
27
|
-
export
|
|
28
|
+
export function proxyExports<Exports, const Parameters extends unknown[]>(Class: new (...args: Parameters) => ControllerLifecycleMethods & Pick<Controller<Exports>, "component" | "exports" | "onUpdate" | "watchExports">): ((...args: Parameters) => Exports);
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Main advantage of this is that it's a bit shorter to type.
|
|
4
4
|
*
|
|
5
5
|
* This utility can be used for converting non-controller classes to functions
|
|
6
|
-
* too
|
|
6
|
+
* too.
|
|
7
|
+
*
|
|
8
|
+
* @param Class
|
|
7
9
|
*/
|
|
8
|
-
export
|
|
10
|
+
export function toFunction<T, const P extends unknown[]>(Class: new (...args: P) => T): ((...args: P) => T);
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { LitElement } from
|
|
2
|
-
import { BaseController, TrackKeyResolution } from
|
|
1
|
+
import type { LitElement } from "../LitElement.js";
|
|
2
|
+
import type { BaseController, TrackKeyResolution } from "./types.js";
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* A combination of trackPropertyKey() and trackPropKey(). For usage when
|
|
5
6
|
* you want to track a property, but don't know if it will be defined with the
|
|
6
|
-
* \@property() decorator or not
|
|
7
|
+
* \@property() decorator or not.
|
|
8
|
+
*
|
|
9
|
+
* @param hostsCandidates
|
|
10
|
+
* @param onResolved
|
|
11
|
+
* @param defaultValue
|
|
7
12
|
*/
|
|
8
|
-
export
|
|
13
|
+
export function trackKey<T>(hostsCandidates: (BaseController | LitElement)[] | BaseController | LitElement | undefined, onResolved: (resolution: TrackKeyResolution | undefined) => void, defaultValue: T): T;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { LitElement } from
|
|
1
|
+
import type { LitElement } from "../LitElement.js";
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Like trackPropertyKey(), but for props that have \@state() or \@property()
|
|
4
5
|
* decorator
|
|
5
6
|
*
|
|
7
|
+
* @param component
|
|
8
|
+
* @param onResolved
|
|
9
|
+
* @param defaultValue
|
|
6
10
|
* @example
|
|
11
|
+
* ```ts
|
|
7
12
|
* function trackMe() {
|
|
8
13
|
* const component = retrieveComponent();
|
|
9
14
|
* const defaultValue = 'some value';
|
|
@@ -17,5 +22,6 @@ import { LitElement } from '../LitElement.ts';
|
|
|
17
22
|
* // Will console log "myState"
|
|
18
23
|
* \@state() myState = trackMe();
|
|
19
24
|
* }
|
|
25
|
+
* ```
|
|
20
26
|
*/
|
|
21
|
-
export
|
|
27
|
+
export function trackPropKey<T>(component: LitElement, onResolved: (key: string | undefined) => void, defaultValue: T): T;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { LitElement } from
|
|
2
|
-
import { BaseController } from
|
|
1
|
+
import type { LitElement } from "../LitElement.js";
|
|
2
|
+
import type { BaseController } from "./types.js";
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* A magical solution to finding out what property name a given controller
|
|
5
6
|
* on a given object was assigned to.
|
|
6
7
|
*
|
|
7
|
-
* @remarks
|
|
8
8
|
* This does not work for properties that have \@property() or \@state()
|
|
9
9
|
* decorator - for those, use trackPropKey() instead.
|
|
10
10
|
*
|
|
11
|
+
* @param object
|
|
12
|
+
* @param onResolved
|
|
13
|
+
* @param defaultValue
|
|
11
14
|
* @example
|
|
15
|
+
* ```ts
|
|
12
16
|
* function trackMe<T>(defaultValue: T, component: LitElement):T {
|
|
13
17
|
* trackPropertyKey(component, (key)=>console.log(key), defaultValue);
|
|
14
18
|
* return defaultValue;
|
|
@@ -18,12 +22,13 @@ import { BaseController } from './types.ts';
|
|
|
18
22
|
* // Will console log "myProp"
|
|
19
23
|
* myProp = trackMe('a', this);
|
|
20
24
|
* }
|
|
21
|
-
*
|
|
25
|
+
* ```
|
|
22
26
|
*/
|
|
23
|
-
export
|
|
27
|
+
export function trackPropertyKey<T>(object: BaseController | LitElement, onResolved: (key: string | undefined) => void, defaultValue: T): T;
|
|
28
|
+
|
|
24
29
|
/**
|
|
25
30
|
* Resolve all pending trackPropertyKey() calls. This must be called after a
|
|
26
31
|
* property you are trying to resolve had it's default value set, thus after
|
|
27
32
|
* constructor. At the start of connectedCallback is a perfect place.
|
|
28
33
|
*/
|
|
29
|
-
export
|
|
34
|
+
export function propertyTrackResolve(): void;
|