An open source design system that's fully customizable and agent ready
TypeScript
// Generated by @astryxdesign/native. Do not edit.
public enum ListItemAlign: String, CaseIterable, Codable, Sendable {
case center = "center"
case start = "start"
case firstLine = "first-line"
}
#if os(iOS)
public struct ListItemProps {
/// 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 description: String?
public var onClick: (() -> Void)?
public var href: String?
public var align: ListItemAlign?
public var isDisabled: Bool?
public var isSelected: Bool?
public init(label: String, description: String? = nil, onClick: (() -> Void)? = nil, href: String? = nil, align: ListItemAlign? = nil, isDisabled: Bool? = nil, isSelected: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
self.label = label
self.description = description
self.onClick = onClick
self.href = href
self.align = align
self.isDisabled = isDisabled
self.isSelected = isSelected
self.base = base
}
}
public struct ListItemNode: Decodable, Equatable, Sendable {
public struct Props: Decodable, Equatable, Sendable {
public var label: String
public var description: String?
public var startContent: [AstryxNode]?
public var endContent: [AstryxNode]?
public var href: String?
public var align: ListItemAlign?
public var isDisabled: Bool?
public var isSelected: Bool?
}
public let key: String
public let base: AstryxBaseProps?
public let props: Props
/// The callbacks the core listens to, by prop name.
public let events: [String]?
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
/// The contract a ListItem view takes; its callbacks send actions to the core.
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ListItemProps {
let key = self.key
return ListItemProps(
label: props.label,
description: props.description,
onClick: listens("onClick") ? { send(AstryxAction(key: key, component: "ListItem", event: "onClick", args: [])) } : nil,
href: props.href,
align: props.align,
isDisabled: props.isDisabled,
isSelected: props.isSelected,
base: base ?? AstryxBaseProps()
)
}
}
#endif
#if os(macOS)
public struct ListItemProps {
/// 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 description: String?
public var onClick: (() -> Void)?
public var href: String?
public var align: ListItemAlign?
public var isDisabled: Bool?
public var isSelected: Bool?
public init(label: String, description: String? = nil, onClick: (() -> Void)? = nil, href: String? = nil, align: ListItemAlign? = nil, isDisabled: Bool? = nil, isSelected: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
self.label = label
self.description = description
self.onClick = onClick
self.href = href
self.align = align
self.isDisabled = isDisabled
self.isSelected = isSelected
self.base = base
}
}
public struct ListItemNode: Decodable, Equatable, Sendable {
public struct Props: Decodable, Equatable, Sendable {
public var label: String
public var description: String?
public var startContent: [AstryxNode]?
public var endContent: [AstryxNode]?
public var href: String?
public var align: ListItemAlign?
public var isDisabled: Bool?
public var isSelected: Bool?
}
public let key: String
public let base: AstryxBaseProps?
public let props: Props
/// The callbacks the core listens to, by prop name.
public let events: [String]?
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
/// The contract a ListItem view takes; its callbacks send actions to the core.
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ListItemProps {
let key = self.key
return ListItemProps(
label: props.label,
description: props.description,
onClick: listens("onClick") ? { send(AstryxAction(key: key, component: "ListItem", event: "onClick", args: [])) } : nil,
href: props.href,
align: props.align,
isDisabled: props.isDisabled,
isSelected: props.isSelected,
base: base ?? AstryxBaseProps()
)
}
}
#endif