@tastic/hud 0.26.0 → 0.28.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 +14 -1
- package/dist/chrome/index.js +22 -4
- package/dist/chrome/index.mjs +2 -2
- package/dist/{chunk-FOJLQMKA.mjs → chunk-5ECU3722.mjs} +22 -4
- package/dist/{chunk-33MWHPPH.mjs → chunk-75Q2VN5R.mjs} +1 -1
- package/dist/{chunk-UO2V5C2U.mjs → chunk-CPNDNJJR.mjs} +33 -10
- package/dist/{index-DW0PsGCE.d.ts → index-B2sz-9jr.d.ts} +10 -3
- package/dist/{index-Bz4j509X.d.mts → index-BOMA2rLU.d.mts} +10 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +54 -13
- package/dist/index.mjs +3 -3
- package/dist/lobby/index.d.mts +2 -2
- package/dist/lobby/index.d.ts +2 -2
- package/dist/lobby/index.js +54 -13
- package/dist/lobby/index.mjs +2 -2
- package/package.json +1 -1
- package/src/PlayerSetupPanel.tsx +37 -12
- package/src/PopoverBody.tsx +45 -16
- package/src/ReadyButton.tsx +42 -3
package/README.md
CHANGED
|
@@ -43,7 +43,10 @@ corner of the screen.
|
|
|
43
43
|
sits in (see `useAutoAlign`).
|
|
44
44
|
- **`TriggerGauge`**: decorative ring of tick marks around a trigger, showing which option(s) are
|
|
45
45
|
active without opening the popover.
|
|
46
|
-
- **`ReadyButton`**: a per-player or standalone ready toggle
|
|
46
|
+
- **`ReadyButton`**: a per-player or standalone ready toggle: an outline and mono label in the seat's
|
|
47
|
+
color until ready, then filled with it. Over a backdrop (a felt) pass `surfaceColor` (the theme's
|
|
48
|
+
surface) and `dark`: it is then a pill the size of `@tastic/profile`'s chip pill, its label black or
|
|
49
|
+
white in the theme's font, filled with the seat's color (its label in that color's own ink) once ready.
|
|
47
50
|
- **`PlayerSetupPanel`**: one panel per player slot in a local-multiplayer loadout/lobby screen: a
|
|
48
51
|
name header (a saved-profile switcher for a human seat, a CPU-difficulty `LabeledDropdown` for a
|
|
49
52
|
non-human one, or a plain label when neither applies), a color picker (`InlineColorPicker`)
|
|
@@ -51,6 +54,16 @@ corner of the screen.
|
|
|
51
54
|
Ported from five apps' own near-identical `PlayerSetupPanel.tsx`/`LobbyPlayerPanel.tsx`
|
|
52
55
|
(AirHockey, BoxHockey, Pong, LightCycles, Snake), which had all independently converged on this
|
|
53
56
|
exact skeleton. See "The secondPicker slot" below before wiring up that one prop.
|
|
57
|
+
Five optional props fit it to a host that draws on a backdrop (a felt) with muted profile colors,
|
|
58
|
+
each changing nothing when left unset: `nullLabel` (the no-profile row's label in the seat button's
|
|
59
|
+
dropdown, e.g. `'Guest'` beside a `'GUEST'` `guestLabel`), `previewValue` (how the seat's color is
|
|
60
|
+
drawn: the button's chip, its Color row and swatches, the fallback swatch, the plain label and the
|
|
61
|
+
Ready button, while `color` and what `onColorChange` receives stay the saved values), `triggerStyle`
|
|
62
|
+
(the seat button's trigger, e.g. a surface behind its pill), `readySurfaceColor` (the Ready button's
|
|
63
|
+
pill look, `ReadyButton`'s `surfaceColor`) and `useSeatPickerAlign` (a placement
|
|
64
|
+
hook of the host's own for the seat button's dropdown, in place of `useZoneClampedAlign`, for a
|
|
65
|
+
screen turned by a fake landscape; leave it unset inside a split-screen zone, and keep the same hook
|
|
66
|
+
for the panel's life).
|
|
54
67
|
- **`CornerActionButtons`**: Back (top-left) + Settings (top-right) icon buttons fixed at a
|
|
55
68
|
screen's rotated corners. This isn't just a loadout/lobby-screen convention - it's the right
|
|
56
69
|
default for *any* screen with top-corner icon buttons, home screens included: every app in the
|
package/dist/chrome/index.js
CHANGED
|
@@ -889,13 +889,13 @@ function PopoverBody({ visible, children, align = "center", verticalAlign = "bel
|
|
|
889
889
|
const caretFill = above ? "borderTopColor" : "borderBottomColor";
|
|
890
890
|
const caretWidthProp = above ? "borderTopWidth" : "borderBottomWidth";
|
|
891
891
|
const caretEdge = (size) => above ? { bottom: -size + CARET_DIP } : { top: -size + CARET_DIP };
|
|
892
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native16.View, { style: [styles13.content, alignStyle, verticalStyle], children: [
|
|
892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native16.View, { style: [styles13.edge, above ? styles13.edgeTop : styles13.edgeBottom], children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native16.View, { style: [styles13.content, alignStyle, verticalStyle], children: [
|
|
893
893
|
children,
|
|
894
894
|
caretColor && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
895
895
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native16.View, { style: [styles13.caret, caretOffset(ringSize), caretEdge(ringSize), { [caretFill]: caretBorderColor ?? caretColor, [caretWidthProp]: ringSize, borderLeftWidth: ringSize, borderRightWidth: ringSize }] }),
|
|
896
896
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native16.View, { style: [styles13.caret, caretOffset(CARET_SIZE), caretEdge(CARET_SIZE - CARET_RING_OFFSET), { [caretFill]: caretColor, [caretWidthProp]: CARET_SIZE, borderLeftWidth: CARET_SIZE, borderRightWidth: CARET_SIZE }] })
|
|
897
897
|
] })
|
|
898
|
-
] });
|
|
898
|
+
] }) });
|
|
899
899
|
}
|
|
900
900
|
var styles13 = import_react_native16.StyleSheet.create({
|
|
901
901
|
caret: {
|
|
@@ -914,13 +914,15 @@ var styles13 = import_react_native16.StyleSheet.create({
|
|
|
914
914
|
position: "absolute",
|
|
915
915
|
zIndex: 50
|
|
916
916
|
},
|
|
917
|
+
// The strip's bottom edge, which is the trigger's top: the box grows up from it.
|
|
917
918
|
contentAbove: {
|
|
918
|
-
bottom:
|
|
919
|
+
bottom: 0,
|
|
919
920
|
marginBottom: 8
|
|
920
921
|
},
|
|
922
|
+
// The strip's top edge, which is the trigger's bottom: the box grows down from it.
|
|
921
923
|
contentBelow: {
|
|
922
924
|
marginTop: 8,
|
|
923
|
-
top:
|
|
925
|
+
top: 0
|
|
924
926
|
},
|
|
925
927
|
// Stretched to the anchor's own (trigger) width, with alignItems centering the actual (usually
|
|
926
928
|
// much wider) popover box inside via plain flexbox - not `left:'50%'` plus a percentage
|
|
@@ -936,6 +938,22 @@ var styles13 = import_react_native16.StyleSheet.create({
|
|
|
936
938
|
},
|
|
937
939
|
contentRight: {
|
|
938
940
|
right: 0
|
|
941
|
+
},
|
|
942
|
+
// The zero-height strip the box hangs off, spanning the trigger's wrapper (see PopoverBody's
|
|
943
|
+
// comment for why it isn't a percentage inset). Its zIndex matches the box's, so on the web, where
|
|
944
|
+
// every positioned view is its own stacking context, the box still paints over later siblings.
|
|
945
|
+
edge: {
|
|
946
|
+
height: 0,
|
|
947
|
+
left: 0,
|
|
948
|
+
position: "absolute",
|
|
949
|
+
right: 0,
|
|
950
|
+
zIndex: 50
|
|
951
|
+
},
|
|
952
|
+
edgeBottom: {
|
|
953
|
+
bottom: 0
|
|
954
|
+
},
|
|
955
|
+
edgeTop: {
|
|
956
|
+
top: 0
|
|
939
957
|
}
|
|
940
958
|
});
|
|
941
959
|
|
package/dist/chrome/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
getStaggeredWordDuration,
|
|
19
19
|
useCompactDialog,
|
|
20
20
|
useWellColors
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-75Q2VN5R.mjs";
|
|
22
22
|
import {
|
|
23
23
|
COMPACT_DIALOG_HEIGHT,
|
|
24
24
|
DialogHeader,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
getInlineColorPickerContentSize,
|
|
38
38
|
useAutoAlign,
|
|
39
39
|
usePopoverHost
|
|
40
|
-
} from "../chunk-
|
|
40
|
+
} from "../chunk-5ECU3722.mjs";
|
|
41
41
|
export {
|
|
42
42
|
AchievementCatalogSection,
|
|
43
43
|
AchievementRow,
|
|
@@ -18,13 +18,13 @@ function PopoverBody({ visible, children, align = "center", verticalAlign = "bel
|
|
|
18
18
|
const caretFill = above ? "borderTopColor" : "borderBottomColor";
|
|
19
19
|
const caretWidthProp = above ? "borderTopWidth" : "borderBottomWidth";
|
|
20
20
|
const caretEdge = (size) => above ? { bottom: -size + CARET_DIP } : { top: -size + CARET_DIP };
|
|
21
|
-
return /* @__PURE__ */ jsxs(View, { style: [styles.content, alignStyle, verticalStyle], children: [
|
|
21
|
+
return /* @__PURE__ */ jsx(View, { style: [styles.edge, above ? styles.edgeTop : styles.edgeBottom], children: /* @__PURE__ */ jsxs(View, { style: [styles.content, alignStyle, verticalStyle], children: [
|
|
22
22
|
children,
|
|
23
23
|
caretColor && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24
24
|
/* @__PURE__ */ jsx(View, { style: [styles.caret, caretOffset(ringSize), caretEdge(ringSize), { [caretFill]: caretBorderColor ?? caretColor, [caretWidthProp]: ringSize, borderLeftWidth: ringSize, borderRightWidth: ringSize }] }),
|
|
25
25
|
/* @__PURE__ */ jsx(View, { style: [styles.caret, caretOffset(CARET_SIZE), caretEdge(CARET_SIZE - CARET_RING_OFFSET), { [caretFill]: caretColor, [caretWidthProp]: CARET_SIZE, borderLeftWidth: CARET_SIZE, borderRightWidth: CARET_SIZE }] })
|
|
26
26
|
] })
|
|
27
|
-
] });
|
|
27
|
+
] }) });
|
|
28
28
|
}
|
|
29
29
|
var styles = StyleSheet.create({
|
|
30
30
|
caret: {
|
|
@@ -43,13 +43,15 @@ var styles = StyleSheet.create({
|
|
|
43
43
|
position: "absolute",
|
|
44
44
|
zIndex: 50
|
|
45
45
|
},
|
|
46
|
+
// The strip's bottom edge, which is the trigger's top: the box grows up from it.
|
|
46
47
|
contentAbove: {
|
|
47
|
-
bottom:
|
|
48
|
+
bottom: 0,
|
|
48
49
|
marginBottom: 8
|
|
49
50
|
},
|
|
51
|
+
// The strip's top edge, which is the trigger's bottom: the box grows down from it.
|
|
50
52
|
contentBelow: {
|
|
51
53
|
marginTop: 8,
|
|
52
|
-
top:
|
|
54
|
+
top: 0
|
|
53
55
|
},
|
|
54
56
|
// Stretched to the anchor's own (trigger) width, with alignItems centering the actual (usually
|
|
55
57
|
// much wider) popover box inside via plain flexbox - not `left:'50%'` plus a percentage
|
|
@@ -65,6 +67,22 @@ var styles = StyleSheet.create({
|
|
|
65
67
|
},
|
|
66
68
|
contentRight: {
|
|
67
69
|
right: 0
|
|
70
|
+
},
|
|
71
|
+
// The zero-height strip the box hangs off, spanning the trigger's wrapper (see PopoverBody's
|
|
72
|
+
// comment for why it isn't a percentage inset). Its zIndex matches the box's, so on the web, where
|
|
73
|
+
// every positioned view is its own stacking context, the box still paints over later siblings.
|
|
74
|
+
edge: {
|
|
75
|
+
height: 0,
|
|
76
|
+
left: 0,
|
|
77
|
+
position: "absolute",
|
|
78
|
+
right: 0,
|
|
79
|
+
zIndex: 50
|
|
80
|
+
},
|
|
81
|
+
edgeBottom: {
|
|
82
|
+
bottom: 0
|
|
83
|
+
},
|
|
84
|
+
edgeTop: {
|
|
85
|
+
top: 0
|
|
68
86
|
}
|
|
69
87
|
});
|
|
70
88
|
|
|
@@ -3,20 +3,41 @@ import {
|
|
|
3
3
|
MONO_FONT,
|
|
4
4
|
useAutoAlign,
|
|
5
5
|
usePopoverHost
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5ECU3722.mjs";
|
|
7
7
|
|
|
8
8
|
// src/ReadyButton.tsx
|
|
9
|
+
import { getTintTextColor } from "@rific/auto-paper";
|
|
9
10
|
import { TouchableRipple } from "@rific/feedback-press";
|
|
10
11
|
import { StyleSheet } from "react-native";
|
|
11
12
|
import { Text } from "react-native-paper";
|
|
12
13
|
import { jsx } from "react/jsx-runtime";
|
|
13
|
-
|
|
14
|
+
var PILL_HEIGHT = 44;
|
|
15
|
+
function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily, surfaceColor, dark = false }) {
|
|
16
|
+
const label = ready ? "READY \u2713" : "READY?";
|
|
17
|
+
if (surfaceColor) {
|
|
18
|
+
const pillStyle = [styles.pill, { backgroundColor: ready ? color : surfaceColor }, style];
|
|
19
|
+
const pillLabelColor = ready ? getTintTextColor(color, color, 1) : dark ? "#FFFFFF" : "#000000";
|
|
20
|
+
return /* @__PURE__ */ jsx(TouchableRipple, { onPress: onToggleReady, borderless: true, style: pillStyle, accessibilityRole: "button", accessibilityLabel: label, children: /* @__PURE__ */ jsx(Text, { style: [styles.pillLabel, { color: pillLabelColor }, labelFontFamily ? { fontFamily: labelFontFamily } : null], children: label }) });
|
|
21
|
+
}
|
|
14
22
|
const readyButtonStyle = [styles.readyButton, { borderColor: color }, ready && { backgroundColor: color }, style];
|
|
15
|
-
const labelTextStyle = { fontFamily: labelFontFamily, fontWeight: "bold" };
|
|
23
|
+
const labelTextStyle = { fontFamily: labelFontFamily ?? MONO_FONT, fontWeight: "bold" };
|
|
16
24
|
const labelColorStyle = { color: ready ? "#000000" : color };
|
|
17
|
-
return /* @__PURE__ */ jsx(TouchableRipple, { onPress: onToggleReady, borderless: true, style: readyButtonStyle, children: /* @__PURE__ */ jsx(Text, { variant: "labelLarge", style: [labelTextStyle, labelColorStyle], children:
|
|
25
|
+
return /* @__PURE__ */ jsx(TouchableRipple, { onPress: onToggleReady, borderless: true, style: readyButtonStyle, children: /* @__PURE__ */ jsx(Text, { variant: "labelLarge", style: [labelTextStyle, labelColorStyle], children: label }) });
|
|
18
26
|
}
|
|
19
27
|
var styles = StyleSheet.create({
|
|
28
|
+
pill: {
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
borderRadius: PILL_HEIGHT / 2,
|
|
31
|
+
height: PILL_HEIGHT,
|
|
32
|
+
justifyContent: "center",
|
|
33
|
+
minWidth: 120,
|
|
34
|
+
paddingHorizontal: 20
|
|
35
|
+
},
|
|
36
|
+
pillLabel: {
|
|
37
|
+
fontSize: 13,
|
|
38
|
+
fontWeight: "700",
|
|
39
|
+
letterSpacing: 1
|
|
40
|
+
},
|
|
20
41
|
readyButton: {
|
|
21
42
|
alignItems: "center",
|
|
22
43
|
borderRadius: 12,
|
|
@@ -81,7 +102,7 @@ function getProfilePopoverId(idPrefix) {
|
|
|
81
102
|
function getCpuDifficultyPopoverId(idPrefix) {
|
|
82
103
|
return `${idPrefix}-difficulty`;
|
|
83
104
|
}
|
|
84
|
-
function PlayerSetupPanel({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor = true, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton = true, profiles, selectedProfileId, takenProfileId, guestLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon = "face-man", cpuIcon = "robot" }) {
|
|
105
|
+
function PlayerSetupPanel({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor = true, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton = true, profiles, selectedProfileId, takenProfileId, guestLabel, nullLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon = "face-man", cpuIcon = "robot", previewValue, triggerStyle, readySurfaceColor, useSeatPickerAlign }) {
|
|
85
106
|
const ownHost = usePopoverHost();
|
|
86
107
|
const popover = host ?? ownHost;
|
|
87
108
|
const ownPopoverOpen = popover.openId?.startsWith(`${idPrefix}-`) ?? false;
|
|
@@ -90,17 +111,19 @@ function PlayerSetupPanel({ idPrefix, host, label, labelFontFamily, color, onCol
|
|
|
90
111
|
const showCpuDifficulty = !isHuman && cpuDifficulty !== void 0 && cpuDifficultyOptions !== void 0 && !!onCpuDifficultyChange;
|
|
91
112
|
const seatButton = showProfilePicker || showCpuDifficulty;
|
|
92
113
|
const selectedProfile = profiles?.find((p) => p.id === selectedProfileId) ?? null;
|
|
93
|
-
const
|
|
114
|
+
const drawn = previewValue ? previewValue(color) : color;
|
|
115
|
+
const colorSection = showColor ? { value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, caption: showProfilePicker && selectedProfile ? colorCaption : void 0, previewValue } : void 0;
|
|
94
116
|
const seatPickerId = showProfilePicker ? getProfilePopoverId(idPrefix) : getCpuDifficultyPopoverId(idPrefix);
|
|
95
117
|
const seatPickerSize = showProfilePicker ? getProfilePickerContentSize(profiles.length, !!onManageProfiles, colorSection) : getOptionPickerContentSize(cpuDifficultyOptions?.length ?? 0, colorSection);
|
|
96
|
-
const
|
|
118
|
+
const useSeatAlign = useSeatPickerAlign ?? useZoneClampedAlign;
|
|
119
|
+
const seatPickerAlign = useSeatAlign(seatButton && popover.openId === seatPickerId, seatPickerSize.width, seatPickerSize.height);
|
|
97
120
|
return /* @__PURE__ */ jsxs(View, { style: [styles2.panel, ownPopoverOpen && styles2.panelOpen], children: [
|
|
98
|
-
showProfilePicker ? /* @__PURE__ */ jsx2(ProfilePicker, { idPrefix, host: popover, profiles, selectedId: selectedProfileId ?? null, takenId: takenProfileId, color, dark, guestLabel: guestLabel ?? "GUEST", onSelect: (profile) => onProfileSelect?.(profile), onManage: onManageProfiles, colorSection, alignOverride: seatPickerAlign }) : showCpuDifficulty ? /* @__PURE__ */ jsx2(OptionPicker, { id: getCpuDifficultyPopoverId(idPrefix), host: popover, options: cpuDifficultyOptions, value: cpuDifficulty, onChange: onCpuDifficultyChange, color, dark, icon: cpuIcon, colorSection, alignOverride: seatPickerAlign }) : label && /* @__PURE__ */ jsx2(Text2, { variant: "labelSmall", style: { color, fontFamily: labelFontFamily }, children: label }),
|
|
121
|
+
showProfilePicker ? /* @__PURE__ */ jsx2(ProfilePicker, { idPrefix, host: popover, profiles, selectedId: selectedProfileId ?? null, takenId: takenProfileId, color: drawn, dark, guestLabel: guestLabel ?? "GUEST", nullLabel, onSelect: (profile) => onProfileSelect?.(profile), onManage: onManageProfiles, colorSection, alignOverride: seatPickerAlign, triggerStyle }) : showCpuDifficulty ? /* @__PURE__ */ jsx2(OptionPicker, { id: getCpuDifficultyPopoverId(idPrefix), host: popover, options: cpuDifficultyOptions, value: cpuDifficulty, onChange: onCpuDifficultyChange, color: drawn, dark, icon: cpuIcon, colorSection, alignOverride: seatPickerAlign, triggerStyle }) : label && /* @__PURE__ */ jsx2(Text2, { variant: "labelSmall", style: { color: drawn, fontFamily: labelFontFamily }, children: label }),
|
|
99
122
|
(!seatButton || secondPicker) && /* @__PURE__ */ jsxs(View, { style: [styles2.pickerRow, pickerRowPopoverOpen && styles2.pickerRowOpen], children: [
|
|
100
|
-
!seatButton && /* @__PURE__ */ jsx2(InlineColorPicker, { id: getColorPopoverId(idPrefix), host: popover, value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, alignOverride: colorAlignOverride, rotation: colorRotation, dark, tag: isHuman ? selectedProfile?.tag : void 0, icon: isHuman ? humanIcon : cpuIcon }),
|
|
123
|
+
!seatButton && /* @__PURE__ */ jsx2(InlineColorPicker, { id: getColorPopoverId(idPrefix), host: popover, value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, previewValue, alignOverride: colorAlignOverride, rotation: colorRotation, dark, tag: isHuman ? selectedProfile?.tag : void 0, icon: isHuman ? humanIcon : cpuIcon }),
|
|
101
124
|
secondPicker
|
|
102
125
|
] }),
|
|
103
|
-
isHuman && showReadyButton && onToggleReady && /* @__PURE__ */ jsx2(ReadyButton, { color, ready: ready ?? false, onToggleReady })
|
|
126
|
+
isHuman && showReadyButton && onToggleReady && /* @__PURE__ */ jsx2(ReadyButton, { color: drawn, ready: ready ?? false, onToggleReady, surfaceColor: readySurfaceColor, dark })
|
|
104
127
|
] });
|
|
105
128
|
}
|
|
106
129
|
var styles2 = StyleSheet2.create({
|
|
@@ -2,8 +2,8 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { SeedColor } from '@rific/auto-paper';
|
|
4
4
|
import { Profile } from '@tastic/profile';
|
|
5
|
-
import { P as PopoverHost, A as AlignResult, a as PopoverRotation, u as useAutoAlign } from './usePopoverHost-T8QWb2_A.js';
|
|
6
5
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
6
|
+
import { P as PopoverHost, A as AlignResult, a as PopoverRotation, u as useAutoAlign } from './usePopoverHost-T8QWb2_A.js';
|
|
7
7
|
|
|
8
8
|
interface MenuOption<T extends string | number> {
|
|
9
9
|
value: T;
|
|
@@ -61,6 +61,7 @@ interface PlayerSetupPanelProps<C extends string = string> {
|
|
|
61
61
|
selectedProfileId?: string | null;
|
|
62
62
|
takenProfileId?: string | null;
|
|
63
63
|
guestLabel?: string;
|
|
64
|
+
nullLabel?: string;
|
|
64
65
|
onProfileSelect?: (profile: Profile | null) => void;
|
|
65
66
|
onManageProfiles?: () => void;
|
|
66
67
|
cpuDifficulty?: C;
|
|
@@ -68,8 +69,12 @@ interface PlayerSetupPanelProps<C extends string = string> {
|
|
|
68
69
|
onCpuDifficultyChange?: (value: C) => void;
|
|
69
70
|
humanIcon?: string;
|
|
70
71
|
cpuIcon?: string;
|
|
72
|
+
previewValue?: (hex: string) => string;
|
|
73
|
+
triggerStyle?: StyleProp<ViewStyle>;
|
|
74
|
+
readySurfaceColor?: string;
|
|
75
|
+
useSeatPickerAlign?: (open: boolean, contentWidth: number, contentHeight: number) => AlignResult;
|
|
71
76
|
}
|
|
72
|
-
declare function PlayerSetupPanel<C extends string = string>({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton, profiles, selectedProfileId, takenProfileId, guestLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon, cpuIcon }: PlayerSetupPanelProps<C>): react.JSX.Element;
|
|
77
|
+
declare function PlayerSetupPanel<C extends string = string>({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton, profiles, selectedProfileId, takenProfileId, guestLabel, nullLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon, cpuIcon, previewValue, triggerStyle, readySurfaceColor, useSeatPickerAlign }: PlayerSetupPanelProps<C>): react.JSX.Element;
|
|
73
78
|
|
|
74
79
|
interface Props$1 {
|
|
75
80
|
color: string;
|
|
@@ -77,8 +82,10 @@ interface Props$1 {
|
|
|
77
82
|
onToggleReady: () => void;
|
|
78
83
|
style?: StyleProp<ViewStyle>;
|
|
79
84
|
labelFontFamily?: string;
|
|
85
|
+
surfaceColor?: string;
|
|
86
|
+
dark?: boolean;
|
|
80
87
|
}
|
|
81
|
-
declare function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily }: Props$1): react.JSX.Element;
|
|
88
|
+
declare function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily, surfaceColor, dark }: Props$1): react.JSX.Element;
|
|
82
89
|
|
|
83
90
|
interface Props {
|
|
84
91
|
onBack: () => void;
|
|
@@ -2,8 +2,8 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { SeedColor } from '@rific/auto-paper';
|
|
4
4
|
import { Profile } from '@tastic/profile';
|
|
5
|
-
import { P as PopoverHost, A as AlignResult, a as PopoverRotation, u as useAutoAlign } from './usePopoverHost-T8QWb2_A.mjs';
|
|
6
5
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
6
|
+
import { P as PopoverHost, A as AlignResult, a as PopoverRotation, u as useAutoAlign } from './usePopoverHost-T8QWb2_A.mjs';
|
|
7
7
|
|
|
8
8
|
interface MenuOption<T extends string | number> {
|
|
9
9
|
value: T;
|
|
@@ -61,6 +61,7 @@ interface PlayerSetupPanelProps<C extends string = string> {
|
|
|
61
61
|
selectedProfileId?: string | null;
|
|
62
62
|
takenProfileId?: string | null;
|
|
63
63
|
guestLabel?: string;
|
|
64
|
+
nullLabel?: string;
|
|
64
65
|
onProfileSelect?: (profile: Profile | null) => void;
|
|
65
66
|
onManageProfiles?: () => void;
|
|
66
67
|
cpuDifficulty?: C;
|
|
@@ -68,8 +69,12 @@ interface PlayerSetupPanelProps<C extends string = string> {
|
|
|
68
69
|
onCpuDifficultyChange?: (value: C) => void;
|
|
69
70
|
humanIcon?: string;
|
|
70
71
|
cpuIcon?: string;
|
|
72
|
+
previewValue?: (hex: string) => string;
|
|
73
|
+
triggerStyle?: StyleProp<ViewStyle>;
|
|
74
|
+
readySurfaceColor?: string;
|
|
75
|
+
useSeatPickerAlign?: (open: boolean, contentWidth: number, contentHeight: number) => AlignResult;
|
|
71
76
|
}
|
|
72
|
-
declare function PlayerSetupPanel<C extends string = string>({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton, profiles, selectedProfileId, takenProfileId, guestLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon, cpuIcon }: PlayerSetupPanelProps<C>): react.JSX.Element;
|
|
77
|
+
declare function PlayerSetupPanel<C extends string = string>({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton, profiles, selectedProfileId, takenProfileId, guestLabel, nullLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon, cpuIcon, previewValue, triggerStyle, readySurfaceColor, useSeatPickerAlign }: PlayerSetupPanelProps<C>): react.JSX.Element;
|
|
73
78
|
|
|
74
79
|
interface Props$1 {
|
|
75
80
|
color: string;
|
|
@@ -77,8 +82,10 @@ interface Props$1 {
|
|
|
77
82
|
onToggleReady: () => void;
|
|
78
83
|
style?: StyleProp<ViewStyle>;
|
|
79
84
|
labelFontFamily?: string;
|
|
85
|
+
surfaceColor?: string;
|
|
86
|
+
dark?: boolean;
|
|
80
87
|
}
|
|
81
|
-
declare function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily }: Props$1): react.JSX.Element;
|
|
88
|
+
declare function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily, surfaceColor, dark }: Props$1): react.JSX.Element;
|
|
82
89
|
|
|
83
90
|
interface Props {
|
|
84
91
|
onBack: () => void;
|
package/dist/index.d.mts
CHANGED
|
@@ -3,8 +3,8 @@ import * as react from 'react';
|
|
|
3
3
|
import { AchievementTier } from '@tastic/achievements';
|
|
4
4
|
import { Profile } from '@tastic/profile';
|
|
5
5
|
import { ViewStyle } from 'react-native';
|
|
6
|
-
import { M as MenuOption } from './index-
|
|
7
|
-
export { L as LABELED_DROPDOWN_POPOVER_WIDTH, a as LabeledDropdown, b as LabeledDropdownOption, P as PlayerSetupPanel, c as PlayerSetupPanelProps, R as ReadyButton, S as SharedActionBand, g as getColorPopoverId, d as getCpuDifficultyPopoverId, e as getLabeledDropdownContentHeight, f as getProfilePopoverId, u as useZoneClampedAlign } from './index-
|
|
6
|
+
import { M as MenuOption } from './index-BOMA2rLU.mjs';
|
|
7
|
+
export { L as LABELED_DROPDOWN_POPOVER_WIDTH, a as LabeledDropdown, b as LabeledDropdownOption, P as PlayerSetupPanel, c as PlayerSetupPanelProps, R as ReadyButton, S as SharedActionBand, g as getColorPopoverId, d as getCpuDifficultyPopoverId, e as getLabeledDropdownContentHeight, f as getProfilePopoverId, u as useZoneClampedAlign } from './index-BOMA2rLU.mjs';
|
|
8
8
|
import { P as PopoverHost, A as AlignResult, a as PopoverRotation } from './usePopoverHost-T8QWb2_A.mjs';
|
|
9
9
|
export { b as PopoverAlign, c as PopoverVerticalAlign, V as ViewInstance, u as useAutoAlign, d as usePopoverHost } from './usePopoverHost-T8QWb2_A.mjs';
|
|
10
10
|
export { loadSkiaWeb, locateSkiaWebFile } from './skia/index.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import * as react from 'react';
|
|
|
3
3
|
import { AchievementTier } from '@tastic/achievements';
|
|
4
4
|
import { Profile } from '@tastic/profile';
|
|
5
5
|
import { ViewStyle } from 'react-native';
|
|
6
|
-
import { M as MenuOption } from './index-
|
|
7
|
-
export { L as LABELED_DROPDOWN_POPOVER_WIDTH, a as LabeledDropdown, b as LabeledDropdownOption, P as PlayerSetupPanel, c as PlayerSetupPanelProps, R as ReadyButton, S as SharedActionBand, g as getColorPopoverId, d as getCpuDifficultyPopoverId, e as getLabeledDropdownContentHeight, f as getProfilePopoverId, u as useZoneClampedAlign } from './index-
|
|
6
|
+
import { M as MenuOption } from './index-B2sz-9jr.js';
|
|
7
|
+
export { L as LABELED_DROPDOWN_POPOVER_WIDTH, a as LabeledDropdown, b as LabeledDropdownOption, P as PlayerSetupPanel, c as PlayerSetupPanelProps, R as ReadyButton, S as SharedActionBand, g as getColorPopoverId, d as getCpuDifficultyPopoverId, e as getLabeledDropdownContentHeight, f as getProfilePopoverId, u as useZoneClampedAlign } from './index-B2sz-9jr.js';
|
|
8
8
|
import { P as PopoverHost, A as AlignResult, a as PopoverRotation } from './usePopoverHost-T8QWb2_A.js';
|
|
9
9
|
export { b as PopoverAlign, c as PopoverVerticalAlign, V as ViewInstance, u as useAutoAlign, d as usePopoverHost } from './usePopoverHost-T8QWb2_A.js';
|
|
10
10
|
export { loadSkiaWeb, locateSkiaWebFile } from './skia/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1073,13 +1073,13 @@ function PopoverBody({ visible, children, align = "center", verticalAlign = "bel
|
|
|
1073
1073
|
const caretFill = above ? "borderTopColor" : "borderBottomColor";
|
|
1074
1074
|
const caretWidthProp = above ? "borderTopWidth" : "borderBottomWidth";
|
|
1075
1075
|
const caretEdge = (size) => above ? { bottom: -size + CARET_DIP } : { top: -size + CARET_DIP };
|
|
1076
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native16.View, { style: [styles13.content, alignStyle, verticalStyle], children: [
|
|
1076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native16.View, { style: [styles13.edge, above ? styles13.edgeTop : styles13.edgeBottom], children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native16.View, { style: [styles13.content, alignStyle, verticalStyle], children: [
|
|
1077
1077
|
children,
|
|
1078
1078
|
caretColor && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
1079
1079
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native16.View, { style: [styles13.caret, caretOffset(ringSize), caretEdge(ringSize), { [caretFill]: caretBorderColor ?? caretColor, [caretWidthProp]: ringSize, borderLeftWidth: ringSize, borderRightWidth: ringSize }] }),
|
|
1080
1080
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native16.View, { style: [styles13.caret, caretOffset(CARET_SIZE), caretEdge(CARET_SIZE - CARET_RING_OFFSET), { [caretFill]: caretColor, [caretWidthProp]: CARET_SIZE, borderLeftWidth: CARET_SIZE, borderRightWidth: CARET_SIZE }] })
|
|
1081
1081
|
] })
|
|
1082
|
-
] });
|
|
1082
|
+
] }) });
|
|
1083
1083
|
}
|
|
1084
1084
|
var styles13 = import_react_native16.StyleSheet.create({
|
|
1085
1085
|
caret: {
|
|
@@ -1098,13 +1098,15 @@ var styles13 = import_react_native16.StyleSheet.create({
|
|
|
1098
1098
|
position: "absolute",
|
|
1099
1099
|
zIndex: 50
|
|
1100
1100
|
},
|
|
1101
|
+
// The strip's bottom edge, which is the trigger's top: the box grows up from it.
|
|
1101
1102
|
contentAbove: {
|
|
1102
|
-
bottom:
|
|
1103
|
+
bottom: 0,
|
|
1103
1104
|
marginBottom: 8
|
|
1104
1105
|
},
|
|
1106
|
+
// The strip's top edge, which is the trigger's bottom: the box grows down from it.
|
|
1105
1107
|
contentBelow: {
|
|
1106
1108
|
marginTop: 8,
|
|
1107
|
-
top:
|
|
1109
|
+
top: 0
|
|
1108
1110
|
},
|
|
1109
1111
|
// Stretched to the anchor's own (trigger) width, with alignItems centering the actual (usually
|
|
1110
1112
|
// much wider) popover box inside via plain flexbox - not `left:'50%'` plus a percentage
|
|
@@ -1120,6 +1122,22 @@ var styles13 = import_react_native16.StyleSheet.create({
|
|
|
1120
1122
|
},
|
|
1121
1123
|
contentRight: {
|
|
1122
1124
|
right: 0
|
|
1125
|
+
},
|
|
1126
|
+
// The zero-height strip the box hangs off, spanning the trigger's wrapper (see PopoverBody's
|
|
1127
|
+
// comment for why it isn't a percentage inset). Its zIndex matches the box's, so on the web, where
|
|
1128
|
+
// every positioned view is its own stacking context, the box still paints over later siblings.
|
|
1129
|
+
edge: {
|
|
1130
|
+
height: 0,
|
|
1131
|
+
left: 0,
|
|
1132
|
+
position: "absolute",
|
|
1133
|
+
right: 0,
|
|
1134
|
+
zIndex: 50
|
|
1135
|
+
},
|
|
1136
|
+
edgeBottom: {
|
|
1137
|
+
bottom: 0
|
|
1138
|
+
},
|
|
1139
|
+
edgeTop: {
|
|
1140
|
+
top: 0
|
|
1123
1141
|
}
|
|
1124
1142
|
});
|
|
1125
1143
|
|
|
@@ -1727,17 +1745,38 @@ var import_react_native27 = require("react-native");
|
|
|
1727
1745
|
var import_react_native_paper16 = require("react-native-paper");
|
|
1728
1746
|
|
|
1729
1747
|
// src/ReadyButton.tsx
|
|
1748
|
+
var import_auto_paper12 = require("@rific/auto-paper");
|
|
1730
1749
|
var import_feedback_press9 = require("@rific/feedback-press");
|
|
1731
1750
|
var import_react_native25 = require("react-native");
|
|
1732
1751
|
var import_react_native_paper15 = require("react-native-paper");
|
|
1733
1752
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1734
|
-
|
|
1753
|
+
var PILL_HEIGHT = 44;
|
|
1754
|
+
function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily, surfaceColor, dark = false }) {
|
|
1755
|
+
const label = ready ? "READY \u2713" : "READY?";
|
|
1756
|
+
if (surfaceColor) {
|
|
1757
|
+
const pillStyle = [styles20.pill, { backgroundColor: ready ? color : surfaceColor }, style];
|
|
1758
|
+
const pillLabelColor = ready ? (0, import_auto_paper12.getTintTextColor)(color, color, 1) : dark ? "#FFFFFF" : "#000000";
|
|
1759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_feedback_press9.TouchableRipple, { onPress: onToggleReady, borderless: true, style: pillStyle, accessibilityRole: "button", accessibilityLabel: label, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_native_paper15.Text, { style: [styles20.pillLabel, { color: pillLabelColor }, labelFontFamily ? { fontFamily: labelFontFamily } : null], children: label }) });
|
|
1760
|
+
}
|
|
1735
1761
|
const readyButtonStyle = [styles20.readyButton, { borderColor: color }, ready && { backgroundColor: color }, style];
|
|
1736
|
-
const labelTextStyle = { fontFamily: labelFontFamily, fontWeight: "bold" };
|
|
1762
|
+
const labelTextStyle = { fontFamily: labelFontFamily ?? MONO_FONT, fontWeight: "bold" };
|
|
1737
1763
|
const labelColorStyle = { color: ready ? "#000000" : color };
|
|
1738
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_feedback_press9.TouchableRipple, { onPress: onToggleReady, borderless: true, style: readyButtonStyle, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_native_paper15.Text, { variant: "labelLarge", style: [labelTextStyle, labelColorStyle], children:
|
|
1764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_feedback_press9.TouchableRipple, { onPress: onToggleReady, borderless: true, style: readyButtonStyle, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_native_paper15.Text, { variant: "labelLarge", style: [labelTextStyle, labelColorStyle], children: label }) });
|
|
1739
1765
|
}
|
|
1740
1766
|
var styles20 = import_react_native25.StyleSheet.create({
|
|
1767
|
+
pill: {
|
|
1768
|
+
alignItems: "center",
|
|
1769
|
+
borderRadius: PILL_HEIGHT / 2,
|
|
1770
|
+
height: PILL_HEIGHT,
|
|
1771
|
+
justifyContent: "center",
|
|
1772
|
+
minWidth: 120,
|
|
1773
|
+
paddingHorizontal: 20
|
|
1774
|
+
},
|
|
1775
|
+
pillLabel: {
|
|
1776
|
+
fontSize: 13,
|
|
1777
|
+
fontWeight: "700",
|
|
1778
|
+
letterSpacing: 1
|
|
1779
|
+
},
|
|
1741
1780
|
readyButton: {
|
|
1742
1781
|
alignItems: "center",
|
|
1743
1782
|
borderRadius: 12,
|
|
@@ -1810,7 +1849,7 @@ function getProfilePopoverId(idPrefix) {
|
|
|
1810
1849
|
function getCpuDifficultyPopoverId(idPrefix) {
|
|
1811
1850
|
return `${idPrefix}-difficulty`;
|
|
1812
1851
|
}
|
|
1813
|
-
function PlayerSetupPanel({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor = true, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton = true, profiles, selectedProfileId, takenProfileId, guestLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon = "face-man", cpuIcon = "robot" }) {
|
|
1852
|
+
function PlayerSetupPanel({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor = true, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton = true, profiles, selectedProfileId, takenProfileId, guestLabel, nullLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon = "face-man", cpuIcon = "robot", previewValue, triggerStyle, readySurfaceColor, useSeatPickerAlign }) {
|
|
1814
1853
|
const ownHost = usePopoverHost();
|
|
1815
1854
|
const popover = host ?? ownHost;
|
|
1816
1855
|
const ownPopoverOpen = popover.openId?.startsWith(`${idPrefix}-`) ?? false;
|
|
@@ -1819,17 +1858,19 @@ function PlayerSetupPanel({ idPrefix, host, label, labelFontFamily, color, onCol
|
|
|
1819
1858
|
const showCpuDifficulty = !isHuman && cpuDifficulty !== void 0 && cpuDifficultyOptions !== void 0 && !!onCpuDifficultyChange;
|
|
1820
1859
|
const seatButton = showProfilePicker || showCpuDifficulty;
|
|
1821
1860
|
const selectedProfile = profiles?.find((p) => p.id === selectedProfileId) ?? null;
|
|
1822
|
-
const
|
|
1861
|
+
const drawn = previewValue ? previewValue(color) : color;
|
|
1862
|
+
const colorSection = showColor ? { value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, caption: showProfilePicker && selectedProfile ? colorCaption : void 0, previewValue } : void 0;
|
|
1823
1863
|
const seatPickerId = showProfilePicker ? getProfilePopoverId(idPrefix) : getCpuDifficultyPopoverId(idPrefix);
|
|
1824
1864
|
const seatPickerSize = showProfilePicker ? (0, import_profile2.getProfilePickerContentSize)(profiles.length, !!onManageProfiles, colorSection) : (0, import_profile2.getOptionPickerContentSize)(cpuDifficultyOptions?.length ?? 0, colorSection);
|
|
1825
|
-
const
|
|
1865
|
+
const useSeatAlign = useSeatPickerAlign ?? useZoneClampedAlign;
|
|
1866
|
+
const seatPickerAlign = useSeatAlign(seatButton && popover.openId === seatPickerId, seatPickerSize.width, seatPickerSize.height);
|
|
1826
1867
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react_native27.View, { style: [styles21.panel, ownPopoverOpen && styles21.panelOpen], children: [
|
|
1827
|
-
showProfilePicker ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_profile2.ProfilePicker, { idPrefix, host: popover, profiles, selectedId: selectedProfileId ?? null, takenId: takenProfileId, color, dark, guestLabel: guestLabel ?? "GUEST", onSelect: (profile) => onProfileSelect?.(profile), onManage: onManageProfiles, colorSection, alignOverride: seatPickerAlign }) : showCpuDifficulty ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_profile2.OptionPicker, { id: getCpuDifficultyPopoverId(idPrefix), host: popover, options: cpuDifficultyOptions, value: cpuDifficulty, onChange: onCpuDifficultyChange, color, dark, icon: cpuIcon, colorSection, alignOverride: seatPickerAlign }) : label && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_native_paper16.Text, { variant: "labelSmall", style: { color, fontFamily: labelFontFamily }, children: label }),
|
|
1868
|
+
showProfilePicker ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_profile2.ProfilePicker, { idPrefix, host: popover, profiles, selectedId: selectedProfileId ?? null, takenId: takenProfileId, color: drawn, dark, guestLabel: guestLabel ?? "GUEST", nullLabel, onSelect: (profile) => onProfileSelect?.(profile), onManage: onManageProfiles, colorSection, alignOverride: seatPickerAlign, triggerStyle }) : showCpuDifficulty ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_profile2.OptionPicker, { id: getCpuDifficultyPopoverId(idPrefix), host: popover, options: cpuDifficultyOptions, value: cpuDifficulty, onChange: onCpuDifficultyChange, color: drawn, dark, icon: cpuIcon, colorSection, alignOverride: seatPickerAlign, triggerStyle }) : label && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_native_paper16.Text, { variant: "labelSmall", style: { color: drawn, fontFamily: labelFontFamily }, children: label }),
|
|
1828
1869
|
(!seatButton || secondPicker) && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react_native27.View, { style: [styles21.pickerRow, pickerRowPopoverOpen && styles21.pickerRowOpen], children: [
|
|
1829
|
-
!seatButton && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(InlineColorPicker, { id: getColorPopoverId(idPrefix), host: popover, value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, alignOverride: colorAlignOverride, rotation: colorRotation, dark, tag: isHuman ? selectedProfile?.tag : void 0, icon: isHuman ? humanIcon : cpuIcon }),
|
|
1870
|
+
!seatButton && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(InlineColorPicker, { id: getColorPopoverId(idPrefix), host: popover, value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, previewValue, alignOverride: colorAlignOverride, rotation: colorRotation, dark, tag: isHuman ? selectedProfile?.tag : void 0, icon: isHuman ? humanIcon : cpuIcon }),
|
|
1830
1871
|
secondPicker
|
|
1831
1872
|
] }),
|
|
1832
|
-
isHuman && showReadyButton && onToggleReady && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ReadyButton, { color, ready: ready ?? false, onToggleReady })
|
|
1873
|
+
isHuman && showReadyButton && onToggleReady && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ReadyButton, { color: drawn, ready: ready ?? false, onToggleReady, surfaceColor: readySurfaceColor, dark })
|
|
1833
1874
|
] });
|
|
1834
1875
|
}
|
|
1835
1876
|
var styles21 = import_react_native27.StyleSheet.create({
|
package/dist/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
getStaggeredWordDuration,
|
|
19
19
|
useCompactDialog,
|
|
20
20
|
useWellColors
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-75Q2VN5R.mjs";
|
|
22
22
|
import {
|
|
23
23
|
COMPACT_DIALOG_HEIGHT,
|
|
24
24
|
DialogHeader,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
getCpuDifficultyPopoverId,
|
|
39
39
|
getProfilePopoverId,
|
|
40
40
|
useZoneClampedAlign
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-CPNDNJJR.mjs";
|
|
42
42
|
import {
|
|
43
43
|
InlineColorPicker,
|
|
44
44
|
MONO_FONT,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
getInlineColorPickerContentSize,
|
|
47
47
|
useAutoAlign,
|
|
48
48
|
usePopoverHost
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-5ECU3722.mjs";
|
|
50
50
|
import {
|
|
51
51
|
loadSkiaWeb,
|
|
52
52
|
locateSkiaWebFile
|
package/dist/lobby/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { M as MenuOption, P as PlayerSetupPanel, c as PlayerSetupPanelProps, R as ReadyButton, S as SharedActionBand, g as getColorPopoverId, d as getCpuDifficultyPopoverId, f as getProfilePopoverId, u as useZoneClampedAlign } from '../index-
|
|
1
|
+
export { M as MenuOption, P as PlayerSetupPanel, c as PlayerSetupPanelProps, R as ReadyButton, S as SharedActionBand, g as getColorPopoverId, d as getCpuDifficultyPopoverId, f as getProfilePopoverId, u as useZoneClampedAlign } from '../index-BOMA2rLU.mjs';
|
|
2
2
|
import 'react';
|
|
3
3
|
import '@rific/auto-paper';
|
|
4
4
|
import '@tastic/profile';
|
|
5
|
+
import 'react-native';
|
|
5
6
|
import '../usePopoverHost-T8QWb2_A.mjs';
|
|
6
7
|
import '@tastic/core';
|
|
7
|
-
import 'react-native';
|
package/dist/lobby/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { M as MenuOption, P as PlayerSetupPanel, c as PlayerSetupPanelProps, R as ReadyButton, S as SharedActionBand, g as getColorPopoverId, d as getCpuDifficultyPopoverId, f as getProfilePopoverId, u as useZoneClampedAlign } from '../index-
|
|
1
|
+
export { M as MenuOption, P as PlayerSetupPanel, c as PlayerSetupPanelProps, R as ReadyButton, S as SharedActionBand, g as getColorPopoverId, d as getCpuDifficultyPopoverId, f as getProfilePopoverId, u as useZoneClampedAlign } from '../index-B2sz-9jr.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import '@rific/auto-paper';
|
|
4
4
|
import '@tastic/profile';
|
|
5
|
+
import 'react-native';
|
|
5
6
|
import '../usePopoverHost-T8QWb2_A.js';
|
|
6
7
|
import '@tastic/core';
|
|
7
|
-
import 'react-native';
|
package/dist/lobby/index.js
CHANGED
|
@@ -62,13 +62,13 @@ function PopoverBody({ visible, children, align = "center", verticalAlign = "bel
|
|
|
62
62
|
const caretFill = above ? "borderTopColor" : "borderBottomColor";
|
|
63
63
|
const caretWidthProp = above ? "borderTopWidth" : "borderBottomWidth";
|
|
64
64
|
const caretEdge = (size) => above ? { bottom: -size + CARET_DIP } : { top: -size + CARET_DIP };
|
|
65
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: [styles.content, alignStyle, verticalStyle], children: [
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.edge, above ? styles.edgeTop : styles.edgeBottom], children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: [styles.content, alignStyle, verticalStyle], children: [
|
|
66
66
|
children,
|
|
67
67
|
caretColor && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
68
68
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.caret, caretOffset(ringSize), caretEdge(ringSize), { [caretFill]: caretBorderColor ?? caretColor, [caretWidthProp]: ringSize, borderLeftWidth: ringSize, borderRightWidth: ringSize }] }),
|
|
69
69
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.caret, caretOffset(CARET_SIZE), caretEdge(CARET_SIZE - CARET_RING_OFFSET), { [caretFill]: caretColor, [caretWidthProp]: CARET_SIZE, borderLeftWidth: CARET_SIZE, borderRightWidth: CARET_SIZE }] })
|
|
70
70
|
] })
|
|
71
|
-
] });
|
|
71
|
+
] }) });
|
|
72
72
|
}
|
|
73
73
|
var styles = import_react_native2.StyleSheet.create({
|
|
74
74
|
caret: {
|
|
@@ -87,13 +87,15 @@ var styles = import_react_native2.StyleSheet.create({
|
|
|
87
87
|
position: "absolute",
|
|
88
88
|
zIndex: 50
|
|
89
89
|
},
|
|
90
|
+
// The strip's bottom edge, which is the trigger's top: the box grows up from it.
|
|
90
91
|
contentAbove: {
|
|
91
|
-
bottom:
|
|
92
|
+
bottom: 0,
|
|
92
93
|
marginBottom: 8
|
|
93
94
|
},
|
|
95
|
+
// The strip's top edge, which is the trigger's bottom: the box grows down from it.
|
|
94
96
|
contentBelow: {
|
|
95
97
|
marginTop: 8,
|
|
96
|
-
top:
|
|
98
|
+
top: 0
|
|
97
99
|
},
|
|
98
100
|
// Stretched to the anchor's own (trigger) width, with alignItems centering the actual (usually
|
|
99
101
|
// much wider) popover box inside via plain flexbox - not `left:'50%'` plus a percentage
|
|
@@ -109,6 +111,22 @@ var styles = import_react_native2.StyleSheet.create({
|
|
|
109
111
|
},
|
|
110
112
|
contentRight: {
|
|
111
113
|
right: 0
|
|
114
|
+
},
|
|
115
|
+
// The zero-height strip the box hangs off, spanning the trigger's wrapper (see PopoverBody's
|
|
116
|
+
// comment for why it isn't a percentage inset). Its zIndex matches the box's, so on the web, where
|
|
117
|
+
// every positioned view is its own stacking context, the box still paints over later siblings.
|
|
118
|
+
edge: {
|
|
119
|
+
height: 0,
|
|
120
|
+
left: 0,
|
|
121
|
+
position: "absolute",
|
|
122
|
+
right: 0,
|
|
123
|
+
zIndex: 50
|
|
124
|
+
},
|
|
125
|
+
edgeBottom: {
|
|
126
|
+
bottom: 0
|
|
127
|
+
},
|
|
128
|
+
edgeTop: {
|
|
129
|
+
top: 0
|
|
112
130
|
}
|
|
113
131
|
});
|
|
114
132
|
|
|
@@ -334,17 +352,38 @@ var styles2 = import_react_native4.StyleSheet.create({
|
|
|
334
352
|
});
|
|
335
353
|
|
|
336
354
|
// src/ReadyButton.tsx
|
|
355
|
+
var import_auto_paper2 = require("@rific/auto-paper");
|
|
337
356
|
var import_feedback_press2 = require("@rific/feedback-press");
|
|
338
357
|
var import_react_native5 = require("react-native");
|
|
339
358
|
var import_react_native_paper2 = require("react-native-paper");
|
|
340
359
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
341
|
-
|
|
360
|
+
var PILL_HEIGHT = 44;
|
|
361
|
+
function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily, surfaceColor, dark = false }) {
|
|
362
|
+
const label = ready ? "READY \u2713" : "READY?";
|
|
363
|
+
if (surfaceColor) {
|
|
364
|
+
const pillStyle = [styles3.pill, { backgroundColor: ready ? color : surfaceColor }, style];
|
|
365
|
+
const pillLabelColor = ready ? (0, import_auto_paper2.getTintTextColor)(color, color, 1) : dark ? "#FFFFFF" : "#000000";
|
|
366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_feedback_press2.TouchableRipple, { onPress: onToggleReady, borderless: true, style: pillStyle, accessibilityRole: "button", accessibilityLabel: label, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_paper2.Text, { style: [styles3.pillLabel, { color: pillLabelColor }, labelFontFamily ? { fontFamily: labelFontFamily } : null], children: label }) });
|
|
367
|
+
}
|
|
342
368
|
const readyButtonStyle = [styles3.readyButton, { borderColor: color }, ready && { backgroundColor: color }, style];
|
|
343
|
-
const labelTextStyle = { fontFamily: labelFontFamily, fontWeight: "bold" };
|
|
369
|
+
const labelTextStyle = { fontFamily: labelFontFamily ?? MONO_FONT, fontWeight: "bold" };
|
|
344
370
|
const labelColorStyle = { color: ready ? "#000000" : color };
|
|
345
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_feedback_press2.TouchableRipple, { onPress: onToggleReady, borderless: true, style: readyButtonStyle, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_paper2.Text, { variant: "labelLarge", style: [labelTextStyle, labelColorStyle], children:
|
|
371
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_feedback_press2.TouchableRipple, { onPress: onToggleReady, borderless: true, style: readyButtonStyle, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_paper2.Text, { variant: "labelLarge", style: [labelTextStyle, labelColorStyle], children: label }) });
|
|
346
372
|
}
|
|
347
373
|
var styles3 = import_react_native5.StyleSheet.create({
|
|
374
|
+
pill: {
|
|
375
|
+
alignItems: "center",
|
|
376
|
+
borderRadius: PILL_HEIGHT / 2,
|
|
377
|
+
height: PILL_HEIGHT,
|
|
378
|
+
justifyContent: "center",
|
|
379
|
+
minWidth: 120,
|
|
380
|
+
paddingHorizontal: 20
|
|
381
|
+
},
|
|
382
|
+
pillLabel: {
|
|
383
|
+
fontSize: 13,
|
|
384
|
+
fontWeight: "700",
|
|
385
|
+
letterSpacing: 1
|
|
386
|
+
},
|
|
348
387
|
readyButton: {
|
|
349
388
|
alignItems: "center",
|
|
350
389
|
borderRadius: 12,
|
|
@@ -417,7 +456,7 @@ function getProfilePopoverId(idPrefix) {
|
|
|
417
456
|
function getCpuDifficultyPopoverId(idPrefix) {
|
|
418
457
|
return `${idPrefix}-difficulty`;
|
|
419
458
|
}
|
|
420
|
-
function PlayerSetupPanel({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor = true, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton = true, profiles, selectedProfileId, takenProfileId, guestLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon = "face-man", cpuIcon = "robot" }) {
|
|
459
|
+
function PlayerSetupPanel({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor = true, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton = true, profiles, selectedProfileId, takenProfileId, guestLabel, nullLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon = "face-man", cpuIcon = "robot", previewValue, triggerStyle, readySurfaceColor, useSeatPickerAlign }) {
|
|
421
460
|
const ownHost = usePopoverHost();
|
|
422
461
|
const popover = host ?? ownHost;
|
|
423
462
|
const ownPopoverOpen = popover.openId?.startsWith(`${idPrefix}-`) ?? false;
|
|
@@ -426,17 +465,19 @@ function PlayerSetupPanel({ idPrefix, host, label, labelFontFamily, color, onCol
|
|
|
426
465
|
const showCpuDifficulty = !isHuman && cpuDifficulty !== void 0 && cpuDifficultyOptions !== void 0 && !!onCpuDifficultyChange;
|
|
427
466
|
const seatButton = showProfilePicker || showCpuDifficulty;
|
|
428
467
|
const selectedProfile = profiles?.find((p) => p.id === selectedProfileId) ?? null;
|
|
429
|
-
const
|
|
468
|
+
const drawn = previewValue ? previewValue(color) : color;
|
|
469
|
+
const colorSection = showColor ? { value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, caption: showProfilePicker && selectedProfile ? colorCaption : void 0, previewValue } : void 0;
|
|
430
470
|
const seatPickerId = showProfilePicker ? getProfilePopoverId(idPrefix) : getCpuDifficultyPopoverId(idPrefix);
|
|
431
471
|
const seatPickerSize = showProfilePicker ? (0, import_profile.getProfilePickerContentSize)(profiles.length, !!onManageProfiles, colorSection) : (0, import_profile.getOptionPickerContentSize)(cpuDifficultyOptions?.length ?? 0, colorSection);
|
|
432
|
-
const
|
|
472
|
+
const useSeatAlign = useSeatPickerAlign ?? useZoneClampedAlign;
|
|
473
|
+
const seatPickerAlign = useSeatAlign(seatButton && popover.openId === seatPickerId, seatPickerSize.width, seatPickerSize.height);
|
|
433
474
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: [styles4.panel, ownPopoverOpen && styles4.panelOpen], children: [
|
|
434
|
-
showProfilePicker ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_profile.ProfilePicker, { idPrefix, host: popover, profiles, selectedId: selectedProfileId ?? null, takenId: takenProfileId, color, dark, guestLabel: guestLabel ?? "GUEST", onSelect: (profile) => onProfileSelect?.(profile), onManage: onManageProfiles, colorSection, alignOverride: seatPickerAlign }) : showCpuDifficulty ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_profile.OptionPicker, { id: getCpuDifficultyPopoverId(idPrefix), host: popover, options: cpuDifficultyOptions, value: cpuDifficulty, onChange: onCpuDifficultyChange, color, dark, icon: cpuIcon, colorSection, alignOverride: seatPickerAlign }) : label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_paper3.Text, { variant: "labelSmall", style: { color, fontFamily: labelFontFamily }, children: label }),
|
|
475
|
+
showProfilePicker ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_profile.ProfilePicker, { idPrefix, host: popover, profiles, selectedId: selectedProfileId ?? null, takenId: takenProfileId, color: drawn, dark, guestLabel: guestLabel ?? "GUEST", nullLabel, onSelect: (profile) => onProfileSelect?.(profile), onManage: onManageProfiles, colorSection, alignOverride: seatPickerAlign, triggerStyle }) : showCpuDifficulty ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_profile.OptionPicker, { id: getCpuDifficultyPopoverId(idPrefix), host: popover, options: cpuDifficultyOptions, value: cpuDifficulty, onChange: onCpuDifficultyChange, color: drawn, dark, icon: cpuIcon, colorSection, alignOverride: seatPickerAlign, triggerStyle }) : label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_paper3.Text, { variant: "labelSmall", style: { color: drawn, fontFamily: labelFontFamily }, children: label }),
|
|
435
476
|
(!seatButton || secondPicker) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: [styles4.pickerRow, pickerRowPopoverOpen && styles4.pickerRowOpen], children: [
|
|
436
|
-
!seatButton && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InlineColorPicker, { id: getColorPopoverId(idPrefix), host: popover, value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, alignOverride: colorAlignOverride, rotation: colorRotation, dark, tag: isHuman ? selectedProfile?.tag : void 0, icon: isHuman ? humanIcon : cpuIcon }),
|
|
477
|
+
!seatButton && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InlineColorPicker, { id: getColorPopoverId(idPrefix), host: popover, value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, previewValue, alignOverride: colorAlignOverride, rotation: colorRotation, dark, tag: isHuman ? selectedProfile?.tag : void 0, icon: isHuman ? humanIcon : cpuIcon }),
|
|
437
478
|
secondPicker
|
|
438
479
|
] }),
|
|
439
|
-
isHuman && showReadyButton && onToggleReady && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ReadyButton, { color, ready: ready ?? false, onToggleReady })
|
|
480
|
+
isHuman && showReadyButton && onToggleReady && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ReadyButton, { color: drawn, ready: ready ?? false, onToggleReady, surfaceColor: readySurfaceColor, dark })
|
|
440
481
|
] });
|
|
441
482
|
}
|
|
442
483
|
var styles4 = import_react_native7.StyleSheet.create({
|
package/dist/lobby/index.mjs
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
getCpuDifficultyPopoverId,
|
|
7
7
|
getProfilePopoverId,
|
|
8
8
|
useZoneClampedAlign
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-CPNDNJJR.mjs";
|
|
10
|
+
import "../chunk-5ECU3722.mjs";
|
|
11
11
|
export {
|
|
12
12
|
PlayerSetupPanel,
|
|
13
13
|
ReadyButton,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tastic/hud",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Visual component kit for local-multiplayer React Native games: inline (non-modal) popovers, dropdowns, color pickers, gauges, ready buttons, and dialogs, built to stay scoped to one player's own zone on a shared screen",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
package/src/PlayerSetupPanel.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SeedColor } from '@rific/auto-paper'
|
|
2
2
|
import { getOptionPickerContentSize, getProfilePickerContentSize, OptionPicker, Profile, ProfilePicker, type ProfilePickerColorSection } from '@tastic/profile'
|
|
3
3
|
import { ReactNode } from 'react'
|
|
4
|
-
import { StyleSheet, View } from 'react-native'
|
|
4
|
+
import { type StyleProp, StyleSheet, View, type ViewStyle } from 'react-native'
|
|
5
5
|
import { Text } from 'react-native-paper'
|
|
6
6
|
|
|
7
7
|
import { InlineColorPicker } from './InlineColorPicker'
|
|
@@ -93,6 +93,10 @@ export interface PlayerSetupPanelProps<C extends string = string> {
|
|
|
93
93
|
// ProfilePicker's own doc for why it's never "Player"). Required whenever profiles is provided,
|
|
94
94
|
// since the trigger always needs some idle text.
|
|
95
95
|
guestLabel?: string
|
|
96
|
+
// The no-profile row's label in the seat button's dropdown (ProfilePicker's `nullLabel`), e.g.
|
|
97
|
+
// 'Guest' for a seat whose button reads 'GUEST' (guestLabel) until a profile is picked. Unset is
|
|
98
|
+
// ProfilePicker's own default.
|
|
99
|
+
nullLabel?: string
|
|
96
100
|
onProfileSelect?: (profile: Profile | null) => void
|
|
97
101
|
// Navigates to a profile-management screen - typically only ever wired up for one seat (a rotated
|
|
98
102
|
// second zone often can't host a working text keyboard).
|
|
@@ -109,6 +113,24 @@ export interface PlayerSetupPanelProps<C extends string = string> {
|
|
|
109
113
|
// than this component needing any opinion on what those states are.
|
|
110
114
|
humanIcon?: string
|
|
111
115
|
cpuIcon?: string
|
|
116
|
+
// How the seat's color is drawn, for a host that draws profile colors muted (Solitaire on its felt):
|
|
117
|
+
// the seat button's chip, its Color row and swatches (the color section's `previewValue`), the
|
|
118
|
+
// fallback swatch, the plain label and the Ready button all show previewValue(color), while `color`,
|
|
119
|
+
// `takenColor` and what onColorChange receives stay the saved values. Unset draws them as given.
|
|
120
|
+
previewValue?: (hex: string) => string
|
|
121
|
+
// Extra style for the seat button's trigger, e.g. a background behind its pill so it reads on a
|
|
122
|
+
// busy backdrop (ProfilePicker's and OptionPicker's `triggerStyle`).
|
|
123
|
+
triggerStyle?: StyleProp<ViewStyle>
|
|
124
|
+
// The Ready button's pill look over a busy backdrop (ReadyButton's `surfaceColor`): pass the
|
|
125
|
+
// theme's surface, as `triggerStyle` puts one behind the seat button. Unset keeps the outline.
|
|
126
|
+
readySurfaceColor?: string
|
|
127
|
+
// A placement of the host's own for the seat button's dropdown, in place of useZoneClampedAlign:
|
|
128
|
+
// called as a hook with whether the dropdown is open and the size it draws, and its result handed
|
|
129
|
+
// to the picker as `alignOverride` (for a screen turned by a fake landscape, whose button
|
|
130
|
+
// useAutoAlign would measure against the upright window). It replaces the zone clamp, so leave it
|
|
131
|
+
// unset for a panel inside a @tastic/split-screen zone. A hook: keep the same one for the panel's
|
|
132
|
+
// life, and remount the panel (a key) to change it.
|
|
133
|
+
useSeatPickerAlign?: (open: boolean, contentWidth: number, contentHeight: number) => AlignResult
|
|
112
134
|
}
|
|
113
135
|
|
|
114
136
|
// One panel per player slot in a local-multiplayer loadout/lobby screen: one seat button, an
|
|
@@ -125,7 +147,7 @@ export interface PlayerSetupPanelProps<C extends string = string> {
|
|
|
125
147
|
// Owns its own popover host shared by its own pickers unless a `host` is passed in to share with
|
|
126
148
|
// another panel (or a shared-controls row) instead - same convention as every popover-hosting
|
|
127
149
|
// component in this package.
|
|
128
|
-
export function PlayerSetupPanel<C extends string = string>({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor = true, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton = true, profiles, selectedProfileId, takenProfileId, guestLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon = 'face-man', cpuIcon = 'robot' }: PlayerSetupPanelProps<C>) {
|
|
150
|
+
export function PlayerSetupPanel<C extends string = string>({ idPrefix, host, label, labelFontFamily, color, onColorChange, swatches, takenColor, allowSwapTaken, colorCaption, showColor = true, colorAlignOverride, colorRotation, isHuman, secondPicker, secondPickerId, ready, onToggleReady, dark, showReadyButton = true, profiles, selectedProfileId, takenProfileId, guestLabel, nullLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon = 'face-man', cpuIcon = 'robot', previewValue, triggerStyle, readySurfaceColor, useSeatPickerAlign }: PlayerSetupPanelProps<C>) {
|
|
129
151
|
const ownHost = usePopoverHost()
|
|
130
152
|
const popover = host ?? ownHost
|
|
131
153
|
// Checking *this panel's own* ids, not just "is anything open on the host" - when `host` is
|
|
@@ -144,26 +166,29 @@ export function PlayerSetupPanel<C extends string = string>({ idPrefix, host, la
|
|
|
144
166
|
// Read live from the selected profile rather than snapshotted at selection time, since a caller
|
|
145
167
|
// typically has no other editing surface for it on this same screen.
|
|
146
168
|
const selectedProfile = profiles?.find((p) => p.id === selectedProfileId) ?? null
|
|
169
|
+
// The seat's color as it's drawn (see previewValue); `color` itself stays the saved one.
|
|
170
|
+
const drawn = previewValue ? previewValue(color) : color
|
|
147
171
|
|
|
148
|
-
const colorSection: ProfilePickerColorSection | undefined = showColor ? { value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, caption: showProfilePicker && selectedProfile ? colorCaption : undefined } : undefined
|
|
172
|
+
const colorSection: ProfilePickerColorSection | undefined = showColor ? { value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, caption: showProfilePicker && selectedProfile ? colorCaption : undefined, previewValue } : undefined
|
|
149
173
|
// The seat button's dropdown is placed here rather than by the caller: inside a
|
|
150
174
|
// @tastic/split-screen zone (2 Player) it has to stay in that player's half, which
|
|
151
|
-
// useZoneClampedAlign does, and outside one it's useAutoAlign's own placement
|
|
152
|
-
// section and rows the picker draws. Rotation 0, the same
|
|
153
|
-
// dropdowns this button replaced were all placed with.
|
|
175
|
+
// useZoneClampedAlign does, and outside one it's useAutoAlign's own placement (or the host's own,
|
|
176
|
+
// useSeatPickerAlign). Sized from the same section and rows the picker draws. Rotation 0, the same
|
|
177
|
+
// as the profile, color and difficulty dropdowns this button replaced were all placed with.
|
|
154
178
|
const seatPickerId = showProfilePicker ? getProfilePopoverId(idPrefix) : getCpuDifficultyPopoverId(idPrefix)
|
|
155
179
|
const seatPickerSize = showProfilePicker ? getProfilePickerContentSize(profiles!.length, !!onManageProfiles, colorSection) : getOptionPickerContentSize(cpuDifficultyOptions?.length ?? 0, colorSection)
|
|
156
|
-
const
|
|
180
|
+
const useSeatAlign = useSeatPickerAlign ?? useZoneClampedAlign
|
|
181
|
+
const seatPickerAlign = useSeatAlign(seatButton && popover.openId === seatPickerId, seatPickerSize.width, seatPickerSize.height)
|
|
157
182
|
|
|
158
183
|
return (
|
|
159
184
|
<View style={[styles.panel, ownPopoverOpen && styles.panelOpen]}>
|
|
160
185
|
{showProfilePicker ? (
|
|
161
|
-
<ProfilePicker idPrefix={idPrefix} host={popover} profiles={profiles!} selectedId={selectedProfileId ?? null} takenId={takenProfileId} color={
|
|
186
|
+
<ProfilePicker idPrefix={idPrefix} host={popover} profiles={profiles!} selectedId={selectedProfileId ?? null} takenId={takenProfileId} color={drawn} dark={dark} guestLabel={guestLabel ?? 'GUEST'} nullLabel={nullLabel} onSelect={(profile: Profile | null) => onProfileSelect?.(profile)} onManage={onManageProfiles} colorSection={colorSection} alignOverride={seatPickerAlign} triggerStyle={triggerStyle} />
|
|
162
187
|
) : showCpuDifficulty ? (
|
|
163
|
-
<OptionPicker id={getCpuDifficultyPopoverId(idPrefix)} host={popover} options={cpuDifficultyOptions!} value={cpuDifficulty!} onChange={onCpuDifficultyChange!} color={
|
|
188
|
+
<OptionPicker id={getCpuDifficultyPopoverId(idPrefix)} host={popover} options={cpuDifficultyOptions!} value={cpuDifficulty!} onChange={onCpuDifficultyChange!} color={drawn} dark={dark} icon={cpuIcon} colorSection={colorSection} alignOverride={seatPickerAlign} triggerStyle={triggerStyle} />
|
|
164
189
|
) : (
|
|
165
190
|
label && (
|
|
166
|
-
<Text variant='labelSmall' style={{ color, fontFamily: labelFontFamily }}>
|
|
191
|
+
<Text variant='labelSmall' style={{ color: drawn, fontFamily: labelFontFamily }}>
|
|
167
192
|
{label}
|
|
168
193
|
</Text>
|
|
169
194
|
)
|
|
@@ -174,13 +199,13 @@ export function PlayerSetupPanel<C extends string = string>({ idPrefix, host, la
|
|
|
174
199
|
{/* The fallback swatch, for a seat with no button: a human slot shows the selected
|
|
175
200
|
profile's own tag when it has one, falling back to humanIcon; a non-human slot always
|
|
176
201
|
falls back to cpuIcon. */}
|
|
177
|
-
{!seatButton && <InlineColorPicker id={getColorPopoverId(idPrefix)} host={popover} value={color} onChange={onColorChange} swatches={swatches} takenValue={takenColor} allowSwapTaken={allowSwapTaken} alignOverride={colorAlignOverride} rotation={colorRotation} dark={dark} tag={isHuman ? selectedProfile?.tag : undefined} icon={isHuman ? humanIcon : cpuIcon} />}
|
|
202
|
+
{!seatButton && <InlineColorPicker id={getColorPopoverId(idPrefix)} host={popover} value={color} onChange={onColorChange} swatches={swatches} takenValue={takenColor} allowSwapTaken={allowSwapTaken} previewValue={previewValue} alignOverride={colorAlignOverride} rotation={colorRotation} dark={dark} tag={isHuman ? selectedProfile?.tag : undefined} icon={isHuman ? humanIcon : cpuIcon} />}
|
|
178
203
|
|
|
179
204
|
{secondPicker}
|
|
180
205
|
</View>
|
|
181
206
|
)}
|
|
182
207
|
|
|
183
|
-
{isHuman && showReadyButton && onToggleReady && <ReadyButton color={
|
|
208
|
+
{isHuman && showReadyButton && onToggleReady && <ReadyButton color={drawn} ready={ready ?? false} onToggleReady={onToggleReady} surfaceColor={readySurfaceColor} dark={dark} />}
|
|
184
209
|
</View>
|
|
185
210
|
)
|
|
186
211
|
}
|
package/src/PopoverBody.tsx
CHANGED
|
@@ -43,11 +43,20 @@ interface Props {
|
|
|
43
43
|
// Rendered inline as an absolutely-positioned sibling of its own trigger (never via Portal), so it
|
|
44
44
|
// inherits any rotation transform the trigger's zone applies - a Portal-based popover renders at
|
|
45
45
|
// the app root, outside that transform, and would end up upside-down relative to its own trigger
|
|
46
|
-
// once a face-to-face zone gets flipped 180°.
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
46
|
+
// once a face-to-face zone gets flipped 180°. Placed against the trigger's own wrapper rather than a
|
|
47
|
+
// measured pixel rect, so no onLayout/measurement plumbing is needed here and it resolves correctly
|
|
48
|
+
// regardless of how deep the trigger sits in the tree - the caller (useAutoAlign) is the one that
|
|
49
|
+
// actually measures, to decide which side to grow toward in the first place.
|
|
50
|
+
//
|
|
51
|
+
// No percentage insets (2026-11-07): it used to sit at `top:'100%'`/`bottom:'100%'` of the wrapper,
|
|
52
|
+
// and React Native's default Yoga errata (YGErrataAll, its "compatibility" layout conformance)
|
|
53
|
+
// includes AbsolutePercentAgainstInnerSize, which resolves an absolute child's percentage insets
|
|
54
|
+
// against the space its containing view was offered rather than its real size. In a wrapping row
|
|
55
|
+
// (a loadout's options on a narrow phone) that space is the whole multi-line row, so a menu in the
|
|
56
|
+
// first line opened a full row below its trigger. Plain insets use the view's measured size, so the
|
|
57
|
+
// box now hangs off a zero-height strip pinned to the wrapper's bottom edge (`bottom: 0`) or top edge
|
|
58
|
+
// (`top: 0`), spanning its width, and sits at the strip's `top: 0` or `bottom: 0`. The web never had
|
|
59
|
+
// the errata and lands exactly where it did.
|
|
51
60
|
export function PopoverBody({ visible, children, align = 'center', verticalAlign = 'below', caretColor, caretBorderColor, caretBorderWidth = 1, triggerSize = 0 }: Props) {
|
|
52
61
|
if (!visible) return null
|
|
53
62
|
|
|
@@ -73,17 +82,19 @@ export function PopoverBody({ visible, children, align = 'center', verticalAlign
|
|
|
73
82
|
const caretEdge = (size: number): ViewStyle => (above ? { bottom: -size + CARET_DIP } : { top: -size + CARET_DIP })
|
|
74
83
|
|
|
75
84
|
return (
|
|
76
|
-
<View style={[styles.
|
|
77
|
-
{
|
|
78
|
-
|
|
85
|
+
<View style={[styles.edge, above ? styles.edgeTop : styles.edgeBottom]}>
|
|
86
|
+
<View style={[styles.content, alignStyle, verticalStyle]}>
|
|
87
|
+
{children}
|
|
88
|
+
{/* Painted after (on top of) the box above, dipping into its edge - see CARET_DIP - so it
|
|
79
89
|
reads as one continuous outline flowing from the trigger into the box, not a separate chip
|
|
80
90
|
butted up against it. */}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
{caretColor && (
|
|
92
|
+
<>
|
|
93
|
+
<View style={[styles.caret, caretOffset(ringSize), caretEdge(ringSize), { [caretFill]: caretBorderColor ?? caretColor, [caretWidthProp]: ringSize, borderLeftWidth: ringSize, borderRightWidth: ringSize }]} />
|
|
94
|
+
<View style={[styles.caret, caretOffset(CARET_SIZE), caretEdge(CARET_SIZE - CARET_RING_OFFSET), { [caretFill]: caretColor, [caretWidthProp]: CARET_SIZE, borderLeftWidth: CARET_SIZE, borderRightWidth: CARET_SIZE }]} />
|
|
95
|
+
</>
|
|
96
|
+
)}
|
|
97
|
+
</View>
|
|
87
98
|
</View>
|
|
88
99
|
)
|
|
89
100
|
}
|
|
@@ -105,13 +116,15 @@ const styles = StyleSheet.create({
|
|
|
105
116
|
position: 'absolute',
|
|
106
117
|
zIndex: 50
|
|
107
118
|
},
|
|
119
|
+
// The strip's bottom edge, which is the trigger's top: the box grows up from it.
|
|
108
120
|
contentAbove: {
|
|
109
|
-
bottom:
|
|
121
|
+
bottom: 0,
|
|
110
122
|
marginBottom: 8
|
|
111
123
|
},
|
|
124
|
+
// The strip's top edge, which is the trigger's bottom: the box grows down from it.
|
|
112
125
|
contentBelow: {
|
|
113
126
|
marginTop: 8,
|
|
114
|
-
top:
|
|
127
|
+
top: 0
|
|
115
128
|
},
|
|
116
129
|
// Stretched to the anchor's own (trigger) width, with alignItems centering the actual (usually
|
|
117
130
|
// much wider) popover box inside via plain flexbox - not `left:'50%'` plus a percentage
|
|
@@ -127,5 +140,21 @@ const styles = StyleSheet.create({
|
|
|
127
140
|
},
|
|
128
141
|
contentRight: {
|
|
129
142
|
right: 0
|
|
143
|
+
},
|
|
144
|
+
// The zero-height strip the box hangs off, spanning the trigger's wrapper (see PopoverBody's
|
|
145
|
+
// comment for why it isn't a percentage inset). Its zIndex matches the box's, so on the web, where
|
|
146
|
+
// every positioned view is its own stacking context, the box still paints over later siblings.
|
|
147
|
+
edge: {
|
|
148
|
+
height: 0,
|
|
149
|
+
left: 0,
|
|
150
|
+
position: 'absolute',
|
|
151
|
+
right: 0,
|
|
152
|
+
zIndex: 50
|
|
153
|
+
},
|
|
154
|
+
edgeBottom: {
|
|
155
|
+
bottom: 0
|
|
156
|
+
},
|
|
157
|
+
edgeTop: {
|
|
158
|
+
top: 0
|
|
130
159
|
}
|
|
131
160
|
})
|
package/src/ReadyButton.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getTintTextColor } from '@rific/auto-paper'
|
|
1
2
|
import { TouchableRipple } from '@rific/feedback-press'
|
|
2
3
|
import { StyleProp, StyleSheet, TextStyle, ViewStyle } from 'react-native'
|
|
3
4
|
import { Text } from 'react-native-paper'
|
|
@@ -14,27 +15,65 @@ interface Props {
|
|
|
14
15
|
// unmounting.
|
|
15
16
|
style?: StyleProp<ViewStyle>
|
|
16
17
|
// Defaults to the system monospace font - pass your own game's registered font to match its UI.
|
|
18
|
+
// The pill look (`surfaceColor`) keeps the theme's own font unless this is passed.
|
|
17
19
|
labelFontFamily?: string
|
|
20
|
+
// For a loadout drawn over a pack's backdrop (Solitaire on its felt), where the outline and label
|
|
21
|
+
// in the seat's color read dim: Ready is then a pill on this color (the theme's surface), the size
|
|
22
|
+
// and style of the seat buttons beside it (@tastic/profile's chip pill), its label black or white
|
|
23
|
+
// (`dark`), and once ready it fills with `color` and its label turns to that color's own ink.
|
|
24
|
+
// Unset keeps the outline on a plain black or white screen.
|
|
25
|
+
surfaceColor?: string
|
|
26
|
+
// Only read with `surfaceColor`: the not-ready label's white (dark) or black, as the seat buttons'.
|
|
27
|
+
dark?: boolean
|
|
18
28
|
}
|
|
19
29
|
|
|
30
|
+
// The pill look's height and label: @tastic/profile's chip pill (a 32pt chip in 6pt of padding,
|
|
31
|
+
// a 13pt bold label spaced 1pt), so Ready lines up with the seat and option buttons around it.
|
|
32
|
+
const PILL_HEIGHT = 44
|
|
33
|
+
|
|
20
34
|
// Standalone toggle so it can render either embedded in a per-player panel or centered on its own
|
|
21
35
|
// below a shared row - e.g. a vs-CPU mode with only one human player needs just one Ready toggle,
|
|
22
36
|
// not one tucked under each slot.
|
|
23
|
-
export function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily =
|
|
37
|
+
export function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily, surfaceColor, dark = false }: Props) {
|
|
38
|
+
const label = ready ? 'READY ✓' : 'READY?'
|
|
39
|
+
|
|
40
|
+
if (surfaceColor) {
|
|
41
|
+
const pillStyle = [styles.pill, { backgroundColor: ready ? color : surfaceColor }, style]
|
|
42
|
+
const pillLabelColor = ready ? getTintTextColor(color, color, 1) : dark ? '#FFFFFF' : '#000000'
|
|
43
|
+
return (
|
|
44
|
+
<TouchableRipple onPress={onToggleReady} borderless style={pillStyle} accessibilityRole='button' accessibilityLabel={label}>
|
|
45
|
+
<Text style={[styles.pillLabel, { color: pillLabelColor }, labelFontFamily ? { fontFamily: labelFontFamily } : null]}>{label}</Text>
|
|
46
|
+
</TouchableRipple>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
24
50
|
const readyButtonStyle = [styles.readyButton, { borderColor: color }, ready && { backgroundColor: color }, style]
|
|
25
|
-
const labelTextStyle: TextStyle = { fontFamily: labelFontFamily, fontWeight: 'bold' }
|
|
51
|
+
const labelTextStyle: TextStyle = { fontFamily: labelFontFamily ?? MONO_FONT, fontWeight: 'bold' }
|
|
26
52
|
const labelColorStyle = { color: ready ? '#000000' : color }
|
|
27
53
|
|
|
28
54
|
return (
|
|
29
55
|
<TouchableRipple onPress={onToggleReady} borderless style={readyButtonStyle}>
|
|
30
56
|
<Text variant='labelLarge' style={[labelTextStyle, labelColorStyle]}>
|
|
31
|
-
{
|
|
57
|
+
{label}
|
|
32
58
|
</Text>
|
|
33
59
|
</TouchableRipple>
|
|
34
60
|
)
|
|
35
61
|
}
|
|
36
62
|
|
|
37
63
|
const styles = StyleSheet.create({
|
|
64
|
+
pill: {
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
borderRadius: PILL_HEIGHT / 2,
|
|
67
|
+
height: PILL_HEIGHT,
|
|
68
|
+
justifyContent: 'center',
|
|
69
|
+
minWidth: 120,
|
|
70
|
+
paddingHorizontal: 20
|
|
71
|
+
},
|
|
72
|
+
pillLabel: {
|
|
73
|
+
fontSize: 13,
|
|
74
|
+
fontWeight: '700',
|
|
75
|
+
letterSpacing: 1
|
|
76
|
+
},
|
|
38
77
|
readyButton: {
|
|
39
78
|
alignItems: 'center',
|
|
40
79
|
borderRadius: 12,
|