@socotra/ec-react-components 2.19.3-next.6 → 2.19.3-next.7

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
@@ -1,78 +1,95 @@
1
- # @socotra/ec-react-components
1
+ ---
2
+ title: ec-react-components
3
+ description: React components for the Socotra Insurance Suite.
4
+ ---
2
5
 
3
- A React component library for generating forms and other components for EC.
6
+ # EC React Components
4
7
 
5
- This library is styled via [tailwindcss](https://tailwindcss.com/) and [shadcn/ui](https://ui.shadcn.com/).
8
+ `@socotra/ec-react-components` is a powerful, schema-driven framework for building enterprise-grade insurance applications. This library provides a comprehensive suite of dynamic forms and UI components designed to accelerate development and handle the full spectrum of policy lifecycle operations with unparalleled flexibility.
6
9
 
7
- - **Package name**: `@socotra/ec-react-components`
8
- - **Repo Path**: `packages/components`
9
- - **Install**:
10
- ```sh
11
- npm i @socotra/ec-react-components @tailwindcss/container-queries
12
- ```
13
- - **Usage**:
10
+ ## Core Philosophy
14
11
 
15
- ```js
16
- // Import style.css anywhere in your application, preferably at the root
17
- import '@socotra/ec-react-components/dist/style.css';
12
+ At its core, this library is engineered to translate Socotra's flexible data model directly into a rich, interactive user interface. By leveraging your unique data model, we dynamically generate complex forms, eliminating the need to manually build and maintain forms for every product or data variation. This schema-driven approach ensures that as your insurance products evolve, your UI adapts automatically, dramatically reducing development overhead and increasing speed to market.
18
13
 
19
- import { MyComponent } from '@socotra/ec-react-components';
20
- ```
14
+ Our components are built with modern, robust technologies including **React**, **TypeScript**, **Shadcn UI**, and **Tailwind CSS**, ensuring a developer-friendly, performant, and highly customizable experience.
21
15
 
22
- - Add the plugin to your `tailwind.config.js` file along with the content path:
16
+ ## Key Features
23
17
 
24
- ```js
25
- // tailwind.config.js
26
- module.exports = {
27
- content: [
28
- // ...
29
- './node_modules/@socotra/ec-react-components/dist/**/*.js',
30
- ]
31
- theme: {
32
- // ...
33
- },
34
- plugins: [
35
- require('@tailwindcss/container-queries'),
36
- // ...
37
- ],
38
- };
39
- ```
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.
40
23
 
41
- ## Customization
24
+ ---
42
25
 
43
- As this library is styled via shadcn components and tailwind, customization can be achieved by installing shadcn in your project. Follow the installation guide from [shadcn](https://ui.shadcn.com/docs/installation) and adjust your theme using the [theme creator](https://ui.shadcn.com/themes).
26
+ ## Installation
44
27
 
45
- Once you install shadcn, or if you are using it already, **delete the style.css import** to avoid style collisions
28
+ ```sh
29
+ npm i @socotra/ec-react-components
30
+ ```
46
31
 
47
- ### Running the Project Locally
32
+ ---
48
33
 
49
- To build the package:
34
+ ## Component Documentation
50
35
 
51
- ```sh
52
- pnpm run build
53
- ```
36
+ Dive into the detailed documentation for our core components to understand their purpose, props, and advanced capabilities.
54
37
 
55
- To run tests:
38
+ ### Core Forms
56
39
 
57
- ```sh
58
- pnpm run test
59
- ```
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. |
60
48
 
61
- To run the linter:
49
+ ### Transaction Forms
62
50
 
63
- ```sh
64
- pnpm run lint
65
- ```
51
+ These forms are used for handling changes to policies post-issuance (endorsements, renewals, etc.).
66
52
 
67
- To run the sandbox
53
+ | Component | Description |
54
+ | :--- | :--- |
55
+ | **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. |
68
57
 
69
- ```sh
70
- cd ../sandbox
71
- pnpm run dev
72
- ```
58
+ ---
59
+
60
+ ## Custom Rendering (Tags for Fields)
61
+
62
+ 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.
73
63
 
74
- Installing directly for local development
64
+ This guide covers:
65
+ - Conditional Field Hiding (`hidden|...`, `rootHidden|...`, `hidden`)
66
+ - Advanced UI Controls (`multiselect`, `horizontal-layout`)
67
+ - Data Formatting (`currency`)
68
+
69
+
70
+ ## Theming
71
+
72
+ To style the components, follow the instructions in the theming guide.
73
+
74
+ This guide covers:
75
+ - Theming with Tailwind CSS and `shadcn/ui`
76
+ - CSS Imports from the package
77
+ - Per-Component Style Overrides
78
+
79
+
80
+ ## Documentation
81
+
82
+ The documentation for this package is generated from a script that must be run after the package is built.
83
+
84
+ To contribute to the documentation, clone the repo and run the following command:
75
85
 
76
86
  ```sh
77
- pnpm i ../path/to/this/packages/components
87
+ git clone https://github.com/socotra/ec-react.git
88
+ cd ec-react/packages/docs/src/components
78
89
  ```
90
+
91
+ Edit files under the `components` directory.
92
+
93
+ Run `pnpm run sync` to update the documentation in the `README.md` files of the other packages.
94
+
95
+ 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
@@ -15,6 +15,7 @@ import { ElementConfig } from '@socotra/ec-react-schemas';
15
15
  import { ElementRequest } from '@socotra/ec-react-schemas';
16
16
  import { ElementResponse } from '@socotra/ec-react-schemas';
17
17
  import { EvaluateConstraintsRequest } from '@socotra/ec-react-schemas';
18
+ import { FieldConfigRecord } from '@socotra/ec-react-schemas';
18
19
  import { ForwardRefExoticComponent } from 'react';
19
20
  import { JSX as JSX_2 } from 'react/jsx-runtime';
20
21
  import { ModifyChangeInstructionCreateRequest } from '@socotra/ec-react-schemas';
@@ -25,6 +26,7 @@ import { PaymentConfigRecord } from '@socotra/ec-react-schemas';
25
26
  import { PaymentRequest as PaymentRequest_2 } from '@socotra/ec-react-schemas';
26
27
  import { PolicyResponse } from '@socotra/ec-react-schemas';
27
28
  import { ProductConfig } from '@socotra/ec-react-schemas';
29
+ import { PropertyRef } from '@socotra/ec-react-schemas';
28
30
  import { QuoteDependencyMapResponse } from '@socotra/ec-react-schemas';
29
31
  import { QuoteRequest } from '@socotra/ec-react-schemas';
30
32
  import { QuoteResponse } from '@socotra/ec-react-schemas';
@@ -104,6 +106,14 @@ declare type BaseProps = {
104
106
  };
105
107
  };
106
108
 
109
+ /**
110
+ * DataPropertyForm is a form to render data based on data property schema and data model with edit and submission capabilities.
111
+ */
112
+ export declare const DataPropertyForm: {
113
+ ({ data, dataModel, id, titles, dataPropertySchema, handleSubmit, isSubmitting, disabled, hideSubmitButton, validateOnSubmit, submitButtonText, readonly, }: Props_11): JSX_2.Element;
114
+ displayName: string;
115
+ };
116
+
107
117
  /**
108
118
  * `DraftTransactionForm` is a form for updating a transaction on an issued policy. It requires a transaction in a `draft` state, a `transactionSnapshot`, `paramsChangeInstruction` (created when the transaction is created), and data types / product model / coverage terms from the tenant data model.
109
119
  */
@@ -260,6 +270,61 @@ declare type Props_10 = {
260
270
  } & Partial<GetDisbursementFormDefaultFieldsProps['titles']>;
261
271
  };
