@tastic/hud 0.25.1 → 0.27.1
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 +47 -11
- package/dist/chrome/index.d.mts +5 -23
- package/dist/chrome/index.d.ts +5 -23
- package/dist/chrome/index.mjs +9 -7
- package/dist/chunk-B2DSHZJT.mjs +177 -0
- package/dist/chunk-FOJLQMKA.mjs +315 -0
- package/dist/{chunk-AJD4FMG5.mjs → chunk-JBE7IQC5.mjs} +26 -336
- package/dist/index-1fnoSjO0.d.ts +100 -0
- package/dist/index-Bhu3I6FN.d.mts +100 -0
- package/dist/index.d.mts +12 -97
- package/dist/index.d.ts +12 -97
- package/dist/index.js +8 -6
- package/dist/index.mjs +26 -176
- package/dist/lobby/index.d.mts +7 -0
- package/dist/lobby/index.d.ts +7 -0
- package/dist/lobby/index.js +513 -0
- package/dist/lobby/index.mjs +19 -0
- package/dist/usePopoverHost-T8QWb2_A.d.mts +25 -0
- package/dist/usePopoverHost-T8QWb2_A.d.ts +25 -0
- package/package.json +11 -4
- package/src/PlayerSetupPanel.tsx +34 -12
- package/src/SectionedDropdown.tsx +4 -11
- package/src/lobby/index.ts +13 -0
- package/src/menuOption.ts +14 -0
package/README.md
CHANGED
|
@@ -51,6 +51,15 @@ corner of the screen.
|
|
|
51
51
|
Ported from five apps' own near-identical `PlayerSetupPanel.tsx`/`LobbyPlayerPanel.tsx`
|
|
52
52
|
(AirHockey, BoxHockey, Pong, LightCycles, Snake), which had all independently converged on this
|
|
53
53
|
exact skeleton. See "The secondPicker slot" below before wiring up that one prop.
|
|
54
|
+
Four optional props fit it to a host that draws on a backdrop (a felt) with muted profile colors,
|
|
55
|
+
each changing nothing when left unset: `nullLabel` (the no-profile row's label in the seat button's
|
|
56
|
+
dropdown, e.g. `'Guest'` beside a `'GUEST'` `guestLabel`), `previewValue` (how the seat's color is
|
|
57
|
+
drawn: the button's chip, its Color row and swatches, the fallback swatch, the plain label and the
|
|
58
|
+
Ready button, while `color` and what `onColorChange` receives stay the saved values), `triggerStyle`
|
|
59
|
+
(the seat button's trigger, e.g. a surface behind its pill) and `useSeatPickerAlign` (a placement
|
|
60
|
+
hook of the host's own for the seat button's dropdown, in place of `useZoneClampedAlign`, for a
|
|
61
|
+
screen turned by a fake landscape; leave it unset inside a split-screen zone, and keep the same hook
|
|
62
|
+
for the panel's life).
|
|
54
63
|
- **`CornerActionButtons`**: Back (top-left) + Settings (top-right) icon buttons fixed at a
|
|
55
64
|
screen's rotated corners. This isn't just a loadout/lobby-screen convention - it's the right
|
|
56
65
|
default for *any* screen with top-corner icon buttons, home screens included: every app in the
|
|
@@ -662,8 +671,9 @@ their props types:
|
|
|
662
671
|
|
|
663
672
|
The popovers are here for `@tastic/profile`: from 0.16 its `ProfilePicker`, `ProfilesScreen` and the rest
|
|
664
673
|
import them (and `ConfirmDialog`) from this entry instead of the main barrel, so a Skia-free app can use
|
|
665
|
-
them. That's why `@tastic/profile` 0.16 needs hud 0.23.0 or later. `useZoneClampedAlign` (it needs `@tastic/split-screen`)
|
|
666
|
-
|
|
674
|
+
them. That's why `@tastic/profile` 0.16 needs hud 0.23.0 or later. `useZoneClampedAlign` (it needs `@tastic/split-screen`) and
|
|
675
|
+
`PlayerSetupPanel` (it renders `@tastic/profile`'s pickers) are in `@tastic/hud/lobby` (below), and
|
|
676
|
+
`SectionedDropdown` (its trigger gauge loads Skia) stays main-entry only.
|
|
667
677
|
|
|
668
678
|
Each is the same component the main entry exports and is documented above. Only the import path changes:
|
|
669
679
|
|
|
@@ -683,6 +693,31 @@ type-checks hud's source and needs it installed. `AchievementUnlockList` isn't h
|
|
|
683
693
|
Metro resolves both entries to the same source files, so an app that imports some components from here and
|
|
684
694
|
others from `@tastic/hud` still bundles each module once.
|
|
685
695
|
|
|
696
|
+
## A loadout without Skia (`@tastic/hud/lobby`)
|
|
697
|
+
|
|
698
|
+
The pieces a two-seat loadout or lobby screen is built from, from a standalone entry that never touches the
|
|
699
|
+
main barrel (whose `TriggerGaugeHost` and `loadSkiaWeb` reach Skia). It's for an app that has `@tastic/profile`
|
|
700
|
+
and `@tastic/split-screen` but no Skia: `@tastic/shell` loads its loadout through here, so a pack with no Skia
|
|
701
|
+
(CardTastic) can install the shell. It exports, with their props types:
|
|
702
|
+
|
|
703
|
+
- `PlayerSetupPanel` (and `getColorPopoverId`, `getProfilePopoverId`, `getCpuDifficultyPopoverId`)
|
|
704
|
+
- `ReadyButton`, `SharedActionBand`, `useZoneClampedAlign`
|
|
705
|
+
- the `MenuOption` type (the shape a CPU's difficulty menu is built from)
|
|
706
|
+
|
|
707
|
+
```tsx
|
|
708
|
+
import { PlayerSetupPanel, ReadyButton, SharedActionBand } from '@tastic/hud/lobby'
|
|
709
|
+
import { PressAwayOverlay, usePopoverHost } from '@tastic/hud/chrome'
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
It pulls in `react`, `react-native`, `react-native-paper`, `react-native-reanimated`,
|
|
713
|
+
`react-native-safe-area-context`, `@rific/auto-paper`, `@rific/feedback-press`, `@tastic/core`,
|
|
714
|
+
`@tastic/profile` and `@tastic/split-screen`, none of which loads Skia.
|
|
715
|
+
`SectionedDropdown` and `ControlSchemePicker` stay main-entry only: their trigger gauge loads Skia. A test
|
|
716
|
+
(`src/__tests__/lobbyImports.test.ts`) walks the import graph from `src/lobby/index.ts` and fails if anything
|
|
717
|
+
it reaches imports another package, reaches the main barrel or a Skia module, or has a `.web` twin, and if the
|
|
718
|
+
installed `@tastic/profile` or `@tastic/split-screen` imports Skia or the bare `@tastic/hud`. Each piece is
|
|
719
|
+
the same one the main entry exports, so Metro bundles it once whichever entry an app imports it from.
|
|
720
|
+
|
|
686
721
|
## Skia on web (`@tastic/hud/skia`)
|
|
687
722
|
|
|
688
723
|
On web, Skia draws through CanvasKit, a WASM file fetched at runtime. `@shopify/react-native-skia` builds
|
|
@@ -764,8 +799,9 @@ when no rotation applies.
|
|
|
764
799
|
|
|
765
800
|
None of these are bundled, so use whatever versions your app already has. Six are marked `optional` in
|
|
766
801
|
`peerDependenciesMeta` so a light app can install hud without the ones it doesn't use: `./guide` needs
|
|
767
|
-
none of the six,
|
|
768
|
-
`@tastic/achievements` to type-check, see above)
|
|
802
|
+
none of the six, `./chrome` needs only `@tastic/core` and `@rific/updater` (plus
|
|
803
|
+
`@tastic/achievements` to type-check, see above), and `./lobby` needs `@tastic/core`, `@tastic/profile` and
|
|
804
|
+
`@tastic/split-screen` but never Skia. **npm does not install optional peers for you**, so an app that imports the
|
|
769
805
|
main `@tastic/hud` entry must list every peer that entry loads in its own `dependencies`, including
|
|
770
806
|
the four optional ones marked "main entry" below. Without them, Metro fails to bundle with "Unable to
|
|
771
807
|
resolve module".
|
|
@@ -773,15 +809,15 @@ resolve module".
|
|
|
773
809
|
| Peer | Floor | Needed by |
|
|
774
810
|
| --- | --- | --- |
|
|
775
811
|
| `react`, `react-native` | >=19.0.0, >=0.76.0 | every entry |
|
|
776
|
-
| `react-native-paper` | >=5.0.0 | main entry, `./guide`, `./chrome` |
|
|
812
|
+
| `react-native-paper` | >=5.0.0 | main entry, `./guide`, `./chrome`, `./lobby` |
|
|
777
813
|
| `react-native-reanimated` | >=3.0.0 | main entry (`StaggeredWord`), `./guide`, `./chrome` (`StaggeredWord`) |
|
|
778
|
-
| `@rific/auto-paper` | >=0.12.2 | main entry (`BaseSettingsDialog` needs the nested `Portal.Host` first shipped in 0.12.2; `OverlayCard` uses `BlurView` and `useBlur`, and `BaseSettingsDialog`'s Blur row uses `useBlurModule` and `useThemeSettings`, all in 0.12.2), `./guide`, `./chrome` |
|
|
779
|
-
| `@rific/feedback-press` | >=0.10.2 | main entry (`useSoundSettings` first shipped in 0.10.2), `./guide`, `./chrome` |
|
|
814
|
+
| `@rific/auto-paper` | >=0.12.2 | main entry (`BaseSettingsDialog` needs the nested `Portal.Host` first shipped in 0.12.2; `OverlayCard` uses `BlurView` and `useBlur`, and `BaseSettingsDialog`'s Blur row uses `useBlurModule` and `useThemeSettings`, all in 0.12.2), `./guide`, `./chrome`, `./lobby` |
|
|
815
|
+
| `@rific/feedback-press` | >=0.10.2 | main entry (`useSoundSettings` first shipped in 0.10.2), `./guide`, `./chrome`, `./lobby` |
|
|
780
816
|
| `@rific/core` | >=0.4.0 | main entry and `./chrome`: `BaseSettingsDialog`'s Keep Awake row (`useKeepAwakeSettings`, `useExpoKeepAwake`, first shipped in 0.4.0) |
|
|
781
|
-
| `react-native-safe-area-context` | >=5.0.0 | main entry (`useZoneClampedAlign`), `./chrome` (`RotatedFrame`, `BaseSettingsDialog`) |
|
|
782
|
-
| `@tastic/core` | >=0.12.0, optional | main entry: `useRotation()` and most dialogs; `RotatedFrame` and `BaseSettingsDialog` need `FakeLandscapeView`'s `rotation`/`passThrough`, first shipped in 0.12.0; `./chrome` (the same dialogs, and `InlineColorPicker`) |
|
|
817
|
+
| `react-native-safe-area-context` | >=5.0.0 | main entry and `./lobby` (`useZoneClampedAlign`), `./chrome` (`RotatedFrame`, `BaseSettingsDialog`) |
|
|
818
|
+
| `@tastic/core` | >=0.12.0, optional | main entry: `useRotation()` and most dialogs; `RotatedFrame` and `BaseSettingsDialog` need `FakeLandscapeView`'s `rotation`/`passThrough`, first shipped in 0.12.0; `./chrome` (the same dialogs, and `InlineColorPicker`); `./lobby` (`PlayerSetupPanel`'s color picker) |
|
|
783
819
|
| `@rific/updater` | >=0.4.0, optional | main entry and `./chrome`: `BaseSettingsDialog`, `UpdateDialog` |
|
|
784
|
-
| `@tastic/profile` | >=0.4.0, optional | main entry: `PlayerSetupPanel`, `AchievementUnlockList` (`ProfileChip`) |
|
|
785
|
-
| `@tastic/split-screen` | >=0.5.0, optional | main entry
|
|
820
|
+
| `@tastic/profile` | >=0.4.0, optional | main entry: `PlayerSetupPanel`, `AchievementUnlockList` (`ProfileChip`); `./lobby` (`PlayerSetupPanel`) |
|
|
821
|
+
| `@tastic/split-screen` | >=0.5.0, optional | main entry and `./lobby`: `useZoneClampedAlign` |
|
|
786
822
|
| `@shopify/react-native-skia` | >=2.6.0, optional | `TriggerGaugeHost`'s gauge (loaded when one mounts) and `./skia` |
|
|
787
823
|
| `@tastic/achievements` | >=0.2.0, optional | `AchievementCatalogSection`, `AchievementUnlockList`, type-only (`AchievementCatalogRow`, first exported in 0.2.0; `AchievementTier`); `./chrome` needs it installed only to type-check |
|
package/dist/chrome/index.d.mts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode, RefObject
|
|
2
|
+
import { ReactNode, RefObject } from 'react';
|
|
3
3
|
import { AchievementCatalogRow } from '@tastic/achievements';
|
|
4
4
|
import { ViewRotation } from '@tastic/core';
|
|
5
|
-
import { Insets, StyleProp, ViewStyle,
|
|
5
|
+
import { Insets, StyleProp, ViewStyle, LayoutChangeEvent, TextStyle } from 'react-native';
|
|
6
6
|
import { SeedColor } from '@rific/auto-paper';
|
|
7
|
+
import { P as PopoverHost, A as AlignResult, a as PopoverRotation, V as ViewInstance } from '../usePopoverHost-T8QWb2_A.mjs';
|
|
8
|
+
export { b as PopoverAlign, c as PopoverVerticalAlign, u as useAutoAlign, d as usePopoverHost } from '../usePopoverHost-T8QWb2_A.mjs';
|
|
7
9
|
import { ButtonProps } from '@rific/feedback-press';
|
|
8
10
|
|
|
9
11
|
interface Props$a {
|
|
@@ -138,26 +140,6 @@ declare function DialogHeader({ icon, title, color, compact, style }: DialogHead
|
|
|
138
140
|
|
|
139
141
|
declare const MONO_FONT: string;
|
|
140
142
|
|
|
141
|
-
type PopoverAlign = 'left' | 'right' | 'center';
|
|
142
|
-
type PopoverVerticalAlign = 'below' | 'above';
|
|
143
|
-
type PopoverRotation = ViewRotation;
|
|
144
|
-
interface AlignResult {
|
|
145
|
-
align: PopoverAlign;
|
|
146
|
-
verticalAlign: PopoverVerticalAlign;
|
|
147
|
-
maxHeight: number;
|
|
148
|
-
measured: boolean;
|
|
149
|
-
triggerRef: RefObject<ViewInstance | null>;
|
|
150
|
-
}
|
|
151
|
-
type ViewInstance = ComponentRef<typeof View>;
|
|
152
|
-
declare function useAutoAlign(open: boolean, contentWidth: number, contentHeight: number, rotation?: PopoverRotation, bounds?: RefObject<ViewInstance | null>): AlignResult;
|
|
153
|
-
|
|
154
|
-
interface PopoverHost {
|
|
155
|
-
openId: string | null;
|
|
156
|
-
toggle: (id: string) => void;
|
|
157
|
-
close: () => void;
|
|
158
|
-
}
|
|
159
|
-
declare function usePopoverHost(): PopoverHost;
|
|
160
|
-
|
|
161
143
|
declare function getInlineColorPickerContentSize(swatchCount: number, windowWidth: number, columns?: number): {
|
|
162
144
|
width: number;
|
|
163
145
|
height: number;
|
|
@@ -354,4 +336,4 @@ interface WellColors {
|
|
|
354
336
|
}
|
|
355
337
|
declare function useWellColors(): WellColors;
|
|
356
338
|
|
|
357
|
-
export { AchievementCatalogSection, AchievementRow, ActivityStatSection,
|
|
339
|
+
export { AchievementCatalogSection, AchievementRow, ActivityStatSection, AlignResult, BaseSettingsDialog, type BaseSettingsDialogProps, BaseStatsScreen, COMPACT_DIALOG_HEIGHT, ConfirmDialog, type ConfirmDialogProps, ContentGutter, CornerActionButtons, DialogHeader, type DialogHeaderProps, InlineColorPicker, type InlineColorPickerSwatchPlace, type InlineColorPickerSwatchRenderer, LOCKED_BADGE_COLOR, MONO_FONT, OverlayBackdrop, type OverlayBackdropProps, OverlayCard, type OverlayCardProps, type OverlayCardThemeColors, PopoverBody, PopoverHost, PopoverRotation, PressAwayOverlay, RotatedFrame, type RotatedFrameProps, SecondaryButton, type SecondaryButtonProps, StaggeredWord, type StaggeredWordProps, StatRow, StatSection, UpdateDialog, type UpdateDialogProps, ViewInstance, WELL_SHADOW, type WellColors, getInlineColorPickerContentSize, getStaggeredWordDuration, isCompactDialogHeight, overlayActionStyles, overlayStyles, useCompactDialog, useOverlayCardColors, useWellColors };
|
package/dist/chrome/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode, RefObject
|
|
2
|
+
import { ReactNode, RefObject } from 'react';
|
|
3
3
|
import { AchievementCatalogRow } from '@tastic/achievements';
|
|
4
4
|
import { ViewRotation } from '@tastic/core';
|
|
5
|
-
import { Insets, StyleProp, ViewStyle,
|
|
5
|
+
import { Insets, StyleProp, ViewStyle, LayoutChangeEvent, TextStyle } from 'react-native';
|
|
6
6
|
import { SeedColor } from '@rific/auto-paper';
|
|
7
|
+
import { P as PopoverHost, A as AlignResult, a as PopoverRotation, V as ViewInstance } from '../usePopoverHost-T8QWb2_A.js';
|
|
8
|
+
export { b as PopoverAlign, c as PopoverVerticalAlign, u as useAutoAlign, d as usePopoverHost } from '../usePopoverHost-T8QWb2_A.js';
|
|
7
9
|
import { ButtonProps } from '@rific/feedback-press';
|
|
8
10
|
|
|
9
11
|
interface Props$a {
|
|
@@ -138,26 +140,6 @@ declare function DialogHeader({ icon, title, color, compact, style }: DialogHead
|
|
|
138
140
|
|
|
139
141
|
declare const MONO_FONT: string;
|
|
140
142
|
|
|
141
|
-
type PopoverAlign = 'left' | 'right' | 'center';
|
|
142
|
-
type PopoverVerticalAlign = 'below' | 'above';
|
|
143
|
-
type PopoverRotation = ViewRotation;
|
|
144
|
-
interface AlignResult {
|
|
145
|
-
align: PopoverAlign;
|
|
146
|
-
verticalAlign: PopoverVerticalAlign;
|
|
147
|
-
maxHeight: number;
|
|
148
|
-
measured: boolean;
|
|
149
|
-
triggerRef: RefObject<ViewInstance | null>;
|
|
150
|
-
}
|
|
151
|
-
type ViewInstance = ComponentRef<typeof View>;
|
|
152
|
-
declare function useAutoAlign(open: boolean, contentWidth: number, contentHeight: number, rotation?: PopoverRotation, bounds?: RefObject<ViewInstance | null>): AlignResult;
|
|
153
|
-
|
|
154
|
-
interface PopoverHost {
|
|
155
|
-
openId: string | null;
|
|
156
|
-
toggle: (id: string) => void;
|
|
157
|
-
close: () => void;
|
|
158
|
-
}
|
|
159
|
-
declare function usePopoverHost(): PopoverHost;
|
|
160
|
-
|
|
161
143
|
declare function getInlineColorPickerContentSize(swatchCount: number, windowWidth: number, columns?: number): {
|
|
162
144
|
width: number;
|
|
163
145
|
height: number;
|
|
@@ -354,4 +336,4 @@ interface WellColors {
|
|
|
354
336
|
}
|
|
355
337
|
declare function useWellColors(): WellColors;
|
|
356
338
|
|
|
357
|
-
export { AchievementCatalogSection, AchievementRow, ActivityStatSection,
|
|
339
|
+
export { AchievementCatalogSection, AchievementRow, ActivityStatSection, AlignResult, BaseSettingsDialog, type BaseSettingsDialogProps, BaseStatsScreen, COMPACT_DIALOG_HEIGHT, ConfirmDialog, type ConfirmDialogProps, ContentGutter, CornerActionButtons, DialogHeader, type DialogHeaderProps, InlineColorPicker, type InlineColorPickerSwatchPlace, type InlineColorPickerSwatchRenderer, LOCKED_BADGE_COLOR, MONO_FONT, OverlayBackdrop, type OverlayBackdropProps, OverlayCard, type OverlayCardProps, type OverlayCardThemeColors, PopoverBody, PopoverHost, PopoverRotation, PressAwayOverlay, RotatedFrame, type RotatedFrameProps, SecondaryButton, type SecondaryButtonProps, StaggeredWord, type StaggeredWordProps, StatRow, StatSection, UpdateDialog, type UpdateDialogProps, ViewInstance, WELL_SHADOW, type WellColors, getInlineColorPickerContentSize, getStaggeredWordDuration, isCompactDialogHeight, overlayActionStyles, overlayStyles, useCompactDialog, useOverlayCardColors, useWellColors };
|
package/dist/chrome/index.mjs
CHANGED
|
@@ -7,10 +7,7 @@ import {
|
|
|
7
7
|
ConfirmDialog,
|
|
8
8
|
ContentGutter,
|
|
9
9
|
CornerActionButtons,
|
|
10
|
-
InlineColorPicker,
|
|
11
10
|
LOCKED_BADGE_COLOR,
|
|
12
|
-
MONO_FONT,
|
|
13
|
-
PopoverBody,
|
|
14
11
|
PressAwayOverlay,
|
|
15
12
|
RotatedFrame,
|
|
16
13
|
StaggeredWord,
|
|
@@ -18,13 +15,18 @@ import {
|
|
|
18
15
|
StatSection,
|
|
19
16
|
UpdateDialog,
|
|
20
17
|
WELL_SHADOW,
|
|
21
|
-
getInlineColorPickerContentSize,
|
|
22
18
|
getStaggeredWordDuration,
|
|
23
|
-
useAutoAlign,
|
|
24
19
|
useCompactDialog,
|
|
25
|
-
usePopoverHost,
|
|
26
20
|
useWellColors
|
|
27
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-JBE7IQC5.mjs";
|
|
22
|
+
import {
|
|
23
|
+
InlineColorPicker,
|
|
24
|
+
MONO_FONT,
|
|
25
|
+
PopoverBody,
|
|
26
|
+
getInlineColorPickerContentSize,
|
|
27
|
+
useAutoAlign,
|
|
28
|
+
usePopoverHost
|
|
29
|
+
} from "../chunk-FOJLQMKA.mjs";
|
|
28
30
|
import {
|
|
29
31
|
COMPACT_DIALOG_HEIGHT,
|
|
30
32
|
DialogHeader,
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InlineColorPicker,
|
|
3
|
+
MONO_FONT,
|
|
4
|
+
useAutoAlign,
|
|
5
|
+
usePopoverHost
|
|
6
|
+
} from "./chunk-FOJLQMKA.mjs";
|
|
7
|
+
|
|
8
|
+
// src/ReadyButton.tsx
|
|
9
|
+
import { TouchableRipple } from "@rific/feedback-press";
|
|
10
|
+
import { StyleSheet } from "react-native";
|
|
11
|
+
import { Text } from "react-native-paper";
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily = MONO_FONT }) {
|
|
14
|
+
const readyButtonStyle = [styles.readyButton, { borderColor: color }, ready && { backgroundColor: color }, style];
|
|
15
|
+
const labelTextStyle = { fontFamily: labelFontFamily, fontWeight: "bold" };
|
|
16
|
+
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: ready ? "READY \u2713" : "READY?" }) });
|
|
18
|
+
}
|
|
19
|
+
var styles = StyleSheet.create({
|
|
20
|
+
readyButton: {
|
|
21
|
+
alignItems: "center",
|
|
22
|
+
borderRadius: 12,
|
|
23
|
+
borderWidth: 1,
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
minWidth: 120,
|
|
26
|
+
paddingHorizontal: 16,
|
|
27
|
+
paddingVertical: 10
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// src/useZoneClampedAlign.ts
|
|
32
|
+
import { useZoneBounds } from "@tastic/split-screen";
|
|
33
|
+
import { useEffect, useState } from "react";
|
|
34
|
+
import { useWindowDimensions } from "react-native";
|
|
35
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
36
|
+
var EDGE_MARGIN = 12;
|
|
37
|
+
function useZoneClampedAlign(open, contentWidth, contentHeight, rotation = 0) {
|
|
38
|
+
const auto = useAutoAlign(open, contentWidth, contentHeight, rotation);
|
|
39
|
+
const zone = useZoneBounds();
|
|
40
|
+
const { height: windowHeight } = useWindowDimensions();
|
|
41
|
+
const insets = useSafeAreaInsets();
|
|
42
|
+
const shouldMeasure = open && auto.measured && zone !== null;
|
|
43
|
+
const [ownBounds, setOwnBounds] = useState(null);
|
|
44
|
+
const [prevShouldMeasure, setPrevShouldMeasure] = useState(shouldMeasure);
|
|
45
|
+
if (shouldMeasure !== prevShouldMeasure) {
|
|
46
|
+
setPrevShouldMeasure(shouldMeasure);
|
|
47
|
+
setOwnBounds(null);
|
|
48
|
+
}
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!shouldMeasure) return;
|
|
51
|
+
auto.triggerRef.current?.measureInWindow((_x, y, _width, height) => {
|
|
52
|
+
const belowShared = zone.zoneSide === "belowShared";
|
|
53
|
+
const awayRoom = belowShared ? windowHeight - insets.bottom - (y + height) - EDGE_MARGIN : y - insets.top - EDGE_MARGIN;
|
|
54
|
+
const towardRoom = belowShared ? y - zone.sharedEdgeY - EDGE_MARGIN : zone.sharedEdgeY - (y + height) - EDGE_MARGIN;
|
|
55
|
+
const useToward = contentHeight > awayRoom && towardRoom > awayRoom;
|
|
56
|
+
let awaySide = belowShared ? "below" : "above";
|
|
57
|
+
let towardSide = belowShared ? "above" : "below";
|
|
58
|
+
if (zone.rotated) {
|
|
59
|
+
awaySide = awaySide === "above" ? "below" : "above";
|
|
60
|
+
towardSide = towardSide === "above" ? "below" : "above";
|
|
61
|
+
}
|
|
62
|
+
setOwnBounds({ maxHeight: Math.max(useToward ? towardRoom : awayRoom, 0), verticalAlign: useToward ? towardSide : awaySide });
|
|
63
|
+
});
|
|
64
|
+
}, [shouldMeasure, zone, auto.triggerRef, contentHeight, windowHeight, insets.top, insets.bottom]);
|
|
65
|
+
if (!zone) return auto;
|
|
66
|
+
if (!ownBounds) return { ...auto, measured: false };
|
|
67
|
+
return { ...auto, maxHeight: ownBounds.maxHeight, measured: auto.measured, verticalAlign: ownBounds.verticalAlign };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/PlayerSetupPanel.tsx
|
|
71
|
+
import { getOptionPickerContentSize, getProfilePickerContentSize, OptionPicker, ProfilePicker } from "@tastic/profile";
|
|
72
|
+
import { StyleSheet as StyleSheet2, View } from "react-native";
|
|
73
|
+
import { Text as Text2 } from "react-native-paper";
|
|
74
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
75
|
+
function getColorPopoverId(idPrefix) {
|
|
76
|
+
return `${idPrefix}-color`;
|
|
77
|
+
}
|
|
78
|
+
function getProfilePopoverId(idPrefix) {
|
|
79
|
+
return `${idPrefix}-profile`;
|
|
80
|
+
}
|
|
81
|
+
function getCpuDifficultyPopoverId(idPrefix) {
|
|
82
|
+
return `${idPrefix}-difficulty`;
|
|
83
|
+
}
|
|
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, nullLabel, onProfileSelect, onManageProfiles, cpuDifficulty, cpuDifficultyOptions, onCpuDifficultyChange, humanIcon = "face-man", cpuIcon = "robot", previewValue, triggerStyle, useSeatPickerAlign }) {
|
|
85
|
+
const ownHost = usePopoverHost();
|
|
86
|
+
const popover = host ?? ownHost;
|
|
87
|
+
const ownPopoverOpen = popover.openId?.startsWith(`${idPrefix}-`) ?? false;
|
|
88
|
+
const pickerRowPopoverOpen = popover.openId === getColorPopoverId(idPrefix) || secondPickerId !== void 0 && popover.openId === secondPickerId;
|
|
89
|
+
const showProfilePicker = isHuman && profiles !== void 0 && !!onProfileSelect;
|
|
90
|
+
const showCpuDifficulty = !isHuman && cpuDifficulty !== void 0 && cpuDifficultyOptions !== void 0 && !!onCpuDifficultyChange;
|
|
91
|
+
const seatButton = showProfilePicker || showCpuDifficulty;
|
|
92
|
+
const selectedProfile = profiles?.find((p) => p.id === selectedProfileId) ?? null;
|
|
93
|
+
const drawn = previewValue ? previewValue(color) : color;
|
|
94
|
+
const colorSection = showColor ? { value: color, onChange: onColorChange, swatches, takenValue: takenColor, allowSwapTaken, caption: showProfilePicker && selectedProfile ? colorCaption : void 0, previewValue } : void 0;
|
|
95
|
+
const seatPickerId = showProfilePicker ? getProfilePopoverId(idPrefix) : getCpuDifficultyPopoverId(idPrefix);
|
|
96
|
+
const seatPickerSize = showProfilePicker ? getProfilePickerContentSize(profiles.length, !!onManageProfiles, colorSection) : getOptionPickerContentSize(cpuDifficultyOptions?.length ?? 0, colorSection);
|
|
97
|
+
const useSeatAlign = useSeatPickerAlign ?? useZoneClampedAlign;
|
|
98
|
+
const seatPickerAlign = useSeatAlign(seatButton && popover.openId === seatPickerId, seatPickerSize.width, seatPickerSize.height);
|
|
99
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles2.panel, ownPopoverOpen && styles2.panelOpen], children: [
|
|
100
|
+
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 }),
|
|
101
|
+
(!seatButton || secondPicker) && /* @__PURE__ */ jsxs(View, { style: [styles2.pickerRow, pickerRowPopoverOpen && styles2.pickerRowOpen], children: [
|
|
102
|
+
!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 }),
|
|
103
|
+
secondPicker
|
|
104
|
+
] }),
|
|
105
|
+
isHuman && showReadyButton && onToggleReady && /* @__PURE__ */ jsx2(ReadyButton, { color: drawn, ready: ready ?? false, onToggleReady })
|
|
106
|
+
] });
|
|
107
|
+
}
|
|
108
|
+
var styles2 = StyleSheet2.create({
|
|
109
|
+
panel: {
|
|
110
|
+
alignItems: "center",
|
|
111
|
+
gap: 12
|
|
112
|
+
},
|
|
113
|
+
// See SectionedDropdown's anchorOpen comment - this panel is typically a sibling of another
|
|
114
|
+
// panel (and/or a shared-controls row), so a popover escaping this panel's bounds needs the panel
|
|
115
|
+
// itself elevated, not just the popover content, to paint above a later sibling.
|
|
116
|
+
panelOpen: {
|
|
117
|
+
zIndex: 100
|
|
118
|
+
},
|
|
119
|
+
// Same gap as `panel`'s own vertical rhythm, reused horizontally - the fallback color swatch and
|
|
120
|
+
// (when present) secondPicker sit side by side within this row instead of stacked in the panel's
|
|
121
|
+
// own column.
|
|
122
|
+
pickerRow: {
|
|
123
|
+
alignItems: "center",
|
|
124
|
+
flexDirection: "row",
|
|
125
|
+
gap: 12
|
|
126
|
+
},
|
|
127
|
+
// A popover is an absolutely-positioned sibling of its own trigger - so a tall one (the color
|
|
128
|
+
// swatch grid) can extend down far enough to overlap the ReadyButton below, which paints on top of
|
|
129
|
+
// it by default DOM order since it's a later sibling within `panel`. `panel`'s own panelOpen
|
|
130
|
+
// elevation only helps this panel paint above OTHER panels (see its own comment) - it does nothing
|
|
131
|
+
// for stacking *within* this panel, since React Native Web gives each View its own stacking
|
|
132
|
+
// context. This is what actually fixes that: elevate pickerRow itself above its own later sibling
|
|
133
|
+
// whenever one of its own popovers is open.
|
|
134
|
+
pickerRowOpen: {
|
|
135
|
+
zIndex: 100
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// src/SharedActionBand.tsx
|
|
140
|
+
import { IconButton } from "@rific/feedback-press";
|
|
141
|
+
import { StyleSheet as StyleSheet3, View as View2 } from "react-native";
|
|
142
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
143
|
+
function SharedActionBand({ onBack, onSettings, onRandomize, onReset, fg, popoverOpen, children }) {
|
|
144
|
+
return /* @__PURE__ */ jsxs2(View2, { style: [styles3.column, popoverOpen && styles3.columnOpen], children: [
|
|
145
|
+
/* @__PURE__ */ jsxs2(View2, { style: styles3.actionsRow, children: [
|
|
146
|
+
/* @__PURE__ */ jsx3(IconButton, { icon: "arrow-left", iconColor: fg, size: 20, onPress: onBack, accessibilityLabel: "Back" }),
|
|
147
|
+
onRandomize && /* @__PURE__ */ jsx3(IconButton, { icon: "dice-multiple", iconColor: fg, size: 18, onPress: onRandomize, accessibilityLabel: "Randomize match settings" }),
|
|
148
|
+
onReset && /* @__PURE__ */ jsx3(IconButton, { icon: "restore", iconColor: fg, size: 18, onPress: onReset, accessibilityLabel: "Reset match settings to defaults" }),
|
|
149
|
+
/* @__PURE__ */ jsx3(IconButton, { icon: "cog", iconColor: fg, size: 20, onPress: onSettings, accessibilityLabel: "Settings" })
|
|
150
|
+
] }),
|
|
151
|
+
children
|
|
152
|
+
] });
|
|
153
|
+
}
|
|
154
|
+
var styles3 = StyleSheet3.create({
|
|
155
|
+
actionsRow: {
|
|
156
|
+
alignItems: "center",
|
|
157
|
+
flexDirection: "row",
|
|
158
|
+
gap: 16
|
|
159
|
+
},
|
|
160
|
+
column: {
|
|
161
|
+
alignItems: "center",
|
|
162
|
+
gap: 8
|
|
163
|
+
},
|
|
164
|
+
columnOpen: {
|
|
165
|
+
zIndex: 100
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
export {
|
|
170
|
+
ReadyButton,
|
|
171
|
+
useZoneClampedAlign,
|
|
172
|
+
getColorPopoverId,
|
|
173
|
+
getProfilePopoverId,
|
|
174
|
+
getCpuDifficultyPopoverId,
|
|
175
|
+
PlayerSetupPanel,
|
|
176
|
+
SharedActionBand
|
|
177
|
+
};
|