element-vir 25.10.0 → 25.12.0
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/README.md +52 -44
- package/dist/declarative-element/define-element-no-inputs.d.ts +2 -15
- package/dist/declarative-element/define-element-no-inputs.js +2 -15
- package/dist/declarative-element/define-element.d.ts +2 -3
- package/dist/declarative-element/define-element.js +4 -3
- package/dist/declarative-element/directives/listen.directive.d.ts +4 -4
- package/dist/declarative-element/directives/on-dom-created.directive.d.ts +2 -2
- package/dist/declarative-element/directives/on-dom-created.directive.js +2 -2
- package/dist/declarative-element/directives/on-dom-rendered.directive.d.ts +2 -2
- package/dist/declarative-element/directives/on-dom-rendered.directive.js +2 -2
- package/dist/declarative-element/directives/on-intersect.directive.d.ts +2 -2
- package/dist/declarative-element/directives/on-intersect.directive.js +2 -2
- package/dist/declarative-element/directives/on-resize.directive.d.ts +2 -2
- package/dist/declarative-element/directives/on-resize.directive.js +2 -2
- package/dist/declarative-element/directives/render-if.directive.d.ts +2 -2
- package/dist/declarative-element/directives/render-if.directive.js +2 -2
- package/dist/declarative-element/directives/test-id.directive.d.ts +2 -2
- package/dist/declarative-element/directives/test-id.directive.js +2 -2
- package/dist/declarative-element/properties/element-events.d.ts +2 -2
- package/dist/declarative-element/properties/element-events.js +2 -2
- package/dist/declarative-element/wrap-define-element.d.ts +6 -3
- package/dist/declarative-element/wrap-define-element.js +9 -4
- package/dist/readme-examples/my-app.element.d.ts +1 -1
- package/dist/readme-examples/my-app.element.js +3 -2
- package/dist/readme-examples/my-custom-define.d.ts +3 -3
- package/dist/readme-examples/my-custom-define.js +3 -3
- package/dist/readme-examples/my-simple.element.d.ts +1 -1
- package/dist/readme-examples/my-simple.element.js +3 -2
- package/dist/readme-examples/my-with-assignment.element.d.ts +1 -1
- package/dist/readme-examples/my-with-assignment.element.js +3 -2
- package/dist/readme-examples/my-with-cleanup-callback.element.d.ts +1 -1
- package/dist/readme-examples/my-with-cleanup-callback.element.js +3 -2
- package/dist/readme-examples/my-with-css-vars.element.d.ts +1 -1
- package/dist/readme-examples/my-with-css-vars.element.js +3 -2
- package/dist/readme-examples/my-with-custom-events.element.d.ts +1 -1
- package/dist/readme-examples/my-with-custom-events.element.js +3 -2
- package/dist/readme-examples/my-with-event-listening.element.d.ts +1 -1
- package/dist/readme-examples/my-with-event-listening.element.js +3 -2
- package/dist/readme-examples/my-with-events.element.d.ts +3 -3
- package/dist/readme-examples/my-with-events.element.js +3 -2
- package/dist/readme-examples/my-with-host-class-definition.element.d.ts +1 -1
- package/dist/readme-examples/my-with-host-class-definition.element.js +3 -2
- package/dist/readme-examples/my-with-host-class-usage.element.d.ts +1 -1
- package/dist/readme-examples/my-with-host-class-usage.element.js +3 -2
- package/dist/readme-examples/my-with-on-dom-created.element.d.ts +1 -1
- package/dist/readme-examples/my-with-on-dom-created.element.js +3 -2
- package/dist/readme-examples/my-with-on-resize.element.d.ts +1 -1
- package/dist/readme-examples/my-with-on-resize.element.js +3 -2
- package/dist/readme-examples/my-with-styles-and-interpolated-selector.element.d.ts +1 -1
- package/dist/readme-examples/my-with-styles-and-interpolated-selector.element.js +3 -2
- package/dist/readme-examples/my-with-styles.element.d.ts +1 -1
- package/dist/readme-examples/my-with-styles.element.js +3 -2
- package/dist/readme-examples/my-with-update-state.element.d.ts +1 -1
- package/dist/readme-examples/my-with-update-state.element.js +3 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -30,20 +30,21 @@ Make sure to install this as a normal dependency (not just a dev dependency) bec
|
|
|
30
30
|
|
|
31
31
|
# Usage
|
|
32
32
|
|
|
33
|
-
Most usage of this package is done through the `defineElement`
|
|
33
|
+
Most usage of this package is done through the `defineElement` functions. See the [`DeclarativeElementInit`](https://github.com/electrovir/element-vir/blob/dev/packages/src/declarative-element/declarative-element-init.ts) type for that function's full inputs. The inputs are also described below with examples.
|
|
34
34
|
|
|
35
35
|
All of [`lit`](https://lit.dev)'s syntax and functionality is available for use if you wish.
|
|
36
36
|
|
|
37
37
|
## Simple element definition
|
|
38
38
|
|
|
39
|
-
Use `
|
|
39
|
+
Use `defineElement` to define your element. Here is a bare-minimum example custom element:
|
|
40
40
|
|
|
41
41
|
<!-- example-link: src/readme-examples/my-simple.element.ts -->
|
|
42
42
|
|
|
43
43
|
```TypeScript
|
|
44
|
-
import {
|
|
44
|
+
import {defineElement} from 'element-vir';
|
|
45
|
+
import {html} from 'element-vir';
|
|
45
46
|
|
|
46
|
-
export const MySimple =
|
|
47
|
+
export const MySimple = defineElement()({
|
|
47
48
|
tagName: 'my-simple',
|
|
48
49
|
render() {
|
|
49
50
|
return html`
|
|
@@ -62,10 +63,11 @@ To use already defined elements (like the example above), they must be interpola
|
|
|
62
63
|
<!-- example-link: src/readme-examples/my-app.element.ts -->
|
|
63
64
|
|
|
64
65
|
```TypeScript
|
|
65
|
-
import {
|
|
66
|
+
import {defineElement} from 'element-vir';
|
|
67
|
+
import {html} from 'element-vir';
|
|
66
68
|
import {MySimple} from './my-simple.element.js';
|
|
67
69
|
|
|
68
|
-
export const MyApp =
|
|
70
|
+
export const MyApp = defineElement()({
|
|
69
71
|
tagName: 'my-app',
|
|
70
72
|
render() {
|
|
71
73
|
return html`
|
|
@@ -85,9 +87,10 @@ Styles are added through the `styles` property when defining a declarative eleme
|
|
|
85
87
|
<!-- example-link: src/readme-examples/my-with-styles.element.ts -->
|
|
86
88
|
|
|
87
89
|
```TypeScript
|
|
88
|
-
import {
|
|
90
|
+
import {defineElement} from 'element-vir';
|
|
91
|
+
import {css, html} from 'element-vir';
|
|
89
92
|
|
|
90
|
-
export const MyWithStyles =
|
|
93
|
+
export const MyWithStyles = defineElement()({
|
|
91
94
|
tagName: 'my-with-styles',
|
|
92
95
|
styles: css`
|
|
93
96
|
:host {
|
|
@@ -116,10 +119,11 @@ Declarative element definitions can be used in the `css` tagged template just li
|
|
|
116
119
|
<!-- example-link: src/readme-examples/my-with-styles-and-interpolated-selector.element.ts -->
|
|
117
120
|
|
|
118
121
|
```TypeScript
|
|
119
|
-
import {
|
|
122
|
+
import {defineElement} from 'element-vir';
|
|
123
|
+
import {css, html} from 'element-vir';
|
|
120
124
|
import {MySimple} from './my-simple.element.js';
|
|
121
125
|
|
|
122
|
-
export const MyWithStylesAndInterpolatedSelector =
|
|
126
|
+
export const MyWithStylesAndInterpolatedSelector = defineElement()({
|
|
123
127
|
tagName: 'my-with-styles-and-interpolated-selector',
|
|
124
128
|
styles: css`
|
|
125
129
|
${MySimple} {
|
|
@@ -136,7 +140,7 @@ export const MyWithStylesAndInterpolatedSelector = defineElementNoInputs({
|
|
|
136
140
|
|
|
137
141
|
## Defining and using Inputs
|
|
138
142
|
|
|
139
|
-
Define element inputs by using `defineElement` to define a declarative element. Pass your input type as a generic to the `defineElement` call. Then call _that_ with the normal definition input
|
|
143
|
+
Define element inputs by using `defineElement` to define a declarative element. Pass your input type, if any, as a generic to the `defineElement` call. Then call _that_ with the normal definition input.
|
|
140
144
|
|
|
141
145
|
To use an element's inputs for use in its template, grab `inputs` from `render`'s parameters and interpolate it into your HTML template:
|
|
142
146
|
|
|
@@ -165,9 +169,10 @@ Define initial internal state values and types with the `stateInit` property whe
|
|
|
165
169
|
<!-- example-link: src/readme-examples/my-with-update-state.element.ts -->
|
|
166
170
|
|
|
167
171
|
```TypeScript
|
|
168
|
-
import {
|
|
172
|
+
import {defineElement} from 'element-vir';
|
|
173
|
+
import {html, listen} from 'element-vir';
|
|
169
174
|
|
|
170
|
-
export const MyWithUpdateState =
|
|
175
|
+
export const MyWithUpdateState = defineElement()({
|
|
171
176
|
tagName: 'my-with-update-state',
|
|
172
177
|
state() {
|
|
173
178
|
return {
|
|
@@ -200,10 +205,11 @@ Use the `assign` directive to assign values to child custom elements inputs:
|
|
|
200
205
|
<!-- example-link: src/readme-examples/my-with-assignment.element.ts -->
|
|
201
206
|
|
|
202
207
|
```TypeScript
|
|
203
|
-
import {
|
|
208
|
+
import {defineElement} from 'element-vir';
|
|
209
|
+
import {html} from 'element-vir';
|
|
204
210
|
import {MyWithInputs} from './my-with-inputs.element.js';
|
|
205
211
|
|
|
206
|
-
export const MyWithAssignment =
|
|
212
|
+
export const MyWithAssignment = defineElement()({
|
|
207
213
|
tagName: 'my-with-assignment',
|
|
208
214
|
render() {
|
|
209
215
|
return html`
|
|
@@ -227,9 +233,10 @@ There are two other callbacks you can define that are sort of similar to lifecyc
|
|
|
227
233
|
<!-- example-link: src/readme-examples/my-with-cleanup-callback.element.ts -->
|
|
228
234
|
|
|
229
235
|
```TypeScript
|
|
230
|
-
import {
|
|
236
|
+
import {defineElement} from 'element-vir';
|
|
237
|
+
import {html} from 'element-vir';
|
|
231
238
|
|
|
232
|
-
export const MyWithAssignmentCleanupCallback =
|
|
239
|
+
export const MyWithAssignmentCleanupCallback = defineElement()({
|
|
233
240
|
tagName: 'my-with-cleanup-callback',
|
|
234
241
|
state() {
|
|
235
242
|
return {
|
|
@@ -257,9 +264,10 @@ To dispatch an event, grab `dispatch` and `events` from `render`'s parameters.
|
|
|
257
264
|
|
|
258
265
|
```TypeScript
|
|
259
266
|
import {randomInteger} from '@augment-vir/common';
|
|
260
|
-
import {
|
|
267
|
+
import {defineElement} from 'element-vir';
|
|
268
|
+
import {defineElementEvent, html, listen} from 'element-vir';
|
|
261
269
|
|
|
262
|
-
export const MyWithEvents =
|
|
270
|
+
export const MyWithEvents = defineElement()({
|
|
263
271
|
tagName: 'my-with-events',
|
|
264
272
|
events: {
|
|
265
273
|
logoutClick: defineElementEvent<void>(),
|
|
@@ -287,10 +295,11 @@ Use the `listen` directive to listen to events emitted by your custom elements:
|
|
|
287
295
|
<!-- example-link: src/readme-examples/my-with-event-listening.element.ts -->
|
|
288
296
|
|
|
289
297
|
```TypeScript
|
|
290
|
-
import {
|
|
298
|
+
import {defineElement} from 'element-vir';
|
|
299
|
+
import {html, listen} from 'element-vir';
|
|
291
300
|
import {MyWithEvents} from './my-with-events.element.js';
|
|
292
301
|
|
|
293
|
-
export const MyWithEventListening =
|
|
302
|
+
export const MyWithEventListening = defineElement()({
|
|
294
303
|
tagName: 'my-with-event-listening',
|
|
295
304
|
state() {
|
|
296
305
|
return {
|
|
@@ -336,10 +345,11 @@ Dispatching a custom event and listening to a custom event is the same as doing
|
|
|
336
345
|
|
|
337
346
|
```TypeScript
|
|
338
347
|
import {randomInteger} from '@augment-vir/common';
|
|
339
|
-
import {
|
|
348
|
+
import {defineElement} from 'element-vir';
|
|
349
|
+
import {html, listen} from 'element-vir';
|
|
340
350
|
import {MyCustomActionEvent} from './my-custom-action.event.js';
|
|
341
351
|
|
|
342
|
-
export const MyWithCustomEvents =
|
|
352
|
+
export const MyWithCustomEvents = defineElement()({
|
|
343
353
|
tagName: 'my-with-custom-events',
|
|
344
354
|
render({dispatch}) {
|
|
345
355
|
return html`
|
|
@@ -375,9 +385,10 @@ Apply host classes in the element's stylesheet by using a callback for the style
|
|
|
375
385
|
<!-- example-link: src/readme-examples/my-with-host-class-definition.element.ts -->
|
|
376
386
|
|
|
377
387
|
```TypeScript
|
|
378
|
-
import {
|
|
388
|
+
import {defineElement} from 'element-vir';
|
|
389
|
+
import {css, html} from 'element-vir';
|
|
379
390
|
|
|
380
|
-
export const MyWithHostClassDefinition =
|
|
391
|
+
export const MyWithHostClassDefinition = defineElement()({
|
|
381
392
|
tagName: 'my-with-host-class-definition',
|
|
382
393
|
state() {
|
|
383
394
|
return {
|
|
@@ -426,10 +437,11 @@ To apply a host class in a consumer, access the child element's `.hostClasses` p
|
|
|
426
437
|
<!-- example-link: src/readme-examples/my-with-host-class-usage.element.ts -->
|
|
427
438
|
|
|
428
439
|
```TypeScript
|
|
429
|
-
import {
|
|
440
|
+
import {defineElement} from 'element-vir';
|
|
441
|
+
import {html} from 'element-vir';
|
|
430
442
|
import {MyWithHostClassDefinition} from './my-with-host-class-definition.element.js';
|
|
431
443
|
|
|
432
|
-
export const MyWithHostClassUsage =
|
|
444
|
+
export const MyWithHostClassUsage = defineElement()({
|
|
433
445
|
tagName: 'my-with-host-class-usage',
|
|
434
446
|
render() {
|
|
435
447
|
return html`
|
|
@@ -448,9 +460,10 @@ Typed CSS variables are created in a similar manner to host classes:
|
|
|
448
460
|
<!-- example-link: src/readme-examples/my-with-css-vars.element.ts -->
|
|
449
461
|
|
|
450
462
|
```TypeScript
|
|
451
|
-
import {
|
|
463
|
+
import {defineElement} from 'element-vir';
|
|
464
|
+
import {css, html} from 'element-vir';
|
|
452
465
|
|
|
453
|
-
export const MyWithCssVars =
|
|
466
|
+
export const MyWithCssVars = defineElement()({
|
|
454
467
|
tagName: 'my-with-css-vars',
|
|
455
468
|
cssVars: {
|
|
456
469
|
/** The value assigned here ('blue') becomes the fallback value for this CSS var. */
|
|
@@ -477,7 +490,7 @@ export const MyWithCssVars = defineElementNoInputs({
|
|
|
477
490
|
|
|
478
491
|
## Custom Type Requirements
|
|
479
492
|
|
|
480
|
-
Use `wrapDefineElement` to compose `defineElement
|
|
493
|
+
Use `wrapDefineElement` to compose `defineElement`. This is particularly useful to adding restrictions on the element `tagName`, but it can be used for restricting any of the type parameters:
|
|
481
494
|
|
|
482
495
|
<!-- example-link: src/readme-examples/my-custom-define.ts -->
|
|
483
496
|
|
|
@@ -486,14 +499,10 @@ import {wrapDefineElement} from 'element-vir';
|
|
|
486
499
|
|
|
487
500
|
export type VirTagName = `vir-${string}`;
|
|
488
501
|
|
|
489
|
-
export const {defineElement: defineVirElement
|
|
490
|
-
wrapDefineElement<VirTagName>();
|
|
502
|
+
export const {defineElement: defineVirElement} = wrapDefineElement<VirTagName>();
|
|
491
503
|
|
|
492
504
|
// add an optional assert callback
|
|
493
|
-
export const {
|
|
494
|
-
defineElement: defineVerifiedVirElement,
|
|
495
|
-
defineElementNoInputs: defineVerifiedVirElementNoInputs,
|
|
496
|
-
} = wrapDefineElement<VirTagName>({
|
|
505
|
+
export const {defineElement: defineVerifiedVirElement} = wrapDefineElement<VirTagName>({
|
|
497
506
|
assertInputs: (inputs) => {
|
|
498
507
|
if (!inputs.tagName.startsWith('vir-')) {
|
|
499
508
|
throw new Error(`all custom elements must start with "vir-"`);
|
|
@@ -502,10 +511,7 @@ export const {
|
|
|
502
511
|
});
|
|
503
512
|
|
|
504
513
|
// add an optional transform callback
|
|
505
|
-
export const {
|
|
506
|
-
defineElement: defineTransformedVirElement,
|
|
507
|
-
defineElementNoInputs: defineTransformedVirElementNoInputs,
|
|
508
|
-
} = wrapDefineElement<VirTagName>({
|
|
514
|
+
export const {defineElement: defineTransformedVirElement} = wrapDefineElement<VirTagName>({
|
|
509
515
|
transformInputs: (inputs) => {
|
|
510
516
|
return {
|
|
511
517
|
...inputs,
|
|
@@ -528,9 +534,10 @@ This triggers only once when the element it's attached to has actually been crea
|
|
|
528
534
|
<!-- example-link: src/readme-examples/my-with-on-dom-created.element.ts -->
|
|
529
535
|
|
|
530
536
|
```TypeScript
|
|
531
|
-
import {
|
|
537
|
+
import {defineElement} from 'element-vir';
|
|
538
|
+
import {html, onDomCreated} from 'element-vir';
|
|
532
539
|
|
|
533
|
-
export const MyWithOnDomCreated =
|
|
540
|
+
export const MyWithOnDomCreated = defineElement()({
|
|
534
541
|
tagName: 'my-with-on-dom-created',
|
|
535
542
|
render() {
|
|
536
543
|
return html`
|
|
@@ -554,9 +561,10 @@ This directive fires its callback whenever the element it's attached to resizes.
|
|
|
554
561
|
<!-- example-link: src/readme-examples/my-with-on-resize.element.ts -->
|
|
555
562
|
|
|
556
563
|
```TypeScript
|
|
557
|
-
import {
|
|
564
|
+
import {defineElement} from 'element-vir';
|
|
565
|
+
import {html, onResize} from 'element-vir';
|
|
558
566
|
|
|
559
|
-
export const MyWithOnResize =
|
|
567
|
+
export const MyWithOnResize = defineElement()({
|
|
560
568
|
tagName: 'my-with-on-resize',
|
|
561
569
|
render() {
|
|
562
570
|
return html`
|
|
@@ -7,20 +7,7 @@ import { type PropertyInitMapBase } from './properties/element-properties.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* Defines an element without any inputs.
|
|
9
9
|
*
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* import {defineElementNoInputs, html} from 'element-vir';
|
|
15
|
-
*
|
|
16
|
-
* const MyElement = defineElementNoInputs({
|
|
17
|
-
* tagName: 'my-element',
|
|
18
|
-
* render() {
|
|
19
|
-
* return html`
|
|
20
|
-
* <p>hi</p>
|
|
21
|
-
* `;
|
|
22
|
-
* },
|
|
23
|
-
* });
|
|
24
|
-
* ```
|
|
10
|
+
* @deprecated Use plain `defineElement` instead.
|
|
11
|
+
* @category Internal
|
|
25
12
|
*/
|
|
26
13
|
export declare function defineElementNoInputs<const TagName extends CustomElementTagName = '-', Inputs extends PropertyInitMapBase = {}, State extends PropertyInitMapBase = {}, EventsInit extends EventsInitMap = {}, const HostClassKeys extends BaseCssPropertyName<TagName> = `${TagName}-`, const CssVarKeys extends BaseCssPropertyName<TagName> = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = Readonly<[]>>(init: DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>): DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>;
|
|
@@ -16,21 +16,8 @@ import { createSlotNamesMap } from './slot-names.js';
|
|
|
16
16
|
/**
|
|
17
17
|
* Defines an element without any inputs.
|
|
18
18
|
*
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
22
|
-
* ```ts
|
|
23
|
-
* import {defineElementNoInputs, html} from 'element-vir';
|
|
24
|
-
*
|
|
25
|
-
* const MyElement = defineElementNoInputs({
|
|
26
|
-
* tagName: 'my-element',
|
|
27
|
-
* render() {
|
|
28
|
-
* return html`
|
|
29
|
-
* <p>hi</p>
|
|
30
|
-
* `;
|
|
31
|
-
* },
|
|
32
|
-
* });
|
|
33
|
-
* ```
|
|
19
|
+
* @deprecated Use plain `defineElement` instead.
|
|
20
|
+
* @category Internal
|
|
34
21
|
*/
|
|
35
22
|
export function defineElementNoInputs(init) {
|
|
36
23
|
if (!check.isObject(init)) {
|
|
@@ -14,9 +14,8 @@ export type DeclarativeElementInputErrorParams<Inputs extends PropertyInitMapBas
|
|
|
14
14
|
'ERROR: Cannot define an element input property that clashes with native HTMLElement properties.'
|
|
15
15
|
];
|
|
16
16
|
/**
|
|
17
|
-
* Defines an element with inputs.
|
|
18
|
-
*
|
|
19
|
-
* TypeScript type inference limitations.
|
|
17
|
+
* Defines an element with inputs. Note that this function must be called twice, due to TypeScript
|
|
18
|
+
* type inference limitations.
|
|
20
19
|
*
|
|
21
20
|
* @category Element Definition
|
|
22
21
|
* @example
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
2
2
|
import { assert, check } from '@augment-vir/assert';
|
|
3
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
3
4
|
import { defineElementNoInputs } from './define-element-no-inputs.js';
|
|
4
5
|
/**
|
|
5
|
-
* Defines an element with inputs.
|
|
6
|
-
*
|
|
7
|
-
* TypeScript type inference limitations.
|
|
6
|
+
* Defines an element with inputs. Note that this function must be called twice, due to TypeScript
|
|
7
|
+
* type inference limitations.
|
|
8
8
|
*
|
|
9
9
|
* @category Element Definition
|
|
10
10
|
* @example
|
|
@@ -34,6 +34,7 @@ export function defineElement(
|
|
|
34
34
|
if (!check.isObject(init)) {
|
|
35
35
|
throw new TypeError('Cannot define element with non-object init: ${init}');
|
|
36
36
|
}
|
|
37
|
+
// eslint-disable-next-line sonarjs/deprecation, @typescript-eslint/no-deprecated
|
|
37
38
|
return defineElementNoInputs({
|
|
38
39
|
...init,
|
|
39
40
|
options: {
|
|
@@ -11,9 +11,9 @@ type ListenCallbackReturn = MaybePromise<any>;
|
|
|
11
11
|
* @example
|
|
12
12
|
*
|
|
13
13
|
* ```ts
|
|
14
|
-
* import {html,
|
|
14
|
+
* import {html, defineElement, listen} from 'element-vir';
|
|
15
15
|
*
|
|
16
|
-
* const MyElement =
|
|
16
|
+
* const MyElement = defineElement()({
|
|
17
17
|
* tagName: 'my-element',
|
|
18
18
|
* render() {
|
|
19
19
|
* return html`
|
|
@@ -54,9 +54,9 @@ listener: (event: TypedEvent<TypedEventTypeNameGeneric, TypedEventDetailGeneric>
|
|
|
54
54
|
* @example
|
|
55
55
|
*
|
|
56
56
|
* ```ts
|
|
57
|
-
* import {html,
|
|
57
|
+
* import {html, defineElement, listen} from 'element-vir';
|
|
58
58
|
*
|
|
59
|
-
* const MyElement =
|
|
59
|
+
* const MyElement = defineElement()({
|
|
60
60
|
* tagName: 'my-element',
|
|
61
61
|
* render() {
|
|
62
62
|
* return html`
|
|
@@ -16,9 +16,9 @@ export type OnDomCreatedCallback = (element: Element) => MaybePromise<void>;
|
|
|
16
16
|
* @example
|
|
17
17
|
*
|
|
18
18
|
* ```ts
|
|
19
|
-
* import {html,
|
|
19
|
+
* import {html, defineElement, onDomCreated} from 'element-vir';
|
|
20
20
|
*
|
|
21
|
-
* const MyElement =
|
|
21
|
+
* const MyElement = defineElement()({
|
|
22
22
|
* tagName: 'my-element',
|
|
23
23
|
* render() {
|
|
24
24
|
* return html`
|
|
@@ -10,9 +10,9 @@ const directiveName = 'onDomCreated';
|
|
|
10
10
|
* @example
|
|
11
11
|
*
|
|
12
12
|
* ```ts
|
|
13
|
-
* import {html,
|
|
13
|
+
* import {html, defineElement, onDomCreated} from 'element-vir';
|
|
14
14
|
*
|
|
15
|
-
* const MyElement =
|
|
15
|
+
* const MyElement = defineElement()({
|
|
16
16
|
* tagName: 'my-element',
|
|
17
17
|
* render() {
|
|
18
18
|
* return html`
|
|
@@ -14,9 +14,9 @@ export type OnDomRenderedCallback = (element: Element) => MaybePromise<void>;
|
|
|
14
14
|
* @example
|
|
15
15
|
*
|
|
16
16
|
* ```ts
|
|
17
|
-
* import {html,
|
|
17
|
+
* import {html, defineElement, onDomRendered} from 'element-vir';
|
|
18
18
|
*
|
|
19
|
-
* const MyElement =
|
|
19
|
+
* const MyElement = defineElement()({
|
|
20
20
|
* tagName: 'my-element',
|
|
21
21
|
* render() {
|
|
22
22
|
* return html`
|
|
@@ -8,9 +8,9 @@ const directiveName = 'onDomRendered';
|
|
|
8
8
|
* @example
|
|
9
9
|
*
|
|
10
10
|
* ```ts
|
|
11
|
-
* import {html,
|
|
11
|
+
* import {html, defineElement, onDomRendered} from 'element-vir';
|
|
12
12
|
*
|
|
13
|
-
* const MyElement =
|
|
13
|
+
* const MyElement = defineElement()({
|
|
14
14
|
* tagName: 'my-element',
|
|
15
15
|
* render() {
|
|
16
16
|
* return html`
|
|
@@ -28,9 +28,9 @@ export type OnIntersectOptions = IntersectionObserverInit;
|
|
|
28
28
|
* @example
|
|
29
29
|
*
|
|
30
30
|
* ```ts
|
|
31
|
-
* import {html,
|
|
31
|
+
* import {html, defineElement, onIntersect} from 'element-vir';
|
|
32
32
|
*
|
|
33
|
-
* const MyElement =
|
|
33
|
+
* const MyElement = defineElement()({
|
|
34
34
|
* tagName: 'my-element',
|
|
35
35
|
* render() {
|
|
36
36
|
* return html`
|
|
@@ -13,9 +13,9 @@ const directiveName = 'onIntersect';
|
|
|
13
13
|
* @example
|
|
14
14
|
*
|
|
15
15
|
* ```ts
|
|
16
|
-
* import {html,
|
|
16
|
+
* import {html, defineElement, onIntersect} from 'element-vir';
|
|
17
17
|
*
|
|
18
|
-
* const MyElement =
|
|
18
|
+
* const MyElement = defineElement()({
|
|
19
19
|
* tagName: 'my-element',
|
|
20
20
|
* render() {
|
|
21
21
|
* return html`
|
|
@@ -17,9 +17,9 @@ export type OnResizeCallback = (size: Readonly<Pick<ResizeObserverEntry,
|
|
|
17
17
|
* @example
|
|
18
18
|
*
|
|
19
19
|
* ```ts
|
|
20
|
-
* import {html,
|
|
20
|
+
* import {html, defineElement, onResize} from 'element-vir';
|
|
21
21
|
*
|
|
22
|
-
* const MyElement =
|
|
22
|
+
* const MyElement = defineElement()({
|
|
23
23
|
* tagName: 'my-element',
|
|
24
24
|
* render() {
|
|
25
25
|
* return html`
|
|
@@ -10,9 +10,9 @@ const directiveName = 'onResize';
|
|
|
10
10
|
* @example
|
|
11
11
|
*
|
|
12
12
|
* ```ts
|
|
13
|
-
* import {html,
|
|
13
|
+
* import {html, defineElement, onResize} from 'element-vir';
|
|
14
14
|
*
|
|
15
|
-
* const MyElement =
|
|
15
|
+
* const MyElement = defineElement()({
|
|
16
16
|
* tagName: 'my-element',
|
|
17
17
|
* render() {
|
|
18
18
|
* return html`
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* @example
|
|
8
8
|
*
|
|
9
9
|
* ```ts
|
|
10
|
-
* import {html,
|
|
10
|
+
* import {html, defineElement, renderIf} from 'element-vir';
|
|
11
11
|
*
|
|
12
|
-
* const MyElement =
|
|
12
|
+
* const MyElement = defineElement()({
|
|
13
13
|
* tagName: 'my-element',
|
|
14
14
|
* render() {
|
|
15
15
|
* return html`
|
|
@@ -8,9 +8,9 @@ import { when } from '../../lit-exports/all-lit-exports.js';
|
|
|
8
8
|
* @example
|
|
9
9
|
*
|
|
10
10
|
* ```ts
|
|
11
|
-
* import {html,
|
|
11
|
+
* import {html, defineElement, renderIf} from 'element-vir';
|
|
12
12
|
*
|
|
13
|
-
* const MyElement =
|
|
13
|
+
* const MyElement = defineElement()({
|
|
14
14
|
* tagName: 'my-element',
|
|
15
15
|
* render() {
|
|
16
16
|
* return html`
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* @example
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
|
-
* import {html,
|
|
8
|
+
* import {html, defineElement, testId} from 'element-vir';
|
|
9
9
|
*
|
|
10
|
-
* const MyElement =
|
|
10
|
+
* const MyElement = defineElement()({
|
|
11
11
|
* tagName: 'my-element',
|
|
12
12
|
* render() {
|
|
13
13
|
* return html`
|
|
@@ -7,9 +7,9 @@ const { attributeDirective, attributeSelector, attributeName } = createAttribute
|
|
|
7
7
|
* @example
|
|
8
8
|
*
|
|
9
9
|
* ```ts
|
|
10
|
-
* import {html,
|
|
10
|
+
* import {html, defineElement, testId} from 'element-vir';
|
|
11
11
|
*
|
|
12
|
-
* const MyElement =
|
|
12
|
+
* const MyElement = defineElement()({
|
|
13
13
|
* tagName: 'my-element',
|
|
14
14
|
* render() {
|
|
15
15
|
* return html`
|
|
@@ -13,9 +13,9 @@ export type EventsInitMap = Record<string, DefineEvent<any>>;
|
|
|
13
13
|
* @example
|
|
14
14
|
*
|
|
15
15
|
* ```ts
|
|
16
|
-
* import {html,
|
|
16
|
+
* import {html, defineElement, defineElementEvent, listen} from 'element-vir';
|
|
17
17
|
*
|
|
18
|
-
* const MyElement =
|
|
18
|
+
* const MyElement = defineElement()({
|
|
19
19
|
* tagName: 'my-element',
|
|
20
20
|
* events: {
|
|
21
21
|
* myOutput: defineElementEvent<number>(),
|
|
@@ -6,9 +6,9 @@ import { defineTypedEvent, } from '../../typed-event/typed-event.js';
|
|
|
6
6
|
* @example
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
|
-
* import {html,
|
|
9
|
+
* import {html, defineElement, defineElementEvent, listen} from 'element-vir';
|
|
10
10
|
*
|
|
11
|
-
* const MyElement =
|
|
11
|
+
* const MyElement = defineElement()({
|
|
12
12
|
* tagName: 'my-element',
|
|
13
13
|
* events: {
|
|
14
14
|
* myOutput: defineElementEvent<number>(),
|
|
@@ -23,8 +23,7 @@ export type WrapDefineElementOptions<TagNameRequirement extends CustomElementTag
|
|
|
23
23
|
transformInputs: (inputInit: DeclarativeElementInit<TagNameRequirement, InputsRequirement, StateRequirement, EventsInitRequirement, BaseCssPropertyName<TagNameRequirement>, BaseCssPropertyName<TagNameRequirement>, ReadonlyArray<string>>) => DeclarativeElementInit<TagNameRequirement, InputsRequirement, StateRequirement, EventsInitRequirement, BaseCssPropertyName<TagNameRequirement>, BaseCssPropertyName<TagNameRequirement>, ReadonlyArray<string>>;
|
|
24
24
|
}>;
|
|
25
25
|
/**
|
|
26
|
-
* Wraps {@link defineElement}
|
|
27
|
-
* example:
|
|
26
|
+
* Wraps {@link defineElement} in a superset of requirements. For example:
|
|
28
27
|
*
|
|
29
28
|
* - You could create element definition functions that require all elements to start with a common
|
|
30
29
|
* prefix, like `vir-`.
|
|
@@ -37,6 +36,10 @@ export type WrapDefineElementOptions<TagNameRequirement extends CustomElementTag
|
|
|
37
36
|
export declare function wrapDefineElement<TagNameRequirement extends CustomElementTagName = CustomElementTagName, InputsRequirement extends PropertyInitMapBase = {}, StateRequirement extends PropertyInitMapBase = {}, EventsInitRequirement extends EventsInitMap = {}>(options?: WrapDefineElementOptions | undefined): {
|
|
38
37
|
/** A wrapped function for defining an element with inputs. */
|
|
39
38
|
defineElement: <Inputs extends InputsRequirement>(...errorParams: DeclarativeElementInputErrorParams<Inputs>) => <const TagName extends TagNameRequirement, State extends StateRequirement, EventsInit extends EventsInitRequirement, const HostClassKeys extends BaseCssPropertyName<TagName> = `${TagName}-`, const CssVarKeys extends BaseCssPropertyName<TagName> = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = Readonly<[]>>(inputs: DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("./declarative-element.js").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>;
|
|
40
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* A wrapped function for defining an element without inputs.
|
|
41
|
+
*
|
|
42
|
+
* @deprecated Use `defineElement` instead.
|
|
43
|
+
*/
|
|
41
44
|
defineElementNoInputs: <const TagName extends TagNameRequirement, Inputs extends InputsRequirement, State extends StateRequirement, EventsInit extends EventsInitRequirement, const HostClassKeys extends BaseCssPropertyName<TagName> = `${TagName}-`, const CssVarKeys extends BaseCssPropertyName<TagName> = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = readonly []>(inputs: DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("./declarative-element.js").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>;
|
|
42
45
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
2
|
-
import { defineElementNoInputs } from './define-element-no-inputs.js';
|
|
3
2
|
import { defineElement } from './define-element.js';
|
|
3
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
4
|
+
import { defineElementNoInputs } from './define-element-no-inputs.js';
|
|
4
5
|
/**
|
|
5
|
-
* Wraps {@link defineElement}
|
|
6
|
-
* example:
|
|
6
|
+
* Wraps {@link defineElement} in a superset of requirements. For example:
|
|
7
7
|
*
|
|
8
8
|
* - You could create element definition functions that require all elements to start with a common
|
|
9
9
|
* prefix, like `vir-`.
|
|
@@ -26,9 +26,14 @@ export function wrapDefineElement(options) {
|
|
|
26
26
|
return defineElement(...errorParams)(transformInputs(inputs));
|
|
27
27
|
};
|
|
28
28
|
},
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* A wrapped function for defining an element without inputs.
|
|
31
|
+
*
|
|
32
|
+
* @deprecated Use `defineElement` instead.
|
|
33
|
+
*/
|
|
30
34
|
defineElementNoInputs: (inputs) => {
|
|
31
35
|
assertInputs(inputs);
|
|
36
|
+
// eslint-disable-next-line sonarjs/deprecation, @typescript-eslint/no-deprecated
|
|
32
37
|
return defineElementNoInputs(transformInputs(inputs));
|
|
33
38
|
},
|
|
34
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MyApp: import("
|
|
1
|
+
export declare const MyApp: import("element-vir").DeclarativeElementDefinition<"my-app", {}, {}, {}, "my-app-", "my-app-", readonly []>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { html } from '../index.js';
|
|
2
3
|
import { MySimple } from './my-simple.element.js';
|
|
3
|
-
export const MyApp =
|
|
4
|
+
export const MyApp = defineElement()({
|
|
4
5
|
tagName: 'my-app',
|
|
5
6
|
render() {
|
|
6
7
|
return html `
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type VirTagName = `vir-${string}`;
|
|
2
|
-
export declare const defineVirElement: <Inputs extends {}>(...errorParams: import("../index.js").DeclarativeElementInputErrorParams<Inputs>) => <const TagName extends `vir-${string}`, State extends {}, EventsInit extends {}, const HostClassKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const CssVarKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = Readonly<[]>>(inputs: import("../index.js").DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("../index.js").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames
|
|
3
|
-
export declare const defineVerifiedVirElement: <Inputs extends {}>(...errorParams: import("../index.js").DeclarativeElementInputErrorParams<Inputs>) => <const TagName extends `vir-${string}`, State extends {}, EventsInit extends {}, const HostClassKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const CssVarKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = Readonly<[]>>(inputs: import("../index.js").DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("../index.js").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames
|
|
4
|
-
export declare const defineTransformedVirElement: <Inputs extends {}>(...errorParams: import("../index.js").DeclarativeElementInputErrorParams<Inputs>) => <const TagName extends `vir-${string}`, State extends {}, EventsInit extends {}, const HostClassKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const CssVarKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = Readonly<[]>>(inputs: import("../index.js").DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("../index.js").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames
|
|
2
|
+
export declare const defineVirElement: <Inputs extends {}>(...errorParams: import("../index.js").DeclarativeElementInputErrorParams<Inputs>) => <const TagName extends `vir-${string}`, State extends {}, EventsInit extends {}, const HostClassKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const CssVarKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = Readonly<[]>>(inputs: import("../index.js").DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("../index.js").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>;
|
|
3
|
+
export declare const defineVerifiedVirElement: <Inputs extends {}>(...errorParams: import("../index.js").DeclarativeElementInputErrorParams<Inputs>) => <const TagName extends `vir-${string}`, State extends {}, EventsInit extends {}, const HostClassKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const CssVarKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = Readonly<[]>>(inputs: import("../index.js").DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("../index.js").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>;
|
|
4
|
+
export declare const defineTransformedVirElement: <Inputs extends {}>(...errorParams: import("../index.js").DeclarativeElementInputErrorParams<Inputs>) => <const TagName extends `vir-${string}`, State extends {}, EventsInit extends {}, const HostClassKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const CssVarKeys extends import("../index.js").BaseCssPropertyName<TagName> = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = Readonly<[]>>(inputs: import("../index.js").DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("../index.js").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { wrapDefineElement } from '../index.js';
|
|
2
|
-
export const { defineElement: defineVirElement
|
|
2
|
+
export const { defineElement: defineVirElement } = wrapDefineElement();
|
|
3
3
|
// add an optional assert callback
|
|
4
|
-
export const { defineElement: defineVerifiedVirElement
|
|
4
|
+
export const { defineElement: defineVerifiedVirElement } = wrapDefineElement({
|
|
5
5
|
assertInputs: (inputs) => {
|
|
6
6
|
if (!inputs.tagName.startsWith('vir-')) {
|
|
7
7
|
throw new Error(`all custom elements must start with "vir-"`);
|
|
@@ -9,7 +9,7 @@ export const { defineElement: defineVerifiedVirElement, defineElementNoInputs: d
|
|
|
9
9
|
},
|
|
10
10
|
});
|
|
11
11
|
// add an optional transform callback
|
|
12
|
-
export const { defineElement: defineTransformedVirElement
|
|
12
|
+
export const { defineElement: defineTransformedVirElement } = wrapDefineElement({
|
|
13
13
|
transformInputs: (inputs) => {
|
|
14
14
|
return {
|
|
15
15
|
...inputs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MySimple: import("
|
|
1
|
+
export declare const MySimple: import("element-vir").DeclarativeElementDefinition<"my-simple", {}, {}, {}, "my-simple-", "my-simple-", readonly []>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { html } from '../index.js';
|
|
3
|
+
export const MySimple = defineElement()({
|
|
3
4
|
tagName: 'my-simple',
|
|
4
5
|
render() {
|
|
5
6
|
return html `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MyWithAssignment: import("
|
|
1
|
+
export declare const MyWithAssignment: import("element-vir").DeclarativeElementDefinition<"my-with-assignment", {}, {}, {}, "my-with-assignment-", "my-with-assignment-", readonly []>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { html } from '../index.js';
|
|
2
3
|
import { MyWithInputs } from './my-with-inputs.element.js';
|
|
3
|
-
export const MyWithAssignment =
|
|
4
|
+
export const MyWithAssignment = defineElement()({
|
|
4
5
|
tagName: 'my-with-assignment',
|
|
5
6
|
render() {
|
|
6
7
|
return html `
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const MyWithAssignmentCleanupCallback: import("
|
|
1
|
+
export declare const MyWithAssignmentCleanupCallback: import("element-vir").DeclarativeElementDefinition<"my-with-cleanup-callback", {}, {
|
|
2
2
|
intervalId: number;
|
|
3
3
|
}, {}, "my-with-cleanup-callback-", "my-with-cleanup-callback-", readonly []>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { html } from '../index.js';
|
|
3
|
+
export const MyWithAssignmentCleanupCallback = defineElement()({
|
|
3
4
|
tagName: 'my-with-cleanup-callback',
|
|
4
5
|
state() {
|
|
5
6
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MyWithCssVars: import("
|
|
1
|
+
export declare const MyWithCssVars: import("element-vir").DeclarativeElementDefinition<"my-with-css-vars", {}, {}, {}, "my-with-css-vars-", "my-with-css-vars-my-var", readonly []>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { css, html } from '../index.js';
|
|
3
|
+
export const MyWithCssVars = defineElement()({
|
|
3
4
|
tagName: 'my-with-css-vars',
|
|
4
5
|
cssVars: {
|
|
5
6
|
/** The value assigned here ('blue') becomes the fallback value for this CSS var. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MyWithCustomEvents: import("
|
|
1
|
+
export declare const MyWithCustomEvents: import("element-vir").DeclarativeElementDefinition<"my-with-custom-events", {}, {}, {}, "my-with-custom-events-", "my-with-custom-events-", readonly []>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { randomInteger } from '@augment-vir/common';
|
|
2
|
-
import {
|
|
2
|
+
import { defineElement } from 'element-vir';
|
|
3
|
+
import { html, listen } from '../index.js';
|
|
3
4
|
import { MyCustomActionEvent } from './my-custom-action.event.js';
|
|
4
|
-
export const MyWithCustomEvents =
|
|
5
|
+
export const MyWithCustomEvents = defineElement()({
|
|
5
6
|
tagName: 'my-with-custom-events',
|
|
6
7
|
render({ dispatch }) {
|
|
7
8
|
return html `
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const MyWithEventListening: import("
|
|
1
|
+
export declare const MyWithEventListening: import("element-vir").DeclarativeElementDefinition<"my-with-event-listening", {}, {
|
|
2
2
|
myNumber: number;
|
|
3
3
|
}, {}, "my-with-event-listening-", "my-with-event-listening-", readonly []>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { html, listen } from '../index.js';
|
|
2
3
|
import { MyWithEvents } from './my-with-events.element.js';
|
|
3
|
-
export const MyWithEventListening =
|
|
4
|
+
export const MyWithEventListening = defineElement()({
|
|
4
5
|
tagName: 'my-with-event-listening',
|
|
5
6
|
state() {
|
|
6
7
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const MyWithEvents: import("
|
|
2
|
-
logoutClick: import("
|
|
3
|
-
randomNumber: import("
|
|
1
|
+
export declare const MyWithEvents: import("element-vir").DeclarativeElementDefinition<"my-with-events", {}, {}, {
|
|
2
|
+
logoutClick: import("element-vir").DefineEvent<void>;
|
|
3
|
+
randomNumber: import("element-vir").DefineEvent<number>;
|
|
4
4
|
}, "my-with-events-", "my-with-events-", readonly []>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomInteger } from '@augment-vir/common';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { defineElement } from 'element-vir';
|
|
3
|
+
import { defineElementEvent, html, listen } from '../index.js';
|
|
4
|
+
export const MyWithEvents = defineElement()({
|
|
4
5
|
tagName: 'my-with-events',
|
|
5
6
|
events: {
|
|
6
7
|
logoutClick: defineElementEvent(),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const MyWithHostClassDefinition: import("
|
|
1
|
+
export declare const MyWithHostClassDefinition: import("element-vir").DeclarativeElementDefinition<"my-with-host-class-definition", {}, {
|
|
2
2
|
myProp: string;
|
|
3
3
|
}, {}, "my-with-host-class-definition-a" | "my-with-host-class-definition-automatic", "my-with-host-class-definition-", readonly []>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { css, html } from '../index.js';
|
|
3
|
+
export const MyWithHostClassDefinition = defineElement()({
|
|
3
4
|
tagName: 'my-with-host-class-definition',
|
|
4
5
|
state() {
|
|
5
6
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MyWithHostClassUsage: import("
|
|
1
|
+
export declare const MyWithHostClassUsage: import("element-vir").DeclarativeElementDefinition<"my-with-host-class-usage", {}, {}, {}, "my-with-host-class-usage-", "my-with-host-class-usage-", readonly []>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { html } from '../index.js';
|
|
2
3
|
import { MyWithHostClassDefinition } from './my-with-host-class-definition.element.js';
|
|
3
|
-
export const MyWithHostClassUsage =
|
|
4
|
+
export const MyWithHostClassUsage = defineElement()({
|
|
4
5
|
tagName: 'my-with-host-class-usage',
|
|
5
6
|
render() {
|
|
6
7
|
return html `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MyWithOnDomCreated: import("
|
|
1
|
+
export declare const MyWithOnDomCreated: import("element-vir").DeclarativeElementDefinition<"my-with-on-dom-created", {}, {}, {}, "my-with-on-dom-created-", "my-with-on-dom-created-", readonly []>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { html, onDomCreated } from '../index.js';
|
|
3
|
+
export const MyWithOnDomCreated = defineElement()({
|
|
3
4
|
tagName: 'my-with-on-dom-created',
|
|
4
5
|
render() {
|
|
5
6
|
return html `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MyWithOnResize: import("
|
|
1
|
+
export declare const MyWithOnResize: import("element-vir").DeclarativeElementDefinition<"my-with-on-resize", {}, {}, {}, "my-with-on-resize-", "my-with-on-resize-", readonly []>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { html, onResize } from '../index.js';
|
|
3
|
+
export const MyWithOnResize = defineElement()({
|
|
3
4
|
tagName: 'my-with-on-resize',
|
|
4
5
|
render() {
|
|
5
6
|
return html `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MyWithStylesAndInterpolatedSelector: import("
|
|
1
|
+
export declare const MyWithStylesAndInterpolatedSelector: import("element-vir").DeclarativeElementDefinition<"my-with-styles-and-interpolated-selector", {}, {}, {}, "my-with-styles-and-interpolated-selector-", "my-with-styles-and-interpolated-selector-", readonly []>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { css, html } from '../index.js';
|
|
2
3
|
import { MySimple } from './my-simple.element.js';
|
|
3
|
-
export const MyWithStylesAndInterpolatedSelector =
|
|
4
|
+
export const MyWithStylesAndInterpolatedSelector = defineElement()({
|
|
4
5
|
tagName: 'my-with-styles-and-interpolated-selector',
|
|
5
6
|
styles: css `
|
|
6
7
|
${MySimple} {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MyWithStyles: import("
|
|
1
|
+
export declare const MyWithStyles: import("element-vir").DeclarativeElementDefinition<"my-with-styles", {}, {}, {}, "my-with-styles-", "my-with-styles-", readonly []>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { css, html } from '../index.js';
|
|
3
|
+
export const MyWithStyles = defineElement()({
|
|
3
4
|
tagName: 'my-with-styles',
|
|
4
5
|
styles: css `
|
|
5
6
|
:host {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const MyWithUpdateState: import("
|
|
1
|
+
export declare const MyWithUpdateState: import("element-vir").DeclarativeElementDefinition<"my-with-update-state", {}, {
|
|
2
2
|
username: string;
|
|
3
3
|
/**
|
|
4
4
|
* Use "as" to create state properties that can be types other than the initial value's
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { defineElement } from 'element-vir';
|
|
2
|
+
import { html, listen } from '../index.js';
|
|
3
|
+
export const MyWithUpdateState = defineElement()({
|
|
3
4
|
tagName: 'my-with-update-state',
|
|
4
5
|
state() {
|
|
5
6
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-vir",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.12.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"custom",
|
|
6
6
|
"web",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"test:docs": "virmator docs check"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@augment-vir/assert": "^31.21.
|
|
43
|
-
"@augment-vir/common": "^31.21.
|
|
42
|
+
"@augment-vir/assert": "^31.21.1",
|
|
43
|
+
"@augment-vir/common": "^31.21.1",
|
|
44
44
|
"date-vir": "^7.3.1",
|
|
45
45
|
"lit": "^3.3.0",
|
|
46
46
|
"lit-css-vars": "^3.0.11",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"typed-event-target": "^4.1.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@augment-vir/test": "^31.21.
|
|
54
|
-
"@augment-vir/web": "^31.21.
|
|
53
|
+
"@augment-vir/test": "^31.21.1",
|
|
54
|
+
"@augment-vir/web": "^31.21.1",
|
|
55
55
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
56
56
|
"@web/test-runner": "^0.20.2",
|
|
57
57
|
"@web/test-runner-commands": "^0.9.0",
|