{"version":3,"file":"remix-reorder.mjs","sources":["../../src/remix-reorder.ts"],"sourcesContent":["import {\n    isMotionValue,\n    motionValue,\n    transformValue,\n    visualElementStore,\n    type MotionValue,\n} from \"motion-dom\"\nimport { moveItem, type Box, type Point } from \"motion-utils\"\nimport { createElement, on, ref } from \"remix/component\"\nimport type { Handle, RemixNode } from \"remix/component\"\nimport type { ItemData, ReorderAxis } from \"./components/Reorder/types\"\nimport {\n    autoScrollIfNeeded,\n    resetAutoScrollState,\n} from \"./components/Reorder/utils/auto-scroll\"\nimport { checkReorder } from \"./components/Reorder/utils/check-reorder\"\nimport { detectAxis } from \"./components/Reorder/utils/detect-axis\"\nimport type { MotionComponentProps } from \"./remix\"\n\nexport type ReorderGroupProps<V> = Omit<MotionComponentProps, \"values\"> & {\n    /**\n     * The element to render. Defaults to `\"ul\"`.\n     */\n    as?: string\n\n    /**\n     * The axis to reorder along. By default, this is detected from the item\n     * layout. Use `\"xy\"` to explicitly enable wrapped layout reordering.\n     */\n    axis?: ReorderAxis\n\n    /**\n     * Called with the new order of `values`, and the value of the item\n     * that moved, for each step of a drag.\n     */\n    onReorder: (newOrder: V[], moved: V) => void\n\n    /**\n     * The latest values, in order.\n     */\n    values: V[]\n}\n\nexport type ReorderItemProps<V> = Omit<MotionComponentProps, \"layout\"> & {\n    /**\n     * The element to render. Defaults to `\"li\"`.\n     */\n    as?: string\n\n    /**\n     * The value in the group's `values` that this item represents.\n     */\n    value: V\n\n    /**\n     * Set to `\"position\"` to animate only the position of the item when\n     * the order changes.\n     *\n     * @default true\n     */\n    layout?: true | \"position\"\n}\n\ntype Grab = (element: Element, from?: any[]) => void\n\nexport interface ReorderContext {\n    axis: ReorderAxis\n    hasReordered: boolean\n    getElement: () => Element | undefined\n    registerItem: (value: any, layout: Box) => void\n    updateOrder: (value: any, offset: Point, velocity: Point) => void\n    onKeyDown: (\n        event: KeyboardEvent,\n        item: any,\n        from: any[] | undefined,\n        grab: Grab\n    ) => void\n}\n\nconst keys = [\"ArrowUp\", \"ArrowLeft\", \"ArrowDown\", \"ArrowRight\"]\n\n/**\n * Creates `Reorder.Group` and `Reorder.Item`, rendering the components of\n * `motion`.\n */\nexport interface ReorderComponents {\n    Group: (\n        handle: Handle<ReorderGroupProps<any>, ReorderContext>\n    ) => () => RemixNode\n    Item: (handle: Handle<ReorderItemProps<any>>) => () => RemixNode\n}\n\nexport function createReorder(motion: any): ReorderComponents {\n    /**\n     * A list of items that can be reordered by drag or keyboard, with the\n     * same props as React's `Reorder.Group`.\n     */\n    function Group(handle: Handle<ReorderGroupProps<any>, ReorderContext>) {\n        const itemLayouts = new Map<any, Box>()\n        let detectedAxis: ReorderAxis = \"y\"\n        let isReordering = false\n        let element: Element | undefined\n        let renderedValues: any[] | undefined\n\n        const getOrder = (): ItemData<any>[] =>\n            handle.props.values.flatMap((value) => {\n                const layout = itemLayouts.get(value)\n                return layout ? [{ value, layout }] : []\n            })\n\n        const isRTL = () =>\n            !!element && getComputedStyle(element).direction === \"rtl\"\n\n        /**\n         * Write the new order of the measured items back into the slots they\n         * hold in `values`, leaving unmeasured values in place.\n         */\n        const commit = (newOrder: ItemData<any>[], moved: any) => {\n            const { values, onReorder } = handle.props\n            let i = 0\n            const newValues = values.map((value) =>\n                itemLayouts.has(value) ? newOrder[i++].value : value\n            )\n            newValues.some((value, j) => value !== values[j]) &&\n                onReorder(newValues, moved)\n        }\n\n        const context: ReorderContext = {\n            axis: \"y\",\n            hasReordered: false,\n            getElement: () => element,\n            /**\n             * Space grabs and drops the item, arrows along `axis` move the\n             * grabbed item one place (Left and Right swap in RTL) and Escape\n             * restores the order in `from`, the values when it was grabbed.\n             */\n            onKeyDown: (event, item, from, grab) => {\n                const { key, currentTarget } = event\n                if (\n                    event.defaultPrevented ||\n                    event.target !== currentTarget ||\n                    event.altKey ||\n                    event.ctrlKey ||\n                    event.metaKey\n                ) {\n                    return\n                }\n\n                const { axis } = context\n                const order = getOrder()\n                const keyIndex = keys.indexOf(key)\n                const isX = keyIndex % 2\n                if (key === \" \") {\n                    event.repeat ||\n                        grab(\n                            currentTarget as Element,\n                            from ? undefined : handle.props.values\n                        )\n                } else if (!from) {\n                    return\n                } else if (key === \"Escape\") {\n                    const kept = from.flatMap((value) =>\n                        order.filter((data) => data.value === value)\n                    )\n                    commit(\n                        order.map((data) =>\n                            from.includes(data.value) ? kept.shift()! : data\n                        ),\n                        item\n                    )\n                    grab(currentTarget as Element)\n                } else if (\n                    keyIndex < 0 ||\n                    (axis !== \"xy\" && axis !== (isX ? \"x\" : \"y\"))\n                ) {\n                    return\n                } else {\n                    const index = order.findIndex(({ value }) => value === item)\n                    const target =\n                        index + (keyIndex > 1 !== !!(isX && isRTL()) ? 1 : -1)\n                    index > -1 &&\n                        order[target] &&\n                        commit(moveItem(order, index, target), item)\n                }\n                event.preventDefault()\n            },\n            registerItem: (value, layout) => {\n                itemLayouts.set(value, layout)\n\n                if (!handle.props.axis) {\n                    const nextAxis = detectAxis(\n                        handle.props.values.flatMap((itemValue) => {\n                            const itemLayout = itemLayouts.get(itemValue)\n                            return itemLayout ? [itemLayout] : []\n                        })\n                    )\n\n                    if (nextAxis !== detectedAxis) {\n                        detectedAxis = nextAxis\n                        handle.update()\n                    }\n                }\n            },\n            updateOrder: (item, offset, velocity) => {\n                if (isReordering) return\n\n                const order = getOrder()\n                const newOrder = checkReorder(\n                    order,\n                    item,\n                    offset,\n                    velocity,\n                    context.axis,\n                    isRTL() ? \"rtl\" : \"ltr\"\n                )\n\n                if (order !== newOrder) {\n                    isReordering = context.hasReordered = true\n                    commit(newOrder, item)\n                }\n            },\n        }\n\n        return () => {\n            const {\n                as = \"ul\",\n                axis,\n                values,\n                onReorder,\n                style,\n                mix,\n                children,\n                ...props\n            } = handle.props\n\n            const valuesSet = new Set(values)\n            itemLayouts.forEach((_, value) => {\n                if (!valuesSet.has(value)) itemLayouts.delete(value)\n            })\n\n            /**\n             * Only allow the next reorder once the new order has rendered.\n             */\n            if (values !== renderedValues) {\n                renderedValues = values\n                handle.queueTask(() => (isReordering = false))\n            }\n\n            context.axis = axis || detectedAxis\n            handle.context.set(context)\n\n            return createElement(\n                motion[as],\n                {\n                    ...props,\n                    /**\n                     * Scroll anchoring would move the page while items\n                     * reorder, and with it the dragged item.\n                     */\n                    style: { overflowAnchor: \"none\", ...style },\n                    mix: [\n                        ref((node) => (element = node)),\n                        /**\n                         * The release that ends a reordering drag isn't a\n                         * click. Clicks with no pointer press behind them\n                         * (detail 0, e.g. keyboard) are left alone.\n                         */\n                        on<HTMLElement, \"pointerdown\">(\n                            \"pointerdown\",\n                            () => {\n                                context.hasReordered = false\n                            },\n                            true\n                        ),\n                        on<HTMLElement, \"click\">(\n                            \"click\",\n                            (event) => {\n                                if (context.hasReordered && event.detail) {\n                                    context.hasReordered = false\n                                    event.stopPropagation()\n                                    event.preventDefault()\n                                }\n                            },\n                            true\n                        ),\n                        mix,\n                    ],\n                },\n                children\n            )\n        }\n    }\n\n    /**\n     * An item in a `Reorder.Group`, with the same props as React's\n     * `Reorder.Item`.\n     */\n    function Item(handle: Handle<ReorderItemProps<any>>) {\n        /**\n         * The group's values when this item was grabbed with the keyboard, for\n         * Escape to restore. Set only while grabbed.\n         */\n        let grabbedFrom: any[] | undefined\n        const defaultX = motionValue(0)\n        const defaultY = motionValue(0)\n        let zIndex: { x: MotionValue; y: MotionValue; value: MotionValue }\n\n        const getGroup = () => handle.context.get(Group) as ReorderContext\n\n        /**\n         * A keyboard grab is a drag without a pointer, so it shares whileDrag.\n         */\n        const grab: Grab = (element, from) => {\n            grabbedFrom = from\n            visualElementStore\n                .get(element)\n                ?.animationState?.setActive(\"whileDrag\", !!from)\n        }\n\n        return () => {\n            const {\n                as = \"li\",\n                value,\n                style = {},\n                layout = true,\n                onDrag,\n                onDragEnd,\n                mix,\n                children,\n                ...props\n            } = handle.props\n            const group = getGroup()\n            const { axis } = group\n\n            const x = isMotionValue(style.x) ? style.x : defaultX\n            const y = isMotionValue(style.y) ? style.y : defaultY\n            if (zIndex?.x !== x || zIndex.y !== y) {\n                zIndex = {\n                    x,\n                    y,\n                    value: transformValue(() =>\n                        x.get() || y.get() ? 1 : \"unset\"\n                    ),\n                }\n            }\n\n            return createElement(\n                motion[as],\n                {\n                    drag: axis === \"xy\" ? true : axis,\n                    tabIndex: 0,\n                    ...props,\n                    dragSnapToOrigin: true,\n                    style: { ...style, x, y, zIndex: zIndex.value },\n                    layout,\n                    onDrag: (event: PointerEvent, info: any) => {\n                        const { velocity, point } = info\n                        group.updateOrder(\n                            handle.props.value,\n                            { x: x.get(), y: y.get() },\n                            velocity\n                        )\n\n                        const scrollAxis =\n                            group.axis === \"xy\"\n                                ? Math.abs(velocity.x) > Math.abs(velocity.y)\n                                    ? \"x\"\n                                    : \"y\"\n                                : group.axis\n                        autoScrollIfNeeded(\n                            group.getElement() || null,\n                            point[scrollAxis],\n                            scrollAxis,\n                            velocity[scrollAxis]\n                        )\n\n                        onDrag?.(event, info)\n                    },\n                    onDragEnd: (event: PointerEvent, info: any) => {\n                        // Runs a frame after release, so after the release's click\n                        group.hasReordered = false\n                        resetAutoScrollState()\n                        onDragEnd?.(event, info)\n                    },\n                    onLayoutMeasure: (measured: Box) =>\n                        group.registerItem(handle.props.value, measured),\n                    mix: [\n                        mix,\n                        on<HTMLElement, \"keydown\">(\"keydown\", (event) =>\n                            group.onKeyDown(\n                                event,\n                                handle.props.value,\n                                grabbedFrom,\n                                grab\n                            )\n                        ),\n                        on<HTMLElement, \"blur\">(\"blur\", (event) => {\n                            grabbedFrom && grab(event.currentTarget)\n                        }),\n                    ],\n                },\n                children\n            )\n        }\n    }\n\n    return { Group, Item }\n}\n"],"names":[],"mappings":";;;;;;;AA+EA,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,CAAC;AAa1D,SAAU,aAAa,CAAC,MAAW,EAAA;AACrC;;;AAGG;IACH,SAAS,KAAK,CAAC,MAAsD,EAAA;AACjE,QAAA,MAAM,WAAW,GAAG,IAAI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