@aegis-framework/pandora 0.5.0 → 0.6.1
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 +1395 -755
- package/dist/pandora.browser.js +16 -15
- package/dist/pandora.browser.js.map +11 -9
- package/dist/pandora.js +16 -15
- package/dist/pandora.js.map +10 -8
- package/dist/types/Component.d.ts +795 -222
- package/dist/types/Component.d.ts.map +1 -1
- package/dist/types/Decorators.d.ts +378 -35
- package/dist/types/Decorators.d.ts.map +1 -1
- package/dist/types/Registry.d.ts +479 -105
- package/dist/types/Registry.d.ts.map +1 -1
- package/dist/types/ShadowComponent.d.ts +133 -23
- package/dist/types/ShadowComponent.d.ts.map +1 -1
- package/dist/types/Testing.d.ts +74 -0
- package/dist/types/Testing.d.ts.map +1 -0
- package/dist/types/TypedState.d.ts +51 -0
- package/dist/types/TypedState.d.ts.map +1 -0
- package/dist/types/Types.d.ts +92 -2
- package/dist/types/Types.d.ts.map +1 -1
- package/dist/types/Util.d.ts +134 -15
- package/dist/types/Util.d.ts.map +1 -1
- package/dist/types/browser.d.ts +14 -0
- package/dist/types/browser.d.ts.map +1 -1
- package/dist/types/index.d.ts +20 -8
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +9 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../../src/Component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../../src/Component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAcxE,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjE;;;;;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;;;;;;;;;;;;OAYG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAE1C;;;;;;;;;;;OAWG;IACU,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAEzC;;;;;;;;;;OAUG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAExC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACI,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAEnG;;;;;;;;;;;;;;;;OAgBG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAiGxC;;;;;;;;;;;;;;OAcG;IACG,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IA2C3C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAqDnG;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB,CAA0H;IAElJ;;;;;;;OAOG;IACH,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAoElC;;;;;;OAMG;IACH,SAAS,CAAC,gBAAgB,IAAI,IAAI;CAOnC;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -1,70 +1,413 @@
|
|
|
1
1
|
import Component from './Component';
|
|
2
|
+
import { Style } from './Types';
|
|
2
3
|
type ComponentConstructor = typeof Component & {
|
|
3
4
|
tag: string;
|
|
4
5
|
_registered?: boolean;
|
|
5
6
|
};
|
|
7
|
+
interface RegisterOptions {
|
|
8
|
+
defer?: boolean;
|
|
9
|
+
}
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
11
|
+
* Registers a class as a custom element with the browser under the given tag.
|
|
12
|
+
*
|
|
13
|
+
* By default the element is defined on `customElements` immediately. Pass
|
|
14
|
+
* `{ defer: true }` when you want to delay registration — useful if you need
|
|
15
|
+
* to wire up dependencies or control mount ordering yourself before the tag
|
|
16
|
+
* becomes usable in the DOM.
|
|
17
|
+
*
|
|
18
|
+
* @param tagName - The custom element tag name (must contain a hyphen).
|
|
19
|
+
* @param options - Pass `{ defer: true }` to skip automatic registration.
|
|
8
20
|
*
|
|
9
21
|
* @example
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* class MyComponent extends Component {
|
|
22
|
+
* @Register('my-greeting')
|
|
23
|
+
* class MyGreeting extends Component {
|
|
13
24
|
* render() {
|
|
14
|
-
* return
|
|
25
|
+
* return html`<p>Hello, world.</p>`;
|
|
15
26
|
* }
|
|
16
27
|
* }
|
|
17
|
-
* ```
|
|
18
28
|
*
|
|
19
|
-
*
|
|
29
|
+
* // <my-greeting></my-greeting>
|
|
30
|
+
*/
|
|
31
|
+
export declare function Register(tagName: string, options?: RegisterOptions): <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext) => T;
|
|
32
|
+
/**
|
|
33
|
+
* Attaches scoped CSS to the component. Accepts either a raw CSS string or
|
|
34
|
+
* a structured `Style` object (selectors and declarations).
|
|
35
|
+
*
|
|
36
|
+
* Styles are applied once per class and live alongside the component's
|
|
37
|
+
* shadow or light DOM output, so they don't leak to the rest of the page.
|
|
38
|
+
*
|
|
39
|
+
* @param css - A CSS string or a `Style` object describing the rules.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* @Register('my-button')
|
|
43
|
+
* @Style({
|
|
44
|
+
* button: {
|
|
45
|
+
* padding: '0.5rem 1rem',
|
|
46
|
+
* borderRadius: '6px',
|
|
47
|
+
* background: 'hotpink',
|
|
48
|
+
* color: 'white',
|
|
49
|
+
* },
|
|
50
|
+
* })
|
|
51
|
+
* class MyButton extends Component {
|
|
52
|
+
* render() {
|
|
53
|
+
* return html`<button>Click me</button>`;
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
*/
|
|
57
|
+
export declare function Style(css: Style | string): <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext) => T;
|
|
58
|
+
/**
|
|
59
|
+
* Runs the decorated method whenever the given reactive property changes,
|
|
60
|
+
* receiving the new and previous values.
|
|
61
|
+
*
|
|
62
|
+
* The watched property must be declared with `@State`, `@Attribute`, or
|
|
63
|
+
* `@Property` — otherwise you'll see a one-time dev warning explaining that
|
|
64
|
+
* the watcher will never fire. Watchers run synchronously on assignment,
|
|
65
|
+
* before the next render is queued.
|
|
66
|
+
*
|
|
67
|
+
* @param property - The name of the reactive field to observe.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* @Register('my-counter')
|
|
71
|
+
* class MyCounter extends Component {
|
|
72
|
+
* @State() count = 0;
|
|
73
|
+
*
|
|
74
|
+
* @Watch('count')
|
|
75
|
+
* onCountChange(next: number, previous: number) {
|
|
76
|
+
* console.log(`count went from ${previous} to ${next}`);
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* render() {
|
|
80
|
+
* return html`<button @click=${() => this.count++}>${this.count}</button>`;
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
*/
|
|
84
|
+
export declare function Watch(property: string): <T extends (...args: any[]) => any>(_target: T, context: ClassMethodDecoratorContext) => void;
|
|
85
|
+
interface StateOptions {
|
|
86
|
+
render?: boolean;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Declares a reactive instance field. Assigning to the field queues a render
|
|
90
|
+
* on the next microtask, and multiple assignments in the same tick coalesce
|
|
91
|
+
* into a single render pass.
|
|
92
|
+
*
|
|
93
|
+
* Pass `{ render: false }` to keep the field reactive — `@Watch` handlers
|
|
94
|
+
* still fire and the value still flows through `didChange` — without
|
|
95
|
+
* triggering a re-render on every assignment.
|
|
96
|
+
*
|
|
97
|
+
* @param options - Optional `{ render: false }` to opt out of re-rendering.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* @Register('my-counter')
|
|
101
|
+
* class MyCounter extends Component {
|
|
102
|
+
* @State() count = 0;
|
|
103
|
+
* @State({ render: false }) private lastPing = Date.now();
|
|
104
|
+
*
|
|
105
|
+
* render() {
|
|
106
|
+
* return html`<button @click=${() => this.count++}>${this.count}</button>`;
|
|
107
|
+
* }
|
|
108
|
+
* }
|
|
20
109
|
*/
|
|
21
|
-
export declare function
|
|
110
|
+
export declare function State(options?: StateOptions): (_target: undefined, context: ClassFieldDecoratorContext) => void;
|
|
111
|
+
interface PropertyOptions {
|
|
112
|
+
attribute?: string | false;
|
|
113
|
+
equals?: (a: unknown, b: unknown) => boolean;
|
|
114
|
+
}
|
|
22
115
|
/**
|
|
23
|
-
*
|
|
116
|
+
* Exposes a reactive JavaScript property on the component — ideal for values
|
|
117
|
+
* that aren't string-serializable, like objects, arrays, or class instances.
|
|
118
|
+
*
|
|
119
|
+
* Properties are reactive (they fire `@Watch` handlers and run through
|
|
120
|
+
* `didChange`) but do not trigger re-renders on their own, so a parent can
|
|
121
|
+
* hand a child rich data without causing render thrash. Pass
|
|
122
|
+
* `{ attribute: 'some-name' }` to mirror the value to an attribute for
|
|
123
|
+
* primitives, or provide a custom `equals` comparator to skip updates when
|
|
124
|
+
* a deep-equal object is assigned.
|
|
24
125
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* 2. Subscribes to global state changes and updates the property automatically
|
|
28
|
-
* 3. When the property is set internally, updates the global state
|
|
29
|
-
* 4. Automatically unsubscribes when the component disconnects
|
|
126
|
+
* @param options - `{ attribute, equals }` to control attribute sync and
|
|
127
|
+
* change detection.
|
|
30
128
|
*
|
|
31
129
|
* @example
|
|
32
|
-
*
|
|
33
|
-
* class UserProfile extends Component {
|
|
34
|
-
* @Consumer('user.theme')
|
|
35
|
-
* theme!: string;
|
|
130
|
+
* interface User { id: string; name: string; }
|
|
36
131
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
132
|
+
* @Register('user-avatar')
|
|
133
|
+
* class UserAvatar extends Component {
|
|
134
|
+
* @Property() user!: User;
|
|
39
135
|
*
|
|
40
136
|
* render() {
|
|
41
|
-
* return `<
|
|
137
|
+
* return html`<img alt=${this.user.name} data-id=${this.user.id}>`;
|
|
42
138
|
* }
|
|
43
139
|
* }
|
|
44
|
-
* ```
|
|
45
140
|
*
|
|
46
|
-
*
|
|
141
|
+
* // In a parent:
|
|
142
|
+
* // const el = document.querySelector('user-avatar');
|
|
143
|
+
* // el.user = { id: 'u_42', name: 'Ada Lovelace' };
|
|
47
144
|
*/
|
|
48
|
-
export declare function
|
|
145
|
+
export declare function Property(options?: PropertyOptions): (_target: undefined, context: ClassFieldDecoratorContext) => void;
|
|
146
|
+
interface AttributeOptions {
|
|
147
|
+
render?: boolean;
|
|
148
|
+
}
|
|
49
149
|
/**
|
|
50
|
-
*
|
|
150
|
+
* Binds a reactive field to an HTML attribute. The field reads through to
|
|
151
|
+
* the attribute, and assignments are written back, keeping DOM and JS state
|
|
152
|
+
* in sync.
|
|
153
|
+
*
|
|
154
|
+
* By default the attribute name matches the field name — pass a string to
|
|
155
|
+
* map to a different attribute (e.g. `@Attribute('user-name')`), or pass
|
|
156
|
+
* `{ render: false }` to keep the field reactive without triggering a
|
|
157
|
+
* re-render when the attribute changes. String, number, and boolean values
|
|
158
|
+
* are serialized automatically.
|
|
51
159
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
160
|
+
* @param attributeNameOrOptions - Either the attribute name to bind to, or
|
|
161
|
+
* an options object like `{ render: false }`.
|
|
54
162
|
*
|
|
55
163
|
* @example
|
|
56
|
-
*
|
|
164
|
+
* @Register('my-greeting')
|
|
165
|
+
* class MyGreeting extends Component {
|
|
166
|
+
* @Attribute() name = 'world';
|
|
167
|
+
*
|
|
168
|
+
* render() {
|
|
169
|
+
* return html`<p>Hello, ${this.name}.</p>`;
|
|
170
|
+
* }
|
|
171
|
+
* }
|
|
172
|
+
*
|
|
173
|
+
* // <my-greeting name="Ada"></my-greeting>
|
|
174
|
+
*/
|
|
175
|
+
export declare function Attribute(attributeNameOrOptions?: string | AttributeOptions): (_target: undefined, context: ClassFieldDecoratorContext) => void;
|
|
176
|
+
/**
|
|
177
|
+
* Subscribes a field to a shared state key on the global `Registry`. Reading
|
|
178
|
+
* the field returns the current registry value; assigning writes it back
|
|
179
|
+
* and notifies every other subscriber.
|
|
180
|
+
*
|
|
181
|
+
* Subscriptions activate on connect and tear down on disconnect, so
|
|
182
|
+
* components automatically stay in sync with the store for as long as
|
|
183
|
+
* they're in the DOM — no manual wiring required.
|
|
184
|
+
*
|
|
185
|
+
* @param stateKey - The key in the `Registry` store this field mirrors.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* // Somewhere at startup:
|
|
189
|
+
* Registry.setState('theme', 'light');
|
|
190
|
+
*
|
|
191
|
+
* @Register('theme-toggle')
|
|
192
|
+
* class ThemeToggle extends Component {
|
|
193
|
+
* @Subscribe('theme') theme!: 'light' | 'dark';
|
|
194
|
+
*
|
|
195
|
+
* render() {
|
|
196
|
+
* return html`
|
|
197
|
+
* <button @click=${() => this.theme = this.theme === 'light' ? 'dark' : 'light'}>
|
|
198
|
+
* Theme: ${this.theme}
|
|
199
|
+
* </button>
|
|
200
|
+
* `;
|
|
201
|
+
* }
|
|
202
|
+
* }
|
|
203
|
+
*/
|
|
204
|
+
export declare function Subscribe(stateKey: string): (_target: undefined, context: ClassFieldDecoratorContext) => void;
|
|
205
|
+
/**
|
|
206
|
+
* Turns a field into a live selector query against the component's rendered
|
|
207
|
+
* DOM. Each access re-runs the lookup, so the reference stays correct even
|
|
208
|
+
* as the template re-renders.
|
|
209
|
+
*
|
|
210
|
+
* @param selector - A CSS selector scoped to the component's root.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* @Register('my-form')
|
|
214
|
+
* class MyForm extends Component {
|
|
215
|
+
* @Query('input[name="email"]') emailInput!: HTMLInputElement | null;
|
|
216
|
+
*
|
|
217
|
+
* submit() {
|
|
218
|
+
* console.log('email:', this.emailInput?.value);
|
|
219
|
+
* }
|
|
220
|
+
*
|
|
221
|
+
* render() {
|
|
222
|
+
* return html`
|
|
223
|
+
* <form @submit=${(e: Event) => { e.preventDefault(); this.submit(); }}>
|
|
224
|
+
* <input name="email" type="email" />
|
|
225
|
+
* <button type="submit">Send</button>
|
|
226
|
+
* </form>
|
|
227
|
+
* `;
|
|
228
|
+
* }
|
|
229
|
+
* }
|
|
230
|
+
*/
|
|
231
|
+
export declare function Query(selector: string): (_target: undefined, context: ClassFieldDecoratorContext) => void;
|
|
232
|
+
/**
|
|
233
|
+
* Like `@Query`, but returns every matching element. Each access re-runs
|
|
234
|
+
* the lookup, so the list reflects the current DOM on every read.
|
|
235
|
+
*
|
|
236
|
+
* @param selector - A CSS selector scoped to the component's root.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* @Register('my-tabs')
|
|
240
|
+
* class MyTabs extends Component {
|
|
241
|
+
* @QueryAll('li') items!: NodeListOf<HTMLLIElement>;
|
|
242
|
+
*
|
|
243
|
+
* logItems() {
|
|
244
|
+
* for (const item of this.items) console.log(item.textContent);
|
|
245
|
+
* }
|
|
246
|
+
*
|
|
247
|
+
* render() {
|
|
248
|
+
* return html`
|
|
249
|
+
* <ul>
|
|
250
|
+
* <li>Overview</li>
|
|
251
|
+
* <li>Activity</li>
|
|
252
|
+
* <li>Settings</li>
|
|
253
|
+
* </ul>
|
|
254
|
+
* `;
|
|
255
|
+
* }
|
|
256
|
+
* }
|
|
257
|
+
*/
|
|
258
|
+
export declare function QueryAll(selector: string): (_target: undefined, context: ClassFieldDecoratorContext) => void;
|
|
259
|
+
/**
|
|
260
|
+
* Exposes a `<slot>` element from the shadow root as a field, so you can
|
|
261
|
+
* inspect projected children or call slot APIs like `assignedElements()`.
|
|
262
|
+
*
|
|
263
|
+
* Call with no argument to grab the default slot, or pass a name for a
|
|
264
|
+
* named slot.
|
|
265
|
+
*
|
|
266
|
+
* @param name - Optional named slot to target; omit for the default slot.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* @Register('my-card')
|
|
270
|
+
* class MyCard extends ShadowComponent {
|
|
271
|
+
* @Slot('header') headerSlot!: HTMLSlotElement | null;
|
|
272
|
+
*
|
|
273
|
+
* connectedCallback() {
|
|
274
|
+
* super.connectedCallback();
|
|
275
|
+
* console.log('header children:', this.headerSlot?.assignedElements());
|
|
276
|
+
* }
|
|
277
|
+
*
|
|
278
|
+
* render() {
|
|
279
|
+
* return html`
|
|
280
|
+
* <section>
|
|
281
|
+
* <header><slot name="header"></slot></header>
|
|
282
|
+
* <slot></slot>
|
|
283
|
+
* </section>
|
|
284
|
+
* `;
|
|
285
|
+
* }
|
|
286
|
+
* }
|
|
287
|
+
*/
|
|
288
|
+
export declare function Slot(name?: string): (_target: undefined, context: ClassFieldDecoratorContext) => void;
|
|
289
|
+
interface ListenOptions {
|
|
290
|
+
target?: 'self' | 'window' | 'document' | string;
|
|
291
|
+
delegate?: string;
|
|
292
|
+
capture?: boolean;
|
|
293
|
+
passive?: boolean;
|
|
294
|
+
once?: boolean;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Binds a method as an event listener. By default the listener attaches to
|
|
298
|
+
* the component itself, and is added on connect and removed on disconnect.
|
|
299
|
+
*
|
|
300
|
+
* Pass `target` to listen on `'window'`, `'document'`, or any CSS selector
|
|
301
|
+
* scoped to the component's own subtree; pass `delegate` to catch events that
|
|
302
|
+
* bubble up from a child matching a selector; `capture`, `passive`, and `once`
|
|
303
|
+
* forward to the underlying `addEventListener` call.
|
|
304
|
+
*
|
|
305
|
+
* @param event - The event name to listen for (e.g. `'click'`, `'keydown'`).
|
|
306
|
+
* @param options - Optional `{ target, delegate, capture, passive, once }`.
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* @Register('my-button')
|
|
57
310
|
* class MyButton extends Component {
|
|
58
|
-
* @
|
|
59
|
-
*
|
|
311
|
+
* @State() pressed = 0;
|
|
312
|
+
*
|
|
313
|
+
* @Listen('click')
|
|
314
|
+
* handleClick(event: MouseEvent) {
|
|
315
|
+
* this.pressed++;
|
|
316
|
+
* }
|
|
60
317
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
318
|
+
* render() {
|
|
319
|
+
* return html`<button>Pressed ${this.pressed} times</button>`;
|
|
320
|
+
* }
|
|
321
|
+
* }
|
|
322
|
+
*/
|
|
323
|
+
export declare function Listen(event: string, options?: ListenOptions): <T extends (...args: any[]) => any>(_target: T, context: ClassMethodDecoratorContext) => void;
|
|
324
|
+
/**
|
|
325
|
+
* Turns a getter into a cached derived value. The result is computed once,
|
|
326
|
+
* reused on every read, and invalidated automatically whenever any of the
|
|
327
|
+
* listed reactive dependencies change.
|
|
328
|
+
*
|
|
329
|
+
* List every `@State`, `@Attribute`, or `@Property` the getter reads — those
|
|
330
|
+
* names drive cache invalidation, so anything missing will leave you with a
|
|
331
|
+
* stale result.
|
|
332
|
+
*
|
|
333
|
+
* @param dependencies - Names of reactive fields the getter depends on.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* @Register('cart-summary')
|
|
337
|
+
* class CartSummary extends Component {
|
|
338
|
+
* @State() price = 10;
|
|
339
|
+
* @State() quantity = 3;
|
|
340
|
+
*
|
|
341
|
+
* @Computed('price', 'quantity')
|
|
342
|
+
* get total() {
|
|
343
|
+
* return this.price * this.quantity;
|
|
344
|
+
* }
|
|
345
|
+
*
|
|
346
|
+
* render() {
|
|
347
|
+
* return html`<p>Total: $${this.total}</p>`;
|
|
348
|
+
* }
|
|
349
|
+
* }
|
|
350
|
+
*/
|
|
351
|
+
export declare function Computed(...dependencies: string[]): <T>(_target: T, context: ClassGetterDecoratorContext) => T;
|
|
352
|
+
type ClassListMap = Record<string, string | ((instance: any) => boolean)>;
|
|
353
|
+
/**
|
|
354
|
+
* Declaratively toggles classes on the host element based on reactive state.
|
|
355
|
+
* Map a class name to a reactive field name (truthy → class on, falsy →
|
|
356
|
+
* class off) or to a predicate function that receives the instance and
|
|
357
|
+
* returns a boolean.
|
|
358
|
+
*
|
|
359
|
+
* Classes are applied on connect and updated whenever the underlying
|
|
360
|
+
* reactive fields change, so you never have to reach into `classList`
|
|
361
|
+
* by hand.
|
|
362
|
+
*
|
|
363
|
+
* @param map - Object mapping class names to reactive fields or predicates.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* @Register('my-toggle')
|
|
367
|
+
* @ClassList({
|
|
368
|
+
* 'is-active': 'active',
|
|
369
|
+
* 'is-empty': (self: MyToggle) => self.label.length === 0,
|
|
370
|
+
* })
|
|
371
|
+
* class MyToggle extends Component {
|
|
372
|
+
* @State() active = false;
|
|
373
|
+
* @Attribute() label = '';
|
|
374
|
+
*
|
|
375
|
+
* render() {
|
|
376
|
+
* return html`
|
|
377
|
+
* <button @click=${() => this.active = !this.active}>${this.label}</button>
|
|
378
|
+
* `;
|
|
379
|
+
* }
|
|
380
|
+
* }
|
|
381
|
+
*/
|
|
382
|
+
export declare function ClassList(map: ClassListMap): <T extends ComponentConstructor>(constructor: T, _context: ClassDecoratorContext) => T;
|
|
383
|
+
/**
|
|
384
|
+
* Installs a function on the component that dispatches a bubbling custom
|
|
385
|
+
* event with the given name. Call the field like a method, passing any
|
|
386
|
+
* payload you want to hand up to parents through `event.detail`.
|
|
387
|
+
*
|
|
388
|
+
* The event bubbles and is composed, so parent components and listeners
|
|
389
|
+
* outside a shadow root can subscribe with a plain `addEventListener`.
|
|
390
|
+
*
|
|
391
|
+
* @param eventName - The custom event name to dispatch.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* @Register('my-button')
|
|
395
|
+
* class MyButton extends Component {
|
|
396
|
+
* @Emitter('button-pressed') pressed!: (detail?: { at: number }) => void;
|
|
397
|
+
*
|
|
398
|
+
* @Listen('click')
|
|
399
|
+
* onClick() {
|
|
400
|
+
* this.pressed({ at: Date.now() });
|
|
401
|
+
* }
|
|
402
|
+
*
|
|
403
|
+
* render() {
|
|
404
|
+
* return html`<button>Press me</button>`;
|
|
405
|
+
* }
|
|
63
406
|
* }
|
|
64
|
-
* ```
|
|
65
407
|
*
|
|
66
|
-
*
|
|
408
|
+
* // In a parent:
|
|
409
|
+
* // el.addEventListener('button-pressed', (e) => console.log(e.detail.at));
|
|
67
410
|
*/
|
|
68
|
-
export declare function
|
|
411
|
+
export declare function Emitter(eventName: string): (_target: undefined, context: ClassFieldDecoratorContext) => void;
|
|
69
412
|
export {};
|
|
70
413
|
//# sourceMappingURL=Decorators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Decorators.d.ts","sourceRoot":"","sources":["../../src/Decorators.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Decorators.d.ts","sourceRoot":"","sources":["../../src/Decorators.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AASpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAWhC,KAAK,oBAAoB,GAAG,OAAO,SAAS,GAAG;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAQF,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,IAChD,CAAC,SAAS,oBAAoB,EAAE,aAAa,CAAC,EAAE,SAAS,qBAAqB,KAAG,CAAC,CAiCpG;AAMD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,IACtB,CAAC,SAAS,oBAAoB,EAAE,aAAa,CAAC,EAAE,SAAS,qBAAqB,KAAG,CAAC,CAMpG;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBA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