rockin 0.0.36 → 0.0.38

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
+ };
@@ -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
+ };
@@ -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,9 +12,6 @@ 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";
@@ -26,10 +26,11 @@ import "../chunk-DVNTJNDP.js";
26
26
  import {
27
27
  useFullscreen,
28
28
  useNative
29
- } from "../chunk-RT2YVQ2Y.js";
29
+ } from "../chunk-WR27Y55B.js";
30
30
  import {
31
31
  isNativeApp
32
- } from "../chunk-ATPUW3SQ.js";
32
+ } from "../chunk-2LD63YUK.js";
33
+ import "../chunk-X56ZEDOW.js";
33
34
 
34
35
  // src/hooks/useSearchParams.ts
35
36
  import {
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 * from 'next-themes';
4
+ export { BellIcon, BellIconHandle, IconSwap, Loader, LoaderProps } from './icon/index.js';
6
5
  export { TopLoader, TopLoaderProps } from './loader.js';
7
- export { BrowserTheme, BrowserThemeColors, Provider, ProviderProps, browserThemeColors } from './provider.js';
8
- import 'react';
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
- Provider,
4
- browserThemeColors
5
- } from "./chunk-54ZJAEO5.js";
6
- import "./chunk-GBVAFFZR.js";
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
- Provider,
27
+ PreferencesProvider,
29
28
  TopLoader,
30
- browserThemeColors
29
+ useAccent,
30
+ usePreferences,
31
+ useTheme
31
32
  };
@@ -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,18 @@
1
+ import {
2
+ preferencesScript
3
+ } from "./chunk-X56ZEDOW.js";
4
+
5
+ // src/layout/layout.tsx
6
+ import { cookies } from "next/headers";
7
+ import { ClientProvider } from "./provider.js";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ async function Layout({ cookie, ...props }) {
10
+ const header = cookie ?? (await cookies()).toString();
11
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
12
+ /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: preferencesScript(header) } }),
13
+ /* @__PURE__ */ jsx(ClientProvider, { cookie: header, ...props })
14
+ ] });
15
+ }
16
+ export {
17
+ Layout
18
+ };