@funstack/ui 0.1.0-alpha.20 → 0.1.0-alpha.22
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/menu.md +1 -1
- package/dist/docs/components/menubar.md +309 -0
- package/dist/docs/components/meter.md +1 -1
- package/dist/docs/components/navigation-menu.md +501 -0
- package/dist/docs/components/number-field.md +2 -2
- package/dist/docs/components/otp-field.md +508 -0
- package/dist/docs/components/progress.md +1 -1
- package/dist/docs/components/radio-group.md +1 -1
- package/dist/docs/components/scroll-area.md +294 -0
- package/dist/docs/components/slider.md +1 -1
- package/dist/docs/concepts/direction-and-locales.md +106 -0
- package/dist/docs/index.md +8 -1
- package/dist/docs/roadmap.md +13 -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 +29 -2
- package/dist/index.mjs +6 -1
- package/dist/internal/menubar-context.mjs +12 -0
- package/dist/internal/menubar-context.mjs.map +1 -0
- package/dist/internal/overlay/trigger-ref.mjs +1 -1
- package/dist/internal/overlay/trigger-ref.mjs.map +1 -1
- package/dist/internal/overlay/use-overlay-root.mjs +3 -2
- package/dist/internal/overlay/use-overlay-root.mjs.map +1 -1
- package/dist/internal/overlay/use-popover-trigger.mjs +2 -2
- package/dist/internal/overlay/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/range-value.mjs +5 -3
- package/dist/internal/range-value.mjs.map +1 -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.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +34 -7
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +10 -3
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +53 -5
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/menubar/index.d.mts +3 -0
- package/dist/menubar/index.mjs +1 -0
- package/dist/menubar/menubar.d.mts +49 -0
- package/dist/menubar/menubar.d.mts.map +1 -0
- package/dist/menubar/menubar.mjs +147 -0
- package/dist/menubar/menubar.mjs.map +1 -0
- package/dist/meter/meter-root.d.mts +3 -2
- package/dist/meter/meter-root.d.mts.map +1 -1
- package/dist/meter/meter-root.mjs.map +1 -1
- package/dist/multi-select/multi-select-root.mjs +1 -1
- package/dist/multi-select/multi-select-trigger.mjs +1 -1
- package/dist/navigation-menu/index.d.mts +32 -0
- package/dist/navigation-menu/index.d.mts.map +1 -0
- package/dist/navigation-menu/index.mjs +32 -0
- package/dist/navigation-menu/index.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-context.mjs +19 -0
- package/dist/navigation-menu/navigation-menu-context.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-item.d.mts +79 -0
- package/dist/navigation-menu/navigation-menu-item.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-item.mjs +80 -0
- package/dist/navigation-menu/navigation-menu-item.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-link.d.mts +48 -0
- package/dist/navigation-menu/navigation-menu-link.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-link.mjs +66 -0
- package/dist/navigation-menu/navigation-menu-link.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-list.d.mts +33 -0
- package/dist/navigation-menu/navigation-menu-list.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-list.mjs +30 -0
- package/dist/navigation-menu/navigation-menu-list.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-popup.d.mts +102 -0
- package/dist/navigation-menu/navigation-menu-popup.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-popup.mjs +93 -0
- package/dist/navigation-menu/navigation-menu-popup.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-root.d.mts +33 -0
- package/dist/navigation-menu/navigation-menu-root.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-root.mjs +27 -0
- package/dist/navigation-menu/navigation-menu-root.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-trigger.d.mts +32 -0
- package/dist/navigation-menu/navigation-menu-trigger.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-trigger.mjs +42 -0
- package/dist/navigation-menu/navigation-menu-trigger.mjs.map +1 -0
- 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 +152 -0
- package/dist/otp-field/otp-field-root.d.mts.map +1 -0
- package/dist/otp-field/otp-field-root.mjs +400 -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/dist/popover/index.d.mts +1 -1
- package/dist/popover/popover-trigger.mjs +1 -1
- package/dist/progress/progress-root.d.mts +3 -2
- package/dist/progress/progress-root.d.mts.map +1 -1
- package/dist/progress/progress-root.mjs.map +1 -1
- package/package.json +7 -1
- package/skills/funstack-ui-knowledge/SKILL.md +8 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { OTPFieldState } from "./otp-field-root.mjs";
|
|
3
|
+
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
|
+
//#region src/otp-field/otp-field-slot.d.ts
|
|
5
|
+
/** The state a Slot's function props receive. */
|
|
6
|
+
export interface OTPFieldSlotState extends OTPFieldState {
|
|
7
|
+
/** The Slot's `index`. */
|
|
8
|
+
readonly index: number;
|
|
9
|
+
/** The character at `index`, or `null`. */
|
|
10
|
+
readonly char: string | null;
|
|
11
|
+
/** A character is at `index`. */
|
|
12
|
+
readonly filled: boolean;
|
|
13
|
+
/** The input is focused and the caret, or part of the selection, is at this position. */
|
|
14
|
+
readonly active: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Props of `OTPField.Slot`.
|
|
18
|
+
*
|
|
19
|
+
* @see https://ui.funstack.work/components/otp-field
|
|
20
|
+
*/
|
|
21
|
+
export interface OTPFieldSlotProps extends Omit<ComponentPropsWithRef<"span">, "className" | "style" | "children"> {
|
|
22
|
+
/** Which character position this slot shows, from `0`. */
|
|
23
|
+
index: number;
|
|
24
|
+
/** Class name, or a function of the state that returns one. */
|
|
25
|
+
className?: StateValue<string | undefined, OTPFieldSlotState>;
|
|
26
|
+
/** Inline style, or a function of the state that returns one. */
|
|
27
|
+
style?: StateValue<CSSProperties | undefined, OTPFieldSlotState>;
|
|
28
|
+
/**
|
|
29
|
+
* The content. Default: the character at `index`, or nothing. A function draws a placeholder,
|
|
30
|
+
* a dot, a caret element.
|
|
31
|
+
*/
|
|
32
|
+
children?: StateValue<ReactNode, OTPFieldSlotState>;
|
|
33
|
+
/** Replace the default `<span>` (element form) or take over rendering (function form). */
|
|
34
|
+
render?: RenderProp<ComponentPropsWithRef<"span">, OTPFieldSlotState>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* One character position of an OTPField (design/components/otp-field.md 1): a `span` drawn from
|
|
38
|
+
* the Input's text, `aria-hidden` (the input already says everything). Not focusable and never
|
|
39
|
+
* the pointer's target: the Input lies over it.
|
|
40
|
+
*
|
|
41
|
+
* Owned keys (conventions 1.2): `aria-hidden`, `data-index`, `data-filled`, `data-active`, and
|
|
42
|
+
* `pointer-events: none` in the inline style. The
|
|
43
|
+
* Root's attributes (`data-pending`, `data-complete`, …) style the Slots from above.
|
|
44
|
+
*
|
|
45
|
+
* @see https://ui.funstack.work/components/otp-field
|
|
46
|
+
*/
|
|
47
|
+
export declare function OTPFieldSlot({ index, className, style, children, render, ...rest }: OTPFieldSlotProps): ReactNode;
|
|
48
|
+
export declare namespace OTPFieldSlot {
|
|
49
|
+
var displayName: string;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//# sourceMappingURL=otp-field-slot.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp-field-slot.d.mts","names":[],"sources":["../../src/otp-field/otp-field-slot.tsx"],"mappings":";;;;;iBAWiB,0BAA0B;;WAEhC;;WAEA;;WAEA;;WAEA;;;;;;;iBAQM,0BAA0B,KACzC;;EAIA;;EAEA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;;;;EAK9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,+BAA+B;;;;;;;;;;;;;wBAyBrC,eACd,OACA,WACA,OACA,UACA,WACG,QACF,oBAAiB;yBAPJ"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { dataAttr } from "../internal/data-attr.mjs";
|
|
3
|
+
import { useRender } from "../internal/use-render.mjs";
|
|
4
|
+
import { useOTPFieldContext } from "./otp-field-context.mjs";
|
|
5
|
+
import { useCallback, useMemo } from "react";
|
|
6
|
+
//#region src/otp-field/otp-field-slot.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Never the pointer's target (design 1, 6): a Slot that forms a stacking context (`opacity`,
|
|
9
|
+
* `position`, `transform`, an animation of those) would otherwise paint over the Input and take
|
|
10
|
+
* the click. Owned; creates no stacking context of its own.
|
|
11
|
+
*/
|
|
12
|
+
const SLOT_STYLE = { pointerEvents: "none" };
|
|
13
|
+
function defaultChildren(state) {
|
|
14
|
+
return state.char;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* One character position of an OTPField (design/components/otp-field.md 1): a `span` drawn from
|
|
18
|
+
* the Input's text, `aria-hidden` (the input already says everything). Not focusable and never
|
|
19
|
+
* the pointer's target: the Input lies over it.
|
|
20
|
+
*
|
|
21
|
+
* Owned keys (conventions 1.2): `aria-hidden`, `data-index`, `data-filled`, `data-active`, and
|
|
22
|
+
* `pointer-events: none` in the inline style. The
|
|
23
|
+
* Root's attributes (`data-pending`, `data-complete`, …) style the Slots from above.
|
|
24
|
+
*
|
|
25
|
+
* @see https://ui.funstack.work/components/otp-field
|
|
26
|
+
*/
|
|
27
|
+
function OTPFieldSlot({ index, className, style, children, render, ...rest }) {
|
|
28
|
+
const { state, active, registerSlot } = useOTPFieldContext("OTPField.Slot");
|
|
29
|
+
const char = state.value[index] ?? null;
|
|
30
|
+
const isActive = index >= active[0] && index < active[1];
|
|
31
|
+
const slotState = useMemo(() => ({
|
|
32
|
+
...state,
|
|
33
|
+
index,
|
|
34
|
+
char,
|
|
35
|
+
filled: char !== null,
|
|
36
|
+
active: isActive
|
|
37
|
+
}), [
|
|
38
|
+
state,
|
|
39
|
+
index,
|
|
40
|
+
char,
|
|
41
|
+
isActive
|
|
42
|
+
]);
|
|
43
|
+
const ref = useCallback((element) => registerSlot(index, element), [registerSlot, index]);
|
|
44
|
+
const libraryProps = {
|
|
45
|
+
"aria-hidden": true,
|
|
46
|
+
"data-index": String(index),
|
|
47
|
+
"data-filled": dataAttr(char !== null),
|
|
48
|
+
"data-active": dataAttr(isActive),
|
|
49
|
+
style: SLOT_STYLE
|
|
50
|
+
};
|
|
51
|
+
return useRender({
|
|
52
|
+
defaultElement: "span",
|
|
53
|
+
render,
|
|
54
|
+
state: slotState,
|
|
55
|
+
className,
|
|
56
|
+
style,
|
|
57
|
+
children: children ?? defaultChildren,
|
|
58
|
+
props: rest,
|
|
59
|
+
libraryProps,
|
|
60
|
+
ref
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
OTPFieldSlot.displayName = "OTPFieldSlot";
|
|
64
|
+
//#endregion
|
|
65
|
+
export { OTPFieldSlot };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=otp-field-slot.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp-field-slot.mjs","names":[],"sources":["../../src/otp-field/otp-field-slot.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useMemo } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useOTPFieldContext } from \"./otp-field-context.js\";\nimport type { OTPFieldState } from \"./otp-field-root.js\";\n\n/** The state a Slot's function props receive. */\nexport interface OTPFieldSlotState extends OTPFieldState {\n /** The Slot's `index`. */\n readonly index: number;\n /** The character at `index`, or `null`. */\n readonly char: string | null;\n /** A character is at `index`. */\n readonly filled: boolean;\n /** The input is focused and the caret, or part of the selection, is at this position. */\n readonly active: boolean;\n}\n\n/**\n * Props of `OTPField.Slot`.\n *\n * @see https://ui.funstack.work/components/otp-field\n */\nexport interface OTPFieldSlotProps extends Omit<\n ComponentPropsWithRef<\"span\">,\n \"className\" | \"style\" | \"children\"\n> {\n /** Which character position this slot shows, from `0`. */\n index: number;\n /** Class name, or a function of the state that returns one. */\n className?: StateValue<string | undefined, OTPFieldSlotState>;\n /** Inline style, or a function of the state that returns one. */\n style?: StateValue<CSSProperties | undefined, OTPFieldSlotState>;\n /**\n * The content. Default: the character at `index`, or nothing. A function draws a placeholder,\n * a dot, a caret element.\n */\n children?: StateValue<ReactNode, OTPFieldSlotState>;\n /** Replace the default `<span>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"span\">, OTPFieldSlotState>;\n}\n\n/**\n * Never the pointer's target (design 1, 6): a Slot that forms a stacking context (`opacity`,\n * `position`, `transform`, an animation of those) would otherwise paint over the Input and take\n * the click. Owned; creates no stacking context of its own.\n */\nconst SLOT_STYLE: CSSProperties = { pointerEvents: \"none\" };\n\nfunction defaultChildren(state: OTPFieldSlotState): ReactNode {\n return state.char;\n}\n\n/**\n * One character position of an OTPField (design/components/otp-field.md 1): a `span` drawn from\n * the Input's text, `aria-hidden` (the input already says everything). Not focusable and never\n * the pointer's target: the Input lies over it.\n *\n * Owned keys (conventions 1.2): `aria-hidden`, `data-index`, `data-filled`, `data-active`, and\n * `pointer-events: none` in the inline style. The\n * Root's attributes (`data-pending`, `data-complete`, …) style the Slots from above.\n *\n * @see https://ui.funstack.work/components/otp-field\n */\nexport function OTPFieldSlot({\n index,\n className,\n style,\n children,\n render,\n ...rest\n}: OTPFieldSlotProps) {\n const ctx = useOTPFieldContext(\"OTPField.Slot\");\n const { state, active, registerSlot } = ctx;\n const char = state.value[index] ?? null;\n const isActive = index >= active[0] && index < active[1];\n\n const slotState = useMemo<OTPFieldSlotState>(\n () => ({ ...state, index, char, filled: char !== null, active: isActive }),\n [state, index, char, isActive],\n );\n\n const ref = useCallback(\n (element: HTMLElement) => registerSlot(index, element),\n [registerSlot, index],\n );\n\n const libraryProps: Partial<ComponentPropsWithRef<\"span\">> & DataAttributes = {\n \"aria-hidden\": true,\n \"data-index\": String(index),\n \"data-filled\": dataAttr(char !== null),\n \"data-active\": dataAttr(isActive),\n style: SLOT_STYLE,\n };\n\n return useRender<ComponentPropsWithRef<\"span\">, OTPFieldSlotState>({\n defaultElement: \"span\",\n render,\n state: slotState,\n className,\n style,\n children: children ?? defaultChildren,\n props: rest,\n libraryProps,\n ref,\n });\n}\n\nOTPFieldSlot.displayName = \"OTPFieldSlot\";\n"],"mappings":";;;;;;;;;;;AAmDA,MAAM,aAA4B,EAAE,eAAe,OAAO;AAE1D,SAAS,gBAAgB,OAAqC;CAC5D,OAAO,MAAM;AACf;;;;;;;;;;;;AAaA,SAAgB,aAAa,EAC3B,OACA,WACA,OACA,UACA,QACA,GAAG,QACiB;CAEpB,MAAM,EAAE,OAAO,QAAQ,iBADX,mBAAmB,eACW;CAC1C,MAAM,OAAO,MAAM,MAAM,UAAU;CACnC,MAAM,WAAW,SAAS,OAAO,MAAM,QAAQ,OAAO;CAEtD,MAAM,YAAY,eACT;EAAE,GAAG;EAAO;EAAO;EAAM,QAAQ,SAAS;EAAM,QAAQ;CAAS,IACxE;EAAC;EAAO;EAAO;EAAM;CAAQ,CAC/B;CAEA,MAAM,MAAM,aACT,YAAyB,aAAa,OAAO,OAAO,GACrD,CAAC,cAAc,KAAK,CACtB;CAEA,MAAM,eAAwE;EAC5E,eAAe;EACf,cAAc,OAAO,KAAK;EAC1B,eAAe,SAAS,SAAS,IAAI;EACrC,eAAe,SAAS,QAAQ;EAChC,OAAO;CACT;CAEA,OAAO,UAA4D;EACjE,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA,UAAU,YAAY;EACtB,OAAO;EACP;EACA;CACF,CAAC;AACH;AAEA,aAAa,cAAc"}
|
package/dist/popover/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "../internal/platform-attributes.mjs";
|
|
2
|
+
import { PopoverTrigger, PopoverTriggerProps, PopoverTriggerState } from "./popover-trigger.mjs";
|
|
2
3
|
import { PopoverClose, PopoverCloseProps, PopoverCloseState } from "./popover-close.mjs";
|
|
3
4
|
import { PopoverAlign, PopoverPopup, PopoverPopupProps, PopoverPopupState, PopoverSide } from "./popover-popup.mjs";
|
|
4
5
|
import { PopoverDescription, PopoverDescriptionProps, PopoverDescriptionState } from "./popover-description.mjs";
|
|
5
6
|
import { PopoverOpenChangeDetails, PopoverRoot, PopoverRootProps, PopoverRootState } from "./popover-root.mjs";
|
|
6
7
|
import { PopoverTitle, PopoverTitleProps, PopoverTitleState } from "./popover-title.mjs";
|
|
7
|
-
import { PopoverTrigger, PopoverTriggerProps, PopoverTriggerState } from "./popover-trigger.mjs";
|
|
8
8
|
//#region src/popover/index.d.ts
|
|
9
9
|
/**
|
|
10
10
|
* Popover built on `popover="auto"` and Invoker Commands: `Root` (no DOM) > `Trigger`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useRender } from "../internal/use-render.mjs";
|
|
3
|
-
import { usePopoverContext } from "./popover-context.mjs";
|
|
4
3
|
import { usePopoverTrigger } from "../internal/overlay/use-popover-trigger.mjs";
|
|
4
|
+
import { usePopoverContext } from "./popover-context.mjs";
|
|
5
5
|
//#region src/popover/popover-trigger.tsx
|
|
6
6
|
/**
|
|
7
7
|
* The toggle: `<button type="button" popovertarget>`, with no `aria-expanded`: the browser exposes
|
|
@@ -56,11 +56,12 @@ export interface ProgressRootProps extends Omit<ComponentPropsWithRef<"div">, "r
|
|
|
56
56
|
*/
|
|
57
57
|
format?: Intl.NumberFormatOptions;
|
|
58
58
|
/**
|
|
59
|
-
* BCP 47 tag for `Intl.NumberFormat`. Pass it when a client
|
|
59
|
+
* BCP 47 tag, or a preference list of tags, for `Intl.NumberFormat`. Pass it when a client
|
|
60
|
+
* tree is server-rendered.
|
|
60
61
|
*
|
|
61
62
|
* @defaultValue the runtime's locale
|
|
62
63
|
*/
|
|
63
|
-
locale?: string;
|
|
64
|
+
locale?: string | readonly string[];
|
|
64
65
|
/**
|
|
65
66
|
* The `aria-valuetext` to render instead of `formattedValue`. Called with the clamped value
|
|
66
67
|
* (`null` while indeterminate) and the state as it would be without this prop. Return `null`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress-root.d.mts","names":[],"sources":["../../src/progress/progress-root.tsx"],"mappings":";;;;iBAeiB;;WAEN;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA;;WAEA;;WAEA;;;;;;;iBAQM,0BAA0B,KACzC;;;;;;EAiBA;;;;;;EAMA;;;;;;EAMA;;;;;;;;EAQA,SAAS,KAAK
|
|
1
|
+
{"version":3,"file":"progress-root.d.mts","names":[],"sources":["../../src/progress/progress-root.tsx"],"mappings":";;;;iBAeiB;;WAEN;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA;;WAEA;;WAEA;;;;;;;iBAQM,0BAA0B,KACzC;;;;;;EAiBA;;;;;;EAMA;;;;;;EAMA;;;;;;;;EAQA,SAAS,KAAK;;;;;;;EAOd;;;;;;;;EAQA,oBAAoB,sBAAsB,OAAO;;EAEjD,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;wBAapC,eACd,OACA,KACA,KACA,QACA,QACA,kBACA,WACA,OACA,UACA,QACA,QACG,QACF,oCAAiB,IAAA;yBAbJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress-root.mjs","names":[],"sources":["../../src/progress/progress-root.tsx"],"sourcesContent":["// No \"use client\": `Progress.Root` uses only `useId`, arithmetic and `Intl`, and renders the\n// client context's provider (conventions 7.1's second exception). Rendered by a Server Component\n// it runs once, on the server (design/components/progress.md 8.1). It must not import from any\n// \"use client\" module except its context (checked by src/__tests__/directives.test.ts).\nimport { useId } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { warnOnce } from \"../internal/dev-warn.js\";\nimport { clamp, formatRangeValue, isDegenerate, percentage } from \"../internal/range-value.js\";\nimport { mergeRenderRef, renderElement, resolveStateValue } from \"../internal/render-element.js\";\nimport type { DataAttributes } from \"../internal/render-element.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { ProgressContext } from \"./progress-context.js\";\n\n/** The state every Progress part receives. */\nexport interface ProgressState {\n /** The value clamped to `[min, max]`, or `null` while indeterminate. */\n readonly value: number | null;\n /** The `min` prop. */\n readonly min: number;\n /** The `max` prop. */\n readonly max: number;\n /** `(value - min) / (max - min) * 100`, a number 0–100; `null` while indeterminate. */\n readonly percentage: number | null;\n /**\n * The `Intl.NumberFormat` text of the value (or of the fraction, for the percent style): what\n * `Progress.Value` shows. `null` while indeterminate.\n */\n readonly formattedValue: string | null;\n /** What `aria-valuetext` carries: `getAriaValueText`'s result, else `formattedValue`. */\n readonly valueText: string | null;\n /** `value` is `null`. */\n readonly indeterminate: boolean;\n /** The clamped value has reached `max`. */\n readonly complete: boolean;\n}\n\n/**\n * Props of `Progress.Root`.\n *\n * @see https://ui.funstack.work/components/progress\n */\nexport interface ProgressRootProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"role\"\n | \"aria-valuemin\"\n | \"aria-valuemax\"\n | \"aria-valuenow\"\n | \"aria-valuetext\"\n | \"defaultValue\"\n | \"defaultChecked\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * The current value. Absent or `null`: indeterminate. Clamped to `[min, max]`.\n *\n * @defaultValue `null`\n */\n value?: number | null;\n /**\n * Lower bound of the range.\n *\n * @defaultValue `0`\n */\n min?: number;\n /**\n * Upper bound of the range.\n *\n * @defaultValue `100`\n */\n max?: number;\n /**\n * `Intl.NumberFormat` options for `aria-valuetext` and `Progress.Value`. A `percent` style\n * formats the fraction of the range; any other style formats the value. Serialisable: a Server\n * Component may pass it.\n *\n * @defaultValue `{ style: \"percent\" }`\n */\n format?: Intl.NumberFormatOptions;\n /**\n * BCP 47 tag for `Intl.NumberFormat`. Pass it when a client tree is server-rendered.\n *\n * @defaultValue the runtime's locale\n */\n locale?: string;\n /**\n * The `aria-valuetext` to render instead of `formattedValue`. Called with the clamped value\n * (`null` while indeterminate) and the state as it would be without this prop. Return `null`\n * to render no `aria-valuetext`. A function: from a Server Component it works when this Root\n * is rendered by that Server Component (the Root runs on the server), not when the Root is\n * rendered by a client component.\n */\n getAriaValueText?: (value: number | null, state: ProgressState) => string | null | undefined;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, ProgressState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, ProgressState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, ProgressState>;\n /** Replace the default `<div>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ProgressState>;\n}\n\n/**\n * `Progress.Root`: a `div[role=progressbar]` with the ARIA values, `aria-valuetext` from\n * `Intl.NumberFormat`, `data-indeterminate` / `data-complete`, and `--progress-value` (the\n * percentage, absent while indeterminate) in `style`, where the consumer's entries win. Owned\n * keys: `role`, `aria-valuemin`, `aria-valuemax`, `aria-valuenow`, `aria-valuetext`,\n * `aria-labelledby` (token-merged: the consumer's tokens, then `Progress.Label`'s id, always),\n * `data-indeterminate`, `data-complete`.\n *\n * @see https://ui.funstack.work/components/progress\n */\nexport function ProgressRoot({\n value = null,\n min = 0,\n max = 100,\n format,\n locale,\n getAriaValueText,\n className,\n style,\n children,\n render,\n ref,\n ...rest\n}: ProgressRootProps) {\n const id = useId();\n\n let given = value;\n if (given !== null && !Number.isFinite(given)) {\n warnOnce(\n `Progress.Root:non-finite:${given}`,\n `Progress.Root: \\`value\\` is ${given}, which is not a finite number; the bar is rendered ` +\n \"as indeterminate. Pass `null` for an unknown value.\",\n );\n given = null;\n }\n const degenerate = isDegenerate(min, max);\n if (degenerate) {\n warnOnce(\n `Progress.Root:degenerate:${min}:${max}`,\n `Progress.Root: \\`max\\` (${max}) must be greater than \\`min\\` (${min}); the percentage is ` +\n \"rendered as 0. Pass `value={null}` while the total is unknown or empty.\",\n );\n }\n\n const clamped = given === null ? null : clamp(given, min, max);\n const formattedValue =\n clamped === null ? null : formatRangeValue(clamped, min, max, format, locale);\n const base: ProgressState = {\n value: clamped,\n min,\n max,\n percentage: clamped === null ? null : percentage(clamped, min, max),\n formattedValue,\n valueText: formattedValue,\n indeterminate: clamped === null,\n complete: clamped !== null && !degenerate && clamped >= max,\n };\n const valueText =\n getAriaValueText === undefined ? formattedValue : (getAriaValueText(clamped, base) ?? null);\n const state: ProgressState = valueText === base.valueText ? base : { ...base, valueText };\n\n const variables = state.percentage === null ? {} : { \"--progress-value\": `${state.percentage}%` };\n\n const libraryProps: Partial<ComponentPropsWithRef<\"div\">> & DataAttributes = {\n role: \"progressbar\",\n \"aria-valuemin\": min,\n \"aria-valuemax\": max,\n \"aria-valuenow\": clamped ?? undefined,\n \"aria-valuetext\": valueText ?? undefined,\n \"aria-labelledby\": `${id}-label`,\n \"data-indeterminate\": dataAttr(state.indeterminate),\n \"data-complete\": dataAttr(state.complete),\n };\n\n const element = renderElement<ComponentPropsWithRef<\"div\">, ProgressState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // The custom property loses to the consumer's own entry (design 3.1).\n style: (s) => ({ ...(variables as CSSProperties), ...resolveStateValue(style, s) }),\n children,\n props: rest,\n libraryProps,\n // Passed through to the element, never read during render.\n // oxlint-disable-next-line react/refs\n ref: mergeRenderRef(ref, render),\n });\n\n return <ProgressContext value={{ id, state }}>{element}</ProgressContext>;\n}\n\nProgressRoot.displayName = \"ProgressRoot\";\n"],"mappings":";;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"progress-root.mjs","names":[],"sources":["../../src/progress/progress-root.tsx"],"sourcesContent":["// No \"use client\": `Progress.Root` uses only `useId`, arithmetic and `Intl`, and renders the\n// client context's provider (conventions 7.1's second exception). Rendered by a Server Component\n// it runs once, on the server (design/components/progress.md 8.1). It must not import from any\n// \"use client\" module except its context (checked by src/__tests__/directives.test.ts).\nimport { useId } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { warnOnce } from \"../internal/dev-warn.js\";\nimport { clamp, formatRangeValue, isDegenerate, percentage } from \"../internal/range-value.js\";\nimport { mergeRenderRef, renderElement, resolveStateValue } from \"../internal/render-element.js\";\nimport type { DataAttributes } from \"../internal/render-element.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { ProgressContext } from \"./progress-context.js\";\n\n/** The state every Progress part receives. */\nexport interface ProgressState {\n /** The value clamped to `[min, max]`, or `null` while indeterminate. */\n readonly value: number | null;\n /** The `min` prop. */\n readonly min: number;\n /** The `max` prop. */\n readonly max: number;\n /** `(value - min) / (max - min) * 100`, a number 0–100; `null` while indeterminate. */\n readonly percentage: number | null;\n /**\n * The `Intl.NumberFormat` text of the value (or of the fraction, for the percent style): what\n * `Progress.Value` shows. `null` while indeterminate.\n */\n readonly formattedValue: string | null;\n /** What `aria-valuetext` carries: `getAriaValueText`'s result, else `formattedValue`. */\n readonly valueText: string | null;\n /** `value` is `null`. */\n readonly indeterminate: boolean;\n /** The clamped value has reached `max`. */\n readonly complete: boolean;\n}\n\n/**\n * Props of `Progress.Root`.\n *\n * @see https://ui.funstack.work/components/progress\n */\nexport interface ProgressRootProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"role\"\n | \"aria-valuemin\"\n | \"aria-valuemax\"\n | \"aria-valuenow\"\n | \"aria-valuetext\"\n | \"defaultValue\"\n | \"defaultChecked\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * The current value. Absent or `null`: indeterminate. Clamped to `[min, max]`.\n *\n * @defaultValue `null`\n */\n value?: number | null;\n /**\n * Lower bound of the range.\n *\n * @defaultValue `0`\n */\n min?: number;\n /**\n * Upper bound of the range.\n *\n * @defaultValue `100`\n */\n max?: number;\n /**\n * `Intl.NumberFormat` options for `aria-valuetext` and `Progress.Value`. A `percent` style\n * formats the fraction of the range; any other style formats the value. Serialisable: a Server\n * Component may pass it.\n *\n * @defaultValue `{ style: \"percent\" }`\n */\n format?: Intl.NumberFormatOptions;\n /**\n * BCP 47 tag, or a preference list of tags, for `Intl.NumberFormat`. Pass it when a client\n * tree is server-rendered.\n *\n * @defaultValue the runtime's locale\n */\n locale?: string | readonly string[];\n /**\n * The `aria-valuetext` to render instead of `formattedValue`. Called with the clamped value\n * (`null` while indeterminate) and the state as it would be without this prop. Return `null`\n * to render no `aria-valuetext`. A function: from a Server Component it works when this Root\n * is rendered by that Server Component (the Root runs on the server), not when the Root is\n * rendered by a client component.\n */\n getAriaValueText?: (value: number | null, state: ProgressState) => string | null | undefined;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, ProgressState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, ProgressState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, ProgressState>;\n /** Replace the default `<div>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ProgressState>;\n}\n\n/**\n * `Progress.Root`: a `div[role=progressbar]` with the ARIA values, `aria-valuetext` from\n * `Intl.NumberFormat`, `data-indeterminate` / `data-complete`, and `--progress-value` (the\n * percentage, absent while indeterminate) in `style`, where the consumer's entries win. Owned\n * keys: `role`, `aria-valuemin`, `aria-valuemax`, `aria-valuenow`, `aria-valuetext`,\n * `aria-labelledby` (token-merged: the consumer's tokens, then `Progress.Label`'s id, always),\n * `data-indeterminate`, `data-complete`.\n *\n * @see https://ui.funstack.work/components/progress\n */\nexport function ProgressRoot({\n value = null,\n min = 0,\n max = 100,\n format,\n locale,\n getAriaValueText,\n className,\n style,\n children,\n render,\n ref,\n ...rest\n}: ProgressRootProps) {\n const id = useId();\n\n let given = value;\n if (given !== null && !Number.isFinite(given)) {\n warnOnce(\n `Progress.Root:non-finite:${given}`,\n `Progress.Root: \\`value\\` is ${given}, which is not a finite number; the bar is rendered ` +\n \"as indeterminate. Pass `null` for an unknown value.\",\n );\n given = null;\n }\n const degenerate = isDegenerate(min, max);\n if (degenerate) {\n warnOnce(\n `Progress.Root:degenerate:${min}:${max}`,\n `Progress.Root: \\`max\\` (${max}) must be greater than \\`min\\` (${min}); the percentage is ` +\n \"rendered as 0. Pass `value={null}` while the total is unknown or empty.\",\n );\n }\n\n const clamped = given === null ? null : clamp(given, min, max);\n const formattedValue =\n clamped === null ? null : formatRangeValue(clamped, min, max, format, locale);\n const base: ProgressState = {\n value: clamped,\n min,\n max,\n percentage: clamped === null ? null : percentage(clamped, min, max),\n formattedValue,\n valueText: formattedValue,\n indeterminate: clamped === null,\n complete: clamped !== null && !degenerate && clamped >= max,\n };\n const valueText =\n getAriaValueText === undefined ? formattedValue : (getAriaValueText(clamped, base) ?? null);\n const state: ProgressState = valueText === base.valueText ? base : { ...base, valueText };\n\n const variables = state.percentage === null ? {} : { \"--progress-value\": `${state.percentage}%` };\n\n const libraryProps: Partial<ComponentPropsWithRef<\"div\">> & DataAttributes = {\n role: \"progressbar\",\n \"aria-valuemin\": min,\n \"aria-valuemax\": max,\n \"aria-valuenow\": clamped ?? undefined,\n \"aria-valuetext\": valueText ?? undefined,\n \"aria-labelledby\": `${id}-label`,\n \"data-indeterminate\": dataAttr(state.indeterminate),\n \"data-complete\": dataAttr(state.complete),\n };\n\n const element = renderElement<ComponentPropsWithRef<\"div\">, ProgressState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // The custom property loses to the consumer's own entry (design 3.1).\n style: (s) => ({ ...(variables as CSSProperties), ...resolveStateValue(style, s) }),\n children,\n props: rest,\n libraryProps,\n // Passed through to the element, never read during render.\n // oxlint-disable-next-line react/refs\n ref: mergeRenderRef(ref, render),\n });\n\n return <ProgressContext value={{ id, state }}>{element}</ProgressContext>;\n}\n\nProgressRoot.displayName = \"ProgressRoot\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoHA,SAAgB,aAAa,EAC3B,QAAQ,MACR,MAAM,GACN,MAAM,KACN,QACA,QACA,kBACA,WACA,OACA,UACA,QACA,KACA,GAAG,QACiB;CACpB,MAAM,KAAK,MAAM;CAEjB,IAAI,QAAQ;CACZ,IAAI,UAAU,QAAQ,CAAC,OAAO,SAAS,KAAK,GAAG;EAC7C,SACE,4BAA4B,SAC5B,+BAA+B,MAAM,0GAEvC;EACA,QAAQ;CACV;CACA,MAAM,aAAa,aAAa,KAAK,GAAG;CACxC,IAAI,YACF,SACE,4BAA4B,IAAI,GAAG,OACnC,2BAA2B,IAAI,kCAAkC,IAAI,+FAEvE;CAGF,MAAM,UAAU,UAAU,OAAO,OAAO,MAAM,OAAO,KAAK,GAAG;CAC7D,MAAM,iBACJ,YAAY,OAAO,OAAO,iBAAiB,SAAS,KAAK,KAAK,QAAQ,MAAM;CAC9E,MAAM,OAAsB;EAC1B,OAAO;EACP;EACA;EACA,YAAY,YAAY,OAAO,OAAO,WAAW,SAAS,KAAK,GAAG;EAClE;EACA,WAAW;EACX,eAAe,YAAY;EAC3B,UAAU,YAAY,QAAQ,CAAC,cAAc,WAAW;CAC1D;CACA,MAAM,YACJ,qBAAqB,KAAA,IAAY,iBAAkB,iBAAiB,SAAS,IAAI,KAAK;CACxF,MAAM,QAAuB,cAAc,KAAK,YAAY,OAAO;EAAE,GAAG;EAAM;CAAU;CAExF,MAAM,YAAY,MAAM,eAAe,OAAO,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,WAAW,GAAG;CAEhG,MAAM,eAAuE;EAC3E,MAAM;EACN,iBAAiB;EACjB,iBAAiB;EACjB,iBAAiB,WAAW,KAAA;EAC5B,kBAAkB,aAAa,KAAA;EAC/B,mBAAmB,GAAG,GAAG;EACzB,sBAAsB,SAAS,MAAM,aAAa;EAClD,iBAAiB,SAAS,MAAM,QAAQ;CAC1C;CAEA,MAAM,UAAU,cAA2D;EACzE,gBAAgB;EAChB;EACA;EACA;EAEA,QAAQ,OAAO;GAAE,GAAI;GAA6B,GAAG,kBAAkB,OAAO,CAAC;EAAE;EACjF;EACA,OAAO;EACP;EAGA,KAAK,eAAe,KAAK,MAAM;CACjC,CAAC;CAED,OAAO,oBAAC,iBAAD;EAAiB,OAAO;GAAE;GAAI;EAAM;EAAI,UAAA;CAAyB,CAAA;AAC1E;AAEA,aAAa,cAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funstack/ui",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.22",
|
|
4
4
|
"description": "Headless UI library for React — the first Async React-native UI library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
".": "./dist/index.mjs",
|
|
36
36
|
"./accordion": "./dist/accordion/index.mjs",
|
|
37
37
|
"./alert-dialog": "./dist/alert-dialog/index.mjs",
|
|
38
|
+
"./avatar": "./dist/avatar/index.mjs",
|
|
38
39
|
"./button": "./dist/button/index.mjs",
|
|
39
40
|
"./checkbox": "./dist/checkbox/index.mjs",
|
|
40
41
|
"./checkbox-group": "./dist/checkbox-group/index.mjs",
|
|
@@ -42,13 +43,17 @@
|
|
|
42
43
|
"./combobox": "./dist/combobox/index.mjs",
|
|
43
44
|
"./csp": "./dist/csp/index.mjs",
|
|
44
45
|
"./dialog": "./dist/dialog/index.mjs",
|
|
46
|
+
"./drawer": "./dist/drawer/index.mjs",
|
|
45
47
|
"./field": "./dist/field/index.mjs",
|
|
46
48
|
"./form": "./dist/form/index.mjs",
|
|
47
49
|
"./hover-card": "./dist/hover-card/index.mjs",
|
|
48
50
|
"./menu": "./dist/menu/index.mjs",
|
|
51
|
+
"./menubar": "./dist/menubar/index.mjs",
|
|
49
52
|
"./meter": "./dist/meter/index.mjs",
|
|
50
53
|
"./multi-select": "./dist/multi-select/index.mjs",
|
|
54
|
+
"./navigation-menu": "./dist/navigation-menu/index.mjs",
|
|
51
55
|
"./number-field": "./dist/number-field/index.mjs",
|
|
56
|
+
"./otp-field": "./dist/otp-field/index.mjs",
|
|
52
57
|
"./popover": "./dist/popover/index.mjs",
|
|
53
58
|
"./progress": "./dist/progress/index.mjs",
|
|
54
59
|
"./radio-group": "./dist/radio-group/index.mjs",
|
|
@@ -76,6 +81,7 @@
|
|
|
76
81
|
"@types/react": "^19.3.0",
|
|
77
82
|
"@types/react-dom": "^19.3.0",
|
|
78
83
|
"@vitest/browser-playwright": "^5.0.5",
|
|
84
|
+
"axe-core": "^4.14.1",
|
|
79
85
|
"jsdom": "^30.1.3",
|
|
80
86
|
"playwright": "^1.64.1",
|
|
81
87
|
"react": "^19.3.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} />}`.
|
|
@@ -33,6 +33,7 @@ Requirements: `react` and `react-dom` `>=19.3.0` (peer dependencies). ESM only.
|
|
|
33
33
|
9. **Server Components**: parts are `"use client"` modules, so a Server Component can render them, but it can only pass serialisable props. A Server Function (`"use server"`) can be passed directly to any action prop; a plain function cannot.
|
|
34
34
|
10. **Panels never get `data-pending`.** To style content while the next one loads, select through the Root (`.tabs[data-pending] .panel { opacity: .6 }`). Dialog and Popover Roots render no element: use the Trigger's `data-pending` instead.
|
|
35
35
|
11. **Toasts need a viewport.** Render `<Toast.Viewport>` once (its `children` is a function of `{ toasts }`), then call `toast({ title })` anywhere on the client.
|
|
36
|
+
12. **No `DirectionProvider`, no `LocaleProvider`.** Right-to-left is the native `dir` attribute (on `<html>`, a container or a part); components read the computed CSS `direction`, and only ArrowLeft / ArrowRight of a horizontal orientation mirror. `OTPField.Root` renders `dir="ltr"` unless you pass `dir`. `locale` (`string | readonly string[]`) is a prop of `NumberField.Root`, `Progress.Root` and `Meter.Root`; pass it on server-rendered pages. Docs page: `concepts/direction-and-locales`.
|
|
36
37
|
|
|
37
38
|
## Component index
|
|
38
39
|
|
|
@@ -45,12 +46,15 @@ Each line: import path, parts, main state props.
|
|
|
45
46
|
- `Tabs` (`@funstack/ui/tabs`): `Root`, `List`, `Tab`, `Panel`, `Indicator`. `value` / `valueChangeAction`; `Panel` takes `transition`, `keepMounted`.
|
|
46
47
|
- `Accordion` (`@funstack/ui/accordion`): `Root`, `Item` (`<details>`), `Trigger` (`<summary>`, first child of the Item), `Panel`. Without value props it needs no JavaScript; `exclusive` for one open item.
|
|
47
48
|
- `Collapsible` (`@funstack/ui/collapsible`): `Root` (the `<details>` itself), `Trigger` (`<summary>`, first child of the Root), `Panel`. One disclosure; use it rather than a lone `Accordion.Item`. `open` / `defaultOpen` / `openChangeAction` (no `onOpenChange`: find-in-page arrives as `reason: "platform"`); with none of them it needs no JavaScript, and `defaultOpen` alone (even `false`) selects library mode.
|
|
49
|
+
- `NavigationMenu` (`@funstack/ui/navigation-menu`): a site's main navigation, the disclosure pattern (no menu roles, no arrow keys, Tab through everything). `Root` (`nav`; name it), `List` (`ul[role=list]`), `Item` (`li`; owns one panel's open state with Popover's props), `Trigger` (`button[popovertarget]`), `Popup` (`div[popover=auto]`, no role; render it immediately after the Trigger), `Link` (`a`; `render={<RouterLink />}`; mark the current page with `aria-current="page"` yourself). Without open props on an Item it needs no JavaScript (the browser toggles, keeps one panel open, Escape, light dismiss) and the whole navigation can be written in a Server Component. After hydration focus leaving an Item and a followed `Link` inside a Popup (primary button, no modifier; `closeOnActivate={false}` opts out) close the panel. `openChangeAction` on an Item selects library mode: content that suspends holds the open (Trigger `data-pending`), `transition` on the Popup. The Link's close does not wait for a router's next page. Opens on click only.
|
|
48
50
|
- `Tooltip` (`@funstack/ui/tooltip`): `Root`, `Trigger`, `Popup`, `Arrow`. Open state is the browser's (no open props); `delay`, `closeDelay`.
|
|
49
51
|
- `HoverCard` (`@funstack/ui/hover-card`): `Root`, `Trigger` (a link), `Popup` (render it right after the Trigger; `render={<span />}` inside running text). Opens on hover or keyboard focus after `delay` (600) as a request (`openChangeAction(true)`, content mounts in the transition and may suspend, Trigger `data-pending`); every close (lost interest after `closeDelay` 300, Escape, a press outside or on the link) is a fact for `onOpenChange(false)`. Content must be supplementary (nothing on touch); a click-to-open card is a Popover.
|
|
50
52
|
- `Popover` (`@funstack/ui/popover`): `Root`, `Trigger`, `Popup`, `Close`, `Title`, `Description`. `open` / `openChangeAction` (requests) / `onOpenChange` (dismissals); without open props it needs no JavaScript.
|
|
51
53
|
- `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
54
|
- `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.
|
|
55
|
+
- `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
56
|
- `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.
|
|
57
|
+
- `Menubar` (`@funstack/ui/menubar`): one element, `<div role="menubar">`, around ordinary top-level `Menu.Root`s (no `Menubar.Menu` / `Menubar.Trigger`: use the Menu parts). Name it with `aria-label`; `loop` (default `true`). Each `Menu.Trigger` inside becomes an item of the bar (`role="menuitem"`, one Tab stop, Left / Right / Home / End; `disabled` renders `aria-disabled` and stays focusable; do not pass `tabIndex`). Each menu keeps its own `open` / `openChangeAction` / `onOpenChange`; the bar holds no state. A switch (ArrowRight / ArrowLeft inside a menu, the arrows on the Trigger of an open menu, the pointer moving onto another Trigger while a menu is open) closes the old menu as a dismissal (`onOpenChange(false, "dismiss")`) and requests the new one (`openChangeAction(true, "activate")`, `data-pending` on its Trigger while items load). Hover does nothing while every menu is closed. Application menus only; site navigation is not a menubar. No vertical orientation, no typeahead between Triggers, no items directly in the bar.
|
|
54
58
|
- `Toast` (`@funstack/ui/toast`): `toast()` (also `toast.promise`, `toast.update`, `toast.dismiss`), `createToastManager`, parts `Viewport`, `Root`, `Title`, `Description`, `Action`, `Close`.
|
|
55
59
|
- `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]`.
|
|
56
60
|
- `Form` (`@funstack/ui/form`): `Root` (`action`, `errors` for server errors per field), `Submit`.
|
|
@@ -63,8 +67,11 @@ Each line: import path, parts, main state props.
|
|
|
63
67
|
- `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
68
|
- `Slider` (`@funstack/ui/slider`): `Root`, `Label`, `Track`, `Indicator`, `Thumb`, `Value`. `valueChangeAction` per step, `valueCommitAction` once per gesture; `value` is a number or `number[]`.
|
|
65
69
|
- `NumberField` (`@funstack/ui/number-field`): `Root`, `Label`, `Input`, `Increment`, `Decrement`. Locale-formatted; `valueChangeAction`, `valueCommitAction`.
|
|
70
|
+
- `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
71
|
- `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
72
|
- `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.
|
|
73
|
+
- `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).
|
|
74
|
+
- 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
75
|
- `CSPProvider`, `STYLE_SHA256` (`@funstack/ui/csp`): for a strict `style-src` Content Security Policy.
|
|
69
76
|
|
|
70
77
|
## Full documentation
|