@leitware/composables 1.6.1 → 1.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.
- package/README.md +82 -21
- package/dist/presets/kumo.css +8 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/rules/composables.md +37 -32
- package/skills/use-composables/references/public-api.md +2 -2
- package/src/_internal/clipboard-text.tsx +102 -0
- package/src/_internal/flow.tsx +390 -0
- package/src/_internal/layer-card.tsx +61 -0
- package/src/_internal/table-of-contents.tsx +124 -0
- package/src/hooks/use-table-of-contents-active-id.ts +63 -0
- package/src/index.ts +50 -0
- package/src/lib/clipboard.ts +57 -0
- package/src/lib/flow.ts +53 -0
- package/src/opinionated/clipboard-text.tsx +135 -0
- package/src/opinionated/flow.tsx +74 -0
- package/src/opinionated/layer-card.tsx +49 -0
- package/src/opinionated/table-of-contents.tsx +121 -0
- package/src/styles/presets/kumo.css +8 -0
- package/src/styles/presets-data/kumo.ts +4 -0
- package/src/styles/tokens/components.css +18 -0
package/package.json
CHANGED
package/rules/composables.md
CHANGED
|
@@ -106,30 +106,34 @@ Use this catalog to choose public exports. The `Source module` column is for mai
|
|
|
106
106
|
|
|
107
107
|
### Navigation
|
|
108
108
|
|
|
109
|
-
| Module
|
|
110
|
-
|
|
|
111
|
-
| `tabs`
|
|
112
|
-
| `breadcrumb`
|
|
113
|
-
| `pagination`
|
|
114
|
-
| `sidebar`
|
|
115
|
-
| `dropdown-menu`
|
|
109
|
+
| Module | Source module | Import from | Public values | Public types | Description |
|
|
110
|
+
| ------------------- | --------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
111
|
+
| `tabs` | `./opinionated/tabs` | `@leitware/composables` | `Tabs`, `TabsContent` | `TabItem`, `TabsProps`, `TabsVariant` | Tabbed content navigation with items array API |
|
|
112
|
+
| `breadcrumb` | `./opinionated/breadcrumb` | `@leitware/composables` | `Breadcrumb`, `BreadcrumbEllipsis`, `BreadcrumbItem`, `BreadcrumbLink`, `BreadcrumbList`, `BreadcrumbPage`, `BreadcrumbSeparator` | `BreadcrumbItemData`, `BreadcrumbProps` | Navigation trail with items array API |
|
|
113
|
+
| `pagination` | `./opinionated/pagination` | `@leitware/composables` | `Pagination`, `PaginationContent`, `PaginationEllipsis`, `PaginationItem`, `PaginationLink`, `PaginationNext`, `PaginationPrevious` | `PaginationProps` | Page navigation with currentPage and totalPages API |
|
|
114
|
+
| `sidebar` | `./opinionated/sidebar` | `@leitware/composables` | `Sidebar`, `SidebarContent`, `SidebarFooter`, `SidebarGroup`, `SidebarGroupAction`, `SidebarGroupContent`, `SidebarGroupLabel`, `SidebarHeader`, `SidebarInput`, `SidebarInset`, `SidebarMenu`, `SidebarMenuAction`, `SidebarMenuBadge`, `SidebarMenuButton`, `SidebarMenuItem`, `SidebarMenuSkeleton`, `SidebarMenuSub`, `SidebarMenuSubButton`, `SidebarMenuSubItem`, `SidebarProvider`, `SidebarRail`, `SidebarSeparator`, `SidebarTrigger`, `useSidebar` | - | Application sidebar with collapsible navigation groups |
|
|
115
|
+
| `dropdown-menu` | `./opinionated/dropdown-menu` | `@leitware/composables` | `DropdownMenu`, `DropdownMenuCheckboxItem`, `DropdownMenuContent`, `DropdownMenuGroup`, `DropdownMenuItem`, `DropdownMenuLabel`, `DropdownMenuPortal`, `DropdownMenuRadioGroup`, `DropdownMenuRadioItem`, `DropdownMenuSeparator`, `DropdownMenuShortcut`, `DropdownMenuSub`, `DropdownMenuSubContent`, `DropdownMenuSubTrigger`, `DropdownMenuTrigger` | `DropdownMenuItemData`, `DropdownMenuProps` | Contextual menu triggered by a button |
|
|
116
|
+
| `table-of-contents` | `./opinionated/table-of-contents` | `@leitware/composables` | `TableOfContents`, `TableOfContentsGroup`, `TableOfContentsItem`, `TableOfContentsList`, `TableOfContentsRoot`, `TableOfContentsTitle` | `TableOfContentsGroupProps`, `TableOfContentsItemData`, `TableOfContentsItemProps`, `TableOfContentsProps` | Nested section navigation with an active rail and optional scroll tracking |
|
|
116
117
|
|
|
117
118
|
### Data Display
|
|
118
119
|
|
|
119
|
-
| Module
|
|
120
|
-
|
|
|
121
|
-
| `table`
|
|
122
|
-
| `card`
|
|
123
|
-
| `accordion`
|
|
124
|
-
| `collapsible`
|
|
125
|
-
| `item`
|
|
126
|
-
| `message`
|
|
127
|
-
| `bubble`
|
|
128
|
-
| `marker`
|
|
129
|
-
| `empty`
|
|
130
|
-
| `carousel`
|
|
131
|
-
| `code-block`
|
|
132
|
-
| `list`
|
|
120
|
+
| Module | Source module | Import from | Public values | Public types | Description |
|
|
121
|
+
| ---------------- | ------------------------------ | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
122
|
+
| `table` | `./opinionated/table` | `@leitware/composables` | `Table`, `TableBody`, `TableCaption`, `TableCell`, `TableFooter`, `TableHead`, `TableHeader`, `TableRow` | - | Semantic HTML table with styled rows and cells |
|
|
123
|
+
| `card` | `./opinionated/card` | `@leitware/composables` | `Card`, `CardAction`, `CardContent`, `CardDescription`, `CardFooter`, `CardHeader`, `CardTitle` | `CardProps` | Bordered content container with title, description, action, and footer props |
|
|
124
|
+
| `accordion` | `./opinionated/accordion` | `@leitware/composables` | `Accordion`, `AccordionContent`, `AccordionItem`, `AccordionTrigger` | `AccordionItemData`, `AccordionProps`, `AccordionVariant` | Vertically collapsible content sections with items array API |
|
|
125
|
+
| `collapsible` | `./opinionated/collapsible` | `@leitware/composables` | `Collapsible`, `CollapsibleContent`, `CollapsibleTrigger` | `CollapsibleProps` | Expandable and collapsible content panel with trigger prop |
|
|
126
|
+
| `item` | `./opinionated/item` | `@leitware/composables` | `Item`, `ItemActions`, `ItemContent`, `ItemDescription`, `ItemFooter`, `ItemGroup`, `ItemHeader`, `ItemMedia`, `ItemSeparator`, `ItemTitle` | `ItemProps`, `ItemVariants` | Flexible list item with title, description, icon, and actions |
|
|
127
|
+
| `message` | `./opinionated/message` | `@leitware/composables` | `Message`, `MessageAvatar`, `MessageContent`, `MessageFooter`, `MessageGroup`, `MessageHeader` | - | Message row primitives for chat, activity, and assistant UIs |
|
|
128
|
+
| `bubble` | `./opinionated/bubble` | `@leitware/composables` | `Bubble`, `BubbleContent`, `BubbleGroup`, `BubbleReactions`, `bubbleReactionsVariants`, `bubbleVariants` | `BubbleProps` | Message bubble primitives with semantic variants |
|
|
129
|
+
| `marker` | `./opinionated/marker` | `@leitware/composables` | `Marker`, `MarkerContent`, `MarkerIcon`, `markerVariants` | `MarkerProps` | Inline metadata marker with icon, separator, and border variants |
|
|
130
|
+
| `empty` | `./opinionated/empty` | `@leitware/composables` | `Empty`, `EmptyContent`, `EmptyDescription`, `EmptyHeader`, `EmptyMedia`, `EmptyTableState`, `EmptyTitle` | `EmptyProps`, `EmptyTableStateProps` | Empty state placeholder with icon, title, and description |
|
|
131
|
+
| `carousel` | `./opinionated/carousel` | `@leitware/composables` | `Carousel`, `CarouselContent`, `CarouselItem`, `CarouselNext`, `CarouselPrevious` | `CarouselProps` | Horizontally scrollable content slider with items array API |
|
|
132
|
+
| `code-block` | `./opinionated/code-block` | `@leitware/composables` | `CodeBlock` | `CodeBlockProps` | Monospace code display with line numbers |
|
|
133
|
+
| `list` | `./opinionated/list` | `@leitware/composables` | `List`, `ListArrowItem`, `ListBulletItem` | `ListItemData`, `ListProps`, `ListVariant` | Variant list renderer: arrow, bullet |
|
|
134
|
+
| `layer-card` | `./opinionated/layer-card` | `@leitware/composables` | `LayerCard`, `LayerCardPrimary`, `LayerCardRoot`, `LayerCardSecondary` | `LayerCardProps`, `LayerCardRootProps`, `LayerCardSectionProps` | Layered content surface with recessed header and footer |
|
|
135
|
+
| `flow` | `./opinionated/flow` | `@leitware/composables` | `Flow`, `FlowAnchor`, `FlowList`, `FlowNode`, `FlowParallel`, `FlowRoot` | `FlowAlign`, `FlowAnchorProps`, `FlowBranch`, `FlowItem`, `FlowNodeProps`, `FlowOrientation`, `FlowProps`, `FlowRootProps`, `FlowStep` | Connected workflow steps and parallel branches |
|
|
136
|
+
| `clipboard-text` | `./opinionated/clipboard-text` | `@leitware/composables` | `ClipboardText` | `ClipboardTextProps`, `ClipboardTextSize`, `ClipboardTextStatus` | Read-only copy field with success and error feedback |
|
|
133
137
|
|
|
134
138
|
### Form Components
|
|
135
139
|
|
|
@@ -176,17 +180,18 @@ Use this catalog to choose public exports. The `Source module` column is for mai
|
|
|
176
180
|
|
|
177
181
|
### Other Public Exports
|
|
178
182
|
|
|
179
|
-
| Module
|
|
180
|
-
|
|
|
181
|
-
| `aspect-ratio`
|
|
182
|
-
| `direction`
|
|
183
|
-
| `field`
|
|
184
|
-
| `grid-overlay`
|
|
185
|
-
| `input-group`
|
|
186
|
-
| `input`
|
|
187
|
-
| `label`
|
|
188
|
-
| `textarea`
|
|
189
|
-
| `
|
|
183
|
+
| Module | Source module | Import from | Public values | Public types | Description |
|
|
184
|
+
| --------------------------------- | ----------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------- | --------------------------------------------------------- |
|
|
185
|
+
| `aspect-ratio` | `./opinionated/aspect-ratio` | `@leitware/composables` | `AspectRatio` | - | Public export not listed in the README component catalog. |
|
|
186
|
+
| `direction` | `./opinionated/direction` | `@leitware/composables` | `DirectionProvider`, `useDirection` | `DirectionProviderProps`, `TextDirection` | Public export not listed in the README component catalog. |
|
|
187
|
+
| `field` | `./opinionated/field` | `@leitware/composables` | `Field`, `FieldContent`, `FieldDescription`, `FieldError`, `FieldGroup`, `FieldLabel`, `FieldLegend`, `FieldSeparator`, `FieldSet`, `FieldTitle` | - | Public export not listed in the README component catalog. |
|
|
188
|
+
| `grid-overlay` | `./opinionated/grid-overlay` | `@leitware/composables` | `GridOverlay` | `GridOverlayProps` | Public export not listed in the README component catalog. |
|
|
189
|
+
| `input-group` | `./opinionated/input-group` | `@leitware/composables` | `InputGroup`, `InputGroupAddon`, `InputGroupButton`, `InputGroupInput`, `InputGroupTextarea` | - | Public export not listed in the README component catalog. |
|
|
190
|
+
| `input` | `./opinionated/input` | `@leitware/composables` | `Input` | - | Public export not listed in the README component catalog. |
|
|
191
|
+
| `label` | `./opinionated/label` | `@leitware/composables` | `Label` | - | Public export not listed in the README component catalog. |
|
|
192
|
+
| `textarea` | `./opinionated/textarea` | `@leitware/composables` | `Textarea` | - | Public export not listed in the README component catalog. |
|
|
193
|
+
| `use-table-of-contents-active-id` | `./hooks/use-table-of-contents-active-id` | `@leitware/composables` | `useTableOfContentsActiveId` | `TableOfContentsTrackingOptions` | Public export not listed in the README component catalog. |
|
|
194
|
+
| `window-frame` | `./opinionated/window-frame` | `@leitware/composables` | `WindowFrame` | `WindowFrameProps` | Public export not listed in the README component catalog. |
|
|
190
195
|
|
|
191
196
|
## AI Entrypoint Catalog
|
|
192
197
|
|
|
@@ -6,8 +6,8 @@ This is the exact installed-package entrypoint and export-name contract. Import
|
|
|
6
6
|
|
|
7
7
|
## `@leitware/composables`
|
|
8
8
|
|
|
9
|
-
- Values (
|
|
10
|
-
- Types (
|
|
9
|
+
- Values (370): `ACCEPT_PRESETS`, `Accordion`, `AccordionContent`, `AccordionItem`, `AccordionTrigger`, `Alert`, `AlertAction`, `AlertDescription`, `AlertDialog`, `AlertDialogAction`, `AlertDialogCancel`, `AlertDialogContent`, `AlertDialogDescription`, `AlertDialogFooter`, `AlertDialogHeader`, `AlertDialogMedia`, `AlertDialogOverlay`, `AlertDialogPortal`, `AlertDialogTitle`, `AlertDialogTrigger`, `AlertTitle`, `AspectRatio`, `Avatar`, `AvatarFallback`, `AvatarImage`, `avatarVariants`, `Badge`, `BentoCell`, `BentoGrid`, `BentoGrids01`, `BentoLeader`, `BentoQuad`, `BentoSplit`, `BentoTriple`, `Breadcrumb`, `BreadcrumbEllipsis`, `BreadcrumbItem`, `BreadcrumbLink`, `BreadcrumbList`, `BreadcrumbPage`, `BreadcrumbSeparator`, `Bubble`, `BubbleContent`, `BubbleGroup`, `BubbleReactions`, `bubbleReactionsVariants`, `bubbleVariants`, `Button`, `Calendar`, `CalendarDayButton`, `Card`, `CardAction`, `CardContent`, `CardDescription`, `CardFooter`, `CardHeader`, `CardTitle`, `Carousel`, `CarouselContent`, `CarouselItem`, `CarouselNext`, `CarouselPrevious`, `CellGrid`, `CellRow`, `Checkbox`, `ClipboardText`, `cn`, `CodeBlock`, `Collapsible`, `CollapsibleContent`, `CollapsibleTrigger`, `Combobox`, `ComboboxChip`, `ComboboxChips`, `ComboboxChipsInput`, `ComboboxCollection`, `ComboboxContent`, `ComboboxEmpty`, `ComboboxGroup`, `ComboboxInput`, `ComboboxItem`, `ComboboxLabel`, `ComboboxList`, `ComboboxSeparator`, `ComboboxTrigger`, `ComboboxValue`, `Container`, `containerVariants`, `Content02`, `Content04`, `Content06`, `Content07`, `Content09`, `Content11`, `Cta01`, `DEFAULT_ACCEPT`, `DEFAULT_MAX_SIZE`, `Dialog`, `DialogClose`, `DialogContent`, `DialogDescription`, `DialogFooter`, `DialogHeader`, `DialogOverlay`, `DialogPortal`, `DialogTitle`, `DialogTrigger`, `DirectionProvider`, `DISABLED_OPACITY`, `Divider`, `dividerVariants`, `DropdownMenu`, `DropdownMenuCheckboxItem`, `DropdownMenuContent`, `DropdownMenuGroup`, `DropdownMenuItem`, `DropdownMenuLabel`, `DropdownMenuPortal`, `DropdownMenuRadioGroup`, `DropdownMenuRadioItem`, `DropdownMenuSeparator`, `DropdownMenuShortcut`, `DropdownMenuSub`, `DropdownMenuSubContent`, `DropdownMenuSubTrigger`, `DropdownMenuTrigger`, `Dropzone`, `DropZone`, `DropZoneArea`, `DropzoneContent`, `DropZoneContent`, `DropZoneFile`, `DropZoneFileList`, `DropzoneInput`, `DropZoneInput`, `DropzoneLabel`, `Empty`, `EmptyContent`, `EmptyDescription`, `EmptyHeader`, `EmptyMedia`, `EmptyTableState`, `EmptyTitle`, `Feature01`, `Feature02`, `Feature03`, `Field`, `FieldContent`, `FieldDescription`, `FieldError`, `FieldGroup`, `FieldLabel`, `FieldLegend`, `FieldSeparator`, `FieldSet`, `FieldTitle`, `FlexSpacer`, `Flow`, `FlowAnchor`, `FlowList`, `FlowNode`, `FlowParallel`, `FlowRoot`, `FOCUS_RING`, `FOCUS_RING_DESTRUCTIVE`, `formatFileSize`, `formatNumericValue`, `FormCalendarPopover`, `FormCheckbox`, `FormCombobox`, `FormDateOfBirth`, `FormDropZone`, `FormInput`, `FormInputGroup`, `FormMultiCombobox`, `FormMultiDropZone`, `FormRadioGroup`, `FormSelect`, `FormSlider`, `FormSwitch`, `FormTextarea`, `getAcceptDescription`, `getRejectionMessage`, `Grid`, `GridOverlay`, `gridVariants`, `Hero01`, `Hero02`, `Hero03`, `Hero04`, `Hero05`, `Hero06`, `Hero07`, `Hero08`, `Hero09`, `Hero10`, `Hero11`, `Hero12`, `Hero13`, `Hero14`, `HoverCard`, `HoverCardContent`, `HoverCardTrigger`, `Icon`, `iconVariants`, `Input`, `InputGroup`, `InputGroupAddon`, `InputGroupButton`, `InputGroupInput`, `InputGroupTextarea`, `Item`, `ItemActions`, `ItemContent`, `ItemDescription`, `ItemFooter`, `ItemGroup`, `ItemHeader`, `ItemMedia`, `ItemSeparator`, `ItemTitle`, `Kbd`, `KbdGroup`, `Label`, `LayerCard`, `LayerCardPrimary`, `LayerCardRoot`, `LayerCardSecondary`, `leftPad`, `List`, `ListArrowItem`, `ListBulletItem`, `Marker`, `MarkerContent`, `MarkerIcon`, `markerVariants`, `Message`, `MessageAvatar`, `MessageContent`, `MessageFooter`, `MessageGroup`, `MessageHeader`, `NativeSelect`, `NativeSelectOptGroup`, `NativeSelectOption`, `NewspaperCell`, `NewspaperGrid`, `newspaperGridVariants`, `Pagination`, `PaginationContent`, `PaginationEllipsis`, `PaginationItem`, `PaginationLink`, `PaginationNext`, `PaginationPrevious`, `parseNumericValue`, `Popover`, `PopoverContent`, `PopoverDescription`, `PopoverHeader`, `PopoverTitle`, `PopoverTrigger`, `Progress`, `ProgressIndicator`, `ProgressLabel`, `ProgressTrack`, `ProgressValue`, `RadioGroup`, `RadioGroupItem`, `ResizableHandle`, `ResizablePanel`, `ResizablePanelGroup`, `sanitizeNumericInput`, `ScrollArea`, `ScrollBar`, `Section`, `sectionVariants`, `Select`, `SelectContent`, `SelectGroup`, `SelectItem`, `SelectLabel`, `SelectScrollDownButton`, `SelectScrollUpButton`, `SelectSeparator`, `SelectTrigger`, `SelectValue`, `Separator`, `Sheet`, `SheetClose`, `SheetContent`, `SheetDescription`, `SheetFooter`, `SheetHeader`, `SheetTitle`, `SheetTrigger`, `Sidebar`, `SidebarContent`, `SidebarFooter`, `SidebarGroup`, `SidebarGroupAction`, `SidebarGroupContent`, `SidebarGroupLabel`, `SidebarHeader`, `SidebarInput`, `SidebarInset`, `SidebarMenu`, `SidebarMenuAction`, `SidebarMenuBadge`, `SidebarMenuButton`, `SidebarMenuItem`, `SidebarMenuSkeleton`, `SidebarMenuSub`, `SidebarMenuSubButton`, `SidebarMenuSubItem`, `SidebarProvider`, `SidebarRail`, `SidebarSeparator`, `SidebarTrigger`, `Skeleton`, `SkeletonAvatar`, `SkeletonButton`, `SkeletonCard`, `SkeletonInput`, `SkeletonTableRow`, `SkeletonText`, `Slider`, `Spacer`, `spacerVariants`, `Stack`, `stackVariants`, `StatCell`, `Switch`, `Table`, `TableBody`, `TableCaption`, `TableCell`, `TableFooter`, `TableHead`, `TableHeader`, `TableOfContents`, `TableOfContentsGroup`, `TableOfContentsItem`, `TableOfContentsList`, `TableOfContentsRoot`, `TableOfContentsTitle`, `TableRow`, `Tabs`, `TabsContent`, `Testimonials01`, `Textarea`, `ThemeInjector`, `Toaster`, `Toggle`, `ToggleGroup`, `ToggleGroupItem`, `TokenConfigPanel`, `Tooltip`, `TooltipContent`, `TooltipTrigger`, `Typography`, `typographyVariants`, `useComboboxAnchor`, `useDirection`, `useDropZoneContext`, `useIsMobile`, `useNumericInput`, `useSidebar`, `useTableOfContentsActiveId`, `WindowFrame`
|
|
10
|
+
- Types (143): `Accept`, `AccordionItemData`, `AccordionProps`, `AccordionVariant`, `AlertDialogProps`, `AlertProps`, `AlertType`, `AlertVariant`, `AvatarProps`, `BadgeProps`, `BentoGrids01Props`, `BlockAnimation`, `BlockBaseProps`, `BlockCTA`, `BlockMedia`, `BlockVariant`, `BreadcrumbItemData`, `BreadcrumbProps`, `BubbleProps`, `ButtonProps`, `CardProps`, `CarouselProps`, `ClipboardTextProps`, `ClipboardTextSize`, `ClipboardTextStatus`, `CodeBlockProps`, `CollapsibleProps`, `ComboboxOption`, `ComboboxProps`, `ContainerProps`, `Content02Props`, `Content04Props`, `Content06Props`, `Content07Props`, `Content09Props`, `Content11Props`, `Cta01Props`, `DateOfBirthValue`, `DialogProps`, `DirectionProviderProps`, `DividerProps`, `DropdownMenuItemData`, `DropdownMenuProps`, `DropZoneFileProps`, `DropZoneProps`, `EmptyProps`, `EmptyTableStateProps`, `Feature01Props`, `Feature02Props`, `Feature03Props`, `FileRejection`, `FlowAlign`, `FlowAnchorProps`, `FlowBranch`, `FlowItem`, `FlowNodeProps`, `FlowOrientation`, `FlowProps`, `FlowRootProps`, `FlowStep`, `FormCalendarPopoverProps`, `FormCheckboxProps`, `FormComboboxOption`, `FormComboboxProps`, `FormDateOfBirthProps`, `FormDropZoneProps`, `FormInputGroupInputProps`, `FormInputGroupProps`, `FormInputProps`, `FormMultiComboboxOption`, `FormMultiComboboxProps`, `FormMultiDropZoneProps`, `FormRadioGroupOption`, `FormRadioGroupProps`, `FormSelectOption`, `FormSelectProps`, `FormSliderProps`, `FormSwitchProps`, `FormTextareaProps`, `GridOverlayProps`, `GridProps`, `Hero01Props`, `Hero02Props`, `Hero03Props`, `Hero04Props`, `Hero05Props`, `Hero06Props`, `Hero07Props`, `Hero08Props`, `Hero09Props`, `Hero10Props`, `Hero11Props`, `Hero12Props`, `Hero13Props`, `Hero14Props`, `HoverCardProps`, `ItemProps`, `ItemVariants`, `KbdGroupProps`, `KbdProps`, `LayerCardProps`, `LayerCardRootProps`, `LayerCardSectionProps`, `ListItemData`, `ListProps`, `ListVariant`, `MarkerProps`, `NativeSelectOptionData`, `NativeSelectProps`, `NewspaperCellProps`, `NewspaperGridProps`, `NumericInputOptions`, `NumericMode`, `PaginationProps`, `PopoverProps`, `ProgressProps`, `ScrollAreaProps`, `SectionProps`, `SelectOption`, `SelectProps`, `SheetProps`, `SkeletonProps`, `SpacerProps`, `StackProps`, `TabItem`, `TableOfContentsGroupProps`, `TableOfContentsItemData`, `TableOfContentsItemProps`, `TableOfContentsProps`, `TableOfContentsTrackingOptions`, `TabsProps`, `TabsVariant`, `Testimonials01Props`, `TextDirection`, `ToggleGroupOption`, `ToggleGroupProps`, `ToggleProps`, `TooltipProps`, `TypographyProps`, `TypographyVariant`, `UseNumericInputOptions`, `UseNumericInputReturn`, `WindowFrameProps`
|
|
11
11
|
|
|
12
12
|
## `@leitware/composables/ai`
|
|
13
13
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { CheckIcon, CopyIcon, Loader2Icon, AlertCircleIcon } from 'lucide-react'
|
|
2
|
+
import { forwardRef, type ComponentPropsWithoutRef, type ReactNode, type ReactElement } from 'react'
|
|
3
|
+
import { Button as ButtonPrimitive } from '@base-ui/react/button'
|
|
4
|
+
import { buttonVariants } from './button'
|
|
5
|
+
import { cn, GROUP_FOCUS_RING } from '../lib/utils'
|
|
6
|
+
|
|
7
|
+
export type ClipboardTextStatus = 'idle' | 'copying' | 'copied' | 'error'
|
|
8
|
+
export type ClipboardTextSize = 'sm' | 'default' | 'lg'
|
|
9
|
+
export interface ClipboardTextRootProps extends ComponentPropsWithoutRef<'div'> {
|
|
10
|
+
text: string
|
|
11
|
+
size?: ClipboardTextSize
|
|
12
|
+
status?: ClipboardTextStatus
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
copyLabel?: string
|
|
15
|
+
textLabel?: string
|
|
16
|
+
statusText?: string
|
|
17
|
+
onCopyClick?: () => void
|
|
18
|
+
/** Wrapper for the copy button, for example a tooltip. */
|
|
19
|
+
renderCopyButton?: (button: ReactElement) => ReactNode
|
|
20
|
+
}
|
|
21
|
+
const heights = {
|
|
22
|
+
sm: 'h-(--clipboard-text-height-sm)',
|
|
23
|
+
default: 'h-(--clipboard-text-height)',
|
|
24
|
+
lg: 'h-(--clipboard-text-height-lg)',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const ClipboardTextRoot = forwardRef<HTMLDivElement, ClipboardTextRootProps>(
|
|
28
|
+
function ClipboardTextRoot(
|
|
29
|
+
{
|
|
30
|
+
text,
|
|
31
|
+
size = 'default',
|
|
32
|
+
status = 'idle',
|
|
33
|
+
disabled,
|
|
34
|
+
copyLabel = 'Copy to clipboard',
|
|
35
|
+
textLabel = 'Text to copy',
|
|
36
|
+
statusText = '',
|
|
37
|
+
onCopyClick,
|
|
38
|
+
renderCopyButton,
|
|
39
|
+
className,
|
|
40
|
+
...props
|
|
41
|
+
},
|
|
42
|
+
ref,
|
|
43
|
+
) {
|
|
44
|
+
const Icon =
|
|
45
|
+
status === 'copied'
|
|
46
|
+
? CheckIcon
|
|
47
|
+
: status === 'copying'
|
|
48
|
+
? Loader2Icon
|
|
49
|
+
: status === 'error'
|
|
50
|
+
? AlertCircleIcon
|
|
51
|
+
: CopyIcon
|
|
52
|
+
const button = (
|
|
53
|
+
<ButtonPrimitive
|
|
54
|
+
type="button"
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
aria-label={copyLabel}
|
|
57
|
+
aria-busy={status === 'copying' || undefined}
|
|
58
|
+
onClick={onCopyClick}
|
|
59
|
+
className={cn(buttonVariants({ size: 'icon-sm', variant: 'ghost' }), 'me-1 shrink-0')}
|
|
60
|
+
>
|
|
61
|
+
<Icon
|
|
62
|
+
aria-hidden="true"
|
|
63
|
+
className={cn(
|
|
64
|
+
'size-4',
|
|
65
|
+
status === 'copying' && 'animate-spin motion-reduce:animate-none',
|
|
66
|
+
status === 'copied' && 'text-success',
|
|
67
|
+
status === 'error' && 'text-critical',
|
|
68
|
+
)}
|
|
69
|
+
/>
|
|
70
|
+
</ButtonPrimitive>
|
|
71
|
+
)
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
ref={ref}
|
|
75
|
+
data-slot="clipboard-text"
|
|
76
|
+
data-size={size}
|
|
77
|
+
data-status={status}
|
|
78
|
+
className={cn(
|
|
79
|
+
'flex min-w-0 items-center rounded-(--clipboard-text-radius) border border-stroke-input bg-surface-field text-default',
|
|
80
|
+
GROUP_FOCUS_RING,
|
|
81
|
+
heights[size],
|
|
82
|
+
disabled && 'opacity-disabled',
|
|
83
|
+
className,
|
|
84
|
+
)}
|
|
85
|
+
{...props}
|
|
86
|
+
>
|
|
87
|
+
<input
|
|
88
|
+
data-slot="clipboard-text-value"
|
|
89
|
+
value={text}
|
|
90
|
+
readOnly
|
|
91
|
+
disabled={disabled}
|
|
92
|
+
aria-label={textLabel}
|
|
93
|
+
className="h-full min-w-0 flex-1 truncate bg-transparent px-3 font-mono text-sm outline-none"
|
|
94
|
+
/>
|
|
95
|
+
{renderCopyButton ? renderCopyButton(button) : button}
|
|
96
|
+
<span role="status" aria-live="polite" aria-atomic="true" className="sr-only">
|
|
97
|
+
{statusText}
|
|
98
|
+
</span>
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
},
|
|
102
|
+
)
|