@inseefr/lunatic 3.4.10-rc.1 → 3.4.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 (68) hide show
  1. package/README.md +6 -4
  2. package/components/LunaticComponents.d.ts +10 -1
  3. package/components/LunaticComponents.js +3 -1
  4. package/components/LunaticComponents.js.map +1 -1
  5. package/components/shared/HOC/slottableComponent.d.ts +3 -3
  6. package/components/shared/HOC/slottableComponent.js +2 -2
  7. package/esm/components/LunaticComponents.d.ts +10 -1
  8. package/esm/components/LunaticComponents.js +3 -1
  9. package/esm/components/LunaticComponents.js.map +1 -1
  10. package/esm/components/shared/HOC/slottableComponent.d.ts +3 -3
  11. package/esm/components/shared/HOC/slottableComponent.js +2 -2
  12. package/esm/use-lunatic/commons/compile-controls.d.ts +1 -1
  13. package/esm/use-lunatic/commons/compile-controls.js +4 -3
  14. package/esm/use-lunatic/commons/compile-controls.js.map +1 -1
  15. package/esm/use-lunatic/commons/variables/lunatic-variables-store.d.ts +16 -0
  16. package/esm/use-lunatic/commons/variables/lunatic-variables-store.js +6 -6
  17. package/esm/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
  18. package/esm/use-lunatic/hooks/use-loop-variables.d.ts +1 -1
  19. package/esm/use-lunatic/hooks/use-loop-variables.js +1 -1
  20. package/esm/use-lunatic/hooks/use-page-has-response.d.ts +1 -1
  21. package/esm/use-lunatic/hooks/use-page-has-response.js +6 -6
  22. package/esm/use-lunatic/hooks/useOverview.d.ts +1 -1
  23. package/esm/use-lunatic/hooks/useOverview.js +4 -4
  24. package/esm/use-lunatic/hooks/useWarnDepChange.d.ts +3 -2
  25. package/esm/use-lunatic/hooks/useWarnDepChange.js +3 -2
  26. package/esm/use-lunatic/hooks/useWarnDepChange.js.map +1 -1
  27. package/esm/use-lunatic/lunatic-context.d.ts +5 -2
  28. package/esm/use-lunatic/lunatic-context.js +5 -2
  29. package/esm/use-lunatic/lunatic-context.js.map +1 -1
  30. package/esm/use-lunatic/type.d.ts +152 -2
  31. package/esm/use-lunatic/use-lunatic.d.ts +13 -36
  32. package/esm/use-lunatic/use-lunatic.js +13 -2
  33. package/esm/use-lunatic/use-lunatic.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/components/LunaticComponents.tsx +10 -8
  36. package/src/components/shared/HOC/slottableComponent.tsx +3 -3
  37. package/src/use-lunatic/commons/compile-controls.ts +4 -3
  38. package/src/use-lunatic/commons/variables/lunatic-variables-store.ts +18 -18
  39. package/src/use-lunatic/hooks/use-loop-variables.ts +1 -1
  40. package/src/use-lunatic/hooks/use-page-has-response.ts +6 -6
  41. package/src/use-lunatic/hooks/useOverview.ts +4 -4
  42. package/src/use-lunatic/hooks/useWarnDepChange.ts +3 -2
  43. package/src/use-lunatic/lunatic-context.tsx +5 -2
  44. package/src/use-lunatic/type.ts +153 -17
  45. package/src/use-lunatic/use-lunatic.ts +11 -2
  46. package/tsconfig.build.tsbuildinfo +1 -1
  47. package/use-lunatic/commons/compile-controls.d.ts +1 -1
  48. package/use-lunatic/commons/compile-controls.js +4 -3
  49. package/use-lunatic/commons/compile-controls.js.map +1 -1
  50. package/use-lunatic/commons/variables/lunatic-variables-store.d.ts +16 -0
  51. package/use-lunatic/commons/variables/lunatic-variables-store.js +13 -13
  52. package/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
  53. package/use-lunatic/hooks/use-loop-variables.d.ts +1 -1
  54. package/use-lunatic/hooks/use-loop-variables.js +1 -1
  55. package/use-lunatic/hooks/use-page-has-response.d.ts +1 -1
  56. package/use-lunatic/hooks/use-page-has-response.js +6 -6
  57. package/use-lunatic/hooks/useOverview.d.ts +1 -1
  58. package/use-lunatic/hooks/useOverview.js +4 -4
  59. package/use-lunatic/hooks/useWarnDepChange.d.ts +3 -2
  60. package/use-lunatic/hooks/useWarnDepChange.js +3 -2
  61. package/use-lunatic/hooks/useWarnDepChange.js.map +1 -1
  62. package/use-lunatic/lunatic-context.d.ts +5 -2
  63. package/use-lunatic/lunatic-context.js +5 -2
  64. package/use-lunatic/lunatic-context.js.map +1 -1
  65. package/use-lunatic/type.d.ts +152 -2
  66. package/use-lunatic/use-lunatic.d.ts +13 -36
  67. package/use-lunatic/use-lunatic.js +13 -2
  68. package/use-lunatic/use-lunatic.js.map +1 -1
