@digigov/form 2.0.9 → 2.0.10

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 (32) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/FieldArray/BaseFieldArray.d.ts +3 -2
  3. package/FieldArray/BaseFieldArray.js +26 -4
  4. package/FieldArray/DeleteConfirmationModal.d.ts +8 -0
  5. package/FieldArray/DeleteConfirmationModal.js +29 -0
  6. package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js +3 -1
  7. package/FieldArray/FormDialog/ArrayDisplay/index.d.ts +2 -1
  8. package/FieldArray/FormDialog/ArrayDisplay/index.js +39 -6
  9. package/FieldArray/FormDialog/index.d.ts +1 -0
  10. package/FieldArray/FormDialog/index.js +3 -2
  11. package/FieldArray/index.js +2 -0
  12. package/index.js +1 -1
  13. package/lazy.d.ts +5 -35
  14. package/lazy.js +6 -3
  15. package/package.json +4 -4
  16. package/registry.d.ts +4 -3
  17. package/registry.js +8 -6
  18. package/src/FieldArray/BaseFieldArray.tsx +34 -3
  19. package/src/FieldArray/DeleteConfirmationModal.tsx +57 -0
  20. package/src/FieldArray/FieldArray.stories.js +1 -0
  21. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.js +1 -0
  22. package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.tsx +3 -1
  23. package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/WithDeleteConfirmation.tsx +94 -0
  24. package/src/FieldArray/FormDialog/ArrayDisplay/index.test.tsx +30 -26
  25. package/src/FieldArray/FormDialog/ArrayDisplay/index.tsx +70 -36
  26. package/src/FieldArray/FormDialog/index.tsx +3 -0
  27. package/src/FieldArray/__stories__/WithDeleteConfirmation.tsx +190 -0
  28. package/src/FieldArray/index.spec.tsx +42 -0
  29. package/src/FieldArray/index.test.tsx +27 -23
  30. package/src/FieldArray/index.tsx +2 -1
  31. package/src/lazy.ts +2 -1
  32. package/src/registry.ts +8 -6
@@ -0,0 +1,94 @@
1
+ import React, { useState } from 'react';
2
+ import { ArrayDisplay } from '@digigov/form/FieldArray/FormDialog/ArrayDisplay/';
3
+
4
+ const mockOfField = {
5
+ type: 'object',
6
+ label: { primary: 'Item' },
7
+ extra: {
8
+ fields: [
9
+ { key: 'afm', label: { primary: 'ΑΦΜ' } },
10
+ { key: 'firstName', label: { primary: 'Όνομα' } },
11
+ { key: 'lastName', label: { primary: 'Επώνυμο' } },
12
+ ],
13
+ },
14
+ };
15
+
16
+ const mockCustomField = {
17
+ editable: true,
18
+ extra: {
19
+ deleteConfirmation: true,
20
+ noHeader: false,
21
+ noEdit: false,
22
+ noDelete: false,
23
+ border: true,
24
+ verticalAlign: 'top',
25
+ wordBreak: 'break-all',
26
+ stackProps: {
27
+ spacing: 4,
28
+ alignItems: 'flex-end',
29
+ justifyContent: 'flex-end',
30
+ direction: 'column',
31
+ },
32
+ },
33
+ };
34
+
35
+ const initialValues = [
36
+ {
37
+ afm: '123456789',
38
+ firstName: 'Γιάννης',
39
+ lastName: 'Παπαδόπουλος',
40
+ },
41
+ {
42
+ afm: '987654321',
43
+ firstName: 'Μαρία',
44
+ lastName: 'Κωνσταντίνου',
45
+ },
46
+ {
47
+ afm: '456789123',
48
+ firstName: 'Δημήτρης',
49
+ lastName: 'Αθανασίου',
50
+ },
51
+ ];
52
+
53
+ export const WithDeleteConfirmation = () => {
54
+ const [fieldArrayValues, setFieldArrayValues] = useState(initialValues);
55
+
56
+ const handleEdit = (index: number) => {
57
+ const newFirstName = prompt(
58
+ '[TEST INTERFACE] Εισάγετε νέο όνομα:',
59
+ fieldArrayValues[index].firstName
60
+ );
61
+ if (newFirstName !== null) {
62
+ const newValues = [...fieldArrayValues];
63
+ newValues[index] = { ...newValues[index], firstName: newFirstName };
64
+ setFieldArrayValues(newValues);
65
+ }
66
+ };
67
+
68
+ const handleRemove = (index: number) => {
69
+ if (confirm('Είστε βέβαιοι ότι θέλετε να διαγράψετε αυτό το στοιχείο;')) {
70
+ const newValues = fieldArrayValues.filter((_, i) => i !== index);
71
+ setFieldArrayValues(newValues);
72
+ }
73
+ };
74
+
75
+ const handleMove = (fromIndex: number, toIndex: number) => {
76
+ const newValues = [...fieldArrayValues];
77
+ const [movedItem] = newValues.splice(fromIndex, 1);
78
+ newValues.splice(toIndex, 0, movedItem);
79
+ setFieldArrayValues(newValues);
80
+ };
81
+
82
+ return (
83
+ <ArrayDisplay
84
+ fieldArrayName="signatories"
85
+ fieldArrayValues={fieldArrayValues}
86
+ ofField={mockOfField}
87
+ customField={mockCustomField}
88
+ onEdit={handleEdit}
89
+ onRemove={handleRemove}
90
+ move={handleMove}
91
+ sortable={false}
92
+ />
93
+ );
94
+ };
@@ -1,44 +1,48 @@
1
1
  import React from 'react';
