Skip to content

Commit b3007d7

Browse files
committed
fix(ssr): 🐛 use defaultProps for composition
1 parent b01e748 commit b3007d7

File tree

80 files changed

+421
-602
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+421
-602
lines changed

src/avatar-group/AvatarGroupWrapper.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
1-
import { GroupProps, useGroup } from "ariakit";
2-
import {
3-
createComponent,
4-
createElement,
5-
createHook,
6-
} from "ariakit-utils/system";
1+
import { GroupOptions, useGroup } from "ariakit";
2+
import { createElement, createHook } from "ariakit-utils/system";
73
import { As, Props } from "ariakit-utils/types";
84

9-
import { BoxOptions } from "../box";
5+
import { BoxOptions, useBox } from "../box";
106
import { useTheme } from "../theme";
11-
import { tcm } from "../utils";
7+
import { createComponent, cx } from "../utils";
128

139
import { AvatarGroupUIProps } from "./AvatarGroupProps";
1410

1511
export const useAvatarGroupWrapper = createHook<AvatarGroupWrapperOptions>(
1612
({ size, squared, showRing, ringColor, max, ...props }) => {
1713
const theme = useTheme("avatar");
18-
const className = tcm(
14+
const className = cx(
1915
theme.group.base,
2016
size ? theme.group.size[size] : "",
2117
props.className,
2218
);
2319

2420
props = { "aria-label": "avatar group", ...props, className };
2521
props = useGroup(props);
22+
props = useBox(props);
2623

2724
return props;
2825
},
@@ -34,10 +31,11 @@ export const AvatarGroupWrapper = createComponent<AvatarGroupWrapperOptions>(
3431

3532
return createElement("div", htmlProps);
3633
},
34+
"AvatarGroupWrapper",
3735
);
3836

3937
export type AvatarGroupWrapperOptions<T extends As = "div"> = BoxOptions<T> &
40-
GroupProps<T> &
38+
GroupOptions<T> &
4139
Partial<AvatarGroupUIProps> & {};
4240

4341
export type AvatarGroupWrapperProps<T extends As = "div"> = Props<

src/avatar/AvatarIcon.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import {
2-
createComponent,
3-
createElement,
4-
createHook,
5-
} from "ariakit-utils/system";
1+
import { createElement, createHook } from "ariakit-utils/system";
62
import { As, Props } from "ariakit-utils/types";
73

84
import { BoxOptions, useBox } from "../box";
95
import { useTheme } from "../theme";
10-
import { cx } from "../utils";
6+
import { createComponent, cx } from "../utils";
117

128
import { AvatarUIProps } from "./AvatarProps";
139

@@ -51,7 +47,7 @@ export const AvatarIcon = createComponent<AvatarIconOptions>(props => {
5147
const htmlProps = useAvatarIcon(props);
5248

5349
return createElement("span", htmlProps);
54-
});
50+
}, "AvatarIcon");
5551

5652
export type AvatarIconOptions<T extends As = "span"> = BoxOptions<T> &
5753
Partial<AvatarUIProps> & {};

src/avatar/AvatarImage.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import {
2-
createComponent,
3-
createElement,
4-
createHook,
5-
} from "ariakit-utils/system";
1+
import { createElement, createHook } from "ariakit-utils/system";
62
import { As, Props } from "ariakit-utils/types";
73

84
import { BoxOptions, useBox } from "../box";
95
import { useTheme } from "../theme";
10-
import { cx } from "../utils";
6+
import { createComponent, cx } from "../utils";
117

128
import { AvatarUIProps } from "./AvatarProps";
139

@@ -51,7 +47,7 @@ export const AvatarImage = createComponent<AvatarImageOptions>(props => {
5147
const htmlProps = useAvatarImage(props);
5248

5349
return createElement("img", htmlProps);
54-
});
50+
}, "AvatarImage");
5551

5652
export type AvatarImageOptions<T extends As = "img"> = BoxOptions<T> &
5753
Partial<AvatarUIProps> & {};

