@kb.ui/react 0.13.0 → 0.14.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.
@@ -14,6 +14,8 @@ export type CopyableTextProps = Omit<ComponentProps<"span">, "onCopy"> & CopyFee
14
14
  appearance?: "field" | "plain" | undefined;
15
15
  /** Content and copy target density. */
16
16
  size?: "sm" | "md" | undefined;
17
+ /** Copy action height; defaults to `size`. */
18
+ copySize?: "sm" | "md" | "lg" | undefined;
17
19
  /** Monospace display for identifiers, paths, and commands. */
18
20
  mono?: boolean | undefined;
19
21
  /** Value color and subtle field tint; independent of clipboard state. */
@@ -35,4 +37,4 @@ export type CopyableTextProps = Omit<ComponentProps<"span">, "onCopy"> & CopyFee
35
37
  /** Extra classes for each rendered part. */
36
38
  classNames?: ClassNames<CopyableTextPart> | undefined;
37
39
  };
38
- export declare function CopyableText({ value, label, appearance, size, mono, tone, truncate, expandLabel, collapseLabel, highlight, linkify, format, language, copyLabel, copyingLabel, copiedLabel, copyErrorLabel, successMessage, errorMessage, disabled, feedbackDuration, onCopy, onCopyError, className, classNames, children, ...props }: CopyableTextProps): import("react").JSX.Element;
40
+ export declare function CopyableText({ value, label, appearance, size, copySize, mono, tone, truncate, expandLabel, collapseLabel, highlight, linkify, format, language, copyLabel, copyingLabel, copiedLabel, copyErrorLabel, successMessage, errorMessage, disabled, feedbackDuration, onCopy, onCopyError, className, classNames, children, ...props }: CopyableTextProps): import("react").JSX.Element;
@@ -1,12 +1,15 @@
1
1
  import { Toggle as Base } from "@base-ui/react/toggle";
2
2
  import type { Ref } from "react";
3
+ export type ToggleButtonSize = "sm" | "md" | "lg";
3
4
  type ManagedProp = "aria-pressed" | "form" | "nativeButton" | "render" | "role" | "type";
4
5
  export type ToggleButtonProps<Value extends string = string> = Omit<Base.Props<Value>, "className" | ManagedProp> & Partial<Record<ManagedProp, never>> & {
6
+ /** Control height on the shared sm, md and lg scale. */
7
+ size?: ToggleButtonSize | undefined;
5
8
  /** Extra class on the button. */
6
9
  className?: string | undefined;
7
10
  /** Ref to the underlying button. */
8
11
  ref?: Ref<HTMLButtonElement> | undefined;
9
12
  };
10
13
  /** A button with a persistent pressed state and a stable name. */
11
- export declare function ToggleButton<Value extends string = string>({ children, className, disabled, hidden, "aria-pressed": _ariaPressed, form: _form, nativeButton: _nativeButton, render: _render, role: _role, type: _type, ...props }: ToggleButtonProps<Value>): import("react").JSX.Element;
14
+ export declare function ToggleButton<Value extends string = string>({ children, className, disabled, hidden, size, "aria-pressed": _ariaPressed, form: _form, nativeButton: _nativeButton, render: _render, role: _role, type: _type, ...props }: ToggleButtonProps<Value>): import("react").JSX.Element;
12
15
  export {};
package/dist/index.d.ts CHANGED
@@ -66,7 +66,7 @@ export { Text, type TextElement, type TextProps, type TextSize, type TextTone, }
66
66
  export { Textarea, type TextareaPart, type TextareaProps, type TextareaResize, } from "./components/Textarea/Textarea";
67
67
  export { Thumbnail, type ThumbnailProps } from "./components/Thumbnail/Thumbnail";
68
68
  export { createToastManager, Toast, type ToastActionProps, type ToastAddOptions, type ToastCloseProps, type ToastContentProps, type ToastDescriptionProps, type ToastManager, type ToastObject, type ToastPlacement, type ToastPromiseOptions, type ToastProps, type ToastProviderProps, type ToastTitleProps, type ToastTone, type ToastUpdateOptions, type ToastViewportProps, useToastManager, } from "./components/Toast/Toast";
69
- export { ToggleButton, type ToggleButtonProps } from "./components/ToggleButton/ToggleButton";
69
+ export { ToggleButton, type ToggleButtonProps, type ToggleButtonSize, } from "./components/ToggleButton/ToggleButton";
70
70
  export { ToggleGroup, type ToggleGroupProps } from "./components/ToggleGroup/ToggleGroup";
