rockin 0.0.42 → 0.0.44

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.
@@ -7,10 +7,12 @@ import {
7
7
  var ACCENTS = ["slate", "violet", "mint", "gold"];
8
8
  var DEVICES = ["mobile", "desktop"];
9
9
  var MOBILE_QUERY = "(max-width: 767px)";
10
+ var VIEWS = ["grid", "list"];
10
11
  var PREFERENCE_COOKIES = {
11
12
  colorScheme: "color-scheme",
12
13
  accent: "accent",
13
- device: "device"
14
+ device: "device",
15
+ view: "view"
14
16
  };
15
17
  function createAppPreferences(cookie) {
16
18
  const device = createPreference({
@@ -33,7 +35,14 @@ function createAppPreferences(cookie) {
33
35
  storage: createCookieStorage(PREFERENCE_COOKIES.accent, { cookie })
34
36
  }),
35
37
  device,
36
- screen: createScreen(device)
38
+ screen: createScreen(device),
39
+ view: createPreference({
40
+ values: VIEWS,
41
+ defaultValue: "grid",
42
+ attribute: "data-view",
43
+ global: true,
44
+ storage: createCookieStorage(PREFERENCE_COOKIES.view, { cookie })
45
+ })
37
46
  };
38
47
  }
39
48
  function createScreen(device) {
@@ -54,11 +63,12 @@ function createScreen(device) {
54
63
  };
55
64
  }
56
65
  function preferenceAttributes(cookie) {
57
- const { colorScheme, accent, device } = createAppPreferences(cookie);
66
+ const { colorScheme, accent, device, view } = createAppPreferences(cookie);
58
67
  return {
59
68
  [colorScheme.attribute]: colorScheme.initialState.value,
60
69
  [accent.attribute]: accent.initialState.value,
61
- [device.attribute]: device.initialState.value
70
+ [device.attribute]: device.initialState.value,
71
+ [view.attribute]: view.initialState.value
62
72
  };
63
73
  }
64
74
  function preferencesScript(cookie) {
@@ -71,6 +81,7 @@ export {
71
81
  ACCENTS,
72
82
  DEVICES,
73
83
  MOBILE_QUERY,
84
+ VIEWS,
74
85
  PREFERENCE_COOKIES,
75
86
  createAppPreferences,
76
87
  preferenceAttributes,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  usePreferences
3
- } from "./chunk-YA5PSI7E.js";
3
+ } from "./chunk-VFN3HOYP.js";
4
4
 
5
5
  // src/hooks/useMediaQuery.ts
6
6
  import { usePreference } from "@ui-sdk/react/preferences";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAppPreferences
3
- } from "./chunk-GL2CQ5TR.js";
3
+ } from "./chunk-23GWTX3S.js";
4
4
 
5
5
  // src/theme.tsx
6
6
  import { Preferences, usePreference } from "@ui-sdk/react/preferences";
@@ -19,7 +19,8 @@ function PreferencesProvider({
19
19
  preferences: [
20
20
  preferences.colorScheme,
21
21
  preferences.accent,
22
- preferences.device
22
+ preferences.device,
23
+ preferences.view
23
24
  ],
24
25
  children
25
26
  }
@@ -63,10 +64,21 @@ function useAccent() {
63
64
  }
64
65
  };
65
66
  }
67
+ function useView() {
68
+ const { view } = usePreferences();
69
+ const { value } = usePreference(view);
70
+ return {
71
+ view: value,
72
+ views: view.values,
73
+ setView: (next) => view.set(next),
74
+ toggleView: () => view.set(value === "grid" ? "list" : "grid")
75
+ };
76
+ }
66
77
 
67
78
  export {
68
79
  PreferencesProvider,
69
80
  usePreferences,
70
81
  useTheme,
71
- useAccent
82
+ useAccent,
83
+ useView
72
84
  };
@@ -11,7 +11,7 @@ import {
11
11
  } from "../chunk-D6TULSM6.js";
12
12
  import {
13
13
  useMediaQuery
14
- } from "../chunk-4ILCWFOE.js";
14
+ } from "../chunk-53MRWZE4.js";
15
15
  import "../chunk-VFDNWPOI.js";
16
16
  import "../chunk-COPQJFDI.js";
17
17
  import "../chunk-MZBLIA6C.js";
