@seed-design/react 0.0.7 → 0.0.9
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 +2 -4
- package/lib/components/ActionButton/ActionButton.d.ts.map +1 -1
- package/lib/components/ActionButton/ActionButton.js +2 -4
- package/lib/components/ActionChip/ActionChip.cjs +2 -2
- package/lib/components/ActionChip/ActionChip.js +2 -2
- package/lib/components/ActionSheet/ActionSheet.cjs +2 -2
- package/lib/components/ActionSheet/ActionSheet.js +2 -2
- package/lib/components/Badge/Badge.cjs +2 -2
- package/lib/components/Badge/Badge.d.ts.map +1 -1
- package/lib/components/Badge/Badge.js +2 -2
- package/lib/components/ControlChip/ControlChip.cjs +2 -2
- package/lib/components/ControlChip/ControlChip.js +2 -2
- package/lib/components/ExtendedActionSheet/ExtendedActionSheet.cjs +2 -2
- package/lib/components/ExtendedActionSheet/ExtendedActionSheet.js +2 -2
- package/lib/components/ExtendedFab/ExtendedFab.cjs +2 -2
- package/lib/components/ExtendedFab/ExtendedFab.js +2 -2
- package/lib/components/Fab/Fab.cjs +2 -2
- package/lib/components/Fab/Fab.d.ts.map +1 -1
- package/lib/components/Fab/Fab.js +2 -2
- package/lib/components/LinkContent/LinkContent.cjs +2 -2
- package/lib/components/LinkContent/LinkContent.js +2 -2
- package/lib/components/MannerTemp/MannerTemp.cjs +19 -0
- package/lib/components/MannerTemp/MannerTemp.d.ts +7 -0
- package/lib/components/MannerTemp/MannerTemp.d.ts.map +1 -0
- package/lib/components/MannerTemp/MannerTemp.js +15 -0
- package/lib/components/MannerTemp/MannerTempEmote.cjs +632 -0
- package/lib/components/MannerTemp/MannerTempEmote.d.ts +7 -0
- package/lib/components/MannerTemp/MannerTempEmote.d.ts.map +1 -0
- package/lib/components/MannerTemp/MannerTempEmote.js +627 -0
- package/lib/components/MannerTemp/index.cjs +11 -0
- package/lib/components/MannerTemp/index.d.ts +3 -0
- package/lib/components/MannerTemp/index.d.ts.map +1 -0
- package/lib/components/MannerTemp/index.js +2 -0
- package/lib/components/MannerTempBadge/MannerTempBadge.cjs +2 -2
- package/lib/components/MannerTempBadge/MannerTempBadge.d.ts.map +1 -1
- package/lib/components/MannerTempBadge/MannerTempBadge.js +2 -2
- package/lib/components/NotificationBadge/NotificationBadge.cjs +43 -0
- package/lib/components/NotificationBadge/NotificationBadge.d.ts +11 -0
- package/lib/components/NotificationBadge/NotificationBadge.d.ts.map +1 -0
- package/lib/components/NotificationBadge/NotificationBadge.js +20 -0
- package/lib/components/NotificationBadge/index.cjs +10 -0
- package/lib/components/NotificationBadge/index.d.ts +2 -0
- package/lib/components/NotificationBadge/index.d.ts.map +1 -0
- package/lib/components/NotificationBadge/index.js +1 -0
- package/lib/components/ReactionButton/ReactionButton.cjs +2 -4
- package/lib/components/ReactionButton/ReactionButton.d.ts.map +1 -1
- package/lib/components/ReactionButton/ReactionButton.js +2 -4
- package/lib/components/SelectBox/CheckSelectBox.cjs +3 -3
- package/lib/components/SelectBox/CheckSelectBox.js +3 -3
- package/lib/components/SelectBox/RadioSelectBox.cjs +3 -3
- package/lib/components/SelectBox/RadioSelectBox.js +3 -3
- package/lib/components/Skeleton/Skeleton.cjs +2 -2
- package/lib/components/Skeleton/Skeleton.d.ts.map +1 -1
- package/lib/components/Skeleton/Skeleton.js +2 -2
- package/lib/components/Snackbar/Snackbar.cjs +2 -2
- package/lib/components/Snackbar/Snackbar.js +2 -2
- package/lib/components/Tabs/Tabs.cjs +1 -11
- package/lib/components/Tabs/Tabs.d.ts +9 -13
- package/lib/components/Tabs/Tabs.d.ts.map +1 -1
- package/lib/components/Tabs/Tabs.js +2 -11
- package/lib/components/Tabs/Tabs.namespace.cjs +0 -1
- package/lib/components/Tabs/Tabs.namespace.d.ts +1 -1
- package/lib/components/Tabs/Tabs.namespace.d.ts.map +1 -1
- package/lib/components/Tabs/Tabs.namespace.js +1 -1
- package/lib/components/Tabs/index.cjs +0 -1
- package/lib/components/Tabs/index.d.ts +1 -1
- package/lib/components/Tabs/index.d.ts.map +1 -1
- package/lib/components/Tabs/index.js +1 -1
- package/lib/components/ToggleButton/ToggleButton.cjs +3 -5
- package/lib/components/ToggleButton/ToggleButton.d.ts +1 -1
- package/lib/components/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/lib/components/ToggleButton/ToggleButton.js +3 -5
- package/lib/components/index.cjs +7 -1
- package/lib/components/index.d.ts +2 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +4 -1
- package/lib/index.cjs +7 -1
- package/lib/index.js +4 -1
- package/lib/utils/createRecipeContext.cjs +6 -41
- package/lib/utils/createRecipeContext.d.ts +4 -12
- package/lib/utils/createRecipeContext.d.ts.map +1 -1
- package/lib/utils/createRecipeContext.js +6 -41
- package/lib/utils/createWithStateProps.cjs +1 -1
- package/lib/utils/createWithStateProps.js +1 -1
- package/package.json +3 -3
- package/src/components/ActionButton/ActionButton.tsx +12 -17
- package/src/components/ActionChip/ActionChip.tsx +2 -2
- package/src/components/ActionSheet/ActionSheet.tsx +2 -2
- package/src/components/Badge/Badge.tsx +2 -2
- package/src/components/ControlChip/ControlChip.tsx +2 -2
- package/src/components/ExtendedActionSheet/ExtendedActionSheet.tsx +2 -2
- package/src/components/ExtendedFab/ExtendedFab.tsx +2 -2
- package/src/components/Fab/Fab.tsx +2 -2
- package/src/components/LinkContent/LinkContent.tsx +2 -2
- package/src/components/MannerTemp/MannerTemp.tsx +25 -0
- package/src/components/MannerTemp/MannerTempEmote.tsx +464 -0
- package/src/components/MannerTemp/index.ts +2 -0
- package/src/components/MannerTempBadge/MannerTempBadge.tsx +2 -2
- package/src/components/NotificationBadge/NotificationBadge.tsx +47 -0
- package/src/components/NotificationBadge/index.ts +6 -0
- package/src/components/ReactionButton/ReactionButton.tsx +8 -13
- package/src/components/SelectBox/CheckSelectBox.tsx +3 -3
- package/src/components/SelectBox/RadioSelectBox.tsx +3 -3
- package/src/components/Skeleton/Skeleton.tsx +2 -2
- package/src/components/Snackbar/Snackbar.tsx +2 -2
- package/src/components/Tabs/Tabs.namespace.ts +0 -2
- package/src/components/Tabs/Tabs.tsx +1 -22
- package/src/components/Tabs/index.ts +0 -2
- package/src/components/ToggleButton/ToggleButton.tsx +9 -14
- package/src/components/index.ts +2 -0
- package/src/utils/createRecipeContext.tsx +12 -72
|
@@ -8,7 +8,7 @@ import { createRecipeContext } from "../../utils/createRecipeContext";
|
|
|
8
8
|
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
9
9
|
import { InternalIcon, type InternalIconProps } from "../private/Icon";
|
|
10
10
|
|
|
11
|
-
const {
|
|
11
|
+
const { withContext: withRegionContext } = createRecipeContext(snackbarRegion);
|
|
12
12
|
const { withProvider, withContext } = createSlotRecipeContext(snackbar);
|
|
13
13
|
|
|
14
14
|
////////////////////////////////////////////////////////////////////////////////////
|
|
@@ -21,7 +21,7 @@ export const SnackbarRootProvider = SnackbarPrimitive.RootProvider;
|
|
|
21
21
|
|
|
22
22
|
export interface SnackbarRegionProps extends SnackbarVariantProps, SnackbarPrimitive.RegionProps {}
|
|
23
23
|
|
|
24
|
-
export const SnackbarRegion =
|
|
24
|
+
export const SnackbarRegion = withRegionContext<HTMLDivElement, SnackbarRegionProps>(
|
|
25
25
|
SnackbarPrimitive.Region,
|
|
26
26
|
);
|
|
27
27
|
|
|
@@ -6,13 +6,11 @@ export {
|
|
|
6
6
|
TabsCarouselCamera as CarouselCamera,
|
|
7
7
|
TabsCarousel as Carousel,
|
|
8
8
|
TabsTrigger as Trigger,
|
|
9
|
-
TabsTriggerNotification as TriggerNotification,
|
|
10
9
|
type TabsContentProps as ContentProps,
|
|
11
10
|
type TabsIndicatorProps as IndicatorProps,
|
|
12
11
|
type TabsListProps as ListProps,
|
|
13
12
|
type TabsRootProps as RootProps,
|
|
14
13
|
type TabsCarouselCameraProps as CarouselCameraProps,
|
|
15
14
|
type TabsCarouselProps as CarouselProps,
|
|
16
|
-
type TabsTriggerNotificationProps as TriggerNotificationProps,
|
|
17
15
|
type TabsTriggerProps as TriggerProps,
|
|
18
16
|
} from "./Tabs";
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
2
|
-
import {
|
|
3
|
-
Tabs as TabsPrimitive,
|
|
4
|
-
useTabsContext,
|
|
5
|
-
useTabsTriggerContext,
|
|
6
|
-
} from "@seed-design/react-tabs";
|
|
7
1
|
import { tabs, type TabsVariantProps } from "@seed-design/css/recipes/tabs";
|
|
2
|
+
import { Tabs as TabsPrimitive } from "@seed-design/react-tabs";
|
|
8
3
|
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
9
|
-
import { createWithStateProps } from "../../utils/createWithStateProps";
|
|
10
|
-
import type React from "react";
|
|
11
4
|
|
|
12
5
|
const { withProvider, withContext } = createSlotRecipeContext(tabs);
|
|
13
|
-
const withStateProps = createWithStateProps([useTabsContext, useTabsTriggerContext], {
|
|
14
|
-
strict: false,
|
|
15
|
-
});
|
|
16
6
|
|
|
17
7
|
////////////////////////////////////////////////////////////////////////////////////
|
|
18
8
|
|
|
@@ -37,17 +27,6 @@ export const TabsTrigger = withContext<HTMLButtonElement, TabsTriggerProps>(
|
|
|
37
27
|
|
|
38
28
|
////////////////////////////////////////////////////////////////////////////////////
|
|
39
29
|
|
|
40
|
-
export interface TabsTriggerNotificationProps
|
|
41
|
-
extends PrimitiveProps,
|
|
42
|
-
React.HTMLAttributes<HTMLDivElement> {}
|
|
43
|
-
|
|
44
|
-
export const TabsTriggerNotification = withContext<HTMLDivElement, TabsTriggerNotificationProps>(
|
|
45
|
-
withStateProps(Primitive.div),
|
|
46
|
-
"triggerNotification",
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
////////////////////////////////////////////////////////////////////////////////////
|
|
50
|
-
|
|
51
30
|
export interface TabsIndicatorProps extends TabsPrimitive.IndicatorProps {}
|
|
52
31
|
|
|
53
32
|
export const TabsIndicator = withContext<HTMLSpanElement, TabsIndicatorProps>(
|
|
@@ -6,14 +6,12 @@ export {
|
|
|
6
6
|
TabsCarouselCamera,
|
|
7
7
|
TabsCarousel,
|
|
8
8
|
TabsTrigger,
|
|
9
|
-
TabsTriggerNotification,
|
|
10
9
|
type TabsContentProps,
|
|
11
10
|
type TabsIndicatorProps,
|
|
12
11
|
type TabsListProps,
|
|
13
12
|
type TabsRootProps,
|
|
14
13
|
type TabsCarouselCameraProps,
|
|
15
14
|
type TabsCarouselProps,
|
|
16
|
-
type TabsTriggerNotificationProps,
|
|
17
15
|
type TabsTriggerProps,
|
|
18
16
|
} from "./Tabs";
|
|
19
17
|
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { Toggle as TogglePrimitive } from "@seed-design/react-toggle";
|
|
2
1
|
import {
|
|
3
2
|
toggleButton,
|
|
4
3
|
type ToggleButtonVariantProps,
|
|
5
4
|
} from "@seed-design/css/recipes/toggle-button";
|
|
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 { createRecipeContext } from "../../utils/createRecipeContext";
|
|
9
8
|
import {
|
|
10
9
|
PendingButtonProvider,
|
|
11
10
|
usePendingButton,
|
|
12
11
|
type UsePendingButtonProps,
|
|
13
12
|
} from "../LoadingIndicator/usePendingButton";
|
|
14
13
|
|
|
15
|
-
const { ClassNameProvider } = createRecipeContext(toggleButton);
|
|
16
|
-
|
|
17
14
|
export interface ToggleButtonProps
|
|
18
15
|
extends ToggleButtonVariantProps,
|
|
19
16
|
UsePendingButtonProps,
|
|
@@ -25,16 +22,14 @@ export const ToggleButton = React.forwardRef<HTMLButtonElement, ToggleButtonProp
|
|
|
25
22
|
const api = usePendingButton({ loading, disabled: otherProps.disabled });
|
|
26
23
|
|
|
27
24
|
return (
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</PendingButtonProvider>
|
|
37
|
-
</ClassNameProvider>
|
|
25
|
+
<PendingButtonProvider value={api}>
|
|
26
|
+
<TogglePrimitive.Root
|
|
27
|
+
ref={ref}
|
|
28
|
+
className={clsx(recipeClassName, className)}
|
|
29
|
+
{...api.stateProps}
|
|
30
|
+
{...otherProps}
|
|
31
|
+
/>
|
|
32
|
+
</PendingButtonProvider>
|
|
38
33
|
);
|
|
39
34
|
},
|
|
40
35
|
);
|
package/src/components/index.ts
CHANGED
|
@@ -25,7 +25,9 @@ export * from "./Inline";
|
|
|
25
25
|
export * from "./InlineBanner";
|
|
26
26
|
export * from "./LinkContent";
|
|
27
27
|
export * from "./LoadingIndicator";
|
|
28
|
+
export * from "./MannerTemp";
|
|
28
29
|
export * from "./MannerTempBadge";
|
|
30
|
+
export * from "./NotificationBadge";
|
|
29
31
|
export * from "./ProgressCircle";
|
|
30
32
|
export * from "./PullToRefresh";
|
|
31
33
|
export * from "./ReactionButton";
|
|
@@ -1,74 +1,26 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
2
|
import { createContext, forwardRef, useContext } from "react";
|
|
3
3
|
|
|
4
|
-
type Recipe<
|
|
5
|
-
Props
|
|
6
|
-
|
|
7
|
-
> = ((props?: Props) => ClassName) & {
|
|
4
|
+
type Recipe<Props extends Record<string, string | boolean | undefined>> = ((
|
|
5
|
+
props?: Props,
|
|
6
|
+
) => string) & {
|
|
8
7
|
splitVariantProps: <T extends Props>(props: T) => [Props, Omit<T, keyof Props>];
|
|
9
8
|
};
|
|
10
9
|
|
|
11
|
-
export function createRecipeContext<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
>(recipe: Recipe<Props, ClassName>) {
|
|
15
|
-
const ClassNameContext = createContext<ClassName | null>(null);
|
|
10
|
+
export function createRecipeContext<Props extends Record<string, string | boolean | undefined>>(
|
|
11
|
+
recipe: Recipe<Props>,
|
|
12
|
+
) {
|
|
16
13
|
const PropsContext = createContext<Props | null>(null);
|
|
17
14
|
|
|
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
15
|
const PropsProvider = ({ children, value }: { children: React.ReactNode; value: Props }) => {
|
|
29
16
|
return <PropsContext.Provider value={value}>{children}</PropsContext.Provider>;
|
|
30
17
|
};
|
|
31
18
|
|
|
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
19
|
function useProps() {
|
|
43
20
|
return useContext(PropsContext);
|
|
44
21
|
}
|
|
45
22
|
|
|
46
|
-
const
|
|
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>(
|
|
23
|
+
const withContext = <T, P>(
|
|
72
24
|
Component: React.ElementType<any>,
|
|
73
25
|
options?: {
|
|
74
26
|
defaultProps?: Partial<P>;
|
|
@@ -80,7 +32,7 @@ export function createRecipeContext<
|
|
|
80
32
|
const props = { ...(defaultProps ?? {}), ...useProps(), ...innerProps } as Props &
|
|
81
33
|
React.HTMLAttributes<HTMLElement>;
|
|
82
34
|
const [variantProps, otherProps] = recipe.splitVariantProps(props);
|
|
83
|
-
const className = recipe(variantProps);
|
|
35
|
+
const className = recipe(variantProps); // TODO: should we memoize this?
|
|
84
36
|
|
|
85
37
|
return <Component ref={ref} {...otherProps} className={clsx(className, props.className)} />;
|
|
86
38
|
});
|
|
@@ -89,26 +41,14 @@ export function createRecipeContext<
|
|
|
89
41
|
return StyledComponent as any;
|
|
90
42
|
};
|
|
91
43
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
};
|
|
44
|
+
function withPropsProvider<P>(): React.Provider<Partial<P>> {
|
|
45
|
+
return PropsProvider as any;
|
|
46
|
+
}
|
|
104
47
|
|
|
105
48
|
return {
|
|
106
|
-
ClassNameProvider,
|
|
107
49
|
PropsProvider,
|
|
108
|
-
useClassName,
|
|
109
50
|
useProps,
|
|
110
|
-
withRootProvider,
|
|
111
|
-
withProvider,
|
|
112
51
|
withContext,
|
|
52
|
+
withPropsProvider,
|
|
113
53
|
};
|
|
114
54
|
}
|