@primitiv-ui/react 0.1.0 → 0.1.1

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 (162) hide show
  1. package/package.json +1 -1
  2. package/src/AccessibleIcon/AccessibleIcon.tsx +5 -2
  3. package/src/AccessibleIcon/__tests__/AccessibleIcon.test.tsx +1 -1
  4. package/src/Accordion/Accordion.tsx +11 -12
  5. package/src/Accordion/AccordionContext.ts +1 -1
  6. package/src/Accordion/__tests__/Accordion.reading-direction.test.tsx +1 -1
  7. package/src/Accordion/hooks/useAccordionItem.ts +1 -1
  8. package/src/Accordion/hooks/useAccordionRoot.ts +1 -1
  9. package/src/Accordion/hooks/useAccordionTrigger.ts +2 -2
  10. package/src/Alert/Alert.tsx +8 -2
  11. package/src/Alert/__tests__/Alert.test.tsx +1 -1
  12. package/src/Avatar/Avatar.tsx +14 -5
  13. package/src/Avatar/AvatarContext.ts +10 -6
  14. package/src/Breadcrumb/Breadcrumb.tsx +21 -7
  15. package/src/Button/Button.tsx +4 -2
  16. package/src/Carousel/Carousel.tsx +21 -14
  17. package/src/Carousel/CarouselContext.ts +3 -2
  18. package/src/Carousel/__tests__/Carousel.asChild.test.tsx +1 -1
  19. package/src/Carousel/__tests__/Carousel.auto-play.test.tsx +1 -1
  20. package/src/Carousel/__tests__/Carousel.basic-rendering.test.tsx +1 -1
  21. package/src/Carousel/__tests__/Carousel.controlled-state.test.tsx +1 -1
  22. package/src/Carousel/__tests__/Carousel.error-handling.test.tsx +1 -1
  23. package/src/Carousel/__tests__/Carousel.ids.test.tsx +1 -1
  24. package/src/Carousel/__tests__/Carousel.imperative-api.test.tsx +2 -2
  25. package/src/Carousel/__tests__/Carousel.indicators.test.tsx +1 -1
  26. package/src/Carousel/__tests__/Carousel.intersection-observer.test.tsx +2 -2
  27. package/src/Carousel/__tests__/Carousel.keyboard-navigation.test.tsx +1 -1
  28. package/src/Carousel/__tests__/Carousel.play-pause.test.tsx +1 -1
  29. package/src/Carousel/__tests__/Carousel.prev-next.test.tsx +1 -1
  30. package/src/Carousel/__tests__/Carousel.reduced-motion.test.tsx +1 -1
  31. package/src/Carousel/__tests__/Carousel.refresh-progress.test.tsx +2 -2
  32. package/src/Carousel/__tests__/Carousel.scroll-snap-change.test.tsx +1 -1
  33. package/src/Carousel/__tests__/Carousel.scroll-sync.test.tsx +1 -1
  34. package/src/Carousel/__tests__/Carousel.slides-per-move.test.tsx +1 -1
  35. package/src/Carousel/__tests__/Carousel.slides-per-page.test.tsx +1 -1
  36. package/src/Carousel/__tests__/Carousel.touch-interaction.test.tsx +1 -1
  37. package/src/Carousel/__tests__/Carousel.transition-modes.test.tsx +1 -1
  38. package/src/Carousel/__tests__/Carousel.translations.test.tsx +1 -1
  39. package/src/Carousel/__tests__/Carousel.uncontrolled-state.test.tsx +1 -1
  40. package/src/Checkbox/Checkbox.tsx +5 -4
  41. package/src/Checkbox/CheckboxContext.ts +1 -1
  42. package/src/Checkbox/hooks/useCheckboxRoot.ts +1 -1
  43. package/src/CheckboxCard/CheckboxCard.tsx +5 -4
  44. package/src/CheckboxCard/CheckboxCardContext.ts +10 -5
  45. package/src/CheckboxCard/hooks/useCheckboxCardRoot.ts +1 -1
  46. package/src/Collapsible/Collapsible.tsx +22 -21
  47. package/src/Collapsible/CollapsibleContext.ts +1 -1
  48. package/src/Collapsible/hooks/useCollapsibleRoot.ts +1 -1
  49. package/src/Collapsible/hooks/useCollapsibleTrigger.ts +1 -1
  50. package/src/ContextMenu/ContextMenu.tsx +20 -19
  51. package/src/ContextMenu/ContextMenuContext.ts +2 -2
  52. package/src/ContextMenu/ContextMenuSubContext.ts +1 -1
  53. package/src/ContextMenu/__tests__/ContextMenu.reading-direction.test.tsx +1 -1
  54. package/src/ContextMenu/types.ts +1 -1
  55. package/src/DirectionProvider/DirectionProvider.tsx +6 -1
  56. package/src/DirectionProvider/__tests__/DirectionProvider.test.tsx +1 -1
  57. package/src/Divider/Divider.tsx +3 -1
  58. package/src/Divider/__tests__/Divider.test.tsx +1 -1
  59. package/src/Dropdown/Dropdown.tsx +20 -19
  60. package/src/Dropdown/DropdownContext.ts +2 -2
  61. package/src/Dropdown/DropdownSubContext.ts +1 -1
  62. package/src/Dropdown/__tests__/Dropdown.reading-direction.test.tsx +1 -1
  63. package/src/Dropdown/hooks/useDropdownContent.ts +1 -1
  64. package/src/Dropdown/hooks/useDropdownItem.ts +1 -1
  65. package/src/Dropdown/hooks/useDropdownRoot.ts +2 -2
  66. package/src/Dropdown/hooks/useDropdownTrigger.ts +1 -1
  67. package/src/Dropdown/types.ts +1 -1
  68. package/src/EmptyState/EmptyState.tsx +8 -6
  69. package/src/EmptyState/__tests__/EmptyState.Actions.test.tsx +1 -1
  70. package/src/EmptyState/__tests__/EmptyState.Description.test.tsx +1 -1
  71. package/src/EmptyState/__tests__/EmptyState.Media.test.tsx +1 -1
  72. package/src/EmptyState/__tests__/EmptyState.Root.test.tsx +1 -1
  73. package/src/EmptyState/__tests__/EmptyState.Title.test.tsx +1 -1
  74. package/src/Field/Field.tsx +11 -6
  75. package/src/Field/FieldContext.ts +1 -1
  76. package/src/Fieldset/Fieldset.tsx +11 -2
  77. package/src/Input/Input.tsx +5 -3
  78. package/src/Input/__tests__/Input.field-integration.test.tsx +1 -1
  79. package/src/InputGroup/InputGroup.tsx +6 -4
  80. package/src/MillerColumns/MillerColumns.tsx +9 -8
  81. package/src/MillerColumns/MillerColumnsContext.ts +1 -1
  82. package/src/MillerColumns/hooks/useMillerColumnsItem.ts +2 -2
  83. package/src/MillerColumns/hooks/useMillerColumnsRoot.ts +0 -0
  84. package/src/MillerColumns/useMillerColumnsSelection.ts +1 -1
  85. package/src/Modal/Modal.tsx +24 -11
  86. package/src/Modal/ModalContext.ts +10 -6
  87. package/src/Modal/hooks/useModalRoot.ts +1 -1
  88. package/src/Modal/hooks/useModalTrigger.ts +2 -2
  89. package/src/Portal/Portal.tsx +2 -1
  90. package/src/Progress/Progress.tsx +5 -4
  91. package/src/Progress/ProgressContext.ts +11 -6
  92. package/src/RadioCard/RadioCard.tsx +8 -7
  93. package/src/RadioCard/RadioCardContext.ts +10 -5
  94. package/src/RadioCard/RadioCardItemContext.ts +10 -5
  95. package/src/RadioCard/__tests__/RadioCard.reading-direction.test.tsx +1 -1
  96. package/src/RadioCard/hooks/useRadioCardRoot.ts +1 -1
  97. package/src/RadioGroup/RadioGroup.tsx +8 -7
  98. package/src/RadioGroup/RadioGroupContext.ts +1 -1
  99. package/src/RadioGroup/RadioGroupItemContext.ts +1 -1
  100. package/src/RadioGroup/__tests__/RadioGroup.reading-direction.test.tsx +1 -1
  101. package/src/RadioGroup/hooks/useRadioGroupRoot.ts +1 -1
  102. package/src/Select/Select.tsx +10 -6
  103. package/src/Select/__tests__/Select.field-integration.test.tsx +1 -1
  104. package/src/SkipNav/SkipNav.tsx +7 -2
  105. package/src/SkipNav/__tests__/SkipNav.ids.test.tsx +1 -1
  106. package/src/Slider/Slider.tsx +17 -7
  107. package/src/Slider/SliderContext.ts +10 -6
  108. package/src/Slider/__tests__/Slider.reading-direction.test.tsx +1 -1
  109. package/src/Slider/hooks/useSliderRoot.ts +1 -1
  110. package/src/Status/Status.tsx +8 -2
  111. package/src/Status/__tests__/Status.test.tsx +1 -1
  112. package/src/Switch/Switch.tsx +9 -4
  113. package/src/Switch/SwitchContext.ts +9 -5
  114. package/src/Switch/hooks/useSwitchRoot.ts +1 -1
  115. package/src/Table/Table.tsx +15 -9
  116. package/src/Table/__tests__/Table.Body.test.tsx +1 -1
  117. package/src/Table/__tests__/Table.Caption.test.tsx +1 -1
  118. package/src/Table/__tests__/Table.Cell.test.tsx +1 -1
  119. package/src/Table/__tests__/Table.Footer.test.tsx +1 -1
  120. package/src/Table/__tests__/Table.Head.test.tsx +1 -1
  121. package/src/Table/__tests__/Table.Header.test.tsx +1 -1
  122. package/src/Table/__tests__/Table.Root.test.tsx +1 -1
  123. package/src/Table/__tests__/Table.Row.test.tsx +1 -1
  124. package/src/Table/__tests__/Table.ScrollArea.test.tsx +1 -1
  125. package/src/Tabs/Tabs.tsx +24 -9
  126. package/src/Tabs/TabsContext.ts +9 -6
  127. package/src/Tabs/__tests__/Tabs.asChild.test.tsx +1 -1
  128. package/src/Tabs/__tests__/Tabs.basic-rendering.test.tsx +1 -1
  129. package/src/Tabs/__tests__/Tabs.change-event-callbacks.test.tsx +1 -1
  130. package/src/Tabs/__tests__/Tabs.controlled-state.test.tsx +1 -1
  131. package/src/Tabs/__tests__/Tabs.error-handling.test.tsx +1 -1
  132. package/src/Tabs/__tests__/Tabs.imperative-api.test.tsx +1 -1
  133. package/src/Tabs/__tests__/Tabs.keyboard-interaction.test.tsx +1 -1
  134. package/src/Tabs/__tests__/Tabs.lazy-mount.test.tsx +1 -1
  135. package/src/Tabs/__tests__/Tabs.mouse-interaction.test.tsx +1 -1
  136. package/src/Tabs/__tests__/Tabs.reading-direction.test.tsx +1 -1
  137. package/src/Tabs/__tests__/Tabs.uncontrolled-state.test.tsx +1 -1
  138. package/src/Tabs/hooks/useTabsContent.ts +1 -1
  139. package/src/Tabs/hooks/useTabsRoot.ts +1 -1
  140. package/src/Tabs/hooks/useTabsTrigger.ts +1 -1
  141. package/src/Tabs/utils.ts +1 -1
  142. package/src/Textarea/Textarea.tsx +5 -3
  143. package/src/Textarea/__tests__/Textarea.field-integration.test.tsx +1 -1
  144. package/src/Toggle/Toggle.tsx +10 -4
  145. package/src/ToggleGroup/ToggleGroup.tsx +14 -10
  146. package/src/ToggleGroup/ToggleGroupContext.ts +1 -1
  147. package/src/ToggleGroup/__tests__/ToggleGroup.reading-direction.test.tsx +1 -1
  148. package/src/ToggleGroup/hooks/useToggleGroupRoot.ts +1 -1
  149. package/src/Tooltip/Tooltip.tsx +23 -10
  150. package/src/Tooltip/TooltipContext.ts +1 -1
  151. package/src/Tooltip/hooks/useTooltipContent.ts +1 -1
  152. package/src/Tooltip/hooks/useTooltipRoot.ts +1 -1
  153. package/src/Tooltip/hooks/useTooltipTrigger.ts +1 -1
  154. package/src/Tree/Tree.tsx +12 -11
  155. package/src/Tree/TreeContext.ts +1 -1
  156. package/src/Tree/__tests__/Tree.selection-path.test.tsx +2 -2
  157. package/src/Tree/hooks/useTreeItemKeyboard.ts +1 -1
  158. package/src/Tree/hooks/useTreeRoot.ts +1 -1
  159. package/src/VisuallyHidden/VisuallyHidden.tsx +3 -2
  160. package/src/VisuallyHidden/__tests__/VisuallyHidden.test.tsx +1 -1
  161. package/src/index.ts +38 -38
  162. package/src/utils/createStrictContext.ts +9 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primitiv-ui/react",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,5 +1,5 @@
