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

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.
@@ -156,8 +156,17 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
156
156
  * }
157
157
  * ```
158
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;
159
+ listen<K extends keyof HTMLElementEventMap>(name: K, listener: (this: this, event: HTMLElementEventMap[K]) => unknown, options?: AddEventListenerOptions | boolean): void;
160
+ listen(name: string, listener: (this: this, event: Event) => unknown, options?: AddEventListenerOptions | boolean): void;
161
+ listen<EventType extends Event = CustomEvent<"Provide type like this.listenOn<ToEvents<ArcgisCounter>['arcgisClick']>() to get type-checked payload type">>(name: string,
162
+ /**
163
+ * The "NoInfer" here forces type argument to be specified explicitly.
164
+ * Without it, the following would be allowed:
165
+ * ```tsx
166
+ * this.listen("focus",(event:NotFocusEvent)=>{....})
167
+ * ```
168
+ */
169
+ listener: (this: this, event: NoInfer<EventType>) => unknown, options?: AddEventListenerOptions | boolean): void;
161
170
  /**
162
171
  * A helper for setting even listener on any element (or window / document).
163
172
  *
@@ -195,7 +204,15 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
195
204
  listenOn<Name extends keyof HTMLElementEventMap>(target: HTMLElement, name: Name, listener: Listener<this, HTMLElementEventMap[Name] & {
196
205
  currentTarget: HTMLElement;
197
206
  }>, 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 & {
207
+ 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,
208
+ /**
209
+ * The "NoInfer" here forces type argument to be specified explicitly.
210
+ * Without it, the following would be allowed:
211
+ * ```tsx
212
+ * this.listen("focus",(event:NotFocusEvent)=>{....})
213
+ * ```
214
+ */
215
+ listener: Listener<this, NoInfer<EventType> & {
199
216
  currentTarget: Target;
200
217
  }>, options?: AddEventListenerOptions | boolean): void;
201
218
  /**
@@ -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, dynamicValueDirective, 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,30 @@ 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
+ console.error(error);
216
+ this._postLoaded.reject(error);
217
+ });
198
218
  }
199
219
  if (process.env.NODE_ENV !== "production") {
200
220
  ProxyClass._hmrInstances ??= [];
201
221
  ProxyClass._hmrInstances.push(new WeakRef(this));
222
+ Object.defineProperty(this, "_store", {
223
+ value: this._store,
224
+ enumerable: false,
225
+ configurable: true
226
+ });
202
227
  }
203
228
  }
204
229
  static {
@@ -211,7 +236,7 @@ var ProxyComponent = class extends HtmlElement {
211
236
  this._syncMethods?.forEach(this._bindSync, this);
212
237
  }
213
238
  static _bindProp(propName) {
214
- Object.defineProperty(this.prototype, propName, {
239
+ defineProperty(this.prototype, propName, {
215
240
  configurable: true,
216
241
  enumerable: true,
217
242
  get() {
@@ -226,7 +251,7 @@ var ProxyComponent = class extends HtmlElement {
226
251
  });
227
252
  }
228
253
  static _bindAsync(methodName) {
229
- Object.defineProperty(this.prototype, methodName, {
254
+ defineProperty(this.prototype, methodName, {
230
255
  async value(...args) {
231
256
  if (!this._litElement) {
232
257
  await this._postLoaded.promise;
@@ -234,13 +259,11 @@ var ProxyComponent = class extends HtmlElement {
234
259
  const genericLitElement = this._litElement;
235
260
  return await genericLitElement[methodName](...args);
236
261
  },
237
- configurable: true,
238
- writable: true,
239
- enumerable: true
262
+ configurable: true
240
263
  });
241
264
  }
242
265
  static _bindSync(methodName) {
243
- Object.defineProperty(this.prototype, methodName, {
266
+ defineProperty(this.prototype, methodName, {
244
267
  value(...args) {
245
268
  if (process.env.NODE_ENV === "development" && !this._litElement) {
246
269
  const ProxyClass = this.constructor;
@@ -251,8 +274,7 @@ var ProxyComponent = class extends HtmlElement {
251
274
  const genericLitElement = this._litElement;
252
275
  return genericLitElement[methodName](...args);
253
276
  },
254
- configurable: true,
255
- enumerable: true
277
+ configurable: true
256
278
  });
257
279
  }
258
280
  get manager() {
@@ -310,10 +332,10 @@ var ProxyComponent = class extends HtmlElement {
310
332
  }
311
333
  connectedCallback() {
312
334
  if (this._litElement) {
313
- this._litElement?.connectedCallback();
335
+ this._litElement.connectedCallback();
314
336
  } else {
315
337
  queueMicrotask(() => {
316
- this._ancestorLoad = attachToAncestor(this, this);
338
+ this._ancestorLoad = attachToAncestor(this);
317
339
  });
318
340
  }
319
341
  }
@@ -352,17 +374,38 @@ var ProxyComponent = class extends HtmlElement {
352
374
  const isFirstInitialization = !ProxyClass._LitConstructor;
353
375
  if (isFirstInitialization) {
354
376
  ProxyClass._LitConstructor = LitConstructor;
355
- LitConstructor.prototype.removeAttribute = removeAttribute;
356
- LitConstructor.prototype.setAttribute = setAttribute;
377
+ LitConstructor.prototype.removeAttribute = function(qualifiedName) {
378
+ HTMLElement.prototype.removeAttribute.call(this.el, qualifiedName);
379
+ };
380
+ LitConstructor.prototype.setAttribute = function(qualifiedName, value) {
381
+ HTMLElement.prototype.setAttribute.call(this.el, qualifiedName, value);
382
+ };
383
+ defineProperty(LitConstructor.prototype, "isConnected", {
384
+ get() {
385
+ return this.el.isConnected;
386
+ }
387
+ });
357
388
  if (process.env.NODE_ENV !== "production" && LitConstructor.shadowRootOptions !== noShadowRoot) {
358
- devOnlyDetectIncorrectLazyUsages(Object.getPrototypeOf(LitConstructor));
389
+ let prototype = LitConstructor;
390
+ while (prototype && !Object.hasOwn(prototype, "lumina")) {
391
+ prototype = Object.getPrototypeOf(prototype);
392
+ }
393
+ devOnlyDetectIncorrectLazyUsages(prototype);
359
394
  }
360
395
  customElements.define(lazyTagName, LitConstructor);
361
396
  }
362
397
  LitConstructor.lazy = this;
363
398
  const litElement = document.createElement(lazyTagName);
364
399
  LitConstructor.lazy = void 0;
365
- this._litElement = litElement;
400
+ if (process.env.NODE_ENV !== "production") {
401
+ Object.defineProperty(this, "_litElement", {
402
+ value: litElement,
403
+ configurable: true,
404
+ enumerable: false
405
+ });
406
+ } else {
407
+ this._litElement = litElement;
408
+ }
366
409
  this._pendingAttributes.forEach((name) => {
367
410
  const value = this.getAttribute(name);
368
411
  litElement.attributeChangedCallback(
@@ -381,26 +424,24 @@ var ProxyComponent = class extends HtmlElement {
381
424
  const missingFromLit = lazyObserved.filter((attribute) => !litObserved.includes(attribute));
382
425
  if (missingFromLazy.length > 0) {
383
426
  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`
