@refraction-ui/astro 0.3.1 → 0.4.2
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/dist/astro-accordion/Button.astro +55 -0
- package/dist/astro-accordion/index.ts +1 -0
- package/dist/astro-ai/AIScript.astro +69 -0
- package/dist/astro-ai/TTSScript.astro +60 -0
- package/dist/astro-ai/index.ts +16 -0
- package/dist/astro-animated-text/AnimatedText.astro +81 -0
- package/dist/astro-animated-text/TypewriterText.astro +90 -0
- package/dist/astro-animated-text/index.ts +1 -0
- package/dist/astro-app-shell/AppShell.astro +195 -0
- package/dist/astro-app-shell/AppShellContent.astro +29 -0
- package/dist/astro-app-shell/AppShellHeader.astro +54 -0
- package/dist/astro-app-shell/AppShellMain.astro +18 -0
- package/dist/astro-app-shell/AppShellMobileNav.astro +27 -0
- package/dist/astro-app-shell/AppShellOverlay.astro +21 -0
- package/dist/astro-app-shell/AppShellSidebar.astro +26 -0
- package/dist/astro-app-shell/AuthShell.astro +31 -0
- package/dist/astro-app-shell/AuthShellCard.astro +24 -0
- package/dist/astro-app-shell/PageShell.astro +36 -0
- package/dist/astro-app-shell/PageShellFooter.astro +30 -0
- package/dist/astro-app-shell/PageShellNav.astro +33 -0
- package/dist/astro-app-shell/PageShellSection.astro +32 -0
- package/dist/astro-app-shell/index.ts +21 -0
- package/dist/astro-auth/AuthGuard.astro +133 -0
- package/dist/astro-auth/index.ts +5 -0
- package/dist/astro-avatar/Avatar.astro +22 -0
- package/dist/astro-avatar/AvatarFallback.astro +18 -0
- package/dist/astro-avatar/AvatarImage.astro +48 -0
- package/dist/astro-avatar/index.ts +1 -0
- package/dist/astro-avatar-group/AvatarGroup.astro +42 -0
- package/dist/astro-avatar-group/index.ts +1 -0
- package/dist/astro-badge/Badge.astro +27 -0
- package/dist/astro-badge/index.ts +1 -0
- package/dist/astro-bottom-nav/BottomNav.astro +40 -0
- package/dist/astro-bottom-nav/index.ts +1 -0
- package/dist/astro-breadcrumbs/Breadcrumbs.astro +56 -0
- package/dist/astro-breadcrumbs/index.ts +1 -0
- package/dist/astro-button/Button.astro +55 -0
- package/dist/astro-button/index.ts +1 -0
- package/dist/astro-calendar/Calendar.astro +259 -0
- package/dist/astro-calendar/index.ts +1 -0
- package/dist/astro-callout/Callout.astro +3 -0
- package/dist/astro-callout/index.ts +1 -0
- package/dist/astro-card/Card.astro +20 -0
- package/dist/astro-card/CardContent.astro +13 -0
- package/dist/astro-card/CardDescription.astro +13 -0
- package/dist/astro-card/CardFooter.astro +13 -0
- package/dist/astro-card/CardHeader.astro +13 -0
- package/dist/astro-card/CardTitle.astro +15 -0
- package/dist/astro-card/index.ts +1 -0
- package/dist/astro-card-grid/CardGrid.astro +17 -0
- package/dist/astro-card-grid/index.ts +1 -0
- package/dist/astro-carousel/Button.astro +55 -0
- package/dist/astro-carousel/index.ts +1 -0
- package/dist/astro-charts/Bars.astro +53 -0
- package/dist/astro-charts/Chart.astro +31 -0
- package/dist/astro-charts/Circles.astro +48 -0
- package/dist/astro-charts/Gradient.astro +34 -0
- package/dist/astro-charts/Histogram.astro +107 -0
- package/dist/astro-charts/Line.astro +55 -0
- package/dist/astro-charts/PieChart.astro +63 -0
- package/dist/astro-charts/ScatterPlot.astro +95 -0
- package/dist/astro-charts/XAxis.astro +46 -0
- package/dist/astro-charts/YAxis.astro +44 -0
- package/dist/astro-charts/index.ts +26 -0
- package/dist/astro-checkbox/Checkbox.astro +129 -0
- package/dist/astro-checkbox/index.ts +1 -0
- package/dist/astro-code-block/CodeBlock.astro +3 -0
- package/dist/astro-code-block/index.ts +1 -0
- package/dist/astro-code-editor/CodeEditor.astro +123 -0
- package/dist/astro-code-editor/index.ts +1 -0
- package/dist/astro-collapsible/Collapsible.astro +58 -0
- package/dist/astro-collapsible/CollapsibleContent.astro +21 -0
- package/dist/astro-collapsible/CollapsibleTrigger.astro +17 -0
- package/dist/astro-collapsible/index.ts +1 -0
- package/dist/astro-command/Command.astro +170 -0
- package/dist/astro-command/CommandEmpty.astro +17 -0
- package/dist/astro-command/CommandGroup.astro +25 -0
- package/dist/astro-command/CommandInput.astro +21 -0
- package/dist/astro-command/CommandItem.astro +26 -0
- package/dist/astro-command/CommandList.astro +17 -0
- package/dist/astro-command/CommandSeparator.astro +14 -0
- package/dist/astro-command/index.ts +1 -0
- package/dist/astro-command-input/CommandInput.astro +6 -0
- package/dist/astro-command-input/index.ts +1 -0
- package/dist/astro-content-protection/ContentProtection.astro +104 -0
- package/dist/astro-content-protection/index.ts +1 -0
- package/dist/astro-data-table/DataTable.astro +263 -0
- package/dist/astro-data-table/index.ts +1 -0
- package/dist/astro-date-picker/DatePicker.astro +398 -0
- package/dist/astro-date-picker/index.ts +1 -0
- package/dist/astro-device-frame/DeviceFrame.astro +44 -0
- package/dist/astro-device-frame/index.ts +1 -0
- package/dist/astro-dialog/Dialog.astro +138 -0
- package/dist/astro-dialog/DialogClose.astro +16 -0
- package/dist/astro-dialog/DialogContent.astro +24 -0
- package/dist/astro-dialog/DialogDescription.astro +15 -0
- package/dist/astro-dialog/DialogFooter.astro +14 -0
- package/dist/astro-dialog/DialogHeader.astro +14 -0
- package/dist/astro-dialog/DialogOverlay.astro +17 -0
- package/dist/astro-dialog/DialogTitle.astro +15 -0
- package/dist/astro-dialog/DialogTrigger.astro +18 -0
- package/dist/astro-dialog/index.ts +1 -0
- package/dist/astro-diff-viewer/DiffViewer.astro +371 -0
- package/dist/astro-diff-viewer/index.ts +1 -0
- package/dist/astro-dropdown-menu/DropdownMenu.astro +138 -0
- package/dist/astro-dropdown-menu/DropdownMenuContent.astro +20 -0
- package/dist/astro-dropdown-menu/DropdownMenuItem.astro +21 -0
- package/dist/astro-dropdown-menu/DropdownMenuLabel.astro +14 -0
- package/dist/astro-dropdown-menu/DropdownMenuSeparator.astro +14 -0
- package/dist/astro-dropdown-menu/DropdownMenuTrigger.astro +18 -0
- package/dist/astro-dropdown-menu/index.ts +1 -0
- package/dist/astro-emoji-picker/EmojiPicker.astro +255 -0
- package/dist/astro-emoji-picker/index.ts +1 -0
- package/dist/astro-feedback-dialog/FeedbackDialog.astro +152 -0
- package/dist/astro-feedback-dialog/index.ts +1 -0
- package/dist/astro-file-tree/astro-file-tree.astro +4 -0
- package/dist/astro-file-tree/index.ts +1 -0
- package/dist/astro-file-upload/FileUpload.astro +306 -0
- package/dist/astro-file-upload/index.ts +1 -0
- package/dist/astro-footer/Footer.astro +61 -0
- package/dist/astro-footer/index.ts +1 -0
- package/dist/astro-icon-system/astro-icon-system.astro +4 -0
- package/dist/astro-icon-system/index.ts +1 -0
- package/dist/astro-inline-editor/InlineEditor.astro +169 -0
- package/dist/astro-inline-editor/index.ts +1 -0
- package/dist/astro-input/Input.astro +49 -0
- package/dist/astro-input/index.ts +1 -0
- package/dist/astro-input-group/InputGroup.astro +29 -0
- package/dist/astro-input-group/InputGroupAddon.astro +14 -0
- package/dist/astro-input-group/InputGroupButton.astro +19 -0
- package/dist/astro-input-group/InputGroupText.astro +11 -0
- package/dist/astro-input-group/index.ts +1 -0
- package/dist/astro-install-prompt/InstallPrompt.astro +115 -0
- package/dist/astro-install-prompt/index.ts +1 -0
- package/dist/astro-keyboard-shortcut/KeyboardShortcut.astro +83 -0
- package/dist/astro-keyboard-shortcut/ShortcutBadge.astro +41 -0
- package/dist/astro-keyboard-shortcut/index.ts +1 -0
- package/dist/astro-language-selector/LanguageSelector.astro +247 -0
- package/dist/astro-language-selector/index.ts +1 -0
- package/dist/astro-link-card/LinkCard.astro +17 -0
- package/dist/astro-link-card/index.ts +1 -0
- package/dist/astro-markdown-renderer/MarkdownRenderer.astro +62 -0
- package/dist/astro-markdown-renderer/index.ts +1 -0
- package/dist/astro-mobile-nav/MobileNav.astro +84 -0
- package/dist/astro-mobile-nav/MobileNavContent.astro +29 -0
- package/dist/astro-mobile-nav/MobileNavLink.astro +16 -0
- package/dist/astro-mobile-nav/MobileNavTrigger.astro +57 -0
- package/dist/astro-mobile-nav/index.ts +1 -0
- package/dist/astro-navbar/Navbar.astro +49 -0
- package/dist/astro-navbar/index.ts +1 -0
- package/dist/astro-otp-input/OtpInput.astro +253 -0
- package/dist/astro-otp-input/index.ts +1 -0
- package/dist/astro-pagination/Pagination.astro +3 -0
- package/dist/astro-pagination/index.ts +1 -0
- package/dist/astro-payment/Payment.astro +19 -0
- package/dist/astro-payment/index.ts +1 -0
- package/dist/astro-popover/Popover.astro +87 -0
- package/dist/astro-popover/PopoverClose.astro +16 -0
- package/dist/astro-popover/PopoverContent.astro +23 -0
- package/dist/astro-popover/PopoverTrigger.astro +18 -0
- package/dist/astro-popover/index.ts +1 -0
- package/dist/astro-presence-indicator/PresenceIndicator.astro +26 -0
- package/dist/astro-presence-indicator/index.ts +1 -0
- package/dist/astro-progress-display/BadgeDisplay.astro +33 -0
- package/dist/astro-progress-display/ProgressBar.astro +27 -0
- package/dist/astro-progress-display/StatsGrid.astro +32 -0
- package/dist/astro-progress-display/index.ts +1 -0
- package/dist/astro-radio/RadioGroup.astro +111 -0
- package/dist/astro-radio/RadioItem.astro +36 -0
- package/dist/astro-radio/index.ts +1 -0
- package/dist/astro-reaction-bar/ReactionBar.astro +117 -0
- package/dist/astro-reaction-bar/index.ts +1 -0
- package/dist/astro-resizable-layout/ResizableDivider.astro +27 -0
- package/dist/astro-resizable-layout/ResizableLayout.astro +162 -0
- package/dist/astro-resizable-layout/ResizablePane.astro +28 -0
- package/dist/astro-resizable-layout/index.ts +11 -0
- package/dist/astro-rich-editor/RichEditor.astro +260 -0
- package/dist/astro-rich-editor/index.ts +25 -0
- package/dist/astro-search-bar/SearchBar.astro +140 -0
- package/dist/astro-search-bar/SearchResultItem.astro +16 -0
- package/dist/astro-search-bar/SearchResults.astro +17 -0
- package/dist/astro-search-bar/index.ts +1 -0
- package/dist/astro-select/Select.astro +165 -0
- package/dist/astro-select/SelectContent.astro +19 -0
- package/dist/astro-select/SelectItem.astro +42 -0
- package/dist/astro-select/SelectTrigger.astro +36 -0
- package/dist/astro-select/index.ts +1 -0
- package/dist/astro-sidebar/Sidebar.astro +64 -0
- package/dist/astro-sidebar/index.ts +1 -0
- package/dist/astro-skeleton/Skeleton.astro +39 -0
- package/dist/astro-skeleton/SkeletonText.astro +22 -0
- package/dist/astro-skeleton/index.ts +1 -0
- package/dist/astro-skip-to-content/SkipToContent.astro +3 -0
- package/dist/astro-skip-to-content/index.ts +1 -0
- package/dist/astro-slide-viewer/SlideViewer.astro +231 -0
- package/dist/astro-slide-viewer/index.ts +1 -0
- package/dist/astro-slider/index.ts +1 -0
- package/dist/astro-status-indicator/StatusIndicator.astro +31 -0
- package/dist/astro-status-indicator/index.ts +1 -0
- package/dist/astro-steps/Steps.astro +3 -0
- package/dist/astro-steps/index.ts +1 -0
- package/dist/astro-switch/Switch.astro +89 -0
- package/dist/astro-switch/index.ts +1 -0
- package/dist/astro-table-of-contents/TableOfContents.astro +53 -0
- package/dist/astro-table-of-contents/index.ts +1 -0
- package/dist/astro-tabs/Tabs.astro +96 -0
- package/dist/astro-tabs/TabsContent.astro +20 -0
- package/dist/astro-tabs/TabsList.astro +16 -0
- package/dist/astro-tabs/TabsTrigger.astro +24 -0
- package/dist/astro-tabs/index.ts +1 -0
- package/dist/astro-textarea/Textarea.astro +51 -0
- package/dist/astro-textarea/index.ts +1 -0
- package/dist/astro-theme/ThemeScript.astro +13 -0
- package/dist/astro-theme/ThemeToggle.astro +279 -0
- package/dist/astro-theme/index.ts +1 -0
- package/dist/astro-thread-view/ThreadView.astro +159 -0
- package/dist/astro-thread-view/index.ts +1 -0
- package/dist/astro-toast/Toast.astro +49 -0
- package/dist/astro-toast/Toaster.astro +142 -0
- package/dist/astro-toast/index.ts +1 -0
- package/dist/astro-tooltip/Tooltip.astro +95 -0
- package/dist/astro-tooltip/TooltipContent.astro +22 -0
- package/dist/astro-tooltip/TooltipTrigger.astro +16 -0
- package/dist/astro-tooltip/index.ts +1 -0
- package/dist/astro-version-selector/VersionSelector.astro +174 -0
- package/dist/astro-version-selector/index.ts +1 -0
- package/dist/astro-video-player/VideoPlayer.astro +153 -0
- package/dist/astro-video-player/index.ts +1 -0
- package/dist/index.ts +77 -0
- package/dist/shared/a11y.ts +33 -0
- package/dist/shared/aria.ts +30 -0
- package/dist/shared/cn.ts +35 -0
- package/dist/shared/cva.ts +79 -0
- package/dist/shared/engine-adapter.ts +10 -0
- package/dist/shared/focus-trap.ts +123 -0
- package/dist/shared/index.ts +60 -0
- package/dist/shared/keyboard.ts +36 -0
- package/dist/shared/live-region.ts +90 -0
- package/dist/shared/motion.ts +15 -0
- package/dist/shared/skip-link.ts +35 -0
- package/dist/shared/state-machine.ts +57 -0
- package/dist/shared/tokens.ts +16 -0
- package/dist/shared/types.ts +45 -0
- package/dist/shared/variants.ts +17 -0
- package/package.json +22 -20
- package/src/index.ts +0 -92
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
import {
|
|
3
|
+
createBreadcrumbs,
|
|
4
|
+
breadcrumbsVariants,
|
|
5
|
+
breadcrumbItemVariants,
|
|
6
|
+
breadcrumbSeparatorStyles,
|
|
7
|
+
type BreadcrumbItem,
|
|
8
|
+
} from '@refraction-ui/breadcrumbs'
|
|
9
|
+
import { cn } from '../shared/index.ts'
|
|
10
|
+
|
|
11
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
12
|
+
pathname?: string
|
|
13
|
+
items?: BreadcrumbItem[]
|
|
14
|
+
labels?: Record<string, string>
|
|
15
|
+
separator?: string
|
|
16
|
+
maxItems?: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { pathname, items, labels, separator, maxItems, class: className, ...props } = Astro.props
|
|
20
|
+
const api = createBreadcrumbs({ pathname, items, labels, separator, maxItems })
|
|
21
|
+
const classes = cn(breadcrumbsVariants(), className)
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
<nav class={classes} {...api.ariaProps} {...props}>
|
|
25
|
+
<ol class="flex items-center gap-1.5">
|
|
26
|
+
{api.items.map((item, index) => {
|
|
27
|
+
const isLast = api.isLast(index)
|
|
28
|
+
return (
|
|
29
|
+
<li class="flex items-center gap-1.5">
|
|
30
|
+
{index > 0 && (
|
|
31
|
+
<span class={breadcrumbSeparatorStyles} aria-hidden="true">
|
|
32
|
+
{api.separator}
|
|
33
|
+
</span>
|
|
34
|
+
)}
|
|
35
|
+
{item.href && !isLast ? (
|
|
36
|
+
<a
|
|
37
|
+
href={item.href}
|
|
38
|
+
class={breadcrumbItemVariants({ active: 'false' })}
|
|
39
|
+
>
|
|
40
|
+
{item.label}
|
|
41
|
+
</a>
|
|
42
|
+
) : (
|
|
43
|
+
<span
|
|
44
|
+
class={breadcrumbItemVariants({
|
|
45
|
+
active: isLast ? 'true' : 'false',
|
|
46
|
+
})}
|
|
47
|
+
{...api.itemAriaProps(index)}
|
|
48
|
+
>
|
|
49
|
+
{item.label}
|
|
50
|
+
</span>
|
|
51
|
+
)}
|
|
52
|
+
</li>
|
|
53
|
+
)
|
|
54
|
+
})}
|
|
55
|
+
</ol>
|
|
56
|
+
</nav>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
import {
|
|
3
|
+
createButton,
|
|
4
|
+
buttonVariants,
|
|
5
|
+
getButtonType,
|
|
6
|
+
type ButtonVariant,
|
|
7
|
+
type ButtonSize,
|
|
8
|
+
} from '@refraction-ui/button'
|
|
9
|
+
import { cn } from '../shared/index.ts'
|
|
10
|
+
|
|
11
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
12
|
+
variant?: ButtonVariant
|
|
13
|
+
size?: ButtonSize
|
|
14
|
+
loading?: boolean
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { variant, size, loading, disabled, class: className, ...props } = Astro.props
|
|
19
|
+
const api = createButton({ variant, size, disabled, loading, type: props.type as string })
|
|
20
|
+
const classes = cn(buttonVariants({ variant, size }), className)
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
<button
|
|
24
|
+
type={getButtonType({ type: props.type as string }) as any}
|
|
25
|
+
class={classes}
|
|
26
|
+
disabled={disabled || loading}
|
|
27
|
+
{...api.ariaProps}
|
|
28
|
+
{...api.dataAttributes}
|
|
29
|
+
{...props}
|
|
30
|
+
>
|
|
31
|
+
{loading && (
|
|
32
|
+
<svg
|
|
33
|
+
class="animate-spin h-4 w-4"
|
|
34
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
35
|
+
fill="none"
|
|
36
|
+
viewBox="0 0 24 24"
|
|
37
|
+
aria-hidden="true"
|
|
38
|
+
>
|
|
39
|
+
<circle
|
|
40
|
+
class="opacity-25"
|
|
41
|
+
cx="12"
|
|
42
|
+
cy="12"
|
|
43
|
+
r="10"
|
|
44
|
+
stroke="currentColor"
|
|
45
|
+
stroke-width="4"
|
|
46
|
+
/>
|
|
47
|
+
<path
|
|
48
|
+
class="opacity-75"
|
|
49
|
+
fill="currentColor"
|
|
50
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
51
|
+
/>
|
|
52
|
+
</svg>
|
|
53
|
+
)}
|
|
54
|
+
<slot />
|
|
55
|
+
</button>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
---
|
|
2
|
+
import {
|
|
3
|
+
createCalendar,
|
|
4
|
+
calendarVariants,
|
|
5
|
+
dayVariants,
|
|
6
|
+
type CalendarDay,
|
|
7
|
+
} from '@refraction-ui/calendar'
|
|
8
|
+
import { cn } from '../shared/index.ts'
|
|
9
|
+
|
|
10
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
11
|
+
/** Selected date (ISO string or Date-compatible value) */
|
|
12
|
+
value?: string
|
|
13
|
+
/** Minimum selectable date (ISO string) */
|
|
14
|
+
minDate?: string
|
|
15
|
+
/** Maximum selectable date (ISO string) */
|
|
16
|
+
maxDate?: string
|
|
17
|
+
/** Disabled date ISO strings */
|
|
18
|
+
disabledDates?: string[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const { value, minDate, maxDate, disabledDates = [], class: className, ...props } = Astro.props
|
|
22
|
+
|
|
23
|
+
const parsedValue = value ? new Date(value) : undefined
|
|
24
|
+
const parsedMin = minDate ? new Date(minDate) : undefined
|
|
25
|
+
const parsedMax = maxDate ? new Date(maxDate) : undefined
|
|
26
|
+
const parsedDisabled = disabledDates.map((d: string) => new Date(d))
|
|
27
|
+
|
|
28
|
+
const api = createCalendar({
|
|
29
|
+
value: parsedValue,
|
|
30
|
+
month: parsedValue ?? new Date(),
|
|
31
|
+
minDate: parsedMin,
|
|
32
|
+
maxDate: parsedMax,
|
|
33
|
+
disabledDates: parsedDisabled,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const MONTH_NAMES = [
|
|
37
|
+
'January', 'February', 'March', 'April', 'May', 'June',
|
|
38
|
+
'July', 'August', 'September', 'October', 'November', 'December',
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
const DAY_HEADERS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
|
|
42
|
+
|
|
43
|
+
function getDayState(day: CalendarDay): 'selected' | 'today' | 'disabled' | 'outside' | 'default' {
|
|
44
|
+
if (day.isDisabled) return 'disabled'
|
|
45
|
+
if (day.isSelected) return 'selected'
|
|
46
|
+
if (!day.isCurrentMonth) return 'outside'
|
|
47
|
+
if (day.isToday) return 'today'
|
|
48
|
+
return 'default'
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const monthLabel = `${MONTH_NAMES[api.state.currentMonth.getMonth()]} ${api.state.currentMonth.getFullYear()}`
|
|
52
|
+
const currentYear = api.state.currentMonth.getFullYear()
|
|
53
|
+
const currentMonthIndex = api.state.currentMonth.getMonth()
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
<div
|
|
57
|
+
data-rfr-calendar
|
|
58
|
+
data-rfr-calendar-year={currentYear}
|
|
59
|
+
data-rfr-calendar-month={currentMonthIndex}
|
|
60
|
+
data-rfr-calendar-selected={value || ''}
|
|
61
|
+
data-rfr-calendar-min={minDate || ''}
|
|
62
|
+
data-rfr-calendar-max={maxDate || ''}
|
|
63
|
+
data-rfr-calendar-disabled-dates={JSON.stringify(disabledDates)}
|
|
64
|
+
class={cn(calendarVariants(), className)}
|
|
65
|
+
role="grid"
|
|
66
|
+
aria-labelledby={api.ids.label}
|
|
67
|
+
{...props}
|
|
68
|
+
>
|
|
69
|
+
<!-- Header: prev, month label, next -->
|
|
70
|
+
<div class="flex items-center justify-between mb-2">
|
|
71
|
+
<button
|
|
72
|
+
type="button"
|
|
73
|
+
aria-label="Previous month"
|
|
74
|
+
data-rfr-calendar-prev
|
|
75
|
+
class="inline-flex items-center justify-center h-7 w-7 rounded-md hover:bg-accent"
|
|
76
|
+
>‹</button>
|
|
77
|
+
<div
|
|
78
|
+
id={api.ids.label}
|
|
79
|
+
data-rfr-calendar-label
|
|
80
|
+
class="text-sm font-medium"
|
|
81
|
+
aria-live="polite"
|
|
82
|
+
>{monthLabel}</div>
|
|
83
|
+
<button
|
|
84
|
+
type="button"
|
|
85
|
+
aria-label="Next month"
|
|
86
|
+
data-rfr-calendar-next
|
|
87
|
+
class="inline-flex items-center justify-center h-7 w-7 rounded-md hover:bg-accent"
|
|
88
|
+
>›</button>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<!-- Day-of-week headers -->
|
|
92
|
+
<div class="grid grid-cols-7 gap-1 mb-1" role="row">
|
|
93
|
+
{DAY_HEADERS.map((d) => (
|
|
94
|
+
<div
|
|
95
|
+
class="text-center text-xs font-medium text-muted-foreground h-9 flex items-center justify-center"
|
|
96
|
+
role="columnheader"
|
|
97
|
+
aria-label={d}
|
|
98
|
+
>{d}</div>
|
|
99
|
+
))}
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<!-- Day grid -->
|
|
103
|
+
<div class="grid grid-cols-7 gap-1" role="rowgroup" data-rfr-calendar-grid>
|
|
104
|
+
{api.days.map((day) => {
|
|
105
|
+
const state = getDayState(day)
|
|
106
|
+
const ariaProps = api.getDayAriaProps(day)
|
|
107
|
+
return (
|
|
108
|
+
<button
|
|
109
|
+
type="button"
|
|
110
|
+
class={dayVariants({ state })}
|
|
111
|
+
disabled={day.isDisabled}
|
|
112
|
+
data-rfr-calendar-day
|
|
113
|
+
data-date={day.date.toISOString()}
|
|
114
|
+
data-current-month={day.isCurrentMonth ? '' : undefined}
|
|
115
|
+
role={ariaProps.role as string}
|
|
116
|
+
aria-selected={ariaProps['aria-selected'] as boolean}
|
|
117
|
+
aria-disabled={ariaProps['aria-disabled'] as boolean}
|
|
118
|
+
aria-current={ariaProps['aria-current'] as any}
|
|
119
|
+
aria-label={ariaProps['aria-label'] as string}
|
|
120
|
+
>{day.date.getDate()}</button>
|
|
121
|
+
)
|
|
122
|
+
})}
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
<script>
|
|
127
|
+
const MONTH_NAMES = [
|
|
128
|
+
'January', 'February', 'March', 'April', 'May', 'June',
|
|
129
|
+
'July', 'August', 'September', 'October', 'November', 'December',
|
|
130
|
+
]
|
|
131
|
+
const DAY_NAMES = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
|
|
132
|
+
const DAY_VARIANT_DEFAULT = 'inline-flex items-center justify-center rounded-md text-sm h-9 w-9 hover:bg-accent hover:text-accent-foreground'
|
|
133
|
+
const DAY_VARIANT_SELECTED = 'inline-flex items-center justify-center rounded-md text-sm h-9 w-9 bg-primary text-primary-foreground hover:bg-primary/90'
|
|
134
|
+
const DAY_VARIANT_TODAY = 'inline-flex items-center justify-center rounded-md text-sm h-9 w-9 bg-accent text-accent-foreground'
|
|
135
|
+
const DAY_VARIANT_DISABLED = 'inline-flex items-center justify-center rounded-md text-sm h-9 w-9 text-muted-foreground opacity-50 cursor-not-allowed'
|
|
136
|
+
const DAY_VARIANT_OUTSIDE = 'inline-flex items-center justify-center rounded-md text-sm h-9 w-9 text-muted-foreground opacity-50'
|
|
137
|
+
|
|
138
|
+
function isSameDay(a: Date, b: Date): boolean {
|
|
139
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function isDateDisabled(date: Date, minDate: Date | null, maxDate: Date | null, disabledDates: Date[]): boolean {
|
|
143
|
+
if (minDate) {
|
|
144
|
+
const startOfMin = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate())
|
|
145
|
+
if (date < startOfMin) return true
|
|
146
|
+
}
|
|
147
|
+
if (maxDate) {
|
|
148
|
+
const endOfMax = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999)
|
|
149
|
+
if (date > endOfMax) return true
|
|
150
|
+
}
|
|
151
|
+
return disabledDates.some((d) => isSameDay(d, date))
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function renderGrid(root: HTMLElement) {
|
|
155
|
+
const year = parseInt(root.getAttribute('data-rfr-calendar-year') || '0', 10)
|
|
156
|
+
const month = parseInt(root.getAttribute('data-rfr-calendar-month') || '0', 10)
|
|
157
|
+
const selectedStr = root.getAttribute('data-rfr-calendar-selected') || ''
|
|
158
|
+
const minStr = root.getAttribute('data-rfr-calendar-min') || ''
|
|
159
|
+
const maxStr = root.getAttribute('data-rfr-calendar-max') || ''
|
|
160
|
+
const disabledStr = root.getAttribute('data-rfr-calendar-disabled-dates') || '[]'
|
|
161
|
+
|
|
162
|
+
const selectedDate = selectedStr ? new Date(selectedStr) : null
|
|
163
|
+
const minDate = minStr ? new Date(minStr) : null
|
|
164
|
+
const maxDate = maxStr ? new Date(maxStr) : null
|
|
165
|
+
let disabledDates: Date[] = []
|
|
166
|
+
try { disabledDates = JSON.parse(disabledStr).map((s: string) => new Date(s)) } catch {}
|
|
167
|
+
|
|
168
|
+
const today = new Date()
|
|
169
|
+
|
|
170
|
+
// Update label
|
|
171
|
+
const label = root.querySelector<HTMLElement>('[data-rfr-calendar-label]')
|
|
172
|
+
if (label) label.textContent = `${MONTH_NAMES[month]} ${year}`
|
|
173
|
+
|
|
174
|
+
// Build 42-cell grid
|
|
175
|
+
const first = new Date(year, month, 1)
|
|
176
|
+
const startDow = first.getDay()
|
|
177
|
+
const gridStart = new Date(year, month, 1 - startDow)
|
|
178
|
+
|
|
179
|
+
const grid = root.querySelector<HTMLElement>('[data-rfr-calendar-grid]')
|
|
180
|
+
if (!grid) return
|
|
181
|
+
|
|
182
|
+
grid.innerHTML = ''
|
|
183
|
+
|
|
184
|
+
for (let i = 0; i < 42; i++) {
|
|
185
|
+
const date = new Date(gridStart.getFullYear(), gridStart.getMonth(), gridStart.getDate() + i)
|
|
186
|
+
const isToday = isSameDay(date, today)
|
|
187
|
+
const isSelected = selectedDate ? isSameDay(date, selectedDate) : false
|
|
188
|
+
const isCurrentMonth = date.getMonth() === month
|
|
189
|
+
const isDisabled = isDateDisabled(date, minDate, maxDate, disabledDates)
|
|
190
|
+
|
|
191
|
+
let variant = DAY_VARIANT_DEFAULT
|
|
192
|
+
if (isDisabled) variant = DAY_VARIANT_DISABLED
|
|
193
|
+
else if (isSelected) variant = DAY_VARIANT_SELECTED
|
|
194
|
+
else if (!isCurrentMonth) variant = DAY_VARIANT_OUTSIDE
|
|
195
|
+
else if (isToday) variant = DAY_VARIANT_TODAY
|
|
196
|
+
|
|
197
|
+
const btn = document.createElement('button')
|
|
198
|
+
btn.type = 'button'
|
|
199
|
+
btn.className = variant
|
|
200
|
+
btn.disabled = isDisabled
|
|
201
|
+
btn.setAttribute('data-rfr-calendar-day', '')
|
|
202
|
+
btn.setAttribute('data-date', date.toISOString())
|
|
203
|
+
btn.setAttribute('role', 'gridcell')
|
|
204
|
+
btn.setAttribute('aria-selected', String(isSelected))
|
|
205
|
+
btn.setAttribute('aria-disabled', String(isDisabled))
|
|
206
|
+
if (isToday) btn.setAttribute('aria-current', 'date')
|
|
207
|
+
btn.setAttribute('aria-label', `${DAY_NAMES[date.getDay()]}, ${date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' })}`)
|
|
208
|
+
if (isCurrentMonth) btn.setAttribute('data-current-month', '')
|
|
209
|
+
btn.textContent = String(date.getDate())
|
|
210
|
+
grid.appendChild(btn)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function initCalendars() {
|
|
215
|
+
document.querySelectorAll<HTMLElement>('[data-rfr-calendar]').forEach((root) => {
|
|
216
|
+
if (root.hasAttribute('data-rfr-calendar-init')) return
|
|
217
|
+
root.setAttribute('data-rfr-calendar-init', '')
|
|
218
|
+
|
|
219
|
+
// Prev month
|
|
220
|
+
root.querySelector('[data-rfr-calendar-prev]')?.addEventListener('click', () => {
|
|
221
|
+
const year = parseInt(root.getAttribute('data-rfr-calendar-year') || '0', 10)
|
|
222
|
+
const month = parseInt(root.getAttribute('data-rfr-calendar-month') || '0', 10)
|
|
223
|
+
const prev = new Date(year, month - 1, 1)
|
|
224
|
+
root.setAttribute('data-rfr-calendar-year', String(prev.getFullYear()))
|
|
225
|
+
root.setAttribute('data-rfr-calendar-month', String(prev.getMonth()))
|
|
226
|
+
renderGrid(root)
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
// Next month
|
|
230
|
+
root.querySelector('[data-rfr-calendar-next]')?.addEventListener('click', () => {
|
|
231
|
+
const year = parseInt(root.getAttribute('data-rfr-calendar-year') || '0', 10)
|
|
232
|
+
const month = parseInt(root.getAttribute('data-rfr-calendar-month') || '0', 10)
|
|
233
|
+
const next = new Date(year, month + 1, 1)
|
|
234
|
+
root.setAttribute('data-rfr-calendar-year', String(next.getFullYear()))
|
|
235
|
+
root.setAttribute('data-rfr-calendar-month', String(next.getMonth()))
|
|
236
|
+
renderGrid(root)
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
// Day click (delegated)
|
|
240
|
+
root.querySelector('[data-rfr-calendar-grid]')?.addEventListener('click', (e) => {
|
|
241
|
+
const btn = (e.target as HTMLElement).closest<HTMLButtonElement>('[data-rfr-calendar-day]')
|
|
242
|
+
if (!btn || btn.disabled) return
|
|
243
|
+
const dateStr = btn.getAttribute('data-date')
|
|
244
|
+
if (!dateStr) return
|
|
245
|
+
|
|
246
|
+
root.setAttribute('data-rfr-calendar-selected', dateStr)
|
|
247
|
+
renderGrid(root)
|
|
248
|
+
|
|
249
|
+
root.dispatchEvent(new CustomEvent('rfr-calendar-select', {
|
|
250
|
+
detail: { date: new Date(dateStr), iso: dateStr },
|
|
251
|
+
bubbles: true,
|
|
252
|
+
}))
|
|
253
|
+
})
|
|
254
|
+
})
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
initCalendars()
|
|
258
|
+
document.addEventListener('astro:after-swap', initCalendars)
|
|
259
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Callout } from './Callout.astro';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { createCard, cardVariants } from '@refraction-ui/card'
|
|
3
|
+
import { cn } from '../shared/index.ts'
|
|
4
|
+
|
|
5
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
6
|
+
padding?: 'none' | 'default' | 'compact'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { padding, class: className, ...props } = Astro.props
|
|
10
|
+
const api = createCard(props)
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<div
|
|
14
|
+
class={cn(cardVariants({ padding }), className)}
|
|
15
|
+
{...api.ariaProps}
|
|
16
|
+
{...api.dataAttributes}
|
|
17
|
+
{...props}
|
|
18
|
+
>
|
|
19
|
+
<slot />
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { createCardContent, cardContentVariants } from '@refraction-ui/card'
|
|
3
|
+
import { cn } from '../shared/index.ts'
|
|
4
|
+
|
|
5
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {}
|
|
6
|
+
|
|
7
|
+
const { class: className, ...props } = Astro.props
|
|
8
|
+
const api = createCardContent()
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<div class={cn(cardContentVariants(), className)} {...api.dataAttributes} {...props}>
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { createCardDescription, cardDescriptionVariants } from '@refraction-ui/card'
|
|
3
|
+
import { cn } from '../shared/index.ts'
|
|
4
|
+
|
|
5
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {}
|
|
6
|
+
|
|
7
|
+
const { class: className, ...props } = Astro.props
|
|
8
|
+
const api = createCardDescription()
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<p class={cn(cardDescriptionVariants(), className)} {...api.dataAttributes} {...props}>
|
|
12
|
+
<slot />
|
|
13
|
+
</p>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { createCardFooter, cardFooterVariants } from '@refraction-ui/card'
|
|
3
|
+
import { cn } from '../shared/index.ts'
|
|
4
|
+
|
|
5
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {}
|
|
6
|
+
|
|
7
|
+
const { class: className, ...props } = Astro.props
|
|
8
|
+
const api = createCardFooter()
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<div class={cn(cardFooterVariants(), className)} {...api.dataAttributes} {...props}>
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { createCardHeader, cardHeaderVariants } from '@refraction-ui/card'
|
|
3
|
+
import { cn } from '../shared/index.ts'
|
|
4
|
+
|
|
5
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {}
|
|
6
|
+
|
|
7
|
+
const { class: className, ...props } = Astro.props
|
|
8
|
+
const api = createCardHeader()
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<div class={cn(cardHeaderVariants(), className)} {...api.dataAttributes} {...props}>
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { createCardTitle, cardTitleVariants } from '@refraction-ui/card'
|
|
3
|
+
import { cn } from '../shared/index.ts'
|
|
4
|
+
|
|
5
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
6
|
+
size?: 'sm' | 'default' | 'lg'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { size, class: className, ...props } = Astro.props
|
|
10
|
+
const api = createCardTitle()
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<h3 class={cn(cardTitleVariants({ size }), className)} {...api.dataAttributes} {...props}>
|
|
14
|
+
<slot />
|
|
15
|
+
</h3>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { createCardGrid } from '@refraction-ui/card-grid'
|
|
3
|
+
import { cn } from '../shared/index.ts'
|
|
4
|
+
|
|
5
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {}
|
|
6
|
+
|
|
7
|
+
const { class: className, ...props } = Astro.props
|
|
8
|
+
const api = createCardGrid(props as any)
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<div
|
|
12
|
+
class={cn(className)}
|
|
13
|
+
{...api.dataAttributes}
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
<slot />
|
|
17
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CardGrid } from './CardGrid.astro'
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
import {
|
|
3
|
+
createButton,
|
|
4
|
+
buttonVariants,
|
|
5
|
+
getButtonType,
|
|
6
|
+
type ButtonVariant,
|
|
7
|
+
type ButtonSize,
|
|
8
|
+
} from '@refraction-ui/button'
|
|
9
|
+
import { cn } from '../shared/index.ts'
|
|
10
|
+
|
|
11
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
12
|
+
variant?: ButtonVariant
|
|
13
|
+
size?: ButtonSize
|
|
14
|
+
loading?: boolean
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { variant, size, loading, disabled, class: className, ...props } = Astro.props
|
|
19
|
+
const api = createButton({ variant, size, disabled, loading, type: props.type as string })
|
|
20
|
+
const classes = cn(buttonVariants({ variant, size }), className)
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
<button
|
|
24
|
+
type={getButtonType({ type: props.type as string }) as any}
|
|
25
|
+
class={classes}
|
|
26
|
+
disabled={disabled || loading}
|
|
27
|
+
{...api.ariaProps}
|
|
28
|
+
{...api.dataAttributes}
|
|
29
|
+
{...props}
|
|
30
|
+
>
|
|
31
|
+
{loading && (
|
|
32
|
+
<svg
|
|
33
|
+
class="animate-spin h-4 w-4"
|
|
34
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
35
|
+
fill="none"
|
|
36
|
+
viewBox="0 0 24 24"
|
|
37
|
+
aria-hidden="true"
|
|
38
|
+
>
|
|
39
|
+
<circle
|
|
40
|
+
class="opacity-25"
|
|
41
|
+
cx="12"
|
|
42
|
+
cy="12"
|
|
43
|
+
r="10"
|
|
44
|
+
stroke="currentColor"
|
|
45
|
+
stroke-width="4"
|
|
46
|
+
/>
|
|
47
|
+
<path
|
|
48
|
+
class="opacity-75"
|
|
49
|
+
fill="currentColor"
|
|
50
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
51
|
+
/>
|
|
52
|
+
</svg>
|
|
53
|
+
)}
|
|
54
|
+
<slot />
|
|
55
|
+
</button>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Bars — bar chart rectangles, server-rendered as SVG <rect> elements.
|
|
4
|
+
* Accepts pre-computed labels and values arrays.
|
|
5
|
+
*/
|
|
6
|
+
import { createBandScale, createLinearScale, computeExtent } from '@refraction-ui/charts'
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
/** Category labels for each bar */
|
|
10
|
+
labels: string[]
|
|
11
|
+
/** Numeric values for each bar */
|
|
12
|
+
values: number[]
|
|
13
|
+
/** Bounded width of the chart area */
|
|
14
|
+
boundedWidth: number
|
|
15
|
+
/** Bounded height of the chart area */
|
|
16
|
+
boundedHeight: number
|
|
17
|
+
/** Fill color (default 'currentColor') */
|
|
18
|
+
fill?: string
|
|
19
|
+
/** Band padding ratio (default 0.1) */
|
|
20
|
+
padding?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
labels,
|
|
25
|
+
values,
|
|
26
|
+
boundedWidth,
|
|
27
|
+
boundedHeight,
|
|
28
|
+
fill = 'currentColor',
|
|
29
|
+
padding = 0.1,
|
|
30
|
+
} = Astro.props
|
|
31
|
+
|
|
32
|
+
const [, maxVal] = computeExtent(values)
|
|
33
|
+
const xScale = createBandScale(labels, [0, boundedWidth], padding)
|
|
34
|
+
const yScale = createLinearScale([0, maxVal], [boundedHeight, 0])
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
<g data-rfr-chart-bars>
|
|
38
|
+
{labels.map((label, i) => {
|
|
39
|
+
const barX = xScale(label)
|
|
40
|
+
const barY = yScale(values[i])
|
|
41
|
+
const barHeight = boundedHeight - barY
|
|
42
|
+
const barWidth = xScale.bandwidth()
|
|
43
|
+
return (
|
|
44
|
+
<rect
|
|
45
|
+
x={barX}
|
|
46
|
+
y={barY}
|
|
47
|
+
width={barWidth}
|
|
48
|
+
height={barHeight}
|
|
49
|
+
fill={fill}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
})}
|
|
53
|
+
</g>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Chart — root SVG container for chart compositions.
|
|
4
|
+
* Provides chart dimensions via data attributes for sub-components.
|
|
5
|
+
*/
|
|
6
|
+
import { combineDimensions, type Margin } from '@refraction-ui/charts'
|
|
7
|
+
|
|
8
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
9
|
+
width?: number
|
|
10
|
+
height?: number
|
|
11
|
+
margin?: Partial<Margin>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { width = 600, height = 400, margin, class: className, ...props } = Astro.props
|
|
15
|
+
|
|
16
|
+
const dimensions = combineDimensions({ width, height, margin })
|
|
17
|
+
const dimensionsJSON = JSON.stringify(dimensions)
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
<svg
|
|
21
|
+
width={width}
|
|
22
|
+
height={height}
|
|
23
|
+
class={className}
|
|
24
|
+
data-rfr-chart
|
|
25
|
+
data-rfr-chart-dimensions={dimensionsJSON}
|
|
26
|
+
{...props}
|
|
27
|
+
>
|
|
28
|
+
<g transform={`translate(${dimensions.margin.left},${dimensions.margin.top})`}>
|
|
29
|
+
<slot />
|
|
30
|
+
</g>
|
|
31
|
+
</svg>
|