@apexcura/ui-components 0.0.12 → 0.0.13-Beta1
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 +440 -0
- package/dist/index.d.mts +50 -9
- package/dist/index.d.ts +50 -9
- package/dist/index.js +464 -24
- package/dist/index.mjs +463 -28
- package/package.json +12 -3
- package/postcss.config.js +6 -0
- package/tailwind.config.js +10 -0
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Input as AntInput } from "antd";
|
|
4
4
|
var TextElement = (props) => {
|
|
5
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("label", { htmlFor: props.name }, props.label), /* @__PURE__ */ React.createElement(
|
|
5
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.label && /* @__PURE__ */ React.createElement("label", { htmlFor: props.name }, props.label), /* @__PURE__ */ React.createElement(
|
|
6
6
|
AntInput,
|
|
7
7
|
{
|
|
8
8
|
placeholder: props.placeholder,
|
|
@@ -15,7 +15,7 @@ var TextElement = (props) => {
|
|
|
15
15
|
type: props.type,
|
|
16
16
|
status: props.status,
|
|
17
17
|
style: props.styles,
|
|
18
|
-
className: props.
|
|
18
|
+
className: props.className,
|
|
19
19
|
variant: props.variant,
|
|
20
20
|
name: props.name,
|
|
21
21
|
onChange: (e) => props.onChange(e.target.value)
|
|
@@ -56,7 +56,7 @@ var NumberElement = (props) => {
|
|
|
56
56
|
const newValue = e.target.value.replace(/[^0-9]/g, "");
|
|
57
57
|
props.onChange(newValue);
|
|
58
58
|
};
|
|
59
|
-
return /* @__PURE__ */ React3.createElement(
|
|
59
|
+
return /* @__PURE__ */ React3.createElement(
|
|
60
60
|
AntInput2,
|
|
61
61
|
{
|
|
62
62
|
placeholder: props.placeholder,
|
|
@@ -68,13 +68,12 @@ var NumberElement = (props) => {
|
|
|
68
68
|
prefix: props.prefix,
|
|
69
69
|
type: props.type,
|
|
70
70
|
status: props.status,
|
|
71
|
-
|
|
72
|
-
className: props.classNames,
|
|
71
|
+
className: props.className,
|
|
73
72
|
variant: props.variant,
|
|
74
73
|
name: props.name,
|
|
75
74
|
onChange: handleInputChange
|
|
76
75
|
}
|
|
77
|
-
)
|
|
76
|
+
);
|
|
78
77
|
};
|
|
79
78
|
|
|
80
79
|
// src/Components/TextareaElement.tsx
|
|
@@ -82,7 +81,7 @@ import React4 from "react";
|
|
|
82
81
|
import { Flex, Input as Input2 } from "antd";
|
|
83
82
|
var { TextArea } = Input2;
|
|
84
83
|
var TextareaElement = (props) => {
|
|
85
|
-
return /* @__PURE__ */ React4.createElement(Flex,
|
|
84
|
+
return /* @__PURE__ */ React4.createElement(Flex, null, /* @__PURE__ */ React4.createElement(
|
|
86
85
|
TextArea,
|
|
87
86
|
{
|
|
88
87
|
placeholder: props.placeholder,
|
|
@@ -91,8 +90,7 @@ var TextareaElement = (props) => {
|
|
|
91
90
|
disabled: props.disabled,
|
|
92
91
|
id: props.name,
|
|
93
92
|
status: props.status,
|
|
94
|
-
|
|
95
|
-
className: props.classNames,
|
|
93
|
+
className: props.className,
|
|
96
94
|
variant: props.variant,
|
|
97
95
|
name: props.name,
|
|
98
96
|
showCount: true,
|
|
@@ -130,7 +128,7 @@ var SelectElement = (props) => {
|
|
|
130
128
|
id: props.name,
|
|
131
129
|
status: props.status,
|
|
132
130
|
style: props.styles,
|
|
133
|
-
className: props.
|
|
131
|
+
className: props.className,
|
|
134
132
|
variant: props.variant,
|
|
135
133
|
onChange: handleChange
|
|
136
134
|
}
|
|
@@ -138,27 +136,57 @@ var SelectElement = (props) => {
|
|
|
138
136
|
};
|
|
139
137
|
|
|
140
138
|
// src/Components/RadioElement.tsx
|
|
141
|
-
import React6 from "react";
|
|
139
|
+
import React6, { useState as useState2 } from "react";
|
|
142
140
|
import { Radio } from "antd";
|
|
141
|
+
var radioDefaultStyle = "bg-[#F2F2F2] border border-[#919191] rounded-[8px] m-[10px] hover:bg-[#F2F2F2] text-center text-black shadow-[0px_0px_1px_1px_#919191]";
|
|
142
|
+
var radioSelectedDefaultStyle = "bg-[#E2D6F8] border border-[#B8A4DE] rounded-[8px] p-[6px] m-[10px] shadow-[0px_0px_1px_1px_#B8A4DE] text-center text-black shadow-[0px_0px_1px_1px_#919191]";
|
|
143
143
|
var RadioElement = (props) => {
|
|
144
|
-
const
|
|
144
|
+
const [isDisabled, setIsDisabled] = useState2(props.disabled);
|
|
145
|
+
const [selectedValue, setSelectedValue] = useState2(props.value);
|
|
146
|
+
const optionType = props.optionType === "button" ? "button" : void 0;
|
|
147
|
+
const handleChange = (option) => {
|
|
148
|
+
console.log(option);
|
|
149
|
+
setSelectedValue(option);
|
|
150
|
+
setIsDisabled(true);
|
|
145
151
|
if (props.onChange) {
|
|
146
|
-
|
|
147
|
-
const selectedOptions = [{ id: selectedVal, value: selectedVal }];
|
|
148
|
-
props.onChange(selectedOptions);
|
|
152
|
+
props.onChange(option);
|
|
149
153
|
}
|
|
150
154
|
};
|
|
151
|
-
|
|
155
|
+
const getButtonStyle = (option) => {
|
|
156
|
+
return selectedValue === option.value ? `${radioSelectedDefaultStyle} ${props.activeClassName}` : `${radioDefaultStyle} ${props.className}`;
|
|
157
|
+
};
|
|
158
|
+
return /* @__PURE__ */ React6.createElement("div", { className: props.containerClassName }, props.label && /* @__PURE__ */ React6.createElement("p", { className: props.labelClassName }, props.label), /* @__PURE__ */ React6.createElement(
|
|
159
|
+
Radio.Group,
|
|
160
|
+
{
|
|
161
|
+
optionType,
|
|
162
|
+
className: props.radioGroupClassName,
|
|
163
|
+
value: selectedValue
|
|
164
|
+
},
|
|
165
|
+
props.options && props.options.map((option) => /* @__PURE__ */ React6.createElement(
|
|
166
|
+
Radio,
|
|
167
|
+
{
|
|
168
|
+
onChange: () => {
|
|
169
|
+
handleChange(option);
|
|
170
|
+
},
|
|
171
|
+
key: option.value,
|
|
172
|
+
value: option.value,
|
|
173
|
+
disabled: isDisabled && selectedValue !== option.value,
|
|
174
|
+
className: getButtonStyle(option),
|
|
175
|
+
style: { pointerEvents: isDisabled && selectedValue !== option.value ? "none" : "auto" }
|
|
176
|
+
},
|
|
177
|
+
option.label
|
|
178
|
+
))
|
|
179
|
+
));
|
|
152
180
|
};
|
|
153
181
|
|
|
154
182
|
// src/Components/Checkbox.tsx
|
|
155
|
-
import React7, { useState as
|
|
183
|
+
import React7, { useState as useState3 } from "react";
|
|
156
184
|
import { Checkbox, Divider } from "antd";
|
|
157
185
|
var CheckboxGroup = Checkbox.Group;
|
|
158
186
|
var plainOptions = ["Apple", "Pear", "Orange"];
|
|
159
187
|
var defaultCheckedList = [];
|
|
160
188
|
var CheckboxElement = (props) => {
|
|
161
|
-
const [checkedList, setCheckedList] =
|
|
189
|
+
const [checkedList, setCheckedList] = useState3(defaultCheckedList);
|
|
162
190
|
const checkAll = plainOptions.length === checkedList.length;
|
|
163
191
|
const handleChange = (list) => {
|
|
164
192
|
setCheckedList(list);
|
|
@@ -182,7 +210,7 @@ var CheckboxElement = (props) => {
|
|
|
182
210
|
disabled: props.disabled,
|
|
183
211
|
id: props.name,
|
|
184
212
|
style: props.styles,
|
|
185
|
-
className: props.
|
|
213
|
+
className: props.className,
|
|
186
214
|
onChange: onHandleAllChanges,
|
|
187
215
|
checked: checkAll
|
|
188
216
|
},
|
|
@@ -192,7 +220,7 @@ var CheckboxElement = (props) => {
|
|
|
192
220
|
{
|
|
193
221
|
disabled: props.disabled,
|
|
194
222
|
style: props.styles,
|
|
195
|
-
className: props.
|
|
223
|
+
className: props.className,
|
|
196
224
|
options: plainOptions,
|
|
197
225
|
value: checkedList,
|
|
198
226
|
onChange: handleChange
|
|
@@ -219,8 +247,7 @@ var CkEditor = (props) => {
|
|
|
219
247
|
{
|
|
220
248
|
apiKey: "rwpgt7maa54n0pe5mglhkl686p7h57sg6z636n6gf2mio1b9",
|
|
221
249
|
onInit: (_evt, editor) => {
|
|
222
|
-
if (editor)
|
|
223
|
-
editorRef.current = editor;
|
|
250
|
+
if (editor) editorRef.current = editor;
|
|
224
251
|
},
|
|
225
252
|
initialValue: "<p>This is the initial content of the editor.</p>",
|
|
226
253
|
init: {
|
|
@@ -308,28 +335,436 @@ var MultipleSelectElement = (props) => {
|
|
|
308
335
|
|
|
309
336
|
// src/Components/Button.tsx
|
|
310
337
|
import React11 from "react";
|
|
311
|
-
|
|
312
|
-
|
|
338
|
+
var ButtonElement = (props) => {
|
|
339
|
+
const handleClick = typeof props.action === "string" ? () => {
|
|
340
|
+
console.log("Performing action:", props.action);
|
|
341
|
+
} : props.action;
|
|
342
|
+
return /* @__PURE__ */ React11.createElement(
|
|
343
|
+
"button",
|
|
344
|
+
{
|
|
345
|
+
onClick: handleClick,
|
|
346
|
+
className: `${props.className ? props.className : ""}`
|
|
347
|
+
},
|
|
348
|
+
props.icon && /* @__PURE__ */ React11.createElement("img", { src: props.icon }),
|
|
349
|
+
props.label
|
|
350
|
+
);
|
|
351
|
+
};
|
|
313
352
|
|
|
314
353
|
// src/Components/AddMoreTable.tsx
|
|
315
|
-
import React12 from "react";
|
|
354
|
+
import React12, { useEffect, useState as useState4 } from "react";
|
|
355
|
+
import { Table, Button as Button2 } from "antd";
|
|
356
|
+
import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
|
|
316
357
|
var AddMoreTable = (props) => {
|
|
317
358
|
const { thead, tbody } = props;
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
359
|
+
const [rows, setRows] = useState4(tbody || []);
|
|
360
|
+
const onHandleRows = () => {
|
|
361
|
+
const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
|
|
362
|
+
let newRow = {
|
|
363
|
+
id: newId,
|
|
364
|
+
label: "Medicine",
|
|
365
|
+
name: "Medicine",
|
|
366
|
+
type: "text",
|
|
367
|
+
element: "single-select",
|
|
368
|
+
variable_data: [
|
|
369
|
+
{
|
|
370
|
+
id: 1,
|
|
371
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
372
|
+
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
373
|
+
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
374
|
+
When: { label: "When", element: "textarea", type: "text" },
|
|
375
|
+
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
376
|
+
Instructions: { label: "Instructions", element: "textarea", type: "text" },
|
|
377
|
+
SubRows: { delete: "delete", add: "plus" }
|
|
378
|
+
}
|
|
379
|
+
]
|
|
380
|
+
};
|
|
381
|
+
setRows((prevData) => [...prevData, newRow]);
|
|
382
|
+
};
|
|
383
|
+
const onHandleDelete = (id) => {
|
|
384
|
+
setRows((prevRows) => prevRows.filter((row) => row.id !== id));
|
|
385
|
+
};
|
|
386
|
+
const onHandleSubRowsAdd = (rowIndex) => {
|
|
387
|
+
setRows((prevRows) => {
|
|
388
|
+
return prevRows.map((row, index) => {
|
|
389
|
+
if (index === rowIndex) {
|
|
390
|
+
const newSubRow = {
|
|
391
|
+
id: row.variable_data.length + 1,
|
|
392
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
393
|
+
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
394
|
+
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
395
|
+
When: { label: "When", element: "textarea", type: "text" },
|
|
396
|
+
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
397
|
+
Instructions: { label: "Instructions", element: "textarea", type: "text" },
|
|
398
|
+
SubRows: { delete: "delete", add: "plus" }
|
|
399
|
+
};
|
|
400
|
+
const updatedVariableData = [...row.variable_data, newSubRow];
|
|
401
|
+
return {
|
|
402
|
+
...row,
|
|
403
|
+
variable_data: updatedVariableData
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
return row;
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
};
|
|
410
|
+
const onHandleSubRowsDelete = (rowIndex, subIndex) => {
|
|
411
|
+
setRows((prevRows) => {
|
|
412
|
+
return prevRows.map((row, index) => {
|
|
413
|
+
if (index === rowIndex) {
|
|
414
|
+
const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
|
|
415
|
+
return {
|
|
416
|
+
...row,
|
|
417
|
+
variable_data: updatedVariableData
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
return row;
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
useEffect(() => {
|
|
425
|
+
console.log(rows);
|
|
426
|
+
}, [rows]);
|
|
427
|
+
const renderInputElement = (element, value) => {
|
|
428
|
+
if (!element) return null;
|
|
429
|
+
const { element: type, label } = element;
|
|
430
|
+
if (type === "single-select") {
|
|
431
|
+
return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
|
|
432
|
+
} else if (type === "textarea") {
|
|
433
|
+
return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
|
|
434
|
+
} else {
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
const dataSource = rows.map((eachRow, rowIndex) => {
|
|
439
|
+
const rowData = {
|
|
440
|
+
key: eachRow.id,
|
|
441
|
+
"#": rowIndex + 1,
|
|
442
|
+
"Medicine": renderInputElement({
|
|
443
|
+
element: eachRow.element,
|
|
444
|
+
label: eachRow.label
|
|
445
|
+
})
|
|
446
|
+
};
|
|
447
|
+
eachRow.variable_data.forEach((variable, subIndex) => {
|
|
448
|
+
Object.keys(variable).forEach((key) => {
|
|
449
|
+
if (key === "SubRows") {
|
|
450
|
+
rowData[`${key}`] = /* @__PURE__ */ React12.createElement("div", { key: subIndex }, eachRow.variable_data.length > 1 && /* @__PURE__ */ React12.createElement(Button2, { onClick: () => onHandleSubRowsDelete(rowIndex, subIndex) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement(Button2, { onClick: () => onHandleSubRowsAdd(rowIndex) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
|
|
451
|
+
} else {
|
|
452
|
+
rowData[`${key}`] = renderInputElement(variable[key]);
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
rowData.actions = /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(Button2, { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), rowIndex === rows.length - 1 && /* @__PURE__ */ React12.createElement(Button2, { onClick: onHandleRows }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
|
|
457
|
+
console.log("=====rowdata", rowData);
|
|
458
|
+
return rowData;
|
|
459
|
+
});
|
|
460
|
+
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
461
|
+
title: eachHeadEl.label,
|
|
462
|
+
dataIndex: eachHeadEl.name,
|
|
463
|
+
key: eachHeadEl.id
|
|
464
|
+
})) : [];
|
|
465
|
+
if (!columns.some((col) => col.dataIndex === "actions")) {
|
|
466
|
+
columns.push({
|
|
467
|
+
title: "Actions",
|
|
468
|
+
dataIndex: "actions",
|
|
469
|
+
key: "actions"
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
return /* @__PURE__ */ React12.createElement(
|
|
473
|
+
Table,
|
|
474
|
+
{
|
|
475
|
+
columns,
|
|
476
|
+
dataSource,
|
|
477
|
+
pagination: false,
|
|
478
|
+
bordered: true
|
|
479
|
+
}
|
|
480
|
+
);
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
// src/Components/Sidebar.tsx
|
|
484
|
+
import React13 from "react";
|
|
485
|
+
var Sidebar = (props) => {
|
|
486
|
+
const handleChange = (item) => {
|
|
487
|
+
if (props.onChange) {
|
|
488
|
+
props.onChange(item);
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
return /* @__PURE__ */ React13.createElement("div", { className: props.className, key: props.name }, /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("img", { src: props.img, alt: "logo" })), /* @__PURE__ */ React13.createElement("ul", { className: props.listClassName }, props.items?.map((item) => {
|
|
492
|
+
return /* @__PURE__ */ React13.createElement("li", { onClick: () => {
|
|
493
|
+
handleChange(item);
|
|
494
|
+
}, key: item.label, className: `${props.listItemClassName} ${item.active && props.activeClassName}` }, /* @__PURE__ */ React13.createElement("img", { src: item.icon, className: props.className }), /* @__PURE__ */ React13.createElement("p", null, item.label));
|
|
495
|
+
})));
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
// src/Components/Navbar.tsx
|
|
499
|
+
import React17 from "react";
|
|
500
|
+
|
|
501
|
+
// src/Components/Notification.tsx
|
|
502
|
+
import React14 from "react";
|
|
503
|
+
import { Popover, Badge, Button as Button3, Avatar, List } from "antd";
|
|
504
|
+
import { IoIosNotifications } from "react-icons/io";
|
|
505
|
+
var popoverContentStyle = {
|
|
506
|
+
minWidth: "300px",
|
|
507
|
+
maxWidth: "100%"
|
|
508
|
+
};
|
|
509
|
+
var Notification = (props) => /* @__PURE__ */ React14.createElement(
|
|
510
|
+
Popover,
|
|
511
|
+
{
|
|
512
|
+
className: props.className,
|
|
513
|
+
content: /* @__PURE__ */ React14.createElement("div", { style: popoverContentStyle }, " ", /* @__PURE__ */ React14.createElement(
|
|
514
|
+
List,
|
|
515
|
+
{
|
|
516
|
+
itemLayout: "horizontal",
|
|
517
|
+
dataSource: props.items,
|
|
518
|
+
renderItem: (item, index) => /* @__PURE__ */ React14.createElement(List.Item, { key: item.text }, /* @__PURE__ */ React14.createElement(
|
|
519
|
+
List.Item.Meta,
|
|
520
|
+
{
|
|
521
|
+
avatar: /* @__PURE__ */ React14.createElement(Avatar, { src: `https://api.dicebear.com/7.x/miniavs/svg?seed=${index}` }),
|
|
522
|
+
title: item.text,
|
|
523
|
+
description: item.time
|
|
524
|
+
}
|
|
525
|
+
))
|
|
526
|
+
}
|
|
527
|
+
)),
|
|
528
|
+
trigger: "focus",
|
|
529
|
+
placement: "bottomRight"
|
|
530
|
+
},
|
|
531
|
+
/* @__PURE__ */ React14.createElement(Button3, { className: props.buttonClassName }, /* @__PURE__ */ React14.createElement(Badge, { size: "small", count: props.count }, /* @__PURE__ */ React14.createElement("span", { className: props.iconsClassName }, /* @__PURE__ */ React14.createElement(IoIosNotifications, null))))
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
// src/Components/SpanElement.tsx
|
|
535
|
+
import React15 from "react";
|
|
536
|
+
var SpanElement = (props) => /* @__PURE__ */ React15.createElement("span", { className: props.className }, props.label);
|
|
537
|
+
|
|
538
|
+
// src/Components/Profile.tsx
|
|
539
|
+
import React16 from "react";
|
|
540
|
+
import { Avatar as Avatar2 } from "antd";
|
|
541
|
+
import { UserOutlined } from "@ant-design/icons";
|
|
542
|
+
var Profile = (props) => /* @__PURE__ */ React16.createElement("div", { className: props.className }, /* @__PURE__ */ React16.createElement(Avatar2, { style: { backgroundColor: "#87d068", marginRight: "10px" }, icon: /* @__PURE__ */ React16.createElement(UserOutlined, null) }), /* @__PURE__ */ React16.createElement("div", { className: props.profileSubClassName }, /* @__PURE__ */ React16.createElement("p", null, props.primaryText), /* @__PURE__ */ React16.createElement("p", { className: props.secondTextClassName }, " ", props.secondaryText)));
|
|
543
|
+
|
|
544
|
+
// src/Components/Navbar.tsx
|
|
545
|
+
var Navbar = (props) => {
|
|
546
|
+
return /* @__PURE__ */ React17.createElement("div", { className: `${props.className}`, key: props.name }, props.items && props.items.map((item) => {
|
|
547
|
+
if (item.element === "span") {
|
|
548
|
+
return /* @__PURE__ */ React17.createElement(SpanElement, { ...item });
|
|
549
|
+
} else if (item.element === "notifications") {
|
|
550
|
+
return /* @__PURE__ */ React17.createElement(Notification, { ...item });
|
|
551
|
+
} else if (item.name === "profile") {
|
|
552
|
+
return /* @__PURE__ */ React17.createElement(Profile, { ...item });
|
|
553
|
+
}
|
|
554
|
+
return null;
|
|
555
|
+
}));
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
// src/Components/TableElement.tsx
|
|
559
|
+
import React20, { useState as useState5 } from "react";
|
|
560
|
+
import { Table as Table2 } from "antd";
|
|
561
|
+
|
|
562
|
+
// src/Components/Model.tsx
|
|
563
|
+
import React19 from "react";
|
|
564
|
+
import { Modal } from "antd";
|
|
565
|
+
|
|
566
|
+
// src/Components/ModelBody.tsx
|
|
567
|
+
import React18 from "react";
|
|
568
|
+
var ModelBody = (props) => {
|
|
569
|
+
return /* @__PURE__ */ React18.createElement("div", { className: props.modalContent && props.modalContent.className }, props.modalContent && props.modalContent.fields.map((eachField) => {
|
|
570
|
+
if (eachField.element === "div") {
|
|
571
|
+
return /* @__PURE__ */ React18.createElement("div", { className: eachField.className }, eachField.label);
|
|
572
|
+
} else if (eachField.element === "input-radio") {
|
|
573
|
+
return /* @__PURE__ */ React18.createElement("div", { className: eachField.className }, /* @__PURE__ */ React18.createElement(RadioElement, { ...eachField }));
|
|
574
|
+
} else if (eachField.element === "button") {
|
|
575
|
+
return /* @__PURE__ */ React18.createElement("div", { className: eachField.className }, /* @__PURE__ */ React18.createElement(ButtonElement, { ...eachField }));
|
|
576
|
+
} else {
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
}));
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
// src/Components/Model.tsx
|
|
583
|
+
var ModelElement = (props) => {
|
|
584
|
+
const { model, onCancel, selectedRecord, columns } = props;
|
|
585
|
+
return /* @__PURE__ */ React19.createElement(
|
|
586
|
+
Modal,
|
|
587
|
+
{
|
|
588
|
+
centered: true,
|
|
589
|
+
open: model,
|
|
590
|
+
onCancel,
|
|
591
|
+
footer: null,
|
|
592
|
+
width: 850,
|
|
593
|
+
title: /* @__PURE__ */ React19.createElement(
|
|
594
|
+
"div",
|
|
595
|
+
{
|
|
596
|
+
style: {
|
|
597
|
+
display: "flex",
|
|
598
|
+
flexWrap: "wrap",
|
|
599
|
+
padding: "20px",
|
|
600
|
+
width: "full",
|
|
601
|
+
margin: "-10px"
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
Object.entries(selectedRecord).map(([key, value]) => {
|
|
605
|
+
const record = columns.filter((eachColumn) => eachColumn.key === key);
|
|
606
|
+
return record.length > 0 ? /* @__PURE__ */ React19.createElement("p", { style: { fontWeight: "500", padding: "10px" }, key }, /* @__PURE__ */ React19.createElement("span", { style: { fontWeight: "200", color: "gray", paddingRight: "10px" } }, record[0].title), String(value)) : "";
|
|
607
|
+
})
|
|
608
|
+
)
|
|
609
|
+
},
|
|
610
|
+
/* @__PURE__ */ React19.createElement(ModelBody, { ...props })
|
|
611
|
+
);
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
// src/Components/TableElement.tsx
|
|
615
|
+
var TableElement = (props) => {
|
|
616
|
+
const { thead, tbody } = props;
|
|
617
|
+
const [selectedRecord, setSelectedRecord] = useState5({});
|
|
618
|
+
const [model, setModel] = useState5(false);
|
|
619
|
+
const handleChange = (record) => {
|
|
620
|
+
if (props.onChange) {
|
|
621
|
+
props.onChange(record);
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
let columns = [];
|
|
625
|
+
if (thead) {
|
|
626
|
+
columns = [
|
|
627
|
+
{
|
|
628
|
+
title: "#",
|
|
629
|
+
dataIndex: "#",
|
|
630
|
+
key: "#"
|
|
631
|
+
},
|
|
632
|
+
...thead.map((col, ind) => ({
|
|
633
|
+
title: col.label,
|
|
634
|
+
dataIndex: col.name,
|
|
635
|
+
key: col.key,
|
|
636
|
+
sorter: {
|
|
637
|
+
compare: (a, b) => {
|
|
638
|
+
if (typeof a[col.key] === "number" && typeof a[col.key] === "number") {
|
|
639
|
+
return a[col.key] - b[col.key];
|
|
640
|
+
} else if (typeof a[col.key] === "string" && typeof a[col.key] === "string") {
|
|
641
|
+
return a[col.key].localeCompare(b[col.key]);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}))
|
|
646
|
+
];
|
|
647
|
+
}
|
|
648
|
+
const dataSource = tbody && tbody.map((row, index) => ({
|
|
649
|
+
...row,
|
|
650
|
+
[columns[0].key]: index + 1
|
|
651
|
+
}));
|
|
652
|
+
const count = dataSource ? dataSource.length : 0;
|
|
653
|
+
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(
|
|
654
|
+
Table2,
|
|
655
|
+
{
|
|
656
|
+
pagination: {
|
|
657
|
+
showTotal: (total) => `Total: ${total} items`,
|
|
658
|
+
total: count,
|
|
659
|
+
showSizeChanger: count > 10
|
|
660
|
+
},
|
|
661
|
+
dataSource,
|
|
662
|
+
columns,
|
|
663
|
+
bordered: true,
|
|
664
|
+
size: props.size && props.size,
|
|
665
|
+
onRow: (record) => {
|
|
666
|
+
return {
|
|
667
|
+
onClick: () => {
|
|
668
|
+
setSelectedRecord(record);
|
|
669
|
+
handleChange(record);
|
|
670
|
+
setModel(true);
|
|
671
|
+
},
|
|
672
|
+
style: { cursor: "pointer" }
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
), model && /* @__PURE__ */ React20.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
// src/Components/DatePicker.tsx
|
|
680
|
+
import React21, { useState as useState6 } from "react";
|
|
681
|
+
import { DatePicker } from "antd";
|
|
682
|
+
import { LeftOutlined, RightOutlined } from "@ant-design/icons";
|
|
683
|
+
import moment from "moment";
|
|
684
|
+
var DatePickerElement = (props) => {
|
|
685
|
+
const [date, setDate] = useState6(null);
|
|
686
|
+
const handleChange = (date2, dateString) => {
|
|
687
|
+
console.log("date---------", date2);
|
|
688
|
+
console.log("datestring", dateString);
|
|
689
|
+
if (date2) {
|
|
690
|
+
const formattedDate = dateString;
|
|
691
|
+
console.log("formattedDate-----------------", formattedDate);
|
|
692
|
+
setDate(date2);
|
|
693
|
+
console.log("changedDate------------", date2);
|
|
694
|
+
if (props.onChange) {
|
|
695
|
+
props.onChange(formattedDate);
|
|
696
|
+
}
|
|
697
|
+
} else {
|
|
698
|
+
setDate(null);
|
|
699
|
+
if (props.onChange) {
|
|
700
|
+
props.onChange("");
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
const onHandleDecrement = () => {
|
|
705
|
+
const currentDate = date || moment();
|
|
706
|
+
const newDate = moment(currentDate).subtract(1, "days");
|
|
707
|
+
setDate(newDate);
|
|
708
|
+
if (props.onChange) {
|
|
709
|
+
props.onChange(newDate.format("lll"));
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
const onHandleIncrement = () => {
|
|
713
|
+
const currentDate = date || moment();
|
|
714
|
+
const newDate = moment(currentDate).add(1, "days");
|
|
715
|
+
setDate(newDate);
|
|
716
|
+
if (props.onChange) {
|
|
717
|
+
props.onChange(newDate.format("lll"));
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
return /* @__PURE__ */ React21.createElement("div", null, /* @__PURE__ */ React21.createElement("button", { onClick: onHandleDecrement }, /* @__PURE__ */ React21.createElement(LeftOutlined, null)), /* @__PURE__ */ React21.createElement(
|
|
721
|
+
DatePicker,
|
|
722
|
+
{
|
|
723
|
+
placeholder: props.placeholder,
|
|
724
|
+
value: date,
|
|
725
|
+
variant: "borderless",
|
|
726
|
+
onChange: handleChange
|
|
727
|
+
}
|
|
728
|
+
), /* @__PURE__ */ React21.createElement("button", { onClick: onHandleIncrement }, /* @__PURE__ */ React21.createElement(RightOutlined, null)));
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
// src/Components/DateRangePickerElement.tsx
|
|
732
|
+
import React22 from "react";
|
|
733
|
+
import { DatePicker as DatePicker2, Space as Space2 } from "antd";
|
|
734
|
+
import dayjs from "dayjs";
|
|
735
|
+
var DateRangePickerElement = (props) => {
|
|
736
|
+
const { RangePicker } = DatePicker2;
|
|
737
|
+
const handleChange = (dates, dateStrings) => {
|
|
738
|
+
if (dates && props.onChange) {
|
|
739
|
+
props.onChange(dateStrings);
|
|
740
|
+
} else {
|
|
741
|
+
console.log("Clear");
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
const rangePresets = [
|
|
745
|
+
{ label: "Last 7 Days", value: [dayjs().add(-7, "d"), dayjs()] },
|
|
746
|
+
{ label: "Last 14 Days", value: [dayjs().add(-14, "d"), dayjs()] },
|
|
747
|
+
{ label: "Last 30 Days", value: [dayjs().add(-30, "d"), dayjs()] },
|
|
748
|
+
{ label: "Last 90 Days", value: [dayjs().add(-90, "d"), dayjs()] }
|
|
749
|
+
];
|
|
750
|
+
return /* @__PURE__ */ React22.createElement(Space2, { direction: "vertical", size: 12 }, /* @__PURE__ */ React22.createElement(RangePicker, { presets: rangePresets, onChange: handleChange }));
|
|
321
751
|
};
|
|
322
752
|
export {
|
|
323
753
|
AddMoreTable,
|
|
324
754
|
ButtonElement,
|
|
325
755
|
CheckboxElement,
|
|
326
756
|
CkEditor,
|
|
757
|
+
DatePickerElement,
|
|
758
|
+
DateRangePickerElement,
|
|
327
759
|
MultipleSelectElement,
|
|
760
|
+
Navbar,
|
|
328
761
|
NumberElement,
|
|
329
762
|
PasswordElement,
|
|
330
763
|
RadioElement,
|
|
331
764
|
SelectElement,
|
|
765
|
+
Sidebar,
|
|
332
766
|
SingleSelectElement,
|
|
767
|
+
TableElement,
|
|
333
768
|
TextElement,
|
|
334
769
|
TextareaElement
|
|
335
770
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apexcura/ui-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13-Beta1",
|
|
4
4
|
"description": "Apex cura React components library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apex cura",
|
|
@@ -41,13 +41,22 @@
|
|
|
41
41
|
"react": "^18.3.1",
|
|
42
42
|
"react-dom": "^18.3.1",
|
|
43
43
|
"ts-jest": "^29.1.2",
|
|
44
|
-
"tsup": "^8.0
|
|
44
|
+
"tsup": "^8.1.0",
|
|
45
45
|
"typescript": "^5.4.5"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=18.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@
|
|
51
|
+
"@apexcura/ui-components": "^0.0.11-Beta256",
|
|
52
|
+
"@tinymce/tinymce-react": "^5.0.1",
|
|
53
|
+
"autoprefixer": "^10.4.19",
|
|
54
|
+
"date-fns": "^3.6.0",
|
|
55
|
+
"esbuild": "^0.21.4",
|
|
56
|
+
"moment": "^2.30.1",
|
|
57
|
+
"postcss": "^8.4.38",
|
|
58
|
+
"postcss-import": "^16.1.0",
|
|
59
|
+
"react-icons": "^5.2.1",
|
|
60
|
+
"tailwindcss": "^3.4.3"
|
|
52
61
|
}
|
|
53
62
|
}
|