element-vir 26.15.1 → 26.17.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 +27 -39
- package/dist/declarative-element/declarative-element-init.d.ts +9 -3
- package/dist/declarative-element/declarative-element.d.ts +6 -6
- package/dist/declarative-element/define-element.d.ts +1 -1
- package/dist/declarative-element/define-element.js +24 -14
- package/dist/declarative-element/directives/directive-helpers.js +0 -4
- package/dist/declarative-element/directives/on-intersect.directive.d.ts +5 -0
- package/dist/declarative-element/directives/on-intersect.directive.js +10 -2
- package/dist/declarative-element/directives/on-resize.directive.d.ts +5 -0
- package/dist/declarative-element/directives/on-resize.directive.js +11 -3
- package/dist/declarative-element/properties/element-events.js +1 -1
- package/dist/declarative-element/properties/property-proxy.js +1 -1
- package/dist/declarative-element/properties/string-names.d.ts +21 -1
- package/dist/declarative-element/properties/string-names.js +35 -1
- package/dist/declarative-element/properties/styles.d.ts +8 -5
- package/dist/declarative-element/properties/styles.js +4 -1
- package/dist/declarative-element/render-callback.d.ts +3 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/lit-exports/lit-repeat-fix.d.ts +1 -1
- package/dist/template-transforms/nested-mapped-templates.js +3 -3
- package/dist/template-transforms/vir-html/html-interpolation.d.ts +8 -2
- package/dist/template-transforms/vir-html/html-transform.js +2 -22
- package/dist/util/increment.d.ts +8 -2
- package/package.json +11 -11
- package/dist/readme-examples/my-app.element.d.ts +0 -1
- package/dist/readme-examples/my-app.element.js +0 -12
- package/dist/readme-examples/my-custom-action.event.d.ts +0 -1
- package/dist/readme-examples/my-custom-action.event.js +0 -2
- package/dist/readme-examples/my-custom-define.d.ts +0 -4
- package/dist/readme-examples/my-custom-define.js +0 -19
- package/dist/readme-examples/my-simple.element.d.ts +0 -1
- package/dist/readme-examples/my-simple.element.js +0 -10
- package/dist/readme-examples/my-with-assignment.element.d.ts +0 -1
- package/dist/readme-examples/my-with-assignment.element.js +0 -15
- package/dist/readme-examples/my-with-async-prop.element.d.ts +0 -10
- package/dist/readme-examples/my-with-async-prop.element.js +0 -49
- package/dist/readme-examples/my-with-cleanup-callback.element.d.ts +0 -3
- package/dist/readme-examples/my-with-cleanup-callback.element.js +0 -18
- package/dist/readme-examples/my-with-css-vars.element.d.ts +0 -1
- package/dist/readme-examples/my-with-css-vars.element.js +0 -25
- package/dist/readme-examples/my-with-custom-events.element.d.ts +0 -1
- package/dist/readme-examples/my-with-custom-events.element.js +0 -25
- package/dist/readme-examples/my-with-event-listening.element.d.ts +0 -3
- package/dist/readme-examples/my-with-event-listening.element.js +0 -27
- package/dist/readme-examples/my-with-events.element.d.ts +0 -4
- package/dist/readme-examples/my-with-events.element.js +0 -23
- package/dist/readme-examples/my-with-host-class-definition.element.d.ts +0 -3
- package/dist/readme-examples/my-with-host-class-definition.element.js +0 -42
- package/dist/readme-examples/my-with-host-class-usage.element.d.ts +0 -1
- package/dist/readme-examples/my-with-host-class-usage.element.js +0 -13
- package/dist/readme-examples/my-with-inputs.element.d.ts +0 -4
- package/dist/readme-examples/my-with-inputs.element.js +0 -9
- package/dist/readme-examples/my-with-on-dom-created.element.d.ts +0 -1
- package/dist/readme-examples/my-with-on-dom-created.element.js +0 -17
- package/dist/readme-examples/my-with-on-resize.element.d.ts +0 -1
- package/dist/readme-examples/my-with-on-resize.element.js +0 -18
- package/dist/readme-examples/my-with-render-if.element.d.ts +0 -3
- package/dist/readme-examples/my-with-render-if.element.js +0 -11
- package/dist/readme-examples/my-with-styles-and-interpolated-selector.element.d.ts +0 -1
- package/dist/readme-examples/my-with-styles-and-interpolated-selector.element.js +0 -16
- package/dist/readme-examples/my-with-styles.element.d.ts +0 -1
- package/dist/readme-examples/my-with-styles.element.js +0 -22
- package/dist/readme-examples/my-with-update-state.element.d.ts +0 -8
- package/dist/readme-examples/my-with-update-state.element.js +0 -28
- package/dist/readme-examples/require-declarative-element.d.ts +0 -1
- package/dist/readme-examples/require-declarative-element.js +0 -2
- package/dist/require-declarative-element.d.ts +0 -14
- package/dist/require-declarative-element.js +0 -16
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ All of [`lit`](https://lit.dev)'s syntax and functionality is available for use
|
|
|
38
38
|
|
|
39
39
|
Use `defineElement` to define your element. Here is a bare-minimum example custom element:
|
|
40
40
|
|
|
41
|
-
<!-- example-link: src/readme-examples/my-simple.
|
|
41
|
+
<!-- example-link: src/readme-examples/my-simple.example.ts -->
|
|
42
42
|
|
|
43
43
|
```TypeScript
|
|
44
44
|
import {defineElement} from 'element-vir';
|
|
@@ -60,12 +60,12 @@ Make sure to export your element definition if you need to use it in other files
|
|
|
60
60
|
|
|
61
61
|
To use already defined elements (like the example above), they must be interpolated into HTML templates like so:
|
|
62
62
|
|
|
63
|
-
<!-- example-link: src/readme-examples/my-app.
|
|
63
|
+
<!-- example-link: src/readme-examples/my-app.example.ts -->
|
|
64
64
|
|
|
65
65
|
```TypeScript
|
|
66
66
|
import {defineElement} from 'element-vir';
|
|
67
67
|
import {html} from 'element-vir';
|
|
68
|
-
import {MySimple} from './my-simple.
|
|
68
|
+
import {MySimple} from './my-simple.example.js';
|
|
69
69
|
|
|
70
70
|
export const MyApp = defineElement()({
|
|
71
71
|
tagName: 'my-app',
|
|
@@ -84,7 +84,7 @@ This requirement ensures that the element is properly imported and registered wi
|
|
|
84
84
|
|
|
85
85
|
Styles are added through the `styles` property when defining a declarative element (similar to [how they are defined in `lit`](https://lit.dev/docs/components/styles/)):
|
|
86
86
|
|
|
87
|
-
<!-- example-link: src/readme-examples/my-with-styles.
|
|
87
|
+
<!-- example-link: src/readme-examples/my-with-styles.example.ts -->
|
|
88
88
|
|
|
89
89
|
```TypeScript
|
|
90
90
|
import {defineElement} from 'element-vir';
|
|
@@ -116,12 +116,12 @@ export const MyWithStyles = defineElement()({
|
|
|
116
116
|
|
|
117
117
|
Declarative element definitions can be used in the `css` tagged template just like in the `html` tagged template. This will be replaced by the element's tag name:
|
|
118
118
|
|
|
119
|
-
<!-- example-link: src/readme-examples/my-with-styles-and-interpolated-selector.
|
|
119
|
+
<!-- example-link: src/readme-examples/my-with-styles-and-interpolated-selector.example.ts -->
|
|
120
120
|
|
|
121
121
|
```TypeScript
|
|
122
122
|
import {defineElement} from 'element-vir';
|
|
123
123
|
import {css, html} from 'element-vir';
|
|
124
|
-
import {MySimple} from './my-simple.
|
|
124
|
+
import {MySimple} from './my-simple.example.js';
|
|
125
125
|
|
|
126
126
|
export const MyWithStylesAndInterpolatedSelector = defineElement()({
|
|
127
127
|
tagName: 'my-with-styles-and-interpolated-selector',
|
|
@@ -144,7 +144,7 @@ Define element inputs by using `defineElement` to define a declarative element.
|
|
|
144
144
|
|
|
145
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:
|
|
146
146
|
|
|
147
|
-
<!-- example-link: src/readme-examples/my-with-inputs.
|
|
147
|
+
<!-- example-link: src/readme-examples/my-with-inputs.example.ts -->
|
|
148
148
|
|
|
149
149
|
```TypeScript
|
|
150
150
|
import {defineElement, html} from 'element-vir';
|
|
@@ -166,7 +166,7 @@ export const MyWithInputs = defineElement<{
|
|
|
166
166
|
|
|
167
167
|
Define initial internal state values and types with the `stateInit` property when defining an element. Grab it with `state` in `render` to use state. Grab `updateState` in `render` to update state:
|
|
168
168
|
|
|
169
|
-
<!-- example-link: src/readme-examples/my-with-update-state.
|
|
169
|
+
<!-- example-link: src/readme-examples/my-with-update-state.example.ts -->
|
|
170
170
|
|
|
171
171
|
```TypeScript
|
|
172
172
|
import {defineElement} from 'element-vir';
|
|
@@ -204,12 +204,12 @@ export const MyWithUpdateState = defineElement()({
|
|
|
204
204
|
|
|
205
205
|
Use the `assign` directive to assign values to child custom elements inputs:
|
|
206
206
|
|
|
207
|
-
<!-- example-link: src/readme-examples/my-with-assignment.
|
|
207
|
+
<!-- example-link: src/readme-examples/my-with-assignment.example.ts -->
|
|
208
208
|
|
|
209
209
|
```TypeScript
|
|
210
210
|
import {defineElement} from 'element-vir';
|
|
211
211
|
import {html} from 'element-vir';
|
|
212
|
-
import {MyWithInputs} from './my-with-inputs.
|
|
212
|
+
import {MyWithInputs} from './my-with-inputs.example.js';
|
|
213
213
|
|
|
214
214
|
export const MyWithAssignment = defineElement()({
|
|
215
215
|
tagName: 'my-with-assignment',
|
|
@@ -232,7 +232,7 @@ There are two other callbacks you can define that are sort of similar to lifecyc
|
|
|
232
232
|
- `init`: called right before the first render and has all state and inputs setup. (This is similar to `connectedCallback` in standard HTMLElement classes but is fired much later, after inputs are assigned, to avoid race conditions.)
|
|
233
233
|
- `cleanup`: called when an element is removed from the DOM. (This is the same as the `disconnectedCallback` in standard HTMLElement classes.)
|
|
234
234
|
|
|
235
|
-
<!-- example-link: src/readme-examples/my-with-cleanup-callback.
|
|
235
|
+
<!-- example-link: src/readme-examples/my-with-cleanup-callback.example.ts -->
|
|
236
236
|
|
|
237
237
|
```TypeScript
|
|
238
238
|
import {defineElement} from 'element-vir';
|
|
@@ -262,7 +262,7 @@ When defining a declarative element, use `events` to setup event names and types
|
|
|
262
262
|
|
|
263
263
|
To dispatch an event, grab `dispatch` and `events` from `render`'s parameters.
|
|
264
264
|
|
|
265
|
-
<!-- example-link: src/readme-examples/my-with-events.
|
|
265
|
+
<!-- example-link: src/readme-examples/my-with-events.example.ts -->
|
|
266
266
|
|
|
267
267
|
```TypeScript
|
|
268
268
|
import {randomInteger} from '@augment-vir/common';
|
|
@@ -301,12 +301,12 @@ export const MyWithEvents = defineElement()({
|
|
|
301
301
|
|
|
302
302
|
Use the `listen` directive to listen to events emitted by your custom elements:
|
|
303
303
|
|
|
304
|
-
<!-- example-link: src/readme-examples/my-with-event-listening.
|
|
304
|
+
<!-- example-link: src/readme-examples/my-with-event-listening.example.ts -->
|
|
305
305
|
|
|
306
306
|
```TypeScript
|
|
307
307
|
import {defineElement} from 'element-vir';
|
|
308
308
|
import {html, listen} from 'element-vir';
|
|
309
|
-
import {MyWithEvents} from './my-with-events.
|
|
309
|
+
import {MyWithEvents} from './my-with-events.example.js';
|
|
310
310
|
|
|
311
311
|
export const MyWithEventListening = defineElement()({
|
|
312
312
|
tagName: 'my-with-event-listening',
|
|
@@ -340,7 +340,7 @@ export const MyWithEventListening = defineElement()({
|
|
|
340
340
|
|
|
341
341
|
Create a custom event type with `defineTypedEvent`. Make sure to include the type parameter and call it twice, the second time with the event type name string to ensure type safety when using your event. Note that event type names should be unique, or they will clash with each other.
|
|
342
342
|
|
|
343
|
-
<!-- example-link: src/readme-examples/my-custom-action.
|
|
343
|
+
<!-- example-link: src/readme-examples/my-custom-action.example.ts -->
|
|
344
344
|
|
|
345
345
|
```TypeScript
|
|
346
346
|
import {defineTypedEvent} from 'element-vir';
|
|
@@ -352,13 +352,13 @@ export const MyCustomActionEvent = defineTypedEvent<number>()('my-custom-action'
|
|
|
352
352
|
|
|
353
353
|
Dispatching a custom event and listening to a custom event is the same as doing so for element events:
|
|
354
354
|
|
|
355
|
-
<!-- example-link: src/readme-examples/my-with-custom-events.
|
|
355
|
+
<!-- example-link: src/readme-examples/my-with-custom-events.example.ts -->
|
|
356
356
|
|
|
357
357
|
```TypeScript
|
|
358
358
|
import {randomInteger} from '@augment-vir/common';
|
|
359
359
|
import {defineElement} from 'element-vir';
|
|
360
360
|
import {html, listen} from 'element-vir';
|
|
361
|
-
import {MyCustomActionEvent} from './my-custom-action.
|
|
361
|
+
import {MyCustomActionEvent} from './my-custom-action.example.js';
|
|
362
362
|
|
|
363
363
|
export const MyWithCustomEvents = defineElement()({
|
|
364
364
|
tagName: 'my-with-custom-events',
|
|
@@ -400,7 +400,7 @@ Host classes are defined by passing an object to `hostClasses` at element defini
|
|
|
400
400
|
|
|
401
401
|
Apply host classes in the element's stylesheet by using a callback for the styles property:
|
|
402
402
|
|
|
403
|
-
<!-- example-link: src/readme-examples/my-with-host-class-definition.
|
|
403
|
+
<!-- example-link: src/readme-examples/my-with-host-class-definition.example.ts -->
|
|
404
404
|
|
|
405
405
|
```TypeScript
|
|
406
406
|
import {defineElement} from 'element-vir';
|
|
@@ -452,12 +452,12 @@ export const MyWithHostClassDefinition = defineElement()({
|
|
|
452
452
|
|
|
453
453
|
To apply a host class in a consumer, access the child element's `.hostClasses` property:
|
|
454
454
|
|
|
455
|
-
<!-- example-link: src/readme-examples/my-with-host-class-usage.
|
|
455
|
+
<!-- example-link: src/readme-examples/my-with-host-class-usage.example.ts -->
|
|
456
456
|
|
|
457
457
|
```TypeScript
|
|
458
458
|
import {defineElement} from 'element-vir';
|
|
459
459
|
import {html} from 'element-vir';
|
|
460
|
-
import {MyWithHostClassDefinition} from './my-with-host-class-definition.
|
|
460
|
+
import {MyWithHostClassDefinition} from './my-with-host-class-definition.example.js';
|
|
461
461
|
|
|
462
462
|
export const MyWithHostClassUsage = defineElement()({
|
|
463
463
|
tagName: 'my-with-host-class-usage',
|
|
@@ -475,7 +475,7 @@ export const MyWithHostClassUsage = defineElement()({
|
|
|
475
475
|
|
|
476
476
|
Typed CSS variables are created in a similar manner to host classes:
|
|
477
477
|
|
|
478
|
-
<!-- example-link: src/readme-examples/my-with-css-vars.
|
|
478
|
+
<!-- example-link: src/readme-examples/my-with-css-vars.example.ts -->
|
|
479
479
|
|
|
480
480
|
```TypeScript
|
|
481
481
|
import {defineElement} from 'element-vir';
|
|
@@ -510,7 +510,7 @@ export const MyWithCssVars = defineElement()({
|
|
|
510
510
|
|
|
511
511
|
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:
|
|
512
512
|
|
|
513
|
-
<!-- example-link: src/readme-examples/my-custom-define.ts -->
|
|
513
|
+
<!-- example-link: src/readme-examples/my-custom-define.example.ts -->
|
|
514
514
|
|
|
515
515
|
```TypeScript
|
|
516
516
|
import {wrapDefineElement} from 'element-vir';
|
|
@@ -523,7 +523,7 @@ export const defineVirElement = wrapDefineElement<VirTagName>();
|
|
|
523
523
|
export const defineVerifiedVirElement = wrapDefineElement<VirTagName>({
|
|
524
524
|
assertInputs: (inputs) => {
|
|
525
525
|
if (!inputs.tagName.startsWith('vir-')) {
|
|
526
|
-
throw new Error(
|
|
526
|
+
throw new Error('all custom elements must start with "vir-"');
|
|
527
527
|
}
|
|
528
528
|
},
|
|
529
529
|
});
|
|
@@ -549,7 +549,7 @@ All [built-in `lit` directives](https://lit.dev/docs/templates/directives/) are
|
|
|
549
549
|
|
|
550
550
|
This triggers only once when the element it's attached to has actually been created in the DOM. If the attached element changes, the callback will be triggered again.
|
|
551
551
|
|
|
552
|
-
<!-- example-link: src/readme-examples/my-with-on-dom-created.
|
|
552
|
+
<!-- example-link: src/readme-examples/my-with-on-dom-created.example.ts -->
|
|
553
553
|
|
|
554
554
|
```TypeScript
|
|
555
555
|
import {defineElement} from 'element-vir';
|
|
@@ -576,7 +576,7 @@ export const MyWithOnDomCreated = defineElement()({
|
|
|
576
576
|
|
|
577
577
|
This directive fires its callback whenever the element it's attached to resizes. The callback is passed an object with a portion of the [`ResizeObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry) properties.
|
|
578
578
|
|
|
579
|
-
<!-- example-link: src/readme-examples/my-with-on-resize.
|
|
579
|
+
<!-- example-link: src/readme-examples/my-with-on-resize.example.ts -->
|
|
580
580
|
|
|
581
581
|
```TypeScript
|
|
582
582
|
import {defineElement} from 'element-vir';
|
|
@@ -608,7 +608,7 @@ Listen to a specific event. This is explained in the **Listening to element even
|
|
|
608
608
|
|
|
609
609
|
Use the `renderIf` directive to easily render a template if a given condition is true.
|
|
610
610
|
|
|
611
|
-
<!-- example-link: src/readme-examples/my-with-render-if.
|
|
611
|
+
<!-- example-link: src/readme-examples/my-with-render-if.example.ts -->
|
|
612
612
|
|
|
613
613
|
```TypeScript
|
|
614
614
|
import {defineElement, html, renderIf} from 'element-vir';
|
|
@@ -632,7 +632,7 @@ export const MyWithRenderIf = defineElement<{shouldRender: boolean}>()({
|
|
|
632
632
|
|
|
633
633
|
Use `renderAsync` or `isResolved` in conjunction with `asyncProp` to seamlessly render and update element state based on async values:
|
|
634
634
|
|
|
635
|
-
<!-- example-link: src/readme-examples/my-with-async-prop.
|
|
635
|
+
<!-- example-link: src/readme-examples/my-with-async-prop.example.ts -->
|
|
636
636
|
|
|
637
637
|
```TypeScript
|
|
638
638
|
import {asyncProp, defineElement, html, listen, renderAsync} from 'element-vir';
|
|
@@ -694,18 +694,6 @@ export const MyWithAsyncProp = defineElement<{endpoint: string}>()({
|
|
|
694
694
|
});
|
|
695
695
|
```
|
|
696
696
|
|
|
697
|
-
## Require all child custom elements to be declarative elements
|
|
698
|
-
|
|
699
|
-
To require all child elements to be declarative elements defined by this package, call `requireAllCustomElementsToBeDeclarativeElements` anywhere in your app. This is a global setting so do not enable it unless you want it to be true _everywhere_ in your current run-time. This should not be used if you're using custom elements from other libraries (unless they happen to also use this package to define their custom elements).
|
|
700
|
-
|
|
701
|
-
<!-- example-link: src/readme-examples/require-declarative-element.ts -->
|
|
702
|
-
|
|
703
|
-
```TypeScript
|
|
704
|
-
import {requireAllCustomElementsToBeDeclarativeElements} from 'element-vir';
|
|
705
|
-
|
|
706
|
-
requireAllCustomElementsToBeDeclarativeElements();
|
|
707
|
-
```
|
|
708
|
-
|
|
709
697
|
# Dev
|
|
710
698
|
|
|
711
699
|
## markdown out of date
|
|
@@ -14,17 +14,23 @@ import { type InitCallback, type RenderCallback, type RenderParams } from './ren
|
|
|
14
14
|
*
|
|
15
15
|
* @category Internal
|
|
16
16
|
*/
|
|
17
|
-
export type DeclarativeElementInit<TagName extends CustomElementTagName, Inputs extends PropertyInitMapBase, State extends PropertyInitMapBase, EventsInit extends EventsInitMap, HostClassKeys extends BaseStringName<TagName
|
|
17
|
+
export type DeclarativeElementInit<TagName extends CustomElementTagName, Inputs extends PropertyInitMapBase, State extends PropertyInitMapBase, EventsInit extends EventsInitMap, HostClassKeys extends BaseStringName<NoInfer<TagName>>, CssVarKeys extends BaseStringName<NoInfer<TagName>>, SlotNames extends ReadonlyArray<string>, TestIds extends ReadonlyArray<string>> = {
|
|
18
18
|
/**
|
|
19
19
|
* HTML tag name. This should not be used directly, as interpolating it with the html tagged
|
|
20
20
|
* template from this package is preferred.
|
|
21
21
|
*/
|
|
22
22
|
tagName: TagName;
|
|
23
23
|
/** Static styles. These should not and cannot change. */
|
|
24
|
-
styles?: CSSResult | StylesCallback<TagName, HostClassKeys, CssVarKeys> | undefined;
|
|
24
|
+
styles?: CSSResult | StylesCallback<TagName, HostClassKeys, CssVarKeys, SlotNames> | undefined;
|
|
25
25
|
/** Events that the element can dispatch. (These can be thought of as "outputs".) */
|
|
26
26
|
events?: EventsInit | undefined;
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* An array of slot names that for type safe usage in rendering HTML, CSS, and in consumers for
|
|
29
|
+
* assigning slots. Each slot name must be prefixed with the element's tag name. This prefix is
|
|
30
|
+
* enforced at compile time only: runtimes accept any strings so existing consumers do not
|
|
31
|
+
* break.
|
|
32
|
+
*/
|
|
33
|
+
slotNames?: (SlotNames & ReadonlyArray<BaseStringName<TagName>>) | undefined;
|
|
28
34
|
testIds?: TestIds | undefined;
|
|
29
35
|
/**
|
|
30
36
|
* HTML host classes. Values can be callbacks to determine when a host class should be defined,
|
|
@@ -10,7 +10,7 @@ import { type EventDescriptorMap, type EventsInitMap } from './properties/elemen
|
|
|
10
10
|
import { type PropertyInitMapBase } from './properties/element-properties.js';
|
|
11
11
|
import { type HostClassNamesMap } from './properties/host-classes.js';
|
|
12
12
|
import { type ObservableListenerMap } from './properties/property-proxy.js';
|
|
13
|
-
import { type BaseStringName, type StringNameMap } from './properties/string-names.js';
|
|
13
|
+
import { type BaseStringName, type SlotNamesMap, type StringNameMap } from './properties/string-names.js';
|
|
14
14
|
import { type RenderCallback, type RenderParams, type UpdateStateCallback } from './render-callback.js';
|
|
15
15
|
/**
|
|
16
16
|
* The `host` type for a declarative element. This references a declarative element instance's
|
|
@@ -18,13 +18,13 @@ import { type RenderCallback, type RenderParams, type UpdateStateCallback } from
|
|
|
18
18
|
*
|
|
19
19
|
* @category Internal
|
|
20
20
|
*/
|
|
21
|
-
export type DeclarativeElementHost<TagName extends CustomElementTagName = any, Inputs extends PropertyInitMapBase = any, State extends PropertyInitMapBase = any, EventsInit extends EventsInitMap = any, HostClassKeys extends BaseStringName<TagName
|
|
21
|
+
export type DeclarativeElementHost<TagName extends CustomElementTagName = any, Inputs extends PropertyInitMapBase = any, State extends PropertyInitMapBase = any, EventsInit extends EventsInitMap = any, HostClassKeys extends BaseStringName<NoInfer<TagName>> = any, CssVarKeys extends BaseStringName<NoInfer<TagName>> = any, SlotNames extends ReadonlyArray<string> = any, TestIds extends ReadonlyArray<string> = any> = SetRequiredAndNotNull<Omit<DeclarativeElement<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds>, Exclude<keyof StaticDeclarativeElementProperties<any, any, any, any, any, any, any, any>, keyof HTMLElement>>, 'shadowRoot'>;
|
|
22
22
|
/**
|
|
23
23
|
* The full definition for a declarative element.
|
|
24
24
|
*
|
|
25
25
|
* @category Internal
|
|
26
26
|
*/
|
|
27
|
-
export type DeclarativeElementDefinition<TagName extends CustomElementTagName = any, Inputs extends PropertyInitMapBase = any, State extends PropertyInitMapBase = any, EventsInit extends EventsInitMap = any, HostClassKeys extends BaseStringName<TagName
|
|
27
|
+
export type DeclarativeElementDefinition<TagName extends CustomElementTagName = any, Inputs extends PropertyInitMapBase = any, State extends PropertyInitMapBase = any, EventsInit extends EventsInitMap = any, HostClassKeys extends BaseStringName<NoInfer<TagName>> = any, CssVarKeys extends BaseStringName<NoInfer<TagName>> = any, SlotNames extends ReadonlyArray<string> = any, TestIds extends ReadonlyArray<string> = any> = (new () => DeclarativeElementHost<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds>) & StaticDeclarativeElementProperties<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds> & {
|
|
28
28
|
InstanceType: DeclarativeElementHost<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds>;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
@@ -32,7 +32,7 @@ export type DeclarativeElementDefinition<TagName extends CustomElementTagName =
|
|
|
32
32
|
*
|
|
33
33
|
* @category Internal
|
|
34
34
|
*/
|
|
35
|
-
export declare abstract class DeclarativeElement<TagName extends CustomElementTagName = any, Inputs extends PropertyInitMapBase = any, State extends PropertyInitMapBase = any, EventsInit extends EventsInitMap = any, HostClassKeys extends BaseStringName<TagName
|
|
35
|
+
export declare abstract class DeclarativeElement<TagName extends CustomElementTagName = any, Inputs extends PropertyInitMapBase = any, State extends PropertyInitMapBase = any, EventsInit extends EventsInitMap = any, HostClassKeys extends BaseStringName<NoInfer<TagName>> = any, CssVarKeys extends BaseStringName<NoInfer<TagName>> = any, SlotNames extends ReadonlyArray<string> = any, TestIds extends ReadonlyArray<string> = any> extends LitElement {
|
|
36
36
|
/**
|
|
37
37
|
* Assign inputs to an element instantiation. Use only on the opening tag.
|
|
38
38
|
*
|
|
@@ -93,14 +93,14 @@ export type AssignMethod<TagName extends CustomElementTagName, Inputs extends Pr
|
|
|
93
93
|
*
|
|
94
94
|
* @category Internal
|
|
95
95
|
*/
|
|
96
|
-
export type StaticDeclarativeElementProperties<TagName extends CustomElementTagName, Inputs extends PropertyInitMapBase, State extends PropertyInitMapBase, EventsInit extends EventsInitMap, HostClassKeys extends BaseStringName<TagName
|
|
96
|
+
export type StaticDeclarativeElementProperties<TagName extends CustomElementTagName, Inputs extends PropertyInitMapBase, State extends PropertyInitMapBase, EventsInit extends EventsInitMap, HostClassKeys extends BaseStringName<NoInfer<TagName>>, CssVarKeys extends BaseStringName<NoInfer<TagName>>, SlotNames extends ReadonlyArray<string>, TestIds extends ReadonlyArray<string>> = {
|
|
97
97
|
/** Assign inputs to an element directly on its interpolated tag. */
|
|
98
98
|
readonly assign: AssignMethod<TagName, Inputs>;
|
|
99
99
|
assignedInputs: Inputs | undefined;
|
|
100
100
|
/** Pass through the render callback for direct unit testability */
|
|
101
101
|
readonly render: RenderCallback<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds>;
|
|
102
102
|
readonly events: EventDescriptorMap<TagName, EventsInit>;
|
|
103
|
-
readonly slotNames:
|
|
103
|
+
readonly slotNames: SlotNamesMap<TagName, SlotNames>;
|
|
104
104
|
readonly testIds: Readonly<StringNameMap<TagName, 'test-id', TestIds>>;
|
|
105
105
|
readonly init: DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds>;
|
|
106
106
|
readonly elementOptions: DeclarativeElementDefinitionOptions;
|
|
@@ -38,4 +38,4 @@ export declare function defineElement<Inputs extends PropertyInitMapBase = {}>(
|
|
|
38
38
|
* These `errorParams` is present when there are problems with the `Inputs` type. If it is
|
|
39
39
|
* present, the error should be fixed. This should always be empty.
|
|
40
40
|
*/
|
|
41
|
-
...errorParams: DeclarativeElementInputErrorParams<Inputs>): <const TagName extends CustomElementTagName, State extends PropertyInitMapBase = {}, EventsInit extends EventsInitMap = {}, const HostClassKeys extends BaseStringName<TagName
|
|
41
|
+
...errorParams: DeclarativeElementInputErrorParams<Inputs>): <const TagName extends CustomElementTagName, State extends PropertyInitMapBase = {}, EventsInit extends EventsInitMap = {}, const HostClassKeys extends BaseStringName<NoInfer<TagName>> = `${NoInfer<TagName>}-`, const CssVarKeys extends BaseStringName<NoInfer<TagName>> = `${NoInfer<TagName>}-`, const SlotNames extends ReadonlyArray<string> = Readonly<[]>, const TestIds extends ReadonlyArray<string> = Readonly<[]>>(initInput: DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds>) => DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds>;
|
|
@@ -9,7 +9,7 @@ import { assignInputs } from './properties/assign-inputs.js';
|
|
|
9
9
|
import { createEventDescriptorMap, } from './properties/element-events.js';
|
|
10
10
|
import { createHostClassNamesMap } from './properties/host-classes.js';
|
|
11
11
|
import { bindReactiveProperty, createElementPropertyProxy } from './properties/property-proxy.js';
|
|
12
|
-
import { assertValidStringNames, createStringNameMap, } from './properties/string-names.js';
|
|
12
|
+
import { assertValidStringNames, createSlotNamesMap, createStringNameMap, } from './properties/string-names.js';
|
|
13
13
|
import { applyHostClasses, createStylesCallbackInput } from './properties/styles.js';
|
|
14
14
|
import { createRenderParams } from './render-callback.js';
|
|
15
15
|
/**
|
|
@@ -42,7 +42,7 @@ export function defineElement(
|
|
|
42
42
|
return (initInput) => {
|
|
43
43
|
const init = initInput;
|
|
44
44
|
if (!check.isObject(init)) {
|
|
45
|
-
throw new TypeError(
|
|
45
|
+
throw new TypeError(`Cannot define element with non-object init: ${String(init)}`);
|
|
46
46
|
}
|
|
47
47
|
return internalDefineElement({
|
|
48
48
|
...init,
|
|
@@ -54,7 +54,7 @@ export function defineElement(
|
|
|
54
54
|
}
|
|
55
55
|
function internalDefineElement(init) {
|
|
56
56
|
if (!check.isObject(init)) {
|
|
57
|
-
throw new TypeError(
|
|
57
|
+
throw new TypeError(`Cannot define element with non-object init: ${String(init)}`);
|
|
58
58
|
}
|
|
59
59
|
else if (!check.isString(init.tagName)) {
|
|
60
60
|
throw new TypeError('Missing valid tagName (expected a string).');
|
|
@@ -70,10 +70,10 @@ function internalDefineElement(init) {
|
|
|
70
70
|
const eventsMap = createEventDescriptorMap(init.tagName, init.events);
|
|
71
71
|
const hostClassNames = createHostClassNamesMap(init.hostClasses);
|
|
72
72
|
if (init.hostClasses) {
|
|
73
|
-
assertValidStringNames(init.tagName, init.hostClasses);
|
|
73
|
+
assertValidStringNames(init.tagName, Object.keys(init.hostClasses));
|
|
74
74
|
}
|
|
75
75
|
if (init.cssVars) {
|
|
76
|
-
assertValidStringNames(init.tagName, init.cssVars);
|
|
76
|
+
assertValidStringNames(init.tagName, Object.keys(init.cssVars));
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* As casts here are to prevent defineCssVars from complaining that our CSS var names are too
|
|
@@ -82,12 +82,13 @@ function internalDefineElement(init) {
|
|
|
82
82
|
* specific types externally.)
|
|
83
83
|
*/
|
|
84
84
|
const cssVars = (init.cssVars ? defineCssVars(init.cssVars) : {});
|
|
85
|
-
const slotNamesMap =
|
|
85
|
+
const slotNamesMap = createSlotNamesMap(init.tagName, init.slotNames);
|
|
86
86
|
const testIdsMap = createStringNameMap(init.tagName, 'test-id', init.testIds);
|
|
87
87
|
const calculatedStyles = typeof init.styles === 'function'
|
|
88
88
|
? init.styles(createStylesCallbackInput({
|
|
89
89
|
hostClassNames,
|
|
90
90
|
cssVars,
|
|
91
|
+
slotNamesMap,
|
|
91
92
|
}))
|
|
92
93
|
: init.styles || css ``;
|
|
93
94
|
const typedRenderCallback = init.render;
|
|
@@ -147,7 +148,7 @@ function internalDefineElement(init) {
|
|
|
147
148
|
this._stateCalled = true;
|
|
148
149
|
const stateInit = init.state(renderParams);
|
|
149
150
|
if (stateInit instanceof Promise) {
|
|
150
|
-
throw new TypeError('
|
|
151
|
+
throw new TypeError('state cannot be asynchronous');
|
|
151
152
|
}
|
|
152
153
|
getObjectTypedKeys(stateInit).forEach((stateKey) => {
|
|
153
154
|
bindReactiveProperty(this, stateKey);
|
|
@@ -205,18 +206,27 @@ function internalDefineElement(init) {
|
|
|
205
206
|
stateValue.destroy();
|
|
206
207
|
}
|
|
207
208
|
});
|
|
209
|
+
this._initCalled = false;
|
|
210
|
+
this._stateCalled = false;
|
|
208
211
|
}
|
|
209
212
|
disconnectedCallback() {
|
|
210
213
|
super.disconnectedCallback();
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
214
|
+
/**
|
|
215
|
+
* Always reset bookkeeping and run `destroy()`, even when `cleanup` throws — otherwise
|
|
216
|
+
* a throwing cleanup leaves `_initCalled` / `_stateCalled` stuck and corrupts the next
|
|
217
|
+
* mount.
|
|
218
|
+
*/
|
|
219
|
+
try {
|
|
220
|
+
if (init.cleanup && this._stateCalled) {
|
|
221
|
+
const renderParams = this.createRenderParams();
|
|
222
|
+
if (init.cleanup(renderParams) instanceof Promise) {
|
|
223
|
+
throw new TypeError(`cleanup in '${init.tagName}' cannot be asynchronous`);
|
|
224
|
+
}
|
|
215
225
|
}
|
|
216
226
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
227
|
+
finally {
|
|
228
|
+
this.destroy();
|
|
229
|
+
}
|
|
220
230
|
}
|
|
221
231
|
// this is set below in Object.defineProperties
|
|
222
232
|
definition = {};
|
|
@@ -29,9 +29,5 @@ export function assertIsElementPartInfo(partInfo, directiveName) {
|
|
|
29
29
|
const hostTagMessage = hostTagName ? `: in ${hostTagName}` : '';
|
|
30
30
|
if (partInfo.type !== PartType.ELEMENT) {
|
|
31
31
|
throw new Error(`${directiveName} directive can only be attached directly to an element${hostTagMessage}.`);
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
33
|
-
}
|
|
34
|
-
else if (!partInfo.element) {
|
|
35
|
-
throw new Error(`${directiveName} directive found no element${hostTagMessage}.`);
|
|
36
32
|
}
|
|
37
33
|
}
|
|
@@ -59,6 +59,11 @@ export declare const onIntersect: (options: IntersectionObserverInit, callback:
|
|
|
59
59
|
fireCallback(entries: IntersectionObserverEntry[], observer: IntersectionObserver): void;
|
|
60
60
|
update(partInfo: PartInfo, [options, callback,]: [OnIntersectOptions, OnIntersectCallback]): undefined;
|
|
61
61
|
render(options: OnIntersectOptions, callback: OnIntersectCallback): undefined;
|
|
62
|
+
disconnected(): void;
|
|
63
|
+
reconnected(): void;
|
|
64
|
+
isConnected: boolean;
|
|
65
|
+
_$initialize(part: import("lit-html").Part, parent: import("lit-html").Disconnectable, attributeIndex: number | undefined): void;
|
|
66
|
+
setValue(value: unknown): void;
|
|
62
67
|
get _$isConnected(): boolean;
|
|
63
68
|
};
|
|
64
69
|
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert, assertWrap, check } from '@augment-vir/assert';
|
|
2
|
-
import {
|
|
2
|
+
import { AsyncDirective, directive } from '../../lit-exports/all-lit-exports.js';
|
|
3
3
|
import { assertIsElementPartInfo } from './directive-helpers.js';
|
|
4
4
|
const directiveName = 'onIntersect';
|
|
5
5
|
/**
|
|
@@ -35,7 +35,7 @@ const directiveName = 'onIntersect';
|
|
|
35
35
|
* });
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
export const onIntersect = directive(class extends
|
|
38
|
+
export const onIntersect = directive(class extends AsyncDirective {
|
|
39
39
|
element;
|
|
40
40
|
options;
|
|
41
41
|
intersectionObserver;
|
|
@@ -86,4 +86,12 @@ export const onIntersect = directive(class extends Directive {
|
|
|
86
86
|
render(options, callback) {
|
|
87
87
|
return undefined;
|
|
88
88
|
}
|
|
89
|
+
disconnected() {
|
|
90
|
+
this.intersectionObserver?.disconnect();
|
|
91
|
+
}
|
|
92
|
+
reconnected() {
|
|
93
|
+
if (this.element && this.intersectionObserver) {
|
|
94
|
+
this.intersectionObserver.observe(this.element);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
89
97
|
});
|
|
@@ -42,6 +42,11 @@ export declare const onResize: (callback: OnResizeCallback) => import("lit-html/
|
|
|
42
42
|
callback: OnResizeCallback | undefined;
|
|
43
43
|
update(partInfo: PartInfo, [callback]: [OnResizeCallback]): undefined;
|
|
44
44
|
render(callback: OnResizeCallback): undefined;
|
|
45
|
+
disconnected(): void;
|
|
46
|
+
reconnected(): void;
|
|
47
|
+
isConnected: boolean;
|
|
48
|
+
_$initialize(part: import("lit-html").Part, parent: import("lit-html").Disconnectable, attributeIndex: number | undefined): void;
|
|
49
|
+
setValue(value: unknown): void;
|
|
45
50
|
get _$isConnected(): boolean;
|
|
46
51
|
};
|
|
47
52
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AsyncDirective, directive } from '../../lit-exports/all-lit-exports.js';
|
|
2
2
|
import { assertIsElementPartInfo } from './directive-helpers.js';
|
|
3
3
|
const directiveName = 'onResize';
|
|
4
4
|
/**
|
|
@@ -28,7 +28,7 @@ const directiveName = 'onResize';
|
|
|
28
28
|
* });
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
export const onResize = directive(class extends
|
|
31
|
+
export const onResize = directive(class extends AsyncDirective {
|
|
32
32
|
element;
|
|
33
33
|
resizeObserver = new ResizeObserver((entries) => {
|
|
34
34
|
if (this.element && this.callback) {
|
|
@@ -59,12 +59,20 @@ export const onResize = directive(class extends Directive {
|
|
|
59
59
|
render(callback) {
|
|
60
60
|
return undefined;
|
|
61
61
|
}
|
|
62
|
+
disconnected() {
|
|
63
|
+
this.resizeObserver.disconnect();
|
|
64
|
+
}
|
|
65
|
+
reconnected() {
|
|
66
|
+
if (this.element) {
|
|
67
|
+
this.resizeObserver.observe(this.element);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
62
70
|
});
|
|
63
71
|
function handleOnResizeCallback(element, callback, entries) {
|
|
64
72
|
const resizeEntry = entries[0];
|
|
65
73
|
if (!resizeEntry) {
|
|
66
74
|
console.error(entries);
|
|
67
|
-
throw new Error(
|
|
75
|
+
throw new Error('Resize observation triggered but the first entry was empty.');
|
|
68
76
|
}
|
|
69
77
|
void callback({
|
|
70
78
|
target: resizeEntry.target,
|
|
@@ -47,7 +47,7 @@ export function createEventDescriptorMap(tagName, eventsInit) {
|
|
|
47
47
|
throw new TypeError(`Expected event key of type string but got type '${typeof currentElementEventKey}' for key ${String(currentElementEventKey)}`);
|
|
48
48
|
}
|
|
49
49
|
else if (currentElementEventKey === '') {
|
|
50
|
-
throw new Error(
|
|
50
|
+
throw new Error('Got empty string for events key.');
|
|
51
51
|
}
|
|
52
52
|
return true;
|
|
53
53
|
})
|
|
@@ -77,7 +77,7 @@ export function createElementPropertyProxy(element, shouldAlreadyExist) {
|
|
|
77
77
|
}
|
|
78
78
|
else if (isObservableBase(oldValue)) {
|
|
79
79
|
/** Clear out old listener that is no longer used. */
|
|
80
|
-
element.observablePropertyListenerMap[propertyKey]
|
|
80
|
+
delete element.observablePropertyListenerMap[propertyKey];
|
|
81
81
|
}
|
|
82
82
|
setValueOnElement(newValue);
|
|
83
83
|
return true;
|
|
@@ -11,7 +11,7 @@ export type BaseStringName<ElementTagName extends CustomElementTagName> = `${Ele
|
|
|
11
11
|
*
|
|
12
12
|
* @category Internal
|
|
13
13
|
*/
|
|
14
|
-
export declare function assertValidStringNames(elementTagName: CustomElementTagName, stringNames:
|
|
14
|
+
export declare function assertValidStringNames(elementTagName: CustomElementTagName, stringNames: ReadonlyArray<string>): void;
|
|
15
15
|
/**
|
|
16
16
|
* Type safe mapping of string names to themself with the element tag name inserted.
|
|
17
17
|
*
|
|
@@ -26,3 +26,23 @@ export type StringNameMap<ElementTagName extends CustomElementTagName, NameType
|
|
|
26
26
|
* @category Internal
|
|
27
27
|
*/
|
|
28
28
|
export declare function createStringNameMap<ElementTagName extends CustomElementTagName, NameType extends string, StringNames extends ReadonlyArray<string>>(elementTagName: ElementTagName, nameType: NameType, stringNames: StringNames | undefined): StringNameMap<ElementTagName, NameType, StringNames>;
|
|
29
|
+
/**
|
|
30
|
+
* Map of slot names to their runtime values. Slot names that already start with the element's tag
|
|
31
|
+
* name are kept as-is; legacy slot names without the tag-name prefix are auto-rewritten at runtime
|
|
32
|
+
* to `${ElementTagName}-slot-${Name}` and this type reflects that.
|
|
33
|
+
*
|
|
34
|
+
* @category Internal
|
|
35
|
+
*/
|
|
36
|
+
export type SlotNamesMap<ElementTagName extends string, SlotNames extends ReadonlyArray<string>> = Readonly<{
|
|
37
|
+
[Name in ArrayElement<SlotNames>]: Name extends `${ElementTagName}-${string}` ? Name : `${ElementTagName}-slot-${Name}`;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Converts an array of slot names into a {@link SlotNamesMap}.
|
|
41
|
+
*
|
|
42
|
+
* Slot names that start with the element's tag name pass through unchanged. Slot names that do not
|
|
43
|
+
* are transformed into the legacy `${tagName}-slot-${name}` format so existing elements that
|
|
44
|
+
* pre-date the tag prefix convention keep working.
|
|
45
|
+
*
|
|
46
|
+
* @category Internal
|
|
47
|
+
*/
|
|
48
|
+
export declare function createSlotNamesMap<ElementTagName extends CustomElementTagName, SlotNames extends ReadonlyArray<string>>(elementTagName: ElementTagName, slotNames: SlotNames | undefined): SlotNamesMap<ElementTagName, SlotNames>;
|
|
@@ -9,7 +9,7 @@ export function assertValidStringNames(elementTagName, stringNames) {
|
|
|
9
9
|
elementTagName,
|
|
10
10
|
'-',
|
|
11
11
|
].join('');
|
|
12
|
-
|
|
12
|
+
stringNames.forEach((stringName) => {
|
|
13
13
|
if (!stringName.startsWith(requiredNameStart)) {
|
|
14
14
|
throw new Error(`Invalid element string name '${stringName}' in '${elementTagName}': element string names must begin with the element's tag name.`);
|
|
15
15
|
}
|
|
@@ -38,3 +38,37 @@ export function createStringNameMap(elementTagName, nameType, stringNames) {
|
|
|
38
38
|
});
|
|
39
39
|
return stringNameMap;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Converts an array of slot names into a {@link SlotNamesMap}.
|
|
43
|
+
*
|
|
44
|
+
* Slot names that start with the element's tag name pass through unchanged. Slot names that do not
|
|
45
|
+
* are transformed into the legacy `${tagName}-slot-${name}` format so existing elements that
|
|
46
|
+
* pre-date the tag prefix convention keep working.
|
|
47
|
+
*
|
|
48
|
+
* @category Internal
|
|
49
|
+
*/
|
|
50
|
+
export function createSlotNamesMap(elementTagName, slotNames) {
|
|
51
|
+
if (!slotNames) {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
const requiredNameStart = [
|
|
55
|
+
elementTagName,
|
|
56
|
+
'-',
|
|
57
|
+
].join('');
|
|
58
|
+
const slotNamesMap = arrayToObject(slotNames, (slotName) => {
|
|
59
|
+
const value = slotName.startsWith(requiredNameStart)
|
|
60
|
+
? slotName
|
|
61
|
+
: [
|
|
62
|
+
elementTagName,
|
|
63
|
+
'slot',
|
|
64
|
+
slotName,
|
|
65
|
+
].join('-');
|
|
66
|
+
return {
|
|
67
|
+
key: slotName,
|
|
68
|
+
value,
|
|
69
|
+
};
|
|
70
|
+
}, {
|
|
71
|
+
useRequired: true,
|
|
72
|
+
});
|
|
73
|
+
return slotNamesMap;
|
|
74
|
+
}
|