@arcgis/lumina 4.31.0-next.98 → 4.32.0-next.10

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.
@@ -36,6 +36,9 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
36
36
  /** @internal */
37
37
  static runtime: Runtime;
38
38
  static tagName: string;
39
+ /**
40
+ * Customize Lit's default style handling to support non-shadow-root styles
41
+ */
39
42
  static finalizeStyles(styles?: CSSResultGroup): CSSResultOrNative[];
40
43
  static createProperty(name: PropertyKey,
41
44
  /**
@@ -156,8 +159,17 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
156
159
  * }
157
160
  * ```
158
161
  */
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;
162
+ listen<K extends keyof HTMLElementEventMap>(name: K, listener: (this: this, event: HTMLElementEventMap[K]) => unknown, options?: AddEventListenerOptions | boolean): void;
163
+ listen(name: string, listener: (this: this, event: Event) => unknown, options?: AddEventListenerOptions | boolean): void;
164
+ listen<EventType extends Event = CustomEvent<"Provide type like this.listenOn<ToEvents<ArcgisCounter>['arcgisClick']>() to get type-checked payload type">>(name: string,
165
+ /**
166
+ * The "NoInfer" here forces type argument to be specified explicitly.
167
+ * Without it, the following would be allowed:
168
+ * ```tsx
169
+ * this.listen("focus",(event:NotFocusEvent)=>{....})
170
+ * ```
171
+ */
172
+ listener: (this: this, event: NoInfer<EventType>) => unknown, options?: AddEventListenerOptions | boolean): void;
161
173
  /**
162
174
  * A helper for setting even listener on any element (or window / document).
163
175
  *
@@ -195,7 +207,15 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
195
207
  listenOn<Name extends keyof HTMLElementEventMap>(target: HTMLElement, name: Name, listener: Listener<this, HTMLElementEventMap[Name] & {
196
208
  currentTarget: HTMLElement;
197
209
  }>, 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 & {
210
+ 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,
211
+ /**
212
+ * The "NoInfer" here forces type argument to be specified explicitly.
213
+ * Without it, the following would be allowed:
214
+ * ```tsx
215
+ * this.listen("focus",(event:NotFocusEvent)=>{....})
216
+ * ```
217
+ */
218
+ listener: Listener<this, NoInfer<EventType> & {
199
219
  currentTarget: Target;
200
220
  }>, options?: AddEventListenerOptions | boolean): void;
201
221
  /**
@@ -1,4 +1,4 @@
1
- import type { EventEmitter } from "@arcgis/components-controllers";
1
+ import type { BaseComponent, EventEmitter } from "@arcgis/components-controllers";
2
2
  export type EventOptions = {
3
3
  /**
4
4
  * A Boolean indicating whether the event bubbles up through the DOM or not.
@@ -22,7 +22,7 @@ export type EventOptions = {
22
22
  */
23
23
  composed?: boolean;
24
24
  };
25
- export declare const createEventFactory: <T = undefined>(eventName?: string, options?: EventOptions, component?: import("@arcgis/components-controllers").BaseComponent) => EventEmitter<T>;
25
+ export declare const createEventFactory: <T = undefined>(eventName?: string, options?: EventOptions, component?: BaseComponent) => EventEmitter<T>;
26
26
  /**
27
27
  * Creates an event emitter.
28
28
  * Events emitted by your component will be included in the documentation.
@@ -4,7 +4,10 @@ import type { LitElement } from "./LitElement";
4
4
  * Instead, a proxy element is present and should be used for all DOM actions.
5
5
  *
6
6
  * In practice, this means using this.el.getAttribute() instead of
7
- * this.getAttribute() and etc for each DOM method
7
+ * this.getAttribute() and etc for each DOM method.
8
+ *
9
+ * To detect incorrect usages, this function overwrites each DOM member on the
10
+ * LitElement prototype with an exception-throwing function.
8
11
  *
9
12
  * This code does not ship in production builds.
10
13
  */
package/dist/index.d.ts CHANGED
@@ -3,13 +3,14 @@ export { createEvent } from "./createEvent";
3
3
  export { state, property, method } from "./decorators";
4
4
  export type { HmrComponentMeta } from "./hmrSupport";
5
5
  export { handleComponentMetaUpdate, handleHmrUpdate } from "./hmrSupport";
6
- export type { DefineCustomElements, LazyLoadOptions } from "./lazyLoad";
6
+ export type { DefineCustomElements, LazyLoadOptions, GlobalThisWithPuppeteerEnv } from "./lazyLoad";
7
7
  export { makeDefineCustomElements } from "./lazyLoad";
8
8
  export { LitElement } from "./LitElement";
9
9
  export type { PublicLitElement } from "./PublicLitElement";
10
10
  export type { Runtime, RuntimeOptions, DevOnlyGlobalRuntime, DevOnlyGlobalComponentRefCallback } from "./runtime";
11
11
  export { makeRuntime } from "./runtime";
12
12
  export * from "./jsx/jsx";
13
- export { safeClassMap, safeStyleMap } from "./jsx/directives";
13
+ export { safeClassMap, safeStyleMap, directive, live } from "./jsx/directives";
14
+ export { nothing, noChange, setAttribute, stringOrBoolean } from "./jsx/utils";
14
15
  export { noShadowRoot } from "./utils";
15
16
  export { createPrototypeProxy } from "./wrappersUtils";
package/dist/index.js CHANGED
@@ -8,19 +8,20 @@ import {
8
8
  } from "./chunk-CH52Q2MB.js";
9
9
 
10
10
  // src/createEvent.ts
