rockin 0.0.38 → 0.0.39
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/dist/chunk-JPOAXESG.js +250 -0
- package/dist/hooks/index.js +15 -253
- package/dist/layout.js +6 -2
- package/package.json +1 -1
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildFlagSearchParamHref,
|
|
3
|
+
hasFlagSearchParam,
|
|
4
|
+
searchParamKeys,
|
|
5
|
+
searchParams
|
|
6
|
+
} from "./chunk-M5NHRP6W.js";
|
|
7
|
+
|
|
8
|
+
// src/hooks/useSearchParams.ts
|
|
9
|
+
import {
|
|
10
|
+
useSearchParams as useNextSearchParams,
|
|
11
|
+
usePathname,
|
|
12
|
+
useRouter
|
|
13
|
+
} from "next/navigation";
|
|
14
|
+
import {
|
|
15
|
+
debounce,
|
|
16
|
+
useQueryStates
|
|
17
|
+
} from "nuqs";
|
|
18
|
+
import { NuqsAdapter } from "nuqs/adapters/next/app";
|
|
19
|
+
import * as React from "react";
|
|
20
|
+
var SEARCH_DELAY = 300;
|
|
21
|
+
var QUERY_SEARCH_DELAY = 300;
|
|
22
|
+
function isSearchPath(pathname) {
|
|
23
|
+
return pathname === "/" || pathname === "/pos" || pathname === "/orders" || pathname === "/bin" || pathname.startsWith("/pos/") || pathname.startsWith("/orders/") || pathname.startsWith("/bin/");
|
|
24
|
+
}
|
|
25
|
+
var pendingSearchFocus = false;
|
|
26
|
+
function searchFocus() {
|
|
27
|
+
if (!pendingSearchFocus) return false;
|
|
28
|
+
pendingSearchFocus = false;
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
function searchHref(query) {
|
|
32
|
+
const params = new URLSearchParams();
|
|
33
|
+
if (query) params.set(searchParamKeys.query, query);
|
|
34
|
+
const search = params.toString();
|
|
35
|
+
return search ? `/?${search}` : "/";
|
|
36
|
+
}
|
|
37
|
+
function useSearchParams() {
|
|
38
|
+
const pathname = usePathname();
|
|
39
|
+
const router = useRouter();
|
|
40
|
+
const nativeSearchParams = useNextSearchParams();
|
|
41
|
+
const [isPending, startTransition] = React.useTransition();
|
|
42
|
+
const [params, setParams] = useQueryStates(searchParams, {
|
|
43
|
+
urlKeys: searchParamKeys,
|
|
44
|
+
history: "replace",
|
|
45
|
+
shallow: false,
|
|
46
|
+
scroll: false,
|
|
47
|
+
startTransition
|
|
48
|
+
});
|
|
49
|
+
const productQueryRef = React.useRef(params.query);
|
|
50
|
+
const productNavigationQueuedRef = React.useRef(false);
|
|
51
|
+
const onSearchPath = isSearchPath(pathname);
|
|
52
|
+
const cart = hasFlagSearchParam(nativeSearchParams, "cart");
|
|
53
|
+
const notification = hasFlagSearchParam(nativeSearchParams, "notification");
|
|
54
|
+
const updateParams = React.useCallback(
|
|
55
|
+
(values, options) => {
|
|
56
|
+
void setParams(values, options);
|
|
57
|
+
},
|
|
58
|
+
[setParams]
|
|
59
|
+
);
|
|
60
|
+
const setQuery = React.useCallback(
|
|
61
|
+
(value) => {
|
|
62
|
+
const update = setParams(
|
|
63
|
+
{ query: value, page: 1 },
|
|
64
|
+
{
|
|
65
|
+
history: "replace",
|
|
66
|
+
scroll: false,
|
|
67
|
+
shallow: !onSearchPath,
|
|
68
|
+
limitUrlUpdates: debounce(QUERY_SEARCH_DELAY)
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
if (onSearchPath) return;
|
|
72
|
+
productQueryRef.current = value;
|
|
73
|
+
if (productNavigationQueuedRef.current) return;
|
|
74
|
+
productNavigationQueuedRef.current = true;
|
|
75
|
+
void update.then(() => {
|
|
76
|
+
productNavigationQueuedRef.current = false;
|
|
77
|
+
const query = productQueryRef.current.trim();
|
|
78
|
+
if (!query) return;
|
|
79
|
+
pendingSearchFocus = true;
|
|
80
|
+
router.push(searchHref(query), { scroll: true });
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
[onSearchPath, router, setParams]
|
|
84
|
+
);
|
|
85
|
+
const commitQuery = React.useCallback(() => {
|
|
86
|
+
const query = params.query.trim();
|
|
87
|
+
if (!query || onSearchPath) return;
|
|
88
|
+
pendingSearchFocus = true;
|
|
89
|
+
router.push(searchHref(query), { scroll: true });
|
|
90
|
+
}, [onSearchPath, params.query, router]);
|
|
91
|
+
const setCategory = React.useCallback(
|
|
92
|
+
(value) => {
|
|
93
|
+
updateParams(
|
|
94
|
+
{ category: value, page: 1 },
|
|
95
|
+
{ history: "push", shallow: false, scroll: true }
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
[updateParams]
|
|
99
|
+
);
|
|
100
|
+
const setProductStatus = React.useCallback(
|
|
101
|
+
(value) => {
|
|
102
|
+
updateParams(
|
|
103
|
+
{ productStatus: value, page: 1 },
|
|
104
|
+
{ history: "push", shallow: false, scroll: true }
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
[updateParams]
|
|
108
|
+
);
|
|
109
|
+
const setUser = React.useCallback(
|
|
110
|
+
(value) => {
|
|
111
|
+
updateParams(
|
|
112
|
+
{ user: value },
|
|
113
|
+
{
|
|
114
|
+
history: "replace",
|
|
115
|
+
shallow: false,
|
|
116
|
+
scroll: false,
|
|
117
|
+
limitUrlUpdates: debounce(SEARCH_DELAY)
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
[updateParams]
|
|
122
|
+
);
|
|
123
|
+
const setPage = React.useCallback(
|
|
124
|
+
(value) => {
|
|
125
|
+
updateParams(
|
|
126
|
+
{ page: value },
|
|
127
|
+
{ history: "replace", shallow: true, scroll: false }
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
[updateParams]
|
|
131
|
+
);
|
|
132
|
+
const setUserTransaction = React.useCallback(
|
|
133
|
+
(value) => {
|
|
134
|
+
updateParams(
|
|
135
|
+
{ user: value, transaction: "", transactionPage: 1 },
|
|
136
|
+
{ history: "replace", shallow: false, scroll: false }
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
[updateParams]
|
|
140
|
+
);
|
|
141
|
+
const setTransactionDetail = React.useCallback(
|
|
142
|
+
(value) => {
|
|
143
|
+
updateParams(
|
|
144
|
+
{ transaction: value },
|
|
145
|
+
{ history: "replace", shallow: false, scroll: false }
|
|
146
|
+
);
|
|
147
|
+
},
|
|
148
|
+
[updateParams]
|
|
149
|
+
);
|
|
150
|
+
const clearTransactionDetail = React.useCallback(() => {
|
|
151
|
+
updateParams(
|
|
152
|
+
{ transaction: "" },
|
|
153
|
+
{ history: "replace", shallow: false, scroll: false }
|
|
154
|
+
);
|
|
155
|
+
}, [updateParams]);
|
|
156
|
+
const clearUserTransaction = React.useCallback(() => {
|
|
157
|
+
updateParams(
|
|
158
|
+
{ user: "", transaction: "", transactionPage: 1 },
|
|
159
|
+
{ history: "replace", shallow: false, scroll: false }
|
|
160
|
+
);
|
|
161
|
+
}, [updateParams]);
|
|
162
|
+
const clearAll = React.useCallback(() => {
|
|
163
|
+
updateParams(
|
|
164
|
+
{
|
|
165
|
+
query: "",
|
|
166
|
+
category: "",
|
|
167
|
+
productStatus: "active",
|
|
168
|
+
user: "",
|
|
169
|
+
transaction: "",
|
|
170
|
+
page: 1,
|
|
171
|
+
transactionPage: 1
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
history: "replace",
|
|
175
|
+
shallow: false,
|
|
176
|
+
scroll: true
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
}, [updateParams]);
|
|
180
|
+
const setCart = React.useCallback(
|
|
181
|
+
(value) => {
|
|
182
|
+
window.history.replaceState(
|
|
183
|
+
null,
|
|
184
|
+
"",
|
|
185
|
+
buildFlagSearchParamHref(pathname, nativeSearchParams, "cart", value)
|
|
186
|
+
);
|
|
187
|
+
},
|
|
188
|
+
[nativeSearchParams, pathname]
|
|
189
|
+
);
|
|
190
|
+
const toggleCart = React.useCallback(() => {
|
|
191
|
+
setCart(!cart);
|
|
192
|
+
}, [cart, setCart]);
|
|
193
|
+
const setNotification = React.useCallback(
|
|
194
|
+
(value) => {
|
|
195
|
+
window.history.replaceState(
|
|
196
|
+
null,
|
|
197
|
+
"",
|
|
198
|
+
buildFlagSearchParamHref(
|
|
199
|
+
pathname,
|
|
200
|
+
nativeSearchParams,
|
|
201
|
+
"notification",
|
|
202
|
+
value
|
|
203
|
+
)
|
|
204
|
+
);
|
|
205
|
+
},
|
|
206
|
+
[nativeSearchParams, pathname]
|
|
207
|
+
);
|
|
208
|
+
return {
|
|
209
|
+
...params,
|
|
210
|
+
cart,
|
|
211
|
+
setCart,
|
|
212
|
+
openCart: () => setCart(true),
|
|
213
|
+
closeCart: () => setCart(false),
|
|
214
|
+
toggleCart,
|
|
215
|
+
notification,
|
|
216
|
+
setNotification,
|
|
217
|
+
openNotification: () => setNotification(true),
|
|
218
|
+
closeNotification: () => setNotification(false),
|
|
219
|
+
toggleNotification: () => setNotification(!notification),
|
|
220
|
+
setQuery,
|
|
221
|
+
setCategory,
|
|
222
|
+
setProductStatus,
|
|
223
|
+
setUser,
|
|
224
|
+
setPage,
|
|
225
|
+
setUserTransaction,
|
|
226
|
+
setTransactionDetail,
|
|
227
|
+
commitQuery,
|
|
228
|
+
clearQuery: () => setQuery(""),
|
|
229
|
+
clearCategory: () => setCategory(""),
|
|
230
|
+
clearProductStatus: () => setProductStatus("active"),
|
|
231
|
+
clearUser: () => setUser(""),
|
|
232
|
+
clearTransactionDetail,
|
|
233
|
+
clearUserTransaction,
|
|
234
|
+
clearPage: () => setPage(1),
|
|
235
|
+
clearAll,
|
|
236
|
+
isQueryPending: isPending,
|
|
237
|
+
isCategoryPending: isPending,
|
|
238
|
+
isUserPending: isPending,
|
|
239
|
+
setTab: (value) => updateParams(
|
|
240
|
+
{ tab: value },
|
|
241
|
+
{ history: "replace", shallow: false, scroll: false }
|
|
242
|
+
)
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export {
|
|
247
|
+
NuqsAdapter,
|
|
248
|
+
searchFocus,
|
|
249
|
+
useSearchParams
|
|
250
|
+
};
|
package/dist/hooks/index.js
CHANGED
|
@@ -16,12 +16,6 @@ import "../chunk-VFDNWPOI.js";
|
|
|
16
16
|
import "../chunk-COPQJFDI.js";
|
|
17
17
|
import "../chunk-MZBLIA6C.js";
|
|
18
18
|
import "../chunk-7JJBATB2.js";
|
|
19
|
-
import {
|
|
20
|
-
buildFlagSearchParamHref,
|
|
21
|
-
hasFlagSearchParam,
|
|
22
|
-
searchParamKeys,
|
|
23
|
-
searchParams
|
|
24
|
-
} from "../chunk-M5NHRP6W.js";
|
|
25
19
|
import "../chunk-DVNTJNDP.js";
|
|
26
20
|
import {
|
|
27
21
|
useFullscreen,
|
|
@@ -30,245 +24,13 @@ import {
|
|
|
30
24
|
import {
|
|
31
25
|
isNativeApp
|
|
32
26
|
} from "../chunk-2LD63YUK.js";
|
|
33
|
-
import "../chunk-X56ZEDOW.js";
|
|
34
|
-
|
|
35
|
-
// src/hooks/useSearchParams.ts
|
|
36
|
-
import {
|
|
37
|
-
useSearchParams as useNextSearchParams,
|
|
38
|
-
usePathname,
|
|
39
|
-
useRouter
|
|
40
|
-
} from "next/navigation";
|
|
41
27
|
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
import
|
|
47
|
-
|
|
48
|
-
var QUERY_SEARCH_DELAY = 300;
|
|
49
|
-
function isSearchPath(pathname) {
|
|
50
|
-
return pathname === "/" || pathname === "/pos" || pathname === "/orders" || pathname === "/bin" || pathname.startsWith("/pos/") || pathname.startsWith("/orders/") || pathname.startsWith("/bin/");
|
|
51
|
-
}
|
|
52
|
-
var pendingSearchFocus = false;
|
|
53
|
-
function searchFocus() {
|
|
54
|
-
if (!pendingSearchFocus) return false;
|
|
55
|
-
pendingSearchFocus = false;
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
function searchHref(query) {
|
|
59
|
-
const params = new URLSearchParams();
|
|
60
|
-
if (query) params.set(searchParamKeys.query, query);
|
|
61
|
-
const search = params.toString();
|
|
62
|
-
return search ? `/?${search}` : "/";
|
|
63
|
-
}
|
|
64
|
-
function useSearchParams() {
|
|
65
|
-
const pathname = usePathname();
|
|
66
|
-
const router = useRouter();
|
|
67
|
-
const nativeSearchParams = useNextSearchParams();
|
|
68
|
-
const [isPending, startTransition] = React.useTransition();
|
|
69
|
-
const [params, setParams] = useQueryStates(searchParams, {
|
|
70
|
-
urlKeys: searchParamKeys,
|
|
71
|
-
history: "replace",
|
|
72
|
-
shallow: false,
|
|
73
|
-
scroll: false,
|
|
74
|
-
startTransition
|
|
75
|
-
});
|
|
76
|
-
const productQueryRef = React.useRef(params.query);
|
|
77
|
-
const productNavigationQueuedRef = React.useRef(false);
|
|
78
|
-
const onSearchPath = isSearchPath(pathname);
|
|
79
|
-
const cart = hasFlagSearchParam(nativeSearchParams, "cart");
|
|
80
|
-
const notification = hasFlagSearchParam(nativeSearchParams, "notification");
|
|
81
|
-
const updateParams = React.useCallback(
|
|
82
|
-
(values, options) => {
|
|
83
|
-
void setParams(values, options);
|
|
84
|
-
},
|
|
85
|
-
[setParams]
|
|
86
|
-
);
|
|
87
|
-
const setQuery = React.useCallback(
|
|
88
|
-
(value) => {
|
|
89
|
-
const update = setParams(
|
|
90
|
-
{ query: value, page: 1 },
|
|
91
|
-
{
|
|
92
|
-
history: "replace",
|
|
93
|
-
scroll: false,
|
|
94
|
-
shallow: !onSearchPath,
|
|
95
|
-
limitUrlUpdates: debounce(QUERY_SEARCH_DELAY)
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
if (onSearchPath) return;
|
|
99
|
-
productQueryRef.current = value;
|
|
100
|
-
if (productNavigationQueuedRef.current) return;
|
|
101
|
-
productNavigationQueuedRef.current = true;
|
|
102
|
-
void update.then(() => {
|
|
103
|
-
productNavigationQueuedRef.current = false;
|
|
104
|
-
const query = productQueryRef.current.trim();
|
|
105
|
-
if (!query) return;
|
|
106
|
-
pendingSearchFocus = true;
|
|
107
|
-
router.push(searchHref(query), { scroll: true });
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
[onSearchPath, router, setParams]
|
|
111
|
-
);
|
|
112
|
-
const commitQuery = React.useCallback(() => {
|
|
113
|
-
const query = params.query.trim();
|
|
114
|
-
if (!query || onSearchPath) return;
|
|
115
|
-
pendingSearchFocus = true;
|
|
116
|
-
router.push(searchHref(query), { scroll: true });
|
|
117
|
-
}, [onSearchPath, params.query, router]);
|
|
118
|
-
const setCategory = React.useCallback(
|
|
119
|
-
(value) => {
|
|
120
|
-
updateParams(
|
|
121
|
-
{ category: value, page: 1 },
|
|
122
|
-
{ history: "push", shallow: false, scroll: true }
|
|
123
|
-
);
|
|
124
|
-
},
|
|
125
|
-
[updateParams]
|
|
126
|
-
);
|
|
127
|
-
const setProductStatus = React.useCallback(
|
|
128
|
-
(value) => {
|
|
129
|
-
updateParams(
|
|
130
|
-
{ productStatus: value, page: 1 },
|
|
131
|
-
{ history: "push", shallow: false, scroll: true }
|
|
132
|
-
);
|
|
133
|
-
},
|
|
134
|
-
[updateParams]
|
|
135
|
-
);
|
|
136
|
-
const setUser = React.useCallback(
|
|
137
|
-
(value) => {
|
|
138
|
-
updateParams(
|
|
139
|
-
{ user: value },
|
|
140
|
-
{
|
|
141
|
-
history: "replace",
|
|
142
|
-
shallow: false,
|
|
143
|
-
scroll: false,
|
|
144
|
-
limitUrlUpdates: debounce(SEARCH_DELAY)
|
|
145
|
-
}
|
|
146
|
-
);
|
|
147
|
-
},
|
|
148
|
-
[updateParams]
|
|
149
|
-
);
|
|
150
|
-
const setPage = React.useCallback(
|
|
151
|
-
(value) => {
|
|
152
|
-
updateParams(
|
|
153
|
-
{ page: value },
|
|
154
|
-
{ history: "replace", shallow: true, scroll: false }
|
|
155
|
-
);
|
|
156
|
-
},
|
|
157
|
-
[updateParams]
|
|
158
|
-
);
|
|
159
|
-
const setUserTransaction = React.useCallback(
|
|
160
|
-
(value) => {
|
|
161
|
-
updateParams(
|
|
162
|
-
{ user: value, transaction: "", transactionPage: 1 },
|
|
163
|
-
{ history: "replace", shallow: false, scroll: false }
|
|
164
|
-
);
|
|
165
|
-
},
|
|
166
|
-
[updateParams]
|
|
167
|
-
);
|
|
168
|
-
const setTransactionDetail = React.useCallback(
|
|
169
|
-
(value) => {
|
|
170
|
-
updateParams(
|
|
171
|
-
{ transaction: value },
|
|
172
|
-
{ history: "replace", shallow: false, scroll: false }
|
|
173
|
-
);
|
|
174
|
-
},
|
|
175
|
-
[updateParams]
|
|
176
|
-
);
|
|
177
|
-
const clearTransactionDetail = React.useCallback(() => {
|
|
178
|
-
updateParams(
|
|
179
|
-
{ transaction: "" },
|
|
180
|
-
{ history: "replace", shallow: false, scroll: false }
|
|
181
|
-
);
|
|
182
|
-
}, [updateParams]);
|
|
183
|
-
const clearUserTransaction = React.useCallback(() => {
|
|
184
|
-
updateParams(
|
|
185
|
-
{ user: "", transaction: "", transactionPage: 1 },
|
|
186
|
-
{ history: "replace", shallow: false, scroll: false }
|
|
187
|
-
);
|
|
188
|
-
}, [updateParams]);
|
|
189
|
-
const clearAll = React.useCallback(() => {
|
|
190
|
-
updateParams(
|
|
191
|
-
{
|
|
192
|
-
query: "",
|
|
193
|
-
category: "",
|
|
194
|
-
productStatus: "active",
|
|
195
|
-
user: "",
|
|
196
|
-
transaction: "",
|
|
197
|
-
page: 1,
|
|
198
|
-
transactionPage: 1
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
history: "replace",
|
|
202
|
-
shallow: false,
|
|
203
|
-
scroll: true
|
|
204
|
-
}
|
|
205
|
-
);
|
|
206
|
-
}, [updateParams]);
|
|
207
|
-
const setCart = React.useCallback(
|
|
208
|
-
(value) => {
|
|
209
|
-
window.history.replaceState(
|
|
210
|
-
null,
|
|
211
|
-
"",
|
|
212
|
-
buildFlagSearchParamHref(pathname, nativeSearchParams, "cart", value)
|
|
213
|
-
);
|
|
214
|
-
},
|
|
215
|
-
[nativeSearchParams, pathname]
|
|
216
|
-
);
|
|
217
|
-
const toggleCart = React.useCallback(() => {
|
|
218
|
-
setCart(!cart);
|
|
219
|
-
}, [cart, setCart]);
|
|
220
|
-
const setNotification = React.useCallback(
|
|
221
|
-
(value) => {
|
|
222
|
-
window.history.replaceState(
|
|
223
|
-
null,
|
|
224
|
-
"",
|
|
225
|
-
buildFlagSearchParamHref(
|
|
226
|
-
pathname,
|
|
227
|
-
nativeSearchParams,
|
|
228
|
-
"notification",
|
|
229
|
-
value
|
|
230
|
-
)
|
|
231
|
-
);
|
|
232
|
-
},
|
|
233
|
-
[nativeSearchParams, pathname]
|
|
234
|
-
);
|
|
235
|
-
return {
|
|
236
|
-
...params,
|
|
237
|
-
cart,
|
|
238
|
-
setCart,
|
|
239
|
-
openCart: () => setCart(true),
|
|
240
|
-
closeCart: () => setCart(false),
|
|
241
|
-
toggleCart,
|
|
242
|
-
notification,
|
|
243
|
-
setNotification,
|
|
244
|
-
openNotification: () => setNotification(true),
|
|
245
|
-
closeNotification: () => setNotification(false),
|
|
246
|
-
toggleNotification: () => setNotification(!notification),
|
|
247
|
-
setQuery,
|
|
248
|
-
setCategory,
|
|
249
|
-
setProductStatus,
|
|
250
|
-
setUser,
|
|
251
|
-
setPage,
|
|
252
|
-
setUserTransaction,
|
|
253
|
-
setTransactionDetail,
|
|
254
|
-
commitQuery,
|
|
255
|
-
clearQuery: () => setQuery(""),
|
|
256
|
-
clearCategory: () => setCategory(""),
|
|
257
|
-
clearProductStatus: () => setProductStatus("active"),
|
|
258
|
-
clearUser: () => setUser(""),
|
|
259
|
-
clearTransactionDetail,
|
|
260
|
-
clearUserTransaction,
|
|
261
|
-
clearPage: () => setPage(1),
|
|
262
|
-
clearAll,
|
|
263
|
-
isQueryPending: isPending,
|
|
264
|
-
isCategoryPending: isPending,
|
|
265
|
-
isUserPending: isPending,
|
|
266
|
-
setTab: (value) => updateParams(
|
|
267
|
-
{ tab: value },
|
|
268
|
-
{ history: "replace", shallow: false, scroll: false }
|
|
269
|
-
)
|
|
270
|
-
};
|
|
271
|
-
}
|
|
28
|
+
NuqsAdapter,
|
|
29
|
+
searchFocus,
|
|
30
|
+
useSearchParams
|
|
31
|
+
} from "../chunk-JPOAXESG.js";
|
|
32
|
+
import "../chunk-M5NHRP6W.js";
|
|
33
|
+
import "../chunk-X56ZEDOW.js";
|
|
272
34
|
|
|
273
35
|
// src/hooks/useSideRail.ts
|
|
274
36
|
import { useSyncExternalStore } from "react";
|
|
@@ -339,21 +101,21 @@ function useDataGridMove() {
|
|
|
339
101
|
}
|
|
340
102
|
|
|
341
103
|
// src/ui/data-table/hooks/use-grid-changes.ts
|
|
342
|
-
import * as
|
|
104
|
+
import * as React from "react";
|
|
343
105
|
function useGridChanges(grid, options = {}) {
|
|
344
106
|
const initialRows = options.initialRows ?? [];
|
|
345
|
-
const [dirtyRowIds, setDirtyRowIds] =
|
|
346
|
-
const [deletedRowIds, setDeletedRowIds] =
|
|
107
|
+
const [dirtyRowIds, setDirtyRowIds] = React.useState(/* @__PURE__ */ new Set());
|
|
108
|
+
const [deletedRowIds, setDeletedRowIds] = React.useState(
|
|
347
109
|
/* @__PURE__ */ new Set()
|
|
348
110
|
);
|
|
349
|
-
const updateCell =
|
|
111
|
+
const updateCell = React.useCallback(
|
|
350
112
|
(rowId, columnId, value) => {
|
|
351
113
|
grid.updateCell(rowId, columnId, value);
|
|
352
114
|
setDirtyRowIds((current) => new Set(current).add(rowId));
|
|
353
115
|
},
|
|
354
116
|
[grid]
|
|
355
117
|
);
|
|
356
|
-
const getChangeSet =
|
|
118
|
+
const getChangeSet = React.useCallback(() => {
|
|
357
119
|
const created = [];
|
|
358
120
|
const updated = [];
|
|
359
121
|
const initialById = new Map(
|
|
@@ -374,7 +136,7 @@ function useGridChanges(grid, options = {}) {
|
|
|
374
136
|
});
|
|
375
137
|
return { created, updated, deleted };
|
|
376
138
|
}, [deletedRowIds, dirtyRowIds, grid, initialRows]);
|
|
377
|
-
const insertRows =
|
|
139
|
+
const insertRows = React.useCallback(
|
|
378
140
|
(rows, index) => {
|
|
379
141
|
grid.insertRows(rows, index);
|
|
380
142
|
setDirtyRowIds((current) => {
|
|
@@ -385,14 +147,14 @@ function useGridChanges(grid, options = {}) {
|
|
|
385
147
|
},
|
|
386
148
|
[grid]
|
|
387
149
|
);
|
|
388
|
-
const deleteRows =
|
|
150
|
+
const deleteRows = React.useCallback(
|
|
389
151
|
(rowIds) => {
|
|
390
152
|
grid.deleteRows(rowIds);
|
|
391
153
|
setDeletedRowIds((current) => /* @__PURE__ */ new Set([...current, ...rowIds]));
|
|
392
154
|
},
|
|
393
155
|
[grid]
|
|
394
156
|
);
|
|
395
|
-
const reset =
|
|
157
|
+
const reset = React.useCallback(
|
|
396
158
|
(rows = initialRows) => {
|
|
397
159
|
grid.updateRows(() => rows);
|
|
398
160
|
setDirtyRowIds(/* @__PURE__ */ new Set());
|
|
@@ -400,7 +162,7 @@ function useGridChanges(grid, options = {}) {
|
|
|
400
162
|
},
|
|
401
163
|
[grid, initialRows]
|
|
402
164
|
);
|
|
403
|
-
const reconcile =
|
|
165
|
+
const reconcile = React.useCallback(
|
|
404
166
|
(succeededIds, failedIds = []) => {
|
|
405
167
|
const succeeded = new Set(succeededIds);
|
|
406
168
|
setDirtyRowIds(
|
package/dist/layout.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NuqsAdapter
|
|
3
|
+
} from "./chunk-JPOAXESG.js";
|
|
4
|
+
import "./chunk-M5NHRP6W.js";
|
|
1
5
|
import {
|
|
2
6
|
preferencesScript
|
|
3
7
|
} from "./chunk-X56ZEDOW.js";
|
|
@@ -5,10 +9,10 @@ import {
|
|
|
5
9
|
// src/layout/layout.tsx
|
|
6
10
|
import { cookies } from "next/headers";
|
|
7
11
|
import { ClientProvider } from "./provider.js";
|
|
8
|
-
import {
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
13
|
async function Layout({ cookie, ...props }) {
|
|
10
14
|
const header = cookie ?? (await cookies()).toString();
|
|
11
|
-
return /* @__PURE__ */ jsxs(
|
|
15
|
+
return /* @__PURE__ */ jsxs(NuqsAdapter, { children: [
|
|
12
16
|
/* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: preferencesScript(header) } }),
|
|
13
17
|
/* @__PURE__ */ jsx(ClientProvider, { cookie: header, ...props })
|
|
14
18
|
] });
|