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,47 @@
1
+ "use client";
2
+ import {
3
+ Tabs
4
+ } from "../chunk-6JS62NO4.js";
5
+ import {
6
+ useTheme
7
+ } from "../chunk-G3RYS466.js";
8
+ import "../chunk-X56ZEDOW.js";
9
+
10
+ // src/ui/theme-switcher.tsx
11
+ import { Display, Moon, Sun } from "@gravity-ui/icons";
12
+ import { cn } from "cn";
13
+ import { jsx } from "react/jsx-runtime";
14
+ var THEMES = [
15
+ { label: "Light", value: "light", icon: Sun, motion: "[[data-selected]_&]:rotate-180" },
16
+ { label: "System", value: "system", icon: Display, motion: "[[data-selected]_&]:scale-115" },
17
+ { label: "Dark", value: "dark", icon: Moon, motion: "[[data-selected]_&]:-rotate-25" }
18
+ ];
19
+ var iconMotion = "transition-[rotate,scale] duration-500 ease-[cubic-bezier(0.34,1.56,0.64,1)] motion-reduce:transition-none";
20
+ function ThemeSwitcher({
21
+ variant = "ghost",
22
+ ...props
23
+ }) {
24
+ const { theme, setTheme } = useTheme();
25
+ return /* @__PURE__ */ jsx(
26
+ Tabs,
27
+ {
28
+ variant,
29
+ value: theme,
30
+ onValueChange: (value) => value && setTheme(value),
31
+ ...props,
32
+ children: /* @__PURE__ */ jsx(Tabs.List, { "aria-label": "Theme", className: "border", children: THEMES.map(({ label, value, icon: Icon, motion }) => /* @__PURE__ */ jsx(
33
+ Tabs.Tab,
34
+ {
35
+ value,
36
+ "aria-label": label,
37
+ className: "px-1.5",
38
+ children: /* @__PURE__ */ jsx(Tabs.Icon, { children: /* @__PURE__ */ jsx(Icon, { className: cn(iconMotion, motion) }) })
39
+ },
40
+ value
41
+ )) })
42
+ }
43
+ );
44
+ }
45
+ export {
46
+ ThemeSwitcher
47
+ };
@@ -2,11 +2,14 @@
2
2
  import {
3
3
  buttonVariants
4
4
  } from "../chunk-DVNTJNDP.js";
5
+ import {
6
+ useTheme
7
+ } from "../chunk-G3RYS466.js";
8
+ import "../chunk-X56ZEDOW.js";
5
9
 
6
10
  // src/ui/theme-toggle.tsx
7
11
  import { cn } from "cn";
8
12
  import { motion, useReducedMotion } from "motion/react";
9
- import { useTheme } from "next-themes";
10
13
  import { useId } from "react";
11
14
  import { jsx, jsxs } from "react/jsx-runtime";
