@blenx-dev/core 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.
Files changed (172) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/LICENSE +21 -0
  3. package/package.json +49 -0
  4. package/src/DataTable/data-table-column-toggle.tsx +73 -0
  5. package/src/DataTable/data-table-empty.tsx +27 -0
  6. package/src/DataTable/data-table-error.tsx +25 -0
  7. package/src/DataTable/data-table-infinite-loader.tsx +73 -0
  8. package/src/DataTable/data-table-loading.tsx +67 -0
  9. package/src/DataTable/data-table-pagination.tsx +80 -0
  10. package/src/DataTable/data-table-toolbar.tsx +62 -0
  11. package/src/DataTable/data-table.css.ts +420 -0
  12. package/src/DataTable/data-table.tsx +507 -0
  13. package/src/DataTable/index.ts +24 -0
  14. package/src/DataTable/types.ts +169 -0
  15. package/src/DataTable/use-infinite-scroll.ts +67 -0
  16. package/src/components/Accordion/accordion.css.ts +84 -0
  17. package/src/components/Accordion/accordion.tsx +87 -0
  18. package/src/components/Accordion/index.ts +8 -0
  19. package/src/components/Alert/alert.css.ts +29 -0
  20. package/src/components/Alert/alert.tsx +40 -0
  21. package/src/components/Alert/index.ts +1 -0
  22. package/src/components/AlertDialog/alert-dialog.css.ts +62 -0
  23. package/src/components/AlertDialog/alert-dialog.tsx +199 -0
  24. package/src/components/AlertDialog/index.ts +1 -0
  25. package/src/components/AspectRatio/aspect-ratio.css.ts +7 -0
  26. package/src/components/AspectRatio/aspect-ratio.tsx +20 -0
  27. package/src/components/AspectRatio/index.ts +1 -0
  28. package/src/components/Autocomplete/autocomplete.css.ts +167 -0
  29. package/src/components/Autocomplete/autocomplete.tsx +226 -0
  30. package/src/components/Autocomplete/index.ts +1 -0
  31. package/src/components/Avatar/avatar.css.ts +65 -0
  32. package/src/components/Avatar/avatar.tsx +44 -0
  33. package/src/components/Avatar/index.ts +1 -0
  34. package/src/components/Badge/badge.css.ts +180 -0
  35. package/src/components/Badge/badge.tsx +47 -0
  36. package/src/components/Badge/index.ts +1 -0
  37. package/src/components/Box/box.css.ts +5 -0
  38. package/src/components/Box/box.tsx +21 -0
  39. package/src/components/Box/index.ts +1 -0
  40. package/src/components/Breadcrumbs/breadcrumbs.css.ts +72 -0
  41. package/src/components/Breadcrumbs/breadcrumbs.tsx +79 -0
  42. package/src/components/Breadcrumbs/index.ts +9 -0
  43. package/src/components/Button/button.css.ts +200 -0
  44. package/src/components/Button/button.tsx +55 -0
  45. package/src/components/Button/index.ts +1 -0
  46. package/src/components/Calendar/calendar.css.ts +187 -0
  47. package/src/components/Calendar/calendar.tsx +143 -0
  48. package/src/components/Calendar/index.ts +1 -0
  49. package/src/components/Card/card.tsx +32 -0
  50. package/src/components/Card/index.ts +1 -0
  51. package/src/components/Checkbox/checkbox.css.ts +76 -0
  52. package/src/components/Checkbox/checkbox.tsx +94 -0
  53. package/src/components/Checkbox/index.ts +1 -0
  54. package/src/components/CloseButton/close-button.css.ts +11 -0
  55. package/src/components/CloseButton/close-button.tsx +15 -0
  56. package/src/components/CloseButton/index.ts +2 -0
  57. package/src/components/ColorPicker/color-picker.tsx +123 -0
  58. package/src/components/ColorPicker/index.ts +1 -0
  59. package/src/components/ColorSwatch/color-swatch.tsx +21 -0
  60. package/src/components/ColorSwatch/index.ts +1 -0
  61. package/src/components/Combobox/combobox.css.ts +333 -0
  62. package/src/components/Combobox/combobox.tsx +350 -0
  63. package/src/components/Combobox/index.ts +1 -0
  64. package/src/components/Command/command.css.ts +130 -0
  65. package/src/components/Command/command.tsx +413 -0
  66. package/src/components/Command/index.ts +7 -0
  67. package/src/components/Container/container.css.ts +41 -0
  68. package/src/components/Container/container.tsx +25 -0
  69. package/src/components/Container/index.ts +1 -0
  70. package/src/components/CopyButton/copy-button.css.ts +11 -0
  71. package/src/components/CopyButton/copy-button.tsx +45 -0
  72. package/src/components/CopyButton/index.ts +2 -0
  73. package/src/components/DatePicker/date-picker.tsx +75 -0
  74. package/src/components/DatePicker/index.ts +1 -0
  75. package/src/components/Dialog/dialog.css.ts +57 -0
  76. package/src/components/Dialog/dialog.tsx +181 -0
  77. package/src/components/Dialog/index.ts +1 -0
  78. package/src/components/Drawer/drawer.css.ts +404 -0
  79. package/src/components/Drawer/drawer.tsx +573 -0
  80. package/src/components/Drawer/index.ts +1 -0
  81. package/src/components/Field/field.css.ts +35 -0
  82. package/src/components/Field/field.tsx +101 -0
  83. package/src/components/Field/index.ts +1 -0
  84. package/src/components/Grid/grid.css.ts +12 -0
  85. package/src/components/Grid/grid.tsx +32 -0
  86. package/src/components/Grid/index.ts +1 -0
  87. package/src/components/Icon/icon.css.ts +10 -0
  88. package/src/components/Icon/icon.tsx +15 -0
  89. package/src/components/Icon/index.ts +1 -0
  90. package/src/components/IconButton/icon-button.css.ts +6 -0
  91. package/src/components/IconButton/icon-button.tsx +11 -0
  92. package/src/components/IconButton/index.ts +2 -0
  93. package/src/components/Input/index.ts +1 -0
  94. package/src/components/Input/input.css.ts +72 -0
  95. package/src/components/Input/input.tsx +50 -0
  96. package/src/components/InputGroup/index.ts +1 -0
  97. package/src/components/InputGroup/input-group.css.ts +156 -0
  98. package/src/components/InputGroup/input-group.tsx +133 -0
  99. package/src/components/Menu/index.ts +1 -0
  100. package/src/components/Menu/menu.css.ts +121 -0
  101. package/src/components/Menu/menu.tsx +115 -0
  102. package/src/components/OTPField/index.ts +1 -0
  103. package/src/components/OTPField/otp-field.css.ts +54 -0
  104. package/src/components/OTPField/otp-field.tsx +46 -0
  105. package/src/components/Popover/index.ts +1 -0
  106. package/src/components/Popover/popover.css.ts +81 -0
  107. package/src/components/Popover/popover.tsx +113 -0
  108. package/src/components/Progress/index.ts +7 -0
  109. package/src/components/Progress/progress.css.ts +37 -0
  110. package/src/components/Progress/progress.tsx +62 -0
  111. package/src/components/Radio/index.ts +1 -0
  112. package/src/components/Radio/radio.css.ts +72 -0
  113. package/src/components/Radio/radio.tsx +49 -0
  114. package/src/components/ScrollArea/index.ts +1 -0
  115. package/src/components/ScrollArea/scroll-area.css.ts +79 -0
  116. package/src/components/ScrollArea/scroll-area.tsx +96 -0
  117. package/src/components/SegmentedControl/index.ts +1 -0
  118. package/src/components/SegmentedControl/segmented-control.tsx +42 -0
  119. package/src/components/Select/index.ts +1 -0
  120. package/src/components/Select/select.css.ts +182 -0
  121. package/src/components/Select/select.tsx +165 -0
  122. package/src/components/Separator/index.ts +1 -0
  123. package/src/components/Separator/separator.css.ts +59 -0
  124. package/src/components/Separator/separator.tsx +34 -0
  125. package/src/components/Sheet/index.ts +1 -0
  126. package/src/components/Sheet/sheet.css.ts +184 -0
  127. package/src/components/Sheet/sheet.tsx +215 -0
  128. package/src/components/Slider/index.ts +1 -0
  129. package/src/components/Slider/slider.css.ts +81 -0
  130. package/src/components/Slider/slider.tsx +100 -0
  131. package/src/components/Spinner/index.ts +1 -0
  132. package/src/components/Spinner/spinner.css.ts +17 -0
  133. package/src/components/Spinner/spinner.tsx +15 -0
  134. package/src/components/Splitter/index.ts +1 -0
  135. package/src/components/Splitter/splitter.css.ts +69 -0
  136. package/src/components/Splitter/splitter.tsx +521 -0
  137. package/src/components/Stack/index.ts +1 -0
  138. package/src/components/Stack/stack.css.ts +42 -0
  139. package/src/components/Stack/stack.tsx +32 -0
  140. package/src/components/Surface/index.ts +1 -0
  141. package/src/components/Surface/surface.css.ts +40 -0
  142. package/src/components/Surface/surface.tsx +19 -0
  143. package/src/components/Switch/index.ts +1 -0
  144. package/src/components/Switch/switch.css.ts +46 -0
  145. package/src/components/Switch/switch.tsx +25 -0
  146. package/src/components/Table/index.ts +2 -0
  147. package/src/components/Table/table.css.ts +71 -0
  148. package/src/components/Table/table.tsx +117 -0
  149. package/src/components/Tabs/index.ts +1 -0
  150. package/src/components/Tabs/tabs.css.ts +250 -0
  151. package/src/components/Tabs/tabs.tsx +119 -0
  152. package/src/components/Text/index.ts +2 -0
  153. package/src/components/Text/text.css.ts +118 -0
  154. package/src/components/Text/text.tsx +66 -0
  155. package/src/components/Textarea/index.ts +1 -0
  156. package/src/components/Textarea/textarea.css.ts +66 -0
  157. package/src/components/Textarea/textarea.tsx +48 -0
  158. package/src/components/Toggle/index.ts +1 -0
  159. package/src/components/Toggle/toggle.css.ts +91 -0
  160. package/src/components/Toggle/toggle.tsx +44 -0
  161. package/src/components/ToggleGroup/index.ts +1 -0
  162. package/src/components/ToggleGroup/toggle-group.css.ts +77 -0
  163. package/src/components/ToggleGroup/toggle-group.tsx +131 -0
  164. package/src/components/index.ts +54 -0
  165. package/src/index.ts +3 -0
  166. package/src/utils/drawer-styles.css.ts +85 -0
  167. package/src/utils/heights.ts +16 -0
  168. package/src/utils/sprinkles.css.ts +197 -0
  169. package/src/utils/sprinkles.tokens.ts +74 -0
  170. package/src/utils/types.ts +10 -0
  171. package/src/utils/ve-style.utils.ts +51 -0
  172. package/tsconfig.json +10 -0
