@inseefr/lunatic 0.3.2-experimental → 0.3.6-experimental

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 (101) hide show
  1. package/lib/index.js +38 -82
  2. package/lib/index.js.map +1 -1
  3. package/package.json +2 -2
  4. package/src/components/breadcrumb/component.js +29 -29
  5. package/src/components/button/component.js +53 -53
  6. package/src/components/button/index.js +1 -1
  7. package/src/components/checkbox/index.js +3 -3
  8. package/src/components/datepicker/index.js +1 -1
  9. package/src/components/declarations/index.js +1 -1
  10. package/src/components/declarations/wrappers/input-declarations-wrapper.js +28 -7
  11. package/src/components/declarations/wrappers/list-declarations-wrapper.js +232 -232
  12. package/src/components/dropdown/commons/components/dropdown.js +21 -0
  13. package/src/components/dropdown/dropdown-edit/dropdown-edit.js +4 -1
  14. package/src/components/dropdown/dropdown-simple/dropdown.js +3 -1
  15. package/src/components/filter-description/component.js +42 -42
  16. package/src/components/icon/component.js +33 -33
  17. package/src/components/input/index.js +2 -2
  18. package/src/components/input/input-number.js +2 -1
  19. package/src/components/loop/index.js +1 -1
  20. package/src/components/loop-constructor/wrapper/body-component.js +13 -1
  21. package/src/components/radio/index.js +1 -1
  22. package/src/components/sequence/index.js +1 -1
  23. package/src/components/subsequence/index.js +1 -1
  24. package/src/components/suggester/check-store.js +70 -70
  25. package/src/components/suggester/components/suggester-content.js +42 -42
  26. package/src/components/suggester/components/suggester.js +43 -3
  27. package/src/components/suggester/idb-suggester.js +7 -1
  28. package/src/components/suggester/lunatic-suggester.js +1 -0
  29. package/src/components/suggester/suggester-wrapper.js +6 -0
  30. package/src/components/tooltip/response.js +52 -52
  31. package/src/stories/checkbox-boolean/data-forced.json +48 -48
  32. package/src/stories/icons/icons.stories.js +16 -16
  33. package/src/stories/questionnaire/kish.json +275 -0
  34. package/src/stories/questionnaire/logement-queen.json +23390 -23390
  35. package/src/stories/questionnaire/logement-s2.json +46027 -44536
  36. package/src/stories/questionnaire/questionnaire.stories.js +14 -2
  37. package/src/stories/utils/custom-lunatic.scss +23 -23
  38. package/src/stories/utils/orchestrator-split.js +4 -2
  39. package/src/stories/utils/orchestrator.js +4 -2
  40. package/src/tests/components/breadcrumb.spec.js +13 -13
  41. package/src/tests/components/button.spec.js +11 -11
  42. package/src/tests/components/checkbox-boolean.spec.js +45 -45
  43. package/src/tests/components/checkbox-group.spec.js +53 -53
  44. package/src/tests/components/checkbox-one.spec.js +32 -32
  45. package/src/tests/components/datepicker.spec.js +22 -22
  46. package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +67 -67
  47. package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +52 -52
  48. package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +21 -21
  49. package/src/tests/components/declarations.spec.js +46 -46
  50. package/src/tests/components/input.spec.js +18 -18
  51. package/src/tests/components/loops/loop-static.json +66 -66
  52. package/src/tests/components/loops/loop.json +258 -258
  53. package/src/tests/components/loops/loop.spec.js +30 -30
  54. package/src/tests/components/loops/roster-for-loop.spec.js +18 -18
  55. package/src/tests/components/progress-bar.spec.js +15 -15
  56. package/src/tests/components/radio.spec.js +27 -27
  57. package/src/tests/components/sequence.spec.js +9 -9
  58. package/src/tests/components/subsequence.spec.js +9 -9
  59. package/src/tests/components/table.spec.js +11 -11
  60. package/src/tests/components/textarea.spec.js +18 -18
  61. package/src/tests/components/tooltip.spec.js +25 -25
  62. package/src/tests/setup/setupTests.js +4 -4
  63. package/src/tests/utils/lib/alphabet.spec.js +36 -36
  64. package/src/tests/utils/lib/array.spec.js +22 -22
  65. package/src/tests/utils/lib/checkbox/group.spec.js +72 -72
  66. package/src/tests/utils/lib/decorator/title-decorator.spec.js +12 -12
  67. package/src/tests/utils/lib/input-number.spec.js +18 -18
  68. package/src/tests/utils/lib/items-positioning.spec.js +17 -17
  69. package/src/tests/utils/lib/label-position.spec.js +22 -22
  70. package/src/tests/utils/lib/loops/bindings.spec.js +75 -75
  71. package/src/tests/utils/lib/loops/shared.spec.js +82 -82
  72. package/src/tests/utils/lib/missing/missing.spec.js +74 -74
  73. package/src/tests/utils/lib/missing/mock.js +137 -137
  74. package/src/tests/utils/lib/pagination/shared.spec.js +42 -42
  75. package/src/tests/utils/lib/responses.spec.js +64 -64
  76. package/src/tests/utils/lib/style.spec.js +26 -26
  77. package/src/tests/utils/lib/tooltip/build-response.spec.js +95 -95
  78. package/src/tests/utils/lib/tooltip/content.spec.js +109 -109
  79. package/src/tests/utils/to-expose/handler/handler.spec.js +94 -94
  80. package/src/tests/utils/to-expose/handler/questionnaire.json +158 -158
  81. package/src/tests/utils/to-expose/handler/results/index.js +6 -6
  82. package/src/tests/utils/to-expose/handler/results/res-double.json +158 -158
  83. package/src/tests/utils/to-expose/handler/results/res-input-collected.json +158 -158
  84. package/src/tests/utils/to-expose/handler/results/res-input-edited.json +158 -158
  85. package/src/tests/utils/to-expose/handler/results/res-loop.json +158 -158
  86. package/src/tests/utils/to-expose/handler/results/res-matrix.json +158 -158
  87. package/src/tests/utils/to-expose/handler/results/res-responses.json +158 -158
  88. package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +46 -46
  89. package/src/tests/utils/to-expose/init-questionnaire/data.json +12 -12
  90. package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +19 -19
  91. package/src/tests/utils/to-expose/interpret/interpret.spec.js +48 -48
  92. package/src/tests/utils/to-expose/state/questionnaire.json +61 -61
  93. package/src/tests/utils/to-expose/state/results.js +78 -78
  94. package/src/utils/lib/splitting.js +55 -23
  95. package/src/utils/lib/tooltip/build-response.js +41 -41
  96. package/src/utils/store-tools/create/index.js +1 -1
  97. package/src/utils/store-tools/create/update-store-info.js +26 -26
  98. package/src/utils/store-tools/index.js +5 -5
  99. package/src/utils/to-expose/handler.js +12 -14
  100. package/src/utils/to-expose/hooks/lunatic-split.js +44 -27
  101. package/src/utils/to-expose/hooks/lunatic.js +12 -5
