@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.
@@ -1,205 +1,215 @@
1
- import { jsxDEV as o, Fragment as I } from "react/jsx-dev-runtime";
2
- import { QuestionMarkCircleIcon as S, PauseCircleIcon as $, CheckCircleIcon as b, XCircleIcon as u, ExclamationTriangleIcon as A, ClockIcon as D } from "@heroicons/react/24/solid";
3
- const L = (e) => ({
4
- active: {
5
- icon: b,
6
- bgColor: "bg-green-100",
7
- textColor: "text-green-800",
8
- borderColor: "border-green-200",
9
- defaultLabel: "Active"
10
- },
11
- inactive: {
12
- icon: u,
13
- bgColor: "bg-gray-100",
14
- textColor: "text-gray-800",
15
- borderColor: "border-gray-200",
16
- defaultLabel: "Inactive"
17
- },
18
- pending: {
19
- icon: D,
20
- bgColor: "bg-yellow-100",
21
- textColor: "text-yellow-800",
22
- borderColor: "border-yellow-200",
23
- defaultLabel: "Pending"
24
- },
25
- approved: {
26
- icon: b,
27
- bgColor: "bg-green-100",
28
- textColor: "text-green-800",
29
- borderColor: "border-green-200",
30
- defaultLabel: "Approved"
31
- },
32
- rejected: {
33
- icon: u,
34
- bgColor: "bg-red-100",
35
- textColor: "text-red-800",
36
- borderColor: "border-red-200",
37
- defaultLabel: "Rejected"
38
- },
39
- warning: {
40
- icon: A,
41
- bgColor: "bg-yellow-100",
42
- textColor: "text-yellow-800",
43
- borderColor: "border-yellow-200",
44
- defaultLabel: "Warning"
45
- },
46
- error: {
47
- icon: u,
48
- bgColor: "bg-red-100",
49
- textColor: "text-red-800",
50
- borderColor: "border-red-200",
51
- defaultLabel: "Error"
52
- },
53
- success: {
54
- icon: b,
55
- bgColor: "bg-green-100",
56
- textColor: "text-green-800",
57
- borderColor: "border-green-200",
58
- defaultLabel: "Success"
59
- },
60
- paused: {
61
- icon: $,
62
- bgColor: "bg-blue-100",
63
- textColor: "text-blue-800",
64
- borderColor: "border-blue-200",
65
- defaultLabel: "Paused"
66
- },
67
- unknown: {
68
- icon: S,
69
- bgColor: "bg-gray-100",
70
- textColor: "text-gray-800",
71
- borderColor: "border-gray-200",
72
- defaultLabel: "Unknown"
73
- }
74
- })[e], x = (e) => ({
75
- small: {
76
- text: "text-xs",
77
- padding: "px-2 py-1",
78
- icon: "h-3 w-3",
79
- dot: "h-2 w-2"
80
- },
81
- medium: {
82
- text: "text-sm",
83
- padding: "px-2.5 py-1.5",
84
- icon: "h-4 w-4",
85
- dot: "h-3 w-3"
86
- },
87
- large: {
88
- text: "text-base",
89
- padding: "px-3 py-2",
90
- icon: "h-5 w-5",
91
- dot: "h-4 w-4"
92
- }
93
- })[e], P = (e) => ({
94
- badge: "inline-flex items-center rounded border font-medium",
95
- pill: "inline-flex items-center rounded-full border font-medium",
96
- dot: "inline-flex items-center font-medium",
97
- full: "flex items-center justify-center rounded border font-medium w-full"
98
- })[e], U = (e) => ({
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 f ? /* @__PURE__ */ o(
146
- "button",
147
- {
148
- type: "button",
149
- onClick: w,
150
- className: C,
151
- title: i,
152
- children: p
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
- void 0,
155
- !1,
156
- {
157
- fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/shared/AdminStatusDisplay.tsx",
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
- this
162
- ) : /* @__PURE__ */ o("span", { className: C, title: i, children: p }, void 0, !1, {
163
- fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/shared/AdminStatusDisplay.tsx",
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
- }, this);
186
+ } }, content);
167
187
  }
