@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.
Files changed (43) hide show
  1. package/dist/ControllerManager-B2comd8J.js +310 -0
  2. package/dist/LitElement.d.ts +3 -3
  3. package/dist/context.d.ts +1 -1
  4. package/dist/controllers/ComponentInternals.d.ts +92 -0
  5. package/dist/controllers/Controller.d.ts +152 -0
  6. package/dist/controllers/ControllerInternals.d.ts +52 -0
  7. package/dist/controllers/ControllerManager.d.ts +63 -0
  8. package/dist/controllers/accessor/index.d.ts +2 -0
  9. package/dist/controllers/accessor/index.js +307 -0
  10. package/dist/controllers/accessor/reEmitEvent.d.ts +14 -0
  11. package/dist/controllers/accessor/useAccessor.d.ts +75 -0
  12. package/dist/controllers/framework.d.ts +45 -0
  13. package/dist/controllers/functional.d.ts +19 -0
  14. package/dist/controllers/getSet.d.ts +116 -0
  15. package/dist/controllers/index.d.ts +23 -0
  16. package/dist/controllers/index.js +283 -0
  17. package/dist/controllers/load.d.ts +6 -0
  18. package/dist/controllers/proxyExports.d.ts +27 -0
  19. package/dist/controllers/readonly.d.ts +29 -0
  20. package/dist/controllers/tests/autoDestroyMock.d.ts +5 -0
  21. package/dist/controllers/tests/utils.d.ts +1 -0
  22. package/dist/controllers/toFunction.d.ts +8 -0
  23. package/dist/controllers/trackKey.d.ts +8 -0
  24. package/dist/controllers/trackPropKey.d.ts +21 -0
  25. package/dist/controllers/trackPropertyKey.d.ts +28 -0
  26. package/dist/controllers/types.d.ts +182 -0
  27. package/dist/controllers/useDirection.d.ts +11 -0
  28. package/dist/controllers/useMedia.d.ts +8 -0
  29. package/dist/controllers/usePropertyChange.d.ts +11 -0
  30. package/dist/controllers/useT9n.d.ts +48 -0
  31. package/dist/controllers/useWatch.d.ts +27 -0
  32. package/dist/controllers/useWatchAttributes.d.ts +7 -0
  33. package/dist/controllers/utils.d.ts +15 -0
  34. package/dist/createEvent.d.ts +1 -1
  35. package/dist/decorators.d.ts +1 -1
  36. package/dist/index.d.ts +2 -2
  37. package/dist/index.js +5 -42
  38. package/dist/lazyLoad.d.ts +2 -2
  39. package/dist/makeRuntime.d.ts +109 -0
  40. package/dist/proxyExports-Dl5CHmHQ.js +150 -0
  41. package/dist/runtime.d.ts +4 -107
  42. package/dist/useWatch-CFtSpNnN.js +925 -0
  43. package/package.json +4 -3
