@xsolla/xui-b2c-currency-tag 0.211.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/README.md +3 -0
- package/native/index.d.mts +85 -0
- package/native/index.d.ts +85 -0
- package/native/index.js +475 -0
- package/native/index.js.map +1 -0
- package/native/index.mjs +458 -0
- package/native/index.mjs.map +1 -0
- package/package.json +57 -0
- package/web/index.d.mts +85 -0
- package/web/index.d.ts +85 -0
- package/web/index.js +4047 -0
- package/web/index.js.map +1 -0
- package/web/index.mjs +4036 -0
- package/web/index.mjs.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ThemeOverrideProps, ComponentSize } from '@xsolla/xui-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Xsolla virtual currency the tag represents. Maps 1:1 onto the `Type` variant
|
|
6
|
+
* of the Figma `CurrencyTag` component set.
|
|
7
|
+
*/
|
|
8
|
+
type CurrencyType = "xsolla-points" | "xsolla-tickets" | "xsolla-gold" | "play-time" | "green-orb";
|
|
9
|
+
/** Which side of the value the currency icon sits on. Figma: `Icon`. */
|
|
10
|
+
type CurrencyTagIconPosition = "left" | "right";
|
|
11
|
+
/**
|
|
12
|
+
* Tag size. Figma's size matrix (`6767:26747`) is XS / S / M / L / XL —
|
|
13
|
+
* mapped onto the toolkit `ComponentSize` scale. Default `'sm'` matches the
|
|
14
|
+
* 24px `CurrencyTag` component set.
|
|
15
|
+
*/
|
|
16
|
+
type CurrencyTagSize = ComponentSize;
|
|
17
|
+
interface CurrencyTagProps extends ThemeOverrideProps {
|
|
18
|
+
/** Currency the tag represents. Default: `'xsolla-points'` */
|
|
19
|
+
currency?: CurrencyType;
|
|
20
|
+
/**
|
|
21
|
+
* Size of the tag. Default: `'sm'` (the Figma `CurrencyTag` chip).
|
|
22
|
+
* Figma size matrix: XS / S / M / L / XL → `xs` / `sm` / `md` / `lg` / `xl`.
|
|
23
|
+
*/
|
|
24
|
+
size?: CurrencyTagSize;
|
|
25
|
+
/** The amount shown in the tag, e.g. `250` or `'+250'` */
|
|
26
|
+
value?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Previous amount, rendered struck through and dimmed before `value`.
|
|
29
|
+
* Figma: the `Sublable` boolean property.
|
|
30
|
+
*/
|
|
31
|
+
sublabel?: ReactNode;
|
|
32
|
+
/** Side the currency icon sits on. Default: `'left'` */
|
|
33
|
+
iconPosition?: CurrencyTagIconPosition;
|
|
34
|
+
/**
|
|
35
|
+
* Renders the tag on the themed surface with accent-coloured content instead
|
|
36
|
+
* of a solid accent fill. Figma: `Inverted=Yes`. Default: `false`
|
|
37
|
+
*/
|
|
38
|
+
inverted?: boolean;
|
|
39
|
+
/** Replaces the built-in currency icon. Pass `null` to render no icon. */
|
|
40
|
+
icon?: ReactNode;
|
|
41
|
+
/** Accessible label for the tag. Falls back to the rendered text. */
|
|
42
|
+
"aria-label"?: string;
|
|
43
|
+
/** Test identifier applied to the root element. */
|
|
44
|
+
testID?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare const CurrencyTag: React.FC<CurrencyTagProps>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Per-currency accent palette.
|
|
51
|
+
*
|
|
52
|
+
* Values are taken verbatim from the `CurrencyTag` component set in the B2C
|
|
53
|
+
* Figma library (node `1738:20679`). They are Figma-local variables with no
|
|
54
|
+
* counterpart in the shared XUI theme tokens, so they live here rather than in
|
|
55
|
+
* `@xsolla/xui-core`. `bg` is the solid tag fill of the non-inverted variant and
|
|
56
|
+
* doubles as the content colour of the inverted variant; `border` is the 1px
|
|
57
|
+
* inside stroke of the non-inverted variant.
|
|
58
|
+
*/
|
|
59
|
+
declare const CURRENCY_TAG_PALETTE: Record<CurrencyType, {
|
|
60
|
+
bg: string;
|
|
61
|
+
border: string;
|
|
62
|
+
}>;
|
|
63
|
+
/** Content colour on the solid (non-inverted) tag. Figma: `#000000`. */
|
|
64
|
+
declare const CURRENCY_TAG_SOLID_CONTENT_COLOR = "#000000";
|
|
65
|
+
/**
|
|
66
|
+
* Geometry extras that stay constant across sizes, plus the Figma `sm` snapshot
|
|
67
|
+
* (node `1738:20679`, 24px). Height, padding, radius, icon, and type scale
|
|
68
|
+
* with `theme.sizing.tag(size)` — XS / S / M / L / XL in Figma.
|
|
69
|
+
*/
|
|
70
|
+
declare const CURRENCY_TAG_METRICS: {
|
|
71
|
+
readonly height: 24;
|
|
72
|
+
readonly paddingHorizontal: 4;
|
|
73
|
+
readonly borderRadius: 4;
|
|
74
|
+
readonly borderWidth: 1;
|
|
75
|
+
readonly iconSize: 16;
|
|
76
|
+
readonly textPaddingHorizontal: 2;
|
|
77
|
+
readonly textGap: 3;
|
|
78
|
+
readonly fontSize: 14;
|
|
79
|
+
readonly lineHeight: 16;
|
|
80
|
+
readonly fontWeight: 500;
|
|
81
|
+
/** Opacity applied to the struck-through sublabel. */
|
|
82
|
+
readonly sublabelOpacity: 0.48;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { CURRENCY_TAG_METRICS, CURRENCY_TAG_PALETTE, CURRENCY_TAG_SOLID_CONTENT_COLOR, CurrencyTag, type CurrencyTagIconPosition, type CurrencyTagProps, type CurrencyTagSize, type CurrencyType };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ThemeOverrideProps, ComponentSize } from '@xsolla/xui-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Xsolla virtual currency the tag represents. Maps 1:1 onto the `Type` variant
|
|
6
|
+
* of the Figma `CurrencyTag` component set.
|
|
7
|
+
*/
|
|
8
|
+
type CurrencyType = "xsolla-points" | "xsolla-tickets" | "xsolla-gold" | "play-time" | "green-orb";
|
|
9
|
+
/** Which side of the value the currency icon sits on. Figma: `Icon`. */
|
|
10
|
+
type CurrencyTagIconPosition = "left" | "right";
|
|
11
|
+
/**
|
|
12
|
+
* Tag size. Figma's size matrix (`6767:26747`) is XS / S / M / L / XL —
|
|
13
|
+
* mapped onto the toolkit `ComponentSize` scale. Default `'sm'` matches the
|
|
14
|
+
* 24px `CurrencyTag` component set.
|
|
15
|
+
*/
|
|
16
|
+
type CurrencyTagSize = ComponentSize;
|
|
17
|
+
interface CurrencyTagProps extends ThemeOverrideProps {
|
|
18
|
+
/** Currency the tag represents. Default: `'xsolla-points'` */
|
|
19
|
+
currency?: CurrencyType;
|
|
20
|
+
/**
|
|
21
|
+
* Size of the tag. Default: `'sm'` (the Figma `CurrencyTag` chip).
|
|
22
|
+
* Figma size matrix: XS / S / M / L / XL → `xs` / `sm` / `md` / `lg` / `xl`.
|
|
23
|
+
*/
|
|
24
|
+
size?: CurrencyTagSize;
|
|
25
|
+
/** The amount shown in the tag, e.g. `250` or `'+250'` */
|
|
26
|
+
value?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Previous amount, rendered struck through and dimmed before `value`.
|
|
29
|
+
* Figma: the `Sublable` boolean property.
|
|
30
|
+
*/
|
|
31
|
+
sublabel?: ReactNode;
|
|
32
|
+
/** Side the currency icon sits on. Default: `'left'` */
|
|
33
|
+
iconPosition?: CurrencyTagIconPosition;
|
|
34
|
+
/**
|
|
35
|
+
* Renders the tag on the themed surface with accent-coloured content instead
|
|
36
|
+
* of a solid accent fill. Figma: `Inverted=Yes`. Default: `false`
|
|
37
|
+
*/
|
|
38
|
+
inverted?: boolean;
|
|
39
|
+
/** Replaces the built-in currency icon. Pass `null` to render no icon. */
|
|
40
|
+
icon?: ReactNode;
|
|
41
|
+
/** Accessible label for the tag. Falls back to the rendered text. */
|
|
42
|
+
"aria-label"?: string;
|
|
43
|
+
/** Test identifier applied to the root element. */
|
|
44
|
+
testID?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare const CurrencyTag: React.FC<CurrencyTagProps>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Per-currency accent palette.
|
|
51
|
+
*
|
|
52
|
+
* Values are taken verbatim from the `CurrencyTag` component set in the B2C
|
|
53
|
+
* Figma library (node `1738:20679`). They are Figma-local variables with no
|
|
54
|
+
* counterpart in the shared XUI theme tokens, so they live here rather than in
|
|
55
|
+
* `@xsolla/xui-core`. `bg` is the solid tag fill of the non-inverted variant and
|
|
56
|
+
* doubles as the content colour of the inverted variant; `border` is the 1px
|
|
57
|
+
* inside stroke of the non-inverted variant.
|
|
58
|
+
*/
|
|
59
|
+
declare const CURRENCY_TAG_PALETTE: Record<CurrencyType, {
|
|
60
|
+
bg: string;
|
|
61
|
+
border: string;
|
|
62
|
+
}>;
|
|
63
|
+
/** Content colour on the solid (non-inverted) tag. Figma: `#000000`. */
|
|
64
|
+
declare const CURRENCY_TAG_SOLID_CONTENT_COLOR = "#000000";
|
|
65
|
+
/**
|
|
66
|
+
* Geometry extras that stay constant across sizes, plus the Figma `sm` snapshot
|
|
67
|
+
* (node `1738:20679`, 24px). Height, padding, radius, icon, and type scale
|
|
68
|
+
* with `theme.sizing.tag(size)` — XS / S / M / L / XL in Figma.
|
|
69
|
+
*/
|
|
70
|
+
declare const CURRENCY_TAG_METRICS: {
|
|
71
|
+
readonly height: 24;
|
|
72
|
+
readonly paddingHorizontal: 4;
|
|
73
|
+
readonly borderRadius: 4;
|
|
74
|
+
readonly borderWidth: 1;
|
|
75
|
+
readonly iconSize: 16;
|
|
76
|
+
readonly textPaddingHorizontal: 2;
|
|
77
|
+
readonly textGap: 3;
|
|
78
|
+
readonly fontSize: 14;
|
|
79
|
+
readonly lineHeight: 16;
|
|
80
|
+
readonly fontWeight: 500;
|
|
81
|
+
/** Opacity applied to the struck-through sublabel. */
|
|
82
|
+
readonly sublabelOpacity: 0.48;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { CURRENCY_TAG_METRICS, CURRENCY_TAG_PALETTE, CURRENCY_TAG_SOLID_CONTENT_COLOR, CurrencyTag, type CurrencyTagIconPosition, type CurrencyTagProps, type CurrencyTagSize, type CurrencyType };
|
package/native/index.js
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
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
|
+
CURRENCY_TAG_METRICS: () => CURRENCY_TAG_METRICS,
|
|
24
|
+
CURRENCY_TAG_PALETTE: () => CURRENCY_TAG_PALETTE,
|
|
25
|
+
CURRENCY_TAG_SOLID_CONTENT_COLOR: () => CURRENCY_TAG_SOLID_CONTENT_COLOR,
|
|
26
|
+
CurrencyTag: () => CurrencyTag
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// ../../foundation/primitives-native/src/Box.tsx
|
|
31
|
+
var import_react_native = require("react-native");
|
|
32
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
var roleToAccessibilityRole = {
|
|
34
|
+
button: "button",
|
|
35
|
+
link: "link",
|
|
36
|
+
img: "image",
|
|
37
|
+
image: "image",
|
|
38
|
+
summary: "summary",
|
|
39
|
+
switch: "switch",
|
|
40
|
+
checkbox: "checkbox",
|
|
41
|
+
radio: "radio",
|
|
42
|
+
heading: "header",
|
|
43
|
+
text: "text",
|
|
44
|
+
search: "search",
|
|
45
|
+
alert: "alert",
|
|
46
|
+
none: "none",
|
|
47
|
+
presentation: "none",
|
|
48
|
+
progressbar: "progressbar",
|
|
49
|
+
scrollbar: "scrollbar",
|
|
50
|
+
adjustable: "adjustable",
|
|
51
|
+
tab: "tab",
|
|
52
|
+
menu: "menu",
|
|
53
|
+
menuitem: "menuitem",
|
|
54
|
+
list: "list",
|
|
55
|
+
timer: "timer"
|
|
56
|
+
};
|
|
57
|
+
var toGapValue = (gap) => {
|
|
58
|
+
if (gap === void 0) return void 0;
|
|
59
|
+
if (typeof gap === "number") return gap;
|
|
60
|
+
const pxMatch = /^(\d+(?:\.\d+)?)px$/.exec(gap);
|
|
61
|
+
if (pxMatch) return Number(pxMatch[1]);
|
|
62
|
+
const asNumber = Number(gap);
|
|
63
|
+
return Number.isFinite(asNumber) ? asNumber : void 0;
|
|
64
|
+
};
|
|
65
|
+
var Box = ({
|
|
66
|
+
children,
|
|
67
|
+
onPress,
|
|
68
|
+
onLayout,
|
|
69
|
+
onMoveShouldSetResponder,
|
|
70
|
+
onResponderGrant,
|
|
71
|
+
onResponderMove,
|
|
72
|
+
onResponderRelease,
|
|
73
|
+
onResponderTerminate,
|
|
74
|
+
backgroundColor,
|
|
75
|
+
borderColor,
|
|
76
|
+
borderWidth,
|
|
77
|
+
borderBottomWidth,
|
|
78
|
+
borderBottomColor,
|
|
79
|
+
borderTopWidth,
|
|
80
|
+
borderTopColor,
|
|
81
|
+
borderLeftWidth,
|
|
82
|
+
borderLeftColor,
|
|
83
|
+
borderRightWidth,
|
|
84
|
+
borderRightColor,
|
|
85
|
+
borderRadius,
|
|
86
|
+
borderStyle,
|
|
87
|
+
height,
|
|
88
|
+
padding,
|
|
89
|
+
paddingHorizontal,
|
|
90
|
+
paddingVertical,
|
|
91
|
+
margin,
|
|
92
|
+
marginTop,
|
|
93
|
+
marginBottom,
|
|
94
|
+
marginLeft,
|
|
95
|
+
marginRight,
|
|
96
|
+
flexDirection,
|
|
97
|
+
flexWrap,
|
|
98
|
+
alignItems,
|
|
99
|
+
justifyContent,
|
|
100
|
+
alignSelf,
|
|
101
|
+
position,
|
|
102
|
+
top,
|
|
103
|
+
bottom,
|
|
104
|
+
left,
|
|
105
|
+
right,
|
|
106
|
+
width,
|
|
107
|
+
minWidth,
|
|
108
|
+
minHeight,
|
|
109
|
+
maxWidth,
|
|
110
|
+
maxHeight,
|
|
111
|
+
flex,
|
|
112
|
+
flexShrink,
|
|
113
|
+
gap,
|
|
114
|
+
overflow,
|
|
115
|
+
opacity,
|
|
116
|
+
zIndex,
|
|
117
|
+
hoverStyle,
|
|
118
|
+
pressStyle,
|
|
119
|
+
style,
|
|
120
|
+
disabled,
|
|
121
|
+
"data-testid": dataTestId,
|
|
122
|
+
testID,
|
|
123
|
+
as,
|
|
124
|
+
src,
|
|
125
|
+
alt,
|
|
126
|
+
...rest
|
|
127
|
+
}) => {
|
|
128
|
+
const getContainerStyle = (pressed) => ({
|
|
129
|
+
backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
|
|
130
|
+
borderColor,
|
|
131
|
+
borderWidth,
|
|
132
|
+
borderBottomWidth,
|
|
133
|
+
borderBottomColor,
|
|
134
|
+
borderTopWidth,
|
|
135
|
+
borderTopColor,
|
|
136
|
+
borderLeftWidth,
|
|
137
|
+
borderLeftColor,
|
|
138
|
+
borderRightWidth,
|
|
139
|
+
borderRightColor,
|
|
140
|
+
borderRadius,
|
|
141
|
+
borderStyle,
|
|
142
|
+
overflow,
|
|
143
|
+
opacity: opacity ?? (disabled ? 0.5 : void 0),
|
|
144
|
+
zIndex,
|
|
145
|
+
height,
|
|
146
|
+
width,
|
|
147
|
+
minWidth,
|
|
148
|
+
minHeight,
|
|
149
|
+
maxWidth,
|
|
150
|
+
maxHeight,
|
|
151
|
+
padding,
|
|
152
|
+
paddingHorizontal,
|
|
153
|
+
paddingVertical,
|
|
154
|
+
margin,
|
|
155
|
+
marginTop,
|
|
156
|
+
marginBottom,
|
|
157
|
+
marginLeft,
|
|
158
|
+
marginRight,
|
|
159
|
+
flexDirection,
|
|
160
|
+
flexWrap,
|
|
161
|
+
alignItems,
|
|
162
|
+
justifyContent,
|
|
163
|
+
alignSelf,
|
|
164
|
+
position,
|
|
165
|
+
top,
|
|
166
|
+
bottom,
|
|
167
|
+
left,
|
|
168
|
+
right,
|
|
169
|
+
flex,
|
|
170
|
+
flexShrink,
|
|
171
|
+
gap: toGapValue(gap),
|
|
172
|
+
...style
|
|
173
|
+
});
|
|
174
|
+
const finalTestID = dataTestId || testID;
|
|
175
|
+
const {
|
|
176
|
+
role,
|
|
177
|
+
tabIndex,
|
|
178
|
+
onKeyDown,
|
|
179
|
+
onKeyUp,
|
|
180
|
+
"aria-label": ariaLabel,
|
|
181
|
+
"aria-labelledby": _ariaLabelledBy,
|
|
182
|
+
"aria-current": _ariaCurrent,
|
|
183
|
+
"aria-disabled": ariaDisabled,
|
|
184
|
+
"aria-live": ariaLive,
|
|
185
|
+
"aria-busy": ariaBusy,
|
|
186
|
+
className,
|
|
187
|
+
"data-testid": _dataTestId,
|
|
188
|
+
cursor: _cursor,
|
|
189
|
+
type: _type,
|
|
190
|
+
...nativeRest
|
|
191
|
+
} = rest;
|
|
192
|
+
const accessibilityRole = typeof role === "string" && roleToAccessibilityRole[role] || (as === "button" ? "button" : void 0);
|
|
193
|
+
const isDisabled = Boolean(disabled || ariaDisabled);
|
|
194
|
+
const accessibilityState = {
|
|
195
|
+
disabled: isDisabled || void 0,
|
|
196
|
+
busy: Boolean(ariaBusy) || void 0
|
|
197
|
+
};
|
|
198
|
+
const accessibilityLiveRegion = ariaLive === "polite" || ariaLive === "assertive" ? ariaLive : void 0;
|
|
199
|
+
if (as === "img" && src) {
|
|
200
|
+
const imageStyle = {
|
|
201
|
+
width,
|
|
202
|
+
height,
|
|
203
|
+
borderRadius,
|
|
204
|
+
position,
|
|
205
|
+
top,
|
|
206
|
+
bottom,
|
|
207
|
+
left,
|
|
208
|
+
right,
|
|
209
|
+
...style
|
|
210
|
+
};
|
|
211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
212
|
+
import_react_native.Image,
|
|
213
|
+
{
|
|
214
|
+
source: { uri: src },
|
|
215
|
+
style: imageStyle,
|
|
216
|
+
testID: finalTestID,
|
|
217
|
+
accessibilityLabel: typeof ariaLabel === "string" ? ariaLabel : alt,
|
|
218
|
+
resizeMode: "cover",
|
|
219
|
+
...nativeRest
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
if (onPress || as === "button") {
|
|
224
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
225
|
+
import_react_native.Pressable,
|
|
226
|
+
{
|
|
227
|
+
onPress: !isDisabled && onPress ? onPress : void 0,
|
|
228
|
+
disabled: isDisabled,
|
|
229
|
+
onLayout,
|
|
230
|
+
onMoveShouldSetResponder,
|
|
231
|
+
onResponderGrant,
|
|
232
|
+
onResponderMove,
|
|
233
|
+
onResponderRelease,
|
|
234
|
+
onResponderTerminate,
|
|
235
|
+
style: ({ pressed }) => getContainerStyle(pressed),
|
|
236
|
+
testID: finalTestID,
|
|
237
|
+
accessibilityRole,
|
|
238
|
+
accessibilityLabel: typeof ariaLabel === "string" ? ariaLabel : void 0,
|
|
239
|
+
accessibilityState,
|
|
240
|
+
accessibilityLiveRegion,
|
|
241
|
+
...nativeRest,
|
|
242
|
+
children
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
247
|
+
import_react_native.View,
|
|
248
|
+
{
|
|
249
|
+
style: getContainerStyle(),
|
|
250
|
+
testID: finalTestID,
|
|
251
|
+
onLayout,
|
|
252
|
+
onMoveShouldSetResponder,
|
|
253
|
+
onResponderGrant,
|
|
254
|
+
onResponderMove,
|
|
255
|
+
onResponderRelease,
|
|
256
|
+
onResponderTerminate,
|
|
257
|
+
accessibilityRole,
|
|
258
|
+
accessibilityLabel: typeof ariaLabel === "string" ? ariaLabel : void 0,
|
|
259
|
+
accessibilityState,
|
|
260
|
+
accessibilityLiveRegion,
|
|
261
|
+
...nativeRest,
|
|
262
|
+
children
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// ../../foundation/primitives-native/src/Text.tsx
|
|
268
|
+
var import_react_native2 = require("react-native");
|
|
269
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
270
|
+
var roleMap = {
|
|
271
|
+
alert: "alert",
|
|
272
|
+
heading: "header",
|
|
273
|
+
button: "button",
|
|
274
|
+
link: "link",
|
|
275
|
+
text: "text"
|
|
276
|
+
};
|
|
277
|
+
var parseNumericValue = (value) => {
|
|
278
|
+
if (value === void 0) return void 0;
|
|
279
|
+
if (typeof value === "number") return value;
|
|
280
|
+
const parsed = parseFloat(value);
|
|
281
|
+
return isNaN(parsed) ? void 0 : parsed;
|
|
282
|
+
};
|
|
283
|
+
var Text = ({
|
|
284
|
+
children,
|
|
285
|
+
color,
|
|
286
|
+
fontSize,
|
|
287
|
+
fontWeight,
|
|
288
|
+
fontFamily,
|
|
289
|
+
textAlign,
|
|
290
|
+
lineHeight,
|
|
291
|
+
numberOfLines,
|
|
292
|
+
id,
|
|
293
|
+
role,
|
|
294
|
+
testID,
|
|
295
|
+
"data-testid": dataTestId,
|
|
296
|
+
style: styleProp,
|
|
297
|
+
...props
|
|
298
|
+
}) => {
|
|
299
|
+
let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
|
|
300
|
+
if (resolvedFontFamily === "Pilat Wide" || resolvedFontFamily === "Pilat Wide Bold" || resolvedFontFamily === "Aktiv Grotesk") {
|
|
301
|
+
resolvedFontFamily = void 0;
|
|
302
|
+
}
|
|
303
|
+
const incomingStyle = import_react_native2.StyleSheet.flatten(styleProp);
|
|
304
|
+
const baseStyle = {
|
|
305
|
+
color: color ?? incomingStyle?.color,
|
|
306
|
+
fontSize: typeof fontSize === "number" ? fontSize : void 0,
|
|
307
|
+
fontWeight,
|
|
308
|
+
fontFamily: resolvedFontFamily,
|
|
309
|
+
textDecorationLine: props.textDecoration,
|
|
310
|
+
textAlign: textAlign ?? incomingStyle?.textAlign,
|
|
311
|
+
lineHeight: parseNumericValue(lineHeight ?? incomingStyle?.lineHeight),
|
|
312
|
+
marginTop: parseNumericValue(
|
|
313
|
+
incomingStyle?.marginTop
|
|
314
|
+
),
|
|
315
|
+
marginBottom: parseNumericValue(
|
|
316
|
+
incomingStyle?.marginBottom
|
|
317
|
+
)
|
|
318
|
+
};
|
|
319
|
+
const accessibilityRole = role ? roleMap[role] : void 0;
|
|
320
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
321
|
+
import_react_native2.Text,
|
|
322
|
+
{
|
|
323
|
+
style: baseStyle,
|
|
324
|
+
numberOfLines,
|
|
325
|
+
testID: dataTestId || testID || id,
|
|
326
|
+
accessibilityRole,
|
|
327
|
+
children
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
// src/CurrencyTag.tsx
|
|
333
|
+
var import_xui_core = require("@xsolla/xui-core");
|
|
334
|
+
var import_xui_icons_currency = require("@xsolla/xui-icons-currency");
|
|
335
|
+
|
|
336
|
+
// src/tokens.ts
|
|
337
|
+
var CURRENCY_TAG_PALETTE = {
|
|
338
|
+
"xsolla-points": { bg: "#55dcf6", border: "#31cae8" },
|
|
339
|
+
"xsolla-tickets": { bg: "#ffb2bf", border: "#ff8095" },
|
|
340
|
+
"xsolla-gold": { bg: "#f6db55", border: "#e8ca31" },
|
|
341
|
+
"play-time": { bg: "#9580ff", border: "#7055f6" },
|
|
342
|
+
"green-orb": { bg: "#d9ff66", border: "#c7f53d" }
|
|
343
|
+
};
|
|
344
|
+
var CURRENCY_TAG_SOLID_CONTENT_COLOR = "#000000";
|
|
345
|
+
var CURRENCY_TAG_METRICS = {
|
|
346
|
+
height: 24,
|
|
347
|
+
paddingHorizontal: 4,
|
|
348
|
+
borderRadius: 4,
|
|
349
|
+
borderWidth: 1,
|
|
350
|
+
iconSize: 16,
|
|
351
|
+
textPaddingHorizontal: 2,
|
|
352
|
+
textGap: 3,
|
|
353
|
+
fontSize: 14,
|
|
354
|
+
lineHeight: 16,
|
|
355
|
+
fontWeight: 500,
|
|
356
|
+
/** Opacity applied to the struck-through sublabel. */
|
|
357
|
+
sublabelOpacity: 0.48
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// src/CurrencyTag.tsx
|
|
361
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
362
|
+
var CURRENCY_ICONS = {
|
|
363
|
+
"xsolla-points": import_xui_icons_currency.XsollaPoint,
|
|
364
|
+
"xsolla-tickets": import_xui_icons_currency.XsollaTicket,
|
|
365
|
+
"xsolla-gold": import_xui_icons_currency.XsollaGold,
|
|
366
|
+
"play-time": import_xui_icons_currency.PlayTime,
|
|
367
|
+
"green-orb": import_xui_icons_currency.GreenOrb
|
|
368
|
+
};
|
|
369
|
+
var CURRENCY_LABELS = {
|
|
370
|
+
"xsolla-points": "Xsolla Points",
|
|
371
|
+
"xsolla-tickets": "Xsolla Tickets",
|
|
372
|
+
"xsolla-gold": "Xsolla Gold",
|
|
373
|
+
"play-time": "Play Time",
|
|
374
|
+
"green-orb": "Green Orb"
|
|
375
|
+
};
|
|
376
|
+
var CurrencyTag = ({
|
|
377
|
+
currency = "xsolla-points",
|
|
378
|
+
size = "sm",
|
|
379
|
+
value,
|
|
380
|
+
sublabel,
|
|
381
|
+
iconPosition = "left",
|
|
382
|
+
inverted = false,
|
|
383
|
+
icon,
|
|
384
|
+
"aria-label": ariaLabel,
|
|
385
|
+
testID,
|
|
386
|
+
themeMode,
|
|
387
|
+
themeProductContext = "b2c"
|
|
388
|
+
}) => {
|
|
389
|
+
const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
|
|
390
|
+
const sizeStyles = theme.sizing.tag(size);
|
|
391
|
+
const palette = CURRENCY_TAG_PALETTE[currency];
|
|
392
|
+
const backgroundColor = inverted ? theme.colors.background.primary : palette.bg;
|
|
393
|
+
const borderColor = inverted ? theme.colors.border.secondary : palette.border;
|
|
394
|
+
const contentColor = inverted ? palette.bg : CURRENCY_TAG_SOLID_CONTENT_COLOR;
|
|
395
|
+
const CurrencyIcon = CURRENCY_ICONS[currency];
|
|
396
|
+
const renderedIcon = icon !== void 0 ? icon : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
397
|
+
CurrencyIcon,
|
|
398
|
+
{
|
|
399
|
+
variant: "mono",
|
|
400
|
+
size: sizeStyles.iconSize,
|
|
401
|
+
color: contentColor,
|
|
402
|
+
"aria-hidden": true
|
|
403
|
+
}
|
|
404
|
+
);
|
|
405
|
+
const text = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
406
|
+
Box,
|
|
407
|
+
{
|
|
408
|
+
flexDirection: "row",
|
|
409
|
+
alignItems: "center",
|
|
410
|
+
justifyContent: "center",
|
|
411
|
+
paddingLeft: CURRENCY_TAG_METRICS.textPaddingHorizontal,
|
|
412
|
+
paddingRight: CURRENCY_TAG_METRICS.textPaddingHorizontal,
|
|
413
|
+
gap: CURRENCY_TAG_METRICS.textGap,
|
|
414
|
+
children: [
|
|
415
|
+
sublabel !== void 0 && sublabel !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
416
|
+
Text,
|
|
417
|
+
{
|
|
418
|
+
color: contentColor,
|
|
419
|
+
fontSize: sizeStyles.fontSize,
|
|
420
|
+
lineHeight: sizeStyles.lineHeight,
|
|
421
|
+
fontWeight: CURRENCY_TAG_METRICS.fontWeight,
|
|
422
|
+
textDecoration: "line-through",
|
|
423
|
+
whiteSpace: "nowrap",
|
|
424
|
+
style: { opacity: CURRENCY_TAG_METRICS.sublabelOpacity },
|
|
425
|
+
testID: testID ? `${testID}-sublabel` : "currency-tag-sublabel",
|
|
426
|
+
children: sublabel
|
|
427
|
+
}
|
|
428
|
+
),
|
|
429
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
430
|
+
Text,
|
|
431
|
+
{
|
|
432
|
+
color: contentColor,
|
|
433
|
+
fontSize: sizeStyles.fontSize,
|
|
434
|
+
lineHeight: sizeStyles.lineHeight,
|
|
435
|
+
fontWeight: CURRENCY_TAG_METRICS.fontWeight,
|
|
436
|
+
whiteSpace: "nowrap",
|
|
437
|
+
testID: testID ? `${testID}-value` : "currency-tag-value",
|
|
438
|
+
children: value
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
]
|
|
442
|
+
}
|
|
443
|
+
);
|
|
444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
445
|
+
Box,
|
|
446
|
+
{
|
|
447
|
+
flexDirection: "row",
|
|
448
|
+
alignItems: "center",
|
|
449
|
+
justifyContent: "center",
|
|
450
|
+
height: sizeStyles.height,
|
|
451
|
+
paddingLeft: sizeStyles.padding,
|
|
452
|
+
paddingRight: sizeStyles.padding,
|
|
453
|
+
borderRadius: sizeStyles.radius,
|
|
454
|
+
borderWidth: sizeStyles.borderWidth,
|
|
455
|
+
borderStyle: "solid",
|
|
456
|
+
borderColor,
|
|
457
|
+
backgroundColor,
|
|
458
|
+
"aria-label": ariaLabel || CURRENCY_LABELS[currency],
|
|
459
|
+
testID: testID || "currency-tag",
|
|
460
|
+
children: [
|
|
461
|
+
iconPosition === "left" && renderedIcon,
|
|
462
|
+
text,
|
|
463
|
+
iconPosition === "right" && renderedIcon
|
|
464
|
+
]
|
|
465
|
+
}
|
|
466
|
+
);
|
|
467
|
+
};
|
|
468
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
469
|
+
0 && (module.exports = {
|
|
470
|
+
CURRENCY_TAG_METRICS,
|
|
471
|
+
CURRENCY_TAG_PALETTE,
|
|
472
|
+
CURRENCY_TAG_SOLID_CONTENT_COLOR,
|
|
473
|
+
CurrencyTag
|
|
474
|
+
});
|
|
475
|
+
//# sourceMappingURL=index.js.map
|