@arcgis/lumina 4.33.0-next.97 → 4.33.0-next.99
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/{useWatch-CFtSpNnN.js → Controller-CZ8Djohh.js} +70 -368
- package/dist/LitElement.d.ts +33 -25
- package/dist/context.d.ts +12 -2
- package/dist/controllers/Controller.d.ts +18 -17
- package/dist/controllers/ControllerInternals.d.ts +19 -12
- package/dist/controllers/ControllerManager.d.ts +62 -42
- package/dist/controllers/accessor/index.js +12 -60
- package/dist/controllers/accessor/reEmitEvent.d.ts +1 -5
- package/dist/controllers/accessor/useAccessor.d.ts +6 -7
- package/dist/controllers/functional.d.ts +4 -4
- package/dist/controllers/index.d.ts +6 -5
- package/dist/controllers/index.js +35 -55
- package/dist/controllers/proxyExports.d.ts +1 -1
- package/dist/controllers/trackKey.d.ts +4 -4
- package/dist/controllers/trackPropKey.d.ts +6 -6
- package/dist/controllers/trackPropertyKey.d.ts +8 -7
- package/dist/controllers/types.d.ts +15 -45
- package/dist/controllers/usePropertyChange.d.ts +4 -3
- package/dist/controllers/useT9n.d.ts +1 -1
- package/dist/createEvent.d.ts +7 -2
- package/dist/hmrSupport.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +331 -14
- package/dist/lazyLoad.d.ts +14 -14
- package/dist/proxyExports-CK5BLFLO.js +60 -0
- package/dist/{utils-GhKD5Lo-.js → utils-DBdf1Dqp.js} +4 -12
- package/package.json +2 -2
- package/dist/ControllerManager-B2comd8J.js +0 -310
- package/dist/controllers/ComponentInternals.d.ts +0 -92
- package/dist/controllers/framework.d.ts +0 -45
- package/dist/controllers/getSet.d.ts +0 -116
- package/dist/controllers/readonly.d.ts +0 -29
- package/dist/controllers/useWatch.d.ts +0 -27
- package/dist/proxyExports-Dl5CHmHQ.js +0 -150
package/dist/LitElement.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { CSSResultGroup, CSSResultOrNative, PropertyValues, LitElement as OriginalLitElement } from 'lit';
|
|
1
|
+
import { CSSResultGroup, CSSResultOrNative, PropertyValues, ReactiveController, LitElement as OriginalLitElement } from 'lit';
|
|
2
2
|
import { Runtime } from './makeRuntime';
|
|
3
3
|
import { ProxyComponent } from './lazyLoad';
|
|
4
4
|
import { ToElement } from './jsx/types';
|
|
5
|
-
import { LuminaPropertyDeclaration } from './controllers/types';
|
|
5
|
+
import { BaseController, LuminaPropertyDeclaration } from './controllers/types';
|
|
6
|
+
import { ControllerManager } from './controllers/ControllerManager';
|
|
7
|
+
import { Controller } from './controllers/Controller';
|
|
6
8
|
type ComponentLifecycle = {
|
|
7
9
|
connectedCallback?: () => void;
|
|
8
10
|
disconnectedCallback?: () => void;
|
|
@@ -32,7 +34,7 @@ type ComponentLifecycle = {
|
|
|
32
34
|
* only.
|
|
33
35
|
*/
|
|
34
36
|
export declare class LitElement extends OriginalLitElement implements ComponentLifecycle {
|
|
35
|
-
/** @
|
|
37
|
+
/** @private */
|
|
36
38
|
static runtime: Runtime;
|
|
37
39
|
static tagName: string;
|
|
38
40
|
/**
|
|
@@ -53,7 +55,7 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
|
|
|
53
55
|
* loading logic calls document.createElement(), it temporary sets this static
|
|
54
56
|
* property.
|
|
55
57
|
*
|
|
56
|
-
* @
|
|
58
|
+
* @private
|
|
57
59
|
* */
|
|
58
60
|
static lazy: ProxyComponent | undefined;
|
|
59
61
|
static readonly lumina = true;
|
|
@@ -77,43 +79,35 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
|
|
|
77
79
|
* const isLazy = this.el !== this;
|
|
78
80
|
* ```
|
|
79
81
|
*/
|
|
80
|
-
el: ToElement<this>;
|
|
82
|
+
readonly el: ToElement<this>;
|
|
81
83
|
/**
|
|
82
|
-
* Controller
|
|
83
|
-
*
|
|
84
|
+
* Controller does not need to be an instance of the Controller class. Any
|
|
85
|
+
* Lit's Reactive controller will work as well. See examples:
|
|
86
|
+
* https://lit.dev/docs/composition/controllers/
|
|
87
|
+
*
|
|
88
|
+
* @private
|
|
84
89
|
*/
|
|
85
|
-
|
|
90
|
+
readonly _controllers: Set<BaseController | Controller<unknown>>;
|
|
86
91
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* Do not access this directly as this value is only set during the update
|
|
91
|
-
* lifecycle. Instead, use the `changes` property that is provided
|
|
92
|
-
* to the shouldUpdate(), willUpdate() and didUpdate() lifecycle hooks.
|
|
93
|
-
*
|
|
94
|
-
* @internal
|
|
95
|
-
*
|
|
96
|
-
* @remarks
|
|
97
|
-
* The name does not start with `_` because in the future we may configure the
|
|
98
|
-
* minifier to mangle such properties - but this property is accessed from
|
|
99
|
-
* outside this package, so should not be mangled.
|
|
92
|
+
* Controller Manager orchestrates all controllers used by this component,
|
|
93
|
+
* connecting their lifecycle hooks and providing context information.
|
|
100
94
|
*/
|
|
101
|
-
|
|
102
|
-
/** @
|
|
95
|
+
readonly manager: ControllerManager;
|
|
96
|
+
/** @private */
|
|
103
97
|
_postLoad: ProxyComponent["_postLoad"];
|
|
104
98
|
/**
|
|
105
99
|
* Direct offspring that should be awaited before loaded() is emitted.
|
|
106
100
|
*
|
|
107
101
|
* `attachToAncestor()` will add elements to this array
|
|
108
102
|
*
|
|
109
|
-
* @
|
|
103
|
+
* @private
|
|
110
104
|
*/
|
|
111
105
|
_offspring: ProxyComponent["_offspring"];
|
|
112
106
|
/**
|
|
113
107
|
* Promise that resolves once parent's load() completed. False if there is no
|
|
114
108
|
* parent
|
|
115
109
|
*
|
|
116
|
-
* @
|
|
110
|
+
* @private
|
|
117
111
|
*/
|
|
118
112
|
_ancestorLoad: ProxyComponent["_ancestorLoad"];
|
|
119
113
|
private _originalShouldUpdate?;
|
|
@@ -228,6 +222,20 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
|
|
|
228
222
|
* });
|
|
229
223
|
*/
|
|
230
224
|
componentOnReady(): Promise<this>;
|
|
225
|
+
/**
|
|
226
|
+
* Adds a controller to the host, which connects the controller's lifecycle
|
|
227
|
+
* methods to the host's lifecycle.
|
|
228
|
+
*
|
|
229
|
+
* @remarks
|
|
230
|
+
* Even though Lit's LitElement already has addController,
|
|
231
|
+
* we overwrite it with a compatible version to have more control over
|
|
232
|
+
* timing, and to add support for load/loaded lifecycle hooks.
|
|
233
|
+
*/
|
|
234
|
+
addController(controller: BaseController | ReactiveController): void;
|
|
235
|
+
/**
|
|
236
|
+
* Removes a controller from the host.
|
|
237
|
+
*/
|
|
238
|
+
removeController(controller: BaseController | ReactiveController): void;
|
|
231
239
|
}
|
|
232
240
|
type Listener<ThisType, EventType> = ((this: ThisType, event: EventType) => unknown) | {
|
|
233
241
|
handleEvent(event: EventType): unknown;
|
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContextConsumer, ContextProvider, Context, ContextType } from '@lit/context';
|
|
2
|
-
import {
|
|
2
|
+
import { ReactiveControllerHost } from 'lit';
|
|
3
3
|
interface ContextProviderOptions<C extends Context<unknown, unknown>> {
|
|
4
4
|
context: C;
|
|
5
5
|
initialValue?: ContextType<C>;
|
|
@@ -22,5 +22,15 @@ export declare function useContextProvider<C extends Context<unknown, unknown>>(
|
|
|
22
22
|
*
|
|
23
23
|
* FEATURE: wrap this in proxyExports to improve DX, or keep it simple?
|
|
24
24
|
*/
|
|
25
|
-
export declare function useContextConsumer<C extends Context<unknown, unknown>>(options: ContextConsumerOptions<C>): ContextConsumer<C,
|
|
25
|
+
export declare function useContextConsumer<C extends Context<unknown, unknown>>(options: ContextConsumerOptions<C>): ContextConsumer<C, LitContextHost>;
|
|
26
|
+
/**
|
|
27
|
+
* Lit context wasn't written with lazy loading proxy in mind. For it to
|
|
28
|
+
* work correctly, we must provide the DOM-attached element as the host element.
|
|
29
|
+
* Events will be fired/listened on it.
|
|
30
|
+
*
|
|
31
|
+
* At the same time, .addController() and .requestUpdate() methods will be
|
|
32
|
+
* called on it. We had to implement these on the lazy proxy to redirect the
|
|
33
|
+
* calls to the actual LitElement.
|
|
34
|
+
*/
|
|
35
|
+
type LitContextHost = HTMLElement & ReactiveControllerHost;
|
|
26
36
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Deferred } from '@arcgis/components-utils';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseController, ControllerLifecycleMethods, controllerSymbol } from './types';
|
|
3
3
|
import { use, useRef, useRefSync } from './ControllerInternals';
|
|
4
4
|
import { PropertyValues } from 'lit';
|
|
5
|
+
import { LitElement } from '../LitElement';
|
|
5
6
|
/**
|
|
6
7
|
* Base class for Controllers defined using a class rather than a function.
|
|
7
8
|
* Defining controller using makeController() function is more succinct for smaller
|
|
@@ -16,15 +17,15 @@ export declare abstract class Controller<Exports = never> implements BaseControl
|
|
|
16
17
|
};
|
|
17
18
|
protected _ready: Deferred<Exports>;
|
|
18
19
|
private _lifecycleCleanups;
|
|
19
|
-
/** @
|
|
20
|
+
/** @private */
|
|
20
21
|
assignedProperty?: string | false;
|
|
21
22
|
connectedCalled: boolean;
|
|
22
23
|
protected _loadCalled: boolean;
|
|
23
24
|
loadedCalled: boolean;
|
|
24
25
|
readonly [controllerSymbol] = true;
|
|
25
|
-
component:
|
|
26
|
+
component: LitElement;
|
|
26
27
|
ready: Promise<Exports>;
|
|
27
|
-
constructor(component?:
|
|
28
|
+
constructor(component?: LitElement);
|
|
28
29
|
/**
|
|
29
30
|
* If controller is being added dynamically, after the component
|
|
30
31
|
* construction, then trigger connected and load right away
|
|
@@ -97,7 +98,7 @@ export declare abstract class Controller<Exports = never> implements BaseControl
|
|
|
97
98
|
/**
|
|
98
99
|
* Like useRef, but doesn't wait for the controller to get ready
|
|
99
100
|
*
|
|
100
|
-
* @
|
|
101
|
+
* @private
|
|
101
102
|
*/
|
|
102
103
|
get useRefSync(): typeof useRefSync;
|
|
103
104
|
controllerRemoved(): void;
|
|
@@ -109,31 +110,31 @@ export declare abstract class Controller<Exports = never> implements BaseControl
|
|
|
109
110
|
onUpdated(callback: NonNullable<ControllerLifecycleMethods["hostUpdated"]>): void;
|
|
110
111
|
onDestroy(callback: NonNullable<ControllerLifecycleMethods["hostDestroy"]>): void;
|
|
111
112
|
onLifecycle(callback: NonNullable<ControllerLifecycleMethods["hostLifecycle"]>): void;
|
|
112
|
-
/** @
|
|
113
|
+
/** @private */
|
|
113
114
|
triggerConnected(): void;
|
|
114
|
-
/** @
|
|
115
|
+
/** @private */
|
|
115
116
|
triggerDisconnected(): void;
|
|
116
|
-
/** @
|
|
117
|
+
/** @private */
|
|
117
118
|
triggerLoad(): Promise<void>;
|
|
118
|
-
/** @
|
|
119
|
+
/** @private */
|
|
119
120
|
triggerLoaded(): void;
|
|
120
|
-
/** @
|
|
121
|
+
/** @private */
|
|
121
122
|
triggerUpdate(changes: PropertyValues): void;
|
|
122
|
-
/** @
|
|
123
|
+
/** @private */
|
|
123
124
|
triggerUpdated(changes: PropertyValues): void;
|
|
124
|
-
/** @
|
|
125
|
+
/** @private */
|
|
125
126
|
triggerDestroy(): void;
|
|
126
|
-
/** @
|
|
127
|
+
/** @private */
|
|
127
128
|
triggerLifecycle(): void;
|
|
128
129
|
private _callLifecycle;
|
|
129
130
|
}
|
|
130
|
-
export declare abstract class GenericControllerType<Exports, Requires =
|
|
131
|
-
component:
|
|
132
|
-
constructor(component:
|
|
131
|
+
export declare abstract class GenericControllerType<Exports, Requires = LitElement> extends Controller<Exports> {
|
|
132
|
+
component: LitElement & Requires;
|
|
133
|
+
constructor(component: LitElement & Requires);
|
|
133
134
|
}
|
|
134
135
|
/**
|
|
135
136
|
* If your controller requires some specific properties to be present on the
|
|
136
|
-
* component, besides what's included in
|
|
137
|
+
* component, besides what's included in LitElement, use
|
|
137
138
|
* GenericController over the usual Controller. Use the 2nd generic argument
|
|
138
139
|
* on this class for specifying what properties your controller expects on the
|
|
139
140
|
* component
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Controller } from './Controller';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
2
|
+
import { BaseController } from './types';
|
|
3
|
+
import { LitElement } from '../LitElement';
|
|
4
|
+
export declare function setAmbientComponent(component: LitElement): void;
|
|
5
|
+
export declare function retrieveComponent(name?: string): LitElement;
|
|
5
6
|
export declare function setParentController(controller: BaseController | undefined): void;
|
|
6
7
|
/**
|
|
7
8
|
* Get references to controllers this nested controller might have been called
|
|
@@ -17,17 +18,23 @@ export declare function setAmbientChildController(controller: BaseController | u
|
|
|
17
18
|
export declare const use: <Value>(value: Value, watchExports?: (value: NotNever<InferController<Value>>, unsubscribe: () => void) => void) => Promise<NotNever<InferController<Value>>>;
|
|
18
19
|
export declare const useRef: <Value>(value: Value) => Promise<InferController<Value>>;
|
|
19
20
|
export declare const useRefSync: <Value>(value: Value) => InferController<Value> | undefined;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
readOnly: boolean;
|
|
24
|
-
};
|
|
21
|
+
/** @deprecated */
|
|
22
|
+
export declare let shouldBypassGetter: boolean;
|
|
23
|
+
export declare let shouldBypassReadOnly: boolean;
|
|
25
24
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
* Permits updating read-only properties
|
|
26
|
+
*
|
|
27
|
+
* @see https://qawebgis.esri.com/components/lumina/properties#read-only-properties
|
|
28
|
+
*/
|
|
29
|
+
export declare function bypassReadOnly<T = void>(callback: () => T): T | void;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
|
|
32
|
+
*/
|
|
33
|
+
export declare const bypassSetter: typeof bypassReadOnly;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
|
|
29
36
|
*/
|
|
30
|
-
export declare
|
|
37
|
+
export declare function bypassGetter<T = void>(callback: () => T): T | void;
|
|
31
38
|
/**
|
|
32
39
|
* If passed value is a controller, then return it. Otherwise, assume it's a
|
|
33
40
|
* proxyExports() result and wrap it into a controller
|
|
@@ -1,63 +1,83 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseController } from './types';
|
|
2
2
|
import { GenericController } from './Controller';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
* Using "new ControllerManager(this)" inside a component causes this TypeScript
|
|
6
|
-
* error:
|
|
7
|
-
* 'manager' implicitly has type 'any' because it does not have a type
|
|
8
|
-
* annotation and is referenced directly or indirectly in its own initializer.
|
|
9
|
-
*
|
|
10
|
-
* This function fixes that, and it's also a bit shorter to type
|
|
11
|
-
*
|
|
12
|
-
* @deprecated Lumina packages should not need to call this directly
|
|
13
|
-
*/
|
|
14
|
-
export declare const useControllerManager: (component: BaseComponent) => ControllerManager;
|
|
3
|
+
import { PropertyValues } from 'lit';
|
|
4
|
+
import { LitElement } from '../LitElement';
|
|
15
5
|
/**
|
|
16
6
|
* A manager for all other controllers. It finds all controllers on the
|
|
17
7
|
* component, loads them, and forwards lifecycle events to them.
|
|
18
8
|
*/
|
|
19
9
|
export declare class ControllerManager extends GenericController<undefined> {
|
|
20
|
-
private readonly _controllers;
|
|
21
|
-
/** @internal */
|
|
22
|
-
readonly internals: ComponentInternals;
|
|
23
10
|
hasDestroy: boolean;
|
|
24
11
|
destroyed: boolean;
|
|
25
|
-
private _updatePromise;
|
|
26
12
|
private _autoDestroyTimeout?;
|
|
27
|
-
|
|
28
|
-
* If true, indicates that ControllerManager is running against a Lit component.
|
|
29
|
-
* Otherwise, means we are running against a Stencil component.
|
|
30
|
-
*/
|
|
31
|
-
readonly isLit: boolean;
|
|
32
|
-
constructor(component: BaseComponent);
|
|
33
|
-
private _originalLifecycles;
|
|
34
|
-
private _bindLifecycleMethods;
|
|
13
|
+
constructor(component: LitElement);
|
|
35
14
|
/**
|
|
36
15
|
* Throws an error if component does not implement destroy() lifecycle, but
|
|
37
16
|
* tries to use it. This check is only present in development mode
|
|
17
|
+
*
|
|
18
|
+
* @private
|
|
38
19
|
*/
|
|
39
|
-
|
|
20
|
+
_ensureHasDestroy?: () => void;
|
|
21
|
+
destroy(): Promise<void>;
|
|
22
|
+
/** @private */
|
|
23
|
+
_setAutoDestroyTimeout(): void;
|
|
24
|
+
/**
|
|
25
|
+
* "readOnly" is not enabled initially since we need to allow to set property
|
|
26
|
+
* default values in the constructor.
|
|
27
|
+
*/
|
|
28
|
+
private _enforceReadonly;
|
|
29
|
+
/** @private */
|
|
30
|
+
_trackedValue: unknown;
|
|
31
|
+
/** @private */
|
|
32
|
+
_keyTrackers: ((key: string | undefined, value: unknown) => void)[];
|
|
33
|
+
/** @private */
|
|
34
|
+
_firePropTrackers(key: string | undefined, value: unknown): void;
|
|
35
|
+
/** @private */
|
|
36
|
+
readonly _accessorGetter: Record<string, (value: unknown, propertyName: string) => unknown>;
|
|
37
|
+
/** @private */
|
|
38
|
+
readonly _accessorSetter: Record<string, (newValue: unknown, oldValue: unknown, propertyName: string) => unknown>;
|
|
40
39
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
40
|
+
* Map with keys for any properties that have changed since the last
|
|
41
|
+
* update cycle with previous values.
|
|
42
|
+
*
|
|
43
|
+
* Do not access this directly as this value is only set during the update
|
|
44
|
+
* lifecycle. Instead, use the `changes` property that is provided
|
|
45
|
+
* to the shouldUpdate(), willUpdate() and updated() lifecycle hooks.
|
|
44
46
|
*
|
|
45
|
-
* @
|
|
47
|
+
* @private
|
|
46
48
|
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
_changes?: PropertyValues;
|
|
50
|
+
/**
|
|
51
|
+
* Configure a getter or setter for a given \@property/\@state
|
|
52
|
+
*
|
|
53
|
+
* Since props are defined on the prototype, they are shared between all
|
|
54
|
+
* instances of a component. Thus, instead of passing a reference to the
|
|
55
|
+
* getter/setter function, you should update the
|
|
56
|
+
* ComponentInternals.getters/setters properties, and then call getSetProxy
|
|
57
|
+
* to apply the changes to the prototype
|
|
58
|
+
*
|
|
59
|
+
* @deprecated
|
|
60
|
+
*/
|
|
61
|
+
private _getSetProxy;
|
|
62
|
+
private _exportsStore;
|
|
63
|
+
/**
|
|
64
|
+
* Associate an exports object with a controller for reverse lookup in
|
|
65
|
+
* controller.use
|
|
66
|
+
*
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
_markExports(controller: BaseController, exports: unknown): void;
|
|
70
|
+
/** @private */
|
|
71
|
+
_resolveExports(exports: unknown): BaseController | undefined;
|
|
58
72
|
}
|
|
59
73
|
export declare let autoDestroyOnDisconnectTimeout: number;
|
|
74
|
+
export declare const autoDestroyDisabledPropName = "autoDestroyDisabled";
|
|
60
75
|
export declare const exportsForTests: {
|
|
61
76
|
setAutoDestroyOnDisconnectTimeout: (timeout: number) => void;
|
|
62
77
|
} | undefined;
|
|
63
|
-
export
|
|
78
|
+
export type LuminaLifecycles = {
|
|
79
|
+
connectedCallback?: LitElement["connectedCallback"];
|
|
80
|
+
disconnectedCallback?: LitElement["disconnectedCallback"];
|
|
81
|
+
load?: () => Promise<void> | void;
|
|
82
|
+
loaded?: () => void;
|
|
83
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { p as proxyExports
|
|
3
|
-
import { isEsriInternalEnv
|
|
4
|
-
import {
|
|
1
|
+
import { p as devOnlySetPersistentControllerData, q as devOnlyGetPersistentControllerData, G as GenericController, n as trackPropKey, h as bypassGetter, l as bypassReadOnly, t as trackKey, r as retrieveComponent, g as createEventFactory } from "../../Controller-CZ8Djohh.js";
|
|
2
|
+
import { p as proxyExports } from "../../proxyExports-CK5BLFLO.js";
|
|
3
|
+
import { isEsriInternalEnv } from "@arcgis/components-utils";
|
|
4
|
+
import { watch, on } from "@arcgis/core/core/reactiveUtils.js";
|
|
5
5
|
const makeAccessorController = (loadAccessor, _options) => (component, options) => proxy(component, loadAccessor, options);
|
|
6
6
|
class AccessorController extends GenericController {
|
|
7
7
|
constructor(component, _loadAccessor, _options) {
|
|
@@ -103,11 +103,6 @@ const accessorSupport = {
|
|
|
103
103
|
return value;
|
|
104
104
|
}
|
|
105
105
|
if (watchedProperties.has(prop)) {
|
|
106
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !component.manager.isLit) {
|
|
107
|
-
throw new Error(
|
|
108
|
-
`Tried to bind "${prop.toString()}" prop twice. This might also happen if you are trying to access the accessor instance before ${component.manager.isLit ? "load" : "componentWillLoad"}()`
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
106
|
return;
|
|
112
107
|
}
|
|
113
108
|
return trackKey(
|
|
@@ -115,12 +110,7 @@ const accessorSupport = {
|
|
|
115
110
|
(resolved) => {
|
|
116
111
|
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
117
112
|
if (resolved === void 0) {
|
|
118
|
-
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
throw new Error(
|
|
122
|
-
`Unable to resolve what property is "${prop.toString()}" being bound too. Check documentation for useAccessor to ensure proper usage. Make sure you are not trying to access the accessor instance before ${component.manager.isLit ? "load" : "componentWillLoad"}()`
|
|
123
|
-
);
|
|
113
|
+
return;
|
|
124
114
|
}
|
|
125
115
|
const isFlippingBoolean = resolved.key.toLowerCase().includes("disable");
|
|
126
116
|
const collidesWithNativeProp = prop in HTMLElement.prototype;
|
|
@@ -132,7 +122,7 @@ const accessorSupport = {
|
|
|
132
122
|
}
|
|
133
123
|
if (!resolved.isReactive) {
|
|
134
124
|
throw new Error(
|
|
135
|
-
|
|
125
|
+
`For two-way binding with Accessor to work, the property on your component must have @property() or @state() decorator. "${prop.toString()}" has neither`
|
|
136
126
|
);
|
|
137
127
|
}
|
|
138
128
|
}
|
|
@@ -157,7 +147,7 @@ const accessorSupport = {
|
|
|
157
147
|
const propertyName = watchedProperties.get(propName);
|
|
158
148
|
const value = instance[propertyName];
|
|
159
149
|
const flipBoolean = typeof value === "boolean" && propertyName !== propName && propName.toLowerCase().includes("disable");
|
|
160
|
-
const currentValue = flipBoolean ? !value :
|
|
150
|
+
const currentValue = flipBoolean ? !value : value ?? void 0;
|
|
161
151
|
if (currentValue === newValue) {
|
|
162
152
|
return newValue;
|
|
163
153
|
}
|
|
@@ -165,11 +155,10 @@ const accessorSupport = {
|
|
|
165
155
|
const finalValue = instance[propertyName];
|
|
166
156
|
return flipBoolean ? !finalValue : finalValue;
|
|
167
157
|
};
|
|
168
|
-
const
|
|
169
|
-
const internals = component.manager.internals;
|
|
158
|
+
const manager = controller.component.manager;
|
|
170
159
|
watchedProperties.forEach((_propName, propertyName) => {
|
|
171
|
-
|
|
172
|
-
|
|
160
|
+
manager._accessorGetter[propertyName] = getter;
|
|
161
|
+
manager._accessorSetter[propertyName] = setter;
|
|
173
162
|
});
|
|
174
163
|
},
|
|
175
164
|
// Update component on Accessor prop change
|
|
@@ -192,10 +181,7 @@ const accessorSupport = {
|
|
|
192
181
|
return;
|
|
193
182
|
}
|
|
194
183
|
const domValue = genericComponent[propName];
|
|
195
|
-
|
|
196
|
-
if (component.manager.isLit) {
|
|
197
|
-
modelValue ??= void 0;
|
|
198
|
-
}
|
|
184
|
+
const modelValue = genericInstance[propertyName] ?? void 0;
|
|
199
185
|
const flipBoolean = typeof domValue === "boolean" && propertyName !== propName && propName.toLowerCase().includes("disable");
|
|
200
186
|
const resolvedDomValue = flipBoolean ? !domValue : domValue;
|
|
201
187
|
if (resolvedDomValue != null && modelValue !== resolvedDomValue) {
|
|
@@ -216,7 +202,7 @@ const accessorSupport = {
|
|
|
216
202
|
const newValue = genericInstance[propertyName];
|
|
217
203
|
const flipBoolean = typeof newValue === "boolean" && propertyName !== propName && propName.toLowerCase().includes("disable");
|
|
218
204
|
const resolvedNewValue = flipBoolean ? !newValue : newValue;
|
|
219
|
-
|
|
205
|
+
bypassReadOnly(() => {
|
|
220
206
|
genericComponent[propName] = resolvedNewValue;
|
|
221
207
|
});
|
|
222
208
|
},
|
|
@@ -225,35 +211,6 @@ const accessorSupport = {
|
|
|
225
211
|
);
|
|
226
212
|
});
|
|
227
213
|
},
|
|
228
|
-
// REFACTOR: remove this once Stencil is no longer supported
|
|
229
|
-
reEmitAccessorEvents(controller, instance, prefix) {
|
|
230
|
-
const isEvented = "on" in instance && typeof instance.on === "function";
|
|
231
|
-
if (!isEvented) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const toListen = Object.entries(controller.component).map(([key, unknown]) => {
|
|
235
|
-
const value = unknown;
|
|
236
|
-
if (!key.startsWith(prefix) || key === prefix || typeof value !== "object" || value === null || !("emit" in value) || typeof value.emit !== "function") {
|
|
237
|
-
return void 0;
|
|
238
|
-
}
|
|
239
|
-
const emit = value.emit;
|
|
240
|
-
const trimmedEventName = key.slice(prefix.length);
|
|
241
|
-
const camelCaseEventName = camelToKebab(trimmedEventName);
|
|
242
|
-
const eventName = camelCaseEventName.toLowerCase();
|
|
243
|
-
return [eventName, emit];
|
|
244
|
-
}).filter(isNotUndefined);
|
|
245
|
-
if (toListen.length === 0) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const eventTarget = instance;
|
|
249
|
-
const getEventTarget = () => eventTarget;
|
|
250
|
-
controller.onLifecycle(() => {
|
|
251
|
-
if (instance.destroyed) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
return toListen.map(([eventName, emit]) => on(getEventTarget, eventName, emit));
|
|
255
|
-
});
|
|
256
|
-
},
|
|
257
214
|
async reCreate(instance, component) {
|
|
258
215
|
const accessorController = component.manager.useRefSync(instance);
|
|
259
216
|
if (accessorController === void 0) {
|
|
@@ -284,11 +241,6 @@ const filterWatchedProperties = process.env.NODE_ENV !== "production" && isEsriI
|
|
|
284
241
|
} : void 0;
|
|
285
242
|
function reEmitEvent(getEventedAccessor, eventName) {
|
|
286
243
|
const component = retrieveComponent();
|
|
287
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !component.manager.isLit) {
|
|
288
|
-
throw new Error(
|
|
289
|
-
"reEmitEvent is only supported in Lumina components. Consult documentation for equivalent Stencil pattern."
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
244
|
const manager = component.manager;
|
|
293
245
|
manager.onLoaded(() => manager.onLifecycle(() => on(getEventedAccessor, eventName, emitter.emit)));
|
|
294
246
|
const emitter = createEventFactory();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventEmitter } from '
|
|
1
|
+
import { EventEmitter } from '../../createEvent';
|
|
2
2
|
/**
|
|
3
3
|
* Re-emit an event from the accessor instance on the component
|
|
4
4
|
*
|
|
@@ -6,9 +6,5 @@ import { EventEmitter } from '../types';
|
|
|
6
6
|
* ```tsx
|
|
7
7
|
* arcgisGo = reEmitEvent<__esri.HomeViewModelGoEvent>(() => this.viewModel, "go");
|
|
8
8
|
* ```
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* `reEmitEvent()` only works in Lumina. Consult documentation for equivalent
|
|
12
|
-
* Stencil pattern.
|
|
13
9
|
*/
|
|
14
10
|
export declare function reEmitEvent<T>(getEventedAccessor: () => __esri.Evented, eventName: string): EventEmitter<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Controller, GenericController } from '../Controller';
|
|
2
|
-
import {
|
|
3
|
-
type Requires<Props, Accessor extends __esri.Accessor> =
|
|
2
|
+
import { LitElement } from '../../LitElement';
|
|
3
|
+
type Requires<Props, Accessor extends __esri.Accessor> = LitElement & Pick<Accessor, keyof Accessor & keyof Props> & {
|
|
4
4
|
autoDestroyDisabled: boolean;
|
|
5
5
|
destroy: () => Promise<void>;
|
|
6
6
|
};
|
|
@@ -19,7 +19,7 @@ export declare const makeAccessorController: <Props, Accessor extends __esri.Acc
|
|
|
19
19
|
* (or you wish to bind them but with a different type), you can omit
|
|
20
20
|
* them using this option.
|
|
21
21
|
*
|
|
22
|
-
* You can also bind the property to \@
|
|
22
|
+
* You can also bind the property to \@state rather than \@property if you
|
|
23
23
|
* wish to use it internally only:
|
|
24
24
|
* @example
|
|
25
25
|
* ```tsx
|
|
@@ -49,7 +49,7 @@ export declare class AccessorController<Props, Accessor extends __esri.Accessor,
|
|
|
49
49
|
* (development only) Allow these props to mismatch the name of the Accessor's property
|
|
50
50
|
* to avoid collisions
|
|
51
51
|
*
|
|
52
|
-
* @
|
|
52
|
+
* @private
|
|
53
53
|
*/
|
|
54
54
|
static allowedPropNameMismatches?: Set<string>;
|
|
55
55
|
constructor(component: ExtraRequires & Requires<Props, Accessor>, _loadAccessor: ((props: Props) => Accessor | Promise<Accessor>) | (new (props: Props) => Accessor), _options?: {
|
|
@@ -64,12 +64,11 @@ export declare class AccessorController<Props, Accessor extends __esri.Accessor,
|
|
|
64
64
|
reCreate(): Promise<void>;
|
|
65
65
|
}
|
|
66
66
|
export declare const accessorSupport: {
|
|
67
|
-
makeGetterProxy: (component:
|
|
67
|
+
makeGetterProxy: (component: LitElement, watchedProperties: Map<string, string>, isBinding?: {
|
|
68
68
|
value: boolean;
|
|
69
69
|
}, allowedPropNameMismatches?: Set<string>) => unknown;
|
|
70
70
|
watchComponentUpdates<T>(controller: Controller<T>, instance: __esri.Accessor, watchedProperties: Map<string, string>): void;
|
|
71
71
|
watchAccessorUpdates<T>(controller: Controller<T>, instance: __esri.Accessor, watchedProperties: Map<string, string>): void;
|
|
72
|
-
|
|
73
|
-
reCreate(instance: __esri.Accessor, component: BaseComponent): Promise<void>;
|
|
72
|
+
reCreate(instance: __esri.Accessor, component: LitElement): Promise<void>;
|
|
74
73
|
};
|
|
75
74
|
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
import { LitElement } from '../LitElement';
|
|
1
2
|
import { GenericControllerType, Controller } from './Controller';
|
|
2
|
-
import { BaseComponent, ControllerHost } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Controller is a function that takes a component instance and then can
|
|
5
5
|
* export some values to the component, or hook into component's lifecycle
|
|
6
6
|
*
|
|
7
7
|
* See controllers documentation for many example controllers and their usages
|
|
8
8
|
*/
|
|
9
|
-
export declare const makeController: <Exports>(constructor: (component:
|
|
9
|
+
export declare const makeController: <Exports>(constructor: (component: LitElement, controller: Controller<Exports>) => Exports | Promise<Exports>) => Exports;
|
|
10
10
|
/**
|
|
11
11
|
* If your controller requires some specific properties to be present on the
|
|
12
|
-
* component, besides what's included in the
|
|
12
|
+
* component, besides what's included in the LitElement, use
|
|
13
13
|
* makeGenericController
|
|
14
14
|
*
|
|
15
15
|
* When using a controller created using makeGenericController(), consumer must
|
|
16
16
|
* pass in "this" explicitly for proper type-checking. If controller was
|
|
17
17
|
* created using makeController(), that is not necessary
|
|
18
18
|
*/
|
|
19
|
-
export declare const makeGenericController: <Exports, Component =
|
|
19
|
+
export declare const makeGenericController: <Exports, Component = LitElement>(constructor: (component: Component & LitElement, controller: GenericControllerType<Exports, Component>) => Exports | Promise<Exports>) => (component: Component & LitElement) => Exports;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
+
import { EventEmitter as _EventEmitter } from '../createEvent';
|
|
1
2
|
export type { GenericControllerType } from './Controller';
|
|
2
3
|
export { Controller, GenericController } from './Controller';
|
|
3
4
|
export type { ControllerManager } from './ControllerManager';
|
|
4
|
-
export { retrieveComponent } from './ControllerInternals';
|
|
5
|
-
export { useControllerManager } from './ControllerManager';
|
|
5
|
+
export { retrieveComponent, bypassGetter, bypassSetter, bypassReadOnly } from './ControllerInternals';
|
|
6
6
|
export { trackPropertyKey, keyTrackResolve } from './trackPropertyKey';
|
|
7
7
|
export { trackPropKey } from './trackPropKey';
|
|
8
8
|
export { trackKey } from './trackKey';
|
|
9
9
|
export { makeController, makeGenericController } from './functional';
|
|
10
|
-
export { readonly, bypassReadOnly } from './readonly';
|
|
11
|
-
export { getSet, dynamicGetSet, bypassGetter, bypassSetter } from './getSet';
|
|
12
|
-
export { watch } from './useWatch';
|
|
13
10
|
export { useWatchAttributes } from './useWatchAttributes';
|
|
14
11
|
export { load } from './load';
|
|
15
12
|
export { proxyExports } from './proxyExports';
|
|
@@ -21,3 +18,7 @@ export type { UseT9n, T9nMeta } from './useT9n';
|
|
|
21
18
|
export { makeT9nController } from './useT9n';
|
|
22
19
|
export { usePropertyChange } from './usePropertyChange';
|
|
23
20
|
export { isController } from './utils';
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated import from "@arcgis/lumina" instead
|
|
23
|
+
*/
|
|
24
|
+
export type EventEmitter<T = undefined> = _EventEmitter<T>;
|