@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/src/Tabs/Tabs.tsx CHANGED
@@ -1,14 +1,20 @@
1
1
  import { forwardRef, Ref } from "react";
2
+ import type {
3
+ ForwardRefExoticComponent,
4
+ PropsWithoutRef,
5
+ ReactElement,
6
+ RefAttributes,
7
+ } from "react";
2
8
 
3
- import { useDirection } from "../DirectionProvider";
4
- import { Slot, composeRefs } from "../Slot";
9
+ import { useDirection } from "../DirectionProvider/index.ts";
10
+ import { Slot, composeRefs } from "../Slot/index.ts";
5
11
 
6
12
  import {
7
13
  useTabsRoot,
8
14
  useTabsContext,
9
15
  useTabsTrigger,
10
16
  useTabsContent,
11
- } from "./hooks";
17
+ } from "./hooks/index.ts";
12
18
  import { TabsProvider } from "./TabsContext";
13
19
  import type {
14
20
  TabsRootProps,
@@ -96,7 +102,9 @@ import type {
96
102
  * <button onClick={() => ref.current?.setActiveTab("two")}>Go to two</button>
97
103
  * ```
98
104
  */
99
- const TabsRoot = forwardRef<TabsImperativeApi, TabsRootProps>(function TabsRoot(
105
+ const TabsRoot: ForwardRefExoticComponent<
106
+ PropsWithoutRef<TabsRootProps> & RefAttributes<TabsImperativeApi>
107
+ > = forwardRef<TabsImperativeApi, TabsRootProps>(function TabsRoot(
100
108
  {
101
109
  className = "",
102
110
  orientation = "horizontal",
@@ -166,7 +174,7 @@ export function TabsList({
166
174
  label,
167
175
  ariaLabelledBy,
168
176
  ...rest
169
- }: TabsListProps) {
177
+ }: TabsListProps): ReactElement {
170
178
  const { orientation } = useTabsContext();
171
179
 
172
180
  return (
@@ -259,7 +267,7 @@ export function TabsTrigger<T extends HTMLElement = HTMLButtonElement>({
259
267
  disabled = false,
260
268
  asChild = false,
261
269
  ...rest
262
- }: TabsTriggerProps<T>) {
270
+ }: TabsTriggerProps<T>): ReactElement {
263
271
  const {
264
272
  buttonRef,
265
273
  triggerId,
@@ -345,9 +353,16 @@ export function TabsContent({
345
353
  className = "",
346
354
  value,
347
355
  ...rest
348
- }: TabsContentProps) {
349
- const { panelId, triggerId, orientation, isActive, state, tabIndex, shouldRender } =
350
- useTabsContent({ value });
356
+ }: TabsContentProps): ReactElement {
357
+ const {
358
+ panelId,
359
+ triggerId,
360
+ orientation,
361
+ isActive,
362
+ state,
363
+ tabIndex,
364
+ shouldRender,
365
+ } = useTabsContent({ value });
351
366
 
352
367
  return (
353
368
  <div
@@ -1,12 +1,15 @@
1
- import { createStrictContext } from "../utils";
1
+ import type { Context } from "react";
2
+ import { createStrictContext } from "../utils/index.ts";
2
3
 
3
4
  import { TabsContextValue } from "./types";
4
5
 
5
- export const [TabsContext, useTabsContext] =
6
- createStrictContext<TabsContextValue>(
7
- "Component must be rendered as a child of Tabs.Root",
8
- "TabsContext",
9
- );
6
+ const tabsContextPair = createStrictContext<TabsContextValue>(
7
+ "Component must be rendered as a child of Tabs.Root",
8
+ "TabsContext",
9
+ );
10
+
11
+ export const TabsContext: Context<TabsContextValue | null> = tabsContextPair[0];
12
+ export const useTabsContext: () => TabsContextValue = tabsContextPair[1];
10
13
 
11
14
  const TabsProvider = TabsContext.Provider;
12
15
 
@@ -2,7 +2,7 @@ import { render, screen } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
3
  import { createRef } from "react";
4
4
 
5
- import { Tabs } from "..";
5
+ import { Tabs } from "../index.ts";
6
6
 
7
7
  describe("Tabs.Trigger asChild", () => {
8
8
  it("renders the child element instead of a <button> when asChild is true", () => {
@@ -1,6 +1,6 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
 
3
- import { Tabs, TabsOrientation } from "..";
3
+ import { Tabs, TabsOrientation } from "../index.ts";
4
4
 
5
5
  describe("Tabs basic rendering tests", () => {
6
6
  describe("Tabs.Root", () => {
@@ -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 { Tabs } from '..';
4
+ import { Tabs } from '../index.ts';
5
5
 
6
6
  import { mouseChangeEventCases, keyboardChangeEventCases } from './Tabs.fixtures';
7
7
 
@@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react';
2
2
  import userEvent from '@testing-library/user-event';
3
3
  import { useState } from 'react';
4
4
 
5
- import { Tabs } from '..';
5
+ import { Tabs } from '../index.ts';
6
6
 
7
7
  describe('Tabs controlled state tests', () => {
8
8
  it('should respect the value prop for active tab', () => {
@@ -1,7 +1,7 @@
1
1
  import { render, screen } from '@testing-library/react';
2
2
  import { act, useState } from 'react';
3
3
 
4
- import { Tabs } from '..';
4
+ import { Tabs } from '../index.ts';
5
5
 
6
6
  import { errorCases } from './Tabs.fixtures';
7
7
 
@@ -1,7 +1,7 @@
1
1
  import { render, screen, waitFor } from "@testing-library/react";
2
2
  import { createRef } from "react";
3
3
 
4
- import { Tabs, TabsImperativeApi } from "..";
4
+ import { Tabs, TabsImperativeApi } from "../index.ts";
5
5
 
6
6
  describe("Tabs Imperative API", () => {
7
7
  it("should expose setActiveTab method via ref", () => {
@@ -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 { Tabs } from '..';
4
+ import { Tabs } from '../index.ts';
5
5
 
6
6
  import { arrowKeyCases } from './Tabs.fixtures';
7
7
 
@@ -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 { Tabs } from "..";
4
+ import { Tabs } from "../index.ts";
5
5
 
6
6
  function renderTabs(lazyMount: boolean) {
7
7
  return render(
@@ -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 { Tabs } from '..';
4
+ import { Tabs } from '../index.ts';
5
5
 
6
6
  describe('Tabs mouse interaction tests', () => {
7
7
  describe('tab and panel activation', () => {
@@ -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 { Tabs } from "../Tabs";
6
6
  import { TabsReadingDirection } from "../types";
7
7
 
@@ -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 { Tabs } from '..';
4
+ import { Tabs } from '../index.ts';
5
5
 
6
6
  describe('Tabs state tests', () => {
7
7
  describe('no defaultValue provided', () => {
@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
3
3
  import { TabsContentProps } from "../types";
4
4
  import { getTriggerAndPanelIds } from "../utils";
5
5
 
6
- import { useTabsContext } from ".";
6
+ import { useTabsContext } from "./index.ts";
7
7
 
8
8
  export function useTabsContent({ value }: Pick<TabsContentProps, "value">) {
9
9
  const { orientation, activeValue, tabsId, lazyMount } = useTabsContext();
@@ -7,7 +7,7 @@ import {
7
7
  Ref,
8
8
  } from "react";
9
9
 
10
- import { useCollection, useControllableState } from "../../hooks";
10
+ import { useCollection, useControllableState } from "../../hooks/index.ts";
11
11
 
12
12
  import type { TabsRootProps, TabsImperativeApi } from "../types";
13
13
 
@@ -5,7 +5,7 @@ import {
5
5
  MouseEvent,
6
6
  } from "react";
7
7
 
8
- import { useRovingTabindex } from "../../hooks";
8
+ import { useRovingTabindex } from "../../hooks/index.ts";
9
9
 
10
10
  import { TabsTriggerProps } from "../types";
11
11
  import { getTriggerAndPanelIds } from "../utils";
package/src/Tabs/utils.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { deriveId } from "../utils";
1
+ import { deriveId } from "../utils/index.ts";
2
2
 
3
3
  export function getTriggerAndPanelIds(tabsId: string, value: string) {
4
4
  return {
@@ -1,5 +1,7 @@
1
- import { useFieldProps } from "../Field/hooks";
2
- import { Slot } from "../Slot";
1
+ import type { ReactElement } from "react";
2
+
3
+ import { useFieldProps } from "../Field/hooks/index.ts";
4
+ import { Slot } from "../Slot/index.ts";
3
5
  import { TextareaProps } from "./types";
4
6
 
5
7
  /**
@@ -74,7 +76,7 @@ export function Textarea({
74
76
  children,
75
77
  ref,
76
78
  ...consumer
77
- }: TextareaProps) {
79
+ }: TextareaProps): ReactElement {
78
80
  const merged = useFieldProps(consumer);
79
81
 
80
82
  const rootProps = {
@@ -1,6 +1,6 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
 
3
- import { Field } from "../../Field";
3
+ import { Field } from "../../Field/index.ts";
4
4
  import { Textarea } from "../Textarea";
5
5
 
6
6
  describe("Textarea — Field integration", () => {
@@ -1,5 +1,7 @@
1
- import { useControllableState } from "../hooks";
2
- import { Slot, composeEventHandlers } from "../Slot";
1
+ import type { ReactElement } from "react";
2
+
3
+ import { useControllableState } from "../hooks/index.ts";
4
+ import { Slot, composeEventHandlers } from "../Slot/index.ts";
3
5
 
4
6
  import { ToggleProps } from "./types";
5
7
 
@@ -50,7 +52,7 @@ function Toggle({
50
52
  children,
51
53
  ref,
52
54
  ...rest
53
- }: ToggleProps) {
55
+ }: ToggleProps): ReactElement {
54
56
  const [pressed, setPressed] = useControllableState<boolean>(
55
57
  controlledPressed,
56
58
  defaultPressed ?? false,
@@ -73,7 +75,11 @@ function Toggle({
73
75
  };
74
76
 
75
77
  if (asChild) return <Slot {...toggleProps}>{children}</Slot>;
76
- return <button type="button" {...toggleProps}>{children}</button>;
78
+ return (
79
+ <button type="button" {...toggleProps}>
80
+ {children}
81
+ </button>
82
+ );
77
83
  }
78
84
 
79
85
  Toggle.displayName = "Toggle";
@@ -1,11 +1,12 @@
1
1
  import { useEffect, useMemo, useRef } from "react";
2
+ import type { ReactElement } from "react";
2
3
 
3
- import { useDirection } from "../DirectionProvider";
4
- import { useRovingTabindex } from "../hooks";
5
- import { Slot, composeEventHandlers, composeRefs } from "../Slot";
4
+ import { useDirection } from "../DirectionProvider/index.ts";
5
+ import { useRovingTabindex } from "../hooks/index.ts";
6
+ import { Slot, composeEventHandlers, composeRefs } from "../Slot/index.ts";
6
7
 
7
8
  import { ToggleGroupContext } from "./ToggleGroupContext";
8
- import { useToggleGroupRoot, useToggleGroupContext } from "./hooks";
9
+ import { useToggleGroupRoot, useToggleGroupContext } from "./hooks/index.ts";
9
10
  import { ToggleGroupItemProps, ToggleGroupRootProps } from "./types";
10
11
 
11
12
  /**
@@ -73,7 +74,7 @@ function ToggleGroupRoot({
73
74
  children,
74
75
  ref,
75
76
  ...rest
76
- }: ToggleGroupRootProps) {
77
+ }: ToggleGroupRootProps): ReactElement {
77
78
  const resolvedDir = dir ?? useDirection();
78
79
  const {
79
80
  value,
@@ -177,7 +178,7 @@ function ToggleGroupItem({
177
178
  children,
178
179
  ref,
179
180
  ...rest
180
- }: ToggleGroupItemProps) {
181
+ }: ToggleGroupItemProps): ReactElement {
181
182
  const {
182
183
  value: groupValue,
183
184
  toggle,
@@ -288,10 +289,13 @@ type TToggleGroupCompound = typeof ToggleGroupRoot & {
288
289
  * @see {@link ToggleGroupRoot} for type modes, state, and ARIA.
289
290
  * @see {@link ToggleGroupItem} for selection, roving tabindex, and keyboard navigation.
290
291
  */
291
- const ToggleGroupCompound: TToggleGroupCompound = Object.assign(ToggleGroupRoot, {
292
- Root: ToggleGroupRoot,
293
- Item: ToggleGroupItem,
294
- });
292
+ const ToggleGroupCompound: TToggleGroupCompound = Object.assign(
293
+ ToggleGroupRoot,
294
+ {
295
+ Root: ToggleGroupRoot,
296
+ Item: ToggleGroupItem,
297
+ },
298
+ );
295
299
 
296
300
  ToggleGroupCompound.displayName = "ToggleGroup";
297
301
 
@@ -1,4 +1,4 @@
1
- import { createStrictContext } from "../utils";
1
+ import { createStrictContext } from "../utils/index.ts";
2
2
 
3
3
  import { ToggleGroupContextValue } from "./types";
4
4
 
@@ -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 { ToggleGroup } from "../ToggleGroup";
6
6
 
7
7
  describe("ToggleGroup reading direction", () => {
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo, useState } from "react";
2
2
 
3
- import { useCollection, useControllableState } from "../../hooks";
3
+ import { useCollection, useControllableState } from "../../hooks/index.ts";
4
4
 
5
5
  type ItemMeta = { element: HTMLButtonElement; disabled: boolean };
6
6
 
@@ -1,5 +1,7 @@
1
- import { Portal } from "../Portal";
2
- import { Slot, composeRefs } from "../Slot";
1
+ import type { ReactElement } from "react";
2
+
3
+ import { Portal } from "../Portal/index.ts";
4
+ import { Slot, composeRefs } from "../Slot/index.ts";
3
5
 
4
6
  import {
5
7
  TooltipProvider,
@@ -11,7 +13,7 @@ import {
11
13
  useTooltipProvider,
12
14
  useTooltipRoot,
13
15
  useTooltipTrigger,
14
- } from "./hooks";
16
+ } from "./hooks/index.ts";
15
17
  import type {
16
18
  TooltipArrowProps,
17
19
  TooltipContentProps,
@@ -37,8 +39,11 @@ function TooltipProviderComponent({
37
39
  children,
38
40
  delayDuration = 700,
39
41
  skipDelayDuration = 300,
40
- }: TooltipProviderProps) {
41
- const { contextValue } = useTooltipProvider({ delayDuration, skipDelayDuration });
42
+ }: TooltipProviderProps): ReactElement {
43
+ const { contextValue } = useTooltipProvider({
44
+ delayDuration,
45
+ skipDelayDuration,
46
+ });
42
47
  return (
43
48
  <TooltipProviderProvider value={contextValue}>
44
49
  {children}
@@ -72,7 +77,7 @@ function TooltipRoot({
72
77
  onOpenChange,
73
78
  delayDuration,
74
79
  disableHoverableContent,
75
- }: TooltipRootProps) {
80
+ }: TooltipRootProps): ReactElement {
76
81
  const { contextValue } = useTooltipRoot({
77
82
  defaultOpen,
78
83
  open,
@@ -114,7 +119,7 @@ function TooltipTrigger({
114
119
  onKeyDown,
115
120
  type,
116
121
  ...rest
117
- }: TooltipTriggerProps) {
122
+ }: TooltipTriggerProps): ReactElement {
118
123
  const { getTriggerProps } = useTooltipTrigger({
119
124
  onPointerEnter,
120
125
  onPointerLeave,
@@ -149,7 +154,11 @@ TooltipTrigger.displayName = "TooltipTrigger";
149
154
  * </Tooltip.Portal>
150
155
  * ```
151
156
  */
152
- function TooltipPortal({ children, container, forceMount }: TooltipPortalProps) {
157
+ function TooltipPortal({
158
+ children,
159
+ container,
160
+ forceMount,
161
+ }: TooltipPortalProps): ReactElement | null {
153
162
  const { open } = useTooltipContext();
154
163
 
155
164
  if (!open && !forceMount) return null;
@@ -195,7 +204,7 @@ function TooltipContent({
195
204
  onPointerEnter,
196
205
  onPointerLeave,
197
206
  ...rest
198
- }: TooltipContentProps) {
207
+ }: TooltipContentProps): ReactElement | null {
199
208
  const { open } = useTooltipContext();
200
209
  const { getContentProps, internalRef } = useTooltipContent({
201
210
  onEscapeKeyDown,
@@ -227,7 +236,11 @@ TooltipContent.displayName = "TooltipContent";
227
236
  * </Tooltip.Content>
228
237
  * ```
229
238
  */
230
- function TooltipArrow({ ref, asChild = false, ...rest }: TooltipArrowProps) {
239
+ function TooltipArrow({
240
+ ref,
241
+ asChild = false,
242
+ ...rest
243
+ }: TooltipArrowProps): ReactElement {
231
244
  if (asChild) {
232
245
  return <Slot ref={ref} {...rest} />;
233
246
  }
@@ -1,4 +1,4 @@
1
- import { createStrictContext } from "../utils";
1
+ import { createStrictContext } from "../utils/index.ts";
2
2
 
3
3
  import type { TooltipContextValue, TooltipProviderContextValue } from "./types";
4
4
 
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useRef } from "react";
2
2
 
3
- import { composeEventHandlers } from "../../Slot";
3
+ import { composeEventHandlers } from "../../Slot/index.ts";
4
4
  import { useTooltipContext } from "../TooltipContext";
5
5
  import type { TooltipContentProps } from "../types";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useId, useMemo, useRef } from "react";
2
2
 
3
- import { useControllableState } from "../../hooks";
3
+ import { useControllableState } from "../../hooks/index.ts";
4
4
  import { useTooltipProviderContext } from "../TooltipContext";
5
5
  import type { TooltipContextValue, TooltipRootProps } from "../types";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { KeyboardEvent } from "react";
2
2
 
3
- import { composeEventHandlers } from "../../Slot";
3
+ import { composeEventHandlers } from "../../Slot/index.ts";
4
4
  import { useTooltipContext } from "../TooltipContext";
5
5
  import type { TooltipTriggerProps } from "../types";
6
6
 
package/src/Tree/Tree.tsx CHANGED
@@ -1,8 +1,9 @@
1
1
  import { Fragment, useLayoutEffect, useRef } from "react";
2
+ import type { ReactElement } from "react";
2
3
 
3
- import { Breadcrumb } from "../Breadcrumb";
4
- import { Slot, composeEventHandlers } from "../Slot";
5
- import { deriveId } from "../utils";
4
+ import { Breadcrumb } from "../Breadcrumb/index.ts";
5
+ import { Slot, composeEventHandlers } from "../Slot/index.ts";
6
+ import { deriveId } from "../utils/index.ts";
6
7
 
7
8
  import {
8
9
  TreeContext,
@@ -16,7 +17,7 @@ import {
16
17
  useTreeItemKeyboard,
17
18
  useTreeRoot,
18
19
  useTreeSelectionPaths,
19
- } from "./hooks";
20
+ } from "./hooks/index.ts";
20
21
  import { partitionBranchChildren } from "./utils";
21
22
 
22
23
  import type {
@@ -63,7 +64,7 @@ import type {
63
64
  * </Tree.Root>
64
65
  * ```
65
66
  */
66
- export function TreeRoot(props: TreeRootProps) {
67
+ export function TreeRoot(props: TreeRootProps): ReactElement {
67
68
  const {
68
69
  children,
69
70
  expandedValues,
@@ -141,7 +142,7 @@ export function TreeItem({
141
142
  onFocus,
142
143
  onKeyDown,
143
144
  ...rest
144
- }: TreeItemProps) {
145
+ }: TreeItemProps): ReactElement {
145
146
  const { depth, parentValue } = useTreeLevelContext();
146
147
  const { isSelected, select, registerNode, tabStop, setActiveValue } =
147
148
  useTreeContext();
@@ -235,7 +236,7 @@ export function TreeBranch({
235
236
  onFocus,
236
237
  onKeyDown,
237
238
  ...rest
238
- }: TreeBranchProps) {
239
+ }: TreeBranchProps): ReactElement {
239
240
  const { depth, parentValue } = useTreeLevelContext();
240
241
  const {
241
242
  rootId,
@@ -321,7 +322,7 @@ export function TreeBranchControl({
321
322
  children,
322
323
  onClick,
323
324
  ...rest
324
- }: TreeBranchControlProps) {
325
+ }: TreeBranchControlProps): ReactElement {
325
326
  const { value, disabled, controlId } = useTreeItemContext();
326
327
  const { toggleExpanded, select } = useTreeContext();
327
328
 
@@ -363,7 +364,7 @@ export function TreeBranchContent({
363
364
  children,
364
365
  forceMount = false,
365
366
  ...rest
366
- }: TreeBranchContentProps) {
367
+ }: TreeBranchContentProps): ReactElement {
367
368
  const { depth } = useTreeLevelContext();
368
369
  const { value: branchValue, expanded } = useTreeItemContext();
369
370
 
@@ -413,7 +414,7 @@ export function TreeBranchIndicator({
413
414
  children,
414
415
  asChild = false,
415
416
  ...rest
416
- }: TreeBranchIndicatorProps) {
417
+ }: TreeBranchIndicatorProps): ReactElement {
417
418
  const { expanded } = useTreeItemContext();
418
419
 
419
420
  const indicatorProps = {
@@ -483,7 +484,7 @@ export function TreeSelectionPath({
483
484
  children,
484
485
  separator,
485
486
  ...rest
486
- }: TreeSelectionPathProps) {
487
+ }: TreeSelectionPathProps): ReactElement {
487
488
  const paths = useTreeSelectionPaths();
488
489
  const empty = paths.length === 0;
489
490
 
@@ -1,4 +1,4 @@
1
- import { createStrictContext } from "../utils";
1
+ import { createStrictContext } from "../utils/index.ts";
2
2
 
3
3
  import type {
4
4
  TreeContextValue,
@@ -3,8 +3,8 @@ import { useState } from "react";
3
3
  import { render, screen, within } from "@testing-library/react";
4
4
  import userEvent from "@testing-library/user-event";
5
5
 
6
- import { Tree, useTreePath, useTreeSelectionPaths } from "../../Tree";
7
- import type { TreePathSegment } from "../../Tree";
6
+ import { Tree, useTreePath, useTreeSelectionPaths } from "../../Tree/index.ts";
7
+ import type { TreePathSegment } from "../../Tree/index.ts";
8
8
 
9
9
  function PathProbe({ value }: { value: string }) {
10
10
  const path = useTreePath(value);
@@ -1,6 +1,6 @@
1
1
  import type { KeyboardEvent } from "react";
2
2
 
3
- import { useRovingTabindex } from "../../hooks";
3
+ import { useRovingTabindex } from "../../hooks/index.ts";
4
4
  import { useTreeContext } from "../TreeContext";
5
5
 
6
6
  type TreeItemKeyboardOptions = {
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useId, useRef, useState } from "react";
2
2
 
3
- import { useCollection, useControllableState } from "../../hooks";
3
+ import { useCollection, useControllableState } from "../../hooks/index.ts";
4
4
 
5
5
  import type {
6
6
  SelectionMode,
@@ -1,5 +1,6 @@
1
1
  import { CSSProperties } from "react";
2
- import { Slot } from "../Slot";
2
+ import type { ReactElement } from "react";
3
+ import { Slot } from "../Slot/index.ts";
3
4
  import { VisuallyHiddenProps } from "./types";
4
5
 
5
6
  const visuallyHiddenStyle: CSSProperties = {
@@ -51,7 +52,7 @@ export function VisuallyHidden({
51
52
  children,
52
53
  style,
53
54
  ...rest
54
- }: VisuallyHiddenProps) {
55
+ }: VisuallyHiddenProps): ReactElement {
55
56
  const rootProps = {
56
57
  ...rest,
57
58
  style: { ...visuallyHiddenStyle, ...style },
@@ -1,4 +1,4 @@
1
- import { VisuallyHidden } from "..";
1
+ import { VisuallyHidden } from "../index.ts";
2
2
  import { render, screen } from "@testing-library/react";
3
3
 
4
4
  describe("VisuallyHidden component", () => {