@inseefr/lunatic 2.4.8-dynamicArray → 2.4.8-fixDatePicker

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 (36) hide show
  1. package/lib/components/index.js +0 -7
  2. package/lib/components/loop/loop.js +2 -2
  3. package/lib/components/loop/roster-for-loop/body.js +52 -0
  4. package/lib/components/loop/roster-for-loop/header.js +34 -0
  5. package/lib/components/loop/roster-for-loop/roster-for-loop.js +32 -35
  6. package/lib/components/loop/roster-for-loop/roster-table.js +16 -17
  7. package/lib/components/loop/roster-for-loop/roster.scss +34 -32
  8. package/lib/components/loop/roster-for-loop/row.js +19 -48
  9. package/lib/src/components/index.d.ts +0 -1
  10. package/lib/src/components/loop/block-for-loop/block-for-loop-ochestrator.d.ts +1 -1
  11. package/lib/src/components/loop/block-for-loop/block-for-loop.d.ts +1 -1
  12. package/lib/src/components/loop/roster-for-loop/body.d.ts +12 -0
  13. package/lib/src/components/loop/roster-for-loop/header.d.ts +9 -0
  14. package/lib/src/components/loop/roster-for-loop/roster-for-loop-orchestrator.d.ts +1 -1
  15. package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +4 -4
  16. package/lib/src/components/loop/roster-for-loop/roster-table.d.ts +2 -2
  17. package/lib/src/components/type.d.ts +2 -9
  18. package/lib/stories/loop/block-for-loop.stories.js +8 -1
  19. package/lib/stories/loop/roster-for-loop.stories.js +1 -8
  20. package/lib/stories/loop/source-with-header.json +4 -16
  21. package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +1 -1
  22. package/package.json +2 -2
  23. package/lib/components/duration/duration.js +0 -117
  24. package/lib/components/duration/duration.scss +0 -16
  25. package/lib/components/duration/duration.spec.js +0 -49
  26. package/lib/components/duration/index.js +0 -13
  27. package/lib/components/duration/useDurationValues.js +0 -124
  28. package/lib/hooks/use-did-change.js +0 -19
  29. package/lib/src/components/duration/duration.d.ts +0 -4
  30. package/lib/src/components/duration/duration.spec.d.ts +0 -1
  31. package/lib/src/components/duration/index.d.ts +0 -1
  32. package/lib/src/components/duration/useDurationValues.d.ts +0 -43
  33. package/lib/src/hooks/use-did-change.d.ts +0 -4
  34. package/lib/stories/duration/duration.stories.js +0 -41
  35. package/lib/stories/duration/source.json +0 -32
  36. package/lib/stories/duration/source1.json +0 -32
@@ -51,12 +51,6 @@ Object.defineProperty(exports, "Dropdown", {
51
51
  return _dropdown["default"];
52
52
  }
53
53
  });
54
- Object.defineProperty(exports, "Duration", {
55
- enumerable: true,
56
- get: function get() {
57
- return _duration["default"];
58
- }
59
- });
60
54
  Object.defineProperty(exports, "FilterDescription", {
61
55
  enumerable: true,
62
56
  get: function get() {
@@ -188,7 +182,6 @@ var _suggesterLoaderWidget = _interopRequireDefault(require("./suggester-loader-
188
182
  var _roundabout = _interopRequireDefault(require("./roundabout"));
189
183
  var _table = _interopRequireDefault(require("./table"));
190
184
  var _componentSet = _interopRequireDefault(require("./component-set"));
191
- var _duration = _interopRequireDefault(require("./duration"));
192
185
  var _questionInformation = _interopRequireDefault(require("./questions/question-information"));
193
186
  var _questionContext = _interopRequireDefault(require("./questions/question-context"));
194
187
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -24,7 +24,7 @@ function Loop(props) {
24
24
  value = props.value,
25
25
  executeExpression = props.executeExpression,
26
26
  componentType = props.componentType,
27
- header = props.header,
27
+ headers = props.headers,
28
28
  shortcut = props.shortcut,
29
29
  management = props.management,
30
30
  missing = props.missing,
@@ -68,7 +68,7 @@ function Loop(props) {
68
68
  shortcut: shortcut,
69
69
  features: features,
70
70
  preferences: preferences,
71
- header: header,
71
+ headers: headers,
72
72
  errors: errors
73
73
  });
74
74
  default:
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _htmlTable = require("../../commons/components/html-table");
9
+ var _rosterForLoopOrchestrator = _interopRequireDefault(require("./roster-for-loop-orchestrator"));
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
15
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
+ function Body(_ref) {
21
+ var id = _ref.id,
22
+ components = _ref.components,
23
+ nbRows = _ref.nbRows,
24
+ executeExpression = _ref.executeExpression,
25
+ handleChange = _ref.handleChange,
26
+ valueMap = _ref.value,
27
+ missing = _ref.missing;
28
+ var handleChangeRow = (0, _react.useCallback)(function (response, value, args) {
29
+ handleChange(response, value, _objectSpread(_objectSpread({}, args), {}, {
30
+ loop: true,
31
+ length: nbRows
32
+ }));
33
+ }, [nbRows, handleChange]);
34
+ if (nbRows <= 0) {
35
+ return null;
36
+ }
37
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Tbody, {
38
+ id: id,
39
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_rosterForLoopOrchestrator["default"], {
40
+ id: "roster-".concat(id),
41
+ components: components,
42
+ nbRows: nbRows,
43
+ handleChange: handleChangeRow,
44
+ executeExpression: executeExpression,
45
+ valueMap: valueMap,
46
+ missing: missing,
47
+ preferences: ['COLLECTED']
48
+ })
49
+ });
50
+ }
51
+ var _default = Body;
52
+ exports["default"] = _default;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _htmlTable = require("../../commons/components/html-table");
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+ function Header(_ref) {
12
+ var header = _ref.header,
13
+ id = _ref.id;
14
+ if (!Array.isArray(header)) {
15
+ return null;
16
+ }
17
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Thead, {
18
+ id: id,
19
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Tr, {
20
+ id: id,
21
+ row: 0,
22
+ children: header.map(function (_ref2, index) {
23
+ var label = _ref2.label;
24
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Th, {
25
+ id: id,
26
+ index: index,
27
+ children: label
28
+ }, "".concat(label, "-").concat(index));
29
+ })
30
+ })
31
+ });
32
+ }
33
+ var _default = Header;
34
+ exports["default"] = _default;
@@ -1,19 +1,21 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports["default"] = void 0;
7
- var _react = require("react");
8
- var _commons = require("../../commons");
9
- var _lunaticComponentWithLabel = _interopRequireDefault(require("../../commons/components/lunatic-component-with-label"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _declarations = require("../../declarations");
10
10
  var _rosterTable = _interopRequireDefault(require("./roster-table"));
11
+ var _commons = require("../../commons");
11
12
  var _handleRowButton = _interopRequireDefault(require("../commons/handle-row-button"));
12
13
  var _i18n = _interopRequireDefault(require("../../../i18n"));
13
14
  var _getInitLength = _interopRequireDefault(require("../commons/get-init-length"));
14
- var _useRefSync = require("../../../hooks/use-ref-sync");
15
15
  var _jsxRuntime = require("react/jsx-runtime");
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
+ 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); }
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
19
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
18
20
  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."); }
