@apexcura/ui-components 0.0.11-Beta4 → 0.0.11-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.js CHANGED
@@ -363,18 +363,32 @@ 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
387
  console.log("eachRow---------", eachRow);
373
388
  const variableData = eachRow.variable_data.reduce((acc, curr) => {
374
- acc[curr.label] = curr.element;
389
+ acc[curr.label] = renderInputElement(curr);
375
390
  return acc;
376
391
  }, {});
377
- console.log("variableData", variableData);
378
392
  return {
379
393
  key: index.toString(),
380
394
  ...eachRow,
package/dist/index.mjs CHANGED
@@ -312,22 +312,36 @@ 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
340
  console.log("eachRow---------", eachRow);
326
341
  const variableData = eachRow.variable_data.reduce((acc, curr) => {
327
- acc[curr.label] = curr.element;
342
+ acc[curr.label] = renderInputElement(curr);
328
343
  return acc;
329
344
  }, {});
330
- console.log("variableData", variableData);
331
345
  return {
332
346
  key: index.toString(),
333
347
  ...eachRow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta4",
3
+ "version": "0.0.11-Beta6",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",