@marktiderman/genesis-ui-native 3.11.0 → 3.12.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.
Files changed (78) hide show
  1. package/README.md +69 -0
  2. package/dist/{chunk-ZUR4PK77.js → chunk-47CDRP43.js} +45 -166
  3. package/dist/chunk-47CDRP43.js.map +1 -0
  4. package/dist/{chunk-SG7LYX7Z.js → chunk-BQYT6TH2.js} +14 -6
  5. package/dist/chunk-BQYT6TH2.js.map +1 -0
  6. package/dist/{chunk-EAHK7D7N.js → chunk-C2ARUGT7.js} +146 -42
  7. package/dist/chunk-C2ARUGT7.js.map +1 -0
  8. package/dist/{chunk-VEWSY4TZ.js → chunk-D4UU6KIF.js} +236 -21
  9. package/dist/chunk-D4UU6KIF.js.map +1 -0
  10. package/dist/{chunk-GGH3ZQNO.js → chunk-TUDJDIGC.js} +4 -4
  11. package/dist/{chunk-GGH3ZQNO.js.map → chunk-TUDJDIGC.js.map} +1 -1
  12. package/dist/{chunk-PMS2V46D.js → chunk-VHUUOH46.js} +2 -2
  13. package/dist/{chunk-PMS2V46D.js.map → chunk-VHUUOH46.js.map} +1 -1
  14. package/dist/{chunk-IWWXERKQ.js → chunk-X5CPLUPZ.js} +1236 -136
  15. package/dist/chunk-X5CPLUPZ.js.map +1 -0
  16. package/dist/components/index.d.ts +510 -25
  17. package/dist/components/index.js +5 -5
  18. package/dist/data/index.d.ts +167 -33
  19. package/dist/data/index.js +1082 -760
  20. package/dist/data/index.js.map +1 -1
  21. package/dist/hooks/index.d.ts +2 -2
  22. package/dist/hooks/index.js +1 -1
  23. package/dist/icons/lucide.d.ts +1 -1
  24. package/dist/index.d.ts +6 -3
  25. package/dist/index.js +7 -7
  26. package/dist/layouts/index.d.ts +79 -6
  27. package/dist/layouts/index.js +5 -5
  28. package/dist/{native-modules-Bkm1jHO-.d.ts → native-modules-6JnyeGR-.d.ts} +55 -1
  29. package/package.json +70 -4
  30. package/src/components/__tests__/combobox.test.tsx +20 -0
  31. package/src/components/__tests__/number-input.test.tsx +112 -1
  32. package/src/components/__tests__/parity-controls.test.tsx +366 -0
  33. package/src/components/__tests__/parity-display.test.tsx +295 -0
  34. package/src/components/__tests__/twin-props.test.tsx +114 -0
  35. package/src/components/badge.tsx +3 -0
  36. package/src/components/button-group.tsx +50 -0
  37. package/src/components/calendar.tsx +183 -0
  38. package/src/components/carousel.tsx +175 -0
  39. package/src/components/chart.tsx +268 -0
  40. package/src/components/chip-group.tsx +34 -14
  41. package/src/components/choice-card.tsx +56 -19
  42. package/src/components/combobox.tsx +6 -5
  43. package/src/components/empty-state.tsx +40 -0
  44. package/src/components/flatten-children.ts +13 -0
  45. package/src/components/index.ts +49 -1
  46. package/src/components/inline-alert.tsx +3 -1
  47. package/src/components/input-group.tsx +99 -0
  48. package/src/components/input-otp.tsx +124 -0
  49. package/src/components/input.tsx +40 -12
  50. package/src/components/list-item.tsx +20 -4
  51. package/src/components/number-input.tsx +45 -15
  52. package/src/components/radio-group.tsx +5 -0
  53. package/src/components/resource.tsx +227 -0
  54. package/src/components/settings-row.tsx +194 -0
  55. package/src/components/slider.tsx +3 -9
  56. package/src/components/sortable-list.tsx +287 -0
  57. package/src/components/stat-card.tsx +106 -0
  58. package/src/components/stepper.tsx +4 -2
  59. package/src/components/widget-tile.tsx +66 -0
  60. package/src/components/workspace-switcher.tsx +217 -0
  61. package/src/data/NativeCustomView.tsx +117 -0
  62. package/src/data/NativeFormFields.tsx +312 -0
  63. package/src/data/NativeRecordPeek.tsx +130 -0
  64. package/src/data/NativeResourceFormField.tsx +32 -0
  65. package/src/data/__tests__/parity-data.test.tsx +350 -0
  66. package/src/data/index.ts +13 -0
  67. package/src/layouts/__tests__/keyboard-scroll.test.tsx +58 -2
  68. package/src/layouts/__tests__/notifications-page.test.tsx +12 -0
  69. package/src/layouts/index.ts +13 -0
  70. package/src/layouts/keyboard.tsx +22 -2
  71. package/src/layouts/notifications-page.tsx +13 -35
  72. package/src/layouts/pages.tsx +262 -0
  73. package/src/native-modules.tsx +37 -0
  74. package/dist/chunk-EAHK7D7N.js.map +0 -1
  75. package/dist/chunk-IWWXERKQ.js.map +0 -1
  76. package/dist/chunk-SG7LYX7Z.js.map +0 -1
  77. package/dist/chunk-VEWSY4TZ.js.map +0 -1
  78. package/dist/chunk-ZUR4PK77.js.map +0 -1
