@inseefr/lunatic 3.7.3 → 3.7.5-rc.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 (52) hide show
  1. package/components/Loop/Loop.d.ts +1 -0
  2. package/components/Loop/Loop.js +2 -2
  3. package/components/Loop/Loop.js.map +1 -1
  4. package/components/RosterForLoop/RosterForLoop.js +3 -1
  5. package/components/RosterForLoop/RosterForLoop.js.map +1 -1
  6. package/components/RosterForLoop/RosterForLoop.spec.js +12 -0
  7. package/components/RosterForLoop/RosterForLoop.spec.js.map +1 -1
  8. package/components/shared/Missing/Missing.js +3 -3
  9. package/components/shared/Missing/Missing.js.map +1 -1
  10. package/esm/components/Loop/Loop.d.ts +1 -0
  11. package/esm/components/Loop/Loop.js +2 -2
  12. package/esm/components/Loop/Loop.js.map +1 -1
  13. package/esm/components/RosterForLoop/RosterForLoop.js +3 -1
  14. package/esm/components/RosterForLoop/RosterForLoop.js.map +1 -1
  15. package/esm/components/RosterForLoop/RosterForLoop.spec.js +12 -0
  16. package/esm/components/RosterForLoop/RosterForLoop.spec.js.map +1 -1
  17. package/esm/components/shared/Missing/Missing.js +3 -3
  18. package/esm/components/shared/Missing/Missing.js.map +1 -1
  19. package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +3 -0
  20. package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
  21. package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +16 -0
  22. package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
  23. package/esm/use-lunatic/lunatic-context.d.ts +25 -23
  24. package/esm/use-lunatic/lunatic-context.js +11 -4
  25. package/esm/use-lunatic/lunatic-context.js.map +1 -1
  26. package/esm/use-lunatic/type.d.ts +56 -11
  27. package/esm/use-lunatic/use-lunatic.js +5 -1
  28. package/esm/use-lunatic/use-lunatic.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/components/Loop/Loop.tsx +6 -1
  31. package/src/components/RosterForLoop/RosterForLoop.spec.tsx +28 -0
  32. package/src/components/RosterForLoop/RosterForLoop.tsx +3 -0
  33. package/src/components/RosterForLoop/__snapshots__/RosterForLoop.spec.tsx.snap +114 -0
  34. package/src/components/shared/Missing/Missing.tsx +3 -3
  35. package/src/stories/utils/Orchestrator.tsx +8 -1
  36. package/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.ts +2 -0
  37. package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +21 -0
  38. package/src/use-lunatic/lunatic-context.tsx +26 -14
  39. package/src/use-lunatic/type.ts +59 -12
  40. package/src/use-lunatic/use-lunatic.test.ts +4 -1
  41. package/src/use-lunatic/use-lunatic.ts +5 -1
  42. package/tsconfig.build.tsbuildinfo +1 -1
  43. package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +3 -0
  44. package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
  45. package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +16 -0
  46. package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
  47. package/use-lunatic/lunatic-context.d.ts +25 -23
  48. package/use-lunatic/lunatic-context.js +16 -9
  49. package/use-lunatic/lunatic-context.js.map +1 -1
  50. package/use-lunatic/type.d.ts +56 -11
  51. package/use-lunatic/use-lunatic.js +5 -1
  52. package/use-lunatic/use-lunatic.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"lunatic-context.js","sourceRoot":"","sources":["../../src/use-lunatic/lunatic-context.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGN,aAAa,EACb,UAAU,GACV,MAAM,OAAO,CAAC;AAEf,OAAO,CAAC,MAAM,eAAe,CAAC;AAE9B,MAAM,cAAc,GAAG,aAAa,CAAC;IACpC,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;IACzB,UAAU,EAAE,KAAK;IACjB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,KAAK;IACf,eAA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AG,EAAE;IACxC,OAAO,UAAU,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,UAAU,qBAAqB,CAAC,EACrC,UAAU,EACV,OAAO,EACP,eAAe,EACf,QAAQ,EACR,eAAe,EACf,cAAc,EACd,aAAa,EACb,iBAAiB,GACG;IACpB,MAAM,KAAK,GAAG;QACb,UAAU;QACV,OAAO;QACP,eAAe;QACf,QAAQ;QACR,eAAe;QACf,cAAc;QACd,aAAa;QACb,iBAAiB;KACjB,CAAC;IACF,OAAO,SAAS,QAAQ,CAAC,EAAE,QAAQ,EAAqB;QACvD,OAAO,CACN,KAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACnC,QAAQ,GACgB,CAC1B,CAAC;IACH,CAAC,CAAC;AACH,CAAC"}
