@apexcura/ui-components 0.0.14-Beta153 → 0.0.14-Beta155

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
@@ -730,10 +730,23 @@ var ModelElement = (props) => {
730
730
  };
731
731
 
732
732
  // src/Components/TableElement.tsx
733
+ var import_icons4 = require("@ant-design/icons");
733
734
  var TableElement = (props) => {
734
735
  const { thead, tbody } = props;
735
736
  const [selectedRecord, setSelectedRecord] = (0, import_react20.useState)({});
736
737
  const [model, setModel] = (0, import_react20.useState)(false);
738
+ const [dataSource, setDataSource] = (0, import_react20.useState)([]);
739
+ (0, import_react20.useEffect)(() => {
740
+ if (tbody) {
741
+ setDataSource(
742
+ tbody.map((row, index) => ({
743
+ ...row,
744
+ key: index,
745
+ index: index + 1
746
+ }))
747
+ );
748
+ }
749
+ }, [tbody]);
737
750
  const handleChange = (record) => {
738
751
  console.log("record", record);
739
752
  if (props.onChange) {
@@ -745,8 +758,8 @@ var TableElement = (props) => {
745
758
  columns = [
746
759
  {
747
760
  title: "#",
748
- dataIndex: "#",
749
- key: "#",
761
+ dataIndex: "index",
762
+ key: "index",
750
763
  fixed: "left"
751
764
  },
752
765
  ...thead.map((col, ind) => ({
@@ -757,9 +770,9 @@ var TableElement = (props) => {
757
770
  render: col.render,
758
771
  sorter: {
759
772
  compare: (a, b) => {
760
- if (typeof a[col.key] === "number" && typeof a[col.key] === "number") {
773
+ if (typeof a[col.key] === "number" && typeof b[col.key] === "number") {
761
774
  return a[col.key] - b[col.key];
762
- } else if (typeof a[col.key] === "string" && typeof a[col.key] === "string") {
775
+ } else if (typeof a[col.key] === "string" && typeof b[col.key] === "string") {
763
776
  return a[col.key].localeCompare(b[col.key]);
764
777
  }
765
778
  }
@@ -783,17 +796,21 @@ var TableElement = (props) => {
783
796
  }
784
797
  }
785
798
  },
786
- "View"
799
+ /* @__PURE__ */ import_react20.default.createElement(import_icons4.EyeOutlined, null)
787
800
  );
788
801
  }
789
802
  });
790
803
  }
791
804
  }
792
- const dataSource = tbody && tbody.map((row, index) => ({
793
- ...row,
794
- key: index + 1,
795
- [columns[0].key]: index + 1
796
- }));
805
+ const onChangeTable = (pagination, filters, sorter) => {
806
+ const { currentDataSource } = sorter;
807
+ setDataSource(
808
+ currentDataSource.map((row, index) => ({
809
+ ...row,
810
+ index: index + 1
811
+ }))
812
+ );
813
+ };
797
814
  const count = dataSource ? dataSource.length : 0;
798
815
  const onChangePage = (page, pageSize) => {
799
816
  if (props.onChange) {
@@ -822,9 +839,19 @@ var TableElement = (props) => {
822
839
  dataSource,
823
840
  columns,
824
841
  size: props.size,
825
- bordered: true
842
+ bordered: true,
843
+ onChange: onChangeTable
844
+ }
845
+ ), model && /* @__PURE__ */ import_react20.default.createElement(
846
+ ModelElement,
847
+ {
848
+ selectedRecord,
849
+ ...props,
850
+ columns,
851
+ model,
852
+ onCancel: () => setModel(false)
826
853
  }
827
- ), model && /* @__PURE__ */ import_react20.default.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
854
+ ));
828
855
  };
829
856
 
830
857
  // src/Components/DatePicker.tsx
@@ -958,7 +985,7 @@ var DropDownGroup = (props) => {
958
985
  // src/Components/FilesUpload.tsx
959
986
  var import_react26 = __toESM(require("react"));
960
987
  var import_antd19 = require("antd");
961
- var import_icons4 = require("@ant-design/icons");
988
+ var import_icons5 = require("@ant-design/icons");
962
989
  var FileUpload = (props) => {
963
990
  const { Dragger } = import_antd19.Upload;
964
991
  const [files, setFiles] = (0, import_react26.useState)([]);
@@ -989,7 +1016,7 @@ var FileUpload = (props) => {
989
1016
  showUploadList: true,
990
1017
  customRequest
991
1018
  },
992
- /* @__PURE__ */ import_react26.default.createElement("p", null, /* @__PURE__ */ import_react26.default.createElement(import_icons4.InboxOutlined, null)),
1019
+ /* @__PURE__ */ import_react26.default.createElement("p", null, /* @__PURE__ */ import_react26.default.createElement(import_icons5.InboxOutlined, null)),
993
1020
  /* @__PURE__ */ import_react26.default.createElement("p", null, "Click or drag file to upload")
994
1021
  ));
995
1022
  };