src/avatar/AvatarInitials.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import {
2-
createComponent,
3-
createElement,
4-
createHook,
5-
} from "ariakit-utils/system";
1+
import { createElement, createHook } from "ariakit-utils/system";
62
import { As, Props } from "ariakit-utils/types";
73

84
import { BoxOptions, useBox } from "../box";
95
import { useTheme } from "../theme";
10-
import { cx } from "../utils";
6+
import { createComponent, cx } from "../utils";
117

128
import { AvatarUIProps } from "./AvatarProps";
139

@@ -52,7 +48,7 @@ export const AvatarInitials = createComponent<AvatarInitialsOptions>(props => {
5248
const htmlProps = useAvatarInitials(props);
5349

5450
return createElement("span", htmlProps);
55-
});
51+
}, "AvatarInitials");
5652

5753
export type AvatarInitialsOptions<T extends As = "span"> = BoxOptions<T> &
5854
Partial<AvatarUIProps> & {};

src/avatar/AvatarStatusIndicator.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import {
2-
createComponent,
3-
createElement,
4-
createHook,
5-
} from "ariakit-utils/system";
1+
import { createElement, createHook } from "ariakit-utils/system";
62
import { As, Props } from "ariakit-utils/types";
73

84
import { BoxOptions, useBox } from "../box";
95
import { useTheme } from "../theme";
10-
import { cx } from "../utils";
6+
import { createComponent, cx } from "../utils";
117

128
import { AvatarUIProps } from "./AvatarProps";
139

@@ -45,7 +41,7 @@ export const AvatarStatusIndicator =
4541
const htmlProps = useAvatarStatusIndicator(props);
4642

4743
return createElement("div", htmlProps);
48-
});
44+
}, "AvatarStatusIndicator");
4945

5046
export type AvatarStatusIndicatorOptions<T extends As = "div"> = BoxOptions<T> &
5147
Partial<AvatarUIProps> & {};

src/avatar/AvatarWrapper.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import {
2-
createComponent,
3-
createElement,
4-
createHook,
5-
} from "ariakit-utils/system";
1+
import { createElement, createHook } from "ariakit-utils/system";
62
import { As, Props } from "ariakit-utils/types";
73

84
import { BoxOptions, useBox } from "../box";
95
import { useTheme } from "../theme";
10-
import { cx } from "../utils";
6+
import { createComponent, cx } from "../utils";
117

128
import { AvatarUIProps } from "./AvatarProps";
139

@@ -50,7 +46,7 @@ export const AvatarWrapper = createComponent<AvatarWrapperOptions>(props => {
5046
const htmlProps = useAvatarWrapper(props);
5147

5248
return createElement("span", htmlProps);
53-
});
49+
}, "AvatarWrapper");
5450

5551
export type AvatarWrapperOptions<T extends As = "span"> = BoxOptions<T> &
5652
Partial<AvatarUIProps> & {};

src/badge/Badge.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import {
2-
createComponent,
3-
createElement,
4-
createHook,
5-
} from "ariakit-utils/system";
1+
import { createElement, createHook } from "ariakit-utils/system";
62
import { As, Props } from "ariakit-utils/types";
73

84
import { Box, BoxOptions, useBox } from "../box";
95
import { useTheme } from "../theme";
10-
import { cx, RenderProp, withIconA11y } from "../utils";
6+
import { createComponent, cx, RenderProp, withIconA11y } from "../utils";
117

