@xsolla/xui-link 0.64.0-pr56.1768440195

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.
@@ -0,0 +1,52 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ type LinkSize = "sm" | "md" | "lg";
4
+ interface LinkProps {
5
+ /**
6
+ * Property to specify the size of the link.
7
+ * @default "md"
8
+ */
9
+ size?: LinkSize;
10
+ /**
11
+ * The URL or path for the link.
12
+ */
13
+ href?: string;
14
+ /**
15
+ * Callback fired when the link is clicked.
16
+ */
17
+ onClick?: () => void;
18
+ /**
19
+ * Whether the link is disabled.
20
+ * @default false
21
+ */
22
+ disabled?: boolean;
23
+ /**
24
+ * Whether the link should have an underline.
25
+ * @default false
26
+ */
27
+ underline?: boolean;
28
+ /**
29
+ * The content of the link.
30
+ */
31
+ children?: ReactNode;
32
+ /**
33
+ * Target attribute for the link (e.g., "_blank", "_self").
34
+ */
35
+ target?: string;
36
+ /**
37
+ * Rel attribute for the link (e.g., "noopener noreferrer").
38
+ */
39
+ rel?: string;
40
+ /**
41
+ * Custom color for the link text
42
+ */
43
+ color?: string;
44
+ /**
45
+ * Test ID for testing frameworks
46
+ */
47
+ testID?: string;
48
+ }
49
+
50
+ declare const Link: React.FC<LinkProps>;
51
+
52
+ export { Link, type LinkProps, type LinkSize };
@@ -0,0 +1,52 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ type LinkSize = "sm" | "md" | "lg";
4
+ interface LinkProps {
5
+ /**
6
+ * Property to specify the size of the link.
7
+ * @default "md"
8
+ */
9
+ size?: LinkSize;
10
+ /**
11
+ * The URL or path for the link.
12
+ */
13
+ href?: string;
14
+ /**
15
+ * Callback fired when the link is clicked.
16
+ */
17
+ onClick?: () => void;
18
+ /**
19
+ * Whether the link is disabled.
20
+ * @default false
21
+ */
22
+ disabled?: boolean;
23
+ /**
24
+ * Whether the link should have an underline.
25
+ * @default false
26
+ */
27
+ underline?: boolean;
28
+ /**
29
+ * The content of the link.
30
+ */
31
+ children?: ReactNode;
32
+ /**
33
+ * Target attribute for the link (e.g., "_blank", "_self").
34
+ */
35
+ target?: string;
36
+ /**
37
+ * Rel attribute for the link (e.g., "noopener noreferrer").
38
+ */
39
+ rel?: string;
40
+ /**
41
+ * Custom color for the link text
42
+ */
43
+ color?: string;
44
+ /**
45
+ * Test ID for testing frameworks
46
+ */
47
+ testID?: string;
48
+ }
49
+
50
+ declare const Link: React.FC<LinkProps>;
51
+
52
+ export { Link, type LinkProps, type LinkSize };
@@ -0,0 +1,587 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.tsx
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Link: () => Link
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // ../primitives-native/src/Box.tsx
38
+ var import_react_native = require("react-native");
39
+ var import_jsx_runtime = require("react/jsx-runtime");
40
+ var Box = ({
41
+ children,
42
+ onPress,
43
+ onLayout,
44
+ onMoveShouldSetResponder,
45
+ onResponderGrant,
46
+ onResponderMove,
47
+ onResponderRelease,
48
+ onResponderTerminate,
49
+ backgroundColor,
50
+ borderColor,
51
+ borderWidth,
52
+ borderBottomWidth,
53
+ borderBottomColor,
54
+ borderTopWidth,
55
+ borderTopColor,
56
+ borderLeftWidth,
57
+ borderLeftColor,
58
+ borderRightWidth,
59
+ borderRightColor,
60
+ borderRadius,
61
+ borderStyle,
62
+ height,
63
+ padding,
64
+ paddingHorizontal,
65
+ paddingVertical,
66
+ margin,
67
+ marginTop,
68
+ marginBottom,
69
+ marginLeft,
70
+ marginRight,
71
+ flexDirection,
72
+ alignItems,
73
+ justifyContent,
74
+ position,
75
+ top,
76
+ bottom,
77
+ left,
78
+ right,
79
+ width,
80
+ flex,
81
+ overflow,
82
+ zIndex,
83
+ hoverStyle,
84
+ pressStyle,
85
+ style,
86
+ "data-testid": dataTestId,
87
+ testID,
88
+ as,
89
+ src,
90
+ alt,
91
+ ...rest
92
+ }) => {
93
+ const getContainerStyle = (pressed) => ({
94
+ backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
95
+ borderColor,
96
+ borderWidth,
97
+ borderBottomWidth,
98
+ borderBottomColor,
99
+ borderTopWidth,
100
+ borderTopColor,
101
+ borderLeftWidth,
102
+ borderLeftColor,
103
+ borderRightWidth,
104
+ borderRightColor,
105
+ borderRadius,
106
+ borderStyle,
107
+ overflow,
108
+ zIndex,
109
+ height,
110
+ width,
111
+ padding,
112
+ paddingHorizontal,
113
+ paddingVertical,
114
+ margin,
115
+ marginTop,
116
+ marginBottom,
117
+ marginLeft,
118
+ marginRight,
119
+ flexDirection,
120
+ alignItems,
121
+ justifyContent,
122
+ position,
123
+ top,
124
+ bottom,
125
+ left,
126
+ right,
127
+ flex,
128
+ ...style
129
+ });
130
+ const finalTestID = dataTestId || testID;
131
+ const {
132
+ role,
133
+ tabIndex,
134
+ onKeyDown,
135
+ onKeyUp,
136
+ "aria-label": _ariaLabel,
137
+ "aria-labelledby": _ariaLabelledBy,
138
+ "aria-current": _ariaCurrent,
139
+ "aria-disabled": _ariaDisabled,
140
+ "aria-live": _ariaLive,
141
+ className,
142
+ "data-testid": _dataTestId,
143
+ ...nativeRest
144
+ } = rest;
145
+ if (as === "img" && src) {
146
+ const imageStyle = {
147
+ width,
148
+ height,
149
+ borderRadius,
150
+ position,
151
+ top,
152
+ bottom,
153
+ left,
154
+ right,
155
+ ...style
156
+ };
157
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
158
+ import_react_native.Image,
159
+ {
160
+ source: { uri: src },
161
+ style: imageStyle,
162
+ testID: finalTestID,
163
+ resizeMode: "cover",
164
+ ...nativeRest
165
+ }
166
+ );
167
+ }
168
+ if (onPress) {
169
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
170
+ import_react_native.Pressable,
171
+ {
172
+ onPress,
173
+ onLayout,
174
+ onMoveShouldSetResponder,
175
+ onResponderGrant,
176
+ onResponderMove,
177
+ onResponderRelease,
178
+ onResponderTerminate,
179
+ style: ({ pressed }) => getContainerStyle(pressed),
180
+ testID: finalTestID,
181
+ ...nativeRest,
182
+ children
183
+ }
184
+ );
185
+ }
186
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
187
+ import_react_native.View,
188
+ {
189
+ style: getContainerStyle(),
190
+ testID: finalTestID,
191
+ onLayout,
192
+ onMoveShouldSetResponder,
193
+ onResponderGrant,
194
+ onResponderMove,
195
+ onResponderRelease,
196
+ onResponderTerminate,
197
+ ...nativeRest,
198
+ children
199
+ }
200
+ );
201
+ };
202
+
203
+ // ../primitives-native/src/Text.tsx
204
+ var import_react_native2 = require("react-native");
205
+ var import_jsx_runtime2 = require("react/jsx-runtime");
206
+ var roleMap = {
207
+ alert: "alert",
208
+ heading: "header",
209
+ button: "button",
210
+ link: "link",
211
+ text: "text"
212
+ };
213
+ var Text = ({
214
+ children,
215
+ color,
216
+ fontSize,
217
+ fontWeight,
218
+ fontFamily,
219
+ id,
220
+ role,
221
+ ...props
222
+ }) => {
223
+ let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
224
+ if (resolvedFontFamily === "Pilat Wide Bold") {
225
+ resolvedFontFamily = void 0;
226
+ }
227
+ const style = {
228
+ color,
229
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
230
+ fontWeight,
231
+ fontFamily: resolvedFontFamily,
232
+ textDecorationLine: props.textDecoration
233
+ };
234
+ const accessibilityRole = role ? roleMap[role] : void 0;
235
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style, testID: id, accessibilityRole, children });
236
+ };
237
+
238
+ // ../primitives-native/src/Spinner.tsx
239
+ var import_react_native3 = require("react-native");
240
+ var import_jsx_runtime3 = require("react/jsx-runtime");
241
+ var Spinner = ({
242
+ color,
243
+ size,
244
+ role,
245
+ "aria-label": ariaLabel,
246
+ "aria-live": ariaLive,
247
+ "aria-describedby": ariaDescribedBy,
248
+ testID
249
+ }) => {
250
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
251
+ import_react_native3.View,
252
+ {
253
+ accessible: true,
254
+ accessibilityRole: role === "status" ? "none" : void 0,
255
+ accessibilityLabel: ariaLabel,
256
+ accessibilityLiveRegion: ariaLive === "polite" ? "polite" : ariaLive === "assertive" ? "assertive" : "none",
257
+ testID,
258
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
259
+ import_react_native3.ActivityIndicator,
260
+ {
261
+ color,
262
+ size: typeof size === "number" ? size : "small"
263
+ }
264
+ )
265
+ }
266
+ );
267
+ };
268
+ Spinner.displayName = "Spinner";
269
+
270
+ // ../primitives-native/src/Icon.tsx
271
+ var import_react = __toESM(require("react"));
272
+ var import_react_native4 = require("react-native");
273
+ var import_jsx_runtime4 = require("react/jsx-runtime");
274
+
275
+ // ../primitives-native/src/Divider.tsx
276
+ var import_react_native5 = require("react-native");
277
+ var import_jsx_runtime5 = require("react/jsx-runtime");
278
+
279
+ // ../primitives-native/src/Input.tsx
280
+ var import_react2 = require("react");
281
+ var import_react_native6 = require("react-native");
282
+ var import_jsx_runtime6 = require("react/jsx-runtime");
283
+ var keyboardTypeMap = {
284
+ text: "default",
285
+ number: "numeric",
286
+ email: "email-address",
287
+ tel: "phone-pad",
288
+ url: "url",
289
+ decimal: "decimal-pad"
290
+ };
291
+ var inputModeToKeyboardType = {
292
+ none: "default",
293
+ text: "default",
294
+ decimal: "decimal-pad",
295
+ numeric: "number-pad",
296
+ tel: "phone-pad",
297
+ search: "default",
298
+ email: "email-address",
299
+ url: "url"
300
+ };
301
+ var autoCompleteToTextContentType = {
302
+ "one-time-code": "oneTimeCode",
303
+ email: "emailAddress",
304
+ username: "username",
305
+ password: "password",
306
+ "new-password": "newPassword",
307
+ tel: "telephoneNumber",
308
+ "postal-code": "postalCode",
309
+ name: "name"
310
+ };
311
+ var InputPrimitive = (0, import_react2.forwardRef)(
312
+ ({
313
+ value,
314
+ placeholder,
315
+ onChange,
316
+ onChangeText,
317
+ onFocus,
318
+ onBlur,
319
+ onKeyDown,
320
+ disabled,
321
+ secureTextEntry,
322
+ style,
323
+ color,
324
+ fontSize,
325
+ placeholderTextColor,
326
+ maxLength,
327
+ name,
328
+ type,
329
+ inputMode,
330
+ autoComplete,
331
+ id,
332
+ "aria-invalid": ariaInvalid,
333
+ "aria-describedby": ariaDescribedBy,
334
+ "aria-labelledby": ariaLabelledBy,
335
+ "aria-label": ariaLabel,
336
+ "aria-disabled": ariaDisabled,
337
+ "data-testid": dataTestId
338
+ }, ref) => {
339
+ const handleChangeText = (text) => {
340
+ onChangeText?.(text);
341
+ if (onChange) {
342
+ const syntheticEvent = {
343
+ target: { value: text },
344
+ currentTarget: { value: text },
345
+ type: "change",
346
+ nativeEvent: { text },
347
+ preventDefault: () => {
348
+ },
349
+ stopPropagation: () => {
350
+ },
351
+ isTrusted: false
352
+ };
353
+ onChange(syntheticEvent);
354
+ }
355
+ };
356
+ const keyboardType = inputMode ? inputModeToKeyboardType[inputMode] || "default" : type ? keyboardTypeMap[type] || "default" : "default";
357
+ const textContentType = autoComplete ? autoCompleteToTextContentType[autoComplete] : void 0;
358
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
359
+ import_react_native6.TextInput,
360
+ {
361
+ ref,
362
+ value,
363
+ placeholder,
364
+ onChangeText: handleChangeText,
365
+ onFocus,
366
+ onBlur,
367
+ onKeyPress: (e) => {
368
+ if (onKeyDown) {
369
+ onKeyDown({
370
+ key: e.nativeEvent.key,
371
+ preventDefault: () => {
372
+ }
373
+ });
374
+ }
375
+ },
376
+ editable: !disabled,
377
+ secureTextEntry: secureTextEntry || type === "password",
378
+ keyboardType,
379
+ textContentType,
380
+ style: [
381
+ {
382
+ color,
383
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
384
+ flex: 1,
385
+ padding: 0,
386
+ textAlign: style?.textAlign || "left"
387
+ },
388
+ style
389
+ ],
390
+ placeholderTextColor,
391
+ maxLength,
392
+ testID: dataTestId || id,
393
+ accessibilityLabel: ariaLabel,
394
+ accessibilityHint: ariaDescribedBy,
395
+ accessibilityState: {
396
+ disabled: disabled || ariaDisabled
397
+ },
398
+ accessible: true
399
+ }
400
+ );
401
+ }
402
+ );
403
+ InputPrimitive.displayName = "InputPrimitive";
404
+
405
+ // ../primitives-native/src/TextArea.tsx
406
+ var import_react3 = require("react");
407
+ var import_react_native7 = require("react-native");
408
+ var import_jsx_runtime7 = require("react/jsx-runtime");
409
+ var TextAreaPrimitive = (0, import_react3.forwardRef)(
410
+ ({
411
+ value,
412
+ placeholder,
413
+ onChange,
414
+ onChangeText,
415
+ onFocus,
416
+ onBlur,
417
+ onKeyDown,
418
+ disabled,
419
+ style,
420
+ color,
421
+ fontSize,
422
+ placeholderTextColor,
423
+ maxLength,
424
+ rows,
425
+ id,
426
+ "aria-invalid": ariaInvalid,
427
+ "aria-describedby": ariaDescribedBy,
428
+ "aria-labelledby": ariaLabelledBy,
429
+ "aria-label": ariaLabel,
430
+ "aria-disabled": ariaDisabled,
431
+ "data-testid": dataTestId
432
+ }, ref) => {
433
+ const handleChangeText = (text) => {
434
+ onChangeText?.(text);
435
+ if (onChange) {
436
+ const syntheticEvent = {
437
+ target: { value: text },
438
+ currentTarget: { value: text },
439
+ type: "change",
440
+ nativeEvent: { text },
441
+ preventDefault: () => {
442
+ },
443
+ stopPropagation: () => {
444
+ },
445
+ isTrusted: false
446
+ };
447
+ onChange(syntheticEvent);
448
+ }
449
+ };
450
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
451
+ import_react_native7.TextInput,
452
+ {
453
+ ref,
454
+ value,
455
+ placeholder,
456
+ onChangeText: handleChangeText,
457
+ onFocus,
458
+ onBlur,
459
+ onKeyPress: (e) => {
460
+ if (onKeyDown) {
461
+ onKeyDown({
462
+ key: e.nativeEvent.key,
463
+ preventDefault: () => {
464
+ }
465
+ });
466
+ }
467
+ },
468
+ editable: !disabled,
469
+ multiline: true,
470
+ numberOfLines: rows || 4,
471
+ style: [
472
+ {
473
+ color,
474
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
475
+ flex: 1,
476
+ padding: 0,
477
+ textAlignVertical: "top",
478
+ textAlign: style?.textAlign || "left"
479
+ },
480
+ style
481
+ ],
482
+ placeholderTextColor,
483
+ maxLength,
484
+ testID: dataTestId || id,
485
+ accessibilityLabel: ariaLabel,
486
+ accessibilityHint: ariaDescribedBy,
487
+ accessibilityState: {
488
+ disabled: disabled || ariaDisabled
489
+ },
490
+ accessible: true
491
+ }
492
+ );
493
+ }
494
+ );
495
+ TextAreaPrimitive.displayName = "TextAreaPrimitive";
496
+
497
+ // src/Link.tsx
498
+ var import_xui_core = require("@xsolla/xui-core");
499
+ var import_jsx_runtime8 = require("react/jsx-runtime");
500
+ var Link = ({
501
+ size = "md",
502
+ href,
503
+ onClick,
504
+ disabled = false,
505
+ underline = false,
506
+ children,
507
+ target,
508
+ rel,
509
+ color,
510
+ testID
511
+ }) => {
512
+ const { theme } = (0, import_xui_core.useDesignSystem)();
513
+ const fontSizeMap = {
514
+ sm: 12,
515
+ md: 14,
516
+ lg: 16
517
+ };
518
+ const handleClick = (e) => {
519
+ if (disabled) {
520
+ e.preventDefault?.();
521
+ return;
522
+ }
523
+ if (onClick) {
524
+ e.preventDefault?.();
525
+ onClick();
526
+ }
527
+ };
528
+ const getRel = () => {
529
+ if (target === "_blank") {
530
+ const securityRel = "noopener noreferrer";
531
+ if (rel) {
532
+ const relParts = rel.split(/\s+/);
533
+ const securityParts = securityRel.split(/\s+/);
534
+ const allParts = [...relParts, ...securityParts];
535
+ const uniqueParts = Array.from(new Set(allParts));
536
+ return uniqueParts.join(" ");
537
+ }
538
+ return securityRel;
539
+ }
540
+ return rel;
541
+ };
542
+ const defaultColor = theme.colors.control.link.primary;
543
+ const disabledColor = theme.colors.control.text.disable;
544
+ const textColor = disabled ? disabledColor : color || defaultColor;
545
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
546
+ Box,
547
+ {
548
+ as: "a",
549
+ href: disabled ? void 0 : href,
550
+ onPress: handleClick,
551
+ onClick: handleClick,
552
+ target,
553
+ rel: getRel(),
554
+ cursor: disabled ? "not-allowed" : "pointer",
555
+ flexDirection: "row",
556
+ alignItems: "center",
557
+ display: "inline-flex",
558
+ gap: 8,
559
+ testID,
560
+ role: "link",
561
+ tabIndex: disabled ? -1 : 0,
562
+ hoverStyle: !disabled ? { opacity: 0.8 } : void 0,
563
+ focusStyle: {
564
+ outlineColor: theme.colors.border.brand,
565
+ outlineWidth: 2,
566
+ outlineStyle: "solid",
567
+ outlineOffset: 2
568
+ },
569
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
570
+ Text,
571
+ {
572
+ color: textColor,
573
+ fontSize: fontSizeMap[size],
574
+ fontWeight: "400",
575
+ textDecoration: underline ? "underline" : "none",
576
+ children
577
+ }
578
+ )
579
+ }
580
+ );
581
+ };
582
+ Link.displayName = "Link";
583
+ // Annotate the CommonJS export names for ESM import in node:
584
+ 0 && (module.exports = {
585
+ Link
586
+ });
587
+ //# sourceMappingURL=index.js.map