@@ -22,18 +22,32 @@ export type LunaticOverviewItem = {
22
22
  iterations?: LunaticExpression;
23
23
  };
24
24
  export type LunaticSuggester = SuggesterDefinition;
25
+ /** Survey data. */
25
26
  export type LunaticData = Partial<Record<Exclude<VariableType, 'COLLECTED'>, Record<string, unknown>> & {
26
27
  COLLECTED: Record<string, LunaticCollectedValue>;
27
28
  }>;
28
29
  export type LunaticValues = {
29
30
  [variableName: string]: unknown;
30
31
  };
32
+ /**
33
+ * Errors returned by `useLunatic` hook when an input check is made with their
34
+ * id, criticity, type and the message to display to the user.
35
+ */
31
36
  export type LunaticError = Pick<ControlDefinition, 'id' | 'criticality' | 'typeOfControl'> & {
32
37
  errorMessage: ReactNode;
33
38
  };
34
39
  export type VariableType = 'COLLECTED' | 'EXTERNAL' | 'CALCULATED';
35
40
  export type LunaticExpression = VTLExpression | VTLScalarExpression;
41
+ /**
42
+ * Page numerotation.
43
+ *
44
+ * String representing a location in the survey. It has one of the following
45
+ * format:
46
+ * - [page].[sous-page]#[iteration], when we are in a loop or a roundabount
47
+ * - [page]
48
+ */
36
49
  export type PageTag = `${number}.${number}#${number}` | `${number}`;
50
+ /** Variables provided to Lunatic through the source and used internally in a store. */
37
51
  export type LunaticVariable = Variable;
38
52
  export type LunaticCollectedValue = Partial<{
39
53
  COLLECTED: unknown;
@@ -52,15 +66,51 @@ export type LunaticStateVariable = {
52
66
  CalculatedLinked?: LunaticVariable[];
53
67
  };
54
68
  }[LunaticVariable['variableType']];
69
+ /**
70
+ * Contains informations about navigation (last page reached, number of pages, subpages, etc.).
71
+ *
72
+ * This is the object used internally to determine where we are in the navigation.
73
+ *
74
+ * When we are in a loop, the pager will have additional properties.
75
+ */
55
76
  export type LunaticPager = {
77
+ /** Last page reached. */
56
78
  lastReachedPage?: PageTag;
79
+ /** Last page of the survey. */
57
80
  maxPage: number;
58
- nbSubPages?: number;
81
+ /** Current page. */
59
82
  page: number;
83
+ /**
84
+ * Current subpage.
85
+ *
86
+ * Only in a loop.
87
+ */
60
88
  subPage?: number;
89
+ /**
90
+ * Number of pages in a loop.
91
+ *
92
+ * Only in a loop.
93
+ */
94
+ nbSubPages?: number;
95
+ /**
96
+ * Iteration index (starts at 0).
97
+ *
98
+ * Only in a loop.
99
+ */
61
100
  iteration?: number;
101
+ /**
102
+ * Number of iterations (i.e. number of people).
103
+ *
104
+ * Only in a loop.
105
+ */
62
106
  nbIterations?: number;
107
+ /**
108
+ * Only in a loop.
109
+ */
63
110
  shallowIteration?: number;
111
+ /**
112
+ * Only in a loop.
113
+ */
64
114
  linksIterations?: number[];
65
115
  };
