@socotra/ec-react-utils 2.25.2-next.0 → 2.25.2-next.1

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 CHANGED
@@ -379,41 +379,57 @@ export declare function getAccountRequest(params: {
379
379
  }): AccountCreateRequest;
380
380
 
381
381
  /**
382
- * Converts a JSONForms data path to a constraint record lookup path key.
382
+ * Converts a JSONForms data path to constraint record lookup path keys.
383
383
  *
384
384
  * 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.
385
+ * and converting numeric tokens to array notation for constraint record lookups. It returns both
386
+ * the full path with array notation and a simplified path without array indices.
386
387
  *
387
388
  * @param path - The data path generated by JSONForms library (e.g., "practiceLocation.0.state", "practiceLocation.state")
388
389
  * @param ignoredPrefixes - Array of prefixes to ignore from the first token only (e.g., ["data", "static"])
389
- * @returns The path key formatted for constraint record lookup (e.g., "practiceLocation[0].state", "practiceLocation.state")
390
+ * @returns An object containing:
391
+ * - `pathKey`: The full path with array notation for numeric tokens (e.g., "practiceLocation[0].state")
392
+ * - `pathKeyWithoutIndex`: The simplified path with numeric tokens removed (e.g., "practiceLocation.state")
390
393
  *
391
394
  * @example
392
395
  * // Basic usage
393
- * getConstraintRecordLookupPathKey("practiceLocation.0.state", ["data"])
394
- * // Returns: "practiceLocation[0].state"
396
+ * getConstraintRecordLookupPathKey("practiceLocation.0.state", [])
397
+ * // Returns: { pathKey: "practiceLocation[0].state", pathKeyWithoutIndex: "practiceLocation.state" }
395
398
  *
396
399
  * @example
397
400
  * // With ignored prefix (first token only)
398
401
  * getConstraintRecordLookupPathKey("data.practiceLocation.state", ["data"])
399
- * // Returns: "practiceLocation.state"
402
+ * // Returns: { pathKey: "practiceLocation.state", pathKeyWithoutIndex: "practiceLocation.state" }
400
403
  *
401
404
  * @example
402
405
  * // Multiple ignored prefixes (first token only)
403
406
  * getConstraintRecordLookupPathKey("static.policyNumber", ["data", "static"])
404
- * // Returns: "policyNumber"
407
+ * // Returns: { pathKey: "policyNumber", pathKeyWithoutIndex: "policyNumber" }
408
+ *
409
+ * @example
410
+ * // Complex path with multiple array indices
411
+ * getConstraintRecordLookupPathKey("data.accounts.0.policies.1.coverage.terms", ["data"])
412
+ * // Returns: { pathKey: "accounts[0].policies[1].coverage.terms", pathKeyWithoutIndex: "accounts.policies.coverage.terms" }
405
413
  *
406
414
  * @example
407
415
  * // Prefixes in middle tokens are not filtered
408
416
  * getConstraintRecordLookupPathKey("form.data.field", ["data"])
409
- * // Returns: "form.data.field" (data in middle is not filtered)
417
+ * // Returns: { pathKey: "form.data.field", pathKeyWithoutIndex: "form.data.field" }
410
418
  *
411
419
  * @example
412
420
  * // Empty path
413
421
  * getConstraintRecordLookupPathKey("", ["data"])
414
- * // Returns: ""
422
+ * // Returns: { pathKey: "", pathKeyWithoutIndex: "" }
423
+ *
424
+ * @example
425
+ * // Numeric-only token
426
+ * getConstraintRecordLookupPathKey("0", [])
427
+ * // Returns: { pathKey: "[0]", pathKeyWithoutIndex: "" }
415
428
  */
416
- export declare const getConstraintRecordLookupPathKey: (path: string, ignoredPrefixes: string[]) => string;
429
+ export declare const getConstraintRecordLookupPathKey: (path: string, ignoredPrefixes: string[]) => {
430
+ pathKey: string;
431
+ pathKeyWithoutIndex: string;
432
+ };
417
433
 
418
434
  /**
419
435
  * Generates JSON schema fields for coverage terms based on the provided configuration.
@@ -745,41 +761,6 @@ export declare type QuoteRequestDefaultFields = z.infer<typeof defaultFieldSchem
745
761
 
746
762
  export declare const shouldEvaluateConstraints: (data: Record<string, unknown>, localData: Record<string, unknown>, constraintFieldNames: string[]) => boolean;
747
763
 
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
764
  /**
784
765
  * The function `splitInputAndQuantifier` takes a string input, removes certain characters from it, and
785
766
  * extracts a quantifier if present.