UNPKG

@mantine/form

Version:

Mantine form management library

1 lines 901 B
{"version":3,"file":"reorder-path.mjs","names":[],"sources":["../../src/paths/reorder-path.ts"],"sourcesContent":["import { ReorderPayload } from '../types';\nimport { getPath } from './get-path';\nimport { setPath } from './set-path';\n\nexport function reorderPath<T>(path: unknown, { from, to }: ReorderPayload, values: T) {\n const currentValue = getPath(path, values);\n\n if (!Array.isArray(currentValue)) {\n return values;\n }\n\n const cloned = [...currentValue];\n const item = currentValue[from];\n cloned.splice(from, 1);\n cloned.splice(to, 0, item);\n\n return setPath(path, cloned, values);\n}\n"],"mappings":";;;;AAIA,SAAgB,YAAe,MAAe,EAAE,MAAM,MAAsB,QAAW;CACrF,MAAM,eAAe,QAAQ,MAAM,MAAM;CAEzC,IAAI,CAAC,MAAM,QAAQ,YAAY,GAC7B,OAAO;CAGT,MAAM,SAAS,CAAC,GAAG,YAAY;CAC/B,MAAM,OAAO,aAAa;CAC1B,OAAO,OAAO,MAAM,CAAC;CACrB,OAAO,OAAO,IAAI,GAAG,IAAI;CAEzB,OAAO,QAAQ,MAAM,QAAQ,MAAM;AACrC"}