@kbgarcia8/react-dynamic-form 1.1.3 → 1.1.26

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