@@ -1,232 +1,232 @@
1
- import React, { useState, useEffect, useRef } from 'react';
2
- import KeyboardEventHandler from 'react-keyboard-event-handler';
3
- import PropTypes from 'prop-types';
4
- import debounce from 'lodash.debounce';
5
- import Declarations from '../';
6
- import Icon from '../../icon';
7
- import { TooltipResponse } from '../../tooltip';
8
- import * as U from '../../../utils/lib';
9
- import * as C from '../../../constants';
10
- import { interpret } from '../../../utils/to-expose';
11
-
12
- const ListDeclarationsWrapper = ({
13
- id,
14
- label,
15
- preferences,
16
- response,
17
- options,
18
- handleChange: propsHandleChange,
19
- disabled,
20
- focused,
21
- shortcut,
22
- declarations,
23
- features,
24
- bindings,
25
- management,
26
- style,
27
- positioning,
28
- type,
29
- hasSpecificHandler,
30
- logFunction,
31
- }) => {
32
- const inputRef = useRef();
33
-
34
- const [value, setValue] = useState(() =>
35
- U.getResponseByPreference(preferences)(response)
36
- );
37
-
38
- const filledOptions =
39
- management && type === 'checkbox'
40
- ? [...options, { label: 'NR', value: '_N_R_' }]
41
- : options;
42
-
43
- const specificHandleChange = (e) => {
44
- const { values } = response;
45
- const [key, value] = Object.entries(e)[0];
46
- const newValue =
47
- values[preferences[preferences.length - 1]] === value ? null : value;
48
- handleChange({ [key]: newValue });
49
- if (management) {
50
- setValue(
51
- U.getResponseByPreference(preferences)(
52
- U.buildLocalResponse(response, newValue)
53
- )
54
- );
55
- } else setValue(newValue);
56
- };
57
-
58
- const handleChange = debounce((obj) => propsHandleChange(obj), 50);
59
-
60
- const onChange = (v) => {
61
- const update = {
62
- [U.getResponseName(response)]: v,
63
- };
64
- if (hasSpecificHandler) specificHandleChange(update);
65
- else {
66
- setValue(v);
67
- handleChange(update);
68
- }
69
- if (U.isFunction(logFunction))
70
- logFunction(
71
- U.createObjectEvent(
72
- `${type}-${id}-${v}`,
73
- C.INPUT_CATEGORY,
74
- C.EVENT_SELECTION,
75
- U.getResponseName(response),
76
- v
77
- )
78
- );
79
- };
80
-
81
- // Assume we only want to handle enable external updates
82
- // Don't need to check all value changes
83
- useEffect(() => {
84
- if (U.getResponseByPreference(preferences)(response) !== value)
85
- setValue(U.getResponseByPreference(preferences)(response));
86
- // eslint-disable-next-line react-hooks/exhaustive-deps
87
- }, [response, preferences]);
88
-
89
- useEffect(() => {
90
- if (focused) inputRef.current.focus();
91
- }, [focused]);
92
-
93
- const { fieldsetStyle, modalityStyle } = style;
94
- return (
95
- <>
96
- <Declarations
97
- id={id}
98
- type={C.BEFORE_QUESTION_TEXT}
99
- declarations={declarations}
100
- features={features}
101
- bindings={bindings}
102
- />
103
- <div className="field-container">
104
- <div className={`${management ? 'field-with-tooltip' : 'field'}`}>
105
- <fieldset
106
- key={`${type}-${id}`}
107
- className={`${type}-group-list`}
108
- style={U.buildStyleObject(fieldsetStyle)}
109
- >
110
- <legend>{interpret(features, logFunction)(bindings)(label)}</legend>
111
- <Declarations
112
- id={id}
113
- type={C.AFTER_QUESTION_TEXT}
114
- declarations={declarations}
115
- features={features}
116
- bindings={bindings}
117
- />
118
- {filledOptions.map(
119
- ({ label: optionLabel, value: optionValue }, i) => {
120
- const checked = value === optionValue;
121
- const interpretedLabel = interpret(
122
- features,
123
- logFunction
124
- )(bindings)(optionLabel);
125
- const keyboardSelectionKey =
126
- options.length < 10 ? `${i + 1}` : U.getAlphabet()[i];
127
- return (
128
- <div
129
- key={`${type}-${id}-${optionValue}`}
130
- className={`${type}-modality ${type}-modality-block ${U.getItemsPositioningClass(
131
- positioning
132
- )} ${checked ? 'content-checked' : ''} ${
133
- optionValue === '_N_R_' ? 'modality_NR' : ''
134
- }`}
135
- >
136
- <Icon type={type} checked={checked} disabled={disabled}>
137
- <input
138
- type={type}
139
- name={`${type}-${id}`}
140
- ref={i === 0 || checked ? inputRef : null}
141
- id={`${type}-${id}-${optionValue}`}
142
- aria-labelledby={`input-label-${id}-${optionValue}`}
143
- className={`${type}-lunatic`}
144
- style={U.buildStyleObject(style)}
145
- checked={checked}
146
- disabled={disabled}
147
- onChange={(optionLabel) => onChange(optionValue)}
148
- />
149
- <label
150
- htmlFor={`${type}-${id}-${optionValue}`}
151
- id={`input-label-${id}-${optionValue}`}
152
- style={checked ? U.buildStyleObject(modalityStyle) : {}}
153
- className="modality-label"
154
- >
155
- {shortcut && (
156
- <span className="code-modality">
157
- {keyboardSelectionKey.toUpperCase()}
158
- </span>
159
- )}
160
- {interpretedLabel}
161
- </label>
162
- </Icon>
163
- {shortcut && (
164
- <KeyboardEventHandler
165
- handleKeys={[keyboardSelectionKey.toLowerCase()]}
166
- onKeyEvent={(key, e) => {
167
- e.preventDefault();
168
- onChange(optionValue);
169
- }}
170
- handleFocusableElements
171
- />
172
- )}
173
- </div>
174
- );
175
- }
176
- )}
177
- </fieldset>
178
- </div>
179
- {management && (
180
- <div className="tooltip">
181
- <TooltipResponse
182
- id={id}
183
- response={U.buildMultiTooltipResponse(filledOptions)(response)}
184
- />
185
- </div>
186
- )}
187
- </div>
188
- <Declarations
189
- id={id}
190
- type={C.DETACHABLE}
191
- declarations={declarations}
192
- features={features}
193
- bindings={bindings}
194
- />
195
- </>
196
- );
197
- };
198
-
199
- ListDeclarationsWrapper.defaultProps = {
200
- label: '',
201
- preferences: ['COLLECTED'],
202
- response: {},
203
- options: [],
204
- disabled: false,
205
- focused: false,
206
- positioning: 'DEFAULT',
207
- declarations: [],
208
- features: [],
209
- bindings: {},
210
- management: false,
211
- style: { fieldsetStyle: {}, modalityStyle: {} },
212
- };
213
-
214
- ListDeclarationsWrapper.propTypes = {
215
- id: PropTypes.string.isRequired,
216
- label: PropTypes.string,
217
- preferences: PropTypes.arrayOf(U.valueTypePropTypes),
218
- response: U.responsePropTypes,
219
- options: U.optionsPropTypes,
220
- handleChange: PropTypes.func.isRequired,
221
- disabled: PropTypes.bool,
222
- focused: PropTypes.bool,
223
- positioning: PropTypes.oneOf(['DEFAULT', 'HORIZONTAL', 'VERTICAL']),
224
- declarations: U.declarationsPropTypes,
225
- features: PropTypes.arrayOf(PropTypes.string),
226
- bindings: PropTypes.object,
227
- management: PropTypes.bool,
228
- style: PropTypes.object,
229
- type: PropTypes.oneOf(['radio', 'checkbox']),
230
- };
231
-
232
- export default ListDeclarationsWrapper;
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import KeyboardEventHandler from 'react-keyboard-event-handler';
3
+ import PropTypes from 'prop-types';
4
+ import debounce from 'lodash.debounce';
5
+ import Declarations from '../';
6
+ import Icon from '../../icon';
7
+ import { TooltipResponse } from '../../tooltip';
8
+ import * as U from '../../../utils/lib';
9
+ import * as C from '../../../constants';
10
+ import { interpret } from '../../../utils/to-expose';
11
+
12
+ const ListDeclarationsWrapper = ({
13
+ id,
14
+ label,
15
+ preferences,
16
+ response,
17
+ options,
18
+ handleChange: propsHandleChange,
19
+ disabled,
20
+ focused,
21
+ shortcut,
22
+ declarations,
23
+ features,
24
+ bindings,
25
+ management,
26
+ style,
27
+ positioning,
28
+ type,
29
+ hasSpecificHandler,
30
+ logFunction,
31
+ }) => {
32
+ const inputRef = useRef();
33
+
34
+ const [value, setValue] = useState(() =>
35
+ U.getResponseByPreference(preferences)(response)
36
+ );
37
+
38
+ const filledOptions =
39
+ management && type === 'checkbox'
40
+ ? [...options, { label: 'NR', value: '_N_R_' }]
41
+ : options;
42
+
43
+ const specificHandleChange = (e) => {
44
+ const { values } = response;
45
+ const [key, value] = Object.entries(e)[0];
46
+ const newValue =
47
+ values[preferences[preferences.length - 1]] === value ? null : value;
48
+ handleChange({ [key]: newValue });
49
+ if (management) {
50
+ setValue(
51
+ U.getResponseByPreference(preferences)(
52
+ U.buildLocalResponse(response, newValue)
53
+ )
54
+ );
55
+ } else setValue(newValue);
56
+ };
57
+
58
+ const handleChange = debounce((obj) => propsHandleChange(obj), 50);
59
+
60
+ const onChange = (v) => {
61
+ const update = {
62
+ [U.getResponseName(response)]: v,
63
+ };
64
+ if (hasSpecificHandler) specificHandleChange(update);
65
+ else {
66
+ setValue(v);
67
+ handleChange(update);
68
+ }
69
+ if (U.isFunction(logFunction))
70
+ logFunction(
71
+ U.createObjectEvent(
72
+ `${type}-${id}-${v}`,
73
+ C.INPUT_CATEGORY,
74
+ C.EVENT_SELECTION,
75
+ U.getResponseName(response),
76
+ v
77
+ )
78
+ );
79
+ };
80
+
81
+ // Assume we only want to handle enable external updates
82
+ // Don't need to check all value changes
83
+ useEffect(() => {
84
+ if (U.getResponseByPreference(preferences)(response) !== value)
85
+ setValue(U.getResponseByPreference(preferences)(response));
86
+ // eslint-disable-next-line react-hooks/exhaustive-deps
87
+ }, [response, preferences]);
88
+
89
+ useEffect(() => {
90
+ if (focused) inputRef.current.focus();
91
+ }, [focused]);
92
+
93
+ const { fieldsetStyle, modalityStyle } = style;
94
+ return (
95
+ <>
96
+ <Declarations
97
+ id={id}
98
+ type={C.BEFORE_QUESTION_TEXT}
99
+ declarations={declarations}
100
+ features={features}
101
+ bindings={bindings}
102
+ />
103
+ <div className="field-container">
104
+ <div className={`${management ? 'field-with-tooltip' : 'field'}`}>
105
+ <fieldset
106
+ key={`${type}-${id}`}
107
+ className={`${type}-group-list`}
108
+ style={U.buildStyleObject(fieldsetStyle)}
109
+ >
110
+ <legend>{interpret(features, logFunction)(bindings)(label)}</legend>
111
+ <Declarations
112
+ id={id}
113
+ type={C.AFTER_QUESTION_TEXT}
114
+ declarations={declarations}
115
+ features={features}
116
+ bindings={bindings}
117
+ />
118
+ {filledOptions.map(
119
+ ({ label: optionLabel, value: optionValue }, i) => {
120
+ const checked = value === optionValue;
121
+ const interpretedLabel = interpret(
122
+ features,
123
+ logFunction
124
+ )(bindings)(optionLabel);
125
+ const keyboardSelectionKey =
126
+ options.length < 10 ? `${i + 1}` : U.getAlphabet()[i];
127
+ return (
128
+ <div
129
+ key={`${type}-${id}-${optionValue}`}
130
+ className={`${type}-modality ${type}-modality-block ${U.getItemsPositioningClass(
131
+ positioning
132
+ )} ${checked ? 'content-checked' : ''} ${
133
+ optionValue === '_N_R_' ? 'modality_NR' : ''
134
+ }`}
135
+ >
136
+ <Icon type={type} checked={checked} disabled={disabled}>
137
+ <input
138
+ type={type}
139
+ name={`${type}-${id}`}
140
+ ref={i === 0 || checked ? inputRef : null}
141
+ id={`${type}-${id}-${optionValue}`}
142
+ aria-labelledby={`input-label-${id}-${optionValue}`}
143
+ className={`${type}-lunatic`}
144
+ style={U.buildStyleObject(style)}
145
+ checked={checked}
146
+ disabled={disabled}
147
+ onChange={(optionLabel) => onChange(optionValue)}
148
+ />
149
+ <label
150
+ htmlFor={`${type}-${id}-${optionValue}`}
151
+ id={`input-label-${id}-${optionValue}`}
152
+ style={checked ? U.buildStyleObject(modalityStyle) : {}}
153
+ className="modality-label"
154
+ >
155
+ {shortcut && (
156
+ <span className="code-modality">
157
+ {keyboardSelectionKey.toUpperCase()}
158
+ </span>
159
+ )}
160
+ {interpretedLabel}
161
+ </label>
162
+ </Icon>
163
+ {shortcut && (
164
+ <KeyboardEventHandler
165
+ handleKeys={[keyboardSelectionKey.toLowerCase()]}
166
+ onKeyEvent={(key, e) => {
167
+ e.preventDefault();
168
+ onChange(optionValue);
169
+ }}
170
+ handleFocusableElements
171
+ />
172
+ )}
173
+ </div>
174
+ );
175
+ }
176
+ )}
177
+ </fieldset>
178
+ </div>
179
+ {management && (
180
+ <div className="tooltip">
181
+ <TooltipResponse
182
+ id={id}
183
+ response={U.buildMultiTooltipResponse(filledOptions)(response)}
184
+ />
185
+ </div>
186
+ )}
187
+ </div>
188
+ <Declarations
189
+ id={id}
190
+ type={C.DETACHABLE}
191
+ declarations={declarations}
192
+ features={features}
193
+ bindings={bindings}
194
+ />
195
+ </>
196
+ );
197
+ };
198
+
199
+ ListDeclarationsWrapper.defaultProps = {
200
+ label: '',
201
+ preferences: ['COLLECTED'],
202
+ response: {},
203
+ options: [],
204
+ disabled: false,
205
+ focused: false,
206
+ positioning: 'DEFAULT',
207
+ declarations: [],
208
+ features: [],
209
+ bindings: {},
210
+ management: false,
211
+ style: { fieldsetStyle: {}, modalityStyle: {} },
212
+ };
213
+
214
+ ListDeclarationsWrapper.propTypes = {
215
+ id: PropTypes.string.isRequired,
216
+ label: PropTypes.string,
217
+ preferences: PropTypes.arrayOf(U.valueTypePropTypes),
218
+ response: U.responsePropTypes,
219
+ options: U.optionsPropTypes,
220
+ handleChange: PropTypes.func.isRequired,
221
+ disabled: PropTypes.bool,
222
+ focused: PropTypes.bool,
223
+ positioning: PropTypes.oneOf(['DEFAULT', 'HORIZONTAL', 'VERTICAL']),
224
+ declarations: U.declarationsPropTypes,
225
+ features: PropTypes.arrayOf(PropTypes.string),
226
+ bindings: PropTypes.object,
227
+ management: PropTypes.bool,
228
+ style: PropTypes.object,
229
+ type: PropTypes.oneOf(['radio', 'checkbox']),
230
+ };
231
+
232
+ export default ListDeclarationsWrapper;
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import classnames from 'classnames';
4
4
  import Label from './label';
