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

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 (186) hide show
  1. package/lib/components/CheckboxBoolean/CheckboxBoolean.js +39 -19
  2. package/lib/components/CheckboxGroup/CheckboxGroup.js +3 -2
  3. package/lib/components/CheckboxGroup/CustomCheckboxGroup.js +4 -5
  4. package/lib/components/CheckboxGroup/CustomCheckboxGroup.spec.js +3 -0
  5. package/lib/components/CheckboxOne/CheckboxOne.js +6 -7
  6. package/lib/components/Datepicker/Datepicker.js +43 -29
  7. package/lib/components/Dropdown/Dropdown.js +37 -37
  8. package/lib/components/Duration/Duration.js +41 -17
  9. package/lib/components/FilterDescription/FilterDescription.js +2 -3
  10. package/lib/components/Input/Input.js +39 -22
  11. package/lib/components/InputNumber/InputNumber.js +45 -35
  12. package/lib/components/InputNumber/__snapshots__/InputNumber.spec.tsx.snap +0 -2
  13. package/lib/components/Loop/Loop.js +52 -29
  14. package/lib/components/LunaticComponents.js +60 -51
  15. package/lib/components/Question/Question.js +23 -14
  16. package/lib/components/Radio/Radio.js +2 -2
  17. package/lib/components/RosterForLoop/RosterForLoop.js +13 -36
  18. package/lib/components/Roundabout/CustomRoundabout.js +2 -2
  19. package/lib/components/Roundabout/Roundabout.js +0 -1
  20. package/lib/components/Roundabout/RoundaboutItButton.js +2 -2
  21. package/lib/components/Roundabout/extra.js +6 -6
  22. package/lib/components/Sequence/Sequence.js +2 -3
  23. package/lib/components/Subsequence/Subsequence.js +2 -2
  24. package/lib/components/Subsequence/Subsequence.spec.js +1 -1
  25. package/lib/components/Suggester/CustomSuggester.js +9 -6
  26. package/lib/components/Suggester/Suggester.js +67 -4
  27. package/lib/components/Suggester/SuggesterNotification.js +2 -2
  28. package/lib/components/Summary/Summary.js +3 -3
  29. package/lib/components/Switch/Switch.js +42 -22
  30. package/lib/components/Textarea/Textarea.js +43 -24
  31. package/lib/components/library.js +0 -2
  32. package/lib/components/shared/Button/Button.js +2 -3
  33. package/lib/components/shared/Button/IconButton.js +0 -1
  34. package/lib/components/shared/Checkbox/CheckboxOption.js +2 -3
  35. package/lib/components/shared/Combobox/Combobox.js +5 -4
  36. package/lib/components/shared/Combobox/ComboboxContainer.js +2 -2
  37. package/lib/components/shared/Combobox/ComboboxContentBox.js +2 -2
  38. package/lib/components/shared/Combobox/Panel/ComboboxOption.js +2 -2
  39. package/lib/components/shared/Combobox/Panel/ComboboxPanelContainer.js +2 -2
  40. package/lib/components/shared/Combobox/Selection/ComboboxClearButton.js +2 -2
  41. package/lib/components/shared/Combobox/Selection/ComboboxInput.js +2 -2
  42. package/lib/components/shared/Combobox/Selection/ComboboxLabelSelection.js +2 -2
  43. package/lib/components/shared/ComponentErrors/ComponentErrors.js +0 -1
  44. package/lib/components/shared/Declarations/Declarations.js +6 -7
  45. package/lib/components/shared/Declarations/Declarations.spec.js +5 -5
  46. package/lib/components/shared/Fieldset/Fieldset.js +2 -3
  47. package/lib/components/shared/HOC/{customizedComponent.js → slottableComponent.js} +35 -13
  48. package/lib/components/shared/Icons/lunatic-icon.js +0 -1
  49. package/lib/components/shared/Label/Label.js +2 -3
  50. package/lib/components/shared/MDLabel/RouterLink.js +2 -2
  51. package/lib/components/shared/Missing/Missing.js +0 -1
  52. package/lib/components/shared/ModalControls/ModalControls.js +0 -1
  53. package/lib/components/shared/Notification.js +2 -2
  54. package/lib/components/shared/Radio/RadioGroup.js +4 -4
  55. package/lib/components/shared/Radio/RadioOption.js +2 -2
  56. package/lib/components/shared/Table/Table.js +2 -3
  57. package/lib/components/shared/Table/Tbody.js +2 -2
  58. package/lib/components/shared/Table/Td.js +2 -2
  59. package/lib/components/shared/Table/Th.js +2 -2
  60. package/lib/components/shared/Table/Thead.js +2 -2
  61. package/lib/components/shared/Table/Tr.js +2 -2
  62. package/lib/components/shared/VariableStatus/VariableStatus.js +0 -1
  63. package/lib/components/shared/suggester-loader-widget/dragger/dragger.js +0 -1
  64. package/lib/components/shared/suggester-loader-widget/widget.js +0 -1
  65. package/lib/css/components/Button.scss +24 -0
  66. package/lib/css/components/CheckboxGroup.scss +13 -0
  67. package/lib/css/components/CheckboxOne.scss +19 -0
  68. package/lib/css/components/CheckboxOption.scss +19 -0
  69. package/lib/css/components/Combobox.scss +206 -0
  70. package/lib/css/components/ComponentErrors.scss +5 -0
  71. package/lib/css/components/Datepicker.scss +19 -0
  72. package/lib/css/components/Declarations.scss +42 -0
  73. package/lib/css/components/Dragger.scss +8 -0
  74. package/lib/css/components/Dropdown.scss +38 -0
  75. package/lib/css/components/Duration.scss +9 -0
  76. package/lib/css/components/Fieldset.scss +5 -0
  77. package/lib/css/components/IconButton.scss +38 -0
  78. package/lib/css/components/Input.scss +42 -0
  79. package/lib/css/components/InputNumber.scss +11 -0
  80. package/lib/css/components/Label.scss +6 -0
  81. package/lib/css/components/Missing.scss +27 -0
  82. package/lib/css/components/ModalControls.scss +48 -0
  83. package/lib/css/components/RadioGroup.scss +21 -0
  84. package/lib/css/components/RosterForLoop.scss +39 -0
  85. package/lib/css/components/Roundabout.scss +13 -0
  86. package/lib/css/components/Sequence.scss +10 -0
  87. package/lib/css/components/Suggester.scss +170 -0
  88. package/lib/css/components/SuggesterWidget.scss +176 -0
  89. package/lib/css/components/Table.scss +27 -0
  90. package/lib/css/components/Textarea.scss +8 -0
  91. package/lib/css/components/VariableStatus.scss +36 -0
  92. package/lib/css/main.scss +181 -0
  93. package/lib/hooks/useSuggesterInfo.js +14 -12
  94. package/lib/main.css +1063 -0
  95. package/lib/main.css.map +1 -0
  96. package/lib/src/components/CheckboxBoolean/CheckboxBoolean.d.ts +10 -5
  97. package/lib/src/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  98. package/lib/src/components/CheckboxOne/CheckboxOne.d.ts +5 -12
  99. package/lib/src/components/Datepicker/Datepicker.d.ts +8 -10
  100. package/lib/src/components/Dropdown/Dropdown.d.ts +9 -12
  101. package/lib/src/components/Duration/Duration.d.ts +9 -7
  102. package/lib/src/components/FilterDescription/FilterDescription.d.ts +1 -1
  103. package/lib/src/components/Input/Input.d.ts +9 -8
  104. package/lib/src/components/InputNumber/InputNumber.d.ts +9 -10
  105. package/lib/src/components/Loop/Loop.d.ts +11 -18
  106. package/lib/src/components/LunaticComponents.d.ts +4 -2
  107. package/lib/src/components/Question/Question.d.ts +6 -4
  108. package/lib/src/components/RosterForLoop/RosterForLoop.d.ts +2 -22
  109. package/lib/src/components/Roundabout/Roundabout.d.ts +0 -1
  110. package/lib/src/components/Sequence/Sequence.d.ts +1 -2
  111. package/lib/src/components/Subsequence/Subsequence.d.ts +1 -1
  112. package/lib/src/components/Suggester/CustomSuggester.d.ts +7 -3
  113. package/lib/src/components/Suggester/Suggester.d.ts +1 -2
  114. package/lib/src/components/Suggester/SuggesterType.d.ts +6 -0
  115. package/lib/src/components/Suggester/helpers.d.ts +2 -2
  116. package/lib/src/components/Switch/Switch.d.ts +9 -0
  117. package/lib/src/components/Textarea/Textarea.d.ts +9 -10
  118. package/lib/src/components/library.d.ts +26 -93
  119. package/lib/src/components/shared/Button/Button.d.ts +0 -1
  120. package/lib/src/components/shared/Button/IconButton.d.ts +0 -1
  121. package/lib/src/components/shared/Checkbox/CheckboxOption.d.ts +0 -1
  122. package/lib/src/components/shared/Combobox/Combobox.d.ts +1 -1
  123. package/lib/src/components/shared/ComponentErrors/ComponentErrors.d.ts +0 -1
  124. package/lib/src/components/shared/Declarations/Declarations.d.ts +2 -3
  125. package/lib/src/components/shared/Fieldset/Fieldset.d.ts +0 -1
  126. package/lib/src/components/shared/HOC/slottableComponent.d.ts +105 -0
  127. package/lib/src/components/shared/Icons/lunatic-icon.d.ts +0 -1
  128. package/lib/src/components/shared/Label/Label.d.ts +0 -1
  129. package/lib/src/components/shared/Missing/Missing.d.ts +0 -1
  130. package/lib/src/components/shared/ModalControls/ModalControls.d.ts +0 -1
  131. package/lib/src/components/shared/Radio/RadioGroup.d.ts +1 -1
  132. package/lib/src/components/shared/Table/Table.d.ts +0 -1
  133. package/lib/src/components/shared/VariableStatus/VariableStatus.d.ts +0 -1
  134. package/lib/src/components/shared/suggester-loader-widget/dragger/dragger.d.ts +0 -1
  135. package/lib/src/components/shared/suggester-loader-widget/widget.d.ts +0 -1
  136. package/lib/src/components/type.d.ts +7 -7
  137. package/lib/src/hooks/use-track-changes.d.ts +9 -1
  138. package/lib/src/hooks/useSuggesterInfo.d.ts +1 -1
  139. package/lib/src/index.d.ts +1 -1
  140. package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +106 -59
  141. package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +87 -58
  142. package/lib/src/use-lunatic/commons/fill-components/fill-iterations.d.ts +47 -38
  143. package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +159 -87
  144. package/lib/src/use-lunatic/commons/use-components-from-state.d.ts +1 -1
  145. package/lib/src/use-lunatic/lunatic-context.d.ts +1 -4
  146. package/lib/src/use-lunatic/replace-component-sequence.d.ts +23 -5
  147. package/lib/src/use-lunatic/type-source.d.ts +55 -46
  148. package/lib/src/use-lunatic/type.d.ts +4 -4
  149. package/lib/src/use-lunatic/use-lunatic.d.ts +63 -32
  150. package/lib/src/utils/variables.d.ts +10 -2
  151. package/lib/stories/{component-set/component-set.stories.js → behaviour/slots.stories.js} +36 -25
  152. package/lib/stories/checkbox-group/checkbox-group.stories.js +1 -6
  153. package/lib/stories/disabled/source.json +1 -1
  154. package/lib/stories/loop/source-roster.json +2 -2
  155. package/lib/stories/pairwise/pairwise-links.stories.js +1 -9
  156. package/lib/stories/suggester/fakeReferentiel.json +12 -0
  157. package/lib/stories/suggester/source-option-responses.json +145 -0
  158. package/lib/stories/suggester/suggester.stories.js +45 -7
  159. package/lib/stories/utils/orchestrator.js +4 -4
  160. package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +0 -1
  161. package/lib/use-lunatic/lunatic-context.js +2 -10
  162. package/lib/use-lunatic/replace-component-sequence.js +2 -3
  163. package/lib/use-lunatic/use-lunatic.js +1 -4
  164. package/lib/use-lunatic/use-lunatic.test.js +12 -37
  165. package/lib/use-lunatic/use-suggesters.js +23 -24
  166. package/package.json +2 -2
  167. package/lib/components/ComponentSet/ComponentSet.js +0 -68
  168. package/lib/components/Dropdown/DropdownWritable.js +0 -58
  169. package/lib/components/Dropdown/renderer/WritableLabelRenderer.js +0 -38
  170. package/lib/components/Dropdown/renderer/WritableOptionRenderer.js +0 -140
  171. package/lib/src/components/ComponentSet/ComponentSet.d.ts +0 -7
  172. package/lib/src/components/Dropdown/DropdownWritable.d.ts +0 -17
  173. package/lib/src/components/Dropdown/renderer/WritableLabelRenderer.d.ts +0 -8
  174. package/lib/src/components/Dropdown/renderer/WritableOptionRenderer.d.ts +0 -8
  175. package/lib/src/components/shared/HOC/customizedComponent.d.ts +0 -5
  176. package/lib/src/components/type-custom.d.ts +0 -101
  177. package/lib/stories/checkbox-group/sourceComponentset.json +0 -424
  178. package/lib/stories/component-set/data-loop.json +0 -18
  179. package/lib/stories/component-set/data-roundabout.json +0 -25
  180. package/lib/stories/component-set/data.json +0 -25
  181. package/lib/stories/component-set/source-loop.json +0 -308
  182. package/lib/stories/component-set/source-roundabout.json +0 -434
  183. package/lib/stories/component-set/source.json +0 -113
  184. package/lib/stories/pairwise/source-componentset.json +0 -292
  185. package/lib/stories/suggester/source-component-set.json +0 -113
  186. /package/lib/components/{type-custom.js → Suggester/SuggesterType.js} +0 -0