2
2
  import { test, expect } from '@playwright/experimental-ct-react';
3
- import TestVariant from '@digigov/ui/utils/TestVariant'
3
+ import TestVariant from '@digigov/ui/utils/TestVariant';
4
4
  import { Cards } from '@digigov/form/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards';
5
5
  import { Default } from '@digigov/form/FieldArray/FormDialog/ArrayDisplay/__stories__/Default';
6
6
  import { ReadOnly } from '@digigov/form/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly';
7
7
  import { ReadOnlyCards } from '@digigov/form/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards';
8
8
  import { Sortable } from '@digigov/form/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable';
9
9
  import { SortableCards } from '@digigov/form/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards';
10
+ import { WithDeleteConfirmation } from '@digigov/form/FieldArray/FormDialog/ArrayDisplay/__stories__/WithDeleteConfirmation';
10
11
 
11
12
  test('renders the All ArrayDisplay variants', async ({ mount, page }) => {
12
13
  await mount(
13
-
14
- <div>
15
- <TestVariant title="Cards">
16
- <Cards />
17
- </TestVariant>
18
- <TestVariant title="Default">
19
- <Default />
20
- </TestVariant>
21
- <TestVariant title="ReadOnly">
22
- <ReadOnly />
23
- </TestVariant>
24
- <TestVariant title="ReadOnlyCards">
25
- <ReadOnlyCards />
26
- </TestVariant>
27
- <TestVariant title="Sortable">
28
- <Sortable />
29
- </TestVariant>
30
- <TestVariant title="SortableCards">
31
- <SortableCards />
32
- </TestVariant>
33
- </div>
34
- )
14
+ <div>
15
+ <TestVariant title="Cards">
16
+ <Cards />
17
+ </TestVariant>
18
+ <TestVariant title="Default">
19
+ <Default />
20
+ </TestVariant>
21
+ <TestVariant title="ReadOnly">
22
+ <ReadOnly />
23
+ </TestVariant>
24
+ <TestVariant title="ReadOnlyCards">
25
+ <ReadOnlyCards />
26
+ </TestVariant>
27
+ <TestVariant title="Sortable">
28
+ <Sortable />
29
+ </TestVariant>
30
+ <TestVariant title="SortableCards">
31
+ <SortableCards />
32
+ </TestVariant>
33
+ <TestVariant title="WithDeleteConfirmation">
34
+ <WithDeleteConfirmation />
35
+ </TestVariant>
36
+ </div>
37
+ );
35
38
  await page.evaluate(() => document.fonts.ready);
36
39
 
37
40
  // Move the mouse to the top-left corner to avoid random hover issues
38
41
  await page.mouse.move(0, 0);
39
42
 
40
-
41
- const screenshot = await page.screenshot({ fullPage: true, animations: 'disabled' });
43
+ const screenshot = await page.screenshot({
44
+ fullPage: true,
45
+ animations: 'disabled',
46
+ });
42
47
  expect(screenshot).toMatchSnapshot();
43
48
  });
