@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
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@ import { describe, expect, test } from "bun:test";
|
|
|
2
2
|
import { readdirSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { extendTailwindMerge } from "tailwind-merge";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { cn } from "./lib/cn";
|
|
6
|
+
import { type CustomClassGroupId, TW_MERGE_CONFIG } from "./styles/tokens";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* `cn` against the tailwind-merge it replaced, on this library's own classes.
|
|
@@ -26,7 +26,7 @@ function variantFiles(dir: string): string[] {
|
|
|
26
26
|
|
|
27
27
|
const literals = [
|
|
28
28
|
...new Set(
|
|
29
|
-
variantFiles(join(import.meta.dir, "
|
|
29
|
+
variantFiles(join(import.meta.dir, "components")).flatMap((file) =>
|
|
30
30
|
[...readFileSync(file, "utf8").matchAll(/"([a-z0-9!:[\]/.\-_% ]+)"/g)]
|
|
31
31
|
.map((match) => match[1] ?? "")
|
|
32
32
|
.filter((value) => value.includes("-"))
|
|
@@ -102,8 +102,8 @@ a list of rows.
|
|
|
102
102
|
`onLayout` that wrote the height, can read `ACCORDION_UNMEASURED`. A Release
|
|
103
103
|
build does, deterministically: the effect bailed, nothing re-ran it, and the
|
|
104
104
|
panel reported `expanded` while never opening (a Debug client is slow enough
|
|
105
|
-
for the write to land first, which is why it hid)
|
|
106
|
-
sweeps both files for such a read outside `useAnimatedStyle
|
|
105
|
+
for the write to land first, which is why it hid).<!-- registry:omit --> `accordion.variants.test.ts`
|
|
106
|
+
sweeps both files for such a read outside `useAnimatedStyle`.<!-- /registry:omit -->
|
|
107
107
|
- **`ACCORDION_UNMEASURED` is negative, and that is load-bearing.** A panel that
|
|
108
108
|
measured `0` is a real answer — content that rendered nothing — and must still
|
|
109
109
|
open, indicator and all. Only a value no layout can produce can mean
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { declarationCount } from "../../styles/theme-tokens.test";
|
|
4
|
+
import { declarationCount, TOKENS_CSS } from "../../styles/theme-tokens.test";
|
|
5
5
|
import { ICON_SIZES } from "../icon/icon.variants";
|
|
6
6
|
import {
|
|
7
7
|
ACCORDION_CONTENT_FADE,
|
|
@@ -24,8 +24,6 @@ import {
|
|
|
24
24
|
toggleExpandedValue,
|
|
25
25
|
} from "./accordion.variants";
|
|
26
26
|
|
|
27
|
-
const TOKENS_CSS = readFileSync(join(import.meta.dirname, "../../styles/tokens.css"), "utf-8");
|
|
28
|
-
|
|
29
27
|
/** The minimum a touch target may be, in points. Apple's number, and Android's. */
|
|
30
28
|
const MINIMUM_TARGET = 44;
|
|
31
29
|
|
|
@@ -174,8 +174,7 @@ export const ACCORDION_CONTENT_FADE = { start: 0.1, end: 0.6 } as const;
|
|
|
174
174
|
* cascade colour to a `Text` descendant, so the treatment lives on the `title` and
|
|
175
175
|
* `description` slots. See AGENTS.md rule 1.
|
|
176
176
|
*
|
|
177
|
-
* Free of React Native imports so it stays unit-testable
|
|
178
|
-
* React Native's Flow-typed source. See AGENTS.md.
|
|
177
|
+
* Free of React Native imports so it stays pure and unit-testable. See AGENTS.md.
|
|
179
178
|
*/
|
|
180
179
|
export const accordionVariants = tv({
|
|
181
180
|
slots: {
|
|
@@ -283,8 +282,7 @@ export type AccordionMultipleSelection = {
|
|
|
283
282
|
* rather than a union of functions.
|
|
284
283
|
*
|
|
285
284
|
* Lives here rather than in `accordion.types.ts` because that file imports React
|
|
286
|
-
* Native's `ViewProps`, and the root's selection maths has to stay
|
|
287
|
-
* `bun test`.
|
|
285
|
+
* Native's `ViewProps`, and the root's selection maths has to stay unit-testable.
|
|
288
286
|
*/
|
|
289
287
|
export type AccordionSelection = AccordionSingleSelection | AccordionMultipleSelection;
|
|
290
288
|
|
|
@@ -312,7 +310,7 @@ export function toExpandedList(value: string | readonly string[] | null | undefi
|
|
|
312
310
|
/**
|
|
313
311
|
* The whole state transition a tap on a trigger makes.
|
|
314
312
|
*
|
|
315
|
-
* Pure, so
|
|
313
|
+
* Pure, so the entire matrix is unit-testable — the trade `toggleCheckedValue`
|
|
316
314
|
* already makes for `Checkbox.Group`.
|
|
317
315
|
*
|
|
318
316
|
* **A real change is always a new array**, because React bails out of a re-render
|
|
@@ -369,7 +367,7 @@ export type AccordionItemAxes = { isDisabled: boolean };
|
|
|
369
367
|
* The accordion reaches this one *state* axis only; it cannot acquire a paint axis
|
|
370
368
|
* by accident, and a test pins that.
|
|
371
369
|
*
|
|
372
|
-
* Pure, so the whole matrix is
|
|
370
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
373
371
|
*/
|
|
374
372
|
export function resolveAccordionItemAxes({
|
|
375
373
|
own,
|
|
@@ -68,7 +68,7 @@ plus `Alert.Indicator`, `Alert.Content`, `Alert.Title`, `Alert.Description`,
|
|
|
68
68
|
`destructive` a circle, so the two stay apart for anyone who cannot tell amber
|
|
69
69
|
from red. `default` shares `info`'s circle. The map lives in
|
|
70
70
|
`alert-glyphs.ts`, a leaf `Toast` shares, because the glyphs are RN SVG components and
|
|
71
|
-
`alert.variants.ts` must stay
|
|
71
|
+
`alert.variants.ts` must stay free of React Native imports.
|
|
72
72
|
- **The indicator is hidden from assistive technology.** The title says what
|
|
73
73
|
happened; "image" announced before it adds nothing. Children replace the
|
|
74
74
|
glyph and inherit the alert's icon size and colour — a `Spinner` for a
|
|
@@ -14,7 +14,7 @@ import type { AlertStatus } from "./alert.variants";
|
|
|
14
14
|
* draws the same glyph per status, so the two read as one family, and it may
|
|
15
15
|
* import a leaf across folders where it may not import a part (package rule 3).
|
|
16
16
|
* Not in `alert.variants.ts` because the glyphs are React Native SVG components,
|
|
17
|
-
* and that file must stay
|
|
17
|
+
* and that file must stay free of React Native imports.
|
|
18
18
|
*/
|
|
19
19
|
export const ALERT_GLYPHS: Record<AlertStatus, IconComponent> = {
|
|
20
20
|
default: IconCircleInfo,
|
|
@@ -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 } from "../../styles/theme-tokens.test";
|
|
4
3
|
import {
|
|
5
4
|
ALERT_FOREGROUND_TOKEN,
|
|
6
5
|
ALERT_SIZES,
|
|
@@ -162,7 +161,7 @@ describe("ALERT_FOREGROUND_TOKEN", () => {
|
|
|
162
161
|
// A token no theme declares compiles to nothing and the icon falls back to
|
|
163
162
|
// whatever colour it inherited.
|
|
164
163
|
test("every token is declared in both themes and aliased", () => {
|
|
165
|
-
const css =
|
|
164
|
+
const css = THEME_CSS;
|
|
166
165
|
for (const token of Object.values(ALERT_FOREGROUND_TOKEN)) {
|
|
167
166
|
expect(css).toContain(`--color-${token}: var(--${token})`);
|
|
168
167
|
expect(css.split(`--${token}:`).length - 1).toBeGreaterThanOrEqual(2);
|
|
@@ -68,8 +68,7 @@ export const ALERT_SURFACE_PADDING = {
|
|
|
68
68
|
* The root holds no `text-*` (rule 1). The title takes its status's colour,
|
|
69
69
|
* the description is always muted, so a long explanation never shouts.
|
|
70
70
|
*
|
|
71
|
-
* Free of React Native imports so it stays unit-testable
|
|
72
|
-
* parse React Native's Flow-typed source. See AGENTS.md.
|
|
71
|
+
* Free of React Native imports so it stays pure and unit-testable. See AGENTS.md.
|
|
73
72
|
*/
|
|
74
73
|
export const alertVariants = tv({
|
|
75
74
|
slots: {
|
|
@@ -125,7 +125,7 @@ one job, a small closed API.
|
|
|
125
125
|
must never import its own root (package rule 3).
|
|
126
126
|
- No demo carries `meta.capture` yet. A captured demo must have committed media
|
|
127
127
|
in `apps/web/src/previews/manifest.ts`, and that is written only by
|
|
128
|
-
|
|
128
|
+
<!-- registry:omit -->`bun run previews` on a simulator, which this change did not run.<!-- /registry:omit --> The intended
|
|
129
129
|
set is `status-flow` (hero), `statuses`, `sizes`, `custom-icon` and
|
|
130
130
|
`inline-text`; `reduced-motion` stays uncaptured. Add `capture` to those five
|
|
131
131
|
in the same commit that photographs them, then add `<Preview>` heroes to the
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
* `loading` is absent because it spins instead.
|
|
36
36
|
*
|
|
37
37
|
* Lives here rather than in `animated-badge.variants.ts` because the glyphs are
|
|
38
|
-
* React Native SVG components, and that file must stay
|
|
38
|
+
* React Native SVG components, and that file must stay free of React Native imports.
|
|
39
39
|
*/
|
|
40
40
|
const STATUS_GLYPHS: Record<Exclude<AnimatedBadgeStatus, "loading">, IconComponent> = {
|
|
41
41
|
neutral: IconCircle,
|
|
@@ -71,7 +71,7 @@ Compound root plus `Attachment.Preview`, `.Content`, `.Name`, `.Meta`, `.Progres
|
|
|
71
71
|
the surface as a class for Tailwind's scanner, and the glyph takes the foreground as a token. A
|
|
72
72
|
test pins every pair to tokens both themes declare, the class to the map, and no two kinds to
|
|
73
73
|
one tone. The glyph itself is `ATTACHMENT_KIND_ICON` in `attachment-preview.tsx` — kept out of
|
|
74
|
-
the variants file because an icon import would drag React Native into
|
|
74
|
+
the variants file because an icon import would drag React Native into it.
|
|
75
75
|
- **The glyph is painted first and the image mounts over it** — the `Avatar` rule. A slow or dead
|
|
76
76
|
URL leaves the type glyph, never a hole. A failure is remembered by
|
|
77
77
|
`resolveAttachmentSourceKey`, not by object identity: an inline `source={{ uri }}` is a new
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The attachment's pure decisions — sizes and durations as text, what kind a
|
|
3
3
|
* file is, how a long name is cut, and everything a screen reader hears.
|
|
4
4
|
*
|
|
5
|
-
* Free of React Native imports so
|
|
5
|
+
* Free of React Native imports so every one of them is unit-testable. See
|
|
6
6
|
* AGENTS.md.
|
|
7
7
|
*/
|
|
8
8
|
import type { AttachmentKind, AttachmentStatus } from "./attachment.variants";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The avatar's pure decisions — initials, image retry, group overflow and the
|
|
3
3
|
* name a screen reader reads.
|
|
4
4
|
*
|
|
5
|
-
* Free of React Native imports so
|
|
5
|
+
* Free of React Native imports so every one of them is unit-testable. The
|
|
6
6
|
* source type is restated structurally rather than imported as
|
|
7
7
|
* `ImageSourcePropType` for the same reason. See AGENTS.md.
|
|
8
8
|
*/
|
|
@@ -36,7 +36,7 @@ A compact label for status, category or count. Compound root plus `Badge.Label`,
|
|
|
36
36
|
and no `onLongPress` the root is a plain `View`. Mounting a `GestureDetector`
|
|
37
37
|
regardless would put one under every tag in a list of fifty and announce each
|
|
38
38
|
of them to assistive technology as a button with no action. `resolveBadgeInteractive`
|
|
39
|
-
is that decision, and it is pure so
|
|
39
|
+
is that decision, and it is pure so it is unit-testable. Supply either
|
|
40
40
|
handler and the root becomes a [`Pressable`](../pressable/AGENTS.md),
|
|
41
41
|
inheriting `feedback`, `haptic` and the rest; only the default differs,
|
|
42
42
|
`scale`.
|
|
@@ -106,8 +106,7 @@ export const BADGE_FOREGROUND_TOKEN: Record<BadgeVariant, Record<BadgeColor, str
|
|
|
106
106
|
* colour to a `Text` descendant, so label colour lives on the `label` slot and
|
|
107
107
|
* icon colour is resolved from {@link BADGE_FOREGROUND_TOKEN}.
|
|
108
108
|
*
|
|
109
|
-
* Free of React Native imports so it stays unit-testable
|
|
110
|
-
* parse React Native's Flow-typed source. See AGENTS.md.
|
|
109
|
+
* Free of React Native imports so it stays pure and unit-testable. See AGENTS.md.
|
|
111
110
|
*/
|
|
112
111
|
export const badgeVariants = tv({
|
|
113
112
|
slots: {
|
|
@@ -244,7 +243,7 @@ export const badgeVariants = tv({
|
|
|
244
243
|
* `onClose` is deliberately not read here: the dismiss control is its own
|
|
245
244
|
* pressable, so a badge that can only be dismissed still has an inert root.
|
|
246
245
|
*
|
|
247
|
-
* Pure, so the matrix is
|
|
246
|
+
* Pure, so the matrix is unit-testable. See AGENTS.md.
|
|
248
247
|
*/
|
|
249
248
|
export function resolveBadgeInteractive({
|
|
250
249
|
onPress,
|
|
@@ -192,6 +192,6 @@ problem it has:
|
|
|
192
192
|
|
|
193
193
|
Pattern B, compound and context — the contexts are the engine's. The parts
|
|
194
194
|
never import `./bottom-sheet` or `./index` (rule 3); they import the engine and
|
|
195
|
-
`./bottom-sheet.variants`.
|
|
195
|
+
`./bottom-sheet.variants`. The variants and the constants are unit-testable;
|
|
196
196
|
the behaviour is the engine's and is verified there, and the skin on a
|
|
197
197
|
simulator through `apps/playground`'s Bottom sheet galleries.
|
|
@@ -91,7 +91,7 @@ a word in a row of words reads as a jitter. No underline on press: that is a poi
|
|
|
91
91
|
## Deviations from the design spec
|
|
92
92
|
|
|
93
93
|
- **`resolveBreadcrumbSeparatorGlyph` returns `"chevron-right" | "chevron-left"`, not the icon
|
|
94
|
-
components.** `*.variants.ts` must stay free of React Native imports so
|
|
94
|
+
components.** `*.variants.ts` must stay free of React Native imports so it stays unit-testable,
|
|
95
95
|
and a Central Icon pulls in `react-native-svg`. `Breadcrumb.Separator` maps the name to the glyph.
|
|
96
96
|
- **`Breadcrumb.Ellipsis` takes `hiddenCount`, `onPress` and `haptic`** beyond the spec's
|
|
97
97
|
`ViewProps`. The list wires them itself; a hand-placed ellipsis in a custom layout needs the same
|
|
@@ -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 } from "../../styles/theme-tokens.test";
|
|
4
3
|
import { TEXT_SIZES } from "../text/text.variants";
|
|
5
4
|
import {
|
|
6
5
|
BREADCRUMB_DEFAULT_SIZE,
|
|
@@ -18,8 +17,6 @@ import {
|
|
|
18
17
|
resolveBreadcrumbSequence,
|
|
19
18
|
} from "./breadcrumb.variants";
|
|
20
19
|
|
|
21
|
-
const THEME_CSS = readFileSync(join(import.meta.dirname, "../../styles/theme.css"), "utf-8");
|
|
22
|
-
|
|
23
20
|
/** Tailwind v4's default line heights, in points, for the text utility each `Text` size emits. */
|
|
24
21
|
const LINE_HEIGHT_PX: Record<string, number> = { sm: 20, md: 24 };
|
|
25
22
|
|
|
@@ -46,7 +46,7 @@ The reference implementation for the patterns in the package
|
|
|
46
46
|
never picking between two. The shape is a default rather than a law: three
|
|
47
47
|
numbers in `tokens.css` square the whole kit off without touching a
|
|
48
48
|
component. Values above half the height are clamped by the renderer, which is
|
|
49
|
-
why
|
|
49
|
+
why they must stay under it.
|
|
50
50
|
- **A square footprint is a size, not a flag.** `icon-sm` / `icon-md` /
|
|
51
51
|
`icon-lg` are `sm` / `md` / `lg` with the horizontal padding traded for a width
|
|
52
52
|
off the same token. Padding and width are then mutually exclusive by
|
|
@@ -133,7 +133,7 @@ for a chunk that says something rather than doing something. An
|
|
|
133
133
|
emitted after it, and `tv` emits variants in declaration order. A surviving
|
|
134
134
|
`rounded-button-md` on the size axis would therefore delete the squaring pair
|
|
135
135
|
as soon as someone reordered two keys in `buttonVariants`, with nothing to see
|
|
136
|
-
in the diff
|
|
136
|
+
in the diff.<!-- registry:omit --> `cn.test.ts` pins the asymmetry in both directions.<!-- /registry:omit -->
|
|
137
137
|
- **Horizontal squares on the logical axis; vertical squares on the physical
|
|
138
138
|
one. Never mix them.** `rounded-s-*` / `rounded-e-*` compile to
|
|
139
139
|
`border-start-start-radius` and friends, survive lightningcss, and flip under
|
|
@@ -159,7 +159,7 @@ for a chunk that says something rather than doing something. An
|
|
|
159
159
|
invisible rule. `resolveGroupPositions` and `resolveGroupSeams` are two walks
|
|
160
160
|
rather than one because they ask different questions — "how many of us are
|
|
161
161
|
there" and "what is immediately before me" — and both are pure, so the whole
|
|
162
|
-
matrix is
|
|
162
|
+
matrix is unit-testable.
|
|
163
163
|
- **Membership is a deny-list.** Anything that is not a separator is a member.
|
|
164
164
|
Not `child.type === Button`, for two reasons: it lets a custom control join,
|
|
165
165
|
and it means `button-group.tsx` never imports its own root for an identity
|
|
@@ -14,7 +14,7 @@ export type ButtonGroupSeparatorProps = {
|
|
|
14
14
|
* sit under the members instead of between them — so it reads the group's
|
|
15
15
|
* orientation and inverts it. That inversion is a map in `button.variants.ts`
|
|
16
16
|
* rather than a `SeparatorOrientation` here, because that type lives beside a
|
|
17
|
-
* React Native import and the variants file has to stay
|
|
17
|
+
* React Native import and the variants file has to stay free of React Native imports.
|
|
18
18
|
*
|
|
19
19
|
* A separator is deliberately **not** a member: it consumes no position, so the
|
|
20
20
|
* buttons either side of one are still the group's first and last and keep their
|
|
@@ -63,7 +63,7 @@ export type ButtonGroupSlotPosition = ButtonGroupPosition | "none";
|
|
|
63
63
|
*
|
|
64
64
|
* Typed on the group's own union rather than on `SeparatorOrientation`, which
|
|
65
65
|
* lives in `separator.tsx` beside a React Native import and would make this file
|
|
66
|
-
*
|
|
66
|
+
* import React Native. The two vocabularies are the same two words, and a
|
|
67
67
|
* test asserts this map still names one of them.
|
|
68
68
|
*/
|
|
69
69
|
export const BUTTON_GROUP_SEPARATOR_ORIENTATION: Record<ButtonGroupOrientation, ButtonGroupOrientation> = {
|
|
@@ -135,8 +135,7 @@ export const BUTTON_FOREGROUND_TOKEN: Record<ButtonVariant, string> = {
|
|
|
135
135
|
* button fades to the edge of its own box, and the fade is clipped to the same
|
|
136
136
|
* corner the button draws.
|
|
137
137
|
*
|
|
138
|
-
* Free of React Native imports so it stays unit-testable
|
|
139
|
-
* parse React Native's Flow-typed source. See AGENTS.md.
|
|
138
|
+
* Free of React Native imports so it stays pure and unit-testable. See AGENTS.md.
|
|
140
139
|
*/
|
|
141
140
|
export const buttonVariants = tv({
|
|
142
141
|
slots: {
|
|
@@ -366,7 +365,7 @@ export type ButtonLayout = {
|
|
|
366
365
|
* square is a `size`, so `only` cannot reach it — see the note on the `size`
|
|
367
366
|
* axis for the `alignItems: stretch` failure that rules out earning one here.
|
|
368
367
|
*
|
|
369
|
-
* Pure, so the whole matrix is
|
|
368
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
370
369
|
*/
|
|
371
370
|
export function resolveButtonLayout({
|
|
372
371
|
isLoading = false,
|
|
@@ -394,7 +393,7 @@ export function resolveButtonLayout({
|
|
|
394
393
|
* the spinner, so taking the one icon a button holds regardless of which side
|
|
395
394
|
* it sits on would draw the spinner opposite the side that was asked for.
|
|
396
395
|
*
|
|
397
|
-
* Pure, so the whole matrix is
|
|
396
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
398
397
|
*/
|
|
399
398
|
export function resolveSpinnerSwapIndex(isIcon: readonly boolean[], side: "start" | "end"): number | null {
|
|
400
399
|
const index = side === "start" ? 0 : isIcon.length - 1;
|
|
@@ -411,7 +410,7 @@ export function resolveSpinnerSwapIndex(isIcon: readonly boolean[], side: "start
|
|
|
411
410
|
* `Button.Group` has to line up with the run without having a square form of its
|
|
412
411
|
* own, which is exactly what an `Input` does.
|
|
413
412
|
*
|
|
414
|
-
* Pure, so the whole matrix is
|
|
413
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
415
414
|
*/
|
|
416
415
|
export function resolveButtonSizeStep(size: ButtonSize): ButtonLabelSize {
|
|
417
416
|
return (size.startsWith("icon-") ? size.slice("icon-".length) : size) as ButtonLabelSize;
|
|
@@ -430,7 +429,7 @@ export function resolveButtonSizeStep(size: ButtonSize): ButtonLabelSize {
|
|
|
430
429
|
* to the group's own shape when the member names no size. `icon-md` inside a
|
|
431
430
|
* `sm` group is `icon-sm` — square, and the same height as everything beside it.
|
|
432
431
|
*
|
|
433
|
-
* Pure, so the whole matrix is
|
|
432
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
434
433
|
*/
|
|
435
434
|
export function resolveGroupedButtonSize(own: ButtonSize | undefined, group: ButtonSize | undefined): ButtonSize {
|
|
436
435
|
if (group === undefined) return own ?? "md";
|
|
@@ -449,7 +448,7 @@ export function resolveGroupedButtonSize(own: ButtonSize | undefined, group: But
|
|
|
449
448
|
* one button conditionally look no different from the button on its own.
|
|
450
449
|
*
|
|
451
450
|
* Takes an array of "is this child a member" rather than the children
|
|
452
|
-
* themselves, so it stays free of React and
|
|
451
|
+
* themselves, so it stays free of React and unit-testable — the
|
|
453
452
|
* trade {@link resolveSpinnerSwapIndex} already makes. React Native has no
|
|
454
453
|
* sibling selector, so this is the only place a member's corner can be decided.
|
|
455
454
|
*
|
|
@@ -457,7 +456,7 @@ export function resolveGroupedButtonSize(own: ButtonSize | undefined, group: But
|
|
|
457
456
|
* position, which draws the lone button's corner — rather than minting a fourth
|
|
458
457
|
* sentinel: a spaced member *is* a button on its own that happens to share props.
|
|
459
458
|
*
|
|
460
|
-
* Pure, so the whole matrix is
|
|
459
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
461
460
|
*/
|
|
462
461
|
export function resolveGroupPositions(
|
|
463
462
|
isMember: readonly boolean[],
|
|
@@ -497,7 +496,7 @@ export function resolveGroupPositions(
|
|
|
497
496
|
* A detached run has no shared edge, so nothing overlaps: a point of overlap
|
|
498
497
|
* there would only eat into the gap.
|
|
499
498
|
*
|
|
500
|
-
* Pure, so the whole matrix is
|
|
499
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
501
500
|
*/
|
|
502
501
|
export function resolveGroupSeams(
|
|
503
502
|
isMember: readonly boolean[],
|
|
@@ -527,7 +526,7 @@ export function resolveGroupSeams(
|
|
|
527
526
|
* group. `pressedScale` beats both, because `resolvePressedState` lets an
|
|
528
527
|
* explicit value win on the axis it names — see `pressable.variants.ts`.
|
|
529
528
|
*
|
|
530
|
-
* Pure, so the whole matrix is
|
|
529
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
531
530
|
*/
|
|
532
531
|
export function resolveButtonFeedback(
|
|
533
532
|
own: PressableFeedback | undefined,
|
|
@@ -546,7 +545,7 @@ export function resolveButtonFeedback(
|
|
|
546
545
|
* would collapse every member to nothing — so `isFullWidth` on a vertical group
|
|
547
546
|
* widens the group and does nothing further.
|
|
548
547
|
*
|
|
549
|
-
* Pure, so the whole matrix is
|
|
548
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
550
549
|
*/
|
|
551
550
|
export function resolveGroupMemberStretch({
|
|
552
551
|
isFullWidth,
|
|
@@ -65,7 +65,7 @@ A content surface with a header, a body and a footer, built on
|
|
|
65
65
|
as `flex-1` with the actions after it. The title wraps in the width an action
|
|
66
66
|
leaves instead of pushing it off the edge. The helper takes its predicate as
|
|
67
67
|
an argument so it stays in `card.variants.ts`, free of the part and of React
|
|
68
|
-
Native, and
|
|
68
|
+
Native, and unit-testable.
|
|
69
69
|
- **Bare text in a header is its title.** A raw string inside a `View` is a
|
|
70
70
|
red box, and a header's text is its heading — the same wrap, for the same
|
|
71
71
|
reason, as [`ListGroup.Item`](../list-group/AGENTS.md).
|
|
@@ -56,8 +56,7 @@ export type CardPlane = (typeof CARD_PLANES)[number];
|
|
|
56
56
|
* does not cascade colour to a `Text`, so the tokens live on the title and
|
|
57
57
|
* description slots.
|
|
58
58
|
*
|
|
59
|
-
* Free of React Native imports so it stays unit-testable
|
|
60
|
-
* parse React Native's Flow-typed source. See AGENTS.md.
|
|
59
|
+
* Free of React Native imports so it stays pure and unit-testable. See AGENTS.md.
|
|
61
60
|
*/
|
|
62
61
|
export const cardVariants = tv({
|
|
63
62
|
slots: {
|
|
@@ -52,8 +52,7 @@ export const CAROUSEL_PAN = { activate: 10, fail: 10 } as const;
|
|
|
52
52
|
/**
|
|
53
53
|
* Carousel's slots.
|
|
54
54
|
*
|
|
55
|
-
* Free of React Native imports so it stays unit-testable
|
|
56
|
-
* parse React Native's Flow-typed source. See AGENTS.md.
|
|
55
|
+
* Free of React Native imports so it stays pure and unit-testable. See AGENTS.md.
|
|
57
56
|
*/
|
|
58
57
|
export const carouselVariants = tv({
|
|
59
58
|
slots: {
|
|
@@ -188,7 +188,7 @@ export function resolvePieSeries(
|
|
|
188
188
|
* The axis formatter is deliberately not used: a tick label sits in a column
|
|
189
189
|
* where `1240` and `1,240` differ only in width, but a readout sits beside
|
|
190
190
|
* `PieChart.Center`, and the two must print one number one way. Hand-rolled
|
|
191
|
-
* rather than `toLocaleString` so it prints the same
|
|
191
|
+
* rather than `toLocaleString` so it prints the same in a unit test and
|
|
192
192
|
* on a Hermes build with no Intl data.
|
|
193
193
|
*/
|
|
194
194
|
export function formatPieValue(value: number): string {
|
|
@@ -335,7 +335,7 @@ export function applyChartColors(
|
|
|
335
335
|
*
|
|
336
336
|
* A worklet, so the tooltip tracks the finger on the UI thread. The directive
|
|
337
337
|
* is a string rather than an import, which is what keeps this module free of
|
|
338
|
-
* React Native and
|
|
338
|
+
* React Native and unit-testable.
|
|
339
339
|
*/
|
|
340
340
|
export function chartTooltipOffset(input: ChartTooltipInput): { x: number; y: number } {
|
|
341
341
|
"worklet";
|
|
@@ -636,9 +636,8 @@ export const BAR_RADIUS_STEP: Record<ChartSize, "xs" | "sm"> = { sm: "xs", md: "
|
|
|
636
636
|
* Restated because the corner scale is `@theme inline`: Tailwind substitutes
|
|
637
637
|
* each step into its utilities and emits no `--radius-xs` variable, so
|
|
638
638
|
* `--radius` is the only one that survives to runtime and anything computing
|
|
639
|
-
* a corner in JavaScript multiplies for itself.
|
|
640
|
-
*
|
|
641
|
-
* quietly leaving the bars on the old curve.
|
|
639
|
+
* a corner in JavaScript multiplies for itself. These must stay
|
|
640
|
+
* in step with the file, or retuning the scale quietly leaves the bars on the old curve.
|
|
642
641
|
*/
|
|
643
642
|
export const BAR_RADIUS_MULTIPLIER: Record<ChartSize, number> = { sm: 0.4, md: 0.6, lg: 0.6 };
|
|
644
643
|
|
|
@@ -64,8 +64,8 @@ Root plus `Checkbox.Label` and `Checkbox.Group`.
|
|
|
64
64
|
`destructive`" are different questions and both get an answer. `??` throughout and
|
|
65
65
|
never `||`, so `isDisabled={false}` opts a child out of a disabled group.
|
|
66
66
|
- **`Checkbox.Group`'s state is one array of the children's `value`s.**
|
|
67
|
-
`toggleCheckedValue` is the whole transition and it is pure, so
|
|
68
|
-
|
|
67
|
+
`toggleCheckedValue` is the whole transition and it is pure, so it
|
|
68
|
+
is unit-testable — including that it always returns a *new* array, since React bails
|
|
69
69
|
out of a re-render on an unchanged reference and a mutation would flip the
|
|
70
70
|
state while leaving the screen alone. A grouped checkbox with no `value`
|
|
71
71
|
throws by name: group membership is invisible in the child's props at compile
|
|
@@ -139,12 +139,11 @@ Root plus `Checkbox.Label` and `Checkbox.Group`.
|
|
|
139
139
|
`resolveCheckboxFillRadius` takes the live `--radius` and applies
|
|
140
140
|
`CHECKBOX_RADIUS_MULTIPLIER`, which is why a consumer pasting a theme with a
|
|
141
141
|
different `--radius` moves the fill with the border instead of leaving it
|
|
142
|
-
behind.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
build rather than quietly reopening the gap.
|
|
142
|
+
behind. The multipliers must match `tokens.css`, the result must *be* the box's own step at any
|
|
143
|
+
`--radius`, `CHECKBOX_RADIUS_STEP` must name the `rounded-*` the `box` slot
|
|
144
|
+
actually wears, and the box's border must really be the bare 1pt `border` the
|
|
145
|
+
`-inset-px` assumes. Retuning the scale, or reaching for `border-2`, would
|
|
146
|
+
quietly reopen the gap.<!-- registry:omit --> `checkbox.variants.test.ts` asserts each of these.<!-- /registry:omit -->
|
|
148
147
|
- **The border is the one part of the box no `tv()` describes.** A colour that
|
|
149
148
|
fades cannot be a class, so it interpolates between two token *values* —
|
|
150
149
|
`resolveCheckboxBorderTokens` names them, and `CHECKBOX_SURFACE_TOKEN` is the
|
|
@@ -159,7 +158,7 @@ Root plus `Checkbox.Label` and `Checkbox.Group`.
|
|
|
159
158
|
`size-checkbox-md` cannot be read from JavaScript, so it comes from the fill
|
|
160
159
|
layer's own `onLayout` — that layer is already exactly the width the clip has
|
|
161
160
|
to span. A table of numbers here would be `tokens.css` restated in TypeScript,
|
|
162
|
-
which is the drift
|
|
161
|
+
which is the drift every other measurement here is built to avoid.
|
|
163
162
|
- **Reduce-motion takes Reanimated's default `System` policy here**, unlike
|
|
164
163
|
[`Spinner`](../spinner/AGENTS.md). Under it `withTiming` completes instantly, which for a checkbox is
|
|
165
164
|
right: the state change is the point and the travel is decoration. A spinner
|
|
@@ -81,9 +81,8 @@ export const CHECKBOX_BORDER_WIDTH = 1;
|
|
|
81
81
|
* Tailwind substitutes each step into the utilities that use it and emits no
|
|
82
82
|
* `--radius-xs` variable at all. `--radius` is the only one that survives to
|
|
83
83
|
* runtime, so anything computing a corner in JavaScript has to do the
|
|
84
|
-
* multiplication itself.
|
|
85
|
-
* `tokens.css`,
|
|
86
|
-
* leaving the fill behind.
|
|
84
|
+
* multiplication itself. Both numbers must stay in step
|
|
85
|
+
* with `tokens.css`, or retuning the scale quietly leaves the fill behind.
|
|
87
86
|
*/
|
|
88
87
|
export const CHECKBOX_RADIUS_MULTIPLIER: Record<"sm" | "xs", number> = { xs: 0.4, sm: 0.6 };
|
|
89
88
|
|
|
@@ -110,7 +109,7 @@ export const CHECKBOX_RADIUS_MULTIPLIER: Record<"sm" | "xs", number> = { xs: 0.4
|
|
|
110
109
|
* away from the border the moment anyone did. Clamped at zero so a
|
|
111
110
|
* square-cornered theme draws a square fill rather than a negative radius.
|
|
112
111
|
*
|
|
113
|
-
* Pure, so the whole matrix is
|
|
112
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
114
113
|
*/
|
|
115
114
|
export function resolveCheckboxFillRadius(size: CheckboxSize, radius: number): number {
|
|
116
115
|
const step = CHECKBOX_RADIUS_MULTIPLIER[CHECKBOX_RADIUS_STEP[size]];
|
|
@@ -184,8 +183,7 @@ export const CHECKBOX_INVALID_BORDER_TOKEN = "destructive";
|
|
|
184
183
|
* `opacity-50` for a disabled checkbox goes on the **row**, so the label fades
|
|
185
184
|
* with the box it names rather than standing at full strength beside a ghost.
|
|
186
185
|
*
|
|
187
|
-
* Free of React Native imports so it stays unit-testable
|
|
188
|
-
* parse React Native's Flow-typed source. See AGENTS.md.
|
|
186
|
+
* Free of React Native imports so it stays pure and unit-testable. See AGENTS.md.
|
|
189
187
|
*/
|
|
190
188
|
export const checkboxVariants = tv({
|
|
191
189
|
slots: {
|
|
@@ -240,7 +238,7 @@ export const checkboxVariants = tv({
|
|
|
240
238
|
start: {},
|
|
241
239
|
// `flex-row-reverse` rather than a branch in the JSX: the box is
|
|
242
240
|
// rendered first either way, so the decision stays a class and the whole
|
|
243
|
-
// matrix stays
|
|
241
|
+
// matrix stays unit-testable.
|
|
244
242
|
end: { root: "flex-row-reverse", label: "grow" },
|
|
245
243
|
},
|
|
246
244
|
// The empty `false` branches are load-bearing typing, not placeholders.
|
|
@@ -328,7 +326,7 @@ export const CHECKBOX_HIT_SLOP: Record<CheckboxSize, number> = { sm: 13, md: 12,
|
|
|
328
326
|
* instead of a tick — so the two collapse to one visual state here and the tv()
|
|
329
327
|
* axis is named for that rather than for `checked`.
|
|
330
328
|
*
|
|
331
|
-
* Pure, so the matrix is
|
|
329
|
+
* Pure, so the matrix is unit-testable. See AGENTS.md.
|
|
332
330
|
*/
|
|
333
331
|
export function resolveCheckboxFilled({
|
|
334
332
|
isChecked,
|
|
@@ -369,7 +367,7 @@ export type CheckboxFieldAxes = { isInvalid?: boolean; isDisabled?: boolean };
|
|
|
369
367
|
* `??` throughout and never `||`, so an explicit `false` opts a control out of
|
|
370
368
|
* an invalid field rather than reading as an absence.
|
|
371
369
|
*
|
|
372
|
-
* Pure, so the whole ladder is
|
|
370
|
+
* Pure, so the whole ladder is unit-testable. See AGENTS.md.
|
|
373
371
|
*/
|
|
374
372
|
export function resolveCheckboxAxes({
|
|
375
373
|
own,
|
|
@@ -397,7 +395,7 @@ export function resolveCheckboxAxes({
|
|
|
397
395
|
* Always a new array: React bails out of a re-render on an unchanged reference,
|
|
398
396
|
* so a mutation here would flip the state and leave the screen alone.
|
|
399
397
|
*
|
|
400
|
-
* Pure, so it is
|
|
398
|
+
* Pure, so it is unit-testable. See AGENTS.md.
|
|
401
399
|
*/
|
|
402
400
|
export function toggleCheckedValue(current: readonly string[], value: string): string[] {
|
|
403
401
|
return current.includes(value) ? current.filter((entry) => entry !== value) : [...current, value];
|
|
@@ -409,7 +407,7 @@ export function toggleCheckedValue(current: readonly string[], value: string): s
|
|
|
409
407
|
* A size, never a class. The checkbox's own step names map onto `TEXT_SIZES`'
|
|
410
408
|
* own, so the two scales stay level without either restating the other.
|
|
411
409
|
*
|
|
412
|
-
* Pure, so it is
|
|
410
|
+
* Pure, so it is unit-testable. See AGENTS.md.
|
|
413
411
|
*/
|
|
414
412
|
export function resolveCheckboxLabelSize(size: CheckboxSize): TextSize {
|
|
415
413
|
switch (size) {
|
|
@@ -430,7 +428,7 @@ export function resolveCheckboxLabelSize(size: CheckboxSize): TextSize {
|
|
|
430
428
|
* `Text.Label`'s own `text-foreground`. The same contract `resolveFieldTextColor`
|
|
431
429
|
* uses, and it is what lets the label say "leave it alone".
|
|
432
430
|
*
|
|
433
|
-
* Pure, so it is
|
|
431
|
+
* Pure, so it is unit-testable. See AGENTS.md.
|
|
434
432
|
*/
|
|
435
433
|
export function resolveCheckboxLabelColor(isInvalid: boolean): TextColor | undefined {
|
|
436
434
|
return isInvalid ? "destructive" : undefined;
|
|
@@ -444,7 +442,7 @@ export function resolveCheckboxLabelColor(isInvalid: boolean): TextColor | undef
|
|
|
444
442
|
* making a tap between two checkboxes ambiguous, which is worse than the target
|
|
445
443
|
* being merely adequate.
|
|
446
444
|
*
|
|
447
|
-
* Pure, so it is
|
|
445
|
+
* Pure, so it is unit-testable. See AGENTS.md.
|
|
448
446
|
*/
|
|
449
447
|
export function resolveCheckboxHitSlop({
|
|
450
448
|
size,
|
|
@@ -469,7 +467,7 @@ export function resolveCheckboxHitSlop({
|
|
|
469
467
|
* between invalid and focus, expressed as a pair of endpoints instead of a
|
|
470
468
|
* compound variant.
|
|
471
469
|
*
|
|
472
|
-
* Pure, so the whole matrix is
|
|
470
|
+
* Pure, so the whole matrix is unit-testable. See AGENTS.md.
|
|
473
471
|
*/
|
|
474
472
|
export function resolveCheckboxBorderTokens({ color, isInvalid }: { color: CheckboxColor; isInvalid: boolean }): {
|
|
475
473
|
rest: string;
|
|
@@ -244,7 +244,7 @@ export const chipVariants = tv({
|
|
|
244
244
|
* The surface a chip wears — its resting variant, or `selected`.
|
|
245
245
|
*
|
|
246
246
|
* Pure, so the icon colour and the label colour are chosen by one rule that
|
|
247
|
-
*
|
|
247
|
+
* is unit-testable. See AGENTS.md.
|
|
248
248
|
*/
|
|
249
249
|
export function resolveChipSurface({
|
|
250
250
|
variant,
|
|
@@ -312,7 +312,7 @@ export function resolveChipMode({
|
|
|
312
312
|
*/
|
|
313
313
|
export type ChipCloseExposure = "none" | "element" | "action";
|
|
314
314
|
|
|
315
|
-
/** See {@link ChipCloseExposure}. Pure, so
|
|
315
|
+
/** See {@link ChipCloseExposure}. Pure, so it is unit-testable. */
|
|
316
316
|
export function resolveChipCloseExposure({ mode, hasClose }: { mode: ChipMode; hasClose: boolean }): ChipCloseExposure {
|
|
317
317
|
if (!hasClose) return "none";
|
|
318
318
|
return mode === "static" ? "element" : "action";
|