action-bar
diceui-radix/action-barFreeComponent
diceui/radix publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/radix-nova/action-bar.jsonSource
1"use client";23import {4 Direction as DirectionPrimitive,5 Slot as SlotPrimitive,6} from "radix-ui";7import * as React from "react";8import * as ReactDOM from "react-dom";9import { useComposedRefs } from "@/lib/compose-refs";10import { cn } from "@/lib/utils";11import { useAsRef } from "@/registry/bases/radix/hooks/use-as-ref";12import { useIsomorphicLayoutEffect } from "@/registry/bases/radix/hooks/use-isomorphic-layout-effect";13import { Button } from "@/registry/bases/radix/ui/button";1415const ROOT_NAME = "ActionBar";16const GROUP_NAME = "ActionBarGroup";17const ITEM_NAME = "ActionBarItem";18const CLOSE_NAME = "ActionBarClose";19const SEPARATOR_NAME = "ActionBarSeparator";20const ITEM_SELECT = "actionbar.itemSelect";21const ENTRY_FOCUS = "actionbarFocusGroup.onEntryFocus";22const EVENT_OPTIONS = { bubbles: false, cancelable: true };2324type Direction = "ltr" | "rtl";25type Orientation = "horizontal" | "vertical";2627interface DivProps extends React.ComponentProps<"div"> {28 asChild?: boolean;29}3031type RootElement = React.ComponentRef<typeof ActionBar>;32type ItemElement = React.ComponentRef<typeof ActionBarItem>;33type CloseElement = React.ComponentRef<typeof ActionBarClose>;3435function focusFirst(36 candidates: React.RefObject<HTMLElement | null>[],37 preventScroll = false,38) {39 const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;40 for (const candidateRef of candidates) {41 const candidate = candidateRef.current;42 if (!candidate) continue;43 if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;44 candidate.focus({ preventScroll });45 if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;46 }47}4849function wrapArray<T>(array: T[], startIndex: number) {50 return array.map<T>(51 (_, index) => array[(startIndex + index) % array.length] as T,52 );53}5455function getDirectionAwareKey(key: string, dir?: Direction) {56 if (dir !== "rtl") return key;57 return key === "ArrowLeft"58 ? "ArrowRight"59 : key === "ArrowRight"60 ? "ArrowLeft"61 : key;62}6364interface ItemData {65 id: string;66 ref: React.RefObject<ItemElement | null>;67 disabled: boolean;68}6970interface ActionBarContextValue {71 onOpenChange?: (open: boolean) => void;72 dir: Direction;73 orientation: Orientation;74 loop: boolean;75}7677const ActionBarContext = React.createContext<ActionBarContextValue | null>(78 null,79);8081function useActionBarContext(consumerName: string) {82 const context = React.useContext(ActionBarContext);83 if (!context) {84// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from diceui/radix
All 58 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| angle-sliderangle-slider | diceui/radix | Components | Free | 1 dep · 3 files | |
| avatar-groupavatar-group | diceui/radix | Components | Free | 1 dep | |
| badge-overflowbadge-overflow | diceui/radix | Components | Free | 1 dep · 2 files | |
| bannerbanner | diceui/radix | Components | Free | 1 dep | |
| checkbox-groupcheckbox-group | diceui/radix | Components | Free | 1 dep | |
| circular-progresscircular-progress | diceui/radix | Components | Free | 1 dep | |
| client-onlyclient-only | diceui/radix | Components | Free | no deps | |
| color-pickercolor-picker | diceui/radix | Components | Free | 1 dep · 3 files |
