@socotra/ec-react-utils 2.25.0-next.9 → 2.25.1-next.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/dist/index.d.ts +74 -0
- package/dist/index.es.js +8099 -8244
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +22 -22
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -124,6 +124,8 @@ declare interface DataModelToJsonSchemaProps {
|
|
|
124
124
|
falsyLabel?: string;
|
|
125
125
|
hiddenExceptions?: string[];
|
|
126
126
|
readOnly?: boolean;
|
|
127
|
+
wrapData?: boolean;
|
|
128
|
+
isFetchingEvaluatedConstraints?: boolean;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
declare const defaultFieldSchema: z.ZodObject<{
|
|
@@ -374,6 +376,43 @@ export declare function getAccountRequest(params: {
|
|
|
374
376
|
account?: undefined;
|
|
375
377
|
}): AccountCreateRequest;
|
|
376
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Converts a JSONForms data path to a constraint record lookup path key.
|
|
381
|
+
*
|
|
382
|
+
* This function processes a path string by filtering out ignored prefixes from the first token only
|
|
383
|
+
* and converting numeric tokens to array notation for constraint record lookups.
|
|
384
|
+
*
|
|
385
|
+
* @param path - The data path generated by JSONForms library (e.g., "practiceLocation.0.state", "practiceLocation.state")
|
|
386
|
+
* @param ignoredPrefixes - Array of prefixes to ignore from the first token only (e.g., ["data", "static"])
|
|
387
|
+
* @returns The path key formatted for constraint record lookup (e.g., "practiceLocation[0].state", "practiceLocation.state")
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* // Basic usage
|
|
391
|
+
* getConstraintRecordLookupPathKey("practiceLocation.0.state", ["data"])
|
|
392
|
+
* // Returns: "practiceLocation[0].state"
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* // With ignored prefix (first token only)
|
|
396
|
+
* getConstraintRecordLookupPathKey("data.practiceLocation.state", ["data"])
|
|
397
|
+
* // Returns: "practiceLocation.state"
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* // Multiple ignored prefixes (first token only)
|
|
401
|
+
* getConstraintRecordLookupPathKey("static.policyNumber", ["data", "static"])
|
|
402
|
+
* // Returns: "policyNumber"
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* // Prefixes in middle tokens are not filtered
|
|
406
|
+
* getConstraintRecordLookupPathKey("form.data.field", ["data"])
|
|
407
|
+
* // Returns: "form.data.field" (data in middle is not filtered)
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* // Empty path
|
|
411
|
+
* getConstraintRecordLookupPathKey("", ["data"])
|
|
412
|
+
* // Returns: ""
|
|
413
|
+
*/
|
|
414
|
+
export declare const getConstraintRecordLookupPathKey: (path: string, ignoredPrefixes: string[]) => string;
|
|
415
|
+
|
|
377
416
|
/**
|
|
378
417
|
* Generates JSON schema fields for coverage terms based on the provided configuration.
|
|
379
418
|
* @param coverageTerms - Array of coverage term strings
|
|
@@ -704,6 +743,41 @@ export declare type QuoteRequestDefaultFields = z.infer<typeof defaultFieldSchem
|
|
|
704
743
|
|
|
705
744
|
export declare const shouldEvaluateConstraints: (data: Record<string, unknown>, localData: Record<string, unknown>, constraintFieldNames: string[]) => boolean;
|
|
706
745
|
|
|
746
|
+
/**
|
|
747
|
+
* Determines if a form should be submitted based on changes to constraint-related array fields.
|
|
748
|
+
*
|
|
749
|
+
* This function checks if any of the specified constraint fields have changed in a way that
|
|
750
|
+
* requires form submission. It specifically looks for:
|
|
751
|
+
* - Type changes (one value is an array, the other is not)
|
|
752
|
+
* - Array length changes (both are arrays but have different lengths)
|
|
753
|
+
*
|
|
754
|
+
* @param data - The original data object to compare against
|
|
755
|
+
* @param localData - The new/updated data object to compare
|
|
756
|
+
* @param constraintFieldNames - Array of field names that are constraint-related
|
|
757
|
+
* @returns `true` if the form should be submitted due to constraint field changes, `false` otherwise
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```typescript
|
|
761
|
+
* const originalData = { practiceLocation: [{ state: 'CA' }] };
|
|
762
|
+
* const newData = { practiceLocation: [{ state: 'CA' }, { state: 'NY' }] };
|
|
763
|
+
* const constraintFields = ['practiceLocation.0.state', 'practiceLocation.1.state'];
|
|
764
|
+
*
|
|
765
|
+
* const shouldSubmit = shouldSubmitForm(originalData, newData, constraintFields);
|
|
766
|
+
* // Returns true because array length changed
|
|
767
|
+
* ```
|
|
768
|
+
*
|
|
769
|
+
* @example
|
|
770
|
+
* ```typescript
|
|
771
|
+
* const originalData = { riskType: 'Physician' };
|
|
772
|
+
* const newData = { riskType: ['Physician', 'Nurse'] };
|
|
773
|
+
* const constraintFields = ['riskType'];
|
|
774
|
+
*
|
|
775
|
+
* const shouldSubmit = shouldSubmitForm(originalData, newData, constraintFields);
|
|
776
|
+
* // Returns true because type changed from string to array
|
|
777
|
+
* ```
|
|
778
|
+
*/
|
|
779
|
+
export declare const shouldSubmitForm: (data: Record<string, unknown>, localData: Record<string, unknown>, constraintFieldNames: string[]) => boolean;
|
|
780
|
+
|
|
707
781
|
/**
|
|
708
782
|
* The function `splitInputAndQuantifier` takes a string input, removes certain characters from it, and
|
|
709
783
|
* extracts a quantifier if present.
|