@astryxdesign/native 0.7.6-canary.dfc83ee → 0.7.6-canary.e30ffbf

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 (32) hide show
  1. package/apple/Package.swift +0 -2
  2. package/apple/README.md +18 -3
  3. package/apple/Sources/Astryx/Avatar/Avatar.swift +2 -9
  4. package/apple/Sources/Astryx/Base/SafeDestination.swift +48 -0
  5. package/apple/Sources/Astryx/Button/Button.swift +3 -21
  6. package/apple/Sources/Astryx/Item/Item.swift +354 -0
  7. package/apple/Sources/Astryx/Wire/AstryxNodeView.swift +9 -0
  8. package/apple/Sources/AstryxNative/Generated/AstryxNode.swift +3 -0
  9. package/apple/Sources/AstryxNative/Generated/Item.swift +173 -0
  10. package/apple/Tests/AstryxTests/ItemTests.swift +295 -0
  11. package/dist/components/Item.d.ts +10 -0
  12. package/dist/components/Item.d.ts.map +1 -0
  13. package/dist/components/Item.js +22 -0
  14. package/dist/components/index.d.ts.map +1 -1
  15. package/dist/components/index.js +2 -0
  16. package/dist/types/android.d.ts +16 -3
  17. package/dist/types/core.d.ts +18 -0
  18. package/dist/types/ios.d.ts +16 -3
  19. package/dist/types/macos.d.ts +16 -3
  20. package/dist/types/shared.d.ts +16 -3
  21. package/dist/types/windows.d.ts +16 -3
  22. package/package.json +3 -3
  23. package/src/components/Item.ts +34 -0
  24. package/src/components/index.ts +2 -0
  25. package/src/contract/contracts.test.ts +39 -0
  26. package/src/theme/swiftIOSTheme.test.ts +372 -38
  27. package/apple/Sources/Astryx/Avatar/Avatar.spec.md +0 -219
  28. package/apple/Sources/Astryx/Avatar/AvatarStatusDot.spec.md +0 -162
  29. package/apple/Sources/Astryx/Button/Button.spec.md +0 -174
  30. package/apple/Sources/Astryx/Icon/Icon.spec.md +0 -189
  31. package/apple/Sources/Astryx/TextInput/TextInput.spec.md +0 -179
  32. package/apple/Sources/Astryx/Thumbnail/Thumbnail.spec.md +0 -191
