@kbgarcia8/react-dynamic-form 2.0.3 → 2.0.4
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.
- package/README.md +77 -8
- package/dist/components/organisms/DynamicForm/DynamicForm.d.ts.map +1 -1
- package/dist/react-dynamic-form.cjs.js +45 -45
- package/dist/react-dynamic-form.es.js +386 -368
- package/dist/type/propTypes.d.ts +27 -0
- package/dist/type/propTypes.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -174,6 +174,20 @@ const addressInputsArray = [
|
|
|
174
174
|
editIcon: <.../>, //=>editIcon in EditableInputProps
|
|
175
175
|
deleteIcon: <.../>,
|
|
176
176
|
editing: ...,
|
|
177
|
+
//Styling options for editable option buttons
|
|
178
|
+
editableButtonSize: 'small', //small by default. Value can be only be one of the following: "small" | "smallest" | "smaller" | "medium" | "large" | "larger"
|
|
179
|
+
editableButtonColor: 'primary', //primary by default. Value can only be one of the following: "primary" | "secondary" | "ghost" | "bnw"
|
|
180
|
+
editableButtonRadius: 'squircle', //squircle by default. Value can only be one of the following: "circle" | "square" | "roundedsquare" | "squircle" | "pill"
|
|
181
|
+
//Optional props - text, start icon and end icon of editable option buttons
|
|
182
|
+
saveText: ...,
|
|
183
|
+
saveButtonStartIcon: <.../>,
|
|
184
|
+
saveButtonEndIcon: <.../>,
|
|
185
|
+
cancelText: ...,
|
|
186
|
+
cancelButtonStartIcon: <.../>,
|
|
187
|
+
cancelButtonEndIcon: <.../>,
|
|
188
|
+
deleteText: ...,
|
|
189
|
+
deleteButtonStartIcon: <.../>,
|
|
190
|
+
deleteButtonEndIcon: <.../>,
|
|
177
191
|
//These are informations editable within radio input acting as selection
|
|
178
192
|
editableInformation: [
|
|
179
193
|
{
|
|
@@ -229,7 +243,9 @@ function App() {
|
|
|
229
243
|
| `inputClass` | `string` | — | className for `<Input/>` component inside `<LabeledInput/>` component inside `<DynamicForm/>` |
|
|
230
244
|
| `handleEditableInputEntryChange` | `(e:React.ChangeEvent<HTMLInputElement\|HTMLTextAreaElement>) => void` | — | Function to handle onChange of editable inputs |
|
|
231
245
|
| `handleAddingInputEntry` | `(e:React.MouseEvent<HTMLButtonElement>) => void` | — | Function to add input entry. If isExpandable is false this is not enabled |
|
|
232
|
-
| `
|
|
246
|
+
| `formActionButtonSize` | `string` | `small` | Text size of form action buttons. Values can only be one of the following values: "small", "smallest", "smaller", "medium", "large", "larger" |
|
|
247
|
+
| `formActionButtonColor` | `string` | `primary` | Color of form action buttons. Values can only be one of the following: "primary", "secondary", "ghost", "bnw" |
|
|
248
|
+
| `formActionButtonRadius` | `string` | `squircle` | Border radius of form action buttons. Values can only be one of the following: "circle", "square", "roundedsquare", "squircle", "pill" |
|
|
233
249
|
| `submitText` | `string` | `Submit` | Text inside submit button for `<DynamicForm/>` |
|
|
234
250
|
| `handleSubmit` | `(e:React.MouseEvent<HTMLButtonElement>) => void` | — | Function to handle submit logic for `<DynamicForm/>` |
|
|
235
251
|
| `hasReset` | `boolean` | `false` | This is to enable reset button for `<DynamicForm/>` |
|
|
@@ -252,6 +268,18 @@ function App() {
|
|
|
252
268
|
| `isEditable` | `boolean` | — | To determine if an input is editable or not. This is only applicable for radio or checkbox input to mimick an editable option/selection<br>If false, all props below are automatically not needed |
|
|
253
269
|
| `editing` | `boolean` | — | To identify if an editable input is being modified<br>Can be used in open/close dialogs |
|
|
254
270
|
| `onClickEdit` | `(e:React.MouseEvent<HTMLButtonElement>) => void` | — | Function to handle edit logic of editable input |
|
|
271
|
+
| `editableButtonSize` | `string` | `small` | Text size of editable option buttons. Values can only be one of the following values: "small", "smallest", "smaller", "medium", "large", "larger" |
|
|
272
|
+
| `editableButtonColor` | `string` | `primary` | Color of editable option buttons. Values can only be one of the following: "primary", "secondary", "ghost", "bnw" |
|
|
273
|
+
| `editableButtonRadius` | `string` | `squircle` | Border radius of editable option buttons. Values can only be one of the following: "circle", "square", "roundedsquare", "squircle", "pill" |
|
|
274
|
+
| `saveText` | `string` | `Save` | Text inside save button for `<NestedEditableOption/>` |
|
|
275
|
+
| `saveButtonStartIcon` | `React.ReactNode` | — | TSX/JSX svg component that will serve as the icon before the text (if any) for save button of `<NestedEditableOption/>` |
|
|
276
|
+
| `saveButtonEndIcon` | `React.ReactNode` | — | TSX/JSX svg component that will serve as the icon after the text (if any) for save button of `<NestedEditableOption/>` |
|
|
277
|
+
| `cancelText` | `string` | `Cancel` | Text inside cancel button for `<NestedEditableOption/>` |
|
|
278
|
+
| `cancelButtonStartIcon` | `React.ReactNode` | — | TSX/JSX svg component that will serve as the icon before the text (if any) for cancel button of `<NestedEditableOption/>` |
|
|
279
|
+
| `cancelButtonEndIcon` | `React.ReactNode` | — | TSX/JSX svg component that will serve as the icon after the text (if any) for cancel button of `<NestedEditableOption/>` |
|
|
280
|
+
| `deleteText` | `string` | `Delete` | Text inside delete button for `<NestedEditableOption/>` |
|
|
281
|
+
| `deleteButtonStartIcon` | `React.ReactNode` | — | TSX/JSX svg component that will serve as the icon before the text (if any) for delete button of `<NestedEditableOption/>` |
|
|
282
|
+
| `deleteButtonEndIcon` | `React.ReactNode` | — | TSX/JSX svg component that will serve as the icon after the text (if any) for delete button of `<NestedEditableOption/>` |
|
|
255
283
|
| `editIcon` | `React.ReactNode` | — | TSX/JSX svg component that will serve as an icon for edit button of editable input |
|
|
256
284
|
| `onClickDelete` | `(e:React.MouseEvent<HTMLButtonElement>) => void` | — | Function to handle delete logic of editable input |
|
|
257
285
|
| `deleteIcon` | `React.ReactNode` | — | TSX/JSX svg component that will serve as an icon for delete button of editable input |
|
|
@@ -312,28 +340,66 @@ You allow overriding currentTheme:
|
|
|
312
340
|
<!-- TOC --><a name="reminder-for-custom-theme-override"></a>
|
|
313
341
|
##### Reminder for custom theme override:
|
|
314
342
|
|
|
315
|
-
Below is the supported format for creating a theme object. Usually consisting of light and dark theme
|
|
343
|
+
Below is the supported format for creating a theme object. Usually consisting of light and dark theme. Note that you can specify as many color key-color group you like. In the example below is 'colors', 'anchorTheme', 'footerTheme' and 'notificationPalette'
|
|
316
344
|
|
|
317
345
|
asColor function is used to ensure that color to be supplied in color properties are colors (e.g. hexcode and rgb code). Note that keys of colors are changeable since it has type ``
|
|
318
346
|
|
|
319
347
|
```tsx
|
|
320
348
|
import { asColor } from '@kbgarcia8/react-dynamic-form'
|
|
321
349
|
|
|
350
|
+
export const palette = {
|
|
351
|
+
primary1: asColor('#202234'),
|
|
352
|
+
primary2: asColor('#3C5E83'),
|
|
353
|
+
primary3: asColor('#0F60B6'),
|
|
354
|
+
...
|
|
355
|
+
}
|
|
356
|
+
|
|
322
357
|
export const lightTheme:Theme = {
|
|
323
358
|
name: 'light',
|
|
324
359
|
colors: {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
360
|
+
screenColor: palette.neutral2,
|
|
361
|
+
backgroundColor1: palette.primary1,
|
|
362
|
+
...
|
|
363
|
+
},
|
|
364
|
+
anchorTheme: {
|
|
365
|
+
visited: palette.neutral5,
|
|
366
|
+
hover: palette.primary2,
|
|
367
|
+
active: palette.secondary2
|
|
368
|
+
},
|
|
369
|
+
footerTheme: {
|
|
370
|
+
backgroundColor: palette.neutral5,
|
|
371
|
+
textColor: palette.secondary1,
|
|
372
|
+
shadowColor: palette.shadow1
|
|
373
|
+
},
|
|
374
|
+
notificationPalette: {
|
|
375
|
+
infoText: asColor('#C9E6F0'),
|
|
376
|
+
infoBackground: asColor('#202234'),
|
|
377
|
+
...
|
|
328
378
|
}
|
|
329
379
|
}
|
|
330
380
|
|
|
331
381
|
export const darkTheme:Theme = {
|
|
332
382
|
name: 'dark',
|
|
333
383
|
colors: {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
384
|
+
screenColor: palette.neutral5,
|
|
385
|
+
backgroundColor1: palette.primary2,
|
|
386
|
+
...
|
|
387
|
+
},
|
|
388
|
+
anchorTheme: {
|
|
389
|
+
link: palette.neutral1,
|
|
390
|
+
visited: palette.neutral1,
|
|
391
|
+
hover: palette.primary3,
|
|
392
|
+
active: palette.secondary1
|
|
393
|
+
},
|
|
394
|
+
footerTheme: {
|
|
395
|
+
backgroundColor: palette.accent,
|
|
396
|
+
textColor: palette.primary1,
|
|
397
|
+
shadowColor: palette.shadow2
|
|
398
|
+
},
|
|
399
|
+
notificationPalette: {
|
|
400
|
+
infoText: asColor('#202234'),
|
|
401
|
+
infoBackground: asColor('#C9E6F0'),
|
|
402
|
+
...
|
|
337
403
|
}
|
|
338
404
|
}
|
|
339
405
|
```
|
|
@@ -389,6 +455,9 @@ Every renderable part of the form receives predictable classes or id:
|
|
|
389
455
|
| **No Entry Message** | *default styled component* | Target using parent wrapper |
|
|
390
456
|
| **Children Container** | `children-container` | |
|
|
391
457
|
|
|
458
|
+
#### Note/s
|
|
459
|
+
- These classnames can also be used override styling using native CSS
|
|
460
|
+
|
|
392
461
|
```ts
|
|
393
462
|
import styled from "styled-components";
|
|
394
463
|
import { DynamicForm } from "@kbgarcia8/react-dynamic-form";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicForm.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/DynamicForm/DynamicForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAgB,gBAAgB,EAA+D,MAAM,yBAAyB,CAAC;AAE3I,QAAA,MAAM,WAAW,GAAI,kYA2BnB,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"DynamicForm.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/DynamicForm/DynamicForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAgB,gBAAgB,EAA+D,MAAM,yBAAyB,CAAC;AAE3I,QAAA,MAAM,WAAW,GAAI,kYA2BnB,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,4CA+K1C,CAAA;AAGD,eAAe,WAAW,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
2
|
-
@media (min-width: ${o.breakpoints[
|
|
3
|
-
${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),D=require("react"),s=require("styled-components"),o={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,regular:400,medium:500,bold:700,bolder:900},fontSize:{xxsmall:"0.55rem",xsmall:"0.75rem",small:"1rem",medium:"1.25rem",large:"1.5rem",xlarge:"1.75rem"},spacing:{xxxsmall:"0.25rem",xxsmall:"0.375rem",xsmall:"0.5rem",small:"0.75rem",medium:"1.25rem"},borderRadius:{xsmall:"0.125rem",small:"0.25rem",medium:"0.5rem",large:"1rem",xlarge:"2rem",circle:"50%"},borderThickness:{thin:"0.0625rem",light:"0.125rem"},breakpoints:{mobile:"320px",tablet:"768px",laptop:"1024px",desktop:"1440px",largeDesktop:"1920px"}},te=e=>{const l=/^#([0-9A-Fa-f]{3}){1,2}$/,n=/^rgb(a)?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(0|1|0?\.\d+))?\s*\)$/;return l.test(e)||n.test(e)||CSS.supports("color",e)},b=e=>{if(!te(e))throw new Error(`Invalid color: ${e}`);return e},z=Object.keys(o.breakpoints).reduce((e,l)=>{const n=l;return e[n]=(...a)=>s.css`
|
|
2
|
+
@media (min-width: ${o.breakpoints[n]}) {
|
|
3
|
+
${s.css(...a)}
|
|
4
4
|
}
|
|
5
|
-
`,e},{}),re={primary:
|
|
5
|
+
`,e},{}),re={primary:s.css`
|
|
6
6
|
background-color: ${({theme:e})=>e.colors.backgroundColor1};
|
|
7
7
|
color: ${({theme:e})=>e.colors.textColor3};
|
|
8
8
|
border: ${o.borderThickness.light} solid ${({theme:e})=>e.colors.borderColor2};
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
border: ${o.borderThickness.light} solid ${({theme:e})=>e.colors.shadow};
|
|
19
19
|
cursor: not-allowed;
|
|
20
20
|
}
|
|
21
|
-
`,secondary:
|
|
21
|
+
`,secondary:s.css`
|
|
22
22
|
background-color: ${({theme:e})=>e.colors.backgroundColor4};
|
|
23
23
|
color: ${({theme:e})=>e.colors.textColor1};
|
|
24
24
|
border: ${o.borderThickness.light} solid ${({theme:e})=>e.colors.borderColor1};
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
color: ${({theme:e})=>e.colors.shadow};
|
|
34
34
|
border: ${o.borderThickness.light} solid ${({theme:e})=>e.colors.shadow};
|
|
35
35
|
}
|
|
36
|
-
`,ghost:
|
|
36
|
+
`,ghost:s.css`
|
|
37
37
|
background-color: transparent;
|
|
38
38
|
color: ${({theme:e})=>e.colors.textColor3};
|
|
39
39
|
border: ${o.borderThickness.light} solid ${({theme:e})=>e.colors.textColor3};
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
color: ${({theme:e})=>e.colors.shadow};
|
|
49
49
|
border: ${o.borderThickness.light} solid ${({theme:e})=>e.colors.shadow};
|
|
50
50
|
}
|
|
51
|
-
`,bnw:
|
|
51
|
+
`,bnw:s.css`
|
|
52
52
|
background-color: ${({theme:e})=>e.colors.borderColor1};
|
|
53
53
|
color: ${({theme:e})=>e.colors.borderColor2};
|
|
54
54
|
border: ${o.borderThickness.light} solid ${({theme:e})=>e.colors.borderColor2};
|
|
@@ -63,37 +63,37 @@
|
|
|
63
63
|
color: ${({theme:e})=>e.colors.shadow};
|
|
64
64
|
border: ${o.borderThickness.light} solid ${({theme:e})=>e.colors.shadow};
|
|
65
65
|
}
|
|
66
|
-
`},ae={smallest:
|
|
67
|
-
${
|
|
66
|
+
`},ae={smallest:s.css`
|
|
67
|
+
${z.mobile`
|
|
68
68
|
font-size: ${o.fontSize.xxsmall};
|
|
69
69
|
font-weight: ${o.fontWeight.regular};
|
|
70
70
|
`}
|
|
71
|
-
`,smaller:
|
|
72
|
-
${
|
|
71
|
+
`,smaller:s.css`
|
|
72
|
+
${z.mobile`
|
|
73
73
|
font-size: ${o.fontSize.xsmall};
|
|
74
74
|
font-weight: ${o.fontWeight.regular};
|
|
75
75
|
`}
|
|
76
|
-
`,small:
|
|
77
|
-
${
|
|
76
|
+
`,small:s.css`
|
|
77
|
+
${z.mobile`
|
|
78
78
|
font-size: ${o.fontSize.small};
|
|
79
79
|
font-weight: ${o.fontWeight.medium};
|
|
80
80
|
`}
|
|
81
|
-
`,medium:
|
|
82
|
-
${
|
|
81
|
+
`,medium:s.css`
|
|
82
|
+
${z.mobile`
|
|
83
83
|
font-size: ${o.fontSize.medium};
|
|
84
84
|
font-weight: ${o.fontWeight.bold};
|
|
85
85
|
`}
|
|
86
|
-
`,large:
|
|
87
|
-
${
|
|
86
|
+
`,large:s.css`
|
|
87
|
+
${z.mobile`
|
|
88
88
|
font-size: ${o.fontSize.large};
|
|
89
89
|
font-weight: ${o.fontWeight.bolder};
|
|
90
90
|
`}
|
|
91
|
-
`,larger:
|
|
92
|
-
${
|
|
91
|
+
`,larger:s.css`
|
|
92
|
+
${z.mobile`
|
|
93
93
|
font-size: ${o.fontSize.xlarge};
|
|
94
94
|
font-weight: ${o.fontWeight.bolder};
|
|
95
95
|
`}
|
|
96
|
-
`},se={square:
|
|
96
|
+
`},se={square:s.css`border-radius: ${o.borderRadius.xsmall};`,roundedsquare:s.css`border-radius: ${o.borderRadius.medium};`,squircle:s.css`border-radius: ${o.borderRadius.large};`,pill:s.css`border-radius: ${o.borderRadius.xlarge};`,circle:s.css`border-radius: ${o.borderRadius.circle};`},M=s.button`
|
|
97
97
|
width: 100%;
|
|
98
98
|
display: flex;
|
|
99
99
|
align-items: center;
|
|
@@ -116,19 +116,19 @@
|
|
|
116
116
|
cursor: not-allowed;
|
|
117
117
|
opacity: 0.6;
|
|
118
118
|
}
|
|
119
|
-
`,
|
|
119
|
+
`,U=s.div`
|
|
120
120
|
width: 100%;
|
|
121
121
|
display: flex;
|
|
122
122
|
flex-direction: row;
|
|
123
123
|
align-items: center;
|
|
124
124
|
justify-content: space-around;
|
|
125
125
|
|
|
126
|
-
${({$hasIcon:e,$hasText:
|
|
126
|
+
${({$hasIcon:e,$hasText:l})=>e&&l?s.css``:s.css`
|
|
127
127
|
& > * {
|
|
128
128
|
flex: 1;
|
|
129
129
|
}
|
|
130
130
|
`}
|
|
131
|
-
`,
|
|
131
|
+
`,H=s.span`
|
|
132
132
|
flex: 2;
|
|
133
133
|
${({$size:e})=>ae[e||"small"]}
|
|
134
134
|
font-family: ${o.fonts.tertiary}, ${o.fonts.fallback};
|
|
@@ -136,18 +136,18 @@
|
|
|
136
136
|
align-items: center;
|
|
137
137
|
justify-content: center;
|
|
138
138
|
max-width: 80%;
|
|
139
|
-
`,w=({onClick:e,id:
|
|
139
|
+
`,w=({onClick:e,id:l,buttonType:n="button",startIcon:a,endIcon:m,text:d="",className:x="",dataAttributes:u={},color:h,radius:$,size:g})=>n==="submit"?t.jsx(M,{id:l,type:"submit",className:x,...u,$color:h||"primary",$radius:$||"squircle",children:t.jsxs(U,{className:"button-icon-text-space",$hasIcon:!!(a||m),$hasText:!!d,children:[a||"",d&&t.jsx(H,{$size:g||"small",id:l,children:d}),m||""]})}):t.jsx(M,{onClick:e,id:l,type:n,className:x,...u,$color:h||"primary",$radius:$||"squircle",children:t.jsxs(U,{className:"button-icon-text-space",$hasIcon:!!(a||m),$hasText:!!d,children:[a||"",d&&t.jsx(H,{$size:g||"small",id:l,children:d}),m||""]})}),ne=s.div`
|
|
140
140
|
display: flex;
|
|
141
141
|
flex-direction: column;
|
|
142
142
|
align-items: left;
|
|
143
143
|
width: 100%;
|
|
144
144
|
margin-bottom: ${o.spacing.small};
|
|
145
|
-
`,
|
|
145
|
+
`,le=s.div`
|
|
146
146
|
display: flex;
|
|
147
147
|
gap: ${o.spacing.xsmall};
|
|
148
148
|
width: auto;
|
|
149
149
|
height: auto;
|
|
150
|
-
`,
|
|
150
|
+
`,ce=s.label`
|
|
151
151
|
display: flex;
|
|
152
152
|
align-items: center;
|
|
153
153
|
justify-content: center;
|
|
@@ -164,21 +164,21 @@
|
|
|
164
164
|
height: auto;
|
|
165
165
|
object-fit: contain;
|
|
166
166
|
}
|
|
167
|
-
`,
|
|
167
|
+
`,ie=s.div`
|
|
168
168
|
display: flex;
|
|
169
169
|
flex-direction: column;
|
|
170
170
|
align-items: center;
|
|
171
171
|
justify-content: center;
|
|
172
172
|
gap: ${o.spacing.xxxsmall};
|
|
173
|
-
`,de=
|
|
173
|
+
`,de=s.span`
|
|
174
174
|
font-weight: ${o.fontWeight.bolder};
|
|
175
|
-
`,
|
|
175
|
+
`,Z=s.div`
|
|
176
176
|
max-width: 100%;
|
|
177
177
|
display: flex;
|
|
178
178
|
align-items: center;
|
|
179
|
-
`,me=
|
|
179
|
+
`,me=s.span`
|
|
180
180
|
font-weight: ${o.fontWeight.light};
|
|
181
|
-
`,
|
|
181
|
+
`,G=({htmlFor:e,textLabel:l,additionalInfo:n,$labelFlexDirection:a,startIcon:m,endIcon:d,className:x,children:u})=>t.jsxs(ce,{htmlFor:e,className:x,$labelFlexDirection:a,children:[m&&t.jsx(Z,{className:"label-icon-container",children:m}),t.jsxs(ie,{className:"label-text-container",children:[t.jsx(de,{className:"main-label",children:l}),n&&t.jsx(me,{className:"additional-info",children:n})]}),d&&t.jsx(Z,{className:"label-icon-container",children:d}),u]}),J=s.input`
|
|
182
182
|
display: flex;
|
|
183
183
|
place-content: center;
|
|
184
184
|
font-family: ${o.fonts.secondary}, ${o.fonts.fallback};
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
&:focus{
|
|
196
196
|
border: ${o.borderThickness.thin} solid ${({theme:e})=>e.colors.teal};
|
|
197
197
|
}
|
|
198
|
-
`,be=
|
|
198
|
+
`,be=s.textarea`
|
|
199
199
|
display: flex;
|
|
200
200
|
place-content: center;
|
|
201
201
|
border: ${o.borderThickness.light} solid ${({theme:e})=>e.colors.text};
|
|
@@ -208,27 +208,27 @@
|
|
|
208
208
|
max-width: 100%;
|
|
209
209
|
resize: none;
|
|
210
210
|
overflow-y: auto;
|
|
211
|
-
`,
|
|
211
|
+
`,P=D.forwardRef((e,l)=>{const{type:n,id:a,onChange:m,isRequired:d,dataAttributes:x={},disabled:u,className:h,name:$}=e;if(n==="textarea"){const{rows:p=5,cols:F=30,value:B,...S}=e;return t.jsx(be,{ref:l,value:B,rows:p,cols:F,id:a,onChange:m,required:d,disabled:u,...x,className:h,name:$})}if(n==="radio"||n==="checkbox"){const{checked:p,...F}=e;return t.jsx(J,{ref:l,type:n,checked:p,id:a,onChange:m,required:d,...x,disabled:u,className:h,name:$})}const g=e,{value:y,pattern:f,placeholderText:k,...T}=g;return t.jsx(J,{ref:l,type:n,value:y,pattern:f,placeholder:k,id:a,onChange:m,required:d,...x,disabled:u,className:h,name:$})}),q=e=>{const{className:l,type:n,id:a,textLabel:m,additionalInfo:d,$labelFlexDirection:x,startIcon:u,endIcon:h,labelClass:$="",onChange:g,isRequired:y,dataAttributes:f,inputClass:k="",ref:T,disabled:p,isEditable:F,editIcon:B,onClickEdit:S,deleteIcon:I,onClickDelete:j,idx:v,children:W}=e;return t.jsxs(ne,{className:`${l} ${a.replace("#","")}-label-input-container`,children:[n!=="radio"&&n!=="checkbox"&&t.jsx(G,{startIcon:u,endIcon:h,htmlFor:a,textLabel:m,additionalInfo:d,$labelFlexDirection:x,className:$}),n!=="radio"&&n!=="checkbox"&&n==="textarea"&&(()=>{const{rows:N=5,cols:E=30,value:R,...r}=e;return t.jsx(P,{id:a,name:a,type:"textarea",isRequired:y,onChange:g,value:R,rows:N,cols:E,dataAttributes:f,className:k,ref:T,disabled:p})})(),n!=="radio"&&n!=="checkbox"&&n!=="textarea"&&(()=>{const N=e,{value:E,pattern:R,placeholderText:r,...C}=N;return t.jsx(P,{id:a,name:a,placeholderText:r,onChange:g,value:E,type:n,isRequired:y,dataAttributes:f,className:k,ref:T,disabled:p,pattern:R})})(),(n==="radio"||n==="checkbox")&&(()=>{const{checked:N,...E}=e;return t.jsxs(t.Fragment,{children:[t.jsx(P,{ref:T,type:n,name:a,id:a,isRequired:y,checked:N,onChange:g,disabled:p,className:k,dataAttributes:f}),t.jsx(G,{startIcon:u,endIcon:h,htmlFor:a,textLabel:m,additionalInfo:d,$labelFlexDirection:x,className:$})]})})(),F&&t.jsxs(le,{className:"input-edit-buttons",children:[t.jsx(w,{id:`editable-${a}-edit-btn`,startIcon:B,buttonType:"button",onClick:S,className:`edit-radio-${v}`,dataAttributes:f}),t.jsx(w,{id:`editable-${a}-delete-btn`,startIcon:I,buttonType:"button",onClick:j,className:`delete-radio-${v}`,dataAttributes:f})]}),W]})},xe=s.fieldset`
|
|
212
212
|
padding: 0;
|
|
213
213
|
height: auto;
|
|
214
214
|
width: 100%;
|
|
215
|
-
`,
|
|
215
|
+
`,ue=s.legend`
|
|
216
216
|
font-size: ${o.spacing.medium};
|
|
217
217
|
font-weight: 500;
|
|
218
218
|
margin: 0 auto ${o.spacing.small} auto;
|
|
219
219
|
text-align: center;
|
|
220
220
|
font-family: ${o.fonts.secondary}, ${o.fonts.fallback};
|
|
221
|
-
`,
|
|
221
|
+
`,he=s.div`
|
|
222
222
|
display: flex;
|
|
223
223
|
flex-direction: column;
|
|
224
224
|
align-items: flex-start;
|
|
225
225
|
width: 100%;
|
|
226
226
|
margin-bottom: ${o.spacing.small};
|
|
227
|
-
`,$e=
|
|
227
|
+
`,$e=s.div`
|
|
228
228
|
display: flex;
|
|
229
229
|
justify-content: space-between;
|
|
230
230
|
width: 100%;
|
|
231
|
-
`,K=({editableButtonSize:e,editableButtonColor:
|
|
231
|
+
`,K=({editableButtonSize:e,editableButtonColor:l,editableButtonRadius:n,legend:a,fieldsetIndex:m,idx:d,editableInformation:x,saveText:u,saveButtonStartIcon:h,saveButtonEndIcon:$,cancelText:g,cancelButtonStartIcon:y,cancelButtonEndIcon:f,deleteText:k,deleteButtonStartIcon:T,deleteButtonEndIcon:p,onChangeOfEditableOption:F,onClickSaveEdit:B,onClickCancelEdit:S,onClickDeleteEntry:I})=>t.jsxs(xe,{className:"editable-option-fieldset",children:[t.jsx(ue,{children:`${a} ${d+1}`}),x?.map((j,v)=>t.jsx(he,{className:"editable-option-container",children:t.jsx(P,{id:`editable-option-${v}`,name:`editable-option-${v}`,placeholderText:j.name.charAt(0).toUpperCase()+j.name.slice(1),onChange:F,value:j.info,type:j.type,isRequired:!0,className:"editable-option",dataAttributes:{"data-index":v,"data-fieldsetindex":m,"data-key":j.info}})},`${j.name}-${v}`)),t.jsxs($e,{className:"editable-option-button-space",children:[t.jsx(w,{startIcon:h,endIcon:$,size:e||"small",color:l||"primary",radius:n||"squircle",id:`editable-option-${d}-submit`,buttonType:"button",text:u||"Save",onClick:B,className:"editable-option-btn",dataAttributes:{"data-index":d,"data-fieldsetindex":m}}),t.jsx(w,{startIcon:y,endIcon:f,size:e||"small",color:l||"primary",radius:n||"squircle",id:`editable-option-${d}-cancel`,buttonType:"button",text:g||"Cancel",onClick:S,className:"editable-option-btn",dataAttributes:{"data-index":d,"data-fieldsetindex":m}}),t.jsx(w,{startIcon:T,endIcon:p,size:e||"small",color:l||"primary",radius:n||"squircle",id:`editable-option-${d}-delete`,buttonType:"button",text:k||"Delete",onClick:I,className:"editable-option-btn",dataAttributes:{"data-index":d,"data-fieldsetindex":m}})]})]}),ge=s.div`
|
|
232
232
|
display: flex;
|
|
233
233
|
justify-content: space-around;
|
|
234
234
|
align-content: center;
|
|
@@ -236,22 +236,22 @@
|
|
|
236
236
|
& button {
|
|
237
237
|
margin-inline: 0.25rem;
|
|
238
238
|
}
|
|
239
|
-
`,fe=({id:e,formActionButtonSize:
|
|
239
|
+
`,fe=({id:e,formActionButtonSize:l,formActionButtonColor:n,formActionButtonRadius:a,submitText:m,submitIcon:d,hasReset:x,resetText:u,resetIcon:h,handleReset:$,hasCancel:g,cancelText:y,cancelIcon:f,handleCancel:k})=>t.jsxs(ge,{className:"form-main-button-container",children:[t.jsx(w,{id:`form-${e}-submit`,size:l||"small",color:n||"primary",radius:a||"squircle",startIcon:d,buttonType:"submit",text:m??"Submit",className:"submit-form-btn"}),x&&t.jsx(w,{id:`form-${e}-edit`,size:l||"small",color:n||"primary",radius:a||"squircle",startIcon:h,buttonType:"button",text:u??"Reset",onClick:$,className:"reset-form-btn"}),g&&t.jsx(w,{id:`form-${e}-cancel`,size:l||"small",color:n||"primary",radius:a||"squircle",startIcon:f,buttonType:"button",text:y??"Cancel",onClick:k,className:"cancel-form-btn"})]}),Q=s.legend`
|
|
240
240
|
font-size: ${o.spacing.medium};
|
|
241
241
|
font-weight: 500;
|
|
242
242
|
margin-bottom: ${o.spacing.small};
|
|
243
243
|
width: auto;
|
|
244
244
|
text-align: center;
|
|
245
245
|
font-family: ${o.fonts.secondary}, ${o.fonts.fallback};
|
|
246
|
-
`,V=
|
|
246
|
+
`,V=s.fieldset`
|
|
247
247
|
padding: 0;
|
|
248
248
|
height: auto;
|
|
249
249
|
width: 100%;
|
|
250
|
-
`,X=
|
|
250
|
+
`,X=s.div`
|
|
251
251
|
padding: ${o.spacing.small};
|
|
252
252
|
height: auto;
|
|
253
253
|
width: 100%;
|
|
254
|
-
`,Y=
|
|
254
|
+
`,Y=s.div`
|
|
255
255
|
display: flex;
|
|
256
256
|
justify-content: center;
|
|
257
257
|
align-items: center;
|
|
@@ -260,19 +260,19 @@
|
|
|
260
260
|
font-family: ${o.fonts.tertiary}, ${o.fonts.fallback};
|
|
261
261
|
font-size: ${o.fontSize.xsmall};
|
|
262
262
|
font-weight: ${o.fontWeight.bold};
|
|
263
|
-
`,ye=
|
|
263
|
+
`,ye=s.form`
|
|
264
264
|
display: flex;
|
|
265
265
|
flex-direction: column;
|
|
266
266
|
align-items: center;
|
|
267
267
|
width: 100%;
|
|
268
|
-
`,_=
|
|
268
|
+
`,_=s.div`
|
|
269
269
|
display: flex;
|
|
270
270
|
justify-content: space-between;
|
|
271
271
|
width: 100%;
|
|
272
|
-
`,
|
|
272
|
+
`,ke=s.div`
|
|
273
273
|
width: 100%;
|
|
274
274
|
display: flex;
|
|
275
275
|
flex-direction: column;
|
|
276
276
|
align-items: center;
|
|
277
277
|
justify-content: center;
|
|
278
|
-
`,
|
|
278
|
+
`,pe=({fieldsets:e=null,legendText:l,isExpandable:n,id:a,formInputs:m,labelAndInputContainerClass:d,labelClass:x,inputClass:u,onChangeOfEditableOption:h,handleAddingInputEntry:$,formActionButtonSize:g,formActionButtonColor:y,formActionButtonRadius:f,submitText:k,submitIcon:T,hasReset:p=!1,resetText:F,resetIcon:B,handleReset:S,hasCancel:I=!1,cancelText:j,cancelIcon:v,handleCancel:W,handleSubmitForm:N,className:E,children:R})=>t.jsxs(ye,{id:`${a}-form`,className:E,onSubmit:N,children:[e?e.map((r,C)=>t.jsxs(X,{className:`${a}-fieldset-wrapper`,children:[t.jsxs(V,{id:`${a}-form-fieldset-${C}`,className:`${r.legend}-fieldset`,children:[r.legend&&t.jsx(Q,{className:`${r.legend}-legend`,children:r.legend}),r.inputs.length!==0?r.inputs.map((c,L)=>t.jsxs(D.Fragment,{children:[c.type==="textarea"&&t.jsx(q,{...c,id:c.id??`${r.legend}-input`,labelClass:x,inputClass:u,idx:L,className:`${d} ${c?.uniqueClass}`}),c.type!=="textarea"&&c.type!=="radio"&&c.type!=="checkbox"&&t.jsx(q,{...c,id:c.id??`${r.legend}-input`,labelClass:x,inputClass:u,idx:L,className:`${d} ${c?.uniqueClass}`}),(c.type==="radio"||c.type==="checkbox")&&t.jsxs(t.Fragment,{children:[t.jsx(q,{...c,id:c.id??`${r.legend}-input`,labelClass:x,inputClass:u,idx:L,className:`${d} ${c?.uniqueClass}`}),c.editing&&c.isEditable&&t.jsx(K,{editableButtonSize:c.editableButtonSize,editableButtonColor:c.editableButtonColor,editableButtonRadius:c.editableButtonRadius,legend:`${r.legend}`,fieldsetIndex:C,idx:L,saveText:c.saveText??void 0,saveButtonStartIcon:c.saveButtonStartIcon??void 0,saveButtonEndIcon:c.saveButtonEndIcon??void 0,cancelText:c.cancelText??void 0,cancelButtonStartIcon:c.cancelButtonStartIcon??void 0,cancelButtonEndIcon:c.cancelButtonEndIcon??void 0,deleteText:c.deleteText??void 0,deleteButtonStartIcon:c.deleteButtonStartIcon??void 0,deleteButtonEndIcon:c.deleteButtonEndIcon??void 0,editableInformation:c?.editableInformation||[],onChangeOfEditableOption:h,onClickSaveEdit:c?.onClickSave||(O=>{}),onClickCancelEdit:c?.onClickCancel||(O=>{}),onClickDeleteEntry:c?.onClickDelete||(O=>{})})]})]},`form-${a}-${L}`)):r.isExpandable?t.jsx(Y,{children:`No entry yet on ${r.legend}. Click "+" button to add entry.`}):""]}),r.isExpandable&&t.jsx(_,{className:"add-input-button-space",children:t.jsx(w,{id:`expand-${r.legend}-inputs`,buttonType:"button",text:"+",onClick:$,className:"add-input-entry",dataAttributes:{"data-fieldsetindex":C}})})]},`${r.legend}-${C}`)):t.jsxs(X,{className:`${a}-fieldset-wrapper`,children:[t.jsxs(V,{id:`${a}-form-fieldset`,className:`${l}-fieldset`,children:[l&&t.jsx(Q,{className:`${l}-legend`,children:l}),!e&&m&&m.length!==0?m.map((r,C)=>t.jsxs(D.Fragment,{children:[r.type==="textarea"&&t.jsx(q,{...r,id:r.id??`${l}-input`,labelClass:x,inputClass:u,idx:C,className:`${d} ${r?.uniqueClass}`}),r.type!=="textarea"&&r.type!=="radio"&&r.type!=="checkbox"&&t.jsx(q,{...r,id:r.id??`${l}-input`,labelClass:x,inputClass:u,idx:C,className:`${d} ${r?.uniqueClass}`}),(r.type==="radio"||r.type==="checkbox")&&t.jsxs(t.Fragment,{children:[t.jsx(q,{...r,id:r.id??`${l}-input`,labelClass:x,inputClass:u,idx:C,className:`${d} ${r?.uniqueClass}`}),r.editing&&r.isEditable&&t.jsx(K,{editableButtonSize:r.editableButtonSize,editableButtonColor:r.editableButtonColor,editableButtonRadius:r.editableButtonRadius,legend:`${l}`,idx:C,saveText:r.saveText??void 0,saveButtonStartIcon:r.saveButtonStartIcon??void 0,saveButtonEndIcon:r.saveButtonEndIcon??void 0,cancelText:r.cancelText??void 0,cancelButtonStartIcon:r.cancelButtonStartIcon??void 0,cancelButtonEndIcon:r.cancelButtonEndIcon??void 0,deleteText:r.deleteText??void 0,deleteButtonStartIcon:r.deleteButtonStartIcon??void 0,deleteButtonEndIcon:r.deleteButtonEndIcon??void 0,editableInformation:r?.editableInformation,onChangeOfEditableOption:h,onClickSaveEdit:r?.onClickSave||(c=>{}),onClickCancelEdit:r?.onClickCancel||(c=>{}),onClickDeleteEntry:r?.onClickDelete||(c=>{})})]})]},`form-${a}-${C}`)):n?t.jsx(Y,{children:`No entry yet on ${l}. Please click "+" button to add`}):""]}),n&&t.jsx(_,{className:"add-input-button-space",children:t.jsx(w,{id:`expand-${l}-inputs`,buttonType:"button",text:"+",onClick:$,className:"add-input-entry"})})]}),t.jsx(fe,{id:a,formActionButtonSize:g,formActionButtonColor:y,formActionButtonRadius:f,submitText:k,submitIcon:T,hasReset:p,resetText:F,resetIcon:B,handleReset:S,hasCancel:I,cancelText:j,cancelIcon:v,handleCancel:W}),t.jsx(ke,{className:"children-container",children:R})]}),Ce={mobile:"320px",tablet:"768px",desktop:"992px",largeDesktop:"1200px",largerDesktop:"1400px"},i={primary1:b("#202234"),primary2:b("#3C5E83"),primary3:b("#0F60B6"),secondary1:b("#C67E10"),secondary2:b("#F6C46D"),neutral1:b("#FFFFFF"),neutral2:b("#F2F2F2"),neutral3:b("#ABABAB"),neutral4:b("#373A40"),neutral5:b("#000000"),accent:b("#E1D3B7"),shadow1:b("rgb(88, 88, 88)"),shadow2:b("rgba(255, 255, 255, 0.50)")},ee={name:"light",colors:{screenColor:i.neutral2,backgroundColor1:i.primary1,backgroundColor2:i.primary2,backgroundColor3:i.secondary2,backgroundColor4:i.secondary1,borderColor1:i.neutral5,borderColor2:i.neutral3,textColor1:i.neutral5,textColor2:i.neutral4,textColor3:i.accent,shadow:i.shadow1},anchorTheme:{visited:i.neutral5,hover:i.primary2,active:i.secondary2},footerTheme:{backgroundColor:i.neutral5,textColor:i.secondary1,shadowColor:i.shadow1},notificationPalette:{infoText:b("#C9E6F0"),infoBackground:b("#202234"),warningText:b("#FCFFC1"),warningBackground:b("#F2C265"),successText:b("#9EDF9C"),successBackground:b("#123524"),errorText:b("#FAD4D4"),errorBackground:b("#990000")}},oe={name:"dark",colors:{screenColor:i.neutral5,backgroundColor1:i.primary2,backgroundColor2:i.primary3,backgroundColor3:i.secondary1,backgroundColor4:i.secondary2,borderColor1:i.neutral2,borderColor2:i.neutral3,textColor1:i.neutral1,textColor2:i.accent,textColor3:i.neutral2,shadow:i.shadow2},anchorTheme:{link:i.neutral1,visited:i.neutral1,hover:i.primary3,active:i.secondary1},footerTheme:{backgroundColor:i.accent,textColor:i.primary1,shadowColor:i.shadow2},notificationPalette:{infoText:b("#202234"),infoBackground:b("#C9E6F0"),warningText:b("#F2C265"),warningBackground:b("#FCFFC1"),successText:b("#123524"),successBackground:b("#9EDF9C"),errorBackground:b("#FAD4D4"),errorText:b("#990000")}},A=D.createContext({}),je=({children:e,initialTheme:l=ee,secondTheme:n=oe})=>{const[a,m]=D.useState(l),d=()=>{m(x=>x===l?n:l)};return t.jsx(A.Provider,{value:{currentTheme:a,toggleTheme:d},children:t.jsx(s.ThemeProvider,{theme:a,children:e})})},we=()=>D.useContext(A);exports.DynamicForm=pe;exports.ThemeContext=A;exports.ThemeContextProvider=je;exports.breakpoints=Ce;exports.darkTheme=oe;exports.lightTheme=ee;exports.palette=i;exports.useTheme=we;
|