128
export const useBadge = createHook<BadgeOptions>(
139
({
@@ -52,7 +48,7 @@ export const Badge = createComponent<BadgeOptions>(props => {
5248
const htmlProps = useBadge(props);
5349

5450
return createElement("div", htmlProps);
55-
});
51+
}, "Badge");
5652

5753
export type BadgeState = {
5854
/**

src/box/Box.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import { RoleOptions, useRole } from "ariakit";
2-
import {
3-
createComponent,
4-
createElement,
5-
createHook,
6-
} from "ariakit-utils/system";
1+
import { useRole } from "ariakit";
2+
import { createElement, createHook } from "ariakit-utils/system";
73
import { As, Props } from "ariakit-utils/types";
84

9-
import { tcm } from "../utils";
5+
import { ComponentOptions, createComponent, tcm } from "../utils";
106

11-
export const useBox = createHook<BoxOptions>(props => {
7+
export const useBox = createHook<BoxOptions>(({ __TYPE__, ...props }) => {
128
props = { ...props, className: tcm(props.className) };
139
props = useRole(props);
1410

@@ -19,8 +15,8 @@ export const Box = createComponent<BoxOptions>(props => {
1915
const htmlProps = useBox(props);
2016

2117
return createElement("div", htmlProps);
22-
});
18+
}, "Box");
2319

24-
export type BoxOptions<T extends As = "div"> = RoleOptions<T>;
20+
export type BoxOptions<T extends As = "div"> = ComponentOptions<T>;
2521

2622
export type BoxProps<T extends As = "div"> = Props<BoxOptions<T>>;

src/button-group/ButtonGroup.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { cx, useWrapElement } from "ariakit-utils";
2-
import {
3-
createComponent,
4-
createElement,
5-
createHook,
6-
} from "ariakit-utils/system";
2+
import { createElement, createHook } from "ariakit-utils/system";
73
import { As, Props } from "ariakit-utils/types";
84

95
import { BoxOptions, useBox } from "../box";
106
import { ButtonProps } from "../button";
117
import { useTheme } from "../theme";
8+
import { createComponent } from "../utils";
129

1310
import { ButtonGroupContextProvider } from "./__utils";
1411

@@ -55,7 +52,7 @@ export const ButtonGroup = createComponent<ButtonGroupOptions>(props => {
5552
const htmlProps = useButtonGroup(props);
5653

5754
return createElement("div", htmlProps);
58-
});
55+
}, "ButtonGroup");
5956

6057
export type ButtonGroupOptions<T extends As = "div"> = BoxOptions<T> &
6158
Pick<ButtonProps, "size" | "themeColor" | "variant"> & {

src/button/Button.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@ import {
33
ButtonOptions as AriakitButtonOptions,
44
useButton as useAriakitButton,
55
} from "ariakit";
6-
import {
7-
createComponent,
8-
createElement,
9-
createHook,
10-
} from "ariakit-utils/system";
6+
import { createElement, createHook } from "ariakit-utils/system";
117
import { As, Props } from "ariakit-utils/types";
128
import { announce } from "@react-aria/live-announcer";
139

14-
import { Box } from "../box";
10+
import { Box, BoxOptions, useBox } from "../box";
1511
import { useButtonGroupContext } from "../button-group";
1612
import { usePrevious } from "../hooks";
1713
import { Spinner } from "../spinner";
1814
import { useTheme } from "../theme";
19-
import { cx, RenderProp, tcm, withIconA11y } from "../utils";
15+
import { createComponent, cx, RenderProp, tcm, withIconA11y } from "../utils";
2016

2117
import { ButtonFullWidthSpinner, ButtonSpinner } from "./ButtonSpinner";
2218

@@ -130,6 +126,7 @@ export const useButton = createHook<ButtonOptions>(
130126
);
131127
props = { ...props, className, children, disabled };
132128
props = useAriakitButton(props);
129+
props = useBox(props);
133130

134131
return props;
135132
},
@@ -139,7 +136,7 @@ export const Button = createComponent<ButtonOptions>(props => {
139136
const htmlProps = useButton(props);
140137

141138
return createElement("button", htmlProps);
142-
});
139+
}, "Button");
143140

144141
export type ButtonState = {
145142
/**
@@ -195,10 +192,8 @@ export type ButtonState = {
195192

196193
export type ButtonRenderProps = Pick<ButtonProps, "className" | "disabled">;
197194

198-
export type ButtonOptions<T extends As = "button"> = Omit<
199-
AriakitButtonOptions<T>,
200-
"size" | "prefix"
201-
> &
195+
export type ButtonOptions<T extends As = "button"> = BoxOptions<T> &
196+
Omit<AriakitButtonOptions<T>, "size" | "prefix"> &
202197
Partial<ButtonState>;
203198

204199
export type ButtonProps<T extends As = "button"> = Props<ButtonOptions<T>>;

0 commit comments

Comments
 (0)