@socotra/ec-react-components 2.20.1 → 2.21.0-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/README.md CHANGED
@@ -15,11 +15,11 @@ Our components are built with modern, robust technologies including **React**, *
15
15
 
16
16
  ## Key Features
17
17
 
18
- - **Schema-Driven UI**: Forms for quotes, policies, accounts, and transactions are generated dynamically from your data model, not hardcoded.
19
- - **Complex Logic Handling**: Built-in support for sophisticated insurance workflows, including constraint evaluation for real-time field dependency updates.
20
- - **Highly Customizable**: A powerful `tag` system allows for deep customization of field behavior directly from the data model—from conditional visibility to special UI controls like multi-select and currency inputs.
21
- - **Enterprise-Ready**: Designed to handle the intricate details of policy administration, including endorsements, payments, disbursements, and renewals.
22
- - **Modern Tech Stack**: A clean, modern, and performant codebase that is a pleasure to work with and extend.
18
+ - **Schema-Driven UI**: Forms for quotes, policies, accounts, and transactions are generated dynamically from your data model, not hardcoded.
19
+ - **Complex Logic Handling**: Built-in support for sophisticated insurance workflows, including constraint evaluation for real-time field dependency updates.
20
+ - **Highly Customizable**: A powerful `tag` system allows for deep customization of field behavior directly from the data model—from conditional visibility to special UI controls like multi-select and currency inputs.
21
+ - **Enterprise-Ready**: Designed to handle the intricate details of policy administration, including endorsements, payments, disbursements, and renewals.
22
+ - **Modern Tech Stack**: A clean, modern, and performant codebase that is a pleasure to work with and extend.
23
23
 
24
24
  ---
25
25
 
@@ -37,23 +37,24 @@ Dive into the detailed documentation for our core components to understand their
37
37
 
38
38
  ### Core Forms
39
39
 
40
- | Component | Description |
41
- | :--- | :--- |
42
- | **AccountForm** | A dynamic form for creating and updating customer accounts based on configurable account types. |
43
- | **QuoteForm** | The cornerstone of the quoting process. A comprehensive, multi-section form for creating and updating quotes with full support for constraint evaluation. |
44
- | **PolicyForm** | A specialized, read-only view for displaying the complete data of an issued policy in a structured format. |
45
- | **ElementForm** | A versatile and powerful form for rendering any sub-element of a policy or quote, such as a vehicle, driver, or location. |
46
- | **PaymentForm** | A suite of components for handling all payment-related actions: creating new payments, applying existing credit, and reversing transactions. |
47
- | **DisbursementForm** | A specialized form for processing disbursements from an account, with dynamic fields based on disbursement type. |
40
+ | Component | Description |
41
+ | :------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- |
42
+ | **AccountForm** | A dynamic form for creating and updating customer accounts based on configurable account types. |
43
+ | **QuoteForm** | The cornerstone of the quoting process. A comprehensive, multi-section form for creating and updating quotes with full support for constraint evaluation. |
44
+ | **PolicyForm** | A specialized, read-only view for displaying the complete data of an issued policy in a structured format. |
45
+ | **ElementForm** | A versatile and powerful form for rendering any sub-element of a policy or quote, such as a vehicle, driver, or location. |
46
+ | **PaymentForm** | A suite of components for handling all payment-related actions: creating new payments, applying existing credit, and reversing transactions. |
47
+ | **DisbursementForm** | A specialized form for processing disbursements from an account, with dynamic fields based on disbursement type. |
48
+ | **DataPropertyForm** | A dynamic form used for rendering and editing data properties using a provided data model and property schema. |
48
49
 
49
50
  ### Transaction Forms
50
51
 
51
52
  These forms are used for handling changes to policies post-issuance (endorsements, renewals, etc.).
52
53
 
53
- | Component | Description |
54
- | :--- | :--- |
54
+ | Component | Description |
55
+ | :----------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
55
56
  | **InitializedTransactionForm** | Handles transactions in an `initialized` state (e.g., a new business quote), with full support for constraint evaluation to manage complex field dependencies before issuance. |
56
- | **DraftTransactionForm** | A specialized form for midterm policy changes. It generates the necessary `param` and `modify` change instructions to accurately update a `draft` transaction. |
57
+ | **DraftTransactionForm** | A specialized form for midterm policy changes. It generates the necessary `param` and `modify` change instructions to accurately update a `draft` transaction. |
57
58
 
58
59
  ---
59
60
 
