@juantroconisf/lib 11.5.0 → 11.6.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 +15 -11
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -137,8 +137,12 @@ If your schema contains arrays inside objects inside arrays (infinite depth), yo
|
|
|
137
137
|
|
|
138
138
|
```tsx
|
|
139
139
|
// Schema: items[].form_response.input_values[].value
|
|
140
|
-
<Input
|
|
140
|
+
<Input
|
|
141
|
+
{...on.input("items", itemId, "form_response.input_values", inputId, "value")}
|
|
142
|
+
label='Deep Value'
|
|
143
|
+
/>
|
|
141
144
|
```
|
|
145
|
+
|
|
142
146
|
The library dynamically traverses your state, mapping IDs securely to their array indices natively, regardless of depth.
|
|
143
147
|
|
|
144
148
|
---
|
|
@@ -154,15 +158,15 @@ Each `on.*` method returns a set of props that you spread directly onto a HeroUI
|
|
|
154
158
|
|
|
155
159
|
All methods support **scalar/nested** paths, standard **array item** paths (composite `"array.field"` + `itemId`), and **variadic sequences** for N-level deep structures.
|
|
156
160
|
|
|
157
|
-
| Method
|
|
158
|
-
|
|
|
159
|
-
| `on.input(...args)`
|
|
160
|
-
| `on.numberInput(...args)`
|
|
161
|
-
| `on.select(...args)`
|
|
162
|
-
| `on.autocomplete(...args)`
|
|
163
|
-
| `on.checkbox(...args)`
|
|
164
|
-
| `on.switch(...args)`
|
|
165
|
-
| `on.radio(...args)`
|
|
161
|
+
| Method | HeroUI Component | Key props returned |
|
|
162
|
+
| -------------------------- | ------------------- | ----------------------------------------------- |
|
|
163
|
+
| `on.input(...args)` | `Input`, `Textarea` | `value: string`, `onValueChange(string)` |
|
|
164
|
+
| `on.numberInput(...args)` | `NumberInput` | `value: number`, `onValueChange(number)` |
|
|
165
|
+
| `on.select(...args)` | `Select` | `selectedKeys`, `onSelectionChange` |
|
|
166
|
+
| `on.autocomplete(...args)` | `Autocomplete` | `selectedKey`, `onSelectionChange` |
|
|
167
|
+
| `on.checkbox(...args)` | `Checkbox` | `isSelected: boolean`, `onValueChange(boolean)` |
|
|
168
|
+
| `on.switch(...args)` | `Switch` | `isSelected: boolean`, `onValueChange(boolean)` |
|
|
169
|
+
| `on.radio(...args)` | `RadioGroup` | `value: string`, `onValueChange(string)` |
|
|
166
170
|
|
|
167
171
|
> **Why separate methods?** Each HeroUI component has a different prop contract (e.g. `isSelected` vs `value`, `onSelectionChange` vs `onValueChange`). Separate methods give accurate intellisense for each component.
|
|
168
172
|
|
|
@@ -233,7 +237,7 @@ Extracted from `helpers` on the `useForm` return value. Items in object arrays a
|
|
|
233
237
|
| Method | Description |
|
|
234
238
|
| ------------------------------------------- | -------------------------------------------------- |
|
|
235
239
|
| `addItem(path, item, index?)` | Adds an item to the end (or at `index`) |
|
|
236
|
-
| `
|
|
240
|
+
| `removeItemByIndex(path, index)` | Removes by index |
|
|
237
241
|
| `removeById(path, id)` | Removes by item ID |
|
|
238
242
|
| `updateByIndex(path, index, partial)` | Partially updates an item by index (shallow merge) |
|
|
239
243
|
| `updateById(path, id, partial)` | Partially updates an item by ID (shallow merge) |
|
package/dist/index.d.mts
CHANGED
|
@@ -225,7 +225,7 @@ interface HelpersFunc<O extends StateType> {
|
|
|
225
225
|
/** Adds a new item to an array. */
|
|
226
226
|
addItem: <K extends ArrayPaths<O>>(arrayKey: K, item: NestedFieldValue<O, K> extends (infer E)[] ? E : never, index?: number) => void;
|
|
227
227
|
/** Removes an item from an array by its index. */
|
|
228
|
-
|
|
228
|
+
removeItemByIndex: <K extends ArrayPaths<O>>(arrayKey: K, index: number) => void;
|
|
229
229
|
/** Removes an item from an array by its unique identifier. */
|
|
230
230
|
removeById: <K extends ArrayPaths<O>>(arrayKey: K, itemId: string | number) => void;
|
|
231
231
|
/** Updates an item in an array at the given index (supports partial updates). */
|
package/dist/index.d.ts
CHANGED
|
@@ -225,7 +225,7 @@ interface HelpersFunc<O extends StateType> {
|
|
|
225
225
|
/** Adds a new item to an array. */
|
|
226
226
|
addItem: <K extends ArrayPaths<O>>(arrayKey: K, item: NestedFieldValue<O, K> extends (infer E)[] ? E : never, index?: number) => void;
|
|
227
227
|
/** Removes an item from an array by its index. */
|
|
228
|
-
|
|
228
|
+
removeItemByIndex: <K extends ArrayPaths<O>>(arrayKey: K, index: number) => void;
|
|
229
229
|
/** Removes an item from an array by its unique identifier. */
|
|
230
230
|
removeById: <K extends ArrayPaths<O>>(arrayKey: K, itemId: string | number) => void;
|
|
231
231
|
/** Updates an item in an array at the given index (supports partial updates). */
|
package/dist/index.js
CHANGED
|
@@ -851,7 +851,7 @@ function useForm(schema, {
|
|
|
851
851
|
});
|
|
852
852
|
});
|
|
853
853
|
},
|
|
854
|
-
|
|
854
|
+
removeItemByIndex: (arrayKey, index) => {
|
|
855
855
|
const currentArr = getNestedValue(stateRef.current, arrayKey) || [];
|
|
856
856
|
const item = currentArr[index];
|
|
857
857
|
const idKey = arrayIdentifiers?.[arrayKey] || "id";
|
package/dist/index.mjs
CHANGED
|
@@ -825,7 +825,7 @@ function useForm(schema, {
|
|
|
825
825
|
});
|
|
826
826
|
});
|
|
827
827
|
},
|
|
828
|
-
|
|
828
|
+
removeItemByIndex: (arrayKey, index) => {
|
|
829
829
|
const currentArr = getNestedValue(stateRef.current, arrayKey) || [];
|
|
830
830
|
const item = currentArr[index];
|
|
831
831
|
const idKey = arrayIdentifiers?.[arrayKey] || "id";
|