werewolf-ui 0.1.0-beta.2 → 0.1.0-beta.4

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 (210) hide show
  1. package/README.md +15 -5
  2. package/data/manifest.json +16077 -6044
  3. package/data/native/android/WerewolfAccordion.kt +256 -0
  4. package/data/native/android/WerewolfAlert.kt +4 -4
  5. package/data/native/android/WerewolfAlertDialog.kt +156 -0
  6. package/data/native/android/WerewolfAttachmentPreview.kt +273 -0
  7. package/data/native/android/WerewolfAvatar.kt +393 -0
  8. package/data/native/android/WerewolfAvatarStack.kt +178 -0
  9. package/data/native/android/WerewolfBackdropBlur.kt +89 -0
  10. package/data/native/android/WerewolfBadge.kt +71 -3
  11. package/data/native/android/WerewolfBottomNav.kt +354 -0
  12. package/data/native/android/WerewolfBreadcrumb.kt +22 -0
  13. package/data/native/android/WerewolfBreadcrumbRuntime.kt +177 -0
  14. package/data/native/android/WerewolfButton.kt +12 -3
  15. package/data/native/android/WerewolfButtonGroup.kt +54 -0
  16. package/data/native/android/WerewolfCalendar.kt +85 -0
  17. package/data/native/android/WerewolfCalendarGrid.kt +412 -0
  18. package/data/native/android/WerewolfCalendarMath.kt +252 -0
  19. package/data/native/android/WerewolfCard.kt +3 -3
  20. package/data/native/android/WerewolfCarousel.kt +177 -0
  21. package/data/native/android/WerewolfChart.kt +200 -0
  22. package/data/native/android/WerewolfChartAccessibility.kt +69 -0
  23. package/data/native/android/WerewolfChartFormat.kt +18 -0
  24. package/data/native/android/WerewolfChartGeometry.kt +397 -0
  25. package/data/native/android/WerewolfChartInteraction.kt +106 -0
  26. package/data/native/android/WerewolfChartModel.kt +238 -0
  27. package/data/native/android/WerewolfChartPalette.kt +34 -0
  28. package/data/native/android/WerewolfChatRuntime.kt +242 -0
  29. package/data/native/android/WerewolfCheckbox.kt +387 -0
  30. package/data/native/android/WerewolfChecklist.kt +249 -0
  31. package/data/native/android/WerewolfCodeBlock.kt +353 -0
  32. package/data/native/android/WerewolfColorPicker.kt +84 -0
  33. package/data/native/android/WerewolfColorPickerRuntime.kt +592 -0
  34. package/data/native/android/WerewolfCombobox.kt +371 -0
  35. package/data/native/android/WerewolfComposer.kt +300 -0
  36. package/data/native/android/WerewolfContextMenu.kt +26 -0
  37. package/data/native/android/WerewolfContextMenuRuntime.kt +116 -0
  38. package/data/native/android/WerewolfConversationList.kt +182 -0
  39. package/data/native/android/WerewolfCounter.kt +640 -0
  40. package/data/native/android/WerewolfDataTrend.kt +245 -0
  41. package/data/native/android/WerewolfDatePicker.kt +334 -0
  42. package/data/native/android/WerewolfDialog.kt +131 -0
  43. package/data/native/android/WerewolfDropdownMenu.kt +30 -0
  44. package/data/native/android/WerewolfEmojiData.kt +594 -0
  45. package/data/native/android/WerewolfEmojiPicker.kt +67 -0
  46. package/data/native/android/WerewolfEmojiPickerRuntime.kt +627 -0
  47. package/data/native/android/WerewolfEmptyState.kt +1 -1
  48. package/data/native/android/WerewolfField.kt +66 -0
  49. package/data/native/android/WerewolfGroupAvatar.kt +126 -0
  50. package/data/native/android/WerewolfIcons.kt +448 -1
  51. package/data/native/android/WerewolfImage.kt +82 -0
  52. package/data/native/android/WerewolfInput.kt +3 -3
  53. package/data/native/android/WerewolfKbd.kt +3 -3
  54. package/data/native/android/WerewolfLabel.kt +2 -2
  55. package/data/native/android/WerewolfLayers.kt +1173 -0
  56. package/data/native/android/WerewolfLink.kt +163 -0
  57. package/data/native/android/WerewolfList.kt +504 -0
  58. package/data/native/android/WerewolfListRuntime.kt +383 -0
  59. package/data/native/android/WerewolfMessageActions.kt +86 -0
  60. package/data/native/android/WerewolfMessageActionsRuntime.kt +568 -0
  61. package/data/native/android/WerewolfMessageBubble.kt +402 -0
  62. package/data/native/android/WerewolfMessageList.kt +133 -0
  63. package/data/native/android/WerewolfMetadata.kt +180 -0
  64. package/data/native/android/WerewolfMeter.kt +189 -0
  65. package/data/native/android/WerewolfModifiers.kt +309 -4
  66. package/data/native/android/WerewolfNumberInput.kt +665 -0
  67. package/data/native/android/WerewolfOtpInput.kt +246 -0
  68. package/data/native/android/WerewolfPageRuntime.kt +83 -0
  69. package/data/native/android/WerewolfPagination.kt +29 -0
  70. package/data/native/android/WerewolfPaginationRuntime.kt +245 -0
  71. package/data/native/android/WerewolfPlot.kt +1129 -0
  72. package/data/native/android/WerewolfPopover.kt +92 -0
  73. package/data/native/android/WerewolfProgress.kt +281 -0
  74. package/data/native/android/WerewolfRadioGroup.kt +382 -0
  75. package/data/native/android/WerewolfRangeMath.kt +80 -0
  76. package/data/native/android/WerewolfRating.kt +44 -0
  77. package/data/native/android/WerewolfRatingRuntime.kt +113 -0
  78. package/data/native/android/WerewolfSelect.kt +330 -0
  79. package/data/native/android/WerewolfSeparator.kt +1 -1
  80. package/data/native/android/WerewolfSheet.kt +204 -0
  81. package/data/native/android/WerewolfSkeleton.kt +4 -4
  82. package/data/native/android/WerewolfSlider.kt +214 -0
  83. package/data/native/android/WerewolfSliderRuntime.kt +307 -0
  84. package/data/native/android/WerewolfSortableList.kt +34 -0
  85. package/data/native/android/WerewolfSortableListRuntime.kt +232 -0
  86. package/data/native/android/WerewolfSpinner.kt +1 -1
  87. package/data/native/android/WerewolfStepper.kt +690 -0
  88. package/data/native/android/WerewolfSwitch.kt +9 -57
  89. package/data/native/android/WerewolfTable.kt +134 -0
  90. package/data/native/android/WerewolfTableRuntime.kt +55 -0
  91. package/data/native/android/WerewolfTabs.kt +591 -0
  92. package/data/native/android/WerewolfTextarea.kt +329 -0
  93. package/data/native/android/WerewolfTheme.kt +17 -3
  94. package/data/native/android/WerewolfTimeColumns.kt +333 -0
  95. package/data/native/android/WerewolfTimePicker.kt +319 -0
  96. package/data/native/android/WerewolfTimeline.kt +382 -0
  97. package/data/native/android/WerewolfToast.kt +226 -0
  98. package/data/native/android/WerewolfToaster.kt +281 -0
  99. package/data/native/android/WerewolfToggle.kt +395 -0
  100. package/data/native/android/WerewolfToggleGroup.kt +427 -0
  101. package/data/native/android/WerewolfToken.kt +1 -1
  102. package/data/native/android/WerewolfTokenizer.kt +54 -0
  103. package/data/native/android/WerewolfTokenizerRuntime.kt +221 -0
  104. package/data/native/android/WerewolfTooltip.kt +78 -0
  105. package/data/native/ios/WerewolfAccordion.swift +340 -0
  106. package/data/native/ios/WerewolfAlert.swift +3 -3
  107. package/data/native/ios/WerewolfAlertDialog.swift +187 -0
  108. package/data/native/ios/WerewolfAttachmentPreview.swift +323 -0
  109. package/data/native/ios/WerewolfAvatar.swift +552 -0
  110. package/data/native/ios/WerewolfAvatarStack.swift +214 -0
  111. package/data/native/ios/WerewolfBadge.swift +74 -22
  112. package/data/native/ios/WerewolfBottomNav.swift +463 -0
  113. package/data/native/ios/WerewolfBreadcrumb.swift +22 -0
  114. package/data/native/ios/WerewolfBreadcrumbRuntime.swift +96 -0
  115. package/data/native/ios/WerewolfButton.swift +22 -5
  116. package/data/native/ios/WerewolfButtonGroup.swift +62 -0
  117. package/data/native/ios/WerewolfCalendar.swift +98 -0
  118. package/data/native/ios/WerewolfCalendarGrid.swift +453 -0
  119. package/data/native/ios/WerewolfCalendarMath.swift +321 -0
  120. package/data/native/ios/WerewolfCard.swift +2 -2
  121. package/data/native/ios/WerewolfCarousel.swift +168 -0
  122. package/data/native/ios/WerewolfChart.swift +206 -0
  123. package/data/native/ios/WerewolfChartAccessibility.swift +59 -0
  124. package/data/native/ios/WerewolfChartFormat.swift +14 -0
  125. package/data/native/ios/WerewolfChartGeometry.swift +479 -0
  126. package/data/native/ios/WerewolfChartInteraction.swift +113 -0
  127. package/data/native/ios/WerewolfChartModel.swift +337 -0
  128. package/data/native/ios/WerewolfChartPalette.swift +37 -0
  129. package/data/native/ios/WerewolfChatRuntime.swift +216 -0
  130. package/data/native/ios/WerewolfCheckbox.swift +623 -0
  131. package/data/native/ios/WerewolfChecklist.swift +276 -0
  132. package/data/native/ios/WerewolfCodeBlock.swift +405 -0
  133. package/data/native/ios/WerewolfColorPicker.swift +136 -0
  134. package/data/native/ios/WerewolfColorPickerRuntime.swift +469 -0
  135. package/data/native/ios/WerewolfCombobox.swift +469 -0
  136. package/data/native/ios/WerewolfComposer.swift +269 -0
  137. package/data/native/ios/WerewolfContextMenu.swift +21 -0
  138. package/data/native/ios/WerewolfConversationList.swift +141 -0
  139. package/data/native/ios/WerewolfCounter.swift +770 -0
  140. package/data/native/ios/WerewolfDataTrend.swift +292 -0
  141. package/data/native/ios/WerewolfDatePicker.swift +388 -0
  142. package/data/native/ios/WerewolfDialog.swift +172 -0
  143. package/data/native/ios/WerewolfDropdownMenu.swift +35 -0
  144. package/data/native/ios/WerewolfEmojiData.swift +600 -0
  145. package/data/native/ios/WerewolfEmojiPicker.swift +74 -0
  146. package/data/native/ios/WerewolfEmojiPickerRuntime.swift +361 -0
  147. package/data/native/ios/WerewolfEmptyState.swift +1 -1
  148. package/data/native/ios/WerewolfField.swift +103 -0
  149. package/data/native/ios/WerewolfGroupAvatar.swift +165 -0
  150. package/data/native/ios/WerewolfIcons.swift +85 -1
  151. package/data/native/ios/WerewolfImage.swift +118 -0
  152. package/data/native/ios/WerewolfInput.swift +5 -3
  153. package/data/native/ios/WerewolfKbd.swift +2 -2
  154. package/data/native/ios/WerewolfLabel.swift +2 -2
  155. package/data/native/ios/WerewolfLayers.swift +929 -0
  156. package/data/native/ios/WerewolfLink.swift +188 -0
  157. package/data/native/ios/WerewolfList.swift +603 -0
  158. package/data/native/ios/WerewolfListRuntime.swift +414 -0
  159. package/data/native/ios/WerewolfMessageActions.swift +99 -0
  160. package/data/native/ios/WerewolfMessageActionsRuntime.swift +218 -0
  161. package/data/native/ios/WerewolfMessageBubble.swift +474 -0
  162. package/data/native/ios/WerewolfMessageList.swift +123 -0
  163. package/data/native/ios/WerewolfMetadata.swift +205 -0
  164. package/data/native/ios/WerewolfMeter.swift +186 -0
  165. package/data/native/ios/WerewolfModifiers.swift +205 -1
  166. package/data/native/ios/WerewolfNumberInput.swift +808 -0
  167. package/data/native/ios/WerewolfOtpInput.swift +326 -0
  168. package/data/native/ios/WerewolfPageRuntime.swift +98 -0
  169. package/data/native/ios/WerewolfPagination.swift +34 -0
  170. package/data/native/ios/WerewolfPaginationRuntime.swift +165 -0
  171. package/data/native/ios/WerewolfPlot.swift +1249 -0
  172. package/data/native/ios/WerewolfPopover.swift +132 -0
  173. package/data/native/ios/WerewolfProgress.swift +338 -0
  174. package/data/native/ios/WerewolfRadioGroup.swift +485 -0
  175. package/data/native/ios/WerewolfRangeMath.swift +87 -0
  176. package/data/native/ios/WerewolfRating.swift +52 -0
  177. package/data/native/ios/WerewolfRatingRuntime.swift +100 -0
  178. package/data/native/ios/WerewolfSelect.swift +420 -0
  179. package/data/native/ios/WerewolfSeparator.swift +1 -1
  180. package/data/native/ios/WerewolfSheet.swift +208 -0
  181. package/data/native/ios/WerewolfSkeleton.swift +3 -3
  182. package/data/native/ios/WerewolfSlider.swift +330 -0
  183. package/data/native/ios/WerewolfSliderRuntime.swift +260 -0
  184. package/data/native/ios/WerewolfSortableList.swift +40 -0
  185. package/data/native/ios/WerewolfSortableListRuntime.swift +192 -0
  186. package/data/native/ios/WerewolfSpinner.swift +1 -1
  187. package/data/native/ios/WerewolfStepper.swift +802 -0
  188. package/data/native/ios/WerewolfSwitch.swift +21 -78
  189. package/data/native/ios/WerewolfTable.swift +185 -0
  190. package/data/native/ios/WerewolfTableRuntime.swift +47 -0
  191. package/data/native/ios/WerewolfTabs.swift +758 -0
  192. package/data/native/ios/WerewolfTextarea.swift +405 -0
  193. package/data/native/ios/WerewolfTheme.swift +17 -2
  194. package/data/native/ios/WerewolfTimeColumns.swift +134 -0
  195. package/data/native/ios/WerewolfTimePicker.swift +365 -0
  196. package/data/native/ios/WerewolfTimeline.swift +526 -0
  197. package/data/native/ios/WerewolfToast.swift +280 -0
  198. package/data/native/ios/WerewolfToaster.swift +269 -0
  199. package/data/native/ios/WerewolfToggle.swift +647 -0
  200. package/data/native/ios/WerewolfToggleGroup.swift +511 -0
  201. package/data/native/ios/WerewolfToken.swift +1 -1
  202. package/data/native/ios/WerewolfTokenizer.swift +77 -0
  203. package/data/native/ios/WerewolfTokenizerRuntime.swift +214 -0
  204. package/data/native/ios/WerewolfTooltip.swift +106 -0
  205. package/dist/cli.mjs +8573 -672
  206. package/dist/core.mjs +8279 -566
  207. package/dist/lint.mjs +205 -21
  208. package/dist/paths.mjs +2 -1
  209. package/dist/project.mjs +56 -10
  210. package/package.json +1 -1
