@tamagui/button 1.15.7 → 1.15.9
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/dist/cjs/Button.js +23 -21
- package/dist/cjs/Button.js.map +2 -2
- package/dist/esm/Button.js +23 -21
- package/dist/esm/Button.js.map +2 -2
- package/dist/esm/Button.mjs +23 -21
- package/dist/esm/Button.mjs.map +2 -2
- package/dist/jsx/Button.js +23 -21
- package/dist/jsx/Button.js.map +2 -2
- package/dist/jsx/Button.mjs +23 -21
- package/dist/jsx/Button.mjs.map +2 -2
- package/package.json +7 -7
- package/src/Button.tsx +24 -21
- package/types/Button.d.ts +35 -36
- package/types/Button.d.ts.map +1 -1
package/dist/cjs/Button.js
CHANGED
|
@@ -37,14 +37,15 @@ const NAME = "Button";
|
|
|
37
37
|
const ButtonFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
38
38
|
name: NAME,
|
|
39
39
|
tag: "button",
|
|
40
|
-
justifyContent: "center",
|
|
41
|
-
alignItems: "center",
|
|
42
|
-
flexWrap: "nowrap",
|
|
43
|
-
flexDirection: "row",
|
|
44
|
-
cursor: "pointer",
|
|
45
40
|
variants: {
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
unstyled: {
|
|
42
|
+
false: {
|
|
43
|
+
size: "$true",
|
|
44
|
+
justifyContent: "center",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
flexWrap: "nowrap",
|
|
47
|
+
flexDirection: "row",
|
|
48
|
+
cursor: "pointer",
|
|
48
49
|
focusable: true,
|
|
49
50
|
hoverTheme: true,
|
|
50
51
|
pressTheme: true,
|
|
@@ -82,30 +83,31 @@ const ButtonFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
|
82
83
|
}
|
|
83
84
|
},
|
|
84
85
|
defaultVariants: {
|
|
85
|
-
|
|
86
|
+
unstyled: false
|
|
86
87
|
}
|
|
87
88
|
});
|
|
88
89
|
const ButtonText = (0, import_web.styled)(import_text.SizableText, {
|
|
89
90
|
name: "ButtonText",
|
|
90
|
-
userSelect: "none",
|
|
91
|
-
cursor: "pointer",
|
|
92
|
-
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
93
|
-
flexGrow: 0,
|
|
94
|
-
flexShrink: 1,
|
|
95
|
-
ellipse: true,
|
|
96
91
|
variants: {
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
unstyled: {
|
|
93
|
+
false: {
|
|
94
|
+
userSelect: "none",
|
|
95
|
+
cursor: "pointer",
|
|
96
|
+
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
97
|
+
flexGrow: 0,
|
|
98
|
+
flexShrink: 1,
|
|
99
|
+
ellipse: true,
|
|
99
100
|
color: "$color"
|
|
100
101
|
}
|
|
101
102
|
}
|
|
103
|
+
},
|
|
104
|
+
defaultVariants: {
|
|
105
|
+
unstyled: false
|
|
102
106
|
}
|
|
103
107
|
});
|
|
104
108
|
const ButtonComponent = (0, import_react.forwardRef)(function Button(props, ref) {
|
|
105
|
-
const {
|
|
106
|
-
|
|
107
|
-
} = useButton(props);
|
|
108
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonFrame, { defaultStyle: !unstyled, ...buttonProps, ref });
|
|
109
|
+
const { props: buttonProps } = useButton(props);
|
|
110
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonFrame, { ...buttonProps, ref });
|
|
109
111
|
});
|
|
110
112
|
const buttonStaticConfig = {
|
|
111
113
|
inlineProps: /* @__PURE__ */ new Set([
|
|
@@ -159,7 +161,7 @@ function useButton(propsIn, { Text = ButtonText } = { Text: ButtonText }) {
|
|
|
159
161
|
Text,
|
|
160
162
|
propsActive,
|
|
161
163
|
Text === ButtonText ? {
|
|
162
|
-
|
|
164
|
+
unstyled: propsIn.unstyled
|
|
163
165
|
} : void 0
|
|
164
166
|
);
|
|
165
167
|
const inner = (0, import_web.spacedChildren)({
|
package/dist/cjs/Button.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Button.tsx"],
|
|
4
|
-
"sourcesContent": ["import { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/web'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n *\n * @default 1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n *\n */\n unstyled?: boolean\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\n tag: 'button',\n justifyContent: 'center',\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/web'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n *\n * @default 1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n *\n */\n unstyled?: boolean\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\n tag: 'button',\n\n variants: {\n unstyled: {\n false: {\n size: '$true',\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n focusable: true,\n hoverTheme: true,\n pressTheme: true,\n backgrounded: true,\n borderWidth: 1,\n borderColor: 'transparent',\n\n pressStyle: {\n borderColor: 'transparent',\n },\n\n hoverStyle: {\n borderColor: 'transparent',\n },\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n outlineColor: '$borderColorFocus',\n outlineStyle: 'solid',\n outlineWidth: 2,\n },\n },\n },\n\n size: {\n '...size': getButtonSized,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nexport const ButtonText = styled(SizableText, {\n name: 'ButtonText',\n\n variants: {\n unstyled: {\n false: {\n userSelect: 'none',\n cursor: 'pointer',\n // flexGrow 1 leads to inconsistent native style where text pushes to start of view\n flexGrow: 0,\n flexShrink: 1,\n ellipse: true,\n color: '$color',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(\n props,\n ref\n) {\n const { props: buttonProps } = useButton(props)\n return <ButtonFrame {...buttonProps} ref={ref} />\n})\n\nexport const buttonStaticConfig = {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n // may be able to remove this entirely, as the compiler / runtime have gotten better\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'fontStyle',\n 'letterSpacing',\n 'textAlign',\n 'unstyled',\n ]),\n}\n\nexport const Button = ButtonFrame.extractable(\n themeable(ButtonComponent, ButtonFrame.staticConfig),\n buttonStaticConfig\n)\n\nexport function useButton(\n propsIn: ButtonProps,\n { Text = ButtonText }: { Text: any } = { Text: ButtonText }\n) {\n // careful not to desctructure and re-order props, order is important\n const {\n children,\n icon,\n iconAfter,\n noTextWrap,\n theme: themeName,\n space,\n spaceFlex,\n scaleIcon = 1,\n scaleSpace = 0.66,\n separator,\n\n // text props\n color,\n fontWeight,\n letterSpacing,\n fontSize,\n fontFamily,\n fontStyle,\n textAlign,\n textProps,\n\n ...rest\n } = propsIn\n\n const isNested = isRSC ? false : useContext(ButtonNestingContext)\n const propsActive = useMediaPropsActive(propsIn)\n const size = propsActive.size || '$true'\n const iconSize = (typeof size === 'number' ? size * 0.5 : getFontSize(size)) * scaleIcon\n const getThemedIcon = useGetThemedIcon({ size: iconSize, color })\n const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)\n const spaceSize = propsActive.space ?? getVariableValue(iconSize) * scaleSpace\n const contents = wrapChildrenInText(\n Text,\n propsActive,\n Text === ButtonText\n ? {\n unstyled: propsIn.unstyled,\n }\n : undefined\n )\n const inner = spacedChildren({\n // a bit arbitrary but scaling to font size is necessary so long as button does\n space: spaceSize,\n spaceFlex,\n separator,\n direction:\n propsActive.flexDirection === 'column' ||\n propsActive.flexDirection === 'column-reverse'\n ? 'vertical'\n : 'horizontal',\n children: [themedIcon, ...contents, themedIconAfter],\n })\n\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n const tag = isNested\n ? 'span'\n : // defaults to <a /> when accessibilityRole = link\n // see https://github.com/tamagui/tamagui/issues/505\n propsIn.accessibilityRole === 'link'\n ? 'a'\n : undefined\n\n const props = {\n ...(propsActive.disabled && {\n // in rnw - false still has keyboard tabIndex, undefined = not actually focusable\n focusable: undefined,\n // even with tabIndex unset, it will keep focusStyle on web so disable it here\n focusStyle: {\n borderColor: '$background',\n },\n }),\n tag,\n ...rest,\n children: isRSC ? (\n inner\n ) : (\n <ButtonNestingContext.Provider value={true}>{inner}</ButtonNestingContext.Provider>\n ),\n }\n\n return {\n spaceSize,\n isNested,\n props,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+IS;AA/IT,uBAA4B;AAC5B,8BAA+B;AAC/B,6BAAiC;AACjC,oBAA+B;AAC/B,kBAAkE;AAClE,iBAWO;AACP,mBAA0D;AAoC1D,MAAM,OAAO;AAEN,MAAM,kBAAc,mBAAO,8BAAgB;AAAA,EAChD,MAAM;AAAA,EACN,KAAK;AAAA,EAEL,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,QACN,gBAAgB;AAAA,QAChB,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,eAAe;AAAA,QACf,QAAQ;AAAA,QACR,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QAEb,YAAY;AAAA,UACV,aAAa;AAAA,QACf;AAAA,QAEA,YAAY;AAAA,UACV,aAAa;A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AArB,EAA8B,OAAO,MAAO,iBAAM;AAAA,EAEvD;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["Button"]
|
|
7
7
|
}
|
package/dist/esm/Button.js
CHANGED
|
@@ -18,14 +18,15 @@ const NAME = "Button";
|
|
|
18
18
|
const ButtonFrame = styled(ThemeableStack, {
|
|
19
19
|
name: NAME,
|
|
20
20
|
tag: "button",
|
|
21
|
-
justifyContent: "center",
|
|
22
|
-
alignItems: "center",
|
|
23
|
-
flexWrap: "nowrap",
|
|
24
|
-
flexDirection: "row",
|
|
25
|
-
cursor: "pointer",
|
|
26
21
|
variants: {
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
unstyled: {
|
|
23
|
+
false: {
|
|
24
|
+
size: "$true",
|
|
25
|
+
justifyContent: "center",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
flexWrap: "nowrap",
|
|
28
|
+
flexDirection: "row",
|
|
29
|
+
cursor: "pointer",
|
|
29
30
|
focusable: true,
|
|
30
31
|
hoverTheme: true,
|
|
31
32
|
pressTheme: true,
|
|
@@ -63,30 +64,31 @@ const ButtonFrame = styled(ThemeableStack, {
|
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
66
|
defaultVariants: {
|
|
66
|
-
|
|
67
|
+
unstyled: false
|
|
67
68
|
}
|
|
68
69
|
});
|
|
69
70
|
const ButtonText = styled(SizableText, {
|
|
70
71
|
name: "ButtonText",
|
|
71
|
-
userSelect: "none",
|
|
72
|
-
cursor: "pointer",
|
|
73
|
-
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
74
|
-
flexGrow: 0,
|
|
75
|
-
flexShrink: 1,
|
|
76
|
-
ellipse: true,
|
|
77
72
|
variants: {
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
unstyled: {
|
|
74
|
+
false: {
|
|
75
|
+
userSelect: "none",
|
|
76
|
+
cursor: "pointer",
|
|
77
|
+
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
78
|
+
flexGrow: 0,
|
|
79
|
+
flexShrink: 1,
|
|
80
|
+
ellipse: true,
|
|
80
81
|
color: "$color"
|
|
81
82
|
}
|
|
82
83
|
}
|
|
84
|
+
},
|
|
85
|
+
defaultVariants: {
|
|
86
|
+
unstyled: false
|
|
83
87
|
}
|
|
84
88
|
});
|
|
85
89
|
const ButtonComponent = forwardRef(function Button(props, ref) {
|
|
86
|
-
const {
|
|
87
|
-
|
|
88
|
-
} = useButton(props);
|
|
89
|
-
return /* @__PURE__ */ jsx(ButtonFrame, { defaultStyle: !unstyled, ...buttonProps, ref });
|
|
90
|
+
const { props: buttonProps } = useButton(props);
|
|
91
|
+
return /* @__PURE__ */ jsx(ButtonFrame, { ...buttonProps, ref });
|
|
90
92
|
});
|
|
91
93
|
const buttonStaticConfig = {
|
|
92
94
|
inlineProps: /* @__PURE__ */ new Set([
|
|
@@ -140,7 +142,7 @@ function useButton(propsIn, { Text = ButtonText } = { Text: ButtonText }) {
|
|
|
140
142
|
Text,
|
|
141
143
|
propsActive,
|
|
142
144
|
Text === ButtonText ? {
|
|
143
|
-
|
|
145
|
+
unstyled: propsIn.unstyled
|
|
144
146
|
} : void 0
|
|
145
147
|
);
|
|
146
148
|
const inner = spacedChildren({
|
package/dist/esm/Button.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Button.tsx"],
|
|
4
|
-
"sourcesContent": ["import { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/web'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n *\n * @default 1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n *\n */\n unstyled?: boolean\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\n tag: 'button',\n justifyContent: 'center',\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/web'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n *\n * @default 1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n *\n */\n unstyled?: boolean\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\n tag: 'button',\n\n variants: {\n unstyled: {\n false: {\n size: '$true',\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n focusable: true,\n hoverTheme: true,\n pressTheme: true,\n backgrounded: true,\n borderWidth: 1,\n borderColor: 'transparent',\n\n pressStyle: {\n borderColor: 'transparent',\n },\n\n hoverStyle: {\n borderColor: 'transparent',\n },\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n outlineColor: '$borderColorFocus',\n outlineStyle: 'solid',\n outlineWidth: 2,\n },\n },\n },\n\n size: {\n '...size': getButtonSized,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nexport const ButtonText = styled(SizableText, {\n name: 'ButtonText',\n\n variants: {\n unstyled: {\n false: {\n userSelect: 'none',\n cursor: 'pointer',\n // flexGrow 1 leads to inconsistent native style where text pushes to start of view\n flexGrow: 0,\n flexShrink: 1,\n ellipse: true,\n color: '$color',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(\n props,\n ref\n) {\n const { props: buttonProps } = useButton(props)\n return <ButtonFrame {...buttonProps} ref={ref} />\n})\n\nexport const buttonStaticConfig = {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n // may be able to remove this entirely, as the compiler / runtime have gotten better\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'fontStyle',\n 'letterSpacing',\n 'textAlign',\n 'unstyled',\n ]),\n}\n\nexport const Button = ButtonFrame.extractable(\n themeable(ButtonComponent, ButtonFrame.staticConfig),\n buttonStaticConfig\n)\n\nexport function useButton(\n propsIn: ButtonProps,\n { Text = ButtonText }: { Text: any } = { Text: ButtonText }\n) {\n // careful not to desctructure and re-order props, order is important\n const {\n children,\n icon,\n iconAfter,\n noTextWrap,\n theme: themeName,\n space,\n spaceFlex,\n scaleIcon = 1,\n scaleSpace = 0.66,\n separator,\n\n // text props\n color,\n fontWeight,\n letterSpacing,\n fontSize,\n fontFamily,\n fontStyle,\n textAlign,\n textProps,\n\n ...rest\n } = propsIn\n\n const isNested = isRSC ? false : useContext(ButtonNestingContext)\n const propsActive = useMediaPropsActive(propsIn)\n const size = propsActive.size || '$true'\n const iconSize = (typeof size === 'number' ? size * 0.5 : getFontSize(size)) * scaleIcon\n const getThemedIcon = useGetThemedIcon({ size: iconSize, color })\n const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)\n const spaceSize = propsActive.space ?? getVariableValue(iconSize) * scaleSpace\n const contents = wrapChildrenInText(\n Text,\n propsActive,\n Text === ButtonText\n ? {\n unstyled: propsIn.unstyled,\n }\n : undefined\n )\n const inner = spacedChildren({\n // a bit arbitrary but scaling to font size is necessary so long as button does\n space: spaceSize,\n spaceFlex,\n separator,\n direction:\n propsActive.flexDirection === 'column' ||\n propsActive.flexDirection === 'column-reverse'\n ? 'vertical'\n : 'horizontal',\n children: [themedIcon, ...contents, themedIconAfter],\n })\n\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n const tag = isNested\n ? 'span'\n : // defaults to <a /> when accessibilityRole = link\n // see https://github.com/tamagui/tamagui/issues/505\n propsIn.accessibilityRole === 'link'\n ? 'a'\n : undefined\n\n const props = {\n ...(propsActive.disabled && {\n // in rnw - false still has keyboard tabIndex, undefined = not actually focusable\n focusable: undefined,\n // even with tabIndex unset, it will keep focusStyle on web so disable it here\n focusStyle: {\n borderColor: '$background',\n },\n }),\n tag,\n ...rest,\n children: isRSC ? (\n inner\n ) : (\n <ButtonNestingContext.Provider value={true}>{inner}</ButtonNestingContext.Provider>\n ),\n }\n\n return {\n spaceSize,\n isNested,\n props,\n }\n}\n"],
|
|
5
|
+
"mappings": "AA+IS;AA/IT,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,aAA+B,0BAA0B;AAClE;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA4B,YAAY,kBAAkB;AAoC1D,MAAM,OAAO;AAEN,MAAM,cAAc,OAAO,gBAAgB;AAAA,EAChD,MAAM;AAAA,EACN,KAAK;AAAA,EAEL,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,QACN,gBAAgB;AAAA,QAChB,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,eAAe;AAAA,QACf,QAAQ;AAAA,QACR,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QAEb,YAAY;AAAA,UACV,aAAa;AAAA,QACf;AAAA,QAEA,YAAY;AAAA,UACV,aAAa;AAAA,QACf;AAAA,QAEA,YAAY;AAAA,UACV,aAAa;AAAA,UACb,cAAc;AAAA,UACd,cAAc;AAAA,UACd,cAAc;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM;AAAA,MACJ,WAAW;AAAA,IACb;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,QACJ,YAAY;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAEM,MAAM,aAAa,OAAO,a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AiB,EAAE,MAAM,UAAU,MAAM,CAAC;AAChE,QAAM,CAAC,YAAY,eAAe,IAAI,CAAC,MAAM,SAAS,EAAE,IAAI,aAAa;AACzE,QAAM,YAAY,YAAY,SAAS,iBAAiB,QAAQ,IAAI;AACpE,QAAM,WAAW;AAAA,IACf;AAAA,IACA;AAAA,IACA,SAAS,aACL;AAAA,MACE,UAAU,QAAQ;AAAA,IACpB,IACA;AAAA,EACN;AACA,QAAM,QAAQ,eAAe;AAAA;AAAA,IAE3B,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,WACE,YAAY,kBAAkB,YAC9B,YAAY,kBAAkB,mBAC1B,aACA;AAAA,IACN,UAAU,CAAC,YAAY,GAAG,UAAU,eAAe;AAAA,EACrD,CAAC;AAGD,QAAM,MAAM,WACR;AAAA;AAAA;AAAA,IAGF,QAAQ,sBAAsB,SAC5B,MACA;AAAA;AAEJ,QAAM,QAAQ;AAAA,IACZ,GAAI,YAAY,YAAY;AAAA;AAAA,MAE1B,WAAW;AAAA;AAAA,MAEX,YAAY;AAAA,QACV,aAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA;AAAA,IACA,GAAG;AAAA,IACH,UAAU,QACR,QAEA,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,MAAO,iBAAM;AAAA,EAEvD;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["Button"]
|
|
7
7
|
}
|
package/dist/esm/Button.mjs
CHANGED
|
@@ -18,14 +18,15 @@ const NAME = "Button";
|
|
|
18
18
|
const ButtonFrame = styled(ThemeableStack, {
|
|
19
19
|
name: NAME,
|
|
20
20
|
tag: "button",
|
|
21
|
-
justifyContent: "center",
|
|
22
|
-
alignItems: "center",
|
|
23
|
-
flexWrap: "nowrap",
|
|
24
|
-
flexDirection: "row",
|
|
25
|
-
cursor: "pointer",
|
|
26
21
|
variants: {
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
unstyled: {
|
|
23
|
+
false: {
|
|
24
|
+
size: "$true",
|
|
25
|
+
justifyContent: "center",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
flexWrap: "nowrap",
|
|
28
|
+
flexDirection: "row",
|
|
29
|
+
cursor: "pointer",
|
|
29
30
|
focusable: true,
|
|
30
31
|
hoverTheme: true,
|
|
31
32
|
pressTheme: true,
|
|
@@ -63,30 +64,31 @@ const ButtonFrame = styled(ThemeableStack, {
|
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
66
|
defaultVariants: {
|
|
66
|
-
|
|
67
|
+
unstyled: false
|
|
67
68
|
}
|
|
68
69
|
});
|
|
69
70
|
const ButtonText = styled(SizableText, {
|
|
70
71
|
name: "ButtonText",
|
|
71
|
-
userSelect: "none",
|
|
72
|
-
cursor: "pointer",
|
|
73
|
-
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
74
|
-
flexGrow: 0,
|
|
75
|
-
flexShrink: 1,
|
|
76
|
-
ellipse: true,
|
|
77
72
|
variants: {
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
unstyled: {
|
|
74
|
+
false: {
|
|
75
|
+
userSelect: "none",
|
|
76
|
+
cursor: "pointer",
|
|
77
|
+
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
78
|
+
flexGrow: 0,
|
|
79
|
+
flexShrink: 1,
|
|
80
|
+
ellipse: true,
|
|
80
81
|
color: "$color"
|
|
81
82
|
}
|
|
82
83
|
}
|
|
84
|
+
},
|
|
85
|
+
defaultVariants: {
|
|
86
|
+
unstyled: false
|
|
83
87
|
}
|
|
84
88
|
});
|
|
85
89
|
const ButtonComponent = forwardRef(function Button(props, ref) {
|
|
86
|
-
const {
|
|
87
|
-
|
|
88
|
-
} = useButton(props);
|
|
89
|
-
return /* @__PURE__ */ jsx(ButtonFrame, { defaultStyle: !unstyled, ...buttonProps, ref });
|
|
90
|
+
const { props: buttonProps } = useButton(props);
|
|
91
|
+
return /* @__PURE__ */ jsx(ButtonFrame, { ...buttonProps, ref });
|
|
90
92
|
});
|
|
91
93
|
const buttonStaticConfig = {
|
|
92
94
|
inlineProps: /* @__PURE__ */ new Set([
|
|
@@ -140,7 +142,7 @@ function useButton(propsIn, { Text = ButtonText } = { Text: ButtonText }) {
|
|
|
140
142
|
Text,
|
|
141
143
|
propsActive,
|
|
142
144
|
Text === ButtonText ? {
|
|
143
|
-
|
|
145
|
+
unstyled: propsIn.unstyled
|
|
144
146
|
} : void 0
|
|
145
147
|
);
|
|
146
148
|
const inner = spacedChildren({
|
package/dist/esm/Button.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Button.tsx"],
|
|
4
|
-
"sourcesContent": ["import { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/web'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n *\n * @default 1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n *\n */\n unstyled?: boolean\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\n tag: 'button',\n justifyContent: 'center',\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/web'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n *\n * @default 1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n *\n */\n unstyled?: boolean\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\n tag: 'button',\n\n variants: {\n unstyled: {\n false: {\n size: '$true',\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n focusable: true,\n hoverTheme: true,\n pressTheme: true,\n backgrounded: true,\n borderWidth: 1,\n borderColor: 'transparent',\n\n pressStyle: {\n borderColor: 'transparent',\n },\n\n hoverStyle: {\n borderColor: 'transparent',\n },\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n outlineColor: '$borderColorFocus',\n outlineStyle: 'solid',\n outlineWidth: 2,\n },\n },\n },\n\n size: {\n '...size': getButtonSized,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nexport const ButtonText = styled(SizableText, {\n name: 'ButtonText',\n\n variants: {\n unstyled: {\n false: {\n userSelect: 'none',\n cursor: 'pointer',\n // flexGrow 1 leads to inconsistent native style where text pushes to start of view\n flexGrow: 0,\n flexShrink: 1,\n ellipse: true,\n color: '$color',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(\n props,\n ref\n) {\n const { props: buttonProps } = useButton(props)\n return <ButtonFrame {...buttonProps} ref={ref} />\n})\n\nexport const buttonStaticConfig = {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n // may be able to remove this entirely, as the compiler / runtime have gotten better\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'fontStyle',\n 'letterSpacing',\n 'textAlign',\n 'unstyled',\n ]),\n}\n\nexport const Button = ButtonFrame.extractable(\n themeable(ButtonComponent, ButtonFrame.staticConfig),\n buttonStaticConfig\n)\n\nexport function useButton(\n propsIn: ButtonProps,\n { Text = ButtonText }: { Text: any } = { Text: ButtonText }\n) {\n // careful not to desctructure and re-order props, order is important\n const {\n children,\n icon,\n iconAfter,\n noTextWrap,\n theme: themeName,\n space,\n spaceFlex,\n scaleIcon = 1,\n scaleSpace = 0.66,\n separator,\n\n // text props\n color,\n fontWeight,\n letterSpacing,\n fontSize,\n fontFamily,\n fontStyle,\n textAlign,\n textProps,\n\n ...rest\n } = propsIn\n\n const isNested = isRSC ? false : useContext(ButtonNestingContext)\n const propsActive = useMediaPropsActive(propsIn)\n const size = propsActive.size || '$true'\n const iconSize = (typeof size === 'number' ? size * 0.5 : getFontSize(size)) * scaleIcon\n const getThemedIcon = useGetThemedIcon({ size: iconSize, color })\n const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)\n const spaceSize = propsActive.space ?? getVariableValue(iconSize) * scaleSpace\n const contents = wrapChildrenInText(\n Text,\n propsActive,\n Text === ButtonText\n ? {\n unstyled: propsIn.unstyled,\n }\n : undefined\n )\n const inner = spacedChildren({\n // a bit arbitrary but scaling to font size is necessary so long as button does\n space: spaceSize,\n spaceFlex,\n separator,\n direction:\n propsActive.flexDirection === 'column' ||\n propsActive.flexDirection === 'column-reverse'\n ? 'vertical'\n : 'horizontal',\n children: [themedIcon, ...contents, themedIconAfter],\n })\n\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n const tag = isNested\n ? 'span'\n : // defaults to <a /> when accessibilityRole = link\n // see https://github.com/tamagui/tamagui/issues/505\n propsIn.accessibilityRole === 'link'\n ? 'a'\n : undefined\n\n const props = {\n ...(propsActive.disabled && {\n // in rnw - false still has keyboard tabIndex, undefined = not actually focusable\n focusable: undefined,\n // even with tabIndex unset, it will keep focusStyle on web so disable it here\n focusStyle: {\n borderColor: '$background',\n },\n }),\n tag,\n ...rest,\n children: isRSC ? (\n inner\n ) : (\n <ButtonNestingContext.Provider value={true}>{inner}</ButtonNestingContext.Provider>\n ),\n }\n\n return {\n spaceSize,\n isNested,\n props,\n }\n}\n"],
|
|
5
|
+
"mappings": "AA+IS;AA/IT,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,aAA+B,0BAA0B;AAClE;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA4B,YAAY,kBAAkB;AAoC1D,MAAM,OAAO;AAEN,MAAM,cAAc,OAAO,gBAAgB;AAAA,EAChD,MAAM;AAAA,EACN,KAAK;AAAA,EAEL,UAAU;AAAA,IACR,U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rD,CAAC;AAGD,QAAM,MAAM,WACR;AAAA;AAAA;AAAA,IAGF,QAAQ,sBAAsB,SAC5B,MACA;AAAA;AAEJ,QAAM,QAAQ;AAAA,IACZ,GAAI,YAAY,YAAY;AAAA;AAAA,MAE1B,WAAW;AAAA;AAAA,MAEX,YAAY;AAAA,QACV,aAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA;AAAA,IACA,GAAG;AAAA,IACH,UAAU,QACR,QAEA,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,MAAO,iBAAM;AAAA,EAEvD;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["Button"]
|
|
7
7
|
}
|
package/dist/jsx/Button.js
CHANGED
|
@@ -17,14 +17,15 @@ const NAME = "Button";
|
|
|
17
17
|
const ButtonFrame = styled(ThemeableStack, {
|
|
18
18
|
name: NAME,
|
|
19
19
|
tag: "button",
|
|
20
|
-
justifyContent: "center",
|
|
21
|
-
alignItems: "center",
|
|
22
|
-
flexWrap: "nowrap",
|
|
23
|
-
flexDirection: "row",
|
|
24
|
-
cursor: "pointer",
|
|
25
20
|
variants: {
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
unstyled: {
|
|
22
|
+
false: {
|
|
23
|
+
size: "$true",
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
flexWrap: "nowrap",
|
|
27
|
+
flexDirection: "row",
|
|
28
|
+
cursor: "pointer",
|
|
28
29
|
focusable: true,
|
|
29
30
|
hoverTheme: true,
|
|
30
31
|
pressTheme: true,
|
|
@@ -62,30 +63,31 @@ const ButtonFrame = styled(ThemeableStack, {
|
|
|
62
63
|
}
|
|
63
64
|
},
|
|
64
65
|
defaultVariants: {
|
|
65
|
-
|
|
66
|
+
unstyled: false
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
const ButtonText = styled(SizableText, {
|
|
69
70
|
name: "ButtonText",
|
|
70
|
-
userSelect: "none",
|
|
71
|
-
cursor: "pointer",
|
|
72
|
-
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
73
|
-
flexGrow: 0,
|
|
74
|
-
flexShrink: 1,
|
|
75
|
-
ellipse: true,
|
|
76
71
|
variants: {
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
unstyled: {
|
|
73
|
+
false: {
|
|
74
|
+
userSelect: "none",
|
|
75
|
+
cursor: "pointer",
|
|
76
|
+
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
77
|
+
flexGrow: 0,
|
|
78
|
+
flexShrink: 1,
|
|
79
|
+
ellipse: true,
|
|
79
80
|
color: "$color"
|
|
80
81
|
}
|
|
81
82
|
}
|
|
83
|
+
},
|
|
84
|
+
defaultVariants: {
|
|
85
|
+
unstyled: false
|
|
82
86
|
}
|
|
83
87
|
});
|
|
84
88
|
const ButtonComponent = forwardRef(function Button(props, ref) {
|
|
85
|
-
const {
|
|
86
|
-
|
|
87
|
-
} = useButton(props);
|
|
88
|
-
return <ButtonFrame defaultStyle={!unstyled} {...buttonProps} ref={ref} />;
|
|
89
|
+
const { props: buttonProps } = useButton(props);
|
|
90
|
+
return <ButtonFrame {...buttonProps} ref={ref} />;
|
|
89
91
|
});
|
|
90
92
|
const buttonStaticConfig = {
|
|
91
93
|
inlineProps: /* @__PURE__ */ new Set([
|
|
@@ -139,7 +141,7 @@ function useButton(propsIn, { Text = ButtonText } = { Text: ButtonText }) {
|
|
|
139
141
|
Text,
|
|
140
142
|
propsActive,
|
|
141
143
|
Text === ButtonText ? {
|
|
142
|
-
|
|
144
|
+
unstyled: propsIn.unstyled
|
|
143
145
|
} : void 0
|
|
144
146
|
);
|
|
145
147
|
const inner = spacedChildren({
|
package/dist/jsx/Button.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Button.tsx"],
|
|
4
|
-
"sourcesContent": ["import { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/web'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n *\n * @default 1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n *\n */\n unstyled?: boolean\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\n tag: 'button',\n justifyContent: 'center',\n
|
|
5
|
-
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,aAA+B,0BAA0B;AAClE;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA4B,YAAY,kBAAkB;AAoC1D,MAAM,OAAO;AAEN,MAAM,cAAc,OAAO,gBAAgB;AAAA,EAChD,MAAM;AAAA,EACN,KAAK;AAAA,
|
|
4
|
+
"sourcesContent": ["import { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/web'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n *\n * @default 1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n *\n */\n unstyled?: boolean\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\n tag: 'button',\n\n variants: {\n unstyled: {\n false: {\n size: '$true',\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n focusable: true,\n hoverTheme: true,\n pressTheme: true,\n backgrounded: true,\n borderWidth: 1,\n borderColor: 'transparent',\n\n pressStyle: {\n borderColor: 'transparent',\n },\n\n hoverStyle: {\n borderColor: 'transparent',\n },\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n outlineColor: '$borderColorFocus',\n outlineStyle: 'solid',\n outlineWidth: 2,\n },\n },\n },\n\n size: {\n '...size': getButtonSized,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nexport const ButtonText = styled(SizableText, {\n name: 'ButtonText',\n\n variants: {\n unstyled: {\n false: {\n userSelect: 'none',\n cursor: 'pointer',\n // flexGrow 1 leads to inconsistent native style where text pushes to start of view\n flexGrow: 0,\n flexShrink: 1,\n ellipse: true,\n color: '$color',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(\n props,\n ref\n) {\n const { props: buttonProps } = useButton(props)\n return <ButtonFrame {...buttonProps} ref={ref} />\n})\n\nexport const buttonStaticConfig = {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n // may be able to remove this entirely, as the compiler / runtime have gotten better\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'fontStyle',\n 'letterSpacing',\n 'textAlign',\n 'unstyled',\n ]),\n}\n\nexport const Button = ButtonFrame.extractable(\n themeable(ButtonComponent, ButtonFrame.staticConfig),\n buttonStaticConfig\n)\n\nexport function useButton(\n propsIn: ButtonProps,\n { Text = ButtonText }: { Text: any } = { Text: ButtonText }\n) {\n // careful not to desctructure and re-order props, order is important\n const {\n children,\n icon,\n iconAfter,\n noTextWrap,\n theme: themeName,\n space,\n spaceFlex,\n scaleIcon = 1,\n scaleSpace = 0.66,\n separator,\n\n // text props\n color,\n fontWeight,\n letterSpacing,\n fontSize,\n fontFamily,\n fontStyle,\n textAlign,\n textProps,\n\n ...rest\n } = propsIn\n\n const isNested = isRSC ? false : useContext(ButtonNestingContext)\n const propsActive = useMediaPropsActive(propsIn)\n const size = propsActive.size || '$true'\n const iconSize = (typeof size === 'number' ? size * 0.5 : getFontSize(size)) * scaleIcon\n const getThemedIcon = useGetThemedIcon({ size: iconSize, color })\n const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)\n const spaceSize = propsActive.space ?? getVariableValue(iconSize) * scaleSpace\n const contents = wrapChildrenInText(\n Text,\n propsActive,\n Text === ButtonText\n ? {\n unstyled: propsIn.unstyled,\n }\n : undefined\n )\n const inner = spacedChildren({\n // a bit arbitrary but scaling to font size is necessary so long as button does\n space: spaceSize,\n spaceFlex,\n separator,\n direction:\n propsActive.flexDirection === 'column' ||\n propsActive.flexDirection === 'column-reverse'\n ? 'vertical'\n : 'horizontal',\n children: [themedIcon, ...contents, themedIconAfter],\n })\n\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n const tag = isNested\n ? 'span'\n : // defaults to <a /> when accessibilityRole = link\n // see https://github.com/tamagui/tamagui/issues/505\n propsIn.accessibilityRole === 'link'\n ? 'a'\n : undefined\n\n const props = {\n ...(propsActive.disabled && {\n // in rnw - false still has keyboard tabIndex, undefined = not actually focusable\n focusable: undefined,\n // even with tabIndex unset, it will keep focusStyle on web so disable it here\n focusStyle: {\n borderColor: '$background',\n },\n }),\n tag,\n ...rest,\n children: isRSC ? (\n inner\n ) : (\n <ButtonNestingContext.Provider value={true}>{inner}</ButtonNestingContext.Provider>\n ),\n }\n\n return {\n spaceSize,\n isNested,\n props,\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,aAA+B,0BAA0B;AAClE;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA4B,YAAY,kBAAkB;AAoC1D,MAAM,OAAO;AAEN,MAAM,cAAc,OAAO,gBAAgB;AAAA,EAChD,MAAM;AAAA,EACN,KAAK;AAAA,EAEL,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,QACN,gBAAgB;AAAA,QAChB,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,eAAe;AAAA,QACf,QAAQ;AAAA,QACR,WAAW;AAAA,QACX,YAAY;AAAA,QACZ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AAAA,MAEX,YAAY;AAAA,QACV,aAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA;AAAA,IACA,GAAG;AAAA,IACH,UAAU,QACR,QAEA,CAAC,qBAAqB,SAAS,OAAO,OAAO,MAAM,EAAlD,qBAAqB;AAAA,EAE1B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["Button"]
|
|
7
7
|
}
|
package/dist/jsx/Button.mjs
CHANGED
|
@@ -17,14 +17,15 @@ const NAME = "Button";
|
|
|
17
17
|
const ButtonFrame = styled(ThemeableStack, {
|
|
18
18
|
name: NAME,
|
|
19
19
|
tag: "button",
|
|
20
|
-
justifyContent: "center",
|
|
21
|
-
alignItems: "center",
|
|
22
|
-
flexWrap: "nowrap",
|
|
23
|
-
flexDirection: "row",
|
|
24
|
-
cursor: "pointer",
|
|
25
20
|
variants: {
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
unstyled: {
|
|
22
|
+
false: {
|
|
23
|
+
size: "$true",
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
flexWrap: "nowrap",
|
|
27
|
+
flexDirection: "row",
|
|
28
|
+
cursor: "pointer",
|
|
28
29
|
focusable: true,
|
|
29
30
|
hoverTheme: true,
|
|
30
31
|
pressTheme: true,
|
|
@@ -62,30 +63,31 @@ const ButtonFrame = styled(ThemeableStack, {
|
|
|
62
63
|
}
|
|
63
64
|
},
|
|
64
65
|
defaultVariants: {
|
|
65
|
-
|
|
66
|
+
unstyled: false
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
const ButtonText = styled(SizableText, {
|
|
69
70
|
name: "ButtonText",
|
|
70
|
-
userSelect: "none",
|
|
71
|
-
cursor: "pointer",
|
|
72
|
-
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
73
|
-
flexGrow: 0,
|
|
74
|
-
flexShrink: 1,
|
|
75
|
-
ellipse: true,
|
|
76
71
|
variants: {
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
unstyled: {
|
|
73
|
+
false: {
|
|
74
|
+
userSelect: "none",
|
|
75
|
+
cursor: "pointer",
|
|
76
|
+
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
77
|
+
flexGrow: 0,
|
|
78
|
+
flexShrink: 1,
|
|
79
|
+
ellipse: true,
|
|
79
80
|
color: "$color"
|
|
80
81
|
}
|
|
81
82
|
}
|
|
83
|
+
},
|
|
84
|
+
defaultVariants: {
|
|
85
|
+
unstyled: false
|
|
82
86
|
}
|
|
83
87
|
});
|
|
84
88
|
const ButtonComponent = forwardRef(function Button(props, ref) {
|
|
85
|
-
const {
|
|
86
|
-
|
|
87
|
-
} = useButton(props);
|
|
88
|
-
return <ButtonFrame defaultStyle={!unstyled} {...buttonProps} ref={ref} />;
|
|
89
|
+
const { props: buttonProps } = useButton(props);
|
|
90
|
+
return <ButtonFrame {...buttonProps} ref={ref} />;
|
|
89
91
|
});
|
|
90
92
|
const buttonStaticConfig = {
|
|
91
93
|
inlineProps: /* @__PURE__ */ new Set([
|
|
@@ -139,7 +141,7 @@ function useButton(propsIn, { Text = ButtonText } = { Text: ButtonText }) {
|
|
|
139
141
|
Text,
|
|
140
142
|
propsActive,
|
|
141
143
|
Text === ButtonText ? {
|
|
142
|
-
|
|
144
|
+
unstyled: propsIn.unstyled
|
|
143
145
|
} : void 0
|
|
144
146
|
);
|
|
145
147
|
const inner = spacedChildren({
|
package/dist/jsx/Button.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Button.tsx"],
|
|
4
|
-
"sourcesContent": ["import { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/web'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n *\n * @default 1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n *\n */\n unstyled?: boolean\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\n tag: 'button',\n justifyContent: 'center',\n
|
|
5
|
-
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,aAA+B,0BAA0B;AAClE;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA4B,YAAY,kBAAkB;AAoC1D,MAAM,OAAO;AAEN,MAAM,cAAc,OAAO,gBAAgB;AAAA,EAChD,MAAM;AAAA,EACN,KAAK;AAAA,
|
|
4
|
+
"sourcesContent": ["import { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/web'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n *\n * @default 1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n *\n */\n unstyled?: boolean\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\n tag: 'button',\n\n variants: {\n unstyled: {\n false: {\n size: '$true',\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n focusable: true,\n hoverTheme: true,\n pressTheme: true,\n backgrounded: true,\n borderWidth: 1,\n borderColor: 'transparent',\n\n pressStyle: {\n borderColor: 'transparent',\n },\n\n hoverStyle: {\n borderColor: 'transparent',\n },\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n outlineColor: '$borderColorFocus',\n outlineStyle: 'solid',\n outlineWidth: 2,\n },\n },\n },\n\n size: {\n '...size': getButtonSized,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nexport const ButtonText = styled(SizableText, {\n name: 'ButtonText',\n\n variants: {\n unstyled: {\n false: {\n userSelect: 'none',\n cursor: 'pointer',\n // flexGrow 1 leads to inconsistent native style where text pushes to start of view\n flexGrow: 0,\n flexShrink: 1,\n ellipse: true,\n color: '$color',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(\n props,\n ref\n) {\n const { props: buttonProps } = useButton(props)\n return <ButtonFrame {...buttonProps} ref={ref} />\n})\n\nexport const buttonStaticConfig = {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n // may be able to remove this entirely, as the compiler / runtime have gotten better\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'fontStyle',\n 'letterSpacing',\n 'textAlign',\n 'unstyled',\n ]),\n}\n\nexport const Button = ButtonFrame.extractable(\n themeable(ButtonComponent, ButtonFrame.staticConfig),\n buttonStaticConfig\n)\n\nexport function useButton(\n propsIn: ButtonProps,\n { Text = ButtonText }: { Text: any } = { Text: ButtonText }\n) {\n // careful not to desctructure and re-order props, order is important\n const {\n children,\n icon,\n iconAfter,\n noTextWrap,\n theme: themeName,\n space,\n spaceFlex,\n scaleIcon = 1,\n scaleSpace = 0.66,\n separator,\n\n // text props\n color,\n fontWeight,\n letterSpacing,\n fontSize,\n fontFamily,\n fontStyle,\n textAlign,\n textProps,\n\n ...rest\n } = propsIn\n\n const isNested = isRSC ? false : useContext(ButtonNestingContext)\n const propsActive = useMediaPropsActive(propsIn)\n const size = propsActive.size || '$true'\n const iconSize = (typeof size === 'number' ? size * 0.5 : getFontSize(size)) * scaleIcon\n const getThemedIcon = useGetThemedIcon({ size: iconSize, color })\n const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)\n const spaceSize = propsActive.space ?? getVariableValue(iconSize) * scaleSpace\n const contents = wrapChildrenInText(\n Text,\n propsActive,\n Text === ButtonText\n ? {\n unstyled: propsIn.unstyled,\n }\n : undefined\n )\n const inner = spacedChildren({\n // a bit arbitrary but scaling to font size is necessary so long as button does\n space: spaceSize,\n spaceFlex,\n separator,\n direction:\n propsActive.flexDirection === 'column' ||\n propsActive.flexDirection === 'column-reverse'\n ? 'vertical'\n : 'horizontal',\n children: [themedIcon, ...contents, themedIconAfter],\n })\n\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n const tag = isNested\n ? 'span'\n : // defaults to <a /> when accessibilityRole = link\n // see https://github.com/tamagui/tamagui/issues/505\n propsIn.accessibilityRole === 'link'\n ? 'a'\n : undefined\n\n const props = {\n ...(propsActive.disabled && {\n // in rnw - false still has keyboard tabIndex, undefined = not actually focusable\n focusable: undefined,\n // even with tabIndex unset, it will keep focusStyle on web so disable it here\n focusStyle: {\n borderColor: '$background',\n },\n }),\n tag,\n ...rest,\n children: isRSC ? (\n inner\n ) : (\n <ButtonNestingContext.Provider value={true}>{inner}</ButtonNestingContext.Provider>\n ),\n }\n\n return {\n spaceSize,\n isNested,\n props,\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,aAA+B,0BAA0B;AAClE;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA4B,YAAY,kBAAkB;AAoC1D,MAAM,OAAO;AAEN,MAAM,cAAc,OAAO,gBAAgB;AAAA,EAChD,MAAM;AAAA,EACN,KAAK;AAAA,EAEL,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,QACN,gBAAgB;AAAA,QAChB,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,eAAe;AAAA,QACf,QAAQ;AAAA,QACR,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QAEb,YAAY;AAAA,UACV,aAAa;AAAA,QACf;AAAA,QAEA,YAAY;AAAA,UACV,aAAa;AAAA,QACf;AAAA,QAEA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AqB;AAAA,EAE1B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["Button"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/button",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.9",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tamagui/font-size": "1.15.
|
|
33
|
-
"@tamagui/get-button-sized": "1.15.
|
|
34
|
-
"@tamagui/helpers-tamagui": "1.15.
|
|
35
|
-
"@tamagui/text": "1.15.
|
|
36
|
-
"@tamagui/web": "1.15.
|
|
32
|
+
"@tamagui/font-size": "1.15.9",
|
|
33
|
+
"@tamagui/get-button-sized": "1.15.9",
|
|
34
|
+
"@tamagui/helpers-tamagui": "1.15.9",
|
|
35
|
+
"@tamagui/text": "1.15.9",
|
|
36
|
+
"@tamagui/web": "1.15.9"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "*"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "1.15.
|
|
42
|
+
"@tamagui/build": "1.15.9",
|
|
43
43
|
"react": "^18.2.0",
|
|
44
44
|
"vitest": "^0.26.3"
|
|
45
45
|
},
|
package/src/Button.tsx
CHANGED
|
@@ -56,15 +56,16 @@ const NAME = 'Button'
|
|
|
56
56
|
export const ButtonFrame = styled(ThemeableStack, {
|
|
57
57
|
name: NAME,
|
|
58
58
|
tag: 'button',
|
|
59
|
-
justifyContent: 'center',
|
|
60
|
-
alignItems: 'center',
|
|
61
|
-
flexWrap: 'nowrap',
|
|
62
|
-
flexDirection: 'row',
|
|
63
|
-
cursor: 'pointer',
|
|
64
59
|
|
|
65
60
|
variants: {
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
unstyled: {
|
|
62
|
+
false: {
|
|
63
|
+
size: '$true',
|
|
64
|
+
justifyContent: 'center',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
flexWrap: 'nowrap',
|
|
67
|
+
flexDirection: 'row',
|
|
68
|
+
cursor: 'pointer',
|
|
68
69
|
focusable: true,
|
|
69
70
|
hoverTheme: true,
|
|
70
71
|
pressTheme: true,
|
|
@@ -109,25 +110,29 @@ export const ButtonFrame = styled(ThemeableStack, {
|
|
|
109
110
|
} as const,
|
|
110
111
|
|
|
111
112
|
defaultVariants: {
|
|
112
|
-
|
|
113
|
+
unstyled: false,
|
|
113
114
|
},
|
|
114
115
|
})
|
|
115
116
|
|
|
116
117
|
export const ButtonText = styled(SizableText, {
|
|
117
118
|
name: 'ButtonText',
|
|
118
|
-
userSelect: 'none',
|
|
119
|
-
cursor: 'pointer',
|
|
120
|
-
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
121
|
-
flexGrow: 0,
|
|
122
|
-
flexShrink: 1,
|
|
123
|
-
ellipse: true,
|
|
124
119
|
|
|
125
120
|
variants: {
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
unstyled: {
|
|
122
|
+
false: {
|
|
123
|
+
userSelect: 'none',
|
|
124
|
+
cursor: 'pointer',
|
|
125
|
+
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
126
|
+
flexGrow: 0,
|
|
127
|
+
flexShrink: 1,
|
|
128
|
+
ellipse: true,
|
|
128
129
|
color: '$color',
|
|
129
130
|
},
|
|
130
131
|
},
|
|
132
|
+
} as const,
|
|
133
|
+
|
|
134
|
+
defaultVariants: {
|
|
135
|
+
unstyled: false,
|
|
131
136
|
},
|
|
132
137
|
})
|
|
133
138
|
|
|
@@ -135,10 +140,8 @@ const ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(
|
|
|
135
140
|
props,
|
|
136
141
|
ref
|
|
137
142
|
) {
|
|
138
|
-
const {
|
|
139
|
-
|
|
140
|
-
} = useButton(props)
|
|
141
|
-
return <ButtonFrame defaultStyle={!unstyled} {...buttonProps} ref={ref} />
|
|
143
|
+
const { props: buttonProps } = useButton(props)
|
|
144
|
+
return <ButtonFrame {...buttonProps} ref={ref} />
|
|
142
145
|
})
|
|
143
146
|
|
|
144
147
|
export const buttonStaticConfig = {
|
|
@@ -203,7 +206,7 @@ export function useButton(
|
|
|
203
206
|
propsActive,
|
|
204
207
|
Text === ButtonText
|
|
205
208
|
? {
|
|
206
|
-
|
|
209
|
+
unstyled: propsIn.unstyled,
|
|
207
210
|
}
|
|
208
211
|
: undefined
|
|
209
212
|
)
|
package/types/Button.d.ts
CHANGED
|
@@ -49,8 +49,8 @@ export declare const ButtonFrame: import("@tamagui/web").TamaguiComponent<Omit<i
|
|
|
49
49
|
readonly bordered?: number | boolean | undefined;
|
|
50
50
|
readonly transparent?: boolean | undefined;
|
|
51
51
|
readonly chromeless?: boolean | "all" | undefined;
|
|
52
|
-
}, "disabled" | "
|
|
53
|
-
readonly
|
|
52
|
+
}, "disabled" | "unstyled" | "size" | "active"> & {
|
|
53
|
+
readonly unstyled?: boolean | undefined;
|
|
54
54
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
55
55
|
readonly active?: boolean | undefined;
|
|
56
56
|
readonly disabled?: boolean | undefined;
|
|
@@ -69,8 +69,8 @@ export declare const ButtonFrame: import("@tamagui/web").TamaguiComponent<Omit<i
|
|
|
69
69
|
readonly bordered?: number | boolean | undefined;
|
|
70
70
|
readonly transparent?: boolean | undefined;
|
|
71
71
|
readonly chromeless?: boolean | "all" | undefined;
|
|
72
|
-
}, "disabled" | "
|
|
73
|
-
readonly
|
|
72
|
+
}, "disabled" | "unstyled" | "size" | "active"> & {
|
|
73
|
+
readonly unstyled?: boolean | undefined;
|
|
74
74
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
75
75
|
readonly active?: boolean | undefined;
|
|
76
76
|
readonly disabled?: boolean | undefined;
|
|
@@ -89,8 +89,8 @@ export declare const ButtonFrame: import("@tamagui/web").TamaguiComponent<Omit<i
|
|
|
89
89
|
readonly bordered?: number | boolean | undefined;
|
|
90
90
|
readonly transparent?: boolean | undefined;
|
|
91
91
|
readonly chromeless?: boolean | "all" | undefined;
|
|
92
|
-
}, "disabled" | "
|
|
93
|
-
readonly
|
|
92
|
+
}, "disabled" | "unstyled" | "size" | "active"> & {
|
|
93
|
+
readonly unstyled?: boolean | undefined;
|
|
94
94
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
95
95
|
readonly active?: boolean | undefined;
|
|
96
96
|
readonly disabled?: boolean | undefined;
|
|
@@ -110,7 +110,7 @@ export declare const ButtonFrame: import("@tamagui/web").TamaguiComponent<Omit<i
|
|
|
110
110
|
readonly transparent?: boolean | undefined;
|
|
111
111
|
readonly chromeless?: boolean | "all" | undefined;
|
|
112
112
|
} & {
|
|
113
|
-
readonly
|
|
113
|
+
readonly unstyled?: boolean | undefined;
|
|
114
114
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
115
115
|
readonly active?: boolean | undefined;
|
|
116
116
|
readonly disabled?: boolean | undefined;
|
|
@@ -119,20 +119,20 @@ export declare const ButtonFrame: import("@tamagui/web").TamaguiComponent<Omit<i
|
|
|
119
119
|
}>;
|
|
120
120
|
export declare const ButtonText: import("@tamagui/web").TamaguiComponent<Omit<import("react-native").TextProps, "children" | ("onLayout" | keyof import("react-native").GestureResponderHandlers)> & import("@tamagui/web").ExtendsBaseTextProps & import("@tamagui/web").TamaguiComponentPropsBase & import("@tamagui/web").WithThemeValues<import("@tamagui/web").TextStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").TextStylePropsBase>> & Omit<{
|
|
121
121
|
readonly size?: import("@tamagui/web").FontSizeTokens | undefined;
|
|
122
|
-
}, "
|
|
123
|
-
|
|
122
|
+
}, "unstyled"> & {
|
|
123
|
+
readonly unstyled?: boolean | undefined;
|
|
124
124
|
} & import("@tamagui/web").MediaProps<Partial<Omit<import("react-native").TextProps, "children" | ("onLayout" | keyof import("react-native").GestureResponderHandlers)> & import("@tamagui/web").ExtendsBaseTextProps & import("@tamagui/web").TamaguiComponentPropsBase & import("@tamagui/web").WithThemeValues<import("@tamagui/web").TextStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").TextStylePropsBase>> & Omit<{
|
|
125
125
|
readonly size?: import("@tamagui/web").FontSizeTokens | undefined;
|
|
126
|
-
}, "
|
|
127
|
-
|
|
126
|
+
}, "unstyled"> & {
|
|
127
|
+
readonly unstyled?: boolean | undefined;
|
|
128
128
|
}>> & import("@tamagui/web").PseudoProps<Partial<Omit<import("react-native").TextProps, "children" | ("onLayout" | keyof import("react-native").GestureResponderHandlers)> & import("@tamagui/web").ExtendsBaseTextProps & import("@tamagui/web").TamaguiComponentPropsBase & import("@tamagui/web").WithThemeValues<import("@tamagui/web").TextStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").TextStylePropsBase>> & Omit<{
|
|
129
129
|
readonly size?: import("@tamagui/web").FontSizeTokens | undefined;
|
|
130
|
-
}, "
|
|
131
|
-
|
|
130
|
+
}, "unstyled"> & {
|
|
131
|
+
readonly unstyled?: boolean | undefined;
|
|
132
132
|
}>>, TamaguiElement, import("@tamagui/web").TextPropsBase, {
|
|
133
133
|
readonly size?: import("@tamagui/web").FontSizeTokens | undefined;
|
|
134
134
|
} & {
|
|
135
|
-
|
|
135
|
+
readonly unstyled?: boolean | undefined;
|
|
136
136
|
}, {
|
|
137
137
|
displayName: string | undefined;
|
|
138
138
|
}>;
|
|
@@ -154,8 +154,8 @@ export declare const Button: (props: Omit<Omit<TextParentStyles, "TextComponent"
|
|
|
154
154
|
readonly bordered?: number | boolean | undefined;
|
|
155
155
|
readonly transparent?: boolean | undefined;
|
|
156
156
|
readonly chromeless?: boolean | "all" | undefined;
|
|
157
|
-
}, "disabled" | "
|
|
158
|
-
readonly
|
|
157
|
+
}, "disabled" | "unstyled" | "size" | "active"> & {
|
|
158
|
+
readonly unstyled?: boolean | undefined;
|
|
159
159
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
160
160
|
readonly active?: boolean | undefined;
|
|
161
161
|
readonly disabled?: boolean | undefined;
|
|
@@ -174,8 +174,8 @@ export declare const Button: (props: Omit<Omit<TextParentStyles, "TextComponent"
|
|
|
174
174
|
readonly bordered?: number | boolean | undefined;
|
|
175
175
|
readonly transparent?: boolean | undefined;
|
|
176
176
|
readonly chromeless?: boolean | "all" | undefined;
|
|
177
|
-
}, "disabled" | "
|
|
178
|
-
readonly
|
|
177
|
+
}, "disabled" | "unstyled" | "size" | "active"> & {
|
|
178
|
+
readonly unstyled?: boolean | undefined;
|
|
179
179
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
180
180
|
readonly active?: boolean | undefined;
|
|
181
181
|
readonly disabled?: boolean | undefined;
|
|
@@ -194,8 +194,8 @@ export declare const Button: (props: Omit<Omit<TextParentStyles, "TextComponent"
|
|
|
194
194
|
readonly bordered?: number | boolean | undefined;
|
|
195
195
|
readonly transparent?: boolean | undefined;
|
|
196
196
|
readonly chromeless?: boolean | "all" | undefined;
|
|
197
|
-
}, "disabled" | "
|
|
198
|
-
readonly
|
|
197
|
+
}, "disabled" | "unstyled" | "size" | "active"> & {
|
|
198
|
+
readonly unstyled?: boolean | undefined;
|
|
199
199
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
200
200
|
readonly active?: boolean | undefined;
|
|
201
201
|
readonly disabled?: boolean | undefined;
|
|
@@ -343,7 +343,7 @@ export declare function useButton(propsIn: ButtonProps, { Text }?: {
|
|
|
343
343
|
borderTopWidth?: import("@tamagui/web").ThemeValueFallback | import("@tamagui/web").SpaceTokens | undefined;
|
|
344
344
|
borderWidth?: import("@tamagui/web").ThemeValueFallback | import("@tamagui/web").SpaceTokens | undefined;
|
|
345
345
|
opacity?: number | undefined;
|
|
346
|
-
alignContent?: "center" | "flex-start" | "flex-end" | "
|
|
346
|
+
alignContent?: "center" | "flex-start" | "flex-end" | "stretch" | "space-between" | "space-around" | undefined;
|
|
347
347
|
alignItems?: import("react-native").FlexAlignType | undefined;
|
|
348
348
|
alignSelf?: "auto" | import("react-native").FlexAlignType | undefined;
|
|
349
349
|
aspectRatio?: number | undefined;
|
|
@@ -468,7 +468,10 @@ export declare function useButton(propsIn: ButtonProps, { Text }?: {
|
|
|
468
468
|
padded?: boolean | undefined;
|
|
469
469
|
chromeless?: boolean | "all" | undefined;
|
|
470
470
|
fullscreen?: boolean | undefined;
|
|
471
|
-
|
|
471
|
+
/**
|
|
472
|
+
*
|
|
473
|
+
*/
|
|
474
|
+
unstyled?: boolean | undefined;
|
|
472
475
|
size?: import("@tamagui/web").SizeTokens | undefined;
|
|
473
476
|
active?: boolean | undefined;
|
|
474
477
|
hoverStyle?: Partial<Omit<import("react-native").ViewProps, "display" | "children" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/web").ExtendBaseStackProps & import("@tamagui/web").TamaguiComponentPropsBase & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{
|
|
@@ -486,8 +489,8 @@ export declare function useButton(propsIn: ButtonProps, { Text }?: {
|
|
|
486
489
|
readonly bordered?: number | boolean | undefined;
|
|
487
490
|
readonly transparent?: boolean | undefined;
|
|
488
491
|
readonly chromeless?: boolean | "all" | undefined;
|
|
489
|
-
}, "disabled" | "
|
|
490
|
-
readonly
|
|
492
|
+
}, "disabled" | "unstyled" | "size" | "active"> & {
|
|
493
|
+
readonly unstyled?: boolean | undefined;
|
|
491
494
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
492
495
|
readonly active?: boolean | undefined;
|
|
493
496
|
readonly disabled?: boolean | undefined;
|
|
@@ -507,8 +510,8 @@ export declare function useButton(propsIn: ButtonProps, { Text }?: {
|
|
|
507
510
|
readonly bordered?: number | boolean | undefined;
|
|
508
511
|
readonly transparent?: boolean | undefined;
|
|
509
512
|
readonly chromeless?: boolean | "all" | undefined;
|
|
510
|
-
}, "disabled" | "
|
|
511
|
-
readonly
|
|
513
|
+
}, "disabled" | "unstyled" | "size" | "active"> & {
|
|
514
|
+
readonly unstyled?: boolean | undefined;
|
|
512
515
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
513
516
|
readonly active?: boolean | undefined;
|
|
514
517
|
readonly disabled?: boolean | undefined;
|
|
@@ -528,8 +531,8 @@ export declare function useButton(propsIn: ButtonProps, { Text }?: {
|
|
|
528
531
|
readonly bordered?: number | boolean | undefined;
|
|
529
532
|
readonly transparent?: boolean | undefined;
|
|
530
533
|
readonly chromeless?: boolean | "all" | undefined;
|
|
531
|
-
}, "disabled" | "
|
|
532
|
-
readonly
|
|
534
|
+
}, "disabled" | "unstyled" | "size" | "active"> & {
|
|
535
|
+
readonly unstyled?: boolean | undefined;
|
|
533
536
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
534
537
|
readonly active?: boolean | undefined;
|
|
535
538
|
readonly disabled?: boolean | undefined;
|
|
@@ -549,8 +552,8 @@ export declare function useButton(propsIn: ButtonProps, { Text }?: {
|
|
|
549
552
|
readonly bordered?: number | boolean | undefined;
|
|
550
553
|
readonly transparent?: boolean | undefined;
|
|
551
554
|
readonly chromeless?: boolean | "all" | undefined;
|
|
552
|
-
}, "disabled" | "
|
|
553
|
-
readonly
|
|
555
|
+
}, "disabled" | "unstyled" | "size" | "active"> & {
|
|
556
|
+
readonly unstyled?: boolean | undefined;
|
|
554
557
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
555
558
|
readonly active?: boolean | undefined;
|
|
556
559
|
readonly disabled?: boolean | undefined;
|
|
@@ -570,18 +573,14 @@ export declare function useButton(propsIn: ButtonProps, { Text }?: {
|
|
|
570
573
|
readonly bordered?: number | boolean | undefined;
|
|
571
574
|
readonly transparent?: boolean | undefined;
|
|
572
575
|
readonly chromeless?: boolean | "all" | undefined;
|
|
573
|
-
}, "disabled" | "
|
|
574
|
-
readonly
|
|
576
|
+
}, "disabled" | "unstyled" | "size" | "active"> & {
|
|
577
|
+
readonly unstyled?: boolean | undefined;
|
|
575
578
|
readonly size?: import("@tamagui/web").SizeTokens | undefined;
|
|
576
579
|
readonly active?: boolean | undefined;
|
|
577
580
|
readonly disabled?: boolean | undefined;
|
|
578
581
|
}> | null | undefined;
|
|
579
582
|
themeInverse?: boolean | undefined;
|
|
580
583
|
themeReset?: boolean | undefined;
|
|
581
|
-
/**
|
|
582
|
-
*
|
|
583
|
-
*/
|
|
584
|
-
unstyled?: boolean | undefined;
|
|
585
584
|
};
|
|
586
585
|
};
|
|
587
586
|
export {};
|
package/types/Button.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAe,gBAAgB,EAAsB,MAAM,eAAe,CAAA;AACjF,OAAO,EAEL,QAAQ,EACR,cAAc,EACd,cAAc,EAOf,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,iBAAiB,EAA0B,MAAM,OAAO,CAAA;AAEjE,KAAK,eAAe,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AACxD,KAAK,QAAQ,GAAG,GAAG,CAAC,OAAO,GAAG,iBAAiB,CAAC,eAAe,CAAC,GAAG,IAAI,CAAA;AAEvE,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,EAAE,eAAe,CAAC,GAC/D,QAAQ,CAAC,OAAO,WAAW,CAAC,GAC5B,cAAc,GAAG;I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