168
- function V({
169
- status: e,
170
- showLabel: t = !1,
171
- size: c = "medium",
172
- className: n = ""
188
+ function AdminUserStatus({
189
+ status,
190
+ showLabel = false,
191
+ size = "medium",
192
+ className = ""
173
193
  }) {
174
- const r = U(e), a = x(c), s = a.dot, i = t ? a.text : "";
175
- return /* @__PURE__ */ o("div", { className: `inline-flex items-center ${n}`, children: [
176
- /* @__PURE__ */ o(
177
- "span",
178
- {
179
- className: `inline-block rounded-full ${r.color} ${s}`,
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
- O as AdminStatusDisplay,
204
- V as AdminUserStatus
213
+ AdminStatusDisplay,
214
+ AdminUserStatus
205
215
  };
@@ -1,28 +1,32 @@
1
- import { jsxDEV as o } from "react/jsx-dev-runtime";
2
- import { createContext as d, useContext as m } from "react";
3
- const e = d(null);
4
- function l({
5
- children: t,
6
- sdk: n,
7
- databaseModels: a,
8
- basePath: r = "/admin/data",
9
- formTheme: i
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__ */ o(e.Provider, { value: { sdk: n, databaseModels: a, basePath: r, formTheme: i }, children: t }, void 0, !1, {
12
- fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/context/AdminDataContext.tsx",
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
- }, this);
20
+ } }, children);
16
21
  }
17
- function x() {
18
- const t = m(e);
19
- if (!t)
20
- throw new Error(
21
- "useAdminDataContext must be used within AdminDataProvider. Make sure to wrap your admin data routes with <AdminDataProvider>."
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
- l as AdminDataProvider,
27
- x as useAdminDataContext
30
+ AdminDataProvider,
31
+ useAdminDataContext
28
32
  };
@@ -1,41 +1,41 @@
1
- import { useReducer as S } from "react";
2
- import { initialState as E } from "../types/index.js";
3
- function u(r, e) {
4
- switch (e.type) {
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 { ...r, search: e.payload };
6
+ return { ...state, search: action.payload };
7
7
  case "SET_DEBOUNCED_SEARCH":
8
- return { ...r, debouncedSearch: e.payload };
8
+ return { ...state, debouncedSearch: action.payload };
9
9
  case "SET_SKIP":
10
- return { ...r, skip: e.payload };
10
+ return { ...state, skip: action.payload };
11
11
  case "SET_PAGE_SIZE":
12
- return { ...r, pageSize: e.payload };
12
+ return { ...state, pageSize: action.payload };
13
13
  case "SET_SORT":
14
- return { ...r, sort: e.payload };
14
+ return { ...state, sort: action.payload };
15
15
  case "SET_VISIBLE_COLUMNS":
16
- return { ...r, visibleColumns: e.payload };
16
+ return { ...state, visibleColumns: action.payload };
17
17
  case "TOGGLE_COLUMN_SELECTOR":
18
- return { ...r, showColumnSelector: !r.showColumnSelector };
18
+ return { ...state, showColumnSelector: !state.showColumnSelector };
19
19
  case "SET_SEARCH_FIELDS":
20
- return { ...r, searchFields: e.payload };
20
+ return { ...state, searchFields: action.payload };
21
21
  case "TOGGLE_SEARCH_FIELD_SELECTOR":
22
- return { ...r, showSearchFieldSelector: !r.showSearchFieldSelector };
22
+ return { ...state, showSearchFieldSelector: !state.showSearchFieldSelector };
23
23
  case "SET_FILTERS":
24
- return { ...r, filters: e.payload };
24
+ return { ...state, filters: action.payload };
25
25
  case "TOGGLE_FILTERS":
26
- return { ...r, showFilters: !r.showFilters };
26
+ return { ...state, showFilters: !state.showFilters };
27
27
  case "RESET_PAGINATION":
28
- return { ...r, skip: 0 };
28
+ return { ...state, skip: 0 };
29
29
  case "RESET_FILTERS":
30
- return { ...r, filters: {} };
30
+ return { ...state, filters: {} };
31
31
  default:
32
- return r;
32
+ return state;
33
33
  }
34
34
  }
35
- function s() {
36
- const [r, e] = S(u, E);
37
- return { state: r, dispatch: e };
35
+ function useAdminList() {
36
+ const [state, dispatch] = useReducer(adminListReducer, initialState);
37
+ return { state, dispatch };
38
38
  }
39
39
  export {
40
- s as useAdminList
40
+ useAdminList
41
41
  };
@@ -1,13 +1,16 @@
1
- import { useEffect as o } from "react";
2
- function i(e, t, n = !0) {
3
- o(() => {
4
- if (!n) return;
5
- const r = (u) => {
6
- e.current && !e.current.contains(u.target) && t();
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
- return document.addEventListener("mousedown", r), () => document.removeEventListener("mousedown", r);
9
- }, [t, n]);
10
+ document.addEventListener("mousedown", handleClickOutside);
11
+ return () => document.removeEventListener("mousedown", handleClickOutside);
12
+ }, [handler, isActive]);
10
13
  }
11
14
  export {
12
- i as useClickOutside
15
+ useClickOutside
13
16
  };
@@ -1,13 +1,14 @@
1
- import { useState as r, useEffect as c } from "react";
2
- function i(e, t) {
3
- const [o, u] = r(e);
4
- return c(() => {
5
- const n = setTimeout(() => {
6
- u(e);
7
- }, t);
8
- return () => clearTimeout(n);
9
- }, [e, t]), o;
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
- i as useDebounce
13
+ useDebounce
13
14
  };