mautourco-components 0.2.157 → 0.2.158

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.
@@ -34,6 +34,14 @@ export interface BookingPaxErrorData {
34
34
  type: BookingPaxData['type'];
35
35
  hasError: boolean;
36
36
  }
37
+ export interface BookingPaxChangeData {
38
+ type: BookingPaxData['type'];
39
+ index: number;
40
+ options?: BookingPaxClientOptions;
41
+ remark?: string;
42
+ time?: string | string[];
43
+ flightNumber?: string;
44
+ }
37
45
  export interface BookingPaxProps {
38
46
  /**
39
47
  * The data of the booking pax.
@@ -71,6 +79,10 @@ export interface BookingPaxProps {
71
79
  * The callback function to call when the auto filled data changes.
72
80
  */
73
81
  onAutoFilled?: (data: BookingPaxAutoFilledData[]) => void;
82
+ /**
83
+ * The callback function to call when the data changes.
84
+ */
85
+ onChange?: (data: BookingPaxChangeData) => void;
74
86
  }
75
87
  /**
76
88
  * BookingPaxList is a component that allows the user to select the pax for a booking.
@@ -51,25 +51,29 @@ var isTransferData = function (data) {
51
51
  * @returns The BookingPaxList component.
52
52
  */
53
53
  export function BookingPaxList(props) {
54
- var data = props.data, isSubmitted = props.isSubmitted, clientsInfo = props.clientsInfo, onPaxChange = props.onPaxChange, onRemarkChange = props.onRemarkChange, onError = props.onError, onTimeChange = props.onTimeChange, onFlightNumberChange = props.onFlightNumberChange, onAutoFilled = props.onAutoFilled;
54
+ var data = props.data, isSubmitted = props.isSubmitted, clientsInfo = props.clientsInfo, onPaxChange = props.onPaxChange, onRemarkChange = props.onRemarkChange, onError = props.onError, onTimeChange = props.onTimeChange, onFlightNumberChange = props.onFlightNumberChange, onAutoFilled = props.onAutoFilled, onChange = props.onChange;
55
55
  var _a = useState([]), autoFilledData = _a[0], setAutoFilledData = _a[1];
56
56
  // Memoized callback handlers to reduce re-renders
57
57
  var handlePaxChange = useCallback(function (type, index, options) {
58
58
  onPaxChange === null || onPaxChange === void 0 ? void 0 : onPaxChange(index, type, options);
59
+ onChange === null || onChange === void 0 ? void 0 : onChange({ type: type, index: index, options: options });
59
60
  }, [onPaxChange]);
60
- var handleRemarkChange = useCallback(function (type, index, value) {
61
- onRemarkChange === null || onRemarkChange === void 0 ? void 0 : onRemarkChange(index, type, value);
61
+ var handleRemarkChange = useCallback(function (type, index, remark) {
62
+ onRemarkChange === null || onRemarkChange === void 0 ? void 0 : onRemarkChange(index, type, remark);
63
+ onChange === null || onChange === void 0 ? void 0 : onChange({ type: type, index: index, remark: remark });
62
64
  }, [onRemarkChange]);
63
65
  var handleError = useCallback(function (errorData) {
64
66
  onError === null || onError === void 0 ? void 0 : onError(errorData);
65
67
  }, [onError]);
66
- var handleTimeChange = useCallback(function (value, index) {
68
+ var handleTimeChange = useCallback(function (time, index) {
67
69
  // Don't need type because only transfer has this callback
68
- onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(index, value);
70
+ onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(index, time);
71
+ onChange === null || onChange === void 0 ? void 0 : onChange({ type: 'transfer', index: index, time: time });
69
72
  }, [onTimeChange]);
70
- var handleFlightNumberChange = useCallback(function (value, index) {
73
+ var handleFlightNumberChange = useCallback(function (flightNumber, index) {
71
74
  // Don't need type because only transfer has this callback
72
- onFlightNumberChange === null || onFlightNumberChange === void 0 ? void 0 : onFlightNumberChange(index, value);
75
+ onFlightNumberChange === null || onFlightNumberChange === void 0 ? void 0 : onFlightNumberChange(index, flightNumber);
76
+ onChange === null || onChange === void 0 ? void 0 : onChange({ type: 'transfer', index: index, flightNumber: flightNumber });
73
77
  }, [onFlightNumberChange]);
74
78
  var handleAutoFilled = useCallback(function (type) {
75
79
  return function (paxCount, index, roomIndex) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mautourco-components",
3
- "version": "0.2.157",
3
+ "version": "0.2.158",
4
4
  "private": false,
5
5
  "description": "Bibliothèque de composants Mautourco pour le redesign",
6
6
  "main": "dist/index.js",
@@ -50,6 +50,15 @@ export interface BookingPaxErrorData {
50
50
  hasError: boolean;
51
51
  }
52
52
 
53
+ export interface BookingPaxChangeData {
54
+ type: BookingPaxData['type'];
55
+ index: number;
56
+ options?: BookingPaxClientOptions;
57
+ remark?: string;
58
+ time?: string | string[];
59
+ flightNumber?: string;
60
+ }
61
+
53
62
  export interface BookingPaxProps {
54
63
  /**
55
64
  * The data of the booking pax.
@@ -91,6 +100,11 @@ export interface BookingPaxProps {
91
100
  * The callback function to call when the auto filled data changes.
92
101
  */
93
102
  onAutoFilled?: (data: BookingPaxAutoFilledData[]) => void;
103
+
104
+ /**
105
+ * The callback function to call when the data changes.
106
+ */
107
+ onChange?: (data: BookingPaxChangeData) => void;
94
108
  }
95
109
 
96
110
  // Type guards for better type safety
@@ -142,6 +156,7 @@ export function BookingPaxList(props: BookingPaxProps) {
142
156
  onTimeChange,
143
157
  onFlightNumberChange,
144
158
  onAutoFilled,
159
+ onChange,
145
160
  } = props;
146
161
 
147
162
  const [autoFilledData, setAutoFilledData] = useState<
@@ -157,13 +172,15 @@ export function BookingPaxList(props: BookingPaxProps) {
157
172
  const handlePaxChange = useCallback(
158
173
  (type: BookingPaxData['type'], index: number, options: BookingPaxClientOptions) => {
159
174
  onPaxChange?.(index, type, options);
175
+ onChange?.({ type, index, options });
160
176
  },
161
177
  [onPaxChange]
162
178
  );
163
179
 
164
180
  const handleRemarkChange = useCallback(
165
- (type: BookingPaxData['type'], index: number, value: string) => {
166
- onRemarkChange?.(index, type, value);
181
+ (type: BookingPaxData['type'], index: number, remark: string) => {
182
+ onRemarkChange?.(index, type, remark);
183
+ onChange?.({ type, index, remark });
167
184
  },
168
185
  [onRemarkChange]
169
186
  );
@@ -176,17 +193,19 @@ export function BookingPaxList(props: BookingPaxProps) {
176
193
  );
177
194
 
178
195
  const handleTimeChange = useCallback(
179
- (value: string | string[], index: number) => {
196
+ (time: string | string[], index: number) => {
180
197
  // Don't need type because only transfer has this callback
181
- onTimeChange?.(index, value);
198
+ onTimeChange?.(index, time);
199
+ onChange?.({ type: 'transfer', index, time });
182
200
  },
183
201
  [onTimeChange]
184
202
  );
185
203
 
186
204
  const handleFlightNumberChange = useCallback(
187
- (value: string, index: number) => {
205
+ (flightNumber: string, index: number) => {
188
206
  // Don't need type because only transfer has this callback
189
- onFlightNumberChange?.(index, value);
207
+ onFlightNumberChange?.(index, flightNumber);
208
+ onChange?.({ type: 'transfer', index, flightNumber });
190
209
  },
191
210
  [onFlightNumberChange]
192
211
  );