@inseefr/lunatic 2.5.1-testRoundaboutFix → 2.5.2-beta
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/lib/components/commons/components/combo-box/combo-box-container.js +16 -7
- package/lib/components/commons/components/combo-box/combo-box-container.spec.js +5 -5
- package/lib/components/commons/components/combo-box/combo-box-content-box.js +25 -0
- package/lib/components/commons/components/combo-box/combo-box-content.js +11 -11
- package/lib/components/commons/components/combo-box/combo-box.js +26 -11
- package/lib/components/commons/components/combo-box/panel/panel-container.js +5 -2
- package/lib/components/commons/components/combo-box/panel/panel-container.spec.js +7 -6
- package/lib/components/commons/components/combo-box/panel/panel.js +2 -2
- package/lib/components/commons/components/combo-box/selection/selection-container.js +3 -2
- package/lib/components/commons/components/combo-box/selection/selection.js +3 -1
- package/lib/components/dropdown/lunatic-dropdown.js +3 -1
- package/lib/components/index.js +7 -0
- package/lib/components/modal/html/modal.js +88 -0
- package/lib/components/modal/html/modal.scss +43 -0
- package/lib/components/modal/index.js +13 -0
- package/lib/components/modal/lunatic-modal.js +38 -0
- package/lib/components/pairwise-links/orchestrator.js +2 -0
- package/lib/components/pairwise-links/pairwise-links.js +1 -1
- package/lib/components/pairwise-links/row.js +2 -0
- package/lib/components/suggester/html/suggester.js +10 -6
- package/lib/components/suggester/lunatic-suggester.js +3 -1
- package/lib/src/components/commons/components/combo-box/combo-box-container.d.ts +5 -2
- package/lib/src/components/commons/components/combo-box/combo-box-content-box.d.ts +8 -0
- package/lib/src/components/commons/components/combo-box/combo-box-content.d.ts +2 -1
- package/lib/src/components/commons/components/combo-box/combo-box.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/combo-box.stories.d.ts +2 -0
- package/lib/src/components/commons/components/combo-box/panel/panel-container.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/selection/selection-container.d.ts +2 -1
- package/lib/src/components/commons/components/combo-box/selection/selection.d.ts +2 -1
- package/lib/src/components/dropdown/lunatic-dropdown.d.ts +1 -1
- package/lib/src/components/index.d.ts +1 -0
- package/lib/src/components/modal/html/modal.d.ts +14 -0
- package/lib/src/components/modal/index.d.ts +1 -0
- package/lib/src/components/modal/lunatic-modal.d.ts +3 -0
- package/lib/src/components/pairwise-links/row.d.ts +1 -1
- package/lib/src/components/suggester/html/suggester.d.ts +1 -0
- package/lib/src/components/suggester/lunatic-suggester.d.ts +1 -1
- package/lib/src/components/type.d.ts +8 -0
- package/lib/src/use-lunatic/actions.d.ts +4 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +40 -0
- package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +2 -0
- package/lib/src/use-lunatic/type.d.ts +2 -0
- package/lib/src/use-lunatic/use-lunatic.d.ts +22 -0
- package/lib/stories/modal/modal.stories.js +34 -0
- package/lib/stories/modal/source.json +97 -0
- package/lib/stories/questionnaires/simpsons/simpsons.stories.js +33 -36
- package/lib/stories/suggester/simple.json +15 -0
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +6 -2
- package/lib/use-lunatic/commons/page-navigation.js +2 -2
- package/lib/use-lunatic/commons/page.js +0 -6
- package/lib/use-lunatic/initial-state.js +2 -0
- package/lib/use-lunatic/reducer/commons/auto-explore-loop.js +9 -3
- package/lib/use-lunatic/reducer/reduce-go-next-page.js +11 -4
- package/lib/use-lunatic/reducer/reduce-go-previous-page.js +13 -5
- package/lib/use-lunatic/reducer/reduce-go-to-page.js +7 -6
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-resizing.js +0 -3
- package/lib/use-lunatic/reducer/reduce-on-init.js +11 -7
- package/lib/use-lunatic/use-lunatic.js +3 -1
- package/package.json +1 -1
|
@@ -3,19 +3,28 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = void 0;
|
|
7
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
|
+
var _createCustomizableField = _interopRequireDefault(require("../../create-customizable-field"));
|
|
9
|
+
var _errors = _interopRequireDefault(require("../errors"));
|
|
8
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
12
|
function ComboBoxContainer(_ref) {
|
|
11
13
|
var children = _ref.children,
|
|
12
14
|
className = _ref.className,
|
|
15
|
+
classNamePrefix = _ref.classNamePrefix,
|
|
13
16
|
id = _ref.id,
|
|
14
17
|
_ref$classStyle = _ref.classStyle,
|
|
15
|
-
classStyle = _ref$classStyle === void 0 ? 'default-style' : _ref$classStyle
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
classStyle = _ref$classStyle === void 0 ? 'default-style' : _ref$classStyle,
|
|
19
|
+
errors = _ref.errors;
|
|
20
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
21
|
+
id: "".concat(classNamePrefix !== null && classNamePrefix !== void 0 ? classNamePrefix : 'lunatic', "-combo-box-container-").concat(id),
|
|
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
|
+
children: [children, errors && /*#__PURE__*/(0, _jsxRuntime.jsx)(_errors["default"], {
|
|
24
|
+
errors: errors,
|
|
25
|
+
activeId: id
|
|
26
|
+
})]
|
|
20
27
|
});
|
|
21
|
-
}
|
|
28
|
+
}
|
|
29
|
+
var _default = (0, _createCustomizableField["default"])(ComboBoxContainer, 'ComboboxContainer');
|
|
30
|
+
exports["default"] = _default;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var _react = _interopRequireDefault(require("react"));
|
|
4
4
|
var _react2 = require("@testing-library/react");
|
|
5
|
-
var _comboBoxContainer = require("./combo-box-container");
|
|
5
|
+
var _comboBoxContainer = _interopRequireDefault(require("./combo-box-container"));
|
|
6
6
|
var _vitest = require("vitest");
|
|
7
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
9
|
(0, _vitest.describe)('ComboBoxContainer', function () {
|
|
10
10
|
(0, _vitest.it)('renders with default styles when no classStyle prop is provided', function () {
|
|
11
|
-
var _render = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer
|
|
11
|
+
var _render = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer["default"], {
|
|
12
12
|
id: "test-id",
|
|
13
13
|
children: "Content"
|
|
14
14
|
})),
|
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
16
16
|
(0, _vitest.expect)(container.firstChild).toHaveClass('default-style');
|
|
17
17
|
});
|
|
18
18
|
(0, _vitest.it)('renders with additional styles when classStyle prop is provided', function () {
|
|
19
|
-
var _render2 = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer
|
|
19
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer["default"], {
|
|
20
20
|
id: "test-id",
|
|
21
21
|
classStyle: "custom-style",
|
|
22
22
|
children: "Content"
|
|
@@ -26,7 +26,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
26
26
|
(0, _vitest.expect)(container.firstChild).toHaveClass('custom-style');
|
|
27
27
|
});
|
|
28
28
|
(0, _vitest.it)('renders children inside the component', function () {
|
|
29
|
-
var _render3 = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer
|
|
29
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer["default"], {
|
|
30
30
|
id: "test-id",
|
|
31
31
|
children: "Content"
|
|
32
32
|
})),
|
|
@@ -34,7 +34,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
34
34
|
(0, _vitest.expect)(getByText('Content')).toBeInTheDocument();
|
|
35
35
|
});
|
|
36
36
|
(0, _vitest.it)('passes className prop to the component', function () {
|
|
37
|
-
var _render4 = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer
|
|
37
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer["default"], {
|
|
38
38
|
id: "test-id",
|
|
39
39
|
className: "test-class",
|
|
40
40
|
children: "Content"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ComboBoxContentBox = ComboBoxContentBox;
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _index = require("../../index");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
function ComboBoxContentBox(_ref) {
|
|
14
|
+
var children = _ref.children,
|
|
15
|
+
classNamePrefix = _ref.classNamePrefix,
|
|
16
|
+
focused = _ref.focused;
|
|
17
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
18
|
+
className: (0, _classnames["default"])("".concat(classNamePrefix !== null && classNamePrefix !== void 0 ? classNamePrefix : 'lunatic', "-combo-box"), {
|
|
19
|
+
focused: focused
|
|
20
|
+
}),
|
|
21
|
+
children: children
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
var _default = (0, _index.createCustomizableLunaticField)(ComboBoxContentBox, 'ComboboxContentBox');
|
|
25
|
+
exports["default"] = _default;
|
|
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
11
|
var _keyboardKeyCodes = require("./state-management/reduce-on-keydown/keyboard-key-codes");
|
|
12
12
|
var _index = require("../../index");
|
|
13
|
+
var _comboBoxContentBox = _interopRequireDefault(require("./combo-box-content-box"));
|
|
13
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
16
|
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); }
|
|
@@ -19,7 +20,8 @@ function ComboBoxContent(_ref) {
|
|
|
19
20
|
focused = _ref.focused,
|
|
20
21
|
onFocus = _ref.onFocus,
|
|
21
22
|
onBlur = _ref.onBlur,
|
|
22
|
-
onKeyDown = _ref.onKeyDown
|
|
23
|
+
onKeyDown = _ref.onKeyDown,
|
|
24
|
+
classNamePrefix = _ref.classNamePrefix;
|
|
23
25
|
var ref = (0, _react.useRef)(null);
|
|
24
26
|
var onClick = (0, _react.useCallback)(function (e) {
|
|
25
27
|
var _ref$current;
|
|
@@ -44,19 +46,17 @@ function ComboBoxContent(_ref) {
|
|
|
44
46
|
|
|
45
47
|
onKeyDown(key);
|
|
46
48
|
}, [onKeyDown]);
|
|
47
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("
|
|
48
|
-
|
|
49
|
-
focused: focused
|
|
50
|
-
}),
|
|
51
|
-
onFocus: onFocus,
|
|
52
|
-
onClick: onFocus,
|
|
53
|
-
onKeyDown: handleKeyDown,
|
|
54
|
-
ref: ref,
|
|
55
|
-
tabIndex: 0,
|
|
49
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContentBox["default"], {
|
|
50
|
+
classNamePrefix: classNamePrefix,
|
|
56
51
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
57
|
-
className: (0, _classnames["default"])('lunatic-combo-box-content
|
|
52
|
+
className: (0, _classnames["default"])("".concat(classNamePrefix !== null && classNamePrefix !== void 0 ? classNamePrefix : 'lunatic', "-combo-box-content"), {
|
|
58
53
|
focused: focused
|
|
59
54
|
}),
|
|
55
|
+
ref: ref,
|
|
56
|
+
tabIndex: 0,
|
|
57
|
+
onFocus: onFocus,
|
|
58
|
+
onClick: onFocus,
|
|
59
|
+
onKeyDown: handleKeyDown,
|
|
60
60
|
children: children
|
|
61
61
|
})
|
|
62
62
|
});
|
|
@@ -12,10 +12,9 @@ var _stateManagement = require("./state-management");
|
|
|
12
12
|
require("./combo-box.scss");
|
|
13
13
|
var _selection = require("./selection/selection");
|
|
14
14
|
var _panel = require("./panel/panel");
|
|
15
|
-
var _comboBoxContainer = require("./combo-box-container");
|
|
15
|
+
var _comboBoxContainer = _interopRequireDefault(require("./combo-box-container"));
|
|
16
16
|
var _comboBoxContent = _interopRequireDefault(require("./combo-box-content"));
|
|
17
17
|
var _label = _interopRequireDefault(require("../label"));
|
|
18
|
-
var _errors = _interopRequireDefault(require("../errors"));
|
|
19
18
|
var _index = require("../../index");
|
|
20
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -33,6 +32,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
33
32
|
var EMPTY_SEARCH = '';
|
|
34
33
|
function ComboBox(_ref) {
|
|
35
34
|
var className = _ref.className,
|
|
35
|
+
classNamePrefix = _ref.classNamePrefix,
|
|
36
36
|
_ref$classStyle = _ref.classStyle,
|
|
37
37
|
classStyle = _ref$classStyle === void 0 ? 'default-style' : _ref$classStyle,
|
|
38
38
|
_ref$placeholder = _ref.placeholder,
|
|
@@ -73,12 +73,26 @@ function ComboBox(_ref) {
|
|
|
73
73
|
getOptionValue: getOptionValue
|
|
74
74
|
}));
|
|
75
75
|
}, [options, value, getOptionValue]);
|
|
76
|
+
|
|
77
|
+
// This useEffect ensures that onSelect is called when selectedIndex changes
|
|
78
|
+
(0, _react.useEffect)(function () {
|
|
79
|
+
if (selectedIndex) {
|
|
80
|
+
var option = options[selectedIndex];
|
|
81
|
+
onSelect(getOptionValue(option));
|
|
82
|
+
}
|
|
83
|
+
}, [selectedIndex, options, getOptionValue, onSelect]);
|
|
76
84
|
var onFocus = (0, _react.useCallback)(function () {
|
|
85
|
+
if (disabled) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
77
88
|
dispatch(_stateManagement.actions.onFocus());
|
|
78
|
-
}, []);
|
|
89
|
+
}, [disabled]);
|
|
79
90
|
var onBlur = (0, _react.useCallback)(function () {
|
|
91
|
+
if (disabled) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
80
94
|
dispatch(_stateManagement.actions.onBlur());
|
|
81
|
-
}, []);
|
|
95
|
+
}, [disabled]);
|
|
82
96
|
var handleSelect = (0, _react.useCallback)(function (index) {
|
|
83
97
|
var indexNumber = parseInt(index, 10);
|
|
84
98
|
var option = options[indexNumber];
|
|
@@ -97,16 +111,18 @@ function ComboBox(_ref) {
|
|
|
97
111
|
dispatch(_stateManagement.actions.onDelete());
|
|
98
112
|
onChange === null || onChange === void 0 ? void 0 : onChange(EMPTY_SEARCH);
|
|
99
113
|
}, [onChange]);
|
|
114
|
+
var showClearButton = !disabled;
|
|
100
115
|
if (messageError) {
|
|
101
116
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
102
117
|
className: "lunatic-combo-box-message-error",
|
|
103
118
|
children: messageError
|
|
104
119
|
});
|
|
105
120
|
}
|
|
106
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_comboBoxContainer
|
|
121
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_comboBoxContainer["default"], {
|
|
107
122
|
id: id,
|
|
108
123
|
classStyle: classStyle,
|
|
109
|
-
|
|
124
|
+
classNamePrefix: classNamePrefix,
|
|
125
|
+
errors: errors,
|
|
110
126
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_label["default"], {
|
|
111
127
|
htmlFor: id,
|
|
112
128
|
id: labelId,
|
|
@@ -117,6 +133,7 @@ function ComboBox(_ref) {
|
|
|
117
133
|
onFocus: onFocus,
|
|
118
134
|
onBlur: onBlur,
|
|
119
135
|
onKeyDown: onKeyDown,
|
|
136
|
+
classNamePrefix: classNamePrefix,
|
|
120
137
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_selection.Selection, {
|
|
121
138
|
labelRenderer: labelRenderer,
|
|
122
139
|
placeholder: placeholder,
|
|
@@ -129,7 +146,8 @@ function ComboBox(_ref) {
|
|
|
129
146
|
editable: editable,
|
|
130
147
|
selectedIndex: selectedIndex,
|
|
131
148
|
options: options,
|
|
132
|
-
onChange: handleChange
|
|
149
|
+
onChange: handleChange,
|
|
150
|
+
classNamePrefix: classNamePrefix
|
|
133
151
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_panel.Panel, {
|
|
134
152
|
optionRenderer: optionRenderer,
|
|
135
153
|
options: options,
|
|
@@ -140,16 +158,13 @@ function ComboBox(_ref) {
|
|
|
140
158
|
search: search,
|
|
141
159
|
onSelect: handleSelect
|
|
142
160
|
})]
|
|
143
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_clearButton.ClearButton, {
|
|
161
|
+
}), showClearButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_clearButton.ClearButton, {
|
|
144
162
|
className: (0, _classnames["default"])({
|
|
145
163
|
focused: focused
|
|
146
164
|
}),
|
|
147
165
|
search: search,
|
|
148
166
|
onClick: onDelete,
|
|
149
167
|
editable: editable
|
|
150
|
-
}), errors && /*#__PURE__*/(0, _jsxRuntime.jsx)(_errors["default"], {
|
|
151
|
-
errors: errors,
|
|
152
|
-
activeId: id
|
|
153
168
|
})]
|
|
154
169
|
});
|
|
155
170
|
}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = void 0;
|
|
7
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
|
+
var _createCustomizableField = _interopRequireDefault(require("../../../create-customizable-field"));
|
|
8
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
11
|
function PanelContainer(_ref) {
|
|
@@ -22,4 +23,6 @@ function PanelContainer(_ref) {
|
|
|
22
23
|
role: "listbox",
|
|
23
24
|
children: children
|
|
24
25
|
});
|
|
25
|
-
}
|
|
26
|
+
}
|
|
27
|
+
var _default = (0, _createCustomizableField["default"])(PanelContainer, 'ComboboxPanelContainer');
|
|
28
|
+
exports["default"] = _default;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
4
|
var _vitest = require("vitest");
|
|
5
|
-
var _panelContainer = require("./panel-container");
|
|
5
|
+
var _panelContainer = _interopRequireDefault(require("./panel-container"));
|
|
6
6
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
7
8
|
(0, _vitest.describe)('PanelContainer', function () {
|
|
8
9
|
(0, _vitest.it)('should render children', function () {
|
|
9
|
-
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_panelContainer
|
|
10
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_panelContainer["default"], {
|
|
10
11
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
11
12
|
children: "Item 1"
|
|
12
13
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
@@ -20,7 +21,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
20
21
|
});
|
|
21
22
|
(0, _vitest.it)('should set the id attribute', function () {
|
|
22
23
|
var id = 'test-panel';
|
|
23
|
-
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer
|
|
24
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer["default"], {
|
|
24
25
|
id: id,
|
|
25
26
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
26
27
|
children: "Item 1"
|
|
@@ -29,7 +30,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
29
30
|
(0, _vitest.expect)(_react.screen.getByRole('listbox')).toHaveAttribute('id', "lunatic-combo-box-panel-".concat(id));
|
|
30
31
|
});
|
|
31
32
|
(0, _vitest.it)('should set the aria-label attribute', function () {
|
|
32
|
-
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer
|
|
33
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer["default"], {
|
|
33
34
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
34
35
|
children: "Item 1"
|
|
35
36
|
})
|
|
@@ -37,7 +38,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
37
38
|
(0, _vitest.expect)(_react.screen.getByRole('listbox')).toHaveAttribute('aria-label', 'suggestions');
|
|
38
39
|
});
|
|
39
40
|
(0, _vitest.it)('should set the focused class when focused prop is true', function () {
|
|
40
|
-
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer
|
|
41
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer["default"], {
|
|
41
42
|
focused: true,
|
|
42
43
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
43
44
|
children: "Item 1"
|
|
@@ -46,7 +47,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
46
47
|
(0, _vitest.expect)(_react.screen.getByRole('listbox')).toHaveClass('focused');
|
|
47
48
|
});
|
|
48
49
|
(0, _vitest.it)('should set the expanded class when expanded prop is true', function () {
|
|
49
|
-
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer
|
|
50
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer["default"], {
|
|
50
51
|
expanded: true,
|
|
51
52
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
52
53
|
children: "Item 1"
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Panel = Panel;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _panelContainer = require("./panel-container");
|
|
8
|
+
var _panelContainer = _interopRequireDefault(require("./panel-container"));
|
|
9
9
|
var _optionContainer = require("./option-container");
|
|
10
10
|
var _comboBoxOption = _interopRequireDefault(require("./combo-box-option"));
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -22,7 +22,7 @@ function Panel(_ref) {
|
|
|
22
22
|
onSelect = _ref.onSelect;
|
|
23
23
|
var visibleOptions = expanded ? options : [];
|
|
24
24
|
var ComboBoxOptionComponent = OptionRender !== null && OptionRender !== void 0 ? OptionRender : _comboBoxOption["default"];
|
|
25
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer
|
|
25
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer["default"], {
|
|
26
26
|
expanded: expanded,
|
|
27
27
|
focused: focused,
|
|
28
28
|
id: "".concat(id, "-list"),
|
|
@@ -14,11 +14,12 @@ function SelectionContainer(_ref) {
|
|
|
14
14
|
expanded = _ref.expanded,
|
|
15
15
|
focused = _ref.focused,
|
|
16
16
|
disabled = _ref.disabled,
|
|
17
|
-
labelId = _ref.labelId
|
|
17
|
+
labelId = _ref.labelId,
|
|
18
|
+
classNamePrefix = _ref.classNamePrefix;
|
|
18
19
|
var comboBoxId = "".concat(id);
|
|
19
20
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
20
21
|
id: comboBoxId,
|
|
21
|
-
className: (0, _classnames["default"])('lunatic-combo-box-selection
|
|
22
|
+
className: (0, _classnames["default"])("".concat(classNamePrefix !== null && classNamePrefix !== void 0 ? classNamePrefix : 'lunatic', "-combo-box-selection"), {
|
|
22
23
|
focused: focused,
|
|
23
24
|
disabled: disabled
|
|
24
25
|
}),
|
|
@@ -21,7 +21,8 @@ function Selection(_ref) {
|
|
|
21
21
|
options = _ref.options,
|
|
22
22
|
editable = _ref.editable,
|
|
23
23
|
labelId = _ref.labelId,
|
|
24
|
-
id = _ref.id
|
|
24
|
+
id = _ref.id,
|
|
25
|
+
classNamePrefix = _ref.classNamePrefix;
|
|
25
26
|
var onChangeEx = (0, _react.useCallback)(function (e) {
|
|
26
27
|
onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value);
|
|
27
28
|
}, [onChange]);
|
|
@@ -30,6 +31,7 @@ function Selection(_ref) {
|
|
|
30
31
|
labelId: labelId,
|
|
31
32
|
expanded: expanded,
|
|
32
33
|
"aria-owns": "".concat(id, "-list"),
|
|
34
|
+
classNamePrefix: classNamePrefix,
|
|
33
35
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LabelOrInput.LabelOrInput, {
|
|
34
36
|
labelRenderer: labelRenderer,
|
|
35
37
|
placeholder: placeholder,
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
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 _dropdown = _interopRequireDefault(require("./html/dropdown"));
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
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) {
|
|
@@ -16,6 +17,7 @@ function LunaticDropdown(_ref) {
|
|
|
16
17
|
options = _ref.options,
|
|
17
18
|
writable = _ref.writable,
|
|
18
19
|
disabled = _ref.disabled,
|
|
20
|
+
className = _ref.className,
|
|
19
21
|
value = _ref.value,
|
|
20
22
|
response = _ref.response,
|
|
21
23
|
errors = _ref.errors,
|
|
@@ -48,7 +50,7 @@ function LunaticDropdown(_ref) {
|
|
|
48
50
|
options: options,
|
|
49
51
|
onSelect: onChange,
|
|
50
52
|
value: value,
|
|
51
|
-
className: "lunatic-dropdown",
|
|
53
|
+
className: (0, _classnames["default"])(className, "lunatic-dropdown"),
|
|
52
54
|
errors: errors,
|
|
53
55
|
label: label
|
|
54
56
|
})
|
package/lib/components/index.js
CHANGED
|
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "ComponentSet", {
|
|
|
33
33
|
return _componentSet["default"];
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "ConfirmationModal", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _modal["default"];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
36
42
|
Object.defineProperty(exports, "Datepicker", {
|
|
37
43
|
enumerable: true,
|
|
38
44
|
get: function get() {
|
|
@@ -205,4 +211,5 @@ var _summary = require("./summary");
|
|
|
205
211
|
var _questionInformation = _interopRequireDefault(require("./questions/question-information"));
|
|
206
212
|
var _questionContext = _interopRequireDefault(require("./questions/question-context"));
|
|
207
213
|
var _questionExplication = _interopRequireDefault(require("./question-explication"));
|
|
214
|
+
var _modal = _interopRequireDefault(require("./modal"));
|
|
208
215
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _commons = require("../../commons");
|
|
9
|
+
var _reactDom = require("react-dom");
|
|
10
|
+
require("./modal.scss");
|
|
11
|
+
var _button = _interopRequireDefault(require("../../button"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
+
function Modal(props) {
|
|
15
|
+
var id = props.id,
|
|
16
|
+
label = props.label,
|
|
17
|
+
description = props.description,
|
|
18
|
+
goNextPage = props.goNextPage,
|
|
19
|
+
goPreviousPage = props.goPreviousPage;
|
|
20
|
+
var first = (0, _react.useRef)(null);
|
|
21
|
+
var last = (0, _react.useRef)(null);
|
|
22
|
+
(0, _react.useEffect)(function () {
|
|
23
|
+
var _first$current;
|
|
24
|
+
var focusOnInit = first === null || first === void 0 || (_first$current = first.current) === null || _first$current === void 0 ? void 0 : _first$current.lastElementChild;
|
|
25
|
+
focusOnInit.focus();
|
|
26
|
+
}, [first]);
|
|
27
|
+
var onKeyDown = (0, _react.useCallback)(function (e) {
|
|
28
|
+
var _first$current2, _last$current;
|
|
29
|
+
var firstButtonToFocus = first === null || first === void 0 || (_first$current2 = first.current) === null || _first$current2 === void 0 ? void 0 : _first$current2.lastElementChild;
|
|
30
|
+
var lastButtonToFocus = last === null || last === void 0 || (_last$current = last.current) === null || _last$current === void 0 ? void 0 : _last$current.lastElementChild;
|
|
31
|
+
if (e.key === 'Tab') {
|
|
32
|
+
if (e.shiftKey) {
|
|
33
|
+
if (document.activeElement === firstButtonToFocus) {
|
|
34
|
+
lastButtonToFocus.focus();
|
|
35
|
+
e.nativeEvent.preventDefault();
|
|
36
|
+
}
|
|
37
|
+
} else if (document.activeElement === lastButtonToFocus) {
|
|
38
|
+
firstButtonToFocus.focus();
|
|
39
|
+
e.nativeEvent.preventDefault();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, [first, last]);
|
|
43
|
+
var handleNextClick = (0, _react.useCallback)(function () {
|
|
44
|
+
goNextPage();
|
|
45
|
+
}, [goNextPage]);
|
|
46
|
+
var handlePreviousClick = (0, _react.useCallback)(function () {
|
|
47
|
+
goPreviousPage();
|
|
48
|
+
}, [goPreviousPage]);
|
|
49
|
+
return /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/(0, _jsxRuntime.jsx)("dialog", {
|
|
50
|
+
className: "lunatic-modal",
|
|
51
|
+
open: true,
|
|
52
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
53
|
+
className: "modal-content",
|
|
54
|
+
onKeyDown: onKeyDown,
|
|
55
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
56
|
+
id: id,
|
|
57
|
+
className: "lunatic-modal-container",
|
|
58
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
59
|
+
className: "close-button",
|
|
60
|
+
ref: first,
|
|
61
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_button["default"], {
|
|
62
|
+
onClick: handlePreviousClick,
|
|
63
|
+
children: "fermer x"
|
|
64
|
+
})
|
|
65
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
66
|
+
className: "modal-message",
|
|
67
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
68
|
+
children: label
|
|
69
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
70
|
+
children: description
|
|
71
|
+
})]
|
|
72
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
73
|
+
className: "cancel-confirm-buttons",
|
|
74
|
+
ref: last,
|
|
75
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_button["default"], {
|
|
76
|
+
onClick: handlePreviousClick,
|
|
77
|
+
children: "Annuler"
|
|
78
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button["default"], {
|
|
79
|
+
onClick: handleNextClick,
|
|
80
|
+
children: "Je confirme"
|
|
81
|
+
})]
|
|
82
|
+
})]
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
}), document.body);
|
|
86
|
+
}
|
|
87
|
+
var _default = (0, _commons.createCustomizableLunaticField)(Modal, 'Modal');
|
|
88
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.lunatic-modal {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
background-color: rgba(50, 50, 50, 0.5);
|
|
8
|
+
z-index: 101;
|
|
9
|
+
|
|
10
|
+
.modal-content {
|
|
11
|
+
background-color: snow;
|
|
12
|
+
height: fit-content;
|
|
13
|
+
width: 50%;
|
|
14
|
+
margin: auto;
|
|
15
|
+
padding: 0.5rem;
|
|
16
|
+
margin-top: 38vh;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
border-radius: 8px;
|
|
20
|
+
overflow-wrap: break-word;
|
|
21
|
+
.lunatic-modal-container {
|
|
22
|
+
.close-button {
|
|
23
|
+
color: blue;
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: right;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
.body {
|
|
29
|
+
color: black;
|
|
30
|
+
font-size: 16px;
|
|
31
|
+
font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.modal-buttons {
|
|
35
|
+
align-self: end;
|
|
36
|
+
margin: 0 0.2em 0.2em 0;
|
|
37
|
+
:first-child {
|
|
38
|
+
margin-right: 0.5em;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _lunaticModal["default"];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _lunaticModal = _interopRequireDefault(require("./lunatic-modal"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _modal = _interopRequireDefault(require("./html/modal"));
|
|
8
|
+
var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../commons/components/lunatic-component-without-label"));
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
function empty() {}
|
|
12
|
+
function LunaticModal(props) {
|
|
13
|
+
var id = props.id,
|
|
14
|
+
label = props.label,
|
|
15
|
+
description = props.description,
|
|
16
|
+
goToPage = props.goToPage,
|
|
17
|
+
page = props.page,
|
|
18
|
+
goNextPage = props.goNextPage,
|
|
19
|
+
goPreviousPage = props.goPreviousPage;
|
|
20
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_lunaticComponentWithoutLabel["default"], {
|
|
21
|
+
id: id,
|
|
22
|
+
label: label,
|
|
23
|
+
handleChange: empty,
|
|
24
|
+
value: undefined,
|
|
25
|
+
description: description,
|
|
26
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_modal["default"], {
|
|
27
|
+
id: id,
|
|
28
|
+
label: label,
|
|
29
|
+
page: page,
|
|
30
|
+
description: description,
|
|
31
|
+
goToPage: goToPage,
|
|
32
|
+
goNextPage: goNextPage,
|
|
33
|
+
goPreviousPage: goPreviousPage
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
var _default = LunaticModal;
|
|
38
|
+
exports["default"] = _default;
|
|
@@ -25,6 +25,7 @@ function LinksOrchestrator(props) {
|
|
|
25
25
|
handleChange = props.handleChange,
|
|
26
26
|
features = props.features,
|
|
27
27
|
missing = props.missing,
|
|
28
|
+
className = props.className,
|
|
28
29
|
shortcut = props.shortcut,
|
|
29
30
|
preferences = props.preferences,
|
|
30
31
|
executeExpression = props.executeExpression,
|
|
@@ -60,6 +61,7 @@ function LinksOrchestrator(props) {
|
|
|
60
61
|
/** */,
|
|
61
62
|
features: features,
|
|
62
63
|
shortcut: shortcut,
|
|
64
|
+
className: className,
|
|
63
65
|
preferences: preferences,
|
|
64
66
|
missing: missing,
|
|
65
67
|
errors: errors,
|
|
@@ -4,7 +4,6 @@ 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 _orchestrator = _interopRequireDefault(require("./orchestrator"));
|
|
9
8
|
var _declarations = require("../declarations");
|
|
10
9
|
var _nothingToDisplay = _interopRequireDefault(require("../commons/components/nothing-to-display"));
|
|
@@ -42,6 +41,7 @@ var PairwiseLinks = function PairwiseLinks(_ref) {
|
|
|
42
41
|
handleChange: handleChange,
|
|
43
42
|
nbRows: nbRows,
|
|
44
43
|
value: value,
|
|
44
|
+
className: "pairwise-link",
|
|
45
45
|
management: management,
|
|
46
46
|
missing: missing,
|
|
47
47
|
shortcut: shortcut,
|
|
@@ -26,6 +26,7 @@ function Row(_ref) {
|
|
|
26
26
|
missing = _ref.missing,
|
|
27
27
|
shortcut = _ref.shortcut,
|
|
28
28
|
management = _ref.management,
|
|
29
|
+
className = _ref.className,
|
|
29
30
|
preferences = _ref.preferences,
|
|
30
31
|
executeExpression = _ref.executeExpression,
|
|
31
32
|
linksIterations = _ref.linksIterations,
|
|
@@ -61,6 +62,7 @@ function Row(_ref) {
|
|
|
61
62
|
features: features,
|
|
62
63
|
missing: missing,
|
|
63
64
|
shortcut: shortcut,
|
|
65
|
+
className: className,
|
|
64
66
|
management: management,
|
|
65
67
|
value: value,
|
|
66
68
|
id: idComponent,
|