@arcgis/lumina 5.2.0-next.4 → 5.2.0-next.41
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 +6 -8
- 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 +45 -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 +215 -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,120 @@
|
|
|
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
|
|
74
|
+
HTMLElementTags,
|
|
75
|
+
SvgElementTags,
|
|
76
|
+
ReMappedComponents<DeclareElements>,
|
|
77
|
+
ReMapStencilComponents<ImportStencilElements> {}
|
|
78
|
+
|
|
79
|
+
/** @deprecated import type { CustomAttributes } from "@arcgis/lumina/jsx/baseTypes"; instead */
|
|
80
|
+
export interface CustomAttributes<T = HTMLElement> extends CustomAttributesAlias<T> {}
|
|
81
|
+
/** @deprecated import type { DOMAttributes } from "@arcgis/lumina/jsx/generatedTypes"; instead */
|
|
82
|
+
export interface DOMAttributes<T = HTMLElement> extends DOMAttributesAlias<T> {}
|
|
83
|
+
/** @deprecated import type { HTMLAttributes } from "@arcgis/lumina/jsx/generatedTypes"; instead */
|
|
84
|
+
export interface HTMLAttributes<T = HTMLElement> extends HTMLAttributesAlias<T> {}
|
|
85
|
+
/** @deprecated import type { HTMLElementTags } from "@arcgis/lumina/jsx/generatedTypes"; instead */
|
|
86
|
+
export interface HTMLElementTags extends HTMLElementTagsAlias {}
|
|
87
|
+
/** @deprecated import type { SvgElementTags } from "@arcgis/lumina/jsx/generatedTypes"; instead */
|
|
88
|
+
export interface SvgElementTags extends SvgElementTagsAlias {}
|
|
89
|
+
/** @deprecated import type { AriaAttributes } from "@arcgis/lumina/jsx/generatedTypes"; instead */
|
|
90
|
+
export interface AriaAttributes extends AriaAttributesAlias {}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The references to this function are removed at build time. */
|
|
94
|
+
export const Fragment: (props: { children?: JsxNode; }) => TemplateResult;
|
|
95
|
+
|
|
19
96
|
/**
|
|
20
|
-
* @private
|
|
21
97
|
* The references to this function are removed at build time. You do not need
|
|
22
98
|
* to import it directly
|
|
99
|
+
*
|
|
100
|
+
* @param type
|
|
101
|
+
* @param props
|
|
102
|
+
* @param key
|
|
103
|
+
* @internal
|
|
23
104
|
*/
|
|
24
|
-
export
|
|
105
|
+
export function jsx(type: string, props: unknown, key?: unknown): JsxNode;
|
|
106
|
+
|
|
25
107
|
/**
|
|
26
|
-
* @private
|
|
27
108
|
* The references to this function are removed at build time. You do not need
|
|
28
109
|
* to import it directly
|
|
110
|
+
*
|
|
111
|
+
* @param type
|
|
112
|
+
* @param props
|
|
113
|
+
* @param key
|
|
114
|
+
* @internal
|
|
29
115
|
*/
|
|
30
|
-
export
|
|
116
|
+
export function jsxs(type: string, props: unknown, key?: unknown): JsxNode;
|
|
117
|
+
|
|
31
118
|
/**
|
|
32
119
|
* The JSX to lit-html conversion has a heuristic to determine whether a prop
|
|
33
120
|
* should be converted to a property or attribute at runtime. In cases where
|
|
@@ -38,6 +125,10 @@ export declare function jsxs(type: string, props: unknown, key?: unknown): JsxNo
|
|
|
38
125
|
* impact. But that also means you should not call this function anywhere other
|
|
39
126
|
* than at the top level of a JSX prop value
|
|
40
127
|
*
|
|
128
|
+
* If you often encounter cases where the JSX to lit-html incorrectly converts
|
|
129
|
+
* the prop to a property necessitating the use of `bindAttribute()`, please open
|
|
130
|
+
* an issue for Lumina.
|
|
131
|
+
*
|
|
41
132
|
* @example
|
|
42
133
|
* ```tsx
|
|
43
134
|
* <my-component
|
|
@@ -49,13 +140,9 @@ export declare function jsxs(type: string, props: unknown, key?: unknown): JsxNo
|
|
|
49
140
|
* ```ts
|
|
50
141
|
* html`<my-component name="Pass name as attribute rather than property"></my-component>`
|
|
51
142
|
* ```
|
|
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
143
|
*/
|
|
58
|
-
export
|
|
144
|
+
export const bindAttribute: <T>(value: T) => T;
|
|
145
|
+
|
|
59
146
|
/**
|
|
60
147
|
* The JSX to lit-html conversion has a heuristic to determine whether a prop
|
|
61
148
|
* should be converted to a property, attribute or boolean attribute at runtime.
|
|
@@ -67,8 +154,11 @@ export declare const bindAttribute: <T>(value: T) => T;
|
|
|
67
154
|
* impact. But that also means you should not call this function anywhere other
|
|
68
155
|
* than at the top level of a JSX prop value
|
|
69
156
|
*
|
|
70
|
-
*
|
|
157
|
+
* If you often encounter cases where the JSX to lit-html incorrectly converts
|
|
158
|
+
* the prop necessitating the use of `bindBooleanAttribute()`, please open
|
|
159
|
+
* an issue for Lumina.
|
|
71
160
|
*
|
|
161
|
+
* @see https://lit.dev/docs/templates/expressions/#boolean-attribute-expressions
|
|
72
162
|
* @example
|
|
73
163
|
* ```tsx
|
|
74
164
|
* <my-component
|
|
@@ -80,13 +170,9 @@ export declare const bindAttribute: <T>(value: T) => T;
|
|
|
80
170
|
* ```ts
|
|
81
171
|
* html`<my-component ?checked=${myBoolean}></my-component>`
|
|
82
172
|
* ```
|
|
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
173
|
*/
|
|
89
|
-
export
|
|
174
|
+
export const bindBooleanAttribute: <T>(value: T) => T;
|
|
175
|
+
|
|
90
176
|
/**
|
|
91
177
|
* The JSX to lit-html conversion has a heuristic to determine whether a prop
|
|
92
178
|
* should be converted to a property or attribute at runtime. In cases where
|
|
@@ -97,6 +183,10 @@ export declare const bindBooleanAttribute: <T>(value: T) => T;
|
|
|
97
183
|
* impact. But that also means you should not call this function anywhere other
|
|
98
184
|
* than at the top level of a JSX prop value
|
|
99
185
|
*
|
|
186
|
+
* If you often encounter cases where the JSX to lit-html incorrectly converts
|
|
187
|
+
* the prop to an attribute necessitating the use of `bindProperty()`, please open
|
|
188
|
+
* an issue for Lumina.
|
|
189
|
+
*
|
|
100
190
|
* @example
|
|
101
191
|
* ```tsx
|
|
102
192
|
* <my-component
|
|
@@ -108,17 +198,9 @@ export declare const bindBooleanAttribute: <T>(value: T) => T;
|
|
|
108
198
|
* ```ts
|
|
109
199
|
* html`<my-component .my-prop="Pass my-prop as a property rather than attribute"></my-component>`
|
|
110
200
|
* ```
|
|
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
201
|
*/
|
|
121
|
-
export
|
|
202
|
+
export const bindProperty: <T>(value: T) => T;
|
|
203
|
+
|
|
122
204
|
/**
|
|
123
205
|
* The `bindEvent()` function lets you customize the event binding behavior by
|
|
124
206
|
* providing options like passive, capture, once and other options that you
|
|
@@ -127,6 +209,10 @@ export declare const bindProperty: <T>(value: T) => T;
|
|
|
127
209
|
* This function call will be erased at build-time, thus it has no runtime
|
|
128
210
|
* impact.
|
|
129
211
|
*
|
|
212
|
+
* This function is a _JSX to lit-html_ adaptation of the Lit's event listener
|
|
213
|
+
* customization syntax.
|
|
214
|
+
* See https://lit.dev/docs/components/events/#event-options-decorator
|
|
215
|
+
*
|
|
130
216
|
* @example
|
|
131
217
|
* ```tsx
|
|
132
218
|
* <my-component
|
|
@@ -137,23 +223,13 @@ export declare const bindProperty: <T>(value: T) => T;
|
|
|
137
223
|
* ```ts
|
|
138
224
|
* html`<my-component onScroll=${{ handleEvent: console.log, passive:true }}></my-component>`
|
|
139
225
|
* ```
|
|
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
226
|
*/
|
|
151
|
-
export
|
|
152
|
-
|
|
153
|
-
})) => T;
|
|
227
|
+
export const bindEvent: <T>(descriptor: T | (AddEventListenerOptions & { handleEvent: T; })) => T;
|
|
228
|
+
|
|
154
229
|
export type JsxNode = DirectiveResult<any> | JsxNodeArray | Node | TemplateResult | boolean | number | (NonNullable<unknown> & string) | null | undefined;
|
|
155
|
-
|
|
156
|
-
}
|
|
230
|
+
|
|
231
|
+
export interface JsxNodeArray extends Array<JsxNode> {}
|
|
232
|
+
|
|
157
233
|
/**
|
|
158
234
|
* By not requiring to have some sort of typings generation watcher to run
|
|
159
235
|
* in the background and generate types for the components based on the
|
|
@@ -174,11 +250,10 @@ interface JsxNodeArray extends Array<JsxNode> {
|
|
|
174
250
|
* information and can generate the typings that expose only the actual
|
|
175
251
|
* properties component declared.
|
|
176
252
|
*
|
|
177
|
-
* @
|
|
178
|
-
* Do not exclude "manager" and "componentOnReady" since these properties are
|
|
179
|
-
* available both on lazy and non-lazy instance.
|
|
253
|
+
* @internal
|
|
180
254
|
*/
|
|
181
|
-
type ExcludedProperties = "addController" | "attributeChangedCallback" | "connectedCallback" | "disconnectedCallback" | "el" | "elementInternals" | "hasUpdated" | "isUpdatePending" | "listen" | "load" | "loaded" | "removeController" | "render" | "renderOptions" | "renderRoot" | "requestUpdate" | "updateComplete" | "updated" | "willUpdate";
|
|
255
|
+
export type ExcludedProperties = "addController" | "attributeChangedCallback" | "connectedCallback" | "disconnectedCallback" | "el" | "elementInternals" | "hasUpdated" | "isUpdatePending" | "listen" | "load" | "loaded" | "removeController" | "render" | "renderOptions" | "renderRoot" | "requestUpdate" | "updateComplete" | "updated" | "willUpdate";
|
|
256
|
+
|
|
182
257
|
/**
|
|
183
258
|
* this.el property on a component only has the public properties of the
|
|
184
259
|
* component. All internal methods, properties, as well as LitElement methods
|
|
@@ -189,12 +264,9 @@ type ExcludedProperties = "addController" | "attributeChangedCallback" | "connec
|
|
|
189
264
|
* Usually, you don't need to use this type directly. If you have an
|
|
190
265
|
* `ArcgisCounter` element, you can get its el type by using
|
|
191
266
|
* `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
267
|
*/
|
|
197
268
|
export type ToElement<Component> = Omit<Component, ExcludedProperties>;
|
|
269
|
+
|
|
198
270
|
/**
|
|
199
271
|
* Utility type for getting the JSX prop types for a given component. In particular:
|
|
200
272
|
*
|
|
@@ -211,29 +283,31 @@ export type ToElement<Component> = Omit<Component, ExcludedProperties>;
|
|
|
211
283
|
* absence of decorator does not change the type). Thus, if we don't mark all
|
|
212
284
|
* properties as optional, TypeScript will force us to provide a value for all
|
|
213
285
|
* methods, and regular properties component may have.
|
|
286
|
+
*
|
|
287
|
+
* @internal
|
|
214
288
|
*/
|
|
215
|
-
export type ToJsx<Component extends {
|
|
216
|
-
|
|
217
|
-
|
|
289
|
+
export type ToJsx<Component extends { el: unknown; }> = HTMLAttributesAlias<Component["el"]>
|
|
290
|
+
& Partial<Omit<Component, ExcludedProperties | keyof HTMLElement | keyof RemapEvents<Component>>>
|
|
291
|
+
& RemapEvents<Component>;
|
|
292
|
+
|
|
218
293
|
/**
|
|
219
294
|
* From event emitters create event listener callbacks
|
|
295
|
+
*
|
|
296
|
+
* @internal
|
|
220
297
|
*/
|
|
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 & {
|
|
298
|
+
export type RemapEvents<Component extends { el: unknown; }> = {
|
|
299
|
+
[Key in keyof Component as `on${Key & string}`]?: unknown extends Component[Key] ? never : Component[Key] extends { emit: (...rest: never[]) => infer PayloadType; } ? (event: PayloadType & {
|
|
227
300
|
currentTarget: Component["el"];
|
|
228
301
|
target: Component["el"];
|
|
229
302
|
}) => void : never;
|
|
230
303
|
};
|
|
304
|
+
|
|
231
305
|
/**
|
|
232
306
|
* This interface will be automatically extended in src/lumina.ts files to add
|
|
233
307
|
* typings for Stencil elements usages in Lumina. You do not need to manually
|
|
234
308
|
* extend this interface.
|
|
235
309
|
*
|
|
236
|
-
* @
|
|
310
|
+
* @internal
|
|
237
311
|
* @example
|
|
238
312
|
* ```ts
|
|
239
313
|
* import type { JSX as CalciteJSX } from "@esri/calcite-components/dist/types/components";
|
|
@@ -247,8 +321,8 @@ type RemapEvents<Component extends {
|
|
|
247
321
|
* }
|
|
248
322
|
* ```
|
|
249
323
|
*/
|
|
250
|
-
export interface ImportStencilElements {
|
|
251
|
-
|
|
324
|
+
export interface ImportStencilElements {}
|
|
325
|
+
|
|
252
326
|
/**
|
|
253
327
|
* Get the type of all events for a given component. Includes native DOM events
|
|
254
328
|
* and custom events.
|
|
@@ -263,132 +337,102 @@ export interface ImportStencilElements {
|
|
|
263
337
|
* // event.currentTarget
|
|
264
338
|
* }
|
|
265
339
|
* ```
|
|
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
340
|
*/
|
|
291
|
-
export type ToEvents<Component> = GlobalEventTypes<MaybeEl<Component>>
|
|
341
|
+
export type ToEvents<Component> = GlobalEventTypes<MaybeEl<Component>>
|
|
342
|
+
& {
|
|
292
343
|
[Key in keyof Component as ListenerToPayloadType<Component[Key]> extends BaseEvent ? Key : never]-?: ListenerToPayloadType<Component[Key]> & {
|
|
293
344
|
currentTarget: MaybeEl<Component>;
|
|
294
345
|
target: MaybeEl<Component>;
|
|
295
346
|
};
|
|
296
347
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
348
|
+
|
|
349
|
+
export type MaybeEl<Component> = Component extends { el: unknown; } ? Component["el"] : Component;
|
|
350
|
+
|
|
300
351
|
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
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Returns any custom data event was created with.
|
|
354
|
+
*
|
|
355
|
+
* @see [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
|
|
356
|
+
*/
|
|
357
|
+
readonly detail: Payload;
|
|
358
|
+
/**
|
|
359
|
+
* Returns the object whose event listener's callback is currently being invoked.
|
|
360
|
+
*
|
|
361
|
+
* @see [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
|
|
362
|
+
*/
|
|
363
|
+
readonly currentTarget: Target;
|
|
364
|
+
/**
|
|
365
|
+
* Returns the object to which event is dispatched (its target).
|
|
366
|
+
*
|
|
367
|
+
* @see [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
|
|
368
|
+
*/
|
|
369
|
+
readonly target: Target;
|
|
319
370
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
371
|
+
|
|
372
|
+
/** @internal */
|
|
373
|
+
export interface BaseEvent extends Omit<Event, "currentTarget" | "target"> {
|
|
374
|
+
/**
|
|
375
|
+
* @deprecated Deprecated DOM method. Do not use.
|
|
376
|
+
* @param type
|
|
377
|
+
* @param bubbles
|
|
378
|
+
* @param cancelable
|
|
379
|
+
* @param detail
|
|
380
|
+
*/
|
|
381
|
+
initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: any): void;
|
|
323
382
|
}
|
|
383
|
+
|
|
324
384
|
/**
|
|
325
385
|
* From "GlobalEventHandlersCamelCase" extract event names and their payloads.
|
|
326
386
|
* Not using "HTMLElementEventMap" because that map has all events in lowercase.
|
|
387
|
+
*
|
|
388
|
+
* @internal
|
|
327
389
|
*/
|
|
328
|
-
type GlobalEventTypes<Target = HTMLElement> = {
|
|
390
|
+
export type GlobalEventTypes<Target = HTMLElement> = {
|
|
329
391
|
[Key in keyof GlobalEventHandlersCamelCase<Target> as Key extends `on${infer EventName}` ? Uncapitalize<EventName> : never]-?: Parameters<NonNullable<GlobalEventHandlersCamelCase<Target>[Key]>>[0];
|
|
330
392
|
};
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
} ? PayloadType : Listener extends BaseEvent ? Listener : void;
|
|
393
|
+
|
|
394
|
+
/** @internal */
|
|
395
|
+
export type ListenerToPayloadType<Listener> = unknown extends Listener ? void : Listener extends { emit: (...rest: never[]) => infer PayloadType; } ? PayloadType : Listener extends BaseEvent ? Listener : void;
|
|
396
|
+
|
|
334
397
|
/**
|
|
335
398
|
* Defined Lumina custom elements. This interface is used only for internal
|
|
336
399
|
* type-checking.
|
|
337
400
|
*/
|
|
338
|
-
export interface DeclareElements {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
} ? ToJsx<Components[Key]> : never;
|
|
401
|
+
export interface DeclareElements {}
|
|
402
|
+
|
|
403
|
+
/** @internal */
|
|
404
|
+
export type ReMappedComponents<Components> = {
|
|
405
|
+
[Key in keyof Components]: Components[Key] extends { el: unknown; } ? ToJsx<Components[Key]> : never;
|
|
344
406
|
};
|
|
407
|
+
|
|
345
408
|
/**
|
|
346
409
|
* For common properties, add Lumina's types rather than use Stencil's types
|
|
410
|
+
*
|
|
411
|
+
* @internal
|
|
347
412
|
*/
|
|
348
|
-
type ReMapStencilComponents<Components> = {
|
|
413
|
+
export type ReMapStencilComponents<Components> = {
|
|
349
414
|
[Key in keyof Pick<Components, keyof Components & keyof HTMLElementTagNameMap>]: HTMLAttributes<HTMLElementTagNameMap[Key]> & ReMapStencilComponent<Components[Key]>;
|
|
350
415
|
};
|
|
351
|
-
|
|
416
|
+
|
|
417
|
+
/** @internal */
|
|
418
|
+
export type ReMapStencilComponent<Component> = {
|
|
352
419
|
[Key in keyof Component as FixupStencilEventCasing<Key>]: Component[Key];
|
|
353
420
|
};
|
|
354
|
-
|
|
421
|
+
|
|
355
422
|
/**
|
|
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
|
|
423
|
+
* Uncapitalize the event properties to match the syntax of React 19, Preact and
|
|
424
|
+
* Lumina
|
|
362
425
|
*
|
|
363
|
-
*
|
|
364
|
-
* https://www.typescriptlang.org/docs/handbook/jsx.html
|
|
426
|
+
* @internal
|
|
365
427
|
*/
|
|
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 {};
|
|
428
|
+
export type FixupStencilEventCasing<PropertyName extends PropertyKey> = PropertyName extends `on${infer EventName}` ? `on${Uncapitalize<EventName>}` : PropertyName;
|
|
429
|
+
|
|
430
|
+
/** @internal */
|
|
431
|
+
export type _TypeHelper<_ extends [
|
|
432
|
+
CustomAttributesAlias,
|
|
433
|
+
DOMAttributesAlias,
|
|
434
|
+
HTMLAttributesAlias,
|
|
435
|
+
HTMLElementTagsAlias,
|
|
436
|
+
SvgElementTagsAlias,
|
|
437
|
+
AriaAttributesAlias
|
|
438
|
+
]> = 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; };
|