@funstack/ui 0.1.0-alpha.21 → 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/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 +8 -1
- package/dist/docs/components/progress.md +1 -1
- package/dist/docs/components/radio-group.md +1 -1
- package/dist/docs/components/slider.md +1 -1
- package/dist/docs/concepts/direction-and-locales.md +106 -0
- package/dist/docs/index.md +4 -1
- package/dist/docs/roadmap.md +7 -0
- package/dist/index.d.mts +11 -2
- package/dist/index.mjs +3 -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/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +33 -6
- 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/otp-field-root.d.mts +9 -0
- package/dist/otp-field/otp-field-root.d.mts.map +1 -1
- package/dist/otp-field/otp-field-root.mjs +5 -2
- package/dist/otp-field/otp-field-root.mjs.map +1 -1
- 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 +4 -1
- package/skills/funstack-ui-knowledge/SKILL.md +3 -0
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",
|
|
@@ -48,8 +48,10 @@
|
|
|
48
48
|
"./form": "./dist/form/index.mjs",
|
|
49
49
|
"./hover-card": "./dist/hover-card/index.mjs",
|
|
50
50
|
"./menu": "./dist/menu/index.mjs",
|
|
51
|
+
"./menubar": "./dist/menubar/index.mjs",
|
|
51
52
|
"./meter": "./dist/meter/index.mjs",
|
|
52
53
|
"./multi-select": "./dist/multi-select/index.mjs",
|
|
54
|
+
"./navigation-menu": "./dist/navigation-menu/index.mjs",
|
|
53
55
|
"./number-field": "./dist/number-field/index.mjs",
|
|
54
56
|
"./otp-field": "./dist/otp-field/index.mjs",
|
|
55
57
|
"./popover": "./dist/popover/index.mjs",
|
|
@@ -79,6 +81,7 @@
|
|
|
79
81
|
"@types/react": "^19.3.0",
|
|
80
82
|
"@types/react-dom": "^19.3.0",
|
|
81
83
|
"@vitest/browser-playwright": "^5.0.5",
|
|
84
|
+
"axe-core": "^4.14.1",
|
|
82
85
|
"jsdom": "^30.1.3",
|
|
83
86
|
"playwright": "^1.64.1",
|
|
84
87
|
"react": "^19.3.1",
|
|
@@ -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,6 +46,7 @@ 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.
|
|
@@ -52,6 +54,7 @@ Each line: import path, parts, main state props.
|
|
|
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.
|
|
53
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*`.
|
|
54
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.
|
|
55
58
|
- `Toast` (`@funstack/ui/toast`): `toast()` (also `toast.promise`, `toast.update`, `toast.dismiss`), `createToastManager`, parts `Viewport`, `Root`, `Title`, `Description`, `Action`, `Close`.
|
|
56
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]`.
|
|
57
60
|
- `Form` (`@funstack/ui/form`): `Root` (`action`, `errors` for server errors per field), `Submit`.
|