@conduction/components 2.0.7 → 2.0.9

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 (172) hide show
  1. package/.github/workflows/npm-publish.yml +39 -39
  2. package/.prettierrc +30 -30
  3. package/README.md +33 -25
  4. package/lib/components/badgeCounter/BadgeCounter.d.ts +8 -8
  5. package/lib/components/badgeCounter/BadgeCounter.js +4 -4
  6. package/lib/components/badgeCounter/BadgeCounter.module.css +27 -27
  7. package/lib/components/card/detailsCard/DetailsCard.d.ts +14 -14
  8. package/lib/components/card/detailsCard/DetailsCard.js +10 -10
  9. package/lib/components/card/detailsCard/DetailsCard.module.css +51 -51
  10. package/lib/components/card/downloadCard/DownloadCard.d.ts +11 -11
  11. package/lib/components/card/downloadCard/DownloadCard.js +8 -8
  12. package/lib/components/card/downloadCard/DownloadCard.module.css +27 -27
  13. package/lib/components/card/horizontalImageCard/HorizontalImageCard.d.ts +13 -13
  14. package/lib/components/card/horizontalImageCard/HorizontalImageCard.js +9 -9
  15. package/lib/components/card/horizontalImageCard/HorizontalImageCard.module.css +34 -34
  16. package/lib/components/card/imageAndDetailsCard/ImageAndDetailsCard.d.ts +14 -14
  17. package/lib/components/card/imageAndDetailsCard/ImageAndDetailsCard.js +9 -9
  18. package/lib/components/card/imageAndDetailsCard/ImageAndDetailsCard.module.css +63 -63
  19. package/lib/components/card/index.d.ts +7 -7
  20. package/lib/components/card/index.js +7 -7
  21. package/lib/components/card/infoCard/InfoCard.d.ts +8 -8
  22. package/lib/components/card/infoCard/InfoCard.js +6 -6
  23. package/lib/components/card/infoCard/InfoCard.module.css +26 -26
  24. package/lib/components/card/richContentCard/RichContentCard.d.ts +19 -19
  25. package/lib/components/card/richContentCard/RichContentCard.js +15 -15
  26. package/lib/components/card/richContentCard/RichContentCard.module.css +93 -93
  27. package/lib/components/codeBlock/CodeBlock.d.ts +6 -6
  28. package/lib/components/codeBlock/CodeBlock.js +3 -3
  29. package/lib/components/codeBlock/CodeBlock.module.css +6 -6
  30. package/lib/components/container/Container.d.ts +6 -6
  31. package/lib/components/container/Container.js +4 -4
  32. package/lib/components/container/Container.module.css +9 -9
  33. package/lib/components/denhaag-wrappers/breadcrumbs/Breadcrumbs.css +222 -222
  34. package/lib/components/denhaag-wrappers/breadcrumbs/Breadcrumbs.d.ts +17 -17
  35. package/lib/components/denhaag-wrappers/breadcrumbs/Breadcrumbs.js +20 -20
  36. package/lib/components/denhaag-wrappers/pagination/Pagination.css +120 -120
  37. package/lib/components/denhaag-wrappers/pagination/Pagination.d.ts +9 -9
  38. package/lib/components/denhaag-wrappers/pagination/Pagination.js +15 -15
  39. package/lib/components/editableTableRow/EditableTableRow.d.ts +14 -14
  40. package/lib/components/editableTableRow/EditableTableRow.js +31 -31
  41. package/lib/components/editableTableRow/EditableTableRow.module.css +25 -25
  42. package/lib/components/formFields/checkbox.d.ts +8 -7
  43. package/lib/components/formFields/checkbox.js +3 -3
  44. package/lib/components/formFields/createKeyValue/CreateKeyValue.d.ts +17 -0
  45. package/lib/components/formFields/createKeyValue/CreateKeyValue.js +31 -0
  46. package/lib/components/formFields/createKeyValue/CreateKeyValue.module.css +43 -0
  47. package/lib/components/formFields/index.d.ts +7 -6
  48. package/lib/components/formFields/index.js +7 -6
  49. package/lib/components/formFields/input.d.ts +19 -19
  50. package/lib/components/formFields/input.js +13 -13
  51. package/lib/components/formFields/radio.d.ts +9 -9
  52. package/lib/components/formFields/radio.js +3 -3
  53. package/lib/components/formFields/select/select.d.ts +18 -17
  54. package/lib/components/formFields/select/select.js +20 -14
  55. package/lib/components/formFields/select/select.module.css +35 -35
  56. package/lib/components/formFields/textarea.d.ts +8 -8
  57. package/lib/components/formFields/textarea.js +3 -3
  58. package/lib/components/formFields/types.d.ts +6 -6
  59. package/lib/components/formFields/types.js +1 -1
  60. package/lib/components/imageDivider/ImageDivider.d.ts +7 -7
  61. package/lib/components/imageDivider/ImageDivider.js +6 -6
  62. package/lib/components/imageDivider/imageDivider.module.css +5 -5
  63. package/lib/components/logo/Logo.d.ts +8 -8
  64. package/lib/components/logo/Logo.js +10 -10
  65. package/lib/components/logo/Logo.module.css +15 -15
  66. package/lib/components/metaIcon/MetaIcon.d.ts +7 -7
  67. package/lib/components/metaIcon/MetaIcon.js +3 -3
  68. package/lib/components/metaIcon/MetaIcon.module.css +29 -29
  69. package/lib/components/notificationPopUp/NotificationPopUp.d.ts +24 -24
  70. package/lib/components/notificationPopUp/NotificationPopUp.js +31 -31
  71. package/lib/components/notificationPopUp/NotificationPopUp.module.css +61 -61
  72. package/lib/components/privateRoute/PrivateRoute.d.ts +6 -6
  73. package/lib/components/privateRoute/PrivateRoute.js +15 -15
  74. package/lib/components/quoteWrapper/QuoteWrapper.d.ts +7 -7
  75. package/lib/components/quoteWrapper/QuoteWrapper.js +5 -5
  76. package/lib/components/quoteWrapper/QuoteWrapper.module.css +12 -12
  77. package/lib/components/statusSteps/StatusSteps.d.ts +13 -13
  78. package/lib/components/statusSteps/StatusSteps.js +5 -5
  79. package/lib/components/tag/Tag.d.ts +9 -9
  80. package/lib/components/tag/Tag.js +4 -4
  81. package/lib/components/tag/Tag.module.css +29 -29
  82. package/lib/components/toolTip/ToolTip.d.ts +9 -0
  83. package/lib/components/toolTip/ToolTip.js +7 -0
  84. package/lib/components/toolTip/ToolTip.module.css +4 -0
  85. package/lib/components/topNav/index.d.ts +3 -3
  86. package/lib/components/topNav/index.js +3 -3
  87. package/lib/components/topNav/primaryTopNav/PrimaryTopNav.d.ts +19 -17
  88. package/lib/components/topNav/primaryTopNav/PrimaryTopNav.js +7 -7
  89. package/lib/components/topNav/primaryTopNav/PrimaryTopNav.module.css +65 -60
  90. package/lib/components/topNav/secondaryTopNav/SecondaryTopNav.d.ts +12 -11
  91. package/lib/components/topNav/secondaryTopNav/SecondaryTopNav.js +7 -7
  92. package/lib/components/topNav/secondaryTopNav/SecondaryTopNav.module.css +48 -43
  93. package/lib/index.d.ts +27 -26
  94. package/lib/index.js +20 -19
  95. package/package.json +43 -42
  96. package/src/components/badgeCounter/BadgeCounter.module.css +27 -27
  97. package/src/components/badgeCounter/BadgeCounter.tsx +16 -16
  98. package/src/components/card/detailsCard/DetailsCard.module.css +51 -51
  99. package/src/components/card/detailsCard/DetailsCard.tsx +56 -56
  100. package/src/components/card/downloadCard/DownloadCard.js +10 -10
  101. package/src/components/card/downloadCard/DownloadCard.module.css +27 -27
  102. package/src/components/card/downloadCard/DownloadCard.tsx +40 -40
  103. package/src/components/card/horizontalImageCard/HorizontalImageCard.js +9 -9
  104. package/src/components/card/horizontalImageCard/HorizontalImageCard.module.css +34 -34
  105. package/src/components/card/horizontalImageCard/HorizontalImageCard.tsx +37 -37
  106. package/src/components/card/imageAndDetailsCard/ImageAndDetailsCard.js +9 -9
  107. package/src/components/card/imageAndDetailsCard/ImageAndDetailsCard.module.css +63 -63
  108. package/src/components/card/imageAndDetailsCard/ImageAndDetailsCard.tsx +49 -49
  109. package/src/components/card/index.js +5 -5
  110. package/src/components/card/index.tsx +8 -8
  111. package/src/components/card/infoCard/InfoCard.module.css +26 -26
  112. package/src/components/card/infoCard/InfoCard.tsx +19 -19
  113. package/src/components/card/richContentCard/RichContentCard.js +17 -17
  114. package/src/components/card/richContentCard/RichContentCard.module.css +93 -93
  115. package/src/components/card/richContentCard/RichContentCard.tsx +98 -98
  116. package/src/components/codeBlock/CodeBlock.module.css +6 -6
  117. package/src/components/codeBlock/CodeBlock.tsx +8 -8
  118. package/src/components/container/Container.js +3 -3
  119. package/src/components/container/Container.module.css +9 -9
  120. package/src/components/container/Container.tsx +11 -11
  121. package/src/components/denhaag-wrappers/breadcrumbs/Breadcrumbs.css +222 -222
  122. package/src/components/denhaag-wrappers/breadcrumbs/Breadcrumbs.js +20 -20
  123. package/src/components/denhaag-wrappers/breadcrumbs/Breadcrumbs.tsx +89 -89
  124. package/src/components/denhaag-wrappers/pagination/Pagination.css +120 -120
  125. package/src/components/denhaag-wrappers/pagination/Pagination.tsx +112 -112
  126. package/src/components/editableTableRow/EditableTableRow.js +34 -34
  127. package/src/components/editableTableRow/EditableTableRow.module.css +25 -25
  128. package/src/components/editableTableRow/EditableTableRow.tsx +138 -138
  129. package/src/components/formFields/checkbox.js +3 -3
  130. package/src/components/formFields/checkbox.tsx +21 -14
  131. package/src/components/formFields/createKeyValue/CreateKeyValue.module.css +43 -0
  132. package/src/components/formFields/createKeyValue/CreateKeyValue.tsx +125 -0
  133. package/src/components/formFields/index.js +4 -4
  134. package/src/components/formFields/index.tsx +21 -19
  135. package/src/components/formFields/input.js +12 -12
  136. package/src/components/formFields/input.tsx +123 -123
  137. package/src/components/formFields/radio.tsx +21 -21
  138. package/src/components/formFields/select/select.module.css +35 -35
  139. package/src/components/formFields/select/select.tsx +91 -63
  140. package/src/components/formFields/textarea.js +3 -3
  141. package/src/components/formFields/textarea.tsx +13 -13
  142. package/src/components/formFields/types.js +1 -1
  143. package/src/components/formFields/types.ts +7 -7
  144. package/src/components/imageDivider/ImageDivider.js +6 -6
  145. package/src/components/imageDivider/ImageDivider.tsx +12 -12
  146. package/src/components/imageDivider/imageDivider.module.css +5 -5
  147. package/src/components/logo/Logo.js +10 -10
  148. package/src/components/logo/Logo.module.css +15 -15
  149. package/src/components/logo/Logo.tsx +25 -25
  150. package/src/components/metaIcon/MetaIcon.js +3 -3
  151. package/src/components/metaIcon/MetaIcon.module.css +29 -29
  152. package/src/components/metaIcon/MetaIcon.tsx +18 -18
  153. package/src/components/notificationPopUp/NotificationPopUp.module.css +61 -61
  154. package/src/components/notificationPopUp/NotificationPopUp.tsx +87 -87
  155. package/src/components/privateRoute/PrivateRoute.js +15 -15
  156. package/src/components/privateRoute/PrivateRoute.tsx +22 -22
  157. package/src/components/quoteWrapper/QuoteWrapper.module.css +12 -12
  158. package/src/components/quoteWrapper/QuoteWrapper.tsx +15 -15
  159. package/src/components/statusSteps/StatusSteps.js +5 -5
  160. package/src/components/statusSteps/StatusSteps.tsx +54 -54
  161. package/src/components/tag/Tag.module.css +29 -29
  162. package/src/components/tag/Tag.tsx +17 -17
  163. package/src/components/toolTip/ToolTip.module.css +4 -0
  164. package/src/components/toolTip/ToolTip.tsx +24 -0
  165. package/src/components/topNav/index.ts +4 -4
  166. package/src/components/topNav/primaryTopNav/PrimaryTopNav.module.css +65 -60
  167. package/src/components/topNav/primaryTopNav/PrimaryTopNav.tsx +54 -52
  168. package/src/components/topNav/secondaryTopNav/SecondaryTopNav.module.css +48 -43
  169. package/src/components/topNav/secondaryTopNav/SecondaryTopNav.tsx +27 -27
  170. package/src/custom.d.ts +4 -4
  171. package/src/index.js +14 -14
  172. package/src/index.ts +79 -77