@@ -1,189 +0,0 @@
1
- ---
2
- schema_version: 3
3
- template_version: 7
4
- kind: component
5
- id: component:swift/Icon
6
- platform_of: component:Icon
7
- authority: draft
8
- archive_reason: null
9
- superseded_by: null
10
- approved_by: null
11
- approved_at: null
12
- owners: [cixzhang]
13
- review_triggers: [public-api, behavior, theming, accessibility]
14
- verified_by:
15
- [
16
- packages/native/apple/Tests/AstryxTests/IconTests.swift,
17
- packages/native/src/contract/contracts.test.ts,
18
- ]
19
- modules: []
20
- families: []
21
- design_specs: []
22
- architecture:
23
- [
24
- architecture:component-size-cascade,
25
- architecture:icon-resolution-and-component-slots,
26
- ]
27
- contributing: []
28
- system_specs: [spec:AST-082, spec:AST-093]
29
- ---
30
-
31
- # Icon (Swift) component contract
32
-
33
- ## Contract at a glance
34
-
35
- | Area | Contract |
36
- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
37
- | Public contract | `Icon(_ icon: IconName, color: IconColor? = nil, size: IconSize? = nil, label: String? = nil)` and `Icon(_ props: IconProps)`, a SwiftUI `View` in module `Astryx`. `IconName` is a string-backed name with every built-in name as a static member (`.search`, `.close`). |
38
- | Behavior | Draws the image the theme or the platform maps the name to (an SF Symbol, or an asset the app ships), in a square box at core's icon size grown with Dynamic Type, in core's icon color token or the surrounding foreground. A name nothing maps, or an asset the app does not ship, draws nothing. |
39
- | End-user impact | A person sees the platform's own symbol for each shared icon, or the app's own artwork where its theme maps one, sized and colored as on the web, and VoiceOver reads only icons that carry a label. |
40
- | Builder impact | An app passes a shared name (`.search`) or a name it maps in its theme (`"acme:rocket"`). An SVG component, which the web also accepts, has no Swift form. |
41
- | Compatibility/readiness | Additive: a new view and a new generated `IconName` type. Draft; built and tested on macOS and the iOS Simulator; device captures are attached to the change. |
42
- | Review checks | Reject a substitute symbol for an unknown name, an image or attributed-text form of the icon slot, a visual parameter beyond the contract, an unlabeled icon that VoiceOver reads, or an owner's size winning over an explicit `size`. |
43
- | Governing rules | `spec:AST-082` FR4, FR7, FR17; `spec:AST-093` FR1–FR5; the Swift component API, styles, slots, theme environment, and accessibility records under `packages/native/specs/swift/library/`. |
44
-
45
- This table is a review projection; the body below is authoritative.
46
-
47
- ## Intent
48
-
49
- Icon on Apple platforms draws Astryx's shared icon names as SF Symbols, or as
50
- images the app ships where its theme maps them, so an
51
- icon beside system controls looks like the platform's own while its size, color,
52
- and accessibility follow the core `Icon` contract.
53
-
54
- ## Compatibility and migration
55
-
56
- - Released default preserved: `not yet released`
57
- - Compatibility class: additive
58
- - Controlled/uncontrolled behavior: not applicable
59
- - Migration decision: none
60
-
61
- Consumer migration instructions belong in consumer docs and release notes.
62
-
63
- ## Ownership boundary
64
-
65
- **Owns**
66
-
67
- - Resolving a shared icon name to an image: the theme's mapping (an SF Symbol
68
- or an app asset), else the platform's default SF Symbol.
69
- - Drawing the image in a square box at core's icon size, grown with Dynamic
70
- Type, in core's icon color token. An asset takes the color token when its
71
- asset catalog renders it as a template image, and keeps its own colors when
72
- it renders as an original image.
73
- - The icon's VoiceOver exposure.
74
-
75
- **Does not own / non-goals**
76
-
77
- - The meaning of `icon`, `color`, `size`, and `label` and the built-in names —
78
- owned by `component:Icon` and `spec:AST-082` FR17.
79
- - Which size an owner gives the icons in its icon slot — owned by each owning
80
- component and `architecture:component-size-cascade`.
81
- - The default SF Symbol for each name — owned by `@astryxdesign/native`'s icon
82
- defaults, which a test keeps equal to the Swift map.
83
-
84
- ## Public concepts
85
-
86
- | Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |
87
- | ------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ----------------------------------------- | -------------------------- | ---------------------- | ------------ | ----------------------------------------------------------------------- |
88
- | icon name | the built-in names; a `<library>:<name>` the theme maps | `IconName`, a string on the wire, with each built-in as a static member | always | required | `component:Icon` | experimental | an unmapped name stops a development build and draws nothing in release |
89
- | symbol source | theme mapping; platform default | `Theme(icons:)` replaces a built-in or registers a library name with an SF Symbol or an app asset | always | platform default | `component:swift/Icon` | experimental | a theme entry wins over the default |
90
- | size | `xsm`, `sm`, `md`, `lg`; unset | 12, 16, 20, 24 points at the default text size | always | owner's icon size, else md | `component:Icon` | experimental | unset takes the owner's size, then `md` |
91
- | color | `primary`, `secondary`, `tertiary`, `disabled`, `accent`, `info`, `success`, `error`, `warning`, `inherit`; unset | core's icon color tokens; `inherit` keeps the surrounding foreground | always | `inherit` | `component:Icon` | experimental | unset is `inherit` |
92
-
93
- ## Behavioral and layout contract
94
-
95
- | ID | Candidate invariant | Basis | Draft review state |
96
- | --- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- | ------------------ |
97
- | FR1 | The view MUST draw the image the theme's `icons` maps the name to, an SF Symbol or an asset the app ships, else the platform default for a built-in name. A name neither maps, or an asset the app does not ship, MUST stop a development build with a message naming it and draw nothing in a release build, never a substitute. | `spec:AST-082` FR17; Swift slots S2 | verify |
98
- | FR2 | The symbol MUST fit a square box whose side is core's size in points (12, 16, 20, 24 for `xsm`, `sm`, `md`, `lg`), multiplied by the Dynamic Type scale the theme environment reads. | core `Icon` sizes; `spec:AST-093` FR3; theme environment E1 | verify |
99
- | FR3 | The view MUST use its own `size`, else the size its owning component gives icons in its documented icon slot, else `md`. | `architecture:component-size-cascade`; Swift slots S4 | verify |
100
- | FR4 | The view MUST draw in core's token for its `color` — primary and secondary icon tokens, the secondary icon token for `tertiary`, the disabled icon token, the accent color, and the `info`, `success`, `error`, and `warning` status icon roles — and, for `inherit` or no color, MUST keep the surrounding foreground style. | core `Icon` color map; `spec:AST-093` FR4 | verify |
101
- | FR5 | Both initializers MUST build the same `IconProps`; the labeled initializer takes the contract's props with the generated types and defaults, and base props (`id`, `isHidden`) come through `IconProps`. With `isHidden` the view draws nothing; `id` becomes the accessibility identifier. | Swift component API A2, A3, A7; `spec:AST-082` FR7 | verify |
102
-
103
- ### Allowed variation
104
-
105
- - **AV1 — Glyph shape.** The glyph is the platform's SF Symbol, not the web's
106
- SVG; a theme may map any name to another SF Symbol or to an image the app
107
- ships (`spec:AST-082` FR17).
108
-
109
- ### Representative states
110
-
111
- | State | Required invariant | Allowed variation |
112
- | --------------------------- | --------------------------------------------- | ---------------------------- |
113
- | every size | box side 12, 16, 20, 24 points at Large text | glyph proportions per symbol |
114
- | every color, light and dark | the color's token in the current mode | none |
115
- | inside an owner's icon slot | the owner's size unless the icon sets its own | none |
116
- | largest text size | the box grows with Dynamic Type | none |
117
- | labeled and unlabeled | VoiceOver reads only the labeled icon | none |
118
-
119
- ### Transformation and precedence order
120
-
121
- - **ORD1 — Image.** Theme mapping (SF Symbol or app asset) → platform default
122
- SF Symbol → nothing.
123
- - **ORD2 — Size.** Explicit `size` → owner's icon size → `md`, then × Dynamic
124
- Type scale.
125
-
126
- ### Performance and resources
127
-
128
- - **PR1 — No image data of its own.** The view draws a system symbol by name,
129
- or an asset from the app's main bundle by name; it holds no image data and
130
- loads nothing from the network.
131
-
132
- ## Accessibility contract
133
-
134
- - **AR1 — Decorative unless labeled.** With no `label`, or an empty one, the
135
- view is hidden from VoiceOver. With a label, it is one image element named by
136
- the label, keeping SwiftUI's image trait and adding none (`spec:AST-082` FR17;
137
- Swift accessibility X1, X4).
138
- In an avatar's status slot a labeled icon also names the status, which joins
139
- the avatar's name (`component:swift/Avatar` AR6).
140
- - **AR2 — Rendered tree not measured.** Tests assert what the view sets; the
141
- rendered accessibility tree is not measured until an app-hosted target exists.
142
-
143
- ## Design relationships
144
-
145
- | Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |
146
- | ---------------- | -------------------------------------------------------------- | -------------------------- | -------------- | ------------------ |
147
- | Glyph | SF Symbols (Apple Human Interface Guidelines), or an app asset | prescribed by the platform | supporting | FR1, FR2 |
148
-
149
- The component implements design requirements without copying their rationale.
150
-
151
- Platform control: SwiftUI `Image(systemName:)`, or `Image(_:bundle:)` for an
152
- app asset. It is the platform's own icon view and satisfies the contract, so no custom drawing is needed (`spec:AST-093`
153
- FR2). Guideline pages: SF Symbols and Accessibility in the Apple Human
154
- Interface Guidelines.
155
-
156
- Theme values read: `color.iconPrimary`, `color.iconSecondary`,
157
- `color.iconDisabled`, `color.accent`, `color.iconInfo`, `color.iconSuccess`,
158
- `color.iconError`, `color.iconWarning`, the theme's `icons` map, and the
159
- Dynamic Type scale.
160
-
161
- ## Family and system relationships
162
-
163
- - `component:Icon` owns the props, the built-in names, the size scale, and the
164
- color map; this record states only how Swift draws them.
165
- - `architecture:component-size-cascade` owns when an owner's icon size applies;
166
- owners set it through an internal environment value this view reads.
167
-
168
- ## Verification map
169
-
170
- | Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
171
- | -------- | ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -------------------------- |
172
- | FR1 | `IconTests.swift` symbol and asset tests (a test bundle stands in for the app's); `contracts.test.ts` IconName test | every built-in; theme replacement; library name; a shipped asset; a missing asset drawing nothing and reported (the release-build path) | a missing default, a symbol absent on the platform, a missing asset that draws or goes unreported, or a substitute fails | `audit:swift/Icon/symbols` |
173
- | FR2, FR3 | `IconTests.swift` size and Dynamic Type renders | each size; owner size; explicit size; AX5 | a wrong side or an owner size beating an explicit size fails | `audit:swift/Icon/size` |
174
- | FR4 | `IconTests.swift` color map and two-theme render | every color; neutral and butter | a wrong token or a color of the view's own fails | `audit:swift/Icon/color` |
175
- | FR5 | `IconTests.swift` initializer and hidden tests | both initializers; `isHidden` | differing props or a drawn hidden icon fails | `audit:swift/Icon/api` |
176
- | AR1 | `IconTests.swift` accessibility assertions | labeled, unlabeled, empty label | an unlabeled icon with a label, or a labeled one without, fails | `audit:swift/Icon/a11y` |
177
-
178
- ## Decision log
179
-
180
- No component-local decision is recorded.
181
-
182
- ## Open questions
183
-
184
- None.
185
-
186
- ## Content boundary
187
-
188
- This file does not duplicate consumer prop tables/examples, current audit
189
- results, implementation steps, or family/system rules. It links to their owners.
@@ -1,179 +0,0 @@
1
- ---
2
- schema_version: 3
3
- template_version: 7
4
- kind: component
5
- id: component:swift/TextInput
6
- platform_of: component:TextInput
7
- authority: draft
8
- archive_reason: null
9
- superseded_by: null
10
- approved_by: null
11
- approved_at: null
12
- owners: [cixzhang]
13
- review_triggers: [public-api, behavior, theming, accessibility]
14
- verified_by: [packages/native/apple/Tests/AstryxTests/TextInputTests.swift]
15
- modules: []
16
- families: [family:input-fields]
17
- design_specs: []
18
- architecture: [architecture:public-component-api]
19
- contributing: []
20
- system_specs: [spec:AST-082, spec:AST-093, spec:AST-085]
21
- ---
22
-
23
- # TextInput (Swift) component contract
24
-
25
- ## Contract at a glance
26
-
27
- | Area | Contract |
28
- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
29
- | Public contract | `TextInput(label:value:type:onChange:size:isLabelHidden:description:isOptional:isRequired:onEnter:isDisabled:isReadOnly:disabledMessage:isLoading:placeholder:labelTooltip:status:statusVariant:hasClear:hasAutoFocus:base:)` and `TextInput(_ props: TextInputProps)`, a SwiftUI `View` in module `Astryx`. |
30
- | Behavior | An editable field is SwiftUI's `TextField`, or `SecureField` for a password. A read-only or disabled field draws its value, keeps a focus stop without raising a keyboard, and reads to VoiceOver as SwiftUI's text field. |
31
- | End-user impact | A person types in the platform's own field; keyboard users still reach a read-only or disabled field and its reason; VoiceOver users hear the name, any error, the description, and the state. |
32
- | Builder impact | An app passes `value` and `onChange` as the contract types them, not a `Binding`. |
33
- | Compatibility/readiness | Breaking for canary callers: a `Binding` gives way to `value` and `onChange`, as the contract types them. Draft; built and tested on macOS and the iOS Simulator. |
34
- | Review checks | Reject a read-only field that raises a keyboard or accepts edits, a disabled field that leaves focus, a read-only password that shows its characters, an error only in the hint, or `.help` for a tip. |
35
- | Governing rules | `component:TextInput` FR3–FR10, FR13, FR15; `family:input-fields` FR4; `spec:AST-085`; `spec:AST-082` FR3, FR7, FR11; `spec:AST-093` FR1–FR5; the Swift component API, tooltip, and accessibility records under `packages/native/specs/swift/library/`. |
36
-
37
- This table is a review projection; the body below is authoritative.
38
-
39
- ## Intent
40
-
41
- TextInput on Apple platforms is core's text field drawn with SwiftUI's own
42
- field for typing, so input methods, autofill, and the keyboard work the
43
- platform's way, while its read-only and disabled states keep core's focus and
44
- reading behavior where SwiftUI's field cannot.
45
-
46
- ## Compatibility and migration
47
-
48
- - Released default preserved: `not yet released`
49
- - Compatibility class: breaking for canary callers (`Binding` → `value` and `onChange`)
50
- - Controlled/uncontrolled behavior: controlled; `value` and `onChange` only
51
- - Migration decision: none
52
-
53
- Consumer migration instructions belong in consumer docs and release notes.
54
-
55
- ## Ownership boundary
56
-
57
- **Owns**
58
-
59
- - Which platform field Swift uses in each state, how a read-only or disabled
60
- field keeps focus and reads to VoiceOver, and its status announcements.
61
-
62
- **Does not own / non-goals**
63
-
64
- - The meaning of TextInput's props and states — owned by `component:TextInput`
65
- and `family:input-fields`.
66
- - Tooltip behavior — owned by the Swift tooltip record.
67
-
68
- ## Public concepts
69
-
70
- | Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |
71
- | ------------ | ----------------------------- | ------------------------------------------------------------------------ | ----------------------------------------- | -------- | --------------------------- | ------------ | ---------------------- |
72
- | field | editable; drawn | SwiftUI `TextField`/`SecureField`, or the drawn read-only/disabled field | always | editable | `component:swift/TextInput` | experimental | none |
73
- | availability | editable; read-only; disabled | disabled wins over read-only | always | editable | `component:TextInput` | experimental | none |
74
-
75
- ## Behavioral and layout contract
76
-
77
- | ID | Candidate invariant | Basis | Draft review state |
78
- | --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------- | ------------------ |
79
- | FR1 | Both initializers MUST build the same `TextInputProps`. Edits reach `onChange` only while the field is editable; Return runs `onEnter` while editable or read-only. | Swift component API A2, A3, A5; `component:TextInput` FR3, FR10 | verify |
80
- | FR2 | A read-only or disabled field MUST draw its value (masked for a password, the placeholder when empty), keep its focus stop without raising a keyboard (a field that becomes read-only or disabled while focused keeps focus: the editable and drawn parts stay in one view structure and focus moves between them), accept no edits, and read to VoiceOver as SwiftUI's text field (`accessibilityRepresentation`): dimmed when disabled, a secure field for a password, with "Read only" or the disabled reason in its description. | `component:TextInput` FR6, FR8; `spec:AST-085`; `family:input-fields` FR4; AV1 | verify |
81
- | FR3 | An error MUST be in the field's VoiceOver label after its name; the description and status message MUST stay readable as text and in the description. A status message, and "Loading", are announced on the field's first appearance and when they change, an error at high priority. | `component:TextInput` FR4, FR9; `component:FieldStatus` AR1 | verify |
82
- | FR4 | The label tip, the tooltip-variant status, the clear button, and a disabled reason MUST show through the shared Astryx tooltip; no view uses `.help`. The tooltip-variant status tip is a button, as core's status icon is, named by its status and speaking its message when VoiceOver activates it. Trailing controls each lay out across their own 44-point target. | `component:TextInput` FR5, FR7, FR15; `spec:AST-082` FR11; Swift tooltip record | verify |
83
- | FR5 | Base `id` and `isHidden` MUST apply to the field control, TextInput's base target: `id` is its accessibility identifier, and `isHidden` takes the control and its buttons out of layout and focus (autofocus included) while the label, description, and status stay, with the label and its note read by VoiceOver as text. | `component:TextInput` FR13; `spec:AST-082` FR7 | verify |
84
-
85
- ### Allowed variation
86
-
87
- - **AV1 — The drawn read-only and disabled field.** No platform field fits
88
- both states on both platforms, so Swift draws the value and gives VoiceOver
89
- SwiftUI's text field in its place. Fields considered:
90
- - SwiftUI `TextField` and `SecureField`: no read-only mode, and `.disabled`
91
- removes the focus stop core keeps (`spec:AST-085`).
92
- - UIKit `UITextField` refusing edits through its delegate: focus raises the
93
- keyboard unless its input view is replaced, its text and colors must be
94
- bridged from the theme by hand, and SwiftUI's image renderer and previews
95
- do not draw it.
96
- - AppKit `NSTextField` with editing off and selection on: a true read-only
97
- field on macOS, with no iOS counterpart, so the two platforms would differ.
98
-
99
- ### Representative states
100
-
101
- | State | Required invariant | Allowed variation |
102
- | ------------------ | ----------------------------------------------------------- | ----------------- |
103
- | editable | the platform field; edits reach `onChange` | none |
104
- | read-only | value shown; focus stop; no keyboard; Return runs `onEnter` | none |
105
- | read-only password | masked; not selectable | none |
106
- | disabled | dimmed; focus stop; reads as a dimmed text field | none |
107
- | error | error in the label; message readable | none |
108
-
109
- ### Transformation and precedence order
110
-
111
- - **ORD1 — Availability.** Disabled, then read-only, then editable, as in core.
112
-
113
- ### Performance and resources
114
-
115
- - **PR1 — No work while idle.** The view holds no timers; announcements fire
116
- only on first appearance or a change.
117
-
118
- ## Accessibility contract
119
-
120
- - **AR1 — Name, error, description.** The name is the label and its note; an
121
- error follows it in the label; the description, other status messages,
122
- "Read only", and the disabled reason are the description.
123
- - **AR2 — Rendered tree not measured.** Tests assert what the view sets; the
124
- rendered accessibility tree and keyboard focus are not measured until an
125
- app-hosted target exists.
126
-
127
- ## Design relationships
128
-
129
- | Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |
130
- | ---------------- | ------------------------- | -------------------------- | -------------- | ------------------ |
131
- | Field | the platform's text field | prescribed by the platform | primary | FR1, FR2 |
132
-
133
- The component implements design requirements without copying their rationale.
134
-
135
- Platform control: SwiftUI `TextField` and `SecureField` for editing; the drawn
136
- field in AV1 for read-only and disabled (`spec:AST-093` FR2). Guideline pages:
137
- Text fields and Accessibility in the Apple Human Interface Guidelines
138
- (`spec:AST-093` FR3).
139
-
140
- Theme values read (`spec:AST-093` FR4): `color.textPrimary`,
141
- `color.textSecondary`, `color.textDisabled`, `color.borderEmphasized`, the
142
- status roles `architecture:theme-tokens` INV11 assigns (`color.borderError`,
143
- `color.borderWarning`, `color.borderSuccess` for the border;
144
- `color.iconError`, `color.iconWarning`, `color.iconSuccess` for the icon;
145
- `color.errorMuted`, `color.warningMuted`, `color.successMuted` for the
146
- message ground and `color.onErrorMuted`, `color.onWarningMuted`,
147
- `color.onSuccessMuted` for its text),
148
- `size.elementSm`, `size.elementMd`, `size.elementLg`, `size.borderWidth`,
149
- `radius.element`, `space` steps, `font.body`, `font.label`, `font.supporting`,
150
- `font.weight.medium`, `font.weight.normal`,
151
- `font.family.body`, the theme's icons, and the Dynamic Type scale.
152
-
153
- ## Family and system relationships
154
-
155
- - `component:TextInput` and `family:input-fields` own the props and states;
156
- this record states only how Swift draws them.
157
-
158
- ## Verification map
159
-
160
- | Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
161
- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------ |
162
- | FR1 | `TextInputTests.swift` initializer and edit tests | both initializers; editable, read-only, disabled | differing props, or an edit that reaches `onChange` while not editable, fails | `audit:swift/TextInput/api` |
163
- | FR2 | `TextInputTests.swift` read-only, password, placeholder, and focus-stop tests, and the VoiceOver field each state gives `accessibilityRepresentation` (text or secure, dimmed when disabled, label, value, and description); the rendered tree and focus are not measured | read-only; read-only password; empty; disabled; disabled password; error | a shown password, a missing placeholder, a secure field read as text, an undimmed disabled field, or a disabled field without a stop fails | `audit:swift/TextInput/states` |
164
- | FR3 | `TextInputTests.swift` label, description, and announcement tests | error with and without a message; warning; type change | an error missing from the label, or a missed announcement change, fails | `audit:swift/TextInput/a11y` |
165
- | FR4 | `TooltipPresenterTests.swift` `.help` guard; `TextInputTests.swift` checks the row ends in buttons and that the status tip is a button named by its status with its message; overlap of the 44-point targets is not measured until an app-hosted test can hit-test them | clear and tooltip status together; tooltip, attached, and detached statuses | `.help` in a view, or a status tip without the button trait, fails | `audit:swift/TextInput/tips` |
166
- | FR5 | `TextInputTests.swift` base tests: `isHidden` leaves the control out of layout; `id` and the control base target; the identifier on the drawn control is not measured until an app-hosted test exists | `id`; `isHidden` | `isHidden` keeping the control in layout or hiding the label fails | `audit:swift/TextInput/base` |
167
-
168
- ## Decision log
169
-
170
- No component-local decision is recorded.
171
-
172
- ## Open questions
173
-
174
- None.
175
-
176
- ## Content boundary
177
-
178
- This file does not duplicate consumer prop tables/examples, current audit
179
- results, implementation steps, or family/system rules. It links to their owners.
@@ -1,191 +0,0 @@
1
- ---
2
- schema_version: 3
3
- template_version: 7
4
- kind: component
5
- id: component:swift/Thumbnail
6
- platform_of: component:Thumbnail
7
- authority: draft
8
- archive_reason: null
9
- superseded_by: null
10
- approved_by: null
11
- approved_at: null
12
- owners: [cixzhang]
13
- review_triggers: [public-api, behavior, layout, theming, accessibility]
14
- verified_by:
15
- [
16
- packages/native/apple/Tests/AstryxTests/ThumbnailTests.swift,
17
- packages/native/src/contract/contracts.test.ts,
18
- packages/native/src/theme/swiftIOSStrings.test.ts,
19
- ]
20
- modules: []
21
- families: []
22
- design_specs: []
23
- architecture: []
24
- contributing: []
25
- system_specs: [spec:AST-082, spec:AST-093]
26
- ---
27
-
28
- # Thumbnail (Swift) component contract
29
-
30
- ## Contract at a glance
31
-
32
- | Area | Contract |
33
- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
34
- | Public contract | `Thumbnail(src:, alt:, label:, isLoading:, isDisabled:, showRemoveOn:, onClick:, onRemove:)` and `Thumbnail(_ props: ThumbnailProps)`, a SwiftUI `View` in module `Astryx`. |
35
- | Behavior | A 64-point square on the theme's neutral plate showing the image, else a placeholder silhouette; a skeleton while loading with no image and an upload look over one; a remove button in the top trailing corner; a tap that opens the thumbnail. |
36
- | End-user impact | A person attaching images on iPhone sees the same previews as on the web, can open or remove each one, and VoiceOver reads each by its file name and description and announces once when an upload starts. |
37
- | Builder impact | An app passes the image URL, a label such as a file name, and the actions it supports. A single trailing closure is `onClick`. |
38
- | Compatibility/readiness | Additive: a new view, generated `ThumbnailProps`, and four of core's messages in the Swift string catalogs. Draft; built and tested on macOS and the iOS Simulator; device captures are attached to the change. |
39
- | Review checks | Reject a hidden remove button on a touch device, a tap or remove that works while disabled, a tap that works while loading, an unnamed thumbnail, an upload announced on every render, or a color that is not a theme token. |
40
- | Governing rules | `spec:AST-082` FR3, FR7; `spec:AST-086` FR8; `spec:AST-093` FR1–FR5; the Swift component API, theme environment, and accessibility (X1, X3, X4, X6, X7) records under `packages/native/specs/swift/library/`. |
41
-
42
- This table is a review projection; the body below is authoritative.
43
-
44
- ## Intent
45
-
46
- Thumbnail on Apple platforms is core's preview of an image attachment, drawn
47
- with SwiftUI's own image loading, progress view, and buttons.
48
-
49
- ## Compatibility and migration
50
-
51
- - Released default preserved: `not yet released`
52
- - Compatibility class: additive
53
- - Controlled/uncontrolled behavior: not applicable
54
- - Migration decision: none
55
-
56
- Consumer migration instructions belong in consumer docs and release notes.
57
-
58
- ## Ownership boundary
59
-
60
- **Owns**
61
-
62
- - The 64-point tile, its image, placeholder, skeleton, and upload look.
63
- - The remove button, its visibility, and the open tap.
64
- - The thumbnail's names and its upload announcement.
65
-
66
- **Does not own / non-goals**
67
-
68
- - The meaning of the props and the words — owned by `component:Thumbnail` and
69
- core's message catalogs.
70
- - Laying out several thumbnails, which belongs to the screen that holds them.
71
-
72
- ## Public concepts
73
-
74
- | Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |
75
- | ------------ | ------------------------------------ | -------------------------------------------------------------------------- | ----------------------------------------- | -------- | --------------------- | ------------ | ------------------------------------ |
76
- | picture | image, placeholder, skeleton, upload | what the tile shows | always | — | `component:Thumbnail` | experimental | a failed image shows the placeholder |
77
- | showRemoveOn | `hover`, `always` | `hover` shows remove under a pointer and always on touch; `always` at rest | with `onRemove` | `hover` | `component:Thumbnail` | experimental | none |
78
- | name | label and alt, label, alt, fallback | what VoiceOver reads for the thumbnail | always | fallback | `component:Thumbnail` | experimental | blank strings count as absent |
79
-
80
- ## Behavioral and layout contract
81
-
82
- | ID | Candidate invariant | Basis | Draft review state |
83
- | --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | ------------------ |
84
- | FR1 | The tile MUST be 64 by 64 points, clipped to `radius.element`, on `color.neutral`. It MUST show the image at `src` cropped to fill the tile, with a 1-point `color.border` inset edge on all four sides of the tile; with no `src`, or when the image fails, a 24-point image silhouette in `color.iconSecondary`. | core `Thumbnail` styles | verify |
85
- | FR2 | `isLoading` with no `src` MUST show a skeleton in `color.skeleton` at 25% opacity; after 1 second it climbs to 92.5% in ten equal held steps over core's default 550 ms medium duration and back, repeating, as core's does, and it rests at 25% under Reduce Motion; under Increase Contrast its color moves 30% toward `color.textPrimary`, as core's does under `prefers-contrast: more`. `isLoading` with a `src` MUST draw `color.overlay` over the image with the platform's small progress view in `color.onDark`, which keeps its size at any text size. | core `Thumbnail`; Swift accessibility X6 | verify |
86
- | FR3 | With `onRemove`, a 20-point remove button MUST sit `space.s1` from the top trailing corner on `color.overlay` with the shared `close` `Icon` at `xsm` in `color.onDark`, which the theme can remap and which keeps its size at any text size. It is visible at rest with `always` and on touch devices; with `hover` under a pointer, it appears while the pointer is over an enabled thumbnail or while its open or remove button has keyboard focus; a pointer reveals nothing on a disabled thumbnail, as core turns pointer events off there. | core `Thumbnail` `showRemoveOn`; `spec:AST-082` FR3 | verify |
87
- | FR4 | With `onClick`, not disabled, and not loading, the tile MUST be a SwiftUI `Button` that paints `color.overlayPressed` while pressed. `isDisabled` MUST draw the thumbnail at half opacity and turn off its tap and remove button. The open button while loading or disabled, and the remove button while disabled, MUST stay mounted but inert, so focus on them stays put and VoiceOver reads them dimmed (`spec:AST-085`; Swift accessibility X2); during an upload the remove button stays active, as core's does. | core `Thumbnail` | verify |
88
- | FR5 | With a `label`, the thumbnail MUST show it through the Astryx tooltip (`architecture:native-swift-library-tooltip`), as core's tooltip wraps the whole thumbnail: not a tab stop itself, keyboard focus on its open or remove button shows the label, and a direct tap opens it while an open action still runs, as the Tooltip by input table below states. A disabled thumbnail shows none, and the label is not a hint, since it is in the thumbnail's name. | core `Thumbnail` `label`; core `Tooltip`; `spec:AST-082` FR3 | verify |
89
- | FR6 | Both initializers MUST build the same `ThumbnailProps`; a single trailing closure is `onClick`. Base props come through `ThumbnailProps`: with `isHidden` the view draws nothing; `id` becomes the accessibility identifier. | Swift component API A2–A4, A7; `spec:AST-082` FR7 | verify |
90
-
91
- **Tooltip by input (FR5).** The Astryx tooltip's rules apply; this table
92
- states Thumbnail's choices.
93
-
94
- | Input | With a `label` | Disabled, or no `label` |
95
- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- |
96
- | Pointer | the bubble shows the label above the tile after 200 ms, stays while the pointer is on it, and a press hides it | nothing |
97
- | Keyboard focus | the label at once when keyboard focus is on the open or remove button, as focus within core's tooltip wrapper shows it; the thumbnail itself is not a tab stop | nothing |
98
- | Touch tap | a direct tap opens the bubble with the label, while an open action and an enclosing row still run; another tap on it, or a tap anywhere else, closes it, and that tap still reaches what it lands on | nothing |
99
- | VoiceOver | the label is read once, in the thumbnail's name; the bubble is hidden and the tap is left alone | nothing |
100
-
101
- ### Allowed variation
102
-
103
- - **AV1 — Glyphs and spinner.** The placeholder is the SF Symbol `photo.fill`
104
- and the spinner the platform's progress view.
105
-
106
- ### Representative states
107
-
108
- | State | Required invariant | Allowed variation |
109
- | ------------------------------ | --------------------------------------------- | ----------------- |
110
- | image | the image fills the tile with an inset edge | image content |
111
- | no image, failed image | the placeholder silhouette | AV1 |
112
- | loading without and with image | skeleton; upload overlay with a progress view | AV1 |
113
- | remove, hover and always | visible on touch; at rest with `always` | none |
114
- | tappable, disabled | a button; dimmed with no tap or remove | none |
115
- | light and dark, two themes | each theme's colors | none |
116
-
117
- ### Transformation and precedence order
118
-
119
- - **ORD1 — Picture.** Skeleton (loading, no `src`) → image → placeholder.
120
- - **ORD2 — Name.** `label — alt` → `label` → `alt` → core's fallback word.
121
-
122
- ### Performance and resources
123
-
124
- - **PR1 — System loading.** Images load through `AsyncImage` and the system
125
- URL cache.
126
-
127
- ## Accessibility contract
128
-
129
- - **AR1 — Named group.** The thumbnail is a container named by ORD2. The image
130
- reads as its `alt` and is hidden without one (X4). With `onClick` the open
131
- button covers the image and its name, "Open" with the thumbnail's name,
132
- stands for it, so VoiceOver does not read the image on its own, as core's
133
- open button wraps the image and a button's content is presentational.
134
- - **AR2 — Named actions.** The open button reads "Open" with the name and the
135
- remove button "Remove" with the name, from core's message catalogs in the
136
- person's language (X1).
137
- - **AR3 — Upload announced once.** Each upload start, including one already
138
- in progress when the thumbnail appears, announces core's "Loading" once, as
139
- core does; the spinner is hidden (`spec:AST-086` FR8; X3).
140
- - **AR4 — Targets.** The remove button answers taps across 44 by 44 points
141
- without moving its drawing (X7).
142
- - **AR5 — Rendered tree not measured.** Tests assert what the view sets; the
143
- rendered accessibility tree, the hit region, and the announcement are not
144
- measured until an app-hosted target exists.
145
-
146
- ## Design relationships
147
-
148
- | Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |
149
- | ---------------- | ---------------------------------------- | ------------------------ | -------------- | ------------------ |
150
- | Image, overlays | Apple Human Interface Guidelines, Images | prescribed by core | supporting | FR1–FR4 |
151
-
152
- The component implements design requirements without copying their rationale.
153
-
154
- Platform controls: SwiftUI `AsyncImage` for the image, `ProgressView` for the
155
- upload spinner, and `Button` for the open tap and remove action
156
- (`spec:AST-093` FR2). SwiftUI has no thumbnail control, so the tile and its
157
- overlays are drawn here. Guideline pages: Images, Progress indicators, Buttons,
158
- and Accessibility in the Apple Human Interface Guidelines.
159
-
160
- Theme values read: `color.neutral`, `color.border`, `color.iconSecondary`,
161
- `color.overlay`, `color.onDark`, `color.overlayPressed`, `radius.element`,
162
- `space.s1`, `color.skeleton`, `color.textPrimary`, the theme's `close` icon, Reduce Motion, and Increase Contrast; and, for the Astryx tooltip's bubble, `color.textPrimary`, `color.backgroundSurface`, `space.s1`, `space.s2`, `radius.container`, and the body text size and weight.
163
-
164
- ## Family and system relationships
165
-
166
- - `component:Thumbnail` owns the props, the words, and the look; this record
167
- states only how Swift draws them.
168
-
169
- ## Verification map
170
-
171
- | Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
172
- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
173
- | FR1 | `ThumbnailTests.swift` size, plate, and two-theme renders | no image; default, neutral, butter; the largest text size | a wrong size or a color of its own fails | `audit:swift/Thumbnail/tile` |
174
- | FR2 | `ThumbnailTests.swift` loading states, skeleton color, contrast mix, and largest-text render | loading with and without `src`; Increase Contrast; the largest text size | a skeleton over an image, no upload look, a wrong skeleton color, or a tile that grows fails | `audit:swift/Thumbnail/loading` |
175
- | FR3, FR4 | `ThumbnailTests.swift` remove, tap, disabled, and mounted-while-inert tests and render | `always`, `hover`; disabled; loading | a hidden remove on touch or under keyboard focus, a hard-coded remove glyph, or a tap while disabled or loading fails; an open or remove button that unmounts while loading or disabled fails; a pointer that reveals the remove button on a disabled thumbnail fails | `audit:swift/Thumbnail/actions` |
176
- | FR5 | `TooltipPresenterTests.swift` for each input; `ThumbnailTests.swift` name and focus-within tests | enabled and disabled; blank label | a tooltip on a disabled thumbnail, or none for keyboard focus on its open or remove button, fails; that the tile keeps one structure across a disabled toggle or an upload ending is not measured, since a test cannot see a rebuild | `audit:swift/Thumbnail/tooltip` |
177
- | FR6 | `ThumbnailTests.swift` initializer, trailing-closure, and hidden tests; `contracts.test.ts` | both initializers; `isHidden` | differing props or a drawn hidden thumbnail fails | `audit:swift/Thumbnail/api` |
178
- | AR1, AR2 | `ThumbnailTests.swift` name and open-button tests (`hasOpenButton` decides the image's hiding); `swiftIOSStrings.test.ts`; the rendered tree is not measured | label and alt, each alone, neither; with and without `onClick` | a wrong name or a missing catalog message fails | `audit:swift/Thumbnail/a11y` |
179
-
180
- ## Decision log
181
-
182
- No component-local decision is recorded.
183
-
184
- ## Open questions
185
-
186
- None.
187
-
188
- ## Content boundary
189
-
190
- This file does not duplicate consumer prop tables/examples, current audit
191
- results, implementation steps, or family/system rules. It links to their owners.