@seed-design/react 0.2.5 → 1.0.0

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 (75) hide show
  1. package/lib/components/{Celcius/Celcius.cjs → Celsius/Celsius.cjs} +2 -2
  2. package/lib/components/Celsius/Celsius.d.ts +6 -0
  3. package/lib/components/Celsius/Celsius.d.ts.map +1 -0
  4. package/lib/components/Celsius/Celsius.js +6 -0
  5. package/lib/components/{Celcius → Celsius}/index.cjs +2 -2
  6. package/lib/components/Celsius/index.d.ts +2 -0
  7. package/lib/components/Celsius/index.d.ts.map +1 -0
  8. package/lib/components/Celsius/index.js +1 -0
  9. package/lib/components/Checkbox/Checkbox.cjs +9 -8
  10. package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
  11. package/lib/components/Checkbox/Checkbox.js +9 -8
  12. package/lib/components/List/List.cjs +5 -3
  13. package/lib/components/List/List.d.ts.map +1 -1
  14. package/lib/components/List/List.js +5 -3
  15. package/lib/components/List/ListHeader.cjs +20 -0
  16. package/lib/components/List/ListHeader.d.ts +11 -0
  17. package/lib/components/List/ListHeader.d.ts.map +1 -0
  18. package/lib/components/List/ListHeader.js +16 -0
  19. package/lib/components/List/ListHeader.namespace.d.ts +2 -0
  20. package/lib/components/List/ListHeader.namespace.d.ts.map +1 -0
  21. package/lib/components/List/index.cjs +2 -0
  22. package/lib/components/List/index.d.ts +1 -0
  23. package/lib/components/List/index.d.ts.map +1 -1
  24. package/lib/components/List/index.js +1 -0
  25. package/lib/components/MannerTemp/MannerTempEmote.cjs +80 -612
  26. package/lib/components/MannerTemp/MannerTempEmote.d.ts +2 -2
  27. package/lib/components/MannerTemp/MannerTempEmote.d.ts.map +1 -1
  28. package/lib/components/MannerTemp/MannerTempEmote.js +81 -613
  29. package/lib/components/RadioGroup/RadioGroup.cjs +2 -3
  30. package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -1
  31. package/lib/components/RadioGroup/RadioGroup.js +2 -3
  32. package/lib/components/Snackbar/Snackbar.cjs +5 -0
  33. package/lib/components/Snackbar/Snackbar.d.ts +4 -1
  34. package/lib/components/Snackbar/Snackbar.d.ts.map +1 -1
  35. package/lib/components/Snackbar/Snackbar.js +5 -1
  36. package/lib/components/Snackbar/Snackbar.namespace.cjs +1 -0
  37. package/lib/components/Snackbar/Snackbar.namespace.d.ts +1 -1
  38. package/lib/components/Snackbar/Snackbar.namespace.d.ts.map +1 -1
  39. package/lib/components/Snackbar/Snackbar.namespace.js +1 -1
  40. package/lib/components/Switch/Switch.cjs +23 -11
  41. package/lib/components/Switch/Switch.d.ts +3 -2
  42. package/lib/components/Switch/Switch.d.ts.map +1 -1
  43. package/lib/components/Switch/Switch.js +23 -11
  44. package/lib/components/index.cjs +4 -2
  45. package/lib/components/index.d.ts +1 -1
  46. package/lib/components/index.js +2 -1
  47. package/lib/index.cjs +4 -2
  48. package/lib/index.js +2 -1
  49. package/lib/utils/splitMultipleVariantsProps.cjs +32 -0
  50. package/lib/utils/splitMultipleVariantsProps.d.ts +21 -0
  51. package/lib/utils/splitMultipleVariantsProps.js +28 -0
  52. package/package.json +19 -19
  53. package/src/components/Celsius/Celsius.tsx +9 -0
  54. package/src/components/Celsius/index.ts +4 -0
  55. package/src/components/Checkbox/Checkbox.tsx +15 -15
  56. package/src/components/List/List.tsx +5 -3
  57. package/src/components/List/ListHeader.namespace.ts +0 -0
  58. package/src/components/List/ListHeader.tsx +24 -0
  59. package/src/components/List/index.ts +2 -0
  60. package/src/components/MannerTemp/MannerTempEmote.tsx +104 -432
  61. package/src/components/RadioGroup/RadioGroup.tsx +3 -4
  62. package/src/components/Snackbar/Snackbar.namespace.ts +2 -0
  63. package/src/components/Snackbar/Snackbar.tsx +12 -1
  64. package/src/components/Switch/Switch.tsx +34 -26
  65. package/src/components/index.ts +1 -1
  66. package/src/utils/splitMultipleVariantsProps.d.ts +21 -0
  67. package/src/utils/splitMultipleVariantsProps.mjs +25 -0
  68. package/lib/components/Celcius/Celcius.d.ts +0 -6
  69. package/lib/components/Celcius/Celcius.d.ts.map +0 -1
  70. package/lib/components/Celcius/Celcius.js +0 -6
  71. package/lib/components/Celcius/index.d.ts +0 -2
  72. package/lib/components/Celcius/index.d.ts.map +0 -1
  73. package/lib/components/Celcius/index.js +0 -1
  74. package/src/components/Celcius/Celcius.tsx +0 -9
  75. package/src/components/Celcius/index.ts +0 -4