66
116
  export type LunaticReducerState = {
@@ -79,17 +129,22 @@ export type LunaticReducerState = {
79
129
  components: LunaticSource['components'];
80
130
  isLoop: true;
81
131
  iterations: VTLScalarExpression;
132
+ /** Variables affecting this loop. */
82
133
  loopDependencies: string[];
134
+ /** List of child pages (ex: ['20.1', '20.2'] */
83
135
  subPages: string[];
84
136
  };
85
137
  };
138
+ /** Run an expression using the value from the state. */
86
139
  executeExpression: <T = unknown>(expression: VTLExpression, args?: {
87
140
  iteration?: number | number[];
141
+ /** @deprecated */
88
142
  bindingDependencies?: string[];
89
143
  deps?: string[];
90
144
  }) => T;
91
145
  isInLoop: boolean;
92
146
  updatedAt: number;
147
+ /** Update the value collected for the variable. */
93
148
  updateBindings: (variableName: string, value: unknown, options: {
94
149
  iteration?: number[];
95
150
  }) => unknown;
@@ -97,75 +152,170 @@ export type LunaticReducerState = {
97
152
  disableFilters?: boolean;
98
153
  };
99
154
  };
155
+ /** Specific behaviour options defined in the {@link useLunatic} hook. */
100
156
  export type LunaticOptions = {
157
+ /** Ignore filters. (default: `false`) */
101
158
  disableFilters?: boolean;
159
+ /** Enable VTL and Markdown support. */
102
160
  features?: ('MD' | 'VTL')[];
103
161
  preferences?: ['COLLECTED'];
162
+ /** Key in which the data is saved. (default: `"COLLECTED"`) */
104
163
  savingType?: 'COLLECTED';
164
+ /** 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). */
105
165
  onChange?: LunaticChangesHandler;
106
166
  onVariableChange?: (event: LunaticVariablesStoreEvents['change']) => void;
167
+ /**
168
+ * Not yet implemented.
169
+ *
170
+ * Enable management mode which allow to handle multiple states of the same variable (used by recovery positions).
171
+ *
172
+ * The administrator can switch between `COLLECTED`, `EDITED`, `INPUTTED` modes. (default: `false`)
173
+ */
107
174
  management?: boolean;
175
+ /** Enable keyboard shortcuts for checkboxes, radio buttons and missing buttons (default: `false`). */
108
176
  shortcut?: boolean;
177
+ /** Starting page at launch. (default: `"1"`) */
109
178
  initialPage?: PageTag;
179
+ /** Furthest page the user ever reached. */
110
180
  lastReachedPage?: PageTag;
181
+ /** Enable the preemptive loading of suggester data on Lunatic initialization. (default: `false`) */
111
182
  autoSuggesterLoading?: boolean;
183
+ /** Function called to fetch nomenclatures used by the suggesters. */
112
184
  getReferentiel?: (name: string) => Promise<Array<IndexEntry>>;
185
+ /** Enable data controls (form validation). (default: `false`) */
113
186
  activeControls?: boolean;
187
+ /** Enable overview system. (default: `false`) */
114
188
  withOverview?: boolean;
189
+ /** Enable missing system. (default: `false`) */
115
190
  missing?: boolean;
191
+ /** Function triggered when a missing button is clicked. */
116
192
  missingStrategy?: () => void;
193
+ /** Keyboard shortcut that triggers missing buttons. */
117
194
  missingShortcut?: {
118
195
  dontKnow: string;
119
196
  refused: string;
120
197
  };
198
+ /** "Don't know" button label. */
121
199
  dontKnowButton?: string;
200
+ /** "Refused" button label. */
122
201
  refusedButton?: string;
202
+ /** Enable change tracking to keep a track of what variable changed (allow using getChangedData()). (default: `false`) */
123
203
  trackChanges?: boolean;
124
204
  logger?: LunaticLogger;
125
205
  componentsOptions?: {
126
206
  detailAlwaysDisplayed?: boolean;
127
207
  };
128
208
  };
