@astryxdesign/native 0.7.4-canary.720bb10 → 0.7.5-canary.04434e7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -4
- package/apple/Sources/AstryxNative/Generated/AstryxBase.swift +1 -1
- package/apple/Sources/AstryxNative/Generated/AstryxNode.swift +69 -0
- package/apple/Sources/AstryxNative/Generated/AstryxWire.swift +67 -0
- package/apple/Sources/AstryxNative/Generated/Badge.swift +89 -0
- package/apple/Sources/AstryxNative/Generated/Button.swift +154 -0
- package/apple/Sources/AstryxNative/Generated/Card.swift +117 -0
- package/apple/Sources/AstryxNative/Generated/Divider.swift +97 -0
- package/apple/Sources/AstryxNative/Generated/HStack.swift +308 -0
- package/apple/Sources/AstryxNative/Generated/Heading.swift +169 -0
- package/apple/Sources/AstryxNative/Generated/ProgressBar.swift +144 -0
- package/apple/Sources/AstryxNative/Generated/Selector.swift +133 -9
- package/apple/Sources/AstryxNative/Generated/Switch.swift +202 -0
- package/apple/Sources/AstryxNative/Generated/Text.swift +172 -0
- package/apple/Sources/AstryxNative/Generated/TextInput.swift +243 -0
- package/apple/Sources/AstryxNative/Generated/VStack.swift +308 -0
- package/apple/Sources/AstryxNative/Logic/AstryxLogicHost.swift +102 -0
- package/apple/Tests/AstryxNativeTests/ControlPropsTests.swift +29 -0
- package/apple/Tests/AstryxNativeTests/LogicHostTests.swift +85 -0
- package/apple/Tests/AstryxNativeTests/WireTests.swift +53 -0
- package/dist/components/Badge.d.ts +10 -0
- package/dist/components/Badge.d.ts.map +1 -0
- package/dist/components/Badge.js +7 -0
- package/dist/components/Button.d.ts +10 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Button.js +15 -0
- package/dist/components/Card.d.ts +10 -0
- package/dist/components/Card.d.ts.map +1 -0
- package/dist/components/Card.js +7 -0
- package/dist/components/Divider.d.ts +10 -0
- package/dist/components/Divider.d.ts.map +1 -0
- package/dist/components/Divider.js +6 -0
- package/dist/components/HStack.d.ts +10 -0
- package/dist/components/HStack.d.ts.map +1 -0
- package/dist/components/HStack.js +9 -0
- package/dist/components/Heading.d.ts +10 -0
- package/dist/components/Heading.d.ts.map +1 -0
- package/dist/components/Heading.js +14 -0
- package/dist/components/ProgressBar.d.ts +10 -0
- package/dist/components/ProgressBar.d.ts.map +1 -0
- package/dist/components/ProgressBar.js +5 -0
- package/dist/components/Switch.d.ts +10 -0
- package/dist/components/Switch.d.ts.map +1 -0
- package/dist/components/Switch.js +6 -0
- package/dist/components/Text.d.ts +10 -0
- package/dist/components/Text.d.ts.map +1 -0
- package/dist/components/Text.js +13 -0
- package/dist/components/TextInput.d.ts +10 -0
- package/dist/components/TextInput.d.ts.map +1 -0
- package/dist/components/TextInput.js +9 -0
- package/dist/components/VStack.d.ts +10 -0
- package/dist/components/VStack.d.ts.map +1 -0
- package/dist/components/VStack.js +9 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +25 -1
- package/dist/components/stackShared.d.ts +9 -0
- package/dist/components/stackShared.d.ts.map +1 -0
- package/dist/components/stackShared.js +4 -0
- package/dist/contract/fromComponentDoc.d.ts +44 -5
- package/dist/contract/fromComponentDoc.d.ts.map +1 -1
- package/dist/contract/fromComponentDoc.js +47 -4
- package/dist/contract/generateSwift.d.ts.map +1 -1
- package/dist/contract/generateSwift.js +193 -10
- package/dist/contract/generateTypeScript.d.ts.map +1 -1
- package/dist/contract/generateTypeScript.js +69 -9
- package/dist/contract/index.d.ts +7 -3
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +2 -1
- package/dist/contract/parseDocType.d.ts +5 -2
- package/dist/contract/parseDocType.d.ts.map +1 -1
- package/dist/contract/parseDocType.js +34 -5
- package/dist/contract/rules.d.ts +5 -2
- package/dist/contract/rules.d.ts.map +1 -1
- package/dist/contract/rules.js +8 -4
- package/dist/contract/types.d.ts +11 -0
- package/dist/contract/types.d.ts.map +1 -1
- package/dist/logic/connectBridge.d.ts +29 -0
- package/dist/logic/connectBridge.d.ts.map +1 -0
- package/dist/logic/connectBridge.js +32 -0
- package/dist/logic/createLogicCore.d.ts +44 -0
- package/dist/logic/createLogicCore.d.ts.map +1 -0
- package/dist/logic/createLogicCore.js +40 -0
- package/dist/logic/index.d.ts +12 -0
- package/dist/logic/index.d.ts.map +1 -0
- package/dist/logic/index.js +10 -0
- package/dist/types/android.d.ts +136 -2
- package/dist/types/core.d.ts +150 -0
- package/dist/types/ios.d.ts +136 -2
- package/dist/types/macos.d.ts +136 -2
- package/dist/types/shared.d.ts +136 -2
- package/dist/types/windows.d.ts +136 -2
- package/package.json +10 -4
- package/src/components/Badge.ts +18 -0
- package/src/components/Button.ts +26 -0
- package/src/components/Card.ts +18 -0
- package/src/components/Divider.ts +17 -0
- package/src/components/HStack.ts +20 -0
- package/src/components/Heading.ts +25 -0
- package/src/components/ProgressBar.ts +16 -0
- package/src/components/Switch.ts +17 -0
- package/src/components/Text.ts +24 -0
- package/src/components/TextInput.ts +20 -0
- package/src/components/VStack.ts +20 -0
- package/src/components/index.ts +25 -1
- package/src/components/stackShared.ts +14 -0
- package/src/contract/contracts.test.ts +58 -0
- package/src/contract/fromComponentDoc.test.ts +97 -0
- package/src/contract/fromComponentDoc.ts +106 -9
- package/src/contract/generateSwift.ts +223 -10
- package/src/contract/generateTypeScript.ts +83 -10
- package/src/contract/index.ts +13 -4
- package/src/contract/parseDocType.test.ts +45 -0
- package/src/contract/parseDocType.ts +41 -6
- package/src/contract/rules.ts +11 -4
- package/src/contract/types.ts +6 -0
- package/src/logic/connectBridge.ts +72 -0
- package/src/logic/createLogicCore.ts +97 -0
- package/src/logic/index.ts +19 -0
- package/src/logic/logic.test.ts +160 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// Generated by @astryxdesign/native. Do not edit.
|
|
2
|
+
public enum TextType: String, CaseIterable, Codable, Sendable {
|
|
3
|
+
case body = "body"
|
|
4
|
+
case large = "large"
|
|
5
|
+
case label = "label"
|
|
6
|
+
case supporting = "supporting"
|
|
7
|
+
case code = "code"
|
|
8
|
+
case display1 = "display-1"
|
|
9
|
+
case display2 = "display-2"
|
|
10
|
+
case display3 = "display-3"
|
|
11
|
+
case inherit = "inherit"
|
|
12
|
+
}
|
|
13
|
+
public enum TextSize: String, CaseIterable, Codable, Sendable {
|
|
14
|
+
case v4xs = "4xs"
|
|
15
|
+
case v3xs = "3xs"
|
|
16
|
+
case v2xs = "2xs"
|
|
17
|
+
case xsm = "xsm"
|
|
18
|
+
case sm = "sm"
|
|
19
|
+
case base = "base"
|
|
20
|
+
case lg = "lg"
|
|
21
|
+
case xl = "xl"
|
|
22
|
+
case v2xl = "2xl"
|
|
23
|
+
case v3xl = "3xl"
|
|
24
|
+
case v4xl = "4xl"
|
|
25
|
+
}
|
|
26
|
+
public enum TextColor: String, CaseIterable, Codable, Sendable {
|
|
27
|
+
case primary = "primary"
|
|
28
|
+
case secondary = "secondary"
|
|
29
|
+
case disabled = "disabled"
|
|
30
|
+
case placeholder = "placeholder"
|
|
31
|
+
case accent = "accent"
|
|
32
|
+
case inherit = "inherit"
|
|
33
|
+
}
|
|
34
|
+
public enum TextWeight: String, CaseIterable, Codable, Sendable {
|
|
35
|
+
case normal = "normal"
|
|
36
|
+
case medium = "medium"
|
|
37
|
+
case semibold = "semibold"
|
|
38
|
+
case bold = "bold"
|
|
39
|
+
}
|
|
40
|
+
public enum TextJustify: String, CaseIterable, Codable, Sendable {
|
|
41
|
+
case start = "start"
|
|
42
|
+
case center = "center"
|
|
43
|
+
case end = "end"
|
|
44
|
+
}
|
|
45
|
+
#if os(iOS)
|
|
46
|
+
public struct TextProps {
|
|
47
|
+
/// Base props attach to this part on every platform.
|
|
48
|
+
public static let baseTarget: AstryxBaseTarget = .root
|
|
49
|
+
public var base: AstryxBaseProps
|
|
50
|
+
public var type: TextType?
|
|
51
|
+
public var children: String
|
|
52
|
+
public var size: TextSize?
|
|
53
|
+
public var color: TextColor?
|
|
54
|
+
public var weight: TextWeight?
|
|
55
|
+
public var maxLines: Double?
|
|
56
|
+
public var justify: TextJustify?
|
|
57
|
+
public var hasStrikethrough: Bool?
|
|
58
|
+
public var hasTabularNumbers: Bool?
|
|
59
|
+
public init(type: TextType? = nil, children: String, size: TextSize? = nil, color: TextColor? = nil, weight: TextWeight? = nil, maxLines: Double? = nil, justify: TextJustify? = nil, hasStrikethrough: Bool? = nil, hasTabularNumbers: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
|
|
60
|
+
self.type = type
|
|
61
|
+
self.children = children
|
|
62
|
+
self.size = size
|
|
63
|
+
self.color = color
|
|
64
|
+
self.weight = weight
|
|
65
|
+
self.maxLines = maxLines
|
|
66
|
+
self.justify = justify
|
|
67
|
+
self.hasStrikethrough = hasStrikethrough
|
|
68
|
+
self.hasTabularNumbers = hasTabularNumbers
|
|
69
|
+
self.base = base
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
public struct TextNode: Decodable, Equatable, Sendable {
|
|
73
|
+
public struct Props: Decodable, Equatable, Sendable {
|
|
74
|
+
public var type: TextType?
|
|
75
|
+
public var children: String
|
|
76
|
+
public var size: TextSize?
|
|
77
|
+
public var color: TextColor?
|
|
78
|
+
public var weight: TextWeight?
|
|
79
|
+
public var maxLines: Double?
|
|
80
|
+
public var justify: TextJustify?
|
|
81
|
+
public var hasStrikethrough: Bool?
|
|
82
|
+
public var hasTabularNumbers: Bool?
|
|
83
|
+
}
|
|
84
|
+
public let key: String
|
|
85
|
+
public let base: AstryxBaseProps?
|
|
86
|
+
public let props: Props
|
|
87
|
+
/// The callbacks the core listens to, by prop name.
|
|
88
|
+
public let events: [String]?
|
|
89
|
+
|
|
90
|
+
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
|
|
91
|
+
|
|
92
|
+
/// The contract a Text view takes; its callbacks send actions to the core.
|
|
93
|
+
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> TextProps {
|
|
94
|
+
return TextProps(
|
|
95
|
+
type: props.type,
|
|
96
|
+
children: props.children,
|
|
97
|
+
size: props.size,
|
|
98
|
+
color: props.color,
|
|
99
|
+
weight: props.weight,
|
|
100
|
+
maxLines: props.maxLines,
|
|
101
|
+
justify: props.justify,
|
|
102
|
+
hasStrikethrough: props.hasStrikethrough,
|
|
103
|
+
hasTabularNumbers: props.hasTabularNumbers,
|
|
104
|
+
base: base ?? AstryxBaseProps()
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
#endif
|
|
109
|
+
#if os(macOS)
|
|
110
|
+
public struct TextProps {
|
|
111
|
+
/// Base props attach to this part on every platform.
|
|
112
|
+
public static let baseTarget: AstryxBaseTarget = .root
|
|
113
|
+
public var base: AstryxBaseProps
|
|
114
|
+
public var type: TextType?
|
|
115
|
+
public var children: String
|
|
116
|
+
public var size: TextSize?
|
|
117
|
+
public var color: TextColor?
|
|
118
|
+
public var weight: TextWeight?
|
|
119
|
+
public var maxLines: Double?
|
|
120
|
+
public var justify: TextJustify?
|
|
121
|
+
public var hasStrikethrough: Bool?
|
|
122
|
+
public var hasTabularNumbers: Bool?
|
|
123
|
+
public init(type: TextType? = nil, children: String, size: TextSize? = nil, color: TextColor? = nil, weight: TextWeight? = nil, maxLines: Double? = nil, justify: TextJustify? = nil, hasStrikethrough: Bool? = nil, hasTabularNumbers: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
|
|
124
|
+
self.type = type
|
|
125
|
+
self.children = children
|
|
126
|
+
self.size = size
|
|
127
|
+
self.color = color
|
|
128
|
+
self.weight = weight
|
|
129
|
+
self.maxLines = maxLines
|
|
130
|
+
self.justify = justify
|
|
131
|
+
self.hasStrikethrough = hasStrikethrough
|
|
132
|
+
self.hasTabularNumbers = hasTabularNumbers
|
|
133
|
+
self.base = base
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
public struct TextNode: Decodable, Equatable, Sendable {
|
|
137
|
+
public struct Props: Decodable, Equatable, Sendable {
|
|
138
|
+
public var type: TextType?
|
|
139
|
+
public var children: String
|
|
140
|
+
public var size: TextSize?
|
|
141
|
+
public var color: TextColor?
|
|
142
|
+
public var weight: TextWeight?
|
|
143
|
+
public var maxLines: Double?
|
|
144
|
+
public var justify: TextJustify?
|
|
145
|
+
public var hasStrikethrough: Bool?
|
|
146
|
+
public var hasTabularNumbers: Bool?
|
|
147
|
+
}
|
|
148
|
+
public let key: String
|
|
149
|
+
public let base: AstryxBaseProps?
|
|
150
|
+
public let props: Props
|
|
151
|
+
/// The callbacks the core listens to, by prop name.
|
|
152
|
+
public let events: [String]?
|
|
153
|
+
|
|
154
|
+
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
|
|
155
|
+
|
|
156
|
+
/// The contract a Text view takes; its callbacks send actions to the core.
|
|
157
|
+
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> TextProps {
|
|
158
|
+
return TextProps(
|
|
159
|
+
type: props.type,
|
|
160
|
+
children: props.children,
|
|
161
|
+
size: props.size,
|
|
162
|
+
color: props.color,
|
|
163
|
+
weight: props.weight,
|
|
164
|
+
maxLines: props.maxLines,
|
|
165
|
+
justify: props.justify,
|
|
166
|
+
hasStrikethrough: props.hasStrikethrough,
|
|
167
|
+
hasTabularNumbers: props.hasTabularNumbers,
|
|
168
|
+
base: base ?? AstryxBaseProps()
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
#endif
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// Generated by @astryxdesign/native. Do not edit.
|
|
2
|
+
public enum TextInputType: String, CaseIterable, Codable, Sendable {
|
|
3
|
+
case text = "text"
|
|
4
|
+
case password = "password"
|
|
5
|
+
case email = "email"
|
|
6
|
+
}
|
|
7
|
+
public enum TextInputSize: String, CaseIterable, Codable, Sendable {
|
|
8
|
+
case sm = "sm"
|
|
9
|
+
case md = "md"
|
|
10
|
+
case lg = "lg"
|
|
11
|
+
}
|
|
12
|
+
public enum TextInputStatusType: String, CaseIterable, Codable, Sendable {
|
|
13
|
+
case error = "error"
|
|
14
|
+
case warning = "warning"
|
|
15
|
+
case success = "success"
|
|
16
|
+
}
|
|
17
|
+
public struct TextInputStatus: Equatable, Codable, Sendable {
|
|
18
|
+
public var type: TextInputStatusType
|
|
19
|
+
public var message: String?
|
|
20
|
+
public init(type: TextInputStatusType, message: String? = nil) {
|
|
21
|
+
self.type = type
|
|
22
|
+
self.message = message
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
public enum TextInputStatusVariant: String, CaseIterable, Codable, Sendable {
|
|
26
|
+
case attached = "attached"
|
|
27
|
+
case detached = "detached"
|
|
28
|
+
case tooltip = "tooltip"
|
|
29
|
+
}
|
|
30
|
+
#if os(iOS)
|
|
31
|
+
public struct TextInputProps {
|
|
32
|
+
/// Base props attach to this part on every platform.
|
|
33
|
+
public static let baseTarget: AstryxBaseTarget = .control
|
|
34
|
+
public var base: AstryxBaseProps
|
|
35
|
+
public var type: TextInputType?
|
|
36
|
+
public var label: String
|
|
37
|
+
public var value: String
|
|
38
|
+
public var onChange: ((String) -> Void)?
|
|
39
|
+
public var size: TextInputSize?
|
|
40
|
+
public var isLabelHidden: Bool?
|
|
41
|
+
public var description: String?
|
|
42
|
+
public var isOptional: Bool?
|
|
43
|
+
public var isRequired: Bool?
|
|
44
|
+
public var onEnter: (() -> Void)?
|
|
45
|
+
public var isDisabled: Bool?
|
|
46
|
+
public var isReadOnly: Bool?
|
|
47
|
+
public var disabledMessage: String?
|
|
48
|
+
public var isLoading: Bool?
|
|
49
|
+
public var placeholder: String?
|
|
50
|
+
public var labelTooltip: String?
|
|
51
|
+
public var status: TextInputStatus?
|
|
52
|
+
public var statusVariant: TextInputStatusVariant?
|
|
53
|
+
public var hasClear: Bool?
|
|
54
|
+
public var hasAutoFocus: Bool?
|
|
55
|
+
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()) {
|
|
56
|
+
self.type = type
|
|
57
|
+
self.label = label
|
|
58
|
+
self.value = value
|
|
59
|
+
self.onChange = onChange
|
|
60
|
+
self.size = size
|
|
61
|
+
self.isLabelHidden = isLabelHidden
|
|
62
|
+
self.description = description
|
|
63
|
+
self.isOptional = isOptional
|
|
64
|
+
self.isRequired = isRequired
|
|
65
|
+
self.onEnter = onEnter
|
|
66
|
+
self.isDisabled = isDisabled
|
|
67
|
+
self.isReadOnly = isReadOnly
|
|
68
|
+
self.disabledMessage = disabledMessage
|
|
69
|
+
self.isLoading = isLoading
|
|
70
|
+
self.placeholder = placeholder
|
|
71
|
+
self.labelTooltip = labelTooltip
|
|
72
|
+
self.status = status
|
|
73
|
+
self.statusVariant = statusVariant
|
|
74
|
+
self.hasClear = hasClear
|
|
75
|
+
self.hasAutoFocus = hasAutoFocus
|
|
76
|
+
self.base = base
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
public struct TextInputNode: Decodable, Equatable, Sendable {
|
|
80
|
+
public struct Props: Decodable, Equatable, Sendable {
|
|
81
|
+
public var type: TextInputType?
|
|
82
|
+
public var label: String
|
|
83
|
+
public var value: String
|
|
84
|
+
public var size: TextInputSize?
|
|
85
|
+
public var isLabelHidden: Bool?
|
|
86
|
+
public var description: String?
|
|
87
|
+
public var isOptional: Bool?
|
|
88
|
+
public var isRequired: Bool?
|
|
89
|
+
public var isDisabled: Bool?
|
|
90
|
+
public var isReadOnly: Bool?
|
|
91
|
+
public var disabledMessage: String?
|
|
92
|
+
public var isLoading: Bool?
|
|
93
|
+
public var placeholder: String?
|
|
94
|
+
public var labelTooltip: String?
|
|
95
|
+
public var status: TextInputStatus?
|
|
96
|
+
public var statusVariant: TextInputStatusVariant?
|
|
97
|
+
public var hasClear: Bool?
|
|
98
|
+
public var hasAutoFocus: Bool?
|
|
99
|
+
}
|
|
100
|
+
public let key: String
|
|
101
|
+
public let base: AstryxBaseProps?
|
|
102
|
+
public let props: Props
|
|
103
|
+
/// The callbacks the core listens to, by prop name.
|
|
104
|
+
public let events: [String]?
|
|
105
|
+
|
|
106
|
+
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
|
|
107
|
+
|
|
108
|
+
/// The contract a TextInput view takes; its callbacks send actions to the core.
|
|
109
|
+
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> TextInputProps {
|
|
110
|
+
let key = self.key
|
|
111
|
+
return TextInputProps(
|
|
112
|
+
type: props.type,
|
|
113
|
+
label: props.label,
|
|
114
|
+
value: props.value,
|
|
115
|
+
onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "TextInput", event: "onChange", args: [AstryxValue(arg0)])) } : nil,
|
|
116
|
+
size: props.size,
|
|
117
|
+
isLabelHidden: props.isLabelHidden,
|
|
118
|
+
description: props.description,
|
|
119
|
+
isOptional: props.isOptional,
|
|
120
|
+
isRequired: props.isRequired,
|
|
121
|
+
onEnter: listens("onEnter") ? { send(AstryxAction(key: key, component: "TextInput", event: "onEnter", args: [])) } : nil,
|
|
122
|
+
isDisabled: props.isDisabled,
|
|
123
|
+
isReadOnly: props.isReadOnly,
|
|
124
|
+
disabledMessage: props.disabledMessage,
|
|
125
|
+
isLoading: props.isLoading,
|
|
126
|
+
placeholder: props.placeholder,
|
|
127
|
+
labelTooltip: props.labelTooltip,
|
|
128
|
+
status: props.status,
|
|
129
|
+
statusVariant: props.statusVariant,
|
|
130
|
+
hasClear: props.hasClear,
|
|
131
|
+
hasAutoFocus: props.hasAutoFocus,
|
|
132
|
+
base: base ?? AstryxBaseProps()
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
#endif
|
|
137
|
+
#if os(macOS)
|
|
138
|
+
public struct TextInputProps {
|
|
139
|
+
/// Base props attach to this part on every platform.
|
|
140
|
+
public static let baseTarget: AstryxBaseTarget = .control
|
|
141
|
+
public var base: AstryxBaseProps
|
|
142
|
+
public var type: TextInputType?
|
|
143
|
+
public var label: String
|
|
144
|
+
public var value: String
|
|
145
|
+
public var onChange: ((String) -> Void)?
|
|
146
|
+
public var size: TextInputSize?
|
|
147
|
+
public var isLabelHidden: Bool?
|
|
148
|
+
public var description: String?
|
|
149
|
+
public var isOptional: Bool?
|
|
150
|
+
public var isRequired: Bool?
|
|
151
|
+
public var onEnter: (() -> Void)?
|
|
152
|
+
public var isDisabled: Bool?
|
|
153
|
+
public var isReadOnly: Bool?
|
|
154
|
+
public var disabledMessage: String?
|
|
155
|
+
public var isLoading: Bool?
|
|
156
|
+
public var placeholder: String?
|
|
157
|
+
public var labelTooltip: String?
|
|
158
|
+
public var status: TextInputStatus?
|
|
159
|
+
public var statusVariant: TextInputStatusVariant?
|
|
160
|
+
public var hasClear: Bool?
|
|
161
|
+
public var hasAutoFocus: Bool?
|
|
162
|
+
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()) {
|
|
163
|
+
self.type = type
|
|
164
|
+
self.label = label
|
|
165
|
+
self.value = value
|
|
166
|
+
self.onChange = onChange
|
|
167
|
+
self.size = size
|
|
168
|
+
self.isLabelHidden = isLabelHidden
|
|
169
|
+
self.description = description
|
|
170
|
+
self.isOptional = isOptional
|
|
171
|
+
self.isRequired = isRequired
|
|
172
|
+
self.onEnter = onEnter
|
|
173
|
+
self.isDisabled = isDisabled
|
|
174
|
+
self.isReadOnly = isReadOnly
|
|
175
|
+
self.disabledMessage = disabledMessage
|
|
176
|
+
self.isLoading = isLoading
|
|
177
|
+
self.placeholder = placeholder
|
|
178
|
+
self.labelTooltip = labelTooltip
|
|
179
|
+
self.status = status
|
|
180
|
+
self.statusVariant = statusVariant
|
|
181
|
+
self.hasClear = hasClear
|
|
182
|
+
self.hasAutoFocus = hasAutoFocus
|
|
183
|
+
self.base = base
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
public struct TextInputNode: Decodable, Equatable, Sendable {
|
|
187
|
+
public struct Props: Decodable, Equatable, Sendable {
|
|
188
|
+
public var type: TextInputType?
|
|
189
|
+
public var label: String
|
|
190
|
+
public var value: String
|
|
191
|
+
public var size: TextInputSize?
|
|
192
|
+
public var isLabelHidden: Bool?
|
|
193
|
+
public var description: String?
|
|
194
|
+
public var isOptional: Bool?
|
|
195
|
+
public var isRequired: Bool?
|
|
196
|
+
public var isDisabled: Bool?
|
|
197
|
+
public var isReadOnly: Bool?
|
|
198
|
+
public var disabledMessage: String?
|
|
199
|
+
public var isLoading: Bool?
|
|
200
|
+
public var placeholder: String?
|
|
201
|
+
public var labelTooltip: String?
|
|
202
|
+
public var status: TextInputStatus?
|
|
203
|
+
public var statusVariant: TextInputStatusVariant?
|
|
204
|
+
public var hasClear: Bool?
|
|
205
|
+
public var hasAutoFocus: Bool?
|
|
206
|
+
}
|
|
207
|
+
public let key: String
|
|
208
|
+
public let base: AstryxBaseProps?
|
|
209
|
+
public let props: Props
|
|
210
|
+
/// The callbacks the core listens to, by prop name.
|
|
211
|
+
public let events: [String]?
|
|
212
|
+
|
|
213
|
+
public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
|
|
214
|
+
|
|
215
|
+
/// The contract a TextInput view takes; its callbacks send actions to the core.
|
|
216
|
+
public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> TextInputProps {
|
|
217
|
+
let key = self.key
|
|
218
|
+
return TextInputProps(
|
|
219
|
+
type: props.type,
|
|
220
|
+
label: props.label,
|
|
221
|
+
value: props.value,
|
|
222
|
+
onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "TextInput", event: "onChange", args: [AstryxValue(arg0)])) } : nil,
|
|
223
|
+
size: props.size,
|
|
224
|
+
isLabelHidden: props.isLabelHidden,
|
|
225
|
+
description: props.description,
|
|
226
|
+
isOptional: props.isOptional,
|
|
227
|
+
isRequired: props.isRequired,
|
|
228
|
+
onEnter: listens("onEnter") ? { send(AstryxAction(key: key, component: "TextInput", event: "onEnter", args: [])) } : nil,
|
|
229
|
+
isDisabled: props.isDisabled,
|
|
230
|
+
isReadOnly: props.isReadOnly,
|
|
231
|
+
disabledMessage: props.disabledMessage,
|
|
232
|
+
isLoading: props.isLoading,
|
|
233
|
+
placeholder: props.placeholder,
|
|
234
|
+
labelTooltip: props.labelTooltip,
|
|
235
|
+
status: props.status,
|
|
236
|
+
statusVariant: props.statusVariant,
|
|
237
|
+
hasClear: props.hasClear,
|
|
238
|
+
hasAutoFocus: props.hasAutoFocus,
|
|
239
|
+
base: base ?? AstryxBaseProps()
|
|
240
|
+
)
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
#endif
|