rockin 0.0.34 → 0.0.36

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.
Files changed (91) hide show
  1. package/dist/chunk-3CZ2LLUN.js +198 -0
  2. package/dist/{chunk-7ZCRGTLA.js → chunk-54ZJAEO5.js} +5 -5
  3. package/dist/chunk-5GM3YR42.js +228 -0
  4. package/dist/chunk-6XUTSMTJ.js +183 -0
  5. package/dist/chunk-7JJBATB2.js +35 -0
  6. package/dist/chunk-BITCJZQZ.js +31 -0
  7. package/dist/chunk-COPQJFDI.js +158 -0
  8. package/dist/chunk-D6TULSM6.js +785 -0
  9. package/dist/chunk-DVNTJNDP.js +55 -0
  10. package/dist/chunk-EKDBYSMI.js +87 -0
  11. package/dist/chunk-FGWWRPMR.js +71 -0
  12. package/dist/chunk-G233W3IR.js +17 -0
  13. package/dist/chunk-G4NDAZTB.js +13 -0
  14. package/dist/chunk-GY2BX5SK.js +26 -0
  15. package/dist/chunk-MZBLIA6C.js +20 -0
  16. package/dist/chunk-OSVLAX37.js +101 -0
  17. package/dist/chunk-PRGKTXJU.js +20 -0
  18. package/dist/chunk-RUKQ532H.js +253 -0
  19. package/dist/chunk-S4H2HENE.js +113 -0
  20. package/dist/chunk-UHZTEDHK.js +61 -0
  21. package/dist/chunk-VFDNWPOI.js +293 -0
  22. package/dist/chunk-W4EIJWHF.js +150 -0
  23. package/dist/hooks/index.js +18 -9
  24. package/dist/index.js +4 -4
  25. package/dist/provider.js +3 -3
  26. package/dist/styles.css +2 -2
  27. package/dist/ui/accordion.js +95 -0
  28. package/dist/ui/alert-dialog.js +178 -0
  29. package/dist/ui/apple/english.js +7 -0
  30. package/dist/ui/apple/hindi.js +7 -0
  31. package/dist/ui/apple/index.js +52 -0
  32. package/dist/ui/apple/spanish.js +7 -0
  33. package/dist/ui/ariakit.js +7 -0
  34. package/dist/ui/autocomplete.js +296 -0
  35. package/dist/ui/avatar.js +106 -0
  36. package/dist/ui/badge.js +50 -0
  37. package/dist/ui/bridge.js +109 -0
  38. package/dist/ui/bubble.js +118 -0
  39. package/dist/ui/button-group.js +14 -0
  40. package/dist/ui/button.js +9 -0
  41. package/dist/ui/card.js +102 -0
  42. package/dist/ui/carousel.js +205 -0
  43. package/dist/ui/chart.js +253 -0
  44. package/dist/ui/checkbox.js +34 -0
  45. package/dist/ui/code-block.js +128 -0
  46. package/dist/ui/combobox.js +41 -0
  47. package/dist/ui/command.js +199 -0
  48. package/dist/ui/dashed.js +57 -0
  49. package/dist/ui/data-table/index.js +233 -0
  50. package/dist/ui/dialog.js +26 -0
  51. package/dist/ui/dock.js +86 -0
  52. package/dist/ui/drawer.js +216 -0
  53. package/dist/ui/dropdown-menu.js +35 -0
  54. package/dist/ui/empty.js +17 -0
  55. package/dist/ui/farmer/div.js +38 -0
  56. package/dist/ui/farmer/variants.js +314 -0
  57. package/dist/ui/field.js +224 -0
  58. package/dist/ui/filters.js +1524 -0
  59. package/dist/ui/image.js +88 -0
  60. package/dist/ui/index.d.ts +1 -1
  61. package/dist/ui/index.js +57 -8502
  62. package/dist/ui/input-group.js +20 -0
  63. package/dist/ui/input-otp.js +83 -0
  64. package/dist/ui/input.js +7 -0
  65. package/dist/ui/item.js +200 -0
  66. package/dist/ui/jelly.js +30 -0
  67. package/dist/ui/kbd.js +9 -0
  68. package/dist/ui/label.js +7 -0
  69. package/dist/ui/message-scroller.js +122 -0
  70. package/dist/ui/message.js +93 -0
  71. package/dist/ui/numberstepper.js +416 -0
  72. package/dist/ui/otp.js +403 -0
  73. package/dist/ui/popover.js +83 -0
  74. package/dist/ui/qr-code.js +124 -0
  75. package/dist/ui/quantity.js +48 -0
  76. package/dist/ui/radio-group.js +42 -0
  77. package/dist/ui/resizable.js +52 -0
  78. package/dist/ui/scroll-area.js +9 -0
  79. package/dist/ui/select.js +194 -0
  80. package/dist/ui/separator.js +7 -0
  81. package/dist/ui/skeleton.js +25 -0
  82. package/dist/ui/sonner.js +22 -0
  83. package/dist/ui/sortable.js +503 -0
  84. package/dist/ui/swipe-actions.js +45 -0
  85. package/dist/ui/switch.js +34 -0
  86. package/dist/ui/textarea.js +7 -0
  87. package/dist/ui/theme-toggle.js +141 -0
  88. package/dist/ui/tooltip.js +13 -0
  89. package/package.json +1 -1
  90. package/dist/chunk-4KFB6AJH.js +0 -1330
  91. /package/dist/{chunk-FYFBWCMJ.js → chunk-GBVAFFZR.js} +0 -0
