@wc-bindable/solid 0.2.0 → 0.3.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 +68 -68
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +35 -35
package/README.md
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
# @wc-bindable/solid
|
|
2
|
-
|
|
3
|
-
Solid adapter for the **wc-bindable** protocol.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @wc-bindable/solid @wc-bindable/core
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
### `createWcBindable` — signal + directive (recommended)
|
|
14
|
-
|
|
15
|
-
```tsx
|
|
16
|
-
import { createWcBindable } from "@wc-bindable/solid";
|
|
17
|
-
|
|
18
|
-
function App() {
|
|
19
|
-
const [values, directive] = createWcBindable();
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<>
|
|
23
|
-
<my-input ref={directive} />
|
|
24
|
-
<p>Current value: {values().value as string}</p>
|
|
25
|
-
</>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### `use:wcBindable` — directive with callback
|
|
31
|
-
|
|
32
|
-
```tsx
|
|
33
|
-
import { wcBindable } from "@wc-bindable/solid";
|
|
34
|
-
|
|
35
|
-
function App() {
|
|
36
|
-
const [value, setValue] = createSignal("");
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<my-input use:wcBindable={(name, v) => {
|
|
40
|
-
if (name === "value") setValue(v as string);
|
|
41
|
-
}} />
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## API
|
|
47
|
-
|
|
48
|
-
### `createWcBindable()`
|
|
49
|
-
|
|
50
|
-
**Returns:** `[values, directive]`
|
|
51
|
-
|
|
52
|
-
| Return | Type | Description |
|
|
53
|
-
|---|---|---|
|
|
54
|
-
| `values` | `Accessor<Record<string, unknown>>` | Signal with the latest property values |
|
|
55
|
-
| `directive` | `(el: HTMLElement) => void` | Pass to `ref` to bind the element |
|
|
56
|
-
|
|
57
|
-
### `wcBindable(el, accessor)`
|
|
58
|
-
|
|
59
|
-
Solid directive for use with `use:wcBindable`.
|
|
60
|
-
|
|
61
|
-
| Parameter | Type | Description |
|
|
62
|
-
|---|---|---|
|
|
63
|
-
| `el` | `HTMLElement` | The target element (provided by Solid) |
|
|
64
|
-
| `accessor` | `Accessor<(name, value) => void>` | Callback invoked on property changes |
|
|
65
|
-
|
|
66
|
-
## License
|
|
67
|
-
|
|
68
|
-
MIT
|
|
1
|
+
# @wc-bindable/solid
|
|
2
|
+
|
|
3
|
+
Solid adapter for the **wc-bindable** protocol.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @wc-bindable/solid @wc-bindable/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### `createWcBindable` — signal + directive (recommended)
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { createWcBindable } from "@wc-bindable/solid";
|
|
17
|
+
|
|
18
|
+
function App() {
|
|
19
|
+
const [values, directive] = createWcBindable();
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<my-input ref={directive} />
|
|
24
|
+
<p>Current value: {values().value as string}</p>
|
|
25
|
+
</>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### `use:wcBindable` — directive with callback
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { wcBindable } from "@wc-bindable/solid";
|
|
34
|
+
|
|
35
|
+
function App() {
|
|
36
|
+
const [value, setValue] = createSignal("");
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<my-input use:wcBindable={(name, v) => {
|
|
40
|
+
if (name === "value") setValue(v as string);
|
|
41
|
+
}} />
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
### `createWcBindable()`
|
|
49
|
+
|
|
50
|
+
**Returns:** `[values, directive]`
|
|
51
|
+
|
|
52
|
+
| Return | Type | Description |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| `values` | `Accessor<Record<string, unknown>>` | Signal with the latest property values |
|
|
55
|
+
| `directive` | `(el: HTMLElement) => void` | Pass to `ref` to bind the element |
|
|
56
|
+
|
|
57
|
+
### `wcBindable(el, accessor)`
|
|
58
|
+
|
|
59
|
+
Solid directive for use with `use:wcBindable`.
|
|
60
|
+
|
|
61
|
+
| Parameter | Type | Description |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `el` | `HTMLElement` | The target element (provided by Solid) |
|
|
64
|
+
| `accessor` | `Accessor<(name, value) => void>` | Callback invoked on property changes |
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Accessor } from "solid-js";
|
|
2
2
|
export type WcBindableDirective = (el: HTMLElement, accessor: Accessor<(name: string, value: unknown) => void>) => void;
|
|
3
3
|
export declare const wcBindable: WcBindableDirective;
|
|
4
|
-
export declare function createWcBindable(): readonly [Accessor<
|
|
4
|
+
export declare function createWcBindable<V extends object = Record<string, unknown>>(initialValues?: Partial<V>): readonly [Accessor<V>, (el: HTMLElement) => void];
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGlE,MAAM,MAAM,mBAAmB,GAAG,CAChC,EAAE,EAAE,WAAW,EACf,QAAQ,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,KACvD,IAAI,CAAC;AAEV,eAAO,MAAM,UAAU,EAAE,mBAQxB,CAAC;AAEF,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGlE,MAAM,MAAM,mBAAmB,GAAG,CAChC,EAAE,EAAE,WAAW,EACf,QAAQ,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,KACvD,IAAI,CAAC;AAEV,eAAO,MAAM,UAAU,EAAE,mBAQxB,CAAC;AAEF,wBAAgB,gBAAgB,CAC9B,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,aAAa,GAAE,OAAO,CAAC,CAAC,CAAM,+BAGP,WAAW,WAOnC"}
|
package/dist/index.js
CHANGED
|
@@ -8,8 +8,8 @@ export const wcBindable = (el, accessor) => {
|
|
|
8
8
|
});
|
|
9
9
|
onCleanup(unbind);
|
|
10
10
|
};
|
|
11
|
-
export function createWcBindable() {
|
|
12
|
-
const [values, setValues] = createSignal(
|
|
11
|
+
export function createWcBindable(initialValues = {}) {
|
|
12
|
+
const [values, setValues] = createSignal(initialValues);
|
|
13
13
|
const directive = (el) => {
|
|
14
14
|
wcBindable(el, () => (name, value) => {
|
|
15
15
|
setValues((prev) => ({ ...prev, [name]: value }));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],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CAAC;IAEhE,MAAM,SAAS,GAAG,CAAC,EAAe,EAAE,EAAE;QACpC,UAAU,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACnC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,CAAC,MAAM,EAAE,SAAS,CAAU,CAAC;AACtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@wc-bindable/solid",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Solid adapter for wc-bindable protocol",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"default": "./dist/index.js"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"files": [
|
|
15
|
-
"dist",
|
|
16
|
-
"LICENSE",
|
|
17
|
-
"README.md"
|
|
18
|
-
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsc",
|
|
21
|
-
"dev": "tsc --watch"
|
|
22
|
-
},
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@wc-bindable/core": "^0.
|
|
25
|
-
},
|
|
26
|
-
"peerDependencies": {
|
|
27
|
-
"solid-js": ">=1"
|
|
28
|
-
},
|
|
29
|
-
"repository": {
|
|
30
|
-
"type": "git",
|
|
31
|
-
"url": "https://github.com/wc-bindable-protocol/wc-bindable-protocol.git",
|
|
32
|
-
"directory": "packages/solid"
|
|
33
|
-
},
|
|
34
|
-
"license": "MIT"
|
|
35
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@wc-bindable/solid",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Solid adapter for wc-bindable protocol",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"dev": "tsc --watch"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@wc-bindable/core": "^0.3.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"solid-js": ">=1"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/wc-bindable-protocol/wc-bindable-protocol.git",
|
|
32
|
+
"directory": "packages/solid"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT"
|
|
35
|
+
}
|