@xsolla/xui-svg-themed-web 0.64.0-pr56.1768348754
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/index.d.mts +13 -0
- package/index.d.ts +13 -0
- package/index.js +77 -0
- package/index.js.map +1 -0
- package/index.mjs +55 -0
- package/index.mjs.map +1 -0
- package/package.json +24 -0
package/index.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { SVGProps, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
interface SvgThemedProps extends SVGProps<SVGSVGElement> {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* Optional test ID for testing
|
|
7
|
+
*/
|
|
8
|
+
"data-testid"?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare const SvgThemed: React.ForwardRefExoticComponent<Omit<SvgThemedProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
12
|
+
|
|
13
|
+
export { SvgThemed, type SvgThemedProps };
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { SVGProps, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
interface SvgThemedProps extends SVGProps<SVGSVGElement> {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* Optional test ID for testing
|
|
7
|
+
*/
|
|
8
|
+
"data-testid"?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare const SvgThemed: React.ForwardRefExoticComponent<Omit<SvgThemedProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
12
|
+
|
|
13
|
+
export { SvgThemed, type SvgThemedProps };
|
package/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.tsx
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
SvgThemed: () => SvgThemed
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/SvgThemed.tsx
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_xui_core = require("@xsolla/xui-core");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var resolveToken = (value, theme) => {
|
|
32
|
+
if (typeof value === "string" && value.startsWith("$")) {
|
|
33
|
+
const token = value.slice(1);
|
|
34
|
+
const tokenMap = {
|
|
35
|
+
colors_core_text_primary: theme.colors.content.primary,
|
|
36
|
+
colors_core_text_secondary: theme.colors.content.secondary,
|
|
37
|
+
colors_core_text_tertiary: theme.colors.content.tertiary,
|
|
38
|
+
colors_core_text_brand: theme.colors.content.brand.primary,
|
|
39
|
+
colors_core_text_success: theme.colors.content.success.primary,
|
|
40
|
+
colors_core_text_warning: theme.colors.content.warning.primary,
|
|
41
|
+
colors_core_text_alert: theme.colors.content.alert.primary,
|
|
42
|
+
colors_core_text_neutral: theme.colors.content.neutral.primary,
|
|
43
|
+
colors_control_faint_bg: theme.colors.control.mono.secondary.bg
|
|
44
|
+
};
|
|
45
|
+
return tokenMap[token] || value;
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
};
|
|
49
|
+
var processChildren = (children, theme) => {
|
|
50
|
+
return import_react.Children.map(children, (child) => {
|
|
51
|
+
if (!(0, import_react.isValidElement)(child)) return child;
|
|
52
|
+
const props = { ...child.props };
|
|
53
|
+
const themeableProps = ["fill", "stroke", "stopColor", "color"];
|
|
54
|
+
themeableProps.forEach((prop) => {
|
|
55
|
+
if (props[prop]) {
|
|
56
|
+
props[prop] = resolveToken(props[prop], theme);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
if (props.children) {
|
|
60
|
+
props.children = processChildren(props.children, theme);
|
|
61
|
+
}
|
|
62
|
+
return (0, import_react.cloneElement)(child, props);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
var SvgThemed = (0, import_react.forwardRef)(
|
|
66
|
+
({ children, ...props }, ref) => {
|
|
67
|
+
const { theme } = (0, import_xui_core.useDesignSystem)();
|
|
68
|
+
const themedChildren = processChildren(children, theme);
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { ref, ...props, children: themedChildren });
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
SvgThemed.displayName = "SvgThemed";
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
SvgThemed
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.tsx","../../src/SvgThemed.tsx"],"sourcesContent":["export * from \"./SvgThemed\";\nexport * from \"./types\";\n","import React, {\n Children,\n cloneElement,\n forwardRef,\n isValidElement,\n} from \"react\";\nimport { useDesignSystem } from \"@xsolla/xui-core\";\nimport type { SvgThemedProps } from \"./types\";\n\nconst resolveToken = (value: any, theme: any) => {\n if (typeof value === \"string\" && value.startsWith(\"$\")) {\n const token = value.slice(1);\n\n // Mapping for common tokens used in display packages\n const tokenMap: Record<string, any> = {\n colors_core_text_primary: theme.colors.content.primary,\n colors_core_text_secondary: theme.colors.content.secondary,\n colors_core_text_tertiary: theme.colors.content.tertiary,\n colors_core_text_brand: theme.colors.content.brand.primary,\n colors_core_text_success: theme.colors.content.success.primary,\n colors_core_text_warning: theme.colors.content.warning.primary,\n colors_core_text_alert: theme.colors.content.alert.primary,\n colors_core_text_neutral: theme.colors.content.neutral.primary,\n colors_control_faint_bg: theme.colors.control.mono.secondary.bg,\n };\n\n return tokenMap[token] || value;\n }\n return value;\n};\n\nconst processChildren = (\n children: React.ReactNode,\n theme: any\n): React.ReactNode => {\n return Children.map(children, (child) => {\n if (!isValidElement(child)) return child;\n\n const props: any = { ...(child.props as any) };\n const themeableProps = [\"fill\", \"stroke\", \"stopColor\", \"color\"];\n\n themeableProps.forEach((prop) => {\n if (props[prop]) {\n props[prop] = resolveToken(props[prop], theme);\n }\n });\n\n if (props.children) {\n props.children = processChildren(props.children, theme);\n }\n\n return cloneElement(child, props);\n });\n};\n\nexport const SvgThemed = forwardRef<SVGSVGElement, SvgThemedProps>(\n ({ children, ...props }, ref) => {\n const { theme } = useDesignSystem();\n const themedChildren = processChildren(children, theme);\n\n return (\n <svg ref={ref} {...props}>\n {themedChildren}\n </svg>\n );\n }\n);\n\nSvgThemed.displayName = \"SvgThemed\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAKO;AACP,sBAAgC;AAuD1B;AApDN,IAAM,eAAe,CAAC,OAAY,UAAe;AAC/C,MAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAAG,GAAG;AACtD,UAAM,QAAQ,MAAM,MAAM,CAAC;AAG3B,UAAM,WAAgC;AAAA,MACpC,0BAA0B,MAAM,O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,55 @@
|
|
|
1
|
+
// src/SvgThemed.tsx
|
|
2
|
+
import {
|
|
3
|
+
Children,
|
|
4
|
+
cloneElement,
|
|
5
|
+
forwardRef,
|
|
6
|
+
isValidElement
|
|
7
|
+
} from "react";
|
|
8
|
+
import { useDesignSystem } from "@xsolla/xui-core";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var resolveToken = (value, theme) => {
|
|
11
|
+
if (typeof value === "string" && value.startsWith("$")) {
|
|
12
|
+
const token = value.slice(1);
|
|
13
|
+
const tokenMap = {
|
|
14
|
+
colors_core_text_primary: theme.colors.content.primary,
|
|
15
|
+
colors_core_text_secondary: theme.colors.content.secondary,
|
|
16
|
+
colors_core_text_tertiary: theme.colors.content.tertiary,
|
|
17
|
+
colors_core_text_brand: theme.colors.content.brand.primary,
|
|
18
|
+
colors_core_text_success: theme.colors.content.success.primary,
|
|
19
|
+
colors_core_text_warning: theme.colors.content.warning.primary,
|
|
20
|
+
colors_core_text_alert: theme.colors.content.alert.primary,
|
|
21
|
+
colors_core_text_neutral: theme.colors.content.neutral.primary,
|
|
22
|
+
colors_control_faint_bg: theme.colors.control.mono.secondary.bg
|
|
23
|
+
};
|
|
24
|
+
return tokenMap[token] || value;
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
var processChildren = (children, theme) => {
|
|
29
|
+
return Children.map(children, (child) => {
|
|
30
|
+
if (!isValidElement(child)) return child;
|
|
31
|
+
const props = { ...child.props };
|
|
32
|
+
const themeableProps = ["fill", "stroke", "stopColor", "color"];
|
|
33
|
+
themeableProps.forEach((prop) => {
|
|
34
|
+
if (props[prop]) {
|
|
35
|
+
props[prop] = resolveToken(props[prop], theme);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (props.children) {
|
|
39
|
+
props.children = processChildren(props.children, theme);
|
|
40
|
+
}
|
|
41
|
+
return cloneElement(child, props);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var SvgThemed = forwardRef(
|
|
45
|
+
({ children, ...props }, ref) => {
|
|
46
|
+
const { theme } = useDesignSystem();
|
|
47
|
+
const themedChildren = processChildren(children, theme);
|
|
48
|
+
return /* @__PURE__ */ jsx("svg", { ref, ...props, children: themedChildren });
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
SvgThemed.displayName = "SvgThemed";
|
|
52
|
+
export {
|
|
53
|
+
SvgThemed
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/SvgThemed.tsx"],"sourcesContent":["import React, {\n Children,\n cloneElement,\n forwardRef,\n isValidElement,\n} from \"react\";\nimport { useDesignSystem } from \"@xsolla/xui-core\";\nimport type { SvgThemedProps } from \"./types\";\n\nconst resolveToken = (value: any, theme: any) => {\n if (typeof value === \"string\" && value.startsWith(\"$\")) {\n const token = value.slice(1);\n\n // Mapping for common tokens used in display packages\n const tokenMap: Record<string, any> = {\n colors_core_text_primary: theme.colors.content.primary,\n colors_core_text_secondary: theme.colors.content.secondary,\n colors_core_text_tertiary: theme.colors.content.tertiary,\n colors_core_text_brand: theme.colors.content.brand.primary,\n colors_core_text_success: theme.colors.content.success.primary,\n colors_core_text_warning: theme.colors.content.warning.primary,\n colors_core_text_alert: theme.colors.content.alert.primary,\n colors_core_text_neutral: theme.colors.content.neutral.primary,\n colors_control_faint_bg: theme.colors.control.mono.secondary.bg,\n };\n\n return tokenMap[token] || value;\n }\n return value;\n};\n\nconst processChildren = (\n children: React.ReactNode,\n theme: any\n): React.ReactNode => {\n return Children.map(children, (child) => {\n if (!isValidElement(child)) return child;\n\n const props: any = { ...(child.props as any) };\n const themeableProps = [\"fill\", \"stroke\", \"stopColor\", \"color\"];\n\n themeableProps.forEach((prop) => {\n if (props[prop]) {\n props[prop] = resolveToken(props[prop], theme);\n }\n });\n\n if (props.children) {\n props.children = processChildren(props.children, theme);\n }\n\n return cloneElement(child, props);\n });\n};\n\nexport const SvgThemed = forwardRef<SVGSVGElement, SvgThemedProps>(\n ({ children, ...props }, ref) => {\n const { theme } = useDesignSystem();\n const themedChildren = processChildren(children, theme);\n\n return (\n <svg ref={ref} {...props}>\n {themedChildren}\n </svg>\n );\n }\n);\n\nSvgThemed.displayName = \"SvgThemed\";\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAuD1B;AApDN,IAAM,eAAe,CAAC,OAAY,UAAe;AAC/C,MAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAAG,GAAG;AACtD,UAAM,QAAQ,MAAM,MAAM,CAAC;AAG3B,UAAM,WAAgC;AAAA,MACpC,0BAA0B,MAAM,OAAO,QAAQ;AAAA,MAC/C,4BAA4B,MAAM,OAAO,QAAQ;AAAA,MACjD,2BAA2B,MAAM,OAAO,QAAQ;AAAA,MAChD,wBAAwB,MAAM,OAAO,QAAQ,MAAM;AAAA,MACnD,0BAA0B,MAAM,OAAO,QAAQ,QAAQ;AAAA,MACvD,0BAA0B,MAAM,OAAO,QAAQ,QAAQ;AAAA,MACvD,wBAAwB,MAAM,OAAO,QAAQ,MAAM;AAAA,MACnD,0BAA0B,MAAM,OAAO,QAAQ,QAAQ;AAAA,MACvD,yBAAyB,MAAM,OAAO,QAAQ,KAAK,UAAU;AAAA,IAC/D;AAEA,WAAO,SAAS,KAAK,KAAK;AAAA,EAC5B;AACA,SAAO;AACT;AAEA,IAAM,kBAAkB,CACtB,UACA,UACoB;AACpB,SAAO,SAAS,IAAI,UAAU,CAAC,UAAU;AACvC,QAAI,CAAC,eAAe,KAAK,EAAG,QAAO;AAEnC,UAAM,QAAa,EAAE,GAAI,MAAM,MAAc;AAC7C,UAAM,iBAAiB,CAAC,QAAQ,UAAU,aAAa,OAAO;AAE9D,mBAAe,QAAQ,CAAC,SAAS;AAC/B,UAAI,MAAM,IAAI,GAAG;AACf,cAAM,IAAI,IAAI,aAAa,MAAM,IAAI,GAAG,KAAK;AAAA,MAC/C;AAAA,IACF,CAAC;AAED,QAAI,MAAM,UAAU;AAClB,YAAM,WAAW,gBAAgB,MAAM,UAAU,KAAK;AAAA,IACxD;AAEA,WAAO,aAAa,OAAO,KAAK;AAAA,EAClC,CAAC;AACH;AAEO,IAAM,YAAY;AAAA,EACvB,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC/B,UAAM,EAAE,MAAM,IAAI,gBAAgB;AAClC,UAAM,iBAAiB,gBAAgB,UAAU,KAAK;AAEtD,WACE,oBAAC,SAAI,KAAW,GAAG,OAChB,0BACH;AAAA,EAEJ;AACF;AAEA,UAAU,cAAc;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xsolla/xui-svg-themed-web",
|
|
3
|
+
"version": "0.64.0-pr56.1768348754",
|
|
4
|
+
"main": "./index.js",
|
|
5
|
+
"module": "./index.mjs",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "yarn build:web && yarn build:native",
|
|
9
|
+
"build:web": "PLATFORM=web tsup src/index.tsx --format esm,cjs --dts --env.PLATFORM web --clean",
|
|
10
|
+
"build:native": "PLATFORM=native tsup src/index.tsx --format esm,cjs --dts --env.PLATFORM native --clean"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@xsolla/xui-core": "0.64.0-pr56.1768348754",
|
|
14
|
+
"@xsolla/xui-primitives-core": "0.64.0-pr56.1768348754"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"react": ">=16.8.0",
|
|
18
|
+
"styled-components": ">=4"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"tsup": "^8.0.0"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT"
|
|
24
|
+
}
|