@kbgarcia8/react-dynamic-form 1.1.36 → 1.1.37

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.
@@ -131,7 +131,7 @@
131
131
  display: flex;
132
132
  justify-content: space-between;
133
133
  width: 100%;
134
- `,P=({legend:t,fieldsetIndex:s,idx:o,editableInformation:i,onChangeOfEditableOption:m,onClickSaveEdit:r,onClickCancelEdit:d,onClickDeleteEntry:b})=>(console.log(s),e.jsxs(oe,{className:"editable-option-fieldset",children:[e.jsx(se,{children:`${t} ${o+1}`}),i?.map((h,g)=>e.jsx(ie,{className:"editable-option-container",children:e.jsx(A,{id:`editable-option-${g}`,name:`editable-option-${g}`,placeholderText:h.name.charAt(0).toUpperCase()+h.name.slice(1),onChange:m,value:h.info,type:h.type,isRequired:!0,className:"editable-option",dataAttributes:{"data-index":g,"data-fieldsetindex":s,"data-key":h.info}})},`${h.name}-${g}`)),e.jsxs(le,{className:"editable-option-button-space",children:[e.jsx(f,{id:`editable-option-${o}-submit`,buttonType:"button",text:"Save",onClick:r,className:"editable-option-btn",dataAttributes:{"data-index":o,"data-fieldsetindex":s}}),e.jsx(f,{id:`editable-option-${o}-cancel`,buttonType:"button",text:"Cancel",onClick:d,className:"editable-option-btn",dataAttributes:{"data-index":o,"data-fieldsetindex":s}}),e.jsx(f,{id:`editable-option-${o}-delete`,buttonType:"button",text:"Delete",onClick:b,className:"editable-option-btn",dataAttributes:{"data-index":o,"data-fieldsetindex":s}})]})]})),ce=c.div`
134
+ `,P=({legend:t,fieldsetIndex:s,idx:o,editableInformation:i,onChangeOfEditableOption:m,onClickSaveEdit:r,onClickCancelEdit:d,onClickDeleteEntry:b})=>(console.log(s),e.jsxs(oe,{className:"editable-option-fieldset",children:[e.jsxs(se,{children:[`${t} ${o+1}`,`fieldsetIndex: ${s}`]}),i?.map((h,g)=>e.jsx(ie,{className:"editable-option-container",children:e.jsx(A,{id:`editable-option-${g}`,name:`editable-option-${g}`,placeholderText:h.name.charAt(0).toUpperCase()+h.name.slice(1),onChange:m,value:h.info,type:h.type,isRequired:!0,className:"editable-option",dataAttributes:{"data-index":g,"data-fieldsetindex":s,"data-key":h.info}})},`${h.name}-${g}`)),e.jsxs(le,{className:"editable-option-button-space",children:[e.jsx(f,{id:`editable-option-${o}-submit`,buttonType:"button",text:"Save",onClick:r,className:"editable-option-btn",dataAttributes:{"data-index":o,"data-fieldsetindex":s}}),e.jsx(f,{id:`editable-option-${o}-cancel`,buttonType:"button",text:"Cancel",onClick:d,className:"editable-option-btn",dataAttributes:{"data-index":o,"data-fieldsetindex":s}}),e.jsx(f,{id:`editable-option-${o}-delete`,buttonType:"button",text:"Delete",onClick:b,className:"editable-option-btn",dataAttributes:{"data-index":o,"data-fieldsetindex":s}})]})]})),ce=c.div`
135
135
  display: flex;
136
136
  justify-content: space-between;
137
137
  max-width: 100%;
