charcell 0.1.0
mode

SortableGroup

sortable lists nested in each other's items, with items moving between them.

usage

example

code

import { SortableGroup, SortableList } from 'charcell/react';

function GangList({ id, items }: { id: any; items: any }) {
  return (
    <SortableList id={id} items={items}>
      {({ item }) => (
        <div>
          <span>{item.name}</span>
          {item.children && (
            <>
              <div style={{ paddingInlineStart: '2ch' }}>
                <GangList id={item.name} items={item.children} />
              </div>
            </>
          )}
        </div>
      )}
    </SortableList>
  );
}

export function SortableGroupExample() {
  return (
    <SortableGroup>
      <GangList
        id="gangs"
        items={[
          {
            name: 'polecats',
            children: [
              { name: 'ben' },
              { name: 'darrel' },
              { name: 'father torque' },
            ],
          },
          {
            name: 'vultures',
            children: [{ name: 'suzi' }, { name: 'maureen' }],
          },
          { name: 'cavefish', children: [] },
        ]}
      />
    </SortableGroup>
  );
}

as text

at rest
⠿ polecats
    ⠿ ben
    ⠿ darrel
    ⠿ father torque
⠿ vultures
    ⠿ suzi
    ⠿ maureen
⠿ cavefish
hover
⠿ polecats
    ⠿ ben
    ⠿ darrel
    ⠿ father torque
⠿ vultures
    ⠿ suzi
    ⠿ maureen
⠿ cavefish
press
⠿ polecats
    ⠿ ben
    ⠿ darrel
    ⠿ father torque
⠿ vultures
    ⠿ suzi
    ⠿ maureen
⠿ cavefish
focus
⠿ polecats
    ⠿ ben
    ⠿ darrel
    ⠿ father torque
⠿ vultures
    ⠿ suzi
    ⠿ maureen
⠿ cavefish

props

onMove(move: SortableMove) => void
Called with every move between or within the group's lists.
translationsSortableListTranslations
Every string the lists say (English defaults).
snap'character' | 'row' | 'none'
How a drag moves: 'character' (the default) in whole cells, 'row' in whole rows down only, 'none' freely.

slots

in react, the default slot is children and each named slot a prop of its name, a function where the slot hands values; in vue, a slot; in svelte, a snippet.

default
The lists, at any depth, and whatever surrounds them.