@astryxdesign/native 0.7.5-canary.fd0aba8 → 0.7.6-canary.0d71e8d
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/apple/Package.swift +1 -1
- package/apple/README.md +8 -15
- package/apple/Sources/Astryx/Banner/Banner.swift +18 -18
- package/apple/Sources/Astryx/Base/BaseProps.swift +5 -0
- package/apple/Sources/Astryx/Base/HitArea.swift +16 -0
- package/apple/Sources/Astryx/Button/Button.spec.md +174 -0
- package/apple/Sources/Astryx/Button/Button.swift +222 -107
- package/apple/Sources/Astryx/Localization/AstryxStrings.swift +25 -0
- package/apple/Sources/Astryx/Resources/af.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/ar.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/ca.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/cs.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/da.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/de.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/el.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/en.lproj/Localizable.strings +24 -0
- package/apple/Sources/Astryx/Resources/es.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/fi.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/fr.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/he.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/hu.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/it.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/ja.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/ko.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/nb.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/nl.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/pl.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/pt-BR.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/pt-PT.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/ro.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/ru.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/sr.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/sv.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/tr.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/uk.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/vi.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/zh-Hans.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/Resources/zh-Hant.lproj/Localizable.strings +21 -0
- package/apple/Sources/Astryx/TextInput/TextInput.spec.md +179 -0
- package/apple/Sources/Astryx/TextInput/TextInput.swift +539 -50
- package/apple/Sources/Astryx/Theme/Theme.swift +5 -5
- package/apple/Sources/Astryx/Wire/AstryxNodeView.swift +2 -0
- package/apple/Tests/AstryxTests/BannerTests.swift +5 -2
- package/apple/Tests/AstryxTests/ButtonTests.swift +100 -4
- package/apple/Tests/AstryxTests/TextInputTests.swift +282 -5
- package/apple/Tests/AstryxTests/TwoThemeTests.swift +69 -0
- package/package.json +3 -3
- package/src/theme/swiftIOSStrings.test.ts +18 -0
|
@@ -1,110 +1,195 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
// Adapted from github.com/ejc3/astryx-swift (MIT).
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
case primary
|
|
9
|
-
case secondary
|
|
10
|
-
case ghost
|
|
11
|
-
case destructive
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/// Core's `Button` sizes: `size-element-sm`, `-md`, and `-lg` high.
|
|
15
|
-
public enum AstryxButtonSize: String, CaseIterable, Sendable {
|
|
16
|
-
case sm
|
|
17
|
-
case md
|
|
18
|
-
case lg
|
|
19
|
-
|
|
20
|
-
var heightToken: String { "size-element-\(rawValue)" }
|
|
21
|
-
var fallbackHeight: CGFloat {
|
|
22
|
-
switch self {
|
|
23
|
-
case .sm: 28
|
|
24
|
-
case .md: 32
|
|
25
|
-
case .lg: 36
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/// A labeled action, painted with the theme's tokens. The tap area reaches
|
|
31
|
-
/// the platform's 44-by-44-point minimum even when the drawn button is smaller.
|
|
4
|
+
/// A labeled action, painted with the theme's tokens. It takes core's Button
|
|
5
|
+
/// props (`ButtonProps`). With `href` it is a link the system opens. The tap
|
|
6
|
+
/// area reaches the platform's 44-by-44-point minimum even when the drawn
|
|
7
|
+
/// button is smaller.
|
|
32
8
|
public struct Button: View {
|
|
33
|
-
let
|
|
34
|
-
let variant: AstryxButtonVariant
|
|
35
|
-
let size: AstryxButtonSize
|
|
36
|
-
let icon: String?
|
|
37
|
-
let isLoading: Bool
|
|
38
|
-
let isDisabled: Bool
|
|
39
|
-
let fillsWidth: Bool
|
|
40
|
-
let action: () -> Void
|
|
9
|
+
public let props: ButtonProps
|
|
41
10
|
@Environment(\.astryx) private var astryx
|
|
11
|
+
/// Which part of a Button with `href` holds focus: its link, or the button
|
|
12
|
+
/// it draws while disabled.
|
|
13
|
+
enum Part: Hashable { case link, button }
|
|
14
|
+
@FocusState private var focus: Part?
|
|
15
|
+
|
|
16
|
+
public init(_ props: ButtonProps) {
|
|
17
|
+
self.props = props
|
|
18
|
+
}
|
|
42
19
|
|
|
43
20
|
/// - Parameters:
|
|
44
|
-
/// -
|
|
45
|
-
///
|
|
46
|
-
/// -
|
|
47
|
-
///
|
|
21
|
+
/// - label: core's `label`, the button's words and accessible name.
|
|
22
|
+
/// - variant: core's `variant`; `secondary` when nil.
|
|
23
|
+
/// - size: core's `size`; `md` when nil.
|
|
24
|
+
/// - elevation: core's `elevation`, the theme's shadow at that depth.
|
|
25
|
+
/// - isLoading: core's `isLoading`: a spinner over the label, undimmed and
|
|
26
|
+
/// focusable, "Loading" spoken, presses ignored until it finishes.
|
|
27
|
+
/// - isInterruptible: core's `isInterruptible`: presses still land while
|
|
28
|
+
/// loading, so they can interrupt it.
|
|
29
|
+
/// - isDisabled: core's `isDisabled`.
|
|
30
|
+
/// - width: core's `width`: `content` (default) or `fill`, the whole width
|
|
31
|
+
/// offered.
|
|
32
|
+
/// - tooltip: core's `tooltip`: a tip on hover with a pointer, and a hint
|
|
33
|
+
/// VoiceOver reads; a tap belongs to the button, as on core's touch
|
|
34
|
+
/// screens.
|
|
35
|
+
/// - href: core's `href`: an enabled button becomes a SwiftUI `Link` the
|
|
36
|
+
/// system opens.
|
|
37
|
+
/// - base: core's base props.
|
|
38
|
+
/// - onClick: core's `onClick`, the press.
|
|
48
39
|
public init(
|
|
49
40
|
label: String,
|
|
50
|
-
variant:
|
|
51
|
-
size:
|
|
52
|
-
|
|
53
|
-
isLoading: Bool =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
41
|
+
variant: ButtonVariant? = nil,
|
|
42
|
+
size: ButtonSize? = nil,
|
|
43
|
+
elevation: ButtonElevation? = nil,
|
|
44
|
+
isLoading: Bool? = nil,
|
|
45
|
+
isInterruptible: Bool? = nil,
|
|
46
|
+
isDisabled: Bool? = nil,
|
|
47
|
+
width: ButtonWidth? = nil,
|
|
48
|
+
tooltip: String? = nil,
|
|
49
|
+
href: String? = nil,
|
|
50
|
+
base: AstryxBaseProps = AstryxBaseProps(),
|
|
51
|
+
onClick: (() -> Void)? = nil
|
|
57
52
|
) {
|
|
58
|
-
self.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
self.init(
|
|
54
|
+
ButtonProps(
|
|
55
|
+
label: label,
|
|
56
|
+
variant: variant,
|
|
57
|
+
size: size,
|
|
58
|
+
elevation: elevation,
|
|
59
|
+
isLoading: isLoading,
|
|
60
|
+
isInterruptible: isInterruptible,
|
|
61
|
+
isDisabled: isDisabled,
|
|
62
|
+
width: width,
|
|
63
|
+
tooltip: tooltip,
|
|
64
|
+
onClick: onClick,
|
|
65
|
+
href: href,
|
|
66
|
+
base: base
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
var isLoading: Bool { props.isLoading == true }
|
|
72
|
+
var isDisabled: Bool { props.isDisabled == true }
|
|
73
|
+
|
|
74
|
+
/// The destination a Button with `href` opens while enabled, or nil when
|
|
75
|
+
/// it has none or its destination is refused.
|
|
76
|
+
var destination: URL? {
|
|
77
|
+
guard let href = props.href, let safe = Self.safeDestination(href) else { return nil }
|
|
78
|
+
return URL(string: safe)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/// The link an enabled button with `href` becomes. A disabled one draws a
|
|
82
|
+
/// disabled button, as core draws a disabled `<button>`.
|
|
83
|
+
var link: URL? { isDisabled ? nil : destination }
|
|
84
|
+
|
|
85
|
+
/// A destination a link may open, normalized as core's shared rule does, or
|
|
86
|
+
/// nil for a script URL or an HTML document in a `data:` URL, which core's
|
|
87
|
+
/// navigation destinations refuse (`family:navigation-destinations` FR4).
|
|
88
|
+
/// Control characters are removed and whitespace trimmed; the scheme is
|
|
89
|
+
/// compared in lowercase without the spaces after its colon, which a data
|
|
90
|
+
/// URL's media type ignores (`data: text/html` is HTML).
|
|
91
|
+
nonisolated static func safeDestination(_ href: String) -> String? {
|
|
92
|
+
let normalized = String(String.UnicodeScalarView(
|
|
93
|
+
href.unicodeScalars.filter { $0.value > 0x1F && $0.value != 0x7F }
|
|
94
|
+
)).trimmingCharacters(in: .whitespacesAndNewlines)
|
|
95
|
+
var comparable = normalized.lowercased()
|
|
96
|
+
if let colon = comparable.firstIndex(of: ":"),
|
|
97
|
+
comparable[..<colon].range(of: "^[a-z][a-z0-9+.-]*$", options: .regularExpression) != nil {
|
|
98
|
+
let rest = comparable[comparable.index(after: colon)...].drop { $0 == " " }
|
|
99
|
+
comparable = String(comparable[...colon]) + rest
|
|
100
|
+
}
|
|
101
|
+
for blocked in ["javascript:", "vbscript:", "data:text/html"] where comparable.hasPrefix(blocked) {
|
|
102
|
+
return nil
|
|
103
|
+
}
|
|
104
|
+
return normalized
|
|
66
105
|
}
|
|
67
106
|
|
|
68
107
|
public var body: some View {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
108
|
+
control
|
|
109
|
+
.buttonStyle(style)
|
|
110
|
+
// The shared Astryx tooltip on hover and keyboard focus, as core's
|
|
111
|
+
// Button tooltip; its words are the VoiceOver hint.
|
|
112
|
+
.astryxTooltip(props.tooltip, hint: props.tooltip, focus: .control)
|
|
113
|
+
.accessibilityLabel(SwiftUI.Text(accessibilityText))
|
|
114
|
+
.accessibilityValue(SwiftUI.Text(loadingValue ?? ""))
|
|
115
|
+
.onChange(of: isLoading) { _, loading in
|
|
116
|
+
if loading { AccessibilityNotification.Announcement(AstryxStrings.buttonLoading).post() }
|
|
117
|
+
}
|
|
118
|
+
.astryxBase(props.base)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@ViewBuilder private var control: some View {
|
|
122
|
+
if let destination {
|
|
123
|
+
// A Button with `href` keeps its link and its disabled button in one
|
|
124
|
+
// structure; only one is shown and reachable at a time, and focus moves
|
|
125
|
+
// from the link to the button when it becomes disabled and back, so it
|
|
126
|
+
// stays inside the component (AST-085 FR4, core Button FR10).
|
|
127
|
+
ZStack {
|
|
128
|
+
// A link the system opens, read as a link; while loading it stays a
|
|
129
|
+
// link and opens nothing until loading ends, unless interruptible.
|
|
130
|
+
SwiftUI.Link(destination: destination) { content }
|
|
131
|
+
.environment(\.openURL, OpenURLAction { _ in
|
|
132
|
+
let lands = acceptsPress
|
|
133
|
+
if lands { props.onClick?() }
|
|
134
|
+
return lands ? .systemAction : .handled
|
|
135
|
+
})
|
|
136
|
+
.focused($focus, equals: .link)
|
|
137
|
+
.disabled(isDisabled)
|
|
138
|
+
.opacity(isDisabled ? 0 : 1)
|
|
139
|
+
.accessibilityHidden(isDisabled)
|
|
140
|
+
plainButton
|
|
141
|
+
.focused($focus, equals: .button)
|
|
142
|
+
.disabled(!isDisabled)
|
|
143
|
+
.opacity(isDisabled ? 1 : 0)
|
|
144
|
+
.accessibilityHidden(!isDisabled)
|
|
78
145
|
}
|
|
146
|
+
.onChange(of: isDisabled) { _, disabled in
|
|
147
|
+
if focus != nil { focus = disabled ? .button : .link }
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
plainButton
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/// A disabled Button keeps its focus stop, as core keeps it focusable, so
|
|
155
|
+
/// keyboard users reach it and its tooltip; presses never land. VoiceOver
|
|
156
|
+
/// reads the platform's button, dimmed when disabled, in both states, so a
|
|
157
|
+
/// focused Button that becomes disabled keeps one view structure and focus.
|
|
158
|
+
private var plainButton: some View {
|
|
159
|
+
SwiftUI.Button(action: activate) { content }
|
|
160
|
+
.accessibilityAddTraits(Self.accessibilityTraits)
|
|
161
|
+
.accessibilityRepresentation {
|
|
162
|
+
SwiftUI.Button(accessibilityText, action: activate).disabled(isDisabled)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private var content: some View {
|
|
167
|
+
// The label keeps its place while loading so the width holds; the
|
|
168
|
+
// spinner draws over it.
|
|
169
|
+
SwiftUI.Text(props.label)
|
|
170
|
+
.lineLimit(1)
|
|
79
171
|
.opacity(isLoading ? 0 : 1)
|
|
80
172
|
.overlay {
|
|
81
173
|
if isLoading {
|
|
82
174
|
ProgressView().controlSize(.small).tint(foreground)
|
|
83
175
|
}
|
|
84
176
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private var style: AstryxButtonStyle {
|
|
180
|
+
AstryxButtonStyle(
|
|
181
|
+
astryx: astryx,
|
|
182
|
+
height: height,
|
|
183
|
+
fillsWidth: props.width == .fill,
|
|
184
|
+
foreground: foreground,
|
|
185
|
+
background: background,
|
|
186
|
+
shadow: shadow,
|
|
187
|
+
isDimmed: isDisabled
|
|
94
188
|
)
|
|
95
|
-
// As core's Button: a loading button stays undimmed and focusable, keeps
|
|
96
|
-
// its label, and says Loading; taps do nothing until it finishes.
|
|
97
|
-
.disabled(isDisabled)
|
|
98
|
-
.accessibilityLabel(SwiftUI.Text(accessibilityText))
|
|
99
|
-
.accessibilityAddTraits(Self.accessibilityTraits)
|
|
100
|
-
.accessibilityValue(SwiftUI.Text(loadingValue ?? ""))
|
|
101
|
-
.onChange(of: isLoading) { _, loading in
|
|
102
|
-
if loading { AccessibilityNotification.Announcement(AstryxStrings.buttonLoading).post() }
|
|
103
|
-
}
|
|
104
189
|
}
|
|
105
190
|
|
|
106
191
|
/// The button's accessible name: its label, also while loading.
|
|
107
|
-
var accessibilityText: String { label }
|
|
192
|
+
var accessibilityText: String { props.label }
|
|
108
193
|
|
|
109
194
|
/// The traits assistive technology gets: a button.
|
|
110
195
|
static var accessibilityTraits: AccessibilityTraits { .isButton }
|
|
@@ -113,52 +198,81 @@ public struct Button: View {
|
|
|
113
198
|
/// catalog message, in the person's language.
|
|
114
199
|
var loadingValue: String? { isLoading ? AstryxStrings.buttonLoading : nil }
|
|
115
200
|
|
|
116
|
-
///
|
|
201
|
+
/// Whether a press lands now: not while loading, unless interruptible.
|
|
202
|
+
var acceptsPress: Bool { !isDisabled && (!isLoading || props.isInterruptible == true) }
|
|
203
|
+
|
|
204
|
+
/// A disabled Button keeps its focus stop (core Button FR10).
|
|
205
|
+
var keepsFocusWhileDisabled: Bool { isDisabled }
|
|
206
|
+
|
|
207
|
+
/// Runs `onClick` when a press lands.
|
|
117
208
|
func activate() {
|
|
118
|
-
guard
|
|
119
|
-
|
|
209
|
+
guard acceptsPress else { return }
|
|
210
|
+
props.onClick?()
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var height: CGFloat {
|
|
214
|
+
let size = astryx.tokens.size
|
|
215
|
+
switch props.size ?? .md {
|
|
216
|
+
case .sm: return size.elementSm
|
|
217
|
+
case .md: return size.elementMd
|
|
218
|
+
case .lg: return size.elementLg
|
|
219
|
+
}
|
|
120
220
|
}
|
|
121
221
|
|
|
122
222
|
private var foreground: Color {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
case .
|
|
126
|
-
case .
|
|
223
|
+
let color = astryx.tokens.color
|
|
224
|
+
switch props.variant ?? .secondary {
|
|
225
|
+
case .primary: return color.onAccent
|
|
226
|
+
case .destructive: return color.onError
|
|
227
|
+
case .secondary, .ghost: return color.textPrimary
|
|
127
228
|
}
|
|
128
229
|
}
|
|
129
230
|
|
|
130
231
|
private var background: Color {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
case .
|
|
134
|
-
case .
|
|
135
|
-
case .
|
|
232
|
+
let color = astryx.tokens.color
|
|
233
|
+
switch props.variant ?? .secondary {
|
|
234
|
+
case .primary: return color.accent
|
|
235
|
+
case .destructive: return color.error
|
|
236
|
+
case .secondary: return color.neutral
|
|
237
|
+
case .ghost: return .clear
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
var shadow: [ShadowLayer] {
|
|
242
|
+
let shadow = astryx.tokens.shadow
|
|
243
|
+
switch props.elevation ?? .none {
|
|
244
|
+
case .none: return []
|
|
245
|
+
case .low: return shadow.low
|
|
246
|
+
case .med: return shadow.med
|
|
247
|
+
case .high: return shadow.high
|
|
136
248
|
}
|
|
137
249
|
}
|
|
138
250
|
}
|
|
139
251
|
|
|
140
252
|
struct AstryxButtonStyle: ButtonStyle {
|
|
141
253
|
let astryx: AstryxStyle
|
|
142
|
-
let
|
|
254
|
+
let height: CGFloat
|
|
143
255
|
let fillsWidth: Bool
|
|
144
256
|
let foreground: Color
|
|
145
257
|
let background: Color
|
|
146
|
-
|
|
258
|
+
let shadow: [ShadowLayer]
|
|
259
|
+
/// Draws the disabled look for a disabled Button that keeps its focus stop.
|
|
260
|
+
var isDimmed = false
|
|
261
|
+
@Environment(\.isEnabled) private var environmentEnabled
|
|
262
|
+
private var isEnabled: Bool { environmentEnabled && !isDimmed }
|
|
147
263
|
|
|
148
264
|
func makeBody(configuration: Configuration) -> some View {
|
|
149
|
-
let shape = RoundedRectangle(
|
|
150
|
-
|
|
151
|
-
style: .continuous
|
|
152
|
-
)
|
|
153
|
-
// Grows with text size, but not so far that one line of a large label
|
|
154
|
-
// becomes a tall slab.
|
|
155
|
-
let height = astryx.size(size.heightToken, size.fallbackHeight) * min(astryx.textScale, 1.4)
|
|
265
|
+
let shape = RoundedRectangle(cornerRadius: astryx.tokens.radius.element, style: .continuous)
|
|
266
|
+
let font = astryx.tokens.font
|
|
156
267
|
configuration.label
|
|
157
|
-
.font(astryx.font(
|
|
268
|
+
.font(astryx.font(TypeStyle(font.label, families: font.family.body)))
|
|
158
269
|
.foregroundStyle(foreground)
|
|
159
|
-
.padding(.horizontal, astryx.space
|
|
160
|
-
|
|
270
|
+
.padding(.horizontal, astryx.tokens.space.s3)
|
|
271
|
+
// Grows with text size, but not so far that one line of a large label
|
|
272
|
+
// becomes a tall slab.
|
|
273
|
+
.frame(maxWidth: fillsWidth ? .infinity : nil, minHeight: height * min(astryx.textScale, 1.4))
|
|
161
274
|
.background(shape.fill(background))
|
|
275
|
+
.astryxShadow(shadow, in: shape)
|
|
162
276
|
.opacity(isEnabled ? (configuration.isPressed ? 0.75 : 1) : 0.5)
|
|
163
277
|
// Drawn at the token size; laid out at least 44 by 44 so the whole
|
|
164
278
|
// platform-minimum tap area counts.
|
|
@@ -166,3 +280,4 @@ struct AstryxButtonStyle: ButtonStyle {
|
|
|
166
280
|
.contentShape(Rectangle())
|
|
167
281
|
}
|
|
168
282
|
}
|
|
283
|
+
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
|
+
import AstryxNative
|
|
3
4
|
import Foundation
|
|
4
5
|
|
|
5
6
|
/// Core's catalog messages, read from `Resources/<locale>.lproj`, which
|
|
@@ -44,6 +45,30 @@ enum AstryxStrings {
|
|
|
44
45
|
fill(localized("@astryx.thumbnail.remove", "Remove {accessibleName}"), ["accessibleName": accessibleName])
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
/// The indicator after an optional field's label.
|
|
49
|
+
static var fieldOptional: String { localized("@astryx.field.optional", "Optional") }
|
|
50
|
+
/// What VoiceOver reads for a read-only field, which SwiftUI cannot mark.
|
|
51
|
+
static var inputReadOnly: String { localized("@astryx.input.readOnly", "Read only") }
|
|
52
|
+
/// The indicator after a required field's label.
|
|
53
|
+
static var fieldRequired: String { localized("@astryx.field.required", "Required") }
|
|
54
|
+
/// The hover and pointer tip on an input's clear button.
|
|
55
|
+
static var clearTooltip: String { localized("@astryx.inputClearButton.tooltip", "Clear") }
|
|
56
|
+
|
|
57
|
+
/// The clear button's accessible name, naming the field.
|
|
58
|
+
static func clearLabel(_ label: String) -> String {
|
|
59
|
+
localized("@astryx.textInput.clearLabel", "Clear {label}").replacingOccurrences(of: "{label}", with: label)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// The accessible name of an input's status button when its message shows
|
|
63
|
+
/// in a tip.
|
|
64
|
+
static func statusButton(_ type: TextInputStatusType) -> String {
|
|
65
|
+
switch type {
|
|
66
|
+
case .error: localized("@astryx.input.statusButton.error", "Error details")
|
|
67
|
+
case .warning: localized("@astryx.input.statusButton.warning", "Warning details")
|
|
68
|
+
case .success: localized("@astryx.input.statusButton.success", "Success details")
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
47
72
|
static func localized(_ key: String, _ english: String) -> String {
|
|
48
73
|
resourceBundle.localizedString(forKey: key, value: english, table: nil)
|
|
49
74
|
}
|
|
@@ -6,9 +6,30 @@
|
|
|
6
6
|
/* Screen-reader-only live-region announcement while a Button is in its loading state (spinner shown, action in flight). Progressive sense ("work in progress"), not a noun. Kept separate from `typeahead.loading` — translations may diverge. */
|
|
7
7
|
"@astryx.button.loading" = "Laai tans";
|
|
8
8
|
|
|
9
|
+
/* Visible indicator shown next to a form field's label when the field is optional (isOptional). Mutually exclusive with the required indicator. Very short — appears inline after the label text. */
|
|
10
|
+
"@astryx.field.optional" = "Opsioneel";
|
|
11
|
+
|
|
12
|
+
/* Visible indicator shown next to a form field's label when the field must be filled in (isRequired). Mutually exclusive with the optional indicator. Very short — appears inline after the label text. */
|
|
13
|
+
"@astryx.field.required" = "Verpligtend";
|
|
14
|
+
|
|
15
|
+
/* Screen-reader-only description appended to a read-only form control when the platform does not expose aria-readonly for that control's host element. Short state label, not an instruction. */
|
|
16
|
+
"@astryx.input.readOnly" = "Slegs lees";
|
|
17
|
+
|
|
18
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is error. Activating or focusing the button reveals the error message in a tooltip. Keep it short — it labels an icon-only button. */
|
|
19
|
+
"@astryx.input.statusButton.error" = "Foutbesonderhede";
|
|
20
|
+
|
|
21
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is success. Activating or focusing the button reveals the success message in a tooltip. */
|
|
22
|
+
"@astryx.input.statusButton.success" = "Suksesbesonderhede";
|
|
23
|
+
|
|
24
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is warning. Activating or focusing the button reveals the warning message in a tooltip. */
|
|
25
|
+
"@astryx.input.statusButton.warning" = "Waarskuwingbesonderhede";
|
|
26
|
+
|
|
9
27
|
/* Screen-reader-only default name for a standalone Spinner's role="status" element, used when the consumer supplies neither `aria-label` nor a visible string label. Present-progressive form. Kept separate from `button.loading` and `typeahead.loading` — translations may diverge. */
|
|
10
28
|
"@astryx.spinner.loading" = "Laai tans";
|
|
11
29
|
|
|
30
|
+
/* Screen-reader-only label on the X that clears the value from a TextInput. Example: `Clear Email`, `Clear Name`. */
|
|
31
|
+
"@astryx.textInput.clearLabel" = "Vee {label} uit";
|
|
32
|
+
|
|
12
33
|
/* Generic screen-reader name for a Thumbnail (image preview) that has no `alt` or `label`. Last-resort fallback so the control is never nameless; prefer a real name via `alt` or `label`. */
|
|
13
34
|
"@astryx.thumbnail.fallbackName" = "Duimnael";
|
|
14
35
|
|
|
@@ -6,9 +6,30 @@
|
|
|
6
6
|
/* Screen-reader-only live-region announcement while a Button is in its loading state (spinner shown, action in flight). Progressive sense ("work in progress"), not a noun. Kept separate from `typeahead.loading` — translations may diverge. */
|
|
7
7
|
"@astryx.button.loading" = "جارٍ التحميل";
|
|
8
8
|
|
|
9
|
+
/* Visible indicator shown next to a form field's label when the field is optional (isOptional). Mutually exclusive with the required indicator. Very short — appears inline after the label text. */
|
|
10
|
+
"@astryx.field.optional" = "اختياري";
|
|
11
|
+
|
|
12
|
+
/* Visible indicator shown next to a form field's label when the field must be filled in (isRequired). Mutually exclusive with the optional indicator. Very short — appears inline after the label text. */
|
|
13
|
+
"@astryx.field.required" = "مطلوب";
|
|
14
|
+
|
|
15
|
+
/* Screen-reader-only description appended to a read-only form control when the platform does not expose aria-readonly for that control's host element. Short state label, not an instruction. */
|
|
16
|
+
"@astryx.input.readOnly" = "للقراءة فقط";
|
|
17
|
+
|
|
18
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is error. Activating or focusing the button reveals the error message in a tooltip. Keep it short — it labels an icon-only button. */
|
|
19
|
+
"@astryx.input.statusButton.error" = "تفاصيل الخطأ";
|
|
20
|
+
|
|
21
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is success. Activating or focusing the button reveals the success message in a tooltip. */
|
|
22
|
+
"@astryx.input.statusButton.success" = "تفاصيل النجاح";
|
|
23
|
+
|
|
24
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is warning. Activating or focusing the button reveals the warning message in a tooltip. */
|
|
25
|
+
"@astryx.input.statusButton.warning" = "تفاصيل التحذير";
|
|
26
|
+
|
|
9
27
|
/* Screen-reader-only default name for a standalone Spinner's role="status" element, used when the consumer supplies neither `aria-label` nor a visible string label. Present-progressive form. Kept separate from `button.loading` and `typeahead.loading` — translations may diverge. */
|
|
10
28
|
"@astryx.spinner.loading" = "جارٍ التحميل";
|
|
11
29
|
|
|
30
|
+
/* Screen-reader-only label on the X that clears the value from a TextInput. Example: `Clear Email`, `Clear Name`. */
|
|
31
|
+
"@astryx.textInput.clearLabel" = "مسح {label}";
|
|
32
|
+
|
|
12
33
|
/* Generic screen-reader name for a Thumbnail (image preview) that has no `alt` or `label`. Last-resort fallback so the control is never nameless; prefer a real name via `alt` or `label`. */
|
|
13
34
|
"@astryx.thumbnail.fallbackName" = "صورة مصغّرة";
|
|
14
35
|
|
|
@@ -6,9 +6,30 @@
|
|
|
6
6
|
/* Screen-reader-only live-region announcement while a Button is in its loading state (spinner shown, action in flight). Progressive sense ("work in progress"), not a noun. Kept separate from `typeahead.loading` — translations may diverge. */
|
|
7
7
|
"@astryx.button.loading" = "S’està carregant";
|
|
8
8
|
|
|
9
|
+
/* Visible indicator shown next to a form field's label when the field is optional (isOptional). Mutually exclusive with the required indicator. Very short — appears inline after the label text. */
|
|
10
|
+
"@astryx.field.optional" = "Opcional";
|
|
11
|
+
|
|
12
|
+
/* Visible indicator shown next to a form field's label when the field must be filled in (isRequired). Mutually exclusive with the optional indicator. Very short — appears inline after the label text. */
|
|
13
|
+
"@astryx.field.required" = "Obligatori";
|
|
14
|
+
|
|
15
|
+
/* Screen-reader-only description appended to a read-only form control when the platform does not expose aria-readonly for that control's host element. Short state label, not an instruction. */
|
|
16
|
+
"@astryx.input.readOnly" = "Només de lectura";
|
|
17
|
+
|
|
18
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is error. Activating or focusing the button reveals the error message in a tooltip. Keep it short — it labels an icon-only button. */
|
|
19
|
+
"@astryx.input.statusButton.error" = "Detalls de l’error";
|
|
20
|
+
|
|
21
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is success. Activating or focusing the button reveals the success message in a tooltip. */
|
|
22
|
+
"@astryx.input.statusButton.success" = "Detalls de l’èxit";
|
|
23
|
+
|
|
24
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is warning. Activating or focusing the button reveals the warning message in a tooltip. */
|
|
25
|
+
"@astryx.input.statusButton.warning" = "Detalls de l’advertiment";
|
|
26
|
+
|
|
9
27
|
/* Screen-reader-only default name for a standalone Spinner's role="status" element, used when the consumer supplies neither `aria-label` nor a visible string label. Present-progressive form. Kept separate from `button.loading` and `typeahead.loading` — translations may diverge. */
|
|
10
28
|
"@astryx.spinner.loading" = "S’està carregant";
|
|
11
29
|
|
|
30
|
+
/* Screen-reader-only label on the X that clears the value from a TextInput. Example: `Clear Email`, `Clear Name`. */
|
|
31
|
+
"@astryx.textInput.clearLabel" = "Esborra {label}";
|
|
32
|
+
|
|
12
33
|
/* Generic screen-reader name for a Thumbnail (image preview) that has no `alt` or `label`. Last-resort fallback so the control is never nameless; prefer a real name via `alt` or `label`. */
|
|
13
34
|
"@astryx.thumbnail.fallbackName" = "Miniatura";
|
|
14
35
|
|
|
@@ -6,9 +6,30 @@
|
|
|
6
6
|
/* Screen-reader-only live-region announcement while a Button is in its loading state (spinner shown, action in flight). Progressive sense ("work in progress"), not a noun. Kept separate from `typeahead.loading` — translations may diverge. */
|
|
7
7
|
"@astryx.button.loading" = "Načítání";
|
|
8
8
|
|
|
9
|
+
/* Visible indicator shown next to a form field's label when the field is optional (isOptional). Mutually exclusive with the required indicator. Very short — appears inline after the label text. */
|
|
10
|
+
"@astryx.field.optional" = "Volitelné";
|
|
11
|
+
|
|
12
|
+
/* Visible indicator shown next to a form field's label when the field must be filled in (isRequired). Mutually exclusive with the optional indicator. Very short — appears inline after the label text. */
|
|
13
|
+
"@astryx.field.required" = "Povinné";
|
|
14
|
+
|
|
15
|
+
/* Screen-reader-only description appended to a read-only form control when the platform does not expose aria-readonly for that control's host element. Short state label, not an instruction. */
|
|
16
|
+
"@astryx.input.readOnly" = "Jen pro čtení";
|
|
17
|
+
|
|
18
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is error. Activating or focusing the button reveals the error message in a tooltip. Keep it short — it labels an icon-only button. */
|
|
19
|
+
"@astryx.input.statusButton.error" = "Podrobnosti chyby";
|
|
20
|
+
|
|
21
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is success. Activating or focusing the button reveals the success message in a tooltip. */
|
|
22
|
+
"@astryx.input.statusButton.success" = "Podrobnosti úspěchu";
|
|
23
|
+
|
|
24
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is warning. Activating or focusing the button reveals the warning message in a tooltip. */
|
|
25
|
+
"@astryx.input.statusButton.warning" = "Podrobnosti varování";
|
|
26
|
+
|
|
9
27
|
/* Screen-reader-only default name for a standalone Spinner's role="status" element, used when the consumer supplies neither `aria-label` nor a visible string label. Present-progressive form. Kept separate from `button.loading` and `typeahead.loading` — translations may diverge. */
|
|
10
28
|
"@astryx.spinner.loading" = "Načítání";
|
|
11
29
|
|
|
30
|
+
/* Screen-reader-only label on the X that clears the value from a TextInput. Example: `Clear Email`, `Clear Name`. */
|
|
31
|
+
"@astryx.textInput.clearLabel" = "Vymazat {label}";
|
|
32
|
+
|
|
12
33
|
/* Generic screen-reader name for a Thumbnail (image preview) that has no `alt` or `label`. Last-resort fallback so the control is never nameless; prefer a real name via `alt` or `label`. */
|
|
13
34
|
"@astryx.thumbnail.fallbackName" = "Náhled";
|
|
14
35
|
|
|
@@ -6,9 +6,30 @@
|
|
|
6
6
|
/* Screen-reader-only live-region announcement while a Button is in its loading state (spinner shown, action in flight). Progressive sense ("work in progress"), not a noun. Kept separate from `typeahead.loading` — translations may diverge. */
|
|
7
7
|
"@astryx.button.loading" = "Indlæser";
|
|
8
8
|
|
|
9
|
+
/* Visible indicator shown next to a form field's label when the field is optional (isOptional). Mutually exclusive with the required indicator. Very short — appears inline after the label text. */
|
|
10
|
+
"@astryx.field.optional" = "Valgfri";
|
|
11
|
+
|
|
12
|
+
/* Visible indicator shown next to a form field's label when the field must be filled in (isRequired). Mutually exclusive with the optional indicator. Very short — appears inline after the label text. */
|
|
13
|
+
"@astryx.field.required" = "Påkrævet";
|
|
14
|
+
|
|
15
|
+
/* Screen-reader-only description appended to a read-only form control when the platform does not expose aria-readonly for that control's host element. Short state label, not an instruction. */
|
|
16
|
+
"@astryx.input.readOnly" = "Skrivebeskyttet";
|
|
17
|
+
|
|
18
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is error. Activating or focusing the button reveals the error message in a tooltip. Keep it short — it labels an icon-only button. */
|
|
19
|
+
"@astryx.input.statusButton.error" = "Fejldetaljer";
|
|
20
|
+
|
|
21
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is success. Activating or focusing the button reveals the success message in a tooltip. */
|
|
22
|
+
"@astryx.input.statusButton.success" = "Detaljer om succes";
|
|
23
|
+
|
|
24
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is warning. Activating or focusing the button reveals the warning message in a tooltip. */
|
|
25
|
+
"@astryx.input.statusButton.warning" = "Advarselsdetaljer";
|
|
26
|
+
|
|
9
27
|
/* Screen-reader-only default name for a standalone Spinner's role="status" element, used when the consumer supplies neither `aria-label` nor a visible string label. Present-progressive form. Kept separate from `button.loading` and `typeahead.loading` — translations may diverge. */
|
|
10
28
|
"@astryx.spinner.loading" = "Indlæser";
|
|
11
29
|
|
|
30
|
+
/* Screen-reader-only label on the X that clears the value from a TextInput. Example: `Clear Email`, `Clear Name`. */
|
|
31
|
+
"@astryx.textInput.clearLabel" = "Ryd {label}";
|
|
32
|
+
|
|
12
33
|
/* Generic screen-reader name for a Thumbnail (image preview) that has no `alt` or `label`. Last-resort fallback so the control is never nameless; prefer a real name via `alt` or `label`. */
|
|
13
34
|
"@astryx.thumbnail.fallbackName" = "Miniature";
|
|
14
35
|
|
|
@@ -6,9 +6,30 @@
|
|
|
6
6
|
/* Screen-reader-only live-region announcement while a Button is in its loading state (spinner shown, action in flight). Progressive sense ("work in progress"), not a noun. Kept separate from `typeahead.loading` — translations may diverge. */
|
|
7
7
|
"@astryx.button.loading" = "Wird geladen";
|
|
8
8
|
|
|
9
|
+
/* Visible indicator shown next to a form field's label when the field is optional (isOptional). Mutually exclusive with the required indicator. Very short — appears inline after the label text. */
|
|
10
|
+
"@astryx.field.optional" = "Optional";
|
|
11
|
+
|
|
12
|
+
/* Visible indicator shown next to a form field's label when the field must be filled in (isRequired). Mutually exclusive with the optional indicator. Very short — appears inline after the label text. */
|
|
13
|
+
"@astryx.field.required" = "Erforderlich";
|
|
14
|
+
|
|
15
|
+
/* Screen-reader-only description appended to a read-only form control when the platform does not expose aria-readonly for that control's host element. Short state label, not an instruction. */
|
|
16
|
+
"@astryx.input.readOnly" = "Schreibgeschützt";
|
|
17
|
+
|
|
18
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is error. Activating or focusing the button reveals the error message in a tooltip. Keep it short — it labels an icon-only button. */
|
|
19
|
+
"@astryx.input.statusButton.error" = "Fehlerdetails";
|
|
20
|
+
|
|
21
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is success. Activating or focusing the button reveals the success message in a tooltip. */
|
|
22
|
+
"@astryx.input.statusButton.success" = "Erfolgsdetails";
|
|
23
|
+
|
|
24
|
+
/* Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is warning. Activating or focusing the button reveals the warning message in a tooltip. */
|
|
25
|
+
"@astryx.input.statusButton.warning" = "Warndetails";
|
|
26
|
+
|
|
9
27
|
/* Screen-reader-only default name for a standalone Spinner's role="status" element, used when the consumer supplies neither `aria-label` nor a visible string label. Present-progressive form. Kept separate from `button.loading` and `typeahead.loading` — translations may diverge. */
|
|
10
28
|
"@astryx.spinner.loading" = "Wird geladen";
|
|
11
29
|
|
|
30
|
+
/* Screen-reader-only label on the X that clears the value from a TextInput. Example: `Clear Email`, `Clear Name`. */
|
|
31
|
+
"@astryx.textInput.clearLabel" = "{label} löschen";
|
|
32
|
+
|
|
12
33
|
/* Generic screen-reader name for a Thumbnail (image preview) that has no `alt` or `label`. Last-resort fallback so the control is never nameless; prefer a real name via `alt` or `label`. */
|
|
13
34
|
"@astryx.thumbnail.fallbackName" = "Miniaturansicht";
|
|
14
35
|
|