@kbgarcia8/react-dynamic-form 1.1.1 → 1.1.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Button/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,QAAA,MAAM,MAAM,GAAI,gFAUd,WAAW,4CAoBZ,CAAA;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Button/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,QAAA,MAAM,MAAM,GAAI,gFAUd,WAAW,4CAgBZ,CAAA;AAED,eAAe,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,yBAAyB,CAAC;AAExE,QAAA,MAAM,KAAK,2GA2DT,CAAC;AAEH,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,yBAAyB,CAAC;AAExE,QAAA,MAAM,KAAK,2GAsDT,CAAC;AAEH,eAAe,KAAK,CAAC"}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),T=require("react"),c=require("styled-components"),n={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"}},V=c.button`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("react"),c=require("styled-components"),n={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"}},V=c.button`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
@@ -39,7 +39,7 @@
39
39
  display: flex;
40
40
  align-items: center;
41
41
  justify-content: center;
42
- `,$=({onClick:t,id:o,buttonType:i,source:s,svg:r,alt:d="alt-button-icon",text:b="",className:l="",dataAttributes:x={}})=>{const f=x?Object.fromEntries(Object.entries(x).map(([u,g])=>[`data-${u}`,g])):{};return e.jsx(V,{onClick:t,id:o,type:i,className:l,...f,children:e.jsxs(X,{className:"button-icon-text-space",children:[s?e.jsx(Y,{src:s,alt:d}):r||"",b&&e.jsx(Z,{id:o,children:b})]})})},_=c.div`
42
+ `,g=({onClick:t,id:o,buttonType:i,source:s,svg:r,alt:d="alt-button-icon",text:m="",className:l="",dataAttributes:b={}})=>e.jsx(V,{onClick:t,id:o,type:i,className:l,...b,children:e.jsxs(X,{className:"button-icon-text-space",children:[s?e.jsx(Y,{src:s,alt:d}):r||"",m&&e.jsx(Z,{id:o,children:m})]})}),_=c.div`
43
43
  display: flex;
44
44
  flex-direction: column;
45
45
  align-items: left;
@@ -75,7 +75,7 @@
75
75
  align-items: center;
76
76
  `,ae=c.span`
77
77
  font-weight: ${n.fontWeight.light};
78
- `,P=({htmlFor:t,textLabel:o,additionalInfo:i,$labelFlexDirection:s,source:r,svg:d,className:b,children:l})=>e.jsxs(ee,{htmlFor:t,className:b,$labelFlexDirection:s,children:[(r||d)&&e.jsx(ne,{className:"label-icon-container",children:r?e.jsx("img",{src:r,alt:`${t}-label-icon`}):d||""}),e.jsx(te,{className:"main-label",children:o}),i&&e.jsx(ae,{className:"additional-info",children:i}),l]}),W=c.input`
78
+ `,P=({htmlFor:t,textLabel:o,additionalInfo:i,$labelFlexDirection:s,source:r,svg:d,className:m,children:l})=>e.jsxs(ee,{htmlFor:t,className:m,$labelFlexDirection:s,children:[(r||d)&&e.jsx(ne,{className:"label-icon-container",children:r?e.jsx("img",{src:r,alt:`${t}-label-icon`}):d||""}),e.jsx(te,{className:"main-label",children:o}),i&&e.jsx(ae,{className:"additional-info",children:i}),l]}),W=c.input`
79
79
  display: flex;
80
80
  place-content: center;
81
81
  font-family: ${n.fonts.secondary}, ${n.fonts.fallback};
@@ -105,7 +105,7 @@
105
105
  max-width: 100%;
106
106
  resize: none;
107
107
  overflow-y: auto;
108
- `,L=T.forwardRef((t,o)=>{const{type:i,id:s,onChange:r,isRequired:d,dataAttributes:b,disabled:l,className:x}=t,f=b?Object.fromEntries(Object.entries(b).map(([j,k])=>[`data-${j}`,k])):{};if(i==="textarea"){const{rows:j=5,cols:k=30,value:D,...S}=t;return e.jsx(oe,{id:s,onChange:r,value:D,rows:j,cols:k,...f,className:x,ref:o,disabled:l,required:d})}if(i==="radio"||i==="checkbox"){const{checked:j,...k}=t;return e.jsx(W,{ref:o,type:"checkbox",id:s,checked:j,onChange:r,disabled:l,className:x,...f})}const u=t,{value:g,pattern:p,placeholderText:C,...w}=u;return e.jsx(W,{id:s,name:s,placeholder:C,onChange:r,value:g,type:i,required:d,...f,className:x,ref:o,disabled:l,pattern:p})}),v=t=>{const{className:o,type:i,id:s,textLabel:r,additionalInfo:d,$labelFlexDirection:b,svg:l,labelClass:x,onChange:f,isRequired:u,dataAttributes:g,inputClass:p,ref:C,disabled:w,isEditable:j,editIcon:k,onClickEdit:D,deleteIcon:S,onClickDelete:R,idx:z,children:B}=t;return e.jsxs(_,{className:`${o} ${s.replace("#","")}-label-input-container`,children:[i!=="radio"&&i!=="checkbox"&&e.jsx(P,{htmlFor:s,textLabel:r,additionalInfo:d,$labelFlexDirection:b,svg:l,className:x}),i!=="radio"&&i!=="checkbox"&&i==="textarea"&&(()=>{const{rows:N=5,cols:E=30,value:A,...a}=t;return e.jsx(L,{id:s,name:s,type:"textarea",isRequired:u,onChange:f,value:A,rows:N,cols:E,dataAttributes:g,className:p,ref:C,disabled:w})})(),i!=="radio"&&i!=="checkbox"&&i!=="textarea"&&(()=>{const N=t,{value:E,pattern:A,placeholderText:a,...y}=N;return e.jsx(L,{id:s,name:s,placeholderText:a,onChange:f,value:E,type:i,isRequired:u,dataAttributes:g,className:p,ref:C,disabled:w,pattern:A})})(),(i==="radio"||i==="checkbox")&&(()=>{const{checked:N,...E}=t;return e.jsxs(e.Fragment,{children:[e.jsx(L,{ref:C,type:"checkbox",name:s,id:s,isRequired:u,checked:N,onChange:f,disabled:w,className:p,dataAttributes:g}),e.jsx(P,{htmlFor:s,textLabel:r,additionalInfo:d,$labelFlexDirection:b,svg:l,className:x})]})})(),j&&e.jsxs(I,{className:"input-edit-buttons",children:[e.jsx($,{id:`editable-${s}-edit-btn`,svg:k,buttonType:"button",onClick:D,className:`edit-radio-${z}`,dataAttributes:g}),e.jsx($,{id:`editable-${s}-delete-btn`,svg:S,buttonType:"button",onClick:R,className:`delete-radio-${z}`,dataAttributes:g})]}),B]})},se=c.fieldset`
108
+ `,z=v.forwardRef((t,o)=>{const{type:i,id:s,onChange:r,isRequired:d,dataAttributes:m,disabled:l,className:b}=t;if(i==="textarea"){const{rows:j=5,cols:N=30,value:T,...A}=t;return e.jsx(oe,{id:s,onChange:r,value:T,rows:j,cols:N,...m,className:b,ref:o,disabled:l,required:d})}if(i==="radio"||i==="checkbox"){const{checked:j,...N}=t;return e.jsx(W,{ref:o,type:"checkbox",id:s,checked:j,onChange:r,disabled:l,className:b,...m})}const u=t,{value:y,pattern:f,placeholderText:p,...C}=u;return e.jsx(W,{id:s,name:s,placeholder:p,onChange:r,value:y,type:i,required:d,...m,className:b,ref:o,disabled:l,pattern:f})}),F=t=>{const{className:o,type:i,id:s,textLabel:r,additionalInfo:d,$labelFlexDirection:m,svg:l,labelClass:b,onChange:u,isRequired:y,dataAttributes:f,inputClass:p,ref:C,disabled:j,isEditable:N,editIcon:T,onClickEdit:A,deleteIcon:R,onClickDelete:B,idx:S,children:q}=t;return e.jsxs(_,{className:`${o} ${s.replace("#","")}-label-input-container`,children:[i!=="radio"&&i!=="checkbox"&&e.jsx(P,{htmlFor:s,textLabel:r,additionalInfo:d,$labelFlexDirection:m,svg:l,className:b}),i!=="radio"&&i!=="checkbox"&&i==="textarea"&&(()=>{const{rows:k=5,cols:w=30,value:D,...a}=t;return e.jsx(z,{id:s,name:s,type:"textarea",isRequired:y,onChange:u,value:D,rows:k,cols:w,dataAttributes:f,className:p,ref:C,disabled:j})})(),i!=="radio"&&i!=="checkbox"&&i!=="textarea"&&(()=>{const k=t,{value:w,pattern:D,placeholderText:a,...$}=k;return e.jsx(z,{id:s,name:s,placeholderText:a,onChange:u,value:w,type:i,isRequired:y,dataAttributes:f,className:p,ref:C,disabled:j,pattern:D})})(),(i==="radio"||i==="checkbox")&&(()=>{const{checked:k,...w}=t;return e.jsxs(e.Fragment,{children:[e.jsx(z,{ref:C,type:"checkbox",name:s,id:s,isRequired:y,checked:k,onChange:u,disabled:j,className:p,dataAttributes:f}),e.jsx(P,{htmlFor:s,textLabel:r,additionalInfo:d,$labelFlexDirection:m,svg:l,className:b})]})})(),N&&e.jsxs(I,{className:"input-edit-buttons",children:[e.jsx(g,{id:`editable-${s}-edit-btn`,svg:T,buttonType:"button",onClick:A,className:`edit-radio-${S}`,dataAttributes:f}),e.jsx(g,{id:`editable-${s}-delete-btn`,svg:R,buttonType:"button",onClick:B,className:`delete-radio-${S}`,dataAttributes:f})]}),q]})},se=c.fieldset`
109
109
  padding: 0;
