@socotra/ec-react-utils 2.25.2-next.0 → 2.25.2-next.2
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/index.d.ts +27 -45
- package/dist/index.es.js +16337 -12310
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +48 -22
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,7 @@ declare interface DataModelToJsonSchemaProps {
|
|
|
126
126
|
readOnly?: boolean;
|
|
127
127
|
wrapData?: boolean;
|
|
128
128
|
isFetchingEvaluatedConstraints?: boolean;
|
|
129
|
+
ignoreDefaultValues?: boolean;
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
declare const defaultFieldSchema: z.ZodObject<{
|
|
@@ -379,41 +380,57 @@ export declare function getAccountRequest(params: {
|
|
|
379
380
|
}): AccountCreateRequest;
|
|
380
381
|
|
|
381
382
|
/**
|
|
382
|
-
* Converts a JSONForms data path to
|
|
383
|
+
* Converts a JSONForms data path to constraint record lookup path keys.
|
|
383
384
|
*
|
|
384
385
|
* This function processes a path string by filtering out ignored prefixes from the first token only
|
|
385
|
-
* and converting numeric tokens to array notation for constraint record lookups.
|
|
386
|
+
* and converting numeric tokens to array notation for constraint record lookups. It returns both
|
|
387
|
+
* the full path with array notation and a simplified path without array indices.
|
|
386
388
|
*
|
|
387
389
|
* @param path - The data path generated by JSONForms library (e.g., "practiceLocation.0.state", "practiceLocation.state")
|
|
388
390
|
* @param ignoredPrefixes - Array of prefixes to ignore from the first token only (e.g., ["data", "static"])
|
|
389
|
-
* @returns
|
|
391
|
+
* @returns An object containing:
|
|
392
|
+
* - `pathKey`: The full path with array notation for numeric tokens (e.g., "practiceLocation[0].state")
|
|
393
|
+
* - `pathKeyWithoutIndex`: The simplified path with numeric tokens removed (e.g., "practiceLocation.state")
|
|
390
394
|
*
|
|
391
395
|
* @example
|
|
392
396
|
* // Basic usage
|
|
393
|
-
* getConstraintRecordLookupPathKey("practiceLocation.0.state", [
|
|
394
|
-
* // Returns: "practiceLocation[0].state"
|
|
397
|
+
* getConstraintRecordLookupPathKey("practiceLocation.0.state", [])
|
|
398
|
+
* // Returns: { pathKey: "practiceLocation[0].state", pathKeyWithoutIndex: "practiceLocation.state" }
|
|
395
399
|
*
|
|
396
400
|
* @example
|
|
397
401
|
* // With ignored prefix (first token only)
|
|
398
402
|
* getConstraintRecordLookupPathKey("data.practiceLocation.state", ["data"])
|
|
399
|
-
* // Returns: "practiceLocation.state"
|
|
403
|
+
* // Returns: { pathKey: "practiceLocation.state", pathKeyWithoutIndex: "practiceLocation.state" }
|
|
400
404
|
*
|
|
401
405
|
* @example
|
|
402
406
|
* // Multiple ignored prefixes (first token only)
|
|
403
407
|
* getConstraintRecordLookupPathKey("static.policyNumber", ["data", "static"])
|
|
404
|
-
* // Returns: "policyNumber"
|
|
408
|
+
* // Returns: { pathKey: "policyNumber", pathKeyWithoutIndex: "policyNumber" }
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* // Complex path with multiple array indices
|
|
412
|
+
* getConstraintRecordLookupPathKey("data.accounts.0.policies.1.coverage.terms", ["data"])
|
|
413
|
+
* // Returns: { pathKey: "accounts[0].policies[1].coverage.terms", pathKeyWithoutIndex: "accounts.policies.coverage.terms" }
|
|
405
414
|
*
|
|
406
415
|
* @example
|
|
407
416
|
* // Prefixes in middle tokens are not filtered
|
|
408
417
|
* getConstraintRecordLookupPathKey("form.data.field", ["data"])
|
|
409
|
-
* // Returns: "form.data.field"
|
|
418
|
+
* // Returns: { pathKey: "form.data.field", pathKeyWithoutIndex: "form.data.field" }
|
|
410
419
|
*
|
|
411
420
|
* @example
|
|
412
421
|
* // Empty path
|
|
413
422
|
* getConstraintRecordLookupPathKey("", ["data"])
|
|
414
|
-
* // Returns: ""
|
|
423
|
+
* // Returns: { pathKey: "", pathKeyWithoutIndex: "" }
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* // Numeric-only token
|
|
427
|
+
* getConstraintRecordLookupPathKey("0", [])
|
|
428
|
+
* // Returns: { pathKey: "[0]", pathKeyWithoutIndex: "" }
|
|
415
429
|
*/
|
|
416
|
-
export declare const getConstraintRecordLookupPathKey: (path: string, ignoredPrefixes: string[]) =>
|
|
430
|
+
export declare const getConstraintRecordLookupPathKey: (path: string, ignoredPrefixes: string[]) => {
|
|
431
|
+
pathKey: string;
|
|
432
|
+
pathKeyWithoutIndex: string;
|
|
433
|
+
};
|
|
417
434
|
|
|
418
435
|
/**
|
|
419
436
|
* Generates JSON schema fields for coverage terms based on the provided configuration.
|
|
@@ -745,41 +762,6 @@ export declare type QuoteRequestDefaultFields = z.infer<typeof defaultFieldSchem
|
|
|
745
762
|
|
|
746
763
|
export declare const shouldEvaluateConstraints: (data: Record<string, unknown>, localData: Record<string, unknown>, constraintFieldNames: string[]) => boolean;
|
|
747
764
|
|
|
748
|
-
/**
|
|
749
|
-
* Determines if a form should be submitted based on changes to constraint-related array fields.
|
|
750
|
-
*
|
|
751
|
-
* This function checks if any of the specified constraint fields have changed in a way that
|
|
752
|
-
* requires form submission. It specifically looks for:
|
|
753
|
-
* - Type changes (one value is an array, the other is not)
|
|
754
|
-
* - Array length changes (both are arrays but have different lengths)
|
|
755
|
-
*
|
|
756
|
-
* @param data - The original data object to compare against
|
|
757
|
-
* @param localData - The new/updated data object to compare
|
|
758
|
-
* @param constraintFieldNames - Array of field names that are constraint-related
|
|
759
|
-
* @returns `true` if the form should be submitted due to constraint field changes, `false` otherwise
|
|
760
|
-
*
|
|
761
|
-
* @example
|
|
762
|
-
* ```typescript
|
|
763
|
-
* const originalData = { practiceLocation: [{ state: 'CA' }] };
|
|
764
|
-
* const newData = { practiceLocation: [{ state: 'CA' }, { state: 'NY' }] };
|
|
765
|
-
* const constraintFields = ['practiceLocation.0.state', 'practiceLocation.1.state'];
|
|
766
|
-
*
|
|
767
|
-
* const shouldSubmit = shouldSubmitForm(originalData, newData, constraintFields);
|
|
768
|
-
* // Returns true because array length changed
|
|
769
|
-
* ```
|
|
770
|
-
*
|
|
771
|
-
* @example
|
|
772
|
-
* ```typescript
|
|
773
|
-
* const originalData = { riskType: 'Physician' };
|
|
774
|
-
* const newData = { riskType: ['Physician', 'Nurse'] };
|
|
775
|
-
* const constraintFields = ['riskType'];
|
|
776
|
-
*
|
|
777
|
-
* const shouldSubmit = shouldSubmitForm(originalData, newData, constraintFields);
|
|
778
|
-
* // Returns true because type changed from string to array
|
|
779
|
-
* ```
|
|
780
|
-
*/
|
|
781
|
-
export declare const shouldSubmitForm: (data: Record<string, unknown>, localData: Record<string, unknown>, constraintFieldNames: string[]) => boolean;
|
|
782
|
-
|
|
783
765
|
/**
|
|
784
766
|
* The function `splitInputAndQuantifier` takes a string input, removes certain characters from it, and
|
|
785
767
|
* extracts a quantifier if present.
|