1
1
  import { Children, cloneElement, ReactElement } from "react";
2
- import { VisuallyHidden } from "../VisuallyHidden";
2
+ import { VisuallyHidden } from "../VisuallyHidden/index.ts";
3
3
  import { AccessibleIconProps } from "./types";
4
4
 
5
5
  type DecorativeIconProps = { "aria-hidden": string; focusable: string };
@@ -26,7 +26,10 @@ type DecorativeIconProps = { "aria-hidden": string; focusable: string };
26
26
  * </button>
27
27
  * ```
28
28
  */
29
- export function AccessibleIcon({ label, children }: AccessibleIconProps) {
29
+ export function AccessibleIcon({
30
+ label,
31
+ children,
32
+ }: AccessibleIconProps): ReactElement {
30
33
  const icon = Children.only(children) as ReactElement<DecorativeIconProps>;
31
34
 
32
35
  return (
@@ -1,4 +1,4 @@
1
- import { AccessibleIcon } from "..";
1
+ import { AccessibleIcon } from "../index.ts";
2
2
  import { render, screen } from "@testing-library/react";
3
3
 
4
4
  describe("AccessibleIcon component", () => {
@@ -1,7 +1,8 @@
1
1
  import { Ref, useEffect } from "react";
2
+ import type { ReactElement } from "react";
2
3
 
3
- import { useDirection } from "../DirectionProvider";
4
- import { Slot } from "../Slot";
4
+ import { useDirection } from "../DirectionProvider/index.ts";
5
+ import { Slot } from "../Slot/index.ts";
5
6
 
6
7
  import type {
7
8
  AccordionRootProps,
@@ -21,7 +22,7 @@ import {
21
22
  useAccordionItem,
22
23
  useAccordionItemContext,
23
24
  useAccordionRoot,
24
- } from "./hooks";
25
+ } from "./hooks/index.ts";
25
26
  import { useAccordionTrigger } from "./hooks/useAccordionTrigger";
26
27
 
27
28
  /**
@@ -78,7 +79,7 @@ export function AccordionRoot({
78
79
  orientation = "vertical",
79
80
  dir,
80
81
  ...rest
81
- }: AccordionRootProps) {
82
+ }: AccordionRootProps): ReactElement {
82
83
  const resolvedDir = dir ?? useDirection();
83
84
  const { contextValue } = useAccordionRoot(
84
85
  controlledValue,
@@ -124,7 +125,7 @@ export function AccordionItem({
124
125
  children,
125
126
  value,
126
127
  ...rest
127
- }: AccordionItemProps) {
128
+ }: AccordionItemProps): ReactElement {
128
129
  const { contextValue } = useAccordionItem(value);
129
130
 
130
131
  return (
@@ -156,7 +157,7 @@ export function AccordionHeader({
156
157
  children,
157
158
  level = 3,
158
159
  ...rest
159
- }: AccordionHeaderProps) {
160
+ }: AccordionHeaderProps): ReactElement {
160
161
  useAccordionHeaderContext();
161
162
  const HeadingTag: HeadingTag = `h${level}`;
162
163
 
@@ -229,16 +230,14 @@ AccordionHeader.displayName = "AccordionHeader";
229
230
  * </Accordion.Trigger>
230
231
  * ```