package/dist/index.mjs CHANGED
@@ -608,7 +608,7 @@ var Navbar = (props) => {
608
608
  };
609
609
 
610
610
  // src/Components/TableElement.tsx
611
- import React20, { useState as useState6 } from "react";
611
+ import React20, { useState as useState6, useEffect as useEffect3 } from "react";
612
612
  import { Table as Table2 } from "antd";
613
613
 
614
614
  // src/Components/Model.tsx
@@ -664,10 +664,23 @@ var ModelElement = (props) => {
664
664
  };
665
665
 
666
666
  // src/Components/TableElement.tsx
667
+ import { EyeOutlined } from "@ant-design/icons";
667
668
  var TableElement = (props) => {
668
669
  const { thead, tbody } = props;
669
670
  const [selectedRecord, setSelectedRecord] = useState6({});
670
671
  const [model, setModel] = useState6(false);
672
+ const [dataSource, setDataSource] = useState6([]);
673
+ useEffect3(() => {
674
+ if (tbody) {
675
+ setDataSource(
676
+ tbody.map((row, index) => ({
677
+ ...row,
678
+ key: index,
679
+ index: index + 1
680
+ }))
681
+ );
682
+ }
683
+ }, [tbody]);
671
684
  const handleChange = (record) => {
672
685
  console.log("record", record);
673
686
  if (props.onChange) {
@@ -679,8 +692,8 @@ var TableElement = (props) => {
679
692
  columns = [
680
693
  {
681
694
  title: "#",
682
- dataIndex: "#",
683
- key: "#",
695
+ dataIndex: "index",
696
+ key: "index",
684
697
  fixed: "left"
685
698
  },
686
699
  ...thead.map((col, ind) => ({
@@ -691,9 +704,9 @@ var TableElement = (props) => {
691
704
  render: col.render,
692
705
  sorter: {
693
706
  compare: (a, b) => {
694
- if (typeof a[col.key] === "number" && typeof a[col.key] === "number") {
707
+ if (typeof a[col.key] === "number" && typeof b[col.key] === "number") {
695
708
  return a[col.key] - b[col.key];
696
- } else if (typeof a[col.key] === "string" && typeof a[col.key] === "string") {
709
+ } else if (typeof a[col.key] === "string" && typeof b[col.key] === "string") {
697
710
  return a[col.key].localeCompare(b[col.key]);
698
711
  }
699
712
  }
@@ -717,17 +730,21 @@ var TableElement = (props) => {
717
730
  }
718
731
  }
719
732
  },
720
- "View"
733
+ /* @__PURE__ */ React20.createElement(EyeOutlined, null)
721
734
  );
722
735
  }
723
736
  });
724
737
  }
725
738
  }
726
- const dataSource = tbody && tbody.map((row, index) => ({
727
- ...row,
728
- key: index + 1,
729
- [columns[0].key]: index + 1
730
- }));
739
+ const onChangeTable = (pagination, filters, sorter) => {
740
+ const { currentDataSource } = sorter;
741
+ setDataSource(
742
+ currentDataSource.map((row, index) => ({
743
+ ...row,
744
+ index: index + 1
745
+ }))
746
+ );
747
+ };
731
748
  const count = dataSource ? dataSource.length : 0;
732
749
  const onChangePage = (page, pageSize) => {
733
750
  if (props.onChange) {
@@ -756,9 +773,19 @@ var TableElement = (props) => {
756
773
  dataSource,
757
774
  columns,
758
775
  size: props.size,
759
- bordered: true
776
+ bordered: true,
777
+ onChange: onChangeTable
760
778
  }
761
- ), model && /* @__PURE__ */ React20.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
779
+ ), model && /* @__PURE__ */ React20.createElement(
780
+ ModelElement,
781
+ {
782
+ selectedRecord,
783
+ ...props,
784
+ columns,
785
+ model,
786
+ onCancel: () => setModel(false)
787
+ }
788
+ ));
762
789
  };
763
790
 
764
791
  // src/Components/DatePicker.tsx
@@ -977,7 +1004,7 @@ var Upload2 = (props) => {
977
1004
  };
978
1005
 
979
1006
  // src/Components/OtpElement.tsx
980
- import React30, { useState as useState11, useRef, useEffect as useEffect3 } from "react";
1007
+ import React30, { useState as useState11, useRef, useEffect as useEffect4 } from "react";
981
1008
  import { Input as Input3 } from "antd";
982
1009
  var OtpElement = (props) => {
983
1010
  const length = props.length;
@@ -1014,7 +1041,7 @@ var OtpElement = (props) => {
1014
1041
  });
1015
1042
  }
