@butternutbox/pawprint-native 0.20.0 → 0.22.0
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +36 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +36 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/Checkbox/Checkbox.stories.tsx +4 -1
- package/src/components/molecules/Checkbox/Checkbox.tsx +5 -6
- package/src/components/molecules/Drawer/DrawerBody.tsx +17 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useDrawerKeyboardAvoidance.ts +29 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -98,7 +98,10 @@ export const Tile = () => (
|
|
|
98
98
|
Horizontal
|
|
99
99
|
</Typography>
|
|
100
100
|
<CheckboxGroup orientation="horizontal">
|
|
101
|
-
<Checkbox
|
|
101
|
+
<Checkbox
|
|
102
|
+
variant="tile"
|
|
103
|
+
label="Some really really really really really really long text"
|
|
104
|
+
/>
|
|
102
105
|
<Checkbox variant="tile" label="Beef" />
|
|
103
106
|
<Checkbox variant="tile" label="Lamb" />
|
|
104
107
|
</CheckboxGroup>
|
|
@@ -69,12 +69,13 @@ const StyledRootPressable = styled(Pressable)<{
|
|
|
69
69
|
? { paddingHorizontal: rootPaddingHorizontal }
|
|
70
70
|
: {}),
|
|
71
71
|
// `fitContent` tiles hug their content (for wrapping rows); otherwise the
|
|
72
|
-
// tile fills its container width.
|
|
72
|
+
// tile fills its container width. For standalone checkboxes, always fill width
|
|
73
|
+
// so labels wrap properly.
|
|
73
74
|
...(rootMaxWidth !== undefined
|
|
74
75
|
? rootFitContent
|
|
75
76
|
? { maxWidth: rootMaxWidth, alignSelf: "flex-start" }
|
|
76
77
|
: { maxWidth: rootMaxWidth, width: "100%" }
|
|
77
|
-
: {}),
|
|
78
|
+
: { width: "100%" }),
|
|
78
79
|
...(rootBgColor ? { backgroundColor: rootBgColor } : {}),
|
|
79
80
|
...(rootBorderWidth !== undefined
|
|
80
81
|
? { borderWidth: rootBorderWidth, borderColor: rootBorderColor }
|
|
@@ -113,11 +114,10 @@ const StyledControl = styled(View)<{
|
|
|
113
114
|
|
|
114
115
|
const StyledContent = styled(View)<{
|
|
115
116
|
contentGap: number
|
|
116
|
-
|
|
117
|
-
}>(({ contentGap, contentFlex }) => ({
|
|
117
|
+
}>(({ contentGap }) => ({
|
|
118
118
|
flexDirection: "column",
|
|
119
119
|
gap: contentGap,
|
|
120
|
-
flex:
|
|
120
|
+
flex: 1,
|
|
121
121
|
minWidth: 0
|
|
122
122
|
}))
|
|
123
123
|
|
|
@@ -261,7 +261,6 @@ export const Checkbox = React.forwardRef<View, CheckboxProps>(
|
|
|
261
261
|
|
|
262
262
|
<StyledContent
|
|
263
263
|
contentGap={parseTokenValue(checkbox.spacing.content.gap)}
|
|
264
|
-
contentFlex={isTile && fitContent ? 0 : 1}
|
|
265
264
|
>
|
|
266
265
|
{label && (
|
|
267
266
|
<Typography
|
|
@@ -6,8 +6,11 @@ import { useSafeAreaInsets } from "react-native-safe-area-context"
|
|
|
6
6
|
import { useDrawerHeaderContext } from "./DrawerHeaderContext"
|
|
7
7
|
import { useDrawerFooterContext } from "./DrawerFooterContext"
|
|
8
8
|
import { useDrawerBodyMax } from "./DrawerBodyMaxContext"
|
|
9
|
+
import { useDrawerKeyboardAvoidance } from "../../../hooks/useDrawerKeyboardAvoidance"
|
|
9
10
|
|
|
10
|
-
export type DrawerBodyProps = ScrollViewProps
|
|
11
|
+
export type DrawerBodyProps = ScrollViewProps & {
|
|
12
|
+
ignoreKeyboardAvoidance?: boolean
|
|
13
|
+
}
|
|
11
14
|
|
|
12
15
|
const parseTokenValue = (value: string): number => parseFloat(value)
|
|
13
16
|
|
|
@@ -40,7 +43,15 @@ const StyledScrollView = styled(ScrollView)<{
|
|
|
40
43
|
* chrome-aware `maxHeight`, scrolling beyond that.
|
|
41
44
|
*/
|
|
42
45
|
export const DrawerBody = React.forwardRef<ScrollView, DrawerBodyProps>(
|
|
43
|
-
(
|
|
46
|
+
(
|
|
47
|
+
{
|
|
48
|
+
children,
|
|
49
|
+
contentContainerStyle,
|
|
50
|
+
ignoreKeyboardAvoidance = false,
|
|
51
|
+
...props
|
|
52
|
+
},
|
|
53
|
+
ref
|
|
54
|
+
) => {
|
|
44
55
|
const theme = useTheme()
|
|
45
56
|
const { spacing } = theme.tokens.components.drawer
|
|
46
57
|
const { buttons } = theme.tokens.components
|
|
@@ -50,6 +61,9 @@ export const DrawerBody = React.forwardRef<ScrollView, DrawerBodyProps>(
|
|
|
50
61
|
const providedMaxHeight = useDrawerBodyMax()
|
|
51
62
|
const { height: windowHeight } = useWindowDimensions()
|
|
52
63
|
const insets = useSafeAreaInsets()
|
|
64
|
+
const { contentContainerStyle: keyboardStyle } =
|
|
65
|
+
useDrawerKeyboardAvoidance()
|
|
66
|
+
const effectiveKeyboardStyle = ignoreKeyboardAvoidance ? {} : keyboardStyle
|
|
53
67
|
|
|
54
68
|
const gap = parseTokenValue(content.slot.gap)
|
|
55
69
|
const horizontalPadding = parseTokenValue(content.slot.horizontalPadding)
|
|
@@ -93,6 +107,7 @@ export const DrawerBody = React.forwardRef<ScrollView, DrawerBodyProps>(
|
|
|
93
107
|
paddingTop: topPadding,
|
|
94
108
|
paddingBottom: 0
|
|
95
109
|
},
|
|
110
|
+
effectiveKeyboardStyle,
|
|
96
111
|
contentContainerStyle
|
|
97
112
|
]}
|
|
98
113
|
{...props}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useDrawerKeyboardAvoidance } from "./useDrawerKeyboardAvoidance"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect, useState } from "react"
|
|
2
|
+
import { Keyboard, StyleProp, ViewStyle } from "react-native"
|
|
3
|
+
|
|
4
|
+
const useDrawerKeyboardAvoidance = (
|
|
5
|
+
minPadding: number = 16
|
|
6
|
+
): { contentContainerStyle: StyleProp<ViewStyle> } => {
|
|
7
|
+
const [keyboardHeight, setKeyboardHeight] = useState(0)
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const showListener = Keyboard.addListener("keyboardDidShow", (e) => {
|
|
11
|
+
setKeyboardHeight(e.endCoordinates.height)
|
|
12
|
+
})
|
|
13
|
+
const hideListener = Keyboard.addListener("keyboardDidHide", () => {
|
|
14
|
+
setKeyboardHeight(0)
|
|
15
|
+
})
|
|
16
|
+
return () => {
|
|
17
|
+
showListener.remove()
|
|
18
|
+
hideListener.remove()
|
|
19
|
+
}
|
|
20
|
+
}, [])
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
contentContainerStyle: {
|
|
24
|
+
paddingBottom: Math.max(minPadding, keyboardHeight)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { useDrawerKeyboardAvoidance }
|
package/src/index.ts
CHANGED