@xsolla/xui-toggletip-native 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.js ADDED
@@ -0,0 +1,682 @@
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
+ Toggletip: () => Toggletip
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/Toggletip.tsx
38
+ var import_react4 = require("react");
39
+
40
+ // ../primitives-native/src/Box.tsx
41
+ var import_react_native = require("react-native");
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ var Box = ({
44
+ children,
45
+ onPress,
46
+ onLayout,
47
+ onMoveShouldSetResponder,
48
+ onResponderGrant,
49
+ onResponderMove,
50
+ onResponderRelease,
51
+ onResponderTerminate,
52
+ backgroundColor,
53
+ borderColor,
54
+ borderWidth,
55
+ borderBottomWidth,
56
+ borderBottomColor,
57
+ borderTopWidth,
58
+ borderTopColor,
59
+ borderLeftWidth,
60
+ borderLeftColor,
61
+ borderRightWidth,
62
+ borderRightColor,
63
+ borderRadius,
64
+ borderStyle,
65
+ height,
66
+ padding,
67
+ paddingHorizontal,
68
+ paddingVertical,
69
+ margin,
70
+ marginTop,
71
+ marginBottom,
72
+ marginLeft,
73
+ marginRight,
74
+ flexDirection,
75
+ alignItems,
76
+ justifyContent,
77
+ position,
78
+ top,
79
+ bottom,
80
+ left,
81
+ right,
82
+ width,
83
+ flex,
84
+ overflow,
85
+ zIndex,
86
+ hoverStyle,
87
+ pressStyle,
88
+ style,
89
+ "data-testid": dataTestId,
90
+ testID,
91
+ as,
92
+ src,
93
+ alt,
94
+ ...rest
95
+ }) => {
96
+ const getContainerStyle = (pressed) => ({
97
+ backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
98
+ borderColor,
99
+ borderWidth,
100
+ borderBottomWidth,
101
+ borderBottomColor,
102
+ borderTopWidth,
103
+ borderTopColor,
104
+ borderLeftWidth,
105
+ borderLeftColor,
106
+ borderRightWidth,
107
+ borderRightColor,
108
+ borderRadius,
109
+ borderStyle,
110
+ overflow,
111
+ zIndex,
112
+ height,
113
+ width,
114
+ padding,
115
+ paddingHorizontal,
116
+ paddingVertical,
117
+ margin,
118
+ marginTop,
119
+ marginBottom,
120
+ marginLeft,
121
+ marginRight,
122
+ flexDirection,
123
+ alignItems,
124
+ justifyContent,
125
+ position,
126
+ top,
127
+ bottom,
128
+ left,
129
+ right,
130
+ flex,
131
+ ...style
132
+ });
133
+ const finalTestID = dataTestId || testID;
134
+ const {
135
+ role,
136
+ tabIndex,
137
+ onKeyDown,
138
+ onKeyUp,
139
+ "aria-label": _ariaLabel,
140
+ "aria-labelledby": _ariaLabelledBy,
141
+ "aria-current": _ariaCurrent,
142
+ "aria-disabled": _ariaDisabled,
143
+ "aria-live": _ariaLive,
144
+ className,
145
+ "data-testid": _dataTestId,
146
+ ...nativeRest
147
+ } = rest;
148
+ if (as === "img" && src) {
149
+ const imageStyle = {
150
+ width,
151
+ height,
152
+ borderRadius,
153
+ position,
154
+ top,
155
+ bottom,
156
+ left,
157
+ right,
158
+ ...style
159
+ };
160
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
161
+ import_react_native.Image,
162
+ {
163
+ source: { uri: src },
164
+ style: imageStyle,
165
+ testID: finalTestID,
166
+ resizeMode: "cover",
167
+ ...nativeRest
168
+ }
169
+ );
170
+ }
171
+ if (onPress) {
172
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
+ import_react_native.Pressable,
174
+ {
175
+ onPress,
176
+ onLayout,
177
+ onMoveShouldSetResponder,
178
+ onResponderGrant,
179
+ onResponderMove,
180
+ onResponderRelease,
181
+ onResponderTerminate,
182
+ style: ({ pressed }) => getContainerStyle(pressed),
183
+ testID: finalTestID,
184
+ ...nativeRest,
185
+ children
186
+ }
187
+ );
188
+ }
189
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
190
+ import_react_native.View,
191
+ {
192
+ style: getContainerStyle(),
193
+ testID: finalTestID,
194
+ onLayout,
195
+ onMoveShouldSetResponder,
196
+ onResponderGrant,
197
+ onResponderMove,
198
+ onResponderRelease,
199
+ onResponderTerminate,
200
+ ...nativeRest,
201
+ children
202
+ }
203
+ );
204
+ };
205
+
206
+ // ../primitives-native/src/Text.tsx
207
+ var import_react_native2 = require("react-native");
208
+ var import_jsx_runtime2 = require("react/jsx-runtime");
209
+ var roleMap = {
210
+ alert: "alert",
211
+ heading: "header",
212
+ button: "button",
213
+ link: "link",
214
+ text: "text"
215
+ };
216
+ var Text = ({
217
+ children,
218
+ color,
219
+ fontSize,
220
+ fontWeight,
221
+ fontFamily,
222
+ id,
223
+ role,
224
+ ...props
225
+ }) => {
226
+ let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
227
+ if (resolvedFontFamily === "Pilat Wide Bold") {
228
+ resolvedFontFamily = void 0;
229
+ }
230
+ const style = {
231
+ color,
232
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
233
+ fontWeight,
234
+ fontFamily: resolvedFontFamily,
235
+ textDecorationLine: props.textDecoration
236
+ };
237
+ const accessibilityRole = role ? roleMap[role] : void 0;
238
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style, testID: id, accessibilityRole, children });
239
+ };
240
+
241
+ // ../primitives-native/src/Spinner.tsx
242
+ var import_react_native3 = require("react-native");
243
+ var import_jsx_runtime3 = require("react/jsx-runtime");
244
+ var Spinner = ({
245
+ color,
246
+ size,
247
+ role,
248
+ "aria-label": ariaLabel,
249
+ "aria-live": ariaLive,
250
+ "aria-describedby": ariaDescribedBy,
251
+ testID
252
+ }) => {
253
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
254
+ import_react_native3.View,
255
+ {
256
+ accessible: true,
257
+ accessibilityRole: role === "status" ? "none" : void 0,
258
+ accessibilityLabel: ariaLabel,
259
+ accessibilityLiveRegion: ariaLive === "polite" ? "polite" : ariaLive === "assertive" ? "assertive" : "none",
260
+ testID,
261
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
262
+ import_react_native3.ActivityIndicator,
263
+ {
264
+ color,
265
+ size: typeof size === "number" ? size : "small"
266
+ }
267
+ )
268
+ }
269
+ );
270
+ };
271
+ Spinner.displayName = "Spinner";
272
+
273
+ // ../primitives-native/src/Icon.tsx
274
+ var import_react = __toESM(require("react"));
275
+ var import_react_native4 = require("react-native");
276
+ var import_jsx_runtime4 = require("react/jsx-runtime");
277
+
278
+ // ../primitives-native/src/Divider.tsx
279
+ var import_react_native5 = require("react-native");
280
+ var import_jsx_runtime5 = require("react/jsx-runtime");
281
+ var Divider = ({
282
+ color,
283
+ height,
284
+ width,
285
+ vertical,
286
+ dashStroke
287
+ }) => {
288
+ const style = {
289
+ backgroundColor: dashStroke ? "transparent" : color || "rgba(255, 255, 255, 0.15)",
290
+ width: vertical ? typeof width === "number" ? width : 1 : "100%",
291
+ height: vertical ? "100%" : typeof height === "number" ? height : 1,
292
+ ...dashStroke && {
293
+ borderStyle: "dashed",
294
+ borderColor: color || "rgba(255, 255, 255, 0.15)",
295
+ borderWidth: 0,
296
+ ...vertical ? { borderLeftWidth: typeof width === "number" ? width : 1 } : { borderTopWidth: typeof height === "number" ? height : 1 }
297
+ }
298
+ };
299
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.View, { style });
300
+ };
301
+
302
+ // ../primitives-native/src/Input.tsx
303
+ var import_react2 = require("react");
304
+ var import_react_native6 = require("react-native");
305
+ var import_jsx_runtime6 = require("react/jsx-runtime");
306
+ var keyboardTypeMap = {
307
+ text: "default",
308
+ number: "numeric",
309
+ email: "email-address",
310
+ tel: "phone-pad",
311
+ url: "url",
312
+ decimal: "decimal-pad"
313
+ };
314
+ var inputModeToKeyboardType = {
315
+ none: "default",
316
+ text: "default",
317
+ decimal: "decimal-pad",
318
+ numeric: "number-pad",
319
+ tel: "phone-pad",
320
+ search: "default",
321
+ email: "email-address",
322
+ url: "url"
323
+ };
324
+ var autoCompleteToTextContentType = {
325
+ "one-time-code": "oneTimeCode",
326
+ email: "emailAddress",
327
+ username: "username",
328
+ password: "password",
329
+ "new-password": "newPassword",
330
+ tel: "telephoneNumber",
331
+ "postal-code": "postalCode",
332
+ name: "name"
333
+ };
334
+ var InputPrimitive = (0, import_react2.forwardRef)(
335
+ ({
336
+ value,
337
+ placeholder,
338
+ onChange,
339
+ onChangeText,
340
+ onFocus,
341
+ onBlur,
342
+ onKeyDown,
343
+ disabled,
344
+ secureTextEntry,
345
+ style,
346
+ color,
347
+ fontSize,
348
+ placeholderTextColor,
349
+ maxLength,
350
+ name,
351
+ type,
352
+ inputMode,
353
+ autoComplete,
354
+ id,
355
+ "aria-invalid": ariaInvalid,
356
+ "aria-describedby": ariaDescribedBy,
357
+ "aria-labelledby": ariaLabelledBy,
358
+ "aria-label": ariaLabel,
359
+ "aria-disabled": ariaDisabled,
360
+ "data-testid": dataTestId
361
+ }, ref) => {
362
+ const handleChangeText = (text) => {
363
+ onChangeText?.(text);
364
+ if (onChange) {
365
+ const syntheticEvent = {
366
+ target: { value: text },
367
+ currentTarget: { value: text },
368
+ type: "change",
369
+ nativeEvent: { text },
370
+ preventDefault: () => {
371
+ },
372
+ stopPropagation: () => {
373
+ },
374
+ isTrusted: false
375
+ };
376
+ onChange(syntheticEvent);
377
+ }
378
+ };
379
+ const keyboardType = inputMode ? inputModeToKeyboardType[inputMode] || "default" : type ? keyboardTypeMap[type] || "default" : "default";
380
+ const textContentType = autoComplete ? autoCompleteToTextContentType[autoComplete] : void 0;
381
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
382
+ import_react_native6.TextInput,
383
+ {
384
+ ref,
385
+ value,
386
+ placeholder,
387
+ onChangeText: handleChangeText,
388
+ onFocus,
389
+ onBlur,
390
+ onKeyPress: (e) => {
391
+ if (onKeyDown) {
392
+ onKeyDown({
393
+ key: e.nativeEvent.key,
394
+ preventDefault: () => {
395
+ }
396
+ });
397
+ }
398
+ },
399
+ editable: !disabled,
400
+ secureTextEntry: secureTextEntry || type === "password",
401
+ keyboardType,
402
+ textContentType,
403
+ style: [
404
+ {
405
+ color,
406
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
407
+ flex: 1,
408
+ padding: 0,
409
+ textAlign: style?.textAlign || "left"
410
+ },
411
+ style
412
+ ],
413
+ placeholderTextColor,
414
+ maxLength,
415
+ testID: dataTestId || id,
416
+ accessibilityLabel: ariaLabel,
417
+ accessibilityHint: ariaDescribedBy,
418
+ accessibilityState: {
419
+ disabled: disabled || ariaDisabled
420
+ },
421
+ accessible: true
422
+ }
423
+ );
424
+ }
425
+ );
426
+ InputPrimitive.displayName = "InputPrimitive";
427
+
428
+ // ../primitives-native/src/TextArea.tsx
429
+ var import_react3 = require("react");
430
+ var import_react_native7 = require("react-native");
431
+ var import_jsx_runtime7 = require("react/jsx-runtime");
432
+ var TextAreaPrimitive = (0, import_react3.forwardRef)(
433
+ ({
434
+ value,
435
+ placeholder,
436
+ onChange,
437
+ onChangeText,
438
+ onFocus,
439
+ onBlur,
440
+ onKeyDown,
441
+ disabled,
442
+ style,
443
+ color,
444
+ fontSize,
445
+ placeholderTextColor,
446
+ maxLength,
447
+ rows,
448
+ id,
449
+ "aria-invalid": ariaInvalid,
450
+ "aria-describedby": ariaDescribedBy,
451
+ "aria-labelledby": ariaLabelledBy,
452
+ "aria-label": ariaLabel,
453
+ "aria-disabled": ariaDisabled,
454
+ "data-testid": dataTestId
455
+ }, ref) => {
456
+ const handleChangeText = (text) => {
457
+ onChangeText?.(text);
458
+ if (onChange) {
459
+ const syntheticEvent = {
460
+ target: { value: text },
461
+ currentTarget: { value: text },
462
+ type: "change",
463
+ nativeEvent: { text },
464
+ preventDefault: () => {
465
+ },
466
+ stopPropagation: () => {
467
+ },
468
+ isTrusted: false
469
+ };
470
+ onChange(syntheticEvent);
471
+ }
472
+ };
473
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
474
+ import_react_native7.TextInput,
475
+ {
476
+ ref,
477
+ value,
478
+ placeholder,
479
+ onChangeText: handleChangeText,
480
+ onFocus,
481
+ onBlur,
482
+ onKeyPress: (e) => {
483
+ if (onKeyDown) {
484
+ onKeyDown({
485
+ key: e.nativeEvent.key,
486
+ preventDefault: () => {
487
+ }
488
+ });
489
+ }
490
+ },
491
+ editable: !disabled,
492
+ multiline: true,
493
+ numberOfLines: rows || 4,
494
+ style: [
495
+ {
496
+ color,
497
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
498
+ flex: 1,
499
+ padding: 0,
500
+ textAlignVertical: "top",
501
+ textAlign: style?.textAlign || "left"
502
+ },
503
+ style
504
+ ],
505
+ placeholderTextColor,
506
+ maxLength,
507
+ testID: dataTestId || id,
508
+ accessibilityLabel: ariaLabel,
509
+ accessibilityHint: ariaDescribedBy,
510
+ accessibilityState: {
511
+ disabled: disabled || ariaDisabled
512
+ },
513
+ accessible: true
514
+ }
515
+ );
516
+ }
517
+ );
518
+ TextAreaPrimitive.displayName = "TextAreaPrimitive";
519
+
520
+ // src/Toggletip.tsx
521
+ var import_xui_core = require("@xsolla/xui-core");
522
+ var import_jsx_runtime8 = require("react/jsx-runtime");
523
+ var getPositionStyles = (placement, offset) => {
524
+ switch (placement) {
525
+ case "bottom-center":
526
+ case "center":
527
+ return {
528
+ top: `calc(100% + ${offset}px)`,
529
+ left: "50%",
530
+ transform: "translateX(-50%)"
531
+ };
532
+ case "bottom-start":
533
+ return { top: `calc(100% + ${offset}px)`, left: 0 };
534
+ case "bottom-end":
535
+ return { top: `calc(100% + ${offset}px)`, right: 0 };
536
+ case "top-center":
537
+ return {
538
+ bottom: `calc(100% + ${offset}px)`,
539
+ left: "50%",
540
+ transform: "translateX(-50%)"
541
+ };
542
+ case "top-start":
543
+ return { bottom: `calc(100% + ${offset}px)`, left: 0 };
544
+ case "top-end":
545
+ return { bottom: `calc(100% + ${offset}px)`, right: 0 };
546
+ case "left-center":
547
+ return {
548
+ right: `calc(100% + ${offset}px)`,
549
+ top: "50%",
550
+ transform: "translateY(-50%)"
551
+ };
552
+ case "left-start":
553
+ return { right: `calc(100% + ${offset}px)`, top: 0 };
554
+ case "left-end":
555
+ return { right: `calc(100% + ${offset}px)`, bottom: 0 };
556
+ case "right-center":
557
+ return {
558
+ left: `calc(100% + ${offset}px)`,
559
+ top: "50%",
560
+ transform: "translateY(-50%)"
561
+ };
562
+ case "right-start":
563
+ return { left: `calc(100% + ${offset}px)`, top: 0 };
564
+ case "right-end":
565
+ return { left: `calc(100% + ${offset}px)`, bottom: 0 };
566
+ default:
567
+ return {
568
+ bottom: `calc(100% + ${offset}px)`,
569
+ left: "50%",
570
+ transform: "translateX(-50%)"
571
+ };
572
+ }
573
+ };
574
+ var Toggletip = (0, import_react4.forwardRef)(
575
+ ({
576
+ children,
577
+ title,
578
+ content,
579
+ footer,
580
+ width = "288px",
581
+ direction = "top-center",
582
+ autoDirection = true,
583
+ offset = 12,
584
+ style,
585
+ "data-testid": dataTestId,
586
+ className,
587
+ ...props
588
+ }, ref) => {
589
+ const [isOpen, setOpen] = (0, import_react4.useState)(false);
590
+ const containerRef = (0, import_react4.useRef)(null);
591
+ const { theme } = (0, import_xui_core.useDesignSystem)();
592
+ const toggleOpen = () => setOpen(!isOpen);
593
+ (0, import_react4.useEffect)(() => {
594
+ const handleClickOutside = (event) => {
595
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
596
+ setOpen(false);
597
+ }
598
+ };
599
+ if (isOpen) {
600
+ document.addEventListener("mousedown", handleClickOutside);
601
+ }
602
+ return () => document.removeEventListener("mousedown", handleClickOutside);
603
+ }, [isOpen]);
604
+ const positionStyles = (0, import_react4.useMemo)(
605
+ () => getPositionStyles(direction, offset),
606
+ [direction, offset]
607
+ );
608
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
609
+ Box,
610
+ {
611
+ ref: containerRef,
612
+ display: "inline-flex",
613
+ position: "relative",
614
+ className,
615
+ style: { height: "fit-content" },
616
+ children: [
617
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { onPress: toggleOpen, style: { cursor: "pointer" }, children }),
618
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
619
+ Box,
620
+ {
621
+ "data-testid": dataTestId,
622
+ position: "absolute",
623
+ backgroundColor: theme.colors.background.secondary,
624
+ borderRadius: 12,
625
+ borderWidth: 1,
626
+ borderColor: theme.colors.border.secondary,
627
+ padding: 12,
628
+ width,
629
+ zIndex: 2e3,
630
+ style: {
631
+ ...positionStyles,
632
+ boxShadow: "0 4px 12px rgba(0, 36, 77, 0.2)",
633
+ ...style
634
+ },
635
+ children: [
636
+ title && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
637
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
638
+ Text,
639
+ {
640
+ color: theme.colors.content.primary,
641
+ fontSize: 24,
642
+ lineHeight: "28px",
643
+ fontWeight: "500",
644
+ marginBottom: 8,
645
+ children: title
646
+ }
647
+ ),
648
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Divider, { marginBottom: 12 })
649
+ ] }),
650
+ content && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { marginVertical: 16, children: typeof content === "string" || typeof content === "number" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
651
+ Text,
652
+ {
653
+ color: theme.colors.content.primary,
654
+ fontSize: 14,
655
+ fontWeight: "400",
656
+ children: content
657
+ }
658
+ ) : content }),
659
+ footer && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
660
+ Box,
661
+ {
662
+ marginTop: 20,
663
+ flexDirection: "row",
664
+ justifyContent: "flex-end",
665
+ gap: 12,
666
+ children: footer
667
+ }
668
+ )
669
+ ]
670
+ }
671
+ )
672
+ ]
673
+ }
674
+ );
675
+ }
676
+ );
677
+ Toggletip.displayName = "Toggletip";
678
+ // Annotate the CommonJS export names for ESM import in node:
679
+ 0 && (module.exports = {
680
+ Toggletip
681
+ });
682
+ //# sourceMappingURL=index.js.map