Skip to content

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

TypeScript
6.3 KB
Raw Blame
// Generated by @astryxdesign/native. Do not edit.
public enum ItemAlign: String, CaseIterable, Codable, Sendable {
  case center = "center"
  case start = "start"
  case firstLine = "first-line"
}
public enum ItemDensity: String, CaseIterable, Codable, Sendable {
  case compact = "compact"
  case balanced = "balanced"
  case spacious = "spacious"
}
public enum ItemLayout: String, CaseIterable, Codable, Sendable {
  case stacked = "stacked"
  case inline = "inline"
}
#if os(iOS)
public struct ItemProps {
  /// 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 align: ItemAlign?
  public var density: ItemDensity?
  public var labelLines: Double?
  public var descriptionLines: Double?
  public var layout: ItemLayout?
  public var onClick: (() -> Void)?
  public var href: String?
  public var isHighlighted: Bool?
  public var isSelected: Bool?
  public var isDisabled: Bool?
  public init(label: String, description: String? = nil, align: ItemAlign? = nil, density: ItemDensity? = nil, labelLines: Double? = nil, descriptionLines: Double? = nil, layout: ItemLayout? = nil, onClick: (() -> Void)? = nil, href: String? = nil, isHighlighted: Bool? = nil, isSelected: Bool? = nil, isDisabled: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
    self.label = label
    self.description = description
    self.align = align
    self.density = density
    self.labelLines = labelLines
    self.descriptionLines = descriptionLines
    self.layout = layout
    self.onClick = onClick
    self.href = href
    self.isHighlighted = isHighlighted
    self.isSelected = isSelected
    self.isDisabled = isDisabled
    self.base = base
  }
}
public struct ItemNode: Decodable, Equatable, Sendable {
  public struct Props: Decodable, Equatable, Sendable {
    public var label: String
    public var marker: [AstryxNode]?
    public var startContent: [AstryxNode]?
    public var description: String?
    public var endContent: [AstryxNode]?
    public var align: ItemAlign?
    public var density: ItemDensity?
    public var labelLines: Double?
    public var descriptionLines: Double?
    public var layout: ItemLayout?
    public var href: String?
    public var isHighlighted: Bool?
    public var isSelected: Bool?
    public var isDisabled: 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 Item view takes; its callbacks send actions to the core.
  public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ItemProps {
    let key = self.key
    return ItemProps(
      label: props.label,
      description: props.description,
      align: props.align,
      density: props.density,
      labelLines: props.labelLines,
      descriptionLines: props.descriptionLines,
      layout: props.layout,
      onClick: listens("onClick") ? { send(AstryxAction(key: key, component: "Item", event: "onClick", args: [])) } : nil,
      href: props.href,
      isHighlighted: props.isHighlighted,
      isSelected: props.isSelected,
      isDisabled: props.isDisabled,
      base: base ?? AstryxBaseProps()
    )
  }
}
#endif
#if os(macOS)
public struct ItemProps {
  /// 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 align: ItemAlign?
  public var density: ItemDensity?
  public var labelLines: Double?
  public var descriptionLines: Double?
  public var layout: ItemLayout?
  public var onClick: (() -> Void)?
  public var href: String?
  public var isHighlighted: Bool?
  public var isSelected: Bool?
  public var isDisabled: Bool?
  public init(label: String, description: String? = nil, align: ItemAlign? = nil, density: ItemDensity? = nil, labelLines: Double? = nil, descriptionLines: Double? = nil, layout: ItemLayout? = nil, onClick: (() -> Void)? = nil, href: String? = nil, isHighlighted: Bool? = nil, isSelected: Bool? = nil, isDisabled: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
    self.label = label
    self.description = description
    self.align = align
    self.density = density
    self.labelLines = labelLines
    self.descriptionLines = descriptionLines
    self.layout = layout
    self.onClick = onClick
    self.href = href
    self.isHighlighted = isHighlighted
    self.isSelected = isSelected
    self.isDisabled = isDisabled
    self.base = base
  }
}
public struct ItemNode: Decodable, Equatable, Sendable {
  public struct Props: Decodable, Equatable, Sendable {
    public var label: String
    public var marker: [AstryxNode]?
    public var startContent: [AstryxNode]?
    public var description: String?
    public var endContent: [AstryxNode]?
    public var align: ItemAlign?
    public var density: ItemDensity?
    public var labelLines: Double?
    public var descriptionLines: Double?
    public var layout: ItemLayout?
    public var href: String?
    public var isHighlighted: Bool?
    public var isSelected: Bool?
    public var isDisabled: 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 Item view takes; its callbacks send actions to the core.
  public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ItemProps {
    let key = self.key
    return ItemProps(
      label: props.label,
      description: props.description,
      align: props.align,
      density: props.density,
      labelLines: props.labelLines,
      descriptionLines: props.descriptionLines,
      layout: props.layout,
      onClick: listens("onClick") ? { send(AstryxAction(key: key, component: "Item", event: "onClick", args: [])) } : nil,
      href: props.href,
      isHighlighted: props.isHighlighted,
      isSelected: props.isSelected,
      isDisabled: props.isDisabled,
      base: base ?? AstryxBaseProps()
    )
  }
}
#endif