@@ -1,34 +1,34 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { TableCell, TableHeader, TableRow } from "@gemeente-denhaag/table";
3
- import * as styles from "./EditableTableRow.module.css";
4
- import * as React from "react";
5
- import { useTranslation } from "react-i18next";
6
- import { Link } from "@gemeente-denhaag/components-react";
7
- import { CheckedIcon, CloseIcon, EditIcon } from "@gemeente-denhaag/icons";
8
- import { useForm } from "react-hook-form";
9
- import { InputEmail, InputText } from "../formFields";
10
- export const EditableTableRow = ({ thead, value, inputType, handleSave, }) => {
11
- const [editing, setEditing] = React.useState(false);
12
- return (_jsxs(TableRow, { children: [_jsx(TableHeader, { className: styles.th, children: thead }), editing && _jsx(EditingTableRow, { ...{ value, inputType, handleSave, setEditing } }), !editing && _jsx(RegularTableRow, { ...{ value, setEditing } })] }));
13
- };
14
- const RegularTableRow = ({ value, setEditing }) => {
15
- const { t } = useTranslation();
16
- return (_jsxs(_Fragment, { children: [_jsx(TableCell, { children: value }), _jsx(TableCell, { children: _jsx("div", { className: styles.editButton, onClick: () => setEditing(true), children: _jsx(Link, { icon: _jsx(EditIcon, {}), iconAlign: "start", children: t("Edit") }) }) })] }));
17
- };
18
- const EditingTableRow = ({ value, setEditing, handleSave, inputType, }) => {
19
- const { t } = useTranslation();
20
- const { register, handleSubmit, formState: { errors }, } = useForm();
21
- const onSubmit = (data) => {
22
- handleSave(data.value);
23
- setEditing(false);
24
- };
25
- return (_jsxs(_Fragment, { children: [_jsx(TableCell, { children: _jsxs("form", { onSubmit: handleSubmit(onSubmit), children: [_jsx(FormField, { ...{ inputType, value, register, errors } }), _jsxs("div", { className: styles.editButtonsContainer, children: [_jsx("button", { type: "submit", className: styles.submit, children: _jsx(Link, { icon: _jsx(CheckedIcon, {}), iconAlign: "start", children: t("Save") }) }), _jsx("div", { onClick: () => setEditing(false), children: _jsx(Link, { icon: _jsx(CloseIcon, {}), iconAlign: "start", className: styles.cancel, children: t("Cancel") }) })] })] }) }), _jsx(TableCell, {})] }));
26
- };
27
- const FormField = ({ inputType, value, register, errors }) => {
28
- switch (inputType) {
29
- case "email":
30
- return _jsx(InputEmail, { defaultValue: value, ...{ register, errors }, name: "value", validation: { required: true } });
31
- case "text":
32
- return _jsx(InputText, { defaultValue: value, ...{ register, errors }, name: "value", validation: { required: true } });
33
- }
34
- };
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { TableCell, TableHeader, TableRow } from "@gemeente-denhaag/table";
3
+ import * as styles from "./EditableTableRow.module.css";
4
+ import * as React from "react";
5
+ import { useTranslation } from "react-i18next";
6
+ import { Link } from "@gemeente-denhaag/components-react";
7
+ import { CheckedIcon, CloseIcon, EditIcon } from "@gemeente-denhaag/icons";
8
+ import { useForm } from "react-hook-form";
9
+ import { InputEmail, InputText } from "../formFields";
10
+ export const EditableTableRow = ({ thead, value, inputType, handleSave, }) => {
11
+ const [editing, setEditing] = React.useState(false);
12
+ return (_jsxs(TableRow, { children: [_jsx(TableHeader, { className: styles.th, children: thead }), editing && _jsx(EditingTableRow, { ...{ value, inputType, handleSave, setEditing } }), !editing && _jsx(RegularTableRow, { ...{ value, setEditing } })] }));
13
+ };
14
+ const RegularTableRow = ({ value, setEditing }) => {
15
+ const { t } = useTranslation();
16
+ return (_jsxs(_Fragment, { children: [_jsx(TableCell, { children: value }), _jsx(TableCell, { children: _jsx("div", { className: styles.editButton, onClick: () => setEditing(true), children: _jsx(Link, { icon: _jsx(EditIcon, {}), iconAlign: "start", children: t("Edit") }) }) })] }));
17
+ };
18
+ const EditingTableRow = ({ value, setEditing, handleSave, inputType, }) => {
19
+ const { t } = useTranslation();
20
+ const { register, handleSubmit, formState: { errors }, } = useForm();
21
+ const onSubmit = (data) => {
22
+ handleSave(data.value);
23
+ setEditing(false);
24
+ };
25
+ return (_jsxs(_Fragment, { children: [_jsx(TableCell, { children: _jsxs("form", { onSubmit: handleSubmit(onSubmit), children: [_jsx(FormField, { ...{ inputType, value, register, errors } }), _jsxs("div", { className: styles.editButtonsContainer, children: [_jsx("button", { type: "submit", className: styles.submit, children: _jsx(Link, { icon: _jsx(CheckedIcon, {}), iconAlign: "start", children: t("Save") }) }), _jsx("div", { onClick: () => setEditing(false), children: _jsx(Link, { icon: _jsx(CloseIcon, {}), iconAlign: "start", className: styles.cancel, children: t("Cancel") }) })] })] }) }), _jsx(TableCell, {})] }));
26
+ };
27
+ const FormField = ({ inputType, value, register, errors }) => {
28
+ switch (inputType) {
29
+ case "email":
30
+ return _jsx(InputEmail, { defaultValue: value, ...{ register, errors }, name: "value", validation: { required: true } });
31
+ case "text":
32
+ return _jsx(InputText, { defaultValue: value, ...{ register, errors }, name: "value", validation: { required: true } });
33
+ }
34
+ };
@@ -1,25 +1,25 @@
1
- .th {
2
- width: 35%;
3
- }
4
-
5
- .cancel {
6
- color: var(--skeleton-color-grey-3) !important;
7
- }
8
-
9
- .editButtonsContainer {
10
- display: flex;
11
- margin-block-start: var(--skeleton-size-xs);
12
- }
13
-
14
- .editButtonsContainer > *:not(:last-child) {
15
- margin-inline-end: var(--skeleton-size-md);
16
- }
17
-
18
- .submit {
19
- all: unset;
20
- }
21
-
22
- .editButton {
23
- display: flex;
24
- justify-content: flex-end;
25
- }
1
+ .th {
2
+ width: 35%;
3
+ }
4
+
5
+ .cancel {
6
+ color: var(--skeleton-color-grey-3) !important;
7
+ }
8
+
9
+ .editButtonsContainer {
10
+ display: flex;
11
+ margin-block-start: var(--skeleton-size-xs);
12
+ }
13
+
14
+ .editButtonsContainer > *:not(:last-child) {
15
+ margin-inline-end: var(--skeleton-size-md);
16
+ }
17
+
18
+ .submit {
19
+ all: unset;
20
+ }
21
+
22
+ .editButton {
23
+ display: flex;
24
+ justify-content: flex-end;
25
+ }
@@ -1,138 +1,138 @@
1
- import { TableCell, TableHeader, TableRow } from "@gemeente-denhaag/table";
2
- import * as styles from "./EditableTableRow.module.css";
3
- import * as React from "react";
4
- import { Link } from "@gemeente-denhaag/components-react";
5
- import { CheckedIcon, CloseIcon, EditIcon } from "@gemeente-denhaag/icons";
6
- import { FieldValues, useForm, UseFormRegister } from "react-hook-form";
7
- import { InputEmail, InputText } from "../formFields";
8
-
9
- interface InputTypes {
10
- inputType: "text" | "email";
11
- }
12
-
13
- interface EditableTableRowProps {
14
- thead: string;
15
- value: string;
16
- saveLabel: string;
17
- cancelLabel: string;
18
- editLabel: string;
19
- handleSave: (value: any) => void;
20
- }
21
-
22
- export const EditableTableRow: React.FC<EditableTableRowProps & InputTypes> = ({
23
- thead,
24
- value,
25
- inputType,
26
- editLabel,
27
- cancelLabel,
28
- saveLabel,
29
- handleSave,
30
- }) => {
31
- const [editing, setEditing] = React.useState<boolean>(false);
32
-
33
- return (
34
- <TableRow>
35
- <TableHeader className={styles.th}>{thead}</TableHeader>
36
-
37
- {editing && <EditingTableRow {...{ value, inputType, handleSave, setEditing, saveLabel, cancelLabel }} />}
38
- {!editing && <RegularTableRow {...{ value, setEditing, editLabel }} />}
39
- </TableRow>
40
- );
41
- };
42
-
43
- /**
44
- * Specific rows based on editing (Regular: not editing & Editing: editing)
45
- */
46
-
47
- interface RegularTableRowProps {
48
- value: string;
49
- editLabel: string;
50
- setEditing: React.Dispatch<React.SetStateAction<boolean>>;
51
- }
52
-
53
- const RegularTableRow: React.FC<RegularTableRowProps> = ({ value, editLabel, setEditing }) => {
54
- return (
55
- <>
56
- <TableCell>{value}</TableCell>
57
-
58
- <TableCell>
59
- <div className={styles.editButton} onClick={() => setEditing(true)}>
60
- <Link icon={<EditIcon />} iconAlign="start">
61
- {editLabel}
62
- </Link>
63
- </div>
64
- </TableCell>
65
- </>
66
- );
67
- };
68
-
69
- interface EditingTableRowProps {
70
- value: string;
71
- setEditing: React.Dispatch<React.SetStateAction<boolean>>;
72
- saveLabel: string;
73
- cancelLabel: string;
74
- handleSave: (value: any) => void;
75
- }
76
-
77
- const EditingTableRow: React.FC<EditingTableRowProps & InputTypes> = ({
78
- value,
79
- setEditing,
80
- handleSave,
81
- inputType,
82
- saveLabel,
83
- cancelLabel,
84
- }) => {
85
- const {
86
- register,
87
- handleSubmit,
88
- formState: { errors },
89
- } = useForm();
90
-
91
- const onSubmit = (data: any): void => {
92
- handleSave(data.value);
93
- setEditing(false);
94
- };
95
-
96
- return (
97
- <>
98
- <TableCell>
99
- <form onSubmit={handleSubmit(onSubmit)}>
100
- <FormField {...{ inputType, value, register, errors }} />
101
-
102
- <div className={styles.editButtonsContainer}>
103
- <button type="submit" className={styles.submit}>
104
- <Link icon={<CheckedIcon />} iconAlign="start">
105
- {saveLabel}
106
- </Link>
107
- </button>
108
-
109
- <div onClick={() => setEditing(false)}>
110
- <Link icon={<CloseIcon />} iconAlign="start" className={styles.cancel}>
111
- {cancelLabel}
112
- </Link>
113
- </div>
114
- </div>
115
- </form>
116
- </TableCell>
117
-
118
- <TableCell />
119
- </>
120
- );
121
- };
122
-
123
- interface FormFieldProps {
124
- value: string;
125
- register: UseFormRegister<FieldValues>;
126
- errors: {
127
- [x: string]: any;
128
- };
129
- }
130
-
131
- const FormField: React.FC<FormFieldProps & InputTypes> = ({ inputType, value, register, errors }) => {
132
- switch (inputType) {
133
- case "email":
134
- return <InputEmail defaultValue={value} {...{ register, errors }} name="value" validation={{ required: true }} />;
135
- case "text":
136
- return <InputText defaultValue={value} {...{ register, errors }} name="value" validation={{ required: true }} />;
137
- }
138
- };
1
+ import { TableCell, TableHeader, TableRow } from "@gemeente-denhaag/table";
2
+ import * as styles from "./EditableTableRow.module.css";
3
+ import * as React from "react";
4
+ import { Link } from "@gemeente-denhaag/components-react";
5
+ import { CheckedIcon, CloseIcon, EditIcon } from "@gemeente-denhaag/icons";
6
+ import { FieldValues, useForm, UseFormRegister } from "react-hook-form";
7
+ import { InputEmail, InputText } from "../formFields";
8
+
9
+ interface InputTypes {
10
+ inputType: "text" | "email";
11
+ }
12
+
13
+ interface EditableTableRowProps {
14
+ thead: string;
15
+ value: string;
16
+ saveLabel: string;
17
+ cancelLabel: string;
18
+ editLabel: string;
19
+ handleSave: (value: any) => void;
20
+ }
21
+
22
+ export const EditableTableRow: React.FC<EditableTableRowProps & InputTypes> = ({
23
+ thead,
24
+ value,
25
+ inputType,
26
+ editLabel,
27
+ cancelLabel,
28
+ saveLabel,
29
+ handleSave,
30
+ }) => {
31
+ const [editing, setEditing] = React.useState<boolean>(false);
32
+
33
+ return (
34
+ <TableRow>
35
+ <TableHeader className={styles.th}>{thead}</TableHeader>
36
+
37
+ {editing && <EditingTableRow {...{ value, inputType, handleSave, setEditing, saveLabel, cancelLabel }} />}
38
+ {!editing && <RegularTableRow {...{ value, setEditing, editLabel }} />}
39
+ </TableRow>
40
+ );
41
+ };
42
+
43
+ /**
44
+ * Specific rows based on editing (Regular: not editing & Editing: editing)
45
+ */
46
+
47
+ interface RegularTableRowProps {
48
+ value: string;
49
+ editLabel: string;
50
+ setEditing: React.Dispatch<React.SetStateAction<boolean>>;
51
+ }
52
+
53
+ const RegularTableRow: React.FC<RegularTableRowProps> = ({ value, editLabel, setEditing }) => {
54
+ return (
55
+ <>
56
+ <TableCell>{value}</TableCell>
57
+
58
+ <TableCell>
59
+ <div className={styles.editButton} onClick={() => setEditing(true)}>
60
+ <Link icon={<EditIcon />} iconAlign="start">
61
+ {editLabel}
62
+ </Link>
63
+ </div>
64
+ </TableCell>
65
+ </>
66
+ );
67
+ };
68
+
69
+ interface EditingTableRowProps {
70
+ value: string;
71
+ setEditing: React.Dispatch<React.SetStateAction<boolean>>;
72
+ saveLabel: string;
73
+ cancelLabel: string;
74
+ handleSave: (value: any) => void;
75
+ }
76
+
77
+ const EditingTableRow: React.FC<EditingTableRowProps & InputTypes> = ({
78
+ value,
79
+ setEditing,
80
+ handleSave,
81
+ inputType,
82
+ saveLabel,
83
+ cancelLabel,
84
+ }) => {
85
+ const {
86
+ register,
87
+ handleSubmit,
88
+ formState: { errors },
89
+ } = useForm();
90
+
91
+ const onSubmit = (data: any): void => {
92
+ handleSave(data.value);
93
+ setEditing(false);
94
+ };
95
+
96
+ return (
97
+ <>
98
+ <TableCell>
99
+ <form onSubmit={handleSubmit(onSubmit)}>
100
+ <FormField {...{ inputType, value, register, errors }} />
101
+
102
+ <div className={styles.editButtonsContainer}>
103
+ <button type="submit" className={styles.submit}>
104
+ <Link icon={<CheckedIcon />} iconAlign="start">
105
+ {saveLabel}
106
+ </Link>
107
+ </button>
108
+
109
+ <div onClick={() => setEditing(false)}>
110
+ <Link icon={<CloseIcon />} iconAlign="start" className={styles.cancel}>
111
+ {cancelLabel}
112
+ </Link>
113
+ </div>
114
+ </div>
115
+ </form>
116
+ </TableCell>
117
+
118
+ <TableCell />
119
+ </>
120
+ );
121
+ };
122
+
123
+ interface FormFieldProps {
124
+ value: string;
125
+ register: UseFormRegister<FieldValues>;
126
+ errors: {
127
+ [x: string]: any;
128
+ };
129
+ }
130
+
131
+ const FormField: React.FC<FormFieldProps & InputTypes> = ({ inputType, value, register, errors }) => {
132
+ switch (inputType) {
133
+ case "email":
134
+ return <InputEmail defaultValue={value} {...{ register, errors }} name="value" validation={{ required: true }} />;
135
+ case "text":
136
+ return <InputText defaultValue={value} {...{ register, errors }} name="value" validation={{ required: true }} />;
137
+ }
138
+ };
@@ -1,3 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { FormControlLabel } from "@gemeente-denhaag/components-react";
3
- export const InputCheckbox = ({ name, validation, register, label, }) => _jsx(FormControlLabel, { input: _jsx("input", { type: "checkbox", ...register(name, { ...validation }) }), ...{ label } });
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FormControlLabel } from "@gemeente-denhaag/components-react";
3
+ export const InputCheckbox = ({ name, validation, register, label, }) => _jsx(FormControlLabel, { input: _jsx("input", { type: "checkbox", ...register(name, { ...validation }) }), ...{ label } });
@@ -1,14 +1,21 @@
1
- import { FormControlLabel } from "@gemeente-denhaag/components-react";
2
- import { IReactHookFormProps } from "./types";
3
-
4
- export interface ICheckboxProps {
5
- label: string;
6
- name: string;
7
- }
8
-
9
- export const InputCheckbox: React.FC<ICheckboxProps & IReactHookFormProps> = ({
10
- name,
11
- validation,
12
- register,
13
- label,
14
- }) => <FormControlLabel input={<input type="checkbox" {...register(name, { ...validation })} />} {...{ label }} />;
1
+ import { FormControlLabel } from "@gemeente-denhaag/components-react";
2
+ import { IReactHookFormProps } from "./types";
3
+
4
+ export interface ICheckboxProps {
5
+ label: string;
6
+ name: string;
7
+ defaultChecked?: boolean;
8
+ }
9
+
10
+ export const InputCheckbox: React.FC<ICheckboxProps & IReactHookFormProps> = ({
11
+ name,
12
+ validation,
13
+ register,
14
+ label,
15
+ defaultChecked,
16
+ }) => (
17
+ <FormControlLabel
18
+ input={<input type="checkbox" {...{ defaultChecked }} {...register(name, { ...validation })} />}
19
+ {...{ label }}
20
+ />
21
+ );
@@ -0,0 +1,43 @@
1
+ :root {
2
+ --conduction-create-key-value-table-row-border: 1px solid var(--skeleton-color-grey-1);
3
+ }
4
+
5
+ .keyValue {
6
+ width: 100%;
7
+ display: flex;
8
+ flex-direction: column;
9
+ }
10
+
11
+ .table {
12
+ border-collapse: collapse;
13
+ }
14
+
15
+ .table td,
16
+ .table th {
17
+ text-align: left;
18
+ padding-inline: 0;
19
+ padding-block: var(--skeleton-size-md);
20
+ }
21
+
22
+ .tdDelete {
23
+ display: flex;
24
+ justify-content: flex-end;
25
+ }
26
+
27
+ .form {
28
+ width: 100%;
29
+ display: flex;
30
+ }
31
+
32
+ .form > *:not(:last-child) {
33
+ margin-right: 10px;
34
+ }
35
+
36
+ .form > input {
37
+ flex: 5;
38
+ }
39
+
40
+ .form > button {
41
+ flex: 2;
42
+ max-width: fit-content;
43
+ }
@@ -0,0 +1,125 @@
1
+ import * as React from "react";
2
+ import * as styles from "./CreateKeyValue.module.css";
3
+ import { Control, Controller, FieldValues } from "react-hook-form";
4
+ import { IReactHookFormProps } from "../types";
5
+ import { IInputProps } from "../input";
6
+ import { Button } from "@gemeente-denhaag/components-react";
7
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@gemeente-denhaag/table";
8
+
9
+ /**
10
+ * Export KeyValue input component (wrapped in FormFieldGroup)
11
+ */
12
+ interface CreateKeyValueProps {
13
+ control: Control<FieldValues, any>;
14
+ defaultValue?: IKeyValue[];
15
+ }
16
+
17
+ interface IKeyValue {
18
+ key: string;
19
+ value: string;
20
+ }
21
+
22
+ export const CreateKeyValue: React.FC<CreateKeyValueProps & IInputProps & IReactHookFormProps> = ({
23
+ name,
24
+ errors,
25
+ control,
26
+ validation,
27
+ defaultValue,
28
+ }) => {
29
+ return (
30
+ <Controller
31
+ {...{ control, name, errors }}
32
+ rules={validation}
33
+ render={({ field: { onChange } }) => {
34
+ return <KeyValueComponent handleChange={onChange} {...{ defaultValue, errors }} />;
35
+ }}
36
+ />
37
+ );
38
+ };
39
+
40
+ /**
41
+ * Internal KeyValueComponent (contains all required logic)
42
+ */
43
+ interface CreateKeyValueComponentProps {
44
+ defaultValue?: IKeyValue[];
45
+ handleChange: (...event: any[]) => void;
46
+ }
47
+
48
+ const KeyValueComponent: React.FC<CreateKeyValueComponentProps> = ({ defaultValue, handleChange }) => {
49
+ const [currentKey, setCurrentKey] = React.useState<string>("");
50
+ const [currentValue, setCurrentValue] = React.useState<string>("");
51
+ const [keyValues, setKeyValues] = React.useState<IKeyValue[]>(defaultValue ?? []);
52
+
53
+ const currentKeyRef = React.useRef(null);
54
+ const currentValueRef = React.useRef(null);
55
+
56
+ const handleCreate = (): void => {
57
+ const keyValue: IKeyValue = { key: currentKey, value: currentValue };
58
+
59
+ setCurrentKey("");
60
+ setCurrentValue("");
61
+
62
+ setKeyValues([...keyValues, keyValue]);
63
+ };
64
+
65
+ React.useEffect(() => {
66
+ defaultValue && setKeyValues(defaultValue);
67
+ }, [defaultValue]);
68
+
69
+ React.useEffect(() => {
70
+ handleChange(keyValues);
71
+ }, [keyValues]);
72
+
73
+ return (
74
+ <div className={styles.keyValue}>
75
+ {keyValues && (
76
+ <Table className={styles.table}>
77
+ <TableHead>
78
+ <TableRow>
79
+ <TableHeader>Key</TableHeader>
80
+ <TableHeader>Value</TableHeader>
81
+ <TableHeader />
82
+ </TableRow>
83
+ </TableHead>
84
+ <TableBody>
85
+ {keyValues.map((keyValue, idx) => (
86
+ <TableRow className={styles.row} key={`${keyValue}${idx}`}>
87
+ <TableCell>{keyValue.key}</TableCell>
88
+ <TableCell>{keyValue.value}</TableCell>
89
+ <TableCell className={styles.tdDelete}>
90
+ <Button onClick={() => setKeyValues(keyValues.filter((_keyValue) => _keyValue !== keyValue))}>
91
+ Delete
92
+ </Button>
93
+ </TableCell>
94
+ </TableRow>
95
+ ))}
96
+ </TableBody>
97
+ </Table>
98
+ )}
99
+
100
+ <div className={styles.form}>
101
+ <input
102
+ type="text"
103
+ placeholder="Key"
104
+ value={currentKey}
105
+ ref={currentKeyRef}
106
+ className="denhaag-textfield__input"
107
+ onChange={(e) => setCurrentKey(e.target.value)}
108
+ />
109
+
110
+ <input
111
+ type="text"
112
+ placeholder="Value"
113
+ value={currentValue}
114
+ ref={currentValueRef}
115
+ className="denhaag-textfield__input"
116
+ onChange={(e) => setCurrentValue(e.target.value)}
117
+ />
118
+
119
+ <Button onClick={handleCreate} disabled={!currentKey || !currentValue}>
120
+ Add
121
+ </Button>
122
+ </div>
123
+ </div>
124
+ );
125
+ };
@@ -1,4 +1,4 @@
1
- import { InputText, InputPassword, InputEmail, InputDate, InputNumber } from "./input";
2
- import { Textarea } from "./textarea";
3
- import { InputCheckbox } from "./checkbox";
4
- export { InputText, InputPassword, InputEmail, InputDate, InputNumber, InputCheckbox, Textarea };
1
+ import { InputText, InputPassword, InputEmail, InputDate, InputNumber } from "./input";
2
+ import { Textarea } from "./textarea";
3
+ import { InputCheckbox } from "./checkbox";
4
+ export { InputText, InputPassword, InputEmail, InputDate, InputNumber, InputCheckbox, Textarea };
@@ -1,19 +1,21 @@
1
- import { InputText, InputPassword, InputEmail, InputDate, InputNumber, InputFile } from "./input";
2
- import { Textarea } from "./textarea";
3
- import { InputCheckbox } from "./checkbox";
4
- import { InputRadio } from "./radio";
5
- import { SelectSingle, SelectMultiple } from "./select/select";
6
-
7
- export {
8
- InputRadio,
9
- InputText,
10
- InputPassword,
11
- InputEmail,
12
- InputDate,
13
- InputNumber,
14
- InputCheckbox,
15
- InputFile,
16
- Textarea,
17
- SelectSingle,
18
- SelectMultiple,
19
- };
1
+ import { InputText, InputPassword, InputEmail, InputDate, InputNumber, InputFile } from "./input";
2
+ import { Textarea } from "./textarea";
3
+ import { InputCheckbox } from "./checkbox";
4
+ import { InputRadio } from "./radio";
5
+ import { SelectSingle, SelectMultiple } from "./select/select";
6
+ import { CreateKeyValue } from "./createKeyValue/CreateKeyValue";
7
+
8
+ export {
9
+ InputRadio,
10
+ InputText,
11
+ InputPassword,
12
+ InputEmail,
13
+ InputDate,
14
+ InputNumber,
15
+ InputCheckbox,
16
+ InputFile,
17
+ Textarea,
18
+ SelectSingle,
19
+ SelectMultiple,
20
+ CreateKeyValue,
21
+ };