From 9cf7804d205feaecfc239204795e355f4f928779 Mon Sep 17 00:00:00 2001 From: robert dennis <31261583+robertdrakedennis@users.noreply.github.com> Date: Mon, 12 Oct 2026 09:04:03 -0400 Subject: [PATCH] skin primitives --- docs-notes/skins.md | 111 +++++ packages/sdk/types/components/Avatar.d.ts | 18 + .../sdk/types/components/elements/Badge.d.ts | 13 + .../sdk/types/components/elements/Button.d.ts | 23 +- .../sdk/types/components/elements/Card.d.ts | 19 + .../sdk/types/components/elements/Code.d.ts | 8 + .../types/components/elements/ContentBox.d.ts | 1 + .../components/elements/CopyOnClick.d.ts | 2 +- .../sdk/types/components/elements/Label.d.ts | 4 +- .../types/components/elements/ListRow.d.ts | 13 + .../types/components/elements/NewButton.d.ts | 12 +- .../components/elements/PageHeading.d.ts | 8 +- .../types/components/elements/Pagination.d.ts | 4 +- .../components/elements/ProgressBar.d.ts | 18 + .../types/components/elements/Spinner.d.ts | 6 +- .../components/elements/SpinnerOverlay.d.ts | 4 +- .../components/elements/TitledGreyBox.d.ts | 1 + .../components/elements/alert/Alert.d.ts | 6 +- .../components/elements/alert/index.d.ts | 2 +- .../components/elements/dialog/types.d.ts | 4 +- .../elements/dropdown/DropdownMenu.d.ts | 9 +- .../sdk/types/components/form/controls.d.ts | 10 +- packages/sdk/types/components/ui/empty.d.ts | 12 +- packages/sdk/types/sdk/index.d.ts | 25 +- packages/sdk/types/sdk/theme.d.ts | 2 +- packages/sdk/types/sdk/ui.d.ts | 17 +- packages/sdk/types/themes/primitives.d.ts | 353 ++++++++++++++++ packages/sdk/types/themes/skins.d.ts | 96 ++++- resources/scripts/components/Avatar.tsx | 29 +- .../components/admin/AdminListEmpty.tsx | 3 +- .../databases/DatabaseHostDetailContainer.tsx | 3 +- .../components/admin/eggs/EggVariablesTab.tsx | 3 +- .../components/admin/eggs/EggsContainer.tsx | 3 +- .../admin/extensions/ExtensionsContainer.tsx | 3 +- .../locations/LocationDetailContainer.tsx | 3 +- .../admin/mounts/AttachEggsModal.tsx | 3 +- .../admin/mounts/AttachNodesModal.tsx | 3 +- .../admin/mounts/MountDetailContainer.tsx | 5 +- .../components/admin/nodes/NodeAboutTab.tsx | 21 +- .../admin/nodes/NodeAllocationTab.tsx | 3 +- .../components/admin/nodes/NodeServersTab.tsx | 3 +- .../admin/servers/ServerDatabaseTab.tsx | 3 +- .../admin/servers/ServerMountsTab.tsx | 3 +- .../admin/servers/ServerStartupTab.tsx | 3 +- .../components/admin/tags/NoTagsYet.tsx | 3 +- .../admin/users/UserDetailContainer.tsx | 3 +- .../dashboard/AccountApiContainer.tsx | 3 +- .../dashboard/search/SearchModal.tsx | 4 +- .../dashboard/ssh/AccountSSHContainer.tsx | 3 +- .../scripts/components/elements/Badge.tsx | 23 ++ .../scripts/components/elements/Button.tsx | 168 +++----- .../scripts/components/elements/Card.tsx | 55 +++ .../scripts/components/elements/Code.tsx | 17 +- .../components/elements/ContentBox.tsx | 8 +- .../components/elements/CopyOnClick.tsx | 12 +- .../components/elements/GreyRowBox.tsx | 26 -- .../scripts/components/elements/Label.tsx | 18 +- .../scripts/components/elements/ListRow.tsx | 29 ++ .../scripts/components/elements/NewButton.tsx | 40 +- .../components/elements/PageHeading.tsx | 25 +- .../components/elements/Pagination.tsx | 39 +- .../components/elements/ProgressBar.tsx | 51 ++- .../scripts/components/elements/Spinner.tsx | 46 +-- .../components/elements/SpinnerOverlay.tsx | 16 +- .../components/elements/TitledGreyBox.tsx | 22 +- .../components/elements/alert/Alert.tsx | 59 +-- .../components/elements/alert/index.ts | 2 +- .../components/elements/dialog/Dialog.tsx | 85 ++-- .../elements/dialog/DialogFooter.tsx | 12 +- .../components/elements/dialog/DialogIcon.tsx | 26 +- .../components/elements/dialog/context.ts | 1 + .../components/elements/dialog/types.d.ts | 4 +- .../elements/dropdown/DropdownMenu.tsx | 79 ++-- .../elements/table/DataTable.spec.tsx | 6 +- .../components/elements/table/DataTable.tsx | 42 +- .../components/elements/table/RowActions.tsx | 14 +- .../components/elements/tooltip/Tooltip.tsx | 38 +- .../scripts/components/form/controls.tsx | 98 ++--- .../server/backups/BackupContainer.tsx | 5 +- .../server/databases/DatabasesContainer.tsx | 3 +- .../server/network/NetworkContainer.tsx | 3 +- .../server/schedules/ScheduleContainer.tsx | 3 +- .../schedules/ScheduleEditContainer.tsx | 3 +- .../server/startup/StartupContainer.tsx | 4 +- .../server/users/UsersContainer.tsx | 3 +- resources/scripts/components/ui/Checkbox.tsx | 17 +- resources/scripts/components/ui/Select.tsx | 207 ++++------ resources/scripts/components/ui/Switch.tsx | 28 +- .../scripts/components/ui/empty.spec.tsx | 19 +- resources/scripts/components/ui/empty.tsx | 93 ++--- resources/scripts/components/ui/styles.ts | 3 - resources/scripts/components/ui/typography.ts | 2 - .../scripts/router/layouts/RootLayout.tsx | 4 +- resources/scripts/sdk/index.ts | 50 ++- resources/scripts/sdk/testing.tsx | 3 +- resources/scripts/sdk/theme.ts | 30 +- resources/scripts/sdk/ui.tsx | 32 +- resources/scripts/setup-tests.ts | 5 + .../themes/__fixtures__/classic-classes.json | 28 +- .../scripts/themes/classic/skins/buttons.ts | 76 ++++ .../scripts/themes/classic/skins/data.ts | 37 ++ .../scripts/themes/classic/skins/feedback.ts | 127 ++++++ .../scripts/themes/classic/skins/forms.ts | 118 ++++++ .../scripts/themes/classic/skins/index.ts | 40 +- .../scripts/themes/classic/skins/overlays.ts | 100 +++++ .../scripts/themes/classic/skins/surfaces.ts | 41 ++ .../classic/views/dashboard/ServerCard.tsx | 35 +- .../classic/views/dashboard/ServerList.tsx | 15 +- .../scripts/themes/classicClasses.spec.tsx | 166 ++++---- resources/scripts/themes/primitives.ts | 236 +++++++++++ resources/scripts/themes/skins.spec.tsx | 260 ++++++++++++ resources/scripts/themes/skins.ts | 384 +++++++++++++++++- resources/scripts/views/boot.spec.tsx | 27 +- resources/scripts/views/boot.tsx | 10 +- 114 files changed, 3049 insertions(+), 1140 deletions(-) create mode 100644 docs-notes/skins.md create mode 100644 packages/sdk/types/components/Avatar.d.ts create mode 100644 packages/sdk/types/components/elements/Badge.d.ts create mode 100644 packages/sdk/types/components/elements/Card.d.ts create mode 100644 packages/sdk/types/components/elements/Code.d.ts create mode 100644 packages/sdk/types/components/elements/ListRow.d.ts create mode 100644 packages/sdk/types/components/elements/ProgressBar.d.ts create mode 100644 packages/sdk/types/themes/primitives.d.ts create mode 100644 resources/scripts/components/elements/Badge.tsx create mode 100644 resources/scripts/components/elements/Card.tsx delete mode 100644 resources/scripts/components/elements/GreyRowBox.tsx create mode 100644 resources/scripts/components/elements/ListRow.tsx create mode 100644 resources/scripts/themes/classic/skins/buttons.ts create mode 100644 resources/scripts/themes/classic/skins/data.ts create mode 100644 resources/scripts/themes/classic/skins/feedback.ts create mode 100644 resources/scripts/themes/classic/skins/forms.ts create mode 100644 resources/scripts/themes/classic/skins/overlays.ts create mode 100644 resources/scripts/themes/classic/skins/surfaces.ts create mode 100644 resources/scripts/themes/primitives.ts create mode 100644 resources/scripts/themes/skins.spec.tsx diff --git a/docs-notes/skins.md b/docs-notes/skins.md new file mode 100644 index 000000000..f4b6916b8 --- /dev/null +++ b/docs-notes/skins.md @@ -0,0 +1,111 @@ +# Skin reference (data for the docs lane) + +Source of truth: `resources/scripts/themes/primitives.ts` (`UiPrimitives`, `UI_PRIMITIVES`), the registry in +`resources/scripts/themes/skins.ts`, classic's recipes in `resources/scripts/themes/classic/skins/*.ts`. + +## API (`@pterodactyl/sdk/theme`) + +- `defineTheme({ ui })`: `ui` is `ThemeSkins`, keyed by primitive name. +- `skin(name, skin)` types a skin; `skin(name, (parent) => skin)` extends the layers below. The function form must go + through `skin()`: a bare function is read as a replacement component. +- Skin: `{ [part]: recipe }`. A recipe is a string, a cva recipe `{ base, variants, compoundVariants, defaultVariants }`, + or `(state) => string`. Variant keys are state keys; booleans use `'true'`/`'false'`. +- `parent` in the function form has every part resolved: `parent.root(state)` returns the classes below. +- `useSkin(name, state)` returns a binding: `ui(part, className?, partState?)` gives + `{ className, 'data-ui', 'data-part', data-* }` to spread; `ui.classes(part, className?, partState?)` gives the string. +- Types: `ThemeSkins`, `Skin`, `CompleteSkin`, `CompleteSkins`, `SkinRecipe`, `SkinRecipeConfig`, + `SkinCompoundVariant`, `ResolvedSkin`, `SkinExtension`, `SkinDefinition`, `SkinBinding`, + `SkinPartProps`, `SkinClassName`, `SkinPart`, `PrimitiveName`, `PrimitiveState`, `PrimitiveProps`, + `ReplaceableName`, `UiPrimitives`, `UiTone`, `NoState`, `SkinStateMap`, `SkinStateValue`, `PrimitiveMeta`; + value `UI_PRIMITIVES` (parts and `replaceable` per primitive). + +## Rules + +- Layers: classic, then the theme chain parent first. For each part the topmost recipe wins and replaces the one below + wholesale; nothing merges. Parts a skin leaves out keep the recipe below. +- The call-site `className` is appended with `cn()` (tailwind-merge), so it wins conflicts. +- Every part renders `data-ui=""` and `data-part=""`. The root also renders a `data-` per state + value (camelCase keys become kebab case: `richLabel` → `data-rich-label`). `true` renders as an empty attribute, + `false`/unset render nothing. A part given its own state (Dialog `icon`, Empty `media`, Pagination `page`) renders + that state on itself. +- Parts marked "classes only" below are passed as `className` to another primitive or element and carry no attributes. +- Presentational primitives can be replaced by a component receiving the identical props. The topmost replacement wins; + skins of all layers still resolve for the core components. A replacement must not render the primitive it replaces. +- Base UI primitives (and the other skin-only ones) cannot be replaced: a component there is a type error, and at + runtime it is ignored with a dev warning. Unknown primitive names and unknown parts are ignored with a dev warning. +- Resolution is memoised per primitive per layer stack; a recipe or extension that throws is skipped and logged. + +## Primitives + +`root` gets the bound state as `data-*`. Replaceable = may be a component. + +| Primitive | Parts | State (→ `data-*`) | Replaceable | +|---|---|---|---| +| Alert | root, icon, body, title, content | `type`: success, info, warning, danger | yes | +| Avatar | root | `variant`: beam, marble, pixel, sunset, ring, bauhaus | yes | +| Badge | root | `tone`: neutral, success, warning, danger, info, accent; `size`: sm, md; `variant`: solid, soft | yes | +| Button | root, spinner, label | `color`: primary, grey, green, red, orange; `size`: xsmall, small, large, xlarge; `secondary`; `loading` | yes | +| Card | root, header, title, icon, actions, body | `titled` (has a header); `actions`; `loading` | yes | +| Checkbox | root, indicator | none (Base UI sets `data-checked`, `data-indeterminate`, `data-disabled`) | no | +| Code | root | `dark` | no | +| CopyOnClick | root (toast), status, message, target (classes only, added to the clicked child) | `status`: copied, failed | no | +| Dialog | backdrop, viewport, container, root (popup), body, content, header, heading, title, description, spacer, footer, close, closeButton (classes only, on a Button), closeIcon, icon, iconGlyph | `described`; `type` on `icon`: danger, warning, success, info | no | +| DropdownMenu | trigger, positioner, root (popup) | `context` (ContextDropdownMenu) | no | +| DropdownMenuItem | root, icon, glyph, text, label, description | `danger`; `described` | no | +| Empty | root, header, media, title, description, content | `size`: default, compact; `variant` on `media`: default, icon | yes (root) | +| FileInput | root | none | no | +| Input | root | `light`; `error` | no | +| Label | root | `light` | no | +| ListRow | root | `interactive` | yes | +| NewButton | root (classes only, on the Button), content, icon | `link` (NewLinkButton) | no | +| NumberInput | root (NumberField), input | `light`; `error` | no | +| PageHeading | root, text, title, description, actions | none | yes | +| Pagination | root, page (classes only, on each page Button) | `current` on `page` | no | +| ProgressBar | root (track), indicator | `variant`: meter, page; `tone`: as Badge | yes | +| Select | root (input group), input, trigger, positioner, popup, list, item, itemLabel, indicator, empty, group, groupLabel, summary, preview | `error`; `multiple`; `selected`; `richLabel`; `searching` | no | +| Spinner | root, container (when centered) | `size`: small, base, large; `blue`; `centered` | yes | +| SpinnerOverlay | root, text | `fixed` | no | +| Switch | root, control, thumb, text, label (classes only, on the Label), description | `described`; `position`: start, end | no | +| Table | root, empty, scroller, table, head, headerRow, headerCell, body, row, cell | `fetching` | no | +| TextArea | root | `light`; `error` | no | +| Tooltip | root, arrow | `side`: top, right, bottom, left; `arrow` | no | + +## Components and props (`@pterodactyl/sdk`) + +Button (`ButtonProps`, `ButtonColor`, `ButtonSize`; `Button.Text`, `Button.Danger`), LinkButton, RouterLinkButton, +NewButton/NewLinkButton (`NewButtonProps`, `NewLinkButtonProps`), Input (`InputProps`), TextArea (`TextAreaProps`), +NumberInput (`NumberInputProps`), FileInput (`FileInputProps`), Select (`SelectProps`), Checkbox (`CheckboxProps`), +Switch (`SwitchProps`), Label (`LabelProps`), Dialog (`DialogProps`, `DialogIconProps`; `Dialog.Footer`, `Dialog.Icon`, +`Dialog.Confirm`), Alert (`AlertProps`, `AlertType`), Tooltip (`TooltipProps`), DropdownMenu / DropdownMenuItem / +ContextDropdownMenu (`DropdownMenuProps`, `DropdownMenuItemProps`, `ContextDropdownMenuProps`), Table (`TableProps`), +Pagination (`PaginationProps`), Empty + EmptyHeader/EmptyMedia/EmptyTitle/EmptyDescription/EmptyContent (`EmptyProps`, +`EmptySize`, `EmptyMediaVariant`), Spinner (`SpinnerProps`), SpinnerOverlay (`SpinnerOverlayProps`), Avatar +(`AvatarProps`), ProgressBar (`ProgressBarProps`), Code (`CodeProps`), CopyOnClick (`CopyOnClickProps`), Card +(`CardProps`), ListRow (`ListRowProps`), Badge (`BadgeProps`), PageHeading (`PageHeadingProps`). ContentBox and +TitledGreyBox remain as thin wrappers over Card. + +## Recipes + +```tsx +export default defineTheme({ + ui: { + // Replaces Button's root recipe; spinner and label keep classic's. + Button: skin('Button', { + root: { + base: 'inline-flex h-9 items-center rounded-full px-4 font-medium', + variants: { color: { primary: 'bg-primary text-primary-foreground hover:bg-primary/90' } }, + compoundVariants: [{ secondary: true, color: 'primary', class: 'bg-transparent text-primary' }], + }, + }), + // Builds on the classes below. + Card: skin('Card', (parent) => ({ root: (state) => `${parent.root(state)} backdrop-blur-xl bg-card/60` })), + // Presentational primitives can be components with the same props. + Badge: AuroraBadge, + }, +}); +``` + +Classic's normalised variants: plain `hover:`/`active:` guarded with `not-disabled:` on Button +(`hover:not-disabled:bg-primary/80`), `data-checked:`/`data-highlighted:`/`data-starting-style:` instead of +`data-[…]:`, `z-9999`, and `(--var)` shorthands. Rendered classes are otherwise unchanged +(`resources/scripts/themes/classicClasses.spec.tsx`). diff --git a/packages/sdk/types/components/Avatar.d.ts b/packages/sdk/types/components/Avatar.d.ts new file mode 100644 index 000000000..4f32abe2a --- /dev/null +++ b/packages/sdk/types/components/Avatar.d.ts @@ -0,0 +1,18 @@ +// Generated by scripts/generate-sdk-types.mjs. Do not edit. +export type AvatarVariant = 'beam' | 'marble' | 'pixel' | 'sunset' | 'ring' | 'bauhaus'; +export interface AvatarProps { + /** Seeds the generated pattern; the panel uses a user's UUID. */ + name: string; + size?: number | string; + variant?: AvatarVariant; + square?: boolean; + title?: boolean; + className?: string; +} +declare const Avatar: ((props: AvatarProps) => import("react").ReactElement) & { + User: { + (props: Omit): import("react").JSX.Element; + displayName: string; + }; +}; +export default Avatar; diff --git a/packages/sdk/types/components/elements/Badge.d.ts b/packages/sdk/types/components/elements/Badge.d.ts new file mode 100644 index 000000000..07b6d3847 --- /dev/null +++ b/packages/sdk/types/components/elements/Badge.d.ts @@ -0,0 +1,13 @@ +// Generated by scripts/generate-sdk-types.mjs. Do not edit. +import type React from 'react'; +import { type UiTone } from "../../themes/skins.js"; +export type BadgeSize = 'sm' | 'md'; +/** `solid` fills the badge with its tone; `soft` tints it. */ +export type BadgeVariant = 'solid' | 'soft'; +export interface BadgeProps extends React.HTMLAttributes { + tone?: UiTone; + size?: BadgeSize; + variant?: BadgeVariant; +} +declare const Badge: (props: BadgeProps) => React.ReactElement; +export default Badge; diff --git a/packages/sdk/types/components/elements/Button.d.ts b/packages/sdk/types/components/elements/Button.d.ts index 04869782b..8c94df006 100644 --- a/packages/sdk/types/components/elements/Button.d.ts +++ b/packages/sdk/types/components/elements/Button.d.ts @@ -1,33 +1,34 @@ // Generated by scripts/generate-sdk-types.mjs. Do not edit. import React from 'react'; import { Link } from '@tanstack/react-router'; +export type ButtonColor = 'green' | 'red' | 'orange' | 'primary' | 'grey'; +export type ButtonSize = 'xsmall' | 'small' | 'large' | 'xlarge'; interface Props { isLoading?: boolean; - size?: 'xsmall' | 'small' | 'large' | 'xlarge'; - color?: 'green' | 'red' | 'orange' | 'primary' | 'grey'; + size?: ButtonSize; + color?: ButtonColor; isSecondary?: boolean; } -declare const buttonClassName: ({ color, size, isSecondary, className, }: Omit & { +type StyleableProps = Omit; +/** The root classes of a button, for elements styled as one outside a component. */ +declare const buttonClassName: ({ className, ...props }: StyleableProps & { className?: string; }) => string; -type StyleableProps = Omit; type ButtonStyleProps = { as?: E; ref?: React.ComponentPropsWithRef['ref']; } & StyleableProps & Omit, keyof StyleableProps | 'as'>; +/** Any element, styled as a button. */ declare const ButtonStyle: ({ as, color, size, isSecondary, className, ref, ...props }: ButtonStyleProps) => React.JSX.Element; -type ComponentProps = Omit, keyof Props> & Props; +export type ButtonProps = Omit, keyof Props> & Props; /** Defaults to `type="button"`; `isLoading` shows a spinner and disables the button. */ -declare const Button: { - ({ children, isLoading, disabled, type, ref, ...props }: ComponentProps): React.JSX.Element; - displayName: string; -}; +declare const Button: (props: ButtonProps) => React.ReactElement; declare const TextButton: { - ({ ref, ...props }: ComponentProps): React.JSX.Element; + ({ ref, ...props }: ButtonProps): React.JSX.Element; displayName: string; }; declare const DangerButton: { - ({ ref, ...props }: ComponentProps): React.JSX.Element; + ({ ref, ...props }: ButtonProps): React.JSX.Element; displayName: string; }; declare const ButtonWithVariants: typeof Button & { diff --git a/packages/sdk/types/components/elements/Card.d.ts b/packages/sdk/types/components/elements/Card.d.ts new file mode 100644 index 000000000..8e06a1963 --- /dev/null +++ b/packages/sdk/types/components/elements/Card.d.ts @@ -0,0 +1,19 @@ +// Generated by scripts/generate-sdk-types.mjs. Do not edit. +import type React from 'react'; +import type { LucideIcon } from 'lucide-react'; +export interface CardProps { + /** A string renders as the card's heading; any other node replaces it. */ + title?: React.ReactNode; + /** Shown before a string title. */ + icon?: LucideIcon; + /** Controls placed at the end of the header. */ + actions?: React.ReactNode; + /** Covers the card with a spinner. */ + loading?: boolean; + className?: string; + /** Classes for the body of a card with a header. */ + bodyClassName?: string; + children?: React.ReactNode; +} +declare const Card: (props: CardProps) => React.ReactElement; +export default Card; diff --git a/packages/sdk/types/components/elements/Code.d.ts b/packages/sdk/types/components/elements/Code.d.ts new file mode 100644 index 000000000..f4e1e5ea3 --- /dev/null +++ b/packages/sdk/types/components/elements/Code.d.ts @@ -0,0 +1,8 @@ +// Generated by scripts/generate-sdk-types.mjs. Do not edit. +import React from 'react'; +export interface CodeProps { + dark?: boolean | undefined; + className?: string; + children: React.ReactNode; +} +export default function Code({ dark, className, children }: CodeProps): React.JSX.Element; diff --git a/packages/sdk/types/components/elements/ContentBox.d.ts b/packages/sdk/types/components/elements/ContentBox.d.ts index 73cf3c40d..73f70a77c 100644 --- a/packages/sdk/types/components/elements/ContentBox.d.ts +++ b/packages/sdk/types/components/elements/ContentBox.d.ts @@ -5,5 +5,6 @@ type Props = Readonly; +/** A section title above a plain `Card`. */ declare const ContentBox: ({ title, borderColor, showLoadingOverlay, children, ...props }: Props) => React.JSX.Element; export default ContentBox; diff --git a/packages/sdk/types/components/elements/CopyOnClick.d.ts b/packages/sdk/types/components/elements/CopyOnClick.d.ts index af79b42d8..9a168b9c3 100644 --- a/packages/sdk/types/components/elements/CopyOnClick.d.ts +++ b/packages/sdk/types/components/elements/CopyOnClick.d.ts @@ -1,6 +1,6 @@ // Generated by scripts/generate-sdk-types.mjs. Do not edit. import React from 'react'; -interface CopyOnClickProps { +export interface CopyOnClickProps { text: string | number | null | undefined; showInNotification?: boolean; children: React.ReactNode; diff --git a/packages/sdk/types/components/elements/Label.d.ts b/packages/sdk/types/components/elements/Label.d.ts index c37335308..49df30845 100644 --- a/packages/sdk/types/components/elements/Label.d.ts +++ b/packages/sdk/types/components/elements/Label.d.ts @@ -1,8 +1,8 @@ // Generated by scripts/generate-sdk-types.mjs. Do not edit. import React from 'react'; -type Props = { +export type LabelProps = { as?: E; isLight?: boolean; } & Omit, 'as' | 'isLight'>; -declare const Label: ({ as, isLight, className, ...props }: Props) => React.JSX.Element; +declare const Label: ({ as, isLight, className, ...props }: LabelProps) => React.JSX.Element; export default Label; diff --git a/packages/sdk/types/components/elements/ListRow.d.ts b/packages/sdk/types/components/elements/ListRow.d.ts new file mode 100644 index 000000000..4fbd29629 --- /dev/null +++ b/packages/sdk/types/components/elements/ListRow.d.ts @@ -0,0 +1,13 @@ +// Generated by scripts/generate-sdk-types.mjs. Do not edit. +import React from 'react'; +import { type PanelDestination } from "../../sdk/navigation.js"; +export interface ListRowProps extends React.HTMLAttributes { + as?: 'div' | 'li' | 'article'; + /** Renders the row as a link to the destination. */ + destination?: PanelDestination; + exact?: boolean; + /** Hover and press feedback; on for links and clickable rows unless set. */ + interactive?: boolean; +} +declare const ListRow: (props: ListRowProps) => React.ReactElement; +export default ListRow; diff --git a/packages/sdk/types/components/elements/NewButton.d.ts b/packages/sdk/types/components/elements/NewButton.d.ts index 54cb19279..bad9231cf 100644 --- a/packages/sdk/types/components/elements/NewButton.d.ts +++ b/packages/sdk/types/components/elements/NewButton.d.ts @@ -1,15 +1,17 @@ // Generated by scripts/generate-sdk-types.mjs. Do not edit. import type * as React from 'react'; import { type LucideIcon } from 'lucide-react'; -import Button, { RouterLinkButton } from "./Button.js"; +import { RouterLinkButton, type ButtonProps } from "./Button.js"; interface IconProps { /** Replaces the Plus for sibling toolbar actions such as Upload. */ icon?: LucideIcon; } +export type NewButtonProps = ButtonProps & IconProps; /** The panel's "create" action: a Plus icon and a sentence-case label such as "New node". */ -export declare function NewButton({ icon, className, children, ...props }: React.ComponentProps & IconProps): React.JSX.Element; -/** `NewButton` for actions that navigate to a create page. */ -export declare function NewLinkButton({ icon, className, children, ...props }: Omit, 'children'> & IconProps & { +export declare function NewButton({ icon, className, children, ...props }: NewButtonProps): React.JSX.Element; +export type NewLinkButtonProps = Omit, 'children'> & IconProps & { children: React.ReactNode; -}): React.JSX.Element; +}; +/** `NewButton` for actions that navigate to a create page. */ +export declare function NewLinkButton({ icon, className, children, ...props }: NewLinkButtonProps): React.JSX.Element; export {}; diff --git a/packages/sdk/types/components/elements/PageHeading.d.ts b/packages/sdk/types/components/elements/PageHeading.d.ts index 3d4962fd2..14d80eaec 100644 --- a/packages/sdk/types/components/elements/PageHeading.d.ts +++ b/packages/sdk/types/components/elements/PageHeading.d.ts @@ -1,10 +1,10 @@ // Generated by scripts/generate-sdk-types.mjs. Do not edit. -import React from 'react'; -interface Props { +import type React from 'react'; +export interface PageHeadingProps { title: React.ReactNode; description?: React.ReactNode; actions?: React.ReactNode; className?: string; } -export default function PageHeading({ title, description, actions, className }: Props): React.JSX.Element; -export {}; +declare const PageHeading: (props: PageHeadingProps) => React.ReactElement; +export default PageHeading; diff --git a/packages/sdk/types/components/elements/Pagination.d.ts b/packages/sdk/types/components/elements/Pagination.d.ts index 8ce906797..5a9fd8f95 100644 --- a/packages/sdk/types/components/elements/Pagination.d.ts +++ b/packages/sdk/types/components/elements/Pagination.d.ts @@ -5,7 +5,7 @@ interface RenderFuncProps { isLastPage: boolean; isFirstPage: boolean; } -interface Props { +export interface PaginationProps { data: GeneratedPaginatedResult; showGoToLast?: boolean; showGoToFirst?: boolean; @@ -24,5 +24,5 @@ interface GeneratedPaginatedResult { }; }; } -declare function Pagination({ data, onPageSelect, children }: Props): React.JSX.Element; +declare function Pagination({ data, onPageSelect, children }: PaginationProps): React.JSX.Element; export default Pagination; diff --git a/packages/sdk/types/components/elements/ProgressBar.d.ts b/packages/sdk/types/components/elements/ProgressBar.d.ts new file mode 100644 index 000000000..f950b1463 --- /dev/null +++ b/packages/sdk/types/components/elements/ProgressBar.d.ts @@ -0,0 +1,18 @@ +// Generated by scripts/generate-sdk-types.mjs. Do not edit. +import { type UiTone } from "../../themes/skins.js"; +/** `meter` shows a value in a track; `page` is the loading bar along the top of the page. */ +export type ProgressBarVariant = 'meter' | 'page'; +export interface ProgressBarProps { + /** Percent complete from 0 to 100; `null` shows the track alone. */ + value: number | null; + variant?: ProgressBarVariant; + /** Defaults to `accent` for the page bar and `neutral` otherwise. */ + tone?: UiTone; + /** Names a meter for assistive technology. */ + label?: string; + className?: string; +} +declare const ProgressBar: (props: ProgressBarProps) => import("react").ReactElement; +export default ProgressBar; +/** The page loading bar, driven by the panel's HTTP requests. */ +export declare function HttpProgressBar(): import("react").JSX.Element; diff --git a/packages/sdk/types/components/elements/Spinner.d.ts b/packages/sdk/types/components/elements/Spinner.d.ts index 7414ba8aa..225830b5f 100644 --- a/packages/sdk/types/components/elements/Spinner.d.ts +++ b/packages/sdk/types/components/elements/Spinner.d.ts @@ -1,16 +1,16 @@ // Generated by scripts/generate-sdk-types.mjs. Do not edit. import React from 'react'; export type SpinnerSize = 'small' | 'base' | 'large'; -interface Props { +export interface SpinnerProps { size?: SpinnerSize; centered?: boolean; isBlue?: boolean; children?: React.ReactNode; } -type SpinnerComponentType = ((props: Props) => React.JSX.Element) & { +type SpinnerComponentType = ((props: SpinnerProps) => React.JSX.Element) & { displayName?: string; Size: Record<'SMALL' | 'BASE' | 'LARGE', SpinnerSize>; - Suspense: ((props: Props) => React.JSX.Element) & { + Suspense: ((props: SpinnerProps) => React.JSX.Element) & { displayName?: string; }; }; diff --git a/packages/sdk/types/components/elements/SpinnerOverlay.d.ts b/packages/sdk/types/components/elements/SpinnerOverlay.d.ts index 108d5c476..d22b1cceb 100644 --- a/packages/sdk/types/components/elements/SpinnerOverlay.d.ts +++ b/packages/sdk/types/components/elements/SpinnerOverlay.d.ts @@ -1,12 +1,12 @@ // Generated by scripts/generate-sdk-types.mjs. Do not edit. import React from 'react'; import type { SpinnerSize } from "./Spinner.js"; -interface Props { +export interface SpinnerOverlayProps { visible: boolean; fixed?: boolean; size?: SpinnerSize; backgroundOpacity?: number; children?: React.ReactNode; } -declare const SpinnerOverlay: ({ size, fixed, visible, backgroundOpacity, children }: Props) => React.JSX.Element | null; +declare const SpinnerOverlay: ({ size, fixed, visible, backgroundOpacity, children }: SpinnerOverlayProps) => React.JSX.Element | null; export default SpinnerOverlay; diff --git a/packages/sdk/types/components/elements/TitledGreyBox.d.ts b/packages/sdk/types/components/elements/TitledGreyBox.d.ts index 81e9b3f80..c6652527d 100644 --- a/packages/sdk/types/components/elements/TitledGreyBox.d.ts +++ b/packages/sdk/types/components/elements/TitledGreyBox.d.ts @@ -8,5 +8,6 @@ interface Props { contentClassName?: string; children: React.ReactNode; } +/** A `Card` with a header. */ declare const TitledGreyBox: ({ icon, title, children, className, contentClassName }: Props) => React.JSX.Element; export default TitledGreyBox; diff --git a/packages/sdk/types/components/elements/alert/Alert.d.ts b/packages/sdk/types/components/elements/alert/Alert.d.ts index 0d0eb0145..2709b1265 100644 --- a/packages/sdk/types/components/elements/alert/Alert.d.ts +++ b/packages/sdk/types/components/elements/alert/Alert.d.ts @@ -1,11 +1,11 @@ // Generated by scripts/generate-sdk-types.mjs. Do not edit. import React from 'react'; export type AlertType = 'success' | 'info' | 'warning' | 'danger'; -interface AlertProps { +export interface AlertProps { type: AlertType; title?: React.ReactNode; className?: string; children: React.ReactNode; } -export default function Alert({ type, title, className, children }: AlertProps): React.JSX.Element; -export {}; +declare const Alert: (props: AlertProps) => React.ReactElement; +export default Alert; diff --git a/packages/sdk/types/components/elements/alert/index.d.ts b/packages/sdk/types/components/elements/alert/index.d.ts index 360b226a5..141688a1e 100644 --- a/packages/sdk/types/components/elements/alert/index.d.ts +++ b/packages/sdk/types/components/elements/alert/index.d.ts @@ -1,3 +1,3 @@ // Generated by scripts/generate-sdk-types.mjs. Do not edit. export { default as Alert } from "./Alert.js"; -export type { AlertType } from "./Alert.js"; +export type { AlertProps, AlertType } from "./Alert.js"; diff --git a/packages/sdk/types/components/elements/dialog/types.d.ts b/packages/sdk/types/components/elements/dialog/types.d.ts index 40d48d3e8..07f55c54b 100644 --- a/packages/sdk/types/components/elements/dialog/types.d.ts +++ b/packages/sdk/types/components/elements/dialog/types.d.ts @@ -25,6 +25,8 @@ export interface RenderDialogProps extends DialogProps { } export interface DialogContextType { - setIcon: Callback; + setIcon: Callback; setIconPosition: Callback; + /** The state the dialog's skin reads, for parts rendered by its children. */ + described: boolean; } diff --git a/packages/sdk/types/components/elements/dropdown/DropdownMenu.d.ts b/packages/sdk/types/components/elements/dropdown/DropdownMenu.d.ts index 7eb52a902..7aca34c1a 100644 --- a/packages/sdk/types/components/elements/dropdown/DropdownMenu.d.ts +++ b/packages/sdk/types/components/elements/dropdown/DropdownMenu.d.ts @@ -2,7 +2,7 @@ import React from 'react'; import { Menu } from '@base-ui/react/menu'; import type { LucideIcon } from 'lucide-react'; -interface DropdownMenuProps { +export interface DropdownMenuProps { /** Rendered inside the trigger ` + ); +} /** Defaults to `type="button"`; `isLoading` shows a spinner and disables the button. */ -const Button = ({ children, isLoading, disabled, type = 'button', ref, ...props }: ComponentProps) => ( - - {isLoading && ( - - - - )} - {children} - -); +const Button = replaceable('Button', CoreButton); -Button.displayName = 'Button'; - -const TextButton = ({ ref, ...props }: ComponentProps) => ); } +export type NewLinkButtonProps = Omit, 'children'> & + IconProps & { children: React.ReactNode }; + /** `NewButton` for actions that navigate to a create page. */ -export function NewLinkButton({ - icon = Plus, - className, - children, - ...props -}: Omit, 'children'> & IconProps & { children: React.ReactNode }) { +export function NewLinkButton({ icon = Plus, className, children, ...props }: NewLinkButtonProps) { + const ui = useSkin('NewButton', { link: true }); + return ( - - + + {children} ); diff --git a/resources/scripts/components/elements/PageHeading.tsx b/resources/scripts/components/elements/PageHeading.tsx index 800251656..b6a76fc21 100644 --- a/resources/scripts/components/elements/PageHeading.tsx +++ b/resources/scripts/components/elements/PageHeading.tsx @@ -1,22 +1,27 @@ -import React from 'react'; -import { cn } from '@/lib/cn'; -import { pageTitleClass } from '@/components/ui/typography'; +import type React from 'react'; +import { replaceable, useSkin } from '@/themes/skins'; -interface Props { +export interface PageHeadingProps { title: React.ReactNode; description?: React.ReactNode; actions?: React.ReactNode; className?: string; } -export default function PageHeading({ title, description, actions, className }: Props) { +function CorePageHeading({ title, description, actions, className }: PageHeadingProps) { + const ui = useSkin('PageHeading', {}); + return ( -
-
-