71
71
  export { Toolbar, type ToolbarButtonProps, type ToolbarGroupProps, type ToolbarProps, type ToolbarSeparatorProps, } from "./components/Toolbar/Toolbar";
72
72
  export { Tooltip, type TooltipProps } from "./components/Tooltip/Tooltip";
package/dist/index.js CHANGED
@@ -2433,90 +2433,91 @@ function St(e, t) {
2433
2433
  }
2434
2434
  //#endregion
2435
2435
  //#region src/components/CopyableText/CopyableText.tsx
2436
- function Ct({ value: e, label: t, appearance: n = "field", size: r = "md", mono: i = !0, tone: a = "neutral", truncate: o = !1, expandLabel: s = "Show full value", collapseLabel: c = "Show less", highlight: l, linkify: u, format: p = "auto", language: m, copyLabel: h = "Copy", copyingLabel: g = "Copying…", copiedLabel: y = "Copied", copyErrorLabel: S = "Retry copy", successMessage: C = "Copied to clipboard", errorMessage: w = "Copy failed. Select and copy the text manually.", disabled: T, feedbackDuration: E, onCopy: D, onCopyError: O, className: k, classNames: A, children: j, ...M }) {
2437
- let N = f(), P = p === "text" ? void 0 : m ?? (p === "code" ? "tsx" : xt(e)), [F, I] = _({
2436
+ function Ct({ value: e, label: t, appearance: n = "field", size: r = "md", copySize: i = r, mono: a = !0, tone: o = "neutral", truncate: s = !1, expandLabel: c = "Show full value", collapseLabel: l = "Show less", highlight: u, linkify: p, format: m = "auto", language: h, copyLabel: g = "Copy", copyingLabel: y = "Copying…", copiedLabel: S = "Copied", copyErrorLabel: C = "Retry copy", successMessage: w = "Copied to clipboard", errorMessage: T = "Copy failed. Select and copy the text manually.", disabled: E, feedbackDuration: D, onCopy: O, onCopyError: k, className: A, classNames: j, children: M, ...N }) {
2437
+ let P = f(), F = m === "text" ? void 0 : h ?? (m === "code" ? "tsx" : xt(e)), [I, L] = _({
2438
2438
  value: e,
2439
2439
  open: !1
2440
- }), L = o && F.value === e && F.open;
2441
- d(() => I({
2440
+ }), R = s && I.value === e && I.open;
2441
+ d(() => L({
2442
2442
  value: e,
2443
2443
  open: !1
2444
2444
  }), [e]);
2445
- let R = ge(e, {
2446
- disabled: T,
2447
- feedbackDuration: E,
2448
- onCopy: D,
2445
+ let z = ge(e, {
2446
+ disabled: E,
2447
+ feedbackDuration: D,
2448
+ onCopy: O,
2449
2449
  onCopyError: (t) => {
2450
- I({
2450
+ L({
2451
2451
  value: e,
2452
2452
  open: !0
2453
- }), O?.(t);
2453
+ }), k?.(t);
2454
2454
  }
2455
- }), z = {
2456
- idle: h,
2457
- pending: g,
2458
- copied: y,
2459
- failed: S
2460
- }[R.state];
2455
+ }), B = {
2456
+ idle: g,
2457
+ pending: y,
2458
+ copied: S,
2459
+ failed: C
2460
+ }[z.state];
2461
2461
  return /* @__PURE__ */ x("span", {
2462
- ...M,
2462
+ ...N,
2463
2463
  ...G("copyabletext", {
2464
2464
  appearance: n,
2465
- format: P ? "code" : "text",
2465
+ format: F ? "code" : "text",
2466
2466
  size: r,
2467
- mono: i,
2468
- tone: a,
2469
- expandable: o,
2470
- expanded: L,
2471
- truncate: o && !L,
2472
- disabled: R.disabled,
2473
- "copy-state": R.state
2474
- }, k),
2467
+ mono: a,
2468
+ tone: o,
2469
+ expandable: s,
2470
+ expanded: R,
2471
+ truncate: s && !R,
2472
+ disabled: z.disabled,
2473
+ "copy-state": z.state
2474
+ }, A),
2475
2475
  children: [
2476
2476
  t ? /* @__PURE__ */ b("span", {
2477
- className: v("kb-copyabletext-label", A?.label),
2477
+ className: v("kb-copyabletext-label", j?.label),
2478
2478
  children: t
2479
2479
  }) : null,
2480
2480
  /* @__PURE__ */ b("span", {
2481
- className: v("kb-copyabletext-value", A?.value),
2482
- id: N,
2483
- children: j != null && !L && R.state !== "failed" ? j : St(e, {
2484
- highlight: l,
2485
- linkify: (u ?? p !== "text") && (!o || L),
2486
- detectCode: p !== "text",
2487
- codeLanguage: P,
2488
- codeClassName: A?.code,
2489
- highlightClassName: A?.highlight,
2490
- linkClassName: A?.link
2481
+ className: v("kb-copyabletext-value", j?.value),
2482
+ id: P,
2483
+ children: M != null && !R && z.state !== "failed" ? M : St(e, {
2484
+ highlight: u,
2485
+ linkify: (p ?? m !== "text") && (!s || R),
2486
+ detectCode: m !== "text",
2487
+ codeLanguage: F,
2488
+ codeClassName: j?.code,
2489
+ highlightClassName: j?.highlight,
2490
+ linkClassName: j?.link
2491
2491
  })
2492
2492
  }),
2493
2493
  /* @__PURE__ */ x("span", {
2494
- className: v("kb-copyabletext-actions", A?.actions),
2495
- children: [o ? /* @__PURE__ */ b("button", {
2494
+ className: v("kb-copyabletext-actions", j?.actions),
2495
+ children: [s ? /* @__PURE__ */ b("button", {
2496
2496
  type: "button",
2497
- className: v("kb-copyabletext-toggle", A?.toggle),
2498
- "aria-expanded": L,
2499
- "aria-controls": N,
2500
- onClick: () => I({
2497
+ className: v("kb-copyabletext-toggle", j?.toggle),
2498
+ "aria-expanded": R,
2499
+ "aria-controls": P,
2500
+ onClick: () => L({
2501
2501
  value: e,
2502
- open: !L
2502
+ open: !R
2503
2503
  }),
2504
- children: L ? c : s
2504
+ children: R ? l : c
2505
2505
  }) : null, /* @__PURE__ */ b("button", {
2506
2506
  type: "button",
2507
- className: v("kb-copyabletext-copy", A?.copy),
2508
- disabled: R.disabled,
2509
- "aria-disabled": R.state === "pending" || void 0,
2510
- onClick: () => void R.copy(),
2511
- children: z
2507
+ className: v("kb-copyabletext-copy", j?.copy),
2508
+ "data-size": i,
2509
+ disabled: z.disabled,
2510
+ "aria-disabled": z.state === "pending" || void 0,
2511
+ onClick: () => void z.copy(),
2512
+ children: B
2512
2513
  })]
2513
2514
  }),
2514
2515
  /* @__PURE__ */ b("span", {
2515
2516
  role: "status",
2516
2517
  "aria-live": "polite",
2517
2518
  "aria-atomic": "true",
2518
- className: v("kb-copyabletext-feedback", R.state !== "failed" && "kb-sr-only", A?.feedback),
2519
- children: R.state === "copied" ? C : R.state === "failed" ? w : R.state === "pending" ? g : ""
2519
+ className: v("kb-copyabletext-feedback", z.state !== "failed" && "kb-sr-only", j?.feedback),
2520
+ children: z.state === "copied" ? w : z.state === "failed" ? T : z.state === "pending" ? y : ""
2520
2521
  })
2521
2522
  ]
2522
2523
  });
@@ -4458,12 +4459,12 @@ var Rr = Object.assign(Ir, {
4458
4459
  });
4459
4460
  //#endregion
4460
4461
  //#region src/components/ToggleButton/ToggleButton.tsx
4461
- function zr({ children: e, className: t, disabled: n, hidden: r, "aria-pressed": i, form: a, nativeButton: o, render: s, role: c, type: l, ...u }) {
4462
+ function zr({ children: e, className: t, disabled: n, hidden: r, size: i = "md", "aria-pressed": a, form: o, nativeButton: s, render: c, role: l, type: u, ...d }) {
4462
4463
  return /* @__PURE__ */ x(z, {
4463
- ...u,
4464
+ ...d,
4464
4465
  hidden: r,
4465
4466
  disabled: n || r,
4466
- ...G("togglebutton", {}, t),
4467
+ ...G("togglebutton", { size: i }, t),
4467
4468
  children: [/* @__PURE__ */ b("span", {
4468
4469
  className: "kb-togglebutton-indicator",
4469
4470
  children: /* @__PURE__ */ b("svg", {