@fairfox/polly 0.25.1 → 0.26.1

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,17 @@
1
+ /**
2
+ * Badge — small inline status chip.
3
+ *
4
+ * Renders as a passive <span> with tinted background and on-tint text
5
+ * from the `--polly-status-*` token family. The default variant uses
6
+ * surface-sunken + muted text for a neutral pill. Consumers style
7
+ * placement via className; the primitive owns size, shape, and colour.
8
+ */
9
+ import type { ComponentChildren, JSX } from "preact";
10
+ export type BadgeVariant = "default" | "info" | "success" | "warning" | "danger";
11
+ export type BadgeProps = {
12
+ children: ComponentChildren;
13
+ variant?: BadgeVariant;
14
+ className?: string;
15
+ id?: string;
16
+ };
17
+ export declare function Badge(props: BadgeProps): JSX.Element;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Button — interactive control with tier, semantic colour, and size.
3
+ *
4
+ * Renders as a <button> by default; switches to an <a> when given an
5
+ * `href`. Tier sets visual importance (primary/secondary/tertiary),
6
+ * color overlays semantic meaning (info/success/warning/danger),
7
+ * size picks the padding + font scale (small/normal/large). Icon +
8
+ * label are arranged with a nested inline <Layout>.
9
+ *
10
+ * Action wiring is declared via data-* attributes consumed by the
11
+ * global event delegator in @fairfox/polly/actions — Button does not
12
+ * accept an onClick prop.
13
+ */
14
+ import type { ComponentChildren, JSX, VNode } from "preact";
15
+ export type ButtonTier = "primary" | "secondary" | "tertiary";
16
+ export type ButtonColor = "default" | "info" | "success" | "warning" | "danger";
17
+ export type ButtonSize = "small" | "normal" | "large";
18
+ type BaseButtonProps = {
19
+ id?: string;
20
+ tier?: ButtonTier;
21
+ color?: ButtonColor;
22
+ size?: ButtonSize;
23
+ disabled?: boolean;
24
+ fullWidth?: boolean;
25
+ circle?: boolean;
26
+ className?: string;
27
+ title?: string;
28
+ icon?: VNode;
29
+ label: ComponentChildren;
30
+ "data-action"?: string;
31
+ "aria-label"?: string;
32
+ };
33
+ type ButtonAsButton = BaseButtonProps & {
34
+ href?: never;
35
+ target?: never;
36
+ rel?: never;
37
+ type?: "button" | "submit" | "reset";
38
+ };
39
+ type ButtonAsLink = BaseButtonProps & {
40
+ href: string;
41
+ target?: string;
42
+ rel?: string;
43
+ type?: never;
44
+ };
45
+ export type ButtonProps = ButtonAsButton | ButtonAsLink;
46
+ export declare function Button(props: ButtonProps): JSX.Element;
47
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Checkbox — native checkbox wrapped in a label.
3
+ *
4
+ * Pass a plain boolean for controlled use (caller listens elsewhere),
5
+ * or a Signal<boolean> to have the primitive bind its own change
6
+ * listener and mutate the signal directly. The label wraps the input
7
+ * so clicks anywhere in the target area toggle it.
8
+ */
9
+ import type { Signal } from "@preact/signals";
10
+ import type { JSX } from "preact";
11
+ export type CheckboxProps = {
12
+ checked?: boolean | Signal<boolean>;
13
+ defaultChecked?: boolean;
14
+ name?: string;
15
+ disabled?: boolean;
16
+ label?: string;
17
+ className?: string;
18
+ id?: string;
19
+ };
20
+ export declare function Checkbox(props: CheckboxProps): JSX.Element;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Collapsible — native <details>/<summary> wrapper.
3
+ *
4
+ * Uses the browser's built-in disclosure semantics so keyboard and
5
+ * screen-reader behaviour come free. A ::before arrow rotates on open.
6
+ * Colors, spacing, and motion come from tokens; `prefers-reduced-motion`
7
+ * zeroes the rotation via the motion token.
8
+ */
9
+ import type { ComponentChildren, JSX } from "preact";
10
+ export type CollapsibleProps = {
11
+ summary: string;
12
+ children: ComponentChildren;
13
+ defaultOpen?: boolean;
14
+ className?: string;
15
+ id?: string;
16
+ };
17
+ export declare function Collapsible(props: CollapsibleProps): JSX.Element;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Dropdown — trigger button + popover menu using the native Popover API.
3
+ *
4
+ * The menu element gets `popover="auto"` and a unique `data-overlay-id`.
5
+ * `closeTopOverlay()` from @fairfox/polly/actions finds the topmost
6
+ * `[data-overlay-id]` element and dispatches `overlay:close` — the
7
+ * Dropdown listens for that event and mirrors it onto the `isOpen`
8
+ * signal. In single-select mode, clicking the menu closes it; in
9
+ * multi-select mode, the menu stays open so the consumer can pick
10
+ * several items.
11
+ */
12
+ import { type Signal } from "@preact/signals";
13
+ import type { ComponentChildren, JSX } from "preact";
14
+ export type DropdownProps = {
15
+ isOpen: Signal<boolean>;
16
+ trigger: ComponentChildren;
17
+ children: ComponentChildren;
18
+ align?: "left" | "right";
19
+ multiSelect?: boolean;
20
+ className?: string;
21
+ id?: string;
22
+ };
23
+ export declare function Dropdown(props: DropdownProps): JSX.Element;
@@ -38,6 +38,8 @@ export type LayoutProps = {
38
38
  alignSelf?: string;
39
39
  /** Collapse to a single column at ≤640px. */
40
40
  stackOnMobile?: boolean;
41
+ /** Render as display: inline-grid so the Layout flows inline with surrounding text/controls. */
42
+ inline?: boolean;
41
43
  className?: string;
42
44
  onClick?: JSX.MouseEventHandler<HTMLElement>;
43
45
  onKeyDown?: JSX.KeyboardEventHandler<HTMLElement>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Select — dropdown of options with single- or multi-select semantics.
3
+ *
4
+ * Composes Dropdown for the menu and a native checkbox in each option
5
+ * row for multi-select. The `selected` state is a Signal<Set<T>>;
6
+ * single-select replaces the set, multi-select toggles membership.
7
+ * Multi-select mode also shows Select All / Clear action buttons at
8
+ * the top of the menu.
9
+ */
10
+ import { type Signal } from "@preact/signals";
11
+ import type { JSX } from "preact";
12
+ export type SelectOption<T = string> = {
13
+ value: T;
14
+ label: string;
15
+ };
16
+ export type SelectProps<T = string> = {
17
+ options: SelectOption<T>[];
18
+ selected: Signal<Set<T>>;
19
+ label?: string;
20
+ placeholder?: string;
21
+ multiSelect?: boolean;
22
+ disabled?: boolean;
23
+ className?: string;
24
+ id?: string;
25
+ };
26
+ export declare function Select<T = string>(props: SelectProps<T>): JSX.Element;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Skeleton — shimmering placeholder for loading states.
3
+ *
4
+ * Three variants: text (full-width, 1em tall), rect (full-width, 100px
5
+ * tall), circle (40x40). A CSS gradient animates left-to-right over
6
+ * 1.5s. `prefers-reduced-motion` zeroes the animation via the token
7
+ * system. Consumers size via width/height props (px numbers or CSS
8
+ * strings); default sizing comes from the variant.
9
+ */
10
+ import type { JSX } from "preact";
11
+ export type SkeletonVariant = "text" | "rect" | "circle";
12
+ export type SkeletonProps = {
13
+ variant?: SkeletonVariant;
14
+ width?: string | number;
15
+ height?: string | number;
16
+ className?: string;
17
+ };
18
+ export declare function Skeleton(props: SkeletonProps): JSX.Element;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Tabs — horizontal nav with active-tab accent.
3
+ *
4
+ * Each button carries `data-action` (the consumer-provided action name)
5
+ * and `data-action-id={tab.id}` so the event delegator resolves the
6
+ * activated tab. The active tab gets `aria-current="page"` and a
7
+ * bottom-border accent. The nav scrolls horizontally with a hidden
8
+ * scrollbar for overflow. Internal arrangement uses <Layout>.
9
+ */
10
+ import type { JSX } from "preact";
11
+ export type Tab = {
12
+ id: string;
13
+ label: string;
14
+ disabled?: boolean;
15
+ };
16
+ export type TabsProps = {
17
+ tabs: Tab[];
18
+ activeTab: string;
19
+ action?: string;
20
+ className?: string;
21
+ id?: string;
22
+ "aria-label"?: string;
23
+ };
24
+ export declare function Tabs(props: TabsProps): JSX.Element;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Toggle — switch-role checkbox.
3
+ *
4
+ * A visually-hidden <input role="switch"> paired with a styled track
5
+ * and thumb inside a <label>. Passive: the caller drives `checked` and
6
+ * handles state changes via the action registry (wrap the Toggle in a
7
+ * <label data-action="..."> or bind a parent form's submit). a11y
8
+ * attributes come from the native input; the label wraps so clicks
9
+ * anywhere in the control toggle the input.
10
+ */
11
+ import type { JSX } from "preact";
12
+ export type ToggleProps = {
13
+ checked?: boolean;
14
+ disabled?: boolean;
15
+ label?: string;
16
+ name?: string;
17
+ className?: string;
18
+ id?: string;
19
+ };
20
+ export declare function Toggle(props: ToggleProps): JSX.Element;