@@ -0,0 +1,227 @@
1
+ /**
2
+ * The resource workspace's pieces on the phone (a form, a course, a lesson): the twins of
3
+ * genesis-ui's `/resource` components, over the same genesis-core rules
4
+ * (`@marktiderman/genesis-core/resource`).
5
+ *
6
+ * - NativeReadinessChip: "Ready to publish", or how many problems to fix (`readinessChip`).
7
+ * - NativeHeadlineNumbers: a grid of headline numbers, two across (`HeadlineNumber`).
8
+ * - NativeSummaryCard: one card of a summary: an icon, a title, a line on the right, then the body.
9
+ * - NativeFollowUpList: responses that need a follow-up, with their tag, comment, low score and actions.
10
+ * - NativeResponsesToolbar: Summary / Each response, the host's filters and its actions.
11
+ *
12
+ * @stability Beta
13
+ */
14
+ import type { ReactNode } from "react";
15
+ import { Pressable, Text, View } from "react-native";
16
+ import { readinessChip, type ChipTone, type HeadlineNumber, type HeadlineTone, type Readiness, type ReadinessLabels } from "@marktiderman/genesis-core/resource";
17
+ import { NativeBadge } from "./badge";
18
+ import { NativeCard } from "./card";
19
+ import { NativeSegmentedControl } from "./segmented-control";
20
+ import { NativeSkeleton } from "./skeleton";
21
+ import { WidgetTile } from "./widget-tile";
22
+ import { cn } from "../utils";
23
+
24
+ /** A chip in one of the workspace's tones, on NativeBadge's tints (as the web's Chip on Badge). */
25
+ function ToneChip({ tone, children, testID }: { tone: ChipTone; children: ReactNode; testID?: string | undefined }) {
26
+ return (
27
+ <NativeBadge variant={tone} testID={testID}>
28
+ {children}
29
+ </NativeBadge>
30
+ );
31
+ }
32
+
33
+ export interface NativeReadinessChipProps {
34
+ readiness: Readiness;
35
+ labels?: ReadinessLabels;
36
+ /** Makes it a button (open the checks). */
37
+ onPress?: () => void;
38
+ className?: string;
39
+ }
40
+
41
+ export function NativeReadinessChip({ readiness, labels, onPress, className }: NativeReadinessChipProps) {
42
+ const { label, tone } = readinessChip(readiness, labels);
43
+ const mark = readiness.state === "ready" ? "✓ " : readiness.state === "problems" ? "! " : readiness.state === "warnings" ? "⚠ " : "";
44
+ const chip = (
45
+ <View className={className}>
46
+ <ToneChip tone={tone} testID="readiness">
47
+ {`${mark}${label}`}
48
+ </ToneChip>
49
+ </View>
50
+ );
51
+ if (!onPress) return chip;
52
+ return (
53
+ <Pressable accessibilityRole="button" accessibilityLabel={label} onPress={onPress} hitSlop={8} className="self-start">
54
+ {chip}
55
+ </Pressable>
56
+ );
57
+ }
58
+
59
+ const HEADLINE_TONE: Record<HeadlineTone, string> = {
60
+ positive: "text-emerald-700 dark:text-emerald-300",
61
+ negative: "text-red-700 dark:text-red-300",
62
+ warning: "text-amber-800 dark:text-amber-200",
63
+ muted: "text-muted-foreground",
64
+ };
65
+
66
+ export interface NativeHeadlineNumbersProps {
67
+ numbers: readonly HeadlineNumber[];
68
+ isLoading?: boolean;
69
+ className?: string;
70
+ }
71
+
72
+ export function NativeHeadlineNumbers({ numbers, isLoading = false, className }: NativeHeadlineNumbersProps) {
73
+ if (isLoading) {
74
+ return (
75
+ <View className={cn("flex-row flex-wrap gap-3", className)} testID="headline-numbers-loading">
76
+ {[0, 1, 2, 3].map((i) => (
77
+ <View key={i} className="min-w-[45%] flex-1">
78
+ <NativeSkeleton height={112} className="w-full rounded-lg" />
79
+ </View>
80
+ ))}
81
+ </View>
82
+ );
83
+ }
84
+ if (!numbers.length) return null;
85
+ return (
86
+ <View className={cn("flex-row flex-wrap gap-3", className)} testID="headline-numbers">
87
+ {numbers.map((n) => (
88
+ <View key={n.key} className="min-w-[45%] flex-1">
89
+ <WidgetTile
90
+ variant="headline"
91
+ label={n.label}
92
+ value={n.value}
93
+ detail={n.detail}
94
+ detailClassName={HEADLINE_TONE[n.tone ?? "muted"]}
95
+ testID={`headline-${n.key}`}
96
+ />
97
+ </View>
98
+ ))}
99
+ </View>
100
+ );
101
+ }
102
+
103
+ export interface NativeSummaryCardProps {
104
+ icon?: ReactNode;
105
+ title: string;
106
+ meta?: ReactNode;
107
+ children?: ReactNode;
108
+ className?: string;
109
+ testID?: string;
110
+ }
111
+
112
+ export function NativeSummaryCard({ icon, title, meta, children, className, testID }: NativeSummaryCardProps) {
113
+ return (
114
+ <WidgetTile variant="summary" label={title} icon={icon} meta={meta} className={className} testID={testID}>
115
+ {children}
116
+ </WidgetTile>
117
+ );
118
+ }
119
+
120
+ /** One item in the follow-up list, as the host describes it (the web's `FollowUpEntry`). */
121
+ export interface NativeFollowUpEntry {
122
+ id: string;
123
+ name: string;
124
+ tag?: { label: string; tone?: ChipTone | undefined } | undefined;
125
+ meta?: string | undefined;
126
+ comment?: string | null | undefined;
127
+ rating?: { value: number; max: number } | null | undefined;
128
+ }
129
+
130
+ export interface NativeFollowUpListProps {
131
+ entries: readonly NativeFollowUpEntry[];
132
+ actions?: (entry: NativeFollowUpEntry) => ReactNode;
133
+ title?: string;
134
+ isLoading?: boolean;
135
+ empty?: string;
136
+ noComment?: string;
137
+ className?: string;
138
+ }
139
+
140
+ export function NativeFollowUpList({
141
+ entries,
142
+ actions,
143
+ title = "Needs a follow-up",
144
+ isLoading = false,
145
+ empty = "Nothing to follow up right now.",
146
+ noComment = "No comment",
147
+ className,
148
+ }: NativeFollowUpListProps) {
149
+ return (
150
+ <NativeCard className={cn("gap-3 p-4", className)} testID="follow-up-list">
151
+ <View className="flex-row items-center justify-between gap-2">
152
+ <Text accessibilityRole="header" className="text-base font-semibold text-foreground">
153
+ ⚠ {title}
154
+ </Text>
155
+ {!isLoading ? (
156
+ <NativeBadge variant="muted" accessibilityLabel={`${entries.length}`}>
157
+ {String(entries.length)}
158
+ </NativeBadge>
159
+ ) : null}
160
+ </View>
161
+ {isLoading ? (
162
+ <>
163
+ <NativeSkeleton height={96} className="w-full rounded-md" />
164
+ <NativeSkeleton height={96} className="w-full rounded-md" />
165
+ </>
166
+ ) : entries.length === 0 ? (
167
+ <Text className="text-sm text-muted-foreground">✓ {empty}</Text>
168
+ ) : (
169
+ entries.map((entry) => {
170
+ const buttons = actions?.(entry);
171
+ return (
172
+ <View key={entry.id} testID={`follow-up-${entry.id}`} className="gap-1.5 rounded-md border border-border p-3">
173
+ <View className="flex-row items-start justify-between gap-2">
174
+ <View className="min-w-0 flex-1 flex-row flex-wrap items-center gap-2">
175
+ <Text className="font-medium text-foreground">{entry.name}</Text>
176
+ {entry.tag ? <ToneChip tone={entry.tag.tone ?? "muted"}>{entry.tag.label}</ToneChip> : null}
177
+ </View>
178
+ {entry.rating ? (
179
+ <Text
180
+ accessibilityLabel={`Rated ${entry.rating.value} out of ${entry.rating.max}`}
181
+ className="text-sm font-medium text-amber-800 dark:text-amber-200"
182
+ >
183
+ {entry.rating.value} ★
184
+ </Text>
185
+ ) : null}
186
+ </View>
187
+ {entry.meta ? <Text className="text-xs text-muted-foreground">{entry.meta}</Text> : null}
188
+ <Text numberOfLines={3} className={cn("text-sm", entry.comment ? "text-foreground" : "text-muted-foreground")}>
189
+ {entry.comment || noComment}
190
+ </Text>
191
+ {buttons ? <View className="mt-1 flex-row flex-wrap gap-2">{buttons}</View> : null}
192
+ </View>
193
+ );
194
+ })
195
+ )}
196
+ </NativeCard>
197
+ );
198
+ }
199
+
200
+ export type NativeResponsesView = "summary" | "each";
201
+
202
+ export interface NativeResponsesToolbarProps {
203
+ view: NativeResponsesView;
204
+ onViewChange: (view: NativeResponsesView) => void;
205
+ filters?: ReactNode;
206
+ actions?: ReactNode;
207
+ labels?: { summary?: string; each?: string };
208
+ className?: string;
209
+ }
210
+
211
+ export function NativeResponsesToolbar({ view, onViewChange, filters, actions, labels = {}, className }: NativeResponsesToolbarProps) {
212
+ return (
213
+ <View className={cn("gap-2", className)} testID="responses-toolbar">
214
+ <NativeSegmentedControl<NativeResponsesView>
215
+ testID="responses-view"
216
+ options={[
217
+ { value: "summary", label: labels.summary ?? "Summary" },
218
+ { value: "each", label: labels.each ?? "Each response" },
219
+ ]}
220
+ value={view}
221
+ onChange={onViewChange}
222
+ />
223
+ {filters ? <View className="flex-row flex-wrap items-center gap-2">{filters}</View> : null}
224
+ {actions ? <View className="flex-row flex-wrap items-center gap-2">{actions}</View> : null}
225
+ </View>
226
+ );
227
+ }
@@ -0,0 +1,194 @@
1
+ /**
2
+ * SettingsRow — a label and a description with a control at the end: the twin of genesis-ui's
3
+ * SettingsRow. It is a NativeListItem (the phone's row), with the control in its trailing slot.
4
+ *
5
+ * ToggleRow — a SettingsRow with a switch: the twin of genesis-ui's ToggleRow. The whole row
6
+ * flips the switch and is one `switch` to a screen reader (its label, description and state), as
7
+ * the iOS Settings app's rows are.
8
+ *
9
+ * ResourceSettingsPage — every setting of one thing (a form, a course) as cards with icons, and a
10
+ * row of jump links that scroll to each: the twin of genesis-ui's ResourceSettingsPage. Its
11
+ * sections take the same `id`, `title`, `icon`, `description` and `content`.
12
+ *
13
+ * @stability Beta
14
+ */
15
+ import { useRef, useState, type ReactNode } from "react";
16
+ import { Pressable, ScrollView, Text, View } from "react-native";
17
+ import { NativeCard } from "./card";
18
+ import { flattenChildren } from "./flatten-children";
19
+ import { NativeListItem, NativeListItemDivider } from "./list-item";
20
+ import { NativeSwitch } from "./switch";
21
+ import { cn } from "../utils";
22
+
23
+ export interface NativeSettingsRowProps {
24
+ label: string;
25
+ description?: string;
26
+ /** The control at the end: a NativeSwitch, a NativeSelect trigger, a NativeBadge, a NativeButton. */
27
+ children?: ReactNode;
28
+ /** Makes the row a button (a row that opens a sub-page). */
29
+ onPress?: () => void;
30
+ /** The drill-in chevron, for a row that opens a sub-page. */
31
+ showChevron?: boolean;
32
+ disabled?: boolean;
33
+ className?: string;
34
+ testID?: string;
35
+ }
36
+
37
+ export function NativeSettingsRow({ label, description, children, onPress, showChevron, disabled, className, testID = "settings-row" }: NativeSettingsRowProps) {
38
+ return (
39
+ <NativeListItem
40
+ title={label}
41
+ subtitle={description}
42
+ trailing={children}
43
+ onPress={onPress}
44
+ showChevron={showChevron}
45
+ disabled={disabled}
46
+ className={cn(disabled && !onPress && "opacity-50", className)}
47
+ testID={testID}
48
+ />
49
+ );
50
+ }
51
+
52
+ export interface NativeToggleRowProps {
53
+ label: string;
54
+ description?: string;
55
+ checked?: boolean;
56
+ defaultChecked?: boolean;
57
+ onCheckedChange?: (checked: boolean) => void;
58
+ disabled?: boolean;
59
+ className?: string;
60
+ /** On the switch, as on the web. */
61
+ testID?: string;
62
+ rowTestID?: string;
63
+ }
64
+
65
+ export function NativeToggleRow({ label, description, checked: checkedProp, defaultChecked = false, onCheckedChange, disabled, className, testID = "toggle-row-switch", rowTestID = "toggle-row" }: NativeToggleRowProps) {
66
+ const [checkedState, setCheckedState] = useState(defaultChecked);
67
+ const checked = checkedProp ?? checkedState;
68
+ const set = (next: boolean) => {
69
+ if (disabled) return;
70
+ if (checkedProp === undefined) setCheckedState(next);
71
+ onCheckedChange?.(next);
72
+ };
73
+ return (
74
+ <NativeListItem
75
+ title={label}
76
+ subtitle={description}
77
+ onPress={() => set(!checked)}
78
+ disabled={disabled}
79
+ accessibilityRole="switch"
80
+ accessibilityState={{ checked }}
81
+ className={className}
82
+ testID={rowTestID}
83
+ trailing={
84
+ // The row is the switch for a screen reader; the control itself is hidden from it.
85
+ <View accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
86
+ <NativeSwitch testID={testID} checked={checked} onCheckedChange={set} disabled={disabled} />
87
+ </View>
88
+ }
89
+ />
90
+ );
91
+ }
92
+
93
+ /** One section of a NativeResourceSettingsPage (the web's `ResourceSettingsSection`). */
94
+ export interface NativeResourceSettingsSection {
95
+ id: string;
96
+ title: string;
97
+ icon?: ReactNode;
98
+ description?: string;
99
+ /** The rows (NativeSettingsRow, NativeToggleRow). Absent: a jump link only, with `onSelect`. */
100
+ content?: ReactNode;
101
+ onSelect?: () => void;
102
+ }
103
+
104
+ export interface NativeResourceSettingsPageProps {
105
+ sections: readonly NativeResourceSettingsSection[];
106
+ /** The jump links' accessible name. Default "On this page". */
107
+ navLabel?: string;
108
+ className?: string;
109
+ testID?: string;
110
+ }
111
+
112
+ export function NativeResourceSettingsPage({ sections, navLabel = "On this page", className, testID = "resource-settings-page" }: NativeResourceSettingsPageProps) {
113
+ const scroll = useRef<{ scrollTo?: (to: { x?: number; y?: number; animated?: boolean }) => void } | null>(null);
114
+ const offsets = useRef(new Map<string, number>());
115
+ const [active, setActive] = useState(sections[0]?.id);
116
+
117
+ const jump = (s: NativeResourceSettingsSection) => {
118
+ setActive(s.id);
119
+ if (s.content === undefined) {
120
+ s.onSelect?.();
121
+ return;
122
+ }
123
+ scroll.current?.scrollTo?.({ y: offsets.current.get(s.id) ?? 0, animated: true });
124
+ };
125
+
126
+ return (
127
+ <ScrollView
128
+ ref={scroll}
129
+ testID={testID}
130
+ className={cn("flex-1", className)}
131
+ contentContainerClassName="gap-4 p-4"
132
+ contentInsetAdjustmentBehavior="automatic"
133
+ onScroll={(e: { nativeEvent: { contentOffset: { y: number } } }) => {
134
+ const y = e.nativeEvent.contentOffset.y + 24;
135
+ let current = sections[0]?.id;
136
+ for (const s of sections) if ((offsets.current.get(s.id) ?? Infinity) <= y) current = s.id;
137
+ if (current !== active) setActive(current);
138
+ }}
139
+ scrollEventThrottle={64}
140
+ >
141
+ <ScrollView horizontal showsHorizontalScrollIndicator={false} accessibilityLabel={navLabel} contentContainerClassName="gap-2">
142
+ {sections.map((s) => (
143
+ <Pressable
144
+ key={s.id}
145
+ testID={`${testID}-link-${s.id}`}
146
+ accessibilityRole="link"
147
+ accessibilityState={{ selected: active === s.id }}
148
+ onPress={() => jump(s)}
149
+ className={cn("min-h-[36px] flex-row items-center gap-2 rounded-md px-3", active === s.id ? "bg-muted" : "bg-transparent")}
150
+ >
151
+ {s.icon ? <View accessibilityElementsHidden>{s.icon}</View> : null}
152
+ <Text className={cn("text-sm", active === s.id ? "font-medium text-foreground" : "text-muted-foreground")}>{s.title}</Text>
153
+ </Pressable>
154
+ ))}
155
+ </ScrollView>
156
+ {sections
157
+ .filter((s) => s.content !== undefined)
158
+ .map((s) => (
159
+ <View
160
+ key={s.id}
161
+ onLayout={(e: { nativeEvent?: { layout?: { y?: number } } }) => offsets.current.set(s.id, e.nativeEvent?.layout?.y ?? 0)}
162
+ >
163
+ <NativeCard testID={`${testID}-section-${s.id}`} className="overflow-hidden">
164
+ <View className="flex-row gap-3 border-b border-border px-4 py-3">
165
+ {s.icon ? <View className="mt-0.5" accessibilityElementsHidden>{s.icon}</View> : null}
166
+ <View className="min-w-0 flex-1">
167
+ <Text accessibilityRole="header" className="text-base font-semibold text-foreground">
168
+ {s.title}
169
+ </Text>
170
+ {s.description ? <Text className="text-sm text-muted-foreground">{s.description}</Text> : null}
171
+ </View>
172
+ </View>
173
+ <SectionRows>{s.content}</SectionRows>
174
+ </NativeCard>
175
+ </View>
176
+ ))}
177
+ </ScrollView>
178
+ );
179
+ }
180
+
181
+ /** The section's rows with a line between each, as the web's divided card. */
182
+ function SectionRows({ children }: { children: ReactNode }) {
183
+ const rows = flattenChildren(children);
184
+ return (
185
+ <View>
186
+ {rows.map((row, i) => (
187
+ <View key={i}>
188
+ {i > 0 ? <NativeListItemDivider /> : null}
189
+ {row}
190
+ </View>
191
+ ))}
192
+ </View>
193
+ );
194
+ }
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import { useMemo, useRef, useState } from "react";
15
15
  import { PanResponder, View } from "react-native";
16
+ import { snapToStep } from "@marktiderman/genesis-core/headless";
16
17
  import { cn } from "../utils";
17
18
 
18
19
  interface BaseProps {
@@ -31,15 +32,8 @@ export interface NativeSliderProps extends BaseProps {
31
32
  onChange: (value: number) => void;
32
33
  }
33
34
 
34
- function snap(v: number, step: number, min: number, max: number) {
35
- const clamped = Math.min(max, Math.max(min, v));
36
- if (step <= 0) return clamped;
37
- // Snap relative to `min` so non-zero starts (e.g. min=1, step=2 → 1,3,5,...)
38
- // produce the correct discrete grid. Then re-clamp because the stepped
39
- // value can exceed max when (max - min) is not a multiple of step.
40
- const stepped = Math.round((clamped - min) / step) * step + min;
41
- return Math.min(max, Math.max(min, stepped));
42
- }
35
+ // The grid a thumb snaps to is genesis-core's, as the web's RangeSlider and NumberInput use.
36
+ const snap = snapToStep;
43
37
 
44
38
  function useTrackWidth() {
45
39
  const [width, setWidth] = useState(0);