427
+ `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
428
  );
386
429
  }
387
430
  if (missingFromLit.length > 0) {
388
431
  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`
432
+ `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
433
  );
391
434
  }
392
435
  }
393
- if (this.isConnected) {
394
- litElement.connectedCallback();
436
+ const isStillConnected = this.isConnected;
437
+ if (isStillConnected || this._ancestorLoad) {
438
+ litElement.connectedCallback?.();
439
+ if (!isStillConnected) {
440
+ litElement.disconnectedCallback();
441
+ }
395
442
  }
396
443
  }
397
444
  };
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
445
  function syncLitElement([key, value]) {
405
446
  this[key] = value;
406
447
  }
@@ -542,13 +583,6 @@ var LitElement = class _LitElement extends OriginalLitElement {
542
583
  * @internal
543
584
  */
544
585
  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
586
  this._postLoaded = this.constructor.lazy?._postLoaded ?? new Deferred2();
553
587
  this._enableUpdating = this.enableUpdating;
554
588
  this.enableUpdating = emptyFunction;
@@ -618,7 +652,13 @@ var LitElement = class _LitElement extends OriginalLitElement {
618
652
  const isFirstCall = !this.manager.connectedCalled;
619
653
  super.connectedCallback();
620
654
  if (isFirstCall) {
621
- queueMicrotask(() => void this._load().catch(this._postLoaded.reject));
655
+ queueMicrotask(
656
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/promise-function-async
657
+ () => this._load().catch((error) => {
658
+ console.error(error);
659
+ this._postLoaded.reject(error);
660
+ })
661
+ );
622
662
  }
623
663
  }
624
664
  /**
@@ -643,16 +683,18 @@ var LitElement = class _LitElement extends OriginalLitElement {
643
683
  }
644
684
  return existingShadowRoot;
645
685
  }
646
- const domRoot = renderRoot.getRootNode();
647
- domRoot.adoptedStyleSheets = [
648
- ...domRoot.adoptedStyleSheets,
649
- ...Class.elementStyles.map((stylesheet) => "styleSheet" in stylesheet ? stylesheet.styleSheet : stylesheet)
650
- ];
686
+ if (this.isConnected) {
687
+ const domRoot = renderRoot.getRootNode();
688
+ domRoot.adoptedStyleSheets = [
689
+ ...domRoot.adoptedStyleSheets,
690
+ ...Class.elementStyles.map((stylesheet) => "styleSheet" in stylesheet ? stylesheet.styleSheet : stylesheet)
691
+ ];
692
+ }
651
693
  return renderRoot;
652
694
  }
653
695
  /** Do asynchronous component load */
654
696
  async _load() {
655
- const parentLoadPromise = this._ancestorLoad ?? attachToAncestor(this, this);
697
+ const parentLoadPromise = this.el._ancestorLoad ?? attachToAncestor(this.el);
656
698
  if (parentLoadPromise) {
657
699
  await parentLoadPromise;
658
700
  }
@@ -746,21 +788,72 @@ function makeRuntime(options) {
746
788
  }
747
789
 
748
790
  // 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";
791
+ var Fragment = void 0;
751
792
  var bindAttribute = void 0;
752
793
  var bindBooleanAttribute = void 0;
753
794
  var bindProperty = void 0;
754
795
  var bindEvent = void 0;
755
- var nothing = litNothing;
756
- var noChange = litNoChange;
757
- var directive = litDirective;
758
796
 
759
797
  // src/jsx/directives.ts
760
798
  import { classMap } from "lit-html/directives/class-map.js";
761
799
  import { styleMap } from "lit/directives/style-map.js";
800
+ import { Directive } from "lit-html/directive.js";
801
+ import { directive as litDirective } from "lit-html/directive.js";
802
+ import { live as litLive } from "lit-html/directives/live.js";
762
803
  var safeClassMap = (parameters) => typeof parameters === "object" && parameters != null ? classMap(parameters) : parameters;
763
804
  var safeStyleMap = (parameters) => typeof parameters === "object" && parameters != null ? styleMap(parameters) : parameters;
805
+ var directive = litDirective;
806
+ var DynamicHtmlValueDirective = class extends Directive {
807
+ update(part, [prop, value]) {
808
+ if (process.env.NODE_ENV !== "production") {
809
+ if (part.type !== 6) {
810
+ throw new Error("DynamicHtmlValueDirective can only be used in the element part position");
811
+ }
812
+ if (prop !== "value" && prop !== "defaultValue") {
813
+ throw new Error('Expected the first argument to DynamicHtmlValueDirective to be "value" or "defaultValue"');
814
+ }
815
+ if (typeof value === "object" && value != null) {
816
+ if ("_$litDirective$" in value) {
817
+ throw new Error(
818
+ "Directive is not supported as a value for the `value` or `defaultValue` prop when the tag name is dynamic."
819
+ );
820
+ } else {
821
+ throw new Error(
822
+ `Tried to set an object as the value/defaultValue prop in a <${part.element.tagName}> element.`
823
+ );
824
+ }
825
+ }
826
+ }
827
+ const element = part.element;
828
+ const tagName = element.tagName;
829
+ if (prop === "value" ? tagName === "INPUT" : tagName === "BUTTON" || tagName === "DATA") {
830
+ if (element[prop] !== value) {
831
+ element[prop] = value;
832
+ }
833
+ } else if (value != null) {
834
+ element.setAttribute("value", value);
835
+ } else {
836
+ element.removeAttribute("value");
837
+ }
838
+ }
839
+ };
840
+ var dynamicValueDirective = directive(DynamicHtmlValueDirective);
841
+ var live = litLive;
842
+
843
+ // src/jsx/utils.ts
844
+ import { noChange as litNoChange, nothing as litNothing } from "lit-html";
845
+ var nothing = litNothing;
846
+ var noChange = litNoChange;
847
+ function setAttribute(element, attributeName, value) {
848
+ if (value == null) {
849
+ element.removeAttribute(attributeName);
850
+ } else {
851
+ element.setAttribute(attributeName, value);
852
+ }
853
+ }
854
+ var stringOrBoolean = {
855
+ toAttribute: (value) => value === true ? "" : value === false ? null : value
856
+ };
764
857
 
765
858
  // src/wrappersUtils.ts
766
859
  function createPrototypeProxy(tagName) {
@@ -782,6 +875,7 @@ function createPrototypeProxy(tagName) {
782
875
  return customElement;
783
876
  }
784
877
  export {
878
+ Fragment,
785
879
  LitElement,
786
880
  bindAttribute,
787
881
  bindBooleanAttribute,
@@ -790,8 +884,10 @@ export {
790
884
  createEvent,
791
885
  createPrototypeProxy,
792
886
  directive,
887
+ dynamicValueDirective,
793
888
  handleComponentMetaUpdate,
794
889
  handleHmrUpdate,
890
+ live,
795
891
  makeDefineCustomElements,
796
892
  makeRuntime,
797
893
  method,
@@ -801,5 +897,7 @@ export {
801
897
  property,
802
898
  safeClassMap,
803
899
  safeStyleMap,
804
- state
900
+ setAttribute,
901
+ state,
902
+ stringOrBoolean
805
903
  };
@@ -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,31 @@ 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
+ * Do not import this directly. It will be inserted automatically by JSX to
65
+ * lit-html transformer when you are setting "value" or "defaultValue" JSX prop
66
+ * in an element with dynamic tag name.
67
+ *
68
+ * @internal
69
+ */
70
+ export declare const dynamicValueDirective: (...values: never) => never;
71
+ /**
72
+ * Checks binding values against live DOM values, instead of previously bound
73
+ * values, when determining whether to update the value.
74
+ *
75
+ * @see https://lit.dev/docs/templates/directives/#live
76
+ *
77
+ * @remarks
78
+ * This is equivalent to Lit's native "directive()", but has return type
79
+ * "never" to allow it be set as a value for any JSX attribute.
80
+ */
81
+ 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;
@@ -1409,6 +1360,7 @@ export declare namespace LuminaJsx {
1409
1360
  required?: boolean;
1410
1361
  rows?: number | string;
1411
1362
  value?: string | number;
1363
+ defaultValue?: string | number;
1412
1364
  wrap?: "hard" | "soft" | "off";
1413
1365
  maxLength?: number | string;
1414
1366
  minLength?: number | string;
@@ -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
+ };
@@ -105,7 +105,7 @@ export declare abstract class ProxyComponent extends HtmlElement {
105
105
  /**
106
106
  * Direct offspring that should be awaited before loaded() is emitted
107
107
  */
108
- _offspring: (Partial<Pick<LitElement, "manager">> & Pick<LitElement, "componentOnReady">)[];
108
+ _offspring: (Element & Partial<Pick<LitElement, "manager">> & Pick<LitElement, "componentOnReady">)[];
109
109
  /**
110
110
  * Promise that resolves once parent's load() completed. False if there is no
111
111
  * parent
@@ -151,4 +151,7 @@ export declare abstract class ProxyComponent extends HtmlElement {
151
151
  /** @internal */
152
152
  _initializeComponent(module: Record<string, typeof LitElement>): void;
153
153
  }
154
+ export type GlobalThisWithPuppeteerEnv = typeof globalThis & {
155
+ devOnly$createdElements?: WeakRef<ProxyComponent>[];
156
+ };
154
157
  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,7 +3,7 @@ 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
  /**
@@ -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.2",
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
  },
@@ -29,21 +29,21 @@
29
29
  "clean": "rimraf ./dist ./build ./turbo ./node_modules"
30
30
  },
31
31
  "dependencies": {
32
- "@arcgis/components-controllers": "4.31.0-next.98",
33
- "@arcgis/components-utils": "4.31.0-next.98",
32
+ "@arcgis/components-controllers": "4.32.0-next.2",
33
+ "@arcgis/components-utils": "4.32.0-next.2",
34
34
  "@lit-labs/ssr": "^3.2.2",
35
35
  "@lit-labs/ssr-client": "^1.1.7",
36
36
  "csstype": "^3.1.3",
37
- "lit": "^3.1.2",
37
+ "lit": "^3.2.0",
38
38
  "tslib": "^2.7.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@arcgis/typescript-config": "4.31.0-next.98",
41
+ "@arcgis/typescript-config": "4.32.0-next.2",
42
42
  "@types/node": "^20.2.5",
43
43
  "eslint": "^8.55.0",
44
44
  "rimraf": "^5.0.0",
45
- "tsup": "^8.2.4",
45
+ "tsup": "^8.3.0",
46
46
  "typescript": "~5.4.0"
47
47
  },
48
- "gitHead": "cbe08697f9589db42635f6184bf7bd3dafcb2d79"
48
+ "gitHead": "8c9d6f7c0e88ea1b6ddbc00ebdb1c89069b0cbbf"
49
49
  }