@@ -1,8 +1,7 @@
1
- // Generated file, must not be edited by hand. Source: components/switch.spec.json (werewolf-ui 0.1.0-beta.2).
1
+ // Generated file, must not be edited by hand. Source: components/switch.spec.json (werewolf-ui 0.1.0-beta.4).
2
2
  import SwiftUI
3
3
 
4
4
  public enum WerewolfSwitchSize {
5
- case sm
6
5
  case md
7
6
  case lg
8
7
  case xl
@@ -25,7 +24,7 @@ public struct WerewolfSwitch: View {
25
24
  invalid: Bool = false,
26
25
  required: Bool = false,
27
26
  requiredText: AnyView? = nil,
28
- size: WerewolfSwitchSize = .md
27
+ size: WerewolfSwitchSize = .lg
29
28
  ) {
30
29
  self.isOn = isOn
31
30
  self.checked = false
@@ -45,7 +44,7 @@ public struct WerewolfSwitch: View {
45
44
  invalid: Bool = false,
46
45
  required: Bool = false,
47
46
  requiredText: AnyView? = nil,
48
- size: WerewolfSwitchSize = .md,
47
+ size: WerewolfSwitchSize = .lg,
49
48
  description: AnyView? = nil
50
49
  ) {
51
50
  self.isOn = isOn
@@ -67,7 +66,7 @@ public struct WerewolfSwitch: View {
67
66
  invalid: Bool = false,
68
67
  required: Bool = false,
69
68
  requiredText: AnyView? = nil,
70
- size: WerewolfSwitchSize = .md
69
+ size: WerewolfSwitchSize = .lg
71
70
  ) {
72
71
  self.isOn = isOn
73
72
  self.checked = false
@@ -87,7 +86,7 @@ public struct WerewolfSwitch: View {
87
86
  invalid: Bool = false,
88
87
  required: Bool = false,
89
88
  requiredText: AnyView? = nil,
90
- size: WerewolfSwitchSize = .md
89
+ size: WerewolfSwitchSize = .lg
91
90
  ) {
92
91
  self.isOn = nil
93
92
  self.checked = checked
@@ -108,7 +107,7 @@ public struct WerewolfSwitch: View {
108
107
  invalid: Bool = false,
109
108
  required: Bool = false,
110
109
  requiredText: AnyView? = nil,
111
- size: WerewolfSwitchSize = .md,
110
+ size: WerewolfSwitchSize = .lg,
112
111
  description: AnyView? = nil
113
112
  ) {
114
113
  self.isOn = nil
@@ -131,7 +130,7 @@ public struct WerewolfSwitch: View {
131
130
  invalid: Bool = false,
132
131
  required: Bool = false,
133
132
  requiredText: AnyView? = nil,
134
- size: WerewolfSwitchSize = .md
133
+ size: WerewolfSwitchSize = .lg
135
134
  ) {
136
135
  self.isOn = nil
137
136
  self.checked = checked
@@ -150,7 +149,7 @@ public struct WerewolfSwitch: View {
150
149
  invalid: Bool = false,
151
150
  required: Bool = false,
152
151
  requiredText: AnyView? = nil,
153
- size: WerewolfSwitchSize = .md
152
+ size: WerewolfSwitchSize = .lg
154
153
  ) {
155
154
  self.isOn = nil
156
155
  self.checked = false
@@ -170,7 +169,7 @@ public struct WerewolfSwitch: View {
170
169
  invalid: Bool = false,
171
170
  required: Bool = false,
172
171
  requiredText: AnyView? = nil,
173
- size: WerewolfSwitchSize = .md,
172
+ size: WerewolfSwitchSize = .lg,
174
173
  description: AnyView? = nil
175
174
  ) {
176
175
  self.isOn = nil
@@ -191,7 +190,7 @@ public struct WerewolfSwitch: View {
191
190
  invalid: Bool = false,
192
191
  required: Bool = false,
193
192
  requiredText: AnyView? = nil,
194
- size: WerewolfSwitchSize = .md,
193
+ size: WerewolfSwitchSize = .lg,
195
194
  description: AnyView? = nil
196
195
  ) {
197
196
  self.isOn = nil
@@ -213,7 +212,7 @@ public struct WerewolfSwitch: View {
213
212
  invalid: Bool = false,
214
213
  required: Bool = false,
215
214
  requiredText: AnyView? = nil,
216
- size: WerewolfSwitchSize = .md
215
+ size: WerewolfSwitchSize = .lg
217
216
  ) {
218
217
  self.isOn = nil
219
218
  self.checked = false
@@ -234,7 +233,7 @@ public struct WerewolfSwitch: View {
234
233
  invalid: Bool = false,
235
234
  required: Bool = false,
236
235
  requiredText: AnyView? = nil,
237
- size: WerewolfSwitchSize = .md
236
+ size: WerewolfSwitchSize = .lg
238
237
  ) {
239
238
  self.isOn = nil
240
239
  self.checked = false
@@ -310,7 +309,7 @@ private struct WerewolfSwitchRendering: View {
310
309
  .werewolfFocusRing(rootOutlineColor != nil, in: rootShape)
311
310
  .animation(rootTransitionTimingFunction.flatMap { easing in rootTransitionDuration.flatMap { motion.animation(easing, duration: $0) } }, value: stateKey)
312
311
  if let label {
313
- VStack(alignment: .center) {
312
+ VStack(alignment: .leading) {
314
313
  label
315
314
  .applying(labelFontSize) { $0.werewolfFont(.sans, size: $1, weight: .regular) }
316
315
  if let description {
@@ -344,11 +343,11 @@ private struct WerewolfSwitchRendering: View {
344
343
  }
345
344
  // werewolf:state=checked+pressed
346
345
  if checked && isPressed {
347
- return t.colorGray
346
+ return t.colorBackgroundGray
348
347
  }
349
348
  // werewolf:state=checked+hover
350
349
  if checked && isHovered {
351
- return t.colorGray
350
+ return t.colorBackgroundGray
352
351
  }
353
352
  // werewolf:state=disabled
354
353
  if !isEnabled {
@@ -359,7 +358,7 @@ private struct WerewolfSwitchRendering: View {
359
358
  return t.colorAccent
360
359
  }
361
360
  // werewolf:state=default
362
- return t.colorGray
361
+ return t.colorBackgroundGray
363
362
  }
364
363
 
365
364
  private var rootBorderColor: Color? {
@@ -399,9 +398,6 @@ private struct WerewolfSwitchRendering: View {
399
398
  private var rootHeight: CGFloat? {
400
399
  // werewolf:property=root.height
401
400
  switch size {
402
- // werewolf:size=sm
403
- case .sm:
404
- return t.sizeElementSm / 2 + 2 * t.borderWidth
405
401
  // werewolf:size=md
406
402
  case .md:
407
403
  return t.sizeElementMd / 2 + 2 * t.borderWidth
@@ -493,9 +489,6 @@ private struct WerewolfSwitchRendering: View {
493
489
  private var rootWidth: CGFloat? {
494
490
  // werewolf:property=root.width
495
491
  switch size {
496
- // werewolf:size=sm
497
- case .sm:
498
- return t.sizeElementSm
499
492
  // werewolf:size=md
500
493
  case .md:
501
494
  return t.sizeElementMd
@@ -521,9 +514,6 @@ private struct WerewolfSwitchRendering: View {
521
514
  private var thumbHeight: CGFloat? {
522
515
  // werewolf:property=thumb.height
523
516
  switch size {
524
- // werewolf:size=sm
525
- case .sm:
526
- return t.sizeElementSm / 2 - t.spacingXs
527
517
  // werewolf:size=md
528
518
  case .md:
529
519
  return t.sizeElementMd / 2 - t.spacingXs
@@ -539,26 +529,6 @@ private struct WerewolfSwitchRendering: View {
539
529
  private var thumbOffsetInlineStart: CGFloat? {
540
530
  // werewolf:property=thumb.offset-inline-start
541
531
  switch size {
542
- // werewolf:size=sm
543
- case .sm:
544
- // werewolf:state=checked+disabled
545
- if checked && !isEnabled {
546
- return t.spacingXs / 2
547
- }
548
- // werewolf:state=checked+pressed
549
- if checked && isPressed {
550
- return t.spacingXs / 2
551
- }
552
- // werewolf:state=checked+hover
553
- if checked && isHovered {
554
- return t.spacingXs / 2
555
- }
556
- // werewolf:state=checked
557
- if checked {
558
- return t.sizeElementSm / 2 - 2 * t.borderWidth + t.spacingXs / 2
559
- }
560
- // werewolf:state=default
561
- return t.spacingXs / 2
562
532
  // werewolf:size=md
563
533
  case .md:
564
534
  // werewolf:state=checked+disabled
@@ -625,9 +595,6 @@ private struct WerewolfSwitchRendering: View {
625
595
  private var thumbWidth: CGFloat? {
626
596
  // werewolf:property=thumb.width
627
597
  switch size {
628
- // werewolf:size=sm
629
- case .sm:
630
- return t.sizeElementSm / 2 - t.spacingXs
631
598
  // werewolf:size=md
632
599
  case .md:
633
600
  return t.sizeElementMd / 2 - t.spacingXs
@@ -642,20 +609,7 @@ private struct WerewolfSwitchRendering: View {
642
609
 
643
610
  private var labelFontSize: CGFloat? {
644
611
  // werewolf:property=label.font-size
645
- switch size {
646
- // werewolf:size=sm
647
- case .sm:
648
- return t.fontSizeXs
649
- // werewolf:size=md
650
- case .md:
651
- return t.fontSizeSm
652
- // werewolf:size=lg
653
- case .lg:
654
- return t.fontSizeSm
655
- // werewolf:size=xl
656
- case .xl:
657
- return t.fontSizeSm
658
- }
612
+ return t.fontSizeSm
659
613
  }
660
614
 
661
615
  private var descriptionColor: Color? {
@@ -670,20 +624,7 @@ private struct WerewolfSwitchRendering: View {
670
624
 
671
625
  private var descriptionFontSize: CGFloat? {
672
626
  // werewolf:property=description.font-size
673
- switch size {
674
- // werewolf:size=sm
675
- case .sm:
676
- return t.fontSizeXs
677
- // werewolf:size=md
678
- case .md:
679
- return t.fontSizeSm
680
- // werewolf:size=lg
681
- case .lg:
682
- return t.fontSizeSm
683
- // werewolf:size=xl
684
- case .xl:
685
- return t.fontSizeSm
686
- }
627
+ return t.fontSizeSm
687
628
  }
688
629
 
689
630
  private var rootShape: some InsettableShape {
@@ -712,7 +653,9 @@ private extension View {
712
653
  }
713
654
 
714
655
  func applyingShadows(_ layers: [WerewolfShadowLayer]) -> some View {
715
- layers.filter { !$0.inset }.reduce(AnyView(self)) { view, layer in
656
+ let outer = layers.filter { !$0.inset }
657
+ guard !outer.isEmpty else { return AnyView(self) }
658
+ return outer.reduce(AnyView(self.compositingGroup())) { view, layer in
716
659
  AnyView(view.shadow(color: layer.color, radius: layer.blur / 2, x: layer.x, y: layer.y))
717
660
  }
718
661
  }
@@ -0,0 +1,185 @@
1
+ // Generated file, must not be edited by hand. Source: components/table.spec.json (werewolf-ui 0.1.0-beta.4).
2
+ import SwiftUI
3
+
4
+ public struct WerewolfTable<Content: View, EmptyContent: View, SelectionBarContent: View>: View {
5
+ @Environment(\.werewolfTheme) private var t
6
+ @Environment(\.werewolfBottomInset) private var bottomInset
7
+ @State private var barSize: CGSize = .zero
8
+
9
+ private let label: String
10
+ private let pending: Bool
11
+ private let pendingLabel: String
12
+ private let isEmpty: Bool
13
+ private let selectionMode: Bool
14
+ private let empty: EmptyContent
15
+ private let selectionBar: SelectionBarContent?
16
+ private let content: Content
17
+
18
+ public init(
19
+ label: String,
20
+ pending: Bool = false,
21
+ pendingLabel: String = "Loading",
22
+ isEmpty: Bool = false,
23
+ selectionMode: Bool = false,
24
+ @ViewBuilder empty: () -> EmptyContent,
25
+ @ViewBuilder selectionBar: () -> SelectionBarContent,
26
+ @ViewBuilder content: () -> Content
27
+ ) {
28
+ self.label = label
29
+ self.pending = pending
30
+ self.pendingLabel = pendingLabel
31
+ self.isEmpty = isEmpty
32
+ self.selectionMode = selectionMode
33
+ self.empty = empty()
34
+ self.selectionBar = selectionBar()
35
+ self.content = content()
36
+ }
37
+
38
+ private var showsBar: Bool { selectionMode && selectionBar != nil }
39
+
40
+ public var body: some View {
41
+ ZStack(alignment: .bottom) {
42
+ ScrollView {
43
+ VStack(spacing: 0) {
44
+ if isEmpty {
45
+ empty
46
+ .applying(emptyFontSize) { $0.werewolfFont(.sans, size: $1, weight: .regular) }
47
+ .applying(emptyColor) { $0.foregroundStyle($1) }
48
+ .applying(emptyPaddingInline) { $0.padding(.horizontal, $1) }
49
+ .applying(emptyPaddingBlock) { $0.padding(.vertical, $1) }
50
+ .frame(maxWidth: .infinity)
51
+ } else {
52
+ content
53
+ }
54
+ }
55
+ .padding(.bottom, showsBar ? barSize.height + bottomInset + (selectionBarGap ?? 0) + (selectionBarGap ?? 0) : 0)
56
+ .werewolfPending(pending, label: pendingLabel)
57
+ }
58
+ if selectionMode, let selectionBar {
59
+ HStack(alignment: .center, spacing: selectionBarGap ?? 0) {
60
+ selectionBar
61
+ }
62
+ .applying(selectionBarPaddingInline) { $0.padding(.horizontal, $1) }
63
+ .applying(selectionBarPaddingBlock) { $0.padding(.vertical, $1) }
64
+ .frame(maxWidth: .infinity)
65
+ .background(selectionBarShape.fill(selectionBarBackgroundColor ?? .clear))
66
+ .overlay(selectionBarShape.strokeBorder(selectionBarBorderColor ?? .clear, lineWidth: selectionBarBorderWidth ?? 0))
67
+ .werewolfMeasure($barSize)
68
+ .padding(.horizontal, (selectionBarGap ?? 0))
69
+ .padding(.bottom, bottomInset + (selectionBarGap ?? 0))
70
+ .transition(.move(edge: .bottom).combined(with: .opacity))
71
+ }
72
+ }
73
+ .applying(rootFontSize) { $0.werewolfFont(.sans, size: $1, weight: .regular) }
74
+ .applying(rootColor) { $0.foregroundStyle($1) }
75
+ .werewolfBarArrival(selectionMode)
76
+ .accessibilityElement(children: .contain)
77
+ .accessibilityLabel(label)
78
+ }
79
+
80
+ private var rootColor: Color? {
81
+ // werewolf:property=root.color
82
+ return t.colorTextPrimary
83
+ }
84
+
85
+ private var rootFontFamily: String? {
86
+ // werewolf:property=root.font-family
87
+ return t.fontFamilySans
88
+ }
89
+
90
+ private var rootFontSize: CGFloat? {
91
+ // werewolf:property=root.font-size
92
+ return t.fontSizeSm
93
+ }
94
+
95
+ private var emptyColor: Color? {
96
+ // werewolf:property=empty.color
97
+ return t.colorTextSecondary
98
+ }
99
+
100
+ private var emptyFontSize: CGFloat? {
101
+ // werewolf:property=empty.font-size
102
+ return t.fontSizeSm
103
+ }
104
+
105
+ private var emptyPaddingBlock: CGFloat? {
106
+ // werewolf:property=empty.padding-block
107
+ return t.spacing2xl
108
+ }
109
+
110
+ private var emptyPaddingInline: CGFloat? {
111
+ // werewolf:property=empty.padding-inline
112
+ return t.spacingMd
113
+ }
114
+
115
+ private var selectionBarBackgroundColor: Color? {
116
+ // werewolf:property=selectionBar.background-color
117
+ return t.colorBackgroundSurface
118
+ }
119
+
120
+ private var selectionBarBorderColor: Color? {
121
+ // werewolf:property=selectionBar.border-color
122
+ return t.colorBorder
123
+ }
124
+
125
+ private var selectionBarBorderRadius: CGFloat? {
126
+ // werewolf:property=selectionBar.border-radius
127
+ return t.radiusContainer
128
+ }
129
+
130
+ private var selectionBarBorderWidth: CGFloat? {
131
+ // werewolf:property=selectionBar.border-width
132
+ return t.borderWidth
133
+ }
134
+
135
+ private var selectionBarGap: CGFloat? {
136
+ // werewolf:property=selectionBar.gap
137
+ return t.spacingMd
138
+ }
139
+
140
+ private var selectionBarPaddingBlock: CGFloat? {
141
+ // werewolf:property=selectionBar.padding-block
142
+ return t.spacingMd
143
+ }
144
+
145
+ private var selectionBarPaddingInline: CGFloat? {
146
+ // werewolf:property=selectionBar.padding-inline
147
+ return t.spacingLg
148
+ }
149
+
150
+ private var selectionBarShape: some InsettableShape {
151
+ RoundedRectangle(cornerRadius: selectionBarBorderRadius ?? 0, theme: t)
152
+ }
153
+ }
154
+
155
+ extension WerewolfTable where SelectionBarContent == EmptyView {
156
+ public init(
157
+ label: String,
158
+ pending: Bool = false,
159
+ pendingLabel: String = "Loading",
160
+ isEmpty: Bool = false,
161
+ selectionMode: Bool = false,
162
+ @ViewBuilder empty: () -> EmptyContent,
163
+ @ViewBuilder content: () -> Content
164
+ ) {
165
+ self.label = label
166
+ self.pending = pending
167
+ self.pendingLabel = pendingLabel
168
+ self.isEmpty = isEmpty
169
+ self.selectionMode = selectionMode
170
+ self.empty = empty()
171
+ self.selectionBar = nil
172
+ self.content = content()
173
+ }
174
+ }
175
+
176
+ private extension View {
177
+ @ViewBuilder
178
+ func applying<Value, Result: View>(_ value: Value?, _ transform: (Self, Value) -> Result) -> some View {
179
+ if let value {
180
+ transform(self, value)
181
+ } else {
182
+ self
183
+ }
184
+ }
185
+ }
@@ -0,0 +1,47 @@
1
+ // Werewolf native runtime. Hand-written, independent of the seed.
2
+ import SwiftUI
3
+ #if canImport(UIKit)
4
+ import UIKit
5
+ #endif
6
+
7
+ private struct WerewolfPendingModifier: ViewModifier {
8
+ @Environment(\.werewolfTheme) private var theme
9
+ private let motion = WerewolfMotion()
10
+ let pending: Bool
11
+ let label: String
12
+
13
+ func body(content: Content) -> some View {
14
+ content
15
+ .opacity(pending ? theme.opacityPending : 1)
16
+ .animation(motion.animation(theme.easeStandard, duration: theme.durationMedium), value: pending)
17
+ .accessibilityValue(pending ? label : "")
18
+ .onChange(of: pending) { now in
19
+ guard now else { return }
20
+ #if canImport(UIKit)
21
+ UIAccessibility.post(notification: .announcement, argument: label)
22
+ #endif
23
+ }
24
+ }
25
+ }
26
+
27
+ extension View {
28
+ public func werewolfPending(_ pending: Bool, label: String) -> some View {
29
+ modifier(WerewolfPendingModifier(pending: pending, label: label))
30
+ }
31
+ }
32
+
33
+ private struct WerewolfBarArrivalModifier: ViewModifier {
34
+ @Environment(\.werewolfTheme) private var theme
35
+ private let motion = WerewolfMotion()
36
+ let shown: Bool
37
+
38
+ func body(content: Content) -> some View {
39
+ content.animation(motion.animation(theme.easeEnter, duration: theme.durationMedium), value: shown)
40
+ }
41
+ }
42
+
43
+ extension View {
44
+ public func werewolfBarArrival(_ shown: Bool) -> some View {
45
+ modifier(WerewolfBarArrivalModifier(shown: shown))
46
+ }
47
+ }