Skip to content

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

TypeScript
9.4 KB
Raw Blame
// Generated by @astryxdesign/native. Do not edit.
public enum TextInputType: String, CaseIterable, Codable, Sendable {
  case text = "text"
  case password = "password"
  case email = "email"
}
public enum TextInputSize: String, CaseIterable, Codable, Sendable {
  case sm = "sm"
  case md = "md"
  case lg = "lg"
}
public enum TextInputStatusType: String, CaseIterable, Codable, Sendable {
  case error = "error"
  case warning = "warning"
  case success = "success"
}
public struct TextInputStatus: Equatable, Codable, 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, Codable, 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
  }
}
public struct TextInputNode: Decodable, Equatable, Sendable {
  public struct Props: Decodable, Equatable, Sendable {
    public var type: TextInputType?
    public var label: String
    public var value: String
    public var size: TextInputSize?
    public var isLabelHidden: Bool?
    public var description: String?
    public var isOptional: Bool?
    public var isRequired: Bool?
    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 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 TextInput view takes; its callbacks send actions to the core.
  public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> TextInputProps {
    let key = self.key
    return TextInputProps(
      type: props.type,
      label: props.label,
      value: props.value,
      onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "TextInput", event: "onChange", args: [AstryxValue(arg0)])) } : nil,
      size: props.size,
      isLabelHidden: props.isLabelHidden,
      description: props.description,
      isOptional: props.isOptional,
      isRequired: props.isRequired,
      onEnter: listens("onEnter") ? { send(AstryxAction(key: key, component: "TextInput", event: "onEnter", args: [])) } : nil,
      isDisabled: props.isDisabled,
      isReadOnly: props.isReadOnly,
      disabledMessage: props.disabledMessage,
      isLoading: props.isLoading,
      placeholder: props.placeholder,
      labelTooltip: props.labelTooltip,
      status: props.status,
      statusVariant: props.statusVariant,
      hasClear: props.hasClear,
      hasAutoFocus: props.hasAutoFocus,
      base: base ?? AstryxBaseProps()
    )
  }
}
#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
  }
}
public struct TextInputNode: Decodable, Equatable, Sendable {
  public struct Props: Decodable, Equatable, Sendable {
    public var type: TextInputType?
    public var label: String
    public var value: String
    public var size: TextInputSize?
    public var isLabelHidden: Bool?
    public var description: String?
    public var isOptional: Bool?
    public var isRequired: Bool?
    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 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 TextInput view takes; its callbacks send actions to the core.
  public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> TextInputProps {
    let key = self.key
    return TextInputProps(
      type: props.type,
      label: props.label,
      value: props.value,
      onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "TextInput", event: "onChange", args: [AstryxValue(arg0)])) } : nil,
      size: props.size,
      isLabelHidden: props.isLabelHidden,
      description: props.description,
      isOptional: props.isOptional,
      isRequired: props.isRequired,
      onEnter: listens("onEnter") ? { send(AstryxAction(key: key, component: "TextInput", event: "onEnter", args: [])) } : nil,
      isDisabled: props.isDisabled,
      isReadOnly: props.isReadOnly,
      disabledMessage: props.disabledMessage,
      isLoading: props.isLoading,
      placeholder: props.placeholder,
      labelTooltip: props.labelTooltip,
      status: props.status,
      statusVariant: props.statusVariant,
      hasClear: props.hasClear,
      hasAutoFocus: props.hasAutoFocus,
      base: base ?? AstryxBaseProps()
    )
  }
}
#endif