@nibapp/ui 0.0.0-stage → 0.1.0
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/CHANGELOG.md +35 -0
- package/LICENSE +21 -0
- package/README.md +124 -2
- package/TRADEMARKS.md +22 -0
- package/dist/_bundled/money/index.d.ts +98 -0
- package/dist/_bundled/money/index.js +152 -0
- package/dist/_bundled/tokens/index.d.ts +2 -0
- package/dist/_bundled/tokens/index.js +2 -0
- package/dist/_bundled/tokens/palette.gen.d.ts +51 -0
- package/dist/_bundled/tokens/palette.gen.js +206 -0
- package/dist/_bundled/tokens/spec.d.ts +291 -0
- package/dist/_bundled/tokens/spec.js +221 -0
- package/dist/components/accordion.d.ts +27 -0
- package/dist/components/accordion.js +66 -0
- package/dist/components/alert-dialog.d.ts +59 -0
- package/dist/components/alert-dialog.js +82 -0
- package/dist/components/alert.d.ts +141 -0
- package/dist/components/alert.js +55 -0
- package/dist/components/appear.d.ts +21 -0
- package/dist/components/appear.js +42 -0
- package/dist/components/avatar.d.ts +196 -0
- package/dist/components/avatar.js +135 -0
- package/dist/components/badge.d.ts +183 -0
- package/dist/components/badge.js +68 -0
- package/dist/components/block-stack.d.ts +33 -0
- package/dist/components/block-stack.js +197 -0
- package/dist/components/button.d.ts +327 -0
- package/dist/components/button.js +101 -0
- package/dist/components/card.d.ts +131 -0
- package/dist/components/card.js +100 -0
- package/dist/components/checkbox.d.ts +34 -0
- package/dist/components/checkbox.js +37 -0
- package/dist/components/choice-row.d.ts +104 -0
- package/dist/components/choice-row.js +56 -0
- package/dist/components/clamped-text.d.ts +17 -0
- package/dist/components/clamped-text.js +47 -0
- package/dist/components/code-block.d.ts +48 -0
- package/dist/components/code-block.js +124 -0
- package/dist/components/code-input.d.ts +49 -0
- package/dist/components/code-input.js +59 -0
- package/dist/components/combobox.d.ts +194 -0
- package/dist/components/combobox.js +176 -0
- package/dist/components/command-palette.d.ts +57 -0
- package/dist/components/command-palette.js +83 -0
- package/dist/components/context-menu.d.ts +24 -0
- package/dist/components/context-menu.js +30 -0
- package/dist/components/copy-button.d.ts +9 -0
- package/dist/components/copy-button.js +20 -0
- package/dist/components/copy-command.d.ts +18 -0
- package/dist/components/copy-command.js +19 -0
- package/dist/components/data-table.d.ts +240 -0
- package/dist/components/data-table.js +63 -0
- package/dist/components/dialog.d.ts +80 -0
- package/dist/components/dialog.js +85 -0
- package/dist/components/diff-lines.d.ts +20 -0
- package/dist/components/diff-lines.js +10 -0
- package/dist/components/diff-view.d.ts +128 -0
- package/dist/components/diff-view.js +675 -0
- package/dist/components/disclosure.d.ts +33 -0
- package/dist/components/disclosure.js +51 -0
- package/dist/components/drawn-check.d.ts +8 -0
- package/dist/components/drawn-check.js +16 -0
- package/dist/components/edge-resizer.d.ts +26 -0
- package/dist/components/edge-resizer.js +53 -0
- package/dist/components/empty-state.d.ts +112 -0
- package/dist/components/empty-state.js +56 -0
- package/dist/components/expand-toggle.d.ts +19 -0
- package/dist/components/expand-toggle.js +10 -0
- package/dist/components/field.d.ts +48 -0
- package/dist/components/field.js +60 -0
- package/dist/components/filter-chip.d.ts +47 -0
- package/dist/components/filter-chip.js +33 -0
- package/dist/components/group.d.ts +10 -0
- package/dist/components/group.js +9 -0
- package/dist/components/icon-text.d.ts +11 -0
- package/dist/components/icon-text.js +10 -0
- package/dist/components/image-sources.d.ts +57 -0
- package/dist/components/image-sources.js +58 -0
- package/dist/components/image-thumbnail.d.ts +34 -0
- package/dist/components/image-thumbnail.js +58 -0
- package/dist/components/image-viewer.d.ts +60 -0
- package/dist/components/image-viewer.js +411 -0
- package/dist/components/inline-edit.d.ts +22 -0
- package/dist/components/inline-edit.js +51 -0
- package/dist/components/input.d.ts +155 -0
- package/dist/components/input.js +109 -0
- package/dist/components/item-label.d.ts +11 -0
- package/dist/components/item-label.js +5 -0
- package/dist/components/item-row.d.ts +23 -0
- package/dist/components/item-row.js +19 -0
- package/dist/components/kbd.d.ts +55 -0
- package/dist/components/kbd.js +86 -0
- package/dist/components/link-policy.d.ts +24 -0
- package/dist/components/link-policy.js +32 -0
- package/dist/components/linked-text.d.ts +15 -0
- package/dist/components/linked-text.js +48 -0
- package/dist/components/loading-region.d.ts +18 -0
- package/dist/components/loading-region.js +17 -0
- package/dist/components/markdown.d.ts +34 -0
- package/dist/components/markdown.js +307 -0
- package/dist/components/menu.d.ts +132 -0
- package/dist/components/menu.js +102 -0
- package/dist/components/message-bubble.d.ts +57 -0
- package/dist/components/message-bubble.js +28 -0
- package/dist/components/meta-line.d.ts +28 -0
- package/dist/components/meta-line.js +36 -0
- package/dist/components/money-input.d.ts +23 -0
- package/dist/components/money-input.js +34 -0
- package/dist/components/native-select.d.ts +120 -0
- package/dist/components/native-select.js +85 -0
- package/dist/components/page-trail.d.ts +30 -0
- package/dist/components/page-trail.js +43 -0
- package/dist/components/page.d.ts +80 -0
- package/dist/components/page.js +60 -0
- package/dist/components/path-text.d.ts +8 -0
- package/dist/components/path-text.js +11 -0
- package/dist/components/percent-input.d.ts +20 -0
- package/dist/components/percent-input.js +32 -0
- package/dist/components/popover.d.ts +52 -0
- package/dist/components/popover.js +36 -0
- package/dist/components/progress.d.ts +389 -0
- package/dist/components/progress.js +142 -0
- package/dist/components/radio.d.ts +65 -0
- package/dist/components/radio.js +54 -0
- package/dist/components/remote-image-gate.d.ts +34 -0
- package/dist/components/remote-image-gate.js +60 -0
- package/dist/components/resizable.d.ts +23 -0
- package/dist/components/resizable.js +30 -0
- package/dist/components/rolling-number.d.ts +13 -0
- package/dist/components/rolling-number.js +69 -0
- package/dist/components/scroll-area.d.ts +17 -0
- package/dist/components/scroll-area.js +25 -0
- package/dist/components/section-label.d.ts +10 -0
- package/dist/components/section-label.js +21 -0
- package/dist/components/section-nav.d.ts +22 -0
- package/dist/components/section-nav.js +80 -0
- package/dist/components/segmented-control.d.ts +125 -0
- package/dist/components/segmented-control.js +101 -0
- package/dist/components/select.d.ts +120 -0
- package/dist/components/select.js +89 -0
- package/dist/components/separator.d.ts +10 -0
- package/dist/components/separator.js +12 -0
- package/dist/components/sheet.d.ts +101 -0
- package/dist/components/sheet.js +129 -0
- package/dist/components/shortcut-recorder.d.ts +31 -0
- package/dist/components/shortcut-recorder.js +67 -0
- package/dist/components/skeleton.d.ts +31 -0
- package/dist/components/skeleton.js +33 -0
- package/dist/components/slider.d.ts +138 -0
- package/dist/components/slider.js +98 -0
- package/dist/components/spinner.d.ts +37 -0
- package/dist/components/spinner.js +16 -0
- package/dist/components/switch.d.ts +59 -0
- package/dist/components/switch.js +56 -0
- package/dist/components/tab-strip.d.ts +29 -0
- package/dist/components/tab-strip.js +42 -0
- package/dist/components/tabs.d.ts +13 -0
- package/dist/components/tabs.js +68 -0
- package/dist/components/text-link.d.ts +54 -0
- package/dist/components/text-link.js +38 -0
- package/dist/components/textarea.d.ts +75 -0
- package/dist/components/textarea.js +90 -0
- package/dist/components/toast.d.ts +74 -0
- package/dist/components/toast.js +128 -0
- package/dist/components/tooltip.d.ts +50 -0
- package/dist/components/tooltip.js +46 -0
- package/dist/components/truncated-text.d.ts +15 -0
- package/dist/components/truncated-text.js +19 -0
- package/dist/i18n/defaults.d.ts +7 -0
- package/dist/i18n/defaults.js +7 -0
- package/dist/i18n/format.d.ts +84 -0
- package/dist/i18n/format.js +169 -0
- package/dist/i18n/index.d.ts +6 -0
- package/dist/i18n/index.js +8 -0
- package/dist/i18n/locales/ru-formatters.d.ts +3 -0
- package/dist/i18n/locales/ru-formatters.js +22 -0
- package/dist/i18n/locales/ru.d.ts +5 -0
- package/dist/i18n/locales/ru.js +185 -0
- package/dist/i18n/plural.d.ts +20 -0
- package/dist/i18n/plural.js +26 -0
- package/dist/i18n/provider.d.ts +36 -0
- package/dist/i18n/provider.js +39 -0
- package/dist/i18n/rich.d.ts +14 -0
- package/dist/i18n/rich.js +44 -0
- package/dist/i18n/ru-plural.d.ts +3 -0
- package/dist/i18n/ru-plural.js +4 -0
- package/dist/i18n/strings/alert-dialog.d.ts +5 -0
- package/dist/i18n/strings/alert-dialog.js +5 -0
- package/dist/i18n/strings/block-stack.d.ts +17 -0
- package/dist/i18n/strings/block-stack.js +11 -0
- package/dist/i18n/strings/code-block.d.ts +18 -0
- package/dist/i18n/strings/code-block.js +13 -0
- package/dist/i18n/strings/combobox.d.ts +12 -0
- package/dist/i18n/strings/combobox.js +10 -0
- package/dist/i18n/strings/command-palette.d.ts +17 -0
- package/dist/i18n/strings/command-palette.js +11 -0
- package/dist/i18n/strings/diff-view.d.ts +92 -0
- package/dist/i18n/strings/diff-view.js +68 -0
- package/dist/i18n/strings/image-viewer.d.ts +43 -0
- package/dist/i18n/strings/image-viewer.js +32 -0
- package/dist/i18n/strings/index.d.ts +314 -0
- package/dist/i18n/strings/index.js +43 -0
- package/dist/i18n/strings/kbd.d.ts +42 -0
- package/dist/i18n/strings/kbd.js +39 -0
- package/dist/i18n/strings/markdown.d.ts +23 -0
- package/dist/i18n/strings/markdown.js +18 -0
- package/dist/i18n/strings/money.d.ts +7 -0
- package/dist/i18n/strings/money.js +5 -0
- package/dist/i18n/strings/primitives.d.ts +25 -0
- package/dist/i18n/strings/primitives.js +18 -0
- package/dist/i18n/strings/progress.d.ts +4 -0
- package/dist/i18n/strings/progress.js +4 -0
- package/dist/i18n/strings/shortcut-recorder.d.ts +15 -0
- package/dist/i18n/strings/shortcut-recorder.js +11 -0
- package/dist/i18n/strings/time.d.ts +41 -0
- package/dist/i18n/strings/time.js +20 -0
- package/dist/i18n/strings/toast.d.ts +6 -0
- package/dist/i18n/strings/toast.js +6 -0
- package/dist/i18n/time-zones.d.ts +20 -0
- package/dist/i18n/time-zones.js +64 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.js +88 -0
- package/dist/lib/ansi.d.ts +55 -0
- package/dist/lib/ansi.js +438 -0
- package/dist/lib/clock.d.ts +32 -0
- package/dist/lib/clock.js +106 -0
- package/dist/lib/cn.d.ts +12 -0
- package/dist/lib/cn.js +28 -0
- package/dist/lib/control-props.d.ts +21 -0
- package/dist/lib/control-props.js +14 -0
- package/dist/lib/direction.d.ts +13 -0
- package/dist/lib/direction.js +25 -0
- package/dist/lib/image-size.d.ts +12 -0
- package/dist/lib/image-size.js +66 -0
- package/dist/lib/keycaps.d.ts +21 -0
- package/dist/lib/keycaps.js +62 -0
- package/dist/lib/keyed.d.ts +9 -0
- package/dist/lib/keyed.js +14 -0
- package/dist/lib/keys.d.ts +49 -0
- package/dist/lib/keys.js +159 -0
- package/dist/lib/kit-motion.d.ts +9 -0
- package/dist/lib/kit-motion.js +12 -0
- package/dist/lib/link-check-dialog.d.ts +11 -0
- package/dist/lib/link-check-dialog.js +18 -0
- package/dist/lib/motion-features.d.ts +1 -0
- package/dist/lib/motion-features.js +4 -0
- package/dist/lib/motion-provider.d.ts +5 -0
- package/dist/lib/motion-provider.js +8 -0
- package/dist/lib/motion.d.ts +39 -0
- package/dist/lib/motion.js +49 -0
- package/dist/lib/number-format.d.ts +114 -0
- package/dist/lib/number-format.js +313 -0
- package/dist/lib/patch.d.ts +72 -0
- package/dist/lib/patch.js +344 -0
- package/dist/lib/path.d.ts +34 -0
- package/dist/lib/path.js +85 -0
- package/dist/lib/search.d.ts +10 -0
- package/dist/lib/search.js +20 -0
- package/dist/lib/shiki-themes.d.ts +7 -0
- package/dist/lib/shiki-themes.js +115 -0
- package/dist/lib/shiki.d.ts +101 -0
- package/dist/lib/shiki.js +353 -0
- package/dist/lib/shortcut-context.d.ts +23 -0
- package/dist/lib/shortcut-context.js +29 -0
- package/dist/lib/text.d.ts +56 -0
- package/dist/lib/text.js +149 -0
- package/dist/lib/theme-scope.d.ts +18 -0
- package/dist/lib/theme-scope.js +24 -0
- package/dist/lib/theme.d.ts +40 -0
- package/dist/lib/theme.js +96 -0
- package/dist/lib/tree-keys.d.ts +72 -0
- package/dist/lib/tree-keys.js +126 -0
- package/dist/lib/url.d.ts +17 -0
- package/dist/lib/url.js +38 -0
- package/dist/lib/use-copy-to-clipboard.d.ts +13 -0
- package/dist/lib/use-copy-to-clipboard.js +40 -0
- package/dist/lib/use-delayed-loading.d.ts +11 -0
- package/dist/lib/use-delayed-loading.js +31 -0
- package/dist/lib/use-file-picker.d.ts +26 -0
- package/dist/lib/use-file-picker.js +43 -0
- package/dist/lib/use-hydrated.d.ts +6 -0
- package/dist/lib/use-hydrated.js +11 -0
- package/dist/lib/use-latest.d.ts +12 -0
- package/dist/lib/use-latest.js +22 -0
- package/dist/lib/use-resolved-theme.d.ts +12 -0
- package/dist/lib/use-resolved-theme.js +25 -0
- package/dist/styles/base.css +393 -0
- package/dist/styles/code.css +35 -0
- package/dist/styles/fonts.css +12 -0
- package/dist/styles/index.css +13 -0
- package/dist/styles/tokens.gen.css +494 -0
- package/package.json +208 -4
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Popover as BasePopover } from "@base-ui/react/popover";
|
|
2
|
+
import type { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
|
+
export declare const PopoverRoot: typeof BasePopover.Root;
|
|
4
|
+
export declare const PopoverTrigger: BasePopover.Trigger;
|
|
5
|
+
export declare const PopoverClose: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").PopoverCloseProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
type PositionerProps = ComponentProps<typeof BasePopover.Positioner>;
|
|
7
|
+
export interface PopoverContentProps extends ComponentProps<typeof BasePopover.Popup> {
|
|
8
|
+
/**
|
|
9
|
+
* The anchor's side it opens on. `inline-start` and `inline-end` follow the writing direction, so a
|
|
10
|
+
* card beside a sidebar's link stays off the sidebar in a right-to-left language too.
|
|
11
|
+
*/
|
|
12
|
+
side?: PositionerProps["side"];
|
|
13
|
+
align?: PositionerProps["align"];
|
|
14
|
+
/** Its distance from the anchor; a function of both boxes where it depends on them. */
|
|
15
|
+
sideOffset?: PositionerProps["sideOffset"];
|
|
16
|
+
alignOffset?: number;
|
|
17
|
+
/**
|
|
18
|
+
* What it points at when that isn't its trigger: an element on the page (a tour's stop, a member's
|
|
19
|
+
* figure in the office), or a function that finds it.
|
|
20
|
+
*/
|
|
21
|
+
anchor?: PositionerProps["anchor"];
|
|
22
|
+
/**
|
|
23
|
+
* The positioner's own props. A `className` here merges with the overlay layer's: a `z-*` of its own
|
|
24
|
+
* puts the popover in another layer.
|
|
25
|
+
*/
|
|
26
|
+
positionerProps?: Omit<PositionerProps, "side" | "align" | "sideOffset" | "alignOffset" | "anchor">;
|
|
27
|
+
}
|
|
28
|
+
/** Portal + positioner + popup. Padded card surface; compose Title/Description/Close inside. */
|
|
29
|
+
export declare function PopoverContent({ side, align, sideOffset, alignOffset, anchor, positionerProps, className, children, ...props }: PopoverContentProps): import("react").JSX.Element;
|
|
30
|
+
export declare function PopoverHeader({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
31
|
+
export declare function PopoverTitle({ className, ...props }: ComponentProps<typeof BasePopover.Title>): import("react").JSX.Element;
|
|
32
|
+
export declare function PopoverDescription({ className, ...props }: ComponentProps<typeof BasePopover.Description>): import("react").JSX.Element;
|
|
33
|
+
/** Icon-only close in the top-right corner. */
|
|
34
|
+
export declare function PopoverCloseButton({ className, "aria-label": ariaLabel, ...props }: ComponentProps<typeof BasePopover.Close>): import("react").JSX.Element;
|
|
35
|
+
export interface PopoverProps {
|
|
36
|
+
/** The trigger element; must accept a ref and DOM props (e.g. <Button>). */
|
|
37
|
+
trigger: ReactElement;
|
|
38
|
+
title?: ReactNode;
|
|
39
|
+
description?: ReactNode;
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
side?: PopoverContentProps["side"];
|
|
42
|
+
align?: PopoverContentProps["align"];
|
|
43
|
+
/** Shows the corner close button. */
|
|
44
|
+
closable?: boolean;
|
|
45
|
+
open?: boolean;
|
|
46
|
+
onOpenChange?: ComponentProps<typeof BasePopover.Root>["onOpenChange"];
|
|
47
|
+
/** Popup class (e.g. a width). */
|
|
48
|
+
className?: string;
|
|
49
|
+
}
|
|
50
|
+
/** Convenience wrapper: `<Popover trigger={<Button/>} title="…" description="…">…</Popover>`. */
|
|
51
|
+
export declare function Popover({ trigger, title, description, children, side, align, closable, open, onOpenChange, className, }: PopoverProps): import("react").JSX.Element;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Popover as BasePopover } from "@base-ui/react/popover";
|
|
4
|
+
import { X } from "lucide-react";
|
|
5
|
+
import { useUiStrings } from "../i18n/provider.js";
|
|
6
|
+
import { cn, withBase } from "../lib/cn.js";
|
|
7
|
+
import { usePortalContainer } from "../lib/theme-scope.js";
|
|
8
|
+
import { iconButtonStyles } from "./button.js";
|
|
9
|
+
export const PopoverRoot = BasePopover.Root;
|
|
10
|
+
export const PopoverTrigger = BasePopover.Trigger;
|
|
11
|
+
export const PopoverClose = BasePopover.Close;
|
|
12
|
+
/** Portal + positioner + popup. Padded card surface; compose Title/Description/Close inside. */
|
|
13
|
+
export function PopoverContent({ side = "bottom", align = "center", sideOffset, alignOffset = 0, anchor, positionerProps, className, children, ...props }) {
|
|
14
|
+
const container = usePortalContainer();
|
|
15
|
+
const { className: positionerClassName, ...positioner } = positionerProps ?? {};
|
|
16
|
+
return (_jsx(BasePopover.Portal, { container: container, children: _jsx(BasePopover.Positioner, { side: side, align: align, sideOffset: sideOffset ?? 6, alignOffset: alignOffset, anchor: anchor, collisionPadding: 8, className: withBase("z-(--z-overlay) outline-none", positionerClassName), ...positioner, children: _jsx(BasePopover.Popup, { "data-slot": "popover", className: withBase(cn("popup-motion surface-raised relative w-72 max-w-(--available-width) rounded-xl p-4 text-base text-fg outline-none"), className), ...props, children: children }) }) }));
|
|
17
|
+
}
|
|
18
|
+
export function PopoverHeader({ className, ...props }) {
|
|
19
|
+
return (_jsx("div", { "data-slot": "popover-header", className: cn("mb-3 flex flex-col gap-1 pe-6", className), ...props }));
|
|
20
|
+
}
|
|
21
|
+
export function PopoverTitle({ className, ...props }) {
|
|
22
|
+
return (_jsx(BasePopover.Title, { "data-slot": "popover-title", className: withBase("text-md font-semibold leading-tight text-fg", className), ...props }));
|
|
23
|
+
}
|
|
24
|
+
export function PopoverDescription({ className, ...props }) {
|
|
25
|
+
return (_jsx(BasePopover.Description, { "data-slot": "popover-description", className: withBase("text-sm text-fg-muted", className), ...props }));
|
|
26
|
+
}
|
|
27
|
+
/** Icon-only close in the top-right corner. */
|
|
28
|
+
export function PopoverCloseButton({ className, "aria-label": ariaLabel, ...props }) {
|
|
29
|
+
const t = useUiStrings().primitives;
|
|
30
|
+
return (_jsx(BasePopover.Close, { "data-slot": "popover-close", "aria-label": ariaLabel ?? t.close, className: withBase(cn(iconButtonStyles({ variant: "ghost", size: "xs" }), "absolute top-3 end-3"), className), ...props, children: _jsx(X, { "aria-hidden": true }) }));
|
|
31
|
+
}
|
|
32
|
+
/** Convenience wrapper: `<Popover trigger={<Button/>} title="…" description="…">…</Popover>`. */
|
|
33
|
+
export function Popover({ trigger, title, description, children, side, align, closable = false, open, onOpenChange, className, }) {
|
|
34
|
+
const hasHeader = title !== undefined || description !== undefined;
|
|
35
|
+
return (_jsxs(BasePopover.Root, { ...(open !== undefined && { open }), ...(onOpenChange && { onOpenChange }), children: [_jsx(BasePopover.Trigger, { render: trigger }), _jsxs(PopoverContent, { ...(side && { side }), ...(align && { align }), className: className, children: [closable && _jsx(PopoverCloseButton, {}), hasHeader && (_jsxs(PopoverHeader, { className: children === undefined ? "mb-0" : undefined, children: [title !== undefined && _jsx(PopoverTitle, { children: title }), description !== undefined && _jsx(PopoverDescription, { children: description })] })), children] })] }));
|
|
36
|
+
}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { Meter } from "@base-ui/react/meter";
|
|
2
|
+
import { Progress as BaseProgress } from "@base-ui/react/progress";
|
|
3
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
4
|
+
import { type VariantProps } from "../lib/cn.js";
|
|
5
|
+
declare const progressStyles: import("tailwind-variants").TVReturnType<{
|
|
6
|
+
/** Ink by default. `accent` is a sanctioned blue micro-moment — use it for the hero task only. */
|
|
7
|
+
tone: {
|
|
8
|
+
ink: {
|
|
9
|
+
fill: string;
|
|
10
|
+
sheen: string;
|
|
11
|
+
};
|
|
12
|
+
accent: {
|
|
13
|
+
fill: string;
|
|
14
|
+
sheen: string;
|
|
15
|
+
};
|
|
16
|
+
success: {
|
|
17
|
+
fill: string;
|
|
18
|
+
sheen: string;
|
|
19
|
+
};
|
|
20
|
+
warning: {
|
|
21
|
+
fill: string;
|
|
22
|
+
sheen: string;
|
|
23
|
+
};
|
|
24
|
+
danger: {
|
|
25
|
+
fill: string;
|
|
26
|
+
sheen: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
size: {
|
|
30
|
+
sm: {
|
|
31
|
+
track: string;
|
|
32
|
+
};
|
|
33
|
+
md: {
|
|
34
|
+
track: string;
|
|
35
|
+
};
|
|
36
|
+
lg: {
|
|
37
|
+
track: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}, {
|
|
41
|
+
root: string;
|
|
42
|
+
label: string;
|
|
43
|
+
value: string;
|
|
44
|
+
track: string;
|
|
45
|
+
fill: string[];
|
|
46
|
+
sheen: string[];
|
|
47
|
+
}, undefined, {
|
|
48
|
+
/** Ink by default. `accent` is a sanctioned blue micro-moment — use it for the hero task only. */
|
|
49
|
+
tone: {
|
|
50
|
+
ink: {
|
|
51
|
+
fill: string;
|
|
52
|
+
sheen: string;
|
|
53
|
+
};
|
|
54
|
+
accent: {
|
|
55
|
+
fill: string;
|
|
56
|
+
sheen: string;
|
|
57
|
+
};
|
|
58
|
+
success: {
|
|
59
|
+
fill: string;
|
|
60
|
+
sheen: string;
|
|
61
|
+
};
|
|
62
|
+
warning: {
|
|
63
|
+
fill: string;
|
|
64
|
+
sheen: string;
|
|
65
|
+
};
|
|
66
|
+
danger: {
|
|
67
|
+
fill: string;
|
|
68
|
+
sheen: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
size: {
|
|
72
|
+
sm: {
|
|
73
|
+
track: string;
|
|
74
|
+
};
|
|
75
|
+
md: {
|
|
76
|
+
track: string;
|
|
77
|
+
};
|
|
78
|
+
lg: {
|
|
79
|
+
track: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
}, {
|
|
83
|
+
root: string;
|
|
84
|
+
label: string;
|
|
85
|
+
value: string;
|
|
86
|
+
track: string;
|
|
87
|
+
fill: string[];
|
|
88
|
+
sheen: string[];
|
|
89
|
+
}, import("tailwind-variants").TVReturnTypeLike<{
|
|
90
|
+
/** Ink by default. `accent` is a sanctioned blue micro-moment — use it for the hero task only. */
|
|
91
|
+
tone: {
|
|
92
|
+
ink: {
|
|
93
|
+
fill: string;
|
|
94
|
+
sheen: string;
|
|
95
|
+
};
|
|
96
|
+
accent: {
|
|
97
|
+
fill: string;
|
|
98
|
+
sheen: string;
|
|
99
|
+
};
|
|
100
|
+
success: {
|
|
101
|
+
fill: string;
|
|
102
|
+
sheen: string;
|
|
103
|
+
};
|
|
104
|
+
warning: {
|
|
105
|
+
fill: string;
|
|
106
|
+
sheen: string;
|
|
107
|
+
};
|
|
108
|
+
danger: {
|
|
109
|
+
fill: string;
|
|
110
|
+
sheen: string;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
size: {
|
|
114
|
+
sm: {
|
|
115
|
+
track: string;
|
|
116
|
+
};
|
|
117
|
+
md: {
|
|
118
|
+
track: string;
|
|
119
|
+
};
|
|
120
|
+
lg: {
|
|
121
|
+
track: string;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
}, {
|
|
125
|
+
root: string;
|
|
126
|
+
label: string;
|
|
127
|
+
value: string;
|
|
128
|
+
track: string;
|
|
129
|
+
fill: string[];
|
|
130
|
+
sheen: string[];
|
|
131
|
+
}>>;
|
|
132
|
+
export interface ProgressProps extends Omit<ComponentProps<typeof BaseProgress.Root>, "children" | "value">, VariantProps<typeof progressStyles> {
|
|
133
|
+
/** Current value; `null` renders the indeterminate sheen. */
|
|
134
|
+
value: number | null;
|
|
135
|
+
/** Visible label, wired to the progressbar's accessible name. */
|
|
136
|
+
label?: ReactNode;
|
|
137
|
+
/** Show the formatted value (e.g. "42%") opposite the label. */
|
|
138
|
+
showValue?: boolean;
|
|
139
|
+
}
|
|
140
|
+
/** Linear progress for long-running tasks. Determinate fill or an indeterminate sliding sheen. */
|
|
141
|
+
export declare function Progress({ value, min, max, label, showValue, tone, size, className, ...props }: ProgressProps): import("react").JSX.Element;
|
|
142
|
+
declare const meterBarStyles: import("tailwind-variants").TVReturnType<{
|
|
143
|
+
tone: {
|
|
144
|
+
ink: {
|
|
145
|
+
fill: string;
|
|
146
|
+
};
|
|
147
|
+
muted: {
|
|
148
|
+
fill: string;
|
|
149
|
+
};
|
|
150
|
+
subtle: {
|
|
151
|
+
fill: string;
|
|
152
|
+
};
|
|
153
|
+
success: {
|
|
154
|
+
fill: string;
|
|
155
|
+
};
|
|
156
|
+
warning: {
|
|
157
|
+
fill: string;
|
|
158
|
+
};
|
|
159
|
+
danger: {
|
|
160
|
+
fill: string;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
size: {
|
|
164
|
+
xs: {
|
|
165
|
+
track: string;
|
|
166
|
+
};
|
|
167
|
+
sm: {
|
|
168
|
+
track: string;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
}, {
|
|
172
|
+
track: string;
|
|
173
|
+
fill: string;
|
|
174
|
+
}, undefined, {
|
|
175
|
+
tone: {
|
|
176
|
+
ink: {
|
|
177
|
+
fill: string;
|
|
178
|
+
};
|
|
179
|
+
muted: {
|
|
180
|
+
fill: string;
|
|
181
|
+
};
|
|
182
|
+
subtle: {
|
|
183
|
+
fill: string;
|
|
184
|
+
};
|
|
185
|
+
success: {
|
|
186
|
+
fill: string;
|
|
187
|
+
};
|
|
188
|
+
warning: {
|
|
189
|
+
fill: string;
|
|
190
|
+
};
|
|
191
|
+
danger: {
|
|
192
|
+
fill: string;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
size: {
|
|
196
|
+
xs: {
|
|
197
|
+
track: string;
|
|
198
|
+
};
|
|
199
|
+
sm: {
|
|
200
|
+
track: string;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
}, {
|
|
204
|
+
track: string;
|
|
205
|
+
fill: string;
|
|
206
|
+
}, import("tailwind-variants").TVReturnTypeLike<{
|
|
207
|
+
tone: {
|
|
208
|
+
ink: {
|
|
209
|
+
fill: string;
|
|
210
|
+
};
|
|
211
|
+
muted: {
|
|
212
|
+
fill: string;
|
|
213
|
+
};
|
|
214
|
+
subtle: {
|
|
215
|
+
fill: string;
|
|
216
|
+
};
|
|
217
|
+
success: {
|
|
218
|
+
fill: string;
|
|
219
|
+
};
|
|
220
|
+
warning: {
|
|
221
|
+
fill: string;
|
|
222
|
+
};
|
|
223
|
+
danger: {
|
|
224
|
+
fill: string;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
size: {
|
|
228
|
+
xs: {
|
|
229
|
+
track: string;
|
|
230
|
+
};
|
|
231
|
+
sm: {
|
|
232
|
+
track: string;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
}, {
|
|
236
|
+
track: string;
|
|
237
|
+
fill: string;
|
|
238
|
+
}>>;
|
|
239
|
+
export interface MeterBarProps extends VariantProps<typeof meterBarStyles> {
|
|
240
|
+
/** From 0 to `max`; clamped. */
|
|
241
|
+
readonly value: number;
|
|
242
|
+
readonly max?: number;
|
|
243
|
+
/** Width and placement (`w-10`, `flex-1`). */
|
|
244
|
+
readonly className?: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* A thin inline bar filled to a value, for a figure already said in words beside it (a score, a
|
|
248
|
+
* table row's share): decorative, so it stays out of the accessibility tree. It fills from the
|
|
249
|
+
* start edge, so it reads right in a right-to-left language too. A meter people read on its own is
|
|
250
|
+
* `Progress` or `ProgressRing`.
|
|
251
|
+
*/
|
|
252
|
+
export declare function MeterBar({ value, max, tone, size, className }: MeterBarProps): import("react").JSX.Element;
|
|
253
|
+
declare const ring: import("tailwind-variants").TVReturnType<{
|
|
254
|
+
level: {
|
|
255
|
+
normal: {
|
|
256
|
+
arc: string;
|
|
257
|
+
value: string;
|
|
258
|
+
};
|
|
259
|
+
warning: {
|
|
260
|
+
arc: string;
|
|
261
|
+
value: string;
|
|
262
|
+
};
|
|
263
|
+
danger: {
|
|
264
|
+
arc: string;
|
|
265
|
+
value: string;
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
size: {
|
|
269
|
+
sm: {
|
|
270
|
+
svg: string;
|
|
271
|
+
};
|
|
272
|
+
md: {
|
|
273
|
+
svg: string;
|
|
274
|
+
};
|
|
275
|
+
lg: {
|
|
276
|
+
svg: string;
|
|
277
|
+
};
|
|
278
|
+
/** A card's own meter (a usage card's limit). */
|
|
279
|
+
xl: {
|
|
280
|
+
svg: string;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
}, {
|
|
284
|
+
root: string;
|
|
285
|
+
svg: string;
|
|
286
|
+
arc: string[];
|
|
287
|
+
value: string;
|
|
288
|
+
}, undefined, {
|
|
289
|
+
level: {
|
|
290
|
+
normal: {
|
|
291
|
+
arc: string;
|
|
292
|
+
value: string;
|
|
293
|
+
};
|
|
294
|
+
warning: {
|
|
295
|
+
arc: string;
|
|
296
|
+
value: string;
|
|
297
|
+
};
|
|
298
|
+
danger: {
|
|
299
|
+
arc: string;
|
|
300
|
+
value: string;
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
size: {
|
|
304
|
+
sm: {
|
|
305
|
+
svg: string;
|
|
306
|
+
};
|
|
307
|
+
md: {
|
|
308
|
+
svg: string;
|
|
309
|
+
};
|
|
310
|
+
lg: {
|
|
311
|
+
svg: string;
|
|
312
|
+
};
|
|
313
|
+
/** A card's own meter (a usage card's limit). */
|
|
314
|
+
xl: {
|
|
315
|
+
svg: string;
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
}, {
|
|
319
|
+
root: string;
|
|
320
|
+
svg: string;
|
|
321
|
+
arc: string[];
|
|
322
|
+
value: string;
|
|
323
|
+
}, import("tailwind-variants").TVReturnTypeLike<{
|
|
324
|
+
level: {
|
|
325
|
+
normal: {
|
|
326
|
+
arc: string;
|
|
327
|
+
value: string;
|
|
328
|
+
};
|
|
329
|
+
warning: {
|
|
330
|
+
arc: string;
|
|
331
|
+
value: string;
|
|
332
|
+
};
|
|
333
|
+
danger: {
|
|
334
|
+
arc: string;
|
|
335
|
+
value: string;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
size: {
|
|
339
|
+
sm: {
|
|
340
|
+
svg: string;
|
|
341
|
+
};
|
|
342
|
+
md: {
|
|
343
|
+
svg: string;
|
|
344
|
+
};
|
|
345
|
+
lg: {
|
|
346
|
+
svg: string;
|
|
347
|
+
};
|
|
348
|
+
/** A card's own meter (a usage card's limit). */
|
|
349
|
+
xl: {
|
|
350
|
+
svg: string;
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
}, {
|
|
354
|
+
root: string;
|
|
355
|
+
svg: string;
|
|
356
|
+
arc: string[];
|
|
357
|
+
value: string;
|
|
358
|
+
}>>;
|
|
359
|
+
export type ProgressRingLevel = "normal" | "warning" | "danger";
|
|
360
|
+
export interface ProgressRingProps extends Omit<ComponentProps<typeof Meter.Root>, "children" | "render">, Omit<VariantProps<typeof ring>, "level"> {
|
|
361
|
+
value: number;
|
|
362
|
+
/** Percentage at which the ring turns amber. */
|
|
363
|
+
warningAt?: number;
|
|
364
|
+
/** Percentage at which the ring turns red. */
|
|
365
|
+
dangerAt?: number;
|
|
366
|
+
/** Force a level instead of deriving it from the thresholds. */
|
|
367
|
+
level?: ProgressRingLevel;
|
|
368
|
+
/** Show the formatted value next to the ring — keeps the state legible without color. */
|
|
369
|
+
showValue?: boolean;
|
|
370
|
+
/** Required accessible name, e.g. "Context window". */
|
|
371
|
+
"aria-label": string;
|
|
372
|
+
}
|
|
373
|
+
export interface ProgressRingGlyphProps extends Omit<VariantProps<typeof ring>, "level"> {
|
|
374
|
+
value: number;
|
|
375
|
+
min?: number;
|
|
376
|
+
max?: number;
|
|
377
|
+
warningAt?: number;
|
|
378
|
+
dangerAt?: number;
|
|
379
|
+
level?: ProgressRingLevel;
|
|
380
|
+
className?: string;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* The ring alone, for a control whose own label already says the amount (a button "$4 today of the
|
|
384
|
+
* $25 daily budget"): no meter role and no hidden text, so the control's name stays its visible text.
|
|
385
|
+
*/
|
|
386
|
+
export declare function ProgressRingGlyph({ value, min, max, warningAt, dangerAt, level, size, className, }: ProgressRingGlyphProps): import("react").JSX.Element;
|
|
387
|
+
/** Tiny circular meter for token / context-window usage. Escalates at warning & danger thresholds. */
|
|
388
|
+
export declare function ProgressRing({ value, min, max, warningAt, dangerAt, level, size, showValue, className, ...props }: ProgressRingProps): import("react").JSX.Element;
|
|
389
|
+
export {};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Meter } from "@base-ui/react/meter";
|
|
4
|
+
import { Progress as BaseProgress } from "@base-ui/react/progress";
|
|
5
|
+
import { useFormatters, useUiLocale, useUiStrings } from "../i18n/provider.js";
|
|
6
|
+
import { cn, resolveClassName, tv } from "../lib/cn.js";
|
|
7
|
+
import { useInlineSign } from "../lib/direction.js";
|
|
8
|
+
const clampPercent = (value, min, max) => max === min ? 0 : Math.min(100, Math.max(0, ((value - min) / (max - min)) * 100));
|
|
9
|
+
/* ------------------------------------------------------------------------------------------ */
|
|
10
|
+
/* Progress (linear) */
|
|
11
|
+
/* ------------------------------------------------------------------------------------------ */
|
|
12
|
+
const progressStyles = tv({
|
|
13
|
+
slots: {
|
|
14
|
+
root: "grid w-full grid-cols-[1fr_auto] items-baseline gap-x-3 gap-y-1.5",
|
|
15
|
+
label: "min-w-0 truncate text-sm text-fg-muted",
|
|
16
|
+
value: "col-start-2 text-sm text-fg-subtle tabular",
|
|
17
|
+
// The shared track (system.md §10.8): visible on every surface, popovers and dark mode included.
|
|
18
|
+
track: "relative col-span-2 overflow-hidden rounded-full bg-track",
|
|
19
|
+
fill: [
|
|
20
|
+
"absolute inset-0 rounded-full",
|
|
21
|
+
"transition-transform duration-(--duration-spring-smooth) ease-(--ease-spring-smooth) motion-reduce:transition-none",
|
|
22
|
+
],
|
|
23
|
+
sheen: [
|
|
24
|
+
"absolute inset-0 bg-linear-to-r from-transparent to-transparent animate-sheen",
|
|
25
|
+
"motion-reduce:animate-none motion-reduce:opacity-40",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
variants: {
|
|
29
|
+
/** Ink by default. `accent` is a sanctioned blue micro-moment — use it for the hero task only. */
|
|
30
|
+
tone: {
|
|
31
|
+
ink: { fill: "bg-fg", sheen: "via-fg/70" },
|
|
32
|
+
accent: { fill: "bg-accent", sheen: "via-accent" },
|
|
33
|
+
success: { fill: "bg-success", sheen: "via-success" },
|
|
34
|
+
warning: { fill: "bg-warning", sheen: "via-warning" },
|
|
35
|
+
danger: { fill: "bg-danger", sheen: "via-danger" },
|
|
36
|
+
},
|
|
37
|
+
size: {
|
|
38
|
+
sm: { track: "h-1" },
|
|
39
|
+
md: { track: "h-1.5" },
|
|
40
|
+
lg: { track: "h-2" },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
defaultVariants: { tone: "ink", size: "md" },
|
|
44
|
+
});
|
|
45
|
+
/** Linear progress for long-running tasks. Determinate fill or an indeterminate sliding sheen. */
|
|
46
|
+
export function Progress({ value, min = 0, max = 100, label, showValue = false, tone, size, className, ...props }) {
|
|
47
|
+
const locale = useUiLocale();
|
|
48
|
+
const t = useUiStrings().progress;
|
|
49
|
+
const formatters = useFormatters();
|
|
50
|
+
const inline = useInlineSign();
|
|
51
|
+
const styles = progressStyles({ tone, size });
|
|
52
|
+
const percent = value === null ? null : clampPercent(value, min, max);
|
|
53
|
+
return (_jsxs(BaseProgress.Root, { "data-slot": "progress", value: value, min: min, max: max, locale: locale, getAriaValueText: () => (percent === null ? t.indeterminate : formatters.percent(percent)), className: (state) => cn(styles.root(), resolveClassName(className, state)), ...props, children: [label !== undefined && _jsx(BaseProgress.Label, { className: styles.label(), children: label }), showValue && percent !== null && (_jsx(BaseProgress.Value, { className: styles.value(), children: () => formatters.percent(percent) })), _jsx(BaseProgress.Track, { className: styles.track(), children: percent === null ? (_jsx("span", { "aria-hidden": true, className: styles.sheen() })) : (_jsx("span", { "aria-hidden": true, className: styles.fill(), style: { transform: `translateX(${-inline * (100 - percent)}%)` } })) })] }));
|
|
54
|
+
}
|
|
55
|
+
/* ------------------------------------------------------------------------------------------ */
|
|
56
|
+
/* MeterBar (inline, decorative) */
|
|
57
|
+
/* ------------------------------------------------------------------------------------------ */
|
|
58
|
+
const meterBarStyles = tv({
|
|
59
|
+
slots: {
|
|
60
|
+
track: "relative block overflow-hidden rounded-full bg-track",
|
|
61
|
+
fill: "absolute inset-y-0 start-0 rounded-full",
|
|
62
|
+
},
|
|
63
|
+
variants: {
|
|
64
|
+
tone: {
|
|
65
|
+
ink: { fill: "bg-fg" },
|
|
66
|
+
muted: { fill: "bg-fg-muted" },
|
|
67
|
+
subtle: { fill: "bg-fg-subtle" },
|
|
68
|
+
success: { fill: "bg-success" },
|
|
69
|
+
warning: { fill: "bg-warning" },
|
|
70
|
+
danger: { fill: "bg-danger" },
|
|
71
|
+
},
|
|
72
|
+
size: {
|
|
73
|
+
xs: { track: "h-1" },
|
|
74
|
+
sm: { track: "h-1.5" },
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
defaultVariants: { tone: "muted", size: "xs" },
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* A thin inline bar filled to a value, for a figure already said in words beside it (a score, a
|
|
81
|
+
* table row's share): decorative, so it stays out of the accessibility tree. It fills from the
|
|
82
|
+
* start edge, so it reads right in a right-to-left language too. A meter people read on its own is
|
|
83
|
+
* `Progress` or `ProgressRing`.
|
|
84
|
+
*/
|
|
85
|
+
export function MeterBar({ value, max = 100, tone, size, className }) {
|
|
86
|
+
const styles = meterBarStyles({ tone, size });
|
|
87
|
+
return (_jsx("span", { "aria-hidden": true, "data-slot": "meter-bar", className: styles.track({ class: className }), children: _jsx("span", { className: styles.fill(), style: { inlineSize: `${clampPercent(value, 0, max)}%` } }) }));
|
|
88
|
+
}
|
|
89
|
+
/* ------------------------------------------------------------------------------------------ */
|
|
90
|
+
/* ProgressRing (compact meter) */
|
|
91
|
+
/* ------------------------------------------------------------------------------------------ */
|
|
92
|
+
const ring = tv({
|
|
93
|
+
slots: {
|
|
94
|
+
root: "inline-flex shrink-0 items-center gap-1.5 align-middle",
|
|
95
|
+
svg: "shrink-0 -rotate-90",
|
|
96
|
+
arc: [
|
|
97
|
+
"stroke-current transition-[stroke-dashoffset,color] duration-(--duration-spring-smooth) ease-(--ease-spring-smooth)",
|
|
98
|
+
"motion-reduce:transition-none",
|
|
99
|
+
],
|
|
100
|
+
value: "text-xs font-medium tabular",
|
|
101
|
+
},
|
|
102
|
+
variants: {
|
|
103
|
+
level: {
|
|
104
|
+
normal: { arc: "text-fg-muted", value: "text-fg-muted" },
|
|
105
|
+
warning: { arc: "text-warning", value: "text-warning-fg" },
|
|
106
|
+
danger: { arc: "text-danger", value: "text-danger-fg" },
|
|
107
|
+
},
|
|
108
|
+
size: {
|
|
109
|
+
sm: { svg: "size-3.5" },
|
|
110
|
+
md: { svg: "size-4" },
|
|
111
|
+
lg: { svg: "size-5" },
|
|
112
|
+
/** A card's own meter (a usage card's limit). */
|
|
113
|
+
xl: { svg: "size-11" },
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
defaultVariants: { level: "normal", size: "md" },
|
|
117
|
+
});
|
|
118
|
+
function ringLevel(percent, warningAt, dangerAt, level) {
|
|
119
|
+
return level ?? (percent >= dangerAt ? "danger" : percent >= warningAt ? "warning" : "normal");
|
|
120
|
+
}
|
|
121
|
+
function RingArc({ percent, styles, }) {
|
|
122
|
+
return (_jsxs("svg", { viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, className: styles.svg(), children: [_jsx("circle", { cx: "10", cy: "10", r: "8", strokeWidth: "2.5", className: "stroke-track" }), _jsx("circle", { cx: "10", cy: "10", r: "8", strokeWidth: "2.5", strokeLinecap: "round", pathLength: 100, strokeDasharray: "100 100", strokeDashoffset: 100 - percent, opacity: percent === 0 ? 0 : 1, className: styles.arc() })] }));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The ring alone, for a control whose own label already says the amount (a button "$4 today of the
|
|
126
|
+
* $25 daily budget"): no meter role and no hidden text, so the control's name stays its visible text.
|
|
127
|
+
*/
|
|
128
|
+
export function ProgressRingGlyph({ value, min = 0, max = 100, warningAt = 75, dangerAt = 90, level, size, className, }) {
|
|
129
|
+
const percent = clampPercent(value, min, max);
|
|
130
|
+
const derived = ringLevel(percent, warningAt, dangerAt, level);
|
|
131
|
+
const styles = ring({ level: derived, size });
|
|
132
|
+
return (_jsx("span", { "aria-hidden": true, "data-slot": "progress-ring", "data-level": derived, className: cn(styles.root(), className), children: _jsx(RingArc, { percent: percent, styles: styles }) }));
|
|
133
|
+
}
|
|
134
|
+
/** Tiny circular meter for token / context-window usage. Escalates at warning & danger thresholds. */
|
|
135
|
+
export function ProgressRing({ value, min = 0, max = 100, warningAt = 75, dangerAt = 90, level, size, showValue = false, className, ...props }) {
|
|
136
|
+
const percent = clampPercent(value, min, max);
|
|
137
|
+
const locale = useUiLocale();
|
|
138
|
+
const formatters = useFormatters();
|
|
139
|
+
const derived = ringLevel(percent, warningAt, dangerAt, level);
|
|
140
|
+
const styles = ring({ level: derived, size });
|
|
141
|
+
return (_jsxs(Meter.Root, { "data-slot": "progress-ring", "data-level": derived, value: value, min: min, max: max, locale: locale, getAriaValueText: () => formatters.percent(percent), render: _jsx("span", {}), className: (state) => cn(styles.root(), resolveClassName(className, state)), ...props, children: [_jsx(RingArc, { percent: percent, styles: styles }), showValue && _jsx(Meter.Value, { className: styles.value(), children: () => formatters.percent(percent) })] }));
|
|
142
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Radio as BaseRadio } from "@base-ui/react/radio";
|
|
2
|
+
import { RadioGroup as BaseRadioGroup } from "@base-ui/react/radio-group";
|
|
3
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
4
|
+
import { type VariantProps } from "../lib/cn.js";
|
|
5
|
+
export interface RadioGroupProps extends ComponentProps<typeof BaseRadioGroup> {
|
|
6
|
+
orientation?: "vertical" | "horizontal";
|
|
7
|
+
}
|
|
8
|
+
/** Single choice from a set of <Radio>/<RadioCard>. Arrow keys move the selection. */
|
|
9
|
+
export declare function RadioGroup({ orientation, className, ...props }: RadioGroupProps): import("react").JSX.Element;
|
|
10
|
+
declare const radioStyles: import("tailwind-variants").TVReturnType<{
|
|
11
|
+
size: {
|
|
12
|
+
sm: "size-3.5";
|
|
13
|
+
md: "size-4";
|
|
14
|
+
};
|
|
15
|
+
}, undefined, string[], {
|
|
16
|
+
size: {
|
|
17
|
+
sm: "size-3.5";
|
|
18
|
+
md: "size-4";
|
|
19
|
+
};
|
|
20
|
+
}, undefined, import("tailwind-variants").TVReturnTypeLike<{
|
|
21
|
+
size: {
|
|
22
|
+
sm: "size-3.5";
|
|
23
|
+
md: "size-4";
|
|
24
|
+
};
|
|
25
|
+
}, undefined>>;
|
|
26
|
+
export interface RadioProps extends Omit<ComponentProps<typeof BaseRadio.Root>, "children">, VariantProps<typeof radioStyles> {
|
|
27
|
+
label?: ReactNode;
|
|
28
|
+
description?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
export declare function Radio({ size, label, description, className, ...props }: RadioProps): import("react").JSX.Element;
|
|
31
|
+
export interface RadioCardProps extends Omit<ComponentProps<typeof BaseRadio.Root>, "children"> {
|
|
32
|
+
label: ReactNode;
|
|
33
|
+
description?: ReactNode;
|
|
34
|
+
/** Leading icon. */
|
|
35
|
+
icon?: ReactNode;
|
|
36
|
+
/** Trailing adornment (badge, shortcut…). */
|
|
37
|
+
trailing?: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* A picture of the choice across the card's top (a theme, a layout), edge to edge; the label goes
|
|
40
|
+
* under it. Decorative: the label names the choice.
|
|
41
|
+
*/
|
|
42
|
+
preview?: ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* Where the preview sits: across the `top` (default), or `auto`: beside the text on the start
|
|
45
|
+
* side when the card is wide (a list of full-width cards), on top when it's narrow (cards in a row).
|
|
46
|
+
*/
|
|
47
|
+
previewSide?: "top" | "auto";
|
|
48
|
+
}
|
|
49
|
+
/** A whole card as one radio — for weighty choices like permission modes, or ones best shown (a theme). */
|
|
50
|
+
export declare function RadioCard({ label, description, icon, trailing, preview, previewSide, className, ...props }: RadioCardProps): import("react").JSX.Element;
|
|
51
|
+
export interface RadioSwatchProps extends Omit<ComponentProps<typeof BaseRadio.Root>, "children" | "aria-label"> {
|
|
52
|
+
/** The choice's name, its accessible name: "Teal", "Style 3". */
|
|
53
|
+
label: string;
|
|
54
|
+
/** A colour to show (any CSS colour, e.g. a token's `var(--…)`). */
|
|
55
|
+
color?: string | undefined;
|
|
56
|
+
/** A picture to show instead (an avatar, an icon), sized by the caller. */
|
|
57
|
+
children?: ReactNode;
|
|
58
|
+
size?: "sm" | "md";
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* One choice shown as what it looks like — a colour or a picture — in a `RadioGroup`: a real radio
|
|
62
|
+
* (arrow keys move the choice, one tab stop), the chosen one outlined. Name each by `label`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function RadioSwatch({ label, color, children, size, className, ...props }: RadioSwatchProps): import("react").JSX.Element;
|
|
65
|
+
export {};
|