110
110
  height: auto;
111
111
  width: 100%;
@@ -125,11 +125,11 @@
125
125
  display: flex;
126
126
  justify-content: space-between;
127
127
  width: 100%;
128
- `,M=({legend:t,idx:o,editableInformation:i,onChangeOfEditableOption:s,onClickSaveEdit:r,onClickCancelEdit:d,onClickDeleteEntry:b})=>e.jsxs(se,{className:"editable-selection-fieldset",children:[e.jsx(ie,{children:`${t} ${o+1}`}),i.map((l,x)=>e.jsx(le,{className:"editable-selection-container",children:e.jsx(L,{id:`editable-selection-${x}`,name:`editable-selection-${x}`,placeholderText:l.name.charAt(0).toUpperCase()+l.name.slice(1),onChange:s,value:l.info,type:l.type,isRequired:!0,className:"editable-selection",dataAttributes:{"data-index":x,"data-key":l.info}})},`${l.name}-${x}`)),e.jsxs(ce,{className:"editable-selection-button-space",children:[e.jsx($,{id:`editable-selection-${o}-submit`,buttonType:"submit",text:"Save",onClick:r,className:"editable-selection-btn",dataAttributes:{"data-index":o}}),e.jsx($,{id:`editable-selection-${o}-cancel`,buttonType:"button",text:"Cancel",onClick:d,className:"editable-selection-btn",dataAttributes:{"data-index":o}}),e.jsx($,{id:`editable-selection-${o}-delete`,buttonType:"button",text:"Delete",onClick:b,className:"editable-selection-btn",dataAttributes:{"data-index":o}})]})]}),re=c.div`
128
+ `,M=({legend:t,idx:o,editableInformation:i,onChangeOfEditableOption:s,onClickSaveEdit:r,onClickCancelEdit:d,onClickDeleteEntry:m})=>e.jsxs(se,{className:"editable-selection-fieldset",children:[e.jsx(ie,{children:`${t} ${o+1}`}),i.map((l,b)=>e.jsx(le,{className:"editable-selection-container",children:e.jsx(z,{id:`editable-selection-${b}`,name:`editable-selection-${b}`,placeholderText:l.name.charAt(0).toUpperCase()+l.name.slice(1),onChange:s,value:l.info,type:l.type,isRequired:!0,className:"editable-selection",dataAttributes:{"data-index":b,"data-key":l.info}})},`${l.name}-${b}`)),e.jsxs(ce,{className:"editable-selection-button-space",children:[e.jsx(g,{id:`editable-selection-${o}-submit`,buttonType:"submit",text:"Save",onClick:r,className:"editable-selection-btn",dataAttributes:{"data-index":o}}),e.jsx(g,{id:`editable-selection-${o}-cancel`,buttonType:"button",text:"Cancel",onClick:d,className:"editable-selection-btn",dataAttributes:{"data-index":o}}),e.jsx(g,{id:`editable-selection-${o}-delete`,buttonType:"button",text:"Delete",onClick:m,className:"editable-selection-btn",dataAttributes:{"data-index":o}})]})]}),re=c.div`
129
129
  display: flex;
130
130
  justify-content: space-between;
131
131
  max-width: 100%;
132
- `,de=({id:t,hasSubmit:o,submitText:i,handleSubmit:s,hasEdit:r,editText:d,handleEdit:b,hasCancel:l,cancelText:x,handleCancel:f,hasDelete:u,deleteText:g,handleDelete:p})=>e.jsxs(re,{className:"form-main-button-container",children:[o&&e.jsx($,{id:`form-${t}-submit`,buttonType:"submit",text:i??"Submit",onClick:s,className:"submit-form-btn"}),r&&e.jsx($,{id:`form-${t}-edit`,buttonType:"button",text:d??"Edit",onClick:b,className:"edit-form-btn"}),l&&e.jsx($,{id:`form-${t}-cancel`,buttonType:"button",text:x??"Cancel",onClick:f,className:"cancel-form-btn"}),u&&e.jsx($,{id:`form-${t}-delete`,buttonType:"button",text:g??"Delete",onClick:p,className:"delete-form-btn"})]}),U=c.legend`
132
+ `,de=({id:t,hasSubmit:o,submitText:i,handleSubmit:s,hasEdit:r,editText:d,handleEdit:m,hasCancel:l,cancelText:b,handleCancel:u,hasDelete:y,deleteText:f,handleDelete:p})=>e.jsxs(re,{className:"form-main-button-container",children:[o&&e.jsx(g,{id:`form-${t}-submit`,buttonType:"submit",text:i??"Submit",onClick:s,className:"submit-form-btn"}),r&&e.jsx(g,{id:`form-${t}-edit`,buttonType:"button",text:d??"Edit",onClick:m,className:"edit-form-btn"}),l&&e.jsx(g,{id:`form-${t}-cancel`,buttonType:"button",text:b??"Cancel",onClick:u,className:"cancel-form-btn"}),y&&e.jsx(g,{id:`form-${t}-delete`,buttonType:"button",text:f??"Delete",onClick:p,className:"delete-form-btn"})]}),U=c.legend`
133
133
  font-size: ${n.spacing.medium};
134
134
  font-weight: 500;
135
135
  margin-bottom: ${n.spacing.small};
@@ -162,10 +162,10 @@
162
162
  display: flex;
163
163
  justify-content: space-between;
164
164
  width: 100%;
165
- `,be=c.div`
165
+ `,xe=c.div`
166
166
  width: 100%;
167
167
  display: flex;
168
168
  flex-direction: column;
169
169
  align-items: center;
170
170
  justify-content: center;
