@ctrl-ui/react 0.8.13 → 0.8.15

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 (52) hide show
  1. package/dist/audio-device-select.d.ts +38 -0
  2. package/dist/audio-device-select.js +183 -0
  3. package/dist/audio-visualizer-bar.d.ts +10 -0
  4. package/dist/audio-visualizer-bar.js +49 -0
  5. package/dist/audio-visualizer-line.d.ts +4 -0
  6. package/dist/audio-visualizer-line.js +75 -0
  7. package/dist/audio-visualizer.d.ts +1 -1
  8. package/dist/audio-visualizer.js +43 -16
  9. package/dist/hooks/use-audio-recorder.d.ts +1 -0
  10. package/dist/hooks/use-audio-recorder.js +27 -4
  11. package/dist/hooks/use-color-area.js +0 -3
  12. package/dist/hooks/use-textarea-trigger-menu.js +5 -2
  13. package/dist/knob-contracts/audio-device-select-knobs.d.ts +4 -0
  14. package/dist/knob-contracts/audio-device-select-knobs.js +4 -0
  15. package/dist/knob-contracts/audio-visualizer-knobs.d.ts +1 -1
  16. package/dist/knob-contracts/audio-visualizer-knobs.js +2 -0
  17. package/dist/lib/audio-visualizer-levels.d.ts +12 -0
  18. package/dist/lib/audio-visualizer-levels.js +37 -0
  19. package/dist/lib/code-tokens.js +4 -1
  20. package/dist/lib/popup-item-focus.d.ts +7 -0
  21. package/dist/lib/popup-item-focus.js +9 -0
  22. package/dist/model-switcher.d.ts +23 -0
  23. package/dist/model-switcher.js +70 -0
  24. package/dist/styles/code.css +1 -1
  25. package/dist/styles/index.css +3 -2
  26. package/dist/styles/recipes/audio-device-select.css +15 -0
  27. package/dist/styles/recipes/audio-visualizer.css +97 -2
  28. package/dist/styles/recipes/popup-controls.css +11 -0
  29. package/dist/styles/recipes/popup-motion.css +6 -0
  30. package/dist/styles/recipes/tabs-motion.css +38 -28
  31. package/dist/styles/recipes/tabs.css +1 -0
  32. package/dist/styles/theme.css +43 -0
  33. package/dist/ui/alert-dialog.d.ts +3 -0
  34. package/dist/ui/alert-dialog.js +11 -1
  35. package/dist/ui/autocomplete.d.ts +1 -1
  36. package/dist/ui/color-picker.js +1 -1
  37. package/dist/ui/combobox.d.ts +1 -1
  38. package/dist/ui/context-menu.d.ts +1 -1
  39. package/dist/ui/context-menu.js +7 -4
  40. package/dist/ui/dialog.d.ts +3 -0
  41. package/dist/ui/dialog.js +11 -1
  42. package/dist/ui/dropdown-menu.d.ts +1 -1
  43. package/dist/ui/dropdown-menu.js +7 -4
  44. package/dist/ui/gradient-editor.js +1 -1
  45. package/dist/ui/item.js +1 -1
  46. package/dist/ui/responsive-dialog.d.ts +2 -1
  47. package/dist/ui/responsive-dialog.js +5 -2
  48. package/dist/ui/select.d.ts +1 -1
  49. package/dist/ui/select.js +3 -1
  50. package/dist/ui/sidebar-resize-rail.js +2 -2
  51. package/dist/ui/tabs.js +25 -14
  52. package/package.json +1 -1
package/dist/ui/dialog.js CHANGED
@@ -73,6 +73,16 @@ function DialogHeader({ className, ...props }) {
73
73
  ...props
74
74
  });
75
75
  }
