@polyfen/polykit-react 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.
@@ -0,0 +1,61 @@
1
+ import { type HTMLAttributes } from 'react';
2
+ /** The categorical hues (`--pk-color-cat-*`) for tiles, monograms and avatars. */
3
+ export type CategoryColor = 'rose' | 'green' | 'indigo' | 'sky' | 'purple' | 'amber' | 'teal' | 'gray';
4
+ export type BadgeVariant = 'default' | 'accent' | 'secondary' | 'success' | 'danger' | 'info' | 'purple' | 'magenta'
5
+ /** shadcn: Polykit's `danger`. */
6
+ | 'destructive';
7
+ export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
8
+ variant?: BadgeVariant;
9
+ }
10
+ /** A short label where color adds meaning (`.pk-badge`). Statuses go in a `StatusPill`. */
11
+ export declare const Badge: import("react").ForwardRefExoticComponent<BadgeProps & import("react").RefAttributes<HTMLSpanElement>>;
12
+ /** A status pill (`.pk-status`): the word is the status, so it has no color. shadcn: Badge. */
13
+ export declare const StatusPill: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLSpanElement> & import("react").RefAttributes<HTMLSpanElement>>;
14
+ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
15
+ /** The small card inside a column. */
16
+ compact?: boolean;
17
+ }
18
+ /** A bordered surface that clips what is in it (`.pk-card`). */
19
+ export declare const Card: import("react").ForwardRefExoticComponent<CardProps & import("react").RefAttributes<HTMLDivElement>>;
20
+ export type Tone = 'danger' | 'success' | 'warning' | 'info';
21
+ export interface CalloutProps extends HTMLAttributes<HTMLDivElement> {
22
+ tone?: Tone;
23
+ }
24
+ /** A quoted decision or a note, with a rule down the left edge (`.pk-callout`). */
25
+ export declare const Callout: import("react").ForwardRefExoticComponent<CalloutProps & import("react").RefAttributes<HTMLDivElement>>;
26
+ export interface BannerProps extends HTMLAttributes<HTMLDivElement> {
27
+ /** The accent tint by default; `neutral` is a quiet note; the rest are status tones. */
28
+ tone?: 'accent' | 'neutral' | Tone;
29
+ }
30
+ /**
31
+ * A message across the page with room for actions (`.pk-banner`). Put the words in `BannerText`
32
+ * and the buttons in `BannerActions`. One that appears after load needs `role="status"` (or
33
+ * `role="alert"` for danger). shadcn: Alert.
34
+ */
35
+ export declare const Banner: import("react").ForwardRefExoticComponent<BannerProps & import("react").RefAttributes<HTMLDivElement>>;
36
+ export declare const BannerText: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
37
+ export declare const BannerActions: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
38
+ export interface EmptyProps extends HTMLAttributes<HTMLParagraphElement> {
39
+ /** The small version inside a narrow column. */
40
+ inline?: boolean;
41
+ }
42
+ /** What a list says when it has nothing in it (`.pk-empty`). Say what to do next. */
43
+ export declare const Empty: import("react").ForwardRefExoticComponent<EmptyProps & import("react").RefAttributes<HTMLParagraphElement>>;
44
+ export interface ProgressProps extends HTMLAttributes<HTMLDivElement> {
45
+ /** 0 to 100. Leave it out (or null) while the amount is unknown: the bar runs back and forth. */
46
+ value?: number | null;
47
+ /** A progress bar must have a name: this, `aria-label` or `aria-labelledby`. */
48
+ label?: string;
49
+ }
50
+ /** A progress bar (`.pk-progress`). The bar is ink, as a primary action is. */
51
+ export declare const Progress: import("react").ForwardRefExoticComponent<ProgressProps & import("react").RefAttributes<HTMLDivElement>>;
52
+ export interface SeparatorProps extends HTMLAttributes<HTMLElement> {
53
+ orientation?: 'horizontal' | 'vertical';
54
+ /** Purely visual (the default, as in shadcn): hidden from assistive technology. */
55
+ decorative?: boolean;
56
+ }
57
+ /**
58
+ * A line between groups (`.pk-separator`). With children ("or") it is the labeled version, and
59
+ * the words stay readable to everyone.
60
+ */
61
+ export declare const Separator: import("react").ForwardRefExoticComponent<SeparatorProps & import("react").RefAttributes<HTMLElement>>;
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import { cx } from '../lib/cx.js';
4
+ /** A short label where color adds meaning (`.pk-badge`). Statuses go in a `StatusPill`. */
5
+ export const Badge = forwardRef(function Badge({ variant = 'default', className, ...props }, ref) {
6
+ const tone = variant === 'destructive' ? 'danger' : variant;
7
+ return (_jsx("span", { ref: ref, className: cx('pk-badge', tone !== 'default' && `pk-badge--${tone}`, className), ...props }));
8
+ });
9
+ /** A status pill (`.pk-status`): the word is the status, so it has no color. shadcn: Badge. */
10
+ export const StatusPill = forwardRef(function StatusPill({ className, ...props }, ref) {
11
+ return _jsx("span", { ref: ref, className: cx('pk-status', className), ...props });
12
+ });
13
+ /** A bordered surface that clips what is in it (`.pk-card`). */
14
+ export const Card = forwardRef(function Card({ compact, className, ...props }, ref) {
15
+ return (_jsx("div", { ref: ref, className: cx('pk-card', compact && 'pk-card--compact', className), ...props }));
16
+ });
17
+ /** A quoted decision or a note, with a rule down the left edge (`.pk-callout`). */
18
+ export const Callout = forwardRef(function Callout({ tone, className, ...props }, ref) {
19
+ return (_jsx("div", { ref: ref, className: cx('pk-callout', tone && `pk-callout--${tone}`, className), ...props }));
20
+ });
21
+ /**
22
+ * A message across the page with room for actions (`.pk-banner`). Put the words in `BannerText`
23
+ * and the buttons in `BannerActions`. One that appears after load needs `role="status"` (or
24
+ * `role="alert"` for danger). shadcn: Alert.
25
+ */
26
+ export const Banner = forwardRef(function Banner({ tone = 'accent', className, ...props }, ref) {
27
+ return (_jsx("div", { ref: ref, className: cx('pk-banner', tone !== 'accent' && `pk-banner--${tone}`, className), ...props }));
28
+ });
29
+ export const BannerText = forwardRef(function BannerText({ className, ...props }, ref) {
30
+ return _jsx("div", { ref: ref, className: cx('pk-banner__text', className), ...props });
31
+ });
32
+ export const BannerActions = forwardRef(function BannerActions({ className, ...props }, ref) {
33
+ return _jsx("div", { ref: ref, className: cx('pk-banner__actions', className), ...props });
34
+ });
35
+ /** What a list says when it has nothing in it (`.pk-empty`). Say what to do next. */
36
+ export const Empty = forwardRef(function Empty({ inline, className, ...props }, ref) {
37
+ return (_jsx("p", { ref: ref, className: cx('pk-empty', inline && 'pk-empty--inline', className), ...props }));
38
+ });
39
+ /** A progress bar (`.pk-progress`). The bar is ink, as a primary action is. */
40
+ export const Progress = forwardRef(function Progress({ value, label, className, style, ...props }, ref) {
41
+ const known = typeof value === 'number';
42
+ const pct = known ? Math.min(100, Math.max(0, value)) : undefined;
43
+ return (_jsx("div", { ref: ref, role: "progressbar", "aria-label": label, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": pct, className: cx('pk-progress', className), style: known ? { '--pk-progress': `${pct}%`, ...style } : style, ...props, children: _jsx("div", { className: "pk-progress__bar" }) }));
44
+ });
45
+ /**
46
+ * A line between groups (`.pk-separator`). With children ("or") it is the labeled version, and
47
+ * the words stay readable to everyone.
48
+ */
49
+ export const Separator = forwardRef(function Separator({ orientation = 'horizontal', decorative = true, children, className, ...props }, ref) {
50
+ const semantics = decorative
51
+ ? { role: 'none' }
52
+ : {
53
+ role: 'separator',
54
+ 'aria-orientation': orientation === 'vertical' ? 'vertical' : undefined,
55
+ };
56
+ if (children != null) {
57
+ return (_jsx("div", { ref: ref, className: cx('pk-separator', 'pk-separator--label', className), ...props, children: children }));
58
+ }
59
+ if (orientation === 'vertical') {
60
+ return (_jsx("div", { ref: ref, className: cx('pk-separator', 'pk-separator--vertical', className), ...semantics, ...props }));
61
+ }
62
+ return (_jsx("hr", { ref: ref, className: cx('pk-separator', className), ...semantics, ...props }));
63
+ });
@@ -0,0 +1,44 @@
1
+ import { type HTMLAttributes, type InputHTMLAttributes, type LabelHTMLAttributes, type ReactNode, type SelectHTMLAttributes, type TextareaHTMLAttributes } from 'react';
2
+ export interface FieldProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
3
+ label: ReactNode;
4
+ /** A line under the control that helps fill it in. */
5
+ hint?: ReactNode;
6
+ /** What is wrong and how to fix it. Marks the control invalid and is announced. */
7
+ error?: ReactNode;
8
+ /** Adds `required` to the control and a star for the eye. */
9
+ required?: boolean;
10
+ /** Spans both columns of a `FormGrid`. */
11
+ wide?: boolean;
12
+ /** The id the control gets; one is made up when it is left out. */
13
+ id?: string;
14
+ /** One control: `Input`, `Textarea` or `NativeSelect`. */
15
+ children: ReactNode;
16
+ }
17
+ /**
18
+ * A form field (`.pk-field`): the label, one control and the words around it. It gives the
19
+ * control its id, `aria-describedby` (hint and error), `aria-invalid` and `required`.
20
+ * shadcn: Field with Label.
21
+ */
22
+ export declare const Field: import("react").ForwardRefExoticComponent<FieldProps & import("react").RefAttributes<HTMLDivElement>>;
23
+ /** A label for a control outside a `Field` (`.pk-field__label`). */
24
+ export declare const Label: import("react").ForwardRefExoticComponent<LabelHTMLAttributes<HTMLLabelElement> & import("react").RefAttributes<HTMLLabelElement>>;
25
+ export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
26
+ /** The shorter control for inline rows and toolbars. */
27
+ compact?: boolean;
28
+ }
29
+ /** A text input (`.pk-input`). */
30
+ export declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
31
+ /** A multi-line text input (`.pk-textarea`). */
32
+ export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaHTMLAttributes<HTMLTextAreaElement> & import("react").RefAttributes<HTMLTextAreaElement>>;
33
+ export interface NativeSelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
34
+ compact?: boolean;
35
+ }
36
+ /**
37
+ * The browser's select (`.pk-select`), with `<option>` children. Inside a `Field` the field draws
38
+ * the chevron. shadcn: NativeSelect.
39
+ */
40
+ export declare const NativeSelect: import("react").ForwardRefExoticComponent<NativeSelectProps & import("react").RefAttributes<HTMLSelectElement>>;
41
+ /** Lays fields out in two columns (`.pk-form-grid`); one column on a phone. */
42
+ export declare const FormGrid: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
43
+ /** The row of buttons at the end of a form (`.pk-form-actions`). */
44
+ export declare const FormActions: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { createContext, forwardRef, useContext, useId, } from 'react';
4
+ import { cx } from '../lib/cx.js';
5
+ const FieldContext = createContext(null);
6
+ /**
7
+ * A form field (`.pk-field`): the label, one control and the words around it. It gives the
8
+ * control its id, `aria-describedby` (hint and error), `aria-invalid` and `required`.
9
+ * shadcn: Field with Label.
10
+ */
11
+ export const Field = forwardRef(function Field({ label, hint, error, required = false, wide, id, className, children, ...props }, ref) {
12
+ const auto = useId();
13
+ const controlId = id ?? `pk-field-${auto}`;
14
+ const hintId = hint != null ? `${controlId}-hint` : undefined;
15
+ const errorId = error != null && error !== false ? `${controlId}-error` : undefined;
16
+ const describedBy = [hintId, errorId].filter(Boolean).join(' ') || undefined;
17
+ return (_jsx(FieldContext.Provider, { value: { id: controlId, describedBy, invalid: !!errorId, required }, children: _jsxs("div", { ref: ref, className: cx('pk-field', wide && 'pk-field--wide', className), ...props, children: [_jsxs("label", { className: "pk-field__label", htmlFor: controlId, children: [label, required && (_jsx("span", { className: "pk-field__required", "aria-hidden": "true", children: "*" }))] }), children, hintId && (_jsx("p", { className: "pk-field__hint", id: hintId, children: hint })), errorId && (_jsx("p", { className: "pk-field__error", id: errorId, role: "alert", children: error }))] }) }));
18
+ });
19
+ /** Props a control takes from the field it is in, unless it sets them itself. */
20
+ function useFieldControl(props) {
21
+ const field = useContext(FieldContext);
22
+ const own = props;
23
+ if (!field)
24
+ return props;
25
+ return {
26
+ ...props,
27
+ id: props.id ?? field.id,
28
+ required: props.required ?? (field.required || undefined),
29
+ 'aria-describedby': [field.describedBy, own['aria-describedby']].filter(Boolean).join(' ') || undefined,
30
+ 'aria-invalid': own['aria-invalid'] ?? (field.invalid || undefined),
31
+ };
32
+ }
33
+ /** A label for a control outside a `Field` (`.pk-field__label`). */
34
+ export const Label = forwardRef(function Label({ className, ...props }, ref) {
35
+ return _jsx("label", { ref: ref, className: cx('pk-field__label', className), ...props });
36
+ });
37
+ /** A text input (`.pk-input`). */
38
+ export const Input = forwardRef(function Input({ compact, className, ...props }, ref) {
39
+ const control = useFieldControl(props);
40
+ return (_jsx("input", { ref: ref, className: cx('pk-input', compact && 'pk-input--compact', className), ...control }));
41
+ });
42
+ /** A multi-line text input (`.pk-textarea`). */
43
+ export const Textarea = forwardRef(function Textarea({ className, ...props }, ref) {
44
+ const control = useFieldControl(props);
45
+ return _jsx("textarea", { ref: ref, className: cx('pk-textarea', className), ...control });
46
+ });
47
+ /**
48
+ * The browser's select (`.pk-select`), with `<option>` children. Inside a `Field` the field draws
49
+ * the chevron. shadcn: NativeSelect.
50
+ */
51
+ export const NativeSelect = forwardRef(function NativeSelect({ compact, className, ...props }, ref) {
52
+ const control = useFieldControl(props);
53
+ return (_jsx("select", { ref: ref, className: cx('pk-select', compact && 'pk-select--compact', className), ...control }));
54
+ });
55
+ /** Lays fields out in two columns (`.pk-form-grid`); one column on a phone. */
56
+ export const FormGrid = forwardRef(function FormGrid({ className, ...props }, ref) {
57
+ return _jsx("div", { ref: ref, className: cx('pk-form-grid', className), ...props });
58
+ });
59
+ /** The row of buttons at the end of a form (`.pk-form-actions`). */
60
+ export const FormActions = forwardRef(function FormActions({ className, ...props }, ref) {
61
+ return _jsx("div", { ref: ref, className: cx('pk-form-actions', className), ...props });
62
+ });
@@ -0,0 +1,29 @@
1
+ import type { IconName } from '@polyfen/polykit-icons';
2
+ import { type ReactNode, type SVGProps } from 'react';
3
+ export type { IconName };
4
+ export interface IconProviderProps {
5
+ /**
6
+ * Where the sprite is. Leave it empty when the sprite is inlined in the page (the icons
7
+ * package's recommended setup); set it to a same-origin URL such as `/assets/sprite.svg` when
8
+ * the sprite is a file.
9
+ */
10
+ spriteUrl?: string;
11
+ children?: ReactNode;
12
+ }
13
+ /** Tells every `Icon` below it where the sprite is. */
14
+ export declare function IconProvider({ spriteUrl, children }: IconProviderProps): import("react").JSX.Element;
15
+ export interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'ref'> {
16
+ /** An icon from `@polyfen/polykit-icons`, with its style suffix (`check`, `check-bold`). */
17
+ name: IconName;
18
+ /** `xs` 14, `sm` 16, `md` 18, `lg` 20 (the default size is 20), `xl` 24. */
19
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
20
+ /** Name an icon that stands alone and means something. Without it the icon is decoration. */
21
+ label?: string;
22
+ /** Overrides the provider's sprite URL for this icon. */
23
+ spriteUrl?: string;
24
+ }
25
+ /**
26
+ * An icon from the Polykit sprite (`.pk-icon`). It references the sprite with `<use>`, so it adds
27
+ * nothing to the bundle: load the sprite once (see the icons package's README).
28
+ */
29
+ export declare const Icon: import("react").ForwardRefExoticComponent<IconProps & import("react").RefAttributes<SVGSVGElement>>;
@@ -0,0 +1,17 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, forwardRef, useContext } from 'react';
4
+ import { cx } from '../lib/cx.js';
5
+ const SpriteContext = createContext('');
6
+ /** Tells every `Icon` below it where the sprite is. */
7
+ export function IconProvider({ spriteUrl = '', children }) {
8
+ return _jsx(SpriteContext.Provider, { value: spriteUrl, children: children });
9
+ }
10
+ /**
11
+ * An icon from the Polykit sprite (`.pk-icon`). It references the sprite with `<use>`, so it adds
12
+ * nothing to the bundle: load the sprite once (see the icons package's README).
13
+ */
14
+ export const Icon = forwardRef(function Icon({ name, size, label, spriteUrl, className, ...props }, ref) {
15
+ const sprite = useContext(SpriteContext);
16
+ return (_jsx("svg", { ref: ref, className: cx('pk-icon', size && `pk-icon--${size}`, className), focusable: "false", ...(label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': true }), ...props, children: _jsx("use", { href: `${spriteUrl ?? sprite}#pk-i-${name}` }) }));
17
+ });
@@ -0,0 +1,10 @@
1
+ import { type AnchorHTMLAttributes } from 'react';
2
+ export type LinkVariant = 'default' | 'secondary' | 'inline' | 'on-tint' | 'on-frame';
3
+ export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
4
+ /** `secondary` underlines in the brand's secondary accent; `inline` sits in running text. */
5
+ variant?: LinkVariant;
6
+ /** Render the child (a router's link component, or a button) with the link's classes. */
7
+ asChild?: boolean;
8
+ }
9
+ /** A link with an accent underline (`.pk-link`). shadcn: `Button variant="link"`. */
10
+ export declare const Link: import("react").ForwardRefExoticComponent<LinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Slot } from 'radix-ui';
3
+ import { forwardRef } from 'react';
4
+ import { cx } from '../lib/cx.js';
5
+ /** A link with an accent underline (`.pk-link`). shadcn: `Button variant="link"`. */
6
+ export const Link = forwardRef(function Link({ variant = 'default', asChild, className, ...props }, ref) {
7
+ const Comp = asChild ? Slot.Root : 'a';
8
+ return (_jsx(Comp, { ref: ref, className: cx('pk-link', variant !== 'default' && `pk-link--${variant}`, className), ...props }));
9
+ });
@@ -0,0 +1,35 @@
1
+ import { ContextMenu as ContextPrimitive, DropdownMenu as MenuPrimitive } from 'radix-ui';
2
+ import { type ComponentPropsWithoutRef } from 'react';
3
+ export declare const DropdownMenu: import("react").FC<MenuPrimitive.DropdownMenuProps>;
4
+ export declare const DropdownMenuTrigger: import("react").ForwardRefExoticComponent<MenuPrimitive.DropdownMenuTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
5
+ export declare const DropdownMenuPortal: import("react").FC<MenuPrimitive.DropdownMenuPortalProps>;
6
+ export declare const DropdownMenuGroup: import("react").ForwardRefExoticComponent<MenuPrimitive.DropdownMenuGroupProps & import("react").RefAttributes<HTMLDivElement>>;
7
+ export declare const DropdownMenuRadioGroup: import("react").ForwardRefExoticComponent<MenuPrimitive.DropdownMenuRadioGroupProps & import("react").RefAttributes<HTMLDivElement>>;
8
+ export declare const DropdownMenuSub: import("react").FC<MenuPrimitive.DropdownMenuSubProps>;
9
+ export type DropdownMenuContentProps = ComponentPropsWithoutRef<typeof MenuPrimitive.Content>;
10
+ /**
11
+ * The menu (`.pk-menu`), in a portal. Polykit's menus open under their button, aligned to its
12
+ * end, 6px below; Radix keeps them inside the viewport.
13
+ */
14
+ export declare const DropdownMenuContent: import("react").ForwardRefExoticComponent<Omit<MenuPrimitive.DropdownMenuContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
15
+ export interface MenuItemVariantProps {
16
+ /** `danger` (shadcn: `destructive`) is for destructive actions. */
17
+ variant?: 'default' | 'danger' | 'destructive';
18
+ }
19
+ export declare const DropdownMenuItem: import("react").ForwardRefExoticComponent<Omit<MenuPrimitive.DropdownMenuItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & MenuItemVariantProps & import("react").RefAttributes<HTMLDivElement>>;
20
+ /** An item that is on or off; Polykit draws the tick (`aria-checked`). */
21
+ export declare const DropdownMenuCheckboxItem: import("react").ForwardRefExoticComponent<Omit<MenuPrimitive.DropdownMenuCheckboxItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
22
+ /** One choice in a `DropdownMenuRadioGroup`; the current one gets the tick. */
23
+ export declare const DropdownMenuRadioItem: import("react").ForwardRefExoticComponent<Omit<MenuPrimitive.DropdownMenuRadioItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
24
+ export declare const DropdownMenuLabel: import("react").ForwardRefExoticComponent<Omit<MenuPrimitive.DropdownMenuLabelProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
25
+ export declare const DropdownMenuSeparator: import("react").ForwardRefExoticComponent<Omit<MenuPrimitive.DropdownMenuSeparatorProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
26
+ export declare const ContextMenu: import("react").FC<ContextPrimitive.ContextMenuProps>;
27
+ export declare const ContextMenuTrigger: import("react").ForwardRefExoticComponent<ContextPrimitive.ContextMenuTriggerProps & import("react").RefAttributes<HTMLSpanElement>>;
28
+ export declare const ContextMenuGroup: import("react").ForwardRefExoticComponent<ContextPrimitive.ContextMenuGroupProps & import("react").RefAttributes<HTMLDivElement>>;
29
+ export declare const ContextMenuRadioGroup: import("react").ForwardRefExoticComponent<ContextPrimitive.ContextMenuRadioGroupProps & import("react").RefAttributes<HTMLDivElement>>;
30
+ export declare const ContextMenuContent: import("react").ForwardRefExoticComponent<Omit<ContextPrimitive.ContextMenuContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
31
+ export declare const ContextMenuItem: import("react").ForwardRefExoticComponent<Omit<ContextPrimitive.ContextMenuItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & MenuItemVariantProps & import("react").RefAttributes<HTMLDivElement>>;
32
+ export declare const ContextMenuCheckboxItem: import("react").ForwardRefExoticComponent<Omit<ContextPrimitive.ContextMenuCheckboxItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
33
+ export declare const ContextMenuRadioItem: import("react").ForwardRefExoticComponent<Omit<ContextPrimitive.ContextMenuRadioItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
34
+ export declare const ContextMenuLabel: import("react").ForwardRefExoticComponent<Omit<ContextPrimitive.ContextMenuLabelProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
35
+ export declare const ContextMenuSeparator: import("react").ForwardRefExoticComponent<Omit<ContextPrimitive.ContextMenuSeparatorProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,60 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { ContextMenu as ContextPrimitive, DropdownMenu as MenuPrimitive } from 'radix-ui';
4
+ import { forwardRef } from 'react';
5
+ import { cx } from '../lib/cx.js';
6
+ /* Dropdown menu (Radix DropdownMenu) on the Polykit menu surface. */
7
+ export const DropdownMenu = MenuPrimitive.Root;
8
+ export const DropdownMenuTrigger = MenuPrimitive.Trigger;
9
+ export const DropdownMenuPortal = MenuPrimitive.Portal;
10
+ export const DropdownMenuGroup = MenuPrimitive.Group;
11
+ export const DropdownMenuRadioGroup = MenuPrimitive.RadioGroup;
12
+ export const DropdownMenuSub = MenuPrimitive.Sub;
13
+ /**
14
+ * The menu (`.pk-menu`), in a portal. Polykit's menus open under their button, aligned to its
15
+ * end, 6px below; Radix keeps them inside the viewport.
16
+ */
17
+ export const DropdownMenuContent = forwardRef(function DropdownMenuContent({ className, align = 'end', sideOffset = 6, collisionPadding = 8, ...props }, ref) {
18
+ return (_jsx(MenuPrimitive.Portal, { children: _jsx(MenuPrimitive.Content, { ref: ref, className: cx('pk-menu', className), align: align, sideOffset: sideOffset, collisionPadding: collisionPadding, ...props }) }));
19
+ });
20
+ const itemClass = (variant, className) => cx('pk-menu__item', (variant === 'danger' || variant === 'destructive') && 'pk-menu__item--danger', className);
21
+ export const DropdownMenuItem = forwardRef(function DropdownMenuItem({ variant, className, ...props }, ref) {
22
+ return _jsx(MenuPrimitive.Item, { ref: ref, className: itemClass(variant, className), ...props });
23
+ });
24
+ /** An item that is on or off; Polykit draws the tick (`aria-checked`). */
25
+ export const DropdownMenuCheckboxItem = forwardRef(function DropdownMenuCheckboxItem({ className, ...props }, ref) {
26
+ return (_jsx(MenuPrimitive.CheckboxItem, { ref: ref, className: itemClass('default', className), ...props }));
27
+ });
28
+ /** One choice in a `DropdownMenuRadioGroup`; the current one gets the tick. */
29
+ export const DropdownMenuRadioItem = forwardRef(function DropdownMenuRadioItem({ className, ...props }, ref) {
30
+ return (_jsx(MenuPrimitive.RadioItem, { ref: ref, className: itemClass('default', className), ...props }));
31
+ });
32
+ export const DropdownMenuLabel = forwardRef(function DropdownMenuLabel({ className, ...props }, ref) {
33
+ return _jsx(MenuPrimitive.Label, { ref: ref, className: cx('pk-menu__label', className), ...props });
34
+ });
35
+ export const DropdownMenuSeparator = forwardRef(function DropdownMenuSeparator({ className, ...props }, ref) {
36
+ return (_jsx(MenuPrimitive.Separator, { ref: ref, className: cx('pk-menu__separator', className), ...props }));
37
+ });
38
+ /* Context menu (Radix ContextMenu): the same surface, at the pointer. */
39
+ export const ContextMenu = ContextPrimitive.Root;
40
+ export const ContextMenuTrigger = ContextPrimitive.Trigger;
41
+ export const ContextMenuGroup = ContextPrimitive.Group;
42
+ export const ContextMenuRadioGroup = ContextPrimitive.RadioGroup;
43
+ export const ContextMenuContent = forwardRef(function ContextMenuContent({ className, collisionPadding = 8, ...props }, ref) {
44
+ return (_jsx(ContextPrimitive.Portal, { children: _jsx(ContextPrimitive.Content, { ref: ref, className: cx('pk-menu', className), collisionPadding: collisionPadding, ...props }) }));
45
+ });
46
+ export const ContextMenuItem = forwardRef(function ContextMenuItem({ variant, className, ...props }, ref) {
47
+ return _jsx(ContextPrimitive.Item, { ref: ref, className: itemClass(variant, className), ...props });
48
+ });
49
+ export const ContextMenuCheckboxItem = forwardRef(function ContextMenuCheckboxItem({ className, ...props }, ref) {
50
+ return (_jsx(ContextPrimitive.CheckboxItem, { ref: ref, className: itemClass('default', className), ...props }));
51
+ });
52
+ export const ContextMenuRadioItem = forwardRef(function ContextMenuRadioItem({ className, ...props }, ref) {
53
+ return (_jsx(ContextPrimitive.RadioItem, { ref: ref, className: itemClass('default', className), ...props }));
54
+ });
55
+ export const ContextMenuLabel = forwardRef(function ContextMenuLabel({ className, ...props }, ref) {
56
+ return (_jsx(ContextPrimitive.Label, { ref: ref, className: cx('pk-menu__label', className), ...props }));
57
+ });
58
+ export const ContextMenuSeparator = forwardRef(function ContextMenuSeparator({ className, ...props }, ref) {
59
+ return (_jsx(ContextPrimitive.Separator, { ref: ref, className: cx('pk-menu__separator', className), ...props }));
60
+ });
@@ -0,0 +1,42 @@
1
+ import { Tabs as TabsPrimitive, Toggle, ToggleGroup } from 'radix-ui';
2
+ import { type AnchorHTMLAttributes, type ComponentPropsWithoutRef, type HTMLAttributes } from 'react';
3
+ export declare const Tabs: import("react").ForwardRefExoticComponent<TabsPrimitive.TabsProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ /** The row of tabs (`.pk-tabs`). Name it with `aria-label`. */
5
+ export declare const TabsList: import("react").ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
6
+ /** One tab (`.pk-tabs__tab`); the underline marks the selected one. */
7
+ export declare const TabsTrigger: import("react").ForwardRefExoticComponent<Omit<TabsPrimitive.TabsTriggerProps & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
8
+ export declare const TabsContent: import("react").ForwardRefExoticComponent<TabsPrimitive.TabsContentProps & import("react").RefAttributes<HTMLDivElement>>;
9
+ /** A count after a tab's label (`.pk-tabs__count`). */
10
+ export declare const TabsCount: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLSpanElement> & import("react").RefAttributes<HTMLSpanElement>>;
11
+ /** Navigation tabs (`<nav class="pk-tabs">`). Name it with `aria-label`. */
12
+ export declare const NavTabs: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & import("react").RefAttributes<HTMLElement>>;
13
+ export interface NavTabProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
14
+ /** This tab's page is the one showing. */
15
+ current?: boolean;
16
+ /** Render the child (a router's link) with the tab's classes. */
17
+ asChild?: boolean;
18
+ }
19
+ /** One navigation tab: a link. */
20
+ export declare const NavTab: import("react").ForwardRefExoticComponent<NavTabProps & import("react").RefAttributes<HTMLAnchorElement>>;
21
+ export interface SegmentedControlProps extends Omit<ComponentPropsWithoutRef<typeof ToggleGroup.Root>, 'type' | 'value' | 'defaultValue' | 'onValueChange'> {
22
+ value?: string;
23
+ defaultValue?: string;
24
+ /** Called with the new choice. Pressing the current one again keeps it: one is always chosen. */
25
+ onValueChange?: (value: string) => void;
26
+ /** Icons before each label, with faint dividers. */
27
+ icons?: boolean;
28
+ }
29
+ /**
30
+ * A segmented control (`.pk-segmented`): a Radix single-choice toggle group with roving focus and
31
+ * arrow keys. Name it with `aria-label`. shadcn: `ToggleGroup type="single"`.
32
+ */
33
+ export declare const SegmentedControl: import("react").ForwardRefExoticComponent<SegmentedControlProps & import("react").RefAttributes<HTMLDivElement>>;
34
+ export declare const SegmentedControlItem: import("react").ForwardRefExoticComponent<Omit<ToggleGroup.ToggleGroupItemProps & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
35
+ export interface ChipProps extends ComponentPropsWithoutRef<typeof Toggle.Root> {
36
+ /** `check` adds a tick when pressed; `filter` holds an icon tile and a count. */
37
+ variant?: 'default' | 'check' | 'filter';
38
+ /** For `filter`: the tile's categorical hue, such as `var(--pk-color-cat-sky)`. */
39
+ tileColor?: string;
40
+ }
41
+ /** A pill that toggles (`.pk-chip`, `aria-pressed`). shadcn: Toggle. */
42
+ export declare const Chip: import("react").ForwardRefExoticComponent<ChipProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,47 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Slot, Tabs as TabsPrimitive, Toggle, ToggleGroup } from 'radix-ui';
4
+ import { forwardRef, } from 'react';
5
+ import { cx } from '../lib/cx.js';
6
+ /* Tabs that swap a panel in place (Radix Tabs: role="tab", aria-selected, arrow keys). */
7
+ export const Tabs = TabsPrimitive.Root;
8
+ /** The row of tabs (`.pk-tabs`). Name it with `aria-label`. */
9
+ export const TabsList = forwardRef(function TabsList({ className, ...props }, ref) {
10
+ return _jsx(TabsPrimitive.List, { ref: ref, className: cx('pk-tabs', className), ...props });
11
+ });
12
+ /** One tab (`.pk-tabs__tab`); the underline marks the selected one. */
13
+ export const TabsTrigger = forwardRef(function TabsTrigger({ className, ...props }, ref) {
14
+ return _jsx(TabsPrimitive.Trigger, { ref: ref, className: cx('pk-tabs__tab', className), ...props });
15
+ });
16
+ export const TabsContent = TabsPrimitive.Content;
17
+ /** A count after a tab's label (`.pk-tabs__count`). */
18
+ export const TabsCount = forwardRef(function TabsCount({ className, ...props }, ref) {
19
+ return _jsx("span", { ref: ref, className: cx('pk-tabs__count', className), ...props });
20
+ });
21
+ /* Tabs that change the page: links, the current one with aria-current="page". */
22
+ /** Navigation tabs (`<nav class="pk-tabs">`). Name it with `aria-label`. */
23
+ export const NavTabs = forwardRef(function NavTabs({ className, ...props }, ref) {
24
+ return _jsx("nav", { ref: ref, className: cx('pk-tabs', className), ...props });
25
+ });
26
+ /** One navigation tab: a link. */
27
+ export const NavTab = forwardRef(function NavTab({ current, asChild, className, ...props }, ref) {
28
+ const Comp = asChild ? Slot.Root : 'a';
29
+ return (_jsx(Comp, { ref: ref, className: cx('pk-tabs__tab', className), "aria-current": current ? 'page' : undefined, ...props }));
30
+ });
31
+ /**
32
+ * A segmented control (`.pk-segmented`): a Radix single-choice toggle group with roving focus and
33
+ * arrow keys. Name it with `aria-label`. shadcn: `ToggleGroup type="single"`.
34
+ */
35
+ export const SegmentedControl = forwardRef(function SegmentedControl({ icons, className, onValueChange, ...props }, ref) {
36
+ return (_jsx(ToggleGroup.Root, { ref: ref, type: "single", className: cx('pk-segmented', icons && 'pk-segmented--icons', className), onValueChange: (value) => {
37
+ if (value)
38
+ onValueChange?.(value);
39
+ }, ...props }));
40
+ });
41
+ export const SegmentedControlItem = forwardRef(function SegmentedControlItem({ className, ...props }, ref) {
42
+ return _jsx(ToggleGroup.Item, { ref: ref, className: cx('pk-segmented__item', className), ...props });
43
+ });
44
+ /** A pill that toggles (`.pk-chip`, `aria-pressed`). shadcn: Toggle. */
45
+ export const Chip = forwardRef(function Chip({ variant = 'default', tileColor, className, style, ...props }, ref) {
46
+ return (_jsx(Toggle.Root, { ref: ref, className: cx('pk-chip', variant !== 'default' && `pk-chip--${variant}`, className), style: tileColor ? { '--pk-tile-color': tileColor, ...style } : style, ...props }));
47
+ });
@@ -0,0 +1,10 @@
1
+ import { Popover as PopoverPrimitive } from 'radix-ui';
2
+ export declare const Popover: import("react").FC<PopoverPrimitive.PopoverProps>;
3
+ export declare const PopoverTrigger: import("react").ForwardRefExoticComponent<PopoverPrimitive.PopoverTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
4
+ export declare const PopoverAnchor: import("react").ForwardRefExoticComponent<PopoverPrimitive.PopoverAnchorProps & import("react").RefAttributes<HTMLDivElement>>;
5
+ export declare const PopoverClose: import("react").ForwardRefExoticComponent<PopoverPrimitive.PopoverCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
6
+ /**
7
+ * The popover surface (`.pk-popover`): the menu's surface for anything else, such as a small
8
+ * form. Radix places it, keeps it in the viewport, moves focus in and closes it on Escape.
9
+ */
10
+ export declare const PopoverContent: import("react").ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,16 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Popover as PopoverPrimitive } from 'radix-ui';
4
+ import { forwardRef } from 'react';
5
+ import { cx } from '../lib/cx.js';
6
+ export const Popover = PopoverPrimitive.Root;
7
+ export const PopoverTrigger = PopoverPrimitive.Trigger;
8
+ export const PopoverAnchor = PopoverPrimitive.Anchor;
9
+ export const PopoverClose = PopoverPrimitive.Close;
10
+ /**
11
+ * The popover surface (`.pk-popover`): the menu's surface for anything else, such as a small
12
+ * form. Radix places it, keeps it in the viewport, moves focus in and closes it on Escape.
13
+ */
14
+ export const PopoverContent = forwardRef(function PopoverContent({ className, align = 'start', sideOffset = 6, collisionPadding = 8, ...props }, ref) {
15
+ return (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { ref: ref, className: cx('pk-popover', className), align: align, sideOffset: sideOffset, collisionPadding: collisionPadding, ...props }) }));
16
+ });
@@ -0,0 +1,41 @@
1
+ import { type HTMLAttributes, type TdHTMLAttributes, type ThHTMLAttributes } from 'react';
2
+ export interface TableProps extends HTMLAttributes<HTMLTableElement> {
3
+ density?: 'compact' | 'default' | 'comfortable';
4
+ /** Alternate the row fill. */
5
+ striped?: boolean;
6
+ /**
7
+ * The scroll region's name, when the table has no `TableCaption` (which names it otherwise).
8
+ */
9
+ label?: string;
10
+ /** Rows scroll under a header that stays in view, past this height (a CSS length). */
11
+ maxHeight?: string;
12
+ }
13
+ /**
14
+ * A data table (`.pk-table`) in a focusable scroll wrap, so it works on a narrow screen and the
15
+ * keyboard can scroll it. shadcn: Table.
16
+ */
17
+ export declare const Table: import("react").ForwardRefExoticComponent<TableProps & import("react").RefAttributes<HTMLTableElement>>;
18
+ export interface TableCaptionProps extends HTMLAttributes<HTMLTableCaptionElement> {
19
+ /** Shown above the table. Hidden (for assistive technology only) by default. */
20
+ visible?: boolean;
21
+ }
22
+ export declare const TableCaption: import("react").ForwardRefExoticComponent<TableCaptionProps & import("react").RefAttributes<HTMLTableCaptionElement>>;
23
+ export declare const TableHeader: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLTableSectionElement> & import("react").RefAttributes<HTMLTableSectionElement>>;
24
+ export declare const TableBody: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLTableSectionElement> & import("react").RefAttributes<HTMLTableSectionElement>>;
25
+ export declare const TableFooter: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLTableSectionElement> & import("react").RefAttributes<HTMLTableSectionElement>>;
26
+ export interface TableRowProps extends HTMLAttributes<HTMLTableRowElement> {
27
+ /** A selected row; its checkbox says so too. */
28
+ selected?: boolean;
29
+ }
30
+ export declare const TableRow: import("react").ForwardRefExoticComponent<TableRowProps & import("react").RefAttributes<HTMLTableRowElement>>;
31
+ type CellKind = 'num' | 'date' | 'truncate' | 'check';
32
+ export interface TableHeadProps extends ThHTMLAttributes<HTMLTableCellElement> {
33
+ kind?: CellKind;
34
+ }
35
+ export declare const TableHead: import("react").ForwardRefExoticComponent<TableHeadProps & import("react").RefAttributes<HTMLTableCellElement>>;
36
+ export interface TableCellProps extends TdHTMLAttributes<HTMLTableCellElement> {
37
+ /** `num` right-aligns with tabular figures; `truncate` keeps one line (put the rest in `title`). */
38
+ kind?: CellKind;
39
+ }
40
+ export declare const TableCell: import("react").ForwardRefExoticComponent<TableCellProps & import("react").RefAttributes<HTMLTableCellElement>>;
41
+ export {};
@@ -0,0 +1,35 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, forwardRef, useContext, useId, } from 'react';
4
+ import { cx } from '../lib/cx.js';
5
+ const TableContext = createContext(null);
6
+ /**
7
+ * A data table (`.pk-table`) in a focusable scroll wrap, so it works on a narrow screen and the
8
+ * keyboard can scroll it. shadcn: Table.
9
+ */
10
+ export const Table = forwardRef(function Table({ density = 'default', striped, label, maxHeight, className, ...props }, ref) {
11
+ const captionId = `pk-table-${useId()}-caption`;
12
+ return (_jsx(TableContext.Provider, { value: captionId, children: _jsx("div", { className: "pk-table-wrap", tabIndex: 0, role: "region", "aria-label": label, "aria-labelledby": label ? undefined : captionId, style: maxHeight ? { '--pk-table-max-height': maxHeight } : undefined, children: _jsx("table", { ref: ref, className: cx('pk-table', density !== 'default' && `pk-table--${density}`, striped && 'pk-table--striped', className), ...props }) }) }));
13
+ });
14
+ export const TableCaption = forwardRef(function TableCaption({ visible, className, ...props }, ref) {
15
+ const id = useContext(TableContext) ?? undefined;
16
+ return (_jsx("caption", { ref: ref, id: id, className: cx(!visible && 'pk-sr-only', className), ...props }));
17
+ });
18
+ export const TableHeader = forwardRef(function TableHeader(props, ref) {
19
+ return _jsx("thead", { ref: ref, ...props });
20
+ });
21
+ export const TableBody = forwardRef(function TableBody(props, ref) {
22
+ return _jsx("tbody", { ref: ref, ...props });
23
+ });
24
+ export const TableFooter = forwardRef(function TableFooter(props, ref) {
25
+ return _jsx("tfoot", { ref: ref, ...props });
26
+ });
27
+ export const TableRow = forwardRef(function TableRow({ selected, ...props }, ref) {
28
+ return _jsx("tr", { ref: ref, "aria-selected": selected ? true : undefined, ...props });
29
+ });
30
+ export const TableHead = forwardRef(function TableHead({ kind, scope = 'col', className, ...props }, ref) {
31
+ return (_jsx("th", { ref: ref, scope: scope, className: cx(kind && `pk-table__${kind}`, className) || undefined, ...props }));
32
+ });
33
+ export const TableCell = forwardRef(function TableCell({ kind, className, ...props }, ref) {
34
+ return (_jsx("td", { ref: ref, className: cx(kind && `pk-table__${kind}`, className) || undefined, ...props }));
35
+ });