@inseefr/lunatic 3.0.0-rc.1 → 3.0.0-rc.6

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 (104) hide show
  1. package/lib/components/CheckboxBoolean/CheckboxBoolean.js +39 -19
  2. package/lib/components/CheckboxGroup/CustomCheckboxGroup.js +2 -2
  3. package/lib/components/CheckboxOne/CheckboxOne.js +6 -6
  4. package/lib/components/Datepicker/Datepicker.js +43 -28
  5. package/lib/components/Dropdown/Dropdown.js +40 -23
  6. package/lib/components/Duration/Duration.js +41 -16
  7. package/lib/components/FilterDescription/FilterDescription.js +2 -3
  8. package/lib/components/Input/Input.js +39 -21
  9. package/lib/components/InputNumber/InputNumber.js +45 -34
  10. package/lib/components/InputNumber/__snapshots__/InputNumber.spec.tsx.snap +0 -2
  11. package/lib/components/Loop/Loop.js +52 -29
  12. package/lib/components/LunaticComponents.js +42 -37
  13. package/lib/components/Question/Question.js +23 -14
  14. package/lib/components/Radio/Radio.js +2 -2
  15. package/lib/components/RosterForLoop/RosterForLoop.js +13 -35
  16. package/lib/components/Roundabout/CustomRoundabout.js +2 -2
  17. package/lib/components/Roundabout/RoundaboutItButton.js +2 -2
  18. package/lib/components/Roundabout/extra.js +6 -6
  19. package/lib/components/Sequence/Sequence.js +2 -2
  20. package/lib/components/Subsequence/Subsequence.js +2 -2
  21. package/lib/components/Suggester/CustomSuggester.js +2 -2
  22. package/lib/components/Suggester/SuggesterNotification.js +2 -2
  23. package/lib/components/Summary/Summary.js +3 -3
  24. package/lib/components/Switch/Switch.js +42 -22
  25. package/lib/components/Textarea/Textarea.js +43 -23
  26. package/lib/components/library.js +0 -2
  27. package/lib/components/shared/Button/Button.js +2 -2
  28. package/lib/components/shared/Checkbox/CheckboxOption.js +2 -2
  29. package/lib/components/shared/Combobox/Combobox.js +2 -2
  30. package/lib/components/shared/Combobox/ComboboxContainer.js +2 -2
  31. package/lib/components/shared/Combobox/ComboboxContentBox.js +2 -2
  32. package/lib/components/shared/Combobox/Panel/ComboboxOption.js +2 -2
  33. package/lib/components/shared/Combobox/Panel/ComboboxPanelContainer.js +2 -2
  34. package/lib/components/shared/Combobox/Selection/ComboboxClearButton.js +2 -2
  35. package/lib/components/shared/Combobox/Selection/ComboboxInput.js +2 -2
  36. package/lib/components/shared/Combobox/Selection/ComboboxLabelSelection.js +2 -2
  37. package/lib/components/shared/Declarations/Declarations.js +3 -3
  38. package/lib/components/shared/Fieldset/Fieldset.js +2 -2
  39. package/lib/components/shared/HOC/{customizedComponent.js → slottableComponent.js} +35 -13
  40. package/lib/components/shared/Label/Label.js +2 -2
  41. package/lib/components/shared/MDLabel/RouterLink.js +2 -2
  42. package/lib/components/shared/Notification.js +2 -2
  43. package/lib/components/shared/Radio/RadioGroup.js +4 -3
  44. package/lib/components/shared/Radio/RadioOption.js +2 -2
  45. package/lib/components/shared/Table/Table.js +2 -2
  46. package/lib/components/shared/Table/Tbody.js +2 -2
  47. package/lib/components/shared/Table/Td.js +2 -2
  48. package/lib/components/shared/Table/Th.js +2 -2
  49. package/lib/components/shared/Table/Thead.js +2 -2
  50. package/lib/components/shared/Table/Tr.js +2 -2
  51. package/lib/src/components/CheckboxBoolean/CheckboxBoolean.d.ts +10 -5
  52. package/lib/src/components/CheckboxOne/CheckboxOne.d.ts +5 -11
  53. package/lib/src/components/Datepicker/Datepicker.d.ts +8 -9
  54. package/lib/src/components/Dropdown/Dropdown.d.ts +9 -11
  55. package/lib/src/components/Duration/Duration.d.ts +9 -6
  56. package/lib/src/components/FilterDescription/FilterDescription.d.ts +1 -1
  57. package/lib/src/components/Input/Input.d.ts +9 -7
  58. package/lib/src/components/InputNumber/InputNumber.d.ts +9 -9
  59. package/lib/src/components/Loop/Loop.d.ts +11 -18
  60. package/lib/src/components/LunaticComponents.d.ts +4 -2
  61. package/lib/src/components/Question/Question.d.ts +6 -4
  62. package/lib/src/components/RosterForLoop/RosterForLoop.d.ts +2 -21
  63. package/lib/src/components/Switch/Switch.d.ts +9 -0
  64. package/lib/src/components/Textarea/Textarea.d.ts +9 -9
  65. package/lib/src/components/library.d.ts +24 -91
  66. package/lib/src/components/shared/HOC/slottableComponent.d.ts +101 -0
  67. package/lib/src/components/shared/Radio/RadioGroup.d.ts +1 -0
  68. package/lib/src/components/type.d.ts +0 -5
  69. package/lib/src/index.d.ts +1 -1
  70. package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +18 -33
  71. package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +0 -37
  72. package/lib/src/use-lunatic/commons/fill-components/fill-iterations.d.ts +16 -18
  73. package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +4 -52
  74. package/lib/src/use-lunatic/commons/use-components-from-state.d.ts +1 -1
  75. package/lib/src/use-lunatic/lunatic-context.d.ts +1 -4
  76. package/lib/src/use-lunatic/replace-component-sequence.d.ts +3 -3
  77. package/lib/src/use-lunatic/type-source.d.ts +1 -5
  78. package/lib/src/use-lunatic/use-lunatic.d.ts +8 -19
  79. package/lib/stories/{component-set/component-set.stories.js → behaviour/slots.stories.js} +36 -25
  80. package/lib/stories/checkbox-group/checkbox-group.stories.js +1 -6
  81. package/lib/stories/disabled/source.json +1 -1
  82. package/lib/stories/pairwise/pairwise-links.stories.js +1 -9
  83. package/lib/stories/suggester/suggester.stories.js +1 -8
  84. package/lib/stories/utils/orchestrator.js +4 -4
  85. package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +0 -1
  86. package/lib/use-lunatic/lunatic-context.js +2 -10
  87. package/lib/use-lunatic/replace-component-sequence.js +2 -3
  88. package/lib/use-lunatic/use-lunatic.js +1 -4
  89. package/lib/use-lunatic/use-lunatic.test.js +4 -30
  90. package/package.json +1 -1
  91. package/lib/components/ComponentSet/ComponentSet.js +0 -68
  92. package/lib/components/type-custom.js +0 -5
  93. package/lib/src/components/ComponentSet/ComponentSet.d.ts +0 -7
  94. package/lib/src/components/shared/HOC/customizedComponent.d.ts +0 -5
  95. package/lib/src/components/type-custom.d.ts +0 -101
  96. package/lib/stories/checkbox-group/sourceComponentset.json +0 -424
  97. package/lib/stories/component-set/data-loop.json +0 -18
  98. package/lib/stories/component-set/data-roundabout.json +0 -25
  99. package/lib/stories/component-set/data.json +0 -25
  100. package/lib/stories/component-set/source-loop.json +0 -308
  101. package/lib/stories/component-set/source-roundabout.json +0 -434
  102. package/lib/stories/component-set/source.json +0 -113
  103. package/lib/stories/pairwise/source-componentset.json +0 -292
  104. package/lib/stories/suggester/source-component-set.json +0 -113