262
272
 
273
+ declare type Props_11 = {
274
+ /**
275
+ * The resolved data model retrieved from data model response
276
+ */
277
+ dataModel: DataModel;
278
+ /**
279
+ * The data schema configuration
280
+ */
281
+ dataPropertySchema: FieldConfigRecord;
282
+ /**
283
+ * The initial data to display in the form
284
+ */
285
+ data: Record<string, PropertyRef>;
286
+ /**
287
+ * The function to call when the form is submitted. It will create an PaymentRequest from the form data.
288
+ */
289
+ handleSubmit?: (data: Record<string, PropertyRef>) => void;
290
+ /**
291
+ * Set to true when the form is submitting to set fields to readonly and disable the submit button
292
+ */
293
+ isSubmitting?: boolean;
294
+ /**
295
+ * Disables the form
296
+ */
297
+ disabled?: boolean;
298
+ /**
299
+ * Hides the submit button
300
+ */
301
+ hideSubmitButton?: boolean;
302
+ /**
303
+ * Whether to validate the form on submit
304
+ */
305
+ validateOnSubmit?: boolean;
306
+ /**
307
+ * The text to display on the submit button
308
+ */
309
+ submitButtonText?: string;
310
+ /**
311
+ * Readonly mode for the form
312
+ */
313
+ readonly?: boolean;
314
+ /**
315
+ * ID for the form wrapper
316
+ */
317
+ id?: string;
318
+ /**
319
+ * Titles for the form and boolean labels
320
+ */
321
+ titles?: {
322
+ formTitle?: string;
323
+ truthyLabel?: string;
324
+ falsyLabel?: string;
325
+ };
326
+ };
327
+
263
328
  declare type Props_2 = {
264
329
  /**
265
330
  * The quote object