171
- `,xe=({fieldsets:t=null,legendText:o,isExpandable:i,id:s,formInputs:r,labelAndInputContainerClass:d,labelClass:b,inputClass:l,handleEditableInputEntryChange:x,handleAddingInputEntry:f,hasSubmit:u=!1,hasCancel:g=!1,hasDelete:p=!1,hasEdit:C=!1,submitText:w,handleSubmitForm:j,handleSubmit:k,cancelText:D,handleCancel:S,deleteText:R,handleDelete:z,editText:B,handleEdit:N,className:E,children:A})=>e.jsxs(me,{id:`${s}-form`,className:E,onSubmit:j,children:[t?t.map((a,y)=>e.jsxs(G,{children:[e.jsxs(H,{id:`${s}-form-fieldset-${y}`,className:"form-fieldset",children:[a.legend&&e.jsx(U,{children:a.legend}),a.inputs.length!==0?a.inputs.map((h,F)=>e.jsxs(T.Fragment,{children:[h.type==="textarea"&&e.jsx(v,{...h,id:h.id??`${a.legend}-input`,labelClass:b,inputClass:l,idx:F,className:d}),(h.type==="radio"||h.type==="checkbox")&&e.jsx(v,{...h,id:h.id??`${a.legend}-input`,labelClass:b,inputClass:l,idx:F,className:d}),h.type!=="textarea"&&h.type!=="radio"&&h.type!=="checkbox"&&e.jsx(v,{...h,id:h.id??`${a.legend}-input`,labelClass:b,inputClass:l,idx:F,className:d}),h.isEditable&&h.editing&&e.jsx(M,{legend:`${a.legend} ${F+1}`,idx:F,editableInformation:h?.editableInformation,onChangeOfEditableOption:x,onClickSaveEdit:h?.onClickSave,onClickCancelEdit:h?.onClickCancel,onClickDeleteEntry:h?.onClickDelete})]},`form-${s}-${F}`)):a.isExpandable?e.jsx(J,{children:`No entry yet on ${a.legend}. Click "+" button to add entry.`}):""]}),a.isExpandable&&e.jsx(K,{className:"add-input-button-space",children:e.jsx($,{id:`expand-${a.legend}-inputs`,buttonType:"button",text:"+",onClick:f,className:"add-input-entry"})})]},`${a.legend}-${y}`)):e.jsxs(G,{children:[e.jsxs(H,{id:`${s}-form-fieldset`,className:"form-fieldset",children:[o&&e.jsx(U,{children:o}),!t&&r&&r.length!==0?r.map((a,y)=>e.jsxs(T.Fragment,{children:[a.type==="textarea"&&e.jsx(v,{...a,id:a.id??`${o}-input`,labelClass:b,inputClass:l,idx:y,className:d}),(a.type==="radio"||a.type==="checkbox")&&e.jsx(v,{...a,id:a.id??`${o}-input`,labelClass:b,inputClass:l,idx:y,className:d}),a.type!=="textarea"&&a.type!=="radio"&&a.type!=="checkbox"&&e.jsx(v,{...a,id:a.id??`${o}-input`,labelClass:b,inputClass:l,idx:y,className:d}),a.isEditable&&a.editing&&e.jsx(M,{legend:`${o} ${y+1}`,idx:y,editableInformation:a?.editableInformation,onChangeOfEditableOption:x,onClickSaveEdit:a?.onClickSave,onClickCancelEdit:a?.onClickEdit,onClickDeleteEntry:a?.onClickDelete})]},`form-${s}-${y}`)):i?e.jsx(J,{children:`No entry yet on ${o}. Please click "+" button to add`}):""]}),i&&e.jsx(K,{className:"add-input-button-space",children:e.jsx($,{id:`expand-${o}-inputs`,buttonType:"button",text:"+",onClick:f,className:"add-input-entry"})})]}),e.jsx(de,{id:s,hasSubmit:u,submitText:w,handleSubmit:k,hasEdit:C,editText:B,handleEdit:N,hasCancel:g,cancelText:D,handleCancel:S,hasDelete:p,deleteText:R,handleDelete:z}),e.jsx(be,{className:"children-container",children:A})]}),he=t=>{const o=/^#([0-9A-Fa-f]{3}){1,2}$/,i=/^rgb(a)?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(0|1|0?\.\d+))?\s*\)$/;return o.test(t)||i.test(t)||CSS.supports("color",t)},m=t=>{if(!he(t))throw new Error(`Invalid color: ${t}`);return t},fe={mobile:"320px",tablet:"768px",desktop:"992px",largeDesktop:"1200px",largerDesktop:"1400px"},O={name:"light",colors:{text:m("#333446"),bg:m("#EEEEEE"),blue:m("#7F8CAA"),blue2:m("#80A6FF"),teal:m("#5b8280ff"),teal2:m("#AEEAE7"),gray:m("#AEAEAE"),information:m("#202234"),success:m("#123524"),warning:m("#F2C265"),error:m("#990000")}},Q={name:"dark",colors:{bg:m("#333446"),text:m("#EEEEEE"),blue:m("#80A6FF"),blue2:m("#7F8CAA"),teal:m("#AEEAE7"),teal2:m("#5b8280ff"),gray:m("#D0D0DD"),information:m("#C9E6F0"),success:m("#9EDF9C"),warning:m("#FCFFC1"),error:m("#FAD4D4")}},q=T.createContext(void 0),ge=({children:t})=>{const[o,i]=T.useState(O),s=()=>{i(r=>r===O?Q:O)};return e.jsx(q.Provider,{value:{currentTheme:o,toggleTheme:s},children:e.jsx(c.ThemeProvider,{theme:o,children:t})})},ue=()=>T.useContext(q);exports.DynamicForm=xe;exports.ThemeContext=q;exports.ThemeContextProvider=ge;exports.breakpoints=fe;exports.darkTheme=Q;exports.lightTheme=O;exports.useTheme=ue;
171
+ `,be=({fieldsets:t=null,legendText:o,isExpandable:i,id:s,formInputs:r,labelAndInputContainerClass:d,labelClass:m,inputClass:l,handleEditableInputEntryChange:b,handleAddingInputEntry:u,hasSubmit:y=!1,hasCancel:f=!1,hasDelete:p=!1,hasEdit:C=!1,submitText:j,handleSubmitForm:N,handleSubmit:T,cancelText:A,handleCancel:R,deleteText:B,handleDelete:S,editText:q,handleEdit:k,className:w,children:D})=>e.jsxs(me,{id:`${s}-form`,className:w,onSubmit:N,children:[t?t.map((a,$)=>e.jsxs(G,{children:[e.jsxs(H,{id:`${s}-form-fieldset-${$}`,className:"form-fieldset",children:[a.legend&&e.jsx(U,{children:a.legend}),a.inputs.length!==0?a.inputs.map((h,E)=>e.jsxs(v.Fragment,{children:[h.type==="textarea"&&e.jsx(F,{...h,id:h.id??`${a.legend}-input`,labelClass:m,inputClass:l,idx:E,className:d}),(h.type==="radio"||h.type==="checkbox")&&e.jsx(F,{...h,id:h.id??`${a.legend}-input`,labelClass:m,inputClass:l,idx:E,className:d}),h.type!=="textarea"&&h.type!=="radio"&&h.type!=="checkbox"&&e.jsx(F,{...h,id:h.id??`${a.legend}-input`,labelClass:m,inputClass:l,idx:E,className:d}),h.isEditable&&h.editing&&e.jsx(M,{legend:`${a.legend} ${E+1}`,idx:E,editableInformation:h?.editableInformation,onChangeOfEditableOption:b,onClickSaveEdit:h?.onClickSave,onClickCancelEdit:h?.onClickCancel,onClickDeleteEntry:h?.onClickDelete})]},`form-${s}-${E}`)):a.isExpandable?e.jsx(J,{children:`No entry yet on ${a.legend}. Click "+" button to add entry.`}):""]}),a.isExpandable&&e.jsx(K,{className:"add-input-button-space",children:e.jsx(g,{id:`expand-${a.legend}-inputs`,buttonType:"button",text:"+",onClick:u,className:"add-input-entry"})})]},`${a.legend}-${$}`)):e.jsxs(G,{children:[e.jsxs(H,{id:`${s}-form-fieldset`,className:"form-fieldset",children:[o&&e.jsx(U,{children:o}),!t&&r&&r.length!==0?r.map((a,$)=>e.jsxs(v.Fragment,{children:[a.type==="textarea"&&e.jsx(F,{...a,id:a.id??`${o}-input`,labelClass:m,inputClass:l,idx:$,className:d}),(a.type==="radio"||a.type==="checkbox")&&e.jsx(F,{...a,id:a.id??`${o}-input`,labelClass:m,inputClass:l,idx:$,className:d}),a.type!=="textarea"&&a.type!=="radio"&&a.type!=="checkbox"&&e.jsx(F,{...a,id:a.id??`${o}-input`,labelClass:m,inputClass:l,idx:$,className:d}),a.isEditable&&a.editing&&e.jsx(M,{legend:`${o} ${$+1}`,idx:$,editableInformation:a?.editableInformation,onChangeOfEditableOption:b,onClickSaveEdit:a?.onClickSave,onClickCancelEdit:a?.onClickEdit,onClickDeleteEntry:a?.onClickDelete})]},`form-${s}-${$}`)):i?e.jsx(J,{children:`No entry yet on ${o}. Please click "+" button to add`}):""]}),i&&e.jsx(K,{className:"add-input-button-space",children:e.jsx(g,{id:`expand-${o}-inputs`,buttonType:"button",text:"+",onClick:u,className:"add-input-entry"})})]}),e.jsx(de,{id:s,hasSubmit:y,submitText:j,handleSubmit:T,hasEdit:C,editText:q,handleEdit:k,hasCancel:f,cancelText:A,handleCancel:R,hasDelete:p,deleteText:B,handleDelete:S}),e.jsx(xe,{className:"children-container",children:D})]}),he=t=>{const o=/^#([0-9A-Fa-f]{3}){1,2}$/,i=/^rgb(a)?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(0|1|0?\.\d+))?\s*\)$/;return o.test(t)||i.test(t)||CSS.supports("color",t)},x=t=>{if(!he(t))throw new Error(`Invalid color: ${t}`);return t},fe={mobile:"320px",tablet:"768px",desktop:"992px",largeDesktop:"1200px",largerDesktop:"1400px"},L={name:"light",colors:{text:x("#333446"),bg:x("#EEEEEE"),blue:x("#7F8CAA"),blue2:x("#80A6FF"),teal:x("#5b8280ff"),teal2:x("#AEEAE7"),gray:x("#AEAEAE"),information:x("#202234"),success:x("#123524"),warning:x("#F2C265"),error:x("#990000")}},Q={name:"dark",colors:{bg:x("#333446"),text:x("#EEEEEE"),blue:x("#80A6FF"),blue2:x("#7F8CAA"),teal:x("#AEEAE7"),teal2:x("#5b8280ff"),gray:x("#D0D0DD"),information:x("#C9E6F0"),success:x("#9EDF9C"),warning:x("#FCFFC1"),error:x("#FAD4D4")}},O=v.createContext(void 0),ge=({children:t})=>{const[o,i]=v.useState(L),s=()=>{i(r=>r===L?Q:L)};return e.jsx(O.Provider,{value:{currentTheme:o,toggleTheme:s},children:e.jsx(c.ThemeProvider,{theme:o,children:t})})},ue=()=>v.useContext(O);exports.DynamicForm=be;exports.ThemeContext=O;exports.ThemeContextProvider=ge;exports.breakpoints=fe;exports.darkTheme=Q;exports.lightTheme=L;exports.useTheme=ue;
@@ -1,7 +1,7 @@
1
1
  import { jsx as t, jsxs as g, Fragment as V } from "react/jsx-runtime";
2
2
  import W, { forwardRef as X, createContext as Y, useState as Z, useContext as _ } from "react";
3
3
  import s, { ThemeProvider as I } from "styled-components";
4
- const a = {
4
+ const n = {
5
5
  fonts: {
6
6
  secondary: "Raleway",
7
7
  tertiary: "Lato",
@@ -38,9 +38,9 @@ const a = {
38
38
  justify-content: center;
39
39
  background-color: ${({ theme: e }) => e.colors.blue || "blue"};
40
40
  color: ${({ theme: e }) => e.colors.bg || "white"};
41
- border: ${a.borderThickness.light} solid ${({ theme: e }) => e.colors.text || "black"};
42
- border-radius: ${a.borderRadius.xlarge};
43
- padding: ${a.spacing.xxxsmall} ${a.spacing.small};
41
+ border: ${n.borderThickness.light} solid ${({ theme: e }) => e.colors.text || "black"};
42
+ border-radius: ${n.borderRadius.xlarge};
43
+ padding: ${n.spacing.xxxsmall} ${n.spacing.small};
44
44
  margin: 0.125rem;
45
45
  width: auto;
46
46
  cursor: pointer;
@@ -48,7 +48,7 @@ const a = {
48
48
 
49
49
  &:hover {
50
50
  background-color: lightblue;
51
- border: ${a.borderThickness.light} solid gray;
51
+ border: ${n.borderThickness.light} solid gray;
52
52
  }
53
53
 
54
54
  & .button-icon-text-space {
@@ -64,52 +64,47 @@ const a = {
64
64
  flex-direction: row;
65
65
  align-items: center;
66
66
  justify-content: center;
67
- `, ae = s.img`
67
+ `, ne = s.img`
68
68
  maxwidth: 100%;
69
- `, ne = s.span`
70
- font-size: ${a.fontSize.xsmall};
71
- font-weight: ${a.fontWeight.medium};
72
- font-family: ${a.fonts.tertiary}, ${a.fonts.fallback};
69
+ `, ae = s.span`
70
+ font-size: ${n.fontSize.xsmall};
71
+ font-weight: ${n.fontWeight.medium};
72
+ font-family: ${n.fonts.tertiary}, ${n.fonts.fallback};
73
73
  display: flex;
74
74
  align-items: center;
75
75
  justify-content: center;
76
- `, y = ({
76
+ `, x = ({
77
77
  onClick: e,
78
78
  id: o,
79
79
  buttonType: l,
80
80
  source: i,
81
81
  svg: r,
82
82
  alt: d = "alt-button-icon",
83
- text: b = "",
83
+ text: m = "",
84
84
  className: c = "",
85
85
  dataAttributes: h = {}
86
- }) => {
87
- const u = h ? Object.fromEntries(
88
- Object.entries(h).map(([$, x]) => [`data-${$}`, x])
89
- ) : {};
90
- return /* @__PURE__ */ t(
91
- ee,
92
- {
93
- onClick: e,
94
- id: o,
95
- type: l,
96
- className: c,
97
- ...u,
98
- children: /* @__PURE__ */ g(te, { className: "button-icon-text-space", children: [
99
- i ? /* @__PURE__ */ t(ae, { src: i, alt: d }) : r || "",
100
- b && /* @__PURE__ */ t(ne, { id: o, children: b })
101
- ] })
102
- }
103
- );
104
- }, oe = s.div`
86
+ }) => /* @__PURE__ */ t(
87
+ ee,
88
+ {
89
+ onClick: e,
90
+ id: o,
91
+ type: l,
92
+ className: c,
93
+ ...h,
94
+ children: /* @__PURE__ */ g(te, { className: "button-icon-text-space", children: [
95
+ i ? /* @__PURE__ */ t(ne, { src: i, alt: d }) : r || "",
96
+ m && /* @__PURE__ */ t(ae, { id: o, children: m })
97
+ ] })
98
+ }
99
+ ), oe = s.div`
105
100
  display: flex;
106
101
  flex-direction: column;
107
102
  align-items: left;
108
103
  width: 100%;
109
- margin-bottom: ${a.spacing.small};
104
+ margin-bottom: ${n.spacing.small};
110
105
  `, ie = s.div`
111
106
  display: flex;
112
- gap: ${a.spacing.xsmall};
107
+ gap: ${n.spacing.xsmall};
113
108
  width: auto;
114
109
  height: auto;
115
110
  `, le = s.label`
@@ -118,10 +113,10 @@ const a = {
118
113
  justify-content:center;
119
114
  height: auto;
120
115
  flex-direction: ${(e) => e.$labelFlexDirection || "column"};
121
- font-family: ${a.fonts.secondary}, ${a.fonts.fallback};
122
- font-size: ${a.fontSize.xsmall};
123
- font-weight: ${a.fontWeight.bold};
124
- gap: ${a.spacing.xxsmall};
116
+ font-family: ${n.fonts.secondary}, ${n.fonts.fallback};
117
+ font-size: ${n.fontSize.xsmall};
118
+ font-weight: ${n.fontWeight.bold};
119
+ gap: ${n.spacing.xxsmall};
125
120
 
126
121
  & .label-icon-container img,
127
122
  & .label-icon-container svg {
@@ -130,13 +125,13 @@ const a = {
130
125
  object-fit: contain;
131
126
  }
132
127
  `, ce = s.span`
133
- font-weight: ${a.fontWeight.bolder};
128
+ font-weight: ${n.fontWeight.bolder};
134
129
  `, se = s.div`
135
130
  max-width: 100%;
136
131
  display: flex;
137
132
  align-items: center;
138
133
  `, re = s.span`
139
- font-weight: ${a.fontWeight.light};
134
+ font-weight: ${n.fontWeight.light};
140
135
  `, P = ({
141
136
  htmlFor: e,
142
137
  textLabel: o,
@@ -144,9 +139,9 @@ const a = {
144
139
  $labelFlexDirection: i,
145
140
  source: r,
146
141
  svg: d,
147
- className: b,
142
+ className: m,
148
143
  children: c
149
- }) => /* @__PURE__ */ g(le, { htmlFor: e, className: b, $labelFlexDirection: i, children: [
144
+ }) => /* @__PURE__ */ g(le, { htmlFor: e, className: m, $labelFlexDirection: i, children: [
150
145
  (r || d) && /* @__PURE__ */ t(se, { className: "label-icon-container", children: r ? /* @__PURE__ */ t("img", { src: r, alt: `${e}-label-icon` }) : d || "" }),
151
146
  /* @__PURE__ */ t(ce, { className: "main-label", children: o }),
152
147
  l && /* @__PURE__ */ t(re, { className: "additional-info", children: l }),
@@ -154,39 +149,37 @@ const a = {
154
149
  ] }), q = s.input`
155
150
  display: flex;
156
151
  place-content: center;
157
- font-family: ${a.fonts.secondary}, ${a.fonts.fallback};
158
- font-size: ${a.fontSize.xsmall};
152
+ font-family: ${n.fonts.secondary}, ${n.fonts.fallback};
153
+ font-size: ${n.fontSize.xsmall};
159
154
  line-height: 1.75;
160
- padding: ${a.spacing.xxxsmall} ${a.spacing.xsmall};
155
+ padding: ${n.spacing.xxxsmall} ${n.spacing.xsmall};
161
156
  max-width: 100%;
162
157
  height: auto;
163
158
  background-color: #FFFFFF;
164
159
  outline: none;
165
- border: ${a.borderThickness.thin} solid #000000;
166
- border-radius: ${a.borderRadius.xsmall};
160
+ border: ${n.borderThickness.thin} solid #000000;
161
+ border-radius: ${n.borderRadius.xsmall};
167
162
 
168
163
  &:focus{
169
- border: ${a.borderThickness.thin} solid ${({ theme: e }) => e.colors.teal};
164
+ border: ${n.borderThickness.thin} solid ${({ theme: e }) => e.colors.teal};
170
165
  }
171
166
  `, de = s.textarea`
172
167
  display: flex;
173
168
  place-content: center;
174
- border: ${a.borderThickness.light} solid ${({ theme: e }) => e.colors.text};
175
- border-radius: ${a.borderRadius.small};
169
+ border: ${n.borderThickness.light} solid ${({ theme: e }) => e.colors.text};
170
+ border-radius: ${n.borderRadius.small};
176
171
  outline: none;
177
- line-height: ${a.spacing.small};
178
- padding: ${a.spacing.xxxsmall};
179
- font-family: ${a.fonts.secondary}, ${a.fonts.fallback};
180
- font-size: ${a.fontSize.xsmall};
172
+ line-height: ${n.spacing.small};
173
+ padding: ${n.spacing.xxxsmall};
174
+ font-family: ${n.fonts.secondary}, ${n.fonts.fallback};
175
+ font-size: ${n.fontSize.xsmall};
181
176
  max-width: 100%;
182
177
  resize: none;
183
178
  overflow-y: auto;
184
- `, L = X((e, o) => {
185
- const { type: l, id: i, onChange: r, isRequired: d, dataAttributes: b, disabled: c, className: h } = e, u = b ? Object.fromEntries(
186
- Object.entries(b).map(([N, w]) => [`data-${N}`, w])
187
- ) : {};
179
+ `, j = X((e, o) => {
180
+ const { type: l, id: i, onChange: r, isRequired: d, dataAttributes: m, disabled: c, className: h } = e;
188
181
  if (l === "textarea") {
189
- const { rows: N = 5, cols: w = 30, value: A, ...j } = e;
182
+ const { rows: N = 5, cols: E = 30, value: A, ...S } = e;
190
183
  return /* @__PURE__ */ t(
191
184
  de,
192
185
  {
@@ -194,8 +187,8 @@ const a = {
194
187
  onChange: r,
195
188
  value: A,
196
189
  rows: N,
197
- cols: w,
198
- ...u,
190
+ cols: E,
191
+ ...m,
199
192
  className: h,
200
193
  ref: o,
201
194
  disabled: c,
@@ -204,7 +197,7 @@ const a = {
204
197
  );
205
198
  }
206
199
  if (l === "radio" || l === "checkbox") {
207
- const { checked: N, ...w } = e;
200
+ const { checked: N, ...E } = e;
208
201
  return /* @__PURE__ */ t(
209
202
  q,
210
203
  {
@@ -215,137 +208,137 @@ const a = {
215
208
  onChange: r,
216
209
  disabled: c,
217
210
  className: h,
218
- ...u
211
+ ...m
219
212
  }
220
213
  );
221
214
  }
222
- const $ = e, { value: x, pattern: k, placeholderText: C, ...F } = $;
215
+ const $ = e, { value: p, pattern: u, placeholderText: k, ...C } = $;
223
216
  return /* @__PURE__ */ t(
224
217
  q,
225
218
  {
226
219
  id: i,
227
220
  name: i,
228
- placeholder: C,
221
+ placeholder: k,
229
222
  onChange: r,
230
- value: x,
223
+ value: p,
231
224
  type: l,
232
225
  required: d,
233
- ...u,
226
+ ...m,
234
227
  className: h,
235
228
  ref: o,
236
229
  disabled: c,
237
- pattern: k
230
+ pattern: u
238
231
  }
239
232
  );
240
- }), D = (e) => {
233
+ }), T = (e) => {
241
234
  const {
242
235
  className: o,
243
236
  type: l,
244
237
  id: i,
245
238
  textLabel: r,
246
239
  additionalInfo: d,
247
- $labelFlexDirection: b,
240
+ $labelFlexDirection: m,
248
241
  svg: c,
249
242
  labelClass: h,
250
- onChange: u,
251
- isRequired: $,
252
- dataAttributes: x,
243
+ onChange: $,
244
+ isRequired: p,
245
+ dataAttributes: u,
253
246
  inputClass: k,
254
247
  ref: C,
255
- disabled: F,
256
- isEditable: N,
257
- editIcon: w,
258
- onClickEdit: A,
259
- deleteIcon: j,
248
+ disabled: N,
249
+ isEditable: E,
250
+ editIcon: A,
251
+ onClickEdit: S,
252
+ deleteIcon: L,
260
253
  onClickDelete: B,
261
254
  idx: z,
262
- children: O
255
+ children: R
263
256
  } = e;
264
257
  return /* @__PURE__ */ g(oe, { className: `${o} ${i.replace("#", "")}-label-input-container`, children: [
265
- l !== "radio" && l !== "checkbox" && /* @__PURE__ */ t(P, { htmlFor: i, textLabel: r, additionalInfo: d, $labelFlexDirection: b, svg: c, className: h }),
258
+ l !== "radio" && l !== "checkbox" && /* @__PURE__ */ t(P, { htmlFor: i, textLabel: r, additionalInfo: d, $labelFlexDirection: m, svg: c, className: h }),
266
259
  l !== "radio" && l !== "checkbox" && l === "textarea" && (() => {
267
- const { rows: E = 5, cols: v = 30, value: S, ...n } = e;
260
+ const { rows: w = 5, cols: F = 30, value: D, ...a } = e;
268
261
  return /* @__PURE__ */ t(
269
- L,
262
+ j,
270
263
  {
271
264
  id: i,
272
265
  name: i,
273
266
  type: "textarea",
274
- isRequired: $,
275
- onChange: u,
276
- value: S,
277
- rows: E,
278
- cols: v,
279
- dataAttributes: x,
267
+ isRequired: p,
268
+ onChange: $,
269
+ value: D,
270
+ rows: w,
271
+ cols: F,
272
+ dataAttributes: u,
280
273
  className: k,
281
274
  ref: C,
282
- disabled: F
275
+ disabled: N
283
276
  }
284
277
  );
285
278
  })(),
286
279
  l !== "radio" && l !== "checkbox" && l !== "textarea" && (() => {
287
- const E = e, { value: v, pattern: S, placeholderText: n, ...p } = E;
280
+ const w = e, { value: F, pattern: D, placeholderText: a, ...y } = w;
288
281
  return /* @__PURE__ */ t(
289
- L,
282
+ j,
290
283
  {
291
284
  id: i,
292
285
  name: i,
293
- placeholderText: n,
294
- onChange: u,
295
- value: v,
286
+ placeholderText: a,
287
+ onChange: $,
288
+ value: F,
296
289
  type: l,
297
- isRequired: $,
298
- dataAttributes: x,
290
+ isRequired: p,
291
+ dataAttributes: u,
299
292
  className: k,
300
293
  ref: C,
301
- disabled: F,
302
- pattern: S
294
+ disabled: N,
295
+ pattern: D
303
296
  }
304
297
  );
305
298
  })(),
306
299
  (l === "radio" || l === "checkbox") && (() => {
307
- const { checked: E, ...v } = e;
300
+ const { checked: w, ...F } = e;
308
301
  return /* @__PURE__ */ g(V, { children: [
309
302
  /* @__PURE__ */ t(
310
- L,
303
+ j,
311
304
  {
312
305
  ref: C,
313
306
  type: "checkbox",
314
307
  name: i,
315
308
  id: i,
316
- isRequired: $,
317
- checked: E,
318
- onChange: u,
319
- disabled: F,
309
+ isRequired: p,
310
+ checked: w,
311
+ onChange: $,
312
+ disabled: N,
320
313
  className: k,
321
- dataAttributes: x
314
+ dataAttributes: u
322
315
  }
323
316
  ),
324
- /* @__PURE__ */ t(P, { htmlFor: i, textLabel: r, additionalInfo: d, $labelFlexDirection: b, svg: c, className: h })
317
+ /* @__PURE__ */ t(P, { htmlFor: i, textLabel: r, additionalInfo: d, $labelFlexDirection: m, svg: c, className: h })
325
318
  ] });
326
319
  })(),
327
- N && /* @__PURE__ */ g(ie, { className: "input-edit-buttons", children: [
328
- /* @__PURE__ */ t(y, { id: `editable-${i}-edit-btn`, svg: w, buttonType: "button", onClick: A, className: `edit-radio-${z}`, dataAttributes: x }),
329
- /* @__PURE__ */ t(y, { id: `editable-${i}-delete-btn`, svg: j, buttonType: "button", onClick: B, className: `delete-radio-${z}`, dataAttributes: x })
320
+ E && /* @__PURE__ */ g(ie, { className: "input-edit-buttons", children: [
321
+ /* @__PURE__ */ t(x, { id: `editable-${i}-edit-btn`, svg: A, buttonType: "button", onClick: S, className: `edit-radio-${z}`, dataAttributes: u }),
322
+ /* @__PURE__ */ t(x, { id: `editable-${i}-delete-btn`, svg: L, buttonType: "button", onClick: B, className: `delete-radio-${z}`, dataAttributes: u })
330
323
  ] }),
331
- O
324
+ R
332
325
  ] });
333
326
  }, me = s.fieldset`
334
327
  padding: 0;
335
328
  height: auto;
336
329
  width: 100%;
337
330
  `, be = s.legend`
338
- font-size: ${a.spacing.medium};
331
+ font-size: ${n.spacing.medium};
339
332
  font-weight: 500;
340
- margin: 0 auto ${a.spacing.small} auto;
333
+ margin: 0 auto ${n.spacing.small} auto;
341
334
  text-align: center;
342
- font-family: ${a.fonts.secondary}, ${a.fonts.fallback};
335
+ font-family: ${n.fonts.secondary}, ${n.fonts.fallback};
343
336
  `, he = s.div`
344
337
  display: flex;
345
338
  flex-direction: column;
346
339
  align-items: flex-start;
347
340
  width: 100%;
348
- margin-bottom: ${a.spacing.small};
341
+ margin-bottom: ${n.spacing.small};
349
342
  `, fe = s.div`
350
343
  display: flex;
351
344
  justify-content: space-between;
@@ -357,11 +350,11 @@ const a = {
357
350
  onChangeOfEditableOption: i,
358
351
  onClickSaveEdit: r,
359
352
  onClickCancelEdit: d,
360
- onClickDeleteEntry: b
353
+ onClickDeleteEntry: m
361
354
  }) => /* @__PURE__ */ g(me, { className: "editable-selection-fieldset", children: [
362
355
  /* @__PURE__ */ t(be, { children: `${e} ${o + 1}` }),
363
356
  l.map((c, h) => /* @__PURE__ */ t(he, { className: "editable-selection-container", children: /* @__PURE__ */ t(
364
- L,
357
+ j,
365
358
  {
366
359
  id: `editable-selection-${h}`,
367
360
  name: `editable-selection-${h}`,
@@ -379,9 +372,9 @@ const a = {
379
372
  }
380
373
  ) }, `${c.name}-${h}`)),
381
374
  /* @__PURE__ */ g(fe, { className: "editable-selection-button-space", children: [
382
- /* @__PURE__ */ t(y, { id: `editable-selection-${o}-submit`, buttonType: "submit", text: "Save", onClick: r, className: "editable-selection-btn", dataAttributes: { "data-index": o } }),
383
- /* @__PURE__ */ t(y, { id: `editable-selection-${o}-cancel`, buttonType: "button", text: "Cancel", onClick: d, className: "editable-selection-btn", dataAttributes: { "data-index": o } }),
384
- /* @__PURE__ */ t(y, { id: `editable-selection-${o}-delete`, buttonType: "button", text: "Delete", onClick: b, className: "editable-selection-btn", dataAttributes: { "data-index": o } })
375
+ /* @__PURE__ */ t(x, { id: `editable-selection-${o}-submit`, buttonType: "submit", text: "Save", onClick: r, className: "editable-selection-btn", dataAttributes: { "data-index": o } }),
376
+ /* @__PURE__ */ t(x, { id: `editable-selection-${o}-cancel`, buttonType: "button", text: "Cancel", onClick: d, className: "editable-selection-btn", dataAttributes: { "data-index": o } }),
377
+ /* @__PURE__ */ t(x, { id: `editable-selection-${o}-delete`, buttonType: "button", text: "Delete", onClick: m, className: "editable-selection-btn", dataAttributes: { "data-index": o } })
385
378
  ] })
386
379
  ] }), ge = s.div`
387
380
  display: flex;
@@ -394,31 +387,31 @@ const a = {
394
387
  handleSubmit: i,
395
388
  hasEdit: r,
396
389
  editText: d,
397
- handleEdit: b,
390
+ handleEdit: m,
398
391
  hasCancel: c,
399
392
  cancelText: h,
400
- handleCancel: u,
401
- hasDelete: $,
402
- deleteText: x,
393
+ handleCancel: $,
394
+ hasDelete: p,
395
+ deleteText: u,
403
396
  handleDelete: k
404
397
  }) => /* @__PURE__ */ g(ge, { className: "form-main-button-container", children: [
405
- o && /* @__PURE__ */ t(y, { id: `form-${e}-submit`, buttonType: "submit", text: l ?? "Submit", onClick: i, className: "submit-form-btn" }),
406
- r && /* @__PURE__ */ t(y, { id: `form-${e}-edit`, buttonType: "button", text: d ?? "Edit", onClick: b, className: "edit-form-btn" }),
407
- c && /* @__PURE__ */ t(y, { id: `form-${e}-cancel`, buttonType: "button", text: h ?? "Cancel", onClick: u, className: "cancel-form-btn" }),
408
- $ && /* @__PURE__ */ t(y, { id: `form-${e}-delete`, buttonType: "button", text: x ?? "Delete", onClick: k, className: "delete-form-btn" })
398
+ o && /* @__PURE__ */ t(x, { id: `form-${e}-submit`, buttonType: "submit", text: l ?? "Submit", onClick: i, className: "submit-form-btn" }),
399
+ r && /* @__PURE__ */ t(x, { id: `form-${e}-edit`, buttonType: "button", text: d ?? "Edit", onClick: m, className: "edit-form-btn" }),
400
+ c && /* @__PURE__ */ t(x, { id: `form-${e}-cancel`, buttonType: "button", text: h ?? "Cancel", onClick: $, className: "cancel-form-btn" }),
401
+ p && /* @__PURE__ */ t(x, { id: `form-${e}-delete`, buttonType: "button", text: u ?? "Delete", onClick: k, className: "delete-form-btn" })
409
402
  ] }), U = s.legend`
410
- font-size: ${a.spacing.medium};
403
+ font-size: ${n.spacing.medium};
411
404
  font-weight: 500;
412
- margin-bottom: ${a.spacing.small};
405
+ margin-bottom: ${n.spacing.small};
413
406
  width: auto;
414
407
  text-align: center;
415
- font-family: ${a.fonts.secondary}, ${a.fonts.fallback};
408
+ font-family: ${n.fonts.secondary}, ${n.fonts.fallback};
416
409
  `, H = s.fieldset`
417
410
  padding: 0;
418
411
  height: auto;
419
412
  width: 100%;
420
413
  `, G = s.div`
421
- padding: ${a.spacing.small};
414
+ padding: ${n.spacing.small};
422
415
  height: auto;
423
416
  width: 100%;
424
417
  `, J = s.div`
@@ -427,9 +420,9 @@ const a = {
427
420
  align-items: center;
428
421
  width: 100%;
429
422
  height: auto;
430
- font-family: ${a.fonts.tertiary}, ${a.fonts.fallback};
431
- font-size: ${a.fontSize.xsmall};
432
- font-weight: ${a.fontWeight.bold};
423
+ font-family: ${n.fonts.tertiary}, ${n.fonts.fallback};
424
+ font-size: ${n.fontSize.xsmall};
425
+ font-weight: ${n.fontWeight.bold};
433
426
  `, xe = s.form`
434
427
  display: flex;
435
428
  flex-direction: column;
@@ -456,70 +449,70 @@ const a = {
456
449
  formInputs: r,
457
450
  //* object that contains the input fields information to make it reusable
458
451
  labelAndInputContainerClass: d,
459
- labelClass: b,
452
+ labelClass: m,
460
453
  inputClass: c,
461
454
  handleEditableInputEntryChange: h,
462
455
  //* handles change on editable inputs
463
- handleAddingInputEntry: u,
464
- hasSubmit: $ = !1,
465
- hasCancel: x = !1,
456
+ handleAddingInputEntry: $,
457
+ hasSubmit: p = !1,
458
+ hasCancel: u = !1,
466
459
  hasDelete: k = !1,
467
460
  hasEdit: C = !1,
468
- submitText: F,
469
- handleSubmitForm: N,
470
- handleSubmit: w,
471
- cancelText: A,
472
- handleCancel: j,
461
+ submitText: N,
462
+ handleSubmitForm: E,
463
+ handleSubmit: A,
464
+ cancelText: S,
465
+ handleCancel: L,
473
466
  deleteText: B,
474
467
  handleDelete: z,
475
- editText: O,
476
- handleEdit: E,
477
- className: v,
478
- children: S
468
+ editText: R,
469
+ handleEdit: w,
470
+ className: F,
471
+ children: D
479
472
  //* if there are nodes to be inserted after submit/edit/cancel buttons usually in login or signup forms
480
- }) => /* @__PURE__ */ g(xe, { id: `${i}-form`, className: v, onSubmit: N, children: [
481
- e ? e.map((n, p) => /* @__PURE__ */ g(G, { children: [
482
- /* @__PURE__ */ g(H, { id: `${i}-form-fieldset-${p}`, className: "form-fieldset", children: [
483
- n.legend && /* @__PURE__ */ t(U, { children: n.legend }),
484
- n.inputs.length !== 0 ? n.inputs.map((f, T) => /* @__PURE__ */ g(W.Fragment, { children: [
473
+ }) => /* @__PURE__ */ g(xe, { id: `${i}-form`, className: F, onSubmit: E, children: [
474
+ e ? e.map((a, y) => /* @__PURE__ */ g(G, { children: [
475
+ /* @__PURE__ */ g(H, { id: `${i}-form-fieldset-${y}`, className: "form-fieldset", children: [
476
+ a.legend && /* @__PURE__ */ t(U, { children: a.legend }),
477
+ a.inputs.length !== 0 ? a.inputs.map((f, v) => /* @__PURE__ */ g(W.Fragment, { children: [
485
478
  f.type === "textarea" && /* @__PURE__ */ t(
486
- D,
479
+ T,
487
480
  {
488
481
  ...f,
489
- id: f.id ?? `${n.legend}-input`,
490
- labelClass: b,
482
+ id: f.id ?? `${a.legend}-input`,
483
+ labelClass: m,
491
484
  inputClass: c,
492
- idx: T,
485
+ idx: v,
493
486
  className: d
494
487
  }
495
488
  ),
496
489
  (f.type === "radio" || f.type === "checkbox") && /* @__PURE__ */ t(
497
- D,
490
+ T,
498
491
  {
499
492
  ...f,
500
- id: f.id ?? `${n.legend}-input`,
501
- labelClass: b,
493
+ id: f.id ?? `${a.legend}-input`,
494
+ labelClass: m,
502
495
  inputClass: c,
503
- idx: T,
496
+ idx: v,
504
497
  className: d
505
498
  }
506
499
  ),
507
500
  f.type !== "textarea" && f.type !== "radio" && f.type !== "checkbox" && /* @__PURE__ */ t(
508
- D,
501
+ T,
509
502
  {
510
503
  ...f,
511
- id: f.id ?? `${n.legend}-input`,
512
- labelClass: b,
504
+ id: f.id ?? `${a.legend}-input`,
505
+ labelClass: m,
513
506
  inputClass: c,
514
- idx: T,
507
+ idx: v,
515
508
  className: d
516
509
  }
517
510
  ),
518
511
  f.isEditable && f.editing && /* @__PURE__ */ t(
519
512
  M,
520
513
  {
521
- legend: `${n.legend} ${T + 1}`,
522
- idx: T,
514
+ legend: `${a.legend} ${v + 1}`,
515
+ idx: v,
523
516
  editableInformation: f?.editableInformation,
524
517
  onChangeOfEditableOption: h,
525
518
  onClickSaveEdit: f?.onClickSave,
@@ -527,85 +520,85 @@ const a = {
527
520
  onClickDeleteEntry: f?.onClickDelete
528
521
  }
529
522
  )
530
- ] }, `form-${i}-${T}`)) : n.isExpandable ? /* @__PURE__ */ t(J, { children: `No entry yet on ${n.legend}. Click "+" button to add entry.` }) : ""
523
+ ] }, `form-${i}-${v}`)) : a.isExpandable ? /* @__PURE__ */ t(J, { children: `No entry yet on ${a.legend}. Click "+" button to add entry.` }) : ""
531
524
  ] }),
532
- n.isExpandable && /* @__PURE__ */ t(K, { className: "add-input-button-space", children: /* @__PURE__ */ t(y, { id: `expand-${n.legend}-inputs`, buttonType: "button", text: "+", onClick: u, className: "add-input-entry" }) })
533
- ] }, `${n.legend}-${p}`)) : /* @__PURE__ */ g(G, { children: [
525
+ a.isExpandable && /* @__PURE__ */ t(K, { className: "add-input-button-space", children: /* @__PURE__ */ t(x, { id: `expand-${a.legend}-inputs`, buttonType: "button", text: "+", onClick: $, className: "add-input-entry" }) })
526
+ ] }, `${a.legend}-${y}`)) : /* @__PURE__ */ g(G, { children: [
534
527
  /* @__PURE__ */ g(H, { id: `${i}-form-fieldset`, className: "form-fieldset", children: [
535
528
  o && /* @__PURE__ */ t(U, { children: o }),
536
- !e && r && r.length !== 0 ? r.map((n, p) => /* @__PURE__ */ g(W.Fragment, { children: [
537
- n.type === "textarea" && /* @__PURE__ */ t(
538
- D,
529
+ !e && r && r.length !== 0 ? r.map((a, y) => /* @__PURE__ */ g(W.Fragment, { children: [
530
+ a.type === "textarea" && /* @__PURE__ */ t(
531
+ T,
539
532
  {
540
- ...n,
541
- id: n.id ?? `${o}-input`,
542
- labelClass: b,
533
+ ...a,
534
+ id: a.id ?? `${o}-input`,
535
+ labelClass: m,
543
536
  inputClass: c,
544
- idx: p,
537
+ idx: y,
545
538
  className: d
546
539
  }
547
540
  ),
548
- (n.type === "radio" || n.type === "checkbox") && /* @__PURE__ */ t(
549
- D,
541
+ (a.type === "radio" || a.type === "checkbox") && /* @__PURE__ */ t(
542
+ T,
550
543
  {
551
- ...n,
552
- id: n.id ?? `${o}-input`,
553
- labelClass: b,
544
+ ...a,
545
+ id: a.id ?? `${o}-input`,
546
+ labelClass: m,
554
547
  inputClass: c,
555
- idx: p,
548
+ idx: y,
556
549
  className: d
557
550
  }
558
551
  ),
559
- n.type !== "textarea" && n.type !== "radio" && n.type !== "checkbox" && /* @__PURE__ */ t(
560
- D,
552
+ a.type !== "textarea" && a.type !== "radio" && a.type !== "checkbox" && /* @__PURE__ */ t(
553
+ T,
561
554
  {
562
- ...n,
563
- id: n.id ?? `${o}-input`,
564
- labelClass: b,
555
+ ...a,
556
+ id: a.id ?? `${o}-input`,
557
+ labelClass: m,
565
558
  inputClass: c,
566
- idx: p,
559
+ idx: y,
567
560
  className: d
568
561
  }
569
562
  ),
570
- n.isEditable && n.editing && /* @__PURE__ */ t(
563
+ a.isEditable && a.editing && /* @__PURE__ */ t(
571
564
  M,
572
565
  {
573
- legend: `${o} ${p + 1}`,
574
- idx: p,
575
- editableInformation: n?.editableInformation,
566
+ legend: `${o} ${y + 1}`,
567
+ idx: y,
568
+ editableInformation: a?.editableInformation,
576
569
  onChangeOfEditableOption: h,
577
- onClickSaveEdit: n?.onClickSave,
578
- onClickCancelEdit: n?.onClickEdit,
579
- onClickDeleteEntry: n?.onClickDelete
570
+ onClickSaveEdit: a?.onClickSave,
571
+ onClickCancelEdit: a?.onClickEdit,
572
+ onClickDeleteEntry: a?.onClickDelete
580
573
  }
581
574
  )
582
- ] }, `form-${i}-${p}`)) : l ? /* @__PURE__ */ t(J, { children: `No entry yet on ${o}. Please click "+" button to add` }) : ""
575
+ ] }, `form-${i}-${y}`)) : l ? /* @__PURE__ */ t(J, { children: `No entry yet on ${o}. Please click "+" button to add` }) : ""
583
576
  ] }),
584
- l && /* @__PURE__ */ t(K, { className: "add-input-button-space", children: /* @__PURE__ */ t(y, { id: `expand-${o}-inputs`, buttonType: "button", text: "+", onClick: u, className: "add-input-entry" }) })
577
+ l && /* @__PURE__ */ t(K, { className: "add-input-button-space", children: /* @__PURE__ */ t(x, { id: `expand-${o}-inputs`, buttonType: "button", text: "+", onClick: $, className: "add-input-entry" }) })
585
578
  ] }),
586
579
  /* @__PURE__ */ t(
587
580
  ue,
588
581
  {
589
582
  id: i,
590
- hasSubmit: $,
591
- submitText: F,
592
- handleSubmit: w,
583
+ hasSubmit: p,
584
+ submitText: N,
585
+ handleSubmit: A,
593
586
  hasEdit: C,
594
- editText: O,
595
- handleEdit: E,
596
- hasCancel: x,
597
- cancelText: A,
598
- handleCancel: j,
587
+ editText: R,
588
+ handleEdit: w,
589
+ hasCancel: u,
590
+ cancelText: S,
591
+ handleCancel: L,
599
592
  hasDelete: k,
600
593
  deleteText: B,
601
594
  handleDelete: z
602
595
  }
603
596
  ),
604
- /* @__PURE__ */ t($e, { className: "children-container", children: S })
597
+ /* @__PURE__ */ t($e, { className: "children-container", children: D })
605
598
  ] }), ye = (e) => {
606
599
  const o = /^#([0-9A-Fa-f]{3}){1,2}$/, l = /^rgb(a)?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(0|1|0?\.\d+))?\s*\)$/;
607
600
  return o.test(e) || l.test(e) || CSS.supports("color", e);
608
- }, m = (e) => {
601
+ }, b = (e) => {
609
602
  if (!ye(e)) throw new Error(`Invalid color: ${e}`);
610
603
  return e;
611
604
  }, Ee = {
@@ -617,39 +610,39 @@ const a = {
617
610
  //Macbook 13" (1280x800)
618
611
  largeDesktop: "1200px",
619
612
  largerDesktop: "1400px"
620
- }, R = {
613
+ }, O = {
621
614
  name: "light",
622
615
  colors: {
623
- text: m("#333446"),
624
- bg: m("#EEEEEE"),
625
- blue: m("#7F8CAA"),
626
- blue2: m("#80A6FF"),
627
- teal: m("#5b8280ff"),
628
- teal2: m("#AEEAE7"),
629
- gray: m("#AEAEAE"),
630
- information: m("#202234"),
631
- success: m("#123524"),
632
- warning: m("#F2C265"),
633
- error: m("#990000")
616
+ text: b("#333446"),
617
+ bg: b("#EEEEEE"),
618
+ blue: b("#7F8CAA"),
619
+ blue2: b("#80A6FF"),
620
+ teal: b("#5b8280ff"),
621
+ teal2: b("#AEEAE7"),
622
+ gray: b("#AEAEAE"),
623
+ information: b("#202234"),
624
+ success: b("#123524"),
625
+ warning: b("#F2C265"),
626
+ error: b("#990000")
634
627
  }
635
628
  }, pe = {
636
629
  name: "dark",
637
630
  colors: {
638
- bg: m("#333446"),
639
- text: m("#EEEEEE"),
640
- blue: m("#80A6FF"),
641
- blue2: m("#7F8CAA"),
642
- teal: m("#AEEAE7"),
643
- teal2: m("#5b8280ff"),
644
- gray: m("#D0D0DD"),
645
- information: m("#C9E6F0"),
646
- success: m("#9EDF9C"),
647
- warning: m("#FCFFC1"),
648
- error: m("#FAD4D4")
631
+ bg: b("#333446"),
632
+ text: b("#EEEEEE"),
633
+ blue: b("#80A6FF"),
634
+ blue2: b("#7F8CAA"),
635
+ teal: b("#AEEAE7"),
636
+ teal2: b("#5b8280ff"),
637
+ gray: b("#D0D0DD"),
638
+ information: b("#C9E6F0"),
639
+ success: b("#9EDF9C"),
640
+ warning: b("#FCFFC1"),
641
+ error: b("#FAD4D4")
649
642
  }
650
643
  }, Q = Y(void 0), Fe = ({ children: e }) => {
651
- const [o, l] = Z(R), i = () => {
652
- l((r) => r === R ? pe : R);
644
+ const [o, l] = Z(O), i = () => {
645
+ l((r) => r === O ? pe : O);
653
646
  };
654
647
  return /* @__PURE__ */ t(Q.Provider, { value: { currentTheme: o, toggleTheme: i }, children: /* @__PURE__ */ t(I, { theme: o, children: e }) });
655
648
  }, ve = () => _(Q);
@@ -659,6 +652,6 @@ export {
659
652
  Fe as ThemeContextProvider,
660
653
  Ee as breakpoints,
661
654
  pe as darkTheme,
662
- R as lightTheme,
655
+ O as lightTheme,
663
656
  ve as useTheme
664
657
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbgarcia8/react-dynamic-form",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "A form that can be nested with editable, expandable and flexible input-forms",
5
5
  "keywords": [
6
6
  "form",