element-vir 0.0.5 → 0.2.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 +48 -24
- package/dist/functional-element/define-functional-element.d.ts +1 -2
- package/dist/functional-element/define-functional-element.js +0 -23
- package/dist/functional-element/directives/assign-with-clean-up.directive.d.ts +17 -0
- package/dist/functional-element/directives/assign-with-clean-up.directive.js +28 -0
- package/dist/functional-element/directives/{property-assign.directive.d.ts → assign.directive.d.ts} +1 -9
- package/dist/functional-element/directives/{property-assign.directive.js → assign.directive.js} +2 -2
- package/dist/functional-element/directives/directive-util.d.ts +12 -2
- package/dist/functional-element/directives/directive-util.js +11 -5
- package/dist/functional-element/directives/{event-listen.directive.d.ts → listen.directive.d.ts} +0 -0
- package/dist/functional-element/directives/{event-listen.directive.js → listen.directive.js} +1 -1
- package/dist/functional-element/directives/on-dom-created.directive.d.ts +11 -0
- package/dist/functional-element/directives/on-dom-created.directive.js +22 -0
- package/dist/functional-element/directives/on-resize.directive.d.ts +15 -0
- package/dist/functional-element/directives/on-resize.directive.js +36 -0
- package/dist/functional-element/functional-element.d.ts +14 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/package.json +1 -1
- package/dist/functional-element/functional-element-init.d.ts +0 -22
- package/dist/functional-element/functional-element-init.js +0 -1
- package/dist/functional-element/lifecycle-callback.d.ts +0 -8
- package/dist/functional-element/lifecycle-callback.js +0 -1
- package/dist/vir-html/directive.d.ts +0 -9
- package/dist/vir-html/directive.js +0 -1
package/README.md
CHANGED
|
@@ -28,6 +28,8 @@ npm i element-vir
|
|
|
28
28
|
|
|
29
29
|
Most usage of this package is done through the [`defineFunctionalElement` function](https://github.com/electrovir/element-vir/blob/main/src/functional-element/define-functional-element.ts#L25-L30). See the [`FunctionalElementInit` type](https://github.com/electrovir/element-vir/blob/main/src/functional-element/functional-element-init.ts#L7-L20) for that function's inputs. These inputs are also described below with examples.
|
|
30
30
|
|
|
31
|
+
All of [`lit`](https://lit.dev)'s syntax and functionality is also available for use.
|
|
32
|
+
|
|
31
33
|
## Simple element definition
|
|
32
34
|
|
|
33
35
|
Use `defineFunctionalElement` to define your element. This is apparent if you inspect the types but it must be given an object with at least `tagName` and `renderCallback` properties. This is a bare-minimum example custom element:
|
|
@@ -206,35 +208,57 @@ export const MyAppWithEventsElement = defineFunctionalElement({
|
|
|
206
208
|
});
|
|
207
209
|
```
|
|
208
210
|
|
|
209
|
-
##
|
|
211
|
+
## Directives
|
|
212
|
+
|
|
213
|
+
Some custom [`lit` directives](https://lit.dev/docs/templates/custom-directives/) are also contained within this package.
|
|
214
|
+
|
|
215
|
+
### onDomCreate
|
|
216
|
+
|
|
217
|
+
This directive should be used instead of trying to use `querySelector` directly on the custom element.
|
|
210
218
|
|
|
211
|
-
|
|
219
|
+
This triggers only once when the element it's contained within is created in the DOM. If it's containing element changes, the callback will be triggered again.
|
|
212
220
|
|
|
213
|
-
<!-- src/readme-examples/my-simple-with-
|
|
221
|
+
<!-- src/readme-examples/my-simple-with-on-dom-created.element.ts -->
|
|
214
222
|
|
|
215
223
|
```typescript
|
|
216
|
-
import {defineFunctionalElement, html} from 'element-vir';
|
|
224
|
+
import {defineFunctionalElement, html, onDomCreated} from 'element-vir';
|
|
217
225
|
|
|
218
|
-
export const
|
|
219
|
-
tagName: 'my-simple-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
226
|
+
export const MySimpleWithOnDomCreatedElement = defineFunctionalElement({
|
|
227
|
+
tagName: 'my-simple-with-on-dom-created-element',
|
|
228
|
+
renderCallback: () => html`
|
|
229
|
+
<span
|
|
230
|
+
${onDomCreated((element) => {
|
|
231
|
+
// logs a span element
|
|
232
|
+
console.log(element);
|
|
233
|
+
})}
|
|
234
|
+
>
|
|
235
|
+
Hello there!
|
|
236
|
+
</span>
|
|
237
|
+
`,
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### onResize
|
|
242
|
+
|
|
243
|
+
This directive fulfills a common use case of triggering callbacks when something resizes. Instead of just tracking the _globally_ resizing window though, this allows you to track resizes of an individual element. The callback here is given a portion of the [`ResizeObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry) (since not all properties are supported well in browsers).
|
|
244
|
+
|
|
245
|
+
<!-- src/readme-examples/my-simple-with-on-resize.element.ts -->
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import {defineFunctionalElement, html, onResize} from 'element-vir';
|
|
249
|
+
|
|
250
|
+
export const MySimpleWithOnResizeElement = defineFunctionalElement({
|
|
251
|
+
tagName: 'my-simple-with-on-dom-created-element',
|
|
252
|
+
renderCallback: () => html`
|
|
253
|
+
<span
|
|
254
|
+
${onResize((entry) => {
|
|
255
|
+
// this will track resizing of this span
|
|
256
|
+
// the entry parameter contains target and contentRect properties
|
|
257
|
+
console.log(entry);
|
|
258
|
+
})}
|
|
259
|
+
>
|
|
260
|
+
Hello there!
|
|
261
|
+
</span>
|
|
238
262
|
`,
|
|
239
263
|
});
|
|
240
264
|
```
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EventsInitMap } from './element-events';
|
|
2
2
|
import { PropertyInitMapBase } from './element-properties';
|
|
3
|
-
import { FunctionalElementConstructor } from './functional-element';
|
|
4
|
-
import { FunctionalElementInit } from './functional-element-init';
|
|
3
|
+
import { FunctionalElementConstructor, FunctionalElementInit } from './functional-element';
|
|
5
4
|
export declare function defineFunctionalElement<EventsInitGeneric extends EventsInitMap = never, PropertyInitGeneric extends PropertyInitMapBase = never>(functionalElementInit: FunctionalElementInit<PropertyInitGeneric, EventsInitGeneric>): FunctionalElementConstructor<PropertyInitGeneric, EventsInitGeneric>;
|
|
@@ -24,29 +24,6 @@ export function defineFunctionalElement(functionalElementInit) {
|
|
|
24
24
|
render() {
|
|
25
25
|
return functionalElementInit.renderCallback(this.createRenderParams());
|
|
26
26
|
}
|
|
27
|
-
connectedCallback() {
|
|
28
|
-
var _a;
|
|
29
|
-
super.connectedCallback();
|
|
30
|
-
(_a = functionalElementInit.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(functionalElementInit, {
|
|
31
|
-
element: this,
|
|
32
|
-
...this.createRenderParams(),
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
disconnectedCallback() {
|
|
36
|
-
var _a;
|
|
37
|
-
super.disconnectedCallback();
|
|
38
|
-
(_a = functionalElementInit.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(functionalElementInit, {
|
|
39
|
-
element: this,
|
|
40
|
-
...this.createRenderParams(),
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
firstUpdated() {
|
|
44
|
-
var _a;
|
|
45
|
-
(_a = functionalElementInit.firstUpdated) === null || _a === void 0 ? void 0 : _a.call(functionalElementInit, {
|
|
46
|
-
element: this,
|
|
47
|
-
...this.createRenderParams(),
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
27
|
},
|
|
51
28
|
_a.tagName = functionalElementInit.tagName,
|
|
52
29
|
_a.styles = functionalElementInit.styles || css ``,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PartInfo } from 'lit/directive.js';
|
|
2
|
+
import { PropertyInitMapBase, StaticElementPropertyDescriptor } from '../element-properties';
|
|
3
|
+
import { FunctionalElementInstance } from '../functional-element';
|
|
4
|
+
/**
|
|
5
|
+
* The directive generics (in listenDirective) are not strong enough to maintain their values. Thus,
|
|
6
|
+
* the directive call is wrapped in this function.
|
|
7
|
+
*/
|
|
8
|
+
export declare function assignWithCleanup<PropName extends string, PropValue>(propertyDescriptor: StaticElementPropertyDescriptor<PropName, PropValue>, value: typeof propertyDescriptor['initValue'], cleanupCallback: CleanupCallback<typeof propertyDescriptor['initValue']>): import("lit-html/directive").DirectiveResult<{
|
|
9
|
+
new (partInfo: PartInfo): {
|
|
10
|
+
readonly element: FunctionalElementInstance<PropertyInitMapBase>;
|
|
11
|
+
lastValue: unknown;
|
|
12
|
+
render(propName: string, value: unknown, cleanupCallback: CleanupCallback<any>): symbol;
|
|
13
|
+
readonly _$isConnected: boolean;
|
|
14
|
+
update(_part: import("lit-html").Part, props: unknown[]): unknown;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
export declare type CleanupCallback<T> = (oldValue: T) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { noChange } from 'lit';
|
|
2
|
+
import { directive, Directive } from 'lit/directive.js';
|
|
3
|
+
import { extractFunctionalElement } from './directive-util';
|
|
4
|
+
/**
|
|
5
|
+
* The directive generics (in listenDirective) are not strong enough to maintain their values. Thus,
|
|
6
|
+
* the directive call is wrapped in this function.
|
|
7
|
+
*/
|
|
8
|
+
export function assignWithCleanup(propertyDescriptor, value, cleanupCallback) {
|
|
9
|
+
return assignWithCleanupDirective(propertyDescriptor.propName, value, cleanupCallback);
|
|
10
|
+
}
|
|
11
|
+
const assignWithCleanupDirective = directive(class extends Directive {
|
|
12
|
+
constructor(partInfo) {
|
|
13
|
+
super(partInfo);
|
|
14
|
+
this.element = extractFunctionalElement(partInfo, 'assign');
|
|
15
|
+
}
|
|
16
|
+
render(propName, value, cleanupCallback) {
|
|
17
|
+
if (!(propName in this.element.instanceProps)) {
|
|
18
|
+
throw new Error(`${this.element.tagName} element has no property of name "${propName}"`);
|
|
19
|
+
}
|
|
20
|
+
// reference equality check!
|
|
21
|
+
if (this.lastValue !== value) {
|
|
22
|
+
cleanupCallback(this.lastValue);
|
|
23
|
+
}
|
|
24
|
+
this.element.instanceProps[propName] = value;
|
|
25
|
+
this.lastValue = value;
|
|
26
|
+
return noChange;
|
|
27
|
+
}
|
|
28
|
+
});
|
package/dist/functional-element/directives/{property-assign.directive.d.ts → assign.directive.d.ts}
RENAMED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import { PartInfo } from 'lit/directive.js';
|
|
2
|
-
import { ElementEvent } from '../element-events';
|
|
3
2
|
import { PropertyInitMapBase, StaticElementPropertyDescriptor } from '../element-properties';
|
|
4
3
|
import { FunctionalElementInstance } from '../functional-element';
|
|
5
4
|
/**
|
|
6
|
-
* The directive generics (in
|
|
5
|
+
* The directive generics (in assignDirective) are not strong enough to maintain their values. Thus,
|
|
7
6
|
* the directive call is wrapped in this function.
|
|
8
7
|
*/
|
|
9
8
|
export declare function assign<PropName extends string, PropValue>(propertyDescriptor: StaticElementPropertyDescriptor<PropName, PropValue>, value: typeof propertyDescriptor['initValue']): import("lit-html/directive").DirectiveResult<{
|
|
10
9
|
new (partInfo: PartInfo): {
|
|
11
10
|
readonly element: FunctionalElementInstance<PropertyInitMapBase>;
|
|
12
|
-
lastListenerMetaData: ListenerMetaData<any> | undefined;
|
|
13
11
|
render(propName: string, value: unknown): symbol;
|
|
14
12
|
readonly _$isConnected: boolean;
|
|
15
13
|
update(_part: import("lit-html").Part, props: unknown[]): unknown;
|
|
16
14
|
};
|
|
17
15
|
}>;
|
|
18
|
-
declare type ListenerMetaData<EventDetail> = {
|
|
19
|
-
eventType: string;
|
|
20
|
-
callback: (event: ElementEvent<string, EventDetail>) => void;
|
|
21
|
-
listener: (event: any) => void;
|
|
22
|
-
};
|
|
23
|
-
export {};
|
package/dist/functional-element/directives/{property-assign.directive.js → assign.directive.js}
RENAMED
|
@@ -2,7 +2,7 @@ import { noChange } from 'lit';
|
|
|
2
2
|
import { directive, Directive } from 'lit/directive.js';
|
|
3
3
|
import { extractFunctionalElement } from './directive-util';
|
|
4
4
|
/**
|
|
5
|
-
* The directive generics (in
|
|
5
|
+
* The directive generics (in assignDirective) are not strong enough to maintain their values. Thus,
|
|
6
6
|
* the directive call is wrapped in this function.
|
|
7
7
|
*/
|
|
8
8
|
export function assign(propertyDescriptor, value) {
|
|
@@ -11,7 +11,7 @@ export function assign(propertyDescriptor, value) {
|
|
|
11
11
|
const assignDirective = directive(class extends Directive {
|
|
12
12
|
constructor(partInfo) {
|
|
13
13
|
super(partInfo);
|
|
14
|
-
this.element = extractFunctionalElement(partInfo);
|
|
14
|
+
this.element = extractFunctionalElement(partInfo, 'assign');
|
|
15
15
|
}
|
|
16
16
|
render(propName, value) {
|
|
17
17
|
if (!(propName in this.element.instanceProps)) {
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import { PartInfo } from 'lit/directive.js';
|
|
1
|
+
import { ElementPartInfo, PartInfo } from 'lit/directive.js';
|
|
2
2
|
import { PropertyInitMapBase } from '../element-properties';
|
|
3
3
|
import { FunctionalElementInstance } from '../functional-element';
|
|
4
|
-
|
|
4
|
+
/** For some reason these aren't defined in lit's types already. */
|
|
5
|
+
export declare type ExtraPartInfoProperties = {
|
|
6
|
+
element: Element;
|
|
7
|
+
options: {
|
|
8
|
+
host: Element;
|
|
9
|
+
renderBefore: Element;
|
|
10
|
+
isConnected: boolean;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare function extractFunctionalElement<PropertyInitGeneric extends PropertyInitMapBase>(partInfo: PartInfo, directiveName: string): FunctionalElementInstance<PropertyInitGeneric>;
|
|
14
|
+
export declare function assertsIsElementPartInfo(partInfo: PartInfo, directiveName: string): asserts partInfo is ElementPartInfo & ExtraPartInfoProperties;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { PartType } from 'lit/directive.js';
|
|
2
2
|
import { FunctionalElementBaseClass } from '../functional-element';
|
|
3
|
-
export function extractFunctionalElement(partInfo) {
|
|
4
|
-
|
|
5
|
-
throw new Error(`assign directive can only be attached directly to an element.`);
|
|
6
|
-
}
|
|
3
|
+
export function extractFunctionalElement(partInfo, directiveName) {
|
|
4
|
+
assertsIsElementPartInfo(partInfo, directiveName);
|
|
7
5
|
const element = partInfo.element;
|
|
8
6
|
if (!(element instanceof FunctionalElementBaseClass)) {
|
|
9
|
-
throw new Error(
|
|
7
|
+
throw new Error(`${directiveName} directive only works when attached to functional elements`);
|
|
10
8
|
}
|
|
11
9
|
return element;
|
|
12
10
|
}
|
|
11
|
+
export function assertsIsElementPartInfo(partInfo, directiveName) {
|
|
12
|
+
if (partInfo.type !== PartType.ELEMENT) {
|
|
13
|
+
throw new Error(`${directiveName} directive can only be attached directly to an element.`);
|
|
14
|
+
}
|
|
15
|
+
if (!partInfo.element) {
|
|
16
|
+
throw new Error(`${directiveName} directive found no element`);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/dist/functional-element/directives/{event-listen.directive.d.ts → listen.directive.d.ts}
RENAMED
|
File without changes
|
package/dist/functional-element/directives/{event-listen.directive.js → listen.directive.js}
RENAMED
|
@@ -11,7 +11,7 @@ export function listen(eventType, listener) {
|
|
|
11
11
|
const listenDirective = directive(class extends Directive {
|
|
12
12
|
constructor(partInfo) {
|
|
13
13
|
super(partInfo);
|
|
14
|
-
this.element = extractFunctionalElement(partInfo);
|
|
14
|
+
this.element = extractFunctionalElement(partInfo, 'listen');
|
|
15
15
|
}
|
|
16
16
|
resetListener(listenerMetaData) {
|
|
17
17
|
if (this.lastListenerMetaData) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PartInfo } from 'lit/directive.js';
|
|
2
|
+
export declare type OnDomCreatedCallback = (element: Element) => void;
|
|
3
|
+
/** Only fires once, when the element has been created. */
|
|
4
|
+
export declare const onDomCreated: (callback: OnDomCreatedCallback) => import("lit-html/directive").DirectiveResult<{
|
|
5
|
+
new (partInfo: PartInfo): {
|
|
6
|
+
element: Element | undefined;
|
|
7
|
+
update(partInfo: PartInfo, [callback]: [OnDomCreatedCallback]): undefined;
|
|
8
|
+
render(callback: OnDomCreatedCallback): undefined;
|
|
9
|
+
readonly _$isConnected: boolean;
|
|
10
|
+
};
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { directive, Directive } from 'lit/directive.js';
|
|
2
|
+
import { assertsIsElementPartInfo } from './directive-util';
|
|
3
|
+
const directiveName = 'onDomCreated';
|
|
4
|
+
/** Only fires once, when the element has been created. */
|
|
5
|
+
export const onDomCreated = directive(class extends Directive {
|
|
6
|
+
constructor(partInfo) {
|
|
7
|
+
super(partInfo);
|
|
8
|
+
assertsIsElementPartInfo(partInfo, directiveName);
|
|
9
|
+
}
|
|
10
|
+
update(partInfo, [callback]) {
|
|
11
|
+
assertsIsElementPartInfo(partInfo, directiveName);
|
|
12
|
+
const newElement = partInfo.element;
|
|
13
|
+
if (newElement !== this.element) {
|
|
14
|
+
callback(newElement);
|
|
15
|
+
this.element = newElement;
|
|
16
|
+
}
|
|
17
|
+
return this.render(callback);
|
|
18
|
+
}
|
|
19
|
+
render(callback) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PartInfo } from 'lit/directive.js';
|
|
2
|
+
export declare type OnResizeCallback = (
|
|
3
|
+
/** Only these two properties are supported in all major modern browsers */
|
|
4
|
+
entry: Readonly<Pick<ResizeObserverEntry, 'target' | 'contentRect'>>) => void;
|
|
5
|
+
export declare const onResize: (callback: OnResizeCallback) => import("lit-html/directive").DirectiveResult<{
|
|
6
|
+
new (partInfo: PartInfo): {
|
|
7
|
+
element: Element | undefined;
|
|
8
|
+
readonly resizeObserver: ResizeObserver;
|
|
9
|
+
callback: OnResizeCallback | undefined;
|
|
10
|
+
fireCallback(entries: ResizeObserverEntry[]): void;
|
|
11
|
+
update(partInfo: PartInfo, [callback]: [OnResizeCallback]): undefined;
|
|
12
|
+
render(callback: OnResizeCallback): undefined;
|
|
13
|
+
readonly _$isConnected: boolean;
|
|
14
|
+
};
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { directive, Directive } from 'lit/directive.js';
|
|
2
|
+
import { assertsIsElementPartInfo } from './directive-util';
|
|
3
|
+
const directiveName = 'onResize';
|
|
4
|
+
export const onResize = directive(class extends Directive {
|
|
5
|
+
constructor(partInfo) {
|
|
6
|
+
super(partInfo);
|
|
7
|
+
this.resizeObserver = new ResizeObserver((entries) => this.fireCallback(entries));
|
|
8
|
+
assertsIsElementPartInfo(partInfo, directiveName);
|
|
9
|
+
}
|
|
10
|
+
fireCallback(entries) {
|
|
11
|
+
var _a;
|
|
12
|
+
const resizeEntry = entries[0];
|
|
13
|
+
if (!resizeEntry) {
|
|
14
|
+
console.error(entries);
|
|
15
|
+
throw new Error(`${directiveName} observation triggered but the first entry was empty.`);
|
|
16
|
+
}
|
|
17
|
+
(_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, { target: resizeEntry.target, contentRect: resizeEntry.contentRect });
|
|
18
|
+
}
|
|
19
|
+
update(partInfo, [callback]) {
|
|
20
|
+
assertsIsElementPartInfo(partInfo, directiveName);
|
|
21
|
+
this.callback = callback;
|
|
22
|
+
const newElement = partInfo.element;
|
|
23
|
+
// if the element changes we need to observe the new one
|
|
24
|
+
if (newElement !== this.element) {
|
|
25
|
+
if (this.element) {
|
|
26
|
+
this.resizeObserver.unobserve(this.element);
|
|
27
|
+
}
|
|
28
|
+
this.resizeObserver.observe(newElement);
|
|
29
|
+
this.element = newElement;
|
|
30
|
+
}
|
|
31
|
+
return this.render(callback);
|
|
32
|
+
}
|
|
33
|
+
render(callback) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
@@ -2,6 +2,20 @@ import { CSSResult, LitElement, TemplateResult } from 'lit';
|
|
|
2
2
|
import { EventDescriptorMap, EventsInitMap } from './element-events';
|
|
3
3
|
import { ElementPropertyDescriptorMap, PropertyInitMapBase } from './element-properties';
|
|
4
4
|
import { RenderCallback } from './render-callback';
|
|
5
|
+
export declare type FunctionalElementInit<PropertyInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap> = {
|
|
6
|
+
/**
|
|
7
|
+
* HTML tag name. This should not be used directly, as interpolating it with the html tagged
|
|
8
|
+
* template from this package is preferred.
|
|
9
|
+
*/
|
|
10
|
+
tagName: string;
|
|
11
|
+
/** Static styles. These should not and cannot change. */
|
|
12
|
+
styles?: CSSResult | undefined;
|
|
13
|
+
/** Initializer for element properties. (These can be thought of as "inputs".) */
|
|
14
|
+
props?: PropertyInitGeneric | undefined;
|
|
15
|
+
/** Initializer for events that the element can dispatch. (These can be thought of as "outputs".) */
|
|
16
|
+
events?: EventsInitGeneric | undefined;
|
|
17
|
+
renderCallback: RenderCallback<PropertyInitGeneric, EventsInitGeneric>;
|
|
18
|
+
};
|
|
5
19
|
export declare abstract class FunctionalElementBaseClass<PropertyInitGeneric extends PropertyInitMapBase> extends LitElement {
|
|
6
20
|
static readonly tagName: string;
|
|
7
21
|
static readonly styles: CSSResult;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export * from './functional-element/define-functional-element';
|
|
2
|
-
export * from './functional-element/directives/
|
|
3
|
-
export * from './functional-element/directives/
|
|
2
|
+
export * from './functional-element/directives/assign-with-clean-up.directive';
|
|
3
|
+
export * from './functional-element/directives/assign.directive';
|
|
4
|
+
export * from './functional-element/directives/listen.directive';
|
|
5
|
+
export * from './functional-element/directives/on-dom-created.directive';
|
|
6
|
+
export * from './functional-element/directives/on-resize.directive';
|
|
4
7
|
export * from './functional-element/element-events';
|
|
5
8
|
export * from './functional-element/element-properties';
|
|
6
9
|
export * from './functional-element/functional-element';
|
|
7
|
-
export * from './functional-element/functional-element-init';
|
|
8
|
-
export * from './functional-element/lifecycle-callback';
|
|
9
10
|
export * from './functional-element/render-callback';
|
|
10
|
-
export * from './vir-html/directive';
|
|
11
11
|
export * from './vir-html/vir-html';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export * from './functional-element/define-functional-element';
|
|
2
|
-
export * from './functional-element/directives/
|
|
3
|
-
export * from './functional-element/directives/
|
|
2
|
+
export * from './functional-element/directives/assign-with-clean-up.directive';
|
|
3
|
+
export * from './functional-element/directives/assign.directive';
|
|
4
|
+
export * from './functional-element/directives/listen.directive';
|
|
5
|
+
export * from './functional-element/directives/on-dom-created.directive';
|
|
6
|
+
export * from './functional-element/directives/on-resize.directive';
|
|
4
7
|
export * from './functional-element/element-events';
|
|
5
8
|
export * from './functional-element/element-properties';
|
|
6
9
|
export * from './functional-element/functional-element';
|
|
7
|
-
export * from './functional-element/functional-element-init';
|
|
8
|
-
export * from './functional-element/lifecycle-callback';
|
|
9
10
|
export * from './functional-element/render-callback';
|
|
10
|
-
export * from './vir-html/directive';
|
|
11
11
|
export * from './vir-html/vir-html';
|
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { CSSResult } from 'lit';
|
|
2
|
-
import { EventsInitMap } from './element-events';
|
|
3
|
-
import { PropertyInitMapBase } from './element-properties';
|
|
4
|
-
import { LifecycleCallback } from './lifecycle-callback';
|
|
5
|
-
import { RenderCallback } from './render-callback';
|
|
6
|
-
export declare type FunctionalElementInit<PropertyInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap> = {
|
|
7
|
-
/**
|
|
8
|
-
* HTML tag name. This should not be used directly, as interpolating it with the html tagged
|
|
9
|
-
* template from this package is preferred.
|
|
10
|
-
*/
|
|
11
|
-
tagName: string;
|
|
12
|
-
/** Static styles. These should not and cannot change. */
|
|
13
|
-
styles?: CSSResult | undefined;
|
|
14
|
-
/** Initializer for element properties. (These can be thought of as "inputs".) */
|
|
15
|
-
props?: PropertyInitGeneric | undefined;
|
|
16
|
-
/** Initializer for events that the element can dispatch. (These can be thought of as "outputs".) */
|
|
17
|
-
events?: EventsInitGeneric | undefined;
|
|
18
|
-
connectedCallback?: LifecycleCallback<PropertyInitGeneric, EventsInitGeneric>;
|
|
19
|
-
disconnectedCallback?: LifecycleCallback<PropertyInitGeneric, EventsInitGeneric>;
|
|
20
|
-
firstUpdated?: LifecycleCallback<PropertyInitGeneric, EventsInitGeneric>;
|
|
21
|
-
renderCallback: RenderCallback<PropertyInitGeneric, EventsInitGeneric>;
|
|
22
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { EventsInitMap } from './element-events';
|
|
2
|
-
import { PropertyInitMapBase } from './element-properties';
|
|
3
|
-
import { FunctionalElementInstance } from './functional-element';
|
|
4
|
-
import { RenderParams } from './render-callback';
|
|
5
|
-
export declare type LifecycleCallbackParams<PropertyInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap> = {
|
|
6
|
-
element: FunctionalElementInstance<PropertyInitGeneric>;
|
|
7
|
-
} & RenderParams<PropertyInitGeneric, EventsInitGeneric>;
|
|
8
|
-
export declare type LifecycleCallback<PropertyInitGeneric extends PropertyInitMapBase, EventsInitGeneric extends EventsInitMap> = (params: LifecycleCallbackParams<PropertyInitGeneric, EventsInitGeneric>) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|