@nestledjs/data-browser 0.1.6 → 0.1.8
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
package/index.js
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { AdminDataProvider
|
|
2
|
-
import { AdminDataCreateErrorBoundary
|
|
3
|
-
import { AdminDataEditErrorBoundary
|
|
4
|
-
import { AdminDataErrorBoundary
|
|
5
|
-
import { AdminDataIndexPage
|
|
6
|
-
import { AdminDataLayout
|
|
7
|
-
import { initialState
|
|
8
|
-
import { useAdminList
|
|
9
|
-
import { useClickOutside
|
|
10
|
-
import { useDebounce
|
|
11
|
-
import { useRelationData
|
|
12
|
-
import { DateRangeFilter
|
|
13
|
-
import { NumberRangeFilter
|
|
14
|
-
import { RelationDropdownButton
|
|
15
|
-
import { RelationFilterField
|
|
16
|
-
import { AdminBreadcrumbs
|
|
17
|
-
import { AdminEmptyState
|
|
18
|
-
import { AdminStatusDisplay
|
|
19
|
-
import { buildFormFields
|
|
20
|
-
import { AdminLocalStorage
|
|
21
|
-
import { formatFieldName
|
|
1
|
+
import { AdminDataProvider, useAdminDataContext } from "./lib/context/AdminDataContext.js";
|
|
2
|
+
import { AdminDataCreateErrorBoundary, AdminDataCreatePage } from "./lib/pages/AdminDataCreatePage.js";
|
|
3
|
+
import { AdminDataEditErrorBoundary, AdminDataEditPage } from "./lib/pages/AdminDataEditPage.js";
|
|
4
|
+
import { AdminDataErrorBoundary, AdminDataListPage } from "./lib/pages/AdminDataListPage.js";
|
|
5
|
+
import { AdminDataIndexPage } from "./lib/pages/AdminDataIndexPage.js";
|
|
6
|
+
import { AdminDataLayout } from "./lib/layouts/AdminDataLayout.js";
|
|
7
|
+
import { initialState } from "./lib/types/index.js";
|
|
8
|
+
import { useAdminList } from "./lib/hooks/useAdminList.js";
|
|
9
|
+
import { useClickOutside } from "./lib/hooks/useClickOutside.js";
|
|
10
|
+
import { useDebounce } from "./lib/hooks/useDebounce.js";
|
|
11
|
+
import { useRelationData } from "./lib/hooks/useRelationData.js";
|
|
12
|
+
import { DateRangeFilter } from "./lib/components/filters/DateRangeFilter.js";
|
|
13
|
+
import { NumberRangeFilter } from "./lib/components/filters/NumberRangeFilter.js";
|
|
14
|
+
import { RelationDropdownButton, RelationDropdownContent, RelationItem, RelationItemList, RelationSearchInput } from "./lib/components/filters/RelationComponents.js";
|
|
15
|
+
import { RelationFilterField } from "./lib/components/filters/RelationFilterField.js";
|
|
16
|
+
import { AdminBreadcrumbs } from "./lib/components/shared/AdminBreadcrumbs.js";
|
|
17
|
+
import { AdminEmptyState, AdminErrorState, AdminLoadingState } from "./lib/components/shared/AdminErrorStates.js";
|
|
18
|
+
import { AdminStatusDisplay, AdminUserStatus } from "./lib/components/shared/AdminStatusDisplay.js";
|
|
19
|
+
import { buildFormFields, cleanFormInput, getAdminDocuments, getMutationName } from "./lib/utils/graphql-utils.js";
|
|
20
|
+
import { AdminLocalStorage, SecureAdminLocalStorage } from "./lib/utils/secure-storage.js";
|
|
21
|
+
import { formatFieldName, getItemDisplayName, getSmartSearchFields, kebabCase, normalizeModelNameForDocument, spacedWords } from "./lib/utils/string-utils.js";
|
|
22
22
|
export {
|
|
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
|
-
|
|
23
|
+
AdminBreadcrumbs,
|
|
24
|
+
AdminDataCreateErrorBoundary,
|
|
25
|
+
AdminDataCreatePage,
|
|
26
|
+
AdminDataEditErrorBoundary,
|
|
27
|
+
AdminDataEditPage,
|
|
28
|
+
AdminDataErrorBoundary,
|
|
29
|
+
AdminDataIndexPage,
|
|
30
|
+
AdminDataLayout,
|
|
31
|
+
AdminDataListPage,
|
|
32
|
+
AdminDataProvider,
|
|
33
|
+
AdminEmptyState,
|
|
34
|
+
AdminErrorState,
|
|
35
|
+
AdminLoadingState,
|
|
36
|
+
AdminLocalStorage,
|
|
37
|
+
AdminStatusDisplay,
|
|
38
|
+
AdminUserStatus,
|
|
39
|
+
DateRangeFilter,
|
|
40
|
+
NumberRangeFilter,
|
|
41
|
+
RelationDropdownButton,
|
|
42
|
+
RelationDropdownContent,
|
|
43
|
+
RelationFilterField,
|
|
44
|
+
RelationItem,
|
|
45
|
+
RelationItemList,
|
|
46
|
+
RelationSearchInput,
|
|
47
|
+
SecureAdminLocalStorage,
|
|
48
|
+
buildFormFields,
|
|
49
|
+
cleanFormInput,
|
|
50
|
+
formatFieldName,
|
|
51
|
+
getAdminDocuments,
|
|
52
|
+
getItemDisplayName,
|
|
53
|
+
getMutationName,
|
|
54
|
+
getSmartSearchFields,
|
|
55
|
+
initialState,
|
|
56
|
+
kebabCase,
|
|
57
|
+
normalizeModelNameForDocument,
|
|
58
|
+
spacedWords,
|
|
59
|
+
useAdminDataContext,
|
|
60
|
+
useAdminList,
|
|
61
|
+
useClickOutside,
|
|
62
|
+
useDebounce,
|
|
63
|
+
useRelationData
|
|
64
64
|
};
|
|
@@ -1,105 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
fieldName
|
|
5
|
-
currentValue
|
|
6
|
-
onChange
|
|
1
|
+
import { formatFieldName } from "../../utils/string-utils.js";
|
|
2
|
+
var _jsxFileName = "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/DateRangeFilter.tsx";
|
|
3
|
+
function DateRangeFilter({
|
|
4
|
+
fieldName,
|
|
5
|
+
currentValue,
|
|
6
|
+
onChange
|
|
7
7
|
}) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} else
|
|
17
|
-
delete
|
|
18
|
-
|
|
8
|
+
const fromDate = (currentValue == null ? void 0 : currentValue.gte) ? new Date(currentValue.gte).toISOString().split("T")[0] : "";
|
|
9
|
+
const toDate = (currentValue == null ? void 0 : currentValue.lte) ? new Date(currentValue.lte).toISOString().split("T")[0] : "";
|
|
10
|
+
const handleFromChange = (date) => {
|
|
11
|
+
const newValue = {
|
|
12
|
+
...currentValue
|
|
13
|
+
};
|
|
14
|
+
if (date) {
|
|
15
|
+
newValue.gte = new Date(date).toISOString();
|
|
16
|
+
} else {
|
|
17
|
+
delete newValue.gte;
|
|
18
|
+
}
|
|
19
|
+
if (!newValue.gte && !newValue.lte) {
|
|
20
|
+
onChange(void 0);
|
|
21
|
+
} else {
|
|
22
|
+
onChange(newValue);
|
|
23
|
+
}
|
|
19
24
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
className: "w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-green-web focus:border-green-web"
|
|
40
|
-
},
|
|
41
|
-
void 0,
|
|
42
|
-
!1,
|
|
43
|
-
{
|
|
44
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/DateRangeFilter.tsx",
|
|
45
|
-
lineNumber: 62,
|
|
46
|
-
columnNumber: 11
|
|
47
|
-
},
|
|
48
|
-
this
|
|
49
|
-
)
|
|
50
|
-
] }, void 0, !0, {
|
|
51
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/DateRangeFilter.tsx",
|
|
52
|
-
lineNumber: 60,
|
|
53
|
-
columnNumber: 9
|
|
54
|
-
}, this),
|
|
55
|
-
/* @__PURE__ */ s("div", { children: [
|
|
56
|
-
/* @__PURE__ */ s("label", { className: "block text-xs text-gray-500 mb-1", children: "To" }, void 0, !1, {
|
|
57
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/DateRangeFilter.tsx",
|
|
58
|
-
lineNumber: 70,
|
|
59
|
-
columnNumber: 11
|
|
60
|
-
}, this),
|
|
61
|
-
/* @__PURE__ */ s(
|
|
62
|
-
"input",
|
|
63
|
-
{
|
|
64
|
-
type: "date",
|
|
65
|
-
value: a,
|
|
66
|
-
onChange: (l) => d(l.target.value),
|
|
67
|
-
className: "w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-green-web focus:border-green-web"
|
|
68
|
-
},
|
|
69
|
-
void 0,
|
|
70
|
-
!1,
|
|
71
|
-
{
|
|
72
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/DateRangeFilter.tsx",
|
|
73
|
-
lineNumber: 71,
|
|
74
|
-
columnNumber: 11
|
|
75
|
-
},
|
|
76
|
-
this
|
|
77
|
-
)
|
|
78
|
-
] }, void 0, !0, {
|
|
79
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/DateRangeFilter.tsx",
|
|
80
|
-
lineNumber: 69,
|
|
81
|
-
columnNumber: 9
|
|
82
|
-
}, this)
|
|
83
|
-
] }, void 0, !0, {
|
|
84
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/DateRangeFilter.tsx",
|
|
85
|
-
lineNumber: 59,
|
|
86
|
-
columnNumber: 7
|
|
87
|
-
}, this),
|
|
88
|
-
(i || a) && /* @__PURE__ */ s("div", { className: "text-xs text-gray-500", children: [
|
|
89
|
-
i && a && `${i} to ${a}`,
|
|
90
|
-
i && !a && `From ${i}`,
|
|
91
|
-
!i && a && `Until ${a}`
|
|
92
|
-
] }, void 0, !0, {
|
|
93
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/DateRangeFilter.tsx",
|
|
94
|
-
lineNumber: 80,
|
|
95
|
-
columnNumber: 9
|
|
96
|
-
}, this)
|
|
97
|
-
] }, void 0, !0, {
|
|
98
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/DateRangeFilter.tsx",
|
|
25
|
+
const handleToChange = (date) => {
|
|
26
|
+
const newValue = {
|
|
27
|
+
...currentValue
|
|
28
|
+
};
|
|
29
|
+
if (date) {
|
|
30
|
+
const endOfDay = new Date(date);
|
|
31
|
+
endOfDay.setHours(23, 59, 59, 999);
|
|
32
|
+
newValue.lte = endOfDay.toISOString();
|
|
33
|
+
} else {
|
|
34
|
+
delete newValue.lte;
|
|
35
|
+
}
|
|
36
|
+
if (!newValue.gte && !newValue.lte) {
|
|
37
|
+
onChange(void 0);
|
|
38
|
+
} else {
|
|
39
|
+
onChange(newValue);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ React.createElement("div", { className: "space-y-1", __self: this, __source: {
|
|
43
|
+
fileName: _jsxFileName,
|
|
99
44
|
lineNumber: 55,
|
|
100
45
|
columnNumber: 5
|
|
101
|
-
}, this
|
|
46
|
+
} }, /* @__PURE__ */ React.createElement("label", { className: "block text-sm font-medium text-gray-700", __self: this, __source: {
|
|
47
|
+
fileName: _jsxFileName,
|
|
48
|
+
lineNumber: 56,
|
|
49
|
+
columnNumber: 7
|
|
50
|
+
} }, formatFieldName(fieldName)), /* @__PURE__ */ React.createElement("div", { className: "grid grid-cols-2 gap-2", __self: this, __source: {
|
|
51
|
+
fileName: _jsxFileName,
|
|
52
|
+
lineNumber: 59,
|
|
53
|
+
columnNumber: 7
|
|
54
|
+
} }, /* @__PURE__ */ React.createElement("div", { __self: this, __source: {
|
|
55
|
+
fileName: _jsxFileName,
|
|
56
|
+
lineNumber: 60,
|
|
57
|
+
columnNumber: 9
|
|
58
|
+
} }, /* @__PURE__ */ React.createElement("label", { className: "block text-xs text-gray-500 mb-1", __self: this, __source: {
|
|
59
|
+
fileName: _jsxFileName,
|
|
60
|
+
lineNumber: 61,
|
|
61
|
+
columnNumber: 11
|
|
62
|
+
} }, "From"), /* @__PURE__ */ React.createElement("input", { type: "date", value: fromDate, onChange: (e) => handleFromChange(e.target.value), className: "w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-green-web focus:border-green-web", __self: this, __source: {
|
|
63
|
+
fileName: _jsxFileName,
|
|
64
|
+
lineNumber: 62,
|
|
65
|
+
columnNumber: 11
|
|
66
|
+
} })), /* @__PURE__ */ React.createElement("div", { __self: this, __source: {
|
|
67
|
+
fileName: _jsxFileName,
|
|
68
|
+
lineNumber: 69,
|
|
69
|
+
columnNumber: 9
|
|
70
|
+
} }, /* @__PURE__ */ React.createElement("label", { className: "block text-xs text-gray-500 mb-1", __self: this, __source: {
|
|
71
|
+
fileName: _jsxFileName,
|
|
72
|
+
lineNumber: 70,
|
|
73
|
+
columnNumber: 11
|
|
74
|
+
} }, "To"), /* @__PURE__ */ React.createElement("input", { type: "date", value: toDate, onChange: (e) => handleToChange(e.target.value), className: "w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-green-web focus:border-green-web", __self: this, __source: {
|
|
75
|
+
fileName: _jsxFileName,
|
|
76
|
+
lineNumber: 71,
|
|
77
|
+
columnNumber: 11
|
|
78
|
+
} }))), (fromDate || toDate) && /* @__PURE__ */ React.createElement("div", { className: "text-xs text-gray-500", __self: this, __source: {
|
|
79
|
+
fileName: _jsxFileName,
|
|
80
|
+
lineNumber: 80,
|
|
81
|
+
columnNumber: 9
|
|
82
|
+
} }, fromDate && toDate && `${fromDate} to ${toDate}`, fromDate && !toDate && `From ${fromDate}`, !fromDate && toDate && `Until ${toDate}`));
|
|
102
83
|
}
|
|
103
84
|
export {
|
|
104
|
-
|
|
85
|
+
DateRangeFilter
|
|
105
86
|
};
|
|
@@ -1,115 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
fieldName
|
|
5
|
-
fieldType
|
|
6
|
-
currentValue
|
|
7
|
-
onChange
|
|
1
|
+
import { formatFieldName } from "../../utils/string-utils.js";
|
|
2
|
+
var _jsxFileName = "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/NumberRangeFilter.tsx";
|
|
3
|
+
function NumberRangeFilter({
|
|
4
|
+
fieldName,
|
|
5
|
+
fieldType,
|
|
6
|
+
currentValue,
|
|
7
|
+
onChange
|
|
8
8
|
}) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
const minValue = (currentValue == null ? void 0 : currentValue.gte) !== void 0 ? currentValue.gte.toString() : "";
|
|
10
|
+
const maxValue = (currentValue == null ? void 0 : currentValue.lte) !== void 0 ? currentValue.lte.toString() : "";
|
|
11
|
+
const parseNumber = (value) => {
|
|
12
|
+
if (!value) return void 0;
|
|
13
|
+
if (fieldType === "int" || fieldType === "bigint") {
|
|
14
|
+
const parsed = parseInt(value, 10);
|
|
15
|
+
return isNaN(parsed) ? void 0 : parsed;
|
|
16
|
+
} else if (fieldType === "float" || fieldType === "decimal") {
|
|
17
|
+
const parsed = parseFloat(value);
|
|
18
|
+
return isNaN(parsed) ? void 0 : parsed;
|
|
18
19
|
}
|
|
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
|
-
this
|
|
57
|
-
)
|
|
58
|
-
] }, void 0, !0, {
|
|
59
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/NumberRangeFilter.tsx",
|
|
60
|
-
lineNumber: 79,
|
|
61
|
-
columnNumber: 9
|
|
62
|
-
}, this),
|
|
63
|
-
/* @__PURE__ */ i("div", { children: [
|
|
64
|
-
/* @__PURE__ */ i("label", { className: "block text-xs text-gray-500 mb-1", children: "Max" }, void 0, !1, {
|
|
65
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/NumberRangeFilter.tsx",
|
|
66
|
-
lineNumber: 91,
|
|
67
|
-
columnNumber: 11
|
|
68
|
-
}, this),
|
|
69
|
-
/* @__PURE__ */ i(
|
|
70
|
-
"input",
|
|
71
|
-
{
|
|
72
|
-
type: "number",
|
|
73
|
-
step: d,
|
|
74
|
-
value: n,
|
|
75
|
-
onChange: (t) => u(t.target.value),
|
|
76
|
-
placeholder: "No maximum",
|
|
77
|
-
className: "w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-green-web focus:border-green-web"
|
|
78
|
-
},
|
|
79
|
-
void 0,
|
|
80
|
-
!1,
|
|
81
|
-
{
|
|
82
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/NumberRangeFilter.tsx",
|
|
83
|
-
lineNumber: 92,
|
|
84
|
-
columnNumber: 11
|
|
85
|
-
},
|
|
86
|
-
this
|
|
87
|
-
)
|
|
88
|
-
] }, void 0, !0, {
|
|
89
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/NumberRangeFilter.tsx",
|
|
90
|
-
lineNumber: 90,
|
|
91
|
-
columnNumber: 9
|
|
92
|
-
}, this)
|
|
93
|
-
] }, void 0, !0, {
|
|
94
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/NumberRangeFilter.tsx",
|
|
95
|
-
lineNumber: 78,
|
|
96
|
-
columnNumber: 7
|
|
97
|
-
}, this),
|
|
98
|
-
(l || n) && /* @__PURE__ */ i("div", { className: "text-xs text-gray-500", children: [
|
|
99
|
-
l && n && `${l} to ${n}`,
|
|
100
|
-
l && !n && `≥ ${l}`,
|
|
101
|
-
!l && n && `≤ ${n}`
|
|
102
|
-
] }, void 0, !0, {
|
|
103
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/NumberRangeFilter.tsx",
|
|
104
|
-
lineNumber: 103,
|
|
105
|
-
columnNumber: 9
|
|
106
|
-
}, this)
|
|
107
|
-
] }, void 0, !0, {
|
|
108
|
-
fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/NumberRangeFilter.tsx",
|
|
20
|
+
return void 0;
|
|
21
|
+
};
|
|
22
|
+
const handleMinChange = (value) => {
|
|
23
|
+
const newValue = {
|
|
24
|
+
...currentValue
|
|
25
|
+
};
|
|
26
|
+
const parsedValue = parseNumber(value);
|
|
27
|
+
if (parsedValue !== void 0) {
|
|
28
|
+
newValue.gte = parsedValue;
|
|
29
|
+
} else {
|
|
30
|
+
delete newValue.gte;
|
|
31
|
+
}
|
|
32
|
+
if (newValue.gte === void 0 && newValue.lte === void 0) {
|
|
33
|
+
onChange(void 0);
|
|
34
|
+
} else {
|
|
35
|
+
onChange(newValue);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const handleMaxChange = (value) => {
|
|
39
|
+
const newValue = {
|
|
40
|
+
...currentValue
|
|
41
|
+
};
|
|
42
|
+
const parsedValue = parseNumber(value);
|
|
43
|
+
if (parsedValue !== void 0) {
|
|
44
|
+
newValue.lte = parsedValue;
|
|
45
|
+
} else {
|
|
46
|
+
delete newValue.lte;
|
|
47
|
+
}
|
|
48
|
+
if (newValue.gte === void 0 && newValue.lte === void 0) {
|
|
49
|
+
onChange(void 0);
|
|
50
|
+
} else {
|
|
51
|
+
onChange(newValue);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const step = fieldType === "int" || fieldType === "bigint" ? "1" : "any";
|
|
55
|
+
return /* @__PURE__ */ React.createElement("div", { className: "space-y-1", __self: this, __source: {
|
|
56
|
+
fileName: _jsxFileName,
|
|
109
57
|
lineNumber: 74,
|
|
110
58
|
columnNumber: 5
|
|
111
|
-
}, this
|
|
59
|
+
} }, /* @__PURE__ */ React.createElement("label", { className: "block text-sm font-medium text-gray-700", __self: this, __source: {
|
|
60
|
+
fileName: _jsxFileName,
|
|
61
|
+
lineNumber: 75,
|
|
62
|
+
columnNumber: 7
|
|
63
|
+
} }, formatFieldName(fieldName)), /* @__PURE__ */ React.createElement("div", { className: "grid grid-cols-2 gap-2", __self: this, __source: {
|
|
64
|
+
fileName: _jsxFileName,
|
|
65
|
+
lineNumber: 78,
|
|
66
|
+
columnNumber: 7
|
|
67
|
+
} }, /* @__PURE__ */ React.createElement("div", { __self: this, __source: {
|
|
68
|
+
fileName: _jsxFileName,
|
|
69
|
+
lineNumber: 79,
|
|
70
|
+
columnNumber: 9
|
|
71
|
+
} }, /* @__PURE__ */ React.createElement("label", { className: "block text-xs text-gray-500 mb-1", __self: this, __source: {
|
|
72
|
+
fileName: _jsxFileName,
|
|
73
|
+
lineNumber: 80,
|
|
74
|
+
columnNumber: 11
|
|
75
|
+
} }, "Min"), /* @__PURE__ */ React.createElement("input", { type: "number", step, value: minValue, onChange: (e) => handleMinChange(e.target.value), placeholder: "No minimum", className: "w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-green-web focus:border-green-web", __self: this, __source: {
|
|
76
|
+
fileName: _jsxFileName,
|
|
77
|
+
lineNumber: 81,
|
|
78
|
+
columnNumber: 11
|
|
79
|
+
} })), /* @__PURE__ */ React.createElement("div", { __self: this, __source: {
|
|
80
|
+
fileName: _jsxFileName,
|
|
81
|
+
lineNumber: 90,
|
|
82
|
+
columnNumber: 9
|
|
83
|
+
} }, /* @__PURE__ */ React.createElement("label", { className: "block text-xs text-gray-500 mb-1", __self: this, __source: {
|
|
84
|
+
fileName: _jsxFileName,
|
|
85
|
+
lineNumber: 91,
|
|
86
|
+
columnNumber: 11
|
|
87
|
+
} }, "Max"), /* @__PURE__ */ React.createElement("input", { type: "number", step, value: maxValue, onChange: (e) => handleMaxChange(e.target.value), placeholder: "No maximum", className: "w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-green-web focus:border-green-web", __self: this, __source: {
|
|
88
|
+
fileName: _jsxFileName,
|
|
89
|
+
lineNumber: 92,
|
|
90
|
+
columnNumber: 11
|
|
91
|
+
} }))), (minValue || maxValue) && /* @__PURE__ */ React.createElement("div", { className: "text-xs text-gray-500", __self: this, __source: {
|
|
92
|
+
fileName: _jsxFileName,
|
|
93
|
+
lineNumber: 103,
|
|
94
|
+
columnNumber: 9
|
|
95
|
+
} }, minValue && maxValue && `${minValue} to ${maxValue}`, minValue && !maxValue && `≥ ${minValue}`, !minValue && maxValue && `≤ ${maxValue}`));
|
|
112
96
|
}
|
|
113
97
|
export {
|
|
114
|
-
|
|
98
|
+
NumberRangeFilter
|
|
115
99
|
};
|