19
21
  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); }
@@ -30,13 +32,12 @@ function RosterforLoop(_ref) {
30
32
  label = _ref.label,
31
33
  components = _ref.components,
32
34
  executeExpression = _ref.executeExpression,
33
- header = _ref.header,
35
+ headers = _ref.headers,
34
36
  missing = _ref.missing,
37
+ shortcut = _ref.shortcut,
35
38
  id = _ref.id,
36
39
  management = _ref.management,
37
- errors = _ref.errors,
38
- missingResponse = _ref.missingResponse,
39
- description = _ref.description;
40
+ errors = _ref.errors;
40
41
  var min = (lines === null || lines === void 0 ? void 0 : lines.min) || DEFAULT_MIN_ROWS;
41
42
  var max = (lines === null || lines === void 0 ? void 0 : lines.max) || DEFAULT_MAX_ROWS;
42
43
  var _useState = (0, _react.useState)(function () {
@@ -46,21 +47,19 @@ function RosterforLoop(_ref) {
46
47
  nbRows = _useState2[0],
47
48
  setNbRows = _useState2[1];
48
49
  var showButtons = min && max && min !== max;
49
- var valueMapRef = (0, _useRefSync.useRefSync)(valueMap);
50
- var nbRowsRef = (0, _useRefSync.useRefSync)(nbRows);
51
50
  var addRow = (0, _react.useCallback)(function () {
52
51
  if (nbRows < max) {
53
52
  setNbRows(nbRows + 1);
54
53
  }
55
54
  }, [max, nbRows]);
56
55
  var handleChangeLoop = (0, _react.useCallback)(function (response, value, args) {
57
- var v = valueMapRef.current[response.name];
56
+ var v = valueMap[response.name];
58
57
  v[args.index] = value;
59
58
  handleChange(response, v, {
60
59
  loop: true,
61
- length: nbRowsRef.current
60
+ length: nbRows
62
61
  }); // TODO: a retaper pour déplacer cette compléxité
63
- }, [handleChange, nbRowsRef, valueMapRef]);
62
+ }, [handleChange, nbRows, valueMap]);
64
63
  var removeRow = (0, _react.useCallback)(function () {
65
64
  if (nbRows > 1) {
66
65
  var newNbRows = nbRows - 1;
@@ -80,34 +79,32 @@ function RosterforLoop(_ref) {
80
79
  }, [nbRows, handleChange, valueMap]);
81
80
  if (nbRows > 0) {
82
81
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
83
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_lunaticComponentWithLabel["default"], {
84
- id: id,
85
- label: label,
82
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_declarations.DeclarationsBeforeText, {
86
83
  declarations: declarations,
87
- missing: missing,
88
- missingResponse: missingResponse,
84
+ id: id
85
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_declarations.DeclarationsAfterText, {
86
+ declarations: declarations,
87
+ id: id
88
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_rosterTable["default"], {
89
+ id: id,
90
+ components: components,
91
+ nbRows: nbRows,
92
+ executeExpression: executeExpression,
93
+ headers: headers,
94
+ handleChange: handleChangeLoop,
95
+ value: valueMap,
89
96
  management: management,
90
- description: description,
91
- handleChange: handleChange,
92
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_rosterTable["default"], {
93
- id: id,
94
- components: components,
95
- nbRows: nbRows,
96
- executeExpression: executeExpression,
97
- header: header,
98
- handleChange: handleChangeLoop,
99
- value: valueMap,
100
- missing: missing,
101
- errors: errors
102
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
103
- errors: errors,
104
- activeId: id
105
- })]
97
+ missing: missing,
98
+ shortcut: shortcut,
99
+ errors: errors
100
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_declarations.DeclarationsDetachable, {
101
+ declarations: declarations,
102
+ id: id
106
103
  }), showButtons && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
107
104
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_handleRowButton["default"], {
108
105
  onClick: addRow,
109
106
  disabled: nbRows === max,
110
- children: _i18n["default"].DEFAULT_BUTTON_ADD
107
+ children: label || _i18n["default"].DEFAULT_BUTTON_ADD
111
108
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_handleRowButton["default"], {
112
109
  onClick: removeRow,
113
110
  disabled: nbRows === min,
@@ -4,44 +4,43 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
7
8
  var _htmlTable = require("../../commons/components/html-table");
8
- var _header = _interopRequireDefault(require("../../table/header"));
9
+ var _header = _interopRequireDefault(require("./header"));
10
+ var _body = _interopRequireDefault(require("./body"));
9
11
  require("./roster.scss");
10
12
  var _commons = require("../../commons");
11
- var _rosterForLoopOrchestrator = _interopRequireDefault(require("./roster-for-loop-orchestrator"));
12
13
  var _jsxRuntime = require("react/jsx-runtime");
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
- var preferences = ['COLLECTED'];
15
15
  function RosterTable(_ref) {
16
16
  var components = _ref.components,
17
17
  nbRows = _ref.nbRows,
18
18
  executeExpression = _ref.executeExpression,
19
19
  id = _ref.id,
20
- header = _ref.header,
20
+ headers = _ref.headers,
21
21
  valueMap = _ref.value,
22
+ shortcut = _ref.shortcut,
22
23
  missing = _ref.missing,
24
+ management = _ref.management,
23
25
  handleChange = _ref.handleChange;
24
26
  if (nbRows <= 0) {
25
27
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.NothingToDisplay, {});
26
28
  }
27
29
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_htmlTable.Table, {
28
30
  id: id,
29
- className: "rosterTable",
30
31
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_header["default"], {
31
- header: header,
32
+ header: headers,
32
33
  id: id
33
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Tbody, {
34
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_body["default"], {
34
35
  id: id,
35
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_rosterForLoopOrchestrator["default"], {
36
- id: "roster-".concat(id),
37
- components: components,
38
- nbRows: nbRows,
39
- handleChange: handleChange,
40
- executeExpression: executeExpression,
41
- valueMap: valueMap,
42
- missing: missing,
43
- preferences: preferences
44
- })
36
+ components: components,
37
+ handleChange: handleChange,
38
+ nbRows: nbRows,
39
+ value: valueMap,
40
+ management: management,
41
+ missing: missing,
42
+ shortcut: shortcut,
43
+ executeExpression: executeExpression
45
44
  })]
46
45
  });
47
46
  }
@@ -1,37 +1,39 @@
1
- .lunatic-component {
2
- .rosterTable {
3
- border-collapse: separate;
4
- border-spacing: 0;
5
- thead {
6
- position: sticky;
7
- background-color: var(--color-primary-contrast-text);
8
- z-index: 1;
9
- top: 0;
10
- th {
11
- border-top: 2px solid;
12
- border-bottom: 2px solid;
13
- border-right: 2px solid;
14
- }
15
- th:first-child {
16
- border-left: 2px solid;
17
- }
18
- }
19
- tbody {
20
- th {
21
- border-top: 1px solid;
22
- border-bottom: 1px solid;
23
- border-right: 1px solid;
24
- }
1
+ // .lunatic-component {
2
+ // .table-lunatic {
3
+ // table-layout: fixed;
4
+ // border-collapse: collapse;
5
+ // margin-top: 0.3em;
6
+ // margin-bottom: 0.3em;
7
+ // & td,
8
+ // th {
9
+ // border: 0.15em solid var(--color-primary-dark);
10
+ // padding: 0.2em;
11
+ // }
12
+ // & td {
13
+ // .field,
14
+ // .field-with-tooltip {
15
+ // display: flex;
16
+ // justify-content: center;
17
+ // align-items: center;
18
+ // }
19
+ // }
20
+ // }
25
21
 
26
- td {
27
- border-bottom: 1px solid;
28
- border-right: 1px solid;
29
- }
22
+ // .table-lunatic .tooltip-lunatic img {
23
+ // height: 20px;
24
+ // width: 20px;
25
+ // }
26
+ // }
30
27
 
31
- th:first-child,
32
- td:first-child {
33
- border-left: 1px solid;
34
- }
28
+ .lunatic-table {
29
+ table-layout: fixed;
30
+ border-collapse: collapse;
31
+ margin-top: 0.3em;
32
+ margin-bottom: 0.3em;
33
+ .lunatic-table-thead {
34
+ .lunatic-table-th {
35
+ border: 0.15em solid var(--color-primary-dark);
36
+ padding: 0.2em;
35
37
  }
36
38
  }
37
39
  }
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports["default"] = void 0;
7
- var _react = require("react");
8
+ var _react = _interopRequireWildcard(require("react"));
8
9
  var _htmlTable = require("../../commons/components/html-table");
9
10
  var _commons = require("../../commons");
10
11
  var _jsxRuntime = require("react/jsx-runtime");
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); }
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
14
  var emptyValue = {};
12
15
  function Row(_ref) {
13
16
  var id = _ref.id,
@@ -56,57 +59,25 @@ function Row(_ref) {
56
59
  }
57
60
  }
58
61
  }
59
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(RowCell, {
62
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Td, {
60
63
  id: idComponent,
61
- component: component,
62
- handleChange: handleChangeRow,
63
- features: features,
64
- missing: missing,
65
- shortcut: shortcut,
66
- management: management,
67
- value: value,
68
- preferences: preferences,
69
- rowIndex: rowIndex,
70
- executeExpression: executeExpression,
71
- errors: errors
64
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.OrchestratedComponent, {
65
+ component: component,
66
+ handleChange: handleChangeRow,
67
+ features: features,
68
+ missing: missing,
69
+ shortcut: shortcut,
70
+ management: management,
71
+ value: value,
72
+ id: idComponent,
73
+ preferences: preferences,
74
+ iteration: rowIndex,
75
+ executeExpression: executeExpression,
76
+ errors: errors
77
+ })
72
78
  }, key);
73
79
  })
74
80
  });
75
81
  }
