@arcgis/lumina 4.33.0-next.94 → 4.33.0-next.96
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-B2comd8J.js +310 -0
- package/dist/LitElement.d.ts +3 -3
- package/dist/context.d.ts +1 -1
- package/dist/controllers/ComponentInternals.d.ts +92 -0
- package/dist/controllers/Controller.d.ts +152 -0
- package/dist/controllers/ControllerInternals.d.ts +52 -0
- package/dist/controllers/ControllerManager.d.ts +63 -0
- package/dist/controllers/accessor/index.d.ts +2 -0
- package/dist/controllers/accessor/index.js +307 -0
- package/dist/controllers/accessor/reEmitEvent.d.ts +14 -0
- package/dist/controllers/accessor/useAccessor.d.ts +75 -0
- package/dist/controllers/framework.d.ts +45 -0
- package/dist/controllers/functional.d.ts +19 -0
- package/dist/controllers/getSet.d.ts +116 -0
- package/dist/controllers/index.d.ts +23 -0
- package/dist/controllers/index.js +283 -0
- package/dist/controllers/load.d.ts +6 -0
- package/dist/controllers/proxyExports.d.ts +27 -0
- package/dist/controllers/readonly.d.ts +29 -0
- package/dist/controllers/tests/autoDestroyMock.d.ts +5 -0
- package/dist/controllers/tests/utils.d.ts +1 -0
- package/dist/controllers/toFunction.d.ts +8 -0
- package/dist/controllers/trackKey.d.ts +8 -0
- package/dist/controllers/trackPropKey.d.ts +21 -0
- package/dist/controllers/trackPropertyKey.d.ts +28 -0
- package/dist/controllers/types.d.ts +182 -0
- package/dist/controllers/useDirection.d.ts +11 -0
- package/dist/controllers/useMedia.d.ts +8 -0
- package/dist/controllers/usePropertyChange.d.ts +11 -0
- package/dist/controllers/useT9n.d.ts +48 -0
- package/dist/controllers/useWatch.d.ts +27 -0
- package/dist/controllers/useWatchAttributes.d.ts +7 -0
- package/dist/controllers/utils.d.ts +15 -0
- package/dist/createEvent.d.ts +1 -1
- package/dist/decorators.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -42
- package/dist/lazyLoad.d.ts +2 -2
- package/dist/makeRuntime.d.ts +109 -0
- package/dist/proxyExports-Dl5CHmHQ.js +150 -0
- package/dist/runtime.d.ts +4 -107
- package/dist/useWatch-CFtSpNnN.js +925 -0
- package/package.json +4 -3
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { BaseComponent } from './types';
|
|
2
|
+
import { GenericController } from './Controller';
|
|
3
|
+
import { ComponentInternals } from './ComponentInternals';
|
|
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;
|
|
15
|
+
/**
|
|
16
|
+
* A manager for all other controllers. It finds all controllers on the
|
|
17
|
+
* component, loads them, and forwards lifecycle events to them.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ControllerManager extends GenericController<undefined> {
|
|
20
|
+
private readonly _controllers;
|
|
21
|
+
/** @internal */
|
|
22
|
+
readonly internals: ComponentInternals;
|
|
23
|
+
hasDestroy: boolean;
|
|
24
|
+
destroyed: boolean;
|
|
25
|
+
private _updatePromise;
|
|
26
|
+
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;
|
|
35
|
+
/**
|
|
36
|
+
* Throws an error if component does not implement destroy() lifecycle, but
|
|
37
|
+
* tries to use it. This check is only present in development mode
|
|
38
|
+
*/
|
|
39
|
+
ensureHasDestroy?: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Private because this is not supposed to be called by Component directly.
|
|
42
|
+
* Instead, _bindLifecycleMethods will take care of that. Otherwise, you risk
|
|
43
|
+
* calling lifecycle methods twice.
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
_connectedCallback(): void;
|
|
48
|
+
/** @internal */
|
|
49
|
+
_disconnectedCallback(): void;
|
|
50
|
+
/** @internal */
|
|
51
|
+
_load(): Promise<void>;
|
|
52
|
+
/** @internal */
|
|
53
|
+
_loaded(): void;
|
|
54
|
+
private _update;
|
|
55
|
+
private _updated;
|
|
56
|
+
destroy(): Promise<void>;
|
|
57
|
+
private _setAutoDestroyTimeout;
|
|
58
|
+
}
|
|
59
|
+
export declare let autoDestroyOnDisconnectTimeout: number;
|
|
60
|
+
export declare const exportsForTests: {
|
|
61
|
+
setAutoDestroyOnDisconnectTimeout: (timeout: number) => void;
|
|
62
|
+
} | undefined;
|
|
63
|
+
export declare const defaultGetterSetter: (value: unknown) => unknown;
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { n as devOnlySetPersistentControllerData, o as devOnlyGetPersistentControllerData, G as GenericController, f as trackPropKey, t as trackKey, r as retrieveComponent, d as createEventFactory } from "../../useWatch-CFtSpNnN.js";
|
|
2
|
+
import { p as proxyExports, a as bypassGetter, c as bypassSetter } from "../../proxyExports-Dl5CHmHQ.js";
|
|
3
|
+
import { isEsriInternalEnv, camelToKebab, isNotUndefined } from "@arcgis/components-utils";
|
|
4
|
+
import { on, watch } from "@arcgis/core/core/reactiveUtils.js";
|
|
5
|
+
const makeAccessorController = (loadAccessor, _options) => (component, options) => proxy(component, loadAccessor, options);
|
|
6
|
+
class AccessorController extends GenericController {
|
|
7
|
+
constructor(component, _loadAccessor, _options) {
|
|
8
|
+
super(component);
|
|
9
|
+
this._loadAccessor = _loadAccessor;
|
|
10
|
+
this._options = _options;
|
|
11
|
+
this._watchedProperties = /* @__PURE__ */ new Map();
|
|
12
|
+
this._isBinding = { value: true };
|
|
13
|
+
this.setProvisionalExports(
|
|
14
|
+
accessorSupport.makeGetterProxy(
|
|
15
|
+
component,
|
|
16
|
+
this._watchedProperties,
|
|
17
|
+
this._isBinding,
|
|
18
|
+
this.constructor.allowedPropNameMismatches
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
trackPropKey(
|
|
22
|
+
component,
|
|
23
|
+
(resolved) => {
|
|
24
|
+
if (resolved) {
|
|
25
|
+
this._instancePropName = resolved;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
this.exports
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
hostConnected() {
|
|
32
|
+
this._isBinding.value = false;
|
|
33
|
+
}
|
|
34
|
+
async hostLoad() {
|
|
35
|
+
const component = this.component;
|
|
36
|
+
const parameters = this._gatherParameters();
|
|
37
|
+
const finalParameters = this._options?.editConstructorProperties?.call(component, parameters) ?? parameters;
|
|
38
|
+
const awaitedParameters = finalParameters instanceof Promise ? await finalParameters : finalParameters;
|
|
39
|
+
const genericComponent = component;
|
|
40
|
+
const existingInstance = typeof this._instancePropName === "string" ? genericComponent[this._instancePropName] : void 0;
|
|
41
|
+
const hasInstance = existingInstance != null && existingInstance !== this.exports;
|
|
42
|
+
if (hasInstance) {
|
|
43
|
+
this._instance = existingInstance;
|
|
44
|
+
existingInstance.set(awaitedParameters);
|
|
45
|
+
} else {
|
|
46
|
+
this._instance = await this._createInstance(awaitedParameters);
|
|
47
|
+
}
|
|
48
|
+
if (component.manager.destroyed) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
accessorSupport.watchComponentUpdates(this, this._instance, this._watchedProperties);
|
|
52
|
+
accessorSupport.watchAccessorUpdates(this, this._instance, this._watchedProperties);
|
|
53
|
+
this.exports = this._instance;
|
|
54
|
+
}
|
|
55
|
+
_gatherParameters() {
|
|
56
|
+
const data = Object.fromEntries(
|
|
57
|
+
Array.from(
|
|
58
|
+
this._watchedProperties,
|
|
59
|
+
([prop, property]) => [property, this.component[prop]]
|
|
60
|
+
).filter(([, value]) => value !== void 0)
|
|
61
|
+
);
|
|
62
|
+
const props = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? filterWatchedProperties?.(this, data) ?? data : data;
|
|
63
|
+
return props;
|
|
64
|
+
}
|
|
65
|
+
async _createInstance(parameters) {
|
|
66
|
+
if (this._isAccessorConstructor(this._loadAccessor)) {
|
|
67
|
+
return new this._loadAccessor(parameters);
|
|
68
|
+
} else {
|
|
69
|
+
return await this._loadAccessor(parameters);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
_isAccessorConstructor(loader) {
|
|
73
|
+
return "prototype" in loader && "declaredClass" in loader.prototype;
|
|
74
|
+
}
|
|
75
|
+
hostDestroy() {
|
|
76
|
+
if (this._instance) {
|
|
77
|
+
this._instance.destroy();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async reCreate() {
|
|
81
|
+
this.hostDestroy();
|
|
82
|
+
await this.hostLoad();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const proxy = proxyExports(AccessorController);
|
|
86
|
+
const accessorSupport = {
|
|
87
|
+
makeGetterProxy: (component, watchedProperties, isBinding, allowedPropNameMismatches) => new Proxy(
|
|
88
|
+
{},
|
|
89
|
+
{
|
|
90
|
+
/*
|
|
91
|
+
* Without this, makeProvisionalValue() will throw on accessing
|
|
92
|
+
* non-existent prop
|
|
93
|
+
*/
|
|
94
|
+
has: (target, prop) => typeof prop === "string" || prop in target,
|
|
95
|
+
get: (target, prop) => {
|
|
96
|
+
const value = Reflect.get(target, prop);
|
|
97
|
+
if (typeof prop === "symbol" || prop in Promise.prototype) {
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
const hasProp = prop in target;
|
|
101
|
+
const doBinding = isBinding?.value ?? true;
|
|
102
|
+
if (hasProp || !doBinding) {
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
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
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
return trackKey(
|
|
114
|
+
component,
|
|
115
|
+
(resolved) => {
|
|
116
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
117
|
+
if (resolved === void 0) {
|
|
118
|
+
if (component.manager.isLit) {
|
|
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
|
+
);
|
|
124
|
+
}
|
|
125
|
+
const isFlippingBoolean = resolved.key.toLowerCase().includes("disable");
|
|
126
|
+
const collidesWithNativeProp = prop in HTMLElement.prototype;
|
|
127
|
+
const collidesWithCustomProp = allowedPropNameMismatches?.has(prop) === true;
|
|
128
|
+
if (resolved.key !== prop && !collidesWithNativeProp && !collidesWithCustomProp && !isFlippingBoolean) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
`Tried to bind "${resolved?.key}" property to "${prop.toString()}" - property names must match`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (!resolved.isReactive) {
|
|
134
|
+
throw new Error(
|
|
135
|
+
component.manager.isLit ? `For two-way binding with Accessor to work, the property on your component must have @property() or @state() decorator. "${prop.toString()}" has neither` : `For two-way binding with Accessor to work, the property on your component must have @Prop() or @State() decorator. "${prop.toString()}" has neither`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (resolved !== void 0) {
|
|
140
|
+
watchedProperties.set(resolved.key, prop);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
value
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
// Update Accessor on component prop change
|
|
149
|
+
watchComponentUpdates(controller, instance, watchedProperties) {
|
|
150
|
+
function getter(_value, propName) {
|
|
151
|
+
const propertyName = watchedProperties.get(propName);
|
|
152
|
+
const value = instance[propertyName];
|
|
153
|
+
const flipBoolean = typeof value === "boolean" && propertyName !== propName && propName.toLowerCase().includes("disable");
|
|
154
|
+
return flipBoolean ? !value : value;
|
|
155
|
+
}
|
|
156
|
+
const setter = (newValue, _oldValue, propName) => {
|
|
157
|
+
const propertyName = watchedProperties.get(propName);
|
|
158
|
+
const value = instance[propertyName];
|
|
159
|
+
const flipBoolean = typeof value === "boolean" && propertyName !== propName && propName.toLowerCase().includes("disable");
|
|
160
|
+
const currentValue = flipBoolean ? !value : component.manager.isLit ? value ?? void 0 : value;
|
|
161
|
+
if (currentValue === newValue) {
|
|
162
|
+
return newValue;
|
|
163
|
+
}
|
|
164
|
+
instance[propertyName] = flipBoolean ? !newValue : newValue;
|
|
165
|
+
const finalValue = instance[propertyName];
|
|
166
|
+
return flipBoolean ? !finalValue : finalValue;
|
|
167
|
+
};
|
|
168
|
+
const component = controller.component;
|
|
169
|
+
const internals = component.manager.internals;
|
|
170
|
+
watchedProperties.forEach((_propName, propertyName) => {
|
|
171
|
+
internals.accessorGetter[propertyName] = getter;
|
|
172
|
+
internals.accessorSetter[propertyName] = setter;
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
// Update component on Accessor prop change
|
|
176
|
+
watchAccessorUpdates(controller, instance, watchedProperties) {
|
|
177
|
+
const { component } = controller;
|
|
178
|
+
const genericComponent = component;
|
|
179
|
+
const genericInstance = instance;
|
|
180
|
+
const readonlyProps = findReadOnlyAccessorProps(instance);
|
|
181
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
182
|
+
setReadonlyProps?.(controller, readonlyProps);
|
|
183
|
+
}
|
|
184
|
+
bypassGetter(
|
|
185
|
+
() => (
|
|
186
|
+
// Careful: Map's forEach callback arguments are (value, key), not (key, value)
|
|
187
|
+
watchedProperties.forEach((propertyName, propName) => {
|
|
188
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && !(propertyName in instance)) {
|
|
189
|
+
throw new Error(`"${propertyName}" does not exist on the accessor instance`);
|
|
190
|
+
}
|
|
191
|
+
if (readonlyProps.has(propertyName)) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const domValue = genericComponent[propName];
|
|
195
|
+
let modelValue = genericInstance[propertyName];
|
|
196
|
+
if (component.manager.isLit) {
|
|
197
|
+
modelValue ??= void 0;
|
|
198
|
+
}
|
|
199
|
+
const flipBoolean = typeof domValue === "boolean" && propertyName !== propName && propName.toLowerCase().includes("disable");
|
|
200
|
+
const resolvedDomValue = flipBoolean ? !domValue : domValue;
|
|
201
|
+
if (resolvedDomValue != null && modelValue !== resolvedDomValue) {
|
|
202
|
+
genericInstance[propertyName] = resolvedDomValue;
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
controller.onLifecycle(() => {
|
|
208
|
+
if (instance.destroyed) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
return Array.from(
|
|
212
|
+
watchedProperties,
|
|
213
|
+
([propName, propertyName]) => watch(
|
|
214
|
+
() => genericInstance[propertyName],
|
|
215
|
+
() => {
|
|
216
|
+
const newValue = genericInstance[propertyName];
|
|
217
|
+
const flipBoolean = typeof newValue === "boolean" && propertyName !== propName && propName.toLowerCase().includes("disable");
|
|
218
|
+
const resolvedNewValue = flipBoolean ? !newValue : newValue;
|
|
219
|
+
bypassSetter(() => {
|
|
220
|
+
genericComponent[propName] = resolvedNewValue;
|
|
221
|
+
});
|
|
222
|
+
},
|
|
223
|
+
{ initial: true }
|
|
224
|
+
)
|
|
225
|
+
);
|
|
226
|
+
});
|
|
227
|
+
},
|
|
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
|
+
async reCreate(instance, component) {
|
|
258
|
+
const accessorController = component.manager.useRefSync(instance);
|
|
259
|
+
if (accessorController === void 0) {
|
|
260
|
+
if (process.env.NODE_ENV !== "production") {
|
|
261
|
+
console.error("Unable to resolve the useAccessor controller from the provided value");
|
|
262
|
+
}
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
await accessorController.reCreate();
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
function findReadOnlyAccessorProps(instance) {
|
|
269
|
+
const accessor = instance;
|
|
270
|
+
const properties = Object.entries(accessor.__accessor__?.metadata ?? {});
|
|
271
|
+
return new Set(
|
|
272
|
+
properties.filter(([_property, descriptor]) => descriptor?.readOnly === true).map(([property]) => property)
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
const setReadonlyProps = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (controller, properties) => {
|
|
276
|
+
devOnlySetPersistentControllerData?.(controller, properties);
|
|
277
|
+
} : void 0;
|
|
278
|
+
const filterWatchedProperties = process.env.NODE_ENV !== "production" && isEsriInternalEnv() ? (controller, data) => {
|
|
279
|
+
const readonlyProperties = devOnlyGetPersistentControllerData?.(controller);
|
|
280
|
+
if (readonlyProperties instanceof Set) {
|
|
281
|
+
return Object.fromEntries(Object.entries(data).filter(([key]) => !readonlyProperties.has(key)));
|
|
282
|
+
}
|
|
283
|
+
return data;
|
|
284
|
+
} : void 0;
|
|
285
|
+
function reEmitEvent(getEventedAccessor, eventName) {
|
|
286
|
+
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
|
+
const manager = component.manager;
|
|
293
|
+
manager.onLoaded(() => manager.onLifecycle(() => on(getEventedAccessor, eventName, emitter.emit)));
|
|
294
|
+
const emitter = createEventFactory();
|
|
295
|
+
if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
|
|
296
|
+
if (typeof emitter !== "object" || emitter === null || !("emit" in emitter) || typeof emitter.emit !== "function") {
|
|
297
|
+
throw new Error(`Expected to find $createEvent static property on Lumina's LitElement`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return emitter;
|
|
301
|
+
}
|
|
302
|
+
export {
|
|
303
|
+
AccessorController,
|
|
304
|
+
accessorSupport,
|
|
305
|
+
makeAccessorController,
|
|
306
|
+
reEmitEvent
|
|
307
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EventEmitter } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Re-emit an event from the accessor instance on the component
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* arcgisGo = reEmitEvent<__esri.HomeViewModelGoEvent>(() => this.viewModel, "go");
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* `reEmitEvent()` only works in Lumina. Consult documentation for equivalent
|
|
12
|
+
* Stencil pattern.
|
|
13
|
+
*/
|
|
14
|
+
export declare function reEmitEvent<T>(getEventedAccessor: () => __esri.Evented, eventName: string): EventEmitter<T>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Controller, GenericController } from '../Controller';
|
|
2
|
+
import { BaseComponent } from '../types';
|
|
3
|
+
type Requires<Props, Accessor extends __esri.Accessor> = BaseComponent & Pick<Accessor, keyof Accessor & keyof Props> & {
|
|
4
|
+
autoDestroyDisabled: boolean;
|
|
5
|
+
destroy: () => Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Given an Accessor class, create a controller that will do two-way binding of
|
|
9
|
+
* props between the component and the Accessor
|
|
10
|
+
*
|
|
11
|
+
* See 4.accessor.tsx for documentation & examples
|
|
12
|
+
*/
|
|
13
|
+
export declare const makeAccessorController: <Props, Accessor extends __esri.Accessor, OmitProps extends string = never>(loadAccessor: ((props: Props) => Accessor | Promise<Accessor>) | (new (props: Props) => Accessor), _options?: {
|
|
14
|
+
/**
|
|
15
|
+
* By default, to ensure that you didn't accidentally forget to bind any
|
|
16
|
+
* of the Accessor's properties on your component, every property that
|
|
17
|
+
* is accepted by the Accessor's constructor will be required to be bound
|
|
18
|
+
* on your component. If you do not wish to bind certain properties
|
|
19
|
+
* (or you wish to bind them but with a different type), you can omit
|
|
20
|
+
* them using this option.
|
|
21
|
+
*
|
|
22
|
+
* You can also bind the property to \@State rather than \@Prop if you
|
|
23
|
+
* wish to use it internally only:
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* \@State() timeZone = this.viewModel.timeZone;
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* This option affects the TypeScript error checking only - it has
|
|
31
|
+
* no runtime impact. Thus, if you wish to save a few bytes in the
|
|
32
|
+
* bundle, rather than simply setting this property like
|
|
33
|
+
* `makeAccessorController(..., { omitProps: ["propName"] })`, you can
|
|
34
|
+
* set it like this:
|
|
35
|
+
* `makeAccessorController(..., {} as { omitProps: ["propName"] })`
|
|
36
|
+
*/
|
|
37
|
+
omitProps: OmitProps[];
|
|
38
|
+
}) => (component: Requires<Omit<Props, OmitProps>, Accessor>, options?: {
|
|
39
|
+
editConstructorProperties(props: Props): Promise<Props> | Props;
|
|
40
|
+
}) => Accessor;
|
|
41
|
+
export declare class AccessorController<Props, Accessor extends __esri.Accessor, ExtraRequires = Record<never, never>> extends GenericController<Accessor, ExtraRequires & Requires<Props, Accessor>> {
|
|
42
|
+
private _loadAccessor;
|
|
43
|
+
private _options?;
|
|
44
|
+
protected _instance: Accessor;
|
|
45
|
+
protected _watchedProperties: Map<string, string & keyof Props>;
|
|
46
|
+
private _instancePropName;
|
|
47
|
+
private _isBinding;
|
|
48
|
+
/**
|
|
49
|
+
* (development only) Allow these props to mismatch the name of the Accessor's property
|
|
50
|
+
* to avoid collisions
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
static allowedPropNameMismatches?: Set<string>;
|
|
55
|
+
constructor(component: ExtraRequires & Requires<Props, Accessor>, _loadAccessor: ((props: Props) => Accessor | Promise<Accessor>) | (new (props: Props) => Accessor), _options?: {
|
|
56
|
+
editConstructorProperties?(props: Props): Promise<Props> | Props;
|
|
57
|
+
} | undefined);
|
|
58
|
+
hostConnected(): void;
|
|
59
|
+
hostLoad(): Promise<void>;
|
|
60
|
+
private _gatherParameters;
|
|
61
|
+
private _createInstance;
|
|
62
|
+
private _isAccessorConstructor;
|
|
63
|
+
hostDestroy(): void;
|
|
64
|
+
reCreate(): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
export declare const accessorSupport: {
|
|
67
|
+
makeGetterProxy: (component: BaseComponent, watchedProperties: Map<string, string>, isBinding?: {
|
|
68
|
+
value: boolean;
|
|
69
|
+
}, allowedPropNameMismatches?: Set<string>) => unknown;
|
|
70
|
+
watchComponentUpdates<T>(controller: Controller<T>, instance: __esri.Accessor, watchedProperties: Map<string, string>): void;
|
|
71
|
+
watchAccessorUpdates<T>(controller: Controller<T>, instance: __esri.Accessor, watchedProperties: Map<string, string>): void;
|
|
72
|
+
reEmitAccessorEvents<T>(controller: Controller<T>, instance: __esri.Accessor, prefix: string): void;
|
|
73
|
+
reCreate(instance: __esri.Accessor, component: BaseComponent): Promise<void>;
|
|
74
|
+
};
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
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;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GenericControllerType, Controller } from './Controller';
|
|
2
|
+
import { BaseComponent, ControllerHost } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Controller is a function that takes a component instance and then can
|
|
5
|
+
* export some values to the component, or hook into component's lifecycle
|
|
6
|
+
*
|
|
7
|
+
* See controllers documentation for many example controllers and their usages
|
|
8
|
+
*/
|
|
9
|
+
export declare const makeController: <Exports>(constructor: (component: BaseComponent & ControllerHost, controller: Controller<Exports>) => Exports | Promise<Exports>) => Exports;
|
|
10
|
+
/**
|
|
11
|
+
* If your controller requires some specific properties to be present on the
|
|
12
|
+
* component, besides what's included in the BaseComponent, use
|
|
13
|
+
* makeGenericController
|
|
14
|
+
*
|
|
15
|
+
* When using a controller created using makeGenericController(), consumer must
|
|
16
|
+
* pass in "this" explicitly for proper type-checking. If controller was
|
|
17
|
+
* created using makeController(), that is not necessary
|
|
18
|
+
*/
|
|
19
|
+
export declare const makeGenericController: <Exports, Component = BaseComponent>(constructor: (component: BaseComponent & Component & ControllerHost, controller: GenericControllerType<Exports, Component>) => Exports | Promise<Exports>) => (component: BaseComponent & Component) => Exports;
|
|
@@ -0,0 +1,116 @@
|
|
|
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;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type { GenericControllerType } from './Controller';
|
|
2
|
+
export { Controller, GenericController } from './Controller';
|
|
3
|
+
export type { ControllerManager } from './ControllerManager';
|
|
4
|
+
export { retrieveComponent } from './ControllerInternals';
|
|
5
|
+
export { useControllerManager } from './ControllerManager';
|
|
6
|
+
export { trackPropertyKey, keyTrackResolve } from './trackPropertyKey';
|
|
7
|
+
export { trackPropKey } from './trackPropKey';
|
|
8
|
+
export { trackKey } from './trackKey';
|
|
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
|
+
export { useWatchAttributes } from './useWatchAttributes';
|
|
14
|
+
export { load } from './load';
|
|
15
|
+
export { proxyExports } from './proxyExports';
|
|
16
|
+
export { toFunction } from './toFunction';
|
|
17
|
+
export * from './types';
|
|
18
|
+
export { useMedia } from './useMedia';
|
|
19
|
+
export { useDirection } from './useDirection';
|
|
20
|
+
export type { UseT9n, T9nMeta } from './useT9n';
|
|
21
|
+
export { makeT9nController } from './useT9n';
|
|
22
|
+
export { usePropertyChange } from './usePropertyChange';
|
|
23
|
+
export { isController } from './utils';
|