@apexcura/ui-components 0.0.14-Beta6 → 0.0.14-Beta60
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 +228 -93
- package/dist/index.mjs +236 -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,13 @@ 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
|
+
if (props.onChange) {
|
|
782
|
+
props.onChange(selectedRows);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
710
785
|
} : void 0;
|
|
711
786
|
return /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
712
787
|
import_antd14.Table,
|
|
@@ -717,21 +792,10 @@ var TableElement = (props) => {
|
|
|
717
792
|
showSizeChanger: count > 10,
|
|
718
793
|
onChange: onChangePage
|
|
719
794
|
},
|
|
795
|
+
rowSelection: rowSelectionConfig,
|
|
720
796
|
dataSource,
|
|
721
797
|
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
|
-
}
|
|
798
|
+
bordered: true
|
|
735
799
|
}
|
|
736
800
|
), model && /* @__PURE__ */ import_react20.default.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
|
|
737
801
|
};
|
|
@@ -739,59 +803,40 @@ var TableElement = (props) => {
|
|
|
739
803
|
// src/Components/DatePicker.tsx
|
|
740
804
|
var import_react21 = __toESM(require("react"));
|
|
741
805
|
var import_antd15 = require("antd");
|
|
742
|
-
var
|
|
743
|
-
var
|
|
806
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
807
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
|
|
808
|
+
import_dayjs.default.extend(import_customParseFormat.default);
|
|
744
809
|
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);
|
|
810
|
+
const [dateState, setDateState] = (0, import_react21.useState)("");
|
|
811
|
+
const handleChange = (date, dateString) => {
|
|
812
|
+
if (date) {
|
|
813
|
+
const formattedDate = date;
|
|
814
|
+
setDateState(date);
|
|
754
815
|
if (props.onChange) {
|
|
755
816
|
props.onChange(formattedDate);
|
|
756
817
|
}
|
|
757
818
|
} else {
|
|
758
|
-
|
|
819
|
+
setDateState("");
|
|
759
820
|
if (props.onChange) {
|
|
760
821
|
props.onChange("");
|
|
761
822
|
}
|
|
762
823
|
}
|
|
763
824
|
};
|
|
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(
|
|
825
|
+
return /* @__PURE__ */ import_react21.default.createElement("div", null, /* @__PURE__ */ import_react21.default.createElement(
|
|
781
826
|
import_antd15.DatePicker,
|
|
782
827
|
{
|
|
783
828
|
placeholder: props.placeholder,
|
|
784
|
-
value:
|
|
785
|
-
|
|
829
|
+
value: dateState,
|
|
830
|
+
format: { format: "DD-MM-YYYY" },
|
|
786
831
|
onChange: handleChange
|
|
787
832
|
}
|
|
788
|
-
)
|
|
833
|
+
));
|
|
789
834
|
};
|
|
790
835
|
|
|
791
836
|
// src/Components/DateRangePickerElement.tsx
|
|
792
837
|
var import_react22 = __toESM(require("react"));
|
|
793
838
|
var import_antd16 = require("antd");
|
|
794
|
-
var
|
|
839
|
+
var import_dayjs2 = __toESM(require("dayjs"));
|
|
795
840
|
var DateRangePickerElement = (props) => {
|
|
796
841
|
const { RangePicker } = import_antd16.DatePicker;
|
|
797
842
|
const handleChange = (dates, dateStrings) => {
|
|
@@ -802,10 +847,10 @@ var DateRangePickerElement = (props) => {
|
|
|
802
847
|
}
|
|
803
848
|
};
|
|
804
849
|
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,
|
|
850
|
+
{ label: "Last 7 Days", value: [(0, import_dayjs2.default)().add(-7, "d"), (0, import_dayjs2.default)()] },
|
|
851
|
+
{ label: "Last 14 Days", value: [(0, import_dayjs2.default)().add(-14, "d"), (0, import_dayjs2.default)()] },
|
|
852
|
+
{ label: "Last 30 Days", value: [(0, import_dayjs2.default)().add(-30, "d"), (0, import_dayjs2.default)()] },
|
|
853
|
+
{ label: "Last 90 Days", value: [(0, import_dayjs2.default)().add(-90, "d"), (0, import_dayjs2.default)()] }
|
|
809
854
|
];
|
|
810
855
|
return /* @__PURE__ */ import_react22.default.createElement(import_antd16.Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ import_react22.default.createElement(RangePicker, { presets: rangePresets, onChange: handleChange }));
|
|
811
856
|
};
|
|
@@ -813,7 +858,7 @@ var DateRangePickerElement = (props) => {
|
|
|
813
858
|
// src/Components/Image.tsx
|
|
814
859
|
var import_react23 = __toESM(require("react"));
|
|
815
860
|
var Image = (props) => {
|
|
816
|
-
return /* @__PURE__ */ import_react23.default.createElement("
|
|
861
|
+
return /* @__PURE__ */ import_react23.default.createElement("img", { className: props.className, src: props.img, alt: "image" });
|
|
817
862
|
};
|
|
818
863
|
|
|
819
864
|
// src/Components/SingleCheckbox.tsx
|
|
@@ -834,30 +879,34 @@ var import_antd18 = require("antd");
|
|
|
834
879
|
var DropDownGroup = (props) => {
|
|
835
880
|
const [selectedValue, setSelectedValue] = (0, import_react25.useState)({
|
|
836
881
|
firstValue: {},
|
|
837
|
-
secondValue: {}
|
|
882
|
+
secondValue: {},
|
|
883
|
+
temp: ""
|
|
838
884
|
});
|
|
839
885
|
const handleFirstChange = (value) => {
|
|
840
|
-
|
|
886
|
+
console.log(selectedValue.temp);
|
|
887
|
+
const filterOption2 = props.firstOptions?.find(
|
|
841
888
|
(eachOption) => eachOption.value === value
|
|
842
889
|
);
|
|
843
890
|
setSelectedValue((prev) => {
|
|
844
891
|
const newValue = { ...prev, firstValue: filterOption2 };
|
|
892
|
+
const { temp, ...rest } = newValue;
|
|
845
893
|
if (newValue.firstValue) {
|
|
846
|
-
props.onChange?.(
|
|
894
|
+
props.onChange?.(rest);
|
|
847
895
|
}
|
|
848
|
-
return
|
|
896
|
+
return newValue;
|
|
849
897
|
});
|
|
850
898
|
};
|
|
851
899
|
const handleSecondChange = (value) => {
|
|
852
|
-
const filterOption2 = props.
|
|
900
|
+
const filterOption2 = props.secondOptions?.find(
|
|
853
901
|
(eachOption) => eachOption.value === value
|
|
854
902
|
);
|
|
855
903
|
setSelectedValue((prev) => {
|
|
856
904
|
const newValue = { ...prev, secondValue: filterOption2 };
|
|
905
|
+
const { temp, ...rest } = newValue;
|
|
857
906
|
if (newValue.secondValue) {
|
|
858
|
-
props.onChange?.(
|
|
907
|
+
props.onChange?.(rest);
|
|
859
908
|
}
|
|
860
|
-
return
|
|
909
|
+
return newValue;
|
|
861
910
|
});
|
|
862
911
|
};
|
|
863
912
|
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 +914,7 @@ var DropDownGroup = (props) => {
|
|
|
865
914
|
{
|
|
866
915
|
onChange: handleFirstChange,
|
|
867
916
|
variant: props.variant,
|
|
868
|
-
options: props.
|
|
917
|
+
options: props.firstOptions,
|
|
869
918
|
className: props.className
|
|
870
919
|
}
|
|
871
920
|
), /* @__PURE__ */ import_react25.default.createElement("div", { style: { borderLeft: "1px solid gray", height: "33px" } }), /* @__PURE__ */ import_react25.default.createElement(
|
|
@@ -873,7 +922,7 @@ var DropDownGroup = (props) => {
|
|
|
873
922
|
{
|
|
874
923
|
onChange: handleSecondChange,
|
|
875
924
|
variant: props.variant,
|
|
876
|
-
options: props.
|
|
925
|
+
options: props.secondOptions,
|
|
877
926
|
className: props.className
|
|
878
927
|
}
|
|
879
928
|
)));
|
|
@@ -882,18 +931,10 @@ var DropDownGroup = (props) => {
|
|
|
882
931
|
// src/Components/FilesUpload.tsx
|
|
883
932
|
var import_react26 = __toESM(require("react"));
|
|
884
933
|
var import_antd19 = require("antd");
|
|
885
|
-
var
|
|
934
|
+
var import_icons4 = require("@ant-design/icons");
|
|
886
935
|
var FileUpload = (props) => {
|
|
887
936
|
const { Dragger } = import_antd19.Upload;
|
|
888
937
|
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
938
|
const handleChange = ({ fileList }) => {
|
|
898
939
|
setFiles(fileList);
|
|
899
940
|
if (props.onChange) {
|
|
@@ -917,12 +958,11 @@ var FileUpload = (props) => {
|
|
|
917
958
|
maxCount: props.max_count,
|
|
918
959
|
multiple: props.multiple,
|
|
919
960
|
fileList: files,
|
|
920
|
-
beforeUpload,
|
|
921
961
|
onChange: handleChange,
|
|
922
962
|
showUploadList: true,
|
|
923
963
|
customRequest
|
|
924
964
|
},
|
|
925
|
-
/* @__PURE__ */ import_react26.default.createElement("p", null, /* @__PURE__ */ import_react26.default.createElement(
|
|
965
|
+
/* @__PURE__ */ import_react26.default.createElement("p", null, /* @__PURE__ */ import_react26.default.createElement(import_icons4.InboxOutlined, null)),
|
|
926
966
|
/* @__PURE__ */ import_react26.default.createElement("p", null, "Click or drag file to upload")
|
|
927
967
|
));
|
|
928
968
|
};
|
|
@@ -938,6 +978,98 @@ var TabsElement = (props) => {
|
|
|
938
978
|
};
|
|
939
979
|
return /* @__PURE__ */ import_react27.default.createElement(import_antd20.Tabs, { className: props.containerClassName, items: props.options, onChange: handleChange });
|
|
940
980
|
};
|
|
981
|
+
|
|
982
|
+
// src/Components/SwitchElement.tsx
|
|
983
|
+
var import_react28 = __toESM(require("react"));
|
|
984
|
+
var import_antd21 = require("antd");
|
|
985
|
+
var onChange = (checked) => {
|
|
986
|
+
console.log(`switch to ${checked}`);
|
|
987
|
+
};
|
|
988
|
+
var SwitchElement = () => /* @__PURE__ */ import_react28.default.createElement(import_antd21.Switch, { defaultChecked: true, onChange });
|
|
989
|
+
|
|
990
|
+
// src/Components/Upload.tsx
|
|
991
|
+
var import_react29 = __toESM(require("react"));
|
|
992
|
+
var Upload2 = (props) => {
|
|
993
|
+
const [file, setFile] = (0, import_react29.useState)();
|
|
994
|
+
const handleFileChange = (e) => {
|
|
995
|
+
setFile(e.target.files[0]);
|
|
996
|
+
if (props.onChange) {
|
|
997
|
+
props.onChange(e.target.files[0]);
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
const handleUpload = async () => {
|
|
1001
|
+
if (!file) {
|
|
1002
|
+
console.error("No file selected");
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
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(
|
|
1007
|
+
"button",
|
|
1008
|
+
{
|
|
1009
|
+
type: "button",
|
|
1010
|
+
onClick: handleUpload,
|
|
1011
|
+
disabled: !file,
|
|
1012
|
+
style: { marginTop: 16 }
|
|
1013
|
+
},
|
|
1014
|
+
"Upload"
|
|
1015
|
+
));
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
// src/Components/OtpElement.tsx
|
|
1019
|
+
var import_react30 = __toESM(require("react"));
|
|
1020
|
+
var import_antd22 = require("antd");
|
|
1021
|
+
var OtpElement = (props) => {
|
|
1022
|
+
const length = props.length;
|
|
1023
|
+
const [otp, setOtp] = (0, import_react30.useState)(Array(length).fill(""));
|
|
1024
|
+
const inputRefs = (0, import_react30.useRef)([]);
|
|
1025
|
+
const handleChange = (e, index) => {
|
|
1026
|
+
const value = e.target.value;
|
|
1027
|
+
if (/^[0-9]$/.test(value) || value === "") {
|
|
1028
|
+
const newOtp = [...otp];
|
|
1029
|
+
newOtp[index] = value;
|
|
1030
|
+
setOtp(newOtp);
|
|
1031
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
1032
|
+
if (value && index < length - 1) {
|
|
1033
|
+
inputRefs.current[index + 1]?.focus();
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
const handleKeyDown = (e, index) => {
|
|
1038
|
+
if (e.key === "Backspace" && !otp[index] && index > 0) {
|
|
1039
|
+
inputRefs.current[index - 1]?.focus();
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
const handlePaste = (e) => {
|
|
1043
|
+
e.preventDefault();
|
|
1044
|
+
const pasteData = e.clipboardData.getData("text");
|
|
1045
|
+
if (/^\d+$/.test(pasteData)) {
|
|
1046
|
+
const newOtp = pasteData.split("").slice(0, length);
|
|
1047
|
+
setOtp(newOtp.concat(Array(length - newOtp.length).fill("")));
|
|
1048
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
1049
|
+
newOtp.forEach((_, idx) => {
|
|
1050
|
+
if (inputRefs.current[idx]) {
|
|
1051
|
+
inputRefs.current[idx]?.focus();
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
(0, import_react30.useEffect)(() => {
|
|
1057
|
+
inputRefs.current[0]?.focus();
|
|
1058
|
+
}, []);
|
|
1059
|
+
return /* @__PURE__ */ import_react30.default.createElement("div", { className: props.containerClassName }, Array.from({ length }).map((_, index) => /* @__PURE__ */ import_react30.default.createElement(
|
|
1060
|
+
import_antd22.Input,
|
|
1061
|
+
{
|
|
1062
|
+
key: index,
|
|
1063
|
+
className: props.className,
|
|
1064
|
+
maxLength: 1,
|
|
1065
|
+
value: otp[index],
|
|
1066
|
+
onChange: (e) => handleChange(e, index),
|
|
1067
|
+
onKeyDown: (e) => handleKeyDown(e, index),
|
|
1068
|
+
onPaste: handlePaste,
|
|
1069
|
+
ref: (el) => inputRefs.current[index] = el
|
|
1070
|
+
}
|
|
1071
|
+
)));
|
|
1072
|
+
};
|
|
941
1073
|
// Annotate the CommonJS export names for ESM import in node:
|
|
942
1074
|
0 && (module.exports = {
|
|
943
1075
|
AddMoreTable,
|
|
@@ -952,14 +1084,17 @@ var TabsElement = (props) => {
|
|
|
952
1084
|
MultipleSelectElement,
|
|
953
1085
|
Navbar,
|
|
954
1086
|
NumberElement,
|
|
1087
|
+
OtpElement,
|
|
955
1088
|
PasswordElement,
|
|
956
1089
|
RadioElement,
|
|
957
1090
|
SelectElement,
|
|
958
1091
|
Sidebar,
|
|
959
1092
|
SingleCheckbox,
|
|
960
1093
|
SingleSelectElement,
|
|
1094
|
+
SwitchElement,
|
|
961
1095
|
TableElement,
|
|
962
1096
|
TabsElement,
|
|
963
1097
|
TextElement,
|
|
964
|
-
TextareaElement
|
|
1098
|
+
TextareaElement,
|
|
1099
|
+
Upload
|
|
965
1100
|
});
|
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,13 @@ 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
|
+
if (props.onChange) {
|
|
722
|
+
props.onChange(selectedRows);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
653
725
|
} : void 0;
|
|
654
726
|
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(
|
|
655
727
|
Table2,
|
|
@@ -660,81 +732,51 @@ var TableElement = (props) => {
|
|
|
660
732
|
showSizeChanger: count > 10,
|
|
661
733
|
onChange: onChangePage
|
|
662
734
|
},
|
|
735
|
+
rowSelection: rowSelectionConfig,
|
|
663
736
|
dataSource,
|
|
664
737
|
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
|
-
}
|
|
738
|
+
bordered: true
|
|
678
739
|
}
|
|
679
740
|
), model && /* @__PURE__ */ React20.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
|
|
680
741
|
};
|
|
681
742
|
|
|
682
743
|
// src/Components/DatePicker.tsx
|
|
683
|
-
import React21, { useState as
|
|
744
|
+
import React21, { useState as useState7 } from "react";
|
|
684
745
|
import { DatePicker } from "antd";
|
|
685
|
-
import
|
|
686
|
-
import
|
|
746
|
+
import dayjs from "dayjs";
|
|
747
|
+
import customParseFormat from "dayjs/plugin/customParseFormat.js";
|
|
748
|
+
dayjs.extend(customParseFormat);
|
|
687
749
|
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);
|
|
750
|
+
const [dateState, setDateState] = useState7("");
|
|
751
|
+
const handleChange = (date, dateString) => {
|
|
752
|
+
if (date) {
|
|
753
|
+
const formattedDate = date;
|
|
754
|
+
setDateState(date);
|
|
697
755
|
if (props.onChange) {
|
|
698
756
|
props.onChange(formattedDate);
|
|
699
757
|
}
|
|
700
758
|
} else {
|
|
701
|
-
|
|
759
|
+
setDateState("");
|
|
702
760
|
if (props.onChange) {
|
|
703
761
|
props.onChange("");
|
|
704
762
|
}
|
|
705
763
|
}
|
|
706
764
|
};
|
|
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(
|
|
765
|
+
return /* @__PURE__ */ React21.createElement("div", null, /* @__PURE__ */ React21.createElement(
|
|
724
766
|
DatePicker,
|
|
725
767
|
{
|
|
726
768
|
placeholder: props.placeholder,
|
|
727
|
-
value:
|
|
728
|
-
|
|
769
|
+
value: dateState,
|
|
770
|
+
format: { format: "DD-MM-YYYY" },
|
|
729
771
|
onChange: handleChange
|
|
730
772
|
}
|
|
731
|
-
)
|
|
773
|
+
));
|
|
732
774
|
};
|
|
733
775
|
|
|
734
776
|
// src/Components/DateRangePickerElement.tsx
|
|
735
777
|
import React22 from "react";
|
|
736
778
|
import { DatePicker as DatePicker2, Space } from "antd";
|
|
737
|
-
import
|
|
779
|
+
import dayjs2 from "dayjs";
|
|
738
780
|
var DateRangePickerElement = (props) => {
|
|
739
781
|
const { RangePicker } = DatePicker2;
|
|
740
782
|
const handleChange = (dates, dateStrings) => {
|
|
@@ -745,10 +787,10 @@ var DateRangePickerElement = (props) => {
|
|
|
745
787
|
}
|
|
746
788
|
};
|
|
747
789
|
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: [
|
|
790
|
+
{ label: "Last 7 Days", value: [dayjs2().add(-7, "d"), dayjs2()] },
|
|
791
|
+
{ label: "Last 14 Days", value: [dayjs2().add(-14, "d"), dayjs2()] },
|
|
792
|
+
{ label: "Last 30 Days", value: [dayjs2().add(-30, "d"), dayjs2()] },
|
|
793
|
+
{ label: "Last 90 Days", value: [dayjs2().add(-90, "d"), dayjs2()] }
|
|
752
794
|
];
|
|
753
795
|
return /* @__PURE__ */ React22.createElement(Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ React22.createElement(RangePicker, { presets: rangePresets, onChange: handleChange }));
|
|
754
796
|
};
|
|
@@ -756,7 +798,7 @@ var DateRangePickerElement = (props) => {
|
|
|
756
798
|
// src/Components/Image.tsx
|
|
757
799
|
import React23 from "react";
|
|
758
800
|
var Image = (props) => {
|
|
759
|
-
return /* @__PURE__ */ React23.createElement("
|
|
801
|
+
return /* @__PURE__ */ React23.createElement("img", { className: props.className, src: props.img, alt: "image" });
|
|
760
802
|
};
|
|
761
803
|
|
|
762
804
|
// src/Components/SingleCheckbox.tsx
|
|
@@ -772,35 +814,39 @@ var SingleCheckbox = (props) => {
|
|
|
772
814
|
};
|
|
773
815
|
|
|
774
816
|
// src/Components/DropDownGroup.tsx
|
|
775
|
-
import React25, { useState as
|
|
817
|
+
import React25, { useState as useState8 } from "react";
|
|
776
818
|
import { Select as Select4 } from "antd";
|
|
777
819
|
var DropDownGroup = (props) => {
|
|
778
|
-
const [selectedValue, setSelectedValue] =
|
|
820
|
+
const [selectedValue, setSelectedValue] = useState8({
|
|
779
821
|
firstValue: {},
|
|
780
|
-
secondValue: {}
|
|
822
|
+
secondValue: {},
|
|
823
|
+
temp: ""
|
|
781
824
|
});
|
|
782
825
|
const handleFirstChange = (value) => {
|
|
783
|
-
|
|
826
|
+
console.log(selectedValue.temp);
|
|
827
|
+
const filterOption2 = props.firstOptions?.find(
|
|
784
828
|
(eachOption) => eachOption.value === value
|
|
785
829
|
);
|
|
786
830
|
setSelectedValue((prev) => {
|
|
787
831
|
const newValue = { ...prev, firstValue: filterOption2 };
|
|
832
|
+
const { temp, ...rest } = newValue;
|
|
788
833
|
if (newValue.firstValue) {
|
|
789
|
-
props.onChange?.(
|
|
834
|
+
props.onChange?.(rest);
|
|
790
835
|
}
|
|
791
|
-
return
|
|
836
|
+
return newValue;
|
|
792
837
|
});
|
|
793
838
|
};
|
|
794
839
|
const handleSecondChange = (value) => {
|
|
795
|
-
const filterOption2 = props.
|
|
840
|
+
const filterOption2 = props.secondOptions?.find(
|
|
796
841
|
(eachOption) => eachOption.value === value
|
|
797
842
|
);
|
|
798
843
|
setSelectedValue((prev) => {
|
|
799
844
|
const newValue = { ...prev, secondValue: filterOption2 };
|
|
845
|
+
const { temp, ...rest } = newValue;
|
|
800
846
|
if (newValue.secondValue) {
|
|
801
|
-
props.onChange?.(
|
|
847
|
+
props.onChange?.(rest);
|
|
802
848
|
}
|
|
803
|
-
return
|
|
849
|
+
return newValue;
|
|
804
850
|
});
|
|
805
851
|
};
|
|
806
852
|
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 +854,7 @@ var DropDownGroup = (props) => {
|
|
|
808
854
|
{
|
|
809
855
|
onChange: handleFirstChange,
|
|
810
856
|
variant: props.variant,
|
|
811
|
-
options: props.
|
|
857
|
+
options: props.firstOptions,
|
|
812
858
|
className: props.className
|
|
813
859
|
}
|
|
814
860
|
), /* @__PURE__ */ React25.createElement("div", { style: { borderLeft: "1px solid gray", height: "33px" } }), /* @__PURE__ */ React25.createElement(
|
|
@@ -816,27 +862,19 @@ var DropDownGroup = (props) => {
|
|
|
816
862
|
{
|
|
817
863
|
onChange: handleSecondChange,
|
|
818
864
|
variant: props.variant,
|
|
819
|
-
options: props.
|
|
865
|
+
options: props.secondOptions,
|
|
820
866
|
className: props.className
|
|
821
867
|
}
|
|
822
868
|
)));
|
|
823
869
|
};
|
|
824
870
|
|
|
825
871
|
// src/Components/FilesUpload.tsx
|
|
826
|
-
import React26, { useState as
|
|
827
|
-
import { Upload
|
|
872
|
+
import React26, { useState as useState9 } from "react";
|
|
873
|
+
import { Upload } from "antd";
|
|
828
874
|
import { InboxOutlined } from "@ant-design/icons";
|
|
829
875
|
var FileUpload = (props) => {
|
|
830
876
|
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
|
-
};
|
|
877
|
+
const [files, setFiles] = useState9([]);
|
|
840
878
|
const handleChange = ({ fileList }) => {
|
|
841
879
|
setFiles(fileList);
|
|
842
880
|
if (props.onChange) {
|
|
@@ -860,7 +898,6 @@ var FileUpload = (props) => {
|
|
|
860
898
|
maxCount: props.max_count,
|
|
861
899
|
multiple: props.multiple,
|
|
862
900
|
fileList: files,
|
|
863
|
-
beforeUpload,
|
|
864
901
|
onChange: handleChange,
|
|
865
902
|
showUploadList: true,
|
|
866
903
|
customRequest
|
|
@@ -881,6 +918,98 @@ var TabsElement = (props) => {
|
|
|
881
918
|
};
|
|
882
919
|
return /* @__PURE__ */ React27.createElement(Tabs, { className: props.containerClassName, items: props.options, onChange: handleChange });
|
|
883
920
|
};
|
|
921
|
+
|
|
922
|
+
// src/Components/SwitchElement.tsx
|
|
923
|
+
import React28 from "react";
|
|
924
|
+
import { Switch } from "antd";
|
|
925
|
+
var onChange = (checked) => {
|
|
926
|
+
console.log(`switch to ${checked}`);
|
|
927
|
+
};
|
|
928
|
+
var SwitchElement = () => /* @__PURE__ */ React28.createElement(Switch, { defaultChecked: true, onChange });
|
|
929
|
+
|
|
930
|
+
// src/Components/Upload.tsx
|
|
931
|
+
import React29, { useState as useState10 } from "react";
|
|
932
|
+
var Upload2 = (props) => {
|
|
933
|
+
const [file, setFile] = useState10();
|
|
934
|
+
const handleFileChange = (e) => {
|
|
935
|
+
setFile(e.target.files[0]);
|
|
936
|
+
if (props.onChange) {
|
|
937
|
+
props.onChange(e.target.files[0]);
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
const handleUpload = async () => {
|
|
941
|
+
if (!file) {
|
|
942
|
+
console.error("No file selected");
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
return /* @__PURE__ */ React29.createElement("div", { style: { marginTop: 16 } }, /* @__PURE__ */ React29.createElement("input", { type: "file", onChange: handleFileChange }), /* @__PURE__ */ React29.createElement(
|
|
947
|
+
"button",
|
|
948
|
+
{
|
|
949
|
+
type: "button",
|
|
950
|
+
onClick: handleUpload,
|
|
951
|
+
disabled: !file,
|
|
952
|
+
style: { marginTop: 16 }
|
|
953
|
+
},
|
|
954
|
+
"Upload"
|
|
955
|
+
));
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
// src/Components/OtpElement.tsx
|
|
959
|
+
import React30, { useState as useState11, useRef, useEffect as useEffect3 } from "react";
|
|
960
|
+
import { Input as Input3 } from "antd";
|
|
961
|
+
var OtpElement = (props) => {
|
|
962
|
+
const length = props.length;
|
|
963
|
+
const [otp, setOtp] = useState11(Array(length).fill(""));
|
|
964
|
+
const inputRefs = useRef([]);
|
|
965
|
+
const handleChange = (e, index) => {
|
|
966
|
+
const value = e.target.value;
|
|
967
|
+
if (/^[0-9]$/.test(value) || value === "") {
|
|
968
|
+
const newOtp = [...otp];
|
|
969
|
+
newOtp[index] = value;
|
|
970
|
+
setOtp(newOtp);
|
|
971
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
972
|
+
if (value && index < length - 1) {
|
|
973
|
+
inputRefs.current[index + 1]?.focus();
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
const handleKeyDown = (e, index) => {
|
|
978
|
+
if (e.key === "Backspace" && !otp[index] && index > 0) {
|
|
979
|
+
inputRefs.current[index - 1]?.focus();
|
|
980
|
+
}
|
|
981
|
+
};
|
|
982
|
+
const handlePaste = (e) => {
|
|
983
|
+
e.preventDefault();
|
|
984
|
+
const pasteData = e.clipboardData.getData("text");
|
|
985
|
+
if (/^\d+$/.test(pasteData)) {
|
|
986
|
+
const newOtp = pasteData.split("").slice(0, length);
|
|
987
|
+
setOtp(newOtp.concat(Array(length - newOtp.length).fill("")));
|
|
988
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
989
|
+
newOtp.forEach((_, idx) => {
|
|
990
|
+
if (inputRefs.current[idx]) {
|
|
991
|
+
inputRefs.current[idx]?.focus();
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
useEffect3(() => {
|
|
997
|
+
inputRefs.current[0]?.focus();
|
|
998
|
+
}, []);
|
|
999
|
+
return /* @__PURE__ */ React30.createElement("div", { className: props.containerClassName }, Array.from({ length }).map((_, index) => /* @__PURE__ */ React30.createElement(
|
|
1000
|
+
Input3,
|
|
1001
|
+
{
|
|
1002
|
+
key: index,
|
|
1003
|
+
className: props.className,
|
|
1004
|
+
maxLength: 1,
|
|
1005
|
+
value: otp[index],
|
|
1006
|
+
onChange: (e) => handleChange(e, index),
|
|
1007
|
+
onKeyDown: (e) => handleKeyDown(e, index),
|
|
1008
|
+
onPaste: handlePaste,
|
|
1009
|
+
ref: (el) => inputRefs.current[index] = el
|
|
1010
|
+
}
|
|
1011
|
+
)));
|
|
1012
|
+
};
|
|
884
1013
|
export {
|
|
885
1014
|
AddMoreTable,
|
|
886
1015
|
ButtonElement,
|
|
@@ -894,14 +1023,17 @@ export {
|
|
|
894
1023
|
MultipleSelectElement,
|
|
895
1024
|
Navbar,
|
|
896
1025
|
NumberElement,
|
|
1026
|
+
OtpElement,
|
|
897
1027
|
PasswordElement,
|
|
898
1028
|
RadioElement,
|
|
899
1029
|
SelectElement,
|
|
900
1030
|
Sidebar,
|
|
901
1031
|
SingleCheckbox,
|
|
902
1032
|
SingleSelectElement,
|
|
1033
|
+
SwitchElement,
|
|
903
1034
|
TableElement,
|
|
904
1035
|
TabsElement,
|
|
905
1036
|
TextElement,
|
|
906
|
-
TextareaElement
|
|
1037
|
+
TextareaElement,
|
|
1038
|
+
Upload2 as Upload
|
|
907
1039
|
};
|
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-Beta60",
|
|
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",
|