76
+ function DialogBody({ className, ...props }) {
77
+ return /* @__PURE__ */ jsx("div", {
78
+ "data-control-ui": "dialog",
79
+ "data-control-family": "popup",
80
+ "data-popup-kind": "dialog",
81
+ "data-slot": "body",
82
+ className: cn("grid", className),
83
+ ...props
84
+ });
85
+ }
76
86
  function DialogFooter({ className, ...props }) {
77
87
  return /* @__PURE__ */ jsx("div", {
78
88
  "data-control-ui": "dialog",
@@ -104,4 +114,4 @@ function DialogDescription({ className, ...props }) {
104
114
  });
105
115
  }
106
116
  //#endregion
107
- export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger };
117
+ export { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger };
@@ -44,7 +44,7 @@ export declare function DropdownMenuPortal(props: Menu.Portal.Props): import("re
44
44
  export declare function DropdownMenuGroup(props: DropdownMenuGroupProps): import("react").JSX.Element;
45
45
  export declare function DropdownMenuCheckboxItem({ className, children, ...props }: DropdownMenuCheckboxItemProps): import("react").JSX.Element;
46
46
  export declare function DropdownMenuRadioGroup(props: DropdownMenuRadioGroupProps): import("react").JSX.Element;
47
- export declare function DropdownMenuRadioItem({ className, children, ...props }: DropdownMenuRadioItemProps): import("react").JSX.Element;
47
+ export declare function DropdownMenuRadioItem({ className, children, value, ...props }: DropdownMenuRadioItemProps): import("react").JSX.Element;
48
48
  export declare function DropdownMenuSub(props: DropdownMenuSubProps): import("react").JSX.Element;
49
49
  export declare function DropdownMenuSubTrigger({ className, children, ...props }: DropdownMenuSubTriggerProps): import("react").JSX.Element;
50
50
  export declare function DropdownMenuSubContent(props: DropdownMenuSubContentProps): import("react").JSX.Element;
@@ -2,8 +2,10 @@
2
2
  import { cn } from "../lib/cn.js";
3
3
  import { controlEffectsAttribute } from "../skin.js";
4
4
  import { useSkin } from "../skin-provider.js";
5
+ import { popupItemFocusProps } from "../lib/popup-item-focus.js";
5
6
  import { popupItemStructureClasses } from "../surface-variants.js";
6
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { mergeProps } from "@base-ui/react/merge-props";
7
9
  import { Menu } from "@base-ui/react/menu";
8
10
  //#region src/ui/dropdown-menu.tsx
9
11
  const dropdownMenuTriggerVariants = ["surface", "ghost"];
@@ -62,7 +64,7 @@ function DropdownMenuItem({ className, ...props }) {
62
64
  "data-control-family": "popup",
63
65
  "data-popup-part": "item",
64
66
  className: cn(popupItemStructureClasses, className),
65
- ...props
67
+ ...mergeProps(popupItemFocusProps, props)
66
68
  });
67
69
  }
