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.
- package/dist/{chunk-GL2CQ5TR.js → chunk-23GWTX3S.js} +15 -4
- package/dist/{chunk-4ILCWFOE.js → chunk-53MRWZE4.js} +1 -1
- package/dist/{chunk-YA5PSI7E.js → chunk-VFN3HOYP.js} +15 -3
- package/dist/hooks/index.js +3 -3
- package/dist/index.d.ts +41 -4
- package/dist/index.js +6 -4
- package/dist/layout.js +1 -1
- package/dist/lib/index.d.ts +3 -120
- package/dist/lib/index.js +3 -1
- package/dist/preferences-CvWGOnty.d.ts +158 -0
- package/dist/provider.js +2 -2
- package/dist/ui/bridge.js +1 -1
- package/dist/ui/carousel.js +71 -1
- package/dist/ui/code-block.js +2 -2
- package/dist/ui/drawer-dialog.js +3 -3
- package/dist/ui/farmer/div.js +3 -3
- package/dist/ui/image.js +286 -66
- package/dist/ui/index.d.ts +495 -11
- package/dist/ui/index.js +4 -3
- package/dist/ui/list.js +32 -10
- package/dist/ui/sonner.js +2 -2
- package/dist/ui/theme-switcher.js +2 -2
- package/dist/ui/theme-toggle.js +2 -2
- package/dist/ui/ui-agent.js +81 -0
- package/package.json +1 -1
package/dist/ui/drawer-dialog.js
CHANGED
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
} from "../chunk-UZGJXAFX.js";
|
|
5
5
|
import {
|
|
6
6
|
useMediaQuery
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-53MRWZE4.js";
|
|
8
8
|
import {
|
|
9
9
|
Button
|
|
10
10
|
} from "../chunk-DVNTJNDP.js";
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-VFN3HOYP.js";
|
|
12
|
+
import "../chunk-23GWTX3S.js";
|
|
13
13
|
|
|
14
14
|
// src/ui/drawer-dialog.tsx
|
|
15
15
|
import { Xmark } from "@gravity-ui/icons";
|
package/dist/ui/farmer/div.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useMediaQuery
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-53MRWZE4.js";
|
|
5
|
+
import "../../chunk-VFN3HOYP.js";
|
|
6
|
+
import "../../chunk-23GWTX3S.js";
|
|
7
7
|
|
|
8
8
|
// src/ui/farmer/div.tsx
|
|
9
9
|
import { motion } from "motion/react";
|
package/dist/ui/image.js
CHANGED
|
@@ -4,13 +4,79 @@ import {
|
|
|
4
4
|
} from "../chunk-3CZ2LLUN.js";
|
|
5
5
|
|
|
6
6
|
// src/ui/image.tsx
|
|
7
|
+
import { avatar } from "@ui-sdk/core/avatar";
|
|
8
|
+
import {
|
|
9
|
+
createParts
|
|
10
|
+
} from "@ui-sdk/react/primitive";
|
|
7
11
|
import { cn } from "cn";
|
|
8
|
-
import NextImage from "next/image";
|
|
9
12
|
import {
|
|
13
|
+
createContext,
|
|
10
14
|
useCallback,
|
|
15
|
+
useContext,
|
|
16
|
+
useEffect,
|
|
17
|
+
useMemo,
|
|
11
18
|
useState
|
|
12
19
|
} from "react";
|
|
20
|
+
import { preload as preloadResource } from "react-dom";
|
|
13
21
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { createElement } from "react";
|
|
23
|
+
var {
|
|
24
|
+
Root: ImageRoot,
|
|
25
|
+
Image: ImageSource,
|
|
26
|
+
Fallback: ImageFallback
|
|
27
|
+
} = createParts(avatar, { root: "span", image: "img", fallback: "span" });
|
|
28
|
+
var DEFAULT_WIDTHS = [
|
|
29
|
+
64,
|
|
30
|
+
128,
|
|
31
|
+
256,
|
|
32
|
+
384,
|
|
33
|
+
640,
|
|
34
|
+
750,
|
|
35
|
+
828,
|
|
36
|
+
1080,
|
|
37
|
+
1200,
|
|
38
|
+
1920,
|
|
39
|
+
2048,
|
|
40
|
+
3840
|
|
41
|
+
];
|
|
42
|
+
function readNextImageConfig() {
|
|
43
|
+
let options;
|
|
44
|
+
try {
|
|
45
|
+
options = process.env.__NEXT_IMAGE_OPTS;
|
|
46
|
+
} catch {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
if (!options || typeof options !== "object" || options.unoptimized) return {};
|
|
50
|
+
if (options.loader && options.loader !== "default") return {};
|
|
51
|
+
const path = options.path || "/_next/image";
|
|
52
|
+
const widths = [...options.imageSizes ?? [], ...options.deviceSizes ?? []];
|
|
53
|
+
return {
|
|
54
|
+
loader: ({ src, width, quality }) => `${path}?url=${encodeURIComponent(src)}&w=${width}&q=${quality ?? 75}`,
|
|
55
|
+
widths: widths.length ? widths : void 0,
|
|
56
|
+
qualities: options.qualities
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
var ImageConfigContext = createContext(readNextImageConfig());
|
|
60
|
+
function ImageProvider({
|
|
61
|
+
loader,
|
|
62
|
+
widths,
|
|
63
|
+
quality,
|
|
64
|
+
qualities,
|
|
65
|
+
children
|
|
66
|
+
}) {
|
|
67
|
+
const value = useMemo(
|
|
68
|
+
() => ({ loader, widths, quality, qualities }),
|
|
69
|
+
[loader, widths, quality, qualities]
|
|
70
|
+
);
|
|
71
|
+
return /* @__PURE__ */ jsx(ImageConfigContext.Provider, { value, children });
|
|
72
|
+
}
|
|
73
|
+
function snapQuality(quality, allowed) {
|
|
74
|
+
if (!allowed?.length) return quality;
|
|
75
|
+
const target = quality ?? 75;
|
|
76
|
+
return allowed.reduce(
|
|
77
|
+
(best, q) => Math.abs(q - target) < Math.abs(best - target) ? q : best
|
|
78
|
+
);
|
|
79
|
+
}
|
|
14
80
|
function textHue(text) {
|
|
15
81
|
let hash = 2166136261;
|
|
16
82
|
for (const char of text) {
|
|
@@ -59,88 +125,242 @@ function BrokenThumbnail({ className }) {
|
|
|
59
125
|
}
|
|
60
126
|
);
|
|
61
127
|
}
|
|
62
|
-
function
|
|
128
|
+
function EmptyThumbnail({ className }) {
|
|
129
|
+
return /* @__PURE__ */ jsxs(
|
|
130
|
+
"svg",
|
|
131
|
+
{
|
|
132
|
+
viewBox: "0 0 48 48",
|
|
133
|
+
"aria-hidden": "true",
|
|
134
|
+
fill: "none",
|
|
135
|
+
stroke: "currentColor",
|
|
136
|
+
strokeWidth: "2",
|
|
137
|
+
strokeLinecap: "round",
|
|
138
|
+
strokeLinejoin: "round",
|
|
139
|
+
className,
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ jsx(
|
|
142
|
+
"rect",
|
|
143
|
+
{
|
|
144
|
+
x: "6",
|
|
145
|
+
y: "9",
|
|
146
|
+
width: "36",
|
|
147
|
+
height: "30",
|
|
148
|
+
rx: "4",
|
|
149
|
+
fill: "currentColor",
|
|
150
|
+
fillOpacity: "0.1"
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
/* @__PURE__ */ jsx("circle", { cx: "33", cy: "18", r: "3" }),
|
|
154
|
+
/* @__PURE__ */ jsx("path", { d: "M6 33l10-10 9 9 5-5 12 10" })
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
function ImagePlaceholder({
|
|
160
|
+
label,
|
|
161
|
+
reason = "empty",
|
|
162
|
+
className
|
|
163
|
+
}) {
|
|
63
164
|
const text = (label || "").trim();
|
|
165
|
+
const status = reason === "error" ? "image failed to load" : "no image";
|
|
166
|
+
const Glyph = reason === "error" ? BrokenThumbnail : EmptyThumbnail;
|
|
64
167
|
return /* @__PURE__ */ jsx(
|
|
65
|
-
"
|
|
168
|
+
"span",
|
|
66
169
|
{
|
|
67
170
|
role: "img",
|
|
68
|
-
"aria-label":
|
|
171
|
+
"aria-label": text ? `${text} (${status})` : status[0].toUpperCase() + status.slice(1),
|
|
172
|
+
"data-slot": "image-placeholder",
|
|
173
|
+
"data-reason": reason,
|
|
69
174
|
style: { "--ph-hue": text ? textHue(text) : 250 },
|
|
70
|
-
className:
|
|
71
|
-
|
|
175
|
+
className: cn(
|
|
176
|
+
"flex size-full items-center justify-center bg-linear-135 from-(--ph-from) to-(--ph-to) text-(--ph-fg) [--ph-fg:oklch(0.55_0.12_var(--ph-hue))] [--ph-from:oklch(0.92_0.06_var(--ph-hue))] [--ph-to:oklch(0.97_0.025_calc(var(--ph-hue)+40))] dark:[--ph-fg:oklch(0.82_0.1_var(--ph-hue))] dark:[--ph-from:oklch(0.36_0.07_var(--ph-hue))] dark:[--ph-to:oklch(0.26_0.04_calc(var(--ph-hue)+40))]",
|
|
177
|
+
className
|
|
178
|
+
),
|
|
179
|
+
children: /* @__PURE__ */ jsx(Glyph, { className: "aspect-square h-auto w-[34%] max-w-20 min-w-4" })
|
|
72
180
|
}
|
|
73
181
|
);
|
|
74
182
|
}
|
|
75
|
-
function
|
|
183
|
+
function resolveSrc(src) {
|
|
76
184
|
if (!src) return null;
|
|
77
|
-
if (typeof src === "string") return src;
|
|
78
|
-
if ("
|
|
79
|
-
return src.
|
|
185
|
+
if (typeof src === "string") return { src };
|
|
186
|
+
if ("default" in src) return src.default;
|
|
187
|
+
return src.src ? src : null;
|
|
188
|
+
}
|
|
189
|
+
function toNumber(value) {
|
|
190
|
+
const number = Number(value);
|
|
191
|
+
return Number.isFinite(number) && number > 0 ? number : void 0;
|
|
192
|
+
}
|
|
193
|
+
function buildSources(url, options) {
|
|
194
|
+
const { loader, quality, width, sizes, srcSet, fill } = options;
|
|
195
|
+
if (!loader || srcSet || /^(data|blob):|\.svg($|[?#])/i.test(url)) {
|
|
196
|
+
return { src: url, srcSet, sizes };
|
|
197
|
+
}
|
|
198
|
+
const widths = [...options.widths].sort((a, b) => a - b);
|
|
199
|
+
const largest = widths[widths.length - 1];
|
|
200
|
+
const at = (w) => loader({ src: url, width: w, quality });
|
|
201
|
+
if (sizes || fill || !width) {
|
|
202
|
+
return {
|
|
203
|
+
src: at(largest),
|
|
204
|
+
srcSet: widths.map((w) => `${at(w)} ${w}w`).join(", "),
|
|
205
|
+
sizes: sizes ?? "100vw"
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const pick = (target) => widths.find((w) => w >= target) ?? largest;
|
|
209
|
+
const density = [.../* @__PURE__ */ new Set([pick(width), pick(width * 2)])];
|
|
210
|
+
return {
|
|
211
|
+
src: at(density[density.length - 1]),
|
|
212
|
+
srcSet: density.map((w, i) => `${at(w)} ${i + 1}x`).join(", ")
|
|
213
|
+
};
|
|
80
214
|
}
|
|
81
215
|
function Image({
|
|
216
|
+
src,
|
|
217
|
+
alt = "",
|
|
218
|
+
className,
|
|
219
|
+
style,
|
|
82
220
|
wrapper,
|
|
221
|
+
fill = false,
|
|
83
222
|
showSkeleton = true,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
onError,
|
|
223
|
+
preload: preloadProp,
|
|
224
|
+
priority = false,
|
|
225
|
+
quality: qualityProp,
|
|
226
|
+
unoptimized = false,
|
|
227
|
+
loader: loaderProp,
|
|
228
|
+
retry = 1,
|
|
229
|
+
retryDelay = 1500,
|
|
230
|
+
fallback,
|
|
93
231
|
children,
|
|
94
|
-
|
|
232
|
+
loading,
|
|
233
|
+
fetchPriority,
|
|
234
|
+
decoding = "async",
|
|
235
|
+
width,
|
|
236
|
+
height,
|
|
237
|
+
srcSet,
|
|
238
|
+
sizes,
|
|
239
|
+
onStateChange,
|
|
95
240
|
...props
|
|
96
241
|
}) {
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
242
|
+
const config = useContext(ImageConfigContext);
|
|
243
|
+
const image = resolveSrc(src);
|
|
244
|
+
const url = image?.src ?? null;
|
|
245
|
+
const preload = preloadProp ?? priority;
|
|
246
|
+
const w = fill ? void 0 : toNumber(width) ?? image?.width;
|
|
247
|
+
const h = fill ? void 0 : toNumber(height) ?? image?.height;
|
|
248
|
+
const sources = url ? buildSources(url, {
|
|
249
|
+
loader: unoptimized ? void 0 : loaderProp ?? config.loader,
|
|
250
|
+
widths: config.widths?.length ? config.widths : DEFAULT_WIDTHS,
|
|
251
|
+
quality: snapQuality(qualityProp ?? config.quality, config.qualities),
|
|
252
|
+
width: w,
|
|
253
|
+
sizes,
|
|
254
|
+
srcSet,
|
|
255
|
+
fill
|
|
256
|
+
}) : null;
|
|
257
|
+
const [status, setStatus] = useState("idle");
|
|
258
|
+
const [attempt, setAttempt] = useState({
|
|
259
|
+
src: url,
|
|
260
|
+
count: 0,
|
|
261
|
+
retrying: false
|
|
262
|
+
});
|
|
263
|
+
const current = attempt.src === url ? attempt : { src: url, count: 0, retrying: false };
|
|
264
|
+
const state = !url ? "empty" : current.retrying || status === "idle" || status === "loading" ? "loading" : status;
|
|
265
|
+
if (preload && sources) {
|
|
266
|
+
preloadResource(sources.src, {
|
|
267
|
+
as: "image",
|
|
268
|
+
fetchPriority: "high",
|
|
269
|
+
imageSrcSet: sources.srcSet,
|
|
270
|
+
imageSizes: sources.sizes
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
useEffect(() => {
|
|
274
|
+
onStateChange?.(state);
|
|
275
|
+
}, [state, onStateChange]);
|
|
276
|
+
const reload = useCallback(() => {
|
|
277
|
+
setAttempt(
|
|
278
|
+
(prev) => prev.src === url ? { src: url, count: prev.count + 1, retrying: false } : prev
|
|
279
|
+
);
|
|
280
|
+
}, [url]);
|
|
281
|
+
const handleStatus = useCallback(
|
|
282
|
+
(next) => {
|
|
283
|
+
setStatus(next);
|
|
284
|
+
if (next !== "error") return;
|
|
285
|
+
setAttempt((prev) => {
|
|
286
|
+
const count = prev.src === url ? prev.count : 0;
|
|
287
|
+
return { src: url, count, retrying: count < retry };
|
|
288
|
+
});
|
|
289
|
+
},
|
|
290
|
+
[url, retry]
|
|
291
|
+
);
|
|
292
|
+
useEffect(() => {
|
|
293
|
+
if (!current.retrying) return;
|
|
294
|
+
const timer = window.setTimeout(reload, retryDelay);
|
|
295
|
+
return () => window.clearTimeout(timer);
|
|
296
|
+
}, [current.retrying, reload, retryDelay]);
|
|
297
|
+
useEffect(() => {
|
|
298
|
+
if (state !== "error") return;
|
|
299
|
+
window.addEventListener("online", reload);
|
|
300
|
+
return () => window.removeEventListener("online", reload);
|
|
301
|
+
}, [state, reload]);
|
|
302
|
+
const eager = preload || loading === "eager";
|
|
303
|
+
const overlay = fill || Boolean(wrapper);
|
|
304
|
+
return /* @__PURE__ */ jsxs(
|
|
305
|
+
ImageRoot,
|
|
306
|
+
{
|
|
307
|
+
"data-state": state,
|
|
308
|
+
className: cn("relative block overflow-hidden", wrapper),
|
|
309
|
+
onLoadingStatusChange: handleStatus,
|
|
310
|
+
children: [
|
|
311
|
+
sources && /* @__PURE__ */ createElement(
|
|
312
|
+
ImageSource,
|
|
313
|
+
{
|
|
314
|
+
...props,
|
|
315
|
+
key: `${sources.src}#${current.count}`,
|
|
316
|
+
src: sources.src,
|
|
317
|
+
srcSet: sources.srcSet,
|
|
318
|
+
sizes: sources.sizes,
|
|
319
|
+
alt,
|
|
320
|
+
width: w,
|
|
321
|
+
height: h,
|
|
322
|
+
loading: eager ? "eager" : loading ?? "lazy",
|
|
323
|
+
fetchPriority: fetchPriority ?? (eager ? "high" : void 0),
|
|
324
|
+
decoding,
|
|
325
|
+
style,
|
|
326
|
+
className: cn(
|
|
327
|
+
fill && "absolute inset-0 size-full",
|
|
328
|
+
"transition-opacity duration-200 motion-reduce:transition-none",
|
|
329
|
+
state === "loaded" ? "opacity-100" : "opacity-0",
|
|
330
|
+
className
|
|
331
|
+
)
|
|
332
|
+
}
|
|
333
|
+
),
|
|
334
|
+
state !== "loaded" && /* @__PURE__ */ jsx(
|
|
335
|
+
ImageFallback,
|
|
336
|
+
{
|
|
337
|
+
style: !overlay && w && h ? {
|
|
338
|
+
"--image-w": `${w}px`,
|
|
339
|
+
aspectRatio: `${w} / ${h}`
|
|
340
|
+
} : void 0,
|
|
341
|
+
className: overlay ? "absolute inset-0 block size-full" : cn(
|
|
342
|
+
w && h ? "block w-(--image-w) max-w-full" : "block size-full",
|
|
343
|
+
className
|
|
344
|
+
),
|
|
345
|
+
children: state === "loading" ? showSkeleton && /* @__PURE__ */ jsx(Skeleton, { rounded: "none", className: "size-full" }) : fallback ?? /* @__PURE__ */ jsx(
|
|
346
|
+
ImagePlaceholder,
|
|
347
|
+
{
|
|
348
|
+
label: alt,
|
|
349
|
+
reason: state === "error" ? "error" : "empty"
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
}
|
|
130
353
|
),
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
onError: (event) => {
|
|
136
|
-
markFailed();
|
|
137
|
-
onError?.(event);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
) : fallback,
|
|
141
|
-
children
|
|
142
|
-
] });
|
|
354
|
+
children
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
);
|
|
143
358
|
}
|
|
144
359
|
export {
|
|
145
|
-
Image
|
|
360
|
+
Image,
|
|
361
|
+
ImageFallback,
|
|
362
|
+
ImagePlaceholder,
|
|
363
|
+
ImageProvider,
|
|
364
|
+
ImageRoot,
|
|
365
|
+
ImageSource
|
|
146
366
|
};
|