@seed-design/react 0.0.31 → 0.0.32
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/Box/Box.cjs +5 -1
- package/lib/components/Box/Box.d.ts +1 -0
- package/lib/components/Box/Box.d.ts.map +1 -1
- package/lib/components/Box/Box.js +5 -1
- package/lib/components/Text/Text.cjs +43 -39
- package/lib/components/Text/Text.d.ts +1 -1
- package/lib/components/Text/Text.d.ts.map +1 -1
- package/lib/components/Text/Text.js +44 -40
- package/package.json +1 -1
- package/src/components/Box/Box.tsx +10 -1
- package/src/components/Text/Text.tsx +52 -43
|
@@ -7,6 +7,7 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
const clsx = require('clsx');
|
|
8
8
|
const React = require('react');
|
|
9
9
|
const styled = require('../../utils/styled.cjs');
|
|
10
|
+
const reactSlot = require('@radix-ui/react-slot');
|
|
10
11
|
|
|
11
12
|
function _interopNamespaceDefault(e) {
|
|
12
13
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
@@ -29,7 +30,10 @@ const React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
29
30
|
|
|
30
31
|
const Box = React__namespace.forwardRef((props, ref) => {
|
|
31
32
|
const { style, restProps } = styled.useStyleProps(props);
|
|
32
|
-
const { as: Comp = "div", className, ...nativeProps } = restProps;
|
|
33
|
+
const { as: Comp = "div", asChild = false, className, ...nativeProps } = restProps;
|
|
34
|
+
if (asChild) {
|
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactSlot.Slot, { ref, className: clsx("seed-box", className), style, ...nativeProps });
|
|
36
|
+
}
|
|
33
37
|
return /* @__PURE__ */ jsxRuntime.jsx(Comp, { ref, className: clsx("seed-box", className), style, ...nativeProps });
|
|
34
38
|
});
|
|
35
39
|
|
|
@@ -2,6 +2,7 @@ import { StyleProps } from '../../utils/styled';
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
export interface BoxProps extends StyleProps, Omit<React.HTMLAttributes<HTMLDivElement>, "color"> {
|
|
4
4
|
as?: React.ElementType;
|
|
5
|
+
asChild?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export declare const Box: React.ForwardRefExoticComponent<BoxProps & React.RefAttributes<HTMLDivElement>>;
|
|
7
8
|
//# sourceMappingURL=Box.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../../src/components/Box/Box.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../../src/components/Box/Box.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGpE,MAAM,WAAW,QAAS,SAAQ,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAC/F,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IAEvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,GAAG,iFAWd,CAAC"}
|
|
@@ -3,10 +3,14 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useStyleProps } from '../../utils/styled.js';
|
|
6
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
6
7
|
|
|
7
8
|
const Box = React.forwardRef((props, ref) => {
|
|
8
9
|
const { style, restProps } = useStyleProps(props);
|
|
9
|
-
const { as: Comp = "div", className, ...nativeProps } = restProps;
|
|
10
|
+
const { as: Comp = "div", asChild = false, className, ...nativeProps } = restProps;
|
|
11
|
+
if (asChild) {
|
|
12
|
+
return /* @__PURE__ */ jsx(Slot, { ref, className: clsx("seed-box", className), style, ...nativeProps });
|
|
13
|
+
}
|
|
10
14
|
return /* @__PURE__ */ jsx(Comp, { ref, className: clsx("seed-box", className), style, ...nativeProps });
|
|
11
15
|
});
|
|
12
16
|
|
|
@@ -43,44 +43,48 @@ function mapMaxLines(maxLines) {
|
|
|
43
43
|
}
|
|
44
44
|
return "multi";
|
|
45
45
|
}
|
|
46
|
-
const Text = (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
46
|
+
const Text = React.forwardRef(
|
|
47
|
+
({
|
|
48
|
+
as,
|
|
49
|
+
color,
|
|
50
|
+
textStyle,
|
|
51
|
+
fontSize,
|
|
52
|
+
lineHeight,
|
|
53
|
+
fontWeight,
|
|
54
|
+
maxLines,
|
|
55
|
+
children,
|
|
56
|
+
className,
|
|
57
|
+
style,
|
|
58
|
+
...otherProps
|
|
59
|
+
}, ref) => {
|
|
60
|
+
const Comp = as || "span";
|
|
61
|
+
const textClassName = React.useMemo(
|
|
62
|
+
() => text.text({
|
|
63
|
+
textStyle,
|
|
64
|
+
maxLines: mapMaxLines(maxLines)
|
|
65
|
+
}),
|
|
66
|
+
[textStyle, maxLines]
|
|
67
|
+
);
|
|
68
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
69
|
+
Comp,
|
|
70
|
+
{
|
|
71
|
+
ref,
|
|
72
|
+
className: clsx(textClassName, className),
|
|
73
|
+
style: {
|
|
74
|
+
"--seed-max-lines": maxLines,
|
|
75
|
+
"--seed-text-color": handleColor(color),
|
|
76
|
+
"--seed-font-size": handleFontSize(fontSize),
|
|
77
|
+
"--seed-line-height": handleLineHeight(lineHeight ?? fontSize),
|
|
78
|
+
"--seed-font-weight": handleFontWeight(fontWeight),
|
|
79
|
+
"--seed-text-align": otherProps.align,
|
|
80
|
+
...style
|
|
81
|
+
},
|
|
82
|
+
...otherProps,
|
|
83
|
+
children
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
Text.displayName = "Text";
|
|
85
89
|
|
|
86
90
|
exports.Text = Text;
|
|
@@ -32,5 +32,5 @@ export interface TextProps extends Omit<TextVariantProps, "maxLines">, React.HTM
|
|
|
32
32
|
*/
|
|
33
33
|
align?: "left" | "center" | "right";
|
|
34
34
|
}
|
|
35
|
-
export declare const Text:
|
|
35
|
+
export declare const Text: React.ForwardRefExoticComponent<TextProps & React.RefAttributes<HTMLSpanElement>>;
|
|
36
36
|
//# sourceMappingURL=Text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/components/Text/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAoCpC,MAAM,WAAW,SACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EACxC,KAAK,CAAC,cAAc,CAAC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G,kBAAkB,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC;AAYD,eAAO,MAAM,IAAI,mFAiDhB,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { text } from '@seed-design/css/recipes/text';
|
|
4
4
|
import { vars } from '@seed-design/css/vars';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import { useMemo } from 'react';
|
|
6
|
+
import { forwardRef, useMemo } from 'react';
|
|
7
7
|
|
|
8
8
|
function handleColor(color) {
|
|
9
9
|
if (!color) {
|
|
@@ -39,44 +39,48 @@ function mapMaxLines(maxLines) {
|
|
|
39
39
|
}
|
|
40
40
|
return "multi";
|
|
41
41
|
}
|
|
42
|
-
const Text = (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
42
|
+
const Text = forwardRef(
|
|
43
|
+
({
|
|
44
|
+
as,
|
|
45
|
+
color,
|
|
46
|
+
textStyle,
|
|
47
|
+
fontSize,
|
|
48
|
+
lineHeight,
|
|
49
|
+
fontWeight,
|
|
50
|
+
maxLines,
|
|
51
|
+
children,
|
|
52
|
+
className,
|
|
53
|
+
style,
|
|
54
|
+
...otherProps
|
|
55
|
+
}, ref) => {
|
|
56
|
+
const Comp = as || "span";
|
|
57
|
+
const textClassName = useMemo(
|
|
58
|
+
() => text({
|
|
59
|
+
textStyle,
|
|
60
|
+
maxLines: mapMaxLines(maxLines)
|
|
61
|
+
}),
|
|
62
|
+
[textStyle, maxLines]
|
|
63
|
+
);
|
|
64
|
+
return /* @__PURE__ */ jsx(
|
|
65
|
+
Comp,
|
|
66
|
+
{
|
|
67
|
+
ref,
|
|
68
|
+
className: clsx(textClassName, className),
|
|
69
|
+
style: {
|
|
70
|
+
"--seed-max-lines": maxLines,
|
|
71
|
+
"--seed-text-color": handleColor(color),
|
|
72
|
+
"--seed-font-size": handleFontSize(fontSize),
|
|
73
|
+
"--seed-line-height": handleLineHeight(lineHeight ?? fontSize),
|
|
74
|
+
"--seed-font-weight": handleFontWeight(fontWeight),
|
|
75
|
+
"--seed-text-align": otherProps.align,
|
|
76
|
+
...style
|
|
77
|
+
},
|
|
78
|
+
...otherProps,
|
|
79
|
+
children
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
Text.displayName = "Text";
|
|
81
85
|
|
|
82
86
|
export { Text };
|
package/package.json
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { useStyleProps, type StyleProps } from "../../utils/styled";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
5
|
|
|
5
6
|
export interface BoxProps extends StyleProps, Omit<React.HTMLAttributes<HTMLDivElement>, "color"> {
|
|
6
7
|
as?: React.ElementType;
|
|
8
|
+
|
|
9
|
+
asChild?: boolean;
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
export const Box = React.forwardRef<HTMLDivElement, BoxProps>((props, ref) => {
|
|
10
13
|
const { style, restProps } = useStyleProps(props);
|
|
11
|
-
const { as: Comp = "div", className, ...nativeProps } = restProps;
|
|
14
|
+
const { as: Comp = "div", asChild = false, className, ...nativeProps } = restProps;
|
|
15
|
+
|
|
16
|
+
if (asChild) {
|
|
17
|
+
return (
|
|
18
|
+
<Slot ref={ref} className={clsx("seed-box", className)} style={style} {...nativeProps} />
|
|
19
|
+
);
|
|
20
|
+
}
|
|
12
21
|
|
|
13
22
|
return <Comp ref={ref} className={clsx("seed-box", className)} style={style} {...nativeProps} />;
|
|
14
23
|
});
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "@seed-design/css/vars";
|
|
10
10
|
import clsx from "clsx";
|
|
11
11
|
import type * as React from "react";
|
|
12
|
-
import { useMemo } from "react";
|
|
12
|
+
import { forwardRef, useMemo } from "react";
|
|
13
13
|
|
|
14
14
|
function handleColor(color: string | undefined) {
|
|
15
15
|
if (!color) {
|
|
@@ -94,46 +94,55 @@ function mapMaxLines(maxLines: number | undefined): "none" | "single" | "multi"
|
|
|
94
94
|
return "multi";
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
export const Text = (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
97
|
+
export const Text = forwardRef<HTMLSpanElement, TextProps>(
|
|
98
|
+
(
|
|
99
|
+
{
|
|
100
|
+
as,
|
|
101
|
+
color,
|
|
102
|
+
textStyle,
|
|
103
|
+
fontSize,
|
|
104
|
+
lineHeight,
|
|
105
|
+
fontWeight,
|
|
106
|
+
maxLines,
|
|
107
|
+
children,
|
|
108
|
+
className,
|
|
109
|
+
style,
|
|
110
|
+
...otherProps
|
|
111
|
+
},
|
|
112
|
+
ref,
|
|
113
|
+
) => {
|
|
114
|
+
const Comp = as || "span";
|
|
115
|
+
const textClassName = useMemo(
|
|
116
|
+
() =>
|
|
117
|
+
text({
|
|
118
|
+
textStyle,
|
|
119
|
+
maxLines: mapMaxLines(maxLines),
|
|
120
|
+
}),
|
|
121
|
+
[textStyle, maxLines],
|
|
122
|
+
);
|
|
119
123
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
124
|
+
return (
|
|
125
|
+
<Comp
|
|
126
|
+
// @ts-ignore: We might need overloading for ref types, not a big deal for now.
|
|
127
|
+
ref={ref}
|
|
128
|
+
className={clsx(textClassName, className)}
|
|
129
|
+
style={
|
|
130
|
+
{
|
|
131
|
+
"--seed-max-lines": maxLines,
|
|
132
|
+
"--seed-text-color": handleColor(color),
|
|
133
|
+
"--seed-font-size": handleFontSize(fontSize),
|
|
134
|
+
"--seed-line-height": handleLineHeight(lineHeight ?? fontSize),
|
|
135
|
+
"--seed-font-weight": handleFontWeight(fontWeight),
|
|
136
|
+
"--seed-text-align": otherProps.align,
|
|
137
|
+
...style,
|
|
138
|
+
} as React.CSSProperties
|
|
139
|
+
}
|
|
140
|
+
{...otherProps}
|
|
141
|
+
>
|
|
142
|
+
{children}
|
|
143
|
+
</Comp>
|
|
144
|
+
);
|
|
145
|
+
},
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
Text.displayName = "Text";
|