1016
1043
  };
1017
- useEffect3(() => {
1044
+ useEffect4(() => {
1018
1045
  inputRefs.current[0]?.focus();
1019
1046
  }, []);
1020
1047
  return /* @__PURE__ */ React30.createElement("div", { className: props.containerClassName }, Array.from({ length }).map((_, index) => /* @__PURE__ */ React30.createElement(
@@ -1266,7 +1293,7 @@ var HorizontalBarChart = (props) => {
1266
1293
  };
1267
1294
 
1268
1295
  // src/Components/LineChart.tsx
1269
- import React34, { useEffect as useEffect4, useRef as useRef2 } from "react";
1296
+ import React34, { useEffect as useEffect5, useRef as useRef2 } from "react";
1270
1297
  import Chart from "chart.js/auto";
1271
1298
  var LineChart = (props) => {
1272
1299
  const chartRef = useRef2(null);
@@ -1277,7 +1304,7 @@ var LineChart = (props) => {
1277
1304
  { label: "Conversion Rate", data: [50, 100, 150, 180, 50] }
1278
1305
  ];
1279
1306
  const labels = ["Instagram", "Whatsapp", "Messages", "Telegram", "Linkedin"];
1280
- useEffect4(() => {
1307
+ useEffect5(() => {
1281
1308
  if (chartRef.current) {
1282
1309
  if (chartInstance.current) {
1283
1310
  chartInstance.current.destroy();
@@ -1339,12 +1366,12 @@ var LineChart = (props) => {
1339
1366
  };
1340
1367
 
1341
1368
  // src/Components/DoubleBarChart.tsx
1342
- import React35, { useEffect as useEffect5, useRef as useRef3 } from "react";
1369
+ import React35, { useEffect as useEffect6, useRef as useRef3 } from "react";
1343
1370
  import Chart2 from "chart.js/auto";
1344
1371
  var DoubleBarChart = (props) => {
1345
1372
  const chartRef = useRef3(null);
1346
1373
  const chartInstance = useRef3(null);
1347
- useEffect5(() => {
1374
+ useEffect6(() => {
1348
1375
  if (chartRef.current) {
1349
1376
  if (chartInstance.current) {
1350
1377
  chartInstance.current.destroy();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.14-Beta153",
3
+ "version": "0.0.14-Beta155",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",