@kbgarcia8/react-dynamic-form 1.1.0 → 1.1.2

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