@jasonshimmy/custom-elements-runtime 1.0.10 → 1.1.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/dist/custom-elements-runtime.cjs.js +4 -4
- package/dist/custom-elements-runtime.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.es.js +130 -110
- package/dist/custom-elements-runtime.es.js.map +1 -1
- package/dist/custom-elements-runtime.umd.js +5 -5
- package/dist/custom-elements-runtime.umd.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/runtime/hooks.d.ts +23 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* No external dependencies. Mobile-first, secure, and developer friendly.
|
|
6
6
|
*/
|
|
7
7
|
export { component } from "./runtime/component";
|
|
8
|
-
export { useEmit, useOnConnected, useOnDisconnected, useOnAttributeChanged, useOnError, useStyle } from "./runtime/hooks";
|
|
8
|
+
export { useEmit, useOnConnected, useOnDisconnected, useOnAttributeChanged, useOnError, useStyle, useProps } from "./runtime/hooks";
|
|
9
9
|
export { ref, computed, watch } from "./runtime/reactive";
|
|
10
10
|
export { html } from "./runtime/template-compiler";
|
|
11
11
|
export { css } from "./runtime/style";
|
package/dist/runtime/hooks.d.ts
CHANGED
|
@@ -90,6 +90,29 @@ export declare function useOnAttributeChanged(callback: (name: string, oldValue:
|
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
92
|
export declare function useOnError(callback: (error: Error) => void): void;
|
|
93
|
+
/**
|
|
94
|
+
* Register prop defaults for the component. Can be called during render.
|
|
95
|
+
* Stores the prop defaults on `context._hookCallbacks.props` so the runtime
|
|
96
|
+
* can pick them up when building the component config.
|
|
97
|
+
*
|
|
98
|
+
* Example:
|
|
99
|
+
* ```ts
|
|
100
|
+
* component('my-comp', () => {
|
|
101
|
+
* useProps({ modelValue: false, label: 'Hello' });
|
|
102
|
+
* return html`<div/>`;
|
|
103
|
+
* });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function useProps<T extends Record<string, any>>(defaults: T): T;
|
|
107
|
+
/**
|
|
108
|
+
* Register prop defaults and return a stable props object for use inside render.
|
|
109
|
+
* The returned object reads values from the current component context at render
|
|
110
|
+
* time and falls back to the provided defaults. This keeps prop access stable
|
|
111
|
+
* in production builds and avoids reliance on parsing the render function.
|
|
112
|
+
*
|
|
113
|
+
* Must be called during render. Example:
|
|
114
|
+
* const props = useProps({ modelValue: false });
|
|
115
|
+
*/
|
|
93
116
|
/**
|
|
94
117
|
* Register a style function that will be called during each render
|
|
95
118
|
* to provide reactive styles for the component
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jasonshimmy/custom-elements-runtime",
|
|
3
3
|
"description": "A powerful, modern, and lightweight runtime for creating reactive web components with TypeScript",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"web-components",
|