Skip to content

Commit 24e9246

Browse files
committed
Fix - useObjectBindings composable - Use Ref return type
1 parent 06fa755 commit 24e9246

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,17 +1082,16 @@ This package requires jspdf as a peer dependency. Please install it in your proj
10821082

10831083
## `useObjectBindings`
10841084

1085-
A composable that **flattens** a reactive object into a set of computed refsone for each “leaf” propertyso you can easily bind to deeply nested values by their string paths.
1085+
A composable that **flattens** a reactive object into a set of refs (one for each “leaf” property) so you can easily bind to deeply nested values by their string paths.
10861086

10871087
### Why use it?
10881088

1089-
- **Automatic reactivity**: Every nested property becomes a `ComputedRef`, with automatic getters/setters that keep your source object in sync.
1089+
- **Automatic reactivity**: Every nested property becomes a `Ref`, with automatic getters/setters that keep your source object in sync.
10901090
- **Flat API surface**: Access or update any nested field by its dot‑delimited path, without writing deep destructuring or `ref` plumbing.
10911091
- **Dynamic path support**: New paths added at runtime are discovered automatically (and proxied), so you never lose reactivity when mutating the structure.
10921092

10931093
```js
10941094
import { useObjectBindings } from "vue-data-ui";
1095-
import type { Ref, ComputedRef } from "vue";
10961095

10971096
const config = ref({
10981097
customPalette: ["#CCCCCC", "#1A1A1A"],
@@ -1106,11 +1105,11 @@ const config = ref({
11061105

11071106
const bindings = useObjectBindings(config);
11081107
// Now `bindings` has computed refs for each leaf path:
1109-
// bindings["style.chart.backgroundColor"] → ComputedRef<string>
1110-
// bindings["style.chart.color"] → ComputedRef<string>
1111-
// bindings["customPalette"] → ComputedRef<boolean>
1112-
// // by default, arrays are skipped:
1113-
// // no "customPalette.0", unless you disable skipArrays
1108+
// bindings["style.chart.backgroundColor"] → Ref<string>
1109+
// bindings["style.chart.color"] → Ref<string>
1110+
// bindings["customPalette"] → Ref<boolean>
1111+
// by default, arrays are skipped:
1112+
// no "customPalette.0", unless you disable skipArrays
11141113
```
11151114

11161115
You can then use these in your template:

types/vue-data-ui.d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module "vue-data-ui" {
2-
import { Ref, ComputedRef, DefineComponent } from "vue";
2+
import { Ref, WritableComputedRef, DefineComponent } from "vue";
33

44
export type VueUiUnknownObj = {
55
[key: string]: unknown;
@@ -7690,7 +7690,7 @@ declare module "vue-data-ui" {
76907690
* `ComputedRef` of the exact `PathValue<T,P>`.
76917691
*/
76927692
export type TypedBindings<T extends object> = {
7693-
[P in Paths<T>]: ComputedRef<PathValue<T, P>>;
7693+
[P in Paths<T>]: WritableComputedRef<PathValue<T, P>>;
76947694
};
76957695

76967696
/**
@@ -7702,14 +7702,13 @@ declare module "vue-data-ui" {
77027702
* @param configRef A Vue `Ref<T>` holding your object.
77037703
* @param options Optional settings: `delimiter` (default `"."`) and `skipArrays` (default `true`).
77047704
* @returns A `TypedBindings<T>` whose keys are every “leaf” path in `T`
7705-
* and whose values are `ComputedRef` of the exact property type.
7705+
* and whose values are `WritableComputedRef` of the exact property type.
77067706
*
77077707
* ___
77087708
* @example
77097709
*
77107710
* ```js
77117711
* import { useObjectBindings } from "vue-data-ui";
7712-
* import type { Ref, ComputedRef } from "vue";
77137712
*
77147713
* const config = ref({
77157714
* customPalette: ["#CCCCCC", "#1A1A1A"],

0 commit comments

Comments
 (0)