@forwardreach/saas-ui 0.4.0 → 0.7.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/dist/components/account-menu.d.ts +42 -0
  3. package/dist/components/account-menu.js +41 -0
  4. package/dist/components/button.d.ts +1 -1
  5. package/dist/components/choice-card.d.ts +33 -0
  6. package/dist/components/choice-card.js +40 -0
  7. package/dist/components/combobox.d.ts +37 -0
  8. package/dist/components/combobox.js +103 -0
  9. package/dist/components/dropdown-menu.d.ts +9 -1
  10. package/dist/components/dropdown-menu.js +8 -5
  11. package/dist/components/form-field.d.ts +48 -0
  12. package/dist/components/form-field.js +51 -0
  13. package/dist/components/index.d.ts +12 -0
  14. package/dist/components/index.js +12 -0
  15. package/dist/components/input.js +2 -1
  16. package/dist/components/overflow-menu.d.ts +40 -0
  17. package/dist/components/overflow-menu.js +15 -0
  18. package/dist/components/rail-toggle.d.ts +19 -0
  19. package/dist/components/rail-toggle.js +17 -0
  20. package/dist/components/select.d.ts +9 -0
  21. package/dist/components/select.js +12 -0
  22. package/dist/components/settings-layout.d.ts +10 -0
  23. package/dist/components/settings-layout.js +10 -0
  24. package/dist/components/settings-nav.d.ts +46 -0
  25. package/dist/components/settings-nav.js +21 -0
  26. package/dist/components/switch.d.ts +20 -0
  27. package/dist/components/switch.js +28 -0
  28. package/dist/components/textarea.js +2 -1
  29. package/dist/components/time-zone-field.d.ts +30 -0
  30. package/dist/components/time-zone-field.js +72 -0
  31. package/dist/components/workspace-switcher.d.ts +33 -0
  32. package/dist/components/workspace-switcher.js +34 -0
  33. package/dist/styles/index.css +3 -0
  34. package/dist/utils/index.d.ts +1 -0
  35. package/dist/utils/index.js +1 -0
  36. package/dist/utils/time-zones.d.ts +26 -0
  37. package/dist/utils/time-zones.js +79 -0
  38. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { cn } from "../utils/cn.js";
4
- export const Input = React.forwardRef(({ className, type = "text", ...props }, ref) => (_jsx("input", { ref: ref, type: type, className: cn("flex h-10 w-full rounded-[var(--ssui-radius)] border border-[color:var(--ssui-border)] bg-[color:var(--ssui-surface)] px-3 py-2 text-sm text-[color:var(--ssui-text)] shadow-sm transition-colors placeholder:text-[color:var(--ssui-text-subtle)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--ssui-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-[color:var(--ssui-bg)] disabled:cursor-not-allowed disabled:bg-[color:var(--ssui-surface-muted)] disabled:opacity-70", className), ...props })));
4
+ import { useFormFieldProps } from "./form-field.js";
5
+ export const Input = React.forwardRef(({ className, type = "text", ...props }, ref) => (_jsx("input", { ref: ref, type: type, className: cn("flex h-10 w-full rounded-[var(--ssui-radius)] border border-[color:var(--ssui-border)] bg-[color:var(--ssui-surface)] px-3 py-2 text-sm text-[color:var(--ssui-text)] shadow-sm transition-colors placeholder:text-[color:var(--ssui-text-subtle)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--ssui-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-[color:var(--ssui-bg)] disabled:cursor-not-allowed disabled:bg-[color:var(--ssui-surface-muted)] disabled:opacity-70", className), ...useFormFieldProps(props) })));
5
6
  Input.displayName = "Input";
