rockin 0.0.37 → 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-6JS62NO4.js +276 -0
- package/dist/chunk-G3RYS466.js +68 -0
- package/dist/chunk-JPOAXESG.js +250 -0
- package/dist/{chunk-RT2YVQ2Y.js → chunk-WR27Y55B.js} +1 -1
- package/dist/chunk-X56ZEDOW.js +46 -0
- package/dist/hooks/index.js +20 -257
- package/dist/index.d.ts +87 -4
- package/dist/index.js +10 -9
- package/dist/layout.d.ts +11 -0
- package/dist/layout.js +22 -0
- package/dist/lib/index.d.ts +79 -1
- package/dist/lib/index.js +13 -1
- package/dist/provider.d.ts +6 -4
- package/dist/provider.js +119 -8
- package/dist/styles.css +284 -200
- package/dist/ui/bridge.js +9 -3
- package/dist/ui/code-block.js +7 -4
- package/dist/ui/filters.js +7 -7
- package/dist/ui/image.js +67 -9
- package/dist/ui/index.d.ts +34 -33
- package/dist/ui/index.js +2 -1
- package/dist/ui/jelly.js +214 -16
- package/dist/ui/sonner.js +4 -1
- package/dist/ui/tabs.js +13 -690
- package/dist/ui/theme-switcher.js +47 -0
- package/dist/ui/theme-toggle.js +4 -1
- package/package.json +8 -1
- package/dist/chunk-54ZJAEO5.js +0 -209
- package/dist/chunk-5GM3YR42.js +0 -228
- /package/dist/{chunk-ATPUW3SQ.js → chunk-2LD63YUK.js} +0 -0
package/dist/hooks/index.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
useMounted
|
|
4
4
|
} from "../chunk-G4NDAZTB.js";
|
|
5
|
+
import {
|
|
6
|
+
useMediaQuery
|
|
7
|
+
} from "../chunk-G233W3IR.js";
|
|
5
8
|
import {
|
|
6
9
|
useDataGrid,
|
|
7
10
|
useDataTable,
|
|
@@ -9,265 +12,25 @@ import {
|
|
|
9
12
|
useDataTableRows,
|
|
10
13
|
useDataTableSearch
|
|
11
14
|
} from "../chunk-D6TULSM6.js";
|
|
12
|
-
import {
|
|
13
|
-
useMediaQuery
|
|
14
|
-
} from "../chunk-G233W3IR.js";
|
|
15
15
|
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,
|
|
28
22
|
useNative
|
|
29
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-WR27Y55B.js";
|
|
30
24
|
import {
|
|
31
25
|
isNativeApp
|
|
32
|
-
} from "../chunk-
|
|
33
|
-
|
|
34
|
-
// src/hooks/useSearchParams.ts
|
|
35
|
-
import {
|
|
36
|
-
useSearchParams as useNextSearchParams,
|
|
37
|
-
usePathname,
|
|
38
|
-
useRouter
|
|
39
|
-
} from "next/navigation";
|
|
26
|
+
} from "../chunk-2LD63YUK.js";
|
|
40
27
|
import {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
import
|
|
46
|
-
|
|
47
|
-
var QUERY_SEARCH_DELAY = 300;
|
|
48
|
-
function isSearchPath(pathname) {
|
|
49
|
-
return pathname === "/" || pathname === "/pos" || pathname === "/orders" || pathname === "/bin" || pathname.startsWith("/pos/") || pathname.startsWith("/orders/") || pathname.startsWith("/bin/");
|
|
50
|
-
}
|
|
51
|
-
var pendingSearchFocus = false;
|
|
52
|
-
function searchFocus() {
|
|
53
|
-
if (!pendingSearchFocus) return false;
|
|
54
|
-
pendingSearchFocus = false;
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
function searchHref(query) {
|
|
58
|
-
const params = new URLSearchParams();
|
|
59
|
-
if (query) params.set(searchParamKeys.query, query);
|
|
60
|
-
const search = params.toString();
|
|
61
|
-
return search ? `/?${search}` : "/";
|
|
62
|
-
}
|
|
63
|
-
function useSearchParams() {
|
|
64
|
-
const pathname = usePathname();
|
|
65
|
-
const router = useRouter();
|
|
66
|
-
const nativeSearchParams = useNextSearchParams();
|
|
67
|
-
const [isPending, startTransition] = React.useTransition();
|
|
68
|
-
const [params, setParams] = useQueryStates(searchParams, {
|
|
69
|
-
urlKeys: searchParamKeys,
|
|
70
|
-
history: "replace",
|
|
71
|
-
shallow: false,
|
|
72
|
-
scroll: false,
|
|
73
|
-
startTransition
|
|
74
|
-
});
|
|
75
|
-
const productQueryRef = React.useRef(params.query);
|
|
76
|
-
const productNavigationQueuedRef = React.useRef(false);
|
|
77
|
-
const onSearchPath = isSearchPath(pathname);
|
|
78
|
-
const cart = hasFlagSearchParam(nativeSearchParams, "cart");
|
|
79
|
-
const notification = hasFlagSearchParam(nativeSearchParams, "notification");
|
|
80
|
-
const updateParams = React.useCallback(
|
|
81
|
-
(values, options) => {
|
|
82
|
-
void setParams(values, options);
|
|
83
|
-
},
|
|
84
|
-
[setParams]
|
|
85
|
-
);
|
|
86
|
-
const setQuery = React.useCallback(
|
|
87
|
-
(value) => {
|
|
88
|
-
const update = setParams(
|
|
89
|
-
{ query: value, page: 1 },
|
|
90
|
-
{
|
|
91
|
-
history: "replace",
|
|
92
|
-
scroll: false,
|
|
93
|
-
shallow: !onSearchPath,
|
|
94
|
-
limitUrlUpdates: debounce(QUERY_SEARCH_DELAY)
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
if (onSearchPath) return;
|
|
98
|
-
productQueryRef.current = value;
|
|
99
|
-
if (productNavigationQueuedRef.current) return;
|
|
100
|
-
productNavigationQueuedRef.current = true;
|
|
101
|
-
void update.then(() => {
|
|
102
|
-
productNavigationQueuedRef.current = false;
|
|
103
|
-
const query = productQueryRef.current.trim();
|
|
104
|
-
if (!query) return;
|
|
105
|
-
pendingSearchFocus = true;
|
|
106
|
-
router.push(searchHref(query), { scroll: true });
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
[onSearchPath, router, setParams]
|
|
110
|
-
);
|
|
111
|
-
const commitQuery = React.useCallback(() => {
|
|
112
|
-
const query = params.query.trim();
|
|
113
|
-
if (!query || onSearchPath) return;
|
|
114
|
-
pendingSearchFocus = true;
|
|
115
|
-
router.push(searchHref(query), { scroll: true });
|
|
116
|
-
}, [onSearchPath, params.query, router]);
|
|
117
|
-
const setCategory = React.useCallback(
|
|
118
|
-
(value) => {
|
|
119
|
-
updateParams(
|
|
120
|
-
{ category: value, page: 1 },
|
|
121
|
-
{ history: "push", shallow: false, scroll: true }
|
|
122
|
-
);
|
|
123
|
-
},
|
|
124
|
-
[updateParams]
|
|
125
|
-
);
|
|
126
|
-
const setProductStatus = React.useCallback(
|
|
127
|
-
(value) => {
|
|
128
|
-
updateParams(
|
|
129
|
-
{ productStatus: value, page: 1 },
|
|
130
|
-
{ history: "push", shallow: false, scroll: true }
|
|
131
|
-
);
|
|
132
|
-
},
|
|
133
|
-
[updateParams]
|
|
134
|
-
);
|
|
135
|
-
const setUser = React.useCallback(
|
|
136
|
-
(value) => {
|
|
137
|
-
updateParams(
|
|
138
|
-
{ user: value },
|
|
139
|
-
{
|
|
140
|
-
history: "replace",
|
|
141
|
-
shallow: false,
|
|
142
|
-
scroll: false,
|
|
143
|
-
limitUrlUpdates: debounce(SEARCH_DELAY)
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
},
|
|
147
|
-
[updateParams]
|
|
148
|
-
);
|
|
149
|
-
const setPage = React.useCallback(
|
|
150
|
-
(value) => {
|
|
151
|
-
updateParams(
|
|
152
|
-
{ page: value },
|
|
153
|
-
{ history: "replace", shallow: true, scroll: false }
|
|
154
|
-
);
|
|
155
|
-
},
|
|
156
|
-
[updateParams]
|
|
157
|
-
);
|
|
158
|
-
const setUserTransaction = React.useCallback(
|
|
159
|
-
(value) => {
|
|
160
|
-
updateParams(
|
|
161
|
-
{ user: value, transaction: "", transactionPage: 1 },
|
|
162
|
-
{ history: "replace", shallow: false, scroll: false }
|
|
163
|
-
);
|
|
164
|
-
},
|
|
165
|
-
[updateParams]
|
|
166
|
-
);
|
|
167
|
-
const setTransactionDetail = React.useCallback(
|
|
168
|
-
(value) => {
|
|
169
|
-
updateParams(
|
|
170
|
-
{ transaction: value },
|
|
171
|
-
{ history: "replace", shallow: false, scroll: false }
|
|
172
|
-
);
|
|
173
|
-
},
|
|
174
|
-
[updateParams]
|
|
175
|
-
);
|
|
176
|
-
const clearTransactionDetail = React.useCallback(() => {
|
|
177
|
-
updateParams(
|
|
178
|
-
{ transaction: "" },
|
|
179
|
-
{ history: "replace", shallow: false, scroll: false }
|
|
180
|
-
);
|
|
181
|
-
}, [updateParams]);
|
|
182
|
-
const clearUserTransaction = React.useCallback(() => {
|
|
183
|
-
updateParams(
|
|
184
|
-
{ user: "", transaction: "", transactionPage: 1 },
|
|
185
|
-
{ history: "replace", shallow: false, scroll: false }
|
|
186
|
-
);
|
|
187
|
-
}, [updateParams]);
|
|
188
|
-
const clearAll = React.useCallback(() => {
|
|
189
|
-
updateParams(
|
|
190
|
-
{
|
|
191
|
-
query: "",
|
|
192
|
-
category: "",
|
|
193
|
-
productStatus: "active",
|
|
194
|
-
user: "",
|
|
195
|
-
transaction: "",
|
|
196
|
-
page: 1,
|
|
197
|
-
transactionPage: 1
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
history: "replace",
|
|
201
|
-
shallow: false,
|
|
202
|
-
scroll: true
|
|
203
|
-
}
|
|
204
|
-
);
|
|
205
|
-
}, [updateParams]);
|
|
206
|
-
const setCart = React.useCallback(
|
|
207
|
-
(value) => {
|
|
208
|
-
window.history.replaceState(
|
|
209
|
-
null,
|
|
210
|
-
"",
|
|
211
|
-
buildFlagSearchParamHref(pathname, nativeSearchParams, "cart", value)
|
|
212
|
-
);
|
|
213
|
-
},
|
|
214
|
-
[nativeSearchParams, pathname]
|
|
215
|
-
);
|
|
216
|
-
const toggleCart = React.useCallback(() => {
|
|
217
|
-
setCart(!cart);
|
|
218
|
-
}, [cart, setCart]);
|
|
219
|
-
const setNotification = React.useCallback(
|
|
220
|
-
(value) => {
|
|
221
|
-
window.history.replaceState(
|
|
222
|
-
null,
|
|
223
|
-
"",
|
|
224
|
-
buildFlagSearchParamHref(
|
|
225
|
-
pathname,
|
|
226
|
-
nativeSearchParams,
|
|
227
|
-
"notification",
|
|
228
|
-
value
|
|
229
|
-
)
|
|
230
|
-
);
|
|
231
|
-
},
|
|
232
|
-
[nativeSearchParams, pathname]
|
|
233
|
-
);
|
|
234
|
-
return {
|
|
235
|
-
...params,
|
|
236
|
-
cart,
|
|
237
|
-
setCart,
|
|
238
|
-
openCart: () => setCart(true),
|
|
239
|
-
closeCart: () => setCart(false),
|
|
240
|
-
toggleCart,
|
|
241
|
-
notification,
|
|
242
|
-
setNotification,
|
|
243
|
-
openNotification: () => setNotification(true),
|
|
244
|
-
closeNotification: () => setNotification(false),
|
|
245
|
-
toggleNotification: () => setNotification(!notification),
|
|
246
|
-
setQuery,
|
|
247
|
-
setCategory,
|
|
248
|
-
setProductStatus,
|
|
249
|
-
setUser,
|
|
250
|
-
setPage,
|
|
251
|
-
setUserTransaction,
|
|
252
|
-
setTransactionDetail,
|
|
253
|
-
commitQuery,
|
|
254
|
-
clearQuery: () => setQuery(""),
|
|
255
|
-
clearCategory: () => setCategory(""),
|
|
256
|
-
clearProductStatus: () => setProductStatus("active"),
|
|
257
|
-
clearUser: () => setUser(""),
|
|
258
|
-
clearTransactionDetail,
|
|
259
|
-
clearUserTransaction,
|
|
260
|
-
clearPage: () => setPage(1),
|
|
261
|
-
clearAll,
|
|
262
|
-
isQueryPending: isPending,
|
|
263
|
-
isCategoryPending: isPending,
|
|
264
|
-
isUserPending: isPending,
|
|
265
|
-
setTab: (value) => updateParams(
|
|
266
|
-
{ tab: value },
|
|
267
|
-
{ history: "replace", shallow: false, scroll: false }
|
|
268
|
-
)
|
|
269
|
-
};
|
|
270
|
-
}
|
|
28
|
+
NuqsAdapter,
|
|
29
|
+
searchFocus,
|
|
30
|
+
useSearchParams
|
|
31
|
+
} from "../chunk-JPOAXESG.js";
|
|
32
|
+
import "../chunk-M5NHRP6W.js";
|
|
33
|
+
import "../chunk-X56ZEDOW.js";
|
|
271
34
|
|
|
272
35
|
// src/hooks/useSideRail.ts
|
|
273
36
|
import { useSyncExternalStore } from "react";
|
|
@@ -338,21 +101,21 @@ function useDataGridMove() {
|
|
|
338
101
|
}
|
|
339
102
|
|
|
340
103
|
// src/ui/data-table/hooks/use-grid-changes.ts
|
|
341
|
-
import * as
|
|
104
|
+
import * as React from "react";
|
|
342
105
|
function useGridChanges(grid, options = {}) {
|
|
343
106
|
const initialRows = options.initialRows ?? [];
|
|
344
|
-
const [dirtyRowIds, setDirtyRowIds] =
|
|
345
|
-
const [deletedRowIds, setDeletedRowIds] =
|
|
107
|
+
const [dirtyRowIds, setDirtyRowIds] = React.useState(/* @__PURE__ */ new Set());
|
|
108
|
+
const [deletedRowIds, setDeletedRowIds] = React.useState(
|
|
346
109
|
/* @__PURE__ */ new Set()
|
|
347
110
|
);
|
|
348
|
-
const updateCell =
|
|
111
|
+
const updateCell = React.useCallback(
|
|
349
112
|
(rowId, columnId, value) => {
|
|
350
113
|
grid.updateCell(rowId, columnId, value);
|
|
351
114
|
setDirtyRowIds((current) => new Set(current).add(rowId));
|
|
352
115
|
},
|
|
353
116
|
[grid]
|
|
354
117
|
);
|
|
355
|
-
const getChangeSet =
|
|
118
|
+
const getChangeSet = React.useCallback(() => {
|
|
356
119
|
const created = [];
|
|
357
120
|
const updated = [];
|
|
358
121
|
const initialById = new Map(
|
|
@@ -373,7 +136,7 @@ function useGridChanges(grid, options = {}) {
|
|
|
373
136
|
});
|
|
374
137
|
return { created, updated, deleted };
|
|
375
138
|
}, [deletedRowIds, dirtyRowIds, grid, initialRows]);
|
|
376
|
-
const insertRows =
|
|
139
|
+
const insertRows = React.useCallback(
|
|
377
140
|
(rows, index) => {
|
|
378
141
|
grid.insertRows(rows, index);
|
|
379
142
|
setDirtyRowIds((current) => {
|
|
@@ -384,14 +147,14 @@ function useGridChanges(grid, options = {}) {
|
|
|
384
147
|
},
|
|
385
148
|
[grid]
|
|
386
149
|
);
|
|
387
|
-
const deleteRows =
|
|
150
|
+
const deleteRows = React.useCallback(
|
|
388
151
|
(rowIds) => {
|
|
389
152
|
grid.deleteRows(rowIds);
|
|
390
153
|
setDeletedRowIds((current) => /* @__PURE__ */ new Set([...current, ...rowIds]));
|
|
391
154
|
},
|
|
392
155
|
[grid]
|
|
393
156
|
);
|
|
394
|
-
const reset =
|
|
157
|
+
const reset = React.useCallback(
|
|
395
158
|
(rows = initialRows) => {
|
|
396
159
|
grid.updateRows(() => rows);
|
|
397
160
|
setDirtyRowIds(/* @__PURE__ */ new Set());
|
|
@@ -399,7 +162,7 @@ function useGridChanges(grid, options = {}) {
|
|
|
399
162
|
},
|
|
400
163
|
[grid, initialRows]
|
|
401
164
|
);
|
|
402
|
-
const reconcile =
|
|
165
|
+
const reconcile = React.useCallback(
|
|
403
166
|
(succeededIds, failedIds = []) => {
|
|
404
167
|
const succeeded = new Set(succeededIds);
|
|
405
168
|
setDirtyRowIds(
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,92 @@
|
|
|
1
|
-
export { BellIcon, BellIconHandle, IconSwap, Loader, LoaderProps } from './icon/index.js';
|
|
2
1
|
export { default as NumberFlow } from '@number-flow/react';
|
|
3
2
|
export * from 'goey-toast';
|
|
4
3
|
export * from 'motion/react';
|
|
5
|
-
export
|
|
4
|
+
export { BellIcon, BellIconHandle, IconSwap, Loader, LoaderProps } from './icon/index.js';
|
|
6
5
|
export { TopLoader, TopLoaderProps } from './loader.js';
|
|
7
|
-
|
|
8
|
-
import '
|
|
6
|
+
import * as _ui_sdk_core from '@ui-sdk/core';
|
|
7
|
+
import { ColorSchemeValue } from '@ui-sdk/core';
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import { ReactNode } from 'react';
|
|
9
10
|
import '@bprogress/next/app';
|
|
11
|
+
|
|
12
|
+
/** One set of preferences per request, created from its cookies, as ui-sdk's server rendering docs describe. */
|
|
13
|
+
declare function PreferencesProvider({ cookie, children, }: {
|
|
14
|
+
cookie?: string | null;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}): React.JSX.Element;
|
|
17
|
+
declare function usePreferences(): {
|
|
18
|
+
colorScheme: {
|
|
19
|
+
attribute: `data-${string}`;
|
|
20
|
+
global: boolean;
|
|
21
|
+
values: readonly ("system" | "light" | "dark")[];
|
|
22
|
+
defaultValue: "system" | "light" | "dark";
|
|
23
|
+
storage: {
|
|
24
|
+
id: string;
|
|
25
|
+
kind: "local" | "session" | "cookie";
|
|
26
|
+
readsOnServer: boolean;
|
|
27
|
+
script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
|
|
28
|
+
available: () => boolean;
|
|
29
|
+
get: () => string | null;
|
|
30
|
+
set: (value: string) => boolean;
|
|
31
|
+
remove: () => boolean;
|
|
32
|
+
subscribe(listener: (value: string | null) => void): () => void;
|
|
33
|
+
} | undefined;
|
|
34
|
+
initialState: _ui_sdk_core.ColorSchemeState;
|
|
35
|
+
get: () => _ui_sdk_core.ColorSchemeState;
|
|
36
|
+
set: (next: "system" | "light" | "dark", change?: {
|
|
37
|
+
reason?: _ui_sdk_core.ChangeReason;
|
|
38
|
+
event?: Event;
|
|
39
|
+
}) => boolean;
|
|
40
|
+
subscribe: (listener: (state: _ui_sdk_core.ColorSchemeState) => void) => () => void;
|
|
41
|
+
follow: <Key extends string>(store: _ui_sdk_core.ColorSchemeStore<Key>, key: Key) => () => void;
|
|
42
|
+
};
|
|
43
|
+
accent: {
|
|
44
|
+
attribute: `data-${string}`;
|
|
45
|
+
global: boolean;
|
|
46
|
+
values: readonly ("gold" | "violet" | "slate" | "mint")[];
|
|
47
|
+
defaultValue: "gold" | "violet" | "slate" | "mint";
|
|
48
|
+
storage: {
|
|
49
|
+
id: string;
|
|
50
|
+
kind: "local" | "session" | "cookie";
|
|
51
|
+
readsOnServer: boolean;
|
|
52
|
+
script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
|
|
53
|
+
available: () => boolean;
|
|
54
|
+
get: () => string | null;
|
|
55
|
+
set: (value: string) => boolean;
|
|
56
|
+
remove: () => boolean;
|
|
57
|
+
subscribe(listener: (value: string | null) => void): () => void;
|
|
58
|
+
} | undefined;
|
|
59
|
+
initialState: {
|
|
60
|
+
value: "gold" | "violet" | "slate" | "mint";
|
|
61
|
+
};
|
|
62
|
+
get: () => {
|
|
63
|
+
value: "gold" | "violet" | "slate" | "mint";
|
|
64
|
+
};
|
|
65
|
+
set: (next: "gold" | "violet" | "slate" | "mint", change?: {
|
|
66
|
+
reason?: _ui_sdk_core.ChangeReason;
|
|
67
|
+
event?: Event;
|
|
68
|
+
}) => boolean;
|
|
69
|
+
subscribe: (listener: (state: {
|
|
70
|
+
value: "gold" | "violet" | "slate" | "mint";
|
|
71
|
+
}) => void) => () => void;
|
|
72
|
+
follow: <Key extends string>(store: _ui_sdk_core.PreferenceStore<Key, {
|
|
73
|
+
value: "gold" | "violet" | "slate" | "mint";
|
|
74
|
+
}>, key: Key) => () => void;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
/** The theme as next-themes shaped it, backed by ui-sdk's color scheme. */
|
|
78
|
+
declare function useTheme(): {
|
|
79
|
+
theme: ColorSchemeValue;
|
|
80
|
+
themes: readonly ("dark" | "light" | "system")[];
|
|
81
|
+
systemTheme: "dark" | "light" | undefined;
|
|
82
|
+
resolvedTheme: "dark" | "light" | undefined;
|
|
83
|
+
setTheme: (next: string) => void;
|
|
84
|
+
};
|
|
85
|
+
/** The accent theme, applied as `data-accent` on `<html>`. */
|
|
86
|
+
declare function useAccent(): {
|
|
87
|
+
accent: "gold" | "violet" | "slate" | "mint";
|
|
88
|
+
accents: readonly ("gold" | "violet" | "slate" | "mint")[];
|
|
89
|
+
setAccent: (next: string) => void;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export { PreferencesProvider, useAccent, usePreferences, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
PreferencesProvider,
|
|
4
|
+
useAccent,
|
|
5
|
+
usePreferences,
|
|
6
|
+
useTheme
|
|
7
|
+
} from "./chunk-G3RYS466.js";
|
|
7
8
|
import {
|
|
8
9
|
TopLoader
|
|
9
10
|
} from "./chunk-3ZGQJTWY.js";
|
|
11
|
+
import "./chunk-X56ZEDOW.js";
|
|
10
12
|
import {
|
|
11
13
|
BellIcon,
|
|
12
14
|
IconSwap,
|
|
13
15
|
Loader
|
|
14
16
|
} from "./chunk-5QSYZSVL.js";
|
|
15
|
-
import "./chunk-RT2YVQ2Y.js";
|
|
16
|
-
import "./chunk-ATPUW3SQ.js";
|
|
17
17
|
|
|
18
18
|
// src/index.ts
|
|
19
19
|
import { default as default2 } from "@number-flow/react";
|
|
20
20
|
export * from "goey-toast";
|
|
21
21
|
export * from "motion/react";
|
|
22
|
-
export * from "next-themes";
|
|
23
22
|
export {
|
|
24
23
|
BellIcon,
|
|
25
24
|
IconSwap,
|
|
26
25
|
Loader,
|
|
27
26
|
default2 as NumberFlow,
|
|
28
|
-
|
|
27
|
+
PreferencesProvider,
|
|
29
28
|
TopLoader,
|
|
30
|
-
|
|
29
|
+
useAccent,
|
|
30
|
+
usePreferences,
|
|
31
|
+
useTheme
|
|
31
32
|
};
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ClientProviderProps } from './provider.js';
|
|
3
|
+
|
|
4
|
+
type LayoutProps = ClientProviderProps;
|
|
5
|
+
/**
|
|
6
|
+
* Wraps the app. Reads the request's cookies itself, so saved preferences render on
|
|
7
|
+
* the server and are on `<html>` before the first paint. Put it first inside `<body>`.
|
|
8
|
+
*/
|
|
9
|
+
declare function Layout({ cookie, ...props }: LayoutProps): Promise<React.JSX.Element>;
|
|
10
|
+
|
|
11
|
+
export { Layout, type LayoutProps };
|
package/dist/layout.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NuqsAdapter
|
|
3
|
+
} from "./chunk-JPOAXESG.js";
|
|
4
|
+
import "./chunk-M5NHRP6W.js";
|
|
5
|
+
import {
|
|
6
|
+
preferencesScript
|
|
7
|
+
} from "./chunk-X56ZEDOW.js";
|
|
8
|
+
|
|
9
|
+
// src/layout/layout.tsx
|
|
10
|
+
import { cookies } from "next/headers";
|
|
11
|
+
import { ClientProvider } from "./provider.js";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
async function Layout({ cookie, ...props }) {
|
|
14
|
+
const header = cookie ?? (await cookies()).toString();
|
|
15
|
+
return /* @__PURE__ */ jsxs(NuqsAdapter, { children: [
|
|
16
|
+
/* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: preferencesScript(header) } }),
|
|
17
|
+
/* @__PURE__ */ jsx(ClientProvider, { cookie: header, ...props })
|
|
18
|
+
] });
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
Layout
|
|
22
|
+
};
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as _ui_sdk_core from '@ui-sdk/core';
|
|
2
|
+
|
|
1
3
|
type PluginListenerHandle = {
|
|
2
4
|
remove: () => Promise<void>;
|
|
3
5
|
};
|
|
@@ -197,4 +199,80 @@ declare function pickNativeChooserImageFiles({ isNative, limit, title, }: {
|
|
|
197
199
|
title?: string;
|
|
198
200
|
}): Promise<File[] | null>;
|
|
199
201
|
|
|
200
|
-
|
|
202
|
+
declare const ACCENTS: readonly ["slate", "violet", "mint", "gold"];
|
|
203
|
+
type Accent = (typeof ACCENTS)[number];
|
|
204
|
+
declare const PREFERENCE_COOKIES: {
|
|
205
|
+
readonly colorScheme: "color-scheme";
|
|
206
|
+
readonly accent: "accent";
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* The app's saved preferences, kept in cookies so the server renders them too.
|
|
210
|
+
* Create them once per request from its `Cookie` header.
|
|
211
|
+
*/
|
|
212
|
+
declare function createAppPreferences(cookie?: string | null): {
|
|
213
|
+
colorScheme: {
|
|
214
|
+
attribute: `data-${string}`;
|
|
215
|
+
global: boolean;
|
|
216
|
+
values: readonly ("system" | "light" | "dark")[];
|
|
217
|
+
defaultValue: "system" | "light" | "dark";
|
|
218
|
+
storage: {
|
|
219
|
+
id: string;
|
|
220
|
+
kind: "local" | "session" | "cookie";
|
|
221
|
+
readsOnServer: boolean;
|
|
222
|
+
script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
|
|
223
|
+
available: () => boolean;
|
|
224
|
+
get: () => string | null;
|
|
225
|
+
set: (value: string) => boolean;
|
|
226
|
+
remove: () => boolean;
|
|
227
|
+
subscribe(listener: (value: string | null) => void): () => void;
|
|
228
|
+
} | undefined;
|
|
229
|
+
initialState: _ui_sdk_core.ColorSchemeState;
|
|
230
|
+
get: () => _ui_sdk_core.ColorSchemeState;
|
|
231
|
+
set: (next: "system" | "light" | "dark", change?: {
|
|
232
|
+
reason?: _ui_sdk_core.ChangeReason;
|
|
233
|
+
event?: Event;
|
|
234
|
+
}) => boolean;
|
|
235
|
+
subscribe: (listener: (state: _ui_sdk_core.ColorSchemeState) => void) => () => void;
|
|
236
|
+
follow: <Key extends string>(store: _ui_sdk_core.ColorSchemeStore<Key>, key: Key) => () => void;
|
|
237
|
+
};
|
|
238
|
+
accent: {
|
|
239
|
+
attribute: `data-${string}`;
|
|
240
|
+
global: boolean;
|
|
241
|
+
values: readonly ("gold" | "violet" | "slate" | "mint")[];
|
|
242
|
+
defaultValue: "gold" | "violet" | "slate" | "mint";
|
|
243
|
+
storage: {
|
|
244
|
+
id: string;
|
|
245
|
+
kind: "local" | "session" | "cookie";
|
|
246
|
+
readsOnServer: boolean;
|
|
247
|
+
script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
|
|
248
|
+
available: () => boolean;
|
|
249
|
+
get: () => string | null;
|
|
250
|
+
set: (value: string) => boolean;
|
|
251
|
+
remove: () => boolean;
|
|
252
|
+
subscribe(listener: (value: string | null) => void): () => void;
|
|
253
|
+
} | undefined;
|
|
254
|
+
initialState: {
|
|
255
|
+
value: "gold" | "violet" | "slate" | "mint";
|
|
256
|
+
};
|
|
257
|
+
get: () => {
|
|
258
|
+
value: "gold" | "violet" | "slate" | "mint";
|
|
259
|
+
};
|
|
260
|
+
set: (next: "gold" | "violet" | "slate" | "mint", change?: {
|
|
261
|
+
reason?: _ui_sdk_core.ChangeReason;
|
|
262
|
+
event?: Event;
|
|
263
|
+
}) => boolean;
|
|
264
|
+
subscribe: (listener: (state: {
|
|
265
|
+
value: "gold" | "violet" | "slate" | "mint";
|
|
266
|
+
}) => void) => () => void;
|
|
267
|
+
follow: <Key extends string>(store: _ui_sdk_core.PreferenceStore<Key, {
|
|
268
|
+
value: "gold" | "violet" | "slate" | "mint";
|
|
269
|
+
}>, key: Key) => () => void;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
type AppPreferences = ReturnType<typeof createAppPreferences>;
|
|
273
|
+
/** The `<html>` attributes for a request's saved preferences. */
|
|
274
|
+
declare function preferenceAttributes(cookie?: string | null): Record<`data-${string}`, string>;
|
|
275
|
+
/** Sets the saved preferences on `<html>` while the page parses, before it paints. */
|
|
276
|
+
declare function preferencesScript(cookie?: string | null): string;
|
|
277
|
+
|
|
278
|
+
export { ACCENTS, type Accent, type AppPreferences, type NativeSharePayload, type NativeSharedFile, type NativeUpdateInfo, type NativeUpdateState, PREFERENCE_COOKIES, createAppPreferences, getNativeAppPlugin, getNativeAppSettingsPlugin, getNativeBrowserPlugin, getNativeCameraPlugin, getNativeImagePickerPlugin, getNativeInAppUpdatePlugin, getNativePaymentPlugin, getNativePlatform, getNativeShareFilePlugin, getNativeSharePlugin, getNativeShareTargetPlugin, getNativeStatusBarPlugin, getNativeThemePlugin, isNativeApp, nativeSharedFileToFile, openExternalUrl, openNativeAppSettings, openUpiPaymentUrl, pickNativeChooserImageFiles, pickNativeImageFiles, preferenceAttributes, preferencesScript, saveNativeShareImage, shareNativeOrWeb };
|
package/dist/lib/index.js
CHANGED
|
@@ -21,8 +21,18 @@ import {
|
|
|
21
21
|
pickNativeImageFiles,
|
|
22
22
|
saveNativeShareImage,
|
|
23
23
|
shareNativeOrWeb
|
|
24
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-2LD63YUK.js";
|
|
25
|
+
import {
|
|
26
|
+
ACCENTS,
|
|
27
|
+
PREFERENCE_COOKIES,
|
|
28
|
+
createAppPreferences,
|
|
29
|
+
preferenceAttributes,
|
|
30
|
+
preferencesScript
|
|
31
|
+
} from "../chunk-X56ZEDOW.js";
|
|
25
32
|
export {
|
|
33
|
+
ACCENTS,
|
|
34
|
+
PREFERENCE_COOKIES,
|
|
35
|
+
createAppPreferences,
|
|
26
36
|
getNativeAppPlugin,
|
|
27
37
|
getNativeAppSettingsPlugin,
|
|
28
38
|
getNativeBrowserPlugin,
|
|
@@ -43,6 +53,8 @@ export {
|
|
|
43
53
|
openUpiPaymentUrl,
|
|
44
54
|
pickNativeChooserImageFiles,
|
|
45
55
|
pickNativeImageFiles,
|
|
56
|
+
preferenceAttributes,
|
|
57
|
+
preferencesScript,
|
|
46
58
|
saveNativeShareImage,
|
|
47
59
|
shareNativeOrWeb
|
|
48
60
|
};
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ThemeProvider } from 'next-themes';
|
|
3
2
|
|
|
4
3
|
declare const browserThemeColors: {
|
|
5
4
|
readonly light: "#ffffff";
|
|
@@ -7,11 +6,14 @@ declare const browserThemeColors: {
|
|
|
7
6
|
};
|
|
8
7
|
type BrowserTheme = keyof typeof browserThemeColors;
|
|
9
8
|
type BrowserThemeColors = Record<BrowserTheme, string>;
|
|
10
|
-
type
|
|
9
|
+
type ClientProviderProps = {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
/** The request's `Cookie` header, so saved preferences render on the server. */
|
|
12
|
+
cookie?: string | null;
|
|
11
13
|
light?: string;
|
|
12
14
|
dark?: string;
|
|
13
15
|
fullscreen?: boolean;
|
|
14
16
|
};
|
|
15
|
-
declare function
|
|
17
|
+
declare function ClientProvider({ children, light, dark, fullscreen, cookie, }: ClientProviderProps): React.JSX.Element;
|
|
16
18
|
|
|
17
|
-
export { type BrowserTheme, type BrowserThemeColors,
|
|
19
|
+
export { type BrowserTheme, type BrowserThemeColors, ClientProvider, type ClientProviderProps, browserThemeColors };
|