@seed-design/react 0.0.4 → 0.0.6
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/lib/components/ActionButton/ActionButton.cjs +6 -6
- package/lib/components/ActionButton/ActionButton.d.ts.map +1 -1
- package/lib/components/ActionButton/ActionButton.js +6 -6
- package/lib/components/ActionChip/ActionChip.cjs +4 -4
- package/lib/components/ActionChip/ActionChip.d.ts +1 -1
- package/lib/components/ActionChip/ActionChip.d.ts.map +1 -1
- package/lib/components/ActionChip/ActionChip.js +4 -4
- package/lib/components/ActionSheet/ActionSheet.cjs +7 -7
- package/lib/components/ActionSheet/ActionSheet.d.ts +2 -2
- package/lib/components/ActionSheet/ActionSheet.d.ts.map +1 -1
- package/lib/components/ActionSheet/ActionSheet.js +7 -7
- package/lib/components/Avatar/Avatar.cjs +2 -2
- package/lib/components/Avatar/Avatar.js +2 -2
- package/lib/components/Badge/Badge.cjs +3 -3
- package/lib/components/Badge/Badge.d.ts.map +1 -1
- package/lib/components/Badge/Badge.js +3 -3
- package/lib/components/BottomSheet/BottomSheet.cjs +2 -2
- package/lib/components/BottomSheet/BottomSheet.js +2 -2
- package/lib/components/Callout/Callout.cjs +2 -2
- package/lib/components/Callout/Callout.js +2 -2
- package/lib/components/Checkbox/Checkbox.cjs +2 -2
- package/lib/components/Checkbox/Checkbox.js +2 -2
- package/lib/components/ChipTabs/ChipTabs.cjs +2 -2
- package/lib/components/ChipTabs/ChipTabs.js +2 -2
- package/lib/components/ControlChip/ControlChip.cjs +3 -3
- package/lib/components/ControlChip/ControlChip.js +3 -3
- package/lib/components/Dialog/Dialog.cjs +2 -2
- package/lib/components/Dialog/Dialog.js +2 -2
- package/lib/components/ExtendedActionSheet/ExtendedActionSheet.cjs +5 -4
- package/lib/components/ExtendedActionSheet/ExtendedActionSheet.d.ts.map +1 -1
- package/lib/components/ExtendedActionSheet/ExtendedActionSheet.js +5 -4
- package/lib/components/ExtendedFab/ExtendedFab.cjs +7 -11
- package/lib/components/ExtendedFab/ExtendedFab.d.ts.map +1 -1
- package/lib/components/ExtendedFab/ExtendedFab.js +7 -11
- package/lib/components/Fab/Fab.cjs +3 -3
- package/lib/components/Fab/Fab.d.ts.map +1 -1
- package/lib/components/Fab/Fab.js +3 -3
- package/lib/components/HelpBubble/HelpBubble.cjs +8 -3
- package/lib/components/HelpBubble/HelpBubble.d.ts.map +1 -1
- package/lib/components/HelpBubble/HelpBubble.js +8 -3
- package/lib/components/IdentityPlaceholder/IdentityPlaceholder.cjs +2 -2
- package/lib/components/IdentityPlaceholder/IdentityPlaceholder.js +2 -2
- package/lib/components/InlineBanner/InlineBanner.cjs +2 -2
- package/lib/components/InlineBanner/InlineBanner.js +2 -2
- package/lib/components/LinkContent/LinkContent.cjs +3 -4
- package/lib/components/LinkContent/LinkContent.d.ts.map +1 -1
- package/lib/components/LinkContent/LinkContent.js +3 -4
- package/lib/components/LoadingIndicator/usePendingButton.d.ts +57 -57
- package/lib/components/MannerTempBadge/MannerTempBadge.cjs +4 -7
- package/lib/components/MannerTempBadge/MannerTempBadge.d.ts +1 -1
- package/lib/components/MannerTempBadge/MannerTempBadge.d.ts.map +1 -1
- package/lib/components/MannerTempBadge/MannerTempBadge.js +4 -7
- package/lib/components/ProgressCircle/ProgressCircle.cjs +2 -2
- package/lib/components/ProgressCircle/ProgressCircle.js +2 -2
- package/lib/components/PullToRefresh/PullToRefresh.cjs +2 -2
- package/lib/components/PullToRefresh/PullToRefresh.js +2 -2
- package/lib/components/ReactionButton/ReactionButton.cjs +5 -5
- package/lib/components/ReactionButton/ReactionButton.js +5 -5
- package/lib/components/SegmentedControl/SegmentedControl.cjs +2 -2
- package/lib/components/SegmentedControl/SegmentedControl.js +2 -2
- package/lib/components/SelectBox/CheckSelectBox.cjs +8 -8
- package/lib/components/SelectBox/CheckSelectBox.d.ts.map +1 -1
- package/lib/components/SelectBox/CheckSelectBox.js +8 -8
- package/lib/components/SelectBox/RadioSelectBox.cjs +7 -7
- package/lib/components/SelectBox/RadioSelectBox.d.ts.map +1 -1
- package/lib/components/SelectBox/RadioSelectBox.js +7 -7
- package/lib/components/Skeleton/Skeleton.cjs +3 -6
- package/lib/components/Skeleton/Skeleton.d.ts.map +1 -1
- package/lib/components/Skeleton/Skeleton.js +3 -6
- package/lib/components/Snackbar/Snackbar.cjs +20 -24
- package/lib/components/Snackbar/Snackbar.d.ts +3 -3
- package/lib/components/Snackbar/Snackbar.d.ts.map +1 -1
- package/lib/components/Snackbar/Snackbar.js +21 -25
- package/lib/components/Snackbar/Snackbar.namespace.cjs +1 -1
- package/lib/components/Snackbar/Snackbar.namespace.d.ts +1 -1
- package/lib/components/Snackbar/Snackbar.namespace.d.ts.map +1 -1
- package/lib/components/Snackbar/Snackbar.namespace.js +1 -1
- package/lib/components/Snackbar/index.cjs +1 -1
- package/lib/components/Snackbar/index.d.ts +1 -1
- package/lib/components/Snackbar/index.d.ts.map +1 -1
- package/lib/components/Snackbar/index.js +1 -1
- package/lib/components/Switch/Switch.cjs +2 -2
- package/lib/components/Switch/Switch.js +2 -2
- package/lib/components/Tabs/Tabs.cjs +2 -2
- package/lib/components/Tabs/Tabs.js +2 -2
- package/lib/components/Text/Text.cjs +2 -2
- package/lib/components/Text/Text.js +2 -2
- package/lib/components/TextField/TextField.cjs +2 -2
- package/lib/components/TextField/TextField.js +2 -2
- package/lib/components/ToggleButton/ToggleButton.cjs +5 -5
- package/lib/components/ToggleButton/ToggleButton.js +5 -5
- package/lib/components/VisuallyHidden/VisuallyHidden.cjs +8 -8
- package/lib/components/VisuallyHidden/VisuallyHidden.d.ts.map +1 -1
- package/lib/components/VisuallyHidden/VisuallyHidden.js +7 -7
- package/lib/components/index.cjs +1 -1
- package/lib/components/index.js +1 -1
- package/lib/components/private/useDismissible.d.ts +123 -123
- package/lib/index.cjs +1 -1
- package/lib/index.js +1 -1
- package/lib/utils/createRecipeContext.cjs +74 -0
- package/lib/utils/createRecipeContext.d.ts +24 -0
- package/lib/utils/createRecipeContext.d.ts.map +1 -0
- package/lib/utils/createRecipeContext.js +70 -0
- package/lib/utils/{createStyleContext.cjs → createSlotRecipeContext.cjs} +2 -2
- package/lib/utils/{createStyleContext.d.ts → createSlotRecipeContext.d.ts} +3 -3
- package/lib/utils/createSlotRecipeContext.d.ts.map +1 -0
- package/lib/utils/{createStyleContext.js → createSlotRecipeContext.js} +2 -2
- package/package.json +3 -3
- package/src/components/ActionButton/ActionButton.tsx +7 -7
- package/src/components/ActionChip/ActionChip.tsx +4 -4
- package/src/components/ActionSheet/ActionSheet.tsx +6 -6
- package/src/components/Avatar/Avatar.tsx +2 -2
- package/src/components/Badge/Badge.tsx +3 -3
- package/src/components/BottomSheet/BottomSheet.tsx +2 -2
- package/src/components/Callout/Callout.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +2 -2
- package/src/components/ChipTabs/ChipTabs.tsx +2 -2
- package/src/components/ControlChip/ControlChip.tsx +3 -3
- package/src/components/Dialog/Dialog.tsx +2 -2
- package/src/components/ExtendedActionSheet/ExtendedActionSheet.tsx +5 -4
- package/src/components/ExtendedFab/ExtendedFab.tsx +7 -11
- package/src/components/Fab/Fab.tsx +3 -3
- package/src/components/HelpBubble/HelpBubble.tsx +7 -4
- package/src/components/IdentityPlaceholder/IdentityPlaceholder.tsx +2 -2
- package/src/components/InlineBanner/InlineBanner.tsx +2 -2
- package/src/components/LinkContent/LinkContent.tsx +2 -4
- package/src/components/MannerTempBadge/MannerTempBadge.tsx +4 -7
- package/src/components/ProgressCircle/ProgressCircle.tsx +2 -2
- package/src/components/PullToRefresh/PullToRefresh.tsx +2 -2
- package/src/components/ReactionButton/ReactionButton.tsx +6 -6
- package/src/components/SegmentedControl/SegmentedControl.tsx +2 -2
- package/src/components/SelectBox/CheckSelectBox.tsx +7 -7
- package/src/components/SelectBox/RadioSelectBox.tsx +6 -6
- package/src/components/Skeleton/Skeleton.tsx +3 -6
- package/src/components/Snackbar/Snackbar.namespace.ts +2 -2
- package/src/components/Snackbar/Snackbar.tsx +22 -23
- package/src/components/Snackbar/index.ts +2 -2
- package/src/components/Switch/Switch.tsx +2 -2
- package/src/components/Tabs/Tabs.tsx +2 -2
- package/src/components/Text/Text.tsx +2 -2
- package/src/components/TextField/TextField.tsx +2 -2
- package/src/components/ToggleButton/ToggleButton.tsx +6 -6
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +6 -8
- package/src/utils/createRecipeContext.tsx +114 -0
- package/src/utils/{createStyleContext.tsx → createSlotRecipeContext.tsx} +3 -3
- package/lib/utils/createStyleContext.d.ts.map +0 -1
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
import { mergeProps } from "@seed-design/dom-utils";
|
|
6
6
|
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
7
7
|
import * as React from "react";
|
|
8
|
-
import {
|
|
8
|
+
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
9
9
|
|
|
10
|
-
const { useClassNames, withProvider } =
|
|
10
|
+
const { useClassNames, withProvider } = createSlotRecipeContext(identityPlaceholder);
|
|
11
11
|
|
|
12
12
|
export interface IdentityPlaceholderRootProps
|
|
13
13
|
extends IdentityPlaceholderVariantProps,
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
type InlineBannerVariantProps,
|
|
6
6
|
} from "@seed-design/css/recipes/inline-banner";
|
|
7
7
|
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
8
|
-
import {
|
|
8
|
+
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
9
9
|
import {
|
|
10
10
|
DismissibleCloseButton,
|
|
11
11
|
DismissibleRoot,
|
|
12
12
|
type DismissibleRootProps,
|
|
13
13
|
} from "../private/useDismissible";
|
|
14
14
|
|
|
15
|
-
const { withContext, withProvider } =
|
|
15
|
+
const { withContext, withProvider } = createSlotRecipeContext(inlineBanner);
|
|
16
16
|
|
|
17
17
|
export interface InlineBannerRootProps extends InlineBannerVariantProps, DismissibleRootProps {}
|
|
18
18
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { linkContent, type LinkContentVariantProps } from "@seed-design/css/recipes/link-content";
|
|
2
2
|
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { createRecipeContext } from "../../utils/createRecipeContext";
|
|
5
4
|
import type * as React from "react";
|
|
6
5
|
import { withStyleProps, type StyleProps } from "../../utils/styled";
|
|
7
6
|
|
|
8
|
-
const { withProvider } =
|
|
7
|
+
const { withProvider } = createRecipeContext(linkContent);
|
|
9
8
|
|
|
10
9
|
export interface LinkContentProps
|
|
11
10
|
extends LinkContentVariantProps,
|
|
@@ -15,5 +14,4 @@ export interface LinkContentProps
|
|
|
15
14
|
|
|
16
15
|
export const LinkContent = withProvider<HTMLButtonElement, LinkContentProps>(
|
|
17
16
|
withStyleProps(Primitive.span),
|
|
18
|
-
"root",
|
|
19
17
|
);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
2
1
|
import {
|
|
3
2
|
mannerTempBadge,
|
|
4
3
|
type MannerTempBadgeVariantProps,
|
|
5
4
|
} from "@seed-design/css/recipes/manner-temp-badge";
|
|
5
|
+
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
6
6
|
import type * as React from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { createRecipeContext } from "../../utils/createRecipeContext";
|
|
8
8
|
|
|
9
|
-
const { withProvider } =
|
|
9
|
+
const { withProvider } = createRecipeContext(mannerTempBadge);
|
|
10
10
|
|
|
11
11
|
////////////////////////////////////////////////////////////////////////////////////
|
|
12
12
|
|
|
@@ -15,7 +15,4 @@ export interface MannerTempBadgeProps
|
|
|
15
15
|
PrimitiveProps,
|
|
16
16
|
React.HTMLAttributes<HTMLSpanElement> {}
|
|
17
17
|
|
|
18
|
-
export const MannerTempBadge = withProvider<HTMLSpanElement, MannerTempBadgeProps>(
|
|
19
|
-
Primitive.span,
|
|
20
|
-
"root",
|
|
21
|
-
);
|
|
18
|
+
export const MannerTempBadge = withProvider<HTMLSpanElement, MannerTempBadgeProps>(Primitive.span);
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
progressCircle,
|
|
4
4
|
type ProgressCircleVariantProps,
|
|
5
5
|
} from "@seed-design/css/recipes/progress-circle";
|
|
6
|
-
import {
|
|
6
|
+
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
7
7
|
|
|
8
|
-
const { withContext, withProvider } =
|
|
8
|
+
const { withContext, withProvider } = createSlotRecipeContext(progressCircle);
|
|
9
9
|
|
|
10
10
|
export interface ProgressCircleRootProps
|
|
11
11
|
extends ProgressCirclePrimitive.RootProps,
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
pullToRefresh,
|
|
4
4
|
type PullToRefreshVariantProps,
|
|
5
5
|
} from "@seed-design/css/recipes/pull-to-refresh";
|
|
6
|
-
import {
|
|
6
|
+
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
7
7
|
|
|
8
|
-
const { withContext, withProvider } =
|
|
8
|
+
const { withContext, withProvider } = createSlotRecipeContext(pullToRefresh);
|
|
9
9
|
|
|
10
10
|
export interface PullToRefreshRootProps
|
|
11
11
|
extends PullToRefreshVariantProps,
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
import { Toggle as TogglePrimitive } from "@seed-design/react-toggle";
|
|
6
6
|
import clsx from "clsx";
|
|
7
7
|
import * as React from "react";
|
|
8
|
-
import {
|
|
8
|
+
import { createRecipeContext } from "../../utils/createRecipeContext";
|
|
9
9
|
import {
|
|
10
10
|
PendingButtonProvider,
|
|
11
11
|
usePendingButton,
|
|
12
12
|
type UsePendingButtonProps,
|
|
13
13
|
} from "../LoadingIndicator/usePendingButton";
|
|
14
14
|
|
|
15
|
-
const {
|
|
15
|
+
const { ClassNameProvider } = createRecipeContext(reactionButton);
|
|
16
16
|
|
|
17
17
|
export interface ReactionButtonProps
|
|
18
18
|
extends ReactionButtonVariantProps,
|
|
@@ -21,20 +21,20 @@ export interface ReactionButtonProps
|
|
|
21
21
|
|
|
22
22
|
export const ReactionButton = React.forwardRef<HTMLButtonElement, ReactionButtonProps>(
|
|
23
23
|
({ size = "small", loading = false, className, ...otherProps }, ref) => {
|
|
24
|
-
const
|
|
24
|
+
const recipeClassName = reactionButton({ size });
|
|
25
25
|
const api = usePendingButton({ loading, disabled: otherProps.disabled });
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
|
-
<
|
|
28
|
+
<ClassNameProvider value={recipeClassName}>
|
|
29
29
|
<PendingButtonProvider value={api}>
|
|
30
30
|
<TogglePrimitive.Root
|
|
31
31
|
ref={ref}
|
|
32
|
-
className={clsx(
|
|
32
|
+
className={clsx(recipeClassName, className)}
|
|
33
33
|
{...api.stateProps}
|
|
34
34
|
{...otherProps}
|
|
35
35
|
/>
|
|
36
36
|
</PendingButtonProvider>
|
|
37
|
-
</
|
|
37
|
+
</ClassNameProvider>
|
|
38
38
|
);
|
|
39
39
|
},
|
|
40
40
|
);
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
} from "@seed-design/css/recipes/segmented-control";
|
|
5
5
|
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
6
6
|
import { SegmentedControl as SegmentedControlPrimitive } from "@seed-design/react-segmented-control";
|
|
7
|
-
import {
|
|
7
|
+
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
8
8
|
|
|
9
|
-
const { withProvider, withContext } =
|
|
9
|
+
const { withProvider, withContext } = createSlotRecipeContext(segmentedControl);
|
|
10
10
|
|
|
11
11
|
export interface SegmentedControlRootProps
|
|
12
12
|
extends SegmentedControlVariantProps,
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { Checkbox as CheckboxPrimitive, useCheckboxContext } from "@seed-design/react-checkbox";
|
|
2
|
-
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
3
1
|
import { selectBox } from "@seed-design/css/recipes/select-box";
|
|
4
2
|
import { selectBoxGroup } from "@seed-design/css/recipes/select-box-group";
|
|
5
|
-
import {
|
|
3
|
+
import { Checkbox as CheckboxPrimitive, useCheckboxContext } from "@seed-design/react-checkbox";
|
|
4
|
+
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
5
|
+
import { forwardRef } from "react";
|
|
6
|
+
import { createRecipeContext } from "../../utils/createRecipeContext";
|
|
7
|
+
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
6
8
|
import { createWithStateProps } from "../../utils/createWithStateProps";
|
|
7
9
|
import { InternalIcon, type InternalIconProps } from "../private/Icon";
|
|
8
|
-
import { forwardRef } from "react";
|
|
9
10
|
|
|
10
|
-
const { withProvider: withGroupProvider } =
|
|
11
|
-
const { withProvider, withContext } =
|
|
11
|
+
const { withProvider: withGroupProvider } = createRecipeContext(selectBoxGroup);
|
|
12
|
+
const { withProvider, withContext } = createSlotRecipeContext(selectBox);
|
|
12
13
|
const withStateProps = createWithStateProps([useCheckboxContext]);
|
|
13
14
|
|
|
14
15
|
export interface CheckSelectBoxGroupProps
|
|
@@ -23,7 +24,6 @@ export const CheckSelectBoxGroup = withGroupProvider<HTMLDivElement, CheckSelect
|
|
|
23
24
|
forwardRef<HTMLDivElement, CheckSelectBoxGroupProps>((props, ref) => (
|
|
24
25
|
<Primitive.div ref={ref} role="group" {...props} />
|
|
25
26
|
)),
|
|
26
|
-
"root",
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
export interface CheckSelectBoxRootProps extends CheckboxPrimitive.RootProps {}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
+
import { selectBox } from "@seed-design/css/recipes/select-box";
|
|
2
|
+
import { selectBoxGroup } from "@seed-design/css/recipes/select-box-group";
|
|
1
3
|
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
2
4
|
import {
|
|
3
5
|
RadioGroup as RadioGroupPrimitive,
|
|
4
6
|
useRadioGroupItemContext,
|
|
5
7
|
} from "@seed-design/react-radio-group";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { createStyleContext } from "../../utils/createStyleContext";
|
|
8
|
+
import { createRecipeContext } from "../../utils/createRecipeContext";
|
|
9
|
+
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
9
10
|
import { createWithStateProps } from "../../utils/createWithStateProps";
|
|
10
11
|
import { InternalIcon, type InternalIconProps } from "../private/Icon";
|
|
11
12
|
|
|
12
|
-
const { withProvider: withGroupProvider } =
|
|
13
|
-
const { withProvider, withContext } =
|
|
13
|
+
const { withProvider: withGroupProvider } = createRecipeContext(selectBoxGroup);
|
|
14
|
+
const { withProvider, withContext } = createSlotRecipeContext(selectBox);
|
|
14
15
|
const withStateProps = createWithStateProps([useRadioGroupItemContext]);
|
|
15
16
|
|
|
16
17
|
export interface RadioSelectBoxRootProps extends RadioGroupPrimitive.RootProps {}
|
|
17
18
|
|
|
18
19
|
export const RadioSelectBoxRoot = withGroupProvider<HTMLDivElement, RadioSelectBoxRootProps>(
|
|
19
20
|
RadioGroupPrimitive.Root,
|
|
20
|
-
"root",
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
export interface RadioSelectBoxItemProps extends RadioGroupPrimitive.ItemProps {}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
2
2
|
import { skeleton, type SkeletonVariantProps } from "@seed-design/css/recipes/skeleton";
|
|
3
3
|
import type * as React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { createRecipeContext } from "../../utils/createRecipeContext";
|
|
5
5
|
import { withStyleProps, type StyleProps } from "../../utils/styled";
|
|
6
6
|
|
|
7
|
-
const { withProvider } =
|
|
7
|
+
const { withProvider } = createRecipeContext(skeleton);
|
|
8
8
|
|
|
9
9
|
export interface SkeletonProps
|
|
10
10
|
extends SkeletonVariantProps,
|
|
@@ -12,7 +12,4 @@ export interface SkeletonProps
|
|
|
12
12
|
Pick<StyleProps, "height" | "width">,
|
|
13
13
|
Omit<React.HTMLAttributes<HTMLDivElement>, "color"> {}
|
|
14
14
|
|
|
15
|
-
export const Skeleton = withProvider<HTMLDivElement, SkeletonProps>(
|
|
16
|
-
withStyleProps(Primitive.div),
|
|
17
|
-
"root",
|
|
18
|
-
);
|
|
15
|
+
export const Skeleton = withProvider<HTMLDivElement, SkeletonProps>(withStyleProps(Primitive.div));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export {
|
|
2
2
|
SnackbarActionButton as ActionButton,
|
|
3
3
|
SnackbarAvoidOverlap as AvoidOverlap,
|
|
4
|
-
|
|
4
|
+
SnackbarHiddenCloseButton as HiddenCloseButton,
|
|
5
5
|
SnackbarMessage as Message,
|
|
6
6
|
SnackbarPrefixIcon as PrefixIcon,
|
|
7
7
|
SnackbarRegion as Region,
|
|
@@ -10,7 +10,7 @@ export {
|
|
|
10
10
|
SnackbarRootProvider as RootProvider,
|
|
11
11
|
type SnackbarActionButtonProps as ActionButtonProps,
|
|
12
12
|
type SnackbarAvoidOverlapProps as AvoidOverlapProps,
|
|
13
|
-
type
|
|
13
|
+
type SnackbarHiddenCloseButtonProps as HiddenCloseButtonProps,
|
|
14
14
|
type SnackbarMessageProps as MessageProps,
|
|
15
15
|
type SnackbarPrefixIconProps as PrefixIconProps,
|
|
16
16
|
type SnackbarRegionProps as RegionProps,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
2
|
-
import { Snackbar as SnackbarPrimitive } from "@seed-design/react-snackbar";
|
|
3
1
|
import { snackbar, type SnackbarVariantProps } from "@seed-design/css/recipes/snackbar";
|
|
4
2
|
import { snackbarRegion } from "@seed-design/css/recipes/snackbar-region";
|
|
5
|
-
import { visuallyHidden } from "@seed-design/
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { visuallyHidden } from "@seed-design/dom-utils";
|
|
4
|
+
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
5
|
+
import { Snackbar as SnackbarPrimitive } from "@seed-design/react-snackbar";
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
|
+
import { createRecipeContext } from "../../utils/createRecipeContext";
|
|
8
|
+
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
9
9
|
import { InternalIcon, type InternalIconProps } from "../private/Icon";
|
|
10
10
|
|
|
11
|
-
const { withProvider: withRegionProvider } =
|
|
12
|
-
const { withProvider, withContext } =
|
|
11
|
+
const { withProvider: withRegionProvider } = createRecipeContext(snackbarRegion);
|
|
12
|
+
const { withProvider, withContext } = createSlotRecipeContext(snackbar);
|
|
13
13
|
|
|
14
14
|
////////////////////////////////////////////////////////////////////////////////////
|
|
15
15
|
|
|
@@ -23,7 +23,6 @@ export interface SnackbarRegionProps extends SnackbarVariantProps, SnackbarPrimi
|
|
|
23
23
|
|
|
24
24
|
export const SnackbarRegion = withRegionProvider<HTMLDivElement, SnackbarRegionProps>(
|
|
25
25
|
SnackbarPrimitive.Region,
|
|
26
|
-
"root",
|
|
27
26
|
);
|
|
28
27
|
|
|
29
28
|
////////////////////////////////////////////////////////////////////////////////////
|
|
@@ -68,24 +67,24 @@ export const SnackbarActionButton = withContext<HTMLButtonElement, SnackbarActio
|
|
|
68
67
|
|
|
69
68
|
////////////////////////////////////////////////////////////////////////////////////
|
|
70
69
|
|
|
71
|
-
export interface
|
|
70
|
+
export interface SnackbarHiddenCloseButtonProps extends SnackbarPrimitive.CloseButtonProps {}
|
|
72
71
|
|
|
73
72
|
/**
|
|
74
73
|
* Visually hidden button that closes the snackbar (for screen readers).
|
|
75
74
|
*/
|
|
76
|
-
export const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
75
|
+
export const SnackbarHiddenCloseButton = forwardRef<
|
|
76
|
+
HTMLButtonElement,
|
|
77
|
+
SnackbarHiddenCloseButtonProps
|
|
78
|
+
>((props, ref) => {
|
|
79
|
+
const { style, ...otherProps } = props;
|
|
80
|
+
return (
|
|
81
|
+
<SnackbarPrimitive.CloseButton
|
|
82
|
+
ref={ref}
|
|
83
|
+
style={{ ...visuallyHidden, ...style }}
|
|
84
|
+
{...otherProps}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
});
|
|
89
88
|
|
|
90
89
|
////////////////////////////////////////////////////////////////////////////////////
|
|
91
90
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export {
|
|
2
2
|
SnackbarActionButton,
|
|
3
3
|
SnackbarAvoidOverlap,
|
|
4
|
-
|
|
4
|
+
SnackbarHiddenCloseButton,
|
|
5
5
|
SnackbarMessage,
|
|
6
6
|
SnackbarPrefixIcon,
|
|
7
7
|
SnackbarRegion,
|
|
@@ -10,7 +10,7 @@ export {
|
|
|
10
10
|
SnackbarRootProvider,
|
|
11
11
|
type SnackbarActionButtonProps,
|
|
12
12
|
type SnackbarAvoidOverlapProps,
|
|
13
|
-
type
|
|
13
|
+
type SnackbarHiddenCloseButtonProps,
|
|
14
14
|
type SnackbarMessageProps,
|
|
15
15
|
type SnackbarPrefixIconProps,
|
|
16
16
|
type SnackbarRegionProps,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Switch as SwitchPrimitive, useSwitchContext } from "@seed-design/react-switch";
|
|
2
2
|
import { switchStyle, type SwitchVariantProps } from "@seed-design/css/recipes/switch";
|
|
3
|
-
import {
|
|
3
|
+
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
4
4
|
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
5
5
|
import { createWithStateProps } from "../../utils/createWithStateProps";
|
|
6
6
|
|
|
7
|
-
const { withProvider, withContext } =
|
|
7
|
+
const { withProvider, withContext } = createSlotRecipeContext(switchStyle);
|
|
8
8
|
const withStateProps = createWithStateProps([useSwitchContext]);
|
|
9
9
|
|
|
10
10
|
////////////////////////////////////////////////////////////////////////////////////
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
useTabsTriggerContext,
|
|
6
6
|
} from "@seed-design/react-tabs";
|
|
7
7
|
import { tabs, type TabsVariantProps } from "@seed-design/css/recipes/tabs";
|
|
8
|
-
import {
|
|
8
|
+
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
9
9
|
import { createWithStateProps } from "../../utils/createWithStateProps";
|
|
10
10
|
import type React from "react";
|
|
11
11
|
|
|
12
|
-
const { withProvider, withContext } =
|
|
12
|
+
const { withProvider, withContext } = createSlotRecipeContext(tabs);
|
|
13
13
|
const withStateProps = createWithStateProps([useTabsContext, useTabsTriggerContext], {
|
|
14
14
|
strict: false,
|
|
15
15
|
});
|
|
@@ -108,7 +108,7 @@ export const Text = ({
|
|
|
108
108
|
...otherProps
|
|
109
109
|
}: TextProps) => {
|
|
110
110
|
const Comp = as || "span";
|
|
111
|
-
const
|
|
111
|
+
const textClassName = useMemo(
|
|
112
112
|
() =>
|
|
113
113
|
text({
|
|
114
114
|
textStyle,
|
|
@@ -119,7 +119,7 @@ export const Text = ({
|
|
|
119
119
|
|
|
120
120
|
return (
|
|
121
121
|
<Comp
|
|
122
|
-
className={clsx(
|
|
122
|
+
className={clsx(textClassName, className)}
|
|
123
123
|
style={
|
|
124
124
|
{
|
|
125
125
|
"--seed-max-lines": maxLines,
|
|
@@ -5,12 +5,12 @@ import { textField, type TextFieldVariantProps } from "@seed-design/css/recipes/
|
|
|
5
5
|
import clsx from "clsx";
|
|
6
6
|
import type * as React from "react";
|
|
7
7
|
import { forwardRef, useCallback, useRef } from "react";
|
|
8
|
-
import {
|
|
8
|
+
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
9
9
|
import { createWithStateProps } from "../../utils/createWithStateProps";
|
|
10
10
|
import { InternalIcon, type InternalIconProps } from "../private/Icon";
|
|
11
11
|
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
12
12
|
|
|
13
|
-
const { withProvider, withContext, useClassNames } =
|
|
13
|
+
const { withProvider, withContext, useClassNames } = createSlotRecipeContext(textField);
|
|
14
14
|
const withStateProps = createWithStateProps([useTextFieldContext]);
|
|
15
15
|
|
|
16
16
|
////////////////////////////////////////////////////////////////////////////////////
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
} from "@seed-design/css/recipes/toggle-button";
|
|
6
6
|
import clsx from "clsx";
|
|
7
7
|
import * as React from "react";
|
|
8
|
-
import {
|
|
8
|
+
import { createRecipeContext } from "../../utils/createRecipeContext";
|
|
9
9
|
import {
|
|
10
10
|
PendingButtonProvider,
|
|
11
11
|
usePendingButton,
|
|
12
12
|
type UsePendingButtonProps,
|
|
13
13
|
} from "../LoadingIndicator/usePendingButton";
|
|
14
14
|
|
|
15
|
-
const {
|
|
15
|
+
const { ClassNameProvider } = createRecipeContext(toggleButton);
|
|
16
16
|
|
|
17
17
|
export interface ToggleButtonProps
|
|
18
18
|
extends ToggleButtonVariantProps,
|
|
@@ -21,20 +21,20 @@ export interface ToggleButtonProps
|
|
|
21
21
|
|
|
22
22
|
export const ToggleButton = React.forwardRef<HTMLButtonElement, ToggleButtonProps>(
|
|
23
23
|
({ variant = "brandSolid", size = "small", loading = false, className, ...otherProps }, ref) => {
|
|
24
|
-
const
|
|
24
|
+
const recipeClassName = toggleButton({ variant, size });
|
|
25
25
|
const api = usePendingButton({ loading, disabled: otherProps.disabled });
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
|
-
<
|
|
28
|
+
<ClassNameProvider value={recipeClassName}>
|
|
29
29
|
<PendingButtonProvider value={api}>
|
|
30
30
|
<TogglePrimitive.Root
|
|
31
31
|
ref={ref}
|
|
32
|
-
className={clsx(
|
|
32
|
+
className={clsx(recipeClassName, className)}
|
|
33
33
|
{...api.stateProps}
|
|
34
34
|
{...otherProps}
|
|
35
35
|
/>
|
|
36
36
|
</PendingButtonProvider>
|
|
37
|
-
</
|
|
37
|
+
</ClassNameProvider>
|
|
38
38
|
);
|
|
39
39
|
},
|
|
40
40
|
);
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import { visuallyHidden } from "@seed-design/dom-utils";
|
|
1
2
|
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
2
|
-
import { visuallyHidden } from "@seed-design/css/recipes/visually-hidden";
|
|
3
3
|
import type * as React from "react";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const { withProvider } = createStyleContext(visuallyHidden);
|
|
4
|
+
import { forwardRef } from "react";
|
|
7
5
|
|
|
8
6
|
export interface VisuallyHiddenProps extends PrimitiveProps, React.HTMLAttributes<HTMLDivElement> {}
|
|
9
7
|
|
|
10
|
-
export const VisuallyHidden =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
);
|
|
8
|
+
export const VisuallyHidden = forwardRef<HTMLDivElement, VisuallyHiddenProps>((props, ref) => {
|
|
9
|
+
const { style, ...otherProps } = props;
|
|
10
|
+
return <Primitive.div ref={ref} style={{ ...visuallyHidden, ...style }} {...otherProps} />;
|
|
11
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import { createContext, forwardRef, useContext } from "react";
|
|
3
|
+
|
|
4
|
+
type Recipe<
|
|
5
|
+
Props extends Record<string, string | boolean | undefined>,
|
|
6
|
+
ClassName extends string,
|
|
7
|
+
> = ((props?: Props) => ClassName) & {
|
|
8
|
+
splitVariantProps: <T extends Props>(props: T) => [Props, Omit<T, keyof Props>];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function createRecipeContext<
|
|
12
|
+
Props extends Record<string, string | boolean | undefined>,
|
|
13
|
+
ClassName extends string,
|
|
14
|
+
>(recipe: Recipe<Props, ClassName>) {
|
|
15
|
+
const ClassNameContext = createContext<ClassName | null>(null);
|
|
16
|
+
const PropsContext = createContext<Props | null>(null);
|
|
17
|
+
|
|
18
|
+
const ClassNameProvider = ({
|
|
19
|
+
children,
|
|
20
|
+
value,
|
|
21
|
+
}: {
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
value: ClassName;
|
|
24
|
+
}) => {
|
|
25
|
+
return <ClassNameContext.Provider value={value}>{children}</ClassNameContext.Provider>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const PropsProvider = ({ children, value }: { children: React.ReactNode; value: Props }) => {
|
|
29
|
+
return <PropsContext.Provider value={value}>{children}</PropsContext.Provider>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function useClassName() {
|
|
33
|
+
const context = useContext(ClassNameContext);
|
|
34
|
+
if (context === null) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
"useClassName must be used within a ClassNameProvider. Did you forget to wrap your component in a ClassNameProvider?",
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return context;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function useProps() {
|
|
43
|
+
return useContext(PropsContext);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const withRootProvider = <P,>(
|
|
47
|
+
Component: React.ElementType<any>,
|
|
48
|
+
options?: {
|
|
49
|
+
defaultProps?: Partial<P>;
|
|
50
|
+
},
|
|
51
|
+
): React.ForwardRefExoticComponent<React.PropsWithoutRef<P>> => {
|
|
52
|
+
const { defaultProps } = options ?? {};
|
|
53
|
+
|
|
54
|
+
const StyledComponent = (innerProps: any) => {
|
|
55
|
+
const props = { ...(defaultProps ?? {}), ...useProps(), ...innerProps } as Props &
|
|
56
|
+
React.HTMLAttributes<HTMLElement>;
|
|
57
|
+
const [variantProps, otherProps] = recipe.splitVariantProps(props);
|
|
58
|
+
const className = recipe(variantProps);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<ClassNameProvider value={className}>
|
|
62
|
+
<Component {...otherProps} className={clsx(className, props.className)} />
|
|
63
|
+
</ClassNameProvider>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
StyledComponent.displayName = (Component as any).displayName || (Component as any).name;
|
|
68
|
+
return StyledComponent as any;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const withProvider = <T, P>(
|
|
72
|
+
Component: React.ElementType<any>,
|
|
73
|
+
options?: {
|
|
74
|
+
defaultProps?: Partial<P>;
|
|
75
|
+
},
|
|
76
|
+
): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>> => {
|
|
77
|
+
const { defaultProps } = options ?? {};
|
|
78
|
+
|
|
79
|
+
const StyledComponent = forwardRef<any, any>((innerProps, ref) => {
|
|
80
|
+
const props = { ...(defaultProps ?? {}), ...useProps(), ...innerProps } as Props &
|
|
81
|
+
React.HTMLAttributes<HTMLElement>;
|
|
82
|
+
const [variantProps, otherProps] = recipe.splitVariantProps(props);
|
|
83
|
+
const className = recipe(variantProps);
|
|
84
|
+
|
|
85
|
+
return <Component ref={ref} {...otherProps} className={clsx(className, props.className)} />;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
StyledComponent.displayName = (Component as any).displayName || (Component as any).name;
|
|
89
|
+
return StyledComponent as any;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const withContext = <T, P>(
|
|
93
|
+
Component: React.ElementType<any>,
|
|
94
|
+
): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>> => {
|
|
95
|
+
const StyledComponent = forwardRef<any, React.HTMLAttributes<HTMLElement>>((props, ref) => {
|
|
96
|
+
const className = useClassName();
|
|
97
|
+
|
|
98
|
+
return <Component ref={ref} {...props} className={clsx(className, props.className)} />;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
StyledComponent.displayName = (Component as any).displayName || (Component as any).name;
|
|
102
|
+
return StyledComponent as any;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
ClassNameProvider,
|
|
107
|
+
PropsProvider,
|
|
108
|
+
useClassName,
|
|
109
|
+
useProps,
|
|
110
|
+
withRootProvider,
|
|
111
|
+
withProvider,
|
|
112
|
+
withContext,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
2
|
import { createContext, forwardRef, useContext } from "react";
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type SlotRecipe<
|
|
5
5
|
Props extends Record<string, string | boolean | undefined>,
|
|
6
6
|
Classnames extends Record<string, string>,
|
|
7
7
|
> = ((props?: Props) => Classnames) & {
|
|
8
8
|
splitVariantProps: <T extends Props>(props: T) => [Props, Omit<T, keyof Props>];
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export function
|
|
11
|
+
export function createSlotRecipeContext<
|
|
12
12
|
Props extends Record<string, string | boolean | undefined>,
|
|
13
13
|
Classnames extends Record<string, string>,
|
|
14
|
-
>(recipe:
|
|
14
|
+
>(recipe: SlotRecipe<Props, Classnames>) {
|
|
15
15
|
const ClassNamesContext = createContext<Classnames | null>(null);
|
|
16
16
|
const PropsContext = createContext<Props | null>(null);
|
|
17
17
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createStyleContext.d.ts","sourceRoot":"","sources":["../../src/utils/createStyleContext.tsx"],"names":[],"mappings":"AAGA,KAAK,MAAM,CACT,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,EAC1D,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IACvC,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,UAAU,CAAC,GAAG;IACpC,iBAAiB,EAAE,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC;CACjF,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,EAC1D,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC;+CAO9B;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE;yCAIP;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE;;;uBAmB7D,CAAC,aACd,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,YACvB;QACR,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;KAC3B,KACA,KAAK,CAAC,yBAAyB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;mBAsBtC,CAAC,EAAE,CAAC,aACb,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,QAC3B,MAAM,UAAU,YACZ;QACR,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;KAC3B,KACA,KAAK,CAAC,yBAAyB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;kBAuBhE,CAAC,EAAE,CAAC,aACZ,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,SAC1B,MAAM,UAAU,KACtB,KAAK,CAAC,yBAAyB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;EAsBtF"}
|