Repository navigation
spec(native): typed slots for Swift (text, icon, named components, content) - #8037
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
|
|
/approve-spec 2179207 |
There was a problem hiding this comment.
Changes requested: the record's direction is approved by an engineering owner, but S1 and S3 let Swift content slots take any view under an AST-082 FR4 allowance that the current FR4 does not contain, so land that FR4 amendment first (or include it here) or narrow content slots to the components the core slot names.
- S4 should name which children take their owner's size, since core inherits size only by contract and an unsized Avatar in a web Item keeps its own
mdsize. - S3 and S5 should use the core names
startContentandendContent, withmarkerfirst in the reading order, instead ofstartandend. - The S1/S6 acceptance row should fail generation only for a kept free-form prop, matching S1's rule that an unslotted prop stays web-only.
[Automated review]
| - A **content** slot accepts any SwiftUI view, through a `@ViewBuilder` | ||
| closure (S3). The core's content slot holds named Astryx components; Swift | ||
| accepts this wider form under AST-082 FR4's allowance that a platform may | ||
| accept a wider form for a slot with the same meaning, as the web accepts a | ||
| React node. The component's native additions still name the Astryx |
There was a problem hiding this comment.
Current AST-082 FR4 has no allowance for a platform to accept a wider form for a slot: it places free-form content in the web contract and in platform contracts whose implementation runs React, and lists typed slots only as examples. Land the FR4 amendment first (or include it here) and keep this citation, or narrow content slots to the components the core slot names.
| - **S3 — Content slots are open, the SwiftUI way.** A content slot is a generic | ||
| `@ViewBuilder` closure parameter (`start: () -> Start` where | ||
| `Start: View`), as in SwiftUI's `Label { } icon: { }`, never `AnyView`. For | ||
| each Astryx component the core slot names, the view also has a convenience | ||
| initializer that takes that component's props directly (for example a row's | ||
| `start: AvatarProps`). The props initializer takes the slot as the matching | ||
| generated node type. |
There was a problem hiding this comment.
Item's core props are marker, startContent, label, description, and endContent. AST-082 FR3 says a platform contract never renames a core prop, so the Swift parameter here would be startContent, not start; S5's order on line 55 should also use the core names, with marker first.
| whatever view is in it. An Astryx child takes its size from its owner, as | ||
| core does (an `Icon` in a small `IconButton` is small); an explicit size on | ||
| the child wins. |
There was a problem hiding this comment.
Core inherits size only where a contract adopts the cascade (architecture:component-size-cascade INV2) or for an Icon in an owner's documented icon slot (component:Icon FR5); an unsized Avatar in a web Item stays md. Please name which children inherit here, and keep every other child's own default.
|
|
||
| | Requirement | Check | | ||
| | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | S1, S6 | The generator test fails on a fixture component whose free-form prop has no slot kind, and produces the Swift form of each kind for a fixture with all three. | |
There was a problem hiding this comment.
S1 (line 33) keeps an unslotted free-form prop in the web contract, and S6 fails only a kept one; this row fails any free-form prop without a slot kind. Make it a kept prop with no kind (or a content slot that names no components), and add a fixture whose unkept prop stays web-only.
|
/approve-spec c49b726 |
There was a problem hiding this comment.
Changes requested: an engineering owner approved this record's direction, but S1 and S3 let Swift content slots take any view under an AST-082 FR4 amendment that is not on main yet (it is open in #8070), so this record should land after that amendment or narrow content slots to the components the core slot names.
- S2 should generate the built-in
IconNamemembers from the names AST-082 FR17 has the portable entry carry, not from core's icon registry, which is web code that FR16 keeps native from reading. - S1's localized-text sentence points to a component API spec that is not on
main; drop it (AST-093 FR5 already fixesString) or link that record once it lands.
[Automated review]
| - A **content** slot accepts any SwiftUI view, through a `@ViewBuilder` | ||
| closure (S3). The core's content slot holds named Astryx components; Swift | ||
| accepts this wider form under the AST-082 FR4 amendment that lets a | ||
| platform accept a wider form for a slot with the same meaning, as the web | ||
| accepts a React node. The component's native additions still name the Astryx |
There was a problem hiding this comment.
CURRENT AST-082 FR4 has no wider-form allowance: it places free-form content in the web contract and in platform contracts whose implementation runs React. The clause cited here exists only in open #8070. Land #8070 before this record, as the description plans, or narrow content slots to the components the core slot names.
| - **S2 — Icon names are a string-backed type with the built-ins as members.** | ||
| `IconName` is a `RawRepresentable`, `ExpressibleByStringLiteral`, | ||
| `Hashable`, `Codable`, `Sendable` value. Every built-in semantic name is a | ||
| static member (`.search`, `.close`), generated from core's icon registry. A |
There was a problem hiding this comment.
Core's icon registry is packages/core/src/Icon/globalIconRegistry.tsx, which maps every name to a React node (the web part, AST-082 FR18). FR16 lets native read core only through the portable entry, and FR17 has that entry carry the built-in names, so these members would come from "the built-in names the portable entry carries (AST-082 FR17)".
| - A **text** slot is a `String`, the contract's exact type (AST-093 FR5). A | ||
| localizable spelling waits on the component API spec's open question about | ||
| SwiftUI spellings. |
There was a problem hiding this comment.
No component API spec is on main; this question is OQ1 of open #8035. AST-093 FR5 already fixes the contract's String, so this sentence can go, or link that record by path once it lands.
|
/approve-spec 03df419 |
There was a problem hiding this comment.
Changes requested: an engineering owner approved this record's direction, but S1 and S3 let Swift content slots take any view under an AST-082 FR4 amendment that is still open in #8070, and S2 now cites an AST-082 FR16 build-time read that exists only in open #8048, which the landing order does not name.
- Land #8070 and #8048 before this record (and add #8048 to the landing order), or narrow content slots to the components the core slot names and generate the
IconNamemembers from native's own built-in list. - S4's “an explicit size on any child wins” contradicts core's
AvatarGroup, whose size overrides every childAvatar's size, so let that clause defer to core.
[Automated review]
| accepts this wider form under the AST-082 FR4 amendment that lets a | ||
| platform accept a wider form for a slot with the same meaning, as the web | ||
| accepts a React node. The component's native additions still name the Astryx |
There was a problem hiding this comment.
Current AST-082 FR4 has no wider-form clause: it keeps free-form content and render functions in the web contract and in platform contracts whose implementation runs React. The clause cited here exists only in open #8070, so land that first (as the description plans) and re-approve, or narrow content slots to the components the core slot names.
| static member (`.search`, `.close`), generated from AST-082 FR17's shared | ||
| icon names, read at build time through the icon-names read AST-082 FR16 lists | ||
| (later through core's portable entry), never from core's web icon registry. A |
There was a problem hiding this comment.
Current AST-082 FR16 lists no build-time read (native reads core only through a portable entry); the list that names built-in icon names is only in open #8048, which the landing order does not name. The one icon-names read native has today, readCoreIconNames in packages/native/scripts/core-docs.mjs, parses packages/core/src/Icon/globalIconRegistry.tsx. Add #8048 to the landing order and name the read meant here, or generate the members from native's own BUILTIN_ICON_NAMES.
| adopts the size cascade. Every other child keeps its own default (an unsized | ||
| `Avatar` in a list item stays `md`), and an explicit size on any child wins. |
There was a problem hiding this comment.
Core's AvatarGroup overrides each child Avatar's size, explicit or default (AvatarGroup.doc.mjs; Avatar.tsx resolves avatarGroup?.size ?? size), and AST-082 FR3 keeps that meaning on every platform. Let this clause defer to core: an explicit size wins wherever core's does, and a group that sizes its members keeps doing so.
|
/approve-spec d61bde2 |
There was a problem hiding this comment.
Changes requested: an engineering owner approved this record's direction, but S1 and S3 let Swift content slots take any SwiftUI view under an AST-082 FR4 amendment that is not on main yet (it is open in #8070), and S1's localized-text pointer names a component API record that exists only in open #8035.
- Land #8070 and #8035 first, as the description plans, then cite the FR4 clause itself rather than “its amendment” and re-approve the new head with
/approve-spec, or narrow content slots to the components the core slot names. - S1's example on line 30 says a list item's
startContentholds one ofAvatar,Icon,Thumbnail, but core puts a checkbox there (CheckboxListItem, and ListItem'sinteractiveRefdocs) and never aThumbnail, so take the example from core.
[Automated review]
| accepts this wider form under the AST-082 FR4 amendment that lets a | ||
| platform accept a wider form for a slot with the same meaning, as the web | ||
| accepts a React node. The component's native additions still name the Astryx | ||
| components the core slot holds, and whether it holds one or many (a list item's `startContent` holds one of `Avatar`, `Icon`, `Thumbnail`; a card holds many). |
There was a problem hiding this comment.
Core puts a checkbox in this slot (CheckboxListItem renders one as Item's startContent, and ListItem's interactiveRef docs name “a checkbox in startContent”), and component:Item lists start content as “a status dot, a radio or checkbox, an icon, a short timestamp”; no core doc, story or source puts a Thumbnail here. Take the example from core (an Icon, an Avatar, or a checkbox), or leave the list to each component's spec.
|
/approve-spec a73df5c |
There was a problem hiding this comment.
Changes requested: an engineering owner approved this record's direction, but S1 and S3 still let Swift content slots take any SwiftUI view under an AST-082 FR4 clause that is not on main yet (it is proposed in #8070). Land #8070 first and re-approve this record on its new head, or narrow content slots to the components the core slot names.
- S1 says a localized text spelling is outside this record (lines 22–23) but then rules out localized text (line 31); keep one of the two.
[Automated review]
| wider form for a content slot with the same meaning, as the web | ||
| accepts a React node. The component's native additions still name the Astryx | ||
| components the core slot holds, and whether it holds one or many (a list item's `startContent` holds one of `Icon`, `Avatar`, or `CheckboxInput`; a card holds many). | ||
| Text and icon slots take no wider form (no attributed or localized text, no |
There was a problem hiding this comment.
Lines 22–23 say a localized text spelling is outside this record, but this line rules localized text out for text slots. Keep one: drop “or localized” here (“no attributed text, no image”), or drop the sentence on lines 22–23.
|
/approve-spec a790b21 |
…ill sizes and orders them
…size, cite the pending FR4 amendment
…he component API spec by path
…e component API spec
a790b21 to
91a6995
Compare
|
/approve-spec 91a6995 |
There was a problem hiding this comment.
Looks good: S1–S6 now rest on AST-082 FR4, FR16 and FR17 as they stand on main, an engineering owner approved this exact head, and the earlier requested changes are addressed. Two optional wording tweaks are left inline: say which initializer S3's last sentence means, and name the macOS floor beside iOS in the S2 check.
[Automated review]
| `startContent: AvatarProps`). The props initializer takes the slot as the matching | ||
| generated node type. |
There was a problem hiding this comment.
Non-blocking: this sentence follows the AvatarProps convenience initializer, so it reads as giving that same initializer a node type, while the S3 check (line 77) has it take AvatarProps. If it means the initializer that takes the view's generated props, naming it would remove the ambiguity, for example: “The initializer that takes the view's generated props takes the slot as the matching generated node type.”
| | Requirement | Check | | ||
| | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| | S1, S6 | The generator test fails on a fixture component that keeps a free-form prop with no slot kind, or keeps a content slot that names no components; a fixture's unkept free-form prop stays web-only with no Swift form; a fixture with all three kinds produces each Swift form. | | ||
| | S2 | Every built-in name maps to an SF Symbol that exists on the package's iOS floor; registering `acme:rocket` makes `"acme:rocket"` draw it; an unregistered name stops a development build and draws nothing in release. | |
There was a problem hiding this comment.
Non-blocking: the Swift package also declares macOS 14 (packages/native/apple/Package.swift), and AST-082 FR17 checks icon map coverage per native platform, so “exists on the package's iOS and macOS floors” would cover both platforms this record serves.
Exact decision needed
How each typed slot kind appears in Swift: text, icon, and content. The kinds themselves are AST-082's (FR4, with a proposed amendment that names them); this spec only gives their SwiftUI form. This unblocks icons in buttons and badges and the start and end parts of list rows. Draft until the owner approves; nothing is built from it before then.
Existing authority searched
spec:AST-082(current) FR4: free-form content is not portable; the core expresses it as a typed slot, "such as text, an icon, or a named Astryx component". FR17: shared semantic icon names, namespaced<library>:<name>names, app-registered images, no web icon substitution.textandcontentslots today; icon props of Button and Badge are web-only because no icon slot exists.Decision
String(localized text spellings are outside this record); icon is anIconName; content accepts any SwiftUI view, using AST-082 FR4's allowance that a platform may accept a wider form with the same meaning (as the web's React node). Text and icon take no wider form.IconNameis a string-backed value with built-in names as static members and app-registered namespaced names; an unknown name stops a development build and draws nothing in release.@ViewBuilderclosures, as in SwiftUI'sLabel, neverAnyView, with convenience initializers for the Astryx components the core slot names.Rejected alternatives
None recorded in the spec.
Landing order
S1 and S3 apply AST-082 FR4 as amended by #8070 (a platform may accept a wider form for a content slot with the same meaning). This pull request lands after #8070.
Claim scope and non-goals
Per-component slot lists are set in each component's spec. Generator and Swift changes come after approval.
Evidence and implementation relationship
One file:
packages/native/specs/swift/library/slots.md.Writing rubric results
Scope
packages/native/.