{title}

- {description &&

{description}

} +
+
+

{title}

+ {description &&

{description}

}
- {actions &&
{actions}
} + {actions &&
{actions}
}
); } + +const PageHeading = replaceable('PageHeading', CorePageHeading); + +export default PageHeading; diff --git a/resources/scripts/components/elements/Pagination.tsx b/resources/scripts/components/elements/Pagination.tsx index b75c50912..e0414dbd3 100644 --- a/resources/scripts/components/elements/Pagination.tsx +++ b/resources/scripts/components/elements/Pagination.tsx @@ -1,8 +1,8 @@ import React from 'react'; -import { cn } from '@/lib/cn'; import Button from '@/components/elements/Button'; import { ChevronsLeft, ChevronsRight } from 'lucide-react'; import Icon from '@/components/elements/Icon'; +import { useSkin, type SkinBinding } from '@/themes/skins'; interface RenderFuncProps { items: T[]; @@ -10,7 +10,7 @@ interface RenderFuncProps { isFirstPage: boolean; } -interface Props { +export interface PaginationProps { data: GeneratedPaginatedResult; showGoToLast?: boolean; showGoToFirst?: boolean; @@ -39,8 +39,18 @@ interface PaginationDataSet { totalPages: number; } -const Block = ({ className, ...props }: React.ComponentProps) => ( -