@tamagui/button 1.13.3 → 1.14.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/dist/cjs/Button.js +1 -201
- package/dist/cjs/Button.js.map +2 -2
- package/dist/cjs/Button.test.js +1 -11
- package/dist/cjs/Button.test.js.map +2 -2
- package/dist/cjs/index.js +1 -18
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/Button.js +1 -181
- package/dist/esm/Button.js.map +2 -2
- package/dist/esm/Button.mjs +1 -181
- package/dist/esm/Button.mjs.map +2 -2
- package/dist/esm/Button.test.js +1 -10
- package/dist/esm/Button.test.js.map +2 -2
- package/dist/esm/Button.test.mjs +1 -10
- package/dist/esm/Button.test.mjs.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/jsx/Button.js +1 -180
- package/dist/jsx/Button.js.map +2 -2
- package/dist/jsx/Button.mjs +1 -180
- package/dist/jsx/Button.mjs.map +2 -2
- package/dist/jsx/Button.test.js +1 -10
- package/dist/jsx/Button.test.js.map +2 -2
- package/dist/jsx/Button.test.mjs +1 -10
- package/dist/jsx/Button.test.mjs.map +2 -2
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +1 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/cjs/Button.js
CHANGED
|
@@ -1,202 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var Button_exports = {};
|
|
20
|
-
__export(Button_exports, {
|
|
21
|
-
Button: () => Button2,
|
|
22
|
-
ButtonFrame: () => ButtonFrame,
|
|
23
|
-
ButtonText: () => ButtonText,
|
|
24
|
-
buttonStaticConfig: () => buttonStaticConfig,
|
|
25
|
-
useButton: () => useButton
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(Button_exports);
|
|
28
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
-
var import_font_size = require("@tamagui/font-size");
|
|
30
|
-
var import_get_button_sized = require("@tamagui/get-button-sized");
|
|
31
|
-
var import_helpers_tamagui = require("@tamagui/helpers-tamagui");
|
|
32
|
-
var import_stacks = require("@tamagui/stacks");
|
|
33
|
-
var import_text = require("@tamagui/text");
|
|
34
|
-
var import_web = require("@tamagui/web");
|
|
35
|
-
var import_react = require("react");
|
|
36
|
-
const NAME = "Button";
|
|
37
|
-
const ButtonFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
38
|
-
name: NAME,
|
|
39
|
-
tag: "button",
|
|
40
|
-
justifyContent: "center",
|
|
41
|
-
alignItems: "center",
|
|
42
|
-
flexWrap: "nowrap",
|
|
43
|
-
flexDirection: "row",
|
|
44
|
-
cursor: "pointer",
|
|
45
|
-
variants: {
|
|
46
|
-
defaultStyle: {
|
|
47
|
-
true: {
|
|
48
|
-
focusable: true,
|
|
49
|
-
hoverTheme: true,
|
|
50
|
-
pressTheme: true,
|
|
51
|
-
backgrounded: true,
|
|
52
|
-
borderWidth: 1,
|
|
53
|
-
borderColor: "transparent",
|
|
54
|
-
pressStyle: {
|
|
55
|
-
borderColor: "transparent"
|
|
56
|
-
},
|
|
57
|
-
hoverStyle: {
|
|
58
|
-
borderColor: "transparent"
|
|
59
|
-
},
|
|
60
|
-
focusStyle: {
|
|
61
|
-
borderColor: "$borderColorFocus"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
size: {
|
|
66
|
-
"...size": import_get_button_sized.getButtonSized
|
|
67
|
-
},
|
|
68
|
-
active: {
|
|
69
|
-
true: {
|
|
70
|
-
hoverStyle: {
|
|
71
|
-
backgroundColor: "$background"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
disabled: {
|
|
76
|
-
true: {
|
|
77
|
-
pointerEvents: "none"
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
defaultVariants: {
|
|
82
|
-
size: "$true"
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
const ButtonText = (0, import_web.styled)(import_text.SizableText, {
|
|
86
|
-
name: "ButtonText",
|
|
87
|
-
userSelect: "none",
|
|
88
|
-
cursor: "pointer",
|
|
89
|
-
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
90
|
-
flexGrow: 0,
|
|
91
|
-
flexShrink: 1,
|
|
92
|
-
ellipse: true,
|
|
93
|
-
variants: {
|
|
94
|
-
defaultStyle: {
|
|
95
|
-
true: {
|
|
96
|
-
color: "$color"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
const ButtonComponent = (0, import_react.forwardRef)(function Button(props, ref) {
|
|
102
|
-
const {
|
|
103
|
-
props: { unstyled, ...buttonProps }
|
|
104
|
-
} = useButton(props);
|
|
105
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonFrame, { defaultStyle: !unstyled, ...buttonProps, ref });
|
|
106
|
-
});
|
|
107
|
-
const buttonStaticConfig = {
|
|
108
|
-
inlineProps: /* @__PURE__ */ new Set([
|
|
109
|
-
// text props go here (can't really optimize them, but we never fully extract button anyway)
|
|
110
|
-
// may be able to remove this entirely, as the compiler / runtime have gotten better
|
|
111
|
-
"color",
|
|
112
|
-
"fontWeight",
|
|
113
|
-
"fontSize",
|
|
114
|
-
"fontFamily",
|
|
115
|
-
"fontStyle",
|
|
116
|
-
"letterSpacing",
|
|
117
|
-
"textAlign",
|
|
118
|
-
"unstyled"
|
|
119
|
-
])
|
|
120
|
-
};
|
|
121
|
-
const Button2 = ButtonFrame.extractable(
|
|
122
|
-
(0, import_web.themeable)(ButtonComponent, ButtonFrame.staticConfig),
|
|
123
|
-
buttonStaticConfig
|
|
124
|
-
);
|
|
125
|
-
function useButton(propsIn, { Text = ButtonText } = { Text: ButtonText }) {
|
|
126
|
-
const {
|
|
127
|
-
children,
|
|
128
|
-
icon,
|
|
129
|
-
iconAfter,
|
|
130
|
-
noTextWrap,
|
|
131
|
-
theme: themeName,
|
|
132
|
-
space,
|
|
133
|
-
spaceFlex,
|
|
134
|
-
scaleIcon = 1,
|
|
135
|
-
scaleSpace = 0.66,
|
|
136
|
-
separator,
|
|
137
|
-
// text props
|
|
138
|
-
color,
|
|
139
|
-
fontWeight,
|
|
140
|
-
letterSpacing,
|
|
141
|
-
fontSize,
|
|
142
|
-
fontFamily,
|
|
143
|
-
fontStyle,
|
|
144
|
-
textAlign,
|
|
145
|
-
textProps,
|
|
146
|
-
...rest
|
|
147
|
-
} = propsIn;
|
|
148
|
-
const isNested = import_web.isRSC ? false : (0, import_react.useContext)(import_web.ButtonNestingContext);
|
|
149
|
-
const propsActive = (0, import_web.useMediaPropsActive)(propsIn);
|
|
150
|
-
const size = propsActive.size || "$true";
|
|
151
|
-
const iconSize = (typeof size === "number" ? size * 0.5 : (0, import_font_size.getFontSize)(size)) * scaleIcon;
|
|
152
|
-
const getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({ size: iconSize, color });
|
|
153
|
-
const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon);
|
|
154
|
-
const spaceSize = propsActive.space ?? (0, import_web.getVariableValue)(iconSize) * scaleSpace;
|
|
155
|
-
const contents = (0, import_text.wrapChildrenInText)(
|
|
156
|
-
Text,
|
|
157
|
-
propsActive,
|
|
158
|
-
Text === ButtonText ? {
|
|
159
|
-
defaultStyle: !propsIn.unstyled
|
|
160
|
-
} : void 0
|
|
161
|
-
);
|
|
162
|
-
const inner = (0, import_web.spacedChildren)({
|
|
163
|
-
// a bit arbitrary but scaling to font size is necessary so long as button does
|
|
164
|
-
space: spaceSize,
|
|
165
|
-
spaceFlex,
|
|
166
|
-
separator,
|
|
167
|
-
direction: propsActive.flexDirection === "column" || propsActive.flexDirection === "column-reverse" ? "vertical" : "horizontal",
|
|
168
|
-
children: [themedIcon, ...contents, themedIconAfter]
|
|
169
|
-
});
|
|
170
|
-
const tag = isNested ? "span" : (
|
|
171
|
-
// defaults to <a /> when accessibilityRole = link
|
|
172
|
-
// see https://github.com/tamagui/tamagui/issues/505
|
|
173
|
-
propsIn.accessibilityRole === "link" ? "a" : void 0
|
|
174
|
-
);
|
|
175
|
-
const props = {
|
|
176
|
-
...propsActive.disabled && {
|
|
177
|
-
// in rnw - false still has keyboard tabIndex, undefined = not actually focusable
|
|
178
|
-
focusable: void 0,
|
|
179
|
-
// even with tabIndex unset, it will keep focusStyle on web so disable it here
|
|
180
|
-
focusStyle: {
|
|
181
|
-
borderColor: "$background"
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
tag,
|
|
185
|
-
...rest,
|
|
186
|
-
children: import_web.isRSC ? inner : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.ButtonNestingContext.Provider, { value: true, children: inner })
|
|
187
|
-
};
|
|
188
|
-
return {
|
|
189
|
-
spaceSize,
|
|
190
|
-
isNested,
|
|
191
|
-
props
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
195
|
-
0 && (module.exports = {
|
|
196
|
-
Button,
|
|
197
|
-
ButtonFrame,
|
|
198
|
-
ButtonText,
|
|
199
|
-
buttonStaticConfig,
|
|
200
|
-
useButton
|
|
201
|
-
});
|
|
1
|
+
"use strict";var m=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var V=(o,t)=>{for(var r in t)m(o,r,{get:t[r],enumerable:!0})},M=(o,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of D(t))!R.call(o,n)&&n!==r&&m(o,n,{get:()=>t[n],enumerable:!(s=G(t,n))||s.enumerable});return o};var J=o=>M(m({},"__esModule",{value:!0}),o);var q={};V(q,{Button:()=>j,ButtonFrame:()=>c,ButtonText:()=>l,buttonStaticConfig:()=>P,useButton:()=>T});module.exports=J(q);var d=require("react/jsx-runtime"),y=require("@tamagui/font-size"),h=require("@tamagui/get-button-sized"),g=require("@tamagui/helpers-tamagui"),C=require("@tamagui/stacks"),a=require("@tamagui/text"),e=require("@tamagui/web"),u=require("react");const O="Button",c=(0,e.styled)(C.ThemeableStack,{name:O,tag:"button",justifyContent:"center",alignItems:"center",flexWrap:"nowrap",flexDirection:"row",cursor:"pointer",variants:{defaultStyle:{true:{focusable:!0,hoverTheme:!0,pressTheme:!0,backgrounded:!0,borderWidth:1,borderColor:"transparent",pressStyle:{borderColor:"transparent"},hoverStyle:{borderColor:"transparent"},focusStyle:{borderColor:"$borderColorFocus"}}},size:{"...size":h.getButtonSized},active:{true:{hoverStyle:{backgroundColor:"$background"}}},disabled:{true:{pointerEvents:"none"}}},defaultVariants:{size:"$true"}}),l=(0,e.styled)(a.SizableText,{name:"ButtonText",userSelect:"none",cursor:"pointer",flexGrow:0,flexShrink:1,ellipse:!0,variants:{defaultStyle:{true:{color:"$color"}}}}),X=(0,u.forwardRef)(function(t,r){const{props:{unstyled:s,...n}}=T(t);return(0,d.jsx)(c,{defaultStyle:!s,...n,ref:r})}),P={inlineProps:new Set(["color","fontWeight","fontSize","fontFamily","fontStyle","letterSpacing","textAlign","unstyled"])},j=c.extractable((0,e.themeable)(X,c.staticConfig),P);function T(o,{Text:t=l}={Text:l}){const{children:r,icon:s,iconAfter:n,noTextWrap:H,theme:K,space:L,spaceFlex:B,scaleIcon:z=1,scaleSpace:v=.66,separator:F,color:I,fontWeight:Q,letterSpacing:U,fontSize:Y,fontFamily:Z,fontStyle:_,textAlign:ee,textProps:te,...A}=o,f=e.isRSC?!1:(0,u.useContext)(e.ButtonNestingContext),i=(0,e.useMediaPropsActive)(o),p=i.size||"$true",b=(typeof p=="number"?p*.5:(0,y.getFontSize)(p))*z,k=(0,g.useGetThemedIcon)({size:b,color:I}),[w,$]=[s,n].map(k),S=i.space??(0,e.getVariableValue)(b)*v,E=(0,a.wrapChildrenInText)(t,i,t===l?{defaultStyle:!o.unstyled}:void 0),x=(0,e.spacedChildren)({space:S,spaceFlex:B,separator:F,direction:i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal",children:[w,...E,$]}),N=f?"span":o.accessibilityRole==="link"?"a":void 0,W={...i.disabled&&{focusable:void 0,focusStyle:{borderColor:"$background"}},tag:N,...A,children:e.isRSC?x:(0,d.jsx)(e.ButtonNestingContext.Provider,{value:!0,children:x})};return{spaceSize:S,isNested:f,props:W}}0&&(module.exports={Button,ButtonFrame,ButtonText,buttonStaticConfig,useButton});
|
|
202
2
|
//# sourceMappingURL=Button.js.map
|
package/dist/cjs/Button.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Button.tsx"],
|
|
4
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 alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n\n variants: {\n defaultStyle: {\n true: {\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 },\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 size: '$true',\n },\n})\n\nexport const ButtonText = styled(SizableText, {\n name: 'ButtonText',\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\n variants: {\n defaultStyle: {\n true: {\n color: '$color',\n },\n },\n },\n})\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(\n props,\n ref\n) {\n const {\n props: { unstyled, ...buttonProps },\n } = useButton(props)\n return <ButtonFrame defaultStyle={!unstyled} {...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 defaultStyle: !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": "
|
|
6
|
-
"names": ["Button"]
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,gBAAAC,EAAA,eAAAC,EAAA,uBAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAP,GAyIS,IAAAQ,EAAA,6BAzITC,EAA4B,8BAC5BC,EAA+B,qCAC/BC,EAAiC,oCACjCC,EAA+B,2BAC/BC,EAAkE,yBAClEC,EAWO,wBACPC,EAA0D,iBAoC1D,MAAMC,EAAO,SAEAb,KAAc,UAAO,iBAAgB,CAChD,KAAMa,EACN,IAAK,SACL,eAAgB,SAChB,WAAY,SACZ,SAAU,SACV,cAAe,MACf,OAAQ,UAER,SAAU,CACR,aAAc,CACZ,KAAM,CACJ,UAAW,GACX,WAAY,GACZ,WAAY,GACZ,aAAc,GACd,YAAa,EACb,YAAa,cAEb,WAAY,CACV,YAAa,aACf,EAEA,WAAY,CACV,YAAa,aACf,EAEA,WAAY,CACV,YAAa,mBACf,CACF,CACF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AAM,eAAYA,CAAI,GAAKd,EACzEgB,KAAgB,oBAAiB,CAAE,KAAMD,EAAU,MAAAZ,CAAM,CAAC,EAC1D,CAACc,EAAYC,CAAe,EAAI,CAACxB,EAAMC,CAAS,EAAE,IAAIqB,CAAa,EACnEG,EAAYN,EAAY,UAAS,oBAAiBE,CAAQ,EAAId,EAC9DmB,KAAW,sBACf5B,EACAqB,EACArB,IAASnB,EACL,CACE,aAAc,CAACkB,EAAQ,QACzB,EACA,MACN,EACM8B,KAAQ,kBAAe,CAE3B,MAAOF,EACP,UAAApB,EACA,UAAAG,EACA,UACEW,EAAY,gBAAkB,UAC9BA,EAAY,gBAAkB,iBAC1B,WACA,aACN,SAAU,CAACI,EAAY,GAAGG,EAAUF,CAAe,CACrD,CAAC,EAGKI,EAAMV,EACR,OAGFrB,EAAQ,oBAAsB,OAC5B,IACA,OAEEJ,EAAQ,CACZ,GAAI0B,EAAY,UAAY,CAE1B,UAAW,OAEX,WAAY,CACV,YAAa,aACf,CACF,EACA,IAAAS,EACA,GAAGX,EACH,SAAU,QACRU,KAEA,OAAC,uBAAqB,SAArB,CAA8B,MAAO,GAAO,SAAAA,EAAM,CAEvD,EAEA,MAAO,CACL,UAAAF,EACA,SAAAP,EACA,MAAAzB,CACF,CACF",
|
|
6
|
+
"names": ["Button_exports", "__export", "Button", "ButtonFrame", "ButtonText", "buttonStaticConfig", "useButton", "__toCommonJS", "import_jsx_runtime", "import_font_size", "import_get_button_sized", "import_helpers_tamagui", "import_stacks", "import_text", "import_web", "import_react", "NAME", "ButtonComponent", "props", "ref", "unstyled", "buttonProps", "propsIn", "Text", "children", "icon", "iconAfter", "noTextWrap", "themeName", "space", "spaceFlex", "scaleIcon", "scaleSpace", "separator", "color", "fontWeight", "letterSpacing", "fontSize", "fontFamily", "fontStyle", "textAlign", "textProps", "rest", "isNested", "propsActive", "size", "iconSize", "getThemedIcon", "themedIcon", "themedIconAfter", "spaceSize", "contents", "inner", "tag"]
|
|
7
7
|
}
|
package/dist/cjs/Button.test.js
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var import_config_default = require("@tamagui/config-default");
|
|
3
|
-
var import_core = require("@tamagui/core");
|
|
4
|
-
var import_vitest = require("vitest");
|
|
5
|
-
process.env.TAMAGUI_TARGET = "web";
|
|
6
|
-
const conf = (0, import_core.createTamagui)((0, import_config_default.getDefaultTamaguiConfig)());
|
|
7
|
-
(0, import_vitest.describe)("Button", () => {
|
|
8
|
-
(0, import_vitest.test)(`123`, () => {
|
|
9
|
-
(0, import_vitest.expect)(true).toBeTruthy();
|
|
10
|
-
});
|
|
11
|
-
});
|
|
1
|
+
"use strict";var t=require("@tamagui/config-default"),o=require("@tamagui/core"),r=require("vitest");process.env.TAMAGUI_TARGET="web";const u=(0,o.createTamagui)((0,t.getDefaultTamaguiConfig)());(0,r.describe)("Button",()=>{(0,r.test)("123",()=>{(0,r.expect)(!0).toBeTruthy()})});
|
|
12
2
|
//# sourceMappingURL=Button.test.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Button.test.tsx"],
|
|
4
4
|
"sourcesContent": ["process.env.TAMAGUI_TARGET = 'web'\n\nimport { getDefaultTamaguiConfig } from '@tamagui/config-default'\nimport { TamaguiProvider, createTamagui } from '@tamagui/core'\nimport { render } from '@testing-library/react'\nimport { describe, expect, test } from 'vitest'\n\nimport { Button } from '.'\n\nconst conf = createTamagui(getDefaultTamaguiConfig())\n\ndescribe('Button', () => {\n test(`123`, () => {\n expect(true).toBeTruthy()\n })\n\n // test(`Adapts to a when given accessibilityRole=\"link\"`, async () => {\n // const { container } = render(\n // <TamaguiProvider config={conf} defaultTheme=\"light\">\n // <Button href=\"http://google.com\" accessibilityRole=\"link\" />\n // </TamaguiProvider>\n // )\n\n // expect(container.firstChild).toMatchSnapshot()\n // })\n})\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "aAEA,IAAAA,EAAwC,mCACxCC,EAA+C,yBAE/CC,EAAuC,kBALvC,QAAQ,IAAI,eAAiB,MAS7B,MAAMC,KAAO,oBAAc,2BAAwB,CAAC,KAEpD,YAAS,SAAU,IAAM,IACvB,QAAK,MAAO,IAAM,IAChB,UAAO,EAAI,EAAE,WAAW,CAC1B,CAAC,CAWH,CAAC",
|
|
6
|
+
"names": ["import_config_default", "import_core", "import_vitest", "conf"]
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var src_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(src_exports);
|
|
18
|
-
__reExport(src_exports, require("./Button"), module.exports);
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("./Button"),module.exports);
|
|
19
2
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
4
|
"sourcesContent": ["export * from './Button'\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,oBAAd",
|
|
6
|
+
"names": ["src_exports", "__toCommonJS", "__reExport"]
|
|
7
7
|
}
|
package/dist/esm/Button.js
CHANGED
|
@@ -1,182 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getFontSize } from "@tamagui/font-size";
|
|
3
|
-
import { getButtonSized } from "@tamagui/get-button-sized";
|
|
4
|
-
import { useGetThemedIcon } from "@tamagui/helpers-tamagui";
|
|
5
|
-
import { ThemeableStack } from "@tamagui/stacks";
|
|
6
|
-
import { SizableText, wrapChildrenInText } from "@tamagui/text";
|
|
7
|
-
import {
|
|
8
|
-
ButtonNestingContext,
|
|
9
|
-
getVariableValue,
|
|
10
|
-
isRSC,
|
|
11
|
-
spacedChildren,
|
|
12
|
-
styled,
|
|
13
|
-
themeable,
|
|
14
|
-
useMediaPropsActive
|
|
15
|
-
} from "@tamagui/web";
|
|
16
|
-
import { forwardRef, useContext } from "react";
|
|
17
|
-
const NAME = "Button";
|
|
18
|
-
const ButtonFrame = styled(ThemeableStack, {
|
|
19
|
-
name: NAME,
|
|
20
|
-
tag: "button",
|
|
21
|
-
justifyContent: "center",
|
|
22
|
-
alignItems: "center",
|
|
23
|
-
flexWrap: "nowrap",
|
|
24
|
-
flexDirection: "row",
|
|
25
|
-
cursor: "pointer",
|
|
26
|
-
variants: {
|
|
27
|
-
defaultStyle: {
|
|
28
|
-
true: {
|
|
29
|
-
focusable: true,
|
|
30
|
-
hoverTheme: true,
|
|
31
|
-
pressTheme: true,
|
|
32
|
-
backgrounded: true,
|
|
33
|
-
borderWidth: 1,
|
|
34
|
-
borderColor: "transparent",
|
|
35
|
-
pressStyle: {
|
|
36
|
-
borderColor: "transparent"
|
|
37
|
-
},
|
|
38
|
-
hoverStyle: {
|
|
39
|
-
borderColor: "transparent"
|
|
40
|
-
},
|
|
41
|
-
focusStyle: {
|
|
42
|
-
borderColor: "$borderColorFocus"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
size: {
|
|
47
|
-
"...size": getButtonSized
|
|
48
|
-
},
|
|
49
|
-
active: {
|
|
50
|
-
true: {
|
|
51
|
-
hoverStyle: {
|
|
52
|
-
backgroundColor: "$background"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
disabled: {
|
|
57
|
-
true: {
|
|
58
|
-
pointerEvents: "none"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
defaultVariants: {
|
|
63
|
-
size: "$true"
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
const ButtonText = styled(SizableText, {
|
|
67
|
-
name: "ButtonText",
|
|
68
|
-
userSelect: "none",
|
|
69
|
-
cursor: "pointer",
|
|
70
|
-
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
71
|
-
flexGrow: 0,
|
|
72
|
-
flexShrink: 1,
|
|
73
|
-
ellipse: true,
|
|
74
|
-
variants: {
|
|
75
|
-
defaultStyle: {
|
|
76
|
-
true: {
|
|
77
|
-
color: "$color"
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
const ButtonComponent = forwardRef(function Button(props, ref) {
|
|
83
|
-
const {
|
|
84
|
-
props: { unstyled, ...buttonProps }
|
|
85
|
-
} = useButton(props);
|
|
86
|
-
return /* @__PURE__ */ jsx(ButtonFrame, { defaultStyle: !unstyled, ...buttonProps, ref });
|
|
87
|
-
});
|
|
88
|
-
const buttonStaticConfig = {
|
|
89
|
-
inlineProps: /* @__PURE__ */ new Set([
|
|
90
|
-
// text props go here (can't really optimize them, but we never fully extract button anyway)
|
|
91
|
-
// may be able to remove this entirely, as the compiler / runtime have gotten better
|
|
92
|
-
"color",
|
|
93
|
-
"fontWeight",
|
|
94
|
-
"fontSize",
|
|
95
|
-
"fontFamily",
|
|
96
|
-
"fontStyle",
|
|
97
|
-
"letterSpacing",
|
|
98
|
-
"textAlign",
|
|
99
|
-
"unstyled"
|
|
100
|
-
])
|
|
101
|
-
};
|
|
102
|
-
const Button2 = ButtonFrame.extractable(
|
|
103
|
-
themeable(ButtonComponent, ButtonFrame.staticConfig),
|
|
104
|
-
buttonStaticConfig
|
|
105
|
-
);
|
|
106
|
-
function useButton(propsIn, { Text = ButtonText } = { Text: ButtonText }) {
|
|
107
|
-
const {
|
|
108
|
-
children,
|
|
109
|
-
icon,
|
|
110
|
-
iconAfter,
|
|
111
|
-
noTextWrap,
|
|
112
|
-
theme: themeName,
|
|
113
|
-
space,
|
|
114
|
-
spaceFlex,
|
|
115
|
-
scaleIcon = 1,
|
|
116
|
-
scaleSpace = 0.66,
|
|
117
|
-
separator,
|
|
118
|
-
// text props
|
|
119
|
-
color,
|
|
120
|
-
fontWeight,
|
|
121
|
-
letterSpacing,
|
|
122
|
-
fontSize,
|
|
123
|
-
fontFamily,
|
|
124
|
-
fontStyle,
|
|
125
|
-
textAlign,
|
|
126
|
-
textProps,
|
|
127
|
-
...rest
|
|
128
|
-
} = propsIn;
|
|
129
|
-
const isNested = isRSC ? false : useContext(ButtonNestingContext);
|
|
130
|
-
const propsActive = useMediaPropsActive(propsIn);
|
|
131
|
-
const size = propsActive.size || "$true";
|
|
132
|
-
const iconSize = (typeof size === "number" ? size * 0.5 : getFontSize(size)) * scaleIcon;
|
|
133
|
-
const getThemedIcon = useGetThemedIcon({ size: iconSize, color });
|
|
134
|
-
const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon);
|
|
135
|
-
const spaceSize = propsActive.space ?? getVariableValue(iconSize) * scaleSpace;
|
|
136
|
-
const contents = wrapChildrenInText(
|
|
137
|
-
Text,
|
|
138
|
-
propsActive,
|
|
139
|
-
Text === ButtonText ? {
|
|
140
|
-
defaultStyle: !propsIn.unstyled
|
|
141
|
-
} : void 0
|
|
142
|
-
);
|
|
143
|
-
const inner = spacedChildren({
|
|
144
|
-
// a bit arbitrary but scaling to font size is necessary so long as button does
|
|
145
|
-
space: spaceSize,
|
|
146
|
-
spaceFlex,
|
|
147
|
-
separator,
|
|
148
|
-
direction: propsActive.flexDirection === "column" || propsActive.flexDirection === "column-reverse" ? "vertical" : "horizontal",
|
|
149
|
-
children: [themedIcon, ...contents, themedIconAfter]
|
|
150
|
-
});
|
|
151
|
-
const tag = isNested ? "span" : (
|
|
152
|
-
// defaults to <a /> when accessibilityRole = link
|
|
153
|
-
// see https://github.com/tamagui/tamagui/issues/505
|
|
154
|
-
propsIn.accessibilityRole === "link" ? "a" : void 0
|
|
155
|
-
);
|
|
156
|
-
const props = {
|
|
157
|
-
...propsActive.disabled && {
|
|
158
|
-
// in rnw - false still has keyboard tabIndex, undefined = not actually focusable
|
|
159
|
-
focusable: void 0,
|
|
160
|
-
// even with tabIndex unset, it will keep focusStyle on web so disable it here
|
|
161
|
-
focusStyle: {
|
|
162
|
-
borderColor: "$background"
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
tag,
|
|
166
|
-
...rest,
|
|
167
|
-
children: isRSC ? inner : /* @__PURE__ */ jsx(ButtonNestingContext.Provider, { value: true, children: inner })
|
|
168
|
-
};
|
|
169
|
-
return {
|
|
170
|
-
spaceSize,
|
|
171
|
-
isNested,
|
|
172
|
-
props
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
export {
|
|
176
|
-
Button2 as Button,
|
|
177
|
-
ButtonFrame,
|
|
178
|
-
ButtonText,
|
|
179
|
-
buttonStaticConfig,
|
|
180
|
-
useButton
|
|
181
|
-
};
|
|
1
|
+
import{jsx as S}from"react/jsx-runtime";import{getFontSize as A}from"@tamagui/font-size";import{getButtonSized as k}from"@tamagui/get-button-sized";import{useGetThemedIcon as w}from"@tamagui/helpers-tamagui";import{ThemeableStack as $}from"@tamagui/stacks";import{SizableText as E,wrapChildrenInText as N}from"@tamagui/text";import{ButtonNestingContext as d,getVariableValue as W,isRSC as f,spacedChildren as G,styled as b,themeable as D,useMediaPropsActive as R}from"@tamagui/web";import{forwardRef as V,useContext as M}from"react";const J="Button",i=b($,{name:J,tag:"button",justifyContent:"center",alignItems:"center",flexWrap:"nowrap",flexDirection:"row",cursor:"pointer",variants:{defaultStyle:{true:{focusable:!0,hoverTheme:!0,pressTheme:!0,backgrounded:!0,borderWidth:1,borderColor:"transparent",pressStyle:{borderColor:"transparent"},hoverStyle:{borderColor:"transparent"},focusStyle:{borderColor:"$borderColorFocus"}}},size:{"...size":k},active:{true:{hoverStyle:{backgroundColor:"$background"}}},disabled:{true:{pointerEvents:"none"}}},defaultVariants:{size:"$true"}}),c=b(E,{name:"ButtonText",userSelect:"none",cursor:"pointer",flexGrow:0,flexShrink:1,ellipse:!0,variants:{defaultStyle:{true:{color:"$color"}}}}),O=V(function(o,l){const{props:{unstyled:n,...r}}=j(o);return S(i,{defaultStyle:!n,...r,ref:l})}),X={inlineProps:new Set(["color","fontWeight","fontSize","fontFamily","fontStyle","letterSpacing","textAlign","unstyled"])},de=i.extractable(D(O,i.staticConfig),X);function j(t,{Text:o=c}={Text:c}){const{children:l,icon:n,iconAfter:r,noTextWrap:q,theme:H,space:K,spaceFlex:x,scaleIcon:y=1,scaleSpace:h=.66,separator:g,color:C,fontWeight:L,letterSpacing:Q,fontSize:U,fontFamily:Y,fontStyle:Z,textAlign:_,textProps:ee,...P}=t,a=f?!1:M(d),e=R(t),s=e.size||"$true",u=(typeof s=="number"?s*.5:A(s))*y,T=w({size:u,color:C}),[B,z]=[n,r].map(T),p=e.space??W(u)*h,v=N(o,e,o===c?{defaultStyle:!t.unstyled}:void 0),m=G({space:p,spaceFlex:x,separator:g,direction:e.flexDirection==="column"||e.flexDirection==="column-reverse"?"vertical":"horizontal",children:[B,...v,z]}),F=a?"span":t.accessibilityRole==="link"?"a":void 0,I={...e.disabled&&{focusable:void 0,focusStyle:{borderColor:"$background"}},tag:F,...P,children:f?m:S(d.Provider,{value:!0,children:m})};return{spaceSize:p,isNested:a,props:I}}export{de as Button,i as ButtonFrame,c as ButtonText,X as buttonStaticConfig,j as useButton};
|
|
182
2
|
//# sourceMappingURL=Button.js.map
|
package/dist/esm/Button.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Button.tsx"],
|
|
4
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 alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n\n variants: {\n defaultStyle: {\n true: {\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 },\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 size: '$true',\n },\n})\n\nexport const ButtonText = styled(SizableText, {\n name: 'ButtonText',\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\n variants: {\n defaultStyle: {\n true: {\n color: '$color',\n },\n },\n },\n})\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(\n props,\n ref\n) {\n const {\n props: { unstyled, ...buttonProps },\n } = useButton(props)\n return <ButtonFrame defaultStyle={!unstyled} {...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 defaultStyle: !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 spaceS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e,CACrD,CAAC,EAGKI,EAAMV,EACR,OAGFrB,EAAQ,oBAAsB,OAC5B,IACA,OAEEP,EAAQ,CACZ,GAAI6B,EAAY,UAAY,CAE1B,UAAW,OAEX,WAAY,CACV,YAAa,aACf,CACF,EACA,IAAAS,EACA,GAAGX,EACH,SAAUtC,EACRgD,EAEAzD,EAACO,EAAqB,SAArB,CAA8B,MAAO,GAAO,SAAAkD,EAAM,CAEvD,EAEA,MAAO,CACL,UAAAF,EACA,SAAAP,EACA,MAAA5B,CACF,CACF",
|
|
6
|
+
"names": ["jsx", "getFontSize", "getButtonSized", "useGetThemedIcon", "ThemeableStack", "SizableText", "wrapChildrenInText", "ButtonNestingContext", "getVariableValue", "isRSC", "spacedChildren", "styled", "themeable", "useMediaPropsActive", "forwardRef", "useContext", "NAME", "ButtonFrame", "ButtonText", "ButtonComponent", "props", "ref", "unstyled", "buttonProps", "useButton", "buttonStaticConfig", "Button", "propsIn", "Text", "children", "icon", "iconAfter", "noTextWrap", "themeName", "space", "spaceFlex", "scaleIcon", "scaleSpace", "separator", "color", "fontWeight", "letterSpacing", "fontSize", "fontFamily", "fontStyle", "textAlign", "textProps", "rest", "isNested", "propsActive", "size", "iconSize", "getThemedIcon", "themedIcon", "themedIconAfter", "spaceSize", "contents", "inner", "tag"]
|
|
7
7
|
}
|