@apexcura/ui-components 0.0.11-Beta1 → 0.0.11-Beta11

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
@@ -22,6 +22,7 @@ type ElementType = {
22
22
  id?: number;
23
23
  thead?: any[];
24
24
  tbody?: any[];
25
+ variable_data?: any[];
25
26
  };
26
27
 
27
28
  interface ElementExecuterProps$3 extends ElementType {
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ type ElementType = {
22
22
  id?: number;
23
23
  thead?: any[];
24
24
  tbody?: any[];
25
+ variable_data?: any[];
25
26
  };
26
27
 
27
28
  interface ElementExecuterProps$3 extends ElementType {
package/dist/index.js CHANGED
@@ -363,24 +363,38 @@ 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 { element: 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
  const variableData = eachRow.variable_data.reduce((acc, curr) => {
373
- acc[curr.label] = curr.element;
388
+ acc[curr.label] = renderInputElement(curr);
374
389
  return acc;
375
390
  }, {});
376
391
  return {
377
392
  key: index.toString(),
378
- ...variableData,
379
- ...eachRow
393
+ ...eachRow,
394
+ ...variableData
380
395
  };
381
- console.log("eachRow---------", eachRow);
382
- console.log("VariableData", { ...variableData });
383
396
  }) : [];
397
+ console.log("dataSource.........", dataSource);
384
398
  return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
385
399
  import_antd11.Table,
386
400
  {
package/dist/index.mjs CHANGED
@@ -312,28 +312,42 @@ 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 { element: 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
  const variableData = eachRow.variable_data.reduce((acc, curr) => {
326
- acc[curr.label] = curr.element;
341
+ acc[curr.label] = renderInputElement(curr);
327
342
  return acc;
328
343
  }, {});
329
344
  return {
330
345
  key: index.toString(),
331
- ...variableData,
332
- ...eachRow
346
+ ...eachRow,
347
+ ...variableData
333
348
  };
334
- console.log("eachRow---------", eachRow);
335
- console.log("VariableData", { ...variableData });
336
349
  }) : [];
350
+ console.log("dataSource.........", dataSource);
337
351
  return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
338
352
  Table,
339
353
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta1",
3
+ "version": "0.0.11-Beta11",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",