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