Skip to content

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

TypeScript
6.5 KB
Raw Blame
// Generated by @astryxdesign/native. Do not edit.
public enum SwitchSize: String, CaseIterable, Codable, Sendable {
  case sm = "sm"
  case md = "md"
}
public enum SwitchStatusType: String, CaseIterable, Codable, Sendable {
  case warning = "warning"
  case error = "error"
  case success = "success"
}
public struct SwitchStatus: Equatable, Codable, Sendable {
  public var type: SwitchStatusType
  public var message: String?
  public init(type: SwitchStatusType, message: String? = nil) {
    self.type = type
    self.message = message
  }
}
#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 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, 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.base = base
  }
}
public struct SwitchNode: Decodable, Equatable, Sendable {
  public struct Props: Decodable, Equatable, Sendable {
    public var label: String
    public var value: Bool
    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 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 Switch view takes; its callbacks send actions to the core.
  public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> SwitchProps {
    let key = self.key
    return SwitchProps(
      label: props.label,
      value: props.value,
      onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "Switch", event: "onChange", args: [AstryxValue(arg0)])) } : nil,
      isLoading: props.isLoading,
      isLabelHidden: props.isLabelHidden,
      description: props.description,
      isDisabled: props.isDisabled,
      size: props.size,
      disabledMessage: props.disabledMessage,
      isOptional: props.isOptional,
      isRequired: props.isRequired,
      status: props.status,
      labelTooltip: props.labelTooltip,
      base: base ?? AstryxBaseProps()
    )
  }
}
#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 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, 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.base = base
  }
}
public struct SwitchNode: Decodable, Equatable, Sendable {
  public struct Props: Decodable, Equatable, Sendable {
    public var label: String
    public var value: Bool
    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 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 Switch view takes; its callbacks send actions to the core.
  public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> SwitchProps {
    let key = self.key
    return SwitchProps(
      label: props.label,
      value: props.value,
      onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "Switch", event: "onChange", args: [AstryxValue(arg0)])) } : nil,
      isLoading: props.isLoading,
      isLabelHidden: props.isLabelHidden,
      description: props.description,
      isDisabled: props.isDisabled,
      size: props.size,
      disabledMessage: props.disabledMessage,
      isOptional: props.isOptional,
      isRequired: props.isRequired,
      status: props.status,
      labelTooltip: props.labelTooltip,
      base: base ?? AstryxBaseProps()
    )
  }
}
#endif