44
-
@@ -1,7 +1,10 @@
1
- import React from 'react';
1
+ import React, { useState, useId } from 'react';
2
2
  import type { UseFieldArrayMove } from 'react-hook-form';
3
+ import DeleteConfirmationModal from '@digigov/form/FieldArray/DeleteConfirmationModal';
3
4
  import { ArrayContainerDisplay } from '@digigov/form/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay';
4
5
  import { ArrayItemDisplay } from '@digigov/form/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay';
6
+ import { omit } from '@digigov/form/utils';
7
+ import { useModal } from '@digigov/ui';
5
8
  export interface ArrayDisplayProps {
6
9
  fieldArrayName: string;
7
10
  fieldArrayValues: any[];
@@ -11,6 +14,7 @@ export interface ArrayDisplayProps {
11
14
  onRemove: (index: number) => void;
12
15
  move: UseFieldArrayMove;
13
16
  sortable: boolean;
17
+ deleteConfirmation?: boolean;
14
18
  error?: any;
15
19
  }
16
20
 
@@ -23,44 +27,74 @@ export const ArrayDisplay = ({
23
27
  onRemove,
24
28
  move,
25
29
  sortable,
30
+ deleteConfirmation,
26
31
  error,
27
32
  }: ArrayDisplayProps) => {
33
+ const confirmationModalId = useId();
34
+ const [removeCurrentModal, setRemoveCurrentModal] = useState<number>(-1);
35
+ const { registerModal, open, ...modalProps } = useModal();
36
+
37
+ const handleRemoveClick = React.useCallback(
38
+ (index: number) => {
39
+ const needsConfirmation =
40
+ deleteConfirmation || customField.extra?.deleteConfirmation;
41
+ if (needsConfirmation) {
42
+ setRemoveCurrentModal(index);
43
+ open(confirmationModalId);
44
+ } else {
45
+ onRemove(index);
46
+ }
47
+ },
48
+ [deleteConfirmation, customField.extra, open, onRemove, confirmationModalId]
49
+ );
28
50
  return (
29
- <ArrayContainerDisplay
30
- fieldArrayValues={fieldArrayValues}
31
- ofField={ofField}
32
- customField={customField}
33
- >
34
- {fieldArrayValues?.map?.((field, index) => {
35
- return (
36
- <ArrayItemDisplay
37
- error={error && error[index] ? error[index] : undefined}
38
- key={index}
39
- name={`${fieldArrayName}.${index}`}
40
- index={index}
41
- isFirst={index === 0}
42
- isLast={index === fieldArrayValues.length - 1}
43
- data={field}
44
- edit={() => onEdit(index)}
45
- stackProps={customField?.extra?.stackProps}
46
- wordBreak={customField?.extra?.wordBreak}
47
- valueDisplay={customField?.extra?.valueDisplay}
48
- remove={() => onRemove(index)}
49
- border={customField.extra?.border}
50
- move={move}
51
- sortable={sortable}
52
- disabledEdit={
53
- sortable ? true : (customField.extra?.noEdit ?? false)
54
- }
55
- disabledDelete={customField.extra?.noDelete ?? false}
56
- disabled={customField?.editable === false}
57
- fieldArrayValues={fieldArrayValues}
58
- ofField={ofField}
59
- customField={customField}
60
- />
61
- );
62
- })}
63
- </ArrayContainerDisplay>
51
+ <>
52
+ <ArrayContainerDisplay
53
+ fieldArrayValues={fieldArrayValues}
54
+ ofField={ofField}
55
+ customField={customField}
56
+ >
57
+ {fieldArrayValues?.map?.((field, index) => {
58
+ return (
59
+ <ArrayItemDisplay
60
+ error={error && error[index] ? error[index] : undefined}
61
+ key={index}
62
+ name={`${fieldArrayName}.${index}`}
63
+ index={index}
64
+ isFirst={index === 0}
65
+ isLast={index === fieldArrayValues.length - 1}
66
+ data={field}
67
+ edit={() => onEdit(index)}
68
+ stackProps={customField?.extra?.stackProps}
69
+ wordBreak={customField?.extra?.wordBreak}
70
+ valueDisplay={customField?.extra?.valueDisplay}
71
+ remove={() => handleRemoveClick(index)}
72
+ border={customField.extra?.border}
73
+ move={move}
74
+ sortable={sortable}
75
+ disabledEdit={
76
+ sortable ? true : (customField.extra?.noEdit ?? false)
77
+ }
78
+ disabledDelete={customField.extra?.noDelete ?? false}
79
+ disabled={customField?.editable === false}
80
+ fieldArrayValues={fieldArrayValues}
81
+ ofField={ofField}
82
+ customField={customField}
83
+ />
84
+ );
85
+ })}
86
+ </ArrayContainerDisplay>
87
+ <DeleteConfirmationModal
88
+ {...omit(modalProps, ['registerAction', 'currentOpen'])}
89
+ {...registerModal(confirmationModalId)}
90
+ remove={() => {
91
+ if (removeCurrentModal !== -1) {
92
+ onRemove(removeCurrentModal);
93
+ setRemoveCurrentModal(-1);
94
+ }
95
+ }}
96
+ />
97
+ </>
64
98
  );
65
99
  };
66
100
 
@@ -28,6 +28,7 @@ export interface FormDialogProps extends FieldProps {
28
28
  resetField?: UseFormReturn['resetField'];
29
29
  sortable: boolean;
30
30
  Field: React.FC<FieldProps>;
31
+ deleteConfirmation?: boolean;
31
32
  }
32
33
 
33
34
  export const FormDialog = React.forwardRef<HTMLButtonElement, FormDialogProps>(
@@ -39,6 +40,7 @@ export const FormDialog = React.forwardRef<HTMLButtonElement, FormDialogProps>(
39
40
  getValues,
40
41
  Field,
41
42
  sortable,
43
+ deleteConfirmation = false,
42
44
  ...customField
43
45
  },
44
46
  ref
@@ -264,6 +266,7 @@ export const FormDialog = React.forwardRef<HTMLButtonElement, FormDialogProps>(
264
266
  move={handleMove}
265
267
  sortable={sortable}
266
268
  error={error}
269
+ deleteConfirmation={deleteConfirmation}
267
270
  />
268
271
  )}
269
272
  {customField.extra?.editVariant !== 'display' && // add noAdd: necessary for dilosi's 'fixed' fieldsets
@@ -0,0 +1,190 @@
1
+ import React from 'react';
2
+ import FormBuilder, { Field, FieldSpec } from '@digigov/form';
3
+ import { Button } from '@digigov/ui/form/Button';
4
+
5
+ const fields = [
6
+ {
7
+ key: 'string',
8
+ type: 'string',
9
+ label: {
10
+ primary: 'Πεδίο κειμένου',
11
+ secondary:
12
+ 'Το multiplicity field είναι ένα πεδίο οπότε φαίνεται και είναι μέρος της φόρμας',
13
+ },
14
+ },
15
+ {
16
+ key: 'multiplicity',
17
+ editable: true,
18
+ required: true,
19
+ type: 'array',
20
+ label: {
21
+ primary: 'Συνυπογράφοντες',
22
+ secondary: 'Οι συνυπογράφοντες είναι άνθρωποι σαν και εμάς',
23
+ },
24
+ extra: {
25
+ noIndex: true,
26
+ border: false,
27
+ deleteConfirmation: true,
28
+ variant: 'dialog',
29
+ noHeader: false,
30
+ label: {
31
+ object: {
32
+ title: 'Συνυπογράφοντας',
33
+ title_added: 'Οι συνυπογράφοντες που έχετε προσθέσει',
34
+ add: 'Προσθήκη',
35
+ delete: 'Αφαίρεση συνυπογράφοντος',
36
+ append: {
37
+ label: 'Αποθήκευση',
38
+ props: {
39
+ color: 'primary',
40
+ },
41
+ },
42
+ edit: {
43
+ label: 'Αποθήκευση',
44
+ props: {
45
+ color: 'primary',
46
+ },
47
+ },
48
+ cancel: {
49
+ label: 'Ακύρωση',
50
+ props: {
51
+ variant: 'link',
52
+ },
53
+ },
54
+ },
55
+ question: {
56
+ title: 'Θέλετε να προσθέσετε επιπλέον συνυπογράφοντες;',
57
+ objectLabel: {
58
+ primary: 'Προσθήκη νέου συνυπογράφοντα',
59
+ secondary: 'Συμπληρώστε τα στοιχεία και μετά πατήστε «Προσθήκη»',
60
+ },
61
+ yes: 'Ναι',
62
+ no: 'Όχι',
63
+ },
64
+ },
65
+ min: 2,
66
+ // max: 4,
67
+ of: {
68
+ type: 'object',
69
+ extra: {
70
+ fields: [
71
+ {
72
+ key: 'lastName',
73
+ required: true,
74
+ type: 'string',
75
+ label: {
76
+ primary: 'Όνομα',
77
+ },
78
+ },
79
+ {
80
+ key: 'gender',
81
+ required: true,
82
+ type: 'choice:single',
83
+ label: {
84
+ primary: 'Φύλο',
85
+ },
86
+ extra: {
87
+ options: [
88
+ {
89
+ label: {
90
+ primary: 'Άνδρας',
91
+ secondary: 'Choice 1 explanation',
92
+ },
93
+ value: 'male',
94
+ },
95
+ {
96
+ label: {
97
+ primary: 'Γυναίκα',
98
+ secondary: 'Choice 2 explanation',
99
+ },
100
+ value: 'female',
101
+ },
102
+ {
103
+ label: {
104
+ primary: 'Άλλο',
105
+ secondary: 'Choice 3 explanation',
106
+ },
107
+ value: 'other',
108
+ },
109
+ ],
110
+ },
111
+ },
112
+ ],
113
+ },
114
+ },
115
+ },
116
+ },
117
+ {
118
+ key: 'arrayofafm',
119
+ editable: true,
120
+ type: 'array',
121
+ label: {
122
+ primary: 'Συνυπογράφοντες',
123
+ secondary: 'Οι συνυπογράφοντες είναι άνθρωποι σαν και εμάς',
124
+ },
125
+ extra: {
126
+ variant: 'dialog',
127
+ deleteConfirmation: true,
128
+ noHeader: false,
129
+ label: {
130
+ object: {
131
+ title: 'Συνυπογράφοντας',
132
+ title_added: 'Οι συνυπογράφοντες που έχετε προσθέσει',
133
+ add: 'Προσθήκη',
134
+ delete: 'Αφαίρεση συνυπογράφοντος',
135
+ append: {
136
+ label: 'Αποθήκευση',
137
+ props: {
138
+ color: 'primary',
139
+ },
140
+ },
141
+ edit: {
142
+ label: 'Αποθήκευση',
143
+ props: {
144
+ color: 'primary',
145
+ },
146
+ },
147
+ cancel: {
148
+ label: 'Ακύρωση',
149
+ props: {
150
+ variant: 'link',
151
+ },
152
+ },
153
+ },
154
+ question: {
155
+ title: 'Θέλετε να προσθέσετε επιπλέον συνυπογράφοντες;',
156
+ objectLabel: {
157
+ primary: 'Προσθήκη νέου συνυπογράφοντα',
158
+ secondary: 'Συμπληρώστε τα στοιχεία και μετά πατήστε «Προσθήκη»',
159
+ },
160
+ yes: 'Ναι',
161
+ no: 'Όχι',
162
+ },
163
+ },
164
+ // min: 2,
165
+ // max: 4,
166
+ of: {
167
+ required: true,
168
+ type: 'afm',
169
+ label: {
170
+ primary: 'ΑΦΜ',
171
+ },
172
+ },
173
+ },
174
+ },
175
+ ] as FieldSpec[];
176
+
177
+ export const WithDeleteConfirmation = (_: any) => (
178
+ <FormBuilder
179
+ onSubmit={(data) => {
180
+ console.log(data);
181
+ window.alert('Submit success');
182
+ }}
183
+ initial={{
184
+ multiplicity: [['Παπαδόπουλος', 'other']],
185
+ }}
186
+ >
187
+ <Field name="multiplicity" {...fields[1]} />
188
+ <Button>Συνέχεια</Button>
189
+ </FormBuilder>
190
+ );
@@ -351,5 +351,47 @@ describe('FieldArray', () => {
351
351
 
352
352
  expect(screen.getByText('Προσθήκη συνυπογράφοντα')).toHaveFocus();
353
353
  });
354
+
355
+ it('should show delete confirmation modal and delete item on confirm', async () => {
356
+ render(
357
+ <TestForm
358
+ fieldObject={{
359
+ ...fieldSpec,
360
+ extra: {
361
+ ...fieldSpec.extra,
362
+ deleteConfirmation: true,
363
+ },
364
+ }}
365
+ />
366
+ );
367
+
368
+ const addButton = await screen.findByText('Προσθήκη συνυπογράφοντα');
369
+ expect(addButton).toBeInTheDocument();
370
+ fireEvent.click(addButton);
371
+
372
+ const nameInput = screen.getByLabelText('Όνομα');
373
+ fireEvent.change(nameInput, {
374
+ target: { value: 'John' },
375
+ });
376
+ fireEvent.click(screen.getByText('Αποθήκευση'));
377
+
378
+ await waitFor(() =>
379
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
380
+ );
381
+ await waitFor(() => expect(screen.getByText('John')).toBeInTheDocument());
382
+
383
+ fireEvent.click(screen.getByText('Διαγραφή'));
384
+
385
+ await waitFor(() =>
386
+ expect(screen.getByRole('dialog')).toBeInTheDocument()
387
+ );
388
+ expect(screen.getByText('Επιβεβαίωση διαγραφής')).toBeInTheDocument();
389
+ fireEvent.click(screen.getAllByText('Διαγραφή')[1]);
390
+ await waitFor(() =>
391
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
392
+ );
393
+
394
+ expect(screen.queryByText('John')).not.toBeInTheDocument();
395
+ });
354
396
  });
