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.
- package/dist/chunk-3CZ2LLUN.js +198 -0
- package/dist/{chunk-7ZCRGTLA.js → chunk-54ZJAEO5.js} +5 -5
- package/dist/chunk-5GM3YR42.js +228 -0
- package/dist/chunk-6XUTSMTJ.js +183 -0
- package/dist/chunk-7JJBATB2.js +35 -0
- package/dist/chunk-BITCJZQZ.js +31 -0
- package/dist/chunk-COPQJFDI.js +158 -0
- package/dist/chunk-D6TULSM6.js +785 -0
- package/dist/chunk-DVNTJNDP.js +55 -0
- package/dist/chunk-EKDBYSMI.js +87 -0
- package/dist/chunk-FGWWRPMR.js +71 -0
- package/dist/chunk-G233W3IR.js +17 -0
- package/dist/chunk-G4NDAZTB.js +13 -0
- package/dist/chunk-GY2BX5SK.js +26 -0
- package/dist/chunk-MZBLIA6C.js +20 -0
- package/dist/chunk-OSVLAX37.js +101 -0
- package/dist/chunk-PRGKTXJU.js +20 -0
- package/dist/chunk-RUKQ532H.js +253 -0
- package/dist/chunk-S4H2HENE.js +113 -0
- package/dist/chunk-UHZTEDHK.js +61 -0
- package/dist/chunk-VFDNWPOI.js +293 -0
- package/dist/chunk-W4EIJWHF.js +150 -0
- package/dist/hooks/index.js +18 -9
- package/dist/index.js +4 -4
- package/dist/provider.js +3 -3
- package/dist/styles.css +2 -2
- package/dist/ui/accordion.js +95 -0
- package/dist/ui/alert-dialog.js +178 -0
- package/dist/ui/apple/english.js +7 -0
- package/dist/ui/apple/hindi.js +7 -0
- package/dist/ui/apple/index.js +52 -0
- package/dist/ui/apple/spanish.js +7 -0
- package/dist/ui/ariakit.js +7 -0
- package/dist/ui/autocomplete.js +296 -0
- package/dist/ui/avatar.js +106 -0
- package/dist/ui/badge.js +50 -0
- package/dist/ui/bridge.js +109 -0
- package/dist/ui/bubble.js +118 -0
- package/dist/ui/button-group.js +14 -0
- package/dist/ui/button.js +9 -0
- package/dist/ui/card.js +102 -0
- package/dist/ui/carousel.js +205 -0
- package/dist/ui/chart.js +253 -0
- package/dist/ui/checkbox.js +34 -0
- package/dist/ui/code-block.js +128 -0
- package/dist/ui/combobox.js +41 -0
- package/dist/ui/command.js +199 -0
- package/dist/ui/dashed.js +57 -0
- package/dist/ui/data-table/index.js +233 -0
- package/dist/ui/dialog.js +26 -0
- package/dist/ui/dock.js +86 -0
- package/dist/ui/drawer.js +216 -0
- package/dist/ui/dropdown-menu.js +35 -0
- package/dist/ui/empty.js +17 -0
- package/dist/ui/farmer/div.js +38 -0
- package/dist/ui/farmer/variants.js +314 -0
- package/dist/ui/field.js +224 -0
- package/dist/ui/filters.js +1524 -0
- package/dist/ui/image.js +88 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +57 -8502
- package/dist/ui/input-group.js +20 -0
- package/dist/ui/input-otp.js +83 -0
- package/dist/ui/input.js +7 -0
- package/dist/ui/item.js +200 -0
- package/dist/ui/jelly.js +30 -0
- package/dist/ui/kbd.js +9 -0
- package/dist/ui/label.js +7 -0
- package/dist/ui/message-scroller.js +122 -0
- package/dist/ui/message.js +93 -0
- package/dist/ui/numberstepper.js +416 -0
- package/dist/ui/otp.js +403 -0
- package/dist/ui/popover.js +83 -0
- package/dist/ui/qr-code.js +124 -0
- package/dist/ui/quantity.js +48 -0
- package/dist/ui/radio-group.js +42 -0
- package/dist/ui/resizable.js +52 -0
- package/dist/ui/scroll-area.js +9 -0
- package/dist/ui/select.js +194 -0
- package/dist/ui/separator.js +7 -0
- package/dist/ui/skeleton.js +25 -0
- package/dist/ui/sonner.js +22 -0
- package/dist/ui/sortable.js +503 -0
- package/dist/ui/swipe-actions.js +45 -0
- package/dist/ui/switch.js +34 -0
- package/dist/ui/textarea.js +7 -0
- package/dist/ui/theme-toggle.js +141 -0
- package/dist/ui/tooltip.js +13 -0
- package/package.json +1 -1
- package/dist/chunk-4KFB6AJH.js +0 -1330
- /package/dist/{chunk-FYFBWCMJ.js → chunk-GBVAFFZR.js} +0 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/ui/sortable.tsx
|
|
4
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
|
+
import {
|
|
7
|
+
closestCenter,
|
|
8
|
+
closestCorners,
|
|
9
|
+
defaultDropAnimationSideEffects,
|
|
10
|
+
DndContext,
|
|
11
|
+
DragOverlay,
|
|
12
|
+
KeyboardSensor,
|
|
13
|
+
MouseSensor,
|
|
14
|
+
TouchSensor,
|
|
15
|
+
useSensor,
|
|
16
|
+
useSensors
|
|
17
|
+
} from "@dnd-kit/core";
|
|
18
|
+
import {
|
|
19
|
+
restrictToHorizontalAxis,
|
|
20
|
+
restrictToParentElement,
|
|
21
|
+
restrictToVerticalAxis
|
|
22
|
+
} from "@dnd-kit/modifiers";
|
|
23
|
+
import {
|
|
24
|
+
arrayMove,
|
|
25
|
+
horizontalListSortingStrategy,
|
|
26
|
+
SortableContext,
|
|
27
|
+
sortableKeyboardCoordinates,
|
|
28
|
+
useSortable,
|
|
29
|
+
verticalListSortingStrategy
|
|
30
|
+
} from "@dnd-kit/sortable";
|
|
31
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
32
|
+
import * as React3 from "react";
|
|
33
|
+
import * as ReactDOM from "react-dom";
|
|
34
|
+
|
|
35
|
+
// src/hooks/use-isomorphic-layout-effect.ts
|
|
36
|
+
import * as React from "react";
|
|
37
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
38
|
+
|
|
39
|
+
// src/lib/compose-refs.ts
|
|
40
|
+
import * as React2 from "react";
|
|
41
|
+
function setRef(ref, value) {
|
|
42
|
+
if (typeof ref === "function") {
|
|
43
|
+
return ref(value);
|
|
44
|
+
}
|
|
45
|
+
if (ref !== null && ref !== void 0) {
|
|
46
|
+
ref.current = value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function composeRefs(...refs) {
|
|
50
|
+
return (node) => {
|
|
51
|
+
let hasCleanup = false;
|
|
52
|
+
const cleanups = refs.map((ref) => {
|
|
53
|
+
const cleanup = setRef(ref, node);
|
|
54
|
+
if (!hasCleanup && typeof cleanup === "function") {
|
|
55
|
+
hasCleanup = true;
|
|
56
|
+
}
|
|
57
|
+
return cleanup;
|
|
58
|
+
});
|
|
59
|
+
if (hasCleanup) {
|
|
60
|
+
return () => {
|
|
61
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
62
|
+
const cleanup = cleanups[i];
|
|
63
|
+
if (typeof cleanup === "function") {
|
|
64
|
+
cleanup();
|
|
65
|
+
} else {
|
|
66
|
+
setRef(refs[i], null);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function useComposedRefs(...refs) {
|
|
74
|
+
return React2.useCallback(composeRefs(...refs), refs);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/ui/sortable.tsx
|
|
78
|
+
import { cn } from "cn";
|
|
79
|
+
import { jsx } from "react/jsx-runtime";
|
|
80
|
+
var orientationConfig = {
|
|
81
|
+
vertical: {
|
|
82
|
+
modifiers: [restrictToVerticalAxis, restrictToParentElement],
|
|
83
|
+
strategy: verticalListSortingStrategy,
|
|
84
|
+
collisionDetection: closestCenter
|
|
85
|
+
},
|
|
86
|
+
horizontal: {
|
|
87
|
+
modifiers: [restrictToHorizontalAxis, restrictToParentElement],
|
|
88
|
+
strategy: horizontalListSortingStrategy,
|
|
89
|
+
collisionDetection: closestCenter
|
|
90
|
+
},
|
|
91
|
+
mixed: {
|
|
92
|
+
modifiers: [restrictToParentElement],
|
|
93
|
+
strategy: void 0,
|
|
94
|
+
collisionDetection: closestCorners
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var ROOT_NAME = "Sortable";
|
|
98
|
+
var CONTENT_NAME = "SortableContent";
|
|
99
|
+
var ITEM_NAME = "SortableItem";
|
|
100
|
+
var ITEM_HANDLE_NAME = "SortableItemHandle";
|
|
101
|
+
var OVERLAY_NAME = "SortableOverlay";
|
|
102
|
+
var SortableRootContext = React3.createContext(null);
|
|
103
|
+
function useSortableContext(consumerName) {
|
|
104
|
+
const context = React3.useContext(SortableRootContext);
|
|
105
|
+
if (!context) {
|
|
106
|
+
throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
|
|
107
|
+
}
|
|
108
|
+
return context;
|
|
109
|
+
}
|
|
110
|
+
function Sortable(props) {
|
|
111
|
+
const {
|
|
112
|
+
value,
|
|
113
|
+
onValueChange,
|
|
114
|
+
collisionDetection,
|
|
115
|
+
modifiers,
|
|
116
|
+
strategy,
|
|
117
|
+
onMove,
|
|
118
|
+
orientation = "vertical",
|
|
119
|
+
flatCursor = false,
|
|
120
|
+
getItemValue: getItemValueProp,
|
|
121
|
+
accessibility,
|
|
122
|
+
...sortableProps
|
|
123
|
+
} = props;
|
|
124
|
+
const id = React3.useId();
|
|
125
|
+
const [activeId, setActiveId] = React3.useState(null);
|
|
126
|
+
const sensors = useSensors(
|
|
127
|
+
useSensor(MouseSensor),
|
|
128
|
+
useSensor(TouchSensor),
|
|
129
|
+
useSensor(KeyboardSensor, {
|
|
130
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
131
|
+
})
|
|
132
|
+
);
|
|
133
|
+
const config = React3.useMemo(
|
|
134
|
+
() => orientationConfig[orientation],
|
|
135
|
+
[orientation]
|
|
136
|
+
);
|
|
137
|
+
const getItemValue = React3.useCallback(
|
|
138
|
+
(item) => {
|
|
139
|
+
if (typeof item === "object" && !getItemValueProp) {
|
|
140
|
+
throw new Error(
|
|
141
|
+
"`getItemValue` is required when using array of objects"
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
return getItemValueProp ? getItemValueProp(item) : item;
|
|
145
|
+
},
|
|
146
|
+
[getItemValueProp]
|
|
147
|
+
);
|
|
148
|
+
const items = React3.useMemo(() => {
|
|
149
|
+
return value.map((item) => getItemValue(item));
|
|
150
|
+
}, [value, getItemValue]);
|
|
151
|
+
const onDragStart = React3.useCallback(
|
|
152
|
+
(event) => {
|
|
153
|
+
sortableProps.onDragStart?.(event);
|
|
154
|
+
if (event.activatorEvent.defaultPrevented) return;
|
|
155
|
+
setActiveId(event.active.id);
|
|
156
|
+
},
|
|
157
|
+
[sortableProps.onDragStart]
|
|
158
|
+
);
|
|
159
|
+
const onDragEnd = React3.useCallback(
|
|
160
|
+
(event) => {
|
|
161
|
+
sortableProps.onDragEnd?.(event);
|
|
162
|
+
if (event.activatorEvent.defaultPrevented) return;
|
|
163
|
+
const { active, over } = event;
|
|
164
|
+
if (over && active.id !== over?.id) {
|
|
165
|
+
const activeIndex = value.findIndex(
|
|
166
|
+
(item) => getItemValue(item) === active.id
|
|
167
|
+
);
|
|
168
|
+
const overIndex = value.findIndex(
|
|
169
|
+
(item) => getItemValue(item) === over.id
|
|
170
|
+
);
|
|
171
|
+
if (onMove) {
|
|
172
|
+
onMove({ ...event, activeIndex, overIndex });
|
|
173
|
+
} else {
|
|
174
|
+
onValueChange?.(arrayMove(value, activeIndex, overIndex));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
setActiveId(null);
|
|
178
|
+
},
|
|
179
|
+
[value, onValueChange, onMove, getItemValue, sortableProps.onDragEnd]
|
|
180
|
+
);
|
|
181
|
+
const onDragCancel = React3.useCallback(
|
|
182
|
+
(event) => {
|
|
183
|
+
sortableProps.onDragCancel?.(event);
|
|
184
|
+
if (event.activatorEvent.defaultPrevented) return;
|
|
185
|
+
setActiveId(null);
|
|
186
|
+
},
|
|
187
|
+
[sortableProps.onDragCancel]
|
|
188
|
+
);
|
|
189
|
+
const announcements = React3.useMemo(
|
|
190
|
+
() => ({
|
|
191
|
+
onDragStart({ active }) {
|
|
192
|
+
const activeValue = active.id.toString();
|
|
193
|
+
return `Grabbed sortable item "${activeValue}". Current position is ${active.data.current?.sortable.index + 1} of ${value.length}. Use arrow keys to move, space to drop.`;
|
|
194
|
+
},
|
|
195
|
+
onDragOver({ active, over }) {
|
|
196
|
+
if (over) {
|
|
197
|
+
const overIndex = over.data.current?.sortable.index ?? 0;
|
|
198
|
+
const activeIndex = active.data.current?.sortable.index ?? 0;
|
|
199
|
+
const moveDirection = overIndex > activeIndex ? "down" : "up";
|
|
200
|
+
const activeValue = active.id.toString();
|
|
201
|
+
return `Sortable item "${activeValue}" moved ${moveDirection} to position ${overIndex + 1} of ${value.length}.`;
|
|
202
|
+
}
|
|
203
|
+
return "Sortable item is no longer over a droppable area. Press escape to cancel.";
|
|
204
|
+
},
|
|
205
|
+
onDragEnd({ active, over }) {
|
|
206
|
+
const activeValue = active.id.toString();
|
|
207
|
+
if (over) {
|
|
208
|
+
const overIndex = over.data.current?.sortable.index ?? 0;
|
|
209
|
+
return `Sortable item "${activeValue}" dropped at position ${overIndex + 1} of ${value.length}.`;
|
|
210
|
+
}
|
|
211
|
+
return `Sortable item "${activeValue}" dropped. No changes were made.`;
|
|
212
|
+
},
|
|
213
|
+
onDragCancel({ active }) {
|
|
214
|
+
const activeIndex = active.data.current?.sortable.index ?? 0;
|
|
215
|
+
const activeValue = active.id.toString();
|
|
216
|
+
return `Sorting cancelled. Sortable item "${activeValue}" returned to position ${activeIndex + 1} of ${value.length}.`;
|
|
217
|
+
},
|
|
218
|
+
onDragMove({ active, over }) {
|
|
219
|
+
if (over) {
|
|
220
|
+
const overIndex = over.data.current?.sortable.index ?? 0;
|
|
221
|
+
const activeIndex = active.data.current?.sortable.index ?? 0;
|
|
222
|
+
const moveDirection = overIndex > activeIndex ? "down" : "up";
|
|
223
|
+
const activeValue = active.id.toString();
|
|
224
|
+
return `Sortable item "${activeValue}" is moving ${moveDirection} to position ${overIndex + 1} of ${value.length}.`;
|
|
225
|
+
}
|
|
226
|
+
return "Sortable item is no longer over a droppable area. Press escape to cancel.";
|
|
227
|
+
}
|
|
228
|
+
}),
|
|
229
|
+
[value]
|
|
230
|
+
);
|
|
231
|
+
const screenReaderInstructions = React3.useMemo(
|
|
232
|
+
() => ({
|
|
233
|
+
draggable: `
|
|
234
|
+
To pick up a sortable item, press space or enter.
|
|
235
|
+
While dragging, use the ${orientation === "vertical" ? "up and down" : orientation === "horizontal" ? "left and right" : "arrow"} keys to move the item.
|
|
236
|
+
Press space or enter again to drop the item in its new position, or press escape to cancel.
|
|
237
|
+
`
|
|
238
|
+
}),
|
|
239
|
+
[orientation]
|
|
240
|
+
);
|
|
241
|
+
const contextValue = React3.useMemo(
|
|
242
|
+
() => ({
|
|
243
|
+
id,
|
|
244
|
+
items,
|
|
245
|
+
modifiers: modifiers ?? config.modifiers,
|
|
246
|
+
strategy: strategy ?? config.strategy,
|
|
247
|
+
activeId,
|
|
248
|
+
setActiveId,
|
|
249
|
+
getItemValue,
|
|
250
|
+
flatCursor
|
|
251
|
+
}),
|
|
252
|
+
[
|
|
253
|
+
id,
|
|
254
|
+
items,
|
|
255
|
+
modifiers,
|
|
256
|
+
strategy,
|
|
257
|
+
config.modifiers,
|
|
258
|
+
config.strategy,
|
|
259
|
+
activeId,
|
|
260
|
+
getItemValue,
|
|
261
|
+
flatCursor
|
|
262
|
+
]
|
|
263
|
+
);
|
|
264
|
+
return /* @__PURE__ */ jsx(
|
|
265
|
+
SortableRootContext.Provider,
|
|
266
|
+
{
|
|
267
|
+
value: contextValue,
|
|
268
|
+
children: /* @__PURE__ */ jsx(
|
|
269
|
+
DndContext,
|
|
270
|
+
{
|
|
271
|
+
collisionDetection: collisionDetection ?? config.collisionDetection,
|
|
272
|
+
modifiers: modifiers ?? config.modifiers,
|
|
273
|
+
sensors,
|
|
274
|
+
...sortableProps,
|
|
275
|
+
id,
|
|
276
|
+
onDragStart,
|
|
277
|
+
onDragEnd,
|
|
278
|
+
onDragCancel,
|
|
279
|
+
accessibility: {
|
|
280
|
+
announcements,
|
|
281
|
+
screenReaderInstructions,
|
|
282
|
+
...accessibility
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
var SortableContentContext = React3.createContext(false);
|
|
290
|
+
function SortableContent(props) {
|
|
291
|
+
const {
|
|
292
|
+
strategy: strategyProp,
|
|
293
|
+
withoutSlot,
|
|
294
|
+
children,
|
|
295
|
+
className,
|
|
296
|
+
render,
|
|
297
|
+
ref,
|
|
298
|
+
...contentProps
|
|
299
|
+
} = props;
|
|
300
|
+
const context = useSortableContext(CONTENT_NAME);
|
|
301
|
+
const element = useRender({
|
|
302
|
+
defaultTagName: "div",
|
|
303
|
+
props: mergeProps(
|
|
304
|
+
{
|
|
305
|
+
ref,
|
|
306
|
+
className,
|
|
307
|
+
children
|
|
308
|
+
},
|
|
309
|
+
contentProps
|
|
310
|
+
),
|
|
311
|
+
render,
|
|
312
|
+
state: {
|
|
313
|
+
slot: "sortable-content"
|
|
314
|
+
},
|
|
315
|
+
enabled: !withoutSlot
|
|
316
|
+
});
|
|
317
|
+
return /* @__PURE__ */ jsx(SortableContentContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
318
|
+
SortableContext,
|
|
319
|
+
{
|
|
320
|
+
items: context.items,
|
|
321
|
+
strategy: strategyProp ?? context.strategy,
|
|
322
|
+
children: withoutSlot ? children : element
|
|
323
|
+
}
|
|
324
|
+
) });
|
|
325
|
+
}
|
|
326
|
+
var SortableItemContext = React3.createContext(null);
|
|
327
|
+
function useSortableItemContext(consumerName) {
|
|
328
|
+
const context = React3.useContext(SortableItemContext);
|
|
329
|
+
if (!context) {
|
|
330
|
+
throw new Error(`\`${consumerName}\` must be used within \`${ITEM_NAME}\``);
|
|
331
|
+
}
|
|
332
|
+
return context;
|
|
333
|
+
}
|
|
334
|
+
function SortableItem(props) {
|
|
335
|
+
const {
|
|
336
|
+
value,
|
|
337
|
+
style,
|
|
338
|
+
asHandle,
|
|
339
|
+
disabled,
|
|
340
|
+
className,
|
|
341
|
+
render,
|
|
342
|
+
ref,
|
|
343
|
+
...itemProps
|
|
344
|
+
} = props;
|
|
345
|
+
const inSortableContent = React3.useContext(SortableContentContext);
|
|
346
|
+
const inSortableOverlay = React3.useContext(SortableOverlayContext);
|
|
347
|
+
if (!inSortableContent && !inSortableOverlay) {
|
|
348
|
+
throw new Error(
|
|
349
|
+
`\`${ITEM_NAME}\` must be used within \`${CONTENT_NAME}\` or \`${OVERLAY_NAME}\``
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
if (value === "") {
|
|
353
|
+
throw new Error(`\`${ITEM_NAME}\` value cannot be an empty string`);
|
|
354
|
+
}
|
|
355
|
+
const context = useSortableContext(ITEM_NAME);
|
|
356
|
+
const id = React3.useId();
|
|
357
|
+
const {
|
|
358
|
+
attributes,
|
|
359
|
+
listeners,
|
|
360
|
+
setNodeRef,
|
|
361
|
+
setActivatorNodeRef,
|
|
362
|
+
transform,
|
|
363
|
+
transition,
|
|
364
|
+
isDragging
|
|
365
|
+
} = useSortable({ id: value, disabled });
|
|
366
|
+
const onNodeRefChange = React3.useCallback(
|
|
367
|
+
(node) => {
|
|
368
|
+
if (disabled) return;
|
|
369
|
+
setNodeRef(node);
|
|
370
|
+
if (asHandle) setActivatorNodeRef(node);
|
|
371
|
+
},
|
|
372
|
+
[disabled, asHandle, setNodeRef, setActivatorNodeRef]
|
|
373
|
+
);
|
|
374
|
+
const composedRef = useComposedRefs(ref, onNodeRefChange);
|
|
375
|
+
const composedStyle = React3.useMemo(() => {
|
|
376
|
+
return {
|
|
377
|
+
transform: CSS.Translate.toString(transform),
|
|
378
|
+
transition,
|
|
379
|
+
...style
|
|
380
|
+
};
|
|
381
|
+
}, [transform, transition, style]);
|
|
382
|
+
const itemContext = React3.useMemo(
|
|
383
|
+
() => ({
|
|
384
|
+
id,
|
|
385
|
+
attributes,
|
|
386
|
+
listeners,
|
|
387
|
+
setActivatorNodeRef,
|
|
388
|
+
isDragging,
|
|
389
|
+
disabled
|
|
390
|
+
}),
|
|
391
|
+
[id, attributes, listeners, setActivatorNodeRef, isDragging, disabled]
|
|
392
|
+
);
|
|
393
|
+
const handleProps = asHandle && !disabled ? { ...attributes, ...listeners } : void 0;
|
|
394
|
+
const element = useRender({
|
|
395
|
+
defaultTagName: "div",
|
|
396
|
+
props: mergeProps(
|
|
397
|
+
{
|
|
398
|
+
id,
|
|
399
|
+
ref: composedRef,
|
|
400
|
+
style: composedStyle,
|
|
401
|
+
className: cn(
|
|
402
|
+
"focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-hidden",
|
|
403
|
+
{
|
|
404
|
+
"touch-none select-none": asHandle,
|
|
405
|
+
"cursor-default": context.flatCursor,
|
|
406
|
+
"data-dragging:cursor-grabbing": !context.flatCursor,
|
|
407
|
+
"cursor-grab": !isDragging && asHandle && !context.flatCursor,
|
|
408
|
+
"opacity-50": isDragging,
|
|
409
|
+
"pointer-events-none opacity-50": disabled
|
|
410
|
+
},
|
|
411
|
+
className
|
|
412
|
+
)
|
|
413
|
+
},
|
|
414
|
+
itemProps,
|
|
415
|
+
handleProps
|
|
416
|
+
),
|
|
417
|
+
render,
|
|
418
|
+
state: {
|
|
419
|
+
slot: "sortable-item",
|
|
420
|
+
...disabled && { disabled: "" },
|
|
421
|
+
...isDragging && { dragging: "" }
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
return /* @__PURE__ */ jsx(SortableItemContext.Provider, { value: itemContext, children: element });
|
|
425
|
+
}
|
|
426
|
+
function SortableItemHandle(props) {
|
|
427
|
+
const { disabled, className, render, ref, ...itemHandleProps } = props;
|
|
428
|
+
const context = useSortableContext(ITEM_HANDLE_NAME);
|
|
429
|
+
const itemContext = useSortableItemContext(ITEM_HANDLE_NAME);
|
|
430
|
+
const isDisabled = disabled ?? itemContext.disabled;
|
|
431
|
+
const { setActivatorNodeRef } = itemContext;
|
|
432
|
+
const onActivatorNodeRef = React3.useCallback(
|
|
433
|
+
(node) => {
|
|
434
|
+
if (isDisabled) return;
|
|
435
|
+
setActivatorNodeRef(node);
|
|
436
|
+
},
|
|
437
|
+
[isDisabled, setActivatorNodeRef]
|
|
438
|
+
);
|
|
439
|
+
const composedRef = useComposedRefs(ref, onActivatorNodeRef);
|
|
440
|
+
const handleProps = isDisabled ? void 0 : { ...itemContext.attributes, ...itemContext.listeners };
|
|
441
|
+
return useRender({
|
|
442
|
+
defaultTagName: "button",
|
|
443
|
+
props: mergeProps(
|
|
444
|
+
{
|
|
445
|
+
type: "button",
|
|
446
|
+
"aria-controls": itemContext.id,
|
|
447
|
+
ref: composedRef,
|
|
448
|
+
disabled: isDisabled,
|
|
449
|
+
className: cn(
|
|
450
|
+
"select-none disabled:pointer-events-none disabled:opacity-50",
|
|
451
|
+
context.flatCursor ? "cursor-default" : "cursor-grab data-dragging:cursor-grabbing",
|
|
452
|
+
className
|
|
453
|
+
)
|
|
454
|
+
},
|
|
455
|
+
itemHandleProps,
|
|
456
|
+
handleProps
|
|
457
|
+
),
|
|
458
|
+
render,
|
|
459
|
+
state: {
|
|
460
|
+
slot: "sortable-item-handle",
|
|
461
|
+
...isDisabled && { disabled: "" },
|
|
462
|
+
...itemContext.isDragging && { dragging: "" }
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
var SortableOverlayContext = React3.createContext(false);
|
|
467
|
+
var dropAnimation = {
|
|
468
|
+
sideEffects: defaultDropAnimationSideEffects({
|
|
469
|
+
styles: {
|
|
470
|
+
active: {
|
|
471
|
+
opacity: "0.4"
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
})
|
|
475
|
+
};
|
|
476
|
+
function SortableOverlay(props) {
|
|
477
|
+
const { container: containerProp, children, ...overlayProps } = props;
|
|
478
|
+
const context = useSortableContext(OVERLAY_NAME);
|
|
479
|
+
const [mounted, setMounted] = React3.useState(false);
|
|
480
|
+
useIsomorphicLayoutEffect(() => setMounted(true), []);
|
|
481
|
+
const container = containerProp ?? (mounted ? globalThis.document?.body : null);
|
|
482
|
+
if (!container) return null;
|
|
483
|
+
return ReactDOM.createPortal(
|
|
484
|
+
/* @__PURE__ */ jsx(
|
|
485
|
+
DragOverlay,
|
|
486
|
+
{
|
|
487
|
+
dropAnimation,
|
|
488
|
+
modifiers: context.modifiers,
|
|
489
|
+
className: cn(!context.flatCursor && "cursor-grabbing"),
|
|
490
|
+
...overlayProps,
|
|
491
|
+
children: /* @__PURE__ */ jsx(SortableOverlayContext.Provider, { value: true, children: context.activeId ? typeof children === "function" ? children({ value: context.activeId }) : children : null })
|
|
492
|
+
}
|
|
493
|
+
),
|
|
494
|
+
container
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
export {
|
|
498
|
+
Sortable,
|
|
499
|
+
SortableContent,
|
|
500
|
+
SortableItem,
|
|
501
|
+
SortableItemHandle,
|
|
502
|
+
SortableOverlay
|
|
503
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/ui/swipe-actions.tsx
|
|
4
|
+
import * as SwipeActionsPrimitive from "@ncdai/react-swipe-actions";
|
|
5
|
+
import { cn } from "cn";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var SwipeRoot2 = SwipeActionsPrimitive.SwipeRoot;
|
|
8
|
+
var SwipeItem2 = SwipeActionsPrimitive.SwipeItem;
|
|
9
|
+
var SwipeActions2 = SwipeActionsPrimitive.SwipeActions;
|
|
10
|
+
function SwipeAction2({
|
|
11
|
+
className,
|
|
12
|
+
children,
|
|
13
|
+
...props
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
SwipeActionsPrimitive.SwipeAction,
|
|
17
|
+
{
|
|
18
|
+
className: cn(
|
|
19
|
+
"bg-secondary text-xs font-medium whitespace-nowrap text-secondary-foreground select-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-foreground data-armed:brightness-90 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
20
|
+
className
|
|
21
|
+
),
|
|
22
|
+
...props,
|
|
23
|
+
children: /* @__PURE__ */ jsx(SwipeActionsPrimitive.SwipeActionContent, { className: "min-w-20 flex-col items-center justify-center gap-1.5 px-4", children })
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
function SwipeContent2({
|
|
28
|
+
className,
|
|
29
|
+
...props
|
|
30
|
+
}) {
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
SwipeActionsPrimitive.SwipeContent,
|
|
33
|
+
{
|
|
34
|
+
className: cn("data-dragging:cursor-grabbing", className),
|
|
35
|
+
...props
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
SwipeAction2 as SwipeAction,
|
|
41
|
+
SwipeActions2 as SwipeActions,
|
|
42
|
+
SwipeContent2 as SwipeContent,
|
|
43
|
+
SwipeItem2 as SwipeItem,
|
|
44
|
+
SwipeRoot2 as SwipeRoot
|
|
45
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/ui/switch.tsx
|
|
4
|
+
import { Switch as SwitchPrimitive } from "@base-ui/react/switch";
|
|
5
|
+
import { cn } from "cn";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
function Switch({
|
|
8
|
+
className,
|
|
9
|
+
size = "default",
|
|
10
|
+
...props
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
SwitchPrimitive.Root,
|
|
14
|
+
{
|
|
15
|
+
"data-slot": "switch",
|
|
16
|
+
"data-size": size,
|
|
17
|
+
className: cn(
|
|
18
|
+
"peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-[background-color,border-color,box-shadow,opacity] duration-150 ease-out outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 motion-reduce:transition-none dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
19
|
+
className
|
|
20
|
+
),
|
|
21
|
+
...props,
|
|
22
|
+
children: /* @__PURE__ */ jsx(
|
|
23
|
+
SwitchPrimitive.Thumb,
|
|
24
|
+
{
|
|
25
|
+
"data-slot": "switch-thumb",
|
|
26
|
+
className: "pointer-events-none block rounded-full bg-background ring-0 transition-transform duration-150 ease-out group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 motion-reduce:transition-none group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
Switch
|
|
34
|
+
};
|