An open source design system that's fully customizable and agent ready
TypeScript
// Generated by @astryxdesign/native. Do not edit.
public enum ThumbnailShowRemoveOn: String, CaseIterable, Codable, Sendable {
case always = "always"
case hover = "hover"
}
#if os(iOS)
public struct ThumbnailProps {
/// Base props attach to this part on every platform.
public static let baseTarget: AstryxBaseTarget = .root
public var base: AstryxBaseProps
public var src: String?
public var alt: String?
public var label: String?
public var onRemove: (() -> Void)?
public var onClick: (() -> Void)?
public var isLoading: Bool?
public var isDisabled: Bool?
public var showRemoveOn: ThumbnailShowRemoveOn?
public init(src: String? = nil, alt: String? = nil, label: String? = nil, onRemove: (() -> Void)? = nil, onClick: (() -> Void)? = nil, isLoading: Bool? = nil, isDisabled: Bool? = nil, showRemoveOn: ThumbnailShowRemoveOn? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
self.src = src
self.alt = alt
self.label = label
self.onRemove = onRemove
self.onClick = onClick
self.isLoading = isLoading
self.isDisabled = isDisabled
self.showRemoveOn = showRemoveOn
self.base = base
}
}
public struct ThumbnailNode: Decodable, Equatable, Sendable {
public struct Props: Decodable, Equatable, Sendable {
public var src: String?
public var alt: String?
public var label: String?
public var isLoading: Bool?
public var isDisabled: Bool?
public var showRemoveOn: ThumbnailShowRemoveOn?
}
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 Thumbnail view takes; its callbacks send actions to the core.
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ThumbnailProps {
let key = self.key
return ThumbnailProps(
src: props.src,
alt: props.alt,
label: props.label,
onRemove: listens("onRemove") ? { send(AstryxAction(key: key, component: "Thumbnail", event: "onRemove", args: [])) } : nil,
onClick: listens("onClick") ? { send(AstryxAction(key: key, component: "Thumbnail", event: "onClick", args: [])) } : nil,
isLoading: props.isLoading,
isDisabled: props.isDisabled,
showRemoveOn: props.showRemoveOn,
base: base ?? AstryxBaseProps()
)
}
}
#endif
#if os(macOS)
public struct ThumbnailProps {
/// Base props attach to this part on every platform.
public static let baseTarget: AstryxBaseTarget = .root
public var base: AstryxBaseProps
public var src: String?
public var alt: String?
public var label: String?
public var onRemove: (() -> Void)?
public var onClick: (() -> Void)?
public var isLoading: Bool?
public var isDisabled: Bool?
public var showRemoveOn: ThumbnailShowRemoveOn?
public init(src: String? = nil, alt: String? = nil, label: String? = nil, onRemove: (() -> Void)? = nil, onClick: (() -> Void)? = nil, isLoading: Bool? = nil, isDisabled: Bool? = nil, showRemoveOn: ThumbnailShowRemoveOn? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
self.src = src
self.alt = alt
self.label = label
self.onRemove = onRemove
self.onClick = onClick
self.isLoading = isLoading
self.isDisabled = isDisabled
self.showRemoveOn = showRemoveOn
self.base = base
}
}
public struct ThumbnailNode: Decodable, Equatable, Sendable {
public struct Props: Decodable, Equatable, Sendable {
public var src: String?
public var alt: String?
public var label: String?
public var isLoading: Bool?
public var isDisabled: Bool?
public var showRemoveOn: ThumbnailShowRemoveOn?
}
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 Thumbnail view takes; its callbacks send actions to the core.
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ThumbnailProps {
let key = self.key
return ThumbnailProps(
src: props.src,
alt: props.alt,
label: props.label,
onRemove: listens("onRemove") ? { send(AstryxAction(key: key, component: "Thumbnail", event: "onRemove", args: [])) } : nil,
onClick: listens("onClick") ? { send(AstryxAction(key: key, component: "Thumbnail", event: "onClick", args: [])) } : nil,
isLoading: props.isLoading,
isDisabled: props.isDisabled,
showRemoveOn: props.showRemoveOn,
base: base ?? AstryxBaseProps()
)
}
}
#endif