@arcgis/lumina 5.2.0-next.2 → 5.2.0-next.21
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/dist/{ControllerManager-DpJfvft9.js → ControllerManager-4cSEnB5Y.js} +12 -8
- package/dist/{Controller-Cer_6Z29.js → GenericController-C8NSb50b.js} +59 -23
- package/dist/LitElement.d.ts +179 -250
- package/dist/PublicLitElement.d.ts +64 -30
- package/dist/config.d.ts +22 -16
- package/dist/context.d.ts +24 -24
- package/dist/controllers/Controller.d.ts +106 -139
- package/dist/controllers/ControllerInternals.d.ts +33 -25
- package/dist/controllers/ControllerManager.d.ts +40 -61
- package/dist/controllers/GenericController.d.ts +26 -0
- package/dist/controllers/accessor/index.d.ts +6 -4
- package/dist/controllers/accessor/index.js +23 -5
- package/dist/controllers/accessor/reEmitEvent.d.ts +6 -3
- package/dist/controllers/accessor/store.d.ts +21 -14
- package/dist/controllers/accessor/useAccessor.d.ts +86 -68
- package/dist/controllers/functional.d.ts +11 -4
- package/dist/controllers/index.d.ts +35 -36
- package/dist/controllers/index.js +5 -7
- package/dist/controllers/load.d.ts +3 -2
- package/dist/controllers/proxyExports.d.ts +6 -5
- package/dist/controllers/toFunction.d.ts +4 -2
- package/dist/controllers/trackKey.d.ts +9 -4
- package/dist/controllers/trackPropKey.d.ts +8 -2
- package/dist/controllers/trackPropertyKey.d.ts +11 -6
- package/dist/controllers/types.d.ts +99 -170
- package/dist/controllers/useDirection.d.ts +5 -6
- package/dist/controllers/useMedia.d.ts +3 -2
- package/dist/controllers/usePropertyChange.d.ts +9 -10
- package/dist/controllers/useSlottableRequest.d.ts +15 -10
- package/dist/controllers/useT9n.d.ts +44 -38
- package/dist/controllers/useWatchAttributes.d.ts +6 -3
- package/dist/controllers/utils.d.ts +13 -5
- package/dist/createEvent.d.ts +32 -32
- package/dist/decorators.d.ts +16 -9
- package/dist/formAssociatedUtils.d.ts +5 -47
- package/dist/globalTypes/importMeta.d.ts +18 -10
- package/dist/globalTypes/index.d.ts +6 -4
- package/dist/globalTypes/jsxGlobals.d.ts +36 -23
- package/dist/globalTypes/loadLitCss.d.ts +61 -40
- package/dist/globalTypes/viteEnv.d.ts +60 -26
- package/dist/hmrSupport.d.ts +24 -28
- package/dist/index.d.ts +17 -16
- package/dist/index.js +27 -7
- package/dist/jsx/baseTypes.d.ts +26 -26
- package/dist/jsx/directives.d.ts +30 -42
- package/dist/jsx/generatedTypes.d.ts +3002 -2923
- package/dist/jsx/types.d.ts +214 -171
- package/dist/jsx/utils.d.ts +19 -14
- package/dist/lazyLoad.d.ts +31 -110
- package/dist/makeRuntime.d.ts +104 -127
- package/dist/{proxyExports-BkN6hND0.js → proxyExports-ZRLty8oJ.js} +1 -1
- package/dist/render.d.ts +4 -2
- package/dist/utils.d.ts +9 -14
- package/dist/wrappersUtils.d.ts +25 -26
- package/package.json +7 -4
- package/dist/devOnlyDetectIncorrectLazyUsages.d.ts +0 -14
- package/dist/lifecycleSupport.d.ts +0 -8
- package/dist/tests/wrappersUtils.typeTest.d.ts +0 -1
package/dist/jsx/types.d.ts
CHANGED
|
@@ -1,33 +1,119 @@
|
|
|
1
|
-
import { TemplateResult } from
|
|
2
|
-
import { DirectiveResult } from
|
|
3
|
-
import { HTMLElementTags, HTMLAttributes, GlobalEventHandlersCamelCase, SvgElementTags, DOMAttributes, AriaAttributes } from
|
|
4
|
-
import { CustomAttributes } from
|
|
1
|
+
import type { TemplateResult } from "lit";
|
|
2
|
+
import type { DirectiveResult } from "lit/directive.js";
|
|
3
|
+
import type { HTMLElementTags as HTMLElementTagsAlias, HTMLAttributes as HTMLAttributesAlias, GlobalEventHandlersCamelCase, SvgElementTags as SvgElementTagsAlias, DOMAttributes as DOMAttributesAlias, AriaAttributes as AriaAttributesAlias, HTMLAttributes } from "./generatedTypes.js";
|
|
4
|
+
import type { CustomAttributes as CustomAttributesAlias } from "./baseTypes.js";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* The "h" namespace is used to import JSX types for elements and attributes.
|
|
7
10
|
* It is imported in order to avoid conflicting global JSX issues.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
8
13
|
*/
|
|
9
14
|
export declare namespace h {
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
// TypeScript does not type-check the JSX function signature
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
export function h(sel: any, data?: any, text?: any): TemplateResult;
|
|
18
|
+
|
|
19
|
+
export type { LuminaJsx as JSX };
|
|
12
20
|
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
13
24
|
/**
|
|
14
|
-
*
|
|
25
|
+
* These types are based on dom-expressions typed (used by Solid and Preact):
|
|
26
|
+
* https://github.com/ryansolid/dom-expressions/blob/main/packages/dom-expressions/src/jsx.d.ts
|
|
27
|
+
*
|
|
28
|
+
* They in turn are based on Surplus and Inferno:
|
|
29
|
+
* - https://github.com/adamhaile/surplus/blob/master/index.d.ts
|
|
30
|
+
* - https://github.com/infernojs/inferno/blob/master/packages/inferno/src/core/types.ts
|
|
31
|
+
*
|
|
32
|
+
* Documentation about how to type JSX in TypeScript:
|
|
33
|
+
* https://www.typescriptlang.org/docs/handbook/jsx.html
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
15
36
|
*/
|
|
16
|
-
export declare
|
|
17
|
-
|
|
18
|
-
|
|
37
|
+
export declare namespace LuminaJsx {
|
|
38
|
+
export type Element = TemplateResult;
|
|
39
|
+
|
|
40
|
+
export type ElementType = JsxNode;
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* Class-based components are not supported. All custom elements are to be
|
|
44
|
+
* invoked as <intrinsic-elements>.
|
|
45
|
+
*/
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
47
|
+
export interface ElementClass {}
|
|
48
|
+
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
50
|
+
export interface ElementAttributesProperty {}
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
53
|
+
export interface IntrinsicClassAttributes {}
|
|
54
|
+
|
|
55
|
+
export interface ElementChildrenAttribute {
|
|
56
|
+
children: JsxNode;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface IntrinsicAttributes {
|
|
60
|
+
/**
|
|
61
|
+
* The `key` is a special attribute that can be set on any element.
|
|
62
|
+
*
|
|
63
|
+
* At build-time it is translated into the `keyed()` directive:
|
|
64
|
+
* https://lit.dev/docs/templates/directives/#keyed
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* Unlike in React or Stencil, any JavaScript value is acceptable as a key
|
|
68
|
+
*/
|
|
69
|
+
key?: unknown;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface IntrinsicElements
|
|
73
|
+
extends HTMLElementTags,
|
|
74
|
+
SvgElementTags,
|
|
75
|
+
ReMappedComponents<DeclareElements>,
|
|
76
|
+
ReMapStencilComponents<ImportStencilElements> {}
|
|
77
|
+
|
|
78
|
+
/** @deprecated import type { CustomAttributes } from "@arcgis/lumina/jsx/baseTypes"; instead */
|
|
79
|
+
export interface CustomAttributes<T = HTMLElement> extends CustomAttributesAlias<T> {}
|
|
80
|
+
/** @deprecated import type { DOMAttributes } from "@arcgis/lumina/jsx/generatedTypes"; instead */
|
|
81
|
+
export interface DOMAttributes<T = HTMLElement> extends DOMAttributesAlias<T> {}
|
|
82
|
+
/** @deprecated import type { HTMLAttributes } from "@arcgis/lumina/jsx/generatedTypes"; instead */
|
|
83
|
+
export interface HTMLAttributes<T = HTMLElement> extends HTMLAttributesAlias<T> {}
|
|
84
|
+
/** @deprecated import type { HTMLElementTags } from "@arcgis/lumina/jsx/generatedTypes"; instead */
|
|
85
|
+
export interface HTMLElementTags extends HTMLElementTagsAlias {}
|
|
86
|
+
/** @deprecated import type { SvgElementTags } from "@arcgis/lumina/jsx/generatedTypes"; instead */
|
|
87
|
+
export interface SvgElementTags extends SvgElementTagsAlias {}
|
|
88
|
+
/** @deprecated import type { AriaAttributes } from "@arcgis/lumina/jsx/generatedTypes"; instead */
|
|
89
|
+
export interface AriaAttributes extends AriaAttributesAlias {}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The references to this function are removed at build time. */
|
|
93
|
+
export const Fragment: (props: { children?: JsxNode; }) => TemplateResult;
|
|
94
|
+
|
|
19
95
|
/**
|
|
20
|
-
* @private
|
|
21
96
|
* The references to this function are removed at build time. You do not need
|
|
22
97
|
* to import it directly
|
|
98
|
+
*
|
|
99
|
+
* @param type
|
|
100
|
+
* @param props
|
|
101
|
+
* @param key
|
|
102
|
+
* @internal
|
|
23
103
|
*/
|
|
24
|
-
export
|
|
104
|
+
export function jsx(type: string, props: unknown, key?: unknown): JsxNode;
|
|
105
|
+
|
|
25
106
|
/**
|
|
26
|
-
* @private
|
|
27
107
|
* The references to this function are removed at build time. You do not need
|
|
28
108
|
* to import it directly
|
|
109
|
+
*
|
|
110
|
+
* @param type
|
|
111
|
+
* @param props
|
|
112
|
+
* @param key
|
|
113
|
+
* @internal
|
|
29
114
|
*/
|
|
30
|
-
export
|
|
115
|
+
export function jsxs(type: string, props: unknown, key?: unknown): JsxNode;
|
|
116
|
+
|
|
31
117
|
/**
|
|
32
118
|
* The JSX to lit-html conversion has a heuristic to determine whether a prop
|
|
33
119
|
* should be converted to a property or attribute at runtime. In cases where
|
|
@@ -38,6 +124,10 @@ export declare function jsxs(type: string, props: unknown, key?: unknown): JsxNo
|
|
|
38
124
|
* impact. But that also means you should not call this function anywhere other
|
|
39
125
|
* than at the top level of a JSX prop value
|
|
40
126
|
*
|
|
127
|
+
* If you often encounter cases where the JSX to lit-html incorrectly converts
|
|
128
|
+
* the prop to a property necessitating the use of `bindAttribute()`, please open
|
|
129
|
+
* an issue for Lumina.
|
|
130
|
+
*
|
|
41
131
|
* @example
|
|
42
132
|
* ```tsx
|
|
43
133
|
* <my-component
|
|
@@ -49,13 +139,9 @@ export declare function jsxs(type: string, props: unknown, key?: unknown): JsxNo
|
|
|
49
139
|
* ```ts
|
|
50
140
|
* html`<my-component name="Pass name as attribute rather than property"></my-component>`
|
|
51
141
|
* ```
|
|
52
|
-
*
|
|
53
|
-
* @remarks
|
|
54
|
-
* If you often encounter cases where the JSX to lit-html incorrectly converts
|
|
55
|
-
* the prop to a property necessitating the use of `bindAttribute()`, please open
|
|
56
|
-
* an issue for Lumina.
|
|
57
142
|
*/
|
|
58
|
-
export
|
|
143
|
+
export const bindAttribute: <T>(value: T) => T;
|
|
144
|
+
|
|
59
145
|
/**
|
|
60
146
|
* The JSX to lit-html conversion has a heuristic to determine whether a prop
|
|
61
147
|
* should be converted to a property, attribute or boolean attribute at runtime.
|
|
@@ -67,8 +153,11 @@ export declare const bindAttribute: <T>(value: T) => T;
|
|
|
67
153
|
* impact. But that also means you should not call this function anywhere other
|
|
68
154
|
* than at the top level of a JSX prop value
|
|
69
155
|
*
|
|
70
|
-
*
|
|
156
|
+
* If you often encounter cases where the JSX to lit-html incorrectly converts
|
|
157
|
+
* the prop necessitating the use of `bindBooleanAttribute()`, please open
|
|
158
|
+
* an issue for Lumina.
|
|
71
159
|
*
|
|
160
|
+
* @see https://lit.dev/docs/templates/expressions/#boolean-attribute-expressions
|
|
72
161
|
* @example
|
|
73
162
|
* ```tsx
|
|
74
163
|
* <my-component
|
|
@@ -80,13 +169,9 @@ export declare const bindAttribute: <T>(value: T) => T;
|
|
|
80
169
|
* ```ts
|
|
81
170
|
* html`<my-component ?checked=${myBoolean}></my-component>`
|
|
82
171
|
* ```
|
|
83
|
-
*
|
|
84
|
-
* @remarks
|
|
85
|
-
* If you often encounter cases where the JSX to lit-html incorrectly converts
|
|
86
|
-
* the prop necessitating the use of `bindBooleanAttribute()`, please open
|
|
87
|
-
* an issue for Lumina.
|
|
88
172
|
*/
|
|
89
|
-
export
|
|
173
|
+
export const bindBooleanAttribute: <T>(value: T) => T;
|
|
174
|
+
|
|
90
175
|
/**
|
|
91
176
|
* The JSX to lit-html conversion has a heuristic to determine whether a prop
|
|
92
177
|
* should be converted to a property or attribute at runtime. In cases where
|
|
@@ -97,6 +182,10 @@ export declare const bindBooleanAttribute: <T>(value: T) => T;
|
|
|
97
182
|
* impact. But that also means you should not call this function anywhere other
|
|
98
183
|
* than at the top level of a JSX prop value
|
|
99
184
|
*
|
|
185
|
+
* If you often encounter cases where the JSX to lit-html incorrectly converts
|
|
186
|
+
* the prop to an attribute necessitating the use of `bindProperty()`, please open
|
|
187
|
+
* an issue for Lumina.
|
|
188
|
+
*
|
|
100
189
|
* @example
|
|
101
190
|
* ```tsx
|
|
102
191
|
* <my-component
|
|
@@ -108,17 +197,9 @@ export declare const bindBooleanAttribute: <T>(value: T) => T;
|
|
|
108
197
|
* ```ts
|
|
109
198
|
* html`<my-component .my-prop="Pass my-prop as a property rather than attribute"></my-component>`
|
|
110
199
|
* ```
|
|
111
|
-
*
|
|
112
|
-
* @remarks
|
|
113
|
-
* If you often encounter cases where the JSX to lit-html incorrectly converts
|
|
114
|
-
* the prop to an attribute necessitating the use of `bindProperty()`, please open
|
|
115
|
-
* an issue for Lumina.
|
|
116
|
-
*
|
|
117
|
-
* @remarks
|
|
118
|
-
* This function is not named `property()` because that is already taken by
|
|
119
|
-
* Lit's \@property() decorator
|
|
120
200
|
*/
|
|
121
|
-
export
|
|
201
|
+
export const bindProperty: <T>(value: T) => T;
|
|
202
|
+
|
|
122
203
|
/**
|
|
123
204
|
* The `bindEvent()` function lets you customize the event binding behavior by
|
|
124
205
|
* providing options like passive, capture, once and other options that you
|
|
@@ -127,6 +208,10 @@ export declare const bindProperty: <T>(value: T) => T;
|
|
|
127
208
|
* This function call will be erased at build-time, thus it has no runtime
|
|
128
209
|
* impact.
|
|
129
210
|
*
|
|
211
|
+
* This function is a _JSX to lit-html_ adaptation of the Lit's event listener
|
|
212
|
+
* customization syntax.
|
|
213
|
+
* See https://lit.dev/docs/components/events/#event-options-decorator
|
|
214
|
+
*
|
|
130
215
|
* @example
|
|
131
216
|
* ```tsx
|
|
132
217
|
* <my-component
|
|
@@ -137,23 +222,13 @@ export declare const bindProperty: <T>(value: T) => T;
|
|
|
137
222
|
* ```ts
|
|
138
223
|
* html`<my-component onScroll=${{ handleEvent: console.log, passive:true }}></my-component>`
|
|
139
224
|
* ```
|
|
140
|
-
*
|
|
141
|
-
* @remarks
|
|
142
|
-
* This function is a _JSX to lit-html_ adaptation of the Lit's event listener
|
|
143
|
-
* customization syntax.
|
|
144
|
-
* See https://lit.dev/docs/components/events/#event-options-decorator
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* @remarks
|
|
148
|
-
* This function is not named `event` because there is a legacy `window.event`
|
|
149
|
-
* global that was interfering with auto-imports of this function.
|
|
150
225
|
*/
|
|
151
|
-
export
|
|
152
|
-
|
|
153
|
-
})) => T;
|
|
226
|
+
export const bindEvent: <T>(descriptor: T | (AddEventListenerOptions & { handleEvent: T; })) => T;
|
|
227
|
+
|
|
154
228
|
export type JsxNode = DirectiveResult<any> | JsxNodeArray | Node | TemplateResult | boolean | number | (NonNullable<unknown> & string) | null | undefined;
|
|
155
|
-
|
|
156
|
-
}
|
|
229
|
+
|
|
230
|
+
export interface JsxNodeArray extends Array<JsxNode> {}
|
|
231
|
+
|
|
157
232
|
/**
|
|
158
233
|
* By not requiring to have some sort of typings generation watcher to run
|
|
159
234
|
* in the background and generate types for the components based on the
|
|
@@ -174,11 +249,10 @@ interface JsxNodeArray extends Array<JsxNode> {
|
|
|
174
249
|
* information and can generate the typings that expose only the actual
|
|
175
250
|
* properties component declared.
|
|
176
251
|
*
|
|
177
|
-
* @
|
|
178
|
-
* Do not exclude "manager" and "componentOnReady" since these properties are
|
|
179
|
-
* available both on lazy and non-lazy instance.
|
|
252
|
+
* @internal
|
|
180
253
|
*/
|
|
181
|
-
type ExcludedProperties = "addController" | "attributeChangedCallback" | "connectedCallback" | "disconnectedCallback" | "el" | "elementInternals" | "hasUpdated" | "isUpdatePending" | "listen" | "load" | "loaded" | "removeController" | "render" | "renderOptions" | "renderRoot" | "requestUpdate" | "updateComplete" | "updated" | "willUpdate";
|
|
254
|
+
export type ExcludedProperties = "addController" | "attributeChangedCallback" | "connectedCallback" | "disconnectedCallback" | "el" | "elementInternals" | "hasUpdated" | "isUpdatePending" | "listen" | "load" | "loaded" | "removeController" | "render" | "renderOptions" | "renderRoot" | "requestUpdate" | "updateComplete" | "updated" | "willUpdate";
|
|
255
|
+
|
|
182
256
|
/**
|
|
183
257
|
* this.el property on a component only has the public properties of the
|
|
184
258
|
* component. All internal methods, properties, as well as LitElement methods
|
|
@@ -189,12 +263,9 @@ type ExcludedProperties = "addController" | "attributeChangedCallback" | "connec
|
|
|
189
263
|
* Usually, you don't need to use this type directly. If you have an
|
|
190
264
|
* `ArcgisCounter` element, you can get its el type by using
|
|
191
265
|
* `ArcgisCounter["el"]`
|
|
192
|
-
*
|
|
193
|
-
* @remarks
|
|
194
|
-
* By using Omit<>, TypeScript also "forgets" all private members of the
|
|
195
|
-
* passed in type, which is convenient for us.
|
|
196
266
|
*/
|
|
197
267
|
export type ToElement<Component> = Omit<Component, ExcludedProperties>;
|
|
268
|
+
|
|
198
269
|
/**
|
|
199
270
|
* Utility type for getting the JSX prop types for a given component. In particular:
|
|
200
271
|
*
|
|
@@ -211,29 +282,31 @@ export type ToElement<Component> = Omit<Component, ExcludedProperties>;
|
|
|
211
282
|
* absence of decorator does not change the type). Thus, if we don't mark all
|
|
212
283
|
* properties as optional, TypeScript will force us to provide a value for all
|
|
213
284
|
* methods, and regular properties component may have.
|
|
285
|
+
*
|
|
286
|
+
* @internal
|
|
214
287
|
*/
|
|
215
|
-
export type ToJsx<Component extends {
|
|
216
|
-
|
|
217
|
-
|
|
288
|
+
export type ToJsx<Component extends { el: unknown; }> = HTMLAttributesAlias<Component["el"]>
|
|
289
|
+
& Partial<Omit<Component, ExcludedProperties | keyof HTMLElement | keyof RemapEvents<Component>>>
|
|
290
|
+
& RemapEvents<Component>;
|
|
291
|
+
|
|
218
292
|
/**
|
|
219
293
|
* From event emitters create event listener callbacks
|
|
294
|
+
*
|
|
295
|
+
* @internal
|
|
220
296
|
*/
|
|
221
|
-
type RemapEvents<Component extends {
|
|
222
|
-
|
|
223
|
-
}> = {
|
|
224
|
-
[Key in keyof Component as `on${Key & string}`]?: unknown extends Component[Key] ? never : Component[Key] extends {
|
|
225
|
-
emit: (...rest: never[]) => infer PayloadType;
|
|
226
|
-
} ? (event: PayloadType & {
|
|
297
|
+
export type RemapEvents<Component extends { el: unknown; }> = {
|
|
298
|
+
[Key in keyof Component as `on${Key & string}`]?: unknown extends Component[Key] ? never : Component[Key] extends { emit: (...rest: never[]) => infer PayloadType; } ? (event: PayloadType & {
|
|
227
299
|
currentTarget: Component["el"];
|
|
228
300
|
target: Component["el"];
|
|
229
301
|
}) => void : never;
|
|
230
302
|
};
|
|
303
|
+
|
|
231
304
|
/**
|
|
232
305
|
* This interface will be automatically extended in src/lumina.ts files to add
|
|
233
306
|
* typings for Stencil elements usages in Lumina. You do not need to manually
|
|
234
307
|
* extend this interface.
|
|
235
308
|
*
|
|
236
|
-
* @
|
|
309
|
+
* @internal
|
|
237
310
|
* @example
|
|
238
311
|
* ```ts
|
|
239
312
|
* import type { JSX as CalciteJSX } from "@esri/calcite-components/dist/types/components";
|
|
@@ -247,8 +320,8 @@ type RemapEvents<Component extends {
|
|
|
247
320
|
* }
|
|
248
321
|
* ```
|
|
249
322
|
*/
|
|
250
|
-
export interface ImportStencilElements {
|
|
251
|
-
|
|
323
|
+
export interface ImportStencilElements {}
|
|
324
|
+
|
|
252
325
|
/**
|
|
253
326
|
* Get the type of all events for a given component. Includes native DOM events
|
|
254
327
|
* and custom events.
|
|
@@ -263,132 +336,102 @@ export interface ImportStencilElements {
|
|
|
263
336
|
* // event.currentTarget
|
|
264
337
|
* }
|
|
265
338
|
* ```
|
|
266
|
-
*
|
|
267
|
-
* @remarks
|
|
268
|
-
* This helper is intended to be used on components defined within the same
|
|
269
|
-
* package. For external components, you can use
|
|
270
|
-
* `HTMLArcgisMapElement["arcgisViewClick"]` directly, without need for
|
|
271
|
-
* `ToEvents<>`.
|
|
272
|
-
*
|
|
273
|
-
* @remarks
|
|
274
|
-
* Alternative implementation of this type that is simpler, and potentially
|
|
275
|
-
* more performant, but looses "go to definition" information.
|
|
276
|
-
*
|
|
277
|
-
* ```tsx
|
|
278
|
-
* export type ToEvents<Component extends { el: unknown }> = {
|
|
279
|
-
* [Key in keyof ToJsx<Component> as Key extends `on${infer EventName}`
|
|
280
|
-
* ? Uncapitalize<EventName>
|
|
281
|
-
* : never]-?: ListenerToPayloadType<ToJsx<Component>[Key]>;
|
|
282
|
-
* };
|
|
283
|
-
*
|
|
284
|
-
* type ListenerToPayloadType<Listener> = Listener extends (event: infer EventType) => unknown ? EventType : never;
|
|
285
|
-
* ```
|
|
286
|
-
*
|
|
287
|
-
* TypeScript issues that may fix this:
|
|
288
|
-
* - https://github.com/microsoft/TypeScript/issues/49909
|
|
289
|
-
* - https://github.com/microsoft/TypeScript/issues/50715
|
|
290
339
|
*/
|
|
291
|
-
export type ToEvents<Component> = GlobalEventTypes<MaybeEl<Component>>
|
|
340
|
+
export type ToEvents<Component> = GlobalEventTypes<MaybeEl<Component>>
|
|
341
|
+
& {
|
|
292
342
|
[Key in keyof Component as ListenerToPayloadType<Component[Key]> extends BaseEvent ? Key : never]-?: ListenerToPayloadType<Component[Key]> & {
|
|
293
343
|
currentTarget: MaybeEl<Component>;
|
|
294
344
|
target: MaybeEl<Component>;
|
|
295
345
|
};
|
|
296
346
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
347
|
+
|
|
348
|
+
export type MaybeEl<Component> = Component extends { el: unknown; } ? Component["el"] : Component;
|
|
349
|
+
|
|
300
350
|
export interface TargetedEvent<Target = EventTarget | null, Payload = void> extends BaseEvent {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
351
|
+
/**
|
|
352
|
+
* Returns any custom data event was created with.
|
|
353
|
+
*
|
|
354
|
+
* @see [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
|
|
355
|
+
*/
|
|
356
|
+
readonly detail: Payload;
|
|
357
|
+
/**
|
|
358
|
+
* Returns the object whose event listener's callback is currently being invoked.
|
|
359
|
+
*
|
|
360
|
+
* @see [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
|
|
361
|
+
*/
|
|
362
|
+
readonly currentTarget: Target;
|
|
363
|
+
/**
|
|
364
|
+
* Returns the object to which event is dispatched (its target).
|
|
365
|
+
*
|
|
366
|
+
* @see [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
|
|
367
|
+
*/
|
|
368
|
+
readonly target: Target;
|
|
319
369
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
370
|
+
|
|
371
|
+
/** @internal */
|
|
372
|
+
export interface BaseEvent extends Omit<Event, "currentTarget" | "target"> {
|
|
373
|
+
/**
|
|
374
|
+
* @deprecated Deprecated DOM method. Do not use.
|
|
375
|
+
* @param type
|
|
376
|
+
* @param bubbles
|
|
377
|
+
* @param cancelable
|
|
378
|
+
* @param detail
|
|
379
|
+
*/
|
|
380
|
+
initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: any): void;
|
|
323
381
|
}
|
|
382
|
+
|
|
324
383
|
/**
|
|
325
384
|
* From "GlobalEventHandlersCamelCase" extract event names and their payloads.
|
|
326
385
|
* Not using "HTMLElementEventMap" because that map has all events in lowercase.
|
|
386
|
+
*
|
|
387
|
+
* @internal
|
|
327
388
|
*/
|
|
328
|
-
type GlobalEventTypes<Target = HTMLElement> = {
|
|
389
|
+
export type GlobalEventTypes<Target = HTMLElement> = {
|
|
329
390
|
[Key in keyof GlobalEventHandlersCamelCase<Target> as Key extends `on${infer EventName}` ? Uncapitalize<EventName> : never]-?: Parameters<NonNullable<GlobalEventHandlersCamelCase<Target>[Key]>>[0];
|
|
330
391
|
};
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
} ? PayloadType : Listener extends BaseEvent ? Listener : void;
|
|
392
|
+
|
|
393
|
+
/** @internal */
|
|
394
|
+
export type ListenerToPayloadType<Listener> = unknown extends Listener ? void : Listener extends { emit: (...rest: never[]) => infer PayloadType; } ? PayloadType : Listener extends BaseEvent ? Listener : void;
|
|
395
|
+
|
|
334
396
|
/**
|
|
335
397
|
* Defined Lumina custom elements. This interface is used only for internal
|
|
336
398
|
* type-checking.
|
|
337
399
|
*/
|
|
338
|
-
export interface DeclareElements {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
} ? ToJsx<Components[Key]> : never;
|
|
400
|
+
export interface DeclareElements {}
|
|
401
|
+
|
|
402
|
+
/** @internal */
|
|
403
|
+
export type ReMappedComponents<Components> = {
|
|
404
|
+
[Key in keyof Components]: Components[Key] extends { el: unknown; } ? ToJsx<Components[Key]> : never;
|
|
344
405
|
};
|
|
406
|
+
|
|
345
407
|
/**
|
|
346
408
|
* For common properties, add Lumina's types rather than use Stencil's types
|
|
409
|
+
*
|
|
410
|
+
* @internal
|
|
347
411
|
*/
|
|
348
|
-
type ReMapStencilComponents<Components> = {
|
|
412
|
+
export type ReMapStencilComponents<Components> = {
|
|
349
413
|
[Key in keyof Pick<Components, keyof Components & keyof HTMLElementTagNameMap>]: HTMLAttributes<HTMLElementTagNameMap[Key]> & ReMapStencilComponent<Components[Key]>;
|
|
350
414
|
};
|
|
351
|
-
|
|
415
|
+
|
|
416
|
+
/** @internal */
|
|
417
|
+
export type ReMapStencilComponent<Component> = {
|
|
352
418
|
[Key in keyof Component as FixupStencilEventCasing<Key>]: Component[Key];
|
|
353
419
|
};
|
|
354
|
-
|
|
420
|
+
|
|
355
421
|
/**
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
* They in turn based the typings on Surplus and Inferno:
|
|
360
|
-
* - https://github.com/adamhaile/surplus/blob/master/index.d.ts
|
|
361
|
-
* - https://github.com/infernojs/inferno/blob/master/packages/inferno/src/core/types.ts
|
|
422
|
+
* Uncapitalize the event properties to match the syntax of React 19, Preact and
|
|
423
|
+
* Lumina
|
|
362
424
|
*
|
|
363
|
-
*
|
|
364
|
-
* https://www.typescriptlang.org/docs/handbook/jsx.html
|
|
425
|
+
* @internal
|
|
365
426
|
*/
|
|
366
|
-
export
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
378
|
-
export interface IntrinsicAttributes {
|
|
379
|
-
/**
|
|
380
|
-
* The `key` is a special attribute that can be set on any element.
|
|
381
|
-
*
|
|
382
|
-
* At build-time it is translated into the `keyed()` directive:
|
|
383
|
-
* https://lit.dev/docs/templates/directives/#keyed
|
|
384
|
-
*
|
|
385
|
-
* @remarks
|
|
386
|
-
* Unlike in React or Stencil, any JavaScript value is acceptable as a key
|
|
387
|
-
*/
|
|
388
|
-
key?: unknown;
|
|
389
|
-
}
|
|
390
|
-
export interface IntrinsicElements extends HTMLElementTags, SvgElementTags, ReMappedComponents<DeclareElements>, ReMapStencilComponents<ImportStencilElements> {
|
|
391
|
-
}
|
|
392
|
-
export type { CustomAttributes, DOMAttributes, HTMLAttributes, HTMLElementTags, SvgElementTags, AriaAttributes };
|
|
393
|
-
}
|
|
394
|
-
export {};
|
|
427
|
+
export type FixupStencilEventCasing<PropertyName extends PropertyKey> = PropertyName extends `on${infer EventName}` ? `on${Uncapitalize<EventName>}` : PropertyName;
|
|
428
|
+
|
|
429
|
+
/** @internal */
|
|
430
|
+
export type _TypeHelper<_ extends [
|
|
431
|
+
CustomAttributesAlias,
|
|
432
|
+
DOMAttributesAlias,
|
|
433
|
+
HTMLAttributesAlias,
|
|
434
|
+
HTMLElementTagsAlias,
|
|
435
|
+
SvgElementTagsAlias,
|
|
436
|
+
AriaAttributesAlias
|
|
437
|
+
]> = void;
|
package/dist/jsx/utils.d.ts
CHANGED
|
@@ -6,32 +6,37 @@
|
|
|
6
6
|
* value (which is interpreted by HTML as "true"). To tell Lit that you don't
|
|
7
7
|
* want the attribute to be present, use the `nothing` value.
|
|
8
8
|
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* <a href={this.href ?? nothing}>{this.label}</a>
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
9
|
* This is not a concern for properties as they are passed as is without
|
|
16
10
|
* serialization. For this reason, during _JSX to lit-html_ conversion, most JSX
|
|
17
11
|
* props are converted properties, except for the few cases when an attribute
|
|
18
12
|
* has no equivalent property.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <a href={this.href ?? nothing}>{this.label}</a>
|
|
17
|
+
* ```
|
|
19
18
|
*/
|
|
20
|
-
export
|
|
19
|
+
export const nothing: never;
|
|
20
|
+
|
|
21
21
|
/**
|
|
22
22
|
* A sentinel value that signals that a value was handled by a directive and
|
|
23
23
|
* should not be written to the DOM.
|
|
24
24
|
*
|
|
25
|
-
* @remarks
|
|
26
25
|
* This is equivalent to Lit's native "noChange", but has type "never" to allow
|
|
27
26
|
* it be set as a value for any JSX attribute.
|
|
28
27
|
*/
|
|
29
|
-
export
|
|
28
|
+
export const noChange: never;
|
|
29
|
+
|
|
30
30
|
/**
|
|
31
31
|
* Like native element.setAttribute(), but instead of stringifying nullish
|
|
32
32
|
* values, will call element.removeAttribute()
|
|
33
|
+
*
|
|
34
|
+
* @param element
|
|
35
|
+
* @param attributeName
|
|
36
|
+
* @param value
|
|
33
37
|
*/
|
|
34
|
-
export
|
|
38
|
+
export function setAttribute(element: Element, attributeName: string, value: unknown): void;
|
|
39
|
+
|
|
35
40
|
/**
|
|
36
41
|
* If you have a property that can be both of string or boolean type, there is
|
|
37
42
|
* no automatic boolean conversion in place - that means the attribute is
|
|
@@ -44,13 +49,13 @@ export declare function setAttribute(element: Element, attributeName: string, va
|
|
|
44
49
|
* be either `null` or `""`). This matches the behavior in Stencil.
|
|
45
50
|
*
|
|
46
51
|
* ```tsx
|
|
47
|
-
*
|
|
52
|
+
*
|
|
53
|
+
* @property({
|
|
54
|
+
* reflects:true, converter: stringOrBoolean }) icon: string | boolean;
|
|
48
55
|
* // ...
|
|
49
56
|
* this.icon = false; // attribute is removed
|
|
50
57
|
* this.icon = true; // attribute is ""
|
|
51
58
|
* this.icon = "name"; // attribute is "name"
|
|
52
59
|
* ```
|
|
53
60
|
*/
|
|
54
|
-
export
|
|
55
|
-
toAttribute: (value: unknown) => string | null;
|
|
56
|
-
};
|
|
61
|
+
export const stringOrBoolean: { toAttribute: (value: string) => string | null; };
|