@arcgis/lumina 4.33.0-next.97 → 4.33.0-next.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/{useWatch-CFtSpNnN.js → Controller-CZ8Djohh.js} +70 -368
  2. package/dist/LitElement.d.ts +33 -25
  3. package/dist/context.d.ts +12 -2
  4. package/dist/controllers/Controller.d.ts +18 -17
  5. package/dist/controllers/ControllerInternals.d.ts +19 -12
  6. package/dist/controllers/ControllerManager.d.ts +62 -42
  7. package/dist/controllers/accessor/index.js +12 -60
  8. package/dist/controllers/accessor/reEmitEvent.d.ts +1 -5
  9. package/dist/controllers/accessor/useAccessor.d.ts +6 -7
  10. package/dist/controllers/functional.d.ts +4 -4
  11. package/dist/controllers/index.d.ts +6 -5
  12. package/dist/controllers/index.js +35 -55
  13. package/dist/controllers/proxyExports.d.ts +1 -1
  14. package/dist/controllers/trackKey.d.ts +4 -4
  15. package/dist/controllers/trackPropKey.d.ts +6 -6
  16. package/dist/controllers/trackPropertyKey.d.ts +8 -7
  17. package/dist/controllers/types.d.ts +15 -45
  18. package/dist/controllers/usePropertyChange.d.ts +4 -3
  19. package/dist/controllers/useT9n.d.ts +1 -1
  20. package/dist/createEvent.d.ts +7 -2
  21. package/dist/hmrSupport.js +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.js +331 -14
  24. package/dist/lazyLoad.d.ts +14 -14
  25. package/dist/proxyExports-CK5BLFLO.js +60 -0
  26. package/dist/{utils-GhKD5Lo-.js → utils-DBdf1Dqp.js} +4 -12
  27. package/package.json +2 -2
  28. package/dist/ControllerManager-B2comd8J.js +0 -310
  29. package/dist/controllers/ComponentInternals.d.ts +0 -92
  30. package/dist/controllers/framework.d.ts +0 -45
  31. package/dist/controllers/getSet.d.ts +0 -116
  32. package/dist/controllers/readonly.d.ts +0 -29
  33. package/dist/controllers/useWatch.d.ts +0 -27
  34. package/dist/proxyExports-Dl5CHmHQ.js +0 -150
@@ -1,8 +1,6 @@
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";
1
+ import { C as Controller, s as setAmbientComponent, i as isPromise, e as setParentController, f as retrieveParentControllers, t as trackKey, r as retrieveComponent, g as createEventFactory } from "../Controller-CZ8Djohh.js";
2
+ import { G, h, l, j, c, o, k, n, m } from "../Controller-CZ8Djohh.js";
3
+ import { p as proxyExports } from "../proxyExports-CK5BLFLO.js";
6
4
  import { observeAncestorsMutation, isEsriInternalEnv, getElementAttribute, getElementLocales, startLocaleObserver } from "@arcgis/components-utils";
7
5
  const makeController = (constructor) => proxy(void 0, constructor);
