@delacour/react-native-ui 0.4.1-alpha.20261021072908 → 0.4.1-alpha.20261021114607
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/package.json +1 -1
- package/src/{lib/cn.parity.test.ts → cn.parity.test.ts} +3 -3
- package/src/components/accordion/AGENTS.md +2 -2
- package/src/components/accordion/accordion.variants.test.ts +1 -3
- package/src/components/accordion/accordion.variants.ts +4 -6
- package/src/components/alert/AGENTS.md +1 -1
- package/src/components/alert/alert-glyphs.ts +1 -1
- package/src/components/alert/alert.variants.test.ts +2 -3
- package/src/components/alert/alert.variants.ts +1 -2
- package/src/components/animated-badge/AGENTS.md +1 -1
- package/src/components/animated-badge/animated-badge-glyph.tsx +1 -1
- package/src/components/attachment/AGENTS.md +1 -1
- package/src/components/attachment/attachment.utils.ts +1 -1
- package/src/components/avatar/avatar.utils.ts +1 -1
- package/src/components/badge/AGENTS.md +1 -1
- package/src/components/badge/badge.variants.ts +2 -3
- package/src/components/bottom-sheet/AGENTS.md +1 -1
- package/src/components/breadcrumb/AGENTS.md +1 -1
- package/src/components/breadcrumb/breadcrumb.variants.test.ts +1 -4
- package/src/components/button/AGENTS.md +3 -3
- package/src/components/button/button-group-separator.tsx +1 -1
- package/src/components/button/button.variants.ts +11 -12
- package/src/components/card/AGENTS.md +1 -1
- package/src/components/card/card.variants.ts +1 -2
- package/src/components/carousel/carousel.variants.ts +1 -2
- package/src/components/chart/chart.variants.ts +4 -5
- package/src/components/checkbox/AGENTS.md +8 -9
- package/src/components/checkbox/checkbox.variants.ts +12 -14
- package/src/components/chip/chip.variants.ts +2 -2
- package/src/components/circular-text/circular-text.variants.ts +1 -1
- package/src/components/collapsible/AGENTS.md +2 -4
- package/src/components/collapsible/collapsible.variants.test.ts +1 -4
- package/src/components/collapsible/collapsible.variants.ts +1 -1
- package/src/components/color-picker/color-picker.color.ts +1 -1
- package/src/components/combobox/combobox.filter.ts +1 -1
- package/src/components/combobox/combobox.variants.ts +2 -3
- package/src/components/compare/AGENTS.md +1 -1
- package/src/components/context-menu/context-menu.variants.ts +1 -1
- package/src/components/date-time-picker/date-time-picker.value.ts +1 -1
- package/src/components/dialog/AGENTS.md +2 -2
- package/src/components/dialog/dialog.variants.ts +1 -1
- package/src/components/direction/AGENTS.md +3 -1
- package/src/components/direction/direction.variants.ts +2 -2
- package/src/components/drawer/AGENTS.md +3 -2
- package/src/components/empty-state/empty-state.variants.ts +1 -2
- package/src/components/fab/AGENTS.md +1 -1
- package/src/components/feedback/AGENTS.md +4 -4
- package/src/components/feedback/feedback.variants.ts +3 -3
- package/src/components/field/AGENTS.md +4 -4
- package/src/components/field/field.variants.ts +6 -8
- package/src/components/flip-card/AGENTS.md +2 -3
- package/src/components/frame/frame.variants.ts +1 -2
- package/src/components/grid-item/grid-item.layout.ts +1 -2
- package/src/components/icon/AGENTS.md +1 -1
- package/src/components/icon/icon.variants.ts +2 -3
- package/src/components/image-viewer/AGENTS.md +1 -1
- package/src/components/image-viewer/image-viewer.variants.ts +1 -2
- package/src/components/input/AGENTS.md +5 -6
- package/src/components/input/input-group.tsx +1 -2
- package/src/components/input/input.tsx +1 -1
- package/src/components/input/input.variants.ts +15 -15
- package/src/components/item/AGENTS.md +4 -3
- package/src/components/item/item.variants.ts +2 -2
- package/src/components/label/AGENTS.md +3 -3
- package/src/components/label/label.variants.ts +5 -5
- package/src/components/list-group/list-group.variants.ts +2 -2
- package/src/components/map/AGENTS.md +4 -4
- package/src/components/markdown-editor/AGENTS.md +1 -1
- package/src/components/marquee/AGENTS.md +1 -1
- package/src/components/menu/menu.variants.ts +1 -1
- package/src/components/message-scroller/message-scroller.utils.ts +2 -2
- package/src/components/number-input/AGENTS.md +1 -1
- package/src/components/number-input/number-input.format.ts +2 -2
- package/src/components/number-input/number-input.variants.ts +2 -2
- package/src/components/number-input/use-step-repeat.ts +1 -1
- package/src/components/otp-input/otp-input.logic.ts +1 -1
- package/src/components/otp-input/otp-input.variants.ts +3 -3
- package/src/components/overlay/AGENTS.md +1 -1
- package/src/components/page-header/page-header.utils.ts +1 -2
- package/src/components/pagination/pagination.variants.test.ts +1 -5
- package/src/components/planner/planner-dates.ts +1 -1
- package/src/components/popover/AGENTS.md +1 -1
- package/src/components/popover/popover.position.ts +1 -2
- package/src/components/post/AGENTS.md +3 -2
- package/src/components/post/post.utils.ts +2 -2
- package/src/components/post/post.variants.ts +2 -2
- package/src/components/pressable/pressable.variants.ts +4 -4
- package/src/components/progress/progress.variants.ts +2 -2
- package/src/components/provider/AGENTS.md +1 -1
- package/src/components/qr-code/AGENTS.md +5 -5
- package/src/components/qr-code/qr-code.constants.ts +1 -1
- package/src/components/qr-code/qr-code.path.ts +2 -2
- package/src/components/qr-code/qr-code.tables.ts +2 -2
- package/src/components/qr-code/qr-code.variants.ts +2 -2
- package/src/components/questionnaire/AGENTS.md +1 -1
- package/src/components/questionnaire/questionnaire.logic.ts +1 -1
- package/src/components/radio/AGENTS.md +6 -7
- package/src/components/radio/radio-indicator.tsx +2 -2
- package/src/components/radio/radio.tsx +1 -1
- package/src/components/radio/radio.variants.test.ts +1 -4
- package/src/components/radio/radio.variants.ts +6 -6
- package/src/components/rating/AGENTS.md +2 -2
- package/src/components/screen/AGENTS.md +1 -1
- package/src/components/screen/screen.variants.ts +9 -9
- package/src/components/scroll-canvas/AGENTS.md +1 -1
- package/src/components/scroll-canvas/scroll-canvas.variants.ts +2 -2
- package/src/components/scroll-fade/AGENTS.md +1 -1
- package/src/components/scroll-header/AGENTS.md +2 -2
- package/src/components/scroll-text/AGENTS.md +1 -1
- package/src/components/search-bar/search-bar.debounce.ts +2 -2
- package/src/components/search-bar/search-bar.variants.ts +2 -2
- package/src/components/section-progress/AGENTS.md +2 -2
- package/src/components/select/AGENTS.md +2 -1
- package/src/components/select/select.variants.ts +5 -5
- package/src/components/separator/AGENTS.md +1 -1
- package/src/components/separator/separator.tsx +3 -3
- package/src/components/signature/AGENTS.md +1 -1
- package/src/components/signature/signature.stroke.ts +1 -1
- package/src/components/skeleton/AGENTS.md +1 -1
- package/src/components/sketch/AGENTS.md +2 -2
- package/src/components/sketch/sketch.paths.ts +2 -2
- package/src/components/slider/AGENTS.md +2 -2
- package/src/components/slider/slider-fill.tsx +3 -3
- package/src/components/slider/slider.variants.ts +7 -7
- package/src/components/sortable/sortable.variants.test.ts +1 -4
- package/src/components/spinner/AGENTS.md +1 -1
- package/src/components/spinner/spinner.variants.ts +3 -3
- package/src/components/splitter/AGENTS.md +5 -6
- package/src/components/splitter/splitter.math.ts +1 -1
- package/src/components/steps/AGENTS.md +2 -2
- package/src/components/steps/steps.variants.test.ts +1 -5
- package/src/components/steps/steps.variants.ts +1 -1
- package/src/components/support/AGENTS.md +3 -2
- package/src/components/surface/surface.variants.test.ts +2 -3
- package/src/components/surface/surface.variants.ts +1 -1
- package/src/components/switch/AGENTS.md +1 -2
- package/src/components/switch/switch.tsx +2 -3
- package/src/components/switch/switch.variants.test.ts +1 -5
- package/src/components/switch/switch.variants.ts +5 -5
- package/src/components/tabs/AGENTS.md +2 -2
- package/src/components/tabs/tabs-label.tsx +1 -1
- package/src/components/tabs/tabs.variants.ts +2 -2
- package/src/components/tag-input/AGENTS.md +1 -1
- package/src/components/tag-input/tag-input.logic.ts +2 -2
- package/src/components/tag-input/tag-input.variants.ts +2 -2
- package/src/components/text/text.tsx +2 -2
- package/src/components/text/text.variants.ts +3 -3
- package/src/components/text-animation/AGENTS.md +4 -4
- package/src/components/textarea/AGENTS.md +2 -2
- package/src/components/textarea/textarea.variants.test.ts +1 -4
- package/src/components/textarea/textarea.variants.ts +6 -7
- package/src/components/theme-selector/theme-selector.logic.ts +1 -1
- package/src/components/theme-selector/theme-selector.variants.ts +1 -1
- package/src/components/time-picker/time-picker.time.ts +1 -1
- package/src/components/time-picker/time-picker.variants.ts +2 -2
- package/src/components/toast/AGENTS.md +2 -2
- package/src/components/toast/toast.timer.ts +1 -2
- package/src/components/toggle-button/toggle-button.variants.ts +3 -3
- package/src/components/tooltip/AGENTS.md +2 -2
- package/src/components/tree/tree.variants.test.ts +1 -4
- package/src/components/tree/tree.variants.ts +1 -1
- package/src/hooks/use-keyboard-state-sync.tsx +1 -1
- package/src/hooks/use-navigation-theme.ts +1 -1
- package/src/lib/cn.ts +1 -1
- package/src/lib/color.ts +2 -2
- package/src/lib/keyboard-animation.ts +2 -3
- package/src/lib/navigation-theme.ts +2 -3
- package/src/lib/paging.ts +1 -1
- package/src/lib/scroll-edges.ts +1 -1
- package/src/lib/scroll-maths.ts +2 -2
- package/src/lib/wrap-text-children.ts +1 -1
- package/src/styles/theme-tokens.test.ts +9 -2
- package/src/styles/theme.css +4 -5
- package/src/styles/tokens.css +1 -1
|
@@ -104,8 +104,8 @@ export function resolveItemRender(options: {
|
|
|
104
104
|
* No slot but the two text slots holds a `text-*` colour — a React Native
|
|
105
105
|
* `View` does not cascade one to a `Text`.
|
|
106
106
|
*
|
|
107
|
-
* Free of React Native imports so it stays unit-testable —
|
|
108
|
-
*
|
|
107
|
+
* Free of React Native imports so it stays unit-testable — it must not
|
|
108
|
+
* pull in React Native's Flow-typed source. See AGENTS.md.
|
|
109
109
|
*/
|
|
110
110
|
export const itemVariants = tv({
|
|
111
111
|
slots: {
|
|
@@ -60,9 +60,9 @@ component, no parts.
|
|
|
60
60
|
field's state, and it is **not** built on `Label`, because doing so would
|
|
61
61
|
change its public surface — `Label` narrows `children`, and a disabled `Label`
|
|
62
62
|
reports `accessibilityState.disabled`, which `Field.Label` does not. The two
|
|
63
|
-
must still read as one component, so `
|
|
64
|
-
|
|
65
|
-
`resolveFieldTextColor("label", …)`.
|
|
63
|
+
must still read as one component, so `resolveLabelColor` and the disabled
|
|
64
|
+
fade must match `fieldVariants`' label slot and
|
|
65
|
+
`resolveFieldTextColor("label", …)`. <!-- registry:omit -->`label.variants.test.ts` pins them; change one and the test names the other.<!-- /registry:omit -->
|
|
66
66
|
- **Inside a `Field`, `Label` is the way to say "required".** `Field.Label` has
|
|
67
67
|
no `isRequired`. Pass the field's state yourself —
|
|
68
68
|
`<Label isInvalid={isInvalid} isRequired>Email</Label>` — or read it in a
|
|
@@ -27,8 +27,8 @@ export const LABEL_REQUIRED_MARK_COLOR: TextColor = "destructive";
|
|
|
27
27
|
* Only the root fades. The mark is a run inside the root's text, so the root's
|
|
28
28
|
* opacity already reaches it; fading it again would square the fade.
|
|
29
29
|
*
|
|
30
|
-
* Free of React Native imports so it stays unit-testable —
|
|
31
|
-
*
|
|
30
|
+
* Free of React Native imports so it stays unit-testable — it must not
|
|
31
|
+
* pull in React Native's Flow-typed source. See AGENTS.md.
|
|
32
32
|
*/
|
|
33
33
|
export const labelVariants = tv({
|
|
34
34
|
slots: {
|
|
@@ -57,7 +57,7 @@ export const labelVariants = tv({
|
|
|
57
57
|
* `Text.Label`'s own `text-foreground` without this module knowing which token
|
|
58
58
|
* the preset chose.
|
|
59
59
|
*
|
|
60
|
-
* Pure, so the matrix is
|
|
60
|
+
* Pure, so the matrix is unit-testable. See AGENTS.md.
|
|
61
61
|
*/
|
|
62
62
|
export function resolveLabelColor(isInvalid: boolean): TextColor | undefined {
|
|
63
63
|
return isInvalid ? "destructive" : undefined;
|
|
@@ -74,7 +74,7 @@ export function resolveLabelColor(isInvalid: boolean): TextColor | undefined {
|
|
|
74
74
|
* screen reader's mouth the caller never wrote.
|
|
75
75
|
*
|
|
76
76
|
* Typed on `unknown` rather than `ReactNode` so this module takes not even a
|
|
77
|
-
* type import from React, which is what keeps it
|
|
77
|
+
* type import from React, which is what keeps it unit-testable.
|
|
78
78
|
*/
|
|
79
79
|
export function labelText(children: unknown): string | undefined {
|
|
80
80
|
const parts = Array.isArray(children) ? children : [children];
|
|
@@ -102,7 +102,7 @@ export function labelText(children: unknown): string | undefined {
|
|
|
102
102
|
* one whose children cannot be read as text, returns `undefined` and is left to
|
|
103
103
|
* the platform.
|
|
104
104
|
*
|
|
105
|
-
* Pure, so the matrix is
|
|
105
|
+
* Pure, so the matrix is unit-testable. See AGENTS.md.
|
|
106
106
|
*/
|
|
107
107
|
export function resolveLabelAccessibilityLabel({
|
|
108
108
|
accessibilityLabel,
|
|
@@ -38,8 +38,8 @@ export const LIST_GROUP_SUFFIX_ICON_TOKEN = "muted-foreground";
|
|
|
38
38
|
* `w-full` on the item matters because the root clips: without it a short row
|
|
39
39
|
* leaves the press feedback ending mid-card instead of spanning it.
|
|
40
40
|
*
|
|
41
|
-
* Free of React Native imports so it stays unit-testable —
|
|
42
|
-
*
|
|
41
|
+
* Free of React Native imports so it stays unit-testable — it must not
|
|
42
|
+
* pull in React Native's Flow-typed source. See AGENTS.md.
|
|
43
43
|
*/
|
|
44
44
|
export const listGroupVariants = tv({
|
|
45
45
|
slots: {
|
|
@@ -30,7 +30,7 @@ no directions.
|
|
|
30
30
|
| `map.variants.ts` | The slotted `tv()`, the axes, the pin outline, anchors, the themed basemap style — type imports only |
|
|
31
31
|
| `map.variants.test.ts` | |
|
|
32
32
|
|
|
33
|
-
`src/no-maplibre.test.ts`, one level up
|
|
33
|
+
<!-- registry:omit -->The import-graph rule below is pinned by `src/no-maplibre.test.ts`, one level up.<!-- /registry:omit -->
|
|
34
34
|
|
|
35
35
|
## Design
|
|
36
36
|
|
|
@@ -38,9 +38,9 @@ no directions.
|
|
|
38
38
|
import it.** It is the one native module the library adds for a single component.
|
|
39
39
|
Expo does not bundle it, so it is not in the root catalog; each workspace that
|
|
40
40
|
needs it repeats the range. An app that never imports `/map` never installs it —
|
|
41
|
-
but only while nothing else reaches it, so
|
|
42
|
-
whole tree as text and fails by file name
|
|
43
|
-
|
|
41
|
+
but only while nothing else reaches it, so no file outside this folder may import this folder, and none may import an
|
|
42
|
+
`@maplibre/` package. <!-- registry:omit -->`src/no-maplibre.test.ts` reads the whole tree as text and fails by file name
|
|
43
|
+
for either.<!-- /registry:omit --> Types come from the RN package's
|
|
44
44
|
own re-exports, never `@maplibre/maplibre-gl-style-spec`, which is only a
|
|
45
45
|
transitive dependency.
|
|
46
46
|
- **MapLibre over the platform maps.** Apple Maps takes no style beyond light and
|
|
@@ -35,7 +35,7 @@ parts.
|
|
|
35
35
|
thing that guards against.
|
|
36
36
|
- **Formatting is data in, data out.** `applyMarkdownCommand(text, selection,
|
|
37
37
|
command)` returns `{ text, selection }` and imports nothing from React
|
|
38
|
-
Native, so every rule below is
|
|
38
|
+
Native, so every rule below is unit-testable and the same on
|
|
39
39
|
both platforms. Each command is a list of splices applied in one pass, with
|
|
40
40
|
the selection's ends carried through the same list — no command works out by
|
|
41
41
|
hand how far an earlier insertion pushed the caret.
|
|
@@ -138,7 +138,7 @@ rotation re-resolving the copy count.
|
|
|
138
138
|
|
|
139
139
|
## Previews (follow-up)
|
|
140
140
|
|
|
141
|
-
No demo carries `capture` yet: a captured demo
|
|
141
|
+
No demo carries `capture` yet: a captured demo needs a manifest entry<!-- registry:omit --> (`demos.test.ts` fails without one)<!-- /registry:omit -->, and the
|
|
142
142
|
media are shot after integration. The five to capture, all `align: "stretch"` and all clips, each
|
|
143
143
|
with its flow already written under `.argent/flows/previews/marquee/`: `badges` (**hero**),
|
|
144
144
|
`two-rows`, `vertical`, `hold-to-pause`, `speed`. `cards` stays gallery-only. Add
|
|
@@ -281,7 +281,7 @@ export function resolveMenuItemAccessibility(input: MenuItemAccessibilityInput):
|
|
|
281
281
|
* `transform`, so a class opacity there is not overwritten.
|
|
282
282
|
*
|
|
283
283
|
* No slot worn by a `View` carries `text-*` (rule 1). Free of React Native
|
|
284
|
-
* imports so it stays
|
|
284
|
+
* imports so it stays unit-testable.
|
|
285
285
|
*/
|
|
286
286
|
export const menuVariants = tv({
|
|
287
287
|
slots: {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The pure decisions behind `MessageScroller`: how messages become rows, when the reader counts as
|
|
3
3
|
* "at the end", when the jump button shows, what counts as unread, when to ask for older history and
|
|
4
|
-
* what to announce. Free of React Native imports so
|
|
4
|
+
* what to announce. Free of React Native imports so every one of them is unit-testable.
|
|
5
5
|
*
|
|
6
6
|
* The scroll-position helpers carry a `"worklet"` directive because the jump button's visibility is
|
|
7
7
|
* resolved on the UI thread, inside the list's animated scroll handler. The directive is a string
|
|
8
|
-
* expression, so the same functions run unchanged
|
|
8
|
+
* expression, so the same functions run unchanged outside the UI thread.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -46,7 +46,7 @@ Root plus `NumberInput.Field`, `.Decrement` and `.Increment`, and
|
|
|
46
46
|
a test holds it.
|
|
47
47
|
- **Separators come from `format`, never `formatToParts`.** Hermes on iOS ships
|
|
48
48
|
`Intl.NumberFormat` without `formatToParts`; calling it threw on the first
|
|
49
|
-
keystroke on a simulator while
|
|
49
|
+
keystroke on a simulator while a JavaScriptCore unit test passed.
|
|
50
50
|
`readNumberSeparators` reads the runs between digits in a formatted
|
|
51
51
|
`11111.1` instead, with no regex lookbehind, and a test deletes
|
|
52
52
|
`formatToParts` to hold it.
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Every path into the value — a stepper tap, a held repeat, a committed draft,
|
|
5
5
|
* an accessibility action — funnels through {@link reconcile}, so a value can
|
|
6
6
|
* only ever be on the step grid, inside the bounds and at the precision. This
|
|
7
|
-
* module is the whole of that decision and imports nothing, so
|
|
8
|
-
*
|
|
7
|
+
* module is the whole of that decision and imports nothing, so every
|
|
8
|
+
* branch of it is unit-testable. See AGENTS.md.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/** A number input's value. `null` is empty — a field with nothing typed in it. */
|
|
@@ -36,8 +36,8 @@ export const NUMBER_INPUT_STEPPER_PRESSED_OPACITY = 0.5;
|
|
|
36
36
|
* edge rather than a button floating in a gutter. At `md` and `lg` that is 44pt
|
|
37
37
|
* and over; `sm` makes the rest up with {@link resolveStepperHitSlop}.
|
|
38
38
|
*
|
|
39
|
-
* Free of React Native imports so it stays unit-testable —
|
|
40
|
-
*
|
|
39
|
+
* Free of React Native imports so it stays unit-testable — it must not
|
|
40
|
+
* pull in React Native's Flow-typed source. See AGENTS.md.
|
|
41
41
|
*/
|
|
42
42
|
export const numberInputVariants = tv({
|
|
43
43
|
slots: {
|
|
@@ -18,7 +18,7 @@ export type StepRepeat = {
|
|
|
18
18
|
* {@link NUMBER_INPUT_REPEAT_DELAY_MS} and repeats on `resolveRepeatInterval`'s
|
|
19
19
|
* schedule until `stop`, until a tick answers `"stop"`, or until unmount. The
|
|
20
20
|
* schedule is pure and lives in `number-input.format.ts`; this hook owns only
|
|
21
|
-
* the timer, so the one thing
|
|
21
|
+
* the timer, so the one thing a unit test cannot reach is a `setTimeout`.
|
|
22
22
|
*
|
|
23
23
|
* `onTick` is read through a ref, so a tick always sees the latest render's
|
|
24
24
|
* value and bounds rather than the ones captured when the press began.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The pure half of `OtpInput`: what a keystroke, a paste or an autofill is allowed to leave in the
|
|
3
3
|
* field, which cell is active, when the code counts as complete, and what a screen reader hears.
|
|
4
4
|
*
|
|
5
|
-
* Free of React Native imports so
|
|
5
|
+
* Free of React Native imports so every decision is unit-testable — see AGENTS.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/** Which characters a cell takes. A `RegExp` tests one character at a time. */
|
|
@@ -37,8 +37,8 @@ export const OTP_MAX_FONT_SCALE = 1.5;
|
|
|
37
37
|
*
|
|
38
38
|
* A cell is a lone `Input` box cut square: the same `border-input bg-card` / `bg-secondary` per
|
|
39
39
|
* variant, the same `--spacing-input-*` edge and `--text-input-*` character, the same corner ramp
|
|
40
|
-
* (`rounded-md` at `sm`, `rounded-lg` above) and the same ring on focus.
|
|
41
|
-
*
|
|
40
|
+
* (`rounded-md` at `sm`, `rounded-lg` above) and the same ring on focus. The fill and border
|
|
41
|
+
* track `inputVariants` itself, so a retuned field drags the cells along.
|
|
42
42
|
*
|
|
43
43
|
* A cell is `w-input-*` **and** `shrink`. Twelve cells at `md` are wider than a phone; shrinking
|
|
44
44
|
* lets the row fit the space it is given, and a row that fits is worth more than a square corner
|
|
@@ -128,7 +128,7 @@ export type OtpSlotClasses = { slot: string; char: string; placeholder: string;
|
|
|
128
128
|
/**
|
|
129
129
|
* The four classes one cell draws with. A caller's `className` lands on the cell's box and wins.
|
|
130
130
|
*
|
|
131
|
-
* Pure, so the whole matrix is
|
|
131
|
+
* Pure, so the whole matrix is unit-testable.
|
|
132
132
|
*/
|
|
133
133
|
export function resolveOtpSlotClasses({
|
|
134
134
|
className,
|
|
@@ -84,6 +84,6 @@ imports an overlay never resolves it. The consequence is the same one thing to d
|
|
|
84
84
|
|
|
85
85
|
## Testing
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
The registry, the presence machine, the scrim token and the motion constants are pure and unit-tested.
|
|
88
88
|
The provider, the portal and the hooks are verified on a simulator through every overlay's
|
|
89
89
|
gallery — the foundation has no gallery of its own, the way `DelacourProvider` has none.
|
|
@@ -107,8 +107,7 @@ export function resolvePageHeaderCoverStops({
|
|
|
107
107
|
* whitespace — so the part can render nothing rather than leave a gap.
|
|
108
108
|
*
|
|
109
109
|
* A number is text, zero included. Anything else — an element — is taken at its
|
|
110
|
-
* word. Typed as `unknown` so it stays free of React's types and
|
|
111
|
-
* `bun test`.
|
|
110
|
+
* word. Typed as `unknown` so it stays free of React's types and unit-testable.
|
|
112
111
|
*/
|
|
113
112
|
export function isEmptyText(children: unknown): boolean {
|
|
114
113
|
if (children === undefined || children === null || typeof children === "boolean") return true;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import {
|
|
3
|
-
import { join } from "node:path";
|
|
2
|
+
import { THEME_CSS, TOKENS_CSS } from "../../styles/theme-tokens.test";
|
|
4
3
|
import {
|
|
5
4
|
clampPage,
|
|
6
5
|
formatCompact,
|
|
@@ -33,9 +32,6 @@ import {
|
|
|
33
32
|
shouldEmitPage,
|
|
34
33
|
} from "./pagination.variants";
|
|
35
34
|
|
|
36
|
-
const TOKENS_CSS = readFileSync(join(import.meta.dirname, "../../styles/tokens.css"), "utf-8");
|
|
37
|
-
const THEME_CSS = readFileSync(join(import.meta.dirname, "../../styles/theme.css"), "utf-8");
|
|
38
|
-
|
|
39
35
|
/** A slot's class string, with `tv`'s empty-slot `undefined` flattened. */
|
|
40
36
|
function cls(value: string | undefined): string {
|
|
41
37
|
return value ?? "";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The planner's month math — Gregorian, local-calendar, and free of React
|
|
3
|
-
* Native so
|
|
3
|
+
* Native so all of it is unit-testable.
|
|
4
4
|
*
|
|
5
5
|
* **A day is a `YYYY-MM-DD` key, never a timestamp.** Two `Date`s on one
|
|
6
6
|
* calendar day differ by hours, and a day is 23 or 25 hours long on a
|
|
@@ -132,7 +132,7 @@ half-initialised.
|
|
|
132
132
|
|
|
133
133
|
## Testing
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
The position resolver and the variants are pure and unit-tested. Everything else — the measure frame,
|
|
136
136
|
the motion, the keyboard, dismissal, focus — is verified on a simulator through
|
|
137
137
|
`apps/playground`'s `/popover` gallery, whose `edge-collision` demo puts triggers in the four
|
|
138
138
|
corners to prove flip and shift.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Where an anchored panel goes — pure, so the whole matrix is
|
|
3
|
-
* `bun test`.
|
|
2
|
+
* Where an anchored panel goes — pure, so the whole matrix is unit-testable.
|
|
4
3
|
*
|
|
5
4
|
* **A leaf.** Popover, Tooltip and, later, Menu and Select all import this
|
|
6
5
|
* file, so it imports nothing at all: never `./popover`, never `./index`.
|
|
@@ -27,7 +27,8 @@ animated. Compound root plus `Post.Header`, `Post.Author`, `Post.Community`, `Po
|
|
|
27
27
|
| `post.types.ts` | `PostSlotProps`, shared by `Header` and `Footer` |
|
|
28
28
|
| `post.variants.ts` | The slotted `tv()`, the layout/scrim/vote/tone/fill resolvers, no RN imports |
|
|
29
29
|
| `post.utils.ts` | `formatCompactCount`, `formatRelativeTime`, `tokenizePostBody` and the a11y label builders |
|
|
30
|
-
| `post.variants.test.ts
|
|
30
|
+
| `post.variants.test.ts` | |
|
|
31
|
+
| `post.utils.test.ts` | |
|
|
31
32
|
|
|
32
33
|
## Design
|
|
33
34
|
|
|
@@ -122,7 +123,7 @@ animated. Compound root plus `Post.Header`, `Post.Author`, `Post.Community`, `Po
|
|
|
122
123
|
|
|
123
124
|
## Previews (follow-up)
|
|
124
125
|
|
|
125
|
-
No demo carries `capture` yet: a captured demo
|
|
126
|
+
No demo carries `capture` yet: a captured demo needs a manifest entry<!-- registry:omit --> (`demos.test.ts` fails without one)<!-- /registry:omit -->, and
|
|
126
127
|
the media are shot after integration. The five to capture, all `align: "stretch"`: `feed-card`
|
|
127
128
|
(**hero**), `vote` (flow `post/vote` — tap `post-vote-up`, then again to clear), `compact-timeline`,
|
|
128
129
|
`media-first` and `live-counts` (flow `post/live-counts` — tap `post-like`, `post-repost`, then each
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Post's pure, non-styling logic — counts, times, the tokenised body and the
|
|
3
3
|
* spoken labels.
|
|
4
4
|
*
|
|
5
|
-
* Free of React Native imports so it stays unit-testable —
|
|
6
|
-
*
|
|
5
|
+
* Free of React Native imports so it stays unit-testable — it must not
|
|
6
|
+
* pull in React Native's Flow-typed source. See AGENTS.md.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const COMPACT_UNITS = [
|
|
@@ -190,8 +190,8 @@ export function resolveVoteKey(vote: PostVote): "up" | "down" | "none" {
|
|
|
190
190
|
* under it is what guarantees the contrast. Nothing else names a raw colour or
|
|
191
191
|
* a `dark:` variant.
|
|
192
192
|
*
|
|
193
|
-
* Free of React Native imports so it stays unit-testable —
|
|
194
|
-
*
|
|
193
|
+
* Free of React Native imports so it stays unit-testable — it must not
|
|
194
|
+
* pull in React Native's Flow-typed source. See AGENTS.md.
|
|
195
195
|
*/
|
|
196
196
|
export const postVariants = tv({
|
|
197
197
|
slots: {
|
|
@@ -18,8 +18,8 @@ export type PressedState = {
|
|
|
18
18
|
* There is no mode involving a ripple, ink or highlight overlay — AGENTS.md
|
|
19
19
|
* rules those out for every pressable in this library.
|
|
20
20
|
*
|
|
21
|
-
* Free of React Native imports so it stays unit-testable —
|
|
22
|
-
*
|
|
21
|
+
* Free of React Native imports so it stays unit-testable — it must not
|
|
22
|
+
* pull in React Native's Flow-typed source. See AGENTS.md.
|
|
23
23
|
*/
|
|
24
24
|
export const PRESSABLE_FEEDBACK: Record<PressableFeedback, PressedState> = {
|
|
25
25
|
scale: { opacity: 1, scale: 0.97 },
|
|
@@ -47,7 +47,7 @@ export const PRESSABLE_FEEDBACK_FALLBACK: PressedState = { opacity: 0.9, scale:
|
|
|
47
47
|
* `pressedOpacity={0.2}` is a deeper fade at the mode's scale rather than an
|
|
48
48
|
* all-or-nothing choice between the two APIs.
|
|
49
49
|
*
|
|
50
|
-
* Pure, so the whole matrix is
|
|
50
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
51
51
|
*/
|
|
52
52
|
export function resolvePressedState(
|
|
53
53
|
feedback: PressableFeedback | undefined,
|
|
@@ -72,7 +72,7 @@ export function resolvePressedState(
|
|
|
72
72
|
* types the value as animatable, so anything that is not a finite number is
|
|
73
73
|
* treated as unset, and a number is clamped into `[0, 1]`.
|
|
74
74
|
*
|
|
75
|
-
* Pure, so the whole matrix is
|
|
75
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
76
76
|
*/
|
|
77
77
|
export function resolveRestOpacity(resolved: unknown): number {
|
|
78
78
|
if (typeof resolved !== "number" || !Number.isFinite(resolved)) return 1;
|
|
@@ -80,8 +80,8 @@ export const PROGRESS_OUTPUT_TEXT_SIZE: Record<ProgressSize, TextSize> = { sm: "
|
|
|
80
80
|
* thinner than the slider's groove, because a bar you read is lighter than a
|
|
81
81
|
* groove you grab.
|
|
82
82
|
*
|
|
83
|
-
* Free of React Native imports so it stays unit-testable —
|
|
84
|
-
* React Native's Flow-typed source. See AGENTS.md.
|
|
83
|
+
* Free of React Native imports so it stays unit-testable — it must not
|
|
84
|
+
* pull in React Native's Flow-typed source. See AGENTS.md.
|
|
85
85
|
*/
|
|
86
86
|
export const progressVariants = tv({
|
|
87
87
|
slots: {
|
|
@@ -95,7 +95,7 @@ everything — a root layout, an `App.tsx`.
|
|
|
95
95
|
resolution error coming out of the app's root layout. Rule 3's promise is
|
|
96
96
|
per-subpath and survives intact: `/button` still pulls nothing
|
|
97
97
|
keyboard-related.
|
|
98
|
-
- **Nothing here for
|
|
98
|
+
- **Nothing here for a unit test, and no `provider.variants.ts` to give it
|
|
99
99
|
some.** The component is five nested elements and one default parameter;
|
|
100
100
|
extracting a `resolveInitialMetrics()` would be a unit test of `??`. The rule
|
|
101
101
|
that pure decisions live in a `*.variants.ts` has no decision here to
|
|
@@ -31,10 +31,10 @@ renderer can use.
|
|
|
31
31
|
| `qr-code.fixtures.ts` | **Test-only** golden matrices from an independent encoder |
|
|
32
32
|
| `qr-code.*.test.ts` | One per module: `gf`, `tables`, `format`, `matrix`, `mask`, `encode`, `logo`, `path`, `variants` |
|
|
33
33
|
|
|
34
|
-
Every `qr-code.*.ts` imports nothing from React or React Native, so
|
|
35
|
-
encoder and the path builder. Only `qr-code.tsx`, `qr-code-logo.tsx`, `qr-code.context.tsx` and
|
|
36
|
-
`use-qr-code.ts` touch React. The registry
|
|
37
|
-
|
|
34
|
+
Every `qr-code.*.ts` imports nothing from React or React Native, so the whole
|
|
35
|
+
encoder and the path builder are unit-testable. Only `qr-code.tsx`, `qr-code-logo.tsx`, `qr-code.context.tsx` and
|
|
36
|
+
`use-qr-code.ts` touch React. The registry ships `*.test-helpers.ts` and `*.fixtures.ts` with the
|
|
37
|
+
tests, in the item's `tests` — copied only by `delacour add qr-code --tests`.
|
|
38
38
|
|
|
39
39
|
## Design
|
|
40
40
|
|
|
@@ -124,7 +124,7 @@ The spec's vectors were written from memory, and three were wrong:
|
|
|
124
124
|
code (BCH(18,6)) does reach 8.
|
|
125
125
|
- **Mask 6 at (1, 1) is dark and mask 7 at (1, 1) is light**, by the standard's formulas.
|
|
126
126
|
|
|
127
|
-
The golden matrices in
|
|
127
|
+
The golden matrices in the test fixtures were generated once, offline, from an independent
|
|
128
128
|
encoder run from a throwaway script outside the repo — it is not a dependency. They cover numeric,
|
|
129
129
|
alphanumeric and byte modes, version 7 (version word) and 14, and a full 40-L symbol. The round-trip
|
|
130
130
|
test reads 192 generated payloads back through the reverse reader and requires zero syndromes and an
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The encoder's vocabulary — tuples, the matrix it produces and the errors it
|
|
3
3
|
* reports. Plain data with no React and no React Native, so every module in the
|
|
4
|
-
* encoder can import it and
|
|
4
|
+
* encoder can import it and all of them stay unit-testable.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/** Error-correction levels, weakest first: roughly 7%, 15%, 25% and 30% of codewords recoverable. */
|
|
@@ -2,8 +2,8 @@ import type { QrLogoRegion, QrMatrix } from "./qr-code.constants";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A matrix as one SVG `d` string, in module units with the quiet zone as an
|
|
5
|
-
* offset — the renderer scales it with a `viewBox`. Pure, so
|
|
6
|
-
*
|
|
5
|
+
* offset — the renderer scales it with a `viewBox`. Pure, so every module
|
|
6
|
+
* style is unit-testable.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
export const QR_MODULE_STYLES = ["square", "rounded", "dots"] as const;
|
|
@@ -6,8 +6,8 @@ import type { QrErrorCorrection, QrVersion } from "./qr-code.constants";
|
|
|
6
6
|
* Two 4 x 40 tables carry everything that cannot be derived: error-correction
|
|
7
7
|
* codewords per block and the number of blocks, per level and version. Every
|
|
8
8
|
* other count follows — total codewords from the module geometry, data
|
|
9
|
-
* codewords by subtraction, the block split by division.
|
|
10
|
-
*
|
|
9
|
+
* codewords by subtraction, the block split by division. Every pair
|
|
10
|
+
* must agree with those closed forms, which is the net for a typo here.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
export const QR_MIN_VERSION = 1;
|
|
@@ -3,8 +3,8 @@ import type { QrErrorCorrection } from "./qr-code.constants";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The tile's slots and every pure decision the root makes — size, quiet zone,
|
|
6
|
-
* level, label, the contrast guard. No React Native imports,
|
|
7
|
-
*
|
|
6
|
+
* level, label, the contrast guard. No React Native imports, all of it
|
|
7
|
+
* is unit-testable.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export const QR_SIZES = ["sm", "md", "lg"] as const;
|
|
@@ -41,7 +41,7 @@ Compound root plus `Questionnaire.Title`, `.Progress`, `.Question`, `.Footer`, `
|
|
|
41
41
|
`Separator` runs to the card's edges and each part pads itself. Unframed is a plain column
|
|
42
42
|
spaced by a gap, for a sheet or screen that already has a gutter.
|
|
43
43
|
- **All the decisions are in `questionnaire.logic.ts`, and it imports nothing but types.** That
|
|
44
|
-
is what
|
|
44
|
+
is what keeps every rule unit-testable — and lets a server import `getVisibleQuestions` and
|
|
45
45
|
`validateAnswer` to re-check a submission against the rules the device applied.
|
|
46
46
|
|
|
47
47
|
## Flow rules
|
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
* The questionnaire's whole flow, as pure functions.
|
|
15
15
|
*
|
|
16
16
|
* No React and no React Native: everything that decides what is shown, what is
|
|
17
|
-
* valid and where Next goes lives here so
|
|
17
|
+
* valid and where Next goes lives here so all of it is unit-testable — and so
|
|
18
18
|
* a server can import `getVisibleQuestions` and `validateAnswer` to re-check a
|
|
19
19
|
* submission against the same rules the device applied.
|
|
20
20
|
*/
|
|
@@ -50,7 +50,7 @@ sit in `radio.variants.ts` beside the pure resolver that reads them. See
|
|
|
50
50
|
not a change and a radio group has no deselect gesture, so without
|
|
51
51
|
`shouldEmitSelection` a tap on the current selection would re-notify the caller
|
|
52
52
|
with a value it already holds. HTML's own radio does not fire `change` there
|
|
53
|
-
either. The decision is pure, so
|
|
53
|
+
either. The decision is pure, so it is unit-testable.
|
|
54
54
|
- **The axis ladder is `group ?? own ?? field ?? default`, and it deliberately
|
|
55
55
|
puts the group *first*** — the inverse of `Checkbox`'s
|
|
56
56
|
`own ?? group ?? field ?? default`. A radio group puts itself first because
|
|
@@ -61,8 +61,8 @@ sit in `radio.variants.ts` beside the pure resolver that reads them. See
|
|
|
61
61
|
deliberately: a group holds many radios, so disabling one option out of five
|
|
62
62
|
has to be possible. A group that names the axis still wins outright, so
|
|
63
63
|
`isDisabled={false}` opts a radio out of a disabled `Field` and not out of a
|
|
64
|
-
disabled group. `resolveRadioState` is pure, so the whole matrix is
|
|
65
|
-
|
|
64
|
+
disabled group. `resolveRadioState` is pure, so the whole matrix is
|
|
65
|
+
unit-testable — [Input](../input/AGENTS.md) runs this same ladder inline in
|
|
66
66
|
its own render, where no unit test can see it.
|
|
67
67
|
- **`Radio` takes no `asChild`.** `Pressable`'s root `Animated.View` already owns
|
|
68
68
|
`opacity` and `transform` through a `useAnimatedStyle` of its own, and two
|
|
@@ -91,7 +91,7 @@ sit in `radio.variants.ts` beside the pure resolver that reads them. See
|
|
|
91
91
|
primitives; here the set has no ring-with-a-centred-dot glyph at all. Two
|
|
92
92
|
things follow from drawing it: the dot can scale from the ring's centre
|
|
93
93
|
entirely on the UI thread, and the ring's four themed colours stay classes in
|
|
94
|
-
`radio.variants.ts` where
|
|
94
|
+
`radio.variants.ts` where they stay unit-testable. An `Icon` would take its
|
|
95
95
|
colour as a resolved value, splitting one decision across two mechanisms.
|
|
96
96
|
- **The dot springs on `RADIO_DOT_SPRING`, deliberately near `Pressable`'s
|
|
97
97
|
`PRESS_SPRING` but a touch looser**, so it settles just after the row it sits
|
|
@@ -133,7 +133,7 @@ sit in `radio.variants.ts` beside the pure resolver that reads them. See
|
|
|
133
133
|
landed, and a test asserts a trailing row differs from a leading one by exactly
|
|
134
134
|
that one class. `resolveIndicatorPlacement` takes an array of "is this child an
|
|
135
135
|
indicator" rather than the children themselves, so it stays free of React and
|
|
136
|
-
|
|
136
|
+
unit-testable — the trade `resolveSpinnerSwapIndex` already makes.
|
|
137
137
|
- **Bare text is wrapped in a `Radio.Label`, consecutive strings collapsing into
|
|
138
138
|
one.** React Native cannot render a string outside a `<Text>`, so
|
|
139
139
|
`<Radio>Yes</Radio>` would otherwise crash. They collapse rather than wrapping
|
|
@@ -154,8 +154,7 @@ sit in `radio.variants.ts` beside the pure resolver that reads them. See
|
|
|
154
154
|
reported it because the duplicate overlaps invisibly rather than hiding
|
|
155
155
|
content — a second ring exactly behind the first — where the same bug in
|
|
156
156
|
`Switch` swallowed anything inside the caller's knob. `displayName` survives
|
|
157
|
-
all of it, rule 12 requires one, and `
|
|
158
|
-
that they are present and unique. Worth fixing the next time this file is
|
|
157
|
+
all of it, rule 12 requires one, and every component's `displayName` must be present and unique. Worth fixing the next time this file is
|
|
159
158
|
touched.
|
|
160
159
|
- **`Radio.Label` *is* `Text.Label`.** It renders the preset and names a size
|
|
161
160
|
step from `RADIO_LABEL_TEXT_SIZE`, never a scale, a weight or a colour of its
|
|
@@ -29,8 +29,8 @@ export type RadioIndicatorProps = Omit<ViewProps, "children"> & {
|
|
|
29
29
|
* `Spinner`'s arc is the precedent for primitives; here the set has no
|
|
30
30
|
* ring-with-a-centred-dot glyph at all. Two things follow from drawing it: the
|
|
31
31
|
* dot can scale from the ring's centre entirely on the UI thread, and the ring's
|
|
32
|
-
* four themed colours stay classes in `radio.variants.ts` where
|
|
33
|
-
*
|
|
32
|
+
* four themed colours stay classes in `radio.variants.ts` where
|
|
33
|
+
* they stay unit-testable. An `Icon` would take its colour as a resolved value, splitting
|
|
34
34
|
* one decision across two mechanisms.
|
|
35
35
|
*
|
|
36
36
|
* **The animated style lives on the dot, never on the ring.** `Pressable`'s root
|
|
@@ -134,7 +134,7 @@ function RadioRoot({
|
|
|
134
134
|
* which is what buys a settings row for free: place a `<Radio.Indicator />` last
|
|
135
135
|
* and the row lays out `[label and description] [ring]`, spread to the far edge,
|
|
136
136
|
* with nothing else said. {@link resolveIndicatorPlacement} is that decision and
|
|
137
|
-
* is pure, so
|
|
137
|
+
* is pure, so it is unit-testable.
|
|
138
138
|
*
|
|
139
139
|
* Lives here rather than with the parts: it is the root that wraps its own
|
|
140
140
|
* children, and importing it from a part would close a cycle. See AGENTS.md.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import {
|
|
3
|
-
import { join } from "node:path";
|
|
2
|
+
import { TOKENS_CSS } from "../../styles/theme-tokens.test";
|
|
4
3
|
import { ICON_SIZE_TOKENS } from "../../styles/tokens";
|
|
5
4
|
import { TEXT_SIZES } from "../text/text.variants";
|
|
6
5
|
import {
|
|
@@ -17,8 +16,6 @@ import {
|
|
|
17
16
|
shouldEmitSelection,
|
|
18
17
|
} from "./radio.variants";
|
|
19
18
|
|
|
20
|
-
const TOKENS_CSS = readFileSync(join(import.meta.dirname, "../../styles/tokens.css"), "utf-8");
|
|
21
|
-
|
|
22
19
|
/** Points behind a `--spacing-*` token, failing loudly rather than yielding NaN. */
|
|
23
20
|
function spacingPx(token: string): number {
|
|
24
21
|
const value = TOKENS_CSS.match(new RegExp(`--spacing-${token}:\\s*([\\d.]+)px;`))?.[1];
|
|
@@ -82,8 +82,8 @@ export const RADIO_LABEL_TEXT_SIZE: Record<RadioSize, TextSize> = { sm: "sm", md
|
|
|
82
82
|
* No slot worn by a `View` carries `text-*`, and the `label` slot carries no type
|
|
83
83
|
* scale, weight or colour at all — see {@link RADIO_LABEL_TEXT_SIZE}.
|
|
84
84
|
*
|
|
85
|
-
* Free of React Native imports so it stays unit-testable —
|
|
86
|
-
*
|
|
85
|
+
* Free of React Native imports so it stays unit-testable — it must not
|
|
86
|
+
* pull in React Native's Flow-typed source. See AGENTS.md.
|
|
87
87
|
*/
|
|
88
88
|
export const radioVariants = tv({
|
|
89
89
|
slots: {
|
|
@@ -91,7 +91,7 @@ export const radioVariants = tv({
|
|
|
91
91
|
group: "w-full",
|
|
92
92
|
/** The pressable row. Deliberately neither `self-start` nor `w-full`. */
|
|
93
93
|
root: "flex-row items-center",
|
|
94
|
-
/** The ring. Its colour is a class, so the whole matrix stays
|
|
94
|
+
/** The ring. Its colour is a class, so the whole matrix stays unit-testable. */
|
|
95
95
|
indicator: "items-center justify-center rounded-full border-2",
|
|
96
96
|
/** The inner dot. Its scale and opacity are an animated style, never a class. */
|
|
97
97
|
dot: "rounded-full bg-primary",
|
|
@@ -167,7 +167,7 @@ export const radioVariants = tv({
|
|
|
167
167
|
* between the two, which is the shape a caller would otherwise have to reach for.
|
|
168
168
|
*
|
|
169
169
|
* Takes an array of "is this child an indicator" rather than the children
|
|
170
|
-
* themselves, so it stays free of React and
|
|
170
|
+
* themselves, so it stays free of React and unit-testable — the trade
|
|
171
171
|
* `resolveSpinnerSwapIndex` already makes.
|
|
172
172
|
*/
|
|
173
173
|
export function resolveIndicatorPlacement(isIndicator: readonly boolean[]): "start" | "end" | "none" {
|
|
@@ -230,7 +230,7 @@ export type RadioState = {
|
|
|
230
230
|
* `value` inside a group can never be selected — the dev warning for that lives
|
|
231
231
|
* in `radio.tsx`, where the component name is available to name in the message.
|
|
232
232
|
*
|
|
233
|
-
* Pure, so the whole matrix is
|
|
233
|
+
* Pure, so the whole matrix is unit-testable. `Input` runs this same
|
|
234
234
|
* ladder inline in its own render, where no unit test can see it. See AGENTS.md.
|
|
235
235
|
*/
|
|
236
236
|
export function resolveRadioState({
|
|
@@ -262,7 +262,7 @@ export function resolveRadioState({
|
|
|
262
262
|
* re-notify the caller with a value it already holds. HTML's own radio does not
|
|
263
263
|
* fire `change` there either.
|
|
264
264
|
*
|
|
265
|
-
* Pure, so it is
|
|
265
|
+
* Pure, so it is unit-testable. See AGENTS.md.
|
|
266
266
|
*/
|
|
267
267
|
export function shouldEmitSelection(current: string | null, next: string): boolean {
|
|
268
268
|
return current !== next;
|