@@ -3,6 +3,7 @@ export {
3
3
  SnackbarAvoidOverlap as AvoidOverlap,
4
4
  SnackbarHiddenCloseButton as HiddenCloseButton,
5
5
  SnackbarMessage as Message,
6
+ SnackbarContent as Content,
6
7
  SnackbarPrefixIcon as PrefixIcon,
7
8
  SnackbarRegion as Region,
8
9
  SnackbarRenderer as Renderer,
@@ -12,6 +13,7 @@ export {
12
13
  type SnackbarAvoidOverlapProps as AvoidOverlapProps,
13
14
  type SnackbarHiddenCloseButtonProps as HiddenCloseButtonProps,
14
15
  type SnackbarMessageProps as MessageProps,
16
+ type SnackbarContentProps as ContentProps,
15
17
  type SnackbarPrefixIconProps as PrefixIconProps,
16
18
  type SnackbarRegionProps as RegionProps,
17
19
  type SnackbarRendererProps as RendererProps,
@@ -36,11 +36,22 @@ export const SnackbarRoot = withProvider<HTMLDivElement, SnackbarRootProps>(
36
36
 
37
37
  ////////////////////////////////////////////////////////////////////////////////////
38
38
 
39
+ export interface SnackbarContentProps
40
+ extends PrimitiveProps,
41
+ React.HTMLAttributes<HTMLDivElement> {}
42
+
43
+ export const SnackbarContent = withContext<HTMLDivElement, SnackbarContentProps>(
44
+ Primitive.div,
45
+ "content",
46
+ );
47
+
48
+ ////////////////////////////////////////////////////////////////////////////////////
49
+
39
50
  export interface SnackbarMessageProps
40
51
  extends PrimitiveProps,
41
52
  React.HTMLAttributes<HTMLSpanElement> {}
42
53
 
43
- export const SnackbarMessage = withContext<HTMLDivElement, SnackbarMessageProps>(
54
+ export const SnackbarMessage = withContext<HTMLSpanElement, SnackbarMessageProps>(
44
55
  Primitive.span,
45
56
  "message",
46
57
  );
@@ -1,12 +1,19 @@
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 { switchMark, type SwitchMarkVariantProps } from "@seed-design/css/recipes/switch-mark";
3
4
  import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
4
5
  import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
5
6
  import { createWithStateProps } from "../../utils/createWithStateProps";
6
7
  import React from "react";
7
8
  import clsx from "clsx";
9
+ import { splitMultipleVariantsProps } from "../../utils/splitMultipleVariantsProps";
8
10
 
9
11
  const { withContext, ClassNamesProvider } = createSlotRecipeContext(switchStyle);
12
+ const {
13
+ withContext: withControlContext,
14
+ PropsProvider: ControlPropsProvider,
15
+ withProvider: withControlProvider,
16
+ } = createSlotRecipeContext(switchMark);
10
17
  const withStateProps = createWithStateProps([useSwitchContext]);
11
18
 
12
19
  ////////////////////////////////////////////////////////////////////////////////////
@@ -18,53 +25,54 @@ type SwitchVariantDeprecatedSizeProps = "small" | "medium";
18
25
 
19
26
  export interface SwitchRootProps
20
27
  extends Omit<SwitchVariantProps, "size">,
28
+ Omit<SwitchMarkVariantProps, "size">,
21
29
  SwitchPrimitive.RootProps {
22
30
  size?: SwitchVariantProps["size"] | SwitchVariantDeprecatedSizeProps;
23
31
  }
24
32
 
25
33
  export const SwitchRoot = React.forwardRef<HTMLLabelElement, SwitchRootProps>(
26
- ({ size: propSize, className, ...otherProps }, ref) => {
27
- const classNames = switchStyle({
28
- // TODO: remove this mapping completely
29
- size: propSize === "small" ? "16" : propSize === "medium" ? "32" : propSize,
30
- ...otherProps,
31
- });
34
+ ({ className, ...props }, ref) => {
35
+ const [{ switch: switchVariantProps, switchMark: switchMarkVariantProps }, otherProps] =
36
+ splitMultipleVariantsProps(
37
+ {
38
+ ...props,
39
+ // TODO: replace this mapping completely
40
+ size: props.size === "small" ? "16" : props.size === "medium" ? "32" : props.size,
41
+ },
42
+ { switchMark, switch: switchStyle },
43
+ );
44
+
45
+ const classNames = switchStyle(switchVariantProps);
32
46
 
33
47
  return (
34
- <ClassNamesProvider value={classNames}>
35
- <SwitchPrimitive.Root
36
- ref={ref}
37
- className={clsx(classNames.root, className)}
38
- {...otherProps}
39
- />
40
- </ClassNamesProvider>
48
+ <ControlPropsProvider value={switchMarkVariantProps}>
49
+ <ClassNamesProvider value={classNames}>
50
+ <SwitchPrimitive.Root
51
+ ref={ref}
52
+ className={clsx(classNames.root, className)}
53
+ {...otherProps}
54
+ />
55
+ </ClassNamesProvider>
56
+ </ControlPropsProvider>
41
57
  );
42
58
  },
43
59
  );
44
-
45
- // XXX: use when the deprecated size props are removed
46
-
47
- // export interface SwitchRootProps extends SwitchVariantProps, SwitchPrimitive.RootProps {}
48
-
49
- // export const SwitchRoot = withProvider<HTMLLabelElement, SwitchRootProps>(
50
- // SwitchPrimitive.Root,
51
- // "root",
52
- // );
60
+ SwitchRoot.displayName = "SwitchRoot";
53
61
 
54
62
  ////////////////////////////////////////////////////////////////////////////////////
55
63
 
56
- export interface SwitchControlProps extends SwitchPrimitive.ControlProps {}
64
+ export interface SwitchControlProps extends SwitchMarkVariantProps, SwitchPrimitive.ControlProps {}
57
65
 
58
- export const SwitchControl = withContext<HTMLDivElement, SwitchControlProps>(
66
+ export const SwitchControl = withControlProvider<HTMLDivElement, SwitchControlProps>(
59
67
  SwitchPrimitive.Control,
60
- "control",
68
+ "root",
61
69
  );
62
70
 
63
71
  ////////////////////////////////////////////////////////////////////////////////////
64
72
 
65
73
  export interface SwitchThumbProps extends SwitchPrimitive.ThumbProps {}
66
74
 
67
- export const SwitchThumb = withContext<HTMLDivElement, SwitchThumbProps>(
75
+ export const SwitchThumb = withControlContext<HTMLDivElement, SwitchThumbProps>(
68
76
  SwitchPrimitive.Thumb,
69
77
  "thumb",
70
78
  );
@@ -6,7 +6,7 @@ export * from "./Badge";
6
6
  export * from "./BottomSheet";
7
7
  export * from "./Box";
8
8
  export * from "./Callout";
9
- export * from "./Celcius";
9
+ export * from "./Celsius";
10
10
  export * from "./Checkbox";
11
11
  export * from "./Chip";
12
12
  export * from "./ChipTabs";
@@ -0,0 +1,21 @@
1
+ type ExtractVariantProps<T> = T extends {
2
+ splitVariantProps: (...args: never[]) => [infer V, unknown];
3
+ }
4
+ ? V
5
+ : never;
6
+
7
+ type ExtractAllVariantKeys<R> = {
8
+ [K in keyof R]: ExtractVariantProps<R[K]> extends infer V
9
+ ? V extends Record<string, unknown>
10
+ ? keyof V
11
+ : never
12
+ : never;
13
+ }[keyof R];
14
+
15
+ export declare function splitMultipleVariantsProps<
16
+ R extends Record<string, { splitVariantProps: (...args: never[]) => unknown[] }>,
17
+ P,
18
+ >(
19
+ props: P,
20
+ recipesMap: R,
21
+ ): [{ [K in keyof R]: ExtractVariantProps<R[K]> }, Omit<P, ExtractAllVariantKeys<R>>];
@@ -0,0 +1,25 @@
1
+ export function splitMultipleVariantsProps(props, recipesMap) {
2
+ const multipleVariantsProps = {};
3
+ const extractedKeys = new Set();
4
+
5
+ for (const recipeKey in recipesMap) {
6
+ const recipe = recipesMap[recipeKey];
7
+
8
+ const [variantProps] = recipe.splitVariantProps(props);
9
+ multipleVariantsProps[recipeKey] = variantProps;
10
+
11
+ for (const variantPropKey in variantProps) {
12
+ extractedKeys.add(variantPropKey);
13
+ }
14
+ }
15
+
16
+ const remainingProps = {};
17
+
18
+ for (const propKey in props) {
19
+ if (extractedKeys.has(propKey)) continue;
20
+
21
+ remainingProps[propKey] = props[propKey];
22
+ }
23
+
24
+ return [multipleVariantsProps, remainingProps];
25
+ }
@@ -1,6 +0,0 @@
1
- import type * as React from "react";
2
- export interface CelciusProps {
3
- value: number;
4
- }
5
- export declare const Celcius: React.FC<CelciusProps>;
6
- //# sourceMappingURL=Celcius.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Celcius.d.ts","sourceRoot":"","sources":["../../../src/components/Celcius/Celcius.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAE1C,CAAC"}
@@ -1,6 +0,0 @@
1
- 'use client';
2
- const Celcius = (props) => {
3
- return `${props.value}°C`;
4
- };
5
-
6
- export { Celcius };
@@ -1,2 +0,0 @@
1
- export { Celcius, type CelciusProps, } from './Celcius';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Celcius/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,YAAY,GAClB,MAAM,WAAW,CAAC"}
@@ -1 +0,0 @@
1
- export { Celcius } from './Celcius.js';
@@ -1,9 +0,0 @@
1
- import type * as React from "react";
2
-
3
- export interface CelciusProps {
4
- value: number;
5
- }
6
-
7
- export const Celcius: React.FC<CelciusProps> = (props) => {
8
- return `${props.value}°C`;
9
- };
@@ -1,4 +0,0 @@
1
- export {
2
- Celcius,
3
- type CelciusProps,
4
- } from "./Celcius";