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.
- package/README.md +15 -5
- package/data/manifest.json +16077 -6044
- package/data/native/android/WerewolfAccordion.kt +256 -0
- package/data/native/android/WerewolfAlert.kt +4 -4
- package/data/native/android/WerewolfAlertDialog.kt +156 -0
- package/data/native/android/WerewolfAttachmentPreview.kt +273 -0
- package/data/native/android/WerewolfAvatar.kt +393 -0
- package/data/native/android/WerewolfAvatarStack.kt +178 -0
- package/data/native/android/WerewolfBackdropBlur.kt +89 -0
- package/data/native/android/WerewolfBadge.kt +71 -3
- package/data/native/android/WerewolfBottomNav.kt +354 -0
- package/data/native/android/WerewolfBreadcrumb.kt +22 -0
- package/data/native/android/WerewolfBreadcrumbRuntime.kt +177 -0
- package/data/native/android/WerewolfButton.kt +12 -3
- package/data/native/android/WerewolfButtonGroup.kt +54 -0
- package/data/native/android/WerewolfCalendar.kt +85 -0
- package/data/native/android/WerewolfCalendarGrid.kt +412 -0
- package/data/native/android/WerewolfCalendarMath.kt +252 -0
- package/data/native/android/WerewolfCard.kt +3 -3
- package/data/native/android/WerewolfCarousel.kt +177 -0
- package/data/native/android/WerewolfChart.kt +200 -0
- package/data/native/android/WerewolfChartAccessibility.kt +69 -0
- package/data/native/android/WerewolfChartFormat.kt +18 -0
- package/data/native/android/WerewolfChartGeometry.kt +397 -0
- package/data/native/android/WerewolfChartInteraction.kt +106 -0
- package/data/native/android/WerewolfChartModel.kt +238 -0
- package/data/native/android/WerewolfChartPalette.kt +34 -0
- package/data/native/android/WerewolfChatRuntime.kt +242 -0
- package/data/native/android/WerewolfCheckbox.kt +387 -0
- package/data/native/android/WerewolfChecklist.kt +249 -0
- package/data/native/android/WerewolfCodeBlock.kt +353 -0
- package/data/native/android/WerewolfColorPicker.kt +84 -0
- package/data/native/android/WerewolfColorPickerRuntime.kt +592 -0
- package/data/native/android/WerewolfCombobox.kt +371 -0
- package/data/native/android/WerewolfComposer.kt +300 -0
- package/data/native/android/WerewolfContextMenu.kt +26 -0
- package/data/native/android/WerewolfContextMenuRuntime.kt +116 -0
- package/data/native/android/WerewolfConversationList.kt +182 -0
- package/data/native/android/WerewolfCounter.kt +640 -0
- package/data/native/android/WerewolfDataTrend.kt +245 -0
- package/data/native/android/WerewolfDatePicker.kt +334 -0
- package/data/native/android/WerewolfDialog.kt +131 -0
- package/data/native/android/WerewolfDropdownMenu.kt +30 -0
- package/data/native/android/WerewolfEmojiData.kt +594 -0
- package/data/native/android/WerewolfEmojiPicker.kt +67 -0
- package/data/native/android/WerewolfEmojiPickerRuntime.kt +627 -0
- package/data/native/android/WerewolfEmptyState.kt +1 -1
- package/data/native/android/WerewolfField.kt +66 -0
- package/data/native/android/WerewolfGroupAvatar.kt +126 -0
- package/data/native/android/WerewolfIcons.kt +448 -1
- package/data/native/android/WerewolfImage.kt +82 -0
- package/data/native/android/WerewolfInput.kt +3 -3
- package/data/native/android/WerewolfKbd.kt +3 -3
- package/data/native/android/WerewolfLabel.kt +2 -2
- package/data/native/android/WerewolfLayers.kt +1173 -0
- package/data/native/android/WerewolfLink.kt +163 -0
- package/data/native/android/WerewolfList.kt +504 -0
- package/data/native/android/WerewolfListRuntime.kt +383 -0
- package/data/native/android/WerewolfMessageActions.kt +86 -0
- package/data/native/android/WerewolfMessageActionsRuntime.kt +568 -0
- package/data/native/android/WerewolfMessageBubble.kt +402 -0
- package/data/native/android/WerewolfMessageList.kt +133 -0
- package/data/native/android/WerewolfMetadata.kt +180 -0
- package/data/native/android/WerewolfMeter.kt +189 -0
- package/data/native/android/WerewolfModifiers.kt +309 -4
- package/data/native/android/WerewolfNumberInput.kt +665 -0
- package/data/native/android/WerewolfOtpInput.kt +246 -0
- package/data/native/android/WerewolfPageRuntime.kt +83 -0
- package/data/native/android/WerewolfPagination.kt +29 -0
- package/data/native/android/WerewolfPaginationRuntime.kt +245 -0
- package/data/native/android/WerewolfPlot.kt +1129 -0
- package/data/native/android/WerewolfPopover.kt +92 -0
- package/data/native/android/WerewolfProgress.kt +281 -0
- package/data/native/android/WerewolfRadioGroup.kt +382 -0
- package/data/native/android/WerewolfRangeMath.kt +80 -0
- package/data/native/android/WerewolfRating.kt +44 -0
- package/data/native/android/WerewolfRatingRuntime.kt +113 -0
- package/data/native/android/WerewolfSelect.kt +330 -0
- package/data/native/android/WerewolfSeparator.kt +1 -1
- package/data/native/android/WerewolfSheet.kt +204 -0
- package/data/native/android/WerewolfSkeleton.kt +4 -4
- package/data/native/android/WerewolfSlider.kt +214 -0
- package/data/native/android/WerewolfSliderRuntime.kt +307 -0
- package/data/native/android/WerewolfSortableList.kt +34 -0
- package/data/native/android/WerewolfSortableListRuntime.kt +232 -0
- package/data/native/android/WerewolfSpinner.kt +1 -1
- package/data/native/android/WerewolfStepper.kt +690 -0
- package/data/native/android/WerewolfSwitch.kt +9 -57
- package/data/native/android/WerewolfTable.kt +134 -0
- package/data/native/android/WerewolfTableRuntime.kt +55 -0
- package/data/native/android/WerewolfTabs.kt +591 -0
- package/data/native/android/WerewolfTextarea.kt +329 -0
- package/data/native/android/WerewolfTheme.kt +17 -3
- package/data/native/android/WerewolfTimeColumns.kt +333 -0
- package/data/native/android/WerewolfTimePicker.kt +319 -0
- package/data/native/android/WerewolfTimeline.kt +382 -0
- package/data/native/android/WerewolfToast.kt +226 -0
- package/data/native/android/WerewolfToaster.kt +281 -0
- package/data/native/android/WerewolfToggle.kt +395 -0
- package/data/native/android/WerewolfToggleGroup.kt +427 -0
- package/data/native/android/WerewolfToken.kt +1 -1
- package/data/native/android/WerewolfTokenizer.kt +54 -0
- package/data/native/android/WerewolfTokenizerRuntime.kt +221 -0
- package/data/native/android/WerewolfTooltip.kt +78 -0
- package/data/native/ios/WerewolfAccordion.swift +340 -0
- package/data/native/ios/WerewolfAlert.swift +3 -3
- package/data/native/ios/WerewolfAlertDialog.swift +187 -0
- package/data/native/ios/WerewolfAttachmentPreview.swift +323 -0
- package/data/native/ios/WerewolfAvatar.swift +552 -0
- package/data/native/ios/WerewolfAvatarStack.swift +214 -0
- package/data/native/ios/WerewolfBadge.swift +74 -22
- package/data/native/ios/WerewolfBottomNav.swift +463 -0
- package/data/native/ios/WerewolfBreadcrumb.swift +22 -0
- package/data/native/ios/WerewolfBreadcrumbRuntime.swift +96 -0
- package/data/native/ios/WerewolfButton.swift +22 -5
- package/data/native/ios/WerewolfButtonGroup.swift +62 -0
- package/data/native/ios/WerewolfCalendar.swift +98 -0
- package/data/native/ios/WerewolfCalendarGrid.swift +453 -0
- package/data/native/ios/WerewolfCalendarMath.swift +321 -0
- package/data/native/ios/WerewolfCard.swift +2 -2
- package/data/native/ios/WerewolfCarousel.swift +168 -0
- package/data/native/ios/WerewolfChart.swift +206 -0
- package/data/native/ios/WerewolfChartAccessibility.swift +59 -0
- package/data/native/ios/WerewolfChartFormat.swift +14 -0
- package/data/native/ios/WerewolfChartGeometry.swift +479 -0
- package/data/native/ios/WerewolfChartInteraction.swift +113 -0
- package/data/native/ios/WerewolfChartModel.swift +337 -0
- package/data/native/ios/WerewolfChartPalette.swift +37 -0
- package/data/native/ios/WerewolfChatRuntime.swift +216 -0
- package/data/native/ios/WerewolfCheckbox.swift +623 -0
- package/data/native/ios/WerewolfChecklist.swift +276 -0
- package/data/native/ios/WerewolfCodeBlock.swift +405 -0
- package/data/native/ios/WerewolfColorPicker.swift +136 -0
- package/data/native/ios/WerewolfColorPickerRuntime.swift +469 -0
- package/data/native/ios/WerewolfCombobox.swift +469 -0
- package/data/native/ios/WerewolfComposer.swift +269 -0
- package/data/native/ios/WerewolfContextMenu.swift +21 -0
- package/data/native/ios/WerewolfConversationList.swift +141 -0
- package/data/native/ios/WerewolfCounter.swift +770 -0
- package/data/native/ios/WerewolfDataTrend.swift +292 -0
- package/data/native/ios/WerewolfDatePicker.swift +388 -0
- package/data/native/ios/WerewolfDialog.swift +172 -0
- package/data/native/ios/WerewolfDropdownMenu.swift +35 -0
- package/data/native/ios/WerewolfEmojiData.swift +600 -0
- package/data/native/ios/WerewolfEmojiPicker.swift +74 -0
- package/data/native/ios/WerewolfEmojiPickerRuntime.swift +361 -0
- package/data/native/ios/WerewolfEmptyState.swift +1 -1
- package/data/native/ios/WerewolfField.swift +103 -0
- package/data/native/ios/WerewolfGroupAvatar.swift +165 -0
- package/data/native/ios/WerewolfIcons.swift +85 -1
- package/data/native/ios/WerewolfImage.swift +118 -0
- package/data/native/ios/WerewolfInput.swift +5 -3
- package/data/native/ios/WerewolfKbd.swift +2 -2
- package/data/native/ios/WerewolfLabel.swift +2 -2
- package/data/native/ios/WerewolfLayers.swift +929 -0
- package/data/native/ios/WerewolfLink.swift +188 -0
- package/data/native/ios/WerewolfList.swift +603 -0
- package/data/native/ios/WerewolfListRuntime.swift +414 -0
- package/data/native/ios/WerewolfMessageActions.swift +99 -0
- package/data/native/ios/WerewolfMessageActionsRuntime.swift +218 -0
- package/data/native/ios/WerewolfMessageBubble.swift +474 -0
- package/data/native/ios/WerewolfMessageList.swift +123 -0
- package/data/native/ios/WerewolfMetadata.swift +205 -0
- package/data/native/ios/WerewolfMeter.swift +186 -0
- package/data/native/ios/WerewolfModifiers.swift +205 -1
- package/data/native/ios/WerewolfNumberInput.swift +808 -0
- package/data/native/ios/WerewolfOtpInput.swift +326 -0
- package/data/native/ios/WerewolfPageRuntime.swift +98 -0
- package/data/native/ios/WerewolfPagination.swift +34 -0
- package/data/native/ios/WerewolfPaginationRuntime.swift +165 -0
- package/data/native/ios/WerewolfPlot.swift +1249 -0
- package/data/native/ios/WerewolfPopover.swift +132 -0
- package/data/native/ios/WerewolfProgress.swift +338 -0
- package/data/native/ios/WerewolfRadioGroup.swift +485 -0
- package/data/native/ios/WerewolfRangeMath.swift +87 -0
- package/data/native/ios/WerewolfRating.swift +52 -0
- package/data/native/ios/WerewolfRatingRuntime.swift +100 -0
- package/data/native/ios/WerewolfSelect.swift +420 -0
- package/data/native/ios/WerewolfSeparator.swift +1 -1
- package/data/native/ios/WerewolfSheet.swift +208 -0
- package/data/native/ios/WerewolfSkeleton.swift +3 -3
- package/data/native/ios/WerewolfSlider.swift +330 -0
- package/data/native/ios/WerewolfSliderRuntime.swift +260 -0
- package/data/native/ios/WerewolfSortableList.swift +40 -0
- package/data/native/ios/WerewolfSortableListRuntime.swift +192 -0
- package/data/native/ios/WerewolfSpinner.swift +1 -1
- package/data/native/ios/WerewolfStepper.swift +802 -0
- package/data/native/ios/WerewolfSwitch.swift +21 -78
- package/data/native/ios/WerewolfTable.swift +185 -0
- package/data/native/ios/WerewolfTableRuntime.swift +47 -0
- package/data/native/ios/WerewolfTabs.swift +758 -0
- package/data/native/ios/WerewolfTextarea.swift +405 -0
- package/data/native/ios/WerewolfTheme.swift +17 -2
- package/data/native/ios/WerewolfTimeColumns.swift +134 -0
- package/data/native/ios/WerewolfTimePicker.swift +365 -0
- package/data/native/ios/WerewolfTimeline.swift +526 -0
- package/data/native/ios/WerewolfToast.swift +280 -0
- package/data/native/ios/WerewolfToaster.swift +269 -0
- package/data/native/ios/WerewolfToggle.swift +647 -0
- package/data/native/ios/WerewolfToggleGroup.swift +511 -0
- package/data/native/ios/WerewolfToken.swift +1 -1
- package/data/native/ios/WerewolfTokenizer.swift +77 -0
- package/data/native/ios/WerewolfTokenizerRuntime.swift +214 -0
- package/data/native/ios/WerewolfTooltip.swift +106 -0
- package/dist/cli.mjs +8573 -672
- package/dist/core.mjs +8279 -566
- package/dist/lint.mjs +205 -21
- package/dist/paths.mjs +2 -1
- package/dist/project.mjs +56 -10
- package/package.json +1 -1
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// Generated file, must not be edited by hand. Source: components/accordion.spec.json (werewolf-ui 0.1.0-beta.4).
|
|
2
|
+
package dev.werewolfui
|
|
3
|
+
|
|
4
|
+
import androidx.compose.animation.AnimatedVisibility
|
|
5
|
+
import androidx.compose.animation.core.snap
|
|
6
|
+
import androidx.compose.animation.core.tween
|
|
7
|
+
import androidx.compose.animation.expandVertically
|
|
8
|
+
import androidx.compose.animation.fadeIn
|
|
9
|
+
import androidx.compose.animation.fadeOut
|
|
10
|
+
import androidx.compose.animation.shrinkVertically
|
|
11
|
+
import androidx.compose.foundation.Image
|
|
12
|
+
import androidx.compose.foundation.clickable
|
|
13
|
+
import androidx.compose.foundation.focusable
|
|
14
|
+
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
15
|
+
import androidx.compose.foundation.interaction.collectIsFocusedAsState
|
|
16
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
17
|
+
import androidx.compose.foundation.layout.Column
|
|
18
|
+
import androidx.compose.foundation.layout.Row
|
|
19
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
20
|
+
import androidx.compose.foundation.layout.heightIn
|
|
21
|
+
import androidx.compose.foundation.layout.padding
|
|
22
|
+
import androidx.compose.foundation.text.BasicText
|
|
23
|
+
import androidx.compose.runtime.Composable
|
|
24
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
25
|
+
import androidx.compose.runtime.getValue
|
|
26
|
+
import androidx.compose.runtime.mutableStateOf
|
|
27
|
+
import androidx.compose.runtime.remember
|
|
28
|
+
import androidx.compose.runtime.setValue
|
|
29
|
+
import androidx.compose.runtime.staticCompositionLocalOf
|
|
30
|
+
import androidx.compose.ui.Alignment
|
|
31
|
+
import androidx.compose.ui.Modifier
|
|
32
|
+
import androidx.compose.ui.draw.drawBehind
|
|
33
|
+
import androidx.compose.ui.geometry.Offset
|
|
34
|
+
import androidx.compose.ui.geometry.Size
|
|
35
|
+
import androidx.compose.ui.graphics.Color
|
|
36
|
+
import androidx.compose.ui.graphics.ColorFilter
|
|
37
|
+
import androidx.compose.ui.graphics.RectangleShape
|
|
38
|
+
import androidx.compose.ui.semantics.Role
|
|
39
|
+
import androidx.compose.ui.semantics.semantics
|
|
40
|
+
import androidx.compose.ui.semantics.stateDescription
|
|
41
|
+
import androidx.compose.ui.text.TextStyle
|
|
42
|
+
import androidx.compose.ui.unit.Dp
|
|
43
|
+
import androidx.compose.ui.unit.IntSize
|
|
44
|
+
import androidx.compose.ui.unit.TextUnit
|
|
45
|
+
import dev.werewolfui.runtime.LocalWerewolf
|
|
46
|
+
import dev.werewolfui.runtime.LocalWerewolfContentColor
|
|
47
|
+
import dev.werewolfui.runtime.LocalWerewolfFonts
|
|
48
|
+
import dev.werewolfui.runtime.LocalWerewolfIcons
|
|
49
|
+
import dev.werewolfui.runtime.LocalWerewolfTextStyle
|
|
50
|
+
import dev.werewolfui.runtime.rememberReduceMotion
|
|
51
|
+
import dev.werewolfui.runtime.toCubicBezierEasing
|
|
52
|
+
import dev.werewolfui.runtime.werewolfCornerShape
|
|
53
|
+
import dev.werewolfui.runtime.werewolfFocusRing
|
|
54
|
+
import dev.werewolfui.runtime.werewolfFontWeight
|
|
55
|
+
import dev.werewolfui.runtime.werewolfHalfTurn
|
|
56
|
+
import dev.werewolfui.runtime.werewolfHitArea
|
|
57
|
+
import dev.werewolfui.runtime.werewolfIconMdFrame
|
|
58
|
+
import dev.werewolfui.tokens.WerewolfEasing
|
|
59
|
+
|
|
60
|
+
internal class WerewolfAccordionSelection(
|
|
61
|
+
val value: String?,
|
|
62
|
+
val onToggle: (String) -> Unit,
|
|
63
|
+
val enabled: Boolean,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
internal val LocalWerewolfAccordion = staticCompositionLocalOf { WerewolfAccordionSelection(null, {}, true) }
|
|
67
|
+
|
|
68
|
+
@Composable
|
|
69
|
+
fun WerewolfAccordion(
|
|
70
|
+
value: String?,
|
|
71
|
+
onValueChange: (String) -> Unit,
|
|
72
|
+
modifier: Modifier = Modifier,
|
|
73
|
+
collapsible: Boolean = true,
|
|
74
|
+
enabled: Boolean = true,
|
|
75
|
+
item: @Composable () -> Unit,
|
|
76
|
+
) {
|
|
77
|
+
CompositionLocalProvider(LocalWerewolfAccordion provides WerewolfAccordionSelection(value, { picked -> if (picked == value) { if (collapsible) onValueChange("") } else onValueChange(picked) }, enabled)) {
|
|
78
|
+
Column(modifier = modifier.fillMaxWidth()) {
|
|
79
|
+
item()
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Composable
|
|
85
|
+
fun WerewolfAccordion(
|
|
86
|
+
defaultValue: String? = null,
|
|
87
|
+
modifier: Modifier = Modifier,
|
|
88
|
+
collapsible: Boolean = true,
|
|
89
|
+
enabled: Boolean = true,
|
|
90
|
+
item: @Composable () -> Unit,
|
|
91
|
+
) {
|
|
92
|
+
var value by remember { mutableStateOf(defaultValue) }
|
|
93
|
+
WerewolfAccordion(
|
|
94
|
+
value = value,
|
|
95
|
+
onValueChange = { value = it.ifEmpty { null } },
|
|
96
|
+
modifier = modifier,
|
|
97
|
+
collapsible = collapsible,
|
|
98
|
+
enabled = enabled,
|
|
99
|
+
item = item,
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@Composable
|
|
104
|
+
fun WerewolfAccordionItem(
|
|
105
|
+
value: String,
|
|
106
|
+
title: String,
|
|
107
|
+
modifier: Modifier = Modifier,
|
|
108
|
+
enabled: Boolean = true,
|
|
109
|
+
content: @Composable () -> Unit,
|
|
110
|
+
) {
|
|
111
|
+
val selection = LocalWerewolfAccordion.current
|
|
112
|
+
val open = selection.value == value
|
|
113
|
+
val itemEnabled = enabled && selection.enabled
|
|
114
|
+
val t = LocalWerewolf.current
|
|
115
|
+
val fonts = LocalWerewolfFonts.current
|
|
116
|
+
val icons = LocalWerewolfIcons.current
|
|
117
|
+
val reduced = rememberReduceMotion()
|
|
118
|
+
val interactions = remember { MutableInteractionSource() }
|
|
119
|
+
val focusVisible by interactions.collectIsFocusedAsState()
|
|
120
|
+
// werewolf:property=item.border-bottom-width
|
|
121
|
+
val itemBorderBottomWidth = t.borderWidth
|
|
122
|
+
// werewolf:property=item.border-color
|
|
123
|
+
val itemBorderColor = t.colorBorder
|
|
124
|
+
// werewolf:property=trigger.border-radius
|
|
125
|
+
val triggerBorderRadius = t.radiusInner
|
|
126
|
+
// werewolf:property=trigger.color
|
|
127
|
+
val triggerColor: Color = run {
|
|
128
|
+
// werewolf:state=disabled
|
|
129
|
+
if (!itemEnabled) {
|
|
130
|
+
return@run t.colorTextDisabled
|
|
131
|
+
}
|
|
132
|
+
// werewolf:state=default
|
|
133
|
+
t.colorTextPrimary
|
|
134
|
+
}
|
|
135
|
+
// werewolf:property=trigger.font-family
|
|
136
|
+
val triggerFontFamily = t.fontFamilySans
|
|
137
|
+
// werewolf:property=trigger.font-size
|
|
138
|
+
val triggerFontSize = t.fontSizeSm
|
|
139
|
+
// werewolf:property=trigger.font-weight
|
|
140
|
+
val triggerFontWeight = t.fontWeightMedium
|
|
141
|
+
// werewolf:property=trigger.gap
|
|
142
|
+
val triggerGap = t.spacingSm
|
|
143
|
+
// werewolf:property=trigger.min-height
|
|
144
|
+
val triggerMinHeight = t.sizeElementMd
|
|
145
|
+
// werewolf:property=trigger.outline-color
|
|
146
|
+
val triggerOutlineColor: Color? = run {
|
|
147
|
+
// werewolf:state=focus-visible
|
|
148
|
+
if (focusVisible) {
|
|
149
|
+
return@run t.colorFocusRing
|
|
150
|
+
}
|
|
151
|
+
// werewolf:state=default
|
|
152
|
+
null
|
|
153
|
+
}
|
|
154
|
+
// werewolf:property=trigger.outline-offset
|
|
155
|
+
val triggerOutlineOffset: Dp? = run {
|
|
156
|
+
// werewolf:state=focus-visible
|
|
157
|
+
if (focusVisible) {
|
|
158
|
+
return@run t.outlineOffsetFocusRing
|
|
159
|
+
}
|
|
160
|
+
// werewolf:state=default
|
|
161
|
+
null
|
|
162
|
+
}
|
|
163
|
+
// werewolf:property=trigger.outline-width
|
|
164
|
+
val triggerOutlineWidth: Dp? = run {
|
|
165
|
+
// werewolf:state=focus-visible
|
|
166
|
+
if (focusVisible) {
|
|
167
|
+
return@run t.outlineWidthFocusRing
|
|
168
|
+
}
|
|
169
|
+
// werewolf:state=default
|
|
170
|
+
null
|
|
171
|
+
}
|
|
172
|
+
// werewolf:property=trigger.padding-block
|
|
173
|
+
val triggerPaddingBlock = t.spacingMd
|
|
174
|
+
// werewolf:property=icon.color
|
|
175
|
+
val iconColor: Color = run {
|
|
176
|
+
// werewolf:state=disabled
|
|
177
|
+
if (!itemEnabled) {
|
|
178
|
+
return@run t.colorIconDisabled
|
|
179
|
+
}
|
|
180
|
+
// werewolf:state=default
|
|
181
|
+
t.colorIconSecondary
|
|
182
|
+
}
|
|
183
|
+
// werewolf:property=icon.transition-duration
|
|
184
|
+
val iconTransitionDuration = t.durationMediumMs
|
|
185
|
+
// werewolf:property=icon.transition-timing-function
|
|
186
|
+
val iconTransitionTimingFunction = t.easeStandard
|
|
187
|
+
// werewolf:property=content.color
|
|
188
|
+
val contentColor = t.colorTextSecondary
|
|
189
|
+
// werewolf:property=content.font-family
|
|
190
|
+
val contentFontFamily = t.fontFamilySans
|
|
191
|
+
// werewolf:property=content.font-size
|
|
192
|
+
val contentFontSize = t.fontSizeSm
|
|
193
|
+
// werewolf:property=content.transition-duration
|
|
194
|
+
val contentTransitionDuration = t.durationMediumMs
|
|
195
|
+
// werewolf:property=content.transition-timing-function
|
|
196
|
+
val contentTransitionTimingFunction = t.easeEnter
|
|
197
|
+
// werewolf:property=body.padding-bottom
|
|
198
|
+
val bodyPaddingBottom = t.spacingMd
|
|
199
|
+
val itemShape = RectangleShape
|
|
200
|
+
val triggerShape = werewolfCornerShape(triggerBorderRadius)
|
|
201
|
+
val triggerTextStyle = TextStyle(fontFamily = fonts.sans, fontSize = triggerFontSize, fontWeight = werewolfFontWeight(triggerFontWeight), color = triggerColor)
|
|
202
|
+
val contentTextStyle = TextStyle(fontFamily = fonts.sans, fontSize = contentFontSize, color = contentColor)
|
|
203
|
+
val contentAlphaSpec = if (reduced) snap() else tween<Float>(durationMillis = contentTransitionDuration, easing = contentTransitionTimingFunction.toCubicBezierEasing())
|
|
204
|
+
val contentSizeSpec = if (reduced) snap() else tween<IntSize>(durationMillis = contentTransitionDuration, easing = contentTransitionTimingFunction.toCubicBezierEasing())
|
|
205
|
+
Column(
|
|
206
|
+
modifier = modifier
|
|
207
|
+
.fillMaxWidth()
|
|
208
|
+
.drawBehind {
|
|
209
|
+
val stroke = itemBorderBottomWidth.toPx()
|
|
210
|
+
drawRect(color = itemBorderColor, topLeft = Offset(0f, size.height - stroke), size = Size(size.width, stroke))
|
|
211
|
+
},
|
|
212
|
+
) {
|
|
213
|
+
Row(
|
|
214
|
+
modifier = Modifier
|
|
215
|
+
.fillMaxWidth()
|
|
216
|
+
.heightIn(min = triggerMinHeight)
|
|
217
|
+
.padding(vertical = triggerPaddingBlock)
|
|
218
|
+
.werewolfFocusRing(triggerOutlineColor != null, triggerShape)
|
|
219
|
+
.focusable(enabled = itemEnabled, interactionSource = interactions)
|
|
220
|
+
.clickable(enabled = itemEnabled, role = Role.Button, interactionSource = interactions, indication = null) { selection.onToggle(value) }
|
|
221
|
+
.werewolfHitArea()
|
|
222
|
+
.semantics { stateDescription = if (open) "Expanded" else "Collapsed" }
|
|
223
|
+
,
|
|
224
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
225
|
+
horizontalArrangement = Arrangement.spacedBy(triggerGap),
|
|
226
|
+
) {
|
|
227
|
+
BasicText(text = title, style = triggerTextStyle, modifier = Modifier.weight(1f))
|
|
228
|
+
Image(
|
|
229
|
+
imageVector = icons.chevronDown,
|
|
230
|
+
contentDescription = null,
|
|
231
|
+
colorFilter = ColorFilter.tint(iconColor),
|
|
232
|
+
modifier = Modifier
|
|
233
|
+
.werewolfIconMdFrame()
|
|
234
|
+
.werewolfHalfTurn(open, iconTransitionDuration, iconTransitionTimingFunction),
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
AnimatedVisibility(
|
|
238
|
+
visible = open,
|
|
239
|
+
enter = if (reduced) fadeIn(animationSpec = contentAlphaSpec) else fadeIn(animationSpec = contentAlphaSpec) + expandVertically(animationSpec = contentSizeSpec),
|
|
240
|
+
exit = if (reduced) fadeOut(animationSpec = contentAlphaSpec) else fadeOut(animationSpec = contentAlphaSpec) + shrinkVertically(animationSpec = contentSizeSpec),
|
|
241
|
+
) {
|
|
242
|
+
Column(
|
|
243
|
+
modifier = Modifier
|
|
244
|
+
.fillMaxWidth()
|
|
245
|
+
.padding(bottom = bodyPaddingBottom),
|
|
246
|
+
) {
|
|
247
|
+
CompositionLocalProvider(
|
|
248
|
+
LocalWerewolfContentColor provides contentColor,
|
|
249
|
+
LocalWerewolfTextStyle provides contentTextStyle,
|
|
250
|
+
) {
|
|
251
|
+
content()
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated file, must not be edited by hand. Source: components/alert.spec.json (werewolf-ui 0.1.0-beta.
|
|
1
|
+
// Generated file, must not be edited by hand. Source: components/alert.spec.json (werewolf-ui 0.1.0-beta.4).
|
|
2
2
|
package dev.werewolfui
|
|
3
3
|
|
|
4
4
|
import androidx.compose.foundation.background
|
|
@@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.Box
|
|
|
12
12
|
import androidx.compose.foundation.layout.Column
|
|
13
13
|
import androidx.compose.foundation.layout.Row
|
|
14
14
|
import androidx.compose.foundation.layout.padding
|
|
15
|
-
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
16
15
|
import androidx.compose.runtime.Composable
|
|
17
16
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
18
17
|
import androidx.compose.runtime.getValue
|
|
@@ -27,6 +26,7 @@ import androidx.compose.ui.unit.TextUnit
|
|
|
27
26
|
import dev.werewolfui.runtime.LocalWerewolf
|
|
28
27
|
import dev.werewolfui.runtime.LocalWerewolfContentColor
|
|
29
28
|
import dev.werewolfui.runtime.LocalWerewolfTextStyle
|
|
29
|
+
import dev.werewolfui.runtime.werewolfCornerShape
|
|
30
30
|
import dev.werewolfui.runtime.werewolfFontWeight
|
|
31
31
|
import dev.werewolfui.tokens.WerewolfEasing
|
|
32
32
|
|
|
@@ -165,8 +165,8 @@ fun WerewolfAlert(
|
|
|
165
165
|
val closeTransitionDuration = t.durationFastMs
|
|
166
166
|
// werewolf:property=close.transition-timing-function
|
|
167
167
|
val closeTransitionTimingFunction = t.easeStandard
|
|
168
|
-
val rootShape =
|
|
169
|
-
val closeShape =
|
|
168
|
+
val rootShape = werewolfCornerShape(rootBorderRadius)
|
|
169
|
+
val closeShape = werewolfCornerShape(closeBorderRadius)
|
|
170
170
|
CompositionLocalProvider(LocalWerewolfContentColor provides rootColor) {
|
|
171
171
|
Row(
|
|
172
172
|
modifier = modifier
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Generated file, must not be edited by hand. Source: components/alert-dialog.spec.json (werewolf-ui 0.1.0-beta.4).
|
|
2
|
+
package dev.werewolfui
|
|
3
|
+
|
|
4
|
+
import androidx.compose.foundation.background
|
|
5
|
+
import androidx.compose.foundation.border
|
|
6
|
+
import androidx.compose.foundation.focusGroup
|
|
7
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
8
|
+
import androidx.compose.foundation.layout.Box
|
|
9
|
+
import androidx.compose.foundation.layout.Column
|
|
10
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
11
|
+
import androidx.compose.foundation.layout.padding
|
|
12
|
+
import androidx.compose.foundation.text.BasicText
|
|
13
|
+
import androidx.compose.runtime.Composable
|
|
14
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
15
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
16
|
+
import androidx.compose.runtime.remember
|
|
17
|
+
import androidx.compose.runtime.withFrameNanos
|
|
18
|
+
import androidx.compose.ui.Alignment
|
|
19
|
+
import androidx.compose.ui.Modifier
|
|
20
|
+
import androidx.compose.ui.focus.FocusRequester
|
|
21
|
+
import androidx.compose.ui.focus.focusRequester
|
|
22
|
+
import androidx.compose.ui.graphics.Color
|
|
23
|
+
import androidx.compose.ui.semantics.clearAndSetSemantics
|
|
24
|
+
import androidx.compose.ui.text.TextStyle
|
|
25
|
+
import androidx.compose.ui.unit.Dp
|
|
26
|
+
import androidx.compose.ui.unit.TextUnit
|
|
27
|
+
import dev.werewolfui.runtime.LocalWerewolf
|
|
28
|
+
import dev.werewolfui.runtime.LocalWerewolfContentColor
|
|
29
|
+
import dev.werewolfui.runtime.LocalWerewolfFonts
|
|
30
|
+
import dev.werewolfui.runtime.WerewolfFontRole
|
|
31
|
+
import dev.werewolfui.runtime.WerewolfLayer
|
|
32
|
+
import dev.werewolfui.runtime.WerewolfPresent
|
|
33
|
+
import dev.werewolfui.runtime.werewolfCornerShape
|
|
34
|
+
import dev.werewolfui.runtime.werewolfFontWeight
|
|
35
|
+
import dev.werewolfui.runtime.werewolfShadow
|
|
36
|
+
import dev.werewolfui.tokens.WerewolfShadowLayer
|
|
37
|
+
|
|
38
|
+
enum class WerewolfAlertDialogSize {
|
|
39
|
+
Md,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Composable
|
|
43
|
+
fun WerewolfAlertDialog(
|
|
44
|
+
open: Boolean,
|
|
45
|
+
onOpenChange: (Boolean) -> Unit,
|
|
46
|
+
title: String,
|
|
47
|
+
description: String,
|
|
48
|
+
modifier: Modifier = Modifier,
|
|
49
|
+
size: WerewolfAlertDialogSize = WerewolfAlertDialogSize.Md,
|
|
50
|
+
cancel: @Composable () -> Unit,
|
|
51
|
+
media: (@Composable () -> Unit)? = null,
|
|
52
|
+
action: @Composable () -> Unit,
|
|
53
|
+
) {
|
|
54
|
+
WerewolfPresent(
|
|
55
|
+
open = open,
|
|
56
|
+
layer = WerewolfLayer.Dialog,
|
|
57
|
+
title = title,
|
|
58
|
+
onDismissRequest = { onOpenChange(false) },
|
|
59
|
+
dismissOnScrim = false,
|
|
60
|
+
) {
|
|
61
|
+
val t = LocalWerewolf.current
|
|
62
|
+
val initialFocus = remember { FocusRequester() }
|
|
63
|
+
LaunchedEffect(Unit) {
|
|
64
|
+
withFrameNanos { }
|
|
65
|
+
initialFocus.requestFocus()
|
|
66
|
+
}
|
|
67
|
+
// werewolf:property=content.background-color
|
|
68
|
+
val contentBackgroundColor = t.colorBackgroundRaised
|
|
69
|
+
// werewolf:property=content.border-color
|
|
70
|
+
val contentBorderColor = t.colorBorder
|
|
71
|
+
// werewolf:property=content.border-radius
|
|
72
|
+
val contentBorderRadius = t.radiusPage
|
|
73
|
+
// werewolf:property=content.border-width
|
|
74
|
+
val contentBorderWidth = t.borderWidth
|
|
75
|
+
// werewolf:property=content.box-shadow
|
|
76
|
+
val contentBoxShadow = t.shadowHigh
|
|
77
|
+
// werewolf:property=content.color
|
|
78
|
+
val contentColor = t.colorTextPrimary
|
|
79
|
+
// werewolf:property=content.font-family
|
|
80
|
+
val contentFontFamily = t.fontFamilySans
|
|
81
|
+
// werewolf:property=content.gap
|
|
82
|
+
val contentGap = t.spacingLg
|
|
83
|
+
// werewolf:property=content.padding
|
|
84
|
+
val contentPadding = t.spacingXl
|
|
85
|
+
// werewolf:property=header.gap
|
|
86
|
+
val headerGap = t.spacingSm
|
|
87
|
+
// werewolf:property=title.color
|
|
88
|
+
val titleColor = t.colorTextPrimary
|
|
89
|
+
// werewolf:property=title.font-size
|
|
90
|
+
val titleFontSize = t.fontSizeMd
|
|
91
|
+
// werewolf:property=title.font-weight
|
|
92
|
+
val titleFontWeight = t.fontWeightMedium
|
|
93
|
+
// werewolf:property=description.color
|
|
94
|
+
val descriptionColor = t.colorTextSecondary
|
|
95
|
+
// werewolf:property=description.font-size
|
|
96
|
+
val descriptionFontSize = t.fontSizeSm
|
|
97
|
+
// werewolf:property=footer.gap
|
|
98
|
+
val footerGap = t.spacingSm
|
|
99
|
+
val contentShape = werewolfCornerShape(contentBorderRadius)
|
|
100
|
+
CompositionLocalProvider(LocalWerewolfContentColor provides contentColor) {
|
|
101
|
+
Column(
|
|
102
|
+
modifier = modifier
|
|
103
|
+
.fillMaxWidth()
|
|
104
|
+
.fillMaxWidth()
|
|
105
|
+
.background(contentBackgroundColor, contentShape)
|
|
106
|
+
.border(contentBorderWidth, contentBorderColor, contentShape)
|
|
107
|
+
.padding(contentPadding)
|
|
108
|
+
.werewolfShadow(contentBoxShadow),
|
|
109
|
+
verticalArrangement = Arrangement.spacedBy(contentGap, Alignment.CenterVertically),
|
|
110
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
111
|
+
) {
|
|
112
|
+
if (media != null) {
|
|
113
|
+
Box(
|
|
114
|
+
modifier = Modifier
|
|
115
|
+
.clearAndSetSemantics {},
|
|
116
|
+
) {
|
|
117
|
+
media?.invoke()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
Column(
|
|
121
|
+
verticalArrangement = Arrangement.spacedBy(headerGap, Alignment.CenterVertically),
|
|
122
|
+
horizontalAlignment = Alignment.Start,
|
|
123
|
+
) {
|
|
124
|
+
BasicText(
|
|
125
|
+
text = title,
|
|
126
|
+
style = TextStyle(
|
|
127
|
+
color = titleColor,
|
|
128
|
+
fontSize = titleFontSize,
|
|
129
|
+
fontWeight = werewolfFontWeight(titleFontWeight),
|
|
130
|
+
),
|
|
131
|
+
)
|
|
132
|
+
BasicText(
|
|
133
|
+
text = description,
|
|
134
|
+
style = TextStyle(
|
|
135
|
+
color = descriptionColor,
|
|
136
|
+
fontSize = descriptionFontSize,
|
|
137
|
+
),
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
Column(
|
|
141
|
+
verticalArrangement = Arrangement.spacedBy(footerGap, Alignment.CenterVertically),
|
|
142
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
143
|
+
) {
|
|
144
|
+
action()
|
|
145
|
+
Box(
|
|
146
|
+
modifier = Modifier
|
|
147
|
+
.focusRequester(initialFocus)
|
|
148
|
+
.focusGroup(),
|
|
149
|
+
) {
|
|
150
|
+
cancel()
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|