@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.
- package/package.json +1 -1
- package/src/AccessibleIcon/AccessibleIcon.tsx +5 -2
- package/src/AccessibleIcon/__tests__/AccessibleIcon.test.tsx +1 -1
- package/src/Accordion/Accordion.tsx +11 -12
- package/src/Accordion/AccordionContext.ts +1 -1
- package/src/Accordion/__tests__/Accordion.reading-direction.test.tsx +1 -1
- package/src/Accordion/hooks/useAccordionItem.ts +1 -1
- package/src/Accordion/hooks/useAccordionRoot.ts +1 -1
- package/src/Accordion/hooks/useAccordionTrigger.ts +2 -2
- package/src/Alert/Alert.tsx +8 -2
- package/src/Alert/__tests__/Alert.test.tsx +1 -1
- package/src/Avatar/Avatar.tsx +14 -5
- package/src/Avatar/AvatarContext.ts +10 -6
- package/src/Breadcrumb/Breadcrumb.tsx +21 -7
- package/src/Button/Button.tsx +4 -2
- package/src/Carousel/Carousel.tsx +21 -14
- package/src/Carousel/CarouselContext.ts +3 -2
- package/src/Carousel/__tests__/Carousel.asChild.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.auto-play.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.basic-rendering.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.controlled-state.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.error-handling.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.ids.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.imperative-api.test.tsx +2 -2
- package/src/Carousel/__tests__/Carousel.indicators.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.intersection-observer.test.tsx +2 -2
- package/src/Carousel/__tests__/Carousel.keyboard-navigation.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.play-pause.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.prev-next.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.reduced-motion.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.refresh-progress.test.tsx +2 -2
- package/src/Carousel/__tests__/Carousel.scroll-snap-change.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.scroll-sync.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.slides-per-move.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.slides-per-page.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.touch-interaction.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.transition-modes.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.translations.test.tsx +1 -1
- package/src/Carousel/__tests__/Carousel.uncontrolled-state.test.tsx +1 -1
- package/src/Checkbox/Checkbox.tsx +5 -4
- package/src/Checkbox/CheckboxContext.ts +1 -1
- package/src/Checkbox/hooks/useCheckboxRoot.ts +1 -1
- package/src/CheckboxCard/CheckboxCard.tsx +5 -4
- package/src/CheckboxCard/CheckboxCardContext.ts +10 -5
- package/src/CheckboxCard/hooks/useCheckboxCardRoot.ts +1 -1
- package/src/Collapsible/Collapsible.tsx +22 -21
- package/src/Collapsible/CollapsibleContext.ts +1 -1
- package/src/Collapsible/hooks/useCollapsibleRoot.ts +1 -1
- package/src/Collapsible/hooks/useCollapsibleTrigger.ts +1 -1
- package/src/ContextMenu/ContextMenu.tsx +20 -19
- package/src/ContextMenu/ContextMenuContext.ts +2 -2
- package/src/ContextMenu/ContextMenuSubContext.ts +1 -1
- package/src/ContextMenu/__tests__/ContextMenu.reading-direction.test.tsx +1 -1
- package/src/ContextMenu/types.ts +1 -1
- package/src/DirectionProvider/DirectionProvider.tsx +6 -1
- package/src/DirectionProvider/__tests__/DirectionProvider.test.tsx +1 -1
- package/src/Divider/Divider.tsx +3 -1
- package/src/Divider/__tests__/Divider.test.tsx +1 -1
- package/src/Dropdown/Dropdown.tsx +20 -19
- package/src/Dropdown/DropdownContext.ts +2 -2
- package/src/Dropdown/DropdownSubContext.ts +1 -1
- package/src/Dropdown/__tests__/Dropdown.reading-direction.test.tsx +1 -1
- package/src/Dropdown/hooks/useDropdownContent.ts +1 -1
- package/src/Dropdown/hooks/useDropdownItem.ts +1 -1
- package/src/Dropdown/hooks/useDropdownRoot.ts +2 -2
- package/src/Dropdown/hooks/useDropdownTrigger.ts +1 -1
- package/src/Dropdown/types.ts +1 -1
- package/src/EmptyState/EmptyState.tsx +8 -6
- package/src/EmptyState/__tests__/EmptyState.Actions.test.tsx +1 -1
- package/src/EmptyState/__tests__/EmptyState.Description.test.tsx +1 -1
- package/src/EmptyState/__tests__/EmptyState.Media.test.tsx +1 -1
- package/src/EmptyState/__tests__/EmptyState.Root.test.tsx +1 -1
- package/src/EmptyState/__tests__/EmptyState.Title.test.tsx +1 -1
- package/src/Field/Field.tsx +11 -6
- package/src/Field/FieldContext.ts +1 -1
- package/src/Fieldset/Fieldset.tsx +11 -2
- package/src/Input/Input.tsx +5 -3
- package/src/Input/__tests__/Input.field-integration.test.tsx +1 -1
- package/src/InputGroup/InputGroup.tsx +6 -4
- package/src/MillerColumns/MillerColumns.tsx +9 -8
- package/src/MillerColumns/MillerColumnsContext.ts +1 -1
- package/src/MillerColumns/hooks/useMillerColumnsItem.ts +2 -2
- package/src/MillerColumns/hooks/useMillerColumnsRoot.ts +0 -0
- package/src/MillerColumns/useMillerColumnsSelection.ts +1 -1
- package/src/Modal/Modal.tsx +24 -11
- package/src/Modal/ModalContext.ts +10 -6
- package/src/Modal/hooks/useModalRoot.ts +1 -1
- package/src/Modal/hooks/useModalTrigger.ts +2 -2
- package/src/Portal/Portal.tsx +2 -1
- package/src/Progress/Progress.tsx +5 -4
- package/src/Progress/ProgressContext.ts +11 -6
- package/src/RadioCard/RadioCard.tsx +8 -7
- package/src/RadioCard/RadioCardContext.ts +10 -5
- package/src/RadioCard/RadioCardItemContext.ts +10 -5
- package/src/RadioCard/__tests__/RadioCard.reading-direction.test.tsx +1 -1
- package/src/RadioCard/hooks/useRadioCardRoot.ts +1 -1
- package/src/RadioGroup/RadioGroup.tsx +8 -7
- package/src/RadioGroup/RadioGroupContext.ts +1 -1
- package/src/RadioGroup/RadioGroupItemContext.ts +1 -1
- package/src/RadioGroup/__tests__/RadioGroup.reading-direction.test.tsx +1 -1
- package/src/RadioGroup/hooks/useRadioGroupRoot.ts +1 -1
- package/src/Select/Select.tsx +10 -6
- package/src/Select/__tests__/Select.field-integration.test.tsx +1 -1
- package/src/SkipNav/SkipNav.tsx +7 -2
- package/src/SkipNav/__tests__/SkipNav.ids.test.tsx +1 -1
- package/src/Slider/Slider.tsx +17 -7
- package/src/Slider/SliderContext.ts +10 -6
- package/src/Slider/__tests__/Slider.reading-direction.test.tsx +1 -1
- package/src/Slider/hooks/useSliderRoot.ts +1 -1
- package/src/Status/Status.tsx +8 -2
- package/src/Status/__tests__/Status.test.tsx +1 -1
- package/src/Switch/Switch.tsx +9 -4
- package/src/Switch/SwitchContext.ts +9 -5
- package/src/Switch/hooks/useSwitchRoot.ts +1 -1
- package/src/Table/Table.tsx +15 -9
- package/src/Table/__tests__/Table.Body.test.tsx +1 -1
- package/src/Table/__tests__/Table.Caption.test.tsx +1 -1
- package/src/Table/__tests__/Table.Cell.test.tsx +1 -1
- package/src/Table/__tests__/Table.Footer.test.tsx +1 -1
- package/src/Table/__tests__/Table.Head.test.tsx +1 -1
- package/src/Table/__tests__/Table.Header.test.tsx +1 -1
- package/src/Table/__tests__/Table.Root.test.tsx +1 -1
- package/src/Table/__tests__/Table.Row.test.tsx +1 -1
- package/src/Table/__tests__/Table.ScrollArea.test.tsx +1 -1
- package/src/Tabs/Tabs.tsx +24 -9
- package/src/Tabs/TabsContext.ts +9 -6
- package/src/Tabs/__tests__/Tabs.asChild.test.tsx +1 -1
- package/src/Tabs/__tests__/Tabs.basic-rendering.test.tsx +1 -1
- package/src/Tabs/__tests__/Tabs.change-event-callbacks.test.tsx +1 -1
- package/src/Tabs/__tests__/Tabs.controlled-state.test.tsx +1 -1
- package/src/Tabs/__tests__/Tabs.error-handling.test.tsx +1 -1
- package/src/Tabs/__tests__/Tabs.imperative-api.test.tsx +1 -1
- package/src/Tabs/__tests__/Tabs.keyboard-interaction.test.tsx +1 -1
- package/src/Tabs/__tests__/Tabs.lazy-mount.test.tsx +1 -1
- package/src/Tabs/__tests__/Tabs.mouse-interaction.test.tsx +1 -1
- package/src/Tabs/__tests__/Tabs.reading-direction.test.tsx +1 -1
- package/src/Tabs/__tests__/Tabs.uncontrolled-state.test.tsx +1 -1
- package/src/Tabs/hooks/useTabsContent.ts +1 -1
- package/src/Tabs/hooks/useTabsRoot.ts +1 -1
- package/src/Tabs/hooks/useTabsTrigger.ts +1 -1
- package/src/Tabs/utils.ts +1 -1
- package/src/Textarea/Textarea.tsx +5 -3
- package/src/Textarea/__tests__/Textarea.field-integration.test.tsx +1 -1
- package/src/Toggle/Toggle.tsx +10 -4
- package/src/ToggleGroup/ToggleGroup.tsx +14 -10
- package/src/ToggleGroup/ToggleGroupContext.ts +1 -1
- package/src/ToggleGroup/__tests__/ToggleGroup.reading-direction.test.tsx +1 -1
- package/src/ToggleGroup/hooks/useToggleGroupRoot.ts +1 -1
- package/src/Tooltip/Tooltip.tsx +23 -10
- package/src/Tooltip/TooltipContext.ts +1 -1
- package/src/Tooltip/hooks/useTooltipContent.ts +1 -1
- package/src/Tooltip/hooks/useTooltipRoot.ts +1 -1
- package/src/Tooltip/hooks/useTooltipTrigger.ts +1 -1
- package/src/Tree/Tree.tsx +12 -11
- package/src/Tree/TreeContext.ts +1 -1
- package/src/Tree/__tests__/Tree.selection-path.test.tsx +2 -2
- package/src/Tree/hooks/useTreeItemKeyboard.ts +1 -1
- package/src/Tree/hooks/useTreeRoot.ts +1 -1
- package/src/VisuallyHidden/VisuallyHidden.tsx +3 -2
- package/src/VisuallyHidden/__tests__/VisuallyHidden.test.tsx +1 -1
- package/src/index.ts +38 -38
- 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
|
|
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 {
|
|
350
|
-
|
|
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
|
package/src/Tabs/TabsContext.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Context } from "react";
|
|
2
|
+
import { createStrictContext } from "../utils/index.ts";
|
|
2
3
|
|
|
3
4
|
import { TabsContextValue } from "./types";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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,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, 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
|
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();
|
package/src/Tabs/utils.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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 = {
|
package/src/Toggle/Toggle.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
|
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(
|
|
292
|
-
|
|
293
|
-
|
|
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,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
|
|
package/src/Tooltip/Tooltip.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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({
|
|
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({
|
|
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({
|
|
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,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
|
|
package/src/Tree/TreeContext.ts
CHANGED
|
@@ -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,5 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
|
-
import {
|
|
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 },
|