cogsbox-state 0.5.397 → 0.5.398
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/CogsState.jsx +404 -390
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +31 -8
package/package.json
CHANGED
package/src/CogsState.tsx
CHANGED
|
@@ -2345,7 +2345,7 @@ function createProxyHandler<T>(
|
|
|
2345
2345
|
callbackfn: (
|
|
2346
2346
|
value: InferArrayElement<T>,
|
|
2347
2347
|
setter: StateObject<InferArrayElement<T>>,
|
|
2348
|
-
index:
|
|
2348
|
+
index: number,
|
|
2349
2349
|
array: T,
|
|
2350
2350
|
arraySetter: StateObject<T>
|
|
2351
2351
|
) => any
|
|
@@ -2371,19 +2371,42 @@ function createProxyHandler<T>(
|
|
|
2371
2371
|
const setter = rebuildStateShape(item, finalPath, meta);
|
|
2372
2372
|
const itemComponentId = `${componentId}-${path.join(".")}-${originalIndex}`;
|
|
2373
2373
|
|
|
2374
|
-
|
|
2374
|
+
// Get the validation wrapper from formElements
|
|
2375
|
+
const options = getGlobalStore
|
|
2376
|
+
.getState()
|
|
2377
|
+
.getInitialOptions(stateKey);
|
|
2378
|
+
const validationWrapper = options?.formElements?.validation;
|
|
2379
|
+
|
|
2380
|
+
const childContent = callbackfn(
|
|
2381
|
+
item,
|
|
2382
|
+
setter,
|
|
2383
|
+
originalIndex, // Use originalIndex here
|
|
2384
|
+
arrayToMap as any,
|
|
2385
|
+
rebuildStateShape(arrayToMap as any, path, meta)
|
|
2386
|
+
);
|
|
2387
|
+
|
|
2388
|
+
const wrappedContent = createElement(CogsItemWrapper, {
|
|
2375
2389
|
key: originalIndex,
|
|
2376
2390
|
stateKey,
|
|
2377
2391
|
itemComponentId,
|
|
2378
2392
|
itemPath: finalPath,
|
|
2379
|
-
children:
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2393
|
+
children: validationWrapper ? (
|
|
2394
|
+
// Automatically wrap with validation wrapper
|
|
2395
|
+
<ValidationWrapper
|
|
2396
|
+
formOpts={undefined}
|
|
2397
|
+
path={finalPath}
|
|
2398
|
+
validationKey={options?.validation?.key || ""}
|
|
2399
|
+
stateKey={stateKey}
|
|
2400
|
+
validIndices={meta?.validIndices}
|
|
2401
|
+
>
|
|
2402
|
+
{childContent}
|
|
2403
|
+
</ValidationWrapper>
|
|
2404
|
+
) : (
|
|
2405
|
+
childContent
|
|
2385
2406
|
),
|
|
2386
2407
|
});
|
|
2408
|
+
|
|
2409
|
+
return wrappedContent;
|
|
2387
2410
|
});
|
|
2388
2411
|
};
|
|
2389
2412
|
}
|