5
5
  import * as U from '../../../../utils/lib';
6
+ import * as C from '../../../../constants';
6
7
  import * as CLEAN from '../cleaner-callbacks';
7
8
  import * as actions from '../actions';
8
9
  import DropdownField from './dropdown-field';
@@ -65,9 +66,19 @@ function Dropdown({
65
66
  state,
66
67
  dispatch,
67
68
  refs,
69
+ logFunction,
68
70
  }) {
69
71
  const { visible, focused, id, disabled } = state;
70
72
 
73
+ const createEventFocus = (focusIn = true) =>
74
+ U.createObjectEvent(
75
+ id,
76
+ C.INPUT_CATEGORY,
77
+ focusIn ? C.EVENT_FOCUS_IN : C.EVENT_FOCUS_OUT,
78
+ U.getResponseName(response),
79
+ valueFromProps
80
+ );
81
+
71
82
  CLEAN.add(id, function () {
72
83
  dispatch(actions.hidePanel());
73
84
  dispatch(actions.setFocused(false));
@@ -130,6 +141,16 @@ function Dropdown({
130
141
  [state, dispatch, onSelect]
131
142
  );
132
143
 
144
+ // log info when focus change
145
+ useEffect(() => {
146
+ if (id && focused && U.isFunction(logFunction))
147
+ logFunction(createEventFocus());
148
+ if (id && !focused && U.isFunction(logFunction))
149
+ logFunction(createEventFocus(false));
150
+
151
+ // eslint-disable-next-line react-hooks/exhaustive-deps
152
+ }, [focused, id]);
153
+
133
154
  return (
134
155
  <DropdownContainer
135
156
  className={classnames(className, U.getLabelPositionClass(labelPosition), {
@@ -37,6 +37,7 @@ const createOnSelect = (_, dispatch, onSelect) => (option) => {
37
37
  * @param {props}
38
38
  */
39
39
  function Dropdown({
40
+ id: initId,
40
41
  widthAuto,
41
42
  options = [],
42
43
  onSelect,
@@ -52,10 +53,11 @@ function Dropdown({
52
53
  disabled,
53
54
  focused: initFocused,
54
55
  DeclarationAfterLabel,
56
+ logFunction,
55
57
  }) {
56
58
  const [state, dispatch] = useReducer(reducer, {
57
59
  ...initial,
58
- id: `dropdown-${new Date().getMilliseconds()}`,
60
+ id: `dropdown-${initId || new Date().getMilliseconds()}`,
59
61
  disabled,
60
62
  focused: initFocused,
61
63
  });
@@ -98,6 +100,7 @@ function Dropdown({
98
100
  value={valueFromProps}
99
101
  zIndex={zIndex}
100
102
  management={management}
103
+ logFunction={logFunction}
101
104
  >
102
105
  <DeclarationAfterLabel />
103
106
  <span
@@ -26,11 +26,12 @@ const Dropdown = ({
26
26
  className,
27
27
  zIndex,
28
28
  DeclarationAfterLabel,
29
+ logFunction,
29
30
  }) => {
30
31
  const containerEl = useRef();
31
32
  const [state, dispatch] = useReducer(reducer, {
32
33
  ...initial,
33
- id: `dropdown-${initId}-${new Date().getMilliseconds()}`,
34
+ id: `dropdown-${initId || new Date().getMilliseconds()}`,
34
35
  disabled,
35
36
  focused: initFocused,
36
37
  });
@@ -59,6 +60,7 @@ const Dropdown = ({
59
60
  onSelect={onSelect_}
60
61
  value={value}
61
62
  zIndex={zIndex}
63
+ logFunction={logFunction}
62
64
  >
63
65
  <DeclarationAfterLabel />
64
66
  <span className={classnames('lunatic-dropdown-input', { focused })}>
@@ -1,42 +1,42 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { interpret } from '../../utils/to-expose';
4
- import { buildStyleObject } from '../../utils/lib';
5
-
6
- const FilterDescription = ({
7
- id,
8
- label,
9
- filterDescription,
10
- features,
11
- bindings,
12
- style,
13
- logFunction,
14
- }) =>
15
- filterDescription ? (
16
- <div
17
- id={`filter-description-${id}`}
18
- aria-label={`filter-description`}
19
- className="filter-description-lunatic"
20
- style={buildStyleObject(style)}
21
- >
22
- {interpret(features, logFunction)(bindings)(label)}
23
- </div>
24
- ) : null;
25
-
26
- FilterDescription.defaultProps = {
27
- filterDescription: false,
28
- features: [],
29
- bindings: {},
30
- style: {},
31
- };
32
-
33
- FilterDescription.propTypes = {
34
- id: PropTypes.string.isRequired,
35
- label: PropTypes.string.isRequired,
36
- filterDescription: PropTypes.bool,
37
- features: PropTypes.arrayOf(PropTypes.string),
38
- bindings: PropTypes.object,
39
- style: PropTypes.object,
40
- };
41
-
42
- export default FilterDescription;
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { interpret } from '../../utils/to-expose';
4
+ import { buildStyleObject } from '../../utils/lib';
5
+
6
+ const FilterDescription = ({
7
+ id,
8
+ label,
9
+ filterDescription,
10
+ features,
11
+ bindings,
12
+ style,
13
+ logFunction,
14
+ }) =>
15
+ filterDescription ? (
16
+ <div
17
+ id={`filter-description-${id}`}
18
+ aria-label={`filter-description`}
19
+ className="filter-description-lunatic"
20
+ style={buildStyleObject(style)}
21
+ >
22
+ {interpret(features, logFunction)(bindings)(label)}
23
+ </div>
24
+ ) : null;
25
+
26
+ FilterDescription.defaultProps = {
27
+ filterDescription: false,
28
+ features: [],
29
+ bindings: {},
30
+ style: {},
31
+ };
32
+
33
+ FilterDescription.propTypes = {
34
+ id: PropTypes.string.isRequired,
35
+ label: PropTypes.string.isRequired,
36
+ filterDescription: PropTypes.bool,
37
+ features: PropTypes.arrayOf(PropTypes.string),
38
+ bindings: PropTypes.object,
39
+ style: PropTypes.object,
40
+ };
41
+
42
+ export default FilterDescription;