76
-
77
- /**
78
- * Memoïzed version of a cell (for optimisation)
79
- */
80
- var RowCell = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
81
- var id = _ref2.id,
82
- component = _ref2.component,
83
- handleChange = _ref2.handleChange,
84
- features = _ref2.features,
85
- missing = _ref2.missing,
86
- shortcut = _ref2.shortcut,
87
- management = _ref2.management,
88
- value = _ref2.value,
89
- preferences = _ref2.preferences,
90
- rowIndex = _ref2.rowIndex,
91
- executeExpression = _ref2.executeExpression,
92
- errors = _ref2.errors;
93
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Td, {
94
- id: id,
95
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.OrchestratedComponent, {
96
- component: component,
97
- handleChange: handleChange,
98
- features: features,
99
- missing: missing,
100
- shortcut: shortcut,
101
- management: management,
102
- value: value,
103
- id: id,
104
- preferences: preferences,
105
- iteration: rowIndex,
106
- executeExpression: executeExpression,
107
- errors: errors
108
- })
109
- });
110
- });
111
82
  var _default = Row;
112
83
  exports["default"] = _default;
@@ -22,6 +22,5 @@ export { default as SuggesterLoaderWidget } from './suggester-loader-widget';
22
22
  export { default as Roundabout } from './roundabout';
