@kumix/ui 0.3.2 → 0.3.4
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/README.md +4 -6
- package/dist/components/motion/animated-toast-stack.js +3 -3
- package/dist/components/motion/animated-toast-stack.js.map +1 -1
- package/dist/components/motion/button/base.d.ts +8 -1
- package/dist/components/motion/button/base.d.ts.map +1 -1
- package/dist/components/motion/button/base.js +14 -1
- package/dist/components/motion/button/base.js.map +1 -1
- package/dist/components/motion/button/index.d.ts +2 -2
- package/dist/components/motion/button/index.js +2 -2
- package/dist/components/motion/checkbox.d.ts +3 -1
- package/dist/components/motion/checkbox.d.ts.map +1 -1
- package/dist/components/motion/checkbox.js +2 -1
- package/dist/components/motion/checkbox.js.map +1 -1
- package/dist/components/motion/morphing-tabs.d.ts +36 -0
- package/dist/components/motion/morphing-tabs.d.ts.map +1 -0
- package/dist/components/motion/morphing-tabs.js +518 -0
- package/dist/components/motion/morphing-tabs.js.map +1 -0
- package/dist/components/motion/signup-form.d.ts +56 -0
- package/dist/components/motion/signup-form.d.ts.map +1 -0
- package/dist/components/motion/signup-form.js +337 -0
- package/dist/components/motion/signup-form.js.map +1 -0
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/badge.d.ts +2 -2
- package/dist/components/reui/data-grid/data-grid-column-filter.js +2 -2
- package/dist/components/reui/data-grid/data-grid.d.ts +4 -0
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +6 -2
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts +32 -1
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +32 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +19 -4
- package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-resource-view.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js +16 -4
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js +33 -5
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
- package/dist/components/reui/filters.js +3 -3
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +1 -1
- package/dist/components/reui/gantt/gantt-view.js +3 -3
- package/dist/components/reui/icon-tile.d.ts +1 -1
- package/dist/components/reui/number-field.d.ts +3 -3
- package/dist/components/reui/phone-input.js +1 -1
- package/dist/components/reui/rating.d.ts +1 -1
- package/dist/components/ui/attachment.d.ts +3 -3
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/empty.d.ts +1 -1
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/questionnaire.d.ts +2 -1
- package/dist/components/ui/questionnaire.d.ts.map +1 -1
- package/dist/components/ui/questionnaire.js +11 -4
- package/dist/components/ui/questionnaire.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +2 -2
- package/dist/components/ui/toggle.d.ts +1 -1
- package/package.json +74 -9
package/README.md
CHANGED
|
@@ -30,15 +30,13 @@ This package is a maintained distribution: imports rewritten for monorepo (`@kum
|
|
|
30
30
|
bun add @kumix/ui @kumix/utils
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
Install peers (see `package.json` → `peerDependencies`).
|
|
33
|
+
Install peers (see `package.json` → `peerDependencies`). Six peers are **always required**: `react`, `@kumix/utils`, `@base-ui/react`, `class-variance-authority`, `lucide-react`, `motion`. The remaining 21 are **optional** via `peerDependenciesMeta` — install only what your imported components need.
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
bun add @base-ui/react class-variance-authority lucide-react react
|
|
36
|
+
bun add @base-ui/react class-variance-authority lucide-react motion react @kumix/utils
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
**
|
|
40
|
-
|
|
41
|
-
**Feature peers** (required in `package.json`; needed at runtime only if you import those components):
|
|
39
|
+
**Feature peers** (optional — needed at runtime only if you import those components):
|
|
42
40
|
|
|
43
41
|
| Peer | Used by |
|
|
44
42
|
| --------------------------------------------------- | ---------------------------------------------- |
|
|
@@ -136,7 +134,7 @@ Extended patterns. Preview: [reui.io](https://reui.io/docs).
|
|
|
136
134
|
|
|
137
135
|
Animated components built with [Motion](https://motion.dev). Preview: [beui.dev](https://beui.dev/components/motion). Bundled — `motion`, `lenis`, `@paper-design/shaders-react` are included, no extra installs needed.
|
|
138
136
|
|
|
139
|
-
`action-swap` · `animated-badge` · `animated-number` · `animated-sidebar` · `animated-toast-stack` · `attachment-upload` · `availability-scheduler/*` (copy-menu, day-row, time-select) · `bloom-menu` · `bottom-sheet` · `bounce-sidebar` · `bouncy-accordion` · `button/*` (base, stateful, magnetic) · `center-morph-modal` · `checkbox` · `chromatic-text-reveal` · `command-palette` · `context-menu` · `cylinder-carousel` · `dock` · `drawer` · `dynamic-island` · `expandable-action-bar` · `expandable-tabs` · `feedback-widget` · `file-upload` · `hold-action-button` · `infinite-masonry` · `input` · `loader` · `magnetic` · `marquee` · `morphing-modal` · `not-found/*` (glitch, magnetic, spotlight, stacked, terminal) · `notification-stack` · `number-ticker` · `otp-input` · `overflow-actions` · `parallax` · `popover` · `popover-morph` · `preview-rail` · `pull-to-refresh` · `radio` · `range-slider` (5 variants) · `scroll-progress` · `scroll-reveal` · `scroll-to` · `select` · `select-morph` · `shader-background` · `shared-layout-bg` · `slide-action-button` · `smooth-scroll` · `swipeable-list` · `switch` · `table/*` (virtualized, editable, async) · `tabs` · `text-cascade` · `text-reveal` · `text-shimmer` · `theme-toggle` · `tilt-card` · `tooltip` · `wheel-picker`
|
|
137
|
+
`action-swap` · `animated-badge` · `animated-number` · `animated-sidebar` · `animated-toast-stack` · `attachment-upload` · `availability-scheduler/*` (copy-menu, day-row, time-select) · `bloom-menu` · `bottom-sheet` · `bounce-sidebar` · `bouncy-accordion` · `button/*` (base, stateful, magnetic, `ButtonLink`) · `center-morph-modal` · `checkbox` · `chromatic-text-reveal` · `command-palette` · `context-menu` · `cylinder-carousel` · `dock` · `drawer` · `dynamic-island` · `expandable-action-bar` · `expandable-tabs` · `feedback-widget` · `file-upload` · `hold-action-button` · `infinite-masonry` · `input` · `loader` · `magnetic` · `marquee` · `morphing-modal` · `morphing-tabs` · `not-found/*` (glitch, magnetic, spotlight, stacked, terminal) · `notification-stack` · `number-ticker` · `otp-input` · `overflow-actions` · `parallax` · `popover` · `popover-morph` · `preview-rail` · `pull-to-refresh` · `radio` · `range-slider` (5 variants) · `scroll-progress` · `scroll-reveal` · `scroll-to` · `select` · `select-morph` · `shader-background` · `shared-layout-bg` · `slide-action-button` · `smooth-scroll` · `swipeable-list` · `switch` · `table/*` (virtualized, editable, async) · `tabs` · `text-cascade` · `text-reveal` · `text-shimmer` · `theme-toggle` · `tilt-card` · `tooltip` · `wheel-picker`
|
|
140
138
|
|
|
141
139
|
### beUI — AI Agents (`components/agents`)
|
|
142
140
|
|
|
@@ -212,11 +212,11 @@ const ToastItem = memo(function ToastItem({ toast, index, onDismiss, classNames,
|
|
|
212
212
|
children: /* @__PURE__ */ jsx("div", {
|
|
213
213
|
className: cn("relative overflow-hidden rounded-2xl border border-border bg-card/95 p-3 shadow-2xl backdrop-blur-xl", classNames?.surface),
|
|
214
214
|
children: renderToast ? renderToast(toast) : /* @__PURE__ */ jsxs("div", {
|
|
215
|
-
className: "flex items-
|
|
215
|
+
className: "flex items-center gap-3",
|
|
216
216
|
children: [
|
|
217
217
|
/* @__PURE__ */ jsx(motion.span, {
|
|
218
218
|
layout: true,
|
|
219
|
-
className: cn("
|
|
219
|
+
className: cn("inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full", STATUS_CLASS[status], classNames?.iconWrap),
|
|
220
220
|
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
221
221
|
mode: "popLayout",
|
|
222
222
|
initial: false,
|
|
@@ -271,7 +271,7 @@ const ToastItem = memo(function ToastItem({ toast, index, onDismiss, classNames,
|
|
|
271
271
|
},
|
|
272
272
|
transition: CONTENT_TRANSITION,
|
|
273
273
|
children: [/* @__PURE__ */ jsx("p", {
|
|
274
|
-
className: cn("
|
|
274
|
+
className: cn("font-medium text-foreground text-sm leading-5", classNames?.title),
|
|
275
275
|
children: toast.title
|
|
276
276
|
}), toast.description ? /* @__PURE__ */ jsx("p", {
|
|
277
277
|
className: cn("mt-0.5 line-clamp-2 text-muted-foreground text-xs leading-4", classNames?.description),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animated-toast-stack.js","names":[],"sources":["../../../src/components/motion/animated-toast-stack.tsx"],"sourcesContent":["\"use client\";\n\nimport { memo, type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { AlertCircle, Bell, Check, Info, LoaderCircle, type LucideIcon, X } from \"lucide-react\";\nimport { AnimatePresence, motion, type Transition, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type ToastStatus = \"neutral\" | \"info\" | \"loading\" | \"success\" | \"error\";\nexport type ToastPosition =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\";\n\nexport type AnimatedToastAction = {\n label: ReactNode;\n onClick: (toast: AnimatedToast) => void;\n};\n\nexport type AnimatedToast = {\n id: string;\n title: ReactNode;\n description?: ReactNode;\n status?: ToastStatus;\n icon?: ReactNode;\n action?: AnimatedToastAction;\n duration?: number;\n dismissible?: boolean;\n createdAt?: number;\n};\n\nexport type ToastInput = Omit<AnimatedToast, \"id\" | \"createdAt\"> & {\n id?: string;\n};\n\nexport type ToastClassNames = {\n root?: string;\n item?: string;\n surface?: string;\n iconWrap?: string;\n content?: string;\n title?: string;\n description?: string;\n action?: string;\n close?: string;\n progress?: string;\n};\n\nexport interface AnimatedToastStackProps {\n toasts: AnimatedToast[];\n onDismiss?: (id: string) => void;\n position?: ToastPosition;\n placement?: \"static\" | \"fixed\" | \"absolute\";\n fixed?: boolean;\n portal?: boolean;\n portalRoot?: Element | null;\n maxVisible?: number;\n className?: string;\n classNames?: ToastClassNames;\n icons?: Partial<Record<ToastStatus, ReactNode>>;\n renderToast?: (toast: AnimatedToast) => ReactNode;\n}\n\nexport interface UseAnimatedToastStackOptions {\n initialToasts?: ToastInput[];\n defaultDuration?: number;\n limit?: number;\n}\n\nconst STACK_SPRING: Transition = {\n type: \"spring\",\n stiffness: 420,\n damping: 34,\n mass: 0.75,\n};\n\nconst CONTENT_TRANSITION = {\n duration: 0.28,\n ease: EASE_OUT,\n} as const;\n\nconst STATUS_ICON: Record<ToastStatus, LucideIcon> = {\n neutral: Bell,\n info: Info,\n loading: LoaderCircle,\n success: Check,\n error: AlertCircle,\n};\n\nconst STATUS_CLASS: Record<ToastStatus, string> = {\n neutral: \"text-muted-foreground bg-primary/[0.05]\",\n info: \"text-primary bg-primary/10\",\n loading: \"text-primary bg-primary/10\",\n success: \"text-emerald-600 bg-emerald-500/10 dark:text-emerald-400\",\n error: \"text-destructive bg-destructive/10\",\n};\n\nconst POSITION_CLASS: Record<ToastPosition, string> = {\n \"top-left\": \"left-4 top-4\",\n \"top-center\": \"left-1/2 top-4 -translate-x-1/2\",\n \"top-right\": \"right-4 top-4\",\n \"bottom-left\": \"bottom-6 left-4\",\n \"bottom-center\": \"bottom-6 left-1/2 -translate-x-1/2\",\n \"bottom-right\": \"bottom-6 right-4\",\n};\n\nlet idSeed = 0;\n\nfunction createToast(input: ToastInput, defaultDuration: number): AnimatedToast {\n return {\n duration: defaultDuration,\n dismissible: true,\n ...input,\n id: input.id ?? `toast-${Date.now()}-${idSeed++}`,\n createdAt: Date.now(),\n };\n}\n\nexport function useAnimatedToastStack({\n initialToasts = [],\n defaultDuration = 4200,\n limit,\n}: UseAnimatedToastStackOptions = {}) {\n const toastTimers = useRef<Map<string, { timer: number; signature: string }>>(new Map());\n const [toasts, setToasts] = useState<AnimatedToast[]>(() =>\n initialToasts.map((toast) => createToast(toast, defaultDuration)),\n );\n\n const dismissToast = useCallback((id: string) => {\n setToasts((current) => current.filter((toast) => toast.id !== id));\n }, []);\n\n const clearToasts = useCallback(() => {\n setToasts([]);\n }, []);\n\n const showToast = useCallback(\n (input: ToastInput) => {\n const toast = createToast(input, defaultDuration);\n setToasts((current) => {\n const next = [...current, toast];\n return typeof limit === \"number\" ? next.slice(-limit) : next;\n });\n return toast.id;\n },\n [defaultDuration, limit],\n );\n\n const updateToast = useCallback((id: string, patch: Partial<ToastInput>) => {\n setToasts((current) =>\n current.map((toast) =>\n toast.id === id\n ? {\n ...toast,\n ...patch,\n id,\n createdAt: patch.duration === undefined ? toast.createdAt : Date.now(),\n }\n : toast,\n ),\n );\n }, []);\n\n useEffect(() => {\n const activeIds = new Set(toasts.map((toast) => toast.id));\n\n toastTimers.current.forEach((entry, id) => {\n if (!activeIds.has(id)) {\n window.clearTimeout(entry.timer);\n toastTimers.current.delete(id);\n }\n });\n\n toasts.forEach((toast) => {\n const duration = toast.duration ?? defaultDuration;\n const existing = toastTimers.current.get(toast.id);\n\n if (duration <= 0) {\n if (existing) {\n window.clearTimeout(existing.timer);\n toastTimers.current.delete(toast.id);\n }\n return;\n }\n\n const createdAt = toast.createdAt ?? Date.now();\n const signature = `${createdAt}:${duration}`;\n\n if (existing?.signature === signature) {\n return;\n }\n\n if (existing) {\n window.clearTimeout(existing.timer);\n }\n\n const elapsed = Date.now() - createdAt;\n const remaining = Math.max(duration - elapsed, 0);\n const timer = window.setTimeout(() => {\n toastTimers.current.delete(toast.id);\n dismissToast(toast.id);\n }, remaining);\n\n toastTimers.current.set(toast.id, { timer, signature });\n });\n }, [defaultDuration, dismissToast, toasts]);\n\n useEffect(() => {\n const timers = toastTimers.current;\n\n return () => {\n timers.forEach((entry) => {\n window.clearTimeout(entry.timer);\n });\n timers.clear();\n };\n }, []);\n\n return useMemo(\n () => ({\n toasts,\n showToast,\n updateToast,\n dismissToast,\n clearToasts,\n setToasts,\n }),\n [clearToasts, dismissToast, showToast, toasts, updateToast],\n );\n}\n\nexport function AnimatedToastStack({\n toasts,\n onDismiss,\n position = \"bottom-right\",\n placement,\n fixed = false,\n portal,\n portalRoot,\n maxVisible = 4,\n className,\n classNames,\n icons,\n renderToast,\n}: AnimatedToastStackProps) {\n const [portalTarget, setPortalTarget] = useState<Element | null>(null);\n const visibleToasts = toasts.slice(-maxVisible);\n const isBottom = position.startsWith(\"bottom\");\n const resolvedPlacement = placement ?? (fixed ? \"fixed\" : \"static\");\n const shouldPortal = portal ?? resolvedPlacement === \"fixed\";\n\n useEffect(() => {\n setPortalTarget(shouldPortal ? (portalRoot ?? document.body) : null);\n }, [portalRoot, shouldPortal]);\n\n const stack = (\n <ol\n aria-live=\"polite\"\n aria-atomic=\"false\"\n className={cn(\n \"pointer-events-none flex w-[calc(100vw-2rem)] max-w-sm gap-2\",\n isBottom ? \"flex-col-reverse\" : \"flex-col\",\n resolvedPlacement === \"fixed\" && \"fixed z-90\",\n resolvedPlacement === \"absolute\" && \"absolute z-20\",\n resolvedPlacement !== \"static\" && POSITION_CLASS[position],\n classNames?.root,\n className,\n )}\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n {visibleToasts.map((toast, index) => (\n <ToastItem\n key={toast.id}\n toast={toast}\n index={index}\n onDismiss={onDismiss}\n classNames={classNames}\n icons={icons}\n renderToast={renderToast}\n />\n ))}\n </AnimatePresence>\n </ol>\n );\n\n if (shouldPortal && !portalTarget) {\n return null;\n }\n\n if (shouldPortal && portalTarget) {\n return createPortal(stack, portalTarget);\n }\n\n return stack;\n}\n\nconst ToastItem = memo(function ToastItem({\n toast,\n index,\n onDismiss,\n classNames,\n icons,\n renderToast,\n}: {\n toast: AnimatedToast;\n index: number;\n onDismiss?: (id: string) => void;\n classNames?: ToastClassNames;\n icons?: Partial<Record<ToastStatus, ReactNode>>;\n renderToast?: (toast: AnimatedToast) => ReactNode;\n}) {\n const reduce = useReducedMotion();\n const status = toast.status ?? \"neutral\";\n const Icon = STATUS_ICON[status];\n const iconNode = icons?.[status] ?? toast.icon ?? <Icon className=\"h-3.5 w-3.5\" />;\n const canDismiss = toast.dismissible !== false && Boolean(onDismiss);\n\n return (\n <motion.li\n layout\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 22, scale: 0.96, filter: \"blur(10px)\" }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" }}\n exit={\n reduce\n ? { opacity: 0 }\n : {\n opacity: 0,\n x: 32,\n scale: 0.96,\n filter: \"blur(8px)\",\n transition: { duration: 0.18, ease: EASE_OUT },\n }\n }\n transition={STACK_SPRING}\n drag={canDismiss && !reduce ? \"x\" : false}\n dragConstraints={{ left: 0, right: 0 }}\n dragElastic={0.18}\n onDragEnd={(_, info) => {\n if (!canDismiss || !onDismiss) return;\n if (Math.abs(info.offset.x) > 72 || Math.abs(info.velocity.x) > 520) {\n onDismiss(toast.id);\n }\n }}\n className={cn(\"pointer-events-auto relative will-change-transform\", classNames?.item)}\n style={{ zIndex: 20 - index }}\n >\n <div\n className={cn(\n \"relative overflow-hidden rounded-2xl border border-border bg-card/95 p-3 shadow-2xl backdrop-blur-xl\",\n classNames?.surface,\n )}\n >\n {renderToast ? (\n renderToast(toast)\n ) : (\n <div className=\"flex items-start gap-3\">\n <motion.span\n layout\n className={cn(\n \"mt-0.5 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full\",\n STATUS_CLASS[status],\n classNames?.iconWrap,\n )}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.span\n key={status}\n initial={\n reduce ? { opacity: 0 } : { opacity: 0, y: 8, scale: 0.8, filter: \"blur(6px)\" }\n }\n animate={\n reduce ? { opacity: 1 } : { opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" }\n }\n exit={\n reduce ? { opacity: 0 } : { opacity: 0, y: -8, scale: 0.9, filter: \"blur(6px)\" }\n }\n transition={CONTENT_TRANSITION}\n className=\"inline-flex\"\n >\n {status === \"loading\" ? (\n <span className=\"inline-flex animate-spin\">{iconNode}</span>\n ) : (\n iconNode\n )}\n </motion.span>\n </AnimatePresence>\n </motion.span>\n\n <div className={cn(\"min-w-0 flex-1\", classNames?.content)}>\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.div\n key={`${toast.id}-${status}-${String(toast.title)}`}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 8, filter: \"blur(6px)\" }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -8, filter: \"blur(6px)\" }}\n transition={CONTENT_TRANSITION}\n >\n <p\n className={cn(\n \"truncate font-medium text-foreground text-sm leading-5\",\n classNames?.title,\n )}\n >\n {toast.title}\n </p>\n {toast.description ? (\n <p\n className={cn(\n \"mt-0.5 line-clamp-2 text-muted-foreground text-xs leading-4\",\n classNames?.description,\n )}\n >\n {toast.description}\n </p>\n ) : null}\n </motion.div>\n </AnimatePresence>\n\n {toast.action ? (\n <button\n type=\"button\"\n onClick={() => toast.action?.onClick(toast)}\n className={cn(\n \"mt-2 inline-flex h-7 items-center rounded-full bg-primary/6 px-3 font-medium text-foreground text-xs transition-colors hover:bg-primary/10\",\n classNames?.action,\n )}\n >\n {toast.action.label}\n </button>\n ) : null}\n </div>\n\n {canDismiss ? (\n <button\n type=\"button\"\n onClick={() => onDismiss?.(toast.id)}\n aria-label=\"Dismiss toast\"\n className={cn(\n \"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-primary/6 hover:text-foreground\",\n classNames?.close,\n )}\n >\n <X className=\"h-3.5 w-3.5\" />\n </button>\n ) : null}\n </div>\n )}\n </div>\n </motion.li>\n );\n});\n"],"mappings":";;;;;;;;;AA0EA,MAAM,eAA2B;CAC/B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,qBAAqB;CACzB,UAAU;CACV,MAAM;AACR;AAEA,MAAM,cAA+C;CACnD,SAAS;CACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAM,eAA4C;CAChD,SAAS;CACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAM,iBAAgD;CACpD,YAAY;CACZ,cAAc;CACd,aAAa;CACb,eAAe;CACf,iBAAiB;CACjB,gBAAgB;AAClB;AAEA,IAAI,SAAS;AAEb,SAAS,YAAY,OAAmB,iBAAwC;CAC9E,OAAO;EACL,UAAU;EACV,aAAa;EACb,GAAG;EACH,IAAI,MAAM,MAAM,SAAS,KAAK,IAAI,EAAE,GAAG;EACvC,WAAW,KAAK,IAAI;CACtB;AACF;AAEA,SAAgB,sBAAsB,EACpC,gBAAgB,CAAC,GACjB,kBAAkB,MAClB,UACgC,CAAC,GAAG;CACpC,MAAM,cAAc,uBAA0D,IAAI,IAAI,CAAC;CACvF,MAAM,CAAC,QAAQ,aAAa,eAC1B,cAAc,KAAK,UAAU,YAAY,OAAO,eAAe,CAAC,CAClE;CAEA,MAAM,eAAe,aAAa,OAAe;EAC/C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YAAY,KACd;SAEC,UAAA,MAAM;QACN,CAAA,GACF,MAAM,cACL,oBAAC,KAAD;SACE,WAAW,GACT,+DACA,YAAY,WACd;SAEC,UAAA,MAAM;QACN,CAAA,IACD,IACM;OAxBL,GAAA,GAAG,MAAM,GAAG,GAAG,OAAO,GAAG,OAAO,MAAM,KAAK,GAwBtC;MACG,CAAA,GAEhB,MAAM,SACL,oBAAC,UAAD;OACE,MAAK;OACL,eAAe,MAAM,QAAQ,QAAQ,KAAK;OAC1C,WAAW,GACT,8IACA,YAAY,MACd;OAEC,UAAA,MAAM,OAAO;MACR,CAAA,IACN,IACD;;KAEJ,aACC,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,YAAY,MAAM,EAAE;MACnC,cAAW;MACX,WAAW,GACT,0JACA,YAAY,KACd;MAEA,UAAA,oBAAC,GAAD,EAAG,WAAU,cAAe,CAAA;KACtB,CAAA,IACN;IACD;;EAEJ,CAAA;CACI,CAAA;AAEf,CAAC"}
|
|
1
|
+
{"version":3,"file":"animated-toast-stack.js","names":[],"sources":["../../../src/components/motion/animated-toast-stack.tsx"],"sourcesContent":["\"use client\";\n\nimport { memo, type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { AlertCircle, Bell, Check, Info, LoaderCircle, type LucideIcon, X } from \"lucide-react\";\nimport { AnimatePresence, motion, type Transition, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type ToastStatus = \"neutral\" | \"info\" | \"loading\" | \"success\" | \"error\";\nexport type ToastPosition =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\";\n\nexport type AnimatedToastAction = {\n label: ReactNode;\n onClick: (toast: AnimatedToast) => void;\n};\n\nexport type AnimatedToast = {\n id: string;\n title: ReactNode;\n description?: ReactNode;\n status?: ToastStatus;\n icon?: ReactNode;\n action?: AnimatedToastAction;\n duration?: number;\n dismissible?: boolean;\n createdAt?: number;\n};\n\nexport type ToastInput = Omit<AnimatedToast, \"id\" | \"createdAt\"> & {\n id?: string;\n};\n\nexport type ToastClassNames = {\n root?: string;\n item?: string;\n surface?: string;\n iconWrap?: string;\n content?: string;\n title?: string;\n description?: string;\n action?: string;\n close?: string;\n progress?: string;\n};\n\nexport interface AnimatedToastStackProps {\n toasts: AnimatedToast[];\n onDismiss?: (id: string) => void;\n position?: ToastPosition;\n placement?: \"static\" | \"fixed\" | \"absolute\";\n fixed?: boolean;\n portal?: boolean;\n portalRoot?: Element | null;\n maxVisible?: number;\n className?: string;\n classNames?: ToastClassNames;\n icons?: Partial<Record<ToastStatus, ReactNode>>;\n renderToast?: (toast: AnimatedToast) => ReactNode;\n}\n\nexport interface UseAnimatedToastStackOptions {\n initialToasts?: ToastInput[];\n defaultDuration?: number;\n limit?: number;\n}\n\nconst STACK_SPRING: Transition = {\n type: \"spring\",\n stiffness: 420,\n damping: 34,\n mass: 0.75,\n};\n\nconst CONTENT_TRANSITION = {\n duration: 0.28,\n ease: EASE_OUT,\n} as const;\n\nconst STATUS_ICON: Record<ToastStatus, LucideIcon> = {\n neutral: Bell,\n info: Info,\n loading: LoaderCircle,\n success: Check,\n error: AlertCircle,\n};\n\nconst STATUS_CLASS: Record<ToastStatus, string> = {\n neutral: \"text-muted-foreground bg-primary/[0.05]\",\n info: \"text-primary bg-primary/10\",\n loading: \"text-primary bg-primary/10\",\n success: \"text-emerald-600 bg-emerald-500/10 dark:text-emerald-400\",\n error: \"text-destructive bg-destructive/10\",\n};\n\nconst POSITION_CLASS: Record<ToastPosition, string> = {\n \"top-left\": \"left-4 top-4\",\n \"top-center\": \"left-1/2 top-4 -translate-x-1/2\",\n \"top-right\": \"right-4 top-4\",\n \"bottom-left\": \"bottom-6 left-4\",\n \"bottom-center\": \"bottom-6 left-1/2 -translate-x-1/2\",\n \"bottom-right\": \"bottom-6 right-4\",\n};\n\nlet idSeed = 0;\n\nfunction createToast(input: ToastInput, defaultDuration: number): AnimatedToast {\n return {\n duration: defaultDuration,\n dismissible: true,\n ...input,\n id: input.id ?? `toast-${Date.now()}-${idSeed++}`,\n createdAt: Date.now(),\n };\n}\n\nexport function useAnimatedToastStack({\n initialToasts = [],\n defaultDuration = 4200,\n limit,\n}: UseAnimatedToastStackOptions = {}) {\n const toastTimers = useRef<Map<string, { timer: number; signature: string }>>(new Map());\n const [toasts, setToasts] = useState<AnimatedToast[]>(() =>\n initialToasts.map((toast) => createToast(toast, defaultDuration)),\n );\n\n const dismissToast = useCallback((id: string) => {\n setToasts((current) => current.filter((toast) => toast.id !== id));\n }, []);\n\n const clearToasts = useCallback(() => {\n setToasts([]);\n }, []);\n\n const showToast = useCallback(\n (input: ToastInput) => {\n const toast = createToast(input, defaultDuration);\n setToasts((current) => {\n const next = [...current, toast];\n return typeof limit === \"number\" ? next.slice(-limit) : next;\n });\n return toast.id;\n },\n [defaultDuration, limit],\n );\n\n const updateToast = useCallback((id: string, patch: Partial<ToastInput>) => {\n setToasts((current) =>\n current.map((toast) =>\n toast.id === id\n ? {\n ...toast,\n ...patch,\n id,\n createdAt: patch.duration === undefined ? toast.createdAt : Date.now(),\n }\n : toast,\n ),\n );\n }, []);\n\n useEffect(() => {\n const activeIds = new Set(toasts.map((toast) => toast.id));\n\n toastTimers.current.forEach((entry, id) => {\n if (!activeIds.has(id)) {\n window.clearTimeout(entry.timer);\n toastTimers.current.delete(id);\n }\n });\n\n toasts.forEach((toast) => {\n const duration = toast.duration ?? defaultDuration;\n const existing = toastTimers.current.get(toast.id);\n\n if (duration <= 0) {\n if (existing) {\n window.clearTimeout(existing.timer);\n toastTimers.current.delete(toast.id);\n }\n return;\n }\n\n const createdAt = toast.createdAt ?? Date.now();\n const signature = `${createdAt}:${duration}`;\n\n if (existing?.signature === signature) {\n return;\n }\n\n if (existing) {\n window.clearTimeout(existing.timer);\n }\n\n const elapsed = Date.now() - createdAt;\n const remaining = Math.max(duration - elapsed, 0);\n const timer = window.setTimeout(() => {\n toastTimers.current.delete(toast.id);\n dismissToast(toast.id);\n }, remaining);\n\n toastTimers.current.set(toast.id, { timer, signature });\n });\n }, [defaultDuration, dismissToast, toasts]);\n\n useEffect(() => {\n const timers = toastTimers.current;\n\n return () => {\n timers.forEach((entry) => {\n window.clearTimeout(entry.timer);\n });\n timers.clear();\n };\n }, []);\n\n return useMemo(\n () => ({\n toasts,\n showToast,\n updateToast,\n dismissToast,\n clearToasts,\n setToasts,\n }),\n [clearToasts, dismissToast, showToast, toasts, updateToast],\n );\n}\n\nexport function AnimatedToastStack({\n toasts,\n onDismiss,\n position = \"bottom-right\",\n placement,\n fixed = false,\n portal,\n portalRoot,\n maxVisible = 4,\n className,\n classNames,\n icons,\n renderToast,\n}: AnimatedToastStackProps) {\n const [portalTarget, setPortalTarget] = useState<Element | null>(null);\n const visibleToasts = toasts.slice(-maxVisible);\n const isBottom = position.startsWith(\"bottom\");\n const resolvedPlacement = placement ?? (fixed ? \"fixed\" : \"static\");\n const shouldPortal = portal ?? resolvedPlacement === \"fixed\";\n\n useEffect(() => {\n setPortalTarget(shouldPortal ? (portalRoot ?? document.body) : null);\n }, [portalRoot, shouldPortal]);\n\n const stack = (\n <ol\n aria-live=\"polite\"\n aria-atomic=\"false\"\n className={cn(\n \"pointer-events-none flex w-[calc(100vw-2rem)] max-w-sm gap-2\",\n isBottom ? \"flex-col-reverse\" : \"flex-col\",\n resolvedPlacement === \"fixed\" && \"fixed z-90\",\n resolvedPlacement === \"absolute\" && \"absolute z-20\",\n resolvedPlacement !== \"static\" && POSITION_CLASS[position],\n classNames?.root,\n className,\n )}\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n {visibleToasts.map((toast, index) => (\n <ToastItem\n key={toast.id}\n toast={toast}\n index={index}\n onDismiss={onDismiss}\n classNames={classNames}\n icons={icons}\n renderToast={renderToast}\n />\n ))}\n </AnimatePresence>\n </ol>\n );\n\n if (shouldPortal && !portalTarget) {\n return null;\n }\n\n if (shouldPortal && portalTarget) {\n return createPortal(stack, portalTarget);\n }\n\n return stack;\n}\n\nconst ToastItem = memo(function ToastItem({\n toast,\n index,\n onDismiss,\n classNames,\n icons,\n renderToast,\n}: {\n toast: AnimatedToast;\n index: number;\n onDismiss?: (id: string) => void;\n classNames?: ToastClassNames;\n icons?: Partial<Record<ToastStatus, ReactNode>>;\n renderToast?: (toast: AnimatedToast) => ReactNode;\n}) {\n const reduce = useReducedMotion();\n const status = toast.status ?? \"neutral\";\n const Icon = STATUS_ICON[status];\n const iconNode = icons?.[status] ?? toast.icon ?? <Icon className=\"h-3.5 w-3.5\" />;\n const canDismiss = toast.dismissible !== false && Boolean(onDismiss);\n\n return (\n <motion.li\n layout\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 22, scale: 0.96, filter: \"blur(10px)\" }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" }}\n exit={\n reduce\n ? { opacity: 0 }\n : {\n opacity: 0,\n x: 32,\n scale: 0.96,\n filter: \"blur(8px)\",\n transition: { duration: 0.18, ease: EASE_OUT },\n }\n }\n transition={STACK_SPRING}\n drag={canDismiss && !reduce ? \"x\" : false}\n dragConstraints={{ left: 0, right: 0 }}\n dragElastic={0.18}\n onDragEnd={(_, info) => {\n if (!canDismiss || !onDismiss) return;\n if (Math.abs(info.offset.x) > 72 || Math.abs(info.velocity.x) > 520) {\n onDismiss(toast.id);\n }\n }}\n className={cn(\"pointer-events-auto relative will-change-transform\", classNames?.item)}\n style={{ zIndex: 20 - index }}\n >\n <div\n className={cn(\n \"relative overflow-hidden rounded-2xl border border-border bg-card/95 p-3 shadow-2xl backdrop-blur-xl\",\n classNames?.surface,\n )}\n >\n {renderToast ? (\n renderToast(toast)\n ) : (\n <div className=\"flex items-center gap-3\">\n <motion.span\n layout\n className={cn(\n \"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full\",\n STATUS_CLASS[status],\n classNames?.iconWrap,\n )}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.span\n key={status}\n initial={\n reduce ? { opacity: 0 } : { opacity: 0, y: 8, scale: 0.8, filter: \"blur(6px)\" }\n }\n animate={\n reduce ? { opacity: 1 } : { opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" }\n }\n exit={\n reduce ? { opacity: 0 } : { opacity: 0, y: -8, scale: 0.9, filter: \"blur(6px)\" }\n }\n transition={CONTENT_TRANSITION}\n className=\"inline-flex\"\n >\n {status === \"loading\" ? (\n <span className=\"inline-flex animate-spin\">{iconNode}</span>\n ) : (\n iconNode\n )}\n </motion.span>\n </AnimatePresence>\n </motion.span>\n\n <div className={cn(\"min-w-0 flex-1\", classNames?.content)}>\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.div\n key={`${toast.id}-${status}-${String(toast.title)}`}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 8, filter: \"blur(6px)\" }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -8, filter: \"blur(6px)\" }}\n transition={CONTENT_TRANSITION}\n >\n <p\n className={cn(\n \"font-medium text-foreground text-sm leading-5\",\n classNames?.title,\n )}\n >\n {toast.title}\n </p>\n {toast.description ? (\n <p\n className={cn(\n \"mt-0.5 line-clamp-2 text-muted-foreground text-xs leading-4\",\n classNames?.description,\n )}\n >\n {toast.description}\n </p>\n ) : null}\n </motion.div>\n </AnimatePresence>\n\n {toast.action ? (\n <button\n type=\"button\"\n onClick={() => toast.action?.onClick(toast)}\n className={cn(\n \"mt-2 inline-flex h-7 items-center rounded-full bg-primary/6 px-3 font-medium text-foreground text-xs transition-colors hover:bg-primary/10\",\n classNames?.action,\n )}\n >\n {toast.action.label}\n </button>\n ) : null}\n </div>\n\n {canDismiss ? (\n <button\n type=\"button\"\n onClick={() => onDismiss?.(toast.id)}\n aria-label=\"Dismiss toast\"\n className={cn(\n \"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-primary/6 hover:text-foreground\",\n classNames?.close,\n )}\n >\n <X className=\"h-3.5 w-3.5\" />\n </button>\n ) : null}\n </div>\n )}\n </div>\n </motion.li>\n );\n});\n"],"mappings":";;;;;;;;;AA0EA,MAAM,eAA2B;CAC/B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,qBAAqB;CACzB,UAAU;CACV,MAAM;AACR;AAEA,MAAM,cAA+C;CACnD,SAAS;CACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAM,eAA4C;CAChD,SAAS;CACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAM,iBAAgD;CACpD,YAAY;CACZ,cAAc;CACd,aAAa;CACb,eAAe;CACf,iBAAiB;CACjB,gBAAgB;AAClB;AAEA,IAAI,SAAS;AAEb,SAAS,YAAY,OAAmB,iBAAwC;CAC9E,OAAO;EACL,UAAU;EACV,aAAa;EACb,GAAG;EACH,IAAI,MAAM,MAAM,SAAS,KAAK,IAAI,EAAE,GAAG;EACvC,WAAW,KAAK,IAAI;CACtB;AACF;AAEA,SAAgB,sBAAsB,EACpC,gBAAgB,CAAC,GACjB,kBAAkB,MAClB,UACgC,CAAC,GAAG;CACpC,MAAM,cAAc,uBAA0D,IAAI,IAAI,CAAC;CACvF,MAAM,CAAC,QAAQ,aAAa,eAC1B,cAAc,KAAK,UAAU,YAAY,OAAO,eAAe,CAAC,CAClE;CAEA,MAAM,eAAe,aAAa,OAAe;EAC/C,WAAW,YAAY,QAAQ,QAAQ,UAAU,MAAM,OAAO,EAAE,CAAC;CACnE,GAAG,CAAC,CAAC;CAEL,MAAM,cAAc,kBAAkB;EACpC,UAAU,CAAC,CAAC;CACd,GAAG,CAAC,CAAC;CAEL,MAAM,YAAY,aACf,UAAsB;EACrB,MAAM,QAAQ,YAAY,OAAO,eAAe;EAChD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AEhB,MAAM,SACL,oBAAC,UAAD;OACE,MAAK;OACL,eAAe,MAAM,QAAQ,QAAQ,KAAK;OAC1C,WAAW,GACT,8IACA,YAAY,MACd;OAEC,UAAA,MAAM,OAAO;MACR,CAAA,IACN,IACD;;KAEJ,aACC,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,YAAY,MAAM,EAAE;MACnC,cAAW;MACX,WAAW,GACT,0JACA,YAAY,KACd;MAEA,UAAA,oBAAC,GAAD,EAAG,WAAU,cAAe,CAAA;KACtB,CAAA,IACN;IACD;;EAEJ,CAAA;CACI,CAAA;AAEf,CAAC"}
|
|
@@ -11,7 +11,14 @@ interface ButtonProps extends Omit<HTMLMotionProps<"button">, "children"> {
|
|
|
11
11
|
ripple?: boolean;
|
|
12
12
|
children?: ReactNode;
|
|
13
13
|
}
|
|
14
|
+
interface ButtonLinkProps extends Omit<HTMLMotionProps<"a">, "children"> {
|
|
15
|
+
variant?: ButtonVariant;
|
|
16
|
+
size?: ButtonSize;
|
|
17
|
+
pressScale?: number;
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
}
|
|
14
20
|
declare const Button: import("react").ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
21
|
+
declare const ButtonLink: import("react").ForwardRefExoticComponent<Omit<ButtonLinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
15
22
|
//#endregion
|
|
16
|
-
export { Button, ButtonProps, ButtonSize, ButtonVariant };
|
|
23
|
+
export { Button, ButtonLink, ButtonLinkProps, ButtonProps, ButtonSize, ButtonVariant };
|
|
17
24
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","names":[],"sources":["../../../../src/components/motion/button/base.tsx"],"mappings":";;;KAgBY;KACA;UAEK,oBAAoB,KAAK;EACxC,UAAU;EACV,OAAO;EACP;;EAEA;EACA,WAAW;;cAmBA,wBAAM,0BAAA,KAAA,sCAAA,cAAA"}
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":[],"sources":["../../../../src/components/motion/button/base.tsx"],"mappings":";;;KAgBY;KACA;UAEK,oBAAoB,KAAK;EACxC,UAAU;EACV,OAAO;EACP;;EAEA;EACA,WAAW;;UAGI,wBAAwB,KAAK;EAC5C,UAAU;EACV,OAAO;EACP;EACA,WAAW;;cAmBA,wBAAM,0BAAA,KAAA,sCAAA,cAAA;cAwFN,4BAAU,0BAAA,KAAA,0CAAA,cAAA"}
|
|
@@ -80,7 +80,20 @@ const Button = forwardRef(function Button({ variant = "primary", size = "md", pr
|
|
|
80
80
|
}) : null, children]
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
|
+
const ButtonLink = forwardRef(function ButtonLink({ variant = "primary", size = "md", pressScale = .93, className, children, ...rest }, ref) {
|
|
84
|
+
const reduce = useReducedMotion();
|
|
85
|
+
const canHover = useHoverCapable();
|
|
86
|
+
return /* @__PURE__ */ jsx(motion.a, {
|
|
87
|
+
ref,
|
|
88
|
+
whileTap: reduce ? void 0 : { scale: pressScale },
|
|
89
|
+
whileHover: reduce || !canHover ? void 0 : { scale: 1.02 },
|
|
90
|
+
transition: SPRING_PRESS,
|
|
91
|
+
className: cn("inline-flex select-none items-center justify-center font-medium", "transition-colors", VARIANT_CLASS[variant], SIZE_CLASS[size], className),
|
|
92
|
+
...rest,
|
|
93
|
+
children
|
|
94
|
+
});
|
|
95
|
+
});
|
|
83
96
|
//#endregion
|
|
84
|
-
export { Button };
|
|
97
|
+
export { Button, ButtonLink };
|
|
85
98
|
|
|
86
99
|
//# sourceMappingURL=base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":[],"sources":["../../../../src/components/motion/button/base.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n forwardRef,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useRef,\n useState,\n} from \"react\";\nimport { AnimatePresence, type HTMLMotionProps, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../../hooks/use-hover-capable\";\nimport { EASE_OUT, SPRING_PRESS } from \"../../../lib/ease\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"ghost\" | \"outline\";\nexport type ButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\n\nexport interface ButtonProps extends Omit<HTMLMotionProps<\"button\">, \"children\"> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n pressScale?: number;\n /** Spawn a Material-style ripple from the press point. Off by default. */\n ripple?: boolean;\n children?: ReactNode;\n}\n\ntype Ripple = { id: number; x: number; y: number; size: number };\n\nconst VARIANT_CLASS: Record<ButtonVariant, string> = {\n primary: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n secondary: \"border border-border bg-card text-foreground hover:border-border\",\n ghost: \"text-muted-foreground hover:text-foreground hover:bg-primary/5\",\n outline: \"border border-border bg-transparent text-foreground hover:bg-primary/5\",\n};\n\nconst SIZE_CLASS: Record<ButtonSize, string> = {\n sm: \"h-8 px-3 text-xs gap-1.5 rounded-full\",\n md: \"h-10 px-5 text-sm gap-2 rounded-full\",\n lg: \"h-12 px-6 text-base gap-2 rounded-full\",\n icon: \"h-8 w-8 rounded-lg\",\n};\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = \"primary\",\n size = \"md\",\n pressScale = 0.93,\n ripple = false,\n className,\n children,\n onPointerDown,\n ...rest\n },\n ref,\n) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const [ripples, setRipples] = useState<Ripple[]>([]);\n const nextId = useRef(0);\n\n const handlePointerDown = useCallback(\n (event: PointerEvent<HTMLButtonElement>) => {\n if (ripple && !reduce) {\n const rect = event.currentTarget.getBoundingClientRect();\n const size = Math.max(rect.width, rect.height) * 2;\n const id = nextId.current++;\n setRipples((prev) => [\n ...prev,\n {\n id,\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n size,\n },\n ]);\n }\n onPointerDown?.(event);\n },\n [ripple, reduce, onPointerDown],\n );\n\n return (\n <motion.button\n ref={ref}\n type=\"button\"\n whileTap={reduce ? undefined : { scale: pressScale }}\n whileHover={reduce || !canHover ? undefined : { scale: 1.02 }}\n transition={SPRING_PRESS}\n onPointerDown={handlePointerDown}\n className={cn(\n \"inline-flex select-none items-center justify-center font-medium\",\n \"transition-colors\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n ripple && \"relative overflow-hidden\",\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n className,\n )}\n {...rest}\n >\n {ripple && !reduce ? (\n <span className=\"pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]\">\n <AnimatePresence>\n {ripples.map((r) => (\n <motion.span\n key={r.id}\n className=\"absolute rounded-full bg-current\"\n style={{\n left: r.x,\n top: r.y,\n width: r.size,\n height: r.size,\n x: \"-50%\",\n y: \"-50%\",\n }}\n initial={{ scale: 0.05, opacity: 0.3 }}\n animate={{ scale: 1, opacity: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 1.6, ease: EASE_OUT }}\n onAnimationComplete={() => setRipples((prev) => prev.filter((x) => x.id !== r.id))}\n />\n ))}\n </AnimatePresence>\n </span>\n ) : null}\n {children}\n </motion.button>\n );\n});\n"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"base.js","names":[],"sources":["../../../../src/components/motion/button/base.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n forwardRef,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useRef,\n useState,\n} from \"react\";\nimport { AnimatePresence, type HTMLMotionProps, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../../hooks/use-hover-capable\";\nimport { EASE_OUT, SPRING_PRESS } from \"../../../lib/ease\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"ghost\" | \"outline\";\nexport type ButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\n\nexport interface ButtonProps extends Omit<HTMLMotionProps<\"button\">, \"children\"> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n pressScale?: number;\n /** Spawn a Material-style ripple from the press point. Off by default. */\n ripple?: boolean;\n children?: ReactNode;\n}\n\nexport interface ButtonLinkProps extends Omit<HTMLMotionProps<\"a\">, \"children\"> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n pressScale?: number;\n children?: ReactNode;\n}\n\ntype Ripple = { id: number; x: number; y: number; size: number };\n\nconst VARIANT_CLASS: Record<ButtonVariant, string> = {\n primary: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n secondary: \"border border-border bg-card text-foreground hover:border-border\",\n ghost: \"text-muted-foreground hover:text-foreground hover:bg-primary/5\",\n outline: \"border border-border bg-transparent text-foreground hover:bg-primary/5\",\n};\n\nconst SIZE_CLASS: Record<ButtonSize, string> = {\n sm: \"h-8 px-3 text-xs gap-1.5 rounded-full\",\n md: \"h-10 px-5 text-sm gap-2 rounded-full\",\n lg: \"h-12 px-6 text-base gap-2 rounded-full\",\n icon: \"h-8 w-8 rounded-lg\",\n};\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = \"primary\",\n size = \"md\",\n pressScale = 0.93,\n ripple = false,\n className,\n children,\n onPointerDown,\n ...rest\n },\n ref,\n) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const [ripples, setRipples] = useState<Ripple[]>([]);\n const nextId = useRef(0);\n\n const handlePointerDown = useCallback(\n (event: PointerEvent<HTMLButtonElement>) => {\n if (ripple && !reduce) {\n const rect = event.currentTarget.getBoundingClientRect();\n const size = Math.max(rect.width, rect.height) * 2;\n const id = nextId.current++;\n setRipples((prev) => [\n ...prev,\n {\n id,\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n size,\n },\n ]);\n }\n onPointerDown?.(event);\n },\n [ripple, reduce, onPointerDown],\n );\n\n return (\n <motion.button\n ref={ref}\n type=\"button\"\n whileTap={reduce ? undefined : { scale: pressScale }}\n whileHover={reduce || !canHover ? undefined : { scale: 1.02 }}\n transition={SPRING_PRESS}\n onPointerDown={handlePointerDown}\n className={cn(\n \"inline-flex select-none items-center justify-center font-medium\",\n \"transition-colors\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n ripple && \"relative overflow-hidden\",\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n className,\n )}\n {...rest}\n >\n {ripple && !reduce ? (\n <span className=\"pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]\">\n <AnimatePresence>\n {ripples.map((r) => (\n <motion.span\n key={r.id}\n className=\"absolute rounded-full bg-current\"\n style={{\n left: r.x,\n top: r.y,\n width: r.size,\n height: r.size,\n x: \"-50%\",\n y: \"-50%\",\n }}\n initial={{ scale: 0.05, opacity: 0.3 }}\n animate={{ scale: 1, opacity: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 1.6, ease: EASE_OUT }}\n onAnimationComplete={() => setRipples((prev) => prev.filter((x) => x.id !== r.id))}\n />\n ))}\n </AnimatePresence>\n </span>\n ) : null}\n {children}\n </motion.button>\n );\n});\n\nexport const ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(function ButtonLink(\n { variant = \"primary\", size = \"md\", pressScale = 0.93, className, children, ...rest },\n ref,\n) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n\n return (\n <motion.a\n ref={ref}\n whileTap={reduce ? undefined : { scale: pressScale }}\n whileHover={reduce || !canHover ? undefined : { scale: 1.02 }}\n transition={SPRING_PRESS}\n className={cn(\n \"inline-flex select-none items-center justify-center font-medium\",\n \"transition-colors\",\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n className,\n )}\n {...rest}\n >\n {children}\n </motion.a>\n );\n});\n"],"mappings":";;;;;;;;AAqCA,MAAM,gBAA+C;CACnD,SAAS;CACT,WAAW;CACX,OAAO;CACP,SAAS;AACX;AAEA,MAAM,aAAyC;CAC7C,IAAI;CACJ,IAAI;CACJ,IAAI;CAC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;IAAE;IAChC,MAAM,EAAE,SAAS,EAAE;IACnB,YAAY;KAAE,UAAU;KAAK,MAAM;IAAS;IAC5C,2BAA2B,YAAY,SAAS,KAAK,QAAQ,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;GAClF,GAfM,EAAE,EAeR,CACF,EACc,CAAA;EACb,CAAA,IACJ,MACH,QACY;;AAEnB,CAAC;AAED,MAAa,aAAa,WAA+C,SAAS,WAChF,EAAE,UAAU,WAAW,OAAO,MAAM,aAAa,KAAM,WAAW,UAAU,GAAG,QAC/E,KACA;CACA,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,gBAAgB;CAEjC,OACE,oBAAC,OAAO,GAAR;EACO;EACL,UAAU,SAAS,KAAA,IAAY,EAAE,OAAO,WAAW;EACnD,YAAY,UAAU,CAAC,WAAW,KAAA,IAAY,EAAE,OAAO,KAAK;EAC5D,YAAY;EACZ,WAAW,GACT,mEACA,qBACA,cAAc,UACd,WAAW,OACX,SACF;EACA,GAAI;EAEH;CACO,CAAA;AAEd,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, ButtonProps, ButtonSize, ButtonVariant } from "./base.js";
|
|
1
|
+
import { Button, ButtonLink, ButtonLinkProps, ButtonProps, ButtonSize, ButtonVariant } from "./base.js";
|
|
2
2
|
import { MagneticButton, MagneticButtonProps } from "./magnetic.js";
|
|
3
3
|
import { ButtonState, StatefulButton, StatefulButtonProps } from "./stateful.js";
|
|
4
|
-
export { Button, type ButtonProps, type ButtonSize, type ButtonState, type ButtonVariant, MagneticButton, type MagneticButtonProps, StatefulButton, type StatefulButtonProps };
|
|
4
|
+
export { Button, ButtonLink, type ButtonLinkProps, type ButtonProps, type ButtonSize, type ButtonState, type ButtonVariant, MagneticButton, type MagneticButtonProps, StatefulButton, type StatefulButtonProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Button } from "./base.js";
|
|
2
|
+
import { Button, ButtonLink } from "./base.js";
|
|
3
3
|
import { MagneticButton } from "./magnetic.js";
|
|
4
4
|
import { StatefulButton } from "./stateful.js";
|
|
5
|
-
export { Button, MagneticButton, StatefulButton };
|
|
5
|
+
export { Button, ButtonLink, MagneticButton, StatefulButton };
|
|
@@ -8,8 +8,10 @@ interface CheckboxProps {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
id?: string;
|
|
10
10
|
"aria-label"?: string;
|
|
11
|
+
/** Associates an external message (e.g. a form error) with the control. */
|
|
12
|
+
"aria-describedby"?: string;
|
|
11
13
|
}
|
|
12
|
-
declare function Checkbox({ checked, onCheckedChange, disabled, indeterminate, label, className, id: idProp, "aria-label": ariaLabel }: CheckboxProps): import("react").JSX.Element;
|
|
14
|
+
declare function Checkbox({ checked, onCheckedChange, disabled, indeterminate, label, className, id: idProp, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy }: CheckboxProps): import("react").JSX.Element;
|
|
13
15
|
//#endregion
|
|
14
16
|
export { Checkbox, CheckboxProps };
|
|
15
17
|
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","names":[],"sources":["../../../src/components/motion/checkbox.tsx"],"mappings":";UAWiB;EACf;EACA,kBAAkB;EAClB;EACA;EACA;EACA;EACA;EACA;;iBAGc,WACd,SACA,iBACA,UACA,eACA,OACA,WACA,IAAI,sBACU,
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","names":[],"sources":["../../../src/components/motion/checkbox.tsx"],"mappings":";UAWiB;EACf;EACA,kBAAkB;EAClB;EACA;EACA;EACA;EACA;EACA;;EAEA;;iBAGc,WACd,SACA,iBACA,UACA,eACA,OACA,WACA,IAAI,sBACU,+BACM,mBACnB,gCAAa,IAAA"}
|
|
@@ -7,7 +7,7 @@ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
|
7
7
|
//#region src/components/motion/checkbox.tsx
|
|
8
8
|
const CHECK_PATH = "M5 13l4 4L19 7";
|
|
9
9
|
const INDETERMINATE_PATH = "M6 12h12";
|
|
10
|
-
function Checkbox({ checked, onCheckedChange, disabled, indeterminate, label, className, id: idProp, "aria-label": ariaLabel }) {
|
|
10
|
+
function Checkbox({ checked, onCheckedChange, disabled, indeterminate, label, className, id: idProp, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy }) {
|
|
11
11
|
const autoId = useId();
|
|
12
12
|
const id = idProp ?? autoId;
|
|
13
13
|
const reduce = useReducedMotion();
|
|
@@ -22,6 +22,7 @@ function Checkbox({ checked, onCheckedChange, disabled, indeterminate, label, cl
|
|
|
22
22
|
role: "checkbox",
|
|
23
23
|
"aria-checked": indeterminate ? "mixed" : checked,
|
|
24
24
|
"aria-label": ariaLabel,
|
|
25
|
+
"aria-describedby": ariaDescribedBy,
|
|
25
26
|
disabled,
|
|
26
27
|
onClick: () => !disabled && onCheckedChange(!checked),
|
|
27
28
|
whileTap: reduce || disabled ? void 0 : { scale: .92 },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","names":[],"sources":["../../../src/components/motion/checkbox.tsx"],"sourcesContent":["\"use client\";\n\nimport { useId } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PRESS } from \"../../lib/ease\";\n\nconst CHECK_PATH = \"M5 13l4 4L19 7\";\nconst INDETERMINATE_PATH = \"M6 12h12\";\n\nexport interface CheckboxProps {\n checked: boolean;\n onCheckedChange: (checked: boolean) => void;\n disabled?: boolean;\n indeterminate?: boolean;\n label?: string;\n className?: string;\n id?: string;\n \"aria-label\"?: string;\n}\n\nexport function Checkbox({\n checked,\n onCheckedChange,\n disabled,\n indeterminate,\n label,\n className,\n id: idProp,\n \"aria-label\": ariaLabel,\n}: CheckboxProps) {\n const autoId = useId();\n const id = idProp ?? autoId;\n const reduce = useReducedMotion();\n const showMark = checked || indeterminate;\n const path = indeterminate ? INDETERMINATE_PATH : CHECK_PATH;\n\n return (\n <label\n htmlFor={id}\n className={cn(\n \"inline-flex items-center gap-3\",\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer\",\n className,\n )}\n >\n <motion.button\n id={id}\n type=\"button\"\n role=\"checkbox\"\n aria-checked={indeterminate ? \"mixed\" : checked}\n aria-label={ariaLabel}\n disabled={disabled}\n onClick={() => !disabled && onCheckedChange(!checked)}\n whileTap={reduce || disabled ? undefined : { scale: 0.92 }}\n transition={SPRING_PRESS}\n data-state={checked ? \"checked\" : indeterminate ? \"indeterminate\" : \"unchecked\"}\n className={cn(\n \"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md border-2 outline-none transition-colors duration-200\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n \"disabled:cursor-not-allowed disabled:opacity-60\",\n showMark\n ? \"border-primary bg-primary text-primary-foreground\"\n : \"border-muted-foreground/50 bg-background hover:border-muted-foreground\",\n )}\n >\n <AnimatePresence initial={false}>\n {showMark ? (\n <motion.svg\n key={indeterminate ? \"indeterminate\" : \"checked\"}\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n initial={reduce ? { opacity: 1 } : { opacity: 0, scale: 0.5 }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5, filter: \"blur(4px)\" }}\n transition={reduce ? { duration: 0 } : { duration: 0.16, ease: EASE_OUT }}\n aria-hidden\n >\n <title>{indeterminate ? \"Partially selected\" : \"Selected\"}</title>\n <motion.path\n d={path}\n initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n animate={{ pathLength: 1 }}\n transition={\n reduce\n ? { duration: 0 }\n : {\n duration: indeterminate ? 0.2 : 0.3,\n ease: EASE_OUT,\n delay: 0.04,\n }\n }\n />\n </motion.svg>\n ) : null}\n </AnimatePresence>\n </motion.button>\n {label ? (\n <span className={cn(\"select-none text-foreground text-sm\", disabled && \"opacity-60\")}>\n {label}\n </span>\n ) : null}\n </label>\n );\n}\n"],"mappings":";;;;;;;AAQA,MAAM,aAAa;AACnB,MAAM,qBAAqB;
|
|
1
|
+
{"version":3,"file":"checkbox.js","names":[],"sources":["../../../src/components/motion/checkbox.tsx"],"sourcesContent":["\"use client\";\n\nimport { useId } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PRESS } from \"../../lib/ease\";\n\nconst CHECK_PATH = \"M5 13l4 4L19 7\";\nconst INDETERMINATE_PATH = \"M6 12h12\";\n\nexport interface CheckboxProps {\n checked: boolean;\n onCheckedChange: (checked: boolean) => void;\n disabled?: boolean;\n indeterminate?: boolean;\n label?: string;\n className?: string;\n id?: string;\n \"aria-label\"?: string;\n /** Associates an external message (e.g. a form error) with the control. */\n \"aria-describedby\"?: string;\n}\n\nexport function Checkbox({\n checked,\n onCheckedChange,\n disabled,\n indeterminate,\n label,\n className,\n id: idProp,\n \"aria-label\": ariaLabel,\n \"aria-describedby\": ariaDescribedBy,\n}: CheckboxProps) {\n const autoId = useId();\n const id = idProp ?? autoId;\n const reduce = useReducedMotion();\n const showMark = checked || indeterminate;\n const path = indeterminate ? INDETERMINATE_PATH : CHECK_PATH;\n\n return (\n <label\n htmlFor={id}\n className={cn(\n \"inline-flex items-center gap-3\",\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer\",\n className,\n )}\n >\n <motion.button\n id={id}\n type=\"button\"\n role=\"checkbox\"\n aria-checked={indeterminate ? \"mixed\" : checked}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n disabled={disabled}\n onClick={() => !disabled && onCheckedChange(!checked)}\n whileTap={reduce || disabled ? undefined : { scale: 0.92 }}\n transition={SPRING_PRESS}\n data-state={checked ? \"checked\" : indeterminate ? \"indeterminate\" : \"unchecked\"}\n className={cn(\n \"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md border-2 outline-none transition-colors duration-200\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n \"disabled:cursor-not-allowed disabled:opacity-60\",\n showMark\n ? \"border-primary bg-primary text-primary-foreground\"\n : \"border-muted-foreground/50 bg-background hover:border-muted-foreground\",\n )}\n >\n <AnimatePresence initial={false}>\n {showMark ? (\n <motion.svg\n key={indeterminate ? \"indeterminate\" : \"checked\"}\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n initial={reduce ? { opacity: 1 } : { opacity: 0, scale: 0.5 }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5, filter: \"blur(4px)\" }}\n transition={reduce ? { duration: 0 } : { duration: 0.16, ease: EASE_OUT }}\n aria-hidden\n >\n <title>{indeterminate ? \"Partially selected\" : \"Selected\"}</title>\n <motion.path\n d={path}\n initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n animate={{ pathLength: 1 }}\n transition={\n reduce\n ? { duration: 0 }\n : {\n duration: indeterminate ? 0.2 : 0.3,\n ease: EASE_OUT,\n delay: 0.04,\n }\n }\n />\n </motion.svg>\n ) : null}\n </AnimatePresence>\n </motion.button>\n {label ? (\n <span className={cn(\"select-none text-foreground text-sm\", disabled && \"opacity-60\")}>\n {label}\n </span>\n ) : null}\n </label>\n );\n}\n"],"mappings":";;;;;;;AAQA,MAAM,aAAa;AACnB,MAAM,qBAAqB;AAe3B,SAAgB,SAAS,EACvB,SACA,iBACA,UACA,eACA,OACA,WACA,IAAI,QACJ,cAAc,WACd,oBAAoB,mBACJ;CAChB,MAAM,SAAS,MAAM;CACr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ACd;OACE,UAAU,gBAAgB,KAAM;OAChC,MAAM;OACN,OAAO;MACT;KAEP,CAAA,CACS;IA9BL,GAAA,gBAAgB,kBAAkB,SA8B7B,IACV;GACW,CAAA;EACJ,CAAA,GACd,QACC,oBAAC,QAAD;GAAM,WAAW,GAAG,uCAAuC,YAAY,YAAY;GAChF,UAAA;EACG,CAAA,IACJ,IACC;;AAEX"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/components/motion/morphing-tabs.d.ts
|
|
3
|
+
type MorphingTabsItem = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
content: ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type MorphingTabsClassNames = {
|
|
11
|
+
root?: string;
|
|
12
|
+
rail?: string;
|
|
13
|
+
tab?: string;
|
|
14
|
+
activeTab?: string;
|
|
15
|
+
icon?: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
close?: string;
|
|
18
|
+
content?: string;
|
|
19
|
+
};
|
|
20
|
+
interface MorphingTabsProps {
|
|
21
|
+
items: MorphingTabsItem[];
|
|
22
|
+
value?: string | null;
|
|
23
|
+
defaultValue?: string | null;
|
|
24
|
+
onValueChange?: (id: string | null) => void;
|
|
25
|
+
/** Called once after a pointer drag or keyboard reorder completes. */
|
|
26
|
+
onOrderChange?: (ids: string[]) => void;
|
|
27
|
+
/** Enables the close affordance on every tab when provided. */
|
|
28
|
+
onClose?: (id: string) => void;
|
|
29
|
+
ariaLabel?: string;
|
|
30
|
+
className?: string;
|
|
31
|
+
classNames?: MorphingTabsClassNames;
|
|
32
|
+
}
|
|
33
|
+
declare function MorphingTabs({ items, value, defaultValue, onValueChange, onOrderChange, onClose, ariaLabel, className, classNames }: MorphingTabsProps): import("react").JSX.Element | null;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { MorphingTabs, MorphingTabsClassNames, MorphingTabsItem, MorphingTabsProps };
|
|
36
|
+
//# sourceMappingURL=morphing-tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"morphing-tabs.d.ts","names":[],"sources":["../../../src/components/motion/morphing-tabs.tsx"],"mappings":";;KA6BY;EACV;EACA;EACA,OAAO;EACP,SAAS;EACT;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,OAAO;EACP;EACA;EACA,iBAAiB;;EAEjB,iBAAiB;;EAEjB,WAAW;EACX;EACA;EACA,aAAa;;iBAmMC,eACd,OACA,OACA,cACA,eACA,eACA,SACA,WACA,WACA,cACC,oCAAiB,IAAA"}
|