@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.
Files changed (119) hide show
  1. package/README.md +116 -4
  2. package/apple/Sources/AstryxNative/Generated/AstryxBase.swift +1 -1
  3. package/apple/Sources/AstryxNative/Generated/AstryxNode.swift +69 -0
  4. package/apple/Sources/AstryxNative/Generated/AstryxWire.swift +67 -0
  5. package/apple/Sources/AstryxNative/Generated/Badge.swift +89 -0
  6. package/apple/Sources/AstryxNative/Generated/Button.swift +154 -0
  7. package/apple/Sources/AstryxNative/Generated/Card.swift +117 -0
  8. package/apple/Sources/AstryxNative/Generated/Divider.swift +97 -0
  9. package/apple/Sources/AstryxNative/Generated/HStack.swift +308 -0
  10. package/apple/Sources/AstryxNative/Generated/Heading.swift +169 -0
  11. package/apple/Sources/AstryxNative/Generated/ProgressBar.swift +144 -0
  12. package/apple/Sources/AstryxNative/Generated/Selector.swift +133 -9
  13. package/apple/Sources/AstryxNative/Generated/Switch.swift +202 -0
  14. package/apple/Sources/AstryxNative/Generated/Text.swift +172 -0
  15. package/apple/Sources/AstryxNative/Generated/TextInput.swift +243 -0
  16. package/apple/Sources/AstryxNative/Generated/VStack.swift +308 -0
  17. package/apple/Sources/AstryxNative/Logic/AstryxLogicHost.swift +102 -0
  18. package/apple/Tests/AstryxNativeTests/ControlPropsTests.swift +29 -0
  19. package/apple/Tests/AstryxNativeTests/LogicHostTests.swift +85 -0
  20. package/apple/Tests/AstryxNativeTests/WireTests.swift +53 -0
  21. package/dist/components/Badge.d.ts +10 -0
  22. package/dist/components/Badge.d.ts.map +1 -0
  23. package/dist/components/Badge.js +7 -0
  24. package/dist/components/Button.d.ts +10 -0
  25. package/dist/components/Button.d.ts.map +1 -0
  26. package/dist/components/Button.js +15 -0
  27. package/dist/components/Card.d.ts +10 -0
  28. package/dist/components/Card.d.ts.map +1 -0
  29. package/dist/components/Card.js +7 -0
  30. package/dist/components/Divider.d.ts +10 -0
  31. package/dist/components/Divider.d.ts.map +1 -0
  32. package/dist/components/Divider.js +6 -0
  33. package/dist/components/HStack.d.ts +10 -0
  34. package/dist/components/HStack.d.ts.map +1 -0
  35. package/dist/components/HStack.js +9 -0
  36. package/dist/components/Heading.d.ts +10 -0
  37. package/dist/components/Heading.d.ts.map +1 -0
  38. package/dist/components/Heading.js +14 -0
  39. package/dist/components/ProgressBar.d.ts +10 -0
  40. package/dist/components/ProgressBar.d.ts.map +1 -0
  41. package/dist/components/ProgressBar.js +5 -0
  42. package/dist/components/Switch.d.ts +10 -0
  43. package/dist/components/Switch.d.ts.map +1 -0
  44. package/dist/components/Switch.js +6 -0
  45. package/dist/components/Text.d.ts +10 -0
  46. package/dist/components/Text.d.ts.map +1 -0
  47. package/dist/components/Text.js +13 -0
  48. package/dist/components/TextInput.d.ts +10 -0
  49. package/dist/components/TextInput.d.ts.map +1 -0
  50. package/dist/components/TextInput.js +9 -0
  51. package/dist/components/VStack.d.ts +10 -0
  52. package/dist/components/VStack.d.ts.map +1 -0
  53. package/dist/components/VStack.js +9 -0
  54. package/dist/components/index.d.ts.map +1 -1
  55. package/dist/components/index.js +25 -1
  56. package/dist/components/stackShared.d.ts +9 -0
  57. package/dist/components/stackShared.d.ts.map +1 -0
  58. package/dist/components/stackShared.js +4 -0
  59. package/dist/contract/fromComponentDoc.d.ts +44 -5
  60. package/dist/contract/fromComponentDoc.d.ts.map +1 -1
  61. package/dist/contract/fromComponentDoc.js +47 -4
  62. package/dist/contract/generateSwift.d.ts.map +1 -1
  63. package/dist/contract/generateSwift.js +193 -10
  64. package/dist/contract/generateTypeScript.d.ts.map +1 -1
  65. package/dist/contract/generateTypeScript.js +69 -9
  66. package/dist/contract/index.d.ts +7 -3
  67. package/dist/contract/index.d.ts.map +1 -1
  68. package/dist/contract/index.js +2 -1
  69. package/dist/contract/parseDocType.d.ts +5 -2
  70. package/dist/contract/parseDocType.d.ts.map +1 -1
  71. package/dist/contract/parseDocType.js +34 -5
  72. package/dist/contract/rules.d.ts +5 -2
  73. package/dist/contract/rules.d.ts.map +1 -1
  74. package/dist/contract/rules.js +8 -4
  75. package/dist/contract/types.d.ts +11 -0
  76. package/dist/contract/types.d.ts.map +1 -1
  77. package/dist/logic/connectBridge.d.ts +29 -0
  78. package/dist/logic/connectBridge.d.ts.map +1 -0
  79. package/dist/logic/connectBridge.js +32 -0
  80. package/dist/logic/createLogicCore.d.ts +44 -0
  81. package/dist/logic/createLogicCore.d.ts.map +1 -0
  82. package/dist/logic/createLogicCore.js +40 -0
  83. package/dist/logic/index.d.ts +12 -0
  84. package/dist/logic/index.d.ts.map +1 -0
  85. package/dist/logic/index.js +10 -0
  86. package/dist/types/android.d.ts +136 -2
  87. package/dist/types/core.d.ts +150 -0
  88. package/dist/types/ios.d.ts +136 -2
  89. package/dist/types/macos.d.ts +136 -2
  90. package/dist/types/shared.d.ts +136 -2
  91. package/dist/types/windows.d.ts +136 -2
  92. package/package.json +10 -4
  93. package/src/components/Badge.ts +18 -0
  94. package/src/components/Button.ts +26 -0
  95. package/src/components/Card.ts +18 -0
  96. package/src/components/Divider.ts +17 -0
  97. package/src/components/HStack.ts +20 -0
  98. package/src/components/Heading.ts +25 -0
  99. package/src/components/ProgressBar.ts +16 -0
  100. package/src/components/Switch.ts +17 -0
  101. package/src/components/Text.ts +24 -0
  102. package/src/components/TextInput.ts +20 -0
  103. package/src/components/VStack.ts +20 -0
  104. package/src/components/index.ts +25 -1
  105. package/src/components/stackShared.ts +14 -0
  106. package/src/contract/contracts.test.ts +58 -0
  107. package/src/contract/fromComponentDoc.test.ts +97 -0
  108. package/src/contract/fromComponentDoc.ts +106 -9
  109. package/src/contract/generateSwift.ts +223 -10
  110. package/src/contract/generateTypeScript.ts +83 -10
  111. package/src/contract/index.ts +13 -4
  112. package/src/contract/parseDocType.test.ts +45 -0
  113. package/src/contract/parseDocType.ts +41 -6
  114. package/src/contract/rules.ts +11 -4
  115. package/src/contract/types.ts +6 -0
  116. package/src/logic/connectBridge.ts +72 -0
  117. package/src/logic/createLogicCore.ts +97 -0
  118. package/src/logic/index.ts +19 -0
  119. package/src/logic/logic.test.ts +160 -0