355
397
  });
@@ -1,40 +1,44 @@
1
1
  import React from 'react';
2
2
  import { test, expect } from '@playwright/experimental-ct-react';
3
- import TestVariant from '@digigov/ui/utils/TestVariant'
3
+ import TestVariant from '@digigov/ui/utils/TestVariant';
4
4
  import { CardsWithError } from '@digigov/form/FieldArray/__stories__/CardsWithError';
5
5
  import { Default } from '@digigov/form/FieldArray/__stories__/Default';
6
6
  import { TableWithError } from '@digigov/form/FieldArray/__stories__/TableWithError';
7
7
  import { WithExactLength } from '@digigov/form/FieldArray/__stories__/WithExactLength';
8
8
  import { WithModal } from '@digigov/form/FieldArray/__stories__/WithModal';
9
+ import { WithDeleteConfirmation } from '@digigov/form/FieldArray/__stories__/WithDeleteConfirmation';
9
10
 
10
11
  test('renders the All FieldArray variants', async ({ mount, page }) => {
11
12
  await mount(
12
-
13
- <div>
14
- <TestVariant title="CardsWithError">
15
- <CardsWithError />
16
- </TestVariant>
17
- <TestVariant title="Default">
18
- <Default />
19
- </TestVariant>
20
- <TestVariant title="TableWithError">
21
- <TableWithError />
22
- </TestVariant>
23
- <TestVariant title="WithExactLength">
24
- <WithExactLength />
25
- </TestVariant>
26
- <TestVariant title="WithModal">
27
- <WithModal />
28
- </TestVariant>
29
- </div>
30
- )
13
+ <div>
14
+ <TestVariant title="CardsWithError">
15
+ <CardsWithError />
16
+ </TestVariant>
17
+ <TestVariant title="Default">
18
+ <Default />
19
+ </TestVariant>
20
+ <TestVariant title="TableWithError">
21
+ <TableWithError />
22
+ </TestVariant>
23
+ <TestVariant title="WithExactLength">
24
+ <WithExactLength />
25
+ </TestVariant>
26
+ <TestVariant title="WithModal">
27
+ <WithModal />
28
+ </TestVariant>
29
+ <TestVariant title="WithDeleteConfirmation">
30
+ <WithDeleteConfirmation />
31
+ </TestVariant>
32
+ </div>
33
+ );
31
34
  await page.evaluate(() => document.fonts.ready);
32
35
 
33
36
  // Move the mouse to the top-left corner to avoid random hover issues
34
37
  await page.mouse.move(0, 0);
35
38
 
36
-
37
- const screenshot = await page.screenshot({ fullPage: true, animations: 'disabled' });
39
+ const screenshot = await page.screenshot({
40
+ fullPage: true,
41
+ animations: 'disabled',
42
+ });
38
43
  expect(screenshot).toMatchSnapshot();
39
44
  });
