mautourco-components 0.2.114 → 0.2.115

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.
@@ -32,6 +32,11 @@ var LocationDropdown = function (_a) {
32
32
  var dropdownPanelRef = useRef(null);
33
33
  var inputRef = useRef(null);
34
34
  var searchInputRef = useRef(null);
35
+ var getDefaultLabel = function (id) {
36
+ var _a;
37
+ var option = options.find(function (o) { return o.id === id; });
38
+ return (_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '';
39
+ };
35
40
  // Close dropdown when clicking outside
36
41
  useEffect(function () {
37
42
  var handleClickOutside = function (event) {
@@ -61,9 +66,9 @@ var LocationDropdown = function (_a) {
61
66
  if (!selectedValue && defaultValue && !disabled) {
62
67
  var defaultLocationData = {
63
68
  id: defaultValue.id,
64
- locationName: defaultValue.label,
69
+ locationName: getDefaultLabel(defaultValue.id),
65
70
  };
66
- console.log('defaultLocationData ===>', defaultLocationData);
71
+ console.log('defaultLocationData selected ===>', defaultLocationData);
67
72
  onSelectionChange(defaultLocationData);
68
73
  }
69
74
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -76,11 +81,11 @@ var LocationDropdown = function (_a) {
76
81
  var handleOptionSelect = function (option) {
77
82
  if (disabled)
78
83
  return;
79
- console.log('option selected ===>', option);
80
84
  var locationData = {
81
85
  id: option.id,
82
- locationName: option.label,
86
+ locationName: getDefaultLabel(option.id),
83
87
  };
88
+ console.log('locationData selected ===>', locationData);
84
89
  onSelectionChange(locationData);
85
90
  setIsOpen(false);
86
91
  setSearchQuery('');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mautourco-components",
3
- "version": "0.2.114",
3
+ "version": "0.2.115",
4
4
  "private": false,
5
5
  "description": "Bibliothèque de composants Mautourco pour le redesign",
6
6
  "main": "dist/index.js",
@@ -69,6 +69,11 @@ const LocationDropdown: React.FC<LocationDropdownProps> = ({
69
69
  const inputRef = useRef<HTMLDivElement>(null);
70
70
  const searchInputRef = useRef<HTMLInputElement>(null);
71
71
 
72
+ const getDefaultLabel = (id: string | number) => {
73
+ const option = options.find((o) => o.id === id);
74
+ return option?.label ?? '';
75
+ };
76
+
72
77
  // Close dropdown when clicking outside
73
78
  useEffect(() => {
74
79
  const handleClickOutside = (event: MouseEvent) => {
@@ -102,9 +107,10 @@ const LocationDropdown: React.FC<LocationDropdownProps> = ({
102
107
  if (!selectedValue && defaultValue && !disabled) {
103
108
  const defaultLocationData: LocationData = {
104
109
  id: defaultValue.id,
105
- locationName: defaultValue.label,
110
+ locationName: getDefaultLabel(defaultValue.id),
106
111
  };
107
- console.log('defaultLocationData ===>', defaultLocationData);
112
+
113
+ console.log('defaultLocationData selected ===>', defaultLocationData);
108
114
  onSelectionChange(defaultLocationData);
109
115
  }
110
116
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -118,11 +124,11 @@ const LocationDropdown: React.FC<LocationDropdownProps> = ({
118
124
 
119
125
  const handleOptionSelect = (option: LocationOption) => {
120
126
  if (disabled) return;
121
- console.log('option selected ===>', option);
122
127
  const locationData: LocationData = {
123
128
  id: option.id,
124
- locationName: option.label,
129
+ locationName: getDefaultLabel(option.id),
125
130
  };
131
+ console.log('locationData selected ===>', locationData);
126
132
  onSelectionChange(locationData);
127
133
  setIsOpen(false);
128
134
  setSearchQuery('');