@stevederico/skateboard-ui 3.0.2 → 3.6.0
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/App.jsx +13 -13
- package/CHANGELOG.md +64 -0
- package/README.md +59 -65
- package/components/AuthOverlay.jsx +4 -4
- package/components/ProtectedRoute.jsx +1 -1
- package/components/ThemeToggle.jsx +1 -1
- package/components/UpgradeSheet.jsx +2 -2
- package/{core → components/core}/DynamicIcon.jsx +1 -1
- package/{layout → components/layout}/Header.jsx +4 -4
- package/{layout → components/layout}/Layout.jsx +1 -1
- package/{layout → components/layout}/Sidebar.jsx +2 -2
- package/{layout → components/layout}/TabBar.jsx +1 -1
- package/{views → components/views}/LandingView.jsx +5 -5
- package/{views → components/views}/NotFound.jsx +2 -2
- package/{views → components/views}/PaymentView.jsx +1 -1
- package/{views → components/views}/SettingsView.jsx +6 -6
- package/{views → components/views}/SignInView.jsx +6 -6
- package/{views → components/views}/SignOutView.jsx +1 -1
- package/{views → components/views}/SignUpView.jsx +6 -6
- package/{views → components/views}/TextView.jsx +3 -3
- package/hooks/useAuthGate.js +1 -1
- package/index.js +1 -1
- package/package.json +32 -50
- package/shadcn/lib/base-ui/LICENSE +21 -0
- package/shadcn/lib/base-ui/_chunk-01rqe37g.js +70 -0
- package/shadcn/lib/base-ui/_chunk-0h5sskyw.js +347 -0
- package/shadcn/lib/base-ui/_chunk-0xhx4g7r.js +57 -0
- package/shadcn/lib/base-ui/_chunk-1e6khrvm.js +218 -0
- package/shadcn/lib/base-ui/_chunk-1s41sngz.js +302 -0
- package/shadcn/lib/base-ui/_chunk-20rtfsz9.js +23 -0
- package/shadcn/lib/base-ui/_chunk-2tyt8f8r.js +6034 -0
- package/shadcn/lib/base-ui/_chunk-3f31ka8n.js +11 -0
- package/shadcn/lib/base-ui/_chunk-3h6zpchb.js +89 -0
- package/shadcn/lib/base-ui/_chunk-4s0k3h7t.js +114 -0
- package/shadcn/lib/base-ui/_chunk-502wngfc.js +598 -0
- package/shadcn/lib/base-ui/_chunk-536jvgeq.js +68 -0
- package/shadcn/lib/base-ui/_chunk-611pz5sm.js +10 -0
- package/shadcn/lib/base-ui/_chunk-65zw5gs2.js +15 -0
- package/shadcn/lib/base-ui/_chunk-6b17g8t7.js +34 -0
- package/shadcn/lib/base-ui/_chunk-6xevjepc.js +15 -0
- package/shadcn/lib/base-ui/_chunk-71zm6zgv.js +16 -0
- package/shadcn/lib/base-ui/_chunk-7fmjymvh.js +32 -0
- package/shadcn/lib/base-ui/_chunk-7jjzay8b.js +176 -0
- package/shadcn/lib/base-ui/_chunk-7v1t86x1.js +43 -0
- package/shadcn/lib/base-ui/_chunk-85vrgzwr.js +227 -0
- package/shadcn/lib/base-ui/_chunk-8jz3hb7q.js +9 -0
- package/shadcn/lib/base-ui/_chunk-8kh3xk78.js +35 -0
- package/shadcn/lib/base-ui/_chunk-97tas84n.js +67 -0
- package/shadcn/lib/base-ui/_chunk-9nyxkvte.js +13 -0
- package/shadcn/lib/base-ui/_chunk-a8fwg9d0.js +52 -0
- package/shadcn/lib/base-ui/_chunk-agc6ew3g.js +29 -0
- package/shadcn/lib/base-ui/_chunk-aqwsk46c.js +64 -0
- package/shadcn/lib/base-ui/_chunk-atd5kq5q.js +803 -0
- package/shadcn/lib/base-ui/_chunk-atnkefgd.js +104 -0
- package/shadcn/lib/base-ui/_chunk-b40erthe.js +7 -0
- package/shadcn/lib/base-ui/_chunk-b5jsqt97.js +50 -0
- package/shadcn/lib/base-ui/_chunk-bk7n9s9e.js +15 -0
- package/shadcn/lib/base-ui/_chunk-c3572b5x.js +19 -0
- package/shadcn/lib/base-ui/_chunk-cwr896nf.js +25 -0
- package/shadcn/lib/base-ui/_chunk-drfb9kp2.js +27 -0
- package/shadcn/lib/base-ui/_chunk-ds8fnpjj.js +0 -0
- package/shadcn/lib/base-ui/_chunk-ek863ta9.js +82 -0
- package/shadcn/lib/base-ui/_chunk-f09cp81f.js +12 -0
- package/shadcn/lib/base-ui/_chunk-f5d01bp9.js +0 -0
- package/shadcn/lib/base-ui/_chunk-f9tgee1q.js +21 -0
- package/shadcn/lib/base-ui/_chunk-fch5cba8.js +84 -0
- package/shadcn/lib/base-ui/_chunk-gfce3j3z.js +18 -0
- package/shadcn/lib/base-ui/_chunk-ha06w2pp.js +2391 -0
- package/shadcn/lib/base-ui/_chunk-hzgetm70.js +23 -0
- package/shadcn/lib/base-ui/_chunk-j0eqdjta.js +39 -0
- package/shadcn/lib/base-ui/_chunk-k1e5fvcj.js +48 -0
- package/shadcn/lib/base-ui/_chunk-k4mc2kan.js +81 -0
- package/shadcn/lib/base-ui/_chunk-kfz96xv1.js +128 -0
- package/shadcn/lib/base-ui/_chunk-m45547cc.js +15 -0
- package/shadcn/lib/base-ui/_chunk-mbn76q14.js +184 -0
- package/shadcn/lib/base-ui/_chunk-mvv30fkv.js +9 -0
- package/shadcn/lib/base-ui/_chunk-mznt6ktj.js +33 -0
- package/shadcn/lib/base-ui/_chunk-n7dnqnbw.js +7 -0
- package/shadcn/lib/base-ui/_chunk-nya71ccw.js +546 -0
- package/shadcn/lib/base-ui/_chunk-p6qynd6r.js +146 -0
- package/shadcn/lib/base-ui/_chunk-q3nee19r.js +323 -0
- package/shadcn/lib/base-ui/_chunk-q7yw9mz4.js +385 -0
- package/shadcn/lib/base-ui/_chunk-qce0xt57.js +107 -0
- package/shadcn/lib/base-ui/_chunk-qgzhcjsj.js +14 -0
- package/shadcn/lib/base-ui/_chunk-qt6r015s.js +38 -0
- package/shadcn/lib/base-ui/_chunk-r0vsdknk.js +4 -0
- package/shadcn/lib/base-ui/_chunk-sx6vkz01.js +150 -0
- package/shadcn/lib/base-ui/_chunk-szcr6mhk.js +6 -0
- package/shadcn/lib/base-ui/_chunk-t7j3rbpv.js +67 -0
- package/shadcn/lib/base-ui/_chunk-tmfmrzwe.js +39 -0
- package/shadcn/lib/base-ui/_chunk-v92ycsfj.js +9 -0
- package/shadcn/lib/base-ui/_chunk-vdc01ss3.js +6 -0
- package/shadcn/lib/base-ui/_chunk-vjbnhhg1.js +26 -0
- package/shadcn/lib/base-ui/_chunk-w68yxg9d.js +21 -0
- package/shadcn/lib/base-ui/_chunk-wana68v3.js +477 -0
- package/shadcn/lib/base-ui/_chunk-wtw745qd.js +12 -0
- package/shadcn/lib/base-ui/_chunk-xb7ph1ka.js +6 -0
- package/shadcn/lib/base-ui/_chunk-xfagb0fq.js +28 -0
- package/shadcn/lib/base-ui/_chunk-xxhqanfd.js +16 -0
- package/shadcn/lib/base-ui/_chunk-y887e46p.js +15 -0
- package/shadcn/lib/base-ui/_chunk-ymj1dpqg.js +14 -0
- package/shadcn/lib/base-ui/accordion.js +650 -0
- package/shadcn/lib/base-ui/alert-dialog.js +138 -0
- package/shadcn/lib/base-ui/avatar.js +235 -0
- package/shadcn/lib/base-ui/button.js +52 -0
- package/shadcn/lib/base-ui/checkbox.js +454 -0
- package/shadcn/lib/base-ui/collapsible.js +283 -0
- package/shadcn/lib/base-ui/context-menu.js +324 -0
- package/shadcn/lib/base-ui/dialog.js +71 -0
- package/shadcn/lib/base-ui/input.js +1028 -0
- package/shadcn/lib/base-ui/menu.js +61 -0
- package/shadcn/lib/base-ui/menubar.js +157 -0
- package/shadcn/lib/base-ui/merge-props.js +15 -0
- package/shadcn/lib/base-ui/navigation-menu.js +1854 -0
- package/shadcn/lib/base-ui/popover.js +1090 -0
- package/shadcn/lib/base-ui/preview-card.js +709 -0
- package/shadcn/lib/base-ui/progress.js +278 -0
- package/shadcn/lib/base-ui/radio-group.js +247 -0
- package/shadcn/lib/base-ui/radio.js +382 -0
- package/shadcn/lib/base-ui/scroll-area.js +1061 -0
- package/shadcn/lib/base-ui/select.js +2438 -0
- package/shadcn/lib/base-ui/separator.js +11 -0
- package/shadcn/lib/base-ui/slider.js +1595 -0
- package/shadcn/lib/base-ui/switch.js +333 -0
- package/shadcn/lib/base-ui/tabs.js +892 -0
- package/shadcn/lib/base-ui/toggle-group.js +152 -0
- package/shadcn/lib/base-ui/toggle.js +133 -0
- package/shadcn/lib/base-ui/tooltip.js +791 -0
- package/shadcn/lib/base-ui/use-render.js +15 -0
- package/shadcn/lib/tailwind-merge.js +3312 -0
- package/shadcn/lib/utils.js +1 -1
- package/shadcn/ui/accordion.jsx +1 -1
- package/shadcn/ui/alert-dialog.jsx +1 -1
- package/shadcn/ui/avatar.jsx +1 -1
- package/shadcn/ui/badge.jsx +2 -2
- package/shadcn/ui/breadcrumb.jsx +2 -2
- package/shadcn/ui/button-group.jsx +2 -2
- package/shadcn/ui/button.jsx +1 -1
- package/shadcn/ui/calendar.jsx +1 -1
- package/shadcn/ui/checkbox.jsx +1 -1
- package/shadcn/ui/collapsible.jsx +1 -1
- package/shadcn/ui/command.jsx +1 -1
- package/shadcn/ui/context-menu.jsx +1 -1
- package/shadcn/ui/dialog.jsx +1 -1
- package/shadcn/ui/drawer.jsx +176 -74
- package/shadcn/ui/dropdown-menu.jsx +1 -1
- package/shadcn/ui/hover-card.jsx +1 -1
- package/shadcn/ui/input.jsx +1 -1
- package/shadcn/ui/item.jsx +2 -2
- package/shadcn/ui/menubar.jsx +2 -2
- package/shadcn/ui/navigation-menu.jsx +1 -1
- package/shadcn/ui/popover.jsx +1 -1
- package/shadcn/ui/progress.jsx +1 -1
- package/shadcn/ui/radio-group.jsx +2 -2
- package/shadcn/ui/scroll-area.jsx +1 -1
- package/shadcn/ui/select.jsx +1 -1
- package/shadcn/ui/separator.jsx +1 -1
- package/shadcn/ui/sheet.jsx +1 -1
- package/shadcn/ui/sidebar.jsx +3 -3
- package/shadcn/ui/slider.jsx +1 -1
- package/shadcn/ui/switch.jsx +1 -1
- package/shadcn/ui/tabs.jsx +1 -1
- package/shadcn/ui/toggle-group.jsx +2 -2
- package/shadcn/ui/toggle.jsx +1 -1
- package/shadcn/ui/tooltip.jsx +1 -1
- package/styles.css +31 -0
- package/MIGRATION.md +0 -230
- package/shadcn/ui/carousel.jsx +0 -195
- package/shadcn/ui/chart.jsx +0 -312
- package/shadcn/ui/resizable.jsx +0 -47
- /package/{core → components/core}/Calendar.jsx +0 -0
- /package/{core → components/core}/Command.jsx +0 -0
- /package/{core → components/core}/Context.jsx +0 -0
- /package/{core → components/core}/ThemeProvider.jsx +0 -0
- /package/{core → components/core}/Utilities.js +0 -0
package/MIGRATION.md
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
# Migration Guide
|
|
2
|
-
|
|
3
|
-
## Upgrading from 1.4.x to 2.0.x
|
|
4
|
-
|
|
5
|
-
### Breaking Changes
|
|
6
|
-
|
|
7
|
-
#### 1. `noProtectedRoutes` renamed to `authOverlay`
|
|
8
|
-
|
|
9
|
-
```diff
|
|
10
|
-
const constants = {
|
|
11
|
-
- noProtectedRoutes: true,
|
|
12
|
-
+ authOverlay: true,
|
|
13
|
-
};
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
If you were using `noProtectedRoutes` to allow unauthenticated access to `/app` routes, rename it to `authOverlay`.
|
|
17
|
-
|
|
18
|
-
#### 2. `Toast` replaced by Sonner `Toaster`
|
|
19
|
-
|
|
20
|
-
If you imported `Toast` directly:
|
|
21
|
-
|
|
22
|
-
```diff
|
|
23
|
-
- import Toast from '@stevederico/skateboard-ui/Toast';
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Remove it. `createSkateboardApp` now renders `<Toaster />` from [sonner](https://sonner.emilkowal.dev/) automatically. Use `toast()` from sonner directly:
|
|
27
|
-
|
|
28
|
-
```javascript
|
|
29
|
-
import { toast } from 'sonner';
|
|
30
|
-
|
|
31
|
-
toast.success('Saved!');
|
|
32
|
-
toast.error('Something went wrong');
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
#### 3. `SkeletonLoader` removed
|
|
36
|
-
|
|
37
|
-
```diff
|
|
38
|
-
- import SkeletonLoader from '@stevederico/skateboard-ui/SkeletonLoader';
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Use the shadcn `Skeleton` component instead:
|
|
42
|
-
|
|
43
|
-
```javascript
|
|
44
|
-
import { Skeleton } from '@stevederico/skateboard-ui/shadcn/ui/skeleton';
|
|
45
|
-
|
|
46
|
-
<Skeleton className="h-4 w-[200px]" />
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
#### 4. `AppSidebar` renamed to `Sidebar`
|
|
50
|
-
|
|
51
|
-
```diff
|
|
52
|
-
- import AppSidebar from '@stevederico/skateboard-ui/AppSidebar';
|
|
53
|
-
+ import Sidebar from '@stevederico/skateboard-ui/Sidebar';
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Most apps don't import this directly (Layout handles it), but update if you do.
|
|
57
|
-
|
|
58
|
-
#### 5. `LandingViewSimple` removed
|
|
59
|
-
|
|
60
|
-
```diff
|
|
61
|
-
- import LandingViewSimple from '@stevederico/skateboard-ui/LandingViewSimple';
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Use the `landingPage` parameter on `createSkateboardApp` to provide a custom landing page instead:
|
|
65
|
-
|
|
66
|
-
```javascript
|
|
67
|
-
createSkateboardApp({
|
|
68
|
-
constants,
|
|
69
|
-
appRoutes,
|
|
70
|
-
landingPage: <MyCustomLanding />,
|
|
71
|
-
});
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### New Features
|
|
75
|
-
|
|
76
|
-
#### AuthOverlay and useAuthGate (1.5.0+)
|
|
77
|
-
|
|
78
|
-
Gate actions behind authentication without redirecting:
|
|
79
|
-
|
|
80
|
-
```javascript
|
|
81
|
-
import { useAuthGate } from '@stevederico/skateboard-ui/useAuthGate';
|
|
82
|
-
|
|
83
|
-
function SaveButton() {
|
|
84
|
-
const requireAuth = useAuthGate();
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<button onClick={() => requireAuth(() => saveThing())}>
|
|
88
|
-
Save
|
|
89
|
-
</button>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Enable by setting `authOverlay: true` in constants. The overlay renders automatically.
|
|
95
|
-
|
|
96
|
-
#### Custom Landing Page (1.4.1+)
|
|
97
|
-
|
|
98
|
-
```javascript
|
|
99
|
-
createSkateboardApp({
|
|
100
|
-
constants,
|
|
101
|
-
appRoutes,
|
|
102
|
-
landingPage: <MyLandingPage />,
|
|
103
|
-
});
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
#### Sidebar Visibility Control (1.2.5+)
|
|
107
|
-
|
|
108
|
-
```javascript
|
|
109
|
-
import { hideSidebar, showSidebar, hideTabBar, showTabBar } from '@stevederico/skateboard-ui/Utilities';
|
|
110
|
-
|
|
111
|
-
hideSidebar();
|
|
112
|
-
showTabBar();
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Or via constants:
|
|
116
|
-
|
|
117
|
-
```javascript
|
|
118
|
-
const constants = {
|
|
119
|
-
hideSidebar: true,
|
|
120
|
-
hideTabBar: true,
|
|
121
|
-
};
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### Full Upgrade Steps
|
|
125
|
-
|
|
126
|
-
1. Update the package:
|
|
127
|
-
```bash
|
|
128
|
-
deno install npm:@stevederico/skateboard-ui@latest
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
2. Search your codebase for removed imports:
|
|
132
|
-
```
|
|
133
|
-
Toast, SkeletonLoader, AppSidebar, LandingViewSimple, noProtectedRoutes
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
3. Replace any direct `Toast` usage with `sonner`:
|
|
137
|
-
```javascript
|
|
138
|
-
import { toast } from 'sonner';
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
4. Replace `SkeletonLoader` with shadcn `Skeleton`.
|
|
142
|
-
|
|
143
|
-
5. Rename `noProtectedRoutes` to `authOverlay` in your constants.
|
|
144
|
-
|
|
145
|
-
6. Run the app and verify routing, auth, sidebar, and toasts.
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## Upgrading from 2.0.x to 2.1.x+
|
|
150
|
-
|
|
151
|
-
### No Breaking Changes
|
|
152
|
-
|
|
153
|
-
All consumer import paths are unchanged. This release reorganized the internal file structure but the `exports` map in `package.json` keeps every public import stable:
|
|
154
|
-
|
|
155
|
-
```javascript
|
|
156
|
-
// These all still work exactly the same
|
|
157
|
-
import { createSkateboardApp } from '@stevederico/skateboard-ui/App';
|
|
158
|
-
import { getState } from '@stevederico/skateboard-ui/Context';
|
|
159
|
-
import { apiRequest } from '@stevederico/skateboard-ui/Utilities';
|
|
160
|
-
import Layout from '@stevederico/skateboard-ui/Layout';
|
|
161
|
-
import Sidebar from '@stevederico/skateboard-ui/Sidebar';
|
|
162
|
-
import { Button } from '@stevederico/skateboard-ui/shadcn/ui/button';
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### What Changed Internally
|
|
166
|
-
|
|
167
|
-
Files were reorganized into folders:
|
|
168
|
-
|
|
169
|
-
| Before (2.0.x) | After (2.1.x+) |
|
|
170
|
-
|-----------------|-----------------|
|
|
171
|
-
| `Context.jsx` | `core/Context.jsx` |
|
|
172
|
-
| `Utilities.js` | `core/Utilities.js` |
|
|
173
|
-
| `DynamicIcon.jsx` | `core/DynamicIcon.jsx` |
|
|
174
|
-
| `Layout.jsx` | `layout/Layout.jsx` |
|
|
175
|
-
| `Sidebar.jsx` | `layout/Sidebar.jsx` |
|
|
176
|
-
| `TabBar.jsx` | `layout/TabBar.jsx` |
|
|
177
|
-
| `Header.jsx` | `layout/Header.jsx` |
|
|
178
|
-
| `LandingView.jsx` | `views/LandingView.jsx` |
|
|
179
|
-
| `SignInView.jsx` | `views/SignInView.jsx` |
|
|
180
|
-
| `SignUpView.jsx` | `views/SignUpView.jsx` |
|
|
181
|
-
| `SignOutView.jsx` | `views/SignOutView.jsx` |
|
|
182
|
-
| `SettingsView.jsx` | `views/SettingsView.jsx` |
|
|
183
|
-
| `PaymentView.jsx` | `views/PaymentView.jsx` |
|
|
184
|
-
| `TextView.jsx` | `views/TextView.jsx` |
|
|
185
|
-
| `NotFound.jsx` | `views/NotFound.jsx` |
|
|
186
|
-
| `ThemeToggle.jsx` | `components/ThemeToggle.jsx` |
|
|
187
|
-
| `Sheet.jsx` | `components/Sheet.jsx` |
|
|
188
|
-
| `UpgradeSheet.jsx` | `components/UpgradeSheet.jsx` |
|
|
189
|
-
| `ErrorBoundary.jsx` | `components/ErrorBoundary.jsx` |
|
|
190
|
-
| `AuthOverlay.jsx` | `components/AuthOverlay.jsx` |
|
|
191
|
-
| `ProtectedRoute.jsx` | `components/ProtectedRoute.jsx` |
|
|
192
|
-
| `useAuthGate.js` | `hooks/useAuthGate.js` |
|
|
193
|
-
|
|
194
|
-
### Cleanup
|
|
195
|
-
|
|
196
|
-
- `AppSidebar.jsx` deleted (was dead code since 2.1.0)
|
|
197
|
-
- `LandingViewSimple` export removed (file never existed on disk)
|
|
198
|
-
|
|
199
|
-
### New: View Overrides (2.1.x+)
|
|
200
|
-
|
|
201
|
-
Override built-in views without forking:
|
|
202
|
-
|
|
203
|
-
```javascript
|
|
204
|
-
createSkateboardApp({
|
|
205
|
-
constants,
|
|
206
|
-
appRoutes,
|
|
207
|
-
overrides: {
|
|
208
|
-
settings: MySettingsView,
|
|
209
|
-
signIn: MySignInView,
|
|
210
|
-
signUp: MySignUpView,
|
|
211
|
-
signOut: MySignOutView,
|
|
212
|
-
payment: MyPaymentView,
|
|
213
|
-
notFound: MyNotFoundView,
|
|
214
|
-
layout: MyLayout,
|
|
215
|
-
},
|
|
216
|
-
});
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
### Upgrade Steps
|
|
220
|
-
|
|
221
|
-
1. Update the package:
|
|
222
|
-
```bash
|
|
223
|
-
deno install npm:@stevederico/skateboard-ui@latest
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
2. No code changes required. All imports resolve the same way.
|
|
227
|
-
|
|
228
|
-
3. If you were importing `LandingViewSimple`, it was already broken (file didn't exist). Remove the import.
|
|
229
|
-
|
|
230
|
-
4. Run the app and confirm everything works.
|
package/shadcn/ui/carousel.jsx
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import * as React from "react"
|
|
3
|
-
import useEmblaCarousel from "embla-carousel-react";
|
|
4
|
-
|
|
5
|
-
import { cn } from "../lib/utils.js"
|
|
6
|
-
import { Button } from "./button.jsx"
|
|
7
|
-
import { ChevronLeftIcon, ChevronRightIcon } from "../../icons"
|
|
8
|
-
|
|
9
|
-
const CarouselContext = React.createContext(null)
|
|
10
|
-
|
|
11
|
-
function useCarousel() {
|
|
12
|
-
const context = React.useContext(CarouselContext)
|
|
13
|
-
|
|
14
|
-
if (!context) {
|
|
15
|
-
throw new Error("useCarousel must be used within a <Carousel />")
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return context
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function Carousel({
|
|
22
|
-
orientation = "horizontal",
|
|
23
|
-
opts,
|
|
24
|
-
setApi,
|
|
25
|
-
plugins,
|
|
26
|
-
className,
|
|
27
|
-
children,
|
|
28
|
-
...props
|
|
29
|
-
}) {
|
|
30
|
-
const [carouselRef, api] = useEmblaCarousel({
|
|
31
|
-
...opts,
|
|
32
|
-
axis: orientation === "horizontal" ? "x" : "y",
|
|
33
|
-
}, plugins)
|
|
34
|
-
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
|
35
|
-
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
|
36
|
-
|
|
37
|
-
const onSelect = React.useCallback((api) => {
|
|
38
|
-
if (!api) return
|
|
39
|
-
setCanScrollPrev(api.canScrollPrev())
|
|
40
|
-
setCanScrollNext(api.canScrollNext())
|
|
41
|
-
}, [])
|
|
42
|
-
|
|
43
|
-
const scrollPrev = React.useCallback(() => {
|
|
44
|
-
api?.scrollPrev()
|
|
45
|
-
}, [api])
|
|
46
|
-
|
|
47
|
-
const scrollNext = React.useCallback(() => {
|
|
48
|
-
api?.scrollNext()
|
|
49
|
-
}, [api])
|
|
50
|
-
|
|
51
|
-
const handleKeyDown = React.useCallback((event) => {
|
|
52
|
-
if (event.key === "ArrowLeft") {
|
|
53
|
-
event.preventDefault()
|
|
54
|
-
scrollPrev()
|
|
55
|
-
} else if (event.key === "ArrowRight") {
|
|
56
|
-
event.preventDefault()
|
|
57
|
-
scrollNext()
|
|
58
|
-
}
|
|
59
|
-
}, [scrollPrev, scrollNext])
|
|
60
|
-
|
|
61
|
-
React.useEffect(() => {
|
|
62
|
-
if (!api || !setApi) return
|
|
63
|
-
setApi(api)
|
|
64
|
-
}, [api, setApi])
|
|
65
|
-
|
|
66
|
-
React.useEffect(() => {
|
|
67
|
-
if (!api) return
|
|
68
|
-
onSelect(api)
|
|
69
|
-
api.on("reInit", onSelect)
|
|
70
|
-
api.on("select", onSelect)
|
|
71
|
-
|
|
72
|
-
return () => {
|
|
73
|
-
api?.off("select", onSelect)
|
|
74
|
-
};
|
|
75
|
-
}, [api, onSelect])
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<CarouselContext.Provider
|
|
79
|
-
value={{
|
|
80
|
-
carouselRef,
|
|
81
|
-
api: api,
|
|
82
|
-
opts,
|
|
83
|
-
orientation:
|
|
84
|
-
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
85
|
-
scrollPrev,
|
|
86
|
-
scrollNext,
|
|
87
|
-
canScrollPrev,
|
|
88
|
-
canScrollNext,
|
|
89
|
-
}}>
|
|
90
|
-
<div
|
|
91
|
-
onKeyDownCapture={handleKeyDown}
|
|
92
|
-
className={cn("relative", className)}
|
|
93
|
-
role="region"
|
|
94
|
-
aria-roledescription="carousel"
|
|
95
|
-
data-slot="carousel"
|
|
96
|
-
{...props}>
|
|
97
|
-
{children}
|
|
98
|
-
</div>
|
|
99
|
-
</CarouselContext.Provider>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function CarouselContent({
|
|
104
|
-
className,
|
|
105
|
-
...props
|
|
106
|
-
}) {
|
|
107
|
-
const { carouselRef, orientation } = useCarousel()
|
|
108
|
-
|
|
109
|
-
return (
|
|
110
|
-
<div
|
|
111
|
-
ref={carouselRef}
|
|
112
|
-
className="overflow-hidden"
|
|
113
|
-
data-slot="carousel-content">
|
|
114
|
-
<div
|
|
115
|
-
className={cn(
|
|
116
|
-
"flex",
|
|
117
|
-
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
|
118
|
-
className
|
|
119
|
-
)}
|
|
120
|
-
{...props} />
|
|
121
|
-
</div>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function CarouselItem({
|
|
126
|
-
className,
|
|
127
|
-
...props
|
|
128
|
-
}) {
|
|
129
|
-
const { orientation } = useCarousel()
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<div
|
|
133
|
-
role="group"
|
|
134
|
-
aria-roledescription="slide"
|
|
135
|
-
data-slot="carousel-item"
|
|
136
|
-
className={cn(
|
|
137
|
-
"min-w-0 shrink-0 grow-0 basis-full",
|
|
138
|
-
orientation === "horizontal" ? "pl-4" : "pt-4",
|
|
139
|
-
className
|
|
140
|
-
)}
|
|
141
|
-
{...props} />
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function CarouselPrevious({
|
|
146
|
-
className,
|
|
147
|
-
variant = "outline",
|
|
148
|
-
size = "icon-sm",
|
|
149
|
-
...props
|
|
150
|
-
}) {
|
|
151
|
-
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
|
152
|
-
|
|
153
|
-
return (
|
|
154
|
-
<Button
|
|
155
|
-
data-slot="carousel-previous"
|
|
156
|
-
variant={variant}
|
|
157
|
-
size={size}
|
|
158
|
-
className={cn("rounded-full absolute touch-manipulation", orientation === "horizontal"
|
|
159
|
-
? "top-1/2 -left-12 -translate-y-1/2"
|
|
160
|
-
: "-top-12 left-1/2 -translate-x-1/2 rotate-90", className)}
|
|
161
|
-
disabled={!canScrollPrev}
|
|
162
|
-
onClick={scrollPrev}
|
|
163
|
-
{...props}>
|
|
164
|
-
<ChevronLeftIcon />
|
|
165
|
-
<span className="sr-only">Previous slide</span>
|
|
166
|
-
</Button>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function CarouselNext({
|
|
171
|
-
className,
|
|
172
|
-
variant = "outline",
|
|
173
|
-
size = "icon-sm",
|
|
174
|
-
...props
|
|
175
|
-
}) {
|
|
176
|
-
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
|
177
|
-
|
|
178
|
-
return (
|
|
179
|
-
<Button
|
|
180
|
-
data-slot="carousel-next"
|
|
181
|
-
variant={variant}
|
|
182
|
-
size={size}
|
|
183
|
-
className={cn("rounded-full absolute touch-manipulation", orientation === "horizontal"
|
|
184
|
-
? "top-1/2 -right-12 -translate-y-1/2"
|
|
185
|
-
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className)}
|
|
186
|
-
disabled={!canScrollNext}
|
|
187
|
-
onClick={scrollNext}
|
|
188
|
-
{...props}>
|
|
189
|
-
<ChevronRightIcon />
|
|
190
|
-
<span className="sr-only">Next slide</span>
|
|
191
|
-
</Button>
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export { Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, useCarousel };
|