209
+ /**
210
+ * Return type of {@link useLunatic}.
211
+ *
212
+ * Allow to operate the survey.
213
+ */
129
214
  export type LunaticState = {
215
+ /** Current pager. */
130
216
  pager: LunaticPager;
131
217
  overview: InterpretedLunaticOverviewItem[];
218
+ /** Current page numerotation. */
132
219
  pageTag: PageTag;
220
+ /** Date of the last `handleChange` function call. */
133
221
  updatedAt: number;
222
+ /** Necessary component that must wraps `LunaticComponents` to make the library works. */
134
223
  Provider: FunctionComponent<PropsWithChildren>;
224
+ /** Whether or not we're in a loop. */
135
225
  isInLoop: boolean;
226
+ /** Current loop's variables. */
136
227
  loopVariables: string[];
228
+ /** Whether or not we're on the survey first page. */
137
229
  isFirstPage: boolean;
230
+ /** Whether or not we're on the survey last page (we reached `maxPage`). */
138
231
  isLastPage: boolean;
232
+ /** Errors in the survey. */
139
233
  errors?: {
140
234
  [page: string]: {
141
235
  [id: string]: LunaticError[];
142
236
  };
143
237
  };
238
+ /** Errors in the current page / iteration. */
144
239
  currentErrors?: {
145
240
  [id: string]: LunaticError[];
146
241
  };
242
+ /** Errors in modal. */
147
243
  modalErrors?: Record<string, LunaticError[]>;
244
+ /** Navigate to a specific page. */
148
245
  goToPage: (page: {
149
246
  page: PageTag | number;
150
247
  iteration?: number;
151
248
  nbIterations?: number;
152
249
  subPage?: number;
153
250
  }) => void;
251
+ /** Navigate to the next page. */
154
252
  goNextPage: () => void;
253
+ /** Navigate to the previous page. */
155
254
  goPreviousPage: () => void;
255
+ /** Allow to fetch controls. */
156
256
  compileControls: () => {
157
257
  currentErrors: Record<string, LunaticError[]> | undefined;
158
258
  isCritical: boolean;
159
259
  };
260
+ /**
261
+ * Components to display in the current page.
262
+ *
263
+ * Return an array with the various components' properties. The orchestrator
264
+ * has to handle how they are displayed, using the `componentType` property to
265
+ * select the appropriate component.
266
+ *
267
+ * @example
268
+ * // using `LunaticComponents`
269
+ * import { useLunatic, LunaticComponents } from '@inseefr/lunatic';
270
+ *
271
+ * function App({ source, data }) {
272
+ * const { getComponents, Provider } = useLunatic(source, data, {});
273
+ * const components = getComponents();
274
+ *
275
+ * return (
276
+ * <Provider>
277
+ * <LunaticComponents components={components} />
278
+ * </Provider>
279
+ * );
280
+ * }
281
+ *
282
+ * @example
283
+ * // using custom components
284
+ * import { useLunatic, LunaticComponents } from '@inseefr/lunatic';
285
+ *
286
+ * const customCompoonents = {
287
+ * Input: MyCustomInput,
288
+ * InputNumber: MyCustomInputNumber,
289
+ * };
290
+ *
291
+ * function App({ source, data }) {
292
+ * const { getComponents, Provider } = useLunatic(source, data, {});
293
+ * const components = getComponents();
294
+ *
295
+ * return (
296
+ * <Provider>
297
+ * <LunaticComponents components={components} slots={customComponents} />
298
+ * </Provider>
299
+ * );
300
+ * }
301
+ *
302
+ * @see {@link LunaticComponents}
303
+ */
160
304
  getComponents: () => LunaticComponentProps[];
305
+ /** Get data collected by the survey. */
161
306
  getData: (withRefreshedCalculated: boolean, variableNames?: string[]) => LunaticData;
162
- getChangedData: (reset: boolean) => LunaticData;
307
+ /** Get data that have changed since last reset. Returns the same thing as `getData()`. */
308
+ getChangedData: (reset?: boolean) => LunaticData;
309
+ /** Empty the store of changed variables. */
163
310
  resetChangedData: () => void;
311
+ /** Return `true` as soon as the current page has at least one answer. */
164
312
  hasPageResponse: () => boolean;
313
+ /** Used for testing purpose only. */
165
314
  testing: {
166
315
  handleChanges: LunaticChangesHandler;
167
316
  };
168
317
  };
