Skip to content

Commit b0bf09c

Browse files
authored
Merge pull request #46 from lume/static-class-field-options
`@element` options via static class fields, `@jsonAttribute`, and improvements
2 parents 0c08000 + 65e1384 commit b0bf09c

24 files changed

+1235
-510
lines changed

README.md

Lines changed: 274 additions & 76 deletions
Large diffs are not rendered by default.

dist/LumeElement.d.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AttributeHandler, __attributesToProps } from './decorators/attribute.js';
1+
import type { AttributeHandler, AttributePropSpecs, __attributesToProps, __hasAttributeChangedCallback } from './decorators/attribute.js';
22
import type { DashCasedProps } from './utils.js';
33
declare const root: unique symbol;
44
declare const LumeElement_base: (new (...a: any[]) => {
@@ -19,10 +19,17 @@ declare class LumeElement extends LumeElement_base {
1919
#private;
2020
/**
2121
* The default tag name of the elements this class instantiates. When using
22-
* the `@element` decorator, this property will be set to the value defined
23-
* by the decorator.
22+
* the `@element` decorator, if this field has not been specified, it will
23+
* be set to the value defined by the decorator.
2424
*/
2525
static elementName: string;
26+
/**
27+
* When using the @element decorator, the element will be automatically
28+
* defined in the CustomElementRegistry if this is true, otherwise manual
29+
* registration will be needed if false. If autoDefine is passed into the
30+
* decorator, this field will be overriden by that value.
31+
*/
32+
static autoDefine: boolean;
2633
/**
2734
* Define this class for the given element `name`, or using its default name
2835
* (`elementName`) if no `name` given. Defaults to using the global
@@ -38,7 +45,10 @@ declare class LumeElement extends LumeElement_base {
3845
* different subclass of the class this is called on if passing in a custom
3946
* `name`, otherwise returns the same class this is called on.
4047
*/
41-
static defineElement(name?: string, registry?: CustomElementRegistry): CustomElementConstructor;
48+
static defineElement(): typeof LumeElement;
49+
static defineElement(registry: CustomElementRegistry): typeof LumeElement;
50+
static defineElement(name: string): typeof LumeElement;
51+
static defineElement(name: string, registry: CustomElementRegistry): typeof LumeElement;
4252
/**
4353
* Non-decorator users can use this to specify a list of attributes, and the
4454
* attributes will automatically be mapped to reactive properties. All
@@ -80,10 +90,9 @@ declare class LumeElement extends LumeElement_base {
8090
*/
8191
static observedAttributeHandlers?: AttributeHandlerMap;
8292
/** Note, this is internal and used by the @attribute decorator, see attribute.ts. */
83-
[__attributesToProps]?: Record<string, {
84-
name: string;
85-
attributeHandler?: AttributeHandler;
86-
}>;
93+
[__attributesToProps]?: AttributePropSpecs;
94+
/** Note, this is internal and used by the @attribute decorator, see attribute.ts. */
95+
[__hasAttributeChangedCallback]?: true;
8796
/**
8897
* This can be used by a subclass, or other frameworks handling elements, to
8998
* detect property values that exist from before custom element upgrade.

dist/LumeElement.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/LumeElement.js

Lines changed: 16 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)