12
15
  var MORPH = { type: "spring", visualDuration: 0.4, bounce: 0 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rockin",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "description": "Reusable React UI components, hooks, icons, utilities, and styles for Rock Star projects.",
5
5
  "keywords": [
6
6
  "react",
@@ -54,6 +54,10 @@
54
54
  "types": "./dist/provider.d.ts",
55
55
  "import": "./dist/provider.js"
56
56
  },
57
+ "./layout": {
58
+ "types": "./dist/layout.d.ts",
59
+ "import": "./dist/layout.js"
60
+ },
57
61
  "./lucide": {
58
62
  "types": "./dist/lucide.d.ts",
59
63
  "import": "./dist/lucide.js"
@@ -124,6 +128,8 @@
124
128
  "@radix-ui/react-scroll-area": "^1.2.18",
125
129
  "@radix-ui/react-select": "^2.3.7",
126
130
  "@shadcn/react": "^0.3.0",
131
+ "@ui-sdk/core": "^0.1.0-beta.1",
132
+ "@ui-sdk/react": "^0.1.0-beta.1",
127
133
  "@visx/curve": "4.0.1-alpha.0",
128
134
  "@visx/event": "4.0.1-alpha.0",
129
135
  "@visx/gradient": "4.0.1-alpha.0",
@@ -146,6 +152,7 @@
146
152
  "nuqs": "^2.9.4",
147
153
  "openai": "^7.4.0",
148
154
  "qrcode": "^1.5.4",
155
+ "react-aria-components": "^1.22.1",
149
156
  "react-hotkeys-hook": "^5.3.3",
150
157
  "react-resizable-panels": "^4.13.3",
151
158
  "recharts": "^3.8.0",
@@ -1,209 +0,0 @@
1
- import {
2
- TooltipProvider
3
- } from "./chunk-GBVAFFZR.js";
4
- import {
5
- TopLoader
6
- } from "./chunk-3ZGQJTWY.js";
7
- import {
8
- useFullscreen,
9
- useNative
10
- } from "./chunk-RT2YVQ2Y.js";
11
-
12
- // src/provider.tsx
13
- import { usePathname } from "next/navigation";
14
- import * as React from "react";
15
- import { useHotkeys } from "react-hotkeys-hook";
16
- import { GooeyToaster } from "goey-toast";
17
- import { ThemeProvider, useTheme } from "next-themes";
18
- import { jsx, jsxs } from "react/jsx-runtime";
19
- var browserThemeColors = {
20
- light: "#ffffff",
21
- dark: "#000000"
22
- };
23
- function syncBrowserChrome(theme, colors) {
24
- const themeColor = colors[theme];
25
- const statusBarStyle = theme === "dark" ? "black-translucent" : "default";
26
- const themeColorMetas = document.querySelectorAll(
27
- 'meta[name="theme-color"]'
28
- );
29
- if (themeColorMetas.length) {
30
- themeColorMetas.forEach((meta) => {
31
- if (meta.content !== themeColor) {
32
- meta.content = themeColor;
33
- }
34
- });
35
- } else {
36
- const meta = document.createElement("meta");
37
- meta.name = "theme-color";
38
- meta.content = themeColor;
39
- document.head.appendChild(meta);
40
- }
41
- const statusBarMetas = document.querySelectorAll(
42
- 'meta[name="apple-mobile-web-app-status-bar-style"]'
43
- );
44
- if (statusBarMetas.length) {
45
- statusBarMetas.forEach((meta) => {
46
- if (meta.content !== statusBarStyle) {
47
- meta.content = statusBarStyle;
48
- }
49
- });
50
- } else {
51
- const meta = document.createElement("meta");
52
- meta.name = "apple-mobile-web-app-status-bar-style";
53
- meta.content = statusBarStyle;
54
- document.head.appendChild(meta);
55
- }
56
- if (document.documentElement.style.colorScheme !== theme) {
57
- document.documentElement.style.colorScheme = theme;
58
- }
59
- if (document.documentElement.style.backgroundColor !== themeColor) {
60
- document.documentElement.style.backgroundColor = themeColor;
61
- }
62
- }
63
- function observeBrowserChrome(theme, colors) {
64
- const observer = new MutationObserver(() => {
65
- syncBrowserChrome(theme, colors);
66
- });
67
- observer.observe(document.head, {
68
- childList: true,
69
- subtree: true,
70
- attributes: true,
71
- attributeFilter: ["content"]
72
- });
73
- return observer;
74
- }
75
- function useBrowserTheme() {
76
- const { resolvedTheme } = useTheme();
77
- return resolvedTheme === "dark" ? "dark" : "light";
78
- }
79
- function BrowserThemeSync({ light, dark }) {
80
- const pathname = usePathname();
81
- const theme = useBrowserTheme();
82
- const colors = React.useMemo(() => ({ light, dark }), [dark, light]);
83
- React.useLayoutEffect(() => {
84
- syncBrowserChrome(theme, colors);
85
- }, [colors, pathname, theme]);
86
- React.useEffect(() => {
87
- const observer = observeBrowserChrome(theme, colors);
88
- return () => {
89
- observer.disconnect();
90
- };
91
- }, [colors, theme]);
92
- return null;
93
- }
94
- function Provider({
95
- children,
96
- light = browserThemeColors.light,
97
- dark = browserThemeColors.dark,
98
- fullscreen = true,
99
- ...props
100
- }) {
101
- return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(
102
- ThemeProvider,
103
- {
104
- attribute: "class",
105
- defaultTheme: "system",
106
- enableSystem: true,
107
- disableTransitionOnChange: true,
108
- ...props,
109
- children: /* @__PURE__ */ jsxs(TopLoader, { children: [
110
- /* @__PURE__ */ jsx(AppToaster, {}),
111
- /* @__PURE__ */ jsx(AppStatusBarBackground, {}),
112
- /* @__PURE__ */ jsx(NativeThemeEventSync, {}),
113
- /* @__PURE__ */ jsx(BrowserThemeSync, { light, dark }),
114
- /* @__PURE__ */ jsx(ThemeHotkey, {}),
115
- fullscreen ? /* @__PURE__ */ jsx(FullscreenHotkey, {}) : null,
116
- children
117
- ] })
118
- }
119
- ) });
120
- }
121
- function AppToaster() {
122
- const { resolvedTheme } = useTheme();
123
- const toasterTheme = resolvedTheme === "dark" ? "dark" : "light";
124
- return /* @__PURE__ */ jsx(
125
- GooeyToaster,
126
- {
127
- theme: toasterTheme,
128
- position: "bottom-right",
129
- closeButton: "top-left"
130
- },
131
- toasterTheme
132
- );
133
- }
134
- function AppStatusBarBackground() {
135
- return /* @__PURE__ */ jsx(
136
- "div",
137
- {
138
- "aria-hidden": true,
139
- className: "fixed inset-x-0 top-0 z-50 hidden h-(--app-safe-top) bg-background/80 backdrop-blur-xl standalone:block native:block"
140
- }
141
- );
142
- }
143
- function NativeThemeEventSync() {
144
- const { resolvedTheme } = useTheme();
145
- React.useEffect(() => {
146
- if (!resolvedTheme) return;
147
- window.dispatchEvent(
148
- new CustomEvent("kdpower:theme-change", {
149
- detail: {
150
- theme: resolvedTheme
151
- }
152
- })
153
- );
154
- }, [resolvedTheme]);
155
- return null;
156
- }
157
- function isTypingTarget(target) {
158
- if (!(target instanceof HTMLElement)) {
159
- return false;
160
- }
161
- return target.isContentEditable || target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT";
162
- }
163
- function ThemeHotkey() {
164
- const { resolvedTheme, setTheme } = useTheme();
165
- React.useEffect(() => {
166
- function onKeyDown(event) {
167
- if (event.defaultPrevented || event.repeat) {
168
- return;
169
- }
170
- if (event.metaKey || event.ctrlKey || event.altKey) {
171
- return;
172
- }
173
- if (typeof event.key !== "string" || event.key.toLowerCase() !== "d") {
174
- return;
175
- }
176
- if (isTypingTarget(event.target)) {
177
- return;
178
- }
179
- setTheme(resolvedTheme === "dark" ? "light" : "dark");
180
- }
181
- window.addEventListener("keydown", onKeyDown);
182
- return () => {
183
- window.removeEventListener("keydown", onKeyDown);
184
- };
185
- }, [resolvedTheme, setTheme]);
186
- return null;
187
- }
188
- function FullscreenHotkey() {
189
- const isNative = useNative();
190
- const { toggleFullscreen } = useFullscreen();
191
- useHotkeys(
192
- "f",
193
- () => {
194
- void toggleFullscreen();
195
- },
196
- {
197
- enabled: !isNative,
198
- enableOnContentEditable: false,
199
- enableOnFormTags: false,
200
- preventDefault: true
201
- }
202
- );
203
- return null;
204
- }
205
-
206
- export {
207
- browserThemeColors,
208
- Provider
209
- };
@@ -1,228 +0,0 @@
1
- import {
2
- Empty,
3
- EmptyContent,
4
- EmptyDescription,
5
- EmptyHeader,
6
- EmptyTitle
7
- } from "./chunk-OSVLAX37.js";
8
- import {
9
- useMounted
10
- } from "./chunk-G4NDAZTB.js";
11
- import {
12
- Button
13
- } from "./chunk-DVNTJNDP.js";
14
-
15
- // src/ui/jelly.tsx
16
- import {
17
- BlobSpeech,
18
- JellyBlobMascot
19
- } from "feral-blob";
20
- import * as React from "react";
21
- import { cn } from "cn";
22
- import {
23
- BlobSpeech as BlobSpeech2,
24
- JellyBlobMascot as JellyBlobMascot2,
25
- JellyBlobMascotDemo
26
- } from "feral-blob";
27
- import { jsx, jsxs } from "react/jsx-runtime";
28
- function JellyBlob({ ...props }) {
29
- return /* @__PURE__ */ jsx("span", { className: "inline-block", children: /* @__PURE__ */ jsx(
30
- JellyBlobMascot,
31
- {
32
- ...props,
33
- className: cn("h-auto w-full", props.className)
34
- }
35
- ) });
36
- }
37
- var MOOD_GAZE = {
38
- neutral: { x: 0, y: 8 },
39
- happy: { x: 18, y: -6 },
40
- sad: { x: 0, y: 14 },
41
- angry: { x: 10, y: 2 },
42
- hmm: { x: 10, y: -4 },
43
- sideEye: { x: 30, y: 0 },
44
- password: { x: -14, y: 16 },
45
- curious: { x: 18, y: -8 },
46
- surprised: { x: 0, y: -10 },
47
- sleepy: { x: 0, y: 14 },
48
- shy: { x: -12, y: 4 },
49
- love: { x: 0, y: -4 },
50
- wave: { x: 20, y: -8 }
51
- };
52
- function JellyMini({
53
- mood = "neutral",
54
- gaze,
55
- className,
56
- ...props
57
- }) {
58
- const { mounted } = useMounted();
59
- return /* @__PURE__ */ jsx(
60
- "span",
61
- {
62
- "aria-hidden": "true",
63
- className: cn(
64
- "inline-flex size-5 shrink-0 items-center justify-center select-none",
65
- className
66
- ),
67
- children: mounted ? /* @__PURE__ */ jsx(
68
- JellyBlobMascot,
69
- {
70
- ...props,
71
- mood,
72
- gaze: gaze ?? MOOD_GAZE[mood],
73
- className: "h-auto w-full"
74
- }
75
- ) : null
76
- }
77
- );
78
- }
79
- var JellyMascotContext = React.createContext(null);
80
- function useJellyMood() {
81
- const state = React.useContext(JellyMascotContext);
82
- return React.useCallback(
83
- (mood) => {
84
- if (!mood || !state) return {};
85
- return {
86
- onPointerEnter: () => state.setPreview(mood),
87
- onFocus: () => state.setPreview(mood),
88
- onPointerLeave: () => state.setPreview(null),
89
- onBlur: () => state.setPreview(null)
90
- };
91
- },
92
- [state]
93
- );
94
- }
95
- function withPreviewHandlers(preview, props) {
96
- const handlers = preview(props.mood);
97
- return {
98
- onPointerEnter: props.onPointerEnter ?? handlers.onPointerEnter,
99
- onPointerLeave: props.onPointerLeave ?? handlers.onPointerLeave,
100
- onFocus: props.onFocus ?? handlers.onFocus,
101
- onBlur: props.onBlur ?? handlers.onBlur
102
- };
103
- }
104
- function JellyAction({
105
- mood,
106
- ...props
107
- }) {
108
- const preview = useJellyMood();
109
- return /* @__PURE__ */ jsx(Button, { ...props, ...withPreviewHandlers(preview, { ...props, mood }) });
110
- }
111
- function JellyLink({
112
- mood,
113
- ...props
114
- }) {
115
- const preview = useJellyMood();
116
- return /* @__PURE__ */ jsx("a", { ...props, ...withPreviewHandlers(preview, { ...props, mood }) });
117
- }
118
- function JellyMascotProvider({
119
- mood = "neutral",
120
- speech,
121
- children,
122
- ...blobProps
123
- }) {
124
- const { mounted } = useMounted();
125
- const [previewMood, setPreviewMood] = React.useState(
126
- null
127
- );
128
- const activeMood = previewMood ?? mood;
129
- const value = {
130
- mood: activeMood,
131
- speech,
132
- nod: blobProps.nod ?? false,
133
- gaze: blobProps.gaze ?? MOOD_GAZE[activeMood],
134
- mounted,
135
- blobProps,
136
- setPreview: setPreviewMood
137
- };
138
- return /* @__PURE__ */ jsx(JellyMascotContext.Provider, { value, children });
139
- }
140
- var SIZE_WRAPPER = {
141
- sm: "w-20",
142
- md: "w-28",
143
- lg: "w-48",
144
- auto: "w-auto"
145
- };
146
- function JellyMascotFace({
147
- size = "md",
148
- className
149
- }) {
150
- const mascot = React.useContext(JellyMascotContext);
151
- if (!mascot) return null;
152
- return /* @__PURE__ */ jsxs(
153
- "div",
154
- {
155
- "aria-hidden": "true",
156
- className: cn(
157
- "flex flex-col items-center select-none",
158
- SIZE_WRAPPER[size],
159
- className
160
- ),
161
- children: [
162
- mascot.speech ? /* @__PURE__ */ jsx(
163
- BlobSpeech,
164
- {
165
- mood: mascot.mood,
166
- messages: { [mascot.mood]: mascot.speech }
167
- }
168
- ) : null,
169
- mascot.mounted ? /* @__PURE__ */ jsx(
170
- JellyBlobMascot,
171
- {
172
- ...mascot.blobProps,
173
- mood: mascot.mood,
174
- gaze: mascot.gaze,
175
- nod: mascot.nod,
176
- className: "h-auto w-full"
177
- }
178
- ) : null
179
- ]
180
- }
181
- );
182
- }
183
- function JellyMascot({
184
- size = "md",
185
- className,
186
- ...config
187
- }) {
188
- const existing = React.useContext(JellyMascotContext);
189
- if (existing) return /* @__PURE__ */ jsx(JellyMascotFace, { size, className });
190
- return /* @__PURE__ */ jsx(JellyMascotProvider, { ...config, children: /* @__PURE__ */ jsx(JellyMascotFace, { size, className }) });
191
- }
192
- function JellyGroup({
193
- children,
194
- ...config
195
- }) {
196
- return /* @__PURE__ */ jsx(JellyMascotProvider, { ...config, children });
197
- }
198
- function JellyEmpty({
199
- title,
200
- description,
201
- actions,
202
- size = "lg",
203
- className,
204
- ...config
205
- }) {
206
- return /* @__PURE__ */ jsx(JellyMascotProvider, { ...config, children: /* @__PURE__ */ jsxs(Empty, { className: cn("gap-4", className), children: [
207
- /* @__PURE__ */ jsxs(EmptyHeader, { className: "gap-2", children: [
208
- /* @__PURE__ */ jsx(JellyMascotFace, { size }),
209
- title ? /* @__PURE__ */ jsx(EmptyTitle, { className: "text-base font-semibold sm:text-lg", children: title }) : null,
210
- description ? /* @__PURE__ */ jsx(EmptyDescription, { className: "max-w-sm", children: description }) : null
211
- ] }),
212
- actions ? /* @__PURE__ */ jsx(EmptyContent, { children: actions }) : null
213
- ] }) });
214
- }
215
-
216
- export {
217
- JellyBlob,
218
- JellyMini,
219
- useJellyMood,
220
- JellyAction,
221
- JellyLink,
222
- JellyMascot,
223
- JellyGroup,
224
- JellyEmpty,
225
- BlobSpeech2 as BlobSpeech,
226
- JellyBlobMascot2 as JellyBlobMascot,
227
- JellyBlobMascotDemo
228
- };
File without changes