318
+ /** Function taking as arguments the various changes the user has made. */
169
319
  export type LunaticChangesHandler = (args: {
170
320
  name: string;
171
321
  value: any;
@@ -1,37 +1,14 @@
1
- import type { LunaticChangesHandler, LunaticData, LunaticOptions, PageTag } from './type';
1
+ import type { LunaticData, LunaticOptions, LunaticState } from './type';
2
2
  import type { LunaticSource } from './type';
3
- export declare function useLunatic(source: LunaticSource, data?: LunaticData, argOptions?: LunaticOptions): {
4
- pageTag: PageTag;
5
- isFirstPage: boolean;
6
- isLastPage: boolean;
7
- updatedAt: number;
8
- pager: import("./type").LunaticPager;
9
- isInLoop: boolean;
10
- overview: import("./hooks/useOverview").InterpretedLunaticOverviewItem[];
11
- loopVariables: string[];
12
- getComponents: () => import("..").LunaticComponentProps[];
13
- goPreviousPage: () => void;
14
- goNextPage: () => void;
15
- goToPage: (page: {
16
- page: PageTag | number;
17
- iteration?: number;
18
- nbIterations?: number;
19
- subPage?: number;
20
- }) => void;
21
- compileControls: () => {
22
- currentErrors: Record<string, import("./type").LunaticError[]> | undefined;
23
- isCritical: boolean;
24
- };
25
- getData: (withRefreshedCalculated: boolean, variableNames?: string[]) => LunaticData;
26
- getChangedData: (reset?: boolean) => Partial<Record<"EXTERNAL" | "CALCULATED", Record<string, unknown>> & {
27
- COLLECTED: Record<string, import("./type").LunaticCollectedValue>;
28
- }>;
29
- resetChangedData: () => void;
30
- hasPageResponse: () => boolean;
31
- Provider: import("react").FunctionComponent<{
32
- children?: import("react").ReactNode | undefined;
33
- }>;
34
- testing: {
35
- handleChanges: LunaticChangesHandler;
36
- };
37
- };
3
+ /** The first library entrypoint is the `useLunatic` hook. */
4
+ export declare function useLunatic(
5
+ /**
6
+ * JSON representation of our survey unit in the Lunatic Model.
7
+ *
8
+ * {@link https://github.com/InseeFr/Lunatic-Model}
9
+ */
10
+ source: LunaticSource,
11
+ /** Initial survey data (i.e. if it has been partially filled). */
12
+ data?: LunaticData,
13
+ /** Specific behaviour options. */
14
+ argOptions?: LunaticOptions): LunaticState;
@@ -49,7 +49,18 @@ const defaultOptions = {
49
49
  logger: ConsoleLogger,
50
50
  componentsOptions: { detailAlwaysDisplayed: false },
51
51
  };
52
- export function useLunatic(source, data = DEFAULT_DATA, argOptions = empty) {
52
+ /** The first library entrypoint is the `useLunatic` hook. */
53
+ export function useLunatic(
54
+ /**
55
+ * JSON representation of our survey unit in the Lunatic Model.
56
+ *
57
+ * {@link https://github.com/InseeFr/Lunatic-Model}
58
+ */
59
+ source,
60
+ /** Initial survey data (i.e. if it has been partially filled). */
61
+ data = DEFAULT_DATA,
62
+ /** Specific behaviour options. */
63
+ argOptions = empty) {
53
64
  const options = mergeDefault(argOptions, defaultOptions);
54
65
  const { disableFilters, management, missing, missingStrategy, shortcut, missingShortcut, dontKnowButton, refusedButton, onChange, trackChanges, preferences, logger, componentsOptions, } = options;
55
66
  // Help debug with warnings for options expected to be memoized
@@ -60,7 +71,7 @@ export function useLunatic(source, data = DEFAULT_DATA, argOptions = empty) {
60
71
  data,
61
72
  onVariableChange: useRefSync(options.onVariableChange),
62
73
  }, reducerInitializer);
63
- // Required context provider: cleaner than prop drilling through every component
74
+ /** Required context provider: cleaner than prop drilling through every component */
64
75
  const Provider = useMemo(() => createLunaticProvider({
65
76
  management,
66
77
  missing,
@@ -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;AAQxD,OAAO,CAAC,MAAM,SAAS,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MA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BAAkB,CAAC,UAAU,EAAE,KAAK,CAAC,iBAAiB,CAAC;QACxE,aAAa;QACb,QAAQ;QACR,OAAO,EAAE;YACR,aAAa;SACb;KACsB,CAAC;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "3.4.10-rc.1",
3
+ "version": "3.4.10",
4
4
  "description": "Library of questionnaire components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,21 +19,21 @@ import {
19
19
  import type { LunaticComponentProps } from './type';
20
20
 
21
21
  type Props<V = unknown> = {
22
- // List of components to display (coming from getComponents)
22
+ /** List of components to display (coming from getComponents). */
23
23
  components: LunaticComponentProps[];
24
- // Should we memoized children
24
+ /** Should we memoized children. */
25
25
  memo?: boolean;
26
- // Key that trigger autofocus when it changes (pageTag)
26
+ /** Key that trigger autofocus when it changes (pageTag). */
27
27
  autoFocusKey?: string;
28
- // Returns the list of extra props to add to components
28
+ /** Returns the list of extra props to add to components. */
29
29
  componentProps?: (component: LunaticComponentProps) => V;
30
- // Forbidden components
30
+ /** Forbidden components. */
31
31
  blocklist?: string[];
32
- // Add additional wrapper around each component
32
+ /** Add additional wrapper around each component. */
33
33
  wrapper?: (
34
34
  props: PropsWithChildren<LunaticComponentProps & V & { index: number }>
35
35
  ) => ReactNode;
36
- // Customized deep components
36
+ /** Customized deep components. */
37
37
  slots?: Partial<LunaticSlotComponents>;
38
38
  };
39
39
 
@@ -45,7 +45,9 @@ const LunaticComponentWrapper = slottableComponent(
45
45
  );
46
46
 
47
47
  /**
48
- * Entry point for orchestrators, this component display the list of fields
48
+ * Entry point for orchestrators, this component display the list of fields.
49
+ *
50
+ * Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/3.0/src/components}
49
51
  */
50
52
  export function LunaticComponents<V = unknown>({
51
53
  components,
@@ -45,7 +45,7 @@ import type { MarkdownLink } from '../MDLabel/MarkdownLink';
45
45
  import type { Accordion } from '../../Accordion/Accordion';
46
46
 
47
47
  /**
48
- * Contains the type of every customizable component
48
+ * Contain the type of every customizable components.
49
49
  */
50
50
  export type LunaticSlotComponents = {
51
51
  // Components
@@ -130,9 +130,9 @@ export const SlotsProvider = ({
130
130
  };
131
131
 
132
132
  /**
133
- * Create a replaceable version of a component
133
+ * Create a replaceable version of a component.
134
134
  *
135
- * The component can be replaced using the "slots" props on <LunaticComponents>
135
+ * The component can be replaced through the `slots` props on `LunaticComponents`.
136
136
  */
137
137
  export function slottableComponent<T>(
138
138
  name: keyof LunaticSlotComponents,
@@ -35,7 +35,8 @@ const isLoopComponent = (
35
35
  };
36
36
 
37
37
  /**
38
- * Check if components of the current page have errors, and return a map of error (indexed by component ID)
38
+ * Check if components of the current page have errors, and return a map of
39
+ * errors (indexed by component ID).
39
40
  */
40
41
  function checkComponents(
41
42
  state: StateForControls,
@@ -93,7 +94,7 @@ function checkControls(
93
94
  }
94
95
 
95
96
  /**
96
- * Figure out the number of iterations of a component
97
+ * Figure out the number of iterations of a component.
97
98
  */
98
99
  function computeIterations(
99
100
  component: InterpretedComponent | ComponentDefinition,
@@ -210,7 +211,7 @@ function hasCriticalError(errors?: Record<string, LunaticError[]>): boolean {
210
211
  }
211
212
 
212
213
  /**
213
- * Check controls for currently visible components and output errors
214
+ * Check controls for currently visible components and output errors.
214
215
  */
215
216
  export function compileControls(state: StateForControls) {
216
217
  const components = replaceComponentSequence(getComponentsFromState(state));
@@ -19,23 +19,23 @@ import {
19
19
  VTLMissingDependency,
20
20
  } from './errors';
21
21
 
22
- // Interpret counter, used for testing purpose
22
+ /** Interpret counter. Used for testing purpose. */
23
23
  let interpretCount = 0;
24
- // Special variable that will take the current iteration value
24
+ /** Special variable that will take the current iteration value. */
25
25
  const iterationVariableName = 'GLOBAL_ITERATION_INDEX';
26
26
 
27
27
  type IterationLevel = number[];
28
28
  export type EventArgs = {
29
29
  change: {
30
- // Name of the changed variable
30
+ /** Name of the changed variable. */
31
31
  name: string;
32
- // New value for the variable
32
+ /** New value for the variable. */
33
33
  value: unknown;
34
- // Iteration changed (for array)
34
+ /** Iteration changed (for array). */
35
35
  iteration?: IterationLevel | undefined;
36
- // What triggered this change
36
+ /** What triggered this change. */
37
37
  cause?: 'resizing' | 'cleaning';
38
- // Extra sent when setting the variable
38
+ /** Extra sent when setting the variable. */
39
39
  [extra: string]: unknown;
40
40
  };
41
41
  };
@@ -220,7 +220,7 @@ export class LunaticVariablesStore {
220
220
  this.eventTarget.removeEventListener(eventName, cb as EventListener);
221
221
  }
222
222
 
223
- // Retrieve the number of interpret() run (used in testing only)
223
+ /** Retrieve the number of interpret() run (used in testing only). */
224
224
  get interpretCount() {
225
225
  return interpretCount;
226
226
  }
@@ -249,25 +249,25 @@ export class LunaticVariablesStore {
249
249
  }
250
250
 
251
251
  class LunaticVariable {
252
- // Last time the value was updated (changed)
252
+ /** Last time the value was updated (changed). */
253
253
  public updatedAt = new Map<undefined | string, number>();
254
- // Last time "calculation" was run (for calculated variable)
254
+ /** Last time "calculation" was run (for calculated variable). */
255
255
  private calculatedAt = new Map<undefined | string, number>();
256
- // Internal value for the variable
256
+ /** Internal value for the variable. */
257
257
  private value: unknown;
258
- // List of dependencies, ex: ['FIRSTNAME', 'LASTNAME']
258
+ /** List of dependencies, ex: ['FIRSTNAME', 'LASTNAME']. */
259
259
  private dependencies?: string[];
260
- // Expression for calculated variable
260
+ /** Expression for calculated variable. */
261
261
  public readonly expression?: string;
262
- // Dictionary holding all the available variables
262
+ /** Dictionary holding all the available variables. */
263
263
  private readonly dictionary?: Map<string, LunaticVariable>;
264
- // Specific iteration depth to get value from dependencies (used for yAxis for instance)
264
+ /** Specific iteration depth to get value from dependencies (used for yAxis for instance). */
265
265
  private readonly iterationDepth?: number;
266
- // For calculated variable, shape is copied from another variable
266
+ /** For calculated variable, shape is copied from another variable. */
267
267
  private readonly shapeFrom?: string[];
268
- // Keep a record of variable name (optional, used for debug)
268
+ /** Keep a record of variable name (optional, used for debug). */
269
269
  public readonly name?: string;
270
- // Count the number of calculation
270
+ /** Count the number of calculation. */
271
271
  public calculatedCount = 0;
272
272
 
273
273
  constructor(
@@ -2,7 +2,7 @@ import type { LunaticComponentDefinition, LunaticReducerState } from '../type';
2
2
  import { useMemo } from 'react';
3
3
 
4
4
  /**
5
- * Extract the list of variables used for the current loop
5
+ * Extract the list of variables used for the current loop.
6
6
  */
7
7
  export function useLoopVariables(
8
8
  pager: LunaticReducerState['pager'],
@@ -4,7 +4,7 @@ import type { LunaticComponentDefinition, LunaticReducerState } from '../type';
4
4
  import type { LunaticComponentProps } from '../../components/type';
5
5
 
6
6
  /**
7
- * Check if a page has one response (value is filled for at least one field)
7
+ * Check if a page has one response (value is filled for at least one field).
8
8
  */
9
9
  export function usePageHasResponse(
10
10
  components: LunaticComponentProps[],
@@ -67,10 +67,10 @@ export function usePageHasResponse(
67
67
  }
68
68
 
69
69
  /**
70
- * Check if a value is empty
71
- * - null ou undefined ou ''
72
- * - for arrays, every item must be empty
73
- * - for objects, every value must be empty
70
+ * Check if a value is empty.
71
+ * - `null`, `undefined` or `''`.
72
+ * - for arrays, every item must be empty.
73
+ * - for objects, every value must be empty.
74
74
  */
75
75
  function isEmpty(value: unknown): boolean {
76
76
  // Array is empty if all items are empty
@@ -86,7 +86,7 @@ function isEmpty(value: unknown): boolean {
86
86
  }
87
87
 
88
88
  /**
89
- * For complex component we need to inspect child components, interpret the response value
89
+ * For complex component we need to inspect child components, interpret the response value.
90
90
  */
91
91
  function isSubComponentsEmpty(
92
92
  components: (LunaticComponentProps | LunaticComponentDefinition)[],
@@ -18,7 +18,7 @@ export type InterpretedLunaticOverviewItem = {
18
18
  };
19
19
 
20
20
  /**
21
- * Hook to build a filled overview everytime the deps change
21
+ * Build a filled overview everytime the deps change.
22
22
  */
23
23
  export const useOverview = (
24
24
  {
@@ -36,7 +36,7 @@ export const useOverview = (
36
36
  };
37
37
 
38
38
  /**
39
- * Use lunatic data to interpret the static overview (calculated on init) with the real data
39
+ * Use Lunatic data to interpret the static overview (calculated on init) with the real data.
40
40
  */
41
41
  const interpretOverview = (
42
42
  overviewItems: LunaticOverviewItem[],
@@ -71,7 +71,7 @@ const interpretOverview = (
71
71
  };
72
72
 
73
73
  /**
74
- * Interpret expression inside an item (label & condition)
74
+ * Interpret expression inside an item (label & condition).
75
75
  */
76
76
  const interpretOverviewItem = (
77
77
  items: InterpretedLunaticOverviewItem[],
@@ -127,7 +127,7 @@ const interpretOverviewItem = (
127
127
  };
128
128
 
129
129
  /**
130
- * Set the current property in the correct overview item
130
+ * Set the current property in the correct overview item.
131
131
  */
132
132
  const applyCurrentPage = (
133
133
  items: InterpretedLunaticOverviewItem[],
@@ -3,8 +3,9 @@ import type { LunaticLogger } from '../logger/type';
3
3
  import { useRefSync } from '../../hooks/useRefSync';
4
4
 
5
5
  /**
6
- * Log a warning when the variable change
7
- * ensure that we received a memoized value and help debug
6
+ * Log a warning when the variable change.
7
+ *
8
+ * Ensure that we received a memoized value and help debug.
8
9
  */
9
10
  export function useWarnDepChange(
10
11
  variable: unknown,
@@ -17,8 +17,11 @@ const LunaticContext = createContext({
17
17
  refusedButton: D.RF,
18
18
  componentsOptions: { detailAlwaysDisplayed: false },
19
19
  });
20
- /** Provide `missing` `missingStrategy`, `shortcut` and `missingShortcut`, `dontKnowButton`, `refusedButton` to Missing component
21
- * to manage non-response buttons and shortcut */
20
+ /**
21
+ * Provide `missing`, `missingStrategy`, `shortcut` and `missingShortcut`,
22
+ * `dontKnowButton`, `refusedButton` to `Missing` component to manage
23
+ * non-response buttons and shortcut.
24
+ */
22
25
  export const useLunaticMissing = () => {
23
26
  const {
24
27
  missing,