@kumix/ui 0.3.15 → 0.3.17
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 -4
- package/dist/cascader-types-BnH6wYD-.d.ts.map +1 -1
- package/dist/components/agents/agent-activity/activity-row.js +1 -1
- package/dist/components/agents/agent-activity/index.js +1 -1
- package/dist/components/agents/agent-code.js +1 -1
- package/dist/components/agents/ai-sidebar.js +3 -3
- package/dist/components/agents/ai-sidebar.js.map +1 -1
- package/dist/components/agents/approval-card/index.js +23 -26
- package/dist/components/agents/approval-card/index.js.map +1 -1
- package/dist/components/agents/citations.js +1 -1
- package/dist/components/agents/code-block.js +1 -1
- package/dist/components/agents/file-diff.js +1 -1
- package/dist/components/agents/image-generation.js +1 -1
- package/dist/components/agents/message-bubble.js +2 -2
- package/dist/components/agents/message-bubble.js.map +1 -1
- package/dist/components/agents/prompt-input.js +1 -1
- package/dist/components/agents/streaming-response.js +1 -1
- package/dist/components/agents/todo-list.js +1 -1
- package/dist/components/agents/tool-approval.js +1 -1
- package/dist/components/agents/tool-result.js +1 -1
- package/dist/components/custom/confirm-dialog.js +1 -1
- package/dist/components/motion/action-swap.js +2 -2
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/adaptive-stepper.js +1 -1
- package/dist/components/motion/animated-badge.js +3 -3
- package/dist/components/motion/animated-badge.js.map +1 -1
- package/dist/components/motion/animated-sidebar.js +1 -1
- package/dist/components/motion/animated-toast-stack.js +6 -6
- package/dist/components/motion/animated-toast-stack.js.map +1 -1
- package/dist/components/motion/attachment-upload.js +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +2 -2
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/bloom-menu.js +1 -1
- package/dist/components/motion/bouncy-accordion.js +1 -1
- package/dist/components/motion/button/base.js +2 -2
- package/dist/components/motion/button/base.js.map +1 -1
- package/dist/components/motion/button/stateful.js +1 -1
- package/dist/components/motion/card-folder.js +1 -1
- package/dist/components/motion/center-morph-modal.js +1 -1
- package/dist/components/motion/combobox/list.js +1 -1
- package/dist/components/motion/combobox/trigger.js +1 -1
- package/dist/components/motion/command-palette.js +2 -2
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/dock.js +1 -1
- package/dist/components/motion/dock.js.map +1 -1
- package/dist/components/motion/expandable-action-bar.js +1 -1
- package/dist/components/motion/expandable-action-bar.js.map +1 -1
- package/dist/components/motion/feedback-widget.js +1 -1
- package/dist/components/motion/file-tree.js +1 -1
- package/dist/components/motion/file-upload.js +1 -1
- package/dist/components/motion/infinite-masonry.js +1 -1
- package/dist/components/motion/morphing-search.js +1 -1
- package/dist/components/motion/morphing-tabs.js +1 -1
- package/dist/components/motion/multi-select/list.js +1 -1
- package/dist/components/motion/multi-select/trigger.js +1 -1
- package/dist/components/motion/not-found/shared.js +1 -1
- package/dist/components/motion/not-found/shared.js.map +1 -1
- package/dist/components/motion/notification-stack.js +1 -1
- package/dist/components/motion/overflow-actions.js +1 -1
- package/dist/components/motion/project-folder.js +1 -1
- package/dist/components/motion/select-morph.js +1 -1
- package/dist/components/motion/select.js +1 -1
- package/dist/components/motion/shared-layout-bg.js +1 -1
- package/dist/components/motion/shared-layout-bg.js.map +1 -1
- package/dist/components/motion/signup-form.js +1 -1
- package/dist/components/motion/slide-action-button.js +1 -1
- package/dist/components/motion/slide-action-button.js.map +1 -1
- package/dist/components/motion/table/index.js +1 -1
- package/dist/components/motion/table/index.js.map +1 -1
- package/dist/components/motion/table/row-handle.js +1 -1
- package/dist/components/motion/table/table-header.d.ts.map +1 -1
- package/dist/components/motion/table/table-header.js +2 -2
- package/dist/components/motion/table/table-header.js.map +1 -1
- package/dist/components/motion/tabs.d.ts +2 -1
- package/dist/components/motion/tabs.d.ts.map +1 -1
- package/dist/components/motion/tabs.js +200 -18
- package/dist/components/motion/tabs.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/alert.js +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts.map +1 -1
- package/dist/components/reui/autocomplete.js +1 -1
- package/dist/components/reui/badge.d.ts +2 -2
- package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.js +1 -1
- package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-footer.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-footer.js +1 -1
- package/dist/components/reui/cascader/cascader-item.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-item.js +1 -1
- package/dist/components/reui/cascader/cascader-nav.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.js +1 -1
- package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-virtual.js +2 -0
- package/dist/components/reui/cascader/cascader-virtual.js.map +1 -1
- package/dist/components/reui/cascader/cascader.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader.js +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +28 -22
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts +2 -0
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +104 -43
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +6 -6
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- 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-agenda-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +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 +3 -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 +9 -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 +11 -4
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
- package/dist/components/reui/filters/filters-advanced.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-advanced.js +1 -1
- package/dist/components/reui/filters/filters-advanced.js.map +1 -1
- package/dist/components/reui/filters/filters-builder.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-builder.js +1 -1
- package/dist/components/reui/filters/filters-chip.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-chip.js +1 -1
- package/dist/components/reui/filters/filters-context.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-dnd.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-editors.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-editors.js +1 -1
- package/dist/components/reui/filters/filters-types.d.ts +8 -0
- package/dist/components/reui/filters/filters-types.d.ts.map +1 -1
- package/dist/components/reui/filters/filters.d.ts.map +1 -1
- package/dist/components/reui/filters/filters.js +1 -1
- package/dist/components/reui/frame.d.ts +2 -2
- package/dist/components/reui/frame.js +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 +1 -1
- package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt.js.map +1 -1
- package/dist/components/reui/icon-tile.d.ts +2 -2
- package/dist/components/reui/kanban.d.ts.map +1 -1
- package/dist/components/reui/number-field.d.ts +3 -3
- package/dist/components/reui/number-field.d.ts.map +1 -1
- package/dist/components/reui/number-field.js +1 -1
- package/dist/components/reui/phone-input.js +1 -1
- package/dist/components/reui/rating.d.ts +1 -1
- package/dist/components/reui/rating.js +1 -1
- package/dist/components/reui/sortable.d.ts.map +1 -1
- package/dist/components/reui/tree.js +1 -1
- package/dist/components/ui/accordion.d.ts.map +1 -1
- package/dist/components/ui/accordion.js +1 -1
- package/dist/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog.js +1 -1
- package/dist/components/ui/alert.d.ts.map +1 -1
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/attachment.d.ts +1 -1
- package/dist/components/ui/attachment.d.ts.map +1 -1
- package/dist/components/ui/attachment.js +1 -1
- package/dist/components/ui/avatar.d.ts.map +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts.map +1 -1
- package/dist/components/ui/bubble.js +1 -1
- package/dist/components/ui/button-group.js +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/calendar.d.ts.map +1 -1
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/carousel.d.ts.map +1 -1
- package/dist/components/ui/carousel.js +1 -1
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/collapsible.d.ts.map +1 -1
- package/dist/components/ui/combobox.d.ts.map +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/command.js +1 -1
- package/dist/components/ui/context-menu.d.ts.map +1 -1
- package/dist/components/ui/context-menu.js +1 -1
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/hover-card.d.ts.map +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/input-group.d.ts.map +1 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/input-otp.d.ts.map +1 -1
- package/dist/components/ui/input-otp.js +1 -1
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/item.d.ts.map +1 -1
- package/dist/components/ui/item.js +1 -1
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/marker.d.ts.map +1 -1
- package/dist/components/ui/marker.js +1 -1
- package/dist/components/ui/menubar.d.ts.map +1 -1
- package/dist/components/ui/menubar.js +1 -1
- package/dist/components/ui/message-scroller.d.ts.map +1 -1
- package/dist/components/ui/message-scroller.js +1 -1
- package/dist/components/ui/message.d.ts.map +1 -1
- package/dist/components/ui/native-select.d.ts.map +1 -1
- package/dist/components/ui/native-select.js +1 -1
- package/dist/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu.js +1 -1
- package/dist/components/ui/pagination.d.ts.map +1 -1
- package/dist/components/ui/pagination.js +1 -1
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/questionnaire.d.ts.map +1 -1
- package/dist/components/ui/questionnaire.js +1 -1
- package/dist/components/ui/radio-group.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.d.ts.map +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/slider.d.ts.map +1 -1
- package/dist/components/ui/spinner.js +1 -1
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/tabs.d.ts +1 -1
- package/dist/components/ui/tabs.d.ts.map +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/components/ui/toast.d.ts.map +1 -1
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/toggle.d.ts.map +1 -1
- package/dist/components/ui/toggle.js +1 -1
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/{copy-menu-C5GaT4Z-.js → copy-menu-TIKvPaAZ.js} +2 -2
- package/dist/{copy-menu-C5GaT4Z-.js.map → copy-menu-TIKvPaAZ.js.map} +1 -1
- package/dist/hooks/use-intersection-observer.d.ts.map +1 -1
- package/dist/hooks/use-mutation-observer.d.ts.map +1 -1
- package/dist/hooks/use-slider-input.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { EASE_OUT, SPRING_SWAP } from "../../../lib/ease.js";
|
|
3
3
|
import { Button } from "./base.js";
|
|
4
4
|
import { forwardRef, useLayoutEffect, useRef, useState } from "react";
|
|
5
|
+
import { Check, Loader2, X } from "lucide-react";
|
|
5
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
7
|
-
import { Check, Loader2, X } from "lucide-react";
|
|
8
8
|
//#region src/components/motion/button/stateful.tsx
|
|
9
9
|
const CASCADE_STAGGER = .025;
|
|
10
10
|
const ROLL_BLUR = "blur(6px)";
|
|
@@ -3,9 +3,9 @@ import { EASE_IN_OUT, EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ea
|
|
|
3
3
|
import { DigitSwap } from "./digit-swap.js";
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
+
import { EllipsisVertical, Eye, EyeOff } from "lucide-react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useTransform } from "motion/react";
|
|
8
|
-
import { EllipsisVertical, Eye, EyeOff } from "lucide-react";
|
|
9
9
|
//#region src/components/motion/card-folder.tsx
|
|
10
10
|
const PURSE_MORPH_TRANSITION = {
|
|
11
11
|
duration: .28,
|
|
@@ -3,9 +3,9 @@ import { EASE_OUT } from "../../lib/ease.js";
|
|
|
3
3
|
import { t as PresenceGate } from "../../presence-gate-BekdC4Bo.js";
|
|
4
4
|
import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
+
import { X } from "lucide-react";
|
|
6
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
8
|
-
import { X } from "lucide-react";
|
|
9
9
|
import { createPortal } from "react-dom";
|
|
10
10
|
//#region src/components/motion/center-morph-modal.tsx
|
|
11
11
|
const CenterMorphModalContext = createContext(null);
|
|
@@ -3,9 +3,9 @@ import { EASE_OUT, SPRING_LAYOUT } from "../../../lib/ease.js";
|
|
|
3
3
|
import { ComboboxGroupContext, useComboboxContext } from "./context.js";
|
|
4
4
|
import { useContext, useId, useLayoutEffect, useMemo, useRef } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
+
import { Check } from "lucide-react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { motion } from "motion/react";
|
|
8
|
-
import { Check } from "lucide-react";
|
|
9
9
|
//#region src/components/motion/combobox/list.tsx
|
|
10
10
|
function ComboboxList({ children, ariaLabel = "Options", className }) {
|
|
11
11
|
const context = useComboboxContext("ComboboxList");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { mergeRefs, useComboboxContext } from "./context.js";
|
|
3
3
|
import { cn } from "@kumix/utils";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
4
|
import { ChevronsUpDown, Search } from "lucide-react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/motion/combobox/trigger.tsx
|
|
7
7
|
function ComboboxTrigger({ children, className }) {
|
|
8
8
|
const context = useComboboxContext("ComboboxTrigger");
|
|
@@ -7,9 +7,9 @@ import { EASE_OUT } from "../../lib/ease.js";
|
|
|
7
7
|
import { t as PresenceGate } from "../../presence-gate-BekdC4Bo.js";
|
|
8
8
|
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
9
9
|
import { cn } from "@kumix/utils";
|
|
10
|
+
import { Search } from "lucide-react";
|
|
10
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
12
|
-
import { Search } from "lucide-react";
|
|
13
13
|
import { createPortal } from "react-dom";
|
|
14
14
|
//#region src/components/motion/command-palette.tsx
|
|
15
15
|
const PANEL_SPRING = {
|
|
@@ -215,7 +215,7 @@ function CommandPalette({ items, shortcut = "k", placeholder = "Type a command o
|
|
|
215
215
|
children: [
|
|
216
216
|
isActive ? /* @__PURE__ */ jsx(motion.span, {
|
|
217
217
|
layoutId: `${uid}-active`,
|
|
218
|
-
className: "absolute inset-0 z-0 rounded-md bg-
|
|
218
|
+
className: "absolute inset-0 z-0 rounded-md bg-muted/60",
|
|
219
219
|
transition: reduce ? { duration: 0 } : {
|
|
220
220
|
type: "spring",
|
|
221
221
|
stiffness: 480,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-palette.js","names":[],"sources":["../../../src/components/motion/command-palette.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { type LucideIcon, Search } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useOnOpen } from \"../../hooks/use-on-open\";\nimport { useRowCursor } from \"../../hooks/use-row-cursor\";\nimport { useTouchCapable } from \"../../hooks/use-touch-capable\";\nimport { searchCommands } from \"../../lib/command-search\";\nimport { EASE_OUT } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\nexport type CommandItem = {\n id: string;\n label: string;\n group?: string;\n hint?: string;\n keywords?: string[];\n icon?: LucideIcon;\n badge?: ReactNode;\n onSelect: () => void;\n};\n\nexport interface CommandPaletteProps {\n items: CommandItem[];\n /** Opens with Cmd/Ctrl + this key. Default: \"k\" */\n shortcut?: string;\n placeholder?: string;\n emptyMessage?: string;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\n// Opened via a keyboard shortcut many times a day — entrance must read as\n// instant. Tight spring, even faster exit.\nconst PANEL_SPRING = {\n type: \"spring\",\n stiffness: 560,\n damping: 40,\n mass: 0.5,\n} as const;\n\nexport function CommandPalette({\n items,\n shortcut = \"k\",\n placeholder = \"Type a command or search…\",\n emptyMessage = \"No results found.\",\n open: controlledOpen,\n onOpenChange,\n}: CommandPaletteProps) {\n const [internalOpen, setInternalOpen] = useState(false);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n const setOpen = useCallback(\n (v: boolean) => {\n if (!controlled) setInternalOpen(v);\n onOpenChange?.(v);\n },\n [controlled, onOpenChange],\n );\n\n const [query, setQuery] = useState(\"\");\n // Portal target only exists client-side; render nothing during SSR/hydration.\n const [mounted, setMounted] = useState(false);\n useEffect(() => setMounted(true), []);\n const uid = useId();\n const reduce = useReducedMotion();\n const canTouch = useTouchCapable();\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const onKey = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === shortcut.toLowerCase()) {\n e.preventDefault();\n setOpen(!open);\n return;\n }\n if (e.key === \"Escape\" && open) {\n e.preventDefault();\n setOpen(false);\n }\n };\n window.addEventListener(\"keydown\", onKey);\n return () => window.removeEventListener(\"keydown\", onKey);\n }, [open, shortcut, setOpen]);\n\n useEffect(() => {\n if (!open) return;\n const root = document.documentElement;\n const previousRootOverflow = root.style.overflow;\n const previousBodyOverflow = document.body.style.overflow;\n root.style.overflow = \"hidden\";\n document.body.style.overflow = \"hidden\";\n return () => {\n root.style.overflow = previousRootOverflow;\n document.body.style.overflow = previousBodyOverflow;\n };\n }, [open]);\n\n const filtered = useMemo(() => searchCommands(items, query), [items, query]);\n\n // Reserve the icon column only when at least one item brings an icon, so\n // icon-less lists don't render a dead gap before every label.\n const hasIcons = useMemo(() => items.some((it) => it.icon), [items]);\n\n const grouped = useMemo(() => {\n const map = new Map<string, CommandItem[]>();\n filtered.forEach((it) => {\n const g = it.group ?? \"Results\";\n const groupItems = map.get(g) ?? [];\n groupItems.push(it);\n map.set(g, groupItems);\n });\n return Array.from(map.entries());\n }, [filtered]);\n\n // Grouping reorders the list, so the rendered order is not the filtered\n // order whenever two groups interleave. Everything that has to agree on\n // \"which row\" — the highlight, the ids, Enter, the scroll — reads this one\n // array, so they cannot drift apart.\n const rows = useMemo(() => grouped.flatMap(([, list]) => list), [grouped]);\n\n const { activeIndex: active, moveTo, moveActive } = useRowCursor(rows, query);\n\n // Clearing the query would drop the cursor on its own, but only if it had\n // changed; `moveTo(null)` covers reopening on an already-empty query.\n useOnOpen(open, () => {\n setQuery(\"\");\n moveTo(null);\n });\n\n useEffect(() => {\n if (!open) return;\n const frame = requestAnimationFrame(() => inputRef.current?.focus());\n return () => cancelAnimationFrame(frame);\n }, [open]);\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveActive(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveActive(-1);\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n const it = rows[active];\n if (it) {\n it.onSelect();\n setOpen(false);\n }\n }\n };\n\n useEffect(() => {\n if (!open) return;\n const el = listRef.current?.querySelector<HTMLButtonElement>(`[data-index=\"${active}\"]`);\n el?.scrollIntoView({ block: \"nearest\" });\n }, [active, open]);\n\n if (!mounted) return null;\n\n // Portaled to <body> so ancestors with transforms, filters, or fixed\n // positioning can't trap the overlay in their stacking context, and mounted\n // only while open. The chrome is two fixed siblings rather than one wrapper:\n // the backdrop spans the viewport edges but carries the scrim colour, and the\n // layer positioning the panel is inset off every edge. Both hang off\n // `PresenceGate`, so interaction releases in the same commit that starts the\n // exit rather than when it ends — `open` is already false for those frames.\n // See tests/fixed-overlay-edge-sampling.test.tsx.\n return createPortal(\n <AnimatePresence initial={false}>\n {open ? (\n <PresenceGate key=\"backdrop\">\n {({ gate }) => (\n <motion.button\n type=\"button\"\n aria-label=\"Close command palette\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{\n opacity: 0,\n transition: { duration: 0.12, ease: EASE_OUT },\n }}\n transition={{ duration: 0.18, ease: EASE_OUT }}\n {...gate}\n onClick={() => setOpen(false)}\n className=\"pointer-events-auto fixed inset-0 z-100 bg-background/5 [-webkit-backdrop-filter:blur(12px)_saturate(140%)] [backdrop-filter:blur(12px)_saturate(140%)]\"\n />\n )}\n </PresenceGate>\n ) : null}\n\n {open ? (\n <PresenceGate key=\"panel-layer\">\n {({ isPresent, gate }) => (\n // The layer itself never takes pointer events, so it carries\n // `inert` alone rather than the gate's pointer-events value.\n <div\n inert={!isPresent}\n className=\"pointer-events-none fixed inset-x-4 top-[18vh] bottom-4 z-100 flex items-start justify-center\"\n >\n <motion.div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Command palette\"\n initial={{\n opacity: 0,\n y: reduce ? 0 : -8,\n scale: reduce ? 1 : 0.97,\n }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={{\n opacity: 0,\n y: reduce ? 0 : -8,\n scale: reduce ? 1 : 0.97,\n transition: { duration: 0.12, ease: EASE_OUT },\n }}\n transition={reduce ? { duration: 0.1 } : PANEL_SPRING}\n {...gate}\n onKeyDown={onKeyDown}\n className=\"pointer-events-auto w-full max-w-xl overflow-hidden rounded-2xl border border-border bg-card shadow-2xl will-change-transform\"\n >\n <div className=\"flex items-center gap-3 border-border border-b px-4\">\n <Search className=\"h-4 w-4 text-muted-foreground\" />\n <input\n ref={inputRef}\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n placeholder={placeholder}\n role=\"combobox\"\n // The field only exists while the palette is open.\n aria-expanded=\"true\"\n aria-controls={`${uid}-list`}\n aria-activedescendant={rows.length > 0 ? `${uid}-opt-${active}` : undefined}\n aria-autocomplete=\"list\"\n className={cn(\n \"h-12 flex-1 bg-transparent text-foreground text-sm outline-none placeholder:text-muted-foreground\",\n // The palette focuses this field the moment it opens, and iOS\n // zooms the page in on a focused field under 16px: the fixed\n // overlay is magnified off-center — clipped leading edge, half\n // an icon column — and the zoom outlives the palette. 16px on\n // touch keeps the page at scale 1; pointer devices keep 14px.\n canTouch && \"text-base\",\n )}\n />\n <kbd className=\"hidden rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline-block\">\n ESC\n </kbd>\n </div>\n <div\n ref={listRef}\n id={`${uid}-list`}\n role=\"listbox\"\n aria-label=\"Commands\"\n className=\"max-h-[60vh] overflow-y-auto overscroll-contain p-2 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n >\n {rows.length === 0 ? (\n <div className=\"p-8 text-center text-muted-foreground text-sm\">\n {emptyMessage}\n </div>\n ) : (\n grouped.map(([group, list]) => (\n <div key={group} className=\"mb-1 last:mb-0\">\n <div\n aria-hidden\n className=\"px-2 py-1.5 font-semibold text-[10px] text-muted-foreground uppercase tracking-wider\"\n >\n {group}\n </div>\n {list.map((it) => {\n // `rows` holds these very objects, in render order.\n const idx = rows.indexOf(it);\n const isActive = idx === active;\n const Icon = it.icon;\n return (\n <button\n key={it.id}\n type=\"button\"\n id={`${uid}-opt-${idx}`}\n role=\"option\"\n aria-selected={isActive}\n data-index={idx}\n onMouseEnter={() => moveTo(it.id)}\n onClick={() => {\n it.onSelect();\n setOpen(false);\n }}\n className={cn(\n \"relative isolate flex w-full items-center gap-3 rounded-md px-2 py-2 text-left text-sm transition-colors\",\n isActive ? \"text-foreground\" : \"text-muted-foreground\",\n )}\n >\n {isActive ? (\n <motion.span\n layoutId={`${uid}-active`}\n className=\"absolute inset-0 z-0 rounded-md bg-primary/5\"\n transition={\n reduce\n ? { duration: 0 }\n : // Tracks rapid arrow-key navigation — keep it tighter\n // than SPRING_LAYOUT so it never lags the active row.\n {\n type: \"spring\",\n stiffness: 480,\n damping: 38,\n }\n }\n />\n ) : null}\n {Icon ? (\n <Icon className=\"relative z-10 h-4 w-4\" />\n ) : hasIcons ? (\n <span className=\"relative z-10 h-4 w-4\" />\n ) : null}\n <span className=\"relative z-10 flex-1 truncate\">{it.label}</span>\n {it.badge ? (\n <span className=\"relative z-10 shrink-0\">{it.badge}</span>\n ) : null}\n {it.hint ? (\n <kbd className=\"relative z-10 rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground\">\n {it.hint}\n </kbd>\n ) : null}\n </button>\n );\n })}\n </div>\n ))\n )}\n </div>\n </motion.div>\n </div>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAM,eAAe;CACnB,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,eAAe,EAC7B,OACA,WAAW,KACX,cAAc,6BACd,eAAe,qBACf,MAAM,gBACN,gBACsB;CACtB,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK;CACtD,MAAM,aAAa,mBAAmB,KAAA;CACtC,MAAM,OAAO,aAAa,iBAAiB;CAC3C,MAAM,UAAU,aACb,MAAe;EACd,IAAI,CAAC,YAAY,gBAAgB,CAAC;EAClC,eAAe,CAAC;CAClB,GACA,CAAC,YAAY,YAAY,CAC3B;CAEA,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CAErC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,gBAAgB,WAAW,IAAI,GAAG,CAAC,CAAC;CACpC,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,gBAAgB;CACjC,MAAM,WAAW,OAAyB,IAAI;CAC9C,MAAM,UAAU,OAAuB,IAAI;CAE3C,gBAAgB;EACd,MAAM,SAAS,MAAqB;GAClC,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,YAAY,MAAM,SAAS,YAAY,GAAG;IAC9E,EAAE,eAAe;IACjB,QAAQ,CAAC,IAAI;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SAAS;SACZ,QAAQ,KAAK;QACf;QACA,WAAW,GACT,4GACA,WAAW,oBAAoB,uBACjC;QAfF,UAAA;SAiBG,WACC,oBAAC,OAAO,MAAR;UACE,UAAU,GAAG,IAAI;UACjB,WAAU;UACV,YACE,SACI,EAAE,UAAU,EAAE,IAGd;WACE,MAAM;WACN,WAAW;WACX,SAAS;UACX;SAEP,CAAA,IACC;SACH,OACC,oBAAC,MAAD,EAAM,WAAU,wBAAyB,CAAA,IACvC,WACF,oBAAC,QAAD,EAAM,WAAU,wBAAyB,CAAA,IACvC;SACJ,oBAAC,QAAD;UAAM,WAAU;UAAiC,UAAA,GAAG;SAAY,CAAA;SAC/D,GAAG,QACF,oBAAC,QAAD;UAAM,WAAU;UAA0B,UAAA,GAAG;SAAY,CAAA,IACvD;SACH,GAAG,OACF,oBAAC,OAAD;UAAK,WAAU;UACZ,UAAA,GAAG;SACD,CAAA,IACH;QACE;OA/CD,GAAA,GAAG,EA+CF;MAEZ,CAAC,CACE;KAhEK,GAAA,KAgEL,CACN;IAEA,CAAA,CACK;;EACT,CAAA,EAEK,GA5II,aA4IJ,IACZ,IACW;CACjB,CAAA,GAAA,SAAS,IACX;AACF"}
|
|
1
|
+
{"version":3,"file":"command-palette.js","names":[],"sources":["../../../src/components/motion/command-palette.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { type LucideIcon, Search } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useOnOpen } from \"../../hooks/use-on-open\";\nimport { useRowCursor } from \"../../hooks/use-row-cursor\";\nimport { useTouchCapable } from \"../../hooks/use-touch-capable\";\nimport { searchCommands } from \"../../lib/command-search\";\nimport { EASE_OUT } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\nexport type CommandItem = {\n id: string;\n label: string;\n group?: string;\n hint?: string;\n keywords?: string[];\n icon?: LucideIcon;\n badge?: ReactNode;\n onSelect: () => void;\n};\n\nexport interface CommandPaletteProps {\n items: CommandItem[];\n /** Opens with Cmd/Ctrl + this key. Default: \"k\" */\n shortcut?: string;\n placeholder?: string;\n emptyMessage?: string;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\n// Opened via a keyboard shortcut many times a day — entrance must read as\n// instant. Tight spring, even faster exit.\nconst PANEL_SPRING = {\n type: \"spring\",\n stiffness: 560,\n damping: 40,\n mass: 0.5,\n} as const;\n\nexport function CommandPalette({\n items,\n shortcut = \"k\",\n placeholder = \"Type a command or search…\",\n emptyMessage = \"No results found.\",\n open: controlledOpen,\n onOpenChange,\n}: CommandPaletteProps) {\n const [internalOpen, setInternalOpen] = useState(false);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n const setOpen = useCallback(\n (v: boolean) => {\n if (!controlled) setInternalOpen(v);\n onOpenChange?.(v);\n },\n [controlled, onOpenChange],\n );\n\n const [query, setQuery] = useState(\"\");\n // Portal target only exists client-side; render nothing during SSR/hydration.\n const [mounted, setMounted] = useState(false);\n useEffect(() => setMounted(true), []);\n const uid = useId();\n const reduce = useReducedMotion();\n const canTouch = useTouchCapable();\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const onKey = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === shortcut.toLowerCase()) {\n e.preventDefault();\n setOpen(!open);\n return;\n }\n if (e.key === \"Escape\" && open) {\n e.preventDefault();\n setOpen(false);\n }\n };\n window.addEventListener(\"keydown\", onKey);\n return () => window.removeEventListener(\"keydown\", onKey);\n }, [open, shortcut, setOpen]);\n\n useEffect(() => {\n if (!open) return;\n const root = document.documentElement;\n const previousRootOverflow = root.style.overflow;\n const previousBodyOverflow = document.body.style.overflow;\n root.style.overflow = \"hidden\";\n document.body.style.overflow = \"hidden\";\n return () => {\n root.style.overflow = previousRootOverflow;\n document.body.style.overflow = previousBodyOverflow;\n };\n }, [open]);\n\n const filtered = useMemo(() => searchCommands(items, query), [items, query]);\n\n // Reserve the icon column only when at least one item brings an icon, so\n // icon-less lists don't render a dead gap before every label.\n const hasIcons = useMemo(() => items.some((it) => it.icon), [items]);\n\n const grouped = useMemo(() => {\n const map = new Map<string, CommandItem[]>();\n filtered.forEach((it) => {\n const g = it.group ?? \"Results\";\n const groupItems = map.get(g) ?? [];\n groupItems.push(it);\n map.set(g, groupItems);\n });\n return Array.from(map.entries());\n }, [filtered]);\n\n // Grouping reorders the list, so the rendered order is not the filtered\n // order whenever two groups interleave. Everything that has to agree on\n // \"which row\" — the highlight, the ids, Enter, the scroll — reads this one\n // array, so they cannot drift apart.\n const rows = useMemo(() => grouped.flatMap(([, list]) => list), [grouped]);\n\n const { activeIndex: active, moveTo, moveActive } = useRowCursor(rows, query);\n\n // Clearing the query would drop the cursor on its own, but only if it had\n // changed; `moveTo(null)` covers reopening on an already-empty query.\n useOnOpen(open, () => {\n setQuery(\"\");\n moveTo(null);\n });\n\n useEffect(() => {\n if (!open) return;\n const frame = requestAnimationFrame(() => inputRef.current?.focus());\n return () => cancelAnimationFrame(frame);\n }, [open]);\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveActive(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveActive(-1);\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n const it = rows[active];\n if (it) {\n it.onSelect();\n setOpen(false);\n }\n }\n };\n\n useEffect(() => {\n if (!open) return;\n const el = listRef.current?.querySelector<HTMLButtonElement>(`[data-index=\"${active}\"]`);\n el?.scrollIntoView({ block: \"nearest\" });\n }, [active, open]);\n\n if (!mounted) return null;\n\n // Portaled to <body> so ancestors with transforms, filters, or fixed\n // positioning can't trap the overlay in their stacking context, and mounted\n // only while open. The chrome is two fixed siblings rather than one wrapper:\n // the backdrop spans the viewport edges but carries the scrim colour, and the\n // layer positioning the panel is inset off every edge. Both hang off\n // `PresenceGate`, so interaction releases in the same commit that starts the\n // exit rather than when it ends — `open` is already false for those frames.\n // See tests/fixed-overlay-edge-sampling.test.tsx.\n return createPortal(\n <AnimatePresence initial={false}>\n {open ? (\n <PresenceGate key=\"backdrop\">\n {({ gate }) => (\n <motion.button\n type=\"button\"\n aria-label=\"Close command palette\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{\n opacity: 0,\n transition: { duration: 0.12, ease: EASE_OUT },\n }}\n transition={{ duration: 0.18, ease: EASE_OUT }}\n {...gate}\n onClick={() => setOpen(false)}\n className=\"pointer-events-auto fixed inset-0 z-100 bg-background/5 [-webkit-backdrop-filter:blur(12px)_saturate(140%)] [backdrop-filter:blur(12px)_saturate(140%)]\"\n />\n )}\n </PresenceGate>\n ) : null}\n\n {open ? (\n <PresenceGate key=\"panel-layer\">\n {({ isPresent, gate }) => (\n // The layer itself never takes pointer events, so it carries\n // `inert` alone rather than the gate's pointer-events value.\n <div\n inert={!isPresent}\n className=\"pointer-events-none fixed inset-x-4 top-[18vh] bottom-4 z-100 flex items-start justify-center\"\n >\n <motion.div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Command palette\"\n initial={{\n opacity: 0,\n y: reduce ? 0 : -8,\n scale: reduce ? 1 : 0.97,\n }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={{\n opacity: 0,\n y: reduce ? 0 : -8,\n scale: reduce ? 1 : 0.97,\n transition: { duration: 0.12, ease: EASE_OUT },\n }}\n transition={reduce ? { duration: 0.1 } : PANEL_SPRING}\n {...gate}\n onKeyDown={onKeyDown}\n className=\"pointer-events-auto w-full max-w-xl overflow-hidden rounded-2xl border border-border bg-card shadow-2xl will-change-transform\"\n >\n <div className=\"flex items-center gap-3 border-border border-b px-4\">\n <Search className=\"h-4 w-4 text-muted-foreground\" />\n <input\n ref={inputRef}\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n placeholder={placeholder}\n role=\"combobox\"\n // The field only exists while the palette is open.\n aria-expanded=\"true\"\n aria-controls={`${uid}-list`}\n aria-activedescendant={rows.length > 0 ? `${uid}-opt-${active}` : undefined}\n aria-autocomplete=\"list\"\n className={cn(\n \"h-12 flex-1 bg-transparent text-foreground text-sm outline-none placeholder:text-muted-foreground\",\n // The palette focuses this field the moment it opens, and iOS\n // zooms the page in on a focused field under 16px: the fixed\n // overlay is magnified off-center — clipped leading edge, half\n // an icon column — and the zoom outlives the palette. 16px on\n // touch keeps the page at scale 1; pointer devices keep 14px.\n canTouch && \"text-base\",\n )}\n />\n <kbd className=\"hidden rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline-block\">\n ESC\n </kbd>\n </div>\n <div\n ref={listRef}\n id={`${uid}-list`}\n role=\"listbox\"\n aria-label=\"Commands\"\n className=\"max-h-[60vh] overflow-y-auto overscroll-contain p-2 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n >\n {rows.length === 0 ? (\n <div className=\"p-8 text-center text-muted-foreground text-sm\">\n {emptyMessage}\n </div>\n ) : (\n grouped.map(([group, list]) => (\n <div key={group} className=\"mb-1 last:mb-0\">\n <div\n aria-hidden\n className=\"px-2 py-1.5 font-semibold text-[10px] text-muted-foreground uppercase tracking-wider\"\n >\n {group}\n </div>\n {list.map((it) => {\n // `rows` holds these very objects, in render order.\n const idx = rows.indexOf(it);\n const isActive = idx === active;\n const Icon = it.icon;\n return (\n <button\n key={it.id}\n type=\"button\"\n id={`${uid}-opt-${idx}`}\n role=\"option\"\n aria-selected={isActive}\n data-index={idx}\n onMouseEnter={() => moveTo(it.id)}\n onClick={() => {\n it.onSelect();\n setOpen(false);\n }}\n className={cn(\n \"relative isolate flex w-full items-center gap-3 rounded-md px-2 py-2 text-left text-sm transition-colors\",\n isActive ? \"text-foreground\" : \"text-muted-foreground\",\n )}\n >\n {isActive ? (\n <motion.span\n layoutId={`${uid}-active`}\n className=\"absolute inset-0 z-0 rounded-md bg-muted/60\"\n transition={\n reduce\n ? { duration: 0 }\n : // Tracks rapid arrow-key navigation — keep it tighter\n // than SPRING_LAYOUT so it never lags the active row.\n {\n type: \"spring\",\n stiffness: 480,\n damping: 38,\n }\n }\n />\n ) : null}\n {Icon ? (\n <Icon className=\"relative z-10 h-4 w-4\" />\n ) : hasIcons ? (\n <span className=\"relative z-10 h-4 w-4\" />\n ) : null}\n <span className=\"relative z-10 flex-1 truncate\">{it.label}</span>\n {it.badge ? (\n <span className=\"relative z-10 shrink-0\">{it.badge}</span>\n ) : null}\n {it.hint ? (\n <kbd className=\"relative z-10 rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground\">\n {it.hint}\n </kbd>\n ) : null}\n </button>\n );\n })}\n </div>\n ))\n )}\n </div>\n </motion.div>\n </div>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAM,eAAe;CACnB,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,eAAe,EAC7B,OACA,WAAW,KACX,cAAc,6BACd,eAAe,qBACf,MAAM,gBACN,gBACsB;CACtB,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK;CACtD,MAAM,aAAa,mBAAmB,KAAA;CACtC,MAAM,OAAO,aAAa,iBAAiB;CAC3C,MAAM,UAAU,aACb,MAAe;EACd,IAAI,CAAC,YAAY,gBAAgB,CAAC;EAClC,eAAe,CAAC;CAClB,GACA,CAAC,YAAY,YAAY,CAC3B;CAEA,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CAErC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,gBAAgB,WAAW,IAAI,GAAG,CAAC,CAAC;CACpC,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,gBAAgB;CACjC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K,QAAQ,EAAE;OAC3B,MAAM,WAAW,QAAQ;OACzB,MAAM,OAAO,GAAG;OAChB,OACE,qBAAC,UAAD;QAEE,MAAK;QACL,IAAI,GAAG,IAAI,OAAO;QAClB,MAAK;QACL,iBAAe;QACf,cAAY;QACZ,oBAAoB,OAAO,GAAG,EAAE;QAChC,eAAe;SACb,GAAG,SAAS;SACZ,QAAQ,KAAK;QACf;QACA,WAAW,GACT,4GACA,WAAW,oBAAoB,uBACjC;QAfF,UAAA;SAiBG,WACC,oBAAC,OAAO,MAAR;UACE,UAAU,GAAG,IAAI;UACjB,WAAU;UACV,YACE,SACI,EAAE,UAAU,EAAE,IAGd;WACE,MAAM;WACN,WAAW;WACX,SAAS;UACX;SAEP,CAAA,IACC;SACH,OACC,oBAAC,MAAD,EAAM,WAAU,wBAAyB,CAAA,IACvC,WACF,oBAAC,QAAD,EAAM,WAAU,wBAAyB,CAAA,IACvC;SACJ,oBAAC,QAAD;UAAM,WAAU;UAAiC,UAAA,GAAG;SAAY,CAAA;SAC/D,GAAG,QACF,oBAAC,QAAD;UAAM,WAAU;UAA0B,UAAA,GAAG;SAAY,CAAA,IACvD;SACH,GAAG,OACF,oBAAC,OAAD;UAAK,WAAU;UACZ,UAAA,GAAG;SACD,CAAA,IACH;QACE;OA/CD,GAAA,GAAG,EA+CF;MAEZ,CAAC,CACE;KAhEK,GAAA,KAgEL,CACN;IAEA,CAAA,CACK;;EACT,CAAA,EAEK,GA5II,aA4IJ,IACZ,IACW;CACjB,CAAA,GAAA,SAAS,IACX;AACF"}
|
|
@@ -3,9 +3,9 @@ import { TOUCH_GESTURE_CONTENT_CLASS, holdSelection } from "../../lib/touch.js";
|
|
|
3
3
|
import { EASE_OUT, SPRING_LAYOUT, SPRING_PANEL } from "../../lib/ease.js";
|
|
4
4
|
import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
+
import { Check } from "lucide-react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
8
|
-
import { Check } from "lucide-react";
|
|
9
9
|
import { createPortal } from "react-dom";
|
|
10
10
|
//#region src/components/motion/context-menu.tsx
|
|
11
11
|
const VIEWPORT_PADDING = 8;
|
|
@@ -28,7 +28,7 @@ function DockItem({ children, className, onClick, active, ...rest }) {
|
|
|
28
28
|
const pill = active ? /* @__PURE__ */ jsx(motion.span, {
|
|
29
29
|
layoutId: pillLayoutId,
|
|
30
30
|
transition: reduce ? { duration: 0 } : SPRING_LAYOUT,
|
|
31
|
-
className: "absolute inset-0.5 -z-10 rounded-xl bg-
|
|
31
|
+
className: "absolute inset-0.5 -z-10 rounded-xl bg-muted/60"
|
|
32
32
|
}) : null;
|
|
33
33
|
const sharedStyle = {
|
|
34
34
|
width: size,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dock.js","names":[],"sources":["../../../src/components/motion/dock.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, type ReactNode, useContext, useId, useMemo } from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT } from \"../../lib/ease\";\n\ntype DockContextValue = {\n size: number;\n pillLayoutId: string;\n};\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nexport interface DockProps {\n children: ReactNode;\n className?: string;\n /** Size of each item in px. */\n size?: number;\n}\n\nexport function Dock({ children, size = 44, className }: DockProps) {\n const pillLayoutId = useId();\n const ctx = useMemo<DockContextValue>(() => ({ size, pillLayoutId }), [size, pillLayoutId]);\n\n return (\n <DockContext.Provider value={ctx}>\n <div\n className={cn(\n \"inline-flex h-auto items-end gap-1.5 rounded-2xl border border-border bg-card/80 px-2 py-1 shadow-2xl backdrop-blur-xl\",\n className,\n )}\n >\n {children}\n </div>\n </DockContext.Provider>\n );\n}\n\nexport interface DockItemProps {\n children: ReactNode;\n className?: string;\n /** When set, the item renders as a <button>. Omit when children carry their own link or button. */\n onClick?: () => void;\n active?: boolean;\n \"aria-label\"?: string;\n}\n\nexport function DockItem({ children, className, onClick, active, ...rest }: DockItemProps) {\n const dock = useContext(DockContext);\n const reduce = useReducedMotion();\n const size = dock?.size ?? 44;\n const pillLayoutId = dock?.pillLayoutId ?? \"dock-pill\";\n\n const pill = active ? (\n <motion.span\n layoutId={pillLayoutId}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className=\"absolute inset-0.5 -z-10 rounded-xl bg-
|
|
1
|
+
{"version":3,"file":"dock.js","names":[],"sources":["../../../src/components/motion/dock.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, type ReactNode, useContext, useId, useMemo } from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT } from \"../../lib/ease\";\n\ntype DockContextValue = {\n size: number;\n pillLayoutId: string;\n};\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nexport interface DockProps {\n children: ReactNode;\n className?: string;\n /** Size of each item in px. */\n size?: number;\n}\n\nexport function Dock({ children, size = 44, className }: DockProps) {\n const pillLayoutId = useId();\n const ctx = useMemo<DockContextValue>(() => ({ size, pillLayoutId }), [size, pillLayoutId]);\n\n return (\n <DockContext.Provider value={ctx}>\n <div\n className={cn(\n \"inline-flex h-auto items-end gap-1.5 rounded-2xl border border-border bg-card/80 px-2 py-1 shadow-2xl backdrop-blur-xl\",\n className,\n )}\n >\n {children}\n </div>\n </DockContext.Provider>\n );\n}\n\nexport interface DockItemProps {\n children: ReactNode;\n className?: string;\n /** When set, the item renders as a <button>. Omit when children carry their own link or button. */\n onClick?: () => void;\n active?: boolean;\n \"aria-label\"?: string;\n}\n\nexport function DockItem({ children, className, onClick, active, ...rest }: DockItemProps) {\n const dock = useContext(DockContext);\n const reduce = useReducedMotion();\n const size = dock?.size ?? 44;\n const pillLayoutId = dock?.pillLayoutId ?? \"dock-pill\";\n\n const pill = active ? (\n <motion.span\n layoutId={pillLayoutId}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className=\"absolute inset-0.5 -z-10 rounded-xl bg-muted/60\"\n />\n ) : null;\n const sharedStyle = { width: size, height: size };\n const sharedClass = cn(\n \"relative flex shrink-0 items-center justify-center rounded-full text-foreground\",\n className,\n );\n\n if (onClick) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n aria-label={rest[\"aria-label\"]}\n aria-pressed={active}\n style={sharedStyle}\n className={cn(\n sharedClass,\n \"cursor-pointer border-0 bg-transparent p-0 outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n )}\n >\n {pill}\n {children}\n </button>\n );\n }\n\n // Children carry their own link or button (and its accessible name).\n return (\n <div style={sharedStyle} className={sharedClass}>\n {pill}\n {children}\n </div>\n );\n}\n\nexport function DockSeparator({ className }: { className?: string }) {\n return <span aria-hidden className={cn(\"mx-1 h-6 w-px self-center bg-border\", className)} />;\n}\n"],"mappings":";;;;;;;AAaA,MAAM,cAAc,cAAuC,IAAI;AAS/D,SAAgB,KAAK,EAAE,UAAU,OAAO,IAAI,aAAwB;CAClE,MAAM,eAAe,MAAM;CAC3B,MAAM,MAAM,eAAiC;EAAE;EAAM;CAAa,IAAI,CAAC,MAAM,YAAY,CAAC;CAE1F,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,OAAD;GACE,WAAW,GACT,0HACA,SACF;GAEC;EACE,CAAA;CACe,CAAA;AAE1B;AAWA,SAAgB,SAAS,EAAE,UAAU,WAAW,SAAS,QAAQ,GAAG,QAAuB;CACzF,MAAM,OAAO,WAAW,WAAW;CACnC,MAAM,SAAS,iBAAiB;CAChC,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,eAAe,MAAM,gBAAgB;CAE3C,MAAM,OAAO,SACX,oBAAC,OAAO,MAAR;EACE,UAAU;EACV,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;EACvC,WAAU;CACX,CAAA,IACC;CACJ,MAAM,cAAc;EAAE,OAAO;EAAM,QAAQ;CAAK;CAChD,MAAM,cAAc,GAClB,mFACA,SACF;CAEA,IAAI,SACF,OACE,qBAAC,UAAD;EACE,MAAK;EACI;EACT,cAAY,KAAK;EACjB,gBAAc;EACd,OAAO;EACP,WAAW,GACT,aACA,2DACA,+GACF;EAVF,UAAA,CAYG,MACA,QACK;;CAKZ,OACE,qBAAC,OAAD;EAAK,OAAO;EAAa,WAAW;EAApC,UAAA,CACG,MACA,QACE;;AAET;AAEA,SAAgB,cAAc,EAAE,aAAqC;CACnE,OAAO,oBAAC,QAAD;EAAM,eAAA;EAAY,WAAW,GAAG,uCAAuC,SAAS;CAAI,CAAA;AAC7F"}
|
|
@@ -147,7 +147,7 @@ function ExpandableActionBar({ items, expanded, defaultExpanded = false, onExpan
|
|
|
147
147
|
className: cn("relative isolate inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium text-muted-foreground outline-none transition-[color,background-color] duration-150 ease-out", "focus-visible:text-foreground disabled:pointer-events-none disabled:opacity-40", isHighlighted && "text-foreground", ITEM_SIZE_CLASS[size], classNames?.item, isActive && classNames?.activeItem),
|
|
148
148
|
children: [isHighlighted ? /* @__PURE__ */ jsx(motion.span, {
|
|
149
149
|
layoutId: "action-bar-highlight",
|
|
150
|
-
className: "absolute inset-0 -z-10 rounded-full bg-
|
|
150
|
+
className: "absolute inset-0 -z-10 rounded-full bg-muted/80",
|
|
151
151
|
transition: ITEM_TRANSITION
|
|
152
152
|
}) : null, renderItem ? renderItem(item, {
|
|
153
153
|
expanded: isExpanded,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandable-action-bar.js","names":[],"sources":["../../../src/components/motion/expandable-action-bar.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type FocusEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { LayoutGroup, motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\n\nexport type ExpandableActionBarSize = \"sm\" | \"md\";\n\nexport type ExpandableActionBarItem = {\n id: string;\n label: ReactNode;\n icon: ReactNode;\n onClick?: () => void;\n disabled?: boolean;\n active?: boolean;\n badge?: ReactNode;\n shortcut?: ReactNode;\n};\n\nexport type ExpandableActionBarClassNames = {\n root?: string;\n track?: string;\n item?: string;\n activeItem?: string;\n icon?: string;\n label?: string;\n badge?: string;\n shortcut?: string;\n};\n\nexport interface ExpandableActionBarProps {\n items: ExpandableActionBarItem[];\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n activeId?: string;\n onAction?: (item: ExpandableActionBarItem) => void;\n size?: ExpandableActionBarSize;\n /**\n * Expand when a pointer that hovers rests on the bar. Default true. It also\n * governs the touch equivalent: with no hover to reveal the labels, the\n * first tap expands the bar and runs no action, and the second one acts.\n * Set false to make every tap and click act immediately.\n */\n expandOnHover?: boolean;\n expandOnFocus?: boolean;\n collapseDelay?: number;\n className?: string;\n classNames?: ExpandableActionBarClassNames;\n renderItem?: (\n item: ExpandableActionBarItem,\n state: { expanded: boolean; active: boolean },\n ) => ReactNode;\n}\n\nconst ITEM_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 460,\n damping: 34,\n mass: 0.62,\n};\n\nconst LABEL_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 380,\n damping: 32,\n mass: 0.7,\n};\n\nconst SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"min-h-9 gap-1 p-1 text-xs\",\n md: \"min-h-11 gap-1.5 p-1.5 text-sm\",\n};\n\nconst ITEM_SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"h-7 min-w-7 px-1.5\",\n md: \"h-8 min-w-8 px-2\",\n};\n\nconst ICON_SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"h-3.5 w-3.5\",\n md: \"h-4 w-4\",\n};\n\nfunction useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n}: {\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n}) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded ?? false);\n const isControlled = expanded !== undefined;\n const value = expanded ?? internalExpanded;\n\n const setValue = useCallback(\n (next: boolean) => {\n if (!isControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [isControlled, onExpandedChange],\n );\n\n return [value, setValue] as const;\n}\n\nexport function ExpandableActionBar({\n items,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n activeId,\n onAction,\n size = \"md\",\n expandOnHover = true,\n expandOnFocus = true,\n collapseDelay = 90,\n className,\n classNames,\n renderItem,\n}: ExpandableActionBarProps) {\n const reduce = useReducedMotion();\n const layoutId = useId();\n const [isExpanded, setIsExpanded] = useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n const [hoveredId, setHoveredId] = useState<string | null>(null);\n // Set by the tap that expands the bar, and the reason the outside-tap\n // dismisser exists at all — a hovering pointer has its own way out.\n const [tapExpanded, setTapExpanded] = useState(false);\n const collapseTimer = useRef<number | null>(null);\n const trackRef = useRef<HTMLDivElement | null>(null);\n // What the last gesture on an action was, and whether the bar was already\n // expanded when it started. A click reports neither.\n const tap = useTapGesture<boolean>();\n const hover = useHoverGesture();\n\n const clearCollapseTimer = useCallback(() => {\n if (collapseTimer.current) window.clearTimeout(collapseTimer.current);\n collapseTimer.current = null;\n }, []);\n\n const open = useCallback(() => {\n clearCollapseTimer();\n setIsExpanded(true);\n }, [clearCollapseTimer, setIsExpanded]);\n\n const close = useCallback(() => {\n clearCollapseTimer();\n const timer = window.setTimeout(() => {\n setIsExpanded(false);\n setHoveredId(null);\n setTapExpanded(false);\n }, collapseDelay);\n collapseTimer.current = timer;\n }, [clearCollapseTimer, collapseDelay, setIsExpanded]);\n\n useEffect(() => clearCollapseTimer, [clearCollapseTimer]);\n\n // A collapse from outside takes the labels with it, so the arm the tap that\n // expanded the bar left behind has to go too — otherwise the next tap runs\n // an action whose label nobody can read. Only on the way down from expanded:\n // a controlled bar that declined to expand at all keeps its arm, which is\n // what lets its second tap act.\n const wasExpanded = useRef(isExpanded);\n useEffect(() => {\n if (wasExpanded.current && !isExpanded) setTapExpanded(false);\n wasExpanded.current = isExpanded;\n }, [isExpanded]);\n\n // A finger never hovers and Safari does not focus a button on tap, so a bar a\n // tap expanded would have nothing to close it. The tap that lands elsewhere\n // stands in for the pointer leaving — and it is consumed rather than passed\n // through, because the labelled bar is exactly the kind of surface people\n // dismiss by tapping just past it, over whatever control is there.\n useDismiss(tapExpanded && isExpanded, close, trackRef, {\n behavior: \"consume\",\n });\n\n const onRootPointerEnter = (event: PointerEvent<HTMLDivElement>) => {\n // The gesture is told about every enter, `expandOnHover` or not: it is\n // what the matching leave is read against.\n if (hover.enter(event) && expandOnHover) open();\n };\n\n const onRootPointerLeave = (event: PointerEvent<HTMLDivElement>) => {\n if (!hover.leave(event)) return;\n setHoveredId(null);\n if (expandOnHover) close();\n };\n\n const onRootFocus = () => {\n if (expandOnFocus) open();\n };\n\n const onRootBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node) && expandOnFocus) {\n close();\n }\n };\n\n const activeItemId = activeId ?? items.find((item) => item.active)?.id;\n const highlightId = hoveredId ?? activeItemId;\n\n return (\n <LayoutGroup id={layoutId}>\n <motion.div\n layout=\"size\"\n // Pointer events, not the mouse pair: a tap fires compatibility\n // mouseenter/mouseleave that carry no pointerType, and the bar growing\n // under a stationary finger fired the leave before the click ever\n // landed — so one tap expanded, collapsed and ran nothing.\n onPointerEnter={onRootPointerEnter}\n onPointerLeave={onRootPointerLeave}\n onFocus={onRootFocus}\n onBlur={onRootBlur}\n transition={ITEM_TRANSITION}\n className={cn(\"inline-flex max-w-full\", classNames?.root, className)}\n >\n <motion.div\n ref={trackRef}\n layout=\"size\"\n className={cn(\n // Labelled actions can outgrow the space the bar sits in — the pill\n // stays inside it and scrolls its rail rather than running off the\n // edge, where the last action is unreachable.\n \"scrollbar-hide relative inline-flex max-w-full items-center overflow-x-auto overflow-y-hidden rounded-full border border-border bg-card/90 shadow-2xl backdrop-blur-xl\",\n SIZE_CLASS[size],\n classNames?.track,\n )}\n transition={ITEM_TRANSITION}\n >\n {items.map((item) => {\n const isActive = item.active || activeId === item.id;\n const isHighlighted = highlightId === item.id;\n\n return (\n <motion.button\n key={item.id}\n layout=\"position\"\n type=\"button\"\n disabled={item.disabled}\n title={typeof item.label === \"string\" ? item.label : undefined}\n onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n if (!hover.enter(event)) return;\n clearCollapseTimer();\n setHoveredId(item.id);\n }}\n onPointerDown={(event: PointerEvent<HTMLButtonElement>) => {\n tap.start(event, isExpanded);\n }}\n // A gesture the platform takes away sends no click, and a key\n // press starts an activation that never had a pointer behind\n // it: either one would otherwise leave the finger in place for\n // the next click to spend.\n onPointerCancel={tap.drop}\n onKeyDown={tap.drop}\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n event.currentTarget.blur();\n const gesture = tap.take();\n // Nothing reveals the labels to a finger, so the first tap\n // expands the bar and the next one runs the action. The bar\n // state is read from the gesture's start: a browser that\n // focuses the button on contact expands it mid-tap, and that\n // first tap would otherwise fire the action it was meant to\n // reveal. `tapExpanded` arms the second tap, so a controlled\n // bar that declines to expand still runs the action rather\n // than swallowing every tap.\n const firstTap =\n gesture !== null &&\n gesture.pointerType !== \"mouse\" &&\n !gesture.state &&\n !tapExpanded;\n if (firstTap && expandOnHover) {\n setTapExpanded(true);\n open();\n setHoveredId(item.id);\n return;\n }\n item.onClick?.();\n onAction?.(item);\n }}\n whileTap={reduce || item.disabled ? undefined : { scale: 0.96 }}\n transition={ITEM_TRANSITION}\n className={cn(\n \"relative isolate inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium text-muted-foreground outline-none transition-[color,background-color] duration-150 ease-out\",\n \"focus-visible:text-foreground disabled:pointer-events-none disabled:opacity-40\",\n isHighlighted && \"text-foreground\",\n ITEM_SIZE_CLASS[size],\n classNames?.item,\n isActive && classNames?.activeItem,\n )}\n >\n {isHighlighted ? (\n <motion.span\n layoutId=\"action-bar-highlight\"\n className=\"absolute inset-0 -z-10 rounded-full bg-primary/[0.07]\"\n transition={ITEM_TRANSITION}\n />\n ) : null}\n\n {renderItem ? (\n renderItem(item, { expanded: isExpanded, active: isActive })\n ) : (\n <>\n <span\n className={cn(\n \"inline-flex shrink-0 items-center justify-center\",\n ICON_SIZE_CLASS[size],\n classNames?.icon,\n )}\n >\n {item.icon}\n </span>\n\n <motion.span\n aria-hidden={!isExpanded}\n animate={\n reduce\n ? {\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n marginLeft: isExpanded ? 8 : 0,\n x: 0,\n filter: \"blur(0px)\",\n }\n : {\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n x: isExpanded ? 0 : -4,\n marginLeft: isExpanded ? 8 : 0,\n filter: isExpanded ? \"blur(0px)\" : \"blur(3px)\",\n }\n }\n transition={reduce ? { duration: 0 } : LABEL_TRANSITION}\n className={cn(\n \"inline-block overflow-hidden whitespace-nowrap\",\n classNames?.label,\n )}\n >\n {item.label}\n </motion.span>\n\n {item.shortcut ? (\n <motion.span\n aria-hidden={!isExpanded}\n animate={{\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n marginLeft: isExpanded ? 4 : 0,\n }}\n transition={LABEL_TRANSITION}\n className={cn(\n \"hidden overflow-hidden whitespace-nowrap text-[10px] text-muted-foreground sm:inline-block\",\n classNames?.shortcut,\n )}\n >\n {item.shortcut}\n </motion.span>\n ) : null}\n\n {item.badge ? (\n <span\n className={cn(\n \"ml-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] text-primary-foreground leading-none\",\n !isExpanded && \"absolute top-0.5 right-0.5\",\n classNames?.badge,\n )}\n >\n {item.badge}\n </span>\n ) : null}\n </>\n )}\n </motion.button>\n );\n })}\n </motion.div>\n </motion.div>\n </LayoutGroup>\n );\n}\n\nexport function useExpandableActionBar(items: ExpandableActionBarItem[]) {\n const [expanded, setExpanded] = useState(false);\n const [activeId, setActiveId] = useState(items[0]?.id);\n\n const activeItem = useMemo(() => items.find((item) => item.id === activeId), [activeId, items]);\n\n return useMemo(\n () => ({ expanded, setExpanded, activeId, setActiveId, activeItem }),\n [activeId, activeItem, expanded],\n );\n}\n"],"mappings":";;;;;;;;;AAsEA,MAAM,kBAA8B;CAClC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,mBAA+B;CACnC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,aAAsD;CAC1D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAA2D;CAC/D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAA2D;CAC/D,IAAI;CACJ,IAAI;AACN;AAEA,SAAS,wBAAwB,EAC/B,UACA,iBACA,oBAKC;CACD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,mBAAmB,KAAK;CACjF,MAAM,eAAe,aAAa,KAAA;CAWlC,OAAO,CAVO,YAAY,kBAET,aACd,SAAkB;EACjB,IAAI,CAAC,cAAc,oBAAoB,IAAI;EAC3C,mBAAmB,IAAI;CACzB,GACA,CAAC,cAAc,gBAAgB,CAGX,CAAC;AACzB;AAEA,SAAgB,oBAAoB,EAClC,OACA,UACA,kBAAkB,OAClB,kBACA,UACA,UACA,OAAO,MACP,gBAAgB,MAChB,gBA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R,GAAA,KAAK,EAwIG;IAEnB,CAAC;GACS,CAAA;EACF,CAAA;CACD,CAAA;AAEjB;AAEA,SAAgB,uBAAuB,OAAkC;CACvE,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,UAAU,eAAe,SAAS,MAAM,EAAE,EAAE,EAAE;CAErD,MAAM,aAAa,cAAc,MAAM,MAAM,SAAS,KAAK,OAAO,QAAQ,GAAG,CAAC,UAAU,KAAK,CAAC;CAE9F,OAAO,eACE;EAAE;EAAU;EAAa;EAAU;EAAa;CAAW,IAClE;EAAC;EAAU;EAAY;CAAQ,CACjC;AACF"}
|
|
1
|
+
{"version":3,"file":"expandable-action-bar.js","names":[],"sources":["../../../src/components/motion/expandable-action-bar.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type FocusEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { LayoutGroup, motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\n\nexport type ExpandableActionBarSize = \"sm\" | \"md\";\n\nexport type ExpandableActionBarItem = {\n id: string;\n label: ReactNode;\n icon: ReactNode;\n onClick?: () => void;\n disabled?: boolean;\n active?: boolean;\n badge?: ReactNode;\n shortcut?: ReactNode;\n};\n\nexport type ExpandableActionBarClassNames = {\n root?: string;\n track?: string;\n item?: string;\n activeItem?: string;\n icon?: string;\n label?: string;\n badge?: string;\n shortcut?: string;\n};\n\nexport interface ExpandableActionBarProps {\n items: ExpandableActionBarItem[];\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n activeId?: string;\n onAction?: (item: ExpandableActionBarItem) => void;\n size?: ExpandableActionBarSize;\n /**\n * Expand when a pointer that hovers rests on the bar. Default true. It also\n * governs the touch equivalent: with no hover to reveal the labels, the\n * first tap expands the bar and runs no action, and the second one acts.\n * Set false to make every tap and click act immediately.\n */\n expandOnHover?: boolean;\n expandOnFocus?: boolean;\n collapseDelay?: number;\n className?: string;\n classNames?: ExpandableActionBarClassNames;\n renderItem?: (\n item: ExpandableActionBarItem,\n state: { expanded: boolean; active: boolean },\n ) => ReactNode;\n}\n\nconst ITEM_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 460,\n damping: 34,\n mass: 0.62,\n};\n\nconst LABEL_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 380,\n damping: 32,\n mass: 0.7,\n};\n\nconst SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"min-h-9 gap-1 p-1 text-xs\",\n md: \"min-h-11 gap-1.5 p-1.5 text-sm\",\n};\n\nconst ITEM_SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"h-7 min-w-7 px-1.5\",\n md: \"h-8 min-w-8 px-2\",\n};\n\nconst ICON_SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"h-3.5 w-3.5\",\n md: \"h-4 w-4\",\n};\n\nfunction useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n}: {\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n}) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded ?? false);\n const isControlled = expanded !== undefined;\n const value = expanded ?? internalExpanded;\n\n const setValue = useCallback(\n (next: boolean) => {\n if (!isControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [isControlled, onExpandedChange],\n );\n\n return [value, setValue] as const;\n}\n\nexport function ExpandableActionBar({\n items,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n activeId,\n onAction,\n size = \"md\",\n expandOnHover = true,\n expandOnFocus = true,\n collapseDelay = 90,\n className,\n classNames,\n renderItem,\n}: ExpandableActionBarProps) {\n const reduce = useReducedMotion();\n const layoutId = useId();\n const [isExpanded, setIsExpanded] = useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n const [hoveredId, setHoveredId] = useState<string | null>(null);\n // Set by the tap that expands the bar, and the reason the outside-tap\n // dismisser exists at all — a hovering pointer has its own way out.\n const [tapExpanded, setTapExpanded] = useState(false);\n const collapseTimer = useRef<number | null>(null);\n const trackRef = useRef<HTMLDivElement | null>(null);\n // What the last gesture on an action was, and whether the bar was already\n // expanded when it started. A click reports neither.\n const tap = useTapGesture<boolean>();\n const hover = useHoverGesture();\n\n const clearCollapseTimer = useCallback(() => {\n if (collapseTimer.current) window.clearTimeout(collapseTimer.current);\n collapseTimer.current = null;\n }, []);\n\n const open = useCallback(() => {\n clearCollapseTimer();\n setIsExpanded(true);\n }, [clearCollapseTimer, setIsExpanded]);\n\n const close = useCallback(() => {\n clearCollapseTimer();\n const timer = window.setTimeout(() => {\n setIsExpanded(false);\n setHoveredId(null);\n setTapExpanded(false);\n }, collapseDelay);\n collapseTimer.current = timer;\n }, [clearCollapseTimer, collapseDelay, setIsExpanded]);\n\n useEffect(() => clearCollapseTimer, [clearCollapseTimer]);\n\n // A collapse from outside takes the labels with it, so the arm the tap that\n // expanded the bar left behind has to go too — otherwise the next tap runs\n // an action whose label nobody can read. Only on the way down from expanded:\n // a controlled bar that declined to expand at all keeps its arm, which is\n // what lets its second tap act.\n const wasExpanded = useRef(isExpanded);\n useEffect(() => {\n if (wasExpanded.current && !isExpanded) setTapExpanded(false);\n wasExpanded.current = isExpanded;\n }, [isExpanded]);\n\n // A finger never hovers and Safari does not focus a button on tap, so a bar a\n // tap expanded would have nothing to close it. The tap that lands elsewhere\n // stands in for the pointer leaving — and it is consumed rather than passed\n // through, because the labelled bar is exactly the kind of surface people\n // dismiss by tapping just past it, over whatever control is there.\n useDismiss(tapExpanded && isExpanded, close, trackRef, {\n behavior: \"consume\",\n });\n\n const onRootPointerEnter = (event: PointerEvent<HTMLDivElement>) => {\n // The gesture is told about every enter, `expandOnHover` or not: it is\n // what the matching leave is read against.\n if (hover.enter(event) && expandOnHover) open();\n };\n\n const onRootPointerLeave = (event: PointerEvent<HTMLDivElement>) => {\n if (!hover.leave(event)) return;\n setHoveredId(null);\n if (expandOnHover) close();\n };\n\n const onRootFocus = () => {\n if (expandOnFocus) open();\n };\n\n const onRootBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node) && expandOnFocus) {\n close();\n }\n };\n\n const activeItemId = activeId ?? items.find((item) => item.active)?.id;\n const highlightId = hoveredId ?? activeItemId;\n\n return (\n <LayoutGroup id={layoutId}>\n <motion.div\n layout=\"size\"\n // Pointer events, not the mouse pair: a tap fires compatibility\n // mouseenter/mouseleave that carry no pointerType, and the bar growing\n // under a stationary finger fired the leave before the click ever\n // landed — so one tap expanded, collapsed and ran nothing.\n onPointerEnter={onRootPointerEnter}\n onPointerLeave={onRootPointerLeave}\n onFocus={onRootFocus}\n onBlur={onRootBlur}\n transition={ITEM_TRANSITION}\n className={cn(\"inline-flex max-w-full\", classNames?.root, className)}\n >\n <motion.div\n ref={trackRef}\n layout=\"size\"\n className={cn(\n // Labelled actions can outgrow the space the bar sits in — the pill\n // stays inside it and scrolls its rail rather than running off the\n // edge, where the last action is unreachable.\n \"scrollbar-hide relative inline-flex max-w-full items-center overflow-x-auto overflow-y-hidden rounded-full border border-border bg-card/90 shadow-2xl backdrop-blur-xl\",\n SIZE_CLASS[size],\n classNames?.track,\n )}\n transition={ITEM_TRANSITION}\n >\n {items.map((item) => {\n const isActive = item.active || activeId === item.id;\n const isHighlighted = highlightId === item.id;\n\n return (\n <motion.button\n key={item.id}\n layout=\"position\"\n type=\"button\"\n disabled={item.disabled}\n title={typeof item.label === \"string\" ? item.label : undefined}\n onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n if (!hover.enter(event)) return;\n clearCollapseTimer();\n setHoveredId(item.id);\n }}\n onPointerDown={(event: PointerEvent<HTMLButtonElement>) => {\n tap.start(event, isExpanded);\n }}\n // A gesture the platform takes away sends no click, and a key\n // press starts an activation that never had a pointer behind\n // it: either one would otherwise leave the finger in place for\n // the next click to spend.\n onPointerCancel={tap.drop}\n onKeyDown={tap.drop}\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n event.currentTarget.blur();\n const gesture = tap.take();\n // Nothing reveals the labels to a finger, so the first tap\n // expands the bar and the next one runs the action. The bar\n // state is read from the gesture's start: a browser that\n // focuses the button on contact expands it mid-tap, and that\n // first tap would otherwise fire the action it was meant to\n // reveal. `tapExpanded` arms the second tap, so a controlled\n // bar that declines to expand still runs the action rather\n // than swallowing every tap.\n const firstTap =\n gesture !== null &&\n gesture.pointerType !== \"mouse\" &&\n !gesture.state &&\n !tapExpanded;\n if (firstTap && expandOnHover) {\n setTapExpanded(true);\n open();\n setHoveredId(item.id);\n return;\n }\n item.onClick?.();\n onAction?.(item);\n }}\n whileTap={reduce || item.disabled ? undefined : { scale: 0.96 }}\n transition={ITEM_TRANSITION}\n className={cn(\n \"relative isolate inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium text-muted-foreground outline-none transition-[color,background-color] duration-150 ease-out\",\n \"focus-visible:text-foreground disabled:pointer-events-none disabled:opacity-40\",\n isHighlighted && \"text-foreground\",\n ITEM_SIZE_CLASS[size],\n classNames?.item,\n isActive && classNames?.activeItem,\n )}\n >\n {isHighlighted ? (\n <motion.span\n layoutId=\"action-bar-highlight\"\n className=\"absolute inset-0 -z-10 rounded-full bg-muted/80\"\n transition={ITEM_TRANSITION}\n />\n ) : null}\n\n {renderItem ? (\n renderItem(item, { expanded: isExpanded, active: isActive })\n ) : (\n <>\n <span\n className={cn(\n \"inline-flex shrink-0 items-center justify-center\",\n ICON_SIZE_CLASS[size],\n classNames?.icon,\n )}\n >\n {item.icon}\n </span>\n\n <motion.span\n aria-hidden={!isExpanded}\n animate={\n reduce\n ? {\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n marginLeft: isExpanded ? 8 : 0,\n x: 0,\n filter: \"blur(0px)\",\n }\n : {\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n x: isExpanded ? 0 : -4,\n marginLeft: isExpanded ? 8 : 0,\n filter: isExpanded ? \"blur(0px)\" : \"blur(3px)\",\n }\n }\n transition={reduce ? { duration: 0 } : LABEL_TRANSITION}\n className={cn(\n \"inline-block overflow-hidden whitespace-nowrap\",\n classNames?.label,\n )}\n >\n {item.label}\n </motion.span>\n\n {item.shortcut ? (\n <motion.span\n aria-hidden={!isExpanded}\n animate={{\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n marginLeft: isExpanded ? 4 : 0,\n }}\n transition={LABEL_TRANSITION}\n className={cn(\n \"hidden overflow-hidden whitespace-nowrap text-[10px] text-muted-foreground sm:inline-block\",\n classNames?.shortcut,\n )}\n >\n {item.shortcut}\n </motion.span>\n ) : null}\n\n {item.badge ? (\n <span\n className={cn(\n \"ml-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] text-primary-foreground leading-none\",\n !isExpanded && \"absolute top-0.5 right-0.5\",\n classNames?.badge,\n )}\n >\n {item.badge}\n </span>\n ) : null}\n </>\n )}\n </motion.button>\n );\n })}\n </motion.div>\n </motion.div>\n </LayoutGroup>\n );\n}\n\nexport function useExpandableActionBar(items: ExpandableActionBarItem[]) {\n const [expanded, setExpanded] = useState(false);\n const [activeId, setActiveId] = useState(items[0]?.id);\n\n const activeItem = useMemo(() => items.find((item) => item.id === activeId), [activeId, items]);\n\n return useMemo(\n () => ({ expanded, setExpanded, activeId, setActiveId, activeItem }),\n [activeId, activeItem, expanded],\n );\n}\n"],"mappings":";;;;;;;;;AAsEA,MAAM,kBAA8B;CAClC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,mBAA+B;CACnC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;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AI;SACpB,YAAY,aAAa,IAAI;SAC7B,QAAQ,aAAa,cAAc;QACrC;QAEN,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;QACvC,WAAW,GACT,kDACA,YAAY,KACd;QAEC,UAAA,KAAK;OACK,CAAA;OAEZ,KAAK,WACJ,oBAAC,OAAO,MAAR;QACE,eAAa,CAAC;QACd,SAAS;SACP,OAAO,aAAa,SAAS;SAC7B,SAAS,aAAa,IAAI;SAC1B,YAAY,aAAa,IAAI;QAC/B;QACA,YAAY;QACZ,WAAW,GACT,8FACA,YAAY,QACd;QAEC,UAAA,KAAK;OACK,CAAA,IACX;OAEH,KAAK,QACJ,oBAAC,QAAD;QACE,WAAW,GACT,gJACA,CAAC,cAAc,8BACf,YAAY,KACd;QAEC,UAAA,KAAK;OACF,CAAA,IACJ;MACJ,EAAA,CAAA,CAES;KAxIR,GAAA,KAAK,EAwIG;IAEnB,CAAC;GACS,CAAA;EACF,CAAA;CACD,CAAA;AAEjB;AAEA,SAAgB,uBAAuB,OAAkC;CACvE,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,UAAU,eAAe,SAAS,MAAM,EAAE,EAAE,EAAE;CAErD,MAAM,aAAa,cAAc,MAAM,MAAM,SAAS,KAAK,OAAO,QAAQ,GAAG,CAAC,UAAU,KAAK,CAAC;CAE9F,OAAO,eACE;EAAE;EAAU;EAAa;EAAU;EAAa;CAAW,IAClE;EAAC;EAAU;EAAY;CAAQ,CACjC;AACF"}
|
|
@@ -5,9 +5,9 @@ import { StatefulButton } from "./button/stateful.js";
|
|
|
5
5
|
import "./button/index.js";
|
|
6
6
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
7
7
|
import { cn } from "@kumix/utils";
|
|
8
|
+
import { AlertCircle, MessageSquare, X } from "lucide-react";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
10
|
-
import { AlertCircle, MessageSquare, X } from "lucide-react";
|
|
11
11
|
//#region src/components/motion/feedback-widget.tsx
|
|
12
12
|
const SUCCESS_DURATION_MS = 1600;
|
|
13
13
|
const MORPH_OPEN_EASE = [
|
|
@@ -3,9 +3,9 @@ import { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from "../../lib/ease.js";
|
|
|
3
3
|
import { SharedLayoutBg } from "./shared-layout-bg.js";
|
|
4
4
|
import { Children, Fragment, isValidElement, useCallback, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
+
import { ChevronRight, File, Folder, FolderOpen } from "lucide-react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
8
|
-
import { ChevronRight, File, Folder, FolderOpen } from "lucide-react";
|
|
9
9
|
//#region src/components/motion/file-tree.tsx
|
|
10
10
|
function FileTreeFolder(_props) {
|
|
11
11
|
return null;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
3
3
|
import { useCallback, useId, useRef, useState } from "react";
|
|
4
4
|
import { cn } from "@kumix/utils";
|
|
5
|
+
import { AlertCircle, CheckCircle2, FileArchive, FileAudio, FileCode2, FileIcon, FileImage, FileSpreadsheet, FileText, FileVideo, Loader2, RotateCcw, UploadCloud, X } from "lucide-react";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
7
|
-
import { AlertCircle, CheckCircle2, FileArchive, FileAudio, FileCode2, FileIcon, FileImage, FileSpreadsheet, FileText, FileVideo, Loader2, RotateCcw, UploadCloud, X } from "lucide-react";
|
|
8
8
|
//#region src/components/motion/file-upload.tsx
|
|
9
9
|
const ROW_TRANSITION = {
|
|
10
10
|
duration: .22,
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { EASE_OUT, SPRING_PANEL } from "../../lib/ease.js";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { cn } from "@kumix/utils";
|
|
5
|
+
import { AlertCircle, Inbox } from "lucide-react";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { motion, useReducedMotion } from "motion/react";
|
|
7
|
-
import { AlertCircle, Inbox } from "lucide-react";
|
|
8
8
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
9
9
|
//#region src/components/motion/infinite-masonry.tsx
|
|
10
10
|
function useMasonryMetrics({ elementRef, gap, maxColumns, minColumnWidth }) {
|
|
@@ -4,9 +4,9 @@ import { useRowCursor } from "../../hooks/use-row-cursor.js";
|
|
|
4
4
|
import { EASE_OUT, SPRING_LAYOUT } from "../../lib/ease.js";
|
|
5
5
|
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { cn } from "@kumix/utils";
|
|
7
|
+
import { Search } from "lucide-react";
|
|
7
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
import { AnimatePresence, LayoutGroup, motion, useReducedMotion } from "motion/react";
|
|
9
|
-
import { Search } from "lucide-react";
|
|
10
10
|
import { createPortal } from "react-dom";
|
|
11
11
|
//#region src/components/motion/morphing-search.tsx
|
|
12
12
|
const SEARCH_MORPH = {
|
|
@@ -3,9 +3,9 @@ import { TOUCH_GESTURE_CLASS, capturePointer } from "../../lib/touch.js";
|
|
|
3
3
|
import { EASE_OUT, SPRING_GLIDE, SPRING_PRESS } from "../../lib/ease.js";
|
|
4
4
|
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
+
import { X } from "lucide-react";
|
|
6
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useSpring, useTransform } from "motion/react";
|
|
8
|
-
import { X } from "lucide-react";
|
|
9
9
|
import { createPortal } from "react-dom";
|
|
10
10
|
//#region src/components/motion/morphing-tabs.tsx
|
|
11
11
|
const DRAG_THRESHOLD = 5;
|
|
@@ -3,9 +3,9 @@ import { EASE_OUT, SPRING_LAYOUT } from "../../../lib/ease.js";
|
|
|
3
3
|
import { MultiSelectGroupContext, useMultiSelectContext } from "./context.js";
|
|
4
4
|
import { useContext, useId, useLayoutEffect, useMemo, useRef } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
+
import { Check } from "lucide-react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { motion } from "motion/react";
|
|
8
|
-
import { Check } from "lucide-react";
|
|
9
9
|
//#region src/components/motion/multi-select/list.tsx
|
|
10
10
|
function MultiSelectList({ children, ariaLabel = "Options", className }) {
|
|
11
11
|
const context = useMultiSelectContext("MultiSelectList");
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from "../../../lib/ease.js";
|
|
3
3
|
import { mergeRefs, useMultiSelectContext } from "./context.js";
|
|
4
4
|
import { cn } from "@kumix/utils";
|
|
5
|
+
import { ChevronsUpDown, Search, X } from "lucide-react";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { AnimatePresence, motion } from "motion/react";
|
|
7
|
-
import { ChevronsUpDown, Search, X } from "lucide-react";
|
|
8
8
|
//#region src/components/motion/multi-select/trigger.tsx
|
|
9
9
|
function MultiSelectTrigger({ children, className }) {
|
|
10
10
|
const context = useMultiSelectContext("MultiSelectTrigger");
|
|
@@ -34,7 +34,7 @@ function NotFoundActions({ homeHref = NOT_FOUND_DEFAULTS.homeHref, homeLabel = N
|
|
|
34
34
|
whileTap,
|
|
35
35
|
whileHover,
|
|
36
36
|
transition: SPRING_PRESS,
|
|
37
|
-
className: "inline-flex h-11 select-none items-center justify-center rounded-full border border-border bg-card px-6 font-medium text-foreground text-sm transition-colors hover:bg-
|
|
37
|
+
className: "inline-flex h-11 select-none items-center justify-center rounded-full border border-border bg-card px-6 font-medium text-foreground text-sm transition-colors hover:bg-muted/60",
|
|
38
38
|
children: browseLabel
|
|
39
39
|
})]
|
|
40
40
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","names":[],"sources":["../../../../src/components/motion/not-found/shared.tsx"],"sourcesContent":["\"use client\";\n\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../../hooks/use-hover-capable\";\nimport { SPRING_PRESS } from \"../../../lib/ease\";\n\nexport interface NotFoundProps {\n className?: string;\n /** The big status code. */\n code?: string;\n title?: string;\n description?: string;\n homeHref?: string;\n homeLabel?: string;\n browseHref?: string;\n browseLabel?: string;\n}\n\nexport const NOT_FOUND_DEFAULTS = {\n code: \"404\",\n title: \"Page not found\",\n description: \"The page you are looking for moved, vanished, or never existed.\",\n homeHref: \"/\",\n homeLabel: \"Back home\",\n browseHref: \"/components/motion\",\n browseLabel: \"Browse components\",\n} as const;\n\ntype ActionsProps = Pick<\n NotFoundProps,\n \"homeHref\" | \"homeLabel\" | \"browseHref\" | \"browseLabel\" | \"className\"\n>;\n\n/** The shared dual CTA: a primary \"Back home\" and a secondary \"Browse\". */\nexport function NotFoundActions({\n homeHref = NOT_FOUND_DEFAULTS.homeHref,\n homeLabel = NOT_FOUND_DEFAULTS.homeLabel,\n browseHref = NOT_FOUND_DEFAULTS.browseHref,\n browseLabel = NOT_FOUND_DEFAULTS.browseLabel,\n className,\n}: ActionsProps) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const whileTap = reduce ? undefined : { scale: 0.96 };\n const whileHover = reduce || !canHover ? undefined : { scale: 1.02 };\n\n return (\n <div className={cn(\"flex flex-wrap items-center justify-center gap-3\", className)}>\n <motion.a\n href={homeHref}\n whileTap={whileTap}\n whileHover={whileHover}\n transition={SPRING_PRESS}\n className=\"inline-flex h-11 select-none items-center justify-center rounded-full bg-primary px-6 font-medium text-primary-foreground text-sm transition-colors hover:bg-primary/90\"\n >\n {homeLabel}\n </motion.a>\n <motion.a\n href={browseHref}\n whileTap={whileTap}\n whileHover={whileHover}\n transition={SPRING_PRESS}\n className=\"inline-flex h-11 select-none items-center justify-center rounded-full border border-border bg-card px-6 font-medium text-foreground text-sm transition-colors hover:bg-
|
|
1
|
+
{"version":3,"file":"shared.js","names":[],"sources":["../../../../src/components/motion/not-found/shared.tsx"],"sourcesContent":["\"use client\";\n\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../../hooks/use-hover-capable\";\nimport { SPRING_PRESS } from \"../../../lib/ease\";\n\nexport interface NotFoundProps {\n className?: string;\n /** The big status code. */\n code?: string;\n title?: string;\n description?: string;\n homeHref?: string;\n homeLabel?: string;\n browseHref?: string;\n browseLabel?: string;\n}\n\nexport const NOT_FOUND_DEFAULTS = {\n code: \"404\",\n title: \"Page not found\",\n description: \"The page you are looking for moved, vanished, or never existed.\",\n homeHref: \"/\",\n homeLabel: \"Back home\",\n browseHref: \"/components/motion\",\n browseLabel: \"Browse components\",\n} as const;\n\ntype ActionsProps = Pick<\n NotFoundProps,\n \"homeHref\" | \"homeLabel\" | \"browseHref\" | \"browseLabel\" | \"className\"\n>;\n\n/** The shared dual CTA: a primary \"Back home\" and a secondary \"Browse\". */\nexport function NotFoundActions({\n homeHref = NOT_FOUND_DEFAULTS.homeHref,\n homeLabel = NOT_FOUND_DEFAULTS.homeLabel,\n browseHref = NOT_FOUND_DEFAULTS.browseHref,\n browseLabel = NOT_FOUND_DEFAULTS.browseLabel,\n className,\n}: ActionsProps) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const whileTap = reduce ? undefined : { scale: 0.96 };\n const whileHover = reduce || !canHover ? undefined : { scale: 1.02 };\n\n return (\n <div className={cn(\"flex flex-wrap items-center justify-center gap-3\", className)}>\n <motion.a\n href={homeHref}\n whileTap={whileTap}\n whileHover={whileHover}\n transition={SPRING_PRESS}\n className=\"inline-flex h-11 select-none items-center justify-center rounded-full bg-primary px-6 font-medium text-primary-foreground text-sm transition-colors hover:bg-primary/90\"\n >\n {homeLabel}\n </motion.a>\n <motion.a\n href={browseHref}\n whileTap={whileTap}\n whileHover={whileHover}\n transition={SPRING_PRESS}\n className=\"inline-flex h-11 select-none items-center justify-center rounded-full border border-border bg-card px-6 font-medium text-foreground text-sm transition-colors hover:bg-muted/60\"\n >\n {browseLabel}\n </motion.a>\n </div>\n );\n}\n\n/** Centers a variant and gives it a consistent minimum stage height. */\nexport function NotFoundStage({\n className,\n children,\n}: {\n className?: string;\n children: React.ReactNode;\n}) {\n return (\n <div\n className={cn(\n \"flex min-h-[420px] w-full flex-col items-center justify-center gap-8 px-4 text-center\",\n className,\n )}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAoBA,MAAa,qBAAqB;CAChC,MAAM;CACN,OAAO;CACP,aAAa;CACb,UAAU;CACV,WAAW;CACX,YAAY;CACZ,aAAa;AACf;;AAQA,SAAgB,gBAAgB,EAC9B,WAAW,mBAAmB,UAC9B,YAAY,mBAAmB,WAC/B,aAAa,mBAAmB,YAChC,cAAc,mBAAmB,aACjC,aACe;CACf,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,gBAAgB;CACjC,MAAM,WAAW,SAAS,KAAA,IAAY,EAAE,OAAO,IAAK;CACpD,MAAM,aAAa,UAAU,CAAC,WAAW,KAAA,IAAY,EAAE,OAAO,KAAK;CAEnE,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,oDAAoD,SAAS;EAAhF,UAAA,CACE,oBAAC,OAAO,GAAR;GACE,MAAM;GACI;GACE;GACZ,YAAY;GACZ,WAAU;GAET,UAAA;EACO,CAAA,GACV,oBAAC,OAAO,GAAR;GACE,MAAM;GACI;GACE;GACZ,YAAY;GACZ,WAAU;GAET,UAAA;EACO,CAAA,CACP;;AAET;;AAGA,SAAgB,cAAc,EAC5B,WACA,YAIC;CACD,OACE,oBAAC,OAAD;EACE,WAAW,GACT,yFACA,SACF;EAEC;CACE,CAAA;AAET"}
|
|
@@ -6,9 +6,9 @@ import { EASE_OUT, SPRING_LAYOUT } from "../../lib/ease.js";
|
|
|
6
6
|
import { ActionSwapText } from "./action-swap.js";
|
|
7
7
|
import { useCallback, useRef, useState } from "react";
|
|
8
8
|
import { cn } from "@kumix/utils";
|
|
9
|
+
import { ArrowUpRight, BellOff } from "lucide-react";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
import { motion, useReducedMotion } from "motion/react";
|
|
11
|
-
import { ArrowUpRight, BellOff } from "lucide-react";
|
|
12
12
|
//#region src/components/motion/notification-stack.tsx
|
|
13
13
|
const STACK_PEEK = 8;
|
|
14
14
|
const STACK_INSET = 12;
|
|
@@ -3,9 +3,9 @@ import { useHoverCapable } from "../../hooks/use-hover-capable.js";
|
|
|
3
3
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
4
4
|
import { useCallback, useId, useLayoutEffect, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
+
import { MoreHorizontal, X } from "lucide-react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
8
|
-
import { MoreHorizontal, X } from "lucide-react";
|
|
9
9
|
//#region src/components/motion/overflow-actions.tsx
|
|
10
10
|
const SHELL_TRANSITION = {
|
|
11
11
|
type: "spring",
|
|
@@ -3,9 +3,9 @@ import { useHoverCapable } from "../../hooks/use-hover-capable.js";
|
|
|
3
3
|
import { SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
|
|
4
4
|
import { useCallback, useEffect, useId, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
+
import { X } from "lucide-react";
|
|
6
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { AnimatePresence, LayoutGroup, motion, useReducedMotion } from "motion/react";
|
|
8
|
-
import { X } from "lucide-react";
|
|
9
9
|
import { createPortal } from "react-dom";
|
|
10
10
|
//#region src/components/motion/project-folder.tsx
|
|
11
11
|
const MAX_PREVIEWS = 5;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { cn } from "@kumix/utils";
|
|
4
|
+
import { Check, ChevronDown } from "lucide-react";
|
|
4
5
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
6
|
-
import { Check, ChevronDown } from "lucide-react";
|
|
7
7
|
//#region src/components/motion/select-morph.tsx
|
|
8
8
|
const MORPH = {
|
|
9
9
|
type: "spring",
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
3
3
|
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { cn } from "@kumix/utils";
|
|
5
|
+
import { Check, ChevronDown } from "lucide-react";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { motion, useReducedMotion } from "motion/react";
|
|
7
|
-
import { Check, ChevronDown } from "lucide-react";
|
|
8
8
|
//#region src/components/motion/select.tsx
|
|
9
9
|
const INSTANT_TRANSITION = { duration: 0 };
|
|
10
10
|
const CHEVRON_TRANSITION = {
|
|
@@ -54,7 +54,7 @@ const SharedLayoutBg = forwardRef(function SharedLayoutBg({ children, as = "div"
|
|
|
54
54
|
children: activeId === childKey ? /* @__PURE__ */ jsx(motion.div, {
|
|
55
55
|
layoutId: `shared-bg-${uid}`,
|
|
56
56
|
transition: reduce ? { duration: 0 } : SPRING_LAYOUT,
|
|
57
|
-
className: cn("pointer-events-none h-full w-full rounded-2xl bg-
|
|
57
|
+
className: cn("pointer-events-none h-full w-full rounded-2xl bg-muted/80", pillClassName)
|
|
58
58
|
}) : null
|
|
59
59
|
}) : null
|
|
60
60
|
}), /* @__PURE__ */ jsx("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-layout-bg.js","names":[],"sources":["../../../src/components/motion/shared-layout-bg.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n cloneElement,\n forwardRef,\n type HTMLAttributes,\n isValidElement,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n useId,\n useState,\n} from \"react\";\nimport {\n AnimatePresence,\n type HTMLMotionProps,\n motion,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT } from \"../../lib/ease\";\n\nexport interface SharedLayoutBgProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n children: ReactNode;\n /** Semantic container used for the children. */\n as?: \"div\" | \"ul\";\n /** Tailwind class applied to the moving pill. Defaults to a subtle foreground tint. */\n pillClassName?: string;\n /** Horizontal inset of the pill relative to each row (px). Default 20. */\n inset?: number;\n /** Optional positioning override for the pill wrapper inside each item. */\n pillContainerClassName?: string;\n}\n\nconst variants: Variants = {\n initial: { opacity: 0, filter: \"blur(6px)\" },\n animate: { opacity: 1, filter: \"blur(0px)\" },\n exit: (isActive: boolean) => (!isActive ? { opacity: 0, filter: \"blur(6px)\" } : {}),\n};\n\nconst reducedVariants: Variants = {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: (isActive: boolean) => (!isActive ? { opacity: 0 } : {}),\n};\n\nexport const SharedLayoutBg = forwardRef<HTMLElement, SharedLayoutBgProps>(function SharedLayoutBg(\n {\n children,\n as = \"div\",\n className,\n onMouseLeave,\n pillClassName,\n pillContainerClassName,\n inset = 20,\n ...props\n },\n forwardedRef,\n) {\n const [activeId, setActiveId] = useState<string | null>(null);\n const uid = useId();\n const reduce = useReducedMotion();\n\n const renderedChildren = Children.toArray(children)\n .filter(isValidElement)\n .map((child, index) => {\n const el = child as ReactElement<{\n className?: string;\n onMouseEnter?: () => void;\n children?: ReactNode;\n }>;\n const childKey = el.key ? String(el.key) : `item-${index}`;\n return cloneElement(\n el,\n {\n key: childKey,\n className: cn(\"relative\", el.props.className),\n onMouseEnter: () => {\n el.props.onMouseEnter?.();\n setActiveId(childKey);\n },\n },\n <>\n <AnimatePresence custom={activeId !== null}>\n {activeId !== null ? (\n <motion.div\n variants={reduce ? reducedVariants : variants}\n initial=\"initial\"\n animate=\"animate\"\n exit=\"exit\"\n custom={activeId !== null}\n className={cn(\"pointer-events-none absolute inset-y-0\", pillContainerClassName)}\n style={{ left: -inset, right: -inset }}\n >\n {activeId === childKey ? (\n <motion.div\n layoutId={`shared-bg-${uid}`}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className={cn(\n \"pointer-events-none h-full w-full rounded-2xl bg-
|
|
1
|
+
{"version":3,"file":"shared-layout-bg.js","names":[],"sources":["../../../src/components/motion/shared-layout-bg.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n cloneElement,\n forwardRef,\n type HTMLAttributes,\n isValidElement,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n useId,\n useState,\n} from \"react\";\nimport {\n AnimatePresence,\n type HTMLMotionProps,\n motion,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT } from \"../../lib/ease\";\n\nexport interface SharedLayoutBgProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n children: ReactNode;\n /** Semantic container used for the children. */\n as?: \"div\" | \"ul\";\n /** Tailwind class applied to the moving pill. Defaults to a subtle foreground tint. */\n pillClassName?: string;\n /** Horizontal inset of the pill relative to each row (px). Default 20. */\n inset?: number;\n /** Optional positioning override for the pill wrapper inside each item. */\n pillContainerClassName?: string;\n}\n\nconst variants: Variants = {\n initial: { opacity: 0, filter: \"blur(6px)\" },\n animate: { opacity: 1, filter: \"blur(0px)\" },\n exit: (isActive: boolean) => (!isActive ? { opacity: 0, filter: \"blur(6px)\" } : {}),\n};\n\nconst reducedVariants: Variants = {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: (isActive: boolean) => (!isActive ? { opacity: 0 } : {}),\n};\n\nexport const SharedLayoutBg = forwardRef<HTMLElement, SharedLayoutBgProps>(function SharedLayoutBg(\n {\n children,\n as = \"div\",\n className,\n onMouseLeave,\n pillClassName,\n pillContainerClassName,\n inset = 20,\n ...props\n },\n forwardedRef,\n) {\n const [activeId, setActiveId] = useState<string | null>(null);\n const uid = useId();\n const reduce = useReducedMotion();\n\n const renderedChildren = Children.toArray(children)\n .filter(isValidElement)\n .map((child, index) => {\n const el = child as ReactElement<{\n className?: string;\n onMouseEnter?: () => void;\n children?: ReactNode;\n }>;\n const childKey = el.key ? String(el.key) : `item-${index}`;\n return cloneElement(\n el,\n {\n key: childKey,\n className: cn(\"relative\", el.props.className),\n onMouseEnter: () => {\n el.props.onMouseEnter?.();\n setActiveId(childKey);\n },\n },\n <>\n <AnimatePresence custom={activeId !== null}>\n {activeId !== null ? (\n <motion.div\n variants={reduce ? reducedVariants : variants}\n initial=\"initial\"\n animate=\"animate\"\n exit=\"exit\"\n custom={activeId !== null}\n className={cn(\"pointer-events-none absolute inset-y-0\", pillContainerClassName)}\n style={{ left: -inset, right: -inset }}\n >\n {activeId === childKey ? (\n <motion.div\n layoutId={`shared-bg-${uid}`}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className={cn(\n \"pointer-events-none h-full w-full rounded-2xl bg-muted/80\",\n pillClassName,\n )}\n />\n ) : null}\n </motion.div>\n ) : null}\n </AnimatePresence>\n <div className=\"relative z-10\">{el.props.children}</div>\n </>,\n );\n });\n\n const handleMouseLeave = (event: MouseEvent<HTMLElement>) => {\n setActiveId(null);\n onMouseLeave?.(event);\n };\n\n // layoutRoot scopes the pill's layout projection to this list, so fixed or\n // scrolled ancestors can't smear scroll offsets into its movement.\n return as === \"ul\" ? (\n <motion.ul\n {...(props as HTMLMotionProps<\"ul\">)}\n ref={forwardedRef as Ref<HTMLUListElement>}\n layoutRoot\n onMouseLeave={handleMouseLeave}\n className={cn(\"flex w-full flex-col\", className)}\n >\n {renderedChildren}\n </motion.ul>\n ) : (\n <motion.div\n {...(props as HTMLMotionProps<\"div\">)}\n ref={forwardedRef as Ref<HTMLDivElement>}\n layoutRoot\n onMouseLeave={handleMouseLeave}\n className={cn(\"flex w-full flex-col\", className)}\n >\n {renderedChildren}\n </motion.div>\n );\n});\n"],"mappings":";;;;;;;AAsCA,MAAM,WAAqB;CACzB,SAAS;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC3C,SAAS;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC3C,OAAO,aAAuB,CAAC,WAAW;EAAE,SAAS;EAAG,QAAQ;CAAY,IAAI,CAAC;AACnF;AAEA,MAAM,kBAA4B;CAChC,SAAS,EAAE,SAAS,EAAE;CACtB,SAAS,EAAE,SAAS,EAAE;CACtB,OAAO,aAAuB,CAAC,WAAW,EAAE,SAAS,EAAE,IAAI,CAAC;AAC9D;AAEA,MAAa,iBAAiB,WAA6C,SAAS,eAClF,EACE,UACA,KAAK,OACL,WACA,cACA,eACA,wBACA,QAAQ,IACR,GAAG,SAEL,cACA;CACA,MAAM,CAAC,UAAU,eAAe,SAAwB,IAAI;CAC5D,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS,iBAAiB;CAEhC,MAAM,mBAAmB,SAAS,QAAQ,QAAQ,CAAC,CAChD,OAAO,cAAc,CAAC,CACtB,KAAK,OAAO,UAAU;EACrB,MAAM,KAAK;EAKX,MAAM,WAAW,GAAG,MAAM,OAAO,GAAG,GAAG,IAAI,QAAQ;EACnD,OAAO,aACL,IACA;GACE,KAAK;GACL,WAAW,GAAG,YAAY,GAAG,MAAM,SAAS;GAC5C,oBAAoB;IAClB,GAAG,MAAM,eAAe;IACxB,YAAY,QAAQ;GACtB;EACF,GACA,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,iBAAD;GAAiB,QAAQ,aAAa;GACnC,UAAA,aAAa,OACZ,oBAAC,OAAO,KAAR;IACE,UAAU,SAAS,kBAAkB;IACrC,SAAQ;IACR,SAAQ;IACR,MAAK;IACL,QAAQ,aAAa;IACrB,WAAW,GAAG,0CAA0C,sBAAsB;IAC9E,OAAO;KAAE,MAAM,CAAC;KAAO,OAAO,CAAC;IAAM;IAEpC,UAAA,aAAa,WACZ,oBAAC,OAAO,KAAR;KACE,UAAU,aAAa;KACvB,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;KACvC,WAAW,GACT,6DACA,aACF;IACD,CAAA,IACC;GACM,CAAA,IACV;EACW,CAAA,GACjB,oBAAC,OAAD;GAAK,WAAU;GAAiB,UAAA,GAAG,MAAM;EAAc,CAAA,CACvD,EAAA,CAAA,CACJ;CACF,CAAC;CAEH,MAAM,oBAAoB,UAAmC;EAC3D,YAAY,IAAI;EAChB,eAAe,KAAK;CACtB;CAIA,OAAO,OAAO,OACZ,oBAAC,OAAO,IAAR;EACE,GAAK;EACL,KAAK;EACL,YAAA;EACA,cAAc;EACd,WAAW,GAAG,wBAAwB,SAAS;EAE9C,UAAA;CACQ,CAAA,IAEX,oBAAC,OAAO,KAAR;EACE,GAAK;EACL,KAAK;EACL,YAAA;EACA,cAAc;EACd,WAAW,GAAG,wBAAwB,SAAS;EAE9C,UAAA;CACS,CAAA;AAEhB,CAAC"}
|
|
@@ -6,9 +6,9 @@ import { Checkbox } from "./checkbox.js";
|
|
|
6
6
|
import { Input } from "./input.js";
|
|
7
7
|
import { useCallback, useId, useMemo, useState } from "react";
|
|
8
8
|
import { cn } from "@kumix/utils";
|
|
9
|
+
import { Eye, EyeOff, Lock, Mail, User } from "lucide-react";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
11
|
-
import { Eye, EyeOff, Lock, Mail, User } from "lucide-react";
|
|
12
12
|
//#region src/components/motion/signup-form.tsx
|
|
13
13
|
const EMPTY_VALUES = {
|
|
14
14
|
name: "",
|
|
@@ -80,7 +80,7 @@ function SlideActionButton({ children, completeLabel = "Complete", threshold = .
|
|
|
80
80
|
};
|
|
81
81
|
return /* @__PURE__ */ jsxs("div", {
|
|
82
82
|
ref: trackRef,
|
|
83
|
-
className: cn("relative h-16 w-72 overflow-hidden rounded-[22px] bg-
|
|
83
|
+
className: cn("relative h-16 w-72 overflow-hidden rounded-[22px] bg-muted p-1", "ring-1 ring-primary/10", TOUCH_GESTURE_CONTENT_CLASS, className),
|
|
84
84
|
...rest,
|
|
85
85
|
children: [
|
|
86
86
|
/* @__PURE__ */ jsx(motion.span, {
|