23
23
  export { default as Table } from './table';
24
24
  export { default as ComponentSet } from './component-set';
25
- export { default as Duration } from "./duration";
26
25
  export { default as QuestionInformation } from './questions/question-information';
27
26
  export { default as QuestionContext } from './questions/question-context';
@@ -42,7 +42,7 @@ declare const BlockForLoopOrchestrator: ({ id, components, nbRows, valueMap, han
42
42
  bindingDependencies?: string[] | undefined;
43
43
  } | undefined) => T;
44
44
  value: Record<string, unknown[]>;
45
- header?: {
45
+ headers?: {
46
46
  label: import("react").ReactNode;
47
47
  }[] | undefined;
48
48
  paginatedLoop?: boolean | undefined;
@@ -13,7 +13,7 @@ declare const _default: React.ComponentType<import("../../type").LunaticBaseProp
13
13
  bindingDependencies?: string[] | undefined;
14
14
  } | undefined) => T;
15
15
  value: Record<string, unknown[]>;
16
- header?: {
16
+ headers?: {
17
17
  label: React.ReactNode;
18
18
  }[] | undefined;
19
19
  paginatedLoop?: boolean | undefined;
@@ -0,0 +1,12 @@
1
+ import { LunaticComponentProps } from '../../type';
2
+ type Props = {
3
+ nbRows: number;
4
+ handleChange: (response: {
5
+ name: string;
6
+ }, value: unknown, args: {
7
+ index: number;
8
+ [k: string]: unknown;
9
+ }) => void;
10
+ } & Pick<LunaticComponentProps<'RosterForLoop'>, 'id' | 'components' | 'executeExpression' | 'headers' | 'value' | 'management' | 'missing' | 'shortcut' | 'errors'>;
11
+ declare function Body({ id, components, nbRows, executeExpression, handleChange, value: valueMap, missing, }: Props): import("react/jsx-runtime").JSX.Element | null;
12
+ export default Body;
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ type Props = {
3
+ id?: string;
4
+ header?: Array<{
5
+ label: ReactNode;
6
+ }>;
7
+ };
8
+ declare function Header({ header, id }: Props): import("react/jsx-runtime").JSX.Element | null;
9
+ export default Header;
@@ -42,7 +42,7 @@ declare const RosterForLoopOrchestrator: ({ id, components, nbRows, valueMap, ha
42
42
  bindingDependencies?: string[] | undefined;
43
43
  } | undefined) => T;
44
44
  value: Record<string, unknown[]>;
45
- header?: {
45
+ headers?: {
46
46
  label: import("react").ReactNode;
47
47
  }[] | undefined;
48
48
  paginatedLoop?: boolean | undefined;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
- declare const _default: import("react").ComponentType<import("../../type").LunaticBaseProps<unknown> & {
1
+ import React from 'react';
2
+ declare const _default: React.ComponentType<import("../../type").LunaticBaseProps<unknown> & {
3
3
  lines: {
4
4
  min: number;
5
5
  max: number;
@@ -13,8 +13,8 @@ declare const _default: import("react").ComponentType<import("../../type").Lunat
13
13
  bindingDependencies?: string[] | undefined;
14
14
  } | undefined) => T;
15
15
  value: Record<string, unknown[]>;
16
- header?: {
17
- label: import("react").ReactNode;
16
+ headers?: {
17
+ label: React.ReactNode;
18
18
  }[] | undefined;
19
19
  paginatedLoop?: boolean | undefined;
20
20
  }>;
@@ -8,6 +8,6 @@ type Props = {
8
8
  index: number;
9
9
  [k: string]: unknown;
10
10
  }) => void;
11
- } & Pick<LunaticComponentProps<'RosterForLoop'>, 'id' | 'components' | 'executeExpression' | 'header' | 'value' | 'missing' | 'errors'>;
12
- declare function RosterTable({ components, nbRows, executeExpression, id, header, value: valueMap, missing, handleChange, }: Props): import("react/jsx-runtime").JSX.Element;
11
+ } & Pick<LunaticComponentProps<'RosterForLoop'>, 'id' | 'components' | 'executeExpression' | 'headers' | 'value' | 'management' | 'missing' | 'shortcut' | 'errors'>;
12
+ declare function RosterTable({ components, nbRows, executeExpression, id, headers, value: valueMap, shortcut, missing, management, handleChange, }: Props): import("react/jsx-runtime").JSX.Element;
13
13
  export default RosterTable;
