@kbgarcia8/react-dynamic-form 1.0.9 → 1.1.1

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