@inseefr/lunatic 2.5.1-panelContainer → 2.5.1-testRoundaboutFix

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.
Files changed (28) hide show
  1. package/lib/components/commons/components/combo-box/combo-box-container.js +7 -15
  2. package/lib/components/commons/components/combo-box/combo-box-container.spec.js +5 -5
  3. package/lib/components/commons/components/combo-box/combo-box-content.js +9 -8
  4. package/lib/components/commons/components/combo-box/combo-box.js +7 -6
  5. package/lib/components/commons/components/combo-box/panel/panel-container.js +2 -5
  6. package/lib/components/commons/components/combo-box/panel/panel-container.spec.js +6 -7
  7. package/lib/components/commons/components/combo-box/panel/panel.js +2 -2
  8. package/lib/components/commons/components/combo-box/selection/selection-container.js +2 -3
  9. package/lib/components/commons/components/combo-box/selection/selection.js +1 -3
  10. package/lib/components/roundabout/lunatic-roundabout.js +0 -7
  11. package/lib/components/suggester/html/suggester.js +1 -1
  12. package/lib/components/suggester/lunatic-suggester.js +1 -3
  13. package/lib/src/components/commons/components/combo-box/combo-box-container.d.ts +2 -4
  14. package/lib/src/components/commons/components/combo-box/combo-box-content.d.ts +1 -2
  15. package/lib/src/components/commons/components/combo-box/combo-box.stories.d.ts +0 -1
  16. package/lib/src/components/commons/components/combo-box/panel/panel-container.d.ts +2 -2
  17. package/lib/src/components/commons/components/combo-box/selection/selection-container.d.ts +1 -2
  18. package/lib/src/components/commons/components/combo-box/selection/selection.d.ts +1 -2
  19. package/lib/src/components/suggester/lunatic-suggester.d.ts +1 -1
  20. package/lib/stories/roundabout/data1.json +25 -0
  21. package/lib/stories/roundabout/roundabout.stories.js +12 -4
  22. package/lib/stories/suggester/simple.json +0 -15
  23. package/lib/use-lunatic/commons/page.js +14 -2
  24. package/lib/use-lunatic/reducer/commons/auto-explore-loop.js +17 -4
  25. package/package.json +1 -1
  26. package/lib/components/commons/components/combo-box/combo-box-content-box.js +0 -30
  27. package/lib/src/components/commons/components/combo-box/combo-box-content-box.d.ts +0 -11
  28. /package/lib/stories/roundabout/{data.json → data2.json} +0 -0
@@ -3,10 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports.ComboBoxContainer = ComboBoxContainer;
7
7
  var _classnames = _interopRequireDefault(require("classnames"));
8
- var _createCustomizableField = _interopRequireDefault(require("../../create-customizable-field"));
9
- var _errors = _interopRequireDefault(require("../errors"));
10
8
  var _jsxRuntime = require("react/jsx-runtime");
11
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
10
  function ComboBoxContainer(_ref) {
@@ -14,16 +12,10 @@ function ComboBoxContainer(_ref) {
14
12
  className = _ref.className,
15
13
  id = _ref.id,
16
14
  _ref$classStyle = _ref.classStyle,
17
- classStyle = _ref$classStyle === void 0 ? 'default-style' : _ref$classStyle,
18
- errors = _ref.errors;
19
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
20
- id: "".concat(className !== null && className !== void 0 ? className : 'lunatic', "-combo-box-container-").concat(id),
21
- className: (0, _classnames["default"])("".concat(className !== null && className !== void 0 ? className : 'lunatic', "-combo-box-container"), "".concat(className !== null && className !== void 0 ? className : 'lunatic', "-suggester-").concat(classStyle), "lunatic-suggester-default-style", classStyle),
22
- children: [children, errors && /*#__PURE__*/(0, _jsxRuntime.jsx)(_errors["default"], {
23
- errors: errors,
24
- activeId: id
25
- })]
15
+ classStyle = _ref$classStyle === void 0 ? 'default-style' : _ref$classStyle;
16
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
17
+ id: "lunatic-combo-box-container-".concat(id),
18
+ className: (0, _classnames["default"])('lunatic-combo-box-container', className, classStyle),
19
+ children: children
26
20
  });
27
- }
28
- var _default = (0, _createCustomizableField["default"])(ComboBoxContainer, 'ComboboxContainer');
29
- exports["default"] = _default;
21
+ }
@@ -2,13 +2,13 @@
2
2
 