8
6
  const makeGenericController = (constructor) => (component) => proxy(
@@ -135,11 +133,7 @@ const makeT9nController = (getAssetPath) => (options = {}) => (
135
133
  // eslint-disable-next-line @typescript-eslint/promise-function-async
136
134
  makeController((component, controller) => {
137
135
  const locale = getElementLocales(component.el);
138
- const pending = {
139
- _lang: locale.lang,
140
- _t9nLocale: locale.t9nLocale,
141
- _loading: true
142
- };
136
+ const pending = { _lang: locale.lang, _t9nLocale: locale.t9nLocale, _loading: true };
143
137
  const componentWithOverrides = component;
144
138
  controller.onLifecycle(
145
139
  () => startLocaleObserver(
@@ -172,7 +166,11 @@ const makeT9nController = (getAssetPath) => (options = {}) => (
172
166
  controller.exports = updated;
173
167
  }
174
168
  if ("messageOverrides" in componentWithOverrides) {
175
- controller.onLifecycle(() => watch(componentWithOverrides, "messageOverrides", applyOverrides));
169
+ controller.onUpdate((changes) => {
170
+ if (changes.has("messageOverrides")) {
171
+ applyOverrides(componentWithOverrides.messageOverrides);
172
+ }
173
+ });
176
174
  }
177
175
  if (options.blocking) {
178
176
  controller.setProvisionalExports(pending, false);
@@ -200,44 +198,31 @@ const usePropertyChange = (_component) => propertyChangeController;
200
198
  const eventName = "arcgisPropertyChange";
201
199
  function propertyChangeController(...toWatch) {
202
200
  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
- }
201
+ const eventEmitter = createEventFactory(eventName, void 0, component);
213
202
  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
203
  toWatch.forEach((prop) => {
223
- if (!allProps.has(prop)) {
204
+ const descriptor = component.constructor.elementProperties.get(prop);
205
+ const isProp = descriptor !== void 0 && descriptor.state !== true;
206
+ if (!isProp) {
224
207
  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}`
208
+ `For usePropertyChange to emit event on "${prop}" property change, you should add @property() to ${prop} in ${component.el.localName}`
226
209
  );
227
210
  }
228
211
  });
229
212
  }
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) {
213
+ let isFirst = true;
214
+ component.manager.onUpdated((changes) => {
215
+ if (isFirst || !component.el.isConnected) {
216
+ isFirst = false;
217
+ return;
218
+ }
219
+ for (const name of toWatch) {
220
+ if (changes.has(name)) {
221
+ eventEmitter.emit({ name });
222
+ }
223
+ }
224
+ });
225
+ if (process.env.NODE_ENV !== "production" && isEsriInternalEnv()) {
241
226
  trackKey(
242
227
  component,
243
228
  (resolution) => {
@@ -255,29 +240,24 @@ function propertyChangeController(...toWatch) {
255
240
  export {
256
241
  Controller,
257
242
  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,
243
+ h as bypassGetter,
244
+ l as bypassReadOnly,
245
+ j as bypassSetter,
246
+ c as controllerSymbol,
247
+ o as isController,
265
248
  k as keyTrackResolve,
266
249
  load,
267
250
  makeController,
268
251
  makeGenericController,
269
252
  makeT9nController,
270
253
  proxyExports,
271
- r as readonly,
272
254
  retrieveComponent,
273
255
  toFunction,
274
256
  trackKey,
275
- f as trackPropKey,
276
- e as trackPropertyKey,
277
- u as useControllerManager,
257
+ n as trackPropKey,
258
+ m as trackPropertyKey,
278
259
  useDirection,
279
260
  useMedia,
280
261
  usePropertyChange,
281
- useWatchAttributes,
282
- watch
262
+ useWatchAttributes
283
263
  };
@@ -24,4 +24,4 @@ import { ControllerLifecycleMethods } from './types';
24
24
  * is necessary for proxyExports() to receive a reference to your object
25
25
  * implicitly, and before any of your default values are assigned.
26
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);
27
+ export declare const proxyExports: <Exports, const Parameters extends unknown[]>(Class: new (...args: Parameters) => ControllerLifecycleMethods & Pick<Controller<Exports>, "component" | "exports" | "onUpdate" | "watchExports">) => ((...args: Parameters) => Exports);
@@ -1,8 +1,8 @@
1
- import { TrackKeyResolution } from './ComponentInternals';
2
- import { BaseComponent, BaseController } from './types';
1
+ import { LitElement } from '../LitElement';
2
+ import { BaseController, TrackKeyResolution } from './types';
3
3
  /**
4
4
  * A combination of trackPropertyKey() and trackPropKey(). For usage when
5
5
  * you want to track a property, but don't know if it will be defined with the
6
- * \@Prop() decorator or not
6
+ * \@property() decorator or not
7
7
  */
8
- export declare function trackKey<T>(hostsCandidates: ((BaseComponent | BaseController)[] | BaseComponent | BaseController) | undefined, onResolved: (resolution: TrackKeyResolution | undefined) => void, defaultValue: T): T;
8
+ export declare function trackKey<T>(hostsCandidates: ((BaseController | LitElement)[] | BaseController | LitElement) | undefined, onResolved: (resolution: TrackKeyResolution | undefined) => void, defaultValue: T): T;
@@ -1,6 +1,6 @@
1
- import { BaseComponent } from './types';
1
+ import { LitElement } from '../LitElement';
2
2
  /**
3
- * Like manager.trackPropertyKey(), but for props that have \@State() or \@Prop()
3
+ * Like trackPropertyKey(), but for props that have \@state() or \@property()
4
4
  * decorator
5
5
  *
6
6
  * @example
@@ -10,12 +10,12 @@ import { BaseComponent } from './types';
10
10
  * return trackPropKey(component, (key)=>console.log(key), defaultValue);
11
11
  * }
12
12
  *
13
- * class MyComponent extends BaseComponent {
13
+ * class MyComponent extends LitElement {
14
14
  * // Will console log "myProp"
15
- * @Prop() myProp = trackMe();
15
+ * \@property() myProp = trackMe();
16
16
  *
17
17
  * // Will console log "myState"
18
- * @State() myState = trackMe();
18
+ * \@state() myState = trackMe();
19
19
  * }
20
20
  */
21
- export declare function trackPropKey<T>(component: BaseComponent, onResolved: (key: string | undefined) => void, defaultValue: T): T;
21
+ export declare function trackPropKey<T>(component: LitElement, onResolved: (key: string | undefined) => void, defaultValue: T): T;
@@ -1,25 +1,26 @@
1
- import { BaseComponent, BaseController } from './types';
1
+ import { LitElement } from '../LitElement';
2
+ import { BaseController } from './types';
2
3
  /**
3
4
  * A magical solution to finding out what property name a given controller
4
5
  * on a given object was assigned to.
5
6
  *
6
7
  * @remarks
7
- * This does not work for properties that have \@Prop() or \@State()
8
- * decorator - for those, use manager.trackPropKey() instead.
8
+ * This does not work for properties that have \@property() or \@state()
9
+ * decorator - for those, use trackPropKey() instead.
9
10
  *
10
11
  * @example
11
- * function trackMe<T>(defaultValue:T, component:BaseComponent):T {
12
- * component.manager.trackPropertyKey(component, (key)=>console.log(key), defaultValue);
12
+ * function trackMe<T>(defaultValue: T, component: LitElement):T {
13
+ * trackPropertyKey(component, (key)=>console.log(key), defaultValue);
13
14
  * return defaultValue;
14
15
  * }
15
16
  *
16
- * class MyComponent extends BaseComponent {
17
+ * class MyComponent extends LitElement {
17
18
  * // Will console log "myProp"
18
19
  * myProp = trackMe('a', this);
19
20
  * }
20
21
  *
21
22
  */
22
- export declare function trackPropertyKey<T>(object: BaseComponent | BaseController, onResolved: (key: string | undefined) => void, defaultValue: T): T;
23
+ export declare function trackPropertyKey<T>(object: BaseController | LitElement, onResolved: (key: string | undefined) => void, defaultValue: T): T;
23
24
  /**
24
25
  * Resolve all pending trackPropertyKey() calls. This must be called after a
25
26
  * property you are trying to resolve had it's default value set, thus after
@@ -1,20 +1,13 @@
1
1
  import { IHandle } from '@arcgis/components-utils';
2
2
  import { ReactiveControllerHost, ReactiveController, PropertyDeclaration, PropertyValues } from 'lit';
3
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;
4
+ export type TrackKeyResolution = {
5
+ readonly key: string;
6
+ readonly host: BaseController | LitElement;
7
+ /**
8
+ * True if property is decorated with a `@state()` or `@property()` decorator
9
+ */
10
+ readonly isReactive: boolean;
18
11
  };
19
12
  /**
20
13
  * @deprecated use LitElement instead
@@ -28,9 +21,7 @@ export type BaseComponent = Omit<LitElement, "componentOnReady"> & {
28
21
  * "implements"
29
22
  * @example
30
23
  * 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
24
+ * export class Home extends LitElement implements Use<typeof useHomeViewModel> {
34
25
  *
35
26
  * @remarks
36
27
  * TypeScript detects errors even without Use<typeof useHomeViewModel>, but Use
@@ -38,33 +29,26 @@ export type BaseComponent = Omit<LitElement, "componentOnReady"> & {
38
29
  */
39
30
  export type Use<Callback extends (component: any) => unknown> = Parameters<Callback>[0];
40
31
  /**
41
- * Base API for a controller. Compatible with both Lit's Reactive controllers
42
- * and Stencil's lifecycle
32
+ * Base API for a controller. Compatible with Lit's Reactive controllers
43
33
  */
44
34
  export type ControllerLifecycleMethods = {
45
35
  readonly hostConnected?: ReactiveController["hostConnected"];
46
36
  readonly hostDisconnected?: ReactiveController["hostDisconnected"];
47
- readonly hostLoad?: StencilLifecycles["componentWillLoad"];
48
- readonly hostLoaded?: StencilLifecycles["componentDidLoad"];
37
+ readonly hostLoad?: () => Promise<void> | void;
38
+ readonly hostLoaded?: () => void;
49
39
  /**
50
40
  * Called during the client-side host update, just before the host calls
51
41
  * its own update.
52
42
  *
53
43
  * Code in `update()` can depend on the DOM as it is not called in
54
44
  * server-side rendering.
55
- *
56
- * @remarks
57
- * The `changes` parameter will only be present in Lumina, not in Stencil
58
45
  */
59
- readonly hostUpdate?: (changes: PropertyValues) => void;
46
+ hostUpdate?(changes: PropertyValues): void;
60
47
  /**
61
48
  * Called after a host update, just before the host calls firstUpdated and
62
49
  * 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
50
  */
67
- readonly hostUpdated?: (changes: PropertyValues) => void;
51
+ hostUpdated?(changes: PropertyValues): void;
68
52
  /**
69
53
  * Called when the component is finally being destroyed (rather than
70
54
  * temporary disconnected from the DOM)
@@ -92,6 +76,8 @@ export type ControllerLifecycleMethods = {
92
76
  * Controller host interface, compatible with both Lit's Reactive controllers
93
77
  * and Stencil's lifecycle.
94
78
  * These members are added to the component instance by ControllerManager.
79
+ *
80
+ * @deprecated use LitElement instead
95
81
  */
96
82
  export type ControllerHost = {
97
83
  /**
@@ -110,10 +96,6 @@ export type ControllerHost = {
110
96
  * be waited on via the `updateComplete` property.
111
97
  *
112
98
  * @remarks
113
- * In Stencil:
114
- * This method will re-render your component. All passed parameters are ignored
115
- *
116
- * In Lit:
117
99
  * It is recommended to provide the property name describing what property
118
100
  * triggered the update - property name will be provided to the willUpdate()
119
101
  * lifecycle hook, giving it the ability to react to the change.
@@ -135,18 +117,6 @@ export declare const controllerSymbol: unique symbol;
135
117
  export type BaseController = ControllerLifecycleMethods & {
136
118
  readonly [controllerSymbol]?: true;
137
119
  };
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
120
  /**
151
121
  * Property declaration with additional `reaDonly` option (handled by Controllers)
152
122
  */
@@ -1,5 +1,6 @@
1
- import { BaseComponent, EventEmitter } from './types';
2
- type PropertyChangeController<Component extends BaseComponent> = <ToWatch extends keyof Component>(...toWatch: ToWatch[]) => EventEmitter<{
1
+ import { EventEmitter } from '../createEvent';
2
+ import { LitElement } from '../LitElement';
3
+ type PropertyChangeController<Component extends LitElement> = <ToWatch extends keyof Component>(...toWatch: ToWatch[]) => EventEmitter<{
3
4
  name: ToWatch & string;
4
5
  }>;
5
6
  /**
@@ -7,5 +8,5 @@ type PropertyChangeController<Component extends BaseComponent> = <ToWatch extend
7
8
  *
8
9
  * Documentation: https://qawebgis.esri.com/components/lumina/controllers/usePropertyChange
9
10
  */
10
- export declare const usePropertyChange: <Component extends BaseComponent>(_component?: BaseComponent) => PropertyChangeController<Component>;
11
+ export declare const usePropertyChange: <Component extends LitElement>(_component?: LitElement) => PropertyChangeController<Component>;
11
12
  export {};
@@ -10,7 +10,7 @@ export type T9nMeta<T9nStrings extends GenericT9nStrings> = {
10
10
  * @example
11
11
  * ```ts
12
12
  * // Type of the messageOverrides is set automatically based on _overrides:
13
- * @Prop() messageOverrides?: typeof this.messages._overrides;
13
+ * @property() messageOverrides?: typeof this.messages._overrides;
14
14
  * ```
15
15
  */
16
16
  _overrides: DeepPartial<T9nStrings>;
@@ -1,4 +1,9 @@
1
- import { BaseComponent, EventEmitter } from './controllers/types';
1
+ /**
2
+ * An event emitter object
3
+ */
4
+ export type EventEmitter<T = undefined> = {
5
+ emit(payload: T extends undefined ? void : T): CustomEvent<T>;
6
+ };
2
7
  /**
3
8
  * While these defaults don't match DOM defaults (all false), they match
4
9
  * Stencil and Shoelace defaults. Also, they make more sense for our
@@ -27,7 +32,7 @@ export type EventOptions = {
27
32
  */
28
33
  composed?: boolean;
29
34
  };
30
- export declare const createEventFactory: <T = undefined>(eventName?: string, options?: EventOptions, component?: BaseComponent) => EventEmitter<T>;
35
+ export declare const createEventFactory: <T = undefined>(eventName?: string, options?: EventOptions, component?: import('./LitElement').LitElement) => EventEmitter<T>;
31
36
  /**
32
37
  * Creates an event emitter.
33
38
  * Events emitted by your component will be included in the documentation.
@@ -1,4 +1,4 @@
1
- import { n as noShadowRoot, P as ProxyComponent } from "./utils-GhKD5Lo-.js";
1
+ import { n as noShadowRoot, P as ProxyComponent } from "./utils-DBdf1Dqp.js";
2
2
  import { camelToKebab } from "@arcgis/components-utils";
3
3
  function handleHmrUpdate(newModules) {
4
4
  newModules.forEach((newModule) => {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { useContextProvider, useContextConsumer } from './context';
2
- export type { EventOptions } from './createEvent';
2
+ export type { EventEmitter, EventOptions } from './createEvent';
3
3
  export { createEvent } from './createEvent';
4
4
  export { state, property, method } from './decorators';
5
5
  export type { DefineCustomElements, LazyLoadOptions, GlobalThisWithPuppeteerEnv } from './lazyLoad';