@@ -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,58 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DropdownWritable = DropdownWritable;
7
- var _react = require("react");
8
- var _WritableOptionRenderer = require("./renderer/WritableOptionRenderer");
9
- var _WritableLabelRenderer = require("./renderer/WritableLabelRenderer");
10
- var _Combobox = require("../shared/Combobox/Combobox");
11
- var _helpers = require("./helpers");
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
18
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
- function DropdownWritable(_ref) {
20
- var id = _ref.id,
21
- disabled = _ref.disabled,
22
- options = _ref.options,
23
- onSelect = _ref.onSelect,
24
- className = _ref.className,
25
- value = _ref.value,
26
- label = _ref.label,
27
- errors = _ref.errors,
28
- description = _ref.description,
29
- readOnly = _ref.readOnly;
30
- var _useState = (0, _react.useState)(options),
31
- _useState2 = _slicedToArray(_useState, 2),
32
- filtered = _useState2[0],
33
- setFiltered = _useState2[1];
34
- var onChange = (0, _react.useCallback)(function (search) {
35
- if (search) {
36
- setFiltered((0, _helpers.filterOptions)(options, search));
37
- } else {
38
- setFiltered(options);
39
- }
40
- onSelect(null);
41
- }, [options, onSelect]);
42
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Combobox.Combobox, {
43
- id: id,
44
- className: className,
45
- disabled: disabled,
46
- readOnly: readOnly,
47
- options: filtered,
48
- onSelect: onSelect,
49
- onChange: onChange,
50
- optionRenderer: _WritableOptionRenderer.WritableOptionRenderer,
51
- labelRenderer: _WritableLabelRenderer.WritableLabelRenderer,
52
- editable: true,
53
- value: value,
54
- label: label,
55
- errors: errors,
56
- description: description
57
- });
58
- }
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.WritableLabelRenderer = WritableLabelRenderer;
7
- var _react = require("react");
8
- var _jsxRuntime = require("react/jsx-runtime");
9
- function getContent(option, search) {
10
- if (option) {
11
- var value = option.value,
12
- label = option.label;
13
- if ( /*#__PURE__*/(0, _react.isValidElement)(label)) {
14
- return label;
15
- }
16
- return label ? "".concat(value, " - ").concat(label) : value;
17
- }
18
- if (search !== null && search !== void 0 && search.trim().length) {
19
- return search;
20
- }
21
- return null;
22
- }
23
- function WritableLabelRenderer(_ref) {
24
- var option = _ref.option,
25
- placeholder = _ref.placeholder,
26
- search = _ref.search;
27
- var content = getContent(option, search);
28
- if (content) {
29
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
30
- className: "selection",
31
- children: content
32
- });
33
- }
34
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
35
- className: "placeholder",
36
- children: placeholder
37
- });
38
- }
@@ -1,140 +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.WritableOptionRenderer = WritableOptionRenderer;
8
- var _react = require("react");
9
- var _classnames = _interopRequireDefault(require("classnames"));
10
- var _helpers = require("../helpers");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
- 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; }
16
- 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; }
17
- 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; }
18
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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); }
20
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
21
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
23
- function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
24
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
26
- 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; }
27
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
28
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
29
- function hightlightSearch(label, prefix) {
30
- var labelText = (0, _helpers.labelToString)(label);
31
- var initLetters = (0, _helpers.lettersMatching)(labelText, prefix);
32
- return labelText.split('').reduce(function (_ref, c) {
33
- var letters = _ref.letters,
34
- stack = _ref.stack;
35
- var m = (0, _helpers.preparePrefix)(c);
36
- var _letters = _toArray(letters),
37
- first = _letters[0],
38
- rest = _letters.slice(1);
39
- if (m === first) {
40
- return {
41
- letters: rest,
42
- stack: [].concat(_toConsumableArray(stack), [{
43
- "char": c,
44
- className: 'prefix'
45
- }])
46
- };
47
- }
48
- return {
49
- letters: letters,
50
- stack: [].concat(_toConsumableArray(stack), [{
51
- "char": c,
52
- className: 'normal'
53
- }])
54
- };
55
- }, {
56
- letters: initLetters,
57
- stack: []
58
- }).stack.reduce(function (_ref2, _ref3) {
59
- var last = _ref2.last,
60
- stack = _ref2.stack;
61
- var _char = _ref3["char"],
62
- className = _ref3.className;
63
- if (!last) {
64
- return {
65
- last: className,
66
- stack: [{
67
- part: _char,
68
- className: className
69
- }]
70
- };
71
- }
72
- if (last !== className) {
73
- return {
74
- last: className,
75
- stack: [{
76
- part: _char,
77
- className: className
78
- }].concat(_toConsumableArray(stack))
79
- };
80
- }
81
- var _stack = _toArray(stack),
82
- first = _stack[0],
83
- rest = _stack.slice(1);
84
- return {
85
- last: className,
86
- stack: [_objectSpread(_objectSpread({}, first), {}, {
87
- part: "".concat(first.part).concat(_char)
88
- })].concat(_toConsumableArray(rest))
89
- };
90
- }, {
91
- last: undefined,
92
- stack: []
93
- }).stack.reverse();
94
- }
95
- function WritableOptionRenderer(_ref4) {
96
- var option = _ref4.option,
97
- selected = _ref4.selected,
98
- search = _ref4.search;
99
- var _useState = (0, _react.useState)([]),
100
- _useState2 = _slicedToArray(_useState, 2),
101
- parts = _useState2[0],
102
- setParts = _useState2[1];
103
- var value = option.value,
104
- label = option.label;
105
- (0, _react.useEffect)(function () {
106
- setParts(hightlightSearch(label, search));
107
- }, [search, label]);
108
- if (parts !== null && parts !== void 0 && parts.length) {
109
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
110
- className: (0, _classnames["default"])('lunatic-dropdown-option', {
111
- selected: selected
112
- }),
113
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
114
- className: "id",
115
- children: value
116
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
117
- children: "\xA0\u2014\xA0"
118
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
119
- className: "label",
120
- children: parts.map(function (_ref5, i) {
121
- var part = _ref5.part,
122
- className = _ref5.className;
123
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
124
- className: className,
125
- children: part
126
- }, i);
127
- })
128
- })]
129
- });
130
- }
131
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
132
- className: (0, _classnames["default"])('lunatic-dropdown-option', {
133
- selected: selected
134
- }),
135
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
136
- className: "id",
137
- children: value
138
- })
139
- });
140
- }
@@ -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,17 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- import type { ComboboxOptionType } from '../shared/Combobox/ComboboxType';
3
- import type { LunaticError } from '../../use-lunatic/type';
4
- type Props = {
5
- id?: string;
6
- disabled?: boolean;
7
- options: ComboboxOptionType[];
8
- onSelect: (v: string | null) => void;
9
- className?: string;
10
- value: string | null;
11
- label?: ReactNode;
12
- errors?: LunaticError[];
13
- description?: ReactNode;
14
- readOnly?: boolean;
15
- };
16
- export declare function DropdownWritable({ id, disabled, options, onSelect, className, value, label, errors, description, readOnly, }: Props): import("react/jsx-runtime").JSX.Element;
17
- export {};
@@ -1,8 +0,0 @@
1
- import type { ComboboxOptionType } from '../../shared/Combobox/ComboboxType';
2
- type Props = {
3
- option?: ComboboxOptionType;
4
- placeholder?: string;
5
- search?: string;
6
- };
7
- export declare function WritableLabelRenderer({ option, placeholder, search }: Props): import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -1,8 +0,0 @@
1
- import type { ComboboxOptionType } from '../../shared/Combobox/ComboboxType';
2
- type Props = {
3
- option: ComboboxOptionType;
4
- selected?: boolean;
5
- search?: string;
6
- };
7
- export declare function WritableOptionRenderer({ option, selected, search }: Props): import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -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>;
@@ -1,101 +0,0 @@
1
- import type { Subsequence } from './Subsequence/Subsequence';
2
- import type { Input } from './Input/Input';
3
- import type { Declaration, Declarations } from './shared/Declarations/Declarations';
4
- import type { Label } from './shared/Label/Label';
5
- import { Tr, Td, Th, Tbody, Thead, Table } from './shared/Table';
6
- import type { Textarea } from './Textarea/Textarea';
7
- import type { RadioGroup } from './shared/Radio/RadioGroup';
8
- import type { CustomRoundabout } from './Roundabout/CustomRoundabout';
9
- import { RoundaboutContainer, RoundaboutItContainer, RoundaboutItTitle, RoundaboutLabel, RoundaboutPending } from './Roundabout/extra';
10
- import type { RoundaboutItButton } from './Roundabout/RoundaboutItButton';
11
- import type { Button } from './shared/Button/Button';
12
- import type { CheckboxBoolean } from './CheckboxBoolean/CheckboxBoolean';
13
- import { CheckboxOne } from './CheckboxOne/CheckboxOne';
14
- import type { CheckboxOption } from './shared/Checkbox/CheckboxOption';
15
- import type { Datepicker } from './Datepicker/Datepicker';
16
- import type { Duration } from './Duration/Duration';
17
- import { Fieldset } from './shared/Fieldset/Fieldset';
18
- import type { InputNumber } from './InputNumber/InputNumber';
19
- import type { Question } from './Question/Question';
20
- import type { RadioOption } from './shared/Radio/RadioOption';
21
- import type { Sequence } from './Sequence/Sequence';
22
- import type { Switch } from './Switch/Switch';
23
- import type { Loop } from './Loop/Loop';
24
- import type { RosterForLoop } from './RosterForLoop/RosterForLoop';
25
- import type { Dropdown } from './Dropdown/Dropdown';
26
- import type { Combobox } from './shared/Combobox/Combobox';
27
- import { ComboboxContainer } from './shared/Combobox/ComboboxContainer';
28
- import { ComboboxContentBox } from './shared/Combobox/ComboboxContentBox';
29
- import { ComboboxOption } from './shared/Combobox/Panel/ComboboxOption';
30
- import type { ComboboxPanelContainer } from './shared/Combobox/Panel/ComboboxPanelContainer';
31
- import type { ComboboxClearButton } from './shared/Combobox/Selection/ComboboxClearButton';
32
- import type { ComboboxLabelSelection } from './shared/Combobox/Selection/ComboboxLabelSelection';
33
- import { SuggesterNotification } from './Suggester/SuggesterNotification';
34
- import type { Radio } from './Radio/Radio';
35
- import type { ComboboxInput } from './shared/Combobox/Selection/ComboboxInput';
36
- import type { FilterDescription } from './FilterDescription/FilterDescription';
37
- import type { CustomSuggester } from './Suggester/CustomSuggester';
38
- import type { CustomCheckboxGroup } from './CheckboxGroup/CustomCheckboxGroup';
39
- import { ComponentSet, ComponentSetItem } from './ComponentSet/ComponentSet';
40
- import type { RouterLink } from './shared/MDLabel/RouterLink';
41
- import { SummaryResponses, type SummaryTitle } from './Summary/Summary';
42
- /**
43
- * Contains the type of every customizable component
44
- */
45
- export type LunaticCustomizedComponent = {
46
- Input: typeof Input;
47
- InputNumber: typeof InputNumber;
48
- Sequence: typeof Sequence;
49
- Switch: typeof Switch;
50
- Subsequence: typeof Subsequence;
51
- Textarea: typeof Textarea;
52
- Datepicker: typeof Datepicker;
53
- Duration: typeof Duration;
54
- Question: typeof Question;
55
- BlockForLoop: typeof Loop;
56
- RosterForLoop: typeof RosterForLoop;
57
- Dropdown: typeof Dropdown;
58
- LunaticRadio: typeof Radio;
59
- FilterDescription: typeof FilterDescription;
60
- Suggester: typeof CustomSuggester;
61
- ComponentSet: typeof ComponentSet;
62
- ComponentSetItem: typeof ComponentSetItem;
63
- CheckboxBoolean: typeof CheckboxBoolean;
64
- CheckboxGroup: typeof CustomCheckboxGroup;
65
- CheckboxOne: typeof CheckboxOne;
66
- CheckboxOption: typeof CheckboxOption;
67
- Radio: typeof RadioGroup;
68
- RadioGroup: typeof RadioGroup;
69
- RadioOption: typeof RadioOption;
70
- Combobox: typeof Combobox;
71
- ComboboxContainer: typeof ComboboxContainer;
72
- ComboboxContentBox: typeof ComboboxContentBox;
73
- ComboboxPanelContainer: typeof ComboboxPanelContainer;
74
- ComboboxOption: typeof ComboboxOption;
75
- ComboboxInput: typeof ComboboxInput;
76
- ComboboxClearButton: typeof ComboboxClearButton;
77
- ComboboxLabelSelection: typeof ComboboxLabelSelection;
78
- Roundabout: typeof CustomRoundabout;
79
- RoundaboutContainer: typeof RoundaboutContainer;
80
- RoundaboutLabel: typeof RoundaboutLabel;
81
- RoundaboutItTitle: typeof RoundaboutItTitle;
82
- RoundaboutItContainer: typeof RoundaboutItContainer;
83
- RoundaboutItButton: typeof RoundaboutItButton;
84
- RoundaboutPending: typeof RoundaboutPending;
85
- SuggesterNotification: typeof SuggesterNotification;
86
- SummaryTitle: typeof SummaryTitle;
87
- SummaryResponses: typeof SummaryResponses;
88
- Button: typeof Button;
89
- Label: typeof Label;
90
- Declarations: typeof Declarations;
91
- Declaration: typeof Declaration;
92
- Tr: typeof Tr;
93
- Td: typeof Td;
94
- Th: typeof Th;
95
- Tbody: typeof Tbody;
96
- Table: typeof Table;
97
- Thead: typeof Thead;
98
- Fieldset: typeof Fieldset;
99
- Notification: typeof Notification;
100
- RouterLink: typeof RouterLink;
101
- };