@apexcura/ui-components 0.0.9-Beta4 → 0.0.9-Beta6

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.
package/dist/index.d.mts CHANGED
@@ -17,10 +17,7 @@ type ElementType = {
17
17
  suffix?: React.ReactNode;
18
18
  maxLength?: number;
19
19
  fieldNames?: any[];
20
- onChange?: (value: string | number | boolean | any[] | {
21
- id: string;
22
- title: string;
23
- }[]) => void;
20
+ onChange?: (value: string | number | boolean | any[]) => void;
24
21
  dropDownOptions: any[];
25
22
  };
26
23
 
package/dist/index.d.ts CHANGED
@@ -17,10 +17,7 @@ type ElementType = {
17
17
  suffix?: React.ReactNode;
18
18
  maxLength?: number;
19
19
  fieldNames?: any[];
20
- onChange?: (value: string | number | boolean | any[] | {
21
- id: string;
22
- title: string;
23
- }[]) => void;
20
+ onChange?: (value: string | number | boolean | any[]) => void;
24
21
  dropDownOptions: any[];
25
22
  };
26
23
 
package/dist/index.js CHANGED
@@ -188,8 +188,10 @@ var import_react6 = __toESM(require("react"));
188
188
  var import_antd6 = require("antd");
189
189
  var RadioElement = (props) => {
190
190
  const handleChange = (e) => {
191
- if (props && props.onChange) {
192
- props.onChange(e.target.value);
191
+ if (props.onChange) {
192
+ const selectedVal = e.target.value;
193
+ const selectedOptions = [{ id: selectedVal, value: selectedVal }];
194
+ props.onChange(selectedOptions);
193
195
  }
194
196
  };
195
197
  return /* @__PURE__ */ import_react6.default.createElement(import_antd6.Radio.Group, { name: "radiogroup", defaultValue: 1 }, /* @__PURE__ */ import_react6.default.createElement(import_antd6.Radio, { value: 1, onChange: handleChange }, "A"), /* @__PURE__ */ import_react6.default.createElement(import_antd6.Radio, { value: 2, onChange: handleChange }, "B"), /* @__PURE__ */ import_react6.default.createElement(import_antd6.Radio, { value: 3, onChange: handleChange }, "C"), /* @__PURE__ */ import_react6.default.createElement(import_antd6.Radio, { value: 4, onChange: handleChange }, "D"));
@@ -207,7 +209,10 @@ var CheckboxElement = (props) => {
207
209
  const handleChange = (list) => {
208
210
  setCheckedList(list);
209
211
  if (props.onChange) {
210
- props.onChange(list);
212
+ const selectedOptions = list.map((value) => {
213
+ return { id: list.indexOf(value), value };
214
+ });
215
+ props.onChange(selectedOptions);
211
216
  }
212
217
  };
213
218
  const onHandleAllChanges = (e) => {
@@ -302,9 +307,11 @@ var onSearch = (value) => {
302
307
  };
303
308
  var filterOption = (input, option) => (option?.label ?? "").toLowerCase().includes(input.toLowerCase());
304
309
  var SingleSelectElement = (props) => {
305
- const handleChange = (value) => {
310
+ const handleChange = (values) => {
306
311
  if (props.onChange) {
307
- props.onChange(value);
312
+ const option = props.dropDownOptions.find((option2) => String(option2.title) === values);
313
+ const selectedOption = { id: option?.id, value: values };
314
+ props.onChange([selectedOption]);
308
315
  }
309
316
  };
310
317
  return /* @__PURE__ */ import_react10.default.createElement(
@@ -316,7 +323,7 @@ var SingleSelectElement = (props) => {
316
323
  onChange: handleChange,
317
324
  onSearch,
318
325
  filterOption,
319
- options: props.dropDownOptions?.map((eachOption) => ({ label: String(eachOption.title), value: String(eachOption.title) }))
326
+ options: props.dropDownOptions?.map((eachOption) => ({ label: String(eachOption.title), value: String(eachOption.title), id: String(eachOption.id) }))
320
327
  }
321
328
  );
322
329
  };
@@ -325,15 +332,13 @@ var SingleSelectElement = (props) => {
325
332
  var import_react11 = __toESM(require("react"));
326
333
  var import_antd9 = require("antd");
327
334
  var MultipleSelectElement = (props) => {
328
- const handleChange = (selectedValues) => {
329
- console.log("==========", selectedValues);
330
- const transformedValues = selectedValues.map((option) => ({
331
- id: option.id,
332
- value: option.title
333
- }));
335
+ const handleChange = (values) => {
334
336
  if (props.onChange) {
335
- console.log(transformedValues);
336
- props.onChange(transformedValues);
337
+ const selectedOptions = values.map((value) => {
338
+ const option = props.dropDownOptions.find((option2) => String(option2.title) === value);
339
+ return { id: option?.id, value };
340
+ });
341
+ props.onChange(selectedOptions);
337
342
  }
338
343
  };
339
344
  return /* @__PURE__ */ import_react11.default.createElement(
package/dist/index.mjs CHANGED
@@ -142,8 +142,10 @@ import React6 from "react";
142
142
  import { Radio } from "antd";
143
143
  var RadioElement = (props) => {
144
144
  const handleChange = (e) => {
145
- if (props && props.onChange) {
146
- props.onChange(e.target.value);
145
+ if (props.onChange) {
146
+ const selectedVal = e.target.value;
147
+ const selectedOptions = [{ id: selectedVal, value: selectedVal }];
148
+ props.onChange(selectedOptions);
147
149
  }
148
150
  };
149
151
  return /* @__PURE__ */ React6.createElement(Radio.Group, { name: "radiogroup", defaultValue: 1 }, /* @__PURE__ */ React6.createElement(Radio, { value: 1, onChange: handleChange }, "A"), /* @__PURE__ */ React6.createElement(Radio, { value: 2, onChange: handleChange }, "B"), /* @__PURE__ */ React6.createElement(Radio, { value: 3, onChange: handleChange }, "C"), /* @__PURE__ */ React6.createElement(Radio, { value: 4, onChange: handleChange }, "D"));
@@ -161,7 +163,10 @@ var CheckboxElement = (props) => {
161
163
  const handleChange = (list) => {
162
164
  setCheckedList(list);
163
165
  if (props.onChange) {
164
- props.onChange(list);
166
+ const selectedOptions = list.map((value) => {
167
+ return { id: list.indexOf(value), value };
168
+ });
169
+ props.onChange(selectedOptions);
165
170
  }
166
171
  };
167
172
  const onHandleAllChanges = (e) => {
@@ -256,9 +261,11 @@ var onSearch = (value) => {
256
261
  };
257
262
  var filterOption = (input, option) => (option?.label ?? "").toLowerCase().includes(input.toLowerCase());
258
263
  var SingleSelectElement = (props) => {
259
- const handleChange = (value) => {
264
+ const handleChange = (values) => {
260
265
  if (props.onChange) {
261
- props.onChange(value);
266
+ const option = props.dropDownOptions.find((option2) => String(option2.title) === values);
267
+ const selectedOption = { id: option?.id, value: values };
268
+ props.onChange([selectedOption]);
262
269
  }
263
270
  };
264
271
  return /* @__PURE__ */ React9.createElement(
@@ -270,7 +277,7 @@ var SingleSelectElement = (props) => {
270
277
  onChange: handleChange,
271
278
  onSearch,
272
279
  filterOption,
273
- options: props.dropDownOptions?.map((eachOption) => ({ label: String(eachOption.title), value: String(eachOption.title) }))
280
+ options: props.dropDownOptions?.map((eachOption) => ({ label: String(eachOption.title), value: String(eachOption.title), id: String(eachOption.id) }))
274
281
  }
275
282
  );
276
283
  };
@@ -279,15 +286,13 @@ var SingleSelectElement = (props) => {
279
286
  import React10 from "react";
280
287
  import { Select as Select3 } from "antd";
281
288
  var MultipleSelectElement = (props) => {
282
- const handleChange = (selectedValues) => {
283
- console.log("==========", selectedValues);
284
- const transformedValues = selectedValues.map((option) => ({
285
- id: option.id,
286
- value: option.title
287
- }));
289
+ const handleChange = (values) => {
288
290
  if (props.onChange) {
289
- console.log(transformedValues);
290
- props.onChange(transformedValues);
291
+ const selectedOptions = values.map((value) => {
292
+ const option = props.dropDownOptions.find((option2) => String(option2.title) === value);
293
+ return { id: option?.id, value };
294
+ });
295
+ props.onChange(selectedOptions);
291
296
  }
292
297
  };
293
298
  return /* @__PURE__ */ React10.createElement(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.9-Beta4",
3
+ "version": "0.0.9-Beta6",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",