-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathObjectElements.swift
More file actions
241 lines (180 loc) · 6.81 KB
/
ObjectElements.swift
File metadata and controls
241 lines (180 loc) · 6.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
Abstract:
The file contains the object elements. The html-element 'object' only allows these elements to be its descendants.
Note:
If you about to add something to the file, stick to the official documentation to keep the code consistent.
*/
import OrderedCollections
/// The alias for the element Parameter.
///
/// Param is the official tag and can be used instead of Parameter.
///
/// ```html
/// <param>
/// ```
@_documentation(visibility: internal)
public typealias Param = Parameter
/// The element defines parameters for plugins invoked by an object element.
///
/// ```html
/// <param>
/// ```
public struct Parameter: EmptyNode, ObjectElement {
internal var name: String { "param" }
internal var attributes: OrderedDictionary<String, Any>?
@available(*, deprecated, message: "The parameter element is no longer part of the web standards. Use the data attribute of the object element instead.")
public init() {}
@available(*, deprecated, message: "The parameter element is no longer part of the web standards. Use the data attribute of the object element instead.")
internal init(attributes: OrderedDictionary<String, Any>?) {
self.attributes = attributes
}
public func modify(if condition: Bool, element: (Parameter) -> Parameter) -> Parameter {
if condition {
return self.modify(element(self))
}
return self
}
public func modify<T>(unwrap value: T?, element: (Parameter, T) -> Parameter) -> Parameter {
guard let value = value else {
return self
}
return self.modify(element(self, value as T))
}
}
extension Parameter: GlobalAttributes, GlobalEventAttributes, NameAttribute, ValueAttribute {
public func accessKey(_ value: Character) -> Parameter {
return mutate(accesskey: value)
}
public func autocapitalize(_ value: Values.Capitalization) -> Parameter {
return mutate(autocapitalize: value.rawValue)
}
public func autofocus() -> Parameter {
return mutate(autofocus: "autofocus")
}
public func `class`(_ value: String) -> Parameter {
return mutate(class: value)
}
public func isEditable(_ value: Bool) -> Parameter {
return mutate(contenteditable: value)
}
public func direction(_ value: Values.Direction) -> Parameter {
return mutate(dir: value.rawValue)
}
public func isDraggable(_ value: Bool) -> Parameter {
return mutate(draggable: value)
}
public func enterKeyHint(_ value: Values.Hint) -> Parameter {
return mutate(enterkeyhint: value.rawValue)
}
public func hidden() -> Parameter {
return mutate(hidden: "hidden")
}
public func hidden(_ condition: Bool) -> Parameter {
if condition {
return mutate(hidden: "hidden")
}
return self
}
@available(*, deprecated, message: "The inputmode attribute is actually an enumerated attribute. Use the inputMode(_: Mode) modifier instead.")
public func inputMode(_ value: String) -> Parameter {
return mutate(inputmode: value)
}
public func inputMode(_ value: Values.Mode) -> Parameter {
return mutate(inputmode: value.rawValue)
}
public func `is`(_ value: String) -> Parameter {
return mutate(is: value)
}
public func itemId(_ value: String) -> Parameter {
return mutate(itemid: value)
}
public func itemProperty(_ value: String) -> Parameter {
return mutate(itemprop: value)
}
public func itemReference(_ value: String) -> Parameter {
return mutate(itemref: value)
}
public func itemScope(_ value: String) -> Parameter {
return mutate(itemscope: value)
}
public func itemType(_ value: String) -> Parameter {
return mutate(itemtype: value)
}
public func id(_ value: String) -> Parameter {
return mutate(id: value)
}
public func language(_ value: Values.Language) -> Parameter {
return mutate(lang: value.rawValue)
}
public func nonce(_ value: String) -> Parameter {
return mutate(nonce: value)
}
public func role(_ value: Values.Role) -> Parameter {
return mutate(role: value.rawValue)
}
public func hasSpellCheck(_ value: Bool) -> Parameter {
return mutate(spellcheck: value)
}
public func style(_ value: String) -> Parameter {
return mutate(style: value)
}
public func tabIndex(_ value: Int) -> Parameter {
return mutate(tabindex: value)
}
@_disfavoredOverload
public func title(_ value: String) -> Parameter {
return mutate(title: value)
}
public func title(_ localizedKey: LocalizedStringKey, tableName: String? = nil) -> Parameter {
return mutate(title: LocalizedString(key: localizedKey, table: tableName))
}
public func title(verbatim value: String) -> Parameter {
return mutate(title: value)
}
public func translate(_ value: Values.Decision) -> Parameter {
return mutate(translate: value.rawValue)
}
public func inert() -> Parameter {
return mutate(inert: "inert")
}
public func inert(_ condition: Bool) -> Parameter {
if condition {
return mutate(inert: "inert")
}
return self
}
public func name(_ value: String) -> Parameter {
return mutate(name: value)
}
@_disfavoredOverload
public func value(_ value: String) -> Parameter {
return mutate(value: value)
}
public func value(_ localizedKey: LocalizedStringKey, tableName: String? = nil) -> Parameter {
return mutate(value: LocalizedString(key: localizedKey, table: tableName))
}
public func value(verbatim value: String) -> Parameter {
return mutate(value: value)
}
public func popover(_ value: Values.Popover.State) -> Parameter {
return mutate(popover: value.rawValue)
}
public func custom(key: String, value: Any) -> Parameter {
return mutate(key: key, value: value)
}
public func on(event: Events.Drag, _ value: String) -> Parameter {
return mutate(key: event.rawValue, value: value)
}
public func on(event: Events.Clipboard, _ value: String) -> Parameter {
return mutate(key: event.rawValue, value: value)
}
public func on(event: Events.Wheel, _ value: String) -> Parameter {
return mutate(key: event.rawValue, value: value)
}
public func on(event: Events.Keyboard, _ value: String) -> Parameter {
return mutate(key: event.rawValue, value: value)
}
public func on(event: Events.Mouse, _ value: String) -> Parameter {
return mutate(key: event.rawValue, value: value)
}
}