@vnejs/uis.react.char 0.2.0 → 0.2.1
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/dist/Char.d.ts +3 -1
- package/dist/Char.d.ts.map +1 -1
- package/dist/Char.js +34 -28
- package/dist/Char.js.map +1 -1
- package/package.json +1 -1
- package/src/Char.tsx +27 -35
package/dist/Char.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type CharProps } from "./Char.types.js";
|
|
2
|
-
|
|
2
|
+
declare const CharComponent: ({ token, marks, isVisible, isForce }?: CharProps) => import("react").JSX.Element;
|
|
3
|
+
export declare const Char: import("react").MemoExoticComponent<typeof CharComponent>;
|
|
4
|
+
export {};
|
|
3
5
|
//# sourceMappingURL=Char.d.ts.map
|
package/dist/Char.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Char.d.ts","sourceRoot":"","sources":["../src/Char.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Char.d.ts","sourceRoot":"","sources":["../src/Char.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAMjD,QAAA,MAAM,aAAa,0CAAoE,SAAS,gCAiC/F,CAAC;AAEF,eAAO,MAAM,IAAI,2DAAsB,CAAC"}
|
package/dist/Char.js
CHANGED
|
@@ -1,34 +1,40 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { memo } from "react";
|
|
3
3
|
import { b } from "./Char.styles.js";
|
|
4
4
|
const MARKS_PREFIXES = { COLOR: "color:", WEIGHT: "weight:", OPACITY: "opacity:", ANIMATION: "animation:", ZOOM: "zoom:" };
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
5
|
+
const CharComponent = ({ token = "", marks = [], isVisible = false, isForce = false } = {}) => {
|
|
6
|
+
const style = {};
|
|
7
|
+
const otherMarks = {};
|
|
8
|
+
let zoom;
|
|
9
|
+
let color;
|
|
10
|
+
let weight;
|
|
11
|
+
let opacity;
|
|
12
|
+
let animation;
|
|
13
|
+
for (const mark of marks) {
|
|
14
|
+
if (mark.startsWith(MARKS_PREFIXES.ZOOM))
|
|
15
|
+
zoom = mark.slice(MARKS_PREFIXES.ZOOM.length);
|
|
16
|
+
else if (mark.startsWith(MARKS_PREFIXES.COLOR))
|
|
17
|
+
color = mark.slice(MARKS_PREFIXES.COLOR.length);
|
|
18
|
+
else if (mark.startsWith(MARKS_PREFIXES.WEIGHT))
|
|
19
|
+
weight = mark.slice(MARKS_PREFIXES.WEIGHT.length);
|
|
20
|
+
else if (mark.startsWith(MARKS_PREFIXES.OPACITY))
|
|
21
|
+
opacity = mark.slice(MARKS_PREFIXES.OPACITY.length);
|
|
22
|
+
else if (mark.startsWith(MARKS_PREFIXES.ANIMATION))
|
|
23
|
+
animation = mark.slice(MARKS_PREFIXES.ANIMATION.length);
|
|
24
|
+
else
|
|
25
|
+
otherMarks[mark] = true;
|
|
26
|
+
}
|
|
27
|
+
if (zoom)
|
|
28
|
+
style.zoom = zoom;
|
|
29
|
+
if (color)
|
|
30
|
+
style.color = color;
|
|
31
|
+
if (weight)
|
|
32
|
+
style.fontWeight = weight;
|
|
33
|
+
if (opacity)
|
|
34
|
+
style["--vne-char-visible-opacity"] = opacity;
|
|
35
|
+
if (animation)
|
|
36
|
+
style.animation = animation;
|
|
32
37
|
return (_jsx("div", { className: b({ isVisible, isForce, ...otherMarks }), style: style, children: token }));
|
|
33
38
|
};
|
|
39
|
+
export const Char = memo(CharComponent);
|
|
34
40
|
//# sourceMappingURL=Char.js.map
|
package/dist/Char.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Char.js","sourceRoot":"","sources":["../src/Char.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Char.js","sourceRoot":"","sources":["../src/Char.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAI7B,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AAErC,MAAM,cAAc,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAE3H,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,KAAK,GAAG,EAAE,EAAE,SAAS,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,GAAc,EAAE,EAAE,EAAE;IACvG,MAAM,KAAK,GAAoC,EAAE,CAAC;IAClD,MAAM,UAAU,GAA4B,EAAE,CAAC;IAE/C,IAAI,IAAwB,CAAC;IAC7B,IAAI,KAAyB,CAAC;IAC9B,IAAI,MAA0B,CAAC;IAC/B,IAAI,OAA2B,CAAC;IAChC,IAAI,SAA6B,CAAC;IAElC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC;YAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACnF,IAAI,IAAI,CAAC,UAAU,CAAC,cAA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
|
1
|
+
import { memo } from "react";
|
|
2
2
|
|
|
3
3
|
import { type CharProps } from "./Char.types.js";
|
|
4
4
|
|
|
5
5
|
import { b } from "./Char.styles.js";
|
|
6
6
|
|
|
7
7
|
const MARKS_PREFIXES = { COLOR: "color:", WEIGHT: "weight:", OPACITY: "opacity:", ANIMATION: "animation:", ZOOM: "zoom:" };
|
|
8
|
-
const MARKS_PREFIXES_VALUES = Object.values(MARKS_PREFIXES);
|
|
9
8
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const otherMarks = useMemo(
|
|
36
|
-
() =>
|
|
37
|
-
marks.reduce<Record<string, boolean>>(
|
|
38
|
-
(acc, mark) => (MARKS_PREFIXES_VALUES.some((prefix) => mark.startsWith(prefix)) ? acc : { ...acc, [mark]: true }),
|
|
39
|
-
{},
|
|
40
|
-
),
|
|
41
|
-
[marks],
|
|
42
|
-
);
|
|
9
|
+
const CharComponent = ({ token = "", marks = [], isVisible = false, isForce = false }: CharProps = {}) => {
|
|
10
|
+
const style: Record<string, string | number> = {};
|
|
11
|
+
const otherMarks: Record<string, boolean> = {};
|
|
12
|
+
|
|
13
|
+
let zoom: string | undefined;
|
|
14
|
+
let color: string | undefined;
|
|
15
|
+
let weight: string | undefined;
|
|
16
|
+
let opacity: string | undefined;
|
|
17
|
+
let animation: string | undefined;
|
|
18
|
+
|
|
19
|
+
for (const mark of marks) {
|
|
20
|
+
if (mark.startsWith(MARKS_PREFIXES.ZOOM)) zoom = mark.slice(MARKS_PREFIXES.ZOOM.length);
|
|
21
|
+
else if (mark.startsWith(MARKS_PREFIXES.COLOR)) color = mark.slice(MARKS_PREFIXES.COLOR.length);
|
|
22
|
+
else if (mark.startsWith(MARKS_PREFIXES.WEIGHT)) weight = mark.slice(MARKS_PREFIXES.WEIGHT.length);
|
|
23
|
+
else if (mark.startsWith(MARKS_PREFIXES.OPACITY)) opacity = mark.slice(MARKS_PREFIXES.OPACITY.length);
|
|
24
|
+
else if (mark.startsWith(MARKS_PREFIXES.ANIMATION)) animation = mark.slice(MARKS_PREFIXES.ANIMATION.length);
|
|
25
|
+
else otherMarks[mark] = true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (zoom) style.zoom = zoom;
|
|
29
|
+
if (color) style.color = color;
|
|
30
|
+
if (weight) style.fontWeight = weight;
|
|
31
|
+
if (opacity) style["--vne-char-visible-opacity"] = opacity;
|
|
32
|
+
if (animation) style.animation = animation;
|
|
43
33
|
|
|
44
34
|
return (
|
|
45
35
|
<div
|
|
@@ -50,3 +40,5 @@ export const Char = ({ token = "", marks = [], isVisible = false, isForce = fals
|
|
|
50
40
|
</div>
|
|
51
41
|
);
|
|
52
42
|
};
|
|
43
|
+
|
|
44
|
+
export const Char = memo(CharComponent);
|