@inseefr/lunatic 2.6.15 → 2.6.16

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.
@@ -38,7 +38,10 @@ function Suggester(_ref) {
38
38
  searching = _ref.searching,
39
39
  label = _ref.label,
40
40
  description = _ref.description,
41
- errors = _ref.errors;
41
+ errors = _ref.errors,
42
+ _ref$arbitrary = _ref.arbitrary,
43
+ arbitrary = _ref$arbitrary === void 0 ? true : _ref$arbitrary,
44
+ focused = _ref.focused;
42
45
  var _useState = (0, _react.useState)(''),
43
46
  _useState2 = _slicedToArray(_useState, 2),
44
47
  search = _useState2[0],
@@ -72,7 +75,9 @@ function Suggester(_ref) {
72
75
  setOptions(results);
73
76
  setSearch(search);
74
77
  // if a user does not select an option in the list, their search term is saved
75
- onSelect(search);
78
+ if (arbitrary) {
79
+ onSelect(search);
80
+ }
76
81
  }
77
82
  _context.next = 13;
78
83
  break;
@@ -89,7 +94,7 @@ function Suggester(_ref) {
89
94
  return function (_x) {
90
95
  return _ref2.apply(this, arguments);
91
96
  };
92
- }(), [searching, onSelect]);
97
+ }(), [searching, arbitrary, onSelect]);
93
98
  var defaultSearch = getSearch(search, value);
94
99
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.ComboBox, {
95
100
  id: id,
@@ -108,7 +113,8 @@ function Suggester(_ref) {
108
113
  placeholder: placeholder,
109
114
  label: label,
110
115
  description: description,
111
- errors: errors
116
+ errors: errors,
117
+ focused: focused
112
118
  });
113
119
  }
114
120
  function getSearch(search, value) {
@@ -33,7 +33,9 @@ function IDBSuggester(_ref) {
33
33
  getSuggesterStatus = _ref.getSuggesterStatus,
34
34
  errors = _ref.errors,
35
35
  readOnly = _ref.readOnly,
36
- workersBasePath = _ref.workersBasePath;
36
+ workersBasePath = _ref.workersBasePath,
37
+ arbitrary = _ref.arbitrary,
38
+ focused = _ref.focused;
37
39
  var _useState = (0, _react.useState)(undefined),
38
40
  _useState2 = _slicedToArray(_useState, 2),
39
41
  store = _useState2[0],
@@ -65,7 +67,9 @@ function IDBSuggester(_ref) {
65
67
  value: value,
66
68
  label: label,
67
69
  description: description,
68
- errors: errors
70
+ errors: errors,
71
+ arbitrary: arbitrary,
72
+ focused: focused
69
73
  })
70
74
  })
71
75
  });
@@ -16,7 +16,6 @@ function LunaticSuggester(_ref) {
16
16
  optionRenderer = _ref.optionRenderer,
17
17
  labelRenderer = _ref.labelRenderer,
18
18
  idbVersion = _ref.idbVersion,
19
- focused = _ref.focused,
20
19
  value = _ref.value,
21
20
  handleChange = _ref.handleChange,
22
21
  disabled = _ref.disabled,
@@ -32,7 +31,9 @@ function LunaticSuggester(_ref) {
32
31
  response = _ref.response,
33
32
  className = _ref.className,
34
33
  getSuggesterStatus = _ref.getSuggesterStatus,
35
- workersBasePath = _ref.workersBasePath;
34
+ workersBasePath = _ref.workersBasePath,
35
+ arbitrary = _ref.arbitrary,
36
+ focused = _ref.focused;
36
37
  var onChange = (0, _useOnHandleChange["default"])({
37
38
  handleChange: handleChange,
38
39
  response: response,
@@ -62,7 +63,9 @@ function LunaticSuggester(_ref) {
62
63
  getSuggesterStatus: getSuggesterStatus,
63
64
  className: className,
64
65
  readOnly: readOnly,
65
- workersBasePath: workersBasePath
66
+ workersBasePath: workersBasePath,
67
+ arbitrary: arbitrary,
68
+ focused: focused
66
69
  })
67
70
  });
68
71
  }
@@ -21,6 +21,8 @@ type Props = {
21
21
  label?: ReactNode;
22
22
  description?: ReactNode;
23
23
  errors?: LunaticError[];
24
+ arbitrary?: boolean;
25
+ focused?: boolean;
24
26
  };
25
27
  declare const _default: import("react").ComponentType<Props>;
26
28
  export default _default;
@@ -1,9 +1,9 @@
1
1
  import type { LunaticError } from '../../../use-lunatic/type';
2
2
  import type { LunaticComponentProps } from '../../type';
3
- type Props = Pick<LunaticComponentProps<'Suggester'>, 'storeName' | 'idbVersion' | 'id' | 'className' | 'optionRenderer' | 'labelRenderer' | 'disabled' | 'readOnly' | 'value' | 'label' | 'description' | 'getSuggesterStatus'> & {
3
+ type Props = Pick<LunaticComponentProps<'Suggester'>, 'storeName' | 'idbVersion' | 'id' | 'className' | 'optionRenderer' | 'labelRenderer' | 'disabled' | 'readOnly' | 'value' | 'label' | 'description' | 'getSuggesterStatus' | 'arbitrary' | 'focused'> & {
4
4
  errors?: LunaticError[];
5
5
  onSelect: (v: string | null) => void;
6
6
  workersBasePath?: string;
7
7
  };
8
- export declare function IDBSuggester({ storeName, idbVersion, id, className, optionRenderer, labelRenderer, onSelect, disabled, value, label, description, getSuggesterStatus, errors, readOnly, workersBasePath, }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export declare function IDBSuggester({ storeName, idbVersion, id, className, optionRenderer, labelRenderer, onSelect, disabled, value, label, description, getSuggesterStatus, errors, readOnly, workersBasePath, arbitrary, focused, }: Props): import("react/jsx-runtime").JSX.Element;
9
9
  export {};
@@ -1,3 +1,3 @@
1
1
  import type { LunaticComponentProps } from '../type';
2
- declare function LunaticSuggester({ id, storeName, optionRenderer, labelRenderer, idbVersion, focused, value, handleChange, disabled, readOnly, errors, label, description, preferences, declarations, missing, missingResponse, management, response, className, getSuggesterStatus, workersBasePath, }: LunaticComponentProps<'Suggester'>): import("react/jsx-runtime").JSX.Element;
2
+ declare function LunaticSuggester({ id, storeName, optionRenderer, labelRenderer, idbVersion, value, handleChange, disabled, readOnly, errors, label, description, preferences, declarations, missing, missingResponse, management, response, className, getSuggesterStatus, workersBasePath, arbitrary, focused, }: LunaticComponentProps<'Suggester'>): import("react/jsx-runtime").JSX.Element;
3
3
  export default LunaticSuggester;
@@ -257,6 +257,7 @@ type ComponentPropsByType = {
257
257
  response: {
258
258
  name: string;
259
259
  };
260
+ arbitrary?: boolean;
260
261
  };
261
262
  Summary: LunaticBaseProps<string | null> & {
262
263
  sections: Array<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "2.6.15",
3
+ "version": "2.6.16",
4
4
  "workersVersion": "0.3.0-experimental",
5
5
  "description": "Library of questionnaire components",
6
6
  "repository": {