@apexcura/ui-components 0.0.14-Beta5 → 0.0.14-Beta51
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 +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +173 -86
- package/dist/index.mjs +182 -97
- package/package.json +1 -3
package/dist/index.css
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -26,6 +26,9 @@ type ElementType = {
|
|
|
26
26
|
fields?: any[];
|
|
27
27
|
schema?: any[];
|
|
28
28
|
options?: any[];
|
|
29
|
+
firstOptions?: any[];
|
|
30
|
+
secondOptions?: any[];
|
|
31
|
+
view?: boolean;
|
|
29
32
|
onChange?: (value: string | number | boolean | object | any[] | undefined) => void;
|
|
30
33
|
onClick?: () => void;
|
|
31
34
|
dropDownOptions?: any[];
|
|
@@ -57,6 +60,7 @@ type ElementType = {
|
|
|
57
60
|
containerClassName?: string;
|
|
58
61
|
selectBefore?: any[];
|
|
59
62
|
selectAfter?: any[];
|
|
63
|
+
isSVGStylesOverride?: boolean;
|
|
60
64
|
};
|
|
61
65
|
|
|
62
66
|
declare const TextElement: (props: ElementType) => React$1.JSX.Element;
|
|
@@ -82,7 +86,7 @@ declare const SingleSelectElement: (props: ElementType) => React$1.JSX.Element;
|
|
|
82
86
|
|
|
83
87
|
declare const MultipleSelectElement: (props: ElementType) => React$1.JSX.Element;
|
|
84
88
|
|
|
85
|
-
declare const ButtonElement: React$1.
|
|
89
|
+
declare const ButtonElement: (props: ElementType) => React$1.JSX.Element;
|
|
86
90
|
|
|
87
91
|
declare const AddMoreTable: (props: ElementType) => React$1.JSX.Element;
|
|
88
92
|
|
|
@@ -106,4 +110,8 @@ declare const FileUpload: (props: ElementType) => React$1.JSX.Element;
|
|
|
106
110
|
|
|
107
111
|
declare const TabsElement: (props: ElementType) => React$1.JSX.Element;
|
|
108
112
|
|
|
109
|
-
|
|
113
|
+
declare const SwitchElement: () => React$1.JSX.Element;
|
|
114
|
+
|
|
115
|
+
declare const Upload: (props: ElementType) => React$1.JSX.Element;
|
|
116
|
+
|
|
117
|
+
export { AddMoreTable, ButtonElement, CheckboxElement, CkEditor, DatePickerElement, DateRangePickerElement, DropDownGroup, FileUpload, Image, MultipleSelectElement, Navbar, NumberElement, PasswordElement, RadioElement, SelectElement, Sidebar, SingleCheckbox, SingleSelectElement, SwitchElement, TableElement, TabsElement, TextElement, TextareaElement, Upload };
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,9 @@ type ElementType = {
|
|
|
26
26
|
fields?: any[];
|
|
27
27
|
schema?: any[];
|
|
28
28
|
options?: any[];
|
|
29
|
+
firstOptions?: any[];
|
|
30
|
+
secondOptions?: any[];
|
|
31
|
+
view?: boolean;
|
|
29
32
|
onChange?: (value: string | number | boolean | object | any[] | undefined) => void;
|
|
30
33
|
onClick?: () => void;
|
|
31
34
|
dropDownOptions?: any[];
|
|
@@ -57,6 +60,7 @@ type ElementType = {
|
|
|
57
60
|
containerClassName?: string;
|
|
58
61
|
selectBefore?: any[];
|
|
59
62
|
selectAfter?: any[];
|
|
63
|
+
isSVGStylesOverride?: boolean;
|
|
60
64
|
};
|
|
61
65
|
|
|
62
66
|
declare const TextElement: (props: ElementType) => React$1.JSX.Element;
|
|
@@ -82,7 +86,7 @@ declare const SingleSelectElement: (props: ElementType) => React$1.JSX.Element;
|
|
|
82
86
|
|
|
83
87
|
declare const MultipleSelectElement: (props: ElementType) => React$1.JSX.Element;
|
|
84
88
|
|
|
85
|
-
declare const ButtonElement: React$1.
|
|
89
|
+
declare const ButtonElement: (props: ElementType) => React$1.JSX.Element;
|
|
86
90
|
|
|
87
91
|
declare const AddMoreTable: (props: ElementType) => React$1.JSX.Element;
|
|
88
92
|
|
|
@@ -106,4 +110,8 @@ declare const FileUpload: (props: ElementType) => React$1.JSX.Element;
|
|
|
106
110
|
|
|
107
111
|
declare const TabsElement: (props: ElementType) => React$1.JSX.Element;
|
|
108
112
|
|
|
109
|
-
|
|
113
|
+
declare const SwitchElement: () => React$1.JSX.Element;
|
|
114
|
+
|
|
115
|
+
declare const Upload: (props: ElementType) => React$1.JSX.Element;
|
|
116
|
+
|
|
117
|
+
export { AddMoreTable, ButtonElement, CheckboxElement, CkEditor, DatePickerElement, DateRangePickerElement, DropDownGroup, FileUpload, Image, MultipleSelectElement, Navbar, NumberElement, PasswordElement, RadioElement, SelectElement, Sidebar, SingleCheckbox, SingleSelectElement, SwitchElement, TableElement, TabsElement, TextElement, TextareaElement, Upload };
|
package/dist/index.js
CHANGED
|
@@ -48,10 +48,12 @@ __export(src_exports, {
|
|
|
48
48
|
Sidebar: () => Sidebar,
|
|
49
49
|
SingleCheckbox: () => SingleCheckbox,
|
|
50
50
|
SingleSelectElement: () => SingleSelectElement,
|
|
51
|
+
SwitchElement: () => SwitchElement,
|
|
51
52
|
TableElement: () => TableElement,
|
|
52
53
|
TabsElement: () => TabsElement,
|
|
53
54
|
TextElement: () => TextElement,
|
|
54
|
-
TextareaElement: () => TextareaElement
|
|
55
|
+
TextareaElement: () => TextareaElement,
|
|
56
|
+
Upload: () => Upload2
|
|
55
57
|
});
|
|
56
58
|
module.exports = __toCommonJS(src_exports);
|
|
57
59
|
|
|
@@ -70,6 +72,7 @@ var TextElement = (props) => {
|
|
|
70
72
|
placeholder: props.placeholder,
|
|
71
73
|
allowClear: true,
|
|
72
74
|
id: props.name,
|
|
75
|
+
value: props.value,
|
|
73
76
|
prefix: props.prefix,
|
|
74
77
|
type: props.type,
|
|
75
78
|
status: props.status,
|
|
@@ -129,8 +132,7 @@ var NumberElement = (props) => {
|
|
|
129
132
|
{
|
|
130
133
|
placeholder: props.placeholder,
|
|
131
134
|
addonBefore: props.addonBefore,
|
|
132
|
-
|
|
133
|
-
defaultValue: props.defaultValue,
|
|
135
|
+
value: props.value,
|
|
134
136
|
disabled: props.disabled,
|
|
135
137
|
id: props.name,
|
|
136
138
|
prefix: props.prefix,
|
|
@@ -375,13 +377,75 @@ var MultipleSelectElement = (props) => {
|
|
|
375
377
|
// src/Components/Button.tsx
|
|
376
378
|
var import_react11 = __toESM(require("react"));
|
|
377
379
|
var ButtonElement = (props) => {
|
|
380
|
+
const [svgContent, setSvgContent] = (0, import_react11.useState)(null);
|
|
381
|
+
const [originalSvgContent, setOriginalSvgContent] = (0, import_react11.useState)(null);
|
|
382
|
+
const [hoverColor, setHoverColor] = (0, import_react11.useState)(null);
|
|
383
|
+
(0, import_react11.useEffect)(() => {
|
|
384
|
+
if (props.icon) {
|
|
385
|
+
fetch(props.icon).then((response) => response.text()).then((data) => {
|
|
386
|
+
const tempDiv = document.createElement("div");
|
|
387
|
+
tempDiv.innerHTML = data;
|
|
388
|
+
const svgElement = tempDiv.querySelector("svg");
|
|
389
|
+
if (svgElement) {
|
|
390
|
+
const textColorClass = props.className?.match(/text-[\w-]+/g)?.[0];
|
|
391
|
+
const hoverColorClass = props.className?.match(/hover:text-[\w-]+/g)?.[0];
|
|
392
|
+
if (textColorClass) {
|
|
393
|
+
const tempSpan = document.createElement("span");
|
|
394
|
+
tempSpan.className = textColorClass;
|
|
395
|
+
document.body.appendChild(tempSpan);
|
|
396
|
+
const computedColor = getComputedStyle(tempSpan).color;
|
|
397
|
+
document.body.removeChild(tempSpan);
|
|
398
|
+
const paths = svgElement.querySelectorAll("path");
|
|
399
|
+
paths.forEach((path) => path.setAttribute("fill", computedColor));
|
|
400
|
+
}
|
|
401
|
+
if (hoverColorClass) {
|
|
402
|
+
const tempSpan = document.createElement("span");
|
|
403
|
+
tempSpan.className = hoverColorClass.replace("hover:", "");
|
|
404
|
+
document.body.appendChild(tempSpan);
|
|
405
|
+
const computedHoverColor = getComputedStyle(tempSpan).color;
|
|
406
|
+
document.body.removeChild(tempSpan);
|
|
407
|
+
setHoverColor(computedHoverColor);
|
|
408
|
+
}
|
|
409
|
+
svgElement.setAttribute(
|
|
410
|
+
"class",
|
|
411
|
+
`${props.className ? props.className : ""}`
|
|
412
|
+
);
|
|
413
|
+
setSvgContent(tempDiv.innerHTML);
|
|
414
|
+
setOriginalSvgContent(tempDiv.innerHTML);
|
|
415
|
+
}
|
|
416
|
+
}).catch((error) => console.error("Error fetching SVG:", error));
|
|
417
|
+
}
|
|
418
|
+
}, [props.icon, props.className]);
|
|
419
|
+
const handleMouseEnter = () => {
|
|
420
|
+
if (hoverColor && originalSvgContent) {
|
|
421
|
+
const tempDiv = document.createElement("div");
|
|
422
|
+
tempDiv.innerHTML = originalSvgContent;
|
|
423
|
+
const svgElement = tempDiv.querySelector("svg");
|
|
424
|
+
const paths = svgElement?.querySelectorAll("path");
|
|
425
|
+
paths?.forEach((path) => path.setAttribute("fill", hoverColor));
|
|
426
|
+
setSvgContent(tempDiv.innerHTML);
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
const handleMouseLeave = () => {
|
|
430
|
+
if (originalSvgContent) {
|
|
431
|
+
setSvgContent(originalSvgContent);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
378
434
|
return /* @__PURE__ */ import_react11.default.createElement(
|
|
379
435
|
"button",
|
|
380
436
|
{
|
|
381
|
-
onClick:
|
|
382
|
-
className: `${props.className ? props.className : ""}
|
|
437
|
+
onClick: props.onClick,
|
|
438
|
+
className: `${props.className ? props.className : ""}`,
|
|
439
|
+
onMouseEnter: handleMouseEnter,
|
|
440
|
+
onMouseLeave: handleMouseLeave
|
|
383
441
|
},
|
|
384
|
-
props.
|
|
442
|
+
props.isSVGStylesOverride ? svgContent && /* @__PURE__ */ import_react11.default.createElement(
|
|
443
|
+
"span",
|
|
444
|
+
{
|
|
445
|
+
className: "svg-container",
|
|
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 });
|
|
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 });
|
|
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
|
}
|
|
@@ -667,12 +731,6 @@ var TableElement = (props) => {
|
|
|
667
731
|
dataIndex: "#",
|
|
668
732
|
key: "#"
|
|
669
733
|
},
|
|
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
734
|
...thead.map((col, ind) => ({
|
|
677
735
|
title: col.label,
|
|
678
736
|
dataIndex: col.name,
|
|
@@ -689,6 +747,24 @@ var TableElement = (props) => {
|
|
|
689
747
|
}
|
|
690
748
|
}))
|
|
691
749
|
];
|
|
750
|
+
if (props.view) {
|
|
751
|
+
columns.push({
|
|
752
|
+
title: "View",
|
|
753
|
+
dataIndex: "View",
|
|
754
|
+
key: "View",
|
|
755
|
+
render: (_, record) => /* @__PURE__ */ import_react20.default.createElement(
|
|
756
|
+
"a",
|
|
757
|
+
{
|
|
758
|
+
onClick: () => {
|
|
759
|
+
setSelectedRecord(record);
|
|
760
|
+
handleChange(record);
|
|
761
|
+
setModel(true);
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
"View"
|
|
765
|
+
)
|
|
766
|
+
});
|
|
767
|
+
}
|
|
692
768
|
}
|
|
693
769
|
const dataSource = tbody && tbody.map((row, index) => ({
|
|
694
770
|
...row,
|
|
@@ -721,17 +797,7 @@ var TableElement = (props) => {
|
|
|
721
797
|
columns,
|
|
722
798
|
bordered: true,
|
|
723
799
|
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
|
-
}
|
|
800
|
+
size: props.size && props.size
|
|
735
801
|
}
|
|
736
802
|
), model && /* @__PURE__ */ import_react20.default.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
|
|
737
803
|
};
|
|
@@ -739,59 +805,40 @@ var TableElement = (props) => {
|
|
|
739
805
|
// src/Components/DatePicker.tsx
|
|
740
806
|
var import_react21 = __toESM(require("react"));
|
|
741
807
|
var import_antd15 = require("antd");
|
|
742
|
-
var
|
|
743
|
-
var
|
|
808
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
809
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
|
|
810
|
+
import_dayjs.default.extend(import_customParseFormat.default);
|
|
744
811
|
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);
|
|
812
|
+
const [dateState, setDateState] = (0, import_react21.useState)("");
|
|
813
|
+
const handleChange = (date, dateString) => {
|
|
814
|
+
if (date) {
|
|
815
|
+
const formattedDate = date;
|
|
816
|
+
setDateState(date);
|
|
754
817
|
if (props.onChange) {
|
|
755
818
|
props.onChange(formattedDate);
|
|
756
819
|
}
|
|
757
820
|
} else {
|
|
758
|
-
|
|
821
|
+
setDateState("");
|
|
759
822
|
if (props.onChange) {
|
|
760
823
|
props.onChange("");
|
|
761
824
|
}
|
|
762
825
|
}
|
|
763
826
|
};
|
|
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(
|
|
827
|
+
return /* @__PURE__ */ import_react21.default.createElement("div", null, /* @__PURE__ */ import_react21.default.createElement(
|
|
781
828
|
import_antd15.DatePicker,
|
|
782
829
|
{
|
|
783
830
|
placeholder: props.placeholder,
|
|
784
|
-
value:
|
|
785
|
-
|
|
831
|
+
value: dateState,
|
|
832
|
+
format: { format: "DD-MM-YYYY" },
|
|
786
833
|
onChange: handleChange
|
|
787
834
|
}
|
|
788
|
-
)
|
|
835
|
+
));
|
|
789
836
|
};
|
|
790
837
|
|
|
791
838
|
// src/Components/DateRangePickerElement.tsx
|
|
792
839
|
var import_react22 = __toESM(require("react"));
|
|
793
840
|
var import_antd16 = require("antd");
|
|
794
|
-
var
|
|
841
|
+
var import_dayjs2 = __toESM(require("dayjs"));
|
|
795
842
|
var DateRangePickerElement = (props) => {
|
|
796
843
|
const { RangePicker } = import_antd16.DatePicker;
|
|
797
844
|
const handleChange = (dates, dateStrings) => {
|
|
@@ -802,10 +849,10 @@ var DateRangePickerElement = (props) => {
|
|
|
802
849
|
}
|
|
803
850
|
};
|
|
804
851
|
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,
|
|
852
|
+
{ label: "Last 7 Days", value: [(0, import_dayjs2.default)().add(-7, "d"), (0, import_dayjs2.default)()] },
|
|
853
|
+
{ label: "Last 14 Days", value: [(0, import_dayjs2.default)().add(-14, "d"), (0, import_dayjs2.default)()] },
|
|
854
|
+
{ label: "Last 30 Days", value: [(0, import_dayjs2.default)().add(-30, "d"), (0, import_dayjs2.default)()] },
|
|
855
|
+
{ label: "Last 90 Days", value: [(0, import_dayjs2.default)().add(-90, "d"), (0, import_dayjs2.default)()] }
|
|
809
856
|
];
|
|
810
857
|
return /* @__PURE__ */ import_react22.default.createElement(import_antd16.Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ import_react22.default.createElement(RangePicker, { presets: rangePresets, onChange: handleChange }));
|
|
811
858
|
};
|
|
@@ -813,7 +860,7 @@ var DateRangePickerElement = (props) => {
|
|
|
813
860
|
// src/Components/Image.tsx
|
|
814
861
|
var import_react23 = __toESM(require("react"));
|
|
815
862
|
var Image = (props) => {
|
|
816
|
-
return /* @__PURE__ */ import_react23.default.createElement("
|
|
863
|
+
return /* @__PURE__ */ import_react23.default.createElement("img", { className: props.className, src: props.img, alt: "image" });
|
|
817
864
|
};
|
|
818
865
|
|
|
819
866
|
// src/Components/SingleCheckbox.tsx
|
|
@@ -832,33 +879,44 @@ var SingleCheckbox = (props) => {
|
|
|
832
879
|
var import_react25 = __toESM(require("react"));
|
|
833
880
|
var import_antd18 = require("antd");
|
|
834
881
|
var DropDownGroup = (props) => {
|
|
835
|
-
const [selectedValue, setSelectedValue] = (0, import_react25.useState)({
|
|
882
|
+
const [selectedValue, setSelectedValue] = (0, import_react25.useState)({
|
|
883
|
+
firstValue: {},
|
|
884
|
+
secondValue: {},
|
|
885
|
+
temp: ""
|
|
886
|
+
});
|
|
836
887
|
const handleFirstChange = (value) => {
|
|
837
|
-
|
|
888
|
+
console.log(selectedValue.temp);
|
|
889
|
+
const filterOption2 = props.firstOptions?.find(
|
|
890
|
+
(eachOption) => eachOption.value === value
|
|
891
|
+
);
|
|
838
892
|
setSelectedValue((prev) => {
|
|
839
893
|
const newValue = { ...prev, firstValue: filterOption2 };
|
|
894
|
+
const { temp, ...rest } = newValue;
|
|
840
895
|
if (newValue.firstValue) {
|
|
841
|
-
props.onChange?.(
|
|
896
|
+
props.onChange?.(rest);
|
|
842
897
|
}
|
|
843
|
-
return
|
|
898
|
+
return newValue;
|
|
844
899
|
});
|
|
845
900
|
};
|
|
846
901
|
const handleSecondChange = (value) => {
|
|
847
|
-
const filterOption2 = props.
|
|
902
|
+
const filterOption2 = props.secondOptions?.find(
|
|
903
|
+
(eachOption) => eachOption.value === value
|
|
904
|
+
);
|
|
848
905
|
setSelectedValue((prev) => {
|
|
849
906
|
const newValue = { ...prev, secondValue: filterOption2 };
|
|
907
|
+
const { temp, ...rest } = newValue;
|
|
850
908
|
if (newValue.secondValue) {
|
|
851
|
-
props.onChange?.(
|
|
909
|
+
props.onChange?.(rest);
|
|
852
910
|
}
|
|
853
|
-
return
|
|
911
|
+
return newValue;
|
|
854
912
|
});
|
|
855
913
|
};
|
|
856
|
-
return /* @__PURE__ */ import_react25.default.createElement("div", { className: props.containerClassName }, /* @__PURE__ */ import_react25.default.createElement(
|
|
914
|
+
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(
|
|
857
915
|
import_antd18.Select,
|
|
858
916
|
{
|
|
859
917
|
onChange: handleFirstChange,
|
|
860
918
|
variant: props.variant,
|
|
861
|
-
options: props.
|
|
919
|
+
options: props.firstOptions,
|
|
862
920
|
className: props.className
|
|
863
921
|
}
|
|
864
922
|
), /* @__PURE__ */ import_react25.default.createElement("div", { style: { borderLeft: "1px solid gray", height: "33px" } }), /* @__PURE__ */ import_react25.default.createElement(
|
|
@@ -866,27 +924,19 @@ var DropDownGroup = (props) => {
|
|
|
866
924
|
{
|
|
867
925
|
onChange: handleSecondChange,
|
|
868
926
|
variant: props.variant,
|
|
869
|
-
options: props.
|
|
927
|
+
options: props.secondOptions,
|
|
870
928
|
className: props.className
|
|
871
929
|
}
|
|
872
|
-
));
|
|
930
|
+
)));
|
|
873
931
|
};
|
|
874
932
|
|
|
875
933
|
// src/Components/FilesUpload.tsx
|
|
876
934
|
var import_react26 = __toESM(require("react"));
|
|
877
935
|
var import_antd19 = require("antd");
|
|
878
|
-
var
|
|
936
|
+
var import_icons4 = require("@ant-design/icons");
|
|
879
937
|
var FileUpload = (props) => {
|
|
880
938
|
const { Dragger } = import_antd19.Upload;
|
|
881
939
|
const [files, setFiles] = (0, import_react26.useState)([]);
|
|
882
|
-
const beforeUpload = (file) => {
|
|
883
|
-
const isCorrectFile = ["image/png", "image/jpg", "image/jpeg", "application/pdf"].includes(file.type);
|
|
884
|
-
if (!isCorrectFile) {
|
|
885
|
-
import_antd19.message.error(`(${file.name}) is an invalid file. Please upload files with the following extensions only (.png/.jpg/.jpeg/.pdf)`);
|
|
886
|
-
return import_antd19.Upload.LIST_IGNORE;
|
|
887
|
-
}
|
|
888
|
-
return true;
|
|
889
|
-
};
|
|
890
940
|
const handleChange = ({ fileList }) => {
|
|
891
941
|
setFiles(fileList);
|
|
892
942
|
if (props.onChange) {
|
|
@@ -910,12 +960,11 @@ var FileUpload = (props) => {
|
|
|
910
960
|
maxCount: props.max_count,
|
|
911
961
|
multiple: props.multiple,
|
|
912
962
|
fileList: files,
|
|
913
|
-
beforeUpload,
|
|
914
963
|
onChange: handleChange,
|
|
915
964
|
showUploadList: true,
|
|
916
965
|
customRequest
|
|
917
966
|
},
|
|
918
|
-
/* @__PURE__ */ import_react26.default.createElement("p", null, /* @__PURE__ */ import_react26.default.createElement(
|
|
967
|
+
/* @__PURE__ */ import_react26.default.createElement("p", null, /* @__PURE__ */ import_react26.default.createElement(import_icons4.InboxOutlined, null)),
|
|
919
968
|
/* @__PURE__ */ import_react26.default.createElement("p", null, "Click or drag file to upload")
|
|
920
969
|
));
|
|
921
970
|
};
|
|
@@ -931,6 +980,42 @@ var TabsElement = (props) => {
|
|
|
931
980
|
};
|
|
932
981
|
return /* @__PURE__ */ import_react27.default.createElement(import_antd20.Tabs, { className: props.containerClassName, items: props.options, onChange: handleChange });
|
|
933
982
|
};
|
|
983
|
+
|
|
984
|
+
// src/Components/SwitchElement.tsx
|
|
985
|
+
var import_react28 = __toESM(require("react"));
|
|
986
|
+
var import_antd21 = require("antd");
|
|
987
|
+
var onChange = (checked) => {
|
|
988
|
+
console.log(`switch to ${checked}`);
|
|
989
|
+
};
|
|
990
|
+
var SwitchElement = () => /* @__PURE__ */ import_react28.default.createElement(import_antd21.Switch, { defaultChecked: true, onChange });
|
|
991
|
+
|
|
992
|
+
// src/Components/Upload.tsx
|
|
993
|
+
var import_react29 = __toESM(require("react"));
|
|
994
|
+
var Upload2 = (props) => {
|
|
995
|
+
const [file, setFile] = (0, import_react29.useState)();
|
|
996
|
+
const handleFileChange = (e) => {
|
|
997
|
+
setFile(e.target.files[0]);
|
|
998
|
+
if (props.onChange) {
|
|
999
|
+
props.onChange(e.target.files[0]);
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
const handleUpload = async () => {
|
|
1003
|
+
if (!file) {
|
|
1004
|
+
console.error("No file selected");
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
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(
|
|
1009
|
+
"button",
|
|
1010
|
+
{
|
|
1011
|
+
type: "button",
|
|
1012
|
+
onClick: handleUpload,
|
|
1013
|
+
disabled: !file,
|
|
1014
|
+
style: { marginTop: 16 }
|
|
1015
|
+
},
|
|
1016
|
+
"Upload"
|
|
1017
|
+
));
|
|
1018
|
+
};
|
|
934
1019
|
// Annotate the CommonJS export names for ESM import in node:
|
|
935
1020
|
0 && (module.exports = {
|
|
936
1021
|
AddMoreTable,
|
|
@@ -951,8 +1036,10 @@ var TabsElement = (props) => {
|
|
|
951
1036
|
Sidebar,
|
|
952
1037
|
SingleCheckbox,
|
|
953
1038
|
SingleSelectElement,
|
|
1039
|
+
SwitchElement,
|
|
954
1040
|
TableElement,
|
|
955
1041
|
TabsElement,
|
|
956
1042
|
TextElement,
|
|
957
|
-
TextareaElement
|
|
1043
|
+
TextareaElement,
|
|
1044
|
+
Upload
|
|
958
1045
|
});
|
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,88 @@ 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.className ? props.className : ""}`
|
|
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
|
+
className: "svg-container",
|
|
387
|
+
dangerouslySetInnerHTML: { __html: svgContent }
|
|
388
|
+
}
|
|
389
|
+
) : props.icon && /* @__PURE__ */ React11.createElement("img", { className: props.iconsClassName, src: props.icon, alt: props.label }),
|
|
328
390
|
props.label
|
|
329
391
|
);
|
|
330
392
|
};
|
|
331
393
|
|
|
332
394
|
// src/Components/AddMoreTable.tsx
|
|
333
|
-
import React12, { useEffect, useState as
|
|
395
|
+
import React12, { useEffect as useEffect2, useState as useState5 } from "react";
|
|
334
396
|
import { Table, Button } from "antd";
|
|
335
397
|
import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
|
|
336
398
|
var AddMoreTable = (props) => {
|
|
337
399
|
const { thead, tbody } = props;
|
|
338
|
-
const [rows, setRows] =
|
|
400
|
+
const [rows, setRows] = useState5(tbody || []);
|
|
339
401
|
const onHandleRows = () => {
|
|
340
402
|
const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
|
|
341
403
|
let newRow = {
|
|
@@ -400,16 +462,16 @@ var AddMoreTable = (props) => {
|
|
|
400
462
|
});
|
|
401
463
|
});
|
|
402
464
|
};
|
|
403
|
-
|
|
465
|
+
useEffect2(() => {
|
|
404
466
|
console.log(rows);
|
|
405
467
|
}, [rows]);
|
|
406
468
|
const renderInputElement = (element, value) => {
|
|
407
469
|
if (!element) return null;
|
|
408
470
|
const { element: type, label } = element;
|
|
409
471
|
if (type === "single-select") {
|
|
410
|
-
return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
|
|
472
|
+
return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [], firstOptions: [], secondOptions: [] });
|
|
411
473
|
} else if (type === "textarea") {
|
|
412
|
-
return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
|
|
474
|
+
return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [], firstOptions: [], secondOptions: [] });
|
|
413
475
|
} else {
|
|
414
476
|
return null;
|
|
415
477
|
}
|
|
@@ -535,8 +597,8 @@ var Navbar = (props) => {
|
|
|
535
597
|
};
|
|
536
598
|
|
|
537
599
|
// src/Components/TableElement.tsx
|
|
538
|
-
import React20, { useState as
|
|
539
|
-
import {
|
|
600
|
+
import React20, { useState as useState6 } from "react";
|
|
601
|
+
import { Table as Table2 } from "antd";
|
|
540
602
|
|
|
541
603
|
// src/Components/Model.tsx
|
|
542
604
|
import React19 from "react";
|
|
@@ -593,9 +655,9 @@ var ModelElement = (props) => {
|
|
|
593
655
|
// src/Components/TableElement.tsx
|
|
594
656
|
var TableElement = (props) => {
|
|
595
657
|
const { thead, tbody } = props;
|
|
596
|
-
const [selectedRecord, setSelectedRecord] =
|
|
597
|
-
const [model, setModel] =
|
|
598
|
-
const [selectedRowKeys, setSelectedRowKeys] =
|
|
658
|
+
const [selectedRecord, setSelectedRecord] = useState6({});
|
|
659
|
+
const [model, setModel] = useState6(false);
|
|
660
|
+
const [selectedRowKeys, setSelectedRowKeys] = useState6([]);
|
|
599
661
|
const handleChange = (record) => {
|
|
600
662
|
console.log("record", record);
|
|
601
663
|
if (props.onChange) {
|
|
@@ -610,12 +672,6 @@ var TableElement = (props) => {
|
|
|
610
672
|
dataIndex: "#",
|
|
611
673
|
key: "#"
|
|
612
674
|
},
|
|
613
|
-
{
|
|
614
|
-
title: "View",
|
|
615
|
-
dataIndex: "View",
|
|
616
|
-
key: "View",
|
|
617
|
-
render: (_, record) => /* @__PURE__ */ React20.createElement(Button3, null, "View")
|
|
618
|
-
},
|
|
619
675
|
...thead.map((col, ind) => ({
|
|
620
676
|
title: col.label,
|
|
621
677
|
dataIndex: col.name,
|
|
@@ -632,6 +688,24 @@ var TableElement = (props) => {
|
|
|
632
688
|
}
|
|
633
689
|
}))
|
|
634
690
|
];
|
|
691
|
+
if (props.view) {
|
|
692
|
+
columns.push({
|
|
693
|
+
title: "View",
|
|
694
|
+
dataIndex: "View",
|
|
695
|
+
key: "View",
|
|
696
|
+
render: (_, record) => /* @__PURE__ */ React20.createElement(
|
|
697
|
+
"a",
|
|
698
|
+
{
|
|
699
|
+
onClick: () => {
|
|
700
|
+
setSelectedRecord(record);
|
|
701
|
+
handleChange(record);
|
|
702
|
+
setModel(true);
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
"View"
|
|
706
|
+
)
|
|
707
|
+
});
|
|
708
|
+
}
|
|
635
709
|
}
|
|
636
710
|
const dataSource = tbody && tbody.map((row, index) => ({
|
|
637
711
|
...row,
|
|
@@ -664,77 +738,48 @@ var TableElement = (props) => {
|
|
|
664
738
|
columns,
|
|
665
739
|
bordered: true,
|
|
666
740
|
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
|
-
}
|
|
741
|
+
size: props.size && props.size
|
|
678
742
|
}
|
|
679
743
|
), model && /* @__PURE__ */ React20.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
|
|
680
744
|
};
|
|
681
745
|
|
|
682
746
|
// src/Components/DatePicker.tsx
|
|
683
|
-
import React21, { useState as
|
|
747
|
+
import React21, { useState as useState7 } from "react";
|
|
684
748
|
import { DatePicker } from "antd";
|
|
685
|
-
import
|
|
686
|
-
import
|
|
749
|
+
import dayjs from "dayjs";
|
|
750
|
+
import customParseFormat from "dayjs/plugin/customParseFormat.js";
|
|
751
|
+
dayjs.extend(customParseFormat);
|
|
687
752
|
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);
|
|
753
|
+
const [dateState, setDateState] = useState7("");
|
|
754
|
+
const handleChange = (date, dateString) => {
|
|
755
|
+
if (date) {
|
|
756
|
+
const formattedDate = date;
|
|
757
|
+
setDateState(date);
|
|
697
758
|
if (props.onChange) {
|
|
698
759
|
props.onChange(formattedDate);
|
|
699
760
|
}
|
|
700
761
|
} else {
|
|
701
|
-
|
|
762
|
+
setDateState("");
|
|
702
763
|
if (props.onChange) {
|
|
703
764
|
props.onChange("");
|
|
704
765
|
}
|
|
705
766
|
}
|
|
706
767
|
};
|
|
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(
|
|
768
|
+
return /* @__PURE__ */ React21.createElement("div", null, /* @__PURE__ */ React21.createElement(
|
|
724
769
|
DatePicker,
|
|
725
770
|
{
|
|
726
771
|
placeholder: props.placeholder,
|
|
727
|
-
value:
|
|
728
|
-
|
|
772
|
+
value: dateState,
|
|
773
|
+
format: { format: "DD-MM-YYYY" },
|
|
729
774
|
onChange: handleChange
|
|
730
775
|
}
|
|
731
|
-
)
|
|
776
|
+
));
|
|
732
777
|
};
|
|
733
778
|
|
|
734
779
|
// src/Components/DateRangePickerElement.tsx
|
|
735
780
|
import React22 from "react";
|
|
736
781
|
import { DatePicker as DatePicker2, Space } from "antd";
|
|
737
|
-
import
|
|
782
|
+
import dayjs2 from "dayjs";
|
|
738
783
|
var DateRangePickerElement = (props) => {
|
|
739
784
|
const { RangePicker } = DatePicker2;
|
|
740
785
|
const handleChange = (dates, dateStrings) => {
|
|
@@ -745,10 +790,10 @@ var DateRangePickerElement = (props) => {
|
|
|
745
790
|
}
|
|
746
791
|
};
|
|
747
792
|
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: [
|
|
793
|
+
{ label: "Last 7 Days", value: [dayjs2().add(-7, "d"), dayjs2()] },
|
|
794
|
+
{ label: "Last 14 Days", value: [dayjs2().add(-14, "d"), dayjs2()] },
|
|
795
|
+
{ label: "Last 30 Days", value: [dayjs2().add(-30, "d"), dayjs2()] },
|
|
796
|
+
{ label: "Last 90 Days", value: [dayjs2().add(-90, "d"), dayjs2()] }
|
|
752
797
|
];
|
|
753
798
|
return /* @__PURE__ */ React22.createElement(Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ React22.createElement(RangePicker, { presets: rangePresets, onChange: handleChange }));
|
|
754
799
|
};
|
|
@@ -756,7 +801,7 @@ var DateRangePickerElement = (props) => {
|
|
|
756
801
|
// src/Components/Image.tsx
|
|
757
802
|
import React23 from "react";
|
|
758
803
|
var Image = (props) => {
|
|
759
|
-
return /* @__PURE__ */ React23.createElement("
|
|
804
|
+
return /* @__PURE__ */ React23.createElement("img", { className: props.className, src: props.img, alt: "image" });
|
|
760
805
|
};
|
|
761
806
|
|
|
762
807
|
// src/Components/SingleCheckbox.tsx
|
|
@@ -772,36 +817,47 @@ var SingleCheckbox = (props) => {
|
|
|
772
817
|
};
|
|
773
818
|
|
|
774
819
|
// src/Components/DropDownGroup.tsx
|
|
775
|
-
import React25, { useState as
|
|
820
|
+
import React25, { useState as useState8 } from "react";
|
|
776
821
|
import { Select as Select4 } from "antd";
|
|
777
822
|
var DropDownGroup = (props) => {
|
|
778
|
-
const [selectedValue, setSelectedValue] =
|
|
823
|
+
const [selectedValue, setSelectedValue] = useState8({
|
|
824
|
+
firstValue: {},
|
|
825
|
+
secondValue: {},
|
|
826
|
+
temp: ""
|
|
827
|
+
});
|
|
779
828
|
const handleFirstChange = (value) => {
|
|
780
|
-
|
|
829
|
+
console.log(selectedValue.temp);
|
|
830
|
+
const filterOption2 = props.firstOptions?.find(
|
|
831
|
+
(eachOption) => eachOption.value === value
|
|
832
|
+
);
|
|
781
833
|
setSelectedValue((prev) => {
|
|
782
834
|
const newValue = { ...prev, firstValue: filterOption2 };
|
|
835
|
+
const { temp, ...rest } = newValue;
|
|
783
836
|
if (newValue.firstValue) {
|
|
784
|
-
props.onChange?.(
|
|
837
|
+
props.onChange?.(rest);
|
|
785
838
|
}
|
|
786
|
-
return
|
|
839
|
+
return newValue;
|
|
787
840
|
});
|
|
788
841
|
};
|
|
789
842
|
const handleSecondChange = (value) => {
|
|
790
|
-
const filterOption2 = props.
|
|
843
|
+
const filterOption2 = props.secondOptions?.find(
|
|
844
|
+
(eachOption) => eachOption.value === value
|
|
845
|
+
);
|
|
791
846
|
setSelectedValue((prev) => {
|
|
792
847
|
const newValue = { ...prev, secondValue: filterOption2 };
|
|
848
|
+
const { temp, ...rest } = newValue;
|
|
793
849
|
if (newValue.secondValue) {
|
|
794
|
-
props.onChange?.(
|
|
850
|
+
props.onChange?.(rest);
|
|
795
851
|
}
|
|
796
|
-
return
|
|
852
|
+
return newValue;
|
|
797
853
|
});
|
|
798
854
|
};
|
|
799
|
-
return /* @__PURE__ */ React25.createElement("div", { className: props.containerClassName }, /* @__PURE__ */ React25.createElement(
|
|
855
|
+
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(
|
|
800
856
|
Select4,
|
|
801
857
|
{
|
|
802
858
|
onChange: handleFirstChange,
|
|
803
859
|
variant: props.variant,
|
|
804
|
-
options: props.
|
|
860
|
+
options: props.firstOptions,
|
|
805
861
|
className: props.className
|
|
806
862
|
}
|
|
807
863
|
), /* @__PURE__ */ React25.createElement("div", { style: { borderLeft: "1px solid gray", height: "33px" } }), /* @__PURE__ */ React25.createElement(
|
|
@@ -809,27 +865,19 @@ var DropDownGroup = (props) => {
|
|
|
809
865
|
{
|
|
810
866
|
onChange: handleSecondChange,
|
|
811
867
|
variant: props.variant,
|
|
812
|
-
options: props.
|
|
868
|
+
options: props.secondOptions,
|
|
813
869
|
className: props.className
|
|
814
870
|
}
|
|
815
|
-
));
|
|
871
|
+
)));
|
|
816
872
|
};
|
|
817
873
|
|
|
818
874
|
// src/Components/FilesUpload.tsx
|
|
819
|
-
import React26, { useState as
|
|
820
|
-
import { Upload
|
|
875
|
+
import React26, { useState as useState9 } from "react";
|
|
876
|
+
import { Upload } from "antd";
|
|
821
877
|
import { InboxOutlined } from "@ant-design/icons";
|
|
822
878
|
var FileUpload = (props) => {
|
|
823
879
|
const { Dragger } = Upload;
|
|
824
|
-
const [files, setFiles] =
|
|
825
|
-
const beforeUpload = (file) => {
|
|
826
|
-
const isCorrectFile = ["image/png", "image/jpg", "image/jpeg", "application/pdf"].includes(file.type);
|
|
827
|
-
if (!isCorrectFile) {
|
|
828
|
-
message.error(`(${file.name}) is an invalid file. Please upload files with the following extensions only (.png/.jpg/.jpeg/.pdf)`);
|
|
829
|
-
return Upload.LIST_IGNORE;
|
|
830
|
-
}
|
|
831
|
-
return true;
|
|
832
|
-
};
|
|
880
|
+
const [files, setFiles] = useState9([]);
|
|
833
881
|
const handleChange = ({ fileList }) => {
|
|
834
882
|
setFiles(fileList);
|
|
835
883
|
if (props.onChange) {
|
|
@@ -853,7 +901,6 @@ var FileUpload = (props) => {
|
|
|
853
901
|
maxCount: props.max_count,
|
|
854
902
|
multiple: props.multiple,
|
|
855
903
|
fileList: files,
|
|
856
|
-
beforeUpload,
|
|
857
904
|
onChange: handleChange,
|
|
858
905
|
showUploadList: true,
|
|
859
906
|
customRequest
|
|
@@ -874,6 +921,42 @@ var TabsElement = (props) => {
|
|
|
874
921
|
};
|
|
875
922
|
return /* @__PURE__ */ React27.createElement(Tabs, { className: props.containerClassName, items: props.options, onChange: handleChange });
|
|
876
923
|
};
|
|
924
|
+
|
|
925
|
+
// src/Components/SwitchElement.tsx
|
|
926
|
+
import React28 from "react";
|
|
927
|
+
import { Switch } from "antd";
|
|
928
|
+
var onChange = (checked) => {
|
|
929
|
+
console.log(`switch to ${checked}`);
|
|
930
|
+
};
|
|
931
|
+
var SwitchElement = () => /* @__PURE__ */ React28.createElement(Switch, { defaultChecked: true, onChange });
|
|
932
|
+
|
|
933
|
+
// src/Components/Upload.tsx
|
|
934
|
+
import React29, { useState as useState10 } from "react";
|
|
935
|
+
var Upload2 = (props) => {
|
|
936
|
+
const [file, setFile] = useState10();
|
|
937
|
+
const handleFileChange = (e) => {
|
|
938
|
+
setFile(e.target.files[0]);
|
|
939
|
+
if (props.onChange) {
|
|
940
|
+
props.onChange(e.target.files[0]);
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
const handleUpload = async () => {
|
|
944
|
+
if (!file) {
|
|
945
|
+
console.error("No file selected");
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
return /* @__PURE__ */ React29.createElement("div", { style: { marginTop: 16 } }, /* @__PURE__ */ React29.createElement("input", { type: "file", onChange: handleFileChange }), /* @__PURE__ */ React29.createElement(
|
|
950
|
+
"button",
|
|
951
|
+
{
|
|
952
|
+
type: "button",
|
|
953
|
+
onClick: handleUpload,
|
|
954
|
+
disabled: !file,
|
|
955
|
+
style: { marginTop: 16 }
|
|
956
|
+
},
|
|
957
|
+
"Upload"
|
|
958
|
+
));
|
|
959
|
+
};
|
|
877
960
|
export {
|
|
878
961
|
AddMoreTable,
|
|
879
962
|
ButtonElement,
|
|
@@ -893,8 +976,10 @@ export {
|
|
|
893
976
|
Sidebar,
|
|
894
977
|
SingleCheckbox,
|
|
895
978
|
SingleSelectElement,
|
|
979
|
+
SwitchElement,
|
|
896
980
|
TableElement,
|
|
897
981
|
TabsElement,
|
|
898
982
|
TextElement,
|
|
899
|
-
TextareaElement
|
|
983
|
+
TextareaElement,
|
|
984
|
+
Upload2 as Upload
|
|
900
985
|
};
|
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-Beta51",
|
|
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",
|