@inseefr/lunatic 4.0.0 → 4.0.1

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.
package/README.md CHANGED
@@ -12,6 +12,7 @@ Lunatic is a front-end library in the form of a React hook and component librari
12
12
 
13
13
  ---
14
14
 
15
+ - [Storybook 4.0](https://inseefr.github.io/Lunatic/storybook-3.0), branch `4.0`
15
16
  - [Storybook 3.0](https://inseefr.github.io/Lunatic/storybook-3.0), branch `3.0`
16
17
  - [Storybook 2.7](https://inseefr.github.io/Lunatic/storybook-2.7), branch `2.7`
17
18
  - [Storybook 2.6](https://inseefr.github.io/Lunatic/storybook-2.6), branch `2.6`
@@ -85,7 +86,7 @@ And it returns an object that allows you to control the questionnaire:
85
86
  - `getData()`, returns the collected data in the questionnaire.
86
87
  - `loopVariables`, is an array containing the list of variables used for the current loop.
87
88
 
88
- For more information on the types of this return, you can refer to the available types in the [source code](https://github.com/InseeFr/Lunatic/blob/3.0/src/use-lunatic/type.ts). You can also find an example of using the hook in the [Storybook section](https://github.com/InseeFr/Lunatic/blob/3.0/src/stories/utils/orchestrator.jsx#L121-L152).
89
+ For more information on the types of this return, you can refer to the available types in the [source code](https://github.com/InseeFr/Lunatic/blob/4.0/src/use-lunatic/type.ts). You can also find an example of using the hook in the [Storybook section](https://github.com/InseeFr/Lunatic/blob/4.0/src/stories/utils/orchestrator.jsx#L121-L152).
89
90
 
90
91
  ### Components
91
92
 
@@ -112,7 +113,7 @@ function App({ source, data }) {
112
113
  }
113
114
  ```
114
115
 
115
- All the components offered by Lunatic are available in the [src/components](https://github.com/InseeFr/Lunatic/tree/3.0/src/components) folder.
116
+ All the components offered by Lunatic are available in the [src/components](https://github.com/InseeFr/Lunatic/tree/4.0/src/components) folder.
116
117
 
117
118
  To activate the **autofocus**, you need to pass a key in the `autoFocusKey` property of `LunaticComponents`. As soon as this value changes, the first field is focused (a good solution is to pass the `pageTag` provided by `useLunatic`).
118
119
 
@@ -139,13 +140,13 @@ This section covers the internal working of the `useLunatic()` hook. The goal is
139
140
 
140
141
  ### General Functioning
141
142
 
142
- The hook is based on an [internal state](https://github.com/InseeFr/Lunatic/blob/3.0/src/use-lunatic/type.ts#L79-L187) that is updated through a [reducer](https://reactjs.org/docs/hooks-reference.html#usereducer) system. The [actions](https://github.com/InseeFr/Lunatic/blob/3.0/src/use-lunatic/actions.ts) affecting this state are limited:
143
+ The hook is based on an [internal state](https://github.com/InseeFr/Lunatic/blob/4.0/src/use-lunatic/type.ts#L79-L187) that is updated through a [reducer](https://reactjs.org/docs/hooks-reference.html#usereducer) system. The [actions](https://github.com/InseeFr/Lunatic/blob/4.0/src/use-lunatic/actions.ts) affecting this state are limited:
143
144
 
144
145
  - An action `'use-lunatic/on-init'` allows initialization of the state from the data received as a parameter of the hook.
145
146
  - The actions `'use-lunatic/go-previous'`, `'use-lunatic/go-next'`, and `'use-lunatic/go-to-page'` are called during navigation using the methods returned by the hook.
146
147
  - The action `use-lunatic/handle-change` is the most important action and is called whenever data is changed in the questionnaire.
147
148
 
148
- All the [reducers corresponding to these actions are available here](https://github.com/InseeFr/Lunatic/blob/3.0/src/use-lunatic/reducer/reducer.ts). Generally, they are broken down into several methods depending on the part of the state they modify.
149
+ All the [reducers corresponding to these actions are available here](https://github.com/InseeFr/Lunatic/blob/4.0/src/use-lunatic/reducer/reducer.ts). Generally, they are broken down into several methods depending on the part of the state they modify.
149
150
 
150
151
  ### Pages and Pager
151
152
 
@@ -153,7 +154,7 @@ At initialization, the questionnaire scenario is modeled as an object which is s
153
154
 
154
155
  ### VTL Execution
155
156
 
156
- Another important point of Lunatic is the execution of VTL expressions which allow making certain properties dynamic (labels, errors, etc.). This filling is done [when the state changes](https://github.com/InseeFr/Lunatic/blob/3.0/src/use-lunatic/use-lunatic.ts#L162).
157
+ Another important point of Lunatic is the execution of VTL expressions which allow making certain properties dynamic (labels, errors, etc.). This filling is done [when the state changes](https://github.com/InseeFr/Lunatic/blob/4.0/src/use-lunatic/use-lunatic.ts#L162).
157
158
 
158
159
  To facilitate expression execution, an `executeExpression()` method is exposed in the Lunatic state. This method is accompanied by an `updateBindings()` method which allows updating internal values. This expression execution system uses a memoization system to not re-execute the same expression multiple times. When the `use-lunatic/handle-change` action is executed, the values ("bindings") are updated to memorize the values associated with the different VTL variables. Similarly, the values of calculated variables on which the modified variable depends are forgotten to refresh the value during the next execution.
159
160
 
@@ -161,9 +162,9 @@ To facilitate expression execution, an `executeExpression()` method is exposed i
161
162
 
162
163
  ### Stable Branchs
163
164
 
164
- - Stable branches follow the glob pattern `'2.*'` or `'3.*'`, like `2.7` or `3.0`.
165
+ - Stable branches follow the glob pattern `'2.*'` or `'3.*'`, like `2.7`, `3.0` or `4.0`.
165
166
  - We can maintain if needs, the old stable branches
166
- - `3.0` branch is currently the most advanced branch
167
+ - `4.0` branch is currently the most advanced branch
167
168
 
168
169
  ### Commits and feature branches
169
170
 
@@ -172,6 +173,7 @@ To facilitate expression execution, an `executeExpression()` method is exposed i
172
173
  - Files containing JSX should use the .jsx (or .tsx) extension.
173
174
  - Commits follow the specification [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
174
175
  - Pull Requests should be prefixed in the same convention as commits:
176
+
175
177
  - `test(XXX?)`: XXX for adding tests.
176
178
  - `feat(XXX?)`: XXX for adding new features.
177
179
  - `fix(XXX?)`: XXX for bug fixes.
@@ -22,7 +22,7 @@ type Props<V = unknown> = {
22
22
  /**
23
23
  * Entry point for orchestrators, this component display the list of fields.
24
24
  *
25
- * Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/3.0/src/components}
25
+ * Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/4.0/src/components}
26
26
  */
27
27
  export declare function LunaticComponents<V = unknown>({ components, autoFocusKey, componentProps, blocklist, memo, slots, wrapper, }: Readonly<Props<V>>): import("react/jsx-runtime").JSX.Element;
28
28
  export declare function hasLabel<T>(component: T): component is {
@@ -16,7 +16,7 @@ const LunaticComponentWrapper = (0, slottableComponent_1.slottableComponent)('Co
16
16
  /**
17
17
  * Entry point for orchestrators, this component display the list of fields.
18
18
  *
19
- * Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/3.0/src/components}
19
+ * Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/4.0/src/components}
20
20
  */
21
21
  function LunaticComponents({ components, autoFocusKey, componentProps, blocklist, memo, slots, wrapper = (args) => (0, jsx_runtime_1.jsx)(LunaticComponentWrapper, { ...args }), }) {
22
22
  const wrapperRef = (0, react_1.useRef)(null);
@@ -22,7 +22,7 @@ type Props<V = unknown> = {
22
22
  /**
23
23
  * Entry point for orchestrators, this component display the list of fields.
24
24
  *
25
- * Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/3.0/src/components}
25
+ * Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/4.0/src/components}
26
26
  */
27
27
  export declare function LunaticComponents<V = unknown>({ components, autoFocusKey, componentProps, blocklist, memo, slots, wrapper, }: Readonly<Props<V>>): import("react/jsx-runtime").JSX.Element;
28
28
  export declare function hasLabel<T>(component: T): component is {
@@ -12,7 +12,7 @@ const LunaticComponentWrapper = slottableComponent('ComponentWrapper', ({ childr
12
12
  /**
13
13
  * Entry point for orchestrators, this component display the list of fields.
14
14
  *
15
- * Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/3.0/src/components}
15
+ * Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/4.0/src/components}
16
16
  */
17
17
  export function LunaticComponents({ components, autoFocusKey, componentProps, blocklist, memo, slots, wrapper = (args) => _jsx(LunaticComponentWrapper, { ...args }), }) {
18
18
  const wrapperRef = useRef(null);
@@ -3,14 +3,6 @@ export type SearchInfo = LunaticSuggester;
3
3
  export type IndexEntry = {
4
4
  id: string;
5
5
  label: string;
6
- /**
7
- * Score computed by MiniSearch algo
8
- */
9
- score: number;
10
- /**
11
- * Score compute by melauto algo
12
- */
13
- melautoScore: number;
14
6
  [k: string]: any;
15
7
  };
16
8
  export interface SearchInterface<T extends IndexEntry> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Library of questionnaire components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -47,7 +47,7 @@ const LunaticComponentWrapper = slottableComponent(
47
47
  /**
48
48
  * Entry point for orchestrators, this component display the list of fields.
49
49
  *
50
- * Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/3.0/src/components}
50
+ * Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/4.0/src/components}
51
51
  */
52
52
  export function LunaticComponents<V = unknown>({
53
53
  components,
@@ -5,15 +5,6 @@ export type SearchInfo = LunaticSuggester;
5
5
  export type IndexEntry = {
6
6
  id: string;
7
7
  label: string;
8
- /**
9
- * Score computed by MiniSearch algo
10
- */
11
- score: number;
12
-
13
- /**
14
- * Score compute by melauto algo
15
- */
16
- melautoScore: number;
17
8
  [k: string]: any;
18
9
  };
19
10