tee3apps-cms-sdk-react 0.0.9 → 0.0.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/README.md CHANGED
@@ -69,7 +69,7 @@ export default App;
69
69
 
70
70
  ## 📝 Using PageForm Component
71
71
 
72
- The `PageForm` component allows you to render dynamic forms based on JSON data. It includes built-in validation, form state management, and toast notifications.
72
+ The `PageForm` component allows you to render dynamic forms based on JSON data. It includes built-in validation, form state management, toast notifications, and API submission support.
73
73
 
74
74
  ### Basic PageForm Usage
75
75
 
@@ -120,6 +120,32 @@ function FormPage() {
120
120
  export default FormPage;
121
121
  ```
122
122
 
123
+ ### PageForm with API Submission
124
+
125
+ You can configure the form to automatically submit to an API endpoint:
126
+
127
+ ```jsx
128
+ <PageForm
129
+ jsonData={formData}
130
+ isUrl={true}
131
+ method="POST"
132
+ url="https://api.example.com/submit"
133
+ onSubmit={(responseData) => {
134
+ // This callback is called after successful API submission
135
+ // responseData contains the API response
136
+ console.log('API Response:', responseData);
137
+ }}
138
+ />
139
+ ```
140
+
141
+ **API Submission Props:**
142
+ - `isUrl` (boolean): Set to `true` to enable API submission
143
+ - `method` ('POST' | 'GET'): HTTP method to use (defaults to 'POST')
144
+ - `url` (string): API endpoint URL
145
+ - `onSubmit` (function): Callback function called after submission (receives API response or error)
146
+
147
+ **Note:** When `isUrl` is `false` or not provided, the form uses the `onSubmit` callback with form data directly.
148
+
123
149
  ## 📊 Data Structure
124
150
 
125
151
  The package expects your `pageElements` data to follow this structure:
@@ -464,23 +490,30 @@ The `PageForm` component expects the same structure as `Page`, but with form-spe
464
490
 
465
491
  ### Supported Form Field Types
466
492
 
467
- - **InputField**: Text input fields (text, email, password, etc.)
493
+ - **InputField**: Text input fields (text, email, password, etc.) with postal code formatting support
468
494
  - **NumberField**: Numeric input with min/max validation
469
495
  - **DateField**: Date picker with format support
470
496
  - **SelectField**: Dropdown select with single or multi-select
471
497
  - **RadioField**: Radio button group
472
498
  - **BooleanField**: Checkbox or toggle switch
499
+ - **TermsAndCondition**: Terms and conditions checkbox with modal popup for conditions
500
+ - **ButtonField**: Form buttons with submit, reset, and cancel types
473
501
 
474
502
  ### Form Features
475
503
 
476
504
  - **Automatic Validation**: Required fields are validated automatically
477
- - **Toast Notifications**: Custom toast notifications for validation errors
505
+ - **Toast Notifications**: Custom toast notifications for validation errors and form actions
478
506
  - **Field Name Mapping**: Form values are automatically transformed from codes to field names
479
507
  - **Responsive Design**: Forms adapt to different device modes (web, mobileweb, mobileapp, tablet)
480
508
  - **Error Highlighting**: Invalid fields are visually highlighted
509
+ - **API Submission**: Built-in support for submitting forms directly to API endpoints
510
+ - **Button Types**: Support for submit, reset, and cancel button types
511
+ - **Form Reset/Cancel**: Built-in handlers for resetting or cancelling forms
481
512
 
482
513
  ### Form Submission
483
514
 
515
+ #### Using Callback (Default)
516
+
484
517
  The `onSubmit` callback receives form data with field names as keys:
485
518
 
486
519
  ```jsx
@@ -498,6 +531,92 @@ const handleFormSubmit = (formValues) => {
498
531
  };
499
532
  ```
500
533
 
534
+ #### Using API Submission
535
+
536
+ When `isUrl={true}`, the form automatically submits to the specified API:
537
+
538
+ ```jsx
539
+ <PageForm
540
+ jsonData={formData}
541
+ isUrl={true}
542
+ method="POST"
543
+ url="https://api.example.com/submit"
544
+ onSubmit={(responseData) => {
545
+ // Called after successful API submission
546
+ // responseData contains the API response
547
+ console.log('Success:', responseData);
548
+ }}
549
+ />
550
+ ```
551
+
552
+ **API Submission Behavior:**
553
+ - **POST requests**: Form data is sent in the request body as JSON
554
+ - **GET requests**: Form data is appended as query parameters
555
+ - **Success**: Shows success toast and calls `onSubmit` with response data
556
+ - **Error**: Shows error toast and calls `onSubmit` with error information
557
+
558
+ ### Button Types
559
+
560
+ Buttons support three types: `submit`, `reset`, and `cancel`:
561
+
562
+ ```json
563
+ {
564
+ "name": "ButtonField",
565
+ "props": {
566
+ "text": {
567
+ "all": "Submit",
568
+ "en-IN": "Submit"
569
+ },
570
+ "buttonType": "submit",
571
+ "disabled": false,
572
+ "mode": {
573
+ "web": {
574
+ "radius": "5px",
575
+ "bgColor": "#3498db",
576
+ "textstyle": {
577
+ "fontSize": 16,
578
+ "fontColor": "#ffffff",
579
+ "fontStyle": {
580
+ "isBold": false,
581
+ "isItalic": false,
582
+ "isUnderLine": false,
583
+ "isStrikeThrough": false
584
+ }
585
+ }
586
+ }
587
+ }
588
+ }
589
+ }
590
+ ```
591
+
592
+ **Button Types:**
593
+ - `submit`: Triggers form submission (shows "Submitting..." during API calls)
594
+ - `reset`: Resets all form fields and validation errors
595
+ - `cancel`: Cancels the form (same as reset, can be customized)
596
+
597
+ ### Field Component Props
598
+
599
+ #### InputField
600
+ - `helperText`: Used as placeholder text
601
+ - `format`: "Postalcode" for postal code formatting
602
+ - `postaltype`: "State" for US postal code formatting
603
+ - `textArea`: `true` to render as textarea
604
+ - `minLength` / `maxLength`: Length constraints
605
+
606
+ #### NumberField
607
+ - `helperText`: Used as placeholder text
608
+ - `termsandcondition`: HTML text displayed below input
609
+ - `onText` / `offText`: Status text displayed
610
+
611
+ #### RadioField
612
+ - `helperText`: Displayed in parentheses after the label (e.g., "Label (helperText)")
613
+
614
+ #### TermsAndCondition
615
+ - `termsText`: Clickable terms text (HTML supported)
616
+ - `conditionText`: Conditions displayed in modal popup (HTML supported)
617
+ - `isRequired`: Whether checkbox is required
618
+ - `checked`: Initial checked state
619
+
501
620
  ## 📄 License
502
621
 
503
622
  This project is licensed under the MIT License.
package/dist/index.d.ts CHANGED
@@ -109,6 +109,15 @@ type ComponentProps = {
109
109
  disabled?: boolean;
110
110
  bgColor?: string;
111
111
  radius?: string;
112
+ conditionText?: {
113
+ all?: string;
114
+ };
115
+ termsText?: {
116
+ all?: string;
117
+ };
118
+ isRequired?: boolean;
119
+ checked?: boolean;
120
+ buttonType?: 'submit' | 'reset' | 'cancel';
112
121
  };
113
122
  type Component = {
114
123
  name: string;
@@ -187,6 +196,9 @@ type Row = {
187
196
  interface PageFormProps {
188
197
  jsonData: Row[];
189
198
  onSubmit?: (data: Record<string, any>) => void;
199
+ isUrl?: boolean;
200
+ method?: 'POST' | 'GET' | 'post' | 'get';
201
+ url?: string;
190
202
  }
191
203
  declare const PageForm: React.FC<PageFormProps>;
192
204