68
70
  function DropdownMenuSeparator({ className, ...props }) {
@@ -103,7 +105,7 @@ function DropdownMenuCheckboxItem({ className, children, ...props }) {
103
105
  "data-popup-part": "item",
104
106
  "data-slot": "checkbox-item",
105
107
  className: cn("relative", popupItemStructureClasses, className),
106
- ...props,
108
+ ...mergeProps(popupItemFocusProps, props),
107
109
  children: [/* @__PURE__ */ jsx(Menu.CheckboxItemIndicator, {
108
110
  className: "pointer-events-none absolute start-2 flex size-4 items-center justify-center",
109
111
  children: /* @__PURE__ */ jsx(DropdownMenuCheck, {})
@@ -118,14 +120,15 @@ function DropdownMenuRadioGroup(props) {
118
120
  ...props
119
121
  });
120
122
  }
121
- function DropdownMenuRadioItem({ className, children, ...props }) {
123
+ function DropdownMenuRadioItem({ className, children, value, ...props }) {
122
124
  return /* @__PURE__ */ jsxs(Menu.RadioItem, {
125
+ value,
123
126
  "data-control-ui": "dropdown-menu",
124
127
  "data-control-family": "popup",
125
128
  "data-popup-part": "item",
126
129
  "data-slot": "radio-item",
127
130
  className: cn("relative", popupItemStructureClasses, className),
128
- ...props,
131
+ ...mergeProps(popupItemFocusProps, props),
129
132
  children: [/* @__PURE__ */ jsx(Menu.RadioItemIndicator, {
130
133
  className: "pointer-events-none absolute start-2 flex size-4 items-center justify-center",
131
134
  children: /* @__PURE__ */ jsx(DropdownMenuCheck, {})
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { cn } from "../lib/cn.js";
3
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
3
4
  import { useColorArea } from "../hooks/use-color-area.js";
4
5
  import { formatGradient } from "../lib/color.js";
5
- import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
6
6
  import { ColorPicker, ColorPickerAlpha, ColorPickerArea, ColorPickerContent, ColorPickerFormatSelect, ColorPickerHue, ColorPickerInput, ColorPickerTrigger } from "./color-picker.js";
7
7
  import { createContext, useContext, useRef, useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
package/dist/ui/item.js CHANGED
@@ -38,7 +38,7 @@ function Item({ variant = "default", render, className, children, ...props }) {
38
38
  "data-control-family": "item",
39
39
  "data-slot": "root",
40
40
  "data-variant": variant,
41
- className: cn("flex items-center [&[href]]:cursor-pointer", className),
41
+ className: cn("flex flex-wrap items-center [&[href]]:cursor-pointer", className),
42
42
  children
43
43
  }
44
44
  });
@@ -1,4 +1,4 @@
1
- import { DialogCloseProps, DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogProps, DialogTitle, DialogTrigger } from "./dialog.js";
1
+ import { DialogBody, DialogCloseProps, DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogProps, DialogTitle, DialogTrigger } from "./dialog.js";
2
2
  import { ComponentProps } from "react";
3
3
  //#region src/ui/responsive-dialog.d.ts
4
4
  export type ResponsiveDialogProps = DialogProps;
@@ -11,6 +11,7 @@ export declare function ResponsiveDialogTrigger(props: Omit<ComponentProps<typeo
11
11
  export declare function ResponsiveDialogClose({ className, children, variant, size, tone, iconOnly, ...props }: DialogCloseProps): import("react").JSX.Element;
12
12
  export declare function ResponsiveDialogContent({ className, dialogClassName, drawerClassName, children, showCloseButton, closeLabel, ...props }: ResponsiveDialogContentProps): import("react").JSX.Element;
13
13
  export declare function ResponsiveDialogHeader(props: ComponentProps<typeof DialogHeader>): import("react").JSX.Element;
14
+ export declare function ResponsiveDialogBody(props: ComponentProps<typeof DialogBody>): import("react").JSX.Element;
14
15
  export declare function ResponsiveDialogFooter(props: ComponentProps<typeof DialogFooter>): import("react").JSX.Element;
15
16
  export declare function ResponsiveDialogTitle(props: ComponentProps<typeof DialogTitle>): import("react").JSX.Element;
16
17
  export declare function ResponsiveDialogDescription(props: ComponentProps<typeof DialogDescription>): import("react").JSX.Element;
@@ -3,7 +3,7 @@ import { cn } from "../lib/cn.js";
3
3
  import { Button } from "./button.js";
4
4
  import { PopupCloseButton } from "../popup-parts.js";
5
5
  import { Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger } from "./drawer.js";
6
- import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "./dialog.js";
6
+ import { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "./dialog.js";
7
7
  import { createContext, useContext, useState, useSyncExternalStore } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  //#region src/ui/responsive-dialog.tsx
@@ -94,6 +94,9 @@ function ResponsiveDialogContent({ className, dialogClassName, drawerClassName,
94
94
  function ResponsiveDialogHeader(props) {
95
95
  return useResponsiveDialogContext() ? /* @__PURE__ */ jsx(DrawerHeader, { ...props }) : /* @__PURE__ */ jsx(DialogHeader, { ...props });
96
96
  }
97
+ function ResponsiveDialogBody(props) {
98
+ return /* @__PURE__ */ jsx(DialogBody, { ...props });
99
+ }
97
100
  function ResponsiveDialogFooter(props) {
98
101
  return useResponsiveDialogContext() ? /* @__PURE__ */ jsx(DrawerFooter, { ...props }) : /* @__PURE__ */ jsx(DialogFooter, { ...props });
99
102
  }
@@ -104,4 +107,4 @@ function ResponsiveDialogDescription(props) {
104
107
  return useResponsiveDialogContext() ? /* @__PURE__ */ jsx(DrawerDescription, { ...props }) : /* @__PURE__ */ jsx(DialogDescription, { ...props });
105
108
  }
106
109
  //#endregion
107
- export { ResponsiveDialog, ResponsiveDialogClose, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, ResponsiveDialogTrigger };
110
+ export { ResponsiveDialog, ResponsiveDialogBody, ResponsiveDialogClose, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, ResponsiveDialogTrigger };
@@ -1,8 +1,8 @@
1
1
  import { ControlledChoice } from "../control-props.js";
2
2
  import { ControlSize } from "../control-variants.js";
3
3
  import { ButtonKnobStyle } from "../knob-contracts/button-knobs.js";
4
- import { PopupKnobStyle } from "../knob-contracts/popup-knobs.js";
5
4
  import { FieldKnobStyle } from "../knob-contracts/field-knobs.js";
5
+ import { PopupKnobStyle } from "../knob-contracts/popup-knobs.js";
6
6
  import { CSSProperties, ComponentProps, ReactNode } from "react";
7
7
  import { Select as Select$1 } from "@base-ui/react/select";
8
8
  //#region src/ui/select.d.ts
package/dist/ui/select.js CHANGED
@@ -4,8 +4,10 @@ import { controlEffectsAttribute } from "../skin.js";
4
4
  import { useSkin } from "../skin-provider.js";
5
5
  import { Button } from "./button.js";
6
6
  import { ScrollArea } from "./scroll-area.js";
7
+ import { popupItemFocusProps } from "../lib/popup-item-focus.js";
7
8
  import { popupItemStructureClasses } from "../surface-variants.js";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
+ import { mergeProps } from "@base-ui/react/merge-props";
9
11
  import { Select as Select$1 } from "@base-ui/react/select";
10
12
  //#region src/ui/select.tsx
11
13
  const selectTriggerVariants = ["surface", "ghost"];
@@ -118,7 +120,7 @@ function SelectItem({ className, children, disabled, ...props }) {
118
120
  "data-popup-part": "item",
119
121
  disabled,
120
122
  className: cn(popupItemStructureClasses, className),
121
- ...props,
123
+ ...mergeProps(popupItemFocusProps, props),
122
124
  children: [/* @__PURE__ */ jsx(Select$1.ItemText, {
123
125
  "data-control-ui": "select",
124
126
  "data-control-family": "popup",
@@ -47,7 +47,7 @@ function SidebarResizeRail({ className, ref, onPointerDown, onClick, onKeyDown,
47
47
  const pointerId = event.pointerId;
48
48
  const startX = event.clientX;
49
49
  const anchoredLeft = anchoredToLeftEdge(handle);
50
- const wrapperBounds = wrapper.getBoundingClientRect();
50
+ const sidebarBounds = (handle.closest("[data-control-family=\"sidebar\"][data-slot=\"root\"]") ?? wrapper).getBoundingClientRect();
51
51
  const initialWidth = measure.getBoundingClientRect().width;
52
52
  const previousWidth = wrapper.style.getPropertyValue("--sidebar-width");
53
53
  const previousCursor = document.body.style.cursor;
@@ -92,7 +92,7 @@ function SidebarResizeRail({ className, ref, onPointerDown, onClick, onKeyDown,
92
92
  document.body.style.userSelect = "none";
93
93
  wrapper.setAttribute("data-resizing", "true");
94
94
  handle.setAttribute("data-resizing", "true");
95
- const cursorWidth = anchoredLeft ? pointer.clientX - wrapperBounds.left : wrapperBounds.right - pointer.clientX;
95
+ const cursorWidth = anchoredLeft ? pointer.clientX - sidebarBounds.left : sidebarBounds.right - pointer.clientX;
96
96
  if (updateCollapse(cursorWidth)) return;
97
97
  draftWidth = clampWidth(cursorWidth);
98
98
  wrapper.style.setProperty("--sidebar-width", `${draftWidth}px`);
package/dist/ui/tabs.js CHANGED
@@ -18,6 +18,9 @@ function refreshTabsPanelHeight(panel) {
18
18
  if (panel.node.inert || panel.node.hidden) return;
19
19
  panel.height = panel.node.getBoundingClientRect().height;
20
20
  }
21
+ function setTabsPanelsStarting(panels, starting) {
22
+ for (const panel of panels) panel.toggleAttribute("data-slide-starting", starting);
23
+ }
21
24
  const TabsPanelsContext = createContext(null);
22
25
  function useTabsPanels() {
23
26
  const context = useContext(TabsPanelsContext);
@@ -31,17 +34,20 @@ function setRef(ref, value) {
31
34
  function Tabs({ className, onValueChange, children, ...props }) {
32
35
  const rootRef = useRef(null);
33
36
  const activePanelRef = useRef(null);
37
+ const startingPanelsRef = useRef([]);
38
+ const previousHeightRef = useRef(null);
34
39
  const clearPreviousHeightFrame = useRef(0);
35
40
  const [exitingValue, setExitingValue] = useState(null);
36
41
  const [holdPreviousHeight] = useState(() => (height) => {
37
- const root = rootRef.current;
38
- if (!root) return;
39
- root.style.setProperty("--aui-slide-prev-height", height);
42
+ if (!rootRef.current) return;
43
+ previousHeightRef.current = height;
40
44
  cancelAnimationFrame(clearPreviousHeightFrame.current);
41
45
  clearPreviousHeightFrame.current = requestAnimationFrame(() => {
42
46
  clearPreviousHeightFrame.current = requestAnimationFrame(() => {
43
- root.style.removeProperty("--aui-slide-prev-height");
44
- root.removeAttribute("data-slide-starting");
47
+ previousHeightRef.current = null;
48
+ activePanelRef.current?.node.style.removeProperty("--_tabs-prev-height");
49
+ setTabsPanelsStarting(startingPanelsRef.current, false);
50
+ startingPanelsRef.current = [];
45
51
  });
46
52
  });
47
53
  });
@@ -49,10 +55,14 @@ function Tabs({ className, onValueChange, children, ...props }) {
49
55
  const [registerPanel] = useState(() => (value, node) => {
50
56
  if (!(node && !node.inert && !node.hidden)) return;
51
57
  const previousPanel = activePanelRef.current;
52
- const root = rootRef.current;
53
- if (root && previousPanel && previousPanel.value !== value) {
54
- root.setAttribute("data-slide-starting", "");
55
- holdPreviousHeight(root.style.getPropertyValue("--aui-slide-prev-height") || `${previousPanel.height}px`);
58
+ const switchingPanels = rootRef.current && previousPanel && previousPanel.value !== value;
59
+ if (switchingPanels) {
60
+ setTabsPanelsStarting(startingPanelsRef.current, false);
61
+ startingPanelsRef.current = [previousPanel.node, node];
62
+ setTabsPanelsStarting(startingPanelsRef.current, true);
63
+ const previousHeight = previousHeightRef.current || `${previousPanel.height}px`;
64
+ node.style.setProperty("--_tabs-prev-height", previousHeight);
65
+ holdPreviousHeight(previousHeight);
56
66
  setExitingValue(previousPanel.value);
57
67
  }
58
68
  activePanelRef.current = {
@@ -60,11 +70,12 @@ function Tabs({ className, onValueChange, children, ...props }) {
60
70
  node,
61
71
  height: node.getBoundingClientRect().height
62
72
  };
63
- if (root) {
64
- root.style.setProperty("--_tabs-panel-top", `${node.offsetTop}px`);
65
- root.style.setProperty("--_tabs-panel-left", `${node.offsetLeft}px`);
66
- root.style.setProperty("--_tabs-panel-width", `${node.offsetWidth}px`);
67
- root.style.setProperty("--_tabs-panel-height", `${node.offsetHeight}px`);
73
+ if (switchingPanels) {
74
+ const { offsetTop, offsetLeft, offsetWidth, offsetHeight } = node;
75
+ previousPanel.node.style.setProperty("--_tabs-panel-top", `${offsetTop}px`);
76
+ previousPanel.node.style.setProperty("--_tabs-panel-left", `${offsetLeft}px`);
77
+ previousPanel.node.style.setProperty("--_tabs-panel-width", `${offsetWidth}px`);
78
+ previousPanel.node.style.setProperty("--_tabs-panel-height", `${offsetHeight}px`);
68
79
  }
69
80
  return () => {
70
81
  const currentPanel = activePanelRef.current;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl-ui/react",
3
- "version": "0.8.13",
3
+ "version": "0.8.15",
4
4
  "description": "Control UI components, blocks, and primitives with neutral defaults and consumer-owned themes.",
5
5
  "license": "MIT",
6
6
  "repository": {