@tiny-design/react 1.0.9 → 1.0.10
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/es/typography/heading.d.ts +2 -1
- package/es/typography/heading.js +11 -18
- package/es/typography/heading.js.map +1 -1
- package/es/typography/style/_index.scss +0 -18
- package/es/typography/style/index.css +0 -13
- package/es/typography/text.d.ts +2 -1
- package/es/typography/text.js +4 -2
- package/es/typography/text.js.map +1 -1
- package/es/typography/types.d.ts +1 -1
- package/lib/typography/heading.d.ts +2 -1
- package/lib/typography/heading.js +11 -18
- package/lib/typography/heading.js.map +1 -1
- package/lib/typography/style/_index.scss +0 -18
- package/lib/typography/style/index.css +0 -13
- package/lib/typography/text.d.ts +2 -1
- package/lib/typography/text.js +4 -2
- package/lib/typography/text.js.map +1 -1
- package/lib/typography/types.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { HeadingProps } from "./types.js";
|
|
2
|
+
import React from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/typography/heading.d.ts
|
|
4
|
-
declare const Heading:
|
|
5
|
+
declare const Heading: React.ForwardRefExoticComponent<HeadingProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { Heading };
|
|
7
8
|
//# sourceMappingURL=heading.d.ts.map
|
package/es/typography/heading.js
CHANGED
|
@@ -2,29 +2,22 @@ import { ConfigContext } from "../config-provider/config-context.js";
|
|
|
2
2
|
import { getPrefixCls } from "../_utils/general.js";
|
|
3
3
|
import React, { useContext } from "react";
|
|
4
4
|
import classNames from "classnames";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
5
|
//#region src/typography/heading.tsx
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const cls = classNames(getPrefixCls("typography", useContext(ConfigContext).prefixCls, customisedCls), className);
|
|
11
|
-
return React.createElement(htmlType, {
|
|
12
|
-
...otherProps,
|
|
13
|
-
ref,
|
|
14
|
-
className: cls
|
|
15
|
-
}, children);
|
|
16
|
-
});
|
|
17
|
-
Component.displayName = displayName;
|
|
18
|
-
return Component;
|
|
19
|
-
};
|
|
20
|
-
const Heading = (props) => {
|
|
21
|
-
const { level = 1, ...otherProps } = props;
|
|
6
|
+
const Heading = React.forwardRef((props, ref) => {
|
|
7
|
+
const { level = 1, prefixCls: customisedCls, className, children, ...otherProps } = props;
|
|
8
|
+
const prefixCls = getPrefixCls("typography", useContext(ConfigContext).prefixCls, customisedCls);
|
|
22
9
|
if (level < 1 || level > 6) {
|
|
23
10
|
console.warn("The heading level parameter is invalid.");
|
|
24
11
|
return null;
|
|
25
12
|
}
|
|
26
|
-
|
|
27
|
-
}
|
|
13
|
+
const cls = classNames(prefixCls, className);
|
|
14
|
+
return React.createElement(`h${level}`, {
|
|
15
|
+
...otherProps,
|
|
16
|
+
ref,
|
|
17
|
+
className: cls
|
|
18
|
+
}, children);
|
|
19
|
+
});
|
|
20
|
+
Heading.displayName = "Heading";
|
|
28
21
|
//#endregion
|
|
29
22
|
export { Heading as default };
|
|
30
23
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.js","names":[],"sources":["../../src/typography/heading.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { HeadingProps } from './types';\n\nconst
|
|
1
|
+
{"version":3,"file":"heading.js","names":[],"sources":["../../src/typography/heading.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { HeadingProps } from './types';\n\nconst Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(\n (props, ref) => {\n const { level = 1, prefixCls: customisedCls, className, children, ...otherProps } = props;\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('typography', configContext.prefixCls, customisedCls);\n\n if (level < 1 || level > 6) {\n console.warn('The heading level parameter is invalid.');\n return null;\n }\n const cls = classNames(prefixCls, className);\n\n return React.createElement(\n `h${level}`,\n {\n ...otherProps,\n ref,\n className: cls,\n },\n children\n );\n }\n);\n\nHeading.displayName = 'Heading';\n\nexport default Heading;\n"],"mappings":";;;;;AAMA,MAAM,UAAU,MAAM,YACnB,OAAO,QAAQ;CACd,MAAM,EAAE,QAAQ,GAAG,WAAW,eAAe,WAAW,UAAU,GAAG,eAAe;CAEpF,MAAM,YAAY,aAAa,cADT,WAAW,cAAc,CACY,WAAW,cAAc;AAEpF,KAAI,QAAQ,KAAK,QAAQ,GAAG;AAC1B,UAAQ,KAAK,0CAA0C;AACvD,SAAO;;CAET,MAAM,MAAM,WAAW,WAAW,UAAU;AAE5C,QAAO,MAAM,cACX,IAAI,SACJ;EACE,GAAG;EACH;EACA,WAAW;EACZ,EACD,SACD;EAEJ;AAED,QAAQ,cAAc"}
|
|
@@ -4,8 +4,6 @@ $tp-prefix: #{$prefix}-typography;
|
|
|
4
4
|
|
|
5
5
|
.#{$tp-prefix} {
|
|
6
6
|
box-sizing: border-box;
|
|
7
|
-
font-family: $font-family;
|
|
8
|
-
|
|
9
7
|
& + h1.#{$tp-prefix},
|
|
10
8
|
& + h2.#{$tp-prefix},
|
|
11
9
|
& + h3.#{$tp-prefix},
|
|
@@ -46,22 +44,6 @@ $tp-prefix: #{$prefix}-typography;
|
|
|
46
44
|
background-color: var(--ty-typography-mark-bg);
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
u {
|
|
50
|
-
text-decoration: underline;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
del {
|
|
54
|
-
text-decoration: line-through;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
strong {
|
|
58
|
-
font-weight: 600;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
i {
|
|
62
|
-
font-style: italic;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
47
|
sup {
|
|
66
48
|
vertical-align: super;
|
|
67
49
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
.ty-typography {
|
|
2
2
|
box-sizing: border-box;
|
|
3
|
-
font-family: -apple-system, blinkmacsystemfont, "Segoe UI", roboto, "Helvetica Neue", arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
4
3
|
}
|
|
5
4
|
.ty-typography + h1.ty-typography, .ty-typography + h2.ty-typography, .ty-typography + h3.ty-typography, .ty-typography + h4.ty-typography {
|
|
6
5
|
margin-top: 1.2em;
|
|
@@ -31,18 +30,6 @@
|
|
|
31
30
|
padding: 0;
|
|
32
31
|
background-color: var(--ty-typography-mark-bg);
|
|
33
32
|
}
|
|
34
|
-
.ty-typography u {
|
|
35
|
-
text-decoration: underline;
|
|
36
|
-
}
|
|
37
|
-
.ty-typography del {
|
|
38
|
-
text-decoration: line-through;
|
|
39
|
-
}
|
|
40
|
-
.ty-typography strong {
|
|
41
|
-
font-weight: 600;
|
|
42
|
-
}
|
|
43
|
-
.ty-typography i {
|
|
44
|
-
font-style: italic;
|
|
45
|
-
}
|
|
46
33
|
.ty-typography sup {
|
|
47
34
|
vertical-align: super;
|
|
48
35
|
}
|
package/es/typography/text.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TextProps } from "./types.js";
|
|
2
|
+
import React from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/typography/text.d.ts
|
|
4
|
-
declare const Text:
|
|
5
|
+
declare const Text: React.ForwardRefExoticComponent<Omit<TextProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { Text };
|
|
7
8
|
//# sourceMappingURL=text.d.ts.map
|
package/es/typography/text.js
CHANGED
|
@@ -8,7 +8,7 @@ const tagGenerator = (isRequired, tag, element) => {
|
|
|
8
8
|
if (!isRequired) return element;
|
|
9
9
|
return React.createElement(tag, {}, element);
|
|
10
10
|
};
|
|
11
|
-
const Text = (props) => {
|
|
11
|
+
const Text = React.forwardRef((props, ref) => {
|
|
12
12
|
const { code = false, del = false, underline = false, strong = false, italic = false, mark = false, sub = false, sup = false, className, children, prefixCls: customisedCls, ...otherProps } = props;
|
|
13
13
|
let Node = tagGenerator(code, "code", children);
|
|
14
14
|
Node = tagGenerator(del, "del", Node);
|
|
@@ -21,10 +21,12 @@ const Text = (props) => {
|
|
|
21
21
|
const cls = classNames(className, getPrefixCls("typography", useContext(ConfigContext).prefixCls, customisedCls));
|
|
22
22
|
return /* @__PURE__ */ jsx("span", {
|
|
23
23
|
...otherProps,
|
|
24
|
+
ref,
|
|
24
25
|
className: cls,
|
|
25
26
|
children: Node
|
|
26
27
|
});
|
|
27
|
-
};
|
|
28
|
+
});
|
|
29
|
+
Text.displayName = "Text";
|
|
28
30
|
//#endregion
|
|
29
31
|
export { Text as default };
|
|
30
32
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":[],"sources":["../../src/typography/text.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { TextProps } from './types';\n\nconst tagGenerator = (\n isRequired: boolean,\n tag: string,\n element: React.ReactNode\n): React.ReactNode => {\n if (!isRequired) return element;\n return React.createElement(tag, {}, element);\n};\n\nconst Text = (props
|
|
1
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../src/typography/text.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { TextProps } from './types';\n\nconst tagGenerator = (\n isRequired: boolean,\n tag: string,\n element: React.ReactNode\n): React.ReactNode => {\n if (!isRequired) return element;\n return React.createElement(tag, {}, element);\n};\n\nconst Text = React.forwardRef<HTMLSpanElement, TextProps>(\n (props, ref) => {\n const {\n code = false,\n del = false,\n underline = false,\n strong = false,\n italic = false,\n mark = false,\n sub = false,\n sup = false,\n className,\n children,\n prefixCls: customisedCls,\n ...otherProps\n } = props;\n\n let Node = tagGenerator(code, 'code', children);\n Node = tagGenerator(del, 'del', Node);\n Node = tagGenerator(underline, 'u', Node);\n Node = tagGenerator(strong, 'strong', Node);\n Node = tagGenerator(italic, 'i', Node);\n Node = tagGenerator(mark, 'mark', Node);\n Node = tagGenerator(sub, 'sub', Node);\n Node = tagGenerator(sup, 'sup', Node);\n\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('typography', configContext.prefixCls, customisedCls);\n const cls = classNames(className, prefixCls);\n\n return (\n <span {...otherProps} ref={ref} className={cls}>\n {Node}\n </span>\n );\n }\n);\n\nText.displayName = 'Text';\n\nexport default Text;\n"],"mappings":";;;;;;AAMA,MAAM,gBACJ,YACA,KACA,YACoB;AACpB,KAAI,CAAC,WAAY,QAAO;AACxB,QAAO,MAAM,cAAc,KAAK,EAAE,EAAE,QAAQ;;AAG9C,MAAM,OAAO,MAAM,YAChB,OAAO,QAAQ;CACd,MAAM,EACJ,OAAO,OACP,MAAM,OACN,YAAY,OACZ,SAAS,OACT,SAAS,OACT,OAAO,OACP,MAAM,OACN,MAAM,OACN,WACA,UACA,WAAW,eACX,GAAG,eACD;CAEJ,IAAI,OAAO,aAAa,MAAM,QAAQ,SAAS;AAC/C,QAAO,aAAa,KAAK,OAAO,KAAK;AACrC,QAAO,aAAa,WAAW,KAAK,KAAK;AACzC,QAAO,aAAa,QAAQ,UAAU,KAAK;AAC3C,QAAO,aAAa,QAAQ,KAAK,KAAK;AACtC,QAAO,aAAa,MAAM,QAAQ,KAAK;AACvC,QAAO,aAAa,KAAK,OAAO,KAAK;AACrC,QAAO,aAAa,KAAK,OAAO,KAAK;CAIrC,MAAM,MAAM,WAAW,WADL,aAAa,cADT,WAAW,cAAc,CACY,WAAW,cAAc,CACxC;AAE5C,QACE,oBAAC,QAAD;EAAM,GAAI;EAAiB;EAAK,WAAW;YACxC;EACI,CAAA;EAGZ;AAED,KAAK,cAAc"}
|
package/es/typography/types.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ interface ParagraphProps extends BaseProps, React.PropsWithRef<JSX.IntrinsicElem
|
|
|
9
9
|
children?: React.ReactNode;
|
|
10
10
|
}
|
|
11
11
|
interface HeadingProps extends BaseProps, React.PropsWithRef<React.HTMLAttributes<HTMLHeadingElement>> {
|
|
12
|
-
level?:
|
|
12
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
13
13
|
children?: React.ReactNode;
|
|
14
14
|
}
|
|
15
15
|
interface TextProps extends BaseProps, React.PropsWithRef<JSX.IntrinsicElements['span']> {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { HeadingProps } from "./types.js";
|
|
2
|
+
import React from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/typography/heading.d.ts
|
|
4
|
-
declare const Heading:
|
|
5
|
+
declare const Heading: React.ForwardRefExoticComponent<HeadingProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { Heading };
|
|
7
8
|
//# sourceMappingURL=heading.d.ts.map
|
|
@@ -5,29 +5,22 @@ let react = require("react");
|
|
|
5
5
|
react = require_runtime.__toESM(react);
|
|
6
6
|
let classnames = require("classnames");
|
|
7
7
|
classnames = require_runtime.__toESM(classnames);
|
|
8
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
8
|
//#region src/typography/heading.tsx
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const cls = (0, classnames.default)(require_general.getPrefixCls("typography", (0, react.useContext)(require_config_context.ConfigContext).prefixCls, customisedCls), className);
|
|
14
|
-
return react.default.createElement(htmlType, {
|
|
15
|
-
...otherProps,
|
|
16
|
-
ref,
|
|
17
|
-
className: cls
|
|
18
|
-
}, children);
|
|
19
|
-
});
|
|
20
|
-
Component.displayName = displayName;
|
|
21
|
-
return Component;
|
|
22
|
-
};
|
|
23
|
-
const Heading = (props) => {
|
|
24
|
-
const { level = 1, ...otherProps } = props;
|
|
9
|
+
const Heading = react.default.forwardRef((props, ref) => {
|
|
10
|
+
const { level = 1, prefixCls: customisedCls, className, children, ...otherProps } = props;
|
|
11
|
+
const prefixCls = require_general.getPrefixCls("typography", (0, react.useContext)(require_config_context.ConfigContext).prefixCls, customisedCls);
|
|
25
12
|
if (level < 1 || level > 6) {
|
|
26
13
|
console.warn("The heading level parameter is invalid.");
|
|
27
14
|
return null;
|
|
28
15
|
}
|
|
29
|
-
|
|
30
|
-
}
|
|
16
|
+
const cls = (0, classnames.default)(prefixCls, className);
|
|
17
|
+
return react.default.createElement(`h${level}`, {
|
|
18
|
+
...otherProps,
|
|
19
|
+
ref,
|
|
20
|
+
className: cls
|
|
21
|
+
}, children);
|
|
22
|
+
});
|
|
23
|
+
Heading.displayName = "Heading";
|
|
31
24
|
//#endregion
|
|
32
25
|
exports.default = Heading;
|
|
33
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.js","names":["React","getPrefixCls","ConfigContext"],"sources":["../../src/typography/heading.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { HeadingProps } from './types';\n\nconst
|
|
1
|
+
{"version":3,"file":"heading.js","names":["React","getPrefixCls","ConfigContext"],"sources":["../../src/typography/heading.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { HeadingProps } from './types';\n\nconst Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(\n (props, ref) => {\n const { level = 1, prefixCls: customisedCls, className, children, ...otherProps } = props;\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('typography', configContext.prefixCls, customisedCls);\n\n if (level < 1 || level > 6) {\n console.warn('The heading level parameter is invalid.');\n return null;\n }\n const cls = classNames(prefixCls, className);\n\n return React.createElement(\n `h${level}`,\n {\n ...otherProps,\n ref,\n className: cls,\n },\n children\n );\n }\n);\n\nHeading.displayName = 'Heading';\n\nexport default Heading;\n"],"mappings":";;;;;;;;AAMA,MAAM,UAAUA,MAAAA,QAAM,YACnB,OAAO,QAAQ;CACd,MAAM,EAAE,QAAQ,GAAG,WAAW,eAAe,WAAW,UAAU,GAAG,eAAe;CAEpF,MAAM,YAAYC,gBAAAA,aAAa,eAAA,GAAA,MAAA,YADEC,uBAAAA,cAAc,CACY,WAAW,cAAc;AAEpF,KAAI,QAAQ,KAAK,QAAQ,GAAG;AAC1B,UAAQ,KAAK,0CAA0C;AACvD,SAAO;;CAET,MAAM,OAAA,GAAA,WAAA,SAAiB,WAAW,UAAU;AAE5C,QAAOF,MAAAA,QAAM,cACX,IAAI,SACJ;EACE,GAAG;EACH;EACA,WAAW;EACZ,EACD,SACD;EAEJ;AAED,QAAQ,cAAc"}
|
|
@@ -4,8 +4,6 @@ $tp-prefix: #{$prefix}-typography;
|
|
|
4
4
|
|
|
5
5
|
.#{$tp-prefix} {
|
|
6
6
|
box-sizing: border-box;
|
|
7
|
-
font-family: $font-family;
|
|
8
|
-
|
|
9
7
|
& + h1.#{$tp-prefix},
|
|
10
8
|
& + h2.#{$tp-prefix},
|
|
11
9
|
& + h3.#{$tp-prefix},
|
|
@@ -46,22 +44,6 @@ $tp-prefix: #{$prefix}-typography;
|
|
|
46
44
|
background-color: var(--ty-typography-mark-bg);
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
u {
|
|
50
|
-
text-decoration: underline;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
del {
|
|
54
|
-
text-decoration: line-through;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
strong {
|
|
58
|
-
font-weight: 600;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
i {
|
|
62
|
-
font-style: italic;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
47
|
sup {
|
|
66
48
|
vertical-align: super;
|
|
67
49
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
.ty-typography {
|
|
2
2
|
box-sizing: border-box;
|
|
3
|
-
font-family: -apple-system, blinkmacsystemfont, "Segoe UI", roboto, "Helvetica Neue", arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
4
3
|
}
|
|
5
4
|
.ty-typography + h1.ty-typography, .ty-typography + h2.ty-typography, .ty-typography + h3.ty-typography, .ty-typography + h4.ty-typography {
|
|
6
5
|
margin-top: 1.2em;
|
|
@@ -31,18 +30,6 @@
|
|
|
31
30
|
padding: 0;
|
|
32
31
|
background-color: var(--ty-typography-mark-bg);
|
|
33
32
|
}
|
|
34
|
-
.ty-typography u {
|
|
35
|
-
text-decoration: underline;
|
|
36
|
-
}
|
|
37
|
-
.ty-typography del {
|
|
38
|
-
text-decoration: line-through;
|
|
39
|
-
}
|
|
40
|
-
.ty-typography strong {
|
|
41
|
-
font-weight: 600;
|
|
42
|
-
}
|
|
43
|
-
.ty-typography i {
|
|
44
|
-
font-style: italic;
|
|
45
|
-
}
|
|
46
33
|
.ty-typography sup {
|
|
47
34
|
vertical-align: super;
|
|
48
35
|
}
|
package/lib/typography/text.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TextProps } from "./types.js";
|
|
2
|
+
import React from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/typography/text.d.ts
|
|
4
|
-
declare const Text:
|
|
5
|
+
declare const Text: React.ForwardRefExoticComponent<Omit<TextProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { Text };
|
|
7
8
|
//# sourceMappingURL=text.d.ts.map
|
package/lib/typography/text.js
CHANGED
|
@@ -11,7 +11,7 @@ const tagGenerator = (isRequired, tag, element) => {
|
|
|
11
11
|
if (!isRequired) return element;
|
|
12
12
|
return react.default.createElement(tag, {}, element);
|
|
13
13
|
};
|
|
14
|
-
const Text = (props) => {
|
|
14
|
+
const Text = react.default.forwardRef((props, ref) => {
|
|
15
15
|
const { code = false, del = false, underline = false, strong = false, italic = false, mark = false, sub = false, sup = false, className, children, prefixCls: customisedCls, ...otherProps } = props;
|
|
16
16
|
let Node = tagGenerator(code, "code", children);
|
|
17
17
|
Node = tagGenerator(del, "del", Node);
|
|
@@ -24,10 +24,12 @@ const Text = (props) => {
|
|
|
24
24
|
const cls = (0, classnames.default)(className, require_general.getPrefixCls("typography", (0, react.useContext)(require_config_context.ConfigContext).prefixCls, customisedCls));
|
|
25
25
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
26
26
|
...otherProps,
|
|
27
|
+
ref,
|
|
27
28
|
className: cls,
|
|
28
29
|
children: Node
|
|
29
30
|
});
|
|
30
|
-
};
|
|
31
|
+
});
|
|
32
|
+
Text.displayName = "Text";
|
|
31
33
|
//#endregion
|
|
32
34
|
exports.default = Text;
|
|
33
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":["React","getPrefixCls","ConfigContext"],"sources":["../../src/typography/text.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { TextProps } from './types';\n\nconst tagGenerator = (\n isRequired: boolean,\n tag: string,\n element: React.ReactNode\n): React.ReactNode => {\n if (!isRequired) return element;\n return React.createElement(tag, {}, element);\n};\n\nconst Text = (props
|
|
1
|
+
{"version":3,"file":"text.js","names":["React","getPrefixCls","ConfigContext"],"sources":["../../src/typography/text.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { TextProps } from './types';\n\nconst tagGenerator = (\n isRequired: boolean,\n tag: string,\n element: React.ReactNode\n): React.ReactNode => {\n if (!isRequired) return element;\n return React.createElement(tag, {}, element);\n};\n\nconst Text = React.forwardRef<HTMLSpanElement, TextProps>(\n (props, ref) => {\n const {\n code = false,\n del = false,\n underline = false,\n strong = false,\n italic = false,\n mark = false,\n sub = false,\n sup = false,\n className,\n children,\n prefixCls: customisedCls,\n ...otherProps\n } = props;\n\n let Node = tagGenerator(code, 'code', children);\n Node = tagGenerator(del, 'del', Node);\n Node = tagGenerator(underline, 'u', Node);\n Node = tagGenerator(strong, 'strong', Node);\n Node = tagGenerator(italic, 'i', Node);\n Node = tagGenerator(mark, 'mark', Node);\n Node = tagGenerator(sub, 'sub', Node);\n Node = tagGenerator(sup, 'sup', Node);\n\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('typography', configContext.prefixCls, customisedCls);\n const cls = classNames(className, prefixCls);\n\n return (\n <span {...otherProps} ref={ref} className={cls}>\n {Node}\n </span>\n );\n }\n);\n\nText.displayName = 'Text';\n\nexport default Text;\n"],"mappings":";;;;;;;;;AAMA,MAAM,gBACJ,YACA,KACA,YACoB;AACpB,KAAI,CAAC,WAAY,QAAO;AACxB,QAAOA,MAAAA,QAAM,cAAc,KAAK,EAAE,EAAE,QAAQ;;AAG9C,MAAM,OAAOA,MAAAA,QAAM,YAChB,OAAO,QAAQ;CACd,MAAM,EACJ,OAAO,OACP,MAAM,OACN,YAAY,OACZ,SAAS,OACT,SAAS,OACT,OAAO,OACP,MAAM,OACN,MAAM,OACN,WACA,UACA,WAAW,eACX,GAAG,eACD;CAEJ,IAAI,OAAO,aAAa,MAAM,QAAQ,SAAS;AAC/C,QAAO,aAAa,KAAK,OAAO,KAAK;AACrC,QAAO,aAAa,WAAW,KAAK,KAAK;AACzC,QAAO,aAAa,QAAQ,UAAU,KAAK;AAC3C,QAAO,aAAa,QAAQ,KAAK,KAAK;AACtC,QAAO,aAAa,MAAM,QAAQ,KAAK;AACvC,QAAO,aAAa,KAAK,OAAO,KAAK;AACrC,QAAO,aAAa,KAAK,OAAO,KAAK;CAIrC,MAAM,OAAA,GAAA,WAAA,SAAiB,WADLC,gBAAAA,aAAa,eAAA,GAAA,MAAA,YADEC,uBAAAA,cAAc,CACY,WAAW,cAAc,CACxC;AAE5C,QACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;EAAM,GAAI;EAAiB;EAAK,WAAW;YACxC;EACI,CAAA;EAGZ;AAED,KAAK,cAAc"}
|
|
@@ -9,7 +9,7 @@ interface ParagraphProps extends BaseProps, React.PropsWithRef<JSX.IntrinsicElem
|
|
|
9
9
|
children?: React.ReactNode;
|
|
10
10
|
}
|
|
11
11
|
interface HeadingProps extends BaseProps, React.PropsWithRef<React.HTMLAttributes<HTMLHeadingElement>> {
|
|
12
|
-
level?:
|
|
12
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
13
13
|
children?: React.ReactNode;
|
|
14
14
|
}
|
|
15
15
|
interface TextProps extends BaseProps, React.PropsWithRef<JSX.IntrinsicElements['span']> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiny-design/react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "A friendly UI component set for React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"classnames": "^2.3.1",
|
|
56
56
|
"react-transition-group": "^4.4.2",
|
|
57
57
|
"tslib": "^2.3.1",
|
|
58
|
-
"@tiny-design/icons": "1.0.
|
|
59
|
-
"@tiny-design/tokens": "1.0.
|
|
58
|
+
"@tiny-design/icons": "1.0.10",
|
|
59
|
+
"@tiny-design/tokens": "1.0.10"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@testing-library/jest-dom": "^6.0.0",
|