@@ -0,0 +1,40 @@
1
+ import * as React from "react";
2
+ import { type IconButtonProps } from "./button.js";
3
+ export interface OverflowMenuProps {
4
+ /** Accessible label and tooltip for the trigger button. Defaults to "More actions". */
5
+ label?: string;
6
+ /** Which edge of the trigger the panel aligns to. Defaults to "end". */
7
+ align?: "start" | "center" | "end";
8
+ /** Trigger icon-button size. Defaults to "icon-sm". */
9
+ size?: IconButtonProps["size"];
10
+ /** Trigger icon-button visual variant. Defaults to "ghost". */
11
+ variant?: IconButtonProps["variant"];
12
+ /** Disable the trigger. */
13
+ disabled?: boolean;
14
+ /** Open the panel by default (uncontrolled). Mainly useful in tests. */
15
+ defaultOpen?: boolean;
16
+ /**
17
+ * Trap focus and lock scroll while open (Radix's default). Pass `false` for a
18
+ * lightweight menu that doesn't take the page modal — appropriate for inline
19
+ * affordances embedded in a larger surface.
20
+ */
21
+ modal?: boolean;
22
+ /**
23
+ * Portal the panel to `document.body` (the default). Pass `false` to render it
24
+ * inline next to the trigger, keeping it inside the trigger's DOM subtree.
25
+ */
26
+ portal?: boolean;
27
+ /** Extra classes for the trigger button. */
28
+ triggerClassName?: string;
29
+ /** Extra classes for the panel. */
30
+ contentClassName?: string;
31
+ /** Menu contents — typically `OverflowMenuItem`s separated by `OverflowMenuSeparator`. */
32
+ children: React.ReactNode;
33
+ }
34
+ /**
35
+ * A "⋯" icon-button that opens a dropdown of low-frequency, whole-object actions.
36
+ * Built on the Radix `DropdownMenu` primitives; compose the panel with
37
+ * `OverflowMenuItem` (and `OverflowMenuSeparator`) as children.
38
+ */
39
+ export declare function OverflowMenu({ label, align, size, variant, disabled, defaultOpen, modal, portal, triggerClassName, contentClassName, children, }: OverflowMenuProps): import("react/jsx-runtime").JSX.Element;
40
+ export { DropdownMenuItem as OverflowMenuItem, DropdownMenuSeparator as OverflowMenuSeparator, } from "./dropdown-menu.js";
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { MoreHorizontal } from "lucide-react";
4
+ import * as React from "react";
5
+ import { IconButton } from "./button.js";
6
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger, } from "./dropdown-menu.js";
7
+ /**
8
+ * A "⋯" icon-button that opens a dropdown of low-frequency, whole-object actions.
9
+ * Built on the Radix `DropdownMenu` primitives; compose the panel with
10
+ * `OverflowMenuItem` (and `OverflowMenuSeparator`) as children.
11
+ */
12
+ export function OverflowMenu({ label = "More actions", align = "end", size = "icon-sm", variant = "ghost", disabled, defaultOpen, modal, portal, triggerClassName, contentClassName, children, }) {
13
+ return (_jsxs(DropdownMenu, { defaultOpen: defaultOpen, modal: modal, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(IconButton, { className: triggerClassName, disabled: disabled, label: label, size: size, variant: variant, children: _jsx(MoreHorizontal, {}) }) }), _jsx(DropdownMenuContent, { align: align, className: contentClassName, portal: portal, children: children })] }));
14
+ }
15
+ export { DropdownMenuItem as OverflowMenuItem, DropdownMenuSeparator as OverflowMenuSeparator, } from "./dropdown-menu.js";
@@ -0,0 +1,19 @@
1
+ export interface RailToggleProps {
2
+ /** Current rail state; the toggle renders the action that would change it. */
3
+ collapsed: boolean;
4
+ onToggle: () => void;
5
+ /** Accessible label + tooltip when the rail is expanded. Defaults to "Collapse sidebar". */
6
+ collapseLabel?: string;
7
+ /** Accessible label + tooltip when the rail is collapsed. Defaults to "Expand sidebar". */
8
+ expandLabel?: string;
9
+ /** Optional shortcut rendered muted next to the tooltip label (e.g. "⌘\\"). */
10
+ shortcutHint?: string;
11
+ className?: string;
12
+ }
13
+ /**
14
+ * Icon-only ghost toggle for collapsing/expanding the app-shell rail, meant to
15
+ * sit in the rail header beside the `WorkspaceSwitcher`. Presentational on
16
+ * purpose: collapse state, persistence, and any keyboard shortcut binding are
17
+ * consumer-owned — this only reflects state and fires `onToggle`.
18
+ */
19
+ export declare function RailToggle({ collapsed, onToggle, collapseLabel, expandLabel, shortcutHint, className, }: RailToggleProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { PanelLeftClose, PanelLeftOpen } from "lucide-react";
4
+ import * as React from "react";
5
+ import { cn } from "../utils/cn.js";
6
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip.js";
7
+ /**
8
+ * Icon-only ghost toggle for collapsing/expanding the app-shell rail, meant to
9
+ * sit in the rail header beside the `WorkspaceSwitcher`. Presentational on
10
+ * purpose: collapse state, persistence, and any keyboard shortcut binding are
11
+ * consumer-owned — this only reflects state and fires `onToggle`.
12
+ */
13
+ export function RailToggle({ collapsed, onToggle, collapseLabel = "Collapse sidebar", expandLabel = "Expand sidebar", shortcutHint, className, }) {
14
+ const label = collapsed ? expandLabel : collapseLabel;
15
+ const Icon = collapsed ? PanelLeftOpen : PanelLeftClose;
16
+ return (_jsx(TooltipProvider, { delayDuration: 300, children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", "aria-expanded": !collapsed, "aria-label": label, onClick: onToggle, className: cn("flex size-8 shrink-0 items-center justify-center rounded-[var(--ssui-radius-sm)] text-[color:var(--ssui-text-subtle)] outline-none transition-colors hover:bg-[color:var(--ssui-overlay-hover)] hover:text-[color:var(--ssui-text-muted)] focus-visible:ring-2 focus-visible:ring-[color:var(--ssui-focus-ring)]", className), children: _jsx(Icon, { className: "size-4" }) }) }), _jsxs(TooltipContent, { side: collapsed ? "right" : "bottom", children: [label, shortcutHint ? (_jsx("span", { className: "ms-1.5 text-[color:var(--ssui-text-subtle)]", children: shortcutHint })) : null] })] }) }));
17
+ }
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ export interface SelectProps extends React.SelectHTMLAttributes<HTMLSelectElement> {
3
+ }
4
+ /**
5
+ * Styled native `<select>` matching the shared `Input` look, with a trailing
6
+ * chevron. Native on purpose: correct mobile behavior and form participation
7
+ * with zero positioning code. Participates in `FormField` wiring.
8
+ */
9
+ export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLSelectElement>>;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ChevronDown } from "lucide-react";
3
+ import * as React from "react";
4
+ import { cn } from "../utils/cn.js";
5
+ import { useFormFieldProps } from "./form-field.js";
6
+ /**
7
+ * Styled native `<select>` matching the shared `Input` look, with a trailing
8
+ * chevron. Native on purpose: correct mobile behavior and form participation
9
+ * with zero positioning code. Participates in `FormField` wiring.
10
+ */
11
+ export const Select = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs("div", { className: cn("relative", className), children: [_jsx("select", { ref: ref, className: "flex h-10 w-full cursor-pointer appearance-none rounded-[var(--ssui-radius)] border border-[color:var(--ssui-border)] bg-[color:var(--ssui-surface)] py-2 pl-3 pr-9 text-sm text-[color:var(--ssui-text)] shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--ssui-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-[color:var(--ssui-bg)] disabled:cursor-not-allowed disabled:bg-[color:var(--ssui-surface-muted)] disabled:opacity-70", ...useFormFieldProps(props), children: children }), _jsx(ChevronDown, { "aria-hidden": "true", className: "pointer-events-none absolute right-3 top-1/2 size-4 -translate-y-1/2 text-[color:var(--ssui-text-subtle)]" })] })));
12
+ Select.displayName = "Select";
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ export interface SettingsLayoutProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ /** Settings navigation, typically a `SettingsNav`. */
4
+ nav: React.ReactNode;
5
+ }
6
+ /**
7
+ * Centered, max-width settings shell: nav as a left sidebar beside the
8
+ * content on `md+`, stacked above full-width content on small screens.
9
+ */
10
+ export declare function SettingsLayout({ nav, className, children, ...props }: SettingsLayoutProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { cn } from "../utils/cn.js";
4
+ /**
5
+ * Centered, max-width settings shell: nav as a left sidebar beside the
6
+ * content on `md+`, stacked above full-width content on small screens.
7
+ */
8
+ export function SettingsLayout({ nav, className, children, ...props }) {
9
+ return (_jsxs("div", { className: cn("mx-auto flex max-w-6xl flex-col gap-6 px-4 py-5 md:flex-row md:px-8 md:py-8", className), ...props, children: [nav, _jsx("div", { className: "min-w-0 flex-1", children: children })] }));
10
+ }
@@ -0,0 +1,46 @@
1
+ import * as React from "react";
2
+ export interface SettingsNavItem {
3
+ href: string;
4
+ label: React.ReactNode;
5
+ /** Optional leading icon (e.g. a lucide icon element). */
6
+ icon?: React.ReactNode;
7
+ }
8
+ export interface SettingsNavGroup {
9
+ label: React.ReactNode;
10
+ items: SettingsNavItem[];
11
+ }
12
+ /**
13
+ * Minimal contract for an injected link component: it must accept `href`,
14
+ * `className`, `aria-current`, and children. Next.js `Link` satisfies this.
15
+ */
16
+ export type SettingsNavLinkComponent = React.ElementType<{
17
+ href: string;
18
+ className?: string;
19
+ "aria-current"?: "page";
20
+ children?: React.ReactNode;
21
+ }>;
22
+ export interface SettingsNavProps extends Omit<React.HTMLAttributes<HTMLElement>, "children"> {
23
+ /** Navigation groups, each a labeled set of items. */
24
+ groups: SettingsNavGroup[];
25
+ /** Href of the active item. Ignored when `isActive` is provided. */
26
+ activeHref?: string;
27
+ /** Predicate for active state; use for nested-route or alias matching. */
28
+ isActive?: (href: string) => boolean;
29
+ /**
30
+ * Component used to render item links (e.g. Next.js `Link`).
31
+ * Defaults to a plain anchor.
32
+ */
33
+ linkComponent?: SettingsNavLinkComponent;
34
+ /** Heading shown above the groups. Defaults to "Settings". */
35
+ heading?: React.ReactNode;
36
+ /** Accessible label for the nav landmark. Defaults to "Settings". */
37
+ "aria-label"?: string;
38
+ }
39
+ /**
40
+ * Grouped settings navigation: section-labeled link groups with icons and
41
+ * active highlighting. Renders as a sidebar column on `md+` and collapses to
42
+ * a horizontally scrollable row on small screens (pair with `SettingsLayout`).
43
+ * Router-agnostic: active state comes from `activeHref`/`isActive` and links
44
+ * render through `linkComponent`.
45
+ */
46
+ export declare function SettingsNav({ groups, activeHref, isActive, linkComponent, heading, className, "aria-label": ariaLabel, ...props }: SettingsNavProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { SlidersHorizontal } from "lucide-react";
3
+ import * as React from "react";
4
+ import { cn } from "../utils/cn.js";
5
+ /**
6
+ * Grouped settings navigation: section-labeled link groups with icons and
7
+ * active highlighting. Renders as a sidebar column on `md+` and collapses to
8
+ * a horizontally scrollable row on small screens (pair with `SettingsLayout`).
9
+ * Router-agnostic: active state comes from `activeHref`/`isActive` and links
10
+ * render through `linkComponent`.
11
+ */
12
+ export function SettingsNav({ groups, activeHref, isActive, linkComponent, heading = "Settings", className, "aria-label": ariaLabel = "Settings", ...props }) {
13
+ const LinkComponent = linkComponent ?? "a";
14
+ const activeFor = isActive ?? ((href) => href === activeHref);
15
+ return (_jsxs("aside", { className: cn("space-y-3 md:w-56 md:shrink-0", className), ...props, children: [heading ? (_jsxs("div", { className: "flex items-center gap-2 text-xs font-semibold uppercase text-[color:var(--ssui-text-subtle)]", children: [_jsx(SlidersHorizontal, { "aria-hidden": "true", className: "size-3.5" }), heading] })) : null, _jsx("nav", { "aria-label": ariaLabel, className: "flex gap-4 overflow-x-auto pb-1 md:flex-col md:gap-5 md:overflow-visible md:pb-0", children: groups.map((group, groupIndex) => (_jsxs("div", { className: "min-w-max md:min-w-0", children: [_jsx("div", { className: "mb-1.5 px-2.5 text-[0.68rem] font-semibold uppercase text-[color:var(--ssui-text-subtle)]", children: group.label }), _jsx("div", { className: "flex gap-1 md:flex-col", children: group.items.map((item) => {
16
+ const active = activeFor(item.href);
17
+ return (_jsxs(LinkComponent, { href: item.href, "aria-current": active ? "page" : undefined, className: cn("flex shrink-0 items-center gap-2 rounded-[var(--ssui-radius)] px-2.5 py-1.5 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--ssui-focus-ring)]", active
18
+ ? "bg-[color:var(--ssui-surface-muted)] text-[color:var(--ssui-text)]"
19
+ : "text-[color:var(--ssui-text-muted)] hover:bg-[color:var(--ssui-overlay-hover)] hover:text-[color:var(--ssui-text)]"), children: [item.icon ? (_jsx("span", { "aria-hidden": "true", className: "shrink-0 [&_svg]:size-4", children: item.icon })) : null, item.label] }, item.href));
20
+ }) })] }, groupIndex))) })] }));
21
+ }
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ export interface SwitchProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onChange" | "value" | "type" | "role" | "aria-checked"> {
3
+ /** Controlled checked state. */
4
+ checked?: boolean;
5
+ /** Uncontrolled initial state. */
6
+ defaultChecked?: boolean;
7
+ onCheckedChange?: (checked: boolean) => void;
8
+ /** When set, submits the value under this name via a hidden checkbox. */
9
+ name?: string;
10
+ /** Submitted value when checked. Defaults to "on". */
11
+ value?: string;
12
+ }
13
+ /**
14
+ * Accessible boolean toggle: a `role="switch"` button with a track and thumb.
15
+ * Space/Enter toggle (native button activation), `aria-checked` reflects
16
+ * state. Track colors come from `--ssui-switch-track` /
17
+ * `--ssui-switch-track-checked` tokens with neutral fallbacks. Optional form
18
+ * participation via a hidden checkbox when `name` is provided.
19
+ */
20
+ export declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../utils/cn.js";
5
+ import { useFormFieldProps } from "./form-field.js";
6
+ /**
7
+ * Accessible boolean toggle: a `role="switch"` button with a track and thumb.
8
+ * Space/Enter toggle (native button activation), `aria-checked` reflects
9
+ * state. Track colors come from `--ssui-switch-track` /
10
+ * `--ssui-switch-track-checked` tokens with neutral fallbacks. Optional form
11
+ * participation via a hidden checkbox when `name` is provided.
12
+ */
13
+ export const Switch = React.forwardRef(({ checked, defaultChecked = false, onCheckedChange, name, value = "on", className, disabled, onClick, ...props }, ref) => {
14
+ const [uncontrolledChecked, setUncontrolledChecked] = React.useState(defaultChecked);
15
+ const isChecked = checked ?? uncontrolledChecked;
16
+ function handleClick(event) {
17
+ onClick?.(event);
18
+ if (event.defaultPrevented)
19
+ return;
20
+ if (checked === undefined)
21
+ setUncontrolledChecked(!isChecked);
22
+ onCheckedChange?.(!isChecked);
23
+ }
24
+ return (_jsxs(_Fragment, { children: [_jsx("button", { ref: ref, type: "button", role: "switch", "aria-checked": isChecked, "data-state": isChecked ? "checked" : "unchecked", disabled: disabled, onClick: handleClick, className: cn("inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-transparent p-0.5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--ssui-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-[color:var(--ssui-bg)] disabled:cursor-not-allowed disabled:opacity-50", isChecked
25
+ ? "bg-[color:var(--ssui-switch-track-checked,var(--ssui-primary))]"
26
+ : "bg-[color:var(--ssui-switch-track,var(--ssui-border))]", className), ...useFormFieldProps(props), children: _jsx("span", { "aria-hidden": "true", className: cn("block size-5 rounded-full bg-[color:var(--ssui-switch-thumb,#ffffff)] shadow-sm transition-transform", isChecked ? "translate-x-4" : "translate-x-0") }) }), name ? (_jsx("input", { type: "checkbox", "aria-hidden": "true", tabIndex: -1, className: "sr-only", checked: isChecked, disabled: disabled, name: name, value: value, readOnly: true })) : null] }));
27
+ });
28
+ Switch.displayName = "Switch";
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { cn } from "../utils/cn.js";
4
- export const Textarea = React.forwardRef(({ className, rows = 4, ...props }, ref) => (_jsx("textarea", { ref: ref, rows: rows, className: cn("flex min-h-24 w-full resize-y rounded-[var(--ssui-radius)] border border-[color:var(--ssui-border)] bg-[color:var(--ssui-surface)] px-3 py-2 text-sm text-[color:var(--ssui-text)] shadow-sm transition-colors placeholder:text-[color:var(--ssui-text-subtle)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--ssui-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-[color:var(--ssui-bg)] disabled:cursor-not-allowed disabled:bg-[color:var(--ssui-surface-muted)] disabled:opacity-70", className), ...props })));
4
+ import { useFormFieldProps } from "./form-field.js";
5
+ export const Textarea = React.forwardRef(({ className, rows = 4, ...props }, ref) => (_jsx("textarea", { ref: ref, rows: rows, className: cn("flex min-h-24 w-full resize-y rounded-[var(--ssui-radius)] border border-[color:var(--ssui-border)] bg-[color:var(--ssui-surface)] px-3 py-2 text-sm text-[color:var(--ssui-text)] shadow-sm transition-colors placeholder:text-[color:var(--ssui-text-subtle)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--ssui-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-[color:var(--ssui-bg)] disabled:cursor-not-allowed disabled:bg-[color:var(--ssui-surface-muted)] disabled:opacity-70", className), ...useFormFieldProps(props) })));
5
6
  Textarea.displayName = "Textarea";
@@ -0,0 +1,30 @@
1
+ import type { TimeZoneOption } from "../utils/time-zones.js";
2
+ export type TimeZoneMode = "auto" | "fixed";
3
+ export interface TimeZoneFieldProps {
4
+ /** Initial mode. Defaults to "auto". */
5
+ defaultMode?: TimeZoneMode;
6
+ /** Initial fixed zone. Defaults to the detected browser zone. */
7
+ defaultTimeZone?: string;
8
+ /** Notified whenever mode or zone changes. */
9
+ onChange?: (state: {
10
+ mode: TimeZoneMode;
11
+ timeZone: string;
12
+ }) => void;
13
+ /**
14
+ * Zone options to render; defaults to `timeZoneOptions()` computed
15
+ * client-side. Provide to SSR the list or trim it.
16
+ */
17
+ options?: TimeZoneOption[];
18
+ /** Accessible label for the mode choice. Defaults to "Time zone mode". */
19
+ "aria-label"?: string;
20
+ className?: string;
21
+ }
22
+ /**
23
+ * Composite time-zone preference control: an auto/fixed mode choice rendered
24
+ * as `ChoiceCard`s (auto shows the detected browser zone inline) plus a
25
+ * filterable zone `Combobox` shown only in fixed mode. Search matches zone
26
+ * names with spaces or underscores and offset text ("GMT+09"). Submits
27
+ * through hidden inputs — `timeZoneMode`, `timeZone`, `browserTimeZone` —
28
+ * for server-action form handling.
29
+ */
30
+ export declare function TimeZoneField({ defaultMode, defaultTimeZone, onChange, options, className, "aria-label": ariaLabel, }: TimeZoneFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../utils/cn.js";
5
+ import { detectBrowserTimeZone, formatTimeZoneOffset, timeZoneOptions, } from "../utils/time-zones.js";
6
+ import { ChoiceCard, ChoiceCardGroup } from "./choice-card.js";
7
+ import { Combobox } from "./combobox.js";
8
+ function matchesZoneQuery(option, query) {
9
+ const normalized = query.trim().toLowerCase();
10
+ if (!normalized)
11
+ return true;
12
+ const underscored = normalized.replaceAll(" ", "_");
13
+ const haystacks = [
14
+ option.value.toLowerCase(),
15
+ option.label.toLowerCase(),
16
+ typeof option.trailing === "string" ? option.trailing.toLowerCase() : "",
17
+ ];
18
+ return haystacks.some((haystack) => haystack.includes(normalized) || haystack.includes(underscored));
19
+ }
20
+ /**
21
+ * Composite time-zone preference control: an auto/fixed mode choice rendered
22
+ * as `ChoiceCard`s (auto shows the detected browser zone inline) plus a
23
+ * filterable zone `Combobox` shown only in fixed mode. Search matches zone
24
+ * names with spaces or underscores and offset text ("GMT+09"). Submits
25
+ * through hidden inputs — `timeZoneMode`, `timeZone`, `browserTimeZone` —
26
+ * for server-action form handling.
27
+ */
28
+ export function TimeZoneField({ defaultMode = "auto", defaultTimeZone, onChange, options, className, "aria-label": ariaLabel = "Time zone mode", }) {
29
+ const [mode, setMode] = React.useState(defaultMode);
30
+ const [browserTimeZone, setBrowserTimeZone] = React.useState("UTC");
31
+ const [fixedTimeZone, setFixedTimeZone] = React.useState(defaultTimeZone ?? "");
32
+ // Detection runs in an effect so server and first client render agree.
33
+ React.useEffect(() => {
34
+ const detected = detectBrowserTimeZone();
35
+ setBrowserTimeZone(detected);
36
+ setFixedTimeZone((current) => current || detected);
37
+ }, []);
38
+ // Building the full IANA list constructs one `Intl.DateTimeFormat` per zone
39
+ // (~400 of them, tens of ms). The combobox only renders in fixed mode, so
40
+ // defer the build until fixed is first selected, then cache it for the
41
+ // component's lifetime. Consumer-provided `options` skip the build entirely.
42
+ const builtOptionsRef = React.useRef(null);
43
+ const comboboxOptions = React.useMemo(() => {
44
+ if (options) {
45
+ return options.map((zone) => ({
46
+ value: zone.value,
47
+ label: zone.label,
48
+ trailing: zone.offset,
49
+ }));
50
+ }
51
+ if (mode !== "fixed")
52
+ return [];
53
+ if (!builtOptionsRef.current) {
54
+ builtOptionsRef.current = timeZoneOptions().map((zone) => ({
55
+ value: zone.value,
56
+ label: zone.label,
57
+ trailing: zone.offset,
58
+ }));
59
+ }
60
+ return builtOptionsRef.current;
61
+ }, [options, mode]);
62
+ function update(next) {
63
+ const nextMode = next.mode ?? mode;
64
+ const nextZone = next.timeZone ?? fixedTimeZone;
65
+ if (next.mode !== undefined)
66
+ setMode(next.mode);
67
+ if (next.timeZone !== undefined)
68
+ setFixedTimeZone(next.timeZone);
69
+ onChange?.({ mode: nextMode, timeZone: nextZone });
70
+ }
71
+ return (_jsxs("div", { className: cn("space-y-3", className), children: [_jsx("input", { name: "timeZoneMode", type: "hidden", value: mode }), _jsx("input", { name: "timeZone", type: "hidden", value: fixedTimeZone }), _jsx("input", { name: "browserTimeZone", type: "hidden", value: browserTimeZone }), _jsxs(ChoiceCardGroup, { "aria-label": ariaLabel, onValueChange: (value) => update({ mode: value }), value: mode, children: [_jsx(ChoiceCard, { description: _jsxs(_Fragment, { children: ["Use the browser time zone", _jsxs("span", { className: "mt-0.5 block font-mono text-[color:var(--ssui-text-muted)]", children: [browserTimeZone, " (", formatTimeZoneOffset(browserTimeZone), ")"] })] }), title: "Auto", value: "auto" }), _jsx(ChoiceCard, { description: "Always use one time zone", title: "Fixed", value: "fixed" })] }), mode === "fixed" ? (_jsx(Combobox, { "aria-label": "Fixed time zone", emptyMessage: "No matching time zones", filter: matchesZoneQuery, onValueChange: (value) => update({ timeZone: value }), options: comboboxOptions, placeholder: "America/New_York", value: fixedTimeZone })) : null] }));
72
+ }
@@ -0,0 +1,33 @@
1
+ import * as React from "react";
2
+ export interface WorkspaceSwitcherWorkspace {
3
+ id: string;
4
+ name: string;
5
+ }
6
+ export interface WorkspaceSwitcherProps {
7
+ workspaces: ReadonlyArray<WorkspaceSwitcherWorkspace>;
8
+ activeWorkspaceId: string;
9
+ /** Called with the selected workspace id; never fired for the active row. */
10
+ onSelect: (id: string) => void | Promise<void>;
11
+ /**
12
+ * Brand badge rendered at the left of the trigger (e.g. a product tile).
13
+ * Defaults to a primary-colored tile with the active workspace's initials.
14
+ */
15
+ badge?: React.ReactNode;
16
+ /** Icon-only rail state: badge-only trigger with a name tooltip, menu opens right. */
17
+ collapsed?: boolean;
18
+ /** Renders a separated "New workspace" item when provided. */
19
+ onCreateWorkspace?: () => void;
20
+ /** Defaults to "New workspace". */
21
+ createWorkspaceLabel?: string;
22
+ /** Open the menu by default (uncontrolled). Mainly useful in tests. */
23
+ defaultOpen?: boolean;
24
+ /** Extra classes for the trigger. */
25
+ className?: string;
26
+ }
27
+ /**
28
+ * Top-left workspace context menu for the app shell: a trigger showing the
29
+ * brand badge and active workspace name, opening a list of the user's
30
+ * workspaces with the active one checked. Identity/session actions
31
+ * deliberately do not belong here; that's the bottom-left `AccountMenu`.
32
+ */
33
+ export declare function WorkspaceSwitcher({ workspaces, activeWorkspaceId, onSelect, badge, collapsed, onCreateWorkspace, createWorkspaceLabel, defaultOpen, className, }: WorkspaceSwitcherProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,34 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
4
+ import { Check, ChevronDown, Plus } from "lucide-react";
5
+ import * as React from "react";
6
+ import { cn } from "../utils/cn.js";
7
+ import { getInitials } from "../utils/initials.js";
8
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "./dropdown-menu.js";
9
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip.js";
10
+ /**
11
+ * Top-left workspace context menu for the app shell: a trigger showing the
12
+ * brand badge and active workspace name, opening a list of the user's
13
+ * workspaces with the active one checked. Identity/session actions
14
+ * deliberately do not belong here; that's the bottom-left `AccountMenu`.
15
+ */
16
+ export function WorkspaceSwitcher({ workspaces, activeWorkspaceId, onSelect, badge, collapsed = false, onCreateWorkspace, createWorkspaceLabel = "New workspace", defaultOpen, className, }) {
17
+ const active = workspaces.find((workspace) => workspace.id === activeWorkspaceId);
18
+ const activeName = active?.name ?? "";
19
+ // Mirror open state for the chevron cue: the trigger's data-state is
20
+ // unreliable here because TooltipTrigger's own data-state wins the
21
+ // asChild prop merge over DropdownMenuTrigger's.
22
+ const [open, setOpen] = React.useState(defaultOpen ?? false);
23
+ return (_jsxs(DropdownMenu, { open: open, onOpenChange: setOpen, children: [_jsx(TooltipProvider, { delayDuration: 300, children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { type: "button", "aria-label": collapsed ? activeName : `Switch workspace (current: ${activeName})`, className: cn("flex h-10 w-full items-center gap-2 rounded-[var(--ssui-radius)] px-1.5 text-left outline-none transition-colors hover:bg-[color:var(--ssui-overlay-hover)] focus-visible:ring-2 focus-visible:ring-[color:var(--ssui-focus-ring)]",
24
+ // Collapsed = badge-only: the label/chevron are omitted from the
25
+ // layout entirely (not just faded) so the trigger truly fits an
26
+ // icon rail instead of relying on horizontal clipping.
27
+ collapsed && "justify-center px-0", className), children: [_jsx("span", { className: "flex shrink-0 items-center justify-center", children: badge ?? (_jsx("span", { className: "flex size-7 items-center justify-center rounded-[var(--ssui-radius-sm)] bg-[color:var(--ssui-primary)] text-xs font-semibold text-[color:var(--ssui-primary-foreground)]", children: getInitials(activeName) })) }), !collapsed && (_jsxs(_Fragment, { children: [_jsx("span", { className: "min-w-0 flex-1 truncate text-[13px] font-medium leading-tight text-[color:var(--ssui-text)]", children: activeName }), _jsx(ChevronDown, { className: cn("size-4 shrink-0 text-[color:var(--ssui-text-subtle)] transition-transform duration-150", open && "rotate-180") })] }))] }) }) }), collapsed ? _jsx(TooltipContent, { side: "right", children: activeName }) : null] }) }), _jsxs(DropdownMenuContent, { align: "start", className: "w-60 min-w-[var(--radix-dropdown-menu-trigger-width)]", side: collapsed ? "right" : "bottom", sideOffset: 10, children: [_jsx(DropdownMenuPrimitive.RadioGroup, { value: activeWorkspaceId, onValueChange: (id) => {
28
+ if (id !== activeWorkspaceId)
29
+ void onSelect(id);
30
+ }, children: workspaces.map((workspace) => {
31
+ const isActive = workspace.id === activeWorkspaceId;
32
+ return (_jsxs(DropdownMenuPrimitive.RadioItem, { value: workspace.id, className: cn("relative flex cursor-default select-none items-center gap-2 rounded-[var(--ssui-radius-sm)] px-2 py-1.5 text-sm text-[color:var(--ssui-text)] outline-none transition-colors focus:bg-[color:var(--ssui-overlay-hover)] data-[highlighted]:bg-[color:var(--ssui-overlay-hover)]", isActive && "font-medium"), children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: workspace.name }), isActive ? (_jsx(Check, { className: "size-4 shrink-0 text-[color:var(--ssui-primary)]" })) : null] }, workspace.id));
33
+ }) }), onCreateWorkspace ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onSelect: () => onCreateWorkspace(), children: [_jsx(Plus, { className: "size-4 text-[color:var(--ssui-text-muted)]" }), createWorkspaceLabel] })] })) : null] })] }));
34
+ }
@@ -20,6 +20,9 @@
20
20
  --ssui-destructive-hover: #b91c1c;
