@apexcura/ui-components 0.0.11-Beta3 → 0.0.11-Beta5

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.js CHANGED
@@ -363,19 +363,36 @@ var import_react13 = __toESM(require("react"));
363
363
  var import_antd11 = require("antd");
364
364
  var AddMoreTable = (props) => {
365
365
  const { thead, tbody } = props;
366
+ const [tableData, setTableData] = (0, import_react13.useState)({});
367
+ const onHandleChange = (name, value) => {
368
+ setTableData((prev) => ({ ...prev, [name]: value }));
369
+ console.log(tableData);
370
+ };
366
371
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
367
372
  title: eachHeadEl.label,
368
373
  dataIndex: eachHeadEl.name,
369
374
  key: eachHeadEl.id
370
375
  })) : [];
376
+ const renderInputElement = (element) => {
377
+ const { type, label } = element;
378
+ if (type === "single-select") {
379
+ return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
380
+ } else if (type === "textarea") {
381
+ return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
382
+ } else {
383
+ return null;
384
+ }
385
+ };
371
386
  const dataSource = tbody && tbody.length > 0 ? tbody.map((eachRow, index) => {
372
- const variableData = eachRow.variable_data.reduce;
373
387
  console.log("eachRow---------", eachRow);
374
- console.log("VariableData", { ...variableData });
388
+ const variableData = eachRow.variable_data.reduce((acc, curr) => {
389
+ acc[curr.label] = renderInputElement(curr);
390
+ return acc;
391
+ }, {});
375
392
  return {
376
393
  key: index.toString(),
377
- ...variableData,
378
- ...eachRow
394
+ ...eachRow,
395
+ ...variableData
379
396
  };
380
397
  }) : [];
381
398
  return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
package/dist/index.mjs CHANGED
@@ -312,23 +312,40 @@ import { Button as Button2, Flex as Flex2 } from "antd";
312
312
  var ButtonElement = () => /* @__PURE__ */ React11.createElement(Flex2, { gap: "small" }, /* @__PURE__ */ React11.createElement(Button2, { type: "primary" }, "Primary Button"));
313
313
 
314
314
  // src/Components/AddMoreTable.tsx
315
- import React12 from "react";
315
+ import React12, { useState as useState3 } from "react";
316
316
  import { Table } from "antd";
317
317
  var AddMoreTable = (props) => {
318
318
  const { thead, tbody } = props;
319
+ const [tableData, setTableData] = useState3({});
320
+ const onHandleChange = (name, value) => {
321
+ setTableData((prev) => ({ ...prev, [name]: value }));
322
+ console.log(tableData);
323
+ };
319
324
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
320
325
  title: eachHeadEl.label,
321
326
  dataIndex: eachHeadEl.name,
322
327
  key: eachHeadEl.id
323
328
  })) : [];
329
+ const renderInputElement = (element) => {
330
+ const { type, label } = element;
331
+ if (type === "single-select") {
332
+ return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
333
+ } else if (type === "textarea") {
334
+ return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
335
+ } else {
336
+ return null;
337
+ }
338
+ };
324
339
  const dataSource = tbody && tbody.length > 0 ? tbody.map((eachRow, index) => {
325
- const variableData = eachRow.variable_data.reduce;
326
340
  console.log("eachRow---------", eachRow);
327
- console.log("VariableData", { ...variableData });
341
+ const variableData = eachRow.variable_data.reduce((acc, curr) => {
342
+ acc[curr.label] = renderInputElement(curr);
343
+ return acc;
344
+ }, {});
328
345
  return {
329
346
  key: index.toString(),
330
- ...variableData,
331
- ...eachRow
347
+ ...eachRow,
348
+ ...variableData
332
349
  };
333
350
  }) : [];
334
351
  return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta3",
3
+ "version": "0.0.11-Beta5",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",