@@ -0,0 +1,67 @@
1
+ import { type RefObject, useCallback, useEffect, useRef } from "react";
2
+
3
+ interface UseInfiniteScrollOptions {
4
+ /** Whether there are more pages to load */
5
+ hasNextPage: boolean;
6
+ /** Whether a fetch is currently in progress */
7
+ isFetchingNextPage: boolean;
8
+ /** Function to fetch the next page */
9
+ fetchNextPage: () => void;
10
+ /** IntersectionObserver root margin. Default: "200px" */
11
+ rootMargin?: string;
12
+ /** IntersectionObserver threshold. Default: 0 */
13
+ threshold?: number;
14
+ /** If true, the observer is disabled */
15
+ enabled?: boolean;
16
+ }
17
+
18
+ interface UseInfiniteScrollReturn {
19
+ /** Ref to attach to the sentinel element */
20
+ sentinelRef: RefObject<HTMLDivElement | null>;
21
+ }
22
+
23
+ /**
24
+ * Hook to observe a sentinel element and trigger fetchNextPage when visible.
25
+ *
26
+ * Uses IntersectionObserver with a configurable root margin and threshold.
27
+ * Respects hasNextPage, isFetchingNextPage, and enabled state to prevent
28
+ * duplicate requests.
29
+ */
30
+ export function useInfiniteScroll({
31
+ hasNextPage,
32
+ isFetchingNextPage,
33
+ fetchNextPage,
34
+ rootMargin = "200px",
35
+ threshold = 0,
36
+ enabled = true,
37
+ }: UseInfiniteScrollOptions): UseInfiniteScrollReturn {
38
+ const sentinelRef = useRef<HTMLDivElement | null>(null);
39
+
40
+ const handleIntersection = useCallback(
41
+ (entries: IntersectionObserverEntry[]) => {
42
+ const [entry] = entries;
43
+ if (entry?.isIntersecting && hasNextPage && !isFetchingNextPage) {
44
+ fetchNextPage();
45
+ }
46
+ },
47
+ [hasNextPage, isFetchingNextPage, fetchNextPage],
48
+ );
49
+
50
+ useEffect(() => {
51
+ const sentinel = sentinelRef.current;
52
+ if (!sentinel || !enabled) return;
53
+
54
+ const observer = new IntersectionObserver(handleIntersection, {
55
+ rootMargin,
56
+ threshold,
57
+ });
58
+
59
+ observer.observe(sentinel);
60
+
61
+ return () => {
62
+ observer.disconnect();
63
+ };
64
+ }, [enabled, handleIntersection, rootMargin, threshold]);
65
+
66
+ return { sentinelRef };
67
+ }
@@ -0,0 +1,84 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { semanticVars, tokenVars } from "@blenx-dev/theme/contract";
3
+
4
+ export const root = style({
5
+ display: "flex",
6
+ flexDirection: "column",
7
+ width: "100%",
8
+ boxSizing: "border-box",
9
+ });
10
+
11
+ export const rootVertical = style({
12
+ flexDirection: "column",
13
+ });
14
+
15
+ export const item = style({
16
+ borderBottomWidth: tokenVars.borderWidth.thin,
17
+ borderBottomStyle: "solid",
18
+ borderBottomColor: semanticVars.border.subtle,
19
+ });
20
+
21
+ export const itemDisabled = style({
22
+ opacity: 0.5,
23
+ });
24
+
25
+ export const trigger = style({
26
+ display: "flex",
27
+ alignItems: "center",
28
+ gap: tokenVars.spacing.xxs,
29
+ width: "100%",
30
+ paddingTop: tokenVars.spacing.xs,
31
+ paddingBottom: tokenVars.spacing.xs,
32
+ paddingLeft: tokenVars.spacing.xxs,
33
+ paddingRight: tokenVars.spacing.xxs,
34
+ boxSizing: "border-box",
35
+ fontSize: tokenVars.fontSize.sm,
36
+ lineHeight: tokenVars.lineHeight.normal,
37
+ fontWeight: tokenVars.fontWeight.medium,
38
+ color: semanticVars.text.primary,
39
+ backgroundColor: "transparent",
40
+ border: "none",
41
+ borderRadius: tokenVars.borderRadius.default,
42
+ appearance: "none",
43
+ fontFamily: "inherit",
44
+ textAlign: "left",
45
+ borderWidth: 0,
46
+ cursor: "pointer",
47
+ WebkitTapHighlightColor: "transparent",
48
+ outline: "none",
49
+ outlineOffset: "2px",
50
+ transitionProperty: "background-color",
51
+ transitionDuration: tokenVars.duration.fast,
52
+ transitionTimingFunction: tokenVars.easing.standard,
53
+ selectors: {
54
+ "&:hover": {
55
+ backgroundColor: semanticVars.background.subtle,
56
+ },
57
+ "&:focus-visible": {
58
+ outline: `2px solid ${semanticVars.focus.ring}`,
59
+ },
60
+ },
61
+ });
62
+
63
+ export const triggerIcon = style({
64
+ flexShrink: 0,
65
+ color: semanticVars.text.secondary,
66
+ transform: "rotate(0deg)",
67
+ transitionProperty: "transform",
68
+ transitionDuration: tokenVars.duration.normal,
69
+ transitionTimingFunction: tokenVars.easing.standard,
70
+ selectors: {
71
+ "[data-panel-open] &": {
72
+ transform: "rotate(180deg)",
73
+ },
74
+ },
75
+ });
76
+
77
+ export const panel = style({
78
+ overflow: "hidden",
79
+ boxSizing: "border-box",
80
+ transitionProperty: "grid-template-rows, opacity",
81
+ padding: tokenVars.spacing.xs,
82
+ transitionDuration: tokenVars.duration.normal,
83
+ transitionTimingFunction: tokenVars.easing.standard,
84
+ });
@@ -0,0 +1,87 @@
1
+ "use client";
2
+
3
+ import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion";
4
+ import { CaretDownIcon } from "@phosphor-icons/react";
5
+ import clsx from "clsx";
6
+ import {
7
+ root,
8
+ rootVertical,
9
+ item,
10
+ itemDisabled,
11
+ trigger,
12
+ triggerIcon,
13
+ panel,
14
+ } from "./accordion.css";
15
+
16
+ type AccordionRootProps = AccordionPrimitive.Root.Props;
17
+
18
+ function AccordionRoot({ children, className, ...props }: AccordionRootProps) {
19
+ return (
20
+ <AccordionPrimitive.Root
21
+ className={(state) => clsx(root, state.orientation === "vertical" && rootVertical, className)}
22
+ {...props}
23
+ >
24
+ {children}
25
+ </AccordionPrimitive.Root>
26
+ );
27
+ }
28
+
29
+ type AccordionItemProps = AccordionPrimitive.Item.Props;
30
+
31
+ function AccordionItem({ children, className, ...props }: AccordionItemProps) {
32
+ return (
33
+ <AccordionPrimitive.Item
34
+ className={(state) => clsx(item, state.disabled && itemDisabled, className)}
35
+ {...props}
36
+ >
37
+ {children}
38
+ </AccordionPrimitive.Item>
39
+ );
40
+ }
41
+
42
+ type AccordionHeaderProps = AccordionPrimitive.Header.Props;
43
+
44
+ function AccordionHeader({ children, className, ...props }: AccordionHeaderProps) {
45
+ return (
46
+ <AccordionPrimitive.Header className={className} {...props}>
47
+ {children}
48
+ </AccordionPrimitive.Header>
49
+ );
50
+ }
51
+
52
+ type AccordionTriggerProps = AccordionPrimitive.Trigger.Props;
53
+
54
+ function AccordionTrigger({ children, className, ...props }: AccordionTriggerProps) {
55
+ return (
56
+ <AccordionPrimitive.Trigger className={clsx(trigger, className)} {...props}>
57
+ <CaretDownIcon size={16} className={triggerIcon} />
58
+ {children}
59
+ </AccordionPrimitive.Trigger>
60
+ );
61
+ }
62
+
63
+ type AccordionPanelProps = AccordionPrimitive.Panel.Props;
64
+
65
+ function AccordionPanel({ children, className, ...props }: AccordionPanelProps) {
66
+ return (
67
+ <AccordionPrimitive.Panel className={clsx(panel, className)} {...props}>
68
+ {children}
69
+ </AccordionPrimitive.Panel>
70
+ );
71
+ }
72
+
73
+ export { AccordionPanel, AccordionTrigger, AccordionHeader, AccordionItem, AccordionRoot };
74
+ export type {
75
+ AccordionPanelProps,
76
+ AccordionTriggerProps,
77
+ AccordionHeaderProps,
78
+ AccordionItemProps,
79
+ AccordionRootProps,
80
+ };
81
+ export const Accordion = {
82
+ Root: AccordionRoot,
83
+ Item: AccordionItem,
84
+ Header: AccordionHeader,
85
+ Trigger: AccordionTrigger,
86
+ Panel: AccordionPanel,
87
+ };
@@ -0,0 +1,8 @@
1
+ export {
2
+ Accordion,
3
+ AccordionHeader,
4
+ AccordionItem,
5
+ AccordionPanel,
6
+ AccordionRoot,
7
+ AccordionTrigger,
8
+ } from "./accordion";
@@ -0,0 +1,29 @@
1
+ import { semanticVars } from "@blenx-dev/theme/contract";
2
+ import { recipe } from "@vanilla-extract/recipes";
3
+
4
+ export const alertVariants = recipe({
5
+ variants: {
6
+ variant: {
7
+ info: {
8
+ backgroundColor: semanticVars.status.infoBg,
9
+ color: semanticVars.status.info.active,
10
+ borderColor: semanticVars.status.info.default,
11
+ },
12
+ success: {
13
+ backgroundColor: semanticVars.status.successBg,
14
+ color: semanticVars.status.success.active,
15
+ borderColor: semanticVars.status.success.default,
16
+ },
17
+ warning: {
18
+ backgroundColor: semanticVars.status.warningBg,
19
+ color: semanticVars.status.warning.active,
20
+ borderColor: semanticVars.status.warning.default,
21
+ },
22
+ error: {
23
+ backgroundColor: semanticVars.status.dangerBg,
24
+ color: semanticVars.status.danger.default,
25
+ borderColor: semanticVars.status.danger.default,
26
+ },
27
+ },
28
+ },
29
+ });
@@ -0,0 +1,40 @@
1
+ import type { ReactNode } from "react";
2
+ import { Text } from "../Text";
3
+ import type { RecipeVariants } from "@vanilla-extract/recipes";
4
+ import { alertVariants } from "./alert.css";
5
+ import clsx from "clsx";
6
+ import { HStack, VStack } from "../Stack/stack";
7
+ import { Box } from "../Box/box";
8
+
9
+ type Props = RecipeVariants<typeof alertVariants> & {
10
+ icon?: ReactNode;
11
+ title?: string;
12
+ description?: string;
13
+ children?: ReactNode;
14
+ style?: React.CSSProperties;
15
+ className?: string;
16
+ };
17
+
18
+ function Alert({ variant = "info", icon, title, description, children, className }: Props) {
19
+ return (
20
+ <HStack
21
+ align={icon ? "start" : "center"}
22
+ gap="xs"
23
+ p="sm"
24
+ className={clsx(alertVariants({ variant }), className)}
25
+ >
26
+ <Box p={"xxs"}>{icon}</Box>
27
+ <VStack gap="xxs">
28
+ {title ? (
29
+ <Text variant="h6" padding="none" margin="none" color={variant}>
30
+ {title}
31
+ </Text>
32
+ ) : null}
33
+ {description ? <span style={{ color: "currentColor" }}>{description}</span> : null}
34
+ {children}
35
+ </VStack>
36
+ </HStack>
37
+ );
38
+ }
39
+
40
+ export { Alert };
@@ -0,0 +1 @@
1
+ export { Alert } from "./alert";
@@ -0,0 +1,62 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { semanticVars, tokenVars } from "@blenx-dev/theme/contract";
3
+
4
+ export const header = style({
5
+ display: "flex",
6
+ flexDirection: "column",
7
+ gap: tokenVars.spacing.xxs,
8
+ padding: tokenVars.spacing.md,
9
+ boxSizing: "border-box",
10
+ paddingBottom: tokenVars.spacing.xs,
11
+ });
12
+
13
+ export const footer = style({
14
+ display: "flex",
15
+ flexDirection: "column-reverse",
16
+ gap: tokenVars.spacing.sm,
17
+ paddingLeft: tokenVars.spacing.md,
18
+ paddingRight: tokenVars.spacing.md,
19
+ boxSizing: "border-box",
20
+ "@media": {
21
+ "(min-width: 640px)": {
22
+ flexDirection: "row",
23
+ justifyContent: "flex-end",
24
+ borderBottomLeftRadius: "calc(16px - 1px)",
25
+ borderBottomRightRadius: "calc(16px - 1px)",
26
+ },
27
+ },
28
+ });
29
+
30
+ export const footerDefault = style({
31
+ borderTopWidth: tokenVars.borderWidth.thin,
32
+ borderTopStyle: "solid",
33
+ borderTopColor: semanticVars.border.subtle,
34
+ backgroundColor: semanticVars.background.subtle,
35
+ paddingTop: tokenVars.spacing.md,
36
+ paddingBottom: tokenVars.spacing.md,
37
+ });
38
+
39
+ export const footerBare = style({
40
+ paddingTop: tokenVars.spacing.md,
41
+ paddingBottom: tokenVars.spacing.lg,
42
+ });
43
+
44
+ export const title = style({
45
+ fontSize: tokenVars.fontSize.lg,
46
+ lineHeight: tokenVars.lineHeight.tight,
47
+ fontWeight: tokenVars.fontWeight.semibold,
48
+ color: semanticVars.text.primary,
49
+ });
50
+
51
+ export const description = style({
52
+ fontSize: tokenVars.fontSize.sm,
53
+ lineHeight: tokenVars.lineHeight.normal,
54
+ color: semanticVars.text.secondary,
55
+ });
56
+
57
+ export const panel = style({
58
+ boxSizing: "border-box",
59
+ padding: tokenVars.spacing.md,
60
+ paddingTop: tokenVars.spacing.xxs,
61
+ paddingBottom: tokenVars.spacing.xxs,
62
+ });
@@ -0,0 +1,199 @@
1
+ "use client";
2
+
3
+ import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog";
4
+ import { useRender } from "@base-ui/react/use-render";
5
+ import clsx from "clsx";
6
+ import type React from "react";
7
+ import type { _BaseDivProps } from "../../utils/types";
8
+ import { ScrollArea } from "../ScrollArea/scroll-area";
9
+ import {
10
+ header,
11
+ footer,
12
+ footerDefault,
13
+ footerBare,
14
+ title,
15
+ description,
16
+ panel,
17
+ } from "./alert-dialog.css";
18
+ import { CloseButton } from "../CloseButton";
19
+ import { Box } from "../Box/box";
20
+ import {
21
+ backdrop,
22
+ popup,
23
+ viewport,
24
+ viewportShellBottomStickOnMobile,
25
+ popupBottomStickOnMobile,
26
+ } from "../../utils/drawer-styles.css";
27
+
28
+ function AlertDialog(props: AlertDialogPrimitive.Root.Props): React.ReactElement {
29
+ return <AlertDialogPrimitive.Root {...props} />;
30
+ }
31
+
32
+ function AlertDialogTrigger(props: AlertDialogPrimitive.Trigger.Props): React.ReactElement {
33
+ return <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />;
34
+ }
35
+
36
+ function AlertDialogClose(props: AlertDialogPrimitive.Close.Props): React.ReactElement {
37
+ return <AlertDialogPrimitive.Close data-slot="alert-dialog-close" {...props} />;
38
+ }
39
+
40
+ function AlertDialogPortal(props: AlertDialogPrimitive.Portal.Props): React.ReactElement {
41
+ return <AlertDialogPrimitive.Portal {...props} />;
42
+ }
43
+
44
+ function AlertDialogBackdrop(props: AlertDialogPrimitive.Backdrop.Props): React.ReactElement {
45
+ return (
46
+ <AlertDialogPrimitive.Backdrop
47
+ className={backdrop}
48
+ data-slot="alert-dialog-backdrop"
49
+ {...props}
50
+ />
51
+ );
52
+ }
53
+
54
+ function AlertDialogViewport(
55
+ props: AlertDialogPrimitive.Viewport.Props & {
56
+ bottomStickOnMobile?: boolean;
57
+ },
58
+ ): React.ReactElement {
59
+ const { bottomStickOnMobile, className, ...restProps } = props;
60
+ return (
61
+ <AlertDialogPrimitive.Viewport
62
+ className={clsx(viewport, bottomStickOnMobile && viewportShellBottomStickOnMobile, className)}
63
+ data-slot="alert-dialog-viewport"
64
+ {...restProps}
65
+ />
66
+ );
67
+ }
68
+
69
+ type AlertDialogPopupProps = AlertDialogPrimitive.Popup.Props & {
70
+ showCloseButton?: boolean;
71
+ closeProps?: AlertDialogPrimitive.Close.Props;
72
+ bottomStickOnMobile?: boolean;
73
+ };
74
+
75
+ function AlertDialogPopup({
76
+ children,
77
+ bottomStickOnMobile = true,
78
+ showCloseButton = true,
79
+ closeProps,
80
+ className,
81
+ ...props
82
+ }: AlertDialogPopupProps): React.ReactElement {
83
+ return (
84
+ <AlertDialogPortal>
85
+ <AlertDialogBackdrop />
86
+ <AlertDialogViewport bottomStickOnMobile={bottomStickOnMobile}>
87
+ <AlertDialogPrimitive.Popup
88
+ className={clsx(popup, bottomStickOnMobile && popupBottomStickOnMobile, className)}
89
+ data-slot="alert-dialog-popup"
90
+ {...props}
91
+ >
92
+ {showCloseButton && (
93
+ <Box position="absolute" right="xs" top="xs">
94
+ <AlertDialogPrimitive.Close
95
+ aria-label="Close"
96
+ render={<CloseButton variant="ghost" />}
97
+ {...closeProps}
98
+ />
99
+ </Box>
100
+ )}
101
+ {children}
102
+ </AlertDialogPrimitive.Popup>
103
+ </AlertDialogViewport>
104
+ </AlertDialogPortal>
105
+ );
106
+ }
107
+
108
+ type HeaderProps = _BaseDivProps;
109
+
110
+ function AlertDialogHeader({ className, render, ...props }: HeaderProps): React.ReactElement {
111
+ return useRender({
112
+ defaultTagName: "div",
113
+ props: {
114
+ className: clsx(header, className),
115
+ "data-slot": "alert-dialog-header",
116
+ ...props,
117
+ } as never,
118
+ render,
119
+ });
120
+ }
121
+
122
+ type FooterProps = _BaseDivProps & {
123
+ variant?: "default" | "bare";
124
+ };
125
+
126
+ function AlertDialogFooter({
127
+ className,
128
+ variant = "default",
129
+ render,
130
+ ...props
131
+ }: FooterProps): React.ReactElement {
132
+ return useRender({
133
+ defaultTagName: "div",
134
+ props: {
135
+ className: clsx(
136
+ footer,
137
+ variant === "default" && footerDefault,
138
+ variant === "bare" && footerBare,
139
+ className,
140
+ ),
141
+ "data-slot": "alert-dialog-footer",
142
+ ...props,
143
+ } as never,
144
+ render,
145
+ });
146
+ }
147
+
148
+ function AlertDialogTitle(props: AlertDialogPrimitive.Title.Props): React.ReactElement {
149
+ return <AlertDialogPrimitive.Title className={title} data-slot="alert-dialog-title" {...props} />;
150
+ }
151
+
152
+ function AlertDialogDescription(props: AlertDialogPrimitive.Description.Props): React.ReactElement {
153
+ return (
154
+ <AlertDialogPrimitive.Description
155
+ className={description}
156
+ data-slot="alert-dialog-description"
157
+ {...props}
158
+ />
159
+ );
160
+ }
161
+
162
+ function AlertDialogPanel({
163
+ scrollFade = true,
164
+ render,
165
+ className,
166
+ ...props
167
+ }: _BaseDivProps & {
168
+ scrollFade?: boolean;
169
+ }): React.ReactElement {
170
+ return (
171
+ <ScrollArea scrollFade={scrollFade} height="fit-content">
172
+ {useRender({
173
+ defaultTagName: "div",
174
+ props: {
175
+ className: clsx(panel, className),
176
+ "data-slot": "alert-dialog-panel",
177
+ ...props,
178
+ } as never,
179
+ render,
180
+ })}
181
+ </ScrollArea>
182
+ );
183
+ }
184
+
185
+ export type { AlertDialogPopupProps };
186
+ export {
187
+ AlertDialog,
188
+ AlertDialogBackdrop,
189
+ AlertDialogClose,
190
+ AlertDialogDescription,
191
+ AlertDialogFooter,
192
+ AlertDialogHeader,
193
+ AlertDialogPanel,
194
+ AlertDialogPopup,
195
+ AlertDialogPortal,
196
+ AlertDialogTitle,
197
+ AlertDialogTrigger,
198
+ AlertDialogViewport,
199
+ };
@@ -0,0 +1 @@
1
+ export * from "./alert-dialog";
@@ -0,0 +1,7 @@
1
+ import { style } from "@vanilla-extract/css";
2
+
3
+ export const root = style({
4
+ position: "relative",
5
+ overflow: "hidden",
6
+ maxWidth: "100%",
7
+ });
@@ -0,0 +1,20 @@
1
+ "use client";
2
+
3
+ import clsx from "clsx";
4
+ import type { BoxProps } from "../Box/box";
5
+ import { Box } from "../Box/box";
6
+ import * as styles from "./aspect-ratio.css";
7
+
8
+ type AspectRatioProps = BoxProps & {
9
+ ratio?: number;
10
+ };
11
+
12
+ export function AspectRatio({ ratio = 16 / 9, className, style, ...boxProps }: AspectRatioProps) {
13
+ return (
14
+ <Box
15
+ className={clsx(styles.root, className)}
16
+ style={{ aspectRatio: `${ratio}`, ...style }}
17
+ {...boxProps}
18
+ />
19
+ );
20
+ }
@@ -0,0 +1 @@
1
+ export * from "./aspect-ratio";