@kbgarcia8/react-dynamic-form 1.1.40 → 2.0.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 +17 -2
- package/dist/components/atoms/Button/Button.d.ts.map +1 -1
- package/dist/components/molecules/FormActionButtons/FormActionButtons.d.ts +1 -1
- package/dist/components/molecules/FormActionButtons/FormActionButtons.d.ts.map +1 -1
- package/dist/components/organisms/DynamicForm/DynamicForm.d.ts +1 -1
- package/dist/components/organisms/DynamicForm/DynamicForm.d.ts.map +1 -1
- package/dist/react-dynamic-form.cjs.js +26 -26
- package/dist/react-dynamic-form.es.js +368 -362
- package/dist/type/propTypes.d.ts +18 -10
- package/dist/type/propTypes.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ Reusable React dynamic form showcasing editable, expandable and flexible inputs
|
|
|
36
36
|
* [Styling components via styled-components](#styling-components-via-styled-components)
|
|
37
37
|
+ [Available Default Class Names](#available-default-class-names)
|
|
38
38
|
- [Local Development](#local-development)
|
|
39
|
+
- [Demo](#demo)
|
|
39
40
|
* [License](#license)
|
|
40
41
|
|
|
41
42
|
<!-- TOC end -->
|
|
@@ -221,7 +222,7 @@ function App() {
|
|
|
221
222
|
| `fieldsets` | `FieldsetShape[]` | `null` | Used in multi-section form containing inputs divided into information groups<br><br>If used, legendText and formInputs is no longer needed |
|
|
222
223
|
| `legendText` | `string` | — | |
|
|
223
224
|
| `formInputs` | `inputEntryShape[]` | — | If no fieldsets is provided, this is an object containing information for label and inputs of a single-section form |
|
|
224
|
-
| `isExpandable` | `boolean` | `false` | If inputs are used as options commonly in type: checkbox/radio, this is to enabale a button for entry adding. If fieldset is null this is default to false |
|
|
225
|
+
| `isExpandable` | `boolean` | `false` | If inputs are used as options commonly in type: checkbox/radio, this is to enabale a button for entry adding. Can also be used to add input type for details (e.g. text, email, etc.) If fieldset is null this is default to false |
|
|
225
226
|
| `id` | `string` | — | Form tag id |
|
|
226
227
|
| `labelAndInputContainerClass` | `string` | — | className for `<LabeledInput/>` component inside `<DynamicForm/>` |
|
|
227
228
|
| `labelClass` | `string` | — | className for `<Label/>` component inside `<LabeledInput/>` component inside `<DynamicForm/>` |
|
|
@@ -248,7 +249,7 @@ function App() {
|
|
|
248
249
|
| Prop | Type | Default | Description |
|
|
249
250
|
| --------- | ------------ | -------- | ------------------------------- |
|
|
250
251
|
| `uniqueClass` | `string` | — | className to uniquely select/distinguish a LabeledInput container |
|
|
251
|
-
| `isEditable` | `boolean` | — | To determine if an input is editable or not<br>If false, all props below are automatically not needed |
|
|
252
|
+
| `isEditable` | `boolean` | — | To determine if an input is editable or not. This is only applicable for radio or checkbox input to mimick an editable option/selection<br>If false, all props below are automatically not needed |
|
|
252
253
|
| `editing` | `boolean` | — | To identify if an editable input is being modified<br>Can be used in open/close dialogs |
|
|
253
254
|
| `onClickEdit` | `(e:React.MouseEvent<HTMLButtonElement>) => void` | — | Function to handle edit logic of editable input |
|
|
254
255
|
| `editIcon` | `React.ReactNode` | — | TSX/JSX svg component that will serve as an icon for edit button of editable input |
|
|
@@ -417,6 +418,20 @@ cd react-dynamic-form
|
|
|
417
418
|
npm install
|
|
418
419
|
npm run dev
|
|
419
420
|
```
|
|
421
|
+
|
|
422
|
+
<!-- TOC --><a name="demo"></a>
|
|
423
|
+
## Demo
|
|
424
|
+
```bash
|
|
425
|
+
git clone https://github.com/kbgarcia8/test-react-form
|
|
426
|
+
cd test-react-form
|
|
427
|
+
npm install
|
|
428
|
+
npm run dev
|
|
429
|
+
```
|
|
430
|
+
For the code of the demo where DynamicForm is used, please see:
|
|
431
|
+
src/App.tsx
|
|
432
|
+
|
|
433
|
+
<b>NOTE:</b> This demo uses styled-components for styling. When using CSS you can provide class to components to style them accordingly
|
|
434
|
+
|
|
420
435
|
<!-- TOC --><a name="license"></a>
|
|
421
436
|
### License
|
|
422
437
|
[ => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default FormActionButtons;
|
|
4
4
|
//# sourceMappingURL=FormActionButtons.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormActionButtons.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/FormActionButtons/FormActionButtons.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE,QAAA,MAAM,iBAAiB,GAAI,
|
|
1
|
+
{"version":3,"file":"FormActionButtons.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/FormActionButtons/FormActionButtons.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE,QAAA,MAAM,iBAAiB,GAAI,4FASzB,sBAAsB,4CAQvB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { DynamicFormProps } from "../../../type/propTypes";
|
|
3
|
-
declare const DynamicForm: ({ fieldsets, legendText, isExpandable, id, formInputs, labelAndInputContainerClass, labelClass, inputClass, onChangeOfEditableOption, handleAddingInputEntry,
|
|
3
|
+
declare const DynamicForm: ({ fieldsets, legendText, isExpandable, id, formInputs, labelAndInputContainerClass, labelClass, inputClass, onChangeOfEditableOption, handleAddingInputEntry, submitText, hasReset, resetText, handleReset, hasCancel, cancelText, handleCancel, handleSubmitForm, className, children }: React.PropsWithChildren<DynamicFormProps>) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export default DynamicForm;
|
|
5
5
|
//# sourceMappingURL=DynamicForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicForm.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/DynamicForm/DynamicForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAgB,gBAAgB,EAA+D,MAAM,yBAAyB,CAAC;AAE3I,QAAA,MAAM,WAAW,GAAI,
|
|
1
|
+
{"version":3,"file":"DynamicForm.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/DynamicForm/DynamicForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAgB,gBAAgB,EAA+D,MAAM,yBAAyB,CAAC;AAE3I,QAAA,MAAM,WAAW,GAAI,0RAqBnB,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,4CAiJ1C,CAAA;AAGD,eAAe,WAAW,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("react"),d=require("styled-components"),t={fonts:{secondary:"Raleway",tertiary:"Lato",fallback:"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif"},fontWeight:{light:300,medium:500,bold:700,bolder:900},fontSize:{xsmall:"0.75rem"},spacing:{xxxsmall:"0.25rem",xxsmall:"0.375rem",xsmall:"0.5rem",small:"0.75rem",medium:"1.25rem"},borderRadius:{xsmall:"0.125rem",small:"0.25rem",xlarge:"2rem"},borderThickness:{thin:"0.0625rem",light:"0.125rem"}},L=d.button`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
@@ -24,33 +24,33 @@
|
|
|
24
24
|
& .button-icon-text-space svg {
|
|
25
25
|
max-width: 100%;
|
|
26
26
|
}
|
|
27
|
-
`,
|
|
27
|
+
`,R=d.div`
|
|
28
28
|
width: 100%;
|
|
29
29
|
display: flex;
|
|
30
30
|
flex-direction: row;
|
|
31
31
|
align-items: center;
|
|
32
32
|
justify-content: center;
|
|
33
|
-
`,
|
|
33
|
+
`,B=d.img`
|
|
34
34
|
maxwidth: 100%;
|
|
35
|
-
`,
|
|
35
|
+
`,P=d.span`
|
|
36
36
|
font-size: ${t.fontSize.xsmall};
|
|
37
37
|
font-weight: ${t.fontWeight.medium};
|
|
38
38
|
font-family: ${t.fonts.tertiary}, ${t.fonts.fallback};
|
|
39
39
|
display: flex;
|
|
40
40
|
align-items: center;
|
|
41
41
|
justify-content: center;
|
|
42
|
-
|
|
42
|
+
`,$=({onClick:a,id:i,buttonType:n,source:o,svg:m,alt:c="alt-button-icon",text:r="",className:x="",dataAttributes:h={}})=>n==="submit"?e.jsx(L,{id:i,type:n,className:x,...h,children:e.jsxs(R,{className:"button-icon-text-space",children:[o?e.jsx(B,{src:o,alt:c}):m||"",r&&e.jsx(P,{id:i,children:r})]})}):e.jsx(L,{onClick:a,id:i,type:n,className:x,...h,children:e.jsxs(R,{className:"button-icon-text-space",children:[o?e.jsx(B,{src:o,alt:c}):m||"",r&&e.jsx(P,{id:i,children:r})]})}),X=d.div`
|
|
43
43
|
display: flex;
|
|
44
44
|
flex-direction: column;
|
|
45
45
|
align-items: left;
|
|
46
46
|
width: 100%;
|
|
47
47
|
margin-bottom: ${t.spacing.small};
|
|
48
|
-
`,
|
|
48
|
+
`,Y=d.div`
|
|
49
49
|
display: flex;
|
|
50
50
|
gap: ${t.spacing.xsmall};
|
|
51
51
|
width: auto;
|
|
52
52
|
height: auto;
|
|
53
|
-
`,
|
|
53
|
+
`,Z=d.label`
|
|
54
54
|
display: flex;
|
|
55
55
|
align-items: center;
|
|
56
56
|
justify-content:center;
|
|
@@ -67,21 +67,21 @@
|
|
|
67
67
|
height: auto;
|
|
68
68
|
object-fit: contain;
|
|
69
69
|
}
|
|
70
|
-
`,
|
|
70
|
+
`,_=d.div`
|
|
71
71
|
display: flex;
|
|
72
72
|
flex-direction: column;
|
|
73
73
|
align-items: center;
|
|
74
74
|
justify-content: center;
|
|
75
75
|
gap: ${t.spacing.xxxsmall};
|
|
76
|
-
`,
|
|
76
|
+
`,I=d.span`
|
|
77
77
|
font-weight: ${t.fontWeight.bolder};
|
|
78
|
-
`,
|
|
78
|
+
`,ee=d.div`
|
|
79
79
|
max-width: 100%;
|
|
80
80
|
display: flex;
|
|
81
81
|
align-items: center;
|
|
82
|
-
`,
|
|
82
|
+
`,te=d.span`
|
|
83
83
|
font-weight: ${t.fontWeight.light};
|
|
84
|
-
`,
|
|
84
|
+
`,W=({htmlFor:a,textLabel:i,additionalInfo:n,$labelFlexDirection:o,source:m,svg:c,className:r,children:x})=>e.jsxs(Z,{htmlFor:a,className:r,$labelFlexDirection:o,children:[(m||c)&&e.jsx(ee,{className:"label-icon-container",children:m?e.jsx("img",{src:m,alt:`${a}-label-icon`}):c||""}),e.jsxs(_,{className:"label-text-container",children:[e.jsx(I,{className:"main-label",children:i}),n&&e.jsx(te,{className:"additional-info",children:n})]}),x]}),M=d.input`
|
|
85
85
|
display: flex;
|
|
86
86
|
place-content: center;
|
|
87
87
|
font-family: ${t.fonts.secondary}, ${t.fonts.fallback};
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
&:focus{
|
|
99
99
|
border: ${t.borderThickness.thin} solid ${({theme:a})=>a.colors.teal};
|
|
100
100
|
}
|
|
101
|
-
`,
|
|
101
|
+
`,ae=d.textarea`
|
|
102
102
|
display: flex;
|
|
103
103
|
place-content: center;
|
|
104
104
|
border: ${t.borderThickness.light} solid ${({theme:a})=>a.colors.text};
|
|
@@ -111,46 +111,46 @@
|
|
|
111
111
|
max-width: 100%;
|
|
112
112
|
resize: none;
|
|
113
113
|
overflow-y: auto;
|
|
114
|
-
`,D=
|
|
114
|
+
`,D=v.forwardRef((a,i)=>{const{type:n,id:o,onChange:m,isRequired:c,dataAttributes:r={},disabled:x,className:h,name:u}=a;if(n==="textarea"){const{rows:C=5,cols:w=30,value:T,...A}=a;return e.jsx(ae,{ref:i,value:T,rows:C,cols:w,id:o,onChange:m,required:c,disabled:x,...r,className:h,name:u})}if(n==="radio"||n==="checkbox"){const{checked:C,...w}=a;return e.jsx(M,{ref:i,type:n,checked:C,id:o,onChange:m,required:c,...r,disabled:x,className:h,name:u})}const p=a,{value:y,pattern:j,placeholderText:k,...N}=p;return e.jsx(M,{ref:i,type:n,value:y,pattern:j,placeholder:k,id:o,onChange:m,required:c,...r,disabled:x,className:h,name:u})}),E=a=>{const{className:i,type:n,id:o,textLabel:m,additionalInfo:c,$labelFlexDirection:r,svg:x,labelClass:h,onChange:u,isRequired:p,dataAttributes:y,inputClass:j,ref:k,disabled:N,isEditable:C,editIcon:w,onClickEdit:T,deleteIcon:A,onClickDelete:S,idx:s,children:g}=a;return e.jsxs(X,{className:`${i} ${o.replace("#","")}-label-input-container`,children:[n!=="radio"&&n!=="checkbox"&&e.jsx(W,{htmlFor:o,textLabel:m,additionalInfo:c,$labelFlexDirection:r,svg:x,className:h}),n!=="radio"&&n!=="checkbox"&&n==="textarea"&&(()=>{const{rows:l=5,cols:f=30,value:F,...z}=a;return e.jsx(D,{id:o,name:o,type:"textarea",isRequired:p,onChange:u,value:F,rows:l,cols:f,dataAttributes:y,className:j,ref:k,disabled:N})})(),n!=="radio"&&n!=="checkbox"&&n!=="textarea"&&(()=>{const l=a,{value:f,pattern:F,placeholderText:z,...ge}=l;return e.jsx(D,{id:o,name:o,placeholderText:z,onChange:u,value:f,type:n,isRequired:p,dataAttributes:y,className:j,ref:k,disabled:N,pattern:F})})(),(n==="radio"||n==="checkbox")&&(()=>{const{checked:l,...f}=a;return e.jsxs(e.Fragment,{children:[e.jsx(D,{ref:k,type:n,name:o,id:o,isRequired:p,checked:l,onChange:u,disabled:N,className:j,dataAttributes:y}),e.jsx(W,{htmlFor:o,textLabel:m,additionalInfo:c,$labelFlexDirection:r,svg:x,className:h})]})})(),C&&e.jsxs(Y,{className:"input-edit-buttons",children:[e.jsx($,{id:`editable-${o}-edit-btn`,svg:w,buttonType:"button",onClick:T,className:`edit-radio-${s}`,dataAttributes:y}),e.jsx($,{id:`editable-${o}-delete-btn`,svg:A,buttonType:"button",onClick:S,className:`delete-radio-${s}`,dataAttributes:y})]}),g]})},ne=d.fieldset`
|
|
115
115
|
padding: 0;
|
|
116
116
|
height: auto;
|
|
117
117
|
width: 100%;
|
|
118
|
-
`,
|
|
118
|
+
`,se=d.legend`
|
|
119
119
|
font-size: ${t.spacing.medium};
|
|
120
120
|
font-weight: 500;
|
|
121
121
|
margin: 0 auto ${t.spacing.small} auto;
|
|
122
122
|
text-align: center;
|
|
123
123
|
font-family: ${t.fonts.secondary}, ${t.fonts.fallback};
|
|
124
|
-
`,
|
|
124
|
+
`,oe=d.div`
|
|
125
125
|
display: flex;
|
|
126
126
|
flex-direction: column;
|
|
127
127
|
align-items: flex-start;
|
|
128
128
|
width: 100%;
|
|
129
129
|
margin-bottom: ${t.spacing.small};
|
|
130
|
-
`,
|
|
130
|
+
`,ie=d.div`
|
|
131
131
|
display: flex;
|
|
132
132
|
justify-content: space-between;
|
|
133
133
|
width: 100%;
|
|
134
|
-
`,
|
|
134
|
+
`,U=({legend:a,fieldsetIndex:i,idx:n,editableInformation:o,onChangeOfEditableOption:m,onClickSaveEdit:c,onClickCancelEdit:r,onClickDeleteEntry:x})=>e.jsxs(ne,{className:"editable-option-fieldset",children:[e.jsx(se,{children:`${a} ${n+1}`}),o?.map((h,u)=>e.jsx(oe,{className:"editable-option-container",children:e.jsx(D,{id:`editable-option-${u}`,name:`editable-option-${u}`,placeholderText:h.name.charAt(0).toUpperCase()+h.name.slice(1),onChange:m,value:h.info,type:h.type,isRequired:!0,className:"editable-option",dataAttributes:{"data-index":u,"data-fieldsetindex":i,"data-key":h.info}})},`${h.name}-${u}`)),e.jsxs(ie,{className:"editable-option-button-space",children:[e.jsx($,{id:`editable-option-${n}-submit`,buttonType:"button",text:"Save",onClick:c,className:"editable-option-btn",dataAttributes:{"data-index":n,"data-fieldsetindex":i}}),e.jsx($,{id:`editable-option-${n}-cancel`,buttonType:"button",text:"Cancel",onClick:r,className:"editable-option-btn",dataAttributes:{"data-index":n,"data-fieldsetindex":i}}),e.jsx($,{id:`editable-option-${n}-delete`,buttonType:"button",text:"Delete",onClick:x,className:"editable-option-btn",dataAttributes:{"data-index":n,"data-fieldsetindex":i}})]})]}),le=d.div`
|
|
135
135
|
display: flex;
|
|
136
136
|
justify-content: space-between;
|
|
137
137
|
max-width: 100%;
|
|
138
|
-
`,
|
|
138
|
+
`,ce=({id:a,submitText:i,hasReset:n,resetText:o,handleReset:m,hasCancel:c,cancelText:r,handleCancel:x})=>e.jsxs(le,{className:"form-main-button-container",children:[e.jsx($,{id:`form-${a}-submit`,buttonType:"submit",text:i??"Submit",className:"submit-form-btn"}),n&&e.jsx($,{id:`form-${a}-edit`,buttonType:"button",text:o??"Reset",onClick:m,className:"reset-form-btn"}),c&&e.jsx($,{id:`form-${a}-cancel`,buttonType:"button",text:r??"Cancel",onClick:x,className:"cancel-form-btn"})]}),O=d.legend`
|
|
139
139
|
font-size: ${t.spacing.medium};
|
|
140
140
|
font-weight: 500;
|
|
141
141
|
margin-bottom: ${t.spacing.small};
|
|
142
142
|
width: auto;
|
|
143
143
|
text-align: center;
|
|
144
144
|
font-family: ${t.fonts.secondary}, ${t.fonts.fallback};
|
|
145
|
-
`,
|
|
145
|
+
`,H=d.fieldset`
|
|
146
146
|
padding: 0;
|
|
147
147
|
height: auto;
|
|
148
148
|
width: 100%;
|
|
149
|
-
`,
|
|
149
|
+
`,G=d.div`
|
|
150
150
|
padding: ${t.spacing.small};
|
|
151
151
|
height: auto;
|
|
152
152
|
width: 100%;
|
|
153
|
-
`,
|
|
153
|
+
`,J=d.div`
|
|
154
154
|
display: flex;
|
|
155
155
|
justify-content: center;
|
|
156
156
|
align-items: center;
|
|
@@ -159,19 +159,19 @@
|
|
|
159
159
|
font-family: ${t.fonts.tertiary}, ${t.fonts.fallback};
|
|
160
160
|
font-size: ${t.fontSize.xsmall};
|
|
161
161
|
font-weight: ${t.fontWeight.bold};
|
|
162
|
-
`,
|
|
162
|
+
`,re=d.form`
|
|
163
163
|
display: flex;
|
|
164
164
|
flex-direction: column;
|
|
165
165
|
align-items: center;
|
|
166
166
|
width: 100%;
|
|
167
|
-
`,
|
|
167
|
+
`,K=d.div`
|
|
168
168
|
display: flex;
|
|
169
169
|
justify-content: space-between;
|
|
170
170
|
width: 100%;
|
|
171
|
-
`,
|
|
171
|
+
`,de=d.div`
|
|
172
172
|
width: 100%;
|
|
173
173
|
display: flex;
|
|
174
174
|
flex-direction: column;
|
|
175
175
|
align-items: center;
|
|
176
176
|
justify-content: center;
|
|
177
|
-
`,
|
|
177
|
+
`,me=({fieldsets:a=null,legendText:i,isExpandable:n,id:o,formInputs:m,labelAndInputContainerClass:c,labelClass:r,inputClass:x,onChangeOfEditableOption:h,handleAddingInputEntry:u,submitText:p,hasReset:y=!1,resetText:j,handleReset:k,hasCancel:N=!1,cancelText:C,handleCancel:w,handleSubmitForm:T,className:A,children:S})=>e.jsxs(re,{id:`${o}-form`,className:A,onSubmit:T,children:[a?a.map((s,g)=>e.jsxs(G,{className:`${o}-fieldset-wrapper`,children:[e.jsxs(H,{id:`${o}-form-fieldset-${g}`,className:`${s.legend}-fieldset`,children:[s.legend&&e.jsx(O,{className:`${s.legend}-legend`,children:s.legend}),s.inputs.length!==0?s.inputs.map((l,f)=>e.jsxs(v.Fragment,{children:[l.type==="textarea"&&e.jsx(E,{...l,id:l.id??`${s.legend}-input`,labelClass:r,inputClass:x,idx:f,className:`${c} ${l?.uniqueClass}`}),l.type!=="textarea"&&l.type!=="radio"&&l.type!=="checkbox"&&e.jsx(E,{...l,id:l.id??`${s.legend}-input`,labelClass:r,inputClass:x,idx:f,className:`${c} ${l?.uniqueClass}`}),(l.type==="radio"||l.type==="checkbox")&&e.jsxs(e.Fragment,{children:[e.jsx(E,{...l,id:l.id??`${s.legend}-input`,labelClass:r,inputClass:x,idx:f,className:`${c} ${l?.uniqueClass}`}),l.editing&&l.isEditable&&e.jsx(U,{legend:`${s.legend}`,fieldsetIndex:g,idx:f,editableInformation:l?.editableInformation||[],onChangeOfEditableOption:h,onClickSaveEdit:l?.onClickSave||(F=>{}),onClickCancelEdit:l?.onClickCancel||(F=>{}),onClickDeleteEntry:l?.onClickDelete||(F=>{})})]})]},`form-${o}-${f}`)):s.isExpandable?e.jsx(J,{children:`No entry yet on ${s.legend}. Click "+" button to add entry.`}):""]}),s.isExpandable&&e.jsx(K,{className:"add-input-button-space",children:e.jsx($,{id:`expand-${s.legend}-inputs`,buttonType:"button",text:"+",onClick:u,className:"add-input-entry",dataAttributes:{"data-fieldsetindex":g}})})]},`${s.legend}-${g}`)):e.jsxs(G,{className:`${o}-fieldset-wrapper`,children:[e.jsxs(H,{id:`${o}-form-fieldset`,className:`${i}-fieldset`,children:[i&&e.jsx(O,{className:`${i}-legend`,children:i}),!a&&m&&m.length!==0?m.map((s,g)=>e.jsxs(v.Fragment,{children:[s.type==="textarea"&&e.jsx(E,{...s,id:s.id??`${i}-input`,labelClass:r,inputClass:x,idx:g,className:`${c} ${s?.uniqueClass}`}),s.type!=="textarea"&&s.type!=="radio"&&s.type!=="checkbox"&&e.jsx(E,{...s,id:s.id??`${i}-input`,labelClass:r,inputClass:x,idx:g,className:`${c} ${s?.uniqueClass}`}),(s.type==="radio"||s.type==="checkbox")&&e.jsxs(e.Fragment,{children:[e.jsx(E,{...s,id:s.id??`${i}-input`,labelClass:r,inputClass:x,idx:g,className:`${c} ${s?.uniqueClass}`}),s.editing&&s.isEditable&&e.jsx(U,{legend:`${i}`,idx:g,editableInformation:s?.editableInformation,onChangeOfEditableOption:h,onClickSaveEdit:s?.onClickSave||(l=>{}),onClickCancelEdit:s?.onClickCancel||(l=>{}),onClickDeleteEntry:s?.onClickDelete||(l=>{})})]})]},`form-${o}-${g}`)):n?e.jsx(J,{children:`No entry yet on ${i}. Please click "+" button to add`}):""]}),n&&e.jsx(K,{className:"add-input-button-space",children:e.jsx($,{id:`expand-${i}-inputs`,buttonType:"button",text:"+",onClick:u,className:"add-input-entry"})})]}),e.jsx(ce,{id:o,submitText:p,hasReset:y,resetText:j,handleReset:k,hasCancel:N,cancelText:C,handleCancel:w}),e.jsx(de,{className:"children-container",children:S})]}),xe=a=>{const i=/^#([0-9A-Fa-f]{3}){1,2}$/,n=/^rgb(a)?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(0|1|0?\.\d+))?\s*\)$/;return i.test(a)||n.test(a)||CSS.supports("color",a)},b=a=>{if(!xe(a))throw new Error(`Invalid color: ${a}`);return a},be={mobile:"320px",tablet:"768px",desktop:"992px",largeDesktop:"1200px",largerDesktop:"1400px"},Q={name:"light",colors:{text:b("#333446"),bg:b("#EEEEEE"),blue:b("#7F8CAA"),blue2:b("#80A6FF"),teal:b("#5b8280ff"),teal2:b("#AEEAE7"),gray:b("#AEAEAE"),information:b("#202234"),success:b("#123524"),warning:b("#F2C265"),error:b("#990000")}},V={name:"dark",colors:{bg:b("#333446"),text:b("#EEEEEE"),blue:b("#80A6FF"),blue2:b("#7F8CAA"),teal:b("#AEEAE7"),teal2:b("#5b8280ff"),gray:b("#D0D0DD"),information:b("#C9E6F0"),success:b("#9EDF9C"),warning:b("#FCFFC1"),error:b("#FAD4D4")}},q=v.createContext({}),he=({children:a,initialTheme:i=Q,secondTheme:n=V})=>{const[o,m]=v.useState(i),c=()=>{m(r=>r===i?n:i)};return e.jsx(q.Provider,{value:{currentTheme:o,toggleTheme:c},children:e.jsx(d.ThemeProvider,{theme:o,children:a})})},ue=()=>v.useContext(q);exports.DynamicForm=me;exports.ThemeContext=q;exports.ThemeContextProvider=he;exports.breakpoints=be;exports.darkTheme=V;exports.lightTheme=Q;exports.useTheme=ue;
|