@arcgis/lumina 4.33.0-next.97 → 4.33.0-next.98
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
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import { G as GenericController, j as ComponentInternals, l as retrieveComponentMembers, s as setAmbientComponent, m as elementToInstance, k as keyTrackResolve, n as devOnlySetPersistentControllerData, w as watch, h as controllerSymbol } from "./useWatch-CFtSpNnN.js";
|
|
2
|
-
import { isEsriInternalEnv, Deferred, devToolsAwareTimeout, safeCall, safeAsyncCall } from "@arcgis/components-utils";
|
|
3
|
-
const useControllerManager = (component) => new ControllerManager(component);
|
|
4
|
-
class ControllerManager extends GenericController {
|
|
5
|
-
constructor(component) {
|
|
6
|
-
const isLit = "addController" in component;
|
|
7
|
-
const controllers = /* @__PURE__ */ new Set();
|
|
8
|
-
function addController(controller) {
|
|
9
|
-
controllers.add(controller);
|
|
10
|
-
if (!(controllerSymbol in controller) && component.renderRoot && component.el.isConnected) {
|
|
11
|
-
controller.hostConnected?.();
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function removeController(controller) {
|
|
15
|
-
void controllers.delete(controller);
|
|
16
|
-
controller.controllerRemoved?.();
|
|
17
|
-
}
|
|
18
|
-
const controllerHost = component;
|
|
19
|
-
controllerHost.addController = addController;
|
|
20
|
-
controllerHost.removeController = removeController;
|
|
21
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
22
|
-
const stencilToLitMapping = {
|
|
23
|
-
componentDidLoad: "loaded",
|
|
24
|
-
componentDidRender: "updated",
|
|
25
|
-
componentDidUpdate: "updated",
|
|
26
|
-
componentShouldUpdate: "shouldUpdate",
|
|
27
|
-
componentWillLoad: "load",
|
|
28
|
-
componentWillRender: "willUpdate",
|
|
29
|
-
componentWillUpdate: "willUpdate"
|
|
30
|
-
};
|
|
31
|
-
Object.entries(stencilToLitMapping).forEach(([stencilMethod, litMethod]) => {
|
|
32
|
-
if (isLit && stencilMethod in component) {
|
|
33
|
-
throw new Error(
|
|
34
|
-
`Unexpected ${stencilMethod}() in a Lit component ${component.el.localName}. In Lit, you should use ${litMethod}() instead`
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
if (isLit) {
|
|
39
|
-
let i = 0;
|
|
40
|
-
let isLitElementClass = false;
|
|
41
|
-
for (let prototype = component; !isLitElementClass; i++) {
|
|
42
|
-
if (prototype === null) {
|
|
43
|
-
throw new Error("Expected controllers to be used in a LitElement class");
|
|
44
|
-
}
|
|
45
|
-
if (Object.hasOwn(prototype, "_load")) {
|
|
46
|
-
isLitElementClass = true;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
prototype = Object.getPrototypeOf(prototype);
|
|
50
|
-
}
|
|
51
|
-
if (i < 1) {
|
|
52
|
-
throw new Error(
|
|
53
|
-
"It looks like you are trying to call useControllerManager in a component that uses LitElement imported from 'lit'. useControllerManager should only be used in the LitElement coming from `@arcgis/lumina`"
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
super(component);
|
|
59
|
-
this.internals = new ComponentInternals(this.component);
|
|
60
|
-
this.destroyed = false;
|
|
61
|
-
this._updatePromise = new Deferred();
|
|
62
|
-
this._originalLifecycles = {};
|
|
63
|
-
this.isLit = isLit;
|
|
64
|
-
this.component.manager = this;
|
|
65
|
-
retrieveComponentMembers(component, isLit);
|
|
66
|
-
this._controllers = controllers;
|
|
67
|
-
this.exports = void 0;
|
|
68
|
-
this.hasDestroy = autoDestroyDisabledPropName in this.component && typeof this.component.destroy === "function";
|
|
69
|
-
this._bindLifecycleMethods();
|
|
70
|
-
const internals = this.internals;
|
|
71
|
-
Object.keys(internals.members).forEach((name) => {
|
|
72
|
-
internals.accessorGetter[name] = defaultGetterSetter;
|
|
73
|
-
internals.accessorSetter[name] = defaultGetterSetter;
|
|
74
|
-
internals.getSetProxy(name);
|
|
75
|
-
});
|
|
76
|
-
if (isLit) {
|
|
77
|
-
this.internals.enabledWatchers = this.internals.allWatchers;
|
|
78
|
-
} else {
|
|
79
|
-
Object.defineProperty(component, "updateComplete", {
|
|
80
|
-
get: async () => await this._updatePromise.promise
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
queueMicrotask(internals.enableReadonly);
|
|
84
|
-
setAmbientComponent(component);
|
|
85
|
-
elementToInstance.set(component.el, component);
|
|
86
|
-
elementToInstance.set(component, component);
|
|
87
|
-
}
|
|
88
|
-
_bindLifecycleMethods() {
|
|
89
|
-
const component = this.component;
|
|
90
|
-
const isLit = this.isLit;
|
|
91
|
-
const isStencilDistBuild = component.el === component;
|
|
92
|
-
this._originalLifecycles = {
|
|
93
|
-
// These component's callbacks will be called by Lit, so we don't have to
|
|
94
|
-
_connectedCallback: isLit || isStencilDistBuild ? void 0 : component.connectedCallback,
|
|
95
|
-
_disconnectedCallback: isLit || isStencilDistBuild ? void 0 : component.disconnectedCallback,
|
|
96
|
-
_load: isLit ? component.load : component.componentWillLoad,
|
|
97
|
-
_loaded: isLit ? component.loaded : component.componentDidLoad,
|
|
98
|
-
_willUpdate: isLit ? void 0 : component.componentWillUpdate,
|
|
99
|
-
_updated: isLit ? void 0 : component.componentDidUpdate,
|
|
100
|
-
_destroy: component.destroy
|
|
101
|
-
};
|
|
102
|
-
const hostConnected = this._connectedCallback.bind(this);
|
|
103
|
-
const hostDisconnected = this._disconnectedCallback.bind(this);
|
|
104
|
-
const hostUpdate = this._update.bind(this);
|
|
105
|
-
const hostUpdated = this._updated.bind(this);
|
|
106
|
-
if (isLit) {
|
|
107
|
-
component.constructor.prototype.addController.call(component, {
|
|
108
|
-
// Lit will call these callbacks
|
|
109
|
-
hostConnected,
|
|
110
|
-
hostDisconnected,
|
|
111
|
-
hostUpdate,
|
|
112
|
-
hostUpdated
|
|
113
|
-
});
|
|
114
|
-
} else {
|
|
115
|
-
component.connectedCallback = hostConnected;
|
|
116
|
-
component.disconnectedCallback = hostDisconnected;
|
|
117
|
-
component.componentWillLoad = this._load.bind(this);
|
|
118
|
-
component.componentDidLoad = this._loaded.bind(this);
|
|
119
|
-
component.componentWillUpdate = hostUpdate;
|
|
120
|
-
component.componentDidUpdate = hostUpdated;
|
|
121
|
-
}
|
|
122
|
-
if (this.hasDestroy) {
|
|
123
|
-
component.destroy = this.destroy.bind(this);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Private because this is not supposed to be called by Component directly.
|
|
128
|
-
* Instead, _bindLifecycleMethods will take care of that. Otherwise, you risk
|
|
129
|
-
* calling lifecycle methods twice.
|
|
130
|
-
*
|
|
131
|
-
* @internal
|
|
132
|
-
*/
|
|
133
|
-
_connectedCallback() {
|
|
134
|
-
if (this.destroyed) {
|
|
135
|
-
const tagName = this.component.el.localName;
|
|
136
|
-
this.component.el.remove();
|
|
137
|
-
throw new Error(
|
|
138
|
-
`The ${tagName} component has already been destroyed. It cannot be used again. If you meant to disconnect and reconnect a component without automatic destroy, set the ${autoDestroyDisabledPropName} prop.`
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
if (this._autoDestroyTimeout !== void 0) {
|
|
142
|
-
clearTimeout(this._autoDestroyTimeout);
|
|
143
|
-
}
|
|
144
|
-
const internals = this.internals;
|
|
145
|
-
internals.enabledWatchers = internals.allWatchers;
|
|
146
|
-
keyTrackResolve();
|
|
147
|
-
internals.enableReadonly?.();
|
|
148
|
-
this._controllers.forEach(callConnected);
|
|
149
|
-
this._originalLifecycles._connectedCallback?.call(this.component);
|
|
150
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
151
|
-
devOnlySetPersistentControllerData?.(this, true);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/** @internal */
|
|
155
|
-
_disconnectedCallback() {
|
|
156
|
-
if (this.destroyed) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
this._controllers.forEach(callDisconnected);
|
|
160
|
-
this._originalLifecycles._disconnectedCallback?.call(this.component);
|
|
161
|
-
if (this.hasDestroy) {
|
|
162
|
-
this._setAutoDestroyTimeout();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/** @internal */
|
|
166
|
-
async _load() {
|
|
167
|
-
await Promise.allSettled(Array.from(this._controllers, callLoad));
|
|
168
|
-
await this._originalLifecycles._load?.call(this.component);
|
|
169
|
-
if (this.hasDestroy) {
|
|
170
|
-
watch(this.component, autoDestroyDisabledPropName, () => this._setAutoDestroyTimeout());
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
/** @internal */
|
|
174
|
-
_loaded() {
|
|
175
|
-
this._controllers.forEach(callLoaded);
|
|
176
|
-
this._originalLifecycles._loaded?.call(this.component);
|
|
177
|
-
}
|
|
178
|
-
_update() {
|
|
179
|
-
const maybeLitComponent = this.component;
|
|
180
|
-
this._controllers.forEach(callUpdate, maybeLitComponent.$changes);
|
|
181
|
-
return this._originalLifecycles._willUpdate?.call(this.component);
|
|
182
|
-
}
|
|
183
|
-
_updated() {
|
|
184
|
-
const maybeLitComponent = this.component;
|
|
185
|
-
this._controllers.forEach(callUpdated, maybeLitComponent.$changes);
|
|
186
|
-
this._originalLifecycles._updated?.call(this.component);
|
|
187
|
-
if (this.isLit) {
|
|
188
|
-
maybeLitComponent.$changes = /* @__PURE__ */ new Map();
|
|
189
|
-
} else {
|
|
190
|
-
const updatePromise = this._updatePromise;
|
|
191
|
-
this._updatePromise = new Deferred();
|
|
192
|
-
updatePromise.resolve(true);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
async destroy() {
|
|
196
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
197
|
-
this.ensureHasDestroy?.();
|
|
198
|
-
}
|
|
199
|
-
if (this.destroyed) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
if (this.component.el.isConnected) {
|
|
203
|
-
this.hasDestroy = false;
|
|
204
|
-
try {
|
|
205
|
-
this.component.el.remove();
|
|
206
|
-
} finally {
|
|
207
|
-
this.hasDestroy = true;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
this._autoDestroyTimeout = void 0;
|
|
211
|
-
this.destroyed = true;
|
|
212
|
-
this._controllers.forEach(callDestroy);
|
|
213
|
-
this._controllers.clear();
|
|
214
|
-
await this._originalLifecycles._destroy?.call(this.component);
|
|
215
|
-
}
|
|
216
|
-
_setAutoDestroyTimeout() {
|
|
217
|
-
if (this._autoDestroyTimeout !== void 0) {
|
|
218
|
-
clearTimeout(this._autoDestroyTimeout);
|
|
219
|
-
}
|
|
220
|
-
if (!this.component.el.isConnected && !this.component.autoDestroyDisabled) {
|
|
221
|
-
const destroy = () => void this.destroy().catch(console.error);
|
|
222
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && autoDestroyOnDisconnectTimeout === 0) ;
|
|
223
|
-
else {
|
|
224
|
-
this._autoDestroyTimeout = devToolsAwareTimeout(destroy, autoDestroyOnDisconnectTimeout);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
230
|
-
ControllerManager.prototype.ensureHasDestroy = function ensureHasDestroy() {
|
|
231
|
-
if (!this.hasDestroy) {
|
|
232
|
-
throw new Error(
|
|
233
|
-
`
|
|
234
|
-
If the component uses a controller that uses destroy() method, then the
|
|
235
|
-
component must have the following properties:
|
|
236
|
-
/**
|
|
237
|
-
* If true, the component will not be destroyed automatically when it is
|
|
238
|
-
* disconnected from the document. This is useful when you want to move the
|
|
239
|
-
* component to a different place on the page, or temporarily hide it. If this
|
|
240
|
-
* is set, make sure to call the \`destroy\` method when you are done to prevent
|
|
241
|
-
* memory leaks.
|
|
242
|
-
*/
|
|
243
|
-
@${this.isLit ? "property" : "Prop"}() ${autoDestroyDisabledPropName} = false;
|
|
244
|
-
|
|
245
|
-
/** Permanently destroy the component */
|
|
246
|
-
@${this.isLit ? "method" : "Method"}()
|
|
247
|
-
async destroy(): Promise<void> {
|
|
248
|
-
await this.manager.destroy();
|
|
249
|
-
}
|
|
250
|
-
`.trim().split("\n").map((line) => line.trim()).join("\n")
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
const autoDestroyDisabledPropName = "autoDestroyDisabled";
|
|
256
|
-
let autoDestroyOnDisconnectTimeout = 1e3;
|
|
257
|
-
process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? {} : void 0;
|
|
258
|
-
const defaultGetterSetter = (value) => value;
|
|
259
|
-
function callConnected(controller) {
|
|
260
|
-
if ("triggerConnected" in controller) {
|
|
261
|
-
controller.triggerConnected();
|
|
262
|
-
} else {
|
|
263
|
-
safeCall(controller.hostConnected, controller);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
function callDisconnected(controller) {
|
|
267
|
-
if ("triggerDisconnected" in controller) {
|
|
268
|
-
controller.triggerDisconnected();
|
|
269
|
-
} else {
|
|
270
|
-
safeCall(controller.hostDisconnected, controller);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
async function callLoad(controller) {
|
|
274
|
-
if ("triggerLoad" in controller) {
|
|
275
|
-
await controller.triggerLoad();
|
|
276
|
-
} else {
|
|
277
|
-
await safeAsyncCall(controller.hostLoad, controller);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
function callLoaded(controller) {
|
|
281
|
-
if ("triggerLoaded" in controller) {
|
|
282
|
-
controller.triggerLoaded();
|
|
283
|
-
} else {
|
|
284
|
-
safeCall(controller.hostLoaded, controller);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
function callUpdate(controller) {
|
|
288
|
-
if ("triggerUpdate" in controller) {
|
|
289
|
-
controller.triggerUpdate(this);
|
|
290
|
-
} else {
|
|
291
|
-
safeCall(controller.hostUpdate, controller, this);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
function callUpdated(controller) {
|
|
295
|
-
if ("triggerUpdated" in controller) {
|
|
296
|
-
controller.triggerUpdated(this);
|
|
297
|
-
} else {
|
|
298
|
-
safeCall(controller.hostUpdated, controller, this);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function callDestroy(controller) {
|
|
302
|
-
if ("triggerDestroy" in controller) {
|
|
303
|
-
controller.triggerDestroy();
|
|
304
|
-
} else {
|
|
305
|
-
safeCall(controller.hostDestroy, controller);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
export {
|
|
309
|
-
useControllerManager as u
|
|
310
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { BaseComponent, BaseController, ControllerHost } from './types';
|
|
2
|
-
export type TrackKeyResolution = {
|
|
3
|
-
readonly key: string;
|
|
4
|
-
readonly host: BaseComponent | BaseController;
|
|
5
|
-
/**
|
|
6
|
-
* True if property is decorated with `@State()` or `@Prop()` decorator
|
|
7
|
-
*/
|
|
8
|
-
readonly isReactive: boolean;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Like ControllerInternals, but specific to each instance of a component
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare class ComponentInternals {
|
|
16
|
-
/**
|
|
17
|
-
* When watchers are set, they are set into `allWatchers`. When watchers are
|
|
18
|
-
* read in the setter, they are read from `enabledWatchers`.
|
|
19
|
-
*
|
|
20
|
-
* In Stencil, on connectedCallback(), controller manager does
|
|
21
|
-
* `enabledWatchers=allWatchers`. Reasoning:
|
|
22
|
-
* - This disables watchers until connected callback (matches behavior of
|
|
23
|
-
* Stencil's watchers)
|
|
24
|
-
* - This removes the need for a check in the setter for whether the watchers
|
|
25
|
-
* were enabled already or not (as getters/setters are hot path, and should
|
|
26
|
-
* be streamlined)
|
|
27
|
-
*
|
|
28
|
-
* In Lit, we set enabledWatchers to allWatchers in the constructor.
|
|
29
|
-
* Reasoning:
|
|
30
|
-
* - While in Stencil all user provided properties are either set before the
|
|
31
|
-
* component constructor (this is possible since Stencil's props store is
|
|
32
|
-
* externalized) or after connectedCallback, in Lit the properties may be
|
|
33
|
-
* set by attributeChangedCallback before connectedCallback. Thus, we need
|
|
34
|
-
* to enable watchers even before connectedCallback.
|
|
35
|
-
* - This means, that a watcher set for some prop before your component got
|
|
36
|
-
* a chance to set the default value will trigger the watcher when the
|
|
37
|
-
* default value is set - but, that is inline with Lit's willUpdate behavior
|
|
38
|
-
* of triggering for default values AND, the only way to set a watcher
|
|
39
|
-
* before default value is if you called watcher inside a controller. For
|
|
40
|
-
* now, there are no controllers written outside of arcgis-map-components
|
|
41
|
-
* package, so I was able to verify that this change would have no
|
|
42
|
-
* negative impact.
|
|
43
|
-
*
|
|
44
|
-
* In either way, I plan to remove watchers from controllers once Stencil
|
|
45
|
-
* support is removed.
|
|
46
|
-
*/
|
|
47
|
-
enabledWatchers: Watchers;
|
|
48
|
-
allWatchers: Watchers;
|
|
49
|
-
readonly component: BaseComponent & ControllerHost;
|
|
50
|
-
/**
|
|
51
|
-
* Do not use this directly as it may break on framework updates.
|
|
52
|
-
* Instead, use helpers like getPropMembers() and getPropType()
|
|
53
|
-
*/
|
|
54
|
-
members: Record<string, [number, string?]>;
|
|
55
|
-
constructor(component: BaseComponent & ControllerHost);
|
|
56
|
-
/**
|
|
57
|
-
* "readOnly" is not enabled initially since we need to allow to set property
|
|
58
|
-
* default values in the constructor.
|
|
59
|
-
* For Stencil, readonly is enabled by the `readonly()` controller.
|
|
60
|
-
* For Lit, we have the following logic:
|
|
61
|
-
*/
|
|
62
|
-
enableReadonly: (() => void) | undefined;
|
|
63
|
-
trackedValue: unknown;
|
|
64
|
-
keyTrackers: ((key: string | undefined, value: unknown) => void)[];
|
|
65
|
-
firePropTrackers(key: string | undefined, value: unknown): void;
|
|
66
|
-
readonly getters: Record<string, ((value: unknown, propertyName: string) => unknown)[] | undefined>;
|
|
67
|
-
readonly setters: Record<string, ((newValue: unknown, oldValue: unknown, propertyName: string) => unknown)[] | undefined>;
|
|
68
|
-
readonly accessorGetter: Record<string, (value: unknown, propertyName: string) => unknown>;
|
|
69
|
-
readonly accessorSetter: Record<string, (newValue: unknown, oldValue: unknown, propertyName: string) => unknown>;
|
|
70
|
-
/**
|
|
71
|
-
* Configure a getter or setter for a given \@Prop/\@State
|
|
72
|
-
*
|
|
73
|
-
* Since props are defined on the prototype, they are shared between all
|
|
74
|
-
* instances of a component. Thus, instead of passing a reference to the
|
|
75
|
-
* getter/setter function, you should update the
|
|
76
|
-
* ComponentInternals.getters/setters properties, and then call getSetProxy
|
|
77
|
-
* to apply the changes to the prototype
|
|
78
|
-
*/
|
|
79
|
-
getSetProxy(property: string): void;
|
|
80
|
-
private _getSetProxy;
|
|
81
|
-
private _exports;
|
|
82
|
-
/**
|
|
83
|
-
* Associate an exports object with a controller for reverse lookup in
|
|
84
|
-
* controller.use
|
|
85
|
-
*/
|
|
86
|
-
markExports(controller: BaseController, exports: unknown): void;
|
|
87
|
-
resolveExports(exports: unknown): BaseController | undefined;
|
|
88
|
-
readonlySetter: <T>(newValue: T, _oldValue: T, property: string) => T;
|
|
89
|
-
}
|
|
90
|
-
type Watchers = Record<string, ((newValue: unknown, oldValue: unknown, propertyName: string) => void)[] | undefined>;
|
|
91
|
-
export declare const nothing: symbol;
|
|
92
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Do not consume this enum directly. Instead, consume one of the wrapper
|
|
4
|
-
* functions defined in this file.
|
|
5
|
-
*/
|
|
6
|
-
export declare enum PropTypes {
|
|
7
|
-
String = 1,
|
|
8
|
-
Number = 2,
|
|
9
|
-
Boolean = 4,
|
|
10
|
-
Any = 8,
|
|
11
|
-
Unknown = 16,
|
|
12
|
-
State = 32,
|
|
13
|
-
Method = 64,
|
|
14
|
-
Event = 128,
|
|
15
|
-
Element = 256,
|
|
16
|
-
ReflectAttr = 512,
|
|
17
|
-
Mutable = 1024,
|
|
18
|
-
Prop = 31,
|
|
19
|
-
HasAttribute = 15,
|
|
20
|
-
PropLike = 63,
|
|
21
|
-
ReadOnly = 2048
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Retrieve list of members on a Stencil/Lit component and their types
|
|
25
|
-
*
|
|
26
|
-
* Warning:
|
|
27
|
-
* - this may break on Stencil updates
|
|
28
|
-
* - component meta is not component instance specific, thus any modifications
|
|
29
|
-
* would affect all instances of that component
|
|
30
|
-
*/
|
|
31
|
-
export declare function retrieveComponentMembers(component: BaseComponent, isLit: boolean): void;
|
|
32
|
-
/**
|
|
33
|
-
* This function is only expected to be called in Stencil, not Lit
|
|
34
|
-
*
|
|
35
|
-
* Based on https://github.com/ionic-team/stencil/blob/9c82ffb782f69bfbca28a8aced35c515e711f5fa/src/runtime/parse-property-value.ts#L31-L46
|
|
36
|
-
*/
|
|
37
|
-
export declare function parsePropertyValue(value: unknown, type?: PropTypes): unknown;
|
|
38
|
-
/**
|
|
39
|
-
* Get a number representing different flags for a given prop. To get a value
|
|
40
|
-
* of individual flag, use the PropTypes enum.
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* const isBoolean = (getMemberType(component, "myProp") & PropTypes.Boolean) !== 0;
|
|
44
|
-
*/
|
|
45
|
-
export declare const getMemberType: (component: BaseComponent, name: string) => number | undefined;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Listen for any component's @State()/@Prop() change, and mutate it's
|
|
4
|
-
* value before it is set.
|
|
5
|
-
* This is necessary because Stencil's Compiler does not support get/set for
|
|
6
|
-
* @State()/@Prop().
|
|
7
|
-
* For private component properties, you should use regular get/set syntax.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* @Prop() exampleProp = getSet(defaultValue,{get,set})
|
|
12
|
-
* @Prop() someProp = getSet(
|
|
13
|
-
* undefined as string | undefined,
|
|
14
|
-
* {
|
|
15
|
-
* get: (value)=>value.trim(),
|
|
16
|
-
* set: (newValue,oldValue) => newValue.trim() ?? oldValue
|
|
17
|
-
* }
|
|
18
|
-
* )
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @remarks
|
|
22
|
-
* Unlike a native get/set, the get function receives the current attribute
|
|
23
|
-
* value, and can modify it before returning it (or can disregard the current
|
|
24
|
-
* value and get it from elsewhere instead).
|
|
25
|
-
* Similarly, setter is called with the new and old value, and is expected to
|
|
26
|
-
* return the final new value (or return the old value to undo the change)
|
|
27
|
-
*
|
|
28
|
-
* @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
|
|
29
|
-
*/
|
|
30
|
-
export declare function getSet<T>(
|
|
31
|
-
/**
|
|
32
|
-
* Default value is used only if user did not set a value in the DOM before
|
|
33
|
-
* component was loaded
|
|
34
|
-
*/
|
|
35
|
-
defaultValue: T, getSet: {
|
|
36
|
-
get?(newValue: T, propertyName: string): T;
|
|
37
|
-
set(newValue: T, oldValue: T, propertyName: string): T;
|
|
38
|
-
} | {
|
|
39
|
-
get(newValue: T, propertyName: string): T;
|
|
40
|
-
set?(newValue: T, oldValue: T, propertyName: string): T;
|
|
41
|
-
} | {
|
|
42
|
-
get(newValue: T, propertyName: string): T;
|
|
43
|
-
set: "ignore";
|
|
44
|
-
}): T;
|
|
45
|
-
/**
|
|
46
|
-
* Like getSet(), but can be called on any component's
|
|
47
|
-
* state/prop from anywhere, rather than just from the default value
|
|
48
|
-
*
|
|
49
|
-
* @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
|
|
50
|
-
*/
|
|
51
|
-
export declare const dynamicGetSet: <Component extends BaseComponent, Property extends keyof (BaseComponent & Component)>(component: Component, property: Property, getSet: {
|
|
52
|
-
get?(newValue: (BaseComponent & Component)[Property], propertyName: Property): (BaseComponent & Component)[Property];
|
|
53
|
-
set(newValue: (BaseComponent & Component)[Property], oldValue: (BaseComponent & Component)[Property], propertyName: Property): (BaseComponent & Component)[Property];
|
|
54
|
-
} | {
|
|
55
|
-
get(newValue: (BaseComponent & Component)[Property], propertyName: Property): (BaseComponent & Component)[Property];
|
|
56
|
-
set?(newValue: (BaseComponent & Component)[Property], oldValue: (BaseComponent & Component)[Property], propertyName: Property): (BaseComponent & Component)[Property];
|
|
57
|
-
}) => void;
|
|
58
|
-
/**
|
|
59
|
-
* If you need to set a prop/state without triggering the custom setter you
|
|
60
|
-
* defined with getSet()/dynamicGetSet()/readonly(), set the value inside
|
|
61
|
-
* of this function
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```tsx
|
|
65
|
-
* @Prop() readOnly = readOnly(true);
|
|
66
|
-
*
|
|
67
|
-
* someAction(): void {
|
|
68
|
-
* bypassSetter(()=>{
|
|
69
|
-
* this.readOnly = false;
|
|
70
|
-
* });
|
|
71
|
-
* }
|
|
72
|
-
* ```
|
|
73
|
-
*
|
|
74
|
-
* @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
|
|
75
|
-
*/
|
|
76
|
-
export declare function bypassSetter<T = void>(callback: () => T): T | void;
|
|
77
|
-
/**
|
|
78
|
-
* Property reads inside of this function will bypass any custom getter you
|
|
79
|
-
* may have, and read the value directly from what's stored in Stencil/Lit.
|
|
80
|
-
*
|
|
81
|
-
* This also bypasses reactiveUtils integration - reading a property inside of
|
|
82
|
-
* bypassGetter won't make that property tracked.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```tsx
|
|
86
|
-
* reactiveUtils.watch(
|
|
87
|
-
* ()=>{
|
|
88
|
-
* bypassGetter(()=>{
|
|
89
|
-
* console.log(this.someProp);
|
|
90
|
-
* });
|
|
91
|
-
* return this.prop;
|
|
92
|
-
* },
|
|
93
|
-
* console.log
|
|
94
|
-
* );
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
|
|
98
|
-
*/
|
|
99
|
-
export declare function bypassGetter<T = void>(callback: () => T): T | void;
|
|
100
|
-
/**
|
|
101
|
-
* Like dynamicGetSet, but less type-safe. Useful in cases when trying to set
|
|
102
|
-
* getters/setters in place where property names & types are not known
|
|
103
|
-
* statically
|
|
104
|
-
*
|
|
105
|
-
* @deprecated see https://qawebgis.esri.com/components/lumina/properties#get-set-properties
|
|
106
|
-
*/
|
|
107
|
-
export declare function genericGetSet<Type>(component: BaseComponent, property: string, getSet: {
|
|
108
|
-
get?(newValue: Type, propertyName: string): Type;
|
|
109
|
-
set(newValue: Type, oldValue: Type, propertyName: string): Type;
|
|
110
|
-
} | {
|
|
111
|
-
get(newValue: Type, propertyName: string): Type;
|
|
112
|
-
set?(newValue: Type, oldValue: Type, propertyName: string): Type;
|
|
113
|
-
} | {
|
|
114
|
-
get(newValue: Type, propertyName: string): Type;
|
|
115
|
-
set: "ignore";
|
|
116
|
-
}): void;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Make a @Prop() or @State() readonly (prevent overwriting default value).
|
|
3
|
-
*
|
|
4
|
-
* For internal properties, prefer TypeScript's "readonly" modifier instead.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* // Defining readonly prop
|
|
9
|
-
* @Prop({ reflect: true }) prop = readonly('a');
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* // Overwriting readonly prop internally
|
|
15
|
-
* bypassReadOnly(()=>{
|
|
16
|
-
* this.prop = 'b';
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @deprecated see https://qawebgis.esri.com/components/lumina/properties#read-only-properties
|
|
21
|
-
*/
|
|
22
|
-
export declare function readonly<T>(value: T): T;
|
|
23
|
-
/**
|
|
24
|
-
* Like bypassSetter(), but only bypasses readonly(), rather that
|
|
25
|
-
* all setters set using getSet()
|
|
26
|
-
*
|
|
27
|
-
* @deprecated see https://qawebgis.esri.com/components/lumina/properties#read-only-properties
|
|
28
|
-
*/
|
|
29
|
-
export declare function bypassReadOnly<T = void>(callback: () => T): T | void;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Dynamically set a watcher for any reactive property
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* this.manager.onLifecycle(()=>
|
|
8
|
-
* watch(this, "myProp", (newValue,oldValue)=>console.log(newValue,oldValue))
|
|
9
|
-
* )
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* If you are in Lit, you should prefer the willUpdate() lifecycle method
|
|
14
|
-
* over watch(). willUpdate() is going to be more memory-efficient, and more
|
|
15
|
-
* flexible (can watch multiple props at once or provide dynamic prop name)
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* willUpdate(changes: PropertyValues<this>) {
|
|
19
|
-
* if (changes.has('firstName') || changes.has('lastName')) {
|
|
20
|
-
* this.sha = computeSHA(`${this.firstName} ${this.lastName}`);
|
|
21
|
-
* }
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @deprecated see https://qawebgis.esri.com/components/lumina/lifecycle#willupdate and https://qawebgis.esri.com/components/lumina/controllers/lifecycle
|
|
26
|
-
*/
|
|
27
|
-
export declare function watch<Component extends BaseComponent, Property extends keyof Component>(component: Component, property: Property, callback: (newValue: Component[Property], oldValue: Component[Property], property: Property) => void): () => void;
|