@@ -1,8 +1,8 @@
1
- import { type FunctionComponent } from 'react';
1
+ /// <reference types="react" />
2
2
  import type { LunaticData, LunaticState } from './type';
3
3
  import type { LunaticSource } from './type-source';
4
4
  import type { LunaticComponentType } from '../components/type';
5
- declare function useLunatic(source: LunaticSource, data: LunaticData | undefined, { features, preferences, savingType, onChange, management, shortcut, initialPage, lastReachedPage, autoSuggesterLoading, activeControls, getReferentiel, custom, withOverview, missing, missingStrategy, missingShortcut, dontKnowButton, refusedButton, workersBasePath, trackChanges, }: {
5
+ declare function useLunatic(source: LunaticSource, data: LunaticData | undefined, { features, preferences, savingType, onChange, management, shortcut, initialPage, lastReachedPage, autoSuggesterLoading, activeControls, getReferentiel, withOverview, missing, missingStrategy, missingShortcut, dontKnowButton, refusedButton, workersBasePath, trackChanges, }: {
6
6
  features?: LunaticState['features'];
7
7
  preferences?: LunaticState['preferences'];
8
8
  savingType?: LunaticState['savingType'];
@@ -14,7 +14,6 @@ declare function useLunatic(source: LunaticSource, data: LunaticData | undefined
14
14
  autoSuggesterLoading?: boolean;
15
15
  getReferentiel?: (name: string) => Promise<Array<unknown>>;
16
16
  activeControls?: boolean;
17
- custom?: Record<string, FunctionComponent<unknown>>;
18
17
  withOverview?: boolean;
19
18
  missing?: boolean;
20
19
  missingStrategy?: () => void;
@@ -56,11 +55,6 @@ declare function useLunatic(source: LunaticSource, data: LunaticData | undefined
56
55
  Question: Pick<import("../components/type").LunaticBaseProps<unknown>, "id" | "label" | "description" | "declarations"> & {
57
56
  components: import("./commons/fill-components/fill-components").FilledLunaticComponentProps[];
58
57
  };
59
- ComponentSet: import("../components/type").LunaticBaseProps<unknown> & {
60
- components: import("./commons/fill-components/fill-components").FilledLunaticComponentProps[];
61
- value: Record<string, unknown>;
62
- response: undefined;
63
- };
64
58
  RosterForLoop: import("../components/type").LunaticBaseProps<unknown> & {
65
59
  lines: {
66
60
  min: number;
@@ -232,12 +226,12 @@ declare function useLunatic(source: LunaticSource, data: LunaticData | undefined
232
226
  status: import("./use-suggesters").SuggesterStatus;
233
227
  timestamp: number;
234
228
  };
235
- optionRenderer: FunctionComponent<{
229
+ optionRenderer: import("react").FunctionComponent<{
236
230
  option: import("../components/type").SuggesterOption;
237
231
  placeholder?: string | undefined;
238
232
  search?: string | undefined;
239
233
  }>;
240
- labelRenderer: FunctionComponent<{
234
+ labelRenderer: import("react").FunctionComponent<{
241
235
  option?: import("../components/type").SuggesterOption | undefined;
242
236
  selected?: boolean | undefined;
243
237
  search?: string | undefined;
@@ -294,11 +288,6 @@ declare function useLunatic(source: LunaticSource, data: LunaticData | undefined
294
288
  Question: Pick<import("../components/type").LunaticBaseProps<unknown>, "id" | "label" | "description" | "declarations"> & {
295
289
  components: import("./commons/fill-components/fill-components").FilledLunaticComponentProps[];
296
290
  };
297
- ComponentSet: import("../components/type").LunaticBaseProps<unknown> & {
298
- components: import("./commons/fill-components/fill-components").FilledLunaticComponentProps[];
299
- value: Record<string, unknown>;
300
- response: undefined;
301
- };
302
291
  RosterForLoop: import("../components/type").LunaticBaseProps<unknown> & {
303
292
  lines: {
304
293
  min: number;
@@ -470,12 +459,12 @@ declare function useLunatic(source: LunaticSource, data: LunaticData | undefined
470
459
  status: import("./use-suggesters").SuggesterStatus;
471
460
  timestamp: number;
472
461
  };
473
- optionRenderer: FunctionComponent<{
462
+ optionRenderer: import("react").FunctionComponent<{
474
463
  option: import("../components/type").SuggesterOption;
475
464
  placeholder?: string | undefined;
476
465
  search?: string | undefined;
477
466
  }>;
478
- labelRenderer: FunctionComponent<{
467
+ labelRenderer: import("react").FunctionComponent<{
479
468
  option?: import("../components/type").SuggesterOption | undefined;
480
469
  selected?: boolean | undefined;
481
470
  search?: string | undefined;
@@ -504,7 +493,7 @@ declare function useLunatic(source: LunaticSource, data: LunaticData | undefined
504
493
  }[];
505
494
  };
506
495
  })[] | undefined;
507
- }) => import("./commons/fill-components/fill-components").FilledLunaticComponentProps<"CheckboxOne" | "Sequence" | "Subsequence" | "RosterForLoop" | "Loop" | "Table" | "InputNumber" | "Datepicker" | "CheckboxGroup" | "CheckboxBoolean" | "Radio" | "FilterDescription" | "Dropdown" | "PairwiseLinks" | "Roundabout" | "Suggester" | "Input" | "Textarea" | "ComponentSet" | "Question">[];
496
+ }) => import("./commons/fill-components/fill-components").FilledLunaticComponentProps<"CheckboxOne" | "Sequence" | "Subsequence" | "RosterForLoop" | "Loop" | "Table" | "InputNumber" | "Datepicker" | "CheckboxGroup" | "CheckboxBoolean" | "Radio" | "FilterDescription" | "Dropdown" | "PairwiseLinks" | "Roundabout" | "Suggester" | "Input" | "Textarea" | "Question">[];
508
497
  goPreviousPage: () => void;
509
498
  goNextPage: (payload?: {}) => void;
510
499
  goToPage: (page: {
@@ -533,7 +522,7 @@ declare function useLunatic(source: LunaticSource, data: LunaticData | undefined
533
522
  };
534
523
  waiting: boolean;
535
524
  getData: (withRefreshedCalculated: boolean, variableNames?: string[]) => LunaticData;
536
- Provider: FunctionComponent<{
525
+ Provider: import("react").FunctionComponent<{
537
526
  children?: import("react").ReactNode;
538
527
  }>;
539
528
  onChange: (response: {
@@ -3,14 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.InRoundabout = exports.InLoop = exports.Default = void 0;
6
+ exports["default"] = exports.Default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
7
8
  var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
8
- var _source = _interopRequireDefault(require("./source"));
9
- var _data = _interopRequireDefault(require("./data"));
10
- var _sourceLoop = _interopRequireDefault(require("./source-loop.json"));
11
- var _dataLoop = _interopRequireDefault(require("./data-loop.json"));
12
- var _sourceRoundabout = _interopRequireDefault(require("./source-roundabout.json"));
13
- var _dataRoundabout = _interopRequireDefault(require("./data-roundabout.json"));
9
+ var _source = _interopRequireDefault(require("../input/source"));
10
+ var _data = _interopRequireDefault(require("../input/data"));
14
11
  var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
15
12
  var _jsxRuntime = require("react/jsx-runtime");
16
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -21,7 +18,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
21
18
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
22
19
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
20
  var stories = {
24
- title: 'Components/ComponentSet',
21
+ title: 'Behaviour/Slots',
25
22
  component: _orchestrator["default"],
26
23
  argTypes: _defaultArgTypes["default"]
27
24
  };
@@ -30,24 +27,38 @@ var Template = function Template(args) {
30
27
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_orchestrator["default"], _objectSpread({}, args));
31
28
  };
32
29
  var Default = exports.Default = Template.bind({});
30
+
31
+ /**
32
+ * @var
33
+ */
34
+ var CustomInput = function CustomInput(_ref) {
35
+ var _onChange = _ref.onChange,
36
+ value = _ref.value,
37
+ label = _ref.label;
38
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("fieldset", {
39
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("legend", {
40
+ style: {
41
+ color: 'gray',
42
+ fontSize: '1rem'
43
+ },
44
+ children: label
45
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
46
+ style: {
47
+ border: 'solid 3px gray',
48
+ padding: '.5rem 1rem'
49
+ },
50
+ value: value,
51
+ onChange: function onChange(e) {
52
+ return _onChange(e.target.value);
53
+ }
54
+ })]
55
+ });
56
+ };
33
57
  Default.args = {
34
- id: 'component-set',
58
+ id: 'input',
35
59
  source: _source["default"],
36
- pagination: true,
37
60
  data: _data["default"],
38
- readOnly: false
39
- };
40
- var InRoundabout = exports.InRoundabout = Template.bind({});
41
- InRoundabout.args = {
42
- id: 'component-set-roundabout',
43
- source: _sourceRoundabout["default"],
44
- pagination: true,
45
- data: _dataRoundabout["default"]
46
- };
47
- var InLoop = exports.InLoop = Template.bind({});
48
- InLoop.args = {
49
- id: 'component-set-loop',
50
- source: _sourceLoop["default"],
51
- pagination: true,
52
- data: _dataLoop["default"]
61
+ slots: {
62
+ Input: CustomInput
63
+ }
53
64
  };
@@ -3,11 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.Loop = exports.Default = exports.ComponentSet = void 0;
6
+ exports["default"] = exports.Loop = exports.Default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
9
9
  var _source = _interopRequireDefault(require("./source"));
10
- var _sourceComponentset = _interopRequireDefault(require("./sourceComponentset"));
11
10
  var _sourceLoop = _interopRequireDefault(require("./sourceLoop"));
12
11
  var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
13
12
  var _jsxRuntime = require("react/jsx-runtime");
@@ -41,10 +40,6 @@ Default.args = {
41
40
  source: _source["default"],
42
41
  shortcut: true
43
42
  };
44
- var ComponentSet = exports.ComponentSet = Template.bind({});
45
- ComponentSet.args = _objectSpread(_objectSpread({}, Default.args), {}, {
46
- source: _sourceComponentset["default"]
47
- });
48
43
  var Loop = exports.Loop = Template.bind({});
49
44
  Loop.args = _objectSpread(_objectSpread({}, Default.args), {}, {
50
45
  source: _sourceLoop["default"]
@@ -141,7 +141,7 @@
141
141
  },
142
142
  {
143
143
  "id": "component-set",
144
- "componentType": "ComponentSet",
144
+ "componentType": "Question",
145
145
  "page": "3",
146
146
  "conditionFilter": { "value": "true", "type": "VTL" },
147
147
  "label": {
@@ -3,12 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.PairwiseInComponentSet = exports.Filled = exports.Default = void 0;
6
+ exports["default"] = exports.Filled = exports.Default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
9
9
  var _source = _interopRequireDefault(require("./source.json"));
10
10
  var _data = _interopRequireDefault(require("./data"));
11
- var _sourceComponentset = _interopRequireDefault(require("./source-componentset.json"));
12
11
  var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
13
12
  var _e2e = require("../../../tests/utils/e2e");
14
13
  var _timer = require("../../../tests/utils/timer");
@@ -39,13 +38,6 @@ Default.args = {
39
38
  pagination: true,
40
39
  data: _data["default"]
41
40
  };
42
- var PairwiseInComponentSet = exports.PairwiseInComponentSet = Template.bind({});
43
- PairwiseInComponentSet.args = {
44
- id: 'links-componentset',
45
- source: _sourceComponentset["default"],
46
- pagination: true,
47
- data: _data["default"]
48
- };
49
41
  var Filled = exports.Filled = Template.bind({});
50
42
  Filled.args = _objectSpread(_objectSpread({}, Default.args), {}, {
51
43
  id: 'links-filled'
@@ -3,13 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.Default = exports.ComponentSet = void 0;
6
+ exports["default"] = exports.Default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
9
9
  var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
10
10
  var _referentiel = require("../utils/referentiel");
11
11
  var _source = _interopRequireDefault(require("./source"));
12
- var _sourceComponentSet = _interopRequireDefault(require("./source-component-set"));
13
12
  var _jsxRuntime = require("react/jsx-runtime");
14
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
14
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
@@ -34,10 +33,4 @@ Default.args = {
34
33
  autoSuggesterLoading: true,
35
34
  getReferentiel: _referentiel.getReferentiel,
36
35
  pagination: true
37
- };
38
- var ComponentSet = exports.ComponentSet = Template.bind({});
39
- ComponentSet.args = {
40
- source: _sourceComponentSet["default"],
41
- getReferentiel: _referentiel.getReferentiel,
42
- autoSuggesterLoading: true
43
36
  };
@@ -13,7 +13,7 @@ var _logger = require("../../utils/logger");
13
13
  var _overview = require("./overview");
14
14
  var _waiting = _interopRequireDefault(require("./waiting"));
15
15
  var _jsxRuntime = require("react/jsx-runtime");
16
- var _excluded = ["source", "data", "management", "shortcut", "activeControls", "features", "initialPage", "getStoreInfo", "missing", "missingStrategy", "missingShortcut", "autoSuggesterLoading", "addExternal", "preferences", "custom", "showOverview", "filterDescription", "getReferentiel", "dontKnowButton", "refusedButton", "readOnly"];
16
+ var _excluded = ["source", "data", "management", "shortcut", "activeControls", "features", "initialPage", "getStoreInfo", "missing", "missingStrategy", "missingShortcut", "autoSuggesterLoading", "addExternal", "preferences", "slots", "showOverview", "filterDescription", "getReferentiel", "dontKnowButton", "refusedButton", "readOnly"];
17
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
18
18
  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); }
19
19
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
@@ -161,7 +161,7 @@ function OrchestratorForStories(_ref3) {
161
161
  autoSuggesterLoading = _ref3.autoSuggesterLoading,
162
162
  addExternal = _ref3.addExternal,
163
163
  preferences = _ref3.preferences,
164
- custom = _ref3.custom,
164
+ slots = _ref3.slots,
165
165
  _ref3$showOverview = _ref3.showOverview,
166
166
  showOverview = _ref3$showOverview === void 0 ? false : _ref3$showOverview,
167
167
  _ref3$filterDescripti = _ref3.filterDescription,
@@ -177,10 +177,9 @@ function OrchestratorForStories(_ref3) {
177
177
  features: features,
178
178
  preferences: preferences,
179
179
  onChange: onLogChange,
180
- custom: custom,
181
180
  autoSuggesterLoading: autoSuggesterLoading,
182
181
  getReferentiel: getReferentiel,
183
- workersBasePath: "./workers",
182
+ workersBasePath: './workers',
184
183
  management: management,
185
184
  missing: missing,
186
185
  missingStrategy: missingStrategy,
@@ -263,6 +262,7 @@ function OrchestratorForStories(_ref3) {
263
262
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
264
263
  className: "components",
265
264
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_2.LunaticComponents, {
265
+ slots: slots,
266
266
  autoFocusKey: pageTag,
267
267
  components: components,
268
268
  componentProps: function componentProps(_ref4) {
@@ -146,7 +146,6 @@ function fillSpecificExpressions(component, state) {
146
146
  switch (component.componentType) {
147
147
  case 'Roundabout':
148
148
  return fillRoundaboutProps(component, state);
149
- case 'ComponentSet':
150
149
  case 'Question':
151
150
  return fillChildComponents(component, state);
152
151
  case 'Loop':
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createLunaticProvider = createLunaticProvider;
7
- exports.useLunaticMissing = exports.useLunaticManagement = exports.useLunaticCustom = void 0;
7
+ exports.useLunaticMissing = exports.useLunaticManagement = void 0;
8
8
  var _react = require("react");
9
9
  var _index = _interopRequireDefault(require("../i18n/index"));
10
10
  var _jsxRuntime = require("react/jsx-runtime");
@@ -14,7 +14,6 @@ var LunaticContext = /*#__PURE__*/(0, _react.createContext)({
14
14
  management: false,
15
15
  missing: false,
16
16
  shortcut: false,
17
- custom: {},
18
17
  missingShortcut: {
19
18
  dontKnow: '',
20
19
  refused: ''
@@ -42,18 +41,12 @@ var useLunaticMissing = exports.useLunaticMissing = function useLunaticMissing()
42
41
  };
43
42
  };
44
43
 
45
- /** Return custom elements list to override native components */
46
- var useLunaticCustom = exports.useLunaticCustom = function useLunaticCustom() {
47
- return (0, _react.useContext)(LunaticContext).custom;
48
- };
49
-
50
44
  /** Provide `management` to display data states [COLLECTED,EDITED,FORCED] */
51
45
  var useLunaticManagement = exports.useLunaticManagement = function useLunaticManagement() {
52
46
  return (0, _react.useContext)(LunaticContext).management;
53
47
  };
54
48
  function createLunaticProvider(_ref) {
55
- var custom = _ref.custom,
56
- management = _ref.management,
49
+ var management = _ref.management,
57
50
  missing = _ref.missing,
58
51
  missingStrategy = _ref.missingStrategy,
59
52
  shortcut = _ref.shortcut,
@@ -61,7 +54,6 @@ function createLunaticProvider(_ref) {
61
54
  dontKnowButton = _ref.dontKnowButton,
62
55
  refusedButton = _ref.refusedButton;
63
56
  var value = {
64
- custom: custom,
65
57
  management: management,
66
58
  missing: missing,
67
59
  missingStrategy: missingStrategy,
@@ -11,8 +11,8 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
11
11
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
12
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
13
  /**
14
- * Pour le ComponentSet : les composants du fieldset n'existe pas dans pages.
15
- * Ils échappent donc aux controls. On les substitue ici au ComponentSet.
14
+ * Pour le Question : les composants du fieldset n'existe pas dans pages.
15
+ * Ils échappent donc aux controls. On les substitue ici au Question.
16
16
  * On ne peut pas les ajouter directement dans pages (en spécifiant un page), car ils s'afficheraient 2 fois : dans le fieldset et en dessus, comme
17
17
  * des composant à part entière.
18
18
  * D'autres composant pourraient un jour figurer ici.
@@ -22,7 +22,6 @@ function replaceComponentSequence(components) {
22
22
  var componentType = component.componentType;
23
23
  switch (componentType) {
24
24
  case 'Question':
25
- case 'ComponentSet':
26
25
  return [].concat(_toConsumableArray(acc), _toConsumableArray(component.components));
27
26
  default:
28
27
  return [].concat(_toConsumableArray(acc), [component]);
@@ -65,8 +65,6 @@ function useLunatic(source) {
65
65
  _ref$activeControls = _ref.activeControls,
66
66
  activeControls = _ref$activeControls === void 0 ? false : _ref$activeControls,
67
67
  getReferentiel = _ref.getReferentiel,
68
- _ref$custom = _ref.custom,
69
- custom = _ref$custom === void 0 ? empty : _ref$custom,
70
68
  _ref$withOverview = _ref.withOverview,
71
69
  withOverview = _ref$withOverview === void 0 ? false : _ref$withOverview,
72
70
  _ref$missing = _ref.missing,
@@ -99,7 +97,6 @@ function useLunatic(source) {
99
97
  // Required context provider: cleaner than prop drilling through every component
100
98
  var Provider = (0, _react.useMemo)(function () {
101
99
  return (0, _lunaticContext.createLunaticProvider)({
102
- custom: custom,
103
100
  management: management,
104
101
  missing: missing,
105
102
  missingStrategy: missingStrategy,
@@ -108,7 +105,7 @@ function useLunatic(source) {
108
105
  dontKnowButton: dontKnowButton,
109
106
  refusedButton: refusedButton
110
107
  });
111
- }, [custom, management, missing, missingStrategy, shortcut, missingShortcut, dontKnowButton, refusedButton]);
108
+ }, [management, missing, missingStrategy, shortcut, missingShortcut, dontKnowButton, refusedButton]);
112
109
  var getSuggesterStatus = (0, _useSuggesters.useSuggesters)({
113
110
  auto: autoSuggesterLoading,
114
111
  getReferentiel: getReferentiel,
@@ -6,7 +6,6 @@ var _useLunatic = _interopRequireDefault(require("./use-lunatic"));
6
6
  var _source = _interopRequireDefault(require("../stories/overview/source.json"));
7
7
  var _source2 = _interopRequireDefault(require("../stories/questionnaires/logement/source.json"));
8
8
  var _source3 = _interopRequireDefault(require("../stories/questionnaires2023/simpsons/source.json"));
9
- var _source4 = _interopRequireDefault(require("../stories/component-set/source.json"));
10
9
  var _sourceLoop = _interopRequireDefault(require("../stories/behaviour/cleaning/source-loop.json"));
11
10
  var _sourceResizingCleaning = _interopRequireDefault(require("../stories/behaviour/resizing/source-resizing-cleaning.json"));
12
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -220,38 +219,13 @@ var dataFromObject = function dataFromObject(o) {
220
219
  (0, _vitest.expect)(result.current.getData(true).COLLECTED.PRENOMS.COLLECTED).toEqual([null, null]);
221
220
  });
222
221
  });
223
- (0, _vitest.describe)('getComponents()', function () {
224
- (0, _vitest.describe)('componentSet', function () {
225
- var _renderHook12 = (0, _reactHooks.renderHook)(function () {
226
- return (0, _useLunatic["default"])(_source4["default"], undefined, {});
227
- }),
228
- result = _renderHook12.result;
229
- var getComponents = function getComponents() {
230
- return result.current.getComponents();
231
- };
232
- (0, _vitest.it)('should fill child components', function () {
233
- var _components$0$compone;
234
- var components = getComponents();
235
- (0, _vitest.expect)(components).toHaveLength(1);
236
- (0, _vitest.expect)((_components$0$compone = components[0].components) !== null && _components$0$compone !== void 0 ? _components$0$compone : []).toHaveLength(2);
237
- });
238
- (0, _vitest.it)('should use conditionFilter on nested components', function () {
239
- (0, _reactHooks.act)(function () {
240
- return result.current.onChange({
241
- name: 'PRENOM'
242
- }, 'Jane');
243
- });
244
- (0, _vitest.expect)(getComponents()[0].components).toHaveLength(3);
245
- });
246
- });
247
- });
248
222
  (0, _vitest.describe)('getData()', function () {
249
223
  var hookRef;
250
224
  (0, _vitest.beforeEach)(function () {
251
- var _renderHook13 = (0, _reactHooks.renderHook)(function () {
225
+ var _renderHook12 = (0, _reactHooks.renderHook)(function () {
252
226
  return (0, _useLunatic["default"])(_source3["default"], undefined, {});
253
227
  }),
254
- result = _renderHook13.result;
228
+ result = _renderHook12.result;
255
229
  (0, _reactHooks.act)(function () {
256
230
  result.current.onChange({
257
231
  name: 'COMMENT'
@@ -297,12 +271,12 @@ var dataFromObject = function dataFromObject(o) {
297
271
  (0, _vitest.describe)('getChangedData()', function () {
298
272
  var hookRef;
299
273
  (0, _vitest.beforeEach)(function () {
300
- var _renderHook14 = (0, _reactHooks.renderHook)(function () {
274
+ var _renderHook13 = (0, _reactHooks.renderHook)(function () {
301
275
  return (0, _useLunatic["default"])(_source3["default"], undefined, {
302
276
  trackChanges: true
303
277
  });
304
278
  }),
305
- result = _renderHook14.result;
279
+ result = _renderHook13.result;
306
280
  hookRef = result;
307
281
  });
308
282
  (0, _vitest.it)('should return every value', function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "3.0.0-rc.1",
3
+ "version": "3.0.0-rc.6",
4
4
  "workersVersion": "0.3.0",
5
5
  "description": "Library of questionnaire components",
6
6
  "repository": {
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.ComponentSet = ComponentSet;
8
- exports.ComponentSetItem = void 0;
9
- var _LunaticComponents = require("../LunaticComponents");
10
- var _customizedComponent = require("../shared/HOC/customizedComponent");
11
- var _ComponentErrors = require("../shared/ComponentErrors/ComponentErrors");
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- var _excluded = ["id", "label", "description", "response", "components"];
14
- 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
- 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
- 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; }
17
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
- 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; }
20
- 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; }
21
- function ComponentSet(_ref) {
22
- var id = _ref.id,
23
- label = _ref.label,
24
- description = _ref.description,
25
- response = _ref.response,
26
- components = _ref.components,
27
- props = _objectWithoutProperties(_ref, _excluded);
28
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(ComponentSetWrapper, {
29
- id: id,
30
- legendText: label,
31
- errors: props.errors,
32
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LunaticComponents.LunaticComponents, {
33
- components: components
34
- // Component props take precedence (we don't want to override value for instance)
35
- ,
36
- componentProps: function componentProps(c) {
37
- return _objectSpread(_objectSpread({}, props), c);
38
- },
39
- wrapper: function wrapper(p) {
40
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(ComponentSetItem, _objectSpread({}, p));
41
- }
42
- })
43
- });
44
- }
45
- var ComponentSetWrapper = (0, _customizedComponent.customizedComponent)('ComponentSet', function (props) {
46
- var id = props.id,
47
- errors = props.errors,
48
- legendText = props.legendText,
49
- children = props.children;
50
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("fieldset", {
51
- className: "lunatic-component-set",
52
- children: [legendText && /*#__PURE__*/(0, _jsxRuntime.jsx)("legend", {
53
- id: id,
54
- className: "lunatic-legend",
55
- children: legendText
56
- }), children, /*#__PURE__*/(0, _jsxRuntime.jsx)(_ComponentErrors.ComponentErrors, {
57
- errors: errors,
58
- componentId: id
59
- })]
60
- });
61
- });
62
- var ComponentSetItem = exports.ComponentSetItem = (0, _customizedComponent.customizedComponent)('ComponentSetItem', function (_ref2) {
63
- var children = _ref2.children;
64
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
65
- className: "lunatic-component-set-component",
66
- children: children
67
- });
68
- });
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,7 +0,0 @@
1
- import type { LunaticComponentProps } from '../type';
2
- import type { ReactNode } from 'react';
3
- export declare function ComponentSet({ id, label, description, response, // Do not propagate the response (it's undefined)
4
- components, ...props }: LunaticComponentProps<'ComponentSet'>): import("react/jsx-runtime").JSX.Element;
5
- export declare const ComponentSetItem: import("react").ComponentType<{
6
- children?: ReactNode;
7
- }>;
@@ -1,5 +0,0 @@
1
- import { type ComponentType, type FunctionComponent } from 'react';
2
- /**
3
- * Create a replaceable version of a component
4
- */
5
- export declare function customizedComponent<T extends Record<string, unknown>>(name: string, LunaticField: FunctionComponent<T>): ComponentType<T>;