// The app scripts/check-solid.ts renders on the server and hydrates in the // browser. Solid JSX, compiled by babel-preset-solid as a Solid app's build // compiles it. Built against dist/solid. import { createSignal, For, onMount, Show } from "solid-js"; import { Button, Checkbox, List, ListItem, NavigationRail, NavigationRailItem, Progress, Radio, Radios, Slider, Switch, Tab, Tabs, Textfield, } from "../../dist/solid/index.js"; import type { SwitchElement } from "../../dist/elements/index.js"; import { Chip, Chips } from "../../dist/solid/index.js"; import { Select, SelectOption } from "../../dist/solid/index.js"; import { Dialog } from "../../dist/solid/index.js"; import { Datepicker } from "../../dist/solid/index.js"; import { Search, SearchSuggestion } from "../../dist/solid/index.js"; const ICON = ''; // The suggestions a search offers, filtered by the query as the user types. const FRUITS = ["Apple", "Apricot", "Banana"]; export const App = () => { const log: Array<{ id: string; detail: unknown }> = []; let submits = 0; const [controlled, setControlled] = createSignal(false); const [agreed, setAgreed] = createSignal(false); const [level, setLevel] = createSignal(50); const [text, setText] = createSignal(""); const [size, setSize] = createSignal("m"); const [diet, setDiet] = createSignal(["veg"]); const [tab, setTab] = createSignal("t2"); const [destination, setDestination] = createSignal("inbox"); const [extra, setExtra] = createSignal(false); const [order, setOrder] = createSignal(["a", "b"]); const [show, setShow] = createSignal(true); const [progress, setProgress] = createSignal(30); const [fruit, setFruit] = createSignal("b"); const [pet, setPet] = createSignal("cat"); const [dialog, setDialog] = createSignal(false); const [dialogText, setDialogText] = createSignal("Your changes will be lost."); const [rail, setRail] = createSignal(false); const [due, setDue] = createSignal("2026-09-10"); const [query, setQuery] = createSignal("ap"); let switchRef: SwitchElement | undefined; const record = (id: string) => (event: CustomEvent) => log.push({ id, detail: event.detail }); onMount(() => { (window as unknown as { api: unknown }).api = { log, get submits() { return submits; }, setControlled, setExtra, setOrder, setShow, setProgress, setDialog, setRail, setDialogText, element: () => switchRef, }; }); return (
{ e.preventDefault(); submits++; }}> Uncontrolled setControlled(e.detail.checked)}>Controlled Disabled
setTab(e.detail.value)}> Flights Trips Hotels {String(tab())} {String(controlled())} setAgreed(e.detail.checked)}>Agree {String(agreed())} setLevel(e.detail.value)} /> {String(level())} setText(e.detail.value)} /> {text()} setSize(e.detail.value)}> Small Medium Large {String(size())} setDestination(e.detail.value)}> Inbox Sent Starred {String(destination())} setDiet(e.detail.value)}> Vegetarian Gluten free {String(diet())} setFruit(e.detail.value)}> Apple Banana Cherry {String(fruit())} {String(pet())} {/* Controlled: Escape closes the dialog, and onClose puts the state in step */} {/* Named slots as props (FLO-333): JSX for the headline, a component in actions */} setDialog(false)} headline={Discard draft?} actions={}> {dialogText()} {String(dialog())} {/* Controlled: expanded is state; Escape collapses the modal rail, and onCollapse puts the state in step */} setRail(true)} onCollapse={() => setRail(false)}> Inbox Sent {String(rail())} setDue(e.detail.value)} /> {due()} {/* Controlled, its suggestions replaced as the query changes */} setQuery(e.detail.value)} onSelect={(e) => setQuery(e.detail.value)}> f.toLowerCase().includes(query().toLowerCase()))}> {(f) => {f}} {query()} {(key) => Order {key}} Gone {/* Mounted in the browser after the element is defined: Solid writes a key the element has as a property. */} Late
); };