@@ -83,7 +83,7 @@ const t = {
83
83
  text: d = "",
84
84
  className: h = "",
85
85
  dataAttributes: g = {},
86
- ...f
86
+ ...$
87
87
  }) => /* @__PURE__ */ n(
88
88
  Z,
89
89
  {
@@ -91,7 +91,7 @@ const t = {
91
91
  type: o,
92
92
  onClick: e,
93
93
  className: h,
94
- ...f,
94
+ ...$,
95
95
  ...g,
96
96
  children: /* @__PURE__ */ u(_, { className: "button-icon-text-space", children: [
97
97
  i ? /* @__PURE__ */ n(I, { src: i, alt: r }) : m || "",
@@ -221,7 +221,7 @@ const t = {
221
221
  }
222
222
  );
223
223
  }
224
- const f = e, { value: N, pattern: y, placeholderText: C, ...w } = f;
224
+ const $ = e, { value: N, pattern: y, placeholderText: C, ...w } = $;
225
225
  return /* @__PURE__ */ n(
226
226
  W,
227
227
  {
@@ -247,7 +247,7 @@ const t = {
247
247
  $labelFlexDirection: d,
248
248
  svg: h,
249
249
  labelClass: g,
250
- onChange: f,
250
+ onChange: $,
251
251
  isRequired: N,
252
252
  dataAttributes: y,
253
253
  inputClass: C,
@@ -264,7 +264,7 @@ const t = {
264
264
  return /* @__PURE__ */ u(te, { className: `${l} ${i.replace("#", "")}-label-input-container`, children: [
265
265
  o !== "radio" && o !== "checkbox" && /* @__PURE__ */ n(B, { htmlFor: i, textLabel: m, additionalInfo: r, $labelFlexDirection: d, svg: h, className: g }),
266
266
  o !== "radio" && o !== "checkbox" && o === "textarea" && (() => {
267
- const { rows: a = 5, cols: $ = 30, value: s, ...x } = e;
267
+ const { rows: a = 5, cols: f = 30, value: s, ...x } = e;
268
268
  return /* @__PURE__ */ n(
269
269
  T,
270
270
  {
@@ -272,10 +272,10 @@ const t = {
272
272
  name: i,
273
273
  type: "textarea",
274
274
  isRequired: N,
275
- onChange: f,
275
+ onChange: $,
276
276
  value: s,
277
277
  rows: a,
278
- cols: $,
278
+ cols: f,
279
279
  dataAttributes: y,
280
280
  className: C,
281
281
  ref: w,
@@ -284,15 +284,15 @@ const t = {
284
284
  );
285
285
  })(),
286
286
  o !== "radio" && o !== "checkbox" && o !== "textarea" && (() => {
287
- const a = e, { value: $, pattern: s, placeholderText: x, ...L } = a;
287
+ const a = e, { value: f, pattern: s, placeholderText: x, ...L } = a;
288
288
  return /* @__PURE__ */ n(
289
289
  T,
290
290
  {
291
291
  id: i,
292
292
  name: i,
293
293
  placeholderText: x,
294
- onChange: f,
295
- value: $,
294
+ onChange: $,
295
+ value: f,
296
296
  type: o,
297
297
  isRequired: N,
298
298
  dataAttributes: y,
@@ -304,7 +304,7 @@ const t = {
304
304
  );
305
305
  })(),
306
306
  (o === "radio" || o === "checkbox") && (() => {
307
- const { checked: a, ...$ } = e;
307
+ const { checked: a, ...f } = e;
308
308
  return /* @__PURE__ */ u(R, { children: [
309
309
  /* @__PURE__ */ n(
310
310
  T,
@@ -315,7 +315,7 @@ const t = {
315
315
  id: i,
316
316
  isRequired: N,
317
317
  checked: a,
318
- onChange: f,
318
+ onChange: $,
319
319
  disabled: k,
320
320
  className: C,
321
321
  dataAttributes: y
@@ -360,12 +360,15 @@ const t = {
360
360
  onClickCancelEdit: d,
361
361
  onClickDeleteEntry: h
362
362
  }) => (console.log(l), /* @__PURE__ */ u(re, { className: "editable-option-fieldset", children: [
363
- /* @__PURE__ */ n(de, { children: `${e} ${o + 1}` }),
364
- i?.map((g, f) => /* @__PURE__ */ n(me, { className: "editable-option-container", children: /* @__PURE__ */ n(
363
+ /* @__PURE__ */ u(de, { children: [
364
+ `${e} ${o + 1}`,
365
+ `fieldsetIndex: ${l}`
366
+ ] }),
367
+ i?.map((g, $) => /* @__PURE__ */ n(me, { className: "editable-option-container", children: /* @__PURE__ */ n(
365
368
  T,
366
369
  {
367
- id: `editable-option-${f}`,
368
- name: `editable-option-${f}`,
370
+ id: `editable-option-${$}`,
371
+ name: `editable-option-${$}`,
369
372
  placeholderText: g.name.charAt(0).toUpperCase() + g.name.slice(1),
370
373
  onChange: m,
371
374
  value: g.info,
@@ -373,12 +376,12 @@ const t = {
373
376
  isRequired: !0,
374
377
  className: "editable-option",
375
378
  dataAttributes: {
376
- "data-index": f,
379
+ "data-index": $,
377
380
  "data-fieldsetindex": l,
378
381
  "data-key": g.info
379
382
  }
380
383
  }
381
- ) }, `${g.name}-${f}`)),
384
+ ) }, `${g.name}-${$}`)),
382
385
  /* @__PURE__ */ u(be, { className: "editable-option-button-space", children: [
383
386
  /* @__PURE__ */ n(p, { id: `editable-option-${o}-submit`, buttonType: "button", text: "Save", onClick: r, className: "editable-option-btn", dataAttributes: { "data-index": o, "data-fieldsetindex": l } }),
384
387
  /* @__PURE__ */ n(p, { id: `editable-option-${o}-cancel`, buttonType: "button", text: "Cancel", onClick: d, className: "editable-option-btn", dataAttributes: { "data-index": o, "data-fieldsetindex": l } }),
@@ -398,11 +401,11 @@ const t = {
398
401
  handleReset: d,
399
402
  hasCancel: h,
400
403
  cancelText: g,
401
- handleCancel: f
404
+ handleCancel: $
402
405
  }) => /* @__PURE__ */ u(he, { className: "form-main-button-container", children: [
403
406
  l && /* @__PURE__ */ n(p, { id: `form-${e}-submit`, buttonType: "submit", text: o ?? "Submit", onClick: i, className: "submit-form-btn" }),
404
407
  m && /* @__PURE__ */ n(p, { id: `form-${e}-edit`, buttonType: "button", text: r ?? "Reset", onClick: d, className: "reset-form-btn" }),
405
- h && /* @__PURE__ */ n(p, { id: `form-${e}-cancel`, buttonType: "button", text: g ?? "Cancel", onClick: f, className: "cancel-form-btn" })
408
+ h && /* @__PURE__ */ n(p, { id: `form-${e}-cancel`, buttonType: "button", text: g ?? "Cancel", onClick: $, className: "cancel-form-btn" })
406
409
  ] }), M = c.legend`
407
410
  font-size: ${t.spacing.medium};
408
411
  font-weight: 500;
@@ -436,7 +439,7 @@ const t = {
436
439
  display: flex;
437
440
  justify-content: space-between;
438
441
  width: 100%;
439
- `, fe = c.div`
442
+ `, $e = c.div`
440
443
  width: 100%;
441
444
  display: flex;
442
445
  flex-direction: column;
@@ -452,7 +455,7 @@ const t = {
452
455
  labelClass: d,
453
456
  inputClass: h,
454
457
  onChangeOfEditableOption: g,
455
- handleAddingInputEntry: f,
458
+ handleAddingInputEntry: $,
456
459
  hasSubmit: N = !1,
457
460
  submitText: y,
458
461
  handleSubmit: C,
@@ -465,13 +468,13 @@ const t = {
465
468
  handleSubmitForm: z,
466
469
  className: D,
467
470
  children: j
468
- }) => (console.log("Rendering DynamicForm", e), e?.forEach((a, $) => {
469
- console.log("Fieldset index", $, "legend:", a.legend), a.inputs.forEach((s, x) => {
471
+ }) => (console.log("Rendering DynamicForm", e), e?.forEach((a, f) => {
472
+ console.log("Fieldset index", f, "legend:", a.legend), a.inputs.forEach((s, x) => {
470
473
  console.log("Input", x, "type:", s.type, "editing:", s.editing);
471
474
  });
472
475
  }), /* @__PURE__ */ u(ue, { id: `${i}-form`, className: D, onSubmit: z, children: [
473
- e ? e.map((a, $) => /* @__PURE__ */ u(H, { className: `${i}-fieldset-wrapper`, children: [
474
- /* @__PURE__ */ u(U, { id: `${i}-form-fieldset-${$}`, className: `${a.legend}-fieldset`, children: [
476
+ e ? e.map((a, f) => /* @__PURE__ */ u(H, { className: `${i}-fieldset-wrapper`, children: [
477
+ /* @__PURE__ */ u(U, { id: `${i}-form-fieldset-${f}`, className: `${a.legend}-fieldset`, children: [
475
478
  a.legend && /* @__PURE__ */ n(M, { className: `${a.legend}-legend`, children: a.legend }),
476
479
  a.inputs.length !== 0 ? a.inputs.map((s, x) => /* @__PURE__ */ u(q.Fragment, { children: [
477
480
  s.type === "textarea" && /* @__PURE__ */ n(
@@ -512,7 +515,7 @@ const t = {
512
515
  P,
513
516
  {
514
517
  legend: `${a.legend}`,
515
- fieldsetIndex: $,
518
+ fieldsetIndex: f,
516
519
  idx: x,
517
520
  editableInformation: s?.editableInformation || [],
518
521
  onChangeOfEditableOption: g,
@@ -527,11 +530,11 @@ const t = {
527
530
  ] })
528
531
  ] }, `form-${i}-${x}`)) : a.isExpandable ? /* @__PURE__ */ n(O, { children: `No entry yet on ${a.legend}. Click "+" button to add entry.` }) : ""
529
532
  ] }),
530
- a.isExpandable && /* @__PURE__ */ n(G, { className: "add-input-button-space", children: /* @__PURE__ */ n(p, { id: `expand-${a.legend}-inputs`, buttonType: "button", text: "+", onClick: f, className: "add-input-entry", dataAttributes: { "data-fieldsetindex": $ } }) })
531
- ] }, `${a.legend}-${$}`)) : /* @__PURE__ */ u(H, { className: `${i}-fieldset-wrapper`, children: [
533
+ a.isExpandable && /* @__PURE__ */ n(G, { className: "add-input-button-space", children: /* @__PURE__ */ n(p, { id: `expand-${a.legend}-inputs`, buttonType: "button", text: "+", onClick: $, className: "add-input-entry", dataAttributes: { "data-fieldsetindex": f } }) })
534
+ ] }, `${a.legend}-${f}`)) : /* @__PURE__ */ u(H, { className: `${i}-fieldset-wrapper`, children: [
532
535
  /* @__PURE__ */ u(U, { id: `${i}-form-fieldset`, className: `${l}-fieldset`, children: [
533
536
  l && /* @__PURE__ */ n(M, { className: `${l}-legend`, children: l }),
534
- !e && m && m.length !== 0 ? m.map((a, $) => /* @__PURE__ */ u(q.Fragment, { children: [
537
+ !e && m && m.length !== 0 ? m.map((a, f) => /* @__PURE__ */ u(q.Fragment, { children: [
535
538
  a.type === "textarea" && /* @__PURE__ */ n(
536
539
  E,
537
540
  {
@@ -539,7 +542,7 @@ const t = {
539
542
  id: a.id ?? `${l}-input`,
540
543
  labelClass: d,
541
544
  inputClass: h,
542
- idx: $,
545
+ idx: f,
543
546
  className: `${r} ${a?.uniqueClass}`
544
547
  }
545
548
  ),
@@ -550,7 +553,7 @@ const t = {
550
553
  id: a.id ?? `${l}-input`,
551
554
  labelClass: d,
552
555
  inputClass: h,
553
- idx: $,
556
+ idx: f,
554
557
  className: `${r} ${a?.uniqueClass}`
555
558
  }
556
559
  ),
@@ -562,7 +565,7 @@ const t = {
562
565
  id: a.id ?? `${l}-input`,
563
566
  labelClass: d,
564
567
  inputClass: h,
565
- idx: $,
568
+ idx: f,
566
569
  className: `${r} ${a?.uniqueClass}`
567
570
  }
568
571
  ),
@@ -570,7 +573,7 @@ const t = {
570
573
  P,
571
574
  {
572
575
  legend: `${l}`,
573
- idx: $,
576
+ idx: f,
574
577
  editableInformation: a?.editableInformation,
575
578
  onChangeOfEditableOption: g,
576
579
  onClickSaveEdit: a?.onClickSave || ((s) => {
@@ -582,9 +585,9 @@ const t = {
582
585
  }
583
586
  )
584
587
  ] })
585
- ] }, `form-${i}-${$}`)) : o ? /* @__PURE__ */ n(O, { children: `No entry yet on ${l}. Please click "+" button to add` }) : ""
588
+ ] }, `form-${i}-${f}`)) : o ? /* @__PURE__ */ n(O, { children: `No entry yet on ${l}. Please click "+" button to add` }) : ""
586
589
  ] }),
587
- o && /* @__PURE__ */ n(G, { className: "add-input-button-space", children: /* @__PURE__ */ n(p, { id: `expand-${l}-inputs`, buttonType: "button", text: "+", onClick: f, className: "add-input-entry" }) })
590
+ o && /* @__PURE__ */ n(G, { className: "add-input-button-space", children: /* @__PURE__ */ n(p, { id: `expand-${l}-inputs`, buttonType: "button", text: "+", onClick: $, className: "add-input-entry" }) })
588
591
  ] }),
589
592
  /* @__PURE__ */ n(
590
593
  ge,
@@ -601,12 +604,12 @@ const t = {
601
604
  handleCancel: S
602
605
  }
603
606
  ),
604
- /* @__PURE__ */ n(fe, { className: "children-container", children: j })
605
- ] })), $e = (e) => {
607
+ /* @__PURE__ */ n($e, { className: "children-container", children: j })
608
+ ] })), fe = (e) => {
606
609
  const l = /^#([0-9A-Fa-f]{3}){1,2}$/, o = /^rgb(a)?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(0|1|0?\.\d+))?\s*\)$/;
607
610
  return l.test(e) || o.test(e) || CSS.supports("color", e);
608
611
  }, b = (e) => {
609
- if (!$e(e)) throw new Error(`Invalid color: ${e}`);
612
+ if (!fe(e)) throw new Error(`Invalid color: ${e}`);
610
613
  return e;
611
614
  }, we = {
612
615
  mobile: "320px",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbgarcia8/react-dynamic-form",
3
- "version": "1.1.36",
3
+ "version": "1.1.37",
4
4
  "description": "A form that can be nested with editable, expandable and flexible input-forms",
5
5
  "keywords": [
6
6
  "form",