@inseefr/lunatic 2.7.1 → 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 +19 -42
- 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 +8 -3
- 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 +6 -0
- 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 +15 -0
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +9 -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 +7 -3
- 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 +5 -4
- package/lib/utils/suggester-workers/create-worker.js +10 -1
- package/lib/utils/suggester-workers/worker-path.js +29 -0
- package/package.json +24 -11
- package/scripts/build/add-workers-to-public.js +44 -0
- package/scripts/build/workers-paths.js +45 -0
- package/workers-release/lunatic-append-worker-0.3.0.js +2 -0
- package/workers-release/lunatic-append-worker-0.3.0.js.LICENSE.txt +34 -0
- package/workers-release/lunatic-label-worker-0.3.0.js +2 -0
- package/workers-release/lunatic-label-worker-0.3.0.js.LICENSE.txt +13 -0
- package/workers-release/lunatic-search-worker-0.3.0.js +2 -0
- package/workers-release/lunatic-search-worker-0.3.0.js.LICENSE.txt +34 -0
- 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/src/utils/store-tools/worker-path.d.ts +0 -1
- package/lib/utils/get-component-value.js +0 -34
- package/lib/utils/get-component-value.test.js +0 -57
- package/lib/utils/store-tools/worker-path.js +0 -13
- package/lib/utils/suggester-workers/create-worker-ts.js +0 -54
- /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
|
@@ -10,7 +10,9 @@ var _object = require("../../utils/object");
|
|
|
10
10
|
var _formatDuration = require("./formatDuration");
|
|
11
11
|
var _getDurationFromValue = require("./getDurationFromValue");
|
|
12
12
|
var _durationUtils = require("./durationUtils");
|
|
13
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
16
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
17
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
18
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -25,7 +27,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
25
27
|
var DurationInput = function DurationInput(_ref) {
|
|
26
28
|
var value = _ref.value,
|
|
27
29
|
format = _ref.format,
|
|
28
|
-
onChange = _ref.onChange
|
|
30
|
+
onChange = _ref.onChange,
|
|
31
|
+
label = _ref.label;
|
|
29
32
|
// We need to keep an internal state since one field can be empty (null value in duration)
|
|
30
33
|
// but we still send "0" and we don't want the field to display "0"
|
|
31
34
|
var _useState = (0, _react.useState)((0, _getDurationFromValue.getDurationFromValue)(value, format)),
|
|
@@ -39,19 +42,22 @@ var DurationInput = function DurationInput(_ref) {
|
|
|
39
42
|
if (!e.target.checkValidity()) {
|
|
40
43
|
return;
|
|
41
44
|
}
|
|
42
|
-
var fieldValue = Number.isNaN(e.target.valueAsNumber) ? null : e.target.valueAsNumber;
|
|
45
|
+
var fieldValue = (0, _durationUtils.clampDuration)(Number.isNaN(e.target.valueAsNumber) ? null : e.target.valueAsNumber, unit);
|
|
43
46
|
var newDuration = _objectSpread(_objectSpread({}, duration), {}, _defineProperty({}, unit, fieldValue));
|
|
44
47
|
onChange((0, _formatDuration.formatDuration)(newDuration));
|
|
45
48
|
setDuration(newDuration);
|
|
46
49
|
};
|
|
47
50
|
};
|
|
48
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
49
|
-
className: "
|
|
50
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("
|
|
51
|
-
|
|
51
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("fieldset", {
|
|
52
|
+
className: (0, _classnames["default"])('lunatic-input'),
|
|
53
|
+
children: [label && /*#__PURE__*/(0, _jsxRuntime.jsx)("legend", {
|
|
54
|
+
children: label
|
|
55
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
56
|
+
className: "duration-fields",
|
|
52
57
|
children: (0, _object.objectKeys)(duration).map(function (unit) {
|
|
53
58
|
var _duration$unit;
|
|
54
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
59
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
60
|
+
className: "duration-field",
|
|
55
61
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
|
|
56
62
|
htmlFor: "".concat(unit, "Input"),
|
|
57
63
|
className: "input-label",
|
|
@@ -65,7 +71,7 @@ var DurationInput = function DurationInput(_ref) {
|
|
|
65
71
|
}, _durationUtils.propsByUnit[unit]))]
|
|
66
72
|
}, unit);
|
|
67
73
|
})
|
|
68
|
-
})
|
|
74
|
+
})]
|
|
69
75
|
});
|
|
70
76
|
};
|
|
71
77
|
var _default = exports["default"] = DurationInput;
|
|
@@ -3,22 +3,39 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.clampDuration = clampDuration;
|
|
6
7
|
exports.propsByUnit = exports.labelByUnit = void 0;
|
|
7
8
|
var propsByUnit = exports.propsByUnit = {
|
|
8
9
|
hours: {
|
|
9
|
-
min:
|
|
10
|
-
max:
|
|
10
|
+
min: 0,
|
|
11
|
+
max: 23,
|
|
12
|
+
size: 2,
|
|
13
|
+
style: {
|
|
14
|
+
width: '2.5em'
|
|
15
|
+
}
|
|
11
16
|
},
|
|
12
17
|
minutes: {
|
|
13
|
-
min:
|
|
14
|
-
max:
|
|
18
|
+
min: 0,
|
|
19
|
+
max: 59,
|
|
20
|
+
size: 2,
|
|
21
|
+
style: {
|
|
22
|
+
width: '2.5em'
|
|
23
|
+
}
|
|
15
24
|
},
|
|
16
25
|
months: {
|
|
17
|
-
min:
|
|
18
|
-
max:
|
|
26
|
+
min: 0,
|
|
27
|
+
max: 11,
|
|
28
|
+
size: 2,
|
|
29
|
+
style: {
|
|
30
|
+
width: '2.5em'
|
|
31
|
+
}
|
|
19
32
|
},
|
|
20
33
|
years: {
|
|
21
|
-
min:
|
|
34
|
+
min: 0,
|
|
35
|
+
size: 4,
|
|
36
|
+
style: {
|
|
37
|
+
width: '4em'
|
|
38
|
+
}
|
|
22
39
|
}
|
|
23
40
|
};
|
|
24
41
|
var labelByUnit = exports.labelByUnit = {
|
|
@@ -26,4 +43,17 @@ var labelByUnit = exports.labelByUnit = {
|
|
|
26
43
|
minutes: 'Minutes :',
|
|
27
44
|
months: 'Mois : ',
|
|
28
45
|
years: 'Années :'
|
|
29
|
-
};
|
|
46
|
+
};
|
|
47
|
+
function clampDuration(value, unit) {
|
|
48
|
+
if (value === null) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
var props = propsByUnit[unit];
|
|
52
|
+
if (value < props.min) {
|
|
53
|
+
return props.min;
|
|
54
|
+
}
|
|
55
|
+
if ('max' in props && value > props.max) {
|
|
56
|
+
return props.max;
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
@@ -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
|
/>
|
|
@@ -10,12 +10,6 @@ var _reactNumberFormat = require("react-number-format");
|
|
|
10
10
|
var _i18n = require("../../../i18n");
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
-
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; }
|
|
17
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
18
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
13
|
var InputNumberThousand = function InputNumberThousand(_ref) {
|
|
20
14
|
var id = _ref.id,
|
|
21
15
|
onChange = _ref.onChange,
|
|
@@ -24,14 +18,9 @@ var InputNumberThousand = function InputNumberThousand(_ref) {
|
|
|
24
18
|
readOnly = _ref.readOnly,
|
|
25
19
|
required = _ref.required,
|
|
26
20
|
labelId = _ref.labelId,
|
|
27
|
-
min = _ref.min,
|
|
28
21
|
max = _ref.max,
|
|
29
|
-
decimals = _ref.decimals
|
|
30
|
-
|
|
31
|
-
// Computing step attribute of input according to decimal number
|
|
32
|
-
var _useState = (0, _react.useState)(decimals ? 1 / Math.pow(10, decimals) : 1),
|
|
33
|
-
_useState2 = _slicedToArray(_useState, 1),
|
|
34
|
-
step = _useState2[0];
|
|
22
|
+
decimals = _ref.decimals,
|
|
23
|
+
invalid = _ref.invalid;
|
|
35
24
|
var handleChange = (0, _react.useCallback)(function (e) {
|
|
36
25
|
var _e$floatValue;
|
|
37
26
|
var val = (_e$floatValue = e.floatValue) !== null && _e$floatValue !== void 0 ? _e$floatValue : null;
|
|
@@ -49,9 +38,6 @@ var InputNumberThousand = function InputNumberThousand(_ref) {
|
|
|
49
38
|
}),
|
|
50
39
|
onValueChange: handleChange,
|
|
51
40
|
value: value !== null && value !== void 0 ? value : '',
|
|
52
|
-
min: min,
|
|
53
|
-
max: max,
|
|
54
|
-
step: step,
|
|
55
41
|
"aria-labelledby": labelId,
|
|
56
42
|
disabled: disabled,
|
|
57
43
|
readOnly: readOnly,
|
|
@@ -63,7 +49,8 @@ var InputNumberThousand = function InputNumberThousand(_ref) {
|
|
|
63
49
|
decimalScale: decimals,
|
|
64
50
|
allowLeadingZeros: true,
|
|
65
51
|
thousandSeparator: _i18n.inputNumberPropsI18N.thousandSeparator,
|
|
66
|
-
inputMode: decimals ? 'decimal' : 'numeric'
|
|
52
|
+
inputMode: decimals ? 'decimal' : 'numeric',
|
|
53
|
+
"aria-invalid": invalid
|
|
67
54
|
});
|
|
68
55
|
};
|
|
69
56
|
var _default = exports["default"] = InputNumberThousand;
|
|
@@ -20,7 +20,6 @@ function InputNumber(_ref) {
|
|
|
20
20
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
21
21
|
_ref$readOnly = _ref.readOnly,
|
|
22
22
|
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
23
|
-
min = _ref.min,
|
|
24
23
|
max = _ref.max,
|
|
25
24
|
_ref$decimals = _ref.decimals,
|
|
26
25
|
decimals = _ref$decimals === void 0 ? 0 : _ref$decimals,
|
|
@@ -46,14 +45,13 @@ function InputNumber(_ref) {
|
|
|
46
45
|
readOnly: readOnly,
|
|
47
46
|
required: required,
|
|
48
47
|
labelId: labelId,
|
|
49
|
-
min: min,
|
|
50
48
|
max: max,
|
|
51
|
-
decimals: decimals
|
|
49
|
+
decimals: decimals,
|
|
50
|
+
invalid: !!errors
|
|
52
51
|
}), unit && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
53
52
|
children: unit
|
|
54
53
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
|
|
55
|
-
errors: errors
|
|
56
|
-
activeId: id
|
|
54
|
+
errors: errors
|
|
57
55
|
})]
|
|
58
56
|
});
|
|
59
57
|
}
|
|
@@ -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 _inputNumber = _interopRequireDefault(require("./html/input-number"));
|
|
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 LunaticInputNumber(props) {
|
|
@@ -22,7 +23,6 @@ function LunaticInputNumber(props) {
|
|
|
22
23
|
missing = props.missing,
|
|
23
24
|
missingResponse = props.missingResponse,
|
|
24
25
|
management = props.management,
|
|
25
|
-
min = props.min,
|
|
26
26
|
max = props.max,
|
|
27
27
|
decimals = props.decimals,
|
|
28
28
|
unit = props.unit,
|
|
@@ -51,12 +51,11 @@ function LunaticInputNumber(props) {
|
|
|
51
51
|
label: label,
|
|
52
52
|
disabled: disabled,
|
|
53
53
|
readOnly: readOnly,
|
|
54
|
-
min: min,
|
|
55
54
|
max: max,
|
|
56
55
|
decimals: decimals,
|
|
57
56
|
unit: unit,
|
|
58
57
|
required: required,
|
|
59
|
-
errors: errors
|
|
58
|
+
errors: (0, _errors.getComponentErrors)(errors, id)
|
|
60
59
|
})
|
|
61
60
|
});
|
|
62
61
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Vitest Snapshot v1
|
|
2
|
+
|
|
3
|
+
exports[`RosterForLoop > renders the right number of columns 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<table
|
|
6
|
+
class="lunatic-table"
|
|
7
|
+
id="table-table"
|
|
8
|
+
>
|
|
9
|
+
<tbody
|
|
10
|
+
class="lunatic-table-tbody"
|
|
11
|
+
id="lunatic-table-tbody-table"
|
|
12
|
+
>
|
|
13
|
+
<tr
|
|
14
|
+
class="lunatic-table-tr"
|
|
15
|
+
id="lunatic-table-tr-table-0"
|
|
16
|
+
>
|
|
17
|
+
<td
|
|
18
|
+
class="lunatic-table-td"
|
|
19
|
+
id="lunatic-table-td-jrc3ye5q-QOP-lo6tcvvx-0-0-undefined-undefined"
|
|
20
|
+
>
|
|
21
|
+
<div
|
|
22
|
+
class="field-container"
|
|
23
|
+
>
|
|
24
|
+
<div
|
|
25
|
+
class="field"
|
|
26
|
+
>
|
|
27
|
+
<div
|
|
28
|
+
class="lunatic-input"
|
|
29
|
+
>
|
|
30
|
+
<input
|
|
31
|
+
aria-invalid="false"
|
|
32
|
+
aria-labelledby="label-jrc3ye5q-QOP-lo6tcvvx-0"
|
|
33
|
+
autocomplete="off"
|
|
34
|
+
id="jrc3ye5q-QOP-lo6tcvvx-0"
|
|
35
|
+
maxlength="249"
|
|
36
|
+
type="text"
|
|
37
|
+
value="azeaze"
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</td>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr
|
|
45
|
+
class="lunatic-table-tr"
|
|
46
|
+
id="lunatic-table-tr-table-1"
|
|
47
|
+
>
|
|
48
|
+
<td
|
|
49
|
+
class="lunatic-table-td"
|
|
50
|
+
id="lunatic-table-td-jrc3ye5q-QOP-lo6tcvvx-1-1-undefined-undefined"
|
|
51
|
+
>
|
|
52
|
+
<div
|
|
53
|
+
class="field-container"
|
|
54
|
+
>
|
|
55
|
+
<div
|
|
56
|
+
class="field"
|
|
57
|
+
>
|
|
58
|
+
<div
|
|
59
|
+
class="lunatic-input"
|
|
60
|
+
>
|
|
61
|
+
<input
|
|
62
|
+
aria-invalid="false"
|
|
63
|
+
aria-labelledby="label-jrc3ye5q-QOP-lo6tcvvx-1"
|
|
64
|
+
autocomplete="off"
|
|
65
|
+
id="jrc3ye5q-QOP-lo6tcvvx-1"
|
|
66
|
+
maxlength="249"
|
|
67
|
+
type="text"
|
|
68
|
+
value="azeaze"
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</td>
|
|
74
|
+
</tr>
|
|
75
|
+
</tbody>
|
|
76
|
+
</table>
|
|
77
|
+
<input
|
|
78
|
+
class="button-lunatic"
|
|
79
|
+
type="button"
|
|
80
|
+
value="Ceci est un test"
|
|
81
|
+
/>
|
|
82
|
+
<input
|
|
83
|
+
class="button-lunatic"
|
|
84
|
+
type="button"
|
|
85
|
+
value="Remove row"
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
`;
|
|
@@ -15,6 +15,7 @@ var _tableHeader = require("../../table/table-header");
|
|
|
15
15
|
var _array = require("../../../utils/array");
|
|
16
16
|
var _lunaticComponents = require("../../lunatic-components");
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
var _excluded = ["value", "lines", "handleChange", "declarations", "label", "headers", "iterations", "id", "getComponents"];
|
|
18
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
20
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
21
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -27,6 +28,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
27
28
|
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; }
|
|
28
29
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
29
30
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
31
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
32
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
30
33
|
var DEFAULT_MIN_ROWS = 1;
|
|
31
34
|
var DEFAULT_MAX_ROWS = 12;
|
|
32
35
|
|
|
@@ -42,7 +45,8 @@ var RosterForLoop = exports.RosterForLoop = (0, _commons.createCustomizableLunat
|
|
|
42
45
|
headers = props.headers,
|
|
43
46
|
iterations = props.iterations,
|
|
44
47
|
id = props.id,
|
|
45
|
-
getComponents = props.getComponents
|
|
48
|
+
getComponents = props.getComponents,
|
|
49
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
46
50
|
var min = (lines === null || lines === void 0 ? void 0 : lines.min) || DEFAULT_MIN_ROWS;
|
|
47
51
|
var max = (lines === null || lines === void 0 ? void 0 : lines.max) || DEFAULT_MAX_ROWS;
|
|
48
52
|
var _useState = (0, _react.useState)(iterations),
|
|
@@ -97,7 +101,7 @@ var RosterForLoop = exports.RosterForLoop = (0, _commons.createCustomizableLunat
|
|
|
97
101
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_lunaticComponents.LunaticComponents, {
|
|
98
102
|
components: getComponents(n),
|
|
99
103
|
componentProps: function componentProps(c) {
|
|
100
|
-
return _objectSpread(_objectSpread(_objectSpread({},
|
|
104
|
+
return _objectSpread(_objectSpread(_objectSpread({}, otherProps), c), {}, {
|
|
101
105
|
id: "".concat(c.id, "-").concat(n)
|
|
102
106
|
});
|
|
103
107
|
},
|
|
@@ -110,7 +114,7 @@ var RosterForLoop = exports.RosterForLoop = (0, _commons.createCustomizableLunat
|
|
|
110
114
|
});
|
|
111
115
|
}
|
|
112
116
|
})
|
|
113
|
-
});
|
|
117
|
+
}, n);
|
|
114
118
|
})
|
|
115
119
|
})]
|
|
116
120
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_declarations.DeclarationsDetachable, {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _react = require("@testing-library/react");
|
|
5
|
+
var _rosterForLoop = require("./roster-for-loop");
|
|
6
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
+
(0, _vitest.describe)('RosterForLoop', function () {
|
|
8
|
+
var mockOnChange = _vitest.vi.fn();
|
|
9
|
+
(0, _vitest.beforeEach)(function () {
|
|
10
|
+
mockOnChange.mockClear();
|
|
11
|
+
});
|
|
12
|
+
var getComponents = function getComponents(iteration) {
|
|
13
|
+
return [{
|
|
14
|
+
componentType: 'Input',
|
|
15
|
+
maxLength: 249,
|
|
16
|
+
id: 'jrc3ye5q-QOP-lo6tcvvx',
|
|
17
|
+
response: {
|
|
18
|
+
name: 'TABDYN1'
|
|
19
|
+
},
|
|
20
|
+
iteration: iteration,
|
|
21
|
+
value: 'azeaze'
|
|
22
|
+
}];
|
|
23
|
+
};
|
|
24
|
+
(0, _vitest.it)('renders the right number of columns', function () {
|
|
25
|
+
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_rosterForLoop.RosterForLoop, {
|
|
26
|
+
value: {
|
|
27
|
+
name: ['John Doe', 'Jane Doe']
|
|
28
|
+
},
|
|
29
|
+
handleChange: mockOnChange,
|
|
30
|
+
label: "Ceci est un test",
|
|
31
|
+
id: "table",
|
|
32
|
+
lines: {
|
|
33
|
+
min: 1,
|
|
34
|
+
max: 3
|
|
35
|
+
},
|
|
36
|
+
iterations: 2,
|
|
37
|
+
getComponents: getComponents,
|
|
38
|
+
executeExpression: function executeExpression() {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
})),
|
|
42
|
+
container = _render.container;
|
|
43
|
+
(0, _vitest.expect)(container).toMatchSnapshot();
|
|
44
|
+
(0, _vitest.expect)(_react.screen.getAllByRole('row')).toHaveLength(2);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.LunaticComponents = LunaticComponents;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var lunaticComponents = _interopRequireWildcard(require("./index"));
|
|
9
|
+
var _useAutoFocus = require("../hooks/use-auto-focus");
|
|
9
10
|
var _component = require("../use-lunatic/commons/component");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -33,18 +34,8 @@ function LunaticComponents(_ref) {
|
|
|
33
34
|
} : _ref$wrapper;
|
|
34
35
|
var wrapperRef = (0, _react.useRef)(null);
|
|
35
36
|
var hasComponents = components.length > 0;
|
|
36
|
-
(0, _react.useEffect)(function () {
|
|
37
|
-
var _wrapperRef$current;
|
|
38
|
-
if (!autoFocusKey || !hasComponents || !wrapperRef.current) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
var firstFocusableElement = (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
42
|
-
// The first element can be focusable
|
|
43
|
-
if (firstFocusableElement) {
|
|
44
|
-
return firstFocusableElement.focus();
|
|
45
|
-
}
|
|
46
|
-
}, [autoFocusKey, hasComponents]);
|
|
47
37
|
var WrapperComponent = autoFocusKey ? 'div' : _react.Fragment;
|
|
38
|
+
(0, _useAutoFocus.useAutoFocus)(wrapperRef, hasComponents ? autoFocusKey : undefined);
|
|
48
39
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrapperComponent, {
|
|
49
40
|
ref: WrapperComponent === _react.Fragment ? undefined : wrapperRef,
|
|
50
41
|
children: components.map(function (component, k) {
|
|
@@ -20,7 +20,8 @@ function RadioGroupContent(_ref) {
|
|
|
20
20
|
checkboxStyle = _ref$checkboxStyle === void 0 ? false : _ref$checkboxStyle,
|
|
21
21
|
shortcut = _ref.shortcut,
|
|
22
22
|
disabled = _ref.disabled,
|
|
23
|
-
readOnly = _ref.readOnly
|
|
23
|
+
readOnly = _ref.readOnly,
|
|
24
|
+
invalid = _ref.invalid;
|
|
24
25
|
var onKeyDown = (0, _commons.useOptionsKeydown)(options, onClick);
|
|
25
26
|
var maxIndex = options.length;
|
|
26
27
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
@@ -43,7 +44,8 @@ function RadioGroupContent(_ref) {
|
|
|
43
44
|
codeModality: shortcut ? codeModality : undefined,
|
|
44
45
|
shortcut: shortcut,
|
|
45
46
|
disabled: disabled,
|
|
46
|
-
readOnly: readOnly
|
|
47
|
+
readOnly: readOnly,
|
|
48
|
+
invalid: invalid
|
|
47
49
|
}, radioId);
|
|
48
50
|
})
|
|
49
51
|
});
|
|
@@ -35,10 +35,10 @@ function RadioGroup(_ref) {
|
|
|
35
35
|
options: options,
|
|
36
36
|
shortcut: shortcut,
|
|
37
37
|
disabled: disabled,
|
|
38
|
-
readOnly: readOnly
|
|
38
|
+
readOnly: readOnly,
|
|
39
|
+
invalid: !!errors
|
|
39
40
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
|
|
40
|
-
errors: errors
|
|
41
|
-
activeId: id
|
|
41
|
+
errors: errors
|
|
42
42
|
})]
|
|
43
43
|
});
|
|
44
44
|
}
|
|
@@ -30,7 +30,8 @@ function RadioOption(_ref) {
|
|
|
30
30
|
description = _ref.description,
|
|
31
31
|
shortcut = _ref.shortcut,
|
|
32
32
|
codeModality = _ref.codeModality,
|
|
33
|
-
readOnly = _ref.readOnly
|
|
33
|
+
readOnly = _ref.readOnly,
|
|
34
|
+
invalid = _ref.invalid;
|
|
34
35
|
var spanEl = (0, _react.useRef)(null);
|
|
35
36
|
var Icon = getIcon(checked, checkboxStyle);
|
|
36
37
|
var tabIndex = checked ? 0 : -1;
|
|
@@ -65,6 +66,7 @@ function RadioOption(_ref) {
|
|
|
65
66
|
disabled: disabled,
|
|
66
67
|
readOnly: readOnly
|
|
67
68
|
}),
|
|
69
|
+
"aria-invalid": invalid,
|
|
68
70
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
69
71
|
id: id,
|
|
70
72
|
role: "radio",
|
|
@@ -8,6 +8,7 @@ var _radioGroup = _interopRequireDefault(require("./html/radio-group"));
|
|
|
8
8
|
var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../commons/components/lunatic-component-without-label"));
|
|
9
9
|
var _useOnHandleChange = _interopRequireDefault(require("../commons/use-on-handle-change"));
|
|
10
10
|
var _commons = require("../commons");
|
|
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 LunaticRadioGroup(props) {
|
|
@@ -52,7 +53,7 @@ function LunaticRadioGroup(props) {
|
|
|
52
53
|
value: value,
|
|
53
54
|
onSelect: onChange,
|
|
54
55
|
checkboxStyle: checkboxStyle,
|
|
55
|
-
errors: errors,
|
|
56
|
+
errors: (0, _errors.getComponentErrors)(errors, id),
|
|
56
57
|
label: label,
|
|
57
58
|
className: className,
|
|
58
59
|
shortcut: shortcut,
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _createWorker = require("../../../utils/suggester-workers/create-worker");
|
|
8
|
+
var _workerPath = require("../../../utils/suggester-workers/worker-path");
|
|
8
9
|
// @ts-ignore
|
|
9
10
|
|
|
10
|
-
var WORKER_PATH = process.env.LUNATIC_LABEL_WORKER_PATH || process.env.REACT_APP_LUNATIC_LABEL_WORKER_PATH || '';
|
|
11
11
|
var WORKER;
|
|
12
12
|
var TASKS = new Map();
|
|
13
13
|
function getIdTask() {
|
|
@@ -17,9 +17,9 @@ function getIdTask() {
|
|
|
17
17
|
}
|
|
18
18
|
return id;
|
|
19
19
|
}
|
|
20
|
-
function getWorker() {
|
|
20
|
+
function getWorker(workersBasePath) {
|
|
21
21
|
if (!WORKER) {
|
|
22
|
-
WORKER = (0, _createWorker.createWorker)(
|
|
22
|
+
WORKER = (0, _createWorker.createWorker)((0, _workerPath.getWorkerPath)(_workerPath.WorkerEnum.LABEL, workersBasePath));
|
|
23
23
|
WORKER.addEventListener('message', function (e) {
|
|
24
24
|
var data = e.data;
|
|
25
25
|
var response = data.response,
|
|
@@ -31,10 +31,10 @@ function getWorker() {
|
|
|
31
31
|
}
|
|
32
32
|
return WORKER;
|
|
33
33
|
}
|
|
34
|
-
function findBestLabel(option, search) {
|
|
34
|
+
function findBestLabel(option, search, workersBasePath) {
|
|
35
35
|
return new Promise(function (resolve) {
|
|
36
36
|
var idTask = getIdTask();
|
|
37
|
-
var worker = getWorker();
|
|
37
|
+
var worker = getWorker(workersBasePath);
|
|
38
38
|
TASKS.set(idTask, function (response) {
|
|
39
39
|
resolve(response);
|
|
40
40
|
TASKS["delete"](idTask);
|
|
@@ -19,10 +19,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
19
19
|
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; }
|
|
20
20
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
21
21
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
|
+
/**
|
|
23
|
+
* Check the store info displaying a message while it is fetching
|
|
24
|
+
*/
|
|
22
25
|
function CheckStore(_ref) {
|
|
23
26
|
var storeName = _ref.storeName,
|
|
24
27
|
version = _ref.version,
|
|
25
|
-
|
|
28
|
+
onInfo = _ref.onInfo,
|
|
26
29
|
children = _ref.children;
|
|
27
30
|
var _useState = (0, _react.useState)(0),
|
|
28
31
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -48,7 +51,7 @@ function CheckStore(_ref) {
|
|
|
48
51
|
info = _context.sent;
|
|
49
52
|
if (db && info) {
|
|
50
53
|
setReady(200);
|
|
51
|
-
|
|
54
|
+
onInfo(info);
|
|
52
55
|
}
|
|
53
56
|
_context.next = 13;
|
|
54
57
|
break;
|
|
@@ -61,7 +64,7 @@ function CheckStore(_ref) {
|
|
|
61
64
|
return _context.stop();
|
|
62
65
|
}
|
|
63
66
|
}, _callee, null, [[0, 10]]);
|
|
64
|
-
})), [storeName, version,
|
|
67
|
+
})), [storeName, version, onInfo]);
|
|
65
68
|
(0, _react.useEffect)(function () {
|
|
66
69
|
checkStore();
|
|
67
70
|
}, [checkStore]);
|