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.
@@ -0,0 +1,276 @@
1
+ // src/ui/tabs.tsx
2
+ import {
3
+ definePrimitive,
4
+ isRTL
5
+ } from "@ui-sdk/core";
6
+ import { scrollArea } from "@ui-sdk/core/scroll-area";
7
+ import { tabs } from "@ui-sdk/core/tabs";
8
+ import { createParts } from "@ui-sdk/react/primitive";
9
+ import { cva } from "class-variance-authority";
10
+ import { cn } from "cn";
11
+ import { ChevronDown, ChevronLeft, ChevronRight, ChevronUp } from "lucide-react";
12
+ import { createTabsController } from "@ui-sdk/core/tabs";
13
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
+ var viewportOf = (el) => el?.closest('[data-slot="scroll-area-viewport"]') ?? null;
15
+ var tabsScroll = definePrimitive({
16
+ name: "tabs-scroll",
17
+ state: () => ({}),
18
+ api: (context) => ({
19
+ page(side) {
20
+ const viewport = viewportOf(context.element("track"));
21
+ if (!viewport) return;
22
+ const y = viewport.scrollHeight > viewport.clientHeight;
23
+ const sign = (side === "start" ? -1 : 1) * (!y && isRTL(viewport) ? -1 : 1);
24
+ const distance = (y ? viewport.clientHeight : viewport.clientWidth) * 0.8;
25
+ viewport.scrollBy({
26
+ [y ? "top" : "left"]: sign * distance,
27
+ behavior: matchMedia("(prefers-reduced-motion: reduce)").matches ? "instant" : "smooth"
28
+ });
29
+ }
30
+ }),
31
+ slots: (slot) => ({
32
+ // Tabs reveals a tab selected later; this centres the one it starts on.
33
+ track: slot({
34
+ bind: (el) => {
35
+ const viewport = viewportOf(el);
36
+ const tab = el.querySelector('[role="tab"][data-selected]');
37
+ if (!viewport || !tab) return;
38
+ const v = viewport.getBoundingClientRect();
39
+ const t = tab.getBoundingClientRect();
40
+ viewport.scrollBy({
41
+ left: t.left + t.width / 2 - (v.left + v.width / 2),
42
+ top: t.top + t.height / 2 - (v.top + v.height / 2),
43
+ behavior: "instant"
44
+ });
45
+ }
46
+ }),
47
+ arrow: slot({
48
+ props: { value: "string", shown: "boolean" },
49
+ attrs: (_state, { props }) => ({
50
+ type: "button",
51
+ tabindex: "-1",
52
+ "aria-hidden": "true",
53
+ "data-side": props.value,
54
+ "data-visible": props.shown ? "" : void 0
55
+ }),
56
+ press: ({ api, props }) => api.page(props.value)
57
+ })
58
+ })
59
+ });
60
+ var tabsDefaults = { variant: "default", size: "xs" };
61
+ var tabsVariants = cva(
62
+ "grid gap-4 font-sans [--tabs-pill-fg:var(--color-foreground)] [--tabs-pill-ring:0_0_#0000] [--tabs-radius:999px] data-[orientation=vertical]:grid-cols-[auto_1fr] data-[orientation=vertical]:[--tabs-radius:var(--radius-lg)]",
63
+ {
64
+ variants: {
65
+ variant: {
66
+ default: "[--tabs-pill-fg:var(--color-primary-foreground)] [--tabs-pill:var(--color-primary)]",
67
+ outline: "[--tabs-pill-ring:inset_0_0_0_1px_var(--color-border)] [--tabs-pill:var(--color-background)] dark:[--tabs-pill-ring:inset_0_0_0_1px_var(--color-input)] dark:[--tabs-pill:color-mix(in_oklab,var(--color-input)_30%,transparent)]",
68
+ secondary: "[--tabs-pill-fg:var(--color-secondary-foreground)] [--tabs-pill:var(--color-secondary)]",
69
+ ghost: "[--tabs-pill:var(--color-muted)]",
70
+ destructive: "[--tabs-pill-fg:var(--color-destructive)] [--tabs-pill:color-mix(in_oklab,var(--color-destructive)_10%,transparent)] dark:[--tabs-pill:color-mix(in_oklab,var(--color-destructive)_20%,transparent)]",
71
+ link: "[--tabs-pill-fg:var(--color-primary)] [--tabs-pill-ring:inset_0_-2px_0_var(--color-primary)] [--tabs-pill:transparent] [--tabs-radius:0px] data-[orientation=vertical]:[--tabs-pill-ring:inset_2px_0_0_var(--color-primary)] data-[orientation=vertical]:[--tabs-radius:0px]"
72
+ },
73
+ size: {
74
+ default: "[--tabs-gap:calc(var(--spacing)*1.5)] [--tabs-h:calc(var(--spacing)*8)] [--tabs-icon:calc(var(--spacing)*4)] [--tabs-px:calc(var(--spacing)*2.5)] [--tabs-text:0.875rem]",
75
+ xs: "[--tabs-gap:calc(var(--spacing)*1)] [--tabs-h:calc(var(--spacing)*6)] [--tabs-icon:calc(var(--spacing)*3)] [--tabs-px:calc(var(--spacing)*2)] [--tabs-text:0.75rem]",
76
+ sm: "[--tabs-gap:calc(var(--spacing)*1)] [--tabs-h:calc(var(--spacing)*7)] [--tabs-icon:calc(var(--spacing)*3.5)] [--tabs-px:calc(var(--spacing)*2.5)] [--tabs-text:0.8rem]",
77
+ lg: "[--tabs-gap:calc(var(--spacing)*1.5)] [--tabs-h:calc(var(--spacing)*9)] [--tabs-icon:calc(var(--spacing)*4)] [--tabs-px:calc(var(--spacing)*3)] [--tabs-text:0.875rem]"
78
+ }
79
+ },
80
+ defaultVariants: tabsDefaults
81
+ }
82
+ );
83
+ var Arrows = createParts(tabsScroll, { track: "div", arrow: "button" });
84
+ var Tab = createParts(tabs, {
85
+ root: "div",
86
+ list: "div",
87
+ tab: "button",
88
+ "tab-icon": "span",
89
+ indicator: "span",
90
+ panel: "div"
91
+ });
92
+ var Scroll = createParts(scrollArea, {
93
+ root: "div",
94
+ viewport: "div",
95
+ content: "div"
96
+ });
97
+ var withClass = (className, base) => typeof className === "function" ? (state) => cn(base, className(state)) : cn(base, className);
98
+ var ease = "ease-[cubic-bezier(0.22,1,0.36,1)]";
99
+ function TabsRoot({
100
+ className,
101
+ variant = tabsDefaults.variant,
102
+ size = tabsDefaults.size,
103
+ ...props
104
+ }) {
105
+ return /* @__PURE__ */ jsx(
106
+ Tab.Root,
107
+ {
108
+ "data-variant": variant,
109
+ "data-size": size,
110
+ ...props,
111
+ className: withClass(className, tabsVariants({ variant, size }))
112
+ }
113
+ );
114
+ }
115
+ var vertical = "in-data-[orientation=vertical]";
116
+ var arrowSide = {
117
+ start: `inset-s-0 ${vertical}:top-0`,
118
+ end: `inset-e-0 ${vertical}:bottom-0`
119
+ };
120
+ var arrowIcons = {
121
+ start: [ChevronLeft, ChevronUp],
122
+ end: [ChevronRight, ChevronDown]
123
+ };
124
+ function TabsIndicator({
125
+ className,
126
+ ...props
127
+ }) {
128
+ return /* @__PURE__ */ jsx(
129
+ Tab.Indicator,
130
+ {
131
+ ...props,
132
+ className: withClass(
133
+ className,
134
+ cn(
135
+ "absolute top-(--active-tab-top) left-(--active-tab-left) z-0 h-(--active-tab-height) w-(--active-tab-width) rounded-[inherit] bg-(--tabs-pill) [box-shadow:var(--tabs-pill-ring)] transition-[top,left,width,height] duration-300 motion-reduce:transition-none",
136
+ ease,
137
+ // Before ui-sdk measures it after hydration, the indicator anchors to the selected tab.
138
+ "not-[[style]]:top-[anchor(top)] not-[[style]]:left-[anchor(left)] not-[[style]]:h-[anchor-size(height)] not-[[style]]:w-[anchor-size(width)] not-[[style]]:[position-anchor:--tabs-selected]"
139
+ )
140
+ )
141
+ }
142
+ );
143
+ }
144
+ function TabsList({
145
+ className,
146
+ children,
147
+ ...props
148
+ }) {
149
+ return /* @__PURE__ */ jsx(Arrows.Root, { children: /* @__PURE__ */ jsx(Scroll.Root, { className: "relative flex max-h-full min-h-0 max-w-full min-w-0", children: (scroll) => {
150
+ const overflowing = scroll.overflowX || scroll.overflowY;
151
+ const arrow = (side) => {
152
+ const [Horizontal, Vertical] = arrowIcons[side];
153
+ return /* @__PURE__ */ jsxs(
154
+ Arrows.Arrow,
155
+ {
156
+ value: side,
157
+ shown: overflowing && !(side === "start" ? scroll.atStart : scroll.atEnd),
158
+ "data-no-ring": true,
159
+ className: cn(
160
+ `pointer-events-none absolute inset-y-0 z-10 inline-flex w-9 scale-75 items-center justify-center text-foreground opacity-0 transition-[opacity,scale] duration-200 outline-none data-visible:pointer-events-auto data-visible:scale-100 data-visible:opacity-100 motion-reduce:transition-none ${vertical}:inset-x-0 ${vertical}:inset-y-auto ${vertical}:h-9 ${vertical}:w-auto [&_svg]:size-4.5 [&_svg]:transition-opacity [&_svg]:duration-150 hover:[&_svg]:opacity-70`,
161
+ ease,
162
+ arrowSide[side]
163
+ ),
164
+ children: [
165
+ /* @__PURE__ */ jsx(Horizontal, { className: `rtl:-scale-x-100 ${vertical}:hidden` }),
166
+ /* @__PURE__ */ jsx(Vertical, { className: `hidden ${vertical}:block` })
167
+ ]
168
+ }
169
+ );
170
+ };
171
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
172
+ arrow("start"),
173
+ /* @__PURE__ */ jsx(
174
+ Scroll.Viewport,
175
+ {
176
+ "data-no-ring": true,
177
+ className: cn(
178
+ "max-h-[inherit] min-w-0 flex-1 scroll-fade-x scrollbar-none outline-none [--scroll-fade-reveal:2.25rem] [--scroll-fade-size:2.25rem] in-data-[orientation=vertical]:scroll-fade-y [&::-webkit-scrollbar]:hidden"
179
+ ),
180
+ children: /* @__PURE__ */ jsx(Scroll.Content, { className: "w-max min-w-full", children: /* @__PURE__ */ jsx(Arrows.Track, { children: /* @__PURE__ */ jsx(
181
+ Tab.List,
182
+ {
183
+ ...props,
184
+ className: withClass(
185
+ className,
186
+ cn(
187
+ "relative isolate flex w-fit items-center gap-1 rounded-(--tabs-radius) p-1 [anchor-scope:--tabs-selected] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch"
188
+ )
189
+ ),
190
+ children: (state) => /* @__PURE__ */ jsxs(Fragment, { children: [
191
+ typeof children === "function" ? children(state) : children,
192
+ /* @__PURE__ */ jsx(TabsIndicator, {})
193
+ ] })
194
+ }
195
+ ) }) })
196
+ }
197
+ ),
198
+ arrow("end")
199
+ ] });
200
+ } }) });
201
+ }
202
+ var tabContent = (content) => /* @__PURE__ */ jsx("span", { className: "relative z-1 inline-flex min-w-0 items-center gap-[inherit] transition-[scale] duration-200 ease-out motion-reduce:transition-none [:active:not([data-disabled])>&]:scale-[0.97] [[data-disabled]>&]:opacity-40", children: content });
203
+ function TabsTab({
204
+ className,
205
+ children,
206
+ ...props
207
+ }) {
208
+ return /* @__PURE__ */ jsx(
209
+ Tab.Tab,
210
+ {
211
+ "data-no-ring": true,
212
+ ...props,
213
+ className: withClass(
214
+ className,
215
+ "relative inline-flex h-(--tabs-h) shrink-0 cursor-default items-center gap-(--tabs-gap) rounded-[inherit] px-(--tabs-px) text-(length:--tabs-text) font-medium text-nowrap text-muted-foreground transition-colors duration-200 ease-out outline-none [-webkit-tap-highlight-color:transparent] motion-reduce:transition-none data-selected:text-(--tabs-pill-fg) data-selected:[anchor-name:--tabs-selected] data-disabled:hover:text-muted-foreground"
216
+ ),
217
+ children: typeof children === "function" ? (state) => tabContent(children(state)) : tabContent(children)
218
+ }
219
+ );
220
+ }
221
+ function TabsIcon({
222
+ className,
223
+ ...props
224
+ }) {
225
+ return /* @__PURE__ */ jsx(
226
+ Tab.TabIcon,
227
+ {
228
+ ...props,
229
+ className: withClass(
230
+ className,
231
+ "inline-flex shrink-0 rtl:data-mirror:-scale-x-100 [&_svg]:size-(--tabs-icon)"
232
+ )
233
+ }
234
+ );
235
+ }
236
+ function TabsPanel({
237
+ className,
238
+ ...props
239
+ }) {
240
+ return /* @__PURE__ */ jsx(
241
+ Tab.Panel,
242
+ {
243
+ "data-no-ring": true,
244
+ ...props,
245
+ className: withClass(
246
+ className,
247
+ cn(
248
+ "col-start-1 row-start-2 rounded-md text-sm outline-none data-[orientation=vertical]:col-start-2 data-[orientation=vertical]:row-start-1",
249
+ "[--tab-shift-x:0px] [--tab-shift-y:0px]",
250
+ "data-[activation-direction=left]:[--tab-shift-x:-1rem] data-[activation-direction=right]:[--tab-shift-x:1rem]",
251
+ "data-[activation-direction=down]:[--tab-shift-y:1rem] data-[activation-direction=up]:[--tab-shift-y:-1rem]",
252
+ "transition-[opacity,translate,filter] duration-300 motion-reduce:transition-none",
253
+ ease,
254
+ "data-starting-style:[translate:var(--tab-shift-x)_var(--tab-shift-y)] data-starting-style:opacity-0 data-starting-style:blur-xs",
255
+ "data-ending-style:[translate:calc(var(--tab-shift-x)*-1)_calc(var(--tab-shift-y)*-1)] data-ending-style:opacity-0 data-ending-style:blur-xs data-ending-style:duration-200"
256
+ )
257
+ )
258
+ }
259
+ );
260
+ }
261
+ var Tabs = Object.assign(TabsRoot, {
262
+ List: TabsList,
263
+ Tab: TabsTab,
264
+ Icon: TabsIcon,
265
+ Panel: TabsPanel
266
+ });
267
+
268
+ export {
269
+ tabsVariants,
270
+ TabsList,
271
+ TabsTab,
272
+ TabsIcon,
273
+ TabsPanel,
274
+ Tabs,
275
+ createTabsController
276
+ };
@@ -0,0 +1,68 @@
1
+ import {
2
+ createAppPreferences
3
+ } from "./chunk-X56ZEDOW.js";
4
+
5
+ // src/theme.tsx
6
+ import { Preferences, usePreference } from "@ui-sdk/react/preferences";
7
+ import { createContext, useContext, useState } from "react";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var PreferencesContext = createContext(null);
10
+ var standalone;
11
+ function PreferencesProvider({
12
+ cookie,
13
+ children
14
+ }) {
15
+ const [preferences] = useState(() => createAppPreferences(cookie));
16
+ return /* @__PURE__ */ jsx(PreferencesContext, { value: preferences, children: /* @__PURE__ */ jsx(
17
+ Preferences,
18
+ {
19
+ preferences: [preferences.colorScheme, preferences.accent],
20
+ children
21
+ }
22
+ ) });
23
+ }
24
+ function usePreferences() {
25
+ return useContext(PreferencesContext) ?? (standalone ??= createAppPreferences());
26
+ }
27
+ var includes = (values, value) => values.includes(value);
28
+ function withoutTransitions(apply) {
29
+ const style = document.createElement("style");
30
+ style.textContent = ':not([data-slot="tabs-list"],[data-slot="tabs-list"] *),:not([data-slot="tabs-list"] *)::before,:not([data-slot="tabs-list"] *)::after{transition:none!important}';
31
+ document.head.append(style);
32
+ apply();
33
+ getComputedStyle(document.body).opacity;
34
+ requestAnimationFrame(() => style.remove());
35
+ }
36
+ function useTheme() {
37
+ const { colorScheme } = usePreferences();
38
+ const { value, system, resolved } = usePreference(colorScheme);
39
+ return {
40
+ theme: value,
41
+ themes: colorScheme.values,
42
+ systemTheme: system === "unknown" ? void 0 : system,
43
+ resolvedTheme: resolved === "unknown" ? void 0 : resolved,
44
+ setTheme: (next) => {
45
+ if (includes(colorScheme.values, next))
46
+ withoutTransitions(() => colorScheme.set(next));
47
+ }
48
+ };
49
+ }
50
+ function useAccent() {
51
+ const { accent } = usePreferences();
52
+ const { value } = usePreference(accent);
53
+ return {
54
+ accent: value,
55
+ accents: accent.values,
56
+ setAccent: (next) => {
57
+ if (includes(accent.values, next))
58
+ withoutTransitions(() => accent.set(next));
59
+ }
60
+ };
61
+ }
62
+
63
+ export {
64
+ PreferencesProvider,
65
+ usePreferences,
66
+ useTheme,
67
+ useAccent
68
+ };
@@ -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
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isNativeApp
3
- } from "./chunk-ATPUW3SQ.js";
3
+ } from "./chunk-2LD63YUK.js";
4
4
 
