@inseefr/lunatic 3.6.15 → 3.7.1-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.
@@ -1,5 +1,12 @@
1
1
  import type { LunaticComponentDefinition, LunaticReducerState } from '../type';
2
2
  /**
3
- * Extract the list of components to display for the current page
3
+ *
4
+ * @param state
5
+ * @param ignoreAutoSubPages : (default: `false`), For pagination, during computation of next page, we check if there is component on a page
6
+ * before exploring inside Loop, so we have to return only the Loop component (and not it's child)
7
+ * So if we are computing page (during next or previous action), we have to return only Loop component
8
+ * During process of computing page, we reached Loop by the root (with subpage or iteration undefined)
9
+ * So if you're computing pages, set it to `true`
10
+ * @returns the list of components to display for the current page
4
11
  */
5
- export declare function getComponentsFromState(state: Pick<LunaticReducerState, 'pager' | 'pages' | 'isInLoop'>): LunaticComponentDefinition[];
12
+ export declare function getComponentsFromState(state: Pick<LunaticReducerState, 'pager' | 'pages' | 'isInLoop'>, ignoreAutoSubPages?: boolean): LunaticComponentDefinition[];
@@ -2,15 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getComponentsFromState = getComponentsFromState;
4
4
  /**
5
- * Extract the list of components to display for the current page
5
+ *
6
+ * @param state
7
+ * @param ignoreAutoSubPages : (default: `false`), For pagination, during computation of next page, we check if there is component on a page
8
+ * before exploring inside Loop, so we have to return only the Loop component (and not it's child)
9
+ * So if we are computing page (during next or previous action), we have to return only Loop component
10
+ * During process of computing page, we reached Loop by the root (with subpage or iteration undefined)
11
+ * So if you're computing pages, set it to `true`
12
+ * @returns the list of components to display for the current page
6
13
  */
7
- function getComponentsFromState(state) {
14
+ function getComponentsFromState(state, ignoreAutoSubPages = false) {
8
15
  const { pager, pages, isInLoop } = state;
9
16
  const { page, subPage } = pager;
10
17
  if (page && pages && page in pages) {
11
18
  const current = pages[page];
12
19
  if (isInLoop && current.subPages) {
13
20
  const { subPages } = current;
21
+ if (ignoreAutoSubPages && subPage === undefined)
22
+ return current.components;
14
23
  const stepName = subPages[subPage ?? '0'];
15
24
  if (stepName in pages) {
16
25
  return pages[stepName].components;
@@ -1 +1 @@
1
- {"version":3,"file":"get-components-from-state.js","sourceRoot":"","sources":["../../src/use-lunatic/commons/get-components-from-state.ts"],"names":[],"mappings":";;AAKA,wDAmBC;AAtBD;;GAEG;AACH,SAAgB,sBAAsB,CACrC,KAAgE;IAEhE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACzC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAChC,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YAClC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;YAC7B,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;YAC1C,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;gBACvB,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC;YACnC,CAAC;QACF,CAAC;aAAM,CAAC;YACP,OAAO,OAAO,CAAC,UAAU,CAAC;QAC3B,CAAC;IACF,CAAC;IAED,OAAO,EAAE,CAAC;AACX,CAAC"}
1
+ {"version":3,"file":"get-components-from-state.js","sourceRoot":"","sources":["../../src/use-lunatic/commons/get-components-from-state.ts"],"names":[],"mappings":";;AAYA,wDAsBC;AAhCD;;;;;;;;;GASG;AACH,SAAgB,sBAAsB,CACrC,KAAgE,EAChE,kBAAkB,GAAG,KAAK;IAE1B,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACzC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAChC,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YAClC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;YAC7B,IAAI,kBAAkB,IAAI,OAAO,KAAK,SAAS;gBAC9C,OAAO,OAAO,CAAC,UAAU,CAAC;YAC3B,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;YAC1C,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;gBACvB,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC;YACnC,CAAC;QACF,CAAC;aAAM,CAAC;YACP,OAAO,OAAO,CAAC,UAAU,CAAC;QAC3B,CAAC;IACF,CAAC;IAED,OAAO,EAAE,CAAC;AACX,CAAC"}
@@ -27,7 +27,7 @@ function pageStringToNumbers(page) {
27
27
  function isPageEmpty(state) {
28
28
  const { executeExpression, pager, options } = state;
29
29
  const { iteration } = pager;
30
- const components = (0, get_components_from_state_1.getComponentsFromState)(state);
30
+ const components = (0, get_components_from_state_1.getComponentsFromState)(state, true);
31
31
  const visibleComponents = components.filter((component) => {
32
32
  if (options.disableFilters) {
33
33
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/use-lunatic/commons/page.ts"],"names":[],"mappings":";;;;;AAIA,8BAQC;AAKD,kDAEC;AAMD,kCAkCC;AA1DD,2EAAqE;AACrE,0FAAgE;AAEhE,SAAgB,SAAS,CAAC,EACzB,OAAO,EACP,IAAI,GACoD;IACxD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,GAAG,IAAI,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;AACjC,CAAC;A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