diff --git a/CHANGES.md b/CHANGES.md
index 39ecbe6..cf6f200 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,53 @@
# Changes
+## 0.15.1 (2026-11-23)
+
+- `List_view`, a list of rows in HeroUI's look, on a headless
+ `Solidtype_headless.Grid_list` made of Kobalte's selection hooks: rows
+ chosen by a checkbox, the keys or a press, toggle or replace, actions and
+ links, disabled rows, an empty state, primary and secondary, and
+ `virtualized`, drawing only the rows in view, each `row_height` high. Its
+ look is `list-view.css`.
+- `Rating`, Kobalte's rating in HeroUI's look: chosen by a press or the
+ keys, previewed under the pointer, three sizes, its colours by CSS
+ variables, an icon for every item or per item, a render function,
+ disabled, and read only with a fractional value filled in part. Its look
+ is `rating.css`.
+- `Action_bar`, a `Toolbar` that floats at the foot of the page while open,
+ for what can be done with what is chosen, sliding in and out. Its look is
+ `action-bar.css`.
+- `Toolbar`, HeroUI's, on a headless `Solidtype_headless.Toolbar`: the
+ arrows of its orientation move between its stops, what Tab reaches in it,
+ so a toggle group is one stop that keeps its own arrows. A `Separator`
+ inside it runs across it, a `Button_group` or `Toggle_button_group` along
+ it, unless either gives its own orientation.
+- `Inline_select`, a select drawn as text with no field around it, for a
+ choice made in a sentence, a toolbar or a cell: its trigger muted until
+ hovered, chevrons up and down or an icon given, its list at the trigger's
+ bottom end. Its look is `inline-select.css`, in the plugin's
+ `heroui-extras.css`.
+- `Select.Popover` takes every placement React Aria names, `` `bottom_end ``,
+ `` `top_start ``, `` `left_top `` and the rest, as `Dropdown.Popover` does,
+ where it took a side alone.
+- A virtualized `Table`'s header, and so a virtualized `Data_grid`'s, hides
+ the rows that scroll beneath it, where they showed through it.
+- A virtualized `Table` prerendered on the server tells a reader its rows
+ and columns, `aria-rowcount` and `aria-colcount`, where it said one row and
+ no column, and kept saying so once hydrated.
+- A `Field_error` inside a `Checkbox_group` or a `Radio_group` shows while
+ the group is invalid and describes the group and each control in it, after
+ its description, where it raised.
+- A press on a control inside an `Autocomplete`'s trigger, a tag's remove
+ button in its value, is the control's: the list no longer opens with it.
+- `Switch.Icon`, an icon in the switch's thumb, which now takes children, as
+ HeroUI's does.
+- A press inside a `Table`'s or `Data_grid`'s cell is the control's
+ wherever it lands: an `Autocomplete`'s value, a date field's segments, a
+ tab, a slider or any group of controls no longer runs the row's action.
+- A virtualized or resizable `Data_grid` draws its checkbox and handle
+ columns 40px and 32px wide, header and cells alike, where its layout gave
+ them 75px and its header kept 40px.
+
## 0.15.0 (2026-11-23)
- Breaking: what Kobalte types `any` is no longer a type its reader
diff --git a/agents/llms.txt b/agents/llms.txt
index 1efc645..326274a 100644
--- a/agents/llms.txt
+++ b/agents/llms.txt
@@ -102,9 +102,11 @@ Each component's page gives HeroUI's own examples in OCaml, and a table of its p
- [ColorSwatchPicker](pages/heroui/color-swatch-picker.md): A list of color swatches that allows users to select a color from a predefined palette.
- [Slider](pages/heroui/slider.md): A slider allows a user to select one or more values within a range.
- [Switch](pages/heroui/switch.md): A toggle switch component for boolean states.
+- [Action Bar](pages/heroui/action-bar.md): A floating toolbar for what can be done with what is chosen.
- [Badge](pages/heroui/badge.md): Displays a small indicator positioned relative to another element, commonly used for notification counts, status dots, and labels.
- [Chip](pages/heroui/chip.md): Small informational badges for displaying labels, statuses, and categories.
- [Data Grid](pages/heroui/data-grid.md): A grid of records given as data, with sorting, selection, column resizing, pinned columns, drag and drop, virtualization and loading more, on HeroUI's Table.
+- [List View](pages/heroui/list-view.md): A one-column list of rows, chosen and acted on by the keys and the pointer.
- [Table](pages/heroui/table.md): Tables display structured data in rows and columns with support for sorting, selection, column resizing, and infinite scrolling.
- [TrendChip](pages/heroui/trend-chip.md): A chip that shows a change, its arrow and colour from its trend.
- [Calendar](pages/heroui/calendar.md): Composable date picker with month grid, navigation, and year picker support.
@@ -133,12 +135,14 @@ Each component's page gives HeroUI's own examples in OCaml, and a table of its p
- [NumberField](pages/heroui/number-field.md): Number input fields with increment/decrement buttons, validation, and internationalized formatting.
- [NumberStepper](pages/heroui/number-stepper.md): A number between two round buttons, which rolls to each new value.
- [Radio Group](pages/heroui/radio-group.md): Radio group for selecting a single option from a list.
+- [Rating](pages/heroui/rating.md): A star rating, chosen by a press or the arrow keys, or shown read only as a fraction.
- [SearchField](pages/heroui/search-field.md): Search input field with clear button and search icon.
- [TextArea](pages/heroui/text-area.md): Primitive multiline text input component that accepts standard HTML attributes.
- [TextField](pages/heroui/text-field.md): Composition-friendly text fields with labels, descriptions, and inline validation.
- [Card](pages/heroui/card.md): Flexible container component for grouping related content and actions.
- [Separator](pages/heroui/separator.md): Visually divide content sections.
- [Surface](pages/heroui/surface.md): Container component that provides surface-level styling and context for child components.
+- [Toolbar](pages/heroui/toolbar.md): A container for interactive controls with arrow key navigation.
- [Avatar](pages/heroui/avatar.md): Display user profile images with customizable fallback content.
- [AvatarGroup](pages/heroui/avatar-group.md): Display a stacked or grid group of avatars with overflow counting.
- [Accordion](pages/heroui/accordion.md): A collapsible content panel for organizing information in a compact space.
@@ -157,6 +161,7 @@ Each component's page gives HeroUI's own examples in OCaml, and a table of its p
- [Tooltip](pages/heroui/tooltip.md): Displays informative text when users hover over or focus on an element.
- [Autocomplete](pages/heroui/autocomplete.md): An autocomplete combines a select with filtering, allowing users to search and select from a list of options.
- [ComboBox](pages/heroui/combo-box.md): A combo box combines a text input with a listbox, allowing users to filter a list of options to items matching a query.
+- [Inline Select](pages/heroui/inline-select.md): A select drawn as text, for a choice made in a sentence, a toolbar or a cell.
- [Select](pages/heroui/select.md): A select displays a collapsible list of options and allows a user to select one of them.
- [Kbd](pages/heroui/kbd.md): Display keyboard shortcuts and key combinations.
- [Typography](pages/heroui/typography.md): A semantic typography primitive for headings, body copy, and inline code.
diff --git a/agents/pages/heroui.md b/agents/pages/heroui.md
index 0c1b4e7..b33930c 100644
--- a/agents/pages/heroui.md
+++ b/agents/pages/heroui.md
@@ -69,8 +69,8 @@ let make () =
## How far it goes
-65 of HeroUI 3.2's components are ported;
-[Coverage](heroui/coverage.md) lists each, what it does, and the 9
+66 of HeroUI 3.2's components are ported;
+[Coverage](heroui/coverage.md) lists each, what it does, and the one
still to come. Every component has its page in this section, with HeroUI's
own examples written in OCaml.
diff --git a/agents/pages/heroui/action-bar.md b/agents/pages/heroui/action-bar.md
new file mode 100644
index 0000000..9de937a
--- /dev/null
+++ b/agents/pages/heroui/action-bar.md
@@ -0,0 +1,308 @@
+# Action Bar
+
+A floating toolbar for what can be done with what is chosen.
+
+A [Toolbar](toolbar.md) that floats at the foot of the page
+while `is_open`, sliding in and out. Its look is a stylesheet the library
+ships, imported as [Theming](theming.md#setup) shows.
+
+## Usage
+
+Choose rows to see it.
+
+```ocaml title="action_bar_usage.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module Action_bar = Solidtype_heroui.Action_bar
+module Button = Solidtype_heroui.Button
+module Chip = Solidtype_heroui.Chip
+module List_view = Solidtype_heroui.List_view
+module Separator = Solidtype_heroui.Separator
+module Gravity = Solidtype_gravity_icons
+
+let files =
+ [|
+ ("proposal", "Project proposal.pdf");
+ ("report", "Q4 financial report.xlsx");
+ ("brand", "Brand guidelines.fig");
+ ("photo", "Team photo.jpg");
+ ("notes", "Meeting notes.md");
+ ("api", "API documentation.pdf");
+ |]
+
+let make () =
+ let chosen, set_chosen = S.create_signal [||] in
+
+```
+
+## Anatomy
+
+```ocaml
+
+ ...
+
+ ...
+
+ ...
+
+```
+
+Each section is optional; a `Separator` between them runs across the bar.
+
+## Responsive Labels
+
+Text of the class `action-bar__label` is read but not shown below 640 pixels,
+so a button there shows its icon alone.
+
+## Styling Reference
+
+### CSS Classes
+
+- `.action-bar` - Fixed at the foot of the page, centred; `[data-entering]`
+ and `[data-exiting]` while it slides
+- `.action-bar__wrapper` - The bar itself, its toolbar
+- `.action-bar__prefix` - Its leading section
+- `.action-bar__content` - Its actions
+- `.action-bar__suffix` - Its trailing section
+- `.action-bar__label` - Text hidden below 640 pixels
+
+## API Reference
+
+### Action_bar
+
+| React | solidtype | Type | Default | Description |
+|---|---|---|---|---|
+| `isOpen` | `is_open` | `bool` | | Whether it is shown |
+| `aria-label` | `aria_label` | `string` | `"Actions"` | Its name |
+| `isAttached` | `is_attached` | `bool` | `true` | Whether its toolbar has a surface, fully rounded |
+| `orientation` | `orientation` | `` [ `horizontal \| `vertical ] `` | `` `horizontal `` | Its toolbar's orientation |
+| `className` | `class_` | `string` | | Added after its toolbar's classes |
+
+### Action_bar.Prefix, Content, Suffix
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `className` | `class_` | `string` | Added after its own class |
+| `children` | `children` | elements | What it holds |
diff --git a/agents/pages/heroui/autocomplete.md b/agents/pages/heroui/autocomplete.md
index 396fec7..723b455 100644
--- a/agents/pages/heroui/autocomplete.md
+++ b/agents/pages/heroui/autocomplete.md
@@ -6,22 +6,62 @@ Original HeroUI documentation: [Autocomplete](https://heroui.com/en/docs/react/c
## Usage
-HeroUI's example draws the states chosen as tags, with a TagGroup, which is
-not ported yet; here they are listed as the value draws them.
-
```ocaml title="autocomplete_usage.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
module Autocomplete = Solidtype_heroui.Autocomplete
module Empty_state = Solidtype_heroui.Empty_state
module Label = Solidtype_heroui.Label
module List_box = Solidtype_heroui.List_box
module Search_field = Solidtype_heroui.Search_field
+module Tag = Solidtype_heroui.Tag
+module Tag_group = Solidtype_heroui.Tag_group
+
+let states =
+ [|
+ ("florida", "Florida");
+ ("delaware", "Delaware");
+ ("california", "California");
+ ("texas", "Texas");
+ ("new-york", "New York");
+ ("washington", "Washington");
+ |]
+
+let name_of id =
+ match Array.find_opt (fun (k, _) -> String.equal k id) states with
+ | Some (_, name) -> name
+ | None -> id
let make () =
+ let chosen, set_chosen = S.create_signal [||] in
+ let remove keys =
+ S.set set_chosen
+ (Js.Array.filter (S.get chosen) ~f:(fun k ->
+ not (Array.exists (String.equal k) keys)))
+ in
+ class_="w-[256px]"
+ placeholder="Select states"
+ selection_mode=`multiple
+ value=(S.get chosen)
+ on_change=(fun keys -> S.set set_chosen keys)>
-
+
+ (fun value ->
+
+
+
+ (fun id _ ->
+
+ (Jsx.string (name_of id))
+ )
+
+
+ )
+
+
@@ -37,24 +77,12 @@ let make () =
render_empty_state=(fun _ ->
"No results found")
selection_mode=`multiple>
-
- "Florida"
-
-
- "Delaware"
-
-
- "California"
-
-
- "Texas"
-
-
- "New York"
-
-
- "Washington"
-
+
+ (fun (id, name) _ ->
+
+ (Jsx.string name)
+ )
+
@@ -1434,6 +1462,150 @@ let make () =
```
+### User Selection Multiple
+
+```ocaml title="autocomplete_user_selection_multiple.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module Avatar = Solidtype_heroui.Avatar
+module Description = Solidtype_heroui.Description
+module Label = Solidtype_heroui.Label
+module List_box = Solidtype_heroui.List_box
+module Autocomplete = Solidtype_heroui.Autocomplete
+module Empty_state = Solidtype_heroui.Empty_state
+module Search_field = Solidtype_heroui.Search_field
+module Tag = Solidtype_heroui.Tag
+module Tag_group = Solidtype_heroui.Tag_group
+
+type user = {
+ avatar_url : string;
+ email : string;
+ fallback : string;
+ id : string;
+ name : string;
+}
+
+let users =
+ [|
+ {
+ avatar_url =
+ "https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg";
+ email = "bob@heroui.com";
+ fallback = "B";
+ id = "1";
+ name = "Bob";
+ };
+ {
+ avatar_url =
+ "https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg";
+ email = "fred@heroui.com";
+ fallback = "F";
+ id = "2";
+ name = "Fred";
+ };
+ {
+ avatar_url =
+ "https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg";
+ email = "martha@heroui.com";
+ fallback = "M";
+ id = "3";
+ name = "Martha";
+ };
+ {
+ avatar_url =
+ "https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg";
+ email = "john@heroui.com";
+ fallback = "J";
+ id = "4";
+ name = "John";
+ };
+ {
+ avatar_url =
+ "https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/orange.jpg";
+ email = "jane@heroui.com";
+ fallback = "J";
+ id = "5";
+ name = "Jane";
+ };
+ |]
+
+let make () =
+ let chosen, set_chosen = S.create_signal [||] in
+ let remove keys =
+ S.set set_chosen
+ (Js.Array.filter (S.get chosen) ~f:(fun k ->
+ not (Array.exists (String.equal k) keys)))
+ in
+ let user_of id =
+ Array.find_opt (fun (u : user) -> String.equal u.id id) users
+ in
+ S.set set_chosen keys)>
+
+
+
+ (fun value ->
+
+
+
+ (fun id _ ->
+ match user_of id with
+ | Some user ->
+
+
+
+
+ (Jsx.string user.fallback)
+
+
+ (Jsx.string user.name)
+
+ | None -> Jsx.nothing)
+
+
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "No results found")
+ selection_mode=`multiple>
+
+ (fun (user : user) _ ->
+
+
+
+ (Jsx.string user.fallback)
+
+
+
+ (Jsx.string user.email)
+
+
+ )
+
+
+
+
+
+```
+
### Location Search
```ocaml title="autocomplete_location_search.mlx"
@@ -1533,18 +1705,298 @@ let make () =
```
-### User Selection Multiple, Tag Group Selection, Email Recipients
+### Tag Group Selection
-These draw the options chosen as tags, with HeroUI's TagGroup, which is not
-ported yet.
+```ocaml title="autocomplete_tag_group_selection.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module Autocomplete = Solidtype_heroui.Autocomplete
+module Empty_state = Solidtype_heroui.Empty_state
+module Label = Solidtype_heroui.Label
+module List_box = Solidtype_heroui.List_box
+module Search_field = Solidtype_heroui.Search_field
+module Tag = Solidtype_heroui.Tag
+module Tag_group = Solidtype_heroui.Tag_group
+
+let tags =
+ [|
+ ("react", "React");
+ ("typescript", "TypeScript");
+ ("javascript", "JavaScript");
+ ("nodejs", "Node.js");
+ ("python", "Python");
+ ("vue", "Vue");
+ ("angular", "Angular");
+ ("nextjs", "Next.js");
+ |]
+
+let name_of id =
+ match Array.find_opt (fun (k, _) -> String.equal k id) tags with
+ | Some (_, name) -> name
+ | None -> id
+
+let make () =
+ let chosen, set_chosen = S.create_signal [||] in
+ let remove keys =
+ S.set set_chosen
+ (Js.Array.filter (S.get chosen) ~f:(fun k ->
+ not (Array.exists (String.equal k) keys)))
+ in
+ S.set set_chosen keys)>
+
+
+
+ (fun value ->
+
+
+
+ (fun id _ ->
+
+ (Jsx.string (name_of id))
+ )
+
+
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "No tags found")
+ selection_mode=`multiple>
+
+ (fun (id, name) _ ->
+
+ (Jsx.string name)
+ )
+
+
+
+
+
+```
+
+### Email Recipients
+
+```ocaml title="autocomplete_email_recipients.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module Autocomplete = Solidtype_heroui.Autocomplete
+module Description = Solidtype_heroui.Description
+module Empty_state = Solidtype_heroui.Empty_state
+module Label = Solidtype_heroui.Label
+module List_box = Solidtype_heroui.List_box
+module Search_field = Solidtype_heroui.Search_field
+module Tag = Solidtype_heroui.Tag
+module Tag_group = Solidtype_heroui.Tag_group
+
+let people =
+ [|
+ ("alice@example.com", "Alice Johnson");
+ ("bob@example.com", "Bob Smith");
+ ("charlie@example.com", "Charlie Brown");
+ ("diana@example.com", "Diana Prince");
+ ("eve@example.com", "Eve Wilson");
+ |]
+
+let make () =
+ let chosen, set_chosen = S.create_signal [||] in
+ let remove keys =
+ S.set set_chosen
+ (Js.Array.filter (S.get chosen) ~f:(fun k ->
+ not (Array.exists (String.equal k) keys)))
+ in
+ S.set set_chosen keys)>
+
+
+
+ (fun value ->
+
+
+
+ (fun email _ ->
+ (Jsx.string email))
+
+
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "No recipients found")
+ selection_mode=`multiple>
+
+ (fun (email, name) _ ->
+
+
+
+ (Jsx.string email)
+
+
+ )
+
+
+
+
+
+```
## Customization
### Tailwind CSS
-HeroUI's Tailwind example draws the people chosen as tags, with a TagGroup,
-which is not ported yet; `class_` is added after HeroUI's classes on every
-part, as the examples above show.
+`class_` is added after HeroUI's classes on every part.
+
+```ocaml title="autocomplete_custom_styles.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module Autocomplete = Solidtype_heroui.Autocomplete
+module Description = Solidtype_heroui.Description
+module Empty_state = Solidtype_heroui.Empty_state
+module Label = Solidtype_heroui.Label
+module List_box = Solidtype_heroui.List_box
+module Search_field = Solidtype_heroui.Search_field
+module Tag = Solidtype_heroui.Tag
+module Tag_group = Solidtype_heroui.Tag_group
+
+let teammates =
+ [|
+ ("sarah", "Sarah Chen", "Product Design");
+ ("marcus", "Marcus Lee", "Engineering");
+ ("priya", "Priya Patel", "Data Science");
+ ("jordan", "Jordan Kim", "Customer Success");
+ ("alex", "Alex Rivera", "Marketing");
+ |]
+
+let name_of id =
+ match Array.find_opt (fun (k, _, _) -> String.equal k id) teammates with
+ | Some (_, name, _) -> name
+ | None -> id
+
+let make () =
+ let chosen, set_chosen = S.create_signal [||] in
+ let remove keys =
+ S.set set_chosen
+ (Js.Array.filter (S.get chosen) ~f:(fun k ->
+ not (Array.exists (String.equal k) keys)))
+ in
+
+ S.set set_chosen keys)>
+
+
+ "People who will be notified when this task updates."
+
+
+
+ (fun value ->
+
+
+
+ (fun id _ ->
+
+ (Jsx.string (name_of id))
+ )
+
+
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "No teammates found")
+ selection_mode=`multiple>
+
+ (fun (id, name, role) _ ->
+
+
+
+ (Jsx.string name)
+
+ (Jsx.string role)
+
+
+ )
+
+
+
+
+
+
+```
### Global CSS
diff --git a/agents/pages/heroui/checkbox-group.md b/agents/pages/heroui/checkbox-group.md
index ce6cda1..ce5f032 100644
--- a/agents/pages/heroui/checkbox-group.md
+++ b/agents/pages/heroui/checkbox-group.md
@@ -172,10 +172,74 @@ let make () =
```
-### Not yet
+### Validation
-HeroUI's Validation example validates the group as its form is submitted,
-which is not ported yet; `is_invalid` marks it invalid.
+A group validates nothing itself, as no field here does: it is invalid as
+`is_invalid` says, here once a submit finds nothing chosen, and its
+`Field_error` shows while it is.
+
+```ocaml title="checkbox_group_validation.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module Show = Solidtype.Show
+module Button = Solidtype_heroui.Button
+module Checkbox = Solidtype_heroui.Checkbox
+module Checkbox_group = Solidtype_heroui.Checkbox_group
+module Field_error = Solidtype_heroui.Field_error
+module Form = Solidtype_heroui.Form
+module Label = Solidtype_heroui.Label
+
+external prevent_default : Dom.event -> unit = "preventDefault" [@@mel.send]
+
+let make () =
+ let chosen, set_chosen = S.create_signal [] in
+ let tried, set_tried = S.create_signal false in
+ let sent, set_sent = S.create_signal None in
+
+```
## Styling Reference
diff --git a/agents/pages/heroui/coverage.md b/agents/pages/heroui/coverage.md
index 8788f7c..7b09271 100644
--- a/agents/pages/heroui/coverage.md
+++ b/agents/pages/heroui/coverage.md
@@ -10,7 +10,7 @@ shows it beside the same component in React.
| [Accordion](accordion.md) | ported: one or several expanded, controlled or kept, disabled with an item's own, surface, no separator, its own icon, a button given its slot, panels animated by their height and found by find in page, focus moved by the arrows, a trigger's own `on_press` and `is_disabled` |
| [Alert](alert.md) | ported: statuses and their icons, indicator, title, description, as a surface |
| [AlertDialog](alert-dialog.md) | ported: as Modal, its dialog an `alertdialog` that only its buttons close unless its backdrop says otherwise; statuses and their icons, placements, sizes, a custom portal container |
-| [Autocomplete](autocomplete.md) | ported: one or many chosen, controlled or kept, its search a SearchField filtering its ListBox, a filter given, its search's text controlled, an empty state, open controlled or kept, empty collection, clear button, variants, full width, disabled, disabled options, sections, label, description and error, a form's errors; a value drawn as tags not yet |
+| [Autocomplete](autocomplete.md) | ported: one or many chosen, controlled or kept, its search a SearchField filtering its ListBox, a filter given, its search's text controlled, an empty state, open controlled or kept, empty collection, clear button, variants, full width, disabled, disabled options, sections, label, description and error, a form's errors, a value drawn as removable tags |
| [Avatar](avatar.md) | ported: sizes, colors, variants, image once loaded, fallback |
| [AvatarGroup](avatar-group.md) | ported: sizes, colors, variants, max and its count, grid, overlaps |
| [Badge](badge.md) | ported: colors, placements, sizes, variants, anchor, label |
@@ -60,13 +60,13 @@ shows it beside the same component in React.
| [RangeCalendar](range-calendar.md) | ported: a range begun by a press or Enter and shown to the day hovered or focused, ended by a second; chosen by a drag, an end moved by one; let go by Escape, and ended as `commit_behavior` says; reaching no further than an unavailable day unless non-contiguous, its predicate given the range's anchor; controlled or kept, min and max, disabled, read-only, invalid; weeks or days shown, several months side by side; its year picker; cell indicators |
| [ScrollShadow](scroll-shadow.md) | ported: orientations, sizes, offset, visibility given or measured, hidden scrollbar |
| [SearchField](search-field.md) | ported: query controlled or kept, cleared by Escape or its button, submitted by Enter, variants, disabled, invalid |
-| [Select](select.md) | ported: one or many chosen, controlled or kept, its list a ListBox, placeholder, value drawn as the option or by a function, clear button and Backspace, variants, full width, disabled, disabled options, sections, open controlled or kept, label, description and error, a form's errors; required, its error the application's to show, as a text field's |
+| [Select](select.md) | ported: one or many chosen, controlled or kept, its list a ListBox, placeholder, value drawn as the option or by a function, clear button and Backspace, variants, full width, disabled, disabled options, sections, open controlled or kept, its list placed on any side and end, label, description and error, a form's errors; required, its error the application's to show, as a text field's |
| [Separator](separator.md) | ported: orientations, variants |
| [Skeleton](skeleton.md) | ported: animation types, and the page's `--skeleton-animation` |
| [Slider](slider.md) | ported: one value or a range, controlled or kept, step and range, vertical, disabled, output, format options |
| [Spinner](spinner.md) | ported: colors, sizes, its icon's gradients unique per spinner |
| [Surface](surface.md) | ported: variants, and the variant it gives what is inside it |
-| [Switch](switch.md) | ported: sizes, selected, disabled, invalid, interaction state, with HeroUI's Label |
+| [Switch](switch.md) | ported: sizes, selected, disabled, invalid, interaction state, with HeroUI's Label, an icon in its thumb, a description, a form's values |
| [SwitchGroup](switch.md#group) | ported: orientations |
| [Table](table.md) | ported: variants, static rows or rows of data, columns of data, row headers, an empty state, a footer, rows and cells moved through by the keys, rows selected one or many, by a press, the keys or a checkbox, all by the header's, disabled rows, sorted by a column pressed or keyed, its sortable header's chevron, more rows loaded as its end scrolls into view, columns resized by a drag or the keys, columns pinned to either side, a header kept in view, rows reordered by a drag or the keys, rows that hold rows expanded by a chevron or the keys, virtualized, only the rows in view drawn; a tree virtualized not yet |
| [Tabs](tabs.md) | ported: selection controlled or kept, horizontal or vertical, primary or secondary, aligned, disabled, manual activation, separators, an indicator that slides between tabs, a list that scrolls by its chevrons, a tab as a link, `href` |
@@ -77,18 +77,19 @@ shows it beside the same component in React.
| [Toast](toast.md) | ported: provider, placements, the stack collapsed and expanded, its hotkey, variants, indicators, action, loading, custom rendering, queues of its own, update, promise, pause and resume |
| [ToggleButton](toggle-button.md) | ported: variants, sizes, icon only, selected controlled or kept, disabled, interaction state |
| [ToggleButtonGroup](toggle-button-group.md) | ported: single or multiple selection controlled or kept, empty selection disallowed, sizes, orientations, detached, full width, disabled with a button's own override, separator |
+| [Toolbar](toolbar.md) | ported: horizontal and vertical, attached, the arrows of its orientation between its controls and Tab out and back, the separators, button groups and toggle groups inside it turned to it |
| [Tooltip](tooltip.md) | ported: on a button or a trigger of its own, placements, arrow, offset, flip, delays of its own or the page's, hover or focus, disabled, open controlled or kept, enter and exit animations |
| [Typography](typography.md) | ported: every type and its element, alignments, colors, weights, truncation, primitives, prose |
## Not yet ported
-These 2 components of HeroUI 3.2 are not ported yet; each name links to
+This component of HeroUI 3.2 is not ported yet; its name links to
HeroUI's own page. What a ported component does not do yet is in its row
above and on its page.
| Group | Components |
|---|---|
-| Not yet ported | [InputOTP](https://heroui.com/en/docs/react/components/input-otp), [Toolbar](https://heroui.com/en/docs/react/components/toolbar) |
+| Not yet ported | [InputOTP](https://heroui.com/en/docs/react/components/input-otp) |
## Beyond HeroUI's set
@@ -97,9 +98,13 @@ imported as [Theming](theming.md#setup) shows.
| Component | Status |
|---|---|
+| [ActionBar](action-bar.md) | made: a toolbar that floats at the foot of the page while open, sliding in and out, a prefix, content and suffix, labels hidden on small screens |
| [Command](command.md) | made: a search that filters a menu of commands in a dialog, kept or controlled, by its text or a filter given, the focus kept in the search while the keys move through the commands shown, groups, separators, an empty state, a header and a footer, sizes, backdrops |
-| [Data Grid](data-grid.md) | made: rows as data and columns as definitions, sorted in the browser by text in the page's order or a comparison, or by the application, selection checkboxes, columns resized, pinned to either side and aligned, a header kept in view, rows dragged by a handle and the keys, cells of any control, an empty state, loading more, virtualized, a footer |
+| [Data Grid](data-grid.md) | made: rows as data and columns as definitions, sorted in the browser by text in the page's order or a comparison, or by the application, selection checkboxes and an action bar for the rows chosen, columns resized, pinned to either side and aligned, a header kept in view, rows dragged by a handle and the keys, cells of any control, an empty state, loading more, virtualized, a footer |
+| [InlineSelect](inline-select.md) | made: a select drawn as text, one option or many, kept or controlled, a trigger of any content, a custom indicator, its list placed on any side and end |
+| [ListView](list-view.md) | made: rows chosen one or many by a checkbox, the keys or a press, kept or controlled, toggle or replace, primary and secondary, disabled rows, actions and links, an empty state, a title, a description and an action per row |
| [NumberStepper](number-stepper.md) | made: a number field's value, range, step, format and keys, sizes, a value that rolls, a custom value, custom icons and buttons, reversed, disabled |
+| [Rating](rating.md) | made: Kobalte's rating, chosen by a press or the keys, previewed under the pointer, kept or controlled, sizes, colours, an icon for all or per item, a render function, disabled, read only with fractional values, in a form |
| [Segment](segment.md) | made: one option always selected, controlled or kept, default and ghost, sizes, disabled whole or by option, separators, icons, options that show their label only while selected, an indicator that slides between options |
| [TextShimmer](text-shimmer.md) | made: its text's colour, still under reduced motion |
| [TrendChip](trend-chip.md) | made: trends, sizes, variants, prefix and suffix, a custom indicator, tabular figures |
diff --git a/agents/pages/heroui/data-grid.md b/agents/pages/heroui/data-grid.md
index 746bb2b..15b8ea8 100644
--- a/agents/pages/heroui/data-grid.md
+++ b/agents/pages/heroui/data-grid.md
@@ -30,6 +30,11 @@ type payment = {
email : string;
status : status;
amount : float;
+ fee : float;
+ method_ : string;
+ region : string;
+ description : string;
+ date : string;
}
let payments =
@@ -40,20 +45,35 @@ let payments =
email = "emma@example.com";
status = Succeeded;
amount = 2450.;
+ fee = 73.5;
+ method_ = {js|Visa •••• 4242|js};
+ region = "North America";
+ description = {js|Annual subscription — Enterprise plan|js};
+ date = "2025-12-07";
};
{
id = "pay_1N3x9M";
customer = "Isabella Nguyen";
email = "isabella@example.com";
status = Succeeded;
- amount = 899.;
+ amount = 299.;
+ fee = 8.97;
+ method_ = {js|Visa •••• 1234|js};
+ region = "Asia Pacific";
+ description = {js|Quarterly subscription — Team plan|js};
+ date = "2025-12-03";
};
{
id = "pay_1N3x8L";
customer = "Jackson Lee";
email = "jackson@example.com";
status = Processing;
- amount = 320.;
+ amount = 39.;
+ fee = 1.43;
+ method_ = {js|Mastercard •••• 5555|js};
+ region = "North America";
+ description = {js|Monthly add-on — Extra seats|js};
+ date = "2025-12-02";
};
{
id = "pay_1N3xCQ";
@@ -61,6 +81,11 @@ let payments =
email = "liam@example.com";
status = Refunded;
amount = 150.;
+ fee = 4.5;
+ method_ = {js|Mastercard •••• 6789|js};
+ region = "Europe";
+ description = {js|Monthly subscription — Pro plan|js};
+ date = "2025-12-06";
};
{
id = "pay_1N3x7K";
@@ -68,6 +93,23 @@ let payments =
email = "olivia@example.com";
status = Succeeded;
amount = 1999.;
+ fee = 59.97;
+ method_ = {js|Visa •••• 4242|js};
+ region = "North America";
+ description = {js|Annual subscription — Pro plan|js};
+ date = "2025-12-01";
+ };
+ {
+ id = "pay_1N3xBP";
+ customer = "Sofia Davis";
+ email = "sofia@example.com";
+ status = Succeeded;
+ amount = 450.;
+ fee = 13.5;
+ method_ = {js|Visa •••• 9012|js};
+ region = "Europe";
+ description = {js|One-time purchase — Enterprise setup|js};
+ date = "2025-12-05";
};
{
id = "pay_1N3xAN";
@@ -75,6 +117,11 @@ let payments =
email = "will@example.com";
status = Failed;
amount = 99.;
+ fee = 3.17;
+ method_ = {js|Amex •••• 3782|js};
+ region = "Asia Pacific";
+ description = {js|Monthly subscription — Starter plan|js};
+ date = "2025-12-04";
};
|]
@@ -121,20 +168,29 @@ let actions p =
-let columns money =
+let columns ~money ~day =
+ let amount ~class_ value =
+
+ (Jsx.string (Types.NumberFormat.format (S.get money) value))
+
+ in
[|
Data_grid.column ~id:"customer" ~header:(Text "Customer")
- ~is_row_header:true
+ ~is_row_header:true ~default_width:(Pixels 240.) ~allows_resizing:true
~sort:(By_text (fun p -> p.customer))
(fun p ->
```
## Team Members
@@ -1450,6 +2295,126 @@ let make () =
/>
```
+## Footer
+
+`footer` is drawn below the grid, here a [Pagination](pagination.md).
+
+```ocaml title="data_grid_footer.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module Chip = Solidtype_heroui.Chip
+module Data_grid = Solidtype_heroui.Data_grid
+module Pagination = Solidtype_heroui.Pagination
+
+type status = Paid | Pending | Overdue
+
+type invoice = {
+ id : string;
+ customer : string;
+ date : string;
+ status : status;
+ amount : string;
+}
+
+let invoice id customer date status amount =
+ { id; customer; date; status; amount }
+
+let invoices =
+ [|
+ invoice "INV-001" "Acme Corp" "2024-03-01" Paid "$1,250";
+ invoice "INV-002" "Globex" "2024-03-04" Paid "$890";
+ invoice "INV-003" "Initech" "2024-03-07" Pending "$2,340";
+ invoice "INV-004" "Umbrella Co" "2024-03-09" Overdue "$560";
+ invoice "INV-005" "Stark Industries" "2024-03-12" Paid "$1,780";
+ invoice "INV-006" "Wayne Enterprises" "2024-03-15" Pending "$430";
+ invoice "INV-007" "Cyberdyne" "2024-03-18" Paid "$3,120";
+ invoice "INV-008" "Soylent Corp" "2024-03-21" Overdue "$975";
+ invoice "INV-009" "Massive Dynamic" "2024-03-24" Paid "$1,640";
+ invoice "INV-010" "Hooli" "2024-03-27" Pending "$720";
+ invoice "INV-011" "Vehement Capital" "2024-03-29" Paid "$2,050";
+ invoice "INV-012" "Bluth Company" "2024-03-31" Overdue "$385";
+ |]
+
+let per_page = 4
+let pages = (Array.length invoices + per_page - 1) / per_page
+
+let status_name = function
+ | Paid -> "paid"
+ | Pending -> "pending"
+ | Overdue -> "overdue"
+
+let status_color = function
+ | Paid -> `success
+ | Pending -> `warning
+ | Overdue -> `danger
+
+let columns =
+ [|
+ Data_grid.column ~id:"id" ~header:(Text "Invoice") ~is_row_header:true
+ ~cell_class:"font-medium" (fun i -> Jsx.string (S.get i).id);
+ Data_grid.column ~id:"customer" ~header:(Text "Customer") (fun i ->
+ Jsx.string (S.get i).customer);
+ Data_grid.column ~id:"date" ~header:(Text "Date") (fun i ->
+ Jsx.string (S.get i).date);
+ Data_grid.column ~id:"status" ~header:(Text "Status") (fun i ->
+
+ (Jsx.string (status_name (S.get i).status))
+ );
+ Data_grid.column ~id:"amount" ~header:(Text "Amount") ~align:`end_ (fun i ->
+ (Jsx.string (S.get i).amount));
+ |]
+
+let make () =
+ let page, set_page = S.create_signal 1 in
+ let shown () = Array.sub invoices ((S.get page - 1) * per_page) per_page in
+ i.id)
+ columns
+ content_class="min-w-[640px]"
+ footer=(
+
+ (Jsx.string
+ (string_of_int (((S.get page - 1) * per_page) + 1)
+ ^ " to "
+ ^ string_of_int
+ (min (S.get page * per_page) (Array.length invoices))
+ ^ " of "
+ ^ string_of_int (Array.length invoices)
+ ^ " invoices"))
+
+
+
+ S.update set_page pred)>
+
+
+
+
+ (fun p _ ->
+
+ S.set set_page p)>
+ (Jsx.int p)
+
+ )
+
+
+ S.update set_page succ)>
+
+
+
+
+ )
+ />
+```
+
## Styling Reference
### CSS Classes
@@ -1464,6 +2429,9 @@ let make () =
- `.data-grid__empty-state` - What is drawn with no rows
- `.data-grid__footer` - The footer, with HeroUI's `.table__footer`
+A virtualized or resizable grid places its own two columns itself, at 40px
+and 32px, whatever the variables say.
+
### Interactive States
- **Alignment**: `[data-align="start"]`, `"center"` or `"end"` on a column's
diff --git a/agents/pages/heroui/inline-select.md b/agents/pages/heroui/inline-select.md
new file mode 100644
index 0000000..5cb79a9
--- /dev/null
+++ b/agents/pages/heroui/inline-select.md
@@ -0,0 +1,317 @@
+# Inline Select
+
+A select drawn as text, for a choice made in a sentence, a toolbar or a cell.
+
+A [Select](select.md) drawn as text, with no field around it.
+Its choice, keys and list are the select's. Its look is a stylesheet the
+library ships, imported as [Theming](theming.md#setup) shows.
+
+## Usage
+
+```ocaml title="inline_select_usage.mlx"
+module Inline_select = Solidtype_heroui.Inline_select
+module List_box = Solidtype_heroui.List_box
+
+let make () =
+
+
+
+
+
+
+
+ "English"
+
+
+ "Spanish"
+
+
+ "French"
+
+
+ "Japanese"
+
+
+
+
+```
+
+## Anatomy
+
+```ocaml
+
+
+
+
+
+
+ "English"
+
+
+
+```
+
+## Team Switcher
+
+The trigger draws whatever it is given, here the team chosen.
+
+```ocaml title="inline_select_team_switcher.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module Inline_select = Solidtype_heroui.Inline_select
+module List_box = Solidtype_heroui.List_box
+module Gravity = Solidtype_gravity_icons
+
+type team = { id : string; name : string; color : string }
+
+let teams =
+ [|
+ { id = "northwind"; name = "Northwind Labs"; color = "bg-violet-700" };
+ { id = "acme"; name = "Acme Corp"; color = "bg-blue-600" };
+ { id = "maple"; name = "Maple Studio"; color = "bg-amber-600" };
+ |]
+
+let mark team =
+
+
+ (Jsx.string (String.sub team.name 0 1))
+
+
+
+let make () =
+ let chosen, set_chosen = S.create_signal teams.(0) in
+
+
+ "/"
+
+ match Array.find_opt (fun t -> Array.mem t.id keys) teams with
+ | Some t -> S.set set_chosen t
+ | None -> ())>
+
+ (mark (S.get chosen))
+
+ (Jsx.string (S.get chosen).name)
+
+
+
+
+
+
+ (fun team _ ->
+
+ (mark team) (Jsx.string team.name)
+ )
+
+
+
+
+
+```
+
+## Custom Indicator
+
+`Inline_select.Indicator` draws the icon it is given in place of its chevrons.
+
+```ocaml title="inline_select_custom_indicator.mlx"
+module Inline_select = Solidtype_heroui.Inline_select
+module List_box = Solidtype_heroui.List_box
+module Gravity = Solidtype_gravity_icons
+
+let make () =
+
+
+
+
+
+
+
+
+
+
+ "Viewer"
+
+
+ "Editor"
+
+
+ "Admin"
+
+
+
+
+```
+
+## Multi Select
+
+With `selection_mode=` `` `multiple ``, the value lists every option chosen.
+
+```ocaml title="inline_select_multi_select.mlx"
+module Inline_select = Solidtype_heroui.Inline_select
+module List_box = Solidtype_heroui.List_box
+
+let make () =
+
+
+
+
+
+
+
+ "Email"
+
+
+ "WhatsApp"
+
+
+ "Push Notification"
+
+
+
+
+```
+
+## Placements
+
+`Inline_select.Popover` takes a `placement`, `` `bottom_end `` by default.
+
+```ocaml title="inline_select_placements.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module Inline_select = Solidtype_heroui.Inline_select
+module List_box = Solidtype_heroui.List_box
+
+let placements =
+ [|
+ ("bottom", `bottom, "bottom");
+ ("bottom-start", `bottom_start, "bottom start");
+ ("bottom-end", `bottom_end, "bottom end (default)");
+ ("top", `top, "top");
+ ("top-start", `top_start, "top start");
+ ("top-end", `top_end, "top end");
+ ("left", `left, "left");
+ ("left-top", `left_top, "left top");
+ ("left-bottom", `left_bottom, "left bottom");
+ ("right", `right, "right");
+ ("right-top", `right_top, "right top");
+ ("right-bottom", `right_bottom, "right bottom");
+ |]
+
+let make () =
+ let chosen, set_chosen = S.create_signal "bottom-end" in
+ let placement () =
+ match
+ Array.find_opt
+ (fun (id, _, _) -> String.equal id (S.get chosen))
+ placements
+ with
+ | Some (_, p, _) -> p
+ | None -> `bottom_end
+ in
+
+
+ match keys with [| k |] -> S.set set_chosen k | _ -> ())>
+
+
+
+
+
+
+ (fun (id, _, name) _ ->
+
+ (Jsx.string name)
+ )
+
+
+
+
+
+```
+
+## Styling Reference
+
+### CSS Classes
+
+- `.inline-select`, beside the select's `.select`
+- `.inline-select__trigger`, beside `.select__trigger`
+- `.inline-select__value`, beside `.select__value`
+- `.inline-select__indicator`, beside `.select__indicator`
+- `.inline-select__popover`, beside `.select__popover`
+
+### Interactive States
+
+On `.inline-select__trigger`:
+
+- **Hovered**: `[data-hovered="true"]`
+- **Focus visible**: `[data-focus-visible="true"]`
+- **Disabled**: `[data-disabled="true"]`
+
+And on `.inline-select__indicator`, `[data-open="true"]` while the list is open.
+
+### CSS Variables
+
+| Variable | Default | Description |
+|---|---|---|
+| `--inline-select-value-max-width` | `12rem` | The widest the value is drawn before it is cut short |
+| `--inline-select-indicator-size` | `0.75rem` | The indicator's width and height |
+
+## API Reference
+
+Each prop beside its name in React's convention.
+
+### Inline_select
+
+| React | solidtype | Type | Default | Description |
+|---|---|---|---|---|
+| `selectionMode` | `selection_mode` | `` [ `single \| `multiple ] `` | `` `single `` | One option or many |
+| `value` | `value` | `string array` | | The options chosen (controlled) |
+| `defaultValue` | `default_value` | `string array` | | The options chosen at first (uncontrolled) |
+| `onChange` | `on_change` | `string array -> unit` | | Called with the options chosen |
+| `placeholder` | `placeholder` | `string` | `"Select an item"` | Shown while nothing is chosen |
+| `disabledKeys` | `disabled_keys` | `string array` | | Options that cannot be chosen |
+| `isOpen` | `is_open` | `bool` | | Whether the list is open (controlled) |
+| `defaultOpen` | `default_open` | `bool` | | Whether the list is open at first |
+| `onOpenChange` | `on_open_change` | `bool -> unit` | | Called as the list opens and closes |
+| `isDisabled` | `is_disabled` | `bool` | `false` | Whether it is disabled |
+| `isRequired` | `is_required` | `bool` | `false` | Whether a form requires a choice |
+| `isInvalid` | `is_invalid` | `bool` | `false` | Whether its choice is invalid |
+| `name` | `name` | `string` | | Its name in a form |
+| `className` | `class_` | `string` | | Added after its own classes |
+| `children` | `children` | elements | | Its trigger and popover |
+
+### Inline_select.Trigger
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `aria-label` | `aria_label` | `string` | Its name |
+| `className` | `class_` | `string` | Added after its own classes |
+| `children` | `children` | elements, or a function of its state | Its value and indicator, or anything else |
+
+### Inline_select.Value
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `className` | `class_` | `string` | Added after its own classes |
+| `children` | `children` | elements, or a function of its state | Drawn while an option is chosen, in place of the option |
+
+### Inline_select.Indicator
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `className` | `class_` | `string` | Added after its own classes |
+| `children` | `children` | elements | An icon in place of its chevrons |
+
+### Inline_select.Popover
+
+| React | solidtype | Type | Default | Description |
+|---|---|---|---|---|
+| `placement` | `placement` | `Select.placement` | `` `bottom_end `` | Where the list sits beside the trigger |
+| `className` | `class_` | `string` | | Added after its own classes |
+| `children` | `children` | elements | | Its `List_box` |
diff --git a/agents/pages/heroui/list-view.md b/agents/pages/heroui/list-view.md
new file mode 100644
index 0000000..0f44e06
--- /dev/null
+++ b/agents/pages/heroui/list-view.md
@@ -0,0 +1,469 @@
+# List View
+
+A one-column list of rows, chosen and acted on by the keys and the pointer.
+
+A list of rows, each its content and an action, chosen by a checkbox where the
+list chooses. Its look is a stylesheet the library ships, imported as
+[Theming](theming.md#setup) shows.
+
+## Usage
+
+```ocaml title="list_view_usage.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module List_view = Solidtype_heroui.List_view
+module Gravity = Solidtype_gravity_icons
+
+let files =
+ [|
+ ("documents", "Documents", "2 days ago", true);
+ ("photos", "Photos", "1 week ago", true);
+ ("readme", "README.md", "3 hours ago", false);
+ ("package", "package.json", "Yesterday", false);
+ ("src", "src", "Just now", true);
+ ("gitignore", ".gitignore", "2 weeks ago", false);
+ |]
+
+let make () =
+
+```
+
+## Anatomy
+
+```ocaml
+
+
+
+ "README.md"
+ "Updated 3 hours ago"
+
+ ...
+
+
+```
+
+## Keys
+
+Up and Down move between rows, never past either end, a disabled row passed
+over; Home and End reach the first and the last, and typing the start of a
+row's name the next row of that name. Space chooses a row. Right moves into
+the controls of a row, and Left back out. Where the list has an `on_action`, a
+press or Enter runs it while nothing is chosen.
+
+## Selection Modes
+
+`` `none ``, `` `single `` or `` `multiple ``; a list that chooses draws a
+checkbox in each row.
+
+```ocaml title="list_view_selection_modes.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module List_view = Solidtype_heroui.List_view
+module Gravity = Solidtype_gravity_icons
+
+let files =
+ [|
+ ("documents", "Documents", "2 days ago", true);
+ ("photos", "Photos", "1 week ago", true);
+ ("readme", "README.md", "3 hours ago", false);
+ ("package", "package.json", "Yesterday", false);
+ ("src", "src", "Just now", true);
+ |]
+
+let name_of id =
+ match Array.find_opt (fun (k, _, _, _) -> String.equal k id) files with
+ | Some (_, name, _, _) -> name
+ | None -> id
+
+let chosen_text = function
+ | [||] -> "None selected"
+ | [| one |] -> name_of one
+ | many -> string_of_int (Array.length many) ^ " selected"
+
+let column ~title ~mode =
+ let chosen, set_chosen = S.create_signal [||] in
+
+```
+
+## Virtualization
+
+`virtualized` draws only the rows in view, each `row_height` high, of a list
+given a height, which scrolls them.
+
+```ocaml title="list_view_virtualization.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module List_view = Solidtype_heroui.List_view
+module Gravity = Solidtype_gravity_icons
+
+let files =
+ Array.init 1000 (fun i ->
+ let n = string_of_int (i + 1) in
+ (n, "report-" ^ n ^ ".pdf", string_of_int ((i * 37 mod 900) + 12) ^ " KB"))
+
+let make () =
+
+
+
+ (fun (id, name, size) _ ->
+
+
+
+
+ (Jsx.string name)
+ (Jsx.string size)
+
+
+ )
+
+
+
+```
+
+## Styling Reference
+
+### CSS Classes
+
+- `.list-view` - The list
+- `.list-view--primary`, `.list-view--secondary` - Its variants
+- `.list-view__item` - A row
+- `.list-view__selection-cell` - A row's checkbox
+- `.list-view__item-content` - A row's icon and text
+- `.list-view__title` - A row's name
+- `.list-view__description` - The line under it
+- `.list-view__item-action` - What a row ends with
+- `.list-view__empty-state` - What a list with no rows draws
+
+### Interactive States
+
+On `.list-view__item`:
+
+- **Selected**: `[data-selected="true"]`
+- **Hovered**: `[data-hovered="true"]`
+- **Pressed**: `[data-pressed="true"]`
+- **Focus visible**: `[data-focus-visible="true"]`
+- **Disabled**: `[aria-disabled="true"]`
+
+## API Reference
+
+Each prop beside its name in React's convention.
+
+### List_view
+
+| React | solidtype | Type | Default | Description |
+|---|---|---|---|---|
+| `aria-label` | `aria_label` | `string` | | Its name |
+| `variant` | `variant` | `` [ `primary \| `secondary ] `` | `` `primary `` | Its look |
+| `selectionMode` | `selection_mode` | `` [ `none \| `single \| `multiple ] `` | `` `none `` | How many rows it chooses |
+| `selectionBehavior` | `selection_behavior` | `` [ `toggle \| `replace ] `` | `` `toggle `` | Whether a press adds to the choice or replaces it |
+| `selectedKeys` | `selected_keys` | `string array` | | The rows chosen (controlled) |
+| `defaultSelectedKeys` | `default_selected_keys` | `string array` | | The rows chosen at first |
+| `onSelectionChange` | `on_selection_change` | `string array -> unit` | | Called with the rows chosen |
+| `disabledKeys` | `disabled_keys` | `string array` | | Rows that cannot be chosen or acted on |
+| `disallowEmptySelection` | `disallow_empty_selection` | `bool` | | Whether the last row chosen stays chosen |
+| `onAction` | `on_action` | `string -> unit` | | Called with a row's key as it is acted on |
+| `renderEmptyState` | `render_empty_state` | `unit -> element` | | Drawn while it has no row |
+| `virtualized` | `virtualized` | `bool` | `false` | Whether it draws only the rows in view |
+| `rowHeight` | `row_height` | `float` | `48.` | Each row's height while virtualized |
+| `className` | `class_` | `string` | | Added after its own classes |
+
+### List_view.Item
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `id` | `id` | `string` | Its key |
+| `textValue` | `text_value` | `string` | Its name, which typing finds |
+| `isDisabled` | `is_disabled` | `bool` | Whether it is disabled |
+| `href` | `href` | `string` | The page its action opens |
+| `className` | `class_` | `string` | Added after its own classes |
+| `children` | `children` | elements, or a function of its state | Its content and action |
+
+### List_view.Item_content, Title, Description, Item_action
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `className` | `class_` | `string` | Added after its own class |
+| `children` | `children` | elements | What it holds |
diff --git a/agents/pages/heroui/radio-group.md b/agents/pages/heroui/radio-group.md
index ab0289c..bb9b167 100644
--- a/agents/pages/heroui/radio-group.md
+++ b/agents/pages/heroui/radio-group.md
@@ -164,6 +164,46 @@ let make () =
```
+### In Surface
+
+On a [Surface](surface.md), `variant=` `` `secondary `` is
+the quieter look meant for its background.
+
+```ocaml title="radio_group_in_surface.mlx"
+module Description = Solidtype_heroui.Description
+module Label = Solidtype_heroui.Label
+module Radio = Solidtype_heroui.Radio
+module Radio_group = Solidtype_heroui.Radio_group
+module Surface = Solidtype_heroui.Surface
+
+let make () =
+
+
+
+ "Choose the plan that suits you best"
+
+
+ "Basic Plan"
+
+ "Includes 100 messages per month"
+
+
+
+ "Premium Plan"
+
+ "Includes 200 messages per month"
+
+
+
+ "Business Plan"
+
+ "Unlimited messages"
+
+
+
+```
+
### Disabled
```ocaml title="radio_group_disabled.mlx"
@@ -285,6 +325,166 @@ let make () =
```
+### Validation
+
+The group is invalid as `is_invalid` says, here once a submit finds no plan
+chosen, and its `Field_error` shows while it is.
+
+```ocaml title="radio_group_validation.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module Show = Solidtype.Show
+module Button = Solidtype_heroui.Button
+module Description = Solidtype_heroui.Description
+module Field_error = Solidtype_heroui.Field_error
+module Form = Solidtype_heroui.Form
+module Label = Solidtype_heroui.Label
+module Radio = Solidtype_heroui.Radio
+module Radio_group = Solidtype_heroui.Radio_group
+
+external prevent_default : Dom.event -> unit = "preventDefault" [@@mel.send]
+
+let make () =
+ let plan, set_plan = S.create_signal None in
+ let tried, set_tried = S.create_signal false in
+ let message, set_message = S.create_signal None in
+
+```
+
+### Delivery & Payment
+
+Each `Radio.Content` drawn as a card, its state read by `data-selected`.
+
+```ocaml title="radio_group_delivery_and_payment.mlx"
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module Description = Solidtype_heroui.Description
+module Label = Solidtype_heroui.Label
+module Radio = Solidtype_heroui.Radio
+module Radio_group = Solidtype_heroui.Radio_group
+module Gravity = Solidtype_gravity_icons
+
+let deliveries =
+ [|
+ ("standard", "Standard", "4-10 business days", "$5.00");
+ ("express", "Express", "2-5 business days", "$16.00");
+ ("super-fast", "Super Fast", "1 business day", "$25.00");
+ |]
+
+let payments =
+ [|
+ ("mastercard", "**** 8304", "Exp. on 01/2026");
+ ("visa", "**** 0123", "Exp. on 01/2026");
+ ("paypal", "PayPal", "Pay with PayPal");
+ |]
+
+let accent =
+ "--accent: #006FEE; --accent-foreground: #fff; --accent-hover: #006FEE; \
+ --border-width: 2px; --border-width-field: 2px; --focus: #006FEE;"
+
+let make () =
+
+```
+
### Custom Indicator
```ocaml title="radio_group_custom_indicator.mlx"
@@ -322,10 +522,9 @@ let make () =
```
-### Not yet
+### Render Function
-HeroUI's In Surface, until Surface is ported; Validation and Delivery &
-Payment, which need a form and `FieldError`. `as_` draws another element in a part's place, as [Composition](composition.md#custom-dom-element) shows.
+`as_` draws another element in a part's place, as [Composition](composition.md#custom-dom-element) shows.
## Customization
diff --git a/agents/pages/heroui/rating.md b/agents/pages/heroui/rating.md
new file mode 100644
index 0000000..6bd5710
--- /dev/null
+++ b/agents/pages/heroui/rating.md
@@ -0,0 +1,391 @@
+# Rating
+
+A star rating, chosen by a press or the arrow keys, or shown read only as a fraction.
+
+Kobalte's rating, a radio group of stars, in HeroUI's look: chosen by a press
+or the arrow keys, the stars under the pointer previewed as it moves. Read
+only, its value may be a fraction. Its look is a stylesheet the library ships,
+imported as [Theming](theming.md#setup) shows.
+
+## Usage
+
+```ocaml title="rating_usage.mlx"
+module Rating = Solidtype_heroui.Rating
+
+let make () =
+
+
+
+
+
+
+
+```
+
+## Anatomy
+
+```ocaml
+
+
+
+```
+
+## Controlled
+
+```ocaml title="rating_controlled.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module Rating = Solidtype_heroui.Rating
+
+let make () =
+ let value, set_value = S.create_signal 3. in
+
+```
+
+## Read Only Fractional
+
+A value read only may be a fraction: the stars up to its whole part are active, and the next filled as far as the fraction goes.
+
+```ocaml title="rating_read_only_fractional.mlx"
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module Rating = Solidtype_heroui.Rating
+
+let values = [| 1.5; 2.3; 3.7; 4.2; 4.8 |]
+
+let make () =
+
+```
+
+## Render Function
+
+A function child draws the whole item of its state: `is_active`, `is_partial` and `partial_percent`.
+
+```ocaml title="rating_render_function.mlx"
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module For = Solidtype.For
+module Rating = Solidtype_heroui.Rating
+module Gravity = Solidtype_gravity_icons
+
+let make () =
+ let value, set_value = S.create_signal 0. in
+
+ S.set set_value v)>
+
+ (fun value _ ->
+
+ (fun state ->
+
+
+ )
+ )
+
+
+
+ (Jsx.string
+ (match S.get value with
+ | 0. -> "No rating"
+ | 1. -> "1 star"
+ | v -> Js.Float.toString v ^ " stars"))
+
+
+
+
+
+ "B"
+
+
+ "I"
+
+
+
+
+
+
+
+ )
+ react=(fun host ->
+ Heroui_react.toolbar host
+ (Heroui_react.toolbar_props
+ ~orientation:(snd (S.get orientation))
+ ~is_attached:(S.get attached) ()))
+ />
+
diff --git a/docs/islands/toolbar_tailwind.mlx b/docs/islands/toolbar_tailwind.mlx
new file mode 100644
index 0000000..31a7a84
--- /dev/null
+++ b/docs/islands/toolbar_tailwind.mlx
@@ -0,0 +1,32 @@
+module Toggle_button = Solidtype_heroui.Toggle_button
+module Toggle_button_group = Solidtype_heroui.Toggle_button_group
+module Toolbar = Solidtype_heroui.Toolbar
+module Gravity = Solidtype_gravity_icons
+
+let toggle_class =
+ "rounded-lg data-[selected=true]:bg-accent \
+ data-[selected=true]:text-accent-foreground"
+
+let make () =
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/islands/toolbar_usage.mlx b/docs/islands/toolbar_usage.mlx
new file mode 100644
index 0000000..a89adca
--- /dev/null
+++ b/docs/islands/toolbar_usage.mlx
@@ -0,0 +1,29 @@
+module Button = Solidtype_heroui.Button
+module Button_group = Solidtype_heroui.Button_group
+module Separator = Solidtype_heroui.Separator
+module Toggle_button = Solidtype_heroui.Toggle_button
+module Toggle_button_group = Solidtype_heroui.Toggle_button_group
+module Toolbar = Solidtype_heroui.Toolbar
+module Gravity = Solidtype_gravity_icons
+
+let make () =
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/islands/toolbar_vertical.mlx b/docs/islands/toolbar_vertical.mlx
new file mode 100644
index 0000000..beac8f8
--- /dev/null
+++ b/docs/islands/toolbar_vertical.mlx
@@ -0,0 +1,31 @@
+module Button = Solidtype_heroui.Button
+module Button_group = Solidtype_heroui.Button_group
+module Separator = Solidtype_heroui.Separator
+module Toggle_button = Solidtype_heroui.Toggle_button
+module Toggle_button_group = Solidtype_heroui.Toggle_button_group
+module Toolbar = Solidtype_heroui.Toolbar
+module Gravity = Solidtype_gravity_icons
+
+let make () =
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/islands/toolbar_with_button_group.mlx b/docs/islands/toolbar_with_button_group.mlx
new file mode 100644
index 0000000..0d3c4af
--- /dev/null
+++ b/docs/islands/toolbar_with_button_group.mlx
@@ -0,0 +1,41 @@
+module Button = Solidtype_heroui.Button
+module Button_group = Solidtype_heroui.Button_group
+module Separator = Solidtype_heroui.Separator
+module Toggle_button = Solidtype_heroui.Toggle_button
+module Toggle_button_group = Solidtype_heroui.Toggle_button_group
+module Toolbar = Solidtype_heroui.Toolbar
+module Gravity = Solidtype_gravity_icons
+
+let make () =
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/src/content/docs/heroui/action-bar.mdx b/docs/src/content/docs/heroui/action-bar.mdx
new file mode 100644
index 0000000..ca275c0
--- /dev/null
+++ b/docs/src/content/docs/heroui/action-bar.mdx
@@ -0,0 +1,74 @@
+---
+title: Action Bar
+description: A floating toolbar for what can be done with what is chosen.
+---
+
+import Example from "@components/Example.astro";
+import * as Usage from "@islands/action_bar_usage.jsx";
+import UsageCode from "@islands/action_bar_usage.mlx?raw";
+import * as WithDataGrid from "@islands/data_grid_bulk_actions.jsx";
+import WithDataGridCode from "@islands/data_grid_bulk_actions.mlx?raw";
+
+A [Toolbar](/solidtype/heroui/toolbar/) that floats at the foot of the page
+while `is_open`, sliding in and out. Its look is a stylesheet the library
+ships, imported as [Theming](/solidtype/heroui/theming/#setup) shows.
+
+## Usage
+
+Choose rows to see it.
+
+
+
+## With Data Grid
+
+
+
+## Anatomy
+
+```ocaml
+
+ ...
+
+ ...
+
+ ...
+
+```
+
+Each section is optional; a `Separator` between them runs across the bar.
+
+## Responsive Labels
+
+Text of the class `action-bar__label` is read but not shown below 640 pixels,
+so a button there shows its icon alone.
+
+## Styling Reference
+
+### CSS Classes
+
+- `.action-bar` - Fixed at the foot of the page, centred; `[data-entering]`
+ and `[data-exiting]` while it slides
+- `.action-bar__wrapper` - The bar itself, its toolbar
+- `.action-bar__prefix` - Its leading section
+- `.action-bar__content` - Its actions
+- `.action-bar__suffix` - Its trailing section
+- `.action-bar__label` - Text hidden below 640 pixels
+
+## API Reference
+
+### Action_bar
+
+| React | solidtype | Type | Default | Description |
+|---|---|---|---|---|
+| `isOpen` | `is_open` | `bool` | | Whether it is shown |
+| `aria-label` | `aria_label` | `string` | `"Actions"` | Its name |
+| `isAttached` | `is_attached` | `bool` | `true` | Whether its toolbar has a surface, fully rounded |
+| `orientation` | `orientation` | `` [ `horizontal \| `vertical ] `` | `` `horizontal `` | Its toolbar's orientation |
+| `className` | `class_` | `string` | | Added after its toolbar's classes |
+
+### Action_bar.Prefix, Content, Suffix
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `className` | `class_` | `string` | Added after its own class |
+| `children` | `children` | elements | What it holds |
diff --git a/docs/src/content/docs/heroui/autocomplete.mdx b/docs/src/content/docs/heroui/autocomplete.mdx
index 2dd0791..b531e4f 100644
--- a/docs/src/content/docs/heroui/autocomplete.mdx
+++ b/docs/src/content/docs/heroui/autocomplete.mdx
@@ -44,15 +44,20 @@ import * as ExUserSelection from "@islands/autocomplete_user_selection.jsx";
import ExUserSelectionCode from "@islands/autocomplete_user_selection.mlx?raw";
import * as ExLocationSearch from "@islands/autocomplete_location_search.jsx";
import ExLocationSearchCode from "@islands/autocomplete_location_search.mlx?raw";
+import * as ExUserSelectionMultiple from "@islands/autocomplete_user_selection_multiple.jsx";
+import ExUserSelectionMultipleCode from "@islands/autocomplete_user_selection_multiple.mlx?raw";
+import * as ExTagGroupSelection from "@islands/autocomplete_tag_group_selection.jsx";
+import ExTagGroupSelectionCode from "@islands/autocomplete_tag_group_selection.mlx?raw";
+import * as ExEmailRecipients from "@islands/autocomplete_email_recipients.jsx";
+import ExEmailRecipientsCode from "@islands/autocomplete_email_recipients.mlx?raw";
+import * as ExCustomStyles from "@islands/autocomplete_custom_styles.jsx";
+import ExCustomStylesCode from "@islands/autocomplete_custom_styles.mlx?raw";
import * as Demo from "@islands/autocomplete_demo.jsx";
Original HeroUI documentation: [Autocomplete](https://heroui.com/en/docs/react/components/autocomplete).
## Usage
-HeroUI's example draws the states chosen as tags, with a TagGroup, which is
-not ported yet; here they are listed as the value draws them.
-
## Parity
@@ -203,22 +208,29 @@ is scrolled into view.
+### User Selection Multiple
+
+
+
### Location Search
-### User Selection Multiple, Tag Group Selection, Email Recipients
+### Tag Group Selection
-These draw the options chosen as tags, with HeroUI's TagGroup, which is not
-ported yet.
+
+
+### Email Recipients
+
+
## Customization
### Tailwind CSS
-HeroUI's Tailwind example draws the people chosen as tags, with a TagGroup,
-which is not ported yet; `class_` is added after HeroUI's classes on every
-part, as the examples above show.
+`class_` is added after HeroUI's classes on every part.
+
+
### Global CSS
diff --git a/docs/src/content/docs/heroui/checkbox-group.mdx b/docs/src/content/docs/heroui/checkbox-group.mdx
index 4620ea6..dc80b67 100644
--- a/docs/src/content/docs/heroui/checkbox-group.mdx
+++ b/docs/src/content/docs/heroui/checkbox-group.mdx
@@ -10,6 +10,8 @@ import * as Surface from "@islands/checkbox_group_surface.jsx";
import SurfaceCode from "@islands/checkbox_group_surface.mlx?raw";
import * as Disabled from "@islands/checkbox_group_disabled.jsx";
import DisabledCode from "@islands/checkbox_group_disabled.mlx?raw";
+import * as Validation from "@islands/checkbox_group_validation.jsx";
+import ValidationCode from "@islands/checkbox_group_validation.mlx?raw";
import * as Controlled from "@islands/checkbox_group_controlled.jsx";
import ControlledCode from "@islands/checkbox_group_controlled.mlx?raw";
import * as Demo from "@islands/checkbox_group_demo.jsx";
@@ -67,10 +69,13 @@ surface backgrounds. Each checkbox takes it.
-### Not yet
+### Validation
-HeroUI's Validation example validates the group as its form is submitted,
-which is not ported yet; `is_invalid` marks it invalid.
+A group validates nothing itself, as no field here does: it is invalid as
+`is_invalid` says, here once a submit finds nothing chosen, and its
+`Field_error` shows while it is.
+
+
## Styling Reference
diff --git a/docs/src/content/docs/heroui/coverage.mdx b/docs/src/content/docs/heroui/coverage.mdx
index 0d31bb0..30dd78d 100644
--- a/docs/src/content/docs/heroui/coverage.mdx
+++ b/docs/src/content/docs/heroui/coverage.mdx
@@ -11,7 +11,7 @@ shows it beside the same component in React.
| [Accordion](/solidtype/heroui/accordion/) | ported: one or several expanded, controlled or kept, disabled with an item's own, surface, no separator, its own icon, a button given its slot, panels animated by their height and found by find in page, focus moved by the arrows, a trigger's own `on_press` and `is_disabled` |
| [Alert](/solidtype/heroui/alert/) | ported: statuses and their icons, indicator, title, description, as a surface |
| [AlertDialog](/solidtype/heroui/alert-dialog/) | ported: as Modal, its dialog an `alertdialog` that only its buttons close unless its backdrop says otherwise; statuses and their icons, placements, sizes, a custom portal container |
-| [Autocomplete](/solidtype/heroui/autocomplete/) | ported: one or many chosen, controlled or kept, its search a SearchField filtering its ListBox, a filter given, its search's text controlled, an empty state, open controlled or kept, empty collection, clear button, variants, full width, disabled, disabled options, sections, label, description and error, a form's errors; a value drawn as tags not yet |
+| [Autocomplete](/solidtype/heroui/autocomplete/) | ported: one or many chosen, controlled or kept, its search a SearchField filtering its ListBox, a filter given, its search's text controlled, an empty state, open controlled or kept, empty collection, clear button, variants, full width, disabled, disabled options, sections, label, description and error, a form's errors, a value drawn as removable tags |
| [Avatar](/solidtype/heroui/avatar/) | ported: sizes, colors, variants, image once loaded, fallback |
| [AvatarGroup](/solidtype/heroui/avatar-group/) | ported: sizes, colors, variants, max and its count, grid, overlaps |
| [Badge](/solidtype/heroui/badge/) | ported: colors, placements, sizes, variants, anchor, label |
@@ -61,13 +61,13 @@ shows it beside the same component in React.
| [RangeCalendar](/solidtype/heroui/range-calendar/) | ported: a range begun by a press or Enter and shown to the day hovered or focused, ended by a second; chosen by a drag, an end moved by one; let go by Escape, and ended as `commit_behavior` says; reaching no further than an unavailable day unless non-contiguous, its predicate given the range's anchor; controlled or kept, min and max, disabled, read-only, invalid; weeks or days shown, several months side by side; its year picker; cell indicators |
| [ScrollShadow](/solidtype/heroui/scroll-shadow/) | ported: orientations, sizes, offset, visibility given or measured, hidden scrollbar |
| [SearchField](/solidtype/heroui/search-field/) | ported: query controlled or kept, cleared by Escape or its button, submitted by Enter, variants, disabled, invalid |
-| [Select](/solidtype/heroui/select/) | ported: one or many chosen, controlled or kept, its list a ListBox, placeholder, value drawn as the option or by a function, clear button and Backspace, variants, full width, disabled, disabled options, sections, open controlled or kept, label, description and error, a form's errors; required, its error the application's to show, as a text field's |
+| [Select](/solidtype/heroui/select/) | ported: one or many chosen, controlled or kept, its list a ListBox, placeholder, value drawn as the option or by a function, clear button and Backspace, variants, full width, disabled, disabled options, sections, open controlled or kept, its list placed on any side and end, label, description and error, a form's errors; required, its error the application's to show, as a text field's |
| [Separator](/solidtype/heroui/separator/) | ported: orientations, variants |
| [Skeleton](/solidtype/heroui/skeleton/) | ported: animation types, and the page's `--skeleton-animation` |
| [Slider](/solidtype/heroui/slider/) | ported: one value or a range, controlled or kept, step and range, vertical, disabled, output, format options |
| [Spinner](/solidtype/heroui/spinner/) | ported: colors, sizes, its icon's gradients unique per spinner |
| [Surface](/solidtype/heroui/surface/) | ported: variants, and the variant it gives what is inside it |
-| [Switch](/solidtype/heroui/switch/) | ported: sizes, selected, disabled, invalid, interaction state, with HeroUI's Label |
+| [Switch](/solidtype/heroui/switch/) | ported: sizes, selected, disabled, invalid, interaction state, with HeroUI's Label, an icon in its thumb, a description, a form's values |
| [SwitchGroup](/solidtype/heroui/switch/#group) | ported: orientations |
| [Table](/solidtype/heroui/table/) | ported: variants, static rows or rows of data, columns of data, row headers, an empty state, a footer, rows and cells moved through by the keys, rows selected one or many, by a press, the keys or a checkbox, all by the header's, disabled rows, sorted by a column pressed or keyed, its sortable header's chevron, more rows loaded as its end scrolls into view, columns resized by a drag or the keys, columns pinned to either side, a header kept in view, rows reordered by a drag or the keys, rows that hold rows expanded by a chevron or the keys, virtualized, only the rows in view drawn; a tree virtualized not yet |
| [Tabs](/solidtype/heroui/tabs/) | ported: selection controlled or kept, horizontal or vertical, primary or secondary, aligned, disabled, manual activation, separators, an indicator that slides between tabs, a list that scrolls by its chevrons, a tab as a link, `href` |
@@ -78,18 +78,19 @@ shows it beside the same component in React.
| [Toast](/solidtype/heroui/toast/) | ported: provider, placements, the stack collapsed and expanded, its hotkey, variants, indicators, action, loading, custom rendering, queues of its own, update, promise, pause and resume |
| [ToggleButton](/solidtype/heroui/toggle-button/) | ported: variants, sizes, icon only, selected controlled or kept, disabled, interaction state |
| [ToggleButtonGroup](/solidtype/heroui/toggle-button-group/) | ported: single or multiple selection controlled or kept, empty selection disallowed, sizes, orientations, detached, full width, disabled with a button's own override, separator |
+| [Toolbar](/solidtype/heroui/toolbar/) | ported: horizontal and vertical, attached, the arrows of its orientation between its controls and Tab out and back, the separators, button groups and toggle groups inside it turned to it |
| [Tooltip](/solidtype/heroui/tooltip/) | ported: on a button or a trigger of its own, placements, arrow, offset, flip, delays of its own or the page's, hover or focus, disabled, open controlled or kept, enter and exit animations |
| [Typography](/solidtype/heroui/typography/) | ported: every type and its element, alignments, colors, weights, truncation, primitives, prose |
## Not yet ported
-These 2 components of HeroUI 3.2 are not ported yet; each name links to
+This component of HeroUI 3.2 is not ported yet; its name links to
HeroUI's own page. What a ported component does not do yet is in its row
above and on its page.
| Group | Components |
|---|---|
-| Not yet ported | [InputOTP](https://heroui.com/en/docs/react/components/input-otp), [Toolbar](https://heroui.com/en/docs/react/components/toolbar) |
+| Not yet ported | [InputOTP](https://heroui.com/en/docs/react/components/input-otp) |
## Beyond HeroUI's set
@@ -98,9 +99,13 @@ imported as [Theming](/solidtype/heroui/theming/#setup) shows.
| Component | Status |
|---|---|
+| [ActionBar](/solidtype/heroui/action-bar/) | made: a toolbar that floats at the foot of the page while open, sliding in and out, a prefix, content and suffix, labels hidden on small screens |
| [Command](/solidtype/heroui/command/) | made: a search that filters a menu of commands in a dialog, kept or controlled, by its text or a filter given, the focus kept in the search while the keys move through the commands shown, groups, separators, an empty state, a header and a footer, sizes, backdrops |
-| [Data Grid](/solidtype/heroui/data-grid/) | made: rows as data and columns as definitions, sorted in the browser by text in the page's order or a comparison, or by the application, selection checkboxes, columns resized, pinned to either side and aligned, a header kept in view, rows dragged by a handle and the keys, cells of any control, an empty state, loading more, virtualized, a footer |
+| [Data Grid](/solidtype/heroui/data-grid/) | made: rows as data and columns as definitions, sorted in the browser by text in the page's order or a comparison, or by the application, selection checkboxes and an action bar for the rows chosen, columns resized, pinned to either side and aligned, a header kept in view, rows dragged by a handle and the keys, cells of any control, an empty state, loading more, virtualized, a footer |
+| [InlineSelect](/solidtype/heroui/inline-select/) | made: a select drawn as text, one option or many, kept or controlled, a trigger of any content, a custom indicator, its list placed on any side and end |
+| [ListView](/solidtype/heroui/list-view/) | made: rows chosen one or many by a checkbox, the keys or a press, kept or controlled, toggle or replace, primary and secondary, disabled rows, actions and links, an empty state, a title, a description and an action per row |
| [NumberStepper](/solidtype/heroui/number-stepper/) | made: a number field's value, range, step, format and keys, sizes, a value that rolls, a custom value, custom icons and buttons, reversed, disabled |
+| [Rating](/solidtype/heroui/rating/) | made: Kobalte's rating, chosen by a press or the keys, previewed under the pointer, kept or controlled, sizes, colours, an icon for all or per item, a render function, disabled, read only with fractional values, in a form |
| [Segment](/solidtype/heroui/segment/) | made: one option always selected, controlled or kept, default and ghost, sizes, disabled whole or by option, separators, icons, options that show their label only while selected, an indicator that slides between options |
| [TextShimmer](/solidtype/heroui/text-shimmer/) | made: its text's colour, still under reduced motion |
| [TrendChip](/solidtype/heroui/trend-chip/) | made: trends, sizes, variants, prefix and suffix, a custom indicator, tabular figures |
diff --git a/docs/src/content/docs/heroui/data-grid.mdx b/docs/src/content/docs/heroui/data-grid.mdx
index fa6b3b7..8aa63eb 100644
--- a/docs/src/content/docs/heroui/data-grid.mdx
+++ b/docs/src/content/docs/heroui/data-grid.mdx
@@ -20,8 +20,16 @@ import * as ExEmptyState from "@islands/data_grid_empty_state.jsx";
import ExEmptyStateCode from "@islands/data_grid_empty_state.mlx?raw";
import * as ExAsyncLoading from "@islands/data_grid_async_loading.jsx";
import ExAsyncLoadingCode from "@islands/data_grid_async_loading.mlx?raw";
+import * as ExStickyHeader from "@islands/data_grid_sticky_header.jsx";
+import ExStickyHeaderCode from "@islands/data_grid_sticky_header.mlx?raw";
import * as ExVirtualization from "@islands/data_grid_virtualization.jsx";
import ExVirtualizationCode from "@islands/data_grid_virtualization.mlx?raw";
+import * as ExBulkActions from "@islands/data_grid_bulk_actions.jsx";
+import ExBulkActionsCode from "@islands/data_grid_bulk_actions.mlx?raw";
+import * as ExUsers from "@islands/data_grid_users.jsx";
+import ExUsersCode from "@islands/data_grid_users.mlx?raw";
+import * as ExFooter from "@islands/data_grid_footer.jsx";
+import ExFooterCode from "@islands/data_grid_footer.mlx?raw";
import * as ExTeamMembers from "@islands/data_grid_team_members.jsx";
import ExTeamMembersCode from "@islands/data_grid_team_members.mlx?raw";
import * as ExServers from "@islands/data_grid_servers.jsx";
@@ -98,7 +106,8 @@ in its new order. Selected rows are dragged together.
## Editable Cells
-A cell draws any control: a `Select`, a
+A cell draws any control: an input, an
+[`Inline_select`](/solidtype/heroui/inline-select/), a
[`Number_stepper`](/solidtype/heroui/number-stepper/), a `Switch`. Every key
of a field is its own, and the arrows from a button move between cells.
@@ -121,17 +130,30 @@ a height by `scroll_container_class`.
## Sticky Header
`sticky_header` keeps the header at the top of the scroll container, which
-`scroll_container_class` gives a height or a maximum height; the grid above
-keeps its header so.
+`scroll_container_class` gives a height or a maximum height. Rows keep their
+own heights, and selection, sorting, pinned columns and resizing work as in any
+grid.
+
+
## Virtualization
`virtualized` draws only the rows in view, each `row_height` high below a
-header `heading_height` high. The table is what scrolls: give it a height by
-`content_class`. The keys reach every row.
+header `heading_height` high, for a thousand rows or more. The table is what
+scrolls: give it a height by `content_class`. The keys reach every row.
+## Bulk Actions
+
+An [Action Bar](/solidtype/heroui/action-bar/) for the rows chosen.
+
+
+
+## Users
+
+
+
## Team Members
Search, a status filter and the columns shown are the application's: it
@@ -147,6 +169,12 @@ one row; a capacity a `Progress_circle`.
+## Footer
+
+`footer` is drawn below the grid, here a [Pagination](/solidtype/heroui/pagination/).
+
+
+
## Styling Reference
### CSS Classes
@@ -161,6 +189,9 @@ one row; a capacity a `Progress_circle`.
- `.data-grid__empty-state` - What is drawn with no rows
- `.data-grid__footer` - The footer, with HeroUI's `.table__footer`
+A virtualized or resizable grid places its own two columns itself, at 40px
+and 32px, whatever the variables say.
+
### Interactive States
- **Alignment**: `[data-align="start"]`, `"center"` or `"end"` on a column's
diff --git a/docs/src/content/docs/heroui/index.mdx b/docs/src/content/docs/heroui/index.mdx
index 8f786c3..d485058 100644
--- a/docs/src/content/docs/heroui/index.mdx
+++ b/docs/src/content/docs/heroui/index.mdx
@@ -28,8 +28,8 @@ HeroUI's own React one.
## How far it goes
-65 of HeroUI 3.2's components are ported;
-[Coverage](/solidtype/heroui/coverage/) lists each, what it does, and the 9
+66 of HeroUI 3.2's components are ported;
+[Coverage](/solidtype/heroui/coverage/) lists each, what it does, and the one
still to come. Every component has its page in this section, with HeroUI's
own examples written in OCaml.
diff --git a/docs/src/content/docs/heroui/inline-select.mdx b/docs/src/content/docs/heroui/inline-select.mdx
new file mode 100644
index 0000000..2f54c07
--- /dev/null
+++ b/docs/src/content/docs/heroui/inline-select.mdx
@@ -0,0 +1,144 @@
+---
+title: Inline Select
+description: A select drawn as text, for a choice made in a sentence, a toolbar or a cell.
+---
+
+import Example from "@components/Example.astro";
+import * as Usage from "@islands/inline_select_usage.jsx";
+import UsageCode from "@islands/inline_select_usage.mlx?raw";
+import * as TeamSwitcher from "@islands/inline_select_team_switcher.jsx";
+import TeamSwitcherCode from "@islands/inline_select_team_switcher.mlx?raw";
+import * as CustomIndicator from "@islands/inline_select_custom_indicator.jsx";
+import CustomIndicatorCode from "@islands/inline_select_custom_indicator.mlx?raw";
+import * as MultiSelect from "@islands/inline_select_multi_select.jsx";
+import MultiSelectCode from "@islands/inline_select_multi_select.mlx?raw";
+import * as Placements from "@islands/inline_select_placements.jsx";
+import PlacementsCode from "@islands/inline_select_placements.mlx?raw";
+
+A [Select](/solidtype/heroui/select/) drawn as text, with no field around it.
+Its choice, keys and list are the select's. Its look is a stylesheet the
+library ships, imported as [Theming](/solidtype/heroui/theming/#setup) shows.
+
+## Usage
+
+
+
+## Anatomy
+
+```ocaml
+
+
+
+
+
+
+ "English"
+
+
+
+```
+
+## Team Switcher
+
+The trigger draws whatever it is given, here the team chosen.
+
+
+
+## Custom Indicator
+
+`Inline_select.Indicator` draws the icon it is given in place of its chevrons.
+
+
+
+## Multi Select
+
+With `selection_mode=` `` `multiple ``, the value lists every option chosen.
+
+
+
+## Placements
+
+`Inline_select.Popover` takes a `placement`, `` `bottom_end `` by default.
+
+
+
+## Styling Reference
+
+### CSS Classes
+
+- `.inline-select`, beside the select's `.select`
+- `.inline-select__trigger`, beside `.select__trigger`
+- `.inline-select__value`, beside `.select__value`
+- `.inline-select__indicator`, beside `.select__indicator`
+- `.inline-select__popover`, beside `.select__popover`
+
+### Interactive States
+
+On `.inline-select__trigger`:
+
+- **Hovered**: `[data-hovered="true"]`
+- **Focus visible**: `[data-focus-visible="true"]`
+- **Disabled**: `[data-disabled="true"]`
+
+And on `.inline-select__indicator`, `[data-open="true"]` while the list is open.
+
+### CSS Variables
+
+| Variable | Default | Description |
+|---|---|---|
+| `--inline-select-value-max-width` | `12rem` | The widest the value is drawn before it is cut short |
+| `--inline-select-indicator-size` | `0.75rem` | The indicator's width and height |
+
+## API Reference
+
+Each prop beside its name in React's convention.
+
+### Inline_select
+
+| React | solidtype | Type | Default | Description |
+|---|---|---|---|---|
+| `selectionMode` | `selection_mode` | `` [ `single \| `multiple ] `` | `` `single `` | One option or many |
+| `value` | `value` | `string array` | | The options chosen (controlled) |
+| `defaultValue` | `default_value` | `string array` | | The options chosen at first (uncontrolled) |
+| `onChange` | `on_change` | `string array -> unit` | | Called with the options chosen |
+| `placeholder` | `placeholder` | `string` | `"Select an item"` | Shown while nothing is chosen |
+| `disabledKeys` | `disabled_keys` | `string array` | | Options that cannot be chosen |
+| `isOpen` | `is_open` | `bool` | | Whether the list is open (controlled) |
+| `defaultOpen` | `default_open` | `bool` | | Whether the list is open at first |
+| `onOpenChange` | `on_open_change` | `bool -> unit` | | Called as the list opens and closes |
+| `isDisabled` | `is_disabled` | `bool` | `false` | Whether it is disabled |
+| `isRequired` | `is_required` | `bool` | `false` | Whether a form requires a choice |
+| `isInvalid` | `is_invalid` | `bool` | `false` | Whether its choice is invalid |
+| `name` | `name` | `string` | | Its name in a form |
+| `className` | `class_` | `string` | | Added after its own classes |
+| `children` | `children` | elements | | Its trigger and popover |
+
+### Inline_select.Trigger
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `aria-label` | `aria_label` | `string` | Its name |
+| `className` | `class_` | `string` | Added after its own classes |
+| `children` | `children` | elements, or a function of its state | Its value and indicator, or anything else |
+
+### Inline_select.Value
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `className` | `class_` | `string` | Added after its own classes |
+| `children` | `children` | elements, or a function of its state | Drawn while an option is chosen, in place of the option |
+
+### Inline_select.Indicator
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `className` | `class_` | `string` | Added after its own classes |
+| `children` | `children` | elements | An icon in place of its chevrons |
+
+### Inline_select.Popover
+
+| React | solidtype | Type | Default | Description |
+|---|---|---|---|---|
+| `placement` | `placement` | `Select.placement` | `` `bottom_end `` | Where the list sits beside the trigger |
+| `className` | `class_` | `string` | | Added after its own classes |
+| `children` | `children` | elements | | Its `List_box` |
diff --git a/docs/src/content/docs/heroui/list-view.mdx b/docs/src/content/docs/heroui/list-view.mdx
new file mode 100644
index 0000000..b814a05
--- /dev/null
+++ b/docs/src/content/docs/heroui/list-view.mdx
@@ -0,0 +1,153 @@
+---
+title: List View
+description: A one-column list of rows, chosen and acted on by the keys and the pointer.
+---
+
+import Example from "@components/Example.astro";
+import * as Usage from "@islands/list_view_usage.jsx";
+import UsageCode from "@islands/list_view_usage.mlx?raw";
+import * as SelectionModes from "@islands/list_view_selection_modes.jsx";
+import SelectionModesCode from "@islands/list_view_selection_modes.mlx?raw";
+import * as Secondary from "@islands/list_view_secondary.jsx";
+import SecondaryCode from "@islands/list_view_secondary.mlx?raw";
+import * as DisabledItems from "@islands/list_view_disabled_items.jsx";
+import DisabledItemsCode from "@islands/list_view_disabled_items.mlx?raw";
+import * as WithActionBar from "@islands/list_view_with_action_bar.jsx";
+import WithActionBarCode from "@islands/list_view_with_action_bar.mlx?raw";
+import * as Virtualization from "@islands/list_view_virtualization.jsx";
+import VirtualizationCode from "@islands/list_view_virtualization.mlx?raw";
+
+A list of rows, each its content and an action, chosen by a checkbox where the
+list chooses. Its look is a stylesheet the library ships, imported as
+[Theming](/solidtype/heroui/theming/#setup) shows.
+
+## Usage
+
+
+
+## Anatomy
+
+```ocaml
+
+
+
+ "README.md"
+ "Updated 3 hours ago"
+
+ ...
+
+
+```
+
+## Keys
+
+Up and Down move between rows, never past either end, a disabled row passed
+over; Home and End reach the first and the last, and typing the start of a
+row's name the next row of that name. Space chooses a row. Right moves into
+the controls of a row, and Left back out. Where the list has an `on_action`, a
+press or Enter runs it while nothing is chosen.
+
+## Selection Modes
+
+`` `none ``, `` `single `` or `` `multiple ``; a list that chooses draws a
+checkbox in each row.
+
+
+
+## Variants
+
+### Primary
+
+A grey card of white rows, the default.
+
+
+
+### Secondary
+
+Rows on the page's own background, a line between each.
+
+
+
+## Disabled Items
+
+`disabled_keys` names rows that cannot be chosen, focused or acted on.
+
+
+
+## With Action Bar
+
+An [Action Bar](/solidtype/heroui/action-bar/) for what is chosen.
+
+
+
+## Virtualization
+
+`virtualized` draws only the rows in view, each `row_height` high, of a list
+given a height, which scrolls them.
+
+
+
+## Styling Reference
+
+### CSS Classes
+
+- `.list-view` - The list
+- `.list-view--primary`, `.list-view--secondary` - Its variants
+- `.list-view__item` - A row
+- `.list-view__selection-cell` - A row's checkbox
+- `.list-view__item-content` - A row's icon and text
+- `.list-view__title` - A row's name
+- `.list-view__description` - The line under it
+- `.list-view__item-action` - What a row ends with
+- `.list-view__empty-state` - What a list with no rows draws
+
+### Interactive States
+
+On `.list-view__item`:
+
+- **Selected**: `[data-selected="true"]`
+- **Hovered**: `[data-hovered="true"]`
+- **Pressed**: `[data-pressed="true"]`
+- **Focus visible**: `[data-focus-visible="true"]`
+- **Disabled**: `[aria-disabled="true"]`
+
+## API Reference
+
+Each prop beside its name in React's convention.
+
+### List_view
+
+| React | solidtype | Type | Default | Description |
+|---|---|---|---|---|
+| `aria-label` | `aria_label` | `string` | | Its name |
+| `variant` | `variant` | `` [ `primary \| `secondary ] `` | `` `primary `` | Its look |
+| `selectionMode` | `selection_mode` | `` [ `none \| `single \| `multiple ] `` | `` `none `` | How many rows it chooses |
+| `selectionBehavior` | `selection_behavior` | `` [ `toggle \| `replace ] `` | `` `toggle `` | Whether a press adds to the choice or replaces it |
+| `selectedKeys` | `selected_keys` | `string array` | | The rows chosen (controlled) |
+| `defaultSelectedKeys` | `default_selected_keys` | `string array` | | The rows chosen at first |
+| `onSelectionChange` | `on_selection_change` | `string array -> unit` | | Called with the rows chosen |
+| `disabledKeys` | `disabled_keys` | `string array` | | Rows that cannot be chosen or acted on |
+| `disallowEmptySelection` | `disallow_empty_selection` | `bool` | | Whether the last row chosen stays chosen |
+| `onAction` | `on_action` | `string -> unit` | | Called with a row's key as it is acted on |
+| `renderEmptyState` | `render_empty_state` | `unit -> element` | | Drawn while it has no row |
+| `virtualized` | `virtualized` | `bool` | `false` | Whether it draws only the rows in view |
+| `rowHeight` | `row_height` | `float` | `48.` | Each row's height while virtualized |
+| `className` | `class_` | `string` | | Added after its own classes |
+
+### List_view.Item
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `id` | `id` | `string` | Its key |
+| `textValue` | `text_value` | `string` | Its name, which typing finds |
+| `isDisabled` | `is_disabled` | `bool` | Whether it is disabled |
+| `href` | `href` | `string` | The page its action opens |
+| `className` | `class_` | `string` | Added after its own classes |
+| `children` | `children` | elements, or a function of its state | Its content and action |
+
+### List_view.Item_content, Title, Description, Item_action
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `className` | `class_` | `string` | Added after its own class |
+| `children` | `children` | elements | What it holds |
diff --git a/docs/src/content/docs/heroui/radio-group.mdx b/docs/src/content/docs/heroui/radio-group.mdx
index 2ad16fd..436aed9 100644
--- a/docs/src/content/docs/heroui/radio-group.mdx
+++ b/docs/src/content/docs/heroui/radio-group.mdx
@@ -11,6 +11,12 @@ import * as RadioGroupHorizontal from "@islands/radio_group_horizontal.jsx";
import RadioGroupHorizontalCode from "@islands/radio_group_horizontal.mlx?raw";
import * as RadioGroupVariants from "@islands/radio_group_variants.jsx";
import RadioGroupVariantsCode from "@islands/radio_group_variants.mlx?raw";
+import * as RadioGroupInSurface from "@islands/radio_group_in_surface.jsx";
+import RadioGroupInSurfaceCode from "@islands/radio_group_in_surface.mlx?raw";
+import * as RadioGroupValidation from "@islands/radio_group_validation.jsx";
+import RadioGroupValidationCode from "@islands/radio_group_validation.mlx?raw";
+import * as RadioGroupDeliveryAndPayment from "@islands/radio_group_delivery_and_payment.jsx";
+import RadioGroupDeliveryAndPaymentCode from "@islands/radio_group_delivery_and_payment.mlx?raw";
import * as RadioGroupDisabled from "@islands/radio_group_disabled.jsx";
import RadioGroupDisabledCode from "@islands/radio_group_disabled.mlx?raw";
import * as RadioGroupControlled from "@islands/radio_group_controlled.jsx";
@@ -84,6 +90,13 @@ The RadioGroup component supports two visual variants:
+### In Surface
+
+On a [Surface](/solidtype/heroui/surface/), `variant=` `` `secondary `` is
+the quieter look meant for its background.
+
+
+
### Disabled
@@ -99,14 +112,26 @@ updates.
+### Validation
+
+The group is invalid as `is_invalid` says, here once a submit finds no plan
+chosen, and its `Field_error` shows while it is.
+
+
+
+### Delivery & Payment
+
+Each `Radio.Content` drawn as a card, its state read by `data-selected`.
+
+
+
### Custom Indicator
-### Not yet
+### Render Function
-HeroUI's In Surface, until Surface is ported; Validation and Delivery &
-Payment, which need a form and `FieldError`. `as_` draws another element in a part's place, as [Composition](/solidtype/heroui/composition/#custom-dom-element) shows.
+`as_` draws another element in a part's place, as [Composition](/solidtype/heroui/composition/#custom-dom-element) shows.
## Customization
diff --git a/docs/src/content/docs/heroui/rating.mdx b/docs/src/content/docs/heroui/rating.mdx
new file mode 100644
index 0000000..4afd6aa
--- /dev/null
+++ b/docs/src/content/docs/heroui/rating.mdx
@@ -0,0 +1,154 @@
+---
+title: Rating
+description: A star rating, chosen by a press or the arrow keys, or shown read only as a fraction.
+---
+
+import Example from "@components/Example.astro";
+import * as Usage from "@islands/rating_usage.jsx";
+import UsageCode from "@islands/rating_usage.mlx?raw";
+import * as Controlled from "@islands/rating_controlled.jsx";
+import ControlledCode from "@islands/rating_controlled.mlx?raw";
+import * as CustomColor from "@islands/rating_custom_color.jsx";
+import CustomColorCode from "@islands/rating_custom_color.mlx?raw";
+import * as CustomIconHeart from "@islands/rating_custom_icon_heart.jsx";
+import CustomIconHeartCode from "@islands/rating_custom_icon_heart.mlx?raw";
+import * as CustomIconPerItem from "@islands/rating_custom_icon_per_item.jsx";
+import CustomIconPerItemCode from "@islands/rating_custom_icon_per_item.mlx?raw";
+import * as Disabled from "@islands/rating_disabled.jsx";
+import DisabledCode from "@islands/rating_disabled.mlx?raw";
+import * as ProductReview from "@islands/rating_product_review.jsx";
+import ProductReviewCode from "@islands/rating_product_review.mlx?raw";
+import * as ReadOnly from "@islands/rating_read_only.jsx";
+import ReadOnlyCode from "@islands/rating_read_only.mlx?raw";
+import * as ReadOnlyFractional from "@islands/rating_read_only_fractional.jsx";
+import ReadOnlyFractionalCode from "@islands/rating_read_only_fractional.mlx?raw";
+import * as RenderFunction from "@islands/rating_render_function.jsx";
+import RenderFunctionCode from "@islands/rating_render_function.mlx?raw";
+import * as Sizes from "@islands/rating_sizes.jsx";
+import SizesCode from "@islands/rating_sizes.mlx?raw";
+import * as WithLabel from "@islands/rating_with_label.jsx";
+import WithLabelCode from "@islands/rating_with_label.mlx?raw";
+
+Kobalte's rating, a radio group of stars, in HeroUI's look: chosen by a press
+or the arrow keys, the stars under the pointer previewed as it moves. Read
+only, its value may be a fraction. Its look is a stylesheet the library ships,
+imported as [Theming](/solidtype/heroui/theming/#setup) shows.
+
+## Usage
+
+
+
+## Anatomy
+
+```ocaml
+
+
+
+```
+
+## Controlled
+
+
+
+## Custom Color
+
+`--rating-active-color` colours the active stars.
+
+
+
+## Custom Icon Heart
+
+`icon` is every item's icon.
+
+
+
+## Custom Icon Per Item
+
+An item's children are its own icon.
+
+
+
+## Disabled
+
+
+
+## Product Review
+
+
+
+## Read Only
+
+
+
+## Read Only Fractional
+
+A value read only may be a fraction: the stars up to its whole part are active, and the next filled as far as the fraction goes.
+
+
+
+## Render Function
+
+A function child draws the whole item of its state: `is_active`, `is_partial` and `partial_percent`.
+
+
+
+## Sizes
+
+
+
+## With Label
+
+
+
+## Styling Reference
+
+### CSS Classes
+
+- `.rating`, and its sizes `.rating--sm`, `.rating--md`, `.rating--lg`
+- `.rating__item`, and `.rating__item--sm`, `--md`, `--lg`
+- `.rating__icon` - An item's icon
+- `.rating__icon-partial` - The part of an icon a fraction fills
+
+### Interactive States
+
+- **Active**: `[data-active="true"]` on `.rating__icon`
+- **Read only**: `[data-readonly="true"]` on `.rating` and `.rating__item`
+- **Focus visible**: `[data-focus-visible="true"]` on `.rating__item`
+- **Pressed**: `[data-pressed="true"]` on `.rating__item`
+- **Disabled**: `[data-disabled="true"]` on `.rating`
+
+### CSS Variables
+
+| Variable | Default | Description |
+|---|---|---|
+| `--rating-active-color` | `var(--color-warning)` | The active stars' colour |
+| `--rating-inactive-color` | `var(--color-surface-tertiary)` | The other stars' colour |
+| `--rating-partial` | | How far a fraction fills its star, written by the rating |
+
+## API Reference
+
+Each prop beside its name in React's convention.
+
+### Rating
+
+| React | solidtype | Type | Default | Description |
+|---|---|---|---|---|
+| `size` | `size` | `` [ `sm \| `md \| `lg ] `` | `` `md `` | Its size |
+| `value` | `value` | `float` | | The value (controlled) |
+| `defaultValue` | `default_value` | `float` | `0.` | The value at first (uncontrolled) |
+| `onValueChange` | `on_value_change` | `float -> unit` | | Called with each value chosen |
+| `icon` | `icon` | element | a star | Every item's icon |
+| `isDisabled` | `is_disabled` | `bool` | `false` | Whether it is disabled |
+| `isReadOnly` | `is_read_only` | `bool` | `false` | Whether it only shows its value |
+| `isRequired` | `is_required` | `bool` | `false` | Whether a form requires a value |
+| `name` | `name` | `string` | | Its name in a form |
+| `aria-label` | `aria_label` | `string` | | Its name |
+| `className` | `class_` | `string` | | Added after its own classes |
+
+### Rating.Item
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `value` | `value` | `float` | Its place, from 1 |
+| `children` | `children` | elements, or a function of its state | Its icon, or the whole item |
+| `className` | `class_` | `string` | Added after its own classes |
diff --git a/docs/src/content/docs/heroui/select.mdx b/docs/src/content/docs/heroui/select.mdx
index d4956d9..e4f3ca1 100644
--- a/docs/src/content/docs/heroui/select.mdx
+++ b/docs/src/content/docs/heroui/select.mdx
@@ -301,7 +301,7 @@ Each prop beside the name HeroUI's React component gives it.
| React | solidtype | Type | Description |
|---|---|---|---|
-| `placement` | `placement` | `` `top `` \| `` `bottom `` \| `` `left `` \| `` `right `` | Placement of the popover relative to the trigger, `` `bottom `` by default |
+| `placement` | `placement` | `` `bottom ``, and React Aria's others: `` `bottom_end ``, `` `top_start ``, `` `start ``... | Placement of the popover relative to the trigger, `` `bottom `` by default |
| `className` | `class_` | `string` | Added after HeroUI's classes |
| `children` | `children` | elements | What it holds |
diff --git a/docs/src/content/docs/heroui/surface.mdx b/docs/src/content/docs/heroui/surface.mdx
index b174cab..0137d08 100644
--- a/docs/src/content/docs/heroui/surface.mdx
+++ b/docs/src/content/docs/heroui/surface.mdx
@@ -10,6 +10,8 @@ import * as Variants from "@islands/surface_variants.jsx";
import VariantsCode from "@islands/surface_variants.mlx?raw";
import * as Tailwind from "@islands/surface_tailwind.jsx";
import TailwindCode from "@islands/surface_tailwind.mlx?raw";
+import * as WithFormComponents from "@islands/surface_with_form_components.jsx";
+import WithFormComponentsCode from "@islands/surface_with_form_components.mlx?raw";
import * as Demo from "@islands/surface_demo.jsx";
Original HeroUI documentation: [Surface](https://heroui.com/en/docs/react/components/surface).
@@ -53,10 +55,12 @@ let on_surface () =
match surface with Some variant -> S.get variant | None -> `default
```
-### Not yet
+### With Form Components
-HeroUI's With Form Components example needs Input and TextArea, which are not
-ported yet.
+A field on a surface takes `variant=` `` `secondary ``, the quieter look
+meant for a surface's background.
+
+
## Customization
diff --git a/docs/src/content/docs/heroui/switch.mdx b/docs/src/content/docs/heroui/switch.mdx
index 65c6001..9e96c2b 100644
--- a/docs/src/content/docs/heroui/switch.mdx
+++ b/docs/src/content/docs/heroui/switch.mdx
@@ -23,6 +23,12 @@ import * as SwitchGroup from "@islands/switch_group.jsx";
import SwitchGroupCode from "@islands/switch_group.mlx?raw";
import * as SwitchGroupHorizontal from "@islands/switch_group_horizontal.jsx";
import SwitchGroupHorizontalCode from "@islands/switch_group_horizontal.mlx?raw";
+import * as SwitchWithIcons from "@islands/switch_with_icons.jsx";
+import SwitchWithIconsCode from "@islands/switch_with_icons.mlx?raw";
+import * as SwitchWithDescription from "@islands/switch_with_description.jsx";
+import SwitchWithDescriptionCode from "@islands/switch_with_description.mlx?raw";
+import * as SwitchFormIntegration from "@islands/switch_form_integration.jsx";
+import SwitchFormIntegrationCode from "@islands/switch_form_integration.mlx?raw";
import * as SwitchRenderProps from "@islands/switch_render_props.jsx";
import SwitchRenderPropsCode from "@islands/switch_render_props.mlx?raw";
@@ -84,6 +90,12 @@ grouping multiple switches, use the `Switch_group` component:
+### With Icons
+
+A `Switch.Icon` in the thumb, drawn of the switch's state.
+
+
+
### Disabled
@@ -100,6 +112,10 @@ grouping multiple switches, use the `Switch_group` component:
+### With Description
+
+
+
### Label Position
@@ -114,16 +130,21 @@ grouping multiple switches, use the `Switch_group` component:
+### Form Integration
+
+A switch's `name` and `value` are its form's while it is on.
+
+
+
### Render Props
A function child is given the switch's state.
-### Not yet
+### Render Function
-HeroUI's With Icons, With Description and Form Integration, until their parts
-are ported. `as_` draws another element in a part's place, as [Composition](/solidtype/heroui/composition/#custom-dom-element) shows.
+`as_` draws another element in a part's place, as [Composition](/solidtype/heroui/composition/#custom-dom-element) shows.
## Customization
@@ -153,6 +174,7 @@ ensure component variants and states are reusable and easy to customize.
- `.switch__content` - Content container
- `.switch__control` - Switch control track
- `.switch__thumb` - Switch thumb that moves
+- `.switch__icon` - An icon in the thumb
- `.switch--sm` - Small size variant
- `.switch--md` - Medium size variant (default)
- `.switch--lg` - Large size variant
@@ -200,12 +222,12 @@ Each prop beside the name HeroUI's React component gives it.
| `aria-label` | `aria_label` | `string` | | Its name where no label names it |
| `isInvalid` | `is_invalid` | `bool` | `false` | Whether the switch is invalid |
-### Switch.Content, Switch.Control and Switch.Thumb
+### Switch.Content, Switch.Control, Switch.Thumb and Switch.Icon
| React | solidtype | Type | Description |
|---|---|---|---|
| `className` | `class_` | `string` | Added after HeroUI's class |
-| `children` | `children` | elements | What it holds; not the thumb's |
+| `children` | `children` | elements | What it holds: the thumb an icon, the icon what it draws |
### SwitchGroup
diff --git a/docs/src/content/docs/heroui/toolbar.mdx b/docs/src/content/docs/heroui/toolbar.mdx
new file mode 100644
index 0000000..6b2de17
--- /dev/null
+++ b/docs/src/content/docs/heroui/toolbar.mdx
@@ -0,0 +1,103 @@
+---
+title: Toolbar
+description: A container for interactive controls with arrow key navigation.
+---
+
+import Example from "@components/Example.astro";
+import * as Usage from "@islands/toolbar_usage.jsx";
+import UsageCode from "@islands/toolbar_usage.mlx?raw";
+import * as Vertical from "@islands/toolbar_vertical.jsx";
+import VerticalCode from "@islands/toolbar_vertical.mlx?raw";
+import * as Attached from "@islands/toolbar_attached.jsx";
+import AttachedCode from "@islands/toolbar_attached.mlx?raw";
+import * as WithButtonGroup from "@islands/toolbar_with_button_group.jsx";
+import WithButtonGroupCode from "@islands/toolbar_with_button_group.mlx?raw";
+import * as Tailwind from "@islands/toolbar_tailwind.jsx";
+import TailwindCode from "@islands/toolbar_tailwind.mlx?raw";
+import * as Demo from "@islands/toolbar_demo.jsx";
+
+Original HeroUI documentation: [Toolbar](https://heroui.com/en/docs/react/components/toolbar).
+
+## Usage
+
+
+
+## Parity
+
+The same HeroUI Toolbar twice, under the same props: in solidtype on the left,
+in React on the right. Below them, every attribute of the two toolbars: a
+marked row is one they disagree on, and a dimmed row is a framework's own,
+which no style reads.
+
+
+
+
+
+## Keys
+
+The arrows of its orientation move the focus between its stops, what Tab
+reaches inside it, the page's direction read for the horizontal ones, never
+past either end. A toggle group is one stop, whose own arrows move among its
+buttons. A `Separator` inside the toolbar runs across it, and a
+`Button_group` or `Toggle_button_group` along it, unless either gives its
+own orientation.
+
+## Examples
+
+### Vertical
+
+
+
+### Attached
+
+
+
+### With ButtonGroup
+
+
+
+## Customization
+
+### Tailwind CSS
+
+
+
+### Global CSS
+
+```css
+@layer components {
+ .toolbar {
+ @apply gap-4 rounded-lg bg-surface p-3;
+ }
+}
+```
+
+## Styling Reference
+
+### CSS Classes
+
+- `.toolbar` - Base container
+- `.toolbar--horizontal` - Horizontal orientation (default)
+- `.toolbar--vertical` - Vertical orientation
+- `.toolbar--attached` - Attached variant with surface background and full rounding
+
+## API Reference
+
+Each prop beside the name HeroUI's React component gives it.
+
+### Toolbar
+
+| React | solidtype | Type | Default | Description |
+|---|---|---|---|---|
+| `isAttached` | `is_attached` | `bool` | `false` | Whether the toolbar has a surface background with full rounding |
+| `orientation` | `orientation` | `` [ `horizontal \| `vertical ] `` | `` `horizontal `` | The orientation of the toolbar |
+| `aria-label` | `aria_label` | `string` | | An accessible label for the toolbar |
+| `aria-labelledby` | `aria_labelledby` | `string` | | The id of an element that labels the toolbar |
+| `children` | `children` | elements, or a function of its state | | Its controls |
+| `className` | `class_` | `string` | | Added after HeroUI's classes |
+
+### Render Props
+
+| React | solidtype | Type | Description |
+|---|---|---|---|
+| `orientation` | `orientation` | `` [ `horizontal \| `vertical ] S.accessor `` | The current orientation of the toolbar |
diff --git a/docs/src/content/docs/index.mdx b/docs/src/content/docs/index.mdx
index 392189b..da06630 100644
--- a/docs/src/content/docs/index.mdx
+++ b/docs/src/content/docs/index.mdx
@@ -65,7 +65,7 @@ GitHub release:
"solid-js": "~1.9.17",
"vite": "^8.3.0",
"vite-plugin-solid": "^2.11.14",
- "vite-plugin-solidtype": "https://github.com/hyphatech/solidtype/releases/download/0.15.0/vite-plugin-solidtype-0.15.0.tgz"
+ "vite-plugin-solidtype": "https://github.com/hyphatech/solidtype/releases/download/0.15.1/vite-plugin-solidtype-0.15.1.tgz"
}
}
```
diff --git a/docs/src/styles/heroui.css b/docs/src/styles/heroui.css
index bb9f5dd..0d01393 100644
--- a/docs/src/styles/heroui.css
+++ b/docs/src/styles/heroui.css
@@ -80,6 +80,7 @@
@import "@heroui/styles/components/accordion.css" layer(components);
@import "@heroui/styles/components/tabs.css" layer(components);
@import "@heroui/styles/components/pagination.css" layer(components);
+@import "@heroui/styles/components/toolbar.css" layer(components);
@import "@heroui/styles/components/tooltip.css" layer(components);
@import "@heroui/styles/components/popover.css" layer(components);
@import "@heroui/styles/components/modal.css" layer(components);
diff --git a/headless/grid_list.mli b/headless/grid_list.mli
new file mode 100644
index 0000000..1073d18
--- /dev/null
+++ b/headless/grid_list.mli
@@ -0,0 +1,113 @@
+(** A list of rows, as Kobalte would make one: a [
] of items,
+ each a [
] around one [
], made of
+ {!Solidtype_kobalte.Selection}'s hooks, chosen as the list's
+ [selection_mode] and [selection_behavior] say, and acted on by [on_action]
+ or an item's [href]. It draws no style: each part is the element it names,
+ its roles and state as attributes, and takes every attribute its element
+ does, which it passes on, a [ref] and a handler called beside its own.
+
+ {[
+
+ "README.md"
+
+ ]}
+
+ Tab reaches the item last focused, or the first chosen, or the first, and
+ leaves the list after it. Up and Down move from item to item, a disabled one
+ passed over, never past either end; Home and End, Page Up and Page Down
+ reach the first and the last; typing the start of an item's name the next
+ item of that name. Right moves into the controls of the focused item, and
+ Left back out, each arrow a control's own once it holds the focus.
+
+ A press, Space or Enter chooses an item, as Kobalte's selection does; where
+ the list has an action, a press or Enter runs it instead while nothing is
+ chosen, or while the item cannot be chosen, and a double press runs it where
+ a press replaces the choice. A press on a control inside an item is the
+ control's. A chosen item is [aria-selected] and [data-selected], and a
+ disabled one [aria-disabled] and [data-disabled], present and empty as
+ Kobalte's state is. *)
+
+module S := Solidtype.Solid
+module Jsx := Solidtype.Jsx
+
+type list_state = {
+ selection_mode : [ `none | `single | `multiple ] S.accessor;
+ is_empty : bool S.accessor;
+ is_selected : string -> bool;
+ is_disabled : string -> bool;
+ toggle_selection : string -> unit;
+ (** Chooses an item, or lets it go, where the list chooses. *)
+}
+(** What a part inside a list reads of it. *)
+
+(** The list's state.
+
+ Raises [Invalid_argument] outside a [Grid_list]. *)
+module Context : sig
+ val use : unit -> list_state
+end
+
+type item_state = {
+ key : string S.accessor;
+ is_selected : bool S.accessor;
+ is_disabled : bool S.accessor;
+ allows_selection : bool S.accessor;
+ selection_mode : [ `none | `single | `multiple ] S.accessor;
+ toggle_selection : unit -> unit;
+}
+(** What a part inside an item reads of it. *)
+
+module Props : sig
+ type t
+
+ val check :
+ ?selection_mode:[ `none | `single | `multiple ] Solidtype.Check.value ->
+ ?selection_behavior:[ `toggle | `replace ] Solidtype.Check.value ->
+ ?selected_keys:string array Solidtype.Check.value ->
+ ?default_selected_keys:string array Solidtype.Check.value ->
+ ?on_selection_change:(string array -> unit) ->
+ ?disabled_keys:string array Solidtype.Check.value ->
+ ?disallow_empty_selection:bool Solidtype.Check.value ->
+ ?on_action:(string -> unit) ->
+ ?render_empty_state:(unit -> Jsx.element) ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:'spread S.rest ->
+ (?children:('f, [ `elements ]) Solidtype.Check.children -> unit -> unit)
+ Solidtype.Html.Div.check
+end
+
+val make : Props.t -> Jsx.element
+(** The list: [aria-multiselectable] where it chooses many, [data-empty] while
+ it holds no item, when it draws [render_empty_state] in a row of its own.
+ Inside a [Virtualizer] of a list's layout it draws only the rows in view of
+ what scrolls it, and the focused one wherever it is. *)
+
+val component : Props.t Jsx.component
+
+(** An item: [text_value], or the first text among its children once its row is
+ drawn, names it and is what typing finds, so an item a virtualized list may
+ not draw is given [text_value]; [href] is the page its action opens. Its
+ children are made as its row is drawn. *)
+module Item : sig
+ module Context : sig
+ val use : unit -> item_state
+ (** Raises [Invalid_argument] outside a [Grid_list.Item]. *)
+ end
+
+ module Props : sig
+ type t
+
+ val check :
+ ?id:string Solidtype.Check.value ->
+ ?text_value:string Solidtype.Check.value ->
+ ?is_disabled:bool Solidtype.Check.value ->
+ ?href:string Solidtype.Check.value ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:'spread S.rest ->
+ (?children:('f, [ `elements ]) Solidtype.Check.children -> unit -> unit)
+ Solidtype.Html.Div.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
diff --git a/headless/grid_list.mlx b/headless/grid_list.mlx
new file mode 100644
index 0000000..1b28cda
--- /dev/null
+++ b/headless/grid_list.mlx
@@ -0,0 +1,828 @@
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module Selection = Solidtype_kobalte.Selection
+module I18n = Solidtype_kobalte.I18n
+module Types = Solidtype_kobalte.Types
+module Either = Types.Either
+module Delegate = Types.KeyboardDelegate
+module List_state = Types.ListState
+module Manager = Types.MultipleSelectionManager
+module Selectable_list = Types.Selection_CreateSelectableList
+module Selectable_item = Types.Selection_CreateSelectableItem
+module For = Solidtype.For
+
+external as_element : _ Dom.element_like -> Dom.element = "%identity"
+(* A part's element, of whichever kind it is drawn as, is an element. *)
+
+external contains : _ Dom.element_like -> Dom.element -> bool = "contains"
+[@@mel.send]
+
+external focus : _ Dom.element_like -> unit = "focus" [@@mel.send]
+
+external query_all :
+ _ Dom.element_like -> string -> Dom.element Js.Array.array_like
+ = "querySelectorAll"
+[@@mel.send]
+
+external key_target : Dom.keyboardEvent -> Dom.element = "target" [@@mel.get]
+
+external key_current : Dom.keyboardEvent -> Dom.element = "currentTarget"
+[@@mel.get]
+
+external pressed : Dom.keyboardEvent -> string = "key" [@@mel.get]
+external stop : Dom.keyboardEvent -> unit = "stopPropagation" [@@mel.send]
+external prevent : Dom.keyboardEvent -> unit = "preventDefault" [@@mel.send]
+
+external focus_current : Dom.focusEvent -> Dom.element = "currentTarget"
+[@@mel.get]
+
+external focus_target : Dom.focusEvent -> Dom.element = "target" [@@mel.get]
+
+external closest : Dom.element -> string -> Dom.element Js.null = "closest"
+[@@mel.send]
+
+external pointer_target : Dom.pointerEvent -> Dom.element = "target" [@@mel.get]
+
+external pointer_current : Dom.pointerEvent -> Dom.element = "currentTarget"
+[@@mel.get]
+
+external pointer_type : Dom.pointerEvent -> string = "pointerType" [@@mel.get]
+external mouse_target : Dom.mouseEvent -> Dom.element = "target" [@@mel.get]
+
+external mouse_current : Dom.mouseEvent -> Dom.element = "currentTarget"
+[@@mel.get]
+
+external meta_held : _ Dom.event_like -> bool = "metaKey" [@@mel.get]
+external ctrl_held : _ Dom.event_like -> bool = "ctrlKey" [@@mel.get]
+external alt_held : _ Dom.event_like -> bool = "altKey" [@@mel.get]
+external shift_held : _ Dom.event_like -> bool = "shiftKey" [@@mel.get]
+
+external create_element : string -> Dom.element = "createElement"
+[@@mel.scope "document"]
+
+external set_attribute : Dom.element -> string -> string -> unit
+ = "setAttribute"
+[@@mel.send]
+
+external append_child : _ Dom.element_like -> Dom.element -> Dom.element
+ = "appendChild"
+[@@mel.send]
+
+external remove_element : Dom.element -> unit = "remove" [@@mel.send]
+
+type click_init
+
+external click_init :
+ meta_key:(bool[@mel.as "metaKey"]) ->
+ ctrl_key:(bool[@mel.as "ctrlKey"]) ->
+ alt_key:(bool[@mel.as "altKey"]) ->
+ shift_key:(bool[@mel.as "shiftKey"]) ->
+ click_init = ""
+[@@mel.obj]
+
+external mouse_event : string -> click_init -> Dom.mouseEvent = "MouseEvent"
+[@@mel.new]
+
+external dispatch : Dom.element -> Dom.mouseEvent -> bool = "dispatchEvent"
+[@@mel.send]
+
+(* An item's link opened as a click on a link would open it, the keys held
+ with the press kept, as React Aria's router opens one. *)
+let open_link row href e =
+ let link = create_element "a" in
+ set_attribute link "href" href;
+ ignore (append_child row link : Dom.element);
+ ignore
+ (dispatch link
+ (mouse_event "click"
+ (click_init ~meta_key:(meta_held e) ~ctrl_key:(ctrl_held e)
+ ~alt_key:(alt_held e) ~shift_key:(shift_held e)))
+ : bool);
+ remove_element link
+
+(* Kobalte's state, an attribute present and empty, or none. *)
+let marked on = if on then Jsx.data "" else Jsx.flag false
+
+(* What the arrows reach inside an item, in the page's order. *)
+let focusable =
+ "button:not([disabled]), a[href], input:not([disabled]), \
+ select:not([disabled]), textarea:not([disabled]), [tabindex]"
+
+(* What a press inside an item is a control's: a focusable element, a label,
+ which passes its press to its input, or an element of a widget's role. *)
+let control =
+ focusable
+ ^ ", label, [contenteditable], [role=button], [role=checkbox], [role=radio], \
+ [role=switch], [role=slider], [role=spinbutton], [role=textbox], \
+ [role=searchbox], [role=combobox], [role=link], [role=tab], \
+ [role=option], [role=menuitem], [role=menuitemcheckbox], \
+ [role=menuitemradio], [role=group]"
+
+(* Whether a press began in a control inside an item, whose press is its own:
+ never the item itself. *)
+let in_control row target =
+ match Js.Null.toOption (closest target control) with
+ | Some c -> c != row && contains row c
+ | None -> false
+
+type item_state = {
+ key : string S.accessor;
+ is_selected : bool S.accessor;
+ is_disabled : bool S.accessor;
+ allows_selection : bool S.accessor;
+ selection_mode : [ `none | `single | `multiple ] S.accessor;
+ toggle_selection : unit -> unit;
+}
+
+(* An item as the list keeps it: its key, its name, and how its row is drawn.
+ Each stands in its place among the list's children, so the list reads them
+ in order and draws the rows itself, all of them, or those in view. *)
+type listed = {
+ key : string S.accessor;
+ disabled : bool S.accessor;
+ text : string S.accessor;
+ draw : unit -> Jsx.element;
+}
+
+module Entry = Jsx.Token (struct
+ type t = listed
+end)
+
+type list_state = {
+ selection_mode : [ `none | `single | `multiple ] S.accessor;
+ is_empty : bool S.accessor;
+ is_selected : string -> bool;
+ is_disabled : string -> bool;
+ toggle_selection : string -> unit;
+}
+
+type group = {
+ manager : Manager.t S.accessor;
+ selection_mode : [ `none | `single | `multiple ] S.accessor;
+ disabled_key : string -> bool;
+ on_action : (string -> unit) option S.accessor;
+ is_empty : bool S.accessor;
+}
+
+module Group_context = Solidtype.Context.Make_optional (struct
+ type t = group
+end)
+
+module Item_context = Solidtype.Context.Make_optional (struct
+ type t = item_state
+end)
+
+let in_group part =
+ match Group_context.use () with
+ | Some g -> g
+ | None -> invalid_arg (part ^ " is used inside a Grid_list")
+
+module Context = struct
+ let use () =
+ let g = in_group "Grid_list.Context.use" in
+ {
+ selection_mode = g.selection_mode;
+ is_empty = g.is_empty;
+ is_selected = (fun k -> Manager.is_selected (S.get g.manager) k);
+ is_disabled = g.disabled_key;
+ toggle_selection =
+ (fun k ->
+ match S.get g.selection_mode with
+ | `none -> ()
+ | `single | `multiple ->
+ if not (g.disabled_key k) then
+ Manager.toggle_selection (S.get g.manager) k);
+ }
+end
+
+(* Where the keys move among the items: up and down in order, a disabled one
+ passed over, never past either end, as React Aria's grid list moves. *)
+let delegate ~(items : listed array S.accessor) ~collator =
+ let index k =
+ let all = S.get items in
+ let rec find i =
+ if i >= Array.length all then None
+ else if String.equal (S.get all.(i).key) k then Some i
+ else find (i + 1)
+ in
+ find 0
+ in
+ let rec usable i step =
+ let all = S.get items in
+ if i < 0 || i >= Array.length all then None
+ else if S.get all.(i).disabled then usable (i + step) step
+ else Some (S.get all.(i).key)
+ in
+ let first () = usable 0 1 in
+ let last () = usable (Array.length (S.get items) - 1) (-1) in
+ let next k = Option.bind (index k) (fun i -> usable (i + 1) 1) in
+ let previous k = Option.bind (index k) (fun i -> usable (i - 1) (-1)) in
+ let search typed from =
+ let n = String.length typed in
+ let matches k =
+ match index k with
+ | Some i ->
+ let text = S.get (S.get items).(i).text in
+ String.length text >= n
+ && Float.equal
+ (Types.Collator.compare (S.get collator)
+ (Js.String.slice ~start:0 ~end_:n text)
+ typed)
+ 0.
+ | None -> false
+ in
+ let rec go = function
+ | None -> None
+ | Some k when matches k -> Some k
+ | Some k -> go (next k)
+ in
+ go (match from with Some k -> Some k | None -> first ())
+ in
+ Delegate.make ~get_key_below:next ~get_key_above:previous
+ ~get_key_page_below:(fun _ -> last ())
+ ~get_key_page_above:(fun _ -> first ())
+ ~get_first_key:(fun _ _ -> first ())
+ ~get_last_key:(fun _ _ -> last ())
+ ~get_key_for_search:search ()
+
+module Props = struct
+ type t
+
+ external check :
+ ?selection_mode:[ `none | `single | `multiple ] Solidtype.Check.value ->
+ ?selection_behavior:[ `toggle | `replace ] Solidtype.Check.value ->
+ ?selected_keys:string array Solidtype.Check.value ->
+ ?default_selected_keys:string array Solidtype.Check.value ->
+ ?on_selection_change:(string array -> unit) ->
+ ?disabled_keys:string array Solidtype.Check.value ->
+ ?disallow_empty_selection:bool Solidtype.Check.value ->
+ ?on_action:(string -> unit) ->
+ ?render_empty_state:(unit -> Solidtype.Jsx.element) ->
+ ?as_:(Solidtype.Html.Div.props -> Solidtype.Jsx.element) ->
+ ?props:'spread Solidtype.Solid.rest ->
+ (?children:('f, [ `elements ]) Solidtype.Check.children -> unit -> unit)
+ Solidtype.Html.Div.check = "check"
+ [@@mel.module "vite-plugin-solidtype/markers"]
+
+ external selection_mode : t -> [ `none | `single | `multiple ] option
+ = "selectionMode"
+ [@@mel.get]
+
+ external selection_behavior : t -> [ `toggle | `replace ] option
+ = "selectionBehavior"
+ [@@mel.get]
+
+ external selected_keys : t -> string array option = "selectedKeys" [@@mel.get]
+
+ external default_selected_keys : t -> string array option
+ = "defaultSelectedKeys"
+ [@@mel.get]
+
+ external on_selection_change : t -> ((string array -> unit)[@u]) option
+ = "onSelectionChange"
+ [@@mel.get]
+
+ external disabled_keys : t -> string array option = "disabledKeys" [@@mel.get]
+
+ external disallow_empty_selection : t -> bool option
+ = "disallowEmptySelection"
+ [@@mel.get]
+
+ external on_action : t -> ((string -> unit)[@u]) option = "onAction"
+ [@@mel.get]
+
+ external render_empty_state : t -> Jsx.element S.accessor option
+ = "renderEmptyState"
+ [@@mel.get]
+
+ external children : t -> Jsx.element = "children" [@@mel.get]
+
+ external ref : t -> ((Dom.htmlDivElement -> unit)[@u]) option = "ref"
+ [@@mel.get]
+
+ external on_key_down : t -> ((Dom.keyboardEvent -> unit)[@u]) option
+ = "onKeyDown"
+ [@@mel.get]
+
+ external on_mouse_down : t -> ((Dom.mouseEvent -> unit)[@u]) option
+ = "onMouseDown"
+ [@@mel.get]
+
+ external on_focus_in : t -> ((Dom.focusEvent -> unit)[@u]) option
+ = "onFocusIn"
+ [@@mel.get]
+
+ external on_focus_out : t -> ((Dom.focusEvent -> unit)[@u]) option
+ = "onFocusOut"
+ [@@mel.get]
+end
+
+(* The props the list takes for itself; the rest it passes on. *)
+let own =
+ [|
+ "selectionMode";
+ "selectionBehavior";
+ "selectedKeys";
+ "defaultSelectedKeys";
+ "onSelectionChange";
+ "disabledKeys";
+ "disallowEmptySelection";
+ "onAction";
+ "renderEmptyState";
+ "children";
+ "ref";
+ "onKeyDown";
+ "onMouseDown";
+ "onFocusIn";
+ "onFocusOut";
+ |]
+
+let make (props : Props.t) =
+ let selection_mode =
+ S.accessor (fun () ->
+ Option.value (Props.selection_mode props) ~default:`none)
+ in
+ let disabled_key k =
+ match Props.disabled_keys props with
+ | Some keys -> Array.exists (String.equal k) keys
+ | None -> false
+ in
+ (* Its items, read off its children in order once they are made. *)
+ let items, set_items = S.create_signal [||] in
+ let keys =
+ S.create_memo (fun () -> Array.map (fun t -> S.get t.key) (S.get items))
+ in
+ let find k =
+ Array.find_opt (fun t -> String.equal (S.get t.key) k) (S.get items)
+ in
+ let state =
+ Selection.create_list_state
+ (Types.CreateListStateProps.make ~data_source:(Either.right keys)
+ ~get_key:(Either.left Fun.id)
+ ~get_text_value:
+ (Either.left (fun k ->
+ match find k with Some t -> S.get t.text | None -> ""))
+ ~get_disabled:
+ (Either.left (fun k ->
+ disabled_key k
+ ||
+ match find k with
+ | Some t -> S.get t.disabled
+ | None -> false))
+ ~selection_mode:
+ (Either.right
+ (S.create_memo (fun () -> Some (S.get selection_mode))))
+ ~selection_behavior:
+ (Either.right
+ (S.create_memo (fun () ->
+ Some
+ (Option.value
+ (Props.selection_behavior props)
+ ~default:`toggle))))
+ ~disallow_empty_selection:
+ (Either.right
+ (S.create_memo (fun () -> Props.disallow_empty_selection props)))
+ ~selected_keys:
+ (Either.right (S.create_memo (fun () -> Props.selected_keys props)))
+ ?default_selected_keys:
+ (Option.map Either.left
+ (S.untrack (fun () -> Props.default_selected_keys props)))
+ ~on_selection_change:(fun keys ->
+ Jsx.call (Props.on_selection_change props) (Js.Set.toArray keys))
+ ())
+ in
+ let manager =
+ S.create_memo (fun () ->
+ Types.SelectionManager.to_multiple_selection_manager
+ (S.get (List_state.selection_manager state)))
+ in
+ let collator =
+ I18n.create_collator
+ ~options:(Types.CollatorOptions.make ~usage:`search ~sensitivity:`base ())
+ ()
+ in
+ let keyboard = S.create_memo (fun () -> Some (delegate ~items ~collator)) in
+ let list_element, set_list = S.create_signal None in
+ let list =
+ Selection.create_selectable_list
+ (Types.CreateSelectableListProps.make
+ ~collection:(List_state.collection state)
+ ~selection_manager:(Either.right manager)
+ ~keyboard_delegate:(Either.right keyboard) ())
+ list_element ()
+ in
+ let g =
+ {
+ manager;
+ selection_mode;
+ disabled_key;
+ on_action =
+ S.accessor (fun () ->
+ Option.map (fun f k -> (f k [@u])) (Props.on_action props));
+ is_empty = S.accessor (fun () -> Array.length (S.get items) = 0);
+ }
+ in
+ (* Its rows: every item's, or, inside a virtualizer, those in view of what
+ scrolls the list and the focused one wherever it is. *)
+ let rows () =
+ match Virtualizer.Context.use () with
+ | Some (List l) ->
+ let size = Option.value l.row_size ~default:48. in
+ let w =
+ Virtualizer.window l
+ ~rows:(fun () -> S.get items)
+ ~fixed:(fun _ -> Some size)
+ ~estimate:(fun _ -> size)
+ ~keep:(fun (e : listed) ->
+ match S.get (Manager.focused_key (S.get manager)) with
+ | Some k -> String.equal k (S.get e.key)
+ | None -> false)
+ in
+
+ | Some (Table _) | None ->
+ (fun (e : listed) _ -> e.draw ())
+ in
+
+ ((* Its items are read before its element is made, so it is drawn
+ holding them, on the server as in the browser. *)
+ let resolved = S.children (fun () -> Props.children props) in
+ S.create_computed (fun () ->
+ S.set set_items (Entry.read (S.to_array (S.get resolved))));
+
+ S.set set_list (Some e);
+ Jsx.call (Props.ref props) e)
+ ?aria_multiselectable=(match S.get selection_mode with
+ | `multiple -> Some true
+ | `single | `none -> None)
+ tabindex=(match S.get (Selectable_list.tab_index list) with
+ | Some i -> Js.Float.toString i
+ | None -> "-1")
+ data_empty=(marked (S.get g.is_empty))
+ on_key_down=(fun e ->
+ Jsx.call (Props.on_key_down props) e;
+ Selectable_list.on_key_down list e)
+ on_mouse_down=(fun e ->
+ Jsx.call (Props.on_mouse_down props) e;
+ Selectable_list.on_mouse_down list e)
+ on_focus_in=(fun e ->
+ Jsx.call (Props.on_focus_in props) e;
+ Selectable_list.on_focus_in list e)
+ on_focus_out=(fun e ->
+ Jsx.call (Props.on_focus_out props) e;
+ Selectable_list.on_focus_out list e)
+ ?as_=(S.drawn_as props)
+ props=(S.undrawn (S.omit props own))>
+ (rows ())
+ (match Props.render_empty_state props with
+ | Some draw when S.get g.is_empty ->
+
+
(S.get draw)
+
+ | Some _ | None -> Jsx.string "")
+
)
+
+
+let component = Jsx.component make
+
+module Item = struct
+ module Context = struct
+ let use () =
+ match Item_context.use () with
+ | Some i -> i
+ | None ->
+ invalid_arg
+ "Grid_list.Item.Context.use is used inside a Grid_list.Item"
+ end
+
+ module Props = struct
+ type t
+
+ external check :
+ ?id:string Solidtype.Check.value ->
+ ?text_value:string Solidtype.Check.value ->
+ ?is_disabled:bool Solidtype.Check.value ->
+ ?href:string Solidtype.Check.value ->
+ ?as_:(Solidtype.Html.Div.props -> Solidtype.Jsx.element) ->
+ ?props:'spread Solidtype.Solid.rest ->
+ (?children:('f, [ `elements ]) Solidtype.Check.children -> unit -> unit)
+ Solidtype.Html.Div.check = "check"
+ [@@mel.module "vite-plugin-solidtype/markers"]
+
+ external id : t -> string option = "id" [@@mel.get]
+ external text_value : t -> string option = "textValue" [@@mel.get]
+ external is_disabled : t -> bool option = "isDisabled" [@@mel.get]
+ external href : t -> string option = "href" [@@mel.get]
+ external children : t -> Jsx.element = "children" [@@mel.get]
+
+ external ref : t -> ((Dom.htmlDivElement -> unit)[@u]) option = "ref"
+ [@@mel.get]
+
+ external on_pointer_down : t -> ((Dom.pointerEvent -> unit)[@u]) option
+ = "onPointerDown"
+ [@@mel.get]
+
+ external on_pointer_up : t -> ((Dom.pointerEvent -> unit)[@u]) option
+ = "onPointerUp"
+ [@@mel.get]
+
+ external on_click : t -> ((Dom.mouseEvent -> unit)[@u]) option = "onClick"
+ [@@mel.get]
+
+ external on_key_down : t -> ((Dom.keyboardEvent -> unit)[@u]) option
+ = "onKeyDown"
+ [@@mel.get]
+
+ external on_key_up : t -> ((Dom.keyboardEvent -> unit)[@u]) option
+ = "onKeyUp"
+ [@@mel.get]
+
+ external on_mouse_down : t -> ((Dom.mouseEvent -> unit)[@u]) option
+ = "onMouseDown"
+ [@@mel.get]
+
+ external on_focus : t -> ((Dom.focusEvent -> unit)[@u]) option = "onFocus"
+ [@@mel.get]
+
+ external on_focus_in : t -> ((Dom.focusEvent -> unit)[@u]) option
+ = "onFocusIn"
+ [@@mel.get]
+ end
+
+ let own =
+ [|
+ "id";
+ "textValue";
+ "isDisabled";
+ "href";
+ "children";
+ "ref";
+ "onPointerDown";
+ "onPointerUp";
+ "onClick";
+ "onKeyDown";
+ "onKeyUp";
+ "onMouseDown";
+ "onFocus";
+ "onFocusIn";
+ |]
+
+ (* What a reader is told an item is where it is given no name: the first
+ text among its children. *)
+ let first_text children =
+ Array.fold_left
+ (fun found child ->
+ match found with
+ | Some _ -> found
+ | None -> (
+ match Js.Types.classify child with
+ | JSString s when String.length (String.trim s) > 0 -> Some s
+ | _ -> None))
+ None children
+
+ let make (props : Props.t) =
+ let g = in_group "Grid_list.Item" in
+ let given_key = S.create_unique_id () in
+ let key =
+ S.create_memo (fun () -> Option.value (Props.id props) ~default:given_key)
+ in
+ let disabled =
+ S.accessor (fun () ->
+ Option.value (Props.is_disabled props) ~default:false
+ || g.disabled_key (S.get key))
+ in
+ let m () = S.get g.manager in
+ let selected =
+ S.accessor (fun () -> Manager.is_selected (m ()) (S.get key))
+ in
+ let allows_selection =
+ S.accessor (fun () ->
+ (match S.get g.selection_mode with
+ | `none -> false
+ | `single | `multiple -> true)
+ && not (S.get disabled))
+ in
+ let s =
+ {
+ key;
+ is_selected = selected;
+ is_disabled = disabled;
+ allows_selection;
+ selection_mode = g.selection_mode;
+ toggle_selection =
+ (fun () ->
+ if S.get allows_selection then
+ Manager.toggle_selection (m ()) (S.get key));
+ }
+ in
+ (* Its name: [text_value], or the first text among its children once its
+ row is drawn. *)
+ let drawn_text, set_drawn_text = S.create_signal None in
+ let text =
+ S.accessor (fun () ->
+ match Props.text_value props with
+ | Some t -> t
+ | None -> Option.value (S.get drawn_text) ~default:"")
+ in
+ (* Its row, drawn where the list draws it, with Kobalte's item hooks of
+ its own each time. Its children are made only then, inside it, so a
+ part among them reads the item it is in, and a row a virtualizer never
+ draws makes none, on the server or as the page hydrates. *)
+ let draw () =
+ let resolved =
+ S.children (fun () ->
+
+ (Props.children props)
+ )
+ in
+ S.create_computed (fun () ->
+ S.set set_drawn_text (first_text (S.to_array (S.get resolved))));
+ let element, set_element = S.create_signal None in
+ let item =
+ Selection.create_selectable_item
+ (Types.CreateSelectableItemProps.make
+ ~selection_manager:(Either.right g.manager) ~key:(Either.right key)
+ ~disabled:
+ (Either.right (S.create_memo (fun () -> Some (S.get disabled))))
+ ())
+ element
+ in
+ (* An item's action: the list's, or its link; which a press runs and
+ which selection gives way to, as React Aria's grid list decides. *)
+ let allows_actions () =
+ (Option.is_some (S.get g.on_action) || Option.is_some (Props.href props))
+ && not (S.get disabled)
+ in
+ let replaces () =
+ match S.get (Manager.selection_behavior (m ())) with
+ | `replace -> true
+ | `toggle -> false
+ in
+ let primary () =
+ allows_actions ()
+ &&
+ if replaces () then not (S.get allows_selection)
+ else (not (S.get allows_selection)) || S.get (Manager.is_empty (m ()))
+ in
+ let secondary () =
+ allows_actions () && S.get allows_selection && replaces ()
+ in
+ let act e =
+ Option.iter (fun f -> f (S.get key)) (S.get g.on_action);
+ match (Props.href props, S.get element) with
+ | Some href, Some row -> open_link row href e
+ | Some _, None | None, (Some _ | None) -> ()
+ in
+ let pointer = ref "mouse" in
+ let primary_at_down = ref false in
+ let enter_down = ref false in
+ let own_press row target = not (in_control row target) in
+
+
+ S.set set_element (Some e);
+ Jsx.call (Props.ref props) e)
+ tabindex=(if S.get disabled then "-1"
+ else
+ match S.get (Manager.focused_key (m ())) with
+ | Some k when String.equal k (S.get key) -> "0"
+ | Some _ | None -> "-1")
+ aria_label=(S.get text)
+ ?aria_selected=(if S.get allows_selection then Some (S.get selected)
+ else None)
+ ?aria_disabled=(if S.get disabled then Some true else None)
+ data_key=(Jsx.data (S.get key))
+ data_selected=(marked (S.get selected))
+ data_disabled=(marked (S.get disabled))
+ on_pointer_down=(fun e ->
+ Jsx.call (Props.on_pointer_down props) e;
+ if own_press (pointer_current e) (pointer_target e)
+ then begin
+ pointer := pointer_type e;
+ primary_at_down := primary ();
+ if
+ not
+ (String.equal !pointer "mouse"
+ && !primary_at_down)
+ then Selectable_item.on_pointer_down item e
+ end)
+ on_pointer_up=(fun e ->
+ Jsx.call (Props.on_pointer_up props) e;
+ if own_press (pointer_current e) (pointer_target e)
+ then Selectable_item.on_pointer_up item e)
+ on_click=(fun e ->
+ Jsx.call (Props.on_click props) e;
+ if own_press (mouse_current e) (mouse_target e) then
+ if String.equal !pointer "mouse" then
+ if !primary_at_down then act e
+ else Selectable_item.on_click item e
+ else if primary () || secondary () then act e
+ else Selectable_item.on_click item e)
+ on_key_down=(fun e ->
+ Jsx.call (Props.on_key_down props) e;
+ let row = key_current e in
+ if key_target e != row then
+ (* A key in a control inside the item is the
+ control's, the arrows across it moving back to the
+ item from its first. *)
+ begin match pressed e with
+ | "ArrowLeft" -> (
+ let inside =
+ Js.Array.from (query_all row focusable)
+ in
+ match
+ Js.Array.findIndex
+ ~f:(fun c -> c == key_target e)
+ inside
+ with
+ | 0 ->
+ prevent e;
+ stop e;
+ focus row
+ | -1 -> stop e
+ | at ->
+ prevent e;
+ stop e;
+ focus inside.(at - 1))
+ | "ArrowRight" -> (
+ let inside =
+ Js.Array.from (query_all row focusable)
+ in
+ match
+ Js.Array.findIndex
+ ~f:(fun c -> c == key_target e)
+ inside
+ with
+ | at when at >= 0 && at + 1 < Array.length inside
+ ->
+ prevent e;
+ stop e;
+ focus inside.(at + 1)
+ | _ -> stop e)
+ | "ArrowUp" | "ArrowDown" -> ()
+ | _ -> stop e
+ end
+ else
+ match pressed e with
+ | "ArrowRight" -> (
+ prevent e;
+ stop e;
+ match Js.Array.from (query_all row focusable) with
+ | [||] -> ()
+ | inside -> focus inside.(0))
+ | "ArrowLeft" ->
+ prevent e;
+ stop e
+ | "Enter" when allows_actions () ->
+ prevent e;
+ enter_down := primary () || secondary ();
+ if not !enter_down then
+ Selectable_item.on_key_down item e
+ | _ -> Selectable_item.on_key_down item e)
+ on_key_up=(fun e ->
+ Jsx.call (Props.on_key_up props) e;
+ if String.equal (pressed e) "Enter" && !enter_down then begin
+ enter_down := false;
+ act e
+ end)
+ on_mouse_down=(fun e ->
+ Jsx.call (Props.on_mouse_down props) e;
+ Selectable_item.on_mouse_down item e)
+ on_focus=(fun e ->
+ Jsx.call (Props.on_focus props) e;
+ Selectable_item.on_focus item e)
+ on_focus_in=(fun e ->
+ Jsx.call (Props.on_focus_in props) e;
+ (* The focus on a control inside an item is the item's,
+ so the keys start from it. *)
+ if
+ focus_target e != focus_current e
+ && not (S.get disabled)
+ then Manager.set_focused_key (m ()) ~key:(S.get key) ())
+ ?as_=(S.drawn_as props)
+ props=(S.undrawn (S.omit props own))>
+
+ (Jsx.fragment (S.to_array (S.get resolved)))
+
+
+
+ in
+ Entry.element { key; disabled; text; draw }
+
+ let component = Jsx.component make
+end
diff --git a/headless/table.mlx b/headless/table.mlx
index f7edad2..c01ea78 100644
--- a/headless/table.mlx
+++ b/headless/table.mlx
@@ -50,14 +50,28 @@ external event_target : _ Dom.event_like -> Dom.element = "target" [@@mel.get]
external prevent_default : Dom.keyboardEvent -> unit = "preventDefault"
[@@mel.send]
-(* Whether an event began in a control inside a row, whose press is its own,
- as a pressable element inside React Aria's row keeps its press. *)
+(* What takes a press of its own: an element that is a control, one whose
+ role is a widget's, and a group of controls, as a field's group and an
+ autocomplete's trigger are, whose press anywhere is the field's. *)
+let control =
+ "input, button, select, textarea, a[href], label, [contenteditable], \
+ [role=button], [role=checkbox], [role=radio], [role=switch], [role=slider], \
+ [role=spinbutton], [role=textbox], [role=searchbox], [role=combobox], \
+ [role=link], [role=tab], [role=option], [role=menuitem], \
+ [role=menuitemcheckbox], [role=menuitemradio], [role=group]"
+
+(* Whether an event began in a control inside a cell, whose press is its
+ own, as a pressable element inside React Aria's row keeps its press: never
+ one around the table, which holds every cell. *)
let in_control e =
- Js.Null.toOption
- (closest (event_target e)
- "input, button, select, textarea, a[href], label, [role=checkbox], \
- [role=button]")
- <> None
+ let target = event_target e in
+ match
+ ( Js.Null.toOption
+ (closest target "[role=gridcell], [role=rowheader], [role=columnheader]"),
+ Js.Null.toOption (closest target control) )
+ with
+ | Some cell, Some c -> c != cell && contains cell c
+ | Some _, None | None, _ -> false
external prevent : _ Dom.event_like -> unit = "preventDefault" [@@mel.send]
external pointer_type : Dom.pointerEvent -> string = "pointerType" [@@mel.get]
@@ -2103,6 +2117,12 @@ module Root = struct
(Props.children props)
in
+ (* Its header and body are made before the grid, so the columns and rows
+ they hold are known as the grid's counts are written: the server
+ writes them once, and hydration keeps what it wrote. *)
+ let drawn =
+ (content ())
+ in
- (content ())
+ drawn
diff --git a/headless/toolbar.mli b/headless/toolbar.mli
new file mode 100644
index 0000000..74ac289
--- /dev/null
+++ b/headless/toolbar.mli
@@ -0,0 +1,37 @@
+(** A toolbar, as React Aria's: a [
] around controls, which
+ the arrow keys of its [orientation] move between, the page's direction read
+ for the horizontal ones, never past either end. Tab takes the focus out of
+ it, and coming back gives it to the control that had it. Inside another
+ toolbar it is a [group], whose keys are the outer one's, as a toggle group
+ in a toolbar is.
+
+ {[
+
+
+
+ ]} *)
+
+module S := Solidtype.Solid
+module Jsx := Solidtype.Jsx
+
+type state = { orientation : [ `horizontal | `vertical ] S.accessor }
+(** What its children are drawn of, given as a function. *)
+
+module Props : sig
+ type t
+
+ val check :
+ ?orientation:[ `horizontal | `vertical ] Solidtype.Check.value ->
+ ?aria_label:string Solidtype.Check.value ->
+ ?aria_labelledby:string Solidtype.Check.value ->
+ ?ref:(Dom.htmlDivElement -> unit) ->
+ ?on_key_down:(Dom.keyboardEvent -> unit) ->
+ children:
+ (state -> Jsx.element, [ `elements | `render ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> state -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+end
+
+val make : Props.t -> Jsx.element
+val component : Props.t Jsx.component
diff --git a/headless/toolbar.mlx b/headless/toolbar.mlx
new file mode 100644
index 0000000..b4f903e
--- /dev/null
+++ b/headless/toolbar.mlx
@@ -0,0 +1,134 @@
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module I18n = Solidtype_kobalte.I18n
+module Types = Solidtype_kobalte.Types
+
+external closest : Dom.element -> string -> Dom.element Js.null = "closest"
+[@@mel.send]
+
+external parent : Dom.element -> Dom.element Js.null = "parentElement"
+[@@mel.get]
+
+external query_all : Dom.element -> string -> Dom.element Js.Array.array_like
+ = "querySelectorAll"
+[@@mel.send]
+
+external contains : Dom.element -> Dom.element -> bool = "contains" [@@mel.send]
+external focus : Dom.element -> unit = "focus" [@@mel.send]
+external key : Dom.keyboardEvent -> string = "key" [@@mel.get]
+external key_target : Dom.keyboardEvent -> Dom.element = "target" [@@mel.get]
+external handled : Dom.keyboardEvent -> bool = "defaultPrevented" [@@mel.get]
+
+external prevent_default : Dom.keyboardEvent -> unit = "preventDefault"
+[@@mel.send]
+
+type style
+
+external computed : Dom.element -> style = "getComputedStyle"
+[@@mel.scope "window"]
+
+external display : style -> string = "display" [@@mel.get]
+external visibility : style -> string = "visibility" [@@mel.get]
+external as_element : _ Dom.element_like -> Dom.element = "%identity"
+(* A toolbar's element, of whichever kind it is drawn as, is an element. *)
+
+(* A stop of the toolbar: what Tab reaches inside it. A group of its own
+ keys, Kobalte's toggle group, is one stop, as it gives Tab one. *)
+let stop =
+ "input:not([disabled]):not([type=hidden]):not([tabindex=\"-1\"]), \
+ select:not([disabled]):not([tabindex=\"-1\"]), \
+ textarea:not([disabled]):not([tabindex=\"-1\"]), \
+ button:not([disabled]):not([tabindex=\"-1\"]), \
+ a[href]:not([tabindex=\"-1\"]), [tabindex]:not([tabindex=\"-1\"])"
+
+(* Whether an element and everything between it and the toolbar is drawn. *)
+let shown root e =
+ let rec up e =
+ let s = computed e in
+ (not (String.equal (display s) "none"))
+ && (not (String.equal (visibility s) "hidden"))
+ && (e == root
+ || match Js.Null.toOption (parent e) with Some p -> up p | None -> true)
+ in
+ up e
+
+type state = { orientation : [ `horizontal | `vertical ] S.accessor }
+
+let%component make ?(orientation : [ `horizontal | `vertical ] = `horizontal)
+ ?(aria_label : string option) ?(aria_labelledby : string option)
+ ?ref:(given_ref : (Dom.htmlDivElement -> unit) option)
+ ?(on_key_down : (Dom.keyboardEvent -> unit) option)
+ ~(children : state Jsx.children)
+ ?(as_ : (Solidtype.Html.Div.props -> state -> Solidtype.Jsx.element) option)
+ () =
+ let element = ref None in
+ let nested, set_nested = S.create_signal false in
+ let locale = I18n.use_locale () in
+ S.on_mount (fun () ->
+ Option.iter
+ (fun e ->
+ S.set set_nested
+ (match Js.Null.toOption (parent e) with
+ | Some p ->
+ Option.is_some (Js.Null.toOption (closest p "[role=toolbar]"))
+ | None -> false))
+ !element);
+ (* The arrows of its orientation move between its stops, never past either
+ end; an arrow a control inside has handled, a group moving among its own
+ items, is that control's. *)
+ let move root e =
+ let forward, backward =
+ match S.get orientation with
+ | `horizontal -> (
+ match Types.I18n_UseLocale.direction locale () with
+ | `rtl -> ("ArrowLeft", "ArrowRight")
+ | `ltr -> ("ArrowRight", "ArrowLeft"))
+ | `vertical -> ("ArrowDown", "ArrowUp")
+ in
+ let step =
+ let k = key e in
+ if String.equal k forward then Some 1
+ else if String.equal k backward then Some (-1)
+ else None
+ in
+ match step with
+ | Some step when not (handled e) -> (
+ let all =
+ Js.Array.from (query_all root stop) |> Js.Array.filter ~f:(shown root)
+ in
+ let target = key_target e in
+ match
+ Js.Array.findIndex ~f:(fun c -> c == target || contains c target) all
+ with
+ | -1 -> ()
+ | at ->
+ let next = at + step in
+ if next >= 0 && next < Array.length all then begin
+ prevent_default e;
+ focus all.(next)
+ end)
+ | Some _ | None -> ()
+ in
+ let state = { orientation } in
+
"horizontal"
+ | `vertical -> "vertical"))
+ ref=(fun e ->
+ element := Some (as_element e);
+ ignore (given_ref e : unit option))
+ on_key_down=(fun e ->
+ ignore (on_key_down e : unit option);
+ match !element with
+ | Some root when not (S.get nested) -> move root e
+ | Some _ | None -> ())
+ ?as_=(Option.map (fun f p -> f p state) (S.get as_))
+ props=(Props.others props)>
+ (Jsx.draw (S.get children) state)
+
+[@@element div]
diff --git a/heroui/action-bar.css b/heroui/action-bar.css
new file mode 100644
index 0000000..d74c7e7
--- /dev/null
+++ b/heroui/action-bar.css
@@ -0,0 +1,42 @@
+/* Action_bar, in HeroUI's look, which ships no stylesheet for it: Tailwind on
+ HeroUI's tokens, written as HeroUI writes its components' CSS, so an
+ application restyles a part by a rule for its class. */
+
+/* At the foot of the page, centred, letting presses through but on its bar. */
+.action-bar {
+ @apply pointer-events-none fixed inset-x-0 bottom-6 z-50 flex justify-center;
+
+ & [data-slot="toolbar"] {
+ @apply rounded-[calc(var(--radius)*3)];
+ }
+
+ &[data-entering] {
+ @apply animate-in duration-300 ease-out fade-in-0 slide-in-from-bottom-2;
+ }
+
+ &[data-exiting] {
+ @apply animate-out duration-300 ease-out fade-out-0 slide-out-to-bottom-2;
+ }
+}
+
+.action-bar__wrapper {
+ @apply pointer-events-auto px-2 py-1 shadow-overlay sm:px-3 sm:py-1.5;
+}
+
+.action-bar__prefix {
+ @apply flex items-center gap-1.5 sm:gap-2.5;
+}
+
+.action-bar__content {
+ @apply flex items-center gap-1;
+}
+
+.action-bar__suffix {
+ @apply flex items-center;
+}
+
+/* Read, and shown from 640 pixels on, where a button has room for its
+ words. */
+.action-bar__label {
+ @apply sr-only text-sm font-medium sm:not-sr-only;
+}
diff --git a/heroui/action_bar.mli b/heroui/action_bar.mli
new file mode 100644
index 0000000..b347225
--- /dev/null
+++ b/heroui/action_bar.mli
@@ -0,0 +1,107 @@
+(** An action bar, in HeroUI's look, which ships no stylesheet for it: a
+ {!Toolbar} that floats at the foot of the page, centred, while [is_open],
+ for what can be done with what is chosen -- rows of a {!Data_grid} or a
+ {!List_view} -- sliding in and out as it opens and closes. Its look is a
+ stylesheet, [action-bar.css], in the [components] layer, rules for its
+ classes.
+
+ Its page, with its examples:
+ [$(opam var solidtype:doc)/pages/heroui/action-bar.md].
+
+ {[
+ 0)>
+ (count)
+
+
+
+
+
+ (clear)
+
+ ]}
+
+ Its keys are its toolbar's. Text of the class [action-bar__label] is read
+ but not shown below 640 pixels, so a button there shows its icon alone. *)
+
+module S := Solidtype.Solid
+module Jsx := Solidtype.Jsx
+
+(** What leads the bar, a count of what is chosen: a
+ [
]. *)
+module Prefix : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?class_:string Solidtype.Check.value ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+(** Its actions: a [
]. *)
+module Content : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?class_:string Solidtype.Check.value ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+(** What ends the bar, a button that clears what is chosen: a
+ [
]. *)
+module Suffix : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?class_:string Solidtype.Check.value ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+module Props : sig
+ type t
+
+ val check :
+ is_open:bool Solidtype.Check.value ->
+ ?aria_label:string Solidtype.Check.value ->
+ ?is_attached:bool Solidtype.Check.value ->
+ ?orientation:[ `horizontal | `vertical ] Solidtype.Check.value ->
+ ?class_:string Solidtype.Check.value ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+end
+
+val make : Props.t -> Jsx.element
+(** The bar: a [
] fixed at the foot of the page,
+ [data-entering] and [data-exiting] while it slides, around its {!Toolbar},
+ [
], named [aria_label],
+ ["Actions"] by default, attached unless [is_attached] is [false], which
+ takes the rest of its props. *)
+
+val component : Props.t Jsx.component
diff --git a/heroui/action_bar.mlx b/heroui/action_bar.mlx
new file mode 100644
index 0000000..c605c12
--- /dev/null
+++ b/heroui/action_bar.mlx
@@ -0,0 +1,62 @@
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module Show = Solidtype.Show
+
+let after own = function Some c -> own ^ " " ^ c | None -> own
+
+module Prefix = struct
+ let%component make ?(class_ : string option) ~(children : Jsx.element) () =
+
+
+[@@element div]
diff --git a/heroui/autocomplete.mlx b/heroui/autocomplete.mlx
index 259a6b6..4858f44 100644
--- a/heroui/autocomplete.mlx
+++ b/heroui/autocomplete.mlx
@@ -93,6 +93,29 @@ external prevent_default_event : Dom.event -> unit = "preventDefault"
[@@mel.send]
external contains : Dom.element -> Dom.element -> bool = "contains" [@@mel.send]
+external click_target : Dom.mouseEvent -> Dom.element = "target" [@@mel.get]
+
+external closest : Dom.element -> string -> Dom.element Js.null = "closest"
+[@@mel.send]
+
+(* Whether a click inside the trigger landed on a control of its own, a tag's
+ remove button in its value among them, whose press is the control's: never
+ the trigger's indicator, whose press is the trigger's. *)
+let in_own_control (indicator : Dom.element option) trigger e =
+ match
+ Js.Null.toOption
+ (closest (click_target e)
+ "button, a[href], input, select, textarea, [role=button], \
+ [role=checkbox], [role=switch], [role=link]")
+ with
+ | Some c ->
+ (* The click reached the trigger, so the control was inside it as it
+ landed, though its own handler may have taken it off the page since:
+ only one around the trigger is not its own. *)
+ (not (contains c trigger))
+ && not (match indicator with Some i -> i == c | None -> false)
+ | None -> false
+
external active : Dom.element Js.null = "activeElement" [@@mel.scope "document"]
external body : Dom.element = "body" [@@mel.scope "document"]
@@ -115,6 +138,7 @@ module Trigger = struct
=
let a = within "Autocomplete.Trigger" in
let i = Interaction.create ~disabled:(fun () -> S.get a.disabled) () in
+ let element = ref None in
(* A press anywhere on it opens or closes the list, as HeroUI's does. *)
let state () =
{
@@ -129,13 +153,17 @@ module Trigger = struct
role=`group
ref=(fun e ->
ignore (given_ref e : unit option);
+ element := Some (as_element e);
Interaction.watch i e)
class_=(after
(Styles.Autocomplete.trigger (S.get a.slots))
(S.get class_))
on_click=(fun e ->
ignore (on_click e : unit option);
- if not (S.get a.disabled) then a.toggle ())
+ match !element with
+ | Some trigger when in_own_control !(a.indicator) trigger e ->
+ ()
+ | Some _ | None -> if not (S.get a.disabled) then a.toggle ())
data_slot="autocomplete-trigger"
data_hovered=(Jsx.flag (Interaction.hovered i))
data_focus_within=(Jsx.flag (Interaction.focused i))
diff --git a/heroui/button_group.mli b/heroui/button_group.mli
index 369b5a4..0705dca 100644
--- a/heroui/button_group.mli
+++ b/heroui/button_group.mli
@@ -72,6 +72,24 @@ module Separator : sig
val component : Props.t Jsx.component
end
+(** The orientation a part above gives a group inside it that gives none, as a
+ {!Toolbar} gives its own. *)
+module Orientation : sig
+ module Provider : sig
+ module Props : sig
+ val check :
+ value:[ `horizontal | `vertical ] S.accessor Solidtype.Check.value ->
+ ?children:('f, [ `elements ]) Solidtype.Check.children ->
+ unit ->
+ unit
+ end
+
+ val component : unit Jsx.component
+ end
+
+ val use : unit -> [ `horizontal | `vertical ] S.accessor option
+end
+
module Props : sig
type t
diff --git a/heroui/button_group.mlx b/heroui/button_group.mlx
index 3cf7a98..3d099f6 100644
--- a/heroui/button_group.mlx
+++ b/heroui/button_group.mlx
@@ -17,6 +17,12 @@ type group = {
full_width : bool option S.accessor;
}
+(* The orientation a part above gives a group inside it that gives none: a
+ toolbar's own, as React's toolbar turns its button groups. *)
+module Orientation = Solidtype.Context.Make_optional (struct
+ type t = [ `horizontal | `vertical ] S.accessor
+end)
+
module Context = Solidtype.Context.Make_optional (struct
type t = group
end)
@@ -48,9 +54,17 @@ let%component make
| `danger
| `danger_soft ]
option) ?(size : [ `sm | `md | `lg ] option)
- ?(orientation : [ `horizontal | `vertical ] = `horizontal)
+ ?(orientation : [ `horizontal | `vertical ] option)
?(full_width : bool option) ?(is_disabled : bool option)
?(class_ : string option) ~(children : Jsx.element) () =
+ let around = Orientation.use () in
+ let orientation =
+ S.accessor (fun () ->
+ match (S.get orientation, around) with
+ | Some o, _ -> o
+ | None, Some o -> S.get o
+ | None, None -> `horizontal)
+ in
let g = { variant; size; is_disabled; full_width } in
let disabled () = Option.value (S.get is_disabled) ~default:false in
diff --git a/heroui/checkbox_group.mlx b/heroui/checkbox_group.mlx
index df71b75..afe32f6 100644
--- a/heroui/checkbox_group.mlx
+++ b/heroui/checkbox_group.mlx
@@ -1,5 +1,6 @@
module S = Solidtype.Solid
module Jsx = Solidtype.Jsx
+module Show = Solidtype.Show
type group = {
checked : string -> bool;
@@ -22,8 +23,8 @@ let named () =
let id = S.create_unique_id () in
let count, set_count = S.create_signal 0 in
let here () =
- S.set set_count (S.get count + 1);
- S.on_cleanup (fun () -> S.set set_count (S.get count - 1))
+ S.update set_count (fun n -> n + 1);
+ S.on_cleanup (fun () -> S.update set_count (fun n -> n - 1))
in
(id, here, S.accessor (fun () -> if S.get count > 0 then Some id else None))
@@ -76,7 +77,14 @@ let%component make ?(variant : [ `primary | `secondary ] option)
choose (if on then others @ [ v ] else others)
in
let label_id, label_here, labelled_by = named () in
- let description_id, description_here, described_by = named () in
+ let description_id, description_here, description_shown = named () in
+ let error_id, error_here, error_shown = named () in
+ let described_by =
+ S.accessor (fun () ->
+ match List.filter_map S.get [ description_shown; error_shown ] with
+ | [] -> None
+ | ids -> Some (String.concat " " ids))
+ in
(* A label in a group, but outside a checkbox's content, is a span that
names the group, as React Aria's is; and a description one that
describes it, and each checkbox's input. *)
@@ -99,6 +107,23 @@ let%component make ?(variant : [ `primary | `secondary ] option)
(children ())
in
+ (* An error in a group, shown while it is invalid, which describes it and
+ each checkbox in it after its description. *)
+ let error : Field_error.slot =
+ fun classes others children ->
+
+ (error_here ();
+
+ (children ())
+ )
+
+ in
let g =
{
checked;
@@ -117,44 +142,46 @@ let%component make ?(variant : [ `primary | `secondary ] option)
- (let state =
- {
- is_disabled = disabled;
- is_read_only;
- is_required;
- is_invalid = invalid;
- }
- in
- let resolved =
- S.children (fun () -> Jsx.draw (S.get children) state)
- in
-
- ignore (given_ref e : unit option);
- in_form.root e)
- on_focus_out=(fun e ->
- ignore (on_focus_out e : unit option);
- Field.on_leave
- (fun e ->
- in_form.left ();
- on_blur e)
- e)
- data_slot="checkbox-group"
- data_disabled=(Jsx.flag (S.get disabled))
- data_invalid=(Jsx.flag (S.get invalid))
- data_readonly=(Jsx.flag (S.get is_read_only))
- data_required=(Jsx.flag (S.get is_required))
- ?as_=(Option.map (fun f p -> f p state) (S.get as_))
- props=(Props.others props)>
- (Jsx.fragment (S.to_array (S.get resolved)))
-
)
+
+ (let state =
+ {
+ is_disabled = disabled;
+ is_read_only;
+ is_required;
+ is_invalid = invalid;
+ }
+ in
+ let resolved =
+ S.children (fun () -> Jsx.draw (S.get children) state)
+ in
+
+ ignore (given_ref e : unit option);
+ in_form.root e)
+ on_focus_out=(fun e ->
+ ignore (on_focus_out e : unit option);
+ Field.on_leave
+ (fun e ->
+ in_form.left ();
+ on_blur e)
+ e)
+ data_slot="checkbox-group"
+ data_disabled=(Jsx.flag (S.get disabled))
+ data_invalid=(Jsx.flag (S.get invalid))
+ data_readonly=(Jsx.flag (S.get is_read_only))
+ data_required=(Jsx.flag (S.get is_required))
+ ?as_=(Option.map (fun f p -> f p state) (S.get as_))
+ props=(Props.others props)>
+ (Jsx.fragment (S.to_array (S.get resolved)))
+
)
+
diff --git a/heroui/data_grid.mlx b/heroui/data_grid.mlx
index 1af04a7..c1f8a77 100644
--- a/heroui/data_grid.mlx
+++ b/heroui/data_grid.mlx
@@ -115,6 +115,12 @@ let drag_handle () =
+(* The widths of the grid's own columns where a layout places them, as a
+ virtualized or resizable grid's does; where the browser lays the table
+ out, its stylesheet's variables, of the same widths, set them. *)
+let selection_width = 40.
+let drag_handle_width = 32.
+
let selection_checkbox ~aria_label ~variant =
@@ -267,7 +273,10 @@ let%component make ~(rows : 'row array) ~(row_id : 'row -> string)
+ class_="data-grid__selection-column"
+ width=(Pixels selection_width)
+ min_width=selection_width
+ ?pinned=(lead_pinned ())>
(match S.get selection_mode with
| `multiple ->
selection_checkbox ~aria_label:"Select all" ~variant:`primary
@@ -276,7 +285,10 @@ let%component make ~(rows : 'row array) ~(row_id : 'row -> string)
+ class_="data-grid__drag-handle-column"
+ width=(Pixels drag_handle_width)
+ min_width=drag_handle_width
+ ?pinned=(lead_pinned ())>
(unseen "Reorder")
diff --git a/heroui/extras.css b/heroui/extras.css
index 62e53ff..80b3a9e 100644
--- a/heroui/extras.css
+++ b/heroui/extras.css
@@ -5,3 +5,7 @@
@import "./table.css" layer(components);
@import "./data-grid.css" layer(components);
@import "./command.css" layer(components);
+@import "./inline-select.css" layer(components);
+@import "./list-view.css" layer(components);
+@import "./action-bar.css" layer(components);
+@import "./rating.css" layer(components);
diff --git a/heroui/inline-select.css b/heroui/inline-select.css
new file mode 100644
index 0000000..52602c2
--- /dev/null
+++ b/heroui/inline-select.css
@@ -0,0 +1,63 @@
+/* Inline_select, in HeroUI's look, which ships no stylesheet for it: a
+ select drawn as text, with no field around it, written as HeroUI writes its
+ components' CSS over its select's, so an application restyles a part by a
+ rule for its class. */
+
+.inline-select {
+ --inline-select-value-max-width: 12rem;
+ --inline-select-indicator-size: 0.75rem;
+ @apply shrink-0;
+}
+
+/* Over the select's field: no border, background or shadow, only the text
+ and its chevron, which hover brings forward. */
+.inline-select .inline-select__trigger {
+ @apply min-h-0 items-center gap-2 rounded-[calc(var(--radius)*0.75)] border-0 bg-transparent px-1 py-0.5 text-sm text-muted shadow-none transition-colors;
+
+ &:has(.select__indicator) {
+ @apply pe-1;
+ }
+
+ @media (hover: hover) {
+ &:hover:not(:has(.select__clear-button:hover)),
+ &[data-hovered="true"]:not(:has(.select__clear-button:hover)) {
+ @apply bg-transparent text-foreground;
+ }
+ }
+
+ &:focus-visible:not([data-focused]),
+ &[data-focus-visible="true"] {
+ @apply status-focused bg-transparent;
+ }
+
+ &:disabled,
+ &[data-disabled="true"],
+ &[aria-disabled="true"] {
+ @apply status-disabled;
+ }
+}
+
+.inline-select .inline-select__value {
+ @apply truncate;
+ max-width: var(--inline-select-value-max-width);
+}
+
+/* Beside the value rather than over the field's end, and never turned: its
+ chevrons already point both ways. */
+.inline-select .inline-select__indicator {
+ @apply static my-0 text-muted;
+ width: var(--inline-select-indicator-size);
+ height: var(--inline-select-indicator-size);
+
+ &[data-open="true"] {
+ @apply rotate-0;
+ }
+
+ & svg {
+ @apply size-full;
+ }
+}
+
+.inline-select__popover {
+ @apply min-w-48;
+}
diff --git a/heroui/inline_select.mli b/heroui/inline_select.mli
new file mode 100644
index 0000000..bb498c3
--- /dev/null
+++ b/heroui/inline_select.mli
@@ -0,0 +1,143 @@
+(** An inline select, in HeroUI's look, which ships no stylesheet for it: a
+ {!Select} drawn as text, with no field around it, for a choice made in a
+ sentence, a toolbar or a cell. Its choice, keys, list and form are the
+ select's; its look is a stylesheet, [inline-select.css], in the [components]
+ layer, rules for its classes.
+
+ Its page, with its examples:
+ [$(opam var solidtype:doc)/pages/heroui/inline-select.md].
+
+ {[
+
+
+
+
+
+
+
+ "English"
+
+
+
+
+ ]}
+
+ A part is used inside an [Inline_select]: elsewhere it raises
+ [Invalid_argument] as it is made. *)
+
+module S := Solidtype.Solid
+module Jsx := Solidtype.Jsx
+
+(** Its button: the select's {!Select.Trigger}, its text muted until it is
+ hovered. *)
+module Trigger : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?class_:string Solidtype.Check.value ->
+ ?on_key_down:(Dom.keyboardEvent -> unit) ->
+ ?ref:(Dom.htmlButtonElement -> unit) ->
+ children:
+ ( Select.Trigger.state -> Jsx.element,
+ [ `elements | `render ] )
+ Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Button.props -> Select.Trigger.state -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Button.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+(** The option chosen, as {!Select.Value} draws it, cut short past
+ [--inline-select-value-max-width]. *)
+module Value : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?class_:string Solidtype.Check.value ->
+ ?children:
+ ( Select.Value.state -> Jsx.element,
+ [ `elements | `render ] )
+ Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Span.props -> Select.Value.state -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Span.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+(** Chevrons up and down, or the [children] it is given, beside the value and
+ never turned. *)
+module Indicator : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?class_:string Solidtype.Check.value ->
+ ?children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Svg.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Svg.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+(** The list's popover: {!Select.Popover}, [placement] beside the trigger,
+ [`bottom_end] by default, at least 12rem wide. *)
+module Popover : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?placement:Select.placement Solidtype.Check.value ->
+ ?class_:string Solidtype.Check.value ->
+ ?style:string Solidtype.Check.value ->
+ ?ref:(Dom.htmlDivElement -> unit) ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+(** The select: {!Select}'s root, [
], with its
+ props but the field's [variant] and [full_width]. *)
+module Props : sig
+ type t
+
+ val check :
+ ?placeholder:string Solidtype.Check.value ->
+ ?selection_mode:[ `single | `multiple ] Solidtype.Check.value ->
+ ?value:string array Solidtype.Check.value ->
+ ?default_value:string array Solidtype.Check.value ->
+ ?on_change:(string array -> unit) ->
+ ?disabled_keys:string array Solidtype.Check.value ->
+ ?is_open:bool Solidtype.Check.value ->
+ ?default_open:bool Solidtype.Check.value ->
+ ?on_open_change:(bool -> unit) ->
+ ?is_disabled:bool Solidtype.Check.value ->
+ ?is_required:bool Solidtype.Check.value ->
+ ?is_invalid:bool Solidtype.Check.value ->
+ ?name:string Solidtype.Check.value ->
+ ?class_:string Solidtype.Check.value ->
+ ?ref:(Dom.htmlDivElement -> unit) ->
+ ?on_focus_out:(Dom.focusEvent -> unit) ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> Select.state -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+end
+
+val make : Props.t -> Jsx.element
+val component : Props.t Jsx.component
diff --git a/heroui/inline_select.mlx b/heroui/inline_select.mlx
new file mode 100644
index 0000000..7efbb80
--- /dev/null
+++ b/heroui/inline_select.mlx
@@ -0,0 +1,124 @@
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module Gravity = Solidtype_gravity_icons
+
+let after own = function Some c -> own ^ " " ^ c | None -> own
+
+module Trigger = struct
+ let%component make ?(class_ : string option)
+ ?(on_key_down : (Dom.keyboardEvent -> unit) option)
+ ?ref:(given_ref : (Dom.htmlButtonElement -> unit) option)
+ ~(children : Select.Trigger.state Jsx.children)
+ ?(as_ :
+ (Solidtype.Html.Button.props ->
+ Select.Trigger.state ->
+ Solidtype.Jsx.element)
+ option) () =
+ ignore (on_key_down e : unit option))
+ ref=(fun e -> ignore (given_ref e : unit option))
+ ?as_=(S.get as_)
+ props=(Props.others props)>
+ (fun state -> Jsx.draw (S.get children) state)
+
+ [@@element button]
+end
+
+module Value = struct
+ let%component make ?(class_ : string option)
+ ?(children : Select.Value.state Jsx.children option)
+ ?(as_ :
+ (Solidtype.Html.Span.props ->
+ Select.Value.state ->
+ Solidtype.Jsx.element)
+ option) () =
+ match S.untrack (fun () -> S.get children) with
+ | Some _ ->
+
+ (fun state ->
+ match S.get children with
+ | Some c -> Jsx.draw c state
+ | None -> Jsx.nothing)
+
+ | None ->
+
+ [@@element span]
+end
+
+module Indicator = struct
+ let%component make ?(class_ : string option) ?(children : Jsx.element option)
+ () =
+
+ (match S.get children with
+ | Some c -> c
+ | None -> )
+
+ [@@element svg]
+end
+
+module Popover = struct
+ let%component make ?(placement : Select.placement = `bottom_end)
+ ?(class_ : string option) ?(style : string option)
+ ?ref:(given_ref : (Dom.htmlDivElement -> unit) option)
+ ~(children : Jsx.element) () =
+ ignore (given_ref e : unit option))
+ props=(Props.others props)>
+ (S.get children)
+
+ [@@element div]
+end
+
+let%component make ?(placeholder : string option)
+ ?(selection_mode : [ `single | `multiple ] option)
+ ?(value : string array option) ?(default_value : string array option)
+ ?(on_change : (string array -> unit) option)
+ ?(disabled_keys : string array option) ?(is_open : bool option)
+ ?(default_open : bool option) ?(on_open_change : (bool -> unit) option)
+ ?(is_disabled : bool option) ?(is_required : bool option)
+ ?(is_invalid : bool option) ?(name : string option)
+ ?(class_ : string option)
+ ?ref:(given_ref : (Dom.htmlDivElement -> unit) option)
+ ?(on_focus_out : (Dom.focusEvent -> unit) option) ~(children : Jsx.element)
+ ?(as_ :
+ (Solidtype.Html.Div.props -> Select.state -> Solidtype.Jsx.element)
+ option) () =
+
+[@@element div]
diff --git a/heroui/list-view.css b/heroui/list-view.css
new file mode 100644
index 0000000..80bdfc2
--- /dev/null
+++ b/heroui/list-view.css
@@ -0,0 +1,124 @@
+/* List_view, in HeroUI's look, which ships no stylesheet for it: Tailwind on
+ HeroUI's tokens, written as HeroUI writes its components' CSS, so an
+ application restyles a part by a rule for its class. */
+
+.list-view {
+ @apply relative min-h-0 w-full outline-none;
+}
+
+/* A grey card of white rows. */
+.list-view--primary {
+ @apply rounded-[calc(var(--radius)*2.5)] bg-surface-secondary p-1;
+}
+
+.list-view__item {
+ @apply flex cursor-(--cursor-interactive) items-center gap-3 px-4 py-3 text-sm outline-none;
+ -webkit-tap-highlight-color: transparent;
+
+ &:focus-visible,
+ &[data-focus-visible="true"] {
+ box-shadow: inset 0 0 0 2px var(--color-focus);
+ }
+
+ &[aria-disabled="true"] {
+ @apply status-disabled;
+ }
+
+ &[data-dragging="true"] {
+ @apply opacity-50;
+ }
+}
+
+/* A virtualized list scrolls its own rows, as high as a caller makes it,
+ each as high as the frame its row_height gives it. */
+.list-view[data-virtualized="true"] {
+ @apply overflow-y-auto;
+
+ & .list-view__item {
+ @apply h-full;
+ }
+}
+
+.list-view--primary .list-view__item {
+ @apply border-b bg-surface;
+ border-color: color-mix(in oklab, var(--separator-tertiary) 50%, transparent);
+
+ @media (hover: hover) {
+ &:hover,
+ &[data-hovered="true"] {
+ @apply bg-surface/40;
+ }
+ }
+
+ &[data-selected="true"] {
+ @apply bg-surface/10;
+ }
+}
+
+/* The first and last rows of a list that draws them all, siblings; a
+ virtualized list draws each in a frame of its own. */
+.list-view--primary:not([data-virtualized="true"]) .list-view__item {
+ &:first-child {
+ @apply rounded-t-[calc(var(--radius)*2)];
+ }
+
+ &:last-child {
+ @apply rounded-b-[calc(var(--radius)*2)] border-b-0;
+ }
+}
+
+/* Rows on the page's background, a line between each. */
+.list-view--secondary .list-view__item {
+ @apply border-b bg-transparent;
+ border-color: color-mix(in oklab, var(--separator-tertiary) 50%, transparent);
+
+ @media (hover: hover) {
+ &:hover,
+ &[data-hovered="true"] {
+ @apply bg-default/50;
+ }
+ }
+
+ &[data-selected="true"] {
+ @apply bg-accent-soft;
+
+ @media (hover: hover) {
+ &:hover,
+ &[data-hovered="true"] {
+ background-color: var(--accent-soft-hover);
+ }
+ }
+ }
+}
+
+.list-view--secondary:not([data-virtualized="true"]) .list-view__item:last-child {
+ @apply border-b-0;
+}
+
+.list-view__selection-cell {
+ @apply flex shrink-0 items-center;
+}
+
+.list-view__item-content {
+ @apply flex min-w-0 flex-1 items-center gap-3;
+
+ & svg {
+ @apply size-4 shrink-0 text-muted;
+ }
+}
+
+.list-view__title {
+ @apply truncate text-sm font-medium text-foreground;
+}
+
+.list-view__description {
+ @apply mt-0.5 truncate text-xs text-muted;
+}
+
+.list-view__item-action {
+ @apply ms-auto shrink-0 ps-2;
+}
+
+.list-view__empty-state {
+ @apply flex items-center justify-center px-4 py-8;
+}
diff --git a/heroui/list_view.mli b/heroui/list_view.mli
new file mode 100644
index 0000000..da95509
--- /dev/null
+++ b/heroui/list_view.mli
@@ -0,0 +1,170 @@
+(** A list of rows, in HeroUI's look, which ships no stylesheet for it: a
+ {!Solidtype_headless.Grid_list} of items, each its content and an action,
+ chosen by a checkbox where the list chooses, acted on by [on_action] or an
+ item's [href]. Its look is a stylesheet, [list-view.css], in the
+ [components] layer, rules for its classes.
+
+ Its page, with its examples:
+ [$(opam var solidtype:doc)/pages/heroui/list-view.md].
+
+ {[
+
+
+
+ "README.md"
+ "Updated 3 hours ago"
+
+
+
+ ]}
+
+ Its keys, selection and actions are {!Solidtype_headless.Grid_list}'s. A
+ part is used inside a [List_view]: elsewhere it raises [Invalid_argument] as
+ it is made. *)
+
+module S := Solidtype.Solid
+module Jsx := Solidtype.Jsx
+
+type variant = [ `primary | `secondary ]
+
+(** The content of an item, its icon and its text: a
+ [
]. *)
+module Item_content : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?class_:string Solidtype.Check.value ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+(** An item's name, cut short to its width: a [].
+*)
+module Title : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?class_:string Solidtype.Check.value ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Span.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Span.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+(** A line under an item's name, muted: a
+ []. *)
+module Description : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?class_:string Solidtype.Check.value ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Span.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Span.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+(** What an item ends with, its buttons or its menu, at its far side: a
+ [
]. *)
+module Item_action : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?class_:string Solidtype.Check.value ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+(** An item: a [
], React Aria's state on
+ it as ["true"] -- [data-selected], [data-hovered], [data-pressed],
+ [data-focus-visible], [data-disabled] -- and [data-selection-mode]; where
+ the list chooses, a checkbox first that stands for its selection. *)
+module Item : sig
+ type state = {
+ is_selected : bool S.accessor;
+ is_disabled : bool S.accessor;
+ is_hovered : bool S.accessor;
+ is_pressed : bool S.accessor;
+ is_focused : bool S.accessor;
+ is_focus_visible : bool S.accessor;
+ selection_mode : [ `none | `single | `multiple ] S.accessor;
+ }
+ (** What its children are drawn of, given as a function. *)
+
+ module Props : sig
+ type t
+
+ val check :
+ ?id:string Solidtype.Check.value ->
+ ?text_value:string Solidtype.Check.value ->
+ ?is_disabled:bool Solidtype.Check.value ->
+ ?href:string Solidtype.Check.value ->
+ ?class_:string Solidtype.Check.value ->
+ ?ref:(Dom.htmlDivElement -> unit) ->
+ children:
+ (state -> Jsx.element, [ `elements | `render ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> state -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+module Props : sig
+ type t
+
+ val check :
+ ?variant:variant Solidtype.Check.value ->
+ ?selection_mode:[ `none | `single | `multiple ] Solidtype.Check.value ->
+ ?selection_behavior:[ `toggle | `replace ] Solidtype.Check.value ->
+ ?selected_keys:string array Solidtype.Check.value ->
+ ?default_selected_keys:string array Solidtype.Check.value ->
+ ?on_selection_change:(string array -> unit) ->
+ ?disabled_keys:string array Solidtype.Check.value ->
+ ?disallow_empty_selection:bool Solidtype.Check.value ->
+ ?on_action:(string -> unit) ->
+ ?render_empty_state:(unit -> Jsx.element) ->
+ ?virtualized:bool Solidtype.Check.value ->
+ ?row_height:float Solidtype.Check.value ->
+ ?class_:string Solidtype.Check.value ->
+ ?ref:(Dom.htmlDivElement -> unit) ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+end
+
+val make : Props.t -> Jsx.element
+(** The list: a [
], or
+ [--secondary], [`primary] by default: a grey card of white rows, or rows on
+ the page's own background with a line between each. With [virtualized],
+ [data-virtualized], it draws only the rows in view, each [row_height] high,
+ 48 by default, and scrolls them: give it a height. *)
+
+val component : Props.t Jsx.component
diff --git a/heroui/list_view.mlx b/heroui/list_view.mlx
new file mode 100644
index 0000000..6f9376d
--- /dev/null
+++ b/heroui/list_view.mlx
@@ -0,0 +1,242 @@
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module Headless = Solidtype_headless.Grid_list
+
+let after own = function Some c -> own ^ " " ^ c | None -> own
+
+type variant = [ `primary | `secondary ]
+
+(* Whether a list was given [on_action], read of its props as given, which
+ its own parameter, a call that does nothing where none was, cannot tell:
+ only a list given one runs an item's action on a press. *)
+type handler
+
+external action_given : 'props -> handler Js.Undefined.t = "onAction"
+[@@mel.get]
+
+external empty_state_given : 'props -> handler Js.Undefined.t
+ = "renderEmptyState"
+[@@mel.get]
+
+module Variant = Solidtype.Context.Make (struct
+ type t = variant S.accessor
+
+ let default = S.accessor (fun () -> `primary)
+end)
+
+(* A part drawn as a [
] or a [] of a class of its own, its
+ children what it holds. *)
+module Item_content = struct
+ let%component make ?(class_ : string option) ~(children : Jsx.element) () =
+
)
+ else None)
+ class_=(after
+ ("list-view list-view--"
+ ^
+ match S.get variant with
+ | `primary -> "primary"
+ | `secondary -> "secondary")
+ (S.get class_))
+ data_slot="list-view"
+ data_virtualized=(Jsx.flag (S.get virtualized))
+ data_layout="stack"
+ data_orientation="vertical"
+ ref=(fun e -> ignore (given_ref e : unit option))
+ props=(Props.others props)>
+ (S.get children)
+
+ in
+ (* A long list draws only the rows in view, each [row_height] high. *)
+ if S.untrack (fun () -> S.get virtualized) then
+
+ (list ())
+
+ else list ())
+
+[@@element div]
diff --git a/heroui/radio_group.mlx b/heroui/radio_group.mlx
index e68dcdf..d82981a 100644
--- a/heroui/radio_group.mlx
+++ b/heroui/radio_group.mlx
@@ -97,6 +97,24 @@ let description : Description.slot =
(children ())
+module Kobalte_error = Field.As_span (struct
+ let component = Kobalte.ErrorMessage.component
+end)
+
+(* An error in a group is the group's: Kobalte's, shown while it is invalid
+ and describing it. *)
+let error : Field_error.slot =
+ fun classes others children ->
+
+ (children ())
+
+
(* What its children are drawn of: React Aria's render props for a radio
group. *)
type state = {
@@ -207,7 +225,9 @@ let%component make ?(variant : [ `primary | `secondary ] = `primary)
props=(Props.others props)>
- (Jsx.draw (S.get children) (state ()))
+
+ (Jsx.draw (S.get children) (state ()))
+
diff --git a/heroui/rating.css b/heroui/rating.css
new file mode 100644
index 0000000..5f77515
--- /dev/null
+++ b/heroui/rating.css
@@ -0,0 +1,98 @@
+/* Rating, in HeroUI's look, which ships no stylesheet for it: Tailwind on
+ HeroUI's tokens, written as HeroUI writes its components' CSS, so an
+ application restyles a part by a rule for its class. */
+
+.rating {
+ --rating-active-color: var(--color-warning);
+ --rating-inactive-color: var(--color-surface-tertiary);
+ @apply flex items-center outline-none;
+
+ &[data-focus-visible="true"] {
+ @apply status-focused;
+ }
+
+ &[data-disabled="true"] {
+ @apply status-disabled;
+ }
+
+ &[data-readonly="true"] {
+ @apply pointer-events-none;
+ }
+}
+
+/* Kobalte's control around the items lays nothing out itself. */
+.rating__control {
+ @apply contents;
+}
+
+.rating--sm {
+ gap: 4px;
+}
+
+.rating--md {
+ gap: 5px;
+}
+
+.rating--lg {
+ gap: 8px;
+}
+
+.rating__item {
+ @apply relative flex cursor-(--cursor-interactive) items-center justify-center outline-none transition-transform duration-150 motion-reduce:transition-none;
+ -webkit-tap-highlight-color: transparent;
+
+ &[data-focus-visible="true"] {
+ @apply status-focused rounded-[calc(var(--radius)*0.5)];
+ }
+
+ &[aria-disabled="true"] {
+ @apply status-disabled;
+ }
+
+ &[data-pressed="true"]:not([data-readonly="true"]) {
+ @apply scale-80;
+ }
+
+ &[data-readonly="true"] {
+ @apply pointer-events-none cursor-default;
+ }
+}
+
+.rating__icon {
+ @apply relative flex items-center justify-center transition-colors duration-100 ease-out motion-reduce:transition-none;
+ color: var(--rating-inactive-color);
+
+ & svg {
+ @apply size-full;
+ }
+
+ &[data-active="true"] {
+ color: var(--rating-active-color);
+ }
+}
+
+/* An item a fractional value fills in part, as far as the fraction goes. */
+.rating__icon-partial {
+ @apply absolute inset-y-0 start-0 flex items-center overflow-hidden;
+ width: var(--rating-partial);
+ color: var(--rating-active-color);
+
+ & svg {
+ @apply shrink-0;
+ }
+}
+
+.rating__item--sm .rating__icon,
+.rating__item--sm .rating__icon-partial svg {
+ @apply size-4;
+}
+
+.rating__item--md .rating__icon,
+.rating__item--md .rating__icon-partial svg {
+ @apply size-5;
+}
+
+.rating__item--lg .rating__icon,
+.rating__item--lg .rating__icon-partial svg {
+ @apply size-7;
+}
diff --git a/heroui/rating.mli b/heroui/rating.mli
new file mode 100644
index 0000000..bf40a74
--- /dev/null
+++ b/heroui/rating.mli
@@ -0,0 +1,90 @@
+(** A rating, in HeroUI's look, which ships no stylesheet for it: Kobalte's
+ [Rating], a radio group of items, each a star or the icon given, chosen by a
+ press or the arrow keys, the items under the pointer previewed as it moves.
+ Read only, its value may be a fraction, 3.7, the next item filled as far as
+ the fraction goes. Its look is a stylesheet, [rating.css], in the
+ [components] layer, rules for its classes.
+
+ Its page, with its examples:
+ [$(opam var solidtype:doc)/pages/heroui/rating.md].
+
+ {[
+
+
+
+
+
+ ]}
+
+ A part is used inside a [Rating]: elsewhere it raises [Invalid_argument] as
+ it is made. *)
+
+module S := Solidtype.Solid
+module Jsx := Solidtype.Jsx
+
+type size = [ `sm | `md | `lg ]
+
+(** An item: Kobalte's [Rating.Item], a
+ [
], [data-readonly], [data-pressed],
+ [data-hovered] and [data-focus-visible] as its state is, around a
+ [], [data-active] while it is at or under the
+ value, or the value under the pointer. Its [value] is its place, from 1. *)
+module Item : sig
+ type state = {
+ is_active : bool S.accessor;
+ is_partial : bool S.accessor;
+ (** Whether a fractional value fills it in part. *)
+ partial_percent : float S.accessor; (** How far, from 0 to 100. *)
+ }
+ (** What its children are drawn of. *)
+
+ module Props : sig
+ type t
+
+ val check :
+ value:float Solidtype.Check.value ->
+ ?class_:string Solidtype.Check.value ->
+ ?children:
+ (state -> Jsx.element, [ `elements | `render ]) Solidtype.Check.children ->
+ ?ref:(Dom.htmlDivElement -> unit) ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+ end
+
+ val make : Props.t -> Jsx.element
+ (** Elements given are its icon, in place of the rating's; a function draws
+ the whole item of its state. *)
+
+ val component : Props.t Jsx.component
+end
+
+module Props : sig
+ type t
+
+ val check :
+ ?size:size Solidtype.Check.value ->
+ ?value:float Solidtype.Check.value ->
+ ?default_value:float Solidtype.Check.value ->
+ ?on_value_change:(float -> unit) ->
+ ?icon:Jsx.element Solidtype.Check.value ->
+ ?is_disabled:bool Solidtype.Check.value ->
+ ?is_read_only:bool Solidtype.Check.value ->
+ ?is_required:bool Solidtype.Check.value ->
+ ?name:string Solidtype.Check.value ->
+ ?class_:string Solidtype.Check.value ->
+ ?ref:(Dom.htmlDivElement -> unit) ->
+ children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+end
+
+val make : Props.t -> Jsx.element
+(** The rating: a [
], of
+ [size], [`md] by default. Its value is [value] while it is given, else the
+ one kept, [default_value] at first, [0.] for none; [on_value_change] is told
+ each one chosen. [icon] is every item's icon, a star by default;
+ [--rating-active-color] and [--rating-inactive-color] colour them. *)
+
+val component : Props.t Jsx.component
diff --git a/heroui/rating.mlx b/heroui/rating.mlx
new file mode 100644
index 0000000..745428a
--- /dev/null
+++ b/heroui/rating.mlx
@@ -0,0 +1,179 @@
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module Kobalte = Solidtype_kobalte.Rating
+module Types = Solidtype_kobalte.Types
+
+let after own = function Some c -> own ^ " " ^ c | None -> own
+
+type size = [ `sm | `md | `lg ]
+
+let size_name = function `sm -> "sm" | `md -> "md" | `lg -> "lg"
+
+type group = {
+ size : size S.accessor;
+ value : float S.accessor;
+ read_only : bool S.accessor;
+ icon : Jsx.element option S.accessor;
+}
+
+module Context = Solidtype.Context.Make_optional (struct
+ type t = group
+end)
+
+let within part =
+ match Context.use () with
+ | Some g -> g
+ | None -> invalid_arg (part ^ " is used inside a Rating")
+
+(* The star the items draw unless given another. *)
+let star () =
+
+
+module Item = struct
+ type state = {
+ is_active : bool S.accessor;
+ is_partial : bool S.accessor;
+ partial_percent : float S.accessor;
+ }
+
+ let%component make ~(value : float) ?(class_ : string option)
+ ?(children : state Jsx.children option)
+ ?ref:(given_ref : (Dom.htmlDivElement -> unit) option) () =
+ let g = within "Rating.Item" in
+ let i = Interaction.create ~disabled:(fun () -> S.get g.read_only) () in
+ (* A value read only may be a fraction, 3.7: the items up to its whole
+ part are active, and the next filled as far as the fraction goes. *)
+ let fraction () =
+ let v = S.get g.value in
+ v -. Float.of_int (int_of_float v)
+ in
+ let partial () =
+ S.get g.read_only
+ && fraction () > 0.
+ && Float.equal (S.get value)
+ (Float.of_int (int_of_float (S.get g.value)) +. 1.)
+ in
+ (* Kobalte learns an item's place once it is mounted: until then, on the
+ server and as the page hydrates, the value alone says which are
+ active. *)
+ let mounted, set_mounted = S.create_signal false in
+ S.on_mount (fun () -> S.set set_mounted true);
+ let active_by_value () =
+ S.get value <= Float.of_int (int_of_float (S.get g.value))
+ in
+
+ ignore (given_ref e : unit option);
+ Interaction.watch i e)
+ props=(Props.others props)>
+
+ (fun (k : Types.RatingItemState.t) ->
+ let active () =
+ if S.get g.read_only || not (S.get mounted) then active_by_value ()
+ else S.get (Types.RatingItemState.highlighted k)
+ in
+ let state =
+ {
+ is_active = S.accessor active;
+ is_partial = S.accessor partial;
+ partial_percent =
+ S.accessor (fun () ->
+ if partial () then Float.round (fraction () *. 100.) else 0.);
+ }
+ in
+ match S.get children with
+ | Some c when Jsx.is_function c -> Jsx.draw c state
+ | given ->
+ let icon () =
+ match given with
+ | Some c -> Jsx.draw c state
+ | None -> (
+ match S.get g.icon with Some i -> i | None -> star ())
+ in
+
+ (icon ())
+ (if partial () then
+
+ (icon ())
+
+ else Jsx.string "")
+ )
+
+
+ [@@element div]
+end
+
+let%component make ?(size : size = `md) ?(value : float option)
+ ?(default_value : float option) ?(on_value_change : (float -> unit) option)
+ ?(icon : Jsx.element option) ?(is_disabled : bool = false)
+ ?(is_read_only : bool = false) ?(is_required : bool = false)
+ ?(name : string option) ?(class_ : string option)
+ ?ref:(given_ref : (Dom.htmlDivElement -> unit) option)
+ ~(children : Jsx.element) () =
+ let kept, set_kept =
+ S.create_signal
+ (Option.value (S.untrack (fun () -> S.get default_value)) ~default:0.)
+ in
+ let shown () = match S.get value with Some v -> v | None -> S.get kept in
+ let g =
+ {
+ size = S.accessor (fun () -> S.get size);
+ value = S.accessor shown;
+ read_only = S.accessor (fun () -> S.get is_read_only);
+ icon = S.accessor (fun () -> S.get icon);
+ }
+ in
+ let i = Interaction.create ~disabled:(fun () -> S.get is_disabled) () in
+
+
+ S.set set_kept v;
+ ignore (on_value_change v : unit option))
+ disabled=(S.get is_disabled)
+ read_only=(S.get is_read_only)
+ required=(S.get is_required)
+ ?name=(S.get name)
+ class_=(after ("rating rating--" ^ size_name (S.get size)) (S.get class_))
+ data_slot="rating"
+ data_disabled=(Jsx.flag (S.get is_disabled))
+ data_readonly=(Jsx.flag (S.get is_read_only))
+ data_focus_visible=(Jsx.flag (Interaction.focus_visible i))
+ ref=(fun e ->
+ ignore (given_ref e : unit option);
+ Interaction.watch i e)
+ props=(Props.others props)>
+
+ (S.get children)
+
+
+
+
+[@@element div]
diff --git a/heroui/select.mli b/heroui/select.mli
index 4d2a9dc..45353de 100644
--- a/heroui/select.mli
+++ b/heroui/select.mli
@@ -42,8 +42,8 @@
module S := Solidtype.Solid
module Jsx := Solidtype.Jsx
-type placement = [ `top | `bottom | `left | `right ]
-(** A side of the trigger. *)
+type placement = Overlay.placement
+(** Where its list sits beside the trigger, as React Aria names it. *)
(** Its button: Kobalte's trigger, which opens the list. *)
module Trigger : sig
diff --git a/heroui/select.mlx b/heroui/select.mlx
index bc208fb..061a263 100644
--- a/heroui/select.mlx
+++ b/heroui/select.mlx
@@ -3,9 +3,10 @@ module S = Solidtype.Solid
module Show = Solidtype.Show
module Kobalte = Solidtype_kobalte.Select
module Types = Solidtype_kobalte.Types
+module I18n = Solidtype_kobalte.I18n
module Gravity = Solidtype_gravity_icons
-type placement = [ `top | `bottom | `left | `right ]
+type placement = Overlay.placement
(* What a select's parts read of it: its classes, its list box once one has
joined it, the options selected, whether it is open, and how it clears. *)
@@ -243,7 +244,9 @@ module Popover = struct
s.set_placement (Option.value (S.get placement) ~default:`bottom));
let o = Overlay.create ~is_open:(fun () -> S.get s.is_open) () in
let side, watch_side =
- Overlay.placed_side ~placement:(fun () -> S.get s.placement) ()
+ Overlay.placed_side
+ ~placement:(fun () -> Overlay.side_of (S.get s.placement))
+ ()
in
Jsx.fragment
[|
@@ -379,6 +382,7 @@ let%component make ?(placeholder : string = "Select an item")
ignore (on_open_change o : unit option)
in
let placement, set_placement = S.create_signal `bottom in
+ let locale = I18n.use_locale () in
let disabled_key key =
Array.exists (String.equal key)
(Option.value (S.get disabled_keys) ~default:[||])
@@ -396,11 +400,9 @@ let%component make ?(placeholder : string = "Select an item")
set_placement = S.set set_placement;
placement =
S.accessor (fun () ->
- match S.get placement with
- | `top -> "top"
- | `bottom -> "bottom"
- | `left -> "left"
- | `right -> "right");
+ Overlay.kobalte_placement
+ (Types.I18n_UseLocale.direction locale ())
+ (S.get placement));
is_empty = S.accessor (fun () -> Array.length (keys ()) = 0);
clear =
(fun () ->
diff --git a/heroui/separator.mli b/heroui/separator.mli
index ebbc863..6f6434d 100644
--- a/heroui/separator.mli
+++ b/heroui/separator.mli
@@ -51,6 +51,24 @@ module Slot : sig
val use : unit -> ((unit -> Jsx.element) -> Jsx.element) option
end
+(** The orientation a part above gives the separators inside it that give none,
+ as a {!Toolbar} gives its own one across it. *)
+module Orientation : sig
+ module Provider : sig
+ module Props : sig
+ val check :
+ value:[ `horizontal | `vertical ] S.accessor Solidtype.Check.value ->
+ ?children:('f, [ `elements ]) Solidtype.Check.children ->
+ unit ->
+ unit
+ end
+
+ val component : unit Jsx.component
+ end
+
+ val use : unit -> [ `horizontal | `vertical ] S.accessor option
+end
+
module Props : sig
type t
diff --git a/heroui/separator.mlx b/heroui/separator.mlx
index b226b3c..1b23f7d 100644
--- a/heroui/separator.mlx
+++ b/heroui/separator.mlx
@@ -15,6 +15,13 @@ module Slot = Solidtype.Context.Make_optional (struct
type t = (unit -> Solidtype.Jsx.element) -> Solidtype.Jsx.element
end)
+(* The orientation a part above gives the separators inside it, where they
+ give none, as React Aria's SeparatorContext does: a toolbar's run across
+ it. *)
+module Orientation = Solidtype.Context.Make_optional (struct
+ type t = [ `horizontal | `vertical ] Solidtype.Solid.accessor
+end)
+
(* Kobalte's separator as another element, as React Aria's draws one. *)
module As = struct
module Props = struct
@@ -30,10 +37,18 @@ module As = struct
let component = Kobalte.Root.component
end
-let%component make ?(orientation : [ `horizontal | `vertical ] = `horizontal)
+let%component make ?(orientation : [ `horizontal | `vertical ] option)
?(variant : [ `default | `secondary | `tertiary ] = `default)
?(class_ : string option) () =
let element = Element.use () in
+ let around = Orientation.use () in
+ let orientation =
+ S.accessor (fun () ->
+ match (S.get orientation, around) with
+ | Some o, _ -> o
+ | None, Some o -> S.get o
+ | None, None -> `horizontal)
+ in
let drawn () =
] is a horizontal line, so React Aria draws a vertical
diff --git a/heroui/switch.mli b/heroui/switch.mli
index 3f578b9..b06546f 100644
--- a/heroui/switch.mli
+++ b/heroui/switch.mli
@@ -95,7 +95,7 @@ module Control : sig
val component : Props.t Jsx.component
end
-(** The thumb.
+(** The thumb, and what it is given to hold, an {!Icon}.
Raises [Invalid_argument] outside a [Switch]. *)
module Thumb : sig
@@ -104,6 +104,26 @@ module Thumb : sig
val check :
?class_:string Solidtype.Check.value ->
+ ?children:(_, [ `elements ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Span.props -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Span.check
+ end
+
+ val make : Props.t -> Jsx.element
+ val component : Props.t Jsx.component
+end
+
+(** An icon in the thumb, sized and coloured as HeroUI's.
+
+ Raises [Invalid_argument] outside a [Switch]. *)
+module Icon : sig
+ module Props : sig
+ type t
+
+ val check :
+ ?class_:string Solidtype.Check.value ->
+ ?children:(_, [ `elements ]) Solidtype.Check.children ->
?as_:(Solidtype.Html.Span.props -> Jsx.element) ->
?props:t S.rest ->
(unit -> unit) Solidtype.Html.Span.check
diff --git a/heroui/switch.mlx b/heroui/switch.mlx
index 0513e3b..1b072b1 100644
--- a/heroui/switch.mlx
+++ b/heroui/switch.mlx
@@ -82,13 +82,28 @@ module Control = struct
end
module Thumb = struct
- let%component make ?(class_ : string option) () =
+ let%component make ?(class_ : string option) ?(children : Jsx.element option)
+ () =
let s = within "Switch.Thumb" in
+ props=(Props.others props)>
+ (Option.value (S.get children) ~default:Jsx.nothing)
+
+ [@@element span]
+end
+
+module Icon = struct
+ let%component make ?(class_ : string option) ?(children : Jsx.element option)
+ () =
+ let s = within "Switch.Icon" in
+
+ (Option.value (S.get children) ~default:Jsx.nothing)
+
[@@element span]
end
diff --git a/heroui/table.css b/heroui/table.css
index 908620e..aae2aa1 100644
--- a/heroui/table.css
+++ b/heroui/table.css
@@ -140,6 +140,13 @@
@apply z-4;
}
+/* A virtualized table's header is a
whose columns its layout places
+ apart from it: it fills the place that stays over the rows, so its
+ background hides them as they scroll beneath. */
+div.table__header {
+ @apply h-full w-full;
+}
+
/* A dragged row would land on the side of a row marked: a line in the accent
there, as React Aria's drop indicator is drawn between two rows. */
.table__row[data-drop-position="before"] .table__cell {
diff --git a/heroui/toggle_button_group.mli b/heroui/toggle_button_group.mli
index bf4e998..0ca6f54 100644
--- a/heroui/toggle_button_group.mli
+++ b/heroui/toggle_button_group.mli
@@ -71,6 +71,24 @@ module Separator : sig
val component : Props.t Jsx.component
end
+(** The orientation a part above gives a group inside it that gives none, as a
+ {!Toolbar} gives its own. *)
+module Orientation : sig
+ module Provider : sig
+ module Props : sig
+ val check :
+ value:[ `horizontal | `vertical ] S.accessor Solidtype.Check.value ->
+ ?children:('f, [ `elements ]) Solidtype.Check.children ->
+ unit ->
+ unit
+ end
+
+ val component : unit Jsx.component
+ end
+
+ val use : unit -> [ `horizontal | `vertical ] S.accessor option
+end
+
(** The group. [selection_mode] is [`single] by default, one button selected at
most, or [`multiple]. [selected_keys] are the selected buttons' ids while it
is given, else those kept, [default_selected_keys] at first; a change calls
diff --git a/heroui/toggle_button_group.mlx b/heroui/toggle_button_group.mlx
index 07aea4e..531b12d 100644
--- a/heroui/toggle_button_group.mlx
+++ b/heroui/toggle_button_group.mlx
@@ -12,6 +12,12 @@ type group = {
join : (unit -> bool) -> unit;
}
+(* The orientation a part above gives a group inside it that gives none, as
+ React Aria's ToggleButtonGroupContext does: a toolbar's own. *)
+module Orientation = Solidtype.Context.Make_optional (struct
+ type t = [ `horizontal | `vertical ] S.accessor
+end)
+
module Context = Solidtype.Context.Make_optional (struct
type t = group
end)
@@ -46,13 +52,21 @@ let%component make ?(selection_mode : [ `single | `multiple ] = `single)
?(default_selected_keys : string array option)
?(on_selection_change : (string array -> unit) option)
?(disallow_empty_selection : bool = false)
- ?(orientation : [ `horizontal | `vertical ] = `horizontal)
- ?(size : size option) ?(is_detached : bool = false)
- ?(full_width : bool = false) ?(is_disabled : bool option)
- ?(aria_label : string option) ?(aria_labelledby : string option)
- ?(class_ : string option) ~(children : state Jsx.children)
+ ?(orientation : [ `horizontal | `vertical ] option) ?(size : size option)
+ ?(is_detached : bool = false) ?(full_width : bool = false)
+ ?(is_disabled : bool option) ?(aria_label : string option)
+ ?(aria_labelledby : string option) ?(class_ : string option)
+ ~(children : state Jsx.children)
?(as_ : (Solidtype.Html.Div.props -> state -> Solidtype.Jsx.element) option)
() =
+ let around = Orientation.use () in
+ let orientation =
+ S.accessor (fun () ->
+ match (S.get orientation, around) with
+ | Some o, _ -> o
+ | None, Some o -> S.get o
+ | None, None -> `horizontal)
+ in
(* The selection is kept here and Kobalte's group controlled by it, so a
change that would leave none selected is refused, which Kobalte's group
cannot do. *)
diff --git a/heroui/toolbar.mli b/heroui/toolbar.mli
new file mode 100644
index 0000000..cecb182
--- /dev/null
+++ b/heroui/toolbar.mli
@@ -0,0 +1,48 @@
+(** HeroUI's Toolbar: the headless {!Solidtype_headless.Toolbar}, with HeroUI's
+ classes from {!Styles.Toolbar}. Its arrow keys move between its controls; a
+ {!Separator} inside it runs across it, and a {!Toggle_button_group} along
+ it, where either gives no orientation of its own.
+
+ Its page, with its examples:
+ [$(opam var solidtype:doc)/pages/heroui/toolbar.md].
+
+ {[
+
+
+ ...
+
+
+ ...
+
+ ]} *)
+
+module S := Solidtype.Solid
+module Jsx := Solidtype.Jsx
+
+type state = Solidtype_headless.Toolbar.state = {
+ orientation : [ `horizontal | `vertical ] S.accessor;
+}
+(** What its children are drawn of, given as a function, as HeroUI's render
+ props are. *)
+
+module Props : sig
+ type t
+
+ val check :
+ ?is_attached:bool Solidtype.Check.value ->
+ ?orientation:[ `horizontal | `vertical ] Solidtype.Check.value ->
+ ?aria_label:string Solidtype.Check.value ->
+ ?aria_labelledby:string Solidtype.Check.value ->
+ ?class_:string Solidtype.Check.value ->
+ ?ref:(Dom.htmlDivElement -> unit) ->
+ children:
+ (state -> Jsx.element, [ `elements | `render ]) Solidtype.Check.children ->
+ ?as_:(Solidtype.Html.Div.props -> state -> Jsx.element) ->
+ ?props:t S.rest ->
+ (unit -> unit) Solidtype.Html.Div.check
+end
+
+val make : Props.t -> Jsx.element
+(** The toolbar, its [is_attached] look a surface fully rounded. *)
+
+val component : Props.t Jsx.component
diff --git a/heroui/toolbar.mlx b/heroui/toolbar.mlx
new file mode 100644
index 0000000..357443a
--- /dev/null
+++ b/heroui/toolbar.mlx
@@ -0,0 +1,44 @@
+module S = Solidtype.Solid
+module Jsx = Solidtype.Jsx
+module Headless = Solidtype_headless.Toolbar
+
+type state = Headless.state = {
+ orientation : [ `horizontal | `vertical ] S.accessor;
+}
+
+let%component make ?(is_attached : bool = false)
+ ?(orientation : [ `horizontal | `vertical ] = `horizontal)
+ ?(aria_label : string option) ?(aria_labelledby : string option)
+ ?(class_ : string option)
+ ?ref:(given_ref : (Dom.htmlDivElement -> unit) option)
+ ~(children : state Jsx.children)
+ ?(as_ : (Solidtype.Html.Div.props -> state -> Solidtype.Jsx.element) option)
+ () =
+ let along = S.accessor (fun () -> S.get orientation) in
+ let across =
+ S.accessor (fun () ->
+ match S.get orientation with
+ | `horizontal -> `vertical
+ | `vertical -> `horizontal)
+ in
+
+
+
+ ignore (given_ref e : unit option))
+ ?as_=(S.get as_)
+ props=(Props.others props)>
+ (fun state -> Jsx.draw (S.get children) state)
+
+
+
+
+[@@element div]
diff --git a/test/heroui/action_bar_test.mlx b/test/heroui/action_bar_test.mlx
new file mode 100644
index 0000000..942115c
--- /dev/null
+++ b/test/heroui/action_bar_test.mlx
@@ -0,0 +1,79 @@
+(* An action bar as a caller meets it, since it has no twin: nothing on the
+ page while it is closed; open, a toolbar of its name, attached, its parts
+ in their classes; gone again once it closes; and no violation axe
+ finds. *)
+
+module S = Solidtype.Solid
+module Action_bar = Solidtype_heroui.Action_bar
+module Button = Solidtype_heroui.Button
+module Chip = Solidtype_heroui.Chip
+module Separator = Solidtype_heroui.Separator
+module E = Jest.Expect
+module T = Testing
+open Testing.Syntax
+
+external query_all : Dom.element -> string -> Dom.element Js.Array.array_like
+ = "querySelectorAll"
+[@@mel.send]
+
+let all selector = Js.Array.from (query_all T.body selector)
+
+let bar is_open =
+ T.render (fun () ->
+
+ "2"
+
+
+
+
+
+
+
+
+ )
+
+let shown () =
+ all "[data-slot^=action-bar], [data-slot=toolbar]"
+ |> Array.map (fun e ->
+ (Option.value (T.attribute e "data-slot") ~default:"", T.class_name e))
+
+let () =
+ Jest.describe "Action_bar" (fun () ->
+ Jest.afterEach T.cleanup;
+ Jest.testPromise "is a toolbar while open, and nothing while closed"
+ (fun () ->
+ let is_open, set_open = S.create_signal false in
+ bar is_open;
+ let closed = shown () in
+ S.set set_open true;
+ let* () = T.wait 20 in
+ let opened = shown () in
+ let toolbar = T.by_role "toolbar" in
+ let named = T.attribute toolbar "aria-label" in
+ S.set set_open false;
+ let* () = T.wait 20 in
+ Js.Promise.resolve
+ E.(
+ expect (closed, opened, named, shown ())
+ |> toEqual
+ ( [||],
+ [|
+ ("action-bar", "action-bar");
+ ( "toolbar",
+ "toolbar toolbar--attached toolbar--horizontal \
+ action-bar__wrapper" );
+ ("action-bar-prefix", "action-bar__prefix");
+ ("action-bar-content", "action-bar__content");
+ ("action-bar-suffix", "action-bar__suffix");
+ |],
+ Some "Bulk actions",
+ [||] )));
+ Jest.testPromise "has no violation axe finds" (fun () ->
+ let is_open, _ = S.create_signal true in
+ bar is_open;
+ let* found = T.accessibility_violations () in
+ Js.Promise.resolve E.(expect found |> toEqual [||])))
diff --git a/test/heroui/autocomplete_test.mlx b/test/heroui/autocomplete_test.mlx
index dfec204..9b91f43 100644
--- a/test/heroui/autocomplete_test.mlx
+++ b/test/heroui/autocomplete_test.mlx
@@ -521,6 +521,46 @@ let focused () =
let () =
Jest.describe "Autocomplete, beyond React's" (fun () ->
Jest.afterEach T.cleanup;
+ Jest.testPromise
+ "keeps a press on a control in its value, its list left closed"
+ (fun () ->
+ let chosen, set_chosen = S.create_signal [| "texas"; "utah" |] in
+ T.render (fun () ->
+ S.set set_chosen keys)>
+
+
+
+ (fun value ->
+
+ (fun key _ ->
+ )
+ )
+
+
+
+
+ (search_and_list ())
+
+ );
+ let user = T.setup () in
+ let* () = T.click user (first "[aria-label=\"Remove texas\"]") in
+ let* () = settle () in
+ Js.Promise.resolve
+ E.(
+ expect (S.get chosen, Array.length (all "[role=listbox]"))
+ |> toEqual ([| "utah" |], 0)));
Jest.test "describes its button by no description it lacks" (fun () ->
T.render (fun () -> states (fun () -> ));
let described =
diff --git a/test/heroui/checkbox_group_test.mlx b/test/heroui/checkbox_group_test.mlx
index 33df8b2..bccac4b 100644
--- a/test/heroui/checkbox_group_test.mlx
+++ b/test/heroui/checkbox_group_test.mlx
@@ -10,6 +10,7 @@ module Fieldset = Solidtype_heroui.Fieldset
module Label = Solidtype_heroui.Label
module Form = Solidtype_heroui.Form
module E = Jest.Expect
+module Field_error = Solidtype_heroui.Field_error
module T = Testing
open Testing.Syntax
@@ -328,6 +329,51 @@ let () =
let () =
Jest.describe "Checkbox_group, left" (fun () ->
Jest.afterEach T.cleanup;
+ Jest.test
+ "shows its error while invalid, which describes it after its \
+ description" (fun () ->
+ let invalid, set_invalid = Solidtype.Solid.create_signal false in
+ T.render (fun () ->
+
+
+ "Pick any."
+
+
+
+ "Coding"
+
+
+ "Choose one at least"
+ );
+ let errors () =
+ Js.Array.from (query_all T.body "[data-slot=field-error]")
+ |> Array.map T.text_content
+ in
+ let before = errors () in
+ Solidtype.Solid.set set_invalid true;
+ let described e =
+ match T.attribute e "aria-describedby" with
+ | Some ids ->
+ String.split_on_char ' ' ids
+ |> List.filter_map (fun id ->
+ Option.map T.text_content (T.query ("#" ^ id)))
+ | None -> []
+ in
+ E.(
+ expect
+ ( before,
+ errors (),
+ described
+ (Option.value
+ (T.query "[data-slot=checkbox-group]")
+ ~default:T.body),
+ described (T.by_role "checkbox") )
+ |> toEqual
+ ( [||],
+ [| "Choose one at least" |],
+ [ "Pick any."; "Choose one at least" ],
+ [ "Pick any."; "Choose one at least" ] )));
Jest.test "tells it is left once focus leaves it, as React's does"
(fun () ->
let solidtype =
diff --git a/test/heroui/data_grid_test.mlx b/test/heroui/data_grid_test.mlx
index 0e42a3f..29c27a3 100644
--- a/test/heroui/data_grid_test.mlx
+++ b/test/heroui/data_grid_test.mlx
@@ -11,6 +11,8 @@ module Data_grid = Solidtype_heroui.Data_grid
module Table = Solidtype_heroui.Table
module Button = Solidtype_heroui.Button
module Dropdown = Solidtype_heroui.Dropdown
+module Autocomplete = Solidtype_heroui.Autocomplete
+module List_box = Solidtype_heroui.List_box
module E = Jest.Expect
module T = Testing
open Testing.Syntax
@@ -42,6 +44,9 @@ external query_all : Dom.element -> string -> Dom.element Js.Array.array_like
let all selector = Js.Array.from (query_all T.body selector)
+external parent : Dom.element -> Dom.element Js.Nullable.t = "parentElement"
+[@@mel.get]
+
external active : Dom.element = "activeElement" [@@mel.scope "document"]
external target_value : Dom.element -> string = "value" [@@mel.get]
external event_target : _ Dom.event_like -> Dom.element = "target" [@@mel.get]
@@ -285,6 +290,79 @@ let () =
(fun b -> T.attribute b "aria-expanded"),
all "[aria-selected=true]" |> Array.length )
|> toEqual (1, Some "true", 0)));
+ Jest.testPromise
+ "keeps a press on a group of controls in a cell, the row's action not \
+ run" (fun () ->
+ let acted = ref [||] in
+ T.render (fun () ->
+ p.id)
+ on_row_action=(fun key ->
+ acted := Array.append !acted [| key |])
+ columns=[|
+ Data_grid.column ~id:"customer"
+ ~header:(Text "Customer") ~is_row_header:true
+ (fun p -> Jsx.string (S.get p).customer);
+ Data_grid.column ~id:"tags" ~header:(Text "Tags")
+ (fun p ->
+
+
+
+
+
+
+
+
+ "VIP"
+
+
+ "New"
+
+
+
+ );
+ |]
+ />);
+ let user = T.setup () in
+ let value =
+ match all "[data-slot=autocomplete-value]" with
+ | [||] -> Js.Exn.raiseError "no value"
+ | values -> values.(1)
+ in
+ let* () = T.click user value in
+ let* () = T.wait 50 in
+ Js.Promise.resolve
+ E.(
+ expect (!acted, Array.length (all "[role=listbox]"))
+ |> toEqual ([||], 1)));
+ Jest.testPromise
+ "runs a row's action on a press in its cell, inside a group of its own"
+ (fun () ->
+ let acted = ref [||] in
+ T.render (fun () ->
+