21
21
  --ssui-destructive-foreground: #ffffff;
22
22
  --ssui-focus-ring: #2563eb;
23
+ --ssui-switch-track: var(--ssui-border);
24
+ --ssui-switch-track-checked: var(--ssui-primary);
25
+ --ssui-switch-thumb: #ffffff;
23
26
  --ssui-radius-sm: 0.25rem;
24
27
  --ssui-radius: 0.375rem;
25
28
  --ssui-radius-lg: 0.5rem;
@@ -1,3 +1,4 @@
1
1
  export * from "./cn.js";
2
2
  export * from "./initials.js";
3
3
  export * from "./time.js";
4
+ export * from "./time-zones.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./cn.js";
2
2
  export * from "./initials.js";
3
3
  export * from "./time.js";
4
+ export * from "./time-zones.js";
@@ -0,0 +1,26 @@
1
+ export interface TimeZoneOption {
2
+ /** IANA zone id, e.g. "America/New_York". */
3
+ value: string;
4
+ /** Display label, e.g. "America/New_York". */
5
+ label: string;
6
+ /** Current offset label, e.g. "GMT-04:00". */
7
+ offset: string;
8
+ /** Offset in minutes, for sorting. */
9
+ offsetMinutes: number;
10
+ }
11
+ /**
12
+ * Zones surfaced ahead of the full IANA list — the major business hubs both
13
+ * consuming products' audiences are most likely to pick.
14
+ */
15
+ export declare const COMMON_TIME_ZONES: string[];
16
+ /** Detect the browser's IANA time zone, falling back to UTC. */
17
+ export declare function detectBrowserTimeZone(): string;
18
+ /** Format a zone's current UTC offset as "GMT±HH:MM". Unknown zones map to GMT+00:00. */
19
+ export declare function formatTimeZoneOffset(timeZone: string, date?: Date): string;
20
+ /**
21
+ * Build the ordered, offset-annotated zone option list `TimeZoneField`
22
+ * renders: common zones first, then every zone the runtime supports, each
23
+ * sorted by current offset then name. Offsets are computed for `date`
24
+ * (defaults to now), so DST is reflected.
25
+ */
26
+ export declare function timeZoneOptions(date?: Date): TimeZoneOption[];
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Zones surfaced ahead of the full IANA list — the major business hubs both
3
+ * consuming products' audiences are most likely to pick.
4
+ */
5
+ export const COMMON_TIME_ZONES = [
6
+ "UTC",
7
+ "America/New_York",
8
+ "America/Chicago",
9
+ "America/Denver",
10
+ "America/Los_Angeles",
11
+ "America/Toronto",
12
+ "America/Vancouver",
13
+ "Europe/London",
14
+ "Europe/Paris",
15
+ "Europe/Berlin",
16
+ "Asia/Kolkata",
17
+ "Asia/Singapore",
18
+ "Asia/Tokyo",
19
+ "Australia/Sydney",
20
+ ];
21
+ /** Detect the browser's IANA time zone, falling back to UTC. */
22
+ export function detectBrowserTimeZone() {
23
+ try {
24
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
25
+ }
26
+ catch {
27
+ return "UTC";
28
+ }
29
+ }
30
+ /** Format a zone's current UTC offset as "GMT±HH:MM". Unknown zones map to GMT+00:00. */
31
+ export function formatTimeZoneOffset(timeZone, date = new Date()) {
32
+ try {
33
+ const parts = new Intl.DateTimeFormat("en-US", {
34
+ hour: "2-digit",
35
+ minute: "2-digit",
36
+ timeZone,
37
+ timeZoneName: "longOffset",
38
+ }).formatToParts(date);
39
+ const offset = parts.find((part) => part.type === "timeZoneName")?.value;
40
+ return offset && offset !== "GMT" ? offset : "GMT+00:00";
41
+ }
42
+ catch {
43
+ return "GMT+00:00";
44
+ }
45
+ }
46
+ function offsetMinutesFromLabel(offset) {
47
+ const match = offset.match(/^GMT([+-])(\d{2}):(\d{2})$/);
48
+ if (!match)
49
+ return 0;
50
+ const minutes = Number(match[2]) * 60 + Number(match[3]);
51
+ return match[1] === "-" ? -minutes : minutes;
52
+ }
53
+ function toOption(value, date) {
54
+ const offset = formatTimeZoneOffset(value, date);
55
+ return {
56
+ value,
57
+ label: value,
58
+ offset,
59
+ offsetMinutes: offsetMinutesFromLabel(offset),
60
+ };
61
+ }
62
+ /**
63
+ * Build the ordered, offset-annotated zone option list `TimeZoneField`
64
+ * renders: common zones first, then every zone the runtime supports, each
65
+ * sorted by current offset then name. Offsets are computed for `date`
66
+ * (defaults to now), so DST is reflected.
67
+ */
68
+ export function timeZoneOptions(date = new Date()) {
69
+ const intl = Intl;
70
+ const allZones = intl.supportedValuesOf?.("timeZone") ?? [];
71
+ const common = new Set(COMMON_TIME_ZONES);
72
+ const sortByOffsetThenName = (a, b) => a.offsetMinutes - b.offsetMinutes || a.value.localeCompare(b.value);
73
+ const commonOptions = COMMON_TIME_ZONES.map((zone) => toOption(zone, date)).sort(sortByOffsetThenName);
74
+ const rest = allZones
75
+ .filter((zone) => !common.has(zone))
76
+ .map((zone) => toOption(zone, date))
77
+ .sort(sortByOffsetThenName);
78
+ return [...commonOptions, ...rest];
79
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forwardreach/saas-ui",
3
- "version": "0.4.0",
3
+ "version": "0.7.0",
4
4
  "description": "Brand-neutral React UI primitives and SaaS app patterns for ForwardReach-owned business applications.",
5
5
  "type": "module",
6
6
  "private": false,