@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 CHANGED
@@ -1,64 +1,64 @@
1
- import { AdminDataProvider as r, useAdminDataContext as o } from "./lib/context/AdminDataContext.js";
2
- import { AdminDataCreateErrorBoundary as m, AdminDataCreatePage as i } from "./lib/pages/AdminDataCreatePage.js";
3
- import { AdminDataEditErrorBoundary as d, AdminDataEditPage as p } from "./lib/pages/AdminDataEditPage.js";
4
- import { AdminDataErrorBoundary as u, AdminDataListPage as x } from "./lib/pages/AdminDataListPage.js";
5
- import { AdminDataIndexPage as s } from "./lib/pages/AdminDataIndexPage.js";
6
- import { AdminDataLayout as D } from "./lib/layouts/AdminDataLayout.js";
7
- import { initialState as c } from "./lib/types/index.js";
8
- import { useAdminList as F } from "./lib/hooks/useAdminList.js";
9
- import { useClickOutside as y } from "./lib/hooks/useClickOutside.js";
10
- import { useDebounce as L } from "./lib/hooks/useDebounce.js";
11
- import { useRelationData as C } from "./lib/hooks/useRelationData.js";
12
- import { DateRangeFilter as B } from "./lib/components/filters/DateRangeFilter.js";
13
- import { NumberRangeFilter as P } from "./lib/components/filters/NumberRangeFilter.js";
14
- import { RelationDropdownButton as k, RelationDropdownContent as w, RelationItem as M, RelationItemList as v, RelationSearchInput as z } from "./lib/components/filters/RelationComponents.js";
15
- import { RelationFilterField as U } from "./lib/components/filters/RelationFilterField.js";
16
- import { AdminBreadcrumbs as j } from "./lib/components/shared/AdminBreadcrumbs.js";
17
- import { AdminEmptyState as G, AdminErrorState as H, AdminLoadingState as J } from "./lib/components/shared/AdminErrorStates.js";
18
- import { AdminStatusDisplay as Q, AdminUserStatus as T } from "./lib/components/shared/AdminStatusDisplay.js";
19
- import { buildFormFields as X, cleanFormInput as Y, getAdminDocuments as Z, getMutationName as _ } from "./lib/utils/graphql-utils.js";
20
- import { AdminLocalStorage as ee, SecureAdminLocalStorage as te } from "./lib/utils/secure-storage.js";
21
- import { formatFieldName as oe, getItemDisplayName as ae, getSmartSearchFields as me, kebabCase as ie, normalizeModelNameForDocument as ne, spacedWords as de } from "./lib/utils/string-utils.js";
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
- j as AdminBreadcrumbs,
24
- m as AdminDataCreateErrorBoundary,
25
- i as AdminDataCreatePage,
26
- d as AdminDataEditErrorBoundary,
27
- p as AdminDataEditPage,
28
- u as AdminDataErrorBoundary,
29
- s as AdminDataIndexPage,
30
- D as AdminDataLayout,
31
- x as AdminDataListPage,
32
- r as AdminDataProvider,
33
- G as AdminEmptyState,
34
- H as AdminErrorState,
35
- J as AdminLoadingState,
36
- ee as AdminLocalStorage,
37
- Q as AdminStatusDisplay,
38
- T as AdminUserStatus,
39
- B as DateRangeFilter,
40
- P as NumberRangeFilter,
41
- k as RelationDropdownButton,
42
- w as RelationDropdownContent,
43
- U as RelationFilterField,
44
- M as RelationItem,
45
- v as RelationItemList,
46
- z as RelationSearchInput,
47
- te as SecureAdminLocalStorage,
48
- X as buildFormFields,
49
- Y as cleanFormInput,
50
- oe as formatFieldName,
51
- Z as getAdminDocuments,
52
- ae as getItemDisplayName,
53
- _ as getMutationName,
54
- me as getSmartSearchFields,
55
- c as initialState,
56
- ie as kebabCase,
57
- ne as normalizeModelNameForDocument,
58
- de as spacedWords,
59
- o as useAdminDataContext,
60
- F as useAdminList,
61
- y as useClickOutside,
62
- L as useDebounce,
63
- C as useRelationData
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 { jsxDEV as s } from "react/jsx-dev-runtime";
2
- import { formatFieldName as c } from "../../utils/string-utils.js";
3
- function u({
4
- fieldName: o,
5
- currentValue: t,
6
- onChange: n
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 i = t != null && t.gte ? new Date(t.gte).toISOString().split("T")[0] : "", a = t != null && t.lte ? new Date(t.lte).toISOString().split("T")[0] : "", m = (l) => {
9
- const e = { ...t };
10
- l ? e.gte = new Date(l).toISOString() : delete e.gte, !e.gte && !e.lte ? n(void 0) : n(e);
11
- }, d = (l) => {
12
- const e = { ...t };
13
- if (l) {
14
- const r = new Date(l);
15
- r.setHours(23, 59, 59, 999), e.lte = r.toISOString();
16
- } else
17
- delete e.lte;
18
- !e.gte && !e.lte ? n(void 0) : n(e);
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
- return /* @__PURE__ */ s("div", { className: "space-y-1", children: [
21
- /* @__PURE__ */ s("label", { className: "block text-sm font-medium text-gray-700", children: c(o) }, void 0, !1, {
22
- fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/DateRangeFilter.tsx",
23
- lineNumber: 56,
24
- columnNumber: 7
25
- }, this),
26
- /* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-2", children: [
27
- /* @__PURE__ */ s("div", { children: [
28
- /* @__PURE__ */ s("label", { className: "block text-xs text-gray-500 mb-1", children: "From" }, void 0, !1, {
29
- fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/DateRangeFilter.tsx",
30
- lineNumber: 61,
31
- columnNumber: 11
32
- }, this),
33
- /* @__PURE__ */ s(
34
- "input",
35
- {
36
- type: "date",
37
- value: i,
38
- onChange: (l) => m(l.target.value),
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
- u as DateRangeFilter
85
+ DateRangeFilter
105
86
  };
@@ -1,115 +1,99 @@
1
- import { jsxDEV as i } from "react/jsx-dev-runtime";
2
- import { formatFieldName as N } from "../../utils/string-utils.js";
3
- function p({
4
- fieldName: b,
5
- fieldType: a,
6
- currentValue: s,
7
- onChange: m
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 l = (s == null ? void 0 : s.gte) !== void 0 ? s.gte.toString() : "", n = (s == null ? void 0 : s.lte) !== void 0 ? s.lte.toString() : "", o = (t) => {
10
- if (t) {
11
- if (a === "int" || a === "bigint") {
12
- const e = parseInt(t, 10);
13
- return isNaN(e) ? void 0 : e;
14
- } else if (a === "float" || a === "decimal") {
15
- const e = parseFloat(t);
16
- return isNaN(e) ? void 0 : e;
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
- }, c = (t) => {
20
- const e = { ...s }, r = o(t);
21
- r !== void 0 ? e.gte = r : delete e.gte, e.gte === void 0 && e.lte === void 0 ? m(void 0) : m(e);
22
- }, u = (t) => {
23
- const e = { ...s }, r = o(t);
24
- r !== void 0 ? e.lte = r : delete e.lte, e.gte === void 0 && e.lte === void 0 ? m(void 0) : m(e);
25
- }, d = a === "int" || a === "bigint" ? "1" : "any";
26
- return /* @__PURE__ */ i("div", { className: "space-y-1", children: [
27
- /* @__PURE__ */ i("label", { className: "block text-sm font-medium text-gray-700", children: N(b) }, void 0, !1, {
28
- fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/NumberRangeFilter.tsx",
29
- lineNumber: 75,
30
- columnNumber: 7
31
- }, this),
32
- /* @__PURE__ */ i("div", { className: "grid grid-cols-2 gap-2", children: [
33
- /* @__PURE__ */ i("div", { children: [
34
- /* @__PURE__ */ i("label", { className: "block text-xs text-gray-500 mb-1", children: "Min" }, void 0, !1, {
35
- fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/NumberRangeFilter.tsx",
36
- lineNumber: 80,
37
- columnNumber: 11
38
- }, this),
39
- /* @__PURE__ */ i(
40
- "input",
41
- {
42
- type: "number",
43
- step: d,
44
- value: l,
45
- onChange: (t) => c(t.target.value),
46
- placeholder: "No minimum",
47
- 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"
48
- },
49
- void 0,
50
- !1,
51
- {
52
- fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/components/filters/NumberRangeFilter.tsx",
53
- lineNumber: 81,
54
- columnNumber: 11
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
- p as NumberRangeFilter
98
+ NumberRangeFilter
115
99
  };