@kbgarcia8/react-dynamic-form 1.0.0

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