@nestledjs/data-browser 0.1.7 → 0.1.9
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/index.js +62 -62
- package/lib/components/filters/DateRangeFilter.js +79 -98
- package/lib/components/filters/NumberRangeFilter.js +92 -108
- package/lib/components/filters/RelationComponents.js +129 -247
- package/lib/components/filters/RelationFilterField.js +77 -107
- package/lib/components/shared/AdminBreadcrumbs.js +51 -92
- package/lib/components/shared/AdminErrorStates.js +153 -200
- package/lib/components/shared/AdminStatusDisplay.js +202 -192
- package/lib/context/AdminDataContext.js +25 -21
- package/lib/hooks/useAdminList.js +22 -22
- package/lib/hooks/useClickOutside.js +12 -9
- package/lib/hooks/useDebounce.js +11 -10
- package/lib/hooks/useRelationData.js +70 -47
- package/lib/layouts/AdminDataLayout.js +250 -300
- package/lib/pages/AdminDataCreatePage.js +322 -433
- package/lib/pages/AdminDataEditPage.js +664 -803
- package/lib/pages/AdminDataIndexPage.js +58 -86
- package/lib/pages/AdminDataListPage.js +751 -1164
- package/lib/types/index.js +5 -5
- package/lib/utils/graphql-utils.js +266 -177
- package/lib/utils/secure-storage.js +165 -96
- package/lib/utils/string-utils.js +31 -19
- package/package.json +2 -2
|
@@ -1,205 +1,215 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { QuestionMarkCircleIcon
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
online: {
|
|
100
|
-
color: "bg-green-400",
|
|
101
|
-
label: "Online"
|
|
102
|
-
},
|
|
103
|
-
offline: {
|
|
104
|
-
color: "bg-gray-400",
|
|
105
|
-
label: "Offline"
|
|
106
|
-
},
|
|
107
|
-
away: {
|
|
108
|
-
color: "bg-yellow-400",
|
|
109
|
-
label: "Away"
|
|
110
|
-
},
|
|
111
|
-
busy: {
|
|
112
|
-
color: "bg-red-400",
|
|
113
|
-
label: "Busy"
|
|
114
|
-
}
|
|
115
|
-
})[e];
|
|
116
|
-
function O({
|
|
117
|
-
status: e,
|
|
118
|
-
label: t,
|
|
119
|
-
size: c = "medium",
|
|
120
|
-
variant: n = "badge",
|
|
121
|
-
showIcon: r = !0,
|
|
122
|
-
className: a = "",
|
|
123
|
-
onClick: s,
|
|
124
|
-
tooltip: i
|
|
125
|
-
}) {
|
|
126
|
-
const l = L(e), d = x(c), y = P(n), h = l.icon, m = t || l.defaultLabel, g = n === "dot", N = r && !g, f = !!s, C = `${`${y} ${d.text} ${d.padding} ${l.bgColor} ${l.textColor} ${l.borderColor}`} ${f ? "cursor-pointer hover:opacity-80" : ""} ${a}`.trim(), j = () => g ? /* @__PURE__ */ o("span", { className: `inline-block rounded-full mr-2 ${l.bgColor.replace("bg-", "bg-").replace("-100", "-400")} ${d.dot}` }, void 0, !1, {
|
|
127
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/shared/AdminStatusDisplay.tsx",
|
|
128
|
-
lineNumber: 221,
|
|
129
|
-
columnNumber: 7
|
|
130
|
-
}, this) : null, v = () => N ? /* @__PURE__ */ o(h, { className: `${d.icon} ${m ? "mr-1.5" : ""}` }, void 0, !1, {
|
|
131
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/shared/AdminStatusDisplay.tsx",
|
|
132
|
-
lineNumber: 229,
|
|
133
|
-
columnNumber: 7
|
|
134
|
-
}, this) : null, p = /* @__PURE__ */ o(I, { children: [
|
|
135
|
-
j(),
|
|
136
|
-
v(),
|
|
137
|
-
m
|
|
138
|
-
] }, void 0, !0, {
|
|
139
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/shared/AdminStatusDisplay.tsx",
|
|
140
|
-
lineNumber: 234,
|
|
141
|
-
columnNumber: 5
|
|
142
|
-
}, this), w = () => {
|
|
143
|
-
s && s();
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { QuestionMarkCircleIcon, PauseCircleIcon, CheckCircleIcon, XCircleIcon, ExclamationTriangleIcon, ClockIcon } from "@heroicons/react/24/solid";
|
|
3
|
+
var _jsxFileName = "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/shared/AdminStatusDisplay.tsx";
|
|
4
|
+
const getStatusConfig = (status) => {
|
|
5
|
+
const configs = {
|
|
6
|
+
active: {
|
|
7
|
+
icon: CheckCircleIcon,
|
|
8
|
+
bgColor: "bg-green-100",
|
|
9
|
+
textColor: "text-green-800",
|
|
10
|
+
borderColor: "border-green-200",
|
|
11
|
+
defaultLabel: "Active"
|
|
12
|
+
},
|
|
13
|
+
inactive: {
|
|
14
|
+
icon: XCircleIcon,
|
|
15
|
+
bgColor: "bg-gray-100",
|
|
16
|
+
textColor: "text-gray-800",
|
|
17
|
+
borderColor: "border-gray-200",
|
|
18
|
+
defaultLabel: "Inactive"
|
|
19
|
+
},
|
|
20
|
+
pending: {
|
|
21
|
+
icon: ClockIcon,
|
|
22
|
+
bgColor: "bg-yellow-100",
|
|
23
|
+
textColor: "text-yellow-800",
|
|
24
|
+
borderColor: "border-yellow-200",
|
|
25
|
+
defaultLabel: "Pending"
|
|
26
|
+
},
|
|
27
|
+
approved: {
|
|
28
|
+
icon: CheckCircleIcon,
|
|
29
|
+
bgColor: "bg-green-100",
|
|
30
|
+
textColor: "text-green-800",
|
|
31
|
+
borderColor: "border-green-200",
|
|
32
|
+
defaultLabel: "Approved"
|
|
33
|
+
},
|
|
34
|
+
rejected: {
|
|
35
|
+
icon: XCircleIcon,
|
|
36
|
+
bgColor: "bg-red-100",
|
|
37
|
+
textColor: "text-red-800",
|
|
38
|
+
borderColor: "border-red-200",
|
|
39
|
+
defaultLabel: "Rejected"
|
|
40
|
+
},
|
|
41
|
+
warning: {
|
|
42
|
+
icon: ExclamationTriangleIcon,
|
|
43
|
+
bgColor: "bg-yellow-100",
|
|
44
|
+
textColor: "text-yellow-800",
|
|
45
|
+
borderColor: "border-yellow-200",
|
|
46
|
+
defaultLabel: "Warning"
|
|
47
|
+
},
|
|
48
|
+
error: {
|
|
49
|
+
icon: XCircleIcon,
|
|
50
|
+
bgColor: "bg-red-100",
|
|
51
|
+
textColor: "text-red-800",
|
|
52
|
+
borderColor: "border-red-200",
|
|
53
|
+
defaultLabel: "Error"
|
|
54
|
+
},
|
|
55
|
+
success: {
|
|
56
|
+
icon: CheckCircleIcon,
|
|
57
|
+
bgColor: "bg-green-100",
|
|
58
|
+
textColor: "text-green-800",
|
|
59
|
+
borderColor: "border-green-200",
|
|
60
|
+
defaultLabel: "Success"
|
|
61
|
+
},
|
|
62
|
+
paused: {
|
|
63
|
+
icon: PauseCircleIcon,
|
|
64
|
+
bgColor: "bg-blue-100",
|
|
65
|
+
textColor: "text-blue-800",
|
|
66
|
+
borderColor: "border-blue-200",
|
|
67
|
+
defaultLabel: "Paused"
|
|
68
|
+
},
|
|
69
|
+
unknown: {
|
|
70
|
+
icon: QuestionMarkCircleIcon,
|
|
71
|
+
bgColor: "bg-gray-100",
|
|
72
|
+
textColor: "text-gray-800",
|
|
73
|
+
borderColor: "border-gray-200",
|
|
74
|
+
defaultLabel: "Unknown"
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
return configs[status];
|
|
78
|
+
};
|
|
79
|
+
const getSizeClasses = (size) => {
|
|
80
|
+
const sizeClasses = {
|
|
81
|
+
small: {
|
|
82
|
+
text: "text-xs",
|
|
83
|
+
padding: "px-2 py-1",
|
|
84
|
+
icon: "h-3 w-3",
|
|
85
|
+
dot: "h-2 w-2"
|
|
86
|
+
},
|
|
87
|
+
medium: {
|
|
88
|
+
text: "text-sm",
|
|
89
|
+
padding: "px-2.5 py-1.5",
|
|
90
|
+
icon: "h-4 w-4",
|
|
91
|
+
dot: "h-3 w-3"
|
|
92
|
+
},
|
|
93
|
+
large: {
|
|
94
|
+
text: "text-base",
|
|
95
|
+
padding: "px-3 py-2",
|
|
96
|
+
icon: "h-5 w-5",
|
|
97
|
+
dot: "h-4 w-4"
|
|
98
|
+
}
|
|
144
99
|
};
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
100
|
+
return sizeClasses[size];
|
|
101
|
+
};
|
|
102
|
+
const getVariantClasses = (variant) => {
|
|
103
|
+
const variantClasses = {
|
|
104
|
+
badge: "inline-flex items-center rounded border font-medium",
|
|
105
|
+
pill: "inline-flex items-center rounded-full border font-medium",
|
|
106
|
+
dot: "inline-flex items-center font-medium",
|
|
107
|
+
full: "flex items-center justify-center rounded border font-medium w-full"
|
|
108
|
+
};
|
|
109
|
+
return variantClasses[variant];
|
|
110
|
+
};
|
|
111
|
+
const getUserStatusConfig = (status) => {
|
|
112
|
+
const configs = {
|
|
113
|
+
online: {
|
|
114
|
+
color: "bg-green-400",
|
|
115
|
+
label: "Online"
|
|
153
116
|
},
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
117
|
+
offline: {
|
|
118
|
+
color: "bg-gray-400",
|
|
119
|
+
label: "Offline"
|
|
120
|
+
},
|
|
121
|
+
away: {
|
|
122
|
+
color: "bg-yellow-400",
|
|
123
|
+
label: "Away"
|
|
124
|
+
},
|
|
125
|
+
busy: {
|
|
126
|
+
color: "bg-red-400",
|
|
127
|
+
label: "Busy"
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
return configs[status];
|
|
131
|
+
};
|
|
132
|
+
function AdminStatusDisplay({
|
|
133
|
+
status,
|
|
134
|
+
label,
|
|
135
|
+
size = "medium",
|
|
136
|
+
variant = "badge",
|
|
137
|
+
showIcon = true,
|
|
138
|
+
className = "",
|
|
139
|
+
onClick,
|
|
140
|
+
tooltip
|
|
141
|
+
}) {
|
|
142
|
+
const config = getStatusConfig(status);
|
|
143
|
+
const sizeClasses = getSizeClasses(size);
|
|
144
|
+
const variantClasses = getVariantClasses(variant);
|
|
145
|
+
const IconComponent = config.icon;
|
|
146
|
+
const displayLabel = label || config.defaultLabel;
|
|
147
|
+
const shouldShowDot = variant === "dot";
|
|
148
|
+
const shouldShowIcon = showIcon && !shouldShowDot;
|
|
149
|
+
const isClickable = !!onClick;
|
|
150
|
+
const baseClasses = `${variantClasses} ${sizeClasses.text} ${sizeClasses.padding} ${config.bgColor} ${config.textColor} ${config.borderColor}`;
|
|
151
|
+
const interactiveClasses = isClickable ? "cursor-pointer hover:opacity-80" : "";
|
|
152
|
+
const finalClasses = `${baseClasses} ${interactiveClasses} ${className}`.trim();
|
|
153
|
+
const renderDot = () => {
|
|
154
|
+
if (!shouldShowDot) return null;
|
|
155
|
+
return /* @__PURE__ */ React.createElement("span", { className: `inline-block rounded-full mr-2 ${config.bgColor.replace("bg-", "bg-").replace("-100", "-400")} ${sizeClasses.dot}`, __self: this, __source: {
|
|
156
|
+
fileName: _jsxFileName,
|
|
157
|
+
lineNumber: 221,
|
|
158
|
+
columnNumber: 7
|
|
159
|
+
} });
|
|
160
|
+
};
|
|
161
|
+
const renderIcon = () => {
|
|
162
|
+
if (!shouldShowIcon) return null;
|
|
163
|
+
return /* @__PURE__ */ React.createElement(IconComponent, { className: `${sizeClasses.icon} ${displayLabel ? "mr-1.5" : ""}`, __self: this, __source: {
|
|
164
|
+
fileName: _jsxFileName,
|
|
165
|
+
lineNumber: 229,
|
|
166
|
+
columnNumber: 7
|
|
167
|
+
} });
|
|
168
|
+
};
|
|
169
|
+
const content = /* @__PURE__ */ React.createElement(React.Fragment, null, renderDot(), renderIcon(), displayLabel);
|
|
170
|
+
const handleClick = () => {
|
|
171
|
+
if (onClick) {
|
|
172
|
+
onClick();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
if (isClickable) {
|
|
176
|
+
return /* @__PURE__ */ React.createElement("button", { type: "button", onClick: handleClick, className: finalClasses, title: tooltip, __self: this, __source: {
|
|
177
|
+
fileName: _jsxFileName,
|
|
158
178
|
lineNumber: 249,
|
|
159
179
|
columnNumber: 7
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
fileName:
|
|
180
|
+
} }, content);
|
|
181
|
+
}
|
|
182
|
+
return /* @__PURE__ */ React.createElement("span", { className: finalClasses, title: tooltip, __self: this, __source: {
|
|
183
|
+
fileName: _jsxFileName,
|
|
164
184
|
lineNumber: 261,
|
|
165
185
|
columnNumber: 5
|
|
166
|
-
},
|
|
186
|
+
} }, content);
|
|
167
187
|
}
|
|
168
|
-
function
|
|
169
|
-
status
|
|
170
|
-
showLabel
|
|
171
|
-
size
|
|
172
|
-
className
|
|
188
|
+
function AdminUserStatus({
|
|
189
|
+
status,
|
|
190
|
+
showLabel = false,
|
|
191
|
+
size = "medium",
|
|
192
|
+
className = ""
|
|
173
193
|
}) {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
"aria-label": r.label
|
|
181
|
-
},
|
|
182
|
-
void 0,
|
|
183
|
-
!1,
|
|
184
|
-
{
|
|
185
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/shared/AdminStatusDisplay.tsx",
|
|
186
|
-
lineNumber: 281,
|
|
187
|
-
columnNumber: 7
|
|
188
|
-
},
|
|
189
|
-
this
|
|
190
|
-
),
|
|
191
|
-
t && /* @__PURE__ */ o("span", { className: `ml-2 text-gray-700 ${i}`, children: r.label }, void 0, !1, {
|
|
192
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/shared/AdminStatusDisplay.tsx",
|
|
193
|
-
lineNumber: 286,
|
|
194
|
-
columnNumber: 9
|
|
195
|
-
}, this)
|
|
196
|
-
] }, void 0, !0, {
|
|
197
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/shared/AdminStatusDisplay.tsx",
|
|
194
|
+
const config = getUserStatusConfig(status);
|
|
195
|
+
const sizeClasses = getSizeClasses(size);
|
|
196
|
+
const dotSizeClass = sizeClasses.dot;
|
|
197
|
+
const textSizeClass = showLabel ? sizeClasses.text : "";
|
|
198
|
+
return /* @__PURE__ */ React.createElement("div", { className: `inline-flex items-center ${className}`, __self: this, __source: {
|
|
199
|
+
fileName: _jsxFileName,
|
|
198
200
|
lineNumber: 280,
|
|
199
201
|
columnNumber: 5
|
|
200
|
-
}, this
|
|
202
|
+
} }, /* @__PURE__ */ React.createElement("span", { className: `inline-block rounded-full ${config.color} ${dotSizeClass}`, "aria-label": config.label, __self: this, __source: {
|
|
203
|
+
fileName: _jsxFileName,
|
|
204
|
+
lineNumber: 281,
|
|
205
|
+
columnNumber: 7
|
|
206
|
+
} }), showLabel && /* @__PURE__ */ React.createElement("span", { className: `ml-2 text-gray-700 ${textSizeClass}`, __self: this, __source: {
|
|
207
|
+
fileName: _jsxFileName,
|
|
208
|
+
lineNumber: 286,
|
|
209
|
+
columnNumber: 9
|
|
210
|
+
} }, config.label));
|
|
201
211
|
}
|
|
202
212
|
export {
|
|
203
|
-
|
|
204
|
-
|
|
213
|
+
AdminStatusDisplay,
|
|
214
|
+
AdminUserStatus
|
|
205
215
|
};
|
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
children
|
|
6
|
-
sdk
|
|
7
|
-
databaseModels
|
|
8
|
-
basePath
|
|
9
|
-
formTheme
|
|
1
|
+
import React, { createContext, useContext } from "react";
|
|
2
|
+
var _jsxFileName = "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/context/AdminDataContext.tsx";
|
|
3
|
+
const AdminDataContext = createContext(null);
|
|
4
|
+
function AdminDataProvider({
|
|
5
|
+
children,
|
|
6
|
+
sdk,
|
|
7
|
+
databaseModels,
|
|
8
|
+
basePath = "/admin/data",
|
|
9
|
+
formTheme
|
|
10
10
|
}) {
|
|
11
|
-
return /* @__PURE__ */
|
|
12
|
-
|
|
11
|
+
return /* @__PURE__ */ React.createElement(AdminDataContext.Provider, { value: {
|
|
12
|
+
sdk,
|
|
13
|
+
databaseModels,
|
|
14
|
+
basePath,
|
|
15
|
+
formTheme
|
|
16
|
+
}, __self: this, __source: {
|
|
17
|
+
fileName: _jsxFileName,
|
|
13
18
|
lineNumber: 55,
|
|
14
19
|
columnNumber: 5
|
|
15
|
-
},
|
|
20
|
+
} }, children);
|
|
16
21
|
}
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
20
|
-
throw new Error(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return t;
|
|
22
|
+
function useAdminDataContext() {
|
|
23
|
+
const context = useContext(AdminDataContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error("useAdminDataContext must be used within AdminDataProvider. Make sure to wrap your admin data routes with <AdminDataProvider>.");
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
24
28
|
}
|
|
25
29
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
AdminDataProvider,
|
|
31
|
+
useAdminDataContext
|
|
28
32
|
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { useReducer
|
|
2
|
-
import { initialState
|
|
3
|
-
function
|
|
4
|
-
switch (
|
|
1
|
+
import { useReducer } from "react";
|
|
2
|
+
import { initialState } from "../types/index.js";
|
|
3
|
+
function adminListReducer(state, action) {
|
|
4
|
+
switch (action.type) {
|
|
5
5
|
case "SET_SEARCH":
|
|
6
|
-
return { ...
|
|
6
|
+
return { ...state, search: action.payload };
|
|
7
7
|
case "SET_DEBOUNCED_SEARCH":
|
|
8
|
-
return { ...
|
|
8
|
+
return { ...state, debouncedSearch: action.payload };
|
|
9
9
|
case "SET_SKIP":
|
|
10
|
-
return { ...
|
|
10
|
+
return { ...state, skip: action.payload };
|
|
11
11
|
case "SET_PAGE_SIZE":
|
|
12
|
-
return { ...
|
|
12
|
+
return { ...state, pageSize: action.payload };
|
|
13
13
|
case "SET_SORT":
|
|
14
|
-
return { ...
|
|
14
|
+
return { ...state, sort: action.payload };
|
|
15
15
|
case "SET_VISIBLE_COLUMNS":
|
|
16
|
-
return { ...
|
|
16
|
+
return { ...state, visibleColumns: action.payload };
|
|
17
17
|
case "TOGGLE_COLUMN_SELECTOR":
|
|
18
|
-
return { ...
|
|
18
|
+
return { ...state, showColumnSelector: !state.showColumnSelector };
|
|
19
19
|
case "SET_SEARCH_FIELDS":
|
|
20
|
-
return { ...
|
|
20
|
+
return { ...state, searchFields: action.payload };
|
|
21
21
|
case "TOGGLE_SEARCH_FIELD_SELECTOR":
|
|
22
|
-
return { ...
|
|
22
|
+
return { ...state, showSearchFieldSelector: !state.showSearchFieldSelector };
|
|
23
23
|
case "SET_FILTERS":
|
|
24
|
-
return { ...
|
|
24
|
+
return { ...state, filters: action.payload };
|
|
25
25
|
case "TOGGLE_FILTERS":
|
|
26
|
-
return { ...
|
|
26
|
+
return { ...state, showFilters: !state.showFilters };
|
|
27
27
|
case "RESET_PAGINATION":
|
|
28
|
-
return { ...
|
|
28
|
+
return { ...state, skip: 0 };
|
|
29
29
|
case "RESET_FILTERS":
|
|
30
|
-
return { ...
|
|
30
|
+
return { ...state, filters: {} };
|
|
31
31
|
default:
|
|
32
|
-
return
|
|
32
|
+
return state;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
const [
|
|
37
|
-
return { state
|
|
35
|
+
function useAdminList() {
|
|
36
|
+
const [state, dispatch] = useReducer(adminListReducer, initialState);
|
|
37
|
+
return { state, dispatch };
|
|
38
38
|
}
|
|
39
39
|
export {
|
|
40
|
-
|
|
40
|
+
useAdminList
|
|
41
41
|
};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { useEffect
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
if (!
|
|
5
|
-
const
|
|
6
|
-
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
function useClickOutside(ref, handler, isActive = true) {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
if (!isActive) return;
|
|
5
|
+
const handleClickOutside = (event) => {
|
|
6
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
7
|
+
handler();
|
|
8
|
+
}
|
|
7
9
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
11
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
12
|
+
}, [handler, isActive]);
|
|
10
13
|
}
|
|
11
14
|
export {
|
|
12
|
-
|
|
15
|
+
useClickOutside
|
|
13
16
|
};
|
package/lib/hooks/useDebounce.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { useState
|
|
2
|
-
function
|
|
3
|
-
const [
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
return () => clearTimeout(
|
|
9
|
-
}, [
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
function useDebounce(value, delay) {
|
|
3
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const timer = setTimeout(() => {
|
|
6
|
+
setDebouncedValue(value);
|
|
7
|
+
}, delay);
|
|
8
|
+
return () => clearTimeout(timer);
|
|
9
|
+
}, [value, delay]);
|
|
10
|
+
return debouncedValue;
|
|
10
11
|
}
|
|
11
12
|
export {
|
|
12
|
-
|
|
13
|
+
useDebounce
|
|
13
14
|
};
|