@buoy-gg/shared-ui 7.0.33 → 7.0.34

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.
Files changed (189) hide show
  1. package/lib/commonjs/JsModal.js +57 -22
  2. package/lib/commonjs/hooks/index.js +26 -0
  3. package/lib/commonjs/hooks/safe-area-impl.js +1 -1
  4. package/lib/commonjs/hooks/useChangeLog.js +55 -0
  5. package/lib/commonjs/hooks/useEventStoreEvents.js +65 -0
  6. package/lib/commonjs/hooks/usePersistedState.js +45 -10
  7. package/lib/commonjs/index.js +143 -0
  8. package/lib/commonjs/storage/definePersistedSetting.js +67 -0
  9. package/lib/commonjs/storage/index.js +8 -1
  10. package/lib/commonjs/stores/ChangeLog.js +197 -0
  11. package/lib/commonjs/stores/createToolStore.js +175 -0
  12. package/lib/commonjs/stores/index.js +15 -1
  13. package/lib/commonjs/sync/toolSyncAdapter.js +63 -0
  14. package/lib/commonjs/sync/wireForm.js +172 -0
  15. package/lib/commonjs/tools/defineTool.js +79 -0
  16. package/lib/commonjs/ui/components/ChangeRow.js +110 -0
  17. package/lib/commonjs/ui/components/ChipStrip.js +94 -0
  18. package/lib/commonjs/ui/components/DetailViewToggle.js +130 -0
  19. package/lib/commonjs/ui/components/DevToolsCard.js +3 -1
  20. package/lib/commonjs/ui/components/EntityFilterView.js +354 -0
  21. package/lib/commonjs/ui/components/ExportPreview.js +174 -0
  22. package/lib/commonjs/ui/components/InfoRow.js +90 -0
  23. package/lib/commonjs/ui/components/ModalHeader.js +40 -7
  24. package/lib/commonjs/ui/components/Pill.js +114 -0
  25. package/lib/commonjs/ui/components/ToggleRow.js +116 -0
  26. package/lib/commonjs/ui/components/ToolFooter.js +204 -0
  27. package/lib/commonjs/ui/components/index.js +100 -1
  28. package/lib/commonjs/ui/index.js +24 -2
  29. package/lib/commonjs/ui/listPresets.js +43 -0
  30. package/lib/commonjs/ui/night/primitives.js +3 -1
  31. package/lib/commonjs/utils/snapshotProviderKit.js +167 -0
  32. package/lib/commonjs/utils/stateTools.js +160 -0
  33. package/lib/module/JsModal.js +57 -22
  34. package/lib/module/hooks/index.js +3 -1
  35. package/lib/module/hooks/safe-area-impl.js +1 -1
  36. package/lib/module/hooks/useChangeLog.js +50 -0
  37. package/lib/module/hooks/useEventStoreEvents.js +61 -0
  38. package/lib/module/hooks/usePersistedState.js +44 -10
  39. package/lib/module/index.js +11 -1
  40. package/lib/module/storage/definePersistedSetting.js +63 -0
  41. package/lib/module/storage/index.js +2 -1
  42. package/lib/module/stores/ChangeLog.js +192 -0
  43. package/lib/module/stores/createToolStore.js +171 -0
  44. package/lib/module/stores/index.js +3 -1
  45. package/lib/module/sync/toolSyncAdapter.js +58 -0
  46. package/lib/module/sync/wireForm.js +159 -0
  47. package/lib/module/tools/defineTool.js +74 -0
  48. package/lib/module/ui/components/ChangeRow.js +105 -0
  49. package/lib/module/ui/components/ChipStrip.js +91 -0
  50. package/lib/module/ui/components/DetailViewToggle.js +125 -0
  51. package/lib/module/ui/components/DevToolsCard.js +3 -1
  52. package/lib/module/ui/components/EntityFilterView.js +350 -0
  53. package/lib/module/ui/components/ExportPreview.js +169 -0
  54. package/lib/module/ui/components/InfoRow.js +86 -0
  55. package/lib/module/ui/components/ModalHeader.js +40 -7
  56. package/lib/module/ui/components/Pill.js +110 -0
  57. package/lib/module/ui/components/ToggleRow.js +112 -0
  58. package/lib/module/ui/components/ToolFooter.js +196 -0
  59. package/lib/module/ui/components/index.js +10 -1
  60. package/lib/module/ui/index.js +4 -1
  61. package/lib/module/ui/listPresets.js +39 -0
  62. package/lib/module/ui/night/primitives.js +3 -1
  63. package/lib/module/utils/snapshotProviderKit.js +156 -0
  64. package/lib/module/utils/stateTools.js +154 -0
  65. package/lib/typescript/commonjs/JsModal.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/hooks/index.d.ts +3 -1
  67. package/lib/typescript/commonjs/hooks/index.d.ts.map +1 -1
  68. package/lib/typescript/commonjs/hooks/safe-area-impl.d.ts +1 -1
  69. package/lib/typescript/commonjs/hooks/useChangeLog.d.ts +38 -0
  70. package/lib/typescript/commonjs/hooks/useChangeLog.d.ts.map +1 -0
  71. package/lib/typescript/commonjs/hooks/useEventStoreEvents.d.ts +25 -0
  72. package/lib/typescript/commonjs/hooks/useEventStoreEvents.d.ts.map +1 -0
  73. package/lib/typescript/commonjs/hooks/usePersistedState.d.ts +34 -5
  74. package/lib/typescript/commonjs/hooks/usePersistedState.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/index.d.ts +6 -1
  76. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  77. package/lib/typescript/commonjs/storage/definePersistedSetting.d.ts +39 -0
  78. package/lib/typescript/commonjs/storage/definePersistedSetting.d.ts.map +1 -0
  79. package/lib/typescript/commonjs/storage/index.d.ts +1 -0
  80. package/lib/typescript/commonjs/storage/index.d.ts.map +1 -1
  81. package/lib/typescript/commonjs/stores/ChangeLog.d.ts +100 -0
  82. package/lib/typescript/commonjs/stores/ChangeLog.d.ts.map +1 -0
  83. package/lib/typescript/commonjs/stores/createToolStore.d.ts +92 -0
  84. package/lib/typescript/commonjs/stores/createToolStore.d.ts.map +1 -0
  85. package/lib/typescript/commonjs/stores/index.d.ts +2 -0
  86. package/lib/typescript/commonjs/stores/index.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/sync/toolSyncAdapter.d.ts +66 -0
  88. package/lib/typescript/commonjs/sync/toolSyncAdapter.d.ts.map +1 -0
  89. package/lib/typescript/commonjs/sync/wireForm.d.ts +100 -0
  90. package/lib/typescript/commonjs/sync/wireForm.d.ts.map +1 -0
  91. package/lib/typescript/commonjs/tools/defineTool.d.ts +100 -0
  92. package/lib/typescript/commonjs/tools/defineTool.d.ts.map +1 -0
  93. package/lib/typescript/commonjs/ui/components/ChangeRow.d.ts +52 -0
  94. package/lib/typescript/commonjs/ui/components/ChangeRow.d.ts.map +1 -0
  95. package/lib/typescript/commonjs/ui/components/ChipStrip.d.ts +41 -0
  96. package/lib/typescript/commonjs/ui/components/ChipStrip.d.ts.map +1 -0
  97. package/lib/typescript/commonjs/ui/components/DetailViewToggle.d.ts +36 -0
  98. package/lib/typescript/commonjs/ui/components/DetailViewToggle.d.ts.map +1 -0
  99. package/lib/typescript/commonjs/ui/components/DevToolsCard.d.ts +8 -1
  100. package/lib/typescript/commonjs/ui/components/DevToolsCard.d.ts.map +1 -1
  101. package/lib/typescript/commonjs/ui/components/EntityFilterView.d.ts +51 -0
  102. package/lib/typescript/commonjs/ui/components/EntityFilterView.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/ui/components/ExportPreview.d.ts +48 -0
  104. package/lib/typescript/commonjs/ui/components/ExportPreview.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/ui/components/InfoRow.d.ts +33 -0
  106. package/lib/typescript/commonjs/ui/components/InfoRow.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/ui/components/ModalHeader.d.ts +31 -1
  108. package/lib/typescript/commonjs/ui/components/ModalHeader.d.ts.map +1 -1
  109. package/lib/typescript/commonjs/ui/components/Pill.d.ts +38 -0
  110. package/lib/typescript/commonjs/ui/components/Pill.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/ui/components/ToggleRow.d.ts +33 -0
  112. package/lib/typescript/commonjs/ui/components/ToggleRow.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/ui/components/ToolFooter.d.ts +69 -0
  114. package/lib/typescript/commonjs/ui/components/ToolFooter.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/ui/components/index.d.ts +9 -0
  116. package/lib/typescript/commonjs/ui/components/index.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/ui/index.d.ts +1 -0
  118. package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
  119. package/lib/typescript/commonjs/ui/listPresets.d.ts +28 -0
  120. package/lib/typescript/commonjs/ui/listPresets.d.ts.map +1 -0
  121. package/lib/typescript/commonjs/ui/night/primitives.d.ts +3 -1
  122. package/lib/typescript/commonjs/ui/night/primitives.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/utils/snapshotProviderKit.d.ts +81 -0
  124. package/lib/typescript/commonjs/utils/snapshotProviderKit.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/utils/stateTools.d.ts +44 -0
  126. package/lib/typescript/commonjs/utils/stateTools.d.ts.map +1 -0
  127. package/lib/typescript/module/JsModal.d.ts.map +1 -1
  128. package/lib/typescript/module/hooks/index.d.ts +3 -1
  129. package/lib/typescript/module/hooks/index.d.ts.map +1 -1
  130. package/lib/typescript/module/hooks/safe-area-impl.d.ts +1 -1
  131. package/lib/typescript/module/hooks/useChangeLog.d.ts +38 -0
  132. package/lib/typescript/module/hooks/useChangeLog.d.ts.map +1 -0
  133. package/lib/typescript/module/hooks/useEventStoreEvents.d.ts +25 -0
  134. package/lib/typescript/module/hooks/useEventStoreEvents.d.ts.map +1 -0
  135. package/lib/typescript/module/hooks/usePersistedState.d.ts +34 -5
  136. package/lib/typescript/module/hooks/usePersistedState.d.ts.map +1 -1
  137. package/lib/typescript/module/index.d.ts +6 -1
  138. package/lib/typescript/module/index.d.ts.map +1 -1
  139. package/lib/typescript/module/storage/definePersistedSetting.d.ts +39 -0
  140. package/lib/typescript/module/storage/definePersistedSetting.d.ts.map +1 -0
  141. package/lib/typescript/module/storage/index.d.ts +1 -0
  142. package/lib/typescript/module/storage/index.d.ts.map +1 -1
  143. package/lib/typescript/module/stores/ChangeLog.d.ts +100 -0
  144. package/lib/typescript/module/stores/ChangeLog.d.ts.map +1 -0
  145. package/lib/typescript/module/stores/createToolStore.d.ts +92 -0
  146. package/lib/typescript/module/stores/createToolStore.d.ts.map +1 -0
  147. package/lib/typescript/module/stores/index.d.ts +2 -0
  148. package/lib/typescript/module/stores/index.d.ts.map +1 -1
  149. package/lib/typescript/module/sync/toolSyncAdapter.d.ts +66 -0
  150. package/lib/typescript/module/sync/toolSyncAdapter.d.ts.map +1 -0
  151. package/lib/typescript/module/sync/wireForm.d.ts +100 -0
  152. package/lib/typescript/module/sync/wireForm.d.ts.map +1 -0
  153. package/lib/typescript/module/tools/defineTool.d.ts +100 -0
  154. package/lib/typescript/module/tools/defineTool.d.ts.map +1 -0
  155. package/lib/typescript/module/ui/components/ChangeRow.d.ts +52 -0
  156. package/lib/typescript/module/ui/components/ChangeRow.d.ts.map +1 -0
  157. package/lib/typescript/module/ui/components/ChipStrip.d.ts +41 -0
  158. package/lib/typescript/module/ui/components/ChipStrip.d.ts.map +1 -0
  159. package/lib/typescript/module/ui/components/DetailViewToggle.d.ts +36 -0
  160. package/lib/typescript/module/ui/components/DetailViewToggle.d.ts.map +1 -0
  161. package/lib/typescript/module/ui/components/DevToolsCard.d.ts +8 -1
  162. package/lib/typescript/module/ui/components/DevToolsCard.d.ts.map +1 -1
  163. package/lib/typescript/module/ui/components/EntityFilterView.d.ts +51 -0
  164. package/lib/typescript/module/ui/components/EntityFilterView.d.ts.map +1 -0
  165. package/lib/typescript/module/ui/components/ExportPreview.d.ts +48 -0
  166. package/lib/typescript/module/ui/components/ExportPreview.d.ts.map +1 -0
  167. package/lib/typescript/module/ui/components/InfoRow.d.ts +33 -0
  168. package/lib/typescript/module/ui/components/InfoRow.d.ts.map +1 -0
  169. package/lib/typescript/module/ui/components/ModalHeader.d.ts +31 -1
  170. package/lib/typescript/module/ui/components/ModalHeader.d.ts.map +1 -1
  171. package/lib/typescript/module/ui/components/Pill.d.ts +38 -0
  172. package/lib/typescript/module/ui/components/Pill.d.ts.map +1 -0
  173. package/lib/typescript/module/ui/components/ToggleRow.d.ts +33 -0
  174. package/lib/typescript/module/ui/components/ToggleRow.d.ts.map +1 -0
  175. package/lib/typescript/module/ui/components/ToolFooter.d.ts +69 -0
  176. package/lib/typescript/module/ui/components/ToolFooter.d.ts.map +1 -0
  177. package/lib/typescript/module/ui/components/index.d.ts +9 -0
  178. package/lib/typescript/module/ui/components/index.d.ts.map +1 -1
  179. package/lib/typescript/module/ui/index.d.ts +1 -0
  180. package/lib/typescript/module/ui/index.d.ts.map +1 -1
  181. package/lib/typescript/module/ui/listPresets.d.ts +28 -0
  182. package/lib/typescript/module/ui/listPresets.d.ts.map +1 -0
  183. package/lib/typescript/module/ui/night/primitives.d.ts +3 -1
  184. package/lib/typescript/module/ui/night/primitives.d.ts.map +1 -1
  185. package/lib/typescript/module/utils/snapshotProviderKit.d.ts +81 -0
  186. package/lib/typescript/module/utils/snapshotProviderKit.d.ts.map +1 -0
  187. package/lib/typescript/module/utils/stateTools.d.ts +44 -0
  188. package/lib/typescript/module/utils/stateTools.d.ts.map +1 -0
  189. package/package.json +4 -4
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * defineToolPreset / createToolFactory — the typed way to declare a tool.
5
+ *
6
+ * Every tool package exports a `xToolPreset` object literal and a
7
+ * `createXTool(options)` factory that restates the same literal with
8
+ * `options?.name || default` on each field. None of the 23 presets was
9
+ * annotated with core's `InstalledApp`, so a preset that drifted from the
10
+ * contract (a bad `slot`, a missing `component`) failed at runtime in the
11
+ * dial, not at compile time.
12
+ *
13
+ * `ToolPreset` is that contract, declared here in shared (which every tool
14
+ * already depends on) and structurally identical to core's `InstalledApp`.
15
+ * `defineToolPreset` is an identity function that type-checks the literal;
16
+ * `createToolFactory` derives the `createXTool` function from the preset so
17
+ * the defaults live in exactly one place.
18
+ *
19
+ * Auto-discovery (core's `autoDiscoverPresets` / `autoExternalSync`) stays
20
+ * as hand-written `require()` blocks on purpose: Metro needs each package
21
+ * name as a static string lexically inside its own try, so a manifest can't
22
+ * replace them.
23
+ */
24
+
25
+ /** Where a tool should render within the floating menu surface. */
26
+
27
+ /** What an icon renderer receives. Mirrors core's `FloatingMenuRenderCtx`. */
28
+
29
+ /** Declarative modal chrome for a body-only tool. Mirrors core's `ToolModalConfig`. */
30
+
31
+ /**
32
+ * The shape the floating menu installs. Structurally identical to core's
33
+ * `InstalledApp`; declared here so tool packages can type their presets
34
+ * without depending on core.
35
+ */
36
+
37
+ /** Identity with a type check: the literal must satisfy `ToolPreset`. */
38
+ export function defineToolPreset(preset) {
39
+ return preset;
40
+ }
41
+
42
+ /** The overrides every `createXTool` accepted. */
43
+
44
+ /**
45
+ * Derive `createXTool(options)` from a preset: id/name/description overrides
46
+ * apply on top, and `mapProps` turns tool-specific options into `props`
47
+ * (merged over the preset's defaults).
48
+ *
49
+ * ```ts
50
+ * export const createNetworkTool = createToolFactory(networkToolPreset, (o: { enableSharedModalDimensions?: boolean }) => ({
51
+ * enableSharedModalDimensions: o.enableSharedModalDimensions ?? false,
52
+ * }));
53
+ * ```
54
+ */
55
+ export function createToolFactory(preset, mapProps, /** Last word on any other preset field (a recolored icon, say). */
56
+ extend) {
57
+ return options => {
58
+ const overrides = options ?? {};
59
+ const props = preset.props === undefined && !mapProps ? undefined : {
60
+ ...(preset.props ?? {}),
61
+ ...(mapProps ? mapProps(overrides) : {})
62
+ };
63
+ return {
64
+ ...preset,
65
+ id: overrides.id || preset.id,
66
+ name: overrides.name || preset.name,
67
+ description: overrides.description || preset.description,
68
+ ...(props !== undefined ? {
69
+ props
70
+ } : {}),
71
+ ...(extend ? extend(overrides, preset) : {})
72
+ };
73
+ };
74
+ }
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * ChangeRow — one recorded change in a state tool's history list.
5
+ *
6
+ * redux, zustand and jotai each drew the same row on top of `CompactRow`:
7
+ * a colored status word (the slice / store / atom), a sublabel ("1.2ms ·
8
+ * 3 keys changed"), the primary line (changed keys or a value preview), a
9
+ * relative timestamp, and a right-hand badge made of a mono verb (SET,
10
+ * WRITE, ADDITEM) plus an icon — a lightning bolt when state actually
11
+ * changed, a clock when the update was slow. The three copies differed
12
+ * only in how they computed those strings. This component owns the drawing;
13
+ * tools own the strings.
14
+ *
15
+ * testID convention (unchanged from the originals): `${testID}-badge`,
16
+ * `${testID}-change`, `${testID}-slow`, `${testID}-status`,
17
+ * `${testID}-sublabel`, `${testID}-keys`.
18
+ */
19
+
20
+ import React from "react";
21
+ import { StyleSheet, Text, View } from "react-native";
22
+ import { buoyColors } from "../gameUI/constants/gameUIColors.js";
23
+ import { CompactRow } from "./CompactRow.js";
24
+ import { Clock, Zap } from "../../icons/index.js";
25
+ import { RelativeTime } from "../../utils/time/RelativeTime.js";
26
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
27
+ export function ChangeRow({
28
+ statusColor,
29
+ statusLabel,
30
+ sublabel,
31
+ primaryText,
32
+ timestamp,
33
+ badgeText,
34
+ changed = false,
35
+ slow = false,
36
+ badgePrefix,
37
+ customBadge,
38
+ plainBadgeText,
39
+ onPress,
40
+ testID,
41
+ accessibilityLabel
42
+ }) {
43
+ // Always a custom badge, even when there is no icon to hang off it. The
44
+ // alternative — letting CompactRow draw `badgeText` itself — leaves the one
45
+ // row whose badge matters most (a write that changed NOTHING) as the only
46
+ // row in the list with no handle on its badge.
47
+ const badge = customBadge ?? (badgeText !== undefined || badgePrefix || changed || slow ? /*#__PURE__*/_jsxs(View, {
48
+ style: styles.badgeContainer,
49
+ children: [badgePrefix, badgeText !== undefined ? /*#__PURE__*/_jsx(Text, {
50
+ style: [styles.badgeText, {
51
+ color: statusColor
52
+ }],
53
+ testID: testID ? `${testID}-badge` : undefined,
54
+ children: badgeText
55
+ }) : null, slow ? /*#__PURE__*/_jsx(View, {
56
+ style: styles.iconBadge,
57
+ testID: testID ? `${testID}-slow` : undefined,
58
+ children: /*#__PURE__*/_jsx(Clock, {
59
+ size: 12,
60
+ color: buoyColors.error
61
+ })
62
+ }) : changed ? /*#__PURE__*/_jsx(View, {
63
+ style: styles.iconBadge,
64
+ testID: testID ? `${testID}-change` : undefined,
65
+ children: /*#__PURE__*/_jsx(Zap, {
66
+ size: 12,
67
+ color: buoyColors.warning
68
+ })
69
+ }) : null]
70
+ }) : undefined);
71
+ return /*#__PURE__*/_jsx(CompactRow, {
72
+ statusDotColor: statusColor,
73
+ statusLabel: statusLabel,
74
+ statusSublabel: sublabel,
75
+ primaryText: primaryText,
76
+ bottomRightText: /*#__PURE__*/_jsx(RelativeTime, {
77
+ timestamp: timestamp
78
+ }),
79
+ customBadge: badge,
80
+ badgeText: badge ? undefined : plainBadgeText,
81
+ badgeColor: statusColor,
82
+ showChevron: true,
83
+ onPress: onPress,
84
+ testID: testID,
85
+ statusTestID: testID ? `${testID}-status` : undefined,
86
+ statusSublabelTestID: testID ? `${testID}-sublabel` : undefined,
87
+ primaryTestID: testID ? `${testID}-keys` : undefined,
88
+ accessibilityLabel: accessibilityLabel
89
+ });
90
+ }
91
+ const styles = StyleSheet.create({
92
+ badgeContainer: {
93
+ flexDirection: "row",
94
+ alignItems: "center",
95
+ gap: 4
96
+ },
97
+ badgeText: {
98
+ fontSize: 11,
99
+ fontWeight: "600",
100
+ fontFamily: "monospace"
101
+ },
102
+ iconBadge: {
103
+ paddingHorizontal: 4
104
+ }
105
+ });
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * ChipStrip — a horizontally scrolling row of filter chips whose taps
5
+ * don't misfire while the strip is being panned.
6
+ *
7
+ * react-query drew this three times (query status, mutation status, storage
8
+ * type) with the same 5-point / 300 ms swipe-vs-tap discrimination. The
9
+ * strip and the discrimination live here; the chip is whatever the tool
10
+ * renders, wired through `useChipTap`.
11
+ */
12
+
13
+ import { useCallback, useRef, useState } from "react";
14
+ import { ScrollView, StyleSheet, View } from "react-native";
15
+
16
+ /** How far a touch may travel and still count as a tap. */
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ const TAP_SLOP_PX = 5;
19
+ /** How long after a scroll ends taps stay suppressed. */
20
+ const SCROLL_SETTLE_MS = 300;
21
+ /**
22
+ * Swipe-vs-tap discrimination for chips inside a horizontal ScrollView.
23
+ * A press that moved more than a few points, or landed while the strip was
24
+ * still scrolling, is a pan — not a filter toggle.
25
+ */
26
+ export function useChipTap() {
27
+ const [isScrolling, setIsScrolling] = useState(false);
28
+ const touchStartX = useRef(0);
29
+ const touchStartY = useRef(0);
30
+ const onTouchStart = useCallback(event => {
31
+ touchStartX.current = event.nativeEvent.pageX;
32
+ touchStartY.current = event.nativeEvent.pageY;
33
+ }, []);
34
+ const isTap = useCallback(event => {
35
+ if (!event) return true;
36
+ const dx = Math.abs(event.nativeEvent.pageX - touchStartX.current);
37
+ const dy = Math.abs(event.nativeEvent.pageY - touchStartY.current);
38
+ return !(dx > TAP_SLOP_PX || dy > TAP_SLOP_PX || isScrolling);
39
+ }, [isScrolling]);
40
+ const settle = useCallback(() => {
41
+ setTimeout(() => setIsScrolling(false), SCROLL_SETTLE_MS);
42
+ }, []);
43
+ const begin = useCallback(() => setIsScrolling(true), []);
44
+ return {
45
+ scrollProps: {
46
+ onScrollBeginDrag: begin,
47
+ onScrollEndDrag: settle,
48
+ onMomentumScrollBegin: begin,
49
+ onMomentumScrollEnd: settle
50
+ },
51
+ onTouchStart,
52
+ isTap
53
+ };
54
+ }
55
+ export function ChipStrip({
56
+ children,
57
+ scrollProps,
58
+ sentryLabel,
59
+ style,
60
+ contentStyle
61
+ }) {
62
+ return /*#__PURE__*/_jsx(View, {
63
+ style: [styles.container, style],
64
+ children: /*#__PURE__*/_jsx(ScrollView, {
65
+ "sentry-label": sentryLabel,
66
+ horizontal: true,
67
+ showsHorizontalScrollIndicator: false,
68
+ style: styles.scrollView,
69
+ contentContainerStyle: [styles.scrollContent, contentStyle],
70
+ ...scrollProps,
71
+ children: children
72
+ })
73
+ });
74
+ }
75
+ const styles = StyleSheet.create({
76
+ container: {
77
+ flex: 1,
78
+ minWidth: 0
79
+ },
80
+ scrollView: {
81
+ flex: 1
82
+ },
83
+ scrollContent: {
84
+ flexDirection: "row",
85
+ alignItems: "center",
86
+ gap: 8,
87
+ paddingHorizontal: 4,
88
+ paddingVertical: 4,
89
+ flexGrow: 1
90
+ }
91
+ });
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * DetailViewToggle — the row of view cards at the top of a detail screen
5
+ * (ACTION · STATE · DIFF, CHANGE · STATE · DIFF, …).
6
+ *
7
+ * redux, zustand and jotai each shipped their own copy, differing only in
8
+ * the view keys, labels and testID prefix. The cards, the accent chrome,
9
+ * the disabled state (diff with nothing to compare) and the a11y contract
10
+ * are all one component now; tools pass their `views`.
11
+ */
12
+
13
+ import React, { memo } from "react";
14
+ import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
15
+ import { night } from "../night/nightTheme.js";
16
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
+ function DetailViewToggleImpl({
18
+ views,
19
+ activeView,
20
+ onViewChange,
21
+ disabledKeys,
22
+ testIDPrefix
23
+ }) {
24
+ return /*#__PURE__*/_jsx(View, {
25
+ style: styles.container,
26
+ children: views.map(view => {
27
+ const isActive = activeView === view.key;
28
+ const isDisabled = disabledKeys?.includes(view.key) ?? false;
29
+ const activeColor = view.activeColor ?? night.color.accent;
30
+ const IconComponent = view.icon;
31
+ return /*#__PURE__*/_jsxs(TouchableOpacity, {
32
+ style: [styles.card, isActive && [styles.cardActive, {
33
+ borderColor: activeColor
34
+ }], isDisabled && styles.cardDisabled],
35
+ onPress: () => !isDisabled && onViewChange(view.key),
36
+ activeOpacity: isDisabled ? 1 : 0.8,
37
+ disabled: isDisabled,
38
+ testID: testIDPrefix ? `${testIDPrefix}-view-${view.key}` : undefined,
39
+ accessibilityRole: "button",
40
+ accessibilityLabel: view.label,
41
+ accessibilityState: {
42
+ selected: isActive,
43
+ disabled: isDisabled
44
+ },
45
+ children: [/*#__PURE__*/_jsxs(View, {
46
+ style: styles.cardContent,
47
+ children: [/*#__PURE__*/_jsx(IconComponent, {
48
+ size: 14,
49
+ color: isActive ? activeColor : isDisabled ? night.color.textTertiary : night.color.textSecondary
50
+ }), /*#__PURE__*/_jsx(Text, {
51
+ style: [styles.cardLabel, isActive && [styles.cardLabelActive, {
52
+ color: activeColor
53
+ }], isDisabled && styles.cardLabelDisabled],
54
+ children: view.label
55
+ })]
56
+ }), view.description ? /*#__PURE__*/_jsx(Text, {
57
+ style: [styles.cardDescription, isActive && styles.cardDescriptionActive, isDisabled && styles.cardDescriptionDisabled],
58
+ children: view.description
59
+ }) : null]
60
+ }, view.key);
61
+ })
62
+ });
63
+ }
64
+ export const DetailViewToggle = /*#__PURE__*/memo(DetailViewToggleImpl);
65
+ const styles = StyleSheet.create({
66
+ container: {
67
+ flexDirection: "row",
68
+ gap: 8,
69
+ padding: 14,
70
+ // Transparent so the night sheet's star field shows through.
71
+ backgroundColor: "transparent"
72
+ },
73
+ card: {
74
+ flex: 1,
75
+ backgroundColor: night.color.surface,
76
+ borderRadius: 12,
77
+ borderWidth: 1,
78
+ borderColor: night.color.border,
79
+ padding: 10,
80
+ gap: 4
81
+ },
82
+ cardActive: {
83
+ borderWidth: 1.5,
84
+ backgroundColor: night.color.accentSoft,
85
+ shadowColor: night.color.accent,
86
+ shadowOffset: {
87
+ width: 0,
88
+ height: 2
89
+ },
90
+ shadowOpacity: 0.1,
91
+ shadowRadius: 8,
92
+ elevation: 3
93
+ },
94
+ cardDisabled: {
95
+ opacity: 0.5
96
+ },
97
+ cardContent: {
98
+ flexDirection: "row",
99
+ alignItems: "center",
100
+ gap: 6
101
+ },
102
+ cardLabel: {
103
+ fontSize: 10,
104
+ fontWeight: "700",
105
+ letterSpacing: 0.5,
106
+ color: night.color.textSecondary
107
+ },
108
+ cardLabelActive: {
109
+ color: night.color.text
110
+ },
111
+ cardLabelDisabled: {
112
+ color: night.color.textTertiary
113
+ },
114
+ cardDescription: {
115
+ fontSize: 9,
116
+ color: night.color.textTertiary,
117
+ lineHeight: 12
118
+ },
119
+ cardDescriptionActive: {
120
+ color: night.color.textSecondary
121
+ },
122
+ cardDescriptionDisabled: {
123
+ color: night.color.textTertiary
124
+ }
125
+ });
@@ -45,7 +45,8 @@ export function DevToolsCard({
45
45
  style,
46
46
  contentStyle,
47
47
  testID,
48
- accessibilityLabel
48
+ accessibilityLabel,
49
+ accessible
49
50
  }) {
50
51
  const isInteractive = !!onPress || !!onLongPress;
51
52
 
@@ -54,6 +55,7 @@ export function DevToolsCard({
54
55
  return /*#__PURE__*/_jsx(View, {
55
56
  style: [styles.wrapper, style],
56
57
  testID: testID,
58
+ accessible: accessible,
57
59
  accessibilityLabel: accessibilityLabel,
58
60
  children: /*#__PURE__*/_jsx(View, {
59
61
  style: [styles.card, isSelected && styles.selectedCard, contentStyle],