@@ -0,0 +1,144 @@
1
+ // Generated by @astryxdesign/native. Do not edit.
2
+ public enum ProgressBarVariant: String, CaseIterable, Codable, Sendable {
3
+ case accent = "accent"
4
+ case success = "success"
5
+ case warning = "warning"
6
+ case error = "error"
7
+ case neutral = "neutral"
8
+ }
9
+ public struct ProgressBarMarks: Equatable, Codable, Sendable {
10
+ public var value: Double
11
+ public var label: String
12
+ public init(value: Double, label: String) {
13
+ self.value = value
14
+ self.label = label
15
+ }
16
+ }
17
+ #if os(iOS)
18
+ public struct ProgressBarProps {
19
+ /// Base props attach to this part on every platform.
20
+ public static let baseTarget: AstryxBaseTarget = .root
21
+ public var base: AstryxBaseProps
22
+ public var label: String
23
+ public var value: Double?
24
+ public var max: Double?
25
+ public var isLabelHidden: Bool?
26
+ public var hasValueLabel: Bool?
27
+ public var variant: ProgressBarVariant?
28
+ public var isIndeterminate: Bool?
29
+ public var marks: [ProgressBarMarks]?
30
+ public var isDisabled: Bool?
31
+ public init(label: String, value: Double? = nil, max: Double? = nil, isLabelHidden: Bool? = nil, hasValueLabel: Bool? = nil, variant: ProgressBarVariant? = nil, isIndeterminate: Bool? = nil, marks: [ProgressBarMarks]? = nil, isDisabled: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
32
+ self.label = label
33
+ self.value = value
34
+ self.max = max
35
+ self.isLabelHidden = isLabelHidden
36
+ self.hasValueLabel = hasValueLabel
37
+ self.variant = variant
38
+ self.isIndeterminate = isIndeterminate
39
+ self.marks = marks
40
+ self.isDisabled = isDisabled
41
+ self.base = base
42
+ }
43
+ }
44
+ public struct ProgressBarNode: Decodable, Equatable, Sendable {
45
+ public struct Props: Decodable, Equatable, Sendable {
46
+ public var label: String
47
+ public var value: Double?
48
+ public var max: Double?
49
+ public var isLabelHidden: Bool?
50
+ public var hasValueLabel: Bool?
51
+ public var variant: ProgressBarVariant?
52
+ public var isIndeterminate: Bool?
53
+ public var marks: [ProgressBarMarks]?
54
+ public var isDisabled: Bool?
55
+ }
56
+ public let key: String
57
+ public let base: AstryxBaseProps?
58
+ public let props: Props
59
+ /// The callbacks the core listens to, by prop name.
60
+ public let events: [String]?
61
+
62
+ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
63
+
64
+ /// The contract a ProgressBar view takes; its callbacks send actions to the core.
65
+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ProgressBarProps {
66
+ return ProgressBarProps(
67
+ label: props.label,
68
+ value: props.value,
69
+ max: props.max,
70
+ isLabelHidden: props.isLabelHidden,
71
+ hasValueLabel: props.hasValueLabel,
72
+ variant: props.variant,
73
+ isIndeterminate: props.isIndeterminate,
74
+ marks: props.marks,
75
+ isDisabled: props.isDisabled,
76
+ base: base ?? AstryxBaseProps()
77
+ )
78
+ }
79
+ }
80
+ #endif
81
+ #if os(macOS)
82
+ public struct ProgressBarProps {
83
+ /// Base props attach to this part on every platform.
84
+ public static let baseTarget: AstryxBaseTarget = .root
85
+ public var base: AstryxBaseProps
86
+ public var label: String
87
+ public var value: Double?
88
+ public var max: Double?
89
+ public var isLabelHidden: Bool?
90
+ public var hasValueLabel: Bool?
91
+ public var variant: ProgressBarVariant?
92
+ public var isIndeterminate: Bool?
93
+ public var marks: [ProgressBarMarks]?
94
+ public var isDisabled: Bool?
95
+ public init(label: String, value: Double? = nil, max: Double? = nil, isLabelHidden: Bool? = nil, hasValueLabel: Bool? = nil, variant: ProgressBarVariant? = nil, isIndeterminate: Bool? = nil, marks: [ProgressBarMarks]? = nil, isDisabled: Bool? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
96
+ self.label = label
97
+ self.value = value
98
+ self.max = max
99
+ self.isLabelHidden = isLabelHidden
100
+ self.hasValueLabel = hasValueLabel
101
+ self.variant = variant
102
+ self.isIndeterminate = isIndeterminate
103
+ self.marks = marks
104
+ self.isDisabled = isDisabled
105
+ self.base = base
106
+ }
107
+ }
108
+ public struct ProgressBarNode: Decodable, Equatable, Sendable {
109
+ public struct Props: Decodable, Equatable, Sendable {
110
+ public var label: String
111
+ public var value: Double?
112
+ public var max: Double?
113
+ public var isLabelHidden: Bool?
114
+ public var hasValueLabel: Bool?
115
+ public var variant: ProgressBarVariant?
116
+ public var isIndeterminate: Bool?
117
+ public var marks: [ProgressBarMarks]?
118
+ public var isDisabled: Bool?
119
+ }
120
+ public let key: String
121
+ public let base: AstryxBaseProps?
122
+ public let props: Props
123
+ /// The callbacks the core listens to, by prop name.
124
+ public let events: [String]?
125
+
126
+ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
127
+
128
+ /// The contract a ProgressBar view takes; its callbacks send actions to the core.
129
+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> ProgressBarProps {
130
+ return ProgressBarProps(
131
+ label: props.label,
132
+ value: props.value,
133
+ max: props.max,
134
+ isLabelHidden: props.isLabelHidden,
135
+ hasValueLabel: props.hasValueLabel,
136
+ variant: props.variant,
137
+ isIndeterminate: props.isIndeterminate,
138
+ marks: props.marks,
139
+ isDisabled: props.isDisabled,
140
+ base: base ?? AstryxBaseProps()
141
+ )
142
+ }
143
+ }
144
+ #endif
@@ -1,5 +1,5 @@
1
1
  // Generated by @astryxdesign/native. Do not edit.