40
-
@@ -40,7 +40,6 @@ export const FieldArray: React.FC<FieldArrayProps> = ({
40
40
  }) => {
41
41
  /** The ref of the add-button */
42
42
  const buttonRef = useRef<HTMLButtonElement | null>(null);
43
-
44
43
  // Register the button to be focusable
45
44
  useEffect(() => {
46
45
  let unregister: (name: string) => void = () => {};
@@ -90,6 +89,7 @@ export const FieldArray: React.FC<FieldArrayProps> = ({
90
89
  reset={reset}
91
90
  resetField={resetField}
92
91
  sortable={customField.extra.sortable}
92
+ deleteConfirmation={customField.extra?.deleteConfirmation}
93
93
  {...customField}
94
94
  />
95
95
  ) : (
@@ -102,6 +102,7 @@ export const FieldArray: React.FC<FieldArrayProps> = ({
102
102
  error={error}
103
103
  getValues={getValues}
104
104
  Field={Field}
105
+ deleteConfirmation={customField.extra?.deleteConfirmation}
105
106
  {...customField}
106
107
  />
107
108
  )}
package/src/lazy.ts CHANGED
@@ -9,9 +9,10 @@ export default {
9
9
  'FieldBase': lazy(() => import('@digigov/form/Field/FieldBase').then((module) => ({ default: module['FieldBase'] }))),
10
10
  'FieldBaseContainer': lazy(() => import('@digigov/form/Field/FieldBaseContainer').then((module) => ({ default: module['FieldBaseContainer'] }))),
11
11
  'FieldConditional': lazy(() => import('@digigov/form/Field/FieldConditional').then((module) => ({ default: module['FieldConditional'] }))),
12
+ 'FieldObject': lazy(() => import('@digigov/form/FieldObject').then((module) => ({ default: module['FieldObject'] }))),
12
13
  'BaseFieldArray': lazy(() => import('@digigov/form/FieldArray/BaseFieldArray').then((module) => ({ default: module['BaseFieldArray'] }))),
14
+ 'DeleteConfirmationModal': lazy(() => import('@digigov/form/FieldArray/DeleteConfirmationModal').then((module) => ({ default: module['DeleteConfirmationModal'] }))),
13
15
  'FieldArray': lazy(() => import('@digigov/form/FieldArray').then((module) => ({ default: module['FieldArray'] }))),
14
- 'FieldObject': lazy(() => import('@digigov/form/FieldObject').then((module) => ({ default: module['FieldObject'] }))),
15
16
  'FieldsetWithContext': lazy(() => import('@digigov/form/Fieldset/FieldsetWithContext').then((module) => ({ default: module['FieldsetWithContext'] }))),
16
17
  'FieldsetLabel': lazy(() => import('@digigov/form/Fieldset').then((module) => ({ default: module['FieldsetLabel'] }))),
17
18
  'FieldsetCaption': lazy(() => import('@digigov/form/Fieldset').then((module) => ({ default: module['FieldsetCaption'] }))),