@seed-design/react 0.0.8 → 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.
Files changed (87) hide show
  1. package/lib/components/ActionButton/ActionButton.cjs +2 -4
  2. package/lib/components/ActionButton/ActionButton.d.ts.map +1 -1
  3. package/lib/components/ActionButton/ActionButton.js +2 -4
  4. package/lib/components/ActionChip/ActionChip.cjs +2 -2
  5. package/lib/components/ActionChip/ActionChip.js +2 -2
  6. package/lib/components/ActionSheet/ActionSheet.cjs +2 -2
  7. package/lib/components/ActionSheet/ActionSheet.js +2 -2
  8. package/lib/components/Badge/Badge.cjs +2 -2
  9. package/lib/components/Badge/Badge.d.ts.map +1 -1
  10. package/lib/components/Badge/Badge.js +2 -2
  11. package/lib/components/ControlChip/ControlChip.cjs +2 -2
  12. package/lib/components/ControlChip/ControlChip.js +2 -2
  13. package/lib/components/ExtendedActionSheet/ExtendedActionSheet.cjs +2 -2
  14. package/lib/components/ExtendedActionSheet/ExtendedActionSheet.js +2 -2
  15. package/lib/components/ExtendedFab/ExtendedFab.cjs +2 -2
  16. package/lib/components/ExtendedFab/ExtendedFab.js +2 -2
  17. package/lib/components/Fab/Fab.cjs +2 -2
  18. package/lib/components/Fab/Fab.d.ts.map +1 -1
  19. package/lib/components/Fab/Fab.js +2 -2
  20. package/lib/components/LinkContent/LinkContent.cjs +2 -2
  21. package/lib/components/LinkContent/LinkContent.js +2 -2
  22. package/lib/components/MannerTemp/MannerTemp.cjs +19 -0
  23. package/lib/components/MannerTemp/MannerTemp.d.ts +7 -0
  24. package/lib/components/MannerTemp/MannerTemp.d.ts.map +1 -0
  25. package/lib/components/MannerTemp/MannerTemp.js +15 -0
  26. package/lib/components/MannerTemp/MannerTempEmote.cjs +632 -0
  27. package/lib/components/MannerTemp/MannerTempEmote.d.ts +7 -0
  28. package/lib/components/MannerTemp/MannerTempEmote.d.ts.map +1 -0
  29. package/lib/components/MannerTemp/MannerTempEmote.js +627 -0
  30. package/lib/components/MannerTemp/index.cjs +11 -0
  31. package/lib/components/MannerTemp/index.d.ts +3 -0
  32. package/lib/components/MannerTemp/index.d.ts.map +1 -0
  33. package/lib/components/MannerTemp/index.js +2 -0
  34. package/lib/components/MannerTempBadge/MannerTempBadge.cjs +2 -2
  35. package/lib/components/MannerTempBadge/MannerTempBadge.d.ts.map +1 -1
  36. package/lib/components/MannerTempBadge/MannerTempBadge.js +2 -2
  37. package/lib/components/NotificationBadge/NotificationBadge.cjs +2 -2
  38. package/lib/components/NotificationBadge/NotificationBadge.js +2 -2
  39. package/lib/components/ReactionButton/ReactionButton.cjs +2 -4
  40. package/lib/components/ReactionButton/ReactionButton.d.ts.map +1 -1
  41. package/lib/components/ReactionButton/ReactionButton.js +2 -4
  42. package/lib/components/SelectBox/CheckSelectBox.cjs +3 -3
  43. package/lib/components/SelectBox/CheckSelectBox.js +3 -3
  44. package/lib/components/SelectBox/RadioSelectBox.cjs +3 -3
  45. package/lib/components/SelectBox/RadioSelectBox.js +3 -3
  46. package/lib/components/Skeleton/Skeleton.cjs +2 -2
  47. package/lib/components/Skeleton/Skeleton.d.ts.map +1 -1
  48. package/lib/components/Skeleton/Skeleton.js +2 -2
  49. package/lib/components/Snackbar/Snackbar.cjs +2 -2
  50. package/lib/components/Snackbar/Snackbar.js +2 -2
  51. package/lib/components/ToggleButton/ToggleButton.cjs +3 -5
  52. package/lib/components/ToggleButton/ToggleButton.d.ts +1 -1
  53. package/lib/components/ToggleButton/ToggleButton.d.ts.map +1 -1
  54. package/lib/components/ToggleButton/ToggleButton.js +3 -5
  55. package/lib/components/index.cjs +4 -0
  56. package/lib/components/index.d.ts +1 -0
  57. package/lib/components/index.d.ts.map +1 -1
  58. package/lib/components/index.js +2 -0
  59. package/lib/index.cjs +4 -0
  60. package/lib/index.js +2 -0
  61. package/lib/utils/createRecipeContext.cjs +6 -41
  62. package/lib/utils/createRecipeContext.d.ts +4 -12
  63. package/lib/utils/createRecipeContext.d.ts.map +1 -1
  64. package/lib/utils/createRecipeContext.js +6 -41
  65. package/package.json +3 -3
  66. package/src/components/ActionButton/ActionButton.tsx +12 -17
  67. package/src/components/ActionChip/ActionChip.tsx +2 -2
  68. package/src/components/ActionSheet/ActionSheet.tsx +2 -2
  69. package/src/components/Badge/Badge.tsx +2 -2
  70. package/src/components/ControlChip/ControlChip.tsx +2 -2
  71. package/src/components/ExtendedActionSheet/ExtendedActionSheet.tsx +2 -2
  72. package/src/components/ExtendedFab/ExtendedFab.tsx +2 -2
  73. package/src/components/Fab/Fab.tsx +2 -2
  74. package/src/components/LinkContent/LinkContent.tsx +2 -2
  75. package/src/components/MannerTemp/MannerTemp.tsx +25 -0
  76. package/src/components/MannerTemp/MannerTempEmote.tsx +464 -0
  77. package/src/components/MannerTemp/index.ts +2 -0
  78. package/src/components/MannerTempBadge/MannerTempBadge.tsx +2 -2
  79. package/src/components/NotificationBadge/NotificationBadge.tsx +2 -2
  80. package/src/components/ReactionButton/ReactionButton.tsx +8 -13
  81. package/src/components/SelectBox/CheckSelectBox.tsx +3 -3
  82. package/src/components/SelectBox/RadioSelectBox.tsx +3 -3
  83. package/src/components/Skeleton/Skeleton.tsx +2 -2
  84. package/src/components/Snackbar/Snackbar.tsx +2 -2
  85. package/src/components/ToggleButton/ToggleButton.tsx +9 -14
  86. package/src/components/index.ts +1 -0
  87. package/src/utils/createRecipeContext.tsx +12 -72
@@ -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
- <ClassNameProvider value={recipeClassName}>
29
- <PendingButtonProvider value={api}>
30
- <TogglePrimitive.Root
31
- ref={ref}
32
- className={clsx(recipeClassName, className)}
33
- {...api.stateProps}
34
- {...otherProps}
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
  );
@@ -25,6 +25,7 @@ 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";
29
30
  export * from "./NotificationBadge";
30
31
  export * from "./ProgressCircle";
@@ -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 extends Record<string, string | boolean | undefined>,
6
- ClassName extends string,
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
- Props extends Record<string, string | boolean | undefined>,
13
- ClassName extends string,
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 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>(
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
- 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
- };
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
  }