@@ -151,14 +151,23 @@ export type LunaticReducerState = {
151
151
  };
152
152
  /** Specific behaviour options defined in the {@link useLunatic} hook. */
153
153
  export type LunaticOptions = {
154
- /** Ignore filters. (default: `false`) */
154
+ /**
155
+ * Ignore filters.
156
+ * @default false
157
+ */
155
158
  disableFilters?: boolean;
156
- /** Disable filters description. (default: `true`) */
159
+ /**
160
+ * Disable filters description.
161
+ * @default true
162
+ */
157
163
  disableFiltersDescription?: boolean;
158
164
  /** Enable VTL and Markdown support. */
159
165
  features?: ('MD' | 'VTL')[];
160
166
  preferences?: ['COLLECTED'];
161
- /** Key in which the data is saved. (default: `"COLLECTED"`) */
167
+ /**
168
+ * Key in which the data is saved.
169
+ * @default "COLLECTED"
170
+ */
162
171
  savingType?: 'COLLECTED';
163
172
  /** Function called when a variable is changed by a user input (must be memoized as it is used in dependency of a `useCallback` by the library). */
164
173
  onChange?: LunaticChangesHandler;
@@ -168,24 +177,43 @@ export type LunaticOptions = {
168
177
  *
169
178
  * Enable management mode which allow to handle multiple states of the same variable (used by recovery positions).
170
179
  *
171
- * The administrator can switch between `COLLECTED`, `EDITED`, `INPUTTED` modes. (default: `false`)
180
+ * The administrator can switch between `COLLECTED`, `EDITED`, `INPUTTED` modes.
181
+ * @default false
172
182
  */
173
183
  management?: boolean;
174
- /** Enable keyboard shortcuts for checkboxes, radio buttons and missing buttons (default: `false`). */
184
+ /**
185
+ * Enable keyboard shortcuts for checkboxes, radio buttons and missing buttons.
186
+ * @default false
187
+ */
175
188
  shortcut?: boolean;
176
- /** Starting page at launch. (default: `"1"`) */
189
+ /**
190
+ * Starting page at launch.
191
+ * @default '1'
192
+ */
177
193
  initialPage?: PageTag;
178
194
  /** Furthest page the user ever reached. */
179
195
  lastReachedPage?: PageTag;
180
- /** Enable the preemptive loading of suggester data on Lunatic initialization. (default: `false`) */
196
+ /**
197
+ * Enable the preemptive loading of suggester data on Lunatic initialization.
198
+ * @default false
199
+ */
181
200
  autoSuggesterLoading?: boolean;
182
201
  /** Function called to fetch nomenclatures used by the suggesters. */
183
202
  getReferentiel?: (name: string) => Promise<Array<IndexEntry>>;
184
- /** Enable data controls (form validation). (default: `false`) */
203
+ /**
204
+ * Enable data controls (form validation).
205
+ * @default false
206
+ */
185
207
  activeControls?: boolean;
186
- /** Enable overview system. (default: `false`) */
208
+ /**
209
+ * Enable overview system.
210
+ * @default false
211
+ */
187
212
  withOverview?: boolean;
188
- /** Enable missing system. (default: `false`) */
213
+ /**
214
+ * Enable missing system.
215
+ * @default false
216
+ */
189
217
  missing?: boolean;
190
218
  /** Function triggered when a missing button is clicked. */
191
219
  missingStrategy?: () => void;
@@ -198,11 +226,28 @@ export type LunaticOptions = {
198
226
  dontKnowButton?: string;
199
227
  /** "Refused" button label. */
200
228
  refusedButton?: string;
201
- /** Enable change tracking to keep a track of what variable changed (allow using getChangedData()). (default: `false`) */
229
+ /**
230
+ * Enable change tracking to keep a track of what variable changed
231
+ * (allow using getChangedData()).
232
+ * @default false
233
+ */
202
234
  trackChanges?: boolean;
203
235
  logger?: LunaticLogger;
236
+ /** Options that can be set to override default component behaviour. */
204
237
  componentsOptions?: {
238
+ /**
239
+ * Set the details ("autre précisez") as always displayed (even if the
240
+ * related "other" modality is not currently selected).
241
+ * @since 3.4.9
242
+ * @default false
243
+ */
205
244
  detailAlwaysDisplayed?: boolean;
245
+ /**
246
+ * Set the "remove row" button as disabled in roster for loop.
247
+ * @since 3.7.5
248
+ * @default false
249
+ */
250
+ disableRosterForLoopDeleteRowButton?: boolean;
206
251
  };
207
252
  /** Commit variable change automatically for resizing / cleaning (used for testing) **/
208
253
  autoCommit?: boolean;
@@ -50,7 +50,10 @@ const defaultOptions = {
50
50
  refusedButton: DEFAULT_REFUSED,
51
51
  trackChanges: false,
52
52
  logger: ConsoleLogger,
53
- componentsOptions: { detailAlwaysDisplayed: false },
53
+ componentsOptions: {
54
+ detailAlwaysDisplayed: false,
55
+ disableRosterForLoopDeleteRowButton: false,
56
+ },
54
57
  };
55
58
  /** The first library entrypoint is the `useLunatic` hook. */
56
59
  export function useLunatic(
@@ -96,6 +99,7 @@ argOptions = empty) {
96
99
  dontKnowButton,
97
100
  refusedButton,
98
101
  componentsOptions.detailAlwaysDisplayed,
102
+ componentsOptions.disableRosterForLoopDeleteRowButton,
99
103
  ]);
100
104
  const compileControls = () => {
101
105
  return compileControlsLib(state);
@@ -1 +1 @@
1
- {"version":3,"file":"use-lunatic.js","sourceRoot":"","sources":["../../src/use-lunatic/use-lunatic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,GACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,CAAC,MAAM,SAAS,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAS1D,OAAO,EAAE,eAAe,IAAI,kBAA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AAU,EAAE,KAAK,CAAC,iBAAiB,CAAC;QACxE,aAAa;QACb,QAAQ;QACR,aAAa;QACb,YAAY;KACW,CAAC;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "3.7.3",
3
+ "version": "3.7.5-rc.0",
4
4
  "description": "Library of questionnaire components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -67,6 +67,7 @@ type CustomProps = Omit<
67
67
  addRow?: () => void;
68
68
  removeRow?: () => void;
69
69
  canControlRows?: boolean;
70
+ disableDeleteRowButton?: boolean;
70
71
  }>;
71
72
 
72
73
  export const CustomLoop = slottableComponent<CustomProps>('Loop', (props) => {
@@ -79,6 +80,7 @@ export const CustomLoop = slottableComponent<CustomProps>('Loop', (props) => {
79
80
  errors,
80
81
  addRow,
81
82
  removeRow,
83
+ disableDeleteRowButton = false,
82
84
  } = props;
83
85
 
84
86
  return (
@@ -98,7 +100,10 @@ export const CustomLoop = slottableComponent<CustomProps>('Loop', (props) => {
98
100
  <Button onClick={addRow} disabled={!addRow}>
99
101
  {D.DEFAULT_BUTTON_ADD}
100
102
  </Button>
101
- <Button onClick={removeRow} disabled={!removeRow}>
103
+ <Button
104
+ onClick={removeRow}
105
+ disabled={disableDeleteRowButton || !removeRow}
106
+ >
102
107
  {D.DEFAULT_BUTTON_REMOVE}
103
108
  </Button>
104
109
  </>
@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import { RosterForLoop } from './RosterForLoop';
4
4
  import type { LunaticComponentProps } from '../type';
5
+ import { LunaticContext } from '../../use-lunatic/lunatic-context';
5
6
 
6
7
  describe('RosterForLoop', () => {
7
8
  const mockOnChange = vi.fn();
@@ -38,5 +39,32 @@ describe('RosterForLoop', () => {
38
39
  );
39
40
  expect(container).toMatchSnapshot();
40
41
  expect(screen.getAllByRole('row')).toHaveLength(2);
42
+ expect(screen.getByRole('button', { name: /add/i })).toBeEnabled();
43
+ expect(screen.getByRole('button', { name: /remove/i })).toBeEnabled();
44
+ });
45
+
46
+ it('disable the remove row button', () => {
47
+ const { container } = render(
48
+ <LunaticContext.Provider
49
+ value={{
50
+ componentsOptions: { disableRosterForLoopDeleteRowButton: true },
51
+ }}
52
+ >
53
+ <RosterForLoop
54
+ value={{ name: ['John Doe', 'Jane Doe'] }}
55
+ handleChanges={mockOnChange}
56
+ label="Ceci est un test"
57
+ id="table"
58
+ lines={{ min: 1, max: 3 }}
59
+ iterations={2}
60
+ getComponents={getComponents}
61
+ executeExpression={() => null as any}
62
+ />
63
+ </LunaticContext.Provider>
64
+ );
65
+ expect(container).toMatchSnapshot();
66
+ expect(screen.getAllByRole('row')).toHaveLength(2);
67
+ expect(screen.getByRole('button', { name: /add/i })).toBeEnabled();
68
+ expect(screen.getByRole('button', { name: /remove/i })).toBeDisabled();
41
69
  });
42
70
  });
@@ -10,6 +10,7 @@ import {
10
10
  } from '../shared/ComponentErrors/ComponentErrors';
11
11
  import { CustomLoop } from '../Loop/Loop';
12
12
  import { useLoopUtils } from '../Loop/utils';
13
+ import { useLunaticComponentsOptions } from '../../use-lunatic/lunatic-context';
13
14
 
14
15
  /**
15
16
  * Loop displayed as a table
@@ -17,6 +18,7 @@ import { useLoopUtils } from '../Loop/utils';
17
18
  export const RosterForLoop = (
18
19
  props: LunaticComponentProps<'RosterForLoop'>
19
20
  ) => {
21
+ const { disableRosterForLoopDeleteRowButton } = useLunaticComponentsOptions();
20
22
  const { min, max, nbRows, addRow, removeRow } = useLoopUtils(props);
21
23
  const {
22
24
  errors,
@@ -43,6 +45,7 @@ export const RosterForLoop = (
43
45
  addRow={nbRows === max ? undefined : addRow}
44
46
  removeRow={nbRows === min ? undefined : removeRow}
45
47
  canControlRows={!!(min && max && min !== max)}
48
+ disableDeleteRowButton={disableRosterForLoopDeleteRowButton}
46
49
  >
47
50
  <Table id={id}>
48
51
  {header && <TableHeader header={header} />}
@@ -1,5 +1,119 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
+ exports[`RosterForLoop > disable the remove row button 1`] = `
4
+ <div>
5
+ <label
6
+ class="lunatic-label"
7
+ for="table"
8
+ id="label-table"
9
+ >
10
+ Ceci est un test
11
+ </label>
12
+ <table
13
+ class="lunatic-table"
14
+ id="table-table"
15
+ >
16
+ <tbody
17
+ class="lunatic-table-tbody"
18
+ >
19
+ <tr
20
+ class="lunatic-table-tr"
21
+ >
22
+ <td
23
+ class="lunatic-table-td"
24
+ >
25
+ <div
26
+ class="field-container"
27
+ >
28
+ <div
29
+ class="field"
30
+ >
31
+ <div
32
+ class="lunatic-input"
33
+ >
34
+ <div
35
+ class="field-with-count"
36
+ >
37
+ <input
38
+ aria-describedby="characters-count-jrc3ye5q-QOP-lo6tcvvx-0"
39
+ aria-invalid="false"
40
+ aria-labelledby="label-jrc3ye5q-QOP-lo6tcvvx-0"
41
+ autocomplete="off"
42
+ id="jrc3ye5q-QOP-lo6tcvvx-0"
43
+ maxlength="249"
44
+ title="azeaze"
45
+ type="text"
46
+ value="azeaze"
47
+ />
48
+ <span
49
+ class="characters-count"
50
+ id="characters-count-jrc3ye5q-QOP-lo6tcvvx-0"
51
+ >
52
+ 6/249
53
+ </span>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </div>
58
+ </td>
59
+ </tr>
60
+ <tr
61
+ class="lunatic-table-tr"
62
+ >
63
+ <td
64
+ class="lunatic-table-td"
65
+ >
66
+ <div
67
+ class="field-container"
68
+ >
69
+ <div
70
+ class="field"
71
+ >
72
+ <div
73
+ class="lunatic-input"
74
+ >
75
+ <div
76
+ class="field-with-count"
77
+ >
78
+ <input
79
+ aria-describedby="characters-count-jrc3ye5q-QOP-lo6tcvvx-1"
80
+ aria-invalid="false"
81
+ aria-labelledby="label-jrc3ye5q-QOP-lo6tcvvx-1"
82
+ autocomplete="off"
83
+ id="jrc3ye5q-QOP-lo6tcvvx-1"
84
+ maxlength="249"
85
+ title="azeaze"
86
+ type="text"
87
+ value="azeaze"
88
+ />
89
+ <span
90
+ class="characters-count"
91
+ id="characters-count-jrc3ye5q-QOP-lo6tcvvx-1"
92
+ >
93
+ 6/249
94
+ </span>
95
+ </div>
96
+ </div>
97
+ </div>
98
+ </div>
99
+ </td>
100
+ </tr>
101
+ </tbody>
102
+ </table>
103
+ <input
104
+ class="button-lunatic"
105
+ type="button"
106
+ value="Add row"
107
+ />
108
+ <input
109
+ class="button-lunatic disabled"
110
+ disabled=""
111
+ type="button"
112
+ value="Remove row"
113
+ />
114
+ </div>
115
+ `;
116
+
3
117
  exports[`RosterForLoop > renders the right number of columns 1`] = `
4
118
  <div>
5
119
  <label
@@ -82,12 +82,12 @@ export const MissingPure = (
82
82
  );
83
83
 
84
84
  useKeyboardKey(
85
- Object.values(missingShortcut),
85
+ missingShortcut ? Object.values(missingShortcut) : [],
86
86
  (e) => {
87
87
  e.preventDefault();
88
- if (e.key.toLowerCase() === missingShortcut.dontKnow.toLowerCase())
88
+ if (e.key.toLowerCase() === missingShortcut?.dontKnow.toLowerCase())
89
89
  onClickDK();
90
- if (e.key.toLowerCase() === missingShortcut.refused.toLowerCase())
90
+ if (e.key.toLowerCase() === missingShortcut?.refused.toLowerCase())
91
91
  onClickRF();
92
92
  },
93
93
  hasKeyboardShortcut
@@ -36,6 +36,8 @@ type Props = {
36
36
  getReferentiel: (name: string) => Promise<IndexEntry[]>;
37
37
  // Display detail input even if the corresponding checkbox is not checked
38
38
  detailAlwaysDisplayed?: boolean;
39
+ // Set the "remove row" button as disabled in roster for loop.
40
+ disableRosterForLoopDeleteRowButton?: boolean;
39
41
  // Enable missing buttons
40
42
  missing?: boolean;
41
43
  // Readonly mode
@@ -78,11 +80,15 @@ function OrchestratorForStories(props: Readonly<Props>) {
78
80
  readOnly,
79
81
  disabled,
80
82
  detailAlwaysDisplayed,
83
+ disableRosterForLoopDeleteRowButton,
81
84
  autoSuggesterLoading,
82
85
  extraTabs = [],
83
86
  } = props;
84
87
 
85
- const componentsOptions = { detailAlwaysDisplayed };
88
+ const componentsOptions = {
89
+ detailAlwaysDisplayed,
90
+ disableRosterForLoopDeleteRowButton,
91
+ };
86
92
 
87
93
  const {
88
94
  getComponents,
@@ -313,6 +319,7 @@ export const OrchestratorMeta: Meta<typeof Orchestrator> = {
313
319
  readOnly: false,
314
320
  disabled: false,
315
321
  detailAlwaysDisplayed: false,
322
+ disableRosterForLoopDeleteRowButton: false,
316
323
  autoSuggesterLoading: false,
317
324
  },
318
325
  };
@@ -55,6 +55,8 @@ export function cleaningBehaviour(
55
55
 
56
56
  for (const variableName in cleaningInfo) {
57
57
  try {
58
+ // Skip if variable to be cleaned (variableName) is the variable causing the change (case in questionnaire (fix later in generation))
59
+ if (variableName === e.detail.name) continue;
58
60
  // Skip if variable is already in a cleaned state
59
61
  if (isAlreadyCleaned(store, variableName)) continue;
60
62
 
@@ -610,6 +610,27 @@ describe('lunatic-variables-store', () => {
610
610
  [null, null, null],
611
611
  ]);
612
612
  });
613
+ it('should handle not clean itself', () => {
614
+ variables.set('PRENOM', ['Renoir', 'Alicia', 'Verso']);
615
+ cleaningBehaviour(
616
+ variables,
617
+ {
618
+ PRENOM: {
619
+ PRENOM: [
620
+ {
621
+ expression: 'PRENOM <> "Renoir"',
622
+ shapeFrom: 'PRENOM',
623
+ isAggregatorUsed: false,
624
+ },
625
+ ],
626
+ },
627
+ },
628
+ { PRENOM: [null] }
629
+ );
630
+
631
+ variables.set('PRENOM', 'Maëlle', { iteration: [1] });
632
+ expect(variables.get('PRENOM')).toEqual(['Renoir', 'Maëlle', 'Verso']);
633
+ });
613
634
  });
614
635
 
615
636
  describe('missing', () => {
@@ -6,8 +6,21 @@ import {
6
6
  } from 'react';
7
7
 
8
8
  import D from '../i18n/index';
9
+ import type { LunaticOptions } from './type';
9
10
 
10
- const LunaticContext = createContext({
11
+ type LunaticContextType = {
12
+ missingStrategy?: LunaticOptions['missingStrategy'];
13
+ management?: LunaticOptions['management'];
14
+ missing?: LunaticOptions['missing'];
15
+ shortcut?: LunaticOptions['shortcut'];
16
+ missingShortcut?: LunaticOptions['missingShortcut'];
17
+ dontKnowButton?: LunaticOptions['dontKnowButton'];
18
+ refusedButton?: LunaticOptions['refusedButton'];
19
+ componentsOptions?: LunaticOptions['componentsOptions'];
20
+ };
21
+
22
+ /** Mandatory values used as a context's last-resort fallback. */
23
+ const defaultValues = {
11
24
  missingStrategy: () => {},
12
25
  management: false,
13
26
  missing: false,
@@ -15,8 +28,15 @@ const LunaticContext = createContext({
15
28
  missingShortcut: { dontKnow: '', refused: '' },
16
29
  dontKnowButton: D.DK,
17
30
  refusedButton: D.RF,
18
- componentsOptions: { detailAlwaysDisplayed: false },
19
- });
31
+ componentsOptions: {
32
+ detailAlwaysDisplayed: false,
33
+ disableRosterForLoopDeleteRowButton: false,
34
+ },
35
+ };
36
+
37
+ /** Expose specific Lunatic options to handle some (e.g. missing, management, components options) */
38
+ export const LunaticContext = createContext<LunaticContextType>(defaultValues);
39
+
20
40
  /**
21
41
  * Provide `missing`, `missingStrategy`, `shortcut` and `missingShortcut`,
22
42
  * `dontKnowButton`, `refusedButton` to `Missing` component to manage
@@ -41,9 +61,10 @@ export const useLunaticMissing = () => {
41
61
  };
42
62
  };
43
63
 
64
+ /** Expose the specified options to override default component behaviour. */
44
65
  export const useLunaticComponentsOptions = () => {
45
66
  const { componentsOptions } = useContext(LunaticContext);
46
- return componentsOptions;
67
+ return componentsOptions ?? {};
47
68
  };
48
69
 
49
70
  /** Provide `management` to display data states [COLLECTED,EDITED,FORCED] */
@@ -60,16 +81,7 @@ export function createLunaticProvider({
60
81
  dontKnowButton,
61
82
  refusedButton,
62
83
  componentsOptions,
63
- }: {
64
- management: boolean;
65
- missing: boolean;
66
- missingStrategy: () => void;
67
- shortcut: boolean;
68
- missingShortcut: { dontKnow: string; refused: string };
69
- dontKnowButton: string;
70
- refusedButton: string;
71
- componentsOptions: { detailAlwaysDisplayed: boolean };
72
- }): FunctionComponent<PropsWithChildren> {
84
+ }: LunaticContextType): FunctionComponent<PropsWithChildren> {
73
85
  const value = {
74
86
  management,
75
87
  missing,
@@ -185,16 +185,25 @@ export type LunaticReducerState = {
185
185
 
186
186
  /** Specific behaviour options defined in the {@link useLunatic} hook. */
187
187
  export type LunaticOptions = {
188
- /** Ignore filters. (default: `false`) */
188
+ /**
189
+ * Ignore filters.
190
+ * @default false
191
+ */
189
192
  disableFilters?: boolean;
190
193
 
191
- /** Disable filters description. (default: `true`) */
194
+ /**
195
+ * Disable filters description.
196
+ * @default true
197
+ */
192
198
  disableFiltersDescription?: boolean;
193
199
 
194
200
  /** Enable VTL and Markdown support. */
195
201
  features?: ('MD' | 'VTL')[];
196
202
  preferences?: ['COLLECTED'];
197
- /** Key in which the data is saved. (default: `"COLLECTED"`) */
203
+ /**
204
+ * Key in which the data is saved.
205
+ * @default "COLLECTED"
206
+ */
198
207
  savingType?: 'COLLECTED';
199
208
  /** Function called when a variable is changed by a user input (must be memoized as it is used in dependency of a `useCallback` by the library). */
200
209
  onChange?: LunaticChangesHandler;
@@ -204,24 +213,43 @@ export type LunaticOptions = {
204
213
  *
205
214
  * Enable management mode which allow to handle multiple states of the same variable (used by recovery positions).
206
215
  *
207
- * The administrator can switch between `COLLECTED`, `EDITED`, `INPUTTED` modes. (default: `false`)
216
+ * The administrator can switch between `COLLECTED`, `EDITED`, `INPUTTED` modes.
217
+ * @default false
208
218
  */
209
219
  management?: boolean;
210
- /** Enable keyboard shortcuts for checkboxes, radio buttons and missing buttons (default: `false`). */
220
+ /**
221
+ * Enable keyboard shortcuts for checkboxes, radio buttons and missing buttons.
222
+ * @default false
223
+ */
211
224
  shortcut?: boolean;
212
- /** Starting page at launch. (default: `"1"`) */
225
+ /**
226
+ * Starting page at launch.
227
+ * @default '1'
228
+ */
213
229
  initialPage?: PageTag;
214
230
  /** Furthest page the user ever reached. */
215
231
  lastReachedPage?: PageTag;
216
- /** Enable the preemptive loading of suggester data on Lunatic initialization. (default: `false`) */
232
+ /**
233
+ * Enable the preemptive loading of suggester data on Lunatic initialization.
234
+ * @default false
235
+ */
217
236
  autoSuggesterLoading?: boolean;
218
237
  /** Function called to fetch nomenclatures used by the suggesters. */
219
238
  getReferentiel?: (name: string) => Promise<Array<IndexEntry>>;
220
- /** Enable data controls (form validation). (default: `false`) */
239
+ /**
240
+ * Enable data controls (form validation).
241
+ * @default false
242
+ */
221
243
  activeControls?: boolean;
222
- /** Enable overview system. (default: `false`) */
244
+ /**
245
+ * Enable overview system.
246
+ * @default false
247
+ */
223
248
  withOverview?: boolean;
224
- /** Enable missing system. (default: `false`) */
249
+ /**
250
+ * Enable missing system.
251
+ * @default false
252
+ */
225
253
  missing?: boolean;
226
254
  /** Function triggered when a missing button is clicked. */
227
255
  missingStrategy?: () => void;
@@ -231,10 +259,29 @@ export type LunaticOptions = {
231
259
  dontKnowButton?: string;
232
260
  /** "Refused" button label. */
233
261
  refusedButton?: string;
234
- /** Enable change tracking to keep a track of what variable changed (allow using getChangedData()). (default: `false`) */
262
+ /**
263
+ * Enable change tracking to keep a track of what variable changed
264
+ * (allow using getChangedData()).
265
+ * @default false
266
+ */
235
267
  trackChanges?: boolean;
236
268
  logger?: LunaticLogger;
237
- componentsOptions?: { detailAlwaysDisplayed?: boolean };
269
+ /** Options that can be set to override default component behaviour. */
270
+ componentsOptions?: {
271
+ /**
272
+ * Set the details ("autre précisez") as always displayed (even if the
273
+ * related "other" modality is not currently selected).
274
+ * @since 3.4.9
275
+ * @default false
276
+ */
277
+ detailAlwaysDisplayed?: boolean;
278
+ /**
279
+ * Set the "remove row" button as disabled in roster for loop.
280
+ * @since 3.7.5
281
+ * @default false
282
+ */
283
+ disableRosterForLoopDeleteRowButton?: boolean;
284
+ };
238
285
  /** Commit variable change automatically for resizing / cleaning (used for testing) **/
239
286
  autoCommit?: boolean;
240
287
  };
@@ -106,7 +106,10 @@ describe('use-lunatic()', () => {
106
106
  missingShortcut: { dontKnow: '1', refused: '2' },
107
107
  dontKnowButton: 'DK',
108
108
  refusedButton: 'RF',
109
- componentsOptions: { detailAlwaysDisplayed: false },
109
+ componentsOptions: {
110
+ detailAlwaysDisplayed: false,
111
+ disableRosterForLoopDeleteRowButton: false,
112
+ },
110
113
  });
111
114
  });
112
115