3
3
  var _react = _interopRequireDefault(require("react"));
4
4
  var _react2 = require("@testing-library/react");
5
- var _comboBoxContainer = _interopRequireDefault(require("./combo-box-container"));
5
+ var _comboBoxContainer = 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["default"], {
11
+ var _render = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer.ComboBoxContainer, {
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["default"], {
19
+ var _render2 = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer.ComboBoxContainer, {
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["default"], {
29
+ var _render3 = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer.ComboBoxContainer, {
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["default"], {
37
+ var _render4 = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContainer.ComboBoxContainer, {
38
38
  id: "test-id",
39
39
  className: "test-class",
40
40
  children: "Content"
@@ -10,7 +10,6 @@ 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"));
14
13
  var _jsxRuntime = require("react/jsx-runtime");
15
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
15
  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); }
@@ -20,8 +19,7 @@ function ComboBoxContent(_ref) {
20
19
  focused = _ref.focused,
21
20
  onFocus = _ref.onFocus,
22
21
  onBlur = _ref.onBlur,
23
- onKeyDown = _ref.onKeyDown,
24
- className = _ref.className;
22
+ onKeyDown = _ref.onKeyDown;
25
23
  var ref = (0, _react.useRef)(null);
26
24
  var onClick = (0, _react.useCallback)(function (e) {
27
25
  var _ref$current;
@@ -46,16 +44,19 @@ function ComboBoxContent(_ref) {
46
44
 
47
45
  onKeyDown(key);
48
46
  }, [onKeyDown]);
49
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContentBox["default"], {
50
- className: className,
47
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
48
+ className: (0, _classnames["default"])('lunatic-combo-box', {
49
+ focused: focused
50
+ }),
51
51
  onFocus: onFocus,
52
+ onClick: onFocus,
52
53
  onKeyDown: handleKeyDown,
54
+ ref: ref,
55
+ tabIndex: 0,
53
56
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
54
- className: (0, _classnames["default"])("".concat(className !== null && className !== void 0 ? className : 'lunatic', "-combo-box-content"), {
57
+ className: (0, _classnames["default"])('lunatic-combo-box-content', {
55
58
  focused: focused
56
59
  }),
57
- ref: ref,
58
- tabIndex: 0,
59
60
  children: children
60
61
  })
61
62
  });
@@ -12,9 +12,10 @@ 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 = _interopRequireDefault(require("./combo-box-container"));
15
+ var _comboBoxContainer = 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"));
18
19
  var _index = require("../../index");
19
20
  var _jsxRuntime = require("react/jsx-runtime");
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -102,11 +103,10 @@ function ComboBox(_ref) {
102
103
  children: messageError
103
104
  });
104
105
  }
105
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_comboBoxContainer["default"], {
106
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_comboBoxContainer.ComboBoxContainer, {
106
107
  id: id,
107
108
  classStyle: classStyle,
108
109
  className: className,
109
- errors: errors,
110
110
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_label["default"], {
111
111
  htmlFor: id,
112
112
  id: labelId,
@@ -117,7 +117,6 @@ function ComboBox(_ref) {
117
117
  onFocus: onFocus,
118
118
  onBlur: onBlur,
119
119
  onKeyDown: onKeyDown,
120
- className: className,
121
120
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_selection.Selection, {
122
121
  labelRenderer: labelRenderer,
123
122
  placeholder: placeholder,
@@ -130,8 +129,7 @@ function ComboBox(_ref) {
130
129
  editable: editable,
131
130
  selectedIndex: selectedIndex,
132
131
  options: options,
133
- onChange: handleChange,
134
- className: className
132
+ onChange: handleChange
135
133
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_panel.Panel, {
136
134
  optionRenderer: optionRenderer,
137
135
  options: options,
@@ -149,6 +147,9 @@ function ComboBox(_ref) {
149
147
  search: search,
150
148
  onClick: onDelete,
151
149
  editable: editable
150
+ }), errors && /*#__PURE__*/(0, _jsxRuntime.jsx)(_errors["default"], {
151
+ errors: errors,
152
+ activeId: id
152
153
  })]
153
154
  });
154
155
  }
@@ -3,9 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports.PanelContainer = PanelContainer;
7
7
  var _classnames = _interopRequireDefault(require("classnames"));
8
- var _createCustomizableField = _interopRequireDefault(require("../../../create-customizable-field"));
9
8
  var _jsxRuntime = require("react/jsx-runtime");
10
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
10
  function PanelContainer(_ref) {
@@ -23,6 +22,4 @@ function PanelContainer(_ref) {
23
22
  role: "listbox",
24
23
  children: children
25
24
  });
26
- }
27
- var _default = (0, _createCustomizableField["default"])(PanelContainer, 'ComboboxPanelContainer');
28
- exports["default"] = _default;
25
+ }
@@ -2,12 +2,11 @@
2
2
 
3
3
  var _react = require("@testing-library/react");
4
4
  var _vitest = require("vitest");
5
- var _panelContainer = _interopRequireDefault(require("./panel-container"));
5
+ var _panelContainer = require("./panel-container");
6
6
  var _jsxRuntime = require("react/jsx-runtime");
7
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
7
  (0, _vitest.describe)('PanelContainer', function () {
9
8
  (0, _vitest.it)('should render children', function () {
10
- (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_panelContainer["default"], {
9
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_panelContainer.PanelContainer, {
11
10
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
12
11
  children: "Item 1"
13
12
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
@@ -21,7 +20,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
21
20
  });
22
21
  (0, _vitest.it)('should set the id attribute', function () {
23
22
  var id = 'test-panel';
24
- (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer["default"], {
23
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer.PanelContainer, {
25
24
  id: id,
26
25
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
27
26
  children: "Item 1"
@@ -30,7 +29,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
30
29
  (0, _vitest.expect)(_react.screen.getByRole('listbox')).toHaveAttribute('id', "lunatic-combo-box-panel-".concat(id));
31
30
  });
32
31
  (0, _vitest.it)('should set the aria-label attribute', function () {
33
- (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer["default"], {
32
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer.PanelContainer, {
34
33
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
35
34
  children: "Item 1"
36
35
  })
@@ -38,7 +37,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
38
37
  (0, _vitest.expect)(_react.screen.getByRole('listbox')).toHaveAttribute('aria-label', 'suggestions');
39
38
  });
40
39
  (0, _vitest.it)('should set the focused class when focused prop is true', function () {
41
- (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer["default"], {
40
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer.PanelContainer, {
42
41
  focused: true,
43
42
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
44
43
  children: "Item 1"
@@ -47,7 +46,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
47
46
  (0, _vitest.expect)(_react.screen.getByRole('listbox')).toHaveClass('focused');
48
47
  });
49
48
  (0, _vitest.it)('should set the expanded class when expanded prop is true', function () {
50
- (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer["default"], {
49
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer.PanelContainer, {
51
50
  expanded: true,
52
51
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
53
52
  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 = _interopRequireDefault(require("./panel-container"));
8
+ var _panelContainer = 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["default"], {
25
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_panelContainer.PanelContainer, {
26
26
  expanded: expanded,
27
27
  focused: focused,
28
28
  id: "".concat(id, "-list"),
@@ -14,12 +14,11 @@ function SelectionContainer(_ref) {
14
14
  expanded = _ref.expanded,
15
15
  focused = _ref.focused,
16
16
  disabled = _ref.disabled,
17
- labelId = _ref.labelId,
18
- className = _ref.className;
17
+ labelId = _ref.labelId;
19
18
  var comboBoxId = "".concat(id);
20
19
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
21
20
  id: comboBoxId,
22
- className: (0, _classnames["default"])("".concat(className !== null && className !== void 0 ? className : 'lunatic', "-combo-box-selection"), {
21
+ className: (0, _classnames["default"])('lunatic-combo-box-selection', {
23
22
  focused: focused,
24
23
  disabled: disabled
25
24
  }),
@@ -21,8 +21,7 @@ function Selection(_ref) {
21
21
  options = _ref.options,
22
22
  editable = _ref.editable,
23
23
  labelId = _ref.labelId,
24
- id = _ref.id,
25
- className = _ref.className;
24
+ id = _ref.id;
26
25
  var onChangeEx = (0, _react.useCallback)(function (e) {
27
26
  onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value);
28
27
  }, [onChange]);
@@ -31,7 +30,6 @@ function Selection(_ref) {
31
30
  labelId: labelId,
32
31
  expanded: expanded,
33
32
  "aria-owns": "".concat(id, "-list"),
34
- className: className,
35
33
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LabelOrInput.LabelOrInput, {
36
34
  labelRenderer: labelRenderer,
37
35
  placeholder: placeholder,
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports["default"] = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _roundabout = _interopRequireDefault(require("./roundabout"));
10
- var _redirect = _interopRequireDefault(require("./redirect"));
11
10
  var _jsxRuntime = require("react/jsx-runtime");
12
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
12
  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); }
@@ -30,12 +29,6 @@ function LunaticRoundabout(_ref) {
30
29
  nbIterations: iterations
31
30
  });
32
31
  }, [goToPage, page, iterations]);
33
- if (iterations === 1) {
34
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_redirect["default"], {
35
- goToIteration: goToIteration,
36
- iteration: 0
37
- });
38
- }
39
32
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_roundabout["default"], {
40
33
  label: label,
41
34
  expressions: expressions,
@@ -25,7 +25,7 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
25
25
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
26
  function Suggester(_ref) {
27
27
  var _ref$className = _ref.className,
28
- className = _ref$className === void 0 ? 'lunatic' : _ref$className,
28
+ className = _ref$className === void 0 ? 'lunatic-suggester-default-style' : _ref$className,
29
29
  _ref$placeholder = _ref.placeholder,
30
30
  placeholder = _ref$placeholder === void 0 ? _i18n["default"].PLACEHOLDER : _ref$placeholder,
31
31
  _ref$onSelect = _ref.onSelect,
@@ -28,7 +28,6 @@ function LunaticSuggester(_ref) {
28
28
  missingResponse = _ref.missingResponse,
29
29
  management = _ref.management,
30
30
  response = _ref.response,
31
- className = _ref.className,
32
31
  getSuggesterStatus = _ref.getSuggesterStatus;
33
32
  var onChange = (0, _useOnHandleChange["default"])({
34
33
  handleChange: handleChange,
@@ -56,8 +55,7 @@ function LunaticSuggester(_ref) {
56
55
  value: value,
57
56
  errors: errors,
58
57
  label: label,
59
- getSuggesterStatus: getSuggesterStatus,
60
- className: className
58
+ getSuggesterStatus: getSuggesterStatus
61
59
  })
62
60
  });
63
61
  }
@@ -1,10 +1,8 @@
1
1
  import type { PropsWithChildren } from 'react';
2
- import { LunaticBaseProps } from '../../../type';
3
2
  type Props = PropsWithChildren<{
4
3
  className?: string;
5
4
  id?: string;
6
5
  classStyle?: string;
7
- errors?: LunaticBaseProps['errors'];
8
6
  }>;
9
- declare const _default: import("react").ComponentType<Props>;
10
- export default _default;
7
+ export declare function ComboBoxContainer({ children, className, id, classStyle, }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -4,7 +4,6 @@ type Props = PropsWithChildren<{
4
4
  onBlur: () => void;
5
5
  onFocus: () => void;
6
6
  onKeyDown: (key: string) => void;
7
- className?: string;
8
7
  }>;
9
- export declare function ComboBoxContent({ children, focused, onFocus, onBlur, onKeyDown, className, }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export declare function ComboBoxContent({ children, focused, onFocus, onBlur, onKeyDown, }: Props): import("react/jsx-runtime").JSX.Element;
10
9
  export default ComboBoxContent;
@@ -10,7 +10,6 @@ export declare const Default: Story<{
10
10
  editable?: boolean | undefined;
11
11
  labelId?: string | undefined;
12
12
  id?: string | undefined;
13
- className?: string | undefined;
14
13
  } & import("./selection/label-selection").LabelSelectionProps & import("./panel/panel").PanelProps & {
15
14
  className?: string | undefined;
16
15
  classStyle?: string | undefined;
@@ -4,5 +4,5 @@ type Props = PropsWithChildren<{
4
4
  expanded?: boolean;
5
5
  id?: string;
6
6
  }>;
7
- declare const _default: import("react").ComponentType<Props>;
8
- export default _default;
7
+ export declare function PanelContainer({ children, focused, expanded, id }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -5,7 +5,6 @@ type Props = PropsWithChildren<{
5
5
  disabled?: boolean;
6
6
  labelId?: string;
7
7
  id?: string;
8
- className?: string;
9
8
  }>;
10
- declare function SelectionContainer({ children, id, expanded, focused, disabled, labelId, className, }: Props): import("react/jsx-runtime").JSX.Element;
9
+ declare function SelectionContainer({ children, id, expanded, focused, disabled, labelId, }: Props): import("react/jsx-runtime").JSX.Element;
11
10
  export default SelectionContainer;
@@ -6,6 +6,5 @@ export type SelectionProps = {
6
6
  editable?: boolean;
7
7
  labelId?: string;
8
8
  id?: string;
9
- className?: string;
10
9
  } & LabelSelectionProps;
11
- export declare function Selection({ labelRenderer, placeholder, search, expanded, disabled, focused, onChange, selectedIndex, options, editable, labelId, id, className, }: SelectionProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function Selection({ labelRenderer, placeholder, search, expanded, disabled, focused, onChange, selectedIndex, options, editable, labelId, id, }: SelectionProps): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import { LunaticComponentProps } from '../type';
2
- declare function LunaticSuggester({ id, storeName, optionRenderer, labelRenderer, idbVersion, focused, value, handleChange, disabled, errors, label, description, preferences, declarations, missing, missingResponse, management, response, className, getSuggesterStatus, }: LunaticComponentProps<'Suggester'>): import("react/jsx-runtime").JSX.Element;
2
+ declare function LunaticSuggester({ id, storeName, optionRenderer, labelRenderer, idbVersion, focused, value, handleChange, disabled, errors, label, description, preferences, declarations, missing, missingResponse, management, response, getSuggesterStatus, }: LunaticComponentProps<'Suggester'>): import("react/jsx-runtime").JSX.Element;
3
3
  export default LunaticSuggester;
@@ -0,0 +1,25 @@
1
+ {
2
+ "COLLECTED": {
3
+ "NB_HAB": {
4
+ "EDITED": null,
5
+ "FORCED": null,
6
+ "INPUTED": null,
7
+ "PREVIOUS": null,
8
+ "COLLECTED": 1
9
+ },
10
+ "PRENOMS": {
11
+ "EDITED": [null],
12
+ "FORCED": [null],
13
+ "INPUTED": [null],
14
+ "PREVIOUS": [null],
15
+ "COLLECTED": ["Fanny"]
16
+ },
17
+ "AGE": {
18
+ "EDITED": [null],
19
+ "FORCED": [null],
20
+ "INPUTED": [null],
21
+ "PREVIOUS": [null],
22
+ "COLLECTED": [15]
23
+ }
24
+ }
25
+ }
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.Default = void 0;
6
+ exports["default"] = exports.OneIteration = exports.Default = void 0;
7
7
  var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
8
8
  var _source = _interopRequireDefault(require("./source"));
9
- var _data = _interopRequireDefault(require("./data"));
9
+ var _data = _interopRequireDefault(require("./data1"));
10
+ var _data2 = _interopRequireDefault(require("./data2"));
10
11
  var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
11
12
  var _jsxRuntime = require("react/jsx-runtime");
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -32,6 +33,13 @@ Default.args = {
32
33
  id: 'roundabout',
33
34
  source: _source["default"],
34
35
  pagination: true,
35
- data: _data["default"],
36
- readOnly: true
36
+ data: _data2["default"]
37
+ };
38
+ var OneIteration = Template.bind({});
39
+ exports.OneIteration = OneIteration;
40
+ OneIteration.args = {
41
+ id: 'roundabout-one-iteration',
42
+ source: _source["default"],
43
+ pagination: true,
44
+ data: _data["default"]
37
45
  };
@@ -46,21 +46,6 @@
46
46
  "value": "true",
47
47
  "type": "VTL"
48
48
  },
49
- "controls": [
50
- {
51
- "id": "age-controls",
52
- "criticality": "ERROR",
53
- "typeOfControl": "FORMAT",
54
- "control": {
55
- "value": "not(isnull(HELLO))",
56
- "type": "VTL"
57
- },
58
- "errorMessage": {
59
- "value": "\"Veuillez selectionner quelquechose\"",
60
- "type": "VTL"
61
- }
62
- }
63
- ],
64
49
  "response": {
65
50
  "name": "HELLO"
66
51
  },
@@ -34,11 +34,23 @@ function isPageEmpty(state) {
34
34
  pager = state.pager;
35
35
  var iteration = pager.iteration;
36
36
  var components = (0, _index.getComponentsFromState)(state);
37
- return components.filter(function (component) {
37
+ var visibleComponents = components.filter(function (component) {
38
38
  var conditionFilter = component.conditionFilter;
39
39
  if (conditionFilter) {
40
40
  return (0, _index.executeConditionFilter)(conditionFilter, executeExpression, iteration);
41
41
  }
42
42
  return true;
43
- }).length === 0;
43
+ });
44
+
45
+ // No components are displayable on this page
46
+ if (visibleComponents.length === 0) {
47
+ return true;
48
+ }
49
+
50
+ // We have a roundabout with only one iteration
51
+ var firstComponent = visibleComponents[0];
52
+ if (visibleComponents.length === 1 && (firstComponent === null || firstComponent === void 0 ? void 0 : firstComponent.componentType) === 'Roundabout' && executeExpression(firstComponent.iterations) === 1) {
53
+ return true;
54
+ }
55
+ return false;
44
56
  }
@@ -20,15 +20,28 @@ function autoExploreLoop(state) {
20
20
  var pageId = (0, _page.getPageId)(newPager);
21
21
  var page = state.pages[pageId];
22
22
  var isForward = direction === 'forward';
23
- // The page is a loop
24
- if (page.isLoop && page.subPages && page.subPages.length > 0) {
25
- var maxSubPage = page.subPages.length;
26
- var firstSubPage = (0, _page.pageStringToNumbers)(page.subPages[isForward ? 0 : maxSubPage - 1]);
23
+ var goInsideSubpage = function goInsideSubpage(subPages, nbIteration) {
24
+ var maxSubPage = subPages.length;
25
+ var firstSubPage = (0, _page.pageStringToNumbers)(subPages[isForward ? 0 : maxSubPage - 1]);
27
26
  newPager.page = firstSubPage[0].toString();
28
27
  newPager.subPage = firstSubPage[1] - 1; // Subpage starts at 0
29
28
  newPager.nbSubPages = maxSubPage;
30
29
  newPager.nbIterations = state.executeExpression(page.iterations);
31
30
  newPager.iteration = isForward ? 0 : newPager.nbIterations - 1;
31
+ };
32
+
33
+ // The page is a loop
34
+ if (page.isLoop && page.subPages && page.subPages.length > 0) {
35
+ goInsideSubpage(page.subPages, state.executeExpression(page.iterations));
36
+ }
37
+
38
+ // The page contains a roundabout, go to the first iteration if it only has one iteration
39
+ var firstComponent = page.components[0];
40
+ if (page.components[0].componentType === 'Roundabout' && page.subPages && page.subPages.length > 0 && isForward) {
41
+ var nbIterations = state.executeExpression(page.iterations);
42
+ if (nbIterations === 1) {
43
+ goInsideSubpage(page.subPages, 1);
44
+ }
32
45
  }
33
46
  return _objectSpread(_objectSpread({}, state), {}, {
34
47
  isInLoop: newPager.nbIterations !== undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "2.5.1-panelContainer",
3
+ "version": "2.5.1-testRoundaboutFix",
4
4
  "workersVersion": "0.2.5-experimental",
5
5
  "description": "Library of questionnaire components",
6
6
  "repository": {
@@ -1,30 +0,0 @@
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
- className = _ref.className,
16
- onFocus = _ref.onFocus,
17
- onKeyDown = _ref.onKeyDown,
18
- focused = _ref.focused;
19
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
20
- className: (0, _classnames["default"])("".concat(className !== null && className !== void 0 ? className : 'lunatic', "-combo-box"), {
21
- focused: focused
22
- }),
23
- onFocus: onFocus,
24
- onClick: onFocus,
25
- onKeyDown: onKeyDown,
26
- children: children
27
- });
28
- }
29
- var _default = (0, _index.createCustomizableLunaticField)(ComboBoxContentBox, 'ComboboxContentBox');
30
- exports["default"] = _default;
@@ -1,11 +0,0 @@
1
- import type { KeyboardEvent } from 'react';
2
- import React, { PropsWithChildren } from 'react';
3
- type Props = PropsWithChildren<{
4
- focused?: boolean;
5
- onFocus: () => void;
6
- onKeyDown: (e: KeyboardEvent<Element>) => void;
7
- className?: string;
8
- }>;
9
- export declare function ComboBoxContentBox({ children, className, onFocus, onKeyDown, focused, }: Props): import("react/jsx-runtime").JSX.Element;
10
- declare const _default: React.ComponentType<Props>;
11
- export default _default;