{"version":3,"file":"SortableItem.mjs","names":["Flexbox"],"sources":["../../../src/SortableList/components/SortableItem.tsx"],"sourcesContent":["'use client';\n\nimport type { DraggableSyntheticListeners } from '@dnd-kit/core';\nimport { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport { cx } from 'antd-style';\nimport { createContext, memo, useMemo } from 'react';\n\nimport { type FlexboxProps } from '@/Flex';\nimport { Flexbox } from '@/Flex';\n\nimport { variants } from '../style';\n\ninterface Context {\n  attributes: Record<string, any>;\n  listeners: DraggableSyntheticListeners;\n  ref: (node: HTMLElement | null) => void;\n}\n\nexport const SortableItemContext = createContext<Context>({\n  attributes: {},\n  listeners: undefined,\n  ref() {},\n});\n\nexport interface SortableItemProps extends Omit<FlexboxProps, 'id'> {\n  id: string | number;\n  variant?: 'borderless' | 'filled' | 'outlined';\n}\n\nconst SortableItem = memo<SortableItemProps>(\n  ({ variant = 'borderless', className, children, id, style, ...rest }) => {\n    const {\n      attributes,\n      isDragging,\n      listeners,\n      setNodeRef,\n      setActivatorNodeRef,\n      transform,\n      transition,\n    } = useSortable({ id });\n    const context = useMemo(\n      () => ({\n        attributes,\n        listeners,\n        ref: setActivatorNodeRef,\n      }),\n      [attributes, listeners, setActivatorNodeRef],\n    );\n\n    return (\n      <SortableItemContext value={context}>\n        <Flexbox\n          horizontal\n          align={'center'}\n          as={'li'}\n          className={cx(variants({ variant }), className)}\n          gap={4}\n          ref={setNodeRef}\n          style={{\n            opacity: isDragging ? 0.4 : undefined,\n            transform: CSS.Translate.toString(transform),\n            transition,\n            ...style,\n          }}\n          {...rest}\n        >\n          {children}\n        </Flexbox>\n      </SortableItemContext>\n    );\n  },\n);\n\nSortableItem.displayName = 'SortableItem';\n\nexport default SortableItem;\n"],"mappings":";;;;;;;;;AAmBA,MAAa,sBAAsB,cAAuB;CACxD,YAAY,EAAE;CACd,WAAW,KAAA;CACX,MAAM;CACP,CAAC;AAOF,MAAM,eAAe,MAClB,EAAE,UAAU,cAAc,WAAW,UAAU,IAAI,OAAO,GAAG,WAAW;CACvE,MAAM,EACJ,YACA,YACA,WACA,YACA,qBACA,WACA,eACE,YAAY,EAAE,IAAI,CAAC;AAUvB,QACE,oBAAC,qBAAD;EAAqB,OAVP,eACP;GACL;GACA;GACA,KAAK;GACN,GACD;GAAC;GAAY;GAAW;GAAoB,CAC7C;YAIG,oBAACA,mBAAD;GACE,YAAA;GACA,OAAO;GACP,IAAI;GACJ,WAAW,GAAG,SAAS,EAAE,SAAS,CAAC,EAAE,UAAU;GAC/C,KAAK;GACL,KAAK;GACL,OAAO;IACL,SAAS,aAAa,KAAM,KAAA;IAC5B,WAAW,IAAI,UAAU,SAAS,UAAU;IAC5C;IACA,GAAG;IACJ;GACD,GAAI;GAEH;GACO,CAAA;EACU,CAAA;EAG3B;AAED,aAAa,cAAc"}