@@ -2,7 +2,6 @@ import { LunaticComponentDefinition, LunaticError, LunaticExpression, LunaticSta
2
2
  import { CSSProperties, FunctionComponent, ReactNode } from 'react';
3
3
  import { SuggesterStatus } from '../use-lunatic/use-suggesters';
4
4
  import useLunatic from '../use-lunatic';
5
- type Formats = 'PTnHnM' | 'PnYnM';
6
5
  export type LunaticBaseProps<ValueType = unknown> = {
7
6
  id: string;
8
7
  handleChange: (response: {
@@ -61,12 +60,6 @@ type ComponentPropsByType = {
61
60
  name: string;
62
61
  };
63
62
  };
64
- Duration: LunaticBaseProps<string | null> & {
65
- format: Formats;
66
- response: {
67
- name: string;
68
- };
69
- };
70
63
  Input: LunaticBaseProps<string> & {
71
64
  maxLength?: number;
72
65
  value: null | string;
@@ -90,7 +83,7 @@ type ComponentPropsByType = {
90
83
  components: LunaticComponentDefinition[];
91
84
  executeExpression: LunaticState['executeExpression'];
92
85
  value: Record<string, unknown[]>;
93
- header?: Array<{
86
+ headers?: Array<{
94
87
  label: ReactNode;
95
88
  }>;
96
89
  paginatedLoop?: boolean;
@@ -104,7 +97,7 @@ type ComponentPropsByType = {
104
97
  components: LunaticComponentDefinition[];
105
98
  executeExpression: LunaticState['executeExpression'];
106
99
  value: Record<string, unknown[]>;
107
- header?: Array<{
100
+ headers?: Array<{
108
101
  label: ReactNode;
109
102
  }>;
110
103
  paginatedLoop?: boolean;
@@ -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.WithHeader = exports.Default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
9
9
  var _sourceBloc = _interopRequireDefault(require("./source-bloc.json"));
10
+ var _sourceWithHeader = _interopRequireDefault(require("./source-with-header.json"));
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 }; }
@@ -31,4 +32,10 @@ exports.Default = Default;
31
32
  Default.args = {
32
33
  id: 'bloc-for-loop',
33
34
  source: _sourceBloc["default"]
35
+ };
36
+ var WithHeader = Template.bind({});
37
+ exports.WithHeader = WithHeader;
38
+ WithHeader.args = {
39
+ id: 'bloc-for-loop-headers',
40
+ source: _sourceWithHeader["default"]
34
41
  };
@@ -3,12 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.WithHeader = exports.Default = void 0;
6
+ exports["default"] = exports.Default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
9
9
  var _sourceRoster = _interopRequireDefault(require("./source-roster"));
10
10
  var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
11
- var _sourceWithHeader = _interopRequireDefault(require("./source-with-header.json"));
12
11
  var _jsxRuntime = require("react/jsx-runtime");
13
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
13
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
@@ -32,10 +31,4 @@ exports.Default = Default;
32
31
  Default.args = {
33
32
  id: 'roster-for-loop',
34
33
  source: _sourceRoster["default"]
35
- };
36
- var WithHeader = Template.bind({});
37
- exports.WithHeader = WithHeader;
38
- WithHeader.args = {
39
- id: 'roster-for-loop-headers',
40
- source: _sourceWithHeader["default"]
41
34
  };
@@ -14,28 +14,16 @@
14
14
  {
15
15
  "id": "loop-prenom",
16
16
  "componentType": "RosterForLoop",
17
- "header": [
18
- {
19
- "headerCell": true,
20
- "label": {
21
- "value": "Prénom",
22
- "type": "VTL|MD"
23
- }
24
- },
25
- {
26
- "headerCell": true,
27
- "label": {
28
- "value": "Age",
29
- "type": "VTL|MD"
30
- }
31
- }
17
+ "headers": [
18
+ { "headerCell": true, "label": "Prénom" },
19
+ { "headerCell": true, "label": "Age" }
32
20
  ],
33
21
  "label": { "value": "\"Ajouter un individu\"", "type": "VTL|MD" },
34
22
  "conditionFilter": { "value": "true", "type": "VTL" },
35
23
  "bindingDependencies": ["PRENOM", "AGE"],
36
24
  "lines": {
37
25
  "min": { "value": 1, "type": "VTL" },
38
- "max": { "value": 1000, "type": "VTL" }
26
+ "max": { "value": 10, "type": "VTL" }
39
27
  },
40
28
  "page": "1",
41
29
  "components": [
@@ -24,7 +24,7 @@ var VTL_ATTRIBUTES = ['label', 'options.label', 'responses.label', 'hierarchy.la
24
24
  // Disable controls compilation
25
25
  // 'controls.control',
26
26
  // 'controls.errorMessage',
27
- 'controls.iterations', 'lines.min', 'lines.max', 'iterations', 'xAxisIterations', 'yAxisIterations', 'conditionFilter', 'header.label'];
27
+ 'controls.iterations', 'lines.min', 'lines.max', 'iterations', 'xAxisIterations', 'yAxisIterations', 'conditionFilter', 'headers.label', 'header.label'];
28
28
 
29
29
  // Utility type to replace all expression from an object into a translated version
30
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "2.4.8-dynamicArray",
3
+ "version": "2.4.8-fixDatePicker",
4
4
  "workersVersion": "0.2.5-experimental",
5
5
  "description": "Library of questionnaire components",
6
6
  "repository": {
@@ -52,7 +52,7 @@
52
52
  "library"
53
53
  ],
54
54
  "dependencies": {
55
- "@inseefr/trevas": "^0.1.18",
55
+ "@inseefr/trevas": "^0.1.17",
56
56
  "@inseefr/vtl-2.0-antlr-tools": "^0.1.0-bundle",
57
57
  "antlr4": "4.11.0",
58
58
  "classnames": "^2.3.1",
@@ -1,117 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- require("./duration.scss");
9
- var _useDurationValues2 = require("./useDurationValues");
10
- var _commons = require("../commons");
11
- var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../commons/components/lunatic-component-without-label"));
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
15
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
- function Duration(props) {
21
- var value = props.value,
22
- label = props.label,
23
- format = props.format,
24
- handleChange = props.handleChange,
25
- response = props.response,
26
- id = props.id,
27
- preferences = props.preferences,
28
- declarations = props.declarations,
29
- missing = props.missing,
30
- missingResponse = props.missingResponse,
31
- management = props.management,
32
- description = props.description;
33
- var onChange = (0, _commons.useOnHandleChange)({
34
- handleChange: handleChange,
35
- response: response,
36
- value: value
37
- });
38
- var _useDurationValues = (0, _useDurationValues2.useDurationValues)(value, format, onChange),
39
- propsHours = _useDurationValues.propsHours,
40
- propsMinutes = _useDurationValues.propsMinutes,
41
- propsYears = _useDurationValues.propsYears,
42
- propsMonths = _useDurationValues.propsMonths;
43
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_lunaticComponentWithoutLabel["default"], {
44
- id: id,
45
- preferences: preferences,
46
- declarations: declarations,
47
- value: value,
48
- missing: missing,
49
- missingResponse: missingResponse,
50
- management: management,
51
- description: description,
52
- handleChange: handleChange,
53
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
54
- className: "container",
55
- children: [label, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {}), format === 'PTnHnM' && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
56
- className: "field-group",
57
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
58
- className: "input-field-group",
59
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
60
- htmlFor: "hoursInput",
61
- className: "input-label",
62
- children: "Heures:"
63
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
64
- id: "hoursInput",
65
- type: "number"
66
- }, propsHours), {}, {
67
- className: "input-field"
68
- }))]
69
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
70
- className: "input-field-group",
71
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
72
- htmlFor: "minutesInput",
73
- className: "input-label",
74
- children: "Minutes:"
75
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
76
- id: "minutesInput",
77
- type: "number"
78
- }, propsMinutes), {}, {
79
- min: "0",
80
- className: "input-field"
81
- }))]
82
- })]
83
- }), format === 'PnYnM' && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
84
- className: "field-group",
85
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
86
- className: "input-field-group",
87
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
88
- htmlFor: "yearsInput",
89
- className: "input-label",
90
- children: "Ann\xE9es:"
91
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
92
- id: "yearsInput",
93
- type: "number"
94
- }, propsYears), {}, {
95
- min: "0",
96
- className: "input-field"
97
- }))]
98
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
99
- className: "input-field-group",
100
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
101
- htmlFor: "monthsInput",
102
- className: "input-label",
103
- children: "Mois:"
104
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
105
- id: "monthsInput",
106
- type: "number"
107
- }, propsMonths), {}, {
108
- min: "0",
109
- className: "input-field"
110
- }))]
111
- })]
112
- })]
113
- })
114
- });
115
- }
116
- var _default = Duration;
117
- exports["default"] = _default;
@@ -1,16 +0,0 @@
1
- .input-field {
2
- width: 100px;
3
- }
4
- .field-group {
5
- display: flex;
6
- }
7
-
8
- .input-field-group {
9
- display: flex;
10
- align-items: first baseline;
11
- margin: 5px;
12
- }
13
-
14
- .input-label {
15
- margin-right: 5px;
16
- }
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
- var _react = _interopRequireDefault(require("react"));
4
- var _react2 = require("@testing-library/react");
5
- var _vitest = require("vitest");
6
- var _duration = _interopRequireDefault(require("./duration"));
7
- var _jsxRuntime = require("react/jsx-runtime");
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
9
- (0, _vitest.describe)('Duration component', function () {
10
- var handleChange = _vitest.vi.fn();
11
- (0, _vitest.it)('should render with hours and minutes inputs when format is "PTnHnM"', function () {
12
- var _render = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_duration["default"], {
13
- format: "PTnHnM",
14
- handleChange: handleChange,
15
- id: '',
16
- value: null,
17
- executeExpression: function executeExpression(expression, args) {
18
- throw new Error('Function not implemented.');
19
- },
20
- response: {
21
- name: ''
22
- }
23
- })),
24
- getByLabelText = _render.getByLabelText;
25
- var hoursInput = getByLabelText('Heures:');
26
- var minutesInput = getByLabelText('Minutes:');
27
- (0, _vitest.expect)(hoursInput).toBeInTheDocument();
28
- (0, _vitest.expect)(minutesInput).toBeInTheDocument();
29
- });
30
- (0, _vitest.it)('should render with years and months inputs when format is "PnYnM"', function () {
31
- var _render2 = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_duration["default"], {
32
- format: "PnYnM",
33
- handleChange: handleChange,
34
- id: '',
35
- value: null,
36
- executeExpression: function executeExpression(expression, args) {
37
- throw new Error('Function not implemented.');
38
- },
39
- response: {
40
- name: ''
41
- }
42
- })),
43
- getByLabelText = _render2.getByLabelText;
44
- var yearsInput = getByLabelText('Années:');
45
- var monthsInput = getByLabelText('Mois:');
46
- (0, _vitest.expect)(yearsInput).toBeInTheDocument();
47
- (0, _vitest.expect)(monthsInput).toBeInTheDocument();
48
- });
49
- });
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function get() {
9
- return _duration["default"];
10
- }
11
- });
12
- var _duration = _interopRequireDefault(require("./duration"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -1,124 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useDurationValues = void 0;
7
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
8
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
- 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."); }
10
- 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); }
11
- 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; }
12
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
13
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
18
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
19
- var useDurationValues = function useDurationValues(value, format, handleChange) {
20
- var duration = parseISO8601Duration(value);
21
- // Gestionnaire de changement pour les champs individuels (heures, minutes, mois, années)
22
- var onChangeHandler = function onChangeHandler(key) {
23
- return function (e) {
24
- // Mise à jour de la valeur de la durée avec la clé dynamique
25
- handleChange(formatISO8601Duration(format, _objectSpread(_objectSpread({}, duration), {}, _defineProperty({}, key, e.target.value))));
26
- };
27
- };
28
- var propsHours = {
29
- value: duration.hours,
30
- onChange: onChangeHandler("hours"),
31
- min: "0",
32
- max: "23"
33
- };
34
- var propsMinutes = {
35
- value: duration.minutes,
36
- onChange: onChangeHandler("minutes"),
37
- min: "0",
38
- max: "59"
39
- };
40
- var propsMonths = {
41
- value: duration.months,
42
- onChange: onChangeHandler("months"),
43
- min: "0",
44
- max: "11"
45
- };
46
- var propsYears = {
47
- value: duration.years,
48
- onChange: onChangeHandler("years"),
49
- min: "0"
50
- };
51
- // Retourne les propriétés pour chaque champ de durée
52
- return {
53
- propsHours: propsHours,
54
- propsMonths: propsMonths,
55
- propsYears: propsYears,
56
- propsMinutes: propsMinutes
57
- };
58
- };
59
- exports.useDurationValues = useDurationValues;
60
- // Fonction pour parser une durée au format ISO8601 en objets individuels
61
- var parseISO8601Duration = function parseISO8601Duration(duration) {
62
- // Si la durée est vide, retourne des valeurs vides pour chaque champ
63
- if (!duration) {
64
- return {
65
- hours: '',
66
- minutes: '',
67
- years: '',
68
- months: ''
69
- };
70
- }
71
- // Expression régulière pour le format heures:minutes (PTnHnM)
72
- var regexHourMinute = /PT(\d+H)?(\d+M)?/i;
73
- var matchHourMinute = duration.match(regexHourMinute);
74
- // Si la durée correspond au format heures:minutes (PTnHnM)
75
- if (matchHourMinute) {
76
- var _matchHourMinute = _slicedToArray(matchHourMinute, 3),
77
- hours = _matchHourMinute[1],
78
- minutes = _matchHourMinute[2];
79
- return {
80
- hours: hours ? hours.replace('H', '') : '',
81
- minutes: minutes ? minutes.replace('M', '') : '',
82
- years: '',
83
- months: ''
84
- };
85
- }
86
- // Expression régulière pour le format années:mois (PnYnM)
87
- var regexYearMonth = /P(\d+Y)?(\d+M)?/i;
88
- var matchYearMonth = duration.match(regexYearMonth);
89
- // Si la durée correspond au format années:mois (PnYnM)
90
- if (matchYearMonth) {
91
- var _matchYearMonth = _slicedToArray(matchYearMonth, 3),
92
- years = _matchYearMonth[1],
93
- months = _matchYearMonth[2];
94
- return {
95
- years: years ? years.replace('Y', '') : '',
96
- months: months ? months.replace('M', '') : '',
97
- hours: '',
98
- minutes: ''
99
- };
100
- }
101
- // Si la durée ne correspond à aucun des formats connus, retourne des valeurs vides pour chaque champ
102
- return {
103
- hours: '',
104
- minutes: '',
105
- years: '',
106
- months: ''
107
- };
108
- };
109
- // Fonction pour formatter les objets individuels en durée au format souhaité
110
- var formatISO8601Duration = function formatISO8601Duration(format, duration) {
111
- // Si tous les champs de durée sont vides, retourne null
112
- if (!duration.hours && !duration.minutes && !duration.years && !duration.months) {
113
- return null;
114
- }
115
- // Formatage de la durée en fonction du format spécifié
116
- if (format === 'PTnHnM') {
117
- return "PT".concat(duration.hours ? "".concat(duration.hours, "H") : '0H').concat(duration.minutes ? "".concat(duration.minutes, "M") : '0M');
118
- }
119
- if (format === 'PnYnM') {
120
- return "P".concat(duration.years ? "".concat(duration.years, "Y") : '0Y').concat(duration.months ? "".concat(duration.months, "M") : '0M');
121
- }
122
- // Si le format spécifié n'est pas valide, retourne null
123
- return null;
124
- };
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useDidChange = useDidChange;
7
- var _react = require("react");
8
- /**
9
- * Hook for debug purpose that log the data that changed between 2 renders
10
- */
11
- function useDidChange(obj, suffix) {
12
- var ref = (0, _react.useRef)(obj);
13
- for (var key in obj) {
14
- if (obj[key] !== ref.current[key]) {
15
- console.log("\"".concat(key, "\" has changed ").concat(suffix !== null && suffix !== void 0 ? suffix : ''), obj[key]);
16
- }
17
- }
18
- ref.current = obj;
19
- }
@@ -1,4 +0,0 @@
1
- import './duration.scss';
2
- import { LunaticComponentProps } from '../type';
3
- declare function Duration(props: LunaticComponentProps<'Duration'>): import("react/jsx-runtime").JSX.Element;
4
- export default Duration;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export { default } from "./duration";
@@ -1,43 +0,0 @@
1
- export declare const useDurationValues: (value: string | null, format: Formats, handleChange: (v: string | null) => void) => {
2
- propsHours: {
3
- value: string;
4
- onChange: (e: {
5
- target: {
6
- value: string;
7
- };
8
- }) => void;
9
- min: string;
10
- max: string;
11
- };
12
- propsMonths: {
13
- value: string;
14
- onChange: (e: {
15
- target: {
16
- value: string;
17
- };
18
- }) => void;
19
- min: string;
20
- max: string;
21
- };
22
- propsYears: {
23
- value: string;
24
- onChange: (e: {
25
- target: {
26
- value: string;
27
- };
28
- }) => void;
29
- min: string;
30
- };
31
- propsMinutes: {
32
- value: string;
33
- onChange: (e: {
34
- target: {
35
- value: string;
36
- };
37
- }) => void;
38
- min: string;
39
- max: string;
40
- };
41
- };
42
- type Formats = "PTnHnM" | "PnYnM";
43
- export {};
@@ -1,4 +0,0 @@
1
- /**
2
- * Hook for debug purpose that log the data that changed between 2 renders
3
- */
4
- export declare function useDidChange(obj: Record<string, unknown>, suffix?: string): void;
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports.PnYnM = exports.PTnHnM = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
9
- var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
10
- var _source = _interopRequireDefault(require("./source"));
11
- var _source2 = _interopRequireDefault(require("./source1"));
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
15
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
- var stories = {
21
- title: 'Components/Duration',
22
- component: _orchestrator["default"],
23
- argTypes: _defaultArgTypes["default"]
24
- };
25
- var _default = stories;
26
- exports["default"] = _default;
27
- var Template = function Template(args) {
28
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_orchestrator["default"], _objectSpread({}, args));
29
- };
30
- var PnYnM = Template.bind({});
31
- exports.PnYnM = PnYnM;
32
- PnYnM.args = {
33
- id: 'durationAnnéesMois',
34
- source: _source["default"]
35
- };
36
- var PTnHnM = Template.bind({});
37
- exports.PTnHnM = PTnHnM;
38
- PTnHnM.args = {
39
- id: 'durationHeureMinute',
40
- source: _source2["default"]
41
- };
@@ -1,32 +0,0 @@
1
- {
2
- "components": [
3
- {
4
- "id": "kxi788",
5
- "componentType": "Duration",
6
- "mandatory": false,
7
- "format": "PnYnM",
8
- "page": "1",
9
- "maxPage": "1",
10
- "label": {
11
- "value": "\"➡ 1. \" || \"Duration \"",
12
- "type": "VTL|MD"
13
- },
14
- "description": { "value": "\"Description\"", "type": "VTL|MD" },
15
- "conditionFilter": { "value": "true", "type": "VTL" },
16
- "response": { "name": "DUREE" }
17
- }
18
- ],
19
- "variables": [
20
- {
21
- "variableType": "COLLECTED",
22
- "name": "DUREE",
23
- "values": {
24
- "PREVIOUS": null,
25
- "COLLECTED": null,
26
- "FORCED": null,
27
- "EDITED": null,
28
- "INPUTED": null
29
- }
30
- }
31
- ]
32
- }
@@ -1,32 +0,0 @@
1
- {
2
- "components": [
3
- {
4
- "id": "kxi788",
5
- "componentType": "Duration",
6
- "mandatory": false,
7
- "format": "PTnHnM",
8
- "page": "1",
9
- "maxPage": "1",
10
- "label": {
11
- "value": "\"➡ 1. \" || \"Duration \"",
12
- "type": "VTL|MD"
13
- },
14
- "description": { "value": "\"Description\"", "type": "VTL|MD" },
15
- "conditionFilter": { "value": "true", "type": "VTL" },
16
- "response": { "name": "DUREE" }
17
- }
18
- ],
19
- "variables": [
20
- {
21
- "variableType": "COLLECTED",
22
- "name": "DUREE",
23
- "values": {
24
- "PREVIOUS": null,
25
- "COLLECTED": "PT12H50M",
26
- "FORCED": null,
27
- "EDITED": null,
28
- "INPUTED": null
29
- }
30
- }
31
- ]
32
- }