@apexcura/ui-components 0.0.14-Beta6 → 0.0.14-Beta61
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.css +3 -0
- package/dist/index.d.mts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +225 -93
- package/dist/index.mjs +233 -104
- package/package.json +1 -3
package/dist/index.css
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -26,8 +26,9 @@ type ElementType = {
|
|
|
26
26
|
fields?: any[];
|
|
27
27
|
schema?: any[];
|
|
28
28
|
options?: any[];
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
firstOptions?: any[];
|
|
30
|
+
secondOptions?: any[];
|
|
31
|
+
view?: boolean;
|
|
31
32
|
onChange?: (value: string | number | boolean | object | any[] | undefined) => void;
|
|
32
33
|
onClick?: () => void;
|
|
33
34
|
dropDownOptions?: any[];
|
|
@@ -59,6 +60,9 @@ type ElementType = {
|
|
|
59
60
|
containerClassName?: string;
|
|
60
61
|
selectBefore?: any[];
|
|
61
62
|
selectAfter?: any[];
|
|
63
|
+
isSVGStylesOverride?: boolean;
|
|
64
|
+
rowSelection?: string;
|
|
65
|
+
length?: number;
|
|
62
66
|
};
|
|
63
67
|
|
|
64
68
|
declare const TextElement: (props: ElementType) => React$1.JSX.Element;
|
|
@@ -84,7 +88,7 @@ declare const SingleSelectElement: (props: ElementType) => React$1.JSX.Element;
|
|
|
84
88
|
|
|
85
89
|
declare const MultipleSelectElement: (props: ElementType) => React$1.JSX.Element;
|
|
86
90
|
|
|
87
|
-
declare const ButtonElement: React$1.
|
|
91
|
+
declare const ButtonElement: (props: ElementType) => React$1.JSX.Element;
|
|
88
92
|
|
|
89
93
|
declare const AddMoreTable: (props: ElementType) => React$1.JSX.Element;
|
|
90
94
|
|
|
@@ -108,4 +112,10 @@ declare const FileUpload: (props: ElementType) => React$1.JSX.Element;
|
|
|
108
112
|
|
|
109
113
|
declare const TabsElement: (props: ElementType) => React$1.JSX.Element;
|
|
110
114
|
|
|
111
|
-
|
|
115
|
+
declare const SwitchElement: () => React$1.JSX.Element;
|
|
116
|
+
|
|
117
|
+
declare const Upload: (props: ElementType) => React$1.JSX.Element;
|
|
118
|
+
|
|
119
|
+
declare const OtpElement: (props: ElementType) => React$1.JSX.Element;
|
|
120
|
+
|
|
121
|
+
export { AddMoreTable, ButtonElement, CheckboxElement, CkEditor, DatePickerElement, DateRangePickerElement, DropDownGroup, FileUpload, Image, MultipleSelectElement, Navbar, NumberElement, OtpElement, PasswordElement, RadioElement, SelectElement, Sidebar, SingleCheckbox, SingleSelectElement, SwitchElement, TableElement, TabsElement, TextElement, TextareaElement, Upload };
|
package/dist/index.d.ts
CHANGED
|
@@ -26,8 +26,9 @@ type ElementType = {
|
|
|
26
26
|
fields?: any[];
|
|
27
27
|
schema?: any[];
|
|
28
28
|
options?: any[];
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
firstOptions?: any[];
|
|
30
|
+
secondOptions?: any[];
|
|
31
|
+
view?: boolean;
|
|
31
32
|
onChange?: (value: string | number | boolean | object | any[] | undefined) => void;
|
|
32
33
|
onClick?: () => void;
|
|
33
34
|
dropDownOptions?: any[];
|
|
@@ -59,6 +60,9 @@ type ElementType = {
|
|
|
59
60
|
containerClassName?: string;
|
|
60
61
|
selectBefore?: any[];
|
|
61
62
|
selectAfter?: any[];
|
|
63
|
+
isSVGStylesOverride?: boolean;
|
|
64
|
+
rowSelection?: string;
|
|
65
|
+
length?: number;
|
|
62
66
|
};
|
|
63
67
|
|
|
64
68
|
declare const TextElement: (props: ElementType) => React$1.JSX.Element;
|
|
@@ -84,7 +88,7 @@ declare const SingleSelectElement: (props: ElementType) => React$1.JSX.Element;
|
|
|
84
88
|
|
|
85
89
|
declare const MultipleSelectElement: (props: ElementType) => React$1.JSX.Element;
|
|
86
90
|
|
|
87
|
-
declare const ButtonElement: React$1.
|
|
91
|
+
declare const ButtonElement: (props: ElementType) => React$1.JSX.Element;
|
|
88
92
|
|
|
89
93
|
declare const AddMoreTable: (props: ElementType) => React$1.JSX.Element;
|
|
90
94
|
|
|
@@ -108,4 +112,10 @@ declare const FileUpload: (props: ElementType) => React$1.JSX.Element;
|
|
|
108
112
|
|
|
109
113
|
declare const TabsElement: (props: ElementType) => React$1.JSX.Element;
|
|
110
114
|
|
|
111
|
-
|
|
115
|
+
declare const SwitchElement: () => React$1.JSX.Element;
|
|
116
|
+
|
|
117
|
+
declare const Upload: (props: ElementType) => React$1.JSX.Element;
|
|
118
|
+
|
|
119
|
+
declare const OtpElement: (props: ElementType) => React$1.JSX.Element;
|
|
120
|
+
|
|
121
|
+
export { AddMoreTable, ButtonElement, CheckboxElement, CkEditor, DatePickerElement, DateRangePickerElement, DropDownGroup, FileUpload, Image, MultipleSelectElement, Navbar, NumberElement, OtpElement, PasswordElement, RadioElement, SelectElement, Sidebar, SingleCheckbox, SingleSelectElement, SwitchElement, TableElement, TabsElement, TextElement, TextareaElement, Upload };
|
package/dist/index.js
CHANGED
|
@@ -42,16 +42,19 @@ __export(src_exports, {
|
|
|
42
42
|
MultipleSelectElement: () => MultipleSelectElement,
|
|
43
43
|
Navbar: () => Navbar,
|
|
44
44
|
NumberElement: () => NumberElement,
|
|
45
|
+
OtpElement: () => OtpElement,
|
|
45
46
|
PasswordElement: () => PasswordElement,
|
|
46
47
|
RadioElement: () => RadioElement,
|
|
47
48
|
SelectElement: () => SelectElement,
|
|
48
49
|
Sidebar: () => Sidebar,
|
|
49
50
|
SingleCheckbox: () => SingleCheckbox,
|
|
50
51
|
SingleSelectElement: () => SingleSelectElement,
|
|
52
|
+
SwitchElement: () => SwitchElement,
|
|
51
53
|
TableElement: () => TableElement,
|
|
52
54
|
TabsElement: () => TabsElement,
|
|
53
55
|
TextElement: () => TextElement,
|
|
54
|
-
TextareaElement: () => TextareaElement
|
|
56
|
+
TextareaElement: () => TextareaElement,
|
|
57
|
+
Upload: () => Upload2
|
|
55
58
|
});
|
|
56
59
|
module.exports = __toCommonJS(src_exports);
|
|
57
60
|
|
|
@@ -70,6 +73,7 @@ var TextElement = (props) => {
|
|
|
70
73
|
placeholder: props.placeholder,
|
|
71
74
|
allowClear: true,
|
|
72
75
|
id: props.name,
|
|
76
|
+
value: props.value,
|
|
73
77
|
prefix: props.prefix,
|
|
74
78
|
type: props.type,
|
|
75
79
|
status: props.status,
|
|
@@ -129,8 +133,7 @@ var NumberElement = (props) => {
|
|
|
129
133
|
{
|
|
130
134
|
placeholder: props.placeholder,
|
|
131
135
|
addonBefore: props.addonBefore,
|
|
132
|
-
|
|
133
|
-
defaultValue: props.defaultValue,
|
|
136
|
+
value: props.value,
|
|
134
137
|
disabled: props.disabled,
|
|
135
138
|
id: props.name,
|
|
136
139
|
prefix: props.prefix,
|
|
@@ -375,13 +378,74 @@ var MultipleSelectElement = (props) => {
|
|
|
375
378
|
// src/Components/Button.tsx
|
|
376
379
|
var import_react11 = __toESM(require("react"));
|
|
377
380
|
var ButtonElement = (props) => {
|
|
381
|
+
const [svgContent, setSvgContent] = (0, import_react11.useState)(null);
|
|
382
|
+
const [originalSvgContent, setOriginalSvgContent] = (0, import_react11.useState)(null);
|
|
383
|
+
const [hoverColor, setHoverColor] = (0, import_react11.useState)(null);
|
|
384
|
+
(0, import_react11.useEffect)(() => {
|
|
385
|
+
if (props.icon) {
|
|
386
|
+
fetch(props.icon).then((response) => response.text()).then((data) => {
|
|
387
|
+
const tempDiv = document.createElement("div");
|
|
388
|
+
tempDiv.innerHTML = data;
|
|
389
|
+
const svgElement = tempDiv.querySelector("svg");
|
|
390
|
+
if (svgElement) {
|
|
391
|
+
const textColorClass = props.className?.match(/text-[\w-]+/g)?.[0];
|
|
392
|
+
const hoverColorClass = props.className?.match(/hover:text-[\w-]+/g)?.[0];
|
|
393
|
+
if (textColorClass) {
|
|
394
|
+
const tempSpan = document.createElement("span");
|
|
395
|
+
tempSpan.className = textColorClass;
|
|
396
|
+
document.body.appendChild(tempSpan);
|
|
397
|
+
const computedColor = getComputedStyle(tempSpan).color;
|
|
398
|
+
document.body.removeChild(tempSpan);
|
|
399
|
+
const paths = svgElement.querySelectorAll("path");
|
|
400
|
+
paths.forEach((path) => path.setAttribute("fill", computedColor));
|
|
401
|
+
}
|
|
402
|
+
if (hoverColorClass) {
|
|
403
|
+
const tempSpan = document.createElement("span");
|
|
404
|
+
tempSpan.className = hoverColorClass.replace("hover:", "");
|
|
405
|
+
document.body.appendChild(tempSpan);
|
|
406
|
+
const computedHoverColor = getComputedStyle(tempSpan).color;
|
|
407
|
+
document.body.removeChild(tempSpan);
|
|
408
|
+
setHoverColor(computedHoverColor);
|
|
409
|
+
}
|
|
410
|
+
svgElement.setAttribute(
|
|
411
|
+
"class",
|
|
412
|
+
`${props.iconsClassName ? props.iconsClassName : ""}`
|
|
413
|
+
);
|
|
414
|
+
setSvgContent(tempDiv.innerHTML);
|
|
415
|
+
setOriginalSvgContent(tempDiv.innerHTML);
|
|
416
|
+
}
|
|
417
|
+
}).catch((error) => console.error("Error fetching SVG:", error));
|
|
418
|
+
}
|
|
419
|
+
}, [props.icon, props.className]);
|
|
420
|
+
const handleMouseEnter = () => {
|
|
421
|
+
if (hoverColor && originalSvgContent) {
|
|
422
|
+
const tempDiv = document.createElement("div");
|
|
423
|
+
tempDiv.innerHTML = originalSvgContent;
|
|
424
|
+
const svgElement = tempDiv.querySelector("svg");
|
|
425
|
+
const paths = svgElement?.querySelectorAll("path");
|
|
426
|
+
paths?.forEach((path) => path.setAttribute("fill", hoverColor));
|
|
427
|
+
setSvgContent(tempDiv.innerHTML);
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
const handleMouseLeave = () => {
|
|
431
|
+
if (originalSvgContent) {
|
|
432
|
+
setSvgContent(originalSvgContent);
|
|
433
|
+
}
|
|
434
|
+
};
|
|
378
435
|
return /* @__PURE__ */ import_react11.default.createElement(
|
|
379
436
|
"button",
|
|
380
437
|
{
|
|
381
|
-
onClick:
|
|
382
|
-
className: `${props.className ? props.className : ""}
|
|
438
|
+
onClick: props.onClick,
|
|
439
|
+
className: `${props.className ? props.className : ""}`,
|
|
440
|
+
onMouseEnter: handleMouseEnter,
|
|
441
|
+
onMouseLeave: handleMouseLeave
|
|
383
442
|
},
|
|
384
|
-
props.
|
|
443
|
+
props.isSVGStylesOverride ? svgContent && /* @__PURE__ */ import_react11.default.createElement(
|
|
444
|
+
"span",
|
|
445
|
+
{
|
|
446
|
+
dangerouslySetInnerHTML: { __html: svgContent }
|
|
447
|
+
}
|
|
448
|
+
) : props.icon && /* @__PURE__ */ import_react11.default.createElement("img", { className: props.iconsClassName, src: props.icon, alt: props.label }),
|
|
385
449
|
props.label
|
|
386
450
|
);
|
|
387
451
|
};
|
|
@@ -464,9 +528,9 @@ var AddMoreTable = (props) => {
|
|
|
464
528
|
if (!element) return null;
|
|
465
529
|
const { element: type, label } = element;
|
|
466
530
|
if (type === "single-select") {
|
|
467
|
-
return /* @__PURE__ */ import_react12.default.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [] });
|
|
531
|
+
return /* @__PURE__ */ import_react12.default.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [], firstOptions: [], secondOptions: [] });
|
|
468
532
|
} else if (type === "textarea") {
|
|
469
|
-
return /* @__PURE__ */ import_react12.default.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [] });
|
|
533
|
+
return /* @__PURE__ */ import_react12.default.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [], firstOptions: [], secondOptions: [] });
|
|
470
534
|
} else {
|
|
471
535
|
return null;
|
|
472
536
|
}
|
|
@@ -652,7 +716,6 @@ var TableElement = (props) => {
|
|
|
652
716
|
const { thead, tbody } = props;
|
|
653
717
|
const [selectedRecord, setSelectedRecord] = (0, import_react20.useState)({});
|
|
654
718
|
const [model, setModel] = (0, import_react20.useState)(false);
|
|
655
|
-
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react20.useState)([]);
|
|
656
719
|
const handleChange = (record) => {
|
|
657
720
|
console.log("record", record);
|
|
658
721
|
if (props.onChange) {
|
|
@@ -667,12 +730,6 @@ var TableElement = (props) => {
|
|
|
667
730
|
dataIndex: "#",
|
|
668
731
|
key: "#"
|
|
669
732
|
},
|
|
670
|
-
{
|
|
671
|
-
title: "View",
|
|
672
|
-
dataIndex: "View",
|
|
673
|
-
key: "View",
|
|
674
|
-
render: (_, record) => /* @__PURE__ */ import_react20.default.createElement(import_antd14.Button, null, "View")
|
|
675
|
-
},
|
|
676
733
|
...thead.map((col, ind) => ({
|
|
677
734
|
title: col.label,
|
|
678
735
|
dataIndex: col.name,
|
|
@@ -689,6 +746,24 @@ var TableElement = (props) => {
|
|
|
689
746
|
}
|
|
690
747
|
}))
|
|
691
748
|
];
|
|
749
|
+
if (props.view) {
|
|
750
|
+
columns.push({
|
|
751
|
+
title: "View",
|
|
752
|
+
dataIndex: "View",
|
|
753
|
+
key: "View",
|
|
754
|
+
render: (_, record) => /* @__PURE__ */ import_react20.default.createElement(
|
|
755
|
+
"a",
|
|
756
|
+
{
|
|
757
|
+
onClick: () => {
|
|
758
|
+
setSelectedRecord(record);
|
|
759
|
+
handleChange(record);
|
|
760
|
+
setModel(true);
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
"View"
|
|
764
|
+
)
|
|
765
|
+
});
|
|
766
|
+
}
|
|
692
767
|
}
|
|
693
768
|
const dataSource = tbody && tbody.map((row, index) => ({
|
|
694
769
|
...row,
|
|
@@ -700,13 +775,10 @@ var TableElement = (props) => {
|
|
|
700
775
|
props.onChange({ name: "pagination", page, pageSize });
|
|
701
776
|
}
|
|
702
777
|
};
|
|
703
|
-
const onSelectChange = (newSelectedRowKeys) => {
|
|
704
|
-
console.log("selectedRowKeys changed: ", newSelectedRowKeys);
|
|
705
|
-
setSelectedRowKeys(newSelectedRowKeys);
|
|
706
|
-
};
|
|
707
778
|
const rowSelectionConfig = props.rowSelection ? {
|
|
708
|
-
selectedRowKeys,
|
|
709
|
-
|
|
779
|
+
onChange: (selectedRowKeys, selectedRows) => {
|
|
780
|
+
console.log(`selectedRowKeys: ${selectedRowKeys}`, "selectedRows: ", selectedRows);
|
|
781
|
+
}
|
|
710
782
|
} : void 0;
|
|
711
783
|
return /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
712
784
|
import_antd14.Table,
|
|
@@ -717,21 +789,10 @@ var TableElement = (props) => {
|
|
|
717
789
|
showSizeChanger: count > 10,
|
|
718
790
|
onChange: onChangePage
|
|
719
791
|
},
|
|
792
|
+
rowSelection: rowSelectionConfig,
|
|
720
793
|
dataSource,
|
|
721
794
|
columns,
|
|
722
|
-
bordered: true
|
|
723
|
-
rowSelection: rowSelectionConfig,
|
|
724
|
-
size: props.size && props.size,
|
|
725
|
-
onRow: (record) => {
|
|
726
|
-
return {
|
|
727
|
-
onClick: () => {
|
|
728
|
-
setSelectedRecord(record);
|
|
729
|
-
handleChange(record);
|
|
730
|
-
setModel(true);
|
|
731
|
-
},
|
|
732
|
-
style: { cursor: "pointer" }
|
|
733
|
-
};
|
|
734
|
-
}
|
|
795
|
+
bordered: true
|
|
735
796
|
}
|
|
736
797
|
), model && /* @__PURE__ */ import_react20.default.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
|
|
737
798
|
};
|
|
@@ -739,59 +800,40 @@ var TableElement = (props) => {
|
|
|
739
800
|
// src/Components/DatePicker.tsx
|
|
740
801
|
var import_react21 = __toESM(require("react"));
|
|
741
802
|
var import_antd15 = require("antd");
|
|
742
|
-
var
|
|
743
|
-
var
|
|
803
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
804
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
|
|
805
|
+
import_dayjs.default.extend(import_customParseFormat.default);
|
|
744
806
|
var DatePickerElement = (props) => {
|
|
745
|
-
const [
|
|
746
|
-
const handleChange = (
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
const formattedDate = dateString;
|
|
751
|
-
console.log("formattedDate-----------------", formattedDate);
|
|
752
|
-
setDate(date2);
|
|
753
|
-
console.log("changedDate------------", date2);
|
|
807
|
+
const [dateState, setDateState] = (0, import_react21.useState)("");
|
|
808
|
+
const handleChange = (date, dateString) => {
|
|
809
|
+
if (date) {
|
|
810
|
+
const formattedDate = date;
|
|
811
|
+
setDateState(date);
|
|
754
812
|
if (props.onChange) {
|
|
755
813
|
props.onChange(formattedDate);
|
|
756
814
|
}
|
|
757
815
|
} else {
|
|
758
|
-
|
|
816
|
+
setDateState("");
|
|
759
817
|
if (props.onChange) {
|
|
760
818
|
props.onChange("");
|
|
761
819
|
}
|
|
762
820
|
}
|
|
763
821
|
};
|
|
764
|
-
|
|
765
|
-
const currentDate = date || (0, import_moment.default)();
|
|
766
|
-
const newDate = (0, import_moment.default)(currentDate).subtract(1, "days");
|
|
767
|
-
setDate(newDate);
|
|
768
|
-
if (props.onChange) {
|
|
769
|
-
props.onChange(newDate.format("lll"));
|
|
770
|
-
}
|
|
771
|
-
};
|
|
772
|
-
const onHandleIncrement = () => {
|
|
773
|
-
const currentDate = date || (0, import_moment.default)();
|
|
774
|
-
const newDate = (0, import_moment.default)(currentDate).add(1, "days");
|
|
775
|
-
setDate(newDate);
|
|
776
|
-
if (props.onChange) {
|
|
777
|
-
props.onChange(newDate.format("lll"));
|
|
778
|
-
}
|
|
779
|
-
};
|
|
780
|
-
return /* @__PURE__ */ import_react21.default.createElement("div", null, /* @__PURE__ */ import_react21.default.createElement("button", { onClick: onHandleDecrement }, /* @__PURE__ */ import_react21.default.createElement(import_icons4.LeftOutlined, null)), /* @__PURE__ */ import_react21.default.createElement(
|
|
822
|
+
return /* @__PURE__ */ import_react21.default.createElement("div", null, /* @__PURE__ */ import_react21.default.createElement(
|
|
781
823
|
import_antd15.DatePicker,
|
|
782
824
|
{
|
|
783
825
|
placeholder: props.placeholder,
|
|
784
|
-
value:
|
|
785
|
-
|
|
826
|
+
value: dateState,
|
|
827
|
+
format: { format: "DD-MM-YYYY" },
|
|
786
828
|
onChange: handleChange
|
|
787
829
|
}
|
|
788
|
-
)
|
|
830
|
+
));
|
|
789
831
|
};
|
|
790
832
|
|
|
791
833
|
// src/Components/DateRangePickerElement.tsx
|
|
792
834
|
var import_react22 = __toESM(require("react"));
|
|
793
835
|
var import_antd16 = require("antd");
|
|
794
|
-
var
|
|
836
|
+
var import_dayjs2 = __toESM(require("dayjs"));
|
|
795
837
|
var DateRangePickerElement = (props) => {
|
|
796
838
|
const { RangePicker } = import_antd16.DatePicker;
|
|
797
839
|
const handleChange = (dates, dateStrings) => {
|
|
@@ -802,10 +844,10 @@ var DateRangePickerElement = (props) => {
|
|
|
802
844
|
}
|
|
803
845
|
};
|
|
804
846
|
const rangePresets = [
|
|
805
|
-
{ label: "Last 7 Days", value: [(0,
|
|
806
|
-
{ label: "Last 14 Days", value: [(0,
|
|
807
|
-
{ label: "Last 30 Days", value: [(0,
|
|
808
|
-
{ label: "Last 90 Days", value: [(0,
|
|
847
|
+
{ label: "Last 7 Days", value: [(0, import_dayjs2.default)().add(-7, "d"), (0, import_dayjs2.default)()] },
|
|
848
|
+
{ label: "Last 14 Days", value: [(0, import_dayjs2.default)().add(-14, "d"), (0, import_dayjs2.default)()] },
|
|
849
|
+
{ label: "Last 30 Days", value: [(0, import_dayjs2.default)().add(-30, "d"), (0, import_dayjs2.default)()] },
|
|
850
|
+
{ label: "Last 90 Days", value: [(0, import_dayjs2.default)().add(-90, "d"), (0, import_dayjs2.default)()] }
|
|
809
851
|
];
|
|
810
852
|
return /* @__PURE__ */ import_react22.default.createElement(import_antd16.Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ import_react22.default.createElement(RangePicker, { presets: rangePresets, onChange: handleChange }));
|
|
811
853
|
};
|
|
@@ -813,7 +855,7 @@ var DateRangePickerElement = (props) => {
|
|
|
813
855
|
// src/Components/Image.tsx
|
|
814
856
|
var import_react23 = __toESM(require("react"));
|
|
815
857
|
var Image = (props) => {
|
|
816
|
-
return /* @__PURE__ */ import_react23.default.createElement("
|
|
858
|
+
return /* @__PURE__ */ import_react23.default.createElement("img", { className: props.className, src: props.img, alt: "image" });
|
|
817
859
|
};
|
|
818
860
|
|
|
819
861
|
// src/Components/SingleCheckbox.tsx
|
|
@@ -834,30 +876,34 @@ var import_antd18 = require("antd");
|
|
|
834
876
|
var DropDownGroup = (props) => {
|
|
835
877
|
const [selectedValue, setSelectedValue] = (0, import_react25.useState)({
|
|
836
878
|
firstValue: {},
|
|
837
|
-
secondValue: {}
|
|
879
|
+
secondValue: {},
|
|
880
|
+
temp: ""
|
|
838
881
|
});
|
|
839
882
|
const handleFirstChange = (value) => {
|
|
840
|
-
|
|
883
|
+
console.log(selectedValue.temp);
|
|
884
|
+
const filterOption2 = props.firstOptions?.find(
|
|
841
885
|
(eachOption) => eachOption.value === value
|
|
842
886
|
);
|
|
843
887
|
setSelectedValue((prev) => {
|
|
844
888
|
const newValue = { ...prev, firstValue: filterOption2 };
|
|
889
|
+
const { temp, ...rest } = newValue;
|
|
845
890
|
if (newValue.firstValue) {
|
|
846
|
-
props.onChange?.(
|
|
891
|
+
props.onChange?.(rest);
|
|
847
892
|
}
|
|
848
|
-
return
|
|
893
|
+
return newValue;
|
|
849
894
|
});
|
|
850
895
|
};
|
|
851
896
|
const handleSecondChange = (value) => {
|
|
852
|
-
const filterOption2 = props.
|
|
897
|
+
const filterOption2 = props.secondOptions?.find(
|
|
853
898
|
(eachOption) => eachOption.value === value
|
|
854
899
|
);
|
|
855
900
|
setSelectedValue((prev) => {
|
|
856
901
|
const newValue = { ...prev, secondValue: filterOption2 };
|
|
902
|
+
const { temp, ...rest } = newValue;
|
|
857
903
|
if (newValue.secondValue) {
|
|
858
|
-
props.onChange?.(
|
|
904
|
+
props.onChange?.(rest);
|
|
859
905
|
}
|
|
860
|
-
return
|
|
906
|
+
return newValue;
|
|
861
907
|
});
|
|
862
908
|
};
|
|
863
909
|
return /* @__PURE__ */ import_react25.default.createElement("div", { className: props.containerClassName }, props.label && /* @__PURE__ */ import_react25.default.createElement("label", { htmlFor: props.name, className: props.labelClassName }, props.label), /* @__PURE__ */ import_react25.default.createElement("div", { className: props.subContainerClassName }, /* @__PURE__ */ import_react25.default.createElement(
|
|
@@ -865,7 +911,7 @@ var DropDownGroup = (props) => {
|
|
|
865
911
|
{
|
|
866
912
|
onChange: handleFirstChange,
|
|
867
913
|
variant: props.variant,
|
|
868
|
-
options: props.
|
|
914
|
+
options: props.firstOptions,
|
|
869
915
|
className: props.className
|
|
870
916
|
}
|
|
871
917
|
), /* @__PURE__ */ import_react25.default.createElement("div", { style: { borderLeft: "1px solid gray", height: "33px" } }), /* @__PURE__ */ import_react25.default.createElement(
|
|
@@ -873,7 +919,7 @@ var DropDownGroup = (props) => {
|
|
|
873
919
|
{
|
|
874
920
|
onChange: handleSecondChange,
|
|
875
921
|
variant: props.variant,
|
|
876
|
-
options: props.
|
|
922
|
+
options: props.secondOptions,
|
|
877
923
|
className: props.className
|
|
878
924
|
}
|
|
879
925
|
)));
|
|
@@ -882,18 +928,10 @@ var DropDownGroup = (props) => {
|
|
|
882
928
|
// src/Components/FilesUpload.tsx
|
|
883
929
|
var import_react26 = __toESM(require("react"));
|
|
884
930
|
var import_antd19 = require("antd");
|
|
885
|
-
var
|
|
931
|
+
var import_icons4 = require("@ant-design/icons");
|
|
886
932
|
var FileUpload = (props) => {
|
|
887
933
|
const { Dragger } = import_antd19.Upload;
|
|
888
934
|
const [files, setFiles] = (0, import_react26.useState)([]);
|
|
889
|
-
const beforeUpload = (file) => {
|
|
890
|
-
const isCorrectFile = ["image/png", "image/jpg", "image/jpeg", "application/pdf"].includes(file.type);
|
|
891
|
-
if (!isCorrectFile) {
|
|
892
|
-
import_antd19.message.error(`(${file.name}) is an invalid file. Please upload files with the following extensions only (.png/.jpg/.jpeg/.pdf)`);
|
|
893
|
-
return import_antd19.Upload.LIST_IGNORE;
|
|
894
|
-
}
|
|
895
|
-
return true;
|
|
896
|
-
};
|
|
897
935
|
const handleChange = ({ fileList }) => {
|
|
898
936
|
setFiles(fileList);
|
|
899
937
|
if (props.onChange) {
|
|
@@ -917,12 +955,11 @@ var FileUpload = (props) => {
|
|
|
917
955
|
maxCount: props.max_count,
|
|
918
956
|
multiple: props.multiple,
|
|
919
957
|
fileList: files,
|
|
920
|
-
beforeUpload,
|
|
921
958
|
onChange: handleChange,
|
|
922
959
|
showUploadList: true,
|
|
923
960
|
customRequest
|
|
924
961
|
},
|
|
925
|
-
/* @__PURE__ */ import_react26.default.createElement("p", null, /* @__PURE__ */ import_react26.default.createElement(
|
|
962
|
+
/* @__PURE__ */ import_react26.default.createElement("p", null, /* @__PURE__ */ import_react26.default.createElement(import_icons4.InboxOutlined, null)),
|
|
926
963
|
/* @__PURE__ */ import_react26.default.createElement("p", null, "Click or drag file to upload")
|
|
927
964
|
));
|
|
928
965
|
};
|
|
@@ -938,6 +975,98 @@ var TabsElement = (props) => {
|
|
|
938
975
|
};
|
|
939
976
|
return /* @__PURE__ */ import_react27.default.createElement(import_antd20.Tabs, { className: props.containerClassName, items: props.options, onChange: handleChange });
|
|
940
977
|
};
|
|
978
|
+
|
|
979
|
+
// src/Components/SwitchElement.tsx
|
|
980
|
+
var import_react28 = __toESM(require("react"));
|
|
981
|
+
var import_antd21 = require("antd");
|
|
982
|
+
var onChange = (checked) => {
|
|
983
|
+
console.log(`switch to ${checked}`);
|
|
984
|
+
};
|
|
985
|
+
var SwitchElement = () => /* @__PURE__ */ import_react28.default.createElement(import_antd21.Switch, { defaultChecked: true, onChange });
|
|
986
|
+
|
|
987
|
+
// src/Components/Upload.tsx
|
|
988
|
+
var import_react29 = __toESM(require("react"));
|
|
989
|
+
var Upload2 = (props) => {
|
|
990
|
+
const [file, setFile] = (0, import_react29.useState)();
|
|
991
|
+
const handleFileChange = (e) => {
|
|
992
|
+
setFile(e.target.files[0]);
|
|
993
|
+
if (props.onChange) {
|
|
994
|
+
props.onChange(e.target.files[0]);
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
const handleUpload = async () => {
|
|
998
|
+
if (!file) {
|
|
999
|
+
console.error("No file selected");
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
return /* @__PURE__ */ import_react29.default.createElement("div", { style: { marginTop: 16 } }, /* @__PURE__ */ import_react29.default.createElement("input", { type: "file", onChange: handleFileChange }), /* @__PURE__ */ import_react29.default.createElement(
|
|
1004
|
+
"button",
|
|
1005
|
+
{
|
|
1006
|
+
type: "button",
|
|
1007
|
+
onClick: handleUpload,
|
|
1008
|
+
disabled: !file,
|
|
1009
|
+
style: { marginTop: 16 }
|
|
1010
|
+
},
|
|
1011
|
+
"Upload"
|
|
1012
|
+
));
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
// src/Components/OtpElement.tsx
|
|
1016
|
+
var import_react30 = __toESM(require("react"));
|
|
1017
|
+
var import_antd22 = require("antd");
|
|
1018
|
+
var OtpElement = (props) => {
|
|
1019
|
+
const length = props.length;
|
|
1020
|
+
const [otp, setOtp] = (0, import_react30.useState)(Array(length).fill(""));
|
|
1021
|
+
const inputRefs = (0, import_react30.useRef)([]);
|
|
1022
|
+
const handleChange = (e, index) => {
|
|
1023
|
+
const value = e.target.value;
|
|
1024
|
+
if (/^[0-9]$/.test(value) || value === "") {
|
|
1025
|
+
const newOtp = [...otp];
|
|
1026
|
+
newOtp[index] = value;
|
|
1027
|
+
setOtp(newOtp);
|
|
1028
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
1029
|
+
if (value && index < length - 1) {
|
|
1030
|
+
inputRefs.current[index + 1]?.focus();
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
const handleKeyDown = (e, index) => {
|
|
1035
|
+
if (e.key === "Backspace" && !otp[index] && index > 0) {
|
|
1036
|
+
inputRefs.current[index - 1]?.focus();
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
const handlePaste = (e) => {
|
|
1040
|
+
e.preventDefault();
|
|
1041
|
+
const pasteData = e.clipboardData.getData("text");
|
|
1042
|
+
if (/^\d+$/.test(pasteData)) {
|
|
1043
|
+
const newOtp = pasteData.split("").slice(0, length);
|
|
1044
|
+
setOtp(newOtp.concat(Array(length - newOtp.length).fill("")));
|
|
1045
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
1046
|
+
newOtp.forEach((_, idx) => {
|
|
1047
|
+
if (inputRefs.current[idx]) {
|
|
1048
|
+
inputRefs.current[idx]?.focus();
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
(0, import_react30.useEffect)(() => {
|
|
1054
|
+
inputRefs.current[0]?.focus();
|
|
1055
|
+
}, []);
|
|
1056
|
+
return /* @__PURE__ */ import_react30.default.createElement("div", { className: props.containerClassName }, Array.from({ length }).map((_, index) => /* @__PURE__ */ import_react30.default.createElement(
|
|
1057
|
+
import_antd22.Input,
|
|
1058
|
+
{
|
|
1059
|
+
key: index,
|
|
1060
|
+
className: props.className,
|
|
1061
|
+
maxLength: 1,
|
|
1062
|
+
value: otp[index],
|
|
1063
|
+
onChange: (e) => handleChange(e, index),
|
|
1064
|
+
onKeyDown: (e) => handleKeyDown(e, index),
|
|
1065
|
+
onPaste: handlePaste,
|
|
1066
|
+
ref: (el) => inputRefs.current[index] = el
|
|
1067
|
+
}
|
|
1068
|
+
)));
|
|
1069
|
+
};
|
|
941
1070
|
// Annotate the CommonJS export names for ESM import in node:
|
|
942
1071
|
0 && (module.exports = {
|
|
943
1072
|
AddMoreTable,
|
|
@@ -952,14 +1081,17 @@ var TabsElement = (props) => {
|
|
|
952
1081
|
MultipleSelectElement,
|
|
953
1082
|
Navbar,
|
|
954
1083
|
NumberElement,
|
|
1084
|
+
OtpElement,
|
|
955
1085
|
PasswordElement,
|
|
956
1086
|
RadioElement,
|
|
957
1087
|
SelectElement,
|
|
958
1088
|
Sidebar,
|
|
959
1089
|
SingleCheckbox,
|
|
960
1090
|
SingleSelectElement,
|
|
1091
|
+
SwitchElement,
|
|
961
1092
|
TableElement,
|
|
962
1093
|
TabsElement,
|
|
963
1094
|
TextElement,
|
|
964
|
-
TextareaElement
|
|
1095
|
+
TextareaElement,
|
|
1096
|
+
Upload
|
|
965
1097
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -13,6 +13,7 @@ var TextElement = (props) => {
|
|
|
13
13
|
placeholder: props.placeholder,
|
|
14
14
|
allowClear: true,
|
|
15
15
|
id: props.name,
|
|
16
|
+
value: props.value,
|
|
16
17
|
prefix: props.prefix,
|
|
17
18
|
type: props.type,
|
|
18
19
|
status: props.status,
|
|
@@ -72,8 +73,7 @@ var NumberElement = (props) => {
|
|
|
72
73
|
{
|
|
73
74
|
placeholder: props.placeholder,
|
|
74
75
|
addonBefore: props.addonBefore,
|
|
75
|
-
|
|
76
|
-
defaultValue: props.defaultValue,
|
|
76
|
+
value: props.value,
|
|
77
77
|
disabled: props.disabled,
|
|
78
78
|
id: props.name,
|
|
79
79
|
prefix: props.prefix,
|
|
@@ -316,26 +316,87 @@ var MultipleSelectElement = (props) => {
|
|
|
316
316
|
};
|
|
317
317
|
|
|
318
318
|
// src/Components/Button.tsx
|
|
319
|
-
import React11 from "react";
|
|
319
|
+
import React11, { useEffect, useState as useState4 } from "react";
|
|
320
320
|
var ButtonElement = (props) => {
|
|
321
|
+
const [svgContent, setSvgContent] = useState4(null);
|
|
322
|
+
const [originalSvgContent, setOriginalSvgContent] = useState4(null);
|
|
323
|
+
const [hoverColor, setHoverColor] = useState4(null);
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
if (props.icon) {
|
|
326
|
+
fetch(props.icon).then((response) => response.text()).then((data) => {
|
|
327
|
+
const tempDiv = document.createElement("div");
|
|
328
|
+
tempDiv.innerHTML = data;
|
|
329
|
+
const svgElement = tempDiv.querySelector("svg");
|
|
330
|
+
if (svgElement) {
|
|
331
|
+
const textColorClass = props.className?.match(/text-[\w-]+/g)?.[0];
|
|
332
|
+
const hoverColorClass = props.className?.match(/hover:text-[\w-]+/g)?.[0];
|
|
333
|
+
if (textColorClass) {
|
|
334
|
+
const tempSpan = document.createElement("span");
|
|
335
|
+
tempSpan.className = textColorClass;
|
|
336
|
+
document.body.appendChild(tempSpan);
|
|
337
|
+
const computedColor = getComputedStyle(tempSpan).color;
|
|
338
|
+
document.body.removeChild(tempSpan);
|
|
339
|
+
const paths = svgElement.querySelectorAll("path");
|
|
340
|
+
paths.forEach((path) => path.setAttribute("fill", computedColor));
|
|
341
|
+
}
|
|
342
|
+
if (hoverColorClass) {
|
|
343
|
+
const tempSpan = document.createElement("span");
|
|
344
|
+
tempSpan.className = hoverColorClass.replace("hover:", "");
|
|
345
|
+
document.body.appendChild(tempSpan);
|
|
346
|
+
const computedHoverColor = getComputedStyle(tempSpan).color;
|
|
347
|
+
document.body.removeChild(tempSpan);
|
|
348
|
+
setHoverColor(computedHoverColor);
|
|
349
|
+
}
|
|
350
|
+
svgElement.setAttribute(
|
|
351
|
+
"class",
|
|
352
|
+
`${props.iconsClassName ? props.iconsClassName : ""}`
|
|
353
|
+
);
|
|
354
|
+
setSvgContent(tempDiv.innerHTML);
|
|
355
|
+
setOriginalSvgContent(tempDiv.innerHTML);
|
|
356
|
+
}
|
|
357
|
+
}).catch((error) => console.error("Error fetching SVG:", error));
|
|
358
|
+
}
|
|
359
|
+
}, [props.icon, props.className]);
|
|
360
|
+
const handleMouseEnter = () => {
|
|
361
|
+
if (hoverColor && originalSvgContent) {
|
|
362
|
+
const tempDiv = document.createElement("div");
|
|
363
|
+
tempDiv.innerHTML = originalSvgContent;
|
|
364
|
+
const svgElement = tempDiv.querySelector("svg");
|
|
365
|
+
const paths = svgElement?.querySelectorAll("path");
|
|
366
|
+
paths?.forEach((path) => path.setAttribute("fill", hoverColor));
|
|
367
|
+
setSvgContent(tempDiv.innerHTML);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
const handleMouseLeave = () => {
|
|
371
|
+
if (originalSvgContent) {
|
|
372
|
+
setSvgContent(originalSvgContent);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
321
375
|
return /* @__PURE__ */ React11.createElement(
|
|
322
376
|
"button",
|
|
323
377
|
{
|
|
324
|
-
onClick:
|
|
325
|
-
className: `${props.className ? props.className : ""}
|
|
378
|
+
onClick: props.onClick,
|
|
379
|
+
className: `${props.className ? props.className : ""}`,
|
|
380
|
+
onMouseEnter: handleMouseEnter,
|
|
381
|
+
onMouseLeave: handleMouseLeave
|
|
326
382
|
},
|
|
327
|
-
props.
|
|
383
|
+
props.isSVGStylesOverride ? svgContent && /* @__PURE__ */ React11.createElement(
|
|
384
|
+
"span",
|
|
385
|
+
{
|
|
386
|
+
dangerouslySetInnerHTML: { __html: svgContent }
|
|
387
|
+
}
|
|
388
|
+
) : props.icon && /* @__PURE__ */ React11.createElement("img", { className: props.iconsClassName, src: props.icon, alt: props.label }),
|
|
328
389
|
props.label
|
|
329
390
|
);
|
|
330
391
|
};
|
|
331
392
|
|
|
332
393
|
// src/Components/AddMoreTable.tsx
|
|
333
|
-
import React12, { useEffect, useState as
|
|
394
|
+
import React12, { useEffect as useEffect2, useState as useState5 } from "react";
|
|
334
395
|
import { Table, Button } from "antd";
|
|
335
396
|
import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
|
|
336
397
|
var AddMoreTable = (props) => {
|
|
337
398
|
const { thead, tbody } = props;
|
|
338
|
-
const [rows, setRows] =
|
|
399
|
+
const [rows, setRows] = useState5(tbody || []);
|
|
339
400
|
const onHandleRows = () => {
|
|
340
401
|
const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
|
|
341
402
|
let newRow = {
|
|
@@ -400,16 +461,16 @@ var AddMoreTable = (props) => {
|
|
|
400
461
|
});
|
|
401
462
|
});
|
|
402
463
|
};
|
|
403
|
-
|
|
464
|
+
useEffect2(() => {
|
|
404
465
|
console.log(rows);
|
|
405
466
|
}, [rows]);
|
|
406
467
|
const renderInputElement = (element, value) => {
|
|
407
468
|
if (!element) return null;
|
|
408
469
|
const { element: type, label } = element;
|
|
409
470
|
if (type === "single-select") {
|
|
410
|
-
return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [] });
|
|
471
|
+
return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [], firstOptions: [], secondOptions: [] });
|
|
411
472
|
} else if (type === "textarea") {
|
|
412
|
-
return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [] });
|
|
473
|
+
return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [], firstOptions: [], secondOptions: [] });
|
|
413
474
|
} else {
|
|
414
475
|
return null;
|
|
415
476
|
}
|
|
@@ -535,8 +596,8 @@ var Navbar = (props) => {
|
|
|
535
596
|
};
|
|
536
597
|
|
|
537
598
|
// src/Components/TableElement.tsx
|
|
538
|
-
import React20, { useState as
|
|
539
|
-
import {
|
|
599
|
+
import React20, { useState as useState6 } from "react";
|
|
600
|
+
import { Table as Table2 } from "antd";
|
|
540
601
|
|
|
541
602
|
// src/Components/Model.tsx
|
|
542
603
|
import React19 from "react";
|
|
@@ -593,9 +654,8 @@ var ModelElement = (props) => {
|
|
|
593
654
|
// src/Components/TableElement.tsx
|
|
594
655
|
var TableElement = (props) => {
|
|
595
656
|
const { thead, tbody } = props;
|
|
596
|
-
const [selectedRecord, setSelectedRecord] =
|
|
597
|
-
const [model, setModel] =
|
|
598
|
-
const [selectedRowKeys, setSelectedRowKeys] = useState5([]);
|
|
657
|
+
const [selectedRecord, setSelectedRecord] = useState6({});
|
|
658
|
+
const [model, setModel] = useState6(false);
|
|
599
659
|
const handleChange = (record) => {
|
|
600
660
|
console.log("record", record);
|
|
601
661
|
if (props.onChange) {
|
|
@@ -610,12 +670,6 @@ var TableElement = (props) => {
|
|
|
610
670
|
dataIndex: "#",
|
|
611
671
|
key: "#"
|
|
612
672
|
},
|
|
613
|
-
{
|
|
614
|
-
title: "View",
|
|
615
|
-
dataIndex: "View",
|
|
616
|
-
key: "View",
|
|
617
|
-
render: (_, record) => /* @__PURE__ */ React20.createElement(Button3, null, "View")
|
|
618
|
-
},
|
|
619
673
|
...thead.map((col, ind) => ({
|
|
620
674
|
title: col.label,
|
|
621
675
|
dataIndex: col.name,
|
|
@@ -632,6 +686,24 @@ var TableElement = (props) => {
|
|
|
632
686
|
}
|
|
633
687
|
}))
|
|
634
688
|
];
|
|
689
|
+
if (props.view) {
|
|
690
|
+
columns.push({
|
|
691
|
+
title: "View",
|
|
692
|
+
dataIndex: "View",
|
|
693
|
+
key: "View",
|
|
694
|
+
render: (_, record) => /* @__PURE__ */ React20.createElement(
|
|
695
|
+
"a",
|
|
696
|
+
{
|
|
697
|
+
onClick: () => {
|
|
698
|
+
setSelectedRecord(record);
|
|
699
|
+
handleChange(record);
|
|
700
|
+
setModel(true);
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
"View"
|
|
704
|
+
)
|
|
705
|
+
});
|
|
706
|
+
}
|
|
635
707
|
}
|
|
636
708
|
const dataSource = tbody && tbody.map((row, index) => ({
|
|
637
709
|
...row,
|
|
@@ -643,13 +715,10 @@ var TableElement = (props) => {
|
|
|
643
715
|
props.onChange({ name: "pagination", page, pageSize });
|
|
644
716
|
}
|
|
645
717
|
};
|
|
646
|
-
const onSelectChange = (newSelectedRowKeys) => {
|
|
647
|
-
console.log("selectedRowKeys changed: ", newSelectedRowKeys);
|
|
648
|
-
setSelectedRowKeys(newSelectedRowKeys);
|
|
649
|
-
};
|
|
650
718
|
const rowSelectionConfig = props.rowSelection ? {
|
|
651
|
-
selectedRowKeys,
|
|
652
|
-
|
|
719
|
+
onChange: (selectedRowKeys, selectedRows) => {
|
|
720
|
+
console.log(`selectedRowKeys: ${selectedRowKeys}`, "selectedRows: ", selectedRows);
|
|
721
|
+
}
|
|
653
722
|
} : void 0;
|
|
654
723
|
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(
|
|
655
724
|
Table2,
|
|
@@ -660,81 +729,51 @@ var TableElement = (props) => {
|
|
|
660
729
|
showSizeChanger: count > 10,
|
|
661
730
|
onChange: onChangePage
|
|
662
731
|
},
|
|
732
|
+
rowSelection: rowSelectionConfig,
|
|
663
733
|
dataSource,
|
|
664
734
|
columns,
|
|
665
|
-
bordered: true
|
|
666
|
-
rowSelection: rowSelectionConfig,
|
|
667
|
-
size: props.size && props.size,
|
|
668
|
-
onRow: (record) => {
|
|
669
|
-
return {
|
|
670
|
-
onClick: () => {
|
|
671
|
-
setSelectedRecord(record);
|
|
672
|
-
handleChange(record);
|
|
673
|
-
setModel(true);
|
|
674
|
-
},
|
|
675
|
-
style: { cursor: "pointer" }
|
|
676
|
-
};
|
|
677
|
-
}
|
|
735
|
+
bordered: true
|
|
678
736
|
}
|
|
679
737
|
), model && /* @__PURE__ */ React20.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
|
|
680
738
|
};
|
|
681
739
|
|
|
682
740
|
// src/Components/DatePicker.tsx
|
|
683
|
-
import React21, { useState as
|
|
741
|
+
import React21, { useState as useState7 } from "react";
|
|
684
742
|
import { DatePicker } from "antd";
|
|
685
|
-
import
|
|
686
|
-
import
|
|
743
|
+
import dayjs from "dayjs";
|
|
744
|
+
import customParseFormat from "dayjs/plugin/customParseFormat.js";
|
|
745
|
+
dayjs.extend(customParseFormat);
|
|
687
746
|
var DatePickerElement = (props) => {
|
|
688
|
-
const [
|
|
689
|
-
const handleChange = (
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
const formattedDate = dateString;
|
|
694
|
-
console.log("formattedDate-----------------", formattedDate);
|
|
695
|
-
setDate(date2);
|
|
696
|
-
console.log("changedDate------------", date2);
|
|
747
|
+
const [dateState, setDateState] = useState7("");
|
|
748
|
+
const handleChange = (date, dateString) => {
|
|
749
|
+
if (date) {
|
|
750
|
+
const formattedDate = date;
|
|
751
|
+
setDateState(date);
|
|
697
752
|
if (props.onChange) {
|
|
698
753
|
props.onChange(formattedDate);
|
|
699
754
|
}
|
|
700
755
|
} else {
|
|
701
|
-
|
|
756
|
+
setDateState("");
|
|
702
757
|
if (props.onChange) {
|
|
703
758
|
props.onChange("");
|
|
704
759
|
}
|
|
705
760
|
}
|
|
706
761
|
};
|
|
707
|
-
|
|
708
|
-
const currentDate = date || moment();
|
|
709
|
-
const newDate = moment(currentDate).subtract(1, "days");
|
|
710
|
-
setDate(newDate);
|
|
711
|
-
if (props.onChange) {
|
|
712
|
-
props.onChange(newDate.format("lll"));
|
|
713
|
-
}
|
|
714
|
-
};
|
|
715
|
-
const onHandleIncrement = () => {
|
|
716
|
-
const currentDate = date || moment();
|
|
717
|
-
const newDate = moment(currentDate).add(1, "days");
|
|
718
|
-
setDate(newDate);
|
|
719
|
-
if (props.onChange) {
|
|
720
|
-
props.onChange(newDate.format("lll"));
|
|
721
|
-
}
|
|
722
|
-
};
|
|
723
|
-
return /* @__PURE__ */ React21.createElement("div", null, /* @__PURE__ */ React21.createElement("button", { onClick: onHandleDecrement }, /* @__PURE__ */ React21.createElement(LeftOutlined, null)), /* @__PURE__ */ React21.createElement(
|
|
762
|
+
return /* @__PURE__ */ React21.createElement("div", null, /* @__PURE__ */ React21.createElement(
|
|
724
763
|
DatePicker,
|
|
725
764
|
{
|
|
726
765
|
placeholder: props.placeholder,
|
|
727
|
-
value:
|
|
728
|
-
|
|
766
|
+
value: dateState,
|
|
767
|
+
format: { format: "DD-MM-YYYY" },
|
|
729
768
|
onChange: handleChange
|
|
730
769
|
}
|
|
731
|
-
)
|
|
770
|
+
));
|
|
732
771
|
};
|
|
733
772
|
|
|
734
773
|
// src/Components/DateRangePickerElement.tsx
|
|
735
774
|
import React22 from "react";
|
|
736
775
|
import { DatePicker as DatePicker2, Space } from "antd";
|
|
737
|
-
import
|
|
776
|
+
import dayjs2 from "dayjs";
|
|
738
777
|
var DateRangePickerElement = (props) => {
|
|
739
778
|
const { RangePicker } = DatePicker2;
|
|
740
779
|
const handleChange = (dates, dateStrings) => {
|
|
@@ -745,10 +784,10 @@ var DateRangePickerElement = (props) => {
|
|
|
745
784
|
}
|
|
746
785
|
};
|
|
747
786
|
const rangePresets = [
|
|
748
|
-
{ label: "Last 7 Days", value: [
|
|
749
|
-
{ label: "Last 14 Days", value: [
|
|
750
|
-
{ label: "Last 30 Days", value: [
|
|
751
|
-
{ label: "Last 90 Days", value: [
|
|
787
|
+
{ label: "Last 7 Days", value: [dayjs2().add(-7, "d"), dayjs2()] },
|
|
788
|
+
{ label: "Last 14 Days", value: [dayjs2().add(-14, "d"), dayjs2()] },
|
|
789
|
+
{ label: "Last 30 Days", value: [dayjs2().add(-30, "d"), dayjs2()] },
|
|
790
|
+
{ label: "Last 90 Days", value: [dayjs2().add(-90, "d"), dayjs2()] }
|
|
752
791
|
];
|
|
753
792
|
return /* @__PURE__ */ React22.createElement(Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ React22.createElement(RangePicker, { presets: rangePresets, onChange: handleChange }));
|
|
754
793
|
};
|
|
@@ -756,7 +795,7 @@ var DateRangePickerElement = (props) => {
|
|
|
756
795
|
// src/Components/Image.tsx
|
|
757
796
|
import React23 from "react";
|
|
758
797
|
var Image = (props) => {
|
|
759
|
-
return /* @__PURE__ */ React23.createElement("
|
|
798
|
+
return /* @__PURE__ */ React23.createElement("img", { className: props.className, src: props.img, alt: "image" });
|
|
760
799
|
};
|
|
761
800
|
|
|
762
801
|
// src/Components/SingleCheckbox.tsx
|
|
@@ -772,35 +811,39 @@ var SingleCheckbox = (props) => {
|
|
|
772
811
|
};
|
|
773
812
|
|
|
774
813
|
// src/Components/DropDownGroup.tsx
|
|
775
|
-
import React25, { useState as
|
|
814
|
+
import React25, { useState as useState8 } from "react";
|
|
776
815
|
import { Select as Select4 } from "antd";
|
|
777
816
|
var DropDownGroup = (props) => {
|
|
778
|
-
const [selectedValue, setSelectedValue] =
|
|
817
|
+
const [selectedValue, setSelectedValue] = useState8({
|
|
779
818
|
firstValue: {},
|
|
780
|
-
secondValue: {}
|
|
819
|
+
secondValue: {},
|
|
820
|
+
temp: ""
|
|
781
821
|
});
|
|
782
822
|
const handleFirstChange = (value) => {
|
|
783
|
-
|
|
823
|
+
console.log(selectedValue.temp);
|
|
824
|
+
const filterOption2 = props.firstOptions?.find(
|
|
784
825
|
(eachOption) => eachOption.value === value
|
|
785
826
|
);
|
|
786
827
|
setSelectedValue((prev) => {
|
|
787
828
|
const newValue = { ...prev, firstValue: filterOption2 };
|
|
829
|
+
const { temp, ...rest } = newValue;
|
|
788
830
|
if (newValue.firstValue) {
|
|
789
|
-
props.onChange?.(
|
|
831
|
+
props.onChange?.(rest);
|
|
790
832
|
}
|
|
791
|
-
return
|
|
833
|
+
return newValue;
|
|
792
834
|
});
|
|
793
835
|
};
|
|
794
836
|
const handleSecondChange = (value) => {
|
|
795
|
-
const filterOption2 = props.
|
|
837
|
+
const filterOption2 = props.secondOptions?.find(
|
|
796
838
|
(eachOption) => eachOption.value === value
|
|
797
839
|
);
|
|
798
840
|
setSelectedValue((prev) => {
|
|
799
841
|
const newValue = { ...prev, secondValue: filterOption2 };
|
|
842
|
+
const { temp, ...rest } = newValue;
|
|
800
843
|
if (newValue.secondValue) {
|
|
801
|
-
props.onChange?.(
|
|
844
|
+
props.onChange?.(rest);
|
|
802
845
|
}
|
|
803
|
-
return
|
|
846
|
+
return newValue;
|
|
804
847
|
});
|
|
805
848
|
};
|
|
806
849
|
return /* @__PURE__ */ React25.createElement("div", { className: props.containerClassName }, props.label && /* @__PURE__ */ React25.createElement("label", { htmlFor: props.name, className: props.labelClassName }, props.label), /* @__PURE__ */ React25.createElement("div", { className: props.subContainerClassName }, /* @__PURE__ */ React25.createElement(
|
|
@@ -808,7 +851,7 @@ var DropDownGroup = (props) => {
|
|
|
808
851
|
{
|
|
809
852
|
onChange: handleFirstChange,
|
|
810
853
|
variant: props.variant,
|
|
811
|
-
options: props.
|
|
854
|
+
options: props.firstOptions,
|
|
812
855
|
className: props.className
|
|
813
856
|
}
|
|
814
857
|
), /* @__PURE__ */ React25.createElement("div", { style: { borderLeft: "1px solid gray", height: "33px" } }), /* @__PURE__ */ React25.createElement(
|
|
@@ -816,27 +859,19 @@ var DropDownGroup = (props) => {
|
|
|
816
859
|
{
|
|
817
860
|
onChange: handleSecondChange,
|
|
818
861
|
variant: props.variant,
|
|
819
|
-
options: props.
|
|
862
|
+
options: props.secondOptions,
|
|
820
863
|
className: props.className
|
|
821
864
|
}
|
|
822
865
|
)));
|
|
823
866
|
};
|
|
824
867
|
|
|
825
868
|
// src/Components/FilesUpload.tsx
|
|
826
|
-
import React26, { useState as
|
|
827
|
-
import { Upload
|
|
869
|
+
import React26, { useState as useState9 } from "react";
|
|
870
|
+
import { Upload } from "antd";
|
|
828
871
|
import { InboxOutlined } from "@ant-design/icons";
|
|
829
872
|
var FileUpload = (props) => {
|
|
830
873
|
const { Dragger } = Upload;
|
|
831
|
-
const [files, setFiles] =
|
|
832
|
-
const beforeUpload = (file) => {
|
|
833
|
-
const isCorrectFile = ["image/png", "image/jpg", "image/jpeg", "application/pdf"].includes(file.type);
|
|
834
|
-
if (!isCorrectFile) {
|
|
835
|
-
message.error(`(${file.name}) is an invalid file. Please upload files with the following extensions only (.png/.jpg/.jpeg/.pdf)`);
|
|
836
|
-
return Upload.LIST_IGNORE;
|
|
837
|
-
}
|
|
838
|
-
return true;
|
|
839
|
-
};
|
|
874
|
+
const [files, setFiles] = useState9([]);
|
|
840
875
|
const handleChange = ({ fileList }) => {
|
|
841
876
|
setFiles(fileList);
|
|
842
877
|
if (props.onChange) {
|
|
@@ -860,7 +895,6 @@ var FileUpload = (props) => {
|
|
|
860
895
|
maxCount: props.max_count,
|
|
861
896
|
multiple: props.multiple,
|
|
862
897
|
fileList: files,
|
|
863
|
-
beforeUpload,
|
|
864
898
|
onChange: handleChange,
|
|
865
899
|
showUploadList: true,
|
|
866
900
|
customRequest
|
|
@@ -881,6 +915,98 @@ var TabsElement = (props) => {
|
|
|
881
915
|
};
|
|
882
916
|
return /* @__PURE__ */ React27.createElement(Tabs, { className: props.containerClassName, items: props.options, onChange: handleChange });
|
|
883
917
|
};
|
|
918
|
+
|
|
919
|
+
// src/Components/SwitchElement.tsx
|
|
920
|
+
import React28 from "react";
|
|
921
|
+
import { Switch } from "antd";
|
|
922
|
+
var onChange = (checked) => {
|
|
923
|
+
console.log(`switch to ${checked}`);
|
|
924
|
+
};
|
|
925
|
+
var SwitchElement = () => /* @__PURE__ */ React28.createElement(Switch, { defaultChecked: true, onChange });
|
|
926
|
+
|
|
927
|
+
// src/Components/Upload.tsx
|
|
928
|
+
import React29, { useState as useState10 } from "react";
|
|
929
|
+
var Upload2 = (props) => {
|
|
930
|
+
const [file, setFile] = useState10();
|
|
931
|
+
const handleFileChange = (e) => {
|
|
932
|
+
setFile(e.target.files[0]);
|
|
933
|
+
if (props.onChange) {
|
|
934
|
+
props.onChange(e.target.files[0]);
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
const handleUpload = async () => {
|
|
938
|
+
if (!file) {
|
|
939
|
+
console.error("No file selected");
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
return /* @__PURE__ */ React29.createElement("div", { style: { marginTop: 16 } }, /* @__PURE__ */ React29.createElement("input", { type: "file", onChange: handleFileChange }), /* @__PURE__ */ React29.createElement(
|
|
944
|
+
"button",
|
|
945
|
+
{
|
|
946
|
+
type: "button",
|
|
947
|
+
onClick: handleUpload,
|
|
948
|
+
disabled: !file,
|
|
949
|
+
style: { marginTop: 16 }
|
|
950
|
+
},
|
|
951
|
+
"Upload"
|
|
952
|
+
));
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
// src/Components/OtpElement.tsx
|
|
956
|
+
import React30, { useState as useState11, useRef, useEffect as useEffect3 } from "react";
|
|
957
|
+
import { Input as Input3 } from "antd";
|
|
958
|
+
var OtpElement = (props) => {
|
|
959
|
+
const length = props.length;
|
|
960
|
+
const [otp, setOtp] = useState11(Array(length).fill(""));
|
|
961
|
+
const inputRefs = useRef([]);
|
|
962
|
+
const handleChange = (e, index) => {
|
|
963
|
+
const value = e.target.value;
|
|
964
|
+
if (/^[0-9]$/.test(value) || value === "") {
|
|
965
|
+
const newOtp = [...otp];
|
|
966
|
+
newOtp[index] = value;
|
|
967
|
+
setOtp(newOtp);
|
|
968
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
969
|
+
if (value && index < length - 1) {
|
|
970
|
+
inputRefs.current[index + 1]?.focus();
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
const handleKeyDown = (e, index) => {
|
|
975
|
+
if (e.key === "Backspace" && !otp[index] && index > 0) {
|
|
976
|
+
inputRefs.current[index - 1]?.focus();
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
const handlePaste = (e) => {
|
|
980
|
+
e.preventDefault();
|
|
981
|
+
const pasteData = e.clipboardData.getData("text");
|
|
982
|
+
if (/^\d+$/.test(pasteData)) {
|
|
983
|
+
const newOtp = pasteData.split("").slice(0, length);
|
|
984
|
+
setOtp(newOtp.concat(Array(length - newOtp.length).fill("")));
|
|
985
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
986
|
+
newOtp.forEach((_, idx) => {
|
|
987
|
+
if (inputRefs.current[idx]) {
|
|
988
|
+
inputRefs.current[idx]?.focus();
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
useEffect3(() => {
|
|
994
|
+
inputRefs.current[0]?.focus();
|
|
995
|
+
}, []);
|
|
996
|
+
return /* @__PURE__ */ React30.createElement("div", { className: props.containerClassName }, Array.from({ length }).map((_, index) => /* @__PURE__ */ React30.createElement(
|
|
997
|
+
Input3,
|
|
998
|
+
{
|
|
999
|
+
key: index,
|
|
1000
|
+
className: props.className,
|
|
1001
|
+
maxLength: 1,
|
|
1002
|
+
value: otp[index],
|
|
1003
|
+
onChange: (e) => handleChange(e, index),
|
|
1004
|
+
onKeyDown: (e) => handleKeyDown(e, index),
|
|
1005
|
+
onPaste: handlePaste,
|
|
1006
|
+
ref: (el) => inputRefs.current[index] = el
|
|
1007
|
+
}
|
|
1008
|
+
)));
|
|
1009
|
+
};
|
|
884
1010
|
export {
|
|
885
1011
|
AddMoreTable,
|
|
886
1012
|
ButtonElement,
|
|
@@ -894,14 +1020,17 @@ export {
|
|
|
894
1020
|
MultipleSelectElement,
|
|
895
1021
|
Navbar,
|
|
896
1022
|
NumberElement,
|
|
1023
|
+
OtpElement,
|
|
897
1024
|
PasswordElement,
|
|
898
1025
|
RadioElement,
|
|
899
1026
|
SelectElement,
|
|
900
1027
|
Sidebar,
|
|
901
1028
|
SingleCheckbox,
|
|
902
1029
|
SingleSelectElement,
|
|
1030
|
+
SwitchElement,
|
|
903
1031
|
TableElement,
|
|
904
1032
|
TabsElement,
|
|
905
1033
|
TextElement,
|
|
906
|
-
TextareaElement
|
|
1034
|
+
TextareaElement,
|
|
1035
|
+
Upload2 as Upload
|
|
907
1036
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apexcura/ui-components",
|
|
3
|
-
"version": "0.0.14-
|
|
3
|
+
"version": "0.0.14-Beta61",
|
|
4
4
|
"description": "Apex cura React components library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apex cura",
|
|
@@ -48,8 +48,6 @@
|
|
|
48
48
|
"node": ">=18.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@apexcura/core": "^0.0.15-Beta34",
|
|
52
|
-
"@apexcura/ui-components": "^0.0.11-Beta256",
|
|
53
51
|
"@tinymce/tinymce-react": "^5.0.1",
|
|
54
52
|
"autoprefixer": "^10.4.19",
|
|
55
53
|
"date-fns": "^3.6.0",
|