@butternutbox/pawprint-native 0.12.0 → 0.13.1
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 +9 -9
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +37 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +37 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/TextArea/TextAreaField.tsx +15 -1
- package/src/components/molecules/Checkbox/Checkbox.tsx +19 -3
- package/src/components/molecules/Checkbox/CheckboxGroup.tsx +31 -7
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
Error as ErrorIcon,
|
|
14
14
|
CheckCircle as SuccessIcon
|
|
15
15
|
} from "@butternutbox/pawprint-icons/core"
|
|
16
|
+
import { resolveFont } from "../../../fonts"
|
|
16
17
|
import { Icon } from "../Icon"
|
|
17
18
|
import type { InputState } from "../Input/InputField"
|
|
18
19
|
|
|
@@ -50,13 +51,26 @@ const StyledTextAreaWrapper = styled(Animated.View)<{
|
|
|
50
51
|
})
|
|
51
52
|
|
|
52
53
|
const StyledTextArea = styled(TextInput)(({ theme }) => {
|
|
53
|
-
const { colour } = theme.tokens.components.inputs
|
|
54
|
+
const { colour, field } = theme.tokens.components.inputs
|
|
55
|
+
const typography = field.placeholder.default
|
|
56
|
+
const { fontFamily } = resolveFont(
|
|
57
|
+
typography.fontFamily,
|
|
58
|
+
typography.fontWeight
|
|
59
|
+
)
|
|
60
|
+
const fontSize = parseTokenValue(typography.fontSize)
|
|
61
|
+
const letterSpacing = typography.letterSpacing?.endsWith("%")
|
|
62
|
+
? (parseFloat(typography.letterSpacing) / 100) * fontSize
|
|
63
|
+
: parseFloat(typography.letterSpacing ?? "0")
|
|
64
|
+
|
|
54
65
|
return {
|
|
55
66
|
flex: 1,
|
|
56
67
|
minWidth: 0,
|
|
57
68
|
minHeight: 0,
|
|
58
69
|
padding: 0,
|
|
59
70
|
color: colour.field.text.default,
|
|
71
|
+
fontFamily,
|
|
72
|
+
fontSize,
|
|
73
|
+
letterSpacing,
|
|
60
74
|
textAlignVertical: "top",
|
|
61
75
|
// Suppress the browser default focus outline on React Native Web —
|
|
62
76
|
// the focus indicator is rendered on the wrapper instead.
|
|
@@ -19,6 +19,12 @@ type CheckboxOwnProps = {
|
|
|
19
19
|
disabled?: boolean
|
|
20
20
|
name?: string
|
|
21
21
|
value?: string
|
|
22
|
+
/**
|
|
23
|
+
* Tile only: hug the content width instead of filling the container, so tiles
|
|
24
|
+
* can sit side by side and wrap. Set automatically by a horizontal
|
|
25
|
+
* `CheckboxGroup`; rarely needs setting by hand.
|
|
26
|
+
*/
|
|
27
|
+
fitContent?: boolean
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
export type CheckboxProps = CheckboxOwnProps &
|
|
@@ -33,6 +39,7 @@ const StyledRootPressable = styled(Pressable)<{
|
|
|
33
39
|
rootPaddingVertical?: number
|
|
34
40
|
rootPaddingHorizontal?: number
|
|
35
41
|
rootMaxWidth?: number
|
|
42
|
+
rootFitContent?: boolean
|
|
36
43
|
rootBgColor?: string
|
|
37
44
|
rootBorderWidth?: number
|
|
38
45
|
rootBorderColor?: string
|
|
@@ -45,6 +52,7 @@ const StyledRootPressable = styled(Pressable)<{
|
|
|
45
52
|
rootPaddingVertical,
|
|
46
53
|
rootPaddingHorizontal,
|
|
47
54
|
rootMaxWidth,
|
|
55
|
+
rootFitContent,
|
|
48
56
|
rootBgColor,
|
|
49
57
|
rootBorderWidth,
|
|
50
58
|
rootBorderColor,
|
|
@@ -60,8 +68,12 @@ const StyledRootPressable = styled(Pressable)<{
|
|
|
60
68
|
...(rootPaddingHorizontal !== undefined
|
|
61
69
|
? { paddingHorizontal: rootPaddingHorizontal }
|
|
62
70
|
: {}),
|
|
71
|
+
// `fitContent` tiles hug their content (for wrapping rows); otherwise the
|
|
72
|
+
// tile fills its container width.
|
|
63
73
|
...(rootMaxWidth !== undefined
|
|
64
|
-
?
|
|
74
|
+
? rootFitContent
|
|
75
|
+
? { maxWidth: rootMaxWidth, alignSelf: "flex-start" }
|
|
76
|
+
: { maxWidth: rootMaxWidth, width: "100%" }
|
|
65
77
|
: {}),
|
|
66
78
|
...(rootBgColor ? { backgroundColor: rootBgColor } : {}),
|
|
67
79
|
...(rootBorderWidth !== undefined
|
|
@@ -101,10 +113,11 @@ const StyledControl = styled(View)<{
|
|
|
101
113
|
|
|
102
114
|
const StyledContent = styled(View)<{
|
|
103
115
|
contentGap: number
|
|
104
|
-
|
|
116
|
+
contentFlex: number
|
|
117
|
+
}>(({ contentGap, contentFlex }) => ({
|
|
105
118
|
flexDirection: "column",
|
|
106
119
|
gap: contentGap,
|
|
107
|
-
flex:
|
|
120
|
+
flex: contentFlex,
|
|
108
121
|
minWidth: 0
|
|
109
122
|
}))
|
|
110
123
|
|
|
@@ -144,6 +157,7 @@ export const Checkbox = React.forwardRef<View, CheckboxProps>(
|
|
|
144
157
|
defaultChecked = false,
|
|
145
158
|
onCheckedChange,
|
|
146
159
|
disabled = false,
|
|
160
|
+
fitContent = false,
|
|
147
161
|
style,
|
|
148
162
|
...rest
|
|
149
163
|
},
|
|
@@ -201,6 +215,7 @@ export const Checkbox = React.forwardRef<View, CheckboxProps>(
|
|
|
201
215
|
? parseTokenValue(checkbox.checkboxTile.size.maxWidth)
|
|
202
216
|
: undefined
|
|
203
217
|
}
|
|
218
|
+
rootFitContent={isTile && fitContent}
|
|
204
219
|
rootBgColor={
|
|
205
220
|
isTile
|
|
206
221
|
? isChecked
|
|
@@ -246,6 +261,7 @@ export const Checkbox = React.forwardRef<View, CheckboxProps>(
|
|
|
246
261
|
|
|
247
262
|
<StyledContent
|
|
248
263
|
contentGap={parseTokenValue(checkbox.spacing.content.gap)}
|
|
264
|
+
contentFlex={isTile && fitContent ? 0 : 1}
|
|
249
265
|
>
|
|
250
266
|
{label && (
|
|
251
267
|
<Typography
|
|
@@ -2,6 +2,7 @@ import React from "react"
|
|
|
2
2
|
import { View, ViewProps } from "react-native"
|
|
3
3
|
import styled from "@emotion/native"
|
|
4
4
|
import { useTheme } from "@emotion/react"
|
|
5
|
+
import type { CheckboxProps } from "./Checkbox"
|
|
5
6
|
|
|
6
7
|
type CheckboxGroupOwnProps = {
|
|
7
8
|
children: React.ReactNode
|
|
@@ -16,20 +17,26 @@ const parseTokenValue = (value: string): number => parseFloat(value)
|
|
|
16
17
|
const StyledGroup = styled(View)<{
|
|
17
18
|
groupDirection: "row" | "column"
|
|
18
19
|
groupGap: number
|
|
19
|
-
|
|
20
|
+
groupWrap: boolean
|
|
21
|
+
}>(({ groupDirection, groupGap, groupWrap }) => ({
|
|
20
22
|
flexDirection: groupDirection,
|
|
21
|
-
gap: groupGap
|
|
23
|
+
gap: groupGap,
|
|
24
|
+
flexWrap: groupWrap ? "wrap" : "nowrap"
|
|
22
25
|
}))
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
* CheckboxGroup manages layout for a collection of Checkboxes.
|
|
26
29
|
*
|
|
30
|
+
* A `horizontal` group lays its tiles out in a wrapping row and makes them hug
|
|
31
|
+
* their content (via each Checkbox's `fitContent`) so they sit side by side;
|
|
32
|
+
* a `vertical` group stacks full-width tiles.
|
|
33
|
+
*
|
|
27
34
|
* @param {"horizontal" | "vertical"} [orientation="vertical"] - Layout direction.
|
|
28
35
|
*
|
|
29
36
|
* @example
|
|
30
|
-
* <CheckboxGroup>
|
|
31
|
-
* <Checkbox label="Chicken" />
|
|
32
|
-
* <Checkbox label="Beef" />
|
|
37
|
+
* <CheckboxGroup orientation="horizontal">
|
|
38
|
+
* <Checkbox variant="tile" label="Chicken" />
|
|
39
|
+
* <Checkbox variant="tile" label="Beef" />
|
|
33
40
|
* </CheckboxGroup>
|
|
34
41
|
*/
|
|
35
42
|
export const CheckboxGroup = React.forwardRef<View, CheckboxGroupProps>(
|
|
@@ -37,14 +44,31 @@ export const CheckboxGroup = React.forwardRef<View, CheckboxGroupProps>(
|
|
|
37
44
|
const theme = useTheme()
|
|
38
45
|
const { checkbox } = theme.tokens.components
|
|
39
46
|
|
|
47
|
+
const isHorizontal = orientation === "horizontal"
|
|
48
|
+
|
|
49
|
+
// Horizontal tiles hug their content so they can wrap; let an explicit
|
|
50
|
+
// per-Checkbox `fitContent` still win.
|
|
51
|
+
const renderChildren = (): React.ReactNode =>
|
|
52
|
+
isHorizontal
|
|
53
|
+
? React.Children.map(children, (child) => {
|
|
54
|
+
if (!React.isValidElement(child)) return child
|
|
55
|
+
const childProps = child.props as CheckboxProps
|
|
56
|
+
return React.cloneElement(
|
|
57
|
+
child as React.ReactElement<CheckboxProps>,
|
|
58
|
+
{ fitContent: childProps.fitContent ?? true }
|
|
59
|
+
)
|
|
60
|
+
})
|
|
61
|
+
: children
|
|
62
|
+
|
|
40
63
|
return (
|
|
41
64
|
<StyledGroup
|
|
42
65
|
ref={ref}
|
|
43
|
-
groupDirection={
|
|
66
|
+
groupDirection={isHorizontal ? "row" : "column"}
|
|
44
67
|
groupGap={parseTokenValue(checkbox.spacing.gap)}
|
|
68
|
+
groupWrap={isHorizontal}
|
|
45
69
|
{...rest}
|
|
46
70
|
>
|
|
47
|
-
{
|
|
71
|
+
{renderChildren()}
|
|
48
72
|
</StyledGroup>
|
|
49
73
|
)
|
|
50
74
|
}
|