5
5
  // src/hooks/useFullscreen.ts
6
6
  import * as React from "react";
@@ -0,0 +1,46 @@
1
+ // src/lib/preferences.ts
2
+ import {
3
+ createColorScheme,
4
+ createCookieStorage,
5
+ createPreference
6
+ } from "@ui-sdk/core";
7
+ var ACCENTS = ["slate", "violet", "mint", "gold"];
8
+ var PREFERENCE_COOKIES = {
9
+ colorScheme: "color-scheme",
10
+ accent: "accent"
11
+ };
12
+ function createAppPreferences(cookie) {
13
+ return {
14
+ colorScheme: createColorScheme({
15
+ global: true,
16
+ storage: createCookieStorage(PREFERENCE_COOKIES.colorScheme, { cookie })
17
+ }),
18
+ accent: createPreference({
19
+ values: ACCENTS,
20
+ defaultValue: "slate",
21
+ attribute: "data-accent",
22
+ global: true,
23
+ storage: createCookieStorage(PREFERENCE_COOKIES.accent, { cookie })
24
+ })
25
+ };
26
+ }
27
+ function preferenceAttributes(cookie) {
28
+ const { colorScheme, accent } = createAppPreferences(cookie);
29
+ return {
30
+ [colorScheme.attribute]: colorScheme.initialState.value,
31
+ [accent.attribute]: accent.initialState.value
32
+ };
33
+ }
34
+ function preferencesScript(cookie) {
35
+ return `(()=>{const r=document.documentElement;for(const[k,v]of Object.entries(${JSON.stringify(
36
+ preferenceAttributes(cookie)
37
+ )}))r.setAttribute(k,v)})()`;
38
+ }
39
+
40
+ export {
41
+ ACCENTS,
42
+ PREFERENCE_COOKIES,
43
+ createAppPreferences,
44
+ preferenceAttributes,
45
+ preferencesScript
46
+ };