@moveindustries/movement-design-system 1.1.0 → 1.1.3
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/CHANGELOG.md +26 -0
- package/README.md +17 -21
- package/dist/button-DBoRj4Bh.js +59 -0
- package/dist/button-Dmwbc4J_.cjs +1 -0
- package/dist/carousel.cjs +1 -0
- package/dist/carousel.d.ts +3 -0
- package/dist/carousel.d.ts.map +1 -0
- package/dist/carousel.js +1425 -0
- package/dist/dialog-9n6-1DUQ.js +1180 -0
- package/dist/dialog-LjNZCtUV.cjs +9 -0
- package/dist/drawer-BkuiusSD.cjs +3 -0
- package/dist/drawer-C7hRQ7X-.js +1155 -0
- package/dist/drawer.cjs +1 -0
- package/dist/drawer.d.ts +2 -0
- package/dist/drawer.d.ts.map +1 -0
- package/dist/drawer.js +11 -0
- package/dist/forms.cjs +1 -0
- package/dist/forms.d.ts +2 -0
- package/dist/forms.d.ts.map +1 -0
- package/dist/forms.js +386 -0
- package/dist/index-5va-8CrW.cjs +1 -0
- package/dist/index-uPOYJZpG.js +34 -0
- package/dist/index.cjs +3 -11
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2261 -7049
- package/dist/label-CPL77haD.js +23 -0
- package/dist/label-tKsAbVfX.cjs +1 -0
- package/dist/movement-design-system.css +1 -1
- package/dist/utils-CikHldDD.cjs +1 -0
- package/dist/utils-eGXXUFl7.js +2935 -0
- package/dist/wallet.cjs +1 -0
- package/dist/wallet.d.ts +3 -0
- package/dist/wallet.d.ts.map +1 -0
- package/dist/wallet.js +279 -0
- package/package.json +45 -24
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,32 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.1.3] - 2026-03-15
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Peer dependency bloat** — Consumers no longer need to install unused dependencies
|
|
12
|
+
- Carousel, Form, Drawer, and WalletModal moved to separate tree-shakeable entry points
|
|
13
|
+
- Carousel, Form, and Drawer deps are bundled — no installs required
|
|
14
|
+
- WalletModal still requires `@moveindustries/wallet-adapter-react` as peer dep (for shared context)
|
|
15
|
+
- Removed 8 unused peer dependencies (recharts, react-day-picker, date-fns, cmdk, input-otp, react-resizable-panels, zod, @hookform/resolvers)
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// These work without installing extra deps
|
|
19
|
+
import { Carousel } from "@moveindustries/movement-design-system/carousel"
|
|
20
|
+
import { Form } from "@moveindustries/movement-design-system/forms"
|
|
21
|
+
import { Drawer } from "@moveindustries/movement-design-system/drawer"
|
|
22
|
+
|
|
23
|
+
// This requires: pnpm add @moveindustries/wallet-adapter-react
|
|
24
|
+
import { WalletModal } from "@moveindustries/movement-design-system/wallet"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## [1.1.1] - 2026-03-15
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- **Storybook** — Add missing `@import "tailwindcss"` to `index.css` so Storybook renders styles correctly
|
|
32
|
+
|
|
7
33
|
## [1.1.0] - 2026-03-14
|
|
8
34
|
|
|
9
35
|
### Changed
|
package/README.md
CHANGED
|
@@ -28,24 +28,11 @@ pnpm add @moveindustries/movement-design-system
|
|
|
28
28
|
|
|
29
29
|
### Install Peer Dependencies
|
|
30
30
|
|
|
31
|
-
The design system externalizes most UI dependencies. Install the required peer dependencies:
|
|
32
|
-
|
|
33
31
|
```bash
|
|
34
|
-
# Required
|
|
35
32
|
pnpm add @phosphor-icons/react lucide-react sonner next-themes
|
|
36
33
|
|
|
37
34
|
# Radix UI primitives (install those you use)
|
|
38
35
|
pnpm add @radix-ui/react-dialog @radix-ui/react-dropdown-menu @radix-ui/react-tooltip @radix-ui/react-tabs @radix-ui/react-select @radix-ui/react-checkbox @radix-ui/react-switch @radix-ui/react-slider @radix-ui/react-avatar @radix-ui/react-accordion @radix-ui/react-popover @radix-ui/react-label @radix-ui/react-separator @radix-ui/react-scroll-area @radix-ui/react-progress @radix-ui/react-slot
|
|
39
|
-
|
|
40
|
-
# Optional (for specific components)
|
|
41
|
-
pnpm add vaul # Drawer component
|
|
42
|
-
pnpm add recharts # Chart components
|
|
43
|
-
pnpm add react-day-picker date-fns # Calendar component
|
|
44
|
-
pnpm add cmdk # Command palette
|
|
45
|
-
pnpm add embla-carousel-react # Carousel
|
|
46
|
-
pnpm add input-otp # OTP input
|
|
47
|
-
pnpm add react-resizable-panels # Resizable panels
|
|
48
|
-
pnpm add react-hook-form @hookform/resolvers zod # Form management
|
|
49
36
|
```
|
|
50
37
|
|
|
51
38
|
### Import Styles
|
|
@@ -75,22 +62,31 @@ function App() {
|
|
|
75
62
|
}
|
|
76
63
|
```
|
|
77
64
|
|
|
78
|
-
##
|
|
65
|
+
## Optional Components
|
|
79
66
|
|
|
80
|
-
|
|
67
|
+
Some components are available via separate entry points. Carousel, Forms, and Drawer have their dependencies bundled — no extra installs required.
|
|
81
68
|
|
|
82
|
-
|
|
69
|
+
```tsx
|
|
70
|
+
// Carousel (embla-carousel-react bundled)
|
|
71
|
+
import { Carousel, CarouselContent, CarouselItem } from '@moveindustries/movement-design-system/carousel';
|
|
83
72
|
|
|
84
|
-
|
|
73
|
+
// Forms (react-hook-form bundled)
|
|
74
|
+
import { Form, FormField, FormItem, FormLabel } from '@moveindustries/movement-design-system/forms';
|
|
75
|
+
|
|
76
|
+
// Drawer (vaul bundled)
|
|
77
|
+
import { Drawer, DrawerContent, DrawerTrigger } from '@moveindustries/movement-design-system/drawer';
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### WalletModal
|
|
81
|
+
|
|
82
|
+
WalletModal requires the wallet adapter as a peer dependency (for shared context):
|
|
85
83
|
|
|
86
84
|
```bash
|
|
87
85
|
pnpm add @moveindustries/wallet-adapter-react
|
|
88
86
|
```
|
|
89
87
|
|
|
90
|
-
### Usage
|
|
91
|
-
|
|
92
88
|
```tsx
|
|
93
|
-
import { WalletModal } from '@moveindustries/movement-design-system';
|
|
89
|
+
import { WalletModal } from '@moveindustries/movement-design-system/wallet';
|
|
94
90
|
import { useWallet } from '@moveindustries/wallet-adapter-react';
|
|
95
91
|
|
|
96
92
|
function ConnectButton() {
|
|
@@ -108,7 +104,7 @@ function ConnectButton() {
|
|
|
108
104
|
}
|
|
109
105
|
```
|
|
110
106
|
|
|
111
|
-
> **Note**: `WalletModal` displays only the wallets configured in your app's `WalletProvider`.
|
|
107
|
+
> **Note**: `WalletModal` displays only the wallets configured in your app's `WalletProvider`.
|
|
112
108
|
|
|
113
109
|
## Development
|
|
114
110
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Slot as n } from "@radix-ui/react-slot";
|
|
4
|
+
import { c as s } from "./index-uPOYJZpG.js";
|
|
5
|
+
import { c } from "./utils-eGXXUFl7.js";
|
|
6
|
+
const g = s(
|
|
7
|
+
"cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-bold transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive uppercase tracking-wider rounded-full",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80",
|
|
12
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/90 active:bg-secondary/80",
|
|
13
|
+
accent: "bg-accent text-accent-foreground hover:bg-accent/90 active:bg-accent/80",
|
|
14
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90 active:bg-destructive/80",
|
|
15
|
+
success: "bg-success text-success-foreground hover:bg-success/90 active:bg-success/80",
|
|
16
|
+
warning: "bg-warning text-warning-foreground hover:bg-warning/90 active:bg-warning/80",
|
|
17
|
+
outline: "border-2 border-primary bg-transparent text-primary hover:bg-primary hover:text-primary-foreground active:bg-primary/90 active:text-primary-foreground",
|
|
18
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
19
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
20
|
+
glow: "w-full max-w-[522px] p-3 bg-[#81FFBA] border-0 font-mono text-[#0237FE] rounded-lg text-2xl font-bold leading-6 tracking-[-0.06rem] uppercase relative overflow-hidden backdrop-blur-[21px] shadow-[8px_8px_0_0_#0337FF] hover:-translate-y-px hover:bg-white hover:shadow-[-8px_-8px_0_0_#0337FF] active:translate-y-0 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 ease-in-out"
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
xs: "h-6 px-3 text-xs gap-1.5",
|
|
24
|
+
sm: "h-8 px-4 text-sm gap-2",
|
|
25
|
+
default: "h-10 px-6 text-base gap-2",
|
|
26
|
+
lg: "h-12 px-8 text-lg gap-2.5",
|
|
27
|
+
xl: "h-14 px-10 text-xl gap-2.5",
|
|
28
|
+
"2xl": "h-16 px-12 text-2xl gap-3",
|
|
29
|
+
icon: "size-9",
|
|
30
|
+
"icon-sm": "size-8",
|
|
31
|
+
"icon-lg": "size-10"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
variant: "default",
|
|
36
|
+
size: "default"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
function x({
|
|
41
|
+
className: e,
|
|
42
|
+
variant: r,
|
|
43
|
+
size: t,
|
|
44
|
+
asChild: a = !1,
|
|
45
|
+
...i
|
|
46
|
+
}) {
|
|
47
|
+
return /* @__PURE__ */ o(
|
|
48
|
+
a ? n : "button",
|
|
49
|
+
{
|
|
50
|
+
"data-slot": "button",
|
|
51
|
+
className: c(g({ variant: r, size: t, className: e })),
|
|
52
|
+
...i
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
x as B,
|
|
58
|
+
g as b
|
|
59
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime");require("react");const c=require("@radix-ui/react-slot"),d=require("./index-5va-8CrW.cjs"),g=require("./utils-CikHldDD.cjs"),e=d.cva("cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-bold transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive uppercase tracking-wider rounded-full",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/90 active:bg-secondary/80",accent:"bg-accent text-accent-foreground hover:bg-accent/90 active:bg-accent/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 active:bg-destructive/80",success:"bg-success text-success-foreground hover:bg-success/90 active:bg-success/80",warning:"bg-warning text-warning-foreground hover:bg-warning/90 active:bg-warning/80",outline:"border-2 border-primary bg-transparent text-primary hover:bg-primary hover:text-primary-foreground active:bg-primary/90 active:text-primary-foreground",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline",glow:"w-full max-w-[522px] p-3 bg-[#81FFBA] border-0 font-mono text-[#0237FE] rounded-lg text-2xl font-bold leading-6 tracking-[-0.06rem] uppercase relative overflow-hidden backdrop-blur-[21px] shadow-[8px_8px_0_0_#0337FF] hover:-translate-y-px hover:bg-white hover:shadow-[-8px_-8px_0_0_#0337FF] active:translate-y-0 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 ease-in-out"},size:{xs:"h-6 px-3 text-xs gap-1.5",sm:"h-8 px-4 text-sm gap-2",default:"h-10 px-6 text-base gap-2",lg:"h-12 px-8 text-lg gap-2.5",xl:"h-14 px-10 text-xl gap-2.5","2xl":"h-16 px-12 text-2xl gap-3",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function u({className:t,variant:r,size:n,asChild:i=!1,...a}){const o=i?c.Slot:"button";return s.jsx(o,{"data-slot":"button",className:g.cn(e({variant:r,size:n,className:t})),...a})}exports.Button=u;exports.buttonVariants=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),Y=require("react"),_t=require("lucide-react"),ht=require("./utils-CikHldDD.cjs"),Qt=require("./button-Dmwbc4J_.cjs");function ln(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,s.get?s:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const K=ln(Y);function fn(t){return Object.prototype.toString.call(t)==="[object Object]"}function Ht(t){return fn(t)||Array.isArray(t)}function dn(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function Pt(t,n){const e=Object.keys(t),s=Object.keys(n);if(e.length!==s.length)return!1;const c=JSON.stringify(Object.keys(t.breakpoints||{})),i=JSON.stringify(Object.keys(n.breakpoints||{}));return c!==i?!1:e.every(o=>{const a=t[o],r=n[o];return typeof a=="function"?`${a}`==`${r}`:!Ht(a)||!Ht(r)?a===r:Pt(a,r)})}function $t(t){return t.concat().sort((n,e)=>n.name>e.name?1:-1).map(n=>n.options)}function pn(t,n){if(t.length!==n.length)return!1;const e=$t(t),s=$t(n);return e.every((c,i)=>{const o=s[i];return Pt(c,o)})}function Dt(t){return typeof t=="number"}function Ot(t){return typeof t=="string"}function xt(t){return typeof t=="boolean"}function Kt(t){return Object.prototype.toString.call(t)==="[object Object]"}function D(t){return Math.abs(t)}function At(t){return Math.sign(t)}function dt(t,n){return D(t-n)}function mn(t,n){if(t===0||n===0||D(t)<=D(n))return 0;const e=dt(D(t),D(n));return D(e/t)}function gn(t){return Math.round(t*100)/100}function pt(t){return mt(t).map(Number)}function V(t){return t[St(t)]}function St(t){return Math.max(0,t.length-1)}function Mt(t,n){return n===St(t)}function Ut(t,n=0){return Array.from(Array(t),(e,s)=>n+s)}function mt(t){return Object.keys(t)}function Jt(t,n){return[t,n].reduce((e,s)=>(mt(s).forEach(c=>{const i=e[c],o=s[c],a=Kt(i)&&Kt(o);e[c]=a?Jt(i,o):o}),e),{})}function wt(t,n){return typeof n.MouseEvent<"u"&&t instanceof n.MouseEvent}function hn(t,n){const e={start:s,center:c,end:i};function s(){return 0}function c(r){return i(r)/2}function i(r){return n-r}function o(r,u){return Ot(t)?e[t](r):t(n,r,u)}return{measure:o}}function gt(){let t=[];function n(c,i,o,a={passive:!0}){let r;if("addEventListener"in c)c.addEventListener(i,o,a),r=()=>c.removeEventListener(i,o,a);else{const u=c;u.addListener(o),r=()=>u.removeListener(o)}return t.push(r),s}function e(){t=t.filter(c=>c())}const s={add:n,clear:e};return s}function Sn(t,n,e,s){const c=gt(),i=1e3/60;let o=null,a=0,r=0;function u(){c.add(t,"visibilitychange",()=>{t.hidden&&f()})}function h(){b(),c.clear()}function d(g){if(!r)return;o||(o=g,e(),e());const l=g-o;for(o=g,a+=l;a>=i;)e(),a-=i;const S=a/i;s(S),r&&(r=n.requestAnimationFrame(d))}function p(){r||(r=n.requestAnimationFrame(d))}function b(){n.cancelAnimationFrame(r),o=null,a=0,r=0}function f(){o=null,a=0}return{init:u,destroy:h,start:p,stop:b,update:e,render:s}}function bn(t,n){const e=n==="rtl",s=t==="y",c=s?"y":"x",i=s?"x":"y",o=!s&&e?-1:1,a=h(),r=d();function u(f){const{height:m,width:g}=f;return s?m:g}function h(){return s?"top":e?"right":"left"}function d(){return s?"bottom":e?"left":"right"}function p(f){return f*o}return{scroll:c,cross:i,startEdge:a,endEdge:r,measureSize:u,direction:p}}function ot(t=0,n=0){const e=D(t-n);function s(u){return u<t}function c(u){return u>n}function i(u){return s(u)||c(u)}function o(u){return i(u)?s(u)?t:n:u}function a(u){return e?u-e*Math.ceil((u-n)/e):u}return{length:e,max:n,min:t,constrain:o,reachedAny:i,reachedMax:c,reachedMin:s,removeOffset:a}}function Xt(t,n,e){const{constrain:s}=ot(0,t),c=t+1;let i=o(n);function o(p){return e?D((c+p)%c):s(p)}function a(){return i}function r(p){return i=o(p),d}function u(p){return h().set(a()+p)}function h(){return Xt(t,a(),e)}const d={get:a,set:r,add:u,clone:h};return d}function yn(t,n,e,s,c,i,o,a,r,u,h,d,p,b,f,m,g,l,S){const{cross:x,direction:L}=t,w=["INPUT","SELECT","TEXTAREA"],C={passive:!1},v=gt(),E=gt(),I=ot(50,225).constrain(b.measure(20)),A={mouse:300,touch:400},T={mouse:500,touch:600},k=f?43:25;let R=!1,q=0,G=0,tt=!1,Z=!1,U=!1,_=!1;function ct(y){if(!S)return;function O(j){(xt(S)||S(y,j))&&at(j)}const M=n;v.add(M,"dragstart",j=>j.preventDefault(),C).add(M,"touchmove",()=>{},C).add(M,"touchend",()=>{}).add(M,"touchstart",O).add(M,"mousedown",O).add(M,"touchcancel",N).add(M,"contextmenu",N).add(M,"click",J,!0)}function H(){v.clear(),E.clear()}function rt(){const y=_?e:n;E.add(y,"touchmove",F,C).add(y,"touchend",N).add(y,"mousemove",F,C).add(y,"mouseup",N)}function st(y){const O=y.nodeName||"";return w.includes(O)}function Q(){return(f?T:A)[_?"mouse":"touch"]}function ut(y,O){const M=d.add(At(y)*-1),j=h.byDistance(y,!f).distance;return f||D(y)<I?j:g&&O?j*.5:h.byIndex(M.get(),0).distance}function at(y){const O=wt(y,s);_=O,U=f&&O&&!y.buttons&&R,R=dt(c.get(),o.get())>=2,!(O&&y.button!==0)&&(st(y.target)||(tt=!0,i.pointerDown(y),u.useFriction(0).useDuration(0),c.set(o),rt(),q=i.readPoint(y),G=i.readPoint(y,x),p.emit("pointerDown")))}function F(y){if(!wt(y,s)&&y.touches.length>=2)return N(y);const M=i.readPoint(y),j=i.readPoint(y,x),$=dt(M,q),X=dt(j,G);if(!Z&&!_&&(!y.cancelable||(Z=$>X,!Z)))return N(y);const nt=i.pointerMove(y);$>m&&(U=!0),u.useFriction(.3).useDuration(.75),a.start(),c.add(L(nt)),y.preventDefault()}function N(y){const M=h.byDistance(0,!1).index!==d.get(),j=i.pointerUp(y)*Q(),$=ut(L(j),M),X=mn(j,$),nt=k-10*X,W=l+X/50;Z=!1,tt=!1,E.clear(),u.useDuration(nt).useFriction(W),r.distance($,!f),_=!1,p.emit("pointerUp")}function J(y){U&&(y.stopPropagation(),y.preventDefault(),U=!1)}function z(){return tt}return{init:ct,destroy:H,pointerDown:z}}function xn(t,n){let s,c;function i(d){return d.timeStamp}function o(d,p){const f=`client${(p||t.scroll)==="x"?"X":"Y"}`;return(wt(d,n)?d:d.touches[0])[f]}function a(d){return s=d,c=d,o(d)}function r(d){const p=o(d)-o(c),b=i(d)-i(s)>170;return c=d,b&&(s=d),p}function u(d){if(!s||!c)return 0;const p=o(c)-o(s),b=i(d)-i(s),f=i(d)-i(c)>170,m=p/b;return b&&!f&&D(m)>.1?m:0}return{pointerDown:a,pointerMove:r,pointerUp:u,readPoint:o}}function vn(){function t(e){const{offsetTop:s,offsetLeft:c,offsetWidth:i,offsetHeight:o}=e;return{top:s,right:c+i,bottom:s+o,left:c,width:i,height:o}}return{measure:t}}function En(t){function n(s){return t*(s/100)}return{measure:n}}function Ln(t,n,e,s,c,i,o){const a=[t].concat(s);let r,u,h=[],d=!1;function p(g){return c.measureSize(o.measure(g))}function b(g){if(!i)return;u=p(t),h=s.map(p);function l(S){for(const x of S){if(d)return;const L=x.target===t,w=s.indexOf(x.target),C=L?u:h[w],v=p(L?t:s[w]);if(D(v-C)>=.5){g.reInit(),n.emit("resize");break}}}r=new ResizeObserver(S=>{(xt(i)||i(g,S))&&l(S)}),e.requestAnimationFrame(()=>{a.forEach(S=>r.observe(S))})}function f(){d=!0,r&&r.disconnect()}return{init:b,destroy:f}}function Cn(t,n,e,s,c,i){let o=0,a=0,r=c,u=i,h=t.get(),d=0;function p(){const C=s.get()-t.get(),v=!r;let E=0;return v?(o=0,e.set(s),t.set(s),E=C):(e.set(t),o+=C/r,o*=u,h+=o,t.add(o),E=h-d),a=At(E),d=h,w}function b(){const C=s.get()-n.get();return D(C)<.001}function f(){return r}function m(){return a}function g(){return o}function l(){return x(c)}function S(){return L(i)}function x(C){return r=C,w}function L(C){return u=C,w}const w={direction:m,duration:f,velocity:g,seek:p,settled:b,useBaseFriction:S,useBaseDuration:l,useFriction:L,useDuration:x};return w}function In(t,n,e,s,c){const i=c.measure(10),o=c.measure(50),a=ot(.1,.99);let r=!1;function u(){return!(r||!t.reachedAny(e.get())||!t.reachedAny(n.get()))}function h(b){if(!u())return;const f=t.reachedMin(n.get())?"min":"max",m=D(t[f]-n.get()),g=e.get()-n.get(),l=a.constrain(m/o);e.subtract(g*l),!b&&D(g)<i&&(e.set(t.constrain(e.get())),s.useDuration(25).useBaseFriction())}function d(b){r=!b}return{shouldConstrain:u,constrain:h,toggleActive:d}}function Tn(t,n,e,s,c){const i=ot(-n+t,0),o=d(),a=h(),r=p();function u(f,m){return dt(f,m)<=1}function h(){const f=o[0],m=V(o),g=o.lastIndexOf(f),l=o.indexOf(m)+1;return ot(g,l)}function d(){return e.map((f,m)=>{const{min:g,max:l}=i,S=i.constrain(f),x=!m,L=Mt(e,m);return x?l:L||u(g,S)?g:u(l,S)?l:S}).map(f=>parseFloat(f.toFixed(3)))}function p(){if(n<=t+c)return[i.max];if(s==="keepSnaps")return o;const{min:f,max:m}=a;return o.slice(f,m)}return{snapsContained:r,scrollContainLimit:a}}function On(t,n,e){const s=n[0],c=e?s-t:V(n);return{limit:ot(c,s)}}function wn(t,n,e,s){const i=n.min+.1,o=n.max+.1,{reachedMin:a,reachedMax:r}=ot(i,o);function u(p){return p===1?r(e.get()):p===-1?a(e.get()):!1}function h(p){if(!u(p))return;const b=t*(p*-1);s.forEach(f=>f.add(b))}return{loop:h}}function Pn(t){const{max:n,length:e}=t;function s(i){const o=i-n;return e?o/-e:0}return{get:s}}function Dn(t,n,e,s,c){const{startEdge:i,endEdge:o}=t,{groupSlides:a}=c,r=d().map(n.measure),u=p(),h=b();function d(){return a(s).map(m=>V(m)[o]-m[0][i]).map(D)}function p(){return s.map(m=>e[i]-m[i]).map(m=>-D(m))}function b(){return a(u).map(m=>m[0]).map((m,g)=>m+r[g])}return{snaps:u,snapsAligned:h}}function An(t,n,e,s,c,i){const{groupSlides:o}=c,{min:a,max:r}=s,u=h();function h(){const p=o(i),b=!t||n==="keepSnaps";return e.length===1?[i]:b?p:p.slice(a,r).map((f,m,g)=>{const l=!m,S=Mt(g,m);if(l){const x=V(g[0])+1;return Ut(x)}if(S){const x=St(i)-V(g)[0]+1;return Ut(x,V(g)[0])}return f})}return{slideRegistry:u}}function Mn(t,n,e,s,c){const{reachedAny:i,removeOffset:o,constrain:a}=s;function r(f){return f.concat().sort((m,g)=>D(m)-D(g))[0]}function u(f){const m=t?o(f):a(f),g=n.map((S,x)=>({diff:h(S-m,0),index:x})).sort((S,x)=>D(S.diff)-D(x.diff)),{index:l}=g[0];return{index:l,distance:m}}function h(f,m){const g=[f,f+e,f-e];if(!t)return f;if(!m)return r(g);const l=g.filter(S=>At(S)===m);return l.length?r(l):V(g)-e}function d(f,m){const g=n[f]-c.get(),l=h(g,m);return{index:f,distance:l}}function p(f,m){const g=c.get()+f,{index:l,distance:S}=u(g),x=!t&&i(g);if(!m||x)return{index:l,distance:f};const L=n[l]-S,w=f+h(L,0);return{index:l,distance:w}}return{byDistance:p,byIndex:d,shortcut:h}}function Nn(t,n,e,s,c,i,o){function a(d){const p=d.distance,b=d.index!==n.get();i.add(p),p&&(s.duration()?t.start():(t.update(),t.render(1),t.update())),b&&(e.set(n.get()),n.set(d.index),o.emit("select"))}function r(d,p){const b=c.byDistance(d,p);a(b)}function u(d,p){const b=n.clone().set(d),f=c.byIndex(b.get(),p);a(f)}return{distance:r,index:u}}function jn(t,n,e,s,c,i,o,a){const r={passive:!0,capture:!0};let u=0;function h(b){if(!a)return;function f(m){if(new Date().getTime()-u>10)return;o.emit("slideFocusStart"),t.scrollLeft=0;const S=e.findIndex(x=>x.includes(m));Dt(S)&&(c.useDuration(0),s.index(S,0),o.emit("slideFocus"))}i.add(document,"keydown",d,!1),n.forEach((m,g)=>{i.add(m,"focus",l=>{(xt(a)||a(b,l))&&f(g)},r)})}function d(b){b.code==="Tab"&&(u=new Date().getTime())}return{init:h}}function ft(t){let n=t;function e(){return n}function s(r){n=o(r)}function c(r){n+=o(r)}function i(r){n-=o(r)}function o(r){return Dt(r)?r:r.get()}return{get:e,set:s,add:c,subtract:i}}function Yt(t,n){const e=t.scroll==="x"?o:a,s=n.style;let c=null,i=!1;function o(p){return`translate3d(${p}px,0px,0px)`}function a(p){return`translate3d(0px,${p}px,0px)`}function r(p){if(i)return;const b=gn(t.direction(p));b!==c&&(s.transform=e(b),c=b)}function u(p){i=!p}function h(){i||(s.transform="",n.getAttribute("style")||n.removeAttribute("style"))}return{clear:h,to:r,toggleActive:u}}function kn(t,n,e,s,c,i,o,a,r){const h=pt(c),d=pt(c).reverse(),p=l().concat(S());function b(v,E){return v.reduce((I,A)=>I-c[A],E)}function f(v,E){return v.reduce((I,A)=>b(I,E)>0?I.concat([A]):I,[])}function m(v){return i.map((E,I)=>({start:E-s[I]+.5+v,end:E+n-.5+v}))}function g(v,E,I){const A=m(E);return v.map(T=>{const k=I?0:-e,R=I?e:0,q=I?"end":"start",G=A[T][q];return{index:T,loopPoint:G,slideLocation:ft(-1),translate:Yt(t,r[T]),target:()=>a.get()>G?k:R}})}function l(){const v=o[0],E=f(d,v);return g(E,e,!1)}function S(){const v=n-o[0]-1,E=f(h,v);return g(E,-e,!0)}function x(){return p.every(({index:v})=>{const E=h.filter(I=>I!==v);return b(E,n)<=.1})}function L(){p.forEach(v=>{const{target:E,translate:I,slideLocation:A}=v,T=E();T!==A.get()&&(I.to(T),A.set(T))})}function w(){p.forEach(v=>v.translate.clear())}return{canLoop:x,clear:w,loop:L,loopPoints:p}}function Fn(t,n,e){let s,c=!1;function i(r){if(!e)return;function u(h){for(const d of h)if(d.type==="childList"){r.reInit(),n.emit("slidesChanged");break}}s=new MutationObserver(h=>{c||(xt(e)||e(r,h))&&u(h)}),s.observe(t,{childList:!0})}function o(){s&&s.disconnect(),c=!0}return{init:i,destroy:o}}function zn(t,n,e,s){const c={};let i=null,o=null,a,r=!1;function u(){a=new IntersectionObserver(f=>{r||(f.forEach(m=>{const g=n.indexOf(m.target);c[g]=m}),i=null,o=null,e.emit("slidesInView"))},{root:t.parentElement,threshold:s}),n.forEach(f=>a.observe(f))}function h(){a&&a.disconnect(),r=!0}function d(f){return mt(c).reduce((m,g)=>{const l=parseInt(g),{isIntersecting:S}=c[l];return(f&&S||!f&&!S)&&m.push(l),m},[])}function p(f=!0){if(f&&i)return i;if(!f&&o)return o;const m=d(f);return f&&(i=m),f||(o=m),m}return{init:u,destroy:h,get:p}}function Bn(t,n,e,s,c,i){const{measureSize:o,startEdge:a,endEdge:r}=t,u=e[0]&&c,h=f(),d=m(),p=e.map(o),b=g();function f(){if(!u)return 0;const S=e[0];return D(n[a]-S[a])}function m(){if(!u)return 0;const S=i.getComputedStyle(V(s));return parseFloat(S.getPropertyValue(`margin-${r}`))}function g(){return e.map((S,x,L)=>{const w=!x,C=Mt(L,x);return w?p[x]+h:C?p[x]+d:L[x+1][a]-S[a]}).map(D)}return{slideSizes:p,slideSizesWithGaps:b,startGap:h,endGap:d}}function Vn(t,n,e,s,c,i,o,a,r){const{startEdge:u,endEdge:h,direction:d}=t,p=Dt(e);function b(l,S){return pt(l).filter(x=>x%S===0).map(x=>l.slice(x,x+S))}function f(l){return l.length?pt(l).reduce((S,x,L)=>{const w=V(S)||0,C=w===0,v=x===St(l),E=c[u]-i[w][u],I=c[u]-i[x][h],A=!s&&C?d(o):0,T=!s&&v?d(a):0,k=D(I-T-(E+A));return L&&k>n+r&&S.push(x),v&&S.push(l.length),S},[]).map((S,x,L)=>{const w=Math.max(L[x-1]||0);return l.slice(w,S)}):[]}function m(l){return p?b(l,e):f(l)}return{groupSlides:m}}function Rn(t,n,e,s,c,i,o){const{align:a,axis:r,direction:u,startIndex:h,loop:d,duration:p,dragFree:b,dragThreshold:f,inViewThreshold:m,slidesToScroll:g,skipSnaps:l,containScroll:S,watchResize:x,watchSlides:L,watchDrag:w,watchFocus:C}=i,v=2,E=vn(),I=E.measure(n),A=e.map(E.measure),T=bn(r,u),k=T.measureSize(I),R=En(k),q=hn(a,k),G=!d&&!!S,tt=d||!!S,{slideSizes:Z,slideSizesWithGaps:U,startGap:_,endGap:ct}=Bn(T,I,A,e,tt,c),H=Vn(T,k,g,d,I,A,_,ct,v),{snaps:rt,snapsAligned:st}=Dn(T,q,I,A,H),Q=-V(rt)+V(U),{snapsContained:ut,scrollContainLimit:at}=Tn(k,Q,st,S,v),F=G?ut:st,{limit:N}=On(Q,F,d),J=Xt(St(F),h,d),z=J.clone(),P=pt(e),y=({dragHandler:it,scrollBody:It,scrollBounds:Tt,options:{loop:bt}})=>{bt||Tt.constrain(it.pointerDown()),It.seek()},O=({scrollBody:it,translate:It,location:Tt,offsetLocation:bt,previousLocation:nn,scrollLooper:en,slideLooper:on,dragHandler:rn,animation:sn,eventHandler:zt,scrollBounds:cn,options:{loop:Bt}},Vt)=>{const Rt=it.settled(),un=!cn.shouldConstrain(),qt=Bt?Rt:Rt&&un,Gt=qt&&!rn.pointerDown();Gt&&sn.stop();const an=Tt.get()*Vt+nn.get()*(1-Vt);bt.set(an),Bt&&(en.loop(it.direction()),on.loop()),It.to(bt.get()),Gt&&zt.emit("settle"),qt||zt.emit("scroll")},M=Sn(s,c,()=>y(Ct),it=>O(Ct,it)),j=.68,$=F[J.get()],X=ft($),nt=ft($),W=ft($),et=ft($),lt=Cn(X,W,nt,et,p,j),Et=Mn(d,F,Q,N,et),Lt=Nn(M,J,z,lt,Et,et,o),jt=Pn(N),kt=gt(),Wt=zn(n,e,o,m),{slideRegistry:Ft}=An(G,S,F,at,H,P),tn=jn(t,e,Ft,Lt,lt,kt,o,C),Ct={ownerDocument:s,ownerWindow:c,eventHandler:o,containerRect:I,slideRects:A,animation:M,axis:T,dragHandler:yn(T,t,s,c,et,xn(T,c),X,M,Lt,lt,Et,J,o,R,b,f,l,j,w),eventStore:kt,percentOfView:R,index:J,indexPrevious:z,limit:N,location:X,offsetLocation:W,previousLocation:nt,options:i,resizeHandler:Ln(n,o,c,e,T,x,E),scrollBody:lt,scrollBounds:In(N,W,et,lt,R),scrollLooper:wn(Q,N,W,[X,W,nt,et]),scrollProgress:jt,scrollSnapList:F.map(jt.get),scrollSnaps:F,scrollTarget:Et,scrollTo:Lt,slideLooper:kn(T,k,Q,Z,U,rt,F,W,e),slideFocus:tn,slidesHandler:Fn(n,o,L),slidesInView:Wt,slideIndexes:P,slideRegistry:Ft,slidesToScroll:H,target:et,translate:Yt(T,n)};return Ct}function qn(){let t={},n;function e(u){n=u}function s(u){return t[u]||[]}function c(u){return s(u).forEach(h=>h(n,u)),r}function i(u,h){return t[u]=s(u).concat([h]),r}function o(u,h){return t[u]=s(u).filter(d=>d!==h),r}function a(){t={}}const r={init:e,emit:c,off:o,on:i,clear:a};return r}const Gn={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function Hn(t){function n(i,o){return Jt(i,o||{})}function e(i){const o=i.breakpoints||{},a=mt(o).filter(r=>t.matchMedia(r).matches).map(r=>o[r]).reduce((r,u)=>n(r,u),{});return n(i,a)}function s(i){return i.map(o=>mt(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(t.matchMedia)}return{mergeOptions:n,optionsAtMedia:e,optionsMediaQueries:s}}function $n(t){let n=[];function e(i,o){return n=o.filter(({options:a})=>t.optionsAtMedia(a).active!==!1),n.forEach(a=>a.init(i,t)),o.reduce((a,r)=>Object.assign(a,{[r.name]:r}),{})}function s(){n=n.filter(i=>i.destroy())}return{init:e,destroy:s}}function yt(t,n,e){const s=t.ownerDocument,c=s.defaultView,i=Hn(c),o=$n(i),a=gt(),r=qn(),{mergeOptions:u,optionsAtMedia:h,optionsMediaQueries:d}=i,{on:p,off:b,emit:f}=r,m=T;let g=!1,l,S=u(Gn,yt.globalOptions),x=u(S),L=[],w,C,v;function E(){const{container:P,slides:y}=x;C=(Ot(P)?t.querySelector(P):P)||t.children[0];const M=Ot(y)?C.querySelectorAll(y):y;v=[].slice.call(M||C.children)}function I(P){const y=Rn(t,C,v,s,c,P,r);if(P.loop&&!y.slideLooper.canLoop()){const O=Object.assign({},P,{loop:!1});return I(O)}return y}function A(P,y){g||(S=u(S,P),x=h(S),L=y||L,E(),l=I(x),d([S,...L.map(({options:O})=>O)]).forEach(O=>a.add(O,"change",T)),x.active&&(l.translate.to(l.location.get()),l.animation.init(),l.slidesInView.init(),l.slideFocus.init(z),l.eventHandler.init(z),l.resizeHandler.init(z),l.slidesHandler.init(z),l.options.loop&&l.slideLooper.loop(),C.offsetParent&&v.length&&l.dragHandler.init(z),w=o.init(z,L)))}function T(P,y){const O=H();k(),A(u({startIndex:O},P),y),r.emit("reInit")}function k(){l.dragHandler.destroy(),l.eventStore.clear(),l.translate.clear(),l.slideLooper.clear(),l.resizeHandler.destroy(),l.slidesHandler.destroy(),l.slidesInView.destroy(),l.animation.destroy(),o.destroy(),a.clear()}function R(){g||(g=!0,a.clear(),k(),r.emit("destroy"),r.clear())}function q(P,y,O){!x.active||g||(l.scrollBody.useBaseFriction().useDuration(y===!0?0:x.duration),l.scrollTo.index(P,O||0))}function G(P){const y=l.index.add(1).get();q(y,P,-1)}function tt(P){const y=l.index.add(-1).get();q(y,P,1)}function Z(){return l.index.add(1).get()!==H()}function U(){return l.index.add(-1).get()!==H()}function _(){return l.scrollSnapList}function ct(){return l.scrollProgress.get(l.offsetLocation.get())}function H(){return l.index.get()}function rt(){return l.indexPrevious.get()}function st(){return l.slidesInView.get()}function Q(){return l.slidesInView.get(!1)}function ut(){return w}function at(){return l}function F(){return t}function N(){return C}function J(){return v}const z={canScrollNext:Z,canScrollPrev:U,containerNode:N,internalEngine:at,destroy:R,off:b,on:p,emit:f,plugins:ut,previousScrollSnap:rt,reInit:m,rootNode:F,scrollNext:G,scrollPrev:tt,scrollProgress:ct,scrollSnapList:_,scrollTo:q,selectedScrollSnap:H,slideNodes:J,slidesInView:st,slidesNotInView:Q};return A(n,e),setTimeout(()=>r.emit("init"),0),z}yt.globalOptions=void 0;function Nt(t={},n=[]){const e=Y.useRef(t),s=Y.useRef(n),[c,i]=Y.useState(),[o,a]=Y.useState(),r=Y.useCallback(()=>{c&&c.reInit(e.current,s.current)},[c]);return Y.useEffect(()=>{Pt(e.current,t)||(e.current=t,r())},[t,r]),Y.useEffect(()=>{pn(s.current,n)||(s.current=n,r())},[n,r]),Y.useEffect(()=>{if(dn()&&o){yt.globalOptions=Nt.globalOptions;const u=yt(o,e.current,s.current);return i(u),()=>u.destroy()}else i(void 0)},[o,i]),[a,c]}Nt.globalOptions=void 0;const Zt=K.createContext(null);function vt(){const t=K.useContext(Zt);if(!t)throw new Error("useCarousel must be used within a <Carousel />");return t}function Kn({orientation:t="horizontal",opts:n,setApi:e,plugins:s,className:c,children:i,...o}){const[a,r]=Nt({...n,axis:t==="horizontal"?"x":"y"},s),[u,h]=K.useState(!1),[d,p]=K.useState(!1),b=K.useCallback(l=>{l&&(h(l.canScrollPrev()),p(l.canScrollNext()))},[]),f=K.useCallback(()=>{r?.scrollPrev()},[r]),m=K.useCallback(()=>{r?.scrollNext()},[r]),g=K.useCallback(l=>{l.key==="ArrowLeft"?(l.preventDefault(),f()):l.key==="ArrowRight"&&(l.preventDefault(),m())},[f,m]);return K.useEffect(()=>{!r||!e||e(r)},[r,e]),K.useEffect(()=>{if(r)return b(r),r.on("reInit",b),r.on("select",b),()=>{r?.off("select",b)}},[r,b]),B.jsx(Zt.Provider,{value:{carouselRef:a,api:r,opts:n,orientation:t||(n?.axis==="y"?"vertical":"horizontal"),scrollPrev:f,scrollNext:m,canScrollPrev:u,canScrollNext:d},children:B.jsx("div",{onKeyDownCapture:g,className:ht.cn("relative",c),role:"region","aria-roledescription":"carousel","data-slot":"carousel",...o,children:i})})}function Un({className:t,...n}){const{carouselRef:e,orientation:s}=vt();return B.jsx("div",{ref:e,className:"overflow-hidden","data-slot":"carousel-content",children:B.jsx("div",{className:ht.cn("flex",s==="horizontal"?"-ml-4":"-mt-4 flex-col",t),...n})})}function _n({className:t,...n}){const{orientation:e}=vt();return B.jsx("div",{role:"group","aria-roledescription":"slide","data-slot":"carousel-item",className:ht.cn("min-w-0 shrink-0 grow-0 basis-full",e==="horizontal"?"pl-4":"pt-4",t),...n})}function Qn({className:t,variant:n="outline",size:e="icon",...s}){const{orientation:c,scrollPrev:i,canScrollPrev:o}=vt();return B.jsxs(Qt.Button,{"data-slot":"carousel-previous",variant:n,size:e,className:ht.cn("absolute size-8 rounded-full",c==="horizontal"?"top-1/2 -left-12 -translate-y-1/2":"-top-12 left-1/2 -translate-x-1/2 rotate-90",t),disabled:!o,onClick:i,...s,children:[B.jsx(_t.ArrowLeft,{}),B.jsx("span",{className:"sr-only",children:"Previous slide"})]})}function Jn({className:t,variant:n="outline",size:e="icon",...s}){const{orientation:c,scrollNext:i,canScrollNext:o}=vt();return B.jsxs(Qt.Button,{"data-slot":"carousel-next",variant:n,size:e,className:ht.cn("absolute size-8 rounded-full",c==="horizontal"?"top-1/2 -right-12 -translate-y-1/2":"-bottom-12 left-1/2 -translate-x-1/2 rotate-90",t),disabled:!o,onClick:i,...s,children:[B.jsx(_t.ArrowRight,{}),B.jsx("span",{className:"sr-only",children:"Next slide"})]})}exports.Carousel=Kn;exports.CarouselContent=Un;exports.CarouselItem=_n;exports.CarouselNext=Jn;exports.CarouselPrevious=Qn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carousel.d.ts","sourceRoot":"","sources":["../src/carousel.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC"}
|