thunderous 0.3.3 → 0.3.4
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/dist/index.cjs +7 -0
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +7 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -294,6 +294,7 @@ var customElement = (render, options) => {
|
|
294
294
|
#connectedFns = /* @__PURE__ */ new Set();
|
295
295
|
#disconnectedFns = /* @__PURE__ */ new Set();
|
296
296
|
#adoptedCallbackFns = /* @__PURE__ */ new Set();
|
297
|
+
#formAssociatedCallbackFns = /* @__PURE__ */ new Set();
|
297
298
|
#formDisabledCallbackFns = /* @__PURE__ */ new Set();
|
298
299
|
#formResetCallbackFns = /* @__PURE__ */ new Set();
|
299
300
|
#formStateRestoreCallbackFns = /* @__PURE__ */ new Set();
|
@@ -325,6 +326,7 @@ var customElement = (render, options) => {
|
|
325
326
|
connectedCallback: (fn) => this.#connectedFns.add(fn),
|
326
327
|
disconnectedCallback: (fn) => this.#disconnectedFns.add(fn),
|
327
328
|
adoptedCallback: (fn) => this.#adoptedCallbackFns.add(fn),
|
329
|
+
formAssociatedCallback: (fn) => this.#formAssociatedCallbackFns.add(fn),
|
328
330
|
formDisabledCallback: (fn) => this.#formDisabledCallbackFns.add(fn),
|
329
331
|
formResetCallback: (fn) => this.#formResetCallbackFns.add(fn),
|
330
332
|
formStateRestoreCallback: (fn) => this.#formStateRestoreCallbackFns.add(fn),
|
@@ -476,6 +478,11 @@ var customElement = (render, options) => {
|
|
476
478
|
fn();
|
477
479
|
}
|
478
480
|
}
|
481
|
+
formAssociatedCallback() {
|
482
|
+
for (const fn of this.#formAssociatedCallbackFns) {
|
483
|
+
fn();
|
484
|
+
}
|
485
|
+
}
|
479
486
|
formDisabledCallback() {
|
480
487
|
for (const fn of this.#formDisabledCallbackFns) {
|
481
488
|
fn();
|
package/dist/index.d.cts
CHANGED
@@ -14,8 +14,35 @@ type SignalOptions = {
|
|
14
14
|
type SignalGetter<T> = (options?: SignalOptions) => T;
|
15
15
|
type SignalSetter<T> = (newValue: T, options?: SignalOptions) => void;
|
16
16
|
type Signal<T = unknown> = [SignalGetter<T>, SignalSetter<T>];
|
17
|
+
/**
|
18
|
+
* Create a signal with an initial value.
|
19
|
+
* @example
|
20
|
+
* ```ts
|
21
|
+
* const [getCount, setCount] = createSignal(0);
|
22
|
+
* const increment = () => setCount(getCount() + 1);
|
23
|
+
* const decrement = () => setCount(getCount() - 1);
|
24
|
+
* ```
|
25
|
+
*/
|
17
26
|
declare const createSignal: <T = undefined>(initVal?: T, options?: SignalOptions) => Signal<T>;
|
27
|
+
/**
|
28
|
+
* Create a derived signal that depends on other signals.
|
29
|
+
* @example
|
30
|
+
* ```ts
|
31
|
+
* const [getCount, setCount] = createSignal(0);
|
32
|
+
* const doubleCount = derived(() => getCount() * 2);
|
33
|
+
* ```
|
34
|
+
*/
|
18
35
|
declare const derived: <T>(fn: () => T) => SignalGetter<T>;
|
36
|
+
/**
|
37
|
+
* Create an effect that runs when signals change.
|
38
|
+
* @example
|
39
|
+
* ```ts
|
40
|
+
* const [getCount, setCount] = createSignal(0);
|
41
|
+
* createEffect(() => {
|
42
|
+
* console.log('Count:', getCount());
|
43
|
+
* });
|
44
|
+
* ```
|
45
|
+
*/
|
19
46
|
declare const createEffect: (fn: () => void) => void;
|
20
47
|
|
21
48
|
declare global {
|
@@ -40,6 +67,7 @@ type RenderProps = {
|
|
40
67
|
formDisabledCallback: (fn: () => void) => void;
|
41
68
|
formResetCallback: (fn: () => void) => void;
|
42
69
|
formStateRestoreCallback: (fn: () => void) => void;
|
70
|
+
formAssociatedCallback: (fn: () => void) => void;
|
43
71
|
customCallback: (fn: () => void) => `{{callback:${string}}}`;
|
44
72
|
attrSignals: Record<string, Signal<string | null>>;
|
45
73
|
propSignals: Record<string, Signal<unknown>>;
|
@@ -55,11 +83,31 @@ type RenderOptions = {
|
|
55
83
|
shadowRootOptions: ShadowRootInit;
|
56
84
|
};
|
57
85
|
type RenderFunction = (props: RenderProps) => DocumentFragment;
|
86
|
+
/**
|
87
|
+
* Create a custom element that can be defined for use in the DOM.
|
88
|
+
* @example
|
89
|
+
* ```ts
|
90
|
+
* const MyElement = customElement(() => {
|
91
|
+
* return html`<h1>Hello, World!</h1>`;
|
92
|
+
* });
|
93
|
+
* MyElement.define('my-element');
|
94
|
+
* ```
|
95
|
+
*/
|
58
96
|
declare const customElement: (render: RenderFunction, options?: Partial<RenderOptions>) => ElementResult;
|
59
97
|
type Registry = {
|
60
98
|
register: (tagName: string, element: CustomElementConstructor) => void;
|
61
99
|
getTagName: (element: CustomElementConstructor) => string | undefined;
|
62
100
|
};
|
101
|
+
/**
|
102
|
+
* Create a registry for custom elements.
|
103
|
+
* @example
|
104
|
+
* ```ts
|
105
|
+
* const registry = createRegistry();
|
106
|
+
* registry.register('my-element', MyElement);
|
107
|
+
* const tagName = registry.getTagName(MyElement);
|
108
|
+
* console.log(tagName); // 'MY-ELEMENT'
|
109
|
+
* ```
|
110
|
+
*/
|
63
111
|
declare const createRegistry: () => Registry;
|
64
112
|
|
65
113
|
export { type RenderFunction, type RenderProps, type Signal, type SignalGetter, type SignalSetter, createEffect, createRegistry, createSignal, css, customElement, derived, html };
|
package/dist/index.d.ts
CHANGED
@@ -14,8 +14,35 @@ type SignalOptions = {
|
|
14
14
|
type SignalGetter<T> = (options?: SignalOptions) => T;
|
15
15
|
type SignalSetter<T> = (newValue: T, options?: SignalOptions) => void;
|
16
16
|
type Signal<T = unknown> = [SignalGetter<T>, SignalSetter<T>];
|
17
|
+
/**
|
18
|
+
* Create a signal with an initial value.
|
19
|
+
* @example
|
20
|
+
* ```ts
|
21
|
+
* const [getCount, setCount] = createSignal(0);
|
22
|
+
* const increment = () => setCount(getCount() + 1);
|
23
|
+
* const decrement = () => setCount(getCount() - 1);
|
24
|
+
* ```
|
25
|
+
*/
|
17
26
|
declare const createSignal: <T = undefined>(initVal?: T, options?: SignalOptions) => Signal<T>;
|
27
|
+
/**
|
28
|
+
* Create a derived signal that depends on other signals.
|
29
|
+
* @example
|
30
|
+
* ```ts
|
31
|
+
* const [getCount, setCount] = createSignal(0);
|
32
|
+
* const doubleCount = derived(() => getCount() * 2);
|
33
|
+
* ```
|
34
|
+
*/
|
18
35
|
declare const derived: <T>(fn: () => T) => SignalGetter<T>;
|
36
|
+
/**
|
37
|
+
* Create an effect that runs when signals change.
|
38
|
+
* @example
|
39
|
+
* ```ts
|
40
|
+
* const [getCount, setCount] = createSignal(0);
|
41
|
+
* createEffect(() => {
|
42
|
+
* console.log('Count:', getCount());
|
43
|
+
* });
|
44
|
+
* ```
|
45
|
+
*/
|
19
46
|
declare const createEffect: (fn: () => void) => void;
|
20
47
|
|
21
48
|
declare global {
|
@@ -40,6 +67,7 @@ type RenderProps = {
|
|
40
67
|
formDisabledCallback: (fn: () => void) => void;
|
41
68
|
formResetCallback: (fn: () => void) => void;
|
42
69
|
formStateRestoreCallback: (fn: () => void) => void;
|
70
|
+
formAssociatedCallback: (fn: () => void) => void;
|
43
71
|
customCallback: (fn: () => void) => `{{callback:${string}}}`;
|
44
72
|
attrSignals: Record<string, Signal<string | null>>;
|
45
73
|
propSignals: Record<string, Signal<unknown>>;
|
@@ -55,11 +83,31 @@ type RenderOptions = {
|
|
55
83
|
shadowRootOptions: ShadowRootInit;
|
56
84
|
};
|
57
85
|
type RenderFunction = (props: RenderProps) => DocumentFragment;
|
86
|
+
/**
|
87
|
+
* Create a custom element that can be defined for use in the DOM.
|
88
|
+
* @example
|
89
|
+
* ```ts
|
90
|
+
* const MyElement = customElement(() => {
|
91
|
+
* return html`<h1>Hello, World!</h1>`;
|
92
|
+
* });
|
93
|
+
* MyElement.define('my-element');
|
94
|
+
* ```
|
95
|
+
*/
|
58
96
|
declare const customElement: (render: RenderFunction, options?: Partial<RenderOptions>) => ElementResult;
|
59
97
|
type Registry = {
|
60
98
|
register: (tagName: string, element: CustomElementConstructor) => void;
|
61
99
|
getTagName: (element: CustomElementConstructor) => string | undefined;
|
62
100
|
};
|
101
|
+
/**
|
102
|
+
* Create a registry for custom elements.
|
103
|
+
* @example
|
104
|
+
* ```ts
|
105
|
+
* const registry = createRegistry();
|
106
|
+
* registry.register('my-element', MyElement);
|
107
|
+
* const tagName = registry.getTagName(MyElement);
|
108
|
+
* console.log(tagName); // 'MY-ELEMENT'
|
109
|
+
* ```
|
110
|
+
*/
|
63
111
|
declare const createRegistry: () => Registry;
|
64
112
|
|
65
113
|
export { type RenderFunction, type RenderProps, type Signal, type SignalGetter, type SignalSetter, createEffect, createRegistry, createSignal, css, customElement, derived, html };
|
package/dist/index.js
CHANGED
@@ -252,6 +252,7 @@ var customElement = (render, options) => {
|
|
252
252
|
#connectedFns = /* @__PURE__ */ new Set();
|
253
253
|
#disconnectedFns = /* @__PURE__ */ new Set();
|
254
254
|
#adoptedCallbackFns = /* @__PURE__ */ new Set();
|
255
|
+
#formAssociatedCallbackFns = /* @__PURE__ */ new Set();
|
255
256
|
#formDisabledCallbackFns = /* @__PURE__ */ new Set();
|
256
257
|
#formResetCallbackFns = /* @__PURE__ */ new Set();
|
257
258
|
#formStateRestoreCallbackFns = /* @__PURE__ */ new Set();
|
@@ -283,6 +284,7 @@ var customElement = (render, options) => {
|
|
283
284
|
connectedCallback: (fn) => this.#connectedFns.add(fn),
|
284
285
|
disconnectedCallback: (fn) => this.#disconnectedFns.add(fn),
|
285
286
|
adoptedCallback: (fn) => this.#adoptedCallbackFns.add(fn),
|
287
|
+
formAssociatedCallback: (fn) => this.#formAssociatedCallbackFns.add(fn),
|
286
288
|
formDisabledCallback: (fn) => this.#formDisabledCallbackFns.add(fn),
|
287
289
|
formResetCallback: (fn) => this.#formResetCallbackFns.add(fn),
|
288
290
|
formStateRestoreCallback: (fn) => this.#formStateRestoreCallbackFns.add(fn),
|
@@ -434,6 +436,11 @@ var customElement = (render, options) => {
|
|
434
436
|
fn();
|
435
437
|
}
|
436
438
|
}
|
439
|
+
formAssociatedCallback() {
|
440
|
+
for (const fn of this.#formAssociatedCallbackFns) {
|
441
|
+
fn();
|
442
|
+
}
|
443
|
+
}
|
437
444
|
formDisabledCallback() {
|
438
445
|
for (const fn of this.#formDisabledCallbackFns) {
|
439
446
|
fn();
|