@arcgis/lumina 4.31.0-next.100

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/LICENSE.md ADDED
@@ -0,0 +1,13 @@
1
+ # Licensing
2
+
3
+ COPYRIGHT © 2024 Esri
4
+
5
+ All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
6
+
7
+ This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
8
+
9
+ See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
10
+
11
+ For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
12
+
13
+ email: contracts@esri.com
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # ArcGIS Maps SDK for JavaScript - Lit
2
+
3
+ **No Esri Technical Support included.**
4
+
5
+ Package that is part of the [ArcGIS Maps SDK for JavaScript](https://developers.arcgis.com/javascript).
6
+
7
+ It is not intended to be used directly, but rather used as a dependency by other packages in the SDK.
8
+
9
+ ## License
10
+
11
+ COPYRIGHT © 2024 Esri
12
+
13
+ All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
14
+
15
+ This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
16
+
17
+ See use restrictions at <http://www.esri.com/legal/pdfs/mla_e204_e300/english>
18
+
19
+ For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
20
+
21
+ email: contracts@esri.com
@@ -0,0 +1,216 @@
1
+ import type { CSSResultGroup, CSSResultOrNative, PropertyValues } from "lit";
2
+ import { LitElement as OriginalLitElement } from "lit";
3
+ import type { LuminaPropertyDeclaration } from "@arcgis/components-controllers";
4
+ import type { Runtime } from "./runtime";
5
+ import type { ProxyComponent } from "./lazyLoad";
6
+ import type { ToElement } from "./jsx/jsx";
7
+ type ComponentLifecycle = {
8
+ connectedCallback?: () => void;
9
+ disconnectedCallback?: () => void;
10
+ load?: () => Promise<void> | void;
11
+ loaded?: () => void;
12
+ };
13
+ /**
14
+ * Base Lit class that should be used by all components instead of the original
15
+ * Lit element.
16
+ *
17
+ * This class:
18
+ * - Handles being used in a lazy-loading build
19
+ * - Connects to the Controller Manager
20
+ * - Provides load/loaded lifecycle hooks
21
+ * (like componentWillLoad and componentDidLoad in Stencil)
22
+ * - Provides a .listen() method like Stencil's \@Listen decorator
23
+ *
24
+ * @remarks
25
+ * Even though all components will extend this class, it is not exposed in the
26
+ * public typings as we do not want to expose internal methods like
27
+ * addController() and connectedCallback() to the public typings.
28
+ *
29
+ * Instead, `@arcgis/lumina-compiler` will make it appear that your component
30
+ * extends `PublicLitElement`.
31
+ *
32
+ * `PublicLitElement` will never be called at runtime - it exists for typings
33
+ * only.
34
+ */
35
+ export declare class LitElement extends OriginalLitElement implements ComponentLifecycle {
36
+ /** @internal */
37
+ static runtime: Runtime;
38
+ static tagName: string;
39
+ static finalizeStyles(styles?: CSSResultGroup): CSSResultOrNative[];
40
+ static createProperty(name: PropertyKey,
41
+ /**
42
+ * While in vanilla Lit this type is always LuminaPropertyDeclaration,
43
+ * in Lumina it is always number or
44
+ * [number,LuminaPropertyDeclaration], so we don't even check for the
45
+ * LuminaPropertyDeclaration case. LuminaPropertyDeclaration is here
46
+ * only to satisfy the type checker.
47
+ */
48
+ options?: LuminaPropertyDeclaration | number | [number, LuminaPropertyDeclaration]): void;
49
+ /**
50
+ * Since we can't pass arguments to web component constructor, before lazy
51
+ * loading logic calls document.createElement(), it temporary sets this static
52
+ * property.
53
+ *
54
+ * @internal
55
+ * */
56
+ static lazy: ProxyComponent | undefined;
57
+ static readonly lumina = true;
58
+ /**
59
+ * In lazy build, the actual DOM element differs from the class instance:
60
+ * - "this.el" is a proxy custom element - it's physically present in the DOM
61
+ * even before the Lit component is loaded.
62
+ * - "this" is the actual Lit component - in case of Lazy builds, it's
63
+ * never directly attached to the DOM. Instead, all interactions with the
64
+ * proxy are forwarded to the actual Lit component. And, when Lit wants to
65
+ * render, it renders into the shadow root of the proxy.
66
+ *
67
+ * "this.el" should be used instead of "this" for all things involving the
68
+ * DOM (addEventListener, querySelector, children, setAttribute,
69
+ * MutationObserver, etc...)
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * // Generally, you shouldn't have to write logic specific to lazy or non-lazy
74
+ * // build, but if you have to, you can detect if you are in a lazy build like so:
75
+ * const isLazy = this.el !== this;
76
+ * ```
77
+ */
78
+ el: ToElement<this>;
79
+ /**
80
+ * Controller Manager orchestrates all components used by this component,
81
+ * connecting their lifecycle hooks and providing context information.
82
+ */
83
+ manager: import("@arcgis/components-controllers").ControllerManager<never>;
84
+ /**
85
+ * Map with keys for any properties that have changed since the last
86
+ * update cycle with previous values.
87
+ *
88
+ * Do not access this directly as this value is only set during the update
89
+ * lifecycle. Instead, use the `changes` property that is provided
90
+ * to the shouldUpdate(), willUpdate() and didUpdate() lifecycle hooks.
91
+ *
92
+ * @internal
93
+ *
94
+ * @remarks
95
+ * The name does not start with `_` because in the future we may configure the
96
+ * minifier to mangle such properties - but this property is accessed from
97
+ * outside this package, so should not be mangled.
98
+ */
99
+ $changes: PropertyValues;
100
+ /** @internal */
101
+ _postLoad: ProxyComponent["_postLoad"];
102
+ /**
103
+ * Direct offspring that should be awaited before loaded() is emitted.
104
+ *
105
+ * `attachToAncestor()` will add elements to this array
106
+ *
107
+ * @internal
108
+ */
109
+ _offspring: ProxyComponent["_offspring"];
110
+ /**
111
+ * Promise that resolves once parent's load() completed. False if there is no
112
+ * parent
113
+ *
114
+ * @internal
115
+ */
116
+ _ancestorLoad: ProxyComponent["_ancestorLoad"];
117
+ private _originalShouldUpdate?;
118
+ private _enableUpdating;
119
+ private _postLoaded;
120
+ constructor();
121
+ connectedCallback(): void;
122
+ /**
123
+ * Overwrite Lit's default behavior of attaching shadow root to the lit
124
+ * element, and instead use this.el to support lazy builds.
125
+ *
126
+ * Also, support the case when component asked to not use shadow root
127
+ */
128
+ protected createRenderRoot(): DocumentFragment | HTMLElement;
129
+ /** Do asynchronous component load */
130
+ private _load;
131
+ /**
132
+ * Overwriting default shouldUpdate simply to get access to
133
+ * "changedProperties" so that we can later provide it to ControllerManager
134
+ */
135
+ protected shouldUpdate(_changedProperties: PropertyValues): boolean;
136
+ /**
137
+ * A helper for setting event listener on the current component.
138
+ *
139
+ * The event listener will be removed automatically when component
140
+ * disconnects, and added back if component re-comments, thus you don't have
141
+ * to clean it up manually.
142
+ *
143
+ * @remarks
144
+ * This listens for any event on the component or one of it's children.
145
+ * If you only want to listen for events originating from the component itself
146
+ * use `const isSelf = event.target === this.el;` to check.
147
+ *
148
+ * @example
149
+ * ```tsx
150
+ * constructor() {
151
+ * // Handle click will only be called while component is connected
152
+ * this.listen('click', this.handleClick);
153
+ * }
154
+ * handleClick(event: MouseEvent):void {
155
+ * console.log('clicked');
156
+ * }
157
+ * ```
158
+ */
159
+ listen<K extends keyof HTMLElementEventMap>(type: K, listener: (this: this, event: HTMLElementEventMap[K]) => unknown, options?: AddEventListenerOptions | boolean): void;
160
+ listen(type: string, listener: (this: this, event: Event) => unknown, options?: AddEventListenerOptions | boolean): void;
161
+ /**
162
+ * A helper for setting even listener on any element (or window / document).
163
+ *
164
+ * The event listener will be removed automatically when component
165
+ * disconnects, and added back if component re-comments, thus you don't have
166
+ * to clean it up manually.
167
+ *
168
+ * Use cases:
169
+ * - Listening for pointer events on the top-most element
170
+ * - Listening to events that are emitted exclusively on document/window/body
171
+ * - Imperatively listening for events on children components
172
+ * - Listening for events on non-Element objects (like Worker, WebSocket, etc)
173
+ * - Your component could emit a custom event, and then listen for that event
174
+ * on the window. This lets consumer of the component handle the event and
175
+ * stop propagation - and if they didn't and event reached the window, your
176
+ * component can handle the event itself using the default behavior.
177
+ *
178
+ * @example
179
+ * ```tsx
180
+ * constructor() {
181
+ * // Handle click will only be called while component is connected
182
+ * this.listenOn(window, 'click', this.handleWindowClick);
183
+ * }
184
+ * handleWindowClick(event: MouseEvent):void {
185
+ * console.log('clicked');
186
+ * }
187
+ * ```
188
+ */
189
+ listenOn<Name extends keyof WindowEventMap>(target: Window, name: Name, listener: Listener<this, WindowEventMap[Name] & {
190
+ currentTarget: Window;
191
+ }>, options?: AddEventListenerOptions | boolean): void;
192
+ listenOn<Name extends keyof DocumentEventMap>(target: Document, name: Name, listener: Listener<this, DocumentEventMap[Name] & {
193
+ currentTarget: Document;
194
+ }>, options?: AddEventListenerOptions | boolean): void;
195
+ listenOn<Name extends keyof HTMLElementEventMap>(target: HTMLElement, name: Name, listener: Listener<this, HTMLElementEventMap[Name] & {
196
+ currentTarget: HTMLElement;
197
+ }>, options?: AddEventListenerOptions | boolean): void;
198
+ listenOn<EventType extends Event = CustomEvent<"Provide type like this.listenOn<ToEvents<ArcgisCounter>['arcgisClick']>() to get type-checked payload type">, Target = EventTarget>(target: Target, name: string, listener: Listener<this, EventType & {
199
+ currentTarget: Target;
200
+ }>, options?: AddEventListenerOptions | boolean): void;
201
+ /**
202
+ * Create a promise that resolves once component is fully loaded.
203
+ *
204
+ * @example
205
+ * const map = document.createElement('arcgis-map');
206
+ * document.body.append(map);
207
+ * map.componentOnReady().then(() => {
208
+ * console.log('Map is ready to go!');
209
+ * });
210
+ */
211
+ componentOnReady(): Promise<this>;
212
+ }
213
+ type Listener<ThisType, EventType> = ((this: ThisType, event: EventType) => unknown) | {
214
+ handleEvent(event: EventType): unknown;
215
+ };
216
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The base public interface for all `@arcgis/lumina` components
3
+ */
4
+ export declare class PublicLitElement extends HTMLElement {
5
+ /**
6
+ * Create a promise that resolves once component is fully loaded.
7
+ *
8
+ * @example
9
+ * const map = document.createElement("arcgis-map");
10
+ * document.body.append(map);
11
+ * map.componentOnReady().then(() => {
12
+ * console.log("Map is ready to go!");
13
+ * });
14
+ */
15
+ componentOnReady(): Promise<this>;
16
+ }
@@ -0,0 +1,27 @@
1
+ // src/config.ts
2
+ var lazyMetaGroupJoiner = ";";
3
+ var lazyMetaItemJoiner = ",";
4
+ var lazyMetaSubItemJoiner = ":";
5
+ var defaultEventBubbles = true;
6
+ var defaultEventCancelable = true;
7
+ var defaultEventComposed = true;
8
+ var PropertyFlags = /* @__PURE__ */ ((PropertyFlags2) => {
9
+ PropertyFlags2[PropertyFlags2["ATTRIBUTE"] = 1] = "ATTRIBUTE";
10
+ PropertyFlags2[PropertyFlags2["REFLECT"] = 2] = "REFLECT";
11
+ PropertyFlags2[PropertyFlags2["BOOLEAN"] = 4] = "BOOLEAN";
12
+ PropertyFlags2[PropertyFlags2["NUMBER"] = 8] = "NUMBER";
13
+ PropertyFlags2[PropertyFlags2["STATE"] = 16] = "STATE";
14
+ PropertyFlags2[PropertyFlags2["READ_ONLY"] = 32] = "READ_ONLY";
15
+ PropertyFlags2[PropertyFlags2["NO_ACCESSOR"] = 64] = "NO_ACCESSOR";
16
+ return PropertyFlags2;
17
+ })(PropertyFlags || {});
18
+
19
+ export {
20
+ lazyMetaGroupJoiner,
21
+ lazyMetaItemJoiner,
22
+ lazyMetaSubItemJoiner,
23
+ defaultEventBubbles,
24
+ defaultEventCancelable,
25
+ defaultEventComposed,
26
+ PropertyFlags
27
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Configuration options that are shared between `@arcgis/lumina` and
3
+ * `@arcgis/lumina-compiler`. To avoid the need of loading DOM modules in Node.js,
4
+ * this file is extracted into a separate entrypoint.
5
+ */
6
+ export declare const lazyMetaGroupJoiner = ";";
7
+ export declare const lazyMetaItemJoiner = ",";
8
+ export declare const lazyMetaSubItemJoiner = ":";
9
+ /**
10
+ * While these defaults don't match DOM defaults (all false), they match
11
+ * Stencil and Shoelace defaults. Also, they make more sense for our
12
+ * usage (i.e why would you want events to not be cancelable by default?)
13
+ */
14
+ export declare const defaultEventBubbles = true;
15
+ export declare const defaultEventCancelable = true;
16
+ export declare const defaultEventComposed = true;
17
+ /**
18
+ * By default in Lit, the `@property()` decorator accepts an object. However, to
19
+ * keep the bundle size smaller, in production builds, instead of passing it an
20
+ * object, we pass it a compact number, that gets converted back to an object
21
+ * in createProperty() at runtime.
22
+ */
23
+ export declare enum PropertyFlags {
24
+ ATTRIBUTE = 1,
25
+ REFLECT = 2,
26
+ BOOLEAN = 4,
27
+ NUMBER = 8,
28
+ STATE = 16,
29
+ READ_ONLY = 32,
30
+ NO_ACCESSOR = 64
31
+ }
package/dist/config.js ADDED
@@ -0,0 +1,18 @@
1
+ import {
2
+ PropertyFlags,
3
+ defaultEventBubbles,
4
+ defaultEventCancelable,
5
+ defaultEventComposed,
6
+ lazyMetaGroupJoiner,
7
+ lazyMetaItemJoiner,
8
+ lazyMetaSubItemJoiner
9
+ } from "./chunk-CH52Q2MB.js";
10
+ export {
11
+ PropertyFlags,
12
+ defaultEventBubbles,
13
+ defaultEventCancelable,
14
+ defaultEventComposed,
15
+ lazyMetaGroupJoiner,
16
+ lazyMetaItemJoiner,
17
+ lazyMetaSubItemJoiner
18
+ };
@@ -0,0 +1,40 @@
1
+ import type { EventEmitter } from "@arcgis/components-controllers";
2
+ export type EventOptions = {
3
+ /**
4
+ * A Boolean indicating whether the event bubbles up through the DOM or not.
5
+ *
6
+ * @default true
7
+ */
8
+ bubbles?: boolean;
9
+ /**
10
+ * A Boolean indicating whether the event is cancelable. Defaults to `true`,
11
+ * unlike the DOM's default of `false`, as that is the desired behavior most
12
+ * of the time.
13
+ *
14
+ * @default true
15
+ */
16
+ cancelable?: boolean;
17
+ /**
18
+ * A Boolean value indicating whether or not the event can bubble across the
19
+ * boundary between the shadow DOM and the regular DOM.
20
+ *
21
+ * @default true
22
+ */
23
+ composed?: boolean;
24
+ };
25
+ export declare const createEventFactory: <T = undefined>(eventName?: string, options?: EventOptions, component?: import("@arcgis/components-controllers").BaseComponent) => EventEmitter<T>;
26
+ /**
27
+ * Creates an event emitter.
28
+ * Events emitted by your component will be included in the documentation.
29
+ *
30
+ * @example
31
+ * Declaring an event whose payload is of type `number`:
32
+ *
33
+ * ```ts
34
+ * class MyComponent extends LitElement {
35
+ * arcgisClick = createEvent<number>();
36
+ * }
37
+ * ```
38
+ *
39
+ */
40
+ export declare const createEvent: <T = undefined>(options?: EventOptions) => EventEmitter<T>;
@@ -0,0 +1,55 @@
1
+ import type { LuminaPropertyDeclaration } from "@arcgis/components-controllers";
2
+ export { state } from "@lit/reactive-element/decorators/state.js";
3
+ /**
4
+ * A class field or accessor decorator which creates a reactive property that
5
+ * reflects a corresponding attribute value. When a decorated property is set
6
+ * the element will update and render.
7
+ *
8
+ * This decorator should only be used for public fields. As public fields,
9
+ * properties should be considered as primarily settable by element users,
10
+ * either via attribute or the property itself.
11
+ *
12
+ * Generally, properties that are changed by the element should be private or
13
+ * protected fields and should use the `state()` decorator.
14
+ *
15
+ * However, sometimes element code does need to set a public property. This
16
+ * should typically only be done in response to user interaction, and an event
17
+ * should be fired informing the user; for example, a checkbox sets its
18
+ * `checked` property when clicked and fires a `changed` event. Mutating public
19
+ * properties should typically not be done for non-primitive (object or array)
20
+ * properties. In other cases when an element needs to manage state, a private
21
+ * property decorated via the `state()` decorator should be used. When
22
+ * needed, state properties can be initialized via public properties to
23
+ * facilitate complex interactions.
24
+ *
25
+ * @example
26
+ *
27
+ * ```ts
28
+ * class MyElement {
29
+ * \@property()
30
+ * clicked = false;
31
+ * }
32
+ * ```
33
+ *
34
+ * @example
35
+ * Declaring a readOnly property:
36
+ *
37
+ * ```ts
38
+ * class MyElement {
39
+ * \@property({ readOnly: true })
40
+ * state: State = "loading";
41
+ * }
42
+ * ```
43
+ */
44
+ export declare const property: (options?: Omit<LuminaPropertyDeclaration, "state">) => PropertyDecorator;
45
+ declare type CustomMethodDecorator<T> = (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
46
+ /**
47
+ * The `@method()` decorator is used to expose methods on the public API.
48
+ * Class methods decorated with the `@method()` decorator can be called directly
49
+ * from the element, meaning they are intended to be callable from the outside.
50
+ *
51
+ * @remarks
52
+ * This decorator does not exist at runtime and is only used as a hint for the
53
+ * compiler to declare certain methods as public.
54
+ */
55
+ export declare const method: () => CustomMethodDecorator<any>;
@@ -0,0 +1,11 @@
1
+ import type { LitElement } from "./LitElement";
2
+ /**
3
+ * When in lazy-build, the actual Lit element is never attached to the DOM.
4
+ * Instead, a proxy element is present and should be used for all DOM actions.
5
+ *
6
+ * In practice, this means using this.el.getAttribute() instead of
7
+ * this.getAttribute() and etc for each DOM method
8
+ *
9
+ * This code does not ship in production builds.
10
+ */
11
+ export declare function devOnlyDetectIncorrectLazyUsages(LitClass: typeof LitElement): void;
@@ -0,0 +1,29 @@
1
+ import type { ModuleNamespace } from "vite/types/hot.js";
2
+ /**
3
+ * Update web component proxies when a module is updated.
4
+ *
5
+ * @remarks
6
+ * You should not need to call this function directly - it will be inserted
7
+ * automatically when running in serve mode.
8
+ */
9
+ export declare function handleHmrUpdate(newModules: (ModuleNamespace | undefined)[]): void;
10
+ export type HmrComponentMeta = {
11
+ readonly tagName: string;
12
+ /**
13
+ * 2nd tuple element ("attribute") is missing when attribute name can be
14
+ * trivially inferred from the property name (using camelToKebab()).
15
+ * If 2nd tuple element is empty string, it means the property does not have
16
+ * an attribute.
17
+ */
18
+ readonly properties: (readonly [property: string, attribute: string] | readonly [property: string])[];
19
+ readonly asyncMethods: readonly string[];
20
+ readonly syncMethods: readonly string[];
21
+ };
22
+ /**
23
+ * Update lazy component meta
24
+ *
25
+ * @remarks
26
+ * You should not need to call this function directly - it will be inserted
27
+ * automatically when running in serve mode.
28
+ */
29
+ export declare function handleComponentMetaUpdate(meta: HmrComponentMeta): void;
@@ -0,0 +1,15 @@
1
+ export type { EventOptions } from "./createEvent";
2
+ export { createEvent } from "./createEvent";
3
+ export { state, property, method } from "./decorators";
4
+ export type { HmrComponentMeta } from "./hmrSupport";
5
+ export { handleComponentMetaUpdate, handleHmrUpdate } from "./hmrSupport";
6
+ export type { DefineCustomElements, LazyLoadOptions } from "./lazyLoad";
7
+ export { makeDefineCustomElements } from "./lazyLoad";
8
+ export { LitElement } from "./LitElement";
9
+ export type { PublicLitElement } from "./PublicLitElement";
10
+ export type { Runtime, RuntimeOptions, DevOnlyGlobalRuntime, DevOnlyGlobalComponentRefCallback } from "./runtime";
11
+ export { makeRuntime } from "./runtime";
12
+ export * from "./jsx/jsx";
13
+ export { safeClassMap, safeStyleMap } from "./jsx/directives";
14
+ export { noShadowRoot } from "./utils";
15
+ export { createPrototypeProxy } from "./wrappersUtils";