@@ -0,0 +1,283 @@
1
+ import { C as Controller, s as setAmbientComponent, i as isPromise, a as setParentController, b as retrieveParentControllers, t as trackKey, w as watch, r as retrieveComponent, d as createEventFactory, P as PropTypes } from "../useWatch-CFtSpNnN.js";
2
+ import { G, h, g, k, f, e } from "../useWatch-CFtSpNnN.js";
3
+ import { u } from "../ControllerManager-B2comd8J.js";
4
+ import { p as proxyExports } from "../proxyExports-Dl5CHmHQ.js";
5
+ import { a, b, c, d, g as g2, r } from "../proxyExports-Dl5CHmHQ.js";
6
+ import { observeAncestorsMutation, isEsriInternalEnv, getElementAttribute, getElementLocales, startLocaleObserver } from "@arcgis/components-utils";
7
+ const makeController = (constructor) => proxy(void 0, constructor);
8
+ const makeGenericController = (constructor) => (component) => proxy(
9
+ component,
10
+ /**
11
+ * GenericController is identical to Controller, in all except for typing.
12
+ * So dying a type-cast here so as not to needlessly add one more object
13
+ * to the prototype chain
14
+ */
15
+ constructor
16
+ );
17
+ class FunctionalController extends Controller {
18
+ constructor(component, constructor) {
19
+ super(component);
20
+ const originalExports = this.exports;
21
+ try {
22
+ setAmbientComponent(this.component);
23
+ const value = constructor(this.component, this);
24
+ const constructorChangedExports = this.exports !== originalExports;
25
+ if (isPromise(value)) {
26
+ if (!constructorChangedExports) {
27
+ this.setProvisionalExports(value);
28
+ }
29
+ const resolved = value.then((result) => {
30
+ this.exports = result;
31
+ super.catchUpLifecycle();
32
+ }).catch((error) => {
33
+ this._ready.reject(error);
34
+ console.error(error);
35
+ });
36
+ this.onLoad(async () => await resolved);
37
+ } else {
38
+ if (!constructorChangedExports || value !== void 0) {
39
+ this.exports = value;
40
+ }
41
+ queueMicrotask(() => super.catchUpLifecycle());
42
+ }
43
+ } catch (error) {
44
+ this._ready.reject(error);
45
+ console.error(error);
46
+ }
47
+ }
48
+ /** Noop - will be called in the constructor instead */
49
+ catchUpLifecycle() {
50
+ return;
51
+ }
52
+ }
53
+ const proxy = proxyExports(FunctionalController);
54
+ const useWatchAttributes = (attributes, callback) => new AttributeWatchController(attributes, callback);
55
+ class AttributeWatchController extends Controller {
56
+ constructor(_attributes, _callback) {
57
+ super();
58
+ this._attributes = _attributes;
59
+ this._callback = _callback;
60
+ this._observer = new MutationObserver((mutations) => {
61
+ mutations.forEach((mutation) => {
62
+ if (_attributes.includes(mutation.attributeName)) {
63
+ _callback.call(
64
+ this.component,
65
+ this.component.el.getAttribute(mutation.attributeName),
66
+ mutation.oldValue,
67
+ mutation.attributeName
68
+ );
69
+ }
70
+ });
71
+ });
72
+ }
73
+ hostConnected() {
74
+ this._attributes.forEach((attribute) => {
75
+ if (this.component.el.hasAttribute(attribute)) {
76
+ this._callback.call(this.component, null, this.component.el.getAttribute(attribute), attribute);
77
+ }
78
+ });
79
+ this._observer.observe(this.component.el, {
80
+ attributes: true,
81
+ attributeOldValue: true,
82
+ attributeFilter: this._attributes
83
+ });
84
+ }
85
+ hostDisconnected() {
86
+ this._observer.disconnect();
87
+ }
88
+ }
89
+ const load = makeController;
90
+ const toFunction = (Class) => (...args) => {
91
+ const ambientControllers = retrieveParentControllers();
92
+ const instance = new Class(...args);
93
+ setParentController(ambientControllers.at(-1));
94
+ return instance;
95
+ };
96
+ const useMedia = (query) => makeController((_component, controller) => {
97
+ const media = globalThis.matchMedia(query);
98
+ function changed() {
99
+ controller.exports = media.matches;
100
+ }
101
+ changed();
102
+ controller.onLifecycle(() => {
103
+ media.addEventListener("change", changed);
104
+ return () => media.removeEventListener("change", changed);
105
+ });
106
+ return void 0;
107
+ });
108
+ const defaultDirection = "ltr";
109
+ const useDirection = () => makeController((component, controller) => {
110
+ controller.exports = defaultDirection;
111
+ controller.onLifecycle(() => {
112
+ function callback() {
113
+ const dir = getElementAttribute(component.el, "dir", defaultDirection);
114
+ controller.exports = dir === "rtl" ? "rtl" : "ltr";
115
+ }
116
+ callback();
117
+ return observeAncestorsMutation(component.el, ["dir"], callback);
118
+ });
119
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
120
+ trackKey(
121
+ component,
122
+ (resolved) => {
123
+ if (resolved?.key === "dir") {
124
+ throw new Error(
125
+ `Do not assign this controller to a prop called \`dir\` as that will overwrite the \`dir\` attribute on the host element - component should not be setting the \`dir\` attribute on itself. Instead, assign this controller to a property called \`direction\`.`
126
+ );
127
+ }
128
+ },
129
+ controller.exports
130
+ );
131
+ }
132
+ return void 0;
133
+ });
134
+ const makeT9nController = (getAssetPath) => (options = {}) => (
135
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
136
+ makeController((component, controller) => {
137
+ const locale = getElementLocales(component.el);
138
+ const pending = {
139
+ _lang: locale.lang,
140
+ _t9nLocale: locale.t9nLocale,
141
+ _loading: true
142
+ };
143
+ const componentWithOverrides = component;
144
+ controller.onLifecycle(
145
+ () => startLocaleObserver(
146
+ component.el,
147
+ () => getAssetPath("./assets"),
148
+ ({ t9nLocale, t9nStrings, lang }) => {
149
+ const withoutOverrides = {
150
+ ...t9nStrings,
151
+ _lang: lang,
152
+ _t9nLocale: t9nLocale,
153
+ _loading: false
154
+ };
155
+ controller.exports = withoutOverrides;
156
+ const label = t9nStrings.componentLabel;
157
+ if (typeof label === "string" && "label" in component && component.label == null) {
158
+ component.label ??= label;
159
+ }
160
+ applyOverrides(componentWithOverrides.messageOverrides);
161
+ },
162
+ options.name
163
+ )
164
+ );
165
+ function applyOverrides(messageOverrides) {
166
+ const currentValue = controller.exports;
167
+ const rawMessages = currentValue._original ?? currentValue;
168
+ const updated = deepMerge(rawMessages, messageOverrides);
169
+ if (messageOverrides) {
170
+ updated._original = rawMessages;
171
+ }
172
+ controller.exports = updated;
173
+ }
174
+ if ("messageOverrides" in componentWithOverrides) {
175
+ controller.onLifecycle(() => watch(componentWithOverrides, "messageOverrides", applyOverrides));
176
+ }
177
+ if (options.blocking) {
178
+ controller.setProvisionalExports(pending, false);
179
+ return controller.ready;
180
+ } else {
181
+ return pending;
182
+ }
183
+ })
184
+ );
185
+ function deepMerge(original, overwrites) {
186
+ if (!overwrites) {
187
+ return original;
188
+ }
189
+ const merged = { ...original };
190
+ Object.entries(overwrites).forEach(([key, value]) => {
191
+ if (typeof value === "object") {
192
+ merged[key] = deepMerge(original[key], value);
193
+ } else {
194
+ merged[key] = value ?? original[key];
195
+ }
196
+ });
197
+ return merged;
198
+ }
199
+ const usePropertyChange = (_component) => propertyChangeController;
200
+ const eventName = "arcgisPropertyChange";
201
+ function propertyChangeController(...toWatch) {
202
+ const component = retrieveComponent();
203
+ const eventedComponent = component;
204
+ let eventEmitter = eventedComponent[eventName];
205
+ if (component.manager.isLit) {
206
+ eventEmitter = createEventFactory(eventName, void 0, component);
207
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
208
+ if (typeof eventEmitter !== "object" || eventEmitter === null || !("emit" in eventEmitter) || typeof eventEmitter.emit !== "function") {
209
+ throw new Error(`Expected to find $createEvent static property on Lumina's LitElement"`);
210
+ }
211
+ }
212
+ }
213
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
214
+ if (typeof eventEmitter !== "object" || eventEmitter === null || !("emit" in eventEmitter) || typeof eventEmitter.emit !== "function") {
215
+ throw new Error(
216
+ `For consistency, usePropertyChange must be assigned to an arcgisPropertyChange property that has an @Event() decorator`
217
+ );
218
+ }
219
+ const allProps = new Set(
220
+ Object.entries(component.manager.internals.members).filter(([_name, [propType]]) => (propType & PropTypes.Prop) !== 0).map(([name]) => name)
221
+ );
222
+ toWatch.forEach((prop) => {
223
+ if (!allProps.has(prop)) {
224
+ throw new Error(
225
+ prop in component ? `For usePropertyChange to emit event on "${prop}" property change, you should add @${component.manager.isLit ? "property" : "Prop"}() to ${prop} in ${component.el.localName}` : `usePropertyChange can't emit event on "${prop}" property change as such property does not exist in ${component.el.localName}`
226
+ );
227
+ }
228
+ });
229
+ }
230
+ component.manager.onLoad(
231
+ () => component.manager.onLifecycle(
232
+ () => toWatch.map(
233
+ (name) => (
234
+ // Casting to 'el' to simplify dynamic prop name typing
235
+ watch(component, name, () => eventEmitter.emit({ name }))
236
+ )
237
+ )
238
+ )
239
+ );
240
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv() && component.manager.isLit) {
241
+ trackKey(
242
+ component,
243
+ (resolution) => {
244
+ if (resolution === void 0 || resolution.isReactive || resolution.key !== eventName) {
245
+ throw new Error(
246
+ `For consistency, usePropertyChange must be assigned to an arcgisPropertyChange property and that property should not have @property() or @state() decorators: arcgisPropertyChange = usePropertyChange<this>()("prop1", "prop2");`
247
+ );
248
+ }
249
+ },
250
+ eventEmitter
251
+ );
252
+ }
253
+ return eventEmitter;
254
+ }
255
+ export {
256
+ Controller,
257
+ G as GenericController,
258
+ a as bypassGetter,
259
+ b as bypassReadOnly,
260
+ c as bypassSetter,
261
+ h as controllerSymbol,
262
+ d as dynamicGetSet,
263
+ g2 as getSet,
264
+ g as isController,
265
+ k as keyTrackResolve,
266
+ load,
267
+ makeController,
268
+ makeGenericController,
269
+ makeT9nController,
270
+ proxyExports,
271
+ r as readonly,
272
+ retrieveComponent,
273
+ toFunction,
274
+ trackKey,
275
+ f as trackPropKey,
276
+ e as trackPropertyKey,
277
+ u as useControllerManager,
278
+ useDirection,
279
+ useMedia,
280
+ usePropertyChange,
281
+ useWatchAttributes,
282
+ watch
283
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Load a value from a promise and provide it to the component
3
+ *
4
+ * Documentation: https://qawebgis.esri.com/components/lumina/controllers/load
5
+ */
6
+ export declare const load: <T>(loader: () => Promise<T>) => T;
@@ -0,0 +1,27 @@
1
+ import { Controller } from './Controller';
2
+ import { ControllerLifecycleMethods } from './types';
3
+ /**
4
+ * If you wish to directly expose the "exports" property of your controller,
5
+ * rather than the entire controller class, wrap your class definition in
6
+ * "proxyExports".
7
+ *
8
+ * This is especially convenient when your exports is not an object, or it is a
9
+ * dynamically created object, and so you don't want your Controller's methods
10
+ * interfering with the keys on the exported value.
11
+ *
12
+ * "proxyExports" is the default behavior for all controllers declared using
13
+ * the makeController()/makeGenericController() function
14
+ *
15
+ * @remarks
16
+ * If using readonly(), and controller updates its exports, the readonly prop
17
+ * will still get updated
18
+ *
19
+ * @remarks
20
+ * (Advanced) If you wish to use proxyExports() in a class that does not
21
+ * extend Controller class and does not have a useControllerManager(), then your
22
+ * class must subclass a class with the following constructor:
23
+ * `constructor() { setAmbientController(this); }`. This
24
+ * is necessary for proxyExports() to receive a reference to your object
25
+ * implicitly, and before any of your default values are assigned.
26
+ */
27
+ export declare const proxyExports: <Exports, const Parameters extends unknown[]>(Class: new (...args: Parameters) => ControllerLifecycleMethods & Pick<Controller<Exports>, "component" | "exports" | "watchExports">) => ((...args: Parameters) => Exports);
@@ -0,0 +1,29 @@
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;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Mocking utility for changing auto-destroy timeout in ControllerManager to 0ms.
3
+ * Also, returns a convenient promise that resolves after the timeout.
4
+ */
5
+ export declare function autoDestroyMock(timeout?: number): () => Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function captureConsoleErrors(): unknown[][];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A tiny helper for using a class-based controller as if it's a function.
3
+ * Main advantage of this is that it's a bit shorter to type.
4
+ *
5
+ * This utility can be used for converting non-controller classes to functions
6
+ * too
7
+ */
8
+ export declare const toFunction: <T, const P extends unknown[]>(Class: new (...args: P) => T) => ((...args: P) => T);
@@ -0,0 +1,8 @@
1
+ import { TrackKeyResolution } from './ComponentInternals';
2
+ import { BaseComponent, BaseController } from './types';
3
+ /**
4
+ * A combination of trackPropertyKey() and trackPropKey(). For usage when
5
+ * you want to track a property, but don't know if it will be defined with the
6
+ * \@Prop() decorator or not
7
+ */
8
+ export declare function trackKey<T>(hostsCandidates: ((BaseComponent | BaseController)[] | BaseComponent | BaseController) | undefined, onResolved: (resolution: TrackKeyResolution | undefined) => void, defaultValue: T): T;
@@ -0,0 +1,21 @@
1
+ import { BaseComponent } from './types';
2
+ /**
3
+ * Like manager.trackPropertyKey(), but for props that have \@State() or \@Prop()
4
+ * decorator
5
+ *
6
+ * @example
7
+ * function trackMe() {
8
+ * const component = retrieveComponent();
9
+ * const defaultValue = 'some value';
10
+ * return trackPropKey(component, (key)=>console.log(key), defaultValue);
11
+ * }
12
+ *
13
+ * class MyComponent extends BaseComponent {
14
+ * // Will console log "myProp"
15
+ * @Prop() myProp = trackMe();
16
+ *
17
+ * // Will console log "myState"
18
+ * @State() myState = trackMe();
19
+ * }
20
+ */
21
+ export declare function trackPropKey<T>(component: BaseComponent, onResolved: (key: string | undefined) => void, defaultValue: T): T;
@@ -0,0 +1,28 @@
1
+ import { BaseComponent, BaseController } from './types';
2
+ /**
3
+ * A magical solution to finding out what property name a given controller
4
+ * on a given object was assigned to.
5
+ *
6
+ * @remarks
7
+ * This does not work for properties that have \@Prop() or \@State()
8
+ * decorator - for those, use manager.trackPropKey() instead.
9
+ *
10
+ * @example
11
+ * function trackMe<T>(defaultValue:T, component:BaseComponent):T {
12
+ * component.manager.trackPropertyKey(component, (key)=>console.log(key), defaultValue);
13
+ * return defaultValue;
14
+ * }
15
+ *
16
+ * class MyComponent extends BaseComponent {
17
+ * // Will console log "myProp"
18
+ * myProp = trackMe('a', this);
19
+ * }
20
+ *
21
+ */
22
+ export declare function trackPropertyKey<T>(object: BaseComponent | BaseController, onResolved: (key: string | undefined) => void, defaultValue: T): T;
23
+ /**
24
+ * Resolve all pending trackPropertyKey() calls. This must be called after a
25
+ * property you are trying to resolve had it's default value set, thus after
26
+ * constructor. At the start of connectedCallback is a perfect place.
27
+ */
28
+ export declare function keyTrackResolve(): void;
@@ -0,0 +1,182 @@
1
+ import { IHandle } from '@arcgis/components-utils';
2
+ import { ReactiveControllerHost, ReactiveController, PropertyDeclaration, PropertyValues } from 'lit';
3
+ import { LitElement } from '../LitElement';
4
+ /**
5
+ * Explicitly picking rather than extending everything because the interface
6
+ * has "[memberName: string]: any;", which ruins type-safety of components
7
+ *
8
+ * @deprecated use LitElement instead
9
+ */
10
+ export type StencilLifecycles = {
11
+ connectedCallback?: () => void;
12
+ disconnectedCallback?: () => void;
13
+ componentWillLoad?: () => Promise<void> | void;
14
+ componentDidLoad?: () => void;
15
+ componentShouldUpdate?: (newVal: any, oldVal: any, propName: string) => boolean | void;
16
+ componentWillUpdate?: () => Promise<void> | void;
17
+ componentDidUpdate?: () => void;
18
+ };
19
+ /**
20
+ * @deprecated use LitElement instead
21
+ */
22
+ export type BaseComponent = Omit<LitElement, "componentOnReady"> & {
23
+ autoDestroyDisabled?: boolean;
24
+ destroy?: () => Promise<void>;
25
+ };
26
+ /**
27
+ * Helper utility to get component type from a controller. Can be used in
28
+ * "implements"
29
+ * @example
30
+ * const useHomeViewModel = makeViewModelController(newWidgetsHomeHomeViewModel);
31
+ * export class Home implements Use<typeof useHomeViewModel> {
32
+ * // No need for "implements BaseComponent" as that's already included in
33
+ * // every controller
34
+ *
35
+ * @remarks
36
+ * TypeScript detects errors even without Use<typeof useHomeViewModel>, but Use
37
+ * makes errors display in a more readable format
38
+ */
39
+ export type Use<Callback extends (component: any) => unknown> = Parameters<Callback>[0];
40
+ /**
41
+ * Base API for a controller. Compatible with both Lit's Reactive controllers
42
+ * and Stencil's lifecycle
43
+ */
44
+ export type ControllerLifecycleMethods = {
45
+ readonly hostConnected?: ReactiveController["hostConnected"];
46
+ readonly hostDisconnected?: ReactiveController["hostDisconnected"];
47
+ readonly hostLoad?: StencilLifecycles["componentWillLoad"];
48
+ readonly hostLoaded?: StencilLifecycles["componentDidLoad"];
49
+ /**
50
+ * Called during the client-side host update, just before the host calls
51
+ * its own update.
52
+ *
53
+ * Code in `update()` can depend on the DOM as it is not called in
54
+ * server-side rendering.
55
+ *
56
+ * @remarks
57
+ * The `changes` parameter will only be present in Lumina, not in Stencil
58
+ */
59
+ readonly hostUpdate?: (changes: PropertyValues) => void;
60
+ /**
61
+ * Called after a host update, just before the host calls firstUpdated and
62
+ * updated. It is not called in server-side rendering.
63
+ *
64
+ * @remarks
65
+ * The `changes` parameter will only be present in Lumina, not in Stencil
66
+ */
67
+ readonly hostUpdated?: (changes: PropertyValues) => void;
68
+ /**
69
+ * Called when the component is finally being destroyed (rather than
70
+ * temporary disconnected from the DOM)
71
+ */
72
+ readonly hostDestroy?: () => void;
73
+ /**
74
+ * lifecycle() is a convenience higher-level callback that:
75
+ * - calls the provided callback right away the first time if
76
+ * connectedCallback has already happened once
77
+ * - otherwise, calls it on connectedCallback
78
+ * - calls the callback on each future connectedCallback
79
+ * - if you returned a function, or an object like {remove:()=>void}, that
80
+ * function will be called on the next disconnectedCallback
81
+ *
82
+ * This is a bit like useEffect(callback, []) in React
83
+ */
84
+ readonly hostLifecycle?: () => (() => void)[] | IHandle | IHandle[] | (() => void) | undefined | void;
85
+ /**
86
+ * Called after component.removeComponent(controller) was called on this
87
+ * controller
88
+ */
89
+ readonly controllerRemoved?: () => void;
90
+ };
91
+ /**
92
+ * Controller host interface, compatible with both Lit's Reactive controllers
93
+ * and Stencil's lifecycle.
94
+ * These members are added to the component instance by ControllerManager.
95
+ */
96
+ export type ControllerHost = {
97
+ /**
98
+ * Adds a controller to the host, which connects the controller's lifecycle
99
+ * methods to the host's lifecycle.
100
+ */
101
+ addController(controller: BaseController): void;
102
+ addController(controller: ReactiveController): void;
103
+ /**
104
+ * Removes a controller from the host.
105
+ */
106
+ removeController(controller: BaseController): void;
107
+ removeController(controller: ReactiveController): void;
108
+ /**
109
+ * Requests a host update which is processed asynchronously. The update can
110
+ * be waited on via the `updateComplete` property.
111
+ *
112
+ * @remarks
113
+ * In Stencil:
114
+ * This method will re-render your component. All passed parameters are ignored
115
+ *
116
+ * In Lit:
117
+ * It is recommended to provide the property name describing what property
118
+ * triggered the update - property name will be provided to the willUpdate()
119
+ * lifecycle hook, giving it the ability to react to the change.
120
+ *
121
+ * @see https://lit.dev/docs/api/ReactiveElement/#ReactiveElement.requestUpdate
122
+ */
123
+ requestUpdate: (name?: PropertyKey, oldValue?: unknown, options?: PropertyDeclaration) => void;
124
+ readonly updateComplete: ReactiveControllerHost["updateComplete"];
125
+ };
126
+ /**
127
+ * A symbol is used to mark providers/controllers on a component instance.
128
+ * This helps to distinguish them from regular properties.
129
+ */
130
+ export declare const controllerSymbol: unique symbol;
131
+ /**
132
+ * Adding an optional symbol to satisfy TypeScript
133
+ * "type Controller has no properties in common with BaseController"
134
+ */
135
+ export type BaseController = ControllerLifecycleMethods & {
136
+ readonly [controllerSymbol]?: true;
137
+ };
138
+ /**
139
+ * A reference to Lit's map of changed properties that triggered the update
140
+ */
141
+ export type LitElementWithChangedPropertiesMap = {
142
+ $changes: PropertyValues;
143
+ };
144
+ /**
145
+ * An event emitter object
146
+ */
147
+ export type EventEmitter<T = undefined> = {
148
+ emit(payload: T extends undefined ? void : T): CustomEvent<T>;
149
+ };
150
+ /**
151
+ * Property declaration with additional `reaDonly` option (handled by Controllers)
152
+ */
153
+ export type LuminaPropertyDeclaration = PropertyDeclaration & {
154
+ /**
155
+ * Declare a property that can't be modified by the developer.
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * \@property({ readOnly: true })
160
+ * myReadonlyProp = 'initialValue';
161
+ * ```
162
+ *
163
+ * @example
164
+ * Inside the component code, you can overwrite the readOnly property like so:
165
+ * ```ts
166
+ * bypassReadOnly(() => {
167
+ * this.myReadonlyProp = 'newValue';
168
+ * });
169
+ * ```
170
+ *
171
+ * @example
172
+ * Alternatively, you can declare a readOnly prop like so:
173
+ *
174
+ * ```ts
175
+ * \@property()
176
+ * get myReadonlyProp(): string {
177
+ * return 'someValue';
178
+ * }
179
+ * ```
180
+ */
181
+ readonly readOnly?: boolean;
182
+ };
@@ -0,0 +1,11 @@
1
+ type Direction = "ltr" | "rtl";
2
+ /**
3
+ * Finds the closest "dir" attribute to current component and returns it's value.
4
+ * Watches for changes to "dir" and will re-render your component if needed.
5
+ *
6
+ * Documentation: https://qawebgis.esri.com/components/lumina/controllers/useDirection
7
+ *
8
+ * Design decisions: https://devtopia.esri.com/WebGIS/arcgis-web-components/discussions/987
9
+ */
10
+ export declare const useDirection: () => Direction;
11
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Lets you query whether a given CSS media query applies to the page (i.e.
3
+ * whether user asked to use reduced motion, or whether the screen size is above
4
+ * certain threshold).
5
+ *
6
+ * Documentation: https://qawebgis.esri.com/components/lumina/controllers/useMedia
7
+ */
8
+ export declare const useMedia: (query: string) => boolean;
@@ -0,0 +1,11 @@
1
+ import { BaseComponent, EventEmitter } from './types';
2
+ type PropertyChangeController<Component extends BaseComponent> = <ToWatch extends keyof Component>(...toWatch: ToWatch[]) => EventEmitter<{
3
+ name: ToWatch & string;
4
+ }>;
5
+ /**
6
+ * Let user easily set watchers for component properties.
7
+ *
8
+ * Documentation: https://qawebgis.esri.com/components/lumina/controllers/usePropertyChange
9
+ */
10
+ export declare const usePropertyChange: <Component extends BaseComponent>(_component?: BaseComponent) => PropertyChangeController<Component>;
11
+ export {};