Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(native): contracts for Button, Divider, Heading, ProgressBar, Switch, Text, TextInput (#7986)

Cindy Zhang95b39e1a2801
diff --git a/packages/native/README.md b/packages/native/README.md
index 468688cec9..0e6f4545e2 100644
--- a/packages/native/README.md
+++ b/packages/native/README.md
@@ -20,8 +20,9 @@ rests on evidence.
| Native theme | `defineNativeTheme` | Durable theme intent (`material: 'opaque' \| 'translucent'`) plus platform entries scoped by OS version, such as Liquid Glass from iOS 26. Never sets tokens. |
| Icons | `NATIVE_ICON_DEFAULTS` | Astryx's built-in icon names mapped to SF Symbols on Apple platforms and Material Symbols on Android. |
-Only `Selector` has native additions so far. React Native and Android bindings
-are not built yet; see [the experiment matrix](#experiment-matrix).
+Contracts cover Button, Divider, Heading, ProgressBar, Selector, Switch, Text,
+and TextInput. React Native and Android bindings are not built yet; see
+[the experiment matrix](#experiment-matrix).
```ts
// tsconfig.json for an iOS app: "customConditions": ["ios"]
@@ -40,7 +41,7 @@ How core documentation becomes a contract:
them, such as `(checked: boolean, e: ChangeEvent) => void`, keeps the values
in the core; the event stays on the web.
- A callback that carries only an event stays on the web, unless the component
- names it in `callbacks`, as a button's `onClick` would. Its core form takes no
+ names it in `callbacks`, as Button does for `onClick`. Its core form takes no
arguments. A callback with an event before a value stays on the web either
way.
- Free-form content becomes a typed slot only where a component declares one
diff --git a/packages/native/apple/Sources/AstryxNative/Generated/Button.swift b/packages/native/apple/Sources/AstryxNative/Generated/Button.swift
new file mode 100644
index 0000000000..28c1784ec4
--- /dev/null
+++ b/packages/native/apple/Sources/AstryxNative/Generated/Button.swift
@@ -0,0 +1,78 @@
+// Generated by @astryxdesign/native. Do not edit.
+public enum ButtonVariant: String, CaseIterable, Sendable {
+ case primary = "primary"
+ case secondary = "secondary"
+ case ghost = "ghost"
+ case destructive = "destructive"
+}
+public enum ButtonSize: String, CaseIterable, Sendable {
+ case sm = "sm"
+ case md = "md"
+ case lg = "lg"
+}
+public enum ButtonElevation: String, CaseIterable, Sendable {
+ case none = "none"
+ case low = "low"
+ case med = "med"
+ case high = "high"
+}
+#if os(iOS)
+public struct ButtonProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var label: String
+ public var variant: ButtonVariant?
+ public var size: ButtonSize?
+ public var elevation: ButtonElevation?
+ public var isLoading: Bool?
+ public var isInterruptible: Bool?
+ public var isDisabled: Bool?
+ public var tooltip: String?
+ public var onClick: (() -> Void)?
+ public var href: String?
+ public init(label: String, variant: ButtonVariant? = nil, size: ButtonSize? = nil, elevation: ButtonElevation? = nil, isLoading: Bool? = nil, isInterruptible: Bool? = nil, isDisabled: Bool? = nil, tooltip: String? = nil, onClick: (() -> Void)? = nil, href: String? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.label = label
+ self.variant = variant
+ self.size = size
+ self.elevation = elevation
+ self.isLoading = isLoading
+ self.isInterruptible = isInterruptible
+ self.isDisabled = isDisabled
+ self.tooltip = tooltip
+ self.onClick = onClick
+ self.href = href
+ self.base = base
+ }
+}
+#endif
+#if os(macOS)
+public struct ButtonProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var label: String
+ public var variant: ButtonVariant?
+ public var size: ButtonSize?
+ public var elevation: ButtonElevation?
+ public var isLoading: Bool?
+ public var isInterruptible: Bool?
+ public var isDisabled: Bool?
+ public var tooltip: String?
+ public var onClick: (() -> Void)?
+ public var href: String?
+ public init(label: String, variant: ButtonVariant? = nil, size: ButtonSize? = nil, elevation: ButtonElevation? = nil, isLoading: Bool? = nil, isInterruptible: Bool? = nil, isDisabled: Bool? = nil, tooltip: String? = nil, onClick: (() -> Void)? = nil, href: String? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.label = label
+ self.variant = variant
+ self.size = size
+ self.elevation = elevation
+ self.isLoading = isLoading
+ self.isInterruptible = isInterruptible
+ self.isDisabled = isDisabled
+ self.tooltip = tooltip
+ self.onClick = onClick
+ self.href = href
+ self.base = base
+ }
+}
+#endif
diff --git a/packages/native/apple/Sources/AstryxNative/Generated/Divider.swift b/packages/native/apple/Sources/AstryxNative/Generated/Divider.swift
new file mode 100644
index 0000000000..efa9e8c8f1
--- /dev/null
+++ b/packages/native/apple/Sources/AstryxNative/Generated/Divider.swift
@@ -0,0 +1,45 @@
+// Generated by @astryxdesign/native. Do not edit.
+public enum DividerOrientation: String, CaseIterable, Sendable {
+ case horizontal = "horizontal"
+ case vertical = "vertical"
+}
+public enum DividerVariant: String, CaseIterable, Sendable {
+ case subtle = "subtle"
+ case strong = "strong"
+}
+#if os(iOS)
+public struct DividerProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var orientation: DividerOrientation?
+ public var label: String?
+ public var variant: DividerVariant?
+ public var isFullBleed: Bool?
+ public init(orientation: DividerOrientation? = nil, label: String? = nil, variant: DividerVariant? = nil, isFullBleed: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.orientation = orientation
+ self.label = label
+ self.variant = variant
+ self.isFullBleed = isFullBleed
+ self.base = base
+ }
+}
+#endif
+#if os(macOS)
+public struct DividerProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var orientation: DividerOrientation?
+ public var label: String?
+ public var variant: DividerVariant?
+ public var isFullBleed: Bool?
+ public init(orientation: DividerOrientation? = nil, label: String? = nil, variant: DividerVariant? = nil, isFullBleed: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.orientation = orientation
+ self.label = label
+ self.variant = variant
+ self.isFullBleed = isFullBleed
+ self.base = base
+ }
+}
+#endif
diff --git a/packages/native/apple/Sources/AstryxNative/Generated/Heading.swift b/packages/native/apple/Sources/AstryxNative/Generated/Heading.swift
new file mode 100644
index 0000000000..2e6c59093b
--- /dev/null
+++ b/packages/native/apple/Sources/AstryxNative/Generated/Heading.swift
@@ -0,0 +1,97 @@
+// Generated by @astryxdesign/native. Do not edit.
+public enum HeadingLevel: Int, CaseIterable, Sendable {
+ case v1 = 1
+ case v2 = 2
+ case v3 = 3
+ case v4 = 4
+ case v5 = 5
+ case v6 = 6
+}
+public enum HeadingType: String, CaseIterable, Sendable {
+ case display1 = "display-1"
+ case display2 = "display-2"
+ case display3 = "display-3"
+}
+public enum HeadingWeight: String, CaseIterable, Sendable {
+ case normal = "normal"
+ case medium = "medium"
+ case semibold = "semibold"
+ case bold = "bold"
+}
+public enum HeadingAccessibilityLevel: Int, CaseIterable, Sendable {
+ case v1 = 1
+ case v2 = 2
+ case v3 = 3
+ case v4 = 4
+ case v5 = 5
+ case v6 = 6
+}
+public enum HeadingColor: String, CaseIterable, Sendable {
+ case primary = "primary"
+ case secondary = "secondary"
+ case disabled = "disabled"
+ case placeholder = "placeholder"
+ case accent = "accent"
+ case inherit = "inherit"
+}
+public enum HeadingJustify: String, CaseIterable, Sendable {
+ case start = "start"
+ case center = "center"
+ case end = "end"
+}
+#if os(iOS)
+public struct HeadingProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var level: HeadingLevel
+ public var type: HeadingType?
+ public var weight: HeadingWeight?
+ public var children: String
+ public var accessibilityLevel: HeadingAccessibilityLevel?
+ public var color: HeadingColor?
+ public var maxLines: Double?
+ public var justify: HeadingJustify?
+ public var hasStrikethrough: Bool?
+ public init(level: HeadingLevel, type: HeadingType? = nil, weight: HeadingWeight? = nil, children: String, accessibilityLevel: HeadingAccessibilityLevel? = nil, color: HeadingColor? = nil, maxLines: Double? = nil, justify: HeadingJustify? = nil, hasStrikethrough: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.level = level
+ self.type = type
+ self.weight = weight
+ self.children = children
+ self.accessibilityLevel = accessibilityLevel
+ self.color = color
+ self.maxLines = maxLines
+ self.justify = justify
+ self.hasStrikethrough = hasStrikethrough
+ self.base = base
+ }
+}
+#endif
+#if os(macOS)
+public struct HeadingProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var level: HeadingLevel
+ public var type: HeadingType?
+ public var weight: HeadingWeight?
+ public var children: String
+ public var accessibilityLevel: HeadingAccessibilityLevel?
+ public var color: HeadingColor?
+ public var maxLines: Double?
+ public var justify: HeadingJustify?
+ public var hasStrikethrough: Bool?
+ public init(level: HeadingLevel, type: HeadingType? = nil, weight: HeadingWeight? = nil, children: String, accessibilityLevel: HeadingAccessibilityLevel? = nil, color: HeadingColor? = nil, maxLines: Double? = nil, justify: HeadingJustify? = nil, hasStrikethrough: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.level = level
+ self.type = type
+ self.weight = weight
+ self.children = children
+ self.accessibilityLevel = accessibilityLevel
+ self.color = color
+ self.maxLines = maxLines
+ self.justify = justify
+ self.hasStrikethrough = hasStrikethrough
+ self.base = base
+ }
+}
+#endif
diff --git a/packages/native/apple/Sources/AstryxNative/Generated/ProgressBar.swift b/packages/native/apple/Sources/AstryxNative/Generated/ProgressBar.swift
new file mode 100644
index 0000000000..830597ded7
--- /dev/null
+++ b/packages/native/apple/Sources/AstryxNative/Generated/ProgressBar.swift
@@ -0,0 +1,72 @@
+// Generated by @astryxdesign/native. Do not edit.
+public enum ProgressBarVariant: String, CaseIterable, Sendable {
+ case accent = "accent"
+ case success = "success"
+ case warning = "warning"
+ case error = "error"
+ case neutral = "neutral"
+}
+public struct ProgressBarMarks: Equatable, Sendable {
+ public var value: Double
+ public var label: String
+ public init(value: Double, label: String) {
+ self.value = value
+ self.label = label
+ }
+}
+#if os(iOS)
+public struct ProgressBarProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var label: String
+ public var value: Double?
+ public var max: Double?
+ public var isLabelHidden: Bool?
+ public var hasValueLabel: Bool?
+ public var variant: ProgressBarVariant?
+ public var isIndeterminate: Bool?
+ public var marks: [ProgressBarMarks]?
+ public var isDisabled: Bool?
+ public init(label: String, value: Double? = nil, max: Double? = nil, isLabelHidden: Bool? = nil, hasValueLabel: Bool? = nil, variant: ProgressBarVariant? = nil, isIndeterminate: Bool? = nil, marks: [ProgressBarMarks]? = nil, isDisabled: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.label = label
+ self.value = value
+ self.max = max
+ self.isLabelHidden = isLabelHidden
+ self.hasValueLabel = hasValueLabel
+ self.variant = variant
+ self.isIndeterminate = isIndeterminate
+ self.marks = marks
+ self.isDisabled = isDisabled
+ self.base = base
+ }
+}
+#endif
+#if os(macOS)
+public struct ProgressBarProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var label: String
+ public var value: Double?
+ public var max: Double?
+ public var isLabelHidden: Bool?
+ public var hasValueLabel: Bool?
+ public var variant: ProgressBarVariant?
+ public var isIndeterminate: Bool?
+ public var marks: [ProgressBarMarks]?
+ public var isDisabled: Bool?
+ public init(label: String, value: Double? = nil, max: Double? = nil, isLabelHidden: Bool? = nil, hasValueLabel: Bool? = nil, variant: ProgressBarVariant? = nil, isIndeterminate: Bool? = nil, marks: [ProgressBarMarks]? = nil, isDisabled: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.label = label
+ self.value = value
+ self.max = max
+ self.isLabelHidden = isLabelHidden
+ self.hasValueLabel = hasValueLabel
+ self.variant = variant
+ self.isIndeterminate = isIndeterminate
+ self.marks = marks
+ self.isDisabled = isDisabled
+ self.base = base
+ }
+}
+#endif
diff --git a/packages/native/apple/Sources/AstryxNative/Generated/Switch.swift b/packages/native/apple/Sources/AstryxNative/Generated/Switch.swift
new file mode 100644
index 0000000000..daad0dfba6
--- /dev/null
+++ b/packages/native/apple/Sources/AstryxNative/Generated/Switch.swift
@@ -0,0 +1,106 @@
+// Generated by @astryxdesign/native. Do not edit.
+public enum SwitchSize: String, CaseIterable, Sendable {
+ case sm = "sm"
+ case md = "md"
+}
+public enum SwitchStatusType: String, CaseIterable, Sendable {
+ case warning = "warning"
+ case error = "error"
+ case success = "success"
+}
+public struct SwitchStatus: Equatable, Sendable {
+ public var type: SwitchStatusType
+ public var message: String?
+ public init(type: SwitchStatusType, message: String? = nil) {
+ self.type = type
+ self.message = message
+ }
+}
+public enum SwitchLabelPosition: String, CaseIterable, Sendable {
+ case start = "start"
+ case end = "end"
+}
+public enum SwitchLabelSpacing: String, CaseIterable, Sendable {
+ case hug = "hug"
+ case spread = "spread"
+}
+#if os(iOS)
+public struct SwitchProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var label: String
+ public var value: Bool
+ public var onChange: ((Bool) -> Void)?
+ public var isLoading: Bool?
+ public var isLabelHidden: Bool?
+ public var description: String?
+ public var isDisabled: Bool?
+ public var size: SwitchSize?
+ public var disabledMessage: String?
+ public var isOptional: Bool?
+ public var isRequired: Bool?
+ public var status: SwitchStatus?
+ public var labelTooltip: String?
+ public var labelPosition: SwitchLabelPosition?
+ public var labelSpacing: SwitchLabelSpacing?
+ public init(label: String, value: Bool, onChange: ((Bool) -> Void)? = nil, isLoading: Bool? = nil, isLabelHidden: Bool? = nil, description: String? = nil, isDisabled: Bool? = nil, size: SwitchSize? = nil, disabledMessage: String? = nil, isOptional: Bool? = nil, isRequired: Bool? = nil, status: SwitchStatus? = nil, labelTooltip: String? = nil, labelPosition: SwitchLabelPosition? = nil, labelSpacing: SwitchLabelSpacing? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.label = label
+ self.value = value
+ self.onChange = onChange
+ self.isLoading = isLoading
+ self.isLabelHidden = isLabelHidden
+ self.description = description
+ self.isDisabled = isDisabled
+ self.size = size
+ self.disabledMessage = disabledMessage
+ self.isOptional = isOptional
+ self.isRequired = isRequired
+ self.status = status
+ self.labelTooltip = labelTooltip
+ self.labelPosition = labelPosition
+ self.labelSpacing = labelSpacing
+ self.base = base
+ }
+}
+#endif
+#if os(macOS)
+public struct SwitchProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var label: String
+ public var value: Bool
+ public var onChange: ((Bool) -> Void)?
+ public var isLoading: Bool?
+ public var isLabelHidden: Bool?
+ public var description: String?
+ public var isDisabled: Bool?
+ public var size: SwitchSize?
+ public var disabledMessage: String?
+ public var isOptional: Bool?
+ public var isRequired: Bool?
+ public var status: SwitchStatus?
+ public var labelTooltip: String?
+ public var labelPosition: SwitchLabelPosition?
+ public var labelSpacing: SwitchLabelSpacing?
+ public init(label: String, value: Bool, onChange: ((Bool) -> Void)? = nil, isLoading: Bool? = nil, isLabelHidden: Bool? = nil, description: String? = nil, isDisabled: Bool? = nil, size: SwitchSize? = nil, disabledMessage: String? = nil, isOptional: Bool? = nil, isRequired: Bool? = nil, status: SwitchStatus? = nil, labelTooltip: String? = nil, labelPosition: SwitchLabelPosition? = nil, labelSpacing: SwitchLabelSpacing? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.label = label
+ self.value = value
+ self.onChange = onChange
+ self.isLoading = isLoading
+ self.isLabelHidden = isLabelHidden
+ self.description = description
+ self.isDisabled = isDisabled
+ self.size = size
+ self.disabledMessage = disabledMessage
+ self.isOptional = isOptional
+ self.isRequired = isRequired
+ self.status = status
+ self.labelTooltip = labelTooltip
+ self.labelPosition = labelPosition
+ self.labelSpacing = labelSpacing
+ self.base = base
+ }
+}
+#endif
diff --git a/packages/native/apple/Sources/AstryxNative/Generated/Text.swift b/packages/native/apple/Sources/AstryxNative/Generated/Text.swift
new file mode 100644
index 0000000000..31718aa044
--- /dev/null
+++ b/packages/native/apple/Sources/AstryxNative/Generated/Text.swift
@@ -0,0 +1,100 @@
+// Generated by @astryxdesign/native. Do not edit.
+public enum TextType: String, CaseIterable, Sendable {
+ case body = "body"
+ case large = "large"
+ case label = "label"
+ case supporting = "supporting"
+ case code = "code"
+ case display1 = "display-1"
+ case display2 = "display-2"
+ case display3 = "display-3"
+ case inherit = "inherit"
+}
+public enum TextSize: String, CaseIterable, Sendable {
+ case v4xs = "4xs"
+ case v3xs = "3xs"
+ case v2xs = "2xs"
+ case xsm = "xsm"
+ case sm = "sm"
+ case base = "base"
+ case lg = "lg"
+ case xl = "xl"
+ case v2xl = "2xl"
+ case v3xl = "3xl"
+ case v4xl = "4xl"
+}
+public enum TextColor: String, CaseIterable, Sendable {
+ case primary = "primary"
+ case secondary = "secondary"
+ case disabled = "disabled"
+ case placeholder = "placeholder"
+ case accent = "accent"
+ case inherit = "inherit"
+}
+public enum TextWeight: String, CaseIterable, Sendable {
+ case normal = "normal"
+ case medium = "medium"
+ case semibold = "semibold"
+ case bold = "bold"
+}
+public enum TextJustify: String, CaseIterable, Sendable {
+ case start = "start"
+ case center = "center"
+ case end = "end"
+}
+#if os(iOS)
+public struct TextProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var type: TextType?
+ public var children: String
+ public var size: TextSize?
+ public var color: TextColor?
+ public var weight: TextWeight?
+ public var maxLines: Double?
+ public var justify: TextJustify?
+ public var hasStrikethrough: Bool?
+ public var hasTabularNumbers: Bool?
+ public init(type: TextType? = nil, children: String, size: TextSize? = nil, color: TextColor? = nil, weight: TextWeight? = nil, maxLines: Double? = nil, justify: TextJustify? = nil, hasStrikethrough: Bool? = nil, hasTabularNumbers: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.type = type
+ self.children = children
+ self.size = size
+ self.color = color
+ self.weight = weight
+ self.maxLines = maxLines
+ self.justify = justify
+ self.hasStrikethrough = hasStrikethrough
+ self.hasTabularNumbers = hasTabularNumbers
+ self.base = base
+ }
+}
+#endif
+#if os(macOS)
+public struct TextProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .root
+ public var base: AstryxBaseProps
+ public var type: TextType?
+ public var children: String
+ public var size: TextSize?
+ public var color: TextColor?
+ public var weight: TextWeight?
+ public var maxLines: Double?
+ public var justify: TextJustify?
+ public var hasStrikethrough: Bool?
+ public var hasTabularNumbers: Bool?
+ public init(type: TextType? = nil, children: String, size: TextSize? = nil, color: TextColor? = nil, weight: TextWeight? = nil, maxLines: Double? = nil, justify: TextJustify? = nil, hasStrikethrough: Bool? = nil, hasTabularNumbers: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.type = type
+ self.children = children
+ self.size = size
+ self.color = color
+ self.weight = weight
+ self.maxLines = maxLines
+ self.justify = justify
+ self.hasStrikethrough = hasStrikethrough
+ self.hasTabularNumbers = hasTabularNumbers
+ self.base = base
+ }
+}
+#endif
diff --git a/packages/native/apple/Sources/AstryxNative/Generated/TextInput.swift b/packages/native/apple/Sources/AstryxNative/Generated/TextInput.swift
new file mode 100644
index 0000000000..46ea5dd044
--- /dev/null
+++ b/packages/native/apple/Sources/AstryxNative/Generated/TextInput.swift
@@ -0,0 +1,129 @@
+// Generated by @astryxdesign/native. Do not edit.
+public enum TextInputType: String, CaseIterable, Sendable {
+ case text = "text"
+ case password = "password"
+ case email = "email"
+}
+public enum TextInputSize: String, CaseIterable, Sendable {
+ case sm = "sm"
+ case md = "md"
+ case lg = "lg"
+}
+public enum TextInputStatusType: String, CaseIterable, Sendable {
+ case error = "error"
+ case warning = "warning"
+ case success = "success"
+}
+public struct TextInputStatus: Equatable, Sendable {
+ public var type: TextInputStatusType
+ public var message: String?
+ public init(type: TextInputStatusType, message: String? = nil) {
+ self.type = type
+ self.message = message
+ }
+}
+public enum TextInputStatusVariant: String, CaseIterable, Sendable {
+ case attached = "attached"
+ case detached = "detached"
+ case tooltip = "tooltip"
+}
+#if os(iOS)
+public struct TextInputProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .control
+ public var base: AstryxBaseProps
+ public var type: TextInputType?
+ public var label: String
+ public var value: String
+ public var onChange: ((String) -> Void)?
+ public var size: TextInputSize?
+ public var isLabelHidden: Bool?
+ public var description: String?
+ public var isOptional: Bool?
+ public var isRequired: Bool?
+ public var onEnter: (() -> Void)?
+ public var isDisabled: Bool?
+ public var isReadOnly: Bool?
+ public var disabledMessage: String?
+ public var isLoading: Bool?
+ public var placeholder: String?
+ public var labelTooltip: String?
+ public var status: TextInputStatus?
+ public var statusVariant: TextInputStatusVariant?
+ public var hasClear: Bool?
+ public var hasAutoFocus: Bool?
+ public init(type: TextInputType? = nil, label: String, value: String, onChange: ((String) -> Void)? = nil, size: TextInputSize? = nil, isLabelHidden: Bool? = nil, description: String? = nil, isOptional: Bool? = nil, isRequired: Bool? = nil, onEnter: (() -> Void)? = nil, isDisabled: Bool? = nil, isReadOnly: Bool? = nil, disabledMessage: String? = nil, isLoading: Bool? = nil, placeholder: String? = nil, labelTooltip: String? = nil, status: TextInputStatus? = nil, statusVariant: TextInputStatusVariant? = nil, hasClear: Bool? = nil, hasAutoFocus: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.type = type
+ self.label = label
+ self.value = value
+ self.onChange = onChange
+ self.size = size
+ self.isLabelHidden = isLabelHidden
+ self.description = description
+ self.isOptional = isOptional
+ self.isRequired = isRequired
+ self.onEnter = onEnter
+ self.isDisabled = isDisabled
+ self.isReadOnly = isReadOnly
+ self.disabledMessage = disabledMessage
+ self.isLoading = isLoading
+ self.placeholder = placeholder
+ self.labelTooltip = labelTooltip
+ self.status = status
+ self.statusVariant = statusVariant
+ self.hasClear = hasClear
+ self.hasAutoFocus = hasAutoFocus
+ self.base = base
+ }
+}
+#endif
+#if os(macOS)
+public struct TextInputProps {
+ /// Base props attach to this part on every platform.
+ public static let baseTarget: AstryxBaseTarget = .control
+ public var base: AstryxBaseProps
+ public var type: TextInputType?
+ public var label: String
+ public var value: String
+ public var onChange: ((String) -> Void)?
+ public var size: TextInputSize?
+ public var isLabelHidden: Bool?
+ public var description: String?
+ public var isOptional: Bool?
+ public var isRequired: Bool?
+ public var onEnter: (() -> Void)?
+ public var isDisabled: Bool?
+ public var isReadOnly: Bool?
+ public var disabledMessage: String?
+ public var isLoading: Bool?
+ public var placeholder: String?
+ public var labelTooltip: String?
+ public var status: TextInputStatus?
+ public var statusVariant: TextInputStatusVariant?
+ public var hasClear: Bool?
+ public var hasAutoFocus: Bool?
+ public init(type: TextInputType? = nil, label: String, value: String, onChange: ((String) -> Void)? = nil, size: TextInputSize? = nil, isLabelHidden: Bool? = nil, description: String? = nil, isOptional: Bool? = nil, isRequired: Bool? = nil, onEnter: (() -> Void)? = nil, isDisabled: Bool? = nil, isReadOnly: Bool? = nil, disabledMessage: String? = nil, isLoading: Bool? = nil, placeholder: String? = nil, labelTooltip: String? = nil, status: TextInputStatus? = nil, statusVariant: TextInputStatusVariant? = nil, hasClear: Bool? = nil, hasAutoFocus: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
+ self.type = type
+ self.label = label
+ self.value = value
+ self.onChange = onChange
+ self.size = size
+ self.isLabelHidden = isLabelHidden
+ self.description = description
+ self.isOptional = isOptional
+ self.isRequired = isRequired
+ self.onEnter = onEnter
+ self.isDisabled = isDisabled
+ self.isReadOnly = isReadOnly
+ self.disabledMessage = disabledMessage
+ self.isLoading = isLoading
+ self.placeholder = placeholder
+ self.labelTooltip = labelTooltip
+ self.status = status
+ self.statusVariant = statusVariant
+ self.hasClear = hasClear
+ self.hasAutoFocus = hasAutoFocus
+ self.base = base
+ }
+}
+#endif
diff --git a/packages/native/apple/Tests/AstryxNativeTests/ControlPropsTests.swift b/packages/native/apple/Tests/AstryxNativeTests/ControlPropsTests.swift
new file mode 100644
index 0000000000..b1e46da406
--- /dev/null
+++ b/packages/native/apple/Tests/AstryxNativeTests/ControlPropsTests.swift
@@ -0,0 +1,27 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import Testing
+@testable import AstryxNative
+
+@Test func valueCallbacksCarryTheValueOnly() {
+ var received: Bool?
+ let props = SwitchProps(label: "Wi-Fi", value: false, onChange: { received = $0 })
+ props.onChange?(true)
+ #expect(received == true)
+ #expect(SwitchProps.baseTarget == .root)
+}
+
+@Test func textSlotsAndNumberSetsAreTyped() {
+ let heading = HeadingProps(level: .v2, children: "Orders")
+ #expect(heading.level.rawValue == 2)
+ #expect(heading.children == "Orders")
+ let divider = DividerProps(label: "Or")
+ #expect(divider.label == "Or")
+}
+
+@Test func aButtonPressTakesNoArguments() {
+ var pressed = 0
+ let button = ButtonProps(label: "Pay", onClick: { pressed += 1 })
+ button.onClick?()
+ #expect(pressed == 1)
+}
diff --git a/packages/native/src/components/Button.ts b/packages/native/src/components/Button.ts
new file mode 100644
index 0000000000..4e5e1ee6f9
--- /dev/null
+++ b/packages/native/src/components/Button.ts
@@ -0,0 +1,26 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file components/Button.ts
+ * @input None
+ * @output What @astryxdesign/native adds to the core Button contract
+ * @position Native additions read by fromComponentDoc together with core's
+ * Button documentation
+ */
+
+import type {NativeAdditions} from '../contract/fromComponentDoc.js';
+
+export const button: NativeAdditions = {
+ name: 'Button',
+ baseTarget: 'root',
+ callbacks: ['onClick'],
+ sameMeaning: {onClick: 'a press, as in Compose'},
+ webOnly: {
+ type: 'HTML form submission type',
+ name: 'HTML form field name',
+ form: 'HTML form owner',
+ target: 'HTML link target',
+ rel: 'HTML link relationship',
+ isIconOnly: 'needs an icon, which has no core slot yet',
+ },
+};
diff --git a/packages/native/src/components/Divider.ts b/packages/native/src/components/Divider.ts
new file mode 100644
index 0000000000..1f818c0759
--- /dev/null
+++ b/packages/native/src/components/Divider.ts
@@ -0,0 +1,17 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file components/Divider.ts
+ * @input None
+ * @output What @astryxdesign/native adds to the core Divider contract
+ * @position Native additions read by fromComponentDoc together with core's
+ * Divider documentation
+ */
+
+import type {NativeAdditions} from '../contract/fromComponentDoc.js';
+
+export const divider: NativeAdditions = {
+ name: 'Divider',
+ baseTarget: 'root',
+ slots: {label: 'text'},
+};
diff --git a/packages/native/src/components/Heading.ts b/packages/native/src/components/Heading.ts
new file mode 100644
index 0000000000..31af60df4a
--- /dev/null
+++ b/packages/native/src/components/Heading.ts
@@ -0,0 +1,25 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file components/Heading.ts
+ * @input None
+ * @output What @astryxdesign/native adds to the core Heading contract
+ * @position Native additions read by fromComponentDoc together with core's
+ * Heading documentation
+ */
+
+import type {NativeAdditions} from '../contract/fromComponentDoc.js';
+
+export const heading: NativeAdditions = {
+ name: 'Heading',
+ baseTarget: 'root',
+ doc: {file: 'Text/Heading'},
+ slots: {children: 'text'},
+ sameMeaning: {children: "the component's content, as on the web"},
+ webOnly: {
+ display: 'CSS display; native layout places text by its container',
+ wordBreak: 'CSS line breaking; native text breaks by platform rules',
+ textWrap: 'CSS text wrapping; native text wraps by platform rules',
+ hasCapsize: 'web text-box trimming of CSS line height',
+ },
+};
diff --git a/packages/native/src/components/ProgressBar.ts b/packages/native/src/components/ProgressBar.ts
new file mode 100644
index 0000000000..c3547cff4a
--- /dev/null
+++ b/packages/native/src/components/ProgressBar.ts
@@ -0,0 +1,16 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file components/ProgressBar.ts
+ * @input None
+ * @output What @astryxdesign/native adds to the core ProgressBar contract
+ * @position Native additions read by fromComponentDoc together with core's
+ * ProgressBar documentation
+ */
+
+import type {NativeAdditions} from '../contract/fromComponentDoc.js';
+
+export const progressBar: NativeAdditions = {
+ name: 'ProgressBar',
+ baseTarget: 'root',
+};
diff --git a/packages/native/src/components/Switch.ts b/packages/native/src/components/Switch.ts
new file mode 100644
index 0000000000..dba734db03
--- /dev/null
+++ b/packages/native/src/components/Switch.ts
@@ -0,0 +1,17 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file components/Switch.ts
+ * @input None
+ * @output What @astryxdesign/native adds to the core Switch contract
+ * @position Native additions read by fromComponentDoc together with core's
+ * Switch documentation
+ */
+
+import type {NativeAdditions} from '../contract/fromComponentDoc.js';
+
+export const switchControl: NativeAdditions = {
+ name: 'Switch',
+ // The web Switch forwards base props to its root wrapper.
+ baseTarget: 'root',
+};
diff --git a/packages/native/src/components/Text.ts b/packages/native/src/components/Text.ts
new file mode 100644
index 0000000000..a731dcb1da
--- /dev/null
+++ b/packages/native/src/components/Text.ts
@@ -0,0 +1,24 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file components/Text.ts
+ * @input None
+ * @output What @astryxdesign/native adds to the core Text contract
+ * @position Native additions read by fromComponentDoc together with core's
+ * Text documentation
+ */
+
+import type {NativeAdditions} from '../contract/fromComponentDoc.js';
+
+export const text: NativeAdditions = {
+ name: 'Text',
+ baseTarget: 'root',
+ slots: {children: 'text'},
+ sameMeaning: {children: "the component's content, as on the web"},
+ webOnly: {
+ display: 'CSS display; native layout places text by its container',
+ wordBreak: 'CSS line breaking; native text breaks by platform rules',
+ textWrap: 'CSS text wrapping; native text wraps by platform rules',
+ hasCapsize: 'web text-box trimming of CSS line height',
+ },
+};
diff --git a/packages/native/src/components/TextInput.ts b/packages/native/src/components/TextInput.ts
new file mode 100644
index 0000000000..9d996be7f6
--- /dev/null
+++ b/packages/native/src/components/TextInput.ts
@@ -0,0 +1,20 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file components/TextInput.ts
+ * @input None
+ * @output What @astryxdesign/native adds to the core TextInput contract
+ * @position Native additions read by fromComponentDoc together with core's
+ * TextInput documentation
+ */
+
+import type {NativeAdditions} from '../contract/fromComponentDoc.js';
+
+export const textInput: NativeAdditions = {
+ name: 'TextInput',
+ // family:input-fields routes base props to the primary semantic control.
+ baseTarget: 'control',
+ webOnly: {
+ autoComplete: 'HTML autocomplete attribute',
+ },
+};
diff --git a/packages/native/src/components/index.ts b/packages/native/src/components/index.ts
index 6952949c09..afa8dc4e9f 100644
--- a/packages/native/src/components/index.ts
+++ b/packages/native/src/components/index.ts
@@ -9,6 +9,22 @@
*/
import type {NativeAdditions} from '../contract/fromComponentDoc.js';
+import {button} from './Button.js';
+import {divider} from './Divider.js';
+import {heading} from './Heading.js';
+import {progressBar} from './ProgressBar.js';
import {selector} from './Selector.js';
+import {switchControl} from './Switch.js';
+import {text} from './Text.js';
+import {textInput} from './TextInput.js';
-export const NATIVE_COMPONENTS: readonly NativeAdditions[] = [selector];
+export const NATIVE_COMPONENTS: readonly NativeAdditions[] = [
+ button,
+ divider,
+ heading,
+ progressBar,
+ selector,
+ switchControl,
+ text,
+ textInput,
+];
diff --git a/packages/native/src/contract/contracts.test.ts b/packages/native/src/contract/contracts.test.ts
index d601ae0153..ead3d24c2a 100644
--- a/packages/native/src/contract/contracts.test.ts
+++ b/packages/native/src/contract/contracts.test.ts
@@ -51,6 +51,33 @@ describe('native contracts', () => {
expect(selector!.core).not.toHaveProperty('controlXstyle');
});
+ it('keeps value callbacks, typed text slots, and number sets in the core', async () => {
+ const {contracts} = await buildContracts(loadCoreDoc);
+ const byName = new Map(
+ contracts.map(contract => [contract.name, contract]),
+ );
+ expect(byName.get('Switch')!.core.onChange?.type).toEqual({
+ kind: 'fn',
+ args: [{kind: 'boolean'}],
+ });
+ expect(byName.get('TextInput')!.core.onChange?.type).toEqual({
+ kind: 'fn',
+ args: [{kind: 'string'}],
+ });
+ expect(byName.get('Button')!.core.onClick?.type).toEqual({
+ kind: 'fn',
+ args: [],
+ });
+ expect(byName.get('Heading')!.core.children?.type).toEqual({
+ kind: 'string',
+ });
+ expect(byName.get('Heading')!.core.level?.type).toEqual({
+ kind: 'numberEnum',
+ values: [1, 2, 3, 4, 5, 6],
+ });
+ expect(byName.get('Text')!.core).not.toHaveProperty('id');
+ });
+
it('reports naming and portability errors', () => {
const bad: ComponentContract = {
name: 'Bad',