@leitware/composables 0.1.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/LICENSE +21 -0
- package/README.md +387 -0
- package/dist/presets/brutalist.css +298 -0
- package/dist/presets/default.css +298 -0
- package/dist/presets/signal-pop.css +369 -0
- package/dist/styles.css +2 -0
- package/package.json +216 -0
- package/rules/composables.md +244 -0
- package/src/_internal/accordion.tsx +93 -0
- package/src/_internal/ai-elements/attachments.tsx +385 -0
- package/src/_internal/ai-elements/chain-of-thought.tsx +197 -0
- package/src/_internal/ai-elements/code-block.tsx +516 -0
- package/src/_internal/ai-elements/confirmation.tsx +150 -0
- package/src/_internal/ai-elements/conversation.tsx +148 -0
- package/src/_internal/ai-elements/inline-citation.tsx +248 -0
- package/src/_internal/ai-elements/message.tsx +292 -0
- package/src/_internal/ai-elements/plan.tsx +126 -0
- package/src/_internal/ai-elements/prompt-input.tsx +1285 -0
- package/src/_internal/ai-elements/reasoning.tsx +208 -0
- package/src/_internal/ai-elements/shimmer.tsx +72 -0
- package/src/_internal/ai-elements/sources.tsx +53 -0
- package/src/_internal/ai-elements/suggestion.tsx +48 -0
- package/src/_internal/ai-elements/task.tsx +64 -0
- package/src/_internal/ai-elements/tool.tsx +156 -0
- package/src/_internal/alert-dialog.tsx +159 -0
- package/src/_internal/alert.tsx +88 -0
- package/src/_internal/aspect-ratio.tsx +23 -0
- package/src/_internal/avatar.tsx +58 -0
- package/src/_internal/badge.tsx +60 -0
- package/src/_internal/breadcrumb.tsx +104 -0
- package/src/_internal/bubble.tsx +125 -0
- package/src/_internal/button-group.tsx +78 -0
- package/src/_internal/button.tsx +62 -0
- package/src/_internal/calendar.tsx +179 -0
- package/src/_internal/card.tsx +83 -0
- package/src/_internal/carousel.tsx +215 -0
- package/src/_internal/checkbox.tsx +26 -0
- package/src/_internal/code-block.tsx +53 -0
- package/src/_internal/collapsible.tsx +15 -0
- package/src/_internal/combobox.tsx +264 -0
- package/src/_internal/command.tsx +155 -0
- package/src/_internal/container.tsx +35 -0
- package/src/_internal/dialog.tsx +132 -0
- package/src/_internal/direction.tsx +12 -0
- package/src/_internal/divider.tsx +162 -0
- package/src/_internal/dropdown-menu.tsx +247 -0
- package/src/_internal/dropzone.tsx +481 -0
- package/src/_internal/empty.tsx +94 -0
- package/src/_internal/field.tsx +221 -0
- package/src/_internal/grid-overlay.tsx +48 -0
- package/src/_internal/grid.tsx +109 -0
- package/src/_internal/hover-card.tsx +47 -0
- package/src/_internal/icon.tsx +45 -0
- package/src/_internal/input-group.tsx +146 -0
- package/src/_internal/input.tsx +24 -0
- package/src/_internal/item.tsx +187 -0
- package/src/_internal/kbd.tsx +28 -0
- package/src/_internal/label.tsx +18 -0
- package/src/_internal/layout-bento.tsx +386 -0
- package/src/_internal/layout.tsx +174 -0
- package/src/_internal/marker.tsx +66 -0
- package/src/_internal/message.tsx +85 -0
- package/src/_internal/native-select.tsx +50 -0
- package/src/_internal/pagination.tsx +108 -0
- package/src/_internal/popover.tsx +83 -0
- package/src/_internal/progress.tsx +59 -0
- package/src/_internal/radio-group.tsx +36 -0
- package/src/_internal/resizable.tsx +44 -0
- package/src/_internal/scroll-area.tsx +48 -0
- package/src/_internal/select.tsx +187 -0
- package/src/_internal/separator.tsx +19 -0
- package/src/_internal/sheet.tsx +122 -0
- package/src/_internal/sidebar.tsx +687 -0
- package/src/_internal/skeleton.tsx +13 -0
- package/src/_internal/slider.tsx +60 -0
- package/src/_internal/sonner.tsx +51 -0
- package/src/_internal/spacer.tsx +42 -0
- package/src/_internal/spinner.tsx +16 -0
- package/src/_internal/stack.tsx +78 -0
- package/src/_internal/switch.tsx +31 -0
- package/src/_internal/table.tsx +84 -0
- package/src/_internal/tabs.tsx +74 -0
- package/src/_internal/textarea.tsx +19 -0
- package/src/_internal/toggle-group.tsx +99 -0
- package/src/_internal/toggle.tsx +42 -0
- package/src/_internal/tooltip.tsx +55 -0
- package/src/_internal/typography.tsx +129 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/hooks/use-numeric-input.ts +119 -0
- package/src/index.ts +443 -0
- package/src/lib/numeric-input.ts +88 -0
- package/src/lib/utils.ts +39 -0
- package/src/opinionated/accordion.tsx +92 -0
- package/src/opinionated/ai/attachments.tsx +27 -0
- package/src/opinionated/ai/chain-of-thought.tsx +16 -0
- package/src/opinionated/ai/code-block.tsx +22 -0
- package/src/opinionated/ai/confirmation.tsx +16 -0
- package/src/opinionated/ai/conversation.tsx +13 -0
- package/src/opinionated/ai/index.ts +15 -0
- package/src/opinionated/ai/inline-citation.tsx +30 -0
- package/src/opinionated/ai/message.tsx +26 -0
- package/src/opinionated/ai/plan.tsx +18 -0
- package/src/opinionated/ai/prompt-input.tsx +29 -0
- package/src/opinionated/ai/reasoning.tsx +9 -0
- package/src/opinionated/ai/shimmer.tsx +4 -0
- package/src/opinionated/ai/sources.tsx +10 -0
- package/src/opinionated/ai/suggestion.tsx +6 -0
- package/src/opinionated/ai/task.tsx +12 -0
- package/src/opinionated/ai/tool.tsx +14 -0
- package/src/opinionated/alert-dialog.tsx +143 -0
- package/src/opinionated/alert.tsx +99 -0
- package/src/opinionated/aspect-ratio.tsx +12 -0
- package/src/opinionated/avatar.tsx +59 -0
- package/src/opinionated/badge.tsx +33 -0
- package/src/opinionated/breadcrumb.tsx +99 -0
- package/src/opinionated/bubble.tsx +9 -0
- package/src/opinionated/button.tsx +59 -0
- package/src/opinionated/calendar.tsx +20 -0
- package/src/opinionated/card.tsx +83 -0
- package/src/opinionated/carousel.tsx +99 -0
- package/src/opinionated/checkbox.tsx +11 -0
- package/src/opinionated/code-block.tsx +12 -0
- package/src/opinionated/collapsible.tsx +123 -0
- package/src/opinionated/combobox.tsx +123 -0
- package/src/opinionated/container.tsx +12 -0
- package/src/opinionated/dialog.tsx +124 -0
- package/src/opinionated/direction.tsx +6 -0
- package/src/opinionated/divider.tsx +13 -0
- package/src/opinionated/dropdown-menu.tsx +131 -0
- package/src/opinionated/dropzone.tsx +39 -0
- package/src/opinionated/empty.tsx +191 -0
- package/src/opinionated/field.tsx +26 -0
- package/src/opinionated/form-calendar-popover.tsx +138 -0
- package/src/opinionated/form-checkbox.tsx +107 -0
- package/src/opinionated/form-combobox.tsx +181 -0
- package/src/opinionated/form-date-of-birth.tsx +193 -0
- package/src/opinionated/form-dropzone.tsx +126 -0
- package/src/opinionated/form-input-group.tsx +184 -0
- package/src/opinionated/form-input.tsx +118 -0
- package/src/opinionated/form-multi-combobox.tsx +213 -0
- package/src/opinionated/form-multi-dropzone.tsx +141 -0
- package/src/opinionated/form-radiogroup.tsx +116 -0
- package/src/opinionated/form-select.tsx +176 -0
- package/src/opinionated/form-slider.tsx +100 -0
- package/src/opinionated/form-switch.tsx +117 -0
- package/src/opinionated/form-textarea.tsx +79 -0
- package/src/opinionated/grid-overlay.tsx +11 -0
- package/src/opinionated/grid.tsx +14 -0
- package/src/opinionated/hover-card.tsx +59 -0
- package/src/opinionated/icon.tsx +14 -0
- package/src/opinionated/input-group.tsx +20 -0
- package/src/opinionated/input.tsx +11 -0
- package/src/opinionated/item.tsx +182 -0
- package/src/opinionated/kbd.tsx +16 -0
- package/src/opinionated/label.tsx +11 -0
- package/src/opinionated/layout-bento.tsx +29 -0
- package/src/opinionated/layout.tsx +26 -0
- package/src/opinionated/list.tsx +94 -0
- package/src/opinionated/marker.tsx +7 -0
- package/src/opinionated/message.tsx +8 -0
- package/src/opinionated/native-select.tsx +51 -0
- package/src/opinionated/pagination.tsx +204 -0
- package/src/opinionated/popover.tsx +68 -0
- package/src/opinionated/progress.tsx +48 -0
- package/src/opinionated/radio-group.tsx +13 -0
- package/src/opinionated/resizable.tsx +2 -0
- package/src/opinionated/scroll-area.tsx +82 -0
- package/src/opinionated/select.tsx +101 -0
- package/src/opinionated/separator.tsx +11 -0
- package/src/opinionated/sheet.tsx +120 -0
- package/src/opinionated/sidebar.tsx +68 -0
- package/src/opinionated/skeleton.tsx +246 -0
- package/src/opinionated/slider.tsx +11 -0
- package/src/opinionated/sonner.tsx +15 -0
- package/src/opinionated/spacer.tsx +11 -0
- package/src/opinionated/stack.tsx +18 -0
- package/src/opinionated/switch.tsx +11 -0
- package/src/opinionated/table.tsx +11 -0
- package/src/opinionated/tabs.tsx +68 -0
- package/src/opinionated/textarea.tsx +11 -0
- package/src/opinionated/theme-injector.tsx +31 -0
- package/src/opinionated/toggle-group.tsx +63 -0
- package/src/opinionated/toggle.tsx +75 -0
- package/src/opinionated/token-config-panel/color-editor.tsx +85 -0
- package/src/opinionated/token-config-panel/helpers.ts +31 -0
- package/src/opinionated/token-config-panel/index.tsx +398 -0
- package/src/opinionated/token-config-panel/json-import-export.tsx +89 -0
- package/src/opinionated/token-config-panel/preset-manager.ts +31 -0
- package/src/opinionated/token-config-panel/presets-data.ts +23 -0
- package/src/opinionated/token-config-panel/spacing-editor.tsx +325 -0
- package/src/opinionated/token-config-panel/types.ts +39 -0
- package/src/opinionated/token-config-panel/typography-editor.tsx +145 -0
- package/src/opinionated/tooltip.tsx +62 -0
- package/src/opinionated/typography.tsx +7 -0
- package/src/scripts/lint-no-arbitrary.ts +155 -0
- package/src/styles/composable.css +68 -0
- package/src/styles/presets/brutalist.css +298 -0
- package/src/styles/presets/default.css +298 -0
- package/src/styles/presets/signal-pop.css +369 -0
- package/src/styles/presets-data/brutalist.ts +325 -0
- package/src/styles/presets-data/default.ts +315 -0
- package/src/styles/presets-data/index.ts +45 -0
- package/src/styles/presets-data/signal-pop.ts +393 -0
- package/src/styles/tokens/base.css +71 -0
- package/src/styles/tokens/components.css +150 -0
- package/src/styles/tokens/palette.css +795 -0
- package/src/styles/tokens/registry.ts +324 -0
- package/src/styles/tokens/semantic.css +266 -0
- package/src/styles/tokens/tailwind-theme.css +247 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for numeric input handling
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type NumericMode = 'integer' | 'decimal'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates a regex pattern for validating numeric input
|
|
9
|
+
*/
|
|
10
|
+
export function createNumericPattern(mode: NumericMode, maxDecimalPlaces: number): RegExp {
|
|
11
|
+
if (mode === 'integer') {
|
|
12
|
+
return /^-?\d*$/
|
|
13
|
+
}
|
|
14
|
+
return new RegExp(`^-?\\d*\\.?\\d{0,${maxDecimalPlaces}}$`)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Tests if a string value is valid for the given numeric mode
|
|
19
|
+
*/
|
|
20
|
+
export function isValidNumericInput(
|
|
21
|
+
value: string,
|
|
22
|
+
mode: NumericMode,
|
|
23
|
+
maxDecimalPlaces: number,
|
|
24
|
+
): boolean {
|
|
25
|
+
const pattern = createNumericPattern(mode, maxDecimalPlaces)
|
|
26
|
+
return pattern.test(value)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Sanitizes input by removing invalid characters and enforcing constraints.
|
|
31
|
+
* Always returns a valid string for the given mode.
|
|
32
|
+
*/
|
|
33
|
+
export function sanitizeNumericInput(
|
|
34
|
+
value: string,
|
|
35
|
+
mode: NumericMode,
|
|
36
|
+
maxDecimalPlaces: number,
|
|
37
|
+
): string {
|
|
38
|
+
if (value === '') return ''
|
|
39
|
+
|
|
40
|
+
if (mode === 'integer') {
|
|
41
|
+
// Keep only digits and minus
|
|
42
|
+
const hasLeadingMinus = value.startsWith('-')
|
|
43
|
+
const digits = value.replace(/[^\d]/g, '')
|
|
44
|
+
return hasLeadingMinus ? `-${digits}` : digits
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Decimal mode
|
|
48
|
+
// Keep only digits, decimal point, and minus
|
|
49
|
+
const hasLeadingMinus = value.startsWith('-')
|
|
50
|
+
let cleaned = value.replace(/[^\d.]/g, '')
|
|
51
|
+
|
|
52
|
+
// Handle multiple decimal points - keep only first
|
|
53
|
+
const dotIndex = cleaned.indexOf('.')
|
|
54
|
+
if (dotIndex !== -1) {
|
|
55
|
+
cleaned = cleaned.slice(0, dotIndex + 1) + cleaned.slice(dotIndex + 1).replace(/\./g, '')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Limit decimal places
|
|
59
|
+
const parts = cleaned.split('.')
|
|
60
|
+
if (parts[1] !== undefined && parts[1].length > maxDecimalPlaces) {
|
|
61
|
+
cleaned = `${parts[0]}.${parts[1].slice(0, maxDecimalPlaces)}`
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return hasLeadingMinus ? `-${cleaned}` : cleaned
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Parses a string value to a number based on the mode
|
|
69
|
+
* Returns null for empty strings or invalid numbers
|
|
70
|
+
*/
|
|
71
|
+
export function parseNumericValue(value: string, mode: NumericMode): number | null {
|
|
72
|
+
const trimmed = value.trim()
|
|
73
|
+
if (trimmed === '') {
|
|
74
|
+
return null
|
|
75
|
+
}
|
|
76
|
+
const num = mode === 'integer' ? parseInt(trimmed, 10) : parseFloat(trimmed)
|
|
77
|
+
return Number.isNaN(num) ? null : num
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Formats a numeric value to a string for display
|
|
82
|
+
*/
|
|
83
|
+
export function formatNumericValue(value: number | null | undefined): string {
|
|
84
|
+
if (value == null) {
|
|
85
|
+
return ''
|
|
86
|
+
}
|
|
87
|
+
return String(value)
|
|
88
|
+
}
|
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ClassValue, clsx } from 'clsx'
|
|
2
|
+
import { twMerge } from 'tailwind-merge'
|
|
3
|
+
|
|
4
|
+
export function cn(...inputs: ClassValue[]) {
|
|
5
|
+
return twMerge(clsx(inputs))
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Centralised focus ring style for all focusable elements.
|
|
10
|
+
* Change this once to update focus behaviour across every component.
|
|
11
|
+
*/
|
|
12
|
+
export const FOCUS_RING =
|
|
13
|
+
'focus-visible:border-[var(--focus-ring-color)] focus-visible:ring-[color:var(--focus-ring-color)]/30 focus-visible:ring-[length:var(--focus-ring-width)] aria-invalid:ring-stroke-critical/20 dark:aria-invalid:ring-stroke-critical/40 aria-invalid:border-stroke-critical dark:aria-invalid:border-stroke-critical/50 aria-invalid:ring-[length:var(--focus-ring-width)]'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Centralised hover ring style for all interactive elements.
|
|
17
|
+
* Uses the same accent color as focus but thinner — creates a clear
|
|
18
|
+
* escalation: hover = hint of accent, focus = full accent border + wider ring.
|
|
19
|
+
*/
|
|
20
|
+
export const HOVER_RING =
|
|
21
|
+
'hover:ring-[length:var(--hover-ring-width)] hover:ring-[color:var(--hover-ring-color)]/30'
|
|
22
|
+
|
|
23
|
+
/** Destructive-variant focus override – layer on top of FOCUS_RING. */
|
|
24
|
+
export const FOCUS_RING_DESTRUCTIVE =
|
|
25
|
+
'focus-visible:ring-stroke-critical/20 dark:focus-visible:ring-stroke-critical/40 focus-visible:border-stroke-critical/40'
|
|
26
|
+
|
|
27
|
+
/** Disabled state opacity — single source of truth for all disabled elements. */
|
|
28
|
+
export const DISABLED_OPACITY = 'disabled:opacity-disabled'
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Left-pad a string to a given total length using the provided fill character.
|
|
32
|
+
* Used by CodeBlock to right-align line numbers.
|
|
33
|
+
*
|
|
34
|
+
* @example leftPad('7', 3) // ' 7' (using space fill)
|
|
35
|
+
* @example leftPad('42', 3) // ' 42'
|
|
36
|
+
*/
|
|
37
|
+
export function leftPad(str: string, length: number, fill = ' '): string {
|
|
38
|
+
return str.length >= length ? str : fill.repeat(length - str.length) + str
|
|
39
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Accordion as AccordionPrimitiveBase } from '@base-ui/react/accordion'
|
|
2
|
+
import type * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
AccordionContent,
|
|
6
|
+
AccordionItem,
|
|
7
|
+
Accordion as AccordionPrimitive,
|
|
8
|
+
AccordionTrigger,
|
|
9
|
+
} from '../_internal/accordion'
|
|
10
|
+
|
|
11
|
+
/** A single panel in an Accordion. */
|
|
12
|
+
export interface AccordionItemData {
|
|
13
|
+
/** Unique identifier for this panel (used for controlled open state). */
|
|
14
|
+
value: string
|
|
15
|
+
/** Content rendered in the clickable trigger/header row. */
|
|
16
|
+
trigger: React.ReactNode
|
|
17
|
+
/** Content revealed when this panel is open. */
|
|
18
|
+
content: React.ReactNode
|
|
19
|
+
/** Whether this panel is open by default. @default false */
|
|
20
|
+
defaultOpen?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Props for the opinionated Accordion component.
|
|
25
|
+
*
|
|
26
|
+
* Pass `items` for the convenience array API, or use `children`
|
|
27
|
+
* with `AccordionItem` / `AccordionTrigger` / `AccordionContent` for full control.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <Accordion items={[
|
|
32
|
+
* { value: 'faq-1', trigger: 'What is this?', content: 'A component library.' },
|
|
33
|
+
* { value: 'faq-2', trigger: 'How do I install it?', content: '...', defaultOpen: true },
|
|
34
|
+
* ]} />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export interface AccordionProps extends Omit<AccordionPrimitiveBase.Root.Props, 'children'> {
|
|
38
|
+
className?: string
|
|
39
|
+
/** Panels to render. When provided, `children` is ignored. */
|
|
40
|
+
items?: AccordionItemData[]
|
|
41
|
+
children?: React.ReactNode
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function Accordion({
|
|
45
|
+
className,
|
|
46
|
+
items,
|
|
47
|
+
children,
|
|
48
|
+
defaultValue,
|
|
49
|
+
...accordionProps
|
|
50
|
+
}: AccordionProps) {
|
|
51
|
+
// If items prop is provided, use opinionated API
|
|
52
|
+
if (items) {
|
|
53
|
+
// Calculate default value from items that have defaultOpen: true
|
|
54
|
+
const defaultOpenValues = items.filter((item) => item.defaultOpen).map((item) => item.value)
|
|
55
|
+
const computedDefaultValue =
|
|
56
|
+
defaultValue ?? (defaultOpenValues.length > 0 ? defaultOpenValues : undefined)
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<AccordionPrimitive
|
|
60
|
+
className={className}
|
|
61
|
+
defaultValue={computedDefaultValue}
|
|
62
|
+
{...accordionProps}
|
|
63
|
+
>
|
|
64
|
+
{items.map((item) => (
|
|
65
|
+
<AccordionItem key={item.value} value={item.value}>
|
|
66
|
+
<AccordionTrigger>{item.trigger}</AccordionTrigger>
|
|
67
|
+
<AccordionContent>{item.content}</AccordionContent>
|
|
68
|
+
</AccordionItem>
|
|
69
|
+
))}
|
|
70
|
+
</AccordionPrimitive>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Fallback to children-based API for advanced use cases
|
|
75
|
+
if (children) {
|
|
76
|
+
return (
|
|
77
|
+
<AccordionPrimitive className={className} defaultValue={defaultValue} {...accordionProps}>
|
|
78
|
+
{children}
|
|
79
|
+
</AccordionPrimitive>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// If neither items nor children provided, return empty accordion
|
|
84
|
+
return (
|
|
85
|
+
<AccordionPrimitive className={className} defaultValue={defaultValue} {...accordionProps}>
|
|
86
|
+
{null}
|
|
87
|
+
</AccordionPrimitive>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Re-export all accordion sub-components for convenience
|
|
92
|
+
export { AccordionContent, AccordionItem, AccordionTrigger, Accordion }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Attachments as AIAttachments,
|
|
3
|
+
Attachment as AIAttachment,
|
|
4
|
+
AttachmentPreview as AIAttachmentPreview,
|
|
5
|
+
AttachmentInfo as AIAttachmentInfo,
|
|
6
|
+
AttachmentRemove as AIAttachmentRemove,
|
|
7
|
+
AttachmentHoverCard as AIAttachmentHoverCard,
|
|
8
|
+
AttachmentHoverCardTrigger as AIAttachmentHoverCardTrigger,
|
|
9
|
+
AttachmentHoverCardContent as AIAttachmentHoverCardContent,
|
|
10
|
+
AttachmentEmpty as AIAttachmentEmpty,
|
|
11
|
+
useAttachmentsContext,
|
|
12
|
+
useAttachmentContext,
|
|
13
|
+
getMediaCategory,
|
|
14
|
+
getAttachmentLabel,
|
|
15
|
+
type AttachmentsProps as AIAttachmentsProps,
|
|
16
|
+
type AttachmentProps as AIAttachmentProps,
|
|
17
|
+
type AttachmentPreviewProps as AIAttachmentPreviewProps,
|
|
18
|
+
type AttachmentInfoProps as AIAttachmentInfoProps,
|
|
19
|
+
type AttachmentRemoveProps as AIAttachmentRemoveProps,
|
|
20
|
+
type AttachmentHoverCardProps as AIAttachmentHoverCardProps,
|
|
21
|
+
type AttachmentHoverCardTriggerProps as AIAttachmentHoverCardTriggerProps,
|
|
22
|
+
type AttachmentHoverCardContentProps as AIAttachmentHoverCardContentProps,
|
|
23
|
+
type AttachmentEmptyProps as AIAttachmentEmptyProps,
|
|
24
|
+
type AttachmentData,
|
|
25
|
+
type AttachmentMediaCategory,
|
|
26
|
+
type AttachmentVariant,
|
|
27
|
+
} from '../../_internal/ai-elements/attachments'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export {
|
|
2
|
+
ChainOfThought as AIChainOfThought,
|
|
3
|
+
ChainOfThoughtHeader as AIChainOfThoughtHeader,
|
|
4
|
+
ChainOfThoughtStep as AIChainOfThoughtStep,
|
|
5
|
+
ChainOfThoughtContent as AIChainOfThoughtContent,
|
|
6
|
+
ChainOfThoughtSearchResults as AIChainOfThoughtSearchResults,
|
|
7
|
+
ChainOfThoughtSearchResult as AIChainOfThoughtSearchResult,
|
|
8
|
+
ChainOfThoughtImage as AIChainOfThoughtImage,
|
|
9
|
+
type ChainOfThoughtProps as AIChainOfThoughtProps,
|
|
10
|
+
type ChainOfThoughtHeaderProps as AIChainOfThoughtHeaderProps,
|
|
11
|
+
type ChainOfThoughtStepProps as AIChainOfThoughtStepProps,
|
|
12
|
+
type ChainOfThoughtContentProps as AIChainOfThoughtContentProps,
|
|
13
|
+
type ChainOfThoughtSearchResultsProps as AIChainOfThoughtSearchResultsProps,
|
|
14
|
+
type ChainOfThoughtSearchResultProps as AIChainOfThoughtSearchResultProps,
|
|
15
|
+
type ChainOfThoughtImageProps as AIChainOfThoughtImageProps,
|
|
16
|
+
} from '../../_internal/ai-elements/chain-of-thought'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export {
|
|
2
|
+
CodeBlock as AICodeBlock,
|
|
3
|
+
CodeBlockContainer as AICodeBlockContainer,
|
|
4
|
+
CodeBlockHeader as AICodeBlockHeader,
|
|
5
|
+
CodeBlockTitle as AICodeBlockTitle,
|
|
6
|
+
CodeBlockFilename as AICodeBlockFilename,
|
|
7
|
+
CodeBlockActions as AICodeBlockActions,
|
|
8
|
+
CodeBlockContent as AICodeBlockContent,
|
|
9
|
+
CodeBlockCopyButton as AICodeBlockCopyButton,
|
|
10
|
+
CodeBlockLanguageSelector as AICodeBlockLanguageSelector,
|
|
11
|
+
CodeBlockLanguageSelectorTrigger as AICodeBlockLanguageSelectorTrigger,
|
|
12
|
+
CodeBlockLanguageSelectorValue as AICodeBlockLanguageSelectorValue,
|
|
13
|
+
CodeBlockLanguageSelectorContent as AICodeBlockLanguageSelectorContent,
|
|
14
|
+
CodeBlockLanguageSelectorItem as AICodeBlockLanguageSelectorItem,
|
|
15
|
+
highlightCode,
|
|
16
|
+
type CodeBlockCopyButtonProps as AICodeBlockCopyButtonProps,
|
|
17
|
+
type CodeBlockLanguageSelectorProps as AICodeBlockLanguageSelectorProps,
|
|
18
|
+
type CodeBlockLanguageSelectorTriggerProps as AICodeBlockLanguageSelectorTriggerProps,
|
|
19
|
+
type CodeBlockLanguageSelectorValueProps as AICodeBlockLanguageSelectorValueProps,
|
|
20
|
+
type CodeBlockLanguageSelectorContentProps as AICodeBlockLanguageSelectorContentProps,
|
|
21
|
+
type CodeBlockLanguageSelectorItemProps as AICodeBlockLanguageSelectorItemProps,
|
|
22
|
+
} from '../../_internal/ai-elements/code-block'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Confirmation as AIConfirmation,
|
|
3
|
+
ConfirmationTitle as AIConfirmationTitle,
|
|
4
|
+
ConfirmationRequest as AIConfirmationRequest,
|
|
5
|
+
ConfirmationAccepted as AIConfirmationAccepted,
|
|
6
|
+
ConfirmationRejected as AIConfirmationRejected,
|
|
7
|
+
ConfirmationActions as AIConfirmationActions,
|
|
8
|
+
ConfirmationAction as AIConfirmationAction,
|
|
9
|
+
type ConfirmationProps as AIConfirmationProps,
|
|
10
|
+
type ConfirmationTitleProps as AIConfirmationTitleProps,
|
|
11
|
+
type ConfirmationRequestProps as AIConfirmationRequestProps,
|
|
12
|
+
type ConfirmationAcceptedProps as AIConfirmationAcceptedProps,
|
|
13
|
+
type ConfirmationRejectedProps as AIConfirmationRejectedProps,
|
|
14
|
+
type ConfirmationActionsProps as AIConfirmationActionsProps,
|
|
15
|
+
type ConfirmationActionProps as AIConfirmationActionProps,
|
|
16
|
+
} from '../../_internal/ai-elements/confirmation'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Conversation as AIConversation,
|
|
3
|
+
ConversationContent as AIConversationContent,
|
|
4
|
+
ConversationEmptyState as AIConversationEmptyState,
|
|
5
|
+
ConversationScrollButton as AIConversationScrollButton,
|
|
6
|
+
ConversationDownload as AIConversationDownload,
|
|
7
|
+
messagesToMarkdown,
|
|
8
|
+
type ConversationProps as AIConversationProps,
|
|
9
|
+
type ConversationContentProps as AIConversationContentProps,
|
|
10
|
+
type ConversationEmptyStateProps as AIConversationEmptyStateProps,
|
|
11
|
+
type ConversationScrollButtonProps as AIConversationScrollButtonProps,
|
|
12
|
+
type ConversationDownloadProps as AIConversationDownloadProps,
|
|
13
|
+
} from '../../_internal/ai-elements/conversation'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './attachments'
|
|
2
|
+
export * from './chain-of-thought'
|
|
3
|
+
export * from './code-block'
|
|
4
|
+
export * from './confirmation'
|
|
5
|
+
export * from './conversation'
|
|
6
|
+
export * from './inline-citation'
|
|
7
|
+
export * from './message'
|
|
8
|
+
export * from './plan'
|
|
9
|
+
export * from './prompt-input'
|
|
10
|
+
export * from './reasoning'
|
|
11
|
+
export * from './shimmer'
|
|
12
|
+
export * from './sources'
|
|
13
|
+
export * from './suggestion'
|
|
14
|
+
export * from './task'
|
|
15
|
+
export * from './tool'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export {
|
|
2
|
+
InlineCitation as AIInlineCitation,
|
|
3
|
+
InlineCitationText as AIInlineCitationText,
|
|
4
|
+
InlineCitationCard as AIInlineCitationCard,
|
|
5
|
+
InlineCitationCardTrigger as AIInlineCitationCardTrigger,
|
|
6
|
+
InlineCitationCardBody as AIInlineCitationCardBody,
|
|
7
|
+
InlineCitationCarousel as AIInlineCitationCarousel,
|
|
8
|
+
InlineCitationCarouselContent as AIInlineCitationCarouselContent,
|
|
9
|
+
InlineCitationCarouselItem as AIInlineCitationCarouselItem,
|
|
10
|
+
InlineCitationCarouselHeader as AIInlineCitationCarouselHeader,
|
|
11
|
+
InlineCitationCarouselIndex as AIInlineCitationCarouselIndex,
|
|
12
|
+
InlineCitationCarouselPrev as AIInlineCitationCarouselPrev,
|
|
13
|
+
InlineCitationCarouselNext as AIInlineCitationCarouselNext,
|
|
14
|
+
InlineCitationSource as AIInlineCitationSource,
|
|
15
|
+
InlineCitationQuote as AIInlineCitationQuote,
|
|
16
|
+
type InlineCitationProps as AIInlineCitationProps,
|
|
17
|
+
type InlineCitationTextProps as AIInlineCitationTextProps,
|
|
18
|
+
type InlineCitationCardProps as AIInlineCitationCardProps,
|
|
19
|
+
type InlineCitationCardTriggerProps as AIInlineCitationCardTriggerProps,
|
|
20
|
+
type InlineCitationCardBodyProps as AIInlineCitationCardBodyProps,
|
|
21
|
+
type InlineCitationCarouselProps as AIInlineCitationCarouselProps,
|
|
22
|
+
type InlineCitationCarouselContentProps as AIInlineCitationCarouselContentProps,
|
|
23
|
+
type InlineCitationCarouselItemProps as AIInlineCitationCarouselItemProps,
|
|
24
|
+
type InlineCitationCarouselHeaderProps as AIInlineCitationCarouselHeaderProps,
|
|
25
|
+
type InlineCitationCarouselIndexProps as AIInlineCitationCarouselIndexProps,
|
|
26
|
+
type InlineCitationCarouselPrevProps as AIInlineCitationCarouselPrevProps,
|
|
27
|
+
type InlineCitationCarouselNextProps as AIInlineCitationCarouselNextProps,
|
|
28
|
+
type InlineCitationSourceProps as AIInlineCitationSourceProps,
|
|
29
|
+
type InlineCitationQuoteProps as AIInlineCitationQuoteProps,
|
|
30
|
+
} from '../../_internal/ai-elements/inline-citation'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Message as AIMessage,
|
|
3
|
+
MessageContent as AIMessageContent,
|
|
4
|
+
MessageActions as AIMessageActions,
|
|
5
|
+
MessageAction as AIMessageAction,
|
|
6
|
+
MessageResponse as AIMessageResponse,
|
|
7
|
+
MessageToolbar as AIMessageToolbar,
|
|
8
|
+
MessageBranch as AIMessageBranch,
|
|
9
|
+
MessageBranchContent as AIMessageBranchContent,
|
|
10
|
+
MessageBranchSelector as AIMessageBranchSelector,
|
|
11
|
+
MessageBranchPrevious as AIMessageBranchPrevious,
|
|
12
|
+
MessageBranchNext as AIMessageBranchNext,
|
|
13
|
+
MessageBranchPage as AIMessageBranchPage,
|
|
14
|
+
type MessageProps as AIMessageProps,
|
|
15
|
+
type MessageContentProps as AIMessageContentProps,
|
|
16
|
+
type MessageActionsProps as AIMessageActionsProps,
|
|
17
|
+
type MessageActionProps as AIMessageActionProps,
|
|
18
|
+
type MessageResponseProps as AIMessageResponseProps,
|
|
19
|
+
type MessageToolbarProps as AIMessageToolbarProps,
|
|
20
|
+
type MessageBranchProps as AIMessageBranchProps,
|
|
21
|
+
type MessageBranchContentProps as AIMessageBranchContentProps,
|
|
22
|
+
type MessageBranchSelectorProps as AIMessageBranchSelectorProps,
|
|
23
|
+
type MessageBranchPreviousProps as AIMessageBranchPreviousProps,
|
|
24
|
+
type MessageBranchNextProps as AIMessageBranchNextProps,
|
|
25
|
+
type MessageBranchPageProps as AIMessageBranchPageProps,
|
|
26
|
+
} from '../../_internal/ai-elements/message'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Plan as AIPlan,
|
|
3
|
+
PlanHeader as AIPlanHeader,
|
|
4
|
+
PlanTitle as AIPlanTitle,
|
|
5
|
+
PlanDescription as AIPlanDescription,
|
|
6
|
+
PlanAction as AIPlanAction,
|
|
7
|
+
PlanContent as AIPlanContent,
|
|
8
|
+
PlanFooter as AIPlanFooter,
|
|
9
|
+
PlanTrigger as AIPlanTrigger,
|
|
10
|
+
type PlanProps as AIPlanProps,
|
|
11
|
+
type PlanHeaderProps as AIPlanHeaderProps,
|
|
12
|
+
type PlanTitleProps as AIPlanTitleProps,
|
|
13
|
+
type PlanDescriptionProps as AIPlanDescriptionProps,
|
|
14
|
+
type PlanActionProps as AIPlanActionProps,
|
|
15
|
+
type PlanContentProps as AIPlanContentProps,
|
|
16
|
+
type PlanFooterProps as AIPlanFooterProps,
|
|
17
|
+
type PlanTriggerProps as AIPlanTriggerProps,
|
|
18
|
+
} from '../../_internal/ai-elements/plan'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export {
|
|
2
|
+
PromptInput as AIPromptInput,
|
|
3
|
+
PromptInputProvider as AIPromptInputProvider,
|
|
4
|
+
PromptInputTextarea as AIPromptInputTextarea,
|
|
5
|
+
PromptInputHeader as AIPromptInputHeader,
|
|
6
|
+
PromptInputFooter as AIPromptInputFooter,
|
|
7
|
+
PromptInputBody as AIPromptInputBody,
|
|
8
|
+
PromptInputTools as AIPromptInputTools,
|
|
9
|
+
PromptInputButton as AIPromptInputButton,
|
|
10
|
+
PromptInputSubmit as AIPromptInputSubmit,
|
|
11
|
+
PromptInputActionMenu as AIPromptInputActionMenu,
|
|
12
|
+
PromptInputActionMenuTrigger as AIPromptInputActionMenuTrigger,
|
|
13
|
+
PromptInputActionMenuContent as AIPromptInputActionMenuContent,
|
|
14
|
+
PromptInputActionMenuItem as AIPromptInputActionMenuItem,
|
|
15
|
+
PromptInputActionAddAttachments as AIPromptInputActionAddAttachments,
|
|
16
|
+
PromptInputActionAddScreenshot as AIPromptInputActionAddScreenshot,
|
|
17
|
+
PromptInputSelect as AIPromptInputSelect,
|
|
18
|
+
PromptInputSelectTrigger as AIPromptInputSelectTrigger,
|
|
19
|
+
PromptInputSelectContent as AIPromptInputSelectContent,
|
|
20
|
+
PromptInputSelectItem as AIPromptInputSelectItem,
|
|
21
|
+
PromptInputSelectValue as AIPromptInputSelectValue,
|
|
22
|
+
usePromptInputController,
|
|
23
|
+
usePromptInputAttachments,
|
|
24
|
+
usePromptInputReferencedSources,
|
|
25
|
+
useProviderAttachments,
|
|
26
|
+
type PromptInputProps as AIPromptInputProps,
|
|
27
|
+
type PromptInputSubmitProps as AIPromptInputSubmitProps,
|
|
28
|
+
type PromptInputMessage,
|
|
29
|
+
} from '../../_internal/ai-elements/prompt-input'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Reasoning as AIReasoning,
|
|
3
|
+
ReasoningTrigger as AIReasoningTrigger,
|
|
4
|
+
ReasoningContent as AIReasoningContent,
|
|
5
|
+
useReasoning,
|
|
6
|
+
type ReasoningProps as AIReasoningProps,
|
|
7
|
+
type ReasoningTriggerProps as AIReasoningTriggerProps,
|
|
8
|
+
type ReasoningContentProps as AIReasoningContentProps,
|
|
9
|
+
} from '../../_internal/ai-elements/reasoning'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Sources as AISources,
|
|
3
|
+
SourcesTrigger as AISourcesTrigger,
|
|
4
|
+
SourcesContent as AISourcesContent,
|
|
5
|
+
Source as AISource,
|
|
6
|
+
type SourcesProps as AISourcesProps,
|
|
7
|
+
type SourcesTriggerProps as AISourcesTriggerProps,
|
|
8
|
+
type SourcesContentProps as AISourcesContentProps,
|
|
9
|
+
type SourceProps as AISourceProps,
|
|
10
|
+
} from '../../_internal/ai-elements/sources'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Task as AITask,
|
|
3
|
+
TaskTrigger as AITaskTrigger,
|
|
4
|
+
TaskContent as AITaskContent,
|
|
5
|
+
TaskItem as AITaskItem,
|
|
6
|
+
TaskItemFile as AITaskItemFile,
|
|
7
|
+
type TaskProps as AITaskProps,
|
|
8
|
+
type TaskTriggerProps as AITaskTriggerProps,
|
|
9
|
+
type TaskContentProps as AITaskContentProps,
|
|
10
|
+
type TaskItemProps as AITaskItemProps,
|
|
11
|
+
type TaskItemFileProps as AITaskItemFileProps,
|
|
12
|
+
} from '../../_internal/ai-elements/task'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Tool as AITool,
|
|
3
|
+
ToolHeader as AIToolHeader,
|
|
4
|
+
ToolContent as AIToolContent,
|
|
5
|
+
ToolInput as AIToolInput,
|
|
6
|
+
ToolOutput as AIToolOutput,
|
|
7
|
+
getStatusBadge,
|
|
8
|
+
type ToolProps as AIToolProps,
|
|
9
|
+
type ToolHeaderProps as AIToolHeaderProps,
|
|
10
|
+
type ToolContentProps as AIToolContentProps,
|
|
11
|
+
type ToolInputProps as AIToolInputProps,
|
|
12
|
+
type ToolOutputProps as AIToolOutputProps,
|
|
13
|
+
type ToolPart,
|
|
14
|
+
} from '../../_internal/ai-elements/tool'
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { AlertDialog as AlertDialogPrimitiveBase } from '@base-ui/react/alert-dialog'
|
|
2
|
+
import type * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
AlertDialogAction,
|
|
6
|
+
AlertDialogCancel,
|
|
7
|
+
AlertDialogContent,
|
|
8
|
+
AlertDialogDescription,
|
|
9
|
+
AlertDialogFooter,
|
|
10
|
+
AlertDialogHeader,
|
|
11
|
+
AlertDialogMedia,
|
|
12
|
+
AlertDialogOverlay,
|
|
13
|
+
AlertDialogPortal,
|
|
14
|
+
AlertDialog as AlertDialogPrimitive,
|
|
15
|
+
AlertDialogTitle,
|
|
16
|
+
AlertDialogTrigger,
|
|
17
|
+
} from '../_internal/alert-dialog'
|
|
18
|
+
|
|
19
|
+
export interface AlertDialogProps extends Omit<AlertDialogPrimitiveBase.Root.Props, 'children'> {
|
|
20
|
+
/** Element that triggers the dialog */
|
|
21
|
+
trigger?: React.ReactNode
|
|
22
|
+
/** Dialog title */
|
|
23
|
+
title?: React.ReactNode
|
|
24
|
+
/** Dialog description */
|
|
25
|
+
description?: React.ReactNode
|
|
26
|
+
/** Dialog body content */
|
|
27
|
+
children?: React.ReactNode
|
|
28
|
+
/** Text for the cancel button */
|
|
29
|
+
cancelText?: string
|
|
30
|
+
/** Text for the action button */
|
|
31
|
+
actionText?: string
|
|
32
|
+
/** Callback when action button is clicked */
|
|
33
|
+
onAction?: () => void
|
|
34
|
+
/** Callback when cancel button is clicked */
|
|
35
|
+
onCancel?: () => void
|
|
36
|
+
/** Icon or media to display in the header */
|
|
37
|
+
media?: React.ReactNode
|
|
38
|
+
/** Size variant for the dialog */
|
|
39
|
+
size?: 'default' | 'sm'
|
|
40
|
+
/** Additional class names for the content */
|
|
41
|
+
className?: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Opinionated AlertDialog component for important confirmations.
|
|
46
|
+
* Follows the same pattern as dialog.tsx for consistency.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* <AlertDialog
|
|
51
|
+
* trigger={<Button variant="destructive">Delete Account</Button>}
|
|
52
|
+
* title="Are you sure?"
|
|
53
|
+
* description="This action cannot be undone. Your account will be permanently deleted."
|
|
54
|
+
* cancelText="Cancel"
|
|
55
|
+
* actionText="Delete"
|
|
56
|
+
* onAction={() => deleteAccount()}
|
|
57
|
+
* />
|
|
58
|
+
*
|
|
59
|
+
* // With media/icon
|
|
60
|
+
* <AlertDialog
|
|
61
|
+
* trigger={<Button>Confirm</Button>}
|
|
62
|
+
* media={<AlertCircleIcon />}
|
|
63
|
+
* title="Confirm Action"
|
|
64
|
+
* description="Are you sure you want to proceed?"
|
|
65
|
+
* actionText="Continue"
|
|
66
|
+
* cancelText="Go Back"
|
|
67
|
+
* />
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
function AlertDialog({
|
|
71
|
+
trigger,
|
|
72
|
+
title,
|
|
73
|
+
description,
|
|
74
|
+
children,
|
|
75
|
+
cancelText = 'Cancel',
|
|
76
|
+
actionText = 'Continue',
|
|
77
|
+
onAction,
|
|
78
|
+
onCancel,
|
|
79
|
+
media,
|
|
80
|
+
size = 'default',
|
|
81
|
+
className,
|
|
82
|
+
open,
|
|
83
|
+
onOpenChange,
|
|
84
|
+
...dialogProps
|
|
85
|
+
}: AlertDialogProps) {
|
|
86
|
+
// If opinionated props are provided, use opinionated API
|
|
87
|
+
if (
|
|
88
|
+
trigger !== undefined ||
|
|
89
|
+
title !== undefined ||
|
|
90
|
+
description !== undefined ||
|
|
91
|
+
media !== undefined
|
|
92
|
+
) {
|
|
93
|
+
return (
|
|
94
|
+
<AlertDialogPrimitive open={open} onOpenChange={onOpenChange} {...dialogProps}>
|
|
95
|
+
{trigger && <AlertDialogTrigger render={<>{trigger}</>} />}
|
|
96
|
+
<AlertDialogContent size={size} className={className}>
|
|
97
|
+
<AlertDialogHeader>
|
|
98
|
+
{media && <AlertDialogMedia>{media}</AlertDialogMedia>}
|
|
99
|
+
{title && <AlertDialogTitle>{title}</AlertDialogTitle>}
|
|
100
|
+
{description && <AlertDialogDescription>{description}</AlertDialogDescription>}
|
|
101
|
+
</AlertDialogHeader>
|
|
102
|
+
{children}
|
|
103
|
+
<AlertDialogFooter>
|
|
104
|
+
<AlertDialogCancel onClick={onCancel}>{cancelText}</AlertDialogCancel>
|
|
105
|
+
<AlertDialogAction onClick={onAction}>{actionText}</AlertDialogAction>
|
|
106
|
+
</AlertDialogFooter>
|
|
107
|
+
</AlertDialogContent>
|
|
108
|
+
</AlertDialogPrimitive>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Fallback to children-based API for advanced use cases
|
|
113
|
+
if (children) {
|
|
114
|
+
return (
|
|
115
|
+
<AlertDialogPrimitive open={open} onOpenChange={onOpenChange} {...dialogProps}>
|
|
116
|
+
{children}
|
|
117
|
+
</AlertDialogPrimitive>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// If neither opinionated props nor children provided, return empty dialog
|
|
122
|
+
return (
|
|
123
|
+
<AlertDialogPrimitive open={open} onOpenChange={onOpenChange} {...dialogProps}>
|
|
124
|
+
{null}
|
|
125
|
+
</AlertDialogPrimitive>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Re-export all sub-components for advanced usage
|
|
130
|
+
export {
|
|
131
|
+
AlertDialogAction,
|
|
132
|
+
AlertDialogCancel,
|
|
133
|
+
AlertDialogContent,
|
|
134
|
+
AlertDialogDescription,
|
|
135
|
+
AlertDialogFooter,
|
|
136
|
+
AlertDialogHeader,
|
|
137
|
+
AlertDialogMedia,
|
|
138
|
+
AlertDialogOverlay,
|
|
139
|
+
AlertDialogPortal,
|
|
140
|
+
AlertDialogTitle,
|
|
141
|
+
AlertDialogTrigger,
|
|
142
|
+
}
|
|
143
|
+
export { AlertDialog }
|