import type { Meta, StoryObj } from "storybook-solidjs"; import { Flex } from "@cn-ui/core"; import { atom, computed, resource } from "@cn-ui/reactive"; import Mock from "mockjs-ts"; import { SortableList, SortableShared } from "./index"; const meta = { title: "Layout 布局组件/Sortable 拖拽排序", component: SortableList, tags: ["autodocs"], argTypes: {}, } satisfies Meta; export default meta; type Story = StoryObj; export const Primary: Story = { render() { const data = atom([ { id: "223232", label: "info", }, { id: "111", label: "info1", }, { id: "222", label: "info2", }, ]); return ( { return item.label; }} > {(item) => { return ; }} ); }, args: {}, }; export const Sortable: Story = { render() { const data = resource<{ data: { id: string; label: string }[] }>( async () => Mock.mock({ "data|10": [ { id: "@id", label: "@cname", }, ], }), { initValue: { data: [] } }, ); const modelLeft = computed(() => data().data.slice(0, 5)); const modelRight = computed(() => data().data.slice(5)); return ( <> {(item) => { return
{item.label}
; }}
{(item) => { return
{item.label}
; }}
{JSON.stringify(modelLeft().map((i) => i.label))}
{JSON.stringify(modelRight().map((i) => i.label))}
); }, args: {}, };