231
232
  */
232
- export function AccordionTrigger<
233
- T extends HTMLElement = HTMLButtonElement,
234
- >({
233
+ export function AccordionTrigger<T extends HTMLElement = HTMLButtonElement>({
235
234
  ref,
236
235
  children,
237
236
  onClick,
238
237
  disabled = false,
239
238
  asChild = false,
240
239
  ...rest
241
- }: AccordionTriggerProps<T>) {
240
+ }: AccordionTriggerProps<T>): ReactElement {
242
241
  // Cast the external ref to match the internal button ref's element type —
243
242
  // RefObject<T> is invariant in React's types, but at runtime the callback
244
243
  // receives whatever DOM element is actually rendered (button or asChild).
@@ -306,7 +305,7 @@ export function AccordionContent({
306
305
  children,
307
306
  forceMount = false,
308
307
  ...rest
309
- }: AccordionContentProps) {
308
+ }: AccordionContentProps): ReactElement {
310
309
  const { panelId, buttonId, itemId, isExpanded } = useAccordionItemContext();
311
310
  const { registerPanel, unregisterPanel } = useAccordionContext();
312
311
 
@@ -373,7 +372,7 @@ AccordionContent.displayName = "AccordionContent";
373
372
  export function AccordionTriggerIcon({
374
373
  children,
375
374
  ...rest
376
- }: AccordionTriggerIconProps) {
375
+ }: AccordionTriggerIconProps): ReactElement {
377
376
  const { isExpanded } = useAccordionItemContext();
378
377
 
379
378
  return (
@@ -1,4 +1,4 @@
1
- import { createStrictContext } from "../utils";
1
+ import { createStrictContext } from "../utils/index.ts";
2
2
  import { AccordionContextValue, AccordionItemContextValue } from "./types";
3
3
 
4
4
  export const [AccordionContext, useAccordionContext] =
@@ -1,7 +1,7 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
3
 
4
- import { DirectionProvider } from "../../DirectionProvider";
4
+ import { DirectionProvider } from "../../DirectionProvider/index.ts";
5
5
  import { Accordion } from "../Accordion";
6
6
 
7
7
  describe("Accordion reading direction tests", () => {
@@ -1,6 +1,6 @@
1
1
  import { useId, useMemo } from "react";
2
2
 
3
- import { deriveId } from "../../utils";
3
+ import { deriveId } from "../../utils/index.ts";
4
4
 
5
5
  import { useAccordionContext } from "./useAccordionContext";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { useRef, useMemo, useCallback, useId, useEffect } from "react";
2
2
 
3
- import { useCollection, useControllableState } from "../../hooks";
3
+ import { useCollection, useControllableState } from "../../hooks/index.ts";
4
4
 
5
5
  import type { AccordionReadingDirection } from "../types";
6
6
 
@@ -1,7 +1,7 @@
1
1
  import { useMemo, useRef, useEffect, MouseEvent, KeyboardEvent } from "react";
2
2
 
3
- import { useRovingTabindex } from "../../hooks";
4
- import { composeRefs } from "../../Slot";
3
+ import { useRovingTabindex } from "../../hooks/index.ts";
4
+ import { composeRefs } from "../../Slot/index.ts";
5
5
 
6
6
  import { AccordionTriggerProps } from "../types";
7
7
 
@@ -1,4 +1,6 @@
1
- import { Slot } from "../Slot";
1
+ import type { ReactElement } from "react";
2
+
3
+ import { Slot } from "../Slot/index.ts";
2
4
  import { AlertProps } from "./types";
3
5
 
4
6
  /**
@@ -30,7 +32,11 @@ import { AlertProps } from "./types";
30
32
  * </Alert>
31
33
  * ```
32
34
  */
33
- export function Alert({ asChild = false, children, ...rest }: AlertProps) {
35
+ export function Alert({
36
+ asChild = false,
37
+ children,
38
+ ...rest
39
+ }: AlertProps): ReactElement {
34
40
  const rootProps = { role: "alert", ...rest };
35
41
 
36
42
  if (asChild) {
@@ -1,4 +1,4 @@
1
- import { Alert } from "..";
1
+ import { Alert } from "../index.ts";
2
2
  import { render, screen } from "@testing-library/react";
3
3
 
4
4
  describe("Alert component", () => {
@@ -1,9 +1,10 @@
1
1
  import { useEffect, useMemo, useState } from "react";
2
+ import type { ReactElement } from "react";
2
3
 
3
- import { Slot } from "../Slot";
4
+ import { Slot } from "../Slot/index.ts";
4
5
 
5
6
  import { AvatarContext } from "./AvatarContext";
6
- import { useAvatarContext, useAvatarImage } from "./hooks";
7
+ import { useAvatarContext, useAvatarImage } from "./hooks/index.ts";
7
8
  import {
8
9
  AvatarFallbackProps,
9
10
  AvatarImageLoadingStatus,
@@ -22,7 +23,11 @@ import {
22
23
  * **`asChild` prop.** Pass `asChild` to render the consumer's own element as
23
24
  * the container, with the `data-status` hook merged in.
24
25
  */
25
- function AvatarRoot({ asChild = false, children, ...rest }: AvatarRootProps) {
26
+ function AvatarRoot({
27
+ asChild = false,
28
+ children,
29
+ ...rest
30
+ }: AvatarRootProps): ReactElement {
26
31
  const [status, setStatus] = useState<AvatarImageLoadingStatus>("idle");
27
32
 
28
33
  const contextValue = useMemo(() => ({ status, setStatus }), [status]);
@@ -55,7 +60,11 @@ AvatarRoot.displayName = "AvatarRoot";
55
60
  *
56
61
  * @throws if rendered outside an `Avatar.Root`.
57
62
  */
58
- function AvatarImage({ asChild = false, children, ...rest }: AvatarImageProps) {
63
+ function AvatarImage({
64
+ asChild = false,
65
+ children,
66
+ ...rest
67
+ }: AvatarImageProps): ReactElement {
59
68
  const { status, setStatus } = useAvatarContext();
60
69
  const { ref, onLoad, onError } = useAvatarImage(setStatus);
61
70
 
@@ -97,7 +106,7 @@ function AvatarFallback({
97
106
  asChild = false,
98
107
  children,
99
108
  ...rest
100
- }: AvatarFallbackProps) {
109
+ }: AvatarFallbackProps): ReactElement | null {
101
110
  const { status } = useAvatarContext();
102
111
  const [delayElapsed, setDelayElapsed] = useState(delayMs === undefined);
103
112
 
@@ -1,4 +1,5 @@
1
- import { createStrictContext } from "../utils";
1
+ import type { Context } from "react";
2
+ import { createStrictContext } from "../utils/index.ts";
2
3
 
3
4
  import { AvatarImageLoadingStatus } from "./types";
4
5
 
@@ -13,8 +14,11 @@ export type AvatarContextValue = {
13
14
  setStatus: (status: AvatarImageLoadingStatus) => void;
14
15
  };
15
16
 
16
- export const [AvatarContext, useAvatarContext] =
17
- createStrictContext<AvatarContextValue>(
18
- "Avatar.Image and Avatar.Fallback must be rendered inside an <Avatar.Root>.",
19
- "AvatarContext",
20
- );
17
+ const avatarContextPair = createStrictContext<AvatarContextValue>(
18
+ "Avatar.Image and Avatar.Fallback must be rendered inside an <Avatar.Root>.",
19
+ "AvatarContext",
20
+ );
21
+
22
+ export const AvatarContext: Context<AvatarContextValue | null> =
23
+ avatarContextPair[0];
24
+ export const useAvatarContext: () => AvatarContextValue = avatarContextPair[1];
@@ -1,4 +1,6 @@
1
- import { Slot } from "../Slot";
1
+ import type { ReactElement } from "react";
2
+
3
+ import { Slot } from "../Slot/index.ts";
2
4
 
3
5
  import {
4
6
  BreadcrumbItemProps,
@@ -24,7 +26,10 @@ import {
24
26
  * </Breadcrumb.Root>
25
27
  * ```
26
28
  */
27
- function BreadcrumbRoot({ children, ...rest }: BreadcrumbRootProps) {
29
+ function BreadcrumbRoot({
30
+ children,
31
+ ...rest
32
+ }: BreadcrumbRootProps): ReactElement {
28
33
  return (
29
34
  <nav aria-label="Breadcrumb" {...rest}>
30
35
  {children}
@@ -51,7 +56,10 @@ BreadcrumbRoot.displayName = "BreadcrumbRoot";
51
56
  * </Breadcrumb.List>
52
57
  * ```
53
58
  */
54
- function BreadcrumbList({ children, ...rest }: BreadcrumbListProps) {
59
+ function BreadcrumbList({
60
+ children,
61
+ ...rest
62
+ }: BreadcrumbListProps): ReactElement {
55
63
  return <ol {...rest}>{children}</ol>;
56
64
  }
57
65
 
@@ -70,7 +78,10 @@ BreadcrumbList.displayName = "BreadcrumbList";
70
78
  * </Breadcrumb.Item>
71
79
  * ```
72
80
  */
73
- function BreadcrumbItem({ children, ...rest }: BreadcrumbItemProps) {
81
+ function BreadcrumbItem({
82
+ children,
83
+ ...rest
84
+ }: BreadcrumbItemProps): ReactElement {
74
85
  return <li {...rest}>{children}</li>;
75
86
  }
76
87
 
@@ -102,7 +113,7 @@ function BreadcrumbLink({
102
113
  children,
103
114
  asChild = false,
104
115
  ...rest
105
- }: BreadcrumbLinkProps) {
116
+ }: BreadcrumbLinkProps): ReactElement {
106
117
  if (asChild) {
107
118
  return <Slot {...rest}>{children}</Slot>;
108
119
  }
@@ -125,7 +136,10 @@ BreadcrumbLink.displayName = "BreadcrumbLink";
125
136
  * </Breadcrumb.Item>
126
137
  * ```
127
138
  */
128
- function BreadcrumbPage({ children, ...rest }: BreadcrumbPageProps) {
139
+ function BreadcrumbPage({
140
+ children,
141
+ ...rest
142
+ }: BreadcrumbPageProps): ReactElement {
129
143
  return (
130
144
  <span aria-current="page" {...rest}>
131
145
  {children}
@@ -160,7 +174,7 @@ BreadcrumbPage.displayName = "BreadcrumbPage";
160
174
  function BreadcrumbSeparator({
161
175
  children = "/",
162
176
  ...rest
163
- }: BreadcrumbSeparatorProps) {
177
+ }: BreadcrumbSeparatorProps): ReactElement {
164
178
  return (
165
179
  <li role="presentation" aria-hidden="true" {...rest}>
166
180
  {children}
@@ -1,4 +1,6 @@
1
- import { Slot } from "../Slot";
1
+ import type { ReactElement } from "react";
2
+
3
+ import { Slot } from "../Slot/index.ts";
2
4
  import { ButtonProps } from "./types";
3
5
 
4
6
  /**
@@ -73,7 +75,7 @@ export function Button({
73
75
  children,
74
76
  ref,
75
77
  ...rest
76
- }: ButtonProps) {
78
+ }: ButtonProps): ReactElement {
77
79
  const rootProps = {
78
80
  ...rest,
79
81
  ref,
@@ -1,13 +1,19 @@
1
1
  import { forwardRef, MouseEvent, useCallback } from "react";
2
+ import type {
3
+ ForwardRefExoticComponent,
4
+ PropsWithoutRef,
5
+ ReactElement,
6
+ RefAttributes,
7
+ } from "react";
2
8
 
3
- import { Slot } from "../Slot";
9
+ import { Slot } from "../Slot/index.ts";
4
10
  import { CarouselProvider } from "./CarouselContext";
5
11
  import {
6
12
  useCarouselContext,
7
13
  useCarouselRoot,
8
14
  useCarouselSlide,
9
15
  useCarouselViewport,
10
- } from "./hooks";
16
+ } from "./hooks/index.ts";
11
17
  import type {
12
18
  CarouselImperativeApi,
13
19
  CarouselRootProps,
@@ -69,10 +75,9 @@ import type {
69
75
  * <Carousel.Root ariaLabelledBy="promos">…</Carousel.Root>
70
76
  * ```
71
77
  */
72
- export const CarouselRoot = forwardRef<
73
- CarouselImperativeApi,
74
- CarouselRootProps
75
- >(function CarouselRoot(
78
+ export const CarouselRoot: ForwardRefExoticComponent<
79
+ PropsWithoutRef<CarouselRootProps> & RefAttributes<CarouselImperativeApi>
80
+ > = forwardRef<CarouselImperativeApi, CarouselRootProps>(function CarouselRoot(
76
81
  {
77
82
  className = "",
78
83
  ariaLabel,
@@ -185,7 +190,7 @@ export function CarouselViewport({
185
190
  className = "",
186
191
  children,
187
192
  ...rest
188
- }: CarouselViewportProps) {
193
+ }: CarouselViewportProps): ReactElement {
189
194
  const { isAutoRotating, ids } = useCarouselContext();
190
195
  const { viewportRef, onKeyDown } = useCarouselViewport();
191
196
 
@@ -254,7 +259,7 @@ export function CarouselSlide({
254
259
  ariaLabel,
255
260
  children,
256
261
  ...rest
257
- }: CarouselSlideProps) {
262
+ }: CarouselSlideProps): ReactElement {
258
263
  const { slideRef, index, total, state } = useCarouselSlide();
259
264
  const { translations } = useCarouselContext();
260
265
  const autoLabel =
@@ -311,7 +316,7 @@ export function CarouselNextTrigger({
311
316
  asChild = false,
312
317
  children,
313
318
  ...rest
314
- }: CarouselNextTriggerProps) {
319
+ }: CarouselNextTriggerProps): ReactElement {
315
320
  const { next, canGoNext, ids } = useCarouselContext();
316
321
  const isDisabled = disabled === true || !canGoNext;
317
322
 
@@ -377,7 +382,7 @@ export function CarouselPreviousTrigger({
377
382
  asChild = false,
378
383
  children,
379
384
  ...rest
380
- }: CarouselPreviousTriggerProps) {
385
+ }: CarouselPreviousTriggerProps): ReactElement {
381
386
  const { previous, canGoPrevious, ids } = useCarouselContext();
382
387
  const isDisabled = disabled === true || !canGoPrevious;
383
388
 
@@ -445,7 +450,7 @@ export function CarouselIndicatorGroup({
445
450
  ariaLabelledBy,
446
451
  children,
447
452
  ...rest
448
- }: CarouselIndicatorGroupProps) {
453
+ }: CarouselIndicatorGroupProps): ReactElement {
449
454
  const { ids } = useCarouselContext();
450
455
 
451
456
  return (
@@ -497,7 +502,7 @@ export function CarouselIndicator({
497
502
  asChild = false,
498
503
  children,
499
504
  ...rest
500
- }: CarouselIndicatorProps) {
505
+ }: CarouselIndicatorProps): ReactElement {
501
506
  const { goTo, currentPage, translations } = useCarouselContext();
502
507
  const isActive = index === currentPage;
503
508
 
@@ -552,7 +557,9 @@ CarouselIndicator.displayName = "CarouselIndicator";
552
557
  * <Carousel.Indicators label="Choose slide" />
553
558
  * ```
554
559
  */
555
- export function CarouselIndicators(props: CarouselIndicatorsProps) {
560
+ export function CarouselIndicators(
561
+ props: CarouselIndicatorsProps,
562
+ ): ReactElement {
556
563
  const { totalPages } = useCarouselContext();
557
564
 
558
565
  return (
@@ -594,7 +601,7 @@ export function CarouselPlayPauseTrigger({
594
601
  asChild = false,
595
602
  children,
596
603
  ...rest
597
- }: CarouselPlayPauseTriggerProps) {
604
+ }: CarouselPlayPauseTriggerProps): ReactElement {
598
605
  const { playing, togglePlaying, translations, ids, autoplayEnabled } =
599
606
  useCarouselContext();
600
607
 
@@ -1,8 +1,9 @@
1
- import { createContext } from "react";
1
+ import { createContext, type Context } from "react";
2
2
 
3
3
  import type { CarouselContextValue } from "./types";
4
4
 
5
- export const CarouselContext = createContext<CarouselContextValue | null>(null);
5
+ export const CarouselContext: Context<CarouselContextValue | null> =
6
+ createContext<CarouselContextValue | null>(null);
6
7
 
7
8
  CarouselContext.displayName = "CarouselContext";
8
9
 
@@ -1,7 +1,7 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
3
 
4
- import { Carousel } from "..";
4
+ import { Carousel } from "../index.ts";
5
5
 
6
6
  describe("Carousel.NextTrigger asChild", () => {
7
7
  it("should render the supplied child element and route the click through to the page-advance handler", async () => {
@@ -1,6 +1,6 @@
1
1
  import { act, fireEvent, render, screen } from "@testing-library/react";
2
2
 
3
- import { Carousel } from "..";
3
+ import { Carousel } from "../index.ts";
4
4
 
5
5
  describe("Carousel autoplay timer", () => {
6
6
  beforeEach(() => {
@@ -1,6 +1,6 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
 
3
- import { Carousel } from "..";
3
+ import { Carousel } from "../index.ts";
4
4
 
5
5
  describe("Carousel basic rendering tests", () => {
6
6
  describe("Carousel.Root", () => {
@@ -2,7 +2,7 @@ import { useState } from "react";
2
2
  import { render, screen } from "@testing-library/react";
3
3
  import userEvent from "@testing-library/user-event";
4
4
 
5
- import { Carousel } from "..";
5
+ import { Carousel } from "../index.ts";
6
6
 
7
7
  describe("Carousel controlled page state", () => {
8
8
  it("should derive the active slide from the controlled page prop", () => {
@@ -1,6 +1,6 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
 
3
- import { Carousel } from "..";
3
+ import { Carousel } from "../index.ts";
4
4
 
5
5
  describe("Carousel error handling", () => {
6
6
  it("should throw when Carousel.PlayPauseTrigger is rendered without autoplay enabled on Carousel.Root", () => {
@@ -1,6 +1,6 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
 
3
- import { Carousel } from "..";
3
+ import { Carousel } from "../index.ts";
4
4
 
5
5
  describe("Carousel custom ids", () => {
6
6
  it("should apply ids.root to the rendered <section>", () => {
@@ -1,8 +1,8 @@
1
1
  import { createRef, useRef } from "react";
2
2
  import { act, render, screen } from "@testing-library/react";
3
3
 
4
- import { Carousel } from "..";
5
- import type { CarouselImperativeApi } from "..";
4
+ import { Carousel } from "../index.ts";
5
+ import type { CarouselImperativeApi } from "../index.ts";
6
6
 
7
7
  function ImperativeFixture({
8
8
  apiRef,
@@ -2,7 +2,7 @@ import { useState } from "react";
2
2
  import { render, screen } from "@testing-library/react";
3
3
  import userEvent from "@testing-library/user-event";
4
4
 
5
- import { Carousel } from "..";
5
+ import { Carousel } from "../index.ts";
6
6
 
7
7
  describe("Carousel.IndicatorGroup", () => {
8
8
  it('should render with role="group"', () => {
@@ -2,8 +2,8 @@ import { RefObject, useRef } from "react";
2
2
  import { act, render, screen } from "@testing-library/react";
3
3
  import userEvent from "@testing-library/user-event";
4
4
 
5
- import { Carousel } from "..";
6
- import type { CarouselImperativeApi } from "..";
5
+ import { Carousel } from "../index.ts";
6
+ import type { CarouselImperativeApi } from "../index.ts";
7
7
  import { MockIntersectionObserver } from "../../test/intersectionObserverPolyfill";
8
8
 
9
9
  describe("Carousel IntersectionObserver fallback + isInView", () => {
@@ -1,7 +1,7 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
3
 
4
- import { Carousel } from "..";
4
+ import { Carousel } from "../index.ts";
5
5
 
6
6
  describe("Carousel keyboard navigation", () => {
7
7
  it("should advance the active page when ArrowRight is pressed with the viewport focused", async () => {
@@ -2,7 +2,7 @@ import { useState } from "react";
2
2
  import { render, screen } from "@testing-library/react";
3
3
  import userEvent from "@testing-library/user-event";
4
4
 
5
- import { Carousel } from "..";
5
+ import { Carousel } from "../index.ts";
6
6
 
7
7
  describe("Carousel.PlayPauseTrigger basic shape", () => {
8
8
  it("should render the PlayPauseTrigger as <button type='button'>", () => {
@@ -1,7 +1,7 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
3
 
4
- import { Carousel } from "..";
4
+ import { Carousel } from "../index.ts";
5
5
 
6
6
  function renderWithSlides(
7
7
  rootProps: { defaultPage?: number } = {},
@@ -1,7 +1,7 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
3
 
4
- import { Carousel } from "..";
4
+ import { Carousel } from "../index.ts";
5
5
 
6
6
  function mockReducedMotion(matches: boolean) {
7
7
  window.matchMedia = vi.fn().mockImplementation((query: string) => ({
@@ -1,8 +1,8 @@
1
1
  import { createRef } from "react";
2
2
  import { act, render, screen } from "@testing-library/react";
3
3
 
4
- import { Carousel } from "..";
5
- import type { CarouselImperativeApi } from "..";
4
+ import { Carousel } from "../index.ts";
5
+ import type { CarouselImperativeApi } from "../index.ts";
6
6
 
7
7
  function fixture(apiRef: React.Ref<CarouselImperativeApi>, slides = 3) {
8
8
  return (
@@ -1,6 +1,6 @@
1
1
  import { act, render, screen } from "@testing-library/react";
2
2
 
3
- import { Carousel } from "..";
3
+ import { Carousel } from "../index.ts";
4
4
 
5
5
  function fireScrollSnapChange(viewport: HTMLElement, snapTarget: HTMLElement) {
6
6
  const event = new Event("scrollsnapchange", { bubbles: false });
@@ -1,7 +1,7 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
3
 
4
- import { Carousel } from "..";
4
+ import { Carousel } from "../index.ts";
5
5
 
6
6
  describe("Carousel scroll sync (programmatic page change)", () => {
7
7
  it("should call scrollIntoView on the first slide of the target page when the active page changes", async () => {
@@ -1,7 +1,7 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
3
 
4
- import { Carousel } from "..";
4
+ import { Carousel } from "../index.ts";
5
5
 
6
6
  describe("Carousel numeric slidesPerMove", () => {
7
7
  it("should render `floor((total - slidesPerPage) / slidesPerMove) + 1` indicators", () => {