@kbgarcia8/react-dynamic-form 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -168,4 +168,4 @@
168
168
  flex-direction: column;
169
169
  align-items: center;
170
170
  justify-content: center;
171
- `,xe=({fieldsets:n=null,legendText:o,isExpandable:l=!1,id:s,formInputs:r,labelAndInputContainerClass:h,labelClass:d,inputClass:i,handleEditableInputEntryChange:b,handleAddingInputEntry:g,hasSubmit:y=!1,hasCancel:u=!1,hasDelete:p=!1,hasEdit:C=!1,submitText:j,handleSubmitForm:w,handleSubmit:T,cancelText:D,handleCancel:L,deleteText:B,handleDelete:S,editText:q,handleEdit:k,className:F,children:A})=>e.jsxs(me,{id:`${s}-form`,className:F,onSubmit:w,children:[n?n.map((a,$)=>e.jsxs(H,{children:[e.jsxs(U,{id:`${s}-form-fieldset-${$}`,className:"form-fieldset",children:[a.legend&&e.jsx(M,{children:a.legend}),a.inputs.length!==0?a.inputs.map((x,N)=>e.jsxs(v.Fragment,{children:[x.type==="textarea"&&e.jsx(E,{...x,id:x.id??`${a.legend}-input`,labelClass:d,inputClass:i,idx:N}),(x.type==="radio"||x.type==="checkbox")&&e.jsx(E,{...x,id:x.id??`${a.legend}-input`,labelClass:d,inputClass:i,idx:N}),x.type!=="textarea"&&x.type!=="radio"&&x.type!=="checkbox"&&e.jsx(E,{...x,id:x.id??`${a.legend}-input`,labelClass:d,inputClass:i,idx:N}),"//* For editable data e.g. address entry, education entry",x.editable&&x.editing&&e.jsx(I,{legend:`${a.legend} ${N+1}`,idx:N,editableInformation:x?.editableInformation,onChangeOfEditableOption:b,onClickSaveEdit:x?.onClickSave,onClickCancelEdit:x?.onClickCancel,onClickDeleteEntry:x?.onClickDelete})]},`form-${s}-${N}`)):a.expandable?e.jsx(G,{children:`No entry yet on ${a.legend}. Click "+" button to add entry.`}):""]}),a.expandable&&e.jsx(J,{className:"add-input-button-space",children:e.jsx(f,{id:`expand-${a.legend}-inputs`,buttonType:"button",text:"+",onClick:g,className:"add-input-entry"})})]},`${a.legend}-${$}`)):e.jsxs(H,{children:[e.jsxs(U,{id:`${s}-form-fieldset`,className:"form-fieldset",children:[o&&e.jsx(M,{children:o}),r.length!==0?r.map((a,$)=>e.jsxs(v.Fragment,{children:[a.type==="textarea"&&e.jsx(E,{...a,id:a.id??`${o}-input`,labelClass:d,inputClass:i,idx:$}),(a.type==="radio"||a.type==="checkbox")&&e.jsx(E,{...a,id:a.id??`${o}-input`,labelClass:d,inputClass:i,idx:$}),a.type!=="textarea"&&a.type!=="radio"&&a.type!=="checkbox"&&e.jsx(E,{...a,id:a.id??`${o}-input`,labelClass:d,inputClass:i,idx:$}),"//*For editable data e.g. address entry, education entry",a.editable&&a.editing&&e.jsx(I,{legend:`${o} ${$+1}`,idx:$,editableInformation:a?.editableInformation,onChangeOfEditableOption:b,onClickSaveEdit:a?.onClickSave,onClickCancelEdit:a?.onClickEdit,onClickDeleteEntry:a?.onClickDelete})]},`form-${s}-${$}`)):l?e.jsx(G,{children:`No entry yet on ${o}. Please click "+" button to add`}):""]}),l&&e.jsx(J,{className:"add-input-button-space",children:e.jsx(f,{id:`expand-${o}-inputs`,buttonType:"button",text:"+",onClick:g,className:"add-input-entry"})})]}),e.jsx(de,{id:s,hasSubmit:y,submitText:j,handleSubmit:T,hasEdit:C,editText:q,handleEdit:k,hasCancel:u,cancelText:D,handleCancel:L,hasDelete:p,deleteText:B,handleDelete:S}),e.jsx(be,{className:"children-container",children:A})]}),he=n=>{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*\)$/;return o.test(n)||l.test(n)||CSS.supports("color",n)},m=n=>{if(!he(n))throw new Error(`Invalid color: ${n}`);return n},ue={mobile:"320px",tablet:"768px",desktop:"992px",largeDesktop:"1200px",largerDesktop:"1400px"},R={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")}},K={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")}},O=v.createContext(void 0),fe=({children:n})=>{const[o,l]=v.useState(R),s=()=>{l(r=>r===R?K:R)};return e.jsx(O.Provider,{value:{currentTheme:o,toggleTheme:s},children:e.jsx(c.ThemeProvider,{theme:o,children:n})})},ge=()=>v.useContext(O);exports.DynamicForm=xe;exports.ThemeContext=O;exports.ThemeContextProvider=fe;exports.breakpoints=ue;exports.darkTheme=K;exports.lightTheme=R;exports.useTheme=ge;
171
+ `,xe=({fieldsets:n=null,legendText:o,isExpandable:l=!1,id:s,formInputs:r,labelAndInputContainerClass:h,labelClass:d,inputClass:i,handleEditableInputEntryChange:b,handleAddingInputEntry:g,hasSubmit:y=!1,hasCancel:u=!1,hasDelete:p=!1,hasEdit:C=!1,submitText:j,handleSubmitForm:w,handleSubmit:T,cancelText:D,handleCancel:L,deleteText:B,handleDelete:S,editText:q,handleEdit:k,className:F,children:A})=>e.jsxs(me,{id:`${s}-form`,className:F,onSubmit:w,children:[n?n.map((a,$)=>e.jsxs(H,{children:[e.jsxs(U,{id:`${s}-form-fieldset-${$}`,className:"form-fieldset",children:[a.legend&&e.jsx(M,{children:a.legend}),a.inputs.length!==0?a.inputs.map((x,N)=>e.jsxs(v.Fragment,{children:[x.type==="textarea"&&e.jsx(E,{...x,id:x.id??`${a.legend}-input`,labelClass:d,inputClass:i,idx:N}),(x.type==="radio"||x.type==="checkbox")&&e.jsx(E,{...x,id:x.id??`${a.legend}-input`,labelClass:d,inputClass:i,idx:N}),x.type!=="textarea"&&x.type!=="radio"&&x.type!=="checkbox"&&e.jsx(E,{...x,id:x.id??`${a.legend}-input`,labelClass:d,inputClass:i,idx:N}),x.editable&&x.editing&&e.jsx(I,{legend:`${a.legend} ${N+1}`,idx:N,editableInformation:x?.editableInformation,onChangeOfEditableOption:b,onClickSaveEdit:x?.onClickSave,onClickCancelEdit:x?.onClickCancel,onClickDeleteEntry:x?.onClickDelete})]},`form-${s}-${N}`)):a.expandable?e.jsx(G,{children:`No entry yet on ${a.legend}. Click "+" button to add entry.`}):""]}),a.expandable&&e.jsx(J,{className:"add-input-button-space",children:e.jsx(f,{id:`expand-${a.legend}-inputs`,buttonType:"button",text:"+",onClick:g,className:"add-input-entry"})})]},`${a.legend}-${$}`)):e.jsxs(H,{children:[e.jsxs(U,{id:`${s}-form-fieldset`,className:"form-fieldset",children:[o&&e.jsx(M,{children:o}),r.length!==0?r.map((a,$)=>e.jsxs(v.Fragment,{children:[a.type==="textarea"&&e.jsx(E,{...a,id:a.id??`${o}-input`,labelClass:d,inputClass:i,idx:$}),(a.type==="radio"||a.type==="checkbox")&&e.jsx(E,{...a,id:a.id??`${o}-input`,labelClass:d,inputClass:i,idx:$}),a.type!=="textarea"&&a.type!=="radio"&&a.type!=="checkbox"&&e.jsx(E,{...a,id:a.id??`${o}-input`,labelClass:d,inputClass:i,idx:$}),a.editable&&a.editing&&e.jsx(I,{legend:`${o} ${$+1}`,idx:$,editableInformation:a?.editableInformation,onChangeOfEditableOption:b,onClickSaveEdit:a?.onClickSave,onClickCancelEdit:a?.onClickEdit,onClickDeleteEntry:a?.onClickDelete})]},`form-${s}-${$}`)):l?e.jsx(G,{children:`No entry yet on ${o}. Please click "+" button to add`}):""]}),l&&e.jsx(J,{className:"add-input-button-space",children:e.jsx(f,{id:`expand-${o}-inputs`,buttonType:"button",text:"+",onClick:g,className:"add-input-entry"})})]}),e.jsx(de,{id:s,hasSubmit:y,submitText:j,handleSubmit:T,hasEdit:C,editText:q,handleEdit:k,hasCancel:u,cancelText:D,handleCancel:L,hasDelete:p,deleteText:B,handleDelete:S}),e.jsx(be,{className:"children-container",children:A})]}),he=n=>{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*\)$/;return o.test(n)||l.test(n)||CSS.supports("color",n)},m=n=>{if(!he(n))throw new Error(`Invalid color: ${n}`);return n},ue={mobile:"320px",tablet:"768px",desktop:"992px",largeDesktop:"1200px",largerDesktop:"1400px"},R={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")}},K={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")}},O=v.createContext(void 0),fe=({children:n})=>{const[o,l]=v.useState(R),s=()=>{l(r=>r===R?K:R)};return e.jsx(O.Provider,{value:{currentTheme:o,toggleTheme:s},children:e.jsx(c.ThemeProvider,{theme:o,children:n})})},ge=()=>v.useContext(O);exports.DynamicForm=xe;exports.ThemeContext=O;exports.ThemeContextProvider=fe;exports.breakpoints=ue;exports.darkTheme=K;exports.lightTheme=R;exports.useTheme=ge;
@@ -179,7 +179,7 @@ const t = {
179
179
  `, j = V((n, o) => {
180
180
  const { type: i, id: l, onChange: r, isRequired: f, dataAttributes: d, disabled: s, className: b } = n;
181
181
  if (i === "textarea") {
182
- const { rows: C = 5, cols: N = 30, value: T, ...S } = n;
182
+ const { rows: C = 5, cols: F = 30, value: T, ...S } = n;
183
183
  return /* @__PURE__ */ e(
184
184
  de,
185
185
  {
@@ -187,7 +187,7 @@ const t = {
187
187
  onChange: r,
188
188
  value: T,
189
189
  rows: C,
190
- cols: N,
190
+ cols: F,
191
191
  ...d,
192
192
  className: b,
193
193
  ref: o,
@@ -197,7 +197,7 @@ const t = {
197
197
  );
198
198
  }
199
199
  if (i === "radio" || i === "checkbox") {
200
- const { checked: C, ...N } = n;
200
+ const { checked: C, ...F } = n;
201
201
  return /* @__PURE__ */ e(
202
202
  q,
203
203
  {
@@ -212,7 +212,7 @@ const t = {
212
212
  }
213
213
  );
214
214
  }
215
- const $ = n, { value: p, pattern: g, placeholderText: k, ...F } = $;
215
+ const $ = n, { value: p, pattern: g, placeholderText: k, ...N } = $;
216
216
  return /* @__PURE__ */ e(
217
217
  q,
218
218
  {
@@ -244,9 +244,9 @@ const t = {
244
244
  isRequired: p,
245
245
  dataAttributes: g,
246
246
  inputClass: k,
247
- ref: F,
247
+ ref: N,
248
248
  disabled: C,
249
- isEditable: N,
249
+ isEditable: F,
250
250
  editIcon: T,
251
251
  onClickEdit: S,
252
252
  deleteIcon: L,
@@ -271,7 +271,7 @@ const t = {
271
271
  cols: E,
272
272
  ...g,
273
273
  className: k,
274
- ref: F,
274
+ ref: N,
275
275
  disabled: C
276
276
  }
277
277
  );
@@ -290,7 +290,7 @@ const t = {
290
290
  isRequired: p,
291
291
  ...g,
292
292
  className: k,
293
- ref: F,
293
+ ref: N,
294
294
  disabled: C,
295
295
  pattern: D
296
296
  }
@@ -302,7 +302,7 @@ const t = {
302
302
  /* @__PURE__ */ e(
303
303
  j,
304
304
  {
305
- ref: F,
305
+ ref: N,
306
306
  type: "checkbox",
307
307
  name: l,
308
308
  id: l,
@@ -318,7 +318,7 @@ const t = {
318
318
  ] });
319
319
  })(),
320
320
  "// * Radio inputs usually have labels next to them",
321
- N && /* @__PURE__ */ u(le, { className: "input-edit-buttons", children: [
321
+ F && /* @__PURE__ */ u(le, { className: "input-edit-buttons", children: [
322
322
  /* @__PURE__ */ e(x, { id: `editable-${l}-edit-btn`, svg: T, buttonType: "button", onClick: S, className: `edit-radio-${z}`, dataAttributes: g }),
323
323
  /* @__PURE__ */ e(x, { id: `editable-${l}-delete-btn`, svg: L, buttonType: "button", onClick: R, className: `delete-radio-${z}`, dataAttributes: g })
324
324
  ] }),
@@ -439,7 +439,7 @@ const t = {
439
439
  flex-direction: column;
440
440
  align-items: center;
441
441
  justify-content: center;
442
- `, Fe = ({
442
+ `, Ne = ({
443
443
  fieldsets: n = null,
444
444
  //* if a form has differrent fieldsets
445
445
  legendText: o,
@@ -458,9 +458,9 @@ const t = {
458
458
  hasSubmit: p = !1,
459
459
  hasCancel: g = !1,
460
460
  hasDelete: k = !1,
461
- hasEdit: F = !1,
461
+ hasEdit: N = !1,
462
462
  submitText: C,
463
- handleSubmitForm: N,
463
+ handleSubmitForm: F,
464
464
  handleSubmit: T,
465
465
  cancelText: S,
466
466
  handleCancel: L,
@@ -471,7 +471,7 @@ const t = {
471
471
  className: E,
472
472
  children: D
473
473
  //* if there are nodes to be inserted after submit/edit/cancel buttons usually in login or signup forms
474
- }) => /* @__PURE__ */ u(xe, { id: `${l}-form`, className: E, onSubmit: N, children: [
474
+ }) => /* @__PURE__ */ u(xe, { id: `${l}-form`, className: E, onSubmit: F, children: [
475
475
  n ? n.map((a, y) => /* @__PURE__ */ u(H, { children: [
476
476
  /* @__PURE__ */ u(U, { id: `${l}-form-fieldset-${y}`, className: "form-fieldset", children: [
477
477
  a.legend && /* @__PURE__ */ e(M, { children: a.legend }),
@@ -506,7 +506,6 @@ const t = {
506
506
  idx: v
507
507
  }
508
508
  ),
509
- "//* For editable data e.g. address entry, education entry",
510
509
  h.editable && h.editing && /* @__PURE__ */ e(
511
510
  I,
512
511
  {
@@ -556,7 +555,6 @@ const t = {
556
555
  idx: y
557
556
  }
558
557
  ),
559
- "//*For editable data e.g. address entry, education entry",
560
558
  a.editable && a.editing && /* @__PURE__ */ e(
561
559
  I,
562
560
  {
@@ -580,7 +578,7 @@ const t = {
580
578
  hasSubmit: p,
581
579
  submitText: C,
582
580
  handleSubmit: T,
583
- hasEdit: F,
581
+ hasEdit: N,
584
582
  editText: B,
585
583
  handleEdit: w,
586
584
  hasCancel: g,
@@ -598,7 +596,7 @@ const t = {
598
596
  }, m = (n) => {
599
597
  if (!ye(n)) throw new Error(`Invalid color: ${n}`);
600
598
  return n;
601
- }, Ne = {
599
+ }, Fe = {
602
600
  mobile: "320px",
603
601
  //Small iPhone SE & Medium: iPhone 12-15
604
602
  tablet: "768px",
@@ -644,10 +642,10 @@ const t = {
644
642
  return /* @__PURE__ */ e(K.Provider, { value: { currentTheme: o, toggleTheme: l }, children: /* @__PURE__ */ e(_, { theme: o, children: n }) });
645
643
  }, ve = () => Z(K);
646
644
  export {
647
- Fe as DynamicForm,
645
+ Ne as DynamicForm,
648
646
  K as ThemeContext,
649
647
  Ee as ThemeContextProvider,
650
- Ne as breakpoints,
648
+ Fe as breakpoints,
651
649
  pe as darkTheme,
652
650
  O as lightTheme,
653
651
  ve as useTheme
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbgarcia8/react-dynamic-form",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A form that can be nested with editable, expandable and flexible input-forms",
5
5
  "keywords": [
6
6
  "form",