@inseefr/lunatic 2.7.0-rc.5 → 2.7.2
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 +45 -11
- package/lib/components/checkbox/checkbox-boolean/html/checkbox-boolean.js +3 -3
- package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +2 -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 -2
- 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/DatepickerField.js +47 -0
- package/lib/components/datepicker/html/__snapshots__/datepicker.spec.tsx.snap +209 -17
- package/lib/components/datepicker/html/datepicker.js +104 -21
- package/lib/components/datepicker/html/datepicker.scss +19 -1
- package/lib/components/datepicker/html/datepicker.spec.js +71 -23
- package/lib/components/datepicker/lunatic-datepicker.js +5 -2
- package/lib/components/dropdown/lunatic-dropdown.js +2 -1
- package/lib/components/duration/duration.js +6 -7
- package/lib/components/duration/duration.scss +6 -14
- package/lib/components/duration/durationInput.js +14 -8
- package/lib/components/duration/durationUtils.js +38 -8
- 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/roster-for-loop/__snapshots__/roster-for-loop.spec.tsx.snap +88 -0
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +7 -3
- package/lib/components/loop/roster-for-loop/roster-for-loop.spec.js +46 -0
- package/lib/components/lunatic-components.js +2 -11
- 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 +5 -5
- package/lib/components/suggester/idb-suggester/check-store.js +6 -3
- package/lib/components/suggester/idb-suggester/idb-suggester.js +8 -7
- package/lib/components/suggester/idb-suggester/suggester-status.js +1 -4
- package/lib/components/suggester/lunatic-suggester.js +7 -4
- package/lib/components/suggester/searching/create-searching.js +5 -5
- package/lib/components/switch/html/switch.js +2 -2
- package/lib/components/switch/lunatic-switch.js +2 -1
- package/lib/components/table/lunatic-table.js +2 -2
- 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/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/DatepickerField.d.ts +12 -0
- package/lib/src/components/datepicker/html/datepicker.d.ts +4 -3
- package/lib/src/components/datepicker/lunatic-datepicker.d.ts +1 -0
- 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/duration/durationInput.d.ts +6 -2
- package/lib/src/components/duration/durationUtils.d.ts +24 -7
- 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/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/check-store.d.ts +5 -2
- package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +5 -2
- package/lib/src/components/suggester/idb-suggester/suggester-status.d.ts +1 -4
- 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/textarea/html/textarea.d.ts +3 -2
- package/lib/src/components/type.d.ts +5 -3
- package/lib/src/hooks/use-auto-focus.d.ts +6 -0
- package/lib/src/use-lunatic/actions.d.ts +2 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +383 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +1 -1
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.spec.d.ts +1 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +20 -0
- package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +4 -0
- package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +1 -0
- package/lib/src/use-lunatic/type.d.ts +1 -0
- package/lib/src/use-lunatic/use-lunatic.d.ts +9 -5
- package/lib/src/use-lunatic/use-suggesters.d.ts +2 -1
- package/lib/src/utils/suggester-workers/append-to-index/create-append-task.d.ts +2 -2
- package/lib/src/utils/suggester-workers/worker-path.d.ts +1 -1
- package/lib/stories/behaviour/cleaning/source.json +151 -0
- package/lib/stories/behaviour/cleaning/test.stories.js +82 -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/stories/date-picker/datepicker.stories.js +32 -29
- package/lib/stories/duration/duration.stories.js +4 -4
- package/lib/stories/duration/{source.json → mois.json} +1 -1
- package/lib/stories/duration/{source1.json → time.json} +1 -1
- package/lib/use-lunatic/commons/fill-components/fill-component-required.js +23 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +1 -1
- package/lib/use-lunatic/commons/fill-components/fill-component-value.spec.js +67 -0
- package/lib/use-lunatic/commons/fill-components/fill-components.js +2 -1
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +2 -0
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +20 -0
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +15 -1
- package/lib/use-lunatic/initial-state.js +2 -1
- package/lib/use-lunatic/reducer/reduce-on-init.js +4 -2
- package/lib/use-lunatic/use-lunatic.js +12 -10
- package/lib/use-lunatic/use-suggesters.js +54 -37
- package/lib/utils/env.js +9 -1
- package/lib/utils/suggester-workers/append-to-index/create-append-task.js +4 -3
- package/lib/utils/suggester-workers/{create-worker-ts.js → create-worker.js} +10 -1
- package/lib/utils/suggester-workers/worker-path.js +5 -4
- package/package.json +20 -10
- package/scripts/build/add-workers-to-public.js +31 -31
- package/scripts/build/workers-paths.js +18 -7
- package/workers-release/{lunatic-append-worker-0.3.0-experimental.js → lunatic-append-worker-0.3.0.js} +1 -1
- package/workers-release/{lunatic-label-worker-0.3.0-experimental.js → lunatic-label-worker-0.3.0.js} +1 -1
- package/workers-release/{lunatic-searching-worker-0.3.0-experimental.js → lunatic-search-worker-0.3.0.js} +1 -1
- package/lib/components/datepicker/html/datepicker-container.js +0 -17
- package/lib/components/datepicker/html/datepicker-input.js +0 -35
- package/lib/env.d.js +0 -1
- package/lib/src/components/datepicker/html/datepicker-container.d.ts +0 -3
- package/lib/src/components/datepicker/html/datepicker-input.d.ts +0 -13
- package/lib/src/utils/get-component-value.d.ts +0 -5
- package/lib/utils/get-component-value.js +0 -34
- package/lib/utils/get-component-value.test.js +0 -57
- /package/lib/src/{utils/get-component-value.test.d.ts → components/loop/roster-for-loop/roster-for-loop.spec.d.ts} +0 -0
- /package/lib/src/utils/suggester-workers/{create-worker-ts.d.ts → create-worker.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/workers-release/{lunatic-append-worker-0.3.0-experimental.js.LICENSE.txt → lunatic-append-worker-0.3.0.js.LICENSE.txt} +0 -0
- /package/workers-release/{lunatic-label-worker-0.3.0-experimental.js.LICENSE.txt → lunatic-label-worker-0.3.0.js.LICENSE.txt} +0 -0
- /package/workers-release/{lunatic-searching-worker-0.3.0-experimental.js.LICENSE.txt → lunatic-search-worker-0.3.0.js.LICENSE.txt} +0 -0
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
-
function DatepickerContainer(_ref) {
|
|
11
|
-
var children = _ref.children;
|
|
12
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
13
|
-
className: "lunatic-input",
|
|
14
|
-
children: children
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
var _default = exports["default"] = DatepickerContainer;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
-
function DatepickerInput(_ref) {
|
|
11
|
-
var id = _ref.id,
|
|
12
|
-
disabled = _ref.disabled,
|
|
13
|
-
readOnly = _ref.readOnly,
|
|
14
|
-
labelId = _ref.labelId,
|
|
15
|
-
value = _ref.value,
|
|
16
|
-
onChange = _ref.onChange,
|
|
17
|
-
min = _ref.min,
|
|
18
|
-
max = _ref.max;
|
|
19
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
20
|
-
id: id,
|
|
21
|
-
className: (0, _classnames["default"])('lunatic-datepicker', {
|
|
22
|
-
disabled: disabled,
|
|
23
|
-
readOnly: readOnly
|
|
24
|
-
}),
|
|
25
|
-
type: "date",
|
|
26
|
-
"aria-labelledby": labelId,
|
|
27
|
-
readOnly: readOnly,
|
|
28
|
-
disabled: disabled,
|
|
29
|
-
value: value,
|
|
30
|
-
onChange: onChange,
|
|
31
|
-
min: min,
|
|
32
|
-
max: max
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
var _default = exports["default"] = DatepickerInput;
|
package/lib/env.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type ChangeEventHandler } from 'react';
|
|
2
|
-
export type Props = {
|
|
3
|
-
labelId: string;
|
|
4
|
-
id?: string;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
readOnly?: boolean;
|
|
7
|
-
value?: string;
|
|
8
|
-
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
9
|
-
min?: string;
|
|
10
|
-
max?: string;
|
|
11
|
-
};
|
|
12
|
-
declare function DatepickerInput({ id, disabled, readOnly, labelId, value, onChange, min, max, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export default DatepickerInput;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract the value associated with a component
|
|
3
|
-
* If the component expect multiple values (it has a responses property) then extract a map of values
|
|
4
|
-
*/
|
|
5
|
-
export declare function getComponentValue(component: unknown, valueMap: Record<string, unknown>, rowIndex?: number): unknown;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getComponentValue = getComponentValue;
|
|
7
|
-
var _component = require("../use-lunatic/commons/component");
|
|
8
|
-
/**
|
|
9
|
-
* Extract the value associated with a component
|
|
10
|
-
* If the component expect multiple values (it has a responses property) then extract a map of values
|
|
11
|
-
*/
|
|
12
|
-
function getComponentValue(component, valueMap, rowIndex) {
|
|
13
|
-
if ((0, _component.hasResponse)(component)) {
|
|
14
|
-
var value = valueMap[component.response.name];
|
|
15
|
-
if (Array.isArray(value)) {
|
|
16
|
-
return value[rowIndex !== null && rowIndex !== void 0 ? rowIndex : 0];
|
|
17
|
-
}
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// For checkbox group we need to send the map of values
|
|
22
|
-
if ((0, _component.hasResponses)(component)) {
|
|
23
|
-
var _component$responses$, _component$responses;
|
|
24
|
-
return Object.fromEntries((_component$responses$ = (_component$responses = component.responses) === null || _component$responses === void 0 ? void 0 : _component$responses.map(function (_ref) {
|
|
25
|
-
var response = _ref.response;
|
|
26
|
-
var value = valueMap[response.name];
|
|
27
|
-
if (Array.isArray(value)) {
|
|
28
|
-
return [response.name, value[rowIndex !== null && rowIndex !== void 0 ? rowIndex : 0]];
|
|
29
|
-
}
|
|
30
|
-
return [response.name, value];
|
|
31
|
-
})) !== null && _component$responses$ !== void 0 ? _component$responses$ : []);
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _getComponentValue = require("./get-component-value");
|
|
5
|
-
(0, _vitest.describe)('getComponentValue', function () {
|
|
6
|
-
var componentWithResponse = {
|
|
7
|
-
response: {
|
|
8
|
-
name: 'prenom'
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
var componentWithResponses = {
|
|
12
|
-
responses: [componentWithResponse, {
|
|
13
|
-
response: {
|
|
14
|
-
name: 'nom'
|
|
15
|
-
}
|
|
16
|
-
}]
|
|
17
|
-
};
|
|
18
|
-
(0, _vitest.it)('Should work with simple response', function () {
|
|
19
|
-
(0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponse, {
|
|
20
|
-
prenom: 'John'
|
|
21
|
-
})).toBe('John');
|
|
22
|
-
(0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponse, {})).toBe(undefined);
|
|
23
|
-
(0, _vitest.expect)((0, _getComponentValue.getComponentValue)({}, {
|
|
24
|
-
prenom: 'John'
|
|
25
|
-
})).toBe(undefined);
|
|
26
|
-
});
|
|
27
|
-
(0, _vitest.it)('Should work with simple response as Array', function () {
|
|
28
|
-
(0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponse, {
|
|
29
|
-
prenom: ['John', 'Renaud']
|
|
30
|
-
}, 1)).toBe('Renaud');
|
|
31
|
-
(0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponse, {
|
|
32
|
-
prenom: ['John', 'Renaud']
|
|
33
|
-
}, 3)).toBe(undefined);
|
|
34
|
-
});
|
|
35
|
-
(0, _vitest.it)('Should work with responses', function () {
|
|
36
|
-
(0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponses, {
|
|
37
|
-
prenom: 'John'
|
|
38
|
-
})).toMatchObject({
|
|
39
|
-
prenom: 'John',
|
|
40
|
-
nom: undefined
|
|
41
|
-
});
|
|
42
|
-
(0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponses, {
|
|
43
|
-
prenom: ['John', 'Renaud'],
|
|
44
|
-
nom: ['Insee', 'Metallica']
|
|
45
|
-
}, 1)).toMatchObject({
|
|
46
|
-
prenom: 'Renaud',
|
|
47
|
-
nom: 'Metallica'
|
|
48
|
-
});
|
|
49
|
-
(0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponses, {
|
|
50
|
-
prenom: ['John', 'Renaud'],
|
|
51
|
-
nom: 'Insee'
|
|
52
|
-
}, 1)).toMatchObject({
|
|
53
|
-
prenom: 'Renaud',
|
|
54
|
-
nom: 'Insee'
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.stories.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|