@tastic/hud 0.8.4 → 0.8.5
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/dist/index.js +30 -11
- package/dist/index.mjs +30 -11
- package/package.json +1 -1
- package/src/ConfirmDialog.tsx +30 -11
package/dist/index.js
CHANGED
|
@@ -312,36 +312,55 @@ function ConfirmDialog({ visible, title, message, confirmLabel, cancelLabel, onC
|
|
|
312
312
|
const { fg, cardBg, cardBorder } = getOverlayCardColors(dark);
|
|
313
313
|
const accent = destructive ? colors.danger : colors.primary;
|
|
314
314
|
const onAccent = destructive ? colors.onDanger : colors.onPrimary;
|
|
315
|
+
const showCancel = cancelLabel !== void 0 && onCancel !== void 0;
|
|
315
316
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_paper2.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.View, { style: [overlayStyles.overlay, styles2.overlay], children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native3.View, { style: [overlayStyles.card, styles2.card, { backgroundColor: cardBg, borderColor: cardBorder }, (0, import_core.toRotationStyle)(rotation)], children: [
|
|
316
317
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_paper2.Icon, { source: icon, size: 64, color: accent }),
|
|
317
318
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_paper2.Text, { variant: "headlineLarge", style: [styles2.title, { color: accent }], children: title }),
|
|
318
319
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_paper2.Text, { variant: "bodyLarge", style: [styles2.body, { color: fg }], children: message }),
|
|
319
320
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native3.View, { style: styles2.actions, children: [
|
|
320
|
-
|
|
321
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_feedback_press.Button, { mode: "contained", onPress: onConfirm, style: styles2.actionButton, buttonColor: accent, textColor: onAccent, children: confirmLabel })
|
|
321
|
+
showCancel && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_feedback_press.Button, { mode: "outlined", onPress: onCancel, style: styles2.actionButton, children: cancelLabel }),
|
|
322
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_feedback_press.Button, { mode: "contained", onPress: onConfirm, style: showCancel ? styles2.actionButton : styles2.actionButtonSingle, buttonColor: accent, textColor: onAccent, children: confirmLabel })
|
|
322
323
|
] })
|
|
323
324
|
] }) }) });
|
|
324
325
|
}
|
|
325
326
|
var styles2 = import_react_native3.StyleSheet.create({
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
//
|
|
329
|
-
//
|
|
327
|
+
// minWidth (not flexBasis) is each button's real floor - whenever both fit side by side, flexGrow
|
|
328
|
+
// still splits any leftover width evenly beyond that floor, same visual result as a plain flex: 1
|
|
329
|
+
// on a roomy screen, but a button can never be squeezed narrower than 128, only wrap to its own
|
|
330
|
+
// row instead (see actions' flexWrap below). This used to be flexBasis: 128, which measured
|
|
331
|
+
// correctly on web but rendered every button roughly SQUARE on iOS - confirmed live (see the
|
|
332
|
+
// "Quit Match?" Cancel/Quit buttons and the single-button "OK" dialogs both coming out ~128pt
|
|
333
|
+
// tall instead of wide). Root cause: react-native-paper's Button renders its Surface as two
|
|
334
|
+
// nested views on iOS only (Surface.tsx's SurfaceIOS, for shadow rendering) - only a curated
|
|
335
|
+
// allowlist of style keys (flex/flexGrow/flexShrink/width/height/position/... - notably NOT
|
|
336
|
+
// flexBasis) reaches the outer view, which is the real flex item inside this row; every other
|
|
337
|
+
// key, flexBasis included, falls through to an inner view whose own unspecified flexDirection
|
|
338
|
+
// defaults to column. flexGrow: 1 landed on the (row-context) outer view and grew width
|
|
339
|
+
// correctly; flexBasis: 128 landed on the (column-context) inner view instead, where a flexBasis
|
|
340
|
+
// sets HEIGHT, not width. minWidth isn't axis-relative like flexBasis, so it constrains width
|
|
341
|
+
// correctly regardless of which of the two views it ends up on. react-native-paper's Button also
|
|
330
342
|
// hardcodes numberOfLines={1} on its label with no override, so a button squeezed under its
|
|
331
343
|
// label's natural width silently ellipsizes ("Cancel" -> "Can...") instead of wrapping - assumed
|
|
332
344
|
// fixable by just giving the row more width, until confirmed live that these two-word labels
|
|
333
345
|
// (Cancel/Reset/New Game) can still lose the truncation fight even with the extra room card's own
|
|
334
|
-
// width fix below provides, on a narrow enough screen.
|
|
335
|
-
// width there's no side-by-side arrangement that fits both buttons at their natural label size,
|
|
336
|
-
// so the layout has to give (stack) rather than the label (truncate).
|
|
346
|
+
// width fix below provides, on a narrow enough screen.
|
|
337
347
|
actionButton: {
|
|
338
|
-
|
|
339
|
-
|
|
348
|
+
flexGrow: 1,
|
|
349
|
+
minWidth: 128
|
|
350
|
+
},
|
|
351
|
+
// A lone confirm button (no cancel - BaseSettingsDialog's info-only "OK" dialogs, e.g. the
|
|
352
|
+
// update-check "no update found" message) has nothing left to share actions' width with, so
|
|
353
|
+
// actionButton's own flexGrow: 1 would stretch it across the entire row instead of reading as a
|
|
354
|
+
// normal button. Same 128 floor, no flexGrow, so it stays at that natural size instead of filling
|
|
355
|
+
// the card - centered by actions' own justifyContent below.
|
|
356
|
+
actionButtonSingle: {
|
|
357
|
+
minWidth: 128
|
|
340
358
|
},
|
|
341
359
|
actions: {
|
|
342
360
|
flexDirection: "row",
|
|
343
361
|
flexWrap: "wrap",
|
|
344
362
|
gap: 12,
|
|
363
|
+
justifyContent: "center",
|
|
345
364
|
width: "100%"
|
|
346
365
|
},
|
|
347
366
|
body: {
|
package/dist/index.mjs
CHANGED
|
@@ -125,36 +125,55 @@ function ConfirmDialog({ visible, title, message, confirmLabel, cancelLabel, onC
|
|
|
125
125
|
const { fg, cardBg, cardBorder } = getOverlayCardColors(dark);
|
|
126
126
|
const accent = destructive ? colors.danger : colors.primary;
|
|
127
127
|
const onAccent = destructive ? colors.onDanger : colors.onPrimary;
|
|
128
|
+
const showCancel = cancelLabel !== void 0 && onCancel !== void 0;
|
|
128
129
|
return /* @__PURE__ */ jsx2(Portal, { children: /* @__PURE__ */ jsx2(View2, { style: [overlayStyles.overlay, styles2.overlay], children: /* @__PURE__ */ jsxs2(View2, { style: [overlayStyles.card, styles2.card, { backgroundColor: cardBg, borderColor: cardBorder }, toRotationStyle(rotation)], children: [
|
|
129
130
|
/* @__PURE__ */ jsx2(Icon2, { source: icon, size: 64, color: accent }),
|
|
130
131
|
/* @__PURE__ */ jsx2(Text2, { variant: "headlineLarge", style: [styles2.title, { color: accent }], children: title }),
|
|
131
132
|
/* @__PURE__ */ jsx2(Text2, { variant: "bodyLarge", style: [styles2.body, { color: fg }], children: message }),
|
|
132
133
|
/* @__PURE__ */ jsxs2(View2, { style: styles2.actions, children: [
|
|
133
|
-
|
|
134
|
-
/* @__PURE__ */ jsx2(Button, { mode: "contained", onPress: onConfirm, style: styles2.actionButton, buttonColor: accent, textColor: onAccent, children: confirmLabel })
|
|
134
|
+
showCancel && /* @__PURE__ */ jsx2(Button, { mode: "outlined", onPress: onCancel, style: styles2.actionButton, children: cancelLabel }),
|
|
135
|
+
/* @__PURE__ */ jsx2(Button, { mode: "contained", onPress: onConfirm, style: showCancel ? styles2.actionButton : styles2.actionButtonSingle, buttonColor: accent, textColor: onAccent, children: confirmLabel })
|
|
135
136
|
] })
|
|
136
137
|
] }) }) });
|
|
137
138
|
}
|
|
138
139
|
var styles2 = StyleSheet3.create({
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
//
|
|
140
|
+
// minWidth (not flexBasis) is each button's real floor - whenever both fit side by side, flexGrow
|
|
141
|
+
// still splits any leftover width evenly beyond that floor, same visual result as a plain flex: 1
|
|
142
|
+
// on a roomy screen, but a button can never be squeezed narrower than 128, only wrap to its own
|
|
143
|
+
// row instead (see actions' flexWrap below). This used to be flexBasis: 128, which measured
|
|
144
|
+
// correctly on web but rendered every button roughly SQUARE on iOS - confirmed live (see the
|
|
145
|
+
// "Quit Match?" Cancel/Quit buttons and the single-button "OK" dialogs both coming out ~128pt
|
|
146
|
+
// tall instead of wide). Root cause: react-native-paper's Button renders its Surface as two
|
|
147
|
+
// nested views on iOS only (Surface.tsx's SurfaceIOS, for shadow rendering) - only a curated
|
|
148
|
+
// allowlist of style keys (flex/flexGrow/flexShrink/width/height/position/... - notably NOT
|
|
149
|
+
// flexBasis) reaches the outer view, which is the real flex item inside this row; every other
|
|
150
|
+
// key, flexBasis included, falls through to an inner view whose own unspecified flexDirection
|
|
151
|
+
// defaults to column. flexGrow: 1 landed on the (row-context) outer view and grew width
|
|
152
|
+
// correctly; flexBasis: 128 landed on the (column-context) inner view instead, where a flexBasis
|
|
153
|
+
// sets HEIGHT, not width. minWidth isn't axis-relative like flexBasis, so it constrains width
|
|
154
|
+
// correctly regardless of which of the two views it ends up on. react-native-paper's Button also
|
|
143
155
|
// hardcodes numberOfLines={1} on its label with no override, so a button squeezed under its
|
|
144
156
|
// label's natural width silently ellipsizes ("Cancel" -> "Can...") instead of wrapping - assumed
|
|
145
157
|
// fixable by just giving the row more width, until confirmed live that these two-word labels
|
|
146
158
|
// (Cancel/Reset/New Game) can still lose the truncation fight even with the extra room card's own
|
|
147
|
-
// width fix below provides, on a narrow enough screen.
|
|
148
|
-
// width there's no side-by-side arrangement that fits both buttons at their natural label size,
|
|
149
|
-
// so the layout has to give (stack) rather than the label (truncate).
|
|
159
|
+
// width fix below provides, on a narrow enough screen.
|
|
150
160
|
actionButton: {
|
|
151
|
-
|
|
152
|
-
|
|
161
|
+
flexGrow: 1,
|
|
162
|
+
minWidth: 128
|
|
163
|
+
},
|
|
164
|
+
// A lone confirm button (no cancel - BaseSettingsDialog's info-only "OK" dialogs, e.g. the
|
|
165
|
+
// update-check "no update found" message) has nothing left to share actions' width with, so
|
|
166
|
+
// actionButton's own flexGrow: 1 would stretch it across the entire row instead of reading as a
|
|
167
|
+
// normal button. Same 128 floor, no flexGrow, so it stays at that natural size instead of filling
|
|
168
|
+
// the card - centered by actions' own justifyContent below.
|
|
169
|
+
actionButtonSingle: {
|
|
170
|
+
minWidth: 128
|
|
153
171
|
},
|
|
154
172
|
actions: {
|
|
155
173
|
flexDirection: "row",
|
|
156
174
|
flexWrap: "wrap",
|
|
157
175
|
gap: 12,
|
|
176
|
+
justifyContent: "center",
|
|
158
177
|
width: "100%"
|
|
159
178
|
},
|
|
160
179
|
body: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tastic/hud",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
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/ConfirmDialog.tsx
CHANGED
|
@@ -42,6 +42,7 @@ export function ConfirmDialog({ visible, title, message, confirmLabel, cancelLab
|
|
|
42
42
|
const { fg, cardBg, cardBorder } = getOverlayCardColors(dark)
|
|
43
43
|
const accent = destructive ? colors.danger : colors.primary
|
|
44
44
|
const onAccent = destructive ? colors.onDanger : colors.onPrimary
|
|
45
|
+
const showCancel = cancelLabel !== undefined && onCancel !== undefined
|
|
45
46
|
|
|
46
47
|
return (
|
|
47
48
|
<Portal>
|
|
@@ -55,12 +56,12 @@ export function ConfirmDialog({ visible, title, message, confirmLabel, cancelLab
|
|
|
55
56
|
{message}
|
|
56
57
|
</Text>
|
|
57
58
|
<View style={styles.actions}>
|
|
58
|
-
{
|
|
59
|
+
{showCancel && (
|
|
59
60
|
<Button mode='outlined' onPress={onCancel} style={styles.actionButton}>
|
|
60
61
|
{cancelLabel}
|
|
61
62
|
</Button>
|
|
62
63
|
)}
|
|
63
|
-
<Button mode='contained' onPress={onConfirm} style={styles.actionButton} buttonColor={accent} textColor={onAccent}>
|
|
64
|
+
<Button mode='contained' onPress={onConfirm} style={showCancel ? styles.actionButton : styles.actionButtonSingle} buttonColor={accent} textColor={onAccent}>
|
|
64
65
|
{confirmLabel}
|
|
65
66
|
</Button>
|
|
66
67
|
</View>
|
|
@@ -71,25 +72,43 @@ export function ConfirmDialog({ visible, title, message, confirmLabel, cancelLab
|
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
const styles = StyleSheet.create({
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
75
|
+
// minWidth (not flexBasis) is each button's real floor - whenever both fit side by side, flexGrow
|
|
76
|
+
// still splits any leftover width evenly beyond that floor, same visual result as a plain flex: 1
|
|
77
|
+
// on a roomy screen, but a button can never be squeezed narrower than 128, only wrap to its own
|
|
78
|
+
// row instead (see actions' flexWrap below). This used to be flexBasis: 128, which measured
|
|
79
|
+
// correctly on web but rendered every button roughly SQUARE on iOS - confirmed live (see the
|
|
80
|
+
// "Quit Match?" Cancel/Quit buttons and the single-button "OK" dialogs both coming out ~128pt
|
|
81
|
+
// tall instead of wide). Root cause: react-native-paper's Button renders its Surface as two
|
|
82
|
+
// nested views on iOS only (Surface.tsx's SurfaceIOS, for shadow rendering) - only a curated
|
|
83
|
+
// allowlist of style keys (flex/flexGrow/flexShrink/width/height/position/... - notably NOT
|
|
84
|
+
// flexBasis) reaches the outer view, which is the real flex item inside this row; every other
|
|
85
|
+
// key, flexBasis included, falls through to an inner view whose own unspecified flexDirection
|
|
86
|
+
// defaults to column. flexGrow: 1 landed on the (row-context) outer view and grew width
|
|
87
|
+
// correctly; flexBasis: 128 landed on the (column-context) inner view instead, where a flexBasis
|
|
88
|
+
// sets HEIGHT, not width. minWidth isn't axis-relative like flexBasis, so it constrains width
|
|
89
|
+
// correctly regardless of which of the two views it ends up on. react-native-paper's Button also
|
|
78
90
|
// hardcodes numberOfLines={1} on its label with no override, so a button squeezed under its
|
|
79
91
|
// label's natural width silently ellipsizes ("Cancel" -> "Can...") instead of wrapping - assumed
|
|
80
92
|
// fixable by just giving the row more width, until confirmed live that these two-word labels
|
|
81
93
|
// (Cancel/Reset/New Game) can still lose the truncation fight even with the extra room card's own
|
|
82
|
-
// width fix below provides, on a narrow enough screen.
|
|
83
|
-
// width there's no side-by-side arrangement that fits both buttons at their natural label size,
|
|
84
|
-
// so the layout has to give (stack) rather than the label (truncate).
|
|
94
|
+
// width fix below provides, on a narrow enough screen.
|
|
85
95
|
actionButton: {
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
flexGrow: 1,
|
|
97
|
+
minWidth: 128
|
|
98
|
+
},
|
|
99
|
+
// A lone confirm button (no cancel - BaseSettingsDialog's info-only "OK" dialogs, e.g. the
|
|
100
|
+
// update-check "no update found" message) has nothing left to share actions' width with, so
|
|
101
|
+
// actionButton's own flexGrow: 1 would stretch it across the entire row instead of reading as a
|
|
102
|
+
// normal button. Same 128 floor, no flexGrow, so it stays at that natural size instead of filling
|
|
103
|
+
// the card - centered by actions' own justifyContent below.
|
|
104
|
+
actionButtonSingle: {
|
|
105
|
+
minWidth: 128
|
|
88
106
|
},
|
|
89
107
|
actions: {
|
|
90
108
|
flexDirection: 'row',
|
|
91
109
|
flexWrap: 'wrap',
|
|
92
110
|
gap: 12,
|
|
111
|
+
justifyContent: 'center',
|
|
93
112
|
width: '100%'
|
|
94
113
|
},
|
|
95
114
|
body: {
|