@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.
- package/lib/components/{Celcius/Celcius.cjs → Celsius/Celsius.cjs} +2 -2
- package/lib/components/Celsius/Celsius.d.ts +6 -0
- package/lib/components/Celsius/Celsius.d.ts.map +1 -0
- package/lib/components/Celsius/Celsius.js +6 -0
- package/lib/components/{Celcius → Celsius}/index.cjs +2 -2
- package/lib/components/Celsius/index.d.ts +2 -0
- package/lib/components/Celsius/index.d.ts.map +1 -0
- package/lib/components/Celsius/index.js +1 -0
- package/lib/components/Checkbox/Checkbox.cjs +9 -8
- package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/components/Checkbox/Checkbox.js +9 -8
- package/lib/components/List/List.cjs +5 -3
- package/lib/components/List/List.d.ts.map +1 -1
- package/lib/components/List/List.js +5 -3
- package/lib/components/List/ListHeader.cjs +20 -0
- package/lib/components/List/ListHeader.d.ts +11 -0
- package/lib/components/List/ListHeader.d.ts.map +1 -0
- package/lib/components/List/ListHeader.js +16 -0
- package/lib/components/List/ListHeader.namespace.d.ts +2 -0
- package/lib/components/List/ListHeader.namespace.d.ts.map +1 -0
- package/lib/components/List/index.cjs +2 -0
- package/lib/components/List/index.d.ts +1 -0
- package/lib/components/List/index.d.ts.map +1 -1
- package/lib/components/List/index.js +1 -0
- package/lib/components/MannerTemp/MannerTempEmote.cjs +80 -612
- package/lib/components/MannerTemp/MannerTempEmote.d.ts +2 -2
- package/lib/components/MannerTemp/MannerTempEmote.d.ts.map +1 -1
- package/lib/components/MannerTemp/MannerTempEmote.js +81 -613
- package/lib/components/RadioGroup/RadioGroup.cjs +2 -3
- package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/lib/components/RadioGroup/RadioGroup.js +2 -3
- package/lib/components/Snackbar/Snackbar.cjs +5 -0
- package/lib/components/Snackbar/Snackbar.d.ts +4 -1
- package/lib/components/Snackbar/Snackbar.d.ts.map +1 -1
- package/lib/components/Snackbar/Snackbar.js +5 -1
- package/lib/components/Snackbar/Snackbar.namespace.cjs +1 -0
- 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/Switch/Switch.cjs +23 -11
- package/lib/components/Switch/Switch.d.ts +3 -2
- package/lib/components/Switch/Switch.d.ts.map +1 -1
- package/lib/components/Switch/Switch.js +23 -11
- package/lib/components/index.cjs +4 -2
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.js +2 -1
- package/lib/index.cjs +4 -2
- package/lib/index.js +2 -1
- package/lib/utils/splitMultipleVariantsProps.cjs +32 -0
- package/lib/utils/splitMultipleVariantsProps.d.ts +21 -0
- package/lib/utils/splitMultipleVariantsProps.js +28 -0
- package/package.json +19 -19
- package/src/components/Celsius/Celsius.tsx +9 -0
- package/src/components/Celsius/index.ts +4 -0
- package/src/components/Checkbox/Checkbox.tsx +15 -15
- package/src/components/List/List.tsx +5 -3
- package/src/components/List/ListHeader.namespace.ts +0 -0
- package/src/components/List/ListHeader.tsx +24 -0
- package/src/components/List/index.ts +2 -0
- package/src/components/MannerTemp/MannerTempEmote.tsx +104 -432
- package/src/components/RadioGroup/RadioGroup.tsx +3 -4
- package/src/components/Snackbar/Snackbar.namespace.ts +2 -0
- package/src/components/Snackbar/Snackbar.tsx +12 -1
- package/src/components/Switch/Switch.tsx +34 -26
- package/src/components/index.ts +1 -1
- package/src/utils/splitMultipleVariantsProps.d.ts +21 -0
- package/src/utils/splitMultipleVariantsProps.mjs +25 -0
- package/lib/components/Celcius/Celcius.d.ts +0 -6
- package/lib/components/Celcius/Celcius.d.ts.map +0 -1
- package/lib/components/Celcius/Celcius.js +0 -6
- package/lib/components/Celcius/index.d.ts +0 -2
- package/lib/components/Celcius/index.d.ts.map +0 -1
- package/lib/components/Celcius/index.js +0 -1
- package/src/components/Celcius/Celcius.tsx +0 -9
- 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<
|
|
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
|
-
({
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
<
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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 =
|
|
66
|
+
export const SwitchControl = withControlProvider<HTMLDivElement, SwitchControlProps>(
|
|
59
67
|
SwitchPrimitive.Control,
|
|
60
|
-
"
|
|
68
|
+
"root",
|
|
61
69
|
);
|
|
62
70
|
|
|
63
71
|
////////////////////////////////////////////////////////////////////////////////////
|
|
64
72
|
|
|
65
73
|
export interface SwitchThumbProps extends SwitchPrimitive.ThumbProps {}
|
|
66
74
|
|
|
67
|
-
export const SwitchThumb =
|
|
75
|
+
export const SwitchThumb = withControlContext<HTMLDivElement, SwitchThumbProps>(
|
|
68
76
|
SwitchPrimitive.Thumb,
|
|
69
77
|
"thumb",
|
|
70
78
|
);
|
package/src/components/index.ts
CHANGED
|
@@ -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 +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 +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';
|