Skip to content

Commit 11a70eb

Browse files
authored
Merge pull request #72 from Robomous/feat/33-sortable-list-docs
feat: export SortableList with its docs page, demos and browser tests
2 parents f0c500d + a2589da commit 11a70eb

35 files changed

Lines changed: 1546 additions & 41 deletions

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
# @robomous/ui-core
66

7-
The Robomous design system, built on top of [shadcn/ui](https://ui.shadcn.com): fifty-four React
7+
The Robomous design system, built on top of [shadcn/ui](https://ui.shadcn.com): fifty-five React
88
components this package owns outright, over Radix UI and Base UI behaviour — plus cmdk under
9-
`Command` and vaul under `Drawer` — and the one stylesheet they resolve through. Extracted from
9+
`Command`, vaul under `Drawer` and UI SDK under `SortableList` — and the one stylesheet they
10+
resolve through. Extracted from
1011
[Robomous/VisionSet](https://github.com/Robomous/VisionSet), where it grew up.
1112

1213
## Install

‎docs/components/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Components
22

3-
Fifty-four components, one file each in `src/components/`, exported by name from `src/index.ts`.
3+
Fifty-five components, one file each in `src/components/`, exported by name from `src/index.ts`.
44
The package is built on top of shadcn/ui: a component enters from the shadcn registry through
55
`components.json` (`pnpm dlx shadcn@latest add <name>`), is adapted to the rules in
66
[DESIGN.md](../DESIGN.md), and is owned here from then on.
@@ -66,6 +66,7 @@ fade.
6666
| Skeleton | `Skeleton` | none | |
6767
| Slider | `Slider` | Radix Slider | The value is an array; one thumb per value, `[min]` when none is given. `aria-label` / `aria-labelledby` land on each thumb, the element with `role="slider"`. `orientation`. |
6868
| Snippet | `Snippet`, `snippetVariants` | none | A command with a drawn `$` (`prompt`) that is never copied. `variant`: `default`, `inverted`, `info`, `success`, `warning`, `error`. `text` string or array; `copyText`, controlled `copied`, `onCopy`. |
69+
| SortableList | `SortableList`, `SortableListItem`, `SortableListHandle` | UI SDK `createReorder` (`src/behaviors/sortable-list.ts`) | The value is the order, an array of item keys; `onValueChange` once per drop, with `reason`. A `listbox` of `option`s, or with `handle` a `list` whose grips take the drag and the keys. The order is reconciled with the children. A dragged item's copy floats above the page and auto-scrolls its scroller. `announce`, `instructions` and `roleDescription` translate what a screen reader hears. |
6970
| Spinner | `Spinner` | none (`role="status"`) | A lucide glyph that announces itself as `Loading`. Compose it into a Button with `data-icon` and `disabled`; there is no `isPending` prop. |
7071
| SplitButton | `SplitButton` | Radix Dropdown Menu over ButtonGroup | `label` + `onClick` for the primary; children are the menu. `menuLabel` names the trigger. `variant`: `default`, `secondary`, `outline` only — no destructive. `menuAlign`: `start`, `end`. |
7172
| Switch | `Switch` | Radix Switch | `role="switch"` with `aria-checked`, for a setting that applies at once; not a Toggle (`aria-pressed`). `size`: `sm`, `default`. |

‎docs/generated/components.manifest.json‎

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8563,6 +8563,229 @@
85638563
"whenNotToUse": ""
85648564
}
85658565
},
8566+
{
8567+
"slug": "sortable-list",
8568+
"import": "@robomous/ui-core",
8569+
"source": "src/components/sortable-list.tsx",
8570+
"docsPage": "examples/catalog/src/content/components/sortable-list.mdx",
8571+
"extracted": {
8572+
"exports": [
8573+
"SortableList",
8574+
"SortableListHandle",
8575+
"SortableListItem",
8576+
"SortableListAnnouncement",
8577+
"SortableListChangeDetails",
8578+
"SortableListChangeReason"
8579+
],
8580+
"parts": [
8581+
{
8582+
"name": "SortableList",
8583+
"description": "A list whose order the reader changes: drag an item, or focus it, press Space, move it with the arrows and press Space again. Each item is a `SortableListItem` with a stable, unique `value`, written as a child of the list (directly or inside a Fragment): a child without a string `value` prop, such as a component that wraps an item, is not rendered. The list renders them in the order `value` (or `defaultValue`) gives, and asks for a new order through `onValueChange` once per move. An item the order leaves out goes at the end, and a key with no item is ignored, so adding or removing an item just works. Name it with `aria-label` or `aria-labelledby`. An item can hold no button or link of its own unless the list has `handle`: then each item is a plain list item and its `SortableListHandle` is what the reader drags and moves.",
8584+
"extends": [
8585+
"Omit<React.ComponentProps<\"ul\">, \"children\" | \"defaultValue\" | \"onChange\" | \"role\">",
8586+
"{ \"aria-label\": string } | { \"aria-labelledby\": string }"
8587+
],
8588+
"props": [
8589+
{
8590+
"name": "value",
8591+
"type": "string[]",
8592+
"default": "",
8593+
"required": false,
8594+
"description": "The order, as the items' `value`s. Pass it with `onValueChange` to control the list."
8595+
},
8596+
{
8597+
"name": "defaultValue",
8598+
"type": "string[]",
8599+
"default": "",
8600+
"required": false,
8601+
"description": "The starting order of an uncontrolled list."
8602+
},
8603+
{
8604+
"name": "onValueChange",
8605+
"type": "(value: string[], details: SortableListChangeDetails) => void",
8606+
"default": "",
8607+
"required": false,
8608+
"description": "Called once per move, when the item is dropped, with the new order and why."
8609+
},
8610+
{
8611+
"name": "orientation",
8612+
"type": "\"vertical\" | \"horizontal\"",
8613+
"default": "\"vertical\"",
8614+
"required": false,
8615+
"description": "Which way the items run: `horizontal` moves them with Left and Right."
8616+
},
8617+
{
8618+
"name": "handle",
8619+
"type": "boolean",
8620+
"default": "false",
8621+
"required": false,
8622+
"description": "Drag and move items by their `SortableListHandle` instead of the whole item."
8623+
},
8624+
{
8625+
"name": "disabled",
8626+
"type": "boolean",
8627+
"default": "false",
8628+
"required": false,
8629+
"description": "Keeps every item in place, as `disabled` on each item does."
8630+
},
8631+
{
8632+
"name": "itemLabel",
8633+
"type": "(value: string) => string | undefined",
8634+
"default": "",
8635+
"required": false,
8636+
"description": "The name a screen reader hears for an item, when its text says more than its name."
8637+
},
8638+
{
8639+
"name": "announce",
8640+
"type": "(announcement: SortableListAnnouncement) => string | undefined",
8641+
"default": "",
8642+
"required": false,
8643+
"description": "Puts a step into words for a screen reader. Return `undefined` for the English default, or `\"\"` to say nothing. Use it to translate."
8644+
},
8645+
{
8646+
"name": "instructions",
8647+
"type": "string",
8648+
"default": "",
8649+
"required": false,
8650+
"description": "How to reorder from the keyboard, read with each item (or handle). An English sentence by default: \"To reorder, press Space to pick an item up…\"."
8651+
},
8652+
{
8653+
"name": "roleDescription",
8654+
"type": "{ list?: string; item?: string }",
8655+
"default": "",
8656+
"required": false,
8657+
"description": "What a screen reader calls the list and its items, in place of \"sortable list\" and \"sortable item\". Translate it with `instructions` and `announce`."
8658+
},
8659+
{
8660+
"name": "className",
8661+
"type": "string",
8662+
"default": "",
8663+
"required": false,
8664+
"description": ""
8665+
}
8666+
],
8667+
"variants": [],
8668+
"dataSlots": [
8669+
"sortable-list"
8670+
],
8671+
"state": [
8672+
{
8673+
"prop": "value",
8674+
"defaultProp": "defaultValue",
8675+
"onChange": "onValueChange"
8676+
}
8677+
],
8678+
"asChild": false
8679+
},
8680+
{
8681+
"name": "SortableListHandle",
8682+
"description": "The grip a reader drags an item by, in a SortableList with `handle`. It is a button, so it needs a name that says which item it moves: `aria-label=\"Reorder Mosaic\"`. It is disabled with its item, never on its own, so it stays focusable and says why it does nothing.",
8683+
"extends": [
8684+
"Omit<React.ComponentProps<\"button\">, \"type\" | \"value\" | \"disabled\">"
8685+
],
8686+
"props": [
8687+
{
8688+
"name": "\"aria-label\"",
8689+
"type": "string",
8690+
"default": "",
8691+
"required": true,
8692+
"description": "Names the item it moves: `Reorder Mosaic`."
8693+
},
8694+
{
8695+
"name": "className",
8696+
"type": "string",
8697+
"default": "",
8698+
"required": false,
8699+
"description": ""
8700+
}
8701+
],
8702+
"variants": [],
8703+
"dataSlots": [
8704+
"sortable-list-handle"
8705+
],
8706+
"state": [],
8707+
"asChild": false
8708+
},
8709+
{
8710+
"name": "SortableListItem",
8711+
"description": "One entry of a SortableList. `value` is its stable key, the string the order is made of; `disabled` keeps it in place (it can't be picked up, the others move past it). Without `handle` on the list, the whole item is what the reader drags and moves, so it holds text, icons or a Badge, never a control.",
8712+
"extends": [
8713+
"Omit<React.ComponentProps<\"li\">, \"value\" | \"role\">"
8714+
],
8715+
"props": [
8716+
{
8717+
"name": "value",
8718+
"type": "string",
8719+
"default": "",
8720+
"required": true,
8721+
"description": "The item's stable key: one of the list's `value`s."
8722+
},
8723+
{
8724+
"name": "disabled",
8725+
"type": "boolean",
8726+
"default": "",
8727+
"required": false,
8728+
"description": "Keeps the item in place: it can't be picked up, and the others move past it."
8729+
},
8730+
{
8731+
"name": "className",
8732+
"type": "string",
8733+
"default": "",
8734+
"required": false,
8735+
"description": ""
8736+
}
8737+
],
8738+
"variants": [],
8739+
"dataSlots": [
8740+
"sortable-list-item"
8741+
],
8742+
"state": [],
8743+
"asChild": false
8744+
}
8745+
],
8746+
"helpers": [
8747+
"SortableListAnnouncement",
8748+
"SortableListChangeDetails",
8749+
"SortableListChangeReason"
8750+
],
8751+
"types": [
8752+
"SortableListAnnouncement",
8753+
"SortableListChangeDetails",
8754+
"SortableListChangeReason"
8755+
],
8756+
"foundation": [
8757+
"@ui-sdk/react/primitive"
8758+
],
8759+
"composes": [
8760+
"Button"
8761+
],
8762+
"demos": [
8763+
"examples/catalog/src/demos/sortable-list/basic.tsx",
8764+
"examples/catalog/src/demos/sortable-list/controlled.tsx",
8765+
"examples/catalog/src/demos/sortable-list/custom-content.tsx",
8766+
"examples/catalog/src/demos/sortable-list/disabled.tsx",
8767+
"examples/catalog/src/demos/sortable-list/handle.tsx",
8768+
"examples/catalog/src/demos/sortable-list/horizontal.tsx",
8769+
"examples/catalog/src/demos/sortable-list/keyboard.tsx",
8770+
"examples/catalog/src/demos/sortable-list/long-list.tsx"
8771+
]
8772+
},
8773+
"authored": {
8774+
"title": "SortableList",
8775+
"category": "Forms",
8776+
"summary": "A list the reader puts in order, by dragging an item or by moving it with the keyboard. Its value is the order, as an array of the items' keys.",
8777+
"related": [
8778+
"toggle-group",
8779+
"scroll-area",
8780+
"item"
8781+
],
8782+
"builtOn": [
8783+
"UI SDK createReorder"
8784+
],
8785+
"whenToUse": "The reader decides an order that matters, such as pipeline steps, priorities or precedence, and the list is short enough to see or scroll through.",
8786+
"whenNotToUse": "The order is a sort the data already has, such as by date or by score; sort a Table instead. Don't use it to pick items; that is a Checkbox list or a Combobox."
8787+
}
8788+
},
85668789
{
85678790
"slug": "spinner",
85688791
"import": "@robomous/ui-core",

0 commit comments

Comments
 (0)