@@ -30,8 +30,8 @@ import {
30
30
  import {
31
31
  isNativeApp
32
32
  } from "../chunk-2LD63YUK.js";
33
- import "../chunk-YA5PSI7E.js";
34
- import "../chunk-GL2CQ5TR.js";
33
+ import "../chunk-VFN3HOYP.js";
34
+ import "../chunk-23GWTX3S.js";
35
35
 
36
36
  // src/hooks/useSearchParams.ts
37
37
  import {
package/dist/index.d.ts CHANGED
@@ -7,9 +7,9 @@ import * as _ui_sdk_core from '@ui-sdk/core';
7
7
  import { ColorSchemeValue } from '@ui-sdk/core';
8
8
  import * as React from 'react';
9
9
  import { ReactNode } from 'react';
10
+ import { V as View } from './preferences-CvWGOnty.js';
10
11
  import '@bprogress/next/app';
11
12
 
12
- /** One set of preferences per request, created from its cookies, as ui-sdk's server rendering docs describe. */
13
13
  declare function PreferencesProvider({ cookie, children, }: {
14
14
  cookie?: string | null;
15
15
  children: ReactNode;
@@ -111,8 +111,40 @@ declare function usePreferences(): {
111
111
  get: () => "mobile" | "desktop";
112
112
  subscribe(listener: () => void): () => void;
113
113
  };
114
+ view: {
115
+ attribute: `data-${string}`;
116
+ global: boolean;
117
+ values: readonly ("grid" | "list")[];
118
+ defaultValue: "grid" | "list";
119
+ storage: {
120
+ id: string;
121
+ kind: "local" | "session" | "cookie";
122
+ readsOnServer: boolean;
123
+ script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
124
+ available: () => boolean;
125
+ get: () => string | null;
126
+ set: (value: string) => boolean;
127
+ remove: () => boolean;
128
+ subscribe(listener: (value: string | null) => void): () => void;
129
+ } | undefined;
130
+ initialState: {
131
+ value: "grid" | "list";
132
+ };
133
+ get: () => {
134
+ value: "grid" | "list";
135
+ };
136
+ set: (next: "grid" | "list", change?: {
137
+ reason?: _ui_sdk_core.ChangeReason;
138
+ event?: Event;
139
+ }) => boolean;
140
+ subscribe: (listener: (state: {
141
+ value: "grid" | "list";
142
+ }) => void) => () => void;
143
+ follow: <Key extends string>(store: _ui_sdk_core.PreferenceStore<Key, {
144
+ value: "grid" | "list";
145
+ }>, key: Key) => () => void;
146
+ };
114
147
  };
115
- /** The theme as next-themes shaped it, backed by ui-sdk's color scheme. */
116
148
  declare function useTheme(): {
117
149
  theme: ColorSchemeValue;
118
150
  themes: readonly ("dark" | "light" | "system")[];
@@ -120,11 +152,16 @@ declare function useTheme(): {
120
152
  resolvedTheme: "dark" | "light" | undefined;
121
153
  setTheme: (next: string) => void;
122
154
  };
123
- /** The accent theme, applied as `data-accent` on `<html>`. */
124
155
  declare function useAccent(): {
125
156
  accent: "gold" | "violet" | "slate" | "mint";
126
157
  accents: readonly ("gold" | "violet" | "slate" | "mint")[];
127
158
  setAccent: (next: string) => void;
128
159
  };
160
+ declare function useView(): {
161
+ view: "grid" | "list";
162
+ views: readonly ("grid" | "list")[];
163
+ setView: (next: View) => boolean;
164
+ toggleView: () => boolean;
165
+ };
129
166
 
130
- export { PreferencesProvider, useAccent, usePreferences, useTheme };
167
+ export { PreferencesProvider, useAccent, usePreferences, useTheme, useView };
package/dist/index.js CHANGED
@@ -3,12 +3,13 @@ import {
3
3
  PreferencesProvider,
4
4
  useAccent,
5
5
  usePreferences,
6
- useTheme
7
- } from "./chunk-YA5PSI7E.js";
6
+ useTheme,
7
+ useView
8
+ } from "./chunk-VFN3HOYP.js";
8
9
  import {
9
10
  TopLoader
10
11
  } from "./chunk-3ZGQJTWY.js";
11
- import "./chunk-GL2CQ5TR.js";
12
+ import "./chunk-23GWTX3S.js";
12
13
  import {
13
14
  BellIcon,
14
15
  IconSwap,
@@ -28,5 +29,6 @@ export {
28
29
  TopLoader,
29
30
  useAccent,
30
31
  usePreferences,
31
- useTheme
32
+ useTheme,
33
+ useView
32
34
  };
package/dist/layout.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  preferencesScript
3
- } from "./chunk-GL2CQ5TR.js";
3
+ } from "./chunk-23GWTX3S.js";
4
4
 
5
5
  // src/layout/layout.tsx
6
6
  import { cookies } from "next/headers";
@@ -1,4 +1,5 @@
1
- import * as _ui_sdk_core from '@ui-sdk/core';
1
+ export { A as ACCENTS, a as Accent, b as AppPreferences, D as DEVICES, c as Device, M as MOBILE_QUERY, P as PREFERENCE_COOKIES, d as VIEWS, V as View, e as createAppPreferences, p as preferenceAttributes, f as preferencesScript } from '../preferences-CvWGOnty.js';
2
+ import '@ui-sdk/core';
2
3
 
3
4
  type PluginListenerHandle = {
4
5
  remove: () => Promise<void>;
@@ -199,122 +200,4 @@ declare function pickNativeChooserImageFiles({ isNative, limit, title, }: {
199
200
  title?: string;
200
201
  }): Promise<File[] | null>;
201
202
 
202
- declare const ACCENTS: readonly ["slate", "violet", "mint", "gold"];
203
- type Accent = (typeof ACCENTS)[number];
204
- declare const DEVICES: readonly ["mobile", "desktop"];
205
- type Device = (typeof DEVICES)[number];
206
- declare const MOBILE_QUERY = "(max-width: 767px)";
207
- declare const PREFERENCE_COOKIES: {
208
- readonly colorScheme: "color-scheme";
209
- readonly accent: "accent";
210
- readonly device: "device";
211
- };
212
- /**
213
- * The app's saved preferences, kept in cookies so the server renders them too.
214
- * Create them once per request from its `Cookie` header.
215
- */
216
- declare function createAppPreferences(cookie?: string | null): {
217
- colorScheme: {
218
- attribute: `data-${string}`;
219
- global: boolean;
220
- values: readonly ("system" | "light" | "dark")[];
221
- defaultValue: "system" | "light" | "dark";
222
- storage: {
223
- id: string;
224
- kind: "local" | "session" | "cookie";
225
- readsOnServer: boolean;
226
- script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
227
- available: () => boolean;
228
- get: () => string | null;
229
- set: (value: string) => boolean;
230
- remove: () => boolean;
231
- subscribe(listener: (value: string | null) => void): () => void;
232
- } | undefined;
233
- initialState: _ui_sdk_core.ColorSchemeState;
234
- get: () => _ui_sdk_core.ColorSchemeState;
235
- set: (next: "system" | "light" | "dark", change?: {
236
- reason?: _ui_sdk_core.ChangeReason;
237
- event?: Event;
238
- }) => boolean;
239
- subscribe: (listener: (state: _ui_sdk_core.ColorSchemeState) => void) => () => void;
240
- follow: <Key extends string>(store: _ui_sdk_core.ColorSchemeStore<Key>, key: Key) => () => void;
241
- };
242
- accent: {
243
- attribute: `data-${string}`;
244
- global: boolean;
245
- values: readonly ("gold" | "violet" | "slate" | "mint")[];
246
- defaultValue: "gold" | "violet" | "slate" | "mint";
247
- storage: {
248
- id: string;
249
- kind: "local" | "session" | "cookie";
250
- readsOnServer: boolean;
251
- script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
252
- available: () => boolean;
253
- get: () => string | null;
254
- set: (value: string) => boolean;
255
- remove: () => boolean;
256
- subscribe(listener: (value: string | null) => void): () => void;
257
- } | undefined;
258
- initialState: {
259
- value: "gold" | "violet" | "slate" | "mint";
260
- };
261
- get: () => {
262
- value: "gold" | "violet" | "slate" | "mint";
263
- };
264
- set: (next: "gold" | "violet" | "slate" | "mint", change?: {
265
- reason?: _ui_sdk_core.ChangeReason;
266
- event?: Event;
267
- }) => boolean;
268
- subscribe: (listener: (state: {
269
- value: "gold" | "violet" | "slate" | "mint";
270
- }) => void) => () => void;
271
- follow: <Key extends string>(store: _ui_sdk_core.PreferenceStore<Key, {
272
- value: "gold" | "violet" | "slate" | "mint";
273
- }>, key: Key) => () => void;
274
- };
275
- device: {
276
- attribute: `data-${string}`;
277
- global: boolean;
278
- values: readonly ("mobile" | "desktop")[];
279
- defaultValue: "mobile" | "desktop";
280
- storage: {
281
- id: string;
282
- kind: "local" | "session" | "cookie";
283
- readsOnServer: boolean;
284
- script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
285
- available: () => boolean;
286
- get: () => string | null;
287
- set: (value: string) => boolean;
288
- remove: () => boolean;
289
- subscribe(listener: (value: string | null) => void): () => void;
290
- } | undefined;
291
- initialState: {
292
- value: "mobile" | "desktop";
293
- };
294
- get: () => {
295
- value: "mobile" | "desktop";
296
- };
297
- set: (next: "mobile" | "desktop", change?: {
298
- reason?: _ui_sdk_core.ChangeReason;
299
- event?: Event;
300
- }) => boolean;
301
- subscribe: (listener: (state: {
302
- value: "mobile" | "desktop";
303
- }) => void) => () => void;
304
- follow: <Key extends string>(store: _ui_sdk_core.PreferenceStore<Key, {
305
- value: "mobile" | "desktop";
306
- }>, key: Key) => () => void;
307
- };
308
- screen: {
309
- initialState: "mobile" | "desktop";
310
- get: () => "mobile" | "desktop";
311
- subscribe(listener: () => void): () => void;
312
- };
313
- };
314
- type AppPreferences = ReturnType<typeof createAppPreferences>;
315
- /** The `<html>` attributes for a request's saved preferences. */
316
- declare function preferenceAttributes(cookie?: string | null): Record<`data-${string}`, string>;
317
- /** Sets the saved preferences on `<html>` while the page parses, before it paints. */
318
- declare function preferencesScript(cookie?: string | null): string;
319
-
320
- export { ACCENTS, type Accent, type AppPreferences, DEVICES, type Device, MOBILE_QUERY, 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 };
203
+ export { type NativeSharePayload, type NativeSharedFile, type NativeUpdateInfo, type NativeUpdateState, getNativeAppPlugin, getNativeAppSettingsPlugin, getNativeBrowserPlugin, getNativeCameraPlugin, getNativeImagePickerPlugin, getNativeInAppUpdatePlugin, getNativePaymentPlugin, getNativePlatform, getNativeShareFilePlugin, getNativeSharePlugin, getNativeShareTargetPlugin, getNativeStatusBarPlugin, getNativeThemePlugin, isNativeApp, nativeSharedFileToFile, openExternalUrl, openNativeAppSettings, openUpiPaymentUrl, pickNativeChooserImageFiles, pickNativeImageFiles, saveNativeShareImage, shareNativeOrWeb };
package/dist/lib/index.js CHANGED
@@ -27,15 +27,17 @@ import {
27
27
  DEVICES,
28
28
  MOBILE_QUERY,
29
29
  PREFERENCE_COOKIES,
30
+ VIEWS,
30
31
  createAppPreferences,
31
32
  preferenceAttributes,
32
33
  preferencesScript
33
- } from "../chunk-GL2CQ5TR.js";
34
+ } from "../chunk-23GWTX3S.js";
34
35
  export {
35
36
  ACCENTS,
36
37
  DEVICES,
37
38
  MOBILE_QUERY,
38
39
  PREFERENCE_COOKIES,
40
+ VIEWS,
39
41
  createAppPreferences,
40
42
  getNativeAppPlugin,
41
43
  getNativeAppSettingsPlugin,
@@ -0,0 +1,158 @@
1
+ import * as _ui_sdk_core from '@ui-sdk/core';
2
+
3
+ declare const ACCENTS: readonly ["slate", "violet", "mint", "gold"];
4
+ type Accent = (typeof ACCENTS)[number];
5
+ declare const DEVICES: readonly ["mobile", "desktop"];
6
+ type Device = (typeof DEVICES)[number];
7
+ declare const MOBILE_QUERY = "(max-width: 767px)";
8
+ /** How a collection of items is laid out: a grid of cards or a list of rows. */
9
+ declare const VIEWS: readonly ["grid", "list"];
10
+ type View = (typeof VIEWS)[number];
11
+ declare const PREFERENCE_COOKIES: {
12
+ readonly colorScheme: "color-scheme";
13
+ readonly accent: "accent";
14
+ readonly device: "device";
15
+ readonly view: "view";
16
+ };
17
+ /**
18
+ * The app's saved preferences, kept in cookies so the server renders them too.
19
+ * Create them once per request from its `Cookie` header.
20
+ */
21
+ declare function createAppPreferences(cookie?: string | null): {
22
+ colorScheme: {
23
+ attribute: `data-${string}`;
24
+ global: boolean;
25
+ values: readonly ("system" | "light" | "dark")[];
26
+ defaultValue: "system" | "light" | "dark";
27
+ storage: {
28
+ id: string;
29
+ kind: "local" | "session" | "cookie";
30
+ readsOnServer: boolean;
31
+ script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
32
+ available: () => boolean;
33
+ get: () => string | null;
34
+ set: (value: string) => boolean;
35
+ remove: () => boolean;
36
+ subscribe(listener: (value: string | null) => void): () => void;
37
+ } | undefined;
38
+ initialState: _ui_sdk_core.ColorSchemeState;
39
+ get: () => _ui_sdk_core.ColorSchemeState;
40
+ set: (next: "system" | "light" | "dark", change?: {
41
+ reason?: _ui_sdk_core.ChangeReason;
42
+ event?: Event;
43
+ }) => boolean;
44
+ subscribe: (listener: (state: _ui_sdk_core.ColorSchemeState) => void) => () => void;
45
+ follow: <Key extends string>(store: _ui_sdk_core.ColorSchemeStore<Key>, key: Key) => () => void;
46
+ };
47
+ accent: {
48
+ attribute: `data-${string}`;
49
+ global: boolean;
50
+ values: readonly ("gold" | "violet" | "slate" | "mint")[];
51
+ defaultValue: "gold" | "violet" | "slate" | "mint";
52
+ storage: {
53
+ id: string;
54
+ kind: "local" | "session" | "cookie";
55
+ readsOnServer: boolean;
56
+ script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
57
+ available: () => boolean;
58
+ get: () => string | null;
59
+ set: (value: string) => boolean;
60
+ remove: () => boolean;
61
+ subscribe(listener: (value: string | null) => void): () => void;
62
+ } | undefined;
63
+ initialState: {
64
+ value: "gold" | "violet" | "slate" | "mint";
65
+ };
66
+ get: () => {
67
+ value: "gold" | "violet" | "slate" | "mint";
68
+ };
69
+ set: (next: "gold" | "violet" | "slate" | "mint", change?: {
70
+ reason?: _ui_sdk_core.ChangeReason;
71
+ event?: Event;
72
+ }) => boolean;
73
+ subscribe: (listener: (state: {
74
+ value: "gold" | "violet" | "slate" | "mint";
75
+ }) => void) => () => void;
76
+ follow: <Key extends string>(store: _ui_sdk_core.PreferenceStore<Key, {
77
+ value: "gold" | "violet" | "slate" | "mint";
78
+ }>, key: Key) => () => void;
79
+ };
80
+ device: {
81
+ attribute: `data-${string}`;
82
+ global: boolean;
83
+ values: readonly ("mobile" | "desktop")[];
84
+ defaultValue: "mobile" | "desktop";
85
+ storage: {
86
+ id: string;
87
+ kind: "local" | "session" | "cookie";
88
+ readsOnServer: boolean;
89
+ script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
90
+ available: () => boolean;
91
+ get: () => string | null;
92
+ set: (value: string) => boolean;
93
+ remove: () => boolean;
94
+ subscribe(listener: (value: string | null) => void): () => void;
95
+ } | undefined;
96
+ initialState: {
97
+ value: "mobile" | "desktop";
98
+ };
99
+ get: () => {
100
+ value: "mobile" | "desktop";
101
+ };
102
+ set: (next: "mobile" | "desktop", change?: {
103
+ reason?: _ui_sdk_core.ChangeReason;
104
+ event?: Event;
105
+ }) => boolean;
106
+ subscribe: (listener: (state: {
107
+ value: "mobile" | "desktop";
108
+ }) => void) => () => void;
109
+ follow: <Key extends string>(store: _ui_sdk_core.PreferenceStore<Key, {
110
+ value: "mobile" | "desktop";
111
+ }>, key: Key) => () => void;
112
+ };
113
+ screen: {
114
+ initialState: "mobile" | "desktop";
115
+ get: () => "mobile" | "desktop";
116
+ subscribe(listener: () => void): () => void;
117
+ };
118
+ view: {
119
+ attribute: `data-${string}`;
120
+ global: boolean;
121
+ values: readonly ("grid" | "list")[];
122
+ defaultValue: "grid" | "list";
123
+ storage: {
124
+ id: string;
125
+ kind: "local" | "session" | "cookie";
126
+ readsOnServer: boolean;
127
+ script: (options: _ui_sdk_core.StorageScriptOptions) => string | undefined;
128
+ available: () => boolean;
129
+ get: () => string | null;
130
+ set: (value: string) => boolean;
131
+ remove: () => boolean;
132
+ subscribe(listener: (value: string | null) => void): () => void;
133
+ } | undefined;
134
+ initialState: {
135
+ value: "grid" | "list";
136
+ };
137
+ get: () => {
138
+ value: "grid" | "list";
139
+ };
140
+ set: (next: "grid" | "list", change?: {
141
+ reason?: _ui_sdk_core.ChangeReason;
142
+ event?: Event;
143
+ }) => boolean;
144
+ subscribe: (listener: (state: {
145
+ value: "grid" | "list";
146
+ }) => void) => () => void;
147
+ follow: <Key extends string>(store: _ui_sdk_core.PreferenceStore<Key, {
148
+ value: "grid" | "list";
149
+ }>, key: Key) => () => void;
150
+ };
151
+ };
152
+ type AppPreferences = ReturnType<typeof createAppPreferences>;
153
+ /** The `<html>` attributes for a request's saved preferences. */
154
+ declare function preferenceAttributes(cookie?: string | null): Record<`data-${string}`, string>;
155
+ /** Sets the saved preferences on `<html>` while the page parses, before it paints. */
156
+ declare function preferencesScript(cookie?: string | null): string;
157
+
158
+ export { ACCENTS as A, DEVICES as D, MOBILE_QUERY as M, PREFERENCE_COOKIES as P, type View as V, type Accent as a, type AppPreferences as b, type Device as c, VIEWS as d, createAppPreferences as e, preferencesScript as f, preferenceAttributes as p };
package/dist/provider.js CHANGED
@@ -11,11 +11,11 @@ import {
11
11
  PreferencesProvider,
12
12
  usePreferences,
13
13
  useTheme
14
- } from "./chunk-YA5PSI7E.js";
14
+ } from "./chunk-VFN3HOYP.js";
15
15
  import {
16
16
  TopLoader
17
17
  } from "./chunk-3ZGQJTWY.js";
18
- import "./chunk-GL2CQ5TR.js";
18
+ import "./chunk-23GWTX3S.js";
19
19
 
20
20
  // src/provider.tsx
21
21
  import * as React from "react";
package/dist/ui/bridge.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  getNativeThemePlugin,
7
7
  isNativeApp
8
8
  } from "../chunk-2LD63YUK.js";
9
- import "../chunk-GL2CQ5TR.js";
9
+ import "../chunk-23GWTX3S.js";
10
10
 
11
11
  // src/ui/bridge.tsx
12
12
  import { useRouter } from "next/navigation";
@@ -35,11 +35,21 @@ function Carousel({
35
35
  );
36
36
  const [canScrollPrev, setCanScrollPrev] = React.useState(false);
37
37
  const [canScrollNext, setCanScrollNext] = React.useState(false);
38
+ const [selectedIndex, setSelectedIndex] = React.useState(0);
39
+ const [snapCount, setSnapCount] = React.useState(0);
38
40
  const onSelect = React.useCallback((api2) => {
39
41
  if (!api2) return;
40
42
  setCanScrollPrev(api2.canScrollPrev());
41
43
  setCanScrollNext(api2.canScrollNext());
44
+ setSelectedIndex(api2.selectedScrollSnap());
45
+ setSnapCount(api2.scrollSnapList().length);
42
46
  }, []);
47
+ const scrollTo = React.useCallback(
48
+ (index) => {
49
+ api?.scrollTo(index);
50
+ },
51
+ [api]
52
+ );
43
53
  const scrollPrev = React.useCallback(() => {
44
54
  api?.scrollPrev();
45
55
  }, [api]);
@@ -83,7 +93,10 @@ function Carousel({
83
93
  scrollPrev,
84
94
  scrollNext,
85
95
  canScrollPrev,
86
- canScrollNext
96
+ canScrollNext,
97
+ selectedIndex,
98
+ snapCount,
99
+ scrollTo
87
100
  },
88
101
  children: /* @__PURE__ */ jsx(
89
102
  "div",
@@ -195,9 +208,66 @@ function CarouselNext({
195
208
  }
196
209
  );
197
210
  }
211
+ function CarouselDots({
212
+ className,
213
+ getDotLabel = (index, count) => `Slide ${index + 1} of ${count}`,
214
+ "aria-label": ariaLabel = "Choose slide",
215
+ ...props
216
+ }) {
217
+ const { orientation, selectedIndex, snapCount, scrollTo } = useCarousel();
218
+ if (snapCount < 2) return null;
219
+ const vertical = orientation === "vertical";
220
+ return /* @__PURE__ */ jsx(
221
+ "div",
222
+ {
223
+ role: "group",
224
+ "aria-label": ariaLabel,
225
+ "data-slot": "carousel-dots",
226
+ className: cn(
227
+ "flex items-center justify-center",
228
+ vertical && "flex-col",
229
+ className
230
+ ),
231
+ ...props,
232
+ children: Array.from({ length: snapCount }, (_, index) => {
233
+ const active = index === selectedIndex;
234
+ return /* @__PURE__ */ jsx(
235
+ "button",
236
+ {
237
+ type: "button",
238
+ "data-slot": "carousel-dot",
239
+ "data-active": active ? "" : void 0,
240
+ "aria-label": getDotLabel(index, snapCount),
241
+ "aria-current": active ? "true" : void 0,
242
+ onClick: () => scrollTo(index),
243
+ className: cn(
244
+ "group/dot relative flex touch-manipulation items-center justify-center rounded-full outline-none",
245
+ "after:absolute after:content-['']",
246
+ vertical ? "min-h-6 w-6 py-1 after:-inset-x-2.5 after:inset-y-0" : "h-6 min-w-6 px-1 after:inset-x-0 after:-inset-y-2.5"
247
+ ),
248
+ children: /* @__PURE__ */ jsx(
249
+ "span",
250
+ {
251
+ "aria-hidden": "true",
252
+ className: cn(
253
+ "block size-1.5 rounded-full bg-muted-foreground/45 transition-[width,height,background-color] duration-200 ease-out motion-reduce:transition-none",
254
+ "group-hover/dot:bg-muted-foreground/70 group-focus-visible/dot:ring-2 group-focus-visible/dot:ring-ring/50 group-focus-visible/dot:ring-offset-1 group-focus-visible/dot:ring-offset-background",
255
+ "group-data-active/dot:bg-foreground",
256
+ vertical ? "group-data-active/dot:h-5" : "group-data-active/dot:w-5"
257
+ )
258
+ }
259
+ )
260
+ },
261
+ index
262
+ );
263
+ })
264
+ }
265
+ );
266
+ }
198
267
  export {
199
268
  Carousel,
200
269
  CarouselContent,
270
+ CarouselDots,
201
271
  CarouselItem,
202
272
  CarouselNext,
203
273
  CarouselPrevious,
@@ -4,8 +4,8 @@ import {
4
4
  } from "../chunk-DVNTJNDP.js";
5
5
  import {
6
6
  useTheme
7
- } from "../chunk-YA5PSI7E.js";
8
- import "../chunk-GL2CQ5TR.js";
7
+ } from "../chunk-VFN3HOYP.js";
8
+ import "../chunk-23GWTX3S.js";
9
9
  import {
10
10
  IconSwap
11
11
  } from "../chunk-5QSYZSVL.js";