@@ -0,0 +1,416 @@
1
+ "use client";
2
+
3
+ // src/ui/numberstepper.tsx
4
+ import { TrashBin } from "@gravity-ui/icons";
5
+ import { cn } from "cn";
6
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
7
+ import {
8
+ forwardRef,
9
+ useEffect,
10
+ useId,
11
+ useLayoutEffect,
12
+ useRef,
13
+ useState
14
+ } from "react";
15
+ import { jsx, jsxs } from "react/jsx-runtime";
16
+ var EASE_OUT = [0.23, 1, 0.32, 1];
17
+ var ROLL = { duration: 0.18, ease: EASE_OUT };
18
+ var SLIDE = { type: "spring", visualDuration: 0.2, bounce: 0 };
19
+ var HOLD_DELAY = 400;
20
+ var FIRST_REPEAT = 150;
21
+ var ACCELERATION = 0.85;
22
+ var FASTEST = 40;
23
+ var sizeStyles = {
24
+ xs: {
25
+ container: "h-6 p-0.5",
26
+ button: "size-5",
27
+ value: "w-6",
28
+ text: "text-xs",
29
+ icon: "size-3"
30
+ },
31
+ sm: {
32
+ container: "h-7 p-0.5",
33
+ button: "size-6",
34
+ value: "w-7",
35
+ text: "text-sm",
36
+ icon: "size-3.5"
37
+ },
38
+ default: {
39
+ container: "h-8 p-0.5",
40
+ button: "size-7",
41
+ value: "w-9",
42
+ text: "text-sm",
43
+ icon: "size-3.5"
44
+ },
45
+ lg: {
46
+ container: "h-9 p-1",
47
+ button: "size-8",
48
+ value: "w-11",
49
+ text: "text-[15px]",
50
+ icon: "size-4"
51
+ }
52
+ };
53
+ var variantStyles = {
54
+ pill: {
55
+ container: "shadow-raised rounded-full",
56
+ button: "rounded-full text-foreground enabled:hover:bg-foreground/6 enabled:active:scale-[0.96] disabled:opacity-35",
57
+ text: "font-medium"
58
+ },
59
+ outline: {
60
+ container: "rounded-lg bg-background p-0! transition-[border-color,box-shadow] duration-150 ease-out focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/15",
61
+ button: "rounded-md text-foreground enabled:hover:bg-muted enabled:active:scale-[0.94] disabled:text-muted-foreground/40",
62
+ text: "font-mono font-medium tracking-tight"
63
+ }
64
+ };
65
+ function useDirection(value) {
66
+ const [previous, setPrevious] = useState(value);
67
+ const [direction, setDirection] = useState(1);
68
+ if (value !== previous) {
69
+ setPrevious(value);
70
+ setDirection(value > previous ? 1 : -1);
71
+ }
72
+ return direction;
73
+ }
74
+ function RollingNumber({
75
+ value,
76
+ format = String,
77
+ className
78
+ }) {
79
+ const direction = useDirection(value);
80
+ const chars = [...format(value)];
81
+ return /* @__PURE__ */ jsx(
82
+ "span",
83
+ {
84
+ "aria-hidden": true,
85
+ className: cn("relative inline-flex tabular-nums", className),
86
+ children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", initial: false, custom: direction, children: chars.map((char, index) => {
87
+ const place = chars.length - index;
88
+ const digit = /\d/.test(char);
89
+ return /* @__PURE__ */ jsx(Place, { digit, children: digit ? /* @__PURE__ */ jsx(Digit, { char, direction }) : char }, digit ? `d${place}` : `s${place}${char}`);
90
+ }) })
91
+ }
92
+ );
93
+ }
94
+ function Place({
95
+ digit,
96
+ children
97
+ }) {
98
+ const reduceMotion = useReducedMotion();
99
+ return /* @__PURE__ */ jsx(
100
+ motion.span,
101
+ {
102
+ layout: reduceMotion ? false : "position",
103
+ initial: { opacity: 0, filter: "blur(4px)" },
104
+ animate: { opacity: 1, filter: "blur(0px)" },
105
+ exit: {
106
+ opacity: 0,
107
+ filter: "blur(0px)",
108
+ transition: { duration: 0.1 }
109
+ },
110
+ transition: { ...ROLL, layout: SLIDE },
111
+ className: cn("inline-grid", digit && "overflow-hidden"),
112
+ children
113
+ }
114
+ );
115
+ }
116
+ function Digit({ char, direction }) {
117
+ const reduceMotion = useReducedMotion();
118
+ const offset = (value) => reduceMotion ? "0%" : `${value * 100}%`;
119
+ return /* @__PURE__ */ jsx(AnimatePresence, { initial: false, custom: direction, children: /* @__PURE__ */ jsx(
120
+ motion.span,
121
+ {
122
+ custom: direction,
123
+ variants: {
124
+ enter: (value) => ({
125
+ y: offset(value),
126
+ opacity: 0
127
+ }),
128
+ center: {
129
+ y: "0%",
130
+ opacity: 1
131
+ },
132
+ exit: (value) => ({
133
+ y: offset(-value),
134
+ opacity: 0
135
+ })
136
+ },
137
+ initial: "enter",
138
+ animate: "center",
139
+ exit: "exit",
140
+ transition: ROLL,
141
+ className: "col-start-1 row-start-1",
142
+ children: char
143
+ },
144
+ char
145
+ ) });
146
+ }
147
+ var NumberStepper = forwardRef(
148
+ function NumberStepper2({
149
+ label,
150
+ value,
151
+ onChange,
152
+ min = 0,
153
+ max = 99,
154
+ step = 1,
155
+ className,
156
+ size = "default",
157
+ variant = "pill",
158
+ disabled = false,
159
+ onRemove,
160
+ removeLabel = "Remove",
161
+ onFocus,
162
+ onKeyDown,
163
+ onKeyDownCapture
164
+ }, ref) {
165
+ const reduceMotion = useReducedMotion();
166
+ const id = useId();
167
+ const [draft, setDraft] = useState(null);
168
+ const valueRef = useRef(null);
169
+ const bumpAnimation = useRef(void 0);
170
+ const timer = useRef(void 0);
171
+ const latest = useRef({
172
+ value,
173
+ onChange,
174
+ min,
175
+ max,
176
+ disabled
177
+ });
178
+ useLayoutEffect(() => {
179
+ latest.current = {
180
+ value,
181
+ onChange,
182
+ min,
183
+ max,
184
+ disabled
185
+ };
186
+ });
187
+ useEffect(
188
+ () => () => {
189
+ clearTimeout(timer.current);
190
+ bumpAnimation.current?.cancel();
191
+ },
192
+ []
193
+ );
194
+ const bump = (direction) => {
195
+ const element = valueRef.current;
196
+ if (!element || reduceMotion) return;
197
+ bumpAnimation.current?.cancel();
198
+ bumpAnimation.current = element.animate(
199
+ {
200
+ translate: ["0", `${direction * 3}px`, "0"]
201
+ },
202
+ {
203
+ duration: 200,
204
+ easing: "cubic-bezier(0.23, 1, 0.32, 1)"
205
+ }
206
+ );
207
+ };
208
+ const setTo = (target, direction) => {
209
+ const current = latest.current;
210
+ if (current.disabled) return false;
211
+ const next = Math.min(Math.max(target, current.min), current.max);
212
+ if (next !== target) {
213
+ bump(direction);
214
+ }
215
+ if (next === current.value) return false;
216
+ latest.current = {
217
+ ...current,
218
+ value: next
219
+ };
220
+ current.onChange(next);
221
+ return true;
222
+ };
223
+ const stepBy = (delta) => setTo(latest.current.value + delta, delta > 0 ? 1 : -1);
224
+ const stop = () => {
225
+ clearTimeout(timer.current);
226
+ };
227
+ const hold = (delta) => {
228
+ if (disabled) return;
229
+ stop();
230
+ if (!stepBy(delta)) return;
231
+ let interval = FIRST_REPEAT;
232
+ const repeat = () => {
233
+ if (!stepBy(delta)) return;
234
+ interval = Math.max(FASTEST, interval * ACCELERATION);
235
+ timer.current = setTimeout(repeat, interval);
236
+ };
237
+ timer.current = setTimeout(repeat, HOLD_DELAY);
238
+ };
239
+ const commitDraft = () => {
240
+ if (draft === null) return;
241
+ const parsed = Number.parseInt(draft, 10);
242
+ setDraft(null);
243
+ if (Number.isNaN(parsed)) return;
244
+ setTo(parsed, parsed > latest.current.value ? 1 : -1);
245
+ };
246
+ const styles = sizeStyles[size];
247
+ const look = variantStyles[variant];
248
+ const button = (delta, atLimit, name, path) => /* @__PURE__ */ jsx(
249
+ "button",
250
+ {
251
+ type: "button",
252
+ disabled: disabled || atLimit,
253
+ "aria-label": `${name} ${label.toLowerCase()}`,
254
+ "aria-controls": id,
255
+ "aria-disabled": disabled || atLimit,
256
+ tabIndex: -1,
257
+ onPointerDown: (event) => {
258
+ if (event.button !== 0 || disabled) return;
259
+ event.preventDefault();
260
+ hold(delta);
261
+ },
262
+ onPointerUp: stop,
263
+ onPointerLeave: stop,
264
+ onPointerCancel: stop,
265
+ onContextMenu: (event) => event.preventDefault(),
266
+ onClick: (event) => {
267
+ if (disabled) return;
268
+ if (event.detail === 0) {
269
+ stepBy(delta);
270
+ }
271
+ },
272
+ className: cn(
273
+ "flex shrink-0 touch-manipulation items-center justify-center outline-hidden select-none disabled:cursor-not-allowed",
274
+ styles.button,
275
+ "transition-[scale,opacity,background-color,color] duration-150 ease-out motion-reduce:transition-[opacity,background-color,color]",
276
+ look.button
277
+ ),
278
+ children: /* @__PURE__ */ jsx(
279
+ "svg",
280
+ {
281
+ viewBox: "0 0 16 16",
282
+ "aria-hidden": true,
283
+ className: styles.icon,
284
+ fill: "none",
285
+ stroke: "currentColor",
286
+ strokeWidth: 1.5,
287
+ strokeLinecap: "round",
288
+ children: /* @__PURE__ */ jsx("path", { d: path })
289
+ }
290
+ )
291
+ }
292
+ );
293
+ const removeButton = /* @__PURE__ */ jsx(
294
+ "button",
295
+ {
296
+ type: "button",
297
+ disabled,
298
+ "aria-label": removeLabel,
299
+ onClick: () => {
300
+ if (!disabled) onRemove?.();
301
+ },
302
+ className: cn(
303
+ "flex shrink-0 touch-manipulation items-center justify-center outline-hidden select-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed",
304
+ styles.button,
305
+ "transition-[scale,background-color,color] duration-150 ease-out motion-reduce:transition-[background-color,color]",
306
+ look.button,
307
+ "enabled:hover:bg-destructive/10 enabled:hover:text-destructive"
308
+ ),
309
+ children: /* @__PURE__ */ jsx(TrashBin, { "aria-hidden": true, className: cn("size-3!", styles.icon) })
310
+ },
311
+ "remove"
312
+ );
313
+ const editing = draft !== null;
314
+ return /* @__PURE__ */ jsxs(
315
+ "div",
316
+ {
317
+ "data-slot": "input-group",
318
+ "data-variant": variant,
319
+ className: cn(
320
+ "inline-flex items-center border",
321
+ disabled && "cursor-not-allowed opacity-50",
322
+ styles.container,
323
+ look.container,
324
+ className
325
+ ),
326
+ children: [
327
+ onRemove && value <= min ? removeButton : button(-step, value <= min, "Decrease", "M3.5 8h9"),
328
+ /* @__PURE__ */ jsxs(
329
+ "span",
330
+ {
331
+ ref: valueRef,
332
+ className: cn("relative grid place-items-center", styles.value),
333
+ children: [
334
+ /* @__PURE__ */ jsx(
335
+ "input",
336
+ {
337
+ ref,
338
+ id,
339
+ disabled,
340
+ "data-slot": "input-group-control",
341
+ "data-no-ring": true,
342
+ role: "spinbutton",
343
+ "aria-label": label,
344
+ "aria-valuenow": value,
345
+ "aria-valuemin": min,
346
+ "aria-valuemax": max,
347
+ inputMode: "numeric",
348
+ autoComplete: "off",
349
+ value: draft ?? String(value),
350
+ onChange: (event) => {
351
+ setDraft(event.target.value.replace(/\D/g, ""));
352
+ },
353
+ onFocus: (event) => {
354
+ event.currentTarget.select();
355
+ onFocus?.(event);
356
+ },
357
+ onBlur: commitDraft,
358
+ onKeyDownCapture,
359
+ onKeyDown: (event) => {
360
+ onKeyDown?.(event);
361
+ if (event.defaultPrevented) return;
362
+ const delta = {
363
+ ArrowUp: step,
364
+ ArrowDown: -step,
365
+ PageUp: step * 10,
366
+ PageDown: -step * 10
367
+ };
368
+ if (event.key in delta) {
369
+ event.preventDefault();
370
+ setDraft(null);
371
+ stepBy(delta[event.key]);
372
+ } else if (event.key === "Home" || event.key === "End") {
373
+ event.preventDefault();
374
+ setDraft(null);
375
+ setTo(
376
+ event.key === "Home" ? min : max,
377
+ event.key === "Home" ? -1 : 1
378
+ );
379
+ } else if (event.key === "Enter") {
380
+ commitDraft();
381
+ } else if (event.key === "Escape") {
382
+ setDraft(null);
383
+ }
384
+ },
385
+ className: cn(
386
+ "col-start-1 row-start-1 w-full bg-transparent text-center tabular-nums caret-foreground outline-hidden selection:bg-ring/25 selection:text-foreground disabled:cursor-not-allowed",
387
+ styles.text,
388
+ look.text,
389
+ editing ? "text-foreground" : "text-transparent"
390
+ )
391
+ }
392
+ ),
393
+ !editing && /* @__PURE__ */ jsx(
394
+ RollingNumber,
395
+ {
396
+ value,
397
+ className: cn(
398
+ "pointer-events-none col-start-1 row-start-1 text-foreground",
399
+ styles.text,
400
+ look.text
401
+ )
402
+ }
403
+ )
404
+ ]
405
+ }
406
+ ),
407
+ button(step, value >= max, "Increase", "M3.5 8h9M8 3.5v9")
408
+ ]
409
+ }
410
+ );
411
+ }
412
+ );
413
+ export {
414
+ NumberStepper,
415
+ RollingNumber
416
+ };