@@ -62,21 +63,21 @@ These forms are used for handling changes to policies post-issuance (endorsement
62
63
  To unlock the full potential of this library, it's essential to understand the `tag` system. Our custom rendering guide provides a detailed walkthrough of how to control form behavior directly from your data model.
63
64
 
64
65
  This guide covers:
65
- - Conditional Field Hiding (`hidden|...`, `rootHidden|...`, `hidden`)
66
- - Advanced UI Controls (`multiselect`, `horizontal-layout`)
67
- - Data Formatting (`currency`)
68
66
 
67
+ - Conditional Field Hiding (`hidden|...`, `rootHidden|...`, `hidden`)
68
+ - Advanced UI Controls (`multiselect`, `horizontal-layout`)
69
+ - Data Formatting (`currency`)
69
70
 
70
71
  ## Theming
71
72
 
72
73
  To style the components, follow the instructions in the theming guide.
73
74
 
74
- This guide covers:
75
+ This guide covers:
76
+
75
77
  - Theming with Tailwind CSS and `shadcn/ui`
76
78
  - CSS Imports from the package
77
79
  - Per-Component Style Overrides
78
80
 
79
-
80
81
  ## Documentation
81
82
 
82
83
  The documentation for this package is generated from a script that must be run after the package is built.
@@ -92,4 +93,4 @@ Edit files under the `components` directory.
92
93
 
93
94
  Run `pnpm run sync` to update the documentation in the `README.md` files of the other packages.
94
95
 
95
- Follow instructions in the `ec-react/packages/docs/README.md` file to build the documentation and update the `Socotra Documentation` repo.
96
+ Follow instructions in the `ec-react/packages/docs/README.md` file to build the documentation and update the `Socotra Documentation` repo.
package/dist/index.d.ts CHANGED
@@ -1,20 +1,22 @@
1
1
  import { AccountConfigRecord } from '@socotra/ec-react-schemas';
2
2
  import { AccountCreateRequest } from '@socotra/ec-react-schemas';
3
+ import { AccountEvaluateConstraintsRequest } from '@socotra/ec-react-schemas';
3
4
  import { AccountResponse } from '@socotra/ec-react-schemas';
4
5
  import { AccountUpdateRequest } from '@socotra/ec-react-schemas';
5
- import { ConstraintEvaluationResponse } from '@socotra/ec-react-schemas';
6
6
  import { CoverageTermsConfigRecord } from '@socotra/ec-react-schemas';
7
7
  import { CreditDistributionRequest } from '@socotra/ec-react-schemas';
8
8
  import { CreditDistributionReverseRequest } from '@socotra/ec-react-schemas';
9
9
  import { CurrencyType } from '@socotra/ec-react-schemas';
10
10
  import { DataModel } from '@socotra/ec-react-schemas';
11
11
  import { DataTypeConfigRecord } from '@socotra/ec-react-schemas';
12
+ import { DependencyMapResponse } from '@socotra/ec-react-schemas';
12
13
  import { DisbursementCreateRequest } from '@socotra/ec-react-schemas';
13
14
  import { DisbursementRefRecord } from '@socotra/ec-react-schemas';
14
15
  import { ElementConfig } from '@socotra/ec-react-schemas';
15
16
  import { ElementRequest } from '@socotra/ec-react-schemas';
16
17
  import { ElementResponse } from '@socotra/ec-react-schemas';
17
18
  import { EvaluateConstraintsRequest } from '@socotra/ec-react-schemas';
19
+ import { EvaluateConstraintsResponse } from '@socotra/ec-react-schemas';
18
20
  import { FieldConfigRecord } from '@socotra/ec-react-schemas';
19
21
  import { ForwardRefExoticComponent } from 'react';
20
22
  import { JSX as JSX_2 } from 'react/jsx-runtime';
@@ -27,7 +29,6 @@ import { PaymentRequest as PaymentRequest_2 } from '@socotra/ec-react-schemas';
27
29
  import { PolicyResponse } from '@socotra/ec-react-schemas';
28
30
  import { ProductConfig } from '@socotra/ec-react-schemas';
29
31
  import { PropertyRef } from '@socotra/ec-react-schemas';
30
- import { QuoteDependencyMapResponse } from '@socotra/ec-react-schemas';
31
32
  import { QuoteRequest } from '@socotra/ec-react-schemas';
32
33
  import { QuoteResponse } from '@socotra/ec-react-schemas';
33
34
  import { RefAttributes } from 'react';
@@ -40,7 +41,10 @@ import { TransactionSnapshotResponse } from '@socotra/ec-react-schemas';
40
41
  * AccountForm is a form for creating or updating an account. It required a resolved data model, custom data types, and an optional account object to put the form in update mode.
41
42
  */
42
43
  export declare const AccountForm: {
43
- ({ dataModel, accountType, disabled, handleSubmit, isSubmitting, preventFormResetOnDisabled, hideSubmitButton, hideAdvancedFields, validateOnSubmit, account, submitButtonText, id, titles, styles, }: Props): JSX_2.Element;
44
+ ({ dataModel, accountType, disabled, handleSubmit, isSubmitting, preventFormResetOnDisabled, hideSubmitButton, hideAdvancedFields, validateOnSubmit, account, submitButtonText, id, titles, styles, dependencyMap, getEvaluatedConstraints, }: Props & {
45
+ dependencyMap?: DependencyMapResponse;
46
+ getEvaluatedConstraints?: (request: AccountEvaluateConstraintsRequest) => Promise<EvaluateConstraintsResponse | undefined>;
47
+ }): JSX_2.Element;
44
48
  displayName: string;
45
49
  };
46
50
 
@@ -104,6 +108,14 @@ declare type BaseProps = {
104
108
  invoiceDocument?: string;
105
109
  installmentPlanName?: string;
106
110
  };
111
+ /**
112
+ * Optional dependency map for account constraints
113
+ */
114
+ dependencyMap?: DependencyMapResponse;
115
+ /**
116
+ * Optional function to evaluate constraints for the account
117
+ */
118
+ getEvaluatedConstraints?: (request: AccountEvaluateConstraintsRequest) => Promise<EvaluateConstraintsResponse | undefined>;
107
119
  };