2
- public struct SelectorOption: Equatable, Sendable {
2
+ public struct SelectorOption: Equatable, Codable, Sendable {
3
3
  public var value: String
4
4
  public var label: String?
5
5
  public var disabled: Bool?
@@ -9,22 +9,22 @@ public struct SelectorOption: Equatable, Sendable {
9
9
  self.disabled = disabled
10
10
  }
11
11
  }
12
- public enum SelectorSize: String, CaseIterable, Sendable {
12
+ public enum SelectorSize: String, CaseIterable, Codable, Sendable {
13
13
  case sm = "sm"
14
14
  case md = "md"
15
15
  case lg = "lg"
16
16
  }
17
- public enum SelectorVariant: String, CaseIterable, Sendable {
17
+ public enum SelectorVariant: String, CaseIterable, Codable, Sendable {
18
18
  case input = "input"
19
19
  case secondary = "secondary"
20
20
  case ghost = "ghost"
21
21
  }
22
- public enum SelectorStatusType: String, CaseIterable, Sendable {
22
+ public enum SelectorStatusType: String, CaseIterable, Codable, Sendable {
23
23
  case error = "error"
24
24
  case warning = "warning"
25
25
  case success = "success"
26
26
  }
27
- public struct SelectorStatus: Equatable, Sendable {
27
+ public struct SelectorStatus: Equatable, Codable, Sendable {
28
28
  public var type: SelectorStatusType
29
29
  public var message: String?
30
30
  public init(type: SelectorStatusType, message: String? = nil) {
@@ -32,17 +32,17 @@ public struct SelectorStatus: Equatable, Sendable {
32
32
  self.message = message
33
33
  }
34
34
  }
35
- public enum SelectorStatusVariant: String, CaseIterable, Sendable {
35
+ public enum SelectorStatusVariant: String, CaseIterable, Codable, Sendable {
36
36
  case attached = "attached"
37
37
  case detached = "detached"
38
38
  case tooltip = "tooltip"
39
39
  }
40
- public enum SelectorIndicatorPosition: String, CaseIterable, Sendable {
40
+ public enum SelectorIndicatorPosition: String, CaseIterable, Codable, Sendable {
41
41
  case start = "start"
42
42
  case end = "end"
43
43
  }
44
44
  #if os(iOS)
45
- public enum SelectorMenuStyle: String, CaseIterable, Sendable {
45
+ public enum SelectorMenuStyle: String, CaseIterable, Codable, Sendable {
46
46
  case popUp = "popUp"
47
47
  case pullDown = "pullDown"
48
48
  }
@@ -98,9 +98,71 @@ public struct SelectorProps {
98
98
  self.base = base
99
99
  }
100
100
  }
101
+ public struct SelectorNode: Decodable, Equatable, Sendable {
102
+ public struct Props: Decodable, Equatable, Sendable {
103
+ public var label: String
104
+ public var options: [SelectorOption]
105
+ public var value: String?
106
+ public var hasClear: Bool?
107
+ public var hasSearch: Bool?
108
+ public var searchPlaceholder: String?
109
+ public var placeholder: String?
110
+ public var size: SelectorSize?
111
+ public var variant: SelectorVariant?
112
+ public var isDisabled: Bool?
113
+ public var isReadOnly: Bool?
114
+ public var disabledMessage: String?
115
+ public var isLabelHidden: Bool?
116
+ public var description: String?
117
+ public var isOptional: Bool?
118
+ public var isRequired: Bool?
119
+ public var status: SelectorStatus?
120
+ public var statusVariant: SelectorStatusVariant?
121
+ public var indicatorPosition: SelectorIndicatorPosition?
122
+ public var isLoading: Bool?
123
+ public var menuStyle: SelectorMenuStyle?
124
+ }
125
+ public let key: String
126
+ public let base: AstryxBaseProps?
127
+ public let props: Props
128
+ /// The callbacks the core listens to, by prop name.
129
+ public let events: [String]?
130
+
131
+ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
132
+
133
+ /// The contract a Selector view takes; its callbacks send actions to the core.
134
+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> SelectorProps {
135
+ let key = self.key
136
+ return SelectorProps(
137
+ label: props.label,
138
+ options: props.options,
139
+ value: props.value,
140
+ onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "Selector", event: "onChange", args: [AstryxValue(arg0)])) } : nil,
141
+ hasClear: props.hasClear,
142
+ hasSearch: props.hasSearch,
143
+ searchPlaceholder: props.searchPlaceholder,
144
+ placeholder: props.placeholder,
145
+ size: props.size,
146
+ variant: props.variant,
147
+ isDisabled: props.isDisabled,
148
+ isReadOnly: props.isReadOnly,
149
+ disabledMessage: props.disabledMessage,
150
+ isLabelHidden: props.isLabelHidden,
151
+ description: props.description,
152
+ isOptional: props.isOptional,
153
+ isRequired: props.isRequired,
154
+ status: props.status,
155
+ statusVariant: props.statusVariant,
156
+ indicatorPosition: props.indicatorPosition,
157
+ isLoading: props.isLoading,
158
+ menuStyle: props.menuStyle,
159
+ base: base ?? AstryxBaseProps()
160
+ )
161
+ }
162
+ }
101
163
  #endif
102
164
  #if os(macOS)
103
- public enum SelectorMenuStyle: String, CaseIterable, Sendable {
165
+ public enum SelectorMenuStyle: String, CaseIterable, Codable, Sendable {
104
166
  case popUp = "popUp"
105
167
  case pullDown = "pullDown"
106
168
  }
@@ -156,4 +218,66 @@ public struct SelectorProps {
156
218
  self.base = base
157
219
  }
158
220
  }
221
+ public struct SelectorNode: Decodable, Equatable, Sendable {
222
+ public struct Props: Decodable, Equatable, Sendable {
223
+ public var label: String
224
+ public var options: [SelectorOption]
225
+ public var value: String?
226
+ public var hasClear: Bool?
227
+ public var hasSearch: Bool?
228
+ public var searchPlaceholder: String?
229
+ public var placeholder: String?
230
+ public var size: SelectorSize?
231
+ public var variant: SelectorVariant?
232
+ public var isDisabled: Bool?
233
+ public var isReadOnly: Bool?
234
+ public var disabledMessage: String?
235
+ public var isLabelHidden: Bool?
236
+ public var description: String?
237
+ public var isOptional: Bool?
238
+ public var isRequired: Bool?
239
+ public var status: SelectorStatus?
240
+ public var statusVariant: SelectorStatusVariant?
241
+ public var indicatorPosition: SelectorIndicatorPosition?
242
+ public var isLoading: Bool?
243
+ public var menuStyle: SelectorMenuStyle?
244
+ }
245
+ public let key: String
246
+ public let base: AstryxBaseProps?
247
+ public let props: Props
248
+ /// The callbacks the core listens to, by prop name.
249
+ public let events: [String]?
250
+
251
+ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
252
+
253
+ /// The contract a Selector view takes; its callbacks send actions to the core.
254
+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> SelectorProps {
255
+ let key = self.key
256
+ return SelectorProps(
257
+ label: props.label,
258
+ options: props.options,
259
+ value: props.value,
260
+ onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "Selector", event: "onChange", args: [AstryxValue(arg0)])) } : nil,
261
+ hasClear: props.hasClear,
262
+ hasSearch: props.hasSearch,
263
+ searchPlaceholder: props.searchPlaceholder,
264
+ placeholder: props.placeholder,
265
+ size: props.size,
266
+ variant: props.variant,
267
+ isDisabled: props.isDisabled,
268
+ isReadOnly: props.isReadOnly,
269
+ disabledMessage: props.disabledMessage,
270
+ isLabelHidden: props.isLabelHidden,
271
+ description: props.description,
272
+ isOptional: props.isOptional,
273
+ isRequired: props.isRequired,
274
+ status: props.status,
275
+ statusVariant: props.statusVariant,
276
+ indicatorPosition: props.indicatorPosition,
277
+ isLoading: props.isLoading,
278
+ menuStyle: props.menuStyle,
279
+ base: base ?? AstryxBaseProps()
280
+ )
281
+ }
282
+ }
159
283
  #endif
@@ -0,0 +1,202 @@
1
+ // Generated by @astryxdesign/native. Do not edit.
2
+ public enum SwitchSize: String, CaseIterable, Codable, Sendable {
3
+ case sm = "sm"
4
+ case md = "md"
5
+ }
6
+ public enum SwitchStatusType: String, CaseIterable, Codable, Sendable {
7
+ case warning = "warning"
8
+ case error = "error"
9
+ case success = "success"
10
+ }
11
+ public struct SwitchStatus: Equatable, Codable, Sendable {
12
+ public var type: SwitchStatusType
13
+ public var message: String?
14
+ public init(type: SwitchStatusType, message: String? = nil) {
15
+ self.type = type
16
+ self.message = message
17
+ }
18
+ }
19
+ public enum SwitchLabelPosition: String, CaseIterable, Codable, Sendable {
20
+ case start = "start"
21
+ case end = "end"
22
+ }
23
+ public enum SwitchLabelSpacing: String, CaseIterable, Codable, Sendable {
24
+ case hug = "hug"
25
+ case spread = "spread"
26
+ }
27
+ #if os(iOS)
28
+ public struct SwitchProps {
29
+ /// Base props attach to this part on every platform.
30
+ public static let baseTarget: AstryxBaseTarget = .root
31
+ public var base: AstryxBaseProps
32
+ public var label: String
33
+ public var value: Bool
34
+ public var onChange: ((Bool) -> Void)?
35
+ public var isLoading: Bool?
36
+ public var isLabelHidden: Bool?
37
+ public var description: String?
38
+ public var isDisabled: Bool?
39
+ public var size: SwitchSize?
40
+ public var disabledMessage: String?
41
+ public var isOptional: Bool?
42
+ public var isRequired: Bool?
43
+ public var status: SwitchStatus?
44
+ public var labelTooltip: String?
45
+ public var labelPosition: SwitchLabelPosition?
46
+ public var labelSpacing: SwitchLabelSpacing?
47
+ 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, labelPosition: SwitchLabelPosition? = nil, labelSpacing: SwitchLabelSpacing? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
48
+ self.label = label
49
+ self.value = value
50
+ self.onChange = onChange
51
+ self.isLoading = isLoading
52
+ self.isLabelHidden = isLabelHidden
53
+ self.description = description
54
+ self.isDisabled = isDisabled
55
+ self.size = size
56
+ self.disabledMessage = disabledMessage
57
+ self.isOptional = isOptional
58
+ self.isRequired = isRequired
59
+ self.status = status
60
+ self.labelTooltip = labelTooltip
61
+ self.labelPosition = labelPosition
62
+ self.labelSpacing = labelSpacing
63
+ self.base = base
64
+ }
65
+ }
66
+ public struct SwitchNode: Decodable, Equatable, Sendable {
67
+ public struct Props: Decodable, Equatable, Sendable {
68
+ public var label: String
69
+ public var value: Bool
70
+ public var isLoading: Bool?
71
+ public var isLabelHidden: Bool?
72
+ public var description: String?
73
+ public var isDisabled: Bool?
74
+ public var size: SwitchSize?
75
+ public var disabledMessage: String?
76
+ public var isOptional: Bool?
77
+ public var isRequired: Bool?
78
+ public var status: SwitchStatus?
79
+ public var labelTooltip: String?
80
+ public var labelPosition: SwitchLabelPosition?
81
+ public var labelSpacing: SwitchLabelSpacing?
82
+ }
83
+ public let key: String
84
+ public let base: AstryxBaseProps?
85
+ public let props: Props
86
+ /// The callbacks the core listens to, by prop name.
87
+ public let events: [String]?
88
+
89
+ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
90
+
91
+ /// The contract a Switch view takes; its callbacks send actions to the core.
92
+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> SwitchProps {
93
+ let key = self.key
94
+ return SwitchProps(
95
+ label: props.label,
96
+ value: props.value,
97
+ onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "Switch", event: "onChange", args: [AstryxValue(arg0)])) } : nil,
98
+ isLoading: props.isLoading,
99
+ isLabelHidden: props.isLabelHidden,
100
+ description: props.description,
101
+ isDisabled: props.isDisabled,
102
+ size: props.size,
103
+ disabledMessage: props.disabledMessage,
104
+ isOptional: props.isOptional,
105
+ isRequired: props.isRequired,
106
+ status: props.status,
107
+ labelTooltip: props.labelTooltip,
108
+ labelPosition: props.labelPosition,
109
+ labelSpacing: props.labelSpacing,
110
+ base: base ?? AstryxBaseProps()
111
+ )
112
+ }
113
+ }
114
+ #endif
115
+ #if os(macOS)
116
+ public struct SwitchProps {
117
+ /// Base props attach to this part on every platform.
118
+ public static let baseTarget: AstryxBaseTarget = .root
119
+ public var base: AstryxBaseProps
120
+ public var label: String
121
+ public var value: Bool
122
+ public var onChange: ((Bool) -> Void)?
123
+ public var isLoading: Bool?
124
+ public var isLabelHidden: Bool?
125
+ public var description: String?
126
+ public var isDisabled: Bool?
127
+ public var size: SwitchSize?
128
+ public var disabledMessage: String?
129
+ public var isOptional: Bool?
130
+ public var isRequired: Bool?
131
+ public var status: SwitchStatus?
132
+ public var labelTooltip: String?
133
+ public var labelPosition: SwitchLabelPosition?
134
+ public var labelSpacing: SwitchLabelSpacing?
135
+ 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, labelPosition: SwitchLabelPosition? = nil, labelSpacing: SwitchLabelSpacing? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
136
+ self.label = label
137
+ self.value = value
138
+ self.onChange = onChange
139
+ self.isLoading = isLoading
140
+ self.isLabelHidden = isLabelHidden
141
+ self.description = description
142
+ self.isDisabled = isDisabled
143
+ self.size = size
144
+ self.disabledMessage = disabledMessage
145
+ self.isOptional = isOptional
146
+ self.isRequired = isRequired
147
+ self.status = status
148
+ self.labelTooltip = labelTooltip
149
+ self.labelPosition = labelPosition
150
+ self.labelSpacing = labelSpacing
151
+ self.base = base
152
+ }
153
+ }
154
+ public struct SwitchNode: Decodable, Equatable, Sendable {
155
+ public struct Props: Decodable, Equatable, Sendable {
156
+ public var label: String
157
+ public var value: Bool
158
+ public var isLoading: Bool?
159
+ public var isLabelHidden: Bool?
160
+ public var description: String?
161
+ public var isDisabled: Bool?
162
+ public var size: SwitchSize?
163
+ public var disabledMessage: String?
164
+ public var isOptional: Bool?
165
+ public var isRequired: Bool?
166
+ public var status: SwitchStatus?
167
+ public var labelTooltip: String?
168
+ public var labelPosition: SwitchLabelPosition?
169
+ public var labelSpacing: SwitchLabelSpacing?
170
+ }
171
+ public let key: String
172
+ public let base: AstryxBaseProps?
173
+ public let props: Props
174
+ /// The callbacks the core listens to, by prop name.
175
+ public let events: [String]?
176
+
177
+ public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }
178
+
179
+ /// The contract a Switch view takes; its callbacks send actions to the core.
180
+ public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> SwitchProps {
181
+ let key = self.key
182
+ return SwitchProps(
183
+ label: props.label,
184
+ value: props.value,
185
+ onChange: listens("onChange") ? { arg0 in send(AstryxAction(key: key, component: "Switch", event: "onChange", args: [AstryxValue(arg0)])) } : nil,
186
+ isLoading: props.isLoading,
187
+ isLabelHidden: props.isLabelHidden,
188
+ description: props.description,
189
+ isDisabled: props.isDisabled,
190
+ size: props.size,
191
+ disabledMessage: props.disabledMessage,
192
+ isOptional: props.isOptional,
193
+ isRequired: props.isRequired,
194
+ status: props.status,
195
+ labelTooltip: props.labelTooltip,
196
+ labelPosition: props.labelPosition,
197
+ labelSpacing: props.labelSpacing,
198
+ base: base ?? AstryxBaseProps()
199
+ )
200
+ }
201
+ }
202
+ #endif