react-admin-crud-manager 1.0.0
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/README.md +40 -0
- package/package.json +55 -0
- package/src/App.jsx +5 -0
- package/src/components/Button/Button.jsx +85 -0
- package/src/components/Chip/Chip.jsx +71 -0
- package/src/components/CrudPage.jsx +532 -0
- package/src/components/Details/Details.jsx +134 -0
- package/src/components/Filter/FilterDrawer.jsx +99 -0
- package/src/components/Form/Form.jsx +51 -0
- package/src/components/Form/components/Checkbox.jsx +119 -0
- package/src/components/Form/components/ImagePicker.jsx +128 -0
- package/src/components/Form/components/Input.jsx +71 -0
- package/src/components/Form/components/InputLabel.jsx +12 -0
- package/src/components/Form/components/PhoneInput.jsx +221 -0
- package/src/components/Form/components/RenderFields.jsx +181 -0
- package/src/components/Form/components/Select.jsx +191 -0
- package/src/components/Form/components/Switch.jsx +64 -0
- package/src/components/Form/components/TextArea.jsx +31 -0
- package/src/components/Form/components/TinyEditor.jsx +113 -0
- package/src/components/Loader/Spinner.jsx +21 -0
- package/src/components/Modal/Modal.jsx +152 -0
- package/src/components/Table/Table.jsx +554 -0
- package/src/components/Table/components/ImagePreview.jsx +58 -0
- package/src/components/Table/components/TableSkeleton.jsx +39 -0
- package/src/data/countries.js +252 -0
- package/src/data/teams.js +130 -0
- package/src/index.css +170 -0
- package/src/lib/utils.js +74 -0
- package/src/main.jsx +11 -0
package/src/lib/utils.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// ======= Format Date : Jan 15, 2024 =======
|
|
2
|
+
|
|
3
|
+
export const formatDate = (dateString, format = "DD MMM YYYY") => {
|
|
4
|
+
if (!dateString) return "N/A";
|
|
5
|
+
|
|
6
|
+
const date = new Date(dateString);
|
|
7
|
+
if (isNaN(date)) return "Invalid Date";
|
|
8
|
+
|
|
9
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
10
|
+
|
|
11
|
+
const map = {
|
|
12
|
+
YYYY: date.getFullYear(),
|
|
13
|
+
YY: String(date.getFullYear()).slice(-2),
|
|
14
|
+
|
|
15
|
+
MMMM: date.toLocaleString("en-US", { month: "long" }),
|
|
16
|
+
MMM: date.toLocaleString("en-US", { month: "short" }),
|
|
17
|
+
MM: pad(date.getMonth() + 1),
|
|
18
|
+
M: date.getMonth() + 1,
|
|
19
|
+
|
|
20
|
+
DD: pad(date.getDate()),
|
|
21
|
+
D: date.getDate(),
|
|
22
|
+
|
|
23
|
+
dddd: date.toLocaleString("en-US", { weekday: "long" }),
|
|
24
|
+
ddd: date.toLocaleString("en-US", { weekday: "short" }),
|
|
25
|
+
|
|
26
|
+
HH: pad(date.getHours()),
|
|
27
|
+
hh: pad(date.getHours() % 12 || 12),
|
|
28
|
+
|
|
29
|
+
mm: pad(date.getMinutes()),
|
|
30
|
+
ss: pad(date.getSeconds()),
|
|
31
|
+
|
|
32
|
+
A: date.getHours() >= 12 ? "PM" : "AM",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return format.replace(
|
|
36
|
+
/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|HH|hh|mm|ss|A/g,
|
|
37
|
+
(token) => map[token],
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// =========== Local Search function ===========
|
|
42
|
+
export const searchLocalData = (data, searchTerm, searchKeys = []) => {
|
|
43
|
+
if (!searchTerm?.trim()) return data;
|
|
44
|
+
|
|
45
|
+
const lowerSearchTerm = searchTerm.toLowerCase();
|
|
46
|
+
|
|
47
|
+
const extractValues = (obj) => {
|
|
48
|
+
if (obj == null) return [];
|
|
49
|
+
if (typeof obj === "object") {
|
|
50
|
+
return Object.values(obj).flatMap(extractValues);
|
|
51
|
+
}
|
|
52
|
+
return [String(obj)];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return data.filter((item) => {
|
|
56
|
+
let valuesToSearch = [];
|
|
57
|
+
|
|
58
|
+
// ✅ If specific keys are provided → search only in those keys
|
|
59
|
+
if (searchKeys.length > 0) {
|
|
60
|
+
searchKeys.forEach((key) => {
|
|
61
|
+
if (item[key] !== undefined) {
|
|
62
|
+
valuesToSearch.push(...extractValues(item[key]));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
// ✅ Otherwise → search in entire object
|
|
67
|
+
valuesToSearch = extractValues(item);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return valuesToSearch.some((val) =>
|
|
71
|
+
val.toLowerCase().includes(lowerSearchTerm),
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
};
|
package/src/main.jsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import ReactDOM from 'react-dom/client'
|
|
3
|
+
import { BrowserRouter } from 'react-router-dom'
|
|
4
|
+
import App from './App'
|
|
5
|
+
import "./index.css";
|
|
6
|
+
|
|
7
|
+
ReactDOM.createRoot(document.getElementById('root')).render(
|
|
8
|
+
<BrowserRouter>
|
|
9
|
+
<App />
|
|
10
|
+
</BrowserRouter>
|
|
11
|
+
)
|