108
120
 
109
121
  /**
@@ -337,7 +349,9 @@ declare type Props_2 = {
337
349
  /**
338
350
  * The function to call when the form is submitted. It will create an QuoteRequest from the form data.
339
351
  */
340
- handleSubmit: (data: QuoteRequest) => void;
352
+ handleSubmit: (data: QuoteRequest, staticData?: {
353
+ [key: string]: any;
354
+ }) => void;
341
355
  /**
342
356
  * Set to true when the form is submitting to set fields to readonly and disable the submit button
343
357
  */
@@ -373,6 +387,11 @@ declare type Props_2 = {
373
387
  * default is false
374
388
  */
375
389
  hideAdvancedFields?: boolean;
390
+ /**
391
+ * Whether to hide the static data fields
392
+ * default is false
393
+ */
394
+ hideStaticDataFields?: boolean;
376
395
  /**
377
396
  * Whether to hide the coverage terms fields
378
397
  * default is false
@@ -396,14 +415,14 @@ declare type Props_2 = {
396
415
  * }
397
416
  * });
398
417
  */
399
- dependencyMap?: QuoteDependencyMapResponse;
418
+ dependencyMap?: DependencyMapResponse;
400
419
  /**
401
420
  * Evaluates constraints for the quote to determine the values of other fields
402
421
  *
403
422
  * This function must be provided to enable the form to evaluate constraints
404
423
  *
405
424
  * @param {object} request - The request object containing the quote locator
406
- * @param {string} tenantLocator - The tenant locator
425
+ * @param {string} quoteLocator - The locator of the quote
407
426
  * @param {string} locator - The locator of the element to evaluate constraints for
408
427
  * @example
409
428
  * const getEvaluatedConstraints = async (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => {
@@ -419,7 +438,7 @@ declare type Props_2 = {
419
438
  * return data;
420
439
  * }
421
440
  */
422
- getEvaluatedConstraints?: (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => Promise<ConstraintEvaluationResponse | undefined>;
441
+ getEvaluatedConstraints?: (request: EvaluateConstraintsRequest, quoteLocator: string, locator: string) => Promise<EvaluateConstraintsResponse | undefined>;
423
442
  /**
424
443
  * Whether to hide all fields
425
444
  */
@@ -450,6 +469,16 @@ declare type Props_2 = {
450
469
  truthyLabel?: string;
451
470
  falsyLabel?: string;
452
471
  installmentPlanName?: string;
472
+ staticData?: string;
473
+ };
474
+ /**
475
+ * Default open state for advanced and static data fields
476
+ * If not provided, the advanced fields will be closed and static data fields will be open
477
+ * Default value is { advancedFields: false, staticDataFields: true }
478
+ */
479
+ defaultOpen?: {
480
+ advancedFields?: boolean;
481
+ staticDataFields?: boolean;
453
482
  };
454
483
  };
455
484
 
@@ -530,7 +559,7 @@ declare type Props_3 = {
530
559
  * }
531
560
  * });
532
561
  */
533
- dependencyMap?: QuoteDependencyMapResponse;
562
+ dependencyMap?: DependencyMapResponse;
534
563
  /**
535
564
  * Evaluates constraints for the quote to determine the values of other fields
536
565
  *
@@ -553,7 +582,7 @@ declare type Props_3 = {
553
582
  * return data;
554
583
  * }
555
584
  */
556
- getEvaluatedConstraints?: (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => Promise<ConstraintEvaluationResponse | undefined>;
585
+ getEvaluatedConstraints?: (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => Promise<EvaluateConstraintsResponse | undefined>;
557
586
  /**
558
587
  * Custom form styling
559
588
  * See https://github.com/eclipsesource/jsonforms/blob/master/packages/vanilla-renderers/Styles.md
@@ -887,7 +916,7 @@ declare type Props_8 = {
887
916
  * }
888
917
  * });
889
918
  */
890
- dependencyMap?: QuoteDependencyMapResponse;
919
+ dependencyMap?: DependencyMapResponse;
891
920
  /**
892
921
  * Evaluates constraints for the quote to determine the values of other fields
893
922
  *
@@ -910,7 +939,7 @@ declare type Props_8 = {
910
939
  * return data;
911
940
  * }
912
941
  */
913
- getEvaluatedConstraints?: (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => Promise<ConstraintEvaluationResponse | undefined>;
942
+ getEvaluatedConstraints?: (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => Promise<EvaluateConstraintsResponse | undefined>;
914
943
  /**
915
944
  * Custom form styling
916
945
  * See https://github.com/eclipsesource/jsonforms/blob/master/packages/vanilla-renderers/Styles.md