@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
|
@@ -1,8 +1,9 @@
|
|
|
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 { RadioCardContext } from "./RadioCardContext";
|
|
8
9
|
import { RadioCardItemContext } from "./RadioCardItemContext";
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
useRadioCardContext,
|
|
11
12
|
useRadioCardItemContext,
|
|
12
13
|
useRadioCardRoot,
|
|
13
|
-
} from "./hooks";
|
|
14
|
+
} from "./hooks/index.ts";
|
|
14
15
|
import {
|
|
15
16
|
RadioCardIndicatorProps,
|
|
16
17
|
RadioCardItemProps,
|
|
@@ -81,7 +82,7 @@ function RadioCardRoot({
|
|
|
81
82
|
asChild = false,
|
|
82
83
|
children,
|
|
83
84
|
...rest
|
|
84
|
-
}: RadioCardRootProps) {
|
|
85
|
+
}: RadioCardRootProps): ReactElement {
|
|
85
86
|
const resolvedDir = dir ?? useDirection();
|
|
86
87
|
const { value, select, registerItem, itemValues, disabledValues, focusItem } =
|
|
87
88
|
useRadioCardRoot({
|
|
@@ -166,7 +167,7 @@ function RadioCardItem({
|
|
|
166
167
|
asChild = false,
|
|
167
168
|
ref,
|
|
168
169
|
...rest
|
|
169
|
-
}: RadioCardItemProps) {
|
|
170
|
+
}: RadioCardItemProps): ReactElement {
|
|
170
171
|
const {
|
|
171
172
|
value: selectedValue,
|
|
172
173
|
select,
|
|
@@ -264,7 +265,7 @@ function RadioCardIndicator({
|
|
|
264
265
|
forceMount,
|
|
265
266
|
asChild = false,
|
|
266
267
|
...rest
|
|
267
|
-
}: RadioCardIndicatorProps) {
|
|
268
|
+
}: RadioCardIndicatorProps): ReactElement | null {
|
|
268
269
|
const { checked } = useRadioCardItemContext();
|
|
269
270
|
if (!checked && !forceMount) return null;
|
|
270
271
|
const indicatorProps = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Context } from "react";
|
|
2
|
+
import { createStrictContext } from "../utils/index.ts";
|
|
2
3
|
|
|
3
4
|
import { RadioCardOrientation, RadioCardReadingDirection } from "./types";
|
|
4
5
|
|
|
@@ -17,7 +18,11 @@ export type RadioCardContextValue = {
|
|
|
17
18
|
dir: RadioCardReadingDirection;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const radioCardContextPair = createStrictContext<RadioCardContextValue>(
|
|
22
|
+
"RadioCard sub-components must be rendered inside a <RadioCard.Root>.",
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const RadioCardContext: Context<RadioCardContextValue | null> =
|
|
26
|
+
radioCardContextPair[0];
|
|
27
|
+
export const useRadioCardContext: () => RadioCardContextValue =
|
|
28
|
+
radioCardContextPair[1];
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Context } from "react";
|
|
2
|
+
import { createStrictContext } from "../utils/index.ts";
|
|
2
3
|
|
|
3
4
|
export type RadioCardItemContextValue = {
|
|
4
5
|
checked: boolean;
|
|
5
6
|
};
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const radioCardItemContextPair = createStrictContext<RadioCardItemContextValue>(
|
|
9
|
+
"RadioCard.Indicator must be rendered inside a <RadioCard.Item>.",
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export const RadioCardItemContext: Context<RadioCardItemContextValue | null> =
|
|
13
|
+
radioCardItemContextPair[0];
|
|
14
|
+
export const useRadioCardItemContext: () => RadioCardItemContextValue =
|
|
15
|
+
radioCardItemContextPair[1];
|
|
@@ -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 { RadioCard } from "../RadioCard";
|
|
6
6
|
|
|
7
7
|
describe("RadioCard reading direction", () => {
|
|
@@ -1,8 +1,9 @@
|
|
|
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 { RadioGroupContext } from "./RadioGroupContext";
|
|
8
9
|
import { RadioGroupItemContext } from "./RadioGroupItemContext";
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
useRadioGroupContext,
|
|
11
12
|
useRadioGroupItemContext,
|
|
12
13
|
useRadioGroupRoot,
|
|
13
|
-
} from "./hooks";
|
|
14
|
+
} from "./hooks/index.ts";
|
|
14
15
|
import {
|
|
15
16
|
RadioGroupIndicatorProps,
|
|
16
17
|
RadioGroupItemProps,
|
|
@@ -82,7 +83,7 @@ function RadioGroupRoot({
|
|
|
82
83
|
asChild = false,
|
|
83
84
|
children,
|
|
84
85
|
...rest
|
|
85
|
-
}: RadioGroupRootProps) {
|
|
86
|
+
}: RadioGroupRootProps): ReactElement {
|
|
86
87
|
const resolvedDir = dir ?? useDirection();
|
|
87
88
|
const { value, select, registerItem, itemValues, disabledValues, focusItem } =
|
|
88
89
|
useRadioGroupRoot({
|
|
@@ -172,7 +173,7 @@ function RadioGroupItem({
|
|
|
172
173
|
asChild = false,
|
|
173
174
|
ref,
|
|
174
175
|
...rest
|
|
175
|
-
}: RadioGroupItemProps) {
|
|
176
|
+
}: RadioGroupItemProps): ReactElement {
|
|
176
177
|
const {
|
|
177
178
|
value: selectedValue,
|
|
178
179
|
select,
|
|
@@ -282,7 +283,7 @@ function RadioGroupIndicator({
|
|
|
282
283
|
forceMount,
|
|
283
284
|
asChild = false,
|
|
284
285
|
...rest
|
|
285
|
-
}: RadioGroupIndicatorProps) {
|
|
286
|
+
}: RadioGroupIndicatorProps): ReactElement | null {
|
|
286
287
|
const { checked } = useRadioGroupItemContext();
|
|
287
288
|
if (!checked && !forceMount) return null;
|
|
288
289
|
const indicatorProps = {
|
|
@@ -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 { RadioGroup } from "../RadioGroup";
|
|
6
6
|
|
|
7
7
|
describe("RadioGroup reading direction", () => {
|
package/src/Select/Select.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ChangeEvent, Children, isValidElement, ReactNode } from "react";
|
|
2
|
+
import type { ReactElement } from "react";
|
|
2
3
|
|
|
3
|
-
import { useFieldProps } from "../Field/hooks";
|
|
4
|
-
import { Slot } from "../Slot";
|
|
4
|
+
import { useFieldProps } from "../Field/hooks/index.ts";
|
|
5
|
+
import { Slot } from "../Slot/index.ts";
|
|
5
6
|
|
|
6
7
|
import {
|
|
7
8
|
SelectGroupProps,
|
|
@@ -59,7 +60,7 @@ function SelectRoot({
|
|
|
59
60
|
value,
|
|
60
61
|
defaultValue,
|
|
61
62
|
...consumer
|
|
62
|
-
}: SelectRootProps) {
|
|
63
|
+
}: SelectRootProps): ReactElement {
|
|
63
64
|
const merged = useFieldProps(consumer);
|
|
64
65
|
|
|
65
66
|
const handleChange = (event: ChangeEvent<HTMLSelectElement>) => {
|
|
@@ -104,7 +105,7 @@ SelectRoot.displayName = "SelectRoot";
|
|
|
104
105
|
* Native `<option>` only renders text; rich content (icons, descriptions)
|
|
105
106
|
* is not supported.
|
|
106
107
|
*/
|
|
107
|
-
function SelectOption({ children, ...rest }: SelectOptionProps) {
|
|
108
|
+
function SelectOption({ children, ...rest }: SelectOptionProps): ReactElement {
|
|
108
109
|
return <option {...rest}>{children}</option>;
|
|
109
110
|
}
|
|
110
111
|
|
|
@@ -115,7 +116,7 @@ SelectOption.displayName = "SelectOption";
|
|
|
115
116
|
* native `<optgroup>` element. The `label` is shown by the browser as a
|
|
116
117
|
* non-selectable heading and is announced as the group's accessible name.
|
|
117
118
|
*/
|
|
118
|
-
function SelectGroup({ children, ...rest }: SelectGroupProps) {
|
|
119
|
+
function SelectGroup({ children, ...rest }: SelectGroupProps): ReactElement {
|
|
119
120
|
return <optgroup {...rest}>{children}</optgroup>;
|
|
120
121
|
}
|
|
121
122
|
|
|
@@ -131,7 +132,10 @@ SelectGroup.displayName = "SelectGroup";
|
|
|
131
132
|
* Pair with `required` on {@link Select.Root} to make the browser's
|
|
132
133
|
* native form validation catch an unchosen value at submission.
|
|
133
134
|
*/
|
|
134
|
-
function SelectPlaceholder({
|
|
135
|
+
function SelectPlaceholder({
|
|
136
|
+
children,
|
|
137
|
+
...rest
|
|
138
|
+
}: SelectPlaceholderProps): ReactElement {
|
|
135
139
|
return (
|
|
136
140
|
<option {...rest} value="" disabled hidden>
|
|
137
141
|
{children}
|
package/src/SkipNav/SkipNav.tsx
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
|
|
1
3
|
import { SkipNavContentProps, SkipNavLinkProps } from "./types";
|
|
2
4
|
|
|
3
5
|
const DEFAULT_CONTENT_ID = "primitiv-skip-nav";
|
|
@@ -34,7 +36,7 @@ function SkipNavLink({
|
|
|
34
36
|
children,
|
|
35
37
|
contentId = DEFAULT_CONTENT_ID,
|
|
36
38
|
...rest
|
|
37
|
-
}: SkipNavLinkProps) {
|
|
39
|
+
}: SkipNavLinkProps): ReactElement {
|
|
38
40
|
return (
|
|
39
41
|
<a href={`#${contentId}`} {...rest}>
|
|
40
42
|
{children}
|
|
@@ -63,7 +65,10 @@ SkipNavLink.displayName = "SkipNavLink";
|
|
|
63
65
|
* </SkipNav.Content>
|
|
64
66
|
* ```
|
|
65
67
|
*/
|
|
66
|
-
function SkipNavContent({
|
|
68
|
+
function SkipNavContent({
|
|
69
|
+
children,
|
|
70
|
+
...rest
|
|
71
|
+
}: SkipNavContentProps): ReactElement {
|
|
67
72
|
return (
|
|
68
73
|
<div id={DEFAULT_CONTENT_ID} tabIndex={-1} {...rest}>
|
|
69
74
|
{children}
|
package/src/Slider/Slider.tsx
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
import { useDirection } from "../DirectionProvider/index.ts";
|
|
4
|
+
import { Slot, composeEventHandlers, composeRefs } from "../Slot/index.ts";
|
|
3
5
|
|
|
4
6
|
import { SliderContext } from "./SliderContext";
|
|
5
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
useSliderContext,
|
|
9
|
+
useSliderRoot,
|
|
10
|
+
useSliderThumb,
|
|
11
|
+
} from "./hooks/index.ts";
|
|
6
12
|
import type {
|
|
7
13
|
SliderRangeProps,
|
|
8
14
|
SliderRootProps,
|
|
@@ -87,7 +93,7 @@ function SliderRoot({
|
|
|
87
93
|
ref,
|
|
88
94
|
children,
|
|
89
95
|
...rest
|
|
90
|
-
}: SliderRootProps) {
|
|
96
|
+
}: SliderRootProps): ReactElement {
|
|
91
97
|
const resolvedDir = dir ?? useDirection();
|
|
92
98
|
const {
|
|
93
99
|
contextValue,
|
|
@@ -147,7 +153,11 @@ SliderRoot.displayName = "SliderRoot";
|
|
|
147
153
|
*
|
|
148
154
|
* @throws if rendered outside a `Slider.Root`.
|
|
149
155
|
*/
|
|
150
|
-
function SliderTrack({
|
|
156
|
+
function SliderTrack({
|
|
157
|
+
children,
|
|
158
|
+
asChild = false,
|
|
159
|
+
...rest
|
|
160
|
+
}: SliderTrackProps): ReactElement {
|
|
151
161
|
const { orientation, disabled } = useSliderContext();
|
|
152
162
|
const trackProps = {
|
|
153
163
|
...rest,
|
|
@@ -178,7 +188,7 @@ function SliderRange({
|
|
|
178
188
|
asChild = false,
|
|
179
189
|
children,
|
|
180
190
|
...rest
|
|
181
|
-
}: SliderRangeProps) {
|
|
191
|
+
}: SliderRangeProps): ReactElement {
|
|
182
192
|
const { values, min, max, orientation, dir, inverted, disabled } =
|
|
183
193
|
useSliderContext();
|
|
184
194
|
const rangeProps = {
|
|
@@ -227,7 +237,7 @@ function SliderThumb({
|
|
|
227
237
|
asChild = false,
|
|
228
238
|
children,
|
|
229
239
|
...rest
|
|
230
|
-
}: SliderThumbProps) {
|
|
240
|
+
}: SliderThumbProps): ReactElement {
|
|
231
241
|
const {
|
|
232
242
|
ref,
|
|
233
243
|
value,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Context } from "react";
|
|
2
|
+
import { createStrictContext } from "../utils/index.ts";
|
|
2
3
|
|
|
3
4
|
import type { SliderDirection, SliderOrientation } from "./types";
|
|
4
5
|
|
|
@@ -17,8 +18,11 @@ export type SliderContextValue = {
|
|
|
17
18
|
commit: (values: number[]) => void;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const sliderContextPair = createStrictContext<SliderContextValue>(
|
|
22
|
+
"Slider sub-components must be rendered inside a <Slider.Root>.",
|
|
23
|
+
"SliderContext",
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const SliderContext: Context<SliderContextValue | null> =
|
|
27
|
+
sliderContextPair[0];
|
|
28
|
+
export const useSliderContext: () => SliderContextValue = sliderContextPair[1];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fireEvent, 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 { Slider } from "../Slider";
|
|
6
6
|
|
|
7
7
|
import { rtlKeyboardCases } from "./Slider.fixtures";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
2
|
import type { PointerEvent as ReactPointerEvent } from "react";
|
|
3
3
|
|
|
4
|
-
import { useCollection, useControllableState } from "../../hooks";
|
|
4
|
+
import { useCollection, useControllableState } from "../../hooks/index.ts";
|
|
5
5
|
import type { SliderContextValue } from "../SliderContext";
|
|
6
6
|
import type { SliderDirection, SliderOrientation } from "../types";
|
|
7
7
|
import { clamp, getClosestThumbIndex, getPointerValue } from "../utils";
|
package/src/Status/Status.tsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
import { Slot } from "../Slot/index.ts";
|
|
2
4
|
import { StatusProps } from "./types";
|
|
3
5
|
|
|
4
6
|
/**
|
|
@@ -31,7 +33,11 @@ import { StatusProps } from "./types";
|
|
|
31
33
|
* </Status>
|
|
32
34
|
* ```
|
|
33
35
|
*/
|
|
34
|
-
export function Status({
|
|
36
|
+
export function Status({
|
|
37
|
+
asChild = false,
|
|
38
|
+
children,
|
|
39
|
+
...rest
|
|
40
|
+
}: StatusProps): ReactElement {
|
|
35
41
|
const rootProps = { role: "status", ...rest };
|
|
36
42
|
|
|
37
43
|
if (asChild) {
|
package/src/Switch/Switch.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
+
import type { ReactElement } from "react";
|
|
2
3
|
|
|
3
|
-
import { Slot, composeEventHandlers } from "../Slot";
|
|
4
|
+
import { Slot, composeEventHandlers } from "../Slot/index.ts";
|
|
4
5
|
|
|
5
6
|
import { SwitchContext } from "./SwitchContext";
|
|
6
|
-
import { useSwitchContext, useSwitchRoot } from "./hooks";
|
|
7
|
+
import { useSwitchContext, useSwitchRoot } from "./hooks/index.ts";
|
|
7
8
|
import { SwitchRootProps, SwitchThumbProps } from "./types";
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -58,7 +59,7 @@ function SwitchRoot({
|
|
|
58
59
|
children,
|
|
59
60
|
ref,
|
|
60
61
|
...rest
|
|
61
|
-
}: SwitchRootProps) {
|
|
62
|
+
}: SwitchRootProps): ReactElement {
|
|
62
63
|
const { checked: isChecked, toggle } = useSwitchRoot({
|
|
63
64
|
defaultChecked,
|
|
64
65
|
checked,
|
|
@@ -111,7 +112,11 @@ SwitchRoot.displayName = "SwitchRoot";
|
|
|
111
112
|
*
|
|
112
113
|
* @throws if rendered outside a `Switch.Root`.
|
|
113
114
|
*/
|
|
114
|
-
function SwitchThumb({
|
|
115
|
+
function SwitchThumb({
|
|
116
|
+
children,
|
|
117
|
+
asChild = false,
|
|
118
|
+
...rest
|
|
119
|
+
}: SwitchThumbProps): ReactElement {
|
|
115
120
|
const { checked } = useSwitchContext();
|
|
116
121
|
const thumbProps = {
|
|
117
122
|
...rest,
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Context } from "react";
|
|
2
|
+
import { createStrictContext } from "../utils/index.ts";
|
|
2
3
|
|
|
3
4
|
export type SwitchContextValue = {
|
|
4
5
|
checked: boolean;
|
|
5
6
|
};
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const switchContextPair = createStrictContext<SwitchContextValue>(
|
|
9
|
+
"Switch.Thumb must be rendered inside a <Switch.Root>.",
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export const SwitchContext: Context<SwitchContextValue | null> =
|
|
13
|
+
switchContextPair[0];
|
|
14
|
+
export const useSwitchContext: () => SwitchContextValue = switchContextPair[1];
|
package/src/Table/Table.tsx
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
TableBodyProps,
|
|
3
5
|
TableCaptionProps,
|
|
@@ -40,7 +42,7 @@ import {
|
|
|
40
42
|
* </Table.Root>
|
|
41
43
|
* ```
|
|
42
44
|
*/
|
|
43
|
-
function Table({ children, ...rest }: TableRootProps) {
|
|
45
|
+
function Table({ children, ...rest }: TableRootProps): ReactElement {
|
|
44
46
|
return <table {...rest}>{children}</table>;
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -63,7 +65,7 @@ Table.displayName = "Table";
|
|
|
63
65
|
* </Table.Head>
|
|
64
66
|
* ```
|
|
65
67
|
*/
|
|
66
|
-
function TableHead({ children, ...rest }: TableHeadProps) {
|
|
68
|
+
function TableHead({ children, ...rest }: TableHeadProps): ReactElement {
|
|
67
69
|
return <thead {...rest}>{children}</thead>;
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -87,7 +89,7 @@ TableHead.displayName = "TableHead";
|
|
|
87
89
|
* </Table.Body>
|
|
88
90
|
* ```
|
|
89
91
|
*/
|
|
90
|
-
function TableBody({ children, ...rest }: TableBodyProps) {
|
|
92
|
+
function TableBody({ children, ...rest }: TableBodyProps): ReactElement {
|
|
91
93
|
return <tbody {...rest}>{children}</tbody>;
|
|
92
94
|
}
|
|
93
95
|
|
|
@@ -110,7 +112,7 @@ TableBody.displayName = "TableBody";
|
|
|
110
112
|
* </Table.Footer>
|
|
111
113
|
* ```
|
|
112
114
|
*/
|
|
113
|
-
function TableFooter({ children, ...rest }: TableFooterProps) {
|
|
115
|
+
function TableFooter({ children, ...rest }: TableFooterProps): ReactElement {
|
|
114
116
|
return <tfoot {...rest}>{children}</tfoot>;
|
|
115
117
|
}
|
|
116
118
|
|
|
@@ -132,7 +134,7 @@ TableFooter.displayName = "TableFooter";
|
|
|
132
134
|
* </Table.Row>
|
|
133
135
|
* ```
|
|
134
136
|
*/
|
|
135
|
-
function TableRow({ children, ...rest }: TableRowProps) {
|
|
137
|
+
function TableRow({ children, ...rest }: TableRowProps): ReactElement {
|
|
136
138
|
return <tr {...rest}>{children}</tr>;
|
|
137
139
|
}
|
|
138
140
|
|
|
@@ -166,7 +168,7 @@ TableRow.displayName = "TableRow";
|
|
|
166
168
|
* <Table.Header scope="row">Alice</Table.Header>
|
|
167
169
|
* ```
|
|
168
170
|
*/
|
|
169
|
-
function TableHeader({ children, ...rest }: TableHeaderProps) {
|
|
171
|
+
function TableHeader({ children, ...rest }: TableHeaderProps): ReactElement {
|
|
170
172
|
return <th {...rest}>{children}</th>;
|
|
171
173
|
}
|
|
172
174
|
|
|
@@ -188,7 +190,7 @@ TableHeader.displayName = "TableHeader";
|
|
|
188
190
|
* <Table.Cell colSpan={2}>Full-width note</Table.Cell>
|
|
189
191
|
* ```
|
|
190
192
|
*/
|
|
191
|
-
function TableCell({ children, ...rest }: TableCellProps) {
|
|
193
|
+
function TableCell({ children, ...rest }: TableCellProps): ReactElement {
|
|
192
194
|
return <td {...rest}>{children}</td>;
|
|
193
195
|
}
|
|
194
196
|
|
|
@@ -222,7 +224,11 @@ TableCell.displayName = "TableCell";
|
|
|
222
224
|
* </Table.ScrollArea>
|
|
223
225
|
* ```
|
|
224
226
|
*/
|
|
225
|
-
function TableScrollArea({
|
|
227
|
+
function TableScrollArea({
|
|
228
|
+
children,
|
|
229
|
+
style,
|
|
230
|
+
...rest
|
|
231
|
+
}: TableScrollAreaProps): ReactElement {
|
|
226
232
|
return (
|
|
227
233
|
<div
|
|
228
234
|
style={{
|
|
@@ -277,7 +283,7 @@ function TableCaption({
|
|
|
277
283
|
children,
|
|
278
284
|
captionSide = "bottom",
|
|
279
285
|
...rest
|
|
280
|
-
}: TableCaptionProps) {
|
|
286
|
+
}: TableCaptionProps): ReactElement {
|
|
281
287
|
return (
|
|
282
288
|
<caption style={{ captionSide }} {...rest}>
|
|
283
289
|
{children}
|