@brdgapp/ui 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  Every release of `@brdgapp/ui`. Versions follow the rules in README.md → Versions.
4
4
 
5
+ ## 1.8.0
6
+
7
+ 2026-11-19. A label option on Switch. Nothing changes for apps already on 1.7.
8
+
9
+ - Switch: `label` shows a visible label before the switch, in the toolbar's 13px SemiBold, for one on/off
10
+ view setting in a table toolbar ("Include people's network"). Clicking the label flips it, and it names the
11
+ switch for screen readers.
12
+
5
13
  ## 1.7.0
6
14
 
7
15
  2026-11-19. A search option on FilterPill. Nothing changes for apps already on 1.6.
@@ -1,13 +1,16 @@
1
+ import * as React from "react";
1
2
  type SwitchProps = {
2
3
  checked: boolean;
3
4
  onChange: (checked: boolean) => void;
4
5
  disabled?: boolean;
5
- /** A name is required: either `aria-label`, or `aria-labelledby` pointing at the visible label. */
6
+ /** A visible label before the switch, for a toolbar: "Include people's network". Clicking it flips the switch, and it names it. */
7
+ label?: string;
8
+ /** A name is required: `label`, `aria-label`, or `aria-labelledby` pointing at the visible label. */
6
9
  "aria-label"?: string;
7
10
  "aria-labelledby"?: string;
8
11
  id?: string;
9
12
  className?: string;
10
13
  };
11
- declare function Switch({ checked, onChange, disabled, className, ...props }: SwitchProps): import("react").JSX.Element;
14
+ declare function Switch({ checked, onChange, disabled, label, className, ...props }: SwitchProps): React.JSX.Element;
12
15
  export { Switch };
13
16
  export type { SwitchProps };
@@ -1,12 +1,17 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
3
4
  import { Switch as SwitchPrimitive } from "@base-ui/react/switch";
4
5
  import { cn } from "@brdgapp/ui/lib/utils";
5
- function Switch({ checked, onChange, disabled = false, className, ...props }) {
6
- return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", checked: checked, onCheckedChange: (next) => onChange(next), disabled: disabled, className: cn(
6
+ function Switch({ checked, onChange, disabled = false, label, className, ...props }) {
7
+ const labelId = React.useId();
8
+ const root = (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", checked: checked, onCheckedChange: (next) => onChange(next), disabled: disabled, className: cn(
7
9
  // Off is mid-grey, not pale: the track's edge has to reach 3:1 against the page (4.8:1 on white). 2026-11-04.
8
10
  "relative inline-flex h-5 w-9 shrink-0 items-center rounded-full bg-[var(--text-muted)] transition-colors duration-200 outline-none",
9
11
  // Hover steps darker in light and in dark, so the white thumb always stands out from the track.
10
- "hover:bg-[var(--text-secondary)] dark:hover:bg-[var(--text-disabled)] data-[checked]:hover:bg-[var(--primary-solid-hover)]", "focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-primary)]", "data-[checked]:bg-[var(--primary-solid)]", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: "inline-block size-4 translate-x-[2px] rounded-full bg-white shadow-[0_1px_2px_rgba(0,0,0,0.3)] transition-transform duration-200 data-[checked]:translate-x-[18px]" }) }));
12
+ "hover:bg-[var(--text-secondary)] dark:hover:bg-[var(--text-disabled)] data-[checked]:hover:bg-[var(--primary-solid-hover)]", "focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-primary)]", "data-[checked]:bg-[var(--primary-solid)]", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), ...props, "aria-labelledby": label ? labelId : props["aria-labelledby"], children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: "inline-block size-4 translate-x-[2px] rounded-full bg-white shadow-[0_1px_2px_rgba(0,0,0,0.3)] transition-transform duration-200 data-[checked]:translate-x-[18px]" }) }));
13
+ if (!label)
14
+ return root;
15
+ return (_jsxs("span", { "data-slot": "switch-field", className: "inline-flex shrink-0 items-center gap-2", children: [_jsx("span", { id: labelId, onClick: () => !disabled && onChange(!checked), className: cn("text-13 leading-normal font-semibold text-[var(--text-secondary)] select-none", disabled ? "opacity-50" : "cursor-pointer"), children: label }), root] }));
11
16
  }
12
17
  export { Switch };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brdgapp/ui",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Bridge's shared components, tokens and styles. Documented at handbook.brdg.app.",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://handbook.brdg.app",