@funstack/ui 0.1.0-alpha.20 → 0.1.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alert-dialog/alert-dialog-root.mjs +2 -1
- package/dist/alert-dialog/alert-dialog-root.mjs.map +1 -1
- package/dist/avatar/avatar-context.mjs +24 -0
- package/dist/avatar/avatar-context.mjs.map +1 -0
- package/dist/avatar/avatar-fallback.d.mts +32 -0
- package/dist/avatar/avatar-fallback.d.mts.map +1 -0
- package/dist/avatar/avatar-fallback.mjs +31 -0
- package/dist/avatar/avatar-fallback.mjs.map +1 -0
- package/dist/avatar/avatar-image.d.mts +37 -0
- package/dist/avatar/avatar-image.d.mts.map +1 -0
- package/dist/avatar/avatar-image.mjs +91 -0
- package/dist/avatar/avatar-image.mjs.map +1 -0
- package/dist/avatar/avatar-root.d.mts +48 -0
- package/dist/avatar/avatar-root.d.mts.map +1 -0
- package/dist/avatar/avatar-root.mjs +81 -0
- package/dist/avatar/avatar-root.mjs.map +1 -0
- package/dist/avatar/index.d.mts +24 -0
- package/dist/avatar/index.d.mts.map +1 -0
- package/dist/avatar/index.mjs +24 -0
- package/dist/avatar/index.mjs.map +1 -0
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +14 -3
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs +7 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +1 -0
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +20 -2
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.mjs +6 -4
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/docs/components/avatar.md +354 -0
- package/dist/docs/components/drawer.md +622 -0
- package/dist/docs/components/otp-field.md +501 -0
- package/dist/docs/components/scroll-area.md +294 -0
- package/dist/docs/index.md +5 -1
- package/dist/docs/roadmap.md +6 -0
- package/dist/drawer/drawer-close.d.mts +26 -0
- package/dist/drawer/drawer-close.d.mts.map +1 -0
- package/dist/drawer/drawer-close.mjs +19 -0
- package/dist/drawer/drawer-close.mjs.map +1 -0
- package/dist/drawer/drawer-description.d.mts +23 -0
- package/dist/drawer/drawer-description.d.mts.map +1 -0
- package/dist/drawer/drawer-description.mjs +18 -0
- package/dist/drawer/drawer-description.mjs.map +1 -0
- package/dist/drawer/drawer-form.d.mts +24 -0
- package/dist/drawer/drawer-form.d.mts.map +1 -0
- package/dist/drawer/drawer-form.mjs +19 -0
- package/dist/drawer/drawer-form.mjs.map +1 -0
- package/dist/drawer/drawer-popup.d.mts +77 -0
- package/dist/drawer/drawer-popup.d.mts.map +1 -0
- package/dist/drawer/drawer-popup.mjs +124 -0
- package/dist/drawer/drawer-popup.mjs.map +1 -0
- package/dist/drawer/drawer-root.d.mts +31 -0
- package/dist/drawer/drawer-root.d.mts.map +1 -0
- package/dist/drawer/drawer-root.mjs +23 -0
- package/dist/drawer/drawer-root.mjs.map +1 -0
- package/dist/drawer/drawer-swipe.d.mts +5 -0
- package/dist/drawer/drawer-swipe.d.mts.map +1 -0
- package/dist/drawer/drawer-swipe.mjs +193 -0
- package/dist/drawer/drawer-swipe.mjs.map +1 -0
- package/dist/drawer/drawer-title.d.mts +23 -0
- package/dist/drawer/drawer-title.d.mts.map +1 -0
- package/dist/drawer/drawer-title.mjs +18 -0
- package/dist/drawer/drawer-title.mjs.map +1 -0
- package/dist/drawer/drawer-trigger.d.mts +23 -0
- package/dist/drawer/drawer-trigger.d.mts.map +1 -0
- package/dist/drawer/drawer-trigger.mjs +18 -0
- package/dist/drawer/drawer-trigger.mjs.map +1 -0
- package/dist/drawer/index.d.mts +34 -0
- package/dist/drawer/index.d.mts.map +1 -0
- package/dist/drawer/index.mjs +33 -0
- package/dist/drawer/index.mjs.map +1 -0
- package/dist/index.d.mts +19 -1
- package/dist/index.mjs +4 -1
- package/dist/internal/swipe-arithmetic.mjs +75 -0
- package/dist/internal/swipe-arithmetic.mjs.map +1 -0
- package/dist/internal/swipe.mjs +169 -0
- package/dist/internal/swipe.mjs.map +1 -0
- package/dist/menu/menu-context-trigger.mjs +1 -1
- package/dist/menu/menu-popup.mjs +1 -1
- package/dist/otp-field/index.d.mts +23 -0
- package/dist/otp-field/index.d.mts.map +1 -0
- package/dist/otp-field/index.mjs +23 -0
- package/dist/otp-field/index.mjs.map +1 -0
- package/dist/otp-field/otp-field-context.mjs +13 -0
- package/dist/otp-field/otp-field-context.mjs.map +1 -0
- package/dist/otp-field/otp-field-filter.d.mts +5 -0
- package/dist/otp-field/otp-field-filter.d.mts.map +1 -0
- package/dist/otp-field/otp-field-filter.mjs +135 -0
- package/dist/otp-field/otp-field-filter.mjs.map +1 -0
- package/dist/otp-field/otp-field-input.d.mts +41 -0
- package/dist/otp-field/otp-field-input.d.mts.map +1 -0
- package/dist/otp-field/otp-field-input.mjs +177 -0
- package/dist/otp-field/otp-field-input.mjs.map +1 -0
- package/dist/otp-field/otp-field-root.d.mts +143 -0
- package/dist/otp-field/otp-field-root.d.mts.map +1 -0
- package/dist/otp-field/otp-field-root.mjs +397 -0
- package/dist/otp-field/otp-field-root.mjs.map +1 -0
- package/dist/otp-field/otp-field-slot.d.mts +52 -0
- package/dist/otp-field/otp-field-slot.d.mts.map +1 -0
- package/dist/otp-field/otp-field-slot.mjs +67 -0
- package/dist/otp-field/otp-field-slot.mjs.map +1 -0
- package/package.json +4 -1
- package/skills/funstack-ui-knowledge/SKILL.md +5 -1
|
@@ -22,7 +22,7 @@ Requirements: `react` and `react-dom` `>=19.3.0` (peer dependencies). ESM only.
|
|
|
22
22
|
|
|
23
23
|
## Things agents get wrong
|
|
24
24
|
|
|
25
|
-
1. **Do not use `onClick`, `onChange`, `onValueChange`, `onPressedChange`.** They do not exist as library props. Handlers a part installs itself (for example `onClick` on `Toggle`) are removed from its props type; unused DOM handlers pass through to the element. The library's own `on*` props report **facts** (changes that had already happened when the library heard of them, such as a popup dismissed with Escape): `onOpenChange` on `Popover.Root`, `Menu.Root`, `Combobox.Root`, `MultiSelect.Root`, `Dialog.Root` and `
|
|
25
|
+
1. **Do not use `onClick`, `onChange`, `onValueChange`, `onPressedChange`.** They do not exist as library props (the one `onValueChange` is `OTPField.Root`'s, below). Handlers a part installs itself (for example `onClick` on `Toggle`) are removed from its props type; unused DOM handlers pass through to the element. The library's own `on*` props report **facts** (changes that had already happened when the library heard of them, such as a popup dismissed with Escape): `onOpenChange` on `Popover.Root`, `Menu.Root`, `Combobox.Root`, `MultiSelect.Root`, `Dialog.Root`, `AlertDialog.Root` and `Drawer.Root` (dismissals only, always `false`), `Combobox.Root`'s `onInputValueChange` (input text), `OTPField.Root`'s `onValueChange` (the code's text), and a toast's `onClose` (`toast({ onClose })`, formerly `closeAction`). Each is called synchronously, outside any transition, not awaited; it may return a promise; a rejection, or a throw, goes to `reportError`.
|
|
26
26
|
2. **Do not wrap the action in `startTransition` yourself**, and do not add `useOptimistic` or a pending flag around a component: it already does this. But a `setState` that runs **after your own `await`** inside an action is outside the transition (a React rule); wrap that one in `startTransition`.
|
|
27
27
|
3. **Return a promise only if the UI must wait for it.** A pending async action holds every other transition in the app (including router navigations). For background work, do not return the promise: `valueChangeAction={(v) => { void save(v); }}`.
|
|
28
28
|
4. **No `asChild`, no `as`.** Use `render`: `render={<MyButton />}` (the element must accept `ref` and spread its props) or `render={(props, state) => <a {...props} />}`.
|
|
@@ -50,6 +50,7 @@ Each line: import path, parts, main state props.
|
|
|
50
50
|
- `Popover` (`@funstack/ui/popover`): `Root`, `Trigger`, `Popup`, `Close`, `Title`, `Description`. `open` / `openChangeAction` (requests) / `onOpenChange` (dismissals); without open props it needs no JavaScript.
|
|
51
51
|
- `Dialog` (`@funstack/ui/dialog`): `Root`, `Trigger`, `Popup` (`<dialog>`), `Close`, `Form`, `Title`, `Description`. Same modes as Popover; `Dialog.Form` closes after its form action settles. A `Close` with `action` (Dialog or Popover) renders no native command, so it does nothing before hydration; the JS-free way to run work and close is `Dialog.Form` with a Server Function.
|
|
52
52
|
- `AlertDialog` (`@funstack/ui/alert-dialog`): a Dialog for confirmations. `Root` (no `modal`: always modal), `Trigger`, `Popup` (`<dialog role="alertdialog">`, no `lightDismiss`: a backdrop click does nothing), `Title`, `Description` (expected: dev warning without one), `Cancel` (focused on open; `initialFocus` on the Popup overrides), `Action`, `Form`. Put the confirmed work in `<AlertDialog.Action action={() => deleteProject(id)}>`: it pends on the button and closes the dialog when it resolves; a rejection keeps it open (place an Error Boundary inside the Popup to show it; a caught error resolves and closes). An Action with `action` does nothing before hydration (as every Close part with `action`); the confirm that works without JavaScript is `AlertDialog.Form action={serverFunction}` with a plain submit button. Escape always closes it (a fact for `onOpenChange`; no prop turns it off), and so does Cancel while the Action is pending (in library mode that close waits for the action to settle and shows nothing meanwhile: disable Cancel with your own `useOptimistic` flag set inside the action when the work is slow). Same transition types and data attributes as Dialog.
|
|
53
|
+
- `Drawer` (`@funstack/ui/drawer`): a Dialog on an edge that the user can swipe away (a sheet). Same parts as Dialog (`Root`, `Trigger`, `Popup`, `Title`, `Description`, `Close`, `Form`), each running Dialog's code. `Drawer.Popup` adds `side` (`"top" | "bottom" | "left" | "right" | "inline-start" | "inline-end"`, default `"bottom"`, rendered as `data-side`; the library places nothing, your CSS does) and `swipeDismiss` (default `true`: mouse, pen and touch drag toward the edge; past 25% of the drawer or a 0.5 px/ms flick it closes, as a dismissal for `onOpenChange` with `details.event.type === "pointerup"`, never `openChangeAction`); `lightDismiss` defaults to the Root's `modal`. While dragging the Popup has `data-swiping` and inline `--drawer-swipe-x` / `--drawer-swipe-y` (px) / `--drawer-swipe-progress` (0 to 1): style `.drawer:open { translate: var(--drawer-swipe-x, 0px) var(--drawer-swipe-y, 0px) }`, a CSS `transition` on `translate` (the release waits for it, then closes), `[data-swiping] { transition: none }`, and closed positions inside `:where()` so `:open` wins. A press inside a scroll container along the drawer's axis never drags: a bottom sheet scrolls in a child with `overflow-y: auto` (the dialog `overflow: hidden`); the Popup renders an inline `touch-action`. Always render a `Drawer.Close` (dev warning without one). In a side drawer, `overflow-y: auto` on a child makes `overflow-x` compute to `auto`, so presses in that list never swipe (dev warning); give the list `overflow-x: hidden; touch-action: pan-y pinch-zoom` to swipe from it. Opt a region out with `onPointerDown={(e) => e.preventDefault()}`, which also stops a mouse press there from focusing or selecting: only on non-focusable regions (a map, a canvas). Scale the swipe variables only under `[data-swiping]` (the release writes the full extent). No snap points, no handle part, no background scaling (CSS recipe). Transition types `fsui-drawer*`.
|
|
53
54
|
- `Menu` (`@funstack/ui/menu`): `Root`, `Trigger`, `Popup`, `Item` (`action`), `CheckboxItem`, `RadioGroup`, `RadioItem`, `Group`, `GroupLabel`, `Separator`, `SubmenuTrigger`, `ContextTrigger` (context menu). A `Root` inside a `Popup` is a submenu.
|
|
54
55
|
- `Toast` (`@funstack/ui/toast`): `toast()` (also `toast.promise`, `toast.update`, `toast.dismiss`), `createToastManager`, parts `Viewport`, `Root`, `Title`, `Description`, `Action`, `Close`.
|
|
55
56
|
- `Field` (`@funstack/ui/field`): `Root`, `Label`, `Control`, `Description`, `Error`. Native constraint validation, no validation engine. A textarea is `<Field.Control render={<textarea />} />`, grown with CSS `field-sizing: content` (no auto-size prop). `Field.Control` also works outside a `Field.Root` as the plain control (it takes `id` there; the other parts throw). There is no Input, Textarea or Fieldset part: use the native elements, and group Fields in a native `<fieldset>` / `<legend>` (`<fieldset disabled>` disables every FUNSTACK control inside, but their `data-disabled` does not see it: select `:disabled`). Never disable a fieldset because a submission is pending (focus is lost); use `form[data-pending]`.
|
|
@@ -63,8 +64,11 @@ Each line: import path, parts, main state props.
|
|
|
63
64
|
- `MultiSelect` (`@funstack/ui/multi-select`): a select-only combobox for several values (JS listbox on a popover; nothing opens before hydration). `Root`, `Label`, `Trigger` (`button[role=combobox]`, the Tab stop), `Value`, `Popup`, `List`, `Option`, `Group`, `GroupLabel`, `Empty`, `Status`. `value` is `string[]` (pick order), `valueChangeAction(next, { added, removed })` (persist the diff); a pick toggles and keeps the listbox open; full open-state API (`open`, `openChangeAction`, `onOpenChange`). Show the selection with `<MultiSelect.Value>{({ value }) => value.map((v) => names[v]).join(", ")}</MultiSelect.Value>` (the library knows a label only after the option was rendered once). `required` (at least one) blocks the submit with no browser bubble: put it in a `Field.Root` with `Field.Error` for the message. No chips, no search, no Clear: for those use `Combobox multiple`.
|
|
64
65
|
- `Slider` (`@funstack/ui/slider`): `Root`, `Label`, `Track`, `Indicator`, `Thumb`, `Value`. `valueChangeAction` per step, `valueCommitAction` once per gesture; `value` is a number or `number[]`.
|
|
65
66
|
- `NumberField` (`@funstack/ui/number-field`): `Root`, `Label`, `Input`, `Increment`, `Decrement`. Locale-formatted; `valueChangeAction`, `valueCommitAction`.
|
|
67
|
+
- `OTPField` (`@funstack/ui/otp-field`): `Root` (`length` required, `charset` `"numeric"` default / `"alphanumeric"` / `"alphabetic"`), `Input` (the one `<input autocomplete="one-time-code">`; name it with a `<label for>`, `Field.Label` or `aria-label`), `Slot` (`index` required; `aria-hidden`, `data-filled`, `data-active`). The text is urgent: `value` / `defaultValue` / `onValueChange(next, details)` (a fact, no transition). `completeAction(value, details)` runs in the Root's transition each time an edit leaves the code complete (`data-pending` on Root and Input; every completion runs, no `whilePending`; not at mount, reset or a controlled change); a wrong code is not an error: resolve and show a message, `setCode("")` to clear. `submitOnComplete` (default `false`) calls `requestSubmit()` on the Input's form (tell the user before the field; keep a submit button). `experimental_webOTP` asks for the SMS code (Chromium, Safari). Pasted `123 456` becomes `123456`; no `maxlength`; text typed before hydration is invisible until hydration (use the `@media (scripting: none)` recipe on the docs page for no-JS pages).
|
|
66
68
|
- `Progress` (`@funstack/ui/progress`) and `Meter` (`@funstack/ui/meter`): `Root`, `Track`, `Indicator`, `Label`, `Value`. Output only, no actions; the Root renders in a Server Component.
|
|
67
69
|
- `Separator` (`@funstack/ui/separator`): a single `<hr>`; `orientation` (`"horizontal"` default, `"vertical"`), `decorative` (`role="none"`, no `aria-orientation`: for a purely visual line; it is also the separator element that is valid inside a Combobox or MultiSelect listbox, where a Group boundary styled in CSS is the other option). `data-orientation` always; reset the `<hr>`'s margin and border in CSS. No `"use client"`: a Server Component may render it. Inside a Toolbar, Menu or Select use their own `Separator` part.
|
|
70
|
+
- `Avatar` (`@funstack/ui/avatar`): `Root` (`span`; `alt` is **required**: a name gives `role="img"` + `aria-label`, `alt=""` gives `aria-hidden`), `Image` (`<img alt="">`, in the server HTML; removed once its source failed), `Fallback` (rendered until the image loaded; stack it **under** the image in one CSS grid cell, there is no `delay` prop). `data-status` / `state.status`: `"idle" | "loading" | "loaded" | "error"`, an urgent mirror; no action, no handler prop. Do not add `onLoad` to `Avatar.Image` unless you mean to opt it out of React's commit wait for images under a `<ViewTransition>`; do not wrap it in your own Suspense for the image. Nothing interactive inside the Root (wrap it in the link instead).
|
|
71
|
+
- No `ScrollArea`: style a native scroller with `scrollbar-width` / `scrollbar-color` / `scrollbar-gutter`; give one whose content has nothing focusable `tabindex="0"`, a role and a name (Safari gives it no Tab stop otherwise). Recipe page: `components/scroll-area`.
|
|
68
72
|
- `CSPProvider`, `STYLE_SHA256` (`@funstack/ui/csp`): for a strict `style-src` Content Security Policy.
|
|
69
73
|
|
|
70
74
|
## Full documentation
|