11
- import { retrieveComponent, trackPropertyKey } from "@arcgis/components-controllers";
11
+ import { retrieveComponent, trackPropertyKey, keyTrackResolve } from "@arcgis/components-controllers";
12
12
  var createEventFactory = (eventName = "", options = {}, component = retrieveComponent()) => {
13
13
  const emitter = {
14
14
  emit: (payload) => {
15
- if (process.env.NODE_ENV !== "production") {
16
- if (eventName === "") {
15
+ if (process.env.NODE_ENV !== "production" && !component.el.isConnected) {
16
+ console.warn(
17
+ `Trying to emit an ${eventName} event on a disconnected element ${component.el.tagName.toLowerCase()}`
18
+ );
19
+ }
20
+ if (eventName === "") {
21
+ keyTrackResolve();
22
+ if (process.env.NODE_ENV !== "production" && eventName === "") {
17
23
  throw new Error("Unable to resolve event name from property name");
18
24
  }
19
- if (!component.el.isConnected) {
20
- console.warn(
21
- `Trying to emit an ${eventName} event on a disconnected element ${component.el.tagName.toLowerCase()}`
22
- );
23
- }
24
25
  }
25
26
  const event = new CustomEvent(eventName, {
26
27
  detail: payload,
@@ -61,11 +62,21 @@ import { Deferred, camelToKebab } from "@arcgis/components-utils";
61
62
  // src/devOnlyDetectIncorrectLazyUsages.ts
62
63
  function devOnlyDetectIncorrectLazyUsages(LitClass) {
63
64
  const genericPrototype = LitClass.prototype;
65
+ const descriptor = Object.getOwnPropertyDescriptor(genericPrototype, "innerText");
66
+ if (descriptor !== void 0 && descriptor.get === descriptor.set) {
67
+ return;
68
+ }
64
69
  const allowList = /* @__PURE__ */ new Set([
65
70
  // We shouldn't be overwriting this property
66
71
  "constructor",
67
72
  // Called by Lit - we proxy it to this.el in ProxyComponent
68
- "setAttribute"
73
+ "setAttribute",
74
+ // Called by Lit SSR - we proxy it to this.el in ProxyComponent
75
+ "removeAttribute",
76
+ // Called by Lit - we proxy it to this.el in ProxyComponent
77
+ "isConnected",
78
+ // Called by Lit, but only in dev mode for warnings, so we don't have to proxy.
79
+ "localName"
69
80
  ]);
70
81
  const customErrorMessages = {
71
82
  addEventListener: "use this.listen() or this.el.addEventListener()"
@@ -75,28 +86,36 @@ function devOnlyDetectIncorrectLazyUsages(LitClass) {
75
86
  ...Object.getOwnPropertyDescriptors(Element.prototype),
76
87
  ...Object.getOwnPropertyDescriptors(Node.prototype),
77
88
  ...Object.getOwnPropertyDescriptors(EventTarget.prototype)
78
- }).filter(([key, { value }]) => typeof value === "function" && !allowList.has(key)).forEach(([key]) => {
79
- genericPrototype[key] = (...args) => {
89
+ }).forEach(([key, value]) => {
90
+ if (allowList.has(key)) {
91
+ return;
92
+ }
93
+ const callback = (...args) => {
80
94
  if (key === "hasAttribute" && args[0] === "defer-hydration") {
81
95
  return false;
82
96
  }
83
97
  throw new Error(
84
- `You should not be calling this.${key}() directly as it won't work correctly in lazy-builds. Instead, ${customErrorMessages[key] ?? `use this.el.${key}()`}`
98
+ `You should not be trying to access this.${key} directly as it won't work correctly in lazy-builds. Instead, ${customErrorMessages[key] ?? `use this.el.${key}`}`
85
99
  );
86
100
  };
101
+ if (typeof value.value === "function") {
102
+ genericPrototype[key] = callback;
103
+ } else {
104
+ Object.defineProperty(genericPrototype, key, { get: callback, set: callback });
105
+ }
87
106
  });
88
107
  }
89
108
 
90
109
  // src/lifecycleSupport.ts
91
- function attachToAncestor(child, el) {
92
- let ancestor = el;
110
+ function attachToAncestor(child) {
111
+ let ancestor = child;
93
112
  while (ancestor = ancestor.parentNode ?? ancestor.host) {
94
113
  if (ancestor?.constructor?.lumina) {
95
114
  const litParent = ancestor;
96
115
  if (!litParent.manager?.loadedCalled) {
97
116
  litParent._offspring.push(child);
98
117
  }
99
- return litParent._postLoad?.promise;
118
+ return litParent._postLoad.promise;
100
119
  }
101
120
  }
102
121
  return false;
@@ -151,6 +170,7 @@ function createLazyElement([tagName, [load, compactMeta = ""]]) {
151
170
  };
152
171
  customElements.define(tagName, ProxyClass);
153
172
  }
173
+ var defineProperty = Object.defineProperty;
154
174
  function parseCondensedProp(propAndAttribute) {
155
175
  const name = propAndAttribute.split(lazyMetaSubItemJoiner);
156
176
  return name.length === 1 ? [name[0], camelToKebab(name[0])] : name;
@@ -159,15 +179,6 @@ var HtmlElement = globalThis.HTMLElement ?? parseCondensedProp;
159
179
  var ProxyComponent = class extends HtmlElement {
160
180
  constructor() {
161
181
  super();
162
- /**
163
- * On HMR, preserve the values of all properties that at least once were set
164
- * by someone other than component itself.
165
- *
166
- * @internal
167
- */
168
- this._hmrSetProps = /* @__PURE__ */ new Set();
169
- /** @internal */
170
- this._hmrSetAttributes = /* @__PURE__ */ new Set();
171
182
  /** @internal */
172
183
  this._store = {};
173
184
  /**
@@ -189,16 +200,32 @@ var ProxyComponent = class extends HtmlElement {
189
200
  * Direct offspring that should be awaited before loaded() is emitted
190
201
  */
191
202
  this._offspring = [];
203
+ if (process.env.NODE_ENV !== "production") {
204
+ this._hmrSetProps = /* @__PURE__ */ new Set();
205
+ this._hmrSetAttributes = /* @__PURE__ */ new Set();
206
+ globalThis.devOnly$createdElements ??= [];
207
+ globalThis.devOnly$createdElements.push(new WeakRef(this));
208
+ }
192
209
  this._saveInstanceProperties();
193
210
  const ProxyClass = this.constructor;
194
211
  if (ProxyClass._LitConstructor) {
195
212
  this._initializeComponent({ a: ProxyClass._LitConstructor });
196
213
  } else {
197
- void ProxyClass._loadPromise.then(this._initializeComponent.bind(this)).catch(this._postLoaded.reject);
214
+ void ProxyClass._loadPromise.then(this._initializeComponent.bind(this)).catch((error) => {
215
+ this._postLoaded.reject(error);
216
+ setTimeout(() => {
217
+ throw error;
218
+ });
219
+ });
198
220
  }
199
221
  if (process.env.NODE_ENV !== "production") {
200
222
  ProxyClass._hmrInstances ??= [];
201
223
  ProxyClass._hmrInstances.push(new WeakRef(this));
224
+ Object.defineProperty(this, "_store", {
225
+ value: this._store,
226
+ enumerable: false,
227
+ configurable: true
228
+ });
202
229
  }
203
230
  }
204
231
  static {
@@ -211,7 +238,7 @@ var ProxyComponent = class extends HtmlElement {
211
238
  this._syncMethods?.forEach(this._bindSync, this);
212
239
  }
213
240
  static _bindProp(propName) {
214
- Object.defineProperty(this.prototype, propName, {
241
+ defineProperty(this.prototype, propName, {
215
242
  configurable: true,
216
243
  enumerable: true,
217
244
  get() {
@@ -226,7 +253,7 @@ var ProxyComponent = class extends HtmlElement {
226
253
  });
227
254
  }
228
255
  static _bindAsync(methodName) {
229
- Object.defineProperty(this.prototype, methodName, {
256
+ defineProperty(this.prototype, methodName, {
230
257
  async value(...args) {
231
258
  if (!this._litElement) {
232
259
  await this._postLoaded.promise;
@@ -234,13 +261,11 @@ var ProxyComponent = class extends HtmlElement {
234
261
  const genericLitElement = this._litElement;
235
262
  return await genericLitElement[methodName](...args);
236
263
  },
237
- configurable: true,
238
- writable: true,
239
- enumerable: true
264
+ configurable: true
240
265
  });
241
266
  }
242
267
  static _bindSync(methodName) {
243
- Object.defineProperty(this.prototype, methodName, {
268
+ defineProperty(this.prototype, methodName, {
244
269
  value(...args) {
245
270
  if (process.env.NODE_ENV === "development" && !this._litElement) {
246
271
  const ProxyClass = this.constructor;
@@ -251,8 +276,7 @@ var ProxyComponent = class extends HtmlElement {
251
276
  const genericLitElement = this._litElement;
252
277
  return genericLitElement[methodName](...args);
253
278
  },
254
- configurable: true,
255
- enumerable: true
279
+ configurable: true
256
280
  });
257
281
  }
258
282
  get manager() {
@@ -310,10 +334,10 @@ var ProxyComponent = class extends HtmlElement {
310
334
  }
311
335
  connectedCallback() {
312
336
  if (this._litElement) {
313
- this._litElement?.connectedCallback();
337
+ this._litElement.connectedCallback();
314
338
  } else {
315
339
  queueMicrotask(() => {
316
- this._ancestorLoad = attachToAncestor(this, this);
340
+ this._ancestorLoad = attachToAncestor(this);
317
341
  });
318
342
  }
319
343
  }
@@ -325,7 +349,7 @@ var ProxyComponent = class extends HtmlElement {
325
349
  */
326
350
  async componentOnReady() {
327
351
  await this._postLoaded.promise;
328
- return this._litElement;
352
+ return this;
329
353
  }
330
354
  /** @internal */
331
355
  _initializeComponent(module) {
@@ -352,17 +376,38 @@ var ProxyComponent = class extends HtmlElement {
352
376
  const isFirstInitialization = !ProxyClass._LitConstructor;
353
377
  if (isFirstInitialization) {
354
378
  ProxyClass._LitConstructor = LitConstructor;
355
- LitConstructor.prototype.removeAttribute = removeAttribute;
356
- LitConstructor.prototype.setAttribute = setAttribute;
379
+ LitConstructor.prototype.removeAttribute = function(qualifiedName) {
380
+ HTMLElement.prototype.removeAttribute.call(this.el, qualifiedName);
381
+ };
382
+ LitConstructor.prototype.setAttribute = function(qualifiedName, value) {
383
+ HTMLElement.prototype.setAttribute.call(this.el, qualifiedName, value);
384
+ };
385
+ defineProperty(LitConstructor.prototype, "isConnected", {
386
+ get() {
387
+ return this.el.isConnected;
388
+ }
389
+ });
357
390
  if (process.env.NODE_ENV !== "production" && LitConstructor.shadowRootOptions !== noShadowRoot) {
358
- devOnlyDetectIncorrectLazyUsages(Object.getPrototypeOf(LitConstructor));
391
+ let prototype = LitConstructor;
392
+ while (prototype && !Object.hasOwn(prototype, "lumina")) {
393
+ prototype = Object.getPrototypeOf(prototype);
394
+ }
395
+ devOnlyDetectIncorrectLazyUsages(prototype);
359
396
  }
360
397
  customElements.define(lazyTagName, LitConstructor);
361
398
  }
362
399
  LitConstructor.lazy = this;
363
400
  const litElement = document.createElement(lazyTagName);
364
401
  LitConstructor.lazy = void 0;
365
- this._litElement = litElement;
402
+ if (process.env.NODE_ENV !== "production") {
403
+ Object.defineProperty(this, "_litElement", {
404
+ value: litElement,
405
+ configurable: true,
406
+ enumerable: false
407
+ });
408
+ } else {
409
+ this._litElement = litElement;
410
+ }
366
411
  this._pendingAttributes.forEach((name) => {
367
412
  const value = this.getAttribute(name);
368
413
  litElement.attributeChangedCallback(
@@ -381,26 +426,24 @@ var ProxyComponent = class extends HtmlElement {
381
426
  const missingFromLit = lazyObserved.filter((attribute) => !litObserved.includes(attribute));
382
427
  if (missingFromLazy.length > 0) {
383
428
  console.warn(
384
- `The following attributes on <${ProxyClass._name}> are present on the Lit element, but are missing from the lazy proxy component: ${missingFromLazy.join(", ")}. This either indicates a bug in Lumina, or you are creating the attribute dynamically in a way that compiler can not infer statically. For these attributes, lazy-loading version of your component won't work correctly, thus this must be resolved`
429
+ `The following attributes on <${ProxyClass._name}> are present on the Lit element, but are missing from the lazy proxy component: ${missingFromLazy.join(", ")}. This either indicates a bug in Lumina, or you are creating the attribute dynamically in a way that compiler cannot infer statically. For these attributes, lazy-loading version of your component won't work correctly, thus this must be resolved`
385
430
  );
386
431
  }
387
432
  if (missingFromLit.length > 0) {
388
433
  console.warn(
389
- `The following attributes on <${ProxyClass._name}> are defined on the lazy proxy component, but not on the actual Lit element: ${missingFromLit.join(", ")}. This either indicates a bug in Lumina, or you are creating the attribute dynamically in a way that compiler can not infer statically. This is a non-critical issue, but does indicate that something is going wrong and should be fixed`
434
+ `The following attributes on <${ProxyClass._name}> are defined on the lazy proxy component, but not on the actual Lit element: ${missingFromLit.join(", ")}. This either indicates a bug in Lumina, or you are creating the attribute dynamically in a way that compiler cannot infer statically. This is a non-critical issue, but does indicate that something is going wrong and should be fixed`
390
435
  );
391
436
  }
392
437
  }
393
- if (this.isConnected) {
394
- litElement.connectedCallback();
438
+ const isStillConnected = this.isConnected;
439
+ if (isStillConnected || this._ancestorLoad) {
440
+ litElement.connectedCallback?.();
441
+ if (!isStillConnected) {
442
+ litElement.disconnectedCallback();
443
+ }
395
444
  }
396
445
  }
397
446
  };
398
- function removeAttribute(qualifiedName) {
399
- HTMLElement.prototype.removeAttribute.call(this.el, qualifiedName);
400
- }
401
- function setAttribute(qualifiedName, value) {
402
- HTMLElement.prototype.setAttribute.call(this.el, qualifiedName, value);
403
- }
404
447
  function syncLitElement([key, value]) {
405
448
  this[key] = value;
406
449
  }
@@ -542,13 +585,6 @@ var LitElement = class _LitElement extends OriginalLitElement {
542
585
  * @internal
543
586
  */
544
587
  this._offspring = this.constructor.lazy?._offspring ?? [];
545
- /**
546
- * Promise that resolves once parent's load() completed. False if there is no
547
- * parent
548
- *
549
- * @internal
550
- */
551
- this._ancestorLoad = this.constructor.lazy?._ancestorLoad;
552
588
  this._postLoaded = this.constructor.lazy?._postLoaded ?? new Deferred2();
553
589
  this._enableUpdating = this.enableUpdating;
554
590
  this.enableUpdating = emptyFunction;
@@ -564,6 +600,9 @@ var LitElement = class _LitElement extends OriginalLitElement {
564
600
  this.el.setAttribute(this.constructor.runtime.hydratedAttribute, "");
565
601
  }
566
602
  }
603
+ /**
604
+ * Customize Lit's default style handling to support non-shadow-root styles
605
+ */
567
606
  static finalizeStyles(styles) {
568
607
  if (process.env.NODE_ENV === "test" && Array.isArray(styles)) {
569
608
  styles = styles.filter(Boolean);
@@ -618,7 +657,15 @@ var LitElement = class _LitElement extends OriginalLitElement {
618
657
  const isFirstCall = !this.manager.connectedCalled;
619
658
  super.connectedCallback();
620
659
  if (isFirstCall) {
621
- queueMicrotask(() => void this._load().catch(this._postLoaded.reject));
660
+ queueMicrotask(
661
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/promise-function-async
662
+ () => this._load().catch((error) => {
663
+ this._postLoaded.reject(error);
664
+ setTimeout(() => {
665
+ throw error;
666
+ });
667
+ })
668
+ );
622
669
  }
623
670
  }
624
671
  /**
@@ -643,16 +690,18 @@ var LitElement = class _LitElement extends OriginalLitElement {
643
690
  }
644
691
  return existingShadowRoot;
645
692
  }
646
- const domRoot = renderRoot.getRootNode();
647
- domRoot.adoptedStyleSheets = [
648
- ...domRoot.adoptedStyleSheets,
649
- ...Class.elementStyles.map((stylesheet) => "styleSheet" in stylesheet ? stylesheet.styleSheet : stylesheet)
650
- ];
693
+ if (this.isConnected) {
694
+ const domRoot = renderRoot.getRootNode();
695
+ domRoot.adoptedStyleSheets = [
696
+ ...domRoot.adoptedStyleSheets,
697
+ ...Class.elementStyles.map((stylesheet) => "styleSheet" in stylesheet ? stylesheet.styleSheet : stylesheet)
698
+ ];
699
+ }
651
700
  return renderRoot;
652
701
  }
653
702
  /** Do asynchronous component load */
654
703
  async _load() {
655
- const parentLoadPromise = this._ancestorLoad ?? attachToAncestor(this, this);
704
+ const parentLoadPromise = this.el._ancestorLoad ?? attachToAncestor(this.el);
656
705
  if (parentLoadPromise) {
657
706
  await parentLoadPromise;
658
707
  }
@@ -746,21 +795,36 @@ function makeRuntime(options) {
746
795
  }
747
796
 
748
797
  // src/jsx/jsx.ts
749
- import { directive as litDirective } from "lit-html/directive.js";
750
- import { noChange as litNoChange, nothing as litNothing } from "lit-html";
798
+ var Fragment = void 0;
751
799
  var bindAttribute = void 0;
752
800
  var bindBooleanAttribute = void 0;
753
801
  var bindProperty = void 0;
754
802
  var bindEvent = void 0;
755
- var nothing = litNothing;
756
- var noChange = litNoChange;
757
- var directive = litDirective;
758
803
 
759
804
  // src/jsx/directives.ts
760
805
  import { classMap } from "lit-html/directives/class-map.js";
761
806
  import { styleMap } from "lit/directives/style-map.js";
807
+ import { directive as litDirective } from "lit-html/directive.js";
808
+ import { live as litLive } from "lit-html/directives/live.js";
762
809
  var safeClassMap = (parameters) => typeof parameters === "object" && parameters != null ? classMap(parameters) : parameters;
763
810
  var safeStyleMap = (parameters) => typeof parameters === "object" && parameters != null ? styleMap(parameters) : parameters;
811
+ var directive = litDirective;
812
+ var live = litLive;
813
+
814
+ // src/jsx/utils.ts
815
+ import { noChange as litNoChange, nothing as litNothing } from "lit-html";
816
+ var nothing = litNothing;
817
+ var noChange = litNoChange;
818
+ function setAttribute(element, attributeName, value) {
819
+ if (value == null) {
820
+ element.removeAttribute(attributeName);
821
+ } else {
822
+ element.setAttribute(attributeName, value);
823
+ }
824
+ }
825
+ var stringOrBoolean = {
826
+ toAttribute: (value) => value === true ? "" : value === false ? null : value
827
+ };
764
828
 
765
829
  // src/wrappersUtils.ts
766
830
  function createPrototypeProxy(tagName) {
@@ -782,6 +846,7 @@ function createPrototypeProxy(tagName) {
782
846
  return customElement;
783
847
  }
784
848
  export {
849
+ Fragment,
785
850
  LitElement,
786
851
  bindAttribute,
787
852
  bindBooleanAttribute,
@@ -792,6 +857,7 @@ export {
792
857
  directive,
793
858
  handleComponentMetaUpdate,
794
859
  handleHmrUpdate,
860
+ live,
795
861
  makeDefineCustomElements,
796
862
  makeRuntime,
797
863
  method,
@@ -801,5 +867,7 @@ export {
801
867
  property,
802
868
  safeClassMap,
803
869
  safeStyleMap,
804
- state
870
+ setAttribute,
871
+ state,
872
+ stringOrBoolean
805
873
  };
@@ -4,6 +4,7 @@ import type { ClassInfo } from "lit-html/directives/class-map.js";
4
4
  import type { DirectiveResult } from "lit/directive.js";
5
5
  import type { ClassMapDirective } from "lit/directives/class-map.js";
6
6
  import type { StyleMapDirective } from "lit/directives/style-map.js";
7
+ import type { DirectiveClass } from "lit-html/directive.js";
7
8
  /**
8
9
  * You likely won't have to import this directly. It will be added during
9
10
  * _JSX to lit-html_ conversion.
@@ -50,3 +51,23 @@ export declare const safeClassMap: (parameters: ClassInfo | Nil | string) => Dir
50
51
  * determine at runtime if directive should be called
51
52
  */
52
53
  export declare const safeStyleMap: (parameters: CssProperties | Nil | string) => DirectiveResult<typeof StyleMapDirective> | Nil | string;
54
+ /**
55
+ * Creates a user-facing directive function from a Directive class. This
56
+ * function has the same parameters as the directive's render() method.
57
+ *
58
+ * @remarks
59
+ * This is equivalent to Lit's native "directive()", but has return type
60
+ * "never" to allow it be set as a value for any JSX attribute.
61
+ */
62
+ export declare const directive: <C extends DirectiveClass>(c: C) => (...values: Parameters<InstanceType<C>["render"]>) => never;
63
+ /**
64
+ * Checks binding values against live DOM values, instead of previously bound
65
+ * values, when determining whether to update the value.
66
+ *
67
+ * @see https://lit.dev/docs/templates/directives/#live
68
+ *
69
+ * @remarks
70
+ * This is equivalent to Lit's native "directive()", but has return type
71
+ * "never" to allow it be set as a value for any JSX attribute.
72
+ */
73
+ export declare const live: (value: unknown) => never;
package/dist/jsx/jsx.d.ts CHANGED
@@ -10,11 +10,9 @@
10
10
  import type { Properties as CssProperties } from "csstype";
11
11
  import type { TemplateResult } from "lit-html";
12
12
  import type { DirectiveResult } from "lit-html/directive.js";
13
- import type { ClassMapDirective } from "lit-html/directives/class-map.js";
13
+ import type { ClassMapDirective, ClassInfo } from "lit-html/directives/class-map.js";
14
14
  import type { StyleMapDirective } from "lit-html/directives/style-map.js";
15
15
  import type { Ref } from "lit-html/directives/ref.js";
16
- import type { ClassInfo } from "lit/directives/class-map.js";
17
- import type { DirectiveClass } from "lit/directive.js";
18
16
  /**
19
17
  * The "h" namespace is used to import JSX types for elements and attributes.
20
18
  * It is imported in order to avoid conflicting global JSX issues.
@@ -24,31 +22,21 @@ export declare namespace h {
24
22
  export type { LuminaJsx as JSX };
25
23
  }
26
24
  /**
27
- * Fragment
28
- *
29
- * @remarks
30
- * This function is not actually defined in the code since references to it will
31
- * be removed at build time by the jsxToLitHtml plugin.
25
+ * The references to this function are removed at build time.
32
26
  */
33
- export declare function Fragment(props: {
27
+ export declare const Fragment: (props: {
34
28
  children?: JsxNode;
35
- }): TemplateResult;
29
+ }) => TemplateResult;
36
30
  /**
37
- * @remarks
38
- * This function is not actually defined in the code since references to it will
39
- * be removed at build time by the jsxToLitHtml plugin.
40
- */
41
- export declare function h(sel: any, data?: any, text?: any): TemplateResult;
42
- /**
43
- * @remarks
44
- * This function is not actually defined in the code since references to it will
45
- * be removed at build time by the jsxToLitHtml plugin.
31
+ * @internal
32
+ * The references to this function are removed at build time. You do not need
33
+ * to import it directly
46
34
  */
47
35
  export declare function jsx(type: string, props: unknown, key?: unknown): JsxNode;
48
36
  /**
49
- * @remarks
50
- * This function is not actually defined in the code since references to it will
51
- * be removed at build time by the jsxToLitHtml plugin.
37
+ * @internal
38
+ * The references to this function are removed at build time. You do not need
39
+ * to import it directly
52
40
  */
53
41
  export declare function jsxs(type: string, props: unknown, key?: unknown): JsxNode;
54
42
  /**
@@ -177,44 +165,6 @@ export declare const bindEvent: <T>(descriptor: T | (AddEventListenerOptions & {
177
165
  export type JsxNode = DirectiveResult<any> | JsxNodeArray | Node | TemplateResult | boolean | number | (NonNullable<unknown> & string) | null | undefined;
178
166
  interface JsxNodeArray extends Array<JsxNode> {
179
167
  }
180
- /**
181
- * Equivalent to Lit's "nothing", but has type "never" to allow it to be set as a
182
- * value for any JSX attribute.
183
- *
184
- * By default in Lit, nullish attribute value renders to an attribute without a
185
- * value (which is interpreted by HTML as "true"). To tell Lit that you don't
186
- * want the attribute to be present, use the `nothing` value.
187
- *
188
- * @example
189
- * ```tsx
190
- * <a href={this.href ?? nothing}>{this.label}</a>
191
- * ```
192
- *
193
- * @remarks
194
- * This is not a concern for properties as they are passed as is without
195
- * serialization. For this reason, during _JSX to lit-html_ conversion, most JSX
196
- * props are converted properties, except for the few cases when an attribute
197
- * has no equivalent property.
198
- */
199
- export declare const nothing: never;
200
- /**
201
- * A sentinel value that signals that a value was handled by a directive and
202
- * should not be written to the DOM.
203
- *
204
- * @remarks
205
- * This is equivalent to Lit's native "noChange", but has type "never" to allow
206
- * it be set as a value for any JSX attribute.
207
- */
208
- export declare const noChange: never;
209
- /**
210
- * Creates a user-facing directive function from a Directive class. This
211
- * function has the same parameters as the directive's render() method.
212
- *
213
- * @remarks
214
- * This is equivalent to Lit's native "directive()", but has return type
215
- * "never" to allow it be set as a value for any JSX attribute.
216
- */
217
- export declare const directive: <C extends DirectiveClass>(c: C) => (...values: Parameters<InstanceType<C>["render"]>) => never;
218
168
  /**
219
169
  * this.el property on a component only has the public properties of the
220
170
  * component. All internal methods, properties, as well as LitElement methods
@@ -1078,6 +1028,7 @@ export declare namespace LuminaJsx {
1078
1028
  fetchPriority?: "high" | "low" | "auto";
1079
1029
  }
1080
1030
  interface InputHTMLAttributes<T> extends HTMLAttributes<T> {
1031
+ autocomplete?: AutoFill;
1081
1032
  accept?: string;
1082
1033
  alt?: string;
1083
1034
  autofocus?: boolean;
@@ -1342,6 +1293,8 @@ export declare namespace LuminaJsx {
1342
1293
  form?: string;
1343
1294
  for?: string;
1344
1295
  name?: string;
1296
+ value?: string | number;
1297
+ defaultValue?: string | number;
1345
1298
  }
1346
1299
  interface ProgressHTMLAttributes<T> extends HTMLAttributes<T> {
1347
1300
  max?: number | string;
@@ -1409,6 +1362,7 @@ export declare namespace LuminaJsx {
1409
1362
  required?: boolean;
1410
1363
  rows?: number | string;
1411
1364
  value?: string | number;
1365
+ defaultValue?: string | number;
1412
1366
  wrap?: "hard" | "soft" | "off";
1413
1367
  maxLength?: number | string;
1414
1368
  minLength?: number | string;
@@ -1910,7 +1864,7 @@ export declare namespace LuminaJsx {
1910
1864
  base: BaseHTMLAttributes<HTMLBaseElement>;
1911
1865
  bdi: HTMLAttributes;
1912
1866
  bdo: HTMLAttributes;
1913
- blockquote: BlockquoteHTMLAttributes<HTMLElement>;
1867
+ blockquote: BlockquoteHTMLAttributes<HTMLQuoteElement>;
1914
1868
  body: HTMLAttributes<HTMLBodyElement>;
1915
1869
  br: HTMLAttributes<HTMLBRElement>;
1916
1870
  button: ButtonHTMLAttributes<HTMLButtonElement>;
@@ -1920,7 +1874,7 @@ export declare namespace LuminaJsx {
1920
1874
  code: HTMLAttributes;
1921
1875
  col: ColHTMLAttributes<HTMLTableColElement>;
1922
1876
  colgroup: ColgroupHTMLAttributes<HTMLTableColElement>;
1923
- data: DataHTMLAttributes<HTMLElement>;
1877
+ data: DataHTMLAttributes<HTMLDataElement>;
1924
1878
  datalist: HTMLAttributes<HTMLDataListElement>;
1925
1879
  dd: HTMLAttributes;
1926
1880
  del: HTMLAttributes;
@@ -1962,16 +1916,16 @@ export declare namespace LuminaJsx {
1962
1916
  map: MapHTMLAttributes<HTMLMapElement>;
1963
1917
  math: MathMLAttributes;
1964
1918
  mark: HTMLAttributes;
1965
- menu: MenuHTMLAttributes<HTMLElement>;
1919
+ menu: MenuHTMLAttributes<HTMLMenuElement>;
1966
1920
  meta: MetaHTMLAttributes<HTMLMetaElement>;
1967
- meter: MeterHTMLAttributes<HTMLElement>;
1921
+ meter: MeterHTMLAttributes<HTMLMeterElement>;
1968
1922
  nav: HTMLAttributes;
1969
1923
  noscript: HTMLAttributes;
1970
1924
  object: ObjectHTMLAttributes<HTMLObjectElement>;
1971
1925
  ol: OlHTMLAttributes<HTMLOListElement>;
1972
1926
  optgroup: OptgroupHTMLAttributes<HTMLOptGroupElement>;
1973
1927
  option: OptionHTMLAttributes<HTMLOptionElement>;
1974
- output: OutputHTMLAttributes<HTMLElement>;
1928
+ output: OutputHTMLAttributes<HTMLOutputElement>;
1975
1929
  p: HTMLAttributes<HTMLParagraphElement>;
1976
1930
  picture: HTMLAttributes;
1977
1931
  pre: HTMLAttributes<HTMLPreElement>;
@@ -2009,7 +1963,7 @@ export declare namespace LuminaJsx {
2009
1963
  tfoot: HTMLAttributes<HTMLTableSectionElement>;
2010
1964
  th: ThHTMLAttributes<HTMLTableCellElement>;
2011
1965
  thead: HTMLAttributes<HTMLTableSectionElement>;
2012
- time: TimeHTMLAttributes<HTMLElement>;
1966
+ time: TimeHTMLAttributes<HTMLTimeElement>;
2013
1967
  title: HTMLAttributes<HTMLTitleElement>;
2014
1968
  tr: HTMLAttributes<HTMLTableRowElement>;
2015
1969
  track: TrackHTMLAttributes<HTMLTrackElement>;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Equivalent to Lit's "nothing", but has type "never" to allow it to be set as a
3
+ * value for any JSX attribute.
4
+ *
5
+ * By default in Lit, nullish attribute value renders to an attribute without a
6
+ * value (which is interpreted by HTML as "true"). To tell Lit that you don't
7
+ * want the attribute to be present, use the `nothing` value.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * <a href={this.href ?? nothing}>{this.label}</a>
12
+ * ```
13
+ *
14
+ * @remarks
15
+ * This is not a concern for properties as they are passed as is without
16
+ * serialization. For this reason, during _JSX to lit-html_ conversion, most JSX
17
+ * props are converted properties, except for the few cases when an attribute
18
+ * has no equivalent property.
19
+ */
20
+ export declare const nothing: never;
21
+ /**
22
+ * A sentinel value that signals that a value was handled by a directive and
23
+ * should not be written to the DOM.
24
+ *
25
+ * @remarks
26
+ * This is equivalent to Lit's native "noChange", but has type "never" to allow
27
+ * it be set as a value for any JSX attribute.
28
+ */
29
+ export declare const noChange: never;
30
+ /**
31
+ * Like native element.setAttribute(), but instead of stringifying nullish
32
+ * values, will call element.removeAttribute()
33
+ */
34
+ export declare function setAttribute(element: Element, attributeName: string, value: unknown): void;
35
+ /**
36
+ * If you have a property that can be both of string or boolean type, there is
37
+ * no automatic boolean conversion in place - that means the attribute is
38
+ * treated as a string.
39
+ *
40
+ * This converter improves that handling by converting `true` property value to
41
+ * an empty attribute, and `false` to removing the attribute.
42
+ *
43
+ * When setting the boolean attribute, the value is still not parsed (and will
44
+ * be either `null` or `""`). This matches the behavior in Stencil.
45
+ *
46
+ * ```tsx
47
+ * @property({ reflects:true, converter: stringOrBoolean }) icon: string | boolean;
48
+ * // ...
49
+ * this.icon = false; // attribute is removed
50
+ * this.icon = true; // attribute is ""
51
+ * this.icon = "name"; // attribute is "name"
52
+ * ```
53
+ */
54
+ export declare const stringOrBoolean: {
55
+ toAttribute: (value: unknown) => string | null;
56
+ };
@@ -2,6 +2,7 @@ import { Deferred } from "@arcgis/components-utils";
2
2
  import type { LitElement } from "./LitElement";
3
3
  import type { Runtime } from "./runtime";
4
4
  import type { ControllerManager } from "@arcgis/components-controllers";
5
+ import type { PublicLitElement } from "./PublicLitElement";
5
6
  /**
6
7
  * Defines lazy-loading proxy components for all web components in this package.
7
8
  *
@@ -105,7 +106,9 @@ export declare abstract class ProxyComponent extends HtmlElement {
105
106
  /**
106
107
  * Direct offspring that should be awaited before loaded() is emitted
107
108
  */
108
- _offspring: (Partial<Pick<LitElement, "manager">> & Pick<LitElement, "componentOnReady">)[];
109
+ _offspring: (PublicLitElement & {
110
+ manager?: LitElement["manager"];
111
+ })[];
109
112
  /**
110
113
  * Promise that resolves once parent's load() completed. False if there is no
111
114
  * parent
@@ -147,8 +150,11 @@ export declare abstract class ProxyComponent extends HtmlElement {
147
150
  /**
148
151
  * Create a promise that resolves once component is fully loaded
149
152
  */
150
- componentOnReady(): Promise<LitElement>;
153
+ componentOnReady(): Promise<this>;
151
154
  /** @internal */
152
155
  _initializeComponent(module: Record<string, typeof LitElement>): void;
153
156
  }
157
+ export type GlobalThisWithPuppeteerEnv = typeof globalThis & {
158
+ devOnly$createdElements?: WeakRef<ProxyComponent>[];
159
+ };
154
160
  export {};
@@ -5,4 +5,4 @@ import type { ProxyComponent } from "./lazyLoad";
5
5
  * Also, return a promise that will delay our load() until parent's load()
6
6
  * is completed.
7
7
  */
8
- export declare function attachToAncestor(child: ProxyComponent["_offspring"][number], el: HTMLElement): Promise<void> | false;
8
+ export declare function attachToAncestor(child: ProxyComponent["_offspring"][number]): Promise<void> | false;
package/dist/runtime.d.ts CHANGED
@@ -3,12 +3,12 @@ import type { LitElement } from "./LitElement";
3
3
  /**
4
4
  * `@arcgis/lumina` package may be bundled once but used by multiple packages with
5
5
  * different configuration options. For that reason, the configuration options
6
- * can not be a global object, but has to be an object that you pass around.
6
+ * cannot be a global object, but has to be an object that you pass around.
7
7
  */
8
8
  export type Runtime = RuntimeOptions & {
9
9
  /**
10
10
  * Get the base path to where the package assets can be found.
11
- * By default, the package asset path is set to "https://js.arcgis.com/<simplified-package-name>/<released-verion>/".
11
+ * By default, the package asset path is set to `https://js.arcgis.com/<simplified-package-name>/<released-verion>/`.
12
12
  * We are hosting our assets on a CDN (Content Delivery Network) to ensure fast and reliable access.
13
13
  * It is CORS-enabled, so you can load the assets from any domain.
14
14
  * Use "setAssetPath(path)" if the path needs to be customized.
@@ -18,8 +18,8 @@ export type Runtime = RuntimeOptions & {
18
18
  * Used to manually set the base path where package assets (like localization
19
19
  * and icons) can be found.
20
20
  *
21
- * By default, the package asset path is set to "https://js.arcgis.com/<simplified-package-name>/<released-verion>/".
22
- * For example, "https://js.arcgis.com/map-components/4.30/".
21
+ * By default, the package asset path is set to `https://js.arcgis.com/<simplified-package-name>/<released-verion>/`.
22
+ * For example, `https://js.arcgis.com/map-components/4.30/`.
23
23
  * We are hosting our assets on a CDN (Content Delivery Network) to ensure fast and reliable access.
24
24
  * It is CORS-enabled, so you can load the assets from any domain.
25
25
  * This is the recommended way to load the assets and avoid bundling them with your application.
@@ -1,8 +1,8 @@
1
- // src/stencil-ssr-compatibility/index.ts
1
+ // src/stencilSsrCompatibility/index.ts
2
2
  import { getWindow } from "@lit-labs/ssr/lib/dom-shim.js";
3
3
  import { render } from "@lit-labs/ssr/lib/render.js";
4
4
  import { html } from "@lit-labs/ssr/lib/server-template.js";
5
- import { unsafeStatic, withStatic } from "lit/static-html.js";
5
+ import { unsafeStatic, withStatic } from "lit-html/static.js";
6
6
  import { collectResult } from "@lit-labs/ssr/lib/render-result.js";
7
7
  import { RenderResultReadable } from "@lit-labs/ssr/lib/render-result-readable.js";
8
8
  var staticHtml = withStatic(html);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/lumina",
3
- "version": "4.31.0-next.98",
3
+ "version": "4.32.0-next.10",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -8,7 +8,7 @@
8
8
  "exports": {
9
9
  ".": "./dist/index.js",
10
10
  "./config": "./dist/config.js",
11
- "./stencil-ssr-compatibility": "./dist/stencil-ssr-compatibility/index.js",
11
+ "./stencilSsrCompatibility": "./dist/stencilSsrCompatibility/index.js",
12
12
  "./typings": {
13
13
  "types": "./dist/typings/index.d.ts"
14
14
  },
@@ -17,33 +17,14 @@
17
17
  "files": [
18
18
  "dist/"
19
19
  ],
20
- "publishConfig": {
21
- "registry": "https://registry.npmjs.org/",
22
- "access": "public"
23
- },
24
20
  "license": "SEE LICENSE IN LICENSE.md",
25
- "scripts": {
26
- "build": "tsup",
27
- "build:dev": "tsup --sourcemap",
28
- "watch": "yarn build:dev --watch",
29
- "clean": "rimraf ./dist ./build ./turbo ./node_modules"
30
- },
31
21
  "dependencies": {
32
- "@arcgis/components-controllers": "4.31.0-next.98",
33
- "@arcgis/components-utils": "4.31.0-next.98",
22
+ "@arcgis/components-controllers": "4.32.0-next.10",
23
+ "@arcgis/components-utils": "4.32.0-next.10",
34
24
  "@lit-labs/ssr": "^3.2.2",
35
25
  "@lit-labs/ssr-client": "^1.1.7",
36
26
  "csstype": "^3.1.3",
37
- "lit": "^3.1.2",
27
+ "lit": "^3.2.0",
38
28
  "tslib": "^2.7.0"
39
- },
40
- "devDependencies": {
41
- "@arcgis/typescript-config": "4.31.0-next.98",
42
- "@types/node": "^20.2.5",
43
- "eslint": "^8.55.0",
44
- "rimraf": "^5.0.0",
45
- "tsup": "^8.2.4",
46
- "typescript": "~5.4.0"
47
- },
48
- "gitHead": "cbe08697f9589db42635f6184bf7bd3dafcb2d79"
49
- }
29
+ }
30
+ }