@socotra/ec-react-utils 2.25.0-next.1 → 2.25.0-next.11
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 +78 -1
- package/dist/index.es.js +5124 -5042
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +20 -20
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ import { QuoteRequest } from '@socotra/ec-react-schemas';
|
|
|
29
29
|
import { QuoteResponse } from '@socotra/ec-react-schemas';
|
|
30
30
|
import { SegmentResponse } from '@socotra/ec-react-schemas';
|
|
31
31
|
import { TransactionSnapshotResponse } from '@socotra/ec-react-schemas';
|
|
32
|
+
import { Translator } from '@jsonforms/core';
|
|
33
|
+
import { UISchemaElement } from '@jsonforms/core';
|
|
32
34
|
import { z } from 'zod/v4';
|
|
33
35
|
|
|
34
36
|
/**
|
|
@@ -121,6 +123,9 @@ declare interface DataModelToJsonSchemaProps {
|
|
|
121
123
|
truthyLabel?: string;
|
|
122
124
|
falsyLabel?: string;
|
|
123
125
|
hiddenExceptions?: string[];
|
|
126
|
+
readOnly?: boolean;
|
|
127
|
+
wrapData?: boolean;
|
|
128
|
+
isFetchingEvaluatedConstraints?: boolean;
|
|
124
129
|
}
|
|
125
130
|
|
|
126
131
|
declare const defaultFieldSchema: z.ZodObject<{
|
|
@@ -371,6 +376,43 @@ export declare function getAccountRequest(params: {
|
|
|
371
376
|
account?: undefined;
|
|
372
377
|
}): AccountCreateRequest;
|
|
373
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
|
+
|
|
374
416
|
/**
|
|
375
417
|
* Generates JSON schema fields for coverage terms based on the provided configuration.
|
|
376
418
|
* @param coverageTerms - Array of coverage term strings
|
|
@@ -701,6 +743,41 @@ export declare type QuoteRequestDefaultFields = z.infer<typeof defaultFieldSchem
|
|
|
701
743
|
|
|
702
744
|
export declare const shouldEvaluateConstraints: (data: Record<string, unknown>, localData: Record<string, unknown>, constraintFieldNames: string[]) => boolean;
|
|
703
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
|
+
|
|
704
781
|
/**
|
|
705
782
|
* The function `splitInputAndQuantifier` takes a string input, removes certain characters from it, and
|
|
706
783
|
* extracts a quantifier if present.
|
|
@@ -768,6 +845,6 @@ declare interface TransactionFormData_3 {
|
|
|
768
845
|
timezone: string;
|
|
769
846
|
}
|
|
770
847
|
|
|
771
|
-
export declare function translateError(error: ErrorObject): string;
|
|
848
|
+
export declare function translateError(error: ErrorObject, _translator: Translator, uischema?: UISchemaElement): string;
|
|
772
849
|
|
|
773
850
|
export { }
|