@inseefr/lunatic 2.6.3-rc.1 → 2.6.3
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 +49 -3
- package/lib/components/checkbox/checkbox-boolean/html/checkbox-boolean.js +3 -3
- package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +7 -1
- package/lib/components/checkbox/checkbox-group/checkbox-group-content.js +0 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group-content.js +4 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group.js +3 -3
- package/lib/components/checkbox/checkbox-group/lunatic-checkbox-group.js +2 -1
- package/lib/components/checkbox/checkbox-one/lunatic-checkbox-one.js +2 -1
- package/lib/components/checkbox/commons/checkbox-option.js +3 -1
- package/lib/components/commons/components/combo-box/combo-box-container.js +1 -2
- package/lib/components/commons/components/combo-box/combo-box.js +2 -2
- package/lib/components/commons/components/combo-box/selection/LabelOrInput.js +3 -1
- package/lib/components/commons/components/combo-box/selection/input.js +3 -1
- package/lib/components/commons/components/combo-box/selection/selection.js +3 -1
- package/lib/components/commons/components/errors/errors.js +12 -10
- package/lib/components/commons/components/errors/errors.spec.js +6 -6
- package/lib/components/component-set/html/__snapshots__/component-set.spec.tsx.snap +2 -0
- package/lib/components/component-set/html/component-set.js +2 -2
- package/lib/components/datepicker/html/__snapshots__/datepicker.spec.tsx.snap +2 -0
- package/lib/components/datepicker/html/datepicker-input.js +4 -2
- package/lib/components/datepicker/html/datepicker.js +3 -3
- package/lib/components/datepicker/lunatic-datepicker.js +2 -1
- package/lib/components/dropdown/lunatic-dropdown.js +2 -1
- package/lib/components/index.js +4 -4
- package/lib/components/input/html/__snapshots__/input.spec.tsx.snap +2 -0
- package/lib/components/input/html/input.js +3 -3
- package/lib/components/input/lunatic-input.js +2 -1
- package/lib/components/input-number/html/__snapshots__/input-number.spec.tsx.snap +2 -2
- package/lib/components/input-number/html/input-number-thousand.js +4 -17
- package/lib/components/input-number/html/input-number.js +3 -5
- package/lib/components/input-number/lunatic-input-number.js +2 -3
- package/lib/components/loop/block-for-loop.js +10 -6
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +35 -27
- package/lib/components/loop/utils/get-initial-nb-rows.js +17 -0
- package/lib/components/lunatic-components.js +7 -27
- package/lib/components/pairwise-links/index.js +13 -0
- package/lib/components/pairwise-links/orchestrator.js +71 -0
- package/lib/components/pairwise-links/pairwise-links.js +30 -27
- package/lib/components/pairwise-links/row.js +74 -0
- package/lib/components/radio/html/radio-group-content.js +4 -2
- package/lib/components/radio/html/radio-group.js +3 -3
- package/lib/components/radio/html/radio-option.js +3 -1
- package/lib/components/radio/lunatic-radio-group.js +2 -1
- package/lib/components/suggester/find-best-label/find-best-label.js +6 -6
- package/lib/components/suggester/idb-suggester/idb-suggester.js +4 -3
- package/lib/components/suggester/lunatic-suggester.js +7 -4
- package/lib/components/suggester/searching/create-searching.js +20 -39
- package/lib/components/switch/html/switch.js +2 -2
- package/lib/components/switch/lunatic-switch.js +2 -1
- package/lib/components/table/cell.js +89 -0
- package/lib/components/table/{table-header.js → header.js} +5 -3
- package/lib/components/table/index.js +13 -0
- package/lib/components/table/lunatic-table.js +15 -24
- package/lib/components/table/row.js +40 -0
- package/lib/components/table/table-orchestrator.js +35 -0
- package/lib/components/textarea/html/__snapshots__/textarea.spec.tsx.snap +2 -0
- package/lib/components/textarea/html/textarea.js +6 -4
- package/lib/components/textarea/lunatic-textarea.js +6 -3
- package/lib/hooks/use-auto-focus.js +26 -0
- package/lib/src/components/checkbox/checkbox-boolean/html/checkbox-boolean.d.ts +1 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group-content.d.ts +2 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group.d.ts +1 -1
- package/lib/src/components/checkbox/commons/checkbox-option.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/combo-box-container.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/combo-box.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/combo-box.stories.d.ts +4 -6
- package/lib/src/components/commons/components/combo-box/selection/LabelOrInput.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/selection/input.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/selection/selection.d.ts +2 -1
- package/lib/src/components/commons/components/errors/errors.d.ts +6 -3
- package/lib/src/components/datepicker/html/datepicker-input.d.ts +2 -1
- package/lib/src/components/datepicker/html/datepicker.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown-writable/dropdown-writable.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown.d.ts +3 -1
- package/lib/src/components/index.d.ts +2 -2
- package/lib/src/components/input/html/input.d.ts +2 -2
- package/lib/src/components/input-number/html/input-number-thousand.d.ts +2 -2
- package/lib/src/components/input-number/html/input-number.d.ts +2 -3
- package/lib/src/components/loop/block-for-loop.d.ts +4 -3
- package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +4 -3
- package/lib/src/components/loop/utils/get-initial-nb-rows.d.ts +4 -0
- package/lib/src/components/lunatic-components.d.ts +3 -5
- package/lib/src/components/pairwise-links/index.d.ts +1 -0
- package/lib/src/components/pairwise-links/orchestrator.d.ts +6 -0
- package/lib/src/components/pairwise-links/pairwise-links.d.ts +2 -1
- package/lib/src/components/pairwise-links/row.d.ts +7 -0
- package/lib/src/components/radio/html/radio-group-content.d.ts +2 -1
- package/lib/src/components/radio/html/radio-group.d.ts +1 -1
- package/lib/src/components/radio/html/radio-option.d.ts +1 -0
- package/lib/src/components/suggester/find-best-label/find-best-label.d.ts +1 -1
- package/lib/src/components/suggester/html/suggester.d.ts +1 -1
- package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +5 -2
- package/lib/src/components/suggester/lunatic-suggester.d.ts +1 -1
- package/lib/src/components/suggester/searching/create-searching.d.ts +1 -1
- package/lib/src/components/switch/html/switch.d.ts +1 -1
- package/lib/src/components/table/cell.d.ts +19 -0
- package/lib/src/components/table/{table-header.d.ts → header.d.ts} +2 -2
- package/lib/src/components/table/index.d.ts +1 -0
- package/lib/src/components/table/lunatic-table.d.ts +1 -1
- package/lib/src/components/table/row.d.ts +18 -0
- package/lib/src/components/table/table-orchestrator.d.ts +4 -0
- package/lib/src/components/textarea/html/textarea.d.ts +3 -2
- package/lib/src/components/type.d.ts +9 -7
- package/lib/src/hooks/use-auto-focus.d.ts +6 -0
- package/lib/src/use-lunatic/actions.d.ts +19 -3
- package/lib/src/use-lunatic/commons/calculated-variables.d.ts +8 -0
- package/lib/src/use-lunatic/commons/compile-controls.d.ts +2 -3
- package/lib/src/use-lunatic/commons/execute-expression/create-execute-expression.d.ts +9 -0
- package/lib/src/use-lunatic/commons/execute-expression/create-memoizer.d.ts +8 -0
- package/lib/src/use-lunatic/commons/execute-expression/create-refresh-calculated.d.ts +24 -0
- package/lib/src/use-lunatic/commons/execute-expression/execute-expression.d.ts +11 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.d.ts +7 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.spec.d.ts +1 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-safety-expression.d.ts +6 -0
- package/lib/src/use-lunatic/commons/execute-expression/index.d.ts +1 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +418 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +3 -2
- package/lib/src/use-lunatic/commons/fill-components/fill-components.d.ts +0 -6
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +142 -107
- package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +89 -53
- package/lib/src/use-lunatic/commons/get-compatible-vtl-expression.d.ts +0 -1
- package/lib/src/use-lunatic/commons/get-component-value/get-component-value.d.ts +6 -0
- package/lib/src/use-lunatic/commons/get-component-value/index.d.ts +1 -0
- package/lib/src/use-lunatic/commons/get-data.d.ts +26 -0
- package/lib/src/use-lunatic/commons/index.d.ts +3 -0
- package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +9 -10
- package/lib/src/use-lunatic/reducer/reduce-handle-change/index.d.ts +1 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.d.ts +7 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.d.ts +1 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.d.ts +4 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.d.ts +15 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-missing.d.ts +7 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-resizing.d.ts +4 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-array.d.ts +14 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.d.ts +9 -0
- package/lib/src/use-lunatic/reducer/reduce-on-init.d.ts +12 -1
- package/lib/src/use-lunatic/reducer/reduce-on-init.spec.d.ts +1 -0
- package/lib/src/use-lunatic/type-source.d.ts +21 -7
- package/lib/src/use-lunatic/type.d.ts +12 -13
- package/lib/src/use-lunatic/use-lunatic.d.ts +62 -36
- package/lib/src/use-lunatic/use-suggesters.d.ts +2 -1
- package/lib/src/utils/array.d.ts +1 -6
- package/lib/src/utils/number.d.ts +0 -4
- package/lib/src/utils/suggester-workers/append-to-index/create-append-task.d.ts +1 -1
- package/lib/src/utils/suggester-workers/worker-path.d.ts +6 -0
- package/lib/src/utils/vtl/dataset-builder.d.ts +5 -0
- package/lib/src/utils/vtl/index.d.ts +1 -0
- package/lib/stories/behaviour/cleaning/source.json +151 -0
- package/lib/stories/behaviour/cleaning/test.stories.js +84 -0
- package/lib/stories/{questionnaires-test → behaviour}/controls/controls.stories.js +5 -5
- package/lib/stories/{questionnaires-test → behaviour/others}/test.stories.js +7 -7
- package/lib/stories/{paste-questionnaire → behaviour/paste}/test.stories.js +3 -3
- package/lib/stories/{resizing-questionnaire → behaviour/resizing}/test.stories.js +3 -3
- package/lib/use-lunatic/actions.js +3 -3
- package/lib/use-lunatic/commons/calculated-variables.js +104 -0
- package/lib/use-lunatic/commons/compile-controls.js +5 -3
- package/lib/use-lunatic/commons/execute-condition-filter.js +9 -1
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.js +233 -0
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.spec.js +155 -0
- package/lib/use-lunatic/commons/execute-expression/create-memoizer.js +63 -0
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.js +149 -0
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.spec.js +130 -0
- package/lib/use-lunatic/commons/execute-expression/execute-expression.js +90 -0
- package/lib/use-lunatic/commons/execute-expression/execute-expression.spec.js +38 -0
- package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.js +40 -0
- package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.spec.js +31 -0
- package/lib/use-lunatic/commons/{fill-components/fill-iterations.js → execute-expression/get-safety-expression.js} +20 -30
- package/lib/use-lunatic/commons/execute-expression/index.js +13 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +3 -2
- package/lib/use-lunatic/{reducer/reduce-handle-change.js → commons/fill-components/fill-component-required.js} +8 -14
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +7 -21
- package/lib/use-lunatic/commons/fill-components/fill-components.js +4 -5
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +2 -0
- package/lib/use-lunatic/commons/fill-components/fill-missing-response.js +13 -6
- package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +5 -58
- package/lib/use-lunatic/commons/get-compatible-vtl-expression.js +0 -1
- package/lib/use-lunatic/commons/get-component-value/get-component-value.js +174 -0
- package/lib/use-lunatic/commons/get-component-value/index.js +13 -0
- package/lib/use-lunatic/commons/get-data.js +80 -0
- package/lib/use-lunatic/commons/index.js +21 -0
- package/lib/use-lunatic/initial-state.js +4 -6
- package/lib/use-lunatic/reducer/overview/overview-on-change.js +1 -1
- package/lib/use-lunatic/reducer/reduce-handle-change/__mocks__/source-cleaning-loop.json +792 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/index.js +13 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.js +78 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.js +46 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.js +115 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.js +89 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-missing.js +88 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-resizing.js +119 -0
- package/lib/use-lunatic/{commons/variables/get-questionnaire-data.js → reducer/reduce-handle-change/reduce-variables-array.js} +32 -53
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.js +28 -0
- package/lib/use-lunatic/reducer/reduce-on-init.js +184 -90
- package/lib/use-lunatic/reducer/reduce-on-init.spec.js +17 -0
- package/lib/use-lunatic/reducer/reducer.js +2 -2
- package/lib/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.js +4 -2
- package/lib/use-lunatic/use-lunatic.js +29 -22
- package/lib/use-lunatic/use-lunatic.test.js +36 -133
- package/lib/use-lunatic/use-suggesters.js +4 -3
- package/lib/utils/array.js +6 -57
- package/lib/utils/get-component-value.js +9 -3
- package/lib/utils/number.js +1 -13
- package/lib/utils/suggester-workers/append-to-index/create-append-task.js +4 -3
- package/lib/utils/suggester-workers/worker-path.js +29 -0
- package/lib/utils/vtl/dataset-builder.js +27 -0
- package/lib/utils/vtl/index.js +13 -0
- package/package.json +15 -10
- package/scripts/build/add-workers-to-public.js +44 -0
- package/scripts/build/workers-paths.js +44 -0
- package/workers-release/lunatic-append-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-append-worker-0.3.0-experimental.js.LICENSE.txt +34 -0
- package/workers-release/lunatic-label-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-label-worker-0.3.0-experimental.js.LICENSE.txt +13 -0
- package/workers-release/lunatic-searching-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-searching-worker-0.3.0-experimental.js.LICENSE.txt +34 -0
- package/lib/hooks/use-track-changes.js +0 -50
- package/lib/src/hooks/use-track-changes.d.ts +0 -9
- package/lib/src/use-lunatic/commons/component.d.ts +0 -22
- package/lib/src/use-lunatic/commons/fill-components/fill-iterations.d.ts +0 -112
- package/lib/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/behaviours/missing-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/behaviours/resizing-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/get-questionnaire-data.d.ts +0 -4
- package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +0 -77
- package/lib/src/use-lunatic/reducer/reduce-handle-change.d.ts +0 -6
- package/lib/src/utils/env.d.ts +0 -1
- package/lib/src/utils/store-tools/worker-path.d.ts +0 -1
- package/lib/src/utils/variables.d.ts +0 -5
- package/lib/src/utils/vtl.d.ts +0 -14
- package/lib/use-lunatic/commons/component.js +0 -22
- package/lib/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +0 -39
- package/lib/use-lunatic/commons/variables/behaviours/missing-behaviour.js +0 -47
- package/lib/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +0 -78
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +0 -330
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +0 -216
- package/lib/utils/array.spec.js +0 -30
- package/lib/utils/env.js +0 -10
- package/lib/utils/store-tools/worker-path.js +0 -13
- package/lib/utils/suggester-workers/create-worker.js +0 -55
- package/lib/utils/variables.js +0 -37
- package/lib/utils/vtl.js +0 -100
- /package/lib/src/use-lunatic/commons/{variables/lunatic-variables-store.spec.d.ts → execute-expression/create-refresh-calculated.spec.d.ts} +0 -0
- /package/lib/src/{utils/array.spec.d.ts → use-lunatic/commons/execute-expression/execute-expression.spec.d.ts} +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNonNum_horsBoucle_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNum_horsBoucle_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees2_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/boucles-n.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.stories.js +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_DeclarationsSimples.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_MinMaxSum_Boucles.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_QuestSimple_Boucles.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_TCMRallyeGames.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/test-dylan.json +0 -0
- /package/lib/stories/{paste-questionnaire → behaviour/paste}/source.json +0 -0
- /package/lib/stories/{resizing-questionnaire → behaviour/resizing}/source.json +0 -0
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
Lunatic is a front-end library in the form of a React hook and component libraries for generating a questionnaire from the [Lunatic-Model](https://github.com/InseeFr/Lunatic-Model) data format.
|
|
12
12
|
|
|
13
|
-
- [Storybook](https://inseefr.github.io/Lunatic/storybook), branch `main`
|
|
14
|
-
- [Storybook
|
|
15
|
-
- [Storybook
|
|
13
|
+
- [Storybook v1](https://inseefr.github.io/Lunatic/storybook-0.3.9), branch `v1-main`
|
|
14
|
+
- [Storybook 2.7](https://inseefr.github.io/Lunatic/storybook), branch `2.7`
|
|
15
|
+
- [Storybook 2.6](https://inseefr.github.io/Lunatic/storybook-beta), branch `2.6`
|
|
16
16
|
- [Documentation](https://inseefr.github.io/Lunatic/en/)
|
|
17
17
|
|
|
18
18
|
## Table of Contents
|
|
@@ -111,6 +111,42 @@ All the components offered by Lunatic are available in the [src/components](http
|
|
|
111
111
|
|
|
112
112
|
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`).
|
|
113
113
|
|
|
114
|
+
### Workers
|
|
115
|
+
|
|
116
|
+
#### General
|
|
117
|
+
|
|
118
|
+
Lunatic uses webWorkers to take the load off the main execution frame (e.g. list search).
|
|
119
|
+
|
|
120
|
+
Workers are normally installed when the library is installed (postinstall scripts). If this is not the case, you can always manually run the command `npx @inseefr/lunatic workers` to add Lunatic workers to your project.
|
|
121
|
+
|
|
122
|
+
Lunatic workers are added to the public/workers folder of the current project when the library is installed.
|
|
123
|
+
|
|
124
|
+
If a new version of Lunatic offers new workers, they will be automatically updated.
|
|
125
|
+
This ensures that you always have the right version of workers for the version of Lunatic you're using.
|
|
126
|
+
|
|
127
|
+
A good practice is to add the public/workers folder to your `.gitignore.`
|
|
128
|
+
|
|
129
|
+
#### How it works
|
|
130
|
+
|
|
131
|
+
Workers are loaded into the latest version (version `workersVersion` of package.json) of the public `workers` folder.
|
|
132
|
+
|
|
133
|
+
It's up to you if you want to load them at runtime from another location.
|
|
134
|
+
Simply specify the base url of the workers folder to useLunatic.
|
|
135
|
+
|
|
136
|
+
For example, if your workers are hosted on the server `http://localhost:9090/static/final-workers`.
|
|
137
|
+
We would then have the workers available at the addresses :
|
|
138
|
+
|
|
139
|
+
- `http://localhost:9090/static/final-workers/lunatic-append-worker-0.3.0-experimental.js`
|
|
140
|
+
- `http://localhost:9090/static/final-workers/lunatic-label-worker-0.3.0-experimental.js`
|
|
141
|
+
- `http://localhost:9090/static/final-workers/lunatic-searching-worker-0.3.0-experimental.js`
|
|
142
|
+
|
|
143
|
+
You'll need to specify the `workersBasePath` props in the useLunatic:
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
const { getComponents } = useLunatic(source, data,
|
|
147
|
+
{ features, preferences, ..., workersBasePath: 'http://localhost:9090/static/final-workers' })
|
|
148
|
+
```
|
|
149
|
+
|
|
114
150
|
## Customization
|
|
115
151
|
|
|
116
152
|
By default, the components offered by Lunatic are quite simple with a minimal style. You can customize the fields with your own CSS, but for more complex cases, you can also replace the basic components using the `custom` property that you can pass when calling `useLunatic`.
|
|
@@ -154,6 +190,16 @@ To facilitate expression execution, an `executeExpression()` method is exposed i
|
|
|
154
190
|
|
|
155
191
|
## Convention and Best Practices
|
|
156
192
|
|
|
193
|
+
### Stable Branchs
|
|
194
|
+
|
|
195
|
+
- Stable branches follow the glob pattern `'2.*'`, like `2.6` or `2.7`.
|
|
196
|
+
- We can maintain if needs, the old stable branches
|
|
197
|
+
- `main` branch corresponding to the latest release
|
|
198
|
+
- `develop` branch is temporarily maintained. (actually `develop` is the `2.7` branch = the future main release)
|
|
199
|
+
- `develop` branch will be deleted soon with this new convention
|
|
200
|
+
|
|
201
|
+
### Commits and feature branches
|
|
202
|
+
|
|
157
203
|
- Avoid "default" exports as it impairs readability during import.
|
|
158
204
|
- Comments in the code should be in English.
|
|
159
205
|
- Files containing JSX should use the .jsx (or .tsx) extension.
|
|
@@ -24,10 +24,10 @@ function CheckboxBoolean(_ref) {
|
|
|
24
24
|
id: id,
|
|
25
25
|
onClick: onClick !== null && onClick !== void 0 ? onClick : _function.voidFunction,
|
|
26
26
|
label: label,
|
|
27
|
-
description: description
|
|
27
|
+
description: description,
|
|
28
|
+
invalid: !!errors
|
|
28
29
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
|
|
29
|
-
errors: errors
|
|
30
|
-
activeId: id
|
|
30
|
+
errors: errors
|
|
31
31
|
})]
|
|
32
32
|
});
|
|
33
33
|
}
|
|
@@ -7,6 +7,7 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../../commons/components/lunatic-component-without-label"));
|
|
8
8
|
var _useOnHandleChange = _interopRequireDefault(require("../../commons/use-on-handle-change"));
|
|
9
9
|
var _checkboxBoolean = _interopRequireDefault(require("./html/checkbox-boolean"));
|
|
10
|
+
var _errors = require("../../commons/components/errors/errors");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
13
|
function LunaticCheckboxBoolean(_ref) {
|
|
@@ -29,6 +30,11 @@ function LunaticCheckboxBoolean(_ref) {
|
|
|
29
30
|
response: response,
|
|
30
31
|
value: value
|
|
31
32
|
});
|
|
33
|
+
console.log({
|
|
34
|
+
errors: errors,
|
|
35
|
+
computed: (0, _errors.getComponentErrors)(errors, id),
|
|
36
|
+
id: id
|
|
37
|
+
});
|
|
32
38
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_lunaticComponentWithoutLabel["default"], {
|
|
33
39
|
id: id,
|
|
34
40
|
preferences: preferences,
|
|
@@ -45,7 +51,7 @@ function LunaticCheckboxBoolean(_ref) {
|
|
|
45
51
|
onClick: onChange,
|
|
46
52
|
disabled: disabled,
|
|
47
53
|
label: label,
|
|
48
|
-
errors: errors
|
|
54
|
+
errors: (0, _errors.getComponentErrors)(errors, id)
|
|
49
55
|
})
|
|
50
56
|
});
|
|
51
57
|
}
|
|
@@ -4,11 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
7
|
var _commons = require("../commons");
|
|
9
8
|
require("./checkbox.scss");
|
|
10
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
10
|
function CheckboxGroupContent(_ref) {
|
|
13
11
|
var options = _ref.options,
|
|
14
12
|
id = _ref.id;
|
|
@@ -10,7 +10,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
10
10
|
function CheckboxGroupContent(_ref) {
|
|
11
11
|
var options = _ref.options,
|
|
12
12
|
id = _ref.id,
|
|
13
|
-
shortcut = _ref.shortcut
|
|
13
|
+
shortcut = _ref.shortcut,
|
|
14
|
+
invalid = _ref.invalid;
|
|
14
15
|
var maxIndex = options.length;
|
|
15
16
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
16
17
|
children: options.map(function (option, index) {
|
|
@@ -30,7 +31,8 @@ function CheckboxGroupContent(_ref) {
|
|
|
30
31
|
label: label,
|
|
31
32
|
description: description,
|
|
32
33
|
shortcut: shortcut,
|
|
33
|
-
codeModality: shortcut ? codeModality : undefined
|
|
34
|
+
codeModality: shortcut ? codeModality : undefined,
|
|
35
|
+
invalid: invalid
|
|
34
36
|
})
|
|
35
37
|
}, checkboxId);
|
|
36
38
|
})
|
|
@@ -23,10 +23,10 @@ function CheckboxGroup(_ref) {
|
|
|
23
23
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_checkboxGroupContent["default"], {
|
|
24
24
|
id: id,
|
|
25
25
|
options: options,
|
|
26
|
-
shortcut: shortcut
|
|
26
|
+
shortcut: shortcut,
|
|
27
|
+
invalid: !!errors
|
|
27
28
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
|
|
28
|
-
errors: errors
|
|
29
|
-
activeId: id
|
|
29
|
+
errors: errors
|
|
30
30
|
})]
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -7,6 +7,7 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../../commons/components/lunatic-component-without-label"));
|
|
9
9
|
var _checkboxGroup = _interopRequireDefault(require("./html/checkbox-group"));
|
|
10
|
+
var _errors = require("../../commons/components/errors/errors");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
13
|
function LunaticCheckboxGroup(_ref) {
|
|
@@ -53,7 +54,7 @@ function LunaticCheckboxGroup(_ref) {
|
|
|
53
54
|
id: id,
|
|
54
55
|
options: options,
|
|
55
56
|
label: label,
|
|
56
|
-
errors: errors,
|
|
57
|
+
errors: (0, _errors.getComponentErrors)(errors, id),
|
|
57
58
|
shortcut: shortcut
|
|
58
59
|
})
|
|
59
60
|
});
|
|
@@ -7,6 +7,7 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../../commons/components/lunatic-component-without-label"));
|
|
8
8
|
var _useOnHandleChange = _interopRequireDefault(require("../../commons/use-on-handle-change"));
|
|
9
9
|
var _checkboxOne = _interopRequireDefault(require("./html/checkbox-one"));
|
|
10
|
+
var _errors = require("../../commons/components/errors/errors");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
13
|
function LunaticCheckboxOne(_ref) {
|
|
@@ -45,7 +46,7 @@ function LunaticCheckboxOne(_ref) {
|
|
|
45
46
|
className: "lunatic-checkbox-one",
|
|
46
47
|
options: options,
|
|
47
48
|
value: value,
|
|
48
|
-
errors: errors,
|
|
49
|
+
errors: (0, _errors.getComponentErrors)(errors, id),
|
|
49
50
|
onSelect: onSelect,
|
|
50
51
|
label: label,
|
|
51
52
|
shortcut: shortcut
|
|
@@ -20,7 +20,8 @@ function CheckboxOption(_ref) {
|
|
|
20
20
|
label = _ref.label,
|
|
21
21
|
description = _ref.description,
|
|
22
22
|
codeModality = _ref.codeModality,
|
|
23
|
-
shortcut = _ref.shortcut
|
|
23
|
+
shortcut = _ref.shortcut,
|
|
24
|
+
invalid = _ref.invalid;
|
|
24
25
|
var onClickOption = (0, _react.useCallback)(function () {
|
|
25
26
|
onClick(!checked);
|
|
26
27
|
}, [checked, onClick]);
|
|
@@ -41,6 +42,7 @@ function CheckboxOption(_ref) {
|
|
|
41
42
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
42
43
|
id: id,
|
|
43
44
|
role: "checkbox",
|
|
45
|
+
"aria-invalid": invalid,
|
|
44
46
|
className: "lunatic-input-checkbox",
|
|
45
47
|
"aria-checked": checked,
|
|
46
48
|
tabIndex: 0,
|
|
@@ -21,8 +21,7 @@ function ComboBoxContainer(_ref) {
|
|
|
21
21
|
id: "".concat(classNamePrefix !== null && classNamePrefix !== void 0 ? classNamePrefix : 'lunatic', "-combo-box-container-").concat(id),
|
|
22
22
|
className: (0, _classnames["default"])(className, "".concat(classNamePrefix !== null && classNamePrefix !== void 0 ? classNamePrefix : 'lunatic', "-combo-box-container"), "".concat(classNamePrefix !== null && classNamePrefix !== void 0 ? classNamePrefix : 'lunatic', "-suggester-").concat(classStyle), "lunatic-suggester-default-style", classStyle),
|
|
23
23
|
children: [children, errors && /*#__PURE__*/(0, _jsxRuntime.jsx)(_errors["default"], {
|
|
24
|
-
errors: errors
|
|
25
|
-
activeId: id
|
|
24
|
+
errors: errors
|
|
26
25
|
})]
|
|
27
26
|
});
|
|
28
27
|
}
|
|
@@ -131,7 +131,6 @@ function ComboBox(_ref) {
|
|
|
131
131
|
children: messageError
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
console.log(readOnly);
|
|
135
134
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_comboBoxContainer["default"], {
|
|
136
135
|
id: id,
|
|
137
136
|
className: className,
|
|
@@ -163,7 +162,8 @@ function ComboBox(_ref) {
|
|
|
163
162
|
selectedIndex: selectedIndex,
|
|
164
163
|
options: options,
|
|
165
164
|
onChange: handleChange,
|
|
166
|
-
classNamePrefix: classNamePrefix
|
|
165
|
+
classNamePrefix: classNamePrefix,
|
|
166
|
+
invalid: !!errors
|
|
167
167
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_panel.Panel, {
|
|
168
168
|
optionRenderer: optionRenderer,
|
|
169
169
|
options: options,
|
|
@@ -29,7 +29,8 @@ function LabelOrInput(props) {
|
|
|
29
29
|
readOnly = props.readOnly,
|
|
30
30
|
id = props.id,
|
|
31
31
|
focused = props.focused,
|
|
32
|
-
onChange = props.onChange
|
|
32
|
+
onChange = props.onChange,
|
|
33
|
+
invalid = props.invalid;
|
|
33
34
|
if (displayLabel) {
|
|
34
35
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_labelSelection["default"], {
|
|
35
36
|
labelRenderer: labelRenderer,
|
|
@@ -42,6 +43,7 @@ function LabelOrInput(props) {
|
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_input["default"], {
|
|
46
|
+
invalid: invalid,
|
|
45
47
|
id: "combobox-input-".concat(id),
|
|
46
48
|
className: "lunatic-combo-box-input",
|
|
47
49
|
onChange: onChange,
|
|
@@ -20,7 +20,8 @@ function Input(_ref) {
|
|
|
20
20
|
id = _ref.id,
|
|
21
21
|
labelledBy = _ref.labelledBy,
|
|
22
22
|
focused = _ref.focused,
|
|
23
|
-
className = _ref.className
|
|
23
|
+
className = _ref.className,
|
|
24
|
+
invalid = _ref.invalid;
|
|
24
25
|
var inputEl = (0, _react.useRef)(null);
|
|
25
26
|
(0, _react.useEffect)(function () {
|
|
26
27
|
if (inputEl.current && focused) {
|
|
@@ -41,6 +42,7 @@ function Input(_ref) {
|
|
|
41
42
|
onChange: onChange,
|
|
42
43
|
value: value,
|
|
43
44
|
"aria-label": "lunatic-combo-box",
|
|
45
|
+
"aria-invalid": invalid,
|
|
44
46
|
title: "combo-box",
|
|
45
47
|
autoComplete: "off",
|
|
46
48
|
autoCapitalize: "off",
|
|
@@ -23,7 +23,8 @@ function Selection(_ref) {
|
|
|
23
23
|
editable = _ref.editable,
|
|
24
24
|
labelId = _ref.labelId,
|
|
25
25
|
id = _ref.id,
|
|
26
|
-
classNamePrefix = _ref.classNamePrefix
|
|
26
|
+
classNamePrefix = _ref.classNamePrefix,
|
|
27
|
+
invalid = _ref.invalid;
|
|
27
28
|
var onChangeEx = (0, _react.useCallback)(function (e) {
|
|
28
29
|
onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value);
|
|
29
30
|
}, [onChange]);
|
|
@@ -34,6 +35,7 @@ function Selection(_ref) {
|
|
|
34
35
|
"aria-owns": "".concat(id, "-list"),
|
|
35
36
|
classNamePrefix: classNamePrefix,
|
|
36
37
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LabelOrInput.LabelOrInput, {
|
|
38
|
+
invalid: invalid,
|
|
37
39
|
labelRenderer: labelRenderer,
|
|
38
40
|
placeholder: placeholder,
|
|
39
41
|
selectedIndex: selectedIndex,
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
+
exports.getComponentErrors = getComponentErrors;
|
|
7
8
|
require("./errors.scss");
|
|
8
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
10
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
@@ -12,19 +13,17 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
12
13
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
14
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
14
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
+
/**
|
|
17
|
+
* Display a list of error as simple red text
|
|
18
|
+
*/
|
|
15
19
|
function Errors(_ref) {
|
|
16
|
-
var errors = _ref.errors
|
|
17
|
-
activeId = _ref.activeId;
|
|
20
|
+
var errors = _ref.errors;
|
|
18
21
|
if (!errors) {
|
|
19
22
|
return null;
|
|
20
23
|
}
|
|
21
|
-
var activeErrors = getActiveErrors(errors, activeId);
|
|
22
|
-
if (!activeErrors) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
24
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
26
25
|
className: "lunatic-errors",
|
|
27
|
-
children:
|
|
26
|
+
children: errors.map(function (_ref2) {
|
|
28
27
|
var id = _ref2.id,
|
|
29
28
|
errorMessage = _ref2.errorMessage;
|
|
30
29
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -34,16 +33,19 @@ function Errors(_ref) {
|
|
|
34
33
|
})
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
|
-
function
|
|
36
|
+
function getComponentErrors(errors, componentId) {
|
|
37
|
+
if (!componentId || !errors) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
38
40
|
var activeErrors = Object.entries(errors).find(function (_ref3) {
|
|
39
41
|
var _ref4 = _slicedToArray(_ref3, 1),
|
|
40
42
|
k = _ref4[0];
|
|
41
|
-
return
|
|
43
|
+
return componentId === null || componentId === void 0 ? void 0 : componentId.trim().endsWith(k);
|
|
42
44
|
});
|
|
43
45
|
if (Array.isArray(activeErrors) && Array.isArray(activeErrors[1])) {
|
|
44
46
|
return activeErrors[1];
|
|
45
47
|
}
|
|
46
|
-
return
|
|
48
|
+
return undefined;
|
|
47
49
|
}
|
|
48
50
|
var _default = Errors;
|
|
49
51
|
exports["default"] = _default;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
4
|
var _react = require("@testing-library/react");
|
|
4
5
|
var _vitest = require("vitest");
|
|
5
|
-
var _errors =
|
|
6
|
+
var _errors = _interopRequireWildcard(require("./errors"));
|
|
6
7
|
var _typeSource = require("../../../../use-lunatic/type-source");
|
|
7
8
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
-
function
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
9
11
|
(0, _vitest.describe)('Errors component', function () {
|
|
10
12
|
var errors = {
|
|
11
13
|
id1: [{
|
|
@@ -28,16 +30,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
28
30
|
};
|
|
29
31
|
(0, _vitest.it)('renders null when no active errors', function () {
|
|
30
32
|
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_errors["default"], {
|
|
31
|
-
errors: errors,
|
|
32
|
-
activeId: "id3"
|
|
33
|
+
errors: (0, _errors.getComponentErrors)(errors, 'id3')
|
|
33
34
|
})),
|
|
34
35
|
container = _render.container;
|
|
35
36
|
(0, _vitest.expect)(container.firstChild).toBeNull();
|
|
36
37
|
});
|
|
37
38
|
(0, _vitest.it)('renders active errors', function () {
|
|
38
39
|
var _render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_errors["default"], {
|
|
39
|
-
errors: errors,
|
|
40
|
-
activeId: "id2"
|
|
40
|
+
errors: (0, _errors.getComponentErrors)(errors, 'id2')
|
|
41
41
|
})),
|
|
42
42
|
getByText = _render2.getByText;
|
|
43
43
|
(0, _vitest.expect)(getByText('Error 2 message')).toBeInTheDocument();
|
|
@@ -47,6 +47,7 @@ exports[`ComponentSet > renders without crashing 1`] = `
|
|
|
47
47
|
</span>
|
|
48
48
|
</label>
|
|
49
49
|
<input
|
|
50
|
+
aria-invalid="false"
|
|
50
51
|
aria-labelledby="label-toto1"
|
|
51
52
|
autocomplete="off"
|
|
52
53
|
id="toto1"
|
|
@@ -108,6 +109,7 @@ exports[`ComponentSet > should handle readOnly in sub-components 1`] = `
|
|
|
108
109
|
</span>
|
|
109
110
|
</label>
|
|
110
111
|
<input
|
|
112
|
+
aria-invalid="false"
|
|
111
113
|
aria-labelledby="label-toto1"
|
|
112
114
|
autocomplete="off"
|
|
113
115
|
id="toto1"
|
|
@@ -7,6 +7,7 @@ exports.ComponentSet = void 0;
|
|
|
7
7
|
exports.ComponentSetBase = ComponentSetBase;
|
|
8
8
|
var _commons = require("../../commons");
|
|
9
9
|
var _componentSetLegend = require("./component-set-legend");
|
|
10
|
+
var _errors = require("../../commons/components/errors/errors");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
12
|
function ComponentSetBase(_ref) {
|
|
12
13
|
var id = _ref.id,
|
|
@@ -20,8 +21,7 @@ function ComponentSetBase(_ref) {
|
|
|
20
21
|
id: labelId,
|
|
21
22
|
children: legendText
|
|
22
23
|
}), children, /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
|
|
23
|
-
errors: errors,
|
|
24
|
-
activeId: id
|
|
24
|
+
errors: (0, _errors.getComponentErrors)(errors, id)
|
|
25
25
|
})]
|
|
26
26
|
});
|
|
27
27
|
}
|
|
@@ -6,6 +6,7 @@ exports[`Datepicker > renders without crashing 1`] = `
|
|
|
6
6
|
class="lunatic-input"
|
|
7
7
|
>
|
|
8
8
|
<input
|
|
9
|
+
aria-invalid="false"
|
|
9
10
|
aria-labelledby="lunatic-datepicker-datepicker"
|
|
10
11
|
class="lunatic-datepicker"
|
|
11
12
|
id="datepicker"
|
|
@@ -22,6 +23,7 @@ exports[`Datepicker > should handle readOnly 1`] = `
|
|
|
22
23
|
class="lunatic-input"
|
|
23
24
|
>
|
|
24
25
|
<input
|
|
26
|
+
aria-invalid="false"
|
|
25
27
|
aria-labelledby="lunatic-datepicker-Datepicker"
|
|
26
28
|
class="lunatic-datepicker readOnly"
|
|
27
29
|
id="Datepicker"
|
|
@@ -15,7 +15,8 @@ function DatepickerInput(_ref) {
|
|
|
15
15
|
value = _ref.value,
|
|
16
16
|
onChange = _ref.onChange,
|
|
17
17
|
min = _ref.min,
|
|
18
|
-
max = _ref.max
|
|
18
|
+
max = _ref.max,
|
|
19
|
+
invalid = _ref.invalid;
|
|
19
20
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
20
21
|
id: id,
|
|
21
22
|
className: (0, _classnames["default"])('lunatic-datepicker', {
|
|
@@ -29,7 +30,8 @@ function DatepickerInput(_ref) {
|
|
|
29
30
|
value: value,
|
|
30
31
|
onChange: onChange,
|
|
31
32
|
min: min,
|
|
32
|
-
max: max
|
|
33
|
+
max: max,
|
|
34
|
+
"aria-invalid": invalid
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
37
|
var _default = DatepickerInput;
|
|
@@ -42,10 +42,10 @@ function Datepicker(_ref) {
|
|
|
42
42
|
value: value,
|
|
43
43
|
onChange: handleChange,
|
|
44
44
|
min: min,
|
|
45
|
-
max: max
|
|
45
|
+
max: max,
|
|
46
|
+
invalid: !!errors
|
|
46
47
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
|
|
47
|
-
errors: errors
|
|
48
|
-
activeId: id
|
|
48
|
+
errors: errors
|
|
49
49
|
})]
|
|
50
50
|
});
|
|
51
51
|
}
|
|
@@ -8,6 +8,7 @@ var _datepicker = _interopRequireDefault(require("./html/datepicker"));
|
|
|
8
8
|
var _commons = require("../commons");
|
|
9
9
|
var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../commons/components/lunatic-component-without-label"));
|
|
10
10
|
var _useOnHandleChange = _interopRequireDefault(require("../commons/use-on-handle-change"));
|
|
11
|
+
var _errors = require("../commons/components/errors/errors");
|
|
11
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
14
|
var LunaticDatepicker = function LunaticDatepicker(props) {
|
|
@@ -52,7 +53,7 @@ var LunaticDatepicker = function LunaticDatepicker(props) {
|
|
|
52
53
|
max: max,
|
|
53
54
|
label: label,
|
|
54
55
|
description: description,
|
|
55
|
-
errors: errors
|
|
56
|
+
errors: (0, _errors.getComponentErrors)(errors, id)
|
|
56
57
|
})
|
|
57
58
|
});
|
|
58
59
|
};
|
|
@@ -8,6 +8,7 @@ var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../commons/c
|
|
|
8
8
|
var _useOnHandleChange = _interopRequireDefault(require("../commons/use-on-handle-change"));
|
|
9
9
|
var _dropdown = _interopRequireDefault(require("./html/dropdown"));
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
var _errors = require("../commons/components/errors/errors");
|
|
11
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
14
|
function LunaticDropdown(_ref) {
|
|
@@ -51,7 +52,7 @@ function LunaticDropdown(_ref) {
|
|
|
51
52
|
onSelect: onChange,
|
|
52
53
|
value: value,
|
|
53
54
|
className: (0, _classnames["default"])(className, 'lunatic-dropdown'),
|
|
54
|
-
errors: errors,
|
|
55
|
+
errors: (0, _errors.getComponentErrors)(errors, id),
|
|
55
56
|
label: label,
|
|
56
57
|
readOnly: readOnly
|
|
57
58
|
})
|
package/lib/components/index.js
CHANGED
|
@@ -96,7 +96,7 @@ Object.defineProperty(exports, "Modal", {
|
|
|
96
96
|
Object.defineProperty(exports, "PairwiseLinks", {
|
|
97
97
|
enumerable: true,
|
|
98
98
|
get: function get() {
|
|
99
|
-
return _pairwiseLinks
|
|
99
|
+
return _pairwiseLinks["default"];
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
Object.defineProperty(exports, "QuestionContext", {
|
|
@@ -174,7 +174,7 @@ Object.defineProperty(exports, "Switch", {
|
|
|
174
174
|
Object.defineProperty(exports, "Table", {
|
|
175
175
|
enumerable: true,
|
|
176
176
|
get: function get() {
|
|
177
|
-
return
|
|
177
|
+
return _table["default"];
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
Object.defineProperty(exports, "Textarea", {
|
|
@@ -195,7 +195,7 @@ var _inputNumber = _interopRequireDefault(require("./input-number"));
|
|
|
195
195
|
var _filterDescription = _interopRequireDefault(require("./filter-description"));
|
|
196
196
|
var _loop = require("./loop/loop");
|
|
197
197
|
var _modalControls = _interopRequireDefault(require("./modal-controls"));
|
|
198
|
-
var _pairwiseLinks = require("./pairwise-links
|
|
198
|
+
var _pairwiseLinks = _interopRequireDefault(require("./pairwise-links"));
|
|
199
199
|
var _radio = _interopRequireDefault(require("./radio"));
|
|
200
200
|
var _rosterForLoop = require("./loop/roster-for-loop/roster-for-loop");
|
|
201
201
|
var _sequence = _interopRequireDefault(require("./sequence"));
|
|
@@ -205,7 +205,7 @@ var _switch = _interopRequireDefault(require("./switch"));
|
|
|
205
205
|
var _textarea = _interopRequireDefault(require("./textarea"));
|
|
206
206
|
var _suggesterLoaderWidget = _interopRequireDefault(require("./suggester-loader-widget"));
|
|
207
207
|
var _roundabout = _interopRequireDefault(require("./roundabout"));
|
|
208
|
-
var
|
|
208
|
+
var _table = _interopRequireDefault(require("./table"));
|
|
209
209
|
var _lunaticComponentSet = require("./component-set/lunatic-component-set");
|
|
210
210
|
var _duration = _interopRequireDefault(require("./duration"));
|
|
211
211
|
var _summary = require("./summary");
|
|
@@ -6,6 +6,7 @@ exports[`Input > renders without crashing 1`] = `
|
|
|
6
6
|
class="lunatic-input"
|
|
7
7
|
>
|
|
8
8
|
<input
|
|
9
|
+
aria-invalid="false"
|
|
9
10
|
aria-labelledby="label-input"
|
|
10
11
|
autocomplete="off"
|
|
11
12
|
id="input"
|
|
@@ -22,6 +23,7 @@ exports[`Input > should handle readOnly 1`] = `
|
|
|
22
23
|
class="lunatic-input"
|
|
23
24
|
>
|
|
24
25
|
<input
|
|
26
|
+
aria-invalid="false"
|
|
25
27
|
aria-labelledby="label-number"
|
|
26
28
|
autocomplete="off"
|
|
27
29
|
id="number"
|
|
@@ -44,10 +44,10 @@ function Input(_ref) {
|
|
|
44
44
|
onChange: handleChange,
|
|
45
45
|
"aria-required": required,
|
|
46
46
|
required: required,
|
|
47
|
-
maxLength: maxLength
|
|
47
|
+
maxLength: maxLength,
|
|
48
|
+
"aria-invalid": !!errors
|
|
48
49
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
|
|
49
|
-
errors: errors
|
|
50
|
-
activeId: id
|
|
50
|
+
errors: errors
|
|
51
51
|
})]
|
|
52
52
|
});
|
|
53
53
|
}
|
|
@@ -7,6 +7,7 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _input = _interopRequireDefault(require("./html/input"));
|
|
8
8
|
var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../commons/components/lunatic-component-without-label"));
|
|
9
9
|
var _useOnHandleChange = _interopRequireDefault(require("../commons/use-on-handle-change"));
|
|
10
|
+
var _errors = require("../commons/components/errors/errors");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
13
|
function LunaticInput(props) {
|
|
@@ -47,7 +48,7 @@ function LunaticInput(props) {
|
|
|
47
48
|
onChange: onChange,
|
|
48
49
|
label: label,
|
|
49
50
|
disabled: disabled,
|
|
50
|
-
errors: errors,
|
|
51
|
+
errors: (0, _errors.getComponentErrors)(errors, id),
|
|
51
52
|
required: required,
|
|
52
53
|
maxLength: maxLength,
|
|
53
54
|
readOnly: readOnly
|
|
@@ -6,13 +6,13 @@ exports[`InputNumber > renders without crashing 1`] = `
|
|
|
6
6
|
class="lunatic-input-number"
|
|
7
7
|
>
|
|
8
8
|
<input
|
|
9
|
+
aria-invalid="false"
|
|
9
10
|
aria-labelledby="label-input"
|
|
10
11
|
class=""
|
|
11
12
|
id="input"
|
|
12
13
|
inputmode="numeric"
|
|
13
14
|
lang="en"
|
|
14
15
|
required=""
|
|
15
|
-
step="1"
|
|
16
16
|
type="text"
|
|
17
17
|
value=""
|
|
18
18
|
/>
|
|
@@ -26,6 +26,7 @@ exports[`InputNumber > should handle readOnly 1`] = `
|
|
|
26
26
|
class="lunatic-input-number"
|
|
27
27
|
>
|
|
28
28
|
<input
|
|
29
|
+
aria-invalid="false"
|
|
29
30
|
aria-labelledby="label-number"
|
|
30
31
|
class=""
|
|
31
32
|
id="number"
|
|
@@ -33,7 +34,6 @@ exports[`InputNumber > should handle readOnly 1`] = `
|
|
|
33
34
|
lang="en"
|
|
34
35
|
readonly=""
|
|
35
36
|
required=""
|
|
36
|
-
step="1"
|
